diff options
Diffstat (limited to 'src/adlmidi_midiplay.cpp')
-rw-r--r-- | src/adlmidi_midiplay.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/adlmidi_midiplay.cpp b/src/adlmidi_midiplay.cpp index 15dee53..c1f40d0 100644 --- a/src/adlmidi_midiplay.cpp +++ b/src/adlmidi_midiplay.cpp @@ -909,6 +909,7 @@ void MIDIplay::realTime_ResetState() chan.lastlrpn = 0; chan.lastmrpn = 0; chan.nrpn = false; + chan.brightness = 127; NoteUpdate_All(uint16_t(ch), Upd_All); NoteUpdate_All(uint16_t(ch), Upd_Off); } @@ -1221,11 +1222,14 @@ void MIDIplay::realTime_Controller(uint8_t channel, uint8_t type, uint8_t value) NoteUpdate_All(channel, Upd_Volume); break; + case 74: // Change brightness + Ch[channel].brightness = value; + NoteUpdate_All(channel, Upd_Volume); + break; + case 64: // Enable/disable sustain Ch[channel].sustain = value; - if(!value) KillSustainingNotes(channel); - break; case 11: // Change expression (another volume factor) @@ -1252,6 +1256,7 @@ void MIDIplay::realTime_Controller(uint8_t channel, uint8_t type, uint8_t value) Ch[channel].vibdelay = 0; Ch[channel].panning = 0x30; Ch[channel].portamento = 0; + Ch[channel].brightness = 127; //UpdatePortamento(MidCh); NoteUpdate_All(channel, Upd_Pan + Upd_Volume + Upd_Pitch); // Kill all sustained notes @@ -1450,6 +1455,7 @@ void MIDIplay::NoteUpdate(uint16_t MidCh, if(props_mask & Upd_Volume) { uint32_t volume; + uint8_t brightness = Ch[MidCh].brightness; switch(opl.m_volumeScale) { @@ -1472,12 +1478,11 @@ void MIDIplay::NoteUpdate(uint16_t MidCh, else { // The formula below: SOLVE(V=127^3 * 2^( (A-63.49999) / 8), A) - volume = volume > 8725 ? static_cast<unsigned int>(std::log((double)volume) * 11.541561 + (0.5 - 104.22845)) : 0; + volume = volume > 8725 ? static_cast<uint32_t>(std::log(static_cast<double>(volume)) * 11.541561 + (0.5 - 104.22845)) : 0; // The incorrect formula below: SOLVE(V=127^3 * (2^(A/63)-1), A) //opl.Touch_Real(c, volume>11210 ? 91.61112 * std::log(4.8819E-7*volume + 1.0)+0.5 : 0); } - - opl.Touch_Real(c, volume); + opl.Touch_Real(c, volume, brightness); //opl.Touch(c, volume); } break; @@ -1487,7 +1492,7 @@ void MIDIplay::NoteUpdate(uint16_t MidCh, volume = 2 * ((Ch[MidCh].volume * Ch[MidCh].expression) * 127 / 16129) + 1; //volume = 2 * (Ch[MidCh].volume) + 1; volume = (DMX_volume_mapping_table[vol] * volume) >> 9; - opl.Touch_Real(c, volume); + opl.Touch_Real(c, volume, brightness); } break; @@ -1496,7 +1501,7 @@ void MIDIplay::NoteUpdate(uint16_t MidCh, volume = ((Ch[MidCh].volume * Ch[MidCh].expression) * 127 / 16129); volume = ((64 * (vol + 0x80)) * volume) >> 15; //volume = ((63 * (vol + 0x80)) * Ch[MidCh].volume) >> 15; - opl.Touch_Real(c, volume); + opl.Touch_Real(c, volume, brightness); } break; @@ -1505,7 +1510,7 @@ void MIDIplay::NoteUpdate(uint16_t MidCh, //volume = 63 - W9X_volume_mapping_table[(((vol * Ch[MidCh].volume /** Ch[MidCh].expression*/) * 127 / 16129 /*2048383*/) >> 2)]; volume = 63 - W9X_volume_mapping_table[(((vol * Ch[MidCh].volume * Ch[MidCh].expression) * 127 / 2048383) >> 2)]; //volume = W9X_volume_mapping_table[vol >> 2] + volume; - opl.Touch_Real(c, volume); + opl.Touch_Real(c, volume, brightness); } break; } |