diff --git a/source/bridges-plugin/CarlaBridgeSingleLV2.cpp b/source/bridges-plugin/CarlaBridgeSingleLV2.cpp index 4f087f5d3..90c0ce88b 100644 --- a/source/bridges-plugin/CarlaBridgeSingleLV2.cpp +++ b/source/bridges-plugin/CarlaBridgeSingleLV2.cpp @@ -125,6 +125,8 @@ public: fPorts.usesTime = true; fPorts.numAudioIns = fPlugin->getAudioInCount(); fPorts.numAudioOuts = fPlugin->getAudioOutCount(); + fPorts.numCVIns = fPlugin->getCVInCount(); + fPorts.numCVOuts = fPlugin->getCVOutCount(); fPorts.numMidiIns = fPlugin->getMidiInCount(); fPorts.numMidiOuts = fPlugin->getMidiOutCount(); fPorts.numParams = fPlugin->getParameterCount(); @@ -221,7 +223,11 @@ public: if (fPlugin->tryLock(fIsOffline)) { fPlugin->initBuffers(); - fPlugin->process(fPorts.audioIns, fPorts.audioOuts, nullptr, nullptr, frames); + fPlugin->process(fPorts.audioCVIns, + fPorts.audioCVOuts, + fPorts.audioCVIns + fPorts.numAudioIns, + fPorts.audioCVOuts + fPorts.numAudioOuts, + frames); fPlugin->unlock(); if (fPorts.numMidiOuts > 0) @@ -285,7 +291,9 @@ public: else { for (uint32_t i=0; ilabel, "carlapatchbay16" ) == 0 || std::strcmp(desc->label, "carlapatchbay32" ) == 0 || std::strcmp(desc->label, "carlapatchbay64" ) == 0 || + std::strcmp(desc->label, "carlapatchbaycv" ) == 0 || std::strcmp(desc->label, "bigmeter" ) == 0 /*std::strcmp(desc->label, "notes" ) == 0*/) { diff --git a/source/plugin/carla-lv2-export.cpp b/source/plugin/carla-lv2-export.cpp index 617e32d34..1d891bc88 100644 --- a/source/plugin/carla-lv2-export.cpp +++ b/source/plugin/carla-lv2-export.cpp @@ -542,6 +542,44 @@ static void writePluginFile(const NativePluginDescriptor* const pluginDesc) text += " ] , [\n"; } + // ------------------------------------------------------------------- + // CV inputs + + for (uint32_t i=0; i < pluginDesc->cvIns; ++i) + { + if (i == 0) + text += " lv2:port [\n"; + + text += " a lv2:InputPort, lv2:CVPort ;\n"; + text += " lv2:index " + String(portIndex++) + " ;\n"; + text += " lv2:symbol \"lv2_cv_in_" + String(i+1) + "\" ;\n"; + text += " lv2:name \"CV Input " + String(i+1) + "\" ;\n"; + + if (i+1 == pluginDesc->cvIns) + text += " ] ;\n\n"; + else + text += " ] , [\n"; + } + + // ------------------------------------------------------------------- + // CV outputs + + for (uint32_t i=0; i < pluginDesc->cvOuts; ++i) + { + if (i == 0) + text += " lv2:port [\n"; + + text += " a lv2:OutputPort, lv2:CVPort ;\n"; + text += " lv2:index " + String(portIndex++) + " ;\n"; + text += " lv2:symbol \"lv2_cv_out_" + String(i+1) + "\" ;\n"; + text += " lv2:name \"CV Output " + String(i+1) + "\" ;\n"; + + if (i+1 == pluginDesc->cvOuts) + text += " ] ;\n\n"; + else + text += " ] , [\n"; + } + // ------------------------------------------------------------------- // Parameters diff --git a/source/plugin/carla-lv2.cpp b/source/plugin/carla-lv2.cpp index 7d3e77d84..f1f15fc37 100644 --- a/source/plugin/carla-lv2.cpp +++ b/source/plugin/carla-lv2.cpp @@ -141,6 +141,8 @@ public: fPorts.usesTime = fDescriptor->hints & NATIVE_PLUGIN_USES_TIME; fPorts.numAudioIns = fDescriptor->audioIns; fPorts.numAudioOuts = fDescriptor->audioOuts; + fPorts.numCVIns = fDescriptor->cvIns; + fPorts.numCVOuts = fDescriptor->cvOuts; fPorts.numMidiIns = fDescriptor->midiIns; fPorts.numMidiOuts = fDescriptor->midiOuts; @@ -319,7 +321,7 @@ public: } } - fDescriptor->process(fHandle, fPorts.audioIns, fPorts.audioOuts, frames, fMidiEvents, fMidiEventCount); + fDescriptor->process(fHandle, fPorts.audioCVIns, fPorts.audioCVOuts, frames, fMidiEvents, fMidiEventCount); if (fWorkerUISignal == -1 && fPorts.hasUI) { diff --git a/source/utils/CarlaLv2Utils.hpp b/source/utils/CarlaLv2Utils.hpp index 2238b4fa7..75f3e3f7c 100644 --- a/source/utils/CarlaLv2Utils.hpp +++ b/source/utils/CarlaLv2Utils.hpp @@ -1236,6 +1236,8 @@ protected: uint32_t indexOffset; uint32_t numAudioIns; uint32_t numAudioOuts; + uint32_t numCVIns; + uint32_t numCVOuts; uint32_t numMidiIns; uint32_t numMidiOuts; uint32_t numParams; @@ -1246,8 +1248,8 @@ protected: const LV2_Atom_Sequence** eventsIn; /* */ LV2_Atom_Sequence** eventsOut; /* */ EventsOutData* eventsOutData; - const float** audioIns; - /* */ float** audioOuts; + const float** audioCVIns; + /* */ float** audioCVOuts; /* */ float* freewheel; // cached parameter values @@ -1259,6 +1261,8 @@ protected: : indexOffset(0), numAudioIns(0), numAudioOuts(0), + numCVIns(0), + numCVOuts(0), numMidiIns(0), numMidiOuts(0), numParams(0), @@ -1267,8 +1271,8 @@ protected: eventsIn(nullptr), eventsOut(nullptr), eventsOutData(nullptr), - audioIns(nullptr), - audioOuts(nullptr), + audioCVIns(nullptr), + audioCVOuts(nullptr), freewheel(nullptr), paramsLast(nullptr), paramsPtr(nullptr), @@ -1294,16 +1298,16 @@ protected: eventsOutData = nullptr; } - if (audioIns != nullptr) + if (audioCVIns != nullptr) { - delete[] audioIns; - audioIns = nullptr; + delete[] audioCVIns; + audioCVIns = nullptr; } - if (audioOuts != nullptr) + if (audioCVOuts != nullptr) { - delete[] audioOuts; - audioOuts = nullptr; + delete[] audioCVOuts; + audioCVOuts = nullptr; } if (paramsLast != nullptr) @@ -1355,20 +1359,16 @@ protected: eventsOut[0] = nullptr; } - if (numAudioIns > 0) + if (const uint32_t numAudioCVIns = numAudioIns+numCVIns) { - audioIns = new const float*[numAudioIns]; - - for (uint32_t i=0; i < numAudioIns; ++i) - audioIns[i] = nullptr; + audioCVIns = new const float*[numAudioCVIns]; + carla_zeroPointers(audioCVIns, numAudioCVIns); } - if (numAudioOuts > 0) + if (const uint32_t numAudioCVOuts = numAudioOuts+numCVOuts) { - audioOuts = new float*[numAudioOuts]; - - for (uint32_t i=0; i < numAudioOuts; ++i) - audioOuts[i] = nullptr; + audioCVOuts = new float*[numAudioCVOuts]; + carla_zeroPointers(audioCVOuts, numAudioCVOuts); } if (numParams > 0) @@ -1384,7 +1384,7 @@ protected: // NOTE: need to be filled in by the parent class } - indexOffset = numAudioIns + numAudioOuts; + indexOffset = numAudioIns + numAudioOuts + numCVIns + numCVOuts; // 1 event port for time or ui if no midi input is used indexOffset += numMidiIns > 0 ? numMidiIns : ((usesTime || hasUI) ? 1 : 0); // 1 event port for ui if no midi output is used @@ -1443,7 +1443,7 @@ protected: { if (port == index++) { - audioIns[i] = (float*)dataLocation; + audioCVIns[i] = (const float*)dataLocation; return; } } @@ -1452,7 +1452,25 @@ protected: { if (port == index++) { - audioOuts[i] = (float*)dataLocation; + audioCVOuts[i] = (float*)dataLocation; + return; + } + } + + for (uint32_t i=0; i < numCVIns; ++i) + { + if (port == index++) + { + audioCVIns[numAudioIns+i] = (const float*)dataLocation; + return; + } + } + + for (uint32_t i=0; i < numCVOuts; ++i) + { + if (port == index++) + { + audioCVOuts[numAudioOuts+i] = (float*)dataLocation; return; } }