From add55f65c5727bfab338be16e6548f9af8756048 Mon Sep 17 00:00:00 2001 From: Wohlstand Date: Thu, 3 Sep 2020 00:46:53 +0300 Subject: Fixed an incorrect logic of CC121 Issue #227 --- src/midi_sequencer_impl.hpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/midi_sequencer_impl.hpp') diff --git a/src/midi_sequencer_impl.hpp b/src/midi_sequencer_impl.hpp index f0ba839..62e78c3 100644 --- a/src/midi_sequencer_impl.hpp +++ b/src/midi_sequencer_impl.hpp @@ -206,6 +206,7 @@ void BW_MidiSequencer::MidiTrackRow::sortEvents(bool *noteStates) else if((events[i].type == MidiEvent::T_SPECIAL) && ( (events[i].subtype == MidiEvent::ST_MARKER) || (events[i].subtype == MidiEvent::ST_DEVICESWITCH) || + (events[i].subtype == MidiEvent::ST_SONG_BEGIN_HOOK) || (events[i].subtype == MidiEvent::ST_LOOPSTART) || (events[i].subtype == MidiEvent::ST_LOOPEND) || (events[i].subtype == MidiEvent::ST_LOOPSTACK_BEGIN) || @@ -566,13 +567,11 @@ bool BW_MidiSequencer::buildSmfTrackData(const std::vector } // HACK: Begin every track with "Reset all controllers" event to avoid controllers state break came from end of song - for(uint8_t chan = 0; chan < 16; chan++) + if(tk == 0) { MidiEvent resetEvent; - resetEvent.type = MidiEvent::T_CTRLCHANGE; - resetEvent.channel = chan; - resetEvent.data.push_back(121); - resetEvent.data.push_back(0); + resetEvent.type = MidiEvent::T_SPECIAL; + resetEvent.subtype = MidiEvent::ST_SONG_BEGIN_HOOK; evtPos.events.push_back(resetEvent); } @@ -1677,7 +1676,7 @@ void BW_MidiSequencer::handleEvent(size_t track, const BW_MidiSequencer::MidiEve if(evt.type == MidiEvent::T_SPECIAL) { // Special event FF - uint8_t evtype = evt.subtype; + uint_fast16_t evtype = evt.subtype; uint64_t length = static_cast(evt.data.size()); const char *data(length ? reinterpret_cast(evt.data.data()) : ""); @@ -1771,6 +1770,13 @@ void BW_MidiSequencer::handleEvent(size_t track, const BW_MidiSequencer::MidiEve return; } + if(evtype == MidiEvent::ST_SONG_BEGIN_HOOK) + { + if(m_interface->onSongStart) + m_interface->onSongStart(m_interface->onSongStart_userData); + return; + } + return; } -- cgit v1.2.3