summaryrefslogtreecommitdiff
path: root/src/synth/saw.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/synth/saw.rs')
-rw-r--r--src/synth/saw.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/synth/saw.rs b/src/synth/saw.rs
index 3e30ca6..5c36cc1 100644
--- a/src/synth/saw.rs
+++ b/src/synth/saw.rs
@@ -1,4 +1,7 @@
-use super::*;
+use super::{
+ mem, FactoryParameters, GenBox, GenFactoryError, Generator, GeneratorFactory, ParamValue,
+ Parameters, Rate, SampleBuffer,
+};
#[derive(Debug)]
pub struct Saw {
@@ -19,7 +22,9 @@ impl Generator for Saw {
self.phase = (self.phase + pvel * (self.buf.len() as f32)) % 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)
}
@@ -31,7 +36,9 @@ impl GeneratorFactory for SawFactory {
fn new(&self, params: &mut FactoryParameters) -> Result<GenBox, GenFactoryError> {
Ok(Box::new(Saw {
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),
}))
}