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.

221 lines
7.1KB

  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. Controller.h - (Midi) Controllers implementation
  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 CONTROLLER_H
  18. #define CONTROLLER_H
  19. #include "../globals.h"
  20. #include "../Misc/XMLwrapper.h"
  21. /**(Midi) Controllers implementation*/
  22. class Controller
  23. {
  24. public:
  25. Controller();
  26. ~Controller();
  27. void resetall();
  28. void add2XML(XMLwrapper *xml);
  29. void defaults();
  30. void getfromXML(XMLwrapper *xml);
  31. //Controllers functions
  32. void setpitchwheel(int value);
  33. void setpitchwheelbendrange(unsigned short int value);
  34. void setexpression(int value);
  35. void setpanning(int value);
  36. void setfiltercutoff(int value);
  37. void setfilterq(int value);
  38. void setbandwidth(int value);
  39. void setmodwheel(int value);
  40. void setfmamp(int value);
  41. void setvolume(int value);
  42. void setsustain(int value);
  43. /**Enable or disable portamento
  44. * @param value 0-127 MIDI value (greater than 64 enables)*/
  45. void setportamento(int value);
  46. void setresonancecenter(int value);
  47. void setresonancebw(int value);
  48. void setparameternumber(unsigned int type, int value); //used for RPN and NRPN's
  49. int getnrpn(int *parhi, int *parlo, int *valhi, int *vallo);
  50. /**
  51. * Initialize a portamento
  52. *
  53. * @param oldfreq Starting frequency of the portamento (Hz)
  54. * @param newfreq Ending frequency of the portamento (Hz)
  55. * @param legatoflag true when legato is in progress, false otherwise
  56. * @returns 1 if properly initialized, 0 otherwise*/
  57. int initportamento(float oldfreq, float newfreq, bool legatoflag);
  58. /**Update portamento's freqrap to next value based upon dx*/
  59. void updateportamento();
  60. // Controllers values
  61. struct { //Pitch Wheel
  62. int data;
  63. short int bendrange; //bendrange is in cents
  64. float relfreq; //the relative frequency (default is 1.0f)
  65. } pitchwheel;
  66. struct { //Expression
  67. int data;
  68. float relvolume;
  69. unsigned char receive;
  70. } expression;
  71. struct { //Panning
  72. int data;
  73. float pan;
  74. unsigned char depth;
  75. } panning;
  76. struct { //Filter cutoff
  77. int data;
  78. float relfreq;
  79. unsigned char depth;
  80. } filtercutoff;
  81. struct { //Filter Q
  82. int data;
  83. float relq;
  84. unsigned char depth;
  85. } filterq;
  86. struct { //Bandwidth
  87. int data;
  88. float relbw;
  89. unsigned char depth;
  90. unsigned char exponential;
  91. } bandwidth;
  92. struct { //Modulation Wheel
  93. int data;
  94. float relmod;
  95. unsigned char depth;
  96. unsigned char exponential;
  97. } modwheel;
  98. struct { //FM amplitude
  99. int data;
  100. float relamp;
  101. unsigned char receive;
  102. } fmamp;
  103. struct { //Volume
  104. int data;
  105. float volume;
  106. unsigned char receive;
  107. } volume;
  108. struct { //Sustain
  109. int data, sustain;
  110. unsigned char receive;
  111. } sustain;
  112. struct { /**<Portamento*/
  113. //parameters
  114. int data;
  115. unsigned char portamento;
  116. /**Whether the portamento midi events are received or not*/
  117. unsigned char receive;
  118. /** The time that it takes for the portamento to complete
  119. *
  120. * Translates in an expontal fashion to 0 Seconds to 1.93f Seconds
  121. * of completion time*/
  122. unsigned char time;
  123. /**If the portamento is proportinal to the distance spanned
  124. *
  125. * 0 - constant time(default)
  126. * 1 - proportional*/
  127. unsigned char proportional;
  128. /**Rate of proportinal portamento*/
  129. unsigned char propRate;
  130. /**Depth of proportinal portamento*/
  131. unsigned char propDepth;
  132. /**pitchthresh is the threshold of enabling protamento*/
  133. unsigned char pitchthresh;
  134. /**enable the portamento only below(0)/above(1) the threshold*/
  135. unsigned char pitchthreshtype;
  136. /**this value represent how the portamento time is reduced
  137. * 0 - for down portamento
  138. * 1-63 - the up portamento's time is smaller than the down portamento
  139. * 64 - the portamento time is always the same
  140. * 64-126 - the down portamento's time is smaller than the up portamento
  141. * 127 - for upper portamento
  142. * 'up portamento' means when the frequency is rising
  143. * (eg: the portamento is from 200Hz to 300 Hz)
  144. * 'down portamento' means when the frequency is lowering
  145. * (eg: the portamento is from 300Hz to 200 Hz)
  146. */
  147. unsigned char updowntimestretch;
  148. /**this value is used to compute the actual portamento
  149. *
  150. * This is a multiplyer to change the frequency of the newer
  151. * frequency to fit the profile of the portamento.
  152. * This will be linear with respect to x.*/
  153. float freqrap;
  154. /**this is used by the Part for knowing which note uses the portamento*/
  155. int noteusing;
  156. /**if a the portamento is used by a note
  157. * \todo see if this can be a bool*/
  158. int used;
  159. //Internal data
  160. /**x is from 0.0f (start portamento) to 1.0f (finished portamento)*/
  161. float x;
  162. /**dx is the increment to x when updateportamento is called*/
  163. float dx;
  164. /** this is used for computing oldfreq value from x*/
  165. float origfreqrap;
  166. } portamento;
  167. struct { //Resonance Center Frequency
  168. int data;
  169. float relcenter;
  170. unsigned char depth;
  171. } resonancecenter;
  172. struct { //Resonance Bandwidth
  173. int data;
  174. float relbw;
  175. unsigned char depth;
  176. } resonancebandwidth;
  177. /** RPN and NPRPN */
  178. struct { //nrpn
  179. int parhi, parlo;
  180. int valhi, vallo;
  181. unsigned char receive; //this is saved to disk by Master
  182. } NRPN;
  183. private:
  184. };
  185. #endif