Added generic send() option to MidiChannel.

This circumvents problems doing generic send()
calls to MidiDrivers that support more than
16 MIDI channels (i.e. Adlib). Because of the
way it interacts with MidiDriver, Simon could
have run into a problem if it tried to
allocate more than 15 Adlib music channels
(though this would only happen in very, VERY
rare circumstances).

Also fixed a problem with the channel
numbering scheme used by MidiDriver_Adlib,
in particular the percussion channel number.

svn-id: r9604
This commit is contained in:
Jamieson Christian 2003-08-08 11:54:24 +00:00
parent f1a3253fa2
commit 154e872d5a
5 changed files with 23 additions and 5 deletions

View file

@ -102,6 +102,8 @@ public:
byte getNumber() { return _channel; }
void release() { _allocated = false; }
void send (uint32 b);
// Regular messages
void noteOff(byte note);
void noteOn(byte note, byte velocity);
@ -559,6 +561,7 @@ public:
int open();
void close();
void send(uint32 b);
void send (byte channel, uint32 b); // Supports higher than channel 15
uint32 property(int prop, uint32 param);
void setPitchBendRange(byte channel, uint range);
@ -646,6 +649,10 @@ MidiDriver *AdlibPart::device() {
return _owner;
}
void AdlibPart::send (uint32 b) {
_owner->send (_channel, b);
}
void AdlibPart::noteOff(byte note) {
_owner->part_key_off(this, note);
}
@ -830,9 +837,9 @@ MidiDriver_ADLIB::MidiDriver_ADLIB(SoundMixer *mixer)
}
for (i = 0; i < ARRAYSIZE(_parts); ++i) {
_parts[i].init(this, i);
_parts[i].init(this, i + ((i >= 9) ? 1 : 0));
}
_percussion.init(this, 0);
_percussion.init(this, 9);
}
int MidiDriver_ADLIB::open() {
@ -888,12 +895,15 @@ void MidiDriver_ADLIB::close() {
_isOpen = false;
}
void MidiDriver_ADLIB::send(uint32 b) {
void MidiDriver_ADLIB::send (uint32 b) {
send (b & 0xF, b & 0xFFFFFFF0);
}
void MidiDriver_ADLIB::send (byte chan, uint32 b) {
//byte param3 = (byte) ((b >> 24) & 0xFF);
byte param2 = (byte) ((b >> 16) & 0xFF);
byte param1 = (byte) ((b >> 8) & 0xFF);
byte cmd = (byte) (b & 0xF0);
byte chan = (byte) (b & 0x0F);
AdlibPart *part;
if (chan == 9)