org.tritonus.midi.device.java
Class JavaSequencer

java.lang.Object
  extended byorg.tritonus.share.midi.TMidiDevice
      extended byorg.tritonus.share.midi.TSequencer
          extended byorg.tritonus.midi.device.java.JavaSequencer
All Implemented Interfaces:
MidiDevice, Runnable, Sequencer

public class JavaSequencer
extends TSequencer
implements Runnable

Sequencer implementation in pure Java.


Nested Class Summary
static interface JavaSequencer.Clock
          Interface for sequencer clocks.
 
Nested classes inherited from class org.tritonus.share.midi.TMidiDevice
TMidiDevice.Info, TMidiDevice.TReceiver, TMidiDevice.TTransmitter
 
Nested classes inherited from class javax.sound.midi.Sequencer
Sequencer.SyncMode
 
Nested classes inherited from class javax.sound.midi.MidiDevice
MidiDevice.Info
 
Field Summary
 
Fields inherited from interface javax.sound.midi.Sequencer
LOOP_CONTINUOUSLY
 
Constructor Summary
JavaSequencer(MidiDevice.Info info)
           
 
Method Summary
protected  void closeImpl()
          Subclasses have to override this method to be notified of closeing.
 JavaSequencer.Clock getClock()
          Obtain the clock used by this sequencer.
 long getTickPosition()
           
protected  long getTimeInMicroseconds()
          Retrieve system time in microseconds.
 boolean isRecording()
           
protected  void openImpl()
          Subclasses have to override this method to be notified of opening.
 void recordDisable(Track track)
           
 void recordEnable(Track track)
           
 void recordEnable(Track track, int nChannel)
           
 void run()
           
 void setClock(JavaSequencer.Clock clock)
          Set the clock this sequencer should use.
protected  void setMasterSyncModeImpl(Sequencer.SyncMode syncMode)
           
 void setMicrosecondPosition(long lPosition)
           
 void setSequence(Sequence sequence)
           
protected  void setSlaveSyncModeImpl(Sequencer.SyncMode syncMode)
           
protected  void setTempoImpl(float fMPQ)
          Change the tempo of the native sequencer part.
 void setTickPosition(long lPosition)
           
protected  void startImpl()
          Subclasses have to override this method to be notified of starting.
 void startRecording()
           
protected  void stopImpl()
          Subclasses have to override this method to be notified of stopping.
 void stopRecording()
           
 
Methods inherited from class org.tritonus.share.midi.TSequencer
addControllerEventListener, addMetaEventListener, checkOpen, getLatency, getLoopCount, getLoopEndPoint, getLoopStartPoint, getMasterSyncMode, getMasterSyncModes, getMetaEventListeners, getMicrosecondLength, getResolution, getSequence, getSlaveSyncMode, getSlaveSyncModes, getTempoFactor, getTempoInBPM, getTempoInMPQ, getTickLength, getTrackMute, getTrackSolo, isRunning, isTrackEnabled, notifyListeners, removeControllerEventListener, removeMetaEventListener, sendControllerEvent, sendMetaMessage, setLatency, setLoopCount, setLoopEndPoint, setLoopStartPoint, setMasterSyncMode, setRealTempo, setSequence, setSequenceImpl, setSlaveSyncMode, setTempoFactor, setTempoInBPM, setTempoInMPQ, setTrackEnabledImpl, setTrackMute, setTrackMuteImpl, setTrackSolo, setTrackSoloImpl, start, stop
 
Methods inherited from class org.tritonus.share.midi.TMidiDevice
close, getDeviceInfo, getMaxReceivers, getMaxTransmitters, getMicrosecondPosition, getReceiver, getReceivers, getTransmitter, getTransmitters, getUseIn, getUseOut, isOpen, open, receive, sendImpl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.sound.midi.Sequencer
getMicrosecondPosition
 
Methods inherited from interface javax.sound.midi.MidiDevice
close, getDeviceInfo, getMaxReceivers, getMaxTransmitters, getReceiver, getReceivers, getTransmitter, getTransmitters, isOpen, open
 

Constructor Detail

JavaSequencer

public JavaSequencer(MidiDevice.Info info)
Method Detail

openImpl

protected void openImpl()
Description copied from class: TMidiDevice
Subclasses have to override this method to be notified of opening.

Overrides:
openImpl in class TMidiDevice

closeImpl

protected void closeImpl()
Description copied from class: TMidiDevice
Subclasses have to override this method to be notified of closeing.

Overrides:
closeImpl in class TMidiDevice

startImpl

protected void startImpl()
Description copied from class: TSequencer
Subclasses have to override this method to be notified of starting.

Overrides:
startImpl in class TSequencer

stopImpl

protected void stopImpl()
Description copied from class: TSequencer
Subclasses have to override this method to be notified of stopping.

Overrides:
stopImpl in class TSequencer

run

public void run()
Specified by:
run in interface Runnable

setMasterSyncModeImpl

protected void setMasterSyncModeImpl(Sequencer.SyncMode syncMode)
Overrides:
setMasterSyncModeImpl in class TSequencer

setSlaveSyncModeImpl

protected void setSlaveSyncModeImpl(Sequencer.SyncMode syncMode)
Overrides:
setSlaveSyncModeImpl in class TSequencer

setSequence

public void setSequence(Sequence sequence)
                 throws InvalidMidiDataException
Specified by:
setSequence in interface Sequencer
Overrides:
setSequence in class TSequencer
Throws:
InvalidMidiDataException

setMicrosecondPosition

public void setMicrosecondPosition(long lPosition)
Specified by:
setMicrosecondPosition in interface Sequencer

setTickPosition

public void setTickPosition(long lPosition)
Specified by:
setTickPosition in interface Sequencer

getTickPosition

public long getTickPosition()
Specified by:
getTickPosition in interface Sequencer

recordDisable

public void recordDisable(Track track)
Specified by:
recordDisable in interface Sequencer

recordEnable

public void recordEnable(Track track)

recordEnable

public void recordEnable(Track track,
                         int nChannel)
Specified by:
recordEnable in interface Sequencer

isRecording

public boolean isRecording()
Specified by:
isRecording in interface Sequencer

stopRecording

public void stopRecording()
Specified by:
stopRecording in interface Sequencer

startRecording

public void startRecording()
Specified by:
startRecording in interface Sequencer

setTempoImpl

protected void setTempoImpl(float fMPQ)
Description copied from class: TSequencer
Change the tempo of the native sequencer part. This method has to be defined by subclasses according to the native facilities they use for sequenceing. The implementation should not take into account the tempo factor. This is handled elsewhere.

Specified by:
setTempoImpl in class TSequencer

getTimeInMicroseconds

protected long getTimeInMicroseconds()
Retrieve system time in microseconds. This method uses the clock as set with setClock(org.tritonus.midi.device.java.JavaSequencer.Clock).

Returns:
the system time in microseconds

setClock

public void setClock(JavaSequencer.Clock clock)
Set the clock this sequencer should use.

Parameters:
clock - the Clock to be used
Throws:
IllegalStateException - if the sequencer is not closed

getClock

public JavaSequencer.Clock getClock()
Obtain the clock used by this sequencer.

Returns:
the clock currently set for this sequencer