Browse Source

cmProc4.h/c: Added cmRcdPlaySetLaSecs().

Added comments.
Fixed bug in filling record buffer.
master
kevin 11 years ago
parent
commit
198908dd47
2 changed files with 27 additions and 11 deletions
  1. 25
    11
      cmProc4.c
  2. 2
    0
      cmProc4.h

+ 25
- 11
cmProc4.c View File

4237
   return cmOkRC;
4237
   return cmOkRC;
4238
 }
4238
 }
4239
 
4239
 
4240
-cmRC_t         cmRecdPlayRewind( cmRecdPlay* p )
4240
+cmRC_t cmRecdPlaySetLaSecs( cmRecdPlay* p, double curLaSecs )
4241
+{
4242
+   p->curLaSmpCnt  = floor(curLaSecs*p->srate);  
4243
+   return cmOkRC;
4244
+}
4245
+
4246
+
4247
+cmRC_t cmRecdPlayRewind( cmRecdPlay* p )
4241
 {
4248
 {
4242
   unsigned i;
4249
   unsigned i;
4243
 
4250
 
4251
+  // zero the look-ahead buffers
4244
   p->laSmpIdx = 0;
4252
   p->laSmpIdx = 0;
4253
+  for(i=0; i<p->chCnt; ++i)
4254
+    cmVOS_Zero(p->laChs[i],p->maxLaSmpCnt);
4245
 
4255
 
4256
+  // remove all the active players
4246
   while( p->plist != NULL )
4257
   while( p->plist != NULL )
4247
     cmRecdPlayEndPlay(p,p->plist->labelSymId);
4258
     cmRecdPlayEndPlay(p,p->plist->labelSymId);
4248
   
4259
   
4260
+  // remove all the active recorders
4249
   while( p->rlist != NULL )
4261
   while( p->rlist != NULL )
4250
-    cmRecdPlayEndRecord(p,p->plist->labelSymId);
4262
+    cmRecdPlayEndRecord(p,p->rlist->labelSymId);
4251
 
4263
 
4264
+  // rewind all the fragments play posn. 
4252
   for(i=0; i<p->fragCnt; ++i)
4265
   for(i=0; i<p->fragCnt; ++i)
4253
     p->frags[i].playIdx = 0;
4266
     p->frags[i].playIdx = 0;
4254
 
4267
 
4271
         p->frags[i].rlink   = p->rlist;
4284
         p->frags[i].rlink   = p->rlist;
4272
         p->rlist            = p->frags + i;
4285
         p->rlist            = p->frags + i;
4273
 
4286
 
4287
+       
4274
         // handle LA buf longer than frag buf.
4288
         // handle LA buf longer than frag buf.
4275
         int cpyCnt  = cmMin(p->curLaSmpCnt,p->frags[i].allocCnt); 
4289
         int cpyCnt  = cmMin(p->curLaSmpCnt,p->frags[i].allocCnt); 
4276
 
4290
 
4302
         }
4316
         }
4303
 
4317
 
4304
         p->frags[i].recdIdx = cpyCnt;
4318
         p->frags[i].recdIdx = cpyCnt;
4305
-
4319
+        p->frags[i].playIdx = 0;
4320
+        
4306
       }
4321
       }
4307
       
4322
       
4308
       return cmOkRC;
4323
       return cmOkRC;
4407
   chCnt = cmMin(chCnt, p->chCnt);
4422
   chCnt = cmMin(chCnt, p->chCnt);
4408
 
4423
 
4409
   //-------------------------------------------------------------------
4424
   //-------------------------------------------------------------------
4410
-  // copy incoming audio into the look-head buffers
4425
+  // copy incoming audio into the look-ahead buffers
4411
   //
4426
   //
4412
 
4427
 
4413
   // if the number of incoming samples is longer than the look-head buffer
4428
   // if the number of incoming samples is longer than the look-head buffer
4418
   if( srcSmpCnt > p->maxLaSmpCnt )
4433
   if( srcSmpCnt > p->maxLaSmpCnt )
4419
   {
4434
   {
4420
     // advance incoming sample buffer so that there are maxLaSmpCnt samples remaining
4435
     // advance incoming sample buffer so that there are maxLaSmpCnt samples remaining
4421
-    srcOffs   = smpCnt-p->maxLaSmpCnt; 
4436
+    srcOffs   = srcSmpCnt-p->maxLaSmpCnt; 
4422
     srcSmpCnt = p->maxLaSmpCnt;        // decrease the total samples to copy  
4437
     srcSmpCnt = p->maxLaSmpCnt;        // decrease the total samples to copy  
4423
   }
4438
   }
4424
 
4439
 
4457
     unsigned n = cmMin(fp->allocCnt - fp->recdIdx,smpCnt);
4472
     unsigned n = cmMin(fp->allocCnt - fp->recdIdx,smpCnt);
4458
     unsigned i;
4473
     unsigned i;
4459
     for(i=0; i<p->chCnt; ++i)
4474
     for(i=0; i<p->chCnt; ++i)
4460
-    {
4461
       cmVOS_Copy(fp->chArray[i] + fp->recdIdx, n, iChs[i] );
4475
       cmVOS_Copy(fp->chArray[i] + fp->recdIdx, n, iChs[i] );
4462
-      fp->recdIdx += n;
4463
-    }
4476
+
4477
+    fp->recdIdx += n;
4478
+
4464
   }  
4479
   }  
4465
 
4480
 
4466
   //-------------------------------------------------------------------
4481
   //-------------------------------------------------------------------
4476
     unsigned i;
4491
     unsigned i;
4477
 
4492
 
4478
     for(i=0; i<p->chCnt; ++i)
4493
     for(i=0; i<p->chCnt; ++i)
4479
-    {
4480
       cmVOS_MultVVS(oChs[i],n,fp->chArray[i] + fp->playIdx,gain);
4494
       cmVOS_MultVVS(oChs[i],n,fp->chArray[i] + fp->playIdx,gain);
4481
-      fp->playIdx += n;
4482
-    }
4495
+
4496
+    fp->playIdx += n;
4483
 
4497
 
4484
     // if a fade rate has been set then advance the fade phase
4498
     // if a fade rate has been set then advance the fade phase
4485
     if(fp->fadeDbPerSec!=0.0)
4499
     if(fp->fadeDbPerSec!=0.0)

+ 2
- 0
cmProc4.h View File

665
 
665
 
666
   cmRC_t         cmRecdPlayRegisterFrag( cmRecdPlay* p, unsigned fragIdx, unsigned labelSymId );
666
   cmRC_t         cmRecdPlayRegisterFrag( cmRecdPlay* p, unsigned fragIdx, unsigned labelSymId );
667
 
667
 
668
+  cmRC_t         cmRecdPlaySetLaSecs( cmRecdPlay* p, double curLaSecs );
669
+
668
   cmRC_t         cmRecdPlayRewind(      cmRecdPlay* p );
670
   cmRC_t         cmRecdPlayRewind(      cmRecdPlay* p );
669
   cmRC_t         cmRecdPlayBeginRecord( cmRecdPlay* p, unsigned labelSymId );
671
   cmRC_t         cmRecdPlayBeginRecord( cmRecdPlay* p, unsigned labelSymId );
670
   cmRC_t         cmRecdPlayEndRecord(   cmRecdPlay* p, unsigned labelSymId );
672
   cmRC_t         cmRecdPlayEndRecord(   cmRecdPlay* p, unsigned labelSymId );

Loading…
Cancel
Save