Browse Source

Merge branch '1.0.x'

tags/1.9.4
falkTX 11 years ago
parent
commit
f9e4511d6c
1 changed files with 84 additions and 50 deletions
  1. +84
    -50
      source/backend/plugin/CarlaPlugin.cpp

+ 84
- 50
source/backend/plugin/CarlaPlugin.cpp View File

@@ -1453,10 +1453,18 @@ 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)
{
@@ -1465,36 +1473,33 @@ 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)
{
// FIXME?
kData->param.ranges[i].def = getParameterValue(i);
kData->param.ranges[i].fixDefault();
const float value(kData->param.ranges[i].fixValue(getParameterValue(i)));

#ifndef BUILD_BRIDGE
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
}
}
kData->param.ranges[i].def = value;

if (sendOsc || sendCallback)
{
#ifndef BUILD_BRIDGE
if (sendOsc)
kData->engine->osc_send_control_set_program(fId, fixedIndex);
kData->engine->osc_send_control_set_default_value(fId, i, value);
kData->engine->osc_send_control_set_parameter_value(fId, i, value);
#endif

if (sendCallback)
kData->engine->callback(CALLBACK_PROGRAM_CHANGED, fId, fixedIndex, 0, 0.0f, nullptr);
kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, i, 0, value, nullptr);
kData->engine->callback(CALLBACK_PARAMETER_DEFAULT_CHANGED, fId, i, 0, value, nullptr);
}
}
}

#ifdef BUILD_BRIDGE
return;

// unused
(void)sendGui;
(void)sendOsc;
#endif
}

@@ -1508,10 +1513,18 @@ 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
@@ -1519,40 +1532,33 @@ void CarlaPlugin::setMidiProgram(int32_t index, const bool sendGui, const bool s
uiMidiProgramChange(fixedIndex);
#endif

// Change default parameter values (sound banks never change defaults)
if (type() != PLUGIN_GIG && type() != PLUGIN_SF2 && type() != PLUGIN_SFZ)
if (type() == PLUGIN_GIG || type() == PLUGIN_SF2 || type() == PLUGIN_SFZ)
return;

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

kData->param.ranges[i].def = value;

if (sendOsc || sendCallback)
{
#ifndef BUILD_BRIDGE
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);
}
kData->engine->osc_send_control_set_default_value(fId, i, value);
kData->engine->osc_send_control_set_parameter_value(fId, i, value);
#endif

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;

// unused
(void)sendGui;
(void)sendOsc;
#endif
}

@@ -2015,15 +2021,29 @@ void CarlaPlugin::postRtEventsRun()
#ifndef BUILD_BRIDGE
// Update OSC control client
if (kData->engine->isOscControlRegistered())
{
kData->engine->osc_send_control_set_program(fId, event.value1);

for (uint32_t j=0; j < kData->param.count; ++j)
kData->engine->osc_send_control_set_default_value(fId, j, kData->param.ranges[j].def);
}

// Update Host
kData->engine->callback(CALLBACK_PROGRAM_CHANGED, fId, event.value1, 0, 0.0f, nullptr);

// Update param values
{
const bool sendOsc(kData->engine->isOscControlRegistered());

for (uint32_t j=0; j < kData->param.count; ++j)
{
const float value(getParameterValue(j));

if (sendOsc)
{
kData->engine->osc_send_control_set_parameter_value(fId, j, value);
kData->engine->osc_send_control_set_default_value(fId, j, kData->param.ranges[j].def);
}

kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, j, 0, value, nullptr);
kData->engine->callback(CALLBACK_PARAMETER_DEFAULT_CHANGED, fId, j, 0, kData->param.ranges[j].def, nullptr);
}
}
#endif
break;

@@ -2035,15 +2055,29 @@ void CarlaPlugin::postRtEventsRun()
#ifndef BUILD_BRIDGE
// Update OSC control client
if (kData->engine->isOscControlRegistered())
{
kData->engine->osc_send_control_set_midi_program(fId, event.value1);

for (uint32_t j=0; j < kData->param.count; ++j)
kData->engine->osc_send_control_set_default_value(fId, j, kData->param.ranges[j].def);
}

// Update Host
kData->engine->callback(CALLBACK_MIDI_PROGRAM_CHANGED, fId, event.value1, 0, 0.0f, nullptr);

// Update param values
{
const bool sendOsc(kData->engine->isOscControlRegistered());

for (uint32_t j=0; j < kData->param.count; ++j)
{
const float value(getParameterValue(j));

if (sendOsc)
{
kData->engine->osc_send_control_set_parameter_value(fId, j, value);
kData->engine->osc_send_control_set_default_value(fId, j, kData->param.ranges[j].def);
}

kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, j, 0, value, nullptr);
kData->engine->callback(CALLBACK_PARAMETER_DEFAULT_CHANGED, fId, j, 0, kData->param.ranges[j].def, nullptr);
}
}
#endif
break;



Loading…
Cancel
Save