From d242cfcf9a62bed5158c33c061e47fa393e2301a Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Sun, 15 Feb 2009 13:20:21 -0500 Subject: Engine: Fixed MIDI awkwardness Previously, MIDIs would retain some behavior from the previously playing MIDI, either because the Sequencer hadn't been reset or because a critical MidiMessage was incorrectly positioned. Both of these possibilities have been fixed. --- src/com/fourisland/fourpuzzle/Audio.java | 4 ++++ src/com/fourisland/fourpuzzle/util/MidiParser.java | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src/com') diff --git a/src/com/fourisland/fourpuzzle/Audio.java b/src/com/fourisland/fourpuzzle/Audio.java index 9083d27..3283c68 100755 --- a/src/com/fourisland/fourpuzzle/Audio.java +++ b/src/com/fourisland/fourpuzzle/Audio.java @@ -62,6 +62,10 @@ public class Audio { if ((seq.getSequence() != null) && (seq.getSequence().equals(s))) { return; + } else { + seq.close(); + + init(); } try { diff --git a/src/com/fourisland/fourpuzzle/util/MidiParser.java b/src/com/fourisland/fourpuzzle/util/MidiParser.java index 84dea26..3d6c06b 100644 --- a/src/com/fourisland/fourpuzzle/util/MidiParser.java +++ b/src/com/fourisland/fourpuzzle/util/MidiParser.java @@ -55,7 +55,12 @@ public class MidiParser { { parseShortMessage((ShortMessage) mm,tick); } else { - currentTrack.add(new MidiEvent(mm, tick)); + if (foundFirstReal) + { + currentTrack.add(new MidiEvent(mm, tick-firstReal)); + } else { + currentTrack.add(new MidiEvent(mm, 0)); + } } } @@ -77,7 +82,12 @@ public class MidiParser { } } - currentTrack.add(new MidiEvent(mm, tick-firstReal)); + if (foundFirstReal) + { + currentTrack.add(new MidiEvent(mm, tick-firstReal)); + } else { + currentTrack.add(new MidiEvent(mm, 0)); + } } } -- cgit 1.4.1