1 import javax.sound.midi.*;
3 // Import external MIDIFileReader and MIDIFileWriter
6 * Moosique - The MIDI Tracker
8 * Main class that handles initiation, IO and sound FX.
10 * @author Andersson, Andreen, Lanneskog, Pehrson
14 public class Moosique {
16 private static MooGUI gui;
17 private static MooSequence mooSeq;
18 private static Sequence seq;
19 private static Sequencer sequencer = null;
20 private static String filename;
21 private static int position;
24 * Starts the application.
26 public static void main (String[] args) {
27 // Creates song and GUI
28 seq = new MooSequence();
29 gui = new MooGUI(mooSeq);
31 // Initializes MIDI sequencer
33 sequencer = MidiSystem.getSequencer();
35 } catch (MidiUnavailableException e) {
41 * Returns a pointer to the current sequence.
42 * @return the current sequence
44 public static MooSequence getSequence() {
49 * Starts playback of the current sequence.
51 public static void play() {
52 seq = mooSeq.getSequence();
53 sequencer.setSequence(seq);
58 * Pauses playback of the current sequence.
60 public static void pause() {
65 * Stops playback of the current sequence.
67 public static void stop() {
72 * Rewinds the current sequence the given number of measures.
73 * @param measures the number of measures to rewind
75 public static void rewind(int measures) {
80 * Fast forwards the current sequence the given number of measures.
81 * @param measures the number of measures to fast forward
83 public static void forward(int measures) {
88 * Loads the MooSequence in the given file.
89 * @param filename the filename to use
91 public static void load(String filename) throws IOException {
96 * Saves the current sequence to the given filename
97 * @param filename the filename to use
99 public static void saveAs(String filename) throws IOException {
104 * Saves the current sequence to the previously given filename.
106 public static void save() throws IOException {
111 * Exports the current sequence to a standard MIDI file.
112 * @param filename the filename to use
114 public static void exportMIDI(String filename) throws IOException {