pedalboard
adalah pustaka Python untuk bekerja dengan audio: membaca, menulis, merender, menambahkan efek, dan banyak lagi. Ini mendukung format file audio paling populer dan sejumlah efek audio umum, dan juga memungkinkan penggunaan format VST3® dan Unit Audio untuk memuat instrumen dan efek perangkat lunak pihak ketiga.
pedalboard
dibuat oleh Audio Intelligence Lab Spotify untuk memungkinkan penggunaan efek audio berkualitas studio dari dalam Python dan TensorFlow. Secara internal di Spotify, pedalboard
digunakan untuk augmentasi data guna meningkatkan model pembelajaran mesin dan untuk membantu fitur-fitur canggih seperti AI DJ Spotify dan AI Voice Translation. pedalboard
juga membantu dalam proses pembuatan konten, sehingga memungkinkan untuk menambahkan efek pada audio tanpa menggunakan Digital Audio Workstation.
O(1)
AudioStream
Chorus
, Distortion
, Phaser
, Clipping
Compressor
, Gain
, Limiter
HighpassFilter
, LadderFilter
, LowpassFilter
Convolution
, Delay
, Reverb
PitchShift
GSMFullRateCompressor
, MP3Compressor
Resample
, Bitcrush
pedalboard.load_plugin
)multiprocessing
!tf.data
! pedalboard
tersedia melalui PyPI (melalui Platform Wheels):
pip install pedalboard # That's it! No other dependencies required.
Jika Anda baru mengenal Python, ikuti INSTALLATION.md untuk panduan lengkap.
pedalboard
diuji secara menyeluruh dengan Python 3.8, 3.9, 3.10, 3.11, 3.12, dan 3.13.
manylinux
dan musllinux
dibuat untuk x86_64
(Intel/AMD) dan aarch64
(ARM/Apple Silicon)amd64
(x86-64, Intel/AMD) Catatan : Jika Anda lebih suka menonton video daripada membaca contoh atau dokumentasi, tonton Bekerja dengan Audio dengan Python (feat. Pedalboard) di YouTube .
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 )
Catatan : Untuk informasi lebih lanjut tentang cara memproses audio melalui plugin Pedalboard, termasuk cara kerja parameter
reset
, lihat dokumentasi untukpedalboard.Plugin.process
.
# 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 )
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 )
Contoh ini menciptakan efek pergeseran nada tertunda dengan menjalankan beberapa Pedalboard secara paralel pada audio yang sama. Objek Pedalboard
sendiri merupakan objek Plugin
, sehingga Anda dapat menyarangkannya sebanyak yang Anda suka:
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 ()
])
pedalboard
mendukung streaming audio langsung melalui objek AudioStream
, memungkinkan manipulasi audio secara real-time dengan menambahkan efek dengan 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.
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 )
Untuk contoh lebih lanjut, lihat:
Kontribusi pada pedalboard
disambut baik! Lihat KONTRIBUSI.md untuk detailnya.
Untuk mengutip pedalboard
dalam karya akademis, gunakan entrinya di Zenodo:
Mengutip melalui 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}
}
pedalboard
adalah Hak Cipta 2021-2024 Spotify AB.
pedalboard
dilisensikan di bawah GNU General Public License v3. pedalboard
mencakup sejumlah perpustakaan yang dikompilasi secara statis, dan memiliki lisensi berikut:
PitchShift
dan fungsi time_stretch
menggunakan Rubber Band Library, yang memiliki lisensi ganda di bawah lisensi komersial dan GPLv2 (atau lebih baru). FFTW juga disertakan untuk mempercepat Rubber Band, dan dilisensikan di bawah GPLv2 (atau lebih baru).MP3Compressor
menggunakan libmp3lame dari proyek LAME, yang dilisensikan di bawah LGPLv2 dan ditingkatkan ke GPLv3 untuk dimasukkan dalam proyek ini (sebagaimana diizinkan oleh LGPLv2).GSMFullRateCompressor
menggunakan libgsm, yang dilisensikan di bawah lisensi ISC dan kompatibel dengan GPLv3.VST adalah merek dagang terdaftar dari Steinberg Media Technologies GmbH.