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.

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