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.

SUBnote.h 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. namespace zyncarla {
  16. class SUBnote:public SynthNote
  17. {
  18. public:
  19. SUBnote(const SUBnoteParameters *parameters, SynthParams &pars);
  20. ~SUBnote();
  21. SynthNote *cloneLegato(void);
  22. void legatonote(LegatoParams pars);
  23. int noteout(float *outl, float *outr); //note output,return 0 if the note is finished
  24. void releasekey();
  25. bool finished() const;
  26. void entomb(void);
  27. private:
  28. void setup(float freq,
  29. float velocity,
  30. int portamento_,
  31. int midinote,
  32. bool legato = false);
  33. float setupFilters(int *pos, bool automation);
  34. void computecurrentparameters();
  35. /*
  36. * Initialize envelopes and global filter
  37. * calls computercurrentparameters()
  38. */
  39. void initparameters(float freq, WatchManager *wm);
  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 BendAdjust;
  50. float OffsetHz;
  51. float panning;
  52. Envelope *AmpEnvelope;
  53. Envelope *FreqEnvelope;
  54. Envelope *BandWidthEnvelope;
  55. ModFilter *GlobalFilter;
  56. Envelope *GlobalFilterEnvelope;
  57. //internal values
  58. bool NoteEnabled;
  59. bool firsttick, portamento;
  60. float volume, oldamplitude, newamplitude;
  61. float oldreduceamp;
  62. struct bpfilter {
  63. float freq, bw, amp; //filter parameters
  64. float a1, a2, b0, b2; //filter coefs. b1=0
  65. float xn1, xn2, yn1, yn2; //filter internal values
  66. };
  67. void chanOutput(float *out, bpfilter *bp, int buffer_size);
  68. void initfilter(bpfilter &filter,
  69. float freq,
  70. float bw,
  71. float amp,
  72. float mag,
  73. bool automation);
  74. float computerolloff(float freq);
  75. void computeallfiltercoefs(bpfilter *filters, float envfreq, float envbw, float gain);
  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. int oldpitchwheel, oldbandwidth;
  85. float globalfiltercenterq;
  86. float velocity;
  87. WatchManager *wm;
  88. };
  89. }
  90. #endif