import javax.sound.midi.*;
-import javax.swing.*;
import java.io.*;
+import javax.swing.*;
+import java.util.*;
/**
* Moosique - The MIDI Tracker
private static String filename, fileArg;
private static long position;
private static boolean makeGUI = true;
- private static boolean playing = false;
/**
* Starts the application.
setActiveChannel(0);
} catch (MidiUnavailableException e) {
System.out.println("Failed, quitting.");
- quit();
+// System.exit(1);
}
System.out.println("Done");
clearSequence();
}
- // If n-flag is set, plays song and then exits. Otherwise builds GUI.
+ // Builds GUI, unless n-flag is set.
if (makeGUI) {
System.out.print("Building GUI...");
+ try {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ } catch (Exception e) {}
gui = new MooGUI(seq);
System.out.println("Done");
} else {
* 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
} catch (InvalidMidiDataException e) {
return false;
} catch (IOException e) {
- JOptionPane.showMessageDialog(null, "Error 404", "File Not Found", JOptionPane.ERROR_MESSAGE);
return false;
}
MidiMessage nextMsg;
ShortMessage shortMsg;
for (int i = 0; i < tracks.length; i++) {
+ /*
+ Collections.sort(track[i].events, new Comparator() {
+ public int compare(Object o1, Object o2) {
+ return ((MidiEvent)o2).getTick() - ((MidiEvent)o1).getTick();
+ }
+ });
+ */
for (int j = 0; j < tracks[i].size(); j++) {
noteOn = tracks[i].get(j);
if (noteOn.getMessage() instanceof ShortMessage) {