11

I've noticed that some open source DAWs such as Ardour and Audacity are able to access audio plugins (e.g. VST, AU) that the user has installed on their system. This makes me think that "there ought to be a way" to do this in general.

Specifically, I'd like to call some plugins from within my own audio-processing application, which I'm writing in Python. Is there a recommended method or library that one can use for this?

My own searches have turned up nearly nothing. The only relevant post I've seen is this one but it's 5 years old. There is some mention of using JUCE and there are some 2-year-old Python bindings called PyJUCE (which seem to be setup for Windows), but so far I haven't gotten anything working, mostly due my poor acclimation to the sheer "bulk" of JUCE.

Any suggestions?

Perhaps the only remaining option is to start from scratch by writing one's own VST host, and then proceed as one would when calling any external C++ code from within Python. I just thought I'd ask before reinventing the wheel, because it's often the case that "whatever you want to do, someone else has already written a Python package for it." ;-)

sh37211
  • 1,411
  • 1
  • 17
  • 39

5 Answers5

8

...Two years later, here's an answer:

Igor Gadelha wrote a GitHub repo dpm that includes his vstRender class, which he wrote in JUCE. Currently it only works for mono plugins. I wrote some simple code to illustrate how to use vstRender, which Igor included in his "contrib" section: run_plugin.py.

sh37211
  • 1,411
  • 1
  • 17
  • 39
  • Has it been made to work on stereo plugins or at least one of the channels? What about VSTis with a MIDI input also? P.S. Thanks for the answer, it is all I could find. – Tony Jul 30 '20 at 02:30
  • For VSTis you could take a look at RenderMan by Leon Fedden https://github.com/fedden/RenderMan but I don't know what sort of inputs it takes. – sh37211 Jul 30 '20 at 06:23
  • Thank you... how did you install the libraries? – Tony Jul 30 '20 at 14:30
  • 1
    Another update: Spotify just released "Pedalboard" that can run VST3 and even AudioUnit! https://stackoverflow.com/questions/37555711/how-to-call-audio-plugins-from-within-python – sh37211 Sep 07 '21 at 17:01
  • Woops, had the wrong URL in the queue. Meant to link here: https://engineering.atspotify.com/2021/09/07/introducing-pedalboard-spotifys-audio-effects-library-for-python/ – sh37211 Sep 07 '21 at 17:13
6

Spotify has released pedalboard, a pip-installable Python library based on JUCE with support for loading and running audio plugins on macOS, Windows, and Linux. VST3 plugins are supported on all platforms, and Audio Units are supported on macOS. (As of September 2021, Pedalboard only supports audio effects, but contributors may add support for instrument plug-ins in the future.)

An example of using pedalboard:

# After installing with `pip install pedalboard`:

import soundfile as sf
from pedalboard import Pedalboard, Compressor, Chorus, Distortion, Reverb

audio, sample_rate = soundfile.read('some-file.wav')

# Make a Pedalboard object, containing multiple plugins:
board = Pedalboard([
    Compressor(threshold_db=-50, ratio=25),
    Distortion(drive_db=30),
    Chorus(),
    load_plugin("./VSTs/SomePlugin.vst3"), # Load a VST3 plugin
    Reverb(room_size=0.25),
], sample_rate=sample_rate)

# Run the audio through this pedalboard!
effected = board(audio)
Peter Sobot
  • 2,476
  • 21
  • 20
5

The other libraries shared are great. I want to share DawDreamer, which I developed as an evolution of Renderman. It has many features:

  • Composing graphs of audio processors (not just a single linear chain)
  • Audio playback
  • VST2 instruments (some VST3 instruments may not work at the moment)
  • VST2 and VST3 effects
  • FAUST effects and polyphonic instruments
  • Time-stretching and looping according to Ableton Live warp markers
  • Pitch-warping (with Rubberband Library)
  • Parameter automation
  • Rendering multiple processors simultaneously
  • Full support on Linux (Dockerfile), macOS, and Windows
  • pip/PyPi installation

Some people have expressed an interest in LV2 plugins, which I haven't tested. I would suggest trying Faust as an open-source alternative, but I'll get to testing LV2 too.

I hope to demonstrate a reinforcement learning environment soon.

David Braun
  • 782
  • 1
  • 9
  • 18
0

A couple years back I wrote some Python code to load a synth VST, tweak its parameters and generate sound for a given note/velocity/duration. It's pretty limited but could be a starting point.

Because VST 2.4 is in good old C, I could write the whole thing in pure Python, using the ctypes standard library. This however has the drawback of not supporting VST 3.

simlmx
  • 999
  • 12
  • 17
0

Just for a record, Pedalboard was supported for instrument plugins introduced in v0.7.4.

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 28 '23 at 15:54
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/34747675) – Koedlt Jul 31 '23 at 12:19