private static String filename;
private static long editPosition;
- private static boolean makeGUI = true, isEdited = false, drawEmptyTracks = false;
+ private static boolean makeGUI = true, initSound = true, isEdited = false, drawEmptyTracks = false;
private static Thread player;
public static final int DEFAULT_RESOLUTION = 96, DEFAULT_TRACKS = 4;
// Parses command-line arguments.
String fileArg = null;
for (int i = 0; i < args.length; i++) {
- if (args[i].equals("-n")) {makeGUI = false;}
- else if (fileArg == null) {fileArg = args[i];}
+ if (args[i].equals("-n")) makeGUI = false;
+ else if (args[i].equals("-m")) initSound = false;
+ else if (fileArg == null) fileArg = args[i];
}
// Acquires MIDI devices and connects them.
setActiveChannel(0);
} catch (MidiUnavailableException e) {
System.out.println("Failed, quitting.");
- // System.exit(1);
+ System.exit(1);
}
System.out.println("Done");
/* ***
- ** ACCESSOR METHODS **
- *** */
+ ** ACCESSOR METHODS **
+ *** */
return gui;
}
+ /**
+ * Calculates the position (measures, beats, ticks) in the current sequence for the given tick position.
+ * @return an array of integers where index 0 is measures, 1 is beats and 2 is ticks.
+ */
+ public static int[] getPositionForTick(long ticks) {
+ /*
+ int measures, beats, ticks;
+ for (int i = 0; i < timeSignatures.length; i++) {
+ long tick = timeSignatures[i].getTick();
+ // Split the ticks in the interval into measures, beats and ticks.
+ }
+ */
+ int[] pos = {1, 1, 1};
+ return pos;
+ }
+
/**
* Returns the receiver of the current sequencer.
* @return the receiver
// if (tempoMsg == null) return 0;
}
+ /**
+ * Calculates the tick position in the current sequence for the given position (measures, beats, ticks).
+ * @return the tick position.
+ */
+ public static long getTicksForPosition(int measures, int beats, int ticks) {
+ long tickPos = 0;
+ /*
+ for (int i = 0; i < timeSignatures.length; i++) {
+ long tick = timeSignatures[i].getTick();
+ // Add the measures, beats and ticks in the interval.
+ }
+ */
+ return tickPos;
+ }
+
/**
* Returns the tempo of the current sequence.
* @return the tick position
/* ***
- ** MUTATOR METHODS **
- *** */
+ ** MUTATOR METHODS **
+ *** */
public static void setTimeSig(int bpm) {
// timeSigMsg
}
+
+ public static void setTrackSolo(Track track, boolean on){
+ trackSolo.put(track, new Boolean(on));
+ }
+
+ public static void setTrackMute(Track track, boolean on){
+ trackMute.put(track, new Boolean(on));
+ }
/* ***
- ** PLAYBACK METHODS **
- *** */
+ ** PLAYBACK METHODS **
+ *** */
} catch (InvalidMidiDataException e) {}
Track[] tracks = seq.getTracks();
+ sequencer.start();
+
for (int i = 0; i < tracks.length; i++) {
Object ob = trackSolo.get(tracks[i]);
if(ob instanceof Boolean){
- System.out.println("Track solo " + i + "= "+ ob);
sequencer.setTrackSolo(i,((Boolean)ob).booleanValue());
}
ob = trackMute.get(tracks[i]);
if(ob instanceof Boolean){
- System.out.println("Track mute " + i + "= "+ ob);
sequencer.setTrackMute(i,((Boolean)ob).booleanValue());
}
}
- sequencer.start();
// Disables input to volatile components
// gui.disable();
/* ***
- ** SYSTEM & IO METHODS **
- *** */
+ ** SYSTEM & IO METHODS **
+ *** */
sequencer.setSequence(seq);
filename = null;
emptyTracks = new ArrayList();
+ trackSolo = new HashMap();
+ trackMute = new HashMap();
} catch (InvalidMidiDataException e) {}
// Sends sequence to GUI.
if (gui != null) gui.setSequence(seq);
if (synthesizer.isOpen()) synthesizer.close();
System.exit(0);
}
-
- public static void setTrackSolo(Track track, boolean on){
- trackSolo.put(track, new Boolean(on));
- }
-
- public static void setTrackMute(Track track, boolean on){
- trackMute.put(track, new Boolean(on));
- }
}