Browse Source

Carla Native cleanup

tags/v0.9.0
falkTX 12 years ago
parent
commit
14a60f1683
19 changed files with 297 additions and 218 deletions
  1. +1
    -1
      c++/carla-native/3bandeq/DistrhoPlugin3BandEQ.cpp
  2. +1
    -1
      c++/carla-native/3bandeq/DistrhoPlugin3BandEQ.hpp
  3. +1
    -1
      c++/carla-native/3bandsplitter/DistrhoPlugin3BandSplitter.cpp
  4. +1
    -1
      c++/carla-native/3bandsplitter/DistrhoPlugin3BandSplitter.hpp
  5. +6
    -5
      c++/carla-native/Makefile
  6. +2
    -2
      c++/carla-native/bypass.c
  7. +1
    -1
      c++/carla-native/carla_native.doxygen
  8. +1
    -1
      c++/carla-native/carla_native.h
  9. +75
    -57
      c++/carla-native/carla_native.hpp
  10. +0
    -0
      c++/carla-native/distrho-pugl.cpp
  11. +127
    -52
      c++/carla-native/distrho/DistrhoPluginCarla.cpp
  12. +10
    -20
      c++/carla-native/midi-split.cpp
  13. +57
    -61
      c++/carla-native/zynaddsubfx.cpp
  14. +1
    -1
      c++/distrho-plugin-toolkit/DistrhoPlugin.h
  15. +1
    -1
      c++/distrho-plugin-toolkit/src/DistrhoPluginInternal.h
  16. +7
    -10
      c++/distrho-plugin-toolkit/src/DistrhoPluginLADSPA+DSSI.cpp
  17. +2
    -0
      c++/distrho-plugin-toolkit/src/DistrhoPluginVST.cpp
  18. +2
    -2
      c++/distrho-plugin-toolkit/src/DistrhoUIDSSI.cpp
  19. +1
    -1
      c++/distrho-plugin-toolkit/src/DistrhoUILV2.cpp

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

@@ -224,7 +224,7 @@ void DistrhoPlugin3BandEQ::d_deactivate()
tmp1LP = tmp2LP = tmp1HP = tmp2HP = 0.0f; tmp1LP = tmp2LP = tmp1HP = tmp2HP = 0.0f;
} }
void DistrhoPlugin3BandEQ::d_run(const float** inputs, float** outputs, uint32_t frames, uint32_t, const MidiEvent*)
void DistrhoPlugin3BandEQ::d_run(float** inputs, float** outputs, uint32_t frames, uint32_t, const MidiEvent*)
{ {
const float* in1 = inputs[0]; const float* in1 = inputs[0];
const float* in2 = inputs[1]; const float* in2 = inputs[1];


+ 1
- 1
c++/carla-native/3bandeq/DistrhoPlugin3BandEQ.hpp View File

@@ -80,7 +80,7 @@ protected:
// Process // Process
void d_activate(); void d_activate();
void d_deactivate(); void d_deactivate();
void d_run(const float** inputs, float** outputs, uint32_t frames, uint32_t midiEventCount, const MidiEvent* midiEvents);
void d_run(float** inputs, float** outputs, uint32_t frames, uint32_t midiEventCount, const MidiEvent* midiEvents);
// --------------------------------------------- // ---------------------------------------------


+ 1
- 1
c++/carla-native/3bandsplitter/DistrhoPlugin3BandSplitter.cpp View File

@@ -224,7 +224,7 @@ void DistrhoPlugin3BandSplitter::d_deactivate()
tmp1LP = tmp2LP = tmp1HP = tmp2HP = 0.0f; tmp1LP = tmp2LP = tmp1HP = tmp2HP = 0.0f;
} }
void DistrhoPlugin3BandSplitter::d_run(const float** inputs, float** outputs, uint32_t frames, uint32_t, const MidiEvent*)
void DistrhoPlugin3BandSplitter::d_run(float** inputs, float** outputs, uint32_t frames, uint32_t, const MidiEvent*)
{ {
const float* in1 = inputs[0]; const float* in1 = inputs[0];
const float* in2 = inputs[1]; const float* in2 = inputs[1];


+ 1
- 1
c++/carla-native/3bandsplitter/DistrhoPlugin3BandSplitter.hpp View File

@@ -80,7 +80,7 @@ protected:
// Process // Process
void d_activate(); void d_activate();
void d_deactivate(); void d_deactivate();
void d_run(const float** inputs, float** outputs, uint32_t frames, uint32_t midiEventCount, const MidiEvent* midiEvents);
void d_run(float** inputs, float** outputs, uint32_t frames, uint32_t midiEventCount, const MidiEvent* midiEvents);
// --------------------------------------------- // ---------------------------------------------


+ 6
- 5
c++/carla-native/Makefile View File

@@ -10,11 +10,12 @@ include ../Makefile.mk


BUILD_C_FLAGS += -fvisibility=hidden -fPIC -I. BUILD_C_FLAGS += -fvisibility=hidden -fPIC -I.
BUILD_CXX_FLAGS += -fvisibility=hidden -fPIC -I. -I../carla-includes -I../carla-utils BUILD_CXX_FLAGS += -fvisibility=hidden -fPIC -I. -I../carla-includes -I../carla-utils
BUILD_CXX_FLAGS += $(shell pkg-config --cflags QtCore)
BUILD_CXX_FLAGS += $(shell pkg-config --cflags QtCore QtGui)


ifeq ($(HAVE_ZYN_DEPS),true) ifeq ($(HAVE_ZYN_DEPS),true)
BUILD_CXX_FLAGS += -DWANT_ZYNADDSUBFX BUILD_CXX_FLAGS += -DWANT_ZYNADDSUBFX
ZYN_CXX_FLAGS = $(shell pkg-config --cflags fftw3 mxml)
ZYN_CXX_FLAGS = $(BUILD_CXX_FLAGS)
ZYN_CXX_FLAGS += $(shell pkg-config --cflags fftw3 mxml)
endif endif


# Simple plugins # Simple plugins
@@ -51,14 +52,14 @@ distrho-3bandeq.o: distrho-3bandeq.cpp
distrho-3bandsplitter.o: distrho-3bandsplitter.cpp distrho-3bandsplitter.o: distrho-3bandsplitter.cpp
$(CXX) -c $< $(BUILD_CXX_FLAGS) -I../distrho-plugin-toolkit -I3bandsplitter -DDISTRHO_NAMESPACE=DISTRHO_3BandSplitter -o $@ $(CXX) -c $< $(BUILD_CXX_FLAGS) -I../distrho-plugin-toolkit -I3bandsplitter -DDISTRHO_NAMESPACE=DISTRHO_3BandSplitter -o $@


distrho-pugl.o: distrho/pugl.cpp
distrho-pugl.o: distrho-pugl.cpp
$(CXX) -c $< $(BUILD_CXX_FLAGS) -I../distrho-plugin-toolkit -o $@ $(CXX) -c $< $(BUILD_CXX_FLAGS) -I../distrho-plugin-toolkit -o $@


zynaddsubfx.o: zynaddsubfx.cpp zynaddsubfx.o: zynaddsubfx.cpp
$(CXX) -c $< $(BUILD_CXX_FLAGS) $(ZYN_CXX_FLAGS) -o $@
$(CXX) -c $< $(ZYN_CXX_FLAGS) -o $@


zynaddsubfx-src.o: zynaddsubfx-src.cpp zynaddsubfx-src.o: zynaddsubfx-src.cpp
$(CXX) -c $< $(BUILD_CXX_FLAGS) $(ZYN_CXX_FLAGS) -o $@
$(CXX) -c $< $(ZYN_CXX_FLAGS) -o $@


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




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

@@ -29,7 +29,7 @@ static PluginHandle bypass_instantiate(const PluginDescriptor* _this_, HostDescr
(void)host; (void)host;
} }


static void bypass_process(PluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, uint32_t midiEventCount, MidiEvent* midiEvents)
static void bypass_process(PluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, uint32_t midiEventCount, const MidiEvent* midiEvents)
{ {
float* in = inBuffer[0]; float* in = inBuffer[0];
float* out = outBuffer[0]; float* out = outBuffer[0];
@@ -45,7 +45,7 @@ static void bypass_process(PluginHandle handle, float** inBuffer, float** outBuf


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


static PluginDescriptor bypassDesc = {
static const PluginDescriptor bypassDesc = {
.category = PLUGIN_CATEGORY_NONE, .category = PLUGIN_CATEGORY_NONE,
.hints = 0x0, .hints = 0x0,
.audioIns = 1, .audioIns = 1,


+ 1
- 1
c++/carla-native/carla_native.doxygen View File

@@ -99,7 +99,7 @@ INPUT =
INPUT_ENCODING = UTF-8 INPUT_ENCODING = UTF-8
FILE_PATTERNS = FILE_PATTERNS =
RECURSIVE = NO RECURSIVE = NO
EXCLUDE = bypass.c midi-split.cpp zynaddsubfx.cpp zynaddsubfx-src.cpp
EXCLUDE = bypass.c midi-split.cpp distrho-3bandeq.cpp distrho-3bandsplitter.cpp distrho-pugl.cpp zynaddsubfx.cpp zynaddsubfx-src.cpp
EXCLUDE_SYMLINKS = NO EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS = EXCLUDE_PATTERNS =
EXCLUDE_SYMBOLS = EXCLUDE_SYMBOLS =


+ 1
- 1
c++/carla-native/carla_native.h View File

@@ -175,7 +175,7 @@ typedef struct _PluginDescriptor {
void (*activate)(PluginHandle handle); void (*activate)(PluginHandle handle);
void (*deactivate)(PluginHandle handle); void (*deactivate)(PluginHandle handle);
void (*cleanup)(PluginHandle handle); void (*cleanup)(PluginHandle handle);
void (*process)(PluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, uint32_t midiEventCount, MidiEvent* midiEvents);
void (*process)(PluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, uint32_t midiEventCount, const MidiEvent* midiEvents);


} PluginDescriptor; } PluginDescriptor;




+ 75
- 57
c++/carla-native/carla_native.hpp View File

@@ -26,11 +26,12 @@
* @{ * @{
*/ */


class PluginDescriptorClass {
class PluginDescriptorClass
{
public: public:
PluginDescriptorClass(const HostDescriptor* host)
PluginDescriptorClass(const HostDescriptor* const host)
: m_host(host)
{ {
this->host = host;
} }


virtual ~PluginDescriptorClass() virtual ~PluginDescriptorClass()
@@ -40,64 +41,79 @@ public:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Host calls // Host calls


const HostDescriptor* getHostHandle() const
{
return m_host;
}

uint32_t getBufferSize() const uint32_t getBufferSize() const
{ {
CARLA_ASSERT(host);
CARLA_ASSERT(m_host);


if (host)
return host->get_buffer_size(host->handle);
if (m_host)
return m_host->get_buffer_size(m_host->handle);


return 0; return 0;
} }


double getSampleRate() const double getSampleRate() const
{ {
CARLA_ASSERT(host);
CARLA_ASSERT(m_host);


if (host)
return host->get_sample_rate(host->handle);
if (m_host)
return m_host->get_sample_rate(m_host->handle);


return 0.0; return 0.0;
} }


const TimeInfo* getTimeInfo() const const TimeInfo* getTimeInfo() const
{ {
CARLA_ASSERT(host);
CARLA_ASSERT(m_host);


if (host)
return host->get_time_info(host->handle);
if (m_host)
return m_host->get_time_info(m_host->handle);


return nullptr; return nullptr;
} }


void writeMidiEvent(MidiEvent* event)
void writeMidiEvent(MidiEvent* const event)
{ {
CARLA_ASSERT(host);
CARLA_ASSERT(m_host);


if (host)
host->write_midi_event(host->handle, event);
if (m_host)
m_host->write_midi_event(m_host->handle, event);
} }


void uiParameterChanged(uint32_t index, float value)
void uiParameterChanged(const uint32_t index, const float value)
{ {
CARLA_ASSERT(host);
CARLA_ASSERT(m_host);


if (host)
host->ui_parameter_changed(host->handle, index, value);
if (m_host)
m_host->ui_parameter_changed(m_host->handle, index, value);
} }


void uiCustomDataChanged(const char* key, const char* value)
void uiMidiProgramChanged(const uint32_t bank, const uint32_t program)
{ {
CARLA_ASSERT(host);
CARLA_ASSERT(m_host);


if (host)
host->ui_custom_data_changed(host->handle, key, value);
if (m_host)
m_host->ui_midi_program_changed(m_host->handle, bank, program);
}

void uiCustomDataChanged(const char* const key, const char* const value)
{
CARLA_ASSERT(m_host);

if (m_host)
m_host->ui_custom_data_changed(m_host->handle, key, value);
} }


void uiClosed() void uiClosed()
{ {
if (host)
host->ui_closed(host->handle);
CARLA_ASSERT(m_host);

if (m_host)
m_host->ui_closed(m_host->handle);
} }


protected: protected:
@@ -109,21 +125,21 @@ protected:
return 0; return 0;
} }


virtual const Parameter* getParameterInfo(uint32_t index)
virtual const Parameter* getParameterInfo(const uint32_t index)
{ {
CARLA_ASSERT(index < getParameterCount()); CARLA_ASSERT(index < getParameterCount());


return nullptr; return nullptr;
} }


virtual float getParameterValue(uint32_t index)
virtual float getParameterValue(const uint32_t index)
{ {
CARLA_ASSERT(index < getParameterCount()); CARLA_ASSERT(index < getParameterCount());


return 0.0f; return 0.0f;
} }


virtual const char* getParameterText(uint32_t index)
virtual const char* getParameterText(const uint32_t index)
{ {
CARLA_ASSERT(index < getParameterCount()); CARLA_ASSERT(index < getParameterCount());


@@ -138,7 +154,7 @@ protected:
return 0; return 0;
} }


virtual const MidiProgram* getMidiProgramInfo(uint32_t index)
virtual const MidiProgram* getMidiProgramInfo(const uint32_t index)
{ {
CARLA_ASSERT(index < getMidiProgramCount()); CARLA_ASSERT(index < getMidiProgramCount());


@@ -148,19 +164,19 @@ protected:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Plugin state calls // Plugin state calls


virtual void setParameterValue(uint32_t index, float value)
virtual void setParameterValue(const uint32_t index, const float value)
{ {
CARLA_ASSERT(index < getParameterCount()); CARLA_ASSERT(index < getParameterCount());
Q_UNUSED(value); Q_UNUSED(value);
} }


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


virtual void setCustomData(const char* key, const char* value)
virtual void setCustomData(const char* const key, const char* const value)
{ {
CARLA_ASSERT(key); CARLA_ASSERT(key);
CARLA_ASSERT(value); CARLA_ASSERT(value);
@@ -169,7 +185,7 @@ protected:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Plugin UI calls // Plugin UI calls


virtual void uiShow(bool show)
virtual void uiShow(const bool show)
{ {
Q_UNUSED(show); Q_UNUSED(show);
} }
@@ -178,19 +194,19 @@ protected:
{ {
} }


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


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


virtual void uiSetCustomData(const char* key, const char* value)
virtual void uiSetCustomData(const char* const key, const char* const value)
{ {
CARLA_ASSERT(key); CARLA_ASSERT(key);
CARLA_ASSERT(value); CARLA_ASSERT(value);
@@ -207,100 +223,102 @@ protected:
{ {
} }


virtual void process(float** inBuffer, float** outBuffer, const uint32_t frames, uint32_t midiEventCount, MidiEvent* midiEvents) = 0;
virtual void process(float** const inBuffer, float** const outBuffer, const uint32_t frames, const uint32_t midiEventCount, const MidiEvent* const midiEvents) = 0;


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


private: private:
const HostDescriptor* host;
const HostDescriptor* const m_host;


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


#ifndef DOXYGEN #ifndef DOXYGEN
public: public:
#define handlePtr ((PluginDescriptorClass*)handle)

static uint32_t _get_parameter_count(PluginHandle handle) static uint32_t _get_parameter_count(PluginHandle handle)
{ {
return ((PluginDescriptorClass*)handle)->getParameterCount();
return handlePtr->getParameterCount();
} }


static const Parameter* _get_parameter_info(PluginHandle handle, uint32_t index) static const Parameter* _get_parameter_info(PluginHandle handle, uint32_t index)
{ {
return ((PluginDescriptorClass*)handle)->getParameterInfo(index);
return handlePtr->getParameterInfo(index);
} }


static float _get_parameter_value(PluginHandle handle, uint32_t index) static float _get_parameter_value(PluginHandle handle, uint32_t index)
{ {
return ((PluginDescriptorClass*)handle)->getParameterValue(index);
return handlePtr->getParameterValue(index);
} }


static const char* _get_parameter_text(PluginHandle handle, uint32_t index) static const char* _get_parameter_text(PluginHandle handle, uint32_t index)
{ {
return ((PluginDescriptorClass*)handle)->getParameterText(index);
return handlePtr->getParameterText(index);
} }


static uint32_t _get_midi_program_count(PluginHandle handle) static uint32_t _get_midi_program_count(PluginHandle handle)
{ {
return ((PluginDescriptorClass*)handle)->getMidiProgramCount();
return handlePtr->getMidiProgramCount();
} }


static const MidiProgram* _get_midi_program_info(PluginHandle handle, uint32_t index) static const MidiProgram* _get_midi_program_info(PluginHandle handle, uint32_t index)
{ {
return ((PluginDescriptorClass*)handle)->getMidiProgramInfo(index);
return handlePtr->getMidiProgramInfo(index);
} }


static void _set_parameter_value(PluginHandle handle, uint32_t index, float value) static void _set_parameter_value(PluginHandle handle, uint32_t index, float value)
{ {
return ((PluginDescriptorClass*)handle)->setParameterValue(index, value);
return handlePtr->setParameterValue(index, value);
} }


static void _set_midi_program(PluginHandle handle, uint32_t bank, uint32_t program) static void _set_midi_program(PluginHandle handle, uint32_t bank, uint32_t program)
{ {
return ((PluginDescriptorClass*)handle)->setMidiProgram(bank, program);
return handlePtr->setMidiProgram(bank, program);
} }


static void _set_custom_data(PluginHandle handle, const char* key, const char* value) static void _set_custom_data(PluginHandle handle, const char* key, const char* value)
{ {
return ((PluginDescriptorClass*)handle)->setCustomData(key, value);
return handlePtr->setCustomData(key, value);
} }


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


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


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


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


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


static void _activate(PluginHandle handle) static void _activate(PluginHandle handle)
{ {
((PluginDescriptorClass*)handle)->activate();
handlePtr->activate();
} }


static void _deactivate(PluginHandle handle) static void _deactivate(PluginHandle handle)
{ {
((PluginDescriptorClass*)handle)->deactivate();
handlePtr->deactivate();
} }


static void _process(PluginHandle handle, float** inBuffer, float** outBuffer, const uint32_t frames, uint32_t midiEventCount, MidiEvent* midiEvents)
static void _process(PluginHandle handle, float** inBuffer, float** outBuffer, const uint32_t frames, uint32_t midiEventCount, const MidiEvent* midiEvents)
{ {
return ((PluginDescriptorClass*)handle)->process(inBuffer, outBuffer, frames, midiEventCount, midiEvents);
return handlePtr->process(inBuffer, outBuffer, frames, midiEventCount, midiEvents);
} }
#endif #endif
}; };


c++/carla-native/distrho/pugl.cpp → c++/carla-native/distrho-pugl.cpp View File


+ 127
- 52
c++/carla-native/distrho/DistrhoPluginCarla.cpp View File

@@ -17,73 +17,115 @@


#include "carla_native.hpp" #include "carla_native.hpp"


#include <QtGui/QDialog>

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

#if DISTRHO_PLUGIN_HAS_UI
# include "DistrhoUIMain.cpp"
#endif


#ifdef QTCREATOR_TEST #ifdef QTCREATOR_TEST
# define DISTRHO_PLUGIN_HAS_UI 1 # define DISTRHO_PLUGIN_HAS_UI 1
//# define DISTRHO_PLUGIN_IS_SYNTH 1
# define DISTRHO_PLUGIN_IS_SYNTH 1
# define DISTRHO_PLUGIN_WANT_PROGRAMS 1 # define DISTRHO_PLUGIN_WANT_PROGRAMS 1
//# define DISTRHO_PLUGIN_WANT_STATE 1
# define DISTRHO_PLUGIN_WANT_STATE 1
#endif #endif


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


START_NAMESPACE_DISTRHO
START_NAMESPACE_DISTRHO


#if DISTRHO_PLUGIN_HAS_UI #if DISTRHO_PLUGIN_HAS_UI
class UICarla
// -----------------------------------------------------------------------
// Carla UI

class UICarla : public QDialog
{ {
public: public:
UICarla(const HostDescriptor* const host, PluginInternal* plugin, intptr_t winId)
: m_host(host),
UICarla(const HostDescriptor* const host, PluginInternal* const plugin)
: QDialog(nullptr),
m_host(host),
m_plugin(plugin), m_plugin(plugin),
ui(this, winId, setParameterCallback, setStateCallback, uiEditParameterCallback, uiSendNoteCallback, uiResizeCallback)
ui(this, winId(), setParameterCallback, setStateCallback, uiEditParameterCallback, uiSendNoteCallback, uiResizeCallback)
{ {
setFixedSize(ui.getWidth(), ui.getHeight());
setWindowTitle("TEST GUI");
} }


~UICarla() ~UICarla()
{ {
} }


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

void carla_show(const bool yesNo)
{
setVisible(yesNo);
}

void carla_idle()
{
ui.idle();
}

void carla_setParameterValue(const uint32_t index, const float value)
{
ui.parameterChanged(index, value);
}

# if DISTRHO_PLUGIN_WANT_PROGRAMS
void carla_setMidiProgram(const uint32_t realProgram)
{
ui.programChanged(realProgram);
}
# endif

# if DISTRHO_PLUGIN_WANT_STATE
void carla_setCustomData(const char* const key, const char* const value)
{
ui.stateChanged(key, value);
}
# endif

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

protected: protected:
void setParameterValue(uint32_t index, float value) void setParameterValue(uint32_t index, float value)
{ {
m_host->ui_parameter_changed(m_host->handle, index, value); m_host->ui_parameter_changed(m_host->handle, index, value);
} }


#if DISTRHO_PLUGIN_WANT_STATE
# if DISTRHO_PLUGIN_WANT_STATE
void setState(const char* key, const char* value) void setState(const char* key, const char* value)
{ {
m_host->ui_custom_data_changed(m_host->handle, key, value); m_host->ui_custom_data_changed(m_host->handle, key, value);
} }
#endif
# endif


void uiEditParameter(uint32_t, bool) void uiEditParameter(uint32_t, bool)
{ {
// TODO // TODO
} }


#if DISTRHO_PLUGIN_IS_SYNTH
# if DISTRHO_PLUGIN_IS_SYNTH
void uiSendNote(bool, uint8_t, uint8_t, uint8_t) void uiSendNote(bool, uint8_t, uint8_t, uint8_t)
{ {
// TODO // TODO
} }
#endif
# endif


void uiResize(unsigned int width, unsigned int height) void uiResize(unsigned int width, unsigned int height)
{ {
//hostCallback(audioMasterSizeWindow, width, height, nullptr, 0.0f);
Q_UNUSED(width);
Q_UNUSED(height);
setFixedSize(width, height);
} }


private: private:
// Carla stuff
// Plugin stuff
const HostDescriptor* const m_host; const HostDescriptor* const m_host;
PluginInternal* const m_plugin; PluginInternal* const m_plugin;


// Plugin UI
// UI
UIInternal ui; UIInternal ui;


// --------------------------------------------- // ---------------------------------------------
@@ -99,16 +141,16 @@ private:


static void setStateCallback(void* ptr, const char* key, const char* value) static void setStateCallback(void* ptr, const char* key, const char* value)
{ {
#if DISTRHO_PLUGIN_WANT_STATE
# if DISTRHO_PLUGIN_WANT_STATE
UICarla* _this_ = (UICarla*)ptr; UICarla* _this_ = (UICarla*)ptr;
CARLA_ASSERT(_this_); CARLA_ASSERT(_this_);


_this_->setState(key, value); _this_->setState(key, value);
#else
# else
Q_UNUSED(ptr); Q_UNUSED(ptr);
Q_UNUSED(key); Q_UNUSED(key);
Q_UNUSED(value); Q_UNUSED(value);
#endif
# endif
} }


static void uiEditParameterCallback(void* ptr, uint32_t index, bool started) static void uiEditParameterCallback(void* ptr, uint32_t index, bool started)
@@ -121,18 +163,18 @@ private:


static void uiSendNoteCallback(void* ptr, bool onOff, uint8_t channel, uint8_t note, uint8_t velocity) static void uiSendNoteCallback(void* ptr, bool onOff, uint8_t channel, uint8_t note, uint8_t velocity)
{ {
#if DISTRHO_PLUGIN_IS_SYNTH
# if DISTRHO_PLUGIN_IS_SYNTH
UICarla* _this_ = (UICarla*)ptr; UICarla* _this_ = (UICarla*)ptr;
CARLA_ASSERT(_this_); CARLA_ASSERT(_this_);


_this_->uiSendNote(onOff, channel, note, velocity); _this_->uiSendNote(onOff, channel, note, velocity);
#else
# else
Q_UNUSED(ptr); Q_UNUSED(ptr);
Q_UNUSED(onOff); Q_UNUSED(onOff);
Q_UNUSED(channel); Q_UNUSED(channel);
Q_UNUSED(note); Q_UNUSED(note);
Q_UNUSED(velocity); Q_UNUSED(velocity);
#endif
# endif
} }


static void uiResizeCallback(void* ptr, unsigned int width, unsigned int height) static void uiResizeCallback(void* ptr, unsigned int width, unsigned int height)
@@ -142,25 +184,29 @@ private:


_this_->uiResize(width, height); _this_->uiResize(width, height);
} }

friend class PluginCarla;
}; };
#endif #endif


// -----------------------------------------------------------------------
// Carla Plugin

class PluginCarla : public PluginDescriptorClass class PluginCarla : public PluginDescriptorClass
{ {
public: public:
PluginCarla(const HostDescriptor* host)
: PluginDescriptorClass(host),
m_host(host)
PluginCarla(const HostDescriptor* const host)
: PluginDescriptorClass(host)
{ {
#if DISTRHO_PLUGIN_HAS_UI
uiPtr = nullptr; uiPtr = nullptr;
#endif
} }


~PluginCarla() ~PluginCarla()
{ {
#if DISTRHO_PLUGIN_HAS_UI
if (uiPtr) if (uiPtr)
delete uiPtr; delete uiPtr;
#endif
} }


protected: protected:
@@ -172,12 +218,15 @@ protected:
return plugin.parameterCount(); return plugin.parameterCount();
} }


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


// reset
param.hints = ::PARAMETER_IS_ENABLED;

{ {
uint32_t paramHints = plugin.parameterHints(index);
const uint32_t paramHints = plugin.parameterHints(index);


if (paramHints & PARAMETER_IS_AUTOMABLE) if (paramHints & PARAMETER_IS_AUTOMABLE)
param.hints |= ::PARAMETER_IS_AUTOMABLE; param.hints |= ::PARAMETER_IS_AUTOMABLE;
@@ -195,7 +244,8 @@ protected:
param.unit = plugin.parameterUnit(index); param.unit = plugin.parameterUnit(index);


{ {
const ParameterRanges* ranges(plugin.parameterRanges(index));
const ParameterRanges* const ranges(plugin.parameterRanges(index));

param.ranges.def = ranges->def; param.ranges.def = ranges->def;
param.ranges.min = ranges->min; param.ranges.min = ranges->min;
param.ranges.max = ranges->max; param.ranges.max = ranges->max;
@@ -210,7 +260,7 @@ protected:
return &param; return &param;
} }


float getParameterValue(uint32_t index)
float getParameterValue(const uint32_t index)
{ {
return plugin.parameterValue(index); return plugin.parameterValue(index);
} }
@@ -224,7 +274,7 @@ protected:
return plugin.programCount(); return plugin.programCount();
} }


virtual const ::MidiProgram* getMidiProgramInfo(uint32_t index)
virtual const ::MidiProgram* getMidiProgramInfo(const uint32_t index)
{ {
static ::MidiProgram midiProgram; static ::MidiProgram midiProgram;
midiProgram.bank = index / 128; midiProgram.bank = index / 128;
@@ -237,21 +287,25 @@ protected:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Plugin state calls // Plugin state calls


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


#if DISTRHO_PLUGIN_WANT_PROGRAMS #if DISTRHO_PLUGIN_WANT_PROGRAMS
void setMidiProgram(uint32_t bank, uint32_t program)
void setMidiProgram(const uint32_t bank, const uint32_t program)
{ {
uint32_t realProgram = bank * 128 + program;
const uint32_t realProgram = bank * 128 + program;

if (realProgram >= plugin.programCount())
return;

plugin.setProgram(realProgram); plugin.setProgram(realProgram);
} }
#endif #endif


#if DISTRHO_PLUGIN_WANT_STATE #if DISTRHO_PLUGIN_WANT_STATE
void setCustomData(const char* key, const char* value)
void setCustomData(const char* const key, const char* const value)
{ {
plugin.setState(key, value); plugin.setState(key, value);
} }
@@ -261,42 +315,42 @@ protected:
// Plugin UI calls // Plugin UI calls


#if DISTRHO_PLUGIN_HAS_UI #if DISTRHO_PLUGIN_HAS_UI
void uiShow(bool show)
void uiShow(const bool show)
{ {
if (show) if (show)
createUiIfNeeded(); createUiIfNeeded();


//if (uiPtr)
// uiPtr->setVisible(show);
if (uiPtr)
uiPtr->carla_show(show);
} }


void uiIdle() void uiIdle()
{ {
if (uiPtr) if (uiPtr)
uiPtr->ui.idle();
uiPtr->carla_idle();
} }


void uiSetParameterValue(uint32_t index, float value)
void uiSetParameterValue(const uint32_t index, const float value)
{ {
if (uiPtr) if (uiPtr)
uiPtr->ui.parameterChanged(index, value);
uiPtr->carla_setParameterValue(index, value);
} }


# if DISTRHO_PLUGIN_WANT_PROGRAMS # if DISTRHO_PLUGIN_WANT_PROGRAMS
void uiSetMidiProgram(uint32_t bank, uint32_t program)
void uiSetMidiProgram(const uint32_t bank, const uint32_t program)
{ {
uint32_t realProgram = bank * 128 + program; uint32_t realProgram = bank * 128 + program;


if (uiPtr) if (uiPtr)
uiPtr->ui.programChanged(realProgram);
uiPtr->carla_setMidiProgram(realProgram);
} }
# endif # endif


# if DISTRHO_PLUGIN_WANT_STATE # if DISTRHO_PLUGIN_WANT_STATE
void uiSetCustomData(const char* key, const char* value)
void uiSetCustomData(const char* const key, const char* const value)
{ {
if (uiPtr) if (uiPtr)
uiPtr->ui.stateChanged(key, value);
uiPtr->carla_setCustomData(key, value);
} }
# endif # endif
#endif #endif
@@ -314,30 +368,51 @@ protected:
plugin.deactivate(); plugin.deactivate();
} }


void process(float**, float**, uint32_t, uint32_t, ::MidiEvent*)
#if DISTRHO_PLUGIN_IS_SYNTH
void process(float** const inBuffer, float** const outBuffer, const uint32_t frames, const uint32_t midiEventCount, const ::MidiEvent* const midiEvents)
{
for (uint32_t i=0; i < midiEventCount && i < MAX_MIDI_EVENTS; i++)
{
const ::MidiEvent* midiEvent = &midiEvents[i];
MidiEvent* realEvent = &realMidiEvents[i];

realEvent->buffer[0] = midiEvent->data[0];
realEvent->buffer[1] = midiEvent->data[1];
realEvent->buffer[2] = midiEvent->data[2];
realEvent->frame = midiEvent->time;
}

plugin.run(inBuffer, outBuffer, frames, midiEventCount, realMidiEvents);
}
#else
void process(float** const inBuffer, float** const outBuffer, const uint32_t frames, const uint32_t, const ::MidiEvent* const)
{ {
//plugin->d_run();
plugin.run(inBuffer, outBuffer, frames, 0, nullptr);
} }
#endif


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


private: private:
PluginInternal plugin; PluginInternal plugin;
const HostDescriptor* const m_host;

#if DISTRHO_PLUGIN_IS_SYNTH
MidiEvent realMidiEvents[MAX_MIDI_EVENTS];
#endif


#if DISTRHO_PLUGIN_HAS_UI #if DISTRHO_PLUGIN_HAS_UI
// UI // UI
UICarla* uiPtr; UICarla* uiPtr;
#endif


void createUiIfNeeded() void createUiIfNeeded()
{ {
if (! uiPtr) if (! uiPtr)
{ {
setLastUiSampleRate(getSampleRate()); setLastUiSampleRate(getSampleRate());
uiPtr = new UICarla(m_host, &plugin, 0);
uiPtr = new UICarla(getHostHandle(), &plugin);
} }
} }
#endif


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




+ 10
- 20
c++/carla-native/midi-split.cpp View File

@@ -20,7 +20,7 @@
class MidiSplitPlugin : public PluginDescriptorClass class MidiSplitPlugin : public PluginDescriptorClass
{ {
public: public:
MidiSplitPlugin(const HostDescriptor* host)
MidiSplitPlugin(const HostDescriptor* const host)
: PluginDescriptorClass(host) : PluginDescriptorClass(host)
{ {
} }
@@ -33,48 +33,38 @@ protected:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Plugin process calls // Plugin process calls


void activate()
void process(float**, float**, const uint32_t, const uint32_t midiEventCount, const MidiEvent* const midiEvents)
{ {
//memset(events, 0, sizeof(MidiEvent) * MAX_MIDI_EVENTS);
}

void process(float**, float**, uint32_t, uint32_t midiEventCount, MidiEvent* midiEvents)
{
MidiEvent midiEvent;

for (uint32_t i=0; i < midiEventCount; i++) for (uint32_t i=0; i < midiEventCount; i++)
{ {
memcpy(&midiEvent, &midiEvents[i], sizeof(MidiEvent));
memcpy(&m_midiEvent, &midiEvents[i], sizeof(MidiEvent));


uint8_t status = midiEvent.data[0];
uint8_t channel = status & 0x0F;
const uint8_t status = m_midiEvent.data[0] & 0xF0;
const uint8_t channel = status & 0x0F;


CARLA_ASSERT(channel < 16); CARLA_ASSERT(channel < 16);


if (channel >= 16) if (channel >= 16)
continue; continue;


status -= channel;

midiEvent.port = channel;
midiEvent.data[0] = status;
m_midiEvent.port = channel;
m_midiEvent.data[0] = status;


writeMidiEvent(&midiEvent);
writeMidiEvent(&m_midiEvent);
} }
} }


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


private: private:
//static const unsigned short MAX_MIDI_EVENTS = 512;
//MidiEvent events[MAX_MIDI_EVENTS];
MidiEvent m_midiEvent;


PluginDescriptorClassEND(MidiSplitPlugin) PluginDescriptorClassEND(MidiSplitPlugin)
}; };


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


static PluginDescriptor midiSplitDesc = {
static const PluginDescriptor midiSplitDesc = {
/* category */ PLUGIN_CATEGORY_UTILITY, /* category */ PLUGIN_CATEGORY_UTILITY,
/* hints */ 0x0, /* hints */ 0x0,
/* audioIns */ 0, /* audioIns */ 0,


+ 57
- 61
c++/carla-native/zynaddsubfx.cpp View File

@@ -15,11 +15,13 @@
* For a full copy of the GNU General Public License see the COPYING file * For a full copy of the GNU General Public License see the COPYING file
*/ */


// for UINT32_MAX
#define __STDC_LIMIT_MACROS
#include <cstdint>

#include "carla_midi.h" #include "carla_midi.h"
#include "carla_native.hpp" #include "carla_native.hpp"


#include <climits>

#include "zynaddsubfx/Misc/Master.h" #include "zynaddsubfx/Misc/Master.h"
#include "zynaddsubfx/Misc/Util.h" #include "zynaddsubfx/Misc/Util.h"


@@ -40,21 +42,18 @@ class ZynAddSubFxPlugin : public PluginDescriptorClass
{ {
public: public:
enum Parameters { enum Parameters {
PARAMETER_MASTER,
PARAMETER_MAX
PARAMETER_COUNT = 0
}; };


ZynAddSubFxPlugin(const HostDescriptor* host)
ZynAddSubFxPlugin(const HostDescriptor* const host)
: PluginDescriptorClass(host) : PluginDescriptorClass(host)
{ {
qDebug("ZynAddSubFxPlugin::ZynAddSubFxPlugin(), s_instanceCount=%i", s_instanceCount);

m_master = new Master; m_master = new Master;


// refresh banks // refresh banks
m_master->bank.rescanforbanks(); m_master->bank.rescanforbanks();


for (size_t i=0, size = m_master->bank.banks.size(); i < size; i++)
for (uint32_t i=0, size = m_master->bank.banks.size(); i < size; i++)
{ {
if (m_master->bank.banks[i].dir.empty()) if (m_master->bank.banks[i].dir.empty())
continue; continue;
@@ -63,15 +62,12 @@ public:


for (unsigned int instrument = 0; instrument < BANK_SIZE; instrument++) for (unsigned int instrument = 0; instrument < BANK_SIZE; instrument++)
{ {
const std::string insName = m_master->bank.getname(instrument);
const std::string insName(m_master->bank.getname(instrument));


if (insName.empty() || insName[0] == '\0' || insName[0] == ' ') if (insName.empty() || insName[0] == '\0' || insName[0] == ' ')
continue; continue;


ProgramInfo pInfo;
pInfo.bank = i;
pInfo.prog = instrument;
pInfo.name = insName;
ProgramInfo pInfo = { i, instrument, CarlaString(insName.c_str()) };
m_programs.push_back(pInfo); m_programs.push_back(pInfo);
} }
} }
@@ -79,8 +75,6 @@ public:


~ZynAddSubFxPlugin() ~ZynAddSubFxPlugin()
{ {
qDebug("ZynAddSubFxPlugin::~ZynAddSubFxPlugin(), s_instanceCount=%i", s_instanceCount);

//ensure that everything has stopped with the mutex wait //ensure that everything has stopped with the mutex wait
pthread_mutex_lock(&m_master->mutex); pthread_mutex_lock(&m_master->mutex);
pthread_mutex_unlock(&m_master->mutex); pthread_mutex_unlock(&m_master->mutex);
@@ -96,15 +90,15 @@ protected:


uint32_t getParameterCount() uint32_t getParameterCount()
{ {
return PARAMETER_MAX;
return PARAMETER_COUNT;
} }


const Parameter* getParameterInfo(uint32_t index)
const Parameter* getParameterInfo(const uint32_t index)
{ {
CARLA_ASSERT(index < getParameterCount()); CARLA_ASSERT(index < getParameterCount());


if (index >= PARAMETER_MAX)
return nullptr;
//if (index >= PARAMETER_COUNT)
return nullptr;


static Parameter param; static Parameter param;


@@ -116,6 +110,7 @@ protected:


switch (index) switch (index)
{ {
#if 0
case PARAMETER_MASTER: case PARAMETER_MASTER:
param.hints = PARAMETER_IS_ENABLED | PARAMETER_IS_AUTOMABLE; param.hints = PARAMETER_IS_ENABLED | PARAMETER_IS_AUTOMABLE;
param.name = "Master Volume"; param.name = "Master Volume";
@@ -124,17 +119,20 @@ protected:
param.ranges.max = 100.0f; param.ranges.max = 100.0f;
param.ranges.def = 100.0f; param.ranges.def = 100.0f;
break; break;
#endif
} }


return &param; return &param;
} }


float getParameterValue(uint32_t index)
float getParameterValue(const uint32_t index)
{ {
switch (index) switch (index)
{ {
#if 0
case PARAMETER_MASTER: case PARAMETER_MASTER:
return m_master->Pvolume; return m_master->Pvolume;
#endif
default: default:
return 0.0f; return 0.0f;
} }
@@ -148,19 +146,19 @@ protected:
return m_programs.size(); return m_programs.size();
} }


const MidiProgram* getMidiProgramInfo(uint32_t index)
const MidiProgram* getMidiProgramInfo(const uint32_t index)
{ {
CARLA_ASSERT(index < getMidiProgramCount()); CARLA_ASSERT(index < getMidiProgramCount());


if (index >= m_programs.size()) if (index >= m_programs.size())
return nullptr; return nullptr;


const ProgramInfo pInfo(m_programs[index]);
const ProgramInfo& pInfo(m_programs[index]);


static MidiProgram midiProgram; static MidiProgram midiProgram;
midiProgram.bank = pInfo.bank; midiProgram.bank = pInfo.bank;
midiProgram.program = pInfo.prog; midiProgram.program = pInfo.prog;
midiProgram.name = pInfo.name.c_str();
midiProgram.name = pInfo.name;


return &midiProgram; return &midiProgram;
} }
@@ -168,17 +166,15 @@ protected:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Plugin state calls // Plugin state calls


void setParameterValue(uint32_t index, float value)
void setParameterValue(const uint32_t index, const float value)
{ {
switch (index) switch (index)
{ {
case PARAMETER_MASTER:
m_master->setPvolume((char)rint(value));
break;
} }
Q_UNUSED(value);
} }


void setMidiProgram(uint32_t bank, uint32_t program)
void setMidiProgram(const uint32_t bank, const uint32_t program)
{ {
if (bank >= m_master->bank.banks.size()) if (bank >= m_master->bank.banks.size())
return; return;
@@ -206,70 +202,70 @@ protected:
m_master->setController(0, MIDI_CONTROL_ALL_SOUND_OFF, 0); m_master->setController(0, MIDI_CONTROL_ALL_SOUND_OFF, 0);
} }


void process(float**, float** outBuffer, uint32_t frames, uint32_t midiEventCount, MidiEvent* midiEvents)
void process(float**, float** const outBuffer, const uint32_t frames, const uint32_t midiEventCount, const MidiEvent* const midiEvents)
{ {
unsigned long from_frame = 0;
unsigned long event_index = 0;
unsigned long next_event_frame = 0;
unsigned long to_frame = 0;
uint32_t fromFrame = 0;
uint32_t eventIndex = 0;
uint32_t nextEventFrame = 0;
uint32_t toFrame = 0;
pthread_mutex_lock(&m_master->mutex); pthread_mutex_lock(&m_master->mutex);


do { do {
/* Find the time of the next event, if any */
if (event_index >= midiEventCount)
next_event_frame = ULONG_MAX;
// Find the time of the next event, if any
if (eventIndex >= midiEventCount)
nextEventFrame = UINT32_MAX;
else else
next_event_frame = midiEvents[event_index].time;
nextEventFrame = midiEvents[eventIndex].time;


/* find the end of the sub-sample to be processed this time round... */
/* if the next event falls within the desired sample interval... */
if ((next_event_frame < frames) && (next_event_frame >= to_frame))
/* set the end to be at that event */
to_frame = next_event_frame;
// find the end of the sub-sample to be processed this time round...
// if the next event falls within the desired sample interval...
if ((nextEventFrame < frames) && (nextEventFrame >= toFrame))
// set the end to be at that event
toFrame = nextEventFrame;
else else
/* ...else go for the whole remaining sample */
to_frame = frames;
// ...else go for the whole remaining sample
toFrame = frames;


if (from_frame < to_frame)
if (fromFrame < toFrame)
{ {
// call master to fill from `from_frame` to `to_frame`:
m_master->GetAudioOutSamples(to_frame - from_frame, (int)getSampleRate(), &outBuffer[0][from_frame], &outBuffer[1][from_frame]);
// call master to fill from `fromFrame` to `toFrame`:
m_master->GetAudioOutSamples(toFrame - fromFrame, (unsigned)getSampleRate(), &outBuffer[0][fromFrame], &outBuffer[1][fromFrame]);
// next sub-sample please... // next sub-sample please...
from_frame = to_frame;
fromFrame = toFrame;
} }


// Now process any event(s) at the current timing point // Now process any event(s) at the current timing point
while (event_index < midiEventCount && midiEvents[event_index].time == to_frame)
while (eventIndex < midiEventCount && midiEvents[eventIndex].time == toFrame)
{ {
uint8_t status = midiEvents[event_index].data[0];
uint8_t status = midiEvents[eventIndex].data[0];
uint8_t channel = status & 0x0F; uint8_t channel = status & 0x0F;


if (MIDI_IS_STATUS_NOTE_OFF(status)) if (MIDI_IS_STATUS_NOTE_OFF(status))
{ {
uint8_t note = midiEvents[event_index].data[1];
uint8_t note = midiEvents[eventIndex].data[1];


m_master->noteOff(channel, note); m_master->noteOff(channel, note);
} }
else if (MIDI_IS_STATUS_NOTE_ON(status)) else if (MIDI_IS_STATUS_NOTE_ON(status))
{ {
uint8_t note = midiEvents[event_index].data[1];
uint8_t velo = midiEvents[event_index].data[2];
uint8_t note = midiEvents[eventIndex].data[1];
uint8_t velo = midiEvents[eventIndex].data[2];


m_master->noteOn(channel, note, velo); m_master->noteOn(channel, note, velo);
} }
else if (MIDI_IS_STATUS_POLYPHONIC_AFTERTOUCH(status)) else if (MIDI_IS_STATUS_POLYPHONIC_AFTERTOUCH(status))
{ {
uint8_t note = midiEvents[event_index].data[1];
uint8_t pressure = midiEvents[event_index].data[2];
uint8_t note = midiEvents[eventIndex].data[1];
uint8_t pressure = midiEvents[eventIndex].data[2];


m_master->polyphonicAftertouch(channel, note, pressure); m_master->polyphonicAftertouch(channel, note, pressure);
} }


event_index++;
eventIndex++;
} }


// Keep going until we have the desired total length of sample... // Keep going until we have the desired total length of sample...
} while (to_frame < frames);
} while (toFrame < frames);


pthread_mutex_unlock(&m_master->mutex); pthread_mutex_unlock(&m_master->mutex);
} }
@@ -280,7 +276,7 @@ private:
struct ProgramInfo { struct ProgramInfo {
uint32_t bank; uint32_t bank;
uint32_t prog; uint32_t prog;
std::string name;
CarlaString name;
}; };
std::vector<ProgramInfo> m_programs; std::vector<ProgramInfo> m_programs;


@@ -331,14 +327,14 @@ int ZynAddSubFxPlugin::s_instanceCount = 0;


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


static PluginDescriptor zynAddSubFxDesc = {
static const PluginDescriptor zynAddSubFxDesc = {
/* category */ PLUGIN_CATEGORY_SYNTH, /* category */ PLUGIN_CATEGORY_SYNTH,
/* hints */ PLUGIN_IS_SYNTH | PLUGIN_USES_SINGLE_THREAD,
/* hints */ PLUGIN_IS_SYNTH,
/* audioIns */ 2, /* audioIns */ 2,
/* audioOuts */ 2, /* audioOuts */ 2,
/* midiIns */ 1, /* midiIns */ 1,
/* midiOuts */ 0, /* midiOuts */ 0,
/* paramIns */ ZynAddSubFxPlugin::PARAMETER_MAX,
/* paramIns */ ZynAddSubFxPlugin::PARAMETER_COUNT,
/* paramOuts */ 0, /* paramOuts */ 0,
/* name */ "ZynAddSubFX", /* name */ "ZynAddSubFX",
/* label */ "zynaddsubfx", /* label */ "zynaddsubfx",


+ 1
- 1
c++/distrho-plugin-toolkit/DistrhoPlugin.h View File

@@ -167,7 +167,7 @@ protected:
// Process // Process
virtual void d_activate() = 0; virtual void d_activate() = 0;
virtual void d_deactivate() = 0; virtual void d_deactivate() = 0;
virtual void d_run(const float** inputs, float** outputs, uint32_t frames, uint32_t midiEventCount, const MidiEvent* midiEvents) = 0;
virtual void d_run(float** inputs, float** outputs, uint32_t frames, uint32_t midiEventCount, const MidiEvent* midiEvents) = 0;


// Callbacks // Callbacks
virtual void d_bufferSizeChanged(uint32_t newBufferSize); virtual void d_bufferSizeChanged(uint32_t newBufferSize);


+ 1
- 1
c++/distrho-plugin-toolkit/src/DistrhoPluginInternal.h View File

@@ -293,7 +293,7 @@ public:
plugin->d_deactivate(); plugin->d_deactivate();
} }


void run(const float** inputs, float** outputs, uint32_t frames, uint32_t midiEventCount, const MidiEvent* midiEvents)
void run(float** inputs, float** outputs, uint32_t frames, uint32_t midiEventCount, const MidiEvent* midiEvents)
{ {
assert(plugin && frames >= 2); assert(plugin && frames >= 2);




+ 7
- 10
c++/distrho-plugin-toolkit/src/DistrhoPluginLADSPA+DSSI.cpp View File

@@ -195,9 +195,6 @@ public:
void ladspa_run(unsigned long bufferSize) void ladspa_run(unsigned long bufferSize)
#endif #endif
{ {
if (bufferSize <= 1)
return;

// Check for updated bufferSize // Check for updated bufferSize
if (bufferSize != lastBufferSize) if (bufferSize != lastBufferSize)
{ {
@@ -230,7 +227,7 @@ public:
snd_seq_event_t* event = &events[i]; snd_seq_event_t* event = &events[i];
memset(&midiEvents[midiEventCount], 0, sizeof(MidiEvent)); memset(&midiEvents[midiEventCount], 0, sizeof(MidiEvent));


if (events[i].type == SND_SEQ_EVENT_NOTEON)
if (event->type == SND_SEQ_EVENT_NOTEON)
{ {
j = midiEventCount++; j = midiEventCount++;
midiEvents[j].frame = event->time.tick; midiEvents[j].frame = event->time.tick;
@@ -238,14 +235,14 @@ public:
midiEvents[j].buffer[1] = event->data.note.note; midiEvents[j].buffer[1] = event->data.note.note;
midiEvents[j].buffer[2] = event->data.note.velocity; midiEvents[j].buffer[2] = event->data.note.velocity;
} }
else if (events[i].type == SND_SEQ_EVENT_NOTEOFF)
else if (event->type == SND_SEQ_EVENT_NOTEOFF)
{ {
j = midiEventCount++; j = midiEventCount++;
midiEvents[j].frame = event->time.tick; midiEvents[j].frame = event->time.tick;
midiEvents[j].buffer[0] = 0x80 + event->data.note.channel; midiEvents[j].buffer[0] = 0x80 + event->data.note.channel;
midiEvents[j].buffer[1] = event->data.note.note; midiEvents[j].buffer[1] = event->data.note.note;
} }
else if (events[i].type == SND_SEQ_EVENT_KEYPRESS)
else if (event->type == SND_SEQ_EVENT_KEYPRESS)
{ {
j = midiEventCount++; j = midiEventCount++;
midiEvents[j].frame = event->time.tick; midiEvents[j].frame = event->time.tick;
@@ -253,7 +250,7 @@ public:
midiEvents[j].buffer[1] = event->data.note.note; midiEvents[j].buffer[1] = event->data.note.note;
midiEvents[j].buffer[2] = event->data.note.velocity; midiEvents[j].buffer[2] = event->data.note.velocity;
} }
else if (events[i].type == SND_SEQ_EVENT_CONTROLLER)
else if (event->type == SND_SEQ_EVENT_CONTROLLER)
{ {
j = midiEventCount++; j = midiEventCount++;
midiEvents[j].frame = event->time.tick; midiEvents[j].frame = event->time.tick;
@@ -261,14 +258,14 @@ public:
midiEvents[j].buffer[1] = event->data.control.param; midiEvents[j].buffer[1] = event->data.control.param;
midiEvents[j].buffer[2] = event->data.control.value; midiEvents[j].buffer[2] = event->data.control.value;
} }
else if (events[i].type == SND_SEQ_EVENT_CHANPRESS)
else if (event->type == SND_SEQ_EVENT_CHANPRESS)
{ {
j = midiEventCount++; j = midiEventCount++;
midiEvents[j].frame = event->time.tick; midiEvents[j].frame = event->time.tick;
midiEvents[j].buffer[0] = 0xD0 + event->data.control.channel; midiEvents[j].buffer[0] = 0xD0 + event->data.control.channel;
midiEvents[j].buffer[1] = event->data.control.value; midiEvents[j].buffer[1] = event->data.control.value;
} }
else if (events[i].type == SND_SEQ_EVENT_PITCHBEND)
else if (event->type == SND_SEQ_EVENT_PITCHBEND)
{ {
// TODO // TODO
//j = midiEventCount++; //j = midiEventCount++;
@@ -348,7 +345,7 @@ private:
static LADSPA_Handle ladspa_instantiate(const LADSPA_Descriptor*, unsigned long sampleRate) static LADSPA_Handle ladspa_instantiate(const LADSPA_Descriptor*, unsigned long sampleRate)
{ {
if (d_lastBufferSize == 0) if (d_lastBufferSize == 0)
d_lastBufferSize = 512;
d_lastBufferSize = 2048;
d_lastSampleRate = sampleRate; d_lastSampleRate = sampleRate;


return new PluginLadspaDssi(); return new PluginLadspaDssi();


+ 2
- 0
c++/distrho-plugin-toolkit/src/DistrhoPluginVST.cpp View File

@@ -507,6 +507,7 @@ static intptr_t vst_dispatcherCallback(AEffect* effect, int32_t opcode, int32_t


if (doInternalInit) if (doInternalInit)
{ {
// set valid but dummy values
d_lastBufferSize = 512; d_lastBufferSize = 512;
d_lastSampleRate = 44100.0; d_lastSampleRate = 44100.0;
} }
@@ -516,6 +517,7 @@ static intptr_t vst_dispatcherCallback(AEffect* effect, int32_t opcode, int32_t


if (doInternalInit) if (doInternalInit)
{ {
// unset
d_lastBufferSize = 0; d_lastBufferSize = 0;
d_lastSampleRate = 0.0; d_lastSampleRate = 0.0;




+ 2
- 2
c++/distrho-plugin-toolkit/src/DistrhoUIDSSI.cpp View File

@@ -241,7 +241,7 @@ protected:
while (lo_server_recv_noblock(oscData->server, 0) != 0) {} while (lo_server_recv_noblock(oscData->server, 0) != 0) {}
} }


QObject::timerEvent(event);
QMainWindow::timerEvent(event);
} }


private: private:
@@ -307,7 +307,7 @@ private:


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


static UIDssi* globalUI = nullptr;
static UIDssi* globalUI = nullptr;


void osc_error_handler(int num, const char* msg, const char* path) void osc_error_handler(int num, const char* msg, const char* path)
{ {


+ 1
- 1
c++/distrho-plugin-toolkit/src/DistrhoUILV2.cpp View File

@@ -199,7 +199,7 @@ protected:
#endif #endif


private: private:
UIInternal ui;
UIInternal ui;


// LV2 Stuff // LV2 Stuff
LV2UI_Controller const lv2Controller; LV2UI_Controller const lv2Controller;


Loading…
Cancel
Save