libcm is a C development framework with an emphasis on audio signal processing applications.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

cmDspPgm.c 122KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865
  1. #include "cmPrefix.h"
  2. #include "cmGlobal.h"
  3. #include "cmFloatTypes.h"
  4. #include "cmRpt.h"
  5. #include "cmErr.h"
  6. #include "cmCtx.h"
  7. #include "cmMem.h"
  8. #include "cmMallocDebug.h"
  9. #include "cmLinkedHeap.h"
  10. #include "cmFileSys.h"
  11. #include "cmSymTbl.h"
  12. #include "cmJson.h"
  13. #include "cmPrefs.h"
  14. #include "cmDspValue.h"
  15. #include "cmMsgProtocol.h"
  16. #include "cmThread.h"
  17. #include "cmUdpPort.h"
  18. #include "cmUdpNet.h"
  19. #include "cmTime.h"
  20. #include "cmAudioSys.h"
  21. #include "cmProcObj.h"
  22. #include "cmDspCtx.h"
  23. #include "cmDspClass.h"
  24. #include "cmDspSys.h"
  25. #include "cmDspPgm.h"
  26. #include "cmDspPgmPP.h"
  27. #include "cmDspPgmKr.h"
  28. cmDspRC_t _cmDspSysPgm_SyncRecd( cmDspSysH_t h, void** userPtrPtr )
  29. {
  30. cmDspRC_t rc = kOkDspRC;
  31. unsigned audioFileBits = 24;
  32. cmDspInst_t* ai0p = cmDspSysAllocInst(h,"AudioIn", NULL, 1, 0 );
  33. cmDspInst_t* ai1p = cmDspSysAllocInst(h,"AudioIn", NULL, 1, 1 );
  34. cmDspInst_t* mip = cmDspSysAllocInst(h,"MidiIn", NULL, 0 );
  35. cmDspInst_t* srp = cmDspSysAllocInst(h,"SyncRecd",NULL, 3, "/home/kevin/temp/kr/sr","sr","audio",audioFileBits);
  36. cmDspInst_t* am0p = cmDspSysAllocInst(h,"AMeter", "Left", 0);
  37. cmDspInst_t* am1p = cmDspSysAllocInst(h,"AMeter", "Right",0);
  38. cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut", NULL, 1, 0 );
  39. cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut", NULL, 1, 1 );
  40. cmDspInst_t* chk = cmDspSysAllocInst(h,"Checkbox","recd", 5, "Recd","open","close", 1.0, 0.0);
  41. cmDspInst_t* gain0 = cmDspSysAllocInst(h,"Scalar", "In Gain-0", 5, kNumberDuiId, 0.0, 10.0,0.01, 1.0 );
  42. cmDspInst_t* gain1 = cmDspSysAllocInst(h,"Scalar", "In Gain-1", 5, kNumberDuiId, 0.0, 10.0,0.01, 1.0 );
  43. // check for allocation errors
  44. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  45. goto errLabel;
  46. cmDspSysInstallCb(h, mip, "status", srp, "status", NULL);
  47. cmDspSysInstallCb(h, mip, "d0", srp, "d0", NULL);
  48. cmDspSysInstallCb(h, mip, "d1", srp, "d1", NULL);
  49. cmDspSysInstallCb(h, mip, "sec", srp, "sec", NULL);
  50. cmDspSysInstallCb(h, mip, "nsec", srp, "nsec", NULL);
  51. cmDspSysInstallCb(h, chk, "sym", srp, "cmd", NULL);
  52. cmDspSysInstallCb(h, gain0, "val", ai0p, "gain", NULL);
  53. cmDspSysInstallCb(h, gain1, "val", ai1p, "gain", NULL);
  54. cmDspSysConnectAudio(h, ai0p, "out", srp, "ain-0");
  55. cmDspSysConnectAudio(h, ai1p, "out", srp, "ain-1");
  56. cmDspSysConnectAudio(h, ai0p, "out", am0p, "in");
  57. cmDspSysConnectAudio(h, ai1p, "out", am1p, "in");
  58. cmDspSysConnectAudio(h, ai0p, "out", ao0p, "in");
  59. cmDspSysConnectAudio(h, ai1p, "out", ao1p, "in");
  60. errLabel:
  61. return rc;
  62. }
  63. cmDspRC_t _cmDspSysPgm_MidiFilePlay( cmDspSysH_t h, void** userPtrPtr )
  64. {
  65. cmDspRC_t rc = kOkDspRC;
  66. const cmChar_t* deviceName = "Fastlane";
  67. const cmChar_t* portName = "Fastlane MIDI A";
  68. //const cmChar_t* deviceName = "DKV-M4";
  69. //const cmChar_t* portName = "DKV-M4 MIDI 1";
  70. const char* fn0 = "media/midi/kriesberg/part2/piano_score_part_2_draft_1_master_m191-195.mid";
  71. const cmChar_t* fn = cmFsMakeFn(cmFsUserDir(),fn0,NULL,NULL );
  72. cmDspInst_t* fnp = cmDspSysAllocInst(h,"Fname", NULL, 3, false,"MIDI Files (*.mid)\tMIDI Files (*.{mid})",fn);
  73. cmDspInst_t* ignp = cmDspSysAllocInst( h,"Scalar", "In Gain", 5, kNumberDuiId, 0.0, 4.0, 0.01, 1.0);
  74. cmDspInst_t* ai0p = cmDspSysAllocInst(h,"AudioIn", NULL, 1, 2 );
  75. cmDspInst_t* ai1p = cmDspSysAllocInst(h,"AudioIn", NULL, 1, 3 );
  76. cmDspInst_t* mfp = cmDspSysAllocInst(h,"MidiFilePlay",NULL, 0 );
  77. cmDspInst_t* mop = cmDspSysAllocInst( h,"MidiOut", NULL, 2, deviceName, portName);
  78. cmDspInst_t* start = cmDspSysAllocInst( h,"Button", "start", 2, kButtonDuiId, 0.0 );
  79. cmDspInst_t* stop = cmDspSysAllocInst( h,"Button", "stop", 2, kButtonDuiId, 0.0 );
  80. cmDspInst_t* cont = cmDspSysAllocInst( h,"Button", "continue", 2, kButtonDuiId, 0.0 );
  81. cmDspInst_t* beg = cmDspSysAllocInst(h,"Scalar", "Beg Samp", 5, kNumberDuiId, 0.0, 1000000000.0, 1.0, 0.0 );
  82. cmDspInst_t* end = cmDspSysAllocInst(h,"Scalar", "End Samp", 5, kNumberDuiId, 0.0, 1000000000.0, 1.0, 1000000000.0 );
  83. cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 0 );
  84. cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 1 );
  85. cmDspInst_t* im0p = cmDspSysAllocInst(h,"AMeter","In 0", 0);
  86. cmDspInst_t* im1p = cmDspSysAllocInst(h,"AMeter","In 1", 0);
  87. cmDspInst_t* om0p = cmDspSysAllocInst(h,"AMeter","Out 0", 0);
  88. cmDspInst_t* om1p = cmDspSysAllocInst(h,"AMeter","Out 1",0);
  89. // check for allocation errors
  90. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  91. goto errLabel;
  92. cmDspSysInstallCb( h, fnp, "out", mfp, "fn", NULL);
  93. cmDspSysInstallCb( h, start, "sym", beg, "send", NULL);
  94. cmDspSysInstallCb( h, beg, "val", mfp, "bsi", NULL);
  95. cmDspSysInstallCb( h, start, "sym", end, "send", NULL);
  96. cmDspSysInstallCb( h, end, "val", mfp, "esi", NULL);
  97. cmDspSysInstallCb( h, start, "sym", mfp, "sel", NULL);
  98. cmDspSysInstallCb( h, stop, "sym", mfp, "sel", NULL);
  99. cmDspSysInstallCb( h, cont, "sym", mfp, "sel", NULL);
  100. cmDspSysInstallCb( h, mfp, "d1", mop, "d1", NULL);
  101. cmDspSysInstallCb( h, mfp, "d0", mop, "d0", NULL);
  102. cmDspSysInstallCb( h, mfp, "status", mop, "status", NULL);
  103. //cmDspSysConnectAudio(h, ai0p, "out", ao0p, "in");
  104. //cmDspSysConnectAudio(h, ai1p, "out", ao1p, "in");
  105. cmDspSysConnectAudio(h, ai0p, "out", im0p, "in"); //ain0 -> imtr0
  106. cmDspSysConnectAudio(h, ai1p, "out", im1p, "in"); //ain1 -> imtr1
  107. cmDspSysInstallCb( h, ignp,"val", ai0p, "gain", NULL); // igain -> ain0
  108. cmDspSysConnectAudio(h, ai0p,"out", ao0p, "in" ); // ain0 -> aout0
  109. cmDspSysConnectAudio(h, ai0p,"out", om0p, "in" ); // ain0 -> omtr0
  110. cmDspSysInstallCb( h, ignp,"val", ai1p, "gain", NULL); // igain -> ain1
  111. cmDspSysConnectAudio(h, ai1p,"out", ao1p, "in" ); // ain1 -> aout1
  112. cmDspSysConnectAudio(h, ai1p,"out", om1p, "in" ); // ain1 -> omtr1
  113. errLabel:
  114. cmFsFreeFn(fn);
  115. return rc;
  116. }
  117. cmDspRC_t _cmDspSysPgm_Test_Midi( cmDspSysH_t h, void** userPtrPtr )
  118. {
  119. cmDspRC_t rc = kOkDspRC;
  120. const cmChar_t* deviceName = "Fastlane";
  121. const cmChar_t* portName = "Fastlane MIDI A";
  122. #ifdef OS_OSX
  123. deviceName = "MOTU - FastLane USB";
  124. portName = "Port A";
  125. //deviceName = "RME - Fireface UFX (23148636)";
  126. //portName = "Port 2";
  127. #endif
  128. cmDspInst_t* sendBtn = cmDspSysAllocInst( h,"Button", "Send", 2, kButtonDuiId, 0.0 );
  129. cmDspInst_t* status = cmDspSysAllocInst( h,"Scalar", "Status", 5, kNumberDuiId, 0.0, 127.0, 1.0, 144.0);
  130. cmDspInst_t* d0 = cmDspSysAllocInst( h,"Scalar", "D0", 5, kNumberDuiId, 0.0, 127.0, 1.0, 64.0);
  131. cmDspInst_t* d1 = cmDspSysAllocInst( h,"Scalar", "D1", 5, kNumberDuiId, 0.0, 127.0, 1.0, 64.0);
  132. cmDspInst_t* midiOut = cmDspSysAllocInst( h,"MidiOut", NULL, 2, deviceName, portName);
  133. cmDspInst_t* midiIn = cmDspSysAllocInst( h,"MidiIn", NULL, 0 );
  134. //cmDspInst_t* printer = cmDspSysAllocInst( h,"Printer", NULL, 1, ">" );
  135. cmDspInst_t* prst = cmDspSysAllocInst( h,"Printer", NULL, 1, "st>" );
  136. cmDspInst_t* prd0 = cmDspSysAllocInst( h,"Printer", NULL, 1, "d0>" );
  137. cmDspInst_t* prd1 = cmDspSysAllocInst( h,"Printer", NULL, 1, "d1>" );
  138. // check for allocation errors
  139. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  140. goto errLabel;
  141. cmDspSysInstallCb( h, sendBtn, "out", d1, "send", NULL);
  142. cmDspSysInstallCb( h, sendBtn, "out", d0, "send", NULL);
  143. cmDspSysInstallCb( h, sendBtn, "out", status, "send", NULL);
  144. cmDspSysInstallCb( h, status, "val", midiOut, "status",NULL);
  145. cmDspSysInstallCb( h, d0, "val", midiOut, "d0", NULL);
  146. cmDspSysInstallCb( h, d1, "val", midiOut, "d1", NULL);
  147. cmDspSysInstallCb( h, midiIn, "status", prst, "in", NULL);
  148. cmDspSysInstallCb( h, midiIn, "d0", prd0, "in", NULL);
  149. cmDspSysInstallCb( h, midiIn, "d1", prd1, "in", NULL);
  150. //cmDspSysInstallCb( h, midiIn, "smpidx", printer, "in", NULL);
  151. errLabel:
  152. return rc;
  153. }
  154. cmDspRC_t _cmDspSysPgm_Stereo_Through( cmDspSysH_t h, void** userPtrPtr )
  155. {
  156. cmDspInst_t* ignp = cmDspSysAllocInst( h,"Scalar", "In Gain", 5, kNumberDuiId, 0.0, 4.0, 0.01, 1.0);
  157. //cmDspInst_t* ognp = cmDspSysAllocInst( h,"Scalar", "Out Gain", 5, kNumberDuiId, 0.0, 4.0, 0.01, 1.0);
  158. cmDspInst_t* hzp = cmDspSysAllocInst(h,"Scalar", "Hz", 5, kNumberDuiId, 0.0, 10.0, 0.001, 1.0);
  159. cmDspInst_t* php = cmDspSysAllocInst(h,"Phasor", NULL, 0 );
  160. cmDspInst_t* wtp = cmDspSysAllocInst(h,"WaveTable",NULL, 2, cmDspSysSampleRate(h), 2 );
  161. cmDspInst_t* ai0p = cmDspSysAllocInst(h,"AudioIn", NULL, 1, 2 );
  162. cmDspInst_t* ai1p = cmDspSysAllocInst(h,"AudioIn", NULL, 1, 3 );
  163. // MOTU Traveler: Use channels 2&3 (out plugs:3&4) because 0&1 do not show up on plugs 1&2.
  164. cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 0 );
  165. cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 1 );
  166. cmDspInst_t* im0p = cmDspSysAllocInst(h,"AMeter","In 0", 0);
  167. cmDspInst_t* im1p = cmDspSysAllocInst(h,"AMeter","In 1", 0);
  168. cmDspInst_t* om0p = cmDspSysAllocInst(h,"AMeter","Out 0", 0);
  169. cmDspInst_t* om1p = cmDspSysAllocInst(h,"AMeter","Out 1",0);
  170. //cmDspSysConnectAudio(h, ai0p, "out", ao0p, "in");
  171. //cmDspSysConnectAudio(h, ai1p, "out", ao1p, "in");
  172. cmDspSysConnectAudio(h, ai0p, "out", im0p, "in"); //ain0 -> imtr0
  173. cmDspSysConnectAudio(h, ai1p, "out", im1p, "in"); //ain1 -> imtr1
  174. if(0)
  175. {
  176. cmDspSysInstallCb( h, hzp, "val", php, "mult", NULL); // hz -> phs
  177. cmDspSysConnectAudio(h, php, "out", wtp, "phs" ); // phs -> wt
  178. cmDspSysConnectAudio(h, wtp, "out", ao0p, "in" ); // wt -> aout0
  179. cmDspSysConnectAudio(h, wtp, "out", om0p, "in" ); // wt -> omtr0
  180. }
  181. else
  182. {
  183. cmDspSysInstallCb( h, ignp,"val", ai0p, "gain", NULL); // igain -> ain0
  184. cmDspSysConnectAudio(h, ai0p,"out", ao0p, "in" ); // ain0 -> aout0
  185. cmDspSysConnectAudio(h, ai0p,"out", om0p, "in" ); // ain0 -> omtr0
  186. }
  187. cmDspSysInstallCb( h, ignp,"val", ai1p, "gain", NULL); // igain -> ain1
  188. cmDspSysConnectAudio(h, ai1p,"out", ao1p, "in" ); // ain1 -> aout1
  189. cmDspSysConnectAudio(h, ai1p,"out", om1p, "in" ); // ain1 -> omtr1
  190. return kOkDspRC;
  191. }
  192. cmDspRC_t _cmDspSysPgm_Stereo_Fx( cmDspSysH_t h, void** userPtrPtr )
  193. {
  194. bool useBuiltInFl = true;
  195. cmDspInst_t* ignp = cmDspSysAllocInst( h,"Scalar", "In Gain", 5, kNumberDuiId, 0.0, 4.0, 0.01, 1.0);
  196. cmDspInst_t* ognp = cmDspSysAllocInst( h,"Scalar", "Out Gain", 5, kNumberDuiId, 0.0, 4.0, 0.01, 1.0);
  197. //cmDspInst_t* fb0p = cmDspSysAllocInst( h,"Scalar", "Feeback 0", 5, kNumberDuiId, 0.0, 1.0, 0.001, 0.0);
  198. //cmDspInst_t* fb1p = cmDspSysAllocInst( h,"Scalar", "Feedback 1", 5, kNumberDuiId, 0.0, 1.0, 0.001, 0.0);
  199. //cmDspInst_t* tm0p = cmDspSysAllocInst( h,"Scalar", "Time 0", 5, kNumberDuiId, 0.0, 1000.0, 0.0001, 10.0);
  200. //cmDspInst_t* tm1p = cmDspSysAllocInst( h,"Scalar", "Time 1", 5, kNumberDuiId, 0.0, 1000.0, 0.0001, 10.0);
  201. cmDspInst_t* rt0p = cmDspSysAllocInst( h,"Scalar", "Ratio 0", 5, kNumberDuiId, 0.01, 10.0, 0.01, 1.0);
  202. cmDspInst_t* rt1p = cmDspSysAllocInst( h,"Scalar", "Ratio 1", 5, kNumberDuiId, 0.01, 10.0, 0.01, 1.0);
  203. cmDspInst_t* ai0p = cmDspSysAllocInst(h,"AudioIn", NULL, 1, useBuiltInFl ? 0 : 2 );
  204. cmDspInst_t* ai1p = cmDspSysAllocInst(h,"AudioIn", NULL, 1, useBuiltInFl ? 1 : 3 );
  205. cmDspInst_t* om0p = cmDspSysAllocInst(h,"AMeter","Out Left", 0);
  206. cmDspInst_t* om1p = cmDspSysAllocInst(h,"AMeter","Out Right",0);
  207. //cmDspInst_t* dy0p = cmDspSysAllocInst(h,"Delay", NULL, 2, 1000.0, 0.5 );
  208. //cmDspInst_t* dy1p = cmDspSysAllocInst(h,"Delay", NULL, 2, 2000.0, 0.7 );
  209. cmDspInst_t* ps0p = cmDspSysAllocInst(h,"PShift", NULL, 0 );
  210. cmDspInst_t* ps1p = cmDspSysAllocInst(h,"PShift", NULL, 0 );
  211. // MOTU Traveler: Use channels 2&3 (out plugs:3&4) because 0&1 do not show up on plugs 1&2.
  212. cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, useBuiltInFl ? 0 : 2 );
  213. cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, useBuiltInFl ? 1 : 3 );
  214. cmDspSysConnectAudio(h, ai0p,"out", om0p, "in" ); // input meter connection
  215. cmDspSysConnectAudio(h, ai1p,"out", om1p, "in" );
  216. //cmDspSysConnectAudio(h, ai0p,"out", dy0p, "in" ); // input -> delay
  217. //cmDspSysConnectAudio(h, ai1p,"out", dy1p, "in" );
  218. cmDspSysConnectAudio(h, ai0p,"out", ps0p, "in" ); // delay -> pshift
  219. cmDspSysConnectAudio(h, ai1p,"out", ps1p, "in" );
  220. cmDspSysConnectAudio(h, ps0p,"out", ao0p, "in" ); // pshift -> output
  221. cmDspSysConnectAudio(h, ps1p,"out", ao1p, "in" );
  222. //cmDspSysConnectAudio(h, dy0p,"out", ao0p, "in" ); // delay -> output
  223. //cmDspSysConnectAudio(h, dy1p,"out", ao1p, "in" );
  224. cmDspSysInstallCb( h, ignp,"val", ai0p, "gain", NULL); // input gain
  225. cmDspSysInstallCb( h, ignp,"val", ai1p, "gain", NULL);
  226. cmDspSysInstallCb( h, ognp, "val", ao0p, "gain", NULL); // output gain
  227. cmDspSysInstallCb( h, ognp, "val", ao1p, "gain", NULL);
  228. //cmDspSysInstallCb( h, fb0p, "val", dy0p, "fb", NULL); // feedback
  229. //cmDspSysInstallCb( h, fb1p, "val", dy1p, "fb", NULL);
  230. //cmDspSysInstallCb( h, tm0p, "val", dy0p, "time", NULL); // delay time
  231. //cmDspSysInstallCb( h, tm1p, "val", dy1p, "time", NULL);
  232. cmDspSysInstallCb( h, rt0p, "val", ps0p, "ratio", NULL); // pitch ratio
  233. cmDspSysInstallCb( h, rt1p, "val", ps1p, "ratio", NULL);
  234. return kOkDspRC;
  235. }
  236. cmDspRC_t _cmDspSysPgm_PlaySine( cmDspSysH_t h, void** userPtrPtr )
  237. {
  238. bool useBuiltInFl = true;
  239. double frqHz = 440.0;
  240. cmDspInst_t* chp = cmDspSysAllocInst( h,"Scalar", "Channel", 5, kNumberDuiId, 0.0, 100.0, 1.0, 0.0);
  241. cmDspInst_t* php = cmDspSysAllocInst(h,"Phasor", NULL, 2, cmDspSysSampleRate(h), frqHz );
  242. cmDspInst_t* wtp = cmDspSysAllocInst(h,"WaveTable", NULL, 2, ((int)cmDspSysSampleRate(h)), 4);
  243. cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut", NULL, 1, useBuiltInFl ? 0 : 2 );
  244. cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut", NULL, 1, useBuiltInFl ? 1 : 3 );
  245. cmDspInst_t* om0p = cmDspSysAllocInst(h,"AMeter","Out", 0);
  246. cmDspSysConnectAudio(h, php, "out", wtp, "phs" ); // phasor -> wave table
  247. cmDspSysConnectAudio(h, wtp, "out", ao0p, "in" ); // wave table -> audio out
  248. cmDspSysConnectAudio(h, wtp, "out", ao1p, "in" ); //
  249. cmDspSysConnectAudio(h, wtp, "out", om0p, "in" );
  250. cmDspSysInstallCb( h, chp, "val", ao0p, "ch", NULL);
  251. return kOkDspRC;
  252. }
  253. cmDspRC_t _cmDspSysPgm_PlayFile( cmDspSysH_t h, void** userPtrPtr )
  254. {
  255. bool useBuiltInFl = true;
  256. const char* fn0 = "media/audio/20110723-Kriesberg/Audio Files/Piano 3_01.wav";
  257. //int beg = 6900826;
  258. //int end = 13512262;
  259. const cmChar_t* fn = cmFsMakeFn(cmFsUserDir(),fn0,NULL,NULL );
  260. cmDspInst_t* ofp = cmDspSysAllocInst(h,"Scalar", "Offset", 5, kNumberDuiId, 0.0, cmDspSysSampleRate(h)*600.0, 1.0, 0.0);
  261. cmDspInst_t* fnp = cmDspSysAllocInst(h,"Fname", NULL, 3, false,"Audio Files (*.wav,*.aiff,*.aif)\tAudio Files (*.{wav,aiff,aif})",fn);
  262. cmDspInst_t* php = cmDspSysAllocInst(h,"Phasor", NULL, 0 );
  263. cmDspInst_t* wtp = cmDspSysAllocInst(h,"WaveTable",NULL, 2, ((int)cmDspSysSampleRate(h)), 1 );
  264. //cmDspInst_t* afp = cmDspSysAllocInst(h,"AudioFileOut",NULL,2,"/home/kevin/temp/record0.aif",1);
  265. cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, useBuiltInFl ? 0 : 2 );
  266. cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, useBuiltInFl ? 1 : 3 );
  267. cmDspSysConnectAudio(h, php, "out", wtp, "phs" ); // phasor -> wave table
  268. cmDspSysConnectAudio(h, wtp, "out", ao0p, "in" ); // wave table -> audio out
  269. cmDspSysConnectAudio(h, wtp, "out", ao1p, "in" ); //
  270. //cmDspSysConnectAudio(h, wtp, "out", afp, "in0");
  271. cmDspSysInstallCb(h, ofp, "val", wtp, "beg", NULL );
  272. cmDspSysInstallCb(h, fnp, "out", wtp, "fn", NULL);
  273. return kOkDspRC;
  274. }
  275. cmDspRC_t _cmDspSysPgm_MultiOut( cmDspSysH_t h, void** userPtrPtr )
  276. {
  277. cmDspRC_t rc = kOkDspRC;
  278. double frqHz = 440.0;
  279. unsigned chCnt = 8;
  280. unsigned oneOfN_chCnt = 2;
  281. double offs = 34612504;
  282. cmDspInst_t* aout[chCnt];
  283. unsigned i;
  284. const char* fn0 = "media/audio/20110723-Kriesberg/Audio Files/Piano 3_23.wav";
  285. const cmChar_t* fn = cmFsMakeFn(cmFsUserDir(),fn0,NULL,NULL );
  286. cmDspInst_t* f_phs = cmDspSysAllocInst(h,"Phasor", NULL, 0 );
  287. cmDspInst_t* f_wt = cmDspSysAllocInst(h,"WaveTable",NULL, 2, ((int)cmDspSysSampleRate(h)), 1 );
  288. cmDspInst_t* f_mtr = cmDspSysAllocInst(h,"AMeter", "File Out", 0);
  289. cmDspInst_t* f_rew = cmDspSysAllocInst(h,"Button", "Rewind", 2, kButtonDuiId, 1.0 );
  290. cmDspInst_t* f_pts = cmDspSysAllocInst(h,"PortToSym", NULL, 1, "on" );
  291. cmDspInst_t* f_beg = cmDspSysAllocInst(h,"Scalar", "File Begin", 5, kNumberDuiId, 0.0, cmDspSysSampleRate(h)*6000.0, 1.0, offs);
  292. cmDspInst_t* f_nam = cmDspSysAllocInst(h,"Fname", NULL, 3, false,"Audio Files (*.wav,*.aiff,*.aif)\tAudio Files (*.{wav,aiff,aif})",fn);
  293. cmDspInst_t* s_phs = cmDspSysAllocInst(h,"Phasor", NULL, 2, cmDspSysSampleRate(h), frqHz );
  294. cmDspInst_t* s_wt = cmDspSysAllocInst(h,"WaveTable", NULL, 2, ((int)cmDspSysSampleRate(h)), 4);
  295. cmDspInst_t* s_mtr = cmDspSysAllocInst(h,"AMeter", "Tone Out", 0);
  296. cmDspInst_t* swtch = cmDspSysAllocInst(h,"1ofN", NULL, 2, oneOfN_chCnt, 0 );
  297. for(i=0; i<chCnt; ++i)
  298. aout[i] = cmDspSysAllocInst(h,"AudioOut",NULL, 1, i );
  299. cmDspInst_t* chck = cmDspSysAllocInst(h,"Checkbox", "Source", 5, "Tone","file","tone", 0.0, 1.0);
  300. cmDspInst_t** vol = cmDspSysAllocInstArray(h,chCnt,"Scalar", "Gain", NULL, 5, kNumberDuiId, 0.0, 10.0, 0.01, 0.0 );
  301. // check for allocation errors
  302. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  303. goto errLabel;
  304. cmDspSysConnectAudio( h, s_phs, "out", s_wt, "phs" ); // sine phasor -> wave table
  305. cmDspSysConnectAudio( h, s_wt, "out", s_mtr, "in" ); // sine wave table -> meter
  306. cmDspSysConnectAudio( h, s_wt, "out", swtch, "a-in-1");
  307. cmDspSysConnectAudio( h, f_phs, "out", f_wt, "phs" ); // file phasor -> wave table
  308. cmDspSysConnectAudio( h, f_wt, "out", f_mtr, "in" ); // file wave table -> meter
  309. cmDspSysConnectAudio( h, f_wt, "out", swtch, "a-in-0");
  310. cmDspSysConnectAudio11N1( h, swtch, "a-out", aout, "in", chCnt );
  311. cmDspSysInstallCbN1N1( h, vol, "val", aout, "gain", chCnt );
  312. cmDspSysInstallCb( h, chck, "out", swtch, "chidx", NULL );
  313. cmDspSysInstallCb( h, f_nam, "out", f_wt, "fn", NULL );
  314. cmDspSysInstallCb( h, f_beg, "val", f_wt, "beg", NULL );
  315. cmDspSysInstallCb( h, f_rew, "out", f_pts, "on", NULL );
  316. cmDspSysInstallCb( h, f_pts, "on", f_beg, "send", NULL );
  317. cmDspSysInstallCb( h, f_pts, "on", f_nam, "send", NULL );
  318. cmDspSysInstallCb( h, f_pts, "on", f_wt, "cmd", NULL );
  319. errLabel:
  320. return rc;
  321. }
  322. cmDspRC_t _cmDspSysPgm_MultiIn(cmDspSysH_t h, void** userPtrPtr)
  323. {
  324. int chCnt = 8;
  325. cmDspInst_t* a[chCnt];
  326. int i;
  327. for(i=0; i<chCnt; ++i)
  328. a[i] = cmDspSysAllocInst( h, "AudioIn", NULL, 1, i );
  329. cmDspInst_t* mxp = cmDspSysAllocInst( h, "AMix", NULL, chCnt+1, chCnt, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 );
  330. cmDspInst_t* afp = cmDspSysAllocInst( h, "AudioFileOut", NULL, 2,"/home/kevin/temp/at/test_in.aif",1);
  331. cmDspInst_t* aop = cmDspSysAllocInst( h, "AudioOut", NULL, 1, 0 );
  332. // AudioFileOut needs an open message to create the output file
  333. cmDspInst_t* btn = cmDspSysAllocInst( h, "Button", "open", 2, kButtonDuiId, 1.0 );
  334. cmDspSysAssignInstAttrSymbolStr(h, btn, "_reset" );
  335. cmDspInst_t* pts = cmDspSysAllocInst(h,"PortToSym", NULL, 1, "open" );
  336. cmDspSysConnectAudioN11N(h, a, "out", mxp, "in", chCnt );
  337. cmDspSysConnectAudio( h, mxp, "out", afp, "in0" );
  338. cmDspSysConnectAudio( h, mxp, "out", aop, "in" );
  339. cmDspSysInstallCb( h, btn, "sym", pts, "open", NULL );
  340. cmDspSysInstallCb( h, pts, "open", afp, "sel", NULL );
  341. return kOkDspRC;
  342. }
  343. cmDspRC_t _cmDspSysPgm_GateDetect( cmDspSysH_t h, void** userPtrPtr )
  344. {
  345. bool useBuiltInFl = true;
  346. //const char* fn0 = "media/audio/20110723-Kriesberg/Audio Files/Piano 3_01.wav";
  347. //int beg = 6900826;
  348. //int end = 13512262;
  349. //const char* fn0 = "media/audio/McGill-3/1 Audio Track.aiff";
  350. const char* fn0 = "temp/gate_detect0.aif";
  351. int beg = 0;
  352. int end = -1;
  353. const cmChar_t* fn = cmFsMakeFn(cmFsUserDir(),fn0,NULL,NULL );
  354. const cmChar_t* tfn = "/home/kevin/temp/test0.txt";
  355. cmDspInst_t* ofp = cmDspSysAllocInst(h,"Scalar", "Offset", 5, kNumberDuiId, 0.0, cmDspSysSampleRate(h)*600.0, 1.0, 0.0);
  356. //cmDspInst_t* fnp = cmDspSysAllocInst(h,"Fname", NULL, 3, false,"Audio Files (*.wav,*.aiff,*.aif)\tAudio Files (*.{wav,aiff,aif})",fn);
  357. cmDspInst_t* php = cmDspSysAllocInst(h,"Phasor", NULL, 0 );
  358. cmDspInst_t* wtp = cmDspSysAllocInst(h,"WaveTable", NULL, 6, ((int)cmDspSysSampleRate(h)), 1, fn, -1, beg, end );
  359. cmDspInst_t* gdp = cmDspSysAllocInst(h,"GateDetect",NULL, 1, 20.0);
  360. cmDspInst_t* gmp = cmDspSysAllocInst(h,"Meter", NULL, 3, 0.0, 0.0, 1.0);
  361. cmDspInst_t* rmp = cmDspSysAllocInst(h,"Meter", NULL, 3, -100.0, -100.0, 0.0);
  362. cmDspInst_t* txp = cmDspSysAllocInst(h,"TextFile", NULL, 2, 3, tfn);
  363. cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, useBuiltInFl ? 0 : 2 );
  364. cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, useBuiltInFl ? 1 : 3 );
  365. cmDspSysConnectAudio(h, php, "out", wtp, "phs" ); // phasor -> wave table
  366. cmDspSysConnectAudio(h, wtp, "out", ao0p, "in" ); // wave table -> audio out
  367. cmDspSysConnectAudio(h, wtp, "out", ao1p, "in" ); //
  368. cmDspSysConnectAudio(h, wtp, "out", gdp, "in" );
  369. cmDspSysInstallCb(h, ofp, "val", wtp, "beg", NULL );
  370. cmDspSysInstallCb(h, gdp, "gate", gmp, "in", NULL );
  371. cmDspSysInstallCb(h, gdp, "rms", rmp, "in", NULL );
  372. cmDspSysInstallCb(h, gdp, "gate", txp, "in-0", NULL);
  373. cmDspSysInstallCb(h, gdp, "rms", txp, "in-1", NULL);
  374. cmDspSysInstallCb(h, gdp, "mean", txp, "in-2", NULL);
  375. return kOkDspRC;
  376. }
  377. cmDspRC_t _cmDspSysPgm_Record(cmDspSysH_t h, void** userPtrPtr)
  378. {
  379. int chCnt = 8;
  380. cmDspInst_t* a[chCnt];
  381. int i;
  382. for(i=0; i<chCnt; ++i)
  383. a[i] = cmDspSysAllocInst( h, "AudioIn", NULL, 1, i );
  384. cmDspInst_t* mxp = cmDspSysAllocInst( h, "AMix", NULL, chCnt+1, chCnt, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 );
  385. cmDspInst_t* afp = cmDspSysAllocInst( h, "AudioFileOut", NULL, 2,"/home/kevin/temp/gate_detect.aif",1);
  386. cmDspInst_t* aop = cmDspSysAllocInst( h, "AudioOut", NULL, 1, 0 );
  387. cmDspInst_t* txp = cmDspSysAllocInst( h, "TextFile", NULL, 2, 1, "/home/kevin/temp/gate_detect.txt");
  388. cmDspInst_t* chp = cmDspSysAllocInst( h, "Scalar", "Channel", 5, kNumberDuiId, 0.0, 7.0, 1.0, 0.0);
  389. // AudioFileOut needs an open message to create the output file
  390. cmDspInst_t* btn = cmDspSysAllocInst( h, "Button", "open", 2, kButtonDuiId, 1.0 );
  391. cmDspSysAssignInstAttrSymbolStr(h, btn, "_reset" );
  392. cmDspInst_t* pts = cmDspSysAllocInst(h,"PortToSym", NULL, 1, "open" );
  393. for(i=0; i<chCnt; ++i)
  394. {
  395. cmChar_t lbl[15];
  396. snprintf(lbl,15,"in-%i",i);
  397. cmDspSysConnectAudio(h,a[i], "out", mxp, lbl);
  398. }
  399. cmDspSysConnectAudio(h, mxp, "out", afp, "in0" );
  400. cmDspSysConnectAudio(h, mxp, "out", aop, "in" );
  401. cmDspSysInstallCb(h, chp, "out", txp, "in-0", NULL);
  402. cmDspSysInstallCb( h, btn, "sym", pts, "open", NULL );
  403. cmDspSysInstallCb( h, pts, "open", afp, "sel", NULL );
  404. return kOkDspRC;
  405. }
  406. cmDspRC_t _cmDspSysPgm_PitchShiftFile( cmDspSysH_t h, void** userPtrPtr )
  407. {
  408. bool useBuiltInFl = true;
  409. const cmChar_t* fn0 = "media/audio/20110723-Kriesberg/Audio Files/Piano 3_01.wav";
  410. const cmChar_t* fn1 = "temp/record0.aif";
  411. int beg = 6900826;
  412. int end = 13512262;
  413. const cmChar_t* fn = cmFsMakeFn(cmFsUserDir(),fn0,NULL,NULL );
  414. const cmChar_t* ofn = cmFsMakeFn(cmFsUserDir(),fn1,NULL,NULL );
  415. cmDspInst_t* rt0p = cmDspSysAllocInst(h,"Scalar", "Ratio 0", 5, kNumberDuiId, 0.01, 10.0, 0.01, 1.0);
  416. cmDspInst_t* rt1p = cmDspSysAllocInst(h,"Scalar", "Ratio 1", 5, kNumberDuiId, 0.01, 10.0, 0.01, 1.0);
  417. cmDspInst_t* ofp = cmDspSysAllocInst(h,"Scalar", "Offset", 5, kNumberDuiId, 0.0, cmDspSysSampleRate(h)*600.0, 1.0, 0.0);
  418. //cmDspInst_t* fnp = cmDspSysAllocInst(h,"Fname", NULL, 3, false,"Audio Files (*.wav,*.aiff,*.aif)\tAudio Files (*.{wav,aiff,aif})",fn);
  419. cmDspInst_t* php = cmDspSysAllocInst(h,"Phasor", NULL, 0 );
  420. cmDspInst_t* wtp = cmDspSysAllocInst(h,"WaveTable",NULL, 6, ((int)cmDspSysSampleRate(h)), 1, fn, -1, beg, end );
  421. cmDspInst_t* afp = cmDspSysAllocInst(h,"AudioFileOut",NULL,2,ofn,1);
  422. cmDspInst_t* ps0p = cmDspSysAllocInst(h,"PShift", NULL, 0 );
  423. cmDspInst_t* ps1p = cmDspSysAllocInst(h,"PShift", NULL, 0 );
  424. cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, useBuiltInFl ? 0 : 2 );
  425. cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, useBuiltInFl ? 1 : 3 );
  426. cmDspSysConnectAudio(h, php, "out", wtp, "phs" ); // phasor -> wave table
  427. cmDspSysConnectAudio(h, wtp, "out", ps0p, "in" ); // wave table -> shift
  428. cmDspSysConnectAudio(h, wtp, "out", ps1p, "in" ); //
  429. cmDspSysConnectAudio(h, ps0p, "out", ao0p, "in" ); // shift -> audio out
  430. cmDspSysConnectAudio(h, ps1p, "out", ao1p, "in" ); //
  431. cmDspSysConnectAudio(h, ps0p, "out", afp, "in0"); //
  432. cmDspSysInstallCb(h, ofp, "val", wtp, "beg", NULL );
  433. //cmDspSysInstallCb(h, fnp, "out", wtp, "fn", NULL);
  434. cmDspSysInstallCb(h, rt0p, "val", ps0p, "ratio", NULL);
  435. cmDspSysInstallCb(h, rt1p, "val", ps1p, "ratio", NULL);
  436. return kOkDspRC;
  437. }
  438. cmDspRC_t _cmDspSysPgm_LoopRecd( cmDspSysH_t h, void** userPtrPtr )
  439. {
  440. bool useBuiltInFl = true;
  441. const cmChar_t* fn0 = "media/audio/20110723-Kriesberg/Audio Files/Piano 3_01.wav";
  442. const cmChar_t* fn = cmFsMakeFn(cmFsUserDir(),fn0,NULL,NULL );
  443. int beg = 6900826;
  444. int end = 13512262;
  445. cmDspInst_t* rfl = cmDspSysAllocInst(h,"Button", "Recd", 2, kCheckDuiId, 0.0 );
  446. cmDspInst_t* pfl = cmDspSysAllocInst(h,"Button", "Play", 2, kButtonDuiId, 1.0 );
  447. cmDspInst_t* rtp = cmDspSysAllocInst(h,"Scalar", "Ratio", 5, kNumberDuiId, 0.0, 10.0, 0.01, 1.0 );
  448. cmDspInst_t* ofp = cmDspSysAllocInst(h,"Scalar", "Offset", 5, kNumberDuiId, 0.0, cmDspSysSampleRate(h)*600.0, 1.0, 0.0);
  449. //cmDspInst_t* fnp = cmDspSysAllocInst(h,"Fname", NULL, 3, false,"Audio Files (*.wav,*.aiff,*.aif)\tAudio Files (*.{wav,aiff,aif})",fn);
  450. cmDspInst_t* php = cmDspSysAllocInst(h,"Phasor", NULL, 0 );
  451. cmDspInst_t* wtp = cmDspSysAllocInst(h,"WaveTable",NULL, 6, ((int)cmDspSysSampleRate(h)), 1, fn, -1, beg, end );
  452. //cmDspInst_t* afp = cmDspSysAllocInst(h,"AudioFileOut",NULL,2,"/home/kevin/temp/record0.aif",1);
  453. cmDspInst_t* lrp = cmDspSysAllocInst(h,"LoopRecd", NULL, 0 );
  454. cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, useBuiltInFl ? 0 : 2 );
  455. cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, useBuiltInFl ? 1 : 3 );
  456. cmDspSysConnectAudio(h, php, "out", wtp, "phs" ); // phasor -> wave table
  457. cmDspSysConnectAudio(h, wtp, "out", lrp, "in" ); // wave table -> shift
  458. cmDspSysConnectAudio(h, lrp, "out", ao0p, "in" ); // shift -> audio out
  459. cmDspSysConnectAudio(h, wtp, "out", ao1p, "in" );
  460. cmDspSysInstallCb(h, ofp, "val", wtp, "beg", NULL );
  461. //cmDspSysInstallCb(h, fnp, "out", wtp, "fn", NULL);
  462. cmDspSysInstallCb(h, rfl, "out", lrp, "recd", NULL);
  463. cmDspSysInstallCb(h, pfl, "out", lrp, "play", NULL);
  464. cmDspSysInstallCb(h, rtp, "val", lrp, "ratio",NULL);
  465. return kOkDspRC;
  466. }
  467. cmDspRC_t _cmDspSysPgm_UiTest(cmDspSysH_t h, void** userPtrPtr )
  468. {
  469. cmDspRC_t rc = kOkDspRC;
  470. cmDspInst_t* mdp = cmDspSysAllocInst(h,"Scalar", "Mode", 5, kNumberDuiId, 0.0, 4.0, 1.0, 1.0);
  471. cmDspInst_t* wsp = cmDspSysAllocInst(h,"MsgList","wndSmpCnt", 3, "wndSmpCnt", NULL, 2);
  472. cmDspInst_t* hfp = cmDspSysAllocInst(h,"MsgList","hopFact", 3, "hopFact", NULL, 2);
  473. cmDspInst_t* thp = cmDspSysAllocInst(h,"Scalar", "threshold", 5, kNumberDuiId, 0.0, 1.0, 0.01, 0.5 );
  474. cmDspInst_t* trp = cmDspSysAllocInst(h,"Scalar", "target", 5, kNumberDuiId, 0.0, 1.0, 0.01, 0.5 );
  475. cmDspInst_t* btn = cmDspSysAllocInst(h,"Button", "btn", 2, kButtonDuiId, 12.3 );
  476. cmDspInst_t* chk = cmDspSysAllocInst(h,"Button", "check", 2, kCheckDuiId, 0 );
  477. cmDspInst_t* chb = cmDspSysAllocInst(h,"Checkbox","checkbox", 5, "Checker","up","down", 2.0, 1.0);
  478. cmDspInst_t* txt = cmDspSysAllocInst(h,"Text", "text", 1, "Hello" );
  479. cmDspInst_t* prp = cmDspSysAllocInst(h,"Printer", NULL, 1, ">" );
  480. cmDspInst_t* mtp = cmDspSysAllocInst(h,"Meter", "meter", 3, 0.0, 0.0, 4.0);
  481. cmDspInst_t* ctp = cmDspSysAllocInst(h,"Counter", NULL, 3, 0.0, 10.0, 1.0 );
  482. cmDspSysAllocInst(h,"Label", "label1", 1, "label2");
  483. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  484. return rc;
  485. cmDspSysInstallCb(h, mdp, "val", thp, "val", NULL );
  486. cmDspSysInstallCb(h, mdp, "val", prp, "in", NULL );
  487. cmDspSysInstallCb(h, wsp, "out", prp, "in", NULL );
  488. cmDspSysInstallCb(h, hfp, "out", prp, "in", NULL );
  489. cmDspSysInstallCb(h, trp, "val", prp, "in", NULL );
  490. cmDspSysInstallCb(h, btn, "out", prp, "in", NULL );
  491. cmDspSysInstallCb(h, chk, "out", prp, "in", NULL );
  492. cmDspSysInstallCb(h, ctp, "out", prp, "in", NULL );
  493. cmDspSysInstallCb(h, mdp, "val", btn, "in", NULL );
  494. cmDspSysInstallCb(h, thp, "val", mtp, "in", NULL );
  495. cmDspSysInstallCb(h, thp, "val", trp, "val", NULL );
  496. cmDspSysInstallCb(h, btn, "sym", prp, "in", NULL );
  497. cmDspSysInstallCb(h, btn, "out", ctp, "next", NULL );
  498. cmDspSysInstallCb(h, txt, "val", prp, "in", NULL );
  499. cmDspSysInstallCb(h, chb, "out", prp, "in", NULL );
  500. cmDspSysInstallCb(h, chb, "sym", prp, "in", NULL );
  501. return rc;
  502. }
  503. cmDspRC_t _cmDspSysPgm_Xfade( cmDspSysH_t h, void** userPtrPtr )
  504. {
  505. cmDspRC_t rc = kOkDspRC;
  506. unsigned leftChIdx = 0;
  507. unsigned rightChIdx = 1;
  508. unsigned chCnt = 2;
  509. double xfadeMs = 1000; // cross fade time
  510. double sgHz = 500;
  511. unsigned sgShapeId = 1;
  512. double sgGain = 0.5;
  513. cmDspInst_t* sg = cmDspSysAllocInst( h, "SigGen", NULL, 3, sgHz, sgShapeId, sgGain );
  514. cmDspInst_t* xfp = cmDspSysAllocInst(h,"Xfader", NULL, 2, chCnt, xfadeMs );
  515. cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, leftChIdx );
  516. cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, rightChIdx );
  517. cmDspInst_t* im0p = cmDspSysAllocInst(h,"AMeter","In 0", 0);
  518. cmDspInst_t* im1p = cmDspSysAllocInst(h,"AMeter","In 1", 0);
  519. cmDspInst_t* om0p = cmDspSysAllocInst(h,"AMeter","Out 0", 0);
  520. cmDspInst_t* om1p = cmDspSysAllocInst(h,"AMeter","Out 1", 0);
  521. cmDspInst_t* mstr = cmDspSysAllocInst(h,"Button", "Mstr", 2, kCheckDuiId, 0.0 );
  522. cmDspInst_t* btn0 = cmDspSysAllocInst(h,"Button", "Fade 0", 2, kCheckDuiId, 0.0 );
  523. cmDspInst_t* btn1 = cmDspSysAllocInst(h,"Button", "Fade 1", 2, kCheckDuiId, 1.0 );
  524. cmDspInst_t* gm0p = cmDspSysAllocInst(h,"Meter","Gain 0", 3, 0.0, 0.0, 1.0);
  525. cmDspInst_t* gm1p = cmDspSysAllocInst(h,"Meter","Gain 1", 3, 0.0, 0.0, 1.0);
  526. cmDspInst_t* pon = cmDspSysAllocInst(h,"Printer", NULL, 1, "on:" );
  527. cmDspInst_t* pof = cmDspSysAllocInst(h,"Printer", NULL, 1, "off:" );
  528. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  529. return rc;
  530. cmDspSysConnectAudio(h, sg, "out", im0p, "in"); // ain -> meter
  531. cmDspSysConnectAudio(h, sg, "out", im1p, "in"); //
  532. cmDspSysConnectAudio(h, sg, "out", xfp, "in-0"); // ain -> xfader
  533. cmDspSysConnectAudio(h, sg, "out", xfp, "in-1");
  534. cmDspSysConnectAudio(h, xfp, "out-0", om0p, "in" ); // xfade -> meter
  535. cmDspSysConnectAudio(h, xfp, "out-1", om1p, "in" ); //
  536. cmDspSysConnectAudio(h, xfp, "out-0", ao0p, "in" ); // xfade -> aout
  537. cmDspSysConnectAudio(h, xfp, "out-1", ao1p, "in" ); //
  538. cmDspSysInstallCb(h, btn0, "out", xfp, "gate-0", NULL ); // check -> xfade gate
  539. cmDspSysInstallCb(h, btn1, "out", xfp, "gate-1", NULL );
  540. cmDspSysInstallCb(h, mstr, "out", xfp, "mgate", NULL );
  541. cmDspSysInstallCb(h, xfp, "gain-0", gm0p, "in", NULL );
  542. cmDspSysInstallCb(h, xfp, "gain-1", gm1p, "in", NULL );
  543. cmDspSysInstallCb(h, xfp, "on", pon, "in", NULL );
  544. cmDspSysInstallCb(h, xfp, "off", pof, "in", NULL );
  545. return cmDspSysLastRC(h);
  546. }
  547. cmDspRC_t _cmDspSysPgm6( cmDspSysH_t h, void* audioDir )
  548. {
  549. cmDspRC_t rc = kOkDspRC;
  550. int wndSmpCnt = 2048;
  551. int hopFact = 4;
  552. //const char* afDir = "/Volumes/LaTetra0/media/audio/20110723-Kriesberg/Audio Files";
  553. //const char* afDir = "/Users/administrator/Documents/kc";
  554. const char* afDir = "/home/kevin/media/audio/20110723-Kriesberg/Audio Files";
  555. cmDspInst_t* ph0p = cmDspSysAllocInst(h,"Phasor", NULL, 0 );
  556. cmDspInst_t* wt0p = cmDspSysAllocInst(h,"WaveTable",NULL, 0 );
  557. cmDspInst_t* ro0p = cmDspSysAllocInst(h,"Reorder", NULL, 5, 3, 2, 0, 1, 2 );
  558. cmDspInst_t* kr0p = cmDspSysAllocInst(h,"Kr", NULL, 2, wndSmpCnt, hopFact );
  559. cmDspInst_t* kr1p = cmDspSysAllocInst(h,"Kr", NULL, 2, wndSmpCnt, hopFact );
  560. cmDspInst_t* prp = cmDspSysAllocInst(h,"Printer", NULL, 0 );
  561. bool useBuiltInFl = true;
  562. // MOTU Traveler: Use channels 2&3 (out plugs:3&4) because 0&1 do not show up on plugs 1&2.
  563. cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, useBuiltInFl ? 0 : 2 );
  564. cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, useBuiltInFl ? 1 : 3 );
  565. // BUG: If audio inputs are not connected a 'not an audio buffer' msg is generated.
  566. // This is a problem with type determination in the cmDspClass related code : see cmDspClass.c 833
  567. // for a place that this error would be thrown in the following audio outputs were not connected
  568. // to audio sources.
  569. cmDspInst_t* ao2p = NULL;
  570. cmDspInst_t* ao3p = NULL;
  571. if( !useBuiltInFl )
  572. {
  573. ao2p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 4 );
  574. ao3p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 5 );
  575. }
  576. cmDspInst_t* al0p = cmDspSysAllocInst(h,"MsgList","audFiles", 2, "audFiles",NULL);
  577. cmDspInst_t* fl0p = cmDspSysAllocInst(h,"MsgList","audFragsA", 2, "audFrags",NULL);
  578. cmDspInst_t* fn0p = cmDspSysAllocInst(h,"Sprintf","filename", 1, "%s/%s_%02i.wav");
  579. cmDspInst_t* md0p = cmDspSysAllocInst(h,"Scalar", "Mode", 5, kNumberDuiId, 0.0, 4.0, 1.0, 1.0);
  580. cmDspInst_t* ws0p = cmDspSysAllocInst(h,"MsgList","wndSmpCnt", 3, "wndSmpCnt", NULL, 2);
  581. cmDspInst_t* hf0p = cmDspSysAllocInst(h,"MsgList","hopFact", 3, "hopFact", NULL, 2);
  582. cmDspInst_t* th0p = cmDspSysAllocInst(h,"Scalar", "threshold", 5, kNumberDuiId, 0.0, 100.0, 1.0, 60.0 );
  583. cmDspInst_t* us0p = cmDspSysAllocInst(h,"Scalar", "upr slope", 5, kNumberDuiId, 0.0, 10.0, 0.01, 0.0 );
  584. cmDspInst_t* ls0p = cmDspSysAllocInst(h,"Scalar", "lwr slope", 5, kNumberDuiId, 0.3, 10.0, 0.01, 2.0 );
  585. cmDspInst_t* of0p = cmDspSysAllocInst(h,"Scalar", "offset", 5, kNumberDuiId, 0.0, 100.0, 0.01, 30.0 );
  586. cmDspInst_t* iv0p = cmDspSysAllocInst(h,"Scalar", "invert", 5, kNumberDuiId, 0.0, 1.0, 1.0, 0.0 );
  587. cmDspSysNewColumn(h,0);
  588. //cmDspInst_t* al1p = cmDspSysAllocInst(h,"MsgList","audFiles", 2, "audFiles",NULL);
  589. //cmDspInst_t* fl1p = cmDspSysAllocInst(h,"MsgList","audFrags1", 2, "audFrags",NULL);
  590. //cmDspInst_t* fn1p = cmDspSysAllocInst(h,"Sprintf","filename", 1, "%s/%s_%02i.wav");
  591. cmDspInst_t* md1p = cmDspSysAllocInst(h,"Scalar", "Mode", 5, kNumberDuiId, 0.0, 4.0, 1.0, 1.0);
  592. cmDspInst_t* ws1p = cmDspSysAllocInst(h,"MsgList","wndSmpCnt", 3, "wndSmpCnt", NULL, 2);
  593. cmDspInst_t* hf1p = cmDspSysAllocInst(h,"MsgList","hopFact", 3, "hopFact", NULL, 2);
  594. cmDspInst_t* th1p = cmDspSysAllocInst(h,"Scalar", "threshold", 5, kNumberDuiId, 0.0, 100.0, 1.0, 60.0 );
  595. cmDspInst_t* us1p = cmDspSysAllocInst(h,"Scalar", "upr slope", 5, kNumberDuiId, 0.0, 10.0, 0.01, 0.0 );
  596. cmDspInst_t* ls1p = cmDspSysAllocInst(h,"Scalar", "lwr slope", 5, kNumberDuiId, 0.3, 10.0, 0.01, 2.0 );
  597. cmDspInst_t* of1p = cmDspSysAllocInst(h,"Scalar", "offset", 5, kNumberDuiId, 0.0, 100.0, 0.01, 30.0 );
  598. cmDspInst_t* iv1p = cmDspSysAllocInst(h,"Scalar", "invert", 5, kNumberDuiId, 0.0, 1.0, 1.0, 0.0 );
  599. cmDspSysNewColumn(h,0);
  600. cmDspInst_t* dnp = cmDspSysAllocInst(h,"Fname", "audDir", 3, true,NULL,afDir);
  601. cmDspInst_t* mtp = cmDspSysAllocInst(h,"Meter","MyMeter", 3, 50.0, 0.0, 100.0);
  602. cmDspInst_t* atp = cmDspSysAllocInst(h,"AMeter","Audio Meter",0);
  603. if( (rc = cmDspSysLastRC(h)) != kOkDspRC )
  604. return rc;
  605. cmDspSysConnectAudio(h, ph0p, "out", wt0p, "phs"); // phasor->wt:phs
  606. cmDspSysConnectAudio(h, wt0p, "out", kr0p, "in"); // wt->kr
  607. cmDspSysConnectAudio(h, kr0p, "out", ao0p, "in"); // kr->aout- 0
  608. cmDspSysConnectAudio(h, wt0p, "out", kr1p, "in"); // wt->kr
  609. cmDspSysConnectAudio(h, kr1p, "out", ao1p, "in"); // kr->aout - 1
  610. if( ao2p != NULL )
  611. cmDspSysConnectAudio(h, wt0p,"out", ao2p, "in"); // wt->aout - 2
  612. if( ao3p != NULL )
  613. cmDspSysConnectAudio(h, wt0p,"out", ao3p, "in"); // wt->aout - 3
  614. cmDspSysConnectAudio(h, wt0p,"out", atp, "in"); // wt->meter
  615. cmDspSysInstallCb(h, ws0p, "out", kr0p, "wndn", NULL ); // wndSmpCnt->kr
  616. cmDspSysInstallCb(h, hf0p, "out", kr0p, "hopf", NULL ); // hopFact->kr
  617. cmDspSysInstallCb(h, md0p, "val", kr0p, "mode", NULL ); // mode->kr
  618. cmDspSysInstallCb(h, th0p, "val", kr0p, "thrh", NULL ); // thresh->kr
  619. cmDspSysInstallCb(h, ls0p, "val", kr0p, "lwrs", NULL ); // lwrSlope->kr
  620. cmDspSysInstallCb(h, us0p, "val", kr0p, "uprs", NULL ); // uprSlope->kr
  621. cmDspSysInstallCb(h, of0p, "val", kr0p, "offs", NULL ); // offset->kr
  622. cmDspSysInstallCb(h, iv0p, "val", kr0p, "invt", NULL ); // invert->kr
  623. cmDspSysInstallCb(h, th0p, "val", mtp, "in", NULL );
  624. cmDspSysInstallCb(h, ws1p, "out", kr1p, "wndn", NULL ); // wndSmpCnt->kr
  625. cmDspSysInstallCb(h, hf1p, "out", kr1p, "hopf", NULL ); // hopFact->kr
  626. cmDspSysInstallCb(h, md1p, "val", kr1p, "mode", NULL ); // mode->kr
  627. cmDspSysInstallCb(h, th1p, "val", kr1p, "thrh", NULL ); // thresh->kr
  628. cmDspSysInstallCb(h, ls1p, "val", kr1p, "lwrs", NULL ); // lwrSlope->kr
  629. cmDspSysInstallCb(h, us1p, "val", kr1p, "uprs", NULL ); // uprSlope->kr
  630. cmDspSysInstallCb(h, of1p, "val", kr1p, "offs", NULL ); // offset->kr
  631. cmDspSysInstallCb(h, iv1p, "val", kr1p, "invt", NULL ); // invert->kr
  632. cmDspSysInstallCb(h, dnp, "out", fn0p, "in-0", NULL); // dir->fn:0
  633. cmDspSysInstallCb(h, al0p, "out", fn0p, "in-1", NULL ); // fn->fn:1
  634. cmDspSysInstallCb(h, fl0p, "take", fn0p, "in-2", NULL ); // take->fn:2
  635. cmDspSysInstallCb(h, fn0p, "out", ro0p, "in-0", NULL); // fn->print
  636. cmDspSysInstallCb(h, fl0p, "beg", ro0p, "in-1", NULL); //
  637. cmDspSysInstallCb(h, fl0p, "end", ro0p, "in-2", NULL); //
  638. cmDspSysInstallCb(h, ro0p, "out-0", wt0p, "fn", NULL ); // fn->wt:fn
  639. cmDspSysInstallCb(h, ro0p, "out-1", wt0p, "beg", NULL ); // beg->wt:beg
  640. cmDspSysInstallCb(h, ro0p, "out-2", wt0p, "end", NULL ); // end->wt:end
  641. cmDspSysInstallCb(h, ro0p, "out-1", prp, "in", NULL ); //
  642. //cmDspSysInstallCb(h, dnp, "out", fn1p, "in-0", NULL); // dir->fn:0
  643. //cmDspSysInstallCb(h, al1p, "out", fn1p, "in-1", NULL ); // fn->fn:1
  644. //cmDspSysInstallCb(h, fl1p, "take", fn1p, "in-2", NULL ); // take->fn:2
  645. //cmDspSysInstallCb(h, fn1p, "out", ro1p, "in-0", NULL); // fn->print
  646. //cmDspSysInstallCb(h, fl1p, "beg", ro1p, "in-1", NULL); //
  647. //cmDspSysInstallCb(h, fl1p, "end", ro1p, "in-2", NULL); //
  648. //cmDspSysInstallCb(h, ro1p, "out-0", wt1p, "fn", NULL ); // fn->wt:fn
  649. //cmDspSysInstallCb(h, ro1p, "out-1", wt1p, "beg", NULL ); // beg->wt:beg
  650. //cmDspSysInstallCb(h, ro1p, "out-2", wt1p, "end", NULL ); // end->wt:end
  651. return cmDspSysLastRC(h);
  652. }
  653. cmDspRC_t _cmDspSysPgmGuitar( cmDspSysH_t h, void** userPtrPtr )
  654. {
  655. cmDspRC_t rc = kOkDspRC;
  656. int wndSmpCnt = 2048;
  657. int hopFact = 4;
  658. const char* afDir = "/Volumes/LaTetra0/media/audio/20110723-Kriesberg/Audio Files";
  659. //const char* afDir = "/Users/administrator/Documents/kc";
  660. cmDspInst_t* ph0p = cmDspSysAllocInst(h,"Phasor", NULL, 0 );
  661. cmDspInst_t* wt0p = cmDspSysAllocInst(h,"WaveTable",NULL, 0 );
  662. cmDspInst_t* ro0p = cmDspSysAllocInst(h,"Reorder", NULL, 5, 3, 2, 0, 1, 2 );
  663. cmDspInst_t* kr0p = cmDspSysAllocInst(h,"Kr", NULL, 2, wndSmpCnt, hopFact );
  664. cmDspInst_t* kr1p = cmDspSysAllocInst(h,"Kr", NULL, 2, wndSmpCnt, hopFact );
  665. cmDspInst_t* prp = cmDspSysAllocInst(h,"Printer", NULL, 0 );
  666. bool useBuiltInFl = true;
  667. // MOTU Traveler: Use channels 2&3 (out plugs:3&4) because 0&1 do not show up on plugs 1&2.
  668. cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, useBuiltInFl ? 0 : 2 );
  669. cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, useBuiltInFl ? 1 : 3 );
  670. // BUG: If audio inputs are not connected a 'not an audio buffer' msg is generated.
  671. // This is a problem with type determination in the cmDspClass related code : see cmDspClass.c 833
  672. // for a place that this error would be thrown in the following audio outputs were not connected
  673. // to audio sources.
  674. cmDspInst_t* ao2p = NULL;
  675. cmDspInst_t* ao3p = NULL;
  676. if( !useBuiltInFl )
  677. {
  678. ao2p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 4 );
  679. ao3p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 5 );
  680. }
  681. cmDspInst_t* al0p = cmDspSysAllocInst(h,"MsgList","audFiles", 2, "audFiles",NULL);
  682. cmDspInst_t* fl0p = cmDspSysAllocInst(h,"MsgList","audFragsA", 2, "audFrags",NULL);
  683. cmDspInst_t* fn0p = cmDspSysAllocInst(h,"Sprintf","filename", 1, "%s/%s_%02i.wav");
  684. cmDspInst_t* md0p = cmDspSysAllocInst(h,"Scalar", "Mode", 5, kNumberDuiId, 0.0, 4.0, 1.0, 1.0);
  685. cmDspInst_t* ws0p = cmDspSysAllocInst(h,"MsgList","wndSmpCnt", 3, "wndSmpCnt", NULL, 2);
  686. cmDspInst_t* hf0p = cmDspSysAllocInst(h,"MsgList","hopFact", 3, "hopFact", NULL, 2);
  687. cmDspInst_t* th0p = cmDspSysAllocInst(h,"Scalar", "threshold", 5, kNumberDuiId, 0.0, 100.0, 1.0, 60.0 );
  688. cmDspInst_t* us0p = cmDspSysAllocInst(h,"Scalar", "upr slope", 5, kNumberDuiId, 0.0, 10.0, 0.01, 0.0 );
  689. cmDspInst_t* ls0p = cmDspSysAllocInst(h,"Scalar", "lwr slope", 5, kNumberDuiId, 0.3, 10.0, 0.01, 2.0 );
  690. cmDspInst_t* of0p = cmDspSysAllocInst(h,"Scalar", "offset", 5, kNumberDuiId, 0.0, 100.0, 0.01, 30.0 );
  691. cmDspInst_t* iv0p = cmDspSysAllocInst(h,"Scalar", "invert", 5, kNumberDuiId, 0.0, 1.0, 1.0, 0.0 );
  692. cmDspSysNewColumn(h,0);
  693. //cmDspInst_t* al1p = cmDspSysAllocInst(h,"MsgList","audFiles", 2, "audFiles",NULL);
  694. //cmDspInst_t* fl1p = cmDspSysAllocInst(h,"MsgList","audFrags1", 2, "audFrags",NULL);
  695. //cmDspInst_t* fn1p = cmDspSysAllocInst(h,"Sprintf","filename", 1, "%s/%s_%02i.wav");
  696. cmDspInst_t* md1p = cmDspSysAllocInst(h,"Scalar", "Mode", 5, kNumberDuiId, 0.0, 4.0, 1.0, 1.0);
  697. cmDspInst_t* ws1p = cmDspSysAllocInst(h,"MsgList","wndSmpCnt", 3, "wndSmpCnt", NULL, 2);
  698. cmDspInst_t* hf1p = cmDspSysAllocInst(h,"MsgList","hopFact", 3, "hopFact", NULL, 2);
  699. cmDspInst_t* th1p = cmDspSysAllocInst(h,"Scalar", "threshold", 5, kNumberDuiId, 0.0, 100.0, 1.0, 60.0 );
  700. cmDspInst_t* us1p = cmDspSysAllocInst(h,"Scalar", "upr slope", 5, kNumberDuiId, 0.0, 10.0, 0.01, 0.0 );
  701. cmDspInst_t* ls1p = cmDspSysAllocInst(h,"Scalar", "lwr slope", 5, kNumberDuiId, 0.3, 10.0, 0.01, 2.0 );
  702. cmDspInst_t* of1p = cmDspSysAllocInst(h,"Scalar", "offset", 5, kNumberDuiId, 0.0, 100.0, 0.01, 30.0 );
  703. cmDspInst_t* iv1p = cmDspSysAllocInst(h,"Scalar", "invert", 5, kNumberDuiId, 0.0, 1.0, 1.0, 0.0 );
  704. cmDspSysNewColumn(h,0);
  705. cmDspInst_t* dnp = cmDspSysAllocInst(h,"Fname", "audDir", 3, true,NULL,afDir);
  706. cmDspInst_t* mtp = cmDspSysAllocInst(h,"Meter","MyMeter", 3, 50.0, 0.0, 100.0);
  707. cmDspInst_t* atp = cmDspSysAllocInst(h,"AMeter","Audio Meter",0);
  708. if( (rc = cmDspSysLastRC(h)) != kOkDspRC )
  709. return rc;
  710. cmDspSysConnectAudio(h, ph0p, "out", wt0p, "phs"); // phasor->wt:phs
  711. cmDspSysConnectAudio(h, wt0p, "out", kr0p, "in"); // wt->kr
  712. cmDspSysConnectAudio(h, kr0p, "out", ao0p, "in"); // kr->aout- 0
  713. cmDspSysConnectAudio(h, wt0p, "out", kr1p, "in"); // wt->kr
  714. cmDspSysConnectAudio(h, kr1p, "out", ao1p, "in"); // kr->aout - 1
  715. if( ao2p != NULL )
  716. cmDspSysConnectAudio(h, wt0p,"out", ao2p, "in"); // wt->aout - 2
  717. if( ao3p != NULL )
  718. cmDspSysConnectAudio(h, wt0p,"out", ao3p, "in"); // wt->aout - 3
  719. cmDspSysConnectAudio(h, wt0p,"out", atp, "in"); // wt->meter
  720. cmDspSysInstallCb(h, ws0p, "out", kr0p, "wndn", NULL ); // wndSmpCnt->kr
  721. cmDspSysInstallCb(h, hf0p, "out", kr0p, "hopf", NULL ); // hopFact->kr
  722. cmDspSysInstallCb(h, md0p, "val", kr0p, "mode", NULL ); // mode->kr
  723. cmDspSysInstallCb(h, th0p, "val", kr0p, "thrh", NULL ); // thresh->kr
  724. cmDspSysInstallCb(h, ls0p, "val", kr0p, "lwrs", NULL ); // lwrSlope->kr
  725. cmDspSysInstallCb(h, us0p, "val", kr0p, "uprs", NULL ); // uprSlope->kr
  726. cmDspSysInstallCb(h, of0p, "val", kr0p, "offs", NULL ); // offset->kr
  727. cmDspSysInstallCb(h, iv0p, "val", kr0p, "invt", NULL ); // invert->kr
  728. cmDspSysInstallCb(h, th0p, "val", mtp, "in", NULL );
  729. cmDspSysInstallCb(h, ws1p, "out", kr1p, "wndn", NULL ); // wndSmpCnt->kr
  730. cmDspSysInstallCb(h, hf1p, "out", kr1p, "hopf", NULL ); // hopFact->kr
  731. cmDspSysInstallCb(h, md1p, "val", kr1p, "mode", NULL ); // mode->kr
  732. cmDspSysInstallCb(h, th1p, "val", kr1p, "thrh", NULL ); // thresh->kr
  733. cmDspSysInstallCb(h, ls1p, "val", kr1p, "lwrs", NULL ); // lwrSlope->kr
  734. cmDspSysInstallCb(h, us1p, "val", kr1p, "uprs", NULL ); // uprSlope->kr
  735. cmDspSysInstallCb(h, of1p, "val", kr1p, "offs", NULL ); // offset->kr
  736. cmDspSysInstallCb(h, iv1p, "val", kr1p, "invt", NULL ); // invert->kr
  737. cmDspSysInstallCb(h, dnp, "out", fn0p, "in-0", NULL); // dir->fn:0
  738. cmDspSysInstallCb(h, al0p, "out", fn0p, "in-1", NULL ); // fn->fn:1
  739. cmDspSysInstallCb(h, fl0p, "take", fn0p, "in-2", NULL ); // take->fn:2
  740. cmDspSysInstallCb(h, fn0p, "out", ro0p, "in-0", NULL); // fn->print
  741. cmDspSysInstallCb(h, fl0p, "beg", ro0p, "in-1", NULL); //
  742. cmDspSysInstallCb(h, fl0p, "end", ro0p, "in-2", NULL); //
  743. cmDspSysInstallCb(h, ro0p, "out-0", wt0p, "fn", NULL ); // fn->wt:fn
  744. cmDspSysInstallCb(h, ro0p, "out-1", wt0p, "beg", NULL ); // beg->wt:beg
  745. cmDspSysInstallCb(h, ro0p, "out-2", wt0p, "end", NULL ); // end->wt:end
  746. cmDspSysInstallCb(h, ro0p, "out-1", prp, "in", NULL ); //
  747. //cmDspSysInstallCb(h, dnp, "out", fn1p, "in-0", NULL); // dir->fn:0
  748. //cmDspSysInstallCb(h, al1p, "out", fn1p, "in-1", NULL ); // fn->fn:1
  749. //cmDspSysInstallCb(h, fl1p, "take", fn1p, "in-2", NULL ); // take->fn:2
  750. //cmDspSysInstallCb(h, fn1p, "out", ro1p, "in-0", NULL); // fn->print
  751. //cmDspSysInstallCb(h, fl1p, "beg", ro1p, "in-1", NULL); //
  752. //cmDspSysInstallCb(h, fl1p, "end", ro1p, "in-2", NULL); //
  753. //cmDspSysInstallCb(h, ro1p, "out-0", wt1p, "fn", NULL ); // fn->wt:fn
  754. //cmDspSysInstallCb(h, ro1p, "out-1", wt1p, "beg", NULL ); // beg->wt:beg
  755. //cmDspSysInstallCb(h, ro1p, "out-2", wt1p, "end", NULL ); // end->wt:end
  756. return cmDspSysLastRC(h);
  757. }
  758. cmDspRC_t _cmDspSysPgm_Pickups0( cmDspSysH_t h, void** userPtrPtr )
  759. {
  760. unsigned i;
  761. unsigned chCnt = 8;
  762. double delayFb = 0.0;
  763. double delayMaxMs = 1000.0;
  764. cmDspInst_t* chArray[chCnt];
  765. cmDspInst_t* m_mxWet = cmDspSysAllocInst(h,"Scalar", "Mstr Wet", 5, kNumberDuiId, 0.0, 2.0, 0.01, 1.0 );
  766. cmDspInst_t* m_mxDry = cmDspSysAllocInst(h,"Scalar", "Mstr Dry", 5, kNumberDuiId, 0.0, 2.0, 0.01, 1.0 );
  767. cmDspSysNewColumn(h,0);
  768. cmDspInst_t* m_lpByp = cmDspSysAllocInst(h,"Button", "Mstr Lp Byps", 2, kCheckDuiId, 0.0 );
  769. cmDspInst_t* m_lpRcd = cmDspSysAllocInst(h,"Button", "Mstr Lp Recd", 2, kCheckDuiId, 0.0 );
  770. cmDspInst_t* m_lpRat = cmDspSysAllocInst(h,"Scalar", "Mstr Lp Ratio", 5, kNumberDuiId, 0.0, 10.0, 0.01, 1.0 );
  771. cmDspSysNewColumn(h,0);
  772. cmDspInst_t* m_dlyByp = cmDspSysAllocInst(h,"Button", "Mstr Dly Byps", 2, kCheckDuiId, 0.0 );
  773. cmDspInst_t* m_dlyMs = cmDspSysAllocInst(h,"Scalar", "Mstr Dly Time", 5, kNumberDuiId, 0.0, delayMaxMs, 1.0, 0.0 );
  774. cmDspInst_t* m_dlyFb = cmDspSysAllocInst(h,"Scalar", "Mstr Dly Fb", 5, kNumberDuiId, 0.0, 0.999, 0.01, 0.0 );
  775. cmDspSysNewColumn(h,0);
  776. cmDspInst_t* m_psByp = cmDspSysAllocInst(h,"Button", "Mstr PS Byps", 2, kCheckDuiId, 0.0 );
  777. cmDspInst_t* m_psRat = cmDspSysAllocInst(h,"Scalar", "Mstr PS Ratio", 5, kNumberDuiId, 0.0, 10.0, 0.01, 1.0 );
  778. cmDspSysNewColumn(h,0);
  779. cmDspInst_t* m_rcByp = cmDspSysAllocInst(h,"Button", "Mstr Rect Byps", 2, kCheckDuiId, 0.0 );
  780. cmDspSysInsertHorzBorder(h);
  781. for(i=0; i<chCnt; ++i)
  782. {
  783. int chIdx = i;
  784. cmDspInst_t* mxWet = cmDspSysAllocInst(h,"Scalar", "Wet", 5, kNumberDuiId, 0.0, 2.0, 0.01, 1.0 );
  785. cmDspInst_t* mxDry = cmDspSysAllocInst(h,"Scalar", "Dry", 5, kNumberDuiId, 0.0, 2.0, 0.01, 1.0 );
  786. cmDspInst_t* lpByp = cmDspSysAllocInst(h,"Button", "Lp Byps", 2, kCheckDuiId, 0.0 );
  787. cmDspInst_t* lpRcd = cmDspSysAllocInst(h,"Button", "Lp Recd", 2, kCheckDuiId, 0.0 );
  788. cmDspInst_t* lpRat = cmDspSysAllocInst(h,"Scalar", "Lp Ratio", 5, kNumberDuiId, 0.0, 10.0, 0.01, 1.0 );
  789. cmDspInst_t* dlyByp = cmDspSysAllocInst(h,"Button", "Delay Byps", 2, kCheckDuiId, 0.0 );
  790. cmDspInst_t* dlyMs = cmDspSysAllocInst(h,"Scalar", "Delay Time", 5, kNumberDuiId, 0.0, delayMaxMs, 1.0, 0.0 );
  791. cmDspInst_t* dlyFb = cmDspSysAllocInst(h,"Scalar", "Delay Fb", 5, kNumberDuiId, 0.0, 0.999, 0.01, 0.0 );
  792. cmDspInst_t* psByp = cmDspSysAllocInst(h,"Button", "PS Byps", 2, kCheckDuiId, 0.0 );
  793. cmDspInst_t* psRat = cmDspSysAllocInst(h,"Scalar", "PS Ratio", 5, kNumberDuiId, 0.0, 10.0, 0.01, 1.0 );
  794. cmDspInst_t* rcByp = cmDspSysAllocInst(h,"Button", "Rect Byps", 2, kCheckDuiId, 0.0 );
  795. cmDspInst_t* ain = cmDspSysAllocInst(h, "AudioIn", NULL, 1, chIdx );
  796. cmDspInst_t* loop = cmDspSysAllocInst(h, "LoopRecd", NULL, 0 );
  797. cmDspInst_t* dely = cmDspSysAllocInst(h, "Delay", NULL, 2, delayMaxMs, delayFb );
  798. cmDspInst_t* pshf = cmDspSysAllocInst(h, "PShift", NULL, 0 );
  799. cmDspInst_t* rect = cmDspSysAllocInst(h, "Rectify", NULL, 0 );
  800. cmDspInst_t* amix = cmDspSysAllocInst(h, "AMix", NULL, 1, 2 );
  801. //cmDspInst_t* aout = cmDspSysAllocInst(h, "AudioOut", NULL, 1, chIdx );
  802. chArray[i] = amix;
  803. cmDspSysNewColumn(h,0);
  804. cmDspSysConnectAudio(h, ain, "out", loop, "in"); // ain -> loop
  805. cmDspSysConnectAudio(h, loop, "out", dely, "in"); // loop -> delay
  806. cmDspSysConnectAudio(h, dely, "out", pshf, "in"); // delay -> pshf
  807. cmDspSysConnectAudio(h, pshf, "out", rect, "in"); // pshf -> rect
  808. cmDspSysConnectAudio(h, rect, "out", amix, "in-0"); // rect -> mix_wet
  809. cmDspSysConnectAudio(h, ain, "out", amix, "in-1"); // ain -> mix_dry
  810. //cmDspSysConnectAudio(h, amix, "out", aout, "in"); // mix -> out
  811. cmDspSysInstallCb(h, mxWet, "val", amix, "gain-0", NULL );
  812. cmDspSysInstallCb(h, mxDry, "val", amix, "gain-1", NULL );
  813. cmDspSysInstallCb(h, lpByp, "out", loop, "bypass", NULL );
  814. cmDspSysInstallCb(h, lpRcd, "out", loop, "recd", NULL );
  815. cmDspSysInstallCb(h, lpRat, "val", loop, "ratio", NULL );
  816. cmDspSysInstallCb(h, dlyByp,"val", dely, "bypass", NULL );
  817. cmDspSysInstallCb(h, dlyMs, "val", dely, "time", NULL );
  818. cmDspSysInstallCb(h, dlyFb, "out", dely, "fb", NULL );
  819. cmDspSysInstallCb(h, psByp, "out", pshf, "bypass", NULL );
  820. cmDspSysInstallCb(h, psRat, "val", pshf, "ratio", NULL );
  821. cmDspSysInstallCb(h, rcByp, "out", rect, "bypass", NULL );
  822. cmDspSysInstallCb(h, m_mxWet, "val", mxWet, "in", NULL );
  823. cmDspSysInstallCb(h, m_mxDry, "val", mxDry, "in", NULL );
  824. cmDspSysInstallCb(h, m_lpByp, "out", lpByp, "in", NULL );
  825. cmDspSysInstallCb(h, m_lpRcd, "out", lpRcd, "in", NULL );
  826. cmDspSysInstallCb(h, m_lpRat, "val", lpRat, "in", NULL );
  827. cmDspSysInstallCb(h, m_dlyByp,"out", dlyByp,"in", NULL );
  828. cmDspSysInstallCb(h, m_dlyMs, "val", dlyMs, "in", NULL );
  829. cmDspSysInstallCb(h, m_dlyFb, "val", dlyFb, "in", NULL );
  830. cmDspSysInstallCb(h, m_psByp, "out", psByp, "in", NULL );
  831. cmDspSysInstallCb(h, m_psRat, "val", psRat, "in", NULL );
  832. cmDspSysInstallCb(h, m_rcByp, "out", rcByp, "in", NULL );
  833. }
  834. double dfltGain = 0.5;
  835. cmDspInst_t* omix = cmDspSysAllocInst(h, "AMix", NULL, 9, 8, dfltGain, dfltGain, dfltGain, dfltGain, dfltGain, dfltGain, dfltGain, dfltGain );
  836. cmDspInst_t* aout0 = cmDspSysAllocInst(h, "AudioOut", NULL, 1, 0 );
  837. cmDspInst_t* aout1 = cmDspSysAllocInst(h, "AudioOut", NULL, 1, 1 );
  838. cmDspInst_t* aout2 = cmDspSysAllocInst(h, "AudioOut", NULL, 1, 2 );
  839. cmDspInst_t* aout3 = cmDspSysAllocInst(h, "AudioOut", NULL, 1, 3 );
  840. for(i=0; i<chCnt; ++i)
  841. {
  842. char label[32];
  843. snprintf(label,32,"in-%i",i);
  844. cmDspSysConnectAudio(h, chArray[i], "out", omix, label);
  845. }
  846. cmDspSysConnectAudio(h, omix, "out", aout0, "in");
  847. cmDspSysConnectAudio(h, omix, "out", aout1, "in");
  848. cmDspSysConnectAudio(h, omix, "out", aout2, "in");
  849. cmDspSysConnectAudio(h, omix, "out", aout3, "in");
  850. return kOkDspRC;
  851. }
  852. #include "cmAudioFile.h"
  853. #include "cmProcObj.h"
  854. #include "cmProc.h"
  855. #include "cmProc3.h"
  856. // Usage:
  857. // 1) Push 'start'.
  858. // 2) Select the first element in the Ch Cfg List UI.
  859. // 3) Play several examples of the note.
  860. // 4) Select the next element in the Ch Cfg List UI.
  861. // 5) Go to 3) until all ch's have been played.
  862. // 6) Push 'proc'. A new set of gains will be calc'd and sent to the audio input channels.
  863. // Note that if a mistake is made while playing a set of notes in 3) then
  864. // push select the same element from the list again and replay.
  865. // The order the notes are played in does not make any difference.
  866. cmDspRC_t _cmDspSysPgm_AutoGain( cmDspSysH_t h, void** userPtrPtr )
  867. {
  868. cmDspRC_t rc = kOkDspRC;
  869. unsigned i;
  870. //unsigned j;
  871. cmErr_t err;
  872. const cmChar_t* errLabelPtr = NULL;
  873. cmCtx_t* cmCtx = cmDspSysPgmCtx(h);
  874. unsigned chCnt = 0;
  875. unsigned nsChCnt = 0;
  876. const cmChar_t* chCfgFn = NULL;
  877. const cmChar_t* chCfgPath = NULL;
  878. unsigned agMedCnt = 5;
  879. unsigned agAvgCnt = 9;
  880. unsigned agSuprCnt = 3;
  881. unsigned agOffCnt = 3;
  882. cmReal_t agSuprCoeff = 1.4;
  883. cmReal_t agOnThreshDb = -53.0;
  884. cmReal_t agOffThreshDb = -80.0;
  885. cmReal_t agHopMs = 25;
  886. //cmReal_t cdMaxTimeSpanMs = 50;
  887. //cmReal_t cdMinNoteCnt = 3;
  888. unsigned labelCharCnt = 31;
  889. char label0[ labelCharCnt + 1];
  890. cmErrSetup(&err,&cmCtx->rpt,"Auto-gain");
  891. // get the name of channel cfg file
  892. if( cmJsonPathValues( cmDspSysPgmRsrcHandle(h),"cfg/",NULL,&errLabelPtr,
  893. "chCfgFn", kStringTId, &chCfgFn,
  894. "agParms/hopMs", kRealTId, &agHopMs,
  895. "agParms/medCnt", kIntTId, &agMedCnt,
  896. "agParms/avgCnt", kIntTId, &agAvgCnt,
  897. "agParms/suprCnt", kIntTId, &agSuprCnt,
  898. "agParms/offCnt", kIntTId, &agOffCnt,
  899. "agParms/suprCoeff", kRealTId, &agSuprCoeff,
  900. "agParms/onThreshDb", kRealTId, &agOnThreshDb,
  901. "agParms/offThreshDb", kRealTId, &agOffThreshDb,
  902. NULL) != kOkJsRC )
  903. {
  904. rc = cmErrMsg(&err,kPgmCfgFailDspRC,"An error occurred while reading the required auto-tune JSON parameters.");
  905. goto errLabel;
  906. }
  907. // get the count of channels from the ch. cfg. array
  908. if(( chCnt = cmChCfgChannelCount(cmCtx,chCfgFn,&nsChCnt)) == 0 )
  909. {
  910. rc = cmErrMsg(&err,kPgmCfgFailDspRC,"Unable to obtain the channel count from '%s'.",cmStringNullGuard(chCfgFn));
  911. goto errLabel;
  912. }
  913. // prepend the prefs directory to the ch. cfg filename
  914. chCfgPath = cmFsMakeFn(cmFsPrefsDir(),chCfgFn,NULL,NULL);
  915. if( rc == kOkDspRC )
  916. {
  917. //mDspInst_t* ain[chCnt];
  918. cmDspInst_t* ef[chCnt];
  919. cmDspInst_t* mtr[chCnt];
  920. cmDspInst_t* amtr[chCnt];
  921. cmDspInst_t* on[chCnt];
  922. cmDspInst_t* off[chCnt];
  923. cmDspInst_t* rms[chCnt];
  924. ///cmDspInst_t* fdr0[chCnt];
  925. ///cmDspInst_t* fdr1[chCnt];
  926. ///cmDspInst_t* fdr2[chCnt];
  927. // allocate the audio inputs
  928. //for(i=0; i<chCnt; ++i)
  929. // ain[i] = cmDspSysAllocAudioIn(h,i,1.0);
  930. unsigned inChCnt;
  931. cmDspInst_t** ain = cmDspSysAllocAudioInAR( h, "audioInMap", 1.0, &inChCnt );
  932. // allocate the auto-gain calibration object
  933. cmDspInst_t* ag = cmDspSysAllocInst( h, "AutoGain", NULL, 9, chCnt, agHopMs,agMedCnt,agAvgCnt,agSuprCnt,agOffCnt,agSuprCoeff,agOnThreshDb,agOffThreshDb );
  934. // allocate the command buttons
  935. cmDspInst_t* start = cmDspSysAllocButton(h, "start", 0);
  936. cmDspInst_t* proc = cmDspSysAllocButton(h, "proc", 0);
  937. cmDspInst_t* cancel = cmDspSysAllocButton(h, "cancel", 0);
  938. cmDspInst_t* write = cmDspSysAllocButton(h, "write", 0);
  939. cmDspInst_t* print = cmDspSysAllocButton(h, "print", 0);
  940. cmDspInst_t* chMenu = cmDspSysAllocMsgList(h, chCfgPath, "ch_array", 0 );
  941. cmDspInst_t* onThr = cmDspSysAllocScalar(h,"On Thresh",-100.0,0.0,0.1,-45.0);
  942. cmDspInst_t* offThr = cmDspSysAllocScalar(h,"Off Thresh",-100.0,0.0,0.1,-80.0);
  943. //cmDspInst_t* prt = cmDspSysAllocInst(h,"Printer",NULL,1,"ag>");
  944. cmDspInst_t* sub = cmDspSysAllocInst(h,"ScalarOp",NULL,6,2,"+","in-0",0.0,"in-1",-1.0);
  945. cmDspSysNewColumn(h,200);
  946. cmDspSysAllocLabel(h,"EF Gate",kLeftAlignDuiId);
  947. // allocate the envelope followers and meters
  948. for(i=0; i<chCnt; ++i )
  949. {
  950. snprintf(label0,labelCharCnt,"%2i",i);
  951. ef[i] = cmDspSysAllocInst( h, "EnvFollow", NULL, 0 );
  952. mtr[i] = cmDspSysAllocInst( h, "Meter",label0, 3, 0.0, 0.0, 1.0 );
  953. }
  954. cmDspSysNewColumn(h,200);
  955. cmDspSysAllocLabel(h,"Audio",kLeftAlignDuiId);
  956. // allocate the envelope followers and meters
  957. for(i=0; i<chCnt; ++i )
  958. {
  959. amtr[i] = cmDspSysAllocInst( h, "AMeter", NULL, 0 );
  960. }
  961. // chord detector, note selector, mix0, mix1, mix2
  962. ///cmDspInst_t* cdp = cmDspSysAllocInst(h, "ChordDetect", NULL, 1, "cdSel" );
  963. ///cmDspInst_t* nsp = cmDspSysAllocInst(h, "NoteSelect", NULL, 1, chCnt );
  964. // onset count display
  965. cmDspSysNewColumn(h,150);
  966. cmDspSysAllocLabel(h,"Onsets",kLeftAlignDuiId);
  967. for(i=0; i<chCnt; ++i)
  968. on[i] = cmDspSysAllocScalar(h,NULL,0,1,0,0);
  969. // offset count display
  970. cmDspSysNewColumn(h,150);
  971. cmDspSysAllocLabel(h,"Offsets",kLeftAlignDuiId);
  972. for(i=0; i<chCnt; ++i)
  973. off[i] = cmDspSysAllocScalar(h,NULL,0,1,0,0);
  974. // offset count display
  975. cmDspSysNewColumn(h,150);
  976. cmDspSysAllocLabel(h,"RMS",kLeftAlignDuiId);
  977. for(i=0; i<chCnt; ++i)
  978. rms[i] = cmDspSysAllocScalar(h,NULL,0,1,0,0);
  979. /*
  980. // note select gate meters
  981. for(j=0; j<3; ++j)
  982. {
  983. snprintf(label0,labelCharCnt,"Set %i",j);
  984. cmDspSysNewColumn(h,50);
  985. cmDspSysAllocLabel(h,label0,kLeftAlignDuiId );
  986. for(i=0; i<chCnt; ++i)
  987. {
  988. cmDspInst_t* m = cmDspSysAllocInst(h, "Meter", NULL, 3, 0.0, 0.0, 1.0 );
  989. switch(j)
  990. {
  991. case 0: fdr0[i] = m; break;
  992. case 1: fdr1[i] = m; break;
  993. case 2: fdr2[i] = m; break;
  994. }
  995. }
  996. }
  997. // chord detector parameters
  998. cmDspSysNewColumn(h,150);
  999. cmDspSysAllocLabel(h,"Chord Detector",kLeftAlignDuiId);
  1000. cmDspInst_t* cdSpanMs = cmDspSysAllocScalar(h,"Span Ms", 10.0,1000.0,1.0,cdMaxTimeSpanMs);
  1001. cmDspInst_t* cdNoteCnt = cmDspSysAllocScalar(h,"Note Cnt", 1.0, 100.0,1.0,cdMinNoteCnt );
  1002. cmDspInst_t* cdCount = cmDspSysAllocScalar(h,"Ch. Count", 0,1,0,0);
  1003. */
  1004. // allocate an audio mixer and two audio output channels
  1005. cmDspInst_t* amix = cmDspSysAllocInst( h, "AMix", NULL, 1, chCnt);
  1006. cmDspInst_t* ao0 = cmDspSysAllocAudioOut(h,0,1.0);
  1007. cmDspInst_t* ao1 = cmDspSysAllocAudioOut(h,1,1.0);
  1008. // alloc chCfg last so that it's default outputs are applied to connected objects
  1009. cmDspInst_t* chCfg = cmDspSysAllocInst( h, "ChCfg", NULL, 1, chCfgFn );
  1010. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1011. goto errLabel;
  1012. cmDspSysConnectAudioN11N(h,ain, "out", ag, "in", chCnt); // ain -> auto gain
  1013. cmDspSysConnectAudioN11N(h,ain, "out", amix, "in", chCnt); // ain -> amix
  1014. cmDspSysConnectAudioN1N1(h,ain, "out", ef, "in", chCnt); // ain -> EF
  1015. cmDspSysConnectAudioN1N1(h, ain, "out", amtr, "in",chCnt);
  1016. cmDspSysInstallCb1N1N(h, ag, "gain", chCfg, "gain", chCnt ); // ag -> chCfg (gain)
  1017. cmDspSysInstallCb1NN1(h, chCfg, "gain", ain, "gain", chCnt ); // cgCfg -> ain (gain)
  1018. cmDspSysInstallCb1NN1(h, chCfg, "ch", ain, "ch", chCnt ); // cgCfg -> ain (ch)
  1019. cmDspSysInstallCbN1N1(h, ef, "gate", mtr, "in", chCnt ); // EF gate -> meter
  1020. cmDspSysInstallCb11N1(h, onThr, "val", ef, "ondb", chCnt ); //
  1021. cmDspSysInstallCb11N1(h, offThr, "val", ef, "offdb", chCnt ); //
  1022. cmDspSysInstallCbN1N1(h, ef, "ons", on, "val", chCnt ); // EF -> onset count
  1023. cmDspSysInstallCbN1N1(h, ef, "offs", off, "val", chCnt ); // EF -> offset count
  1024. cmDspSysInstallCbN1N1(h, ef, "rms", rms, "val", chCnt );
  1025. ///cmDspSysInstallCbN11N(h, ef, "gate", cdp, "gate", chCnt ); // EF -> CD gate
  1026. ///cmDspSysInstallCbN11N(h, ef, "rms", cdp, "rms", chCnt ); // EF -> CD rms
  1027. ///cmDspSysInstallCb1N1N(h, cdp, "gate", nsp, "gate", chCnt ); // CD -> NS gate
  1028. ///cmDspSysInstallCb1N1N(h, cdp, "rms", nsp, "rms", chCnt ); // CD -> NS rms
  1029. ///cmDspSysInstallCb1NN1(h, nsp, "gate-0",fdr0, "in", chCnt ); // NS -> Fader 0 gate
  1030. ///cmDspSysInstallCb1NN1(h, nsp, "gate-1",fdr1, "in", chCnt ); // NS -> Fader 1 gate
  1031. ///cmDspSysInstallCb1NN1(h, nsp, "gate-2",fdr2, "in", chCnt ); // NS -> Fader 2 gate
  1032. cmDspSysConnectAudio(h, amix, "out", ao0, "in"); // amix -> aout 0
  1033. cmDspSysConnectAudio(h, amix, "out", ao1, "in"); // amix -> aout 1
  1034. //cmDspSysInstallCb(h, chMenu, "ch", ag, "id", NULL );
  1035. cmDspSysInstallCb(h, chMenu, "sel", sub, "in-0", NULL );
  1036. cmDspSysInstallCb(h, sub, "out", ag, "id", NULL );
  1037. cmDspSysInstallCb(h, start, "sym", ag, "sel", NULL );
  1038. cmDspSysInstallCb(h, proc, "sym", ag, "sel", NULL );
  1039. cmDspSysInstallCb(h, cancel, "sym", ag, "sel", NULL );
  1040. cmDspSysInstallCb(h, print, "sym", ag, "sel", NULL );
  1041. cmDspSysInstallCb(h, print, "sym", chCfg, "sel", NULL );
  1042. cmDspSysInstallCb(h, write, "sym", chCfg, "sel", NULL );
  1043. /*
  1044. cmDspSysInstallCb(h, cdSpanMs, "val", cdp, "span", NULL );
  1045. cmDspSysInstallCb(h, cdNoteCnt, "val", cdp, "notes", NULL );
  1046. cmDspSysInstallCb(h, cdp, "count", cdCount, "val", NULL );
  1047. cmDspSysInstallCb(h, cdp, "detect", nsp, "trig", NULL );
  1048. */
  1049. }
  1050. errLabel:
  1051. cmFsFreeFn(chCfgPath);
  1052. return rc;
  1053. }
  1054. cmDspRC_t _cmDspSysPgm_PickupFxFile( cmDspSysH_t h, void** userPtrPtr )
  1055. {
  1056. cmDspRC_t rc = kOkDspRC;
  1057. cmErr_t err;
  1058. cmCtx_t* cmCtx = cmDspSysPgmCtx(h);
  1059. unsigned chCnt = 0;
  1060. unsigned nsChCnt = 0;
  1061. const cmChar_t* chCfgPath = NULL;
  1062. const cmChar_t* chCfgFn = "pick_chs8.js";
  1063. double cfMinHz = 20.0;
  1064. double cfAlpha = 0.9;
  1065. bool cfFbFl = true;
  1066. unsigned sgShapeId = 2;
  1067. const cmChar_t* afn = "/home/kevin/media/audio/gate_detect/gate_detect0.aif";
  1068. double abeg[] = { 9.842046, 18.838291, 27.007957, 35.562079, 45.461793, 52.920218, 60.436312, 68.913543};
  1069. double aend[] = {11.399088, 20.645229, 28.891786, 37.311349, 47.287954, 54.131251, 62.473923, 72.142964};
  1070. bool cfBypassFl = false;
  1071. unsigned i;
  1072. cmErrSetup(&err,&cmCtx->rpt,"Pickup Effects");
  1073. // prepend the prefs directory to the ch. cfg filename
  1074. chCfgPath = cmFsMakeFn(cmFsPrefsDir(),chCfgFn,NULL,NULL);
  1075. // get the count of channels from the ch. cfg. array
  1076. if(( chCnt = cmChCfgChannelCount(cmCtx,chCfgFn,&nsChCnt)) == 0 )
  1077. {
  1078. rc = cmErrMsg(&err,kPgmCfgFailDspRC,"Unable to obtain the channel count from '%s'.",cmStringNullGuard(chCfgFn));
  1079. goto errLabel;
  1080. }
  1081. if( rc == kOkDspRC )
  1082. {
  1083. cmDspInst_t* af[chCnt];
  1084. //cmDspInst_t* aout[chCnt];
  1085. cmDspInst_t* ef[chCnt];
  1086. cmDspInst_t* cf[chCnt];
  1087. cmDspInst_t* sg[chCnt];
  1088. cmDspInst_t* mtr[chCnt];
  1089. cmDspInst_t* mute[chCnt];
  1090. cmDspInst_t* phs = cmDspSysAllocInst(h,"Phasor", NULL, 0 );
  1091. // allocate the audio inputs
  1092. for(i=0; i<chCnt; ++i)
  1093. {
  1094. unsigned labelCharCnt = 31;
  1095. cmChar_t label[labelCharCnt+1];
  1096. snprintf(label,labelCharCnt,"%i",i);
  1097. int sbeg = floor(abeg[i] * cmDspSysSampleRate(h));
  1098. int send = floor(aend[i] * cmDspSysSampleRate(h));
  1099. //ain[i] = cmDspSysAllocAudioIn( h,i,1.0);
  1100. af[i] = cmDspSysAllocInst(h,"WaveTable",NULL, 6, ((int)cmDspSysSampleRate(h)), 1, afn, -1, sbeg, send );
  1101. //aout[i] = cmDspSysAllocAudioOut(h,i,1.0);
  1102. ef[i] = cmDspSysAllocInst(h, "EnvFollow", NULL, 0 );
  1103. sg[i] = cmDspSysAllocInst(h, "SigGen", NULL, 2, 1000.0, sgShapeId );
  1104. cf[i] = cmDspSysAllocInst(h, "CombFilt", NULL, 5, cfBypassFl, cfMinHz, cfFbFl, cfMinHz, cfAlpha );
  1105. mtr[i] = cmDspSysAllocInst( h, "Meter",label, 3, 0.0, 0.0, 1.0 );
  1106. }
  1107. // allocate the ch cfg last so that it's default outputs initialize connected objects
  1108. cmDspInst_t* chCfg = cmDspSysAllocInst( h, "ChCfg", NULL, 1, chCfgFn );
  1109. cmDspInst_t* mix = cmDspSysAllocInst( h, "AMix", NULL, 1, chCnt );
  1110. cmDspSysNewColumn(h,50);
  1111. for(i=0; i<chCnt; ++i)
  1112. mute[i] = cmDspSysAllocCheck(h,"",0);
  1113. // checkk for allocation errors
  1114. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1115. goto errLabel;
  1116. //
  1117. //cmDspSysConnectAudioN1N1(h, ain, "out", aout, "in", chCnt );
  1118. cmDspSysConnectAudio11N1(h, phs, "out", af, "phs", chCnt );
  1119. cmDspSysConnectAudioN1N1(h, af, "out", ef, "in", chCnt ); // af -> EF
  1120. cmDspSysConnectAudioN1N1(h, sg, "out", cf, "in", chCnt ); // sg -> CF
  1121. cmDspSysConnectAudioN11N(h, cf, "out", mix, "in", chCnt ); // CF -> mix
  1122. //cmDspSysInstallCb1NN1( h, chCfg, "gain", ain, "gain", chCnt ); // chCfg -> ain gain
  1123. cmDspSysInstallCb1NN1( h, chCfg, "hz", cf, "hz", chCnt ); // chCfg -> CF Hz
  1124. //cmDspSysInstallCbN1N1( h, ef, "rms", aout, "gain", chCnt ); // EF -> aout gain
  1125. cmDspSysInstallCbN1N1( h, ef, "rms", mtr, "in", chCnt ); // EF -> meter RMS
  1126. cmDspSysInstallCbN11N( h, ef, "rms", mix, "gain", chCnt );
  1127. cmDspSysInstallCbN11N( h, mute, "out", mix, "mute", chCnt ); // mute -> mix
  1128. }
  1129. errLabel:
  1130. cmFsFreeFn(chCfgPath);
  1131. return rc;
  1132. }
  1133. cmDspRC_t _cmDspSysPgm_NoiseTails( cmDspSysH_t h, void** userPtrPtr )
  1134. {
  1135. cmDspRC_t rc = kOkDspRC;
  1136. cmErr_t err;
  1137. cmCtx_t* cmCtx = cmDspSysPgmCtx(h);
  1138. unsigned chCnt = 0;
  1139. unsigned nsChCnt = 0;
  1140. const cmChar_t* chCfgPath = NULL;
  1141. const cmChar_t* chCfgFn = "pick_chs8.js";
  1142. double cfMinHz = 20.0;
  1143. double cfHz = 500;
  1144. double cfAlpha = 0.9;
  1145. bool cfFbFl = true;
  1146. bool cfBypassFl= false;
  1147. unsigned sgShapeId = 3;
  1148. double dfltDelayMs = 100;
  1149. unsigned i;
  1150. cmErrSetup(&err,&cmCtx->rpt,"Noise Tails");
  1151. // prepend the prefs directory to the ch. cfg filename
  1152. chCfgPath = cmFsMakeFn(cmFsPrefsDir(),chCfgFn,NULL,NULL);
  1153. // get the count of channels from the ch. cfg. array
  1154. if(( chCnt = cmChCfgChannelCount(cmCtx,chCfgFn,&nsChCnt)) == 0 )
  1155. {
  1156. rc = cmErrMsg(&err,kPgmCfgFailDspRC,"Unable to obtain the channel count from '%s'.",cmStringNullGuard(chCfgFn));
  1157. goto errLabel;
  1158. }
  1159. if( rc == kOkDspRC )
  1160. {
  1161. cmDspInst_t* ain[chCnt];
  1162. cmDspInst_t* ef[chCnt];
  1163. cmDspInst_t* cf[chCnt];
  1164. cmDspInst_t* sg[chCnt];
  1165. cmDspInst_t* mtr[chCnt];
  1166. cmDspInst_t* add[chCnt];
  1167. cmDspInst_t* mul[chCnt];
  1168. cmDspInst_t* dly[chCnt];
  1169. // allocate the audio inputs
  1170. for(i=0; i<chCnt; ++i)
  1171. {
  1172. unsigned labelCharCnt = 31;
  1173. cmChar_t label[labelCharCnt+1];
  1174. snprintf(label,labelCharCnt,"%i",i);
  1175. ain[i] = cmDspSysAllocAudioIn( h, i, 1.0);
  1176. ef[i] = cmDspSysAllocInst( h, "EnvFollow", NULL, 0 );
  1177. sg[i] = cmDspSysAllocInst( h, "SigGen", NULL, 2, 1000.0, sgShapeId );
  1178. cf[i] = cmDspSysAllocInst( h, "CombFilt", NULL, 5, cfBypassFl, cfMinHz, cfFbFl, cfHz, cfAlpha );
  1179. mtr[i] = cmDspSysAllocInst( h, "Meter",label, 3, 0.0, 0.0, 1.0 );
  1180. add[i] = cmDspSysAllocInst( h, "ScalarOp", NULL, 6, 2, "+", "in-0", 0.0, "in-1", 0.0);
  1181. mul[i] = cmDspSysAllocInst( h, "ScalarOp", NULL, 6, 2, "*", "in-0", 0.0, "in-1", 0.99);
  1182. dly[i] = cmDspSysAllocInst( h, "MsgDelay", NULL, 2, 1000, dfltDelayMs );
  1183. }
  1184. // allocate the ch cfg last so that it's default outputs initialize connected objects
  1185. cmDspInst_t* chCfg = cmDspSysAllocInst( h, "ChCfg", NULL, 1, chCfgFn );
  1186. cmDspInst_t* mix = cmDspSysAllocInst( h, "AMix", NULL, 1, chCnt );
  1187. cmDspInst_t* ao0 = cmDspSysAllocAudioOut( h, 0, 1.0 );
  1188. cmDspInst_t* ao1 = cmDspSysAllocAudioOut( h, 1, 1.0 );
  1189. cmDspInst_t* alpha = cmDspSysAllocScalar( h, "alpha", -1.0, 1.0, 0.001, cfAlpha );
  1190. cmDspInst_t* decay = cmDspSysAllocScalar( h, "decay", -1.0, 1.0, 0.001, 0.5);
  1191. cmDspInst_t* delay = cmDspSysAllocScalar( h, "delay", 0.0, 1000.0, 1.0, dfltDelayMs );
  1192. cmDspInst_t* zero = cmDspSysAllocScalar( h, "zero", 0.0, 0.0, 0.0, 0.0);
  1193. // check for allocation errors
  1194. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1195. goto errLabel;
  1196. cmDspSysConnectAudioN1N1( h, ain, "out", ef, "in", chCnt ); // ain -> EF
  1197. cmDspSysConnectAudioN1N1( h, sg, "out", cf, "in", chCnt ); // sg -> CF
  1198. cmDspSysConnectAudioN11N( h, cf, "out", mix, "in", chCnt ); // cf -> mix
  1199. cmDspSysConnectAudio( h, mix, "out", ao0, "in"); // mix -> aout L
  1200. cmDspSysConnectAudio( h, mix, "out", ao1, "in"); // mix -> aout R
  1201. cmDspSysInstallCb1NN1( h, chCfg, "gain", ain, "gain", chCnt ); // chCfg -> ain gain
  1202. cmDspSysInstallCb1NN1( h, chCfg, "hz", cf, "hz", chCnt ); // chCfg -> CF Hz
  1203. cmDspSysInstallCbN1N1( h, ef, "rms", add, "in-0", chCnt ); // EF -> mul 0
  1204. cmDspSysInstallCbN1N1( h, mul, "out", add, "in-1", chCnt ); // mul -> add
  1205. cmDspSysInstallCbN1N1( h, add, "out", dly, "in", chCnt ); // add -> delay
  1206. cmDspSysInstallCbN11N( h, dly, "out", mix, "gain", chCnt ); // delay -> mix gain
  1207. cmDspSysInstallCbN1N1( h, add, "out", mul, "in-0", chCnt); // add -> mul (feedback)
  1208. cmDspSysInstallCb11N1( h, decay, "val", mul, "in-1", chCnt ); // decay ctl
  1209. cmDspSysInstallCbN1N1( h, ef, "gate", mtr, "in", chCnt ); // EF -> meter RMS
  1210. cmDspSysInstallCb11N1( h, alpha, "val", cf, "alpha",chCnt ); // CF alpha
  1211. cmDspSysInstallCb11N1( h, delay, "val", dly, "delay",chCnt ); // Delay ctl
  1212. cmDspSysInstallCb111N( h, zero, "val", mix, "in", chCnt ); //
  1213. }
  1214. errLabel:
  1215. cmFsFreeFn(chCfgPath);
  1216. return rc;
  1217. }
  1218. cmDspRC_t _cmDspSysPgm_NoiseTails2( cmDspSysH_t h, void** userPtrPtr )
  1219. {
  1220. cmDspRC_t rc = kOkDspRC;
  1221. cmErr_t err;
  1222. cmCtx_t* cmCtx = cmDspSysPgmCtx(h);
  1223. unsigned chCnt = 0;
  1224. unsigned nsChCnt = 0;
  1225. const cmChar_t* chCfgPath = NULL;
  1226. const cmChar_t* chCfgFn = "pick_chs8.js";
  1227. double cfMinHz = 20.0;
  1228. double cfHz = 500;
  1229. double cfAlpha = 0.9;
  1230. bool cfFbFl = true;
  1231. bool cfBypassFl = false;
  1232. unsigned sgShapeId = 3;
  1233. double adsrMaxMs = 10000;
  1234. double adsrMinMs = 0;
  1235. double adsrIncMs = 1;
  1236. double adsrMaxLevel = 100.0;
  1237. double adsrSusLevel = 100.0;
  1238. double adsrMinLevel = 0.0;
  1239. double adsrIncLevel = 0.001;
  1240. bool eqBypassFl = false;
  1241. unsigned eqModeSymId = cmSymTblRegisterStaticSymbol(cmDspSysSymbolTable(h),"LP");
  1242. double eqF0hz = 250;
  1243. double eqQ = 1.0;
  1244. double eqFgain = 1.0;
  1245. bool mtBypassFl = false;
  1246. double mtTimeScale= 1.0;
  1247. double mtFeedback = 0.0;
  1248. unsigned i;
  1249. cmErrSetup(&err,&cmCtx->rpt,"Noise Tails");
  1250. // prepend the prefs directory to the ch. cfg filename
  1251. chCfgPath = cmFsMakeFn(cmFsPrefsDir(),chCfgFn,NULL,NULL);
  1252. // get the count of channels from the ch. cfg. array
  1253. if(( chCnt = cmChCfgChannelCount(cmCtx,chCfgFn,&nsChCnt)) == 0 )
  1254. {
  1255. rc = cmErrMsg(&err,kPgmCfgFailDspRC,"Unable to obtain the channel count from '%s'.",cmStringNullGuard(chCfgFn));
  1256. goto errLabel;
  1257. }
  1258. if( rc == kOkDspRC )
  1259. {
  1260. cmDspInst_t* ain[chCnt];
  1261. cmDspInst_t* ef[chCnt];
  1262. cmDspInst_t* cf[chCnt];
  1263. cmDspInst_t* sg[chCnt];
  1264. cmDspInst_t* mtr[chCnt];
  1265. cmDspInst_t* add[chCnt];
  1266. cmDspInst_t* mul[chCnt];
  1267. cmDspInst_t* env[chCnt];
  1268. cmDspInst_t* d2l[chCnt];
  1269. cmDspInst_t* eq[chCnt];
  1270. cmDspInst_t* mt[chCnt];
  1271. // allocate the audio inputs
  1272. for(i=0; i<chCnt; ++i)
  1273. {
  1274. unsigned labelCharCnt = 31;
  1275. cmChar_t label[labelCharCnt+1];
  1276. snprintf(label,labelCharCnt,"%i",i);
  1277. ain[i] = cmDspSysAllocAudioIn( h, i, 1.0);
  1278. ef[i] = cmDspSysAllocInst( h, "EnvFollow", NULL, 0 );
  1279. sg[i] = cmDspSysAllocInst( h, "SigGen", NULL, 2, 1000.0, sgShapeId );
  1280. cf[i] = cmDspSysAllocInst( h, "CombFilt", NULL, 5, cfBypassFl, cfMinHz, cfFbFl, cfHz, cfAlpha );
  1281. mtr[i] = cmDspSysAllocInst( h, "Meter",label, 3, 0.0, 0.0, 1.0 );
  1282. env[i] = cmDspSysAllocInst( h, "Adsr", NULL, 2, true, adsrMinLevel );
  1283. d2l[i] = cmDspSysAllocInst( h, "DbToLin", NULL, 0 );
  1284. add[i] = cmDspSysAllocInst( h, "ScalarOp", NULL, 6, 2, "+", "in-0", 0.0, "in-1", 0.0);
  1285. mul[i] = cmDspSysAllocInst( h, "ScalarOp", NULL, 6, 2, "*", "in-0", 0.0, "in-1", 0.99);
  1286. eq[i] = cmDspSysAllocInst( h, "BiQuadEq", NULL, 5, eqBypassFl, eqModeSymId, eqF0hz, eqQ, eqFgain );
  1287. mt[i] = cmDspSysAllocInst( h, "MtDelay", NULL, 9, mtBypassFl, mtTimeScale, mtFeedback, 20.0, 0.8, 15.0, 0.9, 12.0, 0.9 );
  1288. }
  1289. // allocate the ch cfg last so that it's default outputs initialize connected objects
  1290. cmDspInst_t* chCfg = cmDspSysAllocInst( h, "ChCfg", NULL, 1, chCfgFn );
  1291. cmDspInst_t* mix = cmDspSysAllocInst( h, "AMix", NULL, 1, chCnt );
  1292. cmDspInst_t* ao0 = cmDspSysAllocAudioOut( h, 0, 1.0 );
  1293. cmDspInst_t* ao1 = cmDspSysAllocAudioOut( h, 1, 1.0 );
  1294. cmDspInst_t* alpha = cmDspSysAllocScalar( h, "alpha", -1.0, 1.0, 0.001, cfAlpha );
  1295. cmDspInst_t* decay = cmDspSysAllocScalar( h, "decay", -1.0, 1.0, 0.001, 0.5);
  1296. cmDspInst_t* zero = cmDspSysAllocScalar( h, "zero", 0.0, 0.0, 0.0, 0.0);
  1297. // cmDspInst_t* print = cmDspSysAllocButton( h, "print", 0 );
  1298. cmDspSysNewColumn(h,200);
  1299. cmDspInst_t* dly = cmDspSysAllocScalar( h, "Dly Ms", adsrMinMs, adsrMaxMs, adsrIncMs, 0.0);
  1300. cmDspInst_t* atk = cmDspSysAllocScalar( h, "Atk Ms", adsrMinMs, adsrMaxMs, adsrIncMs, 2000.0);
  1301. cmDspInst_t* dcy = cmDspSysAllocScalar( h, "Dcy Ms", adsrMinMs, adsrMaxMs, adsrIncMs, 100.0);
  1302. cmDspInst_t* hold = cmDspSysAllocScalar( h, "Hold Ms", adsrMinMs, adsrMaxMs, adsrIncMs, 100.0);
  1303. cmDspInst_t* rls = cmDspSysAllocScalar( h, "Rls Ms", adsrMinMs, adsrMaxMs, adsrIncMs, 4000.0);
  1304. cmDspInst_t* alvl = cmDspSysAllocScalar( h, "AdsrMax", adsrMinLevel,adsrMaxLevel,adsrIncLevel, adsrMaxLevel);
  1305. cmDspInst_t* sus = cmDspSysAllocScalar( h, "Sustain", adsrMinLevel,adsrMaxLevel,adsrIncLevel, adsrSusLevel );
  1306. cmDspSysNewColumn(h,200);
  1307. cmDspInst_t* onThr = cmDspSysAllocScalar(h,"On Thresh",-100.0,0.0,0.1,-55.0);
  1308. cmDspInst_t* offThr = cmDspSysAllocScalar(h,"Off Thresh",-100.0,0.0,0.1,-80.0);
  1309. cmDspInst_t* eqbyp = cmDspSysAllocCheck( h, "Eq Byp", 0 );
  1310. cmDspInst_t* eqmode = cmDspSysAllocInst( h, "MsgList","Mode", 1, "biQuadEqMode");
  1311. cmDspInst_t* eqq = cmDspSysAllocScalar( h, "Q", -100.0, 100.0, 0.1, eqQ);
  1312. cmDspInst_t* eqfgn = cmDspSysAllocScalar( h, "Filt Gain", 0.0, 1.0, 0.1, eqFgain);
  1313. cmDspInst_t* mtfb = cmDspSysAllocScalar( h, "Mt Feedback", 0.0, 1.0, 0.01, mtFeedback);
  1314. cmDspInst_t* mtscale= cmDspSysAllocScalar( h, "Mt Time Scale", 0.01, 10.0, 0.01, mtTimeScale);
  1315. // check for allocation errors
  1316. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1317. goto errLabel;
  1318. cmDspSysConnectAudioN1N1( h, ain, "out", ef, "in", chCnt ); // ain -> EF
  1319. cmDspSysConnectAudioN1N1( h, sg, "out", cf, "in", chCnt ); // sg -> CF
  1320. cmDspSysConnectAudioN1N1( h, cf, "out", eq, "in", chCnt );
  1321. cmDspSysConnectAudioN1N1( h, eq, "out", mt, "in", chCnt );
  1322. cmDspSysConnectAudioN11N( h, mt, "out", mix, "in", chCnt ); // cf -> mix
  1323. cmDspSysConnectAudio( h, mix, "out", ao0, "in"); // mix -> aout L
  1324. cmDspSysConnectAudio( h, mix, "out", ao1, "in"); // mix -> aout R
  1325. cmDspSysInstallCb1NN1( h, chCfg, "gain", ain, "gain", chCnt ); // chCfg -> ain gain
  1326. cmDspSysInstallCb1NN1( h, chCfg, "hz", cf, "hz", chCnt ); // chCfg -> CF Hz
  1327. cmDspSysInstallCb1NN1( h, chCfg, "hz", eq, "f0", chCnt ); // chCfg -> Eq Hz
  1328. cmDspSysInstallCbN1N1( h, mul, "out", add, "in-1", chCnt ); // mul -> add
  1329. cmDspSysInstallCbN1N1( h, ef, "gate", env, "gate", chCnt ); // EF -> adsr (gate)
  1330. cmDspSysInstallCbN1N1( h, ef, "rms", env, "rms", chCnt ); // EF ->adsr (rms)
  1331. //cmDspSysInstallCb11N1( h, print, "out", env, "cmd", chCnt );
  1332. cmDspSysInstallCbN1N1( h, env, "out", d2l, "in", chCnt );
  1333. cmDspSysInstallCbN11N( h, d2l, "out", mix, "gain", chCnt );
  1334. cmDspSysInstallCbN1N1( h, add, "out", mul, "in-0", chCnt ); // add -> mul (feedback)
  1335. cmDspSysInstallCb11N1( h, decay, "val", mul, "in-1", chCnt ); // decay ctl
  1336. cmDspSysInstallCbN1N1( h, ef, "gate", mtr, "in", chCnt ); // EF -> meter RMS
  1337. cmDspSysInstallCb11N1( h, alpha, "val", cf, "alpha",chCnt ); // CF alpha
  1338. cmDspSysInstallCb111N( h, zero, "val", mix, "in", chCnt ); //
  1339. cmDspSysInstallCb11N1( h, dly, "val", env, "dly", chCnt );
  1340. cmDspSysInstallCb11N1( h, atk, "val", env, "atk", chCnt );
  1341. cmDspSysInstallCb11N1( h, dcy, "val", env, "dcy", chCnt );
  1342. cmDspSysInstallCb11N1( h, hold, "val", env, "hold", chCnt );
  1343. cmDspSysInstallCb11N1( h, rls, "val", env, "rls", chCnt );
  1344. cmDspSysInstallCb11N1( h, alvl, "val", env, "alvl", chCnt );
  1345. cmDspSysInstallCb11N1( h, sus, "val", env, "sus", chCnt );
  1346. cmDspSysInstallCb11N1( h, onThr, "val", ef, "ondb", chCnt ); //
  1347. cmDspSysInstallCb11N1( h, offThr, "val", ef, "offdb", chCnt ); //
  1348. cmDspSysInstallCb11N1( h, eqbyp, "out", eq, "bypass", chCnt );
  1349. cmDspSysInstallCb11N1( h, eqmode, "mode", eq, "mode", chCnt );
  1350. cmDspSysInstallCb11N1( h, eqq, "val", eq, "Q", chCnt );
  1351. cmDspSysInstallCb11N1( h, eqfgn, "val", eq, "gain", chCnt );
  1352. cmDspSysInstallCb11N1( h, mtfb, "val", mt, "fb", chCnt );
  1353. cmDspSysInstallCb11N1( h, mtscale, "val", mt, "scale", chCnt );
  1354. }
  1355. errLabel:
  1356. cmFsFreeFn(chCfgPath);
  1357. return rc;
  1358. }
  1359. cmDspRC_t _cmDspSysPgm_CombFilt( cmDspSysH_t h, void** userPtrPtr )
  1360. {
  1361. cmDspRC_t rc = kOkDspRC;
  1362. double cfMinHz = 20.0;
  1363. double cfAlpha = 0.9;
  1364. bool cfFbFl = true;
  1365. bool cfBypassFl= false;
  1366. unsigned sgShapeId = 2;
  1367. cmDspInst_t* ao = cmDspSysAllocAudioOut( h, 0, 1.0 );
  1368. cmDspInst_t* sg = cmDspSysAllocInst( h, "SigGen", NULL, 2, 1000.0, sgShapeId );
  1369. cmDspInst_t* cf = cmDspSysAllocInst( h, "CombFilt", NULL, 5, cfBypassFl, cfMinHz, cfFbFl, cfMinHz, cfAlpha );
  1370. cmDspInst_t* hz = cmDspSysAllocScalar( h, "Hz", 25, 10000, 1, 1000 );
  1371. cmDspInst_t* a = cmDspSysAllocScalar( h, "Alpha", 0.0, 2.0, 0.001, cfAlpha);
  1372. // check for allocation errors
  1373. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1374. goto errLabel;
  1375. cmDspSysConnectAudio(h, sg, "out", cf, "in");
  1376. cmDspSysConnectAudio(h, cf, "out", ao, "in");
  1377. cmDspSysInstallCb( h, hz, "val", cf, "hz", NULL);
  1378. cmDspSysInstallCb( h, a, "val", cf, "alpha", NULL);
  1379. errLabel:
  1380. return rc;
  1381. }
  1382. cmDspRC_t _cmDspSysPgm_ScalarOp( cmDspSysH_t h, void** userPtrPtr )
  1383. {
  1384. cmDspRC_t rc;
  1385. cmDspInst_t* add = cmDspSysAllocInst( h, "ScalarOp", NULL, 6, 2, "+", "in-0", 0.0, "in-1", 0.0 );
  1386. cmDspInst_t* mul0 = cmDspSysAllocInst( h, "ScalarOp", NULL, 6, 2, "*", "in-0", 0.0, "in-1", 0.0 );
  1387. cmDspInst_t* mul1 = cmDspSysAllocInst( h, "ScalarOp", NULL, 6, 2, "*", "in-0", 0.0, "in-1", 0.0 );
  1388. cmDspInst_t* in = cmDspSysAllocScalar( h, "Input", 0.0, 10.0, 0.001, 0.0);
  1389. cmDspInst_t* in_m = cmDspSysAllocScalar( h, "Input_M", 0.0, 10.0, 0.001, 0.0);
  1390. cmDspInst_t* fb = cmDspSysAllocScalar( h, "Feedback", 0.0, 10.0, 0.001, 0.0);
  1391. cmDspInst_t* fb_m = cmDspSysAllocScalar( h, "Feedback_M", 0.0, 10.0, 0.001, 0.0);
  1392. cmDspInst_t* out = cmDspSysAllocScalar( h, "Out", 0.0, 10.0, 0.001, 0.0);
  1393. // check for allocation errors
  1394. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1395. goto errLabel;
  1396. cmDspSysInstallCb( h, in, "val", mul0, "in-0", NULL );
  1397. cmDspSysInstallCb( h, in_m, "val", mul0, "in-1", NULL );
  1398. cmDspSysInstallCb( h, fb, "val", mul1, "in-0", NULL );
  1399. cmDspSysInstallCb( h, fb_m, "val", mul1, "in-1", NULL );
  1400. cmDspSysInstallCb( h, mul0, "out", add, "in-0", NULL );
  1401. cmDspSysInstallCb( h, mul1, "out", add, "in-1", NULL );
  1402. cmDspSysInstallCb( h, add, "out", fb, "val", NULL );
  1403. cmDspSysInstallCb( h, add, "out", out, "val", NULL );
  1404. errLabel:
  1405. return rc;
  1406. }
  1407. cmDspRC_t _cmDspSysPgm_RingMod( cmDspSysH_t h, void** userPtrPtr )
  1408. {
  1409. cmDspRC_t rc = kOkDspRC;
  1410. cmErr_t err;
  1411. cmCtx_t* cmCtx = cmDspSysPgmCtx(h);
  1412. unsigned chCnt = 0;
  1413. unsigned nsChCnt = 0;
  1414. const cmChar_t* chCfgPath = NULL;
  1415. const cmChar_t* chCfgFn = "pick_chs8.js";
  1416. unsigned groupCnt = 3;
  1417. unsigned chsPerGroup = 2;
  1418. cmReal_t fadeTimeMs = 25;
  1419. unsigned i,j,k;
  1420. cmErrSetup(&err,&cmCtx->rpt,"Pickup Effects");
  1421. // prepend the prefs directory to the ch. cfg filename
  1422. chCfgPath = cmFsMakeFn(cmFsPrefsDir(),chCfgFn,NULL,NULL);
  1423. // get the count of channels from the ch. cfg. array
  1424. if(( chCnt = cmChCfgChannelCount(cmCtx,chCfgFn,&nsChCnt)) == 0 )
  1425. {
  1426. rc = cmErrMsg(&err,kPgmCfgFailDspRC,"Unable to obtain the channel count from '%s'.",cmStringNullGuard(chCfgFn));
  1427. goto errLabel;
  1428. }
  1429. if( rc == kOkDspRC )
  1430. {
  1431. cmDspInst_t* ain[chCnt];
  1432. cmDspInst_t* ef[chCnt];
  1433. cmDspInst_t* mtr[chCnt];
  1434. cmDspInst_t* nom[groupCnt];
  1435. cmDspInst_t* rm[groupCnt];
  1436. cmDspInst_t* nm_mtr[groupCnt*chsPerGroup];
  1437. unsigned labelCharCnt = 31;
  1438. cmChar_t label[labelCharCnt+1];
  1439. // allocate the audio inputs and envelope followers
  1440. for(i=0; i<chCnt; ++i)
  1441. {
  1442. snprintf(label,labelCharCnt,"%i",i);
  1443. ain[i] = cmDspSysAllocAudioIn( h, i, 1.0);
  1444. ef[i] = cmDspSysAllocInst( h, "EnvFollow", NULL, 0 );
  1445. mtr[i] = cmDspSysAllocInst( h, "Meter", label, 3, 0.0, 0.0, 1.0 );
  1446. }
  1447. cmDspInst_t* gs = cmDspSysAllocInst( h, "GroupSel", NULL, 3, chCnt, groupCnt, chsPerGroup );
  1448. for(i=0; i<groupCnt; ++i)
  1449. {
  1450. nom[i] = cmDspSysAllocInst(h, "AudioNofM", NULL, 3, chCnt, chsPerGroup, fadeTimeMs );
  1451. rm[i] = cmDspSysAllocInst(h, "RingMod", NULL, 1, chsPerGroup );
  1452. }
  1453. for(i=0,k=0; i<groupCnt; ++i)
  1454. {
  1455. cmDspSysNewColumn(h,50);
  1456. snprintf(label,labelCharCnt,"%i",i);
  1457. cmDspSysAllocLabel(h,label,kLeftAlignDuiId );
  1458. for(j=0; j<chsPerGroup; ++j,++k)
  1459. {
  1460. snprintf(label,labelCharCnt,"%i",j);
  1461. nm_mtr[k] = cmDspSysAllocInst(h, "Meter", label, 3, 0.0, 0.0, 1.0 );
  1462. }
  1463. }
  1464. assert(k==groupCnt*chsPerGroup);
  1465. // allocate the ch cfg last so that it's default outputs initialize connected objects
  1466. //cmDspInst_t* chCfg = cmDspSysAllocInst( h, "ChCfg", NULL, 1, chCfgFn );
  1467. cmDspInst_t* mix = cmDspSysAllocInst( h, "AMix", NULL, 1, groupCnt );
  1468. cmDspInst_t* ao0 = cmDspSysAllocAudioOut( h, 0, 1.0 );
  1469. cmDspInst_t* ao1 = cmDspSysAllocAudioOut( h, 1, 1.0 );
  1470. // check for allocation errors
  1471. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1472. goto errLabel;
  1473. cmDspSysConnectAudioN1N1( h, ain, "out", ef, "in", chCnt ); // ain -> EF
  1474. for(i=0; i<groupCnt; ++i)
  1475. {
  1476. cmDspSysConnectAudioN11N( h, ain, "out", nom[i], "in", chCnt );
  1477. cmDspSysConnectAudio1N1N( h, nom[i], "out", rm[i], "in", chsPerGroup);
  1478. snprintf(label,labelCharCnt,"gate-%i",i);
  1479. cmDspSysInstallCb1N1N( h, gs, label, nom[i], "gate", chCnt );
  1480. cmDspSysInstallCb1NN1( h, nom[i], "gain", nm_mtr + i * chsPerGroup, "in", chsPerGroup);
  1481. }
  1482. cmDspSysConnectAudioN11N( h, rm, "out", mix, "in", groupCnt );
  1483. cmDspSysConnectAudio( h, mix, "out", ao0, "in"); // mix -> aout L
  1484. cmDspSysConnectAudio( h, mix, "out", ao1, "in"); // mix -> aout R
  1485. cmDspSysInstallCbN11N( h, ef, "gate", gs, "gate", chCnt ); // EF -> grp_sel gate
  1486. cmDspSysInstallCbN11N( h, ef, "rms", gs, "rms", chCnt ); // EF -> grp_sel RMS
  1487. cmDspSysInstallCbN1N1( h, ef, "gate", mtr, "in", chCnt );
  1488. }
  1489. errLabel:
  1490. cmFsFreeFn(chCfgPath);
  1491. return rc;
  1492. }
  1493. cmDspRC_t _cmDspSysPgm_RingMod2( cmDspSysH_t h, void** userPtrPtr )
  1494. {
  1495. cmDspRC_t rc = kOkDspRC;
  1496. cmErr_t err;
  1497. cmCtx_t* cmCtx = cmDspSysPgmCtx(h);
  1498. unsigned iChCnt = 0;
  1499. unsigned oChCnt = 0;
  1500. unsigned nsChCnt = 0;
  1501. const cmChar_t* chCfgPath = NULL;
  1502. const cmChar_t* chCfgFn = "pick_chs8.js";
  1503. unsigned i;
  1504. cmErrSetup(&err,&cmCtx->rpt,"Pickup Effects");
  1505. // prepend the prefs directory to the ch. cfg filename
  1506. chCfgPath = cmFsMakeFn(cmFsPrefsDir(),chCfgFn,NULL,NULL);
  1507. // get the count of channels from the ch. cfg. array
  1508. if(( iChCnt = cmChCfgChannelCount(cmCtx,chCfgFn,&nsChCnt)) == 0 )
  1509. {
  1510. rc = cmErrMsg(&err,kPgmCfgFailDspRC,"Unable to obtain the channel count from '%s'.",cmStringNullGuard(chCfgFn));
  1511. goto errLabel;
  1512. }
  1513. if( rc == kOkDspRC && iChCnt > 0 )
  1514. {
  1515. if( iChCnt % 2 )
  1516. iChCnt -= 1;
  1517. oChCnt = iChCnt/2;
  1518. cmDspInst_t* ain[iChCnt];
  1519. cmDspInst_t* ef[iChCnt];
  1520. cmDspInst_t* mtr[iChCnt];
  1521. cmDspInst_t* rm[oChCnt];
  1522. unsigned labelCharCnt = 31;
  1523. cmChar_t label[labelCharCnt+1];
  1524. // allocate the audio inputs and envelope followers
  1525. for(i=0; i<iChCnt; ++i)
  1526. {
  1527. snprintf(label,labelCharCnt,"%i",i);
  1528. ain[i] = cmDspSysAllocAudioIn( h, i, 1.0);
  1529. ef[i] = cmDspSysAllocInst( h, "EnvFollow", NULL, 0 );
  1530. mtr[i] = cmDspSysAllocInst( h, "Meter", label, 3, 0.0, 0.0, 1.0 );
  1531. }
  1532. for(i=0; i<oChCnt; ++i)
  1533. {
  1534. rm[i] = cmDspSysAllocInst( h, "RingMod", NULL, 1, 2 );
  1535. }
  1536. cmDspInst_t* gain = cmDspSysAllocScalar( h, "RM Gain", 0.0, 10.0, 0.001, 1.0);
  1537. cmDspInst_t* mix = cmDspSysAllocInst( h, "AMix", NULL, 1, oChCnt );
  1538. cmDspInst_t* ao0 = cmDspSysAllocAudioOut( h, 0, 1.0 );
  1539. cmDspInst_t* ao1 = cmDspSysAllocAudioOut( h, 1, 1.0 );
  1540. // check for allocation errors
  1541. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1542. goto errLabel;
  1543. cmDspSysConnectAudioN1N1( h, ain, "out", ef, "in", iChCnt ); // ain -> EF
  1544. cmDspSysInstallCbN1N1( h, ef, "gate", mtr, "in", iChCnt ); // EF -> mtr (gate)
  1545. for(i=0; i<oChCnt; ++i)
  1546. {
  1547. cmDspSysConnectAudio( h, ain[i*2+0], "out", rm[i], "in-0"); // ain -> rm 0
  1548. cmDspSysConnectAudio( h, ain[i*2+1], "out", rm[i], "in-1"); // ain -> rm 1
  1549. snprintf(label,labelCharCnt,"in-%i",i);
  1550. cmDspSysConnectAudio( h, rm[i], "out", mix, label); // rm -> mix
  1551. cmDspSysInstallCb(h, gain, "val", rm[i], "gain", NULL ); // gain -> rm gain
  1552. }
  1553. cmDspSysConnectAudio( h, mix, "out", ao0, "in"); // mix -> aout L
  1554. cmDspSysConnectAudio( h, mix, "out", ao1, "in"); // mix -> aout R
  1555. }
  1556. errLabel:
  1557. cmFsFreeFn(chCfgPath);
  1558. return rc;
  1559. }
  1560. cmDspRC_t _cmDspSysPgm_MsgDelay( cmDspSysH_t h, void** userPtrPtr )
  1561. {
  1562. cmDspRC_t rc = kOkDspRC;
  1563. double dfltDelayTimeMs = 100.0;
  1564. double maxDelayTimeMs = 10000.0;
  1565. cmDspInst_t* ctl = cmDspSysAllocScalar( h, "Delay", 0.0, maxDelayTimeMs, 1.0, dfltDelayTimeMs );
  1566. cmDspInst_t* dly = cmDspSysAllocInst( h, "MsgDelay", NULL, 2, 1000, dfltDelayTimeMs );
  1567. cmDspInst_t* print = cmDspSysAllocInst( h, "Printer", NULL, 1, ">");
  1568. if( (rc = cmDspSysLastRC(h)) != kOkDspRC )
  1569. return rc;
  1570. cmDspSysInstallCb( h, ctl, "val", dly, "delay", NULL );
  1571. cmDspSysInstallCb( h, ctl, "val", dly, "in", NULL );
  1572. cmDspSysInstallCb( h, dly, "out", print, "in", NULL );
  1573. return rc;
  1574. }
  1575. cmDspRC_t _cmDspSysPgm_Adsr( cmDspSysH_t h, void** userPtrPtr )
  1576. {
  1577. cmDspRC_t rc;
  1578. bool trigModeFl = true;
  1579. double adsrMaxMs = 5000;
  1580. double adsrMinMs = 0;
  1581. double adsrIncMs = 1;
  1582. double adsrMaxLevel = 100.0; //1.0;
  1583. double adsrSusLevel = 80.0; //0.8;
  1584. double adsrMinLevel = 0.0; //0.0;
  1585. double adsrIncLevel = 0.001;
  1586. const cmChar_t* fn = "/home/kevin/temp/adsr1.bin";
  1587. cmDspInst_t* adsr = cmDspSysAllocInst(h, "Adsr", NULL, 2, trigModeFl, adsrMinLevel );
  1588. cmDspInst_t* chck = cmDspSysAllocCheck(h,"Gate",0);
  1589. cmDspInst_t* mtr = cmDspSysAllocInst(h,"Meter","Out", 3, adsrMinLevel, adsrMinLevel, adsrMaxLevel );
  1590. cmDspInst_t* bmf = cmDspSysAllocInst(h,"BinMtxFile", NULL, 2, 1, fn );
  1591. cmDspInst_t* dly = cmDspSysAllocScalar( h, "Dly Ms", adsrMinMs, adsrMaxMs, adsrIncMs, 0.0);
  1592. cmDspInst_t* atk = cmDspSysAllocScalar( h, "Atk Ms", adsrMinMs, adsrMaxMs, adsrIncMs, 1000.0);
  1593. cmDspInst_t* dcy = cmDspSysAllocScalar( h, "Dcy Ms", adsrMinMs, adsrMaxMs, adsrIncMs, 300.0);
  1594. cmDspInst_t* hold = cmDspSysAllocScalar( h, "Hold Ms", adsrMinMs, adsrMaxMs, adsrIncMs, 500.0);
  1595. cmDspInst_t* rls = cmDspSysAllocScalar( h, "Rls Ms", adsrMinMs, adsrMaxMs, adsrIncMs, 1000.0);
  1596. cmDspInst_t* alvl = cmDspSysAllocScalar( h, "AdsrMax", adsrMinLevel,adsrMaxLevel,adsrIncLevel, adsrMaxLevel);
  1597. cmDspInst_t* sus = cmDspSysAllocScalar( h, "Sustain", adsrMinLevel,adsrMaxLevel,adsrIncLevel, adsrSusLevel);
  1598. // check for allocation errors
  1599. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1600. goto errLabel;
  1601. cmDspSysInstallCb( h, dly, "val", adsr, "dly", NULL );
  1602. cmDspSysInstallCb( h, atk, "val", adsr, "atk", NULL );
  1603. cmDspSysInstallCb( h, dcy, "val", adsr, "dcy", NULL );
  1604. cmDspSysInstallCb( h, hold, "val", adsr, "hold", NULL );
  1605. cmDspSysInstallCb( h, rls, "val", adsr, "rls", NULL );
  1606. cmDspSysInstallCb( h, alvl, "val", adsr, "alvl", NULL );
  1607. cmDspSysInstallCb( h, sus, "val", adsr, "sus", NULL );
  1608. cmDspSysInstallCb( h, chck, "out", adsr, "gate", NULL );
  1609. cmDspSysInstallCb( h, adsr, "out", mtr, "in", NULL );
  1610. cmDspSysInstallCb( h, adsr, "out", bmf, "in", NULL );
  1611. errLabel:
  1612. return rc;
  1613. }
  1614. cmDspRC_t _cmDspSysPgm_Compressor( cmDspSysH_t h, void** userPtrPtr )
  1615. {
  1616. cmDspRC_t rc;
  1617. const cmChar_t* ofn = "/home/kevin/temp/adsr0.bin";
  1618. const char* afn0 = "media/audio/20110723-Kriesberg/Audio Files/Piano 3_01.wav";
  1619. int beg = 6900826;
  1620. int end = 13512262;
  1621. const cmChar_t* afn = cmFsMakeFn(cmFsUserDir(),afn0,NULL,NULL );
  1622. bool bypassFl = false;
  1623. double inGain = 1.0;
  1624. double threshDb = -40.0;
  1625. double ratio_num = 4.0;
  1626. double atkMs = 100.0;
  1627. double rlsMs = 100.0;
  1628. double makeup = 1.0;
  1629. double wndMaxMs = 1000.0;
  1630. double wndMs = 200.0;
  1631. cmDspInst_t* off = cmDspSysAllocInst(h,"Scalar", "Offset", 5, kNumberDuiId, 0.0, cmDspSysSampleRate(h)*600.0, 1.0, 0.0);
  1632. cmDspInst_t* phs = cmDspSysAllocInst(h,"Phasor", NULL, 0 );
  1633. cmDspInst_t* wt = cmDspSysAllocInst(h,"WaveTable",NULL, 6, ((int)cmDspSysSampleRate(h)), 1, afn, -1, beg, end );
  1634. cmDspInst_t* cmp = cmDspSysAllocInst(h,"Compressor",NULL, 8, bypassFl, threshDb, ratio_num, atkMs, rlsMs, makeup, wndMs, wndMaxMs );
  1635. cmDspInst_t* ao0 = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 0 );
  1636. cmDspInst_t* ao1 = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 1 );
  1637. cmDspInst_t* bmf = cmDspSysAllocInst(h,"BinMtxFile", NULL, 2, 1, ofn );
  1638. cmDspInst_t* mtr = cmDspSysAllocInst(h,"Meter","Env", 3, 0.0, 0.0, 1.0);
  1639. cmDspInst_t* igain = cmDspSysAllocScalar( h, "In Gain", 0.0, 10.0, 0.1, inGain);
  1640. cmDspInst_t* thr = cmDspSysAllocScalar( h, "ThreshDb", -100.0, 0.0, 0.1, threshDb);
  1641. cmDspInst_t* rat = cmDspSysAllocScalar( h, "Ratio", 0.1, 100, 0.1, ratio_num);
  1642. cmDspInst_t* atk = cmDspSysAllocScalar( h, "Atk Ms", 0.0, 1000.0, 0.1, atkMs);
  1643. cmDspInst_t* rls = cmDspSysAllocScalar( h, "Rls Ms", 0.0, 1000.0, 0.1, rlsMs);
  1644. cmDspInst_t* mkup = cmDspSysAllocScalar( h, "Makeup", 0.0, 10.0, 0.01, makeup);
  1645. cmDspInst_t* wnd = cmDspSysAllocScalar( h, "Wnd Ms", 1.0, wndMaxMs, 1.0, wndMs );
  1646. // check for allocation errors
  1647. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1648. goto errLabel;
  1649. cmDspSysConnectAudio(h, phs, "out", wt, "phs" ); // phasor -> wave table
  1650. cmDspSysConnectAudio(h, wt, "out", cmp, "in" ); // wave table -> cmp in
  1651. cmDspSysConnectAudio(h, cmp, "out", ao0, "in" ); // comp -> aout
  1652. cmDspSysConnectAudio(h, cmp, "out", ao1, "in" ); //
  1653. cmDspSysInstallCb(h, off, "val", wt, "beg", NULL );
  1654. cmDspSysInstallCb(h, igain,"val", cmp, "igain", NULL );
  1655. cmDspSysInstallCb(h, thr, "val", cmp, "thr", NULL );
  1656. cmDspSysInstallCb(h, rat, "val", cmp, "ratio", NULL );
  1657. cmDspSysInstallCb(h, atk, "val", cmp, "atk", NULL );
  1658. cmDspSysInstallCb(h, rls, "val", cmp, "rls", NULL );
  1659. cmDspSysInstallCb(h, mkup, "val", cmp, "ogain", NULL );
  1660. cmDspSysInstallCb(h, wnd, "val", cmp, "wnd", NULL );
  1661. cmDspSysInstallCb(h, cmp, "env", bmf, "in", NULL );
  1662. cmDspSysInstallCb(h, cmp, "env", mtr, "in", NULL );
  1663. errLabel:
  1664. return rc;
  1665. }
  1666. cmDspRC_t _cmDspSysPgm_BiQuadEq( cmDspSysH_t h, void** userPtrPtr )
  1667. {
  1668. cmDspRC_t rc = kOkDspRC;
  1669. const char* afn0 = "media/audio/20110723-Kriesberg/Audio Files/Piano 3_01.wav";
  1670. int beg = 6900826;
  1671. int end = 13512262;
  1672. const cmChar_t* afn = cmFsMakeFn(cmFsUserDir(),afn0,NULL,NULL );
  1673. bool bypassFl = false;
  1674. unsigned modeSymId = cmSymTblRegisterStaticSymbol(cmDspSysSymbolTable(h),"LP");
  1675. double f0hz = 264.0;
  1676. double Q = 1.0;
  1677. double fgain = 1.0;
  1678. cmDspInst_t* off = cmDspSysAllocInst(h,"Scalar", "Offset", 5, kNumberDuiId, 0.0, cmDspSysSampleRate(h)*600.0, 1.0, 0.0);
  1679. cmDspInst_t* phs = cmDspSysAllocInst(h,"Phasor", NULL, 0 );
  1680. cmDspInst_t* wt = cmDspSysAllocInst(h,"WaveTable",NULL, 6, ((int)cmDspSysSampleRate(h)), 1, afn, -1, beg, end );
  1681. cmDspInst_t* flt = cmDspSysAllocInst(h,"BiQuadEq",NULL, 5, bypassFl, modeSymId,f0hz, Q, fgain );
  1682. cmDspInst_t* ao0 = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 0 );
  1683. cmDspInst_t* ao1 = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 1 );
  1684. cmDspInst_t* mode = cmDspSysAllocInst( h, "MsgList","Mode", 1, "biQuadEqMode");
  1685. cmDspInst_t* fhz = cmDspSysAllocScalar( h, "Fc Hz", 0.0, 15000.0, 0.1, f0hz);
  1686. cmDspInst_t* q = cmDspSysAllocScalar( h, "Q", -100.0, 100, 0.1, Q);
  1687. cmDspInst_t* fgn = cmDspSysAllocScalar( h, "Filt Gain", 0.0, 1.0, 0.1, fgain);
  1688. // check for allocation errors
  1689. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1690. goto errLabel;
  1691. cmDspSysConnectAudio(h, phs, "out", wt, "phs" ); // phasor -> wave table
  1692. cmDspSysConnectAudio(h, wt, "out", flt, "in" ); // wave table -> cmp in
  1693. cmDspSysConnectAudio(h, flt, "out", ao0, "in" ); // filter -> aout
  1694. cmDspSysConnectAudio(h, flt, "out", ao1, "in" ); //
  1695. cmDspSysInstallCb(h, off, "val", wt, "beg", NULL );
  1696. cmDspSysInstallCb(h, mode,"mode",flt, "mode", NULL );
  1697. cmDspSysInstallCb(h, fhz, "val", flt, "f0", NULL );
  1698. cmDspSysInstallCb(h, q, "val", flt, "Q", NULL );
  1699. cmDspSysInstallCb(h, fgn, "val", flt, "gain", NULL );
  1700. errLabel:
  1701. return rc;
  1702. }
  1703. cmDspRC_t _cmDspSysPgm_DistDs( cmDspSysH_t h, void** userPtrPtr )
  1704. {
  1705. cmDspRC_t rc = kOkDspRC;
  1706. const char* afn0 = "media/audio/20110723-Kriesberg/Audio Files/Piano 3_01.wav";
  1707. int beg = 6900826;
  1708. int end = 13512262;
  1709. const cmChar_t* afn = cmFsMakeFn(cmFsUserDir(),afn0,NULL,NULL );
  1710. bool bypassFl = false;
  1711. double inGain = 1.0;
  1712. double dsrate = 44100.0;
  1713. double bits = 24.0;
  1714. bool rectifyFl = false;
  1715. bool fullRectFl = false;
  1716. double clipDb = -10.0;
  1717. cmDspInst_t* off = cmDspSysAllocInst(h,"Scalar", "Offset", 5, kNumberDuiId, 0.0, cmDspSysSampleRate(h)*600.0, 1.0, 0.0);
  1718. cmDspInst_t* phs = cmDspSysAllocInst(h,"Phasor", NULL, 0 );
  1719. cmDspInst_t* wt = cmDspSysAllocInst(h,"WaveTable",NULL, 6, ((int)cmDspSysSampleRate(h)), 1, afn, -1, beg, end );
  1720. cmDspInst_t* dst = cmDspSysAllocInst(h,"DistDs",NULL, 3, bypassFl, inGain, dsrate, bits );
  1721. cmDspInst_t* ao0 = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 0 );
  1722. cmDspInst_t* ao1 = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 1 );
  1723. cmDspInst_t* ign = cmDspSysAllocScalar( h, "In Gain", 0.0, 10.0, 0.01, 1.0);
  1724. cmDspInst_t* rct = cmDspSysAllocCheck( h, "Rectify", rectifyFl);
  1725. cmDspInst_t* ful = cmDspSysAllocCheck( h, "Full/Half", fullRectFl);
  1726. cmDspInst_t* dsr = cmDspSysAllocScalar( h, "Srate", 0.0, 96000, 1.0, dsrate);
  1727. cmDspInst_t* dbt = cmDspSysAllocScalar( h, "bits", 2.0, 32.0, 1.0, bits);
  1728. cmDspInst_t* clip = cmDspSysAllocScalar( h, "Clip dB", -100.0, 0.0, 0.1, clipDb);
  1729. cmDspInst_t* ogn = cmDspSysAllocScalar( h, "Out Gain", 0.0, 10.0, 0.01, 1.0);
  1730. // check for allocation errors
  1731. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1732. goto errLabel;
  1733. cmDspSysConnectAudio(h, phs, "out", wt, "phs" ); // phasor -> wave table
  1734. cmDspSysConnectAudio(h, wt, "out", dst, "in" ); // wave table -> cmp in
  1735. cmDspSysConnectAudio(h, dst, "out", ao0, "in" ); // filter -> aout
  1736. cmDspSysConnectAudio(h, dst, "out", ao1, "in" ); //
  1737. cmDspSysInstallCb(h, off, "val", wt, "beg", NULL );
  1738. cmDspSysInstallCb(h, ign, "val", dst, "igain", NULL );
  1739. cmDspSysInstallCb(h, dsr, "val", dst, "srate", NULL );
  1740. cmDspSysInstallCb(h, dbt, "val", dst, "bits", NULL );
  1741. cmDspSysInstallCb(h, rct, "out", dst, "rect", NULL );
  1742. cmDspSysInstallCb(h, ful, "out", dst, "full", NULL );
  1743. cmDspSysInstallCb(h, clip, "val", dst, "clip", NULL );
  1744. cmDspSysInstallCb(h, ogn, "val", dst, "ogain", NULL );
  1745. errLabel:
  1746. return rc;
  1747. }
  1748. cmDspRC_t _cmDspSysPgm_Seq( cmDspSysH_t h, void** userPtrPtr )
  1749. {
  1750. cmDspRC_t rc;
  1751. double min = 1.0;
  1752. double max = 10.0;
  1753. double incr = 1.0;
  1754. cmDspInst_t* btn = cmDspSysAllocButton( h, "smack", 0);
  1755. cmDspInst_t* cnt = cmDspSysAllocInst( h, "Counter", NULL, 3, min, max, incr );
  1756. cmDspInst_t* lst = cmDspSysAllocInst( h, "MsgList","Seq", 1, "seqTest");
  1757. cmDspInst_t* prt = cmDspSysAllocInst( h, "Printer", NULL, 1, ">");
  1758. cmDspSysInstallCb(h, lst, "cnt", cnt, "max", NULL );
  1759. cmDspSysInstallCb(h, btn, "out", cnt, "next", NULL );
  1760. cmDspSysInstallCb(h, cnt, "out", lst, "sel", NULL );
  1761. cmDspSysInstallCb(h, lst, "midi", prt, "in", NULL );
  1762. // check for allocation errors
  1763. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1764. goto errLabel;
  1765. errLabel:
  1766. return rc;
  1767. }
  1768. cmDspRC_t _cmDspSysPgm_ThunkNet( cmDspSysH_t h, void** userPtrPtr )
  1769. {
  1770. cmDspRC_t rc;
  1771. cmDspInst_t* add = cmDspSysAllocInst( h, "ScalarOp", "adder-0", 6, 2, "+", "in-0", 0.0, "in-1", 0.0 );
  1772. cmDspInst_t* in = cmDspSysAllocScalar( h, "Input", 0.0, 10.0, 0.001, 0.0);
  1773. cmDspInst_t* out = cmDspSysAllocScalar( h, "Out", 0.0, 10.0, 0.001, 0.0);
  1774. // check for allocation errors
  1775. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1776. goto errLabel;
  1777. cmDspSysInstallCb( h, in, "val", add, "in-1", NULL );
  1778. cmDspSysInstallCb( h, add, "out", out, "val", NULL );
  1779. errLabel:
  1780. return rc;
  1781. }
  1782. cmDspRC_t _cmDspSysPgm_WhirlNet( cmDspSysH_t h, void** userPtrPtr )
  1783. {
  1784. cmDspRC_t rc;
  1785. cmDspInst_t* in = cmDspSysAllocScalar( h, "Input", 0.0, 10.0, 0.001, 0.0);
  1786. // check for allocation errors
  1787. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1788. goto errLabel;
  1789. cmDspSysInstallNetCb( h, in, "val", "thunk", "adder-0", "in-0" );
  1790. errLabel:
  1791. return rc;
  1792. }
  1793. cmDspRC_t _cmDspSysPgm_NofM( cmDspSysH_t h, void** userPtrPtr )
  1794. {
  1795. cmDspRC_t rc;
  1796. unsigned iChCnt = 3;
  1797. unsigned oChCnt = 2;
  1798. unsigned sgShapeId = 0;
  1799. double sgGain = 0.4;
  1800. double xfadeMs = 1000;
  1801. cmDspInst_t* onBtn = cmDspSysAllocButton( h, "on", 0 );
  1802. cmDspInst_t* offBtn = cmDspSysAllocButton(h, "off", 0 );
  1803. cmDspInst_t* sg0 = cmDspSysAllocInst( h, "SigGen", NULL, 3, 500.0, sgShapeId, sgGain );
  1804. cmDspInst_t* sg1 = cmDspSysAllocInst( h, "SigGen", NULL, 3, 1000.0, sgShapeId, sgGain );
  1805. cmDspInst_t* sg2 = cmDspSysAllocInst( h, "SigGen", NULL, 3, 2000.0, sgShapeId, sgGain );
  1806. cmDspInst_t* nom = cmDspSysAllocInst( h,"NofM", NULL, 3, iChCnt, oChCnt, xfadeMs );
  1807. cmDspInst_t* mix = cmDspSysAllocInst( h, "AMix", NULL, 1, oChCnt );
  1808. cmDspInst_t* ao = cmDspSysAllocAudioOut(h, 0, 1.0 );
  1809. cmDspInst_t* btn = cmDspSysAllocButton( h, "cfg", 0);
  1810. cmDspInst_t* sel0 = cmDspSysAllocCheck(h,"Sel-0",0);
  1811. cmDspInst_t* sel1 = cmDspSysAllocCheck(h,"Sel-1",0);
  1812. cmDspInst_t* sel2 = cmDspSysAllocCheck(h,"Sel-2",0);
  1813. cmDspInst_t* in0 = cmDspSysAllocScalar( h, "In-0", 0.0, 10.0, 0.001, 0.0);
  1814. cmDspInst_t* in1 = cmDspSysAllocScalar( h, "In-1", 0.0, 10.0, 0.001, 0.0);
  1815. cmDspInst_t* in2 = cmDspSysAllocScalar( h, "In-2", 0.0, 10.0, 0.001, 0.0);
  1816. cmDspInst_t* out0 = cmDspSysAllocScalar( h, "Out-0", 0.0, 10.0, 0.001, 0.0);
  1817. cmDspInst_t* out1 = cmDspSysAllocScalar( h, "Out-1", 0.0, 10.0, 0.001, 0.0);
  1818. // check for allocation errors
  1819. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1820. goto errLabel;
  1821. cmDspSysConnectAudio( h, sg0, "out", nom, "a-in-0" );
  1822. cmDspSysConnectAudio( h, sg1, "out", nom, "a-in-1" );
  1823. cmDspSysConnectAudio( h, sg2, "out", nom, "a-in-2" );
  1824. cmDspSysConnectAudio( h, nom, "a-out-0", mix, "in-0" );
  1825. cmDspSysConnectAudio( h, nom, "a-out-1", mix, "in-1" );
  1826. cmDspSysConnectAudio( h, mix, "out", ao, "in" );
  1827. cmDspSysInstallCb( h, btn, "sym", nom, "cmd", NULL );
  1828. cmDspSysInstallCb( h, sel0, "out", nom, "sel-0", NULL );
  1829. cmDspSysInstallCb( h, sel1, "out", nom, "sel-1", NULL );
  1830. cmDspSysInstallCb( h, sel2, "out", nom, "sel-2", NULL );
  1831. cmDspSysInstallCb( h, in0, "val", nom, "f-in-0", NULL );
  1832. cmDspSysInstallCb( h, in1, "val", nom, "f-in-1", NULL );
  1833. cmDspSysInstallCb( h, in2, "val", nom, "f-in-2", NULL );
  1834. cmDspSysInstallCb( h, nom, "f-out-0", out0, "val", NULL );
  1835. cmDspSysInstallCb( h, nom, "f-out-1", out1, "val", NULL );
  1836. cmDspSysInstallCb( h, onBtn, "sym", nom, "cmd", NULL );
  1837. cmDspSysInstallCb( h, offBtn, "sym", nom, "cmd", NULL );
  1838. errLabel:
  1839. return rc;
  1840. }
  1841. cmDspRC_t _cmDspSysPgm_1ofN( cmDspSysH_t h, void** userPtrPtr )
  1842. {
  1843. cmDspRC_t rc;
  1844. unsigned inCnt = 3;
  1845. unsigned initSel = 0;
  1846. cmDspInst_t* oom = cmDspSysAllocInst(h,"1ofN", NULL, 2, inCnt, initSel );
  1847. cmDspInst_t* sel = cmDspSysAllocScalar( h, "Sel", 0, inCnt-1, 0.001, 0.0);
  1848. cmDspInst_t* in0 = cmDspSysAllocScalar( h, "In-0", 0.0, 10.0, 0.001, 0.0);
  1849. cmDspInst_t* in1 = cmDspSysAllocScalar( h, "In-1", 0.0, 10.0, 0.001, 0.0);
  1850. cmDspInst_t* in2 = cmDspSysAllocScalar( h, "In-2", 0.0, 10.0, 0.001, 0.0);
  1851. cmDspInst_t* out = cmDspSysAllocScalar( h, "Out", 0.0, 10.0, 0.001, 0.0);
  1852. // check for allocation errors
  1853. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1854. goto errLabel;
  1855. cmDspSysInstallCb( h, sel, "val", oom, "chidx", NULL );
  1856. cmDspSysInstallCb( h, in0, "val", oom, "f-in-0", NULL );
  1857. cmDspSysInstallCb( h, in1, "val", oom, "f-in-1", NULL );
  1858. cmDspSysInstallCb( h, in2, "val", oom, "f-in-2", NULL );
  1859. cmDspSysInstallCb( h, oom, "f-out", out, "val", NULL );
  1860. errLabel:
  1861. return rc;
  1862. }
  1863. cmDspRC_t _cmDspSysPgm_Router( cmDspSysH_t h, void** userPtrPtr )
  1864. {
  1865. cmDspRC_t rc;
  1866. unsigned inCnt = 3;
  1867. unsigned initSel = 0;
  1868. cmDspInst_t* rtr = cmDspSysAllocInst(h,"Router", NULL, 2, inCnt, initSel );
  1869. cmDspInst_t* sel = cmDspSysAllocScalar( h, "Sel", 0, inCnt-1, 1.0, 0.0);
  1870. cmDspInst_t* in = cmDspSysAllocScalar( h, "In", 0.0, 10.0, 0.001, 0.0);
  1871. cmDspInst_t* out0 = cmDspSysAllocScalar( h, "Out-0", 0.0, 10.0, 0.001, 0.0);
  1872. cmDspInst_t* out1 = cmDspSysAllocScalar( h, "Out-1", 0.0, 10.0, 0.001, 0.0);
  1873. cmDspInst_t* out2 = cmDspSysAllocScalar( h, "Out-2", 0.0, 10.0, 0.001, 0.0);
  1874. // check for allocation errors
  1875. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1876. goto errLabel;
  1877. cmDspSysInstallCb( h, sel, "val", rtr, "sel", NULL );
  1878. cmDspSysInstallCb( h, in, "val", rtr, "f-in", NULL );
  1879. cmDspSysInstallCb( h, rtr, "f-out-0", out0, "val", NULL );
  1880. cmDspSysInstallCb( h, rtr, "f-out-1", out1, "val", NULL );
  1881. cmDspSysInstallCb( h, rtr, "f-out-2", out2, "val", NULL );
  1882. errLabel:
  1883. return rc;
  1884. }
  1885. cmDspRC_t _cmDspSysPgm_Preset( cmDspSysH_t h, void** userPtrPtr )
  1886. {
  1887. cmDspRC_t rc;
  1888. unsigned sgShapeId = 0;
  1889. double sgHz = 500;
  1890. double sgGain = 0.02;
  1891. unsigned grpSymId = cmDspSysPresetRegisterGroup(h,"test");
  1892. const cmChar_t* prefixLabel = NULL;
  1893. cmDspInst_t* sg = cmDspSysAllocInst( h, "SigGen", NULL, 3, sgHz, sgShapeId, sgGain );
  1894. cmDspInst_t* ao = cmDspSysAllocAudioOut( h, 0, 1.0 );
  1895. cmDspInst_t* shapes = cmDspSysAllocMsgListP(h, grpSymId, prefixLabel, "Shape", NULL, "shapeList", 0 );
  1896. cmDspInst_t* gains = cmDspSysAllocMsgListP(h, grpSymId, prefixLabel, "Gains", NULL, "gainMenu", 0 );
  1897. cmDspInst_t* hz = cmDspSysAllocScalarP( h, grpSymId, prefixLabel, "Hz", 0.0, 10000.0, 0.01, sgHz);
  1898. cmDspInst_t* gain = cmDspSysAllocScalarP( h, grpSymId, prefixLabel, "Gain", 0.0, 1.0, 0.01, sgGain);
  1899. cmDspInst_t* preset = cmDspSysAllocInst( h, "Preset", NULL, 1, grpSymId );
  1900. cmDspInst_t* presetLbl = cmDspSysAllocInst( h, "Text", "Preset", 1, "" );
  1901. cmDspInst_t* storeBtn = cmDspSysAllocButton( h, "store", 0);
  1902. cmDspInst_t* recallBtn = cmDspSysAllocButton( h, "recall", 0);
  1903. // check for allocation errors
  1904. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1905. goto errLabel;
  1906. cmDspSysConnectAudio(h, sg, "out", ao, "in" );
  1907. cmDspSysInstallCb( h, shapes,"out", sg, "shape", NULL );
  1908. cmDspSysInstallCb( h, hz, "val", sg, "hz", NULL );
  1909. cmDspSysInstallCb( h, gain, "val", sg, "gain", NULL );
  1910. cmDspSysInstallCb( h, gains, "out", gain, "val", NULL );
  1911. cmDspSysInstallCb( h, presetLbl, "val", preset, "label",NULL);
  1912. cmDspSysInstallCb( h, storeBtn, "sym", preset, "cmd", NULL );
  1913. cmDspSysInstallCb( h, recallBtn, "sym", preset, "cmd", NULL );
  1914. errLabel:
  1915. return rc;
  1916. }
  1917. cmDspRC_t _cmDspSysPgm_RsrcWr( cmDspSysH_t h, void** userPtrPtr )
  1918. {
  1919. cmDspRC_t rc = kOkDspRC;
  1920. const cmChar_t* lbl1 = "rsrc1";
  1921. const cmChar_t* lbl2 = "rsrc2";
  1922. const cmChar_t* str1 = NULL;
  1923. const cmChar_t* str2 = NULL;
  1924. if( cmDspRsrcString(h,&str1, lbl1, NULL ) != kOkDspRC )
  1925. str1 = "1";
  1926. if( cmDspRsrcString(h,&str2, lbl2, NULL ) != kOkDspRC )
  1927. str2 = "2";
  1928. cmDspInst_t* rsrcWr = cmDspSysAllocInst( h, "RsrcWr", NULL, 2, lbl1, lbl2 );
  1929. cmDspInst_t* textUi0 = cmDspSysAllocInst( h, "Text", "Value1", 1, str1 );
  1930. cmDspInst_t* textUi1 = cmDspSysAllocInst( h, "Text", "Value2", 1, str2 );
  1931. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1932. goto errLabel;
  1933. cmDspSysInstallCb( h, textUi0, "val", rsrcWr, "rsrc1", NULL );
  1934. cmDspSysInstallCb( h, textUi1, "val", rsrcWr, "rsrc2", NULL );
  1935. errLabel:
  1936. return rc;
  1937. }
  1938. cmDspRC_t _cmDspSysPgm_1Up( cmDspSysH_t h, void** userPtrPtr )
  1939. {
  1940. cmDspRC_t rc;
  1941. unsigned chCnt = 3;
  1942. double maxIdx = chCnt - 1;
  1943. unsigned initIdx = 2;
  1944. cmDspInst_t* sel = cmDspSysAllocScalar( h, "Chan", 0.0, maxIdx, 1.0, 0.0 );
  1945. cmDspInst_t* up = cmDspSysAllocInst( h, "1Up", NULL, 2, chCnt, initIdx );
  1946. cmDspInst_t* pr0 = cmDspSysAllocInst( h, "Printer", NULL, 1, "0:" );
  1947. cmDspInst_t* pr1 = cmDspSysAllocInst( h, "Printer", NULL, 1, "1:" );
  1948. cmDspInst_t* pr2 = cmDspSysAllocInst( h, "Printer", NULL, 1, "2:" );
  1949. // check for allocation errors
  1950. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1951. goto errLabel;
  1952. cmDspSysInstallCb( h, sel, "val", up, "sel",NULL);
  1953. cmDspSysInstallCb( h, up, "out-0", pr0, "in", NULL );
  1954. cmDspSysInstallCb( h, up, "out-1", pr1, "in", NULL );
  1955. cmDspSysInstallCb( h, up, "out-2", pr2, "in", NULL );
  1956. errLabel:
  1957. return rc;
  1958. }
  1959. cmDspRC_t _cmDspSysPgm_PortToSym( cmDspSysH_t h, void** userPtrPtr )
  1960. {
  1961. cmDspRC_t rc = kOkDspRC;
  1962. cmDspInst_t* btn0 = cmDspSysAllocButton( h, "Btn0", 0.0 );
  1963. cmDspInst_t* btn1 = cmDspSysAllocButton( h, "Btn1", 0.0 );
  1964. cmDspInst_t* btn2 = cmDspSysAllocButton( h, "Btn2", 0.0 );
  1965. cmDspInst_t* pts = cmDspSysAllocInst( h, "PortToSym", NULL, 3, "one", "two", "three");
  1966. cmDspInst_t* pr0 = cmDspSysAllocInst( h, "Printer", NULL, 1, "0:" );
  1967. cmDspInst_t* pr1 = cmDspSysAllocInst( h, "Printer", NULL, 1, "1:" );
  1968. // check for allocation errors
  1969. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1970. goto errLabel;
  1971. cmDspSysInstallCb( h, btn0, "out", pts, "one",NULL);
  1972. cmDspSysInstallCb( h, btn1, "out", pts, "two",NULL);
  1973. cmDspSysInstallCb( h, btn2, "out", pts, "three",NULL);
  1974. cmDspSysInstallCb( h, btn0, "out", pr1, "in",NULL);
  1975. cmDspSysInstallCb( h, btn1, "out", pr1, "in",NULL);
  1976. cmDspSysInstallCb( h, btn2, "out", pr1, "in",NULL);
  1977. cmDspSysInstallCb( h, pts, "one", pr0, "in", NULL );
  1978. cmDspSysInstallCb( h, pts, "two", pr0, "in", NULL );
  1979. cmDspSysInstallCb( h, pts, "three", pr0, "in", NULL );
  1980. errLabel:
  1981. return rc;
  1982. }
  1983. cmDspRC_t _cmDspSysPgm_Line( cmDspSysH_t h, void** userPtrPtr )
  1984. {
  1985. cmDspRC_t rc = kOkDspRC;
  1986. cmDspInst_t* beg = cmDspSysAllocScalar( h, "beg", -10.0, 10.0, 1.0, 0.0 );
  1987. cmDspInst_t* end = cmDspSysAllocScalar( h, "end", -10.0, 10.0, 1.0, 1.0 );
  1988. cmDspInst_t* dur = cmDspSysAllocScalar( h, "dur", 0.0, 10000.0, 1.0, 0.0 );
  1989. cmDspInst_t* reset = cmDspSysAllocButton(h, "reset", 0.0 );
  1990. cmDspInst_t* line = cmDspSysAllocInst( h, "Line", NULL, 3, 0.0, 10.0, 1000.0 );
  1991. cmDspInst_t* mtr = cmDspSysAllocInst( h, "Meter", NULL, 3, -10.0, 10.0, 0.0 );
  1992. cmDspInst_t* pr1 = cmDspSysAllocInst( h, "Printer", NULL, 1, ">" );
  1993. // check for allocation errors
  1994. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  1995. goto errLabel;
  1996. cmDspSysInstallCb( h, beg, "val", line, "beg",NULL);
  1997. cmDspSysInstallCb( h, end, "val", line, "end",NULL);
  1998. cmDspSysInstallCb( h, dur, "val", line, "dur",NULL);
  1999. cmDspSysInstallCb( h, line, "out", mtr, "in", NULL );
  2000. cmDspSysInstallCb( h, reset, "sym", line, "cmd", NULL );
  2001. cmDspSysInstallCb( h, line, "out", pr1, "in", NULL );
  2002. errLabel:
  2003. return rc;
  2004. }
  2005. cmDspRC_t _cmDspSysPgm_Array( cmDspSysH_t h, void** userPtrPtr )
  2006. {
  2007. cmDspRC_t rc = kOkDspRC;
  2008. unsigned cnt = 0;
  2009. const cmChar_t* rsrcLabelStr = "test";
  2010. if( cmDspRsrcArrayCount( h, &cnt, rsrcLabelStr, NULL ) != kOkDspRC )
  2011. return cmErrMsg(&cmDspSysPgmCtx(h)->err,kPgmCfgFailDspRC,"The resource '%s' could not be read.",rsrcLabelStr);
  2012. cmDspInst_t* printBtn = cmDspSysAllocButton( h, "print", 0.0 );
  2013. cmDspInst_t* sendBtn = cmDspSysAllocButton( h, "send", 0.0 );
  2014. cmDspInst_t* cntBtn = cmDspSysAllocButton( h, "count", 0.0 );
  2015. cmDspInst_t* offsCtl = cmDspSysAllocScalar( h, "offset",0.0, 128.0, 1.0, 60.0 );
  2016. cmDspInst_t* array = cmDspSysAllocInst( h, "Array", NULL, 1, rsrcLabelStr );
  2017. cmDspInst_t** pcvt = cmDspSysAllocInstArray( h, cnt, "PitchCvt", NULL, NULL, 0 );
  2018. cmDspInst_t* printer = cmDspSysAllocInst( h, "Printer", NULL, 1, ">" );
  2019. cmDspSysInstallCb( h, printBtn, "sym", array, "cmd", NULL );
  2020. cmDspSysInstallCb( h, sendBtn, "sym", array, "cmd", NULL );
  2021. cmDspSysInstallCb( h, cntBtn, "sym", array, "cmd", NULL );
  2022. cmDspSysInstallCb11N1( h, offsCtl, "val", pcvt, "offs", cnt );
  2023. cmDspSysInstallCb1NN1( h, array, "out", pcvt, "midi", cnt );
  2024. cmDspSysInstallCbN111( h, pcvt, "midi", printer, "in", cnt );
  2025. cmDspSysInstallCb( h, array, "cnt", printer, "in", NULL );
  2026. return rc;
  2027. }
  2028. cmDspRC_t _cmDspSysPgm_SegLine( cmDspSysH_t h, void** userPtrPtr )
  2029. {
  2030. cmDspRC_t rc = kOkDspRC;
  2031. cmDspInst_t* btn = cmDspSysAllocButton( h, "Trig", 0.0 );
  2032. cmDspInst_t* sline = cmDspSysAllocInst( h, "SegLine", NULL, 1, "array" );
  2033. cmDspInst_t* printer = cmDspSysAllocInst( h, "Printer", NULL, 1, ">" );
  2034. // check for allocation errors
  2035. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  2036. goto errLabel;
  2037. cmDspSysInstallCb( h, btn, "sym", sline, "trig", NULL );
  2038. cmDspSysInstallCb( h, sline, "out", printer, "in", NULL );
  2039. errLabel:
  2040. return rc;
  2041. }
  2042. cmDspRC_t _cmDspSysPgm_AvailCh( cmDspSysH_t h, void** userPtrPtr )
  2043. {
  2044. double frqHz = 440.0;
  2045. unsigned xfadeChCnt = 2;
  2046. double xfadeMs = 250.0;
  2047. bool xfadeInitFl = false;
  2048. const char* fn = "/home/kevin/media/audio/20110723-Kriesberg/Audio Files/Piano 3_01.wav";
  2049. cmDspInst_t* chk0 = cmDspSysAllocInst(h,"Button", "0", 2, kButtonDuiId, 0.0 );
  2050. //cmDspInst_t* chk1 = cmDspSysAllocInst(h,"Button", "1", 2, kCheckDuiId, 0.0 );
  2051. cmDspInst_t* achp = cmDspSysAllocInst( h, "AvailCh", NULL, 1, xfadeChCnt );
  2052. cmDspInst_t* sphp = cmDspSysAllocInst( h, "Phasor", NULL, 2, cmDspSysSampleRate(h), frqHz );
  2053. cmDspInst_t* swtp = cmDspSysAllocInst( h, "WaveTable", NULL, 2, ((int)cmDspSysSampleRate(h)), 4);
  2054. cmDspInst_t* fphp = cmDspSysAllocInst( h, "Phasor", NULL, 1, cmDspSysSampleRate(h) );
  2055. cmDspInst_t* fwtp = cmDspSysAllocInst( h, "WaveTable", NULL, 5, ((int)cmDspSysSampleRate(h)), 1, fn, -1, 7000000 );
  2056. cmDspInst_t* fad0 = cmDspSysAllocInst( h, "Xfader", NULL, 3, xfadeChCnt, xfadeMs, xfadeInitFl );
  2057. //cmDspInst_t* prp = cmDspSysAllocInst( h, "Printer", NULL, 1, ">" );
  2058. cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut", NULL, 1, 0 );
  2059. cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut", NULL, 1, 1 );
  2060. // phasor->sine->fad-0->aout
  2061. cmDspSysConnectAudio(h, sphp, "out", swtp, "phs" );
  2062. cmDspSysConnectAudio(h, swtp, "out", fad0, "in-0" );
  2063. cmDspSysConnectAudio(h, fad0, "out-0", ao0p, "in" );
  2064. // phasor->file->fad-1->aout
  2065. cmDspSysConnectAudio(h, fphp, "out", fwtp, "phs" );
  2066. cmDspSysConnectAudio(h, fwtp, "out", fad0, "in-1" );
  2067. cmDspSysConnectAudio(h, fad0, "out-1", ao1p, "in" );
  2068. //cmDspSysInstallCb(h, chk0, "out", fad0, "gate-0", NULL);
  2069. //cmDspSysInstallCb(h, chk1, "out", fad0, "gate-1", NULL);
  2070. cmDspSysInstallCb(h, chk0, "sym", achp, "trig", NULL);
  2071. cmDspSysInstallCb(h, achp, "gate-0", fad0, "gate-0", NULL );
  2072. cmDspSysInstallCb(h, fad0, "state-0", achp, "dis-0", NULL );
  2073. cmDspSysInstallCb(h, achp, "gate-1", fad0, "gate-1", NULL );
  2074. cmDspSysInstallCb(h, fad0, "state-1", achp, "dis-1", NULL );
  2075. return kOkDspRC;
  2076. }
  2077. cmDspRC_t _cmDspSysPgm_Goertzel( cmDspSysH_t h, void** userPtrPtr )
  2078. {
  2079. cmDspRC_t rc;
  2080. const unsigned chCnt = 8;
  2081. unsigned hopFact = 2;
  2082. double dfltHz = 18000.0;
  2083. unsigned sigGenMode = 2; // sine
  2084. double sigGenGain = 0.9;
  2085. double dfltMixGain = 1.0/chCnt;
  2086. double fcHzV[chCnt];
  2087. unsigned i;
  2088. for(i=0; i<chCnt; ++i)
  2089. fcHzV[i] = 18000.0 + (20000.0-18000.0) * i /chCnt;
  2090. cmDspInst_t* ain = cmDspSysAllocAudioIn( h, 0, 1.0);
  2091. cmDspInst_t* amtr = cmDspSysAllocInst( h, "AMeter", "In", 0 );
  2092. cmDspInst_t* goer = cmDspSysAllocInst( h, "Goertzel", NULL, 3, hopFact, chCnt, fcHzV );
  2093. cmDspSysNewColumn(h,0);
  2094. cmDspInst_t** mtrV = cmDspSysAllocInstArray(h, chCnt, "Meter", "Mtr", NULL, 3, 0.0, 0.0, 1.0 );
  2095. cmDspInst_t** sgV = cmDspSysAllocInstArray(h, chCnt, "SigGen", "SG", NULL, 2, dfltHz, sigGenMode, sigGenGain, 0 );
  2096. cmDspInst_t* mix = cmDspSysAllocInst( h, "AMix", NULL,1, chCnt );
  2097. cmDspInst_t* ao0 = cmDspSysAllocAudioOut( h, 0, 1.0);
  2098. cmDspInst_t* ao1 = cmDspSysAllocAudioOut( h, 0, 1.0);
  2099. cmDspSysNewColumn(h,0);
  2100. cmDspInst_t** hzV = cmDspSysAllocInstArray( h, chCnt, "Scalar", "Hz", NULL, 5, kNumberDuiId, 0.0, 22000.0, 100.0, dfltHz );
  2101. cmDspSysNewColumn(h,0);
  2102. cmDspInst_t** gnV = cmDspSysAllocInstArray( h, chCnt, "Scalar", "Gain", NULL, 5, kNumberDuiId, 0.0, 1.0, 0.01, dfltMixGain );
  2103. cmDspInst_t* igain = cmDspSysAllocScalar( h, "igain", 0.0, 3.0, 0.01, 1.0 );
  2104. cmDspInst_t* hop = cmDspSysAllocScalar( h, "hop", 0.0, 16.0, 1.0, 4.0 );
  2105. //cmDspInst_t* prnt = cmDspSysAllocInst( h,"Printer", NULL, 1, ">" );
  2106. // check for allocation errors
  2107. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  2108. goto errLabel;
  2109. cmDspSysConnectAudio(h,ain,"out", goer, "in" );
  2110. cmDspSysConnectAudio(h,ain,"out", amtr, "in" );
  2111. cmDspSysConnectAudioN11N(h,sgV, "out", mix, "in", chCnt );
  2112. cmDspSysConnectAudio(h,mix,"out", ao0, "in" );
  2113. cmDspSysConnectAudio(h,mix,"out", ao1, "in" );
  2114. cmDspSysInstallCb( h, igain, "val", ain, "gain", NULL);
  2115. cmDspSysInstallCbN1N1( h, hzV, "val", sgV, "hz", chCnt);
  2116. cmDspSysInstallCbN11N( h, hzV, "val", goer, "hz", chCnt );
  2117. cmDspSysInstallCbN11N( h, gnV, "val", mix, "gain", chCnt);
  2118. cmDspSysInstallCb1NN1( h, goer, "out", mtrV, "in", chCnt );
  2119. cmDspSysInstallCb( h, hop, "val", goer, "hop", NULL );
  2120. errLabel:
  2121. return rc;
  2122. }
  2123. cmDspRC_t _cmDspSysPgm_TakeSeqBldr( cmDspSysH_t h, void** userPtrPtr )
  2124. {
  2125. cmDspRC_t rc = kOkDspRC;
  2126. const cmChar_t* tksbFn = "/home/kevin/src/cmkc/src/kc/data/takeSeqBldr0.js";
  2127. const cmChar_t* deviceName = "Fastlane";
  2128. const cmChar_t* portName = "Fastlane MIDI A";
  2129. //const cmChar_t* deviceName = "DKV-M4";
  2130. //const cmChar_t* portName = "DKV-M4 MIDI 1";
  2131. const cmChar_t* fn = cmFsMakeFn(cmFsUserDir(),tksbFn,NULL,NULL );
  2132. cmDspInst_t* tsb = cmDspSysAllocInst( h,"TakeSeqBldr", NULL, 1, tksbFn );
  2133. cmDspInst_t* tsr = cmDspSysAllocInst( h,"TakeSeqRend", NULL, 0 );
  2134. cmDspInst_t* nano = cmDspSysAllocInst( h,"NanoMap", NULL, 0 );
  2135. cmDspInst_t* mop = cmDspSysAllocInst( h,"MidiOut", NULL, 2, deviceName, portName);
  2136. cmDspSysNewPage(h,"Controls");
  2137. //cmDspInst_t* fnp = cmDspSysAllocInst(h,"Fname", NULL, 3, false,"JS Files (*.js)\tJS Files (*.{js})",fn);
  2138. cmDspInst_t* start = cmDspSysAllocInst( h,"Button", "start", 2, kButtonDuiId, 0.0 );
  2139. cmDspInst_t* stop = cmDspSysAllocInst( h,"Button", "stop", 2, kButtonDuiId, 0.0 );
  2140. cmDspInst_t* cont = cmDspSysAllocInst( h,"Button", "continue", 2, kButtonDuiId, 0.0 );
  2141. cmDspInst_t* prt = cmDspSysAllocInst( h, "Printer", NULL, 1, ">" );
  2142. // check for allocation errors
  2143. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  2144. goto errLabel;
  2145. cmDspSysInstallCb( h, tsb, "bldr", tsr, "bldr", NULL);
  2146. cmDspSysInstallCb( h, tsb, "refresh", tsr, "refresh", NULL );
  2147. cmDspSysInstallCb( h, tsb, "sel", tsr, "sel", NULL );
  2148. cmDspSysInstallCb( h, start, "sym", tsr, "cmd", NULL);
  2149. cmDspSysInstallCb( h, stop, "sym", tsr, "cmd", NULL);
  2150. cmDspSysInstallCb( h, cont, "sym", tsr, "cmd", NULL);
  2151. cmDspSysInstallCb( h, tsr, "d1", nano, "d1", NULL);
  2152. cmDspSysInstallCb( h, tsr, "d0", nano, "d0", NULL);
  2153. cmDspSysInstallCb( h, tsr, "status", nano, "status", NULL);
  2154. cmDspSysInstallCb( h, nano, "d1", mop, "d1", NULL);
  2155. cmDspSysInstallCb( h, nano, "d0", mop, "d0", NULL);
  2156. cmDspSysInstallCb( h, nano, "status", mop, "status", NULL);
  2157. //cmDspSysInstallCb( h, tsb, "sel", prt, "in", NULL );
  2158. cmDspSysInstallCb( h, tsb, "refresh", prt, "in", NULL);
  2159. errLabel:
  2160. cmFsFreeFn(fn);
  2161. return rc;
  2162. }
  2163. _cmDspSysPgm_t _cmDspSysPgmArray[] =
  2164. {
  2165. { "tksb", _cmDspSysPgm_Tksb, NULL, NULL },
  2166. { "time_line", _cmDspSysPgm_TimeLine, NULL, NULL },
  2167. { "seq-bldr", _cmDspSysPgm_TakeSeqBldr, NULL, NULL },
  2168. { "multi-out", _cmDspSysPgm_MultiOut, NULL, NULL },
  2169. { "multi-in", _cmDspSysPgm_MultiIn, NULL, NULL },
  2170. { "goertzel", _cmDspSysPgm_Goertzel, NULL, NULL },
  2171. { "main", _cmDspSysPgm_Main, NULL, NULL },
  2172. { "array", _cmDspSysPgm_Array, NULL, NULL },
  2173. { "line", _cmDspSysPgm_Line, NULL, NULL },
  2174. { "1Up", _cmDspSysPgm_1Up, NULL, NULL },
  2175. { "PortToSym", _cmDspSysPgm_PortToSym, NULL, NULL },
  2176. { "preset", _cmDspSysPgm_Preset, NULL, NULL },
  2177. { "rsrcWr", _cmDspSysPgm_RsrcWr, NULL, NULL },
  2178. { "router", _cmDspSysPgm_Router, NULL, NULL },
  2179. { "1ofN", _cmDspSysPgm_1ofN, NULL, NULL },
  2180. { "NofM", _cmDspSysPgm_NofM, NULL, NULL },
  2181. { "whirl_net", _cmDspSysPgm_WhirlNet, NULL, NULL },
  2182. { "thunk_net", _cmDspSysPgm_ThunkNet, NULL, NULL },
  2183. { "seq", _cmDspSysPgm_Seq, NULL, NULL },
  2184. { "dist_ds", _cmDspSysPgm_DistDs, NULL, NULL },
  2185. { "bi_quad_eq", _cmDspSysPgm_BiQuadEq, NULL, NULL },
  2186. { "compressor", _cmDspSysPgm_Compressor, NULL, NULL },
  2187. { "adsr", _cmDspSysPgm_Adsr, NULL, NULL },
  2188. { "msg delay", _cmDspSysPgm_MsgDelay, NULL, NULL },
  2189. { "pickup rmod2", _cmDspSysPgm_RingMod2, NULL, NULL },
  2190. { "pickup rmod", _cmDspSysPgm_RingMod, NULL, NULL },
  2191. { "pickup tails", _cmDspSysPgm_NoiseTails, NULL, NULL },
  2192. { "tails_2", _cmDspSysPgm_NoiseTails2, NULL, NULL },
  2193. { "pickups", _cmDspSysPgm_Pickups0, NULL, NULL },
  2194. { "sync_recd", _cmDspSysPgm_SyncRecd, NULL, NULL },
  2195. { "midi_test", _cmDspSysPgm_Test_Midi, NULL, NULL },
  2196. { "midi_file", _cmDspSysPgm_MidiFilePlay, NULL, NULL },
  2197. { "2_thru", _cmDspSysPgm_Stereo_Through, NULL, NULL },
  2198. { "guitar", _cmDspSysPgmGuitar, NULL, NULL },
  2199. { "2_fx", _cmDspSysPgm_Stereo_Fx, NULL, NULL },
  2200. { "sine", _cmDspSysPgm_PlaySine, NULL, NULL },
  2201. { "file", _cmDspSysPgm_PlayFile, NULL, NULL },
  2202. { "gate_detect", _cmDspSysPgm_GateDetect, NULL, NULL },
  2203. { "record", _cmDspSysPgm_Record, NULL, NULL },
  2204. { "pitch_shift", _cmDspSysPgm_PitchShiftFile, NULL, NULL },
  2205. { "loop_recd", _cmDspSysPgm_LoopRecd, NULL, NULL },
  2206. { "ui_test", _cmDspSysPgm_UiTest, NULL, NULL },
  2207. { "xfade_test", _cmDspSysPgm_Xfade, NULL, NULL },
  2208. { "auto_gain", _cmDspSysPgm_AutoGain, NULL, NULL },
  2209. { "comb filt", _cmDspSysPgm_CombFilt, NULL, NULL },
  2210. { "scalar op", _cmDspSysPgm_ScalarOp, NULL, NULL },
  2211. { "seg_line", _cmDspSysPgm_SegLine, NULL, NULL },
  2212. { "avail_ch", _cmDspSysPgm_AvailCh, NULL, NULL },
  2213. { NULL , NULL, NULL, NULL }
  2214. };
  2215. _cmDspSysPgm_t* _cmDspSysPgmArrayBase()
  2216. {
  2217. return _cmDspSysPgmArray;
  2218. }