pub fn update(&mut self, buf: &AudioBuffer<i32>, bps: u32) {
        // The MD5 checksum is calculated on a buffer containing interleaved audio samples of the
        // correct sample width. While FLAC can encode and decode samples of arbitrary bit widths,
        // the samples in the buffer must be a multiple of 8-bits.
        //
        // Additionally, Symphonia's AudioBuffer's are in planar format, and the FLAC decoder works
        // internally on signed 32-bit samples exclusively.
        //
        // Therefore, to compute the checksum, the audio buffer samples must truncated to the
        // correct bit-width, interlaced, and converted to a little-endian byte buffer. The byte
        // buffer can then be passed to the MD5 algorithm for hashing.

        // Round the sample bit width up to the nearest byte.
        let bytes_per_sample = match bps {
            0       => return,
            1..=8   => 1,
            9..=16  => 2,
            17..=24 => 3,
            25..=32 => 4,
            _ => unreachable!(),
        };

        let n_channels = buf.spec().channels.count();
        let n_frames = buf.frames();

        // Calculate the total size of all the samples in bytes.
        let buf_len = (n_channels * n_frames * bytes_per_sample) as usize;

        // Ensure the byte buffer length can accomodate all the samples.
        if self.buf.len() < buf_len {
            self.buf.resize(buf_len, 0u8);
        }

        // Populate the hash buffer with samples truncated to the correct width. A &[u8] slice of
        // all the samples in hash buffer will be returned.
        let buf_slice = match bytes_per_sample {
            1 => copy_as_i8(buf, &mut self.buf, n_channels, n_frames),
            2 => copy_as_i16(buf, &mut self.buf, n_channels, n_frames),
            3 => copy_as_i24(buf, &mut self.buf, n_channels, n_frames),
            4 => copy_as_i32(buf, &mut self.buf, n_channels, n_frames),
            _ => unreachable!(),
        };

        // Update the MD5 state.
        self.state.process_buf_bytes(buf_slice);
    }
/// Processes the audio buffer and updates the state of the validator.
Processes the audio buffer and updates the state of the validator.
Processes the audio buffer and updates the state of the validator .
pub fn update(&mut self, buf: &AudioBuffer<i32>, bps: u32) {
        // The MD5 checksum is calculated on a buffer containing interleaved audio samples of the
        // correct sample width. While FLAC can encode and decode samples of arbitrary bit widths,
        // the samples in the buffer must be a multiple of 8-bits.
        //
        // Additionally, Symphonia's AudioBuffer's are in planar format, and the FLAC decoder works
        // internally on signed 32-bit samples exclusively.
        //
        // Therefore, to compute the checksum, the audio buffer samples must truncated to the
        // correct bit-width, interlaced, and converted to a little-endian byte buffer. The byte
        // buffer can then be passed to the MD5 algorithm for hashing.
        // Round the sample bit width up to the nearest byte.
        let bytes_per_sample = match bps {
            0       => return,
            1..=8   => 1,
            9..=16  => 2,
            17..=24 => 3,
            25..=32 => 4,
            _ => unreachable!(),
        };
        let n_channels = buf.spec().channels.count();
        let n_frames = buf.frames();
        // Calculate the total size of all the samples in bytes.
        let buf_len = (n_channels * n_frames * bytes_per_sample) as usize;
        // Ensure the byte buffer length can accomodate all the samples.
        if self.buf.len() < buf_len {
            self.buf.resize(buf_len, 0u8);
        }
        // Populate the hash buffer with samples truncated to the correct width. A &[u8] slice of
        // all the samples in hash buffer will be returned.
        let buf_slice = match bytes_per_sample {
            1 => copy_as_i8(buf, &mut self.buf, n_channels, n_frames),
            2 => copy_as_i16(buf, &mut self.buf, n_channels, n_frames),
            3 => copy_as_i24(buf, &mut self.buf, n_channels, n_frames),
            4 => copy_as_i32(buf, &mut self.buf, n_channels, n_frames),
            _ => unreachable!(),
        };
        // Update the MD5 state.
        self.state.process_buf_bytes(buf_slice);
    }
pub fn update ( & mut self , buf : & AudioBuffer < i32 > , bps : u32 ) { // The MD5 checksum is calculated on a buffer containing interleaved audio samples of the // correct sample width. While FLAC can encode and decode samples of arbitrary bit widths, // the samples in the buffer must be a multiple of 8-bits. // // Additionally, Symphonia's AudioBuffer's are in planar format, and the FLAC decoder works // internally on signed 32-bit samples exclusively. // // Therefore, to compute the checksum, the audio buffer samples must truncated to the // correct bit-width, interlaced, and converted to a little-endian byte buffer. The byte // buffer can then be passed to the MD5 algorithm for hashing. // Round the sample bit width up to the nearest byte. let bytes_per_sample = match bps { 0 => return , 1 ..= 8 => 1 , 9 ..= 16 => 2 , 17 ..= 24 => 3 , 25 ..= 32 => 4 , _ => unreachable ! ( ) , } ; let n_channels = buf . spec ( ) . channels . count ( ) ; let n_frames = buf . frames ( ) ; // Calculate the total size of all the samples in bytes. let buf_len = ( n_channels * n_frames * bytes_per_sample ) as usize ; // Ensure the byte buffer length can accomodate all the samples. if self . buf . len ( ) < buf_len { self . buf . resize ( buf_len , 0u8 ) ; } // Populate the hash buffer with samples truncated to the correct width. A &[u8] slice of // all the samples in hash buffer will be returned. let buf_slice = match bytes_per_sample { 1 => copy_as_i8 ( buf , & mut self . buf , n_channels , n_frames ) , 2 => copy_as_i16 ( buf , & mut self . buf , n_channels , n_frames ) , 3 => copy_as_i24 ( buf , & mut self . buf , n_channels , n_frames ) , 4 => copy_as_i32 ( buf , & mut self . buf , n_channels , n_frames ) , _ => unreachable ! ( ) , } ; // Update the MD5 state. self . state . process_buf_bytes ( buf_slice ) ; }
Processes the audio buffer and updates the state of the validator.
Processes the audio buffer and updates the state of the validator .
&mut self
buf
&AudioBuffer<i32>
bps
u32
&mut self
buf
&AudioBuffer<i32>
bps
u32