pub fn adjust_resampling(&self, in_samples: u32) {
        let mut atomic = self.atomic.lock().unwrap();

        let out_samples = atomic.out_samples;

        // Reset the atomic counter
        atomic.out_samples = 0;

        // Compute the resampling factor since the last adjust
        let r = in_samples as f32 / out_samples as f32;

        match atomic.training {
            Training::Init(c) => {
                // We're just starting, ignore the current measure and
                // wait for the next
                let c = c - 1;

                atomic.training =
                    if c > 0 {
                        Training::Init(c)
                    } else {
                        Training::Measure
                    }
            }
            Training::Measure => {
                // Our first real sample, let's use this value directly
                info!("Measured sound sample rate: {}Hz",
                      (::spu::SAMPLE_RATE as f32 / r));

                atomic.ratio = r;
                atomic.training = Training::Adjust;
            }
            Training::Adjust => {
                // Compute the delta with the current ratio
                let delta = r - atomic.ratio;

                // Avoid brutal sample rate changes by dividing the
                // delta. That way sudden spikes will be smoothed out
                // and long term tendencies will settle in
                // progressively
                let delta = delta / RATIO_AVERAGE_SMOOTH;

                // Update the ratio
                atomic.ratio += delta;
            }
        }
    }
/// Adjust the resampling ratio. `in_samples` is the number of
/// samples generated by the emulator since the last adjustment
/// (counting even the samples potentially dropped in case of a
/// FIFO overflow). This call resets the internal sample counter.
Adjust the resampling ratio. `in_samples` is the number of
samples generated by the emulator since the last adjustment
(counting even the samples potentially dropped in case of a
FIFO overflow). This call resets the internal sample counter.
Adjust the resampling ratio . ` in_samples ` is the number of samples generated by the emulator since the last adjustment ( counting even the samples potentially dropped in case of a FIFO overflow ) . This call resets the internal sample counter .
pub fn adjust_resampling(&self, in_samples: u32) {
        let mut atomic = self.atomic.lock().unwrap();
        let out_samples = atomic.out_samples;
        // Reset the atomic counter
        atomic.out_samples = 0;
        // Compute the resampling factor since the last adjust
        let r = in_samples as f32 / out_samples as f32;
        match atomic.training {
            Training::Init(c) => {
                // We're just starting, ignore the current measure and
                // wait for the next
                let c = c - 1;
                atomic.training =
                    if c > 0 {
                        Training::Init(c)
                    } else {
                        Training::Measure
                    }
            }
            Training::Measure => {
                // Our first real sample, let's use this value directly
                info!("Measured sound sample rate: {}Hz",
                      (::spu::SAMPLE_RATE as f32 / r));
                atomic.ratio = r;
                atomic.training = Training::Adjust;
            }
            Training::Adjust => {
                // Compute the delta with the current ratio
                let delta = r - atomic.ratio;
                // Avoid brutal sample rate changes by dividing the
                // delta. That way sudden spikes will be smoothed out
                // and long term tendencies will settle in
                // progressively
                let delta = delta / RATIO_AVERAGE_SMOOTH;
                // Update the ratio
                atomic.ratio += delta;
            }
        }
    }
pub fn adjust_resampling ( & self , in_samples : u32 ) { let mut atomic = self . atomic . lock ( ) . unwrap ( ) ; let out_samples = atomic . out_samples ; // Reset the atomic counter atomic . out_samples = 0 ; // Compute the resampling factor since the last adjust let r = in_samples as f32 / out_samples as f32 ; match atomic . training { Training :: Init ( c ) => { // We're just starting, ignore the current measure and // wait for the next let c = c - 1 ; atomic . training = if c > 0 { Training :: Init ( c ) } else { Training :: Measure } } Training :: Measure => { // Our first real sample, let's use this value directly info ! ( " " ( spu SAMPLE_RATE as f32 r ) ) ; atomic . ratio = r ; atomic . training = Training :: Adjust ; } Training :: Adjust => { // Compute the delta with the current ratio let delta = r - atomic . ratio ; // Avoid brutal sample rate changes by dividing the // delta. That way sudden spikes will be smoothed out // and long term tendencies will settle in // progressively let delta = delta / RATIO_AVERAGE_SMOOTH ; // Update the ratio atomic . ratio += delta ; } } }
Adjust the resampling ratio.
Adjust the resampling ratio .
&self
in_samples
u32
&self
in_samples
u32