org.jfugue
Class StreamingPlayer

java.lang.Object
  extended by org.jfugue.StreamingPlayer
All Implemented Interfaces:
java.util.EventListener, PatternListener

public class StreamingPlayer
extends java.lang.Object
implements PatternListener

Provides a player that can be given new MusicStrings at runtime. The original Player class requires that a MusicString be fully formed before sending to Player.play(). This class lets you add new bits of a MusicString with the add() method. The newly-added patterns are played immediately.

Version:
3.2
Author:
David Koelle
See Also:
Pattern, Player

Constructor Summary
StreamingPlayer(Pattern pattern)
          Instantiates a new Player object, which is used for playing music.
 
Method Summary
 void close()
          Closes MIDI resources - be sure to call this after play() has returned.
 void fragmentAdded(Pattern fragment)
          Listener for additions to streaming patterns.
 javax.sound.midi.Sequence getSequence()
          Returns the sequence containing the MIDI data from the given pattern.
 javax.sound.midi.Sequencer getSequencer()
          Returns the sequencer containing the MIDI data from a pattern that has been parsed.
 void saveMidi(java.io.File file)
          Saves the MIDI data from a pattern into a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamingPlayer

public StreamingPlayer(Pattern pattern)
Instantiates a new Player object, which is used for playing music.

Method Detail

close

public void close()
Closes MIDI resources - be sure to call this after play() has returned.


saveMidi

public void saveMidi(java.io.File file)
              throws java.io.IOException
Saves the MIDI data from a pattern into a file.

Parameters:
file - the File to save the sequence to. Should include file extension, such as .mid
Throws:
java.io.IOException

getSequencer

public javax.sound.midi.Sequencer getSequencer()
Returns the sequencer containing the MIDI data from a pattern that has been parsed.

Returns:
the Sequencer from the pattern that was recently parsed

getSequence

public javax.sound.midi.Sequence getSequence()
Returns the sequence containing the MIDI data from the given pattern.

Returns:
the Sequence from the given pattern

fragmentAdded

public void fragmentAdded(Pattern fragment)
Listener for additions to streaming patterns. When a fragment has been added to a pattern, this implementation plays the pattern.

Specified by:
fragmentAdded in interface PatternListener
Parameters:
fragment - the fragment added to the pattern.