Browse Source

Make SFZero and JSFX not rely on VLAs

Signed-off-by: falkTX <falktx@falktx.com>
pull/1780/head
falkTX 1 year ago
parent
commit
1dae245eff
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 17 additions and 15 deletions
  1. +9
    -8
      source/backend/plugin/CarlaPluginJSFX.cpp
  2. +8
    -7
      source/backend/plugin/CarlaPluginSFZero.cpp

+ 9
- 8
source/backend/plugin/CarlaPluginJSFX.cpp View File

@@ -792,9 +792,10 @@ public:
case kEngineEventTypeMidi: {
const EngineMidiEvent& midiEvent(event.midi);

const uint8_t* const midiData(midiEvent.size > EngineMidiEvent::kDataSize ? midiEvent.dataExt : midiEvent.data);
if (midiEvent.size > EngineMidiEvent::kDataSize)
continue;

uint8_t status = uint8_t(MIDI_GET_STATUS_FROM_DATA(midiData));
uint8_t status = uint8_t(MIDI_GET_STATUS_FROM_DATA(midiEvent.data));

if ((status == MIDI_STATUS_NOTE_OFF || status == MIDI_STATUS_NOTE_ON) && (pData->options & PLUGIN_OPTION_SKIP_SENDING_NOTES))
continue;
@@ -808,28 +809,28 @@ public:
continue;

// Fix bad note-off
if (status == MIDI_STATUS_NOTE_ON && midiData[2] == 0)
if (status == MIDI_STATUS_NOTE_ON && midiEvent.data[2] == 0)
status = MIDI_STATUS_NOTE_OFF;

// put back channel in data
uint8_t midiData2[midiEvent.size];
uint8_t midiData2[EngineMidiEvent::kDataSize];
midiData2[0] = uint8_t(status | (event.channel & MIDI_CHANNEL_BIT));
std::memcpy(midiData2+1, midiData+1, static_cast<std::size_t>(midiEvent.size-1));
std::memcpy(midiData2 + 1, midiEvent.data + 1, static_cast<std::size_t>(midiEvent.size - 1));

ysfx_midi_event_t yevent;
yevent.bus = midiEvent.port;
yevent.offset = event.time;
yevent.size = midiEvent.size;
yevent.data = midiData;
yevent.data = midiData2;
ysfx_send_midi(fEffect, &yevent);

if (status == MIDI_STATUS_NOTE_ON)
{
pData->postponeNoteOnRtEvent(true, event.channel, midiData[1], midiData[2]);
pData->postponeNoteOnRtEvent(true, event.channel, midiEvent.data[1], midiEvent.data[2]);
}
else if (status == MIDI_STATUS_NOTE_OFF)
{
pData->postponeNoteOffRtEvent(true, event.channel, midiData[1]);
pData->postponeNoteOffRtEvent(true, event.channel, midiEvent.data[1]);
}
} break;
} // switch (event.type)


+ 8
- 7
source/backend/plugin/CarlaPluginSFZero.cpp View File

@@ -510,9 +510,10 @@ public:
case kEngineEventTypeMidi: {
const EngineMidiEvent& midiEvent(event.midi);

const uint8_t* const midiData(midiEvent.size > EngineMidiEvent::kDataSize ? midiEvent.dataExt : midiEvent.data);
if (midiEvent.size > EngineMidiEvent::kDataSize)
continue;

uint8_t status = uint8_t(MIDI_GET_STATUS_FROM_DATA(midiData));
uint8_t status = uint8_t(MIDI_GET_STATUS_FROM_DATA(midiEvent.data));

if ((status == MIDI_STATUS_NOTE_OFF || status == MIDI_STATUS_NOTE_ON) && (pData->options & PLUGIN_OPTION_SKIP_SENDING_NOTES))
continue;
@@ -526,13 +527,13 @@ public:
continue;

// Fix bad note-off
if (status == MIDI_STATUS_NOTE_ON && midiData[2] == 0)
if (status == MIDI_STATUS_NOTE_ON && midiEvent.data[2] == 0)
status = MIDI_STATUS_NOTE_OFF;

// put back channel in data
uint8_t midiData2[midiEvent.size];
uint8_t midiData2[EngineMidiEvent::kDataSize];
midiData2[0] = uint8_t(status | (event.channel & MIDI_CHANNEL_BIT));
std::memcpy(midiData2+1, midiData+1, static_cast<std::size_t>(midiEvent.size-1));
std::memcpy(midiData2 + 1, midiEvent.data + 1, static_cast<std::size_t>(midiEvent.size - 1));

const MidiMessage midiMessage(midiData2, static_cast<int>(midiEvent.size), 0.0);

@@ -540,11 +541,11 @@ public:

if (status == MIDI_STATUS_NOTE_ON)
{
pData->postponeNoteOnRtEvent(true, event.channel, midiData[1], midiData[2]);
pData->postponeNoteOnRtEvent(true, event.channel, midiEvent.data[1], midiEvent.data[2]);
}
else if (status == MIDI_STATUS_NOTE_OFF)
{
pData->postponeNoteOffRtEvent(true, event.channel, midiData[1]);
pData->postponeNoteOffRtEvent(true, event.channel, midiEvent.data[1]);
}
} break;
}


Loading…
Cancel
Save