|
From: | D.Bartolec |
Subject: | [fluid-dev] Fix for problem with CC changes to Bank MSB |
Date: | Sun, 5 Apr 2009 00:07:29 +1100 |
I've discovered
it after playing some MIDI files that would send bank LSB:0 for drum channel
without sending bank MSB at all.
This would cause drum tracks to change to MSB:0
LSB:0.
Here is the fix:
Index:
src/fluid_chan.c
=================================================================== --- src/fluid_chan.c (revision 169) +++ src/fluid_chan.c (working copy) @@ -74,7 +74,6 @@ chan->channel_pressure = 0; chan->pitch_bend = 0x2000; /* Range is 0x4000, pitch bend wheel starts in centered position */ chan->pitch_wheel_sensitivity = 2; /* two semi-tones */ - chan->bank_msb = 0; for (i = 0; i < GEN_LAST; i++) { chan->gen[i] = 0.0f; @@ -204,28 +203,24 @@ case BANK_SELECT_MSB: { - chan->bank_msb = (unsigned char) (value & 0x7f); -/* printf("** bank select msb recieved: %d\n", value); */ + unsigned char bank_msb = (unsigned char) (value & 0x7f); + unsigned char bank_lsb = (unsigned char) (chan->banknum & 0x7F); - /* I fixed the handling of a MIDI bank select controller 0, - e.g., bank select MSB (or "coarse" bank select according to - my spec). Prior to this fix a channel's bank number was only - changed upon reception of MIDI bank select controller 32, - e.g, bank select LSB (or "fine" bank-select according to my - spec). [KLE] + if ( (chan == 9) && (bank_msb == 0)) + { + bank_msb = 1; /* Ignore CC value and set the default MSB value for drum channel */ + } - FIXME: is this correct? [PH] */ - fluid_channel_set_banknum(chan, (unsigned int)(value & 0x7f)); /* KLE */ + fluid_channel_set_banknum(chan, (unsigned int)((bank_msb << 7) | bank_lsb)); /* KLE */ } break; case BANK_SELECT_LSB: { - /* FIXME: according to the Downloadable Sounds II specification, - bit 31 should be set when we receive the message on channel - 10 (drum channel) */ - fluid_channel_set_banknum(chan, (((unsigned int) value & 0x7f) - + ((unsigned int) chan->bank_msb << 7))); + unsigned char bank_msb = (unsigned char) ((chan->banknum >> 7) & 0x7f); + unsigned char bank_lsb = (unsigned char) (value & 0x7f); + + fluid_channel_set_banknum(chan, (unsigned int)((bank_msb << 7) | bank_lsb)); } break; Index: src/fluid_chan.h =================================================================== --- src/fluid_chan.h (revision 169) +++ src/fluid_chan.h (working copy) @@ -44,8 +44,6 @@ /* controller values */ short cc[128]; - /* cached values of last MSB values of MSB/LSB controllers */ - unsigned char bank_msb; int interp_method; /* the micro-tuning */ |
[Prev in Thread] | Current Thread | [Next in Thread] |