libcm is a C development framework with an emphasis on audio signal processing applications.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

cmDspPgmKr.c 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. #include "cmPrefix.h"
  2. #include "cmGlobal.h"
  3. #include "cmFloatTypes.h"
  4. #include "cmRpt.h"
  5. #include "cmErr.h"
  6. #include "cmCtx.h"
  7. #include "cmMem.h"
  8. #include "cmMallocDebug.h"
  9. #include "cmLinkedHeap.h"
  10. #include "cmText.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 "cmAudioSys.h"
  21. #include "cmProcObj.h"
  22. #include "cmDspCtx.h"
  23. #include "cmDspClass.h"
  24. #include "cmDspSys.h"
  25. #include "cmDspPgm.h"
  26. #include "cmAudioFile.h"
  27. #include "cmProcObj.h"
  28. #include "cmProc.h"
  29. #include "cmProc3.h"
  30. #include "cmVectOpsTemplateMain.h"
  31. #include "cmVectOps.h"
  32. typedef struct
  33. {
  34. const cmChar_t* tlFn;
  35. const cmChar_t* audPath;
  36. const cmChar_t* scFn;
  37. const cmChar_t* modFn;
  38. } krRsrc_t;
  39. cmDspRC_t krLoadRsrc(cmDspSysH_t h, cmErr_t* err, krRsrc_t* r)
  40. {
  41. cmDspRC_t rc;
  42. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  43. return rc;
  44. cmDspRsrcString(h,&r->tlFn, "timeLineFn", NULL);
  45. cmDspRsrcString(h,&r->audPath,"tlAudioFilePath", NULL);
  46. cmDspRsrcString(h,&r->scFn, "scoreFn", NULL);
  47. cmDspRsrcString(h,&r->modFn, "modFn", NULL);
  48. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  49. cmErrMsg(err,rc,"A KR DSP resource load failed.");
  50. return rc;
  51. }
  52. cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr )
  53. {
  54. cmDspRC_t rc = kOkDspRC;
  55. cmCtx_t* cmCtx = cmDspSysPgmCtx(h);
  56. cmErr_t err;
  57. krRsrc_t r;
  58. unsigned wtLoopCnt = 1; // 1=play once (-1=loop forever)
  59. unsigned wtInitMode = 0; // initial wt mode is 'silence'
  60. unsigned wtSmpCnt = floor(cmDspSysSampleRate(h)); // wt length == srate
  61. int krWndSmpCnt = 2048;
  62. int krHopFact = 4;
  63. unsigned xfadOutChCnt = 2;
  64. double xfadMs = 200;
  65. bool xfadAllOnFl = true;
  66. memset(&r,0,sizeof(r));
  67. cmErrSetup(&err,&cmCtx->rpt,"Kr Timeline");
  68. if( krLoadRsrc(h,&err,&r) != kOkDspRC )
  69. return rc;
  70. cmDspInst_t* tlp = cmDspSysAllocInst(h,"TimeLine", "tl", 2, r.tlFn, r.audPath );
  71. cmDspInst_t* scp = cmDspSysAllocInst(h,"Score", "sc", 1, r.scFn );
  72. cmDspInst_t* php = cmDspSysAllocInst(h,"Phasor", NULL, 1, cmDspSysSampleRate(h) );
  73. cmDspInst_t* wtp = cmDspSysAllocInst(h,"WaveTable", NULL, 4, wtSmpCnt, wtInitMode, NULL, wtLoopCnt );
  74. cmDspInst_t* pts = cmDspSysAllocInst(h,"PortToSym", NULL, 2, "on", "off" );
  75. cmDspInst_t* mfp = cmDspSysAllocInst(h,"MidiFilePlay",NULL, 0 );
  76. cmDspInst_t* sfp = cmDspSysAllocInst(h,"ScFol", NULL, 1, r.scFn );
  77. cmDspInst_t* modp = cmDspSysAllocInst(h,"ScMod", NULL, 2, r.modFn, "m1" );
  78. cmDspInst_t* kr0p = cmDspSysAllocInst(h,"Kr", NULL, 2, krWndSmpCnt, krHopFact );
  79. cmDspInst_t* kr1p = cmDspSysAllocInst(h,"Kr", NULL, 2, krWndSmpCnt, krHopFact );
  80. cmDspInst_t* xfad = cmDspSysAllocInst(h,"Xfader", NULL, 3, xfadOutChCnt, xfadMs, xfadAllOnFl );
  81. cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut", NULL, 1, 0 );
  82. cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut", NULL, 1, 1 );
  83. //cmDspInst_t* af0p = cmDspSysAllocInst(h,"AudioFileOut",NULL, 2, "/home/kevin/temp/debug0.wav",1);
  84. cmDspSysNewPage(h,"Controls");
  85. cmDspInst_t* onb = cmDspSysAllocInst(h,"Button", "start", 2, kButtonDuiId, 1.0 );
  86. cmDspInst_t* offb = cmDspSysAllocInst(h,"Button", "stop", 2, kButtonDuiId, 1.0 );
  87. cmDspInst_t* prtb = cmDspSysAllocInst(h,"Button", "print", 2, kButtonDuiId, 1.0 );
  88. cmDspInst_t* qtb = cmDspSysAllocInst(h,"Button", "quiet", 2, kButtonDuiId, 1.0 );
  89. cmDspInst_t* prp = cmDspSysAllocInst(h,"Printer", NULL, 1, ">" );
  90. cmDspInst_t* prd = cmDspSysAllocInst(h,"Printer", NULL, 1, "DYN:" );
  91. cmDspInst_t* pre = cmDspSysAllocInst(h,"Printer", NULL, 1, "EVEN:" );
  92. cmDspInst_t* prt = cmDspSysAllocInst(h,"Printer", NULL, 1, "TEMPO:");
  93. //cmDspInst_t* prv = cmDspSysAllocInst(h,"Printer", NULL, 1, "Value:");
  94. cmDspSysNewColumn(h,0);
  95. cmDspInst_t* md0p = cmDspSysAllocInst(h,"Scalar", "Mode", 5, kNumberDuiId, 0.0, 4.0, 1.0, 1.0);
  96. cmDspInst_t* ws0p = cmDspSysAllocInst(h,"MsgList","wndSmpCnt", 3, "wndSmpCnt", NULL, 2);
  97. cmDspInst_t* hf0p = cmDspSysAllocInst(h,"MsgList","hopFact", 3, "hopFact", NULL, 2);
  98. cmDspInst_t* th0p = cmDspSysAllocInst(h,"Scalar", "threshold", 5, kNumberDuiId, 0.0, 100.0, 1.0, 60.0 );
  99. cmDspInst_t* us0p = cmDspSysAllocInst(h,"Scalar", "upr slope", 5, kNumberDuiId, 0.0, 10.0, 0.01, 0.0 );
  100. cmDspInst_t* ls0p = cmDspSysAllocInst(h,"Scalar", "lwr slope", 5, kNumberDuiId, 0.3, 10.0, 0.01, 2.0 );
  101. cmDspInst_t* of0p = cmDspSysAllocInst(h,"Scalar", "offset", 5, kNumberDuiId, 0.0, 100.0, 0.01, 30.0 );
  102. cmDspInst_t* iv0p = cmDspSysAllocInst(h,"Scalar", "invert", 5, kNumberDuiId, 0.0, 1.0, 1.0, 0.0 );
  103. cmDspInst_t* wet0 = cmDspSysAllocInst(h,"Scalar", "wet", 5, kNumberDuiId, 0.0, 1.0,0.001, 1.0 );
  104. cmDspSysNewColumn(h,0);
  105. //cmDspInst_t* al1p = cmDspSysAllocInst(h,"MsgList","audFiles", 2, "audFiles",NULL);
  106. //cmDspInst_t* fl1p = cmDspSysAllocInst(h,"MsgList","audFrags1", 2, "audFrags",NULL);
  107. //cmDspInst_t* fn1p = cmDspSysAllocInst(h,"Sprintf","filename", 1, "%s/%s_%02i.wav");
  108. cmDspInst_t* md1p = cmDspSysAllocInst(h,"Scalar", "Mode1", 5, kNumberDuiId, 0.0, 4.0, 1.0, 1.0);
  109. cmDspInst_t* ws1p = cmDspSysAllocInst(h,"MsgList","wndSmpCnt1", 3, "wndSmpCnt", NULL, 2);
  110. cmDspInst_t* hf1p = cmDspSysAllocInst(h,"MsgList","hopFact1", 3, "hopFact", NULL, 2);
  111. cmDspInst_t* th1p = cmDspSysAllocInst(h,"Scalar", "threshold1", 5, kNumberDuiId, 0.0, 100.0, 1.0, 60.0 );
  112. cmDspInst_t* us1p = cmDspSysAllocInst(h,"Scalar", "upr slope1", 5, kNumberDuiId, 0.0, 10.0, 0.01, 0.0 );
  113. cmDspInst_t* ls1p = cmDspSysAllocInst(h,"Scalar", "lwr slope1", 5, kNumberDuiId, 0.3, 10.0, 0.01, 2.0 );
  114. cmDspInst_t* of1p = cmDspSysAllocInst(h,"Scalar", "offset1", 5, kNumberDuiId, 0.0, 100.0, 0.01, 30.0 );
  115. cmDspInst_t* iv1p = cmDspSysAllocInst(h,"Scalar", "invert1", 5, kNumberDuiId, 0.0, 1.0, 1.0, 0.0 );
  116. cmDspInst_t* wet1 = cmDspSysAllocInst(h,"Scalar", "wet1", 5, kNumberDuiId, 0.0, 1.0,0.001, 1.0 );
  117. cmDspSysNewColumn(h,0);
  118. cmDspInst_t* ogain = cmDspSysAllocInst(h,"Scalar", "Out Gain", 5, kNumberDuiId, 0.0, 10.0,0.01, 3.0 );
  119. //cmDspInst_t* reload = cmDspSysAllocInst(h,"Button", "Reload", 2, kButtonDuiId, 0.0 );
  120. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  121. return rc;
  122. // phasor->wt->aout
  123. cmDspSysConnectAudio(h, php, "out", wtp, "phs" ); // phs -> wt
  124. if(1)
  125. {
  126. cmDspSysConnectAudio(h, wtp, "out", kr0p, "in" ); // wt->kr
  127. cmDspSysConnectAudio(h, wtp, "out", kr1p, "in" );
  128. cmDspSysConnectAudio(h, kr0p, "out", xfad, "in-0"); // kr->aout
  129. cmDspSysConnectAudio(h, kr1p, "out", xfad, "in-1");
  130. cmDspSysConnectAudio(h, xfad, "out-0", ao0p, "in"); // kr->aout
  131. cmDspSysConnectAudio(h, xfad, "out-1", ao1p, "in");
  132. }
  133. else
  134. {
  135. cmDspSysConnectAudio(h, wtp, "out", ao0p, "in" ); // wt -> aout0
  136. cmDspSysConnectAudio(h, wtp, "out", ao1p, "in" ); // wt -> aout1
  137. //cmDspSysConnectAudio(h, wtp, "out", af0p, "in0" ); // wt -> audio file
  138. }
  139. // wave-table to time-line cursor
  140. cmDspSysInstallCb( h, wtp, "fidx",tlp, "curs", NULL);
  141. // start connections
  142. cmDspSysInstallCb(h, onb, "sym", tlp, "reset", NULL );
  143. cmDspSysInstallCb(h, onb, "sym", scp, "send", NULL );
  144. cmDspSysInstallCb(h, onb, "sym", mfp, "sel", NULL );
  145. cmDspSysInstallCb(h, onb, "sym", pts, "on", NULL );
  146. cmDspSysInstallCb(h, pts, "on", wtp, "cmd", NULL );
  147. cmDspSysInstallCb(h, pts, "on", modp,"cmd", NULL );
  148. // stop connections
  149. cmDspSysInstallCb(h, wtp, "done",offb,"in", NULL ); // 'done' from WT simulates pressing Stop btn.
  150. cmDspSysInstallCb(h, tlp, "mfn", pts, "off", NULL ); // Prevents WT start on new audio file from TL.
  151. cmDspSysInstallCb(h, offb, "sym", mfp, "sel", NULL );
  152. cmDspSysInstallCb(h, offb, "sym", pts, "off", NULL );
  153. cmDspSysInstallCb(h, pts, "off", wtp, "cmd", NULL );
  154. cmDspSysInstallCb(h, pts, "off", modp,"cmd", NULL );
  155. // time-line to wave-table selection
  156. cmDspSysInstallCb(h, tlp, "absi", wtp, "beg", NULL );
  157. cmDspSysInstallCb(h, tlp, "aesi", wtp, "end", NULL );
  158. cmDspSysInstallCb(h, tlp, "afn", wtp, "fn", NULL );
  159. // time-line to MIDI file player selection
  160. cmDspSysInstallCb(h, tlp, "mbsi", mfp, "bsi", NULL );
  161. cmDspSysInstallCb(h, tlp, "mesi", mfp, "esi", NULL );
  162. cmDspSysInstallCb(h, tlp, "mfn", mfp, "fn", NULL );
  163. // score to score follower - to set initial search location
  164. cmDspSysInstallCb(h, scp, "sel", sfp, "index", NULL );
  165. //cmDspSysInstallCb(h, scp, "sel", prv, "in", NULL );
  166. cmDspSysInstallCb(h, scp, "sel", modp,"reset", NULL );
  167. //cmDspSysInstallCb(h, reload,"out", modp, "reload", NULL );
  168. // MIDI file play er to score follower
  169. if(1)
  170. {
  171. cmDspSysInstallCb(h, mfp, "smpidx", sfp, "smpidx", NULL );
  172. cmDspSysInstallCb(h, mfp, "d1", sfp, "d1", NULL );
  173. cmDspSysInstallCb(h, mfp, "d0", sfp, "d0", NULL );
  174. cmDspSysInstallCb(h, mfp, "status", sfp, "status", NULL );
  175. }
  176. // score follower to modulator and printers
  177. cmDspSysInstallCb(h, sfp, "out", modp, "index", NULL );
  178. cmDspSysInstallCb(h, sfp, "out", prp, "in", NULL );
  179. cmDspSysInstallCb(h, sfp, "even", pre, "in", NULL );
  180. cmDspSysInstallCb(h, sfp, "dyn", prd, "in", NULL );
  181. cmDspSysInstallCb(h, sfp, "tempo",prt, "in", NULL );
  182. cmDspSysInstallCb(h, prtb, "sym", sfp, "cmd", NULL );
  183. cmDspSysInstallCb(h, qtb, "sym", sfp, "cmd", NULL );
  184. cmDspSysInstallCb(h, ws0p, "out", kr0p, "wndn", NULL ); // wndSmpCnt->kr
  185. cmDspSysInstallCb(h, hf0p, "out", kr0p, "hopf", NULL ); // hopFact->kr
  186. cmDspSysInstallCb(h, md0p, "val", kr0p, "mode", NULL ); // mode->kr
  187. cmDspSysInstallCb(h, th0p, "val", kr0p, "thrh", NULL ); // thresh->kr
  188. cmDspSysInstallCb(h, ls0p, "val", kr0p, "lwrs", NULL ); // lwrSlope->kr
  189. cmDspSysInstallCb(h, us0p, "val", kr0p, "uprs", NULL ); // uprSlope->kr
  190. cmDspSysInstallCb(h, of0p, "val", kr0p, "offs", NULL ); // offset->kr
  191. cmDspSysInstallCb(h, iv0p, "val", kr0p, "invt", NULL ); // invert->kr
  192. cmDspSysInstallCb(h, wet0, "val", kr0p, "wet", NULL ); // wet->kr
  193. cmDspSysInstallCb(h, ws1p, "out", kr1p, "wndn", NULL ); // wndSmpCnt->kr
  194. cmDspSysInstallCb(h, hf1p, "out", kr1p, "hopf", NULL ); // hopFact->kr
  195. cmDspSysInstallCb(h, md1p, "val", kr1p, "mode", NULL ); // mode->kr
  196. cmDspSysInstallCb(h, th1p, "val", kr1p, "thrh", NULL ); // thresh->kr
  197. cmDspSysInstallCb(h, ls1p, "val", kr1p, "lwrs", NULL ); // lwrSlope->kr
  198. cmDspSysInstallCb(h, us1p, "val", kr1p, "uprs", NULL ); // uprSlope->kr
  199. cmDspSysInstallCb(h, of1p, "val", kr1p, "offs", NULL ); // offset->kr
  200. cmDspSysInstallCb(h, iv1p, "val", kr1p, "invt", NULL ); // invert->kr
  201. cmDspSysInstallCb(h, wet1, "val", kr1p, "wet", NULL ); // wet->kr
  202. cmDspSysInstallCb(h, ogain, "val", ao0p, "gain", NULL ); // output gain control
  203. cmDspSysInstallCb(h, ogain, "val", ao1p, "gain", NULL );
  204. // Printer connections
  205. cmDspSysInstallCb(h, tlp, "afn", prp, "in", NULL );
  206. cmDspSysInstallCb(h, tlp, "mfn", prp, "in", NULL );
  207. cmDspSysInstallCb(h, tlp, "sel", prp, "in", NULL );
  208. cmDspSysInstallCb(h, modp, "mod0", md0p, "val", NULL );
  209. cmDspSysInstallCb(h, modp, "win0", kr0p, "wndn",NULL );
  210. cmDspSysInstallCb(h, modp, "thr0", th0p, "val", NULL );
  211. cmDspSysInstallCb(h, modp, "upr0", us0p, "val", NULL );
  212. cmDspSysInstallCb(h, modp, "lwr0", ls0p, "val", NULL );
  213. cmDspSysInstallCb(h, modp, "off0", of0p, "val", NULL );
  214. cmDspSysInstallCb(h, modp, "inv0", iv0p, "val", NULL );
  215. cmDspSysInstallCb(h, modp, "wet0", wet0, "val", NULL );
  216. cmDspSysInstallCb(h, modp, "xf0", xfad, "gate-0", NULL );
  217. cmDspSysInstallCb(h, modp, "mod1", md1p, "val", NULL );
  218. cmDspSysInstallCb(h, modp, "win1", kr1p, "wndn",NULL );
  219. cmDspSysInstallCb(h, modp, "thr1", th1p, "val", NULL );
  220. cmDspSysInstallCb(h, modp, "upr1", us1p, "val", NULL );
  221. cmDspSysInstallCb(h, modp, "lwr1", ls1p, "val", NULL );
  222. cmDspSysInstallCb(h, modp, "off1", of1p, "val", NULL );
  223. cmDspSysInstallCb(h, modp, "inv1", iv1p, "val", NULL );
  224. cmDspSysInstallCb(h, modp, "wet1", wet1, "val", NULL );
  225. cmDspSysInstallCb(h, modp, "xf1", xfad, "gate-1", NULL );
  226. return rc;
  227. }
  228. cmDspRC_t _cmDspSysPgm_Switcher(cmDspSysH_t h, void** userPtrPtr )
  229. {
  230. cmDspRC_t rc = kOkDspRC;
  231. const char* fn0 = "media/audio/20110723-Kriesberg/Audio Files/Piano 3_01.wav";
  232. const cmChar_t* fn = cmFsMakeFn(cmFsUserDir(),fn0,NULL,NULL );
  233. bool bypassFl = false;
  234. double inGain = 1.0;
  235. double dsrate = 96000.0;
  236. double bits = 24.0;
  237. bool rectifyFl = false;
  238. bool fullRectFl = false;
  239. double clipDb = -10.0;
  240. double cfMinHz = 20.0;
  241. double cfHz = 1000.0;
  242. double cfAlpha = 0.9;
  243. bool cfFbFl = true;
  244. bool cfBypassFl = false;
  245. unsigned outChCnt = 2;
  246. double xfadeMs = 250;
  247. cmDspInst_t* gsw = cmDspSysAllocInst(h,"GSwitch", NULL, 2, 12,2 );
  248. cmDspInst_t* ofp = cmDspSysAllocInst(h,"Scalar", "Offset", 5, kNumberDuiId, 0.0, cmDspSysSampleRate(h)*600.0, 1.0, 6900000.0);
  249. cmDspInst_t* fnp = cmDspSysAllocInst(h,"Fname", NULL, 3, false,"Audio Files (*.wav,*.aiff,*.aif)\tAudio Files (*.{wav,aiff,aif})",fn);
  250. cmDspInst_t* php = cmDspSysAllocInst(h,"Phasor", NULL, 0 );
  251. cmDspInst_t* wtp = cmDspSysAllocInst(h,"WaveTable",NULL, 2, ((int)cmDspSysSampleRate(h)), 1 );
  252. cmDspInst_t* dst = cmDspSysAllocInst(h,"DistDs", NULL, 3, bypassFl, inGain, dsrate, bits );
  253. cmDspInst_t* cf = cmDspSysAllocInst( h,"CombFilt", NULL, 5, cfBypassFl, cfMinHz, cfFbFl, cfMinHz, cfAlpha );
  254. cmDspInst_t* xfad = cmDspSysAllocInst(h,"Xfader", NULL, 2, outChCnt, xfadeMs );
  255. cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 0 );
  256. cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 1 );
  257. cmDspInst_t* ign = cmDspSysAllocScalar( h, "In Gain", 0.0, 10.0, 0.01, 1.0);
  258. cmDspInst_t* rct = cmDspSysAllocCheck( h, "Rectify", rectifyFl);
  259. cmDspInst_t* ful = cmDspSysAllocCheck( h, "Full/Half", fullRectFl);
  260. cmDspInst_t* dsr = cmDspSysAllocScalar( h, "Srate", 0.0, 96000, 1.0, dsrate);
  261. cmDspInst_t* dbt = cmDspSysAllocScalar( h, "bits", 2.0, 32.0, 1.0, bits);
  262. cmDspInst_t* clip = cmDspSysAllocScalar( h, "Clip dB", -100.0, 0.0, 0.1, clipDb);
  263. cmDspInst_t* ogn = cmDspSysAllocScalar( h, "Out Gain", 0.0, 10.0, 0.01, 1.0);
  264. cmDspInst_t* cfhz = cmDspSysAllocScalar( h, "CF Hz", 25, 10000, 1, cfHz );
  265. cmDspInst_t* cfalpha = cmDspSysAllocScalar( h, "CF Alpha", 0.0, 2.0, 0.001, cfAlpha);
  266. cmDspInst_t* cfgain = cmDspSysAllocScalar( h, "CF Gain", 0.0, 20.0, 0.001, 1.0);
  267. cmDspInst_t* cffb = cmDspSysAllocInst( h,"Button", "CF Fb", 2, kCheckDuiId, 0.0 );
  268. cmDspInst_t* dfdb = cmDspSysAllocInst( h,"Button", "Dist Fade", 2, kCheckDuiId, 0.0 );
  269. cmDspInst_t* cfdb = cmDspSysAllocInst( h,"Button", "CF Fade", 2, kCheckDuiId, 0.0 );
  270. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  271. return rc;
  272. cmDspSysConnectAudio(h, php, "out", wtp, "phs" ); // phasor -> wave table
  273. cmDspSysConnectAudio(h, wtp, "out", dst, "in" ); // wt -> dist
  274. cmDspSysConnectAudio(h, dst, "out", xfad, "in-0"); // dist -> xfad
  275. cmDspSysConnectAudio(h, xfad,"out-0",ao0p, "in" ); // xfad -> aout
  276. cmDspSysConnectAudio(h, wtp, "out", cf, "in" ); // wt -> xfad
  277. cmDspSysConnectAudio(h, cf, "out", xfad, "in-1"); // xfad -> cf
  278. cmDspSysConnectAudio(h, xfad,"out-1",ao1p, "in" ); // cf -> aout
  279. cmDspSysInstallCb(h, ofp, "val", wtp, "beg", NULL ); // offset -> wavetable
  280. cmDspSysInstallCb(h, fnp, "out", wtp, "fn", NULL); // filename -> wavetable
  281. // Distortion control connections
  282. cmDspSysInstallCb(h, ign, "val", dst, "igain", NULL );
  283. cmDspSysInstallCb(h, dsr, "val", dst, "srate", NULL );
  284. cmDspSysInstallCb(h, dbt, "val", dst, "bits", NULL );
  285. cmDspSysInstallCb(h, rct, "out", dst, "rect", NULL );
  286. cmDspSysInstallCb(h, ful, "out", dst, "full", NULL );
  287. cmDspSysInstallCb(h, clip, "val", dst, "clip", NULL );
  288. cmDspSysInstallCb(h, ogn, "val", dst, "ogain", NULL );
  289. cmDspSysInstallCb(h, cfhz, "val", cf, "hz", NULL );
  290. cmDspSysInstallCb(h, cfalpha, "val", cf, "alpha", NULL );
  291. cmDspSysInstallCb(h, cffb, "out", cf, "fb", NULL );
  292. cmDspSysInstallCb(h, cfgain, "val", ao1p, "gain", NULL );
  293. cmDspSysInstallCb(h, dfdb, "out", xfad, "gate-0", NULL);
  294. cmDspSysInstallCb(h, cfdb, "out", xfad, "gate-1", NULL);
  295. return cmDspSysLastRC(h);
  296. }