diff options
Diffstat (limited to 'src/synth/sine.rs')
-rw-r--r-- | src/synth/sine.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/synth/sine.rs b/src/synth/sine.rs index 4476d4a..3be79db 100644 --- a/src/synth/sine.rs +++ b/src/synth/sine.rs @@ -1,5 +1,8 @@ +use super::{ + mem, FactoryParameters, GenBox, GenFactoryError, Generator, GeneratorFactory, ParamValue, + Parameters, Rate, SampleBuffer, +}; use std::f32::consts::PI; -use super::*; const TAU: f32 = 2f32 * PI; @@ -22,7 +25,9 @@ impl Generator for Sine { self.phase = (self.phase + pvel * (self.buf.len() as f32)) % TAU; &self.buf } - fn buffer(&self) -> &SampleBuffer { &self.buf } + fn buffer(&self) -> &SampleBuffer { + &self.buf + } fn set_buffer(&mut self, buf: SampleBuffer) -> SampleBuffer { mem::replace(&mut self.buf, buf) } @@ -34,7 +39,9 @@ impl GeneratorFactory for SineFactory { fn new(&self, params: &mut FactoryParameters) -> Result<GenBox, GenFactoryError> { Ok(Box::new(Sine { freq: params.remove_param("freq", 0)?.into_gen()?, - phase: params.get_param("phase", 1, &mut ParamValue::Float(0.0)).as_f32()?, + phase: params + .get_param("phase", 1, &mut ParamValue::Float(0.0)) + .as_f32()?, buf: SampleBuffer::new(params.env.default_buffer_size), })) } |