summaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 6db2bcfef8a541f4a4b56fe4f4d4655241f2a2c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use std::io;
use std::io::*;

extern crate synfone;
use synfone::synth::*;

const FRAMES: usize = 44100 * 2;

fn main() {
    let mut params = Default::default();
    
    let mut freq: GenBox = Box::new(Param { name: "freq".to_string(), default: 440.0, buf: SampleBuffer::new(1) });
    let mut sg: GenBox = Box::new(Sine { freq: freq, phase: 0.0, buf: SampleBuffer::new(params.env.default_buffer_size) });

    let mut counter = 0;
    let mut out = io::stderr();

    while counter < FRAMES {
        let buf = sg.eval(&params);
        out.write_all(buf.bytes());
        counter += buf.len();
    }
}