cmScore.h/c : Added csvEventId to hold the CSV file 'evt' column value.

This commit is contained in:
kevin 2016-03-02 18:51:51 -05:00
parent 4c4b9e878a
commit 63fff58dd8
2 changed files with 11 additions and 5 deletions

View File

@ -31,7 +31,8 @@ enum
enum enum
{ {
kMidiFileIdColScIdx= 0, kMidiFileIdColScIdx= 0,
kEventIdColScIdx = 2,
kTypeLabelColScIdx = 3, kTypeLabelColScIdx = 3,
kDSecsColScIdx = 4, kDSecsColScIdx = 4,
kSecsColScIdx = 5, kSecsColScIdx = 5,
@ -723,10 +724,13 @@ cmScRC_t _cmScParseNoteOn( cmSc_t* p, unsigned rowIdx, cmScoreEvt_t* s, unsigned
const cmChar_t* attr; const cmChar_t* attr;
double secs; double secs;
double durSecs; double durSecs;
unsigned eventId;
const cmCsvCell_t* cell; const cmCsvCell_t* cell;
s += scoreIdx; s += scoreIdx;
eventId = cmCsvCellUInt(p->cH,rowIdx,kEventIdColScIdx);
// verify the scientific pitch cell was formatted correcly // verify the scientific pitch cell was formatted correcly
if((cell = cmCsvCellPtr(p->cH,rowIdx,kPitchColScIdx)) == NULL || cell->lexTId != p->sciPitchLexTId ) if((cell = cmCsvCellPtr(p->cH,rowIdx,kPitchColScIdx)) == NULL || cell->lexTId != p->sciPitchLexTId )
return cmErrMsg(&p->err,kSyntaxErrScRC,"Pitch column format error."); return cmErrMsg(&p->err,kSyntaxErrScRC,"Pitch column format error.");
@ -736,7 +740,7 @@ cmScRC_t _cmScParseNoteOn( cmSc_t* p, unsigned rowIdx, cmScoreEvt_t* s, unsigned
if((midiPitch = cmSciPitchToMidi(sciPitch)) == kInvalidMidiPitch) if((midiPitch = cmSciPitchToMidi(sciPitch)) == kInvalidMidiPitch)
return cmErrMsg(&p->err,kSyntaxErrScRC,"Unable to convert the scientific pitch '%s' to a MIDI value. "); return cmErrMsg(&p->err,kSyntaxErrScRC,"Unable to convert the scientific pitch '%s' to a MIDI value. ");
// get the sec's field - or DBL_MAX if it is not set // get the sec's field - or DBL_MAX if it is not set
if((secs = cmCsvCellDouble(p->cH, rowIdx, kSecsColScIdx )) == DBL_MAX) // Returns DBL_MAX on error. if((secs = cmCsvCellDouble(p->cH, rowIdx, kSecsColScIdx )) == DBL_MAX) // Returns DBL_MAX on error.
flags += kInvalidScFl; flags += kInvalidScFl;
@ -812,6 +816,7 @@ cmScRC_t _cmScParseNoteOn( cmSc_t* p, unsigned rowIdx, cmScoreEvt_t* s, unsigned
s->barNoteIdx = barNoteIdx; s->barNoteIdx = barNoteIdx;
s->durSecs = durSecs; s->durSecs = durSecs;
s->csvRowNumb = rowIdx+1; s->csvRowNumb = rowIdx+1;
s->csvEventId = eventId;
return rc; return rc;
} }
@ -2451,7 +2456,7 @@ cmScRC_t cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const c
for(i=1; titles[i]!=NULL; ++i) for(i=1; titles[i]!=NULL; ++i)
{ {
if( cmCsvInsertTextColAfter(csvH, cp, &cp, titles[i], lexTId ) != kOkCsvRC ) if( cmCsvInsertIdentColAfter(csvH, cp, &cp, titles[i], lexTId ) != kOkCsvRC )
{ {
cmErrMsg(&err,kCsvFailScRC,"Error inserting column index '%i' label in '%s'.",i,cmStringNullGuard(scoreFn)); cmErrMsg(&err,kCsvFailScRC,"Error inserting column index '%i' label in '%s'.",i,cmStringNullGuard(scoreFn));
goto errLabel; goto errLabel;
@ -2521,7 +2526,7 @@ cmScRC_t cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const c
goto errLabel; goto errLabel;
} }
if( cmCsvInsertTextColAfter(csvH, cp, &cp, opStr, lexTId ) != kOkCsvRC ) if( cmCsvInsertQTextColAfter(csvH, cp, &cp, opStr, lexTId ) != kOkCsvRC )
{ {
cmErrMsg(&err,kCsvFailScRC,"Error inserting 'opcode' column in '%s'.",cmStringNullGuard(scoreFn)); cmErrMsg(&err,kCsvFailScRC,"Error inserting 'opcode' column in '%s'.",cmStringNullGuard(scoreFn));
goto errLabel; goto errLabel;
@ -2572,7 +2577,7 @@ cmScRC_t cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const c
switch( tmp->status ) switch( tmp->status )
{ {
case kNoteOnMdId: case kNoteOnMdId:
if( cmCsvInsertTextColAfter(csvH, cp, &cp, cmMidiToSciPitch(tmp->u.chMsgPtr->d0,NULL,0), lexTId ) != kOkCsvRC ) if( cmCsvInsertQTextColAfter(csvH, cp, &cp, cmMidiToSciPitch(tmp->u.chMsgPtr->d0,NULL,0), lexTId ) != kOkCsvRC )
{ {
cmErrMsg(&err,kCsvFailScRC,"Error inserting 'opcode' column in '%s'.",cmStringNullGuard(scoreFn)); cmErrMsg(&err,kCsvFailScRC,"Error inserting 'opcode' column in '%s'.",cmStringNullGuard(scoreFn));
goto errLabel; goto errLabel;

View File

@ -96,6 +96,7 @@ extern "C" {
unsigned perfVel; // Velocity of the performed note or 0 if the note 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 unsigned perfDynLvl; // Index into dynamic level ref. array assoc'd with perfVel
unsigned line; // Line number of this event in the score file. unsigned line; // Line number of this event in the score file.
unsigned csvEventId; // EventId from CSV 'evt' column.
} cmScoreEvt_t; } cmScoreEvt_t;
// A 'set' is a collection of events that are grouped in time and all marked with a given attribute. // A 'set' is a collection of events that are grouped in time and all marked with a given attribute.