INNER CODE UNIT · Rust

contains_rate

RustAudio/cpal · src/lib.rs:753

    pub fn contains_rate(&self, rate: SampleRate) -> bool {
        self.min_sample_rate <= rate && rate <= self.max_sample_rate
    }

    /// Retrieve a [`SupportedStreamConfig`] with a standard sample rate.
    ///
    /// The preferred rate is selected in order:
    /// 1. 48 kHz as the dominant native rate on modern hardware.
    /// 2. 44.1 kHz as the standard CD/consumer rate.
    ///
    /// Returns `None` if neither standard rate falls within the range specified within this
    /// [`SupportedStreamConfigRange`] instance.
    pub fn try_with_standard_sample_rate(self) -> Option<SupportedStreamConfig> {
        for rate in [SAMPLE_RATE_48K, SAMPLE_RATE_CD] {
            if self.contains_rate(rate) {
                return Some(self.with_sample_rate(rate));
            }
        }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…