org.jfugue
Class PatternTransformer

java.lang.Object
  extended by org.jfugue.PatternTransformer
All Implemented Interfaces:
java.util.EventListener, ParserListener
Direct Known Subclasses:
DiatonicIntervalPatternTransformer, DurationPatternTransformer, IntervalPatternTransformer, IntervalTransformer, ReversePatternTransformer

public abstract class PatternTransformer
extends java.lang.Object
implements ParserListener

This class is used to transform a pattern. Extend this class to create your own PatternTransformer, which listens to parser events and can modify the events that are fired off by the parser. Some sample PatternTransformer subclasses are packaged with JFugue; refer to those to see examples of transformers in action. This feature is covered in detail in The Complete Guide to JFugue.

Version:
2.0
Author:
David Koelle
See Also:
DiatonicIntervalPatternTransformer, DurationPatternTransformer, IntervalPatternTransformer, ReversePatternTransformer

Field Summary
protected  Pattern returnPattern
          Contains the pattern to return at the end of the transformation.
 
Constructor Summary
PatternTransformer()
           
 
Method Summary
 void channelPressureEvent(ChannelPressure channelPressure)
          Extend this method to make your transformer modify the channel pressure messages.
 void controllerEvent(Controller controller)
          Extend this method to make your transformer modify the controller messages.
 java.lang.String getDescription()
          Indicates what this PatternTransformer does.
 java.lang.Object getParameter(java.lang.String name)
          Returns a variable setting.
 java.lang.String getParameters()
          Returns a list of parameters needed by your Transformer.
 void instrumentEvent(Instrument instrument)
          Extend this method to make your transformer modify the instrument.
 void keySignatureEvent(KeySignature keySig)
          Extend this method to make your transformer modify the time.
 void layerEvent(Layer layer)
          Extend this method to make your transformer modify the layer.
 void measureEvent(Measure measure)
          Extend this method to make your transformer modify the measure.
 void noteEvent(Note note)
          Extend this method to make your transformer modify the note.
 void parallelNoteEvent(Note note)
          Extend this method to make your transformer modify the note.
 void pitchBendEvent(PitchBend pitchBend)
          Extend this method to make your transformer modify the pitch bend messages.
 void polyphonicPressureEvent(PolyphonicPressure polyphonicPressure)
          Extend this method to make your transformer modify the polyphonic pressure messages.
 void putParameter(java.lang.String name, java.lang.Object value)
          Places a value for a variable.
 void sequentialNoteEvent(Note note)
          Extend this method to make your transformer modify the note.
 void tempoEvent(Tempo tempo)
          Extend this method to make your transformer modify the tempo.
 void timeEvent(Time time)
          Extend this method to make your transformer modify the time.
 Pattern transform(Pattern p)
          Transforms the pattern, according to the event method that you have presumably extended.
 void voiceEvent(Voice voice)
          Extend this method to make your transformer modify the voice.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

returnPattern

protected Pattern returnPattern
Contains the pattern to return at the end of the transformation.

Constructor Detail

PatternTransformer

public PatternTransformer()
Method Detail

getParameters

public java.lang.String getParameters()
Returns a list of parameters needed by your Transformer.

It is very important to keep these strings standardized! This will allow future programs to understand what is required of each Transformer. Therefore, make your Transformer return strings like this. Notice the use of quotes and slashes.

'variable name'/type/description/default

If you need to return multiple Strings, end each String with a \n, the newline character.

Also, be sure to add your strings to the JavaDoc for the getParameters() method as well, so users can learn what your code needs from its documentation.


getDescription

public java.lang.String getDescription()
Indicates what this PatternTransformer does.

Returns:
A String giving a quick description of this transformer

putParameter

public void putParameter(java.lang.String name,
                         java.lang.Object value)
Places a value for a variable.


getParameter

public java.lang.Object getParameter(java.lang.String name)
Returns a variable setting.


transform

public Pattern transform(Pattern p)
Transforms the pattern, according to the event method that you have presumably extended.


voiceEvent

public void voiceEvent(Voice voice)
Extend this method to make your transformer modify the voice.

Specified by:
voiceEvent in interface ParserListener
Parameters:
voice - the event that has been parsed
See Also:
Voice

tempoEvent

public void tempoEvent(Tempo tempo)
Extend this method to make your transformer modify the tempo.

Specified by:
tempoEvent in interface ParserListener
Parameters:
tempo - the event that has been parsed
See Also:
Tempo

instrumentEvent

public void instrumentEvent(Instrument instrument)
Extend this method to make your transformer modify the instrument.

Specified by:
instrumentEvent in interface ParserListener
Parameters:
instrument - the event that has been parsed
See Also:
Instrument

layerEvent

public void layerEvent(Layer layer)
Extend this method to make your transformer modify the layer.

Specified by:
layerEvent in interface ParserListener
Parameters:
layer - the event that has been parsed
See Also:
Layer

timeEvent

public void timeEvent(Time time)
Extend this method to make your transformer modify the time.

Specified by:
timeEvent in interface ParserListener
Parameters:
time - the event that has been parsed
See Also:
Time

keySignatureEvent

public void keySignatureEvent(KeySignature keySig)
Extend this method to make your transformer modify the time.

Specified by:
keySignatureEvent in interface ParserListener
See Also:
KeySignature

measureEvent

public void measureEvent(Measure measure)
Extend this method to make your transformer modify the measure.

Specified by:
measureEvent in interface ParserListener
Parameters:
measure - the event that has been parsed
See Also:
Measure

controllerEvent

public void controllerEvent(Controller controller)
Extend this method to make your transformer modify the controller messages.

Specified by:
controllerEvent in interface ParserListener
Parameters:
controller - the event that has been parsed

channelPressureEvent

public void channelPressureEvent(ChannelPressure channelPressure)
Extend this method to make your transformer modify the channel pressure messages.

Specified by:
channelPressureEvent in interface ParserListener
Parameters:
channelPressure - the event that has been parsed
See Also:
ChannelPressure

polyphonicPressureEvent

public void polyphonicPressureEvent(PolyphonicPressure polyphonicPressure)
Extend this method to make your transformer modify the polyphonic pressure messages.

Specified by:
polyphonicPressureEvent in interface ParserListener
Parameters:
polyphonicPressure - the event that has been parsed
See Also:
PolyphonicPressure

pitchBendEvent

public void pitchBendEvent(PitchBend pitchBend)
Extend this method to make your transformer modify the pitch bend messages.

Specified by:
pitchBendEvent in interface ParserListener
Parameters:
pitchBend - the event that has been parsed
See Also:
PitchBend

noteEvent

public void noteEvent(Note note)
Extend this method to make your transformer modify the note. Don't forget to also extend sequentialNoteEvent and parallelNoteEvent.

Specified by:
noteEvent in interface ParserListener
Parameters:
note - the event that has been parsed
See Also:
Note

sequentialNoteEvent

public void sequentialNoteEvent(Note note)
Extend this method to make your transformer modify the note. Don't forget to also extend noteEvent and parallelNoteEvent.

Specified by:
sequentialNoteEvent in interface ParserListener
Parameters:
note - the event that has been parsed
See Also:
Note

parallelNoteEvent

public void parallelNoteEvent(Note note)
Extend this method to make your transformer modify the note. Don't forget to also extend noteEvent and sequentialNoteEvent.

Specified by:
parallelNoteEvent in interface ParserListener
Parameters:
note - the event that has been parsed
See Also:
Note