Преглед изворни кода

cmDspPgm.c : Added cmDspSysPgm_TwoD and cmDspSysPgm_BinEnc.

master
Kevin Larke пре 9 година
родитељ
комит
acd262b3b9
1 измењених фајлова са 107 додато и 14 уклоњено
  1. 107
    14
      dsp/cmDspPgm.c

+ 107
- 14
dsp/cmDspPgm.c Прегледај датотеку

@@ -347,7 +347,8 @@ cmDspRC_t _cmDspSysPgm_PlaySine( cmDspSysH_t h, void** userPtrPtr )
347 347
 cmDspRC_t _cmDspSysPgm_PlayFile( cmDspSysH_t h, void** userPtrPtr )
348 348
 {
349 349
   bool            useBuiltInFl = true;
350
-  const char*     fn0          = "media/audio/20110723-Kriesberg/Audio Files/Piano 3_01.wav";
350
+  //const char*     fn0          = "media/audio/20110723-Kriesberg/Audio Files/Piano 3_01.wav";
351
+  const char*     fn0 = "media/audio/sourcetone/Ella & Louis - Under A Blanket Of Blue";
351 352
   //int             beg          = 6900826;
352 353
   //int             end          = 13512262;
353 354
   const cmChar_t* fn           = cmFsMakeFn(cmFsUserDir(),fn0,NULL,NULL );
@@ -2560,29 +2561,29 @@ cmDspRC_t _cmDspSysPgm_Line( cmDspSysH_t h, void** userPtrPtr )
2560 2561
 {
2561 2562
   cmDspRC_t rc = kOkDspRC;
2562 2563
 
2563
-  cmDspInst_t* beg  = cmDspSysAllocScalar( h, "beg", -10.0, 10.0, 1.0, 0.0 );
2564
-  cmDspInst_t* end  = cmDspSysAllocScalar( h, "end", -10.0, 10.0, 1.0, 1.0 );
2565
-  cmDspInst_t* dur  = cmDspSysAllocScalar( h, "dur", 0.0, 10000.0, 1.0, 0.0 );  
2566
-  cmDspInst_t* reset = cmDspSysAllocButton(h, "reset", 0.0 );
2567
-
2568
-  cmDspInst_t* line   = cmDspSysAllocInst( h, "Line", NULL, 3, 0.0, 10.0, 1000.0 );
2564
+  cmDspInst_t* beg   = cmDspSysAllocScalar( h, "beg", -10.0, 10.0, 1.0, 0.0 );
2565
+  cmDspInst_t* end   = cmDspSysAllocScalar( h, "end", -10.0, 10.0, 1.0, 1.0 );
2566
+  cmDspInst_t* dur   = cmDspSysAllocScalar( h, "dur", 0.0, 10000.0, 1.0, 0.0 );  
2567
+  cmDspInst_t* reset = cmDspSysAllocButton( h, "reset", 0.0 );
2568
+  cmDspInst_t* line  = cmDspSysAllocInst(   h, "Line", NULL, 3, 0.0, 10.0, 1000.0 );
2569 2569
 
2570
-  cmDspInst_t* mtr  = cmDspSysAllocInst( h, "Meter", NULL, 3, -10.0, 10.0, 0.0  );
2570
+  cmDspInst_t* mtr   = cmDspSysAllocInst( h, "Meter", NULL, 3, -10.0, 10.0, 0.0  );
2571 2571
 
2572
-  cmDspInst_t* pr1  = cmDspSysAllocInst( h, "Printer", NULL, 1, ">" );
2572
+  cmDspInst_t* pr1   = cmDspSysAllocInst( h, "Printer", NULL, 1, ">" );
2573 2573
 
2574 2574
   // check for allocation errors
2575 2575
   if((rc = cmDspSysLastRC(h)) != kOkDspRC )
2576 2576
     goto errLabel;
2577 2577
   
2578
-  cmDspSysInstallCb(   h, beg, "val", line, "beg",NULL);
2579
-  cmDspSysInstallCb(   h, end, "val", line, "end",NULL);
2580
-  cmDspSysInstallCb(   h, dur, "val", line, "dur",NULL);
2578
+  cmDspSysInstallCb(   h, beg, "val", line, "beg", NULL);
2579
+  cmDspSysInstallCb(   h, end, "val", line, "end", NULL);
2580
+  cmDspSysInstallCb(   h, dur, "val", line, "dur", NULL);
2581 2581
 
2582 2582
 
2583
-  cmDspSysInstallCb(   h, line,  "out", mtr, "in", NULL );
2583
+  cmDspSysInstallCb(   h, line,  "out", mtr,  "in",  NULL );
2584 2584
   cmDspSysInstallCb(   h, reset, "sym", line, "cmd", NULL );
2585
-  cmDspSysInstallCb(   h, line, "out", pr1, "in", NULL );
2585
+  cmDspSysInstallCb(   h, line,  "out", pr1,  "in",  NULL );
2586
+
2586 2587
  errLabel:
2587 2588
   return rc;
2588 2589
 }
@@ -2801,11 +2802,103 @@ cmDspRC_t _cmDspSysPgm_TakeSeqBldr( cmDspSysH_t h, void** userPtrPtr )
2801 2802
 }
2802 2803
 
2803 2804
 
2805
+cmDspRC_t _cmDspSysPgm_TwoD( cmDspSysH_t h, void** userPtrPtr )
2806
+{
2807
+  cmDspRC_t       rc         = kOkDspRC;
2808
+
2809
+  cmDspInst_t* twod = cmDspSysAllocInst(h,"twod", NULL, 0);
2810
+  cmDspInst_t* aprt  = cmDspSysAllocInst(h,"Printer",NULL, 1, "a: ");
2811
+  cmDspInst_t* rprt  = cmDspSysAllocInst(h,"Printer",NULL, 1, "r: ");
2812
+
2813
+  // check for allocation errors
2814
+  if((rc = cmDspSysLastRC(h)) != kOkDspRC )
2815
+    goto errLabel;
2816
+  
2817
+  cmDspSysInstallCb(h, twod, "angle",  aprt, "in", NULL );
2818
+  cmDspSysInstallCb(h, twod, "radius", rprt, "in", NULL );
2819
+
2820
+ errLabel:
2821
+  return rc;
2822
+}
2823
+
2824
+cmDspRC_t _cmDspSysPgm_BinEnc( cmDspSysH_t h, void** userPtrPtr )
2825
+{
2826
+  cmDspRC_t       rc         = kOkDspRC;
2827
+
2828
+  double durMs    = 10000.0;  
2829
+  double lineHz   = 0.2;
2830
+  double maxDurMs = 60000.0;
2831
+  double azimBeg  =     0.0;
2832
+  double azimEnd  =   360.0;
2833
+  const char* fn1 = "media/audio/sourcetone/Jazz/Ella & Louis - Under A Blanket Of Blue";
2834
+  const char* fn0 = "temp/comhear/drw/monty.wav";
2835
+  
2836
+  cmDspInst_t* twod = cmDspSysAllocInst( h, "twod",       NULL, 0);
2837
+  cmDspInst_t* php  = cmDspSysAllocInst( h, "Phasor",     NULL, 0 );
2838
+  cmDspInst_t* wtp  = cmDspSysAllocInst( h, "WaveTable",  NULL, 2, ((int)cmDspSysSampleRate(h)), 1 );
2839
+  cmDspInst_t* bep  = cmDspSysAllocInst( h, "BinauralEnc",NULL, 1, 0);
2840
+
2841
+  cmDspInst_t* ao0p = cmDspSysAllocInst( h, "AudioOut", NULL, 1, 0  );
2842
+  cmDspInst_t* ao1p = cmDspSysAllocInst( h, "AudioOut", NULL, 1, 1  );
2843
+
2804 2844
 
2845
+  cmDspSysNewPage(h,"Controls");  
2846
+
2847
+  const cmChar_t* fn    = cmFsMakeFn(cmFsUserDir(),fn0,NULL,NULL );
2848
+  cmDspInst_t*    fnp   = cmDspSysAllocInst(   h,"Fname", NULL,  3, false,"Audio Files (*.wav,*.aiff,*.aif)\tAudio Files (*.{wav,aiff,aif})",fn);
2849
+  cmDspInst_t*    beg   = cmDspSysAllocScalar( h, "beg", 0.0, azimEnd,  1.0, azimBeg );
2850
+  cmDspInst_t*    end   = cmDspSysAllocScalar( h, "end", 0.0, azimEnd,  1.0, azimEnd );
2851
+  cmDspInst_t*    dur   = cmDspSysAllocScalar( h, "dur", 0.0, maxDurMs, 1.0, durMs );  
2852
+  cmDspInst_t*    reset = cmDspSysAllocButton( h, "reset", 0.0 );
2853
+  cmDspInst_t*    azm   = cmDspSysAllocScalar( h, "azimuth", azimBeg, azimEnd, 1.0, 0.0 );
2854
+  cmDspInst_t*    angle = cmDspSysAllocScalar( h, "angle",   azimBeg, azimEnd, 1.0, 0.0 );
2855
+  cmDspInst_t*    mode  = cmDspSysAllocScalar( h, "mode", 0.0, 1.0, 1.0, 0.0 );
2856
+  cmDspInst_t*    gain  = cmDspSysAllocScalar( h, "gain", 0.0,10.0, 0.01, 1.0 );
2857
+
2858
+  cmDspInst_t* line  = cmDspSysAllocInst(   h, "Line", NULL, 3, azimBeg, azimEnd, durMs, lineHz );
2859
+  cmDspInst_t* prt   = cmDspSysAllocInst(   h, "Printer",  NULL, 1, ">" );
2860
+
2861
+  // check for allocation errors
2862
+  if((rc = cmDspSysLastRC(h)) != kOkDspRC )
2863
+    goto errLabel;
2864
+
2865
+  cmDspSysConnectAudio(h, php,  "out",  wtp,  "phs" );  // phasor -> wave table
2866
+  cmDspSysConnectAudio(h, wtp,  "out",  bep,  "in" );
2867
+  cmDspSysConnectAudio(h, bep,  "out0", ao0p, "in" );   // wave table -> audio out
2868
+  cmDspSysConnectAudio(h, bep,  "out1", ao1p, "in" );   // 
2869
+
2870
+  cmDspSysInstallCb(   h, fnp,  "out", wtp,  "fn", NULL);    
2871
+  
2872
+  cmDspSysInstallCb(   h, beg,  "val", line, "beg", NULL);
2873
+  cmDspSysInstallCb(   h, end,  "val", line, "end", NULL);
2874
+  cmDspSysInstallCb(   h, dur,  "val", line, "dur", NULL);
2875
+  cmDspSysInstallCb(   h, reset,"sym", line, "cmd", NULL );
2876
+
2877
+  cmDspSysInstallCb(   h, line, "out",   azm, "val",  NULL );
2878
+  cmDspSysInstallCb(   h, azm,  "val",   bep, "azim", NULL );
2879
+
2880
+  cmDspSysInstallCb(   h, twod, "angle", angle,"val", NULL );
2881
+  cmDspSysInstallCb(   h, angle,"val",   bep, "azim", NULL );
2882
+
2883
+  cmDspSysInstallCb(   h, mode, "val",   bep, "mode", NULL );
2884
+  
2885
+  cmDspSysInstallCb(   h, twod, "angle", prt, "in", NULL );
2886
+  cmDspSysInstallCb(   h, gain, "val",   ao0p, "gain", NULL );
2887
+  cmDspSysInstallCb(   h, gain, "val",   ao1p, "gain", NULL );
2888
+
2889
+  return kOkDspRC;
2890
+
2891
+
2892
+
2893
+ errLabel:
2894
+  return rc;
2895
+}
2805 2896
 
2806 2897
 
2807 2898
 _cmDspSysPgm_t _cmDspSysPgmArray[] = 
2808 2899
 {
2900
+  { "two-d",         _cmDspSysPgm_TwoD,         NULL, NULL },
2901
+  { "bin-enc",       _cmDspSysPgm_BinEnc,       NULL, NULL },
2809 2902
   { "tksb",          _cmDspSysPgm_Tksb,         NULL, NULL },
2810 2903
   { "time_line",     _cmDspSysPgm_TimeLine,     NULL, NULL },
2811 2904
   { "seq-bldr",      _cmDspSysPgm_TakeSeqBldr,  NULL, NULL },

Loading…
Откажи
Сачувај