From 3a7b43a63a0fdb20f2d9b53f2d39ef91e891bde0 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Thu, 7 Jul 2016 09:17:30 -1000 Subject: [PATCH] Mask out high bit on Tempo changes --- lib/SongConverter.cpp | 2 +- lib/SongState.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/SongConverter.cpp b/lib/SongConverter.cpp index eaeabc3..290fe02 100644 --- a/lib/SongConverter.cpp +++ b/lib/SongConverter.cpp @@ -675,7 +675,7 @@ std::vector SongConverter::SongToMIDI(const unsigned char* data, int& v encoder.getResult().push_back(0x51); encoder.getResult().push_back(3); - uint32_t tempo24 = SBig(60000000 / change.m_tempo); + uint32_t tempo24 = SBig(60000000 / (change.m_tempo & 0x7fffffff)); for (int i=1 ; i<4 ; ++i) encoder.getResult().push_back(reinterpret_cast(&tempo24)[i]); diff --git a/lib/SongState.cpp b/lib/SongState.cpp index d8e9655..efcbd2d 100644 --- a/lib/SongState.cpp +++ b/lib/SongState.cpp @@ -354,7 +354,7 @@ bool SongState::initialize(const unsigned char* ptr) else m_tempoPtr = nullptr; - m_tempo = m_header.m_initialTempo; + m_tempo = m_header.m_initialTempo & 0x7fffffff; m_curTick = 0; m_songState = SongPlayState::Playing; @@ -604,7 +604,7 @@ bool SongState::advance(Sequencer& seq, double dt) if (remTicks <= 0) { /* Turn over tempo */ - m_tempo = change.m_tempo; + m_tempo = change.m_tempo & 0x7fffffff; seq.setTempo(m_tempo * 384 / 60); ++m_tempoPtr; continue;