Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ADnoteParameters.cpp 41KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295
  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. ADnoteParameters.cpp - Parameters for ADnote (ADsynth)
  4. Copyright (C) 2002-2005 Nasca Octavian Paul
  5. Author: Nasca Octavian Paul
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or (at your option) any later version.
  10. */
  11. #include <stdlib.h>
  12. #include <stdio.h>
  13. #include <math.h>
  14. #include "ADnoteParameters.h"
  15. #include "EnvelopeParams.h"
  16. #include "LFOParams.h"
  17. #include "../Misc/Time.h"
  18. #include "../Misc/XMLwrapper.h"
  19. #include "../DSP/FFTwrapper.h"
  20. #include "../Synth/OscilGen.h"
  21. #include "../Synth/Resonance.h"
  22. #include "FilterParams.h"
  23. #include <rtosc/ports.h>
  24. #include <rtosc/port-sugar.h>
  25. namespace zyncarla {
  26. using rtosc::Ports;
  27. using rtosc::RtData;
  28. #define EXPAND(x) x
  29. #define rObject ADnoteVoiceParam
  30. #undef rChangeCb
  31. #define rChangeCb if (obj->time) { obj->last_update_timestamp = obj->time->time(); }
  32. static const Ports voicePorts = {
  33. //Send Messages To Oscillator Realtime Table
  34. {"OscilSmp/", rDoc("Primary Oscillator"),
  35. &OscilGen::ports,
  36. rBOIL_BEGIN
  37. if(obj->OscilSmp == NULL) return;
  38. data.obj = obj->OscilSmp;
  39. SNIP
  40. OscilGen::realtime_ports.dispatch(msg, data);
  41. if(data.matches == 0)
  42. data.forward();
  43. rBOIL_END},
  44. {"FMSmp/", rDoc("Modulating Oscillator"),
  45. &OscilGen::ports,
  46. rBOIL_BEGIN
  47. if(obj->FMSmp == NULL) return;
  48. data.obj = obj->FMSmp;
  49. SNIP
  50. OscilGen::realtime_ports.dispatch(msg, data);
  51. if(data.matches == 0)
  52. data.forward();
  53. rBOIL_END},
  54. rRecurp(FreqLfo, "Frequency LFO"),
  55. rRecurp(AmpLfo, "Amplitude LFO"),
  56. rRecurp(FilterLfo, "Filter LFO"),
  57. rRecurp(FreqEnvelope, "Frequency Envelope"),
  58. rRecurp(AmpEnvelope, "Amplitude Envelope"),
  59. rRecurp(FilterEnvelope, "Filter Envelope"),
  60. rRecurp(FMFreqEnvelope, "Modulator Frequency Envelope"),
  61. rRecurp(FMAmpEnvelope, "Modulator Amplitude Envelope"),
  62. rRecurp(VoiceFilter, "Optional Voice Filter"),
  63. // rToggle(Enabled, rShort("enable"), "Voice Enable"),
  64. rParamI(Unison_size, rShort("size"), rMap(min, 0), rMap(max, 50),
  65. rDefault(1), "Number of subvoices"),
  66. rParamZyn(Unison_phase_randomness, rShort("ph.rnd."), rDefault(127),
  67. "Phase Randomness"),
  68. rParamZyn(Unison_frequency_spread, rShort("detune"), rDefault(60),
  69. "Subvoice detune"),
  70. rParamZyn(Unison_stereo_spread, rShort("spread"), rDefault(64),
  71. "Subvoice L/R Separation"),
  72. rParamZyn(Unison_vibratto, rShort("vib."), rDefault(64),
  73. "Subvoice vibratto"),
  74. rParamZyn(Unison_vibratto_speed, rShort("speed"), rDefault(64),
  75. "Subvoice vibratto speed"),
  76. rOption(Unison_invert_phase, rShort("inv."),
  77. rOptions(none, random, 50%, 33%, 25%), rDefault(none),
  78. "Subvoice Phases"),
  79. rOption(Type, rShort("type"), rOptions(Sound,White,Pink,DC),
  80. rDefault(Sound), "Type of Sound"),
  81. rParamZyn(PDelay, rShort("delay"), rDefault(0),
  82. "Voice Startup Delay"),
  83. rToggle(Presonance, rShort("enable"), "Resonance Enable"),
  84. rParamI(Pextoscil, rShort("ext."),
  85. rMap(min, -1), rMap(max, 16), "External Oscillator Selection"),
  86. rParamI(PextFMoscil, rShort("ext."),
  87. rMap(min, -1), rMap(max, 16), "External FM Oscillator Selection"),
  88. rParamZyn(Poscilphase, rShort("phase"), "Oscillator Phase"),
  89. rParamZyn(PFMoscilphase, rShort("phase"), "FM Oscillator Phase"),
  90. rToggle(Pfilterbypass, rShort("bypass"), "Filter Bypass"),
  91. //Freq Stuff
  92. rToggle(Pfixedfreq, rShort("fixed"), "If frequency is fixed"),
  93. rParamZyn(PfixedfreqET, rShort("e.t."), "Equal Temperament Parameter"),
  94. rParamZyn(PBendAdjust, rShort("bend"), "Pitch bend adjustment"),
  95. rParamZyn(POffsetHz, rShort("offset"), "Voice constant offset"),
  96. //nominally -8192..8191
  97. rParamI(PDetune, rShort("fine"),
  98. rLinear(0, 16383), "Fine Detune"),
  99. rParamI(PCoarseDetune, rShort("coarse"), "Coarse Detune"),
  100. rParamZyn(PDetuneType, rShort("type"),
  101. rOptions(L35cents, L10cents, E100cents, E1200cents),
  102. "Magnitude of Detune"),
  103. rToggle(PFreqEnvelopeEnabled, rShort("enable"), "Frequency Envelope Enable"),
  104. rToggle(PFreqLfoEnabled, rShort("enable"), "Frequency LFO Enable"),
  105. //Amplitude Stuff
  106. rParamZyn(PPanning, rShort("pan."), "Panning"),
  107. rParamZyn(PVolume, rShort("vol."), rDefault(100),
  108. "Volume"),
  109. rToggle(PVolumeminus, rShort("inv."), rDefault(false),
  110. "Signal Inverter"), //do we really need this??
  111. rParamZyn(PAmpVelocityScaleFunction, rShort("sense"), rDefault(127),
  112. "Velocity Sensing"),
  113. rToggle(PAmpEnvelopeEnabled, rShort("enable"), rDefault(false),
  114. "Amplitude Envelope Enable"),
  115. rToggle(PAmpLfoEnabled, rShort("enable"), rDefault(false),
  116. "Amplitude LFO Enable"),
  117. //Filter Stuff
  118. rToggle(PFilterEnabled, rShort("enable"), rDefault(false),
  119. "Filter Enable"),
  120. rToggle(PFilterEnvelopeEnabled, rShort("enable"), rDefault(false),
  121. "Filter Envelope Enable"),
  122. rToggle(PFilterLfoEnabled, rShort("enable"), rDefault(false),
  123. "Filter LFO Enable"),
  124. rParamZyn(PFilterVelocityScale, rShort("v.scale"), rDefault(0),
  125. "Filter Velocity Magnitude"),
  126. rParamZyn(PFilterVelocityScaleFunction, rShort("v.sense"), rDefault(64),
  127. "Filter Velocity Function Shape"),
  128. //Modulator Stuff
  129. rOption(PFMEnabled, rShort("mode"), rOptions(none, morph, ring, phase,
  130. frequency, pulse), rDefault(none), "Modulator mode"),
  131. rParamI(PFMVoice, rShort("voice"), rDefault(-1),
  132. "Modulator Oscillator Selection"),
  133. rParamZyn(PFMVolume, rShort("vol."), rDefault(90),
  134. "Modulator Magnitude"),
  135. rParamZyn(PFMVolumeDamp, rShort("damp."), rDefault(64),
  136. "Modulator HF dampening"),
  137. rParamZyn(PFMVelocityScaleFunction, rShort("sense"), rDefault(64),
  138. "Modulator Velocity Function"),
  139. //nominally -8192..8191
  140. rParamI(PFMDetune, rShort("fine"),
  141. rLinear(0, 16383), rDefault(8192), "Modulator Fine Detune"),
  142. rParamI(PFMCoarseDetune, rShort("coarse"), rDefault(0),
  143. "Modulator Coarse Detune"),
  144. rParamZyn(PFMDetuneType, rShort("type"),
  145. rOptions(L35cents, L10cents, E100cents, E1200cents),
  146. rDefault(L35cents),
  147. "Modulator Detune Magnitude"),
  148. rToggle(PFMFixedFreq, rShort("fixed"), rDefault(false),
  149. "Modulator Frequency Fixed"),
  150. rToggle(PFMFreqEnvelopeEnabled, rShort("enable"), rDefault(false),
  151. "Modulator Frequency Envelope"),
  152. rToggle(PFMAmpEnvelopeEnabled, rShort("enable"), rDefault(false),
  153. "Modulator Amplitude Envelope"),
  154. //weird stuff for PCoarseDetune
  155. {"detunevalue:", rMap(unit,cents) rDoc("Get detune in cents"), NULL,
  156. [](const char *, RtData &d)
  157. {
  158. rObject *obj = (rObject *)d.obj;
  159. unsigned detuneType =
  160. obj->PDetuneType == 0 ? *(obj->GlobalPDetuneType)
  161. : obj->PDetuneType;
  162. //TODO check if this is accurate or if PCoarseDetune is utilized
  163. //TODO do the same for the other engines
  164. d.reply(d.loc, "f", getdetune(detuneType, 0, obj->PDetune));
  165. }},
  166. {"octave::c:i", rProp(parameter) rShort("octave") rLinear(-8, 7) rDoc("Octave note offset"),
  167. NULL,
  168. [](const char *msg, RtData &d)
  169. {
  170. rObject *obj = (rObject *)d.obj;
  171. if(!rtosc_narguments(msg)) {
  172. int k=obj->PCoarseDetune/1024;
  173. if (k>=8) k-=16;
  174. d.reply(d.loc, "i", k);
  175. } else {
  176. int k=(int) rtosc_argument(msg, 0).i;
  177. if (k<0) k+=16;
  178. obj->PCoarseDetune = k*1024 + obj->PCoarseDetune%1024;
  179. }
  180. }},
  181. {"coarsedetune::c:i", rProp(parameter) rShort("coarse") rLinear(-64,63)
  182. rDoc("Coarse note detune"), NULL,
  183. [](const char *msg, RtData &d)
  184. {
  185. rObject *obj = (rObject *)d.obj;
  186. if(!rtosc_narguments(msg)) {
  187. int k=obj->PCoarseDetune%1024;
  188. if (k>=512) k-=1024;
  189. d.reply(d.loc, "i", k);
  190. } else {
  191. int k=(int) rtosc_argument(msg, 0).i;
  192. if (k<0) k+=1024;
  193. obj->PCoarseDetune = k + (obj->PCoarseDetune/1024)*1024;
  194. }
  195. }},
  196. //weird stuff for PCoarseDetune
  197. {"FMdetunevalue:", rMap(unit,cents) rDoc("Get modulator detune"), NULL, [](const char *, RtData &d)
  198. {
  199. rObject *obj = (rObject *)d.obj;
  200. unsigned detuneType =
  201. obj->PFMDetuneType == 0 ? *(obj->GlobalPDetuneType)
  202. : obj->PFMDetuneType;
  203. //TODO check if this is accurate or if PCoarseDetune is utilized
  204. //TODO do the same for the other engines
  205. d.reply(d.loc, "f", getdetune(detuneType, 0, obj->PFMDetune));
  206. }},
  207. {"FMoctave::c:i", rProp(parameter) rShort("octave") rLinear(-8,7) rDoc("Octave note offset for modulator"), NULL,
  208. [](const char *msg, RtData &d)
  209. {
  210. rObject *obj = (rObject *)d.obj;
  211. if(!rtosc_narguments(msg)) {
  212. int k=obj->PFMCoarseDetune/1024;
  213. if (k>=8) k-=16;
  214. d.reply(d.loc, "i", k);
  215. } else {
  216. int k=(int) rtosc_argument(msg, 0).i;
  217. if (k<0) k+=16;
  218. obj->PFMCoarseDetune = k*1024 + obj->PFMCoarseDetune%1024;
  219. }
  220. }},
  221. {"FMcoarsedetune::c:i", rProp(parameter) rShort("coarse") rLinear(-64,63)
  222. rDoc("Coarse note detune for modulator"),
  223. NULL, [](const char *msg, RtData &d)
  224. {
  225. rObject *obj = (rObject *)d.obj;
  226. if(!rtosc_narguments(msg)) {
  227. int k=obj->PFMCoarseDetune%1024;
  228. if (k>=512) k-=1024;
  229. d.reply(d.loc, "i", k);
  230. } else {
  231. int k=(int) rtosc_argument(msg, 0).i;
  232. if (k<0) k+=1024;
  233. obj->PFMCoarseDetune = k + (obj->PFMCoarseDetune/1024)*1024;
  234. }
  235. }},
  236. //Reader
  237. {"unisonFrequencySpreadCents:", rMap(unit,cents) rDoc("Unison Frequency Spread"),
  238. NULL, [](const char *, RtData &d)
  239. {
  240. rObject *obj = (rObject *)d.obj;
  241. d.reply(d.loc, "f", obj->getUnisonFrequencySpreadCents());
  242. }},
  243. };
  244. #undef rChangeCb
  245. #undef rObject
  246. #define rObject ADnoteGlobalParam
  247. #define rChangeCb if (obj->time) { obj->last_update_timestamp = obj->time->time(); }
  248. static const Ports globalPorts = {
  249. rRecurp(Reson, "Resonance"),
  250. rRecurp(FreqLfo, "Frequency LFO"),
  251. rRecurp(AmpLfo, "Amplitude LFO"),
  252. rRecurp(FilterLfo, "Filter LFO"),
  253. rRecurp(FreqEnvelope, "Frequency Envelope"),
  254. rRecurp(AmpEnvelope, "Frequency Envelope"),
  255. rRecurp(FilterEnvelope, "Frequency Envelope"),
  256. rRecurp(GlobalFilter, "Filter"),
  257. rToggle(PStereo, rShort("stereo"), rDefault(true), "Mono/Stereo Enable"),
  258. //Frequency
  259. //nominally -8192..8191
  260. rParamI(PDetune, rShort("fine"),
  261. rLinear(0, 16383), rDefault(8192), "Fine Detune"),
  262. rParamI(PCoarseDetune, rShort("coarse"), rDefault(0), "Coarse Detune"),
  263. rParamZyn(PDetuneType, rShort("type"),
  264. rOptions(L35cents, L10cents, E100cents, E1200cents),
  265. rDefault(L10cents),
  266. "Detune Scaling Type"),
  267. rParamZyn(PBandwidth, rShort("bw."), rDefault(64),
  268. "Relative Fine Detune Gain"),
  269. //Amplitude
  270. rParamZyn(PPanning, rShort("pan"), rDefault(64),
  271. "Panning of ADsynth (0 random, 1 left, 127 right)"),
  272. rParamZyn(PVolume, rShort("vol"), rDefault(90), "volume control"),
  273. rParamZyn(PAmpVelocityScaleFunction, rShort("scale"), rDefault(64),
  274. "Volume Velocity Control"),
  275. rParamZyn(Fadein_adjustment, rDefault(FADEIN_ADJUSTMENT_SCALE),
  276. "Adjustment for anti-pop strategy."),
  277. rParamZyn(PPunchStrength, rShort("strength"), rDefault(0),
  278. "Punch Strength"),
  279. rParamZyn(PPunchTime, rShort("time"), rDefault(60),
  280. "Length of Punch"),
  281. rParamZyn(PPunchStretch, rShort("stretch"), rDefault(64),
  282. "How Punch changes with note frequency"),
  283. rParamZyn(PPunchVelocitySensing, rShort("v.sns"), rDefault(72),
  284. "Punch Velocity control"),
  285. //Filter
  286. rParamZyn(PFilterVelocityScale, rShort("scale"), rDefault(64),
  287. "Filter Velocity Magnitude"),
  288. rParamZyn(PFilterVelocityScaleFunction, rShort("sense"), rDefault(64),
  289. "Filter Velocity Function Shape"),
  290. //Resonance
  291. rToggle(Hrandgrouping, rDefault(false),
  292. "How randomness is applied to multiple voices using the same oscil"),
  293. //weird stuff for PCoarseDetune
  294. {"detunevalue:", rMap(unit,cents) rDoc("Get detune in cents"), NULL,
  295. [](const char *, RtData &d)
  296. {
  297. rObject *obj = (rObject *)d.obj;
  298. d.reply(d.loc, "f", getdetune(obj->PDetuneType, 0, obj->PDetune));
  299. }},
  300. {"octave::c:i", rProp(parameter) rShort("octave") rLinear(-8,7)
  301. rDoc("Octave note offset"), NULL,
  302. [](const char *msg, RtData &d)
  303. {
  304. rObject *obj = (rObject *)d.obj;
  305. if(!rtosc_narguments(msg)) {
  306. int k=obj->PCoarseDetune/1024;
  307. if (k>=8) k-=16;
  308. d.reply(d.loc, "i", k);
  309. } else {
  310. int k=(int) rtosc_argument(msg, 0).i;
  311. if (k<0) k+=16;
  312. obj->PCoarseDetune = k*1024 + obj->PCoarseDetune%1024;
  313. }
  314. }},
  315. {"coarsedetune::c:i", rProp(parameter) rShort("coarse") rLinear(-64, 63)
  316. rDoc("Coarse note detune"), NULL,
  317. [](const char *msg, RtData &d)
  318. {
  319. rObject *obj = (rObject *)d.obj;
  320. if(!rtosc_narguments(msg)) {
  321. int k=obj->PCoarseDetune%1024;
  322. if (k>=512) k-=1024;
  323. d.reply(d.loc, "i", k);
  324. } else {
  325. int k=(int) rtosc_argument(msg, 0).i;
  326. if (k<0) k+=1024;
  327. obj->PCoarseDetune = k + (obj->PCoarseDetune/1024)*1024;
  328. }
  329. }},
  330. };
  331. #undef rChangeCb
  332. #undef rObject
  333. #define rObject ADnoteParameters
  334. #define rChangeCb obj->last_update_timestamp = obj->time->time();
  335. static const Ports adPorts = {//XXX 16 should not be hard coded
  336. rSelf(ADnoteParameters),
  337. rPaste,
  338. rArrayPaste,
  339. rRecurs(VoicePar, NUM_VOICES),
  340. {"VoicePar#" STRINGIFY(NUM_VOICES) "/Enabled::T:F",
  341. rProp(parameter) rShort("enable") rDoc("Voice Enable"),
  342. NULL, rArrayTCbMember(VoicePar, Enabled)},
  343. rRecur(GlobalPar, "Adnote Parameters"),
  344. };
  345. #undef rChangeCb
  346. const Ports &ADnoteParameters::ports = adPorts;
  347. const Ports &ADnoteVoiceParam::ports = voicePorts;
  348. const Ports &ADnoteGlobalParam::ports = globalPorts;
  349. ADnoteParameters::ADnoteParameters(const SYNTH_T &synth, FFTwrapper *fft_,
  350. const AbsTime *time_)
  351. :PresetsArray(), GlobalPar(time_), time(time_), last_update_timestamp(0)
  352. {
  353. setpresettype("Padsynth");
  354. fft = fft_;
  355. for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice) {
  356. VoicePar[nvoice].GlobalPDetuneType = &GlobalPar.PDetuneType;
  357. VoicePar[nvoice].time = time_;
  358. EnableVoice(synth, nvoice, time_);
  359. }
  360. defaults();
  361. }
  362. ADnoteGlobalParam::ADnoteGlobalParam(const AbsTime *time_) :
  363. time(time_), last_update_timestamp(0)
  364. {
  365. FreqEnvelope = new EnvelopeParams(0, 0, time_);
  366. FreqEnvelope->init(EnvelopeParams::ad_global_freq_env);
  367. FreqLfo = new LFOParams(70, 0, 64, 0, 0, 0, 0, 0, time_);
  368. AmpEnvelope = new EnvelopeParams(64, 1, time_);
  369. AmpEnvelope->init(EnvelopeParams::ad_global_amp_env);
  370. AmpLfo = new LFOParams(80, 0, 64, 0, 0, 0, 0, 1, time_);
  371. GlobalFilter = new FilterParams(2, 94, 40, time_);
  372. FilterEnvelope = new EnvelopeParams(0, 1, time_);
  373. FilterEnvelope->init(EnvelopeParams::ad_global_filter_env);
  374. FilterLfo = new LFOParams(80, 0, 64, 0, 0, 0, 0, 2, time_);
  375. Reson = new Resonance();
  376. }
  377. void ADnoteParameters::defaults()
  378. {
  379. //Default Parameters
  380. GlobalPar.defaults();
  381. for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice)
  382. defaults(nvoice);
  383. VoicePar[0].Enabled = 1;
  384. }
  385. void ADnoteGlobalParam::defaults()
  386. {
  387. /* Frequency Global Parameters */
  388. PStereo = 1; //stereo
  389. PDetune = 8192; //zero
  390. PCoarseDetune = 0;
  391. PDetuneType = 1;
  392. FreqEnvelope->defaults();
  393. FreqLfo->defaults();
  394. PBandwidth = 64;
  395. /* Amplitude Global Parameters */
  396. PVolume = 90;
  397. PPanning = 64; //center
  398. PAmpVelocityScaleFunction = 64;
  399. AmpEnvelope->defaults();
  400. AmpLfo->defaults();
  401. Fadein_adjustment = FADEIN_ADJUSTMENT_SCALE;
  402. PPunchStrength = 0;
  403. PPunchTime = 60;
  404. PPunchStretch = 64;
  405. PPunchVelocitySensing = 72;
  406. Hrandgrouping = 0;
  407. /* Filter Global Parameters*/
  408. PFilterVelocityScale = 64;
  409. PFilterVelocityScaleFunction = 64;
  410. GlobalFilter->defaults();
  411. FilterEnvelope->defaults();
  412. FilterLfo->defaults();
  413. Reson->defaults();
  414. }
  415. /*
  416. * Defaults a voice
  417. */
  418. void ADnoteParameters::defaults(int n)
  419. {
  420. VoicePar[n].defaults();
  421. }
  422. void ADnoteVoiceParam::defaults()
  423. {
  424. Enabled = 0;
  425. Unison_size = 1;
  426. Unison_frequency_spread = 60;
  427. Unison_stereo_spread = 64;
  428. Unison_vibratto = 64;
  429. Unison_vibratto_speed = 64;
  430. Unison_invert_phase = 0;
  431. Unison_phase_randomness = 127;
  432. Type = 0;
  433. Pfixedfreq = 0;
  434. PfixedfreqET = 0;
  435. PBendAdjust = 88; // 64 + 24
  436. POffsetHz = 64;
  437. Presonance = 1;
  438. Pfilterbypass = 0;
  439. Pextoscil = -1;
  440. PextFMoscil = -1;
  441. Poscilphase = 64;
  442. PFMoscilphase = 64;
  443. PDelay = 0;
  444. PVolume = 100;
  445. PVolumeminus = 0;
  446. PPanning = 64; //center
  447. PDetune = 8192; //8192=0
  448. PCoarseDetune = 0;
  449. PDetuneType = 0;
  450. PFreqLfoEnabled = 0;
  451. PFreqEnvelopeEnabled = 0;
  452. PAmpEnvelopeEnabled = 0;
  453. PAmpLfoEnabled = 0;
  454. PAmpVelocityScaleFunction = 127;
  455. PFilterEnabled = 0;
  456. PFilterEnvelopeEnabled = 0;
  457. PFilterLfoEnabled = 0;
  458. PFilterVelocityScale = 0;
  459. PFilterVelocityScaleFunction = 64;
  460. PFMEnabled = 0;
  461. PFMFixedFreq = false;
  462. //I use the internal oscillator (-1)
  463. PFMVoice = -1;
  464. PFMVolume = 90;
  465. PFMVolumeDamp = 64;
  466. PFMDetune = 8192;
  467. PFMCoarseDetune = 0;
  468. PFMDetuneType = 0;
  469. PFMFreqEnvelopeEnabled = 0;
  470. PFMAmpEnvelopeEnabled = 0;
  471. PFMVelocityScaleFunction = 64;
  472. OscilSmp->defaults();
  473. FMSmp->defaults();
  474. AmpEnvelope->defaults();
  475. AmpLfo->defaults();
  476. FreqEnvelope->defaults();
  477. FreqLfo->defaults();
  478. VoiceFilter->defaults();
  479. FilterEnvelope->defaults();
  480. FilterLfo->defaults();
  481. FMFreqEnvelope->defaults();
  482. FMAmpEnvelope->defaults();
  483. }
  484. /*
  485. * Init the voice parameters
  486. */
  487. void ADnoteParameters::EnableVoice(const SYNTH_T &synth, int nvoice,
  488. const AbsTime *time)
  489. {
  490. VoicePar[nvoice].enable(synth, fft, GlobalPar.Reson, time);
  491. }
  492. void ADnoteVoiceParam::enable(const SYNTH_T &synth, FFTwrapper *fft,
  493. Resonance *Reson, const AbsTime *time)
  494. {
  495. OscilSmp = new OscilGen(synth, fft, Reson);
  496. FMSmp = new OscilGen(synth, fft, NULL);
  497. AmpEnvelope = new EnvelopeParams(64, 1, time);
  498. AmpEnvelope->init(EnvelopeParams::ad_voice_amp_env);
  499. AmpLfo = new LFOParams(90, 32, 64, 0, 0, 30, 0, 1, time);
  500. FreqEnvelope = new EnvelopeParams(0, 0, time);
  501. FreqEnvelope->init(EnvelopeParams::ad_voice_freq_env);
  502. FreqLfo = new LFOParams(50, 40, 0, 0, 0, 0, 0, 0, time);
  503. VoiceFilter = new FilterParams(2, 50, 60, time);
  504. FilterEnvelope = new EnvelopeParams(0, 0, time);
  505. FilterEnvelope->init(EnvelopeParams::ad_voice_filter_env);
  506. FilterLfo = new LFOParams(50, 20, 64, 0, 0, 0, 0, 2, time);
  507. FMFreqEnvelope = new EnvelopeParams(0, 0, time);
  508. FMFreqEnvelope->init(EnvelopeParams::ad_voice_fm_freq_env);
  509. FMAmpEnvelope = new EnvelopeParams(64, 1, time);
  510. FMAmpEnvelope->init(EnvelopeParams::ad_voice_fm_amp_env);
  511. }
  512. /*
  513. * Get the Multiplier of the fine detunes of the voices
  514. */
  515. float ADnoteParameters::getBandwidthDetuneMultiplier() const
  516. {
  517. float bw = (GlobalPar.PBandwidth - 64.0f) / 64.0f;
  518. bw = powf(2.0f, bw * powf(fabs(bw), 0.2f) * 5.0f);
  519. return bw;
  520. }
  521. /*
  522. * Get the unison spread in cents for a voice
  523. */
  524. float ADnoteParameters::getUnisonFrequencySpreadCents(int nvoice) const
  525. {
  526. return VoicePar[nvoice].getUnisonFrequencySpreadCents();
  527. }
  528. float ADnoteVoiceParam::getUnisonFrequencySpreadCents(void) const {
  529. return powf(Unison_frequency_spread / 127.0 * 2.0f, 2.0f) * 50.0f; //cents
  530. }
  531. /*
  532. * Kill the voice
  533. */
  534. void ADnoteParameters::KillVoice(int nvoice)
  535. {
  536. VoicePar[nvoice].kill();
  537. }
  538. void ADnoteVoiceParam::kill()
  539. {
  540. delete OscilSmp;
  541. delete FMSmp;
  542. delete AmpEnvelope;
  543. delete AmpLfo;
  544. delete FreqEnvelope;
  545. delete FreqLfo;
  546. delete VoiceFilter;
  547. delete FilterEnvelope;
  548. delete FilterLfo;
  549. delete FMFreqEnvelope;
  550. delete FMAmpEnvelope;
  551. }
  552. ADnoteGlobalParam::~ADnoteGlobalParam()
  553. {
  554. delete FreqEnvelope;
  555. delete FreqLfo;
  556. delete AmpEnvelope;
  557. delete AmpLfo;
  558. delete GlobalFilter;
  559. delete FilterEnvelope;
  560. delete FilterLfo;
  561. delete Reson;
  562. }
  563. ADnoteParameters::~ADnoteParameters()
  564. {
  565. for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice)
  566. KillVoice(nvoice);
  567. }
  568. void ADnoteParameters::add2XMLsection(XMLwrapper& xml, int n)
  569. {
  570. int nvoice = n;
  571. if(nvoice >= NUM_VOICES)
  572. return;
  573. int oscilused = 0, fmoscilused = 0; //if the oscil or fmoscil are used by another voice
  574. for(int i = 0; i < NUM_VOICES; ++i) {
  575. if(VoicePar[i].Pextoscil == nvoice)
  576. oscilused = 1;
  577. if(VoicePar[i].PextFMoscil == nvoice)
  578. fmoscilused = 1;
  579. }
  580. xml.addparbool("enabled", VoicePar[nvoice].Enabled);
  581. if(((VoicePar[nvoice].Enabled == 0) && (oscilused == 0)
  582. && (fmoscilused == 0)) && (xml.minimal))
  583. return;
  584. VoicePar[nvoice].add2XML(xml, fmoscilused);
  585. }
  586. void ADnoteVoiceParam::add2XML(XMLwrapper& xml, bool fmoscilused)
  587. {
  588. xml.addpar("type", Type);
  589. xml.addpar("unison_size", Unison_size);
  590. xml.addpar("unison_frequency_spread",
  591. Unison_frequency_spread);
  592. xml.addpar("unison_stereo_spread", Unison_stereo_spread);
  593. xml.addpar("unison_vibratto", Unison_vibratto);
  594. xml.addpar("unison_vibratto_speed", Unison_vibratto_speed);
  595. xml.addpar("unison_invert_phase", Unison_invert_phase);
  596. xml.addpar("unison_phase_randomness", Unison_phase_randomness);
  597. xml.addpar("delay", PDelay);
  598. xml.addparbool("resonance", Presonance);
  599. xml.addpar("ext_oscil", Pextoscil);
  600. xml.addpar("ext_fm_oscil", PextFMoscil);
  601. xml.addpar("oscil_phase", Poscilphase);
  602. xml.addpar("oscil_fm_phase", PFMoscilphase);
  603. xml.addparbool("filter_enabled", PFilterEnabled);
  604. xml.addparbool("filter_bypass", Pfilterbypass);
  605. xml.addpar("fm_enabled", PFMEnabled);
  606. xml.beginbranch("OSCIL");
  607. OscilSmp->add2XML(xml);
  608. xml.endbranch();
  609. xml.beginbranch("AMPLITUDE_PARAMETERS");
  610. xml.addpar("panning", PPanning);
  611. xml.addpar("volume", PVolume);
  612. xml.addparbool("volume_minus", PVolumeminus);
  613. xml.addpar("velocity_sensing", PAmpVelocityScaleFunction);
  614. xml.addparbool("amp_envelope_enabled",
  615. PAmpEnvelopeEnabled);
  616. if((PAmpEnvelopeEnabled != 0) || (!xml.minimal)) {
  617. xml.beginbranch("AMPLITUDE_ENVELOPE");
  618. AmpEnvelope->add2XML(xml);
  619. xml.endbranch();
  620. }
  621. xml.addparbool("amp_lfo_enabled", PAmpLfoEnabled);
  622. if((PAmpLfoEnabled != 0) || (!xml.minimal)) {
  623. xml.beginbranch("AMPLITUDE_LFO");
  624. AmpLfo->add2XML(xml);
  625. xml.endbranch();
  626. }
  627. xml.endbranch();
  628. xml.beginbranch("FREQUENCY_PARAMETERS");
  629. xml.addparbool("fixed_freq", Pfixedfreq);
  630. xml.addpar("fixed_freq_et", PfixedfreqET);
  631. xml.addpar("bend_adjust", PBendAdjust);
  632. xml.addpar("offset_hz", POffsetHz);
  633. xml.addpar("detune", PDetune);
  634. xml.addpar("coarse_detune", PCoarseDetune);
  635. xml.addpar("detune_type", PDetuneType);
  636. xml.addparbool("freq_envelope_enabled",
  637. PFreqEnvelopeEnabled);
  638. if((PFreqEnvelopeEnabled != 0) || (!xml.minimal)) {
  639. xml.beginbranch("FREQUENCY_ENVELOPE");
  640. FreqEnvelope->add2XML(xml);
  641. xml.endbranch();
  642. }
  643. xml.addparbool("freq_lfo_enabled", PFreqLfoEnabled);
  644. if((PFreqLfoEnabled != 0) || (!xml.minimal)) {
  645. xml.beginbranch("FREQUENCY_LFO");
  646. FreqLfo->add2XML(xml);
  647. xml.endbranch();
  648. }
  649. xml.endbranch();
  650. if((PFilterEnabled != 0) || (!xml.minimal)) {
  651. xml.beginbranch("FILTER_PARAMETERS");
  652. xml.addpar("velocity_sensing_amplitude", PFilterVelocityScale);
  653. xml.addpar("velocity_sensing", PFilterVelocityScaleFunction);
  654. xml.beginbranch("FILTER");
  655. VoiceFilter->add2XML(xml);
  656. xml.endbranch();
  657. xml.addparbool("filter_envelope_enabled",
  658. PFilterEnvelopeEnabled);
  659. if((PFilterEnvelopeEnabled != 0) || (!xml.minimal)) {
  660. xml.beginbranch("FILTER_ENVELOPE");
  661. FilterEnvelope->add2XML(xml);
  662. xml.endbranch();
  663. }
  664. xml.addparbool("filter_lfo_enabled",
  665. PFilterLfoEnabled);
  666. if((PFilterLfoEnabled != 0) || (!xml.minimal)) {
  667. xml.beginbranch("FILTER_LFO");
  668. FilterLfo->add2XML(xml);
  669. xml.endbranch();
  670. }
  671. xml.endbranch();
  672. }
  673. if((PFMEnabled != 0) || (fmoscilused != 0)
  674. || (!xml.minimal)) {
  675. xml.beginbranch("FM_PARAMETERS");
  676. xml.addpar("input_voice", PFMVoice);
  677. xml.addpar("volume", PFMVolume);
  678. xml.addpar("volume_damp", PFMVolumeDamp);
  679. xml.addpar("velocity_sensing",
  680. PFMVelocityScaleFunction);
  681. xml.addparbool("amp_envelope_enabled",
  682. PFMAmpEnvelopeEnabled);
  683. if((PFMAmpEnvelopeEnabled != 0) || (!xml.minimal)) {
  684. xml.beginbranch("AMPLITUDE_ENVELOPE");
  685. FMAmpEnvelope->add2XML(xml);
  686. xml.endbranch();
  687. }
  688. xml.beginbranch("MODULATOR");
  689. xml.addpar("detune", PFMDetune);
  690. xml.addpar("coarse_detune", PFMCoarseDetune);
  691. xml.addpar("detune_type", PFMDetuneType);
  692. xml.addparbool("freq_envelope_enabled",
  693. PFMFreqEnvelopeEnabled);
  694. xml.addparbool("fixed_freq", PFMFixedFreq);
  695. if((PFMFreqEnvelopeEnabled != 0) || (!xml.minimal)) {
  696. xml.beginbranch("FREQUENCY_ENVELOPE");
  697. FMFreqEnvelope->add2XML(xml);
  698. xml.endbranch();
  699. }
  700. xml.beginbranch("OSCIL");
  701. FMSmp->add2XML(xml);
  702. xml.endbranch();
  703. xml.endbranch();
  704. xml.endbranch();
  705. }
  706. }
  707. void ADnoteGlobalParam::add2XML(XMLwrapper& xml)
  708. {
  709. xml.addparbool("stereo", PStereo);
  710. xml.beginbranch("AMPLITUDE_PARAMETERS");
  711. xml.addpar("volume", PVolume);
  712. xml.addpar("panning", PPanning);
  713. xml.addpar("velocity_sensing", PAmpVelocityScaleFunction);
  714. xml.addpar("fadein_adjustment", Fadein_adjustment);
  715. xml.addpar("punch_strength", PPunchStrength);
  716. xml.addpar("punch_time", PPunchTime);
  717. xml.addpar("punch_stretch", PPunchStretch);
  718. xml.addpar("punch_velocity_sensing", PPunchVelocitySensing);
  719. xml.addpar("harmonic_randomness_grouping", Hrandgrouping);
  720. xml.beginbranch("AMPLITUDE_ENVELOPE");
  721. AmpEnvelope->add2XML(xml);
  722. xml.endbranch();
  723. xml.beginbranch("AMPLITUDE_LFO");
  724. AmpLfo->add2XML(xml);
  725. xml.endbranch();
  726. xml.endbranch();
  727. xml.beginbranch("FREQUENCY_PARAMETERS");
  728. xml.addpar("detune", PDetune);
  729. xml.addpar("coarse_detune", PCoarseDetune);
  730. xml.addpar("detune_type", PDetuneType);
  731. xml.addpar("bandwidth", PBandwidth);
  732. xml.beginbranch("FREQUENCY_ENVELOPE");
  733. FreqEnvelope->add2XML(xml);
  734. xml.endbranch();
  735. xml.beginbranch("FREQUENCY_LFO");
  736. FreqLfo->add2XML(xml);
  737. xml.endbranch();
  738. xml.endbranch();
  739. xml.beginbranch("FILTER_PARAMETERS");
  740. xml.addpar("velocity_sensing_amplitude", PFilterVelocityScale);
  741. xml.addpar("velocity_sensing", PFilterVelocityScaleFunction);
  742. xml.beginbranch("FILTER");
  743. GlobalFilter->add2XML(xml);
  744. xml.endbranch();
  745. xml.beginbranch("FILTER_ENVELOPE");
  746. FilterEnvelope->add2XML(xml);
  747. xml.endbranch();
  748. xml.beginbranch("FILTER_LFO");
  749. FilterLfo->add2XML(xml);
  750. xml.endbranch();
  751. xml.endbranch();
  752. xml.beginbranch("RESONANCE");
  753. Reson->add2XML(xml);
  754. xml.endbranch();
  755. }
  756. void ADnoteParameters::add2XML(XMLwrapper& xml)
  757. {
  758. GlobalPar.add2XML(xml);
  759. for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice) {
  760. xml.beginbranch("VOICE", nvoice);
  761. add2XMLsection(xml, nvoice);
  762. xml.endbranch();
  763. }
  764. }
  765. void ADnoteGlobalParam::getfromXML(XMLwrapper& xml)
  766. {
  767. PStereo = xml.getparbool("stereo", PStereo);
  768. if(xml.enterbranch("AMPLITUDE_PARAMETERS")) {
  769. PVolume = xml.getpar127("volume", PVolume);
  770. PPanning = xml.getpar127("panning", PPanning);
  771. PAmpVelocityScaleFunction = xml.getpar127("velocity_sensing",
  772. PAmpVelocityScaleFunction);
  773. Fadein_adjustment = xml.getpar127("fadein_adjustment", Fadein_adjustment);
  774. PPunchStrength = xml.getpar127("punch_strength", PPunchStrength);
  775. PPunchTime = xml.getpar127("punch_time", PPunchTime);
  776. PPunchStretch = xml.getpar127("punch_stretch", PPunchStretch);
  777. PPunchVelocitySensing = xml.getpar127("punch_velocity_sensing",
  778. PPunchVelocitySensing);
  779. Hrandgrouping = xml.getpar127("harmonic_randomness_grouping",
  780. Hrandgrouping);
  781. if(xml.enterbranch("AMPLITUDE_ENVELOPE")) {
  782. AmpEnvelope->getfromXML(xml);
  783. xml.exitbranch();
  784. }
  785. if(xml.enterbranch("AMPLITUDE_LFO")) {
  786. AmpLfo->getfromXML(xml);
  787. xml.exitbranch();
  788. }
  789. xml.exitbranch();
  790. }
  791. if(xml.enterbranch("FREQUENCY_PARAMETERS")) {
  792. PDetune = xml.getpar("detune", PDetune, 0, 16383);
  793. PCoarseDetune = xml.getpar("coarse_detune", PCoarseDetune, 0, 16383);
  794. PDetuneType = xml.getpar127("detune_type", PDetuneType);
  795. PBandwidth = xml.getpar127("bandwidth", PBandwidth);
  796. xml.enterbranch("FREQUENCY_ENVELOPE");
  797. FreqEnvelope->getfromXML(xml);
  798. xml.exitbranch();
  799. xml.enterbranch("FREQUENCY_LFO");
  800. FreqLfo->getfromXML(xml);
  801. xml.exitbranch();
  802. xml.exitbranch();
  803. }
  804. if(xml.enterbranch("FILTER_PARAMETERS")) {
  805. PFilterVelocityScale = xml.getpar127("velocity_sensing_amplitude",
  806. PFilterVelocityScale);
  807. PFilterVelocityScaleFunction = xml.getpar127(
  808. "velocity_sensing",
  809. PFilterVelocityScaleFunction);
  810. xml.enterbranch("FILTER");
  811. GlobalFilter->getfromXML(xml);
  812. xml.exitbranch();
  813. xml.enterbranch("FILTER_ENVELOPE");
  814. FilterEnvelope->getfromXML(xml);
  815. xml.exitbranch();
  816. xml.enterbranch("FILTER_LFO");
  817. FilterLfo->getfromXML(xml);
  818. xml.exitbranch();
  819. xml.exitbranch();
  820. }
  821. if(xml.enterbranch("RESONANCE")) {
  822. Reson->getfromXML(xml);
  823. xml.exitbranch();
  824. }
  825. }
  826. void ADnoteParameters::getfromXML(XMLwrapper& xml)
  827. {
  828. GlobalPar.getfromXML(xml);
  829. for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice) {
  830. VoicePar[nvoice].Enabled = 0;
  831. if(xml.enterbranch("VOICE", nvoice) == 0)
  832. continue;
  833. getfromXMLsection(xml, nvoice);
  834. xml.exitbranch();
  835. }
  836. }
  837. void ADnoteParameters::getfromXMLsection(XMLwrapper& xml, int n)
  838. {
  839. int nvoice = n;
  840. if(nvoice >= NUM_VOICES)
  841. return;
  842. VoicePar[nvoice].getfromXML(xml, nvoice);
  843. }
  844. void ADnoteParameters::paste(ADnoteParameters &a)
  845. {
  846. this->GlobalPar.paste(a.GlobalPar);
  847. for(int i=0; i<NUM_VOICES; ++i)
  848. this->VoicePar[i].paste(a.VoicePar[i]);
  849. if ( time ) {
  850. last_update_timestamp = time->time();
  851. }
  852. }
  853. void ADnoteParameters::pasteArray(ADnoteParameters &a, int nvoice)
  854. {
  855. if(nvoice >= NUM_VOICES)
  856. return;
  857. VoicePar[nvoice].paste(a.VoicePar[nvoice]);
  858. if ( time ) {
  859. last_update_timestamp = time->time();
  860. }
  861. }
  862. #define copy(x) this->x = a.x
  863. #define RCopy(x) this->x->paste(*a.x)
  864. void ADnoteVoiceParam::paste(ADnoteVoiceParam &a)
  865. {
  866. //Come on C++ get some darn reflection, this is horrible
  867. copy(Enabled);
  868. copy(Unison_size);
  869. copy(Unison_frequency_spread);
  870. copy(Unison_stereo_spread);
  871. copy(Unison_vibratto);
  872. copy(Unison_vibratto_speed);
  873. copy(Unison_invert_phase);
  874. copy(Unison_phase_randomness);
  875. copy(Type);
  876. copy(PDelay);
  877. copy(Presonance);
  878. copy(Pextoscil);
  879. copy(PextFMoscil);
  880. copy(Poscilphase);
  881. copy(PFMoscilphase);
  882. copy(PFilterEnabled);
  883. copy(Pfilterbypass);
  884. copy(PFMEnabled);
  885. copy(PFMFixedFreq);
  886. RCopy(OscilSmp);
  887. copy(PPanning);
  888. copy(PVolume);
  889. copy(PVolumeminus);
  890. copy(PAmpVelocityScaleFunction);
  891. copy(PAmpEnvelopeEnabled);
  892. RCopy(AmpEnvelope);
  893. copy(PAmpLfoEnabled);
  894. RCopy(AmpLfo);
  895. copy(Pfixedfreq);
  896. copy(PfixedfreqET);
  897. copy(PDetune);
  898. copy(PCoarseDetune);
  899. copy(PDetuneType);
  900. copy(PBendAdjust);
  901. copy(POffsetHz);
  902. copy(PFreqEnvelopeEnabled);
  903. RCopy(FreqEnvelope);
  904. copy(PFreqLfoEnabled);
  905. RCopy(FreqLfo);
  906. RCopy(VoiceFilter);
  907. copy(PFilterEnvelopeEnabled);
  908. RCopy(FilterEnvelope);
  909. copy(PFilterLfoEnabled);
  910. copy(PFilterVelocityScale);
  911. copy(PFilterVelocityScaleFunction);
  912. RCopy(FilterLfo);
  913. copy(PFMVoice);
  914. copy(PFMVolume);
  915. copy(PFMVolumeDamp);
  916. copy(PFMVelocityScaleFunction);
  917. copy(PFMAmpEnvelopeEnabled);
  918. RCopy(FMAmpEnvelope);
  919. copy(PFMDetune);
  920. copy(PFMCoarseDetune);
  921. copy(PFMDetuneType);
  922. copy(PFMFreqEnvelopeEnabled);
  923. RCopy(FMFreqEnvelope);
  924. RCopy(FMSmp);
  925. if ( time ) {
  926. last_update_timestamp = time->time();
  927. }
  928. }
  929. void ADnoteGlobalParam::paste(ADnoteGlobalParam &a)
  930. {
  931. copy(PStereo);
  932. copy(PVolume);
  933. copy(PPanning);
  934. copy(PAmpVelocityScaleFunction);
  935. copy(Fadein_adjustment);
  936. copy(PPunchStrength);
  937. copy(PPunchTime);
  938. copy(PPunchStretch);
  939. copy(PPunchVelocitySensing);
  940. copy(Hrandgrouping);
  941. RCopy(AmpEnvelope);
  942. RCopy(AmpLfo);
  943. copy(PDetune);
  944. copy(PCoarseDetune);
  945. copy(PDetuneType);
  946. copy(PBandwidth);
  947. RCopy(FreqEnvelope);
  948. RCopy(FreqLfo);
  949. copy(PFilterVelocityScale);
  950. copy(PFilterVelocityScaleFunction);
  951. RCopy(GlobalFilter);
  952. RCopy(FilterEnvelope);
  953. RCopy(FilterLfo);
  954. RCopy(Reson);
  955. if ( time ) {
  956. last_update_timestamp = time->time();
  957. }
  958. }
  959. #undef copy
  960. #undef RCopy
  961. void ADnoteVoiceParam::getfromXML(XMLwrapper& xml, unsigned nvoice)
  962. {
  963. Enabled = xml.getparbool("enabled", 0);
  964. Unison_size = xml.getpar127("unison_size", Unison_size);
  965. Unison_frequency_spread = xml.getpar127("unison_frequency_spread",
  966. Unison_frequency_spread);
  967. Unison_stereo_spread = xml.getpar127("unison_stereo_spread",
  968. Unison_stereo_spread);
  969. Unison_vibratto = xml.getpar127("unison_vibratto", Unison_vibratto);
  970. Unison_vibratto_speed = xml.getpar127("unison_vibratto_speed",
  971. Unison_vibratto_speed);
  972. Unison_invert_phase = xml.getpar127("unison_invert_phase",
  973. Unison_invert_phase);
  974. Unison_phase_randomness = xml.getpar127("unison_phase_randomness",
  975. Unison_phase_randomness);
  976. Type = xml.getpar127("type", Type);
  977. PDelay = xml.getpar127("delay", PDelay);
  978. Presonance = xml.getparbool("resonance", Presonance);
  979. Pextoscil = xml.getpar("ext_oscil", -1, -1, nvoice - 1);
  980. PextFMoscil = xml.getpar("ext_fm_oscil", -1, -1, nvoice - 1);
  981. Poscilphase = xml.getpar127("oscil_phase", Poscilphase);
  982. PFMoscilphase = xml.getpar127("oscil_fm_phase", PFMoscilphase);
  983. PFilterEnabled = xml.getparbool("filter_enabled", PFilterEnabled);
  984. Pfilterbypass = xml.getparbool("filter_bypass", Pfilterbypass);
  985. PFMEnabled = xml.getpar127("fm_enabled", PFMEnabled);
  986. if(xml.enterbranch("OSCIL")) {
  987. OscilSmp->getfromXML(xml);
  988. xml.exitbranch();
  989. }
  990. if(xml.enterbranch("AMPLITUDE_PARAMETERS")) {
  991. PPanning = xml.getpar127("panning", PPanning);
  992. PVolume = xml.getpar127("volume", PVolume);
  993. PVolumeminus = xml.getparbool("volume_minus", PVolumeminus);
  994. PAmpVelocityScaleFunction = xml.getpar127("velocity_sensing",
  995. PAmpVelocityScaleFunction);
  996. PAmpEnvelopeEnabled = xml.getparbool("amp_envelope_enabled",
  997. PAmpEnvelopeEnabled);
  998. if(xml.enterbranch("AMPLITUDE_ENVELOPE")) {
  999. AmpEnvelope->getfromXML(xml);
  1000. xml.exitbranch();
  1001. }
  1002. PAmpLfoEnabled = xml.getparbool("amp_lfo_enabled", PAmpLfoEnabled);
  1003. if(xml.enterbranch("AMPLITUDE_LFO")) {
  1004. AmpLfo->getfromXML(xml);
  1005. xml.exitbranch();
  1006. }
  1007. xml.exitbranch();
  1008. }
  1009. if(xml.enterbranch("FREQUENCY_PARAMETERS")) {
  1010. Pfixedfreq = xml.getparbool("fixed_freq", Pfixedfreq);
  1011. PfixedfreqET = xml.getpar127("fixed_freq_et", PfixedfreqET);
  1012. PBendAdjust = xml.getpar127("bend_adjust", PBendAdjust);
  1013. POffsetHz = xml.getpar127("offset_hz", POffsetHz);
  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. PFreqEnvelopeEnabled = xml.getparbool("freq_envelope_enabled",
  1018. PFreqEnvelopeEnabled);
  1019. if(xml.enterbranch("FREQUENCY_ENVELOPE")) {
  1020. FreqEnvelope->getfromXML(xml);
  1021. xml.exitbranch();
  1022. }
  1023. PFreqLfoEnabled = xml.getparbool("freq_lfo_enabled", PFreqLfoEnabled);
  1024. if(xml.enterbranch("FREQUENCY_LFO")) {
  1025. FreqLfo->getfromXML(xml);
  1026. xml.exitbranch();
  1027. }
  1028. xml.exitbranch();
  1029. }
  1030. if(xml.enterbranch("FILTER_PARAMETERS")) {
  1031. PFilterVelocityScale = xml.getpar127("velocity_sensing_amplitude",
  1032. PFilterVelocityScale);
  1033. PFilterVelocityScaleFunction = xml.getpar127(
  1034. "velocity_sensing",
  1035. PFilterVelocityScaleFunction);
  1036. if(xml.enterbranch("FILTER")) {
  1037. VoiceFilter->getfromXML(xml);
  1038. xml.exitbranch();
  1039. }
  1040. PFilterEnvelopeEnabled = xml.getparbool("filter_envelope_enabled",
  1041. PFilterEnvelopeEnabled);
  1042. if(xml.enterbranch("FILTER_ENVELOPE")) {
  1043. FilterEnvelope->getfromXML(xml);
  1044. xml.exitbranch();
  1045. }
  1046. PFilterLfoEnabled = xml.getparbool("filter_lfo_enabled",
  1047. PFilterLfoEnabled);
  1048. if(xml.enterbranch("FILTER_LFO")) {
  1049. FilterLfo->getfromXML(xml);
  1050. xml.exitbranch();
  1051. }
  1052. xml.exitbranch();
  1053. }
  1054. if(xml.enterbranch("FM_PARAMETERS")) {
  1055. PFMVoice = xml.getpar("input_voice", PFMVoice, -1, nvoice - 1);
  1056. PFMVolume = xml.getpar127("volume", PFMVolume);
  1057. PFMVolumeDamp = xml.getpar127("volume_damp", PFMVolumeDamp);
  1058. PFMVelocityScaleFunction = xml.getpar127("velocity_sensing",
  1059. PFMVelocityScaleFunction);
  1060. PFMAmpEnvelopeEnabled = xml.getparbool("amp_envelope_enabled",
  1061. PFMAmpEnvelopeEnabled);
  1062. if(xml.enterbranch("AMPLITUDE_ENVELOPE")) {
  1063. FMAmpEnvelope->getfromXML(xml);
  1064. xml.exitbranch();
  1065. }
  1066. if(xml.enterbranch("MODULATOR")) {
  1067. PFMDetune = xml.getpar("detune", PFMDetune, 0, 16383);
  1068. PFMCoarseDetune = xml.getpar("coarse_detune",
  1069. PFMCoarseDetune,
  1070. 0,
  1071. 16383);
  1072. PFMDetuneType = xml.getpar127("detune_type", PFMDetuneType);
  1073. PFMFreqEnvelopeEnabled = xml.getparbool("freq_envelope_enabled",
  1074. PFMFreqEnvelopeEnabled);
  1075. PFMFixedFreq = xml.getparbool("fixed_freq",
  1076. PFMFixedFreq);
  1077. if(xml.enterbranch("FREQUENCY_ENVELOPE")) {
  1078. FMFreqEnvelope->getfromXML(xml);
  1079. xml.exitbranch();
  1080. }
  1081. if(xml.enterbranch("OSCIL")) {
  1082. FMSmp->getfromXML(xml);
  1083. xml.exitbranch();
  1084. }
  1085. xml.exitbranch();
  1086. }
  1087. xml.exitbranch();
  1088. }
  1089. }
  1090. }