Browse Source

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

master
kevin 11 years ago
parent
commit
650b2a95a4
1 changed files with 34 additions and 13 deletions
  1. 34
    13
      cmProc2.c

+ 34
- 13
cmProc2.c View File

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