/// Resamples the audio using a specific resampler.
///
/// # Arguments
/// - `frame_rate_hz`: The destination frame rate to resample to.
/// - `resample_mode`: The Babycat resampling backend to pick.
///
/// # Examples
/// ```
/// use babycat::Waveform;
///
/// let waveform = Waveform::from_file(
///     "audio-for-tests/circus-of-freaks/track.mp3",
///     Default::default()
/// ).unwrap();
/// assert_eq!(
///    format!("{:?}", waveform),
///    "Waveform { frame_rate_hz: 44100, num_channels: 2, num_frames: 2491776}"
/// );
///
/// // Here we upsample our audio to 96khz with the libsamplerate resampler.
/// let upsampled_libsamplerate = waveform.resample_by_mode(
///     96000,
///     babycat::RESAMPLE_MODE_LIBSAMPLERATE
/// ).unwrap();
/// assert_eq!(
///    format!("{:?}", upsampled_libsamplerate),
///    "Waveform { frame_rate_hz: 96000, num_channels: 2, num_frames: 5424275}"
/// );
///
/// // And we upsample our audio again with Babycat's Lanczos resampler.
/// let upsampled_lanczos = waveform.resample_by_mode(
///     96000,
///     babycat::RESAMPLE_MODE_BABYCAT_LANCZOS
/// ).unwrap();
/// assert_eq!(
///    format!("{:?}", upsampled_lanczos),
///    "Waveform { frame_rate_hz: 96000, num_channels: 2, num_frames: 5424275}"
/// );
/// ```
Resamples the audio using a specific resampler.
Resamples the audio using a specific resampler .
pub fn resample_by_mode(&self, frame_rate_hz: u32, resample_mode: u32) -> Result<Self, Error> {
        let interleaved_samples = resample(
            self.frame_rate_hz,
            frame_rate_hz,
            self.num_channels,
            &self.interleaved_samples,
            resample_mode,
        )?;
        let num_frames = interleaved_samples.len() as u64 / self.num_channels as u64;
        Ok(Self {
            interleaved_samples,
            frame_rate_hz,
            num_channels: self.num_channels,
            num_frames,
        })
    }
pub fn resample_by_mode ( & self , frame_rate_hz : u32 , resample_mode : u32 ) -> Result < Self , Error > { let interleaved_samples = resample ( self . frame_rate_hz , frame_rate_hz , self . num_channels , & self . interleaved_samples , resample_mode , ) ? ; let num_frames = interleaved_samples . len ( ) as u64 / self . num_channels as u64 ; Ok ( Self { interleaved_samples , frame_rate_hz , num_channels : self . num_channels , num_frames , } ) }
Resamples the audio using a specific resampler.
Resamples the audio using a specific resampler .
&self
frame_rate_hz
u32
The destination frame rate to resample to.
The destination frame rate to resample to .
resample_mode
u32
The Babycat resampling backend to pick.
The Babycat resampling backend to pick .
examples
```
use babycat::Waveform.

let waveform = Waveform::from_file(
"audio-for-tests/circus-of-freaks/track.mp3",
Default::default()
).unwrap();
assert_eq!(
format!("{:?}", waveform),
"Waveform { frame_rate_hz: 44100, num_channels: 2, num_frames: 2491776}"
).

Here we upsample our audio to 96khz with the libsamplerate resampler.
let upsampled_libsamplerate = waveform.resample_by_mode(
96000,
babycat::RESAMPLE_MODE_LIBSAMPLERATE
).unwrap();
assert_eq!(
format!("{:?}", upsampled_libsamplerate),
"Waveform { frame_rate_hz: 96000, num_channels: 2, num_frames: 5424275}"
).

And we upsample our audio again with Babycat's Lanczos resampler.
let upsampled_lanczos = waveform.resample_by_mode(
96000,
babycat::RESAMPLE_MODE_BABYCAT_LANCZOS
).unwrap();
assert_eq!(
format!("{:?}", upsampled_lanczos),
"Waveform { frame_rate_hz: 96000, num_channels: 2, num_frames: 5424275}"
);
```
` ` ` use babycat :: Waveform . let waveform = Waveform :: from_file ( " audio - for - tests / circus - of - freaks / track . mp3 " Default :: default () ) . unwrap () ; assert_eq! ( format! ( " { : ? } " waveform ) " Waveform { frame_rate_hz : 44100 num_channels : 2 num_frames : 2491776 } " ) . Here we upsample our audio to 96khz with the libsamplerate resampler . let upsampled_libsamplerate = waveform . resample_by_mode ( 96000 babycat :: RESAMPLE_MODE_LIBSAMPLERATE ) . unwrap () ; assert_eq! ( format! ( " { : ? } " upsampled_libsamplerate ) " Waveform { frame_rate_hz : 96000 num_channels : 2 num_frames : 5424275 } " ) . And we upsample our audio again with Babycat ' s Lanczos resampler . let upsampled_lanczos = waveform . resample_by_mode ( 96000 babycat :: RESAMPLE_MODE_BABYCAT_LANCZOS ) . unwrap () ; assert_eq! ( format! ( " { : ? } " upsampled_lanczos ) " Waveform { frame_rate_hz : 96000 num_channels : 2 num_frames : 5424275 } " ) ; ` ` `