Browse Source

Zyn fx working, add PLUGIN_USES_STATIC_BUFFERS hint

tags/1.9.4
falkTX 11 years ago
parent
commit
9e63d233a1
4 changed files with 371 additions and 13 deletions
  1. +2
    -1
      source/backend/CarlaNative.h
  2. +364
    -7
      source/backend/native/zynaddsubfx.cpp
  3. +3
    -3
      source/backend/plugin/NativePlugin.cpp
  4. +2
    -2
      source/utils/RtList.hpp

+ 2
- 1
source/backend/CarlaNative.h View File

@@ -55,7 +55,8 @@ typedef enum _PluginHints {
PLUGIN_HAS_GUI = 1 << 2,
PLUGIN_USES_GUI_AS_FILE = 1 << 3,
PLUGIN_USES_SINGLE_THREAD = 1 << 4,
PLUGIN_USES_STATE = 1 << 5
PLUGIN_USES_STATE = 1 << 5,
PLUGIN_USES_STATIC_BUFFERS = 1 << 6
} PluginHints;

typedef enum _ParameterHints {


+ 364
- 7
source/backend/native/zynaddsubfx.cpp View File

@@ -29,6 +29,8 @@
#include "zynaddsubfx/Misc/Master.h"
#include "zynaddsubfx/Misc/Part.h"
#include "zynaddsubfx/Misc/Util.h"

#include "zynaddsubfx/Effects/Alienwah.h"
#include "zynaddsubfx/Effects/Reverb.h"

#ifdef WANT_ZYNADDSUBFX_UI
@@ -560,6 +562,215 @@ public:

// -----------------------------------------------------------------------

class FxAlienWahPlugin : public PluginDescriptorClass
{
public:
static const uint32_t kParamCount = 11;
static const uint32_t kProgramCount = 4;

FxAlienWahPlugin(const HostDescriptor* const host)
: PluginDescriptorClass(host),
efxoutl(new float[getBufferSize()]),
efxoutr(new float[getBufferSize()]),
fEffect(false, efxoutl, efxoutr)
{
}

~FxAlienWahPlugin()
{
if (efxoutl != nullptr)
{
delete[] efxoutl;
efxoutl = nullptr;
}

if (efxoutr != nullptr)
{
delete[] efxoutr;
efxoutr = nullptr;
}
}

protected:
// -------------------------------------------------------------------
// Plugin parameter calls

uint32_t getParameterCount() override
{
return kParamCount;
}

const Parameter* getParameterInfo(const uint32_t index) override
{
if (index >= kParamCount)
return nullptr;

static Parameter param;

int hints = PARAMETER_IS_ENABLED | PARAMETER_IS_INTEGER;

param.name = nullptr;
param.unit = nullptr;
param.ranges.def = 1.0f;
param.ranges.min = 0.0f;
param.ranges.max = 127.0f;
param.ranges.step = 1.0f;
param.ranges.stepSmall = 1.0f;
param.ranges.stepLarge = 20.0f;
param.scalePointCount = 0;
param.scalePoints = nullptr;

switch (index)
{
case 0:
hints |= PARAMETER_IS_AUTOMABLE;
param.name = "Volume";
param.ranges.def = 127.0f;
break;
case 1:
hints |= PARAMETER_IS_AUTOMABLE;
param.name = "Panning";
param.ranges.def = 64.0f;
break;
case 2:
hints |= PARAMETER_IS_AUTOMABLE;
param.name = "LFO Frequency";
param.ranges.def = 70.0f;
break;
case 3:
hints |= PARAMETER_IS_AUTOMABLE;
param.name = "LFO Randomness";
param.ranges.def = 0.0f;
break;
case 4:
hints |= PARAMETER_IS_AUTOMABLE;
param.name = "LFO Type";
param.ranges.def = 0.0f;
break;
case 5:
hints |= PARAMETER_IS_AUTOMABLE;
param.name = "LFO Stereo";
param.ranges.def = 62.0f;
break;
case 6:
hints |= PARAMETER_IS_AUTOMABLE;
param.name = "Depth";
param.ranges.def = 60.0f;
break;
case 7:
hints |= PARAMETER_IS_AUTOMABLE;
param.name = "Feedback";
param.ranges.def = 105.0f;
break;
case 8:
param.name = "Delay";
param.ranges.def = 25.0f;
break;
case 9:
hints |= PARAMETER_IS_AUTOMABLE;
param.name = "Cross";
param.ranges.def = 0.0f;
break;
case 10:
hints |= PARAMETER_IS_AUTOMABLE;
param.name = "Phase";
param.ranges.def = 64.0f;
break;
}

param.hints = static_cast<ParameterHints>(hints);

return &param;
}

float getParameterValue(const uint32_t index) override
{
return fEffect.getpar(index);
}

// -------------------------------------------------------------------
// Plugin midi-program calls

uint32_t getMidiProgramCount() override
{
return kProgramCount;
}

const MidiProgram* getMidiProgramInfo(const uint32_t index) override
{
if (index >= kProgramCount)
return nullptr;

static MidiProgram midiProg;

midiProg.bank = 0;
midiProg.program = index;
midiProg.name = nullptr;

switch (index)
{
case 0:
midiProg.name = "AlienWah1";
break;
case 1:
midiProg.name = "AlienWah2";
break;
case 2:
midiProg.name = "AlienWah3";
break;
case 3:
midiProg.name = "AlienWah4";
break;
}

return &midiProg;
}

// -------------------------------------------------------------------
// Plugin state calls

void setParameterValue(const uint32_t index, const float value) override
{
fEffect.changepar(index, value);
}

void setMidiProgram(const uint8_t, const uint32_t, const uint32_t program) override
{
fEffect.setpreset(program);
}

// -------------------------------------------------------------------
// Plugin process calls

void activate() override
{
fEffect.cleanup();
}

void process(float** const inBuffer, float** const outBuffer, const uint32_t frames, const uint32_t, const MidiEvent* const) override
{
CARLA_ASSERT(frames == synth->buffersize);

fEffect.out(Stereo<float*>(inBuffer[0], inBuffer[1]));

for (uint32_t i=0; i<frames; ++i)
{
outBuffer[0][i] = inBuffer[0][i]/2.0f + efxoutl[i]/2.0f;
outBuffer[1][i] = inBuffer[1][i]/2.0f + efxoutr[i]/2.0f;
}
}

private:
float* efxoutl;
float* efxoutr;
Alienwah fEffect;

ZynPluginDescriptorClassEND(FxAlienWahPlugin)
CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(FxAlienWahPlugin)
};

// -----------------------------------------------------------------------

class FxReverbPlugin : public PluginDescriptorClass
{
public:
@@ -568,10 +779,27 @@ public:

FxReverbPlugin(const HostDescriptor* const host)
: PluginDescriptorClass(host),
fEffect(false, nullptr, nullptr)
efxoutl(new float[getBufferSize()]),
efxoutr(new float[getBufferSize()]),
fEffect(false, efxoutl, efxoutr)
{
}

~FxReverbPlugin()
{
if (efxoutl != nullptr)
{
delete[] efxoutl;
efxoutl = nullptr;
}

if (efxoutr != nullptr)
{
delete[] efxoutr;
efxoutr = nullptr;
}
}

protected:
// -------------------------------------------------------------------
// Plugin parameter calls
@@ -761,14 +989,20 @@ protected:

void process(float** const inBuffer, float** const outBuffer, const uint32_t frames, const uint32_t, const MidiEvent* const) override
{
// beh, only testing for now anyway
*((float**)&fEffect.efxoutl) = outBuffer[0];
*((float**)&fEffect.efxoutr) = outBuffer[1];
CARLA_ASSERT(frames == synth->buffersize);

fEffect.out(Stereo<float*>(inBuffer[0], inBuffer[1]));

for (uint32_t i=0; i<frames; ++i)
{
outBuffer[0][i] = inBuffer[0][i]/2.0f + efxoutl[i]/2.0f;
outBuffer[1][i] = inBuffer[1][i]/2.0f + efxoutr[i]/2.0f;
}
}

private:
float* efxoutl;
float* efxoutr;
Reverb fEffect;

ZynPluginDescriptorClassEND(FxReverbPlugin)
@@ -1076,17 +1310,131 @@ private:

// -----------------------------------------------------------------------

static const PluginDescriptor fxAlienWahDesc = {
/* category */ PLUGIN_CATEGORY_MODULATOR,
/* hints */ static_cast<PluginHints>(PLUGIN_USES_STATIC_BUFFERS),
/* audioIns */ 2,
/* audioOuts */ 2,
/* midiIns */ 0,
/* midiOuts */ 0,
/* paramIns */ FxAlienWahPlugin::kParamCount,
/* paramOuts */ 0,
/* name */ "ZynAlienWah",
/* label */ "zynAlienWah",
/* maker */ "falkTX",
/* copyright */ "GNU GPL v2+",
PluginDescriptorFILL(FxAlienWahPlugin)
};

#if 0
static const PluginDescriptor fxChorusDesc = {
/* category */ PLUGIN_CATEGORY_MODULATOR,
/* hints */ static_cast<PluginHints>(PLUGIN_USES_STATIC_BUFFERS),
/* audioIns */ 2,
/* audioOuts */ 2,
/* midiIns */ 0,
/* midiOuts */ 0,
/* paramIns */ FxChorusPlugin::kParamCount,
/* paramOuts */ 0,
/* name */ "ZynChorus",
/* label */ "zynChorus",
/* maker */ "falkTX",
/* copyright */ "GNU GPL v2+",
PluginDescriptorFILL(FxChorusPlugin)
};

static const PluginDescriptor fxDistortionDesc = {
/* category */ PLUGIN_CATEGORY_MODULATOR,
/* hints */ static_cast<PluginHints>(PLUGIN_USES_STATIC_BUFFERS),
/* audioIns */ 2,
/* audioOuts */ 2,
/* midiIns */ 0,
/* midiOuts */ 0,
/* paramIns */ FxDistortionPlugin::kParamCount,
/* paramOuts */ 0,
/* name */ "ZynDistortion",
/* label */ "zynDistortion",
/* maker */ "falkTX",
/* copyright */ "GNU GPL v2+",
PluginDescriptorFILL(FxDistortionPlugin)
};

static const PluginDescriptor fxDynamicFilterDesc = {
/* category */ PLUGIN_CATEGORY_FILTER,
/* hints */ static_cast<PluginHints>(PLUGIN_USES_STATIC_BUFFERS),
/* audioIns */ 2,
/* audioOuts */ 2,
/* midiIns */ 0,
/* midiOuts */ 0,
/* paramIns */ FxDynamicFilterPlugin::kParamCount,
/* paramOuts */ 0,
/* name */ "ZynDynamicFilter",
/* label */ "zynDynamicFilter",
/* maker */ "falkTX",
/* copyright */ "GNU GPL v2+",
PluginDescriptorFILL(FxDynamicFilterPlugin)
};

static const PluginDescriptor fxEchoDesc = {
/* category */ PLUGIN_CATEGORY_DELAY,
/* hints */ static_cast<PluginHints>(PLUGIN_USES_STATIC_BUFFERS),
/* audioIns */ 2,
/* audioOuts */ 2,
/* midiIns */ 0,
/* midiOuts */ 0,
/* paramIns */ FxEchoPlugin::kParamCount,
/* paramOuts */ 0,
/* name */ "ZynEcho",
/* label */ "zynEcho",
/* maker */ "falkTX",
/* copyright */ "GNU GPL v2+",
PluginDescriptorFILL(FxEchoPlugin)
};

static const PluginDescriptor fxEqDesc = {
/* category */ PLUGIN_CATEGORY_EQ,
/* hints */ static_cast<PluginHints>(PLUGIN_USES_STATIC_BUFFERS),
/* audioIns */ 2,
/* audioOuts */ 2,
/* midiIns */ 0,
/* midiOuts */ 0,
/* paramIns */ FxEqPlugin::kParamCount,
/* paramOuts */ 0,
/* name */ "ZynEq",
/* label */ "zynEq",
/* maker */ "falkTX",
/* copyright */ "GNU GPL v2+",
PluginDescriptorFILL(FxEqPlugin)
};

static const PluginDescriptor fxPhaserDesc = {
/* category */ PLUGIN_CATEGORY_MODULATOR,
/* hints */ static_cast<PluginHints>(PLUGIN_USES_STATIC_BUFFERS),
/* audioIns */ 2,
/* audioOuts */ 2,
/* midiIns */ 0,
/* midiOuts */ 0,
/* paramIns */ FxPhaserPlugin::kParamCount,
/* paramOuts */ 0,
/* name */ "ZynPhaser",
/* label */ "zynPhaser",
/* maker */ "falkTX",
/* copyright */ "GNU GPL v2+",
PluginDescriptorFILL(FxPhaserPlugin)
};
#endif

static const PluginDescriptor fxReverbDesc = {
/* category */ PLUGIN_CATEGORY_DELAY,
/* hints */ static_cast<PluginHints>(/*PLUGIN_IS_RTSAFE*/ 0x0),
/* hints */ static_cast<PluginHints>(PLUGIN_USES_STATIC_BUFFERS),
/* audioIns */ 2,
/* audioOuts */ 2,
/* midiIns */ 0,
/* midiOuts */ 0,
/* paramIns */ 12-2,
/* paramIns */ FxReverbPlugin::kParamCount,
/* paramOuts */ 0,
/* name */ "ZynReverb",
/* label */ "zyn-reverb",
/* label */ "zynReverb",
/* maker */ "falkTX",
/* copyright */ "GNU GPL v2+",
PluginDescriptorFILL(FxReverbPlugin)
@@ -1116,6 +1464,15 @@ static const PluginDescriptor zynaddsubfxDesc = {

void carla_register_native_plugin_zynaddsubfx()
{
carla_register_native_plugin(&fxAlienWahDesc);
#if 0
carla_register_native_plugin(&fxChorusDesc);
carla_register_native_plugin(&fxDistortionDesc);
carla_register_native_plugin(&fxDynamicFilterDesc);
carla_register_native_plugin(&fxEchoDesc);
carla_register_native_plugin(&fxEqDesc);
carla_register_native_plugin(&fxPhaserDesc);
#endif
carla_register_native_plugin(&fxReverbDesc);
carla_register_native_plugin(&zynaddsubfxDesc);
}


+ 3
- 3
source/backend/plugin/NativePlugin.cpp View File

@@ -317,7 +317,7 @@ public:

options |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES;

if (midiInCount() == 0)
if (midiInCount() == 0 && (fDescriptor->hints & PLUGIN_USES_STATIC_BUFFERS) == 0)
options |= PLUGIN_OPTION_FIXED_BUFFER;

if (kData->engine->getProccessMode() != PROCESS_MODE_CONTINUOUS_RACK)
@@ -2317,7 +2317,7 @@ public:

fOptions |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES;

if (midiInCount() > 0)
if (midiInCount() > 0 || (fDescriptor->hints & PLUGIN_USES_STATIC_BUFFERS) != 0)
fOptions |= PLUGIN_OPTION_FIXED_BUFFER;

if (kData->engine->getOptions().forceStereo)
@@ -2337,7 +2337,7 @@ public:
fOptions = kData->loadSettings(fOptions, availableOptions());

// ignore settings, we need this anyway
if (midiInCount() > 0)
if (midiInCount() > 0 || (fDescriptor->hints & PLUGIN_USES_STATIC_BUFFERS) != 0)
fOptions |= PLUGIN_OPTION_FIXED_BUFFER;
}



+ 2
- 2
source/utils/RtList.hpp View File

@@ -484,14 +484,14 @@ public:
fMemPool.resize(minPreallocated, maxPreallocated);
}

void spliceAppend(RtList& list, const bool init = false)
void spliceAppend(RtList& list, const bool init = true)
{
CARLA_ASSERT(fMemPool == list.fMemPool);

List<T>::spliceAppend(list, init);
}

void spliceInsert(RtList& list, const bool init = false)
void spliceInsert(RtList& list, const bool init = true)
{
CARLA_ASSERT(fMemPool == list.fMemPool);



Loading…
Cancel
Save