Browse Source

Carla: Implement force-stereo for internal plugins, make bypass mono

tags/v0.9.0
falkTX 12 years ago
parent
commit
f2517fcfeb
2 changed files with 69 additions and 31 deletions
  1. +60
    -9
      c++/carla-backend/carla_native.cpp
  2. +9
    -22
      c++/carla-backend/plugins/bypass.c

+ 60
- 9
c++/carla-backend/carla_native.cpp View File

@@ -341,8 +341,13 @@ public:
Q_ASSERT(handle);
Q_ASSERT(parameterId < param.count);

if (descriptor && handle)
descriptor->set_parameter_value(handle, parameterId, fixParameterValue(value, param.ranges[parameterId]));
if (descriptor)
{
fixParameterValue(value, param.ranges[parameterId]);

descriptor->set_parameter_value(handle, parameterId, value);
if (h2) descriptor->set_parameter_value(h2, parameterId, value);
}

CarlaPlugin::setParameterValue(parameterId, value, sendGui, sendOsc, sendCallback);
}
@@ -364,8 +369,11 @@ public:
if (! value)
return qCritical("Nativelugin::setCustomData(%s, \"%s\", \"%s\", %s) - value is null", CustomDataType2str(type), key, value, bool2str(sendGui));

if (descriptor && handle)
if (descriptor)
{
descriptor->set_custom_data(handle, key, value);
if (h2) descriptor->set_custom_data(h2, key, value);
}

CarlaPlugin::setCustomData(type, key, value, sendGui);
}
@@ -387,11 +395,13 @@ public:
{
const CarlaEngine::ScopedLocker m(x_engine, block);
descriptor->set_midi_program(handle, midiprog.data[index].bank, midiprog.data[index].program);
if (h2) descriptor->set_midi_program(h2, midiprog.data[index].bank, midiprog.data[index].program);
}
else
{
const ScopedDisabler m(this, block);
descriptor->set_midi_program(handle, midiprog.data[index].bank, midiprog.data[index].program);
if (h2) descriptor->set_midi_program(h2, midiprog.data[index].bank, midiprog.data[index].program);
}
}

@@ -444,6 +454,9 @@ public:
const double sampleRate = x_engine->getSampleRate();
const uint32_t portCount = descriptor->portCount;

bool forcedStereoIn, forcedStereoOut;
forcedStereoIn = forcedStereoOut = false;

for (uint32_t i=0; i < portCount; i++)
{
const PortType portType = descriptor->ports[i].type;
@@ -467,6 +480,23 @@ public:
params += 1;
}

if (carlaOptions.forceStereo && (aIns == 1 || aOuts == 1) && mIns <= 1 && mOuts <= 1 && ! h2)
{
h2 = descriptor->instantiate((struct _PluginDescriptor*)descriptor, &host);

if (aIns == 1)
{
aIns = 2;
forcedStereoIn = true;
}

if (aOuts == 1)
{
aOuts = 2;
forcedStereoOut = true;
}
}

if (aIns > 0)
{
aIn.ports = new CarlaEngineAudioPort*[aIns];
@@ -527,12 +557,26 @@ public:
aOut.ports[j] = (CarlaEngineAudioPort*)x_client->addPort(CarlaEnginePortTypeAudio, portName, false);
aOut.rindexes[j] = i;
needsCtrlIn = true;

if (forcedStereoOut)
{
strcat(portName, "_");
aOut.ports[1] = (CarlaEngineAudioPort*)x_client->addPort(CarlaEnginePortTypeAudio, portName, false);
aOut.rindexes[1] = i;
}
}
else
{
j = aIn.count++;
aIn.ports[j] = (CarlaEngineAudioPort*)x_client->addPort(CarlaEnginePortTypeAudio, portName, true);
aIn.rindexes[j] = i;

if (forcedStereoIn)
{
strcat(portName, "_");
aIn.ports[1] = (CarlaEngineAudioPort*)x_client->addPort(CarlaEnginePortTypeAudio, portName, true);
aIn.rindexes[1] = i;
}
}
}
else if (portType == PORT_TYPE_MIDI)
@@ -993,13 +1037,13 @@ public:
if (descriptor->deactivate)
{
descriptor->deactivate(handle);
//if (h2) ldescriptor->deactivate(h2);
if (h2) descriptor->deactivate(h2);
}

if (descriptor->activate)
{
descriptor->activate(handle);
//if (h2) ldescriptor->activate(h2);
if (h2) descriptor->activate(h2);
}

allNotesOffSent = true;
@@ -1175,13 +1219,20 @@ public:
if (descriptor->activate)
{
descriptor->activate(handle);
//if (h2) descriptor->activate(h2);
if (h2) descriptor->activate(h2);
}
}

isProcessing = true;
descriptor->process(handle, inBuffer, outBuffer, frames, midiEventCountBefore, midiEvents);
//if (h2) descriptor->process(h2, inBuffer, outBuffer, frames, midiEventCount, midiEvents);

if (h2)
{
descriptor->process(handle, inBuffer? &inBuffer[0] : nullptr, outBuffer? &outBuffer[0] : nullptr, frames, midiEventCountBefore, midiEvents);
descriptor->process(h2, inBuffer? &inBuffer[1] : nullptr, outBuffer? &outBuffer[1] : nullptr, frames, midiEventCountBefore, midiEvents);
}
else
descriptor->process(handle, inBuffer, outBuffer, frames, midiEventCountBefore, midiEvents);

isProcessing = false;
}
else
@@ -1191,7 +1242,7 @@ public:
if (descriptor->deactivate)
{
descriptor->deactivate(handle);
//if (h2) descriptor->deactivate(h2);
if (h2) descriptor->deactivate(h2);
}
}
}


+ 9
- 22
c++/carla-backend/plugins/bypass.c View File

@@ -21,11 +21,9 @@
#include <string.h>

enum ByPassPorts {
PORT_IN1 = 0,
PORT_IN2 = 1,
PORT_OUT1 = 2,
PORT_OUT2 = 3,
PORT_MAX = 4
PORT_IN = 0,
PORT_OUT = 1,
PORT_MAX = 2
};

void bypass_init(struct _PluginDescriptor* _this_)
@@ -33,21 +31,13 @@ void bypass_init(struct _PluginDescriptor* _this_)
_this_->portCount = PORT_MAX;
_this_->ports = malloc(sizeof(PluginPort) * PORT_MAX);

_this_->ports[PORT_IN1].type = PORT_TYPE_AUDIO;
_this_->ports[PORT_IN1].hints = 0;
_this_->ports[PORT_IN1].name = "in1";
_this_->ports[PORT_IN].type = PORT_TYPE_AUDIO;
_this_->ports[PORT_IN].hints = 0;
_this_->ports[PORT_IN].name = "in";

_this_->ports[PORT_IN2].type = PORT_TYPE_AUDIO;
_this_->ports[PORT_IN2].hints = 0;
_this_->ports[PORT_IN2].name = "in2";

_this_->ports[PORT_OUT1].type = PORT_TYPE_AUDIO;
_this_->ports[PORT_OUT1].hints = PORT_HINT_IS_OUTPUT;
_this_->ports[PORT_OUT1].name = "out1";

_this_->ports[PORT_OUT2].type = PORT_TYPE_AUDIO;
_this_->ports[PORT_OUT2].hints = PORT_HINT_IS_OUTPUT;
_this_->ports[PORT_OUT2].name = "out2";
_this_->ports[PORT_OUT].type = PORT_TYPE_AUDIO;
_this_->ports[PORT_OUT].hints = PORT_HINT_IS_OUTPUT;
_this_->ports[PORT_OUT].name = "out";
}

void bypass_fini(struct _PluginDescriptor* _this_)
@@ -71,12 +61,9 @@ PluginHandle bypass_instantiate(struct _PluginDescriptor* _this_, HostDescriptor
void bypass_process(PluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, uint32_t midiEventCount, MidiEvent* midiEvents)
{
float* input1 = inBuffer[0];
float* input2 = inBuffer[1];
float* output1 = outBuffer[0];
float* output2 = outBuffer[1];

memcpy(output1, input1, sizeof(float)*frames);
memcpy(output2, input2, sizeof(float)*frames);

return;



Loading…
Cancel
Save