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.

342 lines
9.2KB

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