Fix for SYSEX treatment.

pull/195/head
Holger Wirtz 3 years ago
parent ffa0bfd096
commit c7ca66ab1d
  1. 2
      CMSIS_5
  2. 213
      src/mididevice.cpp

@ -1 +1 @@
Subproject commit 18205c6c2b68e7e96f40dc941c47efdbdd9f7d01 Subproject commit a3936b6605ad0a78680d6a25d8ebc27fe156f31e

@ -149,130 +149,133 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
u8 ucChannel = ucStatus & 0x0F; u8 ucChannel = ucStatus & 0x0F;
u8 ucType = ucStatus >> 4; u8 ucType = ucStatus >> 4;
for (unsigned nTG = 0; nTG < CConfig::ToneGenerators; nTG++) if(ucStatus == MIDI_SYSTEM_EXCLUSIVE) // No MIDI channel information in SYSEX
HandleSystemExclusive(pMessage, nLength, ucChannel);
else
{ {
if ( m_ChannelMap[nTG] == ucChannel for (unsigned nTG = 0; nTG < CConfig::ToneGenerators; nTG++)
|| m_ChannelMap[nTG] == OmniMode)
{ {
switch (ucType) if ( m_ChannelMap[nTG] == ucChannel
|| m_ChannelMap[nTG] == OmniMode)
{ {
case MIDI_NOTE_ON: switch (ucType)
if (nLength < 3)
{ {
case MIDI_NOTE_ON:
if (nLength < 3)
{
break;
}
if (pMessage[2] > 0)
{
if (pMessage[2] <= 127)
{
m_pSynthesizer->keydown (pMessage[1],
pMessage[2], nTG);
}
}
else
{
m_pSynthesizer->keyup (pMessage[1], nTG);
}
break; break;
}
case MIDI_NOTE_OFF:
if (pMessage[2] > 0) if (nLength < 3)
{
if (pMessage[2] <= 127)
{ {
m_pSynthesizer->keydown (pMessage[1], break;
pMessage[2], nTG);
} }
}
else
{
m_pSynthesizer->keyup (pMessage[1], nTG); m_pSynthesizer->keyup (pMessage[1], nTG);
}
break;
case MIDI_NOTE_OFF:
if (nLength < 3)
{
break;
}
m_pSynthesizer->keyup (pMessage[1], nTG);
break;
case MIDI_CONTROL_CHANGE:
if (nLength < 3)
{
break;
}
switch (pMessage[1])
{
case MIDI_CC_MODULATION:
m_pSynthesizer->setModWheel (pMessage[2], nTG);
m_pSynthesizer->ControllersRefresh (nTG);
break;
case MIDI_CC_VOLUME:
m_pSynthesizer->SetVolume (pMessage[2], nTG);
break;
case MIDI_CC_PAN_POSITION:
m_pSynthesizer->SetPan (pMessage[2], nTG);
break;
case MIDI_CC_BANK_SELECT_LSB:
m_pSynthesizer->BankSelectLSB (pMessage[2], nTG);
break;
case MIDI_CC_BANK_SUSTAIN:
m_pSynthesizer->setSustain (pMessage[2] >= 64, nTG);
break; break;
case MIDI_CC_RESONANCE: case MIDI_CONTROL_CHANGE:
m_pSynthesizer->SetResonance (maplong (pMessage[2], 0, 127, 0, 99), nTG); if (nLength < 3)
break;
case MIDI_CC_FREQUENCY_CUTOFF:
m_pSynthesizer->SetCutoff (maplong (pMessage[2], 0, 127, 0, 99), nTG);
break;
case MIDI_CC_REVERB_LEVEL:
m_pSynthesizer->SetReverbSend (maplong (pMessage[2], 0, 127, 0, 99), nTG);
break;
case MIDI_CC_DETUNE_LEVEL:
if (pMessage[2] == 0)
{ {
// "0 to 127, with 0 being no celeste (detune) effect applied at all." break;
m_pSynthesizer->SetMasterTune (0, nTG);
} }
else
switch (pMessage[1])
{ {
m_pSynthesizer->SetMasterTune (maplong (pMessage[2], 1, 127, -99, 99), nTG); case MIDI_CC_MODULATION:
m_pSynthesizer->setModWheel (pMessage[2], nTG);
m_pSynthesizer->ControllersRefresh (nTG);
break;
case MIDI_CC_VOLUME:
m_pSynthesizer->SetVolume (pMessage[2], nTG);
break;
case MIDI_CC_PAN_POSITION:
m_pSynthesizer->SetPan (pMessage[2], nTG);
break;
case MIDI_CC_BANK_SELECT_LSB:
m_pSynthesizer->BankSelectLSB (pMessage[2], nTG);
break;
case MIDI_CC_BANK_SUSTAIN:
m_pSynthesizer->setSustain (pMessage[2] >= 64, nTG);
break;
case MIDI_CC_RESONANCE:
m_pSynthesizer->SetResonance (maplong (pMessage[2], 0, 127, 0, 99), nTG);
break;
case MIDI_CC_FREQUENCY_CUTOFF:
m_pSynthesizer->SetCutoff (maplong (pMessage[2], 0, 127, 0, 99), nTG);
break;
case MIDI_CC_REVERB_LEVEL:
m_pSynthesizer->SetReverbSend (maplong (pMessage[2], 0, 127, 0, 99), nTG);
break;
case MIDI_CC_DETUNE_LEVEL:
if (pMessage[2] == 0)
{
// "0 to 127, with 0 being no celeste (detune) effect applied at all."
m_pSynthesizer->SetMasterTune (0, nTG);
}
else
{
m_pSynthesizer->SetMasterTune (maplong (pMessage[2], 1, 127, -99, 99), nTG);
}
break;
case MIDI_CC_ALL_SOUND_OFF:
m_pSynthesizer->panic (pMessage[2], nTG);
break;
case MIDI_CC_ALL_NOTES_OFF:
m_pSynthesizer->notesOff (pMessage[2], nTG);
break;
} }
break; break;
case MIDI_CC_ALL_SOUND_OFF: case MIDI_PROGRAM_CHANGE:
m_pSynthesizer->panic (pMessage[2], nTG); // do program change only if enabled in config
break; if( m_pConfig->GetMIDIRXProgramChange() )
m_pSynthesizer->ProgramChange (pMessage[1], nTG);
case MIDI_CC_ALL_NOTES_OFF:
m_pSynthesizer->notesOff (pMessage[2], nTG);
break; break;
}
break; case MIDI_PITCH_BEND: {
if (nLength < 3)
case MIDI_PROGRAM_CHANGE: {
// do program change only if enabled in config break;
if( m_pConfig->GetMIDIRXProgramChange() ) }
m_pSynthesizer->ProgramChange (pMessage[1], nTG);
break; s16 nValue = pMessage[1];
nValue |= (s16) pMessage[2] << 7;
case MIDI_PITCH_BEND: { nValue -= 0x2000;
if (nLength < 3)
{ m_pSynthesizer->setPitchbend (nValue, nTG);
} break;
default:
break; break;
} }
s16 nValue = pMessage[1];
nValue |= (s16) pMessage[2] << 7;
nValue -= 0x2000;
m_pSynthesizer->setPitchbend (nValue, nTG);
} break;
default:
break;
} }
} }
else if(ucStatus == MIDI_SYSTEM_EXCLUSIVE) // No MIDI channel information in SYSEX
HandleSystemExclusive(pMessage, nLength, ucChannel);
} }
} }

Loading…
Cancel
Save