From: Einar Pehrson Date: Sun, 27 Apr 2003 01:37:53 +0000 (+0000) Subject: Fixed some error handling X-Git-Url: https://ruin.nu/git/?p=moosique.git;a=commitdiff_plain;h=287a944858d5f8f4db2c58d8fb734589ee8e784f Fixed some error handling --- diff --git a/MooGUI.java b/MooGUI.java index 0095f42..c06dc3a 100644 --- a/MooGUI.java +++ b/MooGUI.java @@ -15,7 +15,7 @@ public class MooGUI { /* * Creates the GUI. */ - public MooGUI () { + public MooGUI (Sequence seq) { } @@ -26,4 +26,4 @@ public class MooGUI { public void setSequence(Sequence sequence) { seq = sequence; } -} +} \ No newline at end of file diff --git a/Moosique.java b/Moosique.java index 792a7f2..6efb2d1 100644 --- a/Moosique.java +++ b/Moosique.java @@ -2,16 +2,6 @@ import javax.sound.midi.*; import javax.swing.*; import java.io.*; -/* UPDATES - Killed superfluous exportMIDI method. - Added public static void quit() - Removed Sequence seq property. - Changed forward(int measures) and rewind(int measures) to forward(long ticks) and rewind(long ticks). - Added public static long getPosition() - Added public static void setPosition(long ticks) - Added public static void resume() -*/ - /* * Moosique - The MIDI Tracker * @@ -51,18 +41,16 @@ public class Moosique { } //If a filename is given as the command-line argument, attempts to load a sequence from the file. - try { - if (args.length == 1) { - if (!load(args[0])) seq = new Sequence(Sequence.PPQ, 96); - } else { - // Otherwise creates a new empty one. - seq = new Sequence(Sequence.PPQ, 96); - } - } catch (InvalidMidiDataException e) {} + if (args.length == 1) { + if (!load(args[0])) createSequence(); + } else { + // Otherwise creates a new empty one. + createSequence(); + } // Sets up channels and GUI. channels = synthesizer.getChannels(); - gui = new MooGUI(); + gui = new MooGUI(seq); } /* @@ -73,14 +61,24 @@ public class Moosique { return seq; } + /* + * Returns a pointer to the current sequence. + * @return the current sequence + */ + public static void createSequence() { + try { + seq = new Sequence(Sequence.PPQ, 96); + } catch (InvalidMidiDataException e) {} + } + /* * Starts playback of the current sequence. */ public static void play() { try { sequencer.setSequence(seq); + sequencer.setTickPosition(position); } catch (InvalidMidiDataException e) {} - sequencer.setTickPosition(position); sequencer.start(); }