org.tritonus.midi.device.alsa
Class AlsaSequencer

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

public class AlsaSequencer
extends TSequencer


Nested Class Summary
 class AlsaSequencer.AlsaSequencerReceiver
           
 class AlsaSequencer.AlsaSequencerTransmitter
           
 class AlsaSequencer.LoaderThread
          Pre-loading events to the sequencer queue.
 class AlsaSequencer.MasterSynchronizer
           
 class AlsaSequencer.PlaybackAlsaMidiInListener
           
 class AlsaSequencer.RecordingAlsaMidiInListener
           
 
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
AlsaSequencer(MidiDevice.Info info)
           
 
Method Summary
protected  void closeImpl()
          Subclasses have to override this method to be notified of closeing.
 long getMicrosecondPosition()
          Returns the device time in microseconds.
 Receiver getReceiver()
          Creates a new Receiver object associated with this instance.
 long getTickPosition()
           
 Transmitter getTransmitter()
          Creates a new Transmitter object associated with this instance.
 boolean isRecording()
           
 boolean isRunning()
           
protected  void openImpl()
          Subclasses have to override this method to be notified of opening.
protected  void receive(MidiMessage message, long lTimestamp)
          Receive an event from a Receiver.
 void recordDisable(Track track)
           
 void recordEnable(Track track, int nChannel)
           
 void sendMessageTick(MidiMessage message, long lTick)
          Put a message into the queue.
protected  void setMasterSyncModeImpl(Sequencer.SyncMode syncMode)
           
 void setMicrosecondPosition(long lMicroseconds)
           
protected  void setSequenceImpl()
          Set Sequence.
protected  void setSlaveSyncModeImpl(Sequencer.SyncMode syncMode)
           
protected  void setTempoImpl(float fRealMPQ)
          Change the tempo of the native sequencer part.
 void setTickPosition(long lTick)
           
protected  void setTrackEnabledImpl(int nTrack, boolean bEnabled)
          Shows that a track state has changed.
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, isTrackEnabled, notifyListeners, removeControllerEventListener, removeMetaEventListener, sendControllerEvent, sendMetaMessage, setLatency, setLoopCount, setLoopEndPoint, setLoopStartPoint, setMasterSyncMode, setRealTempo, setSequence, setSequence, setSlaveSyncMode, setTempoFactor, setTempoInBPM, setTempoInMPQ, setTrackMute, setTrackMuteImpl, setTrackSolo, setTrackSoloImpl, start, stop
 
Methods inherited from class org.tritonus.share.midi.TMidiDevice
close, getDeviceInfo, getMaxReceivers, getMaxTransmitters, getReceivers, getTransmitters, getUseIn, getUseOut, isOpen, open, 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.MidiDevice
close, getDeviceInfo, getMaxReceivers, getMaxTransmitters, getReceivers, getTransmitters, isOpen, open
 

Constructor Detail

AlsaSequencer

public AlsaSequencer(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

setSequenceImpl

protected void setSequenceImpl()
Description copied from class: TSequencer
Set Sequence. Subclasses that need to be informed when a Sequence is set should override this method. It is called by setSequence(). Subclasses can find out the new Sequence by calling getSequence().

Overrides:
setSequenceImpl in class TSequencer

isRunning

public boolean isRunning()
Specified by:
isRunning in interface Sequencer
Overrides:
isRunning in class TSequencer

startRecording

public void startRecording()

stopRecording

public void stopRecording()

isRecording

public boolean isRecording()

recordEnable

public void recordEnable(Track track,
                         int nChannel)

recordDisable

public void recordDisable(Track track)

setTempoImpl

protected void setTempoImpl(float fRealMPQ)
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

getTickPosition

public long getTickPosition()

setTickPosition

public void setTickPosition(long lTick)

getMicrosecondPosition

public long getMicrosecondPosition()
Description copied from class: TMidiDevice
Returns the device time in microseconds. This is a default implementation, telling the application program that the device doesn't track time. If a device wants to give timing information, it has to override this method.

Specified by:
getMicrosecondPosition in interface Sequencer
Overrides:
getMicrosecondPosition in class TMidiDevice

setMicrosecondPosition

public void setMicrosecondPosition(long lMicroseconds)

setMasterSyncModeImpl

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

setSlaveSyncModeImpl

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

setTrackEnabledImpl

protected void setTrackEnabledImpl(int nTrack,
                                   boolean bEnabled)
Description copied from class: TSequencer
Shows that a track state has changed. This method is called for each track where the enabled state (calculated from mute and solo) has changed. The boolean value passed represents the new state.

Overrides:
setTrackEnabledImpl in class TSequencer
Parameters:
nTrack - The track number for which the enabled status has changed.
bEnabled - The new enabled state for this track.

sendMessageTick

public void sendMessageTick(MidiMessage message,
                            long lTick)
Put a message into the queue. This is Claus-Dieter's special method: it puts the message to the ALSA queue for delivery at the specified time. The time has to be given in ticks according to the resolution of the currently active Sequence. For this method to work, the Sequencer has to be started. The message is delivered the same way as messages from a Sequence, i.e. to all registered Transmitters. If the current queue position (as returned by getTickPosition()) is already behind the desired schedule time, the message is ignored.

Parameters:
message - the MidiMessage to put into the queue.
lTick - the desired schedule time in ticks.

receive

protected void receive(MidiMessage message,
                       long lTimestamp)
Receive an event from a Receiver. This method is called by AlsaSequencer.AlsaSequencerReceiver on receipt of a MidiMessage.

Overrides:
receive in class TMidiDevice

getReceiver

public Receiver getReceiver()
                     throws MidiUnavailableException
Description copied from class: TMidiDevice
Creates a new Receiver object associated with this instance. In this implementation, an unlimited number of Receivers per MidiDevice can be created.

Specified by:
getReceiver in interface MidiDevice
Overrides:
getReceiver in class TMidiDevice
Throws:
MidiUnavailableException

getTransmitter

public Transmitter getTransmitter()
                           throws MidiUnavailableException
Description copied from class: TMidiDevice
Creates a new Transmitter object associated with this instance. In this implementation, an unlimited number of Transmitters per MidiDevice can be created.

Specified by:
getTransmitter in interface MidiDevice
Overrides:
getTransmitter in class TMidiDevice
Throws:
MidiUnavailableException