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.2KB

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