simplied state sync in lv2 + implemented it in vst3
This commit is contained in:
parent
5663b4389c
commit
efd6033c4b
@ -331,6 +331,7 @@ static void run(LV2_Handle instance, uint32_t sample_count) {
|
|||||||
|
|
||||||
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
# ifdef DATA_STATE_DSP_CUSTOM
|
# ifdef DATA_STATE_DSP_CUSTOM
|
||||||
|
char do_set;
|
||||||
if (!atomic_flag_test_and_set(&i->sync_lock_flag)) {
|
if (!atomic_flag_test_and_set(&i->sync_lock_flag)) {
|
||||||
if (!i->synced) {
|
if (!i->synced) {
|
||||||
if (i->loaded) {
|
if (i->loaded) {
|
||||||
@ -349,28 +350,23 @@ static void run(LV2_Handle instance, uint32_t sample_count) {
|
|||||||
i->synced = 1;
|
i->synced = 1;
|
||||||
i->loaded = 0;
|
i->loaded = 0;
|
||||||
atomic_flag_clear(&i->sync_lock_flag);
|
atomic_flag_clear(&i->sync_lock_flag);
|
||||||
|
do_set = 1;
|
||||||
|
} else
|
||||||
|
do_set = 0;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_INPUTS_N; j++) {
|
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_INPUTS_N; j++) {
|
||||||
if (i->c[j] == NULL)
|
if (i->c[j] == NULL)
|
||||||
continue;
|
continue;
|
||||||
float v = adjust_param(j, *i->c[j]);
|
float v = adjust_param(j, *i->c[j]);
|
||||||
if (v != i->params[j]) {
|
if (v != i->params[j]) {
|
||||||
i->params[j] = v;
|
i->params[j] = v;
|
||||||
plugin_set_parameter(&i->p, param_data[j].index, v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# ifdef DATA_STATE_DSP_CUSTOM
|
# ifdef DATA_STATE_DSP_CUSTOM
|
||||||
} else {
|
if (do_set)
|
||||||
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_INPUTS_N; j++) {
|
# endif
|
||||||
if (i->c[j] == NULL)
|
plugin_set_parameter(&i->p, param_data[j].index, v);
|
||||||
continue;
|
|
||||||
float v = adjust_param(j, *i->c[j]);
|
|
||||||
if (v != i->params[j])
|
|
||||||
i->params[j] = v;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DATA_PRODUCT_MIDI_INPUTS_N > 0
|
#if DATA_PRODUCT_MIDI_INPUTS_N > 0
|
||||||
|
@ -669,6 +669,7 @@ static Steinberg_tresult pluginSetState(void* thisInterface, struct Steinberg_IB
|
|||||||
};
|
};
|
||||||
int err = plugin_state_load(&cbs, data, length);
|
int err = plugin_state_load(&cbs, data, length);
|
||||||
#else
|
#else
|
||||||
|
// we need to provide a default implementation because of certain hosts (e.g. Ardour)
|
||||||
int err = 0;
|
int err = 0;
|
||||||
if (length != DATA_PRODUCT_PARAMETERS_IN_N * 4) {
|
if (length != DATA_PRODUCT_PARAMETERS_IN_N * 4) {
|
||||||
if (data)
|
if (data)
|
||||||
@ -723,6 +724,7 @@ static Steinberg_tresult pluginGetState(void* thisInterface, struct Steinberg_IB
|
|||||||
};
|
};
|
||||||
int err = plugin_state_save(&p->p, &cbs);
|
int err = plugin_state_save(&p->p, &cbs);
|
||||||
#else
|
#else
|
||||||
|
// we need to provide a default implementation because of certain hosts (e.g. Ardour)
|
||||||
int err = 0;
|
int err = 0;
|
||||||
# if DATA_PRODUCT_PARAMETERS_IN_N > 0
|
# if DATA_PRODUCT_PARAMETERS_IN_N > 0
|
||||||
size_t length = DATA_PRODUCT_PARAMETERS_IN_N * 4;
|
size_t length = DATA_PRODUCT_PARAMETERS_IN_N * 4;
|
||||||
@ -865,6 +867,31 @@ static Steinberg_tresult pluginSetProcessing(void* thisInterface, Steinberg_TBoo
|
|||||||
|
|
||||||
static void processParams(pluginInstance *p, struct Steinberg_Vst_ProcessData *data, char before) {
|
static void processParams(pluginInstance *p, struct Steinberg_Vst_ProcessData *data, char before) {
|
||||||
#if DATA_PRODUCT_PARAMETERS_IN_N + DATA_PRODUCT_BUSES_MIDI_INPUT_N > 0
|
#if DATA_PRODUCT_PARAMETERS_IN_N + DATA_PRODUCT_BUSES_MIDI_INPUT_N > 0
|
||||||
|
# ifdef DATA_STATE_DSP_CUSTOM
|
||||||
|
char do_set;
|
||||||
|
if (!atomic_flag_test_and_set(&p->syncLockFlag)) {
|
||||||
|
if (!p->synced) {
|
||||||
|
if (p->loaded) {
|
||||||
|
for (uint32_t j = 0; j < DATA_PRODUCT_PARAMETERS_IN_N; j++) {
|
||||||
|
p->parametersIn[j] = p->parametersInSync[j];
|
||||||
|
plugin_set_parameter(&p->p, parameterInData[j].index, p->parametersIn[j]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (uint32_t j = 0; j < DATA_PRODUCT_PARAMETERS_IN_N; j++)
|
||||||
|
if (p->parametersIn[j] != p->parametersInSync[j]) {
|
||||||
|
p->parametersInSync[j] = p->parametersIn[j];
|
||||||
|
plugin_set_parameter(&p->p, parameterInData[j].index, p->parametersIn[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p->synced = 1;
|
||||||
|
p->loaded = 0;
|
||||||
|
atomic_flag_clear(&p->syncLockFlag);
|
||||||
|
do_set = 1;
|
||||||
|
} else
|
||||||
|
do_set = 0;
|
||||||
|
# endif
|
||||||
|
|
||||||
if (data->inputParameterChanges == NULL)
|
if (data->inputParameterChanges == NULL)
|
||||||
return;
|
return;
|
||||||
Steinberg_int32 n = data->inputParameterChanges->lpVtbl->getParameterCount(data->inputParameterChanges);
|
Steinberg_int32 n = data->inputParameterChanges->lpVtbl->getParameterCount(data->inputParameterChanges);
|
||||||
@ -924,7 +951,10 @@ static void processParams(pluginInstance *p, struct Steinberg_Vst_ProcessData *d
|
|||||||
v = parameterAdjust(parameterInData + ii, parameterMap(parameterInData + ii, v));
|
v = parameterAdjust(parameterInData + ii, parameterMap(parameterInData + ii, v));
|
||||||
if (v != p->parametersIn[ii]) {
|
if (v != p->parametersIn[ii]) {
|
||||||
p->parametersIn[ii] = v;
|
p->parametersIn[ii] = v;
|
||||||
plugin_set_parameter(&p->p, parameterInData[ii].index, v);
|
# ifdef DATA_STATE_DSP_CUSTOM
|
||||||
|
if (do_set)
|
||||||
|
# endif
|
||||||
|
plugin_set_parameter(&p->p, parameterInData[ii].index, v);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
@ -1798,6 +1828,7 @@ static Steinberg_tresult controllerSetComponentState(void* thisInterface, struct
|
|||||||
};
|
};
|
||||||
int err = plugin_state_load(&cbs, data, length);
|
int err = plugin_state_load(&cbs, data, length);
|
||||||
#else
|
#else
|
||||||
|
// we need to provide a default implementation because of certain hosts (e.g. Reaper)
|
||||||
int err = 0;
|
int err = 0;
|
||||||
# if DATA_PRODUCT_PARAMETERS_IN_N > 0
|
# if DATA_PRODUCT_PARAMETERS_IN_N > 0
|
||||||
for (size_t i = 0; i < DATA_PRODUCT_PARAMETERS_IN_N; i++) {
|
for (size_t i = 0; i < DATA_PRODUCT_PARAMETERS_IN_N; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user