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.

108 lines
3.4KB

  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 "../DSP/Filter.h"
  22. class SUBnote:public SynthNote
  23. {
  24. public:
  25. SUBnote(const SUBnoteParameters *parameters, SynthParams &pars);
  26. ~SUBnote();
  27. SynthNote *cloneLegato(void);
  28. void legatonote(LegatoParams pars);
  29. int noteout(float *outl, float *outr); //note output,return 0 if the note is finished
  30. void releasekey();
  31. int finished() const;
  32. private:
  33. void setup(float freq,
  34. float velocity,
  35. int portamento_,
  36. int midinote,
  37. bool legato = false);
  38. void computecurrentparameters();
  39. void initparameters(float freq);
  40. void KillNote();
  41. const SUBnoteParameters &pars;
  42. //parameters
  43. bool stereo;
  44. int numstages; //number of stages of filters
  45. int numharmonics; //number of harmonics (after the too higher hamonics are removed)
  46. int firstnumharmonics; //To keep track of the first note's numharmonics value, useful in legato mode.
  47. int start; //how the harmonics start
  48. float basefreq;
  49. float panning;
  50. Envelope *AmpEnvelope;
  51. Envelope *FreqEnvelope;
  52. Envelope *BandWidthEnvelope;
  53. Filter *GlobalFilterL, *GlobalFilterR;
  54. Envelope *GlobalFilterEnvelope;
  55. //internal values
  56. ONOFFTYPE NoteEnabled;
  57. int firsttick, portamento;
  58. float volume, oldamplitude, newamplitude;
  59. float GlobalFilterCenterPitch; //octaves
  60. float GlobalFilterFreqTracking;
  61. struct bpfilter {
  62. float freq, bw, amp; //filter parameters
  63. float a1, a2, b0, b2; //filter coefs. b1=0
  64. float xn1, xn2, yn1, yn2; //filter internal values
  65. };
  66. void initfilter(bpfilter &filter,
  67. float freq,
  68. float bw,
  69. float amp,
  70. float mag);
  71. float computerolloff(float freq);
  72. void computefiltercoefs(bpfilter &filter,
  73. float freq,
  74. float bw,
  75. float gain);
  76. inline void filter(bpfilter &filter, float *smps);
  77. bpfilter *lfilter, *rfilter;
  78. float overtone_rolloff[MAX_SUB_HARMONICS];
  79. float overtone_freq[MAX_SUB_HARMONICS];
  80. int oldpitchwheel, oldbandwidth;
  81. float globalfiltercenterq;
  82. float velocity;
  83. };
  84. #endif