Skip to main content

Crate choon

Crate choon 

Source
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 Verdict with 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 the choon program, 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.
  • serde derives Serialize and Deserialize on the thresholds and on Measured, and Serialize on Reading.
  • testing adds fixtures, 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.
CutoffBucket
Count of the non-silent windows that cut off near one frequency.
EncoderGuess
Encoder setting a cutoff matches.
EncoderProfile
Lossy encoder setting known by where it cuts off.
FraunhoferSteps
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.
MeasureThresholds
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.
RateEdge
Band top of a rate some old equipment recorded at.
Reading
What the analyzer makes of a file.
ReadingThresholds
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.
OpusBandwidth
Audio bandwidth an Opus packet states.
OpusMode
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 measure does a file’s.

Type Aliases§

CancelCheck
Check that says whether an analysis is canceled.