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.

Controller.h 7.2KB

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