|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jfugue.Player
public class Player
Prepares a pattern to be turned into music by the Renderer. This class also handles saving the sequence derived from a pattern as a MIDI file.
MidiRenderer,
Pattern| Constructor Summary | |
|---|---|
Player()
Instantiates a new Player object, which is used for playing music. |
|
Player(boolean connected)
Instantiates a new Player object, which is used for playing music. |
|
Player(javax.sound.midi.Sequencer sequencer)
Creates a new Player instance using a Sequencer that you have provided. |
|
Player(javax.sound.midi.Synthesizer synth)
Creates a new Player instance using a Sequencer obtained from the Synthesizer that you have provided. |
|
| Method Summary | |
|---|---|
static void |
allNotesOff()
|
static void |
allNotesOff(javax.sound.midi.Synthesizer synth)
Stops all notes from playing on all MIDI channels. |
void |
close()
Closes MIDI resources - be sure to call this after play() has returned. |
javax.sound.midi.Sequence |
getSequence(Pattern pattern)
Returns the sequence containing the MIDI data from the given pattern. |
long |
getSequenceLength(javax.sound.midi.Sequence sequence)
|
long |
getSequencePosition()
|
javax.sound.midi.Sequencer |
getSequencer()
Returns the sequencer containing the MIDI data from a pattern that has been parsed. |
static javax.sound.midi.Sequencer |
getSequencerConnectedToSynthesizer(javax.sound.midi.Synthesizer synth)
Returns an instance of a Sequencer that uses the provided Synthesizer as its receiver. |
boolean |
isFinished()
|
boolean |
isPaused()
|
boolean |
isPlaying()
|
boolean |
isStarted()
|
void |
jumpTo(long microseconds)
|
Pattern |
loadMidi(java.io.File file)
Parses a MIDI file and returns a Pattern. |
void |
pause()
|
void |
play(Anticipator anticipator,
Pattern pattern,
long offset)
|
void |
play(Anticipator anticipator,
javax.sound.midi.Sequence sequence,
javax.sound.midi.Sequence sequence2,
long offset)
|
void |
play(Pattern pattern)
Plays a pattern by setting up a Renderer and feeding the pattern to it. |
void |
play(Rhythm rhythm)
Plays a pattern by setting up a Renderer and feeding the pattern to it. |
void |
play(java.lang.String musicString)
Plays a string of music. |
void |
playMidiDirectly(java.io.File file)
Plays a MIDI file, without doing any conversions to MusicStrings. |
void |
playMidiDirectly(java.net.URL url)
Plays a URL that contains a MIDI sequence. |
void |
resume()
|
void |
saveMidi(Pattern pattern,
java.io.File file)
Saves the MIDI data from a pattern into a file. |
void |
saveMidi(java.lang.String musicString,
java.io.File file)
Saves the MIDI data from a MusicString into a file. |
void |
stop()
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Player()
public Player(boolean connected)
connected parameter is passed directly to MidiSystem.getSequencer.
Pass false when you do not want to copy a live synthesizer - for example,
if your Player is on a server, and you don't want to create new synthesizers every time
the constructor is called.
public Player(javax.sound.midi.Sequencer sequencer)
sequencer - The Sequencer to send the MIDI events
public Player(javax.sound.midi.Synthesizer synth)
throws javax.sound.midi.MidiUnavailableException
synth - The Synthesizer you want to use for this Player.
javax.sound.midi.MidiUnavailableException| Method Detail |
|---|
public void play(Pattern pattern)
pattern - the pattern to playMidiRendererpublic void play(Rhythm rhythm)
pattern - the pattern to playMidiRendererpublic void play(java.lang.String musicString)
musicString - the MusicString (JFugue-formatted string) to play
public void playMidiDirectly(java.io.File file)
throws java.io.IOException,
javax.sound.midi.InvalidMidiDataException
file - the MIDI file to play
java.io.IOException
javax.sound.midi.InvalidMidiDataException
public void playMidiDirectly(java.net.URL url)
throws java.io.IOException,
javax.sound.midi.InvalidMidiDataException
url - the URL to play
java.io.IOException
javax.sound.midi.InvalidMidiDataException
public void play(Anticipator anticipator,
Pattern pattern,
long offset)
public void play(Anticipator anticipator,
javax.sound.midi.Sequence sequence,
javax.sound.midi.Sequence sequence2,
long offset)
public void close()
public boolean isStarted()
public boolean isFinished()
public boolean isPlaying()
public boolean isPaused()
public void pause()
public void resume()
public void stop()
public void jumpTo(long microseconds)
public long getSequenceLength(javax.sound.midi.Sequence sequence)
public long getSequencePosition()
public void saveMidi(Pattern pattern,
java.io.File file)
throws java.io.IOException
pattern - the pattern to savefile - the File to save the pattern to. Should include file extension, such as .mid
java.io.IOException
public void saveMidi(java.lang.String musicString,
java.io.File file)
throws java.io.IOException
musicString - the MusicString to savefile - the File to save the MusicString to. Should include file extension, such as .mid
java.io.IOException
public Pattern loadMidi(java.io.File file)
throws java.io.IOException,
javax.sound.midi.InvalidMidiDataException
MidiParser parser = new MidiParser(); MusicStringRenderer renderer = new MusicStringRenderer(); parser.addParserListener(renderer); parser.parse(sequence);
filename - The name of the MIDI file
java.io.IOException - If there is a problem opening the MIDI file
javax.sound.midi.InvalidMidiDataException - If there is a problem obtaining MIDI resourcespublic static void allNotesOff()
public static void allNotesOff(javax.sound.midi.Synthesizer synth)
public javax.sound.midi.Sequencer getSequencer()
public javax.sound.midi.Sequence getSequence(Pattern pattern)
public static javax.sound.midi.Sequencer getSequencerConnectedToSynthesizer(javax.sound.midi.Synthesizer synth)
throws javax.sound.midi.MidiUnavailableException
synth - The Synthesizer to use as the receiver for the returned Sequencer
javax.sound.midi.MidiUnavailableException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||