Examples#
Quick start#
from pedalboard import Pedalboard, Chorus, Reverb
from pedalboard.io import AudioFile
# Read in a whole audio file:
with AudioFile('some-file.wav', 'r') as f:
audio = f.read(f.frames)
samplerate = f.samplerate
# Make a Pedalboard object, containing multiple plugins:
board = Pedalboard([Chorus(), Reverb(room_size=0.25)])
# Run the audio through this pedalboard!
effected = board(audio, samplerate)
# Write the audio back as a wav file:
with AudioFile('processed-output.wav', 'w', samplerate, effected.shape[0]) as f:
f.write(effected)
Making a guitar-style pedalboard#
# Don't do import *! (It just makes this example smaller)
from pedalboard import *
from pedalboard.io import AudioFile
with AudioFile('guitar-input.wav', 'r') as f:
audio = f.read(f.frames)
samplerate = f.samplerate
# Make a pretty interesting sounding guitar pedalboard:
board = Pedalboard([
Compressor(threshold_db=-50, ratio=25),
Gain(gain_db=30),
Chorus(),
LadderFilter(mode=LadderFilter.Mode.HPF12, cutoff_hz=900),
Phaser(),
Convolution("./guitar_amp.wav", 1.0),
Reverb(room_size=0.25),
])
# Pedalboard objects behave like lists, so you can add plugins:
board.append(Compressor(threshold_db=-25, ratio=10))
board.append(Gain(gain_db=10))
board.append(Limiter())
# ... or change parameters easily:
board[0].threshold_db = -40
# Run the audio through this pedalboard!
effected = board(audio, samplerate)
# Write the audio back as a wav file:
with AudioFile('processed-output.wav', 'w', samplerate, effected.shape[0]) as f:
f.write(effected)
Using VST3® or Audio Unit plugins#
from pedalboard import Pedalboard, Reverb, load_plugin
from pedalboard.io import AudioFile
# Load a VST3 or Audio Unit plugin from a known path on disk:
vst = load_plugin("./VSTs/RoughRider3.vst3")
print(vst.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
vst.ratio = 15
# Use this VST to process some audio:
with AudioFile('some-file.wav', 'r') as f:
audio = f.read(f.frames)
samplerate = f.samplerate
effected = vst(audio, samplerate)
# ...or put this VST into a chain with other plugins:
board = Pedalboard([vst, Reverb()])
# ...and run that pedalboard with the same VST instance!
effected = board(audio, samplerate)
Creating parallel effects chains#
This example creates a delayed pitch-shift effect by running
multiple Pedalboards in parallel on the same audio. Pedalboard
objects are themselves Plugin
objects, so you can nest them
as much as you like:
from pedalboard import Pedalboard, Compressor, Delay, Distortion, Gain, PitchShift, Reverb, Mix
passthrough = Gain(gain_db=0)
delay_and_pitch_shift = Pedalboard([
Delay(delay_seconds=0.25, mix=1.0),
PitchShift(semitones=7),
Gain(gain_db=-3),
])
delay_longer_and_more_pitch_shift = Pedalboard([
Delay(delay_seconds=0.5, mix=1.0),
PitchShift(semitones=12),
Gain(gain_db=-6),
])
board = Pedalboard([
# Put a compressor at the front of the chain:
Compressor(),
# Run all of these pedalboards simultaneously with the Mix plugin:
Mix([
passthrough,
delay_and_pitch_shift,
delay_longer_and_more_pitch_shift,
]),
# Add a reverb on the final mix:
Reverb()
])
For more examples, see: