Browse Source

Continue last commit, revert CarlaPlugin.cpp changes

tags/1.9.4
falkTX 12 years ago
parent
commit
7c53d75951
7 changed files with 89 additions and 82 deletions
  1. +11
    -11
      source/backend/CarlaNative.h
  2. +6
    -5
      source/backend/CarlaNative.hpp
  3. +1
    -1
      source/backend/native/lfo.c
  4. +1
    -1
      source/backend/native/nekofilter/nekofilter.c
  5. +5
    -5
      source/backend/native/zynaddsubfx.cpp
  6. +36
    -47
      source/backend/plugin/CarlaPlugin.cpp
  7. +29
    -12
      source/backend/plugin/NativePlugin.cpp

+ 11
- 11
source/backend/CarlaNative.h View File

@@ -84,19 +84,19 @@ typedef enum _ParameterHints {

typedef enum _PluginDispatcherOpcode {
PLUGIN_OPCODE_NULL = 0, // nothing
PLUGIN_OPCODE_BUFFER_SIZE_CHANGED = 1, // nothing
PLUGIN_OPCODE_SAMPLE_RATE_CHANGED = 2, // nothing
PLUGIN_OPCODE_OFFLINE_CHANGED = 3, // nothing
PLUGIN_OPCODE_UI_NAME_CHANGED = 4 // nothing
PLUGIN_OPCODE_BUFFER_SIZE_CHANGED = 1, // uses value
PLUGIN_OPCODE_SAMPLE_RATE_CHANGED = 2, // uses opt
PLUGIN_OPCODE_OFFLINE_CHANGED = 3, // uses value
PLUGIN_OPCODE_UI_NAME_CHANGED = 4 // uses ptr
} PluginDispatcherOpcode;

typedef enum _HostDispatcherOpcode {
HOST_OPCODE_NULL = 0, // nothing
HOST_OPCODE_SET_VOLUME = 1, // uses value
HOST_OPCODE_SET_DRYWET = 2, // uses value
HOST_OPCODE_SET_BALANCE_LEFT = 3, // uses value
HOST_OPCODE_SET_BALANCE_RIGHT = 4, // uses value
HOST_OPCODE_SET_PANNING = 5, // uses value
HOST_OPCODE_SET_VOLUME = 1, // uses opt
HOST_OPCODE_SET_DRYWET = 2, // uses opt
HOST_OPCODE_SET_BALANCE_LEFT = 3, // uses opt
HOST_OPCODE_SET_BALANCE_RIGHT = 4, // uses opt
HOST_OPCODE_SET_PANNING = 5, // uses opt
HOST_OPCODE_SET_PROCESS_PRECISION = 6, // uses value
HOST_OPCODE_UI_UNAVAILABLE = 7 // nothing
} HostDispatcherOpcode;
@@ -184,7 +184,7 @@ typedef struct _HostDescriptor {
const char* (*ui_open_file)(HostHandle handle, bool isDir, const char* title, const char* filter);
const char* (*ui_save_file)(HostHandle handle, bool isDir, const char* title, const char* filter);

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

} HostDescriptor;

@@ -232,7 +232,7 @@ typedef struct _PluginDescriptor {
char* (*get_state)(PluginHandle handle);
void (*set_state)(PluginHandle handle, const char* data);

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

} PluginDescriptor;



+ 6
- 5
source/backend/CarlaNative.hpp View File

@@ -169,12 +169,12 @@ protected:
return nullptr;
}

intptr_t hostDispatcher(const HostDispatcherOpcode opcode, const int32_t index, const intptr_t value, void* const ptr)
intptr_t hostDispatcher(const HostDispatcherOpcode opcode, const int32_t index, const intptr_t value, void* const ptr, const float opt)
{
CARLA_ASSERT(kHost != nullptr);

if (kHost != nullptr)
return kHost->dispatcher(kHost->handle, opcode, index, value, ptr);
return kHost->dispatcher(kHost->handle, opcode, index, value, ptr, opt);

return 0;
}
@@ -346,7 +346,7 @@ protected:
// -------------------------------------------------------------------
// Plugin dispatcher

virtual intptr_t pluginDispatcher(const PluginDispatcherOpcode opcode, const int32_t index, const intptr_t value, void* const ptr)
virtual intptr_t pluginDispatcher(const PluginDispatcherOpcode opcode, const int32_t index, const intptr_t value, void* const ptr, const float opt)
{
return 0;

@@ -355,6 +355,7 @@ protected:
(void)index;
(void)value;
(void)ptr;
(void)opt;
}

// -------------------------------------------------------------------
@@ -463,9 +464,9 @@ public:
handlePtr->setState(data);
}

static intptr_t _dispatcher(PluginHandle handle, PluginDispatcherOpcode opcode, int32_t index, intptr_t value, void* ptr)
static intptr_t _dispatcher(PluginHandle handle, PluginDispatcherOpcode opcode, int32_t index, intptr_t value, void* ptr, float opt)
{
return handlePtr->pluginDispatcher(opcode, index, value, ptr);
return handlePtr->pluginDispatcher(opcode, index, value, ptr, opt);
}

#undef handlePtr


+ 1
- 1
source/backend/native/lfo.c View File

@@ -50,7 +50,7 @@ static PluginHandle lfo_instantiate(const PluginDescriptor* _this_, HostDescript
if (handle == NULL)
return NULL;

host->dispatcher(host->handle, HOST_OPCODE_SET_PROCESS_PRECISION, 0, 32, NULL);
host->dispatcher(host->handle, HOST_OPCODE_SET_PROCESS_PRECISION, 0, 32, NULL, 0.0f);

handle->host = host;
handle->mode = 1;


+ 1
- 1
source/backend/native/nekofilter/nekofilter.c View File

@@ -368,7 +368,7 @@ void nekofilter_ui_show(
if (nekofilter_ptr->ui != NULL)
nekoui_show(nekofilter_ptr->ui);
else
nekofilter_ptr->host->dispatcher(nekofilter_ptr->host->handle, HOST_OPCODE_UI_UNAVAILABLE, 0, 0, NULL);
nekofilter_ptr->host->dispatcher(nekofilter_ptr->host->handle, HOST_OPCODE_UI_UNAVAILABLE, 0, 0, NULL, 0.0f);
}
else if (nekofilter_ptr->ui != NULL)
nekoui_hide(nekofilter_ptr->ui);


+ 5
- 5
source/backend/native/zynaddsubfx.cpp View File

@@ -586,7 +586,7 @@ protected:
kParamCount(paramCount-2), // volume and pan handled by host
kProgramCount(programCount)
{
hostDispatcher(HOST_OPCODE_SET_DRYWET, 0, 0.5f, nullptr);
hostDispatcher(HOST_OPCODE_SET_DRYWET, 0, 0, nullptr, 0.5f);
}

~FxAbstractPlugin() override
@@ -646,11 +646,11 @@ protected:
fEffect->setpreset(program);

const float volume(float(fEffect->getpar(0))/127.0f);
hostDispatcher(HOST_OPCODE_SET_VOLUME, 0, volume, nullptr);
hostDispatcher(HOST_OPCODE_SET_VOLUME, 0, 0, nullptr, volume);

const unsigned char pan(fEffect->getpar(1));
const float panning(float(pan)/63.5f-1.0f);
hostDispatcher(HOST_OPCODE_SET_PANNING, 0, (pan == 64) ? 0.0f : panning, nullptr);
hostDispatcher(HOST_OPCODE_SET_PANNING, 0, 0, nullptr, (pan == 64) ? 0.0f : panning);
}

// -------------------------------------------------------------------
@@ -685,7 +685,7 @@ protected:
// -------------------------------------------------------------------
// Plugin dispatcher

intptr_t pluginDispatcher(const PluginDispatcherOpcode opcode, const int32_t, const intptr_t, void* const) final
intptr_t pluginDispatcher(const PluginDispatcherOpcode opcode, const int32_t, const intptr_t, void* const, const float) final
{
switch (opcode)
{
@@ -1599,7 +1599,7 @@ protected:
// -------------------------------------------------------------------
// Plugin dispatcher

intptr_t pluginDispatcher(const PluginDispatcherOpcode opcode, const int32_t index, const intptr_t value, void* const ptr) override
intptr_t pluginDispatcher(const PluginDispatcherOpcode opcode, const int32_t index, const intptr_t value, void* const ptr, const float) override
{
switch (opcode)
{


+ 36
- 47
source/backend/plugin/CarlaPlugin.cpp View File

@@ -1453,18 +1453,11 @@ void CarlaPlugin::setProgram(int32_t index, const bool sendGui, const bool sendO
if (index > static_cast<int32_t>(kData->prog.count))
return;

const int32_t fixedIndex(carla_fixValue<int32_t>(-1, kData->prog.count, index));
const int32_t fixedIndex = carla_fixValue<int32_t>(-1, kData->prog.count, index);

kData->prog.current = fixedIndex;

#ifndef BUILD_BRIDGE
if (sendOsc)
kData->engine->osc_send_control_set_program(fId, fixedIndex);
#endif

if (sendCallback)
kData->engine->callback(CALLBACK_PROGRAM_CHANGED, fId, fixedIndex, 0, 0.0f, nullptr);

// Change default parameter values
if (fixedIndex >= 0)
{
#ifndef BUILD_BRIDGE
@@ -1472,30 +1465,30 @@ void CarlaPlugin::setProgram(int32_t index, const bool sendGui, const bool sendO
uiProgramChange(fixedIndex);
#endif

if (type() == PLUGIN_GIG || type() == PLUGIN_SF2 || type() == PLUGIN_SFZ)
return;

for (uint32_t i=0; i < kData->param.count; ++i)
{
const float value(kData->param.ranges[i].fixValue(getParameterValue(i)));
kData->param.ranges[i].def = value;;
// FIXME?
kData->param.ranges[i].def = getParameterValue(i);
kData->param.ranges[i].fixDefault();

#ifndef BUILD_BRIDGE
if (sendOsc)
{
kData->engine->osc_send_control_set_default_value(fId, i, value);
kData->engine->osc_send_control_set_parameter_value(fId, i, value);
kData->engine->osc_send_control_set_default_value(fId, i, kData->param.ranges[i].def);
kData->engine->osc_send_control_set_parameter_value(fId, i, kData->param.ranges[i].def);
}
#endif
if (sendCallback)
{
kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, i, 0, value, nullptr);
kData->engine->callback(CALLBACK_PARAMETER_DEFAULT_CHANGED, fId, i, 0, value, nullptr);
}
}
}

#ifndef BUILD_BRIDGE
if (sendOsc)
kData->engine->osc_send_control_set_program(fId, fixedIndex);
#endif

if (sendCallback)
kData->engine->callback(CALLBACK_PROGRAM_CHANGED, fId, fixedIndex, 0, 0.0f, nullptr);

#ifdef BUILD_BRIDGE
return;

@@ -1515,18 +1508,10 @@ void CarlaPlugin::setMidiProgram(int32_t index, const bool sendGui, const bool s
if (index > static_cast<int32_t>(kData->midiprog.count))
return;

const int32_t fixedIndex(carla_fixValue<int32_t>(-1, kData->midiprog.count, index));
const int32_t fixedIndex = carla_fixValue<int32_t>(-1, kData->midiprog.count, index);

kData->midiprog.current = fixedIndex;

#ifndef BUILD_BRIDGE
if (sendOsc)
kData->engine->osc_send_control_set_midi_program(fId, fixedIndex);
#endif

if (sendCallback)
kData->engine->callback(CALLBACK_MIDI_PROGRAM_CHANGED, fId, fixedIndex, 0, 0.0f, nullptr);

if (fixedIndex >= 0)
{
#ifndef BUILD_BRIDGE
@@ -1534,30 +1519,34 @@ void CarlaPlugin::setMidiProgram(int32_t index, const bool sendGui, const bool s
uiMidiProgramChange(fixedIndex);
#endif

if (type() == PLUGIN_GIG || type() == PLUGIN_SF2 || type() == PLUGIN_SFZ)
return;

for (uint32_t i=0; i < kData->param.count; ++i)
// Change default parameter values (sound banks never change defaults)
if (type() != PLUGIN_GIG && type() != PLUGIN_SF2 && type() != PLUGIN_SFZ)
{
const float value(kData->param.ranges[i].fixValue(getParameterValue(i)));

kData->param.ranges[i].def = value;;
for (uint32_t i=0; i < kData->param.count; ++i)
{
// FIXME?
kData->param.ranges[i].def = getParameterValue(i);
kData->param.ranges[i].fixDefault();

#ifndef BUILD_BRIDGE
if (sendOsc)
{
kData->engine->osc_send_control_set_default_value(fId, i, value);
kData->engine->osc_send_control_set_parameter_value(fId, i, value);
}
if (sendOsc)
{
kData->engine->osc_send_control_set_default_value(fId, i, kData->param.ranges[i].def);
kData->engine->osc_send_control_set_parameter_value(fId, i, kData->param.ranges[i].def);
}
#endif
if (sendCallback)
{
kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, i, 0, value, nullptr);
kData->engine->callback(CALLBACK_PARAMETER_DEFAULT_CHANGED, fId, i, 0, value, nullptr);
}
}
}

#ifndef BUILD_BRIDGE
if (sendOsc)
kData->engine->osc_send_control_set_midi_program(fId, fixedIndex);
#endif

if (sendCallback)
kData->engine->callback(CALLBACK_MIDI_PROGRAM_CHANGED, fId, fixedIndex, 0, 0.0f, nullptr);

#ifdef BUILD_BRIDGE
return;



+ 29
- 12
source/backend/plugin/NativePlugin.cpp View File

@@ -1885,10 +1885,10 @@ public:

if (fDescriptor != nullptr && fDescriptor->dispatcher != nullptr)
{
fDescriptor->dispatcher(fHandle, PLUGIN_OPCODE_BUFFER_SIZE_CHANGED, 0, 0, nullptr);
fDescriptor->dispatcher(fHandle, PLUGIN_OPCODE_BUFFER_SIZE_CHANGED, 0, newBufferSize, nullptr, 0.0f);

if (fHandle2 != nullptr)
fDescriptor->dispatcher(fHandle2, PLUGIN_OPCODE_BUFFER_SIZE_CHANGED, 0, 0, nullptr);
fDescriptor->dispatcher(fHandle2, PLUGIN_OPCODE_BUFFER_SIZE_CHANGED, 0, newBufferSize, nullptr, 0.0f);
}
}

@@ -1899,21 +1899,21 @@ public:

if (fDescriptor != nullptr && fDescriptor->dispatcher != nullptr)
{
fDescriptor->dispatcher(fHandle, PLUGIN_OPCODE_SAMPLE_RATE_CHANGED, 0, 0, nullptr);
fDescriptor->dispatcher(fHandle, PLUGIN_OPCODE_SAMPLE_RATE_CHANGED, 0, 0, nullptr, newSampleRate);

if (fHandle2 != nullptr)
fDescriptor->dispatcher(fHandle2, PLUGIN_OPCODE_SAMPLE_RATE_CHANGED, 0, 0, nullptr);
fDescriptor->dispatcher(fHandle2, PLUGIN_OPCODE_SAMPLE_RATE_CHANGED, 0, 0, nullptr, newSampleRate);
}
}

void offlineModeChanged(const bool) override
void offlineModeChanged(const bool isOffline) override
{
if (fDescriptor != nullptr && fDescriptor->dispatcher != nullptr)
{
fDescriptor->dispatcher(fHandle, PLUGIN_OPCODE_OFFLINE_CHANGED, 0, 0, nullptr);
fDescriptor->dispatcher(fHandle, PLUGIN_OPCODE_OFFLINE_CHANGED, 0, isOffline ? 1 : 0, nullptr, 0.0f);

if (fHandle2 != nullptr)
fDescriptor->dispatcher(fHandle2, PLUGIN_OPCODE_OFFLINE_CHANGED, 0, 0, nullptr);
fDescriptor->dispatcher(fHandle2, PLUGIN_OPCODE_OFFLINE_CHANGED, 0, isOffline ? 1 : 0, nullptr, 0.0f);
}
}

@@ -2147,15 +2147,32 @@ protected:
return retStr.isNotEmpty() ? (const char*)retStr : nullptr;
}

intptr_t handleDispatcher(HostDispatcherOpcode opcode, int32_t index, intptr_t value, void* ptr)
intptr_t handleDispatcher(const HostDispatcherOpcode opcode, const int32_t index, const intptr_t value, void* const ptr, const float opt)
{
carla_stdout("NativePlugin::handleDispatcher(%i, %i, " P_INTPTR ", %p, %f", opcode, index, value, ptr, opt);

intptr_t ret = 0;

switch (opcode)
{
case HOST_OPCODE_NULL:
case ::HOST_OPCODE_NULL:
break;
case ::HOST_OPCODE_SET_VOLUME:
setVolume(opt, true, true);
break;
case ::HOST_OPCODE_SET_DRYWET:
setDryWet(opt, true, true);
break;
case ::HOST_OPCODE_SET_BALANCE_LEFT:
setBalanceLeft(opt, true, true);
break;
case ::HOST_OPCODE_SET_BALANCE_RIGHT:
setBalanceRight(opt, true, true);
break;
case ::HOST_OPCODE_SET_PANNING:
setPanning(opt, true, true);
break;
case HOST_OPCODE_SET_PROCESS_PRECISION:
case ::HOST_OPCODE_SET_PROCESS_PRECISION:
// TODO
break;
case HOST_OPCODE_UI_UNAVAILABLE:
@@ -2437,9 +2454,9 @@ private:
return handlePtr->handleUiSaveFile(isDir, title, filter);
}

static intptr_t carla_host_dispatcher(HostHandle handle, HostDispatcherOpcode opcode, int32_t index, intptr_t value, void* ptr)
static intptr_t carla_host_dispatcher(HostHandle handle, HostDispatcherOpcode opcode, int32_t index, intptr_t value, void* ptr, float opt)
{
return handlePtr->handleDispatcher(opcode, index, value, ptr);
return handlePtr->handleDispatcher(opcode, index, value, ptr, opt);
}

#undef handlePtr


Loading…
Cancel
Save