|
@@ -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;
|