Loudness measurement to the EBU R128 standard for audio files: integrated loudness, loudness range, true peak, and maximum momentary and short-term loudness. Measurement uses the vendored libebur128 (MIT), with Core Audio decoding and oversampling, so any format Core Audio reads can be measured.
- Measure a file with
LoudnessDescription(parsing:) - Measure decoded audio from a
SequentialPCMSource, for containers Core Audio cannot open or tracks other than the first - Measure a set of files as one program, such as an album, with
LoudnessGatingBlocks - Compute the gain that brings a file to a LUFS or peak target with
NormalizeAnalyzer, optionally limited by a true-peak ceiling and a maximum gain - Channels are weighted by the file's declared channel layout
import SPFKAudioBase
import SPFKLoudness
let loudness = try await LoudnessDescription(parsing: url)
// loudness.loudnessIntegrated (LUFS), loudness.maxTruePeakLevel (dBTP), ...let tracks = try urls.map { try LoudnessAnalyzer.measure(url: $0, minimumDuration: 5) }
let albumLUFS = LoudnessGatingBlocks.integratedLoudness(of: tracks.map(\.gatingBlocks))let normalize = try await NormalizeAnalyzer.analyze(url: url, options: NormalizeOptions(mode: .lufs))
// normalize.gain is a linear multiplier- Decoding is synchronous. The
asyncentry points do not suspend, so call them from a task off the main actor. Cancelling the task stops the decode. - Values outside the representable range are returned as
nil. - Files shorter than 2.5 seconds are looped in memory so the integrated measurement is stable.
- With no channel layout declared, WAV channel order is assumed.
NormalizeAnalyzerthrows when a file cannot be read. A silent file returns unity gain.LoudnessDescriptionis declared in spfk-audio-base, so code that only stores or displays loudness does not need this package.
Spongefork is the personal software projects of musician and developer Ryan Francesconi. Dedicated to creative sound manipulation, his first application, Spongefork, was released in 1999 for macOS 8. From 2026, Spongefork returns as his software container for more musical experimentation. In addition to software releases, open source components can be found on his GitHub page.