Convert Figma logo to code with AI

spotify logopedalboard

🎛 🔊 A Python library for audio.

5,177
260
5,177
64

Top Related Projects

7,088

Python library for audio and music analysis

3,291

a library for audio and music analysis

C++ library for audio and music analysis, description and synthesis, including Python bindings

2,854

DDSP: Differentiable Digital Signal Processing

25,598

Deezer source separation library including pretrained models.

2,506

Data manipulation and transformation for audio signal processing, powered by PyTorch

Quick Overview

Pedalboard is an open-source audio effects library developed by Spotify. It provides a simple Python interface for applying high-quality audio effects to audio files or real-time audio streams. The library is designed to be fast, efficient, and easy to use for both beginners and advanced users.

Pros

  • High-performance audio processing with minimal latency
  • Wide range of built-in audio effects and filters
  • Easy integration with popular audio libraries like librosa and pydub
  • Cross-platform compatibility (Windows, macOS, Linux)

Cons

  • Limited documentation for advanced use cases
  • Fewer effects compared to some professional audio software
  • Potential learning curve for users new to audio processing concepts

Code Examples

  1. Loading an audio file and applying effects:
import pedalboard
from pedalboard.io import AudioFile

with AudioFile('input.wav') as f:
    audio = f.read(f.frames)
    samplerate = f.samplerate

board = pedalboard.Pedalboard([
    pedalboard.Reverb(room_size=0.8),
    pedalboard.Compressor(threshold_db=-10, ratio=3),
    pedalboard.Gain(gain_db=3)
])

effected = board(audio, samplerate)

with AudioFile('output.wav', 'w', samplerate, effected.shape[0]) as f:
    f.write(effected)
  1. Real-time audio processing:
import sounddevice as sd
import numpy as np
from pedalboard import Pedalboard, Chorus, Reverb

board = Pedalboard([Chorus(), Reverb(room_size=0.5)])

def callback(indata, outdata, frames, time, status):
    if status:
        print(status)
    outdata[:] = board(indata, 44100)

with sd.Stream(channels=2, callback=callback, samplerate=44100):
    sd.sleep(10000)
  1. Creating a custom effect chain:
from pedalboard import Pedalboard, Distortion, Delay, Reverb

custom_board = Pedalboard([
    Distortion(drive_db=25),
    Delay(delay_seconds=0.5, mix=0.4),
    Reverb(room_size=0.6, wet_level=0.2)
])

processed_audio = custom_board(input_audio, sample_rate)

Getting Started

To get started with Pedalboard, follow these steps:

  1. Install Pedalboard using pip:

    pip install pedalboard
    
  2. Import the library and create a simple effect chain:

    from pedalboard import Pedalboard, Chorus, Reverb
    
    board = Pedalboard([Chorus(), Reverb(room_size=0.5)])
    
  3. Process audio with the effect chain:

    processed_audio = board(input_audio, sample_rate)
    

For more detailed information and advanced usage, refer to the official Pedalboard documentation.

Competitor Comparisons

7,088

Python library for audio and music analysis

Pros of librosa

  • More comprehensive set of audio analysis features, including spectral analysis, beat tracking, and music information retrieval
  • Extensive documentation and tutorials, making it easier for beginners to get started
  • Well-established in the academic and research communities, with numerous citations in scientific papers

Cons of librosa

  • Generally slower performance compared to Pedalboard, especially for real-time audio processing
  • Lacks built-in audio effects and processing capabilities found in Pedalboard
  • Requires additional dependencies for certain functionalities, which can complicate installation and usage

Code Comparison

librosa:

import librosa
y, sr = librosa.load('audio.wav')
librosa.feature.mfcc(y=y, sr=sr)

Pedalboard:

from pedalboard import Pedalboard, Reverb, Compressor
board = Pedalboard([Reverb(), Compressor()])
effected = board(audio, sample_rate)

The code examples highlight the different focus areas of each library. librosa emphasizes audio analysis and feature extraction, while Pedalboard concentrates on audio effects processing and manipulation. librosa's code is more concise for analysis tasks, whereas Pedalboard offers a more intuitive interface for applying audio effects.

3,291

a library for audio and music analysis

Pros of aubio

  • Longer development history and more mature codebase
  • Broader range of audio analysis features, including pitch detection and onset detection
  • Supports multiple programming languages through bindings

Cons of aubio

  • Less active development and fewer recent updates
  • More complex setup and installation process
  • Steeper learning curve for beginners

Code Comparison

aubio:

aubio_pitch_t *pitch;
pitch = new_aubio_pitch("default", 2048, 512, 44100);
aubio_pitch_do(pitch, input_buffer, output_buffer);

Pedalboard:

from pedalboard import Pedalboard, Reverb, Delay

board = Pedalboard([Reverb(), Delay()])
effected = board(audio_samples, sample_rate)

While aubio focuses on audio analysis tasks, Pedalboard is primarily designed for audio effects processing. aubio's code example demonstrates pitch detection, whereas Pedalboard's example shows how to apply audio effects. Both libraries offer different functionalities, making direct code comparison challenging.

C++ library for audio and music analysis, description and synthesis, including Python bindings

Pros of Essentia

  • More comprehensive feature extraction capabilities, including high-level music descriptors
  • Extensive library of audio analysis algorithms and tools
  • Supports multiple programming languages (C++, Python, JavaScript)

Cons of Essentia

  • Steeper learning curve due to its extensive feature set
  • Potentially slower processing speed for basic audio effects
  • More complex installation process, especially for non-Python users

Code Comparison

Essentia (Python):

import essentia.standard as es

audio = es.MonoLoader(filename='audio.wav', sampleRate=44100)()
bpm, beats = es.RhythmExtractor2013(method='multifeature')(audio)

Pedalboard (Python):

from pedalboard import Pedalboard, Reverb, Chorus

board = Pedalboard([Reverb(), Chorus()])
effected = board(audio)

Summary

Essentia offers a more comprehensive set of audio analysis tools and supports multiple programming languages, making it suitable for complex audio research and analysis tasks. However, it may have a steeper learning curve and potentially slower processing for basic effects compared to Pedalboard. Pedalboard, on the other hand, provides a simpler interface for applying audio effects and is more focused on real-time processing and music production workflows.

2,854

DDSP: Differentiable Digital Signal Processing

Pros of DDSP

  • More advanced and research-oriented, focusing on neural audio synthesis
  • Offers a wider range of audio generation and manipulation techniques
  • Integrates well with machine learning workflows and TensorFlow

Cons of DDSP

  • Steeper learning curve due to its complexity and research focus
  • Requires more computational resources for neural network processing
  • Less suitable for real-time audio processing compared to Pedalboard

Code Comparison

DDSP example:

import ddsp
import ddsp.training

# Create a synthesizer
synth = ddsp.synths.Additive()

# Generate audio
audio = synth(frequencies, amplitudes, harmonic_distribution)

Pedalboard example:

from pedalboard import Pedalboard, Reverb, Delay

# Create a pedalboard
board = Pedalboard([Reverb(), Delay()])

# Process audio
output = board(input_audio, sample_rate)

Summary

DDSP is a more advanced, research-oriented library focusing on neural audio synthesis and manipulation. It offers a wider range of techniques but has a steeper learning curve and higher computational requirements. Pedalboard, on the other hand, is more straightforward and better suited for real-time audio effects processing. The choice between the two depends on the specific use case and level of complexity required for the audio project.

25,598

Deezer source separation library including pretrained models.

Pros of Spleeter

  • Specialized in source separation, particularly for isolating vocals and instruments
  • Pre-trained models available for quick and easy use
  • Supports multiple output formats (WAV, MP3, OGG)

Cons of Spleeter

  • Limited to source separation tasks
  • Requires more computational resources for processing
  • Less frequent updates and maintenance

Code Comparison

Spleeter:

from spleeter.separator import Separator

separator = Separator('spleeter:2stems')
separator.separate_to_file('audio_example.mp3', 'output/')

Pedalboard:

from pedalboard import Pedalboard, Reverb, Distortion

board = Pedalboard([Reverb(), Distortion()])
with AudioFile('input.wav') as f:
    audio = f.read(f.frames)
    effected = board(audio, f.samplerate)

Key Differences

Spleeter focuses on source separation, while Pedalboard offers a wide range of audio effects and processing tools. Pedalboard is more versatile for general audio manipulation, whereas Spleeter excels in isolating specific elements from audio tracks. Pedalboard is actively maintained by Spotify and offers better performance for real-time processing, making it suitable for a broader range of audio applications.

2,506

Data manipulation and transformation for audio signal processing, powered by PyTorch

Pros of Audio

  • Broader scope of audio processing capabilities, including speech recognition and music information retrieval
  • Tighter integration with PyTorch ecosystem for deep learning applications
  • More extensive documentation and community support

Cons of Audio

  • Steeper learning curve, especially for users not familiar with PyTorch
  • Potentially slower performance for simple audio effects compared to Pedalboard
  • Larger dependency footprint, which may impact project size and deployment

Code Comparison

Pedalboard:

import pedalboard

board = pedalboard.Pedalboard([pedalboard.Reverb(), pedalboard.Distortion()])
effected = board(audio, sample_rate)

Audio:

import torchaudio
import torchaudio.transforms as T

effects = T.Compose([T.Reverb(), T.Overdrive()])
effected = effects(audio)

Summary

Pedalboard is more focused on real-time audio effects and simpler to use for basic tasks, while Audio offers a wider range of audio processing capabilities and better integration with deep learning workflows. The choice between them depends on the specific requirements of your project and your familiarity with PyTorch.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

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 DOI GitHub Repo stars

pedalboard is a Python library for working with audio: reading, writing, rendering, 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 loading third-party software instruments and effects.

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 and to help power features like Spotify's AI DJ and AI Voice Translation. 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
    • Live audio effects via AudioStream
  • 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® instrument and effect plugins on macOS, Windows, and Linux (pedalboard.load_plugin)
  • Supports instrument and effect 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.8, 3.9, 3.10, 3.11, 3.12, and 3.13.

  • Linux
    • Tested heavily in production use cases at Spotify
    • Tested automatically on GitHub with VSTs
    • Platform manylinux and musllinux 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

Note: If you'd rather watch a video instead of reading examples or documentation, watch Working with Audio in Python (feat. Pedalboard) on YouTube.

Quick start

from pedalboard import Pedalboard, Chorus, Reverb
from pedalboard.io import AudioFile

# Make a Pedalboard object, containing multiple audio plugins:
board = Pedalboard([Chorus(), Reverb(room_size=0.25)])

# Open an audio file for reading, just like a regular file:
with AudioFile('some-file.wav') as f:
  
  # Open an audio file to write to:
  with AudioFile('output.wav', 'w', f.samplerate, f.num_channels) as o:
  
    # Read one second of audio at a time, until the file is empty:
    while f.tell() < f.frames:
      chunk = f.read(f.samplerate)
      
      # Run the audio through our pedalboard:
      effected = board(chunk, f.samplerate, reset=False)
      
      # Write the output to our output file:
      o.write(effected)

Note: For more information about how to process audio through Pedalboard plugins, including how the reset parameter works, see the documentation for pedalboard.Plugin.process.

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 instrument and effect plugins

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:
sample_rate = 44100
audio = instrument(
  [Message("note_on", note=60), Message("note_off", note=60, time=5)],
  duration=5, # seconds
  sample_rate=sample_rate,
)

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

# ...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, sample_rate)

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

Running Pedalboard on Live Audio

pedalboard supports streaming live audio through an AudioStream object, allowing for real-time manipulation of audio by adding effects in Python.

from pedalboard import Pedalboard, Chorus, Compressor, Delay, Gain, Reverb, Phaser
from pedalboard.io import AudioStream

# Open up an audio stream:
with AudioStream(
  input_device_name="Apogee Jam+",  # Guitar interface
  output_device_name="MacBook Pro Speakers"
) as stream:
  # Audio is now streaming through this pedalboard and out of your speakers!
  stream.plugins = Pedalboard([
      Compressor(threshold_db=-50, ratio=25),
      Gain(gain_db=30),
      Chorus(),
      Phaser(),
      Convolution("./guitar_amp.wav", 1.0),
      Reverb(room_size=0.25),
  ])
  input("Press enter to stop streaming...")

# The live AudioStream is now closed, and audio has stopped.

Using Pedalboard in tf.data Pipelines

import tensorflow as tf 

sr = 48000 

# Put whatever plugins you like in here:
plugins = pedalboard.Pedalboard([pedalboard.Gain(), pedalboard.Reverb()]) 

# Make a dataset containing random noise:
# NOTE: for real training, here's where you'd want to load your audio somehow:
ds = tf.data.Dataset.from_tensor_slices([np.random.rand(sr)])

# Apply our Pedalboard instance to the tf.data Pipeline:
ds = ds.map(lambda audio: tf.numpy_function(plugins.process, [audio, sr], tf.float32)) 

# Create and train a (dummy) ML model on this audio:
model = tf.keras.models.Sequential([tf.keras.layers.InputLayer(input_shape=(sr,)), tf.keras.layers.Dense(1)])
model.compile(loss="mse") 
model.fit(ds.map(lambda effected: (effected, 1)).batch(1), epochs=10)

For more examples, see:

Contributing

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

Citing

To cite pedalboard in academic work, use its entry on Zenodo: DOI 7817838

To cite via BibTeX:

@software{sobot_peter_2023_7817838,
  author       = {Sobot, Peter},
  title        = {Pedalboard},
  month        = jul,
  year         = 2021,
  publisher    = {Zenodo},
  doi          = {10.5281/zenodo.7817838},
  url          = {https://doi.org/10.5281/zenodo.7817838}
}

License

pedalboard is Copyright 2021-2024 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.