From 67fe7fb2be8986ba51a277cb0ff557d8b3b9bb56 Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 29 Jun 2016 19:10:18 -0400 Subject: [PATCH] cmMidiFile.c : Fixed problem where cmMidiFileInsertMsg() did not set d0, and d1. --- cmMidiFile.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmMidiFile.c b/cmMidiFile.c index 3385857..a628304 100644 --- a/cmMidiFile.c +++ b/cmMidiFile.c @@ -1202,7 +1202,9 @@ cmMfRC_t cmMidiFileInsertMsg( cmMidiFileH_t h, unsigned uid, int dtick, cmMidiBy else // if dtick is negative ... { // ... get get the msg before the ref. msg. - if((ref = _cmMidiFileMsgBeforeUid(mfp,uid)) == NULL ) + if((ref = _cmMidiFileMsgBeforeUid(mfp,uid)) != NULL ) + trkIdx = ref->trkIdx; + else { // ... the ref. msg was first in the track so there is no msg before it trkIdx = _cmMidiFileIsMsgFirstOnTrack(mfp,uid); @@ -1218,7 +1220,10 @@ cmMfRC_t cmMidiFileInsertMsg( cmMidiFileH_t h, unsigned uid, int dtick, cmMidiBy // complete the msg setup _cmMidiTrack_t* trk = mfp->trkV + trkIdx; cmMidiTrackMsg_t* m = _cmMidiFileAllocMsg(mfp, trkIdx, abs(dtick), status ); - cmMidiChMsg_t* c = (cmMidiChMsg_t*)m->u.chMsgPtr; // cast away const + cmMidiChMsg_t* c = (cmMidiChMsg_t*)_cmMidiFileMalloc(mfp,sizeof(cmMidiChMsg_t)); + + m->u.chMsgPtr = c; + c->ch = ch; c->d0 = d0; c->d1 = d1;