edu.uiuc.cs397rhc.sound
Class ConditionalMidiFilter

java.lang.Object
  extended by edu.uiuc.cs397rhc.sound.MidiFilter
      extended by edu.uiuc.cs397rhc.sound.ConditionalMidiFilter
All Implemented Interfaces:
javax.sound.midi.Receiver, javax.sound.midi.Transmitter
Direct Known Subclasses:
ChannelMapFilter, VelocityFilter

public abstract class ConditionalMidiFilter
extends MidiFilter

ConditionalMidiFilter is a MidiFilter whose isApplicable() method is based entirely on an associated MidiCondition. These are suited for transformations on incoming ShortMessages.

Author:
Pedro DeRose

Constructor Summary
ConditionalMidiFilter()
          Creates a ConditionalMidiFilter with no Receiverthat always applies.
ConditionalMidiFilter(MidiCondition condition)
          Creates a ConditionalMidiFilter with no Receiverthat applies when the given MidiCondition is satisfied.
ConditionalMidiFilter(javax.sound.midi.Receiver receiver)
          Creates a ConditionalMidiFilter with the given Receiver that always applies.
ConditionalMidiFilter(javax.sound.midi.Receiver receiver, MidiCondition condition)
          Creates a ConditionalMidiFilter with the given Receiver that applies when the given MidiCOndition is satisfied.
 
Method Summary
 MidiCondition getCondition()
          Gets the MidiCondition used to determine when this ConditionalMidiFilter applies.
 boolean isApplicable(javax.sound.midi.MidiMessage msg, long time)
          Determines whether this ConditionalMidiFilter applies to the given MidiMessage and timestamp.
 void setCondition(MidiCondition condition)
          Sets the MidiCondition used to determine when this ConditionalMidiFilter applies.
 
Methods inherited from class edu.uiuc.cs397rhc.sound.MidiFilter
applyFilter, close, getMicrosecondPosition, getReceiver, getSequencer, send, setReceiver, setSequencer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConditionalMidiFilter

public ConditionalMidiFilter()
Creates a ConditionalMidiFilter with no Receiverthat always applies.


ConditionalMidiFilter

public ConditionalMidiFilter(MidiCondition condition)
Creates a ConditionalMidiFilter with no Receiverthat applies when the given MidiCondition is satisfied.

Parameters:
condition - the condition

ConditionalMidiFilter

public ConditionalMidiFilter(javax.sound.midi.Receiver receiver)
Creates a ConditionalMidiFilter with the given Receiver that always applies.

Parameters:
receiver - the receiver

ConditionalMidiFilter

public ConditionalMidiFilter(javax.sound.midi.Receiver receiver,
                             MidiCondition condition)
Creates a ConditionalMidiFilter with the given Receiver that applies when the given MidiCOndition is satisfied.

Parameters:
condition - the condition
receiver - the receiver
Method Detail

isApplicable

public boolean isApplicable(javax.sound.midi.MidiMessage msg,
                            long time)
Determines whether this ConditionalMidiFilter applies to the given MidiMessage and timestamp. This is called by send(), with the timestamp replaced by the microsecond position of the associated sequencer if the original timestamp was -1 and a sequencer has been specified.

Overrides:
isApplicable in class MidiFilter
Parameters:
msg - the message
time - the timestamp
Returns:
true if the given condition's isSatisfiedBy(msg,time) returns true, false otherwise

setCondition

public void setCondition(MidiCondition condition)
Sets the MidiCondition used to determine when this ConditionalMidiFilter applies.

Parameters:
condition - the new condition

getCondition

public MidiCondition getCondition()
Gets the MidiCondition used to determine when this ConditionalMidiFilter applies.

Returns:
the current condition