Browse Source

cmDspPgmKrChain.c : Added the cmKr2 based version of the transform chain.

master
kevin larke 7 years ago
parent
commit
79c4326782
1 changed files with 186 additions and 1 deletions
  1. 186
    1
      dsp/cmDspPgmKrChain.c

+ 186
- 1
dsp/cmDspPgmKrChain.c View File

@@ -36,6 +36,9 @@
36 36
 
37 37
 #include "cmDspPgmKrChain.h"
38 38
 
39
+#undef KR2
40
+
41
+
39 42
 cmDspRC_t krLoadRsrc(cmDspSysH_t h, cmErr_t* err, krRsrc_t* r)
40 43
 {
41 44
   cmDspRC_t rc;
@@ -71,7 +74,7 @@ const cmChar_t* _mlbl(const cmChar_t* prefix, unsigned ch )
71 74
 #define mlbl(a)  _mlbl(a,mch)
72 75
 #define lbl(a) cmDspSysPrintLabel(a,ach)
73 76
 
74
-
77
+#ifndef KR2
75 78
 void _cmDspSys_TlXformChain( cmDspSysH_t h, cmDspTlXform_t* c,  unsigned preGrpSymId, unsigned cmpPreGrpSymId, cmDspInst_t* modp, unsigned ach, unsigned mch )
76 79
 {
77 80
   unsigned        measRtrChCnt = 6; // note: router channel 6 is not connected
@@ -357,4 +360,186 @@ void _cmDspSys_TlXformChain( cmDspSysH_t h, cmDspTlXform_t* c,  unsigned preGrpS
357 360
   c->cmp   = cmp; 
358 361
 
359 362
 }
363
+#endif
364
+
365
+//=======================================================================================================================
366
+//=======================================================================================================================
367
+//  KR2 Modeless Transform based on cmDspKr2 and cmSpecDist2
368
+//=======================================================================================================================
369
+//=======================================================================================================================
370
+
371
+#ifdef KR2
372
+void _cmDspSys_TlXformChain( cmDspSysH_t h, cmDspTlXform_t* c,  unsigned preGrpSymId, unsigned cmpPreGrpSymId, cmDspInst_t* modp, unsigned ach, unsigned mch )
373
+{
374
+  unsigned        measRtrChCnt = 6; // note: router channel 6 is not connected
375
+    
376
+  int             krWndSmpCnt = 2048;
377
+  int             krHopFact   = 4;
378
+
379
+  unsigned        xfadeChCnt  = 2;
380
+  double          xfadeMs     = 50;
381
+  bool            xfadeInitFl = true;
382
+  double          mixGain     = 1.0;
383
+
384
+  bool            cmpBypassFl  = false;
385
+  double          cmpInGain    = 3.0;
386
+  double          cmpThreshDb  = -40.0;
387
+  double          cmpRatio_num = 5.0;
388
+  double          cmpAtkMs     = 20.0;
389
+  double          cmpRlsMs     = 100.0;
390
+  double          cmpMakeup    = 1.0;
391
+  double          cmpWndMaxMs  = 1000.0;
392
+  double          cmpWndMs     = 200.0;
393
+
394
+  cmDspInst_t* achan = cmDspSysAllocInst(h, "AvailCh",     NULL, 1, xfadeChCnt );
395
+
396
+ 
397
+  // Parameter-> kr routers (routers used to cross-fade between the two kr units)
398
+  unsigned paramRtChCnt = 2;
399
+  cmDspInst_t* wnd_rt   = cmDspSysAllocInst(h, "Router",      NULL,  2,  paramRtChCnt, paramRtChCnt-1 );
400
+  cmDspInst_t* hop_rt   = cmDspSysAllocInst(h, "Router",      NULL,  2,  paramRtChCnt, paramRtChCnt-1 );
401
+  cmDspInst_t* ceil_rt  = cmDspSysAllocInst(h, "Router",      NULL,  2,  paramRtChCnt, paramRtChCnt-1 );
402
+  cmDspInst_t* expo_rt  = cmDspSysAllocInst(h, "Router",      NULL,  2,  paramRtChCnt, paramRtChCnt-1 );
403
+  cmDspInst_t* mix_rt   = cmDspSysAllocInst(h, "Router",      NULL,  2,  paramRtChCnt, paramRtChCnt-1 );
404
+  cmDspInst_t* thr_rt   = cmDspSysAllocInst(h, "Router",      NULL,  2,  paramRtChCnt, paramRtChCnt-1 );
405
+  cmDspInst_t* upr_rt   = cmDspSysAllocInst(h, "Router",      NULL,  2,  paramRtChCnt, paramRtChCnt-1 );
406
+  cmDspInst_t* lwr_rt   = cmDspSysAllocInst(h, "Router",      NULL,  2,  paramRtChCnt, paramRtChCnt-1 );
407
+  cmDspInst_t* wet_rt   = cmDspSysAllocInst(h, "Router",      NULL,  2,  paramRtChCnt, paramRtChCnt-1 );
408
+
409
+  // Audio processors
410
+  cmDspInst_t* kr0  = cmDspSysAllocInst(h, "Kr2",        NULL,   2, krWndSmpCnt, krHopFact );
411
+  cmDspInst_t* kr1  = cmDspSysAllocInst(h, "Kr2",        NULL,   2, krWndSmpCnt, krHopFact );
412
+  cmDspInst_t* xfad = cmDspSysAllocInst(h, "Xfader",     NULL,   3, xfadeChCnt,  xfadeMs, xfadeInitFl ); 
413
+  cmDspInst_t* mix  = cmDspSysAllocInst(h, "AMix",       NULL,   3, xfadeChCnt,  mixGain, mixGain );
414
+  cmDspInst_t* cmp  = cmDspSysAllocInst(h, "Compressor", NULL,   8, cmpBypassFl, cmpThreshDb, cmpRatio_num, cmpAtkMs, cmpRlsMs, cmpMakeup, cmpWndMs, cmpWndMaxMs ); 
415
+
416
+  // Internal audio connections
417
+  cmDspSysConnectAudio(h, kr0,  "out",   xfad, "in-0");
418
+  cmDspSysConnectAudio(h, kr1,  "out",   xfad, "in-1");
419
+  cmDspSysConnectAudio(h, xfad, "out-0", mix,  "in-0");
420
+  cmDspSysConnectAudio(h, xfad, "out-1", mix,  "in-1");
421
+  cmDspSysConnectAudio(h, mix,  "out",   cmp,  "in" );
422
+
423
+  // active channel <-> cross-fade connections
424
+  cmDspSysInstallCb(h, achan,  "reset",   xfad, "reset", NULL);
425
+  cmDspSysInstallCb(h, achan,  "gate-0",  xfad, "gate-0", NULL );
426
+  cmDspSysInstallCb(h, achan,  "gate-1",  xfad, "gate-1", NULL );
427
+  cmDspSysInstallCb(h, xfad,   "state-0", achan, "dis-0",  NULL );
428
+  cmDspSysInstallCb(h, xfad,   "state-1", achan, "dis-1",  NULL );
429
+
430
+  
431
+  // Parameter number controls 
432
+  cmDspInst_t* wnd_ctl = cmDspSysAllocMsgListP(h,preGrpSymId,NULL, lbl("WndSmpCnt"), NULL, "wndSmpCnt", 2);
433
+  cmDspInst_t* hop_ctl = cmDspSysAllocMsgListP(h,preGrpSymId,NULL, lbl("HopFact"),   NULL, "hopFact",   2);
434
+  cmDspInst_t* ceil_ctl= cmDspSysAllocScalarP( h,preGrpSymId,NULL, lbl("Ceiling"),     0.0, 100.0, 0.1,  30.0 );
435
+  cmDspInst_t* expo_ctl= cmDspSysAllocScalarP( h,preGrpSymId,NULL, lbl("Expo"),      -10.0,  10.0, 0.01,  2.0 );
436
+  cmDspInst_t* mix_ctl = cmDspSysAllocScalarP( h,preGrpSymId,NULL, lbl("Mix"),         0.0,   1.0, 0.01,  0.0 );
437
+  cmDspInst_t* thr_ctl = cmDspSysAllocScalarP( h,preGrpSymId,NULL, lbl("Threshold"),   0.0, 100.0, 0.1,  60.0 );
438
+  cmDspInst_t* upr_ctl = cmDspSysAllocScalarP( h,preGrpSymId,NULL, lbl("Upr slope"), -10.0,  10.0, 0.01,  0.0 ); 
439
+  cmDspInst_t* lwr_ctl = cmDspSysAllocScalarP( h,preGrpSymId,NULL, lbl("Lwr slope"), -10.0,  10.0, 0.01,  2.0 );
440
+  cmDspInst_t* wet_ctl = cmDspSysAllocScalarP( h,preGrpSymId,NULL, lbl("Wet Dry"),     0.0,   1.0, 0.001, 1.0 );
441
+
442
+  cmDspSysInstallCb(h, wnd_ctl, "out",         wnd_rt, "f-in",    NULL );
443
+  cmDspSysInstallCb(h, achan,   "ch",          wnd_rt, "sel",     NULL );   // ach->rt sel
444
+  cmDspSysInstallCb(h, wnd_rt,  "f-out-0",     kr0,    "wndn",    NULL );   // wndn->kr
445
+  cmDspSysInstallCb(h, wnd_rt,  "f-out-1",     kr1,    "wndn",    NULL );   // wndn->kr
446
+
447
+  cmDspSysInstallCb(h, hop_ctl, "out",         hop_rt, "f-in",    NULL );
448
+  cmDspSysInstallCb(h, achan,   "ch",          hop_rt, "sel",     NULL );   // ach->rt sel
449
+  cmDspSysInstallCb(h, hop_rt,  "f-out-0",     kr0,    "hopf",    NULL );   // hopf->kr
450
+  cmDspSysInstallCb(h, hop_rt,  "f-out-1",     kr1,    "hopf",    NULL );   // hopf->kr
451
+
452
+  cmDspSysInstallCb(h, ceil_ctl,     "val",     ceil_rt, "f-in",  NULL );
453
+  cmDspSysInstallCb(h, achan,        "ch",      ceil_rt, "sel",   NULL );   // ach->rt sel
454
+  cmDspSysInstallCb(h, ceil_rt,      "f-out-0", kr0,     "ceil",  NULL );   // ceil->kr
455
+  cmDspSysInstallCb(h, ceil_rt,      "f-out-1", kr1,     "ceil",  NULL );   // ceil->kr
456
+
457
+  cmDspSysInstallCb(h, expo_ctl,     "val",     expo_rt, "f-in",  NULL );
458
+  cmDspSysInstallCb(h, achan,        "ch",      expo_rt, "sel",   NULL );   // ach->rt sel
459
+  cmDspSysInstallCb(h, expo_rt,      "f-out-0", kr0,     "expo",  NULL );   // expo->kr
460
+  cmDspSysInstallCb(h, expo_rt,      "f-out-1", kr1,     "expo",  NULL );   // expo->kr
461
+
462
+  cmDspSysInstallCb(h, mix_ctl,     "val",     mix_rt,  "f-in",   NULL );
463
+  cmDspSysInstallCb(h, achan,       "ch",      mix_rt,  "sel",    NULL );   // ach->rt sel
464
+  cmDspSysInstallCb(h, mix_rt,      "f-out-0", kr0,     "mix",    NULL );   // mix->kr
465
+  cmDspSysInstallCb(h, mix_rt,      "f-out-1", kr1,     "mix",    NULL );   // mix->kr
466
+  
467
+  
468
+  cmDspSysInstallCb(h, thr_ctl,     "val",     thr_rt, "f-in",    NULL );
469
+  cmDspSysInstallCb(h, achan,       "ch",      thr_rt, "sel",     NULL );   // ach->rt sel
470
+  cmDspSysInstallCb(h, thr_rt,      "f-out-0", kr0,    "thrh",    NULL );   // thr->kr
471
+  cmDspSysInstallCb(h, thr_rt,      "f-out-1", kr1,    "thrh",    NULL );   // thr->kr
472
+
473
+  cmDspSysInstallCb(h, upr_ctl,     "val",     upr_rt, "f-in",    NULL );
474
+  cmDspSysInstallCb(h, achan,       "ch",      upr_rt, "sel",     NULL );   // ach->rt sel
475
+  cmDspSysInstallCb(h, upr_rt,      "f-out-0", kr0,    "uprs",    NULL );   // upr->kr
476
+  cmDspSysInstallCb(h, upr_rt,      "f-out-1", kr1,    "uprs",    NULL );   // upr->kr
477
+
478
+  cmDspSysInstallCb(h, lwr_ctl,     "val",     lwr_rt, "f-in",    NULL );
479
+  cmDspSysInstallCb(h, achan,       "ch",      lwr_rt, "sel",     NULL );   // ach->rt sel
480
+  cmDspSysInstallCb(h, lwr_rt,      "f-out-0", kr0,    "lwrs",    NULL );   // lwr->kr
481
+  cmDspSysInstallCb(h, lwr_rt,      "f-out-1", kr1,    "lwrs",    NULL );   // lwr->kr
482
+
483
+  
484
+  cmDspSysInstallCb(h, wet_ctl,     "val",     wet_rt, "f-in",    NULL );
485
+  cmDspSysInstallCb(h, achan,       "ch",      wet_rt, "sel",     NULL );   // ach->rt sel
486
+  cmDspSysInstallCb(h, wet_rt,      "f-out-0", kr0,    "wet",     NULL );   // wet->kr
487
+  cmDspSysInstallCb(h, wet_rt,      "f-out-1", kr1,    "wet",     NULL );   // wet->kr
488
+  
489
+
490
+  cmDspSysNewColumn(h,0);
491
+  cmDspInst_t* cmp_byp   = cmDspSysAllocCheckP(  h, cmpPreGrpSymId, NULL, lbl("Bypass"), 1.0 );
492
+  cmDspInst_t* cmp_igain = cmDspSysAllocScalarP( h, cmpPreGrpSymId, NULL, lbl("In Gain"),  0.0,   10.0, 0.1, cmpInGain);
493
+  cmDspInst_t* cmp_thr   = cmDspSysAllocScalarP( h, cmpPreGrpSymId, NULL, lbl("ThreshDb"), -100.0, 0.0, 0.1, cmpThreshDb);
494
+  cmDspInst_t* cmp_rat   = cmDspSysAllocScalarP( h, cmpPreGrpSymId, NULL, lbl("Ratio"),    0.1, 100, 0.1, cmpRatio_num);
495
+  cmDspInst_t* cmp_atk   = cmDspSysAllocScalarP( h, cmpPreGrpSymId, NULL, lbl("Atk Ms"),   0.0, 1000.0, 0.1, cmpAtkMs);
496
+  cmDspInst_t* cmp_rls   = cmDspSysAllocScalarP( h, cmpPreGrpSymId, NULL, lbl("Rls Ms"),   0.0, 1000.0, 0.1, cmpRlsMs);
497
+  cmDspInst_t* cmp_mkup  = cmDspSysAllocScalarP( h, cmpPreGrpSymId, NULL, lbl("Makeup"),   0.0, 10.0,   0.01, cmpMakeup);
498
+  cmDspInst_t* cmp_wnd   = cmDspSysAllocScalarP( h, cmpPreGrpSymId, NULL, lbl("Wnd Ms"),   1.0, cmpWndMaxMs, 1.0, cmpWndMs );
499
+  cmDspInst_t* cmp_mtr   = cmDspSysAllocInst(h,"Meter",lbl("Env"), 3, 0.0, 0.0, 1.0);
500
+
501
+  cmDspSysInstallCb(h, cmp_byp,  "out", cmp, "bypass", NULL );
502
+  cmDspSysInstallCb(h, cmp_igain,"val", cmp, "igain", NULL );
503
+  cmDspSysInstallCb(h, cmp_thr,  "val", cmp, "thr", NULL );
504
+  cmDspSysInstallCb(h, cmp_rat,  "val", cmp, "ratio", NULL );
505
+  cmDspSysInstallCb(h, cmp_atk,  "val", cmp, "atk", NULL );
506
+  cmDspSysInstallCb(h, cmp_rls,  "val", cmp, "rls", NULL );
507
+  cmDspSysInstallCb(h, cmp_mkup, "val", cmp, "ogain", NULL );
508
+  cmDspSysInstallCb(h, cmp_wnd,  "val", cmp, "wnd", NULL );
509
+  cmDspSysInstallCb(h, cmp,      "env", cmp_mtr, "in", NULL );
510
+
511
+  cmDspSysInstallCb(h, modp, mlbl("cbyp"),    cmp_byp,  "in", NULL );
512
+  cmDspSysInstallCb(h, modp, mlbl("cigain"),  cmp_igain,"val", NULL );
513
+  cmDspSysInstallCb(h, modp, mlbl("cthrsh"),  cmp_thr,  "val", NULL );
514
+  cmDspSysInstallCb(h, modp, mlbl("cratio"),  cmp_rat,  "val", NULL );
515
+  cmDspSysInstallCb(h, modp, mlbl("catkms"),  cmp_atk,  "val", NULL );
516
+  cmDspSysInstallCb(h, modp, mlbl("crlsms"),  cmp_rls,  "val", NULL );
517
+  cmDspSysInstallCb(h, modp, mlbl("cmakeup"), cmp_mkup, "val", NULL );
518
+  cmDspSysInstallCb(h, modp, mlbl("cwndms"),  cmp_wnd,  "val", NULL );
519
+
520
+  // 
521
+  cmDspInst_t* xfadMs = cmDspSysAllocInst(h,"Scalar", lbl("Xfade Ms"),     5, kNumberDuiId, 0.0,   1000.0,0.01, 50.0 );  
522
+  cmDspSysInstallCb(h, xfadMs, "val", xfad, "ms", NULL );
523
+  cmDspSysInstallCb(h, modp, mlbl("xfad"), xfadMs,  "val", NULL);
524
+
525
+  cmDspSysInstallCb(h, modp, mlbl("win"),  wnd_ctl, "sel",  NULL );
526
+  cmDspSysInstallCb(h, modp, mlbl("hop"),  hop_ctl, "sel",  NULL );
527
+  cmDspSysInstallCb(h, modp, mlbl("ceil"), ceil_ctl, "val", NULL );
528
+  cmDspSysInstallCb(h, modp, mlbl("expo"), expo_ctl, "val", NULL );
529
+  cmDspSysInstallCb(h, modp, mlbl("mix"),  mix_ctl,  "val", NULL );
530
+  cmDspSysInstallCb(h, modp, mlbl("thr"),  thr_ctl, "val",  NULL );
531
+  cmDspSysInstallCb(h, modp, mlbl("upr"),  upr_ctl, "val",  NULL );
532
+  cmDspSysInstallCb(h, modp, mlbl("lwr"),  lwr_ctl, "val",  NULL );
533
+  cmDspSysInstallCb(h, modp, mlbl("wet"),  wet_ctl, "val",  NULL );
534
+
535
+  cmDspSysInstallCb(h, modp, mlbl("sw"),   achan,       "trig", NULL ); // See also: amp.sfloc->achan.trig
536
+
537
+  
538
+  c->achan = achan; 
539
+  c->kr0   = kr0; 
540
+  c->kr1   = kr1;
541
+  c->cmp   = cmp; 
542
+
543
+}
360 544
 
545
+#endif

Loading…
Cancel
Save