cmScore.h/c : Added cmScoreIdToEvt() and add 'vel' field to cmScoreEvt_t structure.

This commit is contained in:
kevin 2016-06-16 12:51:55 -04:00
parent bdc1bdb61c
commit 403b85eff4
2 changed files with 24 additions and 3 deletions

View File

@ -723,6 +723,7 @@ cmScRC_t _cmScParseNoteOn( cmSc_t* p, unsigned rowIdx, cmScoreEvt_t* s, unsigned
unsigned dynVal = kInvalidDynScId;
const cmChar_t* sciPitch;
cmMidiByte_t midiPitch;
cmMidiByte_t midiVel;
const cmChar_t* attr;
double secs;
double durSecs;
@ -743,6 +744,9 @@ cmScRC_t _cmScParseNoteOn( cmSc_t* p, unsigned rowIdx, cmScoreEvt_t* s, unsigned
if((midiPitch = cmSciPitchToMidi(sciPitch)) == kInvalidMidiPitch)
return cmErrMsg(&p->err,kSyntaxErrScRC,"Unable to convert the scientific pitch '%s' to a MIDI value. ");
if((midiVel = cmCsvCellUInt( p->cH,rowIdx,kD1ColScIdx)) >= kInvalidMidiVelocity )
return cmErrMsg(&p->err,kSyntaxErrScRC,"An invalid MIDI velocity (%i) was encountered.",midiVel);
// 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.
flags += kInvalidScFl;
@ -812,6 +816,7 @@ cmScRC_t _cmScParseNoteOn( cmSc_t* p, unsigned rowIdx, cmScoreEvt_t* s, unsigned
s->type = kNonEvtScId;
s->secs = secs;
s->pitch = midiPitch;
s->vel = midiVel;
s->flags = flags;
s->dynVal = dynVal;
s->barNumb = barNumb;
@ -1513,7 +1518,7 @@ cmScRC_t _cmScInitLocArray( cmSc_t* p )
for(i=1; i<p->cnt; ++i )
{
if( p->array[i].secs < p->array[i-1].secs )
rc = cmErrMsg(&p->err,kSyntaxErrScRC,"The time associated with the score entry on line %i is less than the previous line.",p->array[i].csvRowNumb);
rc = cmErrMsg(&p->err,kSyntaxErrScRC,"The time (%f) associated with the score entry on line %i is less than the previous line (%f).",p->array[i].csvRowNumb,p->array[i].secs,p->array[i-1].secs);
if( (p->array[i].secs - p->array[i-1].secs) > maxDSecs )
++p->locCnt;
@ -1673,7 +1678,7 @@ cmScoreEvt_t* cmScoreEvt( cmScH_t h, unsigned idx )
return p->array + idx;
}
cmScoreEvt_t* cmScoreBarEvt( cmScH_t h, unsigned barNumb )
const cmScoreEvt_t* cmScoreBarEvt( cmScH_t h, unsigned barNumb )
{
cmSc_t* p = _cmScHandleToPtr(h);
unsigned i = 0;
@ -1684,6 +1689,18 @@ cmScoreEvt_t* cmScoreBarEvt( cmScH_t h, unsigned barNumb )
return NULL;
}
const cmScoreEvt_t* cmScoreIdToEvt( cmScH_t h, unsigned csvEventId )
{
cmSc_t* p = _cmScHandleToPtr(h);
unsigned i = 0;
for(; i<p->cnt; ++i)
if( p->array[i].csvEventId==csvEventId )
return p->array + i;
return NULL;
}
unsigned cmScoreSectionCount( cmScH_t h )
{
cmSc_t* p = _cmScHandleToPtr(h);

View File

@ -87,6 +87,7 @@ extern "C" {
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 or the MIDI pedal id of pedal down/up msg (64=sustain 65=sostenuto 66=soft)
cmMidiByte_t vel; // MIDI velocity of this note
unsigned flags; // Attribute flags for this event
unsigned dynVal; // Dynamcis value pppp to ffff (1 to 11) for this note.
double frac; // Note's time value for tempo and non-grace evenness notes.
@ -185,7 +186,10 @@ extern "C" {
cmScoreEvt_t* cmScoreEvt( cmScH_t h, unsigned idx );
// Given a bar number return the associated 'bar' event record.
cmScoreEvt_t* cmScoreBarEvt( cmScH_t h, unsigned barNumb );
const cmScoreEvt_t* cmScoreBarEvt( cmScH_t h, unsigned barNumb );
// Given a csvEventId return the associated event
const cmScoreEvt_t* cmScoreIdToEvt( cmScH_t h, unsigned csvEventId );
// Access section records
unsigned cmScoreSectionCount( cmScH_t h );