Selaa lähdekoodia

cmProc4.h/c: Added cmRcdPlaySetLaSecs().

Added comments.
Fixed bug in filling record buffer.
master
kevin 10 vuotta sitten
vanhempi
commit
198908dd47
2 muutettua tiedostoa jossa 27 lisäystä ja 11 poistoa
  1. 25
    11
      cmProc4.c
  2. 2
    0
      cmProc4.h

+ 25
- 11
cmProc4.c Näytä tiedosto

@@ -4237,18 +4237,31 @@ cmRC_t         cmRecdPlayRegisterFrag( cmRecdPlay* p,  unsigned fragIdx, unsigne
4237 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 4249
   unsigned i;
4243 4250
 
4251
+  // zero the look-ahead buffers
4244 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 4257
   while( p->plist != NULL )
4247 4258
     cmRecdPlayEndPlay(p,p->plist->labelSymId);
4248 4259
   
4260
+  // remove all the active recorders
4249 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 4265
   for(i=0; i<p->fragCnt; ++i)
4253 4266
     p->frags[i].playIdx = 0;
4254 4267
 
@@ -4271,6 +4284,7 @@ cmRC_t         cmRecdPlayBeginRecord( cmRecdPlay* p, unsigned labelSymId )
4271 4284
         p->frags[i].rlink   = p->rlist;
4272 4285
         p->rlist            = p->frags + i;
4273 4286
 
4287
+       
4274 4288
         // handle LA buf longer than frag buf.
4275 4289
         int cpyCnt  = cmMin(p->curLaSmpCnt,p->frags[i].allocCnt); 
4276 4290
 
@@ -4302,7 +4316,8 @@ cmRC_t         cmRecdPlayBeginRecord( cmRecdPlay* p, unsigned labelSymId )
4302 4316
         }
4303 4317
 
4304 4318
         p->frags[i].recdIdx = cpyCnt;
4305
-
4319
+        p->frags[i].playIdx = 0;
4320
+        
4306 4321
       }
4307 4322
       
4308 4323
       return cmOkRC;
@@ -4407,7 +4422,7 @@ cmRC_t         cmRecdPlayExec( cmRecdPlay* p, const cmSample_t** iChs, cmSample_
4407 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 4428
   // if the number of incoming samples is longer than the look-head buffer
@@ -4418,7 +4433,7 @@ cmRC_t         cmRecdPlayExec( cmRecdPlay* p, const cmSample_t** iChs, cmSample_
4418 4433
   if( srcSmpCnt > p->maxLaSmpCnt )
4419 4434
   {
4420 4435
     // advance incoming sample buffer so that there are maxLaSmpCnt samples remaining
4421
-    srcOffs   = smpCnt-p->maxLaSmpCnt; 
4436
+    srcOffs   = srcSmpCnt-p->maxLaSmpCnt; 
4422 4437
     srcSmpCnt = p->maxLaSmpCnt;        // decrease the total samples to copy  
4423 4438
   }
4424 4439
 
@@ -4457,10 +4472,10 @@ cmRC_t         cmRecdPlayExec( cmRecdPlay* p, const cmSample_t** iChs, cmSample_
4457 4472
     unsigned n = cmMin(fp->allocCnt - fp->recdIdx,smpCnt);
4458 4473
     unsigned i;
4459 4474
     for(i=0; i<p->chCnt; ++i)
4460
-    {
4461 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,10 +4491,9 @@ cmRC_t         cmRecdPlayExec( cmRecdPlay* p, const cmSample_t** iChs, cmSample_
4476 4491
     unsigned i;
4477 4492
 
4478 4493
     for(i=0; i<p->chCnt; ++i)
4479
-    {
4480 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 4498
     // if a fade rate has been set then advance the fade phase
4485 4499
     if(fp->fadeDbPerSec!=0.0)

+ 2
- 0
cmProc4.h Näytä tiedosto

@@ -665,6 +665,8 @@ extern "C" {
665 665
 
666 666
   cmRC_t         cmRecdPlayRegisterFrag( cmRecdPlay* p, unsigned fragIdx, unsigned labelSymId );
667 667
 
668
+  cmRC_t         cmRecdPlaySetLaSecs( cmRecdPlay* p, double curLaSecs );
669
+
668 670
   cmRC_t         cmRecdPlayRewind(      cmRecdPlay* p );
669 671
   cmRC_t         cmRecdPlayBeginRecord( cmRecdPlay* p, unsigned labelSymId );
670 672
   cmRC_t         cmRecdPlayEndRecord(   cmRecdPlay* p, unsigned labelSymId );

Loading…
Peruuta
Tallenna