Tech News
← Back to articles

Python Audio Processing with Pedalboard

read original related products more articles

Python audio processing with pedalboard

The pedalboard library for Python is aimed at audio processing of various sorts, from converting between formats to adding audio effects. The maintainer of pedalboard , Peter Sobot, gave a talk about audio in Python at PyCon US 2025, which was held in Pittsburgh, Pennsylvania in May. He started from the basics of digital audio and then moved into working with pedalboard . There were, as might be guessed, audio examples in the talk, along with some visual information; interested readers may want to view the YouTube video of the presentation.

Sobot works for Spotify as a machine-learning engineer in its audio intelligence lab, so he works on a team using machine-learning models to analyze music. The company has various open APIs that can be used to analyze audio tracks, but it has also released code as open-source software; pedalboard is available under the GPLv3. It has also released open models, such as Basic Pitch, which turns audio data into Musical Instrument Digital Interface (MIDI) files; the model can be used on the web or incorporated into other tools, he said.

$ sudo subscribe today Subscribe today and elevate your LWN privileges. You’ll have access to all of LWN’s high-quality articles as soon as they’re published, and help support LWN in the process. Act now and you can start with a free trial subscription.

He noted that he had created a demo for the talk that attendees could try out during his presentation; it used Python and pedalboard in the browser (by way of Pyodide and WebAssembly) to allow users to create audio. " If somebody were to make sound during my talk because they're playing with this REPL, I would be overjoyed. " He got his wish a little over halfway into his 30-minute talk.

Digital audio

To understand how digital audio works, you need to understand how sound works, Sobot said. " Sound is really just pressure moving through the air "; his voice is moving the air in front of his mouth, which the microphone picks up and sends to the speakers, which create pressure waves by moving the air there. As with anything physical that can be stored into a computer, the way to get sound into the machine is to measure it.

He showed a simple graph with time as the x-axis and pressure on the y-axis; he then played a short saxophone clip, with each note showing up as a dot on the graph. The ten or so dots obviously corresponded to the notes in some fashion, but it was not entirely clear how, in part because each measurement was only taken every 0.4 seconds. A sample rate of one sample per 0.4 seconds is 2.5Hz. Sample rate is important for digital audio; " the faster that you sample, the higher quality audio that you get ". It is not just quality, though, higher sampling rate means that more details, especially high-frequency details, are captured.

Looking a little more closely at the graph, he pointed out that silence (0.0) is not at the bottom of the y-axis as might be inferred, but is in the middle; some of the points measured are above that line, some below, because the pressure is a wave that is moving back and forth, he said. The maximum loudness (+/- 1.0) is both at the bottom and the top of the y-axis; our ears do not distinguish between waves moving toward or away from us, he said, but the measurements do. Each of the points on the graph has a pressure value that can be turned into a number, such as 60% amplitude (or 0.60) or 90% amplitude in a negative direction (-0.90).

If you wanted to reproduce that audio clip, though, you would need much higher-fidelity sampling, so he showed the graph that results from sampling at a standard digital-audio rate of 44,100Hz. That graph (or waveform) has so many points that you cannot distinguish individual measurements anymore, though you can still see where the original points came from.

... continue reading