| @@ -1273,53 +1273,6 @@ void CarlaEngine::setFileCallback(const FileCallbackFunc func, void* const ptr) | |||||
| pData->fileCallbackPtr = ptr; | pData->fileCallbackPtr = ptr; | ||||
| } | } | ||||
| #ifndef BUILD_BRIDGE | |||||
| // ----------------------------------------------------------------------- | |||||
| // Patchbay | |||||
| bool CarlaEngine::patchbayConnect(const uint groupA, const uint portA, const uint groupB, const uint portB) | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK || pData->options.processMode == ENGINE_PROCESS_MODE_PATCHBAY, false); | |||||
| CARLA_SAFE_ASSERT_RETURN(pData->audio.isReady, false); | |||||
| carla_debug("CarlaEngine::patchbayConnect(%u, %u, %u, %u)", groupA, portA, groupB, portB); | |||||
| if (pData->graph.isRack) | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(pData->graph.rack != nullptr, nullptr); | |||||
| return pData->graph.rack->connect(this, groupA, portA, groupB, portB); | |||||
| } | |||||
| else | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(pData->graph.patchbay != nullptr, nullptr); | |||||
| return pData->graph.patchbay->connect(this, groupA, portA, groupB, portB); | |||||
| } | |||||
| } | |||||
| bool CarlaEngine::patchbayDisconnect(const uint connectionId) | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK || pData->options.processMode == ENGINE_PROCESS_MODE_PATCHBAY, false); | |||||
| CARLA_SAFE_ASSERT_RETURN(pData->audio.isReady, false); | |||||
| carla_debug("CarlaEngine::patchbayDisconnect(%u)", connectionId); | |||||
| if (pData->graph.isRack) | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(pData->graph.rack != nullptr, nullptr); | |||||
| return pData->graph.rack->disconnect(this, connectionId); | |||||
| } | |||||
| else | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(pData->graph.patchbay != nullptr, nullptr); | |||||
| return pData->graph.patchbay->disconnect(this, connectionId); | |||||
| } | |||||
| } | |||||
| bool CarlaEngine::patchbayRefresh() | |||||
| { | |||||
| setLastError("Unsupported operation"); | |||||
| return false; | |||||
| } | |||||
| #endif | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // Transport | // Transport | ||||
| @@ -1588,56 +1541,6 @@ void CarlaEngine::setPluginPeaks(const uint pluginId, float const inPeaks[2], fl | |||||
| pluginData.outsPeak[1] = outPeaks[1]; | pluginData.outsPeak[1] = outPeaks[1]; | ||||
| } | } | ||||
| #ifndef BUILD_BRIDGE | |||||
| // ----------------------------------------------------------------------- | |||||
| // Patchbay stuff | |||||
| const char* const* CarlaEngine::getPatchbayConnections() const | |||||
| { | |||||
| carla_debug("CarlaEngine::getPatchbayConnections()"); | |||||
| if (pData->graph.isRack) | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(pData->graph.rack != nullptr, nullptr); | |||||
| return pData->graph.rack->getConnections(); | |||||
| } | |||||
| else | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(pData->graph.patchbay != nullptr, nullptr); | |||||
| return pData->graph.patchbay->getConnections(); | |||||
| } | |||||
| } | |||||
| void CarlaEngine::restorePatchbayConnection(const char* const connSource, const char* const connTarget) | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(connSource != nullptr && connSource[0] != '\0',); | |||||
| CARLA_SAFE_ASSERT_RETURN(connTarget != nullptr && connTarget[0] != '\0',); | |||||
| carla_debug("CarlaEngine::restorePatchbayConnection(\"%s\", \"%s\")", connSource, connTarget); | |||||
| uint groupA, portA; | |||||
| uint groupB, portB; | |||||
| if (pData->graph.isRack) | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(pData->graph.rack != nullptr,); | |||||
| if (! pData->graph.rack->getPortIdFromFullName(connSource, groupA, portA)) | |||||
| return; | |||||
| if (! pData->graph.rack->getPortIdFromFullName(connTarget, groupB, portB)) | |||||
| return; | |||||
| } | |||||
| else | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(pData->graph.patchbay != nullptr,); | |||||
| if (! pData->graph.patchbay->getPortIdFromFullName(connSource, groupA, portA)) | |||||
| return; | |||||
| if (! pData->graph.patchbay->getPortIdFromFullName(connTarget, groupB, portB)) | |||||
| return; | |||||
| } | |||||
| patchbayConnect(groupA, portA, groupB, portB); | |||||
| } | |||||
| #endif | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // Bridge/Controller OSC stuff | // Bridge/Controller OSC stuff | ||||
| @@ -24,414 +24,176 @@ | |||||
| #include "juce_audio_basics.h" | #include "juce_audio_basics.h" | ||||
| using juce::FloatVectorOperations; | using juce::FloatVectorOperations; | ||||
| CARLA_BACKEND_START_NAMESPACE | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // Engine Internal helper macro, sets lastError and returns false/NULL | // Engine Internal helper macro, sets lastError and returns false/NULL | ||||
| #define CARLA_SAFE_ASSERT_RETURN_INTERNAL_ERR(cond, err) if (! (cond)) { carla_safe_assert(#cond, __FILE__, __LINE__); lastError = err; return false; } | #define CARLA_SAFE_ASSERT_RETURN_INTERNAL_ERR(cond, err) if (! (cond)) { carla_safe_assert(#cond, __FILE__, __LINE__); lastError = err; return false; } | ||||
| #define CARLA_SAFE_ASSERT_RETURN_INTERNAL_ERRN(cond, err) if (! (cond)) { carla_safe_assert(#cond, __FILE__, __LINE__); lastError = err; return nullptr; } | #define CARLA_SAFE_ASSERT_RETURN_INTERNAL_ERRN(cond, err) if (! (cond)) { carla_safe_assert(#cond, __FILE__, __LINE__); lastError = err; return nullptr; } | ||||
| // ----------------------------------------------------------------------- | |||||
| CARLA_BACKEND_START_NAMESPACE | |||||
| #if 0 | #if 0 | ||||
| } // Fix editor indentation | |||||
| #endif | |||||
| #ifndef BUILD_BRIDGE | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // Rack Patchbay stuff | |||||
| // InternalAudio | |||||
| static uint getCarlaRackPortIdFromName(const char* const shortname) noexcept | |||||
| EngineInternalAudio::EngineInternalAudio() noexcept | |||||
| : isReady(false), | |||||
| inCount(0), | |||||
| outCount(0), | |||||
| inBuf(nullptr), | |||||
| outBuf(nullptr) {} | |||||
| EngineInternalAudio::~EngineInternalAudio() noexcept | |||||
| { | { | ||||
| if (std::strcmp(shortname, "AudioIn1") == 0 || std::strcmp(shortname, "audio-in1") == 0) | |||||
| return RACK_GRAPH_CARLA_PORT_AUDIO_IN1; | |||||
| if (std::strcmp(shortname, "AudioIn2") == 0 || std::strcmp(shortname, "audio-in2") == 0) | |||||
| return RACK_GRAPH_CARLA_PORT_AUDIO_IN2; | |||||
| if (std::strcmp(shortname, "AudioOut1") == 0 || std::strcmp(shortname, "audio-out1") == 0) | |||||
| return RACK_GRAPH_CARLA_PORT_AUDIO_OUT1; | |||||
| if (std::strcmp(shortname, "AudioOut2") == 0 || std::strcmp(shortname, "audio-out2") == 0) | |||||
| return RACK_GRAPH_CARLA_PORT_AUDIO_OUT2; | |||||
| if (std::strcmp(shortname, "MidiIn") == 0 || std::strcmp(shortname, "midi-in") == 0) | |||||
| return RACK_GRAPH_CARLA_PORT_MIDI_IN; | |||||
| if (std::strcmp(shortname, "MidiOut") == 0 || std::strcmp(shortname, "midi-out") == 0) | |||||
| return RACK_GRAPH_CARLA_PORT_MIDI_OUT; | |||||
| carla_stderr("CarlaBackend::getCarlaRackPortIdFromName(%s) - invalid short name", shortname); | |||||
| return RACK_GRAPH_CARLA_PORT_NULL; | |||||
| CARLA_SAFE_ASSERT(! isReady); | |||||
| CARLA_SAFE_ASSERT(inCount == 0); | |||||
| CARLA_SAFE_ASSERT(outCount == 0); | |||||
| CARLA_SAFE_ASSERT(inBuf == nullptr); | |||||
| CARLA_SAFE_ASSERT(outBuf == nullptr); | |||||
| } | } | ||||
| // ----------------------------------------------------------------------- | |||||
| // RackGraph | |||||
| const char* RackGraph::MIDI::getName(const bool isInput, const uint index) const noexcept | |||||
| void EngineInternalAudio::clearBuffers() noexcept | |||||
| { | { | ||||
| for (LinkedList<PortNameToId>::Itenerator it = isInput ? ins.begin() : outs.begin(); it.valid(); it.next()) | |||||
| for (uint32_t i=0; i < inCount; ++i) | |||||
| { | { | ||||
| const PortNameToId& port(it.getValue()); | |||||
| if (port.port == index) | |||||
| return port.name; | |||||
| if (inBuf[i] != nullptr) | |||||
| { | |||||
| delete[] inBuf[i]; | |||||
| inBuf[i] = nullptr; | |||||
| } | |||||
| } | } | ||||
| return nullptr; | |||||
| } | |||||
| uint RackGraph::MIDI::getPortId(const bool isInput, const char portName[]) const noexcept | |||||
| { | |||||
| for (LinkedList<PortNameToId>::Itenerator it = isInput ? ins.begin() : outs.begin(); it.valid(); it.next()) | |||||
| for (uint32_t i=0; i < outCount; ++i) | |||||
| { | { | ||||
| const PortNameToId& port(it.getValue()); | |||||
| if (std::strcmp(port.name, portName) == 0) | |||||
| return port.port; | |||||
| if (outBuf[i] != nullptr) | |||||
| { | |||||
| delete[] outBuf[i]; | |||||
| outBuf[i] = nullptr; | |||||
| } | |||||
| } | } | ||||
| return 0; | |||||
| } | } | ||||
| bool RackGraph::connect(CarlaEngine* const engine, const uint groupA, const uint portA, const uint groupB, const uint portB) noexcept | |||||
| void EngineInternalAudio::clear() noexcept | |||||
| { | { | ||||
| CARLA_SAFE_ASSERT_RETURN(engine != nullptr, false); | |||||
| isReady = false; | |||||
| uint carlaPort; | |||||
| GroupPort otherPort; | |||||
| clearBuffers(); | |||||
| if (groupA == RACK_GRAPH_GROUP_CARLA) | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(groupB != RACK_GRAPH_GROUP_CARLA, false); | |||||
| inCount = 0; | |||||
| outCount = 0; | |||||
| carlaPort = portA; | |||||
| otherPort.group = groupB; | |||||
| otherPort.port = portB; | |||||
| } | |||||
| else | |||||
| if (inBuf != nullptr) | |||||
| { | { | ||||
| CARLA_SAFE_ASSERT_RETURN(groupB == RACK_GRAPH_GROUP_CARLA, false); | |||||
| carlaPort = portB; | |||||
| otherPort.group = groupA; | |||||
| otherPort.port = portA; | |||||
| } | |||||
| CARLA_SAFE_ASSERT_RETURN(carlaPort > RACK_GRAPH_CARLA_PORT_NULL && carlaPort < RACK_GRAPH_CARLA_PORT_MAX, false); | |||||
| CARLA_SAFE_ASSERT_RETURN(otherPort.group > RACK_GRAPH_GROUP_CARLA && otherPort.group < RACK_GRAPH_GROUP_MAX, false); | |||||
| bool makeConnection = false; | |||||
| switch (carlaPort) | |||||
| { | |||||
| case RACK_GRAPH_CARLA_PORT_AUDIO_IN1: | |||||
| CARLA_SAFE_ASSERT_RETURN(otherPort.group == RACK_GRAPH_GROUP_AUDIO_IN, false); | |||||
| audio.mutex.lock(); | |||||
| makeConnection = audio.connectedIn1.append(otherPort.port); | |||||
| audio.mutex.unlock(); | |||||
| break; | |||||
| case RACK_GRAPH_CARLA_PORT_AUDIO_IN2: | |||||
| CARLA_SAFE_ASSERT_RETURN(otherPort.group == RACK_GRAPH_GROUP_AUDIO_IN, false); | |||||
| audio.mutex.lock(); | |||||
| makeConnection = audio.connectedIn2.append(otherPort.port); | |||||
| audio.mutex.unlock(); | |||||
| break; | |||||
| case RACK_GRAPH_CARLA_PORT_AUDIO_OUT1: | |||||
| CARLA_SAFE_ASSERT_RETURN(otherPort.group == RACK_GRAPH_GROUP_AUDIO_OUT, false); | |||||
| audio.mutex.lock(); | |||||
| makeConnection = audio.connectedOut1.append(otherPort.port); | |||||
| audio.mutex.unlock(); | |||||
| break; | |||||
| case RACK_GRAPH_CARLA_PORT_AUDIO_OUT2: | |||||
| CARLA_SAFE_ASSERT_RETURN(otherPort.group == RACK_GRAPH_GROUP_AUDIO_OUT, false); | |||||
| audio.mutex.lock(); | |||||
| makeConnection = audio.connectedOut2.append(otherPort.port); | |||||
| audio.mutex.unlock(); | |||||
| break; | |||||
| case RACK_GRAPH_CARLA_PORT_MIDI_IN: | |||||
| CARLA_SAFE_ASSERT_RETURN(otherPort.group == RACK_GRAPH_GROUP_MIDI_IN, false); | |||||
| if (const char* const portName = midi.getName(true, otherPort.port)) | |||||
| makeConnection = engine->connectRackMidiInPort(portName); | |||||
| break; | |||||
| case RACK_GRAPH_CARLA_PORT_MIDI_OUT: | |||||
| CARLA_SAFE_ASSERT_RETURN(otherPort.group == RACK_GRAPH_GROUP_MIDI_OUT, false); | |||||
| if (const char* const portName = midi.getName(false, otherPort.port)) | |||||
| makeConnection = engine->connectRackMidiOutPort(portName); | |||||
| break; | |||||
| delete[] inBuf; | |||||
| inBuf = nullptr; | |||||
| } | } | ||||
| if (! makeConnection) | |||||
| if (outBuf != nullptr) | |||||
| { | { | ||||
| engine->setLastError("Invalid rack connection"); | |||||
| return false; | |||||
| delete[] outBuf; | |||||
| outBuf = nullptr; | |||||
| } | } | ||||
| ConnectionToId connectionToId; | |||||
| connectionToId.setData(++connections.lastId, groupA, portA, groupB, portB); | |||||
| char strBuf[STR_MAX+1]; | |||||
| strBuf[STR_MAX] = '\0'; | |||||
| std::snprintf(strBuf, STR_MAX, "%u:%u:%u:%u", groupA, portA, groupB, portB); | |||||
| engine->callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, connectionToId.id, 0, 0, 0.0f, strBuf); | |||||
| connections.list.append(connectionToId); | |||||
| return true; | |||||
| } | } | ||||
| bool RackGraph::disconnect(CarlaEngine* const engine, const uint connectionId) noexcept | |||||
| void EngineInternalAudio::create(const uint32_t bufferSize) | |||||
| { | { | ||||
| CARLA_SAFE_ASSERT_RETURN(engine != nullptr, false); | |||||
| CARLA_SAFE_ASSERT_RETURN(connections.list.count() > 0, false); | |||||
| CARLA_SAFE_ASSERT(! isReady); | |||||
| CARLA_SAFE_ASSERT(inBuf == nullptr); | |||||
| CARLA_SAFE_ASSERT(outBuf == nullptr); | |||||
| for (LinkedList<ConnectionToId>::Itenerator it=connections.list.begin(); it.valid(); it.next()) | |||||
| if (inCount > 0) | |||||
| { | { | ||||
| const ConnectionToId& connection(it.getValue()); | |||||
| if (connection.id != connectionId) | |||||
| continue; | |||||
| uint carlaPort; | |||||
| GroupPort otherPort; | |||||
| if (connection.groupA == RACK_GRAPH_GROUP_CARLA) | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(connection.groupB != RACK_GRAPH_GROUP_CARLA, false); | |||||
| carlaPort = connection.portA; | |||||
| otherPort.group = connection.groupB; | |||||
| otherPort.port = connection.portB; | |||||
| } | |||||
| else | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(connection.groupB == RACK_GRAPH_GROUP_CARLA, false); | |||||
| carlaPort = connection.portB; | |||||
| otherPort.group = connection.groupA; | |||||
| otherPort.port = connection.portA; | |||||
| } | |||||
| inBuf = new float*[inCount]; | |||||
| CARLA_SAFE_ASSERT_RETURN(carlaPort > RACK_GRAPH_CARLA_PORT_NULL && carlaPort < RACK_GRAPH_CARLA_PORT_MAX, false); | |||||
| CARLA_SAFE_ASSERT_RETURN(otherPort.group > RACK_GRAPH_GROUP_CARLA && otherPort.group < RACK_GRAPH_GROUP_MAX, false); | |||||
| bool makeDisconnection = false; | |||||
| switch (carlaPort) | |||||
| { | |||||
| case RACK_GRAPH_CARLA_PORT_AUDIO_IN1: | |||||
| audio.mutex.lock(); | |||||
| makeDisconnection = audio.connectedIn1.removeOne(otherPort.port); | |||||
| audio.mutex.unlock(); | |||||
| break; | |||||
| case RACK_GRAPH_CARLA_PORT_AUDIO_IN2: | |||||
| audio.mutex.lock(); | |||||
| makeDisconnection = audio.connectedIn2.removeOne(otherPort.port); | |||||
| audio.mutex.unlock(); | |||||
| break; | |||||
| case RACK_GRAPH_CARLA_PORT_AUDIO_OUT1: | |||||
| audio.mutex.lock(); | |||||
| makeDisconnection = audio.connectedOut1.removeOne(otherPort.port); | |||||
| audio.mutex.unlock(); | |||||
| break; | |||||
| case RACK_GRAPH_CARLA_PORT_AUDIO_OUT2: | |||||
| audio.mutex.lock(); | |||||
| makeDisconnection = audio.connectedOut2.removeOne(otherPort.port); | |||||
| audio.mutex.unlock(); | |||||
| break; | |||||
| case RACK_GRAPH_CARLA_PORT_MIDI_IN: | |||||
| if (const char* const portName = midi.getName(true, otherPort.port)) | |||||
| makeDisconnection = engine->disconnectRackMidiInPort(portName); | |||||
| break; | |||||
| case RACK_GRAPH_CARLA_PORT_MIDI_OUT: | |||||
| if (const char* const portName = midi.getName(false, otherPort.port)) | |||||
| makeDisconnection = engine->disconnectRackMidiOutPort(portName); | |||||
| break; | |||||
| } | |||||
| if (! makeDisconnection) | |||||
| { | |||||
| engine->setLastError("Invalid rack connection"); | |||||
| return false; | |||||
| } | |||||
| for (uint32_t i=0; i < inCount; ++i) | |||||
| inBuf[i] = nullptr; | |||||
| } | |||||
| engine->callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED, connection.id, 0, 0, 0.0f, nullptr); | |||||
| if (outCount > 0) | |||||
| { | |||||
| outBuf = new float*[outCount]; | |||||
| connections.list.remove(it); | |||||
| return true; | |||||
| for (uint32_t i=0; i < outCount; ++i) | |||||
| outBuf[i] = nullptr; | |||||
| } | } | ||||
| engine->setLastError("Failed to find connection"); | |||||
| return false; | |||||
| resize(bufferSize, false); | |||||
| } | } | ||||
| const char* const* RackGraph::getConnections() const | |||||
| void EngineInternalAudio::resize(const uint32_t bufferSize, const bool doClear = true) | |||||
| { | { | ||||
| if (connections.list.count() == 0) | |||||
| return nullptr; | |||||
| if (doClear) | |||||
| clearBuffers(); | |||||
| LinkedList<const char*> connList; | |||||
| char strBuf[STR_MAX+1]; | |||||
| strBuf[STR_MAX] = '\0'; | |||||
| CARLA_SAFE_ASSERT_RETURN(bufferSize != 0,); | |||||
| for (LinkedList<ConnectionToId>::Itenerator it=connections.list.begin(); it.valid(); it.next()) | |||||
| for (uint32_t i=0; i < inCount; ++i) | |||||
| { | { | ||||
| const ConnectionToId& connection(it.getValue()); | |||||
| uint carlaPort; | |||||
| GroupPort otherPort; | |||||
| if (connection.groupA == RACK_GRAPH_GROUP_CARLA) | |||||
| { | |||||
| CARLA_SAFE_ASSERT_CONTINUE(connection.groupB != RACK_GRAPH_GROUP_CARLA); | |||||
| carlaPort = connection.portA; | |||||
| otherPort.group = connection.groupB; | |||||
| otherPort.port = connection.portB; | |||||
| } | |||||
| else | |||||
| { | |||||
| CARLA_SAFE_ASSERT_CONTINUE(connection.groupB == RACK_GRAPH_GROUP_CARLA); | |||||
| carlaPort = connection.portB; | |||||
| otherPort.group = connection.groupA; | |||||
| otherPort.port = connection.portA; | |||||
| } | |||||
| CARLA_SAFE_ASSERT_CONTINUE(carlaPort > RACK_GRAPH_CARLA_PORT_NULL && carlaPort < RACK_GRAPH_CARLA_PORT_MAX); | |||||
| CARLA_SAFE_ASSERT_CONTINUE(otherPort.group > RACK_GRAPH_GROUP_CARLA && otherPort.group < RACK_GRAPH_GROUP_MAX); | |||||
| switch (carlaPort) | |||||
| { | |||||
| case RACK_GRAPH_CARLA_PORT_AUDIO_IN1: | |||||
| case RACK_GRAPH_CARLA_PORT_AUDIO_IN2: | |||||
| std::snprintf(strBuf, STR_MAX, "AudioIn:%i", otherPort.port+1); | |||||
| connList.append(carla_strdup(strBuf)); | |||||
| connList.append(carla_strdup((carlaPort == RACK_GRAPH_CARLA_PORT_AUDIO_IN1) ? "Carla:AudioIn1" : "Carla:AudioIn2")); | |||||
| break; | |||||
| case RACK_GRAPH_CARLA_PORT_AUDIO_OUT1: | |||||
| case RACK_GRAPH_CARLA_PORT_AUDIO_OUT2: | |||||
| std::snprintf(strBuf, STR_MAX, "AudioOut:%i", otherPort.port+1); | |||||
| connList.append(carla_strdup((carlaPort == RACK_GRAPH_CARLA_PORT_AUDIO_OUT1) ? "Carla:AudioOut1" : "Carla:AudioOut2")); | |||||
| connList.append(carla_strdup(strBuf)); | |||||
| break; | |||||
| case RACK_GRAPH_CARLA_PORT_MIDI_IN: | |||||
| std::snprintf(strBuf, STR_MAX, "MidiIn:%s", midi.getName(true, otherPort.port)); | |||||
| connList.append(carla_strdup(strBuf)); | |||||
| connList.append(carla_strdup("Carla:MidiIn")); | |||||
| break; | |||||
| case RACK_GRAPH_CARLA_PORT_MIDI_OUT: | |||||
| std::snprintf(strBuf, STR_MAX, "MidiOut:%s", midi.getName(false, otherPort.port)); | |||||
| connList.append(carla_strdup("Carla:MidiOut")); | |||||
| connList.append(carla_strdup(strBuf)); | |||||
| break; | |||||
| } | |||||
| inBuf[i] = new float[bufferSize]; | |||||
| FloatVectorOperations::clear(inBuf[i], bufferSize); | |||||
| } | } | ||||
| const size_t connCount(connList.count()); | |||||
| if (connCount == 0) | |||||
| return nullptr; | |||||
| const char** const retConns = new const char*[connCount+1]; | |||||
| for (size_t i=0; i < connCount; ++i) | |||||
| for (uint32_t i=0; i < outCount; ++i) | |||||
| { | { | ||||
| retConns[i] = connList.getAt(i, nullptr); | |||||
| if (retConns[i] == nullptr) | |||||
| retConns[i] = carla_strdup("(unknown)"); | |||||
| outBuf[i] = new float[bufferSize]; | |||||
| FloatVectorOperations::clear(outBuf[i], bufferSize); | |||||
| } | } | ||||
| } | |||||
| #endif | |||||
| retConns[connCount] = nullptr; | |||||
| connList.clear(); | |||||
| // ----------------------------------------------------------------------- | |||||
| // InternalEvents | |||||
| return retConns; | |||||
| } | |||||
| EngineInternalEvents::EngineInternalEvents() noexcept | |||||
| : in(nullptr), | |||||
| out(nullptr) {} | |||||
| bool RackGraph::getPortIdFromFullName(const char* const fullPortName, uint& groupId, uint& portId) const | |||||
| EngineInternalEvents::~EngineInternalEvents() noexcept | |||||
| { | { | ||||
| CARLA_SAFE_ASSERT_RETURN(fullPortName != nullptr && fullPortName[0] != '\0', false); | |||||
| int portTest; | |||||
| CARLA_SAFE_ASSERT(in == nullptr); | |||||
| CARLA_SAFE_ASSERT(out == nullptr); | |||||
| } | |||||
| if (std::strncmp(fullPortName, "Carla:", 6) == 0) | |||||
| { | |||||
| groupId = RACK_GRAPH_GROUP_CARLA; | |||||
| portId = getCarlaRackPortIdFromName(fullPortName+6); | |||||
| CARLA_SAFE_ASSERT_RETURN(portId > RACK_GRAPH_CARLA_PORT_NULL && portId < RACK_GRAPH_CARLA_PORT_MAX, false); | |||||
| } | |||||
| else if (std::strncmp(fullPortName, "AudioIn:", 8) == 0) | |||||
| { | |||||
| groupId = RACK_GRAPH_GROUP_AUDIO_IN; | |||||
| portTest = std::atoi(fullPortName+8) - 1; | |||||
| CARLA_SAFE_ASSERT_RETURN(portTest >= 0, false); | |||||
| portId = static_cast<uint>(portTest); | |||||
| } | |||||
| else if (std::strncmp(fullPortName, "AudioOut:", 9) == 0) | |||||
| { | |||||
| groupId = RACK_GRAPH_GROUP_AUDIO_OUT; | |||||
| portTest = std::atoi(fullPortName+9) - 1; | |||||
| CARLA_SAFE_ASSERT_RETURN(portTest >= 0, false); | |||||
| portId = static_cast<uint>(portTest); | |||||
| } | |||||
| else if (std::strncmp(fullPortName, "MidiIn:", 7) == 0) | |||||
| { | |||||
| groupId = RACK_GRAPH_GROUP_MIDI_IN; | |||||
| //portId = std::atoi(fullPortName+7) - 1; | |||||
| } | |||||
| else if (std::strncmp(fullPortName, "MidiOut:", 8) == 0) | |||||
| void EngineInternalEvents::clear() noexcept | |||||
| { | |||||
| if (in != nullptr) | |||||
| { | { | ||||
| groupId = RACK_GRAPH_GROUP_MIDI_OUT; | |||||
| //portId = std::atoi(fullPortName+8) - 1; | |||||
| delete[] in; | |||||
| in = nullptr; | |||||
| } | } | ||||
| else | |||||
| if (out != nullptr) | |||||
| { | { | ||||
| return false; | |||||
| delete[] out; | |||||
| out = nullptr; | |||||
| } | } | ||||
| return true; | |||||
| } | } | ||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // PatchbayGraph | |||||
| // InternalTime | |||||
| // TODO | |||||
| EngineInternalTime::EngineInternalTime() noexcept | |||||
| : playing(false), | |||||
| frame(0) {} | |||||
| bool PatchbayGraph::connect(CarlaEngine* const engine, const uint /*groupA*/, const uint /*portA*/, const uint /*groupB*/, const uint /*portB*/) noexcept | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(engine != nullptr, false); | |||||
| // ----------------------------------------------------------------------- | |||||
| // NextAction | |||||
| return false; | |||||
| } | |||||
| EngineNextAction::EngineNextAction() noexcept | |||||
| : opcode(kEnginePostActionNull), | |||||
| pluginId(0), | |||||
| value(0) {} | |||||
| bool PatchbayGraph::disconnect(CarlaEngine* const engine, const uint /*connectionId*/) noexcept | |||||
| EngineNextAction::~EngineNextAction() noexcept | |||||
| { | { | ||||
| CARLA_SAFE_ASSERT_RETURN(engine != nullptr, false); | |||||
| return false; | |||||
| CARLA_SAFE_ASSERT(opcode == kEnginePostActionNull); | |||||
| } | } | ||||
| const char* const* PatchbayGraph::getConnections() const | |||||
| void EngineNextAction::ready() const noexcept | |||||
| { | { | ||||
| return nullptr; | |||||
| mutex.lock(); | |||||
| mutex.unlock(); | |||||
| } | } | ||||
| bool PatchbayGraph::getPortIdFromFullName(const char* const /*fillPortName*/, uint& /*groupId*/, uint& /*portId*/) const | |||||
| { | |||||
| return false; | |||||
| } | |||||
| #endif | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // CarlaEngine::ProtectedData | // CarlaEngine::ProtectedData | ||||
| @@ -525,12 +287,6 @@ bool CarlaEngine::ProtectedData::init(const char* const clientName) | |||||
| #ifndef BUILD_BRIDGE | #ifndef BUILD_BRIDGE | ||||
| oscData = osc.getControlData(); | oscData = osc.getControlData(); | ||||
| if (options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK || options.processMode == ENGINE_PROCESS_MODE_PATCHBAY) | |||||
| { | |||||
| graph.isRack = (options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK); | |||||
| graph.create(); | |||||
| } | |||||
| #endif | #endif | ||||
| nextAction.ready(); | nextAction.ready(); | ||||
| @@ -551,11 +307,6 @@ void CarlaEngine::ProtectedData::close() | |||||
| thread.stopThread(500); | thread.stopThread(500); | ||||
| nextAction.ready(); | nextAction.ready(); | ||||
| #ifndef BUILD_BRIDGE | |||||
| if (options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK || options.processMode == ENGINE_PROCESS_MODE_PATCHBAY) | |||||
| graph.clear(); | |||||
| #endif | |||||
| osc.close(); | osc.close(); | ||||
| oscData = nullptr; | oscData = nullptr; | ||||
| @@ -570,12 +321,11 @@ void CarlaEngine::ProtectedData::close() | |||||
| delete[] plugins; | delete[] plugins; | ||||
| plugins = nullptr; | plugins = nullptr; | ||||
| } | } | ||||
| graph.clear(); | |||||
| #endif | #endif | ||||
| events.clear(); | events.clear(); | ||||
| #ifndef BUILD_BRIDGE | |||||
| audio.clear(); | |||||
| #endif | |||||
| name.clear(); | name.clear(); | ||||
| } | } | ||||
| @@ -667,214 +417,6 @@ void CarlaEngine::ProtectedData::doNextPluginAction(const bool unlock) noexcept | |||||
| } | } | ||||
| } | } | ||||
| // ----------------------------------------------------------------------- | |||||
| #ifndef BUILD_BRIDGE | |||||
| void CarlaEngine::ProtectedData::processRack(const float* inBufReal[2], float* outBuf[2], const uint32_t frames, const bool isOffline) | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(events.in != nullptr,); | |||||
| CARLA_SAFE_ASSERT_RETURN(events.out != nullptr,); | |||||
| // safe copy | |||||
| float inBuf0[frames]; | |||||
| float inBuf1[frames]; | |||||
| float* inBuf[2] = { inBuf0, inBuf1 }; | |||||
| // initialize audio inputs | |||||
| FLOAT_COPY(inBuf0, inBufReal[0], frames); | |||||
| FLOAT_COPY(inBuf1, inBufReal[1], frames); | |||||
| // initialize audio outputs (zero) | |||||
| FLOAT_CLEAR(outBuf[0], frames); | |||||
| FLOAT_CLEAR(outBuf[1], frames); | |||||
| // initialize event outputs (zero) | |||||
| carla_zeroStruct<EngineEvent>(events.out, kMaxEngineEventInternalCount); | |||||
| bool processed = false; | |||||
| uint32_t oldAudioInCount = 0; | |||||
| uint32_t oldMidiOutCount = 0; | |||||
| // process plugins | |||||
| for (uint i=0; i < curPluginCount; ++i) | |||||
| { | |||||
| CarlaPlugin* const plugin = plugins[i].plugin; | |||||
| if (plugin == nullptr || ! plugin->isEnabled() || ! plugin->tryLock(isOffline)) | |||||
| continue; | |||||
| if (processed) | |||||
| { | |||||
| // initialize audio inputs (from previous outputs) | |||||
| FLOAT_COPY(inBuf0, outBuf[0], frames); | |||||
| FLOAT_COPY(inBuf1, outBuf[1], frames); | |||||
| // initialize audio outputs (zero) | |||||
| FLOAT_CLEAR(outBuf[0], frames); | |||||
| FLOAT_CLEAR(outBuf[1], frames); | |||||
| // if plugin has no midi out, add previous events | |||||
| if (oldMidiOutCount == 0 && events.in[0].type != kEngineEventTypeNull) | |||||
| { | |||||
| if (events.out[0].type != kEngineEventTypeNull) | |||||
| { | |||||
| // TODO: carefully add to input, sorted events | |||||
| } | |||||
| // else nothing needed | |||||
| } | |||||
| else | |||||
| { | |||||
| // initialize event inputs from previous outputs | |||||
| carla_copyStruct<EngineEvent>(events.in, events.out, kMaxEngineEventInternalCount); | |||||
| // initialize event outputs (zero) | |||||
| carla_zeroStruct<EngineEvent>(events.out, kMaxEngineEventInternalCount); | |||||
| } | |||||
| } | |||||
| oldAudioInCount = plugin->getAudioInCount(); | |||||
| oldMidiOutCount = plugin->getMidiOutCount(); | |||||
| // process | |||||
| plugin->initBuffers(); | |||||
| plugin->process(inBuf, outBuf, frames); | |||||
| plugin->unlock(); | |||||
| // if plugin has no audio inputs, add input buffer | |||||
| if (oldAudioInCount == 0) | |||||
| { | |||||
| FLOAT_ADD(outBuf[0], inBuf0, frames); | |||||
| FLOAT_ADD(outBuf[1], inBuf1, frames); | |||||
| } | |||||
| // set peaks | |||||
| { | |||||
| EnginePluginData& pluginData(plugins[i]); | |||||
| juce::Range<float> range; | |||||
| if (oldAudioInCount > 0) | |||||
| { | |||||
| range = FloatVectorOperations::findMinAndMax(inBuf0, static_cast<int>(frames)); | |||||
| pluginData.insPeak[0] = carla_max<float>(std::abs(range.getStart()), std::abs(range.getEnd()), 1.0f); | |||||
| range = FloatVectorOperations::findMinAndMax(inBuf1, static_cast<int>(frames)); | |||||
| pluginData.insPeak[1] = carla_max<float>(std::abs(range.getStart()), std::abs(range.getEnd()), 1.0f); | |||||
| } | |||||
| else | |||||
| { | |||||
| pluginData.insPeak[0] = 0.0f; | |||||
| pluginData.insPeak[1] = 0.0f; | |||||
| } | |||||
| if (plugin->getAudioOutCount() > 0) | |||||
| { | |||||
| range = FloatVectorOperations::findMinAndMax(outBuf[0], static_cast<int>(frames)); | |||||
| pluginData.outsPeak[0] = carla_max<float>(std::abs(range.getStart()), std::abs(range.getEnd()), 1.0f); | |||||
| range = FloatVectorOperations::findMinAndMax(outBuf[1], static_cast<int>(frames)); | |||||
| pluginData.outsPeak[1] = carla_max<float>(std::abs(range.getStart()), std::abs(range.getEnd()), 1.0f); | |||||
| } | |||||
| else | |||||
| { | |||||
| pluginData.outsPeak[0] = 0.0f; | |||||
| pluginData.outsPeak[1] = 0.0f; | |||||
| } | |||||
| } | |||||
| processed = true; | |||||
| } | |||||
| } | |||||
| void CarlaEngine::ProtectedData::processRackFull(const float* const* const inBuf, const uint32_t inCount, float* const* const outBuf, const uint32_t outCount, const uint32_t nframes, const bool isOffline) | |||||
| { | |||||
| RackGraph::Audio& rackAudio(graph.rack->audio); | |||||
| const CarlaMutexLocker _cml(rackAudio.mutex); | |||||
| if (inBuf != nullptr && inCount > 0) | |||||
| { | |||||
| bool noConnections = true; | |||||
| // connect input buffers | |||||
| for (LinkedList<uint>::Itenerator it = rackAudio.connectedIn1.begin(); it.valid(); it.next()) | |||||
| { | |||||
| const uint& port(it.getValue()); | |||||
| CARLA_SAFE_ASSERT_CONTINUE(port < inCount); | |||||
| if (noConnections) | |||||
| { | |||||
| FLOAT_COPY(audio.inBuf[0], inBuf[port], nframes); | |||||
| noConnections = false; | |||||
| } | |||||
| else | |||||
| { | |||||
| FLOAT_ADD(audio.inBuf[0], inBuf[port], nframes); | |||||
| } | |||||
| } | |||||
| if (noConnections) | |||||
| FLOAT_CLEAR(audio.inBuf[0], nframes); | |||||
| noConnections = true; | |||||
| for (LinkedList<uint>::Itenerator it = rackAudio.connectedIn2.begin(); it.valid(); it.next()) | |||||
| { | |||||
| const uint& port(it.getValue()); | |||||
| CARLA_SAFE_ASSERT_CONTINUE(port < inCount); | |||||
| if (noConnections) | |||||
| { | |||||
| FLOAT_COPY(audio.inBuf[1], inBuf[port], nframes); | |||||
| noConnections = false; | |||||
| } | |||||
| else | |||||
| { | |||||
| FLOAT_ADD(audio.inBuf[1], inBuf[port], nframes); | |||||
| } | |||||
| } | |||||
| if (noConnections) | |||||
| FLOAT_CLEAR(audio.inBuf[1], nframes); | |||||
| } | |||||
| else | |||||
| { | |||||
| FLOAT_CLEAR(audio.inBuf[0], nframes); | |||||
| FLOAT_CLEAR(audio.inBuf[1], nframes); | |||||
| } | |||||
| FLOAT_CLEAR(audio.outBuf[0], nframes); | |||||
| FLOAT_CLEAR(audio.outBuf[1], nframes); | |||||
| // process | |||||
| processRack(const_cast<const float**>(audio.inBuf), audio.outBuf, nframes, isOffline); | |||||
| // connect output buffers | |||||
| if (rackAudio.connectedOut1.count() != 0) | |||||
| { | |||||
| for (LinkedList<uint>::Itenerator it = rackAudio.connectedOut1.begin(); it.valid(); it.next()) | |||||
| { | |||||
| const uint& port(it.getValue()); | |||||
| CARLA_SAFE_ASSERT_CONTINUE(port < outCount); | |||||
| FLOAT_ADD(outBuf[port], audio.outBuf[0], nframes); | |||||
| } | |||||
| } | |||||
| if (rackAudio.connectedOut2.count() != 0) | |||||
| { | |||||
| for (LinkedList<uint>::Itenerator it = rackAudio.connectedOut2.begin(); it.valid(); it.next()) | |||||
| { | |||||
| const uint& port(it.getValue()); | |||||
| CARLA_SAFE_ASSERT_CONTINUE(port < outCount); | |||||
| FLOAT_ADD(outBuf[port], audio.outBuf[1], nframes); | |||||
| } | |||||
| } | |||||
| } | |||||
| #endif | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // ScopedActionLock | // ScopedActionLock | ||||
| @@ -23,9 +23,7 @@ | |||||
| #include "CarlaEngineThread.hpp" | #include "CarlaEngineThread.hpp" | ||||
| #include "CarlaEngineUtils.hpp" | #include "CarlaEngineUtils.hpp" | ||||
| #include "CarlaMathUtils.hpp" | |||||
| #include "CarlaPatchbayUtils.hpp" | |||||
| #include "CarlaMutex.hpp" | |||||
| CARLA_BACKEND_START_NAMESPACE | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // Engine helper macro, sets lastError and returns false/NULL | // Engine helper macro, sets lastError and returns false/NULL | ||||
| @@ -33,239 +31,6 @@ | |||||
| #define CARLA_SAFE_ASSERT_RETURN_ERR(cond, err) if (! (cond)) { carla_safe_assert(#cond, __FILE__, __LINE__); setLastError(err); return false; } | #define CARLA_SAFE_ASSERT_RETURN_ERR(cond, err) if (! (cond)) { carla_safe_assert(#cond, __FILE__, __LINE__); setLastError(err); return false; } | ||||
| #define CARLA_SAFE_ASSERT_RETURN_ERRN(cond, err) if (! (cond)) { carla_safe_assert(#cond, __FILE__, __LINE__); setLastError(err); return nullptr; } | #define CARLA_SAFE_ASSERT_RETURN_ERRN(cond, err) if (! (cond)) { carla_safe_assert(#cond, __FILE__, __LINE__); setLastError(err); return nullptr; } | ||||
| // ----------------------------------------------------------------------- | |||||
| CARLA_BACKEND_START_NAMESPACE | |||||
| #if 0 | |||||
| } // Fix editor indentation | |||||
| #endif | |||||
| // ----------------------------------------------------------------------- | |||||
| // Patchbay stuff | |||||
| struct GroupPort { | |||||
| uint group, port; | |||||
| }; | |||||
| #ifndef BUILD_BRIDGE | |||||
| // ----------------------------------------------------------------------- | |||||
| // Rack Graph stuff | |||||
| enum RackGraphGroupIds { | |||||
| RACK_GRAPH_GROUP_CARLA = 0, | |||||
| RACK_GRAPH_GROUP_AUDIO_IN = 1, | |||||
| RACK_GRAPH_GROUP_AUDIO_OUT = 2, | |||||
| RACK_GRAPH_GROUP_MIDI_IN = 3, | |||||
| RACK_GRAPH_GROUP_MIDI_OUT = 4, | |||||
| RACK_GRAPH_GROUP_MAX = 5 | |||||
| }; | |||||
| enum RackGraphCarlaPortIds { | |||||
| RACK_GRAPH_CARLA_PORT_NULL = 0, | |||||
| RACK_GRAPH_CARLA_PORT_AUDIO_IN1 = 1, | |||||
| RACK_GRAPH_CARLA_PORT_AUDIO_IN2 = 2, | |||||
| RACK_GRAPH_CARLA_PORT_AUDIO_OUT1 = 3, | |||||
| RACK_GRAPH_CARLA_PORT_AUDIO_OUT2 = 4, | |||||
| RACK_GRAPH_CARLA_PORT_MIDI_IN = 5, | |||||
| RACK_GRAPH_CARLA_PORT_MIDI_OUT = 6, | |||||
| RACK_GRAPH_CARLA_PORT_MAX = 7 | |||||
| }; | |||||
| // ----------------------------------------------------------------------- | |||||
| // RackGraph | |||||
| struct RackGraph { | |||||
| PatchbayConnectionList connections; | |||||
| struct Audio { | |||||
| CarlaMutex mutex; | |||||
| LinkedList<uint> connectedIn1; | |||||
| LinkedList<uint> connectedIn2; | |||||
| LinkedList<uint> connectedOut1; | |||||
| LinkedList<uint> connectedOut2; | |||||
| } audio; | |||||
| struct MIDI { | |||||
| LinkedList<PortNameToId> ins; | |||||
| LinkedList<PortNameToId> outs; | |||||
| const char* getName(const bool isInput, const uint index) const noexcept; | |||||
| uint getPortId(const bool isInput, const char portName[]) const noexcept; | |||||
| } midi; | |||||
| RackGraph() noexcept {} | |||||
| ~RackGraph() noexcept | |||||
| { | |||||
| clear(); | |||||
| } | |||||
| void clear() noexcept | |||||
| { | |||||
| connections.clear(); | |||||
| audio.mutex.lock(); | |||||
| audio.connectedIn1.clear(); | |||||
| audio.connectedIn2.clear(); | |||||
| audio.connectedOut1.clear(); | |||||
| audio.connectedOut2.clear(); | |||||
| audio.mutex.unlock(); | |||||
| midi.ins.clear(); | |||||
| midi.outs.clear(); | |||||
| } | |||||
| bool connect(CarlaEngine* const engine, const uint groupA, const uint portA, const uint groupB, const uint portB) noexcept; | |||||
| bool disconnect(CarlaEngine* const engine, const uint connectionId) noexcept; | |||||
| const char* const* getConnections() const; | |||||
| bool getPortIdFromFullName(const char* const fullPortName, uint& groupId, uint& portId) const; | |||||
| }; | |||||
| // ----------------------------------------------------------------------- | |||||
| // PatchbayGraph | |||||
| struct PatchbayGraph { | |||||
| PatchbayGraph() noexcept {} | |||||
| ~PatchbayGraph() noexcept | |||||
| { | |||||
| clear(); | |||||
| } | |||||
| void clear() noexcept | |||||
| { | |||||
| } | |||||
| bool connect(CarlaEngine* const engine, const uint groupA, const uint portA, const uint groupB, const uint portB) noexcept; | |||||
| bool disconnect(CarlaEngine* const engine, const uint connectionId) noexcept; | |||||
| const char* const* getConnections() const; | |||||
| bool getPortIdFromFullName(const char* const fullPortName, uint& groupId, uint& portId) const; | |||||
| }; | |||||
| #endif | |||||
| // ----------------------------------------------------------------------- | |||||
| // InternalAudio | |||||
| struct EngineInternalAudio { | |||||
| bool isReady; | |||||
| // always 2x2 in rack mode | |||||
| uint inCount; | |||||
| uint outCount; | |||||
| float** inBuf; | |||||
| float** outBuf; | |||||
| EngineInternalAudio() noexcept | |||||
| : isReady(false), | |||||
| inCount(0), | |||||
| outCount(0), | |||||
| inBuf(nullptr), | |||||
| outBuf(nullptr) {} | |||||
| ~EngineInternalAudio() noexcept | |||||
| { | |||||
| CARLA_SAFE_ASSERT(! isReady); | |||||
| CARLA_SAFE_ASSERT(inCount == 0); | |||||
| CARLA_SAFE_ASSERT(outCount == 0); | |||||
| CARLA_SAFE_ASSERT(inBuf == nullptr); | |||||
| CARLA_SAFE_ASSERT(outBuf == nullptr); | |||||
| } | |||||
| void clearBuffers() noexcept | |||||
| { | |||||
| for (uint32_t i=0; i < inCount; ++i) | |||||
| { | |||||
| if (inBuf[i] != nullptr) | |||||
| { | |||||
| delete[] inBuf[i]; | |||||
| inBuf[i] = nullptr; | |||||
| } | |||||
| } | |||||
| for (uint32_t i=0; i < outCount; ++i) | |||||
| { | |||||
| if (outBuf[i] != nullptr) | |||||
| { | |||||
| delete[] outBuf[i]; | |||||
| outBuf[i] = nullptr; | |||||
| } | |||||
| } | |||||
| } | |||||
| void clear() noexcept | |||||
| { | |||||
| isReady = false; | |||||
| clearBuffers(); | |||||
| inCount = 0; | |||||
| outCount = 0; | |||||
| if (inBuf != nullptr) | |||||
| { | |||||
| delete[] inBuf; | |||||
| inBuf = nullptr; | |||||
| } | |||||
| if (outBuf != nullptr) | |||||
| { | |||||
| delete[] outBuf; | |||||
| outBuf = nullptr; | |||||
| } | |||||
| } | |||||
| void create(const uint32_t bufferSize) | |||||
| { | |||||
| CARLA_SAFE_ASSERT(! isReady); | |||||
| CARLA_SAFE_ASSERT(inBuf == nullptr); | |||||
| CARLA_SAFE_ASSERT(outBuf == nullptr); | |||||
| if (inCount > 0) | |||||
| { | |||||
| inBuf = new float*[inCount]; | |||||
| for (uint32_t i=0; i < inCount; ++i) | |||||
| inBuf[i] = nullptr; | |||||
| } | |||||
| if (outCount > 0) | |||||
| { | |||||
| outBuf = new float*[outCount]; | |||||
| for (uint32_t i=0; i < outCount; ++i) | |||||
| outBuf[i] = nullptr; | |||||
| } | |||||
| resize(bufferSize, false); | |||||
| } | |||||
| void resize(const uint32_t bufferSize, const bool doClear = true) | |||||
| { | |||||
| if (doClear) | |||||
| clearBuffers(); | |||||
| CARLA_SAFE_ASSERT_RETURN(bufferSize != 0,); | |||||
| for (uint32_t i=0; i < inCount; ++i) | |||||
| { | |||||
| inBuf[i] = new float[bufferSize]; | |||||
| FLOAT_CLEAR(inBuf[i], bufferSize); | |||||
| } | |||||
| for (uint32_t i=0; i < outCount; ++i) | |||||
| { | |||||
| outBuf[i] = new float[bufferSize]; | |||||
| FLOAT_CLEAR(outBuf[i], bufferSize); | |||||
| } | |||||
| } | |||||
| CARLA_DECLARE_NON_COPY_STRUCT(EngineInternalAudio) | |||||
| }; | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // InternalEvents | // InternalEvents | ||||
| @@ -273,30 +38,9 @@ struct EngineInternalEvents { | |||||
| EngineEvent* in; | EngineEvent* in; | ||||
| EngineEvent* out; | EngineEvent* out; | ||||
| EngineInternalEvents() noexcept | |||||
| : in(nullptr), | |||||
| out(nullptr) {} | |||||
| ~EngineInternalEvents() noexcept | |||||
| { | |||||
| CARLA_SAFE_ASSERT(in == nullptr); | |||||
| CARLA_SAFE_ASSERT(out == nullptr); | |||||
| } | |||||
| void clear() noexcept | |||||
| { | |||||
| if (in != nullptr) | |||||
| { | |||||
| delete[] in; | |||||
| in = nullptr; | |||||
| } | |||||
| if (out != nullptr) | |||||
| { | |||||
| delete[] out; | |||||
| out = nullptr; | |||||
| } | |||||
| } | |||||
| EngineInternalEvents() noexcept; | |||||
| ~EngineInternalEvents() noexcept; | |||||
| void clear() noexcept; | |||||
| CARLA_DECLARE_NON_COPY_STRUCT(EngineInternalEvents) | CARLA_DECLARE_NON_COPY_STRUCT(EngineInternalEvents) | ||||
| }; | }; | ||||
| @@ -305,54 +49,19 @@ struct EngineInternalEvents { | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // InternalGraph | // InternalGraph | ||||
| struct InternalGraph; | |||||
| struct EngineInternalGraph { | struct EngineInternalGraph { | ||||
| bool isRack; | bool isRack; | ||||
| bool isReady; | |||||
| InternalGraph* graph; | |||||
| EngineInternalGraph() noexcept; | |||||
| ~EngineInternalGraph() noexcept; | |||||
| union { | |||||
| RackGraph* rack; | |||||
| PatchbayGraph* patchbay; | |||||
| }; | |||||
| EngineInternalGraph() noexcept | |||||
| : isRack(true) | |||||
| { | |||||
| rack = nullptr; | |||||
| } | |||||
| ~EngineInternalGraph() noexcept | |||||
| { | |||||
| CARLA_SAFE_ASSERT(rack == nullptr); | |||||
| } | |||||
| void create() | |||||
| { | |||||
| if (isRack) | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(rack == nullptr,); | |||||
| rack = new RackGraph(); | |||||
| } | |||||
| else | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(patchbay == nullptr,); | |||||
| patchbay = new PatchbayGraph(); | |||||
| } | |||||
| } | |||||
| void clear() | |||||
| { | |||||
| if (isRack) | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(rack != nullptr,); | |||||
| delete rack; | |||||
| rack = nullptr; | |||||
| } | |||||
| else | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(patchbay != nullptr,); | |||||
| delete patchbay; | |||||
| patchbay = nullptr; | |||||
| } | |||||
| } | |||||
| void create(const uint32_t bufferSize); | |||||
| void resize(const uint32_t bufferSize) noexcept; | |||||
| void clear() noexcept; | |||||
| CARLA_DECLARE_NON_COPY_STRUCT(EngineInternalGraph) | CARLA_DECLARE_NON_COPY_STRUCT(EngineInternalGraph) | ||||
| }; | }; | ||||
| @@ -365,22 +74,20 @@ struct EngineInternalTime { | |||||
| bool playing; | bool playing; | ||||
| uint64_t frame; | uint64_t frame; | ||||
| EngineInternalTime() noexcept | |||||
| : playing(false), | |||||
| frame(0) {} | |||||
| EngineInternalTime() noexcept; | |||||
| CARLA_DECLARE_NON_COPY_STRUCT(EngineInternalTime) | CARLA_DECLARE_NON_COPY_STRUCT(EngineInternalTime) | ||||
| }; | }; | ||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // NextAction | |||||
| // EngineNextAction | |||||
| enum EnginePostAction { | enum EnginePostAction { | ||||
| kEnginePostActionNull, | |||||
| kEnginePostActionZeroCount, | |||||
| kEnginePostActionNull = 0, | |||||
| kEnginePostActionZeroCount, // set curPluginCount to 0 | |||||
| #ifndef BUILD_BRIDGE | #ifndef BUILD_BRIDGE | ||||
| kEnginePostActionRemovePlugin, | |||||
| kEnginePostActionSwitchPlugins | |||||
| kEnginePostActionRemovePlugin, // remove a plugin | |||||
| kEnginePostActionSwitchPlugins // switch between 2 plugins | |||||
| #endif | #endif | ||||
| }; | }; | ||||
| @@ -390,21 +97,9 @@ struct EngineNextAction { | |||||
| uint value; | uint value; | ||||
| CarlaMutex mutex; | CarlaMutex mutex; | ||||
| EngineNextAction() noexcept | |||||
| : opcode(kEnginePostActionNull), | |||||
| pluginId(0), | |||||
| value(0) {} | |||||
| ~EngineNextAction() noexcept | |||||
| { | |||||
| CARLA_SAFE_ASSERT(opcode == kEnginePostActionNull); | |||||
| } | |||||
| void ready() const noexcept | |||||
| { | |||||
| mutex.lock(); | |||||
| mutex.unlock(); | |||||
| } | |||||
| EngineNextAction() noexcept; | |||||
| ~EngineNextAction() noexcept; | |||||
| void ready() const noexcept; | |||||
| CARLA_DECLARE_NON_COPY_STRUCT(EngineNextAction) | CARLA_DECLARE_NON_COPY_STRUCT(EngineNextAction) | ||||
| }; | }; | ||||
| @@ -453,9 +148,6 @@ struct CarlaEngine::ProtectedData { | |||||
| EnginePluginData* plugins; | EnginePluginData* plugins; | ||||
| #endif | #endif | ||||
| #ifndef BUILD_BRIDGE | |||||
| EngineInternalAudio audio; | |||||
| #endif | |||||
| EngineInternalEvents events; | EngineInternalEvents events; | ||||
| #ifndef BUILD_BRIDGE | #ifndef BUILD_BRIDGE | ||||
| EngineInternalGraph graph; | EngineInternalGraph graph; | ||||
| @@ -22,11 +22,12 @@ | |||||
| #include "CarlaEngineUtils.hpp" | #include "CarlaEngineUtils.hpp" | ||||
| #include "CarlaMathUtils.hpp" | #include "CarlaMathUtils.hpp" | ||||
| #include "CarlaMIDI.h" | #include "CarlaMIDI.h" | ||||
| #include "CarlaPatchbayUtils.hpp" | |||||
| #include "jackbridge/JackBridge.hpp" | #include "jackbridge/JackBridge.hpp" | ||||
| #include "jackey.h" | #include "jackey.h" | ||||
| #include "juce_core.h" | |||||
| #include "juce_audio_basics.h" | |||||
| #ifdef __SSE2_MATH__ | #ifdef __SSE2_MATH__ | ||||
| # include <xmmintrin.h> | # include <xmmintrin.h> | ||||
| @@ -34,6 +35,7 @@ | |||||
| #define URI_CANVAS_ICON "http://kxstudio.sf.net/ns/canvas/icon" | #define URI_CANVAS_ICON "http://kxstudio.sf.net/ns/canvas/icon" | ||||
| using juce::FloatVectorOperations; | |||||
| using juce::String; | using juce::String; | ||||
| using juce::StringArray; | using juce::StringArray; | ||||
| @@ -153,7 +155,7 @@ public: | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| FLOAT_CLEAR(fBuffer, bufferSize); | |||||
| FloatVectorOperations::clear(fBuffer, bufferSize); | |||||
| } | } | ||||
| } | } | ||||
| @@ -191,7 +193,7 @@ public: | |||||
| { | { | ||||
| fLatencyBufferSize = range.max; | fLatencyBufferSize = range.max; | ||||
| fLatencyBuffer = new float[fLatencyBufferSize]; | fLatencyBuffer = new float[fLatencyBufferSize]; | ||||
| FLOAT_CLEAR(fLatencyBuffer, fLatencyBufferSize); | |||||
| FloatVectorOperations::clear(fLatencyBuffer, fLatencyBufferSize); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -281,7 +283,7 @@ public: | |||||
| } | } | ||||
| if (! fIsInput) | if (! fIsInput) | ||||
| FLOAT_CLEAR(fBuffer, bufferSize); | |||||
| FloatVectorOperations::clear(fBuffer, bufferSize); | |||||
| } | } | ||||
| void invalidate() noexcept | void invalidate() noexcept | ||||
| @@ -1429,8 +1431,8 @@ protected: | |||||
| float* const audioOut2 = (float*)jackbridge_port_get_buffer(fRackPorts[kRackPortAudioOut2], nframes); | float* const audioOut2 = (float*)jackbridge_port_get_buffer(fRackPorts[kRackPortAudioOut2], nframes); | ||||
| void* const eventOut = jackbridge_port_get_buffer(fRackPorts[kRackPortEventOut], nframes); | void* const eventOut = jackbridge_port_get_buffer(fRackPorts[kRackPortEventOut], nframes); | ||||
| FLOAT_COPY(audioOut1, audioIn1, nframes); | |||||
| FLOAT_COPY(audioOut2, audioIn2, nframes); | |||||
| FloatVectorOperations::copy(audioOut1, audioIn1, nframes); | |||||
| FloatVectorOperations::copy(audioOut2, audioIn2, nframes); | |||||
| jackbridge_midi_clear_buffer(eventOut); | jackbridge_midi_clear_buffer(eventOut); | ||||
| } | } | ||||
| @@ -16,6 +16,7 @@ | |||||
| */ | */ | ||||
| #include "CarlaEngineInternal.hpp" | #include "CarlaEngineInternal.hpp" | ||||
| #include "CarlaEngineGraph.hpp" | |||||
| #include "CarlaBackendUtils.hpp" | #include "CarlaBackendUtils.hpp" | ||||
| #include "CarlaStringList.hpp" | #include "CarlaStringList.hpp" | ||||
| @@ -159,23 +160,13 @@ public: | |||||
| pData->bufferSize = static_cast<uint32_t>(fDevice->getCurrentBufferSizeSamples()); | pData->bufferSize = static_cast<uint32_t>(fDevice->getCurrentBufferSizeSamples()); | ||||
| pData->sampleRate = fDevice->getCurrentSampleRate(); | pData->sampleRate = fDevice->getCurrentSampleRate(); | ||||
| if (pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK) | |||||
| { | |||||
| pData->audio.inCount = 2; | |||||
| pData->audio.outCount = 2; | |||||
| } | |||||
| else | |||||
| { | |||||
| pData->audio.inCount = 0; | |||||
| pData->audio.outCount = 0; | |||||
| } | |||||
| pData->audio.create(pData->bufferSize); | |||||
| pData->graph.isRack = (pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK); | |||||
| pData->graph.create(pData->bufferSize); | |||||
| fDevice->start(this); | fDevice->start(this); | ||||
| CarlaEngine::init(clientName); | CarlaEngine::init(clientName); | ||||
| pData->audio.isReady = true; | |||||
| pData->graph.isReady = true; | |||||
| patchbayRefresh(); | patchbayRefresh(); | ||||
| @@ -186,7 +177,7 @@ public: | |||||
| { | { | ||||
| carla_debug("CarlaEngineJuce::close()"); | carla_debug("CarlaEngineJuce::close()"); | ||||
| pData->audio.isReady = false; | |||||
| pData->graph.isReady = false; | |||||
| bool hasError = !CarlaEngine::close(); | bool hasError = !CarlaEngine::close(); | ||||
| @@ -255,7 +246,7 @@ public: | |||||
| bool patchbayRefresh() override | bool patchbayRefresh() override | ||||
| { | { | ||||
| CARLA_SAFE_ASSERT_RETURN(pData->audio.isReady, false); | |||||
| CARLA_SAFE_ASSERT_RETURN(pData->graph.isReady, false); | |||||
| //fUsedMidiPorts.clear(); | //fUsedMidiPorts.clear(); | ||||
| @@ -269,7 +260,7 @@ public: | |||||
| void patchbayRefreshRack() | void patchbayRefreshRack() | ||||
| { | { | ||||
| RackGraph* const rack(pData->graph.rack); | |||||
| RackGraph* const rack((RackGraph*)pData->graph.graph); | |||||
| rack->connections.clear(); | rack->connections.clear(); | ||||
| @@ -484,7 +475,7 @@ protected: | |||||
| CARLA_SAFE_ASSERT_RETURN(outputChannelData != nullptr, runPendingRtEvents()); | CARLA_SAFE_ASSERT_RETURN(outputChannelData != nullptr, runPendingRtEvents()); | ||||
| CARLA_SAFE_ASSERT_RETURN(numSamples == static_cast<int>(pData->bufferSize), runPendingRtEvents()); | CARLA_SAFE_ASSERT_RETURN(numSamples == static_cast<int>(pData->bufferSize), runPendingRtEvents()); | ||||
| if (! pData->audio.isReady) | |||||
| if (! pData->graph.isReady) | |||||
| return runPendingRtEvents(); | return runPendingRtEvents(); | ||||
| const uint32_t nframes(static_cast<uint32_t>(numSamples)); | const uint32_t nframes(static_cast<uint32_t>(numSamples)); | ||||
| @@ -614,7 +605,7 @@ protected: | |||||
| void handleIncomingMidiMessage(MidiInput* /*source*/, const MidiMessage& message) override | void handleIncomingMidiMessage(MidiInput* /*source*/, const MidiMessage& message) override | ||||
| { | { | ||||
| if (! pData->audio.isReady) | |||||
| if (! pData->graph.isReady) | |||||
| return; | return; | ||||
| const int messageSize(message.getRawDataSize()); | const int messageSize(message.getRawDataSize()); | ||||
| @@ -645,7 +636,7 @@ protected: | |||||
| CARLA_SAFE_ASSERT_RETURN(portName != nullptr && portName[0] != '\0', false); | CARLA_SAFE_ASSERT_RETURN(portName != nullptr && portName[0] != '\0', false); | ||||
| carla_debug("CarlaEngineJuce::connectRackMidiInPort(\"%s\")", portName); | carla_debug("CarlaEngineJuce::connectRackMidiInPort(\"%s\")", portName); | ||||
| RackGraph* const rack(pData->graph.rack); | |||||
| RackGraph* const rack((RackGraph*)pData->graph.graph); | |||||
| CARLA_SAFE_ASSERT_RETURN(rack->midi.ins.count() > 0, false); | CARLA_SAFE_ASSERT_RETURN(rack->midi.ins.count() > 0, false); | ||||
| StringArray midiIns(MidiInput::getDevices()); | StringArray midiIns(MidiInput::getDevices()); | ||||
| @@ -671,7 +662,7 @@ protected: | |||||
| CARLA_SAFE_ASSERT_RETURN(portName != nullptr && portName[0] != '\0', false); | CARLA_SAFE_ASSERT_RETURN(portName != nullptr && portName[0] != '\0', false); | ||||
| carla_debug("CarlaEngineJuce::connectRackMidiOutPort(\"%s\")", portName); | carla_debug("CarlaEngineJuce::connectRackMidiOutPort(\"%s\")", portName); | ||||
| RackGraph* const rack(pData->graph.rack); | |||||
| RackGraph* const rack((RackGraph*)pData->graph.graph); | |||||
| CARLA_SAFE_ASSERT_RETURN(rack->midi.ins.count() > 0, false); | CARLA_SAFE_ASSERT_RETURN(rack->midi.ins.count() > 0, false); | ||||
| StringArray midiOuts(MidiOutput::getDevices()); | StringArray midiOuts(MidiOutput::getDevices()); | ||||
| @@ -699,7 +690,7 @@ protected: | |||||
| CARLA_SAFE_ASSERT_RETURN(portName != nullptr && portName[0] != '\0', false); | CARLA_SAFE_ASSERT_RETURN(portName != nullptr && portName[0] != '\0', false); | ||||
| carla_debug("CarlaEngineRtAudio::disconnectRackMidiInPort(\"%s\")", portName); | carla_debug("CarlaEngineRtAudio::disconnectRackMidiInPort(\"%s\")", portName); | ||||
| RackGraph* const rack(pData->graph.rack); | |||||
| RackGraph* const rack((RackGraph*)pData->graph.graph); | |||||
| CARLA_SAFE_ASSERT_RETURN(rack->midi.ins.count() > 0, false); | CARLA_SAFE_ASSERT_RETURN(rack->midi.ins.count() > 0, false); | ||||
| for (LinkedList<MidiInPort>::Itenerator it=fMidiIns.begin(); it.valid(); it.next()) | for (LinkedList<MidiInPort>::Itenerator it=fMidiIns.begin(); it.valid(); it.next()) | ||||
| @@ -725,7 +716,7 @@ protected: | |||||
| CARLA_SAFE_ASSERT_RETURN(portName != nullptr && portName[0] != '\0', false); | CARLA_SAFE_ASSERT_RETURN(portName != nullptr && portName[0] != '\0', false); | ||||
| carla_debug("CarlaEngineRtAudio::disconnectRackMidiOutPort(\"%s\")", portName); | carla_debug("CarlaEngineRtAudio::disconnectRackMidiOutPort(\"%s\")", portName); | ||||
| RackGraph* const rack(pData->graph.rack); | |||||
| RackGraph* const rack((RackGraph*)pData->graph.graph); | |||||
| CARLA_SAFE_ASSERT_RETURN(rack->midi.outs.count() > 0, false); | CARLA_SAFE_ASSERT_RETURN(rack->midi.outs.count() > 0, false); | ||||
| const CarlaMutexLocker cml(fMidiOutMutex); | const CarlaMutexLocker cml(fMidiOutMutex); | ||||
| @@ -34,8 +34,9 @@ | |||||
| #include "CarlaExternalUI.hpp" | #include "CarlaExternalUI.hpp" | ||||
| #include "CarlaNative.hpp" | #include "CarlaNative.hpp" | ||||
| #include "juce_core.h" | |||||
| #include "juce_audio_basics.h" | |||||
| using juce::FloatVectorOperations; | |||||
| using juce::MemoryOutputStream; | using juce::MemoryOutputStream; | ||||
| using juce::ScopedPointer; | using juce::ScopedPointer; | ||||
| using juce::String; | using juce::String; | ||||
| @@ -1069,8 +1070,8 @@ protected: | |||||
| { | { | ||||
| if (pData->curPluginCount == 0 && ! fIsPatchbay) | if (pData->curPluginCount == 0 && ! fIsPatchbay) | ||||
| { | { | ||||
| FLOAT_COPY(outBuffer[0], inBuffer[0], frames); | |||||
| FLOAT_COPY(outBuffer[1], inBuffer[1], frames); | |||||
| FloatVectorOperations::copy(outBuffer[0], inBuffer[0], frames); | |||||
| FloatVectorOperations::copy(outBuffer[1], inBuffer[1], frames); | |||||
| return runPendingRtEvents();; | return runPendingRtEvents();; | ||||
| } | } | ||||
| @@ -16,6 +16,7 @@ | |||||
| */ | */ | ||||
| #include "CarlaEngineInternal.hpp" | #include "CarlaEngineInternal.hpp" | ||||
| #include "CarlaEngineGraph.hpp" | |||||
| #include "CarlaBackendUtils.hpp" | #include "CarlaBackendUtils.hpp" | ||||
| #include "CarlaMathUtils.hpp" | #include "CarlaMathUtils.hpp" | ||||
| #include "CarlaStringList.hpp" | #include "CarlaStringList.hpp" | ||||
| @@ -23,15 +24,14 @@ | |||||
| #include "RtLinkedList.hpp" | #include "RtLinkedList.hpp" | ||||
| #include "jackbridge/JackBridge.hpp" | #include "jackbridge/JackBridge.hpp" | ||||
| #include "juce_audio_basics.h" | |||||
| #include "rtaudio/RtAudio.h" | #include "rtaudio/RtAudio.h" | ||||
| #include "rtmidi/RtMidi.h" | #include "rtmidi/RtMidi.h" | ||||
| CARLA_BACKEND_START_NAMESPACE | |||||
| using juce::FloatVectorOperations; | |||||
| #if 0 | |||||
| } // Fix editor indentation | |||||
| #endif | |||||
| CARLA_BACKEND_START_NAMESPACE | |||||
| // ------------------------------------------------------------------------------------------------------------------- | // ------------------------------------------------------------------------------------------------------------------- | ||||
| // Global static data | // Global static data | ||||
| @@ -262,18 +262,8 @@ public: | |||||
| fAudioOutCount = oParams.nChannels; | fAudioOutCount = oParams.nChannels; | ||||
| fLastEventTime = 0; | fLastEventTime = 0; | ||||
| if (pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK) | |||||
| { | |||||
| pData->audio.inCount = 2; | |||||
| pData->audio.outCount = 2; | |||||
| } | |||||
| else | |||||
| { | |||||
| pData->audio.inCount = 0; | |||||
| pData->audio.outCount = 0; | |||||
| } | |||||
| pData->audio.create(pData->bufferSize); | |||||
| pData->graph.isRack = (pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK); | |||||
| pData->graph.create(pData->bufferSize); | |||||
| try { | try { | ||||
| fAudio.startStream(); | fAudio.startStream(); | ||||
| @@ -286,7 +276,7 @@ public: | |||||
| } | } | ||||
| CarlaEngine::init(clientName); | CarlaEngine::init(clientName); | ||||
| pData->audio.isReady = true; | |||||
| pData->graph.isReady = true; | |||||
| patchbayRefresh(); | patchbayRefresh(); | ||||
| @@ -298,7 +288,7 @@ public: | |||||
| CARLA_SAFE_ASSERT(fAudioOutCount != 0); | CARLA_SAFE_ASSERT(fAudioOutCount != 0); | ||||
| carla_debug("CarlaEngineRtAudio::close()"); | carla_debug("CarlaEngineRtAudio::close()"); | ||||
| pData->audio.isReady = false; | |||||
| pData->graph.isReady = false; | |||||
| bool hasError = !CarlaEngine::close(); | bool hasError = !CarlaEngine::close(); | ||||
| @@ -382,7 +372,7 @@ public: | |||||
| bool patchbayRefresh() override | bool patchbayRefresh() override | ||||
| { | { | ||||
| CARLA_SAFE_ASSERT_RETURN(pData->audio.isReady, false); | |||||
| CARLA_SAFE_ASSERT_RETURN(pData->graph.isReady, false); | |||||
| if (pData->graph.isRack) | if (pData->graph.isRack) | ||||
| patchbayRefreshRack(); | patchbayRefreshRack(); | ||||
| @@ -394,7 +384,7 @@ public: | |||||
| void patchbayRefreshRack() | void patchbayRefreshRack() | ||||
| { | { | ||||
| RackGraph* const rack(pData->graph.rack); | |||||
| RackGraph* const rack((RackGraph*)pData->graph.graph); | |||||
| rack->connections.clear(); | rack->connections.clear(); | ||||
| @@ -608,7 +598,7 @@ protected: | |||||
| CARLA_SAFE_ASSERT_RETURN(outputBuffer != nullptr, runPendingRtEvents()); | CARLA_SAFE_ASSERT_RETURN(outputBuffer != nullptr, runPendingRtEvents()); | ||||
| CARLA_SAFE_ASSERT_RETURN(pData->bufferSize == nframes, runPendingRtEvents()); | CARLA_SAFE_ASSERT_RETURN(pData->bufferSize == nframes, runPendingRtEvents()); | ||||
| if (! pData->audio.isReady) | |||||
| if (! pData->graph.isReady) | |||||
| return runPendingRtEvents(); | return runPendingRtEvents(); | ||||
| // initialize rtaudio input | // initialize rtaudio input | ||||
| @@ -623,7 +613,7 @@ protected: | |||||
| for (uint i=0; i < fAudioOutCount; ++i) | for (uint i=0; i < fAudioOutCount; ++i) | ||||
| outBuf[i] = outsPtr+(nframes*i); | outBuf[i] = outsPtr+(nframes*i); | ||||
| FLOAT_CLEAR(outsPtr, nframes*fAudioOutCount); | |||||
| FloatVectorOperations::clear(outsPtr, nframes*fAudioOutCount); | |||||
| // initialize events | // initialize events | ||||
| carla_zeroStruct<EngineEvent>(pData->events.in, kMaxEngineEventInternalCount); | carla_zeroStruct<EngineEvent>(pData->events.in, kMaxEngineEventInternalCount); | ||||
| @@ -733,7 +723,7 @@ protected: | |||||
| void handleMidiCallback(double timeStamp, std::vector<uchar>* const message) | void handleMidiCallback(double timeStamp, std::vector<uchar>* const message) | ||||
| { | { | ||||
| if (! pData->audio.isReady) | |||||
| if (! pData->graph.isReady) | |||||
| return; | return; | ||||
| const size_t messageSize(message->size()); | const size_t messageSize(message->size()); | ||||
| @@ -774,7 +764,7 @@ protected: | |||||
| CARLA_SAFE_ASSERT_RETURN(portName != nullptr && portName[0] != '\0', false); | CARLA_SAFE_ASSERT_RETURN(portName != nullptr && portName[0] != '\0', false); | ||||
| carla_debug("CarlaEngineRtAudio::connectRackMidiInPort(\"%s\")", portName); | carla_debug("CarlaEngineRtAudio::connectRackMidiInPort(\"%s\")", portName); | ||||
| RackGraph* const rack(pData->graph.rack); | |||||
| RackGraph* const rack((RackGraph*)pData->graph.graph); | |||||
| CARLA_SAFE_ASSERT_RETURN(rack->midi.ins.count() > 0, false); | CARLA_SAFE_ASSERT_RETURN(rack->midi.ins.count() > 0, false); | ||||
| CarlaString newRtMidiPortName; | CarlaString newRtMidiPortName; | ||||
| @@ -828,7 +818,7 @@ protected: | |||||
| CARLA_SAFE_ASSERT_RETURN(portName != nullptr && portName[0] != '\0', false); | CARLA_SAFE_ASSERT_RETURN(portName != nullptr && portName[0] != '\0', false); | ||||
| carla_debug("CarlaEngineRtAudio::connectRackMidiOutPort(\"%s\")", portName); | carla_debug("CarlaEngineRtAudio::connectRackMidiOutPort(\"%s\")", portName); | ||||
| RackGraph* const rack(pData->graph.rack); | |||||
| RackGraph* const rack((RackGraph*)pData->graph.graph); | |||||
| CARLA_SAFE_ASSERT_RETURN(rack->midi.ins.count() > 0, false); | CARLA_SAFE_ASSERT_RETURN(rack->midi.ins.count() > 0, false); | ||||
| CarlaString newRtMidiPortName; | CarlaString newRtMidiPortName; | ||||
| @@ -882,7 +872,7 @@ protected: | |||||
| CARLA_SAFE_ASSERT_RETURN(portName != nullptr && portName[0] != '\0', false); | CARLA_SAFE_ASSERT_RETURN(portName != nullptr && portName[0] != '\0', false); | ||||
| carla_debug("CarlaEngineRtAudio::disconnectRackMidiInPort(\"%s\")", portName); | carla_debug("CarlaEngineRtAudio::disconnectRackMidiInPort(\"%s\")", portName); | ||||
| RackGraph* const rack(pData->graph.rack); | |||||
| RackGraph* const rack((RackGraph*)pData->graph.graph); | |||||
| CARLA_SAFE_ASSERT_RETURN(rack->midi.ins.count() > 0, false); | CARLA_SAFE_ASSERT_RETURN(rack->midi.ins.count() > 0, false); | ||||
| for (LinkedList<MidiInPort>::Itenerator it=fMidiIns.begin(); it.valid(); it.next()) | for (LinkedList<MidiInPort>::Itenerator it=fMidiIns.begin(); it.valid(); it.next()) | ||||
| @@ -909,7 +899,7 @@ protected: | |||||
| CARLA_SAFE_ASSERT_RETURN(portName != nullptr && portName[0] != '\0', false); | CARLA_SAFE_ASSERT_RETURN(portName != nullptr && portName[0] != '\0', false); | ||||
| carla_debug("CarlaEngineRtAudio::disconnectRackMidiOutPort(\"%s\")", portName); | carla_debug("CarlaEngineRtAudio::disconnectRackMidiOutPort(\"%s\")", portName); | ||||
| RackGraph* const rack(pData->graph.rack); | |||||
| RackGraph* const rack((RackGraph*)pData->graph.graph); | |||||
| CARLA_SAFE_ASSERT_RETURN(rack->midi.outs.count() > 0, false); | CARLA_SAFE_ASSERT_RETURN(rack->midi.outs.count() > 0, false); | ||||
| const CarlaMutexLocker cml(fMidiOutMutex); | const CarlaMutexLocker cml(fMidiOutMutex); | ||||
| @@ -12,6 +12,7 @@ OBJS = \ | |||||
| CarlaEngine.cpp.o \ | CarlaEngine.cpp.o \ | ||||
| CarlaEngineClient.cpp.o \ | CarlaEngineClient.cpp.o \ | ||||
| CarlaEngineData.cpp.o \ | CarlaEngineData.cpp.o \ | ||||
| CarlaEngineGraph.cpp.o \ | |||||
| CarlaEngineInternal.cpp.o \ | CarlaEngineInternal.cpp.o \ | ||||
| CarlaEngineOsc.cpp.o \ | CarlaEngineOsc.cpp.o \ | ||||
| CarlaEnginePorts.cpp.o \ | CarlaEnginePorts.cpp.o \ | ||||
| @@ -67,6 +68,9 @@ CarlaEngineClient.cpp.o: CarlaEngineClient.cpp $(CARLA_ENGINE_CLIENT_CPP_DEPS) | |||||
| CarlaEngineData.cpp.o: CarlaEngineData.cpp $(CARLA_ENGINE_DATA_CPP_DEPS) | CarlaEngineData.cpp.o: CarlaEngineData.cpp $(CARLA_ENGINE_DATA_CPP_DEPS) | ||||
| $(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | $(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | ||||
| CarlaEngineGraph.cpp.o: CarlaEngineGraph.cpp $(CARLA_ENGINE_GRAPH_CPP_DEPS) | |||||
| $(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||||
| CarlaEngineInternal.cpp.o: CarlaEngineInternal.cpp $(CARLA_ENGINE_INTERNAL_CPP_DEPS) | CarlaEngineInternal.cpp.o: CarlaEngineInternal.cpp $(CARLA_ENGINE_INTERNAL_CPP_DEPS) | ||||
| $(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | $(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | ||||
| @@ -830,7 +830,7 @@ public: | |||||
| { | { | ||||
| // disable any output sound | // disable any output sound | ||||
| for (uint32_t i=0; i < pData->audioOut.count; ++i) | for (uint32_t i=0; i < pData->audioOut.count; ++i) | ||||
| FLOAT_CLEAR(outBuffer[i], frames); | |||||
| FloatVectorOperations::clear(outBuffer[i], frames); | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -1145,7 +1145,7 @@ public: | |||||
| else if (! pData->singleMutex.tryLock()) | else if (! pData->singleMutex.tryLock()) | ||||
| { | { | ||||
| for (uint32_t i=0; i < pData->audioOut.count; ++i) | for (uint32_t i=0; i < pData->audioOut.count; ++i) | ||||
| FLOAT_CLEAR(outBuffer[i], frames); | |||||
| FloatVectorOperations::clear(outBuffer[i], frames); | |||||
| return false; | return false; | ||||
| } | } | ||||
| @@ -1155,7 +1155,7 @@ public: | |||||
| //std::memset(fShmAudioPool.data, 0, fShmAudioPool.size); | //std::memset(fShmAudioPool.data, 0, fShmAudioPool.size); | ||||
| for (uint32_t i=0; i < fInfo.aIns; ++i) | for (uint32_t i=0; i < fInfo.aIns; ++i) | ||||
| FLOAT_COPY(fShmAudioPool.data + (i * frames), inBuffer[i], frames); | |||||
| FloatVectorOperations::copy(fShmAudioPool.data + (i * frames), inBuffer[i], frames); | |||||
| // -------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------- | ||||
| // TimeInfo | // TimeInfo | ||||
| @@ -1199,7 +1199,7 @@ public: | |||||
| } | } | ||||
| for (uint32_t i=0; i < fInfo.aOuts; ++i) | for (uint32_t i=0; i < fInfo.aOuts; ++i) | ||||
| FLOAT_COPY(outBuffer[i], fShmAudioPool.data + ((i + fInfo.aIns) * frames), frames); | |||||
| FloatVectorOperations::copy(outBuffer[i], fShmAudioPool.data + ((i + fInfo.aIns) * frames), frames); | |||||
| // -------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------- | ||||
| // Post-processing (dry/wet, volume and balance) | // Post-processing (dry/wet, volume and balance) | ||||
| @@ -1232,7 +1232,7 @@ public: | |||||
| if (isPair) | if (isPair) | ||||
| { | { | ||||
| CARLA_ASSERT(i+1 < pData->audioOut.count); | CARLA_ASSERT(i+1 < pData->audioOut.count); | ||||
| FLOAT_COPY(oldBufLeft, outBuffer[i], frames); | |||||
| FloatVectorOperations::copy(oldBufLeft, outBuffer[i], frames); | |||||
| } | } | ||||
| float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f; | float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f; | ||||
| @@ -632,7 +632,7 @@ void CarlaPlugin::ProtectedData::recreateLatencyBuffers() | |||||
| for (uint32_t i=0; i < audioIn.count; ++i) | for (uint32_t i=0; i < audioIn.count; ++i) | ||||
| { | { | ||||
| latencyBuffers[i] = new float[latency]; | latencyBuffers[i] = new float[latency]; | ||||
| FLOAT_CLEAR(latencyBuffers[i], latency); | |||||
| FloatVectorOperations::clear(latencyBuffers[i], latency); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -25,21 +25,14 @@ | |||||
| #include "CarlaStateUtils.hpp" | #include "CarlaStateUtils.hpp" | ||||
| #include "CarlaMIDI.h" | #include "CarlaMIDI.h" | ||||
| #include "CarlaMutex.hpp" | |||||
| #include "RtLinkedList.hpp" | #include "RtLinkedList.hpp" | ||||
| // ----------------------------------------------------------------------- | |||||
| #define CARLA_PROCESS_CONTINUE_CHECK if (! pData->enabled) { pData->engine->callback(ENGINE_CALLBACK_DEBUG, pData->id, 0, 0, 0.0f, "Processing while plugin is disabled!!"); return; } | |||||
| #include "juce_audio_basics.h" | |||||
| // ----------------------------------------------------------------------- | |||||
| using juce::FloatVectorOperations; | |||||
| CARLA_BACKEND_START_NAMESPACE | CARLA_BACKEND_START_NAMESPACE | ||||
| #if 0 | |||||
| } // Fix editor indentation | |||||
| #endif | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // Forward declarations of CarlaEngine port classes | // Forward declarations of CarlaEngine port classes | ||||
| @@ -60,6 +53,17 @@ const uint PLUGIN_EXTRA_HINT_HAS_MIDI_OUT = 0x02; | |||||
| const uint PLUGIN_EXTRA_HINT_CAN_RUN_RACK = 0x04; | const uint PLUGIN_EXTRA_HINT_CAN_RUN_RACK = 0x04; | ||||
| const uint PLUGIN_EXTRA_HINT_USES_MULTI_PROGS = 0x08; | const uint PLUGIN_EXTRA_HINT_USES_MULTI_PROGS = 0x08; | ||||
| // ----------------------------------------------------------------------- | |||||
| // Special parameters | |||||
| enum SpecialParameterType { | |||||
| PARAMETER_SPECIAL_NULL = 0, | |||||
| PARAMETER_SPECIAL_FREEWHEEL = 1, | |||||
| PARAMETER_SPECIAL_LATENCY = 2, | |||||
| PARAMETER_SPECIAL_SAMPLE_RATE = 3, | |||||
| PARAMETER_SPECIAL_TIME = 4 | |||||
| }; | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| /*! | /*! | ||||
| @@ -123,7 +127,7 @@ struct PluginAudioData { | |||||
| struct PluginCVPort { | struct PluginCVPort { | ||||
| uint32_t rindex; | uint32_t rindex; | ||||
| uint32_t param; // FIXME is this needed? | |||||
| //uint32_t param; // FIXME is this needed? | |||||
| CarlaEngineCVPort* port; | CarlaEngineCVPort* port; | ||||
| }; | }; | ||||
| @@ -156,14 +160,6 @@ struct PluginEventData { | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| enum SpecialParameterType { | |||||
| PARAMETER_SPECIAL_NULL = 0, | |||||
| PARAMETER_SPECIAL_FREEWHEEL = 1, | |||||
| PARAMETER_SPECIAL_LATENCY = 2, | |||||
| PARAMETER_SPECIAL_SAMPLE_RATE = 3, | |||||
| PARAMETER_SPECIAL_TIME = 4 | |||||
| }; | |||||
| struct PluginParameterData { | struct PluginParameterData { | ||||
| uint32_t count; | uint32_t count; | ||||
| ParameterData* data; | ParameterData* data; | ||||
| @@ -564,7 +564,7 @@ public: | |||||
| pData->param.createNew(params, true); | pData->param.createNew(params, true); | ||||
| fParamBuffers = new float[params]; | fParamBuffers = new float[params]; | ||||
| FLOAT_CLEAR(fParamBuffers, params); | |||||
| FloatVectorOperations::clear(fParamBuffers, params); | |||||
| } | } | ||||
| const uint portNameSize(pData->engine->getMaxPortNameSize()); | const uint portNameSize(pData->engine->getMaxPortNameSize()); | ||||
| @@ -1093,7 +1093,7 @@ public: | |||||
| { | { | ||||
| // disable any output sound | // disable any output sound | ||||
| for (uint32_t i=0; i < pData->audioOut.count; ++i) | for (uint32_t i=0; i < pData->audioOut.count; ++i) | ||||
| FLOAT_CLEAR(outBuffer[i], frames); | |||||
| FloatVectorOperations::clear(outBuffer[i], frames); | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -1137,7 +1137,7 @@ public: | |||||
| if (pData->latency > 0) | if (pData->latency > 0) | ||||
| { | { | ||||
| for (uint32_t i=0; i < pData->audioIn.count; ++i) | for (uint32_t i=0; i < pData->audioIn.count; ++i) | ||||
| FLOAT_CLEAR(pData->latencyBuffers[i], pData->latency); | |||||
| FloatVectorOperations::clear(pData->latencyBuffers[i], pData->latency); | |||||
| } | } | ||||
| #endif | #endif | ||||
| @@ -1540,7 +1540,7 @@ public: | |||||
| if (pData->latency <= frames) | if (pData->latency <= frames) | ||||
| { | { | ||||
| for (uint32_t i=0; i < pData->audioIn.count; ++i) | for (uint32_t i=0; i < pData->audioIn.count; ++i) | ||||
| FLOAT_COPY(pData->latencyBuffers[i], inBuffer[i]+(frames-pData->latency), pData->latency); | |||||
| FloatVectorOperations::copy(pData->latencyBuffers[i], inBuffer[i]+(frames-pData->latency), pData->latency); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -1618,10 +1618,10 @@ public: | |||||
| // Reset audio buffers | // Reset audio buffers | ||||
| for (uint32_t i=0; i < pData->audioIn.count; ++i) | for (uint32_t i=0; i < pData->audioIn.count; ++i) | ||||
| FLOAT_COPY(fAudioInBuffers[i], inBuffer[i]+timeOffset, frames); | |||||
| FloatVectorOperations::copy(fAudioInBuffers[i], inBuffer[i]+timeOffset, frames); | |||||
| for (uint32_t i=0; i < pData->audioOut.count; ++i) | for (uint32_t i=0; i < pData->audioOut.count; ++i) | ||||
| FLOAT_CLEAR(fAudioOutBuffers[i], frames); | |||||
| FloatVectorOperations::clear(fAudioOutBuffers[i], frames); | |||||
| // -------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------- | ||||
| // Run plugin | // Run plugin | ||||
| @@ -1689,7 +1689,7 @@ public: | |||||
| if (isPair) | if (isPair) | ||||
| { | { | ||||
| CARLA_ASSERT(i+1 < pData->audioOut.count); | CARLA_ASSERT(i+1 < pData->audioOut.count); | ||||
| FLOAT_COPY(oldBufLeft, fAudioOutBuffers[i], frames); | |||||
| FloatVectorOperations::copy(oldBufLeft, fAudioOutBuffers[i], frames); | |||||
| } | } | ||||
| float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f; | float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f; | ||||
| @@ -52,7 +52,7 @@ public: | |||||
| { | { | ||||
| carla_debug("FluidSynthPlugin::FluidSynthPlugin(%p, %i, %s)", engine, id, bool2str(use16Outs)); | carla_debug("FluidSynthPlugin::FluidSynthPlugin(%p, %i, %s)", engine, id, bool2str(use16Outs)); | ||||
| FLOAT_CLEAR(fParamBuffers, FluidSynthParametersMax); | |||||
| FloatVectorOperations::clear(fParamBuffers, FluidSynthParametersMax); | |||||
| carla_fill<int32_t>(fCurMidiProgs, 0, MAX_MIDI_CHANNELS); | carla_fill<int32_t>(fCurMidiProgs, 0, MAX_MIDI_CHANNELS); | ||||
| // create settings | // create settings | ||||
| @@ -1044,7 +1044,7 @@ public: | |||||
| { | { | ||||
| // disable any output sound | // disable any output sound | ||||
| for (uint32_t i=0; i < pData->audioOut.count; ++i) | for (uint32_t i=0; i < pData->audioOut.count; ++i) | ||||
| FLOAT_CLEAR(outBuffer[i], frames); | |||||
| FloatVectorOperations::clear(outBuffer[i], frames); | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -1366,8 +1366,6 @@ public: | |||||
| } // End of Event Input and Processing | } // End of Event Input and Processing | ||||
| CARLA_PROCESS_CONTINUE_CHECK; | |||||
| // -------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------- | ||||
| // Control Output | // Control Output | ||||
| @@ -1414,7 +1412,7 @@ public: | |||||
| if (fUses16Outs) | if (fUses16Outs) | ||||
| { | { | ||||
| for (uint32_t i=0; i < pData->audioOut.count; ++i) | for (uint32_t i=0; i < pData->audioOut.count; ++i) | ||||
| FLOAT_CLEAR(fAudio16Buffers[i], frames); | |||||
| FloatVectorOperations::clear(fAudio16Buffers[i], frames); | |||||
| // FIXME use '32' or '16' instead of outs | // FIXME use '32' or '16' instead of outs | ||||
| fluid_synth_process(fSynth, static_cast<int>(frames), 0, nullptr, static_cast<int>(pData->audioOut.count), fAudio16Buffers); | fluid_synth_process(fSynth, static_cast<int>(frames), 0, nullptr, static_cast<int>(pData->audioOut.count), fAudio16Buffers); | ||||
| @@ -1439,7 +1437,7 @@ public: | |||||
| if (doBalance) | if (doBalance) | ||||
| { | { | ||||
| if (i % 2 == 0) | if (i % 2 == 0) | ||||
| FLOAT_COPY(oldBufLeft, outBuffer[i]+timeOffset, frames); | |||||
| FloatVectorOperations::copy(oldBufLeft, outBuffer[i]+timeOffset, frames); | |||||
| float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f; | float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f; | ||||
| float balRangeR = (pData->postProc.balanceRight + 1.0f)/2.0f; | float balRangeR = (pData->postProc.balanceRight + 1.0f)/2.0f; | ||||
| @@ -534,7 +534,7 @@ public: | |||||
| pData->param.createNew(params, true); | pData->param.createNew(params, true); | ||||
| fParamBuffers = new float[params]; | fParamBuffers = new float[params]; | ||||
| FLOAT_CLEAR(fParamBuffers, params); | |||||
| FloatVectorOperations::clear(fParamBuffers, params); | |||||
| } | } | ||||
| const uint portNameSize(pData->engine->getMaxPortNameSize()); | const uint portNameSize(pData->engine->getMaxPortNameSize()); | ||||
| @@ -960,7 +960,7 @@ public: | |||||
| { | { | ||||
| // disable any output sound | // disable any output sound | ||||
| for (uint32_t i=0; i < pData->audioOut.count; ++i) | for (uint32_t i=0; i < pData->audioOut.count; ++i) | ||||
| FLOAT_CLEAR(outBuffer[i], frames); | |||||
| FloatVectorOperations::clear(outBuffer[i], frames); | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -973,7 +973,7 @@ public: | |||||
| if (pData->latency > 0) | if (pData->latency > 0) | ||||
| { | { | ||||
| for (uint32_t i=0; i < pData->audioIn.count; ++i) | for (uint32_t i=0; i < pData->audioIn.count; ++i) | ||||
| FLOAT_CLEAR(pData->latencyBuffers[i], pData->latency); | |||||
| FloatVectorOperations::clear(pData->latencyBuffers[i], pData->latency); | |||||
| } | } | ||||
| #endif | #endif | ||||
| @@ -1153,7 +1153,7 @@ public: | |||||
| if (pData->latency <= frames) | if (pData->latency <= frames) | ||||
| { | { | ||||
| for (uint32_t i=0; i < pData->audioIn.count; ++i) | for (uint32_t i=0; i < pData->audioIn.count; ++i) | ||||
| FLOAT_COPY(pData->latencyBuffers[i], inBuffer[i]+(frames-pData->latency), pData->latency); | |||||
| FloatVectorOperations::copy(pData->latencyBuffers[i], inBuffer[i]+(frames-pData->latency), pData->latency); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -1231,10 +1231,10 @@ public: | |||||
| // Reset audio buffers | // Reset audio buffers | ||||
| for (uint32_t i=0; i < pData->audioIn.count; ++i) | for (uint32_t i=0; i < pData->audioIn.count; ++i) | ||||
| FLOAT_COPY(fAudioInBuffers[i], inBuffer[i]+timeOffset, frames); | |||||
| FloatVectorOperations::copy(fAudioInBuffers[i], inBuffer[i]+timeOffset, frames); | |||||
| for (uint32_t i=0; i < pData->audioOut.count; ++i) | for (uint32_t i=0; i < pData->audioOut.count; ++i) | ||||
| FLOAT_CLEAR(fAudioOutBuffers[i], frames); | |||||
| FloatVectorOperations::clear(fAudioOutBuffers[i], frames); | |||||
| // -------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------- | ||||
| // Run plugin | // Run plugin | ||||
| @@ -1288,7 +1288,7 @@ public: | |||||
| if (isPair) | if (isPair) | ||||
| { | { | ||||
| CARLA_ASSERT(i+1 < pData->audioOut.count); | CARLA_ASSERT(i+1 < pData->audioOut.count); | ||||
| FLOAT_COPY(oldBufLeft, fAudioOutBuffers[i], frames); | |||||
| FloatVectorOperations::copy(oldBufLeft, fAudioOutBuffers[i], frames); | |||||
| } | } | ||||
| float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f; | float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f; | ||||
| @@ -730,7 +730,7 @@ public: | |||||
| { | { | ||||
| // disable any output sound | // disable any output sound | ||||
| for (uint32_t i=0; i < pData->audioOut.count; ++i) | for (uint32_t i=0; i < pData->audioOut.count; ++i) | ||||
| FLOAT_CLEAR(outBuffer[i], frames); | |||||
| FloatVectorOperations::clear(outBuffer[i], frames); | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -1081,7 +1081,7 @@ public: | |||||
| if (doBalance) | if (doBalance) | ||||
| { | { | ||||
| if (i % 2 == 0) | if (i % 2 == 0) | ||||
| FLOAT_COPY(oldBufLeft, outBuffer[i], frames); | |||||
| FloatVectorOperations::copy(oldBufLeft, outBuffer[i], frames); | |||||
| float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f; | float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f; | ||||
| float balRangeR = (pData->postProc.balanceRight + 1.0f)/2.0f; | float balRangeR = (pData->postProc.balanceRight + 1.0f)/2.0f; | ||||
| @@ -1516,7 +1516,7 @@ public: | |||||
| { | { | ||||
| pData->param.createNew(params, true); | pData->param.createNew(params, true); | ||||
| fParamBuffers = new float[params]; | fParamBuffers = new float[params]; | ||||
| FLOAT_CLEAR(fParamBuffers, params); | |||||
| FloatVectorOperations::clear(fParamBuffers, params); | |||||
| } | } | ||||
| if (const uint32_t count = static_cast<uint32_t>(evIns.count())) | if (const uint32_t count = static_cast<uint32_t>(evIns.count())) | ||||
| @@ -2438,7 +2438,7 @@ public: | |||||
| { | { | ||||
| // disable any output sound | // disable any output sound | ||||
| for (uint32_t i=0; i < pData->audioOut.count; ++i) | for (uint32_t i=0; i < pData->audioOut.count; ++i) | ||||
| FLOAT_CLEAR(outBuffer[i], frames); | |||||
| FloatVectorOperations::clear(outBuffer[i], frames); | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -2487,8 +2487,6 @@ public: | |||||
| } | } | ||||
| } | } | ||||
| CARLA_PROCESS_CONTINUE_CHECK; | |||||
| // -------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------- | ||||
| // Check if needs reset | // Check if needs reset | ||||
| @@ -2552,7 +2550,7 @@ public: | |||||
| if (pData->latency > 0) | if (pData->latency > 0) | ||||
| { | { | ||||
| for (uint32_t i=0; i < pData->audioIn.count; ++i) | for (uint32_t i=0; i < pData->audioIn.count; ++i) | ||||
| FLOAT_CLEAR(pData->latencyBuffers[i], pData->latency); | |||||
| FloatVectorOperations::clear(pData->latencyBuffers[i], pData->latency); | |||||
| } | } | ||||
| #endif | #endif | ||||
| @@ -2705,8 +2703,6 @@ public: | |||||
| pData->postRtEvents.trySplice(); | pData->postRtEvents.trySplice(); | ||||
| carla_copyStruct<EngineTimeInfo>(fLastTimeInfo, timeInfo); | carla_copyStruct<EngineTimeInfo>(fLastTimeInfo, timeInfo); | ||||
| CARLA_PROCESS_CONTINUE_CHECK; | |||||
| } | } | ||||
| // -------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------- | ||||
| @@ -3135,7 +3131,7 @@ public: | |||||
| if (pData->latency <= frames) | if (pData->latency <= frames) | ||||
| { | { | ||||
| for (uint32_t i=0; i < pData->audioIn.count; ++i) | for (uint32_t i=0; i < pData->audioIn.count; ++i) | ||||
| FLOAT_COPY(pData->latencyBuffers[i], inBuffer[i]+(frames-pData->latency), pData->latency); | |||||
| FloatVectorOperations::copy(pData->latencyBuffers[i], inBuffer[i]+(frames-pData->latency), pData->latency); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -3327,19 +3323,19 @@ public: | |||||
| // Set audio buffers | // Set audio buffers | ||||
| for (uint32_t i=0; i < pData->audioIn.count; ++i) | for (uint32_t i=0; i < pData->audioIn.count; ++i) | ||||
| FLOAT_COPY(fAudioInBuffers[i], audioInBuf[i]+timeOffset, frames); | |||||
| FloatVectorOperations::copy(fAudioInBuffers[i], audioInBuf[i]+timeOffset, frames); | |||||
| for (uint32_t i=0; i < pData->audioOut.count; ++i) | for (uint32_t i=0; i < pData->audioOut.count; ++i) | ||||
| FLOAT_CLEAR(fAudioOutBuffers[i], frames); | |||||
| FloatVectorOperations::clear(fAudioOutBuffers[i], frames); | |||||
| // -------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------- | ||||
| // Set CV buffers | // Set CV buffers | ||||
| for (uint32_t i=0; i < fCvIn.count; ++i) | for (uint32_t i=0; i < fCvIn.count; ++i) | ||||
| FLOAT_COPY(fCvInBuffers[i], cvInBuf[i]+timeOffset, frames); | |||||
| FloatVectorOperations::copy(fCvInBuffers[i], cvInBuf[i]+timeOffset, frames); | |||||
| for (uint32_t i=0; i < fCvOut.count; ++i) | for (uint32_t i=0; i < fCvOut.count; ++i) | ||||
| FLOAT_CLEAR(fCvOutBuffers[i], frames); | |||||
| FloatVectorOperations::clear(fCvOutBuffers[i], frames); | |||||
| // -------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------- | ||||
| // Run plugin | // Run plugin | ||||
| @@ -3407,7 +3403,7 @@ public: | |||||
| if (isPair) | if (isPair) | ||||
| { | { | ||||
| CARLA_ASSERT(i+1 < pData->audioOut.count); | CARLA_ASSERT(i+1 < pData->audioOut.count); | ||||
| FLOAT_COPY(oldBufLeft, fAudioOutBuffers[i], frames); | |||||
| FloatVectorOperations::copy(oldBufLeft, fAudioOutBuffers[i], frames); | |||||
| } | } | ||||
| float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f; | float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f; | ||||
| @@ -1282,7 +1282,7 @@ public: | |||||
| { | { | ||||
| // disable any output sound | // disable any output sound | ||||
| for (uint32_t i=0; i < pData->audioOut.count; ++i) | for (uint32_t i=0; i < pData->audioOut.count; ++i) | ||||
| FLOAT_CLEAR(outBuffer[i], frames); | |||||
| FloatVectorOperations::clear(outBuffer[i], frames); | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -1328,8 +1328,6 @@ public: | |||||
| pData->needsReset = false; | pData->needsReset = false; | ||||
| } | } | ||||
| CARLA_PROCESS_CONTINUE_CHECK; | |||||
| // -------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------- | ||||
| // Set TimeInfo | // Set TimeInfo | ||||
| @@ -1357,8 +1355,6 @@ public: | |||||
| else | else | ||||
| fTimeInfo.bbt.valid = false; | fTimeInfo.bbt.valid = false; | ||||
| CARLA_PROCESS_CONTINUE_CHECK; | |||||
| // -------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------- | ||||
| // Event Input and Processing | // Event Input and Processing | ||||
| @@ -1685,8 +1681,6 @@ public: | |||||
| } // End of Plugin processing (no events) | } // End of Plugin processing (no events) | ||||
| CARLA_PROCESS_CONTINUE_CHECK; | |||||
| // -------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------- | ||||
| // Control and MIDI Output | // Control and MIDI Output | ||||
| @@ -1771,10 +1765,10 @@ public: | |||||
| // Reset audio buffers | // Reset audio buffers | ||||
| for (i=0; i < pData->audioIn.count; ++i) | for (i=0; i < pData->audioIn.count; ++i) | ||||
| FLOAT_COPY(fAudioInBuffers[i], inBuffer[i]+timeOffset, frames); | |||||
| FloatVectorOperations::copy(fAudioInBuffers[i], inBuffer[i]+timeOffset, frames); | |||||
| for (i=0; i < pData->audioOut.count; ++i) | for (i=0; i < pData->audioOut.count; ++i) | ||||
| FLOAT_CLEAR(fAudioOutBuffers[i], frames); | |||||
| FloatVectorOperations::clear(fAudioOutBuffers[i], frames); | |||||
| // -------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------- | ||||
| // Run plugin | // Run plugin | ||||
| @@ -1832,7 +1826,7 @@ public: | |||||
| if (isPair) | if (isPair) | ||||
| { | { | ||||
| CARLA_ASSERT(i+1 < pData->audioOut.count); | CARLA_ASSERT(i+1 < pData->audioOut.count); | ||||
| FLOAT_COPY(oldBufLeft, fAudioOutBuffers[i], frames); | |||||
| FloatVectorOperations::copy(oldBufLeft, fAudioOutBuffers[i], frames); | |||||
| } | } | ||||
| float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f; | float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f; | ||||
| @@ -1055,7 +1055,7 @@ public: | |||||
| { | { | ||||
| // disable any output sound | // disable any output sound | ||||
| for (uint32_t i=0; i < pData->audioOut.count; ++i) | for (uint32_t i=0; i < pData->audioOut.count; ++i) | ||||
| FLOAT_CLEAR(outBuffer[i], frames); | |||||
| FloatVectorOperations::clear(outBuffer[i], frames); | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -1101,7 +1101,7 @@ public: | |||||
| if (pData->latency > 0) | if (pData->latency > 0) | ||||
| { | { | ||||
| for (uint32_t i=0; i < pData->audioIn.count; ++i) | for (uint32_t i=0; i < pData->audioIn.count; ++i) | ||||
| FLOAT_CLEAR(pData->latencyBuffers[i], pData->latency); | |||||
| FloatVectorOperations::clear(pData->latencyBuffers[i], pData->latency); | |||||
| } | } | ||||
| #endif | #endif | ||||
| @@ -1474,8 +1474,6 @@ public: | |||||
| } // End of Plugin processing (no events) | } // End of Plugin processing (no events) | ||||
| CARLA_PROCESS_CONTINUE_CHECK; | |||||
| // -------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------- | ||||
| // MIDI Output | // MIDI Output | ||||
| @@ -1568,7 +1566,7 @@ public: | |||||
| else | else | ||||
| { | { | ||||
| for (uint32_t i=0; i < pData->audioOut.count; ++i) | for (uint32_t i=0; i < pData->audioOut.count; ++i) | ||||
| FLOAT_CLEAR(vstOutBuffer[i], frames); | |||||
| FloatVectorOperations::clear(vstOutBuffer[i], frames); | |||||
| #if ! VST_FORCE_DEPRECATED | #if ! VST_FORCE_DEPRECATED | ||||
| fEffect->process(fEffect, (pData->audioIn.count > 0) ? vstInBuffer : nullptr, (pData->audioOut.count > 0) ? vstOutBuffer : nullptr, static_cast<int32_t>(frames)); | fEffect->process(fEffect, (pData->audioIn.count > 0) ? vstInBuffer : nullptr, (pData->audioOut.count > 0) ? vstOutBuffer : nullptr, static_cast<int32_t>(frames)); | ||||
| @@ -1611,7 +1609,7 @@ public: | |||||
| if (isPair) | if (isPair) | ||||
| { | { | ||||
| CARLA_ASSERT(i+1 < pData->audioOut.count); | CARLA_ASSERT(i+1 < pData->audioOut.count); | ||||
| FLOAT_COPY(oldBufLeft, outBuffer[i]+timeOffset, frames); | |||||
| FloatVectorOperations::copy(oldBufLeft, outBuffer[i]+timeOffset, frames); | |||||
| } | } | ||||
| float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f; | float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f; | ||||
| @@ -20,12 +20,9 @@ | |||||
| #include "CarlaMathUtils.hpp" | #include "CarlaMathUtils.hpp" | ||||
| #include "CarlaMIDI.h" | #include "CarlaMIDI.h" | ||||
| // FIXME | |||||
| #ifdef HAVE_JUCE | |||||
| # if defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN) | |||||
| # define WANT_JUCE_PROCESSORS | |||||
| # include "juce_audio_processors.h" | |||||
| # endif | |||||
| #if defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN) | |||||
| # define WANT_JUCE_PROCESSORS | |||||
| # include "juce_audio_processors.h" | |||||
| #endif | #endif | ||||
| #ifdef WANT_LADSPA | #ifdef WANT_LADSPA | ||||
| @@ -49,6 +46,10 @@ | |||||
| #include <iostream> | #include <iostream> | ||||
| #include "juce_audio_basics.h" | |||||
| using juce::FloatVectorOperations; | |||||
| // FIXME | |||||
| #include <QtCore/QDir> | #include <QtCore/QDir> | ||||
| #include <QtCore/QFileInfo> | #include <QtCore/QFileInfo> | ||||
| #include <QtCore/QUrl> | #include <QtCore/QUrl> | ||||
| @@ -553,7 +554,7 @@ static void do_ladspa_check(void*& libHandle, const char* const filename, const | |||||
| if (LADSPA_IS_PORT_AUDIO(portDescriptor)) | if (LADSPA_IS_PORT_AUDIO(portDescriptor)) | ||||
| { | { | ||||
| carla_zeroFloat(bufferAudio[iA], kBufferSize); | |||||
| FloatVectorOperations::clear(bufferAudio[iA], kBufferSize); | |||||
| descriptor->connect_port(handle, j, bufferAudio[iA++]); | descriptor->connect_port(handle, j, bufferAudio[iA++]); | ||||
| } | } | ||||
| else if (LADSPA_IS_PORT_CONTROL(portDescriptor)) | else if (LADSPA_IS_PORT_CONTROL(portDescriptor)) | ||||
| @@ -829,7 +830,7 @@ static void do_dssi_check(void*& libHandle, const char* const filename, const bo | |||||
| if (LADSPA_IS_PORT_AUDIO(portDescriptor)) | if (LADSPA_IS_PORT_AUDIO(portDescriptor)) | ||||
| { | { | ||||
| carla_zeroFloat(bufferAudio[iA], kBufferSize); | |||||
| FloatVectorOperations::clear(bufferAudio[iA], kBufferSize); | |||||
| ldescriptor->connect_port(handle, j, bufferAudio[iA++]); | ldescriptor->connect_port(handle, j, bufferAudio[iA++]); | ||||
| } | } | ||||
| else if (LADSPA_IS_PORT_CONTROL(portDescriptor)) | else if (LADSPA_IS_PORT_CONTROL(portDescriptor)) | ||||
| @@ -1295,14 +1296,14 @@ static void do_vst_check(void*& libHandle, const bool init) | |||||
| for (int j=0; j < audioIns; ++j) | for (int j=0; j < audioIns; ++j) | ||||
| { | { | ||||
| bufferAudioIn[j] = new float[kBufferSize]; | bufferAudioIn[j] = new float[kBufferSize]; | ||||
| carla_zeroFloat(bufferAudioIn[j], kBufferSize); | |||||
| FloatVectorOperations::clear(bufferAudioIn[j], kBufferSize); | |||||
| } | } | ||||
| float* bufferAudioOut[audioOuts]; | float* bufferAudioOut[audioOuts]; | ||||
| for (int j=0; j < audioOuts; ++j) | for (int j=0; j < audioOuts; ++j) | ||||
| { | { | ||||
| bufferAudioOut[j] = new float[kBufferSize]; | bufferAudioOut[j] = new float[kBufferSize]; | ||||
| carla_zeroFloat(bufferAudioOut[j], kBufferSize); | |||||
| FloatVectorOperations::clear(bufferAudioOut[j], kBufferSize); | |||||
| } | } | ||||
| struct VstEventsFixed { | struct VstEventsFixed { | ||||
| @@ -20,7 +20,8 @@ | |||||
| #include "CarlaThread.hpp" | #include "CarlaThread.hpp" | ||||
| #include "CarlaMathUtils.hpp" | |||||
| #include "juce_audio_basics.h" | |||||
| using juce::FloatVectorOperations; | |||||
| extern "C" { | extern "C" { | ||||
| #include "audio_decoder/ad.h" | #include "audio_decoder/ad.h" | ||||
| @@ -91,8 +92,8 @@ struct AudioFilePool { | |||||
| startFrame = 0; | startFrame = 0; | ||||
| FLOAT_CLEAR(buffer[0], size); | |||||
| FLOAT_CLEAR(buffer[1], size); | |||||
| FloatVectorOperations::clear(buffer[0], size); | |||||
| FloatVectorOperations::clear(buffer[1], size); | |||||
| } | } | ||||
| }; | }; | ||||
| @@ -218,8 +219,8 @@ public: | |||||
| { | { | ||||
| pool.startFrame = fPool.startFrame; | pool.startFrame = fPool.startFrame; | ||||
| FLOAT_COPY(pool.buffer[0], fPool.buffer[0], fPool.size); | |||||
| FLOAT_COPY(pool.buffer[1], fPool.buffer[1], fPool.size); | |||||
| FloatVectorOperations::copy(pool.buffer[0], fPool.buffer[0], fPool.size); | |||||
| FloatVectorOperations::copy(pool.buffer[1], fPool.buffer[1], fPool.size); | |||||
| } | } | ||||
| fMutex.unlock(); | fMutex.unlock(); | ||||
| @@ -269,7 +270,7 @@ public: | |||||
| const size_t tmpSize = fPool.size * fFileNfo.channels; | const size_t tmpSize = fPool.size * fFileNfo.channels; | ||||
| float tmpData[tmpSize]; | float tmpData[tmpSize]; | ||||
| FLOAT_CLEAR(tmpData, int(tmpSize)); | |||||
| FloatVectorOperations::clear(tmpData, int(tmpSize)); | |||||
| { | { | ||||
| carla_stderr("R: poll data - reading at %li:%02li", readFrame/44100/60, (readFrame/44100) % 60); | carla_stderr("R: poll data - reading at %li:%02li", readFrame/44100/60, (readFrame/44100) % 60); | ||||
| @@ -128,8 +128,8 @@ protected: | |||||
| //carla_stderr("P: no process"); | //carla_stderr("P: no process"); | ||||
| fLastFrame = timePos->frame; | fLastFrame = timePos->frame; | ||||
| FLOAT_CLEAR(out1, frames); | |||||
| FLOAT_CLEAR(out2, frames); | |||||
| FloatVectorOperations::clear(out1, frames); | |||||
| FloatVectorOperations::clear(out2, frames); | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -142,8 +142,8 @@ protected: | |||||
| if (timePos->frame == 0 && fLastFrame > 0) | if (timePos->frame == 0 && fLastFrame > 0) | ||||
| fThread.setNeedsRead(); | fThread.setNeedsRead(); | ||||
| FLOAT_CLEAR(out1, frames); | |||||
| FLOAT_CLEAR(out2, frames); | |||||
| FloatVectorOperations::clear(out1, frames); | |||||
| FloatVectorOperations::clear(out2, frames); | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -158,8 +158,8 @@ protected: | |||||
| if (timePos->frame + frames < fPool.startFrame) | if (timePos->frame + frames < fPool.startFrame) | ||||
| fThread.setNeedsRead(); | fThread.setNeedsRead(); | ||||
| FLOAT_CLEAR(out1, frames); | |||||
| FLOAT_CLEAR(out2, frames); | |||||
| FloatVectorOperations::clear(out1, frames); | |||||
| FloatVectorOperations::clear(out2, frames); | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -80,8 +80,8 @@ protected: | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| FLOAT_CLEAR(outBuf[0], frames); | |||||
| FLOAT_CLEAR(outBuf[1], frames); | |||||
| FloatVectorOperations::clear(outBuf[0], frames); | |||||
| FloatVectorOperations::clear(outBuf[1], frames); | |||||
| } | } | ||||
| } | } | ||||
| @@ -25,7 +25,8 @@ | |||||
| #include "zynaddsubfx/Effects/Phaser.h" | #include "zynaddsubfx/Effects/Phaser.h" | ||||
| #include "zynaddsubfx/Effects/Reverb.h" | #include "zynaddsubfx/Effects/Reverb.h" | ||||
| #include "CarlaMathUtils.hpp" | |||||
| #include "juce_audio_basics.h" | |||||
| using juce::FloatVectorOperations; | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| @@ -45,8 +46,8 @@ protected: | |||||
| efxoutl = new float[bufferSize]; | efxoutl = new float[bufferSize]; | ||||
| efxoutr = new float[bufferSize]; | efxoutr = new float[bufferSize]; | ||||
| FLOAT_CLEAR(efxoutl, bufferSize); | |||||
| FLOAT_CLEAR(efxoutr, bufferSize); | |||||
| FloatVectorOperations::clear(efxoutl, bufferSize); | |||||
| FloatVectorOperations::clear(efxoutr, bufferSize); | |||||
| } | } | ||||
| ~FxAbstractPlugin() override | ~FxAbstractPlugin() override | ||||
| @@ -134,8 +135,8 @@ protected: | |||||
| { | { | ||||
| fEffect->out(Stereo<float*>(inBuffer[0], inBuffer[1])); | fEffect->out(Stereo<float*>(inBuffer[0], inBuffer[1])); | ||||
| FLOAT_COPY(outBuffer[0], efxoutl, frames); | |||||
| FLOAT_COPY(outBuffer[1], efxoutr, frames); | |||||
| FloatVectorOperations::copy(outBuffer[0], efxoutl, frames); | |||||
| FloatVectorOperations::copy(outBuffer[1], efxoutr, frames); | |||||
| } | } | ||||
| // ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
| @@ -147,8 +148,8 @@ protected: | |||||
| delete[] efxoutr; | delete[] efxoutr; | ||||
| efxoutl = new float[bufferSize]; | efxoutl = new float[bufferSize]; | ||||
| efxoutr = new float[bufferSize]; | efxoutr = new float[bufferSize]; | ||||
| FLOAT_CLEAR(efxoutl, bufferSize); | |||||
| FLOAT_CLEAR(efxoutr, bufferSize); | |||||
| FloatVectorOperations::clear(efxoutl, bufferSize); | |||||
| FloatVectorOperations::clear(efxoutr, bufferSize); | |||||
| doReinit(bufferSize, getSampleRate()); | doReinit(bufferSize, getSampleRate()); | ||||
| } | } | ||||
| @@ -49,6 +49,9 @@ | |||||
| #include <set> | #include <set> | ||||
| #include <string> | #include <string> | ||||
| #include "juce_audio_basics.h" | |||||
| using juce::FloatVectorOperations; | |||||
| #ifdef WANT_ZYNADDSUBFX_UI | #ifdef WANT_ZYNADDSUBFX_UI | ||||
| static Fl_Tiled_Image* gModuleBackdrop = nullptr; | static Fl_Tiled_Image* gModuleBackdrop = nullptr; | ||||
| static CarlaString gPixmapPath; | static CarlaString gPixmapPath; | ||||
| @@ -640,8 +643,8 @@ protected: | |||||
| { | { | ||||
| if (pthread_mutex_trylock(&fMaster->mutex) != 0) | if (pthread_mutex_trylock(&fMaster->mutex) != 0) | ||||
| { | { | ||||
| FLOAT_CLEAR(outBuffer[0], frames); | |||||
| FLOAT_CLEAR(outBuffer[1], frames); | |||||
| FloatVectorOperations::clear(outBuffer[0], frames); | |||||
| FloatVectorOperations::clear(outBuffer[1], frames); | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -453,7 +453,7 @@ public: | |||||
| { | { | ||||
| FloatVectorOperations::multiply(fPorts.audioIns[i], fVolume*(1.0f-fDryWet), frames); | FloatVectorOperations::multiply(fPorts.audioIns[i], fVolume*(1.0f-fDryWet), frames); | ||||
| FloatVectorOperations::multiply(fPorts.audioOuts[i], fVolume*fDryWet, frames); | FloatVectorOperations::multiply(fPorts.audioOuts[i], fVolume*fDryWet, frames); | ||||
| FLOAT_ADD(fPorts.audioOuts[i], fPorts.audioIns[i], frames); | |||||
| FloatVectorOperations::add(fPorts.audioOuts[i], fPorts.audioIns[i], frames); | |||||
| } | } | ||||
| } | } | ||||
| else if (fVolume != 1.0f) | else if (fVolume != 1.0f) | ||||
| @@ -22,25 +22,6 @@ | |||||
| #include <cmath> | #include <cmath> | ||||
| // 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 | |||||
| # 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 | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // math functions (base) | // math functions (base) | ||||
| @@ -115,6 +96,7 @@ uint32_t carla_nextPowerOf2(uint32_t size) noexcept | |||||
| return ++size; | return ++size; | ||||
| } | } | ||||
| #if 0 | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // math functions (extended) | // math functions (extended) | ||||
| @@ -156,6 +138,7 @@ void carla_zeroFloat(float* const data, const std::size_t numSamples) noexcept | |||||
| std::memset(data, 0, numSamples*sizeof(float)); | std::memset(data, 0, numSamples*sizeof(float)); | ||||
| } | } | ||||
| #endif | |||||
| #if defined(CARLA_OS_MAC) && ! defined(DISTRHO_OS_MAC) | #if defined(CARLA_OS_MAC) && ! defined(DISTRHO_OS_MAC) | ||||
| /* | /* | ||||