RealTimeSequencer.java revision 0
0N/A private final static boolean DEBUG_PUMP = false;
0N/A private final static boolean DEBUG_PUMP_ALL = false;
0N/A private boolean autoConnect = false;
0N/A private boolean doAutoConnectAtNextOpen = false;
0N/A throws InvalidMidiDataException {
0N/A if (Printer.trace) Printer.trace("<< RealTimeSequencer: setSequence(" + sequence +") completed");
0N/A public synchronized void setSequence(InputStream stream) throws IOException, InvalidMidiDataException {
0N/A MidiFileFormat fileFormat = MidiSystem.getMidiFileFormat(stream); // can throw IOException, InvalidMidiDataException
0N/A synchronized(metaEventListeners) {
0N/A synchronized(controllerEventListeners) {
0N/A Sequence seq = MidiSystem.getSequence(stream); // can throw IOException, InvalidMidiDataException
0N/A if (Printer.trace) Printer.trace("<< RealTimeSequencer: setSequence(" + stream +") completed");
0N/A public void startRecording() {
0N/A public void stopRecording() {
0N/A public boolean isRecording() {
0N/A synchronized(recordingTracks) {
0N/A synchronized(recordingTracks) {
0N/A public float getTempoInBPM() {
0N/A public float getTempoInMPQ() {
0N/A if (needCaching()) {
0N/A return (float) cacheTempoMPQ;
0N/A if (needCaching()) {
0N/A if (needCaching()) {
0N/A public float getTempoFactor() {
0N/A if (needCaching()) {
0N/A return cacheTempoFactor;
0N/A public long getTickLength() {
0N/A public synchronized long getTickPosition() {
0N/A public long getMicrosecondLength() {
0N/A public long getMicrosecondPosition() {
0N/A synchronized (tempoCache) {
0N/A if (Printer.trace) Printer.trace(">> RealTimeSequencer: setMicrosecondPosition("+microseconds+") ");
0N/A synchronized(tempoCache) {
0N/A return masterSyncMode;
0N/A return returnedModes;
0N/A return slaveSyncMode;
0N/A return returnedModes;
0N/A protected int getTrackCount() {
0N/A synchronized(metaEventListeners) {
0N/A synchronized(metaEventListeners) {
0N/A synchronized(controllerEventListeners) {
0N/A public int[] removeControllerEventListener(ControllerEventListener listener, int[] controllers) {
0N/A synchronized(controllerEventListeners) {
0N/A public long getLoopStartPoint() {
0N/A public long getLoopEndPoint() {
0N/A public int getLoopCount() {
0N/A if (doAutoConnectAtNextOpen) {
0N/A private void doAutoConnect() {
0N/A private synchronized void propagateCaches() {
0N/A if (Printer.err) Printer.err("RealTimeSequencer.implClose() called, but playThread not instanciated!");
0N/A if (Printer.err) Printer.err("RealTimeSequencer.implStart() called, but playThread not instanciated!");
0N/A if (Printer.err) Printer.err("RealTimeSequencer.implStop() called, but playThread not instanciated!");
0N/A if (Printer.debug) Printer.debug("sendControllerEvents: message is NOT instanceof ShortMessage!");
0N/A private boolean needCaching() {
0N/A return tempoCache;
0N/A return new boolean[desiredSize];
0N/A protected boolean hasReceivers() {
0N/A return new SequencerReceiver();
0N/A protected boolean hasTransmitters() {
0N/A return new SequencerTransmitter();
0N/A private SequencerTransmitter() {
0N/A synchronized(tempoCache) {
0N/A private RealTimeSequencerInfo() {
0N/A private class ControllerListElement {
0N/A int [] controllers;
0N/A controllers[i] = i;
0N/A private void addControllers(int[] c) {
0N/A controllers[i] = i;
0N/A if (c[i] == controllers[j]) {
0N/A private void removeControllers(int[] c) {
0N/A if (controllers[i] == c[j]) {
0N/A private int[] getControllers() {
0N/A c[i] = controllers[i];
0N/A static class RecordingTrack {
0N/A synchronized(recordingTracks) {
0N/A synchronized(recordingTracks) {
0N/A boolean interrupted = false;
0N/A PlayThread() {
0N/A if (Printer.err) Printer.err("Waited more than 2 seconds in RealTimeSequencer.PlayThread.stop()!");
0N/A void playThreadImplStop() {
0N/A interrupted = true;
0N/A while (!interrupted) {
0N/A if (wasRunning) {
0N/A private long ignoreTempoEventAt; // ignore next META tempo during playback at this tick pos only
0N/A private int resolution;
0N/A private float divisionType;
0N/A private boolean needReindex = false;
0N/A needReindex = true;
0N/A if (!hasCachedTempo()) {
0N/A long getTickPos() {
0N/A boolean hasCachedTempo() {
0N/A float getTempoMPQ() {
0N/A float getTempoFactor() {
0N/A return tempoFactor;
0N/A synchronized void muteSoloChanged() {
0N/A needReindex = true;
0N/A synchronized void resetLoopCount() {
0N/A void clearNoteOnCache() {
0N/A if (doControllers) {
0N/A private boolean[] makeDisabledArray() {
0N/A synchronized(RealTimeSequencer.this) {
0N/A return newTrackDisabled;
0N/A synchronized(RealTimeSequencer.this) {
0N/A || !oldDisabled[i])
0N/A && newDisabled[i]) {
0N/A && oldDisabled[i]
0N/A && !newDisabled[i]) {
0N/A if (DEBUG_PUMP) Printer.println(" chaseEvents: setting trackReadPos["+trackNum+"] = "+trackReadPos[trackNum]);
0N/A if (DEBUG_PUMP) Printer.println(" chaseTrackEvents track "+trackNum+": sent "+numControllersSent+" controllers.");
0N/A || (!trackDisabled[t])) {
0N/A private long getCurrentTimeMillis() {
0N/A * ((double) divisionType)
0N/A * ((double) resolution))
0N/A if (DEBUG_PUMP) Printer.println(" reindexTrack: setting trackReadPos["+trackNum+"] = "+trackReadPos[trackNum]);
0N/A boolean changesPending = false;
0N/A changesPending = true;
0N/A return changesPending;
0N/A long currMillis;
0N/A boolean changesPending = false;
0N/A changesPending = false;
0N/A if (needReindex) {
0N/A if (DEBUG_PUMP) Printer.println("Need to re-index at "+currMillis+" millis. TargetTick="+targetTick);
0N/A needReindex = false;
0N/A if (DEBUG_PUMP_ALL) {
0N/A if (e instanceof ArrayIndexOutOfBoundsException) {
0N/A needReindex = true;
0N/A changesPending = true;
0N/A if (changesPending) {
0N/A && !changesPending
0N/A needReindex = false;
0N/A changesPending = false;
0N/A } while (changesPending);