]> ruin.nu Git - moosique.git/blobdiff - Moosique.java
no message
[moosique.git] / Moosique.java
index 83545047c848264510512e014a610cdce79ca27a..bc821ba034bf49f69fc9ee4c33c7dcfd9d43b089 100644 (file)
@@ -22,7 +22,7 @@ public class Moosique {
 
        private static String filename, fileArg;
        private static long position;
-       private static boolean makeGUI = true;
+       private static boolean makeGUI = true, isEdited;
 
        /** 
         * Starts the application.
@@ -50,7 +50,7 @@ public class Moosique {
                        setActiveChannel(0);
                } catch (MidiUnavailableException e) {
                        System.out.println("Failed, quitting.");
-                       quit();
+//                     System.exit(1);
                }
                System.out.println("Done");
 
@@ -177,21 +177,36 @@ public class Moosique {
        }
 
        /** 
-        * Rewinds the current sequence the given number of measures.
-        * @param measures      the number of measures to rewind
+        * Returns the current tick position of the sequencer.
+        * @return the tick position
         */
        public static long getPosition() {
                return position;
        }
 
        /** 
-        * Rewinds the current sequence the given number of measures.
-        * @param measures      the number of measures to rewind
+        * Sets the current tick position of the sequencer.
+        * @param ticks         the tick position
         */
        public static void setPosition(long ticks) {
                position = ticks;
        }
 
+       /** 
+        * Returns true if the current sequence has been edited.
+        * @return the tick position
+        */
+       public static boolean isEdited() {
+               return isEdited;
+       }
+
+       /** 
+        * Sets the current sequence as edited, which implies prompts when loading a new sequence.
+        */
+       public static void setEdited() {
+               isEdited = true;
+       }
+
        /** 
         * Rewinds the current sequence the given number of measures.
         * @param measures      the number of measures to rewind
@@ -222,13 +237,8 @@ public class Moosique {
                } catch (IOException e) {
                        return false;
                }
-
-               // Sends sequence to GUI and sequencer
-               if (gui != null) gui.setSequence(seq);
-               try {
-                       sequencer.setSequence(seq);
-               } catch (InvalidMidiDataException e) {}
-
+               isEdited = false;
+               
                // Searches the sequence for NoteOn events
                Track[] tracks = seq.getTracks();
                MidiEvent noteOn, noteOff = null, nextEvent;
@@ -269,6 +279,11 @@ public class Moosique {
                                }
                        }
                }
+               // Sends sequence to GUI and sequencer, then returns
+               if (gui != null) gui.setSequence(seq);
+               try {
+                       sequencer.setSequence(seq);
+               } catch (InvalidMidiDataException e) {}
                return true;
        }
 
@@ -298,4 +313,4 @@ public class Moosique {
                if (synthesizer.isOpen()) synthesizer.close();
                System.exit(0);
        }
-}
\ No newline at end of file
+}