summaryrefslogtreecommitdiff
path: root/src/synth/triangle.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/synth/triangle.rs')
-rw-r--r--src/synth/triangle.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/synth/triangle.rs b/src/synth/triangle.rs
index 944c539..7d88ec1 100644
--- a/src/synth/triangle.rs
+++ b/src/synth/triangle.rs
@@ -1,5 +1,8 @@
+use super::{
+ FactoryParameters, GenBox, GenFactoryError, Generator, GeneratorFactory, ParamValue,
+ Parameters, Rate, SampleBuffer,
+};
use std::mem;
-use super::*;
#[derive(Debug)]
pub struct Triangle {
@@ -27,7 +30,9 @@ impl Generator for Triangle {
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)
}
@@ -39,7 +44,9 @@ impl GeneratorFactory for TriangleFactory {
fn new(&self, params: &mut FactoryParameters) -> Result<GenBox, GenFactoryError> {
Ok(Box::new(Triangle {
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),
}))
}