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.

1250 lines
40KB

  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. ADnoteParameters.cpp - 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. #include <stdlib.h>
  12. #include <stdio.h>
  13. #include <math.h>
  14. #include "ADnoteParameters.h"
  15. #include "EnvelopeParams.h"
  16. #include "LFOParams.h"
  17. #include "../Misc/Time.h"
  18. #include "../Misc/XMLwrapper.h"
  19. #include "../DSP/FFTwrapper.h"
  20. #include "../Synth/OscilGen.h"
  21. #include "../Synth/Resonance.h"
  22. #include "FilterParams.h"
  23. #include <rtosc/ports.h>
  24. #include <rtosc/port-sugar.h>
  25. using rtosc::Ports;
  26. using rtosc::RtData;
  27. #define EXPAND(x) x
  28. #define rObject ADnoteVoiceParam
  29. #undef rChangeCb
  30. #define rChangeCb if (obj->time) { obj->last_update_timestamp = obj->time->time(); }
  31. static const Ports voicePorts = {
  32. //Send Messages To Oscillator Realtime Table
  33. {"OscilSmp/", rDoc("Primary Oscillator"),
  34. &OscilGen::ports,
  35. rBOIL_BEGIN
  36. if(obj->OscilSmp == NULL) return;
  37. data.obj = obj->OscilSmp;
  38. SNIP
  39. OscilGen::realtime_ports.dispatch(msg, data);
  40. if(data.matches == 0)
  41. data.forward();
  42. rBOIL_END},
  43. {"FMSmp/", rDoc("Modulating Oscillator"),
  44. &OscilGen::ports,
  45. rBOIL_BEGIN
  46. if(obj->FMSmp == NULL) return;
  47. data.obj = obj->FMSmp;
  48. SNIP
  49. OscilGen::realtime_ports.dispatch(msg, data);
  50. if(data.matches == 0)
  51. data.forward();
  52. rBOIL_END},
  53. rRecurp(FreqLfo, "Frequency LFO"),
  54. rRecurp(AmpLfo, "Amplitude LFO"),
  55. rRecurp(FilterLfo, "Filter LFO"),
  56. rRecurp(FreqEnvelope, "Frequency Envelope"),
  57. rRecurp(AmpEnvelope, "Amplitude Envelope"),
  58. rRecurp(FilterEnvelope, "Filter Envelope"),
  59. rRecurp(FMFreqEnvelope, "Modulator Frequency Envelope"),
  60. rRecurp(FMAmpEnvelope, "Modulator Amplitude Envelope"),
  61. rRecurp(VoiceFilter, "Optional Voice Filter"),
  62. rToggle(Enabled, rShort("enable"), "Voice Enable"),
  63. rParamZyn(Unison_size, rShort("size"), "Number of subvoices"),
  64. rParamZyn(Unison_phase_randomness, rShort("ph.rnd."), "Phase Randomness"),
  65. rParamZyn(Unison_frequency_spread, rShort("detune"), "Subvoice detune"),
  66. rParamZyn(Unison_stereo_spread, rShort("spread"),
  67. "Subvoice L/R Separation"),
  68. rParamZyn(Unison_vibratto, rShort("vib."), "Subvoice vibratto"),
  69. rParamZyn(Unison_vibratto_speed, rShort("speed"),
  70. "Subvoice vibratto speed"),
  71. rOption(Unison_invert_phase, rShort("inv."),
  72. rOptions(none, random, 50%, 33%, 25%), "Subvoice Phases"),
  73. rOption(Type, rShort("type"), rOptions(Sound,White,Pink,DC), "Type of Sound"),
  74. rParamZyn(PDelay, rShort("delay"), "Voice Startup Delay"),
  75. rToggle(Presonance, rShort("enable"), "Resonance Enable"),
  76. rParamI(Pextoscil, rShort("ext."),
  77. rMap(min, -1), rMap(max, 16), "External Oscillator Selection"),
  78. rParamI(PextFMoscil, rShort("ext."),
  79. rMap(min, -1), rMap(max, 16), "External FM Oscillator Selection"),
  80. rParamZyn(Poscilphase, rShort("phase"), "Oscillator Phase"),
  81. rParamZyn(PFMoscilphase, rShort("phase"), "FM Oscillator Phase"),
  82. rToggle(Pfilterbypass, rShort("bypass"), "Filter Bypass"),
  83. //Freq Stuff
  84. rToggle(Pfixedfreq, rShort("fixed"), "If frequency is fixed"),
  85. rParamZyn(PfixedfreqET, rShort("e.t."), "Equal Temperament Parameter"),
  86. rParamZyn(PBendAdjust, rShort("bend"), "Pitch bend adjustment"),
  87. rParamZyn(POffsetHz, rShort("offset"), "Voice constant offset"),
  88. //nominally -8192..8191
  89. rParamI(PDetune, rShort("fine"),
  90. rLinear(0, 16383), "Fine Detune"),
  91. rParamI(PCoarseDetune, rShort("coarse"), "Coarse Detune"),
  92. rParamZyn(PDetuneType, rShort("type"),
  93. rOptions(L35cents, L10cents, E100cents, E1200cents),
  94. "Magnitude of Detune"),
  95. rToggle(PFreqEnvelopeEnabled, rShort("enable"), "Frequency Envelope Enable"),
  96. rToggle(PFreqLfoEnabled, rShort("enable"), "Frequency LFO Enable"),
  97. //Amplitude Stuff
  98. rParamZyn(PPanning, rShort("pan."), "Panning"),
  99. rParamZyn(PVolume, rShort("vol."), "Volume"),
  100. rToggle(PVolumeminus, rShort("inv."), "Signal Inverter"), //do we really need this??
  101. rParamZyn(PAmpVelocityScaleFunction, rShort("sense"), "Velocity Sensing"),
  102. rToggle(PAmpEnvelopeEnabled, rShort("enable"), "Amplitude Envelope Enable"),
  103. rToggle(PAmpLfoEnabled, rShort("enable"), "Amplitude LFO Enable"),
  104. //Filter Stuff
  105. rToggle(PFilterEnabled, rShort("enable"), "Filter Enable"),
  106. rToggle(PFilterEnvelopeEnabled, rShort("enable"), "Filter Envelope Enable"),
  107. rToggle(PFilterLfoEnabled, rShort("enable"), "Filter LFO Enable"),
  108. rParamZyn(PFilterVelocityScale, rShort("v.scale"), "Filter Velocity Magnitude"),
  109. rParamZyn(PFilterVelocityScaleFunction, rShort("v.sense"), "Filter Velocity Function Shape"),
  110. //Modulator Stuff
  111. rOption(PFMEnabled, rShort("mode"), rOptions(none, morph, ring, phase,
  112. frequency, pulse), "Modulator mode"),
  113. rParamI(PFMVoice, rShort("voice"), "Modulator Oscillator Selection"),
  114. rParamZyn(PFMVolume, rShort("vol."), "Modulator Magnitude"),
  115. rParamZyn(PFMVolumeDamp, rShort("damp."), "Modulator HF dampening"),
  116. rParamZyn(PFMVelocityScaleFunction, rShort("sense"), "Modulator Velocity Function"),
  117. //nominally -8192..8191
  118. rParamI(PFMDetune, rShort("fine"),
  119. rLinear(0, 16383), "Modulator Fine Detune"),
  120. rParamI(PFMCoarseDetune, rShort("coarse"), "Modulator Coarse Detune"),
  121. rParamZyn(PFMDetuneType, rShort("type"),
  122. rOptions(L35cents, L10cents, E100cents, E1200cents),
  123. "Modulator Detune Magnitude"),
  124. rToggle(PFMFixedFreq, rShort("fixed"), "Modulator Frequency Fixed"),
  125. rToggle(PFMFreqEnvelopeEnabled, rShort("enable"), "Modulator Frequency Envelope"),
  126. rToggle(PFMAmpEnvelopeEnabled, rShort("enable"), "Modulator Amplitude Envelope"),
  127. //weird stuff for PCoarseDetune
  128. {"detunevalue:", rMap(unit,cents) rDoc("Get detune in cents"), NULL,
  129. [](const char *, RtData &d)
  130. {
  131. rObject *obj = (rObject *)d.obj;
  132. unsigned detuneType =
  133. obj->PDetuneType == 0 ? *(obj->GlobalPDetuneType)
  134. : obj->PDetuneType;
  135. //TODO check if this is accurate or if PCoarseDetune is utilized
  136. //TODO do the same for the other engines
  137. d.reply(d.loc, "f", getdetune(detuneType, 0, obj->PDetune));
  138. }},
  139. {"octave::c:i", rProp(parameter) rShort("octave") rLinear(-8, 7) rDoc("Octave note offset"),
  140. NULL,
  141. [](const char *msg, RtData &d)
  142. {
  143. rObject *obj = (rObject *)d.obj;
  144. if(!rtosc_narguments(msg)) {
  145. int k=obj->PCoarseDetune/1024;
  146. if (k>=8) k-=16;
  147. d.reply(d.loc, "i", k);
  148. } else {
  149. int k=(int) rtosc_argument(msg, 0).i;
  150. if (k<0) k+=16;
  151. obj->PCoarseDetune = k*1024 + obj->PCoarseDetune%1024;
  152. }
  153. }},
  154. {"coarsedetune::c:i", rProp(parameter) rShort("coarse") rLinear(-64,63)
  155. rDoc("Coarse note detune"), NULL,
  156. [](const char *msg, RtData &d)
  157. {
  158. rObject *obj = (rObject *)d.obj;
  159. if(!rtosc_narguments(msg)) {
  160. int k=obj->PCoarseDetune%1024;
  161. if (k>=512) k-=1024;
  162. d.reply(d.loc, "i", k);
  163. } else {
  164. int k=(int) rtosc_argument(msg, 0).i;
  165. if (k<0) k+=1024;
  166. obj->PCoarseDetune = k + (obj->PCoarseDetune/1024)*1024;
  167. }
  168. }},
  169. //weird stuff for PCoarseDetune
  170. {"FMdetunevalue:", rMap(unit,cents) rDoc("Get modulator detune"), NULL, [](const char *, RtData &d)
  171. {
  172. rObject *obj = (rObject *)d.obj;
  173. unsigned detuneType =
  174. obj->PFMDetuneType == 0 ? *(obj->GlobalPDetuneType)
  175. : obj->PFMDetuneType;
  176. //TODO check if this is accurate or if PCoarseDetune is utilized
  177. //TODO do the same for the other engines
  178. d.reply(d.loc, "f", getdetune(detuneType, 0, obj->PFMDetune));
  179. }},
  180. {"FMoctave::c:i", rProp(parameter) rShort("octave") rLinear(-8,7) rDoc("Octave note offset for modulator"), NULL,
  181. [](const char *msg, RtData &d)
  182. {
  183. rObject *obj = (rObject *)d.obj;
  184. if(!rtosc_narguments(msg)) {
  185. int k=obj->PFMCoarseDetune/1024;
  186. if (k>=8) k-=16;
  187. d.reply(d.loc, "i", k);
  188. } else {
  189. int k=(int) rtosc_argument(msg, 0).i;
  190. if (k<0) k+=16;
  191. obj->PFMCoarseDetune = k*1024 + obj->PFMCoarseDetune%1024;
  192. }
  193. }},
  194. {"FMcoarsedetune::c:i", rProp(parameter) rShort("coarse") rLinear(-64,63)
  195. rDoc("Coarse note detune for modulator"),
  196. NULL, [](const char *msg, RtData &d)
  197. {
  198. rObject *obj = (rObject *)d.obj;
  199. if(!rtosc_narguments(msg)) {
  200. int k=obj->PFMCoarseDetune%1024;
  201. if (k>=512) k-=1024;
  202. d.reply(d.loc, "i", k);
  203. } else {
  204. int k=(int) rtosc_argument(msg, 0).i;
  205. if (k<0) k+=1024;
  206. obj->PFMCoarseDetune = k + (obj->PFMCoarseDetune/1024)*1024;
  207. }
  208. }},
  209. //Reader
  210. {"unisonFrequencySpreadCents:", rMap(unit,cents) rDoc("Unison Frequency Spread"),
  211. NULL, [](const char *, RtData &d)
  212. {
  213. rObject *obj = (rObject *)d.obj;
  214. d.reply(d.loc, "f", obj->getUnisonFrequencySpreadCents());
  215. }},
  216. };
  217. #undef rChangeCb
  218. #undef rObject
  219. #define rObject ADnoteGlobalParam
  220. #define rChangeCb if (obj->time) { obj->last_update_timestamp = obj->time->time(); }
  221. static const Ports globalPorts = {
  222. rRecurp(Reson, "Resonance"),
  223. rRecurp(FreqLfo, "Frequency LFO"),
  224. rRecurp(AmpLfo, "Amplitude LFO"),
  225. rRecurp(FilterLfo, "Filter LFO"),
  226. rRecurp(FreqEnvelope, "Frequency Envelope"),
  227. rRecurp(AmpEnvelope, "Frequency Envelope"),
  228. rRecurp(FilterEnvelope, "Frequency Envelope"),
  229. rRecurp(GlobalFilter, "Filter"),
  230. rToggle(PStereo, rShort("stereo"), "Mono/Stereo Enable"),
  231. //Frequency
  232. //nominally -8192..8191
  233. rParamI(PDetune, rShort("fine"),
  234. rLinear(0, 16383), "Fine Detune"),
  235. rParamI(PCoarseDetune, rShort("coarse"), "Coarse Detune"),
  236. rParamZyn(PDetuneType, rShort("type"),
  237. rOptions(L35cents, L10cents, E100cents, E1200cents),
  238. "Detune Scaling Type"),
  239. rParamZyn(PBandwidth, rShort("bw."), "Relative Fine Detune Gain"),
  240. //Amplitude
  241. rParamZyn(PPanning, rShort("pan"), "Panning of ADsynth (0 random, 1 left, 127 right)"),
  242. rParamZyn(PVolume, rShort("vol"), "volume control"),
  243. rParamZyn(PAmpVelocityScaleFunction, rShort("scale"), "Volume Velocity Control"),
  244. rParamZyn(Fadein_adjustment, "Adjustment for anti-pop strategy."),
  245. rParamZyn(PPunchStrength, rShort("strength"), "Punch Strength"),
  246. rParamZyn(PPunchTime, rShort("time"), "Length of Punch"),
  247. rParamZyn(PPunchStretch, rShort("stretch"), "How Punch changes with note frequency"),
  248. rParamZyn(PPunchVelocitySensing, rShort("v.sns"), "Punch Velocity control"),
  249. //Filter
  250. rParamZyn(PFilterVelocityScale, rShort("scale"), "Filter Velocity Magnitude"),
  251. rParamZyn(PFilterVelocityScaleFunction, rShort("sense"), "Filter Velocity Function Shape"),
  252. //Resonance
  253. rToggle(Hrandgrouping, "How randomness is applied to multiple voices using the same oscil"),
  254. //weird stuff for PCoarseDetune
  255. {"detunevalue:", rMap(unit,cents) rDoc("Get detune in cents"), NULL,
  256. [](const char *, RtData &d)
  257. {
  258. rObject *obj = (rObject *)d.obj;
  259. d.reply(d.loc, "f", getdetune(obj->PDetuneType, 0, obj->PDetune));
  260. }},
  261. {"octave::c:i", rProp(parameter) rShort("octave") rLinear(-8,7)
  262. rDoc("Octave note offset"), NULL,
  263. [](const char *msg, RtData &d)
  264. {
  265. rObject *obj = (rObject *)d.obj;
  266. if(!rtosc_narguments(msg)) {
  267. int k=obj->PCoarseDetune/1024;
  268. if (k>=8) k-=16;
  269. d.reply(d.loc, "i", k);
  270. } else {
  271. int k=(int) rtosc_argument(msg, 0).i;
  272. if (k<0) k+=16;
  273. obj->PCoarseDetune = k*1024 + obj->PCoarseDetune%1024;
  274. }
  275. }},
  276. {"coarsedetune::c:i", rProp(parameter) rShort("coarse") rLinear(-64, 63)
  277. rDoc("Coarse note detune"), NULL,
  278. [](const char *msg, RtData &d)
  279. {
  280. rObject *obj = (rObject *)d.obj;
  281. if(!rtosc_narguments(msg)) {
  282. int k=obj->PCoarseDetune%1024;
  283. if (k>=512) k-=1024;
  284. d.reply(d.loc, "i", k);
  285. } else {
  286. int k=(int) rtosc_argument(msg, 0).i;
  287. if (k<0) k+=1024;
  288. obj->PCoarseDetune = k + (obj->PCoarseDetune/1024)*1024;
  289. }
  290. }},
  291. };
  292. #undef rChangeCb
  293. #undef rObject
  294. #define rObject ADnoteParameters
  295. #define rChangeCb obj->last_update_timestamp = obj->time.time();
  296. static const Ports adPorts = {//XXX 16 should not be hard coded
  297. rSelf(ADnoteParameters),
  298. rPaste,
  299. rArrayPaste,
  300. rRecurs(VoicePar, NUM_VOICES),
  301. rRecur(GlobalPar, "Adnote Parameters"),
  302. };
  303. #undef rChangeCb
  304. const Ports &ADnoteParameters::ports = adPorts;
  305. const Ports &ADnoteVoiceParam::ports = voicePorts;
  306. const Ports &ADnoteGlobalParam::ports = globalPorts;
  307. ADnoteParameters::ADnoteParameters(const SYNTH_T &synth, FFTwrapper *fft_,
  308. const AbsTime *time_)
  309. :PresetsArray(), GlobalPar(time_), time(time_), last_update_timestamp(0)
  310. {
  311. setpresettype("Padsynth");
  312. fft = fft_;
  313. for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice) {
  314. VoicePar[nvoice].GlobalPDetuneType = &GlobalPar.PDetuneType;
  315. VoicePar[nvoice].time = time_;
  316. EnableVoice(synth, nvoice, time_);
  317. }
  318. defaults();
  319. }
  320. ADnoteGlobalParam::ADnoteGlobalParam(const AbsTime *time_) :
  321. time(time_), last_update_timestamp(0)
  322. {
  323. FreqEnvelope = new EnvelopeParams(0, 0, time_);
  324. FreqEnvelope->ASRinit(64, 50, 64, 60);
  325. FreqLfo = new LFOParams(70, 0, 64, 0, 0, 0, 0, 0, time_);
  326. AmpEnvelope = new EnvelopeParams(64, 1, time_);
  327. AmpEnvelope->ADSRinit_dB(0, 40, 127, 25);
  328. AmpLfo = new LFOParams(80, 0, 64, 0, 0, 0, 0, 1, time_);
  329. GlobalFilter = new FilterParams(2, 94, 40, time_);
  330. FilterEnvelope = new EnvelopeParams(0, 1, time_);
  331. FilterEnvelope->ADSRinit_filter(64, 40, 64, 70, 60, 64);
  332. FilterLfo = new LFOParams(80, 0, 64, 0, 0, 0, 0, 2, time_);
  333. Reson = new Resonance();
  334. }
  335. void ADnoteParameters::defaults()
  336. {
  337. //Default Parameters
  338. GlobalPar.defaults();
  339. for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice)
  340. defaults(nvoice);
  341. VoicePar[0].Enabled = 1;
  342. }
  343. void ADnoteGlobalParam::defaults()
  344. {
  345. /* Frequency Global Parameters */
  346. PStereo = 1; //stereo
  347. PDetune = 8192; //zero
  348. PCoarseDetune = 0;
  349. PDetuneType = 1;
  350. FreqEnvelope->defaults();
  351. FreqLfo->defaults();
  352. PBandwidth = 64;
  353. /* Amplitude Global Parameters */
  354. PVolume = 90;
  355. PPanning = 64; //center
  356. PAmpVelocityScaleFunction = 64;
  357. AmpEnvelope->defaults();
  358. AmpLfo->defaults();
  359. Fadein_adjustment = FADEIN_ADJUSTMENT_SCALE;
  360. PPunchStrength = 0;
  361. PPunchTime = 60;
  362. PPunchStretch = 64;
  363. PPunchVelocitySensing = 72;
  364. Hrandgrouping = 0;
  365. /* Filter Global Parameters*/
  366. PFilterVelocityScale = 64;
  367. PFilterVelocityScaleFunction = 64;
  368. GlobalFilter->defaults();
  369. FilterEnvelope->defaults();
  370. FilterLfo->defaults();
  371. Reson->defaults();
  372. }
  373. /*
  374. * Defaults a voice
  375. */
  376. void ADnoteParameters::defaults(int n)
  377. {
  378. VoicePar[n].defaults();
  379. }
  380. void ADnoteVoiceParam::defaults()
  381. {
  382. Enabled = 0;
  383. Unison_size = 1;
  384. Unison_frequency_spread = 60;
  385. Unison_stereo_spread = 64;
  386. Unison_vibratto = 64;
  387. Unison_vibratto_speed = 64;
  388. Unison_invert_phase = 0;
  389. Unison_phase_randomness = 127;
  390. Type = 0;
  391. Pfixedfreq = 0;
  392. PfixedfreqET = 0;
  393. PBendAdjust = 88; // 64 + 24
  394. POffsetHz = 64;
  395. Presonance = 1;
  396. Pfilterbypass = 0;
  397. Pextoscil = -1;
  398. PextFMoscil = -1;
  399. Poscilphase = 64;
  400. PFMoscilphase = 64;
  401. PDelay = 0;
  402. PVolume = 100;
  403. PVolumeminus = 0;
  404. PPanning = 64; //center
  405. PDetune = 8192; //8192=0
  406. PCoarseDetune = 0;
  407. PDetuneType = 0;
  408. PFreqLfoEnabled = 0;
  409. PFreqEnvelopeEnabled = 0;
  410. PAmpEnvelopeEnabled = 0;
  411. PAmpLfoEnabled = 0;
  412. PAmpVelocityScaleFunction = 127;
  413. PFilterEnabled = 0;
  414. PFilterEnvelopeEnabled = 0;
  415. PFilterLfoEnabled = 0;
  416. PFilterVelocityScale = 0;
  417. PFilterVelocityScaleFunction = 64;
  418. PFMEnabled = 0;
  419. PFMFixedFreq = false;
  420. //I use the internal oscillator (-1)
  421. PFMVoice = -1;
  422. PFMVolume = 90;
  423. PFMVolumeDamp = 64;
  424. PFMDetune = 8192;
  425. PFMCoarseDetune = 0;
  426. PFMDetuneType = 0;
  427. PFMFreqEnvelopeEnabled = 0;
  428. PFMAmpEnvelopeEnabled = 0;
  429. PFMVelocityScaleFunction = 64;
  430. OscilSmp->defaults();
  431. FMSmp->defaults();
  432. AmpEnvelope->defaults();
  433. AmpLfo->defaults();
  434. FreqEnvelope->defaults();
  435. FreqLfo->defaults();
  436. VoiceFilter->defaults();
  437. FilterEnvelope->defaults();
  438. FilterLfo->defaults();
  439. FMFreqEnvelope->defaults();
  440. FMAmpEnvelope->defaults();
  441. }
  442. /*
  443. * Init the voice parameters
  444. */
  445. void ADnoteParameters::EnableVoice(const SYNTH_T &synth, int nvoice,
  446. const AbsTime *time)
  447. {
  448. VoicePar[nvoice].enable(synth, fft, GlobalPar.Reson, time);
  449. }
  450. void ADnoteVoiceParam::enable(const SYNTH_T &synth, FFTwrapper *fft,
  451. Resonance *Reson, const AbsTime *time)
  452. {
  453. OscilSmp = new OscilGen(synth, fft, Reson);
  454. FMSmp = new OscilGen(synth, fft, NULL);
  455. AmpEnvelope = new EnvelopeParams(64, 1, time);
  456. AmpEnvelope->ADSRinit_dB(0, 100, 127, 100);
  457. AmpLfo = new LFOParams(90, 32, 64, 0, 0, 30, 0, 1, time);
  458. FreqEnvelope = new EnvelopeParams(0, 0, time);
  459. FreqEnvelope->ASRinit(30, 40, 64, 60);
  460. FreqLfo = new LFOParams(50, 40, 0, 0, 0, 0, 0, 0, time);
  461. VoiceFilter = new FilterParams(2, 50, 60, time);
  462. FilterEnvelope = new EnvelopeParams(0, 0, time);
  463. FilterEnvelope->ADSRinit_filter(90, 70, 40, 70, 10, 40);
  464. FilterLfo = new LFOParams(50, 20, 64, 0, 0, 0, 0, 2, time);
  465. FMFreqEnvelope = new EnvelopeParams(0, 0, time);
  466. FMFreqEnvelope->ASRinit(20, 90, 40, 80);
  467. FMAmpEnvelope = new EnvelopeParams(64, 1, time);
  468. FMAmpEnvelope->ADSRinit(80, 90, 127, 100);
  469. }
  470. /*
  471. * Get the Multiplier of the fine detunes of the voices
  472. */
  473. float ADnoteParameters::getBandwidthDetuneMultiplier() const
  474. {
  475. float bw = (GlobalPar.PBandwidth - 64.0f) / 64.0f;
  476. bw = powf(2.0f, bw * powf(fabs(bw), 0.2f) * 5.0f);
  477. return bw;
  478. }
  479. /*
  480. * Get the unison spread in cents for a voice
  481. */
  482. float ADnoteParameters::getUnisonFrequencySpreadCents(int nvoice) const
  483. {
  484. return VoicePar[nvoice].getUnisonFrequencySpreadCents();
  485. }
  486. float ADnoteVoiceParam::getUnisonFrequencySpreadCents(void) const {
  487. return powf(Unison_frequency_spread / 127.0 * 2.0f, 2.0f) * 50.0f; //cents
  488. }
  489. /*
  490. * Kill the voice
  491. */
  492. void ADnoteParameters::KillVoice(int nvoice)
  493. {
  494. VoicePar[nvoice].kill();
  495. }
  496. void ADnoteVoiceParam::kill()
  497. {
  498. delete OscilSmp;
  499. delete FMSmp;
  500. delete AmpEnvelope;
  501. delete AmpLfo;
  502. delete FreqEnvelope;
  503. delete FreqLfo;
  504. delete VoiceFilter;
  505. delete FilterEnvelope;
  506. delete FilterLfo;
  507. delete FMFreqEnvelope;
  508. delete FMAmpEnvelope;
  509. }
  510. ADnoteGlobalParam::~ADnoteGlobalParam()
  511. {
  512. delete FreqEnvelope;
  513. delete FreqLfo;
  514. delete AmpEnvelope;
  515. delete AmpLfo;
  516. delete GlobalFilter;
  517. delete FilterEnvelope;
  518. delete FilterLfo;
  519. delete Reson;
  520. }
  521. ADnoteParameters::~ADnoteParameters()
  522. {
  523. for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice)
  524. KillVoice(nvoice);
  525. }
  526. void ADnoteParameters::add2XMLsection(XMLwrapper& xml, int n)
  527. {
  528. int nvoice = n;
  529. if(nvoice >= NUM_VOICES)
  530. return;
  531. int oscilused = 0, fmoscilused = 0; //if the oscil or fmoscil are used by another voice
  532. for(int i = 0; i < NUM_VOICES; ++i) {
  533. if(VoicePar[i].Pextoscil == nvoice)
  534. oscilused = 1;
  535. if(VoicePar[i].PextFMoscil == nvoice)
  536. fmoscilused = 1;
  537. }
  538. xml.addparbool("enabled", VoicePar[nvoice].Enabled);
  539. if(((VoicePar[nvoice].Enabled == 0) && (oscilused == 0)
  540. && (fmoscilused == 0)) && (xml.minimal))
  541. return;
  542. VoicePar[nvoice].add2XML(xml, fmoscilused);
  543. }
  544. void ADnoteVoiceParam::add2XML(XMLwrapper& xml, bool fmoscilused)
  545. {
  546. xml.addpar("type", Type);
  547. xml.addpar("unison_size", Unison_size);
  548. xml.addpar("unison_frequency_spread",
  549. Unison_frequency_spread);
  550. xml.addpar("unison_stereo_spread", Unison_stereo_spread);
  551. xml.addpar("unison_vibratto", Unison_vibratto);
  552. xml.addpar("unison_vibratto_speed", Unison_vibratto_speed);
  553. xml.addpar("unison_invert_phase", Unison_invert_phase);
  554. xml.addpar("unison_phase_randomness", Unison_phase_randomness);
  555. xml.addpar("delay", PDelay);
  556. xml.addparbool("resonance", Presonance);
  557. xml.addpar("ext_oscil", Pextoscil);
  558. xml.addpar("ext_fm_oscil", PextFMoscil);
  559. xml.addpar("oscil_phase", Poscilphase);
  560. xml.addpar("oscil_fm_phase", PFMoscilphase);
  561. xml.addparbool("filter_enabled", PFilterEnabled);
  562. xml.addparbool("filter_bypass", Pfilterbypass);
  563. xml.addpar("fm_enabled", PFMEnabled);
  564. xml.beginbranch("OSCIL");
  565. OscilSmp->add2XML(xml);
  566. xml.endbranch();
  567. xml.beginbranch("AMPLITUDE_PARAMETERS");
  568. xml.addpar("panning", PPanning);
  569. xml.addpar("volume", PVolume);
  570. xml.addparbool("volume_minus", PVolumeminus);
  571. xml.addpar("velocity_sensing", PAmpVelocityScaleFunction);
  572. xml.addparbool("amp_envelope_enabled",
  573. PAmpEnvelopeEnabled);
  574. if((PAmpEnvelopeEnabled != 0) || (!xml.minimal)) {
  575. xml.beginbranch("AMPLITUDE_ENVELOPE");
  576. AmpEnvelope->add2XML(xml);
  577. xml.endbranch();
  578. }
  579. xml.addparbool("amp_lfo_enabled", PAmpLfoEnabled);
  580. if((PAmpLfoEnabled != 0) || (!xml.minimal)) {
  581. xml.beginbranch("AMPLITUDE_LFO");
  582. AmpLfo->add2XML(xml);
  583. xml.endbranch();
  584. }
  585. xml.endbranch();
  586. xml.beginbranch("FREQUENCY_PARAMETERS");
  587. xml.addparbool("fixed_freq", Pfixedfreq);
  588. xml.addpar("fixed_freq_et", PfixedfreqET);
  589. xml.addpar("bend_adjust", PBendAdjust);
  590. xml.addpar("offset_hz", POffsetHz);
  591. xml.addpar("detune", PDetune);
  592. xml.addpar("coarse_detune", PCoarseDetune);
  593. xml.addpar("detune_type", PDetuneType);
  594. xml.addparbool("freq_envelope_enabled",
  595. PFreqEnvelopeEnabled);
  596. if((PFreqEnvelopeEnabled != 0) || (!xml.minimal)) {
  597. xml.beginbranch("FREQUENCY_ENVELOPE");
  598. FreqEnvelope->add2XML(xml);
  599. xml.endbranch();
  600. }
  601. xml.addparbool("freq_lfo_enabled", PFreqLfoEnabled);
  602. if((PFreqLfoEnabled != 0) || (!xml.minimal)) {
  603. xml.beginbranch("FREQUENCY_LFO");
  604. FreqLfo->add2XML(xml);
  605. xml.endbranch();
  606. }
  607. xml.endbranch();
  608. if((PFilterEnabled != 0) || (!xml.minimal)) {
  609. xml.beginbranch("FILTER_PARAMETERS");
  610. xml.addpar("velocity_sensing_amplitude", PFilterVelocityScale);
  611. xml.addpar("velocity_sensing", PFilterVelocityScaleFunction);
  612. xml.beginbranch("FILTER");
  613. VoiceFilter->add2XML(xml);
  614. xml.endbranch();
  615. xml.addparbool("filter_envelope_enabled",
  616. PFilterEnvelopeEnabled);
  617. if((PFilterEnvelopeEnabled != 0) || (!xml.minimal)) {
  618. xml.beginbranch("FILTER_ENVELOPE");
  619. FilterEnvelope->add2XML(xml);
  620. xml.endbranch();
  621. }
  622. xml.addparbool("filter_lfo_enabled",
  623. PFilterLfoEnabled);
  624. if((PFilterLfoEnabled != 0) || (!xml.minimal)) {
  625. xml.beginbranch("FILTER_LFO");
  626. FilterLfo->add2XML(xml);
  627. xml.endbranch();
  628. }
  629. xml.endbranch();
  630. }
  631. if((PFMEnabled != 0) || (fmoscilused != 0)
  632. || (!xml.minimal)) {
  633. xml.beginbranch("FM_PARAMETERS");
  634. xml.addpar("input_voice", PFMVoice);
  635. xml.addpar("volume", PFMVolume);
  636. xml.addpar("volume_damp", PFMVolumeDamp);
  637. xml.addpar("velocity_sensing",
  638. PFMVelocityScaleFunction);
  639. xml.addparbool("amp_envelope_enabled",
  640. PFMAmpEnvelopeEnabled);
  641. if((PFMAmpEnvelopeEnabled != 0) || (!xml.minimal)) {
  642. xml.beginbranch("AMPLITUDE_ENVELOPE");
  643. FMAmpEnvelope->add2XML(xml);
  644. xml.endbranch();
  645. }
  646. xml.beginbranch("MODULATOR");
  647. xml.addpar("detune", PFMDetune);
  648. xml.addpar("coarse_detune", PFMCoarseDetune);
  649. xml.addpar("detune_type", PFMDetuneType);
  650. xml.addparbool("freq_envelope_enabled",
  651. PFMFreqEnvelopeEnabled);
  652. xml.addparbool("fixed_freq", PFMFixedFreq);
  653. if((PFMFreqEnvelopeEnabled != 0) || (!xml.minimal)) {
  654. xml.beginbranch("FREQUENCY_ENVELOPE");
  655. FMFreqEnvelope->add2XML(xml);
  656. xml.endbranch();
  657. }
  658. xml.beginbranch("OSCIL");
  659. FMSmp->add2XML(xml);
  660. xml.endbranch();
  661. xml.endbranch();
  662. xml.endbranch();
  663. }
  664. }
  665. void ADnoteGlobalParam::add2XML(XMLwrapper& xml)
  666. {
  667. xml.addparbool("stereo", PStereo);
  668. xml.beginbranch("AMPLITUDE_PARAMETERS");
  669. xml.addpar("volume", PVolume);
  670. xml.addpar("panning", PPanning);
  671. xml.addpar("velocity_sensing", PAmpVelocityScaleFunction);
  672. xml.addpar("fadein_adjustment", Fadein_adjustment);
  673. xml.addpar("punch_strength", PPunchStrength);
  674. xml.addpar("punch_time", PPunchTime);
  675. xml.addpar("punch_stretch", PPunchStretch);
  676. xml.addpar("punch_velocity_sensing", PPunchVelocitySensing);
  677. xml.addpar("harmonic_randomness_grouping", Hrandgrouping);
  678. xml.beginbranch("AMPLITUDE_ENVELOPE");
  679. AmpEnvelope->add2XML(xml);
  680. xml.endbranch();
  681. xml.beginbranch("AMPLITUDE_LFO");
  682. AmpLfo->add2XML(xml);
  683. xml.endbranch();
  684. xml.endbranch();
  685. xml.beginbranch("FREQUENCY_PARAMETERS");
  686. xml.addpar("detune", PDetune);
  687. xml.addpar("coarse_detune", PCoarseDetune);
  688. xml.addpar("detune_type", PDetuneType);
  689. xml.addpar("bandwidth", PBandwidth);
  690. xml.beginbranch("FREQUENCY_ENVELOPE");
  691. FreqEnvelope->add2XML(xml);
  692. xml.endbranch();
  693. xml.beginbranch("FREQUENCY_LFO");
  694. FreqLfo->add2XML(xml);
  695. xml.endbranch();
  696. xml.endbranch();
  697. xml.beginbranch("FILTER_PARAMETERS");
  698. xml.addpar("velocity_sensing_amplitude", PFilterVelocityScale);
  699. xml.addpar("velocity_sensing", PFilterVelocityScaleFunction);
  700. xml.beginbranch("FILTER");
  701. GlobalFilter->add2XML(xml);
  702. xml.endbranch();
  703. xml.beginbranch("FILTER_ENVELOPE");
  704. FilterEnvelope->add2XML(xml);
  705. xml.endbranch();
  706. xml.beginbranch("FILTER_LFO");
  707. FilterLfo->add2XML(xml);
  708. xml.endbranch();
  709. xml.endbranch();
  710. xml.beginbranch("RESONANCE");
  711. Reson->add2XML(xml);
  712. xml.endbranch();
  713. }
  714. void ADnoteParameters::add2XML(XMLwrapper& xml)
  715. {
  716. GlobalPar.add2XML(xml);
  717. for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice) {
  718. xml.beginbranch("VOICE", nvoice);
  719. add2XMLsection(xml, nvoice);
  720. xml.endbranch();
  721. }
  722. }
  723. void ADnoteGlobalParam::getfromXML(XMLwrapper& xml)
  724. {
  725. PStereo = xml.getparbool("stereo", PStereo);
  726. if(xml.enterbranch("AMPLITUDE_PARAMETERS")) {
  727. PVolume = xml.getpar127("volume", PVolume);
  728. PPanning = xml.getpar127("panning", PPanning);
  729. PAmpVelocityScaleFunction = xml.getpar127("velocity_sensing",
  730. PAmpVelocityScaleFunction);
  731. Fadein_adjustment = xml.getpar127("fadein_adjustment", Fadein_adjustment);
  732. PPunchStrength = xml.getpar127("punch_strength", PPunchStrength);
  733. PPunchTime = xml.getpar127("punch_time", PPunchTime);
  734. PPunchStretch = xml.getpar127("punch_stretch", PPunchStretch);
  735. PPunchVelocitySensing = xml.getpar127("punch_velocity_sensing",
  736. PPunchVelocitySensing);
  737. Hrandgrouping = xml.getpar127("harmonic_randomness_grouping",
  738. Hrandgrouping);
  739. if(xml.enterbranch("AMPLITUDE_ENVELOPE")) {
  740. AmpEnvelope->getfromXML(xml);
  741. xml.exitbranch();
  742. }
  743. if(xml.enterbranch("AMPLITUDE_LFO")) {
  744. AmpLfo->getfromXML(xml);
  745. xml.exitbranch();
  746. }
  747. xml.exitbranch();
  748. }
  749. if(xml.enterbranch("FREQUENCY_PARAMETERS")) {
  750. PDetune = xml.getpar("detune", PDetune, 0, 16383);
  751. PCoarseDetune = xml.getpar("coarse_detune", PCoarseDetune, 0, 16383);
  752. PDetuneType = xml.getpar127("detune_type", PDetuneType);
  753. PBandwidth = xml.getpar127("bandwidth", PBandwidth);
  754. xml.enterbranch("FREQUENCY_ENVELOPE");
  755. FreqEnvelope->getfromXML(xml);
  756. xml.exitbranch();
  757. xml.enterbranch("FREQUENCY_LFO");
  758. FreqLfo->getfromXML(xml);
  759. xml.exitbranch();
  760. xml.exitbranch();
  761. }
  762. if(xml.enterbranch("FILTER_PARAMETERS")) {
  763. PFilterVelocityScale = xml.getpar127("velocity_sensing_amplitude",
  764. PFilterVelocityScale);
  765. PFilterVelocityScaleFunction = xml.getpar127(
  766. "velocity_sensing",
  767. PFilterVelocityScaleFunction);
  768. xml.enterbranch("FILTER");
  769. GlobalFilter->getfromXML(xml);
  770. xml.exitbranch();
  771. xml.enterbranch("FILTER_ENVELOPE");
  772. FilterEnvelope->getfromXML(xml);
  773. xml.exitbranch();
  774. xml.enterbranch("FILTER_LFO");
  775. FilterLfo->getfromXML(xml);
  776. xml.exitbranch();
  777. xml.exitbranch();
  778. }
  779. if(xml.enterbranch("RESONANCE")) {
  780. Reson->getfromXML(xml);
  781. xml.exitbranch();
  782. }
  783. }
  784. void ADnoteParameters::getfromXML(XMLwrapper& xml)
  785. {
  786. GlobalPar.getfromXML(xml);
  787. for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice) {
  788. VoicePar[nvoice].Enabled = 0;
  789. if(xml.enterbranch("VOICE", nvoice) == 0)
  790. continue;
  791. getfromXMLsection(xml, nvoice);
  792. xml.exitbranch();
  793. }
  794. }
  795. void ADnoteParameters::getfromXMLsection(XMLwrapper& xml, int n)
  796. {
  797. int nvoice = n;
  798. if(nvoice >= NUM_VOICES)
  799. return;
  800. VoicePar[nvoice].getfromXML(xml, nvoice);
  801. }
  802. void ADnoteParameters::paste(ADnoteParameters &a)
  803. {
  804. this->GlobalPar.paste(a.GlobalPar);
  805. for(int i=0; i<NUM_VOICES; ++i)
  806. this->VoicePar[i].paste(a.VoicePar[i]);
  807. if ( time ) {
  808. last_update_timestamp = time->time();
  809. }
  810. }
  811. void ADnoteParameters::pasteArray(ADnoteParameters &a, int nvoice)
  812. {
  813. if(nvoice >= NUM_VOICES)
  814. return;
  815. VoicePar[nvoice].paste(a.VoicePar[nvoice]);
  816. if ( time ) {
  817. last_update_timestamp = time->time();
  818. }
  819. }
  820. #define copy(x) this->x = a.x
  821. #define RCopy(x) this->x->paste(*a.x)
  822. void ADnoteVoiceParam::paste(ADnoteVoiceParam &a)
  823. {
  824. //Come on C++ get some darn reflection, this is horrible
  825. copy(Enabled);
  826. copy(Unison_size);
  827. copy(Unison_frequency_spread);
  828. copy(Unison_stereo_spread);
  829. copy(Unison_vibratto);
  830. copy(Unison_vibratto_speed);
  831. copy(Unison_invert_phase);
  832. copy(Unison_phase_randomness);
  833. copy(Type);
  834. copy(PDelay);
  835. copy(Presonance);
  836. copy(Pextoscil);
  837. copy(PextFMoscil);
  838. copy(Poscilphase);
  839. copy(PFMoscilphase);
  840. copy(PFilterEnabled);
  841. copy(Pfilterbypass);
  842. copy(PFMEnabled);
  843. copy(PFMFixedFreq);
  844. RCopy(OscilSmp);
  845. copy(PPanning);
  846. copy(PVolume);
  847. copy(PVolumeminus);
  848. copy(PAmpVelocityScaleFunction);
  849. copy(PAmpEnvelopeEnabled);
  850. RCopy(AmpEnvelope);
  851. copy(PAmpLfoEnabled);
  852. RCopy(AmpLfo);
  853. copy(Pfixedfreq);
  854. copy(PfixedfreqET);
  855. copy(PDetune);
  856. copy(PCoarseDetune);
  857. copy(PDetuneType);
  858. copy(PBendAdjust);
  859. copy(POffsetHz);
  860. copy(PFreqEnvelopeEnabled);
  861. RCopy(FreqEnvelope);
  862. copy(PFreqLfoEnabled);
  863. RCopy(FreqLfo);
  864. RCopy(VoiceFilter);
  865. copy(PFilterEnvelopeEnabled);
  866. RCopy(FilterEnvelope);
  867. copy(PFilterLfoEnabled);
  868. copy(PFilterVelocityScale);
  869. copy(PFilterVelocityScaleFunction);
  870. RCopy(FilterLfo);
  871. copy(PFMVoice);
  872. copy(PFMVolume);
  873. copy(PFMVolumeDamp);
  874. copy(PFMVelocityScaleFunction);
  875. copy(PFMAmpEnvelopeEnabled);
  876. RCopy(FMAmpEnvelope);
  877. copy(PFMDetune);
  878. copy(PFMCoarseDetune);
  879. copy(PFMDetuneType);
  880. copy(PFMFreqEnvelopeEnabled);
  881. RCopy(FMFreqEnvelope);
  882. RCopy(FMSmp);
  883. if ( time ) {
  884. last_update_timestamp = time->time();
  885. }
  886. }
  887. void ADnoteGlobalParam::paste(ADnoteGlobalParam &a)
  888. {
  889. copy(PStereo);
  890. copy(PVolume);
  891. copy(PPanning);
  892. copy(PAmpVelocityScaleFunction);
  893. copy(Fadein_adjustment);
  894. copy(PPunchStrength);
  895. copy(PPunchTime);
  896. copy(PPunchStretch);
  897. copy(PPunchVelocitySensing);
  898. copy(Hrandgrouping);
  899. RCopy(AmpEnvelope);
  900. RCopy(AmpLfo);
  901. copy(PDetune);
  902. copy(PCoarseDetune);
  903. copy(PDetuneType);
  904. copy(PBandwidth);
  905. RCopy(FreqEnvelope);
  906. RCopy(FreqLfo);
  907. copy(PFilterVelocityScale);
  908. copy(PFilterVelocityScaleFunction);
  909. RCopy(GlobalFilter);
  910. RCopy(FilterEnvelope);
  911. RCopy(FilterLfo);
  912. RCopy(Reson);
  913. if ( time ) {
  914. last_update_timestamp = time->time();
  915. }
  916. }
  917. #undef copy
  918. #undef RCopy
  919. void ADnoteVoiceParam::getfromXML(XMLwrapper& xml, unsigned nvoice)
  920. {
  921. Enabled = xml.getparbool("enabled", 0);
  922. Unison_size = xml.getpar127("unison_size", Unison_size);
  923. Unison_frequency_spread = xml.getpar127("unison_frequency_spread",
  924. Unison_frequency_spread);
  925. Unison_stereo_spread = xml.getpar127("unison_stereo_spread",
  926. Unison_stereo_spread);
  927. Unison_vibratto = xml.getpar127("unison_vibratto", Unison_vibratto);
  928. Unison_vibratto_speed = xml.getpar127("unison_vibratto_speed",
  929. Unison_vibratto_speed);
  930. Unison_invert_phase = xml.getpar127("unison_invert_phase",
  931. Unison_invert_phase);
  932. Unison_phase_randomness = xml.getpar127("unison_phase_randomness",
  933. Unison_phase_randomness);
  934. Type = xml.getpar127("type", Type);
  935. PDelay = xml.getpar127("delay", PDelay);
  936. Presonance = xml.getparbool("resonance", Presonance);
  937. Pextoscil = xml.getpar("ext_oscil", -1, -1, nvoice - 1);
  938. PextFMoscil = xml.getpar("ext_fm_oscil", -1, -1, nvoice - 1);
  939. Poscilphase = xml.getpar127("oscil_phase", Poscilphase);
  940. PFMoscilphase = xml.getpar127("oscil_fm_phase", PFMoscilphase);
  941. PFilterEnabled = xml.getparbool("filter_enabled", PFilterEnabled);
  942. Pfilterbypass = xml.getparbool("filter_bypass", Pfilterbypass);
  943. PFMEnabled = xml.getpar127("fm_enabled", PFMEnabled);
  944. if(xml.enterbranch("OSCIL")) {
  945. OscilSmp->getfromXML(xml);
  946. xml.exitbranch();
  947. }
  948. if(xml.enterbranch("AMPLITUDE_PARAMETERS")) {
  949. PPanning = xml.getpar127("panning", PPanning);
  950. PVolume = xml.getpar127("volume", PVolume);
  951. PVolumeminus = xml.getparbool("volume_minus", PVolumeminus);
  952. PAmpVelocityScaleFunction = xml.getpar127("velocity_sensing",
  953. PAmpVelocityScaleFunction);
  954. PAmpEnvelopeEnabled = xml.getparbool("amp_envelope_enabled",
  955. PAmpEnvelopeEnabled);
  956. if(xml.enterbranch("AMPLITUDE_ENVELOPE")) {
  957. AmpEnvelope->getfromXML(xml);
  958. xml.exitbranch();
  959. }
  960. PAmpLfoEnabled = xml.getparbool("amp_lfo_enabled", PAmpLfoEnabled);
  961. if(xml.enterbranch("AMPLITUDE_LFO")) {
  962. AmpLfo->getfromXML(xml);
  963. xml.exitbranch();
  964. }
  965. xml.exitbranch();
  966. }
  967. if(xml.enterbranch("FREQUENCY_PARAMETERS")) {
  968. Pfixedfreq = xml.getparbool("fixed_freq", Pfixedfreq);
  969. PfixedfreqET = xml.getpar127("fixed_freq_et", PfixedfreqET);
  970. PBendAdjust = xml.getpar127("bend_adjust", PBendAdjust);
  971. POffsetHz = xml.getpar127("offset_hz", POffsetHz);
  972. PDetune = xml.getpar("detune", PDetune, 0, 16383);
  973. PCoarseDetune = xml.getpar("coarse_detune", PCoarseDetune, 0, 16383);
  974. PDetuneType = xml.getpar127("detune_type", PDetuneType);
  975. PFreqEnvelopeEnabled = xml.getparbool("freq_envelope_enabled",
  976. PFreqEnvelopeEnabled);
  977. if(xml.enterbranch("FREQUENCY_ENVELOPE")) {
  978. FreqEnvelope->getfromXML(xml);
  979. xml.exitbranch();
  980. }
  981. PFreqLfoEnabled = xml.getparbool("freq_lfo_enabled", PFreqLfoEnabled);
  982. if(xml.enterbranch("FREQUENCY_LFO")) {
  983. FreqLfo->getfromXML(xml);
  984. xml.exitbranch();
  985. }
  986. xml.exitbranch();
  987. }
  988. if(xml.enterbranch("FILTER_PARAMETERS")) {
  989. PFilterVelocityScale = xml.getpar127("velocity_sensing_amplitude",
  990. PFilterVelocityScale);
  991. PFilterVelocityScaleFunction = xml.getpar127(
  992. "velocity_sensing",
  993. PFilterVelocityScaleFunction);
  994. if(xml.enterbranch("FILTER")) {
  995. VoiceFilter->getfromXML(xml);
  996. xml.exitbranch();
  997. }
  998. PFilterEnvelopeEnabled = xml.getparbool("filter_envelope_enabled",
  999. PFilterEnvelopeEnabled);
  1000. if(xml.enterbranch("FILTER_ENVELOPE")) {
  1001. FilterEnvelope->getfromXML(xml);
  1002. xml.exitbranch();
  1003. }
  1004. PFilterLfoEnabled = xml.getparbool("filter_lfo_enabled",
  1005. PFilterLfoEnabled);
  1006. if(xml.enterbranch("FILTER_LFO")) {
  1007. FilterLfo->getfromXML(xml);
  1008. xml.exitbranch();
  1009. }
  1010. xml.exitbranch();
  1011. }
  1012. if(xml.enterbranch("FM_PARAMETERS")) {
  1013. PFMVoice = xml.getpar("input_voice", PFMVoice, -1, nvoice - 1);
  1014. PFMVolume = xml.getpar127("volume", PFMVolume);
  1015. PFMVolumeDamp = xml.getpar127("volume_damp", PFMVolumeDamp);
  1016. PFMVelocityScaleFunction = xml.getpar127("velocity_sensing",
  1017. PFMVelocityScaleFunction);
  1018. PFMAmpEnvelopeEnabled = xml.getparbool("amp_envelope_enabled",
  1019. PFMAmpEnvelopeEnabled);
  1020. if(xml.enterbranch("AMPLITUDE_ENVELOPE")) {
  1021. FMAmpEnvelope->getfromXML(xml);
  1022. xml.exitbranch();
  1023. }
  1024. if(xml.enterbranch("MODULATOR")) {
  1025. PFMDetune = xml.getpar("detune", PFMDetune, 0, 16383);
  1026. PFMCoarseDetune = xml.getpar("coarse_detune",
  1027. PFMCoarseDetune,
  1028. 0,
  1029. 16383);
  1030. PFMDetuneType = xml.getpar127("detune_type", PFMDetuneType);
  1031. PFMFreqEnvelopeEnabled = xml.getparbool("freq_envelope_enabled",
  1032. PFMFreqEnvelopeEnabled);
  1033. PFMFixedFreq = xml.getparbool("fixed_freq",
  1034. PFMFixedFreq);
  1035. if(xml.enterbranch("FREQUENCY_ENVELOPE")) {
  1036. FMFreqEnvelope->getfromXML(xml);
  1037. xml.exitbranch();
  1038. }
  1039. if(xml.enterbranch("OSCIL")) {
  1040. FMSmp->getfromXML(xml);
  1041. xml.exitbranch();
  1042. }
  1043. xml.exitbranch();
  1044. }
  1045. xml.exitbranch();
  1046. }
  1047. }