11// use std::clone; 
22
3- #[ derive( Clone ) ]  
3+ use  crate :: osc:: ShapeMath :: { Sawwave ,  Sinewave ,  Squarewave ,  Trianglewave } ; 
4+ 
5+ #[ derive( Debug ,  Clone ,  Copy ) ]  
46pub  enum  ShapeMath  { 
57    Sinewave , 
68    Squarewave , 
79    Sawwave , 
810    Trianglewave 
911} 
1012
11- #[ derive( Clone ) ]  
13+ #[ derive( Debug ,   Clone ) ]  
1214pub  struct  Oscillator  { 
1315    amp :  f32 , 
1416    freq :  f32 , 
@@ -19,16 +21,16 @@ pub struct Oscillator {
1921impl  ShapeMath  { 
2022    pub  fn  compute ( & self ,  freq :  f32 ,  time :  f32 )  -> f32  { 
2123        match  self  { 
22-             ShapeMath :: Sinewave  => ( 2.0  *  std:: f32:: consts:: PI  *  freq *  time) . sin ( ) , 
23-             ShapeMath :: Squarewave  => ( 2.0  *  std:: f32:: consts:: PI  *  freq *  time) . sin ( ) . signum ( ) , 
24-             ShapeMath :: Sawwave  => 2.0  *  ( freq *  time - freq *  time. floor ( ) )  - 1.0 , 
25-             ShapeMath :: Trianglewave  => ( 2.0  *  ( freq *  time - 0.5 ) ) . abs ( )  - 1.0 , 
24+             Self :: Sinewave  => ( 2.0  *  std:: f32:: consts:: PI  *  freq *  time) . sin ( ) , 
25+             Self :: Squarewave  => ( 2.0  *  std:: f32:: consts:: PI  *  freq *  time) . sin ( ) . signum ( ) , 
26+             Self :: Sawwave  => 2.0  *  ( freq *  time - freq *  time. floor ( ) )  - 1.0 , 
27+             Self :: Trianglewave  => ( 2.0  *  ( freq *  time - 0.5 ) ) . abs ( )  - 1.0 , 
2628        } 
2729    } 
2830} 
2931
3032impl  Oscillator  { 
31-     pub  fn  new ( amp :  f32 ,  freq :  f32 ,  shape :  ShapeMath )  -> Oscillator  { 
33+     pub  fn  new ( amp :  f32 ,  freq :  f32 ,  shape :  ShapeMath )  -> Self  { 
3234        Oscillator  { 
3335            amp, 
3436            freq, 
@@ -37,7 +39,7 @@ impl Oscillator {
3739        } 
3840    } 
3941
40-     pub  fn  with_input ( amp :  f32 ,  freq :  f32 ,  shape :  ShapeMath ,  input :  Oscillator )  -> Oscillator  { 
42+     pub  fn  with_input ( amp :  f32 ,  freq :  f32 ,  shape :  ShapeMath ,  input :  Oscillator )  -> Self  { 
4143        Oscillator  { 
4244            amp, 
4345            freq, 
@@ -46,14 +48,14 @@ impl Oscillator {
4648        } 
4749    } 
4850
49-     pub  fn  clone_osc ( & self )  -> Oscillator  { 
50-         Oscillator  { 
51-             amp :  self . amp , 
52-             freq :  self . freq , 
53-             shape :  self . shape . clone ( ) , 
54-             input :  self . input . clone ( ) , 
55-         } 
56-     } 
51+ //     pub fn clone_osc(&self) -> Self  {
52+ //         Oscillator {
53+ //             amp: self.amp,
54+ //             freq: self.freq,
55+ //             shape: self.shape.clone(),
56+ //             input: self.input.clone(),
57+ //         }
58+ //     }
5759
5860    pub  fn  frequency_modulation ( & self ,  time :  f32 )  -> f32  { 
5961        let  input_freq = match  & self . input  { 
0 commit comments