Skip to main content

A Python library for adding effects to audio.

Project description

Pedalboard Logo

License: GPL v3 PyPI - Python Version Supported Platforms Apple Silicon supported PyPI - Wheel Test Badge Coverage Badge PyPI - Downloads GitHub Repo stars

pedalboard is a Python library for adding effects to audio. It supports a number of common audio effects out of the box, and also allows the use of VST3® and Audio Unit plugin formats for third-party effects. It was built by Spotify's Audio Intelligence Lab to enable using studio-quality audio effects from within Python and TensorFlow.

Internally at Spotify, pedalboard is used for data augmentation to improve machine learning models. pedalboard also helps in the process of content creation, making it possible to add effects to audio without using a Digital Audio Workstation.

Usage

  • Built-in support for a number of basic audio transformations:
    • Convolution
    • Compressor
    • Chorus
    • Distortion
    • Gain
    • HighpassFilter
    • LadderFilter
    • Limiter
    • LowpassFilter
    • Phaser
    • Reverb
  • Supports VST3® plugins on macOS, Windows, and Linux
  • Supports Audio Units on macOS
  • Strong thread-safety, memory usage, and speed guarantees
    • Releases Python's Global Interpreter Lock (GIL) to allow use of multiple CPU cores
      • No need to use multiprocessing!
    • Even when only using one thread:
      • Processes audio up to 300x faster than pySoX
  • Tested compatibility with TensorFlow - can be used in tf.data pipelines!

Installation

pedalboard is available via PyPI (via Platform Wheels):

pip install pedalboard

If you are new to Python, follow INSTALLATION.md for a robust guide.

Compatibility

pedalboard is thoroughly tested with Python 3.6, 3.7, 3.8, and 3.9, as well as experimental support for PyPy 7.3.

  • Linux
    • Tested heavily in production use cases at Spotify
    • Tested automatically on GitHub with VSTs
    • Platform manylinux wheels built for x86_64
    • Most Linux VSTs require a relatively modern Linux installation (with glibc > 2.27)
  • macOS
    • Tested manually with VSTs and Audio Units
    • Tested automatically on GitHub with VSTs
    • Platform wheels available for both Intel and Apple Silicon
    • Compatible with a wide range of VSTs and Audio Units
  • Windows
    • Tested automatically on GitHub with VSTs
    • Platform wheels available for amd64 (Intel/AMD)

Plugin Compatibility

pedalboard allows loading VST3® and Audio Unit plugins, which could contain any code. Most plugins that have been tested work just fine with pedalboard, but some plugins may not work with pedalboard; at worst, some may even crash the Python interpreter without warning and with no ability to catch the error. For an ever-growing compatibility list, see COMPATIBILITY.md.

Most audio plugins are "well-behaved" and conform to a set of conventions for how audio plugins are supposed to work, but many do not conform to the VST3® or Audio Unit specifications. pedalboard attempts to detect some common programming errors in plugins and can work around many issues, including automatically detecting plugins that don't clear their internal state when asked. Even so, plugins can misbehave without pedalboard noticing.

If audio is being rendered incorrectly or if audio is "leaking" from one process() call to the next in an undesired fashion, try:

  1. Passing silence to the plugin in between calls to process(), to ensure that any reverb tails or other internal state has time to fade to silence
  2. Reloading the plugin every time audio is processed (with pedalboard.load_plugin)

Examples

A very basic example of how to use pedalboard's built-in plugins:

import soundfile as sf
from pedalboard import (
    Pedalboard,
    Convolution,
    Compressor,
    Chorus,
    Gain,
    Reverb,
    Limiter,
    LadderFilter,
    Phaser,
)

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

# Make a Pedalboard object, containing multiple plugins:
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),
], sample_rate=sample_rate)

# 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())

# Run the audio through this pedalboard!
effected = board(audio)

# Write the audio back as a wav file:
with sf.SoundFile('./processed-output-stereo.wav', 'w', samplerate=sample_rate, channels=len(effected.shape)) as f:
    f.write(effected)

Loading a VST3® plugin and manipulating its parameters

import soundfile as sf
from pedalboard import Pedalboard, Reverb, load_plugin

# Load a VST3 package 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:
audio, sample_rate = sf.read('some-file.wav')
effected = vst(audio, sample_rate=sample_rate)

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

For more examples, see:

Contributing

Contributions to pedalboard are welcomed! See CONTRIBUTING.md for details.

License

pedalboard is Copyright 2021 Spotify AB.

pedalboard is licensed under the GNU General Public License v3, because:

VST is a registered trademark of Steinberg Media Technologies GmbH.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pedalboard-0.3.7-pp37-pypy37_pp73-win_amd64.whl (2.5 MB view hashes)

Uploaded PyPy Windows x86-64

pedalboard-0.3.7-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (3.9 MB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ x86-64

pedalboard-0.3.7-pp37-pypy37_pp73-macosx_10_9_x86_64.whl (3.0 MB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

pedalboard-0.3.7-cp39-cp39-win_amd64.whl (2.5 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

pedalboard-0.3.7-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (3.9 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

pedalboard-0.3.7-cp39-cp39-macosx_10_9_x86_64.whl (3.0 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

pedalboard-0.3.7-cp39-cp39-macosx_10_9_universal2.whl (5.7 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)

pedalboard-0.3.7-cp38-cp38-win_amd64.whl (2.5 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

pedalboard-0.3.7-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (3.9 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

pedalboard-0.3.7-cp38-cp38-macosx_10_9_x86_64.whl (3.0 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

pedalboard-0.3.7-cp38-cp38-macosx_10_9_universal2.whl (5.7 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64)

pedalboard-0.3.7-cp37-cp37m-win_amd64.whl (2.5 MB view hashes)

Uploaded CPython 3.7m Windows x86-64

pedalboard-0.3.7-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (3.9 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

pedalboard-0.3.7-cp37-cp37m-macosx_10_9_x86_64.whl (3.0 MB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

pedalboard-0.3.7-cp36-cp36m-win_amd64.whl (2.5 MB view hashes)

Uploaded CPython 3.6m Windows x86-64

pedalboard-0.3.7-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (3.9 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

pedalboard-0.3.7-cp36-cp36m-macosx_10_9_x86_64.whl (3.0 MB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page