// MidiEvent(MidiMessage message, long tick)
noteOnMsg = new ShortMessage();
noteOffMsg = new ShortMessage();
- noteOnMsg.setMessage(ShortMessage.NOTE_ON, top.getChannel(), pitch, velocity);
- noteOffMsg.setMessage(ShortMessage.NOTE_OFF, top.getChannel(), pitch, velocity);
+ noteOnMsg.setMessage(ShortMessage.NOTE_ON, pitch, velocity);
+ noteOffMsg.setMessage(ShortMessage.NOTE_OFF, pitch, velocity);
// noteOnTime = ???;
noteOffTime = noteOnTime + length;
noteOnEvent = new MidiEvent(noteOnMsg, noteOnTime)
+ @param pitch the pitch of the note (0-127)
*/
public void setPitch(int pitch) {
-
+ noteOnMsg.setMessage(ShortMessage.NOTE_ON, pitch, noteOnMsg.getData2());
+ noteOffMsg.setMessage(ShortMessage.NOTE_OFF, pitch, noteOffMsg.getData2());
}
/*
+ @param vel the velocity of the note (0-127)
*/
public void setVelocity(int vel) {
-
+ noteOnMsg.setMessage(ShortMessage.NOTE_ON, noteOnMsg.getData1(), vel);
+ noteOffMsg.setMessage(ShortMessage.NOTE_OFF, noteOffMsg.getData1(), vel);
}
/*
+ @param n the length of the note in ticks (100 per beat)
*/
public void setLength(int ticks) {
-
+
}
/*
* @return the note on MidiEvent
*/
public MidiEvent getNoteOnEvent() {
-
+ return noteOnEvent;
}
/*
* @return the note off MidiEvent
*/
public MidiEvent getNoteOffEvent() {
-
+ return noteOffEvent;
}
/*
* @return the pitch of the note
*/
public int getPitch() {
-
+ return noteOnMsg.getData1();
}
/*
* @return the velocity of the note
*/
public int getVelocity() {
-
+ return noteOnMsg.getData2();
}
/*
import javax.sound.midi.*;
+import java.util.*;
/*
* Functional representation of a MIDI sequence.
public class MooSequence {
- private Collection tracks;
+ private ArrayList tracks;
/*
* Creates a MooSequence with three tracks.
*/
public MooSequence () {
-
+ tracks = new ArrayList();
+ addTrack(0);
}
/*
* @return the specified track
*/
public MooTrack getTrack(int track) {
-
+ return tracks.get(track);
}
/*
* @return the number of the tracks
*/
public int getNumberOfTracks() {
-
+ return tracks.size();
}
/*
* @param track the number of the track (0-31)
*/
public void addTrack(int track) {
-
+ tracks.add(track, new MooTrack());
}
/*
* @param track the number of the track (0-31)
*/
public void deleteTrack(int track) {
-
+ tracks.remove(track);
}
/*
* Resets the solo and mute settings of all tracks.
*/
public void activateTracks() {
-
+ for (int i = 0; i++; i < tracks.size())
+ tracks[i].setSolo(false);
+ tracks[i].setMute(false);
+ }
}
}
\ No newline at end of file
* Creates an empty MooTrack.
*/
public MooTrack () {
-
+ notes = new Collection();
+ setInstrument(0);
+ // Find the first available channel
}
/*
* @param instr the number of the MIDI instrument (0-127)
*/
public void setInstrument(int instr) {
-
+ instrument = instr;
}
/*
* @param chan the number of the MIDI channel (1-16)
*/
public void setChannel(int chan) {
-
+ channel = chan;
}
/*
* @return the number of the channel
*/
public int getChannel() {
-
+ return channel;
}
/*
* @return the number of notes
*/
public int getNumberOfNotes() {
-
+ return notes.size();
}
/*
* @param note the MooNote to add
*/
public void addNote(MooNote note) {
-
+ notes.add(note);
}
/*
* @param note the index of the note
*/
public MooNote getNote(int note) {
-
+ return notes.get(note);
}
/*
* Makes the current track solo.
* @param set if the track should be solo
*/
- public void solo(boolean set) {
-
+ public void setSolo(boolean set) {
+ solo = set;
}
/*
* Mutes the current track.
* @param set if the track should be muted
*/
- public void mute(boolean set) {
-
+ public void setMute(boolean set) {
+ mute = set;
}
/*
*/
public boolean isSolo() {
-
+ return solo;
}
/*
* @return if the track is muted
*/
public boolean isMute() {
-
+ return mute;
}
}
\ No newline at end of file
import javax.sound.midi.*;
import java.io.*;
+// Import external MIDIFileReader and MIDIFileWriter
/*
* Moosique - The MIDI Tracker
private static Sequence seq;
private static Sequencer sequencer = null;
private static String filename;
+ private static int position;
/*
* Starts the application.