summaryrefslogtreecommitdiff
path: root/src/synth/util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/synth/util.rs')
-rw-r--r--src/synth/util.rs32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/synth/util.rs b/src/synth/util.rs
index 5bde721..16d6f7f 100644
--- a/src/synth/util.rs
+++ b/src/synth/util.rs
@@ -1,4 +1,7 @@
-use super::*;
+use super::{
+ mem, FactoryParameters, GenBox, GenFactoryError, Generator, GeneratorFactory, Parameters, Rate,
+ SampleBuffer,
+};
#[derive(Debug)]
pub struct ControlRate {
@@ -9,7 +12,10 @@ pub struct ControlRate {
impl ControlRate {
pub fn new(mut gen: GenBox) -> ControlRate {
gen.set_buffer(SampleBuffer::new(1));
- ControlRate { value: gen, buf: SampleBuffer::new(1) }
+ ControlRate {
+ value: gen,
+ buf: SampleBuffer::new(1),
+ }
}
}
@@ -19,15 +25,21 @@ impl Generator for ControlRate {
self.buf.update_from(self.value.eval(params));
&self.buf
}
- fn buffer(&self) -> &SampleBuffer { &self.buf }
- fn set_buffer(&mut self, buf: SampleBuffer) -> SampleBuffer { mem::replace(&mut self.buf, buf) }
+ fn buffer(&self) -> &SampleBuffer {
+ &self.buf
+ }
+ fn set_buffer(&mut self, buf: SampleBuffer) -> SampleBuffer {
+ mem::replace(&mut self.buf, buf)
+ }
}
pub struct ControlRateFactory;
impl GeneratorFactory for ControlRateFactory {
fn new(&self, params: &mut FactoryParameters) -> Result<GenBox, GenFactoryError> {
- Ok(Box::new(ControlRate::new(params.remove_param("gen", 0)?.into_gen()?)))
+ Ok(Box::new(ControlRate::new(
+ params.remove_param("gen", 0)?.into_gen()?,
+ )))
}
}
@@ -43,7 +55,9 @@ impl Generator for SampleRate {
self.buf.set(params.env.sample_rate);
&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)
}
@@ -52,8 +66,10 @@ impl Generator for SampleRate {
pub struct SampleRateFactory;
impl GeneratorFactory for SampleRateFactory {
- fn new(&self, params: &mut FactoryParameters) -> Result<GenBox, GenFactoryError> {
- Ok(Box::new(SampleRate { buf: SampleBuffer::new(1) }))
+ fn new(&self, _params: &mut FactoryParameters) -> Result<GenBox, GenFactoryError> {
+ Ok(Box::new(SampleRate {
+ buf: SampleBuffer::new(1),
+ }))
}
}