Browse Source

Fix some issues on native plugins MIDI handling

tags/1.9.4
falkTX 13 years ago
parent
commit
b1e00d874e
6 changed files with 35 additions and 33 deletions
  1. +1
    -0
      source/backend/CarlaNative.h
  2. +1
    -0
      source/backend/native/Makefile
  3. +2
    -2
      source/backend/native/midi-split.c
  4. +2
    -2
      source/backend/native/midi-through.c
  5. +28
    -29
      source/backend/plugin/NativePlugin.cpp
  6. +1
    -0
      source/utils/CarlaStateUtils.hpp

+ 1
- 0
source/backend/CarlaNative.h View File

@@ -197,6 +197,7 @@ void carla_register_native_plugin(const PluginDescriptor* desc);
void carla_register_native_plugin_bypass();
void carla_register_native_plugin_midiSplit();
void carla_register_native_plugin_midiThrough();
void carla_register_native_plugin_midiTranspose();
void carla_register_native_plugin_nekofilter();

// DISTRHO plugins


+ 1
- 0
source/backend/native/Makefile View File

@@ -31,6 +31,7 @@ OBJS = \
bypass.c.o \
midi-split.c.o \
midi-through.c.o \
midi-transpose.c.o \
nekofilter.c.o

# DISTRHO plugins


+ 2
- 2
source/backend/native/midi-split.c View File

@@ -28,7 +28,7 @@ static PluginHandle midiSplit_instantiate(const PluginDescriptor* _this_, HostDe
{
MidiSplitHandle* const handle = (MidiSplitHandle*)malloc(sizeof(MidiSplitHandle));

if (handle)
if (handle != NULL)
{
handle->host = host;
return handle;
@@ -66,7 +66,7 @@ static void midiSplit_process(PluginHandle handle, float** inBuffer, float** out
tmpEvent.data[1] = midiEvent->data[1];
tmpEvent.data[2] = midiEvent->data[2];

host->write_midi_event(host, &tmpEvent);
host->write_midi_event(host->handle, &tmpEvent);
}

return;


+ 2
- 2
source/backend/native/midi-through.c View File

@@ -28,7 +28,7 @@ static PluginHandle midiThrough_instantiate(const PluginDescriptor* _this_, Host
{
MidiThroughHandle* const handle = (MidiThroughHandle*)malloc(sizeof(MidiThroughHandle));

if (handle)
if (handle != NULL)
{
handle->host = host;
return handle;
@@ -50,7 +50,7 @@ static void midiThrough_process(PluginHandle handle, float** inBuffer, float** o
HostDescriptor* const host = ((MidiThroughHandle*)handle)->host;

for (uint32_t i=0; i < midiEventCount; i++)
host->write_midi_event(host, &midiEvents[i]);
host->write_midi_event(host->handle, &midiEvents[i]);

return;



+ 28
- 29
source/backend/plugin/NativePlugin.cpp View File

@@ -1165,7 +1165,7 @@ public:
{
if (fMidiEventCount > 0)
{
carla_zeroMem(fMidiEvents, sizeof(::MidiEvent)*fMidiEventCount);
//carla_zeroMem(fMidiEvents, sizeof(::MidiEvent)*fMidiEventCount);
fMidiEventCount = 0;
}

@@ -1385,7 +1385,7 @@ public:
continue;

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

fMidiEvents[fMidiEventCount].port = 0;
@@ -1397,6 +1397,11 @@ public:

fMidiEventCount += 1;

if (status == MIDI_STATUS_NOTE_ON)
postponeRtEvent(kPluginPostRtEventNoteOn, channel, midiEvent.data[1], midiEvent.data[2]);
else if (status == MIDI_STATUS_NOTE_OFF)
postponeRtEvent(kPluginPostRtEventNoteOff, channel, midiEvent.data[1], 0.0);

break;
}
}
@@ -1421,31 +1426,9 @@ public:
CARLA_PROCESS_CONTINUE_CHECK;

// --------------------------------------------------------------------------------------------------------
// MIDI Output
// Control and MIDI Output

if (fMidiOut.count > 0)
{
// reverse lookup
for (uint32_t i = (MAX_MIDI_EVENTS*2)-1; i >= fMidiEventCount; i--)
{
if (fMidiEvents[i].data[0] == 0)
break;

const uint8_t channel = MIDI_GET_CHANNEL_FROM_DATA(fMidiEvents[i].data);
const uint8_t port = fMidiEvents[i].port;

if (port < fMidiOut.count)
fMidiOut.ports[port]->writeMidiEvent(fMidiEvents[i].time, channel, port, fMidiEvents[i].data, 3);
}

} // End of MIDI Output

CARLA_PROCESS_CONTINUE_CHECK;

// --------------------------------------------------------------------------------------------------------
// Control Output

if (kData->event.portOut != nullptr)
if (fMidiOut.count > 0 || kData->event.portOut != nullptr)
{
float value, curValue;

@@ -1464,7 +1447,22 @@ public:
}
}

} // End of Control Output
// reverse lookup MIDI events
for (k = (MAX_MIDI_EVENTS*2)-1; k >= fMidiEventCount; k--)
{
if (fMidiEvents[k].data[0] == 0)
break;

const uint8_t channel = MIDI_GET_CHANNEL_FROM_DATA(fMidiEvents[k].data);
const uint8_t port = fMidiEvents[k].port;

if (kData->event.portOut != nullptr)
kData->event.portOut->writeMidiEvent(fMidiEvents[k].time, channel, port, fMidiEvents[k].data, 3);
else if (port < fMidiOut.count)
fMidiOut.ports[port]->writeMidiEvent(fMidiEvents[k].time, channel, port, fMidiEvents[k].data, 3);
}

} // End of Control and MIDI Output

// --------------------------------------------------------------------------------------------------------

@@ -1751,7 +1749,7 @@ protected:
bool handleWriteMidiEvent(const ::MidiEvent* const event)
{
CARLA_ASSERT(fEnabled);
CARLA_ASSERT(fMidiOut.count > 0);
CARLA_ASSERT(fMidiOut.count > 0 || kData->event.portOut != nullptr);
CARLA_ASSERT(event != nullptr);
CARLA_ASSERT(fIsProcessing);

@@ -1771,7 +1769,7 @@ protected:
return false;

// reverse-find first free event, and put it there
for (uint32_t i=fMidiEventCount-1; i >= fMidiEventCount; i--)
for (uint32_t i=(MAX_MIDI_EVENTS*2)-1; i >= fMidiEventCount; i--)
{
if (fMidiEvents[i].data[0] == 0)
{
@@ -1928,6 +1926,7 @@ private:
carla_register_native_plugin_bypass();
carla_register_native_plugin_midiSplit();
carla_register_native_plugin_midiThrough();
carla_register_native_plugin_midiTranspose();
carla_register_native_plugin_nekofilter();

carla_register_native_plugin_3BandEQ();


+ 1
- 0
source/utils/CarlaStateUtils.hpp View File

@@ -474,6 +474,7 @@ QString getXMLFromSaveState(const SaveState& saveState)
case PLUGIN_SF2:
case PLUGIN_SFZ:
info += QString(" <Binary>%1</Binary>\n").arg(xmlSafeString(saveState.binary, true));
info += QString(" <Label>%1</Label>\n").arg(xmlSafeString(saveState.label, true));
break;
}



Loading…
Cancel
Save