Bläddra i källkod

cmDspPgm.c : Added _cmDspSysPgm_Goertzel.

master
kevin 10 år sedan
förälder
incheckning
ab1161d138
1 ändrade filer med 51 tillägg och 0 borttagningar
  1. 51
    0
      dsp/cmDspPgm.c

+ 51
- 0
dsp/cmDspPgm.c Visa fil

@@ -2450,9 +2450,60 @@ cmDspRC_t _cmDspSysPgm_AvailCh( cmDspSysH_t h, void** userPtrPtr )
2450 2450
 
2451 2451
 }
2452 2452
 
2453
+cmDspRC_t _cmDspSysPgm_Goertzel( cmDspSysH_t h, void** userPtrPtr )
2454
+{
2455
+  cmDspRC_t rc;
2456
+  const unsigned chCnt        = 3;
2457
+  double         dfltHz       = 19000;
2458
+  double fcHzV[]              = { 18000, dfltHz, 20000 };
2459
+  unsigned       sigGenMode   = 2; // sine
2460
+  double         sigGenGain   = 0.9;
2461
+
2462
+  cmDspInst_t*  ain  = cmDspSysAllocAudioIn(  h, 0, 1.0);
2463
+  cmDspInst_t* amtr  = cmDspSysAllocInst( h, "AMeter", NULL, 0 );
2464
+
2465
+  cmDspInst_t*  goer = cmDspSysAllocInst( h, "Goertzel",  NULL,   2, chCnt, fcHzV );
2466
+  cmDspInst_t** mtr  = cmDspSysAllocInstArray(h, chCnt,"Meter", "Mtr", NULL,  3, 0.0, 0.0, 1.0 );
2467
+  
2468
+  cmDspInst_t*  sg   = cmDspSysAllocInst( h, "SigGen",    NULL,   2, dfltHz, sigGenMode, sigGenGain, 0 );
2469
+  cmDspInst_t*  ao0  = cmDspSysAllocAudioOut( h, 0, 1.0);
2470
+  cmDspInst_t*  ao1  = cmDspSysAllocAudioOut( h, 0, 1.0);
2471
+
2472
+  cmDspInst_t*  hz   = cmDspSysAllocScalar(    h, "hz",0.0, 22000.0, 100.0, dfltHz );
2473
+  cmDspInst_t*  ogain= cmDspSysAllocScalar(    h, "ogain", 0.0, 3.0, 0.01, 1.0 );
2474
+  cmDspInst_t*  igain= cmDspSysAllocScalar(    h, "igain", 0.0, 3.0, 0.01, 1.0 );
2475
+
2476
+  cmDspInst_t* prnt = cmDspSysAllocInst( h,"Printer", NULL,     1, ">" );
2477
+
2478
+  // check for allocation errors
2479
+  if((rc = cmDspSysLastRC(h)) != kOkDspRC )
2480
+    goto errLabel;
2481
+
2482
+  cmDspSysConnectAudio(h,ain,"out", goer, "in" );
2483
+  cmDspSysConnectAudio(h,ain,"out", amtr, "in" );
2484
+
2485
+
2486
+  cmDspSysConnectAudio(h,sg,"out", ao0, "in" );
2487
+  cmDspSysConnectAudio(h,sg,"out", ao1, "in" );
2488
+
2489
+  cmDspSysInstallCb( h, hz,    "val", sg,  "hz", NULL);
2490
+  cmDspSysInstallCb( h, ogain, "val", ao0, "gain", NULL);
2491
+  cmDspSysInstallCb( h, ogain, "val", ao1, "gain", NULL);
2492
+  cmDspSysInstallCb( h, igain, "val", ain, "gain", NULL);
2493
+  cmDspSysInstallCb(h,goer,"out-0", mtr[0], "in",NULL);
2494
+  cmDspSysInstallCb(h,goer,"out-1", mtr[1], "in",NULL);
2495
+  cmDspSysInstallCb(h,goer,"out-2", mtr[2], "in",NULL);
2496
+  //cmDspSysInstallCb(h,goer,"out-1", prnt, "in",NULL);
2497
+  
2498
+ errLabel:
2499
+  return rc;
2500
+}
2501
+
2502
+
2453 2503
 _cmDspSysPgm_t _cmDspSysPgmArray[] = 
2454 2504
 {
2455 2505
   { "time_line",     _cmDspSysPgm_TimeLine,     NULL, NULL },
2506
+  { "goertzel",      _cmDspSysPgm_Goertzel,     NULL, NULL },
2456 2507
   { "kr_live",       _cmDspSysPgm_KrLive,       NULL, NULL },
2457 2508
   { "main",          _cmDspSysPgm_Main,         NULL, NULL },
2458 2509
   { "array",         _cmDspSysPgm_Array,        NULL, NULL },

Laddar…
Avbryt
Spara