First post, by thp
I've recently added support for MPU-401 to my game-in-development (Vogons thread), but it does not work properly on real hardware, so I thought I'd post here in the audio forum with some programming-related questions.
I followed Programming the MPU-401 and the MIDI Specification as reference for implementing support.
This works fine on DOSBox with MPU-401 emulation, backed by Apple's SoftSynth on macOS. However, on real hardware (SB16 + Roland SCB-7 WaveBlaster daughterboard) I get weird results (missing/wrong notes?).
Is there any additional initialisation that needs to be done in this case? Here's what I do:
Wait for 0x40 bit to be cleared reading from 0x331 ("DATA READ READY" bit cleared).
Send command 0xFF to port 0x331.
Wait for 0x80 bit to be cleared reading from 0x331 ("DATA SET READY" bit cleared).
Read from 0x330 and check if it's 0xFE (acknowledgement), if not, redo last step and this step.
Wait for 0x40 bit to be cleared (see first step).
Send command 0x3F to port 0x331.
At this stage, the MPU-401 should be in UART mode, right?
Then I write bytes (one byte at a time) of MIDI data, to port 0x330, without any delay (except of course for waiting between events).
For the drums/percussion I just write notes to MIDI channel 10 (index 9), for everything else, I send a program change (0xC0-0xC9) for each channel I want to play music on. Also, something that might be important in my case: Every instrument (usually two, a voice and a bass) is fixed to a MIDI channel and only gets the program change at the beginning of the song, and then I just do note on events and note on events with velocity zero (which should be the same as note off?).
Is it kind of guaranteed that a WaveBlaster daughterboard can play multiple notes (different MIDI note) simultaneously on a given channel, or would I need to make sure that when playing notes simultaneously, I distribute them among the 16 MIDI channels?