Audio¶
Four things Podlibre does to a recording before it is published: take the room out from under the words, even out the difference between a shout and an aside, set the peak, and set the loudness.
They are one step of the workflow, filter_audio, served by one plugin. They were four
steps, and that was wrong in three ways: it put four rows reading prepare on the strip for one
decision, it made the order of four buttons the user's problem, and it wrote four whole copies of
the episode to disk, each read back from the last. Which of them run, and how hard, is read on
the step's own page.
Nothing is overwritten¶
A step reads each of the episode's clips, processes it, and writes a new file beside the original with the step's name in it:
The clip is then pointed at the new file. The original stays on disk, so a step can be undone by hand, and a filter applied by mistake costs nothing. A clip's source is relative to the show's folder, so all of this survives the folder being copied to another machine.
All the chosen filters run in one pass and write one file. Where only one filter is on, the file is named after it; where several are, they share a name, because a chain of four suffixes names nothing anybody can read:
| On | Writes |
|---|---|
| Reduce noise, alone | take.denoised.wav |
| Compress, alone | take.compressed.wav |
| Normalise peak, alone | take.normalised.wav |
| Normalise loudness, alone | take.levelled.wav |
| More than one | take.filtered.wav |
Nothing tidies these up. Disk is cheap and a recording is not repeatable.
The page, and where its settings live¶
Four filters with a checkbox each, their own numbers, and one button that runs the ones that are on. They always run in the order the page lists them, which is not a choice: rumble and hiss come out before anything decides how loud the words are, and the level is set last, because compressing after it would undo it.
Reducing noise is off to begin with, and the other three are on. It is the only one of the four that changes what the recording sounds like rather than how loud it is, and deciding what in a recording is noise is a decision for somebody who has heard the recording.
With peak and loudness normalisation both on, the peak pass is work whose result the next filter replaces: normalising the loudness applies a measured gain and ends in a brickwall limiter at the same ceiling. It costs one pass over samples already in memory, and it is what somebody who switches the loudness pass off is left with.
The settings are kept in the show file, against the workflow in use — Show.plugin_settings,
in the workflow_state table. A setting that belongs to how this podcast is made belongs with
the way of working: copy the folder to another machine and the settings go with it, choose another
workflow and its own settings come with it. They are not in the application's settings, which
would make one podcast's noise floor another podcast's problem.
A number the filter would refuse — a ratio of 500, a target above any host's — is brought into range when it is read, because a show file can be written by hand or by a later version.
Loudness, and why it has its own module¶
Every podcast host normalises to a loudness target — Apple and Spotify both aim at −16 LUFS for stereo. A meter that is wrong is wrong in every episode published through it, and wrong by a fraction of a decibel is invisible to any listening test. So the measurement is ITU-R BS.1770 integrated loudness, implemented properly and checked against the EBU's own conformance signals.
The gating is the point. BS.1770 throws away the quiet blocks before averaging: anything below −70 LUFS absolutely, and anything more than 10 LU below the rest of the programme. Without it the silence between sentences drags the number down — 3.6 LU on ten seconds of speech against ten of silence — and a podcast normalised on that number is published that much too loud.
| Measured against | EBU Tech 3341 cases 1 and 2 |
| Error | 0.007 LU, where the tolerance is 0.1 |
| Sample rates | Any; a 44.1 kHz file reads the same as a 48 kHz one |
The K-weighting coefficients are the standard's own rather than derived from its analog prototype. Deriving them is a textbook exercise and it was got wrong the first time here — the shelf came out 0.25 dB off at 1 kHz, which nothing but a conformance signal would have caught.
Filtering is done in the frequency domain, one block at a time, because a biquad in the time domain is a sample-by-sample recursion that Python cannot do at this scale and the project has no SciPy. Each bin is weighted at its real frequency, which is what resampling to 48 kHz first would amount to, without the resampling.
Silence, and audio shorter than one 400 ms block, have no loudness rather than a very low one. A caller that read silence as "very quiet" and applied the gain that implies would destroy the file.
The filters¶
| Filter | What it is | Default | On the page |
|---|---|---|---|
| Reduce noise | Two high-pass stages, then spectral subtraction, then a gate | 80 Hz, 12 dB/octave; 14 dB down; gate at the measured floor + 12 dB, 4:1 | strength, 0 to 30 dB |
| Compress | A compressor, gentle by the standards of music | −18 dBFS, 3:1 | threshold, ratio |
| Normalise peak | Scale so the peak sits below the ceiling | −1 dBFS | ceiling |
| Normalise loudness | Measured gain, then a brickwall limiter | −16 LUFS, ceiling −1 dBFS | target, ceiling |
Reducing noise¶
A gate alone only works between words. It is one number for the whole spectrum, so while somebody is talking it passes the hiss under their voice along with the voice. That is the bulk of what a listener hears as a noisy recording, and no threshold anywhere can reach it.
So the middle stage is spectral: the recording is cut into 43 ms windows, a level is measured for every frequency, and the bins that hold nothing louder than that are turned down by 14 dB. It is Podlibre's own, in numpy, because the project has no SciPy and nothing else is needed: an FFT, a comparison and an overlap-add.
The background is measured bin by bin, from the quiet fifth of each frequency's own history. Picking the quietest frames instead needs the recording to have silences in it — and a recording with none had its voice measured as the noise and then subtracted from itself. Speech moves about the spectrum syllable by syllable, so even where the talking never stops, any one frequency holds nothing but the room most of the time.
The line is drawn at about twice the average noise, not at it: noise is noisy, and a line at the average leaves the louder half behind, which chirps. The mask is smoothed across frequency and across time before it is applied, for the same reason — an unsmoothed mask turns a bin on and off between neighbouring frames and that flicker is the "musical noise" that gives spectral subtraction its bad name.
Nothing is removed, only turned down. A bin the measurement misjudges is quietened by 14 dB and no more, so the worst case is a sound that got quieter, never one that was invented. The limit of the method is the other side of the same coin: a sound at one frequency for the whole recording is indistinguishable from a fan, and is treated as one. That is right for hum, and it is why this is a filter for speech.
The windows are padded by one window at each end. A Hann window is zero at its own edges, so without the padding the first and last 43 ms of a file come back as rubbish — the part of a file a listener hears first.
The gate's threshold is measured, not fixed. At a constant −40 dBFS it did nothing whatever to a recording with a fan in it: the hiss sat above the threshold and the gate stood open from the first word to the last, which is exactly the recording somebody opens this step for. It is set from this recording's own floor, twelve decibels above it and never higher than −40 dBFS, and it is measured before the spectral stage: a threshold set against what the subtraction leaves sits in the middle of that residue, and the gate then opens and closes on the noise's own fluctuations, which is the pumping a listener hears as "over-processed".
A gate measures level, not RMS. Broadband hiss peaks about 13 dB above its RMS, so a threshold set at the noise floor's RMS never engages at all — which looks exactly like a filter that works and does nothing.
On an eight-second recording of speech with a −45 dBFS floor — a laptop fan an arm's length from the microphone — the three stages together take the gaps down 30 dB, the hiss under the voice down 10 dB, and leave the speech within 2 dB of where it was. The gate alone managed nothing measurable on the same recording.
One high-pass stage is 6 dB per octave, which leaves a 30 Hz rumble only 9 dB down. Two stages give the 12 dB per octave speech wants.
The limiter after the gain is a brickwall limiter, not a "limiter". pedalboard's Limiter is
loudness-maximising and adds makeup gain: putting it after a measured gain overshot the target by
4.75 dB, undoing the whole point of measuring. BrickwallLimiter only prevents clipping, and does
it on true peak, which is what the −1 dBFS ceiling is for — a file peaking at exactly 0 comes out
of an MP3 encoder clipped.
What it declares, and what it writes¶
| Field | |
|---|---|
loudness_lufs |
what the meter read, written after every run that changed the audio |
It is shared, so an exporter can check an episode is at the level a host wants without knowing this plugin exists. See the data model.
audio_file, which the step requires, belongs to whatever imports audio — the plugin that
sets a field is the one that should define it. The bundled Local audio plugin does both:
it copies a recording into the episode's folder, registers it as a clip, and writes the field,
which is what turns the step from waiting into ready. With no such plugin switched on, the
field does not exist and the step reads not ready, which is the truth.
It plays back what it imported, too — in Podlibre's own player, down in the drawer, which it
asks for with self.listen(). A page that lists a recording and will not let you hear it asks
the user to open a file manager to find out whether the right file arrived, and every step after
it is about audio nobody has listened to. The clips go over in the order the page lists them,
read at the moment the button is pressed, so what plays is what the episode has now.
It used to do the playing itself: PortAudio, a block at a time, on a worker thread, with a Stop button and a task of its own. All of that is what the drawer already is, and two players in one window is two recordings at once.
Testing it¶
The processing and the measurement are in modules that import nothing from Podlibre, so both are tested against signals whose answer is known — the EBU's tones for the meter, and for the filters a signal built so that the thing being tested is the thing that changes.
That matters more here than elsewhere. Audio is the easiest thing to test badly: run the filter,
see no exception, call it working. A filter that quietly does nothing passes that and fails every
test in tests/test_filters.py.