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.

ADnoteParameters.cpp 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. int ADnote_unison_sizes[] =
  29. {1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 25, 30, 40, 50, 0};
  30. ADnoteParameters::ADnoteParameters(FFTwrapper *fft_)
  31. :PresetsArray()
  32. {
  33. setpresettype("Padsynth");
  34. fft = fft_;
  35. for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice)
  36. EnableVoice(nvoice);
  37. defaults();
  38. }
  39. ADnoteGlobalParam::ADnoteGlobalParam()
  40. {
  41. FreqEnvelope = new EnvelopeParams(0, 0);
  42. FreqEnvelope->ASRinit(64, 50, 64, 60);
  43. FreqLfo = new LFOParams(70, 0, 64, 0, 0, 0, 0, 0);
  44. AmpEnvelope = new EnvelopeParams(64, 1);
  45. AmpEnvelope->ADSRinit_dB(0, 40, 127, 25);
  46. AmpLfo = new LFOParams(80, 0, 64, 0, 0, 0, 0, 1);
  47. GlobalFilter = new FilterParams(2, 94, 40);
  48. FilterEnvelope = new EnvelopeParams(0, 1);
  49. FilterEnvelope->ADSRinit_filter(64, 40, 64, 70, 60, 64);
  50. FilterLfo = new LFOParams(80, 0, 64, 0, 0, 0, 0, 2);
  51. Reson = new Resonance();
  52. }
  53. void ADnoteParameters::defaults()
  54. {
  55. //Default Parameters
  56. GlobalPar.defaults();
  57. for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice)
  58. defaults(nvoice);
  59. VoicePar[0].Enabled = 1;
  60. }
  61. void ADnoteGlobalParam::defaults()
  62. {
  63. /* Frequency Global Parameters */
  64. PStereo = 1; //stereo
  65. PDetune = 8192; //zero
  66. PCoarseDetune = 0;
  67. PDetuneType = 1;
  68. FreqEnvelope->defaults();
  69. FreqLfo->defaults();
  70. PBandwidth = 64;
  71. /* Amplitude Global Parameters */
  72. PVolume = 90;
  73. PPanning = 64; //center
  74. PAmpVelocityScaleFunction = 64;
  75. AmpEnvelope->defaults();
  76. AmpLfo->defaults();
  77. PPunchStrength = 0;
  78. PPunchTime = 60;
  79. PPunchStretch = 64;
  80. PPunchVelocitySensing = 72;
  81. Hrandgrouping = 0;
  82. /* Filter Global Parameters*/
  83. PFilterVelocityScale = 64;
  84. PFilterVelocityScaleFunction = 64;
  85. GlobalFilter->defaults();
  86. FilterEnvelope->defaults();
  87. FilterLfo->defaults();
  88. Reson->defaults();
  89. }
  90. /*
  91. * Defaults a voice
  92. */
  93. void ADnoteParameters::defaults(int n)
  94. {
  95. VoicePar[n].defaults();
  96. }
  97. void ADnoteVoiceParam::defaults()
  98. {
  99. Enabled = 0;
  100. Unison_size = 1;
  101. Unison_frequency_spread = 60;
  102. Unison_stereo_spread = 64;
  103. Unison_vibratto = 64;
  104. Unison_vibratto_speed = 64;
  105. Unison_invert_phase = 0;
  106. Type = 0;
  107. Pfixedfreq = 0;
  108. PfixedfreqET = 0;
  109. Presonance = 1;
  110. Pfilterbypass = 0;
  111. Pextoscil = -1;
  112. PextFMoscil = -1;
  113. Poscilphase = 64;
  114. PFMoscilphase = 64;
  115. PDelay = 0;
  116. PVolume = 100;
  117. PVolumeminus = 0;
  118. PPanning = 64; //center
  119. PDetune = 8192; //8192=0
  120. PCoarseDetune = 0;
  121. PDetuneType = 0;
  122. PFreqLfoEnabled = 0;
  123. PFreqEnvelopeEnabled = 0;
  124. PAmpEnvelopeEnabled = 0;
  125. PAmpLfoEnabled = 0;
  126. PAmpVelocityScaleFunction = 127;
  127. PFilterEnabled = 0;
  128. PFilterEnvelopeEnabled = 0;
  129. PFilterLfoEnabled = 0;
  130. PFMEnabled = 0;
  131. //I use the internal oscillator (-1)
  132. PFMVoice = -1;
  133. PFMVolume = 90;
  134. PFMVolumeDamp = 64;
  135. PFMDetune = 8192;
  136. PFMCoarseDetune = 0;
  137. PFMDetuneType = 0;
  138. PFMFreqEnvelopeEnabled = 0;
  139. PFMAmpEnvelopeEnabled = 0;
  140. PFMVelocityScaleFunction = 64;
  141. OscilSmp->defaults();
  142. FMSmp->defaults();
  143. AmpEnvelope->defaults();
  144. AmpLfo->defaults();
  145. FreqEnvelope->defaults();
  146. FreqLfo->defaults();
  147. VoiceFilter->defaults();
  148. FilterEnvelope->defaults();
  149. FilterLfo->defaults();
  150. FMFreqEnvelope->defaults();
  151. FMAmpEnvelope->defaults();
  152. }
  153. /*
  154. * Init the voice parameters
  155. */
  156. void ADnoteParameters::EnableVoice(int nvoice)
  157. {
  158. VoicePar[nvoice].enable(fft, GlobalPar.Reson);
  159. }
  160. void ADnoteVoiceParam::enable(FFTwrapper *fft, Resonance *Reson)
  161. {
  162. OscilSmp = new OscilGen(fft, Reson);
  163. FMSmp = new OscilGen(fft, NULL);
  164. AmpEnvelope = new EnvelopeParams(64, 1);
  165. AmpEnvelope->ADSRinit_dB(0, 100, 127, 100);
  166. AmpLfo = new LFOParams(90, 32, 64, 0, 0, 30, 0, 1);
  167. FreqEnvelope = new EnvelopeParams(0, 0);
  168. FreqEnvelope->ASRinit(30, 40, 64, 60);
  169. FreqLfo = new LFOParams(50, 40, 0, 0, 0, 0, 0, 0);
  170. VoiceFilter = new FilterParams(2, 50, 60);
  171. FilterEnvelope = new EnvelopeParams(0, 0);
  172. FilterEnvelope->ADSRinit_filter(90, 70, 40, 70, 10, 40);
  173. FilterLfo = new LFOParams(50, 20, 64, 0, 0, 0, 0, 2);
  174. FMFreqEnvelope = new EnvelopeParams(0, 0);
  175. FMFreqEnvelope->ASRinit(20, 90, 40, 80);
  176. FMAmpEnvelope = new EnvelopeParams(64, 1);
  177. FMAmpEnvelope->ADSRinit(80, 90, 127, 100);
  178. }
  179. /*
  180. * Get the Multiplier of the fine detunes of the voices
  181. */
  182. float ADnoteParameters::getBandwidthDetuneMultiplier()
  183. {
  184. float bw = (GlobalPar.PBandwidth - 64.0f) / 64.0f;
  185. bw = powf(2.0f, bw * powf(fabs(bw), 0.2f) * 5.0f);
  186. return bw;
  187. }
  188. /*
  189. * Get the unison spread in cents for a voice
  190. */
  191. float ADnoteParameters::getUnisonFrequencySpreadCents(int nvoice) {
  192. float unison_spread = VoicePar[nvoice].Unison_frequency_spread / 127.0f;
  193. unison_spread = powf(unison_spread * 2.0f, 2.0f) * 50.0f; //cents
  194. return unison_spread;
  195. }
  196. /*
  197. * Kill the voice
  198. */
  199. void ADnoteParameters::KillVoice(int nvoice)
  200. {
  201. VoicePar[nvoice].kill();
  202. }
  203. void ADnoteVoiceParam::kill()
  204. {
  205. delete OscilSmp;
  206. delete FMSmp;
  207. delete AmpEnvelope;
  208. delete AmpLfo;
  209. delete FreqEnvelope;
  210. delete FreqLfo;
  211. delete VoiceFilter;
  212. delete FilterEnvelope;
  213. delete FilterLfo;
  214. delete FMFreqEnvelope;
  215. delete FMAmpEnvelope;
  216. }
  217. ADnoteGlobalParam::~ADnoteGlobalParam()
  218. {
  219. delete FreqEnvelope;
  220. delete FreqLfo;
  221. delete AmpEnvelope;
  222. delete AmpLfo;
  223. delete GlobalFilter;
  224. delete FilterEnvelope;
  225. delete FilterLfo;
  226. delete Reson;
  227. }
  228. ADnoteParameters::~ADnoteParameters()
  229. {
  230. for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice)
  231. KillVoice(nvoice);
  232. }
  233. int ADnoteParameters::get_unison_size_index(int nvoice) {
  234. int index = 0;
  235. if(nvoice >= NUM_VOICES)
  236. return 0;
  237. int unison = VoicePar[nvoice].Unison_size;
  238. while(1) {
  239. if(ADnote_unison_sizes[index] >= unison)
  240. return index;
  241. if(ADnote_unison_sizes[index] == 0)
  242. return index - 1;
  243. index++;
  244. }
  245. return 0;
  246. }
  247. void ADnoteParameters::set_unison_size_index(int nvoice, int index) {
  248. int unison = 1;
  249. for(int i = 0; i <= index; ++i) {
  250. unison = ADnote_unison_sizes[i];
  251. if(unison == 0) {
  252. unison = ADnote_unison_sizes[i - 1];
  253. break;
  254. }
  255. }
  256. VoicePar[nvoice].Unison_size = unison;
  257. }
  258. void ADnoteParameters::add2XMLsection(XMLwrapper *xml, int n)
  259. {
  260. int nvoice = n;
  261. if(nvoice >= NUM_VOICES)
  262. return;
  263. int oscilused = 0, fmoscilused = 0; //if the oscil or fmoscil are used by another voice
  264. for(int i = 0; i < NUM_VOICES; ++i) {
  265. if(VoicePar[i].Pextoscil == nvoice)
  266. oscilused = 1;
  267. if(VoicePar[i].PextFMoscil == nvoice)
  268. fmoscilused = 1;
  269. }
  270. xml->addparbool("enabled", VoicePar[nvoice].Enabled);
  271. if(((VoicePar[nvoice].Enabled == 0) && (oscilused == 0)
  272. && (fmoscilused == 0)) && (xml->minimal))
  273. return;
  274. VoicePar[nvoice].add2XML(xml, fmoscilused);
  275. }
  276. void ADnoteVoiceParam::add2XML(XMLwrapper *xml, bool fmoscilused)
  277. {
  278. xml->addpar("type", Type);
  279. xml->addpar("unison_size", Unison_size);
  280. xml->addpar("unison_frequency_spread",
  281. Unison_frequency_spread);
  282. xml->addpar("unison_stereo_spread", Unison_stereo_spread);
  283. xml->addpar("unison_vibratto", Unison_vibratto);
  284. xml->addpar("unison_vibratto_speed", Unison_vibratto_speed);
  285. xml->addpar("unison_invert_phase", Unison_invert_phase);
  286. xml->addpar("delay", PDelay);
  287. xml->addparbool("resonance", Presonance);
  288. xml->addpar("ext_oscil", Pextoscil);
  289. xml->addpar("ext_fm_oscil", PextFMoscil);
  290. xml->addpar("oscil_phase", Poscilphase);
  291. xml->addpar("oscil_fm_phase", PFMoscilphase);
  292. xml->addparbool("filter_enabled", PFilterEnabled);
  293. xml->addparbool("filter_bypass", Pfilterbypass);
  294. xml->addpar("fm_enabled", PFMEnabled);
  295. xml->beginbranch("OSCIL");
  296. OscilSmp->add2XML(xml);
  297. xml->endbranch();
  298. xml->beginbranch("AMPLITUDE_PARAMETERS");
  299. xml->addpar("panning", PPanning);
  300. xml->addpar("volume", PVolume);
  301. xml->addparbool("volume_minus", PVolumeminus);
  302. xml->addpar("velocity_sensing", PAmpVelocityScaleFunction);
  303. xml->addparbool("amp_envelope_enabled",
  304. PAmpEnvelopeEnabled);
  305. if((PAmpEnvelopeEnabled != 0) || (!xml->minimal)) {
  306. xml->beginbranch("AMPLITUDE_ENVELOPE");
  307. AmpEnvelope->add2XML(xml);
  308. xml->endbranch();
  309. }
  310. xml->addparbool("amp_lfo_enabled", PAmpLfoEnabled);
  311. if((PAmpLfoEnabled != 0) || (!xml->minimal)) {
  312. xml->beginbranch("AMPLITUDE_LFO");
  313. AmpLfo->add2XML(xml);
  314. xml->endbranch();
  315. }
  316. xml->endbranch();
  317. xml->beginbranch("FREQUENCY_PARAMETERS");
  318. xml->addparbool("fixed_freq", Pfixedfreq);
  319. xml->addpar("fixed_freq_et", PfixedfreqET);
  320. xml->addpar("detune", PDetune);
  321. xml->addpar("coarse_detune", PCoarseDetune);
  322. xml->addpar("detune_type", PDetuneType);
  323. xml->addparbool("freq_envelope_enabled",
  324. PFreqEnvelopeEnabled);
  325. if((PFreqEnvelopeEnabled != 0) || (!xml->minimal)) {
  326. xml->beginbranch("FREQUENCY_ENVELOPE");
  327. FreqEnvelope->add2XML(xml);
  328. xml->endbranch();
  329. }
  330. xml->addparbool("freq_lfo_enabled", PFreqLfoEnabled);
  331. if((PFreqLfoEnabled != 0) || (!xml->minimal)) {
  332. xml->beginbranch("FREQUENCY_LFO");
  333. FreqLfo->add2XML(xml);
  334. xml->endbranch();
  335. }
  336. xml->endbranch();
  337. if((PFilterEnabled != 0) || (!xml->minimal)) {
  338. xml->beginbranch("FILTER_PARAMETERS");
  339. xml->beginbranch("FILTER");
  340. VoiceFilter->add2XML(xml);
  341. xml->endbranch();
  342. xml->addparbool("filter_envelope_enabled",
  343. PFilterEnvelopeEnabled);
  344. if((PFilterEnvelopeEnabled != 0) || (!xml->minimal)) {
  345. xml->beginbranch("FILTER_ENVELOPE");
  346. FilterEnvelope->add2XML(xml);
  347. xml->endbranch();
  348. }
  349. xml->addparbool("filter_lfo_enabled",
  350. PFilterLfoEnabled);
  351. if((PFilterLfoEnabled != 0) || (!xml->minimal)) {
  352. xml->beginbranch("FILTER_LFO");
  353. FilterLfo->add2XML(xml);
  354. xml->endbranch();
  355. }
  356. xml->endbranch();
  357. }
  358. if((PFMEnabled != 0) || (fmoscilused != 0)
  359. || (!xml->minimal)) {
  360. xml->beginbranch("FM_PARAMETERS");
  361. xml->addpar("input_voice", PFMVoice);
  362. xml->addpar("volume", PFMVolume);
  363. xml->addpar("volume_damp", PFMVolumeDamp);
  364. xml->addpar("velocity_sensing",
  365. PFMVelocityScaleFunction);
  366. xml->addparbool("amp_envelope_enabled",
  367. PFMAmpEnvelopeEnabled);
  368. if((PFMAmpEnvelopeEnabled != 0) || (!xml->minimal)) {
  369. xml->beginbranch("AMPLITUDE_ENVELOPE");
  370. FMAmpEnvelope->add2XML(xml);
  371. xml->endbranch();
  372. }
  373. xml->beginbranch("MODULATOR");
  374. xml->addpar("detune", PFMDetune);
  375. xml->addpar("coarse_detune", PFMCoarseDetune);
  376. xml->addpar("detune_type", PFMDetuneType);
  377. xml->addparbool("freq_envelope_enabled",
  378. PFMFreqEnvelopeEnabled);
  379. if((PFMFreqEnvelopeEnabled != 0) || (!xml->minimal)) {
  380. xml->beginbranch("FREQUENCY_ENVELOPE");
  381. FMFreqEnvelope->add2XML(xml);
  382. xml->endbranch();
  383. }
  384. xml->beginbranch("OSCIL");
  385. FMSmp->add2XML(xml);
  386. xml->endbranch();
  387. xml->endbranch();
  388. xml->endbranch();
  389. }
  390. }
  391. void ADnoteGlobalParam::add2XML(XMLwrapper *xml)
  392. {
  393. xml->addparbool("stereo", PStereo);
  394. xml->beginbranch("AMPLITUDE_PARAMETERS");
  395. xml->addpar("volume", PVolume);
  396. xml->addpar("panning", PPanning);
  397. xml->addpar("velocity_sensing", PAmpVelocityScaleFunction);
  398. xml->addpar("punch_strength", PPunchStrength);
  399. xml->addpar("punch_time", PPunchTime);
  400. xml->addpar("punch_stretch", PPunchStretch);
  401. xml->addpar("punch_velocity_sensing", PPunchVelocitySensing);
  402. xml->addpar("harmonic_randomness_grouping", Hrandgrouping);
  403. xml->beginbranch("AMPLITUDE_ENVELOPE");
  404. AmpEnvelope->add2XML(xml);
  405. xml->endbranch();
  406. xml->beginbranch("AMPLITUDE_LFO");
  407. AmpLfo->add2XML(xml);
  408. xml->endbranch();
  409. xml->endbranch();
  410. xml->beginbranch("FREQUENCY_PARAMETERS");
  411. xml->addpar("detune", PDetune);
  412. xml->addpar("coarse_detune", PCoarseDetune);
  413. xml->addpar("detune_type", PDetuneType);
  414. xml->addpar("bandwidth", PBandwidth);
  415. xml->beginbranch("FREQUENCY_ENVELOPE");
  416. FreqEnvelope->add2XML(xml);
  417. xml->endbranch();
  418. xml->beginbranch("FREQUENCY_LFO");
  419. FreqLfo->add2XML(xml);
  420. xml->endbranch();
  421. xml->endbranch();
  422. xml->beginbranch("FILTER_PARAMETERS");
  423. xml->addpar("velocity_sensing_amplitude", PFilterVelocityScale);
  424. xml->addpar("velocity_sensing", PFilterVelocityScaleFunction);
  425. xml->beginbranch("FILTER");
  426. GlobalFilter->add2XML(xml);
  427. xml->endbranch();
  428. xml->beginbranch("FILTER_ENVELOPE");
  429. FilterEnvelope->add2XML(xml);
  430. xml->endbranch();
  431. xml->beginbranch("FILTER_LFO");
  432. FilterLfo->add2XML(xml);
  433. xml->endbranch();
  434. xml->endbranch();
  435. xml->beginbranch("RESONANCE");
  436. Reson->add2XML(xml);
  437. xml->endbranch();
  438. }
  439. void ADnoteParameters::add2XML(XMLwrapper *xml)
  440. {
  441. GlobalPar.add2XML(xml);
  442. for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice) {
  443. xml->beginbranch("VOICE", nvoice);
  444. add2XMLsection(xml, nvoice);
  445. xml->endbranch();
  446. }
  447. }
  448. void ADnoteGlobalParam::getfromXML(XMLwrapper *xml)
  449. {
  450. PStereo = xml->getparbool("stereo", PStereo);
  451. if(xml->enterbranch("AMPLITUDE_PARAMETERS")) {
  452. PVolume = xml->getpar127("volume", PVolume);
  453. PPanning = xml->getpar127("panning", PPanning);
  454. PAmpVelocityScaleFunction = xml->getpar127("velocity_sensing",
  455. PAmpVelocityScaleFunction);
  456. PPunchStrength = xml->getpar127("punch_strength", PPunchStrength);
  457. PPunchTime = xml->getpar127("punch_time", PPunchTime);
  458. PPunchStretch = xml->getpar127("punch_stretch", PPunchStretch);
  459. PPunchVelocitySensing = xml->getpar127("punch_velocity_sensing",
  460. PPunchVelocitySensing);
  461. Hrandgrouping = xml->getpar127("harmonic_randomness_grouping",
  462. Hrandgrouping);
  463. if(xml->enterbranch("AMPLITUDE_ENVELOPE")) {
  464. AmpEnvelope->getfromXML(xml);
  465. xml->exitbranch();
  466. }
  467. if(xml->enterbranch("AMPLITUDE_LFO")) {
  468. AmpLfo->getfromXML(xml);
  469. xml->exitbranch();
  470. }
  471. xml->exitbranch();
  472. }
  473. if(xml->enterbranch("FREQUENCY_PARAMETERS")) {
  474. PDetune = xml->getpar("detune", PDetune, 0, 16383);
  475. PCoarseDetune = xml->getpar("coarse_detune", PCoarseDetune, 0, 16383);
  476. PDetuneType = xml->getpar127("detune_type", PDetuneType);
  477. PBandwidth = xml->getpar127("bandwidth", PBandwidth);
  478. xml->enterbranch("FREQUENCY_ENVELOPE");
  479. FreqEnvelope->getfromXML(xml);
  480. xml->exitbranch();
  481. xml->enterbranch("FREQUENCY_LFO");
  482. FreqLfo->getfromXML(xml);
  483. xml->exitbranch();
  484. xml->exitbranch();
  485. }
  486. if(xml->enterbranch("FILTER_PARAMETERS")) {
  487. PFilterVelocityScale = xml->getpar127("velocity_sensing_amplitude",
  488. PFilterVelocityScale);
  489. PFilterVelocityScaleFunction = xml->getpar127(
  490. "velocity_sensing",
  491. PFilterVelocityScaleFunction);
  492. xml->enterbranch("FILTER");
  493. GlobalFilter->getfromXML(xml);
  494. xml->exitbranch();
  495. xml->enterbranch("FILTER_ENVELOPE");
  496. FilterEnvelope->getfromXML(xml);
  497. xml->exitbranch();
  498. xml->enterbranch("FILTER_LFO");
  499. FilterLfo->getfromXML(xml);
  500. xml->exitbranch();
  501. xml->exitbranch();
  502. }
  503. if(xml->enterbranch("RESONANCE")) {
  504. Reson->getfromXML(xml);
  505. xml->exitbranch();
  506. }
  507. }
  508. void ADnoteParameters::getfromXML(XMLwrapper *xml)
  509. {
  510. GlobalPar.getfromXML(xml);
  511. for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice) {
  512. VoicePar[nvoice].Enabled = 0;
  513. if(xml->enterbranch("VOICE", nvoice) == 0)
  514. continue;
  515. getfromXMLsection(xml, nvoice);
  516. xml->exitbranch();
  517. }
  518. }
  519. void ADnoteParameters::getfromXMLsection(XMLwrapper *xml, int n)
  520. {
  521. int nvoice = n;
  522. if(nvoice >= NUM_VOICES)
  523. return;
  524. VoicePar[nvoice].getfromXML(xml, nvoice);
  525. }
  526. void ADnoteVoiceParam::getfromXML(XMLwrapper *xml, unsigned nvoice)
  527. {
  528. Enabled = xml->getparbool("enabled", 0);
  529. Unison_size = xml->getpar127("unison_size", Unison_size);
  530. Unison_frequency_spread = xml->getpar127("unison_frequency_spread",
  531. Unison_frequency_spread);
  532. Unison_stereo_spread = xml->getpar127("unison_stereo_spread",
  533. Unison_stereo_spread);
  534. Unison_vibratto = xml->getpar127("unison_vibratto", Unison_vibratto);
  535. Unison_vibratto_speed = xml->getpar127("unison_vibratto_speed",
  536. Unison_vibratto_speed);
  537. Unison_invert_phase = xml->getpar127("unison_invert_phase",
  538. Unison_invert_phase);
  539. Type = xml->getpar127("type", Type);
  540. PDelay = xml->getpar127("delay", PDelay);
  541. Presonance = xml->getparbool("resonance", Presonance);
  542. Pextoscil = xml->getpar("ext_oscil", -1, -1, nvoice - 1);
  543. PextFMoscil = xml->getpar("ext_fm_oscil", -1, -1, nvoice - 1);
  544. Poscilphase = xml->getpar127("oscil_phase", Poscilphase);
  545. PFMoscilphase = xml->getpar127("oscil_fm_phase", PFMoscilphase);
  546. PFilterEnabled = xml->getparbool("filter_enabled", PFilterEnabled);
  547. Pfilterbypass = xml->getparbool("filter_bypass", Pfilterbypass);
  548. PFMEnabled = xml->getpar127("fm_enabled", PFMEnabled);
  549. if(xml->enterbranch("OSCIL")) {
  550. OscilSmp->getfromXML(xml);
  551. xml->exitbranch();
  552. }
  553. if(xml->enterbranch("AMPLITUDE_PARAMETERS")) {
  554. PPanning = xml->getpar127("panning", PPanning);
  555. PVolume = xml->getpar127("volume", PVolume);
  556. PVolumeminus = xml->getparbool("volume_minus", PVolumeminus);
  557. PAmpVelocityScaleFunction = xml->getpar127("velocity_sensing",
  558. PAmpVelocityScaleFunction);
  559. PAmpEnvelopeEnabled = xml->getparbool("amp_envelope_enabled",
  560. PAmpEnvelopeEnabled);
  561. if(xml->enterbranch("AMPLITUDE_ENVELOPE")) {
  562. AmpEnvelope->getfromXML(xml);
  563. xml->exitbranch();
  564. }
  565. PAmpLfoEnabled = xml->getparbool("amp_lfo_enabled", PAmpLfoEnabled);
  566. if(xml->enterbranch("AMPLITUDE_LFO")) {
  567. AmpLfo->getfromXML(xml);
  568. xml->exitbranch();
  569. }
  570. xml->exitbranch();
  571. }
  572. if(xml->enterbranch("FREQUENCY_PARAMETERS")) {
  573. Pfixedfreq = xml->getparbool("fixed_freq", Pfixedfreq);
  574. PfixedfreqET = xml->getpar127("fixed_freq_et", PfixedfreqET);
  575. PDetune = xml->getpar("detune", PDetune, 0, 16383);
  576. PCoarseDetune = xml->getpar("coarse_detune", PCoarseDetune, 0, 16383);
  577. PDetuneType = xml->getpar127("detune_type", PDetuneType);
  578. PFreqEnvelopeEnabled = xml->getparbool("freq_envelope_enabled",
  579. PFreqEnvelopeEnabled);
  580. if(xml->enterbranch("FREQUENCY_ENVELOPE")) {
  581. FreqEnvelope->getfromXML(xml);
  582. xml->exitbranch();
  583. }
  584. PFreqLfoEnabled = xml->getparbool("freq_lfo_enabled", PFreqLfoEnabled);
  585. if(xml->enterbranch("FREQUENCY_LFO")) {
  586. FreqLfo->getfromXML(xml);
  587. xml->exitbranch();
  588. }
  589. xml->exitbranch();
  590. }
  591. if(xml->enterbranch("FILTER_PARAMETERS")) {
  592. if(xml->enterbranch("FILTER")) {
  593. VoiceFilter->getfromXML(xml);
  594. xml->exitbranch();
  595. }
  596. PFilterEnvelopeEnabled = xml->getparbool("filter_envelope_enabled",
  597. PFilterEnvelopeEnabled);
  598. if(xml->enterbranch("FILTER_ENVELOPE")) {
  599. FilterEnvelope->getfromXML(xml);
  600. xml->exitbranch();
  601. }
  602. PFilterLfoEnabled = xml->getparbool("filter_lfo_enabled",
  603. PFilterLfoEnabled);
  604. if(xml->enterbranch("FILTER_LFO")) {
  605. FilterLfo->getfromXML(xml);
  606. xml->exitbranch();
  607. }
  608. xml->exitbranch();
  609. }
  610. if(xml->enterbranch("FM_PARAMETERS")) {
  611. PFMVoice = xml->getpar("input_voice", PFMVoice, -1, nvoice - 1);
  612. PFMVolume = xml->getpar127("volume", PFMVolume);
  613. PFMVolumeDamp = xml->getpar127("volume_damp", PFMVolumeDamp);
  614. PFMVelocityScaleFunction = xml->getpar127("velocity_sensing",
  615. PFMVelocityScaleFunction);
  616. PFMAmpEnvelopeEnabled = xml->getparbool("amp_envelope_enabled",
  617. PFMAmpEnvelopeEnabled);
  618. if(xml->enterbranch("AMPLITUDE_ENVELOPE")) {
  619. FMAmpEnvelope->getfromXML(xml);
  620. xml->exitbranch();
  621. }
  622. if(xml->enterbranch("MODULATOR")) {
  623. PFMDetune = xml->getpar("detune", PFMDetune, 0, 16383);
  624. PFMCoarseDetune = xml->getpar("coarse_detune",
  625. PFMCoarseDetune,
  626. 0,
  627. 16383);
  628. PFMDetuneType = xml->getpar127("detune_type", PFMDetuneType);
  629. PFMFreqEnvelopeEnabled = xml->getparbool("freq_envelope_enabled",
  630. PFMFreqEnvelopeEnabled);
  631. if(xml->enterbranch("FREQUENCY_ENVELOPE")) {
  632. FMFreqEnvelope->getfromXML(xml);
  633. xml->exitbranch();
  634. }
  635. if(xml->enterbranch("OSCIL")) {
  636. FMSmp->getfromXML(xml);
  637. xml->exitbranch();
  638. }
  639. xml->exitbranch();
  640. }
  641. xml->exitbranch();
  642. }
  643. }