/*
* 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.
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();
// Sets up channels and GUI.
System.out.print("Creating GUI...");
- channels = synthesizer.getChannels();
gui = new MooGUI(seq);
System.out.println("Done");
}
}
/*
- * 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);