spotify / pedalboard

🎛 🔊 A Python library for audio.
https://spotify.github.io/pedalboard
GNU General Public License v3.0
4.96k stars 249 forks source link

Have own JUCE plugin recognized as Instrument #255

Open DamRsn opened 9 months ago

DamRsn commented 9 months ago

Thanks for making this amazing library!

I'm working on building a synth with JUCE and I'd like to be able to use it from Python with pedalboard. But I'm having issues loading the VST3.

When I load it, it gets detected as an effect. After browsing pedalboard's code a bit, I realized that this was determined by whether the plugin accepts audio in the main input buses. This was the case for me as I had something like this:

AudioProcessor()
    : AudioProcessor(BusesProperties()
                         .withInput("Input", AudioChannelSet::stereo(), true))
                         .withOutput("Output", AudioChannelSet::stereo(), true))

So I removed the .withInput("Input", AudioChannelSet::stereo(), true)).

But when I try to load this new version of the plugin (with 0 channels as input), I get an exception from pedalboard coming from ExternalPlugin.h (setNumChannels() , line 741) saying:

Plugin '...' does not support 2-channel output. (Main bus currently expects 0 input channels and 2 output channels.)

It seems that this function tries to make the number of input and output channels (from the main bus) match, I'm not sure why. Perhaps mainInputBus should be nullptr for an instrument? In this case, the number of main input channels would not be modified.

As a dirty fix, I've added this to the setNumChannels() function, and with that I can load my plugin as an instrument:

if (mainInputBus->getNumberOfChannels() == 0)
      return;

Do you know how I can have my plugin recognized as an instrument properly?

Ideally I'd like to be able to keep my original busesProperties to stereo/stereo. Maybe load_plugin could have another argument is_instrument=None, that is used only if set to true or false to determine the type of plugin.

Anyway thanks for your help!

jorshi commented 8 months ago

@DamRsn -- in your ProJucer / Cmake do you have the IS_SYNTH flag set to TRUE? I was able to get pedalboard to recognize my JUCE synth with this.

I encountered a slightly different (but related) problem where I have a plugin that accepts audio as input, but can also accept midi. It seems like pedalboard treats plugins as either an audio effect or a synth, but not both, even though it is possible to congifure a plugin like this