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
39KB

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