Browse Source

cmMidiFile.c : Fixed problem where cmMidiFileInsertMsg() did not set d0, and d1.

master
kevin 8 years ago
parent
commit
67fe7fb2be
1 changed files with 7 additions and 2 deletions
  1. 7
    2
      cmMidiFile.c

+ 7
- 2
cmMidiFile.c View File

1202
   else // if dtick is negative ...
1202
   else // if dtick is negative ...
1203
   {
1203
   {
1204
     // ... get get the msg before the ref. msg.
1204
     // ... get get the msg before the ref. msg.
1205
-    if((ref = _cmMidiFileMsgBeforeUid(mfp,uid)) == NULL )
1205
+    if((ref = _cmMidiFileMsgBeforeUid(mfp,uid)) != NULL )
1206
+      trkIdx = ref->trkIdx;
1207
+    else
1206
     {
1208
     {
1207
       // ... the ref. msg was first in the track so there is no msg before it
1209
       // ... the ref. msg was first in the track so there is no msg before it
1208
       trkIdx = _cmMidiFileIsMsgFirstOnTrack(mfp,uid);
1210
       trkIdx = _cmMidiFileIsMsgFirstOnTrack(mfp,uid);
1218
   // complete the msg setup
1220
   // complete the msg setup
1219
   _cmMidiTrack_t* trk   = mfp->trkV + trkIdx;
1221
   _cmMidiTrack_t* trk   = mfp->trkV + trkIdx;
1220
   cmMidiTrackMsg_t* m   = _cmMidiFileAllocMsg(mfp, trkIdx, abs(dtick), status );
1222
   cmMidiTrackMsg_t* m   = _cmMidiFileAllocMsg(mfp, trkIdx, abs(dtick), status );
1221
-  cmMidiChMsg_t*    c   = (cmMidiChMsg_t*)m->u.chMsgPtr; // cast away const
1223
+  cmMidiChMsg_t*    c   = (cmMidiChMsg_t*)_cmMidiFileMalloc(mfp,sizeof(cmMidiChMsg_t));
1224
+
1225
+  m->u.chMsgPtr = c;
1226
+  
1222
   c->ch   = ch;
1227
   c->ch   = ch;
1223
   c->d0   = d0;
1228
   c->d0   = d0;
1224
   c->d1   = d1;
1229
   c->d1   = d1;

Loading…
Cancel
Save