Ticket #8940: adlib-percussion.patch
File adlib-percussion.patch, 2.8 KB (added by , 16 years ago) |
---|
-
sound/softsynth/adlib.cpp
143 143 void init(MidiDriver_ADLIB *owner, byte channel); 144 144 145 145 public: 146 ~AdlibPercussionChannel(); 147 146 148 void noteOff(byte note); 147 149 void noteOn(byte note, byte velocity); 148 150 void programChange(byte program) { } 149 151 void pitchBend(int16 bend) { } 150 152 151 153 // Control Change messages 152 void controlChange(byte control, byte value) { }153 154 void modulationWheel(byte value) { } 154 155 void pitchBendFactor(byte value) { } 155 156 void detune(byte value) { } … … 157 158 void sustain(bool value) { } 158 159 159 160 // SysEx messages 160 void sysEx_customInstrument(uint32 type, const byte *instr) { } 161 void sysEx_customInstrument(uint32 type, const byte *instr); 162 163 private: 164 byte _notes[256]; 165 AdlibInstrument *_customInstruments[256]; 161 166 }; 162 167 163 168 struct Struct10 { … … 775 780 776 781 // MidiChannel method implementations for percussion 777 782 783 AdlibPercussionChannel::~AdlibPercussionChannel() { 784 for (int i = 0; i < ARRAYSIZE(_customInstruments); ++i) { 785 delete _customInstruments[i]; 786 } 787 } 788 778 789 void AdlibPercussionChannel::init(MidiDriver_ADLIB *owner, byte channel) { 779 790 AdlibPart::init(owner, channel); 780 791 _pri_eff = 0; 781 792 _vol_eff = 127; 793 794 // Initialize the custom instruments data 795 memset(_notes, 0, sizeof(_notes)); 796 memset(_customInstruments, 0, sizeof(_customInstruments)); 782 797 } 783 798 784 799 void AdlibPercussionChannel::noteOff(byte note) { … … 797 812 } 798 813 799 814 void AdlibPercussionChannel::noteOn(byte note, byte velocity) { 800 byte key = gm_percussion_lookup[note]; 801 if (key == 0xFF) { 802 debug(2, "No FM map for GM percussion key %d", (int) note); 815 AdlibInstrument *inst = NULL; 816 817 // The custom instruments have priority over the default mapping 818 inst = _customInstruments[note]; 819 if (inst) 820 note = _notes[note]; 821 822 if (!inst) { 823 // Use the default GM to FM mapping as a fallback as a fallback 824 byte key = gm_percussion_lookup[note]; 825 if (key != 0xFF) 826 inst = (AdlibInstrument *)&gm_percussion_to_fm[key]; 827 } 828 829 if (!inst) { 830 debug(2, "No instrument FM definition for GM percussion key %d", (int)note); 803 831 return; 804 832 } 805 _owner->part_key_on(this, (AdlibInstrument *) &gm_percussion_to_fm[key], note, velocity); 833 834 _owner->part_key_on(this, inst, note, velocity); 806 835 } 807 836 837 void AdlibPercussionChannel::sysEx_customInstrument(uint32 type, const byte *instr) { 838 if (type == 'ADLP') { 839 byte note = *instr; 840 _notes[note] = *(instr + 1); 841 842 // Allocate memory for the new instruments 843 if (!_customInstruments[note]) { 844 _customInstruments[note] = new AdlibInstrument; 845 } 846 847 // Save the new instrument data 848 memcpy(_customInstruments[note], instr + 2, sizeof(AdlibInstrument)); 849 } 850 } 851 808 852 // MidiDriver method implementations 809 853 810 854 MidiDriver_ADLIB::MidiDriver_ADLIB(Audio::Mixer *mixer)