summaryrefslogtreecommitdiff
path: root/src/synth/square.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/synth/square.rs')
-rw-r--r--src/synth/square.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/synth/square.rs b/src/synth/square.rs
index 4b01e07..ef49020 100644
--- a/src/synth/square.rs
+++ b/src/synth/square.rs
@@ -1,4 +1,7 @@
-use super::*;
+use super::{
+ mem, FactoryParameters, GenBox, GenFactoryError, Generator, GeneratorFactory, ParamValue,
+ Parameters, Rate, SampleBuffer,
+};
#[derive(Debug)]
pub struct Square {
@@ -23,7 +26,9 @@ impl Generator for Square {
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)
}
@@ -35,7 +40,9 @@ impl GeneratorFactory for SquareFactory {
fn new(&self, params: &mut FactoryParameters) -> Result<GenBox, GenFactoryError> {
Ok(Box::new(Square {
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),
}))
}