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.

90 lines
3.1KB

  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
  11. modify it under the terms of the GNU General Public License
  12. as published by the Free Software Foundation; either version 2
  13. of the License, or (at your option) any later version.
  14. */
  15. #ifndef PHASER_H
  16. #define PHASER_H
  17. #include "../globals.h"
  18. #include "Effect.h"
  19. #include "EffectLFO.h"
  20. #define MAX_PHASER_STAGES 12
  21. class Phaser:public Effect
  22. {
  23. public:
  24. Phaser(EffectParams pars);
  25. ~Phaser();
  26. void out(const Stereo<float *> &input);
  27. void setpreset(unsigned char npreset);
  28. void changepar(int npar, unsigned char value);
  29. unsigned char getpar(int npar) const;
  30. void cleanup();
  31. private:
  32. //Phaser parameters
  33. EffectLFO lfo; //Phaser modulator
  34. unsigned char Pvolume; //Used to set wet/dry mix
  35. unsigned char Pdistortion; //Model distortion added by FET element
  36. unsigned char Pdepth; //Depth of phaser sweep
  37. unsigned char Pwidth; //Phaser width (LFO amplitude)
  38. unsigned char Pfb; //feedback
  39. unsigned char Poffset; //Model mismatch between variable resistors
  40. unsigned char Pstages; //Number of first-order All-Pass stages
  41. unsigned char Poutsub; //if I wish to subtract the output instead of adding
  42. unsigned char Pphase;
  43. unsigned char Phyper; //lfo^2 -- converts tri into hyper-sine
  44. unsigned char Panalog;
  45. //Control parameters
  46. void setvolume(unsigned char Pvolume);
  47. void setdepth(unsigned char Pdepth);
  48. void setfb(unsigned char Pfb);
  49. void setdistortion(unsigned char Pdistortion);
  50. void setwidth(unsigned char Pwidth);
  51. void setoffset(unsigned char Poffset);
  52. void setstages(unsigned char Pstages);
  53. void setphase(unsigned char Pphase);
  54. //Internal Variables
  55. bool barber; //Barber pole phasing flag
  56. float distortion, width, offsetpct;
  57. float feedback, depth, phase;
  58. Stereo<float *> old, xn1, yn1;
  59. Stereo<float> diff, oldgain, fb;
  60. float invperiod;
  61. float offset[12];
  62. float mis;
  63. float Rmin; // 3N5457 typical on resistance at Vgs = 0
  64. float Rmax; // Resistor parallel to FET
  65. float Rmx; // Rmin/Rmax to avoid division in loop
  66. float Rconst; // Handle parallel resistor relationship
  67. float C; // Capacitor
  68. float CFs; // A constant derived from capacitor and resistor relationships
  69. void analog_setup();
  70. void AnalogPhase(const Stereo<float *> &input);
  71. //analog case
  72. float applyPhase(float x, float g, float fb,
  73. float &hpf, float *yn1, float *xn1);
  74. void normalPhase(const Stereo<float *> &input);
  75. float applyPhase(float x, float g, float *old);
  76. };
  77. #endif