Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Phaser.h 3.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. Phaser.h - Phaser effect
  4. Copyright (C) 2002-2005 Nasca Octavian Paul
  5. Copyright (C) 2009-2010 Ryan Billing
  6. Copyright (C) 2010-2010 Mark McCurry
  7. Author: Nasca Octavian Paul
  8. Ryan Billing
  9. Mark McCurry
  10. This program is free software; you can redistribute it and/or modify
  11. it under the terms of version 2 of the GNU General Public License
  12. as published by the Free Software Foundation.
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. GNU General Public License (version 2 or later) for more details.
  17. You should have received a copy of the GNU General Public License (version 2)
  18. along with this program; if not, write to the Free Software Foundation,
  19. Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #ifndef PHASER_H
  22. #define PHASER_H
  23. #include "../globals.h"
  24. #include "Effect.h"
  25. #include "EffectLFO.h"
  26. #define MAX_PHASER_STAGES 12
  27. class Phaser:public Effect
  28. {
  29. public:
  30. Phaser(const int &insertion_, float *efxoutl_, float *efxoutr_, unsigned int srate, int bufsize);
  31. ~Phaser();
  32. void out(const Stereo<float *> &input);
  33. void setpreset(unsigned char npreset);
  34. void changepar(int npar, unsigned char value);
  35. unsigned char getpar(int npar) const;
  36. void cleanup();
  37. private:
  38. //Phaser parameters
  39. EffectLFO lfo; //Phaser modulator
  40. unsigned char Pvolume; //Used to set wet/dry mix
  41. unsigned char Pdistortion; //Model distortion added by FET element
  42. unsigned char Pdepth; //Depth of phaser sweep
  43. unsigned char Pwidth; //Phaser width (LFO amplitude)
  44. unsigned char Pfb; //feedback
  45. unsigned char Poffset; //Model mismatch between variable resistors
  46. unsigned char Pstages; //Number of first-order All-Pass stages
  47. unsigned char Poutsub; //if I wish to subtract the output instead of adding
  48. unsigned char Pphase;
  49. unsigned char Phyper; //lfo^2 -- converts tri into hyper-sine
  50. unsigned char Panalog;
  51. //Control parameters
  52. void setvolume(unsigned char Pvolume);
  53. void setdepth(unsigned char Pdepth);
  54. void setfb(unsigned char Pfb);
  55. void setdistortion(unsigned char Pdistortion);
  56. void setwidth(unsigned char Pwidth);
  57. void setoffset(unsigned char Poffset);
  58. void setstages(unsigned char Pstages);
  59. void setphase(unsigned char Pphase);
  60. //Internal Variables
  61. bool barber; //Barber pole phasing flag
  62. float distortion, width, offsetpct;
  63. float feedback, depth, phase;
  64. Stereo<float *> old, xn1, yn1;
  65. Stereo<float> diff, oldgain, fb;
  66. float invperiod;
  67. float offset[12];
  68. float mis;
  69. float Rmin; // 3N5457 typical on resistance at Vgs = 0
  70. float Rmax; // Resistor parallel to FET
  71. float Rmx; // Rmin/Rmax to avoid division in loop
  72. float Rconst; // Handle parallel resistor relationship
  73. float C; // Capacitor
  74. float CFs; // A constant derived from capacitor and resistor relationships
  75. void analog_setup();
  76. void AnalogPhase(const Stereo<float *> &input);
  77. //analog case
  78. float applyPhase(float x, float g, float fb,
  79. float &hpf, float *yn1, float *xn1);
  80. void normalPhase(const Stereo<float *> &input);
  81. float applyPhase(float x, float g, float *old);
  82. };
  83. #endif