pub struct VoidWAV {
pub duration: f64,
pub sampling: u32,
}
impl Default for VoidWAV {
fn default() -> Self {
Self {
duration: 5.0,
sampling: 64,
}
}
}
impl VoidWAV {
pub fn data(&self) -> Vec<u8> {
let mut ret = Vec::new();
let len = (2.0 * self.duration * (self.sampling as f64)) as u32 + 44;
ret.extend(b"RIFF");
ret.extend((len - 8).to_le_bytes()); ret.extend(b"WAVEfmt\x20\x10\0\0\0\x01\0\x01\0");
ret.extend(self.sampling.to_le_bytes());
ret.extend((self.sampling * 2).to_le_bytes());
ret.extend(b"\x02\0\x10\0\x64\x61\x74\x61");
ret.extend((len - 44).to_le_bytes());
ret.resize(len as usize, 0); ret
}
}