cmMidiFile.h/c : Added cmMidiFileSetVelocity().
This commit is contained in:
parent
2a6739ab0f
commit
bdc1bdb61c
32
cmMidiFile.c
32
cmMidiFile.c
@ -1109,6 +1109,38 @@ const cmMidiTrackMsg_t** cmMidiFileMsgArray( cmMidiFileH_t h )
|
||||
return (const cmMidiTrackMsg_t**)mfp->msgV;
|
||||
}
|
||||
|
||||
|
||||
cmMidiTrackMsg_t* _cmMidiFileUidToMsg( _cmMidiFile_t* mfp, unsigned uid )
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for(i=0; i<mfp->msgN; ++i)
|
||||
if( mfp->msgV[i]->uid == uid )
|
||||
return mfp->msgV[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cmMfRC_t cmMidiFileSetVelocity( cmMidiFileH_t h, unsigned uid, cmMidiByte_t vel )
|
||||
{
|
||||
cmMidiTrackMsg_t* r;
|
||||
_cmMidiFile_t* mfp = _cmMidiFileHandleToPtr(h);
|
||||
|
||||
assert( mfp != NULL );
|
||||
|
||||
if((r = _cmMidiFileUidToMsg(mfp,uid)) == NULL )
|
||||
return cmErrMsg(&mfp->err,kUidNotFoundMfRC,"The MIDI file uid %i could not be found.",uid);
|
||||
|
||||
if( cmMidiIsNoteOn(r->status)==false && cmMidiIsNoteOff(r->status,0)==false )
|
||||
return cmErrMsg(&mfp->err,kUidNotANoteMsgMfRC,"Cannot set velocity on a non-Note-On/Off msg.");
|
||||
|
||||
cmMidiChMsg_t* chm = (cmMidiChMsg_t*)r->u.chMsgPtr;
|
||||
|
||||
chm->d1 = vel;
|
||||
|
||||
return kOkMfRC;
|
||||
}
|
||||
|
||||
unsigned cmMidiFileSeekUsecs( cmMidiFileH_t h, unsigned long long offsUSecs, unsigned* msgUsecsPtr, unsigned* microsPerTickPtr )
|
||||
{
|
||||
_cmMidiFile_t* p;
|
||||
|
@ -111,7 +111,9 @@ extern "C" {
|
||||
kInvalidStatusMfRC, // 9
|
||||
kSustainPedalMfRC, // 10
|
||||
kSostenutoPedalMfRC, // 11
|
||||
kLargeDeltaTickMfRC // 12 (a large delta tick value was filtered)
|
||||
kLargeDeltaTickMfRC, // 12 (a large delta tick value was filtered)
|
||||
kUidNotFoundMfRC, // 13
|
||||
kUidNotANoteMsgMfRC // 14
|
||||
};
|
||||
|
||||
extern cmMidiFileH_t cmMidiFileNullHandle;
|
||||
@ -156,6 +158,9 @@ extern "C" {
|
||||
// Returns NULL if 'h' is invalid.
|
||||
const cmMidiTrackMsg_t** cmMidiFileMsgArray( cmMidiFileH_t h );
|
||||
|
||||
// Set the velocity of a note-on/off msg identified by 'uid'.
|
||||
cmMfRC_t cmMidiFileSetVelocity( cmMidiFileH_t h, unsigned uid, cmMidiByte_t vel );
|
||||
|
||||
// Return a pointer to the first msg at or after 'usecsOffs' or kInvalidIdx if no
|
||||
// msg exists after 'usecsOffs'. Note that 'usecOffs' is an offset from the beginning
|
||||
// of the file.
|
||||
|
Loading…
Reference in New Issue
Block a user