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.

SUBnoteParameters.cpp 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. SUBnoteParameters.cpp - Parameters for SUBnote (SUBsynth)
  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 "../globals.h"
  12. #include "SUBnoteParameters.h"
  13. #include "EnvelopeParams.h"
  14. #include "FilterParams.h"
  15. #include "../Misc/Util.h"
  16. #include "../Misc/Time.h"
  17. #include <cstdio>
  18. #include <cmath>
  19. #include <rtosc/ports.h>
  20. #include <rtosc/port-sugar.h>
  21. #define rObject SUBnoteParameters
  22. using namespace rtosc;
  23. #define rBegin [](const char *msg, RtData &d) { \
  24. SUBnoteParameters *obj = (SUBnoteParameters*) d.obj
  25. #define rEnd }
  26. #undef rChangeCb
  27. #define rChangeCb if (obj->time) { obj->last_update_timestamp = obj->time->time(); }
  28. static const rtosc::Ports SUBnotePorts = {
  29. rSelf(SUBnoteParameters),
  30. rPaste,
  31. rToggle(Pstereo, rShort("stereo"), "Stereo Enable"),
  32. rParamZyn(PVolume, rShort("volume"), "Volume"),
  33. rParamZyn(PPanning, rShort("panning"), "Left Right Panning"),
  34. rParamZyn(PAmpVelocityScaleFunction, rShort("sense"), "Amplitude Velocity Sensing function"),
  35. rParamI(PDetune, rShort("detune"), rLinear(0, 16383), "Detune in detune type units"),
  36. rParamI(PCoarseDetune, rShort("cdetune"), "Coarse Detune"),
  37. //Real values needed
  38. rOption(PDetuneType, rShort("det. scl."),
  39. rOptions(L35 cents, L10 cents, E100 cents, E1200 cents), "Detune Scale"),
  40. rToggle(PFreqEnvelopeEnabled, rShort("enable"), "Enable for Frequency Envelope"),
  41. rToggle(PBandWidthEnvelopeEnabled, rShort("enable"), "Enable for Bandwidth Envelope"),
  42. rToggle(PGlobalFilterEnabled, rShort("enable"), "Enable for Global Filter"),
  43. rParamZyn(PGlobalFilterVelocityScale, rShort("scale"), "Filter Velocity Magnitude"),
  44. rParamZyn(PGlobalFilterVelocityScaleFunction, rShort("sense"), "Filter Velocity Function Shape"),
  45. //rRecur(FreqEnvelope, EnvelopeParams),
  46. //rToggle(),//continue
  47. rToggle(Pfixedfreq, rShort("fixed freq"), "Base frequency fixed frequency enable"),
  48. rParamZyn(PfixedfreqET, rShort("fixed ET"), "Equal temeperate control for fixed frequency operation"),
  49. rParamZyn(PBendAdjust, rShort("bend"), "Pitch bend adjustment"),
  50. rParamZyn(POffsetHz, rShort("+ Hz"), "Voice constant offset"),
  51. #undef rChangeCb
  52. #define rChangeCb obj->updateFrequencyMultipliers(); if (obj->time) { \
  53. obj->last_update_timestamp = obj->time->time(); }
  54. rParamI(POvertoneSpread.type, rMap(min, 0), rMap(max, 7), rShort("spread type")
  55. rOptions(Harmonic, ShiftU, ShiftL, PowerU, PowerL, Sine, Power, Shift),
  56. "Spread of harmonic frequencies"),
  57. rParamI(POvertoneSpread.par1, rMap(min, 0), rMap(max, 255), rShort("p1"),
  58. "Overtone Parameter"),
  59. rParamI(POvertoneSpread.par2, rMap(min, 0), rMap(max, 255), rShort("p2"),
  60. "Overtone Parameter"),
  61. rParamI(POvertoneSpread.par3, rMap(min, 0), rMap(max, 255), rShort("forceH"),
  62. "Force Overtones To Harmonics"),
  63. #undef rChangeCb
  64. #define rChangeCb if (obj->time) { obj->last_update_timestamp = obj->time->time(); }
  65. rParamI(Pnumstages, rShort("stages"), rMap(min, 1), rMap(max, 5), "Number of filter stages"),
  66. rParamZyn(Pbandwidth, rShort("bandwidth"), "Bandwidth of filters"),
  67. rParamZyn(Phmagtype, rShort("mag. type"), rOptions(linear, -40dB, -60dB, -80dB, -100dB), "Magnitude scale"),
  68. rArray(Phmag, MAX_SUB_HARMONICS, "Harmonic magnitudes"),
  69. rArray(Phrelbw, MAX_SUB_HARMONICS, "Relative bandwidth"),
  70. rParamZyn(Pbwscale, rShort("stretch"), "Bandwidth scaling with frequency"),
  71. rRecurp(AmpEnvelope, "Amplitude envelope"),
  72. rRecurp(FreqEnvelope, "Frequency Envelope"),
  73. rRecurp(BandWidthEnvelope, "Bandwidth Envelope"),
  74. rRecurp(GlobalFilterEnvelope, "Post Filter Envelope"),
  75. rRecurp(GlobalFilter, "Post Filter"),
  76. rOption(Pstart, rShort("initial"), rOptions(zero, random, ones), "How harmonics are initialized"),
  77. {"clear:", rDoc("Reset all harmonics to equal bandwidth/zero amplitude"), NULL,
  78. rBegin;
  79. for(int i=0; i<MAX_SUB_HARMONICS; ++i) {
  80. obj->Phmag[i] = 0;
  81. obj->Phrelbw[i] = 64;
  82. }
  83. obj->Phmag[0] = 127;
  84. rEnd},
  85. {"detunevalue:", rDoc("Get note detune value"), NULL,
  86. rBegin;
  87. d.reply(d.loc, "f", getdetune(obj->PDetuneType, 0, obj->PDetune));
  88. rEnd},
  89. //weird stuff for PCoarseDetune
  90. {"octave::c:i", rProp(parameter) rShort("octave") rLinear(-8,7)
  91. rDoc("Note octave shift"), NULL,
  92. rBegin;
  93. if(!rtosc_narguments(msg)) {
  94. int k=obj->PCoarseDetune/1024;
  95. if (k>=8) k-=16;
  96. d.reply(d.loc, "i", k);
  97. } else {
  98. int k=(int) rtosc_argument(msg, 0).i;
  99. if (k<0) k+=16;
  100. obj->PCoarseDetune = k*1024 + obj->PCoarseDetune%1024;
  101. }
  102. rEnd},
  103. {"coarsedetune::c:i", rProp(parameter) rShort("coarse") rLinear(-64, 63)
  104. rDoc("Note coarse detune"), NULL,
  105. rBegin;
  106. if(!rtosc_narguments(msg)) {
  107. int k=obj->PCoarseDetune%1024;
  108. if (k>=512) k-=1024;
  109. d.reply(d.loc, "i", k);
  110. } else {
  111. int k=(int) rtosc_argument(msg, 0).i;
  112. if (k<0) k+=1024;
  113. obj->PCoarseDetune = k + (obj->PCoarseDetune/1024)*1024;
  114. }
  115. rEnd},
  116. {"response:", rDoc("Filter response at 440Hz. with 48kHz sample rate\n\n"
  117. "Format: stages, filter*active_filters\n"
  118. " filter = [frequency, bandwidth, amplitude]"),
  119. NULL,
  120. rBegin;
  121. //Identify the active harmonics
  122. int pos[MAX_SUB_HARMONICS];
  123. int harmonics;
  124. obj->activeHarmonics(pos, harmonics);
  125. float base_freq = 440.0f;
  126. char types[3*MAX_SUB_HARMONICS+2];
  127. rtosc_arg_t args[3*MAX_SUB_HARMONICS+1];
  128. args[0].i = obj->Pnumstages;
  129. types[0] = 'i';
  130. for(int n=0; n<harmonics; ++n) {
  131. const float freq = base_freq * obj->POvertoneFreqMult[pos[n]];
  132. //the bandwidth is not absolute(Hz); it is relative to frequency
  133. const float bw = obj->convertBandwidth(obj->Pbandwidth,
  134. obj->Pnumstages, freq, obj->Pbwscale, obj->Phrelbw[pos[n]]);
  135. //try to keep same amplitude on all freqs and bw. (empirically)
  136. const float hgain = obj->convertHarmonicMag(obj->Phmag[pos[n]],
  137. obj->Phmagtype);
  138. const float gain = hgain * sqrt(1500.0f / (bw * freq));
  139. int base = 1+3*n;
  140. args[base + 0].f = freq;
  141. args[base + 1].f = bw;
  142. args[base + 2].f = gain;
  143. types[base + 0] = 'f';
  144. types[base + 1] = 'f';
  145. types[base + 2] = 'f';
  146. }
  147. types[3*harmonics+1] = 0;
  148. d.replyArray(d.loc, types, args);
  149. rEnd},
  150. };
  151. #undef rChangeCb
  152. #undef rBegin
  153. #undef rEnd
  154. const rtosc::Ports &SUBnoteParameters::ports = SUBnotePorts;
  155. SUBnoteParameters::SUBnoteParameters(const AbsTime *time_)
  156. : Presets(), time(time_), last_update_timestamp(0)
  157. {
  158. setpresettype("Psubsynth");
  159. AmpEnvelope = new EnvelopeParams(64, 1, time_);
  160. AmpEnvelope->ADSRinit_dB(0, 40, 127, 25);
  161. FreqEnvelope = new EnvelopeParams(64, 0, time_);
  162. FreqEnvelope->ASRinit(30, 50, 64, 60);
  163. BandWidthEnvelope = new EnvelopeParams(64, 0, time_);
  164. BandWidthEnvelope->ASRinit_bw(100, 70, 64, 60);
  165. GlobalFilter = new FilterParams(2, 80, 40, time_);
  166. GlobalFilterEnvelope = new EnvelopeParams(0, 1, time_);
  167. GlobalFilterEnvelope->ADSRinit_filter(64, 40, 64, 70, 60, 64);
  168. defaults();
  169. }
  170. void SUBnoteParameters::activeHarmonics(int *pos, int &harmonics) const
  171. {
  172. harmonics = 0;
  173. for(int n = 0; n < MAX_SUB_HARMONICS; ++n) {
  174. if(Phmag[n] == 0)
  175. continue;
  176. pos[harmonics++] = n;
  177. }
  178. }
  179. float SUBnoteParameters::convertBandwidth(int bw_, int stages, float freq,
  180. int scale, int relbw)
  181. {
  182. //the bandwidth is not absolute(Hz); it is relative to frequency
  183. float bw = powf(10, (bw_ - 127.0f) / 127.0f * 4) * stages;
  184. //Bandwidth Scale
  185. bw *= powf(1000 / freq, (scale - 64.0f) / 64.0f * 3.0f);
  186. //Relative BandWidth
  187. bw *= powf(100, (relbw - 64.0f) / 64.0f);
  188. if(bw > 25.0f)
  189. bw = 25.0f;
  190. return bw;
  191. }
  192. float SUBnoteParameters::convertHarmonicMag(int mag, int type)
  193. {
  194. const float hmagnew = 1.0f - mag / 127.0f;
  195. switch(type) {
  196. case 1:
  197. return expf(hmagnew * logf(0.01f));
  198. break;
  199. case 2:
  200. return expf(hmagnew * logf(0.001f));
  201. break;
  202. case 3:
  203. return expf(hmagnew * logf(0.0001f));
  204. break;
  205. case 4:
  206. return expf(hmagnew * logf(0.00001f));
  207. break;
  208. default:
  209. return 1.0f - hmagnew;
  210. }
  211. }
  212. void SUBnoteParameters::defaults()
  213. {
  214. PVolume = 96;
  215. PPanning = 64;
  216. PAmpVelocityScaleFunction = 90;
  217. Pfixedfreq = 0;
  218. PfixedfreqET = 0;
  219. PBendAdjust = 88; // 64 + 24
  220. POffsetHz = 64;
  221. Pnumstages = 2;
  222. Pbandwidth = 40;
  223. Phmagtype = 0;
  224. Pbwscale = 64;
  225. Pstereo = 1;
  226. Pstart = 1;
  227. PDetune = 8192;
  228. PCoarseDetune = 0;
  229. PDetuneType = 1;
  230. PFreqEnvelopeEnabled = 0;
  231. PBandWidthEnvelopeEnabled = 0;
  232. POvertoneSpread.type = 0;
  233. POvertoneSpread.par1 = 0;
  234. POvertoneSpread.par2 = 0;
  235. POvertoneSpread.par3 = 0;
  236. updateFrequencyMultipliers();
  237. for(int n = 0; n < MAX_SUB_HARMONICS; ++n) {
  238. Phmag[n] = 0;
  239. Phrelbw[n] = 64;
  240. }
  241. Phmag[0] = 127;
  242. PGlobalFilterEnabled = 0;
  243. PGlobalFilterVelocityScale = 64;
  244. PGlobalFilterVelocityScaleFunction = 64;
  245. AmpEnvelope->defaults();
  246. FreqEnvelope->defaults();
  247. BandWidthEnvelope->defaults();
  248. GlobalFilter->defaults();
  249. GlobalFilterEnvelope->defaults();
  250. }
  251. SUBnoteParameters::~SUBnoteParameters()
  252. {
  253. delete (AmpEnvelope);
  254. delete (FreqEnvelope);
  255. delete (BandWidthEnvelope);
  256. delete (GlobalFilter);
  257. delete (GlobalFilterEnvelope);
  258. }
  259. void SUBnoteParameters::add2XML(XMLwrapper& xml)
  260. {
  261. xml.addpar("num_stages", Pnumstages);
  262. xml.addpar("harmonic_mag_type", Phmagtype);
  263. xml.addpar("start", Pstart);
  264. xml.beginbranch("HARMONICS");
  265. for(int i = 0; i < MAX_SUB_HARMONICS; ++i) {
  266. if((Phmag[i] == 0) && (xml.minimal))
  267. continue;
  268. xml.beginbranch("HARMONIC", i);
  269. xml.addpar("mag", Phmag[i]);
  270. xml.addpar("relbw", Phrelbw[i]);
  271. xml.endbranch();
  272. }
  273. xml.endbranch();
  274. xml.beginbranch("AMPLITUDE_PARAMETERS");
  275. xml.addparbool("stereo", Pstereo);
  276. xml.addpar("volume", PVolume);
  277. xml.addpar("panning", PPanning);
  278. xml.addpar("velocity_sensing", PAmpVelocityScaleFunction);
  279. xml.beginbranch("AMPLITUDE_ENVELOPE");
  280. AmpEnvelope->add2XML(xml);
  281. xml.endbranch();
  282. xml.endbranch();
  283. xml.beginbranch("FREQUENCY_PARAMETERS");
  284. xml.addparbool("fixed_freq", Pfixedfreq);
  285. xml.addpar("fixed_freq_et", PfixedfreqET);
  286. xml.addpar("bend_adjust", PBendAdjust);
  287. xml.addpar("offset_hz", POffsetHz);
  288. xml.addpar("detune", PDetune);
  289. xml.addpar("coarse_detune", PCoarseDetune);
  290. xml.addpar("overtone_spread_type", POvertoneSpread.type);
  291. xml.addpar("overtone_spread_par1", POvertoneSpread.par1);
  292. xml.addpar("overtone_spread_par2", POvertoneSpread.par2);
  293. xml.addpar("overtone_spread_par3", POvertoneSpread.par3);
  294. xml.addpar("detune_type", PDetuneType);
  295. xml.addpar("bandwidth", Pbandwidth);
  296. xml.addpar("bandwidth_scale", Pbwscale);
  297. xml.addparbool("freq_envelope_enabled", PFreqEnvelopeEnabled);
  298. if((PFreqEnvelopeEnabled != 0) || (!xml.minimal)) {
  299. xml.beginbranch("FREQUENCY_ENVELOPE");
  300. FreqEnvelope->add2XML(xml);
  301. xml.endbranch();
  302. }
  303. xml.addparbool("band_width_envelope_enabled", PBandWidthEnvelopeEnabled);
  304. if((PBandWidthEnvelopeEnabled != 0) || (!xml.minimal)) {
  305. xml.beginbranch("BANDWIDTH_ENVELOPE");
  306. BandWidthEnvelope->add2XML(xml);
  307. xml.endbranch();
  308. }
  309. xml.endbranch();
  310. xml.beginbranch("FILTER_PARAMETERS");
  311. xml.addparbool("enabled", PGlobalFilterEnabled);
  312. if((PGlobalFilterEnabled != 0) || (!xml.minimal)) {
  313. xml.beginbranch("FILTER");
  314. GlobalFilter->add2XML(xml);
  315. xml.endbranch();
  316. xml.addpar("filter_velocity_sensing",
  317. PGlobalFilterVelocityScaleFunction);
  318. xml.addpar("filter_velocity_sensing_amplitude",
  319. PGlobalFilterVelocityScale);
  320. xml.beginbranch("FILTER_ENVELOPE");
  321. GlobalFilterEnvelope->add2XML(xml);
  322. xml.endbranch();
  323. }
  324. xml.endbranch();
  325. }
  326. void SUBnoteParameters::updateFrequencyMultipliers(void) {
  327. float par1 = POvertoneSpread.par1 / 255.0f;
  328. float par1pow = powf(10.0f,
  329. -(1.0f - POvertoneSpread.par1 / 255.0f) * 3.0f);
  330. float par2 = POvertoneSpread.par2 / 255.0f;
  331. float par3 = 1.0f - POvertoneSpread.par3 / 255.0f;
  332. float result;
  333. float tmp = 0.0f;
  334. int thresh = 0;
  335. for(int n = 0; n < MAX_SUB_HARMONICS; ++n) {
  336. float n1 = n + 1.0f;
  337. switch(POvertoneSpread.type) {
  338. case 1:
  339. thresh = (int)(100.0f * par2 * par2) + 1;
  340. if (n1 < thresh)
  341. result = n1;
  342. else
  343. result = n1 + 8.0f * (n1 - thresh) * par1pow;
  344. break;
  345. case 2:
  346. thresh = (int)(100.0f * par2 * par2) + 1;
  347. if (n1 < thresh)
  348. result = n1;
  349. else
  350. result = n1 + 0.9f * (thresh - n1) * par1pow;
  351. break;
  352. case 3:
  353. tmp = par1pow * 100.0f + 1.0f;
  354. result = powf(n / tmp, 1.0f - 0.8f * par2) * tmp + 1.0f;
  355. break;
  356. case 4:
  357. result = n * (1.0f - par1pow) +
  358. powf(0.1f * n, 3.0f * par2 + 1.0f) *
  359. 10.0f * par1pow + 1.0f;
  360. break;
  361. case 5:
  362. result = n1 + 2.0f * sinf(n * par2 * par2 * PI * 0.999f) *
  363. sqrt(par1pow);
  364. break;
  365. case 6:
  366. tmp = powf(2.0f * par2, 2.0f) + 0.1f;
  367. result = n * powf(par1 * powf(0.8f * n, tmp) + 1.0f, tmp) +
  368. 1.0f;
  369. break;
  370. case 7:
  371. result = (n1 + par1) / (par1 + 1);
  372. break;
  373. default:
  374. result = n1;
  375. }
  376. float iresult = floor(result + 0.5f);
  377. POvertoneFreqMult[n] = iresult + par3 * (result - iresult);
  378. }
  379. }
  380. #define doPaste(x) this->x = sub.x;
  381. #define doPPaste(x) this->x->paste(*sub.x);
  382. void SUBnoteParameters::paste(SUBnoteParameters &sub)
  383. {
  384. doPaste(Pstereo);
  385. doPaste(PVolume);
  386. doPaste(PPanning);
  387. doPaste(PAmpVelocityScaleFunction);
  388. doPPaste(AmpEnvelope);
  389. //Frequency Parameters
  390. doPaste(PDetune);
  391. doPaste(PCoarseDetune);
  392. doPaste(PDetuneType);
  393. doPaste(PBendAdjust);
  394. doPaste(POffsetHz);
  395. doPaste(PFreqEnvelopeEnabled);
  396. doPPaste(FreqEnvelope);
  397. doPaste(PBandWidthEnvelopeEnabled);
  398. doPPaste(BandWidthEnvelope);
  399. //Filter Parameters (Global)
  400. doPaste(PGlobalFilterEnabled);
  401. doPPaste(GlobalFilter);
  402. doPaste(PGlobalFilterVelocityScale);
  403. doPaste(PGlobalFilterVelocityScaleFunction);
  404. doPPaste(GlobalFilterEnvelope);
  405. //Other Parameters
  406. doPaste(Pfixedfreq);
  407. doPaste(PfixedfreqET);
  408. doPaste(POvertoneSpread.type);
  409. doPaste(POvertoneSpread.par1);
  410. doPaste(POvertoneSpread.par2);
  411. doPaste(POvertoneSpread.par3);
  412. for(int i=0; i<MAX_SUB_HARMONICS; ++i)
  413. doPaste(POvertoneFreqMult[i]);
  414. doPaste(Pnumstages);
  415. doPaste(Pbandwidth);
  416. doPaste(Phmagtype);
  417. for(int i=0; i<MAX_SUB_HARMONICS; ++i) {
  418. doPaste(Phmag[i]);
  419. doPaste(Phrelbw[i]);
  420. }
  421. doPaste(Pbwscale);
  422. doPaste(Pstart);
  423. if ( time ) {
  424. last_update_timestamp = time->time();
  425. }
  426. }
  427. void SUBnoteParameters::getfromXML(XMLwrapper& xml)
  428. {
  429. Pnumstages = xml.getpar127("num_stages", Pnumstages);
  430. Phmagtype = xml.getpar127("harmonic_mag_type", Phmagtype);
  431. Pstart = xml.getpar127("start", Pstart);
  432. if(xml.enterbranch("HARMONICS")) {
  433. Phmag[0] = 0;
  434. for(int i = 0; i < MAX_SUB_HARMONICS; ++i) {
  435. if(xml.enterbranch("HARMONIC", i) == 0)
  436. continue;
  437. Phmag[i] = xml.getpar127("mag", Phmag[i]);
  438. Phrelbw[i] = xml.getpar127("relbw", Phrelbw[i]);
  439. xml.exitbranch();
  440. }
  441. xml.exitbranch();
  442. }
  443. if(xml.enterbranch("AMPLITUDE_PARAMETERS")) {
  444. Pstereo = xml.getparbool("stereo", Pstereo);
  445. PVolume = xml.getpar127("volume", PVolume);
  446. PPanning = xml.getpar127("panning", PPanning);
  447. PAmpVelocityScaleFunction = xml.getpar127("velocity_sensing",
  448. PAmpVelocityScaleFunction);
  449. if(xml.enterbranch("AMPLITUDE_ENVELOPE")) {
  450. AmpEnvelope->getfromXML(xml);
  451. xml.exitbranch();
  452. }
  453. xml.exitbranch();
  454. }
  455. if(xml.enterbranch("FREQUENCY_PARAMETERS")) {
  456. Pfixedfreq = xml.getparbool("fixed_freq", Pfixedfreq);
  457. PfixedfreqET = xml.getpar127("fixed_freq_et", PfixedfreqET);
  458. PBendAdjust = xml.getpar127("bend_adjust", PBendAdjust);
  459. POffsetHz = xml.getpar127("offset_hz", POffsetHz);
  460. PDetune = xml.getpar("detune", PDetune, 0, 16383);
  461. PCoarseDetune = xml.getpar("coarse_detune", PCoarseDetune, 0, 16383);
  462. POvertoneSpread.type =
  463. xml.getpar127("overtone_spread_type", POvertoneSpread.type);
  464. POvertoneSpread.par1 =
  465. xml.getpar("overtone_spread_par1", POvertoneSpread.par1, 0, 255);
  466. POvertoneSpread.par2 =
  467. xml.getpar("overtone_spread_par2", POvertoneSpread.par2, 0, 255);
  468. POvertoneSpread.par3 =
  469. xml.getpar("overtone_spread_par3", POvertoneSpread.par3, 0, 255);
  470. updateFrequencyMultipliers();
  471. PDetuneType = xml.getpar127("detune_type", PDetuneType);
  472. Pbandwidth = xml.getpar127("bandwidth", Pbandwidth);
  473. Pbwscale = xml.getpar127("bandwidth_scale", Pbwscale);
  474. PFreqEnvelopeEnabled = xml.getparbool("freq_envelope_enabled",
  475. PFreqEnvelopeEnabled);
  476. if(xml.enterbranch("FREQUENCY_ENVELOPE")) {
  477. FreqEnvelope->getfromXML(xml);
  478. xml.exitbranch();
  479. }
  480. PBandWidthEnvelopeEnabled = xml.getparbool(
  481. "band_width_envelope_enabled",
  482. PBandWidthEnvelopeEnabled);
  483. if(xml.enterbranch("BANDWIDTH_ENVELOPE")) {
  484. BandWidthEnvelope->getfromXML(xml);
  485. xml.exitbranch();
  486. }
  487. xml.exitbranch();
  488. }
  489. if(xml.enterbranch("FILTER_PARAMETERS")) {
  490. PGlobalFilterEnabled = xml.getparbool("enabled", PGlobalFilterEnabled);
  491. if(xml.enterbranch("FILTER")) {
  492. GlobalFilter->getfromXML(xml);
  493. xml.exitbranch();
  494. }
  495. PGlobalFilterVelocityScaleFunction = xml.getpar127(
  496. "filter_velocity_sensing",
  497. PGlobalFilterVelocityScaleFunction);
  498. PGlobalFilterVelocityScale = xml.getpar127(
  499. "filter_velocity_sensing_amplitude",
  500. PGlobalFilterVelocityScale);
  501. if(xml.enterbranch("FILTER_ENVELOPE")) {
  502. GlobalFilterEnvelope->getfromXML(xml);
  503. xml.exitbranch();
  504. }
  505. xml.exitbranch();
  506. }
  507. }