com.golden.gamedev.engine.audio
Class MidiRenderer

java.lang.Object
  |
  +--com.golden.gamedev.engine.audio.MidiRenderer
All Implemented Interfaces:
BaseAudioRenderer, EventListener, MetaEventListener

public class MidiRenderer
extends Object
implements BaseAudioRenderer, MetaEventListener

Play midi (*.mid) sound.

Note:
Midi sound use soundbank that not delivered in JRE, only JDK can play midi sound. To play midi in JRE you must explicitly install soundbank.
Don't ask me how, i don't know either, please read JDK documentation.


Constructor Summary
MidiRenderer()
           
 
Method Summary
 BaseAudioRenderer createRenderer()
          Creates another empty renderer based on this renderer.
 URL getAudioFile()
          Returns the audio file associated with this audio renderer.
 float getVolume()
          Returns this audio volume.
 boolean isPlaying()
          Returns true, if this audio is currently playing.
 void meta(MetaMessage msg)
           
 void play()
          Begins playback of this audio renderer.
 void play(URL audiofile)
          Begins playback of specified audio file.
 void setLoop(boolean b)
          The sound is playing continuously until stop is called.
 void setVolume(float volume)
          Sets audio volume in [0.0f - 1.0f].
 void stop()
          Stops currently played audio.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MidiRenderer

public MidiRenderer()
Method Detail

isPlaying

public boolean isPlaying()
Description copied from interface: BaseAudioRenderer
Returns true, if this audio is currently playing.

Specified by:
isPlaying in interface BaseAudioRenderer

getAudioFile

public URL getAudioFile()
Description copied from interface: BaseAudioRenderer
Returns the audio file associated with this audio renderer.

Specified by:
getAudioFile in interface BaseAudioRenderer

play

public void play(URL audiofile)
Description copied from interface: BaseAudioRenderer
Begins playback of specified audio file. If this audio is already playing, the audio will be restarted.

Specified by:
play in interface BaseAudioRenderer
Parameters:
audiofile - the audio file to be played by this renderer.

play

public void play()
Description copied from interface: BaseAudioRenderer
Begins playback of this audio renderer.

Specified by:
play in interface BaseAudioRenderer

setLoop

public void setLoop(boolean b)
Description copied from interface: BaseAudioRenderer
The sound is playing continuously until stop is called.

Note: if the internal renderer doesn't support built-in loop, please use thread that wait the sound ended and restart the sound.

Specified by:
setLoop in interface BaseAudioRenderer
Parameters:
b - true, the audio is playing continously.

stop

public void stop()
Description copied from interface: BaseAudioRenderer
Stops currently played audio.

Specified by:
stop in interface BaseAudioRenderer

createRenderer

public BaseAudioRenderer createRenderer()
Description copied from interface: BaseAudioRenderer
Creates another empty renderer based on this renderer.

Specified by:
createRenderer in interface BaseAudioRenderer

meta

public void meta(MetaMessage msg)
Specified by:
meta in interface MetaEventListener

setVolume

public void setVolume(float volume)
Description copied from interface: BaseAudioRenderer
Sets audio volume in [0.0f - 1.0f].

Specified by:
setVolume in interface BaseAudioRenderer

getVolume

public float getVolume()
Description copied from interface: BaseAudioRenderer
Returns this audio volume.

Specified by:
getVolume in interface BaseAudioRenderer