zynaddsubfx

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

CombFilter.h (1398B)


      1 /*
      2   ZynAddSubFX - a software synthesizer
      3 
      4   CombFilter.h - Several analog filters
      5   Copyright (C) 2021-2021 Michael Kirchner
      6   Author: Michael Kirchner
      7 
      8   This program is free software; you can redistribute it and/or
      9   modify it under the terms of the GNU General Public License
     10   as published by the Free Software Foundation; either version 2
     11   of the License, or (at your option) any later version.
     12 */
     13 
     14 #pragma once
     15 #include "Filter.h"
     16 #include "Value_Smoothing_Filter.h"
     17 
     18 namespace zyn {
     19 
     20 class CombFilter:public Filter
     21 {
     22     public:
     23         //! @param Fq resonance, range [0.1,1000], logscale
     24         CombFilter(Allocator *alloc, unsigned char Ftype, float Ffreq, float Fq,
     25                 unsigned int srate, int bufsize);
     26         ~CombFilter() override;
     27         void filterout(float *smp) override;
     28         void setfreq(float freq) override;
     29         void setfreq_and_q(float freq, float q_) override;
     30         void setq(float q) override;
     31         void setgain(float dBgain) override;
     32         void settype(unsigned char type);
     33 
     34     private:
     35 
     36         float* input;
     37         float* output;
     38         float gain;
     39         float q;
     40         unsigned char type;
     41 
     42         float step(float x);
     43 
     44         float tanhX(const float x);
     45         float sampleLerp(float *smp, float pos);
     46 
     47         float gainfwd;
     48         float gainbwd;
     49         float delay;
     50 
     51         Allocator &memory;
     52         int mem_size;
     53 
     54 };
     55 
     56 }