From d6e399973e9bc6447a28b80cacffcbc6a768f1ed Mon Sep 17 00:00:00 2001 From: thajohns Date: Thu, 9 Sep 2021 01:15:22 -0400 Subject: got pre-linking steps working, removed glob includes --- src/synth/math.rs | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) (limited to 'src/synth/math.rs') diff --git a/src/synth/math.rs b/src/synth/math.rs index 1889139..c73c0c4 100644 --- a/src/synth/math.rs +++ b/src/synth/math.rs @@ -1,4 +1,7 @@ -use super::*; +use super::{ + FactoryParameters, GenBox, GenFactoryError, Generator, GeneratorFactory, Parameters, Rate, + SampleBuffer, +}; use std::mem; #[derive(Debug)] @@ -20,7 +23,9 @@ impl Generator for Add { } &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) } @@ -31,7 +36,11 @@ pub struct AddFactory; impl GeneratorFactory for AddFactory { fn new(&self, params: &mut FactoryParameters) -> Result { Ok(Box::new(Add { - terms: params.get_pos_params().into_iter().map(|x| x.into_gen()).collect::, _>>()?, + terms: params + .get_pos_params() + .into_iter() + .map(|x| x.into_gen()) + .collect::, _>>()?, buf: SampleBuffer::new(params.env.default_buffer_size), })) } @@ -58,7 +67,9 @@ impl Generator for Mul { } &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) } @@ -69,7 +80,11 @@ pub struct MulFactory; impl GeneratorFactory for MulFactory { fn new(&self, params: &mut FactoryParameters) -> Result { Ok(Box::new(Mul { - factors: params.get_pos_params().into_iter().map(|x| x.into_gen()).collect::, _>>()?, + factors: params + .get_pos_params() + .into_iter() + .map(|x| x.into_gen()) + .collect::, _>>()?, buf: SampleBuffer::new(params.env.default_buffer_size), })) } @@ -91,14 +106,16 @@ impl Generator for Negate { for v in self.buf.iter_mut() { *v *= -1.0; } - }, + } Rate::Control => { self.buf[0] *= -1.0; - }, + } } &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) } @@ -133,14 +150,16 @@ impl Generator for Reciprocate { for v in self.buf.iter_mut() { *v = v.powf(-1.0); } - }, + } Rate::Control => { self.buf[0] = self.buf[0].powf(-1.0); - }, + } } &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) } -- cgit v1.2.3-70-g09d2