private static String filename, fileArg;
private static long position;
private static boolean makeGUI = true, isEdited;
+ private static Thread player;
+ public static final int RESOLUTION = 96, DEFAULT_TRACKS = 4;
/**
* Starts the application.
public static void clearSequence() {
// Creates a new sequence and sends it to the sequencer.
try {
- seq = new Sequence(Sequence.PPQ, 96, 3);
+ seq = new Sequence(Sequence.PPQ, RESOLUTION, DEFAULT_TRACKS);
sequencer.setSequence(seq);
} catch (InvalidMidiDataException e) {}
// Sends sequence to GUI.
*/
public static void play() {
sequencer.setTickPosition(position);
- sequencer.start();
+ resume();
}
/**
*/
public static void pause() {
sequencer.stop();
+ player.destroy();
}
/**
*/
public static void resume() {
sequencer.start();
+
+ // Disables input to volatile components
+ // gui.disable();
+
+ // Creates the visualization thread and starts it.
+ player = new Thread () {
+ public void run() {
+ while(sequencer.isRunning()) gui.update(sequencer.getTickPosition());
+ Moosique.stop();
+ }
+ };
+ player.start();
}
/**
public static void stop() {
sequencer.stop();
sequencer.setTickPosition(position);
+ player.interrupt();
+ gui.update((long)0);
}
/**