Skip to main content

A Python library for adding effects to audio.

Project description

Pedalboard Logo

License: GPL v3 Documentation PyPI - Python Version Supported Platforms Apple Silicon support for macOS and Linux (Docker) PyPI - Wheel Test Badge Coverage Badge PyPI - Downloads GitHub Repo stars

pedalboard is a Python library for working with audio: reading, writing, adding effects, and more. It supports most popular audio file formats and a number of common audio effects out of the box, and also allows the use of VST3® and Audio Unit formats for third-party plugins.

pedalboard 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.

Documentation

Features

  • Built-in audio I/O utilities (pedalboard.io)
    • Support for reading and writing AIFF, FLAC, MP3, OGG, and WAV files on all platforms with no dependencies
    • Additional support for reading AAC, AC3, WMA, and other formats depending on platform
    • Support for on-the-fly resampling of audio files and streams with O(1) memory usage
  • Built-in support for a number of basic audio transformations, including:
    • Guitar-style effects: Chorus, Distortion, Phaser, Clipping
    • Loudness and dynamic range effects: Compressor, Gain, Limiter
    • Equalizers and filters: HighpassFilter, LadderFilter, LowpassFilter
    • Spatial effects: Convolution, Delay, Reverb
    • Pitch effects: PitchShift
    • Lossy compression: GSMFullRateCompressor, MP3Compressor
    • Quality reduction: Resample, Bitcrush
  • Supports VST3® plugins on macOS, Windows, and Linux (pedalboard.load_plugin)
  • 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 for single transforms, and 2-5x faster than SoxBindings (via iCorv)
      • Reads audio files up to 4x faster than librosa.load (in many cases)
  • Tested compatibility with TensorFlow - can be used in tf.data pipelines!

Installation

pedalboard is available via PyPI (via Platform Wheels):

pip install pedalboard  # That's it! No other dependencies required.

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, 3.9, 3.10, and 3.11 as well as experimental support for PyPy 3.7, 3.8, and 3.9.

  • Linux
    • Tested heavily in production use cases at Spotify
    • Tested automatically on GitHub with VSTs
    • Platform manylinux wheels built for x86_64 (Intel/AMD) and aarch64 (ARM/Apple Silicon)
    • 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 (x86-64, Intel/AMD)

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') 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

# Read in a whole file, resampling to our desired sample rate:
samplerate = 44100.0
with AudioFile('guitar-input.wav').resampled_to(samplerate) as f:
  audio = f.read(f.frames)

# 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:

Contributing

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

License

pedalboard is Copyright 2021-2022 Spotify AB.

pedalboard is licensed under the GNU General Public License v3. pedalboard includes a number of libraries that are statically compiled, and which carry the following licenses:

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.6.5-pp39-pypy39_pp73-win_amd64.whl (2.9 MB view hashes)

Uploaded PyPy Windows x86-64

pedalboard-0.6.5-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pedalboard-0.6.5-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

pedalboard-0.6.5-pp39-pypy39_pp73-macosx_10_13_x86_64.whl (2.5 MB view hashes)

Uploaded PyPy macOS 10.13+ x86-64

pedalboard-0.6.5-pp38-pypy38_pp73-win_amd64.whl (2.9 MB view hashes)

Uploaded PyPy Windows x86-64

pedalboard-0.6.5-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pedalboard-0.6.5-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

pedalboard-0.6.5-pp38-pypy38_pp73-macosx_10_13_x86_64.whl (2.5 MB view hashes)

Uploaded PyPy macOS 10.13+ x86-64

pedalboard-0.6.5-pp37-pypy37_pp73-win_amd64.whl (2.9 MB view hashes)

Uploaded PyPy Windows x86-64

pedalboard-0.6.5-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pedalboard-0.6.5-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

pedalboard-0.6.5-pp37-pypy37_pp73-macosx_10_13_x86_64.whl (2.5 MB view hashes)

Uploaded PyPy macOS 10.13+ x86-64

pedalboard-0.6.5-cp311-cp311-win_amd64.whl (2.9 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

pedalboard-0.6.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pedalboard-0.6.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

pedalboard-0.6.5-cp311-cp311-macosx_11_0_arm64.whl (2.3 MB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

pedalboard-0.6.5-cp311-cp311-macosx_10_13_x86_64.whl (2.5 MB view hashes)

Uploaded CPython 3.11 macOS 10.13+ x86-64

pedalboard-0.6.5-cp311-cp311-macosx_10_13_universal2.whl (4.8 MB view hashes)

Uploaded CPython 3.11 macOS 10.13+ universal2 (ARM64, x86-64)

pedalboard-0.6.5-cp310-cp310-win_amd64.whl (2.9 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

pedalboard-0.6.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pedalboard-0.6.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

pedalboard-0.6.5-cp310-cp310-macosx_11_0_arm64.whl (2.3 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

pedalboard-0.6.5-cp310-cp310-macosx_10_13_x86_64.whl (2.5 MB view hashes)

Uploaded CPython 3.10 macOS 10.13+ x86-64

pedalboard-0.6.5-cp310-cp310-macosx_10_13_universal2.whl (4.8 MB view hashes)

Uploaded CPython 3.10 macOS 10.13+ universal2 (ARM64, x86-64)

pedalboard-0.6.5-cp39-cp39-win_amd64.whl (2.9 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

pedalboard-0.6.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pedalboard-0.6.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

pedalboard-0.6.5-cp39-cp39-macosx_11_0_arm64.whl (2.3 MB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

pedalboard-0.6.5-cp39-cp39-macosx_10_13_x86_64.whl (2.6 MB view hashes)

Uploaded CPython 3.9 macOS 10.13+ x86-64

pedalboard-0.6.5-cp39-cp39-macosx_10_13_universal2.whl (4.8 MB view hashes)

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

pedalboard-0.6.5-cp38-cp38-win_amd64.whl (2.9 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

pedalboard-0.6.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pedalboard-0.6.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

pedalboard-0.6.5-cp38-cp38-macosx_11_0_arm64.whl (2.3 MB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

pedalboard-0.6.5-cp38-cp38-macosx_10_13_x86_64.whl (2.5 MB view hashes)

Uploaded CPython 3.8 macOS 10.13+ x86-64

pedalboard-0.6.5-cp38-cp38-macosx_10_13_universal2.whl (4.8 MB view hashes)

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

pedalboard-0.6.5-cp37-cp37m-win_amd64.whl (2.9 MB view hashes)

Uploaded CPython 3.7m Windows x86-64

pedalboard-0.6.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view hashes)

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

pedalboard-0.6.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

pedalboard-0.6.5-cp37-cp37m-macosx_10_13_x86_64.whl (2.5 MB view hashes)

Uploaded CPython 3.7m macOS 10.13+ x86-64

pedalboard-0.6.5-cp36-cp36m-win_amd64.whl (3.2 MB view hashes)

Uploaded CPython 3.6m Windows x86-64

pedalboard-0.6.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view hashes)

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

pedalboard-0.6.5-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ ARM64

pedalboard-0.6.5-cp36-cp36m-macosx_10_13_x86_64.whl (2.5 MB view hashes)

Uploaded CPython 3.6m macOS 10.13+ 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