Browse Source

Continue Carla rework, fix build

tags/v0.9.0
falkTX 12 years ago
parent
commit
9ecbb1afd6
18 changed files with 483 additions and 340 deletions
  1. +1
    -1
      c++/caitlib/caitlib.c
  2. +11
    -0
      c++/carla-native/3bandeq-src.cpp
  3. +35
    -20
      c++/carla-native/3bandeq.cpp
  4. +0
    -2
      c++/carla-native/3bandeq/DistrhoPlugin3BandEQ.cpp
  5. +0
    -2
      c++/carla-native/3bandeq/DistrhoUI3BandEQ.cpp
  6. +3
    -1
      c++/carla-native/Makefile
  7. +6
    -2
      c++/carla-native/bypass.c
  8. +6
    -2
      c++/carla-native/carla_native.h
  9. +44
    -8
      c++/carla-native/carla_native.hpp
  10. +2
    -2
      c++/carla-native/carla_native.pro
  11. +143
    -18
      c++/carla-native/distrho/DistrhoPluginCarla.cpp
  12. +4
    -4
      c++/carla-plugin/carla_plugin.cpp
  13. +3
    -3
      c++/carla-plugin/carla_plugin.hpp
  14. +3
    -4
      c++/carla-plugin/carla_plugin_thread.cpp
  15. +3
    -0
      c++/carla-plugin/carla_plugin_thread.hpp
  16. +211
    -268
      c++/carla-plugin/native.cpp
  17. +3
    -1
      c++/carla-plugin/vst.cpp
  18. +5
    -2
      c++/distrho-plugin-toolkit/src/DistrhoDefines.h

+ 1
- 1
c++/caitlib/caitlib.c View File

@@ -468,7 +468,7 @@ MidiEvent* caitlib_get_event(CaitlibHandle handle)
// channel pressure
else if (rawEventPtr->dataSize == 2 && (rawEventPtr->data[0] & 0xF0) == MIDI_EVENT_TYPE_CHANNEL_PRESSURE)
{
midiEvent.typ = MIDI_EVENT_TYPE_CHANNEL_PRESSURE;
midiEvent.type = MIDI_EVENT_TYPE_CHANNEL_PRESSURE;
midiEvent.data.pressure.value = rawEventPtr->data[1];
}



+ 11
- 0
c++/carla-native/3bandeq-src.cpp View File

@@ -0,0 +1,11 @@

// Set plugin data
#include "3bandeq/DistrhoPluginInfo.h"

/// Set namespace for this plugin
#define DISTRHO_NAMESPACE DISTRHO_3BEQ

// Include Plugin code
#include "3bandeq/DistrhoArtwork3BandEQ.cpp"
#include "3bandeq/DistrhoPlugin3BandEQ.cpp"
#include "3bandeq/DistrhoUI3BandEQ.cpp"

+ 35
- 20
c++/carla-native/3bandeq.cpp View File

@@ -23,33 +23,45 @@
/// Set namespace for this plugin
#define DISTRHO_NAMESPACE DISTRHO_3BEQ

// Include Plugin code
#include "3bandeq/DistrhoPlugin3BandEQ.h"
#include "3bandeq/DistrhoUI3BandEQ.h"

// Include DISTRHO code
#include "DistrhoPluginCarla.cpp"

// Include Plugin code
#include "3bandeq/DistrhoArtwork3BandEQ.cpp"
#include "3bandeq/DistrhoPlugin3BandEQ.cpp"
#include "3bandeq/DistrhoUI3BandEQ.cpp"
START_NAMESPACE_DISTRHO

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

class CarlaDistrhoPlugin3BandEQ : public CarlaDistrhoPlugin
{
public:
CarlaDistrhoPlugin3BandEQ(const HostDescriptor* host)
: CarlaDistrhoPlugin(host)
{
}
//class CarlaDistrhoPlugin : public PluginDescriptorClass
//{
//public:
// CarlaDistrhoPlugin(const HostDescriptor* host)
// : PluginDescriptorClass(host)
// {
// }

~CarlaDistrhoPlugin3BandEQ()
{
}
// ~CarlaDistrhoPlugin()
// {
// }

// -------------------------------------------------------------------
//protected:
// // -------------------------------------------------------------------
// // Plugin process calls

private:
PluginDescriptorClassEND(CarlaDistrhoPlugin3BandEQ)
};
// // -------------------------------------------------------------------

//public:
// static PluginHandle _instantiate(struct _PluginDescriptor*, HostDescriptor* host)
// {
// return new CarlaDistrhoPlugin(host);
// }
// static void _cleanup(PluginHandle handle)
// {
// delete (CarlaDistrhoPlugin*)handle;
// }
//};

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

@@ -60,19 +72,22 @@ static PluginDescriptor tBandEqDesc = {
/* audioOuts */ DISTRHO_PLUGIN_NUM_OUTPUTS,
/* midiIns */ 0,
/* midiOuts */ 0,
/* paramIns */ DISTRHO_NAMESPACE::DistrhoPlugin3BandEQ::paramCount,
/* paramIns */ DistrhoPlugin3BandEQ::paramCount,
/* paramOuts */ 0,
/* name */ DISTRHO_PLUGIN_NAME,
/* label */ "3BandEQ",
/* maker */ "falkTX",
/* copyright */ "LGPL",
PluginDescriptorFILL(CarlaDistrhoPlugin3BandEQ)
PluginDescriptorFILL(CarlaDistrhoPlugin)
};

END_NAMESPACE_DISTRHO

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

void carla_register_native_plugin_3BandEQ()
{
USE_NAMESPACE_DISTRHO
carla_register_native_plugin(&tBandEqDesc);
}



+ 0
- 2
c++/carla-native/3bandeq/DistrhoPlugin3BandEQ.cpp View File

@@ -250,11 +250,9 @@ void DistrhoPlugin3BandEQ::d_run(const float** inputs, float** outputs, uint32_t
// -------------------------------------------------
#ifndef DISTRHO_NAMESPACE
Plugin* createPlugin()
{
return new DistrhoPlugin3BandEQ();
}
#endif
END_NAMESPACE_DISTRHO

+ 0
- 2
c++/carla-native/3bandeq/DistrhoUI3BandEQ.cpp View File

@@ -219,12 +219,10 @@ void DistrhoUI3BandEQ::imageSliderValueChanged(ImageSlider* slider, float value)

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

#ifndef DISTRHO_NAMESPACE
UI* createUI()
{
return new DistrhoUI3BandEQ;
}
#endif

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



+ 3
- 1
c++/carla-native/Makefile View File

@@ -29,9 +29,11 @@ OBJS = \

OBJS += \
3bandeq.o \
3bandsplitter.o \
3bandeq-src.o \
distrho/pugl.o

# 3bandsplitter.o

# --------------------------------------------------------------

ifeq ($(HAVE_ZYN_DEPS),true)


+ 6
- 2
c++/carla-native/bypass.c View File

@@ -73,8 +73,12 @@ static PluginDescriptor bypassDesc = {
.set_midi_program = NULL,
.set_custom_data = NULL,

.show_gui = NULL,
.idle_gui = NULL,
.ui_show = NULL,
.ui_idle = NULL,

.ui_set_parameter_value = NULL,
.ui_set_midi_program = NULL,
.ui_set_custom_data = NULL,

.activate = NULL,
.deactivate = NULL,


+ 6
- 2
c++/carla-native/carla_native.h View File

@@ -159,8 +159,12 @@ typedef struct _PluginDescriptor {
void (*set_midi_program)(PluginHandle handle, uint32_t bank, uint32_t program);
void (*set_custom_data)(PluginHandle handle, const char* key, const char* value);

void (*show_gui)(PluginHandle handle, bool show);
void (*idle_gui)(PluginHandle handle);
void (*ui_show)(PluginHandle handle, bool show);
void (*ui_idle)(PluginHandle handle);

void (*ui_set_parameter_value)(PluginHandle handle, uint32_t index, float value);
void (*ui_set_midi_program)(PluginHandle handle, uint32_t bank, uint32_t program);
void (*ui_set_custom_data)(PluginHandle handle, const char* key, const char* value);

void (*activate)(PluginHandle handle);
void (*deactivate)(PluginHandle handle);


+ 44
- 8
c++/carla-native/carla_native.hpp View File

@@ -147,15 +147,33 @@ protected:
// -------------------------------------------------------------------
// Plugin UI calls

virtual void showGui(bool show)
virtual void uiShow(bool show)
{
Q_UNUSED(show);
}

virtual void idleGui()
virtual void uiIdle()
{
}

virtual void uiSetParameterValue(uint32_t index, double value)
{
CARLA_ASSERT(index < getParameterCount());
Q_UNUSED(value);
}

virtual void uiSetMidiProgram(uint32_t bank, uint32_t program)
{
Q_UNUSED(bank);
Q_UNUSED(program);
}

virtual void uiSetCustomData(const char* key, const char* value)
{
CARLA_ASSERT(key);
CARLA_ASSERT(value);
}

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

@@ -223,14 +241,29 @@ public:
return ((PluginDescriptorClass*)handle)->setCustomData(key, value);
}

static void _show_gui(PluginHandle handle, bool show)
static void _ui_show(PluginHandle handle, bool show)
{
return ((PluginDescriptorClass*)handle)->uiShow(show);
}

static void _ui_idle(PluginHandle handle)
{
return ((PluginDescriptorClass*)handle)->uiIdle();
}

static void _ui_set_parameter_value(PluginHandle handle, uint32_t index, float value)
{
return ((PluginDescriptorClass*)handle)->uiSetParameterValue(index, value);
}

static void _ui_set_midi_program(PluginHandle handle, uint32_t bank, uint32_t program)
{
return ((PluginDescriptorClass*)handle)->showGui(show);
return ((PluginDescriptorClass*)handle)->uiSetMidiProgram(bank, program);
}

static void _idle_gui(PluginHandle handle)
static void _ui_set_custom_data(PluginHandle handle, const char* key, const char* value)
{
return ((PluginDescriptorClass*)handle)->idleGui();
return ((PluginDescriptorClass*)handle)->uiSetCustomData(key, value);
}

static void _activate(PluginHandle handle)
@@ -276,8 +309,11 @@ public:
CLASS::_set_parameter_value, \
CLASS::_set_midi_program, \
CLASS::_set_custom_data, \
CLASS::_show_gui, \
CLASS::_idle_gui, \
CLASS::_ui_show, \
CLASS::_ui_idle, \
CLASS::_ui_set_parameter_value, \
CLASS::_ui_set_midi_program, \
CLASS::_ui_set_custom_data, \
CLASS::_activate, \
CLASS::_deactivate, \
CLASS::_cleanup, \


+ 2
- 2
c++/carla-native/carla_native.pro View File

@@ -11,7 +11,7 @@ DEFINES += QTCREATOR_TEST

DEFINES += WANT_ZYNADDSUBFX WANT_ZYNADDSUBFX_GUI

PKGCONFIG = fftw3 mxml
PKGCONFIG = fftw3 mxml ntk

TARGET = carla_native
TEMPLATE = lib
@@ -25,6 +25,7 @@ SOURCES = \

SOURCES += \
3bandeq.cpp \
3bandeq-src.cpp \
3bandsplitter.cpp \
distrho/pugl.cpp

@@ -39,4 +40,3 @@ INCLUDEPATH = . distrho \

QMAKE_CFLAGS *= -std=c99
QMAKE_CXXFLAGS *= -std=c++0x
QMAKE_CXXFLAGS *= `ntk-config --cxxflags`

+ 143
- 18
c++/carla-native/distrho/DistrhoPluginCarla.cpp View File

@@ -15,28 +15,16 @@
* For a full copy of the license see the GPL.txt file
*/

#include "src/DistrhoDefines.h"
#include "carla_native.hpp"

#undef START_NAMESPACE_DISTRHO
//#undef END_NAMESPACE_DISTRHO
#undef USE_NAMESPACE_DISTRHO

#define START_NAMESPACE_DISTRHO namespace DISTRHO_NAMESPACE {
//#define END_NAMESPACE_DISTRHO }
#define USE_NAMESPACE_DISTRHO using namespace DISTRHO_NAMESPACE;
//#include "src/DistrhoDefines.h"

#include "DistrhoPluginMain.cpp"
#include "DistrhoUIMain.cpp"

//#include "src/DistrhoPluginInternal.h"

//#if DISTRHO_PLUGIN_HAS_UI
//# include "src/DistrhoUIInternal.h"
//#endif

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

// START_NAMESPACE_DISTRHO
START_NAMESPACE_DISTRHO

class CarlaDistrhoPlugin : public PluginDescriptorClass
{
@@ -44,6 +32,9 @@ public:
CarlaDistrhoPlugin(const HostDescriptor* host)
: PluginDescriptorClass(host)
{
d_lastBufferSize = getBufferSize();
d_lastSampleRate = getSampleRate();
setLastUiSampleRate(d_lastSampleRate);
}

~CarlaDistrhoPlugin()
@@ -51,23 +42,157 @@ public:
}

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

uint32_t getParameterCount()
{
return plugin.parameterCount();
}

const ::Parameter* getParameterInfo(uint32_t index)
{
static ::Parameter param;

param.hints = 0x0;
#if DISTRHO_PLUGIN_IS_SYNTH
param.hints |= PLUGIN_IS_SYNTH;
#endif
#if DISTRHO_PLUGIN_HAS_UI
param.hints |= PLUGIN_HAS_GUI;
# ifdef DISTRHO_UI_QT4
param.hints |= PLUGIN_USES_SINGLE_THREAD;
# endif
#endif

param.name = plugin.parameterName(index);
param.unit = plugin.parameterUnit(index);

{
const ParameterRanges* ranges(plugin.parameterRanges(index));
param.ranges.def = ranges->def;
param.ranges.min = ranges->min;
param.ranges.max = ranges->max;
param.ranges.step = ranges->step;
param.ranges.stepSmall = ranges->stepSmall;
param.ranges.stepLarge = ranges->stepLarge;
}

param.scalePointCount = 0;
param.scalePoints = nullptr;

return &param;
}

float getParameterValue(uint32_t index)
{
return plugin.parameterValue(index);
}

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

#if DISTRHO_PLUGIN_WANT_PROGRAMS
// TODO
virtual uint32_t getMidiProgramCount()
{
return 0;
}

virtual const MidiProgram* getMidiProgramInfo(uint32_t index)
{
return nullptr;
}
#endif

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

void setParameterValue(uint32_t index, double value)
{
plugin.setParameterValue(index, value);
}

#if DISTRHO_PLUGIN_WANT_PROGRAMS
// TODO
void setMidiProgram(uint32_t bank, uint32_t program)
{
Q_UNUSED(bank);
Q_UNUSED(program);
}
#endif

#if DISTRHO_PLUGIN_WANT_STATE
// TODO
void setCustomData(const char* key, const char* value)
{
CARLA_ASSERT(key);
CARLA_ASSERT(value);
}
#endif

// -------------------------------------------------------------------
// Plugin UI calls

void uiShow(bool show)
{
Q_UNUSED(show);
}

void uiIdle()
{
}

void uiSetParameterValue(uint32_t index, double value)
{
CARLA_ASSERT(index < getParameterCount());
Q_UNUSED(value);
}

#if DISTRHO_PLUGIN_WANT_PROGRAMS
// TODO
void uiSetMidiProgram(uint32_t bank, uint32_t program)
{
Q_UNUSED(bank);
Q_UNUSED(program);
}
#endif

#if DISTRHO_PLUGIN_WANT_STATE
// TODO
void uiSetCustomData(const char* key, const char* value)
{
CARLA_ASSERT(key);
CARLA_ASSERT(value);
}
#endif

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

void activate()
{
plugin.activate();
}

void deactivate()
{
plugin.deactivate();
}

void process(float**, float**, uint32_t, uint32_t, MidiEvent*)
void process(float**, float**, uint32_t, uint32_t, ::MidiEvent*)
{
//plugin->d_run();
}

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

private:
protected:
PluginInternal plugin;

PluginDescriptorClassEND(CarlaDistrhoPlugin)
};

// END_NAMESPACE_DISTRHO
END_NAMESPACE_DISTRHO

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

+ 4
- 4
c++/carla-plugin/carla_plugin.cpp View File

@@ -1100,16 +1100,16 @@ void CarlaPlugin::freeOscData()
osc.data.free();
}

bool CarlaPlugin::showOscGui()
bool CarlaPlugin::waitForOscGuiShow()
{
qWarning("CarlaPlugin::showOscGui()");
qWarning("CarlaPlugin::waitForOscGuiShow()");

// wait for UI 'update' call
for (uint i=0; i < x_engine->oscUiTimeout(); i++)
{
if (osc.data.target)
{
qWarning("CarlaPlugin::showOscGui() - got response, asking UI to show itself now");
qWarning("CarlaPlugin::waitForOscGuiShow() - got response, asking UI to show itself now");
osc_send_show(&osc.data);
return true;
}
@@ -1117,7 +1117,7 @@ bool CarlaPlugin::showOscGui()
carla_msleep(100);
}

qWarning("CarlaPlugin::showOscGui() - Timeout while waiting for UI to respond (waited %i msecs)", x_engine->oscUiTimeout());
qWarning("CarlaPlugin::waitForOscGuiShow() - Timeout while waiting for UI to respond (waited %i msecs)", x_engine->oscUiTimeout());
return false;
}
#endif


+ 3
- 3
c++/carla-plugin/carla_plugin.hpp View File

@@ -712,7 +712,7 @@ public:
* Show the plugin's OSC based GUI.\n
* This is a handy function that waits for the GUI to respond and automatically asks it to show itself.
*/
bool showOscGui();
bool waitForOscGuiShow();
#endif

// -------------------------------------------------------------------
@@ -843,9 +843,9 @@ public:
static CarlaPlugin* newGIG(const initializer& init);
static CarlaPlugin* newSF2(const initializer& init);
static CarlaPlugin* newSFZ(const initializer& init);
#ifndef BUILD_BRIDGE
//#ifndef BUILD_BRIDGE
static CarlaPlugin* newBridge(const initializer& init, const BinaryType btype, const PluginType ptype, const void* const extra);
#endif
//#endif

static size_t getNativePluginCount();
static const PluginDescriptor* getNativePluginDescriptor(const size_t index);


+ 3
- 4
c++/carla-plugin/carla_plugin_thread.cpp View File

@@ -73,8 +73,8 @@ void CarlaPluginThread::run()

m_process->setProcessChannelMode(QProcess::ForwardedChannels);

QString name(plugin->name() ? plugin->name() : "(none)");
QStringList arguments;
const char* name = plugin->name() ? plugin->name() : "(none)";

switch (mode)
{
@@ -115,7 +115,7 @@ void CarlaPluginThread::run()
case PLUGIN_THREAD_DSSI_GUI:
case PLUGIN_THREAD_LV2_GUI:
case PLUGIN_THREAD_VST_GUI:
if (plugin->showOscGui())
if (plugin->waitForOscGuiShow())
{
m_process->waitForFinished(-1);

@@ -150,8 +150,7 @@ void CarlaPluginThread::run()
QString errorString = QString("Plugin '%1' has crashed!\n"
"Saving now will lose its current settings.\n"
"Please remove this plugin, and not rely on it from this point.").arg(plugin->name());
//CarlaBackend::setLastError(errorString.toUtf8().constData());

engine->setLastError(errorString.toUtf8().constData());
engine->callback(CarlaBackend::CALLBACK_ERROR, plugin->id(), 0, 0, 0.0);
}



+ 3
- 0
c++/carla-plugin/carla_plugin_thread.hpp View File

@@ -26,6 +26,9 @@ class QProcess;

CARLA_BACKEND_START_NAMESPACE

class CarlaEngine;
class CarlaPlugin;

class CarlaPluginThread : public QThread
{
public:


+ 211
- 268
c++/carla-plugin/native.cpp View File

@@ -31,41 +31,6 @@ struct NativePluginMidiData {
ports(nullptr) {}
};

class NativePluginScopedInitiliazer
{
public:
NativePluginScopedInitiliazer()
{
firstInit = true;
}

~NativePluginScopedInitiliazer()
{
}

void maybeFirstInit()
{
if (! firstInit)
return;

firstInit = false;

carla_register_native_plugin_bypass();
carla_register_native_plugin_midiSplit();
#ifdef WANT_ZYNADDSUBFX
carla_register_native_plugin_zynaddsubfx();
#endif

carla_register_native_plugin_3BandEQ();
carla_register_native_plugin_3BandSplitter();
}

private:
bool firstInit;
};

static NativePluginScopedInitiliazer scopedInitliazer;

class NativePlugin : public CarlaPlugin
{
public:
@@ -123,7 +88,7 @@ public:
CARLA_ASSERT(descriptor);

if (descriptor)
return (PluginCategory)descriptor->category;
return static_cast<PluginCategory>(descriptor->category);

return getPluginCategoryFromName(m_name);
}
@@ -144,13 +109,12 @@ public:
uint32_t parameterScalePointCount(const uint32_t parameterId)
{
CARLA_ASSERT(descriptor);
CARLA_ASSERT(handle);
CARLA_ASSERT(parameterId < param.count);

int32_t rindex = param.data[parameterId].rindex;

if (descriptor && descriptor->get_parameter_count && rindex < (int32_t)descriptor->get_parameter_count(handle))
if (descriptor && handle && parameterId < param.count && descriptor->get_parameter_info)
{
const Parameter* const param = descriptor->get_parameter_info(handle, rindex);
const ::Parameter* const param = descriptor->get_parameter_info(handle, parameterId);

if (param)
return param->scalePointCount;
@@ -168,7 +132,7 @@ public:
CARLA_ASSERT(handle);
CARLA_ASSERT(parameterId < param.count);

if (descriptor && handle)
if (descriptor && handle && parameterId < param.count && descriptor->get_parameter_value)
return descriptor->get_parameter_value(handle, parameterId);

return 0.0;
@@ -177,25 +141,22 @@ public:
double getParameterScalePointValue(const uint32_t parameterId, const uint32_t scalePointId)
{
CARLA_ASSERT(descriptor);
CARLA_ASSERT(handle);
CARLA_ASSERT(parameterId < param.count);
CARLA_ASSERT(scalePointId < parameterScalePointCount(parameterId));

#if 0
const int32_t rindex = param.data[parameterId].rindex;

if (descriptor && rindex < (int32_t)descriptor->portCount)
if (descriptor && handle && parameterId < param.count && descriptor->get_parameter_info)
{
const PluginPort* const port = &descriptor->ports[rindex];
const ::Parameter* const param = descriptor->get_parameter_info(handle, parameterId);

if (port && scalePointId < port->scalePointCount)
if (param && scalePointId < param->scalePointCount && param->scalePoints)
{
const PluginPortScalePoint* const scalePoint = &port->scalePoints[scalePointId];
const ::ParameterScalePoint* const scalePoint = &param->scalePoints[scalePointId];

if (scalePoint)
return scalePoint->value;
}
}
#endif

return 0.0;
}
@@ -243,22 +204,19 @@ public:
void getParameterName(const uint32_t parameterId, char* const strBuf)
{
CARLA_ASSERT(descriptor);
CARLA_ASSERT(handle);
CARLA_ASSERT(parameterId < param.count);

#if 0
const int32_t rindex = param.data[parameterId].rindex;

if (descriptor && rindex < (int32_t)descriptor->portCount)
if (descriptor && handle && parameterId < param.count && descriptor->get_parameter_info)
{
const PluginPort* const port = &descriptor->ports[rindex];
const ::Parameter* const param = descriptor->get_parameter_info(handle, parameterId);

if (port && port->name)
if (param && param->name)
{
strncpy(strBuf, port->name, STR_MAX);
strncpy(strBuf, param->name, STR_MAX);
return;
}
}
#endif

CarlaPlugin::getParameterName(parameterId, strBuf);
}
@@ -269,11 +227,9 @@ public:
CARLA_ASSERT(handle);
CARLA_ASSERT(parameterId < param.count);

if (descriptor && handle)
if (descriptor && handle && parameterId < param.count && descriptor->get_parameter_text)
{
const int32_t rindex = param.data[parameterId].rindex;

const char* const text = descriptor->get_parameter_text(handle, rindex);
const char* const text = descriptor->get_parameter_text(handle, parameterId);

if (text)
{
@@ -291,20 +247,16 @@ public:
CARLA_ASSERT(handle);
CARLA_ASSERT(parameterId < param.count);

#if 0
if (descriptor && handle)
if (descriptor && handle && parameterId < param.count && descriptor->get_parameter_info)
{
const int32_t rindex = param.data[parameterId].rindex;

const char* const unit = descriptor->get_parameter_unit(handle, rindex);
const ::Parameter* const param = descriptor->get_parameter_info(handle, parameterId);

if (unit)
if (param && param->unit)
{
strncpy(strBuf, unit, STR_MAX);
strncpy(strBuf, param->unit, STR_MAX);
return;
}
}
#endif

CarlaPlugin::getParameterUnit(parameterId, strBuf);
}
@@ -312,19 +264,17 @@ public:
void getParameterScalePointLabel(const uint32_t parameterId, const uint32_t scalePointId, char* const strBuf)
{
CARLA_ASSERT(descriptor);
CARLA_ASSERT(handle);
CARLA_ASSERT(parameterId < param.count);
CARLA_ASSERT(scalePointId < parameterScalePointCount(parameterId));

#if 0
int32_t rindex = param.data[parameterId].rindex;

if (descriptor && rindex < (int32_t)descriptor->portCount)
if (descriptor && handle && parameterId < param.count && descriptor->get_parameter_info)
{
const PluginPort* const port = &descriptor->ports[rindex];
const ::Parameter* const param = descriptor->get_parameter_info(handle, parameterId);

if (port && scalePointId < port->scalePointCount)
if (param && scalePointId < param->scalePointCount && param->scalePoints)
{
const PluginPortScalePoint* const scalePoint = &port->scalePoints[scalePointId];
const ::ParameterScalePoint* const scalePoint = &param->scalePoints[scalePointId];

if (scalePoint && scalePoint->label)
{
@@ -333,7 +283,6 @@ public:
}
}
}
#endif

CarlaPlugin::getParameterScalePointLabel(parameterId, scalePointId, strBuf);
}
@@ -347,7 +296,7 @@ public:
CARLA_ASSERT(handle);
CARLA_ASSERT(parameterId < param.count);

if (descriptor)
if (descriptor && handle && parameterId < param.count)
{
fixParameterValue(value, param.ranges[parameterId]);

@@ -375,10 +324,17 @@ public:
if (! value)
return qCritical("Nativelugin::setCustomData(%s, \"%s\", \"%s\", %s) - value is null", CustomDataType2Str(type), key, value, bool2str(sendGui));

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

// FIXME - only if gui was started before
if (sendGui && descriptor->ui_set_custom_data)
descriptor->ui_set_custom_data(handle, key, value);
}

CarlaPlugin::setCustomData(type, key, value, sendGui);
@@ -420,18 +376,20 @@ public:
void showGui(const bool yesNo)
{
CARLA_ASSERT(descriptor);
CARLA_ASSERT(handle);

if (descriptor && handle)
descriptor->show_gui(handle, yesNo);
if (descriptor && handle && descriptor->ui_show)
descriptor->ui_show(handle, yesNo);
}

void idleGui()
{
// FIXME - this should not be called if there's no GUI!
CARLA_ASSERT(descriptor);
CARLA_ASSERT(handle);

if (descriptor && descriptor->idle_gui && handle)
descriptor->idle_gui(handle);
if (descriptor && handle && descriptor->ui_idle)
descriptor->ui_idle(handle);
}

// -------------------------------------------------------------------
@@ -454,39 +412,20 @@ public:
// Delete old data
deleteBuffers();

#if 0
uint32_t aIns, aOuts, mIns, mOuts, params, j;
aIns = aOuts = mIns = mOuts = params = 0;

const double sampleRate = x_engine->getSampleRate();
const uint32_t portCount = descriptor->portCount;
const double sampleRate = x_engine->getSampleRate();

aIns = descriptor->audioIns;
aOuts = descriptor->audioOuts;
mIns = descriptor->midiIns;
mOuts = descriptor->midiOuts;
params = descriptor->get_parameter_count ? descriptor->get_parameter_count(handle) : 0;

bool forcedStereoIn, forcedStereoOut;
forcedStereoIn = forcedStereoOut = false;

for (uint32_t i=0; i < portCount; i++)
{
const PortType portType = descriptor->ports[i].type;
const uint32_t portHints = descriptor->ports[i].hints;

if (portType == PORT_TYPE_AUDIO)
{
if (portHints & PORT_HINT_IS_OUTPUT)
aOuts += 1;
else
aIns += 1;
}
else if (portType == PORT_TYPE_MIDI)
{
if (portHints & PORT_HINT_IS_OUTPUT)
mOuts += 1;
else
mIns += 1;
}
else if (portType == PORT_TYPE_PARAMETER)
params += 1;
}

if (x_engine->forceStereo() && (aIns == 1 || aOuts == 1) && mIns <= 1 && mOuts <= 1 && ! h2)
{
h2 = descriptor->instantiate((struct _PluginDescriptor*)descriptor, &host);
@@ -539,171 +478,160 @@ public:
bool needsCtrlIn = false;
bool needsCtrlOut = false;

for (uint32_t i=0; i < portCount; i++)
// Audio Ins
for (j=0; j < aIns; j++)
{
const PortType portType = descriptor->ports[i].type;
const uint32_t portHints = descriptor->ports[i].hints;
if (x_engine->processMode() == PROCESS_MODE_SINGLE_CLIENT)
sprintf(portName, "%s:input_%02i", m_name, j+1);
else
sprintf(portName, "input_%02i", j+1);

if (portType == PORT_TYPE_AUDIO || portType == PORT_TYPE_MIDI)
{
if (x_engine->processMode() == PROCESS_MODE_SINGLE_CLIENT)
{
strcpy(portName, m_name);
strcat(portName, ":");
strncat(portName, descriptor->ports[i].name, portNameSize/2);
}
else
strncpy(portName, descriptor->ports[i].name, portNameSize);
}
aIn.ports[j] = (CarlaEngineAudioPort*)x_client->addPort(CarlaEnginePortTypeAudio, portName, true);
aIn.rindexes[j] = j;

if (portType == PORT_TYPE_AUDIO)
if (forcedStereoIn)
{
if (portHints & PORT_HINT_IS_OUTPUT)
{
j = aOut.count++;
aOut.ports[j] = (CarlaEngineAudioPort*)x_client->addPort(CarlaEnginePortTypeAudio, portName, false);
aOut.rindexes[j] = i;
needsCtrlIn = true;
strcat(portName, "_");
aIn.ports[1] = (CarlaEngineAudioPort*)x_client->addPort(CarlaEnginePortTypeAudio, portName, true);
aIn.rindexes[1] = j;
}
}

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;
// Audio Outs
for (j=0; j < aOuts; j++)
{
aOut.ports[j] = (CarlaEngineAudioPort*)x_client->addPort(CarlaEnginePortTypeAudio, portName, false);
aOut.rindexes[j] = j;
needsCtrlIn = true;

if (forcedStereoIn)
{
strcat(portName, "_");
aIn.ports[1] = (CarlaEngineAudioPort*)x_client->addPort(CarlaEnginePortTypeAudio, portName, true);
aIn.rindexes[1] = i;
}
}
}
else if (portType == PORT_TYPE_MIDI)
if (forcedStereoOut)
{
if (portHints & PORT_HINT_IS_OUTPUT)
{
j = mOut.count++;
mOut.ports[j] = (CarlaEngineMidiPort*)x_client->addPort(CarlaEnginePortTypeMIDI, portName, false);
mOut.rindexes[j] = i;
}
else
{
j = mIn.count++;
mIn.ports[j] = (CarlaEngineMidiPort*)x_client->addPort(CarlaEnginePortTypeMIDI, portName, true);
mIn.rindexes[j] = i;
}
strcat(portName, "_");
aOut.ports[1] = (CarlaEngineAudioPort*)x_client->addPort(CarlaEnginePortTypeAudio, portName, false);
aOut.rindexes[1] = j;
}
else if (portType == PORT_TYPE_PARAMETER)
{
j = param.count++;
param.data[j].index = j;
param.data[j].rindex = i;
param.data[j].hints = 0;
param.data[j].midiChannel = 0;
param.data[j].midiCC = -1;

double min, max, def, step, stepSmall, stepLarge;
}

::ParameterRanges ranges = { 0.0, 0.0, 1.0, 0.01, 0.0001, 0.1 };
descriptor->get_parameter_ranges(handle, i, &ranges);
// MIDI Input
for (j=0; j < mIns; j++)
{
mIn.ports[j] = (CarlaEngineMidiPort*)x_client->addPort(CarlaEnginePortTypeMIDI, portName, true);
mIn.rindexes[j] = j;
}

// min value
min = ranges.min;
// MIDI Output
for (j=0; j < mOuts; j++)
{
mOut.ports[j] = (CarlaEngineMidiPort*)x_client->addPort(CarlaEnginePortTypeMIDI, portName, false);
mOut.rindexes[j] = j;
}

// max value
max = ranges.max;
for (j=0; j < params; j++)
{
if (! descriptor->get_parameter_info)
break;

if (min > max)
max = min;
else if (max < min)
min = max;
const ::Parameter* const paramInfo = descriptor->get_parameter_info(handle, j);

if (max - min == 0.0)
{
qWarning("Broken plugin parameter: max - min == 0");
max = min + 0.1;
}
//const uint32_t paramHints = param->hints;
//const bool paramOutput = paramHins;

// default value
def = ranges.def;
param.data[j].index = j;
param.data[j].rindex = j;
param.data[j].hints = 0;
param.data[j].midiChannel = 0;
param.data[j].midiCC = -1;

if (def < min)
def = min;
else if (def > max)
def = max;
double min, max, def, step, stepSmall, stepLarge;

if (portHints & PORT_HINT_USES_SAMPLE_RATE)
{
min *= sampleRate;
max *= sampleRate;
def *= sampleRate;
param.data[j].hints |= PARAMETER_USES_SAMPLERATE;
}
// min value
min = paramInfo->ranges.min;

if (portHints & PORT_HINT_IS_BOOLEAN)
{
step = max - min;
stepSmall = step;
stepLarge = step;
param.data[j].hints |= PARAMETER_IS_BOOLEAN;
}
else if (portHints & PORT_HINT_IS_INTEGER)
{
step = 1.0;
stepSmall = 1.0;
stepLarge = 10.0;
param.data[j].hints |= PARAMETER_IS_INTEGER;
}
else
{
double range = max - min;
step = range/100.0;
stepSmall = range/1000.0;
stepLarge = range/10.0;
}
// max value
max = paramInfo->ranges.max;

if (portHints & PORT_HINT_IS_OUTPUT)
{
param.data[j].type = PARAMETER_OUTPUT;
needsCtrlOut = true;
}
else
{
param.data[j].type = PARAMETER_INPUT;
needsCtrlIn = true;
}
if (min > max)
max = min;
else if (max < min)
min = max;

// extra parameter hints
if (portHints & PORT_HINT_IS_ENABLED)
param.data[j].hints |= PARAMETER_IS_ENABLED;
if (max - min == 0.0)
{
qWarning("Broken plugin parameter: max - min == 0");
max = min + 0.1;
}

if (portHints & PORT_HINT_IS_AUTOMABLE)
param.data[j].hints |= PARAMETER_IS_AUTOMABLE;
// default value
def = paramInfo->ranges.def;

if (portHints & PORT_HINT_IS_LOGARITHMIC)
param.data[j].hints |= PARAMETER_IS_LOGARITHMIC;
if (def < min)
def = min;
else if (def > max)
def = max;

if (portHints & PORT_HINT_USES_SCALEPOINTS)
param.data[j].hints |= PARAMETER_USES_SCALEPOINTS;
if (paramInfo->hints & ::PARAMETER_USES_SAMPLE_RATE)
{
min *= sampleRate;
max *= sampleRate;
def *= sampleRate;
param.data[j].hints |= PARAMETER_USES_SAMPLERATE;
}

if (portHints & PORT_HINT_USES_CUSTOM_TEXT)
param.data[j].hints |= PARAMETER_USES_CUSTOM_TEXT;
if (paramInfo->hints & ::PARAMETER_IS_BOOLEAN)
{
step = max - min;
stepSmall = step;
stepLarge = step;
param.data[j].hints |= PARAMETER_IS_BOOLEAN;
}
else if (paramInfo->hints & ::PARAMETER_IS_INTEGER)
{
step = 1.0;
stepSmall = 1.0;
stepLarge = 10.0;
param.data[j].hints |= PARAMETER_IS_INTEGER;
}
else
{
double range = max - min;
step = range/100.0;
stepSmall = range/1000.0;
stepLarge = range/10.0;
}

param.ranges[j].min = min;
param.ranges[j].max = max;
param.ranges[j].def = def;
param.ranges[j].step = step;
param.ranges[j].stepSmall = stepSmall;
param.ranges[j].stepLarge = stepLarge;
if (paramInfo->hints & ::PARAMETER_IS_OUTPUT)
{
param.data[j].type = PARAMETER_OUTPUT;
needsCtrlOut = true;
}
else
{
param.data[j].type = PARAMETER_INPUT;
needsCtrlIn = true;
}

// extra parameter hints
if (paramInfo->hints & ::PARAMETER_IS_ENABLED)
param.data[j].hints |= PARAMETER_IS_ENABLED;

if (paramInfo->hints & ::PARAMETER_IS_AUTOMABLE)
param.data[j].hints |= PARAMETER_IS_AUTOMABLE;

if (paramInfo->hints & ::PARAMETER_IS_LOGARITHMIC)
param.data[j].hints |= PARAMETER_IS_LOGARITHMIC;

if (paramInfo->hints & ::PARAMETER_USES_SCALEPOINTS)
param.data[j].hints |= PARAMETER_USES_SCALEPOINTS;

if (paramInfo->hints & ::PARAMETER_USES_CUSTOM_TEXT)
param.data[j].hints |= PARAMETER_USES_CUSTOM_TEXT;

param.ranges[j].min = min;
param.ranges[j].max = max;
param.ranges[j].def = def;
param.ranges[j].step = step;
param.ranges[j].stepSmall = stepSmall;
param.ranges[j].stepLarge = stepLarge;
}

if (needsCtrlIn)
@@ -753,10 +681,15 @@ public:
if (aIns <= 2 && aOuts <= 2 && (aIns == aOuts || aIns == 0 || aOuts == 0) && mIns <= 1 && mOuts <= 1)
m_hints |= PLUGIN_CAN_FORCE_STEREO;

m_hints |= getPluginHintsFromNative(descriptor->hints);
// native plugin hints
if (descriptor->hints & ::PLUGIN_IS_SYNTH)
m_hints |= PLUGIN_IS_SYNTH;
if (descriptor->hints & ::PLUGIN_HAS_GUI)
m_hints |= PLUGIN_HAS_GUI;
if (descriptor->hints & ::PLUGIN_USES_SINGLE_THREAD)
m_hints |= PLUGIN_USES_SINGLE_THREAD;

reloadPrograms(true);
#endif

x_client->activate();

@@ -780,24 +713,16 @@ public:
delete[] midiprog.data;
}

midiprog.count = 0;
midiprog.count = (descriptor->get_midi_program_count && descriptor->get_midi_program_info) ? descriptor->get_midi_program_count(handle) : 0;
midiprog.data = nullptr;

#if 0
// Query new programs
if (descriptor->get_midi_program && descriptor->set_midi_program)
{
while (descriptor->get_midi_program(handle, midiprog.count))
midiprog.count += 1;
}

if (midiprog.count > 0)
midiprog.data = new MidiProgramData[midiprog.count];

// Update data
for (i=0; i < midiprog.count; i++)
{
const MidiProgram* const mpDesc = descriptor->get_midi_program(handle, i);
const ::MidiProgram* const mpDesc = descriptor->get_midi_program_info(handle, i);
CARLA_ASSERT(mpDesc);
CARLA_ASSERT(mpDesc->name);

@@ -857,7 +782,6 @@ public:
if (programChanged)
setMidiProgram(midiprog.current, true, true, true, true);
}
#endif
}

// -------------------------------------------------------------------
@@ -1559,11 +1483,11 @@ public:

static size_t getPluginCount()
{
scopedInitliazer.maybeFirstInit();
maybeFirstInit();
return pluginDescriptors.size();
}

static const PluginDescriptor* getPlugin(size_t index)
static const PluginDescriptor* getPlugin(const size_t index)
{
CARLA_ASSERT(index < pluginDescriptors.size());

@@ -1578,6 +1502,23 @@ public:
pluginDescriptors.push_back(desc);
}

static void maybeFirstInit()
{
if (! firstInit)
return;

firstInit = false;

carla_register_native_plugin_bypass();
carla_register_native_plugin_midiSplit();
#ifdef WANT_ZYNADDSUBFX
carla_register_native_plugin_zynaddsubfx();
#endif

carla_register_native_plugin_3BandEQ();
//carla_register_native_plugin_3BandSplitter();
}

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

bool init(const char* const name, const char* const label)
@@ -1585,7 +1526,7 @@ public:
// ---------------------------------------------------------------
// initialize native-plugins descriptors

scopedInitliazer.maybeFirstInit();
maybeFirstInit();

// ---------------------------------------------------------------
// get descriptor that matches label
@@ -1654,9 +1595,11 @@ private:
uint32_t midiEventCount;
::MidiEvent midiEvents[MAX_MIDI_EVENTS*2];

static bool firstInit;
static std::vector<const PluginDescriptor*> pluginDescriptors;
};

bool NativePlugin::firstInit = true;
std::vector<const PluginDescriptor*> NativePlugin::pluginDescriptors;

// -----------------------------------------------------------------------
@@ -1705,7 +1648,7 @@ size_t CarlaPlugin::getNativePluginCount()
return NativePlugin::getPluginCount();
}

const PluginDescriptor* CarlaPlugin::getNativePluginDescriptor(size_t index)
const PluginDescriptor* CarlaPlugin::getNativePluginDescriptor(const size_t index)
{
return NativePlugin::getPlugin(index);
}


+ 3
- 1
c++/carla-plugin/vst.cpp View File

@@ -520,6 +520,7 @@ public:
char portName[portNameSize];
bool needsCtrlIn = (aOuts > 0 || params > 0);

// Audio Ins
for (j=0; j < aIns; j++)
{
#ifndef BUILD_BRIDGE
@@ -533,6 +534,7 @@ public:
aIn.rindexes[j] = j;
}

// Audio Outs
for (j=0; j < aOuts; j++)
{
#ifndef BUILD_BRIDGE
@@ -546,7 +548,7 @@ public:
aOut.rindexes[j] = j;
}

for (j=0; j<params; j++)
for (j=0; j < params; j++)
{
param.data[j].type = PARAMETER_INPUT;
param.data[j].index = j;


+ 5
- 2
c++/distrho-plugin-toolkit/src/DistrhoDefines.h View File

@@ -73,9 +73,12 @@
#endif

#ifndef DISTRHO_NO_NAMESPACE
# define START_NAMESPACE_DISTRHO namespace DISTRHO {
# ifndef DISTRHO_NAMESPACE
# define DISTRHO_NAMESPACE DISTRHO
# endif
# define START_NAMESPACE_DISTRHO namespace DISTRHO_NAMESPACE {
# define END_NAMESPACE_DISTRHO }
# define USE_NAMESPACE_DISTRHO using namespace DISTRHO;
# define USE_NAMESPACE_DISTRHO using namespace DISTRHO_NAMESPACE;
#else
# define START_NAMESPACE_DISTRHO
# define END_NAMESPACE_DISTRHO


Loading…
Cancel
Save