Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.rico.engine.effect.sound
Class MidiSound

    java.lang.Object
      de.rico.engine.effect.sound.MidiSound

All Implemented Interfaces:
  SoundFileIface, java.util.EventListener, javax.sound.midi.MetaEventListener

    public class MidiSound

extends java.lang.Object
implements SoundFileIface, javax.sound.midi.MetaEventListener

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.

Author:
  David Brackeen, some changes by Frank Bruns

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

### END_OF_TRACK_MESSAGE

    public static final int END_OF_TRACK_MESSAGE

See Also:
  Constant Field Values

Constructor Detail

### MidiSound

    public MidiSound(java.lang.String path,
                     boolean loop)

  Creates a new MidiSound object with the specified file path.

  Parameters:
    `path` - file path to midi file
    `loop` - loop the midi file playing? --> true=yes, false=no

### MidiSound

    public MidiSound(java.io.InputStream stream,
                     boolean loop)

  Creates a new MidiSound object with the specified input stream.

  Parameters:
    `stream` - input stream that contains the midi data
    `loop` - loop the midi file playing? --> true=yes, false=no

Method Detail

### getSoundPath

    public java.lang.String getSoundPath()

  Description copied from interface: `SoundFileIface`
  Returns the file path to the sound file.

  Specified by:
    `getSoundPath` in interface `SoundFileIface`
  Returns:
    file path to the sound file

### isLooped

    public boolean isLooped()

  Description copied from interface: `SoundFileIface`
  Determines if the sound was specified to be looped.

  Specified by:
    `isLooped` in interface `SoundFileIface`
  Returns:
    is looped? --> true=yes, false=no

### play

    public void play()

  Description copied from interface: `SoundFileIface`
  Starts playing the assigned sound file.

  Specified by:
    `play` in interface `SoundFileIface`

### stop

    public void stop()

  Description copied from interface: `SoundFileIface`
  Stops playing the assigned sound file.

  Specified by:
    `stop` in interface `SoundFileIface`

### close

    public void close()

  Closes the midi file player.

### meta

    public void meta(javax.sound.midi.MetaMessage event)

  This method is called by the sound system when a meta event occurs. In this case, when the end-of-track meta event is received, the sequence is restarted if looping is on.

  Specified by:
    `meta` in interface `javax.sound.midi.MetaEventListener`
  Parameters:
    `event` - meta event message

### getSequencer

    public javax.sound.midi.Sequencer getSequencer()

  Gets the sequencer that is internally used to play a midi file.

### setPaused

    public void setPaused(boolean paused)

  Sets the paused state. Music may not immediately pause.

  Parameters:
    `paused` - pause midi playing? --> true=yes, false=no

### isPaused

    public boolean isPaused()

  Returns the paused state.

  Returns:
    is player paused? --> true=yes, false=no

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD