import java.awt.*;
import java.awt.event.*;
-/*
+/**
* Moosique's graphical user interface.
*
* @author Mikael Andreen
Sequence seq;
- /*
+ /**
* Creates the GUI.
*/
public MooGUI(Sequence seq) {
setVisible(true);
}
- /*
+ /**
* Changes the sequence of the GUI.
* @param sequence the MIDI sequence to visualize
*/
import java.awt.*;
import java.awt.event.*;
-/*
+/**
* A Combo Box where the instrument of the currently active channel can be selected.
*
* @author Einar Pehrson
import javax.sound.midi.*;
import java.awt.event.*;
-/*
+/**
* Functional representation of a MIDI note, which contains two MIDI events, note on and note off.
*
* @author Einar Pehrson
private static final int startNote = 48;
private static final int[] keyToNote = new int[120];
- /*
+ /**
* Plays the appropriate MIDI NoteOn event.
*/
public void keyPressed(KeyEvent e) {
}
}
- /*
+ /**
* Plays the appropriate MIDI NoteOff event.
*/
public void keyReleased(KeyEvent e) {
}
}
- /* Maps keycodes (array indices) to MIDI note numbers using the following layout:
+ /** Maps keycodes (array indices) to MIDI note numbers using the following layout:
*
* 2 3 5 6 7 9 0 => # # # # # # #
* q w e r t y u i o p => c d e f g a b c d e
import javax.swing.*;
-/*
+/**
*
*
* @author Andersson, Andreen, Lanneskog, Pehrson
public class MooMenu {
- /*
+ /**
* Creates the menus.
*/
public MooMenu () {
import javax.sound.midi.*;
-/*
+/**
* Functional representation of a MIDI note, which adds functionality to the existent MidiEvent class.
* Also provides a reference to the corresponding NoteOff event.
*
protected MidiEvent noteOffEvent;
protected ShortMessage noteOnMsg, noteOffMsg;
- /*
+ /**
* Creates a MooNote from the given NoteOn event in the current track.
* @param noteOnEvent the NoteOn event of the note
*/
noteOnMsg = (ShortMessage)getMessage();
}
- /*
+ /**
* Creates a MooNote from the given NoteOn event in the current track and creates a reference to
* the corresponding NoteOff event.
* @param noteOnEvent the NoteOn event of the note
noteOffMsg = (ShortMessage)noteOffEvent.getMessage();
}
- /*
+ /**
* Creates a MooNote of the given pitch, velocity and duration in the current track.
* @param track the track to which the MooNote was added
* @param channel the channel of the note (1-16)
} catch (InvalidMidiDataException e) {}
}
- /*
+ /**
* Sets the channel of the current note.
* @param channel the channel of the note (1-16)
*/
} catch (InvalidMidiDataException e) {}
}
- /*
+ /**
* Sets the pitch of the current note.
* @param pitch the pitch of the note (0-127)
*/
} catch (InvalidMidiDataException e) {}
}
- /*
+ /**
* Sets the velocity of the current note.
* @param vel the velocity of the note (0-127)
*/
} catch (InvalidMidiDataException e) {}
}
- /*
+ /**
* Sets the duration of the current note (or rather moves the note off event).
* @param n the duration of the note in ticks (96 per beat)
*/
if (hasNoteOffEvent()) noteOffEvent.setTick(getTick() + ticks);
}
- /*
+ /**
* Sets the timestamp of the current note.
* @param tick the timestamp of the note in ticks (96 per beat)
*/
super.setTick(tick);
}
- /*
+ /**
* Returns the channel of the current note.
* @return the channel of the note (1-16)
*/
return noteOnMsg.getChannel();
}
- /*
+ /**
* Returns the pitch of the current note.
* @return the pitch of the note (0-127)
*/
return noteOnMsg.getData1();
}
- /*
+ /**
* Returns the velocity of the current note.
* @return the velocity of the note (0-127)
*/
return noteOnMsg.getData2();
}
- /*
+ /**
* Returns the duration of the current note.
* @return the duration of the note (in ticks)
*/
return (int)(getTick() - noteOffEvent.getTick());
}
- /*
+ /**
* Returns whether the NoteOff event was found.
* @return the note off MidiEvent
*/
import java.awt.*;
import java.awt.event.*;
-/*
+/**
* Graphical representation of a MIDI note.
*
* @author Andersson, Andreen, Lanneskog, Pehrson
public class MooNoteElement extends JPanel{
private MooNote note;
- /*
+ /**
* Creates a new note element.
* @param mn The note that will be graphically represented
*/
}
- /**
+ /***
*
*/
public void paintComponent(Graphics g)
import java.awt.*;
import java.awt.event.*;
-/*
+/**
* Graphical representation of a MIDI note.
*
* @author Andersson, Andreen, Lanneskog, Pehrson
public class MooNoteProp extends JDialog{
private MooNote note;
- /*
+ /**
* Creates a new note preference dialog.
* @param mn The note that will be graphically represented
*/
import javax.swing.*;
-/*
+/**
*
*
* @author Andersson, Andreen, Lanneskog, Pehrson
public class MooStatus {
- /*
+ /**
* Creates the status bar.
*/
public MooStatus () {
import javax.swing.*;
-/*
+/**
*
*
* @author Andersson, Andreen, Lanneskog, Pehrson
public class MooToolbar {
- /*
+ /**
* Creates the toolbar.
*/
public MooToolbar () {
import javax.swing.*;
-/*
+/**
* The title bar for each track with track name, channel, instrument etc.
*
* @author Andersson, Andreen, Lanneskog, Pehrson
public class MooTrackTitle {
- /*
+ /**
* Creates the title bar.
*/
public MooTrackTitle () {
import javax.swing.*;
-/*
+/**
*
*
* @author Andersson, Andreen, Lanneskog, Pehrson
public class MooTrackView {
- /*
+ /**
* Creates
*/
public MooTrackView () {
import javax.swing.*;
-/*
+/**
*
*
* @author Andersson, Andreen, Lanneskog, Pehrson
public class MooView {
- /*
+ /**
* Creates
*/
public MooView () {
import javax.swing.*;
-/*
+/**
*
*
* @author Andersson, Andreen, Lanneskog, Pehrson
public class MooViewCounter {
- /*
+ /**
* Creates
*/
public MooViewCounter () {
import javax.swing.*;
import java.io.*;
-/*
+/**
* Moosique - The MIDI Tracker
*
* Main class that handles initiation, IO and sound.
protected static MooGUI gui;
protected static Sequence seq;
- protected static Sequencer sequencer = null;
- protected static Synthesizer synthesizer = null;
+ protected static Sequencer sequencer;
+ protected static Synthesizer synthesizer;
protected static MidiChannel[] channels;
protected static MidiChannel activeChannel;
protected static String filename;
protected static long position;
- /*
+ /**
* Starts the application.
*/
public static void main (String[] args) {
System.out.println("Done");
}
- /*
+ /**
* Returns a pointer to the current sequence.
* @return the current sequence
*/
return seq;
}
- /*
+ /**
* Returns a pointer to the MidiChannels of the selected synthesizer.
* @return the available MidiChannels
*/
return channels;
}
- /*
+ /**
* Returns a pointer to the currently active MidiChannel.
* @return the active MidiChannel
*/
return activeChannel;
}
- /*
+ /**
* Sets the currently active MidiChannel.
* @param channel the number of the MidiChannel to activate
*/
activeChannel = channels[channel];
}
- /*
+ /**
* Replaces the current sequence with a new one, holding three empty tracks.
*/
public static void clearSequence() {
}
- /*
+ /**
* Starts playback of the current sequence.
*/
public static void play() {
sequencer.start();
}
- /*
+ /**
* Pauses playback of the current sequence.
*/
public static void pause() {
sequencer.stop();
}
- /*
+ /**
* Resumes playback of the current sequence.
*/
public static void resume() {
sequencer.start();
}
- /*
+ /**
* Stops playback of the current sequence.
*/
public static void stop() {
sequencer.setTickPosition(position);
}
- /*
+ /**
* Rewinds the current sequence the given number of measures.
* @param measures the number of measures to rewind
*/
return position;
}
- /*
+ /**
* Rewinds the current sequence the given number of measures.
* @param measures the number of measures to rewind
*/
position = ticks;
}
- /*
+ /**
* Rewinds the current sequence the given number of measures.
* @param measures the number of measures to rewind
*/
position -= ticks;
}
- /*
+ /**
* Fast forwards the current sequence the given number of measures.
* @param measures the number of measures to fast forward
*/
position += ticks;
}
- /*
+ /**
* Loads the MooSequence in the given file.
* @param filename the filename to use
*/
} catch (InvalidMidiDataException e) {
return false;
} catch (IOException e) {
- JOptionPane.showMessageDialog(null, "File", "alert", JOptionPane.ERROR_MESSAGE);
+ JOptionPane.showMessageDialog(null, "Error 404", "File Not Found", JOptionPane.ERROR_MESSAGE);
return false;
}
return true;
}
- /*
+ /**
* Saves the current sequence to the given filename
* @param filename the filename to use
*/
public static void saveAs(String filename) throws IOException {
MidiSystem.write(seq, 1, new File(filename));
-
}
- /*
+ /**
* Saves the current sequence to the previously given filename.
*/
public static void save() throws IOException {
saveAs(filename);
}
- /*
+ /**
* Releases all reserved devices and exits the program.
*/
public static void quit() {
- if (sequencer.isOpen()) {
- try {
- sequencer.open();
- } catch (MidiUnavailableException e) {}
- }
+ if (sequencer.isOpen()) sequencer.close();
+ if (synthesizer.isOpen()) synthesizer.close();
System.exit(0);
}
}
\ No newline at end of file