*/}}

la_audio.c 62 KB

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