org.jfugue
Class MidiRenderer

java.lang.Object
  extended by org.jfugue.MidiRenderer
All Implemented Interfaces:
java.util.EventListener, ParserListener

public class MidiRenderer
extends java.lang.Object
implements ParserListener

This class takes a Pattern, and turns it into wonderful music.

Playing music is only one thing that can be done by rendering a pattern. You could also create your own renderer that draws sheet music based on a pattern. Or, you could create a graphical light show based on the musical notes in the pattern.

This was named Renderer in previous versions of JFugue. The name has been changed to differentiate it from other types of renderers.

Version:
2.0, 3.0 - Renderer renamed to MidiRenderer
Author:
David Koelle

Constructor Summary
MidiRenderer(float sequenceTiming, int resolution)
          Instantiates a Renderer
 
Method Summary
 void channelPressureEvent(ChannelPressure channelPressure)
          Called when the parser encounters a channel pressure event.
 void controllerEvent(Controller controller)
          Called when the parser encounters a controller event.
 void instrumentEvent(Instrument instrument)
          Called when the parser encounters an instrument event.
 void keySignatureEvent(KeySignature keySig)
          Called when the parser encounters a key signature event.
 void layerEvent(Layer layer)
          Called when the parser encounters a layer event.
 void measureEvent(Measure measure)
          Called when the parser encounters a measure event.
 void noteEvent(Note note)
          Called when the parser encounters an initial note event.
 void parallelNoteEvent(Note note)
          Called when the parser encounters a parallel note event.
 void pitchBendEvent(PitchBend pitchBend)
          Called when the parser encounters a pitch bend event.
 void polyphonicPressureEvent(PolyphonicPressure polyphonicPressure)
          Called when the parser encounters a polyphonic pressure event.
 javax.sound.midi.Sequence render(Pattern pattern)
          Starts rendering a pattern by sending it to the parser and listening for parser events to be fired when tokens from the pattern are interpreted.
 void reset()
          Creates a new MidiEventManager using the sequenceTiming and resolution already used to create this MidiRenderer.
 void reset(float sequenceTiming, int resolution)
          Creates a new MidiEventManager.
 void sequentialNoteEvent(Note note)
          Called when the parser encounters a sequential note event.
 void tempoEvent(Tempo tempo)
          Called when the parser encounters a tempo event.
 void timeEvent(Time time)
          Called when the parser encounters a time event.
 void voiceEvent(Voice voice)
          Called when the parser encounters a voice event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MidiRenderer

public MidiRenderer(float sequenceTiming,
                    int resolution)
Instantiates a Renderer

Method Detail

reset

public void reset(float sequenceTiming,
                  int resolution)
Creates a new MidiEventManager. If this isn't called, events from multiple calls to render() will be added to the same eventManager, which means that the second time render() is called, it will contain music left over from the first time it was called. (This wasn't a problem with Java 1.4)

Since:
3.0

reset

public void reset()
Creates a new MidiEventManager using the sequenceTiming and resolution already used to create this MidiRenderer. If this isn't called, events from multiple calls to render() will be added to the same eventManager, which means that the second time render() is called, it will contain music left over from the first time it was called. (This wasn't a problem with Java 1.4)

Since:
3.2

render

public javax.sound.midi.Sequence render(Pattern pattern)
Starts rendering a pattern by sending it to the parser and listening for parser events to be fired when tokens from the pattern are interpreted.

Parameters:
pattern - the pattern to render

voiceEvent

public void voiceEvent(Voice voice)
Description copied from interface: ParserListener
Called when the parser encounters a voice event.

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

tempoEvent

public void tempoEvent(Tempo tempo)
Description copied from interface: ParserListener
Called when the parser encounters a tempo event.

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

instrumentEvent

public void instrumentEvent(Instrument instrument)
Description copied from interface: ParserListener
Called when the parser encounters an instrument event.

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

layerEvent

public void layerEvent(Layer layer)
Description copied from interface: ParserListener
Called when the parser encounters a layer event.

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

timeEvent

public void timeEvent(Time time)
Description copied from interface: ParserListener
Called when the parser encounters a time event.

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

measureEvent

public void measureEvent(Measure measure)
Description copied from interface: ParserListener
Called when the parser encounters a measure event.

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

keySignatureEvent

public void keySignatureEvent(KeySignature keySig)
Description copied from interface: ParserListener
Called when the parser encounters a key signature event.

Specified by:
keySignatureEvent in interface ParserListener
See Also:
KeySignature

controllerEvent

public void controllerEvent(Controller controller)
Description copied from interface: ParserListener
Called when the parser encounters a controller event.

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

channelPressureEvent

public void channelPressureEvent(ChannelPressure channelPressure)
Description copied from interface: ParserListener
Called when the parser encounters a channel pressure event.

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

polyphonicPressureEvent

public void polyphonicPressureEvent(PolyphonicPressure polyphonicPressure)
Description copied from interface: ParserListener
Called when the parser encounters a polyphonic pressure event.

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

pitchBendEvent

public void pitchBendEvent(PitchBend pitchBend)
Description copied from interface: ParserListener
Called when the parser encounters a pitch bend event.

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

noteEvent

public void noteEvent(Note note)
Description copied from interface: ParserListener
Called when the parser encounters an initial note event.

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

sequentialNoteEvent

public void sequentialNoteEvent(Note note)
Description copied from interface: ParserListener
Called when the parser encounters a sequential note event.

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

parallelNoteEvent

public void parallelNoteEvent(Note note)
Description copied from interface: ParserListener
Called when the parser encounters a parallel note event.

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