pedalboard
pedalboard copied to clipboard
Plugin with different number of input and output channels
Is it possible to use plugins with different numbers of input and output channels? I just tried to load a VST3 plugin and I got this error:
ValueError: Plugin 'foo' does not support 2-channel input and output. (Main bus currently expects 2 input channels and 7 output channels.)
Unfortunately not, at the moment: Pedalboard assumes that all audio plugins output the same shape of audio (i.e.: the same length of audio and the same number of channels). It tries to "ask" each plugin to reconfigure itself to match the number of channels provided, but not all plugins comply with that request.
Out of curiosity, which plugin takes 2 channels and returns 7 channels? I've never seen a configuration like that and it could be useful to test with.
This kind of configuration is typical of upmixer/downmixer plugins. In this case I'm trying to load an upmixer (developed in-house at my company for a research project) that takes in stereo Left/Right, does a bunch of processing and then outputs Left/Right/Center/SideLeft/SideRight/RearLeft/RearRight.
Good to know, thanks! It wouldn't be very hard to add support for different input and output channel counts in Pedalboard, now that I think about it; the hardest part might actually be finding plugins to test with.
That's great to hear, I think it would definitely be a worthwhile addition. If you need something for testing I could create a simple upmixer plugin in JUCE that takes stereo L/R and outputs L=L, R=R and C=(L+R)*0.5. I'll share it when it's ready.
@psobot I created a basic upmixer VST3 plugin using JUCE - it takes in stereo and outputs left/right/centre.
Code can be found here - https://github.com/my1e5/audio-plugins
Also under Releases you can find a copy of the .vst3
Plugin 'Voloco' does not support 1-channel input and output. (Main bus currently expects 1 input channels and 2 output channels.
Download: https://resonantcavity.com/plugin/
Just lifting this for a use-case that we have at Darkglass
We develop VSTs for in-house DSP validation and testing, and we're creating regression tests that use some of our intermediate audio streams for checking success criteria. For these cases we are exposing a lot of channels of output audio (mono in, mono out, and a dozen debug audio channels out). I thought of Pedalboard for automating the collection of this data since I like writing tests in Python. For this purpose I'd like to run Pedalboard with 1 channel in and a dozen out.
It might be easier to just write my own standalone executable DSP wrappers, but if you have a hint on where to start with the Pedalboard implementation, I'd be interested on extending those capabilities of the library
There are a number of things to consider when changing Pedalboard to support this feature. Pedalboard currently passes a single mutable I/O buffer to all plugins in a process
call, which is the main technical limitation as to why we can't support variable numbers of channels today; that I/O buffer can't have a variable number of channels. That code path is also used by all calls to process
(i.e.: __call__
) - whether a single plugin is being run on its own, or multiple plugins are being run in series.
There are two main paths forward that I can see:
-
Allow a different number of input and output channels only when a single plugin is passed to
process
. This would be fairly simple to implement and would solve the basic case, but would prevent users from processing audio through valid plugin chains that contain different audio shapes (i.e.:in -> [mono input, stereo output] -> [stereo input, stereo output] -> out
). This is probably a good place to start. -
Implement the logic required to check that each plugin in a chain can be configured to run with the number of input channels to match the previous plugin's output. This can be tricky, as many VSTs and AUs can support different numbers of input and output channels; Pedalboard currently doesn't allow a user to specify the number of input and output channels for each plugin.
We would have to add an additional API that allows users to specify the channel configuration a plugin should use in these situations, while still resorting to useful and error-free defaults. (e.g.: plugin 1 supports mono or stereo output, and plugin 2 supports mono or stereo input. What number of channels should be used by default between the two plugins if the user doesn't specify anything?)
There may be other ways to implement this functionality without major changes to Pedalboard's API or internals, but these are the simplest two approaches I've been able to think through so far. Happy to review code and accept pull requests that implement either of these solutions (or any solution that meets these constraints, really).
I've recently encountered this with Waves RVerb Mono/Stereo and was wondering if anyone has attempted #1 suggested by @psobot above? I'm thinking if Pedalboard can allow num_input_channels != num_output_channels, then whenever my code detects that case (something I'd have to add to Pedalboard I think) then I could create multiple boards and feed the output from one into the next, possibly squashing or duplicating channels in between.
The juce::AudioBuffer only has a single parameter for channel count so I think this isn't just as simple as making the setNumChannels call in ExternalPlugin::detectReloadType survivable.