diff options
| author | thajohns <thajohns@clarkson.edu> | 2021-09-09 01:15:22 -0400 | 
|---|---|---|
| committer | Graham Northup <grahamnorthup@yahoo.com> | 2021-09-10 04:05:55 -0400 | 
| commit | d6e399973e9bc6447a28b80cacffcbc6a768f1ed (patch) | |
| tree | 772939eb5d49bdb6ee8e5d632f2224867f6e817d /src/synth/adsr.rs | |
| parent | ee11b17c0e2796bd3d843a8a516c12453af75927 (diff) | |
got pre-linking steps working, removed glob includes
Diffstat (limited to 'src/synth/adsr.rs')
| -rw-r--r-- | src/synth/adsr.rs | 25 | 
1 files changed, 15 insertions, 10 deletions
| diff --git a/src/synth/adsr.rs b/src/synth/adsr.rs index ca7be9c..e7dba5d 100644 --- a/src/synth/adsr.rs +++ b/src/synth/adsr.rs @@ -1,6 +1,9 @@ -use super::*; +use super::{ +    mem, FactoryParameters, GenBox, GenFactoryError, Generator, GeneratorFactory, Parameters, Rate, +    SampleBuffer, +}; -#[derive(Debug,Clone,Copy,PartialEq,Eq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)]  pub enum Phase {      Delay,      Attack, @@ -44,7 +47,7 @@ impl Generator for DAHDSR {                  self.attack_cd = delay;                  self.cur = 0.0;              } -        } else{ +        } else {              self.phase = Phase::Release;          } @@ -55,7 +58,7 @@ impl Generator for DAHDSR {                      if self.attack_cd <= 0.0 {                          self.phase = Phase::Attack;                      } -                }, +                }                  Phase::Attack => {                      self.cur += attack;                      if self.cur >= 1.0 { @@ -63,36 +66,38 @@ impl Generator for DAHDSR {                          self.phase = Phase::Hold;                          self.decay_cd = hold;                      } -                }, +                }                  Phase::Hold => {                      self.decay_cd -= 1.0;                      if self.decay_cd <= 0.0 {                          self.phase = Phase::Decay;                      } -                }, +                }                  Phase::Decay => {                      self.cur -= decay;                      if self.cur <= sustain {                          self.cur = sustain;                          self.phase = Phase::Sustain;                      } -                }, +                }                  Phase::Sustain => {                      self.cur = sustain; -                }, +                }                  Phase::Release => {                      self.cur -= release;                      if self.cur < 0.0 {                          self.cur = 0.0;                      } -                }, +                }              }              *samp = self.cur;          }          &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)      } | 
