From 2e553c71867ea43f6f35875c8e1b7ccd69e77c25 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Tue, 15 Oct 2013 11:52:20 -0700 Subject: [PATCH] Fixed loop handling if only a loop start or end marker is found --- Plugins/MIDI/MIDI/MIDIDecoder.mm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Plugins/MIDI/MIDI/MIDIDecoder.mm b/Plugins/MIDI/MIDI/MIDIDecoder.mm index 2da2beb87..167dd0c37 100755 --- a/Plugins/MIDI/MIDI/MIDIDecoder.mm +++ b/Plugins/MIDI/MIDI/MIDIDecoder.mm @@ -38,12 +38,15 @@ midi_file.scan_for_loops( true, true ); - framesLength = midi_file.get_timestamp_end( track_num, true ) + 1000; + framesLength = midi_file.get_timestamp_end( track_num, true ); unsigned long loopStart = midi_file.get_timestamp_loop_start( track_num, true ); unsigned long loopEnd = midi_file.get_timestamp_loop_end( track_num, true ); - if ( loopStart != ~0UL && loopEnd != ~0UL ) + if ( loopStart == ~0UL ) loopStart = 0; + if ( loopEnd == ~0UL ) loopEnd = framesLength; + + if ( loopStart != 0 || loopEnd != framesLength ) { // two loops and a fade framesLength = loopStart + ( loopEnd - loopStart ) * 2; @@ -51,6 +54,7 @@ } else { + framesLength += 1000; framesFade = 0; }