Browse Source

Expose carlapatchbaycv as lv2 plugin

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.1-rc1
falkTX 6 years ago
parent
commit
3411c035da
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
5 changed files with 93 additions and 26 deletions
  1. +10
    -2
      source/bridges-plugin/CarlaBridgeSingleLV2.cpp
  2. +1
    -0
      source/plugin/carla-base.cpp
  3. +38
    -0
      source/plugin/carla-lv2-export.cpp
  4. +3
    -1
      source/plugin/carla-lv2.cpp
  5. +41
    -23
      source/utils/CarlaLv2Utils.hpp

+ 10
- 2
source/bridges-plugin/CarlaBridgeSingleLV2.cpp View File

@@ -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; i<fPorts.numAudioOuts; ++i)
carla_zeroFloats(fPorts.audioOuts[i], frames);
carla_zeroFloats(fPorts.audioCVOuts[i], frames);
for (uint32_t i=0; i<fPorts.numCVOuts; ++i)
carla_zeroFloats(fPorts.audioCVOuts[fPorts.numAudioOuts+i], frames);
}

lv2_post_run(frames);


+ 1
- 0
source/plugin/carla-base.cpp View File

@@ -64,6 +64,7 @@ struct PluginListManager {
std::strcmp(desc->label, "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*/)
{


+ 38
- 0
source/plugin/carla-lv2-export.cpp View File

@@ -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



+ 3
- 1
source/plugin/carla-lv2.cpp View File

@@ -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)
{


+ 41
- 23
source/utils/CarlaLv2Utils.hpp View File

@@ -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;
}
}


Loading…
Cancel
Save