X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Moosique.java;h=c411cd6f38cf779e74dda15f66bb68a6856a77db;hb=9f707c235c36921753665933a6b959bfa1027fff;hp=32c4d375d7e43b0f7b502d0b6b25730f8b0e6771;hpb=4ac3b6210979ea78dceb609a0501cb0265d00065;p=moosique.git diff --git a/Moosique.java b/Moosique.java index 32c4d37..c411cd6 100644 --- a/Moosique.java +++ b/Moosique.java @@ -2,7 +2,7 @@ import javax.sound.midi.*; import javax.swing.*; import java.io.*; -/* +/** * Moosique - The MIDI Tracker * * Main class that handles initiation, IO and sound. @@ -15,15 +15,15 @@ public class Moosique { protected static MooGUI gui; protected static Sequence seq; - protected static Sequencer sequencer = null; - protected static Synthesizer synthesizer = null; + protected static Sequencer sequencer; + protected static Synthesizer synthesizer; protected static MidiChannel[] channels; protected static MidiChannel activeChannel; protected static String filename; protected static long position; - /* + /** * Starts the application. */ public static void main (String[] args) { @@ -62,7 +62,7 @@ public class Moosique { System.out.println("Done"); } - /* + /** * Returns a pointer to the current sequence. * @return the current sequence */ @@ -70,7 +70,7 @@ public class Moosique { return seq; } - /* + /** * Returns a pointer to the MidiChannels of the selected synthesizer. * @return the available MidiChannels */ @@ -78,7 +78,7 @@ public class Moosique { return channels; } - /* + /** * Returns a pointer to the currently active MidiChannel. * @return the active MidiChannel */ @@ -86,7 +86,7 @@ public class Moosique { return activeChannel; } - /* + /** * Sets the currently active MidiChannel. * @param channel the number of the MidiChannel to activate */ @@ -94,7 +94,7 @@ public class Moosique { activeChannel = channels[channel]; } - /* + /** * Replaces the current sequence with a new one, holding three empty tracks. */ public static void clearSequence() { @@ -107,7 +107,7 @@ public class Moosique { } - /* + /** * Starts playback of the current sequence. */ public static void play() { @@ -118,21 +118,21 @@ public class Moosique { sequencer.start(); } - /* + /** * Pauses playback of the current sequence. */ public static void pause() { sequencer.stop(); } - /* + /** * Resumes playback of the current sequence. */ public static void resume() { sequencer.start(); } - /* + /** * Stops playback of the current sequence. */ public static void stop() { @@ -140,7 +140,7 @@ public class Moosique { sequencer.setTickPosition(position); } - /* + /** * Rewinds the current sequence the given number of measures. * @param measures the number of measures to rewind */ @@ -148,7 +148,7 @@ public class Moosique { return position; } - /* + /** * Rewinds the current sequence the given number of measures. * @param measures the number of measures to rewind */ @@ -156,7 +156,7 @@ public class Moosique { position = ticks; } - /* + /** * Rewinds the current sequence the given number of measures. * @param measures the number of measures to rewind */ @@ -164,7 +164,7 @@ public class Moosique { position -= ticks; } - /* + /** * Fast forwards the current sequence the given number of measures. * @param measures the number of measures to fast forward */ @@ -172,7 +172,7 @@ public class Moosique { position += ticks; } - /* + /** * Loads the MooSequence in the given file. * @param filename the filename to use */ @@ -184,7 +184,7 @@ public class Moosique { } catch (InvalidMidiDataException e) { return false; } catch (IOException e) { - JOptionPane.showMessageDialog(null, "File", "alert", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(null, "Error 404", "File Not Found", JOptionPane.ERROR_MESSAGE); return false; } @@ -227,31 +227,27 @@ public class Moosique { return true; } - /* + /** * Saves the current sequence to the given filename * @param filename the filename to use */ public static void saveAs(String filename) throws IOException { MidiSystem.write(seq, 1, new File(filename)); - } - /* + /** * Saves the current sequence to the previously given filename. */ public static void save() throws IOException { saveAs(filename); } - /* + /** * Releases all reserved devices and exits the program. */ public static void quit() { - if (sequencer.isOpen()) { - try { - sequencer.open(); - } catch (MidiUnavailableException e) {} - } + if (sequencer.isOpen()) sequencer.close(); + if (synthesizer.isOpen()) synthesizer.close(); System.exit(0); } } \ No newline at end of file