File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed
Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -529,9 +529,10 @@ impl<T: Scalar> Filter<T> {
529529}
530530
531531impl < T : Scalar > Filter < T > {
532- fn update_filter ( & mut self , modulation_st : T ) {
533- let cutoff =
534- semitone_to_ratio ( modulation_st) * T :: from_f64 ( self . params . cutoff . smoothed . next ( ) as _ ) ;
532+ fn update_filter ( & mut self , modulation_st : T , input : T ) {
533+ let fm = semitone_to_ratio ( T :: from_f64 ( self . params . freq_mod . smoothed . next ( ) as _ ) * input) ;
534+ let modulation = semitone_to_ratio ( modulation_st) ;
535+ let cutoff = modulation * fm * T :: from_f64 ( self . params . cutoff . smoothed . next ( ) as _ ) ;
535536 let cutoff = cutoff. simd_clamp ( T :: zero ( ) , self . samplerate / T :: from_f64 ( 12. ) ) ;
536537 let resonance = T :: from_f64 ( self . params . resonance . smoothed . next ( ) as _ ) ;
537538 self . fimpl = match self . params . filter_type . value ( ) {
@@ -583,7 +584,7 @@ impl<T: Scalar> DSPMeta for Filter<T> {
583584
584585impl < T : Scalar > DSPProcess < 2 , 1 > for Filter < T > {
585586 fn process ( & mut self , [ x, mod_st] : [ Self :: Sample ; 2 ] ) -> [ Self :: Sample ; 1 ] {
586- self . update_filter ( mod_st) ;
587+ self . update_filter ( mod_st, x ) ;
587588 self . fimpl . process ( [ x] )
588589 }
589590}
Original file line number Diff line number Diff line change @@ -186,6 +186,8 @@ pub struct FilterParams {
186186 pub keyboard_tracking : FloatParam ,
187187 #[ id = "env" ]
188188 pub env_amt : FloatParam ,
189+ #[ id = "fm" ]
190+ pub freq_mod : FloatParam ,
189191 #[ id = "fty" ]
190192 pub filter_type : EnumParam < FilterType > ,
191193}
@@ -250,6 +252,20 @@ impl FilterParams {
250252 oversample. clone ( ) ,
251253 & SmoothingStyle :: Exponential ( 50. ) ,
252254 ) ) ,
255+ freq_mod : FloatParam :: new (
256+ "Freq. Modulation" ,
257+ 0.0 ,
258+ FloatRange :: Linear {
259+ min : -24. ,
260+ max : 24. ,
261+ } ,
262+ )
263+ . with_unit ( " st" )
264+ . with_value_to_string ( Arc :: new ( |x| format ! ( "{:.2}" , x) ) )
265+ . with_smoother ( SmoothingStyle :: OversamplingAware (
266+ oversample. clone ( ) ,
267+ & SmoothingStyle :: Linear ( 10. ) ,
268+ ) ) ,
253269 filter_type : EnumParam :: new ( "Filter Type" , FilterType :: TransistorLadder ) ,
254270 }
255271 }
You can’t perform that action at this time.
0 commit comments