소스 검색

cmProc2.c:Fixed bug in cmPvAnlInit() where cmShiftBufExec() was not called inside a while() condition.

master
kevin 11 년 전
부모
커밋
650b2a95a4
1개의 변경된 파일34개의 추가작업 그리고 13개의 파일을 삭제
  1. 34
    13
      cmProc2.c

+ 34
- 13
cmProc2.c 파일 보기

@@ -2300,11 +2300,10 @@ cmRC_t     cmPvAnlInit( cmPvAnl* p, unsigned procSmpCnt, double srate, unsigned
2300 2300
 cmRC_t     cmPvAnlFinal(cmPvAnl* p )
2301 2301
 { return cmOkRC; }
2302 2302
 
2303
-
2304 2303
 bool     cmPvAnlExec( cmPvAnl* p, const cmSample_t* x, unsigned xN )
2305 2304
 {
2306 2305
   bool fl = false;
2307
-  if( cmShiftBufExec(&p->sb,x,xN) )
2306
+  while( cmShiftBufExec(&p->sb,x,xN) )
2308 2307
   {
2309 2308
     cmWndFuncExec(&p->wf, p->sb.outV, p->sb.wndSmpCnt );
2310 2309
 
@@ -2421,13 +2420,12 @@ cmRC_t     cmPvSynExec( cmPvSyn* p, const cmReal_t* magV, const cmReal_t* phsV )
2421 2420
   double   twoPi     = 2.0 * M_PI;
2422 2421
   unsigned k;
2423 2422
 
2424
- 
2425 2423
   for(k=0; k<p->binCnt; ++k)
2426 2424
   {
2427 2425
     // phase dist between cur and prv frame
2428 2426
     cmReal_t dp = phsV[k] - p->phs0V[k];
2429 2427
 
2430
-    // dist must be positive (cmcum phase always increases)
2428
+    // dist must be positive (accum phase always increases)
2431 2429
     if( dp < -0.00001 )
2432 2430
       dp += twoPi;
2433 2431
 
@@ -2449,8 +2447,9 @@ cmRC_t     cmPvSynExec( cmPvSyn* p, const cmReal_t* magV, const cmReal_t* phsV )
2449 2447
     p->phs0V[k] = phsV[k];
2450 2448
     p->mag0V[k] = magV[k];
2451 2449
   }
2452
-
2453
-  cmIFftExecPolarRS( &p->ft, p->magV, p->phsV );
2450
+  
2451
+  cmIFftExecPolarRS( &p->ft, magV, phsV );
2452
+  
2454 2453
   cmOlaExecS( &p->ola, p->ft.outV, p->ft.outN ); 
2455 2454
 
2456 2455
   //printf("%i %i\n",p->binCnt,p->ft.binCnt );
@@ -2462,6 +2461,16 @@ cmRC_t     cmPvSynExec( cmPvSyn* p, const cmReal_t* magV, const cmReal_t* phsV )
2462 2461
   return cmOkRC;
2463 2462
 }
2464 2463
 
2464
+cmRC_t  cmPvSynDoIt( cmPvSyn* p, const cmSample_t* v )
2465
+{
2466
+  cmOlaExecS( &p->ola, v, p->wndSmpCnt ); 
2467
+
2468
+  //printf("%f\n",cmVOS_RMS(s,p->wndSmpCnt,p->wndSmpCnt));
2469
+
2470
+  return cmOkRC;
2471
+}
2472
+
2473
+
2465 2474
 const cmSample_t* cmPvSynExecOut(cmPvSyn* p )
2466 2475
 { return cmOlaExecOut(&p->ola); }
2467 2476
 
@@ -3653,9 +3662,14 @@ cmRC_t   cmNmfExec( cmNmf_t* p, const cmReal_t* vM, unsigned cn )
3653 3662
 cmSpecDist_t* cmSpecDistAlloc( cmCtx* ctx,cmSpecDist_t* ap, unsigned procSmpCnt, double srate, unsigned wndSmpCnt, unsigned hopFcmt, unsigned olaWndTypeId  )
3654 3663
 {
3655 3664
   cmSpecDist_t* p = cmObjAlloc( cmSpecDist_t, ctx, ap );
3665
+
3666
+
3656 3667
   if( procSmpCnt != 0 )
3668
+  {
3657 3669
     if( cmSpecDistInit( p, procSmpCnt, srate, wndSmpCnt, hopFcmt, olaWndTypeId ) != cmOkRC )
3658 3670
       cmSpecDistFree(&p);
3671
+  }
3672
+
3659 3673
   return p;
3660 3674
 
3661 3675
 }
@@ -3666,7 +3680,7 @@ cmRC_t cmSpecDistFree( cmSpecDist_t** pp )
3666 3680
     return cmOkRC;
3667 3681
 
3668 3682
   cmSpecDist_t* p = *pp;
3669
-
3683
+  
3670 3684
   cmSpecDistFinal(p);
3671 3685
   cmMemPtrFree(&p->hzV);
3672 3686
   cmObjFree(pp);
@@ -3713,8 +3727,10 @@ cmRC_t cmSpecDistInit( cmSpecDist_t* p, unsigned procSmpCnt, double srate, unsig
3713 3727
   p->aeMin  = 1000;
3714 3728
   p->aeMax  = -1000;
3715 3729
 
3730
+
3716 3731
   //p->bypOut = cmMemResizeZ(cmSample_t, p->bypOut, procSmpCnt );
3717 3732
 
3733
+
3718 3734
   return rc;
3719 3735
 }
3720 3736
 
@@ -3723,6 +3739,7 @@ cmRC_t cmSpecDistFinal(cmSpecDist_t* p )
3723 3739
   cmRC_t rc = cmOkRC;
3724 3740
   cmPvAnlFree(&p->pva);
3725 3741
   cmPvSynFree(&p->pvs);
3742
+
3726 3743
   return rc;
3727 3744
 }
3728 3745
 
@@ -3746,6 +3763,7 @@ void _cmSpecDistBasicMode0(cmSpecDist_t* p, cmReal_t* X1m, unsigned binCnt, cmRe
3746 3763
 
3747 3764
   }
3748 3765
 
3766
+
3749 3767
 }
3750 3768
 
3751 3769
 void _cmSpecDistBasicMode(cmSpecDist_t* p, cmReal_t* X1m, unsigned binCnt, cmReal_t thresh )
@@ -3856,19 +3874,18 @@ void _cmSpecDistAmpEnvMode( cmSpecDist_t* p, cmReal_t* X1m )
3856 3874
 
3857 3875
 }
3858 3876
 
3859
-
3860 3877
 cmRC_t  cmSpecDistExec( cmSpecDist_t* p, const cmSample_t* sp, unsigned sn )
3861 3878
 {
3862 3879
 
3863 3880
   assert( sn == p->procSmpCnt );
3864
-  
3881
+
3865 3882
   // cmPvAnlExec() returns true when it calc's a new spectral output frame
3866 3883
   if( cmPvAnlExec( p->pva, sp, sn ) )
3867 3884
   {
3868 3885
     cmReal_t X1m[p->pva->binCnt]; 
3869 3886
 
3870 3887
     cmVOR_AmplToDbVV(X1m, p->pva->binCnt, p->pva->magV, -1000.0 );
3871
-
3888
+   
3872 3889
     switch( p->mode )
3873 3890
     {
3874 3891
       case kBypassModeSdId:
@@ -3904,17 +3921,21 @@ cmRC_t  cmSpecDistExec( cmSpecDist_t* p, const cmSample_t* sp, unsigned sn )
3904 3921
       default:
3905 3922
         break;
3906 3923
     }
3907
-
3924
+    
3908 3925
     cmVOR_DbToAmplVV(X1m, p->pva->binCnt, X1m );
3909 3926
 
3910 3927
     cmPvSynExec(p->pvs, X1m, p->pva->phsV );
3911
-
3928
+  
3912 3929
   }
3930
+ 
3913 3931
   return cmOkRC;
3914 3932
 }
3915 3933
 
3934
+
3916 3935
 const cmSample_t* cmSpecDistOut(  cmSpecDist_t* p )
3917
-{ return cmPvSynExecOut(p->pvs); }
3936
+{ 
3937
+  return cmPvSynExecOut(p->pvs); 
3938
+}
3918 3939
 
3919 3940
 //------------------------------------------------------------------------------------------------------------
3920 3941
 

Loading…
취소
저장