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.

SynthNote.h 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. Note.h - Abstract Base Class for synthesizers
  4. Copyright (C) 2010-2010 Mark McCurry
  5. Author: Mark McCurry
  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 SYNTH_NOTE_H
  18. #define SYNTH_NOTE_H
  19. #include "../globals.h"
  20. #include "../Params/FilterParams.h"
  21. class SynthNote
  22. {
  23. public:
  24. SynthNote(float freq, float vel, int port, int note, bool quiet);
  25. virtual ~SynthNote() {}
  26. /**Compute Output Samples
  27. * @return 0 if note is finished*/
  28. virtual int noteout(float *outl, float *outr) = 0;
  29. //TODO fix this spelling error [noisey commit]
  30. /**Release the key for the note and start release portion of envelopes.*/
  31. virtual void relasekey() = 0;
  32. /**Return if note is finished.
  33. * @return finished=1 unfinished=0*/
  34. virtual int finished() const = 0;
  35. virtual void legatonote(float freq, float velocity,
  36. int portamento_, int midinote_,
  37. bool externcall) = 0;
  38. /* For polyphonic aftertouch needed */
  39. void setVelocity(float velocity_);
  40. protected:
  41. // Legato transitions
  42. class Legato
  43. {
  44. public:
  45. Legato(float freq, float vel, int port,
  46. int note, bool quiet);
  47. void apply(SynthNote &note, float *outl, float *outr);
  48. int update(float freq, float velocity, int portamento_,
  49. int midinote_, bool externalcall);
  50. private:
  51. bool silent;
  52. float lastfreq;
  53. LegatoMsg msg;
  54. int decounter;
  55. struct { // Fade In/Out vars
  56. int length;
  57. float m, step;
  58. } fade;
  59. struct { // Note parameters
  60. float freq, vel;
  61. int portamento, midinote;
  62. } param;
  63. public: /* Some get routines for legatonote calls (aftertouch feature)*/
  64. float getFreq() {return param.freq; }
  65. float getVelocity() {return param.vel; }
  66. int getPortamento() {return param.portamento; }
  67. int getMidinote() {return param.midinote; }
  68. void setSilent(bool silent_) {silent = silent_; }
  69. void setDecounter(int decounter_) {decounter = decounter_; }
  70. } legato;
  71. };
  72. #endif