pub struct Config {
pub input_sample_rate: usize,
pub output_sample_rate: usize,
pub channels: usize,
pub quality: usize,
pub bandwidth: f32,
pub taper_type: TaperType,
pub phase: f32,
pub phase_intensity: f32,
pub rodio_fast_start: bool,
}Expand description
Configures the ardftsrc resampler.
§Example
let config = ardftsrc::Config::new(44_100, 48_000, 2).with_phase(-0.5);Fields§
§input_sample_rate: usizeInput audio sample rate in Hz.
output_sample_rate: usizeOutput audio sample rate in Hz.
channels: usizeNumber of interleaved audio channels.
quality: usizeSet the overall “quality” of the resampler.
Quality roughly sets the spectral resolution scale (and therefore FFT bin count), but this mapping is not exactly 1:1 (exact bin count depends on rate ratio and quantization).
Default value is 1878 (same quality as PRESET_GOOD).
Value guide:
512(PRESET_FAST): Fast and low quality, great for realtime applications. At this quality you may prefer using a sinc resampler (eg. rubato) instead.1878(PRESET_GOOD): Good balanced quality - you should probably use this. (Default)73622(PRESET_HIGH): High quality, good for offline resampling, also marginally appropriate for realtime applications where quality is critical.524514(PRESET_EXTREME): Extreme quality, good for offline resampling, very high quality but also very slow. Not recommended for realtime applications.
bandwidth: f32Normalized filter bandwidth in the range [0.0, 1.0].
Higher values preserve more high-frequency content but shorten the transition band.
Value guide:
0.82: Fast and low quality, great for realtime applications. At this quality you may prefer using a sinc resampler (eg. rubato) instead.0.95: Balanced high-end retention for most cases.0.97: More aggressive high-end retention; Use with a higher “quality” setting.0.99: Very aggressive high-end retention; Only recommended when using a very high “quality” setting.
taper_type: TaperTypeFrequency taper profile used around the cutoff region.
Planck: Uses a Planck taper transition.Cosine(alpha): Uses a sigmoid-warped cosine transition.BetaCdf(alpha, beta): Beta-CDF taper from the regularized lower incomplete beta function.
Default value is Cosine(3.4375), which was arrived at through testing
various values on the HydrogenAudio SRC test suite.
Lower alpha values result in a smoother transition, while higher values
produce a sharper transition.
Value guide for Cosine(alpha):
1.5: Very smooth transition; may increase audible near-Nyquist artifacts.2.5: Smooth and less aggressive shaping.3.5: Good balance between smoothness and selectivity.4.0: Sharper shaping; can trade smoothness for selectivity.
phase: f32Phase: Frequency-dependent phase rotation in the range [-1.0, 1.0].
Positive values rotate higher bins forward; negative values apply the conjugate rotation.
0.0 disables phase rotation.
Setting a negative phase value can help with pre-ringing artifacts.
Default value is 0.0.
phase_intensity: f32Scales the phase rotation angle in the range [0.0, 100.0].
0.0 disables phase rotation. The default value is 50.0.
rodio_fast_start: boolFor RodioResampler, this setting controls whether to use a fast start mode.
Fast start mode will prime the resampler with initial samples to get it up to speed, and avoid start-up silence.
This is only appropriate to use when the inner sounce can handle rapid calls to next(). For example, this will
generally work on buffered streams or audio files, but not on live microphones.
- Set to “true” if the inner source is something like a buffered stream or audio file.
- Set to “false” if the inner source is very realtime (e.g. a live microphone).
If set to true for an inner source that cannot handle this, you will experience crackling at the start of the stream as the inner source fails to keep up.
This setting is only for RodioResampler, it has no effect on other resamplers.
Implementations§
Source§impl Config
impl Config
pub const DEFAULT: Self
Sourcepub fn new(
input_sample_rate: usize,
output_sample_rate: usize,
channels: usize,
) -> Self
pub fn new( input_sample_rate: usize, output_sample_rate: usize, channels: usize, ) -> Self
Builds a config with explicit sample rates/channel count and default (PRESET_GOOD) quality settings.
Sourcepub fn with_input_rate(self, input_sample_rate: usize) -> Self
pub fn with_input_rate(self, input_sample_rate: usize) -> Self
Input audio sample rate in Hz.
Sourcepub fn with_output_rate(self, output_sample_rate: usize) -> Self
pub fn with_output_rate(self, output_sample_rate: usize) -> Self
Output audio sample rate in Hz.
Sourcepub fn with_channels(self, channels: usize) -> Self
pub fn with_channels(self, channels: usize) -> Self
Number of interleaved audio channels.
Sourcepub fn with_quality(self, quality: usize) -> Self
pub fn with_quality(self, quality: usize) -> Self
Set the overall “quality” of the resampler.
Quality roughly sets the spectral resolution scale (and therefore FFT bin count), but this mapping is not exactly 1:1 (exact bin count depends on rate ratio and quantization).
Default value is 1878 (same quality as PRESET_GOOD).
Value guide:
512(PRESET_FAST): Fast and low quality, great for realtime applications. At this quality you may prefer using a sinc resampler (eg. rubato) instead.1878(PRESET_GOOD): Good balanced quality - you should probably use this. (Default)73622(PRESET_HIGH): High quality, good for offline resampling, also marginally appropriate for realtime applications where quality is critical.524514(PRESET_EXTREME): Extreme quality, good for offline resampling, very high quality but also very slow. Not recommended for realtime applications.
Sourcepub fn with_bandwidth(self, bandwidth: f32) -> Self
pub fn with_bandwidth(self, bandwidth: f32) -> Self
Normalized filter bandwidth in the range [0.0, 1.0].
Higher values preserve more high-frequency content but shorten the transition band.
Value guide:
0.82: Fast and low quality, great for realtime applications. At this quality you may prefer using a sinc resampler (eg. rubato) instead.0.95: Balanced high-end retention for most cases.0.97: More aggressive high-end retention; Use with a higher “quality” setting.0.99: Very aggressive high-end retention; Only recommended when using a very high “quality” setting.
Sourcepub fn with_taper_type(self, taper_type: TaperType) -> Self
pub fn with_taper_type(self, taper_type: TaperType) -> Self
Frequency taper profile used around the cutoff region.
Planck: Uses a Planck taper transition.Cosine(alpha): Uses a sigmoid-warped cosine transition.
Default value is Cosine(3.4375), which was arrived at through testing
various values on the HydrogenAudio SRC test suite.
Lower alpha values result in a smoother transition, while higher values
produce a sharper transition.
Value guide for Cosine(alpha):
1.5: Very smooth transition; may increase audible near-Nyquist artifacts.2.5: Smooth and less aggressive shaping.3.5: Good balance between smoothness and selectivity.4.0: Sharper shaping; can trade smoothness for selectivity.
Sourcepub fn with_phase(self, phase: f32) -> Self
pub fn with_phase(self, phase: f32) -> Self
Phase: Frequency-dependent phase rotation in the range [-1.0, 1.0].
Positive values rotate higher bins forward; negative values apply the conjugate rotation.
0.0 disables phase rotation.
Setting a negative phase value can help with pre-ringing artifacts.
Default value is 0.0.
Sourcepub fn with_phase_intensity(self, phase_intensity: f32) -> Self
pub fn with_phase_intensity(self, phase_intensity: f32) -> Self
Scales the phase rotation angle in the range [0.0, 100.0].
0.0 disables phase rotation. The default value is 50.0.
Sourcepub fn with_rodio_fast_start(self, rodio_fast_start: bool) -> Self
pub fn with_rodio_fast_start(self, rodio_fast_start: bool) -> Self
For RodioResampler, this setting controls whether to use a fast start mode.
Fast start mode will prime the resampler with initial samples to get it up to speed, and avoid start-up silence.
This is only appropriate to use when the inner sounce can handle rapid calls to next(). For example, this will
generally work on buffered streams or audio files, but not on live microphones.
- Set to
trueif the inner source is something like a buffered stream or audio file. - Set to
falseif the inner source is very realtime (e.g. a live microphone).
If set to true for an inner source that cannot handle this, you will experience crackling at the start of the stream as the inner source fails to keep up.
This setting is only for RodioResampler, it has no effect on other resamplers.