1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//! 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
//!
//! ```no_run
//! use choon::{ReadingThresholds, Settings};
//!
//! # fn main() -> Result<(), choon::Error> {
//! let measured = choon::measure("track.flac", &Settings::default())?;
//! let reading = measured.read(&ReadingThresholds::default());
//! println!("{:?}: {}", reading.verdict, reading.summary);
//! # Ok(())
//! # }
//! ```
//!
//! # 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.
;
pub use ;
pub use ;
pub use ;
pub use ;
pub use Flag;
pub use Limitation;
pub use ;
pub use ;
pub use ;