|
@@ -726,6 +726,8 @@ cmRC_t cmReflectCalcFree( cmReflectCalc_t** pp )
|
726
|
726
|
if((rc = cmReflectCalcFinal(p)) != cmOkRC )
|
727
|
727
|
return rc;
|
728
|
728
|
|
|
729
|
+ cmMemFree(p->t0V);
|
|
730
|
+ cmMemFree(p->t1V);
|
729
|
731
|
cmVectArrayFree(&p->phVa);
|
730
|
732
|
cmVectArrayFree(&p->xVa);
|
731
|
733
|
cmVectArrayFree(&p->yVa);
|
|
@@ -770,10 +772,14 @@ cmRC_t cmReflectCalcInit( cmReflectCalc_t* p, const cmGoldSigArg_t* gsa, float p
|
770
|
772
|
goto errLabel;
|
771
|
773
|
}
|
772
|
774
|
|
773
|
|
-
|
774
|
775
|
p->xi = 0;
|
775
|
|
- p->zeroFl = false;
|
776
|
776
|
|
|
777
|
+ p->tN = 5;
|
|
778
|
+ p->t0V = cmMemResizeZ(unsigned,p->t0V,p->tN);
|
|
779
|
+ p->t1V = cmMemResizeZ(unsigned,p->t1V,p->tN);
|
|
780
|
+ p->ti = 0;
|
|
781
|
+ p->t = 0;
|
|
782
|
+
|
777
|
783
|
errLabel:
|
778
|
784
|
|
779
|
785
|
return rc;
|
|
@@ -786,13 +792,15 @@ cmRC_t cmReflectCalcFinal( cmReflectCalc_t* p )
|
786
|
792
|
return cmOkRC;
|
787
|
793
|
}
|
788
|
794
|
|
|
795
|
+/*
|
789
|
796
|
cmRC_t cmReflectCalcExec( cmReflectCalc_t* p, const cmSample_t* xV, cmSample_t* yV, unsigned xyN )
|
790
|
797
|
{
|
791
|
798
|
unsigned i;
|
792
|
799
|
|
793
|
800
|
// feed audio into the PHAT's buffer
|
794
|
801
|
cmPhatExec(p->phat,xV,xyN);
|
795
|
|
-
|
|
802
|
+
|
|
803
|
+ // fill the output buffer
|
796
|
804
|
for(i=0; i<xyN; ++i,++p->xi)
|
797
|
805
|
{
|
798
|
806
|
if( p->xi < p->gs->sigN )
|
|
@@ -820,7 +828,71 @@ cmRC_t cmReflectCalcExec( cmReflectCalc_t* p, const cmSample_t* xV, cmSample_t*
|
820
|
828
|
cmVectArrayAppendS(p->yVa,yV,xyN);
|
821
|
829
|
|
822
|
830
|
return cmOkRC;
|
|
831
|
+}
|
|
832
|
+*/
|
|
833
|
+
|
|
834
|
+cmRC_t cmReflectCalcExec( cmReflectCalc_t* p, const cmSample_t* xV, cmSample_t* yV, unsigned xyN )
|
|
835
|
+{
|
|
836
|
+ unsigned i;
|
|
837
|
+
|
|
838
|
+ unsigned xyN0 = xyN;
|
|
839
|
+
|
|
840
|
+ while(xyN0)
|
|
841
|
+ {
|
|
842
|
+ // feed audio into the PHAT's buffer
|
|
843
|
+ unsigned di = p->phat->di;
|
|
844
|
+ unsigned n = cmMin(xyN0,p->phat->fhN - di );
|
|
845
|
+
|
|
846
|
+ cmPhatExec(p->phat,xV,n);
|
|
847
|
+
|
|
848
|
+ if( di + n == p->phat->fhN )
|
|
849
|
+ {
|
|
850
|
+ // execute the correlation
|
|
851
|
+ cmPhatChExec(p->phat,0,0,0);
|
|
852
|
+
|
|
853
|
+ // p->phat->xV[fhN] now holds the correlation result
|
|
854
|
+
|
|
855
|
+ // get the peak index
|
|
856
|
+ p->t1V[p->ti] = cmVOS_MaxIndex(p->phat->xV,p->phat->fhN,1);
|
|
857
|
+
|
|
858
|
+ printf("%i %i\n",p->t,p->t1V[p->ti]);
|
|
859
|
+
|
|
860
|
+ p->ti = (p->ti + 1) % p->tN;
|
|
861
|
+
|
|
862
|
+
|
|
863
|
+ // store the correlation result
|
|
864
|
+ if( p->phVa != NULL )
|
|
865
|
+ cmVectArrayAppendS(p->phVa,p->phat->xV,p->phat->fhN );
|
|
866
|
+
|
|
867
|
+ }
|
|
868
|
+
|
|
869
|
+ xyN0 -= n;
|
|
870
|
+
|
|
871
|
+ }
|
823
|
872
|
|
|
873
|
+ // fill the output buffer
|
|
874
|
+ for(i=0; i<xyN; ++i)
|
|
875
|
+ {
|
|
876
|
+ if( p->xi == 0 )
|
|
877
|
+ p->t0V[p->ti] = p->t + i;
|
|
878
|
+
|
|
879
|
+ if( p->xi < p->gs->sigN )
|
|
880
|
+ yV[i] = p->gs->ch[0].mdV[p->xi];
|
|
881
|
+ else
|
|
882
|
+ yV[i] = 0;
|
|
883
|
+
|
|
884
|
+ p->xi = (p->xi+1) % p->phat->fhN;
|
|
885
|
+ }
|
|
886
|
+
|
|
887
|
+ p->t += xyN;
|
|
888
|
+
|
|
889
|
+ if( p->xVa != NULL )
|
|
890
|
+ cmVectArrayAppendS(p->xVa,xV,xyN);
|
|
891
|
+
|
|
892
|
+ if( p->yVa != NULL )
|
|
893
|
+ cmVectArrayAppendS(p->yVa,yV,xyN);
|
|
894
|
+
|
|
895
|
+ return cmOkRC;
|
824
|
896
|
}
|
825
|
897
|
|
826
|
898
|
cmRC_t cmReflectCalcWrite( cmReflectCalc_t* p, const char* dirStr )
|