diff options
Diffstat (limited to 'src/synth/param.rs')
-rw-r--r-- | src/synth/param.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/synth/param.rs b/src/synth/param.rs index 602be1d..dd3ecb8 100644 --- a/src/synth/param.rs +++ b/src/synth/param.rs @@ -1,4 +1,7 @@ -use super::*; +use super::{ + mem, FactoryParameters, GenBox, GenFactoryError, Generator, GeneratorFactory, ParamValue, + Parameters, Sample, SampleBuffer, +}; #[derive(Debug)] pub struct Param { @@ -9,10 +12,13 @@ pub struct Param { impl Generator for Param { fn eval<'a>(&'a mut self, params: &Parameters) -> &'a SampleBuffer { - self.buf.set(*params.vars.get(&self.name).unwrap_or(&self.default)); + self.buf + .set(*params.vars.get(&self.name).unwrap_or(&self.default)); + &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) } @@ -24,7 +30,9 @@ impl GeneratorFactory for ParamFactory { fn new(&self, params: &mut FactoryParameters) -> Result<GenBox, GenFactoryError> { Ok(Box::new(Param { name: params.get_req_param("name", 0)?.as_string()?, - default: params.get_param("default", 1, &mut ParamValue::Float(0.0)).as_f32()?, + default: params + .get_param("default", 1, &mut ParamValue::Float(0.0)) + .as_f32()?, buf: SampleBuffer::new(1), })) } |