# SDL\_mixer: native\_midi\_mint: align with latest uMIDI

**URL:** <https://discourse.libsdl.org/t/sdl-mixer-native-midi-mint-align-with-latest-umidi/69562>\
**Category:** SDL Commits\
**Created:** [October 16, 2026, 2:00pm UTC](https://discourse.libsdl.org/t/sdl-mixer-native-midi-mint-align-with-latest-umidi/69562 "2026-10-16T14:00:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [October 16, 2026, 2:00pm UTC](https://discourse.libsdl.org/t/sdl-mixer-native-midi-mint-align-with-latest-umidi/69562/1 "2026-10-16T14:00:44Z")

</div>

> <https://github.com/libsdl-org/SDL_mixer/commit/0df654287a3972c029f109c93aefaddf77b3b928>

```diff
From 0df654287a3972c029f109c93aefaddf77b3b928 Mon Sep 17 00:00:00 2001
From: Miro Kropacek <[EMAIL REDACTED]>
Date: Fri, 16 Oct 2026 23:32:14 +1000
Subject: [PATCH] native_midi_mint: align with latest uMIDI

---
 native_midi/native_midi_mint.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/native_midi/native_midi_mint.c b/native_midi/native_midi_mint.c
index b342208a..d5f53505 100644
--- a/native_midi/native_midi_mint.c
+++ b/native_midi/native_midi_mint.c
@@ -46,6 +46,13 @@ static int umidi_volume(int volume)
     return volume * UMIDI_MAX_VOLUME / MIX_MAX_VOLUME;
 }
 
+/* microseconds to uMIDI's timer periods, rounded up */
+static Uint32 umidi_periods(Uint32 us)
+{
+ return us / 1000000 * UMIDI_TIMER_HZ
+ + (us % 1000000 * UMIDI_TIMER_HZ + 999999) / 1000000;
+}
+
 /* Builds the blocks of a song from the event list: channel messages only,
  * their tick times turned into microseconds with the tempo changes applied.
  * An empty block at the time of the last event (end of track) keeps the
@@ -55,7 +62,7 @@ static int convert_events(UMidiSong *song, const MIDIEvent *events, Uint16 divis
     const MIDIEvent *ev;
     UMidiBlock *blocks;
     Uint8 *data;
- Uint32 numEvents = 0, numBlocks = 0, size = 0;
+ Uint32 numEvents = 0, numBlocks = 0, size = 0, i;
     Uint32 tick = 0, time = 0, rem = 0;
     Uint32 usPerTick, usRem;
 
@@ -137,6 +144,9 @@ static int convert_events(UMidiSong *song, const MIDIEvent *events, Uint16 divis
         numBlocks++;
     }
 
+ for (i = 0; i < numBlocks; i++)
+ blocks[i].time = umidi_periods(blocks[i].time);
+
     song->blocks = blocks;
     song->data = data;
     song->numBlocks = numBlocks;

```
