libcm is a C development framework with an emphasis on audio signal processing applications.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cmDspPgm.c 141KB

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