From: Einar Pehrson Date: Sun, 13 Apr 2003 21:55:38 +0000 (+0000) Subject: Implemented some obvious methods. X-Git-Url: https://ruin.nu/git/?p=moosique.git;a=commitdiff_plain;h=ade446bcfe30be5e4a058926387763f72fc3d4a7 Implemented some obvious methods. --- diff --git a/MooNote.java b/MooNote.java index 826b4c3..fcf32e0 100644 --- a/MooNote.java +++ b/MooNote.java @@ -20,8 +20,8 @@ public class MooNote { // 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) @@ -33,7 +33,8 @@ public class MooNote { + @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()); } /* @@ -41,7 +42,8 @@ public class MooNote { + @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); } /* @@ -49,7 +51,7 @@ public class MooNote { + @param n the length of the note in ticks (100 per beat) */ public void setLength(int ticks) { - + } /* @@ -57,7 +59,7 @@ public class MooNote { * @return the note on MidiEvent */ public MidiEvent getNoteOnEvent() { - + return noteOnEvent; } /* @@ -65,7 +67,7 @@ public class MooNote { * @return the note off MidiEvent */ public MidiEvent getNoteOffEvent() { - + return noteOffEvent; } /* @@ -73,7 +75,7 @@ public class MooNote { * @return the pitch of the note */ public int getPitch() { - + return noteOnMsg.getData1(); } /* @@ -81,7 +83,7 @@ public class MooNote { * @return the velocity of the note */ public int getVelocity() { - + return noteOnMsg.getData2(); } /* diff --git a/MooSequence.java b/MooSequence.java index b37424e..2390c4a 100644 --- a/MooSequence.java +++ b/MooSequence.java @@ -1,4 +1,5 @@ import javax.sound.midi.*; +import java.util.*; /* * Functional representation of a MIDI sequence. @@ -9,13 +10,14 @@ import javax.sound.midi.*; public class MooSequence { - private Collection tracks; + private ArrayList tracks; /* * Creates a MooSequence with three tracks. */ public MooSequence () { - + tracks = new ArrayList(); + addTrack(0); } /* @@ -24,7 +26,7 @@ public class MooSequence { * @return the specified track */ public MooTrack getTrack(int track) { - + return tracks.get(track); } /* @@ -32,7 +34,7 @@ public class MooSequence { * @return the number of the tracks */ public int getNumberOfTracks() { - + return tracks.size(); } /* @@ -40,7 +42,7 @@ public class MooSequence { * @param track the number of the track (0-31) */ public void addTrack(int track) { - + tracks.add(track, new MooTrack()); } /* @@ -48,7 +50,7 @@ public class MooSequence { * @param track the number of the track (0-31) */ public void deleteTrack(int track) { - + tracks.remove(track); } /* @@ -63,6 +65,9 @@ public class MooSequence { * 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 diff --git a/MooTrack.java b/MooTrack.java index df542a6..b14bcca 100644 --- a/MooTrack.java +++ b/MooTrack.java @@ -19,7 +19,9 @@ public class MooTrack { * Creates an empty MooTrack. */ public MooTrack () { - + notes = new Collection(); + setInstrument(0); + // Find the first available channel } /* @@ -27,7 +29,7 @@ public class MooTrack { * @param instr the number of the MIDI instrument (0-127) */ public void setInstrument(int instr) { - + instrument = instr; } /* @@ -35,7 +37,7 @@ public class MooTrack { * @param chan the number of the MIDI channel (1-16) */ public void setChannel(int chan) { - + channel = chan; } /* @@ -43,7 +45,7 @@ public class MooTrack { * @return the number of the channel */ public int getChannel() { - + return channel; } /* @@ -51,7 +53,7 @@ public class MooTrack { * @return the number of notes */ public int getNumberOfNotes() { - + return notes.size(); } /* @@ -59,7 +61,7 @@ public class MooTrack { * @param note the MooNote to add */ public void addNote(MooNote note) { - + notes.add(note); } /* @@ -75,23 +77,23 @@ public class MooTrack { * @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; } /* @@ -100,7 +102,7 @@ public class MooTrack { */ public boolean isSolo() { - + return solo; } /* @@ -108,6 +110,6 @@ public class MooTrack { * @return if the track is muted */ public boolean isMute() { - + return mute; } } \ No newline at end of file diff --git a/Moosique.java b/Moosique.java index 8edc142..42c5e2e 100644 --- a/Moosique.java +++ b/Moosique.java @@ -1,5 +1,6 @@ import javax.sound.midi.*; import java.io.*; +// Import external MIDIFileReader and MIDIFileWriter /* * Moosique - The MIDI Tracker @@ -17,6 +18,7 @@ public class Moosique { private static Sequence seq; private static Sequencer sequencer = null; private static String filename; + private static int position; /* * Starts the application.