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.

323 lines
9.0KB

  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 "PresetsArray.h"
  21. enum FMTYPE {
  22. NONE, MORPH, RING_MOD, PHASE_MOD, FREQ_MOD, PITCH_MOD
  23. };
  24. static const int ADnote_unison_sizes[] =
  25. {1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 25, 30, 40, 50, 0};
  26. /*****************************************************************/
  27. /* GLOBAL PARAMETERS */
  28. /*****************************************************************/
  29. struct ADnoteGlobalParam {
  30. ADnoteGlobalParam();
  31. ~ADnoteGlobalParam();
  32. void defaults();
  33. void add2XML(XMLwrapper *xml);
  34. void getfromXML(XMLwrapper *xml);
  35. void paste(ADnoteGlobalParam &a);
  36. /* The instrument type - MONO/STEREO
  37. If the mode is MONO, the panning of voices are not used
  38. Stereo=1, Mono=0. */
  39. unsigned char PStereo;
  40. /******************************************
  41. * FREQUENCY GLOBAL PARAMETERS *
  42. ******************************************/
  43. unsigned short int PDetune; //fine detune
  44. unsigned short int PCoarseDetune; //coarse detune+octave
  45. unsigned char PDetuneType; //detune type
  46. unsigned char PBandwidth; //how much the relative fine detunes of the voices are changed
  47. EnvelopeParams *FreqEnvelope; //Frequency Envelope
  48. LFOParams *FreqLfo; //Frequency LFO
  49. /********************************************
  50. * AMPLITUDE GLOBAL PARAMETERS *
  51. ********************************************/
  52. /* Panning - 0 - random
  53. 1 - left
  54. 64 - center
  55. 127 - right */
  56. unsigned char PPanning;
  57. unsigned char PVolume;
  58. unsigned char PAmpVelocityScaleFunction;
  59. EnvelopeParams *AmpEnvelope;
  60. LFOParams *AmpLfo;
  61. unsigned char PPunchStrength, PPunchTime, PPunchStretch,
  62. PPunchVelocitySensing;
  63. /******************************************
  64. * FILTER GLOBAL PARAMETERS *
  65. ******************************************/
  66. FilterParams *GlobalFilter;
  67. // filter velocity sensing
  68. unsigned char PFilterVelocityScale;
  69. // filter velocity sensing
  70. unsigned char PFilterVelocityScaleFunction;
  71. EnvelopeParams *FilterEnvelope;
  72. LFOParams *FilterLfo;
  73. // RESONANCE
  74. Resonance *Reson;
  75. //how the randomness is applied to the harmonics on more voices using the same oscillator
  76. unsigned char Hrandgrouping;
  77. static const rtosc::Ports &ports;
  78. };
  79. /***********************************************************/
  80. /* VOICE PARAMETERS */
  81. /***********************************************************/
  82. struct ADnoteVoiceParam {
  83. void getfromXML(XMLwrapper *xml, unsigned nvoice);
  84. void add2XML(XMLwrapper *xml, bool fmoscilused);
  85. void paste(ADnoteVoiceParam &p);
  86. void defaults(void);
  87. void enable(const SYNTH_T &synth, FFTwrapper *fft, Resonance *Reson);
  88. void kill(void);
  89. float getUnisonFrequencySpreadCents(void) const;
  90. /** If the voice is enabled */
  91. unsigned char Enabled;
  92. /** How many subvoices are used in this voice */
  93. unsigned char Unison_size;
  94. /** How subvoices are spread */
  95. unsigned char Unison_frequency_spread;
  96. /** How much phase randomization */
  97. unsigned char Unison_phase_randomness;
  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. static const rtosc::Ports &ports;
  205. };
  206. class ADnoteParameters:public PresetsArray
  207. {
  208. public:
  209. ADnoteParameters(const SYNTH_T &synth, FFTwrapper *fft_);
  210. ~ADnoteParameters();
  211. ADnoteGlobalParam GlobalPar;
  212. ADnoteVoiceParam VoicePar[NUM_VOICES];
  213. void defaults();
  214. void add2XML(XMLwrapper *xml);
  215. void getfromXML(XMLwrapper *xml);
  216. void paste(ADnoteParameters &a);
  217. void pasteArray(ADnoteParameters &a, int section);
  218. float getBandwidthDetuneMultiplier() const;
  219. float getUnisonFrequencySpreadCents(int nvoice) const;
  220. int get_unison_size_index(int nvoice) const;
  221. void set_unison_size_index(int nvoice, int index);
  222. static const rtosc::Ports &ports;
  223. void defaults(int n); //n is the nvoice
  224. void add2XMLsection(XMLwrapper *xml, int n);
  225. void getfromXMLsection(XMLwrapper *xml, int n);
  226. private:
  227. void EnableVoice(const SYNTH_T &synth, int nvoice);
  228. void KillVoice(int nvoice);
  229. FFTwrapper *fft;
  230. };
  231. #endif