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

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