cmMidiFile.h/c : In cmMIdiFileInsertTrack???() return the 'uid' of the new event record.
This commit is contained in:
parent
1da843a380
commit
3ef0c6fd3a
18
cmMidiFile.c
18
cmMidiFile.c
@ -1368,10 +1368,13 @@ cmMfRC_t cmMidiFileInsertMsg( cmMidiFileH_t h, unsigned uid, int dtick, cmMidiBy
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmMfRC_t cmMidiFileInsertTrackMsg( cmMidiFileH_t h, unsigned trkIdx, const cmMidiTrackMsg_t* msg )
|
cmMfRC_t cmMidiFileInsertTrackMsg( cmMidiFileH_t h, unsigned trkIdx, const cmMidiTrackMsg_t* msg, unsigned* uidRef )
|
||||||
{
|
{
|
||||||
_cmMidiFile_t* p = _cmMidiFileHandleToPtr(h);
|
_cmMidiFile_t* p = _cmMidiFileHandleToPtr(h);
|
||||||
|
|
||||||
|
if( uidRef != NULL )
|
||||||
|
*uidRef = cmInvalidId;
|
||||||
|
|
||||||
// validate the track index
|
// validate the track index
|
||||||
if( trkIdx >= p->trkN )
|
if( trkIdx >= p->trkN )
|
||||||
return cmErrMsg(&p->err,kInvalidTrkIndexMfRC,"The track index (%i) is invalid.",trkIdx);
|
return cmErrMsg(&p->err,kInvalidTrkIndexMfRC,"The track index (%i) is invalid.",trkIdx);
|
||||||
@ -1395,6 +1398,9 @@ cmMfRC_t cmMidiFileInsertTrackMsg( cmMidiFileH_t h, unsigned trkIdx, const cmMi
|
|||||||
memcpy((void*)m->u.voidPtr,msg->u.voidPtr,msg->byteCnt);
|
memcpy((void*)m->u.voidPtr,msg->u.voidPtr,msg->byteCnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( uidRef != NULL )
|
||||||
|
*uidRef = m->uid;
|
||||||
|
|
||||||
cmMidiTrackMsg_t* m0 = NULL; // msg before insertion
|
cmMidiTrackMsg_t* m0 = NULL; // msg before insertion
|
||||||
cmMidiTrackMsg_t* m1 = p->trkV[trkIdx].base; // msg after insertion
|
cmMidiTrackMsg_t* m1 = p->trkV[trkIdx].base; // msg after insertion
|
||||||
|
|
||||||
@ -1448,12 +1454,14 @@ cmMfRC_t cmMidiFileInsertTrackMsg( cmMidiFileH_t h, unsigned trkIdx, const cmMi
|
|||||||
|
|
||||||
p->trkV[trkIdx].cnt += 1;
|
p->trkV[trkIdx].cnt += 1;
|
||||||
p->msgVDirtyFl = true;
|
p->msgVDirtyFl = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return kOkMfRC;
|
return kOkMfRC;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmMfRC_t cmMidiFileInsertTrackChMsg( cmMidiFileH_t h, unsigned trkIdx, unsigned atick, cmMidiByte_t status, cmMidiByte_t d0, cmMidiByte_t d1 )
|
cmMfRC_t cmMidiFileInsertTrackChMsg( cmMidiFileH_t h, unsigned trkIdx, unsigned atick, cmMidiByte_t status, cmMidiByte_t d0, cmMidiByte_t d1, unsigned* uidRef )
|
||||||
{
|
{
|
||||||
cmMidiTrackMsg_t m;
|
cmMidiTrackMsg_t m;
|
||||||
cmMidiChMsg_t cm;
|
cmMidiChMsg_t cm;
|
||||||
@ -1472,10 +1480,10 @@ cmMfRC_t cmMidiFileInsertTrackChMsg( cmMidiFileH_t h, unsigned trkIdx, unsigned
|
|||||||
|
|
||||||
assert( m.status >= kNoteOffMdId && m.status <= kPbendMdId );
|
assert( m.status >= kNoteOffMdId && m.status <= kPbendMdId );
|
||||||
|
|
||||||
return cmMidiFileInsertTrackMsg(h,trkIdx,&m);
|
return cmMidiFileInsertTrackMsg(h,trkIdx,&m,uidRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmMfRC_t cmMidFileInsertTrackTempoMsg( cmMidiFileH_t h, unsigned trkIdx, unsigned atick, unsigned bpm )
|
cmMfRC_t cmMidFileInsertTrackTempoMsg( cmMidiFileH_t h, unsigned trkIdx, unsigned atick, unsigned bpm, unsigned* uidRef )
|
||||||
{
|
{
|
||||||
cmMidiTrackMsg_t m;
|
cmMidiTrackMsg_t m;
|
||||||
|
|
||||||
@ -1486,7 +1494,7 @@ cmMfRC_t cmMidFileInsertTrackTempoMsg( cmMidiFileH_t h, unsigned trkIdx, unsign
|
|||||||
m.metaId = kTempoMdId;
|
m.metaId = kTempoMdId;
|
||||||
m.u.iVal = 60000000/bpm; // convert BPM to microsPerQN
|
m.u.iVal = 60000000/bpm; // convert BPM to microsPerQN
|
||||||
|
|
||||||
return cmMidiFileInsertTrackMsg(h,trkIdx,&m);
|
return cmMidiFileInsertTrackMsg(h,trkIdx,&m,uidRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -185,9 +185,9 @@ extern "C" {
|
|||||||
// byteCnt - used to allocate storage for the data element in 'cmMidiTrackMsg_t.u'
|
// byteCnt - used to allocate storage for the data element in 'cmMidiTrackMsg_t.u'
|
||||||
// u - the message data
|
// u - the message data
|
||||||
//
|
//
|
||||||
cmMfRC_t cmMidiFileInsertTrackMsg( cmMidiFileH_t h, unsigned trkIdx, const cmMidiTrackMsg_t* msg );
|
cmMfRC_t cmMidiFileInsertTrackMsg( cmMidiFileH_t h, unsigned trkIdx, const cmMidiTrackMsg_t* msg, unsigned* uidRef );
|
||||||
cmMfRC_t cmMidiFileInsertTrackChMsg( cmMidiFileH_t h, unsigned trkIdx, unsigned atick, cmMidiByte_t status, cmMidiByte_t d0, cmMidiByte_t d1 );
|
cmMfRC_t cmMidiFileInsertTrackChMsg( cmMidiFileH_t h, unsigned trkIdx, unsigned atick, cmMidiByte_t status, cmMidiByte_t d0, cmMidiByte_t d1, unsigned* uidRef );
|
||||||
cmMfRC_t cmMidFileInsertTrackTempoMsg( cmMidiFileH_t h, unsigned trkIdx, unsigned atick, unsigned bpm );
|
cmMfRC_t cmMidFileInsertTrackTempoMsg( cmMidiFileH_t h, unsigned trkIdx, unsigned atick, unsigned bpm, unsigned* uidRef );
|
||||||
|
|
||||||
// Return a pointer to the first msg at or after 'usecsOffs' or kInvalidIdx if no
|
// 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
|
// msg exists after 'usecsOffs'. Note that 'usecOffs' is an offset from the beginning
|
||||||
|
Loading…
Reference in New Issue
Block a user