use wavegen::{sine, wf};
const SAMPLE_RATE: u16 = 44100; const FILENAME: &str = "sine.wav"; const WAVE_TIME_S: f32 = 1.0;
fn main() {
let wf = wf!(i16, SAMPLE_RATE, sine!(500., i16::MAX));
let spec = hound::WavSpec {
channels: 1,
sample_rate: SAMPLE_RATE as u32,
bits_per_sample: 16,
sample_format: hound::SampleFormat::Int,
};
let mut writer = hound::WavWriter::create(FILENAME, spec).unwrap();
for s in wf.iter().take((SAMPLE_RATE as f32 * WAVE_TIME_S) as usize) {
writer.write_sample(s).unwrap();
}
println!("{}s of audio written to {}", WAVE_TIME_S, FILENAME);
}