SUBnoteParameters.cpp (22649B)
1 /* 2 ZynAddSubFX - a software synthesizer 3 4 SUBnoteParameters.cpp - Parameters for SUBnote (SUBsynth) 5 Copyright (C) 2002-2005 Nasca Octavian Paul 6 Author: Nasca Octavian Paul 7 8 This program is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public License 10 as published by the Free Software Foundation; either version 2 11 of the License, or (at your option) any later version. 12 */ 13 14 #include "../globals.h" 15 #include "SUBnoteParameters.h" 16 #include "EnvelopeParams.h" 17 #include "FilterParams.h" 18 #include "../Misc/Util.h" 19 #include "../Misc/Time.h" 20 #include <cstdio> 21 #include <cmath> 22 23 #include <rtosc/ports.h> 24 #include <rtosc/port-sugar.h> 25 using namespace rtosc; 26 27 namespace zyn { 28 29 #define rObject SUBnoteParameters 30 #define rBegin [](const char *msg, RtData &d) { \ 31 SUBnoteParameters *obj = (SUBnoteParameters*) d.obj 32 #define rEnd } 33 34 35 #undef rChangeCb 36 #define rChangeCb if (obj->time) { obj->last_update_timestamp = obj->time->time(); } 37 static const rtosc::Ports SUBnotePorts = { 38 rSelf(SUBnoteParameters), 39 rPasteRt, 40 rToggle(Pstereo, rShort("stereo"), rDefault(true), "Stereo Enable"), 41 rParamF(Volume, rShort("volume"), rDefault(0.f), rUnit(dB), rLinear(-60.0f,20.0f), "Volume"), 42 rParamZyn(PPanning, rShort("panning"), rDefault(64), "Left Right Panning"), 43 rParamF(AmpVelocityScaleFunction, rShort("sense"), rDefault(70.86), 44 rLinear(0.0, 100.0), "Amplitude Velocity Sensing function"), 45 {"PAmpVelocityScaleFunction::i", rShort("sense") rProp(parameter) rLinear(0,127) 46 rDefault(90) rDoc("Amplitude Velocity Sensing function"), 0, 47 [](const char *m, rtosc::RtData &d) { 48 SUBnoteParameters *obj = (SUBnoteParameters*)d.obj; 49 if (rtosc_narguments(m)==0) { 50 d.reply(d.loc, "i", (int) roundf(obj->AmpVelocityScaleFunction * 127.0f / 100.0f)); 51 } else if(rtosc_narguments(m)==1 && rtosc_type(m,0)=='i') { 52 const uint8_t value = limit<char>(rtosc_argument(m, 0).i, 0, 127); 53 obj->AmpVelocityScaleFunction = value * 100.0f / 127.0f; 54 d.broadcast(d.loc, "i", value); 55 rChangeCb 56 } 57 }}, 58 rParamI(PDetune, rShort("detune"), rLinear(0, 16383), rDefault(8192), 59 "Detune in detune type units"), 60 rParamI(PCoarseDetune, rShort("cdetune"), rDefault(0), "Coarse Detune"), 61 //Real values needed 62 rOption(PDetuneType, rShort("det. scl."), 63 rOptions(L35 cents, L10 cents, E100 cents, E1200 cents), 64 rDefaultId(L10 cents), "Detune Scale"), 65 rToggle(PFreqEnvelopeEnabled, rShort("enable"), rDefault(false), 66 "Enable for Frequency Envelope"), 67 rToggle(PBandWidthEnvelopeEnabled, rShort("enable"), rDefault(false), 68 "Enable for Bandwidth Envelope"), 69 rToggle(PGlobalFilterEnabled, rShort("enable"), 70 rDefault(false), "Enable for Global Filter"), 71 rParamZyn(PGlobalFilterVelocityScale, rShort("scale"), rDefault(0), 72 "Filter Velocity Magnitude"), 73 rParamZyn(PGlobalFilterVelocityScaleFunction, rShort("sense"), rDefault(64), 74 "Filter Velocity Function Shape"), 75 //rRecur(FreqEnvelope, EnvelopeParams), 76 //rToggle(),//continue 77 rToggle(Pfixedfreq, rShort("fixed freq"), rDefault(false), 78 "Base frequency fixed frequency enable"), 79 rParamZyn(PfixedfreqET, rShort("fixed ET"), rDefault(0), 80 "Equal temeperate control for fixed frequency operation"), 81 rParamZyn(PBendAdjust, rShort("bend"), rDefault(88), 82 "Pitch bend adjustment"), 83 rParamZyn(POffsetHz, rShort("+ Hz"), rDefault(64), 84 "Voice constant offset"), 85 #undef rChangeCb 86 #define rChangeCb obj->updateFrequencyMultipliers(); if (obj->time) { \ 87 obj->last_update_timestamp = obj->time->time(); } 88 rOption(POvertoneSpread.type, rMap(min, 0), rMap(max, 7), rShort("spread type"), 89 rOptions(Harmonic, ShiftU, ShiftL, PowerU, PowerL, Sine, Power, Shift), 90 rDefault(Harmonic), 91 "Spread of harmonic frequencies"), 92 rParamI(POvertoneSpread.par1, rMap(min, 0), rMap(max, 255), rShort("p1"), 93 rDefault(0), "Overtone Parameter"), 94 rParamI(POvertoneSpread.par2, rMap(min, 0), rMap(max, 255), rShort("p2"), 95 rDefault(0), "Overtone Parameter"), 96 rParamI(POvertoneSpread.par3, rMap(min, 0), rMap(max, 255), rShort("forceH"), 97 rDefault(0), "Force Overtones To Harmonics"), 98 #undef rChangeCb 99 #define rChangeCb if (obj->time) { obj->last_update_timestamp = obj->time->time(); } 100 rParamI(Pnumstages, rShort("stages"), rMap(min, 1), rMap(max, 5), 101 rDefault(2), "Number of filter stages"), 102 rParamZyn(Pbandwidth, rShort("bandwidth"), rDefault(40), 103 "Bandwidth of filters"), 104 rOption(Phmagtype, rShort("mag. type"), 105 rOptions(linear, -40dB, -60dB, -80dB, -100dB), 106 rDefault(linear), "Magnitude scale"), 107 rArray(Phmag, MAX_SUB_HARMONICS, rDefault([127 0 0 ...]), 108 "Harmonic magnitudes"), 109 rArray(Phrelbw, MAX_SUB_HARMONICS, rDefault([64 ...]), 110 "Relative bandwidth"), 111 rParamZyn(Pbwscale, rShort("stretch"), rDefault(64), 112 "Bandwidth scaling with frequency"), 113 rRecurp(AmpEnvelope, "Amplitude envelope"), 114 rRecurp(FreqEnvelope, "Frequency Envelope"), 115 rRecurp(BandWidthEnvelope, "Bandwidth Envelope"), 116 rRecurp(GlobalFilterEnvelope, "Post Filter Envelope"), 117 rRecurp(GlobalFilter, "Post Filter"), 118 rOption(Pstart, rShort("initial"), rOptions(zero, random, ones), 119 rDefault(random), 120 "How harmonics are initialized"), 121 {"PVolume::i", rShort("volume") rLinear(0,127) 122 rDoc("Volume"), NULL, 123 [](const char *msg, RtData &d) 124 { 125 rObject *obj = (rObject *)d.obj; 126 if (!rtosc_narguments(msg)) 127 d.reply(d.loc, "i", (int)roundf(96.0f * (1.0f + obj->Volume/60.0f))); 128 else 129 obj->Volume = -60.0f * (1.0f - rtosc_argument(msg, 0).i / 96.0f); 130 }}, 131 {"clear:", rDoc("Reset all harmonics to equal bandwidth/zero amplitude"), NULL, 132 rBegin; 133 (void) msg; 134 for(int i=0; i<MAX_SUB_HARMONICS; ++i) { 135 obj->Phmag[i] = 0; 136 obj->Phrelbw[i] = 64; 137 } 138 obj->Phmag[0] = 127; 139 rEnd}, 140 {"detunevalue:", rDoc("Get note detune value"), NULL, 141 rBegin; 142 (void) msg; 143 d.reply(d.loc, "f", getdetune(obj->PDetuneType, 0, obj->PDetune)); 144 rEnd}, 145 //weird stuff for PCoarseDetune 146 {"octave::c:i", rProp(parameter) rShort("octave") rLinear(-8,7) 147 rDoc("Note octave shift"), NULL, 148 rBegin; 149 auto get_octave = [&obj](){ 150 int k=obj->PCoarseDetune/1024; 151 if (k>=8) k-=16; 152 return k; 153 }; 154 if(!rtosc_narguments(msg)) { 155 d.reply(d.loc, "i", get_octave()); 156 } else { 157 int k=(int) rtosc_argument(msg, 0).i; 158 if (k<0) k+=16; 159 obj->PCoarseDetune = k*1024 + obj->PCoarseDetune%1024; 160 d.broadcast(d.loc, "i", get_octave()); 161 } 162 rEnd}, 163 {"coarsedetune::c:i", rProp(parameter) rShort("coarse") rLinear(-64, 63) 164 rDoc("Note coarse detune"), NULL, 165 rBegin; 166 auto get_coarse = [&obj](){ 167 int k=obj->PCoarseDetune%1024; 168 if (k>=512) k-=1024; 169 return k; 170 }; 171 if(!rtosc_narguments(msg)) { 172 d.reply(d.loc, "i", get_coarse()); 173 } else { 174 int k=(int) rtosc_argument(msg, 0).i; 175 if (k<0) k+=1024; 176 obj->PCoarseDetune = k + (obj->PCoarseDetune/1024)*1024; 177 d.broadcast(d.loc, "i", get_coarse()); 178 } 179 rEnd}, 180 {"response:", rDoc("Filter response at 440Hz. with 48kHz sample rate\n\n" 181 "Format: stages, filter*active_filters\n" 182 " filter = [frequency, bandwidth, amplitude]"), 183 NULL, 184 rBegin; 185 (void) msg; 186 187 //Identify the active harmonics 188 int pos[MAX_SUB_HARMONICS]; 189 int harmonics; 190 obj->activeHarmonics(pos, harmonics); 191 192 float base_freq = 440.0f; 193 194 char types[3*MAX_SUB_HARMONICS+2]; 195 rtosc_arg_t args[3*MAX_SUB_HARMONICS+1]; 196 197 args[0].i = obj->Pnumstages; 198 types[0] = 'i'; 199 200 for(int n=0; n<harmonics; ++n) { 201 const float freq = base_freq * obj->POvertoneFreqMult[pos[n]]; 202 //the bandwidth is not absolute(Hz); it is relative to frequency 203 const float bw = obj->convertBandwidth(obj->Pbandwidth, 204 obj->Pnumstages, freq, obj->Pbwscale, obj->Phrelbw[pos[n]]); 205 206 //try to keep same amplitude on all freqs and bw. (empirically) 207 const float hgain = obj->convertHarmonicMag(obj->Phmag[pos[n]], 208 obj->Phmagtype); 209 const float gain = hgain * sqrt(1500.0f / (bw * freq)); 210 211 int base = 1+3*n; 212 args[base + 0].f = freq; 213 args[base + 1].f = bw; 214 args[base + 2].f = gain; 215 types[base + 0] = 'f'; 216 types[base + 1] = 'f'; 217 types[base + 2] = 'f'; 218 } 219 220 types[3*harmonics+1] = 0; 221 d.replyArray(d.loc, types, args); 222 rEnd}, 223 224 225 }; 226 #undef rChangeCb 227 #undef rBegin 228 #undef rEnd 229 230 const rtosc::Ports &SUBnoteParameters::ports = SUBnotePorts; 231 232 SUBnoteParameters::SUBnoteParameters(const AbsTime *time_) 233 : Presets(), time(time_), last_update_timestamp(0) 234 { 235 setpresettype("Psubsynth"); 236 AmpEnvelope = new EnvelopeParams(64, 1, time_); 237 AmpEnvelope->init(ad_global_amp); 238 FreqEnvelope = new EnvelopeParams(64, 0, time_); 239 FreqEnvelope->init(sub_freq); 240 BandWidthEnvelope = new EnvelopeParams(64, 0, time_); 241 BandWidthEnvelope->init(sub_bandwidth); 242 243 GlobalFilter = new FilterParams(sub_filter, time_); 244 GlobalFilterEnvelope = new EnvelopeParams(0, 1, time_); 245 GlobalFilterEnvelope->init(sub_filter); 246 247 defaults(); 248 } 249 250 void SUBnoteParameters::activeHarmonics(int *pos, int &harmonics) const 251 { 252 harmonics = 0; 253 for(int n = 0; n < MAX_SUB_HARMONICS; ++n) { 254 if(Phmag[n] == 0) 255 continue; 256 pos[harmonics++] = n; 257 } 258 } 259 260 float SUBnoteParameters::convertBandwidth(int bw_, int stages, float freq, 261 int scale, int relbw) 262 { 263 //the bandwidth is not absolute(Hz); it is relative to frequency 264 float bw = powf(10, (bw_ - 127.0f) / 127.0f * 4) * stages; 265 266 //Bandwidth Scale 267 bw *= powf(1000 / freq, (scale - 64.0f) / 64.0f * 3.0f); 268 269 //Relative BandWidth 270 bw *= powf(100, (relbw - 64.0f) / 64.0f); 271 272 if(bw > 25.0f) 273 bw = 25.0f; 274 275 return bw; 276 } 277 278 float SUBnoteParameters::convertHarmonicMag(int mag, int type) 279 { 280 const float hmagnew = 1.0f - mag / 127.0f; 281 282 switch(type) { 283 case 1: 284 return expf(hmagnew * logf(0.01f)); 285 break; 286 case 2: 287 return expf(hmagnew * logf(0.001f)); 288 break; 289 case 3: 290 return expf(hmagnew * logf(0.0001f)); 291 break; 292 case 4: 293 return expf(hmagnew * logf(0.00001f)); 294 break; 295 default: 296 return 1.0f - hmagnew; 297 } 298 } 299 300 301 void SUBnoteParameters::defaults() 302 { 303 Volume = 0; 304 PPanning = 64; 305 AmpVelocityScaleFunction = 70.86; 306 307 Pfixedfreq = 0; 308 PfixedfreqET = 0; 309 PBendAdjust = 88; // 64 + 24 310 POffsetHz = 64; 311 Pnumstages = 2; 312 Pbandwidth = 40; 313 Phmagtype = 0; 314 Pbwscale = 64; 315 Pstereo = 1; 316 Pstart = 1; 317 318 PDetune = 8192; 319 PCoarseDetune = 0; 320 PDetuneType = 1; 321 PFreqEnvelopeEnabled = 0; 322 PBandWidthEnvelopeEnabled = 0; 323 324 POvertoneSpread.type = 0; 325 POvertoneSpread.par1 = 0; 326 POvertoneSpread.par2 = 0; 327 POvertoneSpread.par3 = 0; 328 updateFrequencyMultipliers(); 329 330 for(int n = 0; n < MAX_SUB_HARMONICS; ++n) { 331 Phmag[n] = 0; 332 Phrelbw[n] = 64; 333 } 334 Phmag[0] = 127; 335 336 PGlobalFilterEnabled = 0; 337 PGlobalFilterVelocityScale = 0; 338 PGlobalFilterVelocityScaleFunction = 64; 339 340 AmpEnvelope->defaults(); 341 FreqEnvelope->defaults(); 342 BandWidthEnvelope->defaults(); 343 GlobalFilter->defaults(); 344 GlobalFilterEnvelope->defaults(); 345 } 346 347 348 349 SUBnoteParameters::~SUBnoteParameters() 350 { 351 delete (AmpEnvelope); 352 delete (FreqEnvelope); 353 delete (BandWidthEnvelope); 354 delete (GlobalFilter); 355 delete (GlobalFilterEnvelope); 356 } 357 358 359 360 361 void SUBnoteParameters::add2XML(XMLwrapper& xml) 362 { 363 xml.addpar("num_stages", Pnumstages); 364 xml.addpar("harmonic_mag_type", Phmagtype); 365 xml.addpar("start", Pstart); 366 367 xml.beginbranch("HARMONICS"); 368 for(int i = 0; i < MAX_SUB_HARMONICS; ++i) { 369 if((Phmag[i] == 0) && (xml.minimal)) 370 continue; 371 xml.beginbranch("HARMONIC", i); 372 xml.addpar("mag", Phmag[i]); 373 xml.addpar("relbw", Phrelbw[i]); 374 xml.endbranch(); 375 } 376 xml.endbranch(); 377 378 xml.beginbranch("AMPLITUDE_PARAMETERS"); 379 xml.addparbool("stereo", Pstereo); 380 xml.addparreal("volume", Volume); 381 xml.addpar("panning", PPanning); 382 xml.addparreal("velocity_sensing", AmpVelocityScaleFunction); 383 xml.beginbranch("AMPLITUDE_ENVELOPE"); 384 AmpEnvelope->add2XML(xml); 385 xml.endbranch(); 386 xml.endbranch(); 387 388 xml.beginbranch("FREQUENCY_PARAMETERS"); 389 xml.addparbool("fixed_freq", Pfixedfreq); 390 xml.addpar("fixed_freq_et", PfixedfreqET); 391 xml.addpar("bend_adjust", PBendAdjust); 392 xml.addpar("offset_hz", POffsetHz); 393 394 xml.addpar("detune", PDetune); 395 xml.addpar("coarse_detune", PCoarseDetune); 396 xml.addpar("overtone_spread_type", POvertoneSpread.type); 397 xml.addpar("overtone_spread_par1", POvertoneSpread.par1); 398 xml.addpar("overtone_spread_par2", POvertoneSpread.par2); 399 xml.addpar("overtone_spread_par3", POvertoneSpread.par3); 400 xml.addpar("detune_type", PDetuneType); 401 402 xml.addpar("bandwidth", Pbandwidth); 403 xml.addpar("bandwidth_scale", Pbwscale); 404 405 xml.addparbool("freq_envelope_enabled", PFreqEnvelopeEnabled); 406 if((PFreqEnvelopeEnabled != 0) || (!xml.minimal)) { 407 xml.beginbranch("FREQUENCY_ENVELOPE"); 408 FreqEnvelope->add2XML(xml); 409 xml.endbranch(); 410 } 411 412 xml.addparbool("band_width_envelope_enabled", PBandWidthEnvelopeEnabled); 413 if((PBandWidthEnvelopeEnabled != 0) || (!xml.minimal)) { 414 xml.beginbranch("BANDWIDTH_ENVELOPE"); 415 BandWidthEnvelope->add2XML(xml); 416 xml.endbranch(); 417 } 418 xml.endbranch(); 419 420 xml.beginbranch("FILTER_PARAMETERS"); 421 xml.addparbool("enabled", PGlobalFilterEnabled); 422 if((PGlobalFilterEnabled != 0) || (!xml.minimal)) { 423 xml.beginbranch("FILTER"); 424 GlobalFilter->add2XML(xml); 425 xml.endbranch(); 426 427 xml.addpar("filter_velocity_sensing", 428 PGlobalFilterVelocityScaleFunction); 429 xml.addpar("filter_velocity_sensing_amplitude", 430 PGlobalFilterVelocityScale); 431 432 xml.beginbranch("FILTER_ENVELOPE"); 433 GlobalFilterEnvelope->add2XML(xml); 434 xml.endbranch(); 435 } 436 xml.endbranch(); 437 } 438 439 440 441 void SUBnoteParameters::updateFrequencyMultipliers(void) { 442 float par1 = POvertoneSpread.par1 / 255.0f; 443 float par1pow = powf(10.0f, 444 -(1.0f - POvertoneSpread.par1 / 255.0f) * 3.0f); 445 float par2 = POvertoneSpread.par2 / 255.0f; 446 float par3 = 1.0f - POvertoneSpread.par3 / 255.0f; 447 float result; 448 float tmp = 0.0f; 449 int thresh = 0; 450 451 for(int n = 0; n < MAX_SUB_HARMONICS; ++n) { 452 float n1 = n + 1.0f; 453 switch(POvertoneSpread.type) { 454 case 1: 455 thresh = (int)(100.0f * par2 * par2) + 1; 456 if (n1 < thresh) 457 result = n1; 458 else 459 result = n1 + 8.0f * (n1 - thresh) * par1pow; 460 break; 461 case 2: 462 thresh = (int)(100.0f * par2 * par2) + 1; 463 if (n1 < thresh) 464 result = n1; 465 else 466 result = n1 + 0.9f * (thresh - n1) * par1pow; 467 break; 468 case 3: 469 tmp = par1pow * 100.0f + 1.0f; 470 result = powf(n / tmp, 1.0f - 0.8f * par2) * tmp + 1.0f; 471 break; 472 case 4: 473 result = n * (1.0f - par1pow) + 474 powf(0.1f * n, 3.0f * par2 + 1.0f) * 475 10.0f * par1pow + 1.0f; 476 break; 477 478 case 5: 479 result = n1 + 2.0f * sinf(n * par2 * par2 * PI * 0.999f) * 480 sqrt(par1pow); 481 break; 482 case 6: 483 tmp = powf(2.0f * par2, 2.0f) + 0.1f; 484 result = n * powf(par1 * powf(0.8f * n, tmp) + 1.0f, tmp) + 485 1.0f; 486 break; 487 488 case 7: 489 result = (n1 + par1) / (par1 + 1); 490 break; 491 default: 492 result = n1; 493 } 494 float iresult = floor(result + 0.5f); 495 POvertoneFreqMult[n] = iresult + par3 * (result - iresult); 496 } 497 } 498 499 #define doPaste(x) this->x = sub.x; 500 #define doPPaste(x) this->x->paste(*sub.x); 501 void SUBnoteParameters::paste(SUBnoteParameters &sub) 502 { 503 doPaste(Pstereo); 504 doPaste(Volume); 505 doPaste(PPanning); 506 doPaste(AmpVelocityScaleFunction); 507 doPPaste(AmpEnvelope); 508 509 //Frequency Parameters 510 doPaste(PDetune); 511 doPaste(PCoarseDetune); 512 doPaste(PDetuneType); 513 doPaste(PBendAdjust); 514 doPaste(POffsetHz); 515 doPaste(PFreqEnvelopeEnabled); 516 doPPaste(FreqEnvelope); 517 doPaste(PBandWidthEnvelopeEnabled); 518 doPPaste(BandWidthEnvelope); 519 520 //Filter Parameters (Global) 521 doPaste(PGlobalFilterEnabled); 522 doPPaste(GlobalFilter); 523 doPaste(PGlobalFilterVelocityScale); 524 doPaste(PGlobalFilterVelocityScaleFunction); 525 doPPaste(GlobalFilterEnvelope); 526 527 528 //Other Parameters 529 doPaste(Pfixedfreq); 530 doPaste(PfixedfreqET); 531 doPaste(POvertoneSpread.type); 532 doPaste(POvertoneSpread.par1); 533 doPaste(POvertoneSpread.par2); 534 doPaste(POvertoneSpread.par3); 535 536 for(int i=0; i<MAX_SUB_HARMONICS; ++i) 537 doPaste(POvertoneFreqMult[i]); 538 539 doPaste(Pnumstages); 540 doPaste(Pbandwidth); 541 doPaste(Phmagtype); 542 543 for(int i=0; i<MAX_SUB_HARMONICS; ++i) { 544 doPaste(Phmag[i]); 545 doPaste(Phrelbw[i]); 546 } 547 548 doPaste(Pbwscale); 549 doPaste(Pstart); 550 551 if ( time ) { 552 last_update_timestamp = time->time(); 553 } 554 } 555 556 void SUBnoteParameters::getfromXML(XMLwrapper& xml) 557 { 558 Pnumstages = xml.getpar127("num_stages", Pnumstages); 559 Phmagtype = xml.getpar127("harmonic_mag_type", Phmagtype); 560 Pstart = xml.getpar127("start", Pstart); 561 562 if(xml.enterbranch("HARMONICS")) { 563 Phmag[0] = 0; 564 for(int i = 0; i < MAX_SUB_HARMONICS; ++i) { 565 if(xml.enterbranch("HARMONIC", i) == 0) 566 continue; 567 Phmag[i] = xml.getpar127("mag", Phmag[i]); 568 Phrelbw[i] = xml.getpar127("relbw", Phrelbw[i]); 569 xml.exitbranch(); 570 } 571 xml.exitbranch(); 572 } 573 574 if(xml.enterbranch("AMPLITUDE_PARAMETERS")) { 575 Pstereo = xml.getparbool("stereo", Pstereo); 576 bool upgrade_3_0_3 = (xml.fileversion() < version_type(3,0,3)) || 577 (!xml.hasparreal("volume")); 578 if (upgrade_3_0_3) { 579 int vol = xml.getpar127("volume", 0); 580 Volume = 60.0f * (vol / 96.0f - 1.0f); 581 } else { 582 Volume = xml.getparreal("volume", Volume); 583 } 584 PPanning = xml.getpar127("panning", PPanning); 585 upgrade_3_0_3 = (xml.fileversion() < version_type(3,0,3)) || 586 (xml.getparreal("velocity_sensing", -1) < 0); 587 588 if (upgrade_3_0_3) { 589 int tmp_val = xml.getpar127("velocity_sensing", 0); 590 AmpVelocityScaleFunction = 100.0f * tmp_val / 127.0f; 591 } else { 592 AmpVelocityScaleFunction = xml.getparreal("velocity_sensing", AmpVelocityScaleFunction); 593 } 594 595 596 if(xml.enterbranch("AMPLITUDE_ENVELOPE")) { 597 AmpEnvelope->getfromXML(xml); 598 xml.exitbranch(); 599 } 600 xml.exitbranch(); 601 } 602 603 if(xml.enterbranch("FREQUENCY_PARAMETERS")) { 604 Pfixedfreq = xml.getparbool("fixed_freq", Pfixedfreq); 605 PfixedfreqET = xml.getpar127("fixed_freq_et", PfixedfreqET); 606 PBendAdjust = xml.getpar127("bend_adjust", PBendAdjust); 607 POffsetHz = xml.getpar127("offset_hz", POffsetHz); 608 609 PDetune = xml.getpar("detune", PDetune, 0, 16383); 610 PCoarseDetune = xml.getpar("coarse_detune", PCoarseDetune, 0, 16383); 611 POvertoneSpread.type = 612 xml.getpar127("overtone_spread_type", POvertoneSpread.type); 613 POvertoneSpread.par1 = 614 xml.getpar("overtone_spread_par1", POvertoneSpread.par1, 0, 255); 615 POvertoneSpread.par2 = 616 xml.getpar("overtone_spread_par2", POvertoneSpread.par2, 0, 255); 617 POvertoneSpread.par3 = 618 xml.getpar("overtone_spread_par3", POvertoneSpread.par3, 0, 255); 619 updateFrequencyMultipliers(); 620 PDetuneType = xml.getpar127("detune_type", PDetuneType); 621 622 Pbandwidth = xml.getpar127("bandwidth", Pbandwidth); 623 Pbwscale = xml.getpar127("bandwidth_scale", Pbwscale); 624 625 PFreqEnvelopeEnabled = xml.getparbool("freq_envelope_enabled", 626 PFreqEnvelopeEnabled); 627 if(xml.enterbranch("FREQUENCY_ENVELOPE")) { 628 FreqEnvelope->getfromXML(xml); 629 xml.exitbranch(); 630 } 631 632 PBandWidthEnvelopeEnabled = xml.getparbool( 633 "band_width_envelope_enabled", 634 PBandWidthEnvelopeEnabled); 635 if(xml.enterbranch("BANDWIDTH_ENVELOPE")) { 636 BandWidthEnvelope->getfromXML(xml); 637 xml.exitbranch(); 638 } 639 640 xml.exitbranch(); 641 } 642 643 if(xml.enterbranch("FILTER_PARAMETERS")) { 644 PGlobalFilterEnabled = xml.getparbool("enabled", PGlobalFilterEnabled); 645 if(xml.enterbranch("FILTER")) { 646 GlobalFilter->getfromXML(xml); 647 xml.exitbranch(); 648 } 649 650 PGlobalFilterVelocityScaleFunction = xml.getpar127( 651 "filter_velocity_sensing", 652 PGlobalFilterVelocityScaleFunction); 653 PGlobalFilterVelocityScale = xml.getpar127( 654 "filter_velocity_sensing_amplitude", 655 PGlobalFilterVelocityScale); 656 657 if(xml.enterbranch("FILTER_ENVELOPE")) { 658 GlobalFilterEnvelope->getfromXML(xml); 659 xml.exitbranch(); 660 } 661 662 xml.exitbranch(); 663 } 664 } 665 666 }