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