RoboJDETM v2.0

com.ridgesoft.io
Class Speaker

java.lang.Object
  extended by com.ridgesoft.io.Speaker

public abstract class Speaker
extends Object

Abstract class to interface to a speaker or buzzer.


Constructor Summary
protected Speaker()
          Initializes a Speaker object.
 
Method Summary
 void beep()
          Beeps the speaker.
 void click()
          Clicks the speaker.
abstract  void play(int frequency, int duration)
          Plays the specified tone (frequency) on the speaker.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait
 

Constructor Detail

Speaker

protected Speaker()
Initializes a Speaker object.

Method Detail

beep

public void beep()
Beeps the speaker.

Doesn't return until done.


click

public void click()
Clicks the speaker.

Doesn't return until done.


play

public abstract void play(int frequency,
                          int duration)
Plays the specified tone (frequency) on the speaker.

The audible range for a human ear is about 20 Hz and 20 kHz. The actual range supported by the hardware implementing the speaker or buzzer may be less.

The frequencies of musical notes starting at middle C on a piano are:

The frequencies of notes double for each higher octave and are halved for each lower octave.

This method doesn't return until tone has been played.

Parameters:
frequency - frequency in Hz of the tone to play
duration - duration to play the tone for in milliseconds

RoboJDETM v2.0

Copyright (c) 2003-2009 RidgeSoft, LLC. All rights reserved.
www.ridgesoft.com