use hound::{SampleFormat, WavWriter};
use markov_chain::Chain;
fn main() {
    let mut chain: Chain<i16> = Chain::new(3);
    let mut reader =
        hound::WavReader::open("/Users/kline/projects/spring/birdkov/src/birds.wav").unwrap();
    let samples: Vec<i16> = reader.samples().map(|x| x.unwrap()).collect::<Vec<i16>>();
    chain.train(samples);
    let sequence = chain.generate_limit(44100 * 30);
    let mut output = WavWriter::create(
        "/Users/kline/projects/spring/birdkov/newbirds.wav",
        hound::WavSpec {
            channels: 1,
            sample_rate: 44100,
            bits_per_sample: 16,
            sample_format: SampleFormat::Int,
        },
    )
    .unwrap();
    for sample in sequence {
        output.write_sample(sample).unwrap();
    }
}
