Add support for legacy plugins with only process()

By emulating the behavior of `processReplacing()`. Not that there should
still be any plugins around that don't support processReplacing.
This commit is contained in:
Robbert van der Helm
2020-04-22 16:51:30 +02:00
parent 2e36c64796
commit 259d23ec57
3 changed files with 21 additions and 7 deletions
+1 -1
View File
@@ -357,7 +357,7 @@ void HostBridge::process_replacing(AEffect* /*plugin*/,
const AudioBuffers request{input_buffers, sample_frames}; const AudioBuffers request{input_buffers, sample_frames};
write_object(host_vst_process_replacing, request, process_buffer); write_object(host_vst_process_replacing, request, process_buffer);
// /Write the results back to the `outputs` arrays // Write the results back to the `outputs` arrays
AudioBuffers response; AudioBuffers response;
response = response =
read_object(host_vst_process_replacing, response, process_buffer); read_object(host_vst_process_replacing, response, process_buffer);
+4 -2
View File
@@ -78,8 +78,10 @@ class HostBridge {
void* data, void* data,
float option); float option);
/** /**
* Ask the VST plugin to process audio for us. This should also be used for * Ask the VST plugin to process audio for us. If the plugin somehow does
* the deprecated 'process' function. * not support `processReplacing()` and only supports the old `process()`
* function, then this will be handled implicitely in
* `PluginBridge::handle_process_replacing()`.
*/ */
void process_replacing(AEffect* plugin, void process_replacing(AEffect* plugin,
float** inputs, float** inputs,
+16 -4
View File
@@ -201,8 +201,6 @@ void PluginBridge::handle_dispatch() {
request = request =
read_object(host_vst_process_replacing, request, process_buffer); read_object(host_vst_process_replacing, request, process_buffer);
// TODO: Check if the plugin doesn't support `processReplacing` and
// call the legacy `process` function instead
// The process functions expect a `float**` for their inputs and // The process functions expect a `float**` for their inputs and
// their outputs // their outputs
std::vector<float*> inputs; std::vector<float*> inputs;
@@ -220,8 +218,22 @@ void PluginBridge::handle_dispatch() {
outputs.push_back(buffer.data()); outputs.push_back(buffer.data());
} }
plugin->processReplacing(plugin, inputs.data(), outputs.data(), // Any plugin made in the last fifteen years or so should support
request.sample_frames); // `processReplacing`. In the off chance it does not we can just emulate
// this behavior ourselves.
if (plugin->processReplacing != nullptr) {
plugin->processReplacing(plugin, inputs.data(), outputs.data(),
request.sample_frames);
} else {
// If we zero out this buffer then the behavior is the same as
// `processReplacing``
for (std::vector<float>& buffer : output_buffers) {
std::fill(buffer.begin(), buffer.end(), 0.0);
}
plugin->process(plugin, inputs.data(), outputs.data(),
request.sample_frames);
}
AudioBuffers response{output_buffers, request.sample_frames}; AudioBuffers response{output_buffers, request.sample_frames};
write_object(host_vst_process_replacing, response, process_buffer); write_object(host_vst_process_replacing, response, process_buffer);