| @@ -23,11 +23,17 @@ | |||
| #if defined(CARLA_ENGINE_JACK) | |||
| #include <jack/jack.h> | |||
| #include <jack/midiport.h> | |||
| typedef jack_client_t CarlaEngineClientNativeHandle; | |||
| typedef jack_port_t CarlaEnginePortNativeHandle; | |||
| struct CarlaEnginePortNativeHandle { | |||
| jack_port_t* port; | |||
| void* buffer; | |||
| }; | |||
| #elif defined(CARLA_ENGINE_RTAUDIO) | |||
| #include "RtAudio.h" | |||
| //#include <RtMidi.h> | |||
| typedef void* CarlaEngineClientNativeHandle; | |||
| typedef void* CarlaEnginePortNativeHandle; | |||
| #endif | |||
| @@ -119,11 +125,11 @@ public: | |||
| CarlaEngineBasePort(CarlaEngineClientNativeHandle* const client, bool isInput); | |||
| virtual ~CarlaEngineBasePort(); | |||
| virtual void* getBuffer() = 0; | |||
| virtual void initBuffer() = 0; | |||
| protected: | |||
| const bool isInput; | |||
| CarlaEnginePortNativeHandle* handle; | |||
| CarlaEnginePortNativeHandle handle; | |||
| CarlaEngineClientNativeHandle* const client; | |||
| }; | |||
| @@ -155,7 +161,11 @@ class CarlaEngineAudioPort : public CarlaEngineBasePort | |||
| public: | |||
| CarlaEngineAudioPort(CarlaEngineClientNativeHandle* const client, const char* name, bool isInput); | |||
| void* getBuffer(); | |||
| void initBuffer(); | |||
| #ifdef CARLA_ENGINE_JACK | |||
| float* getJackAudioBuffer(); | |||
| #endif | |||
| }; | |||
| // ----------------------------------------- | |||
| @@ -165,12 +175,12 @@ class CarlaEngineControlPort : public CarlaEngineBasePort | |||
| public: | |||
| CarlaEngineControlPort(CarlaEngineClientNativeHandle* const client, const char* name, bool isInput); | |||
| void* getBuffer(); | |||
| void initBuffer(); | |||
| void initBuffer(void* buffer); | |||
| uint32_t getEventCount(void* buffer); | |||
| const CarlaEngineControlEvent* getEvent(void* buffer, uint32_t index); | |||
| void writeEvent(void* buffer, CarlaEngineControlEventType type, uint32_t time, uint8_t channel, uint8_t controller, double value); | |||
| uint32_t getEventCount(); | |||
| const CarlaEngineControlEvent* getEvent(uint32_t index); | |||
| void writeEvent(CarlaEngineControlEventType type, uint32_t time, uint8_t channel, uint8_t controller, double value); | |||
| }; | |||
| // ----------------------------------------- | |||
| @@ -180,12 +190,12 @@ class CarlaEngineMidiPort : public CarlaEngineBasePort | |||
| public: | |||
| CarlaEngineMidiPort(CarlaEngineClientNativeHandle* const client, const char* name, bool isInput); | |||
| void* getBuffer(); | |||
| void initBuffer(); | |||
| uint32_t getEventCount(); | |||
| const CarlaEngineMidiEvent* getEvent(uint32_t index); | |||
| void initBuffer(void* buffer); | |||
| uint32_t getEventCount(void* buffer); | |||
| const CarlaEngineMidiEvent* getEvent(void* buffer, uint32_t index); | |||
| void writeEvent(void* buffer, uint32_t time, uint8_t* data, uint8_t size); | |||
| void writeEvent(uint32_t time, uint8_t* data, uint8_t size); | |||
| }; | |||
| /**@}*/ | |||
| @@ -52,6 +52,8 @@ const unsigned short rackPortMidiIn = 6; | |||
| const unsigned short rackPortMidiOut = 7; | |||
| const unsigned short rackPortCount = 8; | |||
| static jack_port_t* carla_jack_rack_ports[rackPortCount] = { nullptr }; | |||
| //static CarlaEngineControlEvent carlaRackControlEventsIn[MAX_POST_EVENTS]; | |||
| //static CarlaEngineControlEvent carlaRackControlEventsOut[MAX_POST_EVENTS]; | |||
| static CarlaEngineMidiEvent carlaRackMidiEventsIn[MAX_MIDI_EVENTS]; | |||
| static CarlaEngineMidiEvent carlaRackMidiEventsOut[MAX_MIDI_EVENTS]; | |||
| #endif | |||
| @@ -144,6 +146,7 @@ static int carla_jack_process_callback(jack_nframes_t nframes, void* arg) | |||
| if (plugin && plugin->enabled()) | |||
| { | |||
| carla_proc_lock(); | |||
| plugin->initBuffers(); | |||
| plugin->process_jack(nframes); | |||
| carla_proc_unlock(); | |||
| } | |||
| @@ -175,6 +178,7 @@ static int carla_jack_process_callback(jack_nframes_t nframes, void* arg) | |||
| memcpy(ains_tmp_buf2, audioIn2, sizeof(float)*nframes); | |||
| // initialize control input | |||
| //memset(carlaRackControlEventsIn, 0, sizeof(CarlaEngineControlEvent)*MAX_POST_EVENTS); | |||
| { | |||
| // TODO | |||
| } | |||
| @@ -297,6 +301,7 @@ static int carla_jack_process_callback(jack_nframes_t nframes, void* arg) | |||
| if (plugin && plugin->enabled()) | |||
| { | |||
| carla_proc_lock(); | |||
| plugin->initBuffers(); | |||
| plugin->process_jack(nframes); | |||
| carla_proc_unlock(); | |||
| } | |||
| @@ -490,6 +495,8 @@ CarlaEngineBasePort::CarlaEngineBasePort(CarlaEngineClientNativeHandle* const cl | |||
| isInput(isInput_), | |||
| client(clientHandle) | |||
| { | |||
| handle.port = nullptr; | |||
| handle.buffer = nullptr; | |||
| } | |||
| CarlaEngineBasePort::~CarlaEngineBasePort() | |||
| @@ -498,8 +505,8 @@ CarlaEngineBasePort::~CarlaEngineBasePort() | |||
| if (carla_options.process_mode != PROCESS_MODE_CONTINUOUS_RACK) | |||
| #endif | |||
| { | |||
| if (client && handle) | |||
| jack_port_unregister(client, handle); | |||
| if (client && handle.port) | |||
| jack_port_unregister(client, handle.port); | |||
| } | |||
| } | |||
| @@ -607,21 +614,23 @@ CarlaEngineAudioPort::CarlaEngineAudioPort(CarlaEngineClientNativeHandle* const | |||
| CarlaEngineBasePort(client, isInput) | |||
| { | |||
| #ifndef BUILD_BRIDGE | |||
| if (carla_options.process_mode == PROCESS_MODE_CONTINUOUS_RACK) | |||
| handle = nullptr; | |||
| else | |||
| if (carla_options.process_mode != PROCESS_MODE_CONTINUOUS_RACK) | |||
| #endif | |||
| handle = jack_port_register(client, name, JACK_DEFAULT_AUDIO_TYPE, isInput ? JackPortIsInput : JackPortIsOutput, 0); | |||
| handle.port = jack_port_register(client, name, JACK_DEFAULT_AUDIO_TYPE, isInput ? JackPortIsInput : JackPortIsOutput, 0); | |||
| } | |||
| void CarlaEngineAudioPort::initBuffer() | |||
| { | |||
| } | |||
| void* CarlaEngineAudioPort::getBuffer() | |||
| float* CarlaEngineAudioPort::getJackAudioBuffer() | |||
| { | |||
| #ifndef BUILD_BRIDGE | |||
| if (carla_options.process_mode == PROCESS_MODE_CONTINUOUS_RACK) | |||
| return nullptr; | |||
| else | |||
| #endif | |||
| return jack_port_get_buffer(handle, carla_buffer_size); | |||
| return (float*)jack_port_get_buffer(handle.port, carla_buffer_size); | |||
| } | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| @@ -631,35 +640,23 @@ CarlaEngineControlPort::CarlaEngineControlPort(CarlaEngineClientNativeHandle* co | |||
| CarlaEngineBasePort(client, isInput) | |||
| { | |||
| #ifndef BUILD_BRIDGE | |||
| if (carla_options.process_mode == PROCESS_MODE_CONTINUOUS_RACK) | |||
| handle = nullptr; | |||
| else | |||
| #endif | |||
| handle = jack_port_register(client, name, JACK_DEFAULT_MIDI_TYPE, isInput ? JackPortIsInput : JackPortIsOutput, 0); | |||
| } | |||
| void* CarlaEngineControlPort::getBuffer() | |||
| { | |||
| #ifndef BUILD_BRIDGE | |||
| if (carla_options.process_mode == PROCESS_MODE_CONTINUOUS_RACK) | |||
| return nullptr; | |||
| if (carla_options.process_mode != PROCESS_MODE_CONTINUOUS_RACK) | |||
| #endif | |||
| return jack_port_get_buffer(handle, carla_buffer_size); | |||
| handle.port = jack_port_register(client, name, JACK_DEFAULT_MIDI_TYPE, isInput ? JackPortIsInput : JackPortIsOutput, 0); | |||
| } | |||
| void CarlaEngineControlPort::initBuffer(void* buffer) | |||
| void CarlaEngineControlPort::initBuffer() | |||
| { | |||
| #ifndef BUILD_BRIDGE | |||
| if (carla_options.process_mode == PROCESS_MODE_CONTINUOUS_RACK) | |||
| return; | |||
| #endif | |||
| if (isInput) | |||
| if (! handle.port) | |||
| return; | |||
| jack_midi_clear_buffer(buffer); | |||
| handle.buffer = jack_port_get_buffer(handle.port, carla_buffer_size); | |||
| if (! isInput) | |||
| jack_midi_clear_buffer(handle.buffer); | |||
| } | |||
| uint32_t CarlaEngineControlPort::getEventCount(void* buffer) | |||
| uint32_t CarlaEngineControlPort::getEventCount() | |||
| { | |||
| if (! isInput) | |||
| return 0; | |||
| @@ -669,10 +666,10 @@ uint32_t CarlaEngineControlPort::getEventCount(void* buffer) | |||
| return 0; // TODO | |||
| #endif | |||
| return jack_midi_get_event_count(buffer); | |||
| return jack_midi_get_event_count(handle.buffer); | |||
| } | |||
| const CarlaEngineControlEvent* CarlaEngineControlPort::getEvent(void* buffer, uint32_t index) | |||
| const CarlaEngineControlEvent* CarlaEngineControlPort::getEvent(uint32_t index) | |||
| { | |||
| if (! isInput) | |||
| return nullptr; | |||
| @@ -685,7 +682,7 @@ const CarlaEngineControlEvent* CarlaEngineControlPort::getEvent(void* buffer, ui | |||
| static jack_midi_event_t jackEvent; | |||
| static CarlaEngineControlEvent carlaEvent; | |||
| if (jack_midi_event_get(&jackEvent, buffer, index) != 0) | |||
| if (jack_midi_event_get(&jackEvent, handle.buffer, index) != 0) | |||
| return nullptr; | |||
| memset(&carlaEvent, 0, sizeof(CarlaEngineControlEvent)); | |||
| @@ -736,7 +733,7 @@ const CarlaEngineControlEvent* CarlaEngineControlPort::getEvent(void* buffer, ui | |||
| return nullptr; | |||
| } | |||
| void CarlaEngineControlPort::writeEvent(void* buffer, CarlaEngineControlEventType type, uint32_t time, uint8_t channel, uint8_t controller, double value) | |||
| void CarlaEngineControlPort::writeEvent(CarlaEngineControlEventType type, uint32_t time, uint8_t channel, uint8_t controller, double value) | |||
| { | |||
| if (isInput) | |||
| return; | |||
| @@ -757,28 +754,28 @@ void CarlaEngineControlPort::writeEvent(void* buffer, CarlaEngineControlEventTyp | |||
| data[0] = MIDI_STATUS_CONTROL_CHANGE + channel; | |||
| data[1] = controller; | |||
| data[2] = value * 127; | |||
| jack_midi_event_write(buffer, time, data, 3); | |||
| jack_midi_event_write(handle.buffer, time, data, 3); | |||
| break; | |||
| case CarlaEngineEventMidiBankChange: | |||
| data[0] = MIDI_STATUS_CONTROL_CHANGE + channel; | |||
| data[1] = MIDI_CONTROL_BANK_SELECT; | |||
| data[2] = value; | |||
| jack_midi_event_write(buffer, time, data, 3); | |||
| jack_midi_event_write(handle.buffer, time, data, 3); | |||
| break; | |||
| case CarlaEngineEventMidiProgramChange: | |||
| data[0] = MIDI_STATUS_PROGRAM_CHANGE + channel; | |||
| data[1] = value; | |||
| jack_midi_event_write(buffer, time, data, 2); | |||
| jack_midi_event_write(handle.buffer, time, data, 2); | |||
| break; | |||
| case CarlaEngineEventAllSoundOff: | |||
| data[0] = MIDI_STATUS_CONTROL_CHANGE + channel; | |||
| data[1] = MIDI_CONTROL_ALL_SOUND_OFF; | |||
| jack_midi_event_write(buffer, time, data, 2); | |||
| jack_midi_event_write(handle.buffer, time, data, 2); | |||
| break; | |||
| case CarlaEngineEventAllNotesOff: | |||
| data[0] = MIDI_STATUS_CONTROL_CHANGE + channel; | |||
| data[1] = MIDI_CONTROL_ALL_NOTES_OFF; | |||
| jack_midi_event_write(buffer, time, data, 2); | |||
| jack_midi_event_write(handle.buffer, time, data, 2); | |||
| break; | |||
| } | |||
| } | |||
| @@ -790,35 +787,23 @@ CarlaEngineMidiPort::CarlaEngineMidiPort(CarlaEngineClientNativeHandle* const cl | |||
| CarlaEngineBasePort(client, isInput) | |||
| { | |||
| #ifndef BUILD_BRIDGE | |||
| if (carla_options.process_mode == PROCESS_MODE_CONTINUOUS_RACK) | |||
| handle = nullptr; | |||
| else | |||
| #endif | |||
| handle = jack_port_register(client, name, JACK_DEFAULT_MIDI_TYPE, isInput ? JackPortIsInput : JackPortIsOutput, 0); | |||
| } | |||
| void* CarlaEngineMidiPort::getBuffer() | |||
| { | |||
| #ifndef BUILD_BRIDGE | |||
| if (carla_options.process_mode == PROCESS_MODE_CONTINUOUS_RACK) | |||
| return nullptr; | |||
| if (carla_options.process_mode != PROCESS_MODE_CONTINUOUS_RACK) | |||
| #endif | |||
| return jack_port_get_buffer(handle, carla_buffer_size); | |||
| handle.port = jack_port_register(client, name, JACK_DEFAULT_MIDI_TYPE, isInput ? JackPortIsInput : JackPortIsOutput, 0); | |||
| } | |||
| void CarlaEngineMidiPort::initBuffer(void* buffer) | |||
| void CarlaEngineMidiPort::initBuffer() | |||
| { | |||
| #ifndef BUILD_BRIDGE | |||
| if (carla_options.process_mode == PROCESS_MODE_CONTINUOUS_RACK) | |||
| return; | |||
| #endif | |||
| if (isInput) | |||
| if (! handle.port) | |||
| return; | |||
| jack_midi_clear_buffer(buffer); | |||
| handle.buffer = jack_port_get_buffer(handle.port, carla_buffer_size); | |||
| if (! isInput) | |||
| jack_midi_clear_buffer(handle.buffer); | |||
| } | |||
| uint32_t CarlaEngineMidiPort::getEventCount(void* buffer) | |||
| uint32_t CarlaEngineMidiPort::getEventCount() | |||
| { | |||
| if (! isInput) | |||
| return 0; | |||
| @@ -835,10 +820,10 @@ uint32_t CarlaEngineMidiPort::getEventCount(void* buffer) | |||
| return count; | |||
| } | |||
| #endif | |||
| return jack_midi_get_event_count(buffer); | |||
| return jack_midi_get_event_count(handle.buffer); | |||
| } | |||
| const CarlaEngineMidiEvent* CarlaEngineMidiPort::getEvent(void* buffer, uint32_t index) | |||
| const CarlaEngineMidiEvent* CarlaEngineMidiPort::getEvent(uint32_t index) | |||
| { | |||
| if (! isInput) | |||
| return nullptr; | |||
| @@ -855,7 +840,7 @@ const CarlaEngineMidiEvent* CarlaEngineMidiPort::getEvent(void* buffer, uint32_t | |||
| static jack_midi_event_t jackEvent; | |||
| static CarlaEngineMidiEvent carlaEvent; | |||
| if (jack_midi_event_get(&jackEvent, buffer, index) != 0) | |||
| if (jack_midi_event_get(&jackEvent, handle.buffer, index) != 0) | |||
| return nullptr; | |||
| if (jackEvent.size < 4) | |||
| @@ -870,7 +855,7 @@ const CarlaEngineMidiEvent* CarlaEngineMidiPort::getEvent(void* buffer, uint32_t | |||
| return nullptr; | |||
| } | |||
| void CarlaEngineMidiPort::writeEvent(void* buffer, uint32_t time, uint8_t* data, uint8_t size) | |||
| void CarlaEngineMidiPort::writeEvent(uint32_t time, uint8_t* data, uint8_t size) | |||
| { | |||
| if (isInput) | |||
| return; | |||
| @@ -894,7 +879,7 @@ void CarlaEngineMidiPort::writeEvent(void* buffer, uint32_t time, uint8_t* data, | |||
| } | |||
| else | |||
| #endif | |||
| jack_midi_event_write(buffer, time, data, size); | |||
| jack_midi_event_write(handle.buffer, time, data, size); | |||
| } | |||
| CARLA_BACKEND_END_NAMESPACE | |||
| @@ -188,7 +188,12 @@ public: | |||
| m_name = nullptr; | |||
| m_filename = nullptr; | |||
| cin_channel = 0; | |||
| #ifndef BUILD_BRIDGE | |||
| if (carla_options.process_mode == PROCESS_MODE_CONTINUOUS_RACK) | |||
| cin_channel = m_id; | |||
| else | |||
| #endif | |||
| cin_channel = 0; | |||
| x_drywet = 1.0; | |||
| x_vol = 1.0; | |||
| @@ -1259,10 +1264,10 @@ public: | |||
| float* aouts_buffer[aout.count]; | |||
| for (uint32_t i=0; i < ain.count; i++) | |||
| ains_buffer[i] = (float*)ain.ports[i]->getBuffer(); | |||
| ains_buffer[i] = (float*)ain.ports[i]->getJackAudioBuffer(); | |||
| for (uint32_t i=0; i < aout.count; i++) | |||
| aouts_buffer[i] = (float*)aout.ports[i]->getBuffer(); | |||
| aouts_buffer[i] = (float*)aout.ports[i]->getJackAudioBuffer(); | |||
| #ifndef BUILD_BRIDGE | |||
| if (carla_options.proccess_hq) | |||
| @@ -1673,6 +1678,38 @@ public: | |||
| qDebug("CarlaPlugin::removeClientPorts() - end"); | |||
| } | |||
| /*! | |||
| * Initializes all RT buffers of the plugin. | |||
| */ | |||
| virtual void initBuffers() | |||
| { | |||
| uint32_t i; | |||
| for (i=0; i < ain.count; i++) | |||
| { | |||
| if (ain.ports[i]) | |||
| ain.ports[i]->initBuffer(); | |||
| } | |||
| for (i=0; i < aout.count; i++) | |||
| { | |||
| if (aout.ports[i]) | |||
| aout.ports[i]->initBuffer(); | |||
| } | |||
| if (param.portCin) | |||
| param.portCin->initBuffer(); | |||
| if (param.portCout) | |||
| param.portCout->initBuffer(); | |||
| if (midi.portMin) | |||
| midi.portMin->initBuffer(); | |||
| if (midi.portMout) | |||
| midi.portMout->initBuffer(); | |||
| } | |||
| /*! | |||
| * Delete all temporary buffers of the plugin. | |||
| */ | |||
| @@ -163,7 +163,13 @@ CustomDataType customdatastr2type(const char* stype) | |||
| short get_new_plugin_id() | |||
| { | |||
| for (unsigned short i=0; i<MAX_PLUGINS; i++) | |||
| #ifdef BUILD_BRIDGE | |||
| const unsigned short max = MAX_PLUGINS; | |||
| #else | |||
| const unsigned short max = (carla_options.process_mode == PROCESS_MODE_CONTINUOUS_RACK) ? 16 : MAX_PLUGINS; | |||
| #endif | |||
| for (unsigned short i=0; i < max; i++) | |||
| { | |||
| if (CarlaPlugins[i] == nullptr) | |||
| return i; | |||
| @@ -796,10 +796,9 @@ public: | |||
| if (param.portCin && m_active && m_activeBefore) | |||
| { | |||
| bool allNotesOffSent = false; | |||
| void* cinBuffer = param.portCin->getBuffer(); | |||
| const CarlaEngineControlEvent* cinEvent; | |||
| uint32_t time, nEvents = param.portCin->getEventCount(cinBuffer); | |||
| uint32_t time, nEvents = param.portCin->getEventCount(); | |||
| uint32_t nextBankId = 0; | |||
| if (midiprog.current >= 0 && midiprog.count > 0) | |||
| @@ -807,7 +806,7 @@ public: | |||
| for (i=0; i < nEvents; i++) | |||
| { | |||
| cinEvent = param.portCin->getEvent(cinBuffer, i); | |||
| cinEvent = param.portCin->getEvent(i); | |||
| if (! cinEvent) | |||
| continue; | |||
| @@ -993,14 +992,12 @@ public: | |||
| if (midi.portMin && m_active && m_activeBefore) | |||
| { | |||
| void* minBuffer = midi.portMin->getBuffer(); | |||
| const CarlaEngineMidiEvent* minEvent; | |||
| uint32_t time, nEvents = midi.portMin->getEventCount(minBuffer); | |||
| uint32_t time, nEvents = midi.portMin->getEventCount(); | |||
| for (i=0; i < nEvents && midiEventCount < MAX_MIDI_EVENTS; i++) | |||
| { | |||
| minEvent = midi.portMin->getEvent(minBuffer, i); | |||
| minEvent = midi.portMin->getEvent(i); | |||
| if (! minEvent) | |||
| continue; | |||
| @@ -1238,11 +1235,6 @@ public: | |||
| if (param.portCout && m_active) | |||
| { | |||
| void* coutBuffer = param.portCout->getBuffer(); | |||
| if (framesOffset == 0 || ! m_activeBefore) | |||
| param.portCout->initBuffer(coutBuffer); | |||
| double value; | |||
| for (k=0; k < param.count; k++) | |||
| @@ -1254,7 +1246,7 @@ public: | |||
| if (param.data[k].midiCC > 0) | |||
| { | |||
| value = (param_buffers[k] - param.ranges[k].min) / (param.ranges[k].max - param.ranges[k].min); | |||
| param.portCout->writeEvent(coutBuffer, CarlaEngineEventControlChange, framesOffset, param.data[k].midiChannel, param.data[k].midiCC, value); | |||
| param.portCout->writeEvent(CarlaEngineEventControlChange, framesOffset, param.data[k].midiChannel, param.data[k].midiCC, value); | |||
| } | |||
| } | |||
| } | |||
| @@ -821,10 +821,9 @@ public: | |||
| if (m_active && m_activeBefore) | |||
| { | |||
| bool allNotesOffSent = false; | |||
| void* cinBuffer = param.portCin->getBuffer(); | |||
| const CarlaEngineControlEvent* cinEvent; | |||
| uint32_t time, nEvents = param.portCin->getEventCount(cinBuffer); | |||
| uint32_t time, nEvents = param.portCin->getEventCount(); | |||
| unsigned char nextBankIds[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0 }; | |||
| @@ -833,7 +832,7 @@ public: | |||
| for (i=0; i < nEvents; i++) | |||
| { | |||
| cinEvent = param.portCin->getEvent(cinBuffer, i); | |||
| cinEvent = param.portCin->getEvent(i); | |||
| if (! cinEvent) | |||
| continue; | |||
| @@ -1034,14 +1033,12 @@ public: | |||
| if (m_active && m_activeBefore) | |||
| { | |||
| void* minBuffer = midi.portMin->getBuffer(); | |||
| const CarlaEngineMidiEvent* minEvent; | |||
| uint32_t time, nEvents = midi.portMin->getEventCount(minBuffer); | |||
| uint32_t time, nEvents = midi.portMin->getEventCount(); | |||
| for (i=0; i < nEvents && midiEventCount < MAX_MIDI_EVENTS; i++) | |||
| { | |||
| minEvent = midi.portMin->getEvent(minBuffer, i); | |||
| minEvent = midi.portMin->getEvent(i); | |||
| if (! minEvent) | |||
| continue; | |||
| @@ -1193,11 +1190,6 @@ public: | |||
| if (m_active) | |||
| { | |||
| void* coutBuffer = param.portCout->getBuffer(); | |||
| if (framesOffset == 0 || ! m_activeBefore) | |||
| param.portCout->initBuffer(coutBuffer); | |||
| k = FluidSynthVoiceCount; | |||
| param_buffers[k] = fluid_synth_get_active_voice_count(f_synth); | |||
| fixParameterValue(param_buffers[k], param.ranges[k]); | |||
| @@ -1205,7 +1197,7 @@ public: | |||
| if (param.data[k].midiCC > 0) | |||
| { | |||
| double value = (param_buffers[k] - param.ranges[k].min) / (param.ranges[k].max - param.ranges[k].min); | |||
| param.portCout->writeEvent(coutBuffer, CarlaEngineEventControlChange, framesOffset, param.data[k].midiChannel, param.data[k].midiCC, value); | |||
| param.portCout->writeEvent(CarlaEngineEventControlChange, framesOffset, param.data[k].midiChannel, param.data[k].midiCC, value); | |||
| } | |||
| } // End of Control Output | |||
| @@ -704,14 +704,12 @@ public: | |||
| if (param.portCin && m_active && m_activeBefore) | |||
| { | |||
| void* cinBuffer = param.portCin->getBuffer(); | |||
| const CarlaEngineControlEvent* cinEvent; | |||
| uint32_t time, nEvents = param.portCin->getEventCount(cinBuffer); | |||
| uint32_t time, nEvents = param.portCin->getEventCount(); | |||
| for (i=0; i < nEvents; i++) | |||
| { | |||
| cinEvent = param.portCin->getEvent(cinBuffer, i); | |||
| cinEvent = param.portCin->getEvent(i); | |||
| if (! cinEvent) | |||
| continue; | |||
| @@ -957,11 +955,6 @@ public: | |||
| if (param.portCout && m_active) | |||
| { | |||
| void* coutBuffer = param.portCout->getBuffer(); | |||
| if (framesOffset == 0 || ! m_activeBefore) | |||
| param.portCout->initBuffer(coutBuffer); | |||
| double value; | |||
| for (k=0; k < param.count; k++) | |||
| @@ -973,7 +966,7 @@ public: | |||
| if (param.data[k].midiCC > 0) | |||
| { | |||
| value = (param_buffers[k] - param.ranges[k].min) / (param.ranges[k].max - param.ranges[k].min); | |||
| param.portCout->writeEvent(coutBuffer, CarlaEngineEventControlChange, framesOffset, param.data[k].midiChannel, param.data[k].midiCC, value); | |||
| param.portCout->writeEvent(CarlaEngineEventControlChange, framesOffset, param.data[k].midiChannel, param.data[k].midiCC, value); | |||
| } | |||
| } | |||
| } | |||
| @@ -414,14 +414,12 @@ public: | |||
| if (m_active && m_activeBefore) | |||
| { | |||
| void* minBuffer = midi.portMin->getBuffer(); | |||
| const CarlaEngineMidiEvent* minEvent; | |||
| uint32_t time, nEvents = midi.portMin->getEventCount(minBuffer); | |||
| uint32_t time, nEvents = midi.portMin->getEventCount(); | |||
| for (i=0; i < nEvents && midiEventCount < MAX_MIDI_EVENTS; i++) | |||
| { | |||
| minEvent = midi.portMin->getEvent(minBuffer, i); | |||
| minEvent = midi.portMin->getEvent(i); | |||
| if (! minEvent) | |||
| continue; | |||
| @@ -1565,9 +1565,6 @@ public: | |||
| double ains_peak_tmp[2] = { 0.0 }; | |||
| double aouts_peak_tmp[2] = { 0.0 }; | |||
| void* evinsBuffer[evin.count]; | |||
| void* evoutsBuffer[evout.count]; | |||
| // handle midi from different APIs | |||
| uint32_t evinAtomOffsets[evin.count]; | |||
| LV2_Event_Iterator evinEventIters[evin.count]; | |||
| @@ -1596,11 +1593,6 @@ public: | |||
| evinMidiStates[i].midi->event_count = 0; | |||
| evinMidiStates[i].midi->size = 0; | |||
| } | |||
| if (evin.data[i].port) | |||
| evinsBuffer[i] = evin.data[i].port->getBuffer(); | |||
| else | |||
| evinsBuffer[i] = nullptr; | |||
| } | |||
| for (i=0; i < evout.count; i++) | |||
| @@ -1620,11 +1612,6 @@ public: | |||
| { | |||
| // not needed | |||
| } | |||
| if (evout.data[i].port) | |||
| evoutsBuffer[i] = evout.data[i].port->getBuffer(); | |||
| else | |||
| evoutsBuffer[i] = nullptr; | |||
| } | |||
| CARLA_PROCESS_CONTINUE_CHECK; | |||
| @@ -1663,10 +1650,9 @@ public: | |||
| if (param.portCin && m_active && m_activeBefore) | |||
| { | |||
| bool allNotesOffSent = false; | |||
| void* cinBuffer = param.portCin->getBuffer(); | |||
| const CarlaEngineControlEvent* cinEvent; | |||
| uint32_t time, nEvents = param.portCin->getEventCount(cinBuffer); | |||
| uint32_t time, nEvents = param.portCin->getEventCount(); | |||
| uint32_t nextBankId = 0; | |||
| if (midiprog.current >= 0 && midiprog.count > 0) | |||
| @@ -1674,7 +1660,7 @@ public: | |||
| for (i=0; i < nEvents; i++) | |||
| { | |||
| cinEvent = param.portCin->getEvent(cinBuffer, i); | |||
| cinEvent = param.portCin->getEvent(i); | |||
| if (! cinEvent) | |||
| continue; | |||
| @@ -1881,21 +1867,17 @@ public: | |||
| if (evin.count > 0 && m_active && m_activeBefore) | |||
| { | |||
| void* minBuffer; | |||
| for (i=0; i < evin.count; i++) | |||
| { | |||
| minBuffer = evinsBuffer[i]; | |||
| if (! minBuffer) | |||
| if (! evin.data[i].port) | |||
| continue; | |||
| const CarlaEngineMidiEvent* minEvent; | |||
| uint32_t time, nEvents = evin.data[i].port->getEventCount(minBuffer); | |||
| uint32_t time, nEvents = evin.data[i].port->getEventCount(); | |||
| for (k=0; k < nEvents && midiEventCount < MAX_MIDI_EVENTS; k++) | |||
| { | |||
| minEvent = evin.data[i].port->getEvent(minBuffer, k); | |||
| minEvent = evin.data[i].port->getEvent(k); | |||
| if (! minEvent) | |||
| continue; | |||
| @@ -2127,11 +2109,6 @@ public: | |||
| if (param.portCout && m_active) | |||
| { | |||
| void* coutBuffer = param.portCout->getBuffer(); | |||
| if (framesOffset == 0 || ! m_activeBefore) | |||
| param.portCout->initBuffer(coutBuffer); | |||
| double value, rvalue; | |||
| for (k=0; k < param.count; k++) | |||
| @@ -2154,7 +2131,7 @@ public: | |||
| } | |||
| rvalue = (value - param.ranges[k].min) / (param.ranges[k].max - param.ranges[k].min); | |||
| param.portCout->writeEvent(coutBuffer, CarlaEngineEventControlChange, framesOffset, param.data[k].midiChannel, param.data[k].midiCC, rvalue); | |||
| param.portCout->writeEvent(CarlaEngineEventControlChange, framesOffset, param.data[k].midiChannel, param.data[k].midiCC, rvalue); | |||
| } | |||
| } | |||
| } | |||
| @@ -2167,18 +2144,11 @@ public: | |||
| if (evout.count > 0 && m_active) | |||
| { | |||
| void* moutBuffer; | |||
| for (i=0; i < evout.count; i++) | |||
| { | |||
| moutBuffer = evoutsBuffer[i]; | |||
| if (! moutBuffer) | |||
| if (! evout.data[i].port) | |||
| continue; | |||
| if (framesOffset == 0 || ! m_activeBefore) | |||
| evout.data[i].port->initBuffer(moutBuffer); | |||
| if (evin.data[i].type & CARLA_EVENT_DATA_ATOM) | |||
| { | |||
| // TODO | |||
| @@ -2196,7 +2166,7 @@ public: | |||
| ev = lv2_event_get(&iter, &data); | |||
| if (ev && data) | |||
| evout.data[i].port->writeEvent(evoutsBuffer[i], ev->frames, data, ev->size); | |||
| evout.data[i].port->writeEvent(ev->frames, data, ev->size); | |||
| lv2_event_increment(&iter); | |||
| } | |||
| @@ -2211,7 +2181,7 @@ public: | |||
| while (lv2midi_get_event(&state, &eventTime, &eventSize, &eventData) < frames) | |||
| { | |||
| evout.data[i].port->writeEvent(evoutsBuffer[i], eventTime, eventData, eventSize); | |||
| evout.data[i].port->writeEvent(eventTime, eventData, eventSize); | |||
| lv2midi_step(&state); | |||
| } | |||
| } | |||
| @@ -2261,6 +2231,25 @@ public: | |||
| qDebug("Lv2Plugin::removeClientPorts() - end"); | |||
| } | |||
| void initBuffers() | |||
| { | |||
| uint32_t i; | |||
| for (i=0; i < evin.count; i++) | |||
| { | |||
| if (evin.data[i].port) | |||
| evin.data[i].port->initBuffer(); | |||
| } | |||
| for (uint32_t i=0; i < evout.count; i++) | |||
| { | |||
| if (evout.data[i].port) | |||
| evout.data[i].port->initBuffer(); | |||
| } | |||
| CarlaPlugin::initBuffers(); | |||
| } | |||
| void deleteBuffers() | |||
| { | |||
| qDebug("Lv2Plugin::deleteBuffers() - start"); | |||
| @@ -2604,7 +2593,7 @@ public: | |||
| return i; | |||
| } | |||
| return 0; | |||
| return LV2UI_INVALID_PORT_INDEX; | |||
| } | |||
| int handleUiResize(int width, int height) | |||
| @@ -709,14 +709,13 @@ public: | |||
| if (param.portCin && m_active && m_activeBefore) | |||
| { | |||
| bool allNotesOffSent = false; | |||
| void* cinBuffer = param.portCin->getBuffer(); | |||
| const CarlaEngineControlEvent* cinEvent; | |||
| uint32_t time, nEvents = param.portCin->getEventCount(cinBuffer); | |||
| uint32_t time, nEvents = param.portCin->getEventCount(); | |||
| for (i=0; i < nEvents; i++) | |||
| { | |||
| cinEvent = param.portCin->getEvent(cinBuffer, i); | |||
| cinEvent = param.portCin->getEvent(i); | |||
| if (! cinEvent) | |||
| continue; | |||
| @@ -897,14 +896,12 @@ public: | |||
| if (midi.portMin && m_active && m_activeBefore) | |||
| { | |||
| void* minBuffer = midi.portMin->getBuffer(); | |||
| const CarlaEngineMidiEvent* minEvent; | |||
| uint32_t time, nEvents = midi.portMin->getEventCount(minBuffer); | |||
| uint32_t time, nEvents = midi.portMin->getEventCount(); | |||
| for (i=0; i < nEvents && midiEventCount < MAX_MIDI_EVENTS; i++) | |||
| { | |||
| minEvent = midi.portMin->getEvent(minBuffer, i); | |||
| minEvent = midi.portMin->getEvent(i); | |||
| if (! minEvent) | |||
| continue; | |||
| @@ -1136,10 +1133,6 @@ public: | |||
| if (midi.portMout && m_active) | |||
| { | |||
| uint8_t data[4]; | |||
| void* moutBuffer = midi.portMout->getBuffer(); | |||
| if (framesOffset == 0 || ! m_activeBefore) | |||
| midi.portMout->initBuffer(moutBuffer); | |||
| for (int32_t i = midiEventCount; i < events.numEvents; i++) | |||
| { | |||
| @@ -1152,7 +1145,7 @@ public: | |||
| if (MIDI_IS_STATUS_NOTE_ON(data[0]) && data[2] == 0) | |||
| data[0] -= 0x10; | |||
| midi.portMout->writeEvent(moutBuffer, midiEvents[i].deltaFrames, data, 3); | |||
| midi.portMout->writeEvent(midiEvents[i].deltaFrames, data, 3); | |||
| } | |||
| } // End of MIDI Output | |||
| @@ -484,7 +484,7 @@ public: | |||
| return i; | |||
| } | |||
| return 0; | |||
| return LV2UI_INVALID_PORT_INDEX; | |||
| } | |||