waba.fx
Class Sound

java.lang.Object
  |
  +--waba.fx.Sound

public final class Sound
extends Object

Sound is used to play sounds such as beeps and tones.

Playing beeps is supported under all platforms but tones are only supported where the underlying platform supports generating tones. Tones aren't supported under Java or Windows CE.

Here is an example that beeps the speaker and plays a tone:

 Sound.beep();
 Sound.tone(4000, 300);
 


Method Summary
static void beep()
          Plays the device's default beep sound.
static void midiTone(int midiNoteNumber, int duration)
          Plays a tone of the specified Midi Note Number for the specified duration.
static void setEnabled(boolean on)
          Sets the sound of the device on/off.
static void tone(int freq, int duration)
          Plays a tone of the specified frequency for the specified duration.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, toString, wait, wait
 

Method Detail

beep

public static void beep()
Plays the device's default beep sound.

tone

public static void tone(int freq,
                        int duration)
Plays a tone of the specified frequency for the specified duration. Tones will only play under Win32 and PalmOS, they won't play under Java or Windows CE due to underlying platform limitations (in these cases, use waba.fx.SoundClip).
Parameters:
freq - frequency in hertz from 32 to 32767
duration - duration in milliseconds

setEnabled

public static void setEnabled(boolean on)
Sets the sound of the device on/off. Note that in PalmOS this turns off the system sound only and, in this case, the Sound.beep goes off but the Sound.tone will still work. The original volume is restored at the vm exit.

Important: If the user had set its device sound to off, this method will not turn it on, ie, it will keep the device in silence. Otherwise, it will set the volume to its original configuration.

Parameters:
on - if true enables the sound, if false disable it.

midiTone

public static void midiTone(int midiNoteNumber,
                            int duration)
Plays a tone of the specified Midi Note Number for the specified duration. Tones will only play under Win32 and PalmOS, they won't play under Java or Windows CE due to underlying platform limitations (in these cases, use waba.fx.SoundClip).

Note: The smaller the midi number, the greater the error in the frequency, due to the fact that the frequency calculated must be an integer.

Parameters:
midiNoteNumber - number of the note according to MIDI standard (eg. A (440hz) = 69), from 24 to 143
duration - duration in milliseconds