javaclient
Class AudioDSPInterface

java.lang.Object
  extended by javaclient.PlayerDevice
      extended by javaclient.AudioDSPInterface

public class AudioDSPInterface
extends PlayerDevice

The audiodsp interface is used to control sound hardware, if equipped.

Version:
Author:
Radu Bogdan Rusu

Field Summary
static short PLAYER_AUDIODSP_GET_CONFIG
           
static short PLAYER_AUDIODSP_PLAY_CHIRP
           
static short PLAYER_AUDIODSP_PLAY_TONE
           
static short PLAYER_AUDIODSP_REPLAY
           
static short PLAYER_AUDIODSP_SET_CONFIG
           
 
Fields inherited from class javaclient.PlayerDevice
device, DIFFERENCE_SYNCH_FACTOR, index, is, os, pc, PLAYER_MAX_REQREP_SIZE, PLAYER_STXX, reserved, size, t_sec, t_usec, ts_sec, ts_usec
 
Constructor Summary
AudioDSPInterface(PlayerClient pc, short indexOfDevice)
          Constructor for AudioDSPInterface.
 
Method Summary
 void command(byte subtype, int freq, int amp, int duration, char[] bitString, int bitStringLen)
          The audiodsp interface accepts commands to produce fixed-frequency tones or binary phase shift keyed(BPSK) chirps through /dev/dsp (which is assumed to be associated with a sound card to which a speaker is attached).
 int[] getAmplitudes()
          Returns the five highest amplitudes.
 void getAudioProperties()
          Configuration request : Get audio properties.
 byte getChannels()
          Returns the number of channels to use (1=mono, 2=stereo).
 int[] getFrequencies()
          Returns the five highest frequencies.
 int getSampleFormat()
          Returns the format with which to sample.
 int getSampleRate()
          Returns the sample rate in Hertz.
 void handleResponse(int size)
          Handle acknowledgement response messages (threaded mode).
 void readData()
          The audiodsp interface reads the audio stream from /dev/dsp (which is assumed to be associated with a sound card connected to a microphone) and performs some analysis on it.
 void setAudioProperties(int sampleFormat, int sampleRate, byte channels)
          Configuration request : Set audio properties.
 
Methods inherited from class javaclient.PlayerDevice
getTimeForDataSampled_sec, getTimeForDataSampled_usec, getTimeForDataSampled, getTimeForDataSent_sec, getTimeForDataSent_usec, getTimeForDataSent, handleEARMessage, handleNARMessage, readHeader, sendHeader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLAYER_AUDIODSP_SET_CONFIG

public static final short PLAYER_AUDIODSP_SET_CONFIG
See Also:
Constant Field Values

PLAYER_AUDIODSP_GET_CONFIG

public static final short PLAYER_AUDIODSP_GET_CONFIG
See Also:
Constant Field Values

PLAYER_AUDIODSP_PLAY_TONE

public static final short PLAYER_AUDIODSP_PLAY_TONE
See Also:
Constant Field Values

PLAYER_AUDIODSP_PLAY_CHIRP

public static final short PLAYER_AUDIODSP_PLAY_CHIRP
See Also:
Constant Field Values

PLAYER_AUDIODSP_REPLAY

public static final short PLAYER_AUDIODSP_REPLAY
See Also:
Constant Field Values
Constructor Detail

AudioDSPInterface

public AudioDSPInterface(PlayerClient pc,
                         short indexOfDevice)
Constructor for AudioDSPInterface.

Parameters:
pc - a reference to the PlayerClient object
indexOfDevice - the index of the device
Method Detail

readData

public void readData()
The audiodsp interface reads the audio stream from /dev/dsp (which is assumed to be associated with a sound card connected to a microphone) and performs some analysis on it. Five frequency/amplitude pairs are then returned as data.

Overrides:
readData in class PlayerDevice

getFrequencies

public int[] getFrequencies()
Returns the five highest frequencies.

Returns:
an array filled with the highest five frequencies

getAmplitudes

public int[] getAmplitudes()
Returns the five highest amplitudes.

Returns:
an array filled with the highest five amplitudes

command

public void command(byte subtype,
                    int freq,
                    int amp,
                    int duration,
                    char[] bitString,
                    int bitStringLen)
The audiodsp interface accepts commands to produce fixed-frequency tones or binary phase shift keyed(BPSK) chirps through /dev/dsp (which is assumed to be associated with a sound card to which a speaker is attached).

Parameters:
subtype - The packet subtype. Set to PLAYER_AUDIODSP_PLAY_TONE to play a single frequency; bitString and bitStringLen do not need to be set. Set to PLAYER_AUDIODSP_PLAY_CHIRP to play a BPSKeyed chirp; bitString should contain the binary string to encode, and bitStringLen set to the length of the bitString. Set to PLAYER_AUDIODSP_REPLAY to replay the last sound.
freq - Frequency to play (Hz)
amp - Amplitude to play (dB?)
duration - Duration to play (msec)
bitString - BitString to encode in sine wave
bitStringLen - Length of the bit string

getAudioProperties

public void getAudioProperties()
Configuration request : Get audio properties.

The audiodsp configuration can be queried using the PLAYER_AUDIODSP_GET_CONFIG request and modified using the PLAYER_AUDIODSP_SET_CONFIG request.

The sample format is defined in sys/soundcard.h, and defines the byte size and endian format for each sample.

The sample rate defines the Hertz at which to sample.

Mono or stereo sampling is defined in the channels parameter where 1==mono and 2==stereo.

See the player_audiodsp_config structure from player.h


setAudioProperties

public void setAudioProperties(int sampleFormat,
                               int sampleRate,
                               byte channels)
Configuration request : Set audio properties.

The audiodsp configuration can be queried using the PLAYER_AUDIODSP_GET_CONFIG request and modified using the PLAYER_AUDIODSP_SET_CONFIG request.

The sample format is defined in sys/soundcard.h, and defines the byte size and endian format for each sample.

The sample rate defines the Hertz at which to sample.

Mono or stereo sampling is defined in the channels parameter where 1==mono and 2==stereo.

See the player_audiodsp_config structure from player.h

Parameters:
sampleFormat - Format with which to sample
sampleRate - Sample rate in Hertz
channels - Number of channels to use. 1=mono, 2=stereo

handleResponse

public void handleResponse(int size)
Handle acknowledgement response messages (threaded mode).

Overrides:
handleResponse in class PlayerDevice
Parameters:
size - size of the payload

getSampleFormat

public int getSampleFormat()
Returns the format with which to sample.

Returns:
the format with which to sample as an integer

getSampleRate

public int getSampleRate()
Returns the sample rate in Hertz.

Returns:
the sample rate in Hertz as an integer

getChannels

public byte getChannels()
Returns the number of channels to use (1=mono, 2=stereo).

Returns:
the number of channels to use as a byte