ADnoteParameters.cpp (47022B)
1 /* 2 ZynAddSubFX - a software synthesizer 3 4 ADnoteParameters.cpp - Parameters for ADnote (ADsynth) 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 <stdlib.h> 15 #include <stdio.h> 16 #include <math.h> 17 18 #include "ADnoteParameters.h" 19 #include "EnvelopeParams.h" 20 #include "LFOParams.h" 21 #include "../Misc/Time.h" 22 #include "../Misc/XMLwrapper.h" 23 #include "../DSP/FFTwrapper.h" 24 #include "../Synth/OscilGen.h" 25 #include "../Synth/Resonance.h" 26 #include "FilterParams.h" 27 28 #include <rtosc/ports.h> 29 #include <rtosc/port-sugar.h> 30 31 namespace zyn { 32 33 using rtosc::Ports; 34 using rtosc::RtData; 35 36 #define rObject ADnoteVoiceParam 37 38 #undef rChangeCb 39 #define rChangeCb if (obj->time) { obj->last_update_timestamp = obj->time->time(); } 40 static const Ports voicePorts = { 41 //Send Messages To Oscillator Realtime Table 42 {"OscilSmp/", rDoc("Primary Oscillator"), 43 &OscilGen::ports, 44 rBOIL_BEGIN 45 if(obj->OscilGn == NULL) return; 46 data.obj = obj->OscilGn; 47 SNIP 48 OscilGen::realtime_ports.dispatch(msg, data); 49 if(data.matches == 0) 50 data.forward(); 51 rBOIL_END}, 52 {"FMSmp/", rDoc("Modulating Oscillator"), 53 &OscilGen::ports, 54 rBOIL_BEGIN 55 if(obj->FmGn == NULL) return; 56 data.obj = obj->FmGn; 57 SNIP 58 OscilGen::realtime_ports.dispatch(msg, data); 59 if(data.matches == 0) 60 data.forward(); 61 rBOIL_END}, 62 rRecurp(FreqLfo, "Frequency LFO"), 63 rRecurp(AmpLfo, "Amplitude LFO"), 64 rRecurp(FilterLfo, "Filter LFO"), 65 rRecurp(FreqEnvelope, "Frequency Envelope"), 66 rRecurp(AmpEnvelope, "Amplitude Envelope"), 67 rRecurp(FilterEnvelope, "Filter Envelope"), 68 rRecurp(FMFreqEnvelope, "Modulator Frequency Envelope"), 69 rRecurp(FMAmpEnvelope, "Modulator Amplitude Envelope"), 70 rRecurp(VoiceFilter, "Optional Voice Filter"), 71 72 // rToggle(Enabled, rShort("enable"), "Voice Enable"), 73 rParamI(Unison_size, rShort("size"), rMap(min, 1), rMap(max, 50), 74 rDefault(1), "Number of subvoices"), 75 rParamZyn(Unison_phase_randomness, rShort("ph.rnd."), rDefault(127), 76 "Phase Randomness"), 77 rParamZyn(Unison_frequency_spread, rShort("detune"), rDefault(60), 78 "Subvoice detune"), 79 rParamZyn(Unison_stereo_spread, rShort("spread"), rDefault(64), 80 "Subvoice L/R Separation"), 81 rParamZyn(Unison_vibratto, rShort("vib."), rDefault(64), 82 "Subvoice vibratto"), 83 rParamZyn(Unison_vibratto_speed, rShort("speed"), rDefault(64), 84 "Subvoice vibratto speed"), 85 rOption(Unison_invert_phase, rShort("inv."), 86 rOptions(none, random, 50%, 33%, 25%), rDefault(none), 87 "Subvoice Phases"), 88 rOption(Type, rShort("type"), rOptions(Sound,White,Pink,DC), 89 rLinear(0,127), rDefault(Sound), "Type of Sound"), 90 rParamZyn(PDelay, rShort("delay"), rDefault(0), 91 "Voice Startup Delay"), 92 rToggle(Presonance, rShort("enable"), rDefault(true), 93 "Resonance Enable"), 94 rParamI(Pextoscil, rDefault(-1), rShort("ext."), 95 rMap(min, -1), rMap(max, 16), "External Oscillator Selection"), 96 rParamI(PextFMoscil, rDefault(-1), rShort("ext."), 97 rMap(min, -1), rMap(max, 16), "External FM Oscillator Selection"), 98 rParamZyn(Poscilphase, rShort("phase"), rDefault(64), 99 "Oscillator Phase"), 100 rParamZyn(PFMoscilphase, rShort("phase"), rDefault(64), 101 "FM Oscillator Phase"), 102 rToggle(Pfilterbypass, rShort("bypass"), rDefault(false), 103 "Filter Bypass"), 104 rToggle(PfilterFcCtlBypass, rShort("CtlBypass"), rDefault(false), 105 "Filter Fc Controll Bypass"), 106 //Freq Stuff 107 rToggle(Pfixedfreq, rShort("fixed"), rDefault(false), 108 "If frequency is fixed"), 109 rParamZyn(PfixedfreqET, rShort("e.t."), rDefault(0), 110 "Equal Temperament Parameter"), 111 rParamZyn(PBendAdjust, rShort("bend"), rDefault(88) /* 64 + 24 */, 112 "Pitch bend adjustment"), 113 rParamZyn(POffsetHz, rShort("offset"), rDefault(64), 114 "Voice constant offset"), 115 //nominally -8192..8191 116 rParamI(PDetune, rShort("fine"), rLinear(0, 16383), 117 rDefault(8192), "Fine Detune"), 118 rParamI(PCoarseDetune, rShort("coarse"), rDefault(0), 119 "Coarse Detune"), 120 rOption(PDetuneType, rShort("type"), 121 rOptions(L35cents, L10cents, E100cents, E1200cents), rDefault(L35cents), 122 "Magnitude of Detune"), 123 rToggle(PFreqEnvelopeEnabled, rShort("enable"), rDefault(false), 124 "Frequency Envelope Enable"), 125 rToggle(PFreqLfoEnabled, rShort("enable"), rDefault(false), 126 "Frequency LFO Enable"), 127 128 //Amplitude Stuff 129 rParamZyn(PPanning, rShort("pan."), rDefault(64), 130 "Panning"), 131 {"PVolume::i", rShort("vol.") rLinear(0,127) 132 rDoc("Volume"), NULL, 133 [](const char *msg, RtData &d) 134 { 135 rObject *obj = (rObject *)d.obj; 136 if (!rtosc_narguments(msg)) 137 d.reply(d.loc, "i", (int)roundf(127.0f * (1.0f + obj->volume/60.0f))); 138 else 139 obj->volume = -60.0f * (1.0f - rtosc_argument(msg, 0).i / 127.0f); 140 }}, 141 {"volume::f", rShort("volume") rProp(parameter) rUnit(dB) 142 rDefault(-0x1.983064p+3) rLinear(-60.0f, 0.0f) rDoc("Part Volume"), NULL, 143 [](const char *msg, RtData &d) 144 { 145 rObject *obj = (rObject *)d.obj; 146 if(!rtosc_narguments(msg)) { 147 d.reply(d.loc, "f", obj->volume); 148 } else if (rtosc_narguments(msg) == 1 && rtosc_type(msg, 0) == 'f') { 149 obj->volume = rtosc_argument(msg, 0).f; 150 d.broadcast(d.loc, "f", ((obj->volume))); 151 } 152 }}, 153 rToggle(PVolumeminus, rShort("inv."), rDefault(false), 154 "Signal Inverter"), //do we really need this?? 155 rToggle(PAAEnabled, rShort("enable"), rDefault(false), 156 "AntiAliasing Enable"), 157 rParamZyn(PAmpVelocityScaleFunction, rShort("sense"), rDefault(127), 158 "Velocity Sensing"), 159 rToggle(PAmpEnvelopeEnabled, rShort("enable"), rDefault(false), 160 "Amplitude Envelope Enable"), 161 rToggle(PAmpLfoEnabled, rShort("enable"), rDefault(false), 162 "Amplitude LFO Enable"), 163 164 //Filter Stuff 165 rToggle(PFilterEnabled, rShort("enable"), rDefault(false), 166 "Filter Enable"), 167 rToggle(PFilterEnvelopeEnabled, rShort("enable"), rDefault(false), 168 "Filter Envelope Enable"), 169 rToggle(PFilterLfoEnabled, rShort("enable"), rDefault(false), 170 "Filter LFO Enable"), 171 rParamZyn(PFilterVelocityScale, rShort("v.scale"), rDefault(0), 172 "Filter Velocity Magnitude"), 173 rParamZyn(PFilterVelocityScaleFunction, rShort("v.sense"), rDefault(64), 174 "Filter Velocity Function Shape"), 175 176 177 //Modulator Stuff 178 rOption(PFMEnabled, rShort("mode"), rOptions(none, mix, ring, phase, 179 frequency, pulse), rLinear(0,127), rDefault(none), "Modulator mode"), 180 rParamI(PFMVoice, rShort("voice"), rDefault(-1), 181 "Modulator Oscillator Selection"), 182 rParamF(FMvolume, rShort("vol."), rLinear(0.0, 100.0), 183 rDefault(70.0), "Modulator Magnitude"), 184 rParamZyn(PFMVolumeDamp, rShort("damp."), rDefault(64), 185 "Modulator HF dampening"), 186 rParamZyn(PFMVelocityScaleFunction, rShort("sense"), rDefault(64), 187 "Modulator Velocity Function"), 188 //nominally -8192..8191 189 rParamI(PFMDetune, rShort("fine"), 190 rLinear(0, 16383), rDefault(8192), "Modulator Fine Detune"), 191 rParamI(PFMCoarseDetune, rShort("coarse"), rDefault(0), 192 "Modulator Coarse Detune"), 193 rOption(PFMDetuneType, rShort("type"), 194 rOptions(L35cents, L10cents, E100cents, E1200cents), 195 rDefault(L35cents), 196 "Modulator Detune Magnitude"), 197 rToggle(PFMFixedFreq, rShort("fixed"), rDefault(false), 198 "Modulator Frequency Fixed"), 199 rToggle(PFMFreqEnvelopeEnabled, rShort("enable"), rDefault(false), 200 "Modulator Frequency Envelope"), 201 rToggle(PFMAmpEnvelopeEnabled, rShort("enable"), rDefault(false), 202 "Modulator Amplitude Envelope"), 203 204 205 206 //weird stuff for PCoarseDetune 207 {"detunevalue:", rMap(unit,cents) rDoc("Get detune in cents"), NULL, 208 [](const char *, RtData &d) 209 { 210 rObject *obj = (rObject *)d.obj; 211 unsigned detuneType = 212 obj->PDetuneType == 0 ? *(obj->GlobalPDetuneType) 213 : obj->PDetuneType; 214 //TODO check if this is accurate or if PCoarseDetune is utilized 215 //TODO do the same for the other engines 216 d.reply(d.loc, "f", getdetune(detuneType, 0, obj->PDetune)); 217 }}, 218 {"octave::c:i", rProp(parameter) rShort("octave") rLinear(-8, 7) rDoc("Octave note offset"), 219 NULL, 220 [](const char *msg, RtData &d) 221 { 222 rObject *obj = (rObject *)d.obj; 223 auto get_octave = [&obj](){ 224 int k=obj->PCoarseDetune/1024; 225 if (k>=8) k-=16; 226 return k; 227 }; 228 if(!rtosc_narguments(msg)) { 229 d.reply(d.loc, "i", get_octave()); 230 } else { 231 int k=(int) rtosc_argument(msg, 0).i; 232 if (k<0) k+=16; 233 obj->PCoarseDetune = k*1024 + obj->PCoarseDetune%1024; 234 d.broadcast(d.loc, "i", get_octave()); 235 } 236 }}, 237 {"coarsedetune::c:i", rProp(parameter) rShort("coarse") rLinear(-64,63) rDefault(0) 238 rDoc("Coarse note detune"), NULL, 239 [](const char *msg, RtData &d) 240 { 241 rObject *obj = (rObject *)d.obj; 242 auto get_coarse = [&obj](){ 243 int k=obj->PCoarseDetune%1024; 244 if (k>=512) k-=1024; 245 return k; 246 }; 247 if(!rtosc_narguments(msg)) { 248 d.reply(d.loc, "i", get_coarse()); 249 } else { 250 int k=(int) rtosc_argument(msg, 0).i; 251 if (k<0) k+=1024; 252 obj->PCoarseDetune = k + (obj->PCoarseDetune/1024)*1024; 253 d.broadcast(d.loc, "i", get_coarse()); 254 } 255 }}, 256 {"PFMVolume::i", rShort("vol.") rLinear(0,127) 257 rDoc("Modulator Magnitude"), NULL, 258 [](const char *msg, RtData &d) 259 { 260 rObject *obj = (rObject *)d.obj; 261 if (!rtosc_narguments(msg)) 262 d.reply(d.loc, "i", (int)roundf(127.0f * obj->FMvolume 263 / 100.0f)); 264 else 265 obj->FMvolume = 100.0f * rtosc_argument(msg, 0).i / 127.0f; 266 }}, 267 //weird stuff for PCoarseDetune 268 {"FMdetunevalue:", rMap(unit,cents) rDoc("Get modulator detune"), NULL, [](const char *, RtData &d) 269 { 270 rObject *obj = (rObject *)d.obj; 271 unsigned detuneType = 272 obj->PFMDetuneType == 0 ? *(obj->GlobalPDetuneType) 273 : obj->PFMDetuneType; 274 //TODO check if this is accurate or if PCoarseDetune is utilized 275 //TODO do the same for the other engines 276 d.reply(d.loc, "f", getdetune(detuneType, 0, obj->PFMDetune)); 277 }}, 278 {"FMoctave::c:i", rProp(parameter) rShort("octave") rLinear(-8,7) rDoc("Octave note offset for modulator"), NULL, 279 [](const char *msg, RtData &d) 280 { 281 rObject *obj = (rObject *)d.obj; 282 auto get_octave = [&obj](){ 283 int k=obj->PFMCoarseDetune/1024; 284 if (k>=8) k-=16; 285 return k; 286 }; 287 if(!rtosc_narguments(msg)) { 288 d.reply(d.loc, "i", get_octave()); 289 } else { 290 int k=(int) rtosc_argument(msg, 0).i; 291 if (k<0) k+=16; 292 obj->PFMCoarseDetune = k*1024 + obj->PFMCoarseDetune%1024; 293 d.broadcast(d.loc, "i", get_octave()); 294 } 295 }}, 296 {"FMcoarsedetune::c:i", rProp(parameter) rShort("coarse") rLinear(-64,63) 297 rDoc("Coarse note detune for modulator"), 298 NULL, [](const char *msg, RtData &d) 299 { 300 rObject *obj = (rObject *)d.obj; 301 auto get_coarse = [&obj](){ 302 int k=obj->PFMCoarseDetune%1024; 303 if (k>=512) k-=1024; 304 return k; 305 }; 306 if(!rtosc_narguments(msg)) { 307 d.reply(d.loc, "i", get_coarse()); 308 } else { 309 int k=(int) rtosc_argument(msg, 0).i; 310 if (k<0) k+=1024; 311 obj->PFMCoarseDetune = k + (obj->PFMCoarseDetune/1024)*1024; 312 d.broadcast(d.loc, "i", get_coarse()); 313 } 314 }}, 315 316 //Reader 317 {"unisonFrequencySpreadCents:", rMap(unit,cents) rDoc("Unison Frequency Spread"), 318 NULL, [](const char *, RtData &d) 319 { 320 rObject *obj = (rObject *)d.obj; 321 d.reply(d.loc, "f", obj->getUnisonFrequencySpreadCents()); 322 }}, 323 }; 324 #undef rChangeCb 325 326 #undef rObject 327 #define rObject ADnoteGlobalParam 328 329 #define rChangeCb if (obj->time) { obj->last_update_timestamp = obj->time->time(); } 330 static const Ports globalPorts = { 331 rRecurp(Reson, "Resonance"), 332 rRecurp(FreqLfo, "Frequency LFO"), 333 rRecurp(AmpLfo, "Amplitude LFO"), 334 rRecurp(FilterLfo, "Filter LFO"), 335 rRecurp(FreqEnvelope, "Frequency Envelope"), 336 rRecurp(AmpEnvelope, "Frequency Envelope"), 337 rRecurp(FilterEnvelope, "Frequency Envelope"), 338 rRecurp(GlobalFilter, "Filter"), 339 340 rToggle(PStereo, rShort("stereo"), rDefault(true), "Mono/Stereo Enable"), 341 342 //Frequency 343 //nominally -8192..8191 344 rParamI(PDetune, rShort("fine"), 345 rLinear(0, 16383), rDefault(8192), "Fine Detune"), 346 rParamI(PCoarseDetune, rShort("coarse"), rDefault(0), "Coarse Detune"), 347 rOption(PDetuneType, rShort("type"), 348 rOptions(L35cents, L10cents, E100cents, E1200cents), 349 rDefault(L10cents), 350 "Detune Scaling Type"), 351 rParamZyn(PBandwidth, rShort("bw."), rDefault(64), 352 "Relative Fine Detune Gain"), 353 354 //Amplitude 355 rParamZyn(PPanning, rShort("pan"), rDefault(64), 356 "Panning of ADsynth (0 random, 1 left, 127 right)"), 357 rParamF(Volume, rShort("vol"), rLinear(-47.9588f,32.0412f), 358 rUnit(dB), rDefault(8.29f), "volume control"), 359 rParamZyn(PAmpVelocityScaleFunction, rShort("sense"), rDefault(64), 360 "Volume velocity sense"), 361 {"PVolume::i", rShort("vol.") rLinear(0,127) 362 rDoc("Volume"), NULL, 363 [](const char *msg, RtData &d) 364 { 365 rObject *obj = (rObject *)d.obj; 366 if (!rtosc_narguments(msg)) 367 d.reply(d.loc, "i", (int)roundf(96.0f * (1.0f + (obj->Volume - 12.0412f)/60.0f))); 368 else 369 obj->Volume = 12.0412f - 60.0f * (1.0f - rtosc_argument(msg, 0).i / 96.0f); 370 }}, 371 rParamZyn(Fadein_adjustment, rDefault(FADEIN_ADJUSTMENT_SCALE), 372 "Adjustment for anti-pop strategy."), 373 rParamZyn(PPunchStrength, rShort("strength"), rDefault(0), 374 "Punch Strength"), 375 rParamZyn(PPunchTime, rShort("time"), rDefault(60), 376 "Length of Punch"), 377 rParamZyn(PPunchStretch, rShort("stretch"), rDefault(64), 378 "How Punch changes with note frequency"), 379 rParamZyn(PPunchVelocitySensing, rShort("v.sns"), rDefault(72), 380 "Punch Velocity control"), 381 382 //Filter 383 rParamZyn(PFilterVelocityScale, rShort("scale"), rDefault(0), 384 "Filter Velocity Magnitude"), 385 rParamZyn(PFilterVelocityScaleFunction, rShort("sense"), rDefault(64), 386 "Filter Velocity Function Shape"), 387 388 389 //Resonance 390 rToggle(Hrandgrouping, rDefault(false), 391 "How randomness is applied to multiple voices using the same oscil"), 392 393 //weird stuff for PCoarseDetune 394 {"detunevalue:", rMap(unit,cents) rDoc("Get detune in cents"), NULL, 395 [](const char *, RtData &d) 396 { 397 rObject *obj = (rObject *)d.obj; 398 d.reply(d.loc, "f", getdetune(obj->PDetuneType, 0, obj->PDetune)); 399 }}, 400 {"octave::c:i", rProp(parameter) rShort("octave") rLinear(-8,7) 401 rDoc("Octave note offset"), NULL, 402 [](const char *msg, RtData &d) 403 { 404 rObject *obj = (rObject *)d.obj; 405 auto get_octave = [&obj](){ 406 int k=obj->PCoarseDetune/1024; 407 if (k>=8) k-=16; 408 return k; 409 }; 410 if(!rtosc_narguments(msg)) { 411 d.reply(d.loc, "i", get_octave()); 412 } else { 413 int k=(int) rtosc_argument(msg, 0).i; 414 if (k<0) k+=16; 415 obj->PCoarseDetune = k*1024 + obj->PCoarseDetune%1024; 416 d.broadcast(d.loc, "i", get_octave()); 417 } 418 }}, 419 {"coarsedetune::c:i", rProp(parameter) rShort("coarse") rLinear(-64, 63) 420 rDoc("Coarse note detune"), NULL, 421 [](const char *msg, RtData &d) 422 { 423 rObject *obj = (rObject *)d.obj; 424 auto get_coarse = [&obj](){ 425 int k=obj->PCoarseDetune%1024; 426 if (k>=512) k-=1024; 427 return k; 428 }; 429 if(!rtosc_narguments(msg)) { 430 d.reply(d.loc, "i", get_coarse()); 431 } else { 432 int k=(int) rtosc_argument(msg, 0).i; 433 if (k<0) k+=1024; 434 obj->PCoarseDetune = k + (obj->PCoarseDetune/1024)*1024; 435 d.broadcast(d.loc, "i", get_coarse()); 436 } 437 }}, 438 439 }; 440 #undef rChangeCb 441 442 #undef rObject 443 #define rObject ADnoteParameters 444 445 #define rChangeCb obj->last_update_timestamp = obj->time->time(); 446 static const Ports adPorts = {//XXX 16 should not be hard coded 447 rSelf(ADnoteParameters), 448 rPasteRt, 449 rArrayPasteRt, 450 {"VoicePar#" STRINGIFY(NUM_VOICES) "/Enabled::T:F", 451 rProp(parameter) rShort("enable") rDoc("Voice Enable") 452 rDefault([true false false ...]), 453 NULL, rArrayTCbMember(VoicePar, Enabled)}, 454 // this must come after "VoicePar#.../..." ports, so rtosc::apropos finds 455 // the more exact path first (bug in apropos) 456 rRecurs(VoicePar, NUM_VOICES, "Voice Parameters"), 457 rRecur(GlobalPar, "Adnote Parameters"), 458 }; 459 #undef rChangeCb 460 const Ports &ADnoteParameters::ports = adPorts; 461 const Ports &ADnoteVoiceParam::ports = voicePorts; 462 const Ports &ADnoteGlobalParam::ports = globalPorts; 463 464 ADnoteParameters::ADnoteParameters(const SYNTH_T &synth, FFTwrapper *fft_, 465 const AbsTime *time_) 466 :PresetsArray(), GlobalPar(time_), time(time_), last_update_timestamp(0) 467 { 468 setpresettype("Padsynth"); 469 fft = fft_; 470 471 472 for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice) { 473 VoicePar[nvoice].GlobalPDetuneType = &GlobalPar.PDetuneType; 474 VoicePar[nvoice].time = time_; 475 EnableVoice(synth, nvoice, time_); 476 } 477 478 defaults(); 479 } 480 481 ADnoteGlobalParam::ADnoteGlobalParam(const AbsTime *time_) : 482 time(time_), last_update_timestamp(0) 483 { 484 FreqEnvelope = new EnvelopeParams(0, 0, time_); 485 FreqEnvelope->init(ad_global_freq); 486 FreqLfo = new LFOParams(ad_global_freq, time_); 487 488 AmpEnvelope = new EnvelopeParams(64, 1, time_); 489 AmpEnvelope->init(ad_global_amp); 490 AmpLfo = new LFOParams(ad_global_amp, time_); 491 492 GlobalFilter = new FilterParams(ad_global_filter, time_); 493 FilterEnvelope = new EnvelopeParams(0, 1, time_); 494 FilterEnvelope->init(ad_global_filter); 495 FilterLfo = new LFOParams(ad_global_filter, time_); 496 Reson = new Resonance(); 497 } 498 499 void ADnoteParameters::defaults() 500 { 501 //Default Parameters 502 GlobalPar.defaults(); 503 504 for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice) 505 defaults(nvoice); 506 507 VoicePar[0].Enabled = 1; 508 } 509 510 void ADnoteGlobalParam::defaults() 511 { 512 /* Frequency Global Parameters */ 513 PStereo = 1; //stereo 514 PDetune = 8192; //zero 515 PCoarseDetune = 0; 516 PDetuneType = 1; 517 FreqEnvelope->defaults(); 518 FreqLfo->defaults(); 519 PBandwidth = 64; 520 521 /* Amplitude Global Parameters */ 522 Volume = 8.29f; 523 PPanning = 64; //center 524 PAmpVelocityScaleFunction = 64; 525 AmpEnvelope->defaults(); 526 AmpLfo->defaults(); 527 Fadein_adjustment = FADEIN_ADJUSTMENT_SCALE; 528 PPunchStrength = 0; 529 PPunchTime = 60; 530 PPunchStretch = 64; 531 PPunchVelocitySensing = 72; 532 Hrandgrouping = 0; 533 534 /* Filter Global Parameters*/ 535 PFilterVelocityScale = 0; 536 PFilterVelocityScaleFunction = 64; 537 GlobalFilter->defaults(); 538 FilterEnvelope->defaults(); 539 FilterLfo->defaults(); 540 Reson->defaults(); 541 } 542 543 /* 544 * Defaults a voice 545 */ 546 void ADnoteParameters::defaults(int n) 547 { 548 VoicePar[n].defaults(); 549 } 550 551 void ADnoteVoiceParam::defaults() 552 { 553 Enabled = 0; 554 555 Unison_size = 1; 556 Unison_frequency_spread = 60; 557 Unison_stereo_spread = 64; 558 Unison_vibratto = 64; 559 Unison_vibratto_speed = 64; 560 Unison_invert_phase = 0; 561 Unison_phase_randomness = 127; 562 563 Type = 0; 564 Pfixedfreq = 0; 565 PfixedfreqET = 0; 566 PBendAdjust = 88; // 64 + 24 567 POffsetHz = 64; 568 Presonance = 1; 569 Pfilterbypass = 0; 570 PfilterFcCtlBypass = 0; 571 Pextoscil = -1; 572 PextFMoscil = -1; 573 Poscilphase = 64; 574 PFMoscilphase = 64; 575 PDelay = 0; 576 volume = -60.0f* (1.0f - 100.0f / 127.0f); 577 PVolumeminus = 0; 578 PAAEnabled = 0; 579 PPanning = 64; //center 580 PDetune = 8192; //8192=0 581 PCoarseDetune = 0; 582 PDetuneType = 0; 583 PFreqLfoEnabled = 0; 584 PFreqEnvelopeEnabled = 0; 585 PAmpEnvelopeEnabled = 0; 586 PAmpLfoEnabled = 0; 587 PAmpVelocityScaleFunction = 127; 588 PFilterEnabled = 0; 589 PFilterEnvelopeEnabled = 0; 590 PFilterLfoEnabled = 0; 591 PFilterVelocityScale = 0; 592 PFilterVelocityScaleFunction = 64; 593 PFMEnabled = FMTYPE::NONE; 594 PFMFixedFreq = false; 595 596 //I use the internal oscillator (-1) 597 PFMVoice = -1; 598 599 FMvolume = 70.0; 600 PFMVolumeDamp = 64; 601 PFMDetune = 8192; 602 PFMCoarseDetune = 0; 603 PFMDetuneType = 0; 604 PFMFreqEnvelopeEnabled = 0; 605 PFMAmpEnvelopeEnabled = 0; 606 PFMVelocityScaleFunction = 64; 607 608 OscilGn->defaults(); 609 FmGn->defaults(); 610 611 AmpEnvelope->defaults(); 612 AmpLfo->defaults(); 613 614 FreqEnvelope->defaults(); 615 FreqLfo->defaults(); 616 617 VoiceFilter->defaults(); 618 FilterEnvelope->defaults(); 619 FilterLfo->defaults(); 620 621 FMFreqEnvelope->defaults(); 622 FMAmpEnvelope->defaults(); 623 } 624 625 626 627 /* 628 * Init the voice parameters 629 */ 630 void ADnoteParameters::EnableVoice(const SYNTH_T &synth, int nvoice, 631 const AbsTime *time) 632 { 633 VoicePar[nvoice].enable(synth, fft, GlobalPar.Reson, time); 634 } 635 636 void ADnoteVoiceParam::enable(const SYNTH_T &synth, FFTwrapper *fft, 637 const Resonance *Reson, const AbsTime *time) 638 { 639 OscilGn = new OscilGen(synth, fft, Reson); 640 FmGn = new OscilGen(synth, fft, NULL); 641 642 AmpEnvelope = new EnvelopeParams(64, 1, time); 643 AmpEnvelope->init(ad_voice_amp); 644 AmpLfo = new LFOParams(ad_voice_amp, time); 645 646 FreqEnvelope = new EnvelopeParams(0, 0, time); 647 FreqEnvelope->init(ad_voice_freq); 648 FreqLfo = new LFOParams(ad_voice_freq, time); 649 650 VoiceFilter = new FilterParams(ad_voice_filter, time); 651 FilterEnvelope = new EnvelopeParams(0, 0, time); 652 FilterEnvelope->init(ad_voice_filter); 653 FilterLfo = new LFOParams(ad_voice_filter, time); 654 655 FMFreqEnvelope = new EnvelopeParams(0, 0, time); 656 FMFreqEnvelope->init(ad_voice_fm_freq); 657 FMAmpEnvelope = new EnvelopeParams(64, 1, time); 658 FMAmpEnvelope->init(ad_voice_fm_amp); 659 } 660 661 /* 662 * Get the Multiplier of the fine detunes of the voices 663 */ 664 float ADnoteParameters::getBandwidthDetuneMultiplier() const 665 { 666 float bw = (GlobalPar.PBandwidth - 64.0f) / 64.0f; 667 bw = powf(2.0f, bw * powf(fabsf(bw), 0.2f) * 5.0f); 668 669 return bw; 670 } 671 672 /* 673 * Get the unison spread in cents for a voice 674 */ 675 676 float ADnoteParameters::getUnisonFrequencySpreadCents(int nvoice) const 677 { 678 return VoicePar[nvoice].getUnisonFrequencySpreadCents(); 679 } 680 681 float ADnoteVoiceParam::getUnisonFrequencySpreadCents(void) const { 682 return powf(Unison_frequency_spread / 127.0f * 2.0f, 2.0f) * 50.0f; //cents 683 } 684 685 /* 686 * Kill the voice 687 */ 688 void ADnoteParameters::KillVoice(int nvoice) 689 { 690 VoicePar[nvoice].kill(); 691 } 692 693 void ADnoteVoiceParam::kill() 694 { 695 delete OscilGn; 696 delete FmGn; 697 698 delete AmpEnvelope; 699 delete AmpLfo; 700 701 delete FreqEnvelope; 702 delete FreqLfo; 703 704 delete VoiceFilter; 705 delete FilterEnvelope; 706 delete FilterLfo; 707 708 delete FMFreqEnvelope; 709 delete FMAmpEnvelope; 710 } 711 712 713 ADnoteGlobalParam::~ADnoteGlobalParam() 714 { 715 delete FreqEnvelope; 716 delete FreqLfo; 717 delete AmpEnvelope; 718 delete AmpLfo; 719 delete GlobalFilter; 720 delete FilterEnvelope; 721 delete FilterLfo; 722 delete Reson; 723 } 724 725 ADnoteParameters::~ADnoteParameters() 726 { 727 for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice) 728 KillVoice(nvoice); 729 } 730 731 void ADnoteParameters::add2XMLsection(XMLwrapper& xml, int n) 732 { 733 int nvoice = n; 734 if(nvoice >= NUM_VOICES) 735 return; 736 737 int oscilused = 0, fmoscilused = 0; //if the oscil or fmoscil are used by another voice 738 739 for(int i = 0; i < NUM_VOICES; ++i) { 740 if(VoicePar[i].Pextoscil == nvoice) 741 oscilused = 1; 742 if(VoicePar[i].PextFMoscil == nvoice) 743 fmoscilused = 1; 744 } 745 746 xml.addparbool("enabled", VoicePar[nvoice].Enabled); 747 if(((VoicePar[nvoice].Enabled == 0) && (oscilused == 0) 748 && (fmoscilused == 0)) && (xml.minimal)) 749 return; 750 751 VoicePar[nvoice].add2XML(xml, fmoscilused); 752 } 753 754 void ADnoteVoiceParam::add2XML(XMLwrapper& xml, bool fmoscilused) 755 { 756 xml.addpar("type", Type); 757 758 xml.addpar("unison_size", Unison_size); 759 xml.addpar("unison_frequency_spread", 760 Unison_frequency_spread); 761 xml.addpar("unison_stereo_spread", Unison_stereo_spread); 762 xml.addpar("unison_vibratto", Unison_vibratto); 763 xml.addpar("unison_vibratto_speed", Unison_vibratto_speed); 764 xml.addpar("unison_invert_phase", Unison_invert_phase); 765 xml.addpar("unison_phase_randomness", Unison_phase_randomness); 766 767 xml.addpar("delay", PDelay); 768 xml.addparbool("resonance", Presonance); 769 770 xml.addpar("ext_oscil", Pextoscil); 771 xml.addpar("ext_fm_oscil", PextFMoscil); 772 773 xml.addpar("oscil_phase", Poscilphase); 774 xml.addpar("oscil_fm_phase", PFMoscilphase); 775 776 xml.addparbool("filter_enabled", PFilterEnabled); 777 xml.addparbool("filter_bypass", Pfilterbypass); 778 xml.addparbool("filter_fcctl_bypass", PfilterFcCtlBypass); 779 780 xml.addpar("fm_enabled", (int)PFMEnabled); 781 782 xml.beginbranch("OSCIL"); 783 OscilGn->add2XML(xml); 784 xml.endbranch(); 785 786 787 xml.beginbranch("AMPLITUDE_PARAMETERS"); 788 xml.addpar("panning", PPanning); 789 xml.addparreal("volume", volume); 790 xml.addparbool("volume_minus", PVolumeminus); 791 xml.addpar("velocity_sensing", PAmpVelocityScaleFunction); 792 793 xml.addparbool("amp_envelope_enabled", 794 PAmpEnvelopeEnabled); 795 if((PAmpEnvelopeEnabled != 0) || (!xml.minimal)) { 796 xml.beginbranch("AMPLITUDE_ENVELOPE"); 797 AmpEnvelope->add2XML(xml); 798 xml.endbranch(); 799 } 800 xml.addparbool("amp_lfo_enabled", PAmpLfoEnabled); 801 if((PAmpLfoEnabled != 0) || (!xml.minimal)) { 802 xml.beginbranch("AMPLITUDE_LFO"); 803 AmpLfo->add2XML(xml); 804 xml.endbranch(); 805 } 806 xml.endbranch(); 807 808 xml.beginbranch("FREQUENCY_PARAMETERS"); 809 xml.addparbool("fixed_freq", Pfixedfreq); 810 xml.addpar("fixed_freq_et", PfixedfreqET); 811 xml.addpar("bend_adjust", PBendAdjust); 812 xml.addpar("offset_hz", POffsetHz); 813 xml.addpar("detune", PDetune); 814 xml.addpar("coarse_detune", PCoarseDetune); 815 xml.addpar("detune_type", PDetuneType); 816 817 xml.addparbool("freq_envelope_enabled", 818 PFreqEnvelopeEnabled); 819 if((PFreqEnvelopeEnabled != 0) || (!xml.minimal)) { 820 xml.beginbranch("FREQUENCY_ENVELOPE"); 821 FreqEnvelope->add2XML(xml); 822 xml.endbranch(); 823 } 824 xml.addparbool("freq_lfo_enabled", PFreqLfoEnabled); 825 if((PFreqLfoEnabled != 0) || (!xml.minimal)) { 826 xml.beginbranch("FREQUENCY_LFO"); 827 FreqLfo->add2XML(xml); 828 xml.endbranch(); 829 } 830 xml.endbranch(); 831 832 833 if((PFilterEnabled != 0) || (!xml.minimal)) { 834 xml.beginbranch("FILTER_PARAMETERS"); 835 xml.addpar("velocity_sensing_amplitude", PFilterVelocityScale); 836 xml.addpar("velocity_sensing", PFilterVelocityScaleFunction); 837 xml.beginbranch("FILTER"); 838 VoiceFilter->add2XML(xml); 839 xml.endbranch(); 840 841 xml.addparbool("filter_envelope_enabled", 842 PFilterEnvelopeEnabled); 843 if((PFilterEnvelopeEnabled != 0) || (!xml.minimal)) { 844 xml.beginbranch("FILTER_ENVELOPE"); 845 FilterEnvelope->add2XML(xml); 846 xml.endbranch(); 847 } 848 849 xml.addparbool("filter_lfo_enabled", 850 PFilterLfoEnabled); 851 if((PFilterLfoEnabled != 0) || (!xml.minimal)) { 852 xml.beginbranch("FILTER_LFO"); 853 FilterLfo->add2XML(xml); 854 xml.endbranch(); 855 } 856 xml.endbranch(); 857 } 858 859 if((PFMEnabled != FMTYPE::NONE) || (fmoscilused != 0) 860 || (!xml.minimal)) { 861 xml.beginbranch("FM_PARAMETERS"); 862 xml.addpar("input_voice", PFMVoice); 863 864 xml.addparreal("volume", FMvolume); 865 xml.addpar("volume_damp", PFMVolumeDamp); 866 xml.addpar("velocity_sensing", 867 PFMVelocityScaleFunction); 868 869 xml.addparbool("amp_envelope_enabled", 870 PFMAmpEnvelopeEnabled); 871 if((PFMAmpEnvelopeEnabled != 0) || (!xml.minimal)) { 872 xml.beginbranch("AMPLITUDE_ENVELOPE"); 873 FMAmpEnvelope->add2XML(xml); 874 xml.endbranch(); 875 } 876 xml.beginbranch("MODULATOR"); 877 xml.addpar("detune", PFMDetune); 878 xml.addpar("coarse_detune", PFMCoarseDetune); 879 xml.addpar("detune_type", PFMDetuneType); 880 881 xml.addparbool("freq_envelope_enabled", 882 PFMFreqEnvelopeEnabled); 883 xml.addparbool("fixed_freq", PFMFixedFreq); 884 if((PFMFreqEnvelopeEnabled != 0) || (!xml.minimal)) { 885 xml.beginbranch("FREQUENCY_ENVELOPE"); 886 FMFreqEnvelope->add2XML(xml); 887 xml.endbranch(); 888 } 889 890 xml.beginbranch("OSCIL"); 891 FmGn->add2XML(xml); 892 xml.endbranch(); 893 894 xml.endbranch(); 895 xml.endbranch(); 896 } 897 } 898 899 void ADnoteGlobalParam::add2XML(XMLwrapper& xml) 900 { 901 xml.addparbool("stereo", PStereo); 902 903 xml.beginbranch("AMPLITUDE_PARAMETERS"); 904 xml.addparreal("volume", Volume); 905 xml.addpar("panning", PPanning); 906 xml.addpar("velocity_sensing", PAmpVelocityScaleFunction); 907 xml.addpar("fadein_adjustment", Fadein_adjustment); 908 xml.addpar("punch_strength", PPunchStrength); 909 xml.addpar("punch_time", PPunchTime); 910 xml.addpar("punch_stretch", PPunchStretch); 911 xml.addpar("punch_velocity_sensing", PPunchVelocitySensing); 912 xml.addpar("harmonic_randomness_grouping", Hrandgrouping); 913 914 xml.beginbranch("AMPLITUDE_ENVELOPE"); 915 AmpEnvelope->add2XML(xml); 916 xml.endbranch(); 917 918 xml.beginbranch("AMPLITUDE_LFO"); 919 AmpLfo->add2XML(xml); 920 xml.endbranch(); 921 xml.endbranch(); 922 923 xml.beginbranch("FREQUENCY_PARAMETERS"); 924 xml.addpar("detune", PDetune); 925 926 xml.addpar("coarse_detune", PCoarseDetune); 927 xml.addpar("detune_type", PDetuneType); 928 929 xml.addpar("bandwidth", PBandwidth); 930 931 xml.beginbranch("FREQUENCY_ENVELOPE"); 932 FreqEnvelope->add2XML(xml); 933 xml.endbranch(); 934 935 xml.beginbranch("FREQUENCY_LFO"); 936 FreqLfo->add2XML(xml); 937 xml.endbranch(); 938 xml.endbranch(); 939 940 941 xml.beginbranch("FILTER_PARAMETERS"); 942 xml.addpar("velocity_sensing_amplitude", PFilterVelocityScale); 943 xml.addpar("velocity_sensing", PFilterVelocityScaleFunction); 944 945 xml.beginbranch("FILTER"); 946 GlobalFilter->add2XML(xml); 947 xml.endbranch(); 948 949 xml.beginbranch("FILTER_ENVELOPE"); 950 FilterEnvelope->add2XML(xml); 951 xml.endbranch(); 952 953 xml.beginbranch("FILTER_LFO"); 954 FilterLfo->add2XML(xml); 955 xml.endbranch(); 956 xml.endbranch(); 957 958 xml.beginbranch("RESONANCE"); 959 Reson->add2XML(xml); 960 xml.endbranch(); 961 } 962 963 void ADnoteParameters::add2XML(XMLwrapper& xml) 964 { 965 GlobalPar.add2XML(xml); 966 for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice) { 967 xml.beginbranch("VOICE", nvoice); 968 add2XMLsection(xml, nvoice); 969 xml.endbranch(); 970 } 971 } 972 973 974 void ADnoteGlobalParam::getfromXML(XMLwrapper& xml) 975 { 976 PStereo = xml.getparbool("stereo", PStereo); 977 978 if(xml.enterbranch("AMPLITUDE_PARAMETERS")) { 979 const bool upgrade_3_0_5 = (xml.fileversion() < version_type(3,0,5)); 980 const bool upgrade_3_0_3 = (xml.fileversion() < version_type(3,0,3)) || 981 (!xml.hasparreal("volume")); 982 983 if (upgrade_3_0_3) { 984 int vol = xml.getpar127("volume", 0); 985 Volume = 12.0412f + 60.0f * (vol / 96.0f - 1.0f); 986 } else if (upgrade_3_0_5) { 987 printf("file version less than 3.0.5\n"); 988 Volume = 12.0412f + xml.getparreal("volume", Volume); 989 } else { 990 Volume = xml.getparreal("volume", Volume); 991 } 992 PPanning = xml.getpar127("panning", PPanning); 993 PAmpVelocityScaleFunction = xml.getpar127("velocity_sensing", 994 PAmpVelocityScaleFunction); 995 996 Fadein_adjustment = xml.getpar127("fadein_adjustment", Fadein_adjustment); 997 PPunchStrength = xml.getpar127("punch_strength", PPunchStrength); 998 PPunchTime = xml.getpar127("punch_time", PPunchTime); 999 PPunchStretch = xml.getpar127("punch_stretch", PPunchStretch); 1000 PPunchVelocitySensing = xml.getpar127("punch_velocity_sensing", 1001 PPunchVelocitySensing); 1002 Hrandgrouping = xml.getpar127("harmonic_randomness_grouping", 1003 Hrandgrouping); 1004 1005 if(xml.enterbranch("AMPLITUDE_ENVELOPE")) { 1006 AmpEnvelope->getfromXML(xml); 1007 xml.exitbranch(); 1008 } 1009 1010 if(xml.enterbranch("AMPLITUDE_LFO")) { 1011 AmpLfo->getfromXML(xml); 1012 xml.exitbranch(); 1013 } 1014 1015 xml.exitbranch(); 1016 } 1017 1018 if(xml.enterbranch("FREQUENCY_PARAMETERS")) { 1019 PDetune = xml.getpar("detune", PDetune, 0, 16383); 1020 PCoarseDetune = xml.getpar("coarse_detune", PCoarseDetune, 0, 16383); 1021 PDetuneType = xml.getpar127("detune_type", PDetuneType); 1022 PBandwidth = xml.getpar127("bandwidth", PBandwidth); 1023 1024 xml.enterbranch("FREQUENCY_ENVELOPE"); 1025 FreqEnvelope->getfromXML(xml); 1026 xml.exitbranch(); 1027 1028 xml.enterbranch("FREQUENCY_LFO"); 1029 FreqLfo->getfromXML(xml); 1030 xml.exitbranch(); 1031 1032 xml.exitbranch(); 1033 } 1034 1035 1036 if(xml.enterbranch("FILTER_PARAMETERS")) { 1037 PFilterVelocityScale = xml.getpar127("velocity_sensing_amplitude", 1038 PFilterVelocityScale); 1039 PFilterVelocityScaleFunction = xml.getpar127( 1040 "velocity_sensing", 1041 PFilterVelocityScaleFunction); 1042 1043 xml.enterbranch("FILTER"); 1044 GlobalFilter->getfromXML(xml); 1045 xml.exitbranch(); 1046 1047 xml.enterbranch("FILTER_ENVELOPE"); 1048 FilterEnvelope->getfromXML(xml); 1049 xml.exitbranch(); 1050 1051 xml.enterbranch("FILTER_LFO"); 1052 FilterLfo->getfromXML(xml); 1053 xml.exitbranch(); 1054 xml.exitbranch(); 1055 } 1056 1057 if(xml.enterbranch("RESONANCE")) { 1058 Reson->getfromXML(xml); 1059 xml.exitbranch(); 1060 } 1061 } 1062 1063 void ADnoteParameters::getfromXML(XMLwrapper& xml) 1064 { 1065 GlobalPar.getfromXML(xml); 1066 1067 for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice) { 1068 VoicePar[nvoice].Enabled = 0; 1069 if(xml.enterbranch("VOICE", nvoice) == 0) 1070 continue; 1071 getfromXMLsection(xml, nvoice); 1072 xml.exitbranch(); 1073 } 1074 } 1075 1076 void ADnoteParameters::getfromXMLsection(XMLwrapper& xml, int n) 1077 { 1078 int nvoice = n; 1079 if(nvoice >= NUM_VOICES) 1080 return; 1081 1082 VoicePar[nvoice].getfromXML(xml, nvoice); 1083 } 1084 1085 void ADnoteParameters::paste(ADnoteParameters &a) 1086 { 1087 this->GlobalPar.paste(a.GlobalPar); 1088 for(int i=0; i<NUM_VOICES; ++i) 1089 this->VoicePar[i].paste(a.VoicePar[i]); 1090 1091 if ( time ) { 1092 last_update_timestamp = time->time(); 1093 } 1094 } 1095 1096 void ADnoteParameters::pasteArray(ADnoteParameters &a, int nvoice) 1097 { 1098 if(nvoice >= NUM_VOICES) 1099 return; 1100 1101 VoicePar[nvoice].paste(a.VoicePar[nvoice]); 1102 1103 if ( time ) { 1104 last_update_timestamp = time->time(); 1105 } 1106 } 1107 1108 #define copy(x) this->x = a.x 1109 #define RCopy(x) this->x->paste(*a.x) 1110 void ADnoteVoiceParam::paste(ADnoteVoiceParam &a) 1111 { 1112 //Come on C++ get some darn reflection, this is horrible 1113 1114 copy(Enabled); 1115 copy(Unison_size); 1116 copy(Unison_frequency_spread); 1117 copy(Unison_stereo_spread); 1118 copy(Unison_vibratto); 1119 copy(Unison_vibratto_speed); 1120 copy(Unison_invert_phase); 1121 copy(Unison_phase_randomness); 1122 copy(Type); 1123 copy(PDelay); 1124 copy(Presonance); 1125 copy(Pextoscil); 1126 copy(PextFMoscil); 1127 copy(Poscilphase); 1128 copy(PFMoscilphase); 1129 copy(PFilterEnabled); 1130 copy(Pfilterbypass); 1131 copy(PfilterFcCtlBypass); 1132 copy(PFMEnabled); 1133 copy(PFMFixedFreq); 1134 1135 RCopy(OscilGn); 1136 1137 1138 copy(PPanning); 1139 copy(volume); 1140 copy(PVolumeminus); 1141 copy(PAmpVelocityScaleFunction); 1142 copy(PAmpEnvelopeEnabled); 1143 1144 RCopy(AmpEnvelope); 1145 1146 copy(PAmpLfoEnabled); 1147 1148 RCopy(AmpLfo); 1149 1150 copy(Pfixedfreq); 1151 copy(PfixedfreqET); 1152 copy(PDetune); 1153 copy(PCoarseDetune); 1154 copy(PDetuneType); 1155 copy(PBendAdjust); 1156 copy(POffsetHz); 1157 copy(PFreqEnvelopeEnabled); 1158 1159 RCopy(FreqEnvelope); 1160 1161 copy(PFreqLfoEnabled); 1162 1163 RCopy(FreqLfo); 1164 1165 RCopy(VoiceFilter); 1166 1167 copy(PFilterEnvelopeEnabled); 1168 1169 RCopy(FilterEnvelope); 1170 1171 copy(PFilterLfoEnabled); 1172 copy(PFilterVelocityScale); 1173 copy(PFilterVelocityScaleFunction); 1174 1175 RCopy(FilterLfo); 1176 1177 copy(PFMVoice); 1178 copy(FMvolume); 1179 copy(PFMVolumeDamp); 1180 copy(PFMVelocityScaleFunction); 1181 1182 copy(PFMAmpEnvelopeEnabled); 1183 1184 RCopy(FMAmpEnvelope); 1185 1186 copy(PFMDetune); 1187 copy(PFMCoarseDetune); 1188 copy(PFMDetuneType); 1189 copy(PFMFreqEnvelopeEnabled); 1190 1191 1192 RCopy(FMFreqEnvelope); 1193 1194 RCopy(FmGn); 1195 1196 if ( time ) { 1197 last_update_timestamp = time->time(); 1198 } 1199 } 1200 1201 void ADnoteGlobalParam::paste(ADnoteGlobalParam &a) 1202 { 1203 copy(PStereo); 1204 1205 copy(Volume); 1206 copy(PPanning); 1207 copy(PAmpVelocityScaleFunction); 1208 1209 copy(Fadein_adjustment); 1210 copy(PPunchStrength); 1211 copy(PPunchTime); 1212 copy(PPunchStretch); 1213 copy(PPunchVelocitySensing); 1214 copy(Hrandgrouping); 1215 1216 RCopy(AmpEnvelope); 1217 RCopy(AmpLfo); 1218 1219 copy(PDetune); 1220 copy(PCoarseDetune); 1221 copy(PDetuneType); 1222 copy(PBandwidth); 1223 1224 RCopy(FreqEnvelope); 1225 RCopy(FreqLfo); 1226 1227 copy(PFilterVelocityScale); 1228 copy(PFilterVelocityScaleFunction); 1229 1230 RCopy(GlobalFilter); 1231 RCopy(FilterEnvelope); 1232 RCopy(FilterLfo); 1233 RCopy(Reson); 1234 1235 if ( time ) { 1236 last_update_timestamp = time->time(); 1237 } 1238 } 1239 #undef copy 1240 #undef RCopy 1241 1242 void ADnoteVoiceParam::getfromXML(XMLwrapper& xml, unsigned nvoice) 1243 { 1244 Enabled = xml.getparbool("enabled", 0); 1245 unsigned char unison_in_file = xml.getpar127("unison_size", Unison_size); 1246 unsigned char unison_min = std::atoi(ports["Unison_size"]->meta()["min"]); 1247 unsigned char unison_max = std::atoi(ports["Unison_size"]->meta()["max"]); 1248 Unison_size = std::min(std::max(unison_in_file, unison_min), unison_max); 1249 Unison_frequency_spread = xml.getpar127("unison_frequency_spread", 1250 Unison_frequency_spread); 1251 Unison_stereo_spread = xml.getpar127("unison_stereo_spread", 1252 Unison_stereo_spread); 1253 Unison_vibratto = xml.getpar127("unison_vibratto", Unison_vibratto); 1254 Unison_vibratto_speed = xml.getpar127("unison_vibratto_speed", 1255 Unison_vibratto_speed); 1256 Unison_invert_phase = xml.getpar127("unison_invert_phase", 1257 Unison_invert_phase); 1258 Unison_phase_randomness = xml.getpar127("unison_phase_randomness", 1259 Unison_phase_randomness); 1260 1261 Type = xml.getpar127("type", Type); 1262 PDelay = xml.getpar127("delay", PDelay); 1263 Presonance = xml.getparbool("resonance", Presonance); 1264 1265 Pextoscil = xml.getpar("ext_oscil", -1, -1, nvoice - 1); 1266 PextFMoscil = xml.getpar("ext_fm_oscil", -1, -1, nvoice - 1); 1267 1268 Poscilphase = xml.getpar127("oscil_phase", Poscilphase); 1269 PFMoscilphase = xml.getpar127("oscil_fm_phase", PFMoscilphase); 1270 PFilterEnabled = xml.getparbool("filter_enabled", PFilterEnabled); 1271 Pfilterbypass = xml.getparbool("filter_bypass", Pfilterbypass); 1272 PfilterFcCtlBypass = xml.getparbool("filter_fcctl_bypass", PfilterFcCtlBypass); 1273 PFMEnabled = (FMTYPE)xml.getpar127("fm_enabled", (int)PFMEnabled); 1274 1275 if(xml.enterbranch("OSCIL")) { 1276 OscilGn->getfromXML(xml); 1277 xml.exitbranch(); 1278 } 1279 1280 1281 if(xml.enterbranch("AMPLITUDE_PARAMETERS")) { 1282 PPanning = xml.getpar127("panning", PPanning); 1283 const bool upgrade_3_0_3 = (xml.fileversion() < version_type(3,0,3)) || 1284 (!xml.hasparreal("volume")); 1285 1286 if (upgrade_3_0_3) { 1287 int vol = xml.getpar127("volume", 0); 1288 volume = 60.0f * (vol / 127.0f - 1.0f); 1289 } else { 1290 volume = xml.getparreal("volume", volume); 1291 } 1292 PVolumeminus = xml.getparbool("volume_minus", PVolumeminus); 1293 PAmpVelocityScaleFunction = xml.getpar127("velocity_sensing", 1294 PAmpVelocityScaleFunction); 1295 1296 PAmpEnvelopeEnabled = xml.getparbool("amp_envelope_enabled", 1297 PAmpEnvelopeEnabled); 1298 if(xml.enterbranch("AMPLITUDE_ENVELOPE")) { 1299 AmpEnvelope->getfromXML(xml); 1300 xml.exitbranch(); 1301 } 1302 1303 PAmpLfoEnabled = xml.getparbool("amp_lfo_enabled", PAmpLfoEnabled); 1304 if(xml.enterbranch("AMPLITUDE_LFO")) { 1305 AmpLfo->getfromXML(xml); 1306 xml.exitbranch(); 1307 } 1308 xml.exitbranch(); 1309 } 1310 1311 if(xml.enterbranch("FREQUENCY_PARAMETERS")) { 1312 Pfixedfreq = xml.getparbool("fixed_freq", Pfixedfreq); 1313 PfixedfreqET = xml.getpar127("fixed_freq_et", PfixedfreqET); 1314 PBendAdjust = xml.getpar127("bend_adjust", PBendAdjust); 1315 POffsetHz = xml.getpar127("offset_hz", POffsetHz); 1316 PDetune = xml.getpar("detune", PDetune, 0, 16383); 1317 PCoarseDetune = xml.getpar("coarse_detune", PCoarseDetune, 0, 16383); 1318 PDetuneType = xml.getpar127("detune_type", PDetuneType); 1319 PFreqEnvelopeEnabled = xml.getparbool("freq_envelope_enabled", 1320 PFreqEnvelopeEnabled); 1321 1322 if(xml.enterbranch("FREQUENCY_ENVELOPE")) { 1323 FreqEnvelope->getfromXML(xml); 1324 xml.exitbranch(); 1325 } 1326 1327 PFreqLfoEnabled = xml.getparbool("freq_lfo_enabled", PFreqLfoEnabled); 1328 1329 if(xml.enterbranch("FREQUENCY_LFO")) { 1330 FreqLfo->getfromXML(xml); 1331 xml.exitbranch(); 1332 } 1333 xml.exitbranch(); 1334 } 1335 1336 if(xml.enterbranch("FILTER_PARAMETERS")) { 1337 PFilterVelocityScale = xml.getpar127("velocity_sensing_amplitude", 1338 PFilterVelocityScale); 1339 PFilterVelocityScaleFunction = xml.getpar127( 1340 "velocity_sensing", 1341 PFilterVelocityScaleFunction); 1342 if(xml.enterbranch("FILTER")) { 1343 VoiceFilter->getfromXML(xml); 1344 xml.exitbranch(); 1345 } 1346 1347 PFilterEnvelopeEnabled = xml.getparbool("filter_envelope_enabled", 1348 PFilterEnvelopeEnabled); 1349 if(xml.enterbranch("FILTER_ENVELOPE")) { 1350 FilterEnvelope->getfromXML(xml); 1351 xml.exitbranch(); 1352 } 1353 1354 PFilterLfoEnabled = xml.getparbool("filter_lfo_enabled", 1355 PFilterLfoEnabled); 1356 if(xml.enterbranch("FILTER_LFO")) { 1357 FilterLfo->getfromXML(xml); 1358 xml.exitbranch(); 1359 } 1360 xml.exitbranch(); 1361 } 1362 1363 if(xml.enterbranch("FM_PARAMETERS")) { 1364 const bool upgrade_3_0_3 = (xml.fileversion() < version_type(3,0,3)) || 1365 (xml.getparreal("volume", -1) < 0); 1366 1367 PFMVoice = xml.getpar("input_voice", PFMVoice, -1, nvoice - 1); 1368 if (upgrade_3_0_3) { 1369 int Pvolume = xml.getpar127("volume", 0); 1370 FMvolume = 100.0f * Pvolume / 127.0f; 1371 } else { 1372 FMvolume = xml.getparreal("volume", FMvolume); 1373 } 1374 PFMVolumeDamp = xml.getpar127("volume_damp", PFMVolumeDamp); 1375 PFMVelocityScaleFunction = xml.getpar127("velocity_sensing", 1376 PFMVelocityScaleFunction); 1377 1378 PFMAmpEnvelopeEnabled = xml.getparbool("amp_envelope_enabled", 1379 PFMAmpEnvelopeEnabled); 1380 if(xml.enterbranch("AMPLITUDE_ENVELOPE")) { 1381 FMAmpEnvelope->getfromXML(xml); 1382 xml.exitbranch(); 1383 } 1384 1385 if(xml.enterbranch("MODULATOR")) { 1386 PFMDetune = xml.getpar("detune", PFMDetune, 0, 16383); 1387 PFMCoarseDetune = xml.getpar("coarse_detune", 1388 PFMCoarseDetune, 1389 0, 1390 16383); 1391 PFMDetuneType = xml.getpar127("detune_type", PFMDetuneType); 1392 1393 PFMFreqEnvelopeEnabled = xml.getparbool("freq_envelope_enabled", 1394 PFMFreqEnvelopeEnabled); 1395 PFMFixedFreq = xml.getparbool("fixed_freq", 1396 PFMFixedFreq); 1397 if(xml.enterbranch("FREQUENCY_ENVELOPE")) { 1398 FMFreqEnvelope->getfromXML(xml); 1399 xml.exitbranch(); 1400 } 1401 1402 if(xml.enterbranch("OSCIL")) { 1403 FmGn->getfromXML(xml); 1404 xml.exitbranch(); 1405 } 1406 1407 xml.exitbranch(); 1408 } 1409 xml.exitbranch(); 1410 } 1411 } 1412 1413 }