libcm is a C development framework with an emphasis on audio signal processing applications.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

cmDspPgm.c 107KB

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