Przeglądaj źródła

cmDspPgm.c : Added _cmDspSysPgm_MultiOut() and _cmDspSysPgm_MultiIn().

master
kpl_harpo 10 lat temu
rodzic
commit
d0c6741b65
1 zmienionych plików z 102 dodań i 0 usunięć
  1. 102
    0
      dsp/cmDspPgm.c

+ 102
- 0
dsp/cmDspPgm.c Wyświetl plik

@@ -291,6 +291,98 @@ cmDspRC_t _cmDspSysPgm_PlayFile( cmDspSysH_t h, void** userPtrPtr )
291 291
 }
292 292
 
293 293
 
294
+cmDspRC_t _cmDspSysPgm_MultiOut( cmDspSysH_t h, void** userPtrPtr )
295
+{
296
+  cmDspRC_t    rc           = kOkDspRC;
297
+  double       frqHz        = 440.0;
298
+  unsigned     chCnt        = 8;
299
+  unsigned     oneOfN_chCnt = 2;
300
+  double       offs         = 34612504;
301
+  cmDspInst_t* aout[chCnt];
302
+  unsigned     i;
303
+
304
+  const char*     fn0   = "media/audio/20110723-Kriesberg/Audio Files/Piano 3_23.wav";
305
+  const cmChar_t* fn    = cmFsMakeFn(cmFsUserDir(),fn0,NULL,NULL );
306
+
307
+  cmDspInst_t* f_phs = cmDspSysAllocInst(h,"Phasor",   NULL,  0 );
308
+  cmDspInst_t* f_wt  = cmDspSysAllocInst(h,"WaveTable",NULL,  2, ((int)cmDspSysSampleRate(h)), 1 );
309
+  cmDspInst_t* f_mtr = cmDspSysAllocInst(h,"AMeter",    "File Out",  0);
310
+
311
+  cmDspInst_t* f_rew = cmDspSysAllocInst(h,"Button", "Rewind",  2, kButtonDuiId, 1.0 );
312
+  cmDspInst_t* f_pts = cmDspSysAllocInst(h,"PortToSym", NULL, 1, "on" );
313
+  cmDspInst_t* f_beg = cmDspSysAllocInst(h,"Scalar", "File Begin",  5, kNumberDuiId, 0.0,  cmDspSysSampleRate(h)*6000.0, 1.0,  offs);
314
+  cmDspInst_t* f_nam = cmDspSysAllocInst(h,"Fname",    NULL,  3, false,"Audio Files (*.wav,*.aiff,*.aif)\tAudio Files (*.{wav,aiff,aif})",fn);
315
+
316
+
317
+  cmDspInst_t* s_phs = cmDspSysAllocInst(h,"Phasor",    NULL,   2, cmDspSysSampleRate(h), frqHz );
318
+  cmDspInst_t* s_wt  = cmDspSysAllocInst(h,"WaveTable", NULL,   2, ((int)cmDspSysSampleRate(h)), 4);
319
+  cmDspInst_t* s_mtr = cmDspSysAllocInst(h,"AMeter",    "Tone Out",  0);
320
+
321
+  cmDspInst_t* swtch = cmDspSysAllocInst(h,"1ofN",      NULL,   2, oneOfN_chCnt, 0 );
322
+
323
+  for(i=0; i<chCnt; ++i)
324
+    aout[i] = cmDspSysAllocInst(h,"AudioOut",NULL,   1, i );
325
+
326
+  cmDspInst_t*  chck = cmDspSysAllocInst(h,"Checkbox", "Source", 5, "Tone","file","tone", 0.0, 1.0);
327
+  cmDspInst_t** vol  = cmDspSysAllocInstArray(h,chCnt,"Scalar", "Gain", NULL, 5, kNumberDuiId, 0.0,  10.0, 0.01,  0.0 );
328
+
329
+  // check for allocation errors
330
+  if((rc = cmDspSysLastRC(h)) != kOkDspRC )
331
+    goto errLabel;
332
+
333
+  cmDspSysConnectAudio(     h, s_phs, "out",  s_wt,  "phs" );          // sine phasor -> wave table
334
+  cmDspSysConnectAudio(     h, s_wt,  "out",  s_mtr, "in" );           // sine wave table -> meter
335
+  cmDspSysConnectAudio(     h, s_wt,  "out",  swtch, "a-in-1");
336
+
337
+  cmDspSysConnectAudio(     h, f_phs, "out", f_wt,  "phs" );          // file phasor -> wave table
338
+  cmDspSysConnectAudio(     h, f_wt, "out",  f_mtr, "in" );           // file wave table -> meter
339
+  cmDspSysConnectAudio(     h, f_wt, "out",  swtch, "a-in-0");
340
+
341
+  cmDspSysConnectAudio11N1( h, swtch, "a-out", aout, "in",   chCnt );
342
+  cmDspSysInstallCbN1N1(    h, vol,   "val",   aout, "gain", chCnt );
343
+
344
+  cmDspSysInstallCb( h, chck,  "out", swtch, "chidx", NULL );
345
+  cmDspSysInstallCb( h, f_nam, "out", f_wt,  "fn",    NULL );    
346
+  cmDspSysInstallCb( h, f_beg, "val", f_wt,  "beg",   NULL ); 
347
+  cmDspSysInstallCb( h, f_rew, "out", f_pts, "on",    NULL );
348
+  cmDspSysInstallCb( h, f_pts, "on",  f_beg, "send",  NULL );
349
+  cmDspSysInstallCb( h, f_pts, "on",  f_nam, "send",  NULL );
350
+  cmDspSysInstallCb( h, f_pts, "on",  f_wt,  "cmd",   NULL );
351
+
352
+ errLabel:
353
+  return rc;
354
+}
355
+
356
+cmDspRC_t _cmDspSysPgm_MultiIn(cmDspSysH_t h, void** userPtrPtr)
357
+{
358
+  int          chCnt = 8;
359
+  cmDspInst_t* a[chCnt];
360
+  int i;
361
+  for(i=0; i<chCnt; ++i)
362
+    a[i]   = cmDspSysAllocInst( h, "AudioIn", NULL,  1, i );
363
+  
364
+  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 );   
365
+  cmDspInst_t* afp   = cmDspSysAllocInst( h, "AudioFileOut", NULL, 2,"/home/kevin/temp/at/test_in.aif",1);
366
+  cmDspInst_t* aop   = cmDspSysAllocInst( h, "AudioOut",     NULL, 1, 0 );
367
+
368
+  // AudioFileOut needs an open message to create the output file
369
+  cmDspInst_t* btn   = cmDspSysAllocInst( h, "Button",      "open",  2, kButtonDuiId, 1.0 );
370
+  cmDspSysAssignInstAttrSymbolStr(h, btn, "_reset" );
371
+  cmDspInst_t* pts = cmDspSysAllocInst(h,"PortToSym", NULL, 1, "open" );
372
+
373
+
374
+  cmDspSysConnectAudioN11N(h, a,   "out", mxp, "in", chCnt );
375
+  cmDspSysConnectAudio(    h, mxp, "out", afp,  "in0" );
376
+  cmDspSysConnectAudio(    h, mxp, "out", aop,  "in" );
377
+
378
+  cmDspSysInstallCb( h, btn, "sym",  pts, "open", NULL );
379
+  cmDspSysInstallCb( h, pts, "open", afp, "sel",  NULL );
380
+
381
+  
382
+  return kOkDspRC;
383
+}
384
+
385
+
294 386
 cmDspRC_t _cmDspSysPgm_GateDetect( cmDspSysH_t h, void** userPtrPtr )
295 387
 {
296 388
   bool            useBuiltInFl = true;
@@ -345,6 +437,11 @@ cmDspRC_t _cmDspSysPgm_Record(cmDspSysH_t h, void** userPtrPtr)
345 437
   cmDspInst_t* txp   = cmDspSysAllocInst( h, "TextFile",     NULL,       2, 1, "/home/kevin/temp/gate_detect.txt");
346 438
   cmDspInst_t* chp   = cmDspSysAllocInst( h, "Scalar",       "Channel",  5, kNumberDuiId, 0.0,  7.0, 1.0,  0.0);
347 439
   
440
+  // AudioFileOut needs an open message to create the output file
441
+  cmDspInst_t* btn   = cmDspSysAllocInst( h, "Button",      "open",  2, kButtonDuiId, 1.0 );
442
+  cmDspSysAssignInstAttrSymbolStr(h, btn, "_reset" );
443
+  cmDspInst_t* pts = cmDspSysAllocInst(h,"PortToSym", NULL, 1, "open" );
444
+
348 445
   for(i=0; i<chCnt; ++i)
349 446
   {
350 447
     cmChar_t lbl[15];
@@ -357,6 +454,9 @@ cmDspRC_t _cmDspSysPgm_Record(cmDspSysH_t h, void** userPtrPtr)
357 454
 
358 455
   cmDspSysInstallCb(h, chp, "out", txp, "in-0", NULL);
359 456
   
457
+  cmDspSysInstallCb( h, btn, "sym",  pts, "open", NULL );
458
+  cmDspSysInstallCb( h, pts, "open", afp, "sel",  NULL );
459
+
360 460
   return kOkDspRC;
361 461
 }
362 462
 
@@ -2565,6 +2665,8 @@ cmDspRC_t _cmDspSysPgm_Goertzel( cmDspSysH_t h, void** userPtrPtr )
2565 2665
 _cmDspSysPgm_t _cmDspSysPgmArray[] = 
2566 2666
 {
2567 2667
   { "time_line",     _cmDspSysPgm_TimeLine,     NULL, NULL },
2668
+  { "multi-out",     _cmDspSysPgm_MultiOut,     NULL, NULL },
2669
+  { "multi-in",      _cmDspSysPgm_MultiIn,     NULL, NULL },
2568 2670
   { "goertzel",      _cmDspSysPgm_Goertzel,     NULL, NULL },
2569 2671
   { "kr_live",       _cmDspSysPgm_KrLive,       NULL, NULL },
2570 2672
   { "main",          _cmDspSysPgm_Main,         NULL, NULL },

Ładowanie…
Anuluj
Zapisz