Skip to content

Commit

Permalink
carla-vst: expose first plugin params for host automation; cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed Mar 21, 2019
1 parent 1dc76b5 commit d4a0292
Show file tree
Hide file tree
Showing 24 changed files with 942 additions and 641 deletions.
1,196 changes: 648 additions & 548 deletions source/backend/engine/CarlaEngineNative.cpp

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions source/backend/plugin/CarlaPluginNative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2058,17 +2058,19 @@ class CarlaPluginNative : public CarlaPlugin

if (fHandle2 == nullptr)
{
fDescriptor->process(fHandle, fAudioInBuffers, fAudioOutBuffers, frames, fMidiInEvents, fMidiEventInCount);
fDescriptor->process(fHandle,
const_cast<const float**>(fAudioInBuffers), fAudioOutBuffers, frames,
fMidiInEvents, fMidiEventInCount);
}
else
{
fDescriptor->process(fHandle,
(pData->audioIn.count > 0) ? &fAudioInBuffers[0] : nullptr,
(pData->audioIn.count > 0) ? const_cast<const float**>(&fAudioInBuffers[0]) : nullptr,
(pData->audioOut.count > 0) ? &fAudioOutBuffers[0] : nullptr,
frames, fMidiInEvents, fMidiEventInCount);

fDescriptor->process(fHandle2,
(pData->audioIn.count > 0) ? &fAudioInBuffers[1] : nullptr,
(pData->audioIn.count > 0) ? const_cast<const float**>(&fAudioInBuffers[1]) : nullptr,
(pData->audioOut.count > 0) ? &fAudioOutBuffers[1] : nullptr,
frames, fMidiInEvents, fMidiEventInCount);
}
Expand Down
12 changes: 8 additions & 4 deletions source/includes/CarlaNative.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Carla Native Plugin API
* Copyright (C) 2012-2014 Filipe Coelho <[email protected]>
* Copyright (C) 2012-2019 Filipe Coelho <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -199,7 +199,8 @@ typedef struct {
const char* (*ui_open_file)(NativeHostHandle handle, bool isDir, const char* title, const char* filter);
const char* (*ui_save_file)(NativeHostHandle handle, bool isDir, const char* title, const char* filter);

intptr_t (*dispatcher)(NativeHostHandle handle, NativeHostDispatcherOpcode opcode, int32_t index, intptr_t value, void* ptr, float opt);
intptr_t (*dispatcher)(NativeHostHandle handle,
NativeHostDispatcherOpcode opcode, int32_t index, intptr_t value, void* ptr, float opt);

} NativeHostDescriptor;

Expand Down Expand Up @@ -244,12 +245,15 @@ typedef struct _NativePluginDescriptor {

void (*activate)(NativePluginHandle handle);
void (*deactivate)(NativePluginHandle handle);
void (*process)(NativePluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, const NativeMidiEvent* midiEvents, uint32_t midiEventCount);
void (*process)(NativePluginHandle handle,
const float** inBuffer, float** outBuffer, uint32_t frames,
const NativeMidiEvent* midiEvents, uint32_t midiEventCount);

char* (*get_state)(NativePluginHandle handle);
void (*set_state)(NativePluginHandle handle, const char* data);

intptr_t (*dispatcher)(NativePluginHandle handle, NativePluginDispatcherOpcode opcode, int32_t index, intptr_t value, void* ptr, float opt);
intptr_t (*dispatcher)(NativePluginHandle handle,
NativePluginDispatcherOpcode opcode, int32_t index, intptr_t value, void* ptr, float opt);

} NativePluginDescriptor;

Expand Down
10 changes: 7 additions & 3 deletions source/includes/CarlaNative.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ class NativePluginClass

virtual void deactivate() {}

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

// -------------------------------------------------------------------
// Plugin UI calls
Expand Down Expand Up @@ -454,7 +455,9 @@ class NativePluginClass
handlePtr->deactivate();
}

static void _process(NativePluginHandle handle, float** inBuffer, float** outBuffer, const uint32_t frames, const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
static void _process(NativePluginHandle handle,
const float** inBuffer, float** outBuffer, const uint32_t frames,
const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
{
handlePtr->process(inBuffer, outBuffer, frames, midiEvents, midiEventCount);
}
Expand All @@ -469,7 +472,8 @@ class NativePluginClass
handlePtr->setState(data);
}

static intptr_t _dispatcher(NativePluginHandle handle, NativePluginDispatcherOpcode opcode, int32_t index, intptr_t value, void* ptr, float opt)
static intptr_t _dispatcher(NativePluginHandle handle,
NativePluginDispatcherOpcode opcode, int32_t index, intptr_t value, void* ptr, float opt)
{
switch(opcode)
{
Expand Down
5 changes: 3 additions & 2 deletions source/native-plugins/audio-file.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Carla Native Plugins
* Copyright (C) 2013-2018 Filipe Coelho <[email protected]>
* Copyright (C) 2013-2019 Filipe Coelho <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -118,7 +118,8 @@ class AudioFilePlugin : public NativePluginClass,
// -------------------------------------------------------------------
// Plugin process calls

void process(float**, float** const outBuffer, const uint32_t frames, const NativeMidiEvent*, uint32_t) override
void process(const float**, float** const outBuffer, const uint32_t frames,
const NativeMidiEvent*, uint32_t) override
{
const NativeTimeInfo* const timePos(getTimeInfo());

Expand Down
5 changes: 3 additions & 2 deletions source/native-plugins/bigmeter.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Carla Native Plugins
* Copyright (C) 2012-2017 Filipe Coelho <[email protected]>
* Copyright (C) 2012-2019 Filipe Coelho <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -154,7 +154,8 @@ class BigMeterPlugin : public NativePluginAndUiClass
fOutRight = 0.0f;
}

void process(float** inputs, float**, const uint32_t frames, const NativeMidiEvent* const, const uint32_t) override
void process(const float** inputs, float**, const uint32_t frames,
const NativeMidiEvent* const, const uint32_t) override
{
fOutLeft = carla_findMaxNormalizedFloat(inputs[0], frames);
fOutRight = carla_findMaxNormalizedFloat(inputs[1], frames);
Expand Down
9 changes: 6 additions & 3 deletions source/native-plugins/bypass.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Carla Native Plugins
* Copyright (C) 2012-2014 Filipe Coelho <[email protected]>
* Copyright (C) 2012-2019 Filipe Coelho <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -30,9 +30,12 @@ static NativePluginHandle bypass_instantiate(const NativeHostDescriptor* host)
(void)host;
}

static void bypass_process(NativePluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
static void bypass_process(NativePluginHandle handle,
const float** inBuffer, float** outBuffer, uint32_t frames,
const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
{
memcpy(outBuffer[0], inBuffer[0], sizeof(float)*frames);
if (outBuffer[0] != inBuffer[0])
memcpy(outBuffer[0], inBuffer[0], sizeof(float)*frames);
return;

// unused
Expand Down
4 changes: 3 additions & 1 deletion source/native-plugins/lfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ static void lfo_set_parameter_value(NativePluginHandle handle, uint32_t index, f
}
}

static void lfo_process(NativePluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
static void lfo_process(NativePluginHandle handle,
const float** inBuffer, float** outBuffer, uint32_t frames,
const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
{
const NativeHostDescriptor* const host = handlePtr->host;
const NativeTimeInfo* const timeInfo = host->get_time_info(host->handle);
Expand Down
4 changes: 3 additions & 1 deletion source/native-plugins/midi-channel-ab.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ static void midichanab_set_parameter_value(NativePluginHandle handle, uint32_t i
handlePtr->channels[index] = (value >= 0.5f);
}

static void midichanab_process(NativePluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
static void midichanab_process(NativePluginHandle handle,
const float** inBuffer, float** outBuffer, uint32_t frames,
const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
{
const NativeHostDescriptor* const host = handlePtr->host;
const bool* const channels = handlePtr->channels;
Expand Down
6 changes: 4 additions & 2 deletions source/native-plugins/midi-channel-filter.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Carla Native Plugins
* Copyright (C) 2012-2015 Filipe Coelho <[email protected]>
* Copyright (C) 2012-2019 Filipe Coelho <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -106,7 +106,9 @@ static void midichanfilter_set_parameter_value(NativePluginHandle handle, uint32
handlePtr->channels[index] = (value >= 0.5f);
}

static void midichanfilter_process(NativePluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
static void midichanfilter_process(NativePluginHandle handle,
const float** inBuffer, float** outBuffer, uint32_t frames,
const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
{
const NativeHostDescriptor* const host = handlePtr->host;
const bool* const channels = handlePtr->channels;
Expand Down
4 changes: 3 additions & 1 deletion source/native-plugins/midi-channelize.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ static void midichannelize_set_parameter_value(NativePluginHandle handle, uint32
}
}

static void midichannelize_process(NativePluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
static void midichannelize_process(NativePluginHandle handle,
const float** inBuffer, float** outBuffer, uint32_t frames,
const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
{
const NativeHostDescriptor* const host = handlePtr->host;
const int channel = handlePtr->channel;
Expand Down
2 changes: 1 addition & 1 deletion source/native-plugins/midi-file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class MidiFilePlugin : public NativePluginClass,
// -------------------------------------------------------------------
// Plugin process calls

void process(float**, float**, const uint32_t frames, const NativeMidiEvent* const, const uint32_t) override
void process(const float**, float**, const uint32_t frames, const NativeMidiEvent* const, const uint32_t) override
{
const NativeTimeInfo* const timePos(getTimeInfo());

Expand Down
6 changes: 4 additions & 2 deletions source/native-plugins/midi-gain.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Carla Native Plugins
* Copyright (C) 2012-2014 Filipe Coelho <[email protected]>
* Copyright (C) 2012-2019 Filipe Coelho <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -168,7 +168,9 @@ static void midigain_set_parameter_value(NativePluginHandle handle, uint32_t ind
}
}

static void midigain_process(NativePluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
static void midigain_process(NativePluginHandle handle,
const float** inBuffer, float** outBuffer, uint32_t frames,
const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
{
const NativeHostDescriptor* const host = handlePtr->host;
const float gain = handlePtr->gain;
Expand Down
6 changes: 4 additions & 2 deletions source/native-plugins/midi-join.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Carla Native Plugins
* Copyright (C) 2012-2018 Filipe Coelho <[email protected]>
* Copyright (C) 2012-2019 Filipe Coelho <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -47,7 +47,9 @@ static void midijoin_cleanup(NativePluginHandle handle)
free(handlePtr);
}

static void midijoin_process(NativePluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
static void midijoin_process(NativePluginHandle handle,
const float** inBuffer, float** outBuffer, uint32_t frames,
const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
{
const NativeHostDescriptor* const host = handlePtr->host;
NativeMidiEvent tmpEvent;
Expand Down
2 changes: 1 addition & 1 deletion source/native-plugins/midi-pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class MidiPatternPlugin : public NativePluginAndUiClass,
// -------------------------------------------------------------------
// Plugin process calls

void process(float**, float**, const uint32_t frames, const NativeMidiEvent*, uint32_t) override
void process(const float**, float**, const uint32_t frames, const NativeMidiEvent*, uint32_t) override
{
if (const NativeTimeInfo* const timeInfo = getTimeInfo())
fTimeInfo = *timeInfo;
Expand Down
6 changes: 4 additions & 2 deletions source/native-plugins/midi-split.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Carla Native Plugins
* Copyright (C) 2012-2014 Filipe Coelho <[email protected]>
* Copyright (C) 2012-2019 Filipe Coelho <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -46,7 +46,9 @@ static void midisplit_cleanup(NativePluginHandle handle)
free(handlePtr);
}

static void midisplit_process(NativePluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
static void midisplit_process(NativePluginHandle handle,
const float** inBuffer, float** outBuffer, uint32_t frames,
const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
{
const NativeHostDescriptor* const host = handlePtr->host;
NativeMidiEvent tmpEvent;
Expand Down
6 changes: 4 additions & 2 deletions source/native-plugins/midi-through.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Carla Native Plugins
* Copyright (C) 2012-2014 Filipe Coelho <[email protected]>
* Copyright (C) 2012-2019 Filipe Coelho <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -46,7 +46,9 @@ static void midithrough_cleanup(NativePluginHandle handle)
free(handlePtr);
}

static void midithrough_process(NativePluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
static void midithrough_process(NativePluginHandle handle,
const float** inBuffer, float** outBuffer, uint32_t frames,
const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
{
const NativeHostDescriptor* const host = handlePtr->host;

Expand Down
6 changes: 4 additions & 2 deletions source/native-plugins/midi-transpose.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Carla Native Plugins
* Copyright (C) 2012-2018 Filipe Coelho <[email protected]>
* Copyright (C) 2012-2019 Filipe Coelho <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -130,7 +130,9 @@ static void miditranspose_set_parameter_value(NativePluginHandle handle, uint32_
}
}

static void miditranspose_process(NativePluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
static void miditranspose_process(NativePluginHandle handle,
const float** inBuffer, float** outBuffer, uint32_t frames,
const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
{
const NativeHostDescriptor* const host = handlePtr->host;
const int octaves = handlePtr->octaves;
Expand Down
4 changes: 2 additions & 2 deletions source/native-plugins/notes.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Carla Native Plugins
* Copyright (C) 2012-2014 Filipe Coelho <[email protected]>
* Copyright (C) 2012-2019 Filipe Coelho <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -83,7 +83,7 @@ class NotesPlugin : public NativePluginAndUiClass
// -------------------------------------------------------------------
// Plugin process calls

void process(float**, float**, const uint32_t, const NativeMidiEvent* const, const uint32_t) override
void process(const float**, float**, const uint32_t, const NativeMidiEvent* const, const uint32_t) override
{
}

Expand Down
5 changes: 1 addition & 4 deletions source/plugin/carla-lv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,7 @@ class NativePlugin : public Lv2PluginBaseClass<NativeTimeInfo>
}
}

// FIXME
fDescriptor->process(fHandle,
const_cast<float**>(fPorts.audioIns), fPorts.audioOuts, frames,
fMidiEvents, fMidiEventCount);
fDescriptor->process(fHandle, fPorts.audioIns, fPorts.audioOuts, frames, fMidiEvents, fMidiEventCount);

if (fWorkerUISignal == -1 && fPorts.hasUI)
{
Expand Down
9 changes: 9 additions & 0 deletions source/plugin/carla-vst-export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,12 @@ intptr_t VSTAudioMaster(AEffect* effect, int32_t opcode, int32_t index, intptr_t
const audioMasterCallback audioMaster = (audioMasterCallback)((VstObject*)effect->object)->audioMaster;
return audioMaster(effect, opcode, index, value, ptr, opt);
}

bool isUsingUILauncher()
{
#ifdef CARLA_OS_LINUX
return false;
#else
return true;
#endif
}
Loading

0 comments on commit d4a0292

Please sign in to comment.