aboutsummaryrefslogtreecommitdiff
path: root/src/midi_sequencer_impl.hpp
diff options
context:
space:
mode:
authorWohlstand <admin@wohlnet.ru>2018-09-25 19:26:21 +0300
committerWohlstand <admin@wohlnet.ru>2018-09-25 19:26:21 +0300
commitbb0d23251324fadd49cbf53c1673b80ef07ffeff (patch)
tree57a9a9b754f40877add55bde772d06791f5727e1 /src/midi_sequencer_impl.hpp
parent36f58b5c73766e4173b1cb04168909fdbcf9a5bf (diff)
parent923ea2f4d2c26248d518c9af7cafb938cd5ee9d6 (diff)
downloadlibADLMIDI-bb0d23251324fadd49cbf53c1673b80ef07ffeff.tar.gz
libADLMIDI-bb0d23251324fadd49cbf53c1673b80ef07ffeff.tar.bz2
libADLMIDI-bb0d23251324fadd49cbf53c1673b80ef07ffeff.zip
Merge branch 'master' into stable
Diffstat (limited to 'src/midi_sequencer_impl.hpp')
-rw-r--r--src/midi_sequencer_impl.hpp107
1 files changed, 101 insertions, 6 deletions
diff --git a/src/midi_sequencer_impl.hpp b/src/midi_sequencer_impl.hpp
index 0fe6192..6d6b2d8 100644
--- a/src/midi_sequencer_impl.hpp
+++ b/src/midi_sequencer_impl.hpp
@@ -270,6 +270,7 @@ BW_MidiSequencer::BW_MidiSequencer() :
m_interface(NULL),
m_format(Format_MIDI),
m_smfFormat(0),
+ m_loopFormat(Loop_Default),
m_loopEnabled(false),
m_fullSongTimeLength(0.0),
m_postSongWaitDelay(1.0),
@@ -399,6 +400,7 @@ void BW_MidiSequencer::buildSmfSetupReset(size_t trackCount)
m_fullSongTimeLength = 0.0;
m_loopStartTime = -1.0;
m_loopEndTime = -1.0;
+ m_loopFormat = Loop_Default;
m_trackDisable.clear();
m_trackSolo = ~(size_t)0;
m_musTitle.clear();
@@ -614,6 +616,19 @@ bool BW_MidiSequencer::buildSmfTrackData(const std::vector<std::vector<uint8_t>
}
}
+#ifdef ENABLE_END_SILENCE_SKIPPING
+ //Have track end on its own row? Clear any delay on the row before
+ if(event.subtype == MidiEvent::ST_ENDTRACK && evtPos.events.size() == 1)
+ {
+ if (!m_trackData[tk].empty())
+ {
+ MidiTrackRow &previous = m_trackData[tk].back();
+ previous.delay = 0;
+ previous.timeDelay = 0;
+ }
+ }
+#endif
+
if((evtPos.delay > 0) || (event.subtype == MidiEvent::ST_ENDTRACK))
{
evtPos.absPos = abs_position;
@@ -1361,12 +1376,92 @@ BW_MidiSequencer::MidiEvent BW_MidiSequencer::parseEvent(const uint8_t **pptr, c
if(evType == MidiEvent::T_CTRLCHANGE)
{
//111'th loopStart controller (RPG Maker and others)
- if((m_format == Format_MIDI) && (evt.data[0] == 111))
+ if(m_format == Format_MIDI)
{
- //Change event type to custom Loop Start event and clear data
- evt.type = MidiEvent::T_SPECIAL;
- evt.subtype = MidiEvent::ST_LOOPSTART;
- evt.data.clear();
+ switch(evt.data[0])
+ {
+ case 110:
+ if(m_loopFormat == Loop_Default)
+ {
+ //Change event type to custom Loop Start event and clear data
+ evt.type = MidiEvent::T_SPECIAL;
+ evt.subtype = MidiEvent::ST_LOOPSTART;
+ evt.data.clear();
+ m_loopFormat = Loop_HMI;
+ }
+ else if(m_loopFormat == Loop_HMI)
+ {
+ // Repeating of 110'th point is BAD practice, treat as EMIDI
+ m_loopFormat = Loop_EMIDI;
+ }
+ break;
+
+ case 111:
+ if(m_loopFormat == Loop_HMI)
+ {
+ //Change event type to custom Loop End event and clear data
+ evt.type = MidiEvent::T_SPECIAL;
+ evt.subtype = MidiEvent::ST_LOOPEND;
+ evt.data.clear();
+ }
+ else if(m_loopFormat != Loop_EMIDI)
+ {
+ // Change event type to custom Loop Start event and clear data
+ evt.type = MidiEvent::T_SPECIAL;
+ evt.subtype = MidiEvent::ST_LOOPSTART;
+ evt.data.clear();
+ }
+ break;
+
+ case 113:
+ if(m_loopFormat == Loop_EMIDI)
+ {
+ //EMIDI does using of CC113 with same purpose as CC7
+ evt.data[0] = 7;
+ }
+ break;
+#if 0 //WIP
+ case 116:
+ if(m_loopFormat == Loop_EMIDI)
+ {
+ evt.type = MidiEvent::T_SPECIAL;
+ evt.subtype = MidiEvent::ST_LOOPSTACK_BEGIN;
+ evt.data[0] = evt.data[1];
+ evt.data.pop_back();
+
+ if(m_interface->onDebugMessage)
+ {
+ m_interface->onDebugMessage(
+ m_interface->onDebugMessage_userData,
+ "Stack EMIDI Loop Start at %d to %d level with %d loops",
+ m_loop.stackLevel,
+ m_loop.stackLevel + 1,
+ evt.data[0]
+ );
+ }
+ }
+ break;
+
+ case 117: // Next/Break Loop Controller
+ if(m_loopFormat == Loop_EMIDI)
+ {
+ evt.type = MidiEvent::T_SPECIAL;
+ evt.subtype = MidiEvent::ST_LOOPSTACK_END;
+ evt.data.clear();
+
+ if(m_interface->onDebugMessage)
+ {
+ m_interface->onDebugMessage(
+ m_interface->onDebugMessage_userData,
+ "Stack EMIDI Loop End at %d to %d level",
+ m_loop.stackLevel,
+ m_loop.stackLevel - 1
+ );
+ }
+ }
+ break;
+#endif
+ }
}
if(m_format == Format_XMIDI)
@@ -1502,7 +1597,7 @@ void BW_MidiSequencer::handleEvent(size_t track, const BW_MidiSequencer::MidiEve
if(m_interface->onDebugMessage)
m_interface->onDebugMessage(m_interface->onDebugMessage_userData, "Switching another device: %s", data);
if(m_interface->rt_deviceSwitch)
- m_interface->rt_deviceSwitch(m_interface->rtUserData, track, data, length);
+ m_interface->rt_deviceSwitch(m_interface->rtUserData, track, data, size_t(length));
return;
}