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.

1235 lines
38KB

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