Many changes to add score/performance feedback to GUI

This commit is contained in:
kevin 2012-12-13 15:38:45 -08:00
parent 4c8b5915ad
commit e9c4d0edd2
8 changed files with 851 additions and 421 deletions

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,8 @@ extern "C" {
kCsvFailScRC,
kSyntaxErrScRC,
kInvalidIdxScRC,
kTimeLineFailScRC
kTimeLineFailScRC,
kInvalidDynRefCntScRC
};
@ -32,6 +33,7 @@ extern "C" {
kNonEvtScId
};
// Flags used by cmScoreEvt_t.flags
enum
{
kEvenScFl = 0x01, // This note is marked for evenness measurement
@ -41,17 +43,31 @@ extern "C" {
kInvalidScFl = 0x10 // This note has a calculated time
};
// Id's used by cmScoreSet_t.varId and as indexes into
// cmScoreSection_t.vars[].
enum
{
kEvenVarScId,
kDynVarScId,
kTempoVarScId,
kScVarCnt
};
struct cmScoreLoc_str;
struct cmScoreSet_str;
// The score can be divided into arbitrary non-overlapping sections.
typedef struct
{
const cmChar_t* label; // section label
struct cmScoreLoc_str* locPtr; // location where this section starts
unsigned begIndex; // score element index where this section starts
double evenCoeff; //
double dynCoeff; //
double tempoCeoff; //
const cmChar_t* label; // section label
unsigned index; // index of this record in the internal section array
struct cmScoreLoc_str* locPtr; // location where this section starts
unsigned begEvtIndex; // score element index where this section starts
unsigned setCnt; // Count of elements in setArray[]
struct cmScoreSet_str** setArray; // Ptrs to sets which are applied to this section.
double vars[ kScVarCnt ]; // Set to DBL_MAX by default.
} cmScoreSection_t;
typedef struct
@ -60,6 +76,7 @@ extern "C" {
double secs; // Time location in seconds
double durSecs; // Duration in seconds
unsigned index; // Index of this event in the event array.
unsigned locIdx; // Index of the location containing this event
cmMidiByte_t pitch; // MIDI pitch of this note
unsigned flags; // Attribute flags for this event
unsigned dynVal; // Dynamcis value pppp to ffff (1 to 11) for this note.
@ -68,16 +85,17 @@ extern "C" {
unsigned csvRowNumb; // File row number (not index) from which this record originated
unsigned perfSmpIdx; // Time this event was performed or cmInvalidIdx if the event was not performed.
unsigned perfVel; // Velocity of the performed note or 0 if the note was not performed.
unsigned perfDynLvl; // Index into dynamic level ref. array assoc'd with perfVel
} cmScoreEvt_t;
typedef struct cmScoreSet_str
{
unsigned typeFl; // See kXXXScFl flags above
cmScoreEvt_t** eleArray; // Events that make up this set in time order
unsigned eleCnt; //
cmScoreSection_t** sectArray; // Array of pointers to sections to apply this set to
unsigned sectCnt; //
struct cmScoreSet_str* link; // cmScoreLoc_t setList link
unsigned varId; // See kXXXVarScId flags above
cmScoreEvt_t** eleArray; // Events that make up this set in time order
unsigned eleCnt; //
bool doneFl;
double value;
struct cmScoreSet_str* llink; // cmScoreLoc_t setList link
} cmScoreSet_t;
@ -85,11 +103,12 @@ extern "C" {
// cmScoreLoc_t record.
typedef struct cmScoreLoc_str
{
unsigned index; // index of this location record
double secs; // Time of this location
unsigned evtCnt; // Count of events in evtArray[].
cmScoreEvt_t** evtArray; // Events which occur at this time.
unsigned barNumb; // Bar number this event is contained by.
cmScoreSet_t* setList; // Set's which end on this time location
cmScoreSet_t* setList; // Set's which end on this time location (linked through cmScoreSet_t.llink)
cmScoreSection_t* begSectPtr; // NULL if this location does not start a section
} cmScoreLoc_t;
@ -107,7 +126,11 @@ extern "C" {
// Initialize a score object from a CSV File generated from a score spreadsheet.
cmScRC_t cmScoreInitialize( cmCtx_t* ctx, cmScH_t* hp, const cmChar_t* fn, cmScCb_t cbFunc, void* cbArg );
// The dynRefArray[dynRefCnt] and cbFunc(cbArg) are optional if these
// features are not used.
// If provided the dynRefArray[] is copied into an internal array.
// The physical array passed here therefore does not need to remain valid.
cmScRC_t cmScoreInitialize( cmCtx_t* ctx, cmScH_t* hp, const cmChar_t* fn, const unsigned* dynRefArray, unsigned dynRefCnt, cmScCb_t cbFunc, void* cbArg );
cmScRC_t cmScoreFinalize( cmScH_t* hp );
// Filename of last successfuly loaded score file.
@ -120,6 +143,10 @@ extern "C" {
unsigned cmScoreEvtCount( cmScH_t h );
cmScoreEvt_t* cmScoreEvt( cmScH_t h, unsigned idx );
// Access section records
unsigned cmScoreSectionCount( cmScH_t h );
cmScoreSection_t* cmScoreSection( cmScH_t h, unsigned idx );
// Access the score location data
unsigned cmScoreLocCount( cmScH_t h );
cmScoreLoc_t* cmScoreLoc( cmScH_t h, unsigned idx );
@ -132,21 +159,56 @@ extern "C" {
cmScRC_t cmScoreSeqNotify( cmScH_t h );
void cmScoreClearPerfInfo( cmScH_t h );
void cmScoreSetPerfEvent( cmScH_t h, unsigned locIdx, unsigned smpIdx, unsigned pitch, unsigned vel );
// Assign 'smpIdx' and 'vel' to the event matching 'pitch' at 'locIdx'
// but do not trigger any variable calculations. Return true if as a
// result of this call all events assigned to 'locIdx' have been received
// otherwise return false.
bool cmScoreSetPerfEvent( cmScH_t h, unsigned locIdx, unsigned smpIdx, unsigned pitch, unsigned vel );
// Assign 'smpIdx' and 'vel' to the event matching 'pitch' at 'locIdx'
// but and trigger any variable calculations which may happen on, or before, 'locIdx'.
void cmScoreExecPerfEvent( cmScH_t h, unsigned locIdx, unsigned smpIdx, unsigned pitch, unsigned vel );
// Assign 'value' to the section at, or before, 'locIdx'.
void cmScoreSetPerfValue( cmScH_t h, unsigned locIdx, unsigned varId, double value );
// Set the performed dynamic level of a score event.
void cmScoreSetPerfDynLevel( cmScH_t h, unsigned evtIdx, unsigned dynLvl );
typedef enum
{
kInvalidMsgScId,
kBeginMsgScId,
kEventMsgScId,
kEndMsgScId
kSectionMsgScId,
kEndMsgScId,
kVarMsgScId,
kDynMsgScId
} cmScMsgTypeId_t;
typedef struct
{
unsigned varId; // see kXXXVarScId from cmScoreSet_t.varId
double value; // value of a variable
} cmScMeas_t;
typedef struct
{
unsigned evtIdx;
unsigned dynLvl;
} cmScDyn_t;
typedef struct
{
cmScMsgTypeId_t typeId;
cmScoreEvt_t evt; // only used when typeId == kEventMsgScId
union
{
cmScoreEvt_t evt; // only used when typeId == kEventMsgScId
cmScMeas_t meas; // only used when typeId == kVarMsgScId
cmScoreSection_t sect; // only used when typeId == kSectionMsgScId
cmScDyn_t dyn; // only used when typeId == kDynLvlMsgScId
} u;
} cmScMsg_t;
// Decode a serialized cmScMsg_t from a byte stream as passed to the

View File

@ -47,6 +47,7 @@ typedef struct cmGrPlotObj_str
unsigned fontSize;
unsigned fontStyle;
void* userPtr;
unsigned userByteCnt; // 0 if userPtr does not need to be realease on object destruction
cmGrPlotCbFunc_t cbFunc;
void* cbArg;
@ -102,6 +103,12 @@ cmGrPlRC_t _cmGrPlotObjDelete( cmGrPlotObj_t* op )
if( cmGrObjDestroy( op->grH, &op->grObjH ) != kOkGrRC )
return cmErrMsg( &p->err, kGrFailGrPlRC, "Delete failed on the object label='%s' id=%i\n",cmStringNullGuard( op->label ), cmGrObjId(op->grObjH) );
if( op->userByteCnt != 0 )
{
cmMemFree(op->userPtr);
op->userByteCnt = 0;
}
return kOkGrPlRC;
}
@ -424,12 +431,13 @@ bool _cmGrPlotObjRender( cmGrObjFuncArgs_t* args, cmGrDcH_t dcH )
// expand the ext's according to the physical offsets
cmGrPExtExpand(&pext,op->loffs,op->toffs,op->roffs,op->boffs);
switch( op->typeId )
{
case kLineGrPlId:
cmGrDcSetColor( dcH, _cmGrPlotColor(op,op->drawColors) );
cmGrDcDrawLine( dcH, cmGrPExtL(&pext), cmGrPExtT(&pext), cmGrPExtR(&pext), cmGrPExtB(&pext) );
break;
//cmGrDcSetColor( dcH, _cmGrPlotColor(op,op->drawColors) );
//cmGrDcDrawLine( dcH, cmGrPExtL(&pext), cmGrPExtT(&pext), cmGrPExtR(&pext), cmGrPExtB(&pext) );
//break;
case kStarGrPlId:
case kCrossGrPlId:
@ -476,6 +484,9 @@ bool _cmGrPlotObjRender( cmGrObjFuncArgs_t* args, cmGrDcH_t dcH )
cmGrDcFillRect( dcH, pext.loc.x, pext.loc.y, pext.sz.w, pext.sz.h);
break;
case kLineGrPlId:
break;
default:
{ assert(0); }
}
@ -522,6 +533,9 @@ bool _cmGrPlotObjRender( cmGrObjFuncArgs_t* args, cmGrDcH_t dcH )
cmGrDcDrawLine( dcH, cmGrPExtL(&pext), cmGrPExtT(&pext) + cmGrPExtH(&pext)/2, cmGrPExtR(&pext), cmGrPExtT(&pext) + cmGrPExtH(&pext)/2);
break;
case kLineGrPlId:
cmGrDcDrawLine( dcH, cmGrPExtL(&pext), cmGrPExtT(&pext), cmGrPExtR(&pext), cmGrPExtB(&pext) );
break;
case kRectGrPlId:
case kHLineGrPlId:
@ -884,8 +898,35 @@ void cmGrPlotObjSetId( cmGrPlObjH_t oh, unsigned id )
void cmGrPlotObjSetUserPtr( cmGrPlObjH_t oh, void* userPtr )
{
cmGrPlotObj_t* op = _cmGrPlObjHandleToPtr(oh);
if( op->userByteCnt != 0 )
{
cmMemFree(op->userPtr);
op->userByteCnt = 0;
}
op->userPtr = userPtr;
}
void cmGrPlotObjAllocUser( cmGrPlObjH_t oh, const void* data, unsigned byteCnt )
{
cmGrPlotObj_t* op = _cmGrPlObjHandleToPtr(oh);
if( op->userByteCnt != byteCnt )
{
if( op->userByteCnt != 0 )
{
cmMemFree(op->userPtr);
op->userByteCnt = 0;
}
op->userPtr = cmMemAlloc(char,byteCnt);
op->userByteCnt = byteCnt;
}
memcpy(op->userPtr,data,byteCnt);
}
void* cmGrPlotObjUserPtr( cmGrPlObjH_t oh )
{
cmGrPlotObj_t* op = _cmGrPlObjHandleToPtr(oh);

View File

@ -148,6 +148,7 @@ extern "C" {
unsigned cmGrPlotObjId( cmGrPlObjH_t oh );
void cmGrPlotObjSetUserPtr( cmGrPlObjH_t oh, void* userPtr );
void cmGrPlotObjAllocUser( cmGrPlObjH_t oh, const void* data, unsigned byteCnt );
void* cmGrPlotObjUserPtr( cmGrPlObjH_t oh );
void cmGrPlotObjSetLabel( cmGrPlObjH_t oh, const cmChar_t* label );

View File

@ -31,7 +31,6 @@ extern "C" {
kInstMsgRcvFailDspRC,
kNetSendAllocFailDspRC,
kClassNotFoundDspRC,
kInstNotFoundDspRC,
kDuplInstSymIdDspRC,
@ -60,7 +59,6 @@ extern "C" {
kSerializeUiMsgFailDspRC,
kSendToHostFailDspRC,
kUiEleCreateFailDspRC,
@ -75,7 +73,6 @@ extern "C" {
kInvalidPgmIdxDspRC,
kPgmCfgFailDspRC
};
@ -287,7 +284,7 @@ extern "C" {
// Possible values for cmDspSetXXX()
enum
{
kUpdateUiDspFl = 0x00,
kUpdateUiDspFl = 0x00, //
kNoUpdateUiDspFl = 0x01, // don't callback the UI
kNoAllocDspFl = 0x02, // the caller is handling memory mgmt for the incoming value don't allocate space for it internally
kSetDefaultDspFl = 0x04, // set the var default value rather than the current value
@ -393,7 +390,7 @@ extern "C" {
cmDspRC_t cmDspUiButtonCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned typeDuiId, unsigned outVarId, unsigned lblVarId );
cmDspRC_t cmDspUiLabelCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned lblVarId, unsigned alignVarId );
cmDspRC_t cmDspUiTimeLineCreate(cmDspCtx_t* ctx,cmDspInst_t* inst, unsigned tlFileVarId, unsigned audPathVarId, unsigned selVarId, unsigned cursVarId );
cmDspRC_t cmDspUiScoreCreate( cmDspCtx_t* ctx,cmDspInst_t* inst, unsigned scFileVarId, unsigned selVarId );
cmDspRC_t cmDspUiScoreCreate( cmDspCtx_t* ctx,cmDspInst_t* inst, unsigned scFileVarId, unsigned selVarId, unsigned smpIdxVarId, unsigned pitchVarId, unsigned velVarId, unsigned locIdxVarIdx, unsigned evtIdxVarIdx, unsigned dynLvlVarIdx, unsigned valTypeVarIdx, unsigned valueVarIdx );
cmDspRC_t cmDspUiNewColumn( cmDspCtx_t* ctx, unsigned colW );
cmDspRC_t cmDspUiInsertHorzBorder( cmDspCtx_t* ctx );

View File

@ -21,6 +21,7 @@
#include "cmDspCtx.h"
#include "cmDspClass.h"
#include "cmDspUi.h"
#include "cmDspSys.h"
#include "cmMath.h"
@ -404,7 +405,16 @@ enum
{
kFnScId,
kSelScId,
kSendScId
kSendScId,
kStatusScId,
kD0ScId,
kD1ScId,
kSmpIdxScId,
kLocIdxScId,
kEvtIdxScId,
kDynScId,
kValTypeScId,
kValueScId
};
cmDspClass_t _cmScoreDC;
@ -413,15 +423,25 @@ typedef struct
{
cmDspInst_t inst;
cmScH_t scH;
cmDspCtx_t* ctx; // temporary ctx ptr used during cmScore callback in _cmDspScoreRecv()
} cmDspScore_t;
cmDspInst_t* _cmDspScoreAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned storeSymId, unsigned instSymId, unsigned id, unsigned va_cnt, va_list vl )
{
cmDspVarArg_t args[] =
{
{ "fn", kFnScId, 0, 0, kInDsvFl | kStrzDsvFl | kReqArgDsvFl, "Score file." },
{ "sel", kSelScId, 0, 0, kInDsvFl | kOutDsvFl | kUIntDsvFl, "Selected score element index."},
{ "send", kSendScId, 0, 0, kInDsvFl | kTypeDsvMask, "Resend last selected score element."},
{ "fn", kFnScId, 0, 0, kInDsvFl | kStrzDsvFl | kReqArgDsvFl, "Score file." },
{ "sel", kSelScId, 0, 0, kInDsvFl | kOutDsvFl | kUIntDsvFl, "Selected score element index input."},
{ "send", kSendScId, 0, 0, kInDsvFl | kTypeDsvMask, "Resend last selected score element."},
{ "status", kStatusScId, 0, 0, kInDsvFl | kIntDsvFl, "Performed MIDI status value output" },
{ "d0", kD0ScId, 0, 0, kInDsvFl | kUIntDsvFl, "Performed MIDI msg data byte 0" },
{ "d1", kD1ScId, 0, 0, kInDsvFl | kUIntDsvFl, "Performed MIDI msg data byte 1" },
{ "smpidx", kSmpIdxScId, 0, 0, kInDsvFl | kUIntDsvFl, "Performed MIDi msg time tag as a sample index." },
{ "loc", kLocIdxScId, 0, 0, kInDsvFl | kUIntDsvFl, "Performance score location."},
{ "evtidx", kEvtIdxScId, 0, 0, kOutDsvFl | kUIntDsvFl, "Performed event index of following dynamcis level."},
{ "dyn", kDynScId, 0, 0, kOutDsvFl | kUIntDsvFl, "Dynamic level of previous event index."},
{ "type", kValTypeScId,0, 0, kOutDsvFl | kUIntDsvFl, "Output variable type."},
{ "value", kValueScId, 0, 0, kOutDsvFl | kDoubleDsvFl, "Output variable value."},
{ NULL, 0, 0, 0, 0 }
};
@ -430,7 +450,7 @@ cmDspInst_t* _cmDspScoreAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned
cmDspSetDefaultUInt( ctx, &p->inst, kSelScId, 0, cmInvalidId);
// create the UI control
cmDspUiScoreCreate(ctx,&p->inst,kFnScId,kSelScId);
cmDspUiScoreCreate(ctx,&p->inst,kFnScId,kSelScId,kSmpIdxScId,kD0ScId,kD1ScId,kLocIdxScId,kEvtIdxScId,kDynScId,kValTypeScId,kValueScId);
p->scH = cmScNullHandle;
@ -448,40 +468,94 @@ cmDspRC_t _cmDspScoreFree(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t*
return rc;
}
// Callback from cmScore triggered from _cmDspScoreRecv() during call to cmScoreSetPerfEvent().
void _cmDspScoreCb( void* arg, const void* data, unsigned byteCnt )
{
cmDspInst_t* inst = (cmDspInst_t*)arg;
cmDspScore_t* p = (cmDspScore_t*)inst;
cmScMsg_t m;
if( cmScoreDecode(data,byteCnt,&m) == kOkScRC )
{
switch( m.typeId )
{
case kDynMsgScId:
cmDspSetUInt( p->ctx,inst, kEvtIdxScId, m.u.dyn.evtIdx );
cmDspSetUInt( p->ctx,inst, kDynScId, m.u.dyn.dynLvl );
break;
case kVarMsgScId:
cmDspSetUInt( p->ctx,inst, kValTypeScId, m.u.meas.varId);
cmDspSetDouble(p->ctx,inst, kValueScId, m.u.meas.value);
break;
default:
{ assert(0); }
}
}
}
cmDspRC_t _cmDspScoreReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
{
cmDspRC_t rc = kOkDspRC;
cmDspScore_t* p = (cmDspScore_t*)inst;
cmDspRC_t rc = kOkDspRC;
cmDspScore_t* p = (cmDspScore_t*)inst;
const cmChar_t* tlFn = NULL;
unsigned* dynRefArray = NULL;
unsigned dynRefCnt = 0;
cmDspApplyAllDefaults(ctx,inst);
const cmChar_t* tlFn;
if( cmDspRsrcUIntArray(ctx->dspH, &dynRefCnt, &dynRefArray, "dynRef", NULL ) != kOkDspRC )
{
rc = cmErrMsg(&inst->classPtr->err, kRsrcNotFoundDspRC, "The dynamics reference array resource was not found.");
goto errLabel;
}
if((tlFn = cmDspStrcz(inst, kFnScId )) != NULL )
if( cmScoreInitialize(ctx->cmCtx, &p->scH, tlFn, NULL, NULL ) != kOkTlRC )
if( cmScoreInitialize(ctx->cmCtx, &p->scH, tlFn, dynRefArray, dynRefCnt, _cmDspScoreCb, p ) != kOkTlRC )
rc = cmErrMsg(&inst->classPtr->err, kInstResetFailDspRC, "Score file open failed.");
errLabel:
return rc;
}
cmDspRC_t _cmDspScoreRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
{
cmDspScore_t* p = (cmDspScore_t*)inst;
if( evt->dstVarId == kSendScId )
{
unsigned selIdx;
if((selIdx = cmDspUInt(inst,kSelScId)) != cmInvalidIdx )
{
cmDspSetUInt(ctx,inst,kSelScId, selIdx );
cmScoreClearPerfInfo(p->scH);
}
return kOkDspRC;
}
cmDspSetEvent(ctx,inst,evt);
switch( evt->dstVarId )
{
case kSelScId:
cmDspSetEvent(ctx,inst,evt);
cmScoreClearPerfInfo(p->scH);
break;
case kSendScId:
case kStatusScId:
//printf("st:%x\n",cmDspUInt(inst,kStatusScId));
break;
case kLocIdxScId:
{
unsigned selIdx;
if((selIdx = cmDspUInt(inst,kSelScId)) != cmInvalidIdx )
cmDspSetUInt(ctx,inst,kSelScId, selIdx );
assert( cmDspUInt(inst,kStatusScId ) == kNoteOnMdId );
p->ctx = ctx; // setup p->ctx for use in _cmDspScoreCb()
// this call may result in callbacks to _cmDspScoreCb()
cmScoreExecPerfEvent(p->scH, cmDspUInt(inst,kLocIdxScId), cmDspUInt(inst,kSmpIdxScId), cmDspUInt(inst,kD0ScId), cmDspUInt(inst,kD1ScId) );
}
break;
default:
{assert(0);}
}
return kOkDspRC;
@ -619,6 +693,7 @@ cmDspRC_t _cmDspMidiFilePlayOpen(cmDspCtx_t* ctx, cmDspInst_t* inst )
// convert midi msg times to absolute time in samples
cmMidiFileTickToSamples(p->mfH,cmDspSampleRate(ctx),true);
}
return rc;
}
@ -716,6 +791,7 @@ enum
kD0SfId,
kD1SfId,
kSmpIdxSfId,
kCmdSfId,
kOutSfId
};
@ -724,8 +800,10 @@ cmDspClass_t _cmScFolDC;
typedef struct
{
cmDspInst_t inst;
cmScFol* sfp;
cmScTrk* sfp;
cmScH_t scH;
unsigned printSymId;
unsigned quietSymId;
} cmDspScFol_t;
cmDspInst_t* _cmDspScFolAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned storeSymId, unsigned instSymId, unsigned id, unsigned va_cnt, va_list vl )
@ -742,6 +820,7 @@ cmDspInst_t* _cmDspScFolAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned
{ "d0", kD0SfId, 0, 0, kInDsvFl | kUIntDsvFl, "MIDI data byte 0"},
{ "d1", kD1SfId, 0, 0, kInDsvFl | kUIntDsvFl, "MIDI data byte 1"},
{ "smpidx",kSmpIdxSfId, 0, 0, kInDsvFl | kUIntDsvFl, "MIDI time tag as a sample index"},
{ "cmd", kCmdSfId, 0, 0, kInDsvFl | kSymDsvFl, "Command input: print | quiet"},
{ "out", kOutSfId, 0, 0, kOutDsvFl| kUIntDsvFl, "Current score index."},
{ NULL, 0, 0, 0, 0, NULL }
};
@ -752,7 +831,9 @@ cmDspInst_t* _cmDspScFolAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned
return NULL;
p->sfp = cmScFolAlloc(ctx->cmProcCtx, NULL, 0, cmScNullHandle, 0, 0, 0, 0 );
p->sfp = cmScTrkAlloc(ctx->cmProcCtx, NULL, 0, cmScNullHandle, 0, 0, 0, 0 );
p->printSymId = cmSymTblRegisterStaticSymbol(ctx->stH,"print");
p->quietSymId = cmSymTblRegisterStaticSymbol(ctx->stH,"quiet");
cmDspSetDefaultUInt( ctx, &p->inst, kBufCntSfId, 0, 7);
cmDspSetDefaultUInt( ctx, &p->inst, kMinLkAhdSfId, 0, 10);
@ -760,6 +841,7 @@ cmDspInst_t* _cmDspScFolAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned
cmDspSetDefaultUInt( ctx, &p->inst, kMinVelSfId, 0, 5);
cmDspSetDefaultUInt( ctx, &p->inst, kIndexSfId, 0, 0);
cmDspSetDefaultUInt( ctx, &p->inst, kOutSfId, 0, 0);
cmDspSetDefaultSymbol(ctx,&p->inst, kCmdSfId, p->quietSymId );
return &p->inst;
}
@ -767,23 +849,33 @@ cmDspInst_t* _cmDspScFolAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned
cmDspRC_t _cmDspScFolFree(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
{
cmDspScFol_t* p = (cmDspScFol_t*)inst;
cmScFolFree(&p->sfp);
cmScTrkFree(&p->sfp);
cmScoreFinalize(&p->scH);
return kOkDspRC;
}
cmDspRC_t _cmDspScFolOpenScore( cmDspCtx_t* ctx, cmDspInst_t* inst )
{
cmDspRC_t rc = kOkDspRC;
cmDspScFol_t* p = (cmDspScFol_t*)inst;
unsigned* dynRefArray = NULL;
unsigned dynRefCnt = 0;
const cmChar_t* fn;
cmDspScFol_t* p = (cmDspScFol_t*)inst;
if((fn = cmDspStrcz(inst,kFnSfId)) == NULL || strlen(fn)==0 )
return cmErrMsg(&inst->classPtr->err, kInvalidArgDspRC, "No score file name supplied.");
if( cmScoreInitialize(ctx->cmCtx, &p->scH, fn, NULL, NULL ) != kOkScRC )
if( cmDspRsrcUIntArray(ctx->dspH, &dynRefCnt, &dynRefArray, "dynRef", NULL ) != kOkDspRC )
{
rc = cmErrMsg(&inst->classPtr->err, kRsrcNotFoundDspRC, "The dynamics reference array resource was not found.");
goto errLabel;
}
if( cmScoreInitialize(ctx->cmCtx, &p->scH, fn, NULL, 0, NULL, NULL ) != kOkScRC )
return cmErrMsg(&inst->classPtr->err, kSubSysFailDspRC, "Unable to open the score '%s'.",fn);
return kOkDspRC;
errLabel:
return rc;
}
cmDspRC_t _cmDspScFolReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
@ -796,7 +888,7 @@ cmDspRC_t _cmDspScFolReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t*
return rc;
if( cmScoreIsValid(p->scH) )
if( cmScFolInit(p->sfp, cmDspSampleRate(ctx), p->scH, cmDspUInt(inst,kBufCntSfId), cmDspUInt(inst,kMinLkAhdSfId), cmDspUInt(inst,kMaxWndCntSfId), cmDspUInt(inst,kMinVelSfId) ) != cmOkRC )
if( cmScTrkInit(p->sfp, cmDspSampleRate(ctx), p->scH, cmDspUInt(inst,kBufCntSfId), cmDspUInt(inst,kMinLkAhdSfId), cmDspUInt(inst,kMaxWndCntSfId), cmDspUInt(inst,kMinVelSfId) ) != cmOkRC )
rc = cmErrMsg(&inst->classPtr->err, kSubSysFailDspRC, "Internal score follower allocation failed.");
return rc;
@ -814,14 +906,14 @@ cmDspRC_t _cmDspScFolRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t*
{
case kIndexSfId:
if( cmScoreIsValid(p->scH) )
if( cmScFolReset( p->sfp, cmDspUInt(inst,kIndexSfId) ) != cmOkRC )
if( cmScTrkReset( p->sfp, cmDspUInt(inst,kIndexSfId) ) != cmOkRC )
cmErrMsg(&inst->classPtr->err, kSubSysFailDspRC, "Score follower reset to score index '%i' failed.");
break;
case kStatusSfId:
if( cmScoreIsValid(p->scH))
{
unsigned idx = cmScFolExec(p->sfp, ctx->cycleCnt, cmDspUInt(inst,kStatusSfId), cmDspUInt(inst,kD0SfId), cmDspUInt(inst,kD1SfId));
unsigned idx = cmScTrkExec(p->sfp, ctx->cycleCnt, cmDspUInt(inst,kStatusSfId), cmDspUInt(inst,kD0SfId), cmDspUInt(inst,kD1SfId));
if( idx != cmInvalidIdx )
cmDspSetUInt(ctx,inst,kOutSfId,idx);
}
@ -830,6 +922,15 @@ cmDspRC_t _cmDspScFolRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t*
case kFnSfId:
_cmDspScFolOpenScore(ctx,inst);
break;
case kCmdSfId:
if( cmDspSymbol(inst,kCmdSfId) == p->printSymId )
p->sfp->printFl = true;
else
if( cmDspSymbol(inst,kCmdSfId) == p->quietSymId )
p->sfp->printFl = false;
break;
}
}

View File

@ -86,10 +86,11 @@ cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr )
cmDspSysNewPage(h,"Controls");
cmDspInst_t* onb = cmDspSysAllocInst(h,"Button", "start", 2, kButtonDuiId, 1.0 );
cmDspInst_t* offb = cmDspSysAllocInst(h,"Button", "stop", 2, kButtonDuiId, 1.0 );
cmDspInst_t* prp = cmDspSysAllocInst(h,"Printer", NULL, 1, ">" );
cmDspInst_t* prtb = cmDspSysAllocInst(h,"Button", "print", 2, kButtonDuiId, 1.0 );
cmDspInst_t* qtb = cmDspSysAllocInst(h,"Button", "quiet", 2, kButtonDuiId, 1.0 );
cmDspInst_t* prp = cmDspSysAllocInst(h,"Printer", NULL, 1, ">" );
//cmDspInst_t* prd = cmDspSysAllocInst(h,"Printer", NULL, 1, "DYN:" );
//cmDspInst_t* pre = cmDspSysAllocInst(h,"Printer", NULL, 1, "EVEN:" );
if((rc = cmDspSysLastRC(h)) != kOkDspRC )
return rc;
@ -125,14 +126,23 @@ cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr )
cmDspSysInstallCb(h, tlp, "mesi", mfp, "esi", NULL );
cmDspSysInstallCb(h, tlp, "mfn", mfp, "fn", NULL );
// score to score follower
// score to score follower - to set initial search location
cmDspSysInstallCb(h, scp, "sel", sfp, "index", NULL );
// MIDI file player to score-follower
cmDspSysInstallCb(h, mfp, "status", sfp, "status", NULL );
cmDspSysInstallCb(h, mfp, "d0", sfp, "d0", NULL );
// MIDI file player to score-follower and score - the order of connections is the same
// as the msg transmision order from MFP
cmDspSysInstallCb(h, mfp, "smpidx", scp, "smpidx", NULL );
cmDspSysInstallCb(h, mfp, "d1", scp, "d1", NULL );
cmDspSysInstallCb(h, mfp, "d1", sfp, "d1", NULL );
cmDspSysInstallCb(h, mfp, "d0", scp, "d0", NULL );
cmDspSysInstallCb(h, mfp, "d0", sfp, "d0", NULL );
cmDspSysInstallCb(h, mfp, "status", scp, "status", NULL );
cmDspSysInstallCb(h, mfp, "status", sfp, "status", NULL );
// score follower to score
cmDspSysInstallCb(h, sfp, "out", scp, "loc", NULL );
// Printer connections
@ -141,6 +151,11 @@ cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr )
cmDspSysInstallCb(h, tlp, "sel", prp, "in", NULL );
//cmDspSysInstallCb(h, sfp, "out", prp, "in", NULL );
//cmDspSysInstallCb(h, scp, "even", pre, "in", NULL );
//cmDspSysInstallCb(h, scp, "dyn", prd, "in", NULL );
cmDspSysInstallCb(h, prtb, "sym", sfp, "cmd", NULL );
cmDspSysInstallCb(h, qtb, "sym", sfp, "cmd", NULL );
return rc;
}

View File

@ -386,10 +386,10 @@ cmDspRC_t cmDspUiTimeLineCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned
return rc;
}
cmDspRC_t cmDspUiScoreCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned scFileVarId, unsigned selVarId )
cmDspRC_t cmDspUiScoreCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned scFileVarId, unsigned selVarId, unsigned smpIdxVarId, unsigned pitchVarId, unsigned velVarId, unsigned locIdxVarId, unsigned evtIdxVarId, unsigned dynVarId, unsigned valTypeVarId, unsigned valueVarId )
{
cmDspRC_t rc;
unsigned arr[] = { scFileVarId, selVarId };
unsigned arr[] = { scFileVarId, selVarId, smpIdxVarId, pitchVarId, velVarId, locIdxVarId, evtIdxVarId, dynVarId, valTypeVarId, valueVarId };
cmDspValue_t v;
unsigned vn = sizeof(arr)/sizeof(arr[0]);
cmDsvSetUIntMtx(&v,arr,vn,1);
@ -402,6 +402,15 @@ cmDspRC_t cmDspUiScoreCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned scFi
// Setting this flag will cause their values to be sent to the UI whenever they change.
cmDspInstVarSetFlags( ctx, inst, scFileVarId, kUiDsvFl );
cmDspInstVarSetFlags( ctx, inst, selVarId, kUiDsvFl );
cmDspInstVarSetFlags( ctx, inst, smpIdxVarId, kUiDsvFl );
cmDspInstVarSetFlags( ctx, inst, pitchVarId, kUiDsvFl );
cmDspInstVarSetFlags( ctx, inst, velVarId, kUiDsvFl );
cmDspInstVarSetFlags( ctx, inst, locIdxVarId, kUiDsvFl );
cmDspInstVarSetFlags( ctx, inst, evtIdxVarId, kUiDsvFl );
cmDspInstVarSetFlags( ctx, inst, dynVarId, kUiDsvFl );
cmDspInstVarSetFlags( ctx, inst, valTypeVarId, kUiDsvFl );
cmDspInstVarSetFlags( ctx, inst, valueVarId, kUiDsvFl );
return rc;
}