com.motorola.midi
Class MidiPlayer

java.lang.Object
  |
  +--com.motorola.midi.MidiPlayer

public final class MidiPlayer
extends java.lang.Object


Field Summary
static int PLAY_CONTINUOUS
           
static int PLAY_ONCE
           
 
Method Summary
static void play(java.lang.String filename, int mode)
          Play a midi of given filename in one-time or continuous mode.
static void playEffect(int note, int key_pressure, int channel_vol, int instrument, int channel)
          Plays a sound effect on top of a playing midi file.
static void stop()
          Stop playing midi file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLAY_CONTINUOUS

public static final int PLAY_CONTINUOUS

PLAY_ONCE

public static final int PLAY_ONCE
Method Detail

play

public static void play(java.lang.String filename,
                        int mode)
                 throws java.lang.IllegalArgumentException,
                        java.io.IOException
Play a midi of given filename in one-time or continuous mode. Note: pausing a MIDlet will effectively call stop(). It is up to the developer to call play() again if he wishes to resume playing upon resuming the MIDlet.

Parameters:
filename - A String containing the filename.
mode - The mode to play the midi.
Throws:
java.io.IOException - If the filename is empty or doesn't exist or if file is unreadable.
java.lang.IllegalArgumentException - If an invalid mode is passed.
See Also:
PLAY_ONCE, PLAY_CONTINUOUS

stop

public static void stop()
Stop playing midi file.


playEffect

public static void playEffect(int note,
                              int key_pressure,
                              int channel_vol,
                              int instrument,
                              int channel)
                       throws java.lang.IllegalStateException,
                              java.lang.IllegalArgumentException
Plays a sound effect on top of a playing midi file.

Parameters:
note - The pitch of the note (0-127).
key_pressure - The key pressure (0-127).
channel_vol - Volume level (0-127).
instrument - Instument to play (0-176).
channel - Sound channel on which to play the effect (0-15).
Throws:
java.lang.IllegalStateException - If a MIDI started by MidiPlayer.play() is not playing in the background.
java.lang.IllegalArgumentException - If any of the parameters are out of range.