]> ruin.nu Git - moosique.git/blobdiff - Moosique.java
no message
[moosique.git] / Moosique.java
index 0fc6fd74aba1f76cb11b17d1ec75baf8a79657ed..5cf7af5b814f6c6eb07dcab4755d1bd894223f21 100644 (file)
@@ -28,7 +28,7 @@ public class Moosique {
 
        private static String filename;
        private static long editPosition;
-       private static boolean makeGUI = true, isEdited = false, drawEmptyTracks = false;
+       private static boolean makeGUI = true, initSound = true, isEdited = false, drawEmptyTracks = false;
        private static Thread player;
        public static final int DEFAULT_RESOLUTION = 96, DEFAULT_TRACKS = 4;
 
@@ -44,8 +44,9 @@ public class Moosique {
                // Parses command-line arguments.
                String fileArg = null;
                for (int i = 0; i < args.length; i++) {
-                       if (args[i].equals("-n")) {makeGUI = false;}
-                       else if (fileArg == null) {fileArg = args[i];}
+                       if (args[i].equals("-n")) makeGUI = false;
+                       else if (args[i].equals("-m")) initSound = false;
+                       else if (fileArg == null) fileArg = args[i];
                }
 
                // Acquires MIDI devices and connects them.
@@ -63,7 +64,7 @@ public class Moosique {
                        setActiveChannel(0);
                } catch (MidiUnavailableException e) {
                        System.out.println("Failed, quitting.");
-                       // System.exit(1);
+                       System.exit(1);
                }
                System.out.println("Done");
 
@@ -106,8 +107,8 @@ public class Moosique {
 
 
        /*                              ***
-        **       ACCESSOR METHODS      **
-        ***                            */
+        **       ACCESSOR METHODS       **
+        ***                              */
 
 
 
@@ -156,6 +157,22 @@ public class Moosique {
                return gui;
        }
 
+       /** 
+        * Calculates the position (measures, beats, ticks) in the current sequence for the given tick position.
+        * @return an array of integers where index 0 is measures, 1 is beats and 2 is ticks.
+        */
+       public static int[] getPositionForTick(long ticks) {
+               /*
+               int measures, beats, ticks;
+               for (int i = 0; i < timeSignatures.length; i++) {
+                       long tick = timeSignatures[i].getTick();
+                       // Split the ticks in the interval into measures, beats and ticks.
+               }
+               */
+               int[] pos = {1, 1, 1};
+               return pos;
+       }
+
        /** 
         * Returns the receiver of the current sequencer.
         * @return the receiver
@@ -189,6 +206,21 @@ public class Moosique {
                // if (tempoMsg == null) return 0;
        }
 
+       /** 
+        * Calculates the tick position in the current sequence for the given position (measures, beats, ticks).
+        * @return the tick position.
+        */
+       public static long getTicksForPosition(int measures, int beats, int ticks) {
+               long tickPos = 0;
+               /*
+               for (int i = 0; i < timeSignatures.length; i++) {
+                       long tick = timeSignatures[i].getTick();
+                       // Add the measures, beats and ticks in the interval.
+               }
+               */
+               return tickPos;
+       }
+
        /** 
         * Returns the tempo of the current sequence.
         * @return the tick position
@@ -224,8 +256,8 @@ public class Moosique {
 
 
        /*                              ***
-        **       MUTATOR METHODS       **
-        ***                            */
+        **       MUTATOR METHODS        **
+        ***                              */
 
 
 
@@ -296,6 +328,14 @@ public class Moosique {
        public static void setTimeSig(int bpm) {
                // timeSigMsg
        }
+       
+       public static void setTrackSolo(Track track, boolean on){
+               trackSolo.put(track, new Boolean(on));  
+       }
+
+       public static void setTrackMute(Track track, boolean on){
+               trackMute.put(track, new Boolean(on));  
+       }
 
 
 
@@ -305,8 +345,8 @@ public class Moosique {
 
 
        /*                              ***
-        **       PLAYBACK METHODS      **
-        ***                            */
+        **       PLAYBACK METHODS       **
+        ***                              */
 
 
 
@@ -404,8 +444,8 @@ public class Moosique {
 
 
        /*                              ***
-        **       SYSTEM & IO METHODS   **
-        ***                            */
+        **       SYSTEM & IO METHODS    **
+        ***                              */
 
 
 
@@ -575,12 +615,4 @@ public class Moosique {
                if (synthesizer.isOpen()) synthesizer.close();
                System.exit(0);
        }
-       
-       public static void setTrackSolo(Track track, boolean on){
-               trackSolo.put(track, new Boolean(on));  
-       }
-
-       public static void setTrackMute(Track track, boolean on){
-               trackMute.put(track, new Boolean(on));  
-       }
 }