diff options
author | Graham Northup <grissess@nexusg.org> | 2017-09-20 01:49:04 -0400 |
---|---|---|
committer | Graham Northup <grissess@nexusg.org> | 2017-09-20 01:49:04 -0400 |
commit | dcfc4e82386f41bd36c3b102512bd225fc5331b6 (patch) | |
tree | b0b4e8ee6bf95be9970cfad37ef087cce472393b /src/main.rs | |
parent | 9866c0f34c268a09ecaaa9a4361c1c267799358e (diff) |
more of the same for the night :)
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 05538e9..c284820 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,8 @@ use std::io; use std::io::*; +extern crate rand; +use rand::{Rng, SeedableRng}; extern crate synfone; use synfone::synth::*; @@ -9,8 +11,14 @@ const FRAMES: usize = 44100 * 2; fn main() { let mut params = Parameters::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(Saw { freq: freq, phase: 0.0, buf: SampleBuffer::new(params.env.default_buffer_size) }); + //let mut freq: GenBox = Box::new(Param { name: "freq".to_string(), default: 440.0, buf: SampleBuffer::new(1) }); + //let mut sg: GenBox = Box::new(Saw { freq: freq, phase: 0.0, buf: SampleBuffer::new(params.env.default_buffer_size) }); + let mut osrng = rand::os::OsRng::new().expect("Couldn't initialize OS RNG"); + let mut seed: [u32; 4] = Default::default(); + for i in seed.iter_mut() { + *i = osrng.next_u32(); + } + let mut sg: GenBox = Box::new(Noise { rng: rand::XorShiftRng::from_seed(seed), buf: SampleBuffer::new(params.env.default_buffer_size) }); let mut freq2: GenBox = Box::new(Param { name: "freq2".to_string(), default: 660.0, buf: SampleBuffer::new(1) }); let mut sg2: GenBox = Box::new(Sine { freq: freq2, phase: 0.0, buf: SampleBuffer::new(params.env.default_buffer_size) }); |