Browse Source

Send 128 notes-off when OPTION_SEND_ALL_SOUND_OFF is off

tags/1.9.4
falkTX 11 years ago
parent
commit
c1d2d4b24e
8 changed files with 122 additions and 50 deletions
  1. +16
    -7
      source/backend/plugin/DssiPlugin.cpp
  2. +8
    -7
      source/backend/plugin/FluidSynthPlugin.cpp
  3. +2
    -2
      source/backend/plugin/LadspaPlugin.cpp
  4. +7
    -6
      source/backend/plugin/LinuxSamplerPlugin.cpp
  5. +52
    -10
      source/backend/plugin/Lv2Plugin.cpp
  6. +17
    -7
      source/backend/plugin/NativePlugin.cpp
  7. +12
    -4
      source/backend/plugin/VstPlugin.cpp
  8. +8
    -7
      source/utils/CarlaBridgeUtils.hpp

+ 16
- 7
source/backend/plugin/DssiPlugin.cpp View File

@@ -419,8 +419,8 @@ public:

clearBuffers();

const float sampleRate = (float)kData->engine->getSampleRate();
const uint32_t portCount = static_cast<uint32_t>(fDescriptor->PortCount);
const float sampleRate(static_cast<float>(kData->engine->getSampleRate()));
const uint32_t portCount(static_cast<uint32_t>(fDescriptor->PortCount));

uint32_t aIns, aOuts, mIns, params, j;
aIns = aOuts = mIns = params = 0;
@@ -989,7 +989,6 @@ public:

if (kData->needsReset)
{
// TODO!
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{
for (unsigned char j=0, l=MAX_MIDI_CHANNELS; j < MAX_MIDI_CHANNELS; ++j)
@@ -999,17 +998,27 @@ public:

fMidiEvents[j].type = SND_SEQ_EVENT_CONTROLLER;
fMidiEvents[j].data.control.channel = j;
fMidiEvents[j].data.control.param = MIDI_CONTROL_ALL_SOUND_OFF;
fMidiEvents[j].data.control.param = MIDI_CONTROL_ALL_NOTES_OFF;

fMidiEvents[j+l].type = SND_SEQ_EVENT_CONTROLLER;
fMidiEvents[j+l].data.control.channel = j;
fMidiEvents[j+l].data.control.param = MIDI_CONTROL_ALL_NOTES_OFF;
fMidiEvents[j+l].data.control.param = MIDI_CONTROL_ALL_SOUND_OFF;
}

midiEventCount = MAX_MIDI_CHANNELS*2;
}
else
else if (kData->ctrlChannel >= 0 && kData->ctrlChannel < MAX_MIDI_CHANNELS)
{
for (unsigned char j=0; j < MAX_MIDI_NOTE; ++j)
{
carla_zeroStruct<snd_seq_event_t>(fMidiEvents[j]);

fMidiEvents[j].type = SND_SEQ_EVENT_NOTEOFF;
fMidiEvents[j].data.note.channel = kData->ctrlChannel;
fMidiEvents[j].data.note.note = j;
}

midiEventCount = MAX_MIDI_NOTE;
}

if (kData->latency > 0)
@@ -1219,8 +1228,8 @@ public:
{
if (! allNotesOffSent)
{
sendMidiAllNotesOffToCallback();
allNotesOffSent = true;
sendMidiAllNotesOffToCallback();
}

postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 0.0f);


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

@@ -923,22 +923,23 @@ public:

if (kData->needsReset)
{
// TODO
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{
for (int c=0; c < MAX_MIDI_CHANNELS; c++)
for (int c=0; c < MAX_MIDI_CHANNELS; ++c)
{
#ifdef FLUIDSYNTH_VERSION_NEW_API
fluid_synth_all_notes_off(fSynth, c);
fluid_synth_all_sounds_off(fSynth, c);
#else
fluid_synth_cc(f_synth, c, MIDI_CONTROL_ALL_SOUND_OFF, 0);
fluid_synth_cc(f_synth, c, MIDI_CONTROL_ALL_NOTES_OFF, 0);
fluid_synth_cc(fSynth, c, MIDI_CONTROL_ALL_SOUND_OFF, 0);
fluid_synth_cc(fSynth, c, MIDI_CONTROL_ALL_NOTES_OFF, 0);
#endif
}
}
else
else if (kData->ctrlChannel >= 0 && kData->ctrlChannel < MAX_MIDI_CHANNELS)
{
for (k=0; k < MAX_MIDI_NOTE; ++k)
fluid_synth_noteoff(fSynth, kData->ctrlChannel, k);
}

kData->needsReset = false;
@@ -1140,8 +1141,8 @@ public:
{
if (! allNotesOffSent)
{
sendMidiAllNotesOffToCallback();
allNotesOffSent = true;
sendMidiAllNotesOffToCallback();
}

postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 0.0f);
@@ -1163,8 +1164,8 @@ public:
{
if (! allNotesOffSent)
{
sendMidiAllNotesOffToCallback();
allNotesOffSent = true;
sendMidiAllNotesOffToCallback();
}

if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)


+ 2
- 2
source/backend/plugin/LadspaPlugin.cpp View File

@@ -411,8 +411,8 @@ public:

clearBuffers();

const float sampleRate = (float)kData->engine->getSampleRate();
const uint32_t portCount = static_cast<uint32_t>(fDescriptor->PortCount);
const float sampleRate(static_cast<float>(kData->engine->getSampleRate()));
const uint32_t portCount(static_cast<uint32_t>(fDescriptor->PortCount));

uint32_t aIns, aOuts, params, j;
aIns = aOuts = params = 0;


+ 7
- 6
source/backend/plugin/LinuxSamplerPlugin.cpp View File

@@ -522,17 +522,18 @@ public:

if (kData->needsReset)
{
// TODO
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{
for (k=0, i=MAX_MIDI_CHANNELS; k < MAX_MIDI_CHANNELS; ++k)
{
fMidiInputPort->DispatchControlChange(MIDI_CONTROL_ALL_SOUND_OFF, 0, k, 0);
fMidiInputPort->DispatchControlChange(MIDI_CONTROL_ALL_NOTES_OFF, 0, k, 0);
fMidiInputPort->DispatchControlChange(MIDI_CONTROL_ALL_NOTES_OFF, 0, k);
fMidiInputPort->DispatchControlChange(MIDI_CONTROL_ALL_SOUND_OFF, 0, k);
}
}
else
else if (kData->ctrlChannel >= 0 && kData->ctrlChannel < MAX_MIDI_CHANNELS)
{
for (k=0; k < MAX_MIDI_NOTE; ++k)
fMidiInputPort->DispatchNoteOff(k, 0, kData->ctrlChannel);
}

kData->needsReset = false;
@@ -733,8 +734,8 @@ public:
{
if (! allNotesOffSent)
{
sendMidiAllNotesOffToCallback();
allNotesOffSent = true;
sendMidiAllNotesOffToCallback();
}

postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 0.0f);
@@ -750,8 +751,8 @@ public:
{
if (! allNotesOffSent)
{
sendMidiAllNotesOffToCallback();
allNotesOffSent = true;
sendMidiAllNotesOffToCallback();
}
}



+ 52
- 10
source/backend/plugin/Lv2Plugin.cpp View File

@@ -1262,8 +1262,8 @@ public:

clearBuffers();

const float sampleRate = (float)kData->engine->getSampleRate();
const uint32_t portCount = fRdfDescriptor->PortCount;
const float sampleRate(static_cast<float>(kData->engine->getSampleRate()));
const uint32_t portCount(static_cast<uint32_t>(fRdfDescriptor->PortCount));

uint32_t aIns, aOuts, cvIns, cvOuts, params, j;
aIns = aOuts = cvIns = cvOuts = params = 0;
@@ -2278,15 +2278,57 @@ public:

if (kData->needsReset)
{
// TODO!
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
k = fEventsIn.ctrlIndex;
uint8_t midiData[3] = { 0 };

if (fEventsIn.ctrl->type & CARLA_EVENT_TYPE_MIDI)
{
//for (unsigned char j=0, l=MAX_MIDI_CHANNELS; j < MAX_MIDI_CHANNELS; ++j)
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{
for (k=0, i=MAX_MIDI_CHANNELS; k < MAX_MIDI_CHANNELS; ++k)
{
midiData[0] = MIDI_STATUS_CONTROL_CHANGE + k;
midiData[1] = MIDI_CONTROL_ALL_NOTES_OFF;

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

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

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

midiData[0] = MIDI_STATUS_CONTROL_CHANGE + k;
midiData[1] = MIDI_CONTROL_ALL_SOUND_OFF;

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

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

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
lv2midi_put_event(&evInMidiStates[k], 0, 3, midiData);
}
}
else if (kData->ctrlChannel >= 0 && kData->ctrlChannel < MAX_MIDI_CHANNELS)
{
for (k=0; k < MAX_MIDI_NOTE; ++k)
{
midiData[0] = MIDI_STATUS_NOTE_OFF + kData->ctrlChannel;
midiData[1] = k;

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

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

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

if (kData->latency > 0)
@@ -2487,7 +2529,7 @@ public:

CARLA_ASSERT(note.channel >= 0 && note.channel < MAX_MIDI_CHANNELS);

uint8_t midiEvent[3] = { 0 };
uint8_t midiEvent[3];
midiEvent[0] = (note.velo > 0) ? MIDI_STATUS_NOTE_ON : MIDI_STATUS_NOTE_OFF;
midiEvent[0] += note.channel;
midiEvent[1] = note.note;
@@ -2700,8 +2742,8 @@ public:
{
if (! allNotesOffSent)
{
sendMidiAllNotesOffToCallback();
allNotesOffSent = true;
sendMidiAllNotesOffToCallback();
}

postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 0.0f);


+ 17
- 7
source/backend/plugin/NativePlugin.cpp View File

@@ -1193,24 +1193,34 @@ public:

if (kData->needsReset)
{
// TODO!
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{
for (k=0, i=MAX_MIDI_CHANNELS; k < MAX_MIDI_CHANNELS; ++k)
{
fMidiEvents[k].data[0] = MIDI_STATUS_CONTROL_CHANGE + k;
fMidiEvents[k].data[1] = MIDI_CONTROL_ALL_SOUND_OFF;
fMidiEvents[k].size = 2;
fMidiEvents[k].data[1] = MIDI_CONTROL_ALL_NOTES_OFF;
fMidiEvents[k].data[2] = 0;
fMidiEvents[k].size = 3;

fMidiEvents[k+i].data[0] = MIDI_STATUS_CONTROL_CHANGE + k;
fMidiEvents[k+i].data[1] = MIDI_CONTROL_ALL_NOTES_OFF;
fMidiEvents[k+i].size = 2;
fMidiEvents[k+i].data[1] = MIDI_CONTROL_ALL_SOUND_OFF;
fMidiEvents[k+i].data[2] = 0;
fMidiEvents[k+i].size = 3;
}

fMidiEventCount = MAX_MIDI_CHANNELS*2;
}
else
else if (kData->ctrlChannel >= 0 && kData->ctrlChannel < MAX_MIDI_CHANNELS)
{
for (k=0; k < MAX_MIDI_NOTE; ++k)
{
fMidiEvents[k].data[0] = MIDI_STATUS_NOTE_OFF + kData->ctrlChannel;
fMidiEvents[k].data[1] = k;
fMidiEvents[k].data[2] = 0;
fMidiEvents[k].size = 3;
}

fMidiEventCount = MAX_MIDI_NOTE;
}

kData->needsReset = false;
@@ -1452,8 +1462,8 @@ public:
{
if (! allNotesOffSent)
{
sendMidiAllNotesOffToCallback();
allNotesOffSent = true;
sendMidiAllNotesOffToCallback();
}

postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 0.0f);


+ 12
- 4
source/backend/plugin/VstPlugin.cpp View File

@@ -1004,7 +1004,6 @@ public:

if (kData->needsReset)
{
// TODO!
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{
for (k=0, i=MAX_MIDI_CHANNELS; k < MAX_MIDI_CHANNELS; ++k)
@@ -1012,7 +1011,7 @@ public:
fMidiEvents[k].type = kVstMidiType;
fMidiEvents[k].byteSize = sizeof(VstMidiEvent);
fMidiEvents[k].midiData[0] = MIDI_STATUS_CONTROL_CHANGE + k;
fMidiEvents[k].midiData[1] = MIDI_CONTROL_ALL_SOUND_OFF;
fMidiEvents[k].midiData[1] = MIDI_CONTROL_ALL_NOTES_OFF;

fMidiEvents[k+i].type = kVstMidiType;
fMidiEvents[k+i].byteSize = sizeof(VstMidiEvent);
@@ -1022,8 +1021,17 @@ public:

fMidiEventCount = MAX_MIDI_CHANNELS*2;
}
else
else if (kData->ctrlChannel >= 0 && kData->ctrlChannel < MAX_MIDI_CHANNELS)
{
for (k=0; k < MAX_MIDI_NOTE; ++k)
{
fMidiEvents[k].type = kVstMidiType;
fMidiEvents[k].byteSize = sizeof(VstMidiEvent);
fMidiEvents[k].midiData[0] = MIDI_STATUS_NOTE_OFF + kData->ctrlChannel;
fMidiEvents[k].midiData[1] = k;
}

fMidiEventCount = MAX_MIDI_NOTE;
}

if (kData->latency > 0)
@@ -1287,8 +1295,8 @@ public:
{
if (! allNotesOffSent)
{
sendMidiAllNotesOffToCallback();
allNotesOffSent = true;
sendMidiAllNotesOffToCallback();
}

postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 0.0f);


+ 8
- 7
source/utils/CarlaBridgeUtils.hpp View File

@@ -54,13 +54,14 @@ enum PluginBridgeInfoType {
enum PluginBridgeOpcode {
kPluginBridgeOpcodeNull = 0,
kPluginBridgeOpcodeReadyWait = 1,
kPluginBridgeOpcodeSetBufferSize = 2,
kPluginBridgeOpcodeSetSampleRate = 3,
kPluginBridgeOpcodeSetParameter = 4,
kPluginBridgeOpcodeSetProgram = 5,
kPluginBridgeOpcodeSetMidiProgram = 6,
kPluginBridgeOpcodeProcess = 7,
kPluginBridgeOpcodeQuit = 8
kPluginBridgeOpcodeSetBufferSize = 2, // int
kPluginBridgeOpcodeSetSampleRate = 3, // float
kPluginBridgeOpcodeSetParameter = 4, // int, float
kPluginBridgeOpcodeSetProgram = 5, // int
kPluginBridgeOpcodeSetMidiProgram = 6, // int
kPluginBridgeOpcodeMidiEvent = 7, // int, char, ... (int = size, max 4)
kPluginBridgeOpcodeProcess = 8,
kPluginBridgeOpcodeQuit = 9
};

/*!


Loading…
Cancel
Save