From 51a7cb19a8656c91baf616df5986d8e4c4cce97d Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Mon, 4 Jun 2018 03:30:28 +0300 Subject: Fixed bend sensitivity processing --- src/adlmidi_midiplay.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/adlmidi_midiplay.cpp') diff --git a/src/adlmidi_midiplay.cpp b/src/adlmidi_midiplay.cpp index 3c94d76..2413f39 100644 --- a/src/adlmidi_midiplay.cpp +++ b/src/adlmidi_midiplay.cpp @@ -1400,14 +1400,16 @@ void MIDIplay::realTime_PatchChange(uint8_t channel, uint8_t patch) void MIDIplay::realTime_PitchBend(uint8_t channel, uint16_t pitch) { channel = channel % 16; - Ch[channel].bend = (int(pitch) - 8192) * Ch[channel].bendsense; + Ch[channel].bendSrc = (int(pitch) - 8192); + Ch[channel].bend = Ch[channel].bendSrc * Ch[channel].bendsense; NoteUpdate_All(channel, Upd_Pitch); } void MIDIplay::realTime_PitchBend(uint8_t channel, uint8_t msb, uint8_t lsb) { channel = channel % 16; - Ch[channel].bend = (int(lsb) + int(msb) * 128 - 8192) * Ch[channel].bendsense; + Ch[channel].bendSrc = (int(lsb) + int(msb) * 128 - 8192); + Ch[channel].bend = Ch[channel].bendSrc * Ch[channel].bendsense; NoteUpdate_All(channel, Upd_Pitch); } @@ -1641,7 +1643,7 @@ void MIDIplay::NoteUpdate(uint16_t MidCh, #else # define BEND_COEFFICIENT 172.4387 #endif - opl.NoteOn(c, BEND_COEFFICIENT * std::exp(0.057762265 * (tone + bend + phase))); + opl.NoteOn(c, BEND_COEFFICIENT * std::exp(0.057762265 * (static_cast(tone) + bend + phase))); #undef BEND_COEFFICIENT if(hooks.onNote) hooks.onNote(hooks.onNote_userData, c, tone, midiins, vol, Ch[MidCh].bend); @@ -2388,10 +2390,12 @@ void MIDIplay::SetRPN(unsigned MidCh, unsigned value, bool MSB) case 0x0000 + 0*0x10000 + 1*0x20000: // Pitch-bender sensitivity Ch[MidCh].bendsense_msb = value; Ch[MidCh].updateBendSensitivity(); + NoteUpdate_All(MidCh, Upd_Pitch); break; case 0x0000 + 0*0x10000 + 0*0x20000: // Pitch-bender sensitivity LSB Ch[MidCh].bendsense_lsb = value; Ch[MidCh].updateBendSensitivity(); + NoteUpdate_All(MidCh, Upd_Pitch); break; case 0x0108 + 1*0x10000 + 1*0x20000: // Vibrato speed if(value == 64) Ch[MidCh].vibspeed = 1.0; -- cgit v1.2.3