Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for external instrument plugins. #225

Merged
merged 7 commits into from
Jun 15, 2023

Conversation

psobot
Copy link
Member

@psobot psobot commented Jun 13, 2023

Closes #18 and #220.

This PR allows Pedalboard to load and run third-party (VST/AU) instrument plugins, in addition to its existing support for effect plugins.

To accommodate this, this PR adds:

  • a new __call__ method on ExternalPlugin that takes MIDI messages as input, rather than audio.
  • new is_instrument and is_effect properties on Plugin that allow users to determine if any instance of Plugin is an instrument plugin (i.e.: accepts only MIDI as input, returns audio) or an effect plugin (accepts audio and returns audio).
  • a vendored copy of Magical8BitPlug2, a great GPLv3 instrument VST, to be used in tests on macOS and Windows.

TODO:

  • Ensure documentation is comprehensive for instrument plugin support
  • Update README
  • Test with a variety of commercial VST3 plugins
  • Ensure instrument plugins cannot be added to AudioStream objects
  • Test multi-threaded rendering of MIDI to audio

Example usage:

from pedalboard import Pedalboard, Reverb, load_plugin
from pedalboard.io import AudioFile
from mido import Message # not part of Pedalboard, but convenient!

# Load a VST3 or Audio Unit plugin from a known path on disk:
instrument = load_plugin("./VSTs/Magical8BitPlug2.vst3")
effect = load_plugin("./VSTs/RoughRider3.vst3")

print(effect.parameters.keys())
# dict_keys([
#   'sc_hpf_hz', 'input_lvl_db', 'sensitivity_db',
#   'ratio', 'attack_ms', 'release_ms', 'makeup_db',
#   'mix', 'output_lvl_db', 'sc_active',
#   'full_bandwidth', 'bypass', 'program',
# ])

# Set the "ratio" parameter to 15
effect.ratio = 15

# Render some audio by passing MIDI to an instrument:
samplerate = 44100
audio = instrument(
  [Message("note_on", note=60), Message("note_off", note=60, time=5)],
  samplerate,
  duration=5, # seconds
)

# Apply effects to this audio:
effected = effect(audio, samplerate)

# ...or put the effect into a chain with other plugins:
board = Pedalboard([effect, Reverb()])
# ...and run that pedalboard with the same VST instance!
effected = board(audio, samplerate)

@psobot psobot force-pushed the psobot/add-midi-note-support branch from b89d02f to e751a59 Compare June 14, 2023 14:09
@psobot psobot marked this pull request as ready for review June 15, 2023 14:00
@psobot psobot merged commit e275780 into master Jun 15, 2023
25 checks passed
@psobot psobot deleted the psobot/add-midi-note-support branch June 15, 2023 17:30
@psobot psobot mentioned this pull request Jun 15, 2023
@tekkno-primitiv
Copy link

Whoooa!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Request] Midi support
2 participants