Expand description
Audio analysis that tells whether a file is what its format claims.
The usual case is a FLAC made from an MP3. The analyzer judges from the file’s spectrum and from the frame grid an MP3, MP2, AAC, Vorbis, WMA, AC-3 or Opus encoder leaves in decoded samples.
§Examples
use choon::{ReadingThresholds, Settings};
let measured = choon::measure("track.flac", &Settings::default())?;
let reading = measured.read(&ReadingThresholds::default());
println!("{:?}: {}", reading.verdict, reading.summary);§Measuring and reading
measure decodes a file a second at a time, in full or at windows spread over a long
one, and measures each window:
- its loudness
- where its spectrum stops (the cutoff) and how sharply
- gaps below the cutoff
- steps inside a full band
- what a spectrogram and a waveform show of it (
picture)
In a file that claims a lossless format it also scans four stretches of the samples for a
codec’s frame grid (grid). Of an Opus file it keeps the coding mode and audio bandwidth
each packet states (OpusUse), and of an HE-AAC file what its decoder rebuilt (HeAac).
Measured::read turns the measures into a Reading:
- a
Verdictwith how sure it is - the codec grid found
- the encoder setting the cutoff matches
- findings beside it (
Flag) - a summary in words
- what made it less reliable (
Limitation)
Only a grid makes a lossless file a likely transcode; a cutoff that reads as lossy without one makes it possibly lossy.
§Thresholds
Every threshold either step uses is data the caller passes (MeasureThresholds,
ReadingThresholds), so a sweep needs no rebuild. Default holds the values the analyzer
ships with. They come from what common encoders do and are checked against generated audio
in the tests. They are rules of thumb that real files can break, so a reading is evidence.
§Features
cli, on by default, builds thechoonprogram, which prints a reading of each file it is given, as a line of text or of JSON, under one or more sets of thresholds. A library user turns default features off.serdederivesSerializeandDeserializeon the thresholds and onMeasured, andSerializeonReading.testingaddsfixtures, the generated audio and the sample files the analyzer is tested on.
Modules§
- grid
- Frame grids that MP3, MP2, AAC, Vorbis, WMA, AC-3 and Opus encoders leave in decoded audio.
- picture
- Spectrogram and waveform data of each window.
Structs§
- Claimed
- Format a file’s container and codec claim.
- Cutoff
Bucket - Count of the non-silent windows that cut off near one frequency.
- Encoder
Guess - Encoder setting a cutoff matches.
- Encoder
Profile - Lossy encoder setting known by where it cuts off.
- Fraunhofer
Steps - Weights that read the steps of an MP3 decode as Fraunhofer’s encoder.
- HeAac
- What an HE-AAC stream’s decoder rebuilt beside its AAC-LC core.
- Measure
Thresholds - Thresholds each window is measured with.
- Measured
- Measures an analysis took of a file.
- Measures
- Aggregate measures of a file.
- OpusUse
- Time decoded Opus packets spend in one mode and bandwidth.
- Rate
Edge - Band top of a rate some old equipment recorded at.
- Reading
- What the analyzer makes of a file.
- Reading
Thresholds - Thresholds the measures are read with.
- Settings
- Settings of one analysis.
- Step
- Step down in level inside a band that reaches the top.
- Window
- Measures of one window.
Enums§
- Coverage
- How much of a file an analysis reads.
- Error
- Error of an analysis that measured nothing.
- Flag
- Finding reported beside the reading, independent of the cutoff.
- Limitation
- Something that made a reading less reliable.
- Opus
Bandwidth - Audio bandwidth an Opus packet states.
- Opus
Mode - Coding mode an Opus packet states.
- Verdict
- What the analyzer makes of a file.
Functions§
- measure
- Measures the audio of the file at
path. - measure_
bytes - Measures audio held in memory, as
measuredoes a file’s.
Type Aliases§
- Cancel
Check - Check that says whether an analysis is canceled.