Quellcode durchsuchen

cmProc4.h/c : Added cmRecdPlayInsertRecord() to the cmRecdPlay object.

master
kevin vor 11 Jahren
Ursprung
Commit
744da47218
2 geänderte Dateien mit 42 neuen und 0 gelöschten Zeilen
  1. 40
    0
      cmProc4.c
  2. 2
    0
      cmProc4.h

+ 40
- 0
cmProc4.c Datei anzeigen

@@ -4352,6 +4352,46 @@ cmRC_t         cmRecdPlayEndRecord(   cmRecdPlay* p, unsigned labelSymId )
4352 4352
   return  cmCtxRtCondition( &p->obj, cmInvalidArgRC, "The fragment label symbol id '%i' not found for 'end record'.",labelSymId);      
4353 4353
 }
4354 4354
 
4355
+cmRC_t         cmRecdPlayInsertRecord(cmRecdPlay* p, unsigned labelSymId, const cmChar_t* wavFn )
4356
+{
4357
+  cmRC_t rc = cmOkRC;
4358
+  unsigned i;
4359
+
4360
+  for(i=0; i<p->fragCnt; ++i)
4361
+    if( p->frags[i].labelSymId == labelSymId )
4362
+    {
4363
+      cmAudioFileH_t    afH  = cmNullAudioFileH;
4364
+      cmAudioFileInfo_t afInfo;
4365
+      cmRC_t            afRC = kOkAfRC;
4366
+
4367
+      // open the audio file
4368
+      if( cmAudioFileIsValid( afH = cmAudioFileNewOpen(wavFn, &afInfo, &afRC, p->obj.err.rpt )) == false )
4369
+        return  cmCtxRtCondition( &p->obj, cmInvalidArgRC, "The audio file '%s' could not be opened'.",cmStringNullGuard(wavFn));    
4370
+
4371
+      // ignore blank
4372
+      if( afInfo.frameCnt == 0 )
4373
+        return cmOkRC;
4374
+          
4375
+      // allocate buffer space
4376
+      unsigned j;
4377
+      for(j=0; j<p->chCnt; ++j)
4378
+        p->frags[i].chArray[j] = cmMemResize(cmSample_t,p->frags[i].chArray[j],afInfo.frameCnt);
4379
+
4380
+      p->frags[i].allocCnt = afInfo.frameCnt;
4381
+
4382
+      // read samples into the buffer space
4383
+      unsigned chIdx = 0;
4384
+      unsigned chCnt = cmMin(p->chCnt,afInfo.chCnt);
4385
+      unsigned actFrmCnt = 0;
4386
+      if( cmAudioFileReadSample(afH,afInfo.frameCnt,chIdx,chCnt,&p->frags[i].chArray, &actFrmCnt) != kOkAfRC )
4387
+        return cmCtxRtCondition(&p->obj, cmSubSysFailRC, "Read failed on the audio file '%s'.",cmStringNullGuard(wavFn));
4388
+
4389
+    }
4390
+
4391
+    return  cmCtxRtCondition( &p->obj, cmInvalidArgRC, "The fragment label symbol id '%i' not found for 'begin record'.",labelSymId);    
4392
+}
4393
+
4394
+
4355 4395
 cmRC_t         cmRecdPlayBeginPlay(   cmRecdPlay* p, unsigned labelSymId )
4356 4396
 {
4357 4397
   unsigned i;

+ 2
- 0
cmProc4.h Datei anzeigen

@@ -688,6 +688,8 @@ extern "C" {
688 688
 
689 689
   cmRC_t         cmRecdPlayBeginRecord( cmRecdPlay* p, unsigned labelSymId );
690 690
   cmRC_t         cmRecdPlayEndRecord(   cmRecdPlay* p, unsigned labelSymId );
691
+  cmRC_t         cmRecdPlayInsertRecord(cmRecdPlay* p, unsigned labelSymId, const cmChar_t* wavFn );
692
+
691 693
   cmRC_t         cmRecdPlayBeginPlay(   cmRecdPlay* p, unsigned labelSymId );
692 694
   cmRC_t         cmRecdPlayEndPlay(     cmRecdPlay* p, unsigned labelSymId );
693 695
 

Laden…
Abbrechen
Speichern