becker.xtras.radio
Interface ITuner

All Known Implementing Classes:
SampleTuner

public interface ITuner

A tuner is a kind of radio that allows the user to adjust the current frequency up or down or to seek the next station with an adequate signal strength. It also has memory presets so the user can quickly return to a remembered station.

Each tuner object is for a different band -- AM, FM, ShortWave, etc. Each band has a minimum and a maximum frequency. For the AM band, the range is 530 - 1710. For the FM band it is 87.5 to 107.9. AM tuners typically increment the frequecy in steps of 10; FM tuners typically increment the frequency in steps of .1 or .2.

Classes that implement the ITuner interface will often extend Radio, a class that provides the most basic functionality for a radio: set and get the current frequency and a measure of the signal strength being received at the current frequency.

Please see the package description for a more in-depth discussion of using this class.

Author:
Byron Weber Becker

Field Summary
static int NUM_PRESETS
          The number of preset frequencies provided by the tuner.
 
Method Summary
 void addView(IView aView)
          Add a view (graphical user interface) to the tuner.
 double getFrequency()
          Get this tuner's current frequency.
 double getSignalStrength()
          Get the strength of the signal currently being received.
 void recallFrequency(int button)
          Recall the frequency associated with a given preset button by a previous call to rememberFrequency(int).
 void rememberFrequency(int button)
          Remember the current frequency so that it can be later recalled with recallFrequency(int).
 void seekDown()
          Move the frequency down until a station is found with a signal strength of at least 0.5.
 void seekUp()
          Move the frequency up until a station is found with a signal strength of at least 0.5.
 void tuneDown()
          Move the frequency one step down, unless the frequency is already at the lowest value for this band.
 void tuneUp()
          Move the frequency one step up, unless the frequency is already at the highest value for this band.
 

Field Detail

NUM_PRESETS

static final int NUM_PRESETS
The number of preset frequencies provided by the tuner.

See Also:
Constant Field Values
Method Detail

tuneUp

void tuneUp()
Move the frequency one step up, unless the frequency is already at the highest value for this band. In that case, set it to the lowest frequency for this band.


tuneDown

void tuneDown()
Move the frequency one step down, unless the frequency is already at the lowest value for this band. In that case, set it to the highest frequency for this band.


seekUp

void seekUp()
Move the frequency up until a station is found with a signal strength of at least 0.5. If the highest frequency for this band is reached, continue the search with the band's lowest frequency.


seekDown

void seekDown()
Move the frequency down until a station is found with a signal strength of at least 0.5. If the lowest frequency for this band is reached, continue the search with the band's highest frequency.


rememberFrequency

void rememberFrequency(int button)
Remember the current frequency so that it can be later recalled with recallFrequency(int). There are a possible NUM_PRESETS remembered frequencies, each assigned to a button in the user interface.

Parameters:
button - The number of a preset frequency button. Between 1 and NUM_PRESETS, inclusive.

recallFrequency

void recallFrequency(int button)
Recall the frequency associated with a given preset button by a previous call to rememberFrequency(int). Set the recalled frequency to be the current frequency. There are a possible NUM_PRESETS remembered frequencies, each assigned to a button in the user interface.

Parameters:
button - The number of a preset frequency button. Between 1 and NUM_PRESETS, inclusive.

getSignalStrength

double getSignalStrength()
Get the strength of the signal currently being received. This depends, of course, on the current frequency and whether or not there is a "radio station" near or at that frequency.

Returns:
The strength of the signal being received; 0 <= strength <= 1.0

getFrequency

double getFrequency()
Get this tuner's current frequency.

Returns:
The current frequency.

addView

void addView(IView aView)
Add a view (graphical user interface) to the tuner. The view's updateView method must be called each time the tuner's state changes.