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.

91 lines
3.2KB

  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. static rtosc::Ports ports;
  32. private:
  33. //Phaser parameters
  34. EffectLFO lfo; //Phaser modulator
  35. unsigned char Pvolume; //Used to set wet/dry mix
  36. unsigned char Pdistortion; //Model distortion added by FET element
  37. unsigned char Pdepth; //Depth of phaser sweep
  38. unsigned char Pwidth; //Phaser width (LFO amplitude)
  39. unsigned char Pfb; //feedback
  40. unsigned char Poffset; //Model mismatch between variable resistors
  41. unsigned char Pstages; //Number of first-order All-Pass stages
  42. unsigned char Poutsub; //if I wish to subtract the output instead of adding
  43. unsigned char Pphase;
  44. unsigned char Phyper; //lfo^2 -- converts tri into hyper-sine
  45. unsigned char Panalog;
  46. //Control parameters
  47. void setvolume(unsigned char Pvolume);
  48. void setdepth(unsigned char Pdepth);
  49. void setfb(unsigned char Pfb);
  50. void setdistortion(unsigned char Pdistortion);
  51. void setwidth(unsigned char Pwidth);
  52. void setoffset(unsigned char Poffset);
  53. void setstages(unsigned char Pstages);
  54. void setphase(unsigned char Pphase);
  55. //Internal Variables
  56. bool barber; //Barber pole phasing flag
  57. float distortion, width, offsetpct;
  58. float feedback, depth, phase;
  59. Stereo<float *> old, xn1, yn1;
  60. Stereo<float> diff, oldgain, fb;
  61. float invperiod;
  62. float offset[12];
  63. float mis;
  64. float Rmin; // 3N5457 typical on resistance at Vgs = 0
  65. float Rmax; // Resistor parallel to FET
  66. float Rmx; // Rmin/Rmax to avoid division in loop
  67. float Rconst; // Handle parallel resistor relationship
  68. float C; // Capacitor
  69. float CFs; // A constant derived from capacitor and resistor relationships
  70. void analog_setup();
  71. void AnalogPhase(const Stereo<float *> &input);
  72. //analog case
  73. float applyPhase(float x, float g, float fb,
  74. float &hpf, float *yn1, float *xn1);
  75. void normalPhase(const Stereo<float *> &input);
  76. float applyPhase(float x, float g, float *old);
  77. };
  78. #endif