Merge remote-tracking branch 'origin/main' into cpumeter

This commit is contained in:
Paolo Marrone 2024-07-30 14:23:44 +02:00
commit 7302a19c23

View File

@ -203,6 +203,10 @@ typedef struct pluginInstance {
#if DATA_PRODUCT_CHANNELS_AUDIO_OUTPUT_N > 0 #if DATA_PRODUCT_CHANNELS_AUDIO_OUTPUT_N > 0
float *outputs[DATA_PRODUCT_CHANNELS_AUDIO_OUTPUT_N]; float *outputs[DATA_PRODUCT_CHANNELS_AUDIO_OUTPUT_N];
#endif #endif
#if DATA_PRODUCT_BUSES_AUDIO_INPUT_N + DATA_PRODUCT_BUSES_AUDIO_OUTPUT_N + DATA_PRODUCT_BUSES_MIDI_INPUT_N + DATA_PRODUCT_BUSES_MIDI_OUTPUT_N > 0
// see https://github.com/steinbergmedia/vst3sdk/issues/128
char neededBusesActive;
#endif
#if DATA_PRODUCT_BUSES_AUDIO_INPUT_N > 0 #if DATA_PRODUCT_BUSES_AUDIO_INPUT_N > 0
char inputsActive[DATA_PRODUCT_BUSES_AUDIO_INPUT_N]; char inputsActive[DATA_PRODUCT_BUSES_AUDIO_INPUT_N];
#endif #endif
@ -300,21 +304,24 @@ static Steinberg_tresult pluginInitialize(void *thisInterface, struct Steinberg_
plugin_set_parameter(&p->p, parameterData[i].index, parameterData[i].def); plugin_set_parameter(&p->p, parameterData[i].index, parameterData[i].def);
} }
#endif #endif
#if DATA_PRODUCT_BUSES_AUDIO_INPUT_N > 0 #if DATA_PRODUCT_BUSES_AUDIO_INPUT_N + DATA_PRODUCT_BUSES_AUDIO_OUTPUT_N + DATA_PRODUCT_BUSES_MIDI_INPUT_N + DATA_PRODUCT_BUSES_MIDI_OUTPUT_N > 0
p->neededBusesActive = 0;
# if DATA_PRODUCT_BUSES_AUDIO_INPUT_N > 0
for (size_t i = 0; i < DATA_PRODUCT_BUSES_AUDIO_INPUT_N; i++) for (size_t i = 0; i < DATA_PRODUCT_BUSES_AUDIO_INPUT_N; i++)
p->inputsActive[i] = 0; p->inputsActive[i] = 0;
#endif # endif
#if DATA_PRODUCT_BUSES_AUDIO_OUTPUT_N > 0 # if DATA_PRODUCT_BUSES_AUDIO_OUTPUT_N > 0
for (size_t i = 0; i < DATA_PRODUCT_BUSES_AUDIO_OUTPUT_N; i++) for (size_t i = 0; i < DATA_PRODUCT_BUSES_AUDIO_OUTPUT_N; i++)
p->outputsActive[i] = 0; p->outputsActive[i] = 0;
#endif # endif
#if DATA_PRODUCT_BUSES_MIDI_INPUT_N > 0 # if DATA_PRODUCT_BUSES_MIDI_INPUT_N > 0
for (size_t i = 0; i < DATA_PRODUCT_BUSES_MIDI_INPUT_N; i++) for (size_t i = 0; i < DATA_PRODUCT_BUSES_MIDI_INPUT_N; i++)
p->midiInputsActive[i] = 0; p->midiInputsActive[i] = 0;
#endif # endif
#if DATA_PRODUCT_BUSES_MIDI_OUTPUT_N > 0 # if DATA_PRODUCT_BUSES_MIDI_OUTPUT_N > 0
for (size_t i = 0; i < DATA_PRODUCT_BUSES_MIDI_OUTPUT_N; i++) for (size_t i = 0; i < DATA_PRODUCT_BUSES_MIDI_OUTPUT_N; i++)
p->midiOutputsActive[i] = 0; p->midiOutputsActive[i] = 0;
# endif
#endif #endif
p->mem = NULL; p->mem = NULL;
#ifdef PARAM_OUT_CPU_INDEX #ifdef PARAM_OUT_CPU_INDEX
@ -470,25 +477,28 @@ static Steinberg_tresult pluginSetActive(void* thisInterface, Steinberg_TBool st
p->mem = NULL; p->mem = NULL;
} }
if (state) { if (state) {
#if DATA_PRODUCT_BUSES_AUDIO_INPUT_N > 0 #if DATA_PRODUCT_BUSES_AUDIO_INPUT_N + DATA_PRODUCT_BUSES_AUDIO_OUTPUT_N + DATA_PRODUCT_BUSES_MIDI_INPUT_N + DATA_PRODUCT_BUSES_MIDI_OUTPUT_N > 0
for (size_t i = 0; i < DATA_PRODUCT_BUSES_AUDIO_INPUT_N; i++) p->neededBusesActive = 1;
# if DATA_PRODUCT_BUSES_AUDIO_INPUT_N > 0
for (size_t i = 0; p->neededBusesActive && i < DATA_PRODUCT_BUSES_AUDIO_INPUT_N; i++)
if (!p->inputsActive[i] && (busInfoAudioInput[i].flags & Steinberg_Vst_BusInfo_BusFlags_kDefaultActive)) if (!p->inputsActive[i] && (busInfoAudioInput[i].flags & Steinberg_Vst_BusInfo_BusFlags_kDefaultActive))
return Steinberg_kResultFalse; p->neededBusesActive = 0;
#endif # endif
#if DATA_PRODUCT_BUSES_AUDIO_OUTPUT_N > 0 # if DATA_PRODUCT_BUSES_AUDIO_OUTPUT_N > 0
for (size_t i = 0; i < DATA_PRODUCT_BUSES_AUDIO_OUTPUT_N; i++) for (size_t i = 0; p->neededBusesActive && i < DATA_PRODUCT_BUSES_AUDIO_OUTPUT_N; i++)
if (!p->outputsActive[i] && (busInfoAudioOutput[i].flags & Steinberg_Vst_BusInfo_BusFlags_kDefaultActive)) if (!p->outputsActive[i] && (busInfoAudioOutput[i].flags & Steinberg_Vst_BusInfo_BusFlags_kDefaultActive))
return Steinberg_kResultFalse; p->neededBusesActive = 0;
#endif # endif
#if DATA_PRODUCT_BUSES_MIDI_INPUT_N > 0 # if DATA_PRODUCT_BUSES_MIDI_INPUT_N > 0
for (size_t i = 0; i < DATA_PRODUCT_BUSES_MIDI_INPUT_N; i++) for (size_t i = 0; p->neededBusesActive && i < DATA_PRODUCT_BUSES_MIDI_INPUT_N; i++)
if (!p->midiInputsActive[i] && (busInfoMidiInput[i].flags & Steinberg_Vst_BusInfo_BusFlags_kDefaultActive)) if (!p->midiInputsActive[i] && (busInfoMidiInput[i].flags & Steinberg_Vst_BusInfo_BusFlags_kDefaultActive))
return Steinberg_kResultFalse; p->neededBusesActive = 0;
#endif # endif
#if DATA_PRODUCT_BUSES_MIDI_OUTPUT_N > 0 # if DATA_PRODUCT_BUSES_MIDI_OUTPUT_N > 0
for (size_t i = 0; i < DATA_PRODUCT_BUSES_MIDI_OUTPUT_N; i++) for (size_t i = 0; p->neededBusesActive && i < DATA_PRODUCT_BUSES_MIDI_OUTPUT_N; i++)
if (!p->midiOutputsActive[i] && (busInfoMidiOutput[i].flags & Steinberg_Vst_BusInfo_BusFlags_kDefaultActive)) if (!p->midiOutputsActive[i] && (busInfoMidiOutput[i].flags & Steinberg_Vst_BusInfo_BusFlags_kDefaultActive))
return Steinberg_kResultFalse; p->neededBusesActive = 0;
# endif
#endif #endif
plugin_set_sample_rate(&p->p, p->sampleRate); plugin_set_sample_rate(&p->p, p->sampleRate);
size_t req = plugin_mem_req(&p->p); size_t req = plugin_mem_req(&p->p);
@ -789,27 +799,39 @@ static Steinberg_tresult pluginProcess(void* thisInterface, struct Steinberg_Vst
} }
#endif #endif
#if DATA_PRODUCT_CHANNELS_AUDIO_INPUT_N > 0 #if DATA_PRODUCT_BUSES_AUDIO_INPUT_N + DATA_PRODUCT_BUSES_AUDIO_OUTPUT_N + DATA_PRODUCT_BUSES_MIDI_INPUT_N + DATA_PRODUCT_BUSES_MIDI_OUTPUT_N > 0
const float **inputs = p->inputs; if (p->neededBusesActive) {
Steinberg_int32 ki = 0; # if DATA_PRODUCT_CHANNELS_AUDIO_INPUT_N > 0
for (Steinberg_int32 i = 0; i < data->numInputs; i++) const float **inputs = p->inputs;
for (Steinberg_int32 j = 0; j < data->inputs[i].numChannels; j++, ki++) Steinberg_int32 ki = 0;
inputs[ki] = data->inputs[i].Steinberg_Vst_AudioBusBuffers_channelBuffers32[j]; for (Steinberg_int32 i = 0; i < data->numInputs; i++)
#else for (Steinberg_int32 j = 0; j < data->inputs[i].numChannels; j++, ki++)
const float **inputs = NULL; inputs[ki] = data->inputs[i].Steinberg_Vst_AudioBusBuffers_channelBuffers32[j];
#endif # else
const float **inputs = NULL;
# endif
#if DATA_PRODUCT_CHANNELS_AUDIO_OUTPUT_N > 0 # if DATA_PRODUCT_CHANNELS_AUDIO_OUTPUT_N > 0
float **outputs = p->outputs; float **outputs = p->outputs;
Steinberg_int32 ko = 0; Steinberg_int32 ko = 0;
for (Steinberg_int32 i = 0; i < data->numOutputs; i++) for (Steinberg_int32 i = 0; i < data->numOutputs; i++)
for (Steinberg_int32 j = 0; j < data->outputs[i].numChannels; j++, ko++) for (Steinberg_int32 j = 0; j < data->outputs[i].numChannels; j++, ko++)
outputs[ko] = data->outputs[i].Steinberg_Vst_AudioBusBuffers_channelBuffers32[j]; outputs[ko] = data->outputs[i].Steinberg_Vst_AudioBusBuffers_channelBuffers32[j];
#else # else
float **outputs = NULL; float **outputs = NULL;
#endif # endif
plugin_process(&p->p, inputs, outputs, data->numSamples); plugin_process(&p->p, inputs, outputs, data->numSamples);
} else {
# if DATA_PRODUCT_CHANNELS_AUDIO_OUTPUT_N > 0
for (Steinberg_int32 i = 0; i < data->numOutputs; i++)
for (Steinberg_int32 j = 0; j < data->outputs[i].numChannels; j++)
memset(data->outputs[i].Steinberg_Vst_AudioBusBuffers_channelBuffers32[j], 0, data->numSamples * sizeof(float));
# endif
}
#else
plugin_process(&p->p, NULL, NULL, data->numSamples);
#endif
processParams(p, data, 0); processParams(p, data, 0);