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
//! Opt-in conversion helpers.
//!
//! The direct USB path never converts anything. This module is for a host that has audio in one
//! format and a DAC that runs another (a rate the DAC refuses under
//! [`RatePolicy::NearestSupported`](crate::RatePolicy), a depth it lacks): it plans the smallest
//! chain of steps that bridges them, says honestly what that costs, and runs it.
//!
//! - [`ConversionPlan::between`] plans a conversion from a request to a negotiated format and
//! classifies it as [`ConversionKind::None`], [`ConversionKind::BitExact`] (widening and
//! repacking: every sample value is unchanged), [`ConversionKind::Lossless`] (mono duplicated to
//! stereo, integers carried in a float) or [`ConversionKind::Lossy`] (fewer bits, floats to
//! integers, a new sample rate). Only the first two keep a bit-perfect stream bit-perfect.
//! - [`Converter`] runs a plan on chunks of bytes, without allocating after it is built.
//! - [`Resampler`] is the polyphase windowed-sinc converter underneath, for any rational ratio
//! between the standard rates; its design and measured quality are in its module documentation.
//!
//! ### Clipping and headroom
//!
//! Integer outputs saturate at full scale and never wrap, and [`Converter::clipped_samples`] counts
//! how often. A resampled signal can exceed its input's peak (the overshoot of a band-limited
//! reconstruction: a full-scale square wave sampled at 44.1 kHz rises by 3 dB when it is resampled
//! to 48 kHz, as the tests measure), so a resampling plan for material that can do that takes
//! headroom: [`ConvertOptions::headroom_db`], for example `-3.5`. The
//! default of 0 dB keeps the gain at exactly 1 at DC and the passband flat to 0.0001 dB; a full-scale
//! sine, which the filter passes within that ripple, does not clip.
//!
//! ### What is not converted
//!
//! DoP and native DSD are never converted ([`ConvertError::Unsupported`]), nor is any channel
//! layout other than mono to stereo.
pub use ;
pub use ;
pub use ;
pub use ;