pub fn compute(&mut self, buffer: &Buffer) {
        self.stft.process_analyze_only(
            buffer,
            &self.compensated_window_function,
            SPECTRUM_WINDOW_OVERLAP,
            |channel_idx, real_fft_scratch_buffer| {
                // Forward FFT, the helper has already applied window function
                self.plan
                    .r2c_plan
                    .r2c(
                        real_fft_scratch_buffer,
                        &mut self.complex_fft_scratch_buffer,
                    )
                    .unwrap();

                // To be able to reuse `real_fft_scratch_buffer` this function is called per
                // channel, so we need to use the channel index to do any pre- or post-processing.
                // Gain compensation has already been baked into the window function.
                if channel_idx == 0 {
                    for (bin, spectrum_result) in self
                        .complex_fft_scratch_buffer
                        .iter()
                        // We don't care about the DC bin
                        .skip(1)
                        .zip(&mut self.spectrum_result_buffer)
                    {
                        *spectrum_result = bin.norm();
                    }
                } else {
                    for (bin, spectrum_result) in self
                        .complex_fft_scratch_buffer
                        .iter()
                        .skip(1)
                        .zip(&mut self.spectrum_result_buffer)
                    {
                        *spectrum_result += bin.norm();
                    }
                }

                let num_channels_recip = (self.num_channels as f32).recip();
                if channel_idx == self.num_channels - 1 {
                    for bin in &mut self.spectrum_result_buffer {
                        *bin *= num_channels_recip;
                    }
                }

                self.triple_buffer_input.write(self.spectrum_result_buffer);
            },
        );
    }
/// Compute the spectrum for a buffer and send it to the corresponding output pair.
Compute the spectrum for a buffer and send it to the corresponding output pair.
Compute the spectrum for a buffer and send it to the corresponding output pair .
pub fn compute(&mut self, buffer: &Buffer) {
        self.stft.process_analyze_only(
            buffer,
            &self.compensated_window_function,
            SPECTRUM_WINDOW_OVERLAP,
            |channel_idx, real_fft_scratch_buffer| {
                // Forward FFT, the helper has already applied window function
                self.plan
                    .r2c_plan
                    .r2c(
                        real_fft_scratch_buffer,
                        &mut self.complex_fft_scratch_buffer,
                    )
                    .unwrap();
                // To be able to reuse `real_fft_scratch_buffer` this function is called per
                // channel, so we need to use the channel index to do any pre- or post-processing.
                // Gain compensation has already been baked into the window function.
                if channel_idx == 0 {
                    for (bin, spectrum_result) in self
                        .complex_fft_scratch_buffer
                        .iter()
                        // We don't care about the DC bin
                        .skip(1)
                        .zip(&mut self.spectrum_result_buffer)
                    {
                        *spectrum_result = bin.norm();
                    }
                } else {
                    for (bin, spectrum_result) in self
                        .complex_fft_scratch_buffer
                        .iter()
                        .skip(1)
                        .zip(&mut self.spectrum_result_buffer)
                    {
                        *spectrum_result += bin.norm();
                    }
                }
                let num_channels_recip = (self.num_channels as f32).recip();
                if channel_idx == self.num_channels - 1 {
                    for bin in &mut self.spectrum_result_buffer {
                        *bin *= num_channels_recip;
                    }
                }
                self.triple_buffer_input.write(self.spectrum_result_buffer);
            },
        );
    }
pub fn compute ( & mut self , buffer : & Buffer ) { self . stft . process_analyze_only ( buffer , & self . compensated_window_function , SPECTRUM_WINDOW_OVERLAP , | channel_idx , real_fft_scratch_buffer | { // Forward FFT, the helper has already applied window function self . plan . r2c_plan . r2c ( real_fft_scratch_buffer , & mut self . complex_fft_scratch_buffer , ) . unwrap ( ) ; // To be able to reuse `real_fft_scratch_buffer` this function is called per // channel, so we need to use the channel index to do any pre- or post-processing. // Gain compensation has already been baked into the window function. if channel_idx == 0 { for ( bin , spectrum_result ) in self . complex_fft_scratch_buffer . iter ( ) // We don't care about the DC bin . skip ( 1 ) . zip ( & mut self . spectrum_result_buffer ) { * spectrum_result = bin . norm ( ) ; } } else { for ( bin , spectrum_result ) in self . complex_fft_scratch_buffer . iter ( ) . skip ( 1 ) . zip ( & mut self . spectrum_result_buffer ) { * spectrum_result += bin . norm ( ) ; } } let num_channels_recip = ( self . num_channels as f32 ) . recip ( ) ; if channel_idx == self . num_channels - 1 { for bin in & mut self . spectrum_result_buffer { * bin *= num_channels_recip ; } } self . triple_buffer_input . write ( self . spectrum_result_buffer ) ; } , ) ; }
Compute the spectrum for a buffer and send it to the corresponding output pair.
Compute the spectrum for a buffer and send it to the corresponding output pair .
&mut self
buffer
&Buffer
&mut self
buffer
&Buffer