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.

112 lines
3.6KB

  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. SUBnote.h - The subtractive synthesizer
  4. Copyright (C) 2002-2005 Nasca Octavian Paul
  5. Author: Nasca Octavian Paul
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of version 2 of the GNU General Public License
  8. as published by the Free Software Foundation.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License (version 2 or later) for more details.
  13. You should have received a copy of the GNU General Public License (version 2)
  14. along with this program; if not, write to the Free Software Foundation,
  15. Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. */
  17. #ifndef SUB_NOTE_H
  18. #define SUB_NOTE_H
  19. #include "SynthNote.h"
  20. #include "../globals.h"
  21. #include "../Params/SUBnoteParameters.h"
  22. #include "../Params/Controller.h"
  23. #include "Envelope.h"
  24. #include "../DSP/Filter.h"
  25. class SUBnote:public SynthNote
  26. {
  27. public:
  28. SUBnote(SUBnoteParameters *parameters, Controller *ctl_, float freq,
  29. float velocity, int portamento_, int midinote, bool besilent);
  30. ~SUBnote();
  31. void legatonote(float freq, float velocity, int portamento_,
  32. int midinote, bool externcall);
  33. int noteout(float *outl, float *outr); //note output,return 0 if the note is finished
  34. void relasekey();
  35. int finished() const;
  36. private:
  37. void setup(float freq,
  38. float velocity,
  39. int portamento_,
  40. int midinote,
  41. bool legato = false);
  42. void computecurrentparameters();
  43. void initparameters(float freq);
  44. void KillNote();
  45. SUBnoteParameters *pars;
  46. //parameters
  47. int stereo;
  48. int numstages; //number of stages of filters
  49. int numharmonics; //number of harmonics (after the too higher hamonics are removed)
  50. int firstnumharmonics; //To keep track of the first note's numharmonics value, useful in legato mode.
  51. int start; //how the harmonics start
  52. float basefreq;
  53. float panning;
  54. Envelope *AmpEnvelope;
  55. Envelope *FreqEnvelope;
  56. Envelope *BandWidthEnvelope;
  57. Filter *GlobalFilterL, *GlobalFilterR;
  58. Envelope *GlobalFilterEnvelope;
  59. //internal values
  60. ONOFFTYPE NoteEnabled;
  61. int firsttick, portamento;
  62. float volume, oldamplitude, newamplitude;
  63. float GlobalFilterCenterPitch; //octaves
  64. float GlobalFilterFreqTracking;
  65. struct bpfilter {
  66. float freq, bw, amp; //filter parameters
  67. float a1, a2, b0, b2; //filter coefs. b1=0
  68. float xn1, xn2, yn1, yn2; //filter internal values
  69. };
  70. void initfilter(bpfilter &filter,
  71. float freq,
  72. float bw,
  73. float amp,
  74. float mag);
  75. float computerolloff(float freq);
  76. void computefiltercoefs(bpfilter &filter,
  77. float freq,
  78. float bw,
  79. float gain);
  80. inline void filter(bpfilter &filter, float *smps);
  81. bpfilter *lfilter, *rfilter;
  82. float overtone_rolloff[MAX_SUB_HARMONICS];
  83. float overtone_freq[MAX_SUB_HARMONICS];
  84. Controller *ctl;
  85. int oldpitchwheel, oldbandwidth;
  86. float globalfiltercenterq;
  87. };
  88. #endif