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.

317 lines
8.6KB

  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. ADnoteParameters.h - Parameters for ADnote (ADsynth)
  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 AD_NOTE_PARAMETERS_H
  18. #define AD_NOTE_PARAMETERS_H
  19. #include "../globals.h"
  20. #include "../Misc/Util.h"
  21. #include "PresetsArray.h"
  22. class EnvelopeParams;
  23. class LFOParams;
  24. class FilterParams;
  25. class Resonance;
  26. class OscilGen;
  27. class FFTwrapper;
  28. enum FMTYPE {
  29. NONE, MORPH, RING_MOD, PHASE_MOD, FREQ_MOD, PITCH_MOD
  30. };
  31. extern int ADnote_unison_sizes[];
  32. /*****************************************************************/
  33. /* GLOBAL PARAMETERS */
  34. /*****************************************************************/
  35. struct ADnoteGlobalParam {
  36. ADnoteGlobalParam();
  37. ~ADnoteGlobalParam();
  38. void defaults();
  39. void add2XML(XMLwrapper *xml);
  40. void getfromXML(XMLwrapper *xml);
  41. /* The instrument type - MONO/STEREO
  42. If the mode is MONO, the panning of voices are not used
  43. Stereo=1, Mono=0. */
  44. unsigned char PStereo;
  45. /******************************************
  46. * FREQUENCY GLOBAL PARAMETERS *
  47. ******************************************/
  48. unsigned short int PDetune; //fine detune
  49. unsigned short int PCoarseDetune; //coarse detune+octave
  50. unsigned char PDetuneType; //detune type
  51. unsigned char PBandwidth; //how much the relative fine detunes of the voices are changed
  52. EnvelopeParams *FreqEnvelope; //Frequency Envelope
  53. LFOParams *FreqLfo; //Frequency LFO
  54. /********************************************
  55. * AMPLITUDE GLOBAL PARAMETERS *
  56. ********************************************/
  57. /* Panning - 0 - random
  58. 1 - left
  59. 64 - center
  60. 127 - right */
  61. unsigned char PPanning;
  62. unsigned char PVolume;
  63. unsigned char PAmpVelocityScaleFunction;
  64. EnvelopeParams *AmpEnvelope;
  65. LFOParams *AmpLfo;
  66. unsigned char PPunchStrength, PPunchTime, PPunchStretch,
  67. PPunchVelocitySensing;
  68. /******************************************
  69. * FILTER GLOBAL PARAMETERS *
  70. ******************************************/
  71. FilterParams *GlobalFilter;
  72. // filter velocity sensing
  73. unsigned char PFilterVelocityScale;
  74. // filter velocity sensing
  75. unsigned char PFilterVelocityScaleFunction;
  76. EnvelopeParams *FilterEnvelope;
  77. LFOParams *FilterLfo;
  78. // RESONANCE
  79. Resonance *Reson;
  80. //how the randomness is applied to the harmonics on more voices using the same oscillator
  81. unsigned char Hrandgrouping;
  82. };
  83. /***********************************************************/
  84. /* VOICE PARAMETERS */
  85. /***********************************************************/
  86. struct ADnoteVoiceParam {
  87. void getfromXML(XMLwrapper *xml, unsigned nvoice);
  88. void add2XML(XMLwrapper *xml, bool fmoscilused);
  89. void defaults();
  90. void enable(FFTwrapper *fft, Resonance *Reson);
  91. void kill();
  92. /** If the voice is enabled */
  93. unsigned char Enabled;
  94. /** How many subvoices are used in this voice */
  95. unsigned char Unison_size;
  96. /** How subvoices are spread */
  97. unsigned char Unison_frequency_spread;
  98. /** Stereo spread of the subvoices*/
  99. unsigned char Unison_stereo_spread;
  100. /** Vibratto of the subvoices (which makes the unison more "natural")*/
  101. unsigned char Unison_vibratto;
  102. /** Medium speed of the vibratto of the subvoices*/
  103. unsigned char Unison_vibratto_speed;
  104. /** Unison invert phase */
  105. unsigned char Unison_invert_phase; //0=none,1=random,2=50%,3=33%,4=25%
  106. /** Type of the voice (0=Sound,1=Noise)*/
  107. unsigned char Type;
  108. /** Voice Delay */
  109. unsigned char PDelay;
  110. /** If the resonance is enabled for this voice */
  111. unsigned char Presonance;
  112. // What external oscil should I use, -1 for internal OscilSmp&FMSmp
  113. short int Pextoscil, PextFMoscil;
  114. // it is not allowed that the externoscil,externFMoscil => current voice
  115. // oscillator phases
  116. unsigned char Poscilphase, PFMoscilphase;
  117. // filter bypass
  118. unsigned char Pfilterbypass;
  119. /** Voice oscillator */
  120. OscilGen *OscilSmp;
  121. /**********************************
  122. * FREQUENCY PARAMETERS *
  123. **********************************/
  124. /** If the base frequency is fixed to 440 Hz*/
  125. unsigned char Pfixedfreq;
  126. /* Equal temperate (this is used only if the Pfixedfreq is enabled)
  127. If this parameter is 0, the frequency is fixed (to 440 Hz);
  128. if this parameter is 64, 1 MIDI halftone -> 1 frequency halftone */
  129. unsigned char PfixedfreqET;
  130. /** Fine detune */
  131. unsigned short int PDetune;
  132. /** Coarse detune + octave */
  133. unsigned short int PCoarseDetune;
  134. /** Detune type */
  135. unsigned char PDetuneType;
  136. /* Frequency Envelope */
  137. unsigned char PFreqEnvelopeEnabled;
  138. EnvelopeParams *FreqEnvelope;
  139. /* Frequency LFO */
  140. unsigned char PFreqLfoEnabled;
  141. LFOParams *FreqLfo;
  142. /***************************
  143. * AMPLITUDE PARAMETERS *
  144. ***************************/
  145. /* Panning 0 - random
  146. 1 - left
  147. 64 - center
  148. 127 - right
  149. The Panning is ignored if the instrument is mono */
  150. unsigned char PPanning;
  151. /* Voice Volume */
  152. unsigned char PVolume;
  153. /* If the Volume negative */
  154. unsigned char PVolumeminus;
  155. /* Velocity sensing */
  156. unsigned char PAmpVelocityScaleFunction;
  157. /* Amplitude Envelope */
  158. unsigned char PAmpEnvelopeEnabled;
  159. EnvelopeParams *AmpEnvelope;
  160. /* Amplitude LFO */
  161. unsigned char PAmpLfoEnabled;
  162. LFOParams *AmpLfo;
  163. /*************************
  164. * FILTER PARAMETERS *
  165. *************************/
  166. /* Voice Filter */
  167. unsigned char PFilterEnabled;
  168. FilterParams *VoiceFilter;
  169. /* Filter Envelope */
  170. unsigned char PFilterEnvelopeEnabled;
  171. EnvelopeParams *FilterEnvelope;
  172. /* LFO Envelope */
  173. unsigned char PFilterLfoEnabled;
  174. LFOParams *FilterLfo;
  175. /****************************
  176. * MODULLATOR PARAMETERS *
  177. ****************************/
  178. /* Modullator Parameters (0=off,1=Morph,2=RM,3=PM,4=FM.. */
  179. unsigned char PFMEnabled;
  180. /* Voice that I use as modullator instead of FMSmp.
  181. It is -1 if I use FMSmp(default).
  182. It maynot be equal or bigger than current voice */
  183. short int PFMVoice;
  184. /* Modullator oscillator */
  185. OscilGen *FMSmp;
  186. /* Modullator Volume */
  187. unsigned char PFMVolume;
  188. /* Modullator damping at higher frequencies */
  189. unsigned char PFMVolumeDamp;
  190. /* Modullator Velocity Sensing */
  191. unsigned char PFMVelocityScaleFunction;
  192. /* Fine Detune of the Modullator*/
  193. unsigned short int PFMDetune;
  194. /* Coarse Detune of the Modullator */
  195. unsigned short int PFMCoarseDetune;
  196. /* The detune type */
  197. unsigned char PFMDetuneType;
  198. /* Frequency Envelope of the Modullator */
  199. unsigned char PFMFreqEnvelopeEnabled;
  200. EnvelopeParams *FMFreqEnvelope;
  201. /* Frequency Envelope of the Modullator */
  202. unsigned char PFMAmpEnvelopeEnabled;
  203. EnvelopeParams *FMAmpEnvelope;
  204. };
  205. class ADnoteParameters:public PresetsArray
  206. {
  207. public:
  208. ADnoteParameters(FFTwrapper *fft_);
  209. ~ADnoteParameters();
  210. ADnoteGlobalParam GlobalPar;
  211. ADnoteVoiceParam VoicePar[NUM_VOICES];
  212. void defaults();
  213. void add2XML(XMLwrapper *xml);
  214. void getfromXML(XMLwrapper *xml);
  215. float getBandwidthDetuneMultiplier();
  216. float getUnisonFrequencySpreadCents(int nvoice);
  217. int get_unison_size_index(int nvoice);
  218. void set_unison_size_index(int nvoice, int index);
  219. private:
  220. void defaults(int n); //n is the nvoice
  221. void EnableVoice(int nvoice);
  222. void KillVoice(int nvoice);
  223. FFTwrapper *fft;
  224. void add2XMLsection(XMLwrapper *xml, int n);
  225. void getfromXMLsection(XMLwrapper *xml, int n);
  226. };
  227. #endif