libcm is a C development framework with an emphasis on audio signal processing applications.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

cmDspPgmKr.c 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. } krRsrc_t;
  38. cmDspRC_t krLoadRsrc(cmDspSysH_t h, cmErr_t* err, krRsrc_t* r)
  39. {
  40. cmDspRC_t rc;
  41. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  42. return rc;
  43. cmDspRsrcString(h,&r->tlFn, "timeLineFn", NULL);
  44. cmDspRsrcString(h,&r->audPath,"tlAudioFilePath", NULL);
  45. cmDspRsrcString(h,&r->scFn, "scoreFn", NULL);
  46. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  47. cmErrMsg(err,rc,"A KR DSP resource load failed.");
  48. return rc;
  49. }
  50. cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr )
  51. {
  52. cmDspRC_t rc = kOkDspRC;
  53. cmCtx_t* cmCtx = cmDspSysPgmCtx(h);
  54. cmErr_t err;
  55. krRsrc_t r;
  56. unsigned wtLoopCnt = 1; // play once (do not loop)
  57. unsigned wtInitMode = 0; // initial wt mode is 'silence'
  58. unsigned wtSmpCnt = floor(cmDspSysSampleRate(h)); // wt length == srate
  59. memset(&r,0,sizeof(r));
  60. cmErrSetup(&err,&cmCtx->rpt,"Kr Timeline");
  61. if( krLoadRsrc(h,&err,&r) != kOkDspRC )
  62. return rc;
  63. cmDspInst_t* tlp = cmDspSysAllocInst(h,"TimeLine", "tl", 2, r.tlFn, r.audPath );
  64. cmDspInst_t* scp = cmDspSysAllocInst(h,"Score", "sc", 1, r.scFn );
  65. cmDspInst_t* php = cmDspSysAllocInst(h,"Phasor", NULL, 0 );
  66. cmDspInst_t* wtp = cmDspSysAllocInst(h,"WaveTable", NULL, 4, wtSmpCnt, wtInitMode, NULL, wtLoopCnt );
  67. cmDspInst_t* pts = cmDspSysAllocInst(h,"PortToSym", NULL, 2, "on", "off" );
  68. cmDspInst_t* mfp = cmDspSysAllocInst(h,"MidiFilePlay",NULL, 0 );
  69. cmDspInst_t* sfp = cmDspSysAllocInst(h,"ScFol", NULL, 1, r.scFn );
  70. cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut", NULL, 1, 0 );
  71. cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut", NULL, 1, 1 );
  72. cmDspSysNewPage(h,"Controls");
  73. cmDspInst_t* onb = cmDspSysAllocInst(h,"Button", "start", 2, kButtonDuiId, 1.0 );
  74. cmDspInst_t* offb = cmDspSysAllocInst(h,"Button", "stop", 2, kButtonDuiId, 1.0 );
  75. cmDspInst_t* prp = cmDspSysAllocInst(h,"Printer", NULL, 1, ">" );
  76. if((rc = cmDspSysLastRC(h)) != kOkDspRC )
  77. return rc;
  78. // phasor->wt->aout
  79. cmDspSysConnectAudio(h, php, "out", wtp, "phs" ); // phs -> wt
  80. cmDspSysConnectAudio(h, wtp, "out", ao0p, "in" ); // wt -> aout0
  81. cmDspSysConnectAudio(h, wtp, "out", ao1p, "in" ); // wt -> aout1
  82. cmDspSysInstallCb( h, wtp, "fidx",tlp, "curs", NULL);
  83. //cmDspSysInstallCb( h, wtp, "fidx",prp, "in", NULL );
  84. // start connections
  85. cmDspSysInstallCb(h, onb, "sym", tlp, "reset", NULL );
  86. cmDspSysInstallCb(h, onb, "sym", scp, "send", NULL );
  87. cmDspSysInstallCb(h, onb, "sym", mfp, "sel", NULL );
  88. cmDspSysInstallCb(h, onb, "sym", pts, "on", NULL );
  89. cmDspSysInstallCb(h, pts, "on", wtp, "cmd", NULL );
  90. // stop connections
  91. cmDspSysInstallCb(h, wtp, "done",offb,"in", NULL ); // 'done' from WT simulates pressing Stop btn.
  92. cmDspSysInstallCb(h, tlp, "mfn", pts, "off", NULL ); // Prevents WT start on new audio file from TL.
  93. cmDspSysInstallCb(h, offb, "sym", mfp, "sel", NULL );
  94. cmDspSysInstallCb(h, offb, "sym", pts, "off", NULL );
  95. cmDspSysInstallCb(h, pts, "off", wtp, "cmd", NULL );
  96. // time-line to wave-table selection
  97. cmDspSysInstallCb(h, tlp, "absi", wtp, "beg", NULL );
  98. cmDspSysInstallCb(h, tlp, "aesi", wtp, "end", NULL );
  99. cmDspSysInstallCb(h, tlp, "afn", wtp, "fn", NULL );
  100. // time-line to MIDI file player selection
  101. cmDspSysInstallCb(h, tlp, "mbsi", mfp, "bsi", NULL );
  102. cmDspSysInstallCb(h, tlp, "mesi", mfp, "esi", NULL );
  103. cmDspSysInstallCb(h, tlp, "mfn", mfp, "fn", NULL );
  104. // score to score follower
  105. cmDspSysInstallCb(h, scp, "sel", sfp, "index", NULL );
  106. // MIDI file player to score-follower
  107. cmDspSysInstallCb(h, mfp, "status", sfp, "status", NULL );
  108. cmDspSysInstallCb(h, mfp, "d0", sfp, "d0", NULL );
  109. cmDspSysInstallCb(h, mfp, "d1", sfp, "d1", NULL );
  110. // Printer connections
  111. cmDspSysInstallCb(h, tlp, "afn", prp, "in", NULL );
  112. cmDspSysInstallCb(h, tlp, "mfn", prp, "in", NULL );
  113. cmDspSysInstallCb(h, tlp, "sel", prp, "in", NULL );
  114. //cmDspSysInstallCb(h, sfp, "out", prp, "in", NULL );
  115. return rc;
  116. }