@@ -51,293 +51,6 @@ CARLA_BACKEND_START_NAMESPACE | |||
} // Fix editor indentation | |||
#endif | |||
// ----------------------------------------------------------------------- | |||
// Fallback data | |||
static const EngineEvent kFallbackEngineEvent = { kEngineEventTypeNull, 0, 0, {{ kEngineControlEventTypeNull, 0, 0.0f }} }; | |||
// ----------------------------------------------------------------------- | |||
// Carla Engine port (Abstract) | |||
CarlaEnginePort::CarlaEnginePort(const CarlaEngineClient& client, const bool isInputPort) noexcept | |||
: fClient(client), | |||
fIsInput(isInputPort) | |||
{ | |||
carla_debug("CarlaEnginePort::CarlaEnginePort(%s)", bool2str(isInputPort)); | |||
} | |||
CarlaEnginePort::~CarlaEnginePort() noexcept | |||
{ | |||
carla_debug("CarlaEnginePort::~CarlaEnginePort()"); | |||
} | |||
// ----------------------------------------------------------------------- | |||
// Carla Engine Audio port | |||
CarlaEngineAudioPort::CarlaEngineAudioPort(const CarlaEngineClient& client, const bool isInputPort) noexcept | |||
: CarlaEnginePort(client, isInputPort), | |||
fBuffer(nullptr) | |||
{ | |||
carla_debug("CarlaEngineAudioPort::CarlaEngineAudioPort(%s)", bool2str(isInputPort)); | |||
} | |||
CarlaEngineAudioPort::~CarlaEngineAudioPort() noexcept | |||
{ | |||
carla_debug("CarlaEngineAudioPort::~CarlaEngineAudioPort()"); | |||
} | |||
void CarlaEngineAudioPort::initBuffer() noexcept | |||
{ | |||
} | |||
// ----------------------------------------------------------------------- | |||
// Carla Engine CV port | |||
CarlaEngineCVPort::CarlaEngineCVPort(const CarlaEngineClient& client, const bool isInputPort) noexcept | |||
: CarlaEnginePort(client, isInputPort), | |||
fBuffer(nullptr) | |||
{ | |||
carla_debug("CarlaEngineCVPort::CarlaEngineCVPort(%s)", bool2str(isInputPort)); | |||
} | |||
CarlaEngineCVPort::~CarlaEngineCVPort() noexcept | |||
{ | |||
carla_debug("CarlaEngineCVPort::~CarlaEngineCVPort()"); | |||
} | |||
void CarlaEngineCVPort::initBuffer() noexcept | |||
{ | |||
} | |||
// ----------------------------------------------------------------------- | |||
// Carla Engine Event port | |||
CarlaEngineEventPort::CarlaEngineEventPort(const CarlaEngineClient& client, const bool isInputPort) noexcept | |||
: CarlaEnginePort(client, isInputPort), | |||
fBuffer(nullptr), | |||
fProcessMode(client.getEngine().getProccessMode()) | |||
{ | |||
carla_debug("CarlaEngineEventPort::CarlaEngineEventPort(%s)", bool2str(isInputPort)); | |||
if (fProcessMode == ENGINE_PROCESS_MODE_PATCHBAY) | |||
fBuffer = new EngineEvent[kMaxEngineEventInternalCount]; | |||
} | |||
CarlaEngineEventPort::~CarlaEngineEventPort() noexcept | |||
{ | |||
carla_debug("CarlaEngineEventPort::~CarlaEngineEventPort()"); | |||
if (fProcessMode == ENGINE_PROCESS_MODE_PATCHBAY) | |||
{ | |||
CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr,); | |||
delete[] fBuffer; | |||
fBuffer = nullptr; | |||
} | |||
} | |||
void CarlaEngineEventPort::initBuffer() noexcept | |||
{ | |||
if (fProcessMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK || fProcessMode == ENGINE_PROCESS_MODE_BRIDGE) | |||
fBuffer = fClient.getEngine().getInternalEventBuffer(fIsInput); | |||
else if (fProcessMode == ENGINE_PROCESS_MODE_PATCHBAY && ! fIsInput) | |||
carla_zeroStruct<EngineEvent>(fBuffer, kMaxEngineEventInternalCount); | |||
} | |||
uint32_t CarlaEngineEventPort::getEventCount() const noexcept | |||
{ | |||
CARLA_SAFE_ASSERT_RETURN(fIsInput, 0); | |||
CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr, 0); | |||
CARLA_SAFE_ASSERT_RETURN(fProcessMode != ENGINE_PROCESS_MODE_SINGLE_CLIENT && fProcessMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS, 0); | |||
uint32_t i=0; | |||
for (; i < kMaxEngineEventInternalCount; ++i) | |||
{ | |||
if (fBuffer[i].type == kEngineEventTypeNull) | |||
break; | |||
} | |||
return i; | |||
} | |||
const EngineEvent& CarlaEngineEventPort::getEvent(const uint32_t index) const noexcept | |||
{ | |||
CARLA_SAFE_ASSERT_RETURN(fIsInput, kFallbackEngineEvent); | |||
CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr, kFallbackEngineEvent); | |||
CARLA_SAFE_ASSERT_RETURN(fProcessMode != ENGINE_PROCESS_MODE_SINGLE_CLIENT && fProcessMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS, kFallbackEngineEvent); | |||
CARLA_SAFE_ASSERT_RETURN(index < kMaxEngineEventInternalCount, kFallbackEngineEvent); | |||
return fBuffer[index]; | |||
} | |||
const EngineEvent& CarlaEngineEventPort::getEventUnchecked(const uint32_t index) const noexcept | |||
{ | |||
return fBuffer[index]; | |||
} | |||
bool CarlaEngineEventPort::writeControlEvent(const uint32_t time, const uint8_t channel, const EngineControlEvent& ctrl) noexcept | |||
{ | |||
return writeControlEvent(time, channel, ctrl.type, ctrl.param, ctrl.value); | |||
} | |||
bool CarlaEngineEventPort::writeControlEvent(const uint32_t time, const uint8_t channel, const EngineControlEventType type, const uint16_t param, const float value) noexcept | |||
{ | |||
CARLA_SAFE_ASSERT_RETURN(! fIsInput, false); | |||
CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr, false); | |||
CARLA_SAFE_ASSERT_RETURN(fProcessMode != ENGINE_PROCESS_MODE_SINGLE_CLIENT && fProcessMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS, false); | |||
CARLA_SAFE_ASSERT_RETURN(type != kEngineControlEventTypeNull, false); | |||
CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS, false); | |||
CARLA_SAFE_ASSERT(value >= 0.0f && value <= 1.0f); | |||
if (type == kEngineControlEventTypeParameter) { | |||
CARLA_SAFE_ASSERT(! MIDI_IS_CONTROL_BANK_SELECT(param)); | |||
} | |||
for (uint32_t i=0; i < kMaxEngineEventInternalCount; ++i) | |||
{ | |||
EngineEvent& event(fBuffer[i]); | |||
if (event.type != kEngineEventTypeNull) | |||
continue; | |||
event.type = kEngineEventTypeControl; | |||
event.time = time; | |||
event.channel = channel; | |||
event.ctrl.type = type; | |||
event.ctrl.param = param; | |||
event.ctrl.value = carla_fixValue<float>(0.0f, 1.0f, value); | |||
return true; | |||
} | |||
carla_stderr2("CarlaEngineEventPort::writeControlEvent() - buffer full"); | |||
return false; | |||
} | |||
bool CarlaEngineEventPort::writeMidiEvent(const uint32_t time, const uint8_t size, const uint8_t* const data) noexcept | |||
{ | |||
return writeMidiEvent(time, uint8_t(MIDI_GET_CHANNEL_FROM_DATA(data)), 0, size, data); | |||
} | |||
bool CarlaEngineEventPort::writeMidiEvent(const uint32_t time, const uint8_t channel, const EngineMidiEvent& midi) noexcept | |||
{ | |||
return writeMidiEvent(time, channel, midi.port, midi.size, midi.data); | |||
} | |||
bool CarlaEngineEventPort::writeMidiEvent(const uint32_t time, const uint8_t channel, const uint8_t port, const uint8_t size, const uint8_t* const data) noexcept | |||
{ | |||
CARLA_SAFE_ASSERT_RETURN(! fIsInput, false); | |||
CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr, false); | |||
CARLA_SAFE_ASSERT_RETURN(fProcessMode != ENGINE_PROCESS_MODE_SINGLE_CLIENT && fProcessMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS, false); | |||
CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS, false); | |||
CARLA_SAFE_ASSERT_RETURN(size > 0 && size <= EngineMidiEvent::kDataSize, false); | |||
CARLA_SAFE_ASSERT_RETURN(data != nullptr, false); | |||
for (uint32_t i=0; i < kMaxEngineEventInternalCount; ++i) | |||
{ | |||
EngineEvent& event(fBuffer[i]); | |||
if (event.type != kEngineEventTypeNull) | |||
continue; | |||
event.type = kEngineEventTypeMidi; | |||
event.time = time; | |||
event.channel = channel; | |||
event.midi.port = port; | |||
event.midi.size = size; | |||
event.midi.data[0] = uint8_t(MIDI_GET_STATUS_FROM_DATA(data)); | |||
uint8_t j=1; | |||
for (; j < size; ++j) | |||
event.midi.data[j] = data[j]; | |||
for (; j < EngineMidiEvent::kDataSize; ++j) | |||
event.midi.data[j] = 0; | |||
return true; | |||
} | |||
carla_stderr2("CarlaEngineEventPort::writeMidiEvent() - buffer full"); | |||
return false; | |||
} | |||
// ----------------------------------------------------------------------- | |||
// Carla Engine client (Abstract) | |||
CarlaEngineClient::CarlaEngineClient(const CarlaEngine& engine) noexcept | |||
: fEngine(engine), | |||
fActive(false), | |||
fLatency(0) | |||
{ | |||
carla_debug("CarlaEngineClient::CarlaEngineClient()"); | |||
} | |||
CarlaEngineClient::~CarlaEngineClient() noexcept | |||
{ | |||
CARLA_SAFE_ASSERT(! fActive); | |||
carla_debug("CarlaEngineClient::~CarlaEngineClient()"); | |||
} | |||
void CarlaEngineClient::activate() noexcept | |||
{ | |||
CARLA_SAFE_ASSERT(! fActive); | |||
carla_debug("CarlaEngineClient::activate()"); | |||
fActive = true; | |||
} | |||
void CarlaEngineClient::deactivate() noexcept | |||
{ | |||
CARLA_SAFE_ASSERT(fActive); | |||
carla_debug("CarlaEngineClient::deactivate()"); | |||
fActive = false; | |||
} | |||
bool CarlaEngineClient::isActive() const noexcept | |||
{ | |||
return fActive; | |||
} | |||
bool CarlaEngineClient::isOk() const noexcept | |||
{ | |||
return true; | |||
} | |||
uint32_t CarlaEngineClient::getLatency() const noexcept | |||
{ | |||
return fLatency; | |||
} | |||
void CarlaEngineClient::setLatency(const uint32_t samples) noexcept | |||
{ | |||
fLatency = samples; | |||
} | |||
CarlaEnginePort* CarlaEngineClient::addPort(const EnginePortType portType, const char* const name, const bool isInput) | |||
{ | |||
CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', nullptr); | |||
carla_debug("CarlaEngineClient::addPort(%i:%s, \"%s\", %s)", portType, EnginePortType2Str(portType), name, bool2str(isInput)); | |||
switch (portType) | |||
{ | |||
case kEnginePortTypeNull: | |||
break; | |||
case kEnginePortTypeAudio: | |||
return new CarlaEngineAudioPort(*this, isInput); | |||
case kEnginePortTypeCV: | |||
return new CarlaEngineCVPort(*this, isInput); | |||
case kEnginePortTypeEvent: | |||
return new CarlaEngineEventPort(*this, isInput); | |||
} | |||
carla_stderr("CarlaEngineClient::addPort(%i, \"%s\", %s) - invalid type", portType, name, bool2str(isInput)); | |||
return nullptr; | |||
} | |||
// ----------------------------------------------------------------------- | |||
// Carla Engine | |||
@@ -1830,7 +1543,6 @@ const char* CarlaEngine::getOscServerPathUDP() const noexcept | |||
#ifdef BUILD_BRIDGE | |||
void CarlaEngine::setOscBridgeData(const CarlaOscData* const oscData) const noexcept | |||
{ | |||
pData->oscData = oscData; | |||
} | |||
#endif | |||
@@ -0,0 +1,98 @@ | |||
/* | |||
* Carla Plugin Host | |||
* Copyright (C) 2011-2014 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License as | |||
* published by the Free Software Foundation; either version 2 of | |||
* the License, or any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
*/ | |||
#include "CarlaEngineUtils.hpp" | |||
CARLA_BACKEND_START_NAMESPACE | |||
// ----------------------------------------------------------------------- | |||
// Carla Engine client (Abstract) | |||
CarlaEngineClient::CarlaEngineClient(const CarlaEngine& engine) noexcept | |||
: fEngine(engine), | |||
fActive(false), | |||
fLatency(0) | |||
{ | |||
carla_debug("CarlaEngineClient::CarlaEngineClient()"); | |||
} | |||
CarlaEngineClient::~CarlaEngineClient() noexcept | |||
{ | |||
CARLA_SAFE_ASSERT(! fActive); | |||
carla_debug("CarlaEngineClient::~CarlaEngineClient()"); | |||
} | |||
void CarlaEngineClient::activate() noexcept | |||
{ | |||
CARLA_SAFE_ASSERT(! fActive); | |||
carla_debug("CarlaEngineClient::activate()"); | |||
fActive = true; | |||
} | |||
void CarlaEngineClient::deactivate() noexcept | |||
{ | |||
CARLA_SAFE_ASSERT(fActive); | |||
carla_debug("CarlaEngineClient::deactivate()"); | |||
fActive = false; | |||
} | |||
bool CarlaEngineClient::isActive() const noexcept | |||
{ | |||
return fActive; | |||
} | |||
bool CarlaEngineClient::isOk() const noexcept | |||
{ | |||
return true; | |||
} | |||
uint32_t CarlaEngineClient::getLatency() const noexcept | |||
{ | |||
return fLatency; | |||
} | |||
void CarlaEngineClient::setLatency(const uint32_t samples) noexcept | |||
{ | |||
fLatency = samples; | |||
} | |||
CarlaEnginePort* CarlaEngineClient::addPort(const EnginePortType portType, const char* const name, const bool isInput) | |||
{ | |||
CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', nullptr); | |||
carla_debug("CarlaEngineClient::addPort(%i:%s, \"%s\", %s)", portType, EnginePortType2Str(portType), name, bool2str(isInput)); | |||
switch (portType) | |||
{ | |||
case kEnginePortTypeNull: | |||
break; | |||
case kEnginePortTypeAudio: | |||
return new CarlaEngineAudioPort(*this, isInput); | |||
case kEnginePortTypeCV: | |||
return new CarlaEngineCVPort(*this, isInput); | |||
case kEnginePortTypeEvent: | |||
return new CarlaEngineEventPort(*this, isInput); | |||
} | |||
carla_stderr("CarlaEngineClient::addPort(%i, \"%s\", %s) - invalid type", portType, name, bool2str(isInput)); | |||
return nullptr; | |||
} | |||
// ----------------------------------------------------------------------- | |||
CARLA_BACKEND_END_NAMESPACE |
@@ -19,14 +19,8 @@ | |||
#include "CarlaMathUtils.hpp" | |||
#include "CarlaMIDI.h" | |||
// ----------------------------------------------------------------------- | |||
CARLA_BACKEND_START_NAMESPACE | |||
#if 0 | |||
} // Fix editor indentation | |||
#endif | |||
// ----------------------------------------------------------------------- | |||
// EngineControlEvent | |||
@@ -21,6 +21,9 @@ | |||
#include "CarlaMathUtils.hpp" | |||
#include "juce_audio_basics.h" | |||
using juce::FloatVectorOperations; | |||
// ----------------------------------------------------------------------- | |||
// Engine Internal helper macro, sets lastError and returns false/NULL | |||
@@ -21,6 +21,7 @@ | |||
#include "CarlaEngine.hpp" | |||
#include "CarlaEngineOsc.hpp" | |||
#include "CarlaEngineThread.hpp" | |||
#include "CarlaEngineUtils.hpp" | |||
#include "CarlaMathUtils.hpp" | |||
#include "CarlaPatchbayUtils.hpp" | |||
@@ -40,11 +41,6 @@ CARLA_BACKEND_START_NAMESPACE | |||
} // Fix editor indentation | |||
#endif | |||
// ----------------------------------------------------------------------- | |||
// Maximum pre-allocated events for rack and bridge modes | |||
const ushort kMaxEngineEventInternalCount = 512; | |||
// ----------------------------------------------------------------------- | |||
// Patchbay stuff | |||
@@ -0,0 +1,239 @@ | |||
/* | |||
* Carla Plugin Host | |||
* Copyright (C) 2011-2014 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License as | |||
* published by the Free Software Foundation; either version 2 of | |||
* the License, or any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
*/ | |||
#include "CarlaEngineUtils.hpp" | |||
#include "CarlaMathUtils.hpp" | |||
#include "CarlaMIDI.h" | |||
CARLA_BACKEND_START_NAMESPACE | |||
// ----------------------------------------------------------------------- | |||
// Fallback data | |||
static const EngineEvent kFallbackEngineEvent = { kEngineEventTypeNull, 0, 0, {{ kEngineControlEventTypeNull, 0, 0.0f }} }; | |||
// ----------------------------------------------------------------------- | |||
// Carla Engine port (Abstract) | |||
CarlaEnginePort::CarlaEnginePort(const CarlaEngineClient& client, const bool isInputPort) noexcept | |||
: fClient(client), | |||
fIsInput(isInputPort) | |||
{ | |||
carla_debug("CarlaEnginePort::CarlaEnginePort(%s)", bool2str(isInputPort)); | |||
} | |||
CarlaEnginePort::~CarlaEnginePort() noexcept | |||
{ | |||
carla_debug("CarlaEnginePort::~CarlaEnginePort()"); | |||
} | |||
// ----------------------------------------------------------------------- | |||
// Carla Engine Audio port | |||
CarlaEngineAudioPort::CarlaEngineAudioPort(const CarlaEngineClient& client, const bool isInputPort) noexcept | |||
: CarlaEnginePort(client, isInputPort), | |||
fBuffer(nullptr) | |||
{ | |||
carla_debug("CarlaEngineAudioPort::CarlaEngineAudioPort(%s)", bool2str(isInputPort)); | |||
} | |||
CarlaEngineAudioPort::~CarlaEngineAudioPort() noexcept | |||
{ | |||
carla_debug("CarlaEngineAudioPort::~CarlaEngineAudioPort()"); | |||
} | |||
void CarlaEngineAudioPort::initBuffer() noexcept | |||
{ | |||
} | |||
// ----------------------------------------------------------------------- | |||
// Carla Engine CV port | |||
CarlaEngineCVPort::CarlaEngineCVPort(const CarlaEngineClient& client, const bool isInputPort) noexcept | |||
: CarlaEnginePort(client, isInputPort), | |||
fBuffer(nullptr) | |||
{ | |||
carla_debug("CarlaEngineCVPort::CarlaEngineCVPort(%s)", bool2str(isInputPort)); | |||
} | |||
CarlaEngineCVPort::~CarlaEngineCVPort() noexcept | |||
{ | |||
carla_debug("CarlaEngineCVPort::~CarlaEngineCVPort()"); | |||
} | |||
void CarlaEngineCVPort::initBuffer() noexcept | |||
{ | |||
} | |||
// ----------------------------------------------------------------------- | |||
// Carla Engine Event port | |||
CarlaEngineEventPort::CarlaEngineEventPort(const CarlaEngineClient& client, const bool isInputPort) noexcept | |||
: CarlaEnginePort(client, isInputPort), | |||
fBuffer(nullptr), | |||
fProcessMode(client.getEngine().getProccessMode()) | |||
{ | |||
carla_debug("CarlaEngineEventPort::CarlaEngineEventPort(%s)", bool2str(isInputPort)); | |||
if (fProcessMode == ENGINE_PROCESS_MODE_PATCHBAY) | |||
fBuffer = new EngineEvent[kMaxEngineEventInternalCount]; | |||
} | |||
CarlaEngineEventPort::~CarlaEngineEventPort() noexcept | |||
{ | |||
carla_debug("CarlaEngineEventPort::~CarlaEngineEventPort()"); | |||
if (fProcessMode == ENGINE_PROCESS_MODE_PATCHBAY) | |||
{ | |||
CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr,); | |||
delete[] fBuffer; | |||
fBuffer = nullptr; | |||
} | |||
} | |||
void CarlaEngineEventPort::initBuffer() noexcept | |||
{ | |||
if (fProcessMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK || fProcessMode == ENGINE_PROCESS_MODE_BRIDGE) | |||
fBuffer = fClient.getEngine().getInternalEventBuffer(fIsInput); | |||
else if (fProcessMode == ENGINE_PROCESS_MODE_PATCHBAY && ! fIsInput) | |||
carla_zeroStruct<EngineEvent>(fBuffer, kMaxEngineEventInternalCount); | |||
} | |||
uint32_t CarlaEngineEventPort::getEventCount() const noexcept | |||
{ | |||
CARLA_SAFE_ASSERT_RETURN(fIsInput, 0); | |||
CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr, 0); | |||
CARLA_SAFE_ASSERT_RETURN(fProcessMode != ENGINE_PROCESS_MODE_SINGLE_CLIENT && fProcessMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS, 0); | |||
uint32_t i=0; | |||
for (; i < kMaxEngineEventInternalCount; ++i) | |||
{ | |||
if (fBuffer[i].type == kEngineEventTypeNull) | |||
break; | |||
} | |||
return i; | |||
} | |||
const EngineEvent& CarlaEngineEventPort::getEvent(const uint32_t index) const noexcept | |||
{ | |||
CARLA_SAFE_ASSERT_RETURN(fIsInput, kFallbackEngineEvent); | |||
CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr, kFallbackEngineEvent); | |||
CARLA_SAFE_ASSERT_RETURN(fProcessMode != ENGINE_PROCESS_MODE_SINGLE_CLIENT && fProcessMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS, kFallbackEngineEvent); | |||
CARLA_SAFE_ASSERT_RETURN(index < kMaxEngineEventInternalCount, kFallbackEngineEvent); | |||
return fBuffer[index]; | |||
} | |||
const EngineEvent& CarlaEngineEventPort::getEventUnchecked(const uint32_t index) const noexcept | |||
{ | |||
return fBuffer[index]; | |||
} | |||
bool CarlaEngineEventPort::writeControlEvent(const uint32_t time, const uint8_t channel, const EngineControlEvent& ctrl) noexcept | |||
{ | |||
return writeControlEvent(time, channel, ctrl.type, ctrl.param, ctrl.value); | |||
} | |||
bool CarlaEngineEventPort::writeControlEvent(const uint32_t time, const uint8_t channel, const EngineControlEventType type, const uint16_t param, const float value) noexcept | |||
{ | |||
CARLA_SAFE_ASSERT_RETURN(! fIsInput, false); | |||
CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr, false); | |||
CARLA_SAFE_ASSERT_RETURN(fProcessMode != ENGINE_PROCESS_MODE_SINGLE_CLIENT && fProcessMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS, false); | |||
CARLA_SAFE_ASSERT_RETURN(type != kEngineControlEventTypeNull, false); | |||
CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS, false); | |||
CARLA_SAFE_ASSERT(value >= 0.0f && value <= 1.0f); | |||
if (type == kEngineControlEventTypeParameter) { | |||
CARLA_SAFE_ASSERT(! MIDI_IS_CONTROL_BANK_SELECT(param)); | |||
} | |||
for (uint32_t i=0; i < kMaxEngineEventInternalCount; ++i) | |||
{ | |||
EngineEvent& event(fBuffer[i]); | |||
if (event.type != kEngineEventTypeNull) | |||
continue; | |||
event.type = kEngineEventTypeControl; | |||
event.time = time; | |||
event.channel = channel; | |||
event.ctrl.type = type; | |||
event.ctrl.param = param; | |||
event.ctrl.value = carla_fixValue<float>(0.0f, 1.0f, value); | |||
return true; | |||
} | |||
carla_stderr2("CarlaEngineEventPort::writeControlEvent() - buffer full"); | |||
return false; | |||
} | |||
bool CarlaEngineEventPort::writeMidiEvent(const uint32_t time, const uint8_t size, const uint8_t* const data) noexcept | |||
{ | |||
return writeMidiEvent(time, uint8_t(MIDI_GET_CHANNEL_FROM_DATA(data)), 0, size, data); | |||
} | |||
bool CarlaEngineEventPort::writeMidiEvent(const uint32_t time, const uint8_t channel, const EngineMidiEvent& midi) noexcept | |||
{ | |||
return writeMidiEvent(time, channel, midi.port, midi.size, midi.data); | |||
} | |||
bool CarlaEngineEventPort::writeMidiEvent(const uint32_t time, const uint8_t channel, const uint8_t port, const uint8_t size, const uint8_t* const data) noexcept | |||
{ | |||
CARLA_SAFE_ASSERT_RETURN(! fIsInput, false); | |||
CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr, false); | |||
CARLA_SAFE_ASSERT_RETURN(fProcessMode != ENGINE_PROCESS_MODE_SINGLE_CLIENT && fProcessMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS, false); | |||
CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS, false); | |||
CARLA_SAFE_ASSERT_RETURN(size > 0 && size <= EngineMidiEvent::kDataSize, false); | |||
CARLA_SAFE_ASSERT_RETURN(data != nullptr, false); | |||
for (uint32_t i=0; i < kMaxEngineEventInternalCount; ++i) | |||
{ | |||
EngineEvent& event(fBuffer[i]); | |||
if (event.type != kEngineEventTypeNull) | |||
continue; | |||
event.type = kEngineEventTypeMidi; | |||
event.time = time; | |||
event.channel = channel; | |||
event.midi.port = port; | |||
event.midi.size = size; | |||
event.midi.data[0] = uint8_t(MIDI_GET_STATUS_FROM_DATA(data)); | |||
uint8_t j=1; | |||
for (; j < size; ++j) | |||
event.midi.data[j] = data[j]; | |||
for (; j < EngineMidiEvent::kDataSize; ++j) | |||
event.midi.data[j] = 0; | |||
return true; | |||
} | |||
carla_stderr2("CarlaEngineEventPort::writeMidiEvent() - buffer full"); | |||
return false; | |||
} | |||
// ----------------------------------------------------------------------- | |||
CARLA_BACKEND_END_NAMESPACE |
@@ -10,9 +10,11 @@ include ../Makefile.mk | |||
OBJS = \ | |||
CarlaEngine.cpp.o \ | |||
CarlaEngineClient.cpp.o \ | |||
CarlaEngineData.cpp.o \ | |||
CarlaEngineInternal.cpp.o \ | |||
CarlaEngineOsc.cpp.o \ | |||
CarlaEnginePorts.cpp.o \ | |||
CarlaEngineThread.cpp.o | |||
OBJSa = $(OBJS) \ | |||
@@ -63,6 +65,9 @@ debug: | |||
CarlaEngine.cpp.o: CarlaEngine.cpp $(CARLA_ENGINE_CPP_DEPS) | |||
$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||
CarlaEngineClient.cpp.o: CarlaEngineClient.cpp $(CARLA_ENGINE_CLIENT_CPP_DEPS) | |||
$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||
CarlaEngineData.cpp.o: CarlaEngineData.cpp $(CARLA_ENGINE_DATA_CPP_DEPS) | |||
$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||
@@ -72,6 +77,9 @@ CarlaEngineInternal.cpp.o: CarlaEngineInternal.cpp $(CARLA_ENGINE_INTERNAL_CPP_D | |||
CarlaEngineOsc.cpp.o: CarlaEngineOsc.cpp $(CARLA_ENGINE_OSC_CPP_DEPS) | |||
$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||
CarlaEnginePorts.cpp.o: CarlaEnginePorts.cpp $(CARLA_ENGINE_PORTS_CPP_DEPS) | |||
$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||
CarlaEngineThread.cpp.o: CarlaEngineThread.cpp $(CARLA_ENGINE_THREAD_CPP_DEPS) | |||
$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||
@@ -463,9 +463,11 @@ OBJS_NATIVE = CarlaBridgePlugin__native.o \ | |||
# carla-engine | |||
OBJS_NATIVE += \ | |||
../backend/engine/CarlaEngine__native.o \ | |||
../backend/engine/CarlaEngineClient__native.o \ | |||
../backend/engine/CarlaEngineData__native.o \ | |||
../backend/engine/CarlaEngineInternal__native.o \ | |||
../backend/engine/CarlaEngineOsc__native.o \ | |||
../backend/engine/CarlaEnginePorts__native.o \ | |||
../backend/engine/CarlaEngineThread__native.o \ | |||
../backend/engine/CarlaEngineJack__native.o \ | |||
../backend/engine/CarlaEngineBridge__native.o | |||
@@ -23,6 +23,11 @@ | |||
CARLA_BACKEND_START_NAMESPACE | |||
// ----------------------------------------------------------------------- | |||
// Maximum internal pre-allocated events | |||
const ushort kMaxEngineEventInternalCount = 512; | |||
// ----------------------------------------------------------------------- | |||
static inline | |||
@@ -22,23 +22,24 @@ | |||
#include <cmath> | |||
#ifdef HAVE_JUCE | |||
# include "juce_audio_basics.h" | |||
using juce::FloatVectorOperations; | |||
#endif | |||
// TODO - always use juce | |||
// #ifdef HAVE_JUCE | |||
// # include "juce_audio_basics.h" | |||
// using juce::FloatVectorOperations; | |||
// #endif | |||
// ----------------------------------------------------------------------- | |||
// Float operations | |||
#ifdef HAVE_JUCE | |||
# define FLOAT_ADD(bufDst, bufSrc, frames) FloatVectorOperations::add(bufDst, bufSrc, static_cast<int>(frames)) | |||
# define FLOAT_COPY(bufDst, bufSrc, frames) FloatVectorOperations::copy(bufDst, bufSrc, static_cast<int>(frames)) | |||
# define FLOAT_CLEAR(buf, frames) FloatVectorOperations::clear(buf, static_cast<int>(frames)) | |||
#else | |||
// #ifdef HAVE_JUCE | |||
// # define FLOAT_ADD(bufDst, bufSrc, frames) FloatVectorOperations::add(bufDst, bufSrc, static_cast<int>(frames)) | |||
// # define FLOAT_COPY(bufDst, bufSrc, frames) FloatVectorOperations::copy(bufDst, bufSrc, static_cast<int>(frames)) | |||
// # define FLOAT_CLEAR(buf, frames) FloatVectorOperations::clear(buf, static_cast<int>(frames)) | |||
// #else | |||
# define FLOAT_ADD(bufDst, bufSrc, frames) carla_addFloat(bufDst, bufSrc, frames) | |||
# define FLOAT_COPY(bufDst, bufSrc, frames) carla_copyFloat(bufDst, bufSrc, frames) | |||
# define FLOAT_CLEAR(buf, frames) carla_zeroFloat(buf, frames) | |||
#endif | |||
// #endif | |||
// ----------------------------------------------------------------------- | |||
// math functions (base) | |||