From 9866c0f34c268a09ecaaa9a4361c1c267799358e Mon Sep 17 00:00:00 2001 From: Graham Northup Date: Tue, 19 Sep 2017 23:56:15 -0400 Subject: Starting work on proto decode --- src/synth/sine.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/synth/sine.rs') diff --git a/src/synth/sine.rs b/src/synth/sine.rs index 212ab21..90f3200 100644 --- a/src/synth/sine.rs +++ b/src/synth/sine.rs @@ -3,6 +3,7 @@ use super::*; const TAU: f32 = 2f32 * PI; +#[derive(Debug)] pub struct Sine { pub freq: GenBox, pub phase: f32, @@ -11,7 +12,7 @@ pub struct Sine { impl Generator for Sine { fn eval<'a>(&'a mut self, params: &Parameters) -> &'a SampleBuffer { - self.buf.rate = Rate::Control; + self.buf.rate = Rate::Sample; let pvel = TAU * self.freq.eval(params).first() / params.env.sample_rate; for i in 0..self.buf.len() { @@ -21,4 +22,7 @@ impl Generator for Sine { self.phase = (self.phase + pvel * (self.buf.len() as f32)) % TAU; &self.buf } + fn set_buffer(&mut self, buf: SampleBuffer) -> SampleBuffer { + mem::replace(&mut self.buf, buf) + } } -- cgit v1.2.3-70-g09d2