*/}}

la_audio.c 76 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483
  1. /*
  2. * Tiny la: A light weight game engine.
  3. * Copyright (C) 2023 Wu Yiming
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #define MINIAUDIO_IMPLEMENTATION
  19. #include "miniaudio.h"
  20. #include "la_5.h"
  21. extern LA MAIN;
  22. laPropContainer* LA_PC_SYNTH;
  23. laPropContainer* LA_PC_CHANNEL;
  24. laNodeCategory* LA_NODE_CATEGORY_SYNTHESIZER;
  25. laNodeCategory* LA_NODE_CATEGORY_SYSTEM_SOUND;
  26. laBaseNodeType LA_IDN_INPUT;
  27. laBaseNodeType LA_IDN_PULSE;
  28. laBaseNodeType LA_IDN_FM;
  29. laBaseNodeType LA_IDN_VCA;
  30. laBaseNodeType LA_IDN_NOISE;
  31. laBaseNodeType LA_IDN_OUTPUT;
  32. laBaseNodeType LA_IDN_SCOPE;
  33. laBaseNodeType LA_IDN_ENVELOPE;
  34. laBaseNodeType LA_IDN_QUANTIZE;
  35. laBaseNodeType LA_IDN_SYNTH_DRIVER;
  36. laBaseNodeType LA_IDN_SYNTH_TRIGGER;
  37. laPropContainer* LA_PC_IDN_INPUT;
  38. laPropContainer* LA_PC_IDN_PULSE;
  39. laPropContainer* LA_PC_IDN_FM;
  40. laPropContainer* LA_PC_IDN_VCA;
  41. laPropContainer* LA_PC_IDN_NOISE;
  42. laPropContainer* LA_PC_IDN_OUTPUT;
  43. laPropContainer* LA_PC_IDN_SCOPE;
  44. laPropContainer* LA_PC_IDN_ENVELOPE;
  45. laPropContainer* LA_PC_IDN_QUANTIZE;
  46. laPropContainer* LA_PC_IDN_SYNTH_DRIVER;
  47. laPropContainer* LA_PC_IDN_SYNTH_TRIGGER;
  48. #define _2PI 6.283185307
  49. #define VAL2FREQ(val) \
  50. 16.0f*pow(2,val) // 0-10, 16-16384Hz
  51. #define VAL13 -0.218640286
  52. #define VAL27 0.78135971352
  53. #define VAL440 4.78135971352 // 2^FREQC*16=440
  54. #define VALHALF (1.0f/12.0f)
  55. #define WRAPPHASE(p) \
  56. while(p>_2PI){ p-=_2PI; }
  57. #define INITPACKET(arr) \
  58. if(!arr){ arr=memAcquireSimple(sizeof(real)*LA_SYNTH_PLEN); }
  59. #define INPUTPACKET(ptr,socket) \
  60. {if(socket->Source && socket->Source->DataType==(LA_PROP_FLOAT|LA_PROP_ARRAY) && socket->Source->ArrLen>=LA_SYNTH_PLEN){ \
  61. ptr=((real*)socket->Source->Data); }else{ ptr=0; } }
  62. #define FRAME_INTERVAL (MAIN.Audio->AudioFrameInterval)
  63. #define SAMPLE_RATE (MAIN.Audio->AudioSampleRate)
  64. void IDN_InputInit(laSynthNodeInput* n, int NoCreate){
  65. INITPACKET(n->rTime); INITPACKET(n->rTrigger); //INITPACKET(n->rSamplesL); INITPACKET(n->rSamplesR);
  66. if(NoCreate){
  67. if(!n->OutL) n->OutL=laCreateOutSocket(n,"L",LA_PROP_FLOAT|LA_PROP_ARRAY);
  68. if(!n->OutR) n->OutR=laCreateOutSocket(n,"R",LA_PROP_FLOAT|LA_PROP_ARRAY);
  69. return;
  70. }
  71. n->OutTime=laCreateOutSocket(n,"TIME",LA_PROP_FLOAT|LA_PROP_ARRAY);
  72. n->OutTrigger=laCreateOutSocket(n,"TRIGGER",LA_PROP_FLOAT|LA_PROP_ARRAY);
  73. strSafeSet(&n->Base.Name,"Input");
  74. }
  75. void IDN_InputDestroy(laSynthNodeInput* n){
  76. laDestroyOutSocket(n->OutTime); laDestroyOutSocket(n->OutTrigger);
  77. laDestroyOutSocket(n->OutL); laDestroyOutSocket(n->OutR); strSafeDestroy(&n->Base.Name);
  78. memFree(n->rTime); memFree(n->rTrigger); memFree(n->rSamplesL); memFree(n->rSamplesL);
  79. }
  80. int IDN_InputVisit(laSynthNodeInput* n, laNodeVisitInfo* vi){
  81. LA_GUARD_THIS_NODE(n,vi);
  82. LA_ADD_THIS_NODE(n,vi);
  83. return LA_DAG_FLAG_PERM;
  84. }
  85. int IDN_InputEval(laSynthNodeInput* n){
  86. laSynth*ss=MAIN.Audio->AudioEvalSynth;
  87. real time=ss->EvalTime,target_time=time+(real)LA_SYNTH_PLEN/(real)MAIN.Audio->AudioSampleRate;
  88. for(int i=0;i<LA_SYNTH_PLEN;i++){
  89. real fac=(real)i/(real)LA_SYNTH_PLEN;
  90. n->rTime[i] = tnsLinearItp(time,target_time,fac);
  91. }
  92. if(ss->EvalSamples==0){ n->rTrigger[0] = 10; }else{ n->rTrigger[0]=0; }
  93. n->OutTime->Data=n->rTime; n->OutTrigger->Data=n->rTrigger; n->OutTime->ArrLen=LA_SYNTH_PLEN; n->OutTrigger->ArrLen=LA_SYNTH_PLEN;
  94. n->OutL->Data=MAIN.Audio->InputSamplesL; n->OutR->Data=MAIN.Audio->InputSamplesR; n->OutL->ArrLen=LA_SYNTH_PLEN; n->OutR->ArrLen=LA_SYNTH_PLEN;
  95. return 1;
  96. }
  97. void IDN_InputCopy(laSynthNodeInput* new, laSynthNodeInput* old, int DoRematch){
  98. if(DoRematch){ return; }
  99. LA_IDN_OLD_DUPL(OutTime); LA_IDN_OLD_DUPL(OutTrigger);
  100. }
  101. void laui_InputNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  102. laColumn* c=laFirstColumn(uil); laSynthNodeInput*n=This->EndInstance;
  103. LA_BASE_NODE_HEADER(uil,c,This);
  104. laUiItem* b=laBeginRow(uil,c,0,0);
  105. laUiItem* ui=laShowLabel(uil,c,"Capture",0,0); ui->Expand=1; ui->Flags|=LA_TEXT_ALIGN_RIGHT;
  106. laShowNodeSocket(uil,c,This,"out_l",0)->Flags|=LA_UI_SOCKET_LABEL_E;
  107. laShowNodeSocket(uil,c,This,"out_r",0)->Flags|=LA_UI_SOCKET_LABEL_E;
  108. laEndRow(uil,b);
  109. b=laBeginRow(uil,c,0,0);
  110. ui=laShowLabel(uil,c,"Synth",0,0); ui->Expand=1; ui->Flags|=LA_TEXT_ALIGN_RIGHT;
  111. laShowNodeSocket(uil,c,This,"out_time",0)->Flags|=LA_UI_SOCKET_LABEL_E;
  112. laShowNodeSocket(uil,c,This,"out_trigger",0)->Flags|=LA_UI_SOCKET_LABEL_E;
  113. laEndRow(uil,b);
  114. }
  115. void IDN_PulseInit(laSynthNodePulse* n, int NoCreate){
  116. INITPACKET(n->rOut);
  117. if(NoCreate){ return; }
  118. n->InTrigger = laCreateInSocket("TRIGGER",0);
  119. n->InWidth = laCreateInSocket("WIDTH",0);
  120. n->InGate = laCreateInSocket("GATE",0);
  121. n->Out=laCreateOutSocket(n,"OUT",LA_PROP_FLOAT|LA_PROP_ARRAY);
  122. strSafeSet(&n->Base.Name,"Pulse");
  123. }
  124. void IDN_PulseDestroy(laSynthNodePulse* n){
  125. laDestroyOutSocket(n->Out); laDestroyInSocket(n->InWidth); laDestroyInSocket(n->InTrigger); laDestroyInSocket(n->InGate);
  126. strSafeDestroy(&n->Base.Name); memFree(n->rOut);
  127. }
  128. int IDN_PulseVisit(laSynthNodePulse* n, laNodeVisitInfo* vi){
  129. LA_GUARD_THIS_NODE(n,vi);
  130. if(LA_SRC_AND_PARENT(n->InTrigger)){ laBaseNode*bn=n->InTrigger->Source->Parent; LA_VISIT_NODE(bn,vi); }
  131. if(LA_SRC_AND_PARENT(n->InWidth)){ laBaseNode*bn=n->InWidth->Source->Parent; LA_VISIT_NODE(bn,vi); }
  132. if(LA_SRC_AND_PARENT(n->InGate)){ laBaseNode*bn=n->InGate->Source->Parent; LA_VISIT_NODE(bn,vi); }
  133. n->Out->Data = n->rOut; n->Out->ArrLen=LA_SYNTH_PLEN;
  134. LA_ADD_THIS_NODE(n,vi);
  135. return LA_DAG_FLAG_PERM;
  136. }
  137. int IDN_PulseEval(laSynthNodePulse* n){
  138. laSynth*ss=MAIN.Audio->AudioEvalSynth;
  139. real* trigger=0; real trig=n->iTrigger?100:-100; INPUTPACKET(trigger,n->InTrigger); LA_GET_SRC_AS_VALUE(trig,n->InTrigger);
  140. real* gate=0; real gt=n->rGate; INPUTPACKET(gate,n->InGate); LA_GET_SRC_AS_VALUE(gt,n->InGate);
  141. real* width=0; real w=n->rWidth; INPUTPACKET(width,n->InWidth);
  142. real wi=0; LA_GET_SRC_AS_VALUE(wi,n->InWidth); if(!width){ w=n->rWidth+wi*n->rInfluence; }
  143. for(int i=0;i<LA_SYNTH_PLEN;i++){
  144. if(trigger){ trig=trigger[i]; } if(gate){ gt=gate[i]; } if(width){ w=n->rWidth+width[i]*n->rInfluence; }
  145. if(!n->Triggered){ if(trig>gt){ n->Triggered=1; n->EvalSamples=1; } }
  146. else{ if(trig<=gt){ n->Triggered=0; } }
  147. int totalsamples=w*MAIN.Audio->AudioSampleRate;
  148. if(n->EvalSamples) n->EvalSamples++;
  149. n->rOut[i]= (n->Triggered || (n->EvalSamples > 0 && n->EvalSamples < totalsamples)) ? 10.0f : 0.0f;
  150. if(n->EvalSamples > totalsamples && !n->Triggered){ n->EvalSamples=0; }
  151. }
  152. return 1;
  153. }
  154. void IDN_PulseCopy(laSynthNodePulse* new, laSynthNodePulse* old, int DoRematch){
  155. if(DoRematch){ LA_IDN_NEW_LINK(InTrigger); LA_IDN_NEW_LINK(InWidth); LA_IDN_NEW_LINK(InGate); return; }
  156. LA_IDN_OLD_DUPL(Out); new->rGate = old->rGate; new->rInfluence=old->rInfluence; new->rWidth=old->rWidth;
  157. }
  158. void laui_PulseNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  159. laColumn* c=laFirstColumn(uil); laSynthNodePulse*n=This->EndInstance;
  160. LA_BASE_NODE_HEADER(uil,c,This);
  161. laUiItem* b;
  162. b=laBeginRow(uil,c,0,0);
  163. laShowNodeSocket(uil,c,This,"in_width",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  164. laShowItem(uil,c,This,"influence");
  165. laShowItem(uil,c,This,"width")->Expand=1;
  166. laEndRow(uil,b);
  167. b=laBeginRow(uil,c,0,0);
  168. laShowItem(uil,c,This,"gate")->Expand=1;
  169. laShowNodeSocket(uil,c,This,"in_gate",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  170. laShowNodeSocket(uil,c,This,"in_trigger",0)->Flags|=LA_UI_SOCKET_LABEL_E;
  171. laEndRow(uil,b);
  172. b=laBeginRow(uil,c,0,0);
  173. laShowSeparator(uil,c)->Expand=1;
  174. laShowItem(uil,c,This,"trigger")->Flags|=LA_UI_FLAGS_MOMENTARY|LA_UI_FLAGS_HIGHLIGHT;
  175. laShowItem(uil,c,This,"out")->Flags|=LA_UI_SOCKET_LABEL_W;
  176. laEndRow(uil,b);
  177. }
  178. void IDN_FMInit(laSynthNodeFM* n, int NoCreate){
  179. INITPACKET(n->OutSamples);
  180. if(NoCreate){ return; }
  181. n->InFrequency=laCreateInSocket("FREQ",0); n->Out=laCreateOutSocket(n,"OUT",LA_PROP_FLOAT|LA_PROP_ARRAY);
  182. strSafeSet(&n->Base.Name,"FM"); n->Frequency=4;
  183. }
  184. void IDN_FMDestroy(laSynthNodeFM* n){
  185. laDestroyInSocket(n->InFrequency); laDestroyOutSocket(n->Out); strSafeDestroy(&n->Base.Name); memFree(n->OutSamples);
  186. }
  187. int IDN_FMVisit(laSynthNodeFM* n, laNodeVisitInfo* vi){
  188. LA_GUARD_THIS_NODE(n,vi);
  189. if(LA_SRC_AND_PARENT(n->InFrequency)){ laBaseNode*bn=n->InFrequency->Source->Parent; LA_VISIT_NODE(bn,vi); }
  190. LA_ADD_THIS_NODE(n,vi);
  191. return LA_DAG_FLAG_PERM;
  192. }
  193. int IDN_FMEval(laSynthNodeFM* n){
  194. real f=n->Frequency, constf=0; real* inputf;
  195. INPUTPACKET(inputf,n->InFrequency); LA_GET_SRC_AS_VALUE(constf,n->InFrequency);
  196. for(int i=0;i<LA_SYNTH_PLEN;i++){
  197. real useF=inputf?(inputf[i]*n->rInfluence+f):(f+constf); if(n->Slow) useF-=10;
  198. n->Phase+=FRAME_INTERVAL*VAL2FREQ(useF)*_2PI;
  199. WRAPPHASE(n->Phase);
  200. n->OutSamples[i]=sin(n->Phase)*10;
  201. }
  202. n->Out->Data=n->OutSamples; n->Out->ArrLen=LA_SYNTH_PLEN;
  203. return 1;
  204. }
  205. void IDN_FMCopy(laSynthNodeFM* new, laSynthNodeFM* old, int DoRematch){
  206. if(DoRematch){ LA_IDN_NEW_LINK(InFrequency) return; }
  207. LA_IDN_OLD_DUPL(Out); new->Frequency=old->Frequency; new->Slow=old->Slow; new->rInfluence=old->rInfluence;
  208. }
  209. void laui_FMNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  210. laColumn* c=laFirstColumn(uil); laSynthNodeFM*n=This->EndInstance;
  211. LA_BASE_NODE_HEADER(uil,c,This);
  212. laUiItem* b=laBeginRow(uil,c,0,0);
  213. laShowItem(uil,c,This,"slow");
  214. laShowNodeSocket(uil,c,This,"in_frequency",0)->Flags|=LA_UI_SOCKET_LABEL_E;
  215. laShowItem(uil,c,This,"influence");
  216. laShowItem(uil,c,This,"frequency")->Expand=1;
  217. laShowNodeSocket(uil,c,This,"out",0);
  218. laEndRow(uil,b);
  219. }
  220. void IDN_VCAInit(laSynthNodeVCA* n, int NoCreate){
  221. INITPACKET(n->OutSamples);
  222. if(NoCreate){ return; }
  223. n->InAmp=laCreateInSocket("AMP",0); n->In=laCreateInSocket("IN",0);
  224. n->Out=laCreateOutSocket(n,"OUT",LA_PROP_FLOAT|LA_PROP_ARRAY);
  225. strSafeSet(&n->Base.Name,"FM"); n->Amp=10;
  226. }
  227. void IDN_VCADestroy(laSynthNodeVCA* n){
  228. laDestroyInSocket(n->InAmp); laDestroyInSocket(n->In);
  229. laDestroyOutSocket(n->Out); strSafeDestroy(&n->Base.Name); memFree(n->OutSamples);
  230. }
  231. int IDN_VCAVisit(laSynthNodeVCA* n, laNodeVisitInfo* vi){
  232. LA_GUARD_THIS_NODE(n,vi);
  233. if(LA_SRC_AND_PARENT(n->In)){ laBaseNode*bn=n->In->Source->Parent; LA_VISIT_NODE(bn,vi); }
  234. if(LA_SRC_AND_PARENT(n->InAmp)){ laBaseNode*bn=n->InAmp->Source->Parent; LA_VISIT_NODE(bn,vi); }
  235. LA_ADD_THIS_NODE(n,vi);
  236. return LA_DAG_FLAG_PERM;
  237. }
  238. int IDN_VCAEval(laSynthNodeVCA* n){
  239. real amp=n->Amp, constamp=amp; real* inputamp=0,*input=0;
  240. INPUTPACKET(input,n->In); INPUTPACKET(inputamp,n->InAmp);
  241. if(!inputamp) LA_GET_SRC_AS_VALUE(constamp,n->InAmp); constamp/=10;
  242. n->Out->Data=n->OutSamples; n->Out->ArrLen=LA_SYNTH_PLEN;
  243. if(!input){ memset(n->OutSamples,0,sizeof(real)*LA_SYNTH_PLEN); return 0; }
  244. for(int i=0;i<LA_SYNTH_PLEN;i++){
  245. real useA= inputamp?tnsInterpolate(1.0f,inputamp[i]/10.0f,n->rInfluence)*constamp:constamp;
  246. n->OutSamples[i]= input[i]*useA;
  247. }
  248. return 1;
  249. }
  250. void IDN_VCACopy(laSynthNodeVCA* new, laSynthNodeVCA* old, int DoRematch){
  251. if(DoRematch){ LA_IDN_NEW_LINK(InAmp) LA_IDN_NEW_LINK(In) return; }
  252. LA_IDN_OLD_DUPL(Out); new->Amp=old->Amp; new->rInfluence = old->rInfluence;
  253. }
  254. void laui_VCANode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  255. laColumn* c=laFirstColumn(uil); laSynthNodeVCA*n=This->EndInstance;
  256. LA_BASE_NODE_HEADER(uil,c,This);
  257. laColumn* cl,*cr; laSplitColumn(uil,c,0.3); cl=laLeftColumn(c,0); cr=laRightColumn(c,0);
  258. laUiItem* b=laBeginRow(uil,c,0,0);
  259. laShowNodeSocket(uil,c,This,"in",0)->Flags|=LA_UI_SOCKET_LABEL_E;
  260. laShowNodeSocket(uil,c,This,"in_amp",0);
  261. laShowItem(uil,c,This,"influence");
  262. laShowItem(uil,c,This,"amp")->Expand=1;
  263. laShowNodeSocket(uil,cr,This,"out",0);
  264. laEndRow(uil,b);
  265. }
  266. void IDN_NoiseInit(laSynthNodeNoise* n, int NoCreate){
  267. INITPACKET(n->OutWhiteSamples); INITPACKET(n->OutPinkSamples);
  268. n->PinkA[0]=0.02109238; n->PinkA[1]=0.07113478; n->PinkA[2]=0.68873558;
  269. n->PinkP[0]=0.3190; n->PinkP[1]=0.7756; n->PinkP[2]=0.9613;
  270. if(NoCreate){ return; }
  271. n->OutWhite=laCreateOutSocket(n,"WHITE",LA_PROP_FLOAT|LA_PROP_ARRAY);
  272. n->OutPink=laCreateOutSocket(n,"PINK",LA_PROP_FLOAT|LA_PROP_ARRAY);
  273. strSafeSet(&n->Base.Name,"Noise");
  274. }
  275. void IDN_NoiseDestroy(laSynthNodeNoise* n){
  276. laDestroyOutSocket(n->OutWhite); laDestroyOutSocket(n->OutPink); strSafeDestroy(&n->Base.Name);
  277. memFree(n->OutWhiteSamples); memFree(n->OutPinkSamples);
  278. }
  279. int IDN_NoiseVisit(laSynthNodeNoise* n, laNodeVisitInfo* vi){
  280. LA_GUARD_THIS_NODE(n,vi); LA_ADD_THIS_NODE(n,vi);
  281. return LA_DAG_FLAG_PERM;
  282. }
  283. int IDN_NoiseEval(laSynthNodeNoise* n){
  284. real RMI2 = 2.0 / (real)RAND_MAX; // + 1.0; // change for range [0,1)
  285. real offset = n->PinkA[0] + n->PinkA[1] + n->PinkA[2];
  286. for(int i=0;i<LA_SYNTH_PLEN;i++){
  287. real R1=(real)rand()/(real)RAND_MAX;
  288. real R2=(real)rand()/(real)RAND_MAX;
  289. real X=(real)sqrt(-2.0f*log(R1))*cos(2.0f*TNS_PI*R2);
  290. n->OutWhiteSamples[i]=X*2.5;
  291. real temp; for(int i=0;i<3;i++){ temp=(real)rand();
  292. n->PinkStates[i] = n->PinkP[i] * (n->PinkStates[i] - temp) + temp;
  293. }
  294. n->OutPinkSamples[i]=(n->PinkA[0]*n->PinkStates[0]+
  295. n->PinkA[1]*n->PinkStates[1]+
  296. n->PinkA[2]*n->PinkStates[2])*RMI2-offset;
  297. n->OutPinkSamples[i]*=40;
  298. }
  299. n->OutWhite->Data=n->OutWhiteSamples; n->OutWhite->ArrLen=LA_SYNTH_PLEN;
  300. n->OutPink->Data=n->OutPinkSamples; n->OutPink->ArrLen=LA_SYNTH_PLEN;
  301. return 1;
  302. }
  303. void IDN_NoiseCopy(laSynthNodeNoise* new, laSynthNodeNoise* old, int DoRematch){
  304. if(DoRematch){ return; }
  305. LA_IDN_OLD_DUPL(OutWhite);
  306. }
  307. void laui_NoiseNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  308. laColumn* c=laFirstColumn(uil); laSynthNodeNoise*n=This->EndInstance;
  309. LA_BASE_NODE_HEADER(uil,c,This);
  310. laUiItem* b=laBeginRow(uil,c,0,0);
  311. laShowNodeSocket(uil,c,This,"out_white",0)->Flags|=LA_UI_SOCKET_LABEL_N;
  312. laShowNodeSocket(uil,c,This,"out_pink",0)->Flags|=LA_UI_SOCKET_LABEL_N;
  313. laEndRow(uil,b);
  314. }
  315. void IDN_ScopeInit(laSynthNodeScope* n, int NoCreate){
  316. if(!n->Display1){ n->Display1=memAcquireSimple(sizeof(real)*LA_SYNTH_PLEN*2); }
  317. if(!n->Display2){ n->Display2=memAcquireSimple(sizeof(real)*LA_SYNTH_PLEN*2); }
  318. laSpinInit(&n->Lock);
  319. if(NoCreate){ return; }
  320. n->In1=laCreateInSocket("CH1",0); n->In2=laCreateInSocket("CH2",0);
  321. strSafeSet(&n->Base.Name,"SCOPE"); n->Time=5; n->Brightness1=0.7f; n->Brightness2=0.4f;
  322. n->Gain1=1; n->Gain2=1;
  323. }
  324. void IDN_ScopeDestroy(laSynthNodeScope* n){
  325. laDestroyInSocket(n->In1); laDestroyOutSocket(n->In2); strSafeDestroy(&n->Base.Name);
  326. memFree(n->Display1); memFree(n->Display2);
  327. laSpinDestroy(&n->Lock);
  328. }
  329. int IDN_ScopeVisit(laSynthNodeScope* n, laNodeVisitInfo* vi){
  330. LA_GUARD_THIS_NODE(n,vi);
  331. if(LA_SRC_AND_PARENT(n->In1)){ laBaseNode*bn=n->In1->Source->Parent; LA_VISIT_NODE(bn,vi); }
  332. if(LA_SRC_AND_PARENT(n->In2)){ laBaseNode*bn=n->In2->Source->Parent; LA_VISIT_NODE(bn,vi); }
  333. LA_ADD_THIS_NODE(n,vi);
  334. return LA_DAG_FLAG_PERM;
  335. }
  336. int IDN_ScopeEval(laSynthNodeScope* n){
  337. if(!n->Display1){ n->Display1=memAcquireSimple(sizeof(real)*LA_SYNTH_PLEN*2); }
  338. if(!n->Display2){ n->Display2=memAcquireSimple(sizeof(real)*LA_SYNTH_PLEN*2); }
  339. real* ch1,*ch2; INPUTPACKET(ch1,n->In1); INPUTPACKET(ch2,n->In2);
  340. int Frame=1<<(n->Time-1); TNS_CLAMP(Frame,1,LA_SYNTH_PLEN);
  341. int Times=LA_SYNTH_PLEN/Frame; int sp=0; laSpinLock(&n->Lock);
  342. for(int t=0;t<Times;t++){
  343. real smin1=FLT_MAX,smax1=-FLT_MAX,smin2=FLT_MAX,smax2=-FLT_MAX;
  344. for(int i=0;i<Frame;i++){
  345. if(ch1){ smin1=TNS_MIN2(smin1,ch1[sp]); smax1=TNS_MAX2(smax1,ch1[sp]); }
  346. if(ch2){ smin2=TNS_MIN2(smin2,ch2[sp]); smax2=TNS_MAX2(smax2,ch2[sp]); }
  347. sp++;
  348. }
  349. if(!ch1){smin1=smax1=0; LA_GET_SRC_AS_VALUE(smin1,n->In1); smax1=smin1; }
  350. if(!ch2){smin2=smax2=0; LA_GET_SRC_AS_VALUE(smin2,n->In2); smax2=smin2; }
  351. int ns=n->NextSample;
  352. n->Display1[ns]=smin1; n->Display1[ns+LA_SYNTH_PLEN]=smax1;
  353. n->Display2[ns]=smin2; n->Display2[ns+LA_SYNTH_PLEN]=smax2;
  354. n->NextSample++; if(n->NextSample>=LA_SYNTH_PLEN) n->NextSample=0;
  355. }
  356. n->FromSynth=MAIN.Audio->AudioEvalSynth;
  357. laSpinUnlock(&n->Lock);
  358. return 1;
  359. }
  360. void IDN_ScopeCopy(laSynthNodeScope* new, laSynthNodeScope* old, int DoRematch){
  361. if(DoRematch){ LA_IDN_NEW_LINK(In1) LA_IDN_NEW_LINK(In2) return; }
  362. new->Brightness1=old->Brightness1; new->Brightness2=old->Brightness2;
  363. new->Gain1=old->Gain1; new->Gain2=old->Gain2;
  364. new->Offset1=old->Offset1; new->Offset2=old->Offset2;
  365. new->Time=old->Time;
  366. }
  367. void laui_ScopeNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  368. laColumn* c=laFirstColumn(uil); laSynthNodeScope*n=This->EndInstance;
  369. LA_BASE_NODE_HEADER(uil,c,This);
  370. laColumn* cl,*cr; laSplitColumn(uil,c,0.5); cl=laLeftColumn(c,0); cr=laRightColumn(c,0);
  371. laUiItem* b=laBeginRow(uil,c,0,0);
  372. laUiItem* u=laShowItem(uil,c,This,"gain1");u->Flags|=LA_UI_FLAGS_EXPAND; u->Expand=1;
  373. laShowNodeSocket(uil,c,This,"in1",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  374. laEndRow(uil,b);
  375. b=laBeginRow(uil,c,0,0);
  376. u=laShowItem(uil,c,This,"gain2");u->Flags|=LA_UI_FLAGS_EXPAND; u->Expand=1;
  377. laShowNodeSocket(uil,c,This,"in2",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  378. laEndRow(uil,b);
  379. laShowItem(uil,c,This,"scope")->Extra->HeightCoeff=6;
  380. laShowLabel(uil,cl,"CH1",0,0)->Flags|=LA_TEXT_ALIGN_CENTER;
  381. laShowItem(uil,cl,This,"bright1"); laShowItem(uil,cl,This,"offset1");
  382. laShowLabel(uil,cr,"CH2",0,0)->Flags|=LA_TEXT_ALIGN_CENTER;
  383. laShowItem(uil,cr,This,"bright2"); laShowItem(uil,cr,This,"offset2");
  384. laShowItem(uil,c,This,"time")->Flags|=LA_UI_FLAGS_EXPAND;
  385. }
  386. void IDN_OutputInit(laSynthNodeOutput* n, int NoCreate){
  387. if(NoCreate){
  388. laAudioChannel* outchannel = laGetAudioChannel(SSTR(n->SendName));
  389. if(outchannel) memAssignRef(n,&n->Send,outchannel);
  390. if(!n->InL) n->InL=laCreateInSocket("L/M",0);
  391. if(!n->InR) n->InR=laCreateInSocket("R",0);
  392. return;
  393. }
  394. n->InL=laCreateInSocket("L/M",0); n->InR=laCreateInSocket("R",0); strSafeSet(&n->Base.Name,"Output");
  395. }
  396. void IDN_OutputDestroy(laSynthNodeOutput* n){
  397. laDestroyInSocket(n->InL); laDestroyInSocket(n->InR); strSafeDestroy(&n->Base.Name);
  398. }
  399. int IDN_OutputVisit(laSynthNodeOutput* n, laNodeVisitInfo* vi){
  400. if(LA_SRC_AND_PARENT(n->InL)){ laBaseNode*bn=n->InL->Source->Parent; LA_VISIT_NODE(bn,vi); }
  401. if(LA_SRC_AND_PARENT(n->InR)){ laBaseNode*bn=n->InR->Source->Parent; LA_VISIT_NODE(bn,vi); }
  402. LA_ADD_THIS_NODE(n,vi);
  403. laAudioChannel* outchannel = laGetAudioChannel(SSTR(n->SendName));
  404. memAssignRef(n,&n->Send,outchannel);
  405. return LA_DAG_FLAG_PERM;
  406. }
  407. int IDN_OutputEval(laSynthNodeOutput* n){
  408. if(!n->Send)return 1;
  409. real* inputL; INPUTPACKET(inputL,n->InL); real* inputR; INPUTPACKET(inputR,n->InR); if(!inputL && !inputR) return 1;
  410. real Samples[LA_SYNTH_PLEN];
  411. if(inputL){
  412. for(int i=0;i<LA_SYNTH_PLEN;i++){ n->Send->SamplesL[i] += inputL[i]; }
  413. if(n->Send){ n->Send->IsMono=1; }
  414. }
  415. if(inputR){
  416. for(int i=0;i<LA_SYNTH_PLEN;i++){ n->Send->SamplesR[i] += inputR[i]; }
  417. if(n->Send){ n->Send->IsMono=0; }
  418. }
  419. return 1;
  420. }
  421. void IDN_OutputCopy(laSynthNodeOutput* new, laSynthNodeOutput* old, int DoRematch){
  422. if(DoRematch){ LA_IDN_NEW_LINK(InL) return; }
  423. if(DoRematch){ LA_IDN_NEW_LINK(InR) return; }
  424. strSafeSet(&new->SendName,SSTR(old->SendName)); new->Send=old->Send;
  425. }
  426. void laui_OutputNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  427. laColumn* c=laFirstColumn(uil); laSynthNodeOutput*n=This->EndInstance;
  428. LA_BASE_NODE_HEADER(uil,c,This);
  429. laColumn* cl,*cr; laSplitColumn(uil,c,0.3); cl=laLeftColumn(c,0); cr=laRightColumn(c,0);
  430. laUiItem* b=laBeginRow(uil,c,0,0);
  431. laShowNodeSocket(uil,c,This,"in_l",0)->Flags|=LA_UI_SOCKET_LABEL_E;
  432. laShowNodeSocket(uil,c,This,"in_r",0)->Flags|=LA_UI_SOCKET_LABEL_E;
  433. laShowLabel(uil,c,"🕪",0,0);
  434. laShowItemFull(uil,c,This,"send_channel_selector",LA_WIDGET_COLLECTION_SELECTOR,0,laui_IdentifierOnly,0)->Flags|=LA_UI_COLLECTION_SIMPLE_SELECTOR;
  435. laShowItem(uil,c,This,"send_channel_name")->Expand = 1;
  436. laEndRow(uil,b);
  437. }
  438. void IDN_EnvelopeInit(laSynthNodeEnvelope* n, int NoCreate){
  439. if(!NoCreate){ strSafeSet(&n->Base.Name,"Envelope");
  440. n->Attack=laCreateInSocket("ATTACK",0); n->Delay=laCreateInSocket("DELAY",0);
  441. n->Sustain=laCreateInSocket("SUSTAIN",0); n->Release=laCreateInSocket("RELEASE",0);
  442. n->Trigger=laCreateInSocket("TRIGGER",0); n->Out=laCreateOutSocket(n, "OUT",0);
  443. n->Time=20; n->rAttack=1; n->rDelay=5; n->rSustain=5; n->rRelease=7; n->rGate=5;
  444. }
  445. if(!n->Gate){ n->Gate=laCreateInSocket("GATE",0); }
  446. if(!n->Restart){ n->Restart=laCreateInSocket("RESTART",0); }
  447. if(!n->OutSamples){ n->OutSamples=memAcquireSimple(sizeof(real)*LA_SYNTH_PLEN); }
  448. n->Out->Data = n->OutSamples; n->Out->DataType = LA_PROP_FLOAT|LA_PROP_ARRAY; n->Out->ArrLen=LA_SYNTH_PLEN;
  449. }
  450. void IDN_EnvelopeDestroy(laSynthNodeEnvelope* n){
  451. laDestroyInSocket(n->Attack); laDestroyInSocket(n->Delay); laDestroyInSocket(n->Gate);
  452. laDestroyInSocket(n->Sustain); laDestroyInSocket(n->Release);
  453. laDestroyInSocket(n->Trigger); laDestroyOutSocket(n->Out);
  454. memFree(n->OutSamples);
  455. strSafeDestroy(&n->Base.Name);
  456. }
  457. int IDN_EnvelopeVisit(laSynthNodeEnvelope* n, laNodeVisitInfo* vi){
  458. LA_GUARD_THIS_NODE(n,vi);
  459. if(LA_SRC_AND_PARENT(n->Attack)){ laBaseNode*bn=n->Attack->Source->Parent; LA_VISIT_NODE(bn,vi); }
  460. if(LA_SRC_AND_PARENT(n->Delay)){ laBaseNode*bn=n->Delay->Source->Parent; LA_VISIT_NODE(bn,vi); }
  461. if(LA_SRC_AND_PARENT(n->Sustain)){ laBaseNode*bn=n->Sustain->Source->Parent; LA_VISIT_NODE(bn,vi); }
  462. if(LA_SRC_AND_PARENT(n->Release)){ laBaseNode*bn=n->Release->Source->Parent; LA_VISIT_NODE(bn,vi); }
  463. if(LA_SRC_AND_PARENT(n->Trigger)){ laBaseNode*bn=n->Trigger->Source->Parent; LA_VISIT_NODE(bn,vi); }
  464. if(LA_SRC_AND_PARENT(n->Restart)){ laBaseNode*bn=n->Restart->Source->Parent; LA_VISIT_NODE(bn,vi); }
  465. LA_ADD_THIS_NODE(n,vi);
  466. return LA_DAG_FLAG_PERM;
  467. }
  468. int IDN_EnvelopeEval(laSynthNodeEnvelope* n){
  469. int trigger_at=-1; real trig=n->bTrigger?n->bTrigger*100:-100; real res=0;
  470. real* trigger; INPUTPACKET(trigger,n->Trigger); if(!trigger){ LA_GET_SRC_AS_VALUE(trig,n->Trigger); }
  471. real* restart; INPUTPACKET(restart,n->Restart); if(!restart){ LA_GET_SRC_AS_VALUE(res,n->Restart); }
  472. real *att,*del,*sus,*rel,*gat;
  473. real attack=n->rAttack,delay=n->rDelay,sustain=n->rSustain,release=n->rRelease;
  474. real gate = n->rGate; INPUTPACKET(gat,n->Gate); if(!gat) LA_GET_SRC_AS_VALUE(gate,n->Gate);
  475. INPUTPACKET(att,n->Attack); if(!att) LA_GET_SRC_AS_VALUE(attack,n->Attack);
  476. INPUTPACKET(del,n->Delay); if(!del) LA_GET_SRC_AS_VALUE(delay,n->Delay);
  477. INPUTPACKET(sus,n->Sustain); if(!sus) LA_GET_SRC_AS_VALUE(sustain,n->Sustain);
  478. INPUTPACKET(rel,n->Release); if(!rel) LA_GET_SRC_AS_VALUE(release,n->Release);
  479. attack=attack?pow(attack/10,2):0; delay=delay?pow(delay/10,2):0; release=release?pow(release/10,2):0;
  480. for(int i=0;i<LA_SYNTH_PLEN;i++){
  481. if(trigger){ trig=trigger[i]; } if(gat){ gate=gat[i]; } if(restart){ res=restart[i]; }
  482. if(att){ attack=att[i]*n->iAttack+n->rAttack; }
  483. if(del){ delay=del[i]*n->iDelay+n->rDelay; }
  484. if(sus){ sustain=sus[i]*n->iSustain+n->rSustain; }
  485. if(rel){ release=rel[i]*n->iRelease+n->rRelease; }
  486. if(res){ n->Time=0; n->ReleaseTime=-10000; n->Triggered=0;}
  487. if(!n->Triggered){ if(trig > gate){ n->Triggered = 1; n->Time = 0; n->ReleaseTime=10000; n->AtLevel=0; } }
  488. else{ if(trig < gate-0.0001f){ n->Triggered = 0; n->ReleaseTime = n->Time; } }
  489. if(n->Time < n->ReleaseTime){
  490. if(n->Time<=attack){
  491. n->OutSamples[i]=10.0f*pow(n->Time/attack,0.3);
  492. }elif(n->Time<=delay + attack){
  493. real fac=pow((n->Time-attack)/delay,0.3);
  494. n->OutSamples[i]= tnsLinearItp(10.0f, sustain, fac);
  495. }else{
  496. n->OutSamples[i]=sustain;
  497. }
  498. n->AtLevel=n->OutSamples[i];
  499. }else{
  500. if(n->Time - n->ReleaseTime < release){
  501. real fac=pow((n->Time - n->ReleaseTime)/release,0.3);
  502. n->OutSamples[i]= tnsLinearItp(n->AtLevel,0.0f, fac);
  503. }else{
  504. n->OutSamples[i]=0;
  505. }
  506. }
  507. n->Time+=FRAME_INTERVAL;
  508. }
  509. return 1;
  510. }
  511. void IDN_EnvelopeCopy(laSynthNodeEnvelope* new, laSynthNodeEnvelope* old, int DoRematch){
  512. if(DoRematch){
  513. LA_IDN_NEW_LINK(Attack) LA_IDN_NEW_LINK(Delay)
  514. LA_IDN_NEW_LINK(Sustain) LA_IDN_NEW_LINK(Release) LA_IDN_NEW_LINK(Trigger) return;
  515. }
  516. LA_IDN_OLD_DUPL(Out);
  517. new->rGate=old->rGate;
  518. new->rAttack=old->rAttack;new->rSustain=old->rSustain;new->rDelay=old->rDelay;new->rRelease=old->rRelease;
  519. new->iAttack=old->iAttack;new->iSustain=old->iSustain;new->iDelay=old->iDelay;new->iRelease=old->rRelease;
  520. }
  521. void laui_EnvelopeNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  522. laColumn* c=laFirstColumn(uil); laSynthNodeEnvelope*n=This->EndInstance;
  523. LA_BASE_NODE_HEADER(uil,c,This);
  524. laUiItem* b,*b1;
  525. #define ADSR_ROW(what) \
  526. b=laBeginRow(uil,c,0,0);{ \
  527. laShowNodeSocket(uil,c,This,"in_" what,0)->Flags|=LA_UI_SOCKET_LABEL_E; \
  528. laUiItem* value=laShowItem(uil,c,This,"i" what); \
  529. value=laShowItem(uil,c,This,what);value->Expand=1; \
  530. }laEndRow(uil,b);
  531. ADSR_ROW("attack") ADSR_ROW("delay") ADSR_ROW("sustain") ADSR_ROW("release")
  532. b=laBeginRow(uil,c,0,0);
  533. laShowItem(uil,c,This,"gate")->Expand=1;
  534. laShowNodeSocket(uil,c,This,"in_gate",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  535. laShowNodeSocket(uil,c,This,"in_trigger",0)->Flags|=LA_UI_SOCKET_LABEL_E;
  536. laEndRow(uil,b);
  537. b=laBeginRow(uil,c,0,0);
  538. laShowSeparator(uil,c)->Expand=1;
  539. laShowItem(uil,c,This,"in_restart")->Flags|=LA_UI_SOCKET_LABEL_E;
  540. laShowItem(uil,c,This,"trigger")->Flags|=LA_UI_FLAGS_MOMENTARY|LA_UI_FLAGS_HIGHLIGHT;
  541. laShowItem(uil,c,This,"out")->Flags|=LA_UI_SOCKET_LABEL_W;
  542. laEndRow(uil,b);
  543. }
  544. void IDN_QuantizeInit(laSynthNodeQuantize* n, int NoCreate){
  545. if(!NoCreate){ strSafeSet(&n->Base.Name,"Envelope");
  546. n->In=laCreateInSocket("IN",0); n->Out=laCreateOutSocket(n, "OUT",0);
  547. }
  548. if(!n->OutSamples){ n->OutSamples=memAcquireSimple(sizeof(real)*LA_SYNTH_PLEN); }
  549. n->Out->Data = n->OutSamples; n->Out->DataType = LA_PROP_FLOAT|LA_PROP_ARRAY; n->Out->ArrLen=LA_SYNTH_PLEN;
  550. int Enabled[12]={1,0,1,0,1,1,0,1,0,1,0,1};
  551. memcpy(n->EnabledBits,Enabled,sizeof(Enabled));
  552. }
  553. void IDN_QuantizeDestroy(laSynthNodeQuantize* n){
  554. laDestroyInSocket(n->In); laDestroyOutSocket(n->Out);
  555. memFree(n->OutSamples);
  556. strSafeDestroy(&n->Base.Name);
  557. }
  558. int IDN_QuantizeVisit(laSynthNodeQuantize* n, laNodeVisitInfo* vi){
  559. LA_GUARD_THIS_NODE(n,vi);
  560. if(LA_SRC_AND_PARENT(n->In)){ laBaseNode*bn=n->In->Source->Parent; LA_VISIT_NODE(bn,vi); }
  561. LA_ADD_THIS_NODE(n,vi);
  562. return LA_DAG_FLAG_PERM;
  563. }
  564. static const real QTABLE[12]={ VAL13-VALHALF*9, VAL13-VALHALF*8, VAL13-VALHALF*7, VAL13-VALHALF*6,
  565. VAL13-VALHALF*5, VAL13-VALHALF*4, VAL13-VALHALF*3, VAL13-VALHALF*2,
  566. VAL13-VALHALF*1, VAL13, VAL13+VALHALF*1, VAL13+VALHALF*2 };
  567. static void set_quantize_out_bit(laSynthNodeQuantize* n, int which){
  568. for(int i=0;i<12;i++){
  569. if(n->EnabledBits[i]){ n->EnabledBits[i]=1; }
  570. if(i==which && n->EnabledBits){ n->EnabledBits[i]=3; }
  571. }
  572. }
  573. int IDN_QuantizeEval(laSynthNodeQuantize* n){ real cv0=QTABLE[0]+5; /*C4*/ LA_GET_SRC_AS_VALUE(cv0, n->In);
  574. real* cv; INPUTPACKET(cv,n->In); real dists[12];
  575. for(int i=0;i<LA_SYNTH_PLEN;i++){
  576. int octave = (int)(cv0-QTABLE[0]); int minkey=0;
  577. if(cv){ cv0=cv[i]; }
  578. real use_cv = cv0 - octave;
  579. for(int j=0;j<12;j++){ dists[j] = fabs(use_cv - QTABLE[j]); }
  580. for(int j=1;j<12;j++){ if(n->EnabledBits[j] && dists[j] < dists[minkey]){ minkey=j; } }
  581. set_quantize_out_bit(n,minkey);
  582. n->OutSamples[i] = QTABLE[minkey]+octave;
  583. }
  584. return 1;
  585. }
  586. void IDN_QuantizeCopy(laSynthNodeQuantize* new, laSynthNodeQuantize* old, int DoRematch){
  587. if(DoRematch){
  588. LA_IDN_NEW_LINK(In) return;
  589. }
  590. LA_IDN_OLD_DUPL(Out);
  591. memcpy(new->EnabledBits,old->EnabledBits,sizeof(int)*12);
  592. }
  593. void laui_QuantizeNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  594. laColumn* c=laFirstColumn(uil); laSynthNodeQuantize*n=This->EndInstance;
  595. LA_BASE_NODE_HEADER(uil,c,This);
  596. laUiItem* b;
  597. b=laBeginRow(uil,c,0,0);
  598. laUiItem* ui=laShowItem(uil,c,This,"enabled_keys");
  599. ui->Flags|=LA_UI_FLAGS_CYCLE|LA_UI_FLAGS_HIGHLIGHT|LA_UI_FLAGS_TRANSPOSE|LA_UI_FLAGS_ICON; ui->Expand=1;
  600. laShowNodeSocket(uil,c,This,"in",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  601. laShowNodeSocket(uil,c,This,"out",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  602. laEndRow(uil,b);
  603. }
  604. void IDN_SynthDriverInit(laSynthNodeDriver* n, int NoCreate){
  605. if(NoCreate){ return; }
  606. n->Prev=laCreateInSocket("PREV",0); n->Next=laCreateOutSocket(n,"NEXT",0);
  607. n->InTransport=laCreateInSocket("TRANSPORT",LA_PROP_FLOAT|LA_PROP_ARRAY);
  608. n->InReset=laCreateInSocket("RESET",LA_PROP_FLOAT|LA_PROP_ARRAY);
  609. strSafeSet(&n->Base.Name,"Sound Player");
  610. }
  611. void IDN_SynthDriverDestroy(laSynthNodeDriver* n){
  612. laDestroyInSocket(n->InTransport); laDestroyInSocket(n->InReset); strSafeDestroy(&n->Base.Name);
  613. laDestroyInSocket(n->Prev); laDestroyOutSocket(n->Next);
  614. }
  615. int IDN_SynthDriverVisit(laSynthNodeDriver* n, laNodeVisitInfo* vi){
  616. LA_GUARD_THIS_NODE(n,vi);
  617. if(LA_SRC_AND_PARENT(n->Prev)){ laBaseNode*bn=n->Prev->Source->Parent; LA_VISIT_NODE(bn,vi); }
  618. if(LA_SRC_AND_PARENT(n->InTransport)){ laBaseNode*bn=n->InTransport->Source->Parent; LA_VISIT_NODE(bn,vi); }
  619. if(LA_SRC_AND_PARENT(n->InReset)){ laBaseNode*bn=n->InReset->Source->Parent; LA_VISIT_NODE(bn,vi); }
  620. LA_ADD_THIS_NODE(n,vi);
  621. return LA_DAG_FLAG_PERM;
  622. }
  623. int IDN_SynthDriverEval(laSynthNodeDriver* n){
  624. laSynth*ss=n->Target; if(!ss){ return 0; }
  625. int trans=n->iTransport; LA_GET_SRC_AS_VALUE(trans,n->InTransport);
  626. int res=n->iReset; LA_GET_SRC_AS_VALUE(res,n->InReset); int dif=0;
  627. if(n->AlreadyReset && res==0){ n->AlreadyReset=0; res=0; }
  628. elif(!n->AlreadyReset && res!=0){ n->AlreadyReset=1; }
  629. else{ res=0; }
  630. laSpinLock(&ss->Lock);
  631. if(ss->Playing!=trans){ dif=1; }
  632. ss->Playing = trans; if(res){ ss->EvalSamples=0; ss->EvalTime=0; }
  633. laSpinUnlock(&ss->Lock);
  634. if(dif){ laNotifyInstanceUsers(ss); }
  635. return 1;
  636. }
  637. void IDN_SynthDriverCopy(laSynthNodeDriver* new, laSynthNodeDriver* old, int DoRematch){
  638. if(DoRematch){ LA_IDN_NEW_LINK(InTransport); LA_IDN_NEW_LINK(InReset); return; }
  639. new->iTransport = old->iTransport; new->iReset = old->iReset;
  640. memAssignRef(new,&new->Target,old->Target);
  641. }
  642. void laui_SynthDriverNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  643. laColumn* c=laFirstColumn(uil),*cl,*cr,*cll,*clr;
  644. LA_BASE_NODE_HEADER(uil,c,This);
  645. laSplitColumn(uil,c,0.6); cl=laLeftColumn(c,0); cr=laRightColumn(c,3);
  646. //laSplitColumn(uil,cl,0.4); cll=laLeftColumn(cl,3); clr=laRightColumn(cl,0);
  647. laUiItem* b2, *rui;
  648. laShowNodeSocket(uil,cr,This,"prev",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  649. laShowNodeSocket(uil,cr,This,"next",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  650. laUiItem* b=laBeginRow(uil,cl,0,0);
  651. laShowNodeSocket(uil,cl,This,"in_transport",0); b2=laOnConditionThat(uil,c,laNot(laPropExpression(This,"in_transport.source")));{
  652. laShowItemFull(uil,cl,This,"transport",0,"text=Transport",0,0)->Expand=1;
  653. }laElse(uil,b2);{
  654. laShowLabel(uil,cl,"Transport",0,0)->Expand=1;
  655. }laEndCondition(uil,b2);
  656. laShowNodeSocket(uil,cl,This,"in_reset",0); b2=laOnConditionThat(uil,c,laNot(laPropExpression(This,"in_reset.source")));{
  657. laUiItem* u=laShowItemFull(uil,cl,This,"reset",0,"text=Reset",0,0);u->Expand=1;u->Flags|=LA_UI_FLAGS_MOMENTARY;
  658. }laElse(uil,b2);{
  659. laShowLabel(uil,cl,"Reset",0,0)->Expand=1;
  660. }laEndCondition(uil,b2);
  661. laEndRow(uil,b);
  662. laShowItemFull(uil,cl,This,"target",LA_WIDGET_COLLECTION_SELECTOR,0,laui_IdentifierOnly,0);
  663. }
  664. void IDN_SynthTriggerInit(laSynthNodeTrigger* n, int NoCreate){
  665. if(NoCreate){ return; }
  666. n->Prev=laCreateInSocket("PREV",0); n->Next=laCreateOutSocket(n,"NEXT",0);
  667. n->InTrigger=laCreateInSocket("TRIGGER",LA_PROP_FLOAT|LA_PROP_ARRAY);
  668. strSafeSet(&n->Base.Name,"Sound Trigger"); n->TriggerEdge=1;
  669. }
  670. void IDN_SynthTriggerDestroy(laSynthNodeTrigger* n){
  671. laDestroyInSocket(n->InTrigger); strSafeDestroy(&n->Base.Name);
  672. laDestroyInSocket(n->Prev); laDestroyOutSocket(n->Next);
  673. }
  674. int IDN_SynthTriggerVisit(laSynthNodeTrigger* n, laNodeVisitInfo* vi){
  675. LA_GUARD_THIS_NODE(n,vi);
  676. if(LA_SRC_AND_PARENT(n->Prev)){ laBaseNode*bn=n->Prev->Source->Parent; LA_VISIT_NODE(bn,vi); }
  677. if(LA_SRC_AND_PARENT(n->InTrigger)){ laBaseNode*bn=n->InTrigger->Source->Parent; LA_VISIT_NODE(bn,vi); }
  678. LA_ADD_THIS_NODE(n,vi);
  679. return LA_DAG_FLAG_PERM;
  680. }
  681. int IDN_SynthTriggerEval(laSynthNodeTrigger* n){
  682. laSynth*ss=n->Target; if(!ss){ return 0; }
  683. real trig=0; real* trigger=0; INPUTPACKET(trigger,n->InTrigger); LA_GET_SRC_AS_VALUE(trig,n->InTrigger);
  684. if(MAIN.Audio->AudioEvalSynth == ss){ return 0; }
  685. if(trigger){
  686. for(int i=0;i<LA_SYNTH_PLEN;i++){
  687. if(trigger[i]>=5){
  688. if(n->TriggerEdge){ if(!n->Triggered){ n->Triggered=1; laSynthTriggerLater(ss); } }
  689. else{ laSynthTriggerLater(ss); }
  690. }else{ n->Triggered=0; }
  691. }
  692. }else{
  693. if(trig>=0.5){
  694. if(n->TriggerEdge){ if(!n->Triggered){ n->Triggered=1; laSynthTriggerLater(ss); } }
  695. else{ laSynthTriggerLater(ss); }
  696. }else{ n->Triggered=0; }
  697. }
  698. return 1;
  699. }
  700. void IDN_SynthTriggerCopy(laSynthNodeTrigger* new, laSynthNodeTrigger* old, int DoRematch){
  701. if(DoRematch){ LA_IDN_NEW_LINK(InTrigger); return; }
  702. new->TriggerEdge = old->TriggerEdge;
  703. memAssignRef(new,&new->Target,old->Target);
  704. }
  705. void laui_SynthTriggerNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  706. laColumn* c=laFirstColumn(uil),*cl,*cr,*cll,*clr;
  707. LA_BASE_NODE_HEADER(uil,c,This);
  708. laSplitColumn(uil,c,0.6); cl=laLeftColumn(c,0); cr=laRightColumn(c,3);
  709. //laSplitColumn(uil,cl,0.4); cll=laLeftColumn(cl,3); clr=laRightColumn(cl,0);
  710. laUiItem* b2, *rui;
  711. laShowNodeSocket(uil,cr,This,"prev",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  712. laShowNodeSocket(uil,cr,This,"next",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  713. laUiItem* b=laBeginRow(uil,cl,0,0);
  714. laShowItemFull(uil,cl,This,"trigger_edge",0,0,0,0)->Flags|=LA_UI_FLAGS_ICON;
  715. laShowNodeSocket(uil,cl,This,"in_trigger",0);
  716. laShowItemFull(uil,cl,This,"trigger",0,"text=Trigger",0,0)->Flags|=LA_UI_FLAGS_MOMENTARY|LA_UI_FLAGS_HIGHLIGHT;
  717. laShowSeparator(uil,cl)->Expand=1;
  718. laEndRow(uil,b);
  719. laShowItemFull(uil,cl,This,"target",LA_WIDGET_COLLECTION_SELECTOR,0,laui_IdentifierOnly,0);
  720. }
  721. void laRebuildSynthGraphs(int current_only){
  722. if(MAIN.Audio->CurrentSynth && current_only){
  723. laSpinLock(&MAIN.Audio->CurrentSynth->Lock);
  724. laRebuildPageEval(MAIN.Audio->CurrentSynth->Page);
  725. laSpinUnlock(&MAIN.Audio->CurrentSynth->Lock);
  726. }else{
  727. for(laSynth* s=MAIN.Audio->Synths.pFirst;s;s=s->Item.pNext){
  728. laSpinLock(&s->Lock);
  729. laRebuildPageEval(s->Page);
  730. laSpinUnlock(&s->Lock);
  731. }
  732. }
  733. }
  734. int laEvalSingleSynth(laSynth* ss){
  735. laSynth* FirstInst=0; int any=0;
  736. laSpinLock(&ss->Lock);
  737. if(ss->Playing){
  738. MAIN.Audio->AudioEvalSynth=ss;
  739. laRunPage(ss->Page,1);
  740. ss->EvalSamples += LA_SYNTH_PLEN;
  741. ss->EvalTime = (real)ss->EvalSamples/MAIN.Audio->AudioSampleRate;
  742. any=1;
  743. }
  744. FirstInst=ss->PolyphonicInstances.pFirst;
  745. laSpinUnlock(&ss->Lock);
  746. laSpinLock(&MAIN.Audio->AudioStatusLock);
  747. laSynth* pending; while(pending=lstPopPointer(&MAIN.Audio->PolyLaterTrigger)){ laSynthTriggerNew(pending); }
  748. laSpinUnlock(&MAIN.Audio->AudioStatusLock);
  749. laListHandle to_remove={0}; int count=0;
  750. for(laSynth* inst=FirstInst;inst;inst=inst->Item.pNext){
  751. any+=laEvalSingleSynth(inst); count++;
  752. if(inst->EvalTime > ss->Length || count>ss->MaxPoly){ lstAppendPointer(&to_remove,inst); }
  753. }
  754. laSynth* inst; while(inst=lstPopPointer(&to_remove)){
  755. la_SynthRemovePolyInstance(ss,inst);
  756. }
  757. return any;
  758. }
  759. int laEvalSynthGraphs(){
  760. laSynth* ss; int any=0;
  761. memset(MAIN.Audio->OutputSamplesL,0,sizeof(real)*LA_SYNTH_PLEN);
  762. memset(MAIN.Audio->OutputSamplesR,0,sizeof(real)*LA_SYNTH_PLEN);
  763. for(laAudioChannel* ac=MAIN.Audio->Channels.pFirst;ac;ac=ac->Item.pNext){
  764. memset(ac->SamplesL,0,sizeof(real)*LA_SYNTH_PLEN);
  765. memset(ac->SamplesR,0,sizeof(real)*LA_SYNTH_PLEN);
  766. }
  767. for(ss=MAIN.Audio->Synths.pFirst;ss;ss=ss->Item.pNext){
  768. if(laEvalSingleSynth(ss)){ any=1; }
  769. }
  770. for(laAudioChannel* ac=MAIN.Audio->Channels.pFirst;ac;ac=ac->Item.pNext){
  771. real *RSamples = ac->IsMono?ac->SamplesL:ac->SamplesR;
  772. for(int i=0;i<LA_SYNTH_PLEN;i++){
  773. MAIN.Audio->OutputSamplesL[i] += ac->SamplesL[i]*(ac->Volume/10);
  774. MAIN.Audio->OutputSamplesR[i] += RSamples[i]*(ac->Volume/10);
  775. }
  776. }
  777. return any;
  778. }
  779. void laaudio_DataCallback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount){
  780. float* out=pOutput,*in=pInput; int Paused; int any=0;
  781. laSpinLock(&MAIN.Audio->AudioStatusLock);
  782. Paused = MAIN.Audio->Paused;
  783. laSpinUnlock(&MAIN.Audio->AudioStatusLock);
  784. if(Paused){ memset(out,0,sizeof(float)*LA_SYNTH_PLEN);
  785. memset(MAIN.Audio->InputSamplesL,0,sizeof(float)*LA_SYNTH_PLEN);
  786. memset(MAIN.Audio->InputSamplesR,0,sizeof(float)*LA_SYNTH_PLEN); return;
  787. }
  788. for(int i=0;i<frameCount;i++){
  789. if(MAIN.Audio->NextAudioSample>=LA_SYNTH_PLEN){
  790. MAIN.Audio->NextAudioSample=0;
  791. if(laEvalSynthGraphs()){ any=1; }
  792. }
  793. int s=i*2;
  794. out[s]=MAIN.Audio->OutputSamplesL[MAIN.Audio->NextAudioSample]/10;
  795. out[s+1]=MAIN.Audio->OutputSamplesR[MAIN.Audio->NextAudioSample]/10;
  796. MAIN.Audio->InputSamplesL[MAIN.Audio->NextAudioSample] = in[s] * 10;
  797. MAIN.Audio->InputSamplesR[MAIN.Audio->NextAudioSample] = in[s+1] * 10;
  798. MAIN.Audio->NextAudioSample++;
  799. }
  800. }
  801. void la_SelectAudioDevice(laAudioDevice* ad){
  802. memAssignRef(MAIN.Audio, &MAIN.Audio->UsingDevice, ad);
  803. ma_device_stop(&MAIN.Audio->AudioDevice);
  804. ma_device_uninit(&MAIN.Audio->AudioDevice);
  805. if(!ad) return;
  806. int SampleRate=48000;
  807. ma_device_config config = ma_device_config_init(ma_device_type_duplex);
  808. config.capture.pDeviceID = ad->MiniAudioID;
  809. config.capture.format = ma_format_f32;
  810. config.capture.channels = 2;
  811. config.playback.pDeviceID= ad->MiniAudioID;
  812. config.playback.format = ma_format_f32;
  813. config.playback.channels = 2;
  814. config.sampleRate = SampleRate;
  815. config.dataCallback = laaudio_DataCallback;
  816. config.pUserData = 0;
  817. if (ma_device_init(&MAIN.Audio->MiniAudioContext, &config, &MAIN.Audio->AudioDevice) != MA_SUCCESS){ return; }
  818. MAIN.Audio->AudioSampleRate=SampleRate;
  819. MAIN.Audio->NextAudioSample=LA_SYNTH_PLEN;
  820. MAIN.Audio->AudioFrameInterval=1.0f/SampleRate;
  821. }
  822. void la_AddAudioDevice(int id, char* Name){
  823. laAudioDevice* ad=memAcquire(sizeof(laAudioDevice));
  824. strSafeSet(&ad->Name,Name); ad->MiniAudioID=id;
  825. lstAppendItem(&MAIN.Audio->AudioDevices,ad);
  826. }
  827. void la_ClearAudioDevices(){
  828. laAudioDevice* ad; while(ad=lstPopItem(&MAIN.Audio->AudioDevices)){
  829. strSafeDestroy(&ad->Name); memFree(ad);
  830. }
  831. }
  832. void laRefreshAudioDevices(){
  833. if(!MAIN.Audio) return; la_ClearAudioDevices();
  834. ma_device_info* pPlaybackInfos;
  835. ma_uint32 playbackCount;
  836. ma_device_info* pCaptureInfos;
  837. ma_uint32 captureCount;
  838. if (ma_context_get_devices(&MAIN.Audio->MiniAudioContext, &pPlaybackInfos, &playbackCount, &pCaptureInfos, &captureCount) != MA_SUCCESS) {
  839. logPrintNew("Can't get audio devices.\n");
  840. }
  841. for (ma_uint32 iDevice = 0; iDevice < playbackCount; iDevice += 1) {
  842. la_AddAudioDevice(iDevice, pPlaybackInfos[iDevice].name);
  843. }
  844. }
  845. void laInitMiniAudio(){
  846. MAIN.Audio->MiniAudioBackend=ma_backend_null;
  847. if (ma_context_init(NULL, 0, NULL, &MAIN.Audio->MiniAudioContext) != MA_SUCCESS) {
  848. printf("Can't init miniaudio context\n");
  849. }
  850. laRefreshAudioDevices();
  851. laSpinInit(&MAIN.Audio->AudioStatusLock);
  852. INITPACKET(MAIN.Audio->InputSamplesL);
  853. INITPACKET(MAIN.Audio->InputSamplesR);
  854. INITPACKET(MAIN.Audio->OutputSamplesL);
  855. INITPACKET(MAIN.Audio->OutputSamplesR);
  856. la_SelectAudioDevice(MAIN.Audio->AudioDevices.pFirst);
  857. }
  858. void laDeinitAudio(){
  859. memFree(MAIN.Audio->InputSamplesL);
  860. memFree(MAIN.Audio->InputSamplesR);
  861. memFree(MAIN.Audio->OutputSamplesR);
  862. memFree(MAIN.Audio->OutputSamplesL);
  863. laSpinDestroy(&MAIN.Audio->AudioStatusLock);
  864. ma_device_stop(&MAIN.Audio->AudioDevice);
  865. ma_device_uninit(&MAIN.Audio->AudioDevice);
  866. ma_context_uninit(&MAIN.Audio->MiniAudioContext);
  867. }
  868. void laStartAudio(){
  869. laSpinLock(&MAIN.Audio->AudioStatusLock);
  870. MAIN.Audio->Paused = 0;
  871. laSpinUnlock(&MAIN.Audio->AudioStatusLock);
  872. ma_device_start(&MAIN.Audio->AudioDevice);
  873. }
  874. void laStopAudio(){
  875. ma_device_stop(&MAIN.Audio->AudioDevice);
  876. }
  877. void laPauseAudio(){
  878. laSpinLock(&MAIN.Audio->AudioStatusLock);
  879. MAIN.Audio->Paused = 1;
  880. laSpinUnlock(&MAIN.Audio->AudioStatusLock);
  881. }
  882. void laResetAudio(){
  883. for(laSynth* s=MAIN.Audio->Synths.pFirst;s;s=s->Item.pNext){
  884. laSpinLock(&s->Lock);
  885. s->EvalTime = 0; s->EvalSamples = 0; s->Playing = 0;
  886. laSpinUnlock(&s->Lock);
  887. }
  888. }
  889. // Operations
  890. int OPINV_RefreshAudioDevices(laOperator* a, laEvent* e){
  891. laRefreshAudioDevices(); return LA_FINISHED;
  892. }
  893. laSynth* laFindSynth(const char* Name){
  894. for(laSynth* ss=MAIN.Audio->Synths.pFirst;ss;ss=ss->Item.pNext){
  895. if(strSame(SSTR(ss->Name),Name)) return ss;
  896. }
  897. return 0;
  898. }
  899. laSynth* laNewSynth(char* Name){
  900. laSynth* ss=memAcquireHyper(sizeof(laSynth));
  901. ss->Page=memAcquire(sizeof(laRackPage));
  902. ss->Page->RackType=LA_RACK_TYPE_AUDIO;
  903. ss->Length=5; ss->MaxPoly=8;
  904. strSafeSet(&ss->Name,Name);
  905. lstAppendItem(&MAIN.Audio->Synths,ss);
  906. memAssignRef(MAIN.Audio,&MAIN.Audio->CurrentSynth,ss);
  907. laSpinInit(&ss->Lock);
  908. return ss;
  909. }
  910. void laRemoveSynth(laSynth* ss){ if(!ss) return;
  911. strSafeDestroy(&ss->Name);
  912. if(MAIN.Audio->CurrentSynth==ss){
  913. laSynth* nss=ss->Item.pNext?ss->Item.pNext:ss->Item.pPrev;
  914. memAssignRef(MAIN.Audio,&MAIN.Audio->CurrentSynth,nss);
  915. }laNotifyInstanceUsers(ss);
  916. while(ss->Page->Racks.pFirst){ laDestroyRack(ss->Page->Racks.pFirst); } memLeave(ss->Page); //ss->Page=0;
  917. lstRemoveItem(&MAIN.Audio->Synths,ss);
  918. laSpinDestroy(&ss->Lock);
  919. memLeave(ss);
  920. }
  921. int OPINV_ShedNewSynth(laOperator* a, laEvent* e){
  922. laNewSynth("New Synth");
  923. laNotifyInstanceUsers(MAIN.Audio); laRecordAndPush(0,"la.audio","New synth", 0);
  924. return LA_FINISHED;
  925. }
  926. int OPCHK_IslaSynth(laPropPack *This, laStringSplitor *ss){
  927. if (This && This->EndInstance && la_EnsureSubTarget(This->LastPs->p,0) == LA_PC_SYNTH) return 1;
  928. return 0;
  929. }
  930. int OPINV_ShedRemoveSynth(laOperator* a, laEvent* e){
  931. laSynth* ss=a->This?a->This->EndInstance:0; if(!ss)return LA_CANCELED;
  932. if(strSame(strGetArgumentString(a->ExtraInstructionsP,"confirm"),"true")){
  933. laRemoveSynth(ss);
  934. laNotifyInstanceUsers(MAIN.Audio); laRecordAndPush(0,"la.audio","Remove synthesizer", 0);
  935. return LA_FINISHED;
  936. }
  937. laEnableOperatorPanel(a,a->This,e->x,e->y,200,200,0,0,0,0,0,0,0,0,e);
  938. return LA_RUNNING;
  939. }
  940. void laui_RemoveSynth(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  941. laColumn* c=laFirstColumn(uil);
  942. laShowItemFull(uil,c,This,"remove_synth",0,"confirm=true;text=Confirm",0,0);
  943. }
  944. int OPINV_SynthPlay(laOperator* a, laEvent* e){
  945. laSynth* ss=a->This?a->This->EndInstance:0; if(!ss)return LA_CANCELED;
  946. char* str=strGetArgumentString(a->ExtraInstructionsP, "mode");
  947. int play=0; if(str && strSame(str,"PLAY")) play=1;
  948. laRebuildPageEval(ss->Page);
  949. laSpinLock(&ss->Lock);
  950. ss->Playing=play; if(!play){ ss->EvalSamples=0; ss->EvalTime=0; }
  951. laSpinUnlock(&ss->Lock);
  952. if(play){ laStartAudio(); } laNotifyInstanceUsers(ss);
  953. return LA_FINISHED;
  954. }
  955. int OPINV_SynthTriggerNew(laOperator* a, laEvent* e){
  956. laSynth* ss=a->This?a->This->EndInstance:0; if(!ss)return LA_CANCELED;
  957. laSynthTriggerNew(ss);
  958. laStartAudio();
  959. return LA_FINISHED;
  960. }
  961. void la_SynthAddPolyInstance(laSynth* s){
  962. int count=0;
  963. laSpinLock(&s->Lock); count = s->PolyCount; laSpinUnlock(&s->Lock);
  964. if(s->PolyCount>s->MaxPoly){ return; }
  965. laSpinLock(&s->Lock);
  966. laSynth* ns=memAcquire(sizeof(laSynth)); ns->Length=s->Length; ns->Playing=1;
  967. ns->Page = laDuplicateRackPage(0,s->Page);
  968. laRebuildPageEval(ns->Page);
  969. laSpinInit(&ns->Lock);
  970. //laSpinLock(&s->Lock);
  971. lstPushItem(&s->PolyphonicInstances,ns);
  972. s->PolyCount++;
  973. laSpinUnlock(&s->Lock);
  974. }
  975. void la_SynthRemovePolyInstance(laSynth* s, laSynth* inst){
  976. laSpinLock(&inst->Lock);
  977. while(inst->Page->Racks.pFirst){ laDestroyRack(inst->Page->Racks.pFirst); } memFree(inst->Page); //ss->Page=0;
  978. laSpinUnlock(&inst->Lock);
  979. laSpinDestroy(&inst->Lock);
  980. laSpinLock(&s->Lock);
  981. lstRemoveItem(&s->PolyphonicInstances,inst);
  982. s->PolyCount--;
  983. laSpinUnlock(&s->Lock);
  984. memFree(inst);
  985. }
  986. void laSynthTriggerNew(laSynth* s){
  987. if(!s || !s->Poly){ return; } la_SynthAddPolyInstance(s);
  988. }
  989. void laSynthTriggerLater(laSynth* s){
  990. if(!s || !s->Poly){ return; }
  991. laSpinLock(&MAIN.Audio->AudioStatusLock);
  992. lstAppendPointer(&MAIN.Audio->PolyLaterTrigger,s);
  993. laSpinUnlock(&MAIN.Audio->AudioStatusLock);
  994. }
  995. laAudioChannel* laNewAudioChannel(char* Name){
  996. laAudioChannel* ac=memAcquireHyper(sizeof(laAudioChannel)); lstAppendItem(&MAIN.Audio->Channels,ac);
  997. strSafeSet(&ac->Name,Name);
  998. ac->Volume = 10.0f;
  999. }
  1000. void laRemoveAudioChannel(laAudioChannel* ac){
  1001. lstRemoveItem(&MAIN.Audio->Channels,ac); strSafeDestroy(&ac->Name);
  1002. memLeave(ac);
  1003. }
  1004. laAudioChannel* laGetAudioChannel(char* Name){
  1005. for(laAudioChannel* ac=MAIN.Audio->Channels.pFirst;ac;ac=ac->Item.pNext){
  1006. if(strSame(SSTR(ac->Name),Name)) return ac;
  1007. }
  1008. return 0;
  1009. }
  1010. int OPCHK_IslaAudioChannel(laPropPack *This, laStringSplitor *ss){
  1011. if (This && This->EndInstance && la_EnsureSubTarget(This->LastPs->p,0) == LA_PC_CHANNEL) return 1;
  1012. return 0;
  1013. }
  1014. int OPINV_ShedNewAudioChannel(laOperator* a, laEvent* e){
  1015. laNewAudioChannel("Output");
  1016. laNotifyInstanceUsers(MAIN.Audio); laRecordAndPush(0,"la.audio","New channel", 0);
  1017. return LA_FINISHED;
  1018. }
  1019. int OPINV_ShedRemoveAudioChannel(laOperator* a, laEvent* e){
  1020. laAudioChannel*ac=a->This?a->This->EndInstance:0; if(!ac)return LA_CANCELED;
  1021. if(strSame(strGetArgumentString(a->ExtraInstructionsP,"confirm"),"true")){
  1022. laRemoveAudioChannel(ac); laNotifyInstanceUsers(MAIN.Audio); laRecordAndPush(0,"la.audio","Remove audio channel", 0);
  1023. return LA_FINISHED;
  1024. }
  1025. laEnableOperatorPanel(a,a->This,e->x,e->y,200,200,0,0,0,0,0,0,0,0,e);
  1026. return LA_RUNNING;
  1027. }
  1028. void laui_RemoveAudioChannel(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  1029. laColumn* c=laFirstColumn(uil);
  1030. laShowItemFull(uil,c,This,"remove",0,"confirm=true;text=Confirm",0,0);
  1031. }
  1032. void lauidetached_Synthersizers(laPanel* p){
  1033. la_MakeDetachedProp(p, "la.detached_view_switch", "detached");
  1034. la_MakeDetachedProp(p, "la.audio.current_synth", "page");
  1035. }
  1036. void laui_Synthersizers(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  1037. laColumn* c=laFirstColumn(uil),*cl, *cr,*crl,*crr;
  1038. laSplitColumn(uil,c,0.4); cl=laLeftColumn(c,1); cr=laRightColumn(c,0);
  1039. laSplitColumn(uil,cr,0.6); crl=laLeftColumn(cr,0); crr=laRightColumn(cr,2);
  1040. laShowItemFull(uil,cl,Extra,"detached",0,0,0,0)->Flags|=LA_UI_FLAGS_HIGHLIGHT|LA_UI_FLAGS_ICON;
  1041. #define ADD_PAGE \
  1042. laUiItem* b=laBeginRow(uil,crl,0,0); \
  1043. laShowItemFull(uil,crl,&rb->PP,"",LA_WIDGET_COLLECTION_SELECTOR,0,laui_IdentifierOnly,0) \
  1044. ->Flags|=LA_UI_COLLECTION_SIMPLE_SELECTOR; \
  1045. laUiItem* b3=laOnConditionThat(uil,cr,laPropExpression(&rb->PP,""));{ \
  1046. laShowItem(uil,crl,&rb->PP,"name"); \
  1047. laShowItem(uil,crl,0,"LA_new_synth")->Flags|=LA_UI_FLAGS_ICON; \
  1048. laShowSeparator(uil,crl); \
  1049. laShowItem(uil,crl,&rb->PP,"remove_synth")->Flags|=LA_UI_FLAGS_ICON; \
  1050. laShowSeparator(uil,crl)->Expand=1; \
  1051. laUiItem* b4=laOnConditionThat(uil,cr,laPropExpression(&rb->PP,"poly"));{ \
  1052. laShowItem(uil,crl,&rb->PP,"max_poly"); \
  1053. laShowItem(uil,crl,&rb->PP,"length"); \
  1054. laShowItemFull(uil,crl,&rb->PP,"trigger",0,"icon=▶;",0,0)->Flags|=LA_UI_FLAGS_ICON; \
  1055. }laEndCondition(uil,b4); \
  1056. laUiItem* poly=laShowItem(uil,crl,&rb->PP,"poly");poly->Flags|=LA_UI_FLAGS_EXPAND; \
  1057. }laElse(uil,b3);{ \
  1058. laShowItem(uil,crl,0,"LA_new_synth"); \
  1059. }laEndCondition(uil,b3); \
  1060. laEndRow(uil,b); \
  1061. b3=laOnConditionThat(uil,cr,laPropExpression(&rb->PP,""));{ \
  1062. laUiItem* b4=laOnConditionThat(uil,crr,laPropExpression(&rb->PP,"playing"));{ \
  1063. laShowItemFull(uil,crr,&rb->PP,"play",0,"text=❚❚;",0,0) \
  1064. ->Flags|=LA_UI_FLAGS_EXIT_WHEN_TRIGGERED|LA_TEXT_ALIGN_CENTER; \
  1065. }laElse(uil,b4);{ \
  1066. laShowItemFull(uil,crr,&rb->PP,"play",0,"icon=▶;mode=PLAY;",0,0) \
  1067. ->Flags|=LA_UI_FLAGS_ICON|LA_UI_FLAGS_EXIT_WHEN_TRIGGERED; \
  1068. }laEndCondition(uil,b4); \
  1069. laShowItemFull(uil,c,&rb->PP,"page",LA_WIDGET_COLLECTION_SINGLE,0,laui_RackPage,0)->Flags|=LA_UI_FLAGS_NO_DECAL; \
  1070. }laEndCondition(uil,b3); \
  1071. laUiItem* b1=laOnConditionThat(uil,cr,laPropExpression(Extra,"detached"));{
  1072. laUiItem* rb=laShowInvisibleItem(uil,cr,Extra,"page");
  1073. ADD_PAGE
  1074. }laElse(uil,b1);{
  1075. laUiItem* rb=laShowInvisibleItem(uil,cr,0,"la.audio.current_synth");
  1076. ADD_PAGE
  1077. }laEndCondition(uil,b1);
  1078. #undef ADD_PAGE
  1079. }
  1080. void laui_AudioChannel(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  1081. laColumn* c=laFirstColumn(uil); laSplitColumn(uil,c,0.3); laColumn* c1=laLeftColumn(c,1),*c2=laRightColumn(c,0); laUiItem* b;
  1082. laShowHeightAdjuster(uil,c1,This,"__move",0);
  1083. b=laBeginRow(uil,c2,0,0);
  1084. laShowItem(uil,c2,This,"name")->Expand=1;
  1085. laShowItem(uil,c2,This,"remove")->Flags|=LA_UI_FLAGS_ICON;
  1086. laEndRow(uil,b);
  1087. laShowItem(uil,c2,This,"volume");
  1088. laShowSeparator(uil,c);
  1089. }
  1090. void laui_AudioChannels(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  1091. laColumn* c=laFirstColumn(uil); laUiItem* b;
  1092. b=laBeginRow(uil,c,0,0);
  1093. laShowItem(uil,c,0,"LA_new_channel");
  1094. laEndRow(uil,b);
  1095. // if horizontal look:
  1096. // laUiItem* g=laMakeGroup(uil,c,"Racks",0);{ g->Flags|=/*LA_UI_FLAGS_NO_GAP|LA_UI_FLAGS_NO_DECAL|*/LA_UI_FLAGS_NODE_CONTAINER;
  1097. // laUiList* gu=g->Page; laColumn* gc=laFirstColumn(gu); gu->HeightCoeff=-1; g->State=LA_UI_ACTIVE;
  1098. // laShowItemFull(gu,gc,0,"la.audio.channels",0,0,laui_AudioChannel,0)->Expand=5;
  1099. // }
  1100. laShowItemFull(uil,c,0,"la.audio.channels",0,0,laui_AudioChannel,0);
  1101. }
  1102. void* laget_FirstAudioDevice(void* unused1,void* unused2){
  1103. return MAIN.Audio->AudioDevices.pFirst;
  1104. }
  1105. void* laget_FirstSynth(void* unused1,void* unused2){
  1106. return MAIN.Audio->Synths.pFirst;
  1107. }
  1108. void* laget_FirstAudioChannel(void* unused1, void* unused2){
  1109. return MAIN.Audio->Channels.pFirst;
  1110. }
  1111. void lapost_Synth(laSynth* ss){
  1112. laSpinInit(&ss->Lock);
  1113. laRebuildPageEval(ss->Page);
  1114. }
  1115. int laget_SynthPlaying(laSynth* ss){
  1116. int play=0;
  1117. laSpinLock(&ss->Lock); play=ss->Playing; laSpinUnlock(&ss->Lock);
  1118. return play;
  1119. }
  1120. void laset_CurrentSynth(laAudio* a,laSynth* s){
  1121. memAssignRef(a,&a->CurrentSynth,s);
  1122. }
  1123. void laset_CurrentAudioDevice(laAudio* a,laAudioDevice* ad){
  1124. la_SelectAudioDevice(ad);
  1125. }
  1126. void laset_OutputSendChannel(laSynthNodeOutput* n,laAudioChannel* ac){
  1127. if(ac){ strSafeSet(&n->SendName, SSTR(ac->Name)); } else { strSafeSet(&n->SendName,""); }
  1128. laAudioChannel* outchannel = laGetAudioChannel(SSTR(n->SendName));
  1129. memAssignRef(n,&n->Send,outchannel);
  1130. }
  1131. void laset_OutputSendName(laSynthNodeOutput* n,char* name){
  1132. strSafeSet(&n->SendName,name);
  1133. laAudioChannel* outchannel = laGetAudioChannel(name);
  1134. memAssignRef(n,&n->Send,outchannel);
  1135. }
  1136. void laset_QuantizeEnabledKeys(laSynthNodeQuantize* n, int index, int val_UNUSED){
  1137. if(n->EnabledBits[index] & 0x1){ n->EnabledBits[index]=0; }
  1138. else{ n->EnabledBits[index]=1; }
  1139. }
  1140. void laset_AudioChannelMove(laAudioChannel* ac, int move){
  1141. if(move<0 && ac->Item.pPrev){ lstMoveUp(&MAIN.Audio->Channels, ac); laNotifyUsers("la.audio"); }
  1142. elif(move>0 && ac->Item.pNext){ lstMoveDown(&MAIN.Audio->Channels, ac); laNotifyUsers("la.audio"); }
  1143. }
  1144. void laset_SynthTriggerTrigger(laSynthNodeTrigger* n, int trig){
  1145. if(trig){ laSynthTriggerNew(n->Target); } n->iTrigger=trig;
  1146. }
  1147. void laset_MiniAudioBackend(void* unused, int backend){
  1148. laStopAudio();
  1149. ma_device_uninit(&MAIN.Audio->AudioDevice);
  1150. ma_context_uninit(&MAIN.Audio->MiniAudioContext);
  1151. MAIN.Audio->MiniAudioBackend = backend;
  1152. ma_backend _backends[1]; _backends[0] = MAIN.Audio->MiniAudioBackend; ma_backend* backends=_backends;
  1153. int numback=1;
  1154. if(backend==ma_backend_null){ numback=0; backends=0; }
  1155. if (ma_context_init(backends, numback, NULL, &MAIN.Audio->MiniAudioContext) != MA_SUCCESS) {
  1156. printf("Can't init miniaudio context\n"); MAIN.Audio->MiniAudioBackend=ma_backend_null;
  1157. }
  1158. laRefreshAudioDevices();
  1159. la_SelectAudioDevice(MAIN.Audio->AudioDevices.pFirst);
  1160. }
  1161. void la_AudioPreFrame(){
  1162. if(MAIN.GraphNeedsRebuild){ laRebuildSynthGraphs(1); }
  1163. }
  1164. void laInitAudio(){
  1165. laPropContainer* pc; laProp* p; laSubProp* sp;
  1166. laInitMiniAudio();
  1167. laRegisterUiTemplate("LAUI_synthesizers","Synthesizers",laui_Synthersizers,lauidetached_Synthersizers,0,"Audio",0,0,0);
  1168. laRegisterUiTemplate("LAUI_audio_channels","Mixer",laui_AudioChannels,0,0,0,0,0,0);
  1169. laCreateOperatorType("LA_new_synth", "New Synthesizer", "Add a synthesizer",0,0,0,OPINV_ShedNewSynth,0,'+',0);
  1170. laCreateOperatorType("LA_remove_synth", "Remove Synthesizer", "Remove a synthesizer",OPCHK_IslaSynth,0,0,OPINV_ShedRemoveSynth,OPMOD_FinishOnData,L'🗴',0)
  1171. ->UiDefine=laui_RemoveSynth;
  1172. laCreateOperatorType("LA_synth_play", "Play Synthesizer", "Play a synthesizer",OPCHK_IslaSynth,0,0,OPINV_SynthPlay,0,0,0);
  1173. laCreateOperatorType("LA_synth_trigger_new", "Trigger New", "Trigger a new polyphonic note",OPCHK_IslaSynth,0,0,OPINV_SynthTriggerNew,0,0,0);
  1174. laCreateOperatorType("LA_refresh_audio_devices", "Refresh Audio Devices", "Enumerate audio devices for selection",0,0,0,OPINV_RefreshAudioDevices,0,U'🗘',0);
  1175. laCreateOperatorType("LA_new_channel", "New Channel", "Add an audio channel",0,0,0,OPINV_ShedNewAudioChannel,0,'+',0);
  1176. laCreateOperatorType("LA_remove_channel", "Remove Channel", "Remove an audio channel",OPCHK_IslaAudioChannel,0,0,OPINV_ShedRemoveAudioChannel,OPMOD_FinishOnData,L'🗴',0)
  1177. ->UiDefine=laui_RemoveAudioChannel;
  1178. pc = laAddPropertyContainer("la_audio_device","LaGUI Audio Device","LaGUI enumerated audio device",0,0,sizeof(laAudioDevice),0,0,1);{
  1179. laAddStringProperty(pc,"name","Name","Name of the audio device",0,0,0,0,1,offsetof(laAudioDevice,Name),0,0,0,0,LA_AS_IDENTIFIER);
  1180. }
  1181. pc = laAddPropertyContainer("la_synth", "LaGUI Synthesizer", "LaGUI synthesizer", 0,0,sizeof(laSynth),lapost_Synth,0,2);{
  1182. LA_PC_SYNTH=pc;
  1183. laAddStringProperty(pc,"name","Name","Name of the synthesizer",0,0,0,0,1,offsetof(laSynth,Name),0,0,0,0,LA_AS_IDENTIFIER);
  1184. laAddSubGroup(pc, "page", "Page", "Rack page","la_rack_page",0,0,0,offsetof(laSynth,Page),0,0,0,0,0,0,0,LA_UDF_SINGLE|LA_HIDE_IN_SAVE);
  1185. p=laAddEnumProperty(pc,"playing","Playing","Synth is playing",0,0,0,0,0,-1,laget_SynthPlaying,0,0,0,0,0,0,0,0,LA_READ_ONLY);
  1186. laAddEnumItemAs(p,"IDLE","Idle","Synth is not playing",0,0);
  1187. laAddEnumItemAs(p,"PLAYING","Playing","Synth is playing",1,0);
  1188. laAddFloatProperty(pc,"length","Length","Length of this sound",0,0,"s",10,0,0,5,0,offsetof(laSynth,Length),0,0,0,0,0,0,0,0,0,0,0);
  1189. p=laAddEnumProperty(pc,"poly","Polyphonic","Whether this synth supports polyphonic triggering",0,0,0,0,0,offsetof(laSynth,Poly),0,0,0,0,0,0,0,0,0,0);
  1190. p->ElementBytes=2;
  1191. laAddEnumItemAs(p,"MONO","Mono","Synth is monophonic",0,0);
  1192. laAddEnumItemAs(p,"POLY","Poly","Synth is polyphonic",1,0);
  1193. laAddIntProperty(pc,"max_poly","Max Poly","Max polyphonic sound count",0,0,0,16,0,0,0,0,offsetof(laSynth,MaxPoly),0,0,0,0,0,0,0,0,0,0,0)->ElementBytes=2;
  1194. laAddOperatorProperty(pc,"remove_synth","Remove Synth", "Remove synth", "LA_remove_synth", L'🗴', 0);
  1195. laAddOperatorProperty(pc,"play","Play Synth", "Play synth", "LA_synth_play", 0, 0);
  1196. laAddOperatorProperty(pc,"trigger","Trigger", "Trigger a new polyphonic node", "LA_synth_trigger_new", 0, 0);
  1197. }
  1198. pc = laAddPropertyContainer("la_audio_channel", "LaGUI Audio Channel", "LaGUI Audio Channel", 0,0,sizeof(laAudioChannel),0,0,2);{
  1199. LA_PC_CHANNEL=pc;
  1200. laAddStringProperty(pc,"name","Name","Name of the channel",0,0,0,0,1,offsetof(laAudioChannel,Name),0,0,0,0,LA_AS_IDENTIFIER);
  1201. laAddFloatProperty(pc,"volume","Volume","Volume of this channel",0,0,0,15,0,0.05,0,0,offsetof(laAudioChannel,Volume),0,0,0,0,0,0,0,0,0,0,0);
  1202. laAddOperatorProperty(pc,"remove","Remove Channel", "Remove this channel", "LA_remove_channel", L'🗴', 0);
  1203. laAddIntProperty(pc,"__move","Move Slider","Move Slider",LA_WIDGET_HEIGHT_ADJUSTER,0,0,0,0,0,0,0,0,0,laset_AudioChannelMove,0,0,0,0,0,0,0,0,LA_UDF_IGNORE);
  1204. }
  1205. pc=laAddPropertyContainer("la_node_synth_input", "Synth Input Node", "Synthesizer time and trigger input",0,laui_InputNode,sizeof(laSynthNodeInput),lapost_Node,0,1);
  1206. LA_PC_IDN_INPUT=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1207. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1208. laAddSubGroup(pc,"out_time", "Out Time","Time output","la_out_socket",0,0,0,offsetof(laSynthNodeInput,OutTime),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1209. laAddSubGroup(pc,"out_trigger", "Out Trigger","Trigger output","la_out_socket",0,0,0,offsetof(laSynthNodeInput,OutTrigger),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1210. laAddSubGroup(pc,"out_l", "Out Left","Capture left","la_out_socket",0,0,0,offsetof(laSynthNodeInput,OutL),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1211. laAddSubGroup(pc,"out_r", "Out Right","Capture right","la_out_socket",0,0,0,offsetof(laSynthNodeInput,OutR),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1212. pc=laAddPropertyContainer("la_node_synth_pulse", "Synth Pulse Node", "Pulse generate node for synth",0,laui_PulseNode,sizeof(laSynthNodePulse),lapost_Node,0,1);
  1213. LA_PC_IDN_PULSE=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1214. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1215. laAddSubGroup(pc,"out", "Out","Pulse output","la_out_socket",0,0,0,offsetof(laSynthNodePulse,Out),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1216. laAddSubGroup(pc,"in_trigger", "In Trigger","Trigger input","la_in_socket",0,0,0,offsetof(laSynthNodePulse,InTrigger),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1217. laAddSubGroup(pc,"in_width", "In Width","Width input","la_in_socket",0,0,0,offsetof(laSynthNodePulse,InWidth),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1218. laAddSubGroup(pc,"in_gate", "In Gate","Gate input","la_in_socket",0,0,0,offsetof(laSynthNodePulse,InGate),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1219. laAddFloatProperty(pc,"influence","Influence","Influence of the width input",LA_WIDGET_KNOB,0,0,1,-1,0.01,0,0,offsetof(laSynthNodePulse,rInfluence),0,0,0,0,0,0,0,0,0,0,0);
  1220. laAddFloatProperty(pc,"width","Width","Width of the pulse",0,0,0,10,0,0.1,0,0,offsetof(laSynthNodePulse,rWidth),0,0,0,0,0,0,0,0,0,0,0);
  1221. laAddFloatProperty(pc,"gate","Gate","Gate of the trigger",0,0,0,10,-10,0.1,0,0,offsetof(laSynthNodePulse,rGate),0,0,0,0,0,0,0,0,0,0,0);
  1222. p=laAddEnumProperty(pc,"trigger","Trigger","Trigger the envelope",LA_WIDGET_ENUM_CYCLE,0,0,0,0,offsetof(laSynthNodePulse,iTrigger),0,0,0,0,0,0,0,0,0,0);
  1223. laAddEnumItemAs(p,"IDLE","Idle","Trigger idle",0,0);
  1224. laAddEnumItemAs(p,"TRIG","Trigger","Trigger active",1,0);
  1225. pc=laAddPropertyContainer("la_node_synth_fm", "FM OSC Node", "Osilliator node with frequency modulation",0,laui_FMNode,sizeof(laSynthNodeFM),lapost_Node,0,1);
  1226. LA_PC_IDN_FM=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1227. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1228. laAddSubGroup(pc,"in_frequency", "In Frequency","Input frequency","la_in_socket",0,0,0,offsetof(laSynthNodeFM,InFrequency),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1229. laAddSubGroup(pc,"out", "Out","Output","la_out_socket",0,0,0,offsetof(laSynthNodeFM,Out),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1230. laAddFloatProperty(pc,"frequency","Frequency","Frequency of the oscilliator",0,0,0,10,0,0.1,0,0,offsetof(laSynthNodeFM,Frequency),0,0,0,0,0,0,0,0,0,0,0);
  1231. laAddFloatProperty(pc,"influence","Influence","Influence of the molulation input",LA_WIDGET_KNOB,0,0,1,-1,0.01,0,0,offsetof(laSynthNodeFM,rInfluence),0,0,0,0,0,0,0,0,0,0,0);
  1232. p=laAddEnumProperty(pc,"slow","Slow","Low frequency oscilliator",LA_WIDGET_ENUM_HIGHLIGHT,0,0,0,0,offsetof(laSynthNodeFM,Slow),0,0,0,0,0,0,0,0,0,0);
  1233. laAddEnumItemAs(p,"NONE","None","Regular frequency range",0,0);
  1234. laAddEnumItemAs(p,"SLOW","Slow","Slow frequency range",1,0);
  1235. pc=laAddPropertyContainer("la_node_synth_vca", "VCA Node", "Voltage controlled amplifier",0,laui_VCANode,sizeof(laSynthNodeVCA),lapost_Node,0,1);
  1236. LA_PC_IDN_VCA=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1237. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1238. laAddSubGroup(pc,"in_amp", "In Amptitude","Input amptitude","la_in_socket",0,0,0,offsetof(laSynthNodeVCA,InAmp),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1239. laAddSubGroup(pc,"in", "Input","Input","la_in_socket",0,0,0,offsetof(laSynthNodeVCA,In),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1240. laAddSubGroup(pc,"out", "Out","Output","la_out_socket",0,0,0,offsetof(laSynthNodeVCA,Out),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1241. laAddFloatProperty(pc,"amp","Amptitude","Amptitude of the output signal",0,0,0,10,0,0.1,0,0,offsetof(laSynthNodeVCA,Amp),0,0,0,0,0,0,0,0,0,0,0);
  1242. laAddFloatProperty(pc,"influence","Influence","Influence of the modulating signal",LA_WIDGET_KNOB,0,0,1,-1,0.01,0,0,offsetof(laSynthNodeVCA,rInfluence),0,0,0,0,0,0,0,0,0,0,0);
  1243. pc=laAddPropertyContainer("la_node_synth_noise", "Noise Node", "Noise node",0,laui_NoiseNode,sizeof(laSynthNodeNoise),lapost_Node,0,1);
  1244. LA_PC_IDN_NOISE=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1245. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1246. laAddSubGroup(pc,"out_white", "White","White noise output","la_out_socket",0,0,0,offsetof(laSynthNodeNoise,OutWhite),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1247. laAddSubGroup(pc,"out_pink", "Pink","Pinknoise output","la_out_socket",0,0,0,offsetof(laSynthNodeNoise,OutPink),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1248. pc=laAddPropertyContainer("la_node_synth_scope", "Scope Node", "Scope for synthesizer",0,laui_ScopeNode,sizeof(laSynthNodeScope),lapost_Node,0,1);
  1249. LA_PC_IDN_SCOPE=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1250. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1251. laAddSubGroup(pc,"scope", "Scope","Synth scope","la_node_synth_scope",0,LA_WIDGET_SCOPE,0,-1,0,laget_InstanceSelf,0,0,0,0,0,LA_UDF_REFER|LA_UDF_IGNORE);
  1252. laAddSubGroup(pc,"in1", "In 1","Input Channel 1","la_in_socket",0,0,0,offsetof(laSynthNodeScope,In1),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1253. laAddSubGroup(pc,"in2", "In 2","Input Channel 2","la_in_socket",0,0,0,offsetof(laSynthNodeScope,In2),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1254. p=laAddEnumProperty(pc,"time","Time","Time factor of the scope",0,0,0,5,0,offsetof(laSynthNodeScope,Time),0,0,0,0,0,0,0,0,0,0);
  1255. #define _STR(a) #a
  1256. #define ADD_TIME_FACTOR(a) laAddEnumItemAs(p,"FAC"_STR(a),_STR(a),"^"_STR(a)" time",a,0);
  1257. ADD_TIME_FACTOR(1) ADD_TIME_FACTOR(2) ADD_TIME_FACTOR(3) ADD_TIME_FACTOR(4) ADD_TIME_FACTOR(5)
  1258. ADD_TIME_FACTOR(6) ADD_TIME_FACTOR(7) ADD_TIME_FACTOR(8) ADD_TIME_FACTOR(9) ADD_TIME_FACTOR(10)
  1259. #undef ADD_TIME_FACTOR
  1260. p=laAddEnumProperty(pc,"gain1","Gain 1","Channel 1 Gain",0,0,0,5,0,offsetof(laSynthNodeScope,Gain1),0,0,0,0,0,0,0,0,0,0);
  1261. #define ADD_GAIN(a) laAddEnumItemAs(p,"GAIN"_STR(a),_STR(a),"^"_STR(a)" gain",a,0);
  1262. #define ADD_GAIN_S(a,s) laAddEnumItemAs(p,"GAIN"_STR(a),s,"^"s" gain",a,0);
  1263. ADD_GAIN_S(-1,"¼") ADD_GAIN_S(0,"½") ADD_GAIN(1) ADD_GAIN(2) ADD_GAIN(3) ADD_GAIN(4) ADD_GAIN(5) ADD_GAIN(6)
  1264. p=laAddEnumProperty(pc,"gain2","Gain 2","Channel 2 Gain",0,0,0,5,0,offsetof(laSynthNodeScope,Gain2),0,0,0,0,0,0,0,0,0,0);
  1265. ADD_GAIN_S(-1,"¼") ADD_GAIN_S(0,"½") ADD_GAIN(1) ADD_GAIN(2) ADD_GAIN(3) ADD_GAIN(4) ADD_GAIN(5) ADD_GAIN(6)
  1266. #undef ADD_GAIN
  1267. #undef ADD_GAIN_S
  1268. laAddFloatProperty(pc,"offset1","Offset 1","Channel 1 offset",0,0,0,10,-10,0.1,0,0,offsetof(laSynthNodeScope,Offset1),0,0,0,0,0,0,0,0,0,0,0);
  1269. laAddFloatProperty(pc,"offset2","Offset 2","Channel 2 offset",0,0,0,10,-10,0.1,0,0,offsetof(laSynthNodeScope,Offset2),0,0,0,0,0,0,0,0,0,0,0);
  1270. laAddFloatProperty(pc,"bright1","Brightness 1","Channel 1 brightness",0,0,0,1,0,0.1,0,0,offsetof(laSynthNodeScope,Brightness1),0,0,0,0,0,0,0,0,0,0,0);
  1271. laAddFloatProperty(pc,"bright2","Brightness 2","Channel 2 brightness",0,0,0,1,0,0.1,0,0,offsetof(laSynthNodeScope,Brightness2),0,0,0,0,0,0,0,0,0,0,0);
  1272. pc=laAddPropertyContainer("la_node_synth_output", "Output Node", "Sound output to system",0,laui_OutputNode,sizeof(laSynthNodeOutput),lapost_Node,0,1);
  1273. LA_PC_IDN_OUTPUT=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1274. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1275. laAddSubGroup(pc,"in_l", "Input Left","Input sound left channel","la_in_socket",0,0,0,offsetof(laSynthNodeOutput,InL),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1276. laAddSubGroup(pc,"in_r", "Input Right","Input sound right channel","la_in_socket",0,0,0,offsetof(laSynthNodeOutput,InR),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1277. laAddStringProperty(pc,"send_channel_name","Channel Name","Channel name of this send target",0,0,0,0,1,offsetof(laSynthNodeOutput,SendName),0,0,laset_OutputSendName,0,0);
  1278. laAddSubGroup(pc,"send_channel_selector","Send","Send to channel","la_audio_channel",0,0,0,-1,laget_FirstAudioChannel,0,laget_ListNext,laset_OutputSendChannel,0,0,0,LA_UDF_REFER|LA_UDF_IGNORE);
  1279. pc=laAddPropertyContainer("la_node_synth_envelope", "Envelope Node", "Sound envelope",0,laui_EnvelopeNode,sizeof(laSynthNodeEnvelope),lapost_Node,0,1);
  1280. LA_PC_IDN_ENVELOPE=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1281. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1282. laAddSubGroup(pc,"in_gate", "Gate","Gate input","la_in_socket",0,0,0,offsetof(laSynthNodeEnvelope,Gate),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1283. laAddSubGroup(pc,"in_attack", "Attack","Attack input","la_in_socket",0,0,0,offsetof(laSynthNodeEnvelope,Attack),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1284. laAddSubGroup(pc,"in_delay", "Delay","Delay input","la_in_socket",0,0,0,offsetof(laSynthNodeEnvelope,Delay),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1285. laAddSubGroup(pc,"in_sustain", "Sustain","Sustain input","la_in_socket",0,0,0,offsetof(laSynthNodeEnvelope,Sustain),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1286. laAddSubGroup(pc,"in_release", "Release","Release input","la_in_socket",0,0,0,offsetof(laSynthNodeEnvelope,Release),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1287. laAddSubGroup(pc,"in_trigger", "Trigger","Trigger input","la_in_socket",0,0,0,offsetof(laSynthNodeEnvelope,Trigger),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1288. laAddSubGroup(pc,"in_restart", "Restart","Restart input","la_in_socket",0,0,0,offsetof(laSynthNodeEnvelope,Restart),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1289. laAddSubGroup(pc,"out", "Output","Envelope output","la_out_socket",0,0,0,offsetof(laSynthNodeEnvelope,Out),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1290. laAddFloatProperty(pc,"gate","Gate","Gate for the trigger",0,0,0,10,-10,0.01,0,0,offsetof(laSynthNodeEnvelope,rGate),0,0,0,0,0,0,0,0,0,0,0);
  1291. laAddFloatProperty(pc,"attack","Attack","Attack value",0,0,0,10,0,0.01,0,0,offsetof(laSynthNodeEnvelope,rAttack),0,0,0,0,0,0,0,0,0,0,0);
  1292. laAddFloatProperty(pc,"delay","Delay","Delay value",0,0,0,10,0,0.01,0,0,offsetof(laSynthNodeEnvelope,rDelay),0,0,0,0,0,0,0,0,0,0,0);
  1293. laAddFloatProperty(pc,"sustain","Sustain","Sustain value",0,0,0,10,0,0.01,0,0,offsetof(laSynthNodeEnvelope,rSustain),0,0,0,0,0,0,0,0,0,0,0);
  1294. laAddFloatProperty(pc,"release","Release","Release value",0,0,0,10,0,0.01,0,0,offsetof(laSynthNodeEnvelope,rRelease),0,0,0,0,0,0,0,0,0,0,0);
  1295. laAddFloatProperty(pc,"iattack","Attack Influence","Attack modulation influence value",LA_WIDGET_KNOB,0,0,1,-1,0.01,0,0,offsetof(laSynthNodeEnvelope,iAttack),0,0,0,0,0,0,0,0,0,0,0);
  1296. laAddFloatProperty(pc,"idelay","Delay Influence","Delay modulation influence value",LA_WIDGET_KNOB,0,0,1,-1,0.01,0,0,offsetof(laSynthNodeEnvelope,iDelay),0,0,0,0,0,0,0,0,0,0,0);
  1297. laAddFloatProperty(pc,"isustain","Sustain Influence","Sustain modulation influence value",LA_WIDGET_KNOB,0,0,1,-1,0.01,0,0,offsetof(laSynthNodeEnvelope,iSustain),0,0,0,0,0,0,0,0,0,0,0);
  1298. laAddFloatProperty(pc,"irelease","Release Influence","Release modulation influence value",LA_WIDGET_KNOB,0,0,1,-1,0.01,0,0,offsetof(laSynthNodeEnvelope,iRelease),0,0,0,0,0,0,0,0,0,0,0);
  1299. p=laAddEnumProperty(pc,"trigger","Trigger","Trigger the envelope",LA_WIDGET_ENUM_CYCLE,0,0,0,0,offsetof(laSynthNodeEnvelope,bTrigger),0,0,0,0,0,0,0,0,0,0);
  1300. laAddEnumItemAs(p,"IDLE","Idle","Trigger idle",0,0);
  1301. laAddEnumItemAs(p,"TRIG","Trigger","Trigger active",1,0);
  1302. pc=laAddPropertyContainer("la_node_synth_driver", "Synth Driver Node", "Control playing status of the synth",0,laui_SynthDriverNode,sizeof(laSynthNodeDriver),lapost_Node,0,1);
  1303. LA_PC_IDN_SYNTH_DRIVER=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1304. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1305. laAddSubGroup(pc,"prev", "Previous","Previous node","la_in_socket",0,0,0,offsetof(laSynthNodeDriver,Prev),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1306. laAddSubGroup(pc,"next", "Next","Next node","la_out_socket",0,0,0,offsetof(laSynthNodeDriver,Next),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1307. laAddSubGroup(pc,"in_transport", "In Transport","Transport input","la_in_socket",0,0,0,offsetof(laSynthNodeDriver,InTransport),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1308. laAddSubGroup(pc,"in_reset", "In Reset","Reset input (trigger on rising edge)","la_in_socket",0,0,0,offsetof(laSynthNodeDriver,InReset),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1309. p=laAddEnumProperty(pc,"transport","Transport","Play or stop the synth playing",LA_WIDGET_ENUM_HIGHLIGHT,0,0,0,0,offsetof(laSynthNodeDriver,iTransport),0,0,0,0,0,0,0,0,0,0);
  1310. laAddEnumItemAs(p,"STOPPED","Stopped","Synth is stopped",0,0);
  1311. laAddEnumItemAs(p,"PLAYING","Playing","Synth is playing",1,0);
  1312. p=laAddEnumProperty(pc,"reset","Reset","Reset Synth",LA_WIDGET_ENUM_HIGHLIGHT,0,0,0,0,offsetof(laSynthNodeDriver,iReset),0,0,0,0,0,0,0,0,0,0);
  1313. laAddEnumItemAs(p,"IDLE","Idle","Trigger idle",0,0);
  1314. laAddEnumItemAs(p,"TRIG","Trigger","Trigger active",1,0);
  1315. laAddSubGroup(pc,"target","Target","Target synth to control","la_synth",0,0,0,offsetof(laSynthNodeDriver,Target),laget_FirstSynth,0,laget_ListNext,0,0,0,0,LA_UDF_REFER);
  1316. pc=laAddPropertyContainer("la_node_synth_trigger", "Synth Trigger Node", "Trigger a new polyphonic note",0,laui_SynthTriggerNode,sizeof(laSynthNodeTrigger),lapost_Node,0,1);
  1317. LA_PC_IDN_SYNTH_TRIGGER=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1318. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1319. laAddSubGroup(pc,"prev", "Previous","Previous node","la_in_socket",0,0,0,offsetof(laSynthNodeTrigger,Prev),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1320. laAddSubGroup(pc,"next", "Next","Next node","la_out_socket",0,0,0,offsetof(laSynthNodeTrigger,Next),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1321. laAddSubGroup(pc,"in_trigger", "In Trigger","Trigger input","la_in_socket",0,0,0,offsetof(laSynthNodeTrigger,InTrigger),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1322. p=laAddEnumProperty(pc,"trigger","Trigger","Trigger new note",LA_WIDGET_ENUM_HIGHLIGHT,0,0,0,0,offsetof(laSynthNodeTrigger,iTrigger),0,laset_SynthTriggerTrigger,0,0,0,0,0,0,0,0);
  1323. laAddEnumItemAs(p,"IDLE","Idle","Trigger idle",0,0);
  1324. laAddEnumItemAs(p,"TRIG","Trigger","Trigger active",1,0);
  1325. p=laAddEnumProperty(pc,"trigger_edge","Edge","Trigger on rising edge",LA_WIDGET_ENUM_HIGHLIGHT,0,0,0,0,offsetof(laSynthNodeTrigger,TriggerEdge),0,0,0,0,0,0,0,0,0,0);
  1326. laAddEnumItemAs(p,"LEVEL","Level","Trigger on high level",0,'-');
  1327. laAddEnumItemAs(p,"RISING_EDGE","Rising Edge","Trigger on rising edge",1,U'⮥');
  1328. laAddSubGroup(pc,"target","Target","Target synth to trigger","la_synth",0,0,0,offsetof(laSynthNodeTrigger,Target),laget_FirstSynth,0,laget_ListNext,0,0,0,0,LA_UDF_REFER);
  1329. pc=laAddPropertyContainer("la_node_synth_quantize", "Quantize Node", "Quantize control voltages",0,laui_QuantizeNode,sizeof(laSynthNodeQuantize),lapost_Node,0,1);
  1330. LA_PC_IDN_QUANTIZE=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1331. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1332. laAddSubGroup(pc,"in", "Input","CV input","la_in_socket",0,0,0,offsetof(laSynthNodeQuantize,In),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1333. laAddSubGroup(pc,"out", "Output","CV output","la_out_socket",0,0,0,offsetof(laSynthNodeQuantize,Out),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1334. p=laAddEnumProperty(pc,"enabled_keys","Keys","Enabled keys",LA_WIDGET_ENUM_CYCLE,0,0,0,0,offsetof(laSynthNodeQuantize,EnabledBits),0,0,12,0,laset_QuantizeEnabledKeys,0,0,0,0,0);
  1335. laAddEnumItemAs(p,"DISABLED","Disabled","Key is disabled",0,' ');
  1336. laAddEnumItemAs(p,"ENABLED","Enabled","Key is enabled",1,' ');
  1337. laAddEnumItemAs(p,"OUTPUT","Outputting","Key is Outputting",3,U'🌑');
  1338. LA_IDN_REGISTER("Inputs",U'🔌',LA_IDN_INPUT, LA_PC_IDN_INPUT, IDN_Input, laSynthNodeInput);
  1339. LA_IDN_REGISTER("Pulse",U'⎍',LA_IDN_PULSE, LA_PC_IDN_PULSE, IDN_Pulse, laSynthNodePulse);
  1340. LA_IDN_REGISTER("VCO",'f',LA_IDN_FM, LA_PC_IDN_FM, IDN_FM, laSynthNodeFM);
  1341. LA_IDN_REGISTER("VCA",'a',LA_IDN_VCA, LA_PC_IDN_VCA, IDN_VCA, laSynthNodeVCA);
  1342. LA_IDN_REGISTER("Noise",'~',LA_IDN_NOISE, LA_PC_IDN_NOISE, IDN_Noise, laSynthNodeNoise);
  1343. LA_IDN_REGISTER("Scope",'s',LA_IDN_SCOPE, LA_PC_IDN_SCOPE, IDN_Scope, laSynthNodeScope);
  1344. LA_IDN_REGISTER("Sound Output",U'🕪',LA_IDN_OUTPUT, LA_PC_IDN_OUTPUT, IDN_Output, laSynthNodeOutput);
  1345. LA_IDN_REGISTER("Envelope",U'^',LA_IDN_ENVELOPE, LA_PC_IDN_ENVELOPE, IDN_Envelope, laSynthNodeEnvelope);
  1346. LA_IDN_REGISTER("Quantize",U'#',LA_IDN_QUANTIZE, LA_PC_IDN_QUANTIZE, IDN_Quantize, laSynthNodeQuantize);
  1347. LA_IDN_REGISTER("Sound Player",U'⏯',LA_IDN_SYNTH_DRIVER, LA_PC_IDN_SYNTH_DRIVER, IDN_SynthDriver, laSynthNodeDriver);
  1348. LA_IDN_REGISTER("Sound Trigger",U'🎵',LA_IDN_SYNTH_TRIGGER, LA_PC_IDN_SYNTH_TRIGGER, IDN_SynthTrigger, laSynthNodeTrigger);
  1349. LA_NODE_CATEGORY_SYNTHESIZER=laEnsureNodeCategory("OSC",0,LA_RACK_TYPE_AUDIO);
  1350. LA_NODE_CATEGORY_SYSTEM_SOUND=laEnsureNodeCategory("System",0,LA_RACK_TYPE_AUDIO);
  1351. laNodeCategoryAddNodeTypes(LA_NODE_CATEGORY_SYNTHESIZER,
  1352. &LA_IDN_INPUT,&LA_IDN_PULSE,&LA_IDN_FM,&LA_IDN_NOISE,&LA_IDN_VCA,&LA_IDN_ENVELOPE,&LA_IDN_QUANTIZE,&LA_IDN_SCOPE,&LA_IDN_SYNTH_TRIGGER,0LL);
  1353. laNodeCategoryAddNodeTypes(LA_NODE_CATEGORY_SYSTEM_SOUND, &LA_IDN_OUTPUT,0LL);
  1354. LA_NODE_CATEGORY_DRIVER=laEnsureNodeCategory("Driver",0,LA_RACK_TYPE_DRIVER);
  1355. laNodeCategoryAddNodeTypes(LA_NODE_CATEGORY_DRIVER, &LA_IDN_SYNTH_DRIVER, &LA_IDN_SYNTH_TRIGGER,0LL);
  1356. }