Browse Source

Implement forgotteng "Send MIDI CC" for LV2 plugins; misc fixing

tags/1.9.4
falkTX 11 years ago
parent
commit
49f6fccb3c
2 changed files with 37 additions and 9 deletions
  1. +10
    -3
      source/backend/engine/CarlaEngineJack.cpp
  2. +27
    -6
      source/backend/plugin/Lv2Plugin.cpp

+ 10
- 3
source/backend/engine/CarlaEngineJack.cpp View File

@@ -1275,6 +1275,8 @@ protected:

if (MIDI_IS_STATUS_CONTROL_CHANGE(midiStatus))
{
CARLA_ASSERT(jackEvent.size == 2 || jackEvent.size == 3);

const uint8_t midiControl = jackEvent.buffer[1];
engineEvent->type = kEngineEventTypeControl;

@@ -1300,6 +1302,8 @@ protected:
}
else
{
CARLA_ASSERT(jackEvent.size == 3);

const uint8_t midiValue = jackEvent.buffer[2];

engineEvent->ctrl.type = kEngineControlEventTypeParameter;
@@ -1309,6 +1313,8 @@ protected:
}
else if (MIDI_IS_STATUS_PROGRAM_CHANGE(midiStatus))
{
CARLA_ASSERT(jackEvent.size == 2);

const uint8_t midiProgram = jackEvent.buffer[1];
engineEvent->type = kEngineEventTypeControl;

@@ -1320,10 +1326,11 @@ protected:
{
engineEvent->type = kEngineEventTypeMidi;

carla_copy<uint8_t>(engineEvent->midi.data, jackEvent.buffer, jackEvent.size);

engineEvent->midi.data[0] = midiStatus;
engineEvent->midi.size = static_cast<uint8_t>(jackEvent.size);

if (jackEvent.size > 1)
carla_copy<uint8_t>(engineEvent->midi.data+1, jackEvent.buffer+1, jackEvent.size-1);
}

if (engineEventIndex >= INTERNAL_EVENT_COUNT)
@@ -1539,7 +1546,7 @@ protected:
PortNameToId portNameId(groupId, portId, portName, fullPortName);
fUsedPortNames.removeOne(portNameId);

callback(CALLBACK_PATCHBAY_PORT_REMOVED, 0, portId, 0, 0.0f, nullptr);
callback(CALLBACK_PATCHBAY_PORT_REMOVED, 0, portId, 0, 0.0f, fullPortName);
}
}



+ 27
- 6
source/backend/plugin/Lv2Plugin.cpp View File

@@ -2782,6 +2782,23 @@ public:
postponeRtEvent(kPluginPostRtEventParameterChange, static_cast<int32_t>(k), 0, value);
}

if ((fOptions & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param <= 0x5F)
{
uint8_t midiData[3];
midiData[0] = MIDI_STATUS_CONTROL_CHANGE + i;
midiData[1] = ctrlEvent.param;
midiData[2] = ctrlEvent.value*127.0f;

if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM)
lv2_atom_buffer_write(&evInAtomIters[fEventsIn.ctrlIndex], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT)
lv2_event_write(&evInEventIters[fEventsIn.ctrlIndex], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
lv2midi_put_event(&evInMidiStates[fEventsIn.ctrlIndex], 0, 3, midiData);
}

break;
}

@@ -2810,19 +2827,21 @@ public:
case kEngineControlEventTypeAllSoundOff:
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{
const uint32_t mtime(sampleAccurate ? startTime : time);

uint8_t midiData[3];
midiData[0] = MIDI_STATUS_CONTROL_CHANGE + i;
midiData[1] = MIDI_CONTROL_ALL_SOUND_OFF;
midiData[2] = 0;

if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM)
lv2_atom_buffer_write(&evInAtomIters[fEventsIn.ctrlIndex], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData);
lv2_atom_buffer_write(&evInAtomIters[fEventsIn.ctrlIndex], mtime, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT)
lv2_event_write(&evInEventIters[fEventsIn.ctrlIndex], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData);
lv2_event_write(&evInEventIters[fEventsIn.ctrlIndex], mtime, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
lv2midi_put_event(&evInMidiStates[fEventsIn.ctrlIndex], 0, 3, midiData);
lv2midi_put_event(&evInMidiStates[fEventsIn.ctrlIndex], mtime, 3, midiData);
}
break;

@@ -2835,19 +2854,21 @@ public:
sendMidiAllNotesOffToCallback();
}

const uint32_t mtime(sampleAccurate ? startTime : time);

uint8_t midiData[3];
midiData[0] = MIDI_STATUS_CONTROL_CHANGE + i;
midiData[1] = MIDI_CONTROL_ALL_NOTES_OFF;
midiData[2] = 0;

if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM)
lv2_atom_buffer_write(&evInAtomIters[fEventsIn.ctrlIndex], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData);
lv2_atom_buffer_write(&evInAtomIters[fEventsIn.ctrlIndex], mtime, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT)
lv2_event_write(&evInEventIters[fEventsIn.ctrlIndex], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData);
lv2_event_write(&evInEventIters[fEventsIn.ctrlIndex], mtime, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
lv2midi_put_event(&evInMidiStates[fEventsIn.ctrlIndex], 0, 3, midiData);
lv2midi_put_event(&evInMidiStates[fEventsIn.ctrlIndex], mtime, 3, midiData);
}
break;
}


Loading…
Cancel
Save