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.

107 lines
3.3KB

  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
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or (at your option) any later version.
  10. */
  11. #ifndef SUB_NOTE_H
  12. #define SUB_NOTE_H
  13. #include "SynthNote.h"
  14. #include "../globals.h"
  15. class SUBnote:public SynthNote
  16. {
  17. public:
  18. SUBnote(const SUBnoteParameters *parameters, SynthParams &pars);
  19. ~SUBnote();
  20. SynthNote *cloneLegato(void);
  21. void legatonote(LegatoParams pars);
  22. int noteout(float *outl, float *outr); //note output,return 0 if the note is finished
  23. void releasekey();
  24. bool finished() const;
  25. void entomb(void);
  26. private:
  27. void setup(float freq,
  28. float velocity,
  29. int portamento_,
  30. int midinote,
  31. bool legato = false);
  32. float setupFilters(int *pos, bool automation);
  33. void computecurrentparameters();
  34. /*
  35. * Initialize envelopes and global filter
  36. * calls computercurrentparameters()
  37. */
  38. void initparameters(float freq);
  39. void KillNote();
  40. const SUBnoteParameters &pars;
  41. //parameters
  42. bool stereo;
  43. int numstages; //number of stages of filters
  44. int numharmonics; //number of harmonics (after the too higher hamonics are removed)
  45. int firstnumharmonics; //To keep track of the first note's numharmonics value, useful in legato mode.
  46. int start; //how the harmonics start
  47. float basefreq;
  48. float BendAdjust;
  49. float OffsetHz;
  50. float panning;
  51. Envelope *AmpEnvelope;
  52. Envelope *FreqEnvelope;
  53. Envelope *BandWidthEnvelope;
  54. ModFilter *GlobalFilter;
  55. Envelope *GlobalFilterEnvelope;
  56. //internal values
  57. bool NoteEnabled;
  58. bool firsttick, portamento;
  59. float volume, oldamplitude, newamplitude;
  60. float oldreduceamp;
  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 chanOutput(float *out, bpfilter *bp, int buffer_size);
  67. void initfilter(bpfilter &filter,
  68. float freq,
  69. float bw,
  70. float amp,
  71. float mag,
  72. bool automation);
  73. float computerolloff(float freq);
  74. void computeallfiltercoefs(bpfilter *filters, float envfreq, float envbw, float gain);
  75. void computefiltercoefs(bpfilter &filter,
  76. float freq,
  77. float bw,
  78. float gain);
  79. inline void filter(bpfilter &filter, float *smps);
  80. bpfilter *lfilter, *rfilter;
  81. float overtone_rolloff[MAX_SUB_HARMONICS];
  82. float overtone_freq[MAX_SUB_HARMONICS];
  83. int oldpitchwheel, oldbandwidth;
  84. float globalfiltercenterq;
  85. float velocity;
  86. };
  87. #endif