Merge branch 'master' of klarke.webfactional.com:webapps/git/repos/libcm
This commit is contained in:
commit
9dc8a4eb8c
@ -613,27 +613,29 @@ cmScRC_t _cmScParseMarkers( cmSc_t* p, unsigned scoreIdx, const cmChar_t* text,
|
||||
if( cmSymTblIsValid(p->stH) == false )
|
||||
return kOkScRC;
|
||||
|
||||
// go to command/id space
|
||||
if((ip = cmTextNextWhiteOrEosC(text)) == NULL )
|
||||
goto errLabel;
|
||||
|
||||
// goto label
|
||||
if((ip = cmTextNextNonWhiteC(ip)) == NULL )
|
||||
goto errLabel;
|
||||
|
||||
// goto end of label
|
||||
if((ep = cmTextNextWhiteOrEosC(ip)) == NULL )
|
||||
goto errLabel;
|
||||
else
|
||||
for(;(cp = cmTextNextNonWhiteC(cp)) != NULL; cp=ep )
|
||||
{
|
||||
unsigned n = (ep-ip)+1;
|
||||
cmChar_t markTextStr[n+1];
|
||||
strncpy(markTextStr,ip,n);
|
||||
// go to command/id space
|
||||
if((ip = cmTextNextWhiteOrEosC(cp)) == NULL )
|
||||
goto errLabel;
|
||||
|
||||
// for each command code
|
||||
// (there may be more than one character)
|
||||
for(; *cp && !isspace(*cp); ++cp)
|
||||
// goto label
|
||||
if((ip = cmTextNextNonWhiteC(ip)) == NULL )
|
||||
goto errLabel;
|
||||
|
||||
// goto end of label
|
||||
if((ep = cmTextNextWhiteOrEosC(ip)) == NULL )
|
||||
goto errLabel;
|
||||
else
|
||||
{
|
||||
unsigned n = (ep-ip)+1;
|
||||
cmChar_t markTextStr[n+1];
|
||||
strncpy(markTextStr,ip,n);
|
||||
markTextStr[n] = 0;
|
||||
|
||||
// remove any trailing white space
|
||||
cmTextTrimEnd(markTextStr);
|
||||
|
||||
cmMarkScMId_t cmdId = kInvalidScMId;
|
||||
|
||||
switch( *cp )
|
||||
@ -653,6 +655,8 @@ cmScRC_t _cmScParseMarkers( cmSc_t* p, unsigned scoreIdx, const cmChar_t* text,
|
||||
mp->scoreIdx = scoreIdx;
|
||||
mp->csvRowIdx = rowIdx;
|
||||
|
||||
//printf("%i %c '%s'\n",rowIdx,*cp,markTextStr);
|
||||
|
||||
// insert the new mark at the end of the list
|
||||
if( p->markList == NULL )
|
||||
p->markList = mp;
|
||||
@ -665,7 +669,9 @@ cmScRC_t _cmScParseMarkers( cmSc_t* p, unsigned scoreIdx, const cmChar_t* text,
|
||||
ep->link = mp;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return kOkScRC;
|
||||
|
||||
errLabel:
|
||||
|
43
cmProc4.c
43
cmProc4.c
@ -4352,6 +4352,49 @@ cmRC_t cmRecdPlayEndRecord( cmRecdPlay* p, unsigned labelSymId )
|
||||
return cmCtxRtCondition( &p->obj, cmInvalidArgRC, "The fragment label symbol id '%i' not found for 'end record'.",labelSymId);
|
||||
}
|
||||
|
||||
cmRC_t cmRecdPlayInsertRecord(cmRecdPlay* p, unsigned labelSymId, const cmChar_t* wavFn )
|
||||
{
|
||||
cmRC_t rc = cmOkRC;
|
||||
unsigned i;
|
||||
|
||||
for(i=0; i<p->fragCnt; ++i)
|
||||
if( p->frags[i].labelSymId == labelSymId )
|
||||
{
|
||||
cmAudioFileH_t afH = cmNullAudioFileH;
|
||||
cmAudioFileInfo_t afInfo;
|
||||
cmRC_t afRC = kOkAfRC;
|
||||
|
||||
// open the audio file
|
||||
if( cmAudioFileIsValid( afH = cmAudioFileNewOpen(wavFn, &afInfo, &afRC, p->obj.err.rpt )) == false )
|
||||
return cmCtxRtCondition( &p->obj, cmInvalidArgRC, "The audio file '%s' could not be opened'.",cmStringNullGuard(wavFn));
|
||||
|
||||
// ignore blank
|
||||
if( afInfo.frameCnt == 0 )
|
||||
return cmOkRC;
|
||||
|
||||
// allocate buffer space
|
||||
unsigned j;
|
||||
for(j=0; j<p->chCnt; ++j)
|
||||
p->frags[i].chArray[j] = cmMemResize(cmSample_t,p->frags[i].chArray[j],afInfo.frameCnt);
|
||||
|
||||
p->frags[i].allocCnt = afInfo.frameCnt;
|
||||
|
||||
// read samples into the buffer space
|
||||
unsigned chIdx = 0;
|
||||
unsigned chCnt = cmMin(p->chCnt,afInfo.chCnt);
|
||||
unsigned actFrmCnt = 0;
|
||||
if( cmAudioFileReadSample(afH,afInfo.frameCnt,chIdx,chCnt,p->frags[i].chArray, &actFrmCnt) != kOkAfRC )
|
||||
return cmCtxRtCondition(&p->obj, cmSubSysFailRC, "Read failed on the audio file '%s'.",cmStringNullGuard(wavFn));
|
||||
|
||||
p->frags[i].recdIdx = actFrmCnt;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
return cmCtxRtCondition( &p->obj, cmInvalidArgRC, "The fragment label symbol id '%i' not found for 'begin record'.",labelSymId);
|
||||
}
|
||||
|
||||
|
||||
cmRC_t cmRecdPlayBeginPlay( cmRecdPlay* p, unsigned labelSymId )
|
||||
{
|
||||
unsigned i;
|
||||
|
@ -688,6 +688,8 @@ extern "C" {
|
||||
|
||||
cmRC_t cmRecdPlayBeginRecord( cmRecdPlay* p, unsigned labelSymId );
|
||||
cmRC_t cmRecdPlayEndRecord( cmRecdPlay* p, unsigned labelSymId );
|
||||
cmRC_t cmRecdPlayInsertRecord(cmRecdPlay* p, unsigned labelSymId, const cmChar_t* wavFn );
|
||||
|
||||
cmRC_t cmRecdPlayBeginPlay( cmRecdPlay* p, unsigned labelSymId );
|
||||
cmRC_t cmRecdPlayEndPlay( cmRecdPlay* p, unsigned labelSymId );
|
||||
|
||||
|
43
cmText.c
43
cmText.c
@ -539,6 +539,49 @@ void cmTextClip( cmChar_t* s, unsigned n )
|
||||
|
||||
}
|
||||
|
||||
cmChar_t* cmTextTrimBegin( cmChar_t* s )
|
||||
{
|
||||
if( s==NULL || strlen(s) == 0 )
|
||||
return s;
|
||||
|
||||
cmChar_t* s0 = cmTextNextNonWhite(s);
|
||||
|
||||
// no non-white char's exist
|
||||
if( s0 == NULL )
|
||||
{
|
||||
s[0] = 0;
|
||||
return s;
|
||||
}
|
||||
|
||||
if( s0 != s )
|
||||
cmTextShrinkS(s,s,s0-s);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
cmChar_t* cmTextTrimEnd( cmChar_t* s )
|
||||
{
|
||||
unsigned sn;
|
||||
|
||||
if( s==NULL || (sn = strlen(s))==0)
|
||||
return s;
|
||||
|
||||
cmChar_t* s0 = cmTextLastNonWhiteChar(s);
|
||||
|
||||
if(s0-s+1 < sn )
|
||||
s[s0-s+1] = 0;
|
||||
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
cmChar_t* cmTextTrim( cmChar_t* s)
|
||||
{
|
||||
cmTextTrimBegin(s);
|
||||
cmTextTrimEnd(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
cmChar_t* cmTextExpandS( cmChar_t* s, const cmChar_t* t, unsigned tn )
|
||||
{ return cmVOC_Expand(s,strlen(s)+1,t,tn); }
|
||||
|
5
cmText.h
5
cmText.h
@ -166,6 +166,11 @@ extern "C" {
|
||||
// Remove the last n characters from s by inserting a '\0' at s[ strlen(s)-n ].
|
||||
void cmTextClip( cmChar_t* s, unsigned n );
|
||||
|
||||
// Trim white space from the begining/end/both of a string
|
||||
cmChar_t* cmTextTrimBegin( cmChar_t* s );
|
||||
cmChar_t* cmTextTrimEnd( cmChar_t* s );
|
||||
cmChar_t* cmTextTrim( cmChar_t* );
|
||||
|
||||
// Expand s by copying all bytes past t to t+tn.
|
||||
cmChar_t* cmTextExpandS( cmChar_t* s, const cmChar_t* t, unsigned tn );
|
||||
|
||||
|
177
dsp/cmDspKr.c
177
dsp/cmDspKr.c
@ -27,7 +27,6 @@
|
||||
#include "cmDspSys.h"
|
||||
#include "cmMath.h"
|
||||
|
||||
|
||||
#include "cmAudioFile.h"
|
||||
#include "cmFileSys.h"
|
||||
#include "cmProcObj.h"
|
||||
@ -2371,6 +2370,7 @@ cmDspClass_t _cmNanoMapDC;
|
||||
typedef struct
|
||||
{
|
||||
cmDspInst_t inst;
|
||||
|
||||
} cmDspNanoMap_t;
|
||||
|
||||
cmDspRC_t _cmDspNanoMapSend( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned st, unsigned d0, unsigned d1 )
|
||||
@ -2383,6 +2383,8 @@ cmDspRC_t _cmDspNanoMapSend( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned st, un
|
||||
|
||||
void _cmDspNanoMapPgm( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned pgm )
|
||||
{
|
||||
cmDspNanoMap_t* p = (cmDspNanoMap_t*)inst;
|
||||
|
||||
unsigned i;
|
||||
|
||||
for(i=0; i<kMidiChCnt; ++i)
|
||||
@ -2428,7 +2430,7 @@ cmDspRC_t _cmDspNanoMapReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
|
||||
|
||||
cmDspRC_t _cmDspNanoMapRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
|
||||
{
|
||||
//cmDspNanoMap_t* p = (cmDspNanoMap_t*)inst;
|
||||
cmDspNanoMap_t* p = (cmDspNanoMap_t*)inst;
|
||||
|
||||
switch( evt->dstVarId )
|
||||
{
|
||||
@ -2447,6 +2449,7 @@ cmDspRC_t _cmDspNanoMapRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t
|
||||
status = (status & 0xf0) + ch;
|
||||
cmDspSetUInt(ctx,inst,kStatusNmId,status);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
@ -2485,6 +2488,7 @@ enum
|
||||
kMaxLaSecsPrId,
|
||||
kCurLaSecsPrId,
|
||||
kFadeRatePrId,
|
||||
kScInitLocIdxPrId,
|
||||
kScLocIdxPrId,
|
||||
kCmdPrId,
|
||||
kInAudioBasePrId
|
||||
@ -2501,9 +2505,83 @@ typedef struct
|
||||
unsigned offSymId;
|
||||
unsigned audioOutBaseId;
|
||||
unsigned chCnt;
|
||||
unsigned scLocIdx;
|
||||
//unsigned scLocIdx;
|
||||
} cmDspRecdPlay_t;
|
||||
|
||||
cmDspRC_t _cmDspRecdPlayParseRsrc( cmDspCtx_t* ctx, cmDspInst_t* inst, cmRecdPlay* rcdply )
|
||||
{
|
||||
cmDspRC_t rc = kOkDspRC;
|
||||
const cmChar_t* path = NULL;
|
||||
|
||||
// read the 'recdplay' audio file path
|
||||
if( cmDspRsrcString( ctx->dspH, &path, "recdPlayPath", NULL ) != kOkDspRC )
|
||||
{
|
||||
cmDspInstErr(ctx,inst,kRsrcNotFoundDspRC,"The 'recdPlayPath' resource string was not found.");
|
||||
}
|
||||
|
||||
if( path == NULL )
|
||||
path = "";
|
||||
|
||||
cmJsonH_t jsH = cmDspSysPgmRsrcHandle(ctx->dspH);
|
||||
cmJsonNode_t* jnp = cmJsonFindValue(jsH,"recdPlay",NULL, kArrayTId);
|
||||
|
||||
if( jnp == NULL || cmJsonIsArray(jnp)==false )
|
||||
{
|
||||
// this is really a warning - the object does not require preloaded segments.
|
||||
cmDspInstErr(ctx,inst,kRsrcNotFoundDspRC,"The 'recdPlay' resource used to define pre-loaded segments was not found.");
|
||||
return kOkDspRC;
|
||||
}
|
||||
|
||||
unsigned n = cmJsonChildCount(jnp);
|
||||
unsigned i;
|
||||
|
||||
// for each 'recdplay' segment record
|
||||
for(i=0; i<n && rc==kOkDspRC; ++i)
|
||||
{
|
||||
cmJsonNode_t* cnp = cmJsonArrayElement(jnp,i);
|
||||
const cmChar_t* label = NULL;
|
||||
unsigned segSymId = cmInvalidId;
|
||||
const cmChar_t* errLabel = NULL;
|
||||
const cmChar_t* fn = NULL;
|
||||
|
||||
// read the ith segment record
|
||||
if( cmJsonMemberValues(cnp,&errLabel,
|
||||
"label", kStringTId, &label,
|
||||
"file", kStringTId, &fn,
|
||||
NULL) != kOkJsRC )
|
||||
{
|
||||
rc = cmDspInstErr(ctx,inst,kRsrcNotFoundDspRC,"The record at index %i in the 'recdPlay' pre-loaded segment list could not be parsed.",i);
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
// find or generate the symbol id for the segment label symbol
|
||||
if((segSymId = cmSymTblRegisterSymbol(ctx->stH,label)) == cmInvalidId )
|
||||
{
|
||||
rc = cmDspInstErr(ctx,inst,kSymNotFoundDspRC,"The 'recdPlay' pre-load segment symbol '%s' could not be found or registered.",cmStringNullGuard(label));
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
// create the full path name for the segment audio file
|
||||
if((fn = cmFsMakeFn( path, fn, NULL, NULL )) == NULL )
|
||||
{
|
||||
rc = cmDspInstErr(ctx,inst,kFileSysFailDspRC,"The 'recdPlay' file name '%s/%s' could not be generated.",cmStringNullGuard(path),cmStringNullGuard(fn));
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
|
||||
// pre-load the segment
|
||||
if( cmRecdPlayInsertRecord(rcdply,segSymId,fn) != cmOkRC )
|
||||
rc = cmDspInstErr(ctx,inst,kSubSysFailDspRC,"The 'recdPlay' segment label:'%s' file:'%s' could not be loaded.",cmStringNullGuard(label),cmStringNullGuard(fn));
|
||||
|
||||
|
||||
cmFsFreeFn(fn);
|
||||
|
||||
}
|
||||
|
||||
errLabel:
|
||||
return rc;
|
||||
}
|
||||
|
||||
cmDspRC_t _cmDspRecdPlayOpenScore( cmDspCtx_t* ctx, cmDspInst_t* inst )
|
||||
{
|
||||
cmDspRC_t rc =kOkDspRC;
|
||||
@ -2511,14 +2589,14 @@ cmDspRC_t _cmDspRecdPlayOpenScore( cmDspCtx_t* ctx, cmDspInst_t* inst )
|
||||
|
||||
cmDspRecdPlay_t* p = (cmDspRecdPlay_t*)inst;
|
||||
|
||||
p->scLocIdx = 0;
|
||||
//p->scLocIdx = 0;
|
||||
|
||||
|
||||
if((fn = cmDspStrcz(inst,kFnPrId)) == NULL || strlen(fn)==0 )
|
||||
return cmErrMsg(&inst->classPtr->err, kInvalidArgDspRC, "No score file name supplied.");
|
||||
return cmDspInstErr(ctx,inst, kInvalidArgDspRC, "No score file name supplied.");
|
||||
|
||||
if( cmScoreInitialize(ctx->cmCtx, &p->scH, fn, cmDspSampleRate(ctx), NULL, 0, NULL, NULL, ctx->stH ) != kOkScRC )
|
||||
return cmErrMsg(&inst->classPtr->err, kSubSysFailDspRC, "Unable to open the score '%s'.",fn);
|
||||
return cmDspInstErr(ctx,inst, kSubSysFailDspRC, "Unable to open the score '%s'.",fn);
|
||||
|
||||
if( cmScoreIsValid(p->scH) )
|
||||
{
|
||||
@ -2537,6 +2615,11 @@ cmDspRC_t _cmDspRecdPlayOpenScore( cmDspCtx_t* ctx, cmDspInst_t* inst )
|
||||
for(i=0; i<markerCnt; ++i)
|
||||
cmRecdPlayRegisterFrag(p->rcdply,i, cmScoreMarkerLabelSymbolId(p->scH,i ));
|
||||
|
||||
if((rc = _cmDspRecdPlayParseRsrc(ctx,inst,p->rcdply)) != kOkDspRC )
|
||||
rc = cmDspInstErr(ctx,inst,kInstResetFailDspRC,"The 'recdplay' segment pre-load failed.");
|
||||
|
||||
//p->scLocIdx = cmDspUInt(inst,kScInitLocIdxPrId);
|
||||
|
||||
}
|
||||
|
||||
return rc;
|
||||
@ -2565,6 +2648,7 @@ cmDspInst_t* _cmDspRecdPlayAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
|
||||
1, "maxla", kMaxLaSecsPrId, 0,0, kInDsvFl | kDoubleDsvFl | kReqArgDsvFl, "Maximum look-ahead buffer in seconds.",
|
||||
1, "curla", kCurLaSecsPrId, 0,0, kInDsvFl | kDoubleDsvFl | kOptArgDsvFl, "Current look-head buffer in seconds.",
|
||||
1, "frate", kFadeRatePrId, 0,0, kInDsvFl | kDoubleDsvFl | kOptArgDsvFl, "Fade rate in dB per second.",
|
||||
1, "initIdx",kScInitLocIdxPrId,0,0,kInDsvFl | kUIntDsvFl, "Score search start location.",
|
||||
1, "index", kScLocIdxPrId, 0,0, kInDsvFl | kUIntDsvFl, "Score follower location index.",
|
||||
1, "cmd", kCmdPrId, 0,0, kInDsvFl | kSymDsvFl, "on=reset off=stop.",
|
||||
chCnt, "in", kInAudioBasePrId,0,1, kInDsvFl | kAudioBufDsvFl, "Audio input",
|
||||
@ -2577,7 +2661,7 @@ cmDspInst_t* _cmDspRecdPlayAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
|
||||
p->offSymId = cmSymTblId(ctx->stH,"off");
|
||||
p->audioOutBaseId = audioOutBase;
|
||||
p->chCnt = chCnt;
|
||||
p->scLocIdx = 0;
|
||||
//p->scLocIdx = 0;
|
||||
|
||||
printf("0 max la secs:%f\n",cmDspDouble(&p->inst,kMaxLaSecsPrId));
|
||||
|
||||
@ -2585,10 +2669,13 @@ cmDspInst_t* _cmDspRecdPlayAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
|
||||
cmDspSetDefaultDouble(ctx,&p->inst, kMaxLaSecsPrId,0.0, 2.0);
|
||||
cmDspSetDefaultDouble(ctx,&p->inst, kCurLaSecsPrId,0.0, 0.1);
|
||||
cmDspSetDefaultDouble(ctx,&p->inst, kFadeRatePrId, 0.0, 1.0);
|
||||
cmDspSetDefaultUInt( ctx,&p->inst, kScInitLocIdxPrId,0,0);
|
||||
|
||||
printf("1 max la secs:%f\n",cmDspDouble(&p->inst,kMaxLaSecsPrId));
|
||||
|
||||
|
||||
|
||||
|
||||
return &p->inst;
|
||||
}
|
||||
|
||||
@ -2670,7 +2757,7 @@ cmDspRC_t _cmDspRecdPlayRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
|
||||
{
|
||||
printf("rewind\n");
|
||||
cmRecdPlayRewind(p->rcdply);
|
||||
p->scLocIdx = 0;
|
||||
//p->scLocIdx = cmDspUInt(inst,kScInitLocIdxPrId);
|
||||
}
|
||||
else
|
||||
if( cmDspSymbol(inst,kCmdPrId) == p->offSymId )
|
||||
@ -2683,49 +2770,57 @@ cmDspRC_t _cmDspRecdPlayRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
|
||||
cmRecdPlaySetLaSecs(p->rcdply, cmDspDouble(inst,kCurLaSecsPrId));
|
||||
break;
|
||||
|
||||
case kScInitLocIdxPrId:
|
||||
printf("init-idx:%i\n",cmDspUInt(inst,kScInitLocIdxPrId));
|
||||
break;
|
||||
|
||||
case kScLocIdxPrId:
|
||||
{
|
||||
unsigned endScLocIdx = cmDspUInt(inst,kScLocIdxPrId) ;
|
||||
unsigned endScLocIdx = cmDspUInt(inst,kScLocIdxPrId);
|
||||
|
||||
for(; p->scLocIdx<=endScLocIdx; p->scLocIdx+=1)
|
||||
{
|
||||
cmScoreLoc_t* loc = cmScoreLoc(p->scH, p->scLocIdx );
|
||||
cmScoreMarker_t* mp = loc->markList;
|
||||
if( endScLocIdx < cmDspUInt(inst,kScInitLocIdxPrId) )
|
||||
break;
|
||||
|
||||
for(; mp!=NULL; mp=mp->link)
|
||||
switch( mp->markTypeId )
|
||||
{
|
||||
case kRecdBegScMId:
|
||||
printf("recd-beg\n");
|
||||
cmRecdPlayBeginRecord(p->rcdply, mp->labelSymId );
|
||||
break;
|
||||
cmScoreLoc_t* loc = cmScoreLoc(p->scH, endScLocIdx );
|
||||
if( loc == NULL )
|
||||
break;
|
||||
|
||||
case kRecdEndScMId:
|
||||
printf("recd-end\n");
|
||||
cmRecdPlayEndRecord(p->rcdply, mp->labelSymId );
|
||||
break;
|
||||
cmScoreMarker_t* mp = loc->markList;
|
||||
|
||||
case kPlayBegScMId:
|
||||
printf("play-beg\n");
|
||||
cmRecdPlayBeginPlay(p->rcdply, mp->labelSymId );
|
||||
break;
|
||||
for(; mp!=NULL; mp=mp->link)
|
||||
switch( mp->markTypeId )
|
||||
{
|
||||
case kRecdBegScMId:
|
||||
printf("recd-beg %s\n",cmSymTblLabel(ctx->stH,mp->labelSymId));
|
||||
cmRecdPlayBeginRecord(p->rcdply, mp->labelSymId );
|
||||
break;
|
||||
|
||||
case kPlayEndScMId:
|
||||
printf("play-end\n");
|
||||
cmRecdPlayEndPlay(p->rcdply, mp->labelSymId );
|
||||
break;
|
||||
case kRecdEndScMId:
|
||||
printf("recd-end %s\n",cmSymTblLabel(ctx->stH,mp->labelSymId));
|
||||
cmRecdPlayEndRecord(p->rcdply, mp->labelSymId );
|
||||
break;
|
||||
|
||||
case kFadeScMId:
|
||||
printf("fade-beg\n");
|
||||
cmRecdPlayBeginFade(p->rcdply, mp->labelSymId, cmDspDouble(inst,kFadeRatePrId) );
|
||||
break;
|
||||
case kPlayBegScMId:
|
||||
printf("play-beg\n");
|
||||
cmRecdPlayBeginPlay(p->rcdply, mp->labelSymId );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
case kPlayEndScMId:
|
||||
printf("play-end\n");
|
||||
cmRecdPlayEndPlay(p->rcdply, mp->labelSymId );
|
||||
break;
|
||||
|
||||
p->scLocIdx = endScLocIdx+1;
|
||||
case kFadeScMId:
|
||||
printf("fade-beg\n");
|
||||
cmRecdPlayBeginFade(p->rcdply, mp->labelSymId, cmDspDouble(inst,kFadeRatePrId) );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//p->scLocIdx = endScLocIdx+1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -61,8 +61,6 @@ cmDspRC_t krLoadRsrc(cmDspSysH_t h, cmErr_t* err, krRsrc_t* r)
|
||||
cmDspRsrcString(h,&r->midiDevice, "midiDevice", NULL);
|
||||
cmDspRsrcString(h,&r->midiOutPort, "midiOutPort", NULL);
|
||||
|
||||
|
||||
|
||||
if((rc = cmDspSysLastRC(h)) != kOkDspRC )
|
||||
cmErrMsg(err,rc,"A KR DSP resource load failed.");
|
||||
|
||||
@ -363,7 +361,8 @@ cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr )
|
||||
cmCtx_t* cmCtx = cmDspSysPgmCtx(h);
|
||||
cmErr_t err;
|
||||
krRsrc_t r;
|
||||
bool fragFl = false;
|
||||
bool fragFl = true;
|
||||
bool useWtFl = false;
|
||||
unsigned wtLoopCnt = 1; // 1=play once (-1=loop forever)
|
||||
unsigned wtInitMode = 0; // initial wt mode is 'silence'
|
||||
unsigned wtSmpCnt = floor(cmDspSysSampleRate(h)); // wt length == srate
|
||||
@ -398,7 +397,7 @@ cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr )
|
||||
cmDspInst_t* mop = cmDspSysAllocInst(h,"MidiOut", NULL, 2, r.midiDevice,r.midiOutPort);
|
||||
cmDspInst_t* sfp = cmDspSysAllocInst(h,"ScFol", NULL, 1, r.scFn, sfBufCnt, sfMaxWndCnt, sfMinVel, sfEnaMeasFl );
|
||||
cmDspInst_t* amp = cmDspSysAllocInst(h,"ActiveMeas", NULL, 1, 100 );
|
||||
cmDspInst_t* rpp = cmDspSysAllocInst(h,"RecdPlay", NULL, 6, 2, r.scFn, recdPlayInitAllocSecs, recdPlayMaxLaSecs, recdPlayCurLaSecs, recdPlayFadeRateDbPerSec );
|
||||
cmDspInst_t* rpp = cmDspSysAllocInst(h,"RecdPlay", NULL, 6, 2, r.scFn, recdPlayInitAllocSecs, recdPlayMaxLaSecs, recdPlayCurLaSecs, recdPlayFadeRateDbPerSec);
|
||||
cmDspInst_t* modp = cmDspSysAllocInst(h,"ScMod", NULL, 2, r.modFn, "m1" );
|
||||
cmDspInst_t* modr = cmDspSysAllocInst(h,"ScMod", NULL, 2, r.modFn, "m1" );
|
||||
|
||||
@ -498,21 +497,22 @@ cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr )
|
||||
// Audio connections
|
||||
cmDspSysConnectAudio(h, php, "out", wtp, "phs" ); // phs -> wt
|
||||
|
||||
cmDspSysConnectAudio(h, wtp, "out", au0Sw, "a-in-0" ); // wt -> sw
|
||||
|
||||
/*
|
||||
cmDspSysConnectAudio(h, ai0p, "out", au0Sw, "a-in-1" ); // ain -> sw
|
||||
cmDspSysConnectAudio(h, ai0p, "out", mi0p, "in" );
|
||||
cmDspSysConnectAudio(h, au0Sw, "a-out", rpp, "in-0"); // sw -> rcdply
|
||||
cmDspSysConnectAudio(h, au0Sw, "a-out", c0.kr0,"in" ); // sw -> kr
|
||||
cmDspSysConnectAudio(h, au0Sw, "a-out", c0.kr1,"in" ); // sw -> kr
|
||||
*/
|
||||
|
||||
|
||||
cmDspSysConnectAudio(h, ai0p, "out", rpp, "in-0"); // sw -> rcdply
|
||||
cmDspSysConnectAudio(h, ai0p, "out", c0.kr0, "in" ); // ain -> sw
|
||||
cmDspSysConnectAudio(h, ai0p, "out", c0.kr1, "in" ); // ain -> sw
|
||||
cmDspSysConnectAudio(h, ai0p, "out", mi0p, "in" );
|
||||
if( useWtFl )
|
||||
{
|
||||
cmDspSysConnectAudio(h, wtp, "out", au0Sw, "a-in-0" ); // wt -> sw
|
||||
cmDspSysConnectAudio(h, ai0p, "out", au0Sw, "a-in-1" ); // ain -> sw
|
||||
cmDspSysConnectAudio(h, ai0p, "out", mi0p, "in" );
|
||||
cmDspSysConnectAudio(h, au0Sw, "a-out", rpp, "in-0"); // sw -> rcdply
|
||||
cmDspSysConnectAudio(h, au0Sw, "a-out", c0.kr0,"in" ); // sw -> kr
|
||||
cmDspSysConnectAudio(h, au0Sw, "a-out", c0.kr1,"in" ); // sw -> kr
|
||||
}
|
||||
else
|
||||
{
|
||||
cmDspSysConnectAudio(h, ai0p, "out", rpp, "in-0"); // sw -> rcdply
|
||||
cmDspSysConnectAudio(h, ai0p, "out", c0.kr0, "in" ); // ain -> sw
|
||||
cmDspSysConnectAudio(h, ai0p, "out", c0.kr1, "in" ); // ain -> sw
|
||||
cmDspSysConnectAudio(h, ai0p, "out", mi0p, "in" );
|
||||
}
|
||||
|
||||
if( fragFl )
|
||||
{
|
||||
@ -525,22 +525,26 @@ cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr )
|
||||
else
|
||||
{
|
||||
cmDspSysConnectAudio(h, c0.cmp, "out", ao0p, "in" );
|
||||
//cmDspSysConnectAudio(h, wtp, "out", ao0p, "in" );
|
||||
}
|
||||
|
||||
|
||||
cmDspSysConnectAudio(h, wtp, "out", au1Sw, "a-in-0" ); // wt -> sw
|
||||
/*
|
||||
cmDspSysConnectAudio(h, ai1p, "out", au1Sw, "a-in-1" ); // ain -> sw
|
||||
cmDspSysConnectAudio(h, ai1p, "out", mi1p, "in" );
|
||||
cmDspSysConnectAudio(h, au1Sw, "a-out", rpp, "in-1"); // sw -> rcdply
|
||||
cmDspSysConnectAudio(h, au1Sw, "a-out", c1.kr0,"in" ); // sw -> kr
|
||||
cmDspSysConnectAudio(h, au1Sw, "a-out", c1.kr1,"in" ); // sw -> kr
|
||||
*/
|
||||
|
||||
cmDspSysConnectAudio(h, ai1p, "out", rpp, "in-1"); // sw -> rcdply
|
||||
cmDspSysConnectAudio(h, ai1p, "out", c1.kr0, "in" ); // ain -> sw
|
||||
cmDspSysConnectAudio(h, ai1p, "out", c1.kr1, "in" ); // ain -> sw
|
||||
cmDspSysConnectAudio(h, ai1p, "out", mi1p, "in" );
|
||||
if( useWtFl )
|
||||
{
|
||||
cmDspSysConnectAudio(h, wtp, "out", au1Sw, "a-in-0" ); // wt -> sw
|
||||
cmDspSysConnectAudio(h, ai1p, "out", au1Sw, "a-in-1" ); // ain -> sw
|
||||
cmDspSysConnectAudio(h, ai1p, "out", mi1p, "in" );
|
||||
cmDspSysConnectAudio(h, au1Sw, "a-out", rpp, "in-1"); // sw -> rcdply
|
||||
cmDspSysConnectAudio(h, au1Sw, "a-out", c1.kr0,"in" ); // sw -> kr
|
||||
cmDspSysConnectAudio(h, au1Sw, "a-out", c1.kr1,"in" ); // sw -> kr
|
||||
}
|
||||
else
|
||||
{
|
||||
cmDspSysConnectAudio(h, ai1p, "out", rpp, "in-1"); // sw -> rcdply
|
||||
cmDspSysConnectAudio(h, ai1p, "out", c1.kr0, "in" ); // ain -> sw
|
||||
cmDspSysConnectAudio(h, ai1p, "out", c1.kr1, "in" ); // ain -> sw
|
||||
cmDspSysConnectAudio(h, ai1p, "out", mi1p, "in" );
|
||||
}
|
||||
|
||||
if( fragFl )
|
||||
{
|
||||
@ -553,6 +557,8 @@ cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr )
|
||||
else
|
||||
{
|
||||
cmDspSysConnectAudio(h, c1.cmp, "out", ao1p, "in" ); // cmp -> mix 0
|
||||
//cmDspSysConnectAudio(h, wtp, "out", ao1p, "in" );
|
||||
|
||||
}
|
||||
|
||||
cmDspSysConnectAudio(h, c0.cmp, "out", afop, "in0" ); // comp -> audio_file_out
|
||||
@ -689,7 +695,8 @@ cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr )
|
||||
cmDspSysInstallCb(h, scp, "sel", sfp, "index", NULL );
|
||||
cmDspSysInstallCb(h, scp, "sel", modp,"reset", NULL );
|
||||
cmDspSysInstallCb(h, scp, "sel", modr,"reset", NULL );
|
||||
|
||||
cmDspSysInstallCb(h, scp, "sel", rpp, "initIdx", NULL );
|
||||
cmDspSysInstallCb(h, scp, "sel", prp, "in", NULL );
|
||||
//cmDspSysInstallCb(h, reload,"out", modp, "reload", NULL );
|
||||
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "cmPrefix.h"
|
||||
#include "cmGlobal.h"
|
||||
#include "cmRpt.h"
|
||||
#include "cmTime.h"
|
||||
#include "cmAudioPort.h"
|
||||
#include "cmMem.h"
|
||||
#include "cmMallocDebug.h"
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "cmCtx.h"
|
||||
#include "cmMem.h"
|
||||
#include "cmMallocDebug.h"
|
||||
#include "cmTime.h"
|
||||
#include "cmMidi.h"
|
||||
#include "cmMidiPort.h"
|
||||
|
||||
@ -507,7 +508,7 @@ void _cmMpMIDISystemReadProc( const MIDIPacketList *pktListPtr, void* readProcRe
|
||||
|
||||
double nano = 1e-9 * ( (double) _cmMpRoot.timeBaseInfo.numer) / ((double) _cmMpRoot.timeBaseInfo.denom);
|
||||
|
||||
// so here's the delta in nanoseconds:
|
||||
// so here's the timestamp in nanoseconds:
|
||||
double nanoSeconds = ((double) packetPtr->timeStamp) * nano;
|
||||
|
||||
// 1000 times that for microSeconds:
|
||||
@ -516,13 +517,17 @@ void _cmMpMIDISystemReadProc( const MIDIPacketList *pktListPtr, void* readProcRe
|
||||
// BUG BUG BUG: How can multiplying the nanoseconds produce microseconds?
|
||||
// Shouldn't the nano to micro conversion be a divide?
|
||||
|
||||
double deltaMicroSecs = microSecs - pp->prevMicroSecs;
|
||||
//double deltaMicroSecs = microSecs - pp->prevMicroSecs;
|
||||
|
||||
pp->prevMicroSecs = microSecs;
|
||||
|
||||
cmTimeSpec_t ts;
|
||||
ts.tv_sec = floor(microSecs / 1000000.0);
|
||||
ts.tv_nsec = (microSecs - ts.tv_sec * 1000000.0) * 1000.0;
|
||||
|
||||
assert( pp->inputFl == true );
|
||||
|
||||
cmMpParseMidiData( pp->parserH, (unsigned)deltaMicroSecs, packetPtr->data, packetPtr->length );
|
||||
cmMpParseMidiData( pp->parserH, &ts, packetPtr->data, packetPtr->length );
|
||||
|
||||
packetPtr = MIDIPacketNext(packetPtr);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user