瀏覽代碼

cmProc5.h/c : Added audion in/out cmVectArray's to cmPhat.

master
kevin 8 年之前
父節點
當前提交
512171ef9a
共有 2 個檔案被更改,包括 31 行新增17 行删除
  1. 27
    16
      cmProc5.c
  2. 4
    1
      cmProc5.h

+ 27
- 16
cmProc5.c 查看文件

@@ -381,6 +381,9 @@ cmPhat_t*   cmPhatAlloc(  cmCtx* ctx, cmPhat_t* ap, unsigned chN, unsigned hN, f
381 381
   // allocate the FFT object
382 382
   cmFftAllocSR(ctx,&p->fft,NULL,fhN,kToPolarFftFl);
383 383
   cmIFftAllocRS(ctx,&p->ifft,fhN/2 + 1 );
384
+
385
+  // allocate the vect array
386
+  p->ftVa = cmVectArrayAlloc(ctx, kSampleVaFl );
384 387
   
385 388
   if( chN != 0 )  
386 389
     if( cmPhatInit(p,chN,hN,alpha,mult,flags) != cmOkRC )
@@ -456,11 +459,9 @@ cmRC_t   cmPhatInit(  cmPhat_t* p, unsigned chN, unsigned hN, float alpha, unsig
456 459
   p->mhM = cmMemResizeZ(float,        p->mhM, p->binN * chN);
457 460
   cmPhatReset(p);
458 461
 
459
-  //if( cmIsFlag(p->flags,kDebugAtPhatFl)) 
460
-  //  cmVectArrayAlloc(ctx, &p->ftVa,  kSampleVaFl );
461
-  //else
462
-  //  p->ftVa = NULL;
463
-
462
+  if( cmIsFlag(p->flags,kDebugAtPhatFl)) 
463
+    cmVectArrayClear(p->ftVa);
464
+  
464 465
   return rc;
465 466
 
466 467
 }
@@ -659,7 +660,7 @@ cmRC_t cmPhatWrite( cmPhat_t* p, const char* dirStr )
659 660
   {
660 661
     const char* path = NULL;
661 662
 
662
-    if( p->ftVa != NULL )
663
+    if( cmVectArrayCount(p->ftVa) )
663 664
       if((rc = cmVectArrayWrite(p->ftVa, path = cmFsMakeFn(path,"cmPhatFT","va",dirStr,NULL) )) != cmOkRC )
664 665
         rc = cmCtxRtCondition(&p->obj,cmSubSysFailRC,"PHAT debug file write failed.");
665 666
     
@@ -693,7 +694,9 @@ cmReflectCalc_t* cmReflectCalcAlloc( cmCtx* ctx, cmReflectCalc_t* p, const cmGol
693 694
     goto errLabel;
694 695
   }
695 696
 
696
-  op->va = cmVectArrayAlloc(ctx,kSampleVaFl);
697
+  op->phVa  = cmVectArrayAlloc(ctx,kSampleVaFl);
698
+  op->xVa   = cmVectArrayAlloc(ctx,kSampleVaFl);
699
+  op->yVa   = cmVectArrayAlloc(ctx,kSampleVaFl);
697 700
 
698 701
   // allocate 'this'
699 702
   if( gsa != NULL )  
@@ -723,7 +726,9 @@ cmRC_t cmReflectCalcFree( cmReflectCalc_t** pp )
723 726
   if((rc = cmReflectCalcFinal(p)) != cmOkRC )
724 727
     return rc;
725 728
 
726
-  cmVectArrayFree(&p->va);
729
+  cmVectArrayFree(&p->phVa);
730
+  cmVectArrayFree(&p->xVa);
731
+  cmVectArrayFree(&p->yVa);
727 732
   cmGoldSigFree(&p->gs); 
728 733
   cmPhatFree(&p->phat);
729 734
   
@@ -803,14 +808,17 @@ cmRC_t cmReflectCalcExec( cmReflectCalc_t* p, const cmSample_t* xV, cmSample_t*
803 808
       // execute the correlation
804 809
       cmPhatChExec(p->phat,0,0,0);
805 810
 
806
-      // p->phat->xV now holds the correlation result
811
+      // p->phat->xV[fhN] now holds the correlation result
807 812
       
808
-      if( p->va != NULL )
809
-        cmVectArrayAppendS(p->va,p->phat->xV,p->phat->fhN );
813
+      if( p->phVa != NULL )
814
+        cmVectArrayAppendS(p->phVa,p->phat->xV,p->phat->fhN );
810 815
     }
811 816
     
812 817
   }
813 818
 
819
+  cmVectArrayAppendS(p->xVa,xV,xyN);
820
+  cmVectArrayAppendS(p->yVa,yV,xyN);
821
+
814 822
   return cmOkRC;
815 823
   
816 824
 }
@@ -819,14 +827,17 @@ cmRC_t cmReflectCalcWrite( cmReflectCalc_t* p, const char* dirStr )
819 827
 {
820 828
   cmRC_t rc = cmOkRC;
821 829
   
822
-  if( p->va != NULL) 
830
+  if( p->phVa != NULL) 
823 831
   {
824
-    const char* path = NULL;
832
+    //const char* path = NULL;
825 833
 
826
-    if((rc = cmVectArrayWrite(p->va, path = cmFsMakeFn(path,"reflect_calc","va",dirStr,NULL) )) != cmOkRC )
827
-        rc = cmCtxRtCondition(&p->obj,cmSubSysFailRC,"Reflect calc file write failed.");
834
+    cmVectArrayWriteDirFn(p->xVa, dirStr, "reflect_calc_x.va" );
835
+    cmVectArrayWriteDirFn(p->yVa, dirStr, "reflect_calc_y.va" );
836
+    cmVectArrayWriteDirFn(p->phVa,dirStr, "reflect_calc_ph.va");
828 837
     
829
-    cmFsFreeFn(path);
838
+    //if((rc = cmVectArrayWrite(p->phVa, path = cmFsMakeFn(path,"reflect_calc","va",dirStr,NULL) )) != cmOkRC )
839
+    //    rc = cmCtxRtCondition(&p->obj,cmSubSysFailRC,"Reflect calc file write failed.");    
840
+    //cmFsFreeFn(path);
830 841
   }
831 842
   
832 843
   return rc;

+ 4
- 1
cmProc5.h 查看文件

@@ -204,7 +204,10 @@ extern "C" {
204 204
     unsigned         xi;  // index into gs->ch[0].mdV[] of the next sample to output
205 205
     bool             zeroFl;
206 206
     cmPhat_t*        phat;
207
-    cmVectArray_t*   va;
207
+    
208
+    cmVectArray_t*   phVa;
209
+    cmVectArray_t*   xVa;
210
+    cmVectArray_t*   yVa;
208 211
   } cmReflectCalc_t;
209 212
 
210 213
   

Loading…
取消
儲存