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.

330 lines
9.1KB

  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. /*****************************************************************/
  25. /* GLOBAL PARAMETERS */
  26. /*****************************************************************/
  27. struct ADnoteGlobalParam {
  28. ADnoteGlobalParam();
  29. ~ADnoteGlobalParam();
  30. void defaults();
  31. void add2XML(XMLwrapper *xml);
  32. void getfromXML(XMLwrapper *xml);
  33. void paste(ADnoteGlobalParam &a);
  34. /* The instrument type - MONO/STEREO
  35. If the mode is MONO, the panning of voices are not used
  36. Stereo=1, Mono=0. */
  37. unsigned char PStereo;
  38. /******************************************
  39. * FREQUENCY GLOBAL PARAMETERS *
  40. ******************************************/
  41. unsigned short int PDetune; //fine detune
  42. unsigned short int PCoarseDetune; //coarse detune+octave
  43. unsigned char PDetuneType; //detune type
  44. unsigned char PBandwidth; //how much the relative fine detunes of the voices are changed
  45. EnvelopeParams *FreqEnvelope; //Frequency Envelope
  46. LFOParams *FreqLfo; //Frequency LFO
  47. /********************************************
  48. * AMPLITUDE GLOBAL PARAMETERS *
  49. ********************************************/
  50. /* Panning - 0 - random
  51. 1 - left
  52. 64 - center
  53. 127 - right */
  54. unsigned char PPanning;
  55. unsigned char PVolume;
  56. unsigned char PAmpVelocityScaleFunction;
  57. EnvelopeParams *AmpEnvelope;
  58. LFOParams *AmpLfo;
  59. /* Adjustment factor for anti-pop fadein */
  60. unsigned char Fadein_adjustment;
  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. /* Filter LFO */
  173. unsigned char PFilterLfoEnabled;
  174. LFOParams *FilterLfo;
  175. // filter velocity sensing
  176. unsigned char PFilterVelocityScale;
  177. // filter velocity sensing
  178. unsigned char PFilterVelocityScaleFunction;
  179. /****************************
  180. * MODULLATOR PARAMETERS *
  181. ****************************/
  182. /* Modullator Parameters (0=off,1=Morph,2=RM,3=PM,4=FM.. */
  183. unsigned char PFMEnabled;
  184. /* Voice that I use as modullator instead of FMSmp.
  185. It is -1 if I use FMSmp(default).
  186. It maynot be equal or bigger than current voice */
  187. short int PFMVoice;
  188. /* Modullator oscillator */
  189. OscilGen *FMSmp;
  190. /* Modullator Volume */
  191. unsigned char PFMVolume;
  192. /* Modullator damping at higher frequencies */
  193. unsigned char PFMVolumeDamp;
  194. /* Modullator Velocity Sensing */
  195. unsigned char PFMVelocityScaleFunction;
  196. /* Fine Detune of the Modullator*/
  197. unsigned short int PFMDetune;
  198. /* Coarse Detune of the Modullator */
  199. unsigned short int PFMCoarseDetune;
  200. /* The detune type */
  201. unsigned char PFMDetuneType;
  202. /* Frequency Envelope of the Modullator */
  203. unsigned char PFMFreqEnvelopeEnabled;
  204. EnvelopeParams *FMFreqEnvelope;
  205. /* Frequency Envelope of the Modullator */
  206. unsigned char PFMAmpEnvelopeEnabled;
  207. EnvelopeParams *FMAmpEnvelope;
  208. unsigned char *GlobalPDetuneType;
  209. static const rtosc::Ports &ports;
  210. };
  211. class ADnoteParameters:public PresetsArray
  212. {
  213. public:
  214. ADnoteParameters(const SYNTH_T &synth, FFTwrapper *fft_);
  215. ~ADnoteParameters();
  216. ADnoteGlobalParam GlobalPar;
  217. ADnoteVoiceParam VoicePar[NUM_VOICES];
  218. void defaults();
  219. void add2XML(XMLwrapper *xml);
  220. void getfromXML(XMLwrapper *xml);
  221. void paste(ADnoteParameters &a);
  222. void pasteArray(ADnoteParameters &a, int section);
  223. float getBandwidthDetuneMultiplier() const;
  224. float getUnisonFrequencySpreadCents(int nvoice) const;
  225. static const rtosc::Ports &ports;
  226. void defaults(int n); //n is the nvoice
  227. void add2XMLsection(XMLwrapper *xml, int n);
  228. void getfromXMLsection(XMLwrapper *xml, int n);
  229. private:
  230. void EnableVoice(const SYNTH_T &synth, int nvoice);
  231. void KillVoice(int nvoice);
  232. FFTwrapper *fft;
  233. };
  234. #endif