[][src]Function bae_rs::utils::write_wav

pub fn write_wav(tracks: Vec<TrackT>, bps: u16, d: &mut dyn Write) -> Result<()>

Takes the given track and filename and writes the track data to the WAV file at the given location with a given bit-depth.

Parameters

  • track - A vector of tracks to write. Each track is considered a channel.
  • bps - The number of bits per sample. Should be 8, 16, or 24.
  • d - The destination to write to.

Errors

This function fails if:

  • Anything that wav::write_wav specifies.
  • The channels don't have equal lengths.
  • The given vector contains no data.

Example

use bae_rs::{*,generators::*, utils::*};
let mut n = Noise::new();
let mut t = TrackT::new();

for _ in 0..SAMPLE_RATE {
    t.push(n.process());
}

write_wav(vec![t], 16, &mut File::create(".junk/some/path/noise.wav").unwrap());