zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

ModFilter.h (2244B)


      1 /*
      2   ZynAddSubFX - a software synthesizer
      3 
      4   ModFilter.h - Modulated Filter
      5   Copyright (C) 2016 Mark McCurry
      6 
      7   This program is free software; you can redistribute it and/or
      8   modify it under the terms of the GNU General Public License
      9   as published by the Free Software Foundation; either version 2
     10   of the License, or (at your option) any later version.
     11 */
     12 #pragma once
     13 #include "../globals.h"
     14 #include "../Misc/Time.h"
     15 
     16 namespace zyn {
     17 
     18 //Modulated instance of one of the filters in src/DSP/
     19 //Supports stereo modes
     20 class ModFilter
     21 {
     22     public:
     23         ModFilter(const FilterParams &pars,
     24                   const SYNTH_T      &synth,
     25                   const AbsTime      &time,
     26                         Allocator    &alloc,
     27                         bool         stereo,
     28                         float        notefreq_);
     29         ~ModFilter(void);
     30 
     31         void addMod(LFO      &lfo);
     32         void addMod(Envelope &env);
     33 
     34         //normal per tick update
     35         void update(float relfreq, float relq);
     36 
     37         //updates typically seen in note-init
     38         void updateNoteFreq(float noteFreq_);
     39         void updateSense(float velocity,
     40                 uint8_t scale, uint8_t func);
     41 
     42         //filter stereo/mono signal(s) in-place
     43         void filter(float *l, float *r);
     44     private:
     45         void paramUpdate(Filter *&f);
     46         void svParamUpdate(SVFilter &sv);
     47         void anParamUpdate(AnalogFilter &an);
     48         void mgParamUpdate(MoogFilter &mg);
     49         void cbParamUpdate(CombFilter &cb);
     50 
     51 
     52         const FilterParams &pars;  //Parameters to Pull Updates From
     53         const SYNTH_T      &synth; //Synthesizer Buffer Parameters
     54         const AbsTime      &time;  //Time for RT Updates
     55         Allocator          &alloc; //RT Memory Pool
     56 
     57 
     58         smooth_float baseQ;    //filter sharpness
     59         smooth_float baseFreq; //base filter frequency
     60         float noteFreq; //frequency note was initialized to
     61         smooth_float tracking; //shift due to note frequency
     62         smooth_float sense;    //shift due to note velocity
     63 
     64 
     65         Filter       *left; //left  channel filter
     66         Filter       *right;//right channel filter
     67         Envelope     *env;  //center freq envelope
     68         LFO          *lfo;  //center freq lfo
     69 };
     70 
     71 }