Browse Source

cmProc5.h/c : Added cmReflectCalcWrite().

master
kevin 9 years ago
parent
commit
da34a3e4a5
2 changed files with 31 additions and 5 deletions
  1. 27
    1
      cmProc5.c
  2. 4
    4
      cmProc5.h

+ 27
- 1
cmProc5.c View File

@@ -694,6 +694,8 @@ cmRC_t cmReflectCalcFree( cmReflectCalc_t** pp )
694 694
 
695 695
   cmReflectCalc_t* p = *pp;
696 696
 
697
+  cmReflectCalcWrite(p,"/Users/kevin/temp/cmkc");
698
+  
697 699
   if((rc = cmReflectCalcFinal(p)) != cmOkRC )
698 700
     return rc;
699 701
 
@@ -755,9 +757,12 @@ cmRC_t cmReflectCalcFinal( cmReflectCalc_t* p )
755 757
   return cmOkRC;
756 758
 }
757 759
 
758
-cmRC_t cmReflectCalcExec( cmReflectCalc_t* p, const cmSample_t xV, cmSample_t* yV, unsigned xyN )
760
+cmRC_t cmReflectCalcExec( cmReflectCalc_t* p, const cmSample_t* xV, cmSample_t* yV, unsigned xyN )
759 761
 {
760 762
   unsigned i;
763
+
764
+  // feed audio into the PHAT's buffer
765
+  cmPhatExec(p->phat,xV,xyN);
761 766
   
762 767
   for(i=0; i<xyN; ++i,++p->xi)
763 768
   {
@@ -766,12 +771,16 @@ cmRC_t cmReflectCalcExec( cmReflectCalc_t* p, const cmSample_t xV, cmSample_t* y
766 771
     else
767 772
       yV[i] = 0;
768 773
 
774
+    // if the PHAT has a complete buffer
769 775
     if( p->xi == p->phat->fhN )
770 776
     {
771 777
       p->xi = 0;
772 778
 
779
+      // execute the correlation
773 780
       cmPhatChExec(p->phat,0,0,0);
774 781
 
782
+      // p->phat->xV now holds the correlation result
783
+      
775 784
       if( p->va != NULL )
776 785
         cmVectArrayAppendS(p->va,p->phat->xV,p->phat->fhN );
777 786
     }
@@ -781,3 +790,20 @@ cmRC_t cmReflectCalcExec( cmReflectCalc_t* p, const cmSample_t xV, cmSample_t* y
781 790
   return cmOkRC;
782 791
   
783 792
 }
793
+
794
+cmRC_t cmReflectCalcWrite( cmReflectCalc_t* p, const char* dirStr )
795
+{
796
+  cmRC_t rc = cmOkRC;
797
+  
798
+  if( p->va != NULL) 
799
+  {
800
+    const char* path = NULL;
801
+
802
+    if((rc = cmVectArrayWrite(p->va, path = cmFsMakeFn(path,"reflect_calc","va",dirStr,NULL) )) != cmOkRC )
803
+        rc = cmCtxRtCondition(&p->obj,cmSubSysFailRC,"Reflect calc file write failed.");
804
+    
805
+    cmFsFreeFn(path);
806
+  }
807
+  
808
+  return rc;
809
+}

+ 4
- 4
cmProc5.h View File

@@ -208,11 +208,11 @@ extern "C" {
208 208
 
209 209
   
210 210
   cmReflectCalc_t* cmReflectCalcAlloc( cmCtx* ctx, cmReflectCalc_t* p, const cmGoldSigArg_t* gsa, float phat_alpha, unsigned phat_mult );
211
-  cmRC_t cmReflectCalcFree( cmReflectCalc_t** pp );
212
-  cmRC_t cmReflectCalcInit( cmReflectCalc_t* p, const cmGoldSigArg_t* gsa, float phat_alpha, unsigned phat_mult );
211
+  cmRC_t cmReflectCalcFree(  cmReflectCalc_t** pp );
212
+  cmRC_t cmReflectCalcInit(  cmReflectCalc_t* p, const cmGoldSigArg_t* gsa, float phat_alpha, unsigned phat_mult );
213 213
   cmRC_t cmReflectCalcFinal( cmReflectCalc_t* p );
214
-  cmRC_t cmReflectCalcExec( cmReflectCalc_t* p, const cmSample_t xV, cmSample_t* yV, unsigned xyN );
215
-
214
+  cmRC_t cmReflectCalcExec(  cmReflectCalc_t* p, const cmSample_t* xV, cmSample_t* yV, unsigned xyN );
215
+  cmRC_t cmReflectCalcWrite( cmReflectCalc_t* p, const char* dirStr );
216 216
   
217 217
   
218 218
 #ifdef __cplusplus

Loading…
Cancel
Save