edu.neu.ccs.util
Class SoundUtilities

java.lang.Object
  extended byedu.neu.ccs.util.SoundUtilities

public class SoundUtilities
extends Object

Provides static utility methods for playback of sound.

Since:
1.1
Version:
2.2

Field Summary
private static Vector currentLines
          Lines currently running.
private static float gain
          Gain for all lines created through this interface.
private static boolean muted
          Whether or not lines created through this interface are muted.
private static float pan
          Pan for all lines created through this interface.
 
Constructor Summary
SoundUtilities()
           
 
Method Summary
private static void applyGain(float gain, Line l)
          Sets the gain for the given line to the given gain.
private static void applyPan(float pan, Line l)
          Sets the pan for the given line to the given pan.
static float getGain()
          Returns the gain for all lines created through this interface.
static float getPan()
          Returns the pan for all lines created through this interface.
static boolean isMuted()
          Returns whether or not sound is muted for all lines created through this interface.
private static SourceDataLine playImpl(AudioInputStream stream)
          Plays the given audio input stream.
private static Thread playImpl(Sequence midiSong)
          Plays the given MIDI sequence.
static Thread playMidi(File midiFile)
          Plays the MIDI sequence stored in the given file.
static Thread playMidi(String midiFileName)
          Plays the MIDI sequence stored in a file with the given name.
static Thread playMidi(URL midiURL)
          Plays the MIDI sequence stored in the file at the given URL.
static SourceDataLine playSound(File soundFile)
           
static SourceDataLine playSound(String soundFileName)
          Plays the sound file with the given file name.
static SourceDataLine playSound(URL soundURL)
           
private static void removeLine(Line l)
          Removes the given line from the list of current lines.
static void setGain(float dB)
          Sets the gain for all lines created through this interface to the given gain in dB.
static void setMuted(boolean isMuted)
          Sets whether or not sound is muted for all lines created through this interface.
static void setPan(float p)
          Sets the pan for all lines created through this interface to the given pan.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentLines

private static Vector currentLines
Lines currently running.


gain

private static float gain
Gain for all lines created through this interface.


muted

private static boolean muted
Whether or not lines created through this interface are muted.


pan

private static float pan
Pan for all lines created through this interface.

Constructor Detail

SoundUtilities

public SoundUtilities()
Method Detail

setGain

public static void setGain(float dB)
Sets the gain for all lines created through this interface to the given gain in dB.

Parameters:
dB - the desired gain level
See Also:
getGain()

getGain

public static float getGain()
Returns the gain for all lines created through this interface.

See Also:
setGain(float)

setMuted

public static void setMuted(boolean isMuted)
Sets whether or not sound is muted for all lines created through this interface.

Parameters:
isMuted - whether or not sound is muted

isMuted

public static boolean isMuted()
Returns whether or not sound is muted for all lines created through this interface.

See Also:
setMuted(boolean)

setPan

public static void setPan(float p)
Sets the pan for all lines created through this interface to the given pan.

Parameters:
p - the desired pan level
See Also:
getPan()

getPan

public static float getPan()
Returns the pan for all lines created through this interface.

See Also:
setPan(float)

playSound

public static SourceDataLine playSound(String soundFileName)
Plays the sound file with the given file name. If a file with the given name cannot be found, opened or read, this playback operation is cancelled. If the audio system for the host machine is unavailable, this playback operation is cancelled.

Parameters:
soundFileName - the file name for the sound to be played

playSound

public static SourceDataLine playSound(File soundFile)

playSound

public static SourceDataLine playSound(URL soundURL)

playMidi

public static Thread playMidi(String midiFileName)
Plays the MIDI sequence stored in a file with the given name. If a file with the given name cannot be found, opened, or read, this playback operation is cancelled. If the MIDI system for the host machine is unavailable, this playback operation is cancelled.

Parameters:
midiFileName - the file name for the desired sequence

playMidi

public static Thread playMidi(File midiFile)
Plays the MIDI sequence stored in the given file. If the given file cannot be found, opened, or read, this playback operation is cancelled. If the MIDI system for the host machine is unavailable, this playback operation is cancelled.

Parameters:
midiFile - the file containing the desired sequence

playMidi

public static Thread playMidi(URL midiURL)
Plays the MIDI sequence stored in the file at the given URL. If the file at the given URL cannot be found, opened, or read, this playback operation is cancelled. If the MIDI system for the host machine is unavailable, this playback operation is cancelled.

Parameters:
midiURL - the URL of the midi file containing the desired sequence

playImpl

private static SourceDataLine playImpl(AudioInputStream stream)
Plays the given audio input stream.


playImpl

private static Thread playImpl(Sequence midiSong)
Plays the given MIDI sequence.


removeLine

private static void removeLine(Line l)
Removes the given line from the list of current lines.


applyGain

private static void applyGain(float gain,
                              Line l)
Sets the gain for the given line to the given gain.


applyPan

private static void applyPan(float pan,
                             Line l)
Sets the pan for the given line to the given pan.