Advertisement
Guest User

moogfiter.h

a guest
Dec 9th, 2019
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. /*
  2.   ZynAddSubFX - a software synthesizer
  3.  
  4.   Moog Filter.h - Several analog filters (lowpass, highpass...)
  5.   Copyright (C) 2018-2018 Mark McCurry
  6.   Author: Mark McCurry
  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 <vector>
  17.  
  18. namespace zyn {
  19.  
  20.  
  21.        
  22. class MoogFilter:public Filter
  23. {
  24.     public:
  25.         //! @param Fq resonance, range [0.1,1000], logscale
  26.         MoogFilter(float Ffreq, float Fq,
  27.                 unsigned char non_linear_element /* currently set by "stages" */,
  28.                 unsigned int srate, int bufsize);
  29.         ~MoogFilter() override;
  30.         void filterout(float *smp) override;
  31.         void setfreq(float /*frequency*/) override;
  32.         void setfreq_and_q(float frequency, float q_) override;
  33.         void setq(float /*q_*/) override;
  34.         void setgain(float dBgain) override;
  35.     private:
  36.         unsigned sr;
  37.         float gain;
  38.        
  39.         float step(float x);
  40.         void make_filter(float ff, float k);
  41.         std::vector<float> impulse_response(float alpha, float k);
  42.         float tanhd(const float x, const float d, const float s);
  43.        
  44.         float b[4] = { 0, 0, 0, 0 };
  45.         float compensation, estimate, c, c2, fb;
  46.         float xx, y0, y1, y2, y3;
  47.         float t0, t1, t2, t3;
  48.         float g0, g1, g2, g3;
  49.         float z0, z1, z2, z3;
  50.         float f0, f1, f2, f3;
  51.         float cgfbr, f, fd2;
  52.         float a = 2.0f;
  53.         float s = 0.1f;
  54.         float d = 1.0f;
  55.        
  56. };
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement