com.webkitchen.brainathlon.gameComponents
Class MidiFeedback

java.lang.Object
  extended by com.webkitchen.brainathlon.gameComponents.MidiFeedback

public class MidiFeedback
extends java.lang.Object

Handles setup of Midi and playback of sounds


Nested Class Summary
static class MidiFeedback.SoundType
           
static class MidiFeedback.Volume
           
 
Method Summary
static MidiFeedback getInstance()
          Factory method for return the single instance of MidiFeedback
 java.util.Map<java.lang.String,java.lang.Integer> getInstrumentOptions()
          Returns the target instrument options
 boolean isLoaded()
           
 void loadMidi()
          Attempts to load Midi components
 void playCourseOverSong()
          Play the Midi song specified in the configuration file
 void playSound(MidiFeedback.SoundType type, int channel, int instrument)
          Plays a feedback sound at medium volume
 void playSound(MidiFeedback.SoundType type, int channel, int instrument, MidiFeedback.Volume volume)
          Plays a feedback sound
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static MidiFeedback getInstance()
Factory method for return the single instance of MidiFeedback

Returns:
the single instance of MidiFeedback

loadMidi

public void loadMidi()
              throws javax.sound.midi.MidiUnavailableException
Attempts to load Midi components

Throws:
javax.sound.midi.MidiUnavailableException - if we are unable to load any components

isLoaded

public boolean isLoaded()

getInstrumentOptions

public java.util.Map<java.lang.String,java.lang.Integer> getInstrumentOptions()
Returns the target instrument options

Returns:
a Map of instrument names and numbers

playSound

public void playSound(MidiFeedback.SoundType type,
                      int channel,
                      int instrument)
Plays a feedback sound at medium volume

Parameters:
type - the type of feedback
channel - the channel to use
instrument - the Midi instrument number

playSound

public void playSound(MidiFeedback.SoundType type,
                      int channel,
                      int instrument,
                      MidiFeedback.Volume volume)
Plays a feedback sound

Parameters:
type - the type of feedback
channel - the channel to use
instrument - the Midi instrument number
volume - the sound level

playCourseOverSong

public void playCourseOverSong()
Play the Midi song specified in the configuration file

See Also:
Configuration