瀏覽代碼

merging recdplay updates from thunk onto mac

master
kevin 11 年之前
父節點
當前提交
1d9455e9eb
共有 3 個檔案被更改,包括 57 行新增0 行删除
  1. 40
    0
      cmProc4.c
  2. 2
    0
      cmProc4.h
  3. 15
    0
      dsp/cmDspKr.c

+ 40
- 0
cmProc4.c 查看文件

@@ -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 查看文件

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

+ 15
- 0
dsp/cmDspKr.c 查看文件

@@ -2485,6 +2485,8 @@ enum
2485 2485
   kMaxLaSecsPrId,
2486 2486
   kCurLaSecsPrId,
2487 2487
   kFadeRatePrId,
2488
+  kSegFnPrId,
2489
+  kSegLblPrId,
2488 2490
   kScLocIdxPrId,
2489 2491
   kCmdPrId,
2490 2492
   kInAudioBasePrId
@@ -2537,6 +2539,15 @@ cmDspRC_t _cmDspRecdPlayOpenScore( cmDspCtx_t* ctx, cmDspInst_t* inst )
2537 2539
     for(i=0; i<markerCnt; ++i)
2538 2540
       cmRecdPlayRegisterFrag(p->rcdply,i, cmScoreMarkerLabelSymbolId(p->scH,i ));
2539 2541
 
2542
+    const cmChar_t* segFn = cmDspStrcz(inst,kSegFnPrId);
2543
+    const cmChar_t* segLbl= cmDspStrcz(inst,kSegLblPrId);
2544
+    
2545
+    if( cmTextLength(segFn)>0 && cmTextLength(segLbl)>0 )
2546
+    {
2547
+      unsigned segSymId = cmSymTblRegisterSymbol(ctx->stH,segLbl);
2548
+      cmRecdPlayInsertRecord(p->rcdply,segSymId,segFn);
2549
+    }
2550
+
2540 2551
   }
2541 2552
 
2542 2553
   return rc;
@@ -2565,6 +2576,8 @@ cmDspInst_t*  _cmDspRecdPlayAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
2565 2576
     1,         "maxla",  kMaxLaSecsPrId,  0,0, kInDsvFl   | kDoubleDsvFl | kReqArgDsvFl, "Maximum look-ahead buffer in seconds.",
2566 2577
     1,         "curla",  kCurLaSecsPrId,  0,0, kInDsvFl   | kDoubleDsvFl | kOptArgDsvFl, "Current look-head buffer in seconds.",
2567 2578
     1,         "frate",  kFadeRatePrId,   0,0, kInDsvFl   | kDoubleDsvFl | kOptArgDsvFl, "Fade rate in dB per second.",
2579
+    1,         "segFn",  kSegFnPrId,      0,0, kInDsvFl   | kStrzDsvFl   | kOptArgDsvFl, "Preload an audio segment.",
2580
+    1,         "segLbl", kSegLblPrId,     0,0, kInDsvFl   | kStrzDsvFl   | kOptArgDsvFl, "Score symbol of preloaded audio segment.",
2568 2581
     1,         "index",  kScLocIdxPrId,   0,0, kInDsvFl   | kUIntDsvFl,                "Score follower location index.",
2569 2582
     1,         "cmd",    kCmdPrId,        0,0, kInDsvFl   | kSymDsvFl,                 "on=reset off=stop.",
2570 2583
     chCnt,     "in",     kInAudioBasePrId,0,1, kInDsvFl   | kAudioBufDsvFl,            "Audio input",
@@ -2589,6 +2602,8 @@ cmDspInst_t*  _cmDspRecdPlayAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
2589 2602
   printf("1 max la secs:%f\n",cmDspDouble(&p->inst,kMaxLaSecsPrId));
2590 2603
 
2591 2604
 
2605
+
2606
+
2592 2607
   return &p->inst;
2593 2608
 }
2594 2609
 

Loading…
取消
儲存