private static String filename, fileArg;
private static long position;
private static boolean makeGUI = true;
+ private static boolean playing = false;
/**
* Starts the application.
//If a filename is given as the command-line argument, attempts to load a sequence from the file.
if (fileArg != null) {
System.out.print("Loading MIDI sequence from " + fileArg + "...");
- if (!load(fileArg)) clearSequence();
- System.out.println("Done");
+ if (!load(fileArg)) {
+ System.out.println("Failed");
+ clearSequence();
+ } else {
+ System.out.println("Done");
+ }
} else {
// Otherwise creates a new empty one.
clearSequence();
}
/**
- * Returns a pointer to the current sequence.
+ * Returns the GUI.
+ * @return the GUI
+ */
+ public static MooGUI getGUI() {
+ return gui;
+ }
+
+ /**
+ * Returns the current sequence.
* @return the current sequence
*/
public static Sequence getSequence() {
}
/**
- * Returns a pointer to the MidiChannels of the selected synthesizer.
+ * Returns the current sequencer.
+ * @return the current sequencer
+ */
+ public static Sequencer getSequencer() {
+ return sequencer;
+ }
+
+ /**
+ * Returns the MidiChannels of the selected synthesizer.
* @return the available MidiChannels
*/
public static MidiChannel[] getChannels() {
}
/**
- * Returns a pointer to the currently active MidiChannel.
+ * Returns the currently active MidiChannel.
* @return the active MidiChannel
*/
public static MidiChannel getActiveChannel() {
* Starts playback of the current sequence.
*/
public static void play() {
+ playing = true;
sequencer.setTickPosition(position);
sequencer.start();
}
* Pauses playback of the current sequence.
*/
public static void pause() {
+ playing = false;
sequencer.stop();
}
* Resumes playback of the current sequence.
*/
public static void resume() {
+ playing = true;
sequencer.start();
}
* Stops playback of the current sequence.
*/
public static void stop() {
+ playing = false;
sequencer.stop();
sequencer.setTickPosition(position);
}
+ /**
+ * Pauses if playing and resumes if stopped.
+ */
+ public static void resumepause()
+ {
+ if (playing)
+ pause();
+ else
+ resume();
+ }
+
/**
* Rewinds the current sequence the given number of measures.
* @param measures the number of measures to rewind
* @param measures the number of measures to rewind
*/
public static void rewind(long ticks) {
- position -= ticks;
+ setPosition(position - ticks);
}
/**
* @param measures the number of measures to fast forward
*/
public static void forward(long ticks) {
- position += ticks;
+ setPosition(position + ticks);
}
/**
if (synthesizer.isOpen()) synthesizer.close();
System.exit(0);
}
-}
\ No newline at end of file
+}