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.

346 lines
9.3KB

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