]> ruin.nu Git - moosique.git/blobdiff - Moosique.java
Added MooInstrumentList - a subcomponent to MooToolbar -
[moosique.git] / Moosique.java
index 01070c1391956b5667d630a9a1dbac4dd99f3fb1..32c4d375d7e43b0f7b502d0b6b25730f8b0e6771 100644 (file)
@@ -5,23 +5,23 @@ import java.io.*;
 /*
  * Moosique - The MIDI Tracker
  * 
- * Main class that handles initiation, IO and sound FX.
+ * Main class that handles initiation, IO and sound.
  * 
- * @author  Andersson, Andreen, Lanneskog, Pehrson
- * @version 1
+ * @author  Einar Pehrson
  */
  
 public class Moosique {
 
-       private static MooGUI gui;
-       private static Sequence seq;
+       protected static MooGUI gui;
+       protected static Sequence seq;
 
-       private static Sequencer sequencer = null;
-       private static Synthesizer synthesizer = null;
-       private static MidiChannel[] channels;
+       protected static Sequencer sequencer = null;
+       protected static Synthesizer synthesizer = null;
+       protected static MidiChannel[] channels;
+       protected static MidiChannel activeChannel;
 
-       private static String filename;
-       private static long position;
+       protected static String filename;
+       protected static long position;
 
        /* 
         * Starts the application.
@@ -34,12 +34,12 @@ public class Moosique {
                        sequencer = MidiSystem.getSequencer();
                        System.out.print(".");
                        sequencer.open();
-                       System.out.print(".");
                        synthesizer = MidiSystem.getSynthesizer();
                        System.out.print(".");
                        synthesizer.open();
-                       System.out.print(".");
                        sequencer.getTransmitter().setReceiver(synthesizer.getReceiver());
+                       channels = synthesizer.getChannels();
+                       setActiveChannel(0);
                } catch (MidiUnavailableException e) {
                        System.out.println("Failed, quitting.");
                        quit();
@@ -58,7 +58,6 @@ public class Moosique {
 
                // Sets up channels and GUI.
                System.out.print("Creating GUI...");
-               channels = synthesizer.getChannels();
                gui = new MooGUI(seq);
                System.out.println("Done");
        }
@@ -72,13 +71,36 @@ public class Moosique {
        }
 
        /* 
-        * Returns a pointer to the current sequence.
-        * @return the current sequence
+        * Returns a pointer to the MidiChannels of the selected synthesizer.
+        * @return the available MidiChannels
+        */
+       public static MidiChannel[] getChannels() {
+               return channels;
+       }
+
+       /* 
+        * Returns a pointer to the currently active MidiChannel.
+        * @return the active MidiChannel
+        */
+       public static MidiChannel getActiveChannel() {
+               return activeChannel;
+       }
+
+       /* 
+        * Sets the currently active MidiChannel.
+        * @param channel       the number of the MidiChannel to activate
+        */
+       public static void setActiveChannel(int channel) {
+               activeChannel = channels[channel];
+       }
+
+       /* 
+        * Replaces the current sequence with a new one, holding three empty tracks.
         */
        public static void clearSequence() {
                // Creates sequence.
                try {
-                       seq = new Sequence(Sequence.PPQ, 96);
+                       seq = new Sequence(Sequence.PPQ, 96, 3);
                } catch (InvalidMidiDataException e) {}
                // Sends sequence to GUI.
                if (gui != null) gui.setSequence(seq);