|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.rico.engine.effect.sound.MidiSound
public class MidiSound
This class represents a playable midi sound. I've taken it from the book "Developing games in Java" by David Brackeen, but simplified it a little bit and added some more comments.
Field Summary | |
---|---|
static int |
END_OF_TRACK_MESSAGE
|
Constructor Summary | |
---|---|
MidiSound(java.io.InputStream stream,
boolean loop)
Creates a new MidiSound object with the specified input stream. |
|
MidiSound(java.lang.String path,
boolean loop)
Creates a new MidiSound object with the specified file path. |
Method Summary | |
---|---|
void |
close()
Closes the midi file player. |
javax.sound.midi.Sequencer |
getSequencer()
Gets the sequencer that is internally used to play a midi file. |
java.lang.String |
getSoundPath()
Returns the file path to the sound file. |
boolean |
isLooped()
Determines if the sound was specified to be looped. |
boolean |
isPaused()
Returns the paused state. |
void |
meta(javax.sound.midi.MetaMessage event)
This method is called by the sound system when a meta event occurs. |
void |
play()
Starts playing the assigned sound file. |
void |
setPaused(boolean paused)
Sets the paused state. |
void |
stop()
Stops playing the assigned sound file. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int END_OF_TRACK_MESSAGE
Constructor Detail |
---|
public MidiSound(java.lang.String path, boolean loop)
path
- file path to midi fileloop
- loop the midi file playing? --> true=yes, false=nopublic MidiSound(java.io.InputStream stream, boolean loop)
stream
- input stream that contains the midi dataloop
- loop the midi file playing? --> true=yes, false=noMethod Detail |
---|
public java.lang.String getSoundPath()
SoundFileIface
getSoundPath
in interface SoundFileIface
public boolean isLooped()
SoundFileIface
isLooped
in interface SoundFileIface
public void play()
SoundFileIface
play
in interface SoundFileIface
public void stop()
SoundFileIface
stop
in interface SoundFileIface
public void close()
public void meta(javax.sound.midi.MetaMessage event)
meta
in interface javax.sound.midi.MetaEventListener
event
- meta event messagepublic javax.sound.midi.Sequencer getSequencer()
public void setPaused(boolean paused)
paused
- pause midi playing? --> true=yes, false=nopublic boolean isPaused()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |