org.jscience.media.audio.dsp
Class AbstractAudio

java.lang.Object
  extended by org.jscience.media.audio.dsp.AbstractAudio
All Implemented Interfaces:
Named
Direct Known Subclasses:
AmplitudeAdjust, Cache, Chorus, CompExp, CompExpHard, Delay, Distortion, GraphicEQ, Oscillator, Panner, ParametricEQ, Phaser, PitchShifter, Reverb, Scope, SpectrumAnalyzer

public abstract class AbstractAudio
extends java.lang.Object
implements Named

DOCUMENT ME!


Field Summary
static int ALLTYPES
          DOCUMENT ME!
static int MONITOR
          DOCUMENT ME!
 AbstractAudio next
          DOCUMENT ME!
static int NOTYPE
          DOCUMENT ME!
 AbstractAudio previous
          DOCUMENT ME!
static int PROCESSOR
          DOCUMENT ME!
static int SAMPLEBUFFERSIZE
          DOCUMENT ME!
static int SINK
          DOCUMENT ME!
static int SOURCE
          DOCUMENT ME!
 
Constructor Summary
AbstractAudio(java.lang.String name, int type)
          AbstractAudio class constructor

NOTE: name and type are for informational purposes only and serve to identify a specific device.

 
Method Summary
 void doReset()
          Called to perform a reset operation on all participating device stages.
 boolean equals(AbstractAudio a)
          Function to determine if one AbstractAudio device is the same as another.
 boolean getByPass()
          Return the current by pass state of this device.
 java.lang.String getName()
          Return the name of this AbstractAudio device
 int getNumberOfChannels()
          Retrieve the number of channel of the signal path.
abstract  int getSamples(short[] buffer, int length)
          This method must be iplemented by all devices that extend the AbstractAudio class.
 int getSamplingRate()
          Retrieve the sample rate of the signal path.
 void hexo(int i)
          Hex string display method
static void hexo(long i)
          Hex string display method
 void hexo(java.lang.String s, int i)
          Labeled hex string display method
static void hexo(java.lang.String s, long i)
          Labeled hex string display method
 void minMaxChannels(int min, int max, int preferred)
          Called to find the min, preferred and max values for the number of channels the devices in the signal path find acceptable.
 void minMaxSamplingRate(int min, int max, int preferred)
          Called to find the min, preferred and max values for sample rate the devices in the signal path find acceptable.
protected  void negotiateNumberOfChannels()
          Called to instigate number of channel negotiation in the signal chain of AbstractAudio device.
protected  void negotiateSamplingRate()
          Called to instigate sample rate negotiation in the signal chain of AbstractAudio device.
static void o(java.lang.String s)
          Shortcut method for system.out.println
protected  void propagateReset()
          Propagate reset call to all processing stages
protected  void reset()
          Override this method if reset functionality is required for your AbstractAudio device derivative.
 void setByPass(boolean byPass)
          Used to set the bypass state of this device
 void setChannelsRecursive(int ch)
          Called to force the specified number of channels to be used in the device chain.
protected  void setNumberOfChannels(int channels)
          Sets the number of channels for this device if possible
protected  void setSamplingRate(int s)
          Sets the sample rate for this device if possible
 void setSamplingRateRecursive(int sr)
          Causes all the device stages to have their sampling rate set to the specified value.
 java.lang.String toString()
          Convert AbstractAudio parameters to a string for display
static java.lang.String typeString(int type)
          Static method for displaying a type string given the device type
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SAMPLEBUFFERSIZE

public static final int SAMPLEBUFFERSIZE
DOCUMENT ME!

See Also:
Constant Field Values

ALLTYPES

public static final int ALLTYPES
DOCUMENT ME!

See Also:
Constant Field Values

NOTYPE

public static final int NOTYPE
DOCUMENT ME!

See Also:
Constant Field Values

SOURCE

public static final int SOURCE
DOCUMENT ME!

See Also:
Constant Field Values

PROCESSOR

public static final int PROCESSOR
DOCUMENT ME!

See Also:
Constant Field Values

MONITOR

public static final int MONITOR
DOCUMENT ME!

See Also:
Constant Field Values

SINK

public static final int SINK
DOCUMENT ME!

See Also:
Constant Field Values

previous

public AbstractAudio previous
DOCUMENT ME!


next

public AbstractAudio next
DOCUMENT ME!

Constructor Detail

AbstractAudio

public AbstractAudio(java.lang.String name,
                     int type)
AbstractAudio class constructor

NOTE: name and type are for informational purposes only and serve to identify a specific device.

Parameters:
String - name is the name given to this device
int - type is one of the device types listed above
Method Detail

typeString

public static java.lang.String typeString(int type)
Static method for displaying a type string given the device type

Parameters:
type - type is the type of this AbstractAudio device
Returns:
DOCUMENT ME!

toString

public java.lang.String toString()
Convert AbstractAudio parameters to a string for display

Overrides:
toString in class java.lang.Object
Returns:
String containing description of this device

equals

public boolean equals(AbstractAudio a)
Function to determine if one AbstractAudio device is the same as another. Equality is assumed if name and type match. This method is used in the LinkedListVector class to find specific devices on the list.

Parameters:
a - DOCUMENT ME!
Returns:
boolean true if the name and type match, false otherwise.

getName

public java.lang.String getName()
Return the name of this AbstractAudio device

Specified by:
getName in interface Named
Returns:
String containing device's assigned name

getSamples

public abstract int getSamples(short[] buffer,
                               int length)
This method must be iplemented by all devices that extend the AbstractAudio class. This is the method by which audio samples are moved between device stages. Call the getSamples() method on the device previous to this device in the signal path causes samples to be pull from it.

Parameters:
buffer - [] buffer is a buffer that this stage of processing should fill with data for subsequent return to calling code.
length - length is the number of samples that are requested
Returns:
int indicating the number of samples available or -1 if the end of input or file has been reached.

getByPass

public boolean getByPass()
Return the current by pass state of this device.

Returns:
boolean true if this stage of processing is bypassed and false otherwise.

setByPass

public void setByPass(boolean byPass)
Used to set the bypass state of this device

Parameters:
byPass - byPass if true stage will be bypassed.

getSamplingRate

public int getSamplingRate()
Retrieve the sample rate of the signal path. If not already set, this call with instigate negotiation.

Returns:
int containing the agreed upon sample rate

setSamplingRate

protected void setSamplingRate(int s)
Sets the sample rate for this device if possible

Parameters:
s - s is the sample rate to set

negotiateSamplingRate

protected void negotiateSamplingRate()
Called to instigate sample rate negotiation in the signal chain of AbstractAudio device. First it causes propagation towards the sink in the signal chain. Next, the default sample rate values are set and the negotiation is begun by a call to minMaxSamplingRate. Upon return from negotiation, some checking is done to see that the negotiated rate is acceptable and then setSamplingRateRecursive is called to force the agreed upon sample rate into each of the AbstractAudio devices in the signal chain.


minMaxSamplingRate

public void minMaxSamplingRate(int min,
                               int max,
                               int preferred)
Called to find the min, preferred and max values for sample rate the devices in the signal path find acceptable.

Parameters:
min - min is the wrapped minimum value of sampling rate this signal path can tolerate.
max - max is the wrapped maximum value of sampling rate this signal path can tolerate.
preferred - preferred is the wrapped sampling rate value this signal path prefers.

setSamplingRateRecursive

public void setSamplingRateRecursive(int sr)
Causes all the device stages to have their sampling rate set to the specified value.

Parameters:
sr - sr is the sampling rate that was negotiated and needs therefore to be set into each stage.

getNumberOfChannels

public int getNumberOfChannels()
Retrieve the number of channel of the signal path. If not already set, this call with instigate negotiation.

Returns:
int containing the agreed upon number of channels

setNumberOfChannels

protected void setNumberOfChannels(int channels)
Sets the number of channels for this device if possible

Parameters:
channels - channels is the number of channels to set

negotiateNumberOfChannels

protected void negotiateNumberOfChannels()
Called to instigate number of channel negotiation in the signal chain of AbstractAudio device. First it causes propagation towards the sink in the signal chain. Next, the default number of channels value is set and the negotiation is begun by a call to minMaxChannels. Upon return from negotiation, some checking is done to see that the negotiated channels is acceptable and then setChannelsRecursive is called to force the agreed upon number of channels into each of the AbstractAudio devices in the signal chain.


minMaxChannels

public void minMaxChannels(int min,
                           int max,
                           int preferred)
Called to find the min, preferred and max values for the number of channels the devices in the signal path find acceptable.

Parameters:
min - min is the wrapped minimum number of channels this signal path can tolerate.
max - max is the wrapped maximum number of channels this signal path can tolerate.
preferred - preferred is the wrapped number of channels this signal path prefers.

setChannelsRecursive

public void setChannelsRecursive(int ch)
Called to force the specified number of channels to be used in the device chain. This causes a propagation towards the source in the signal chain and then on return sets the number of channels variable in each stage of the chain.

Parameters:
ch - ch is the number of channels to set either 1 for mono or 2 for stereo.

reset

protected void reset()
Override this method if reset functionality is required for your AbstractAudio device derivative. If not overridden nothing will happen in this device when a reset operation occurs.


propagateReset

protected void propagateReset()
Propagate reset call to all processing stages


doReset

public void doReset()
Called to perform a reset operation on all participating device stages.


hexo

public void hexo(int i)
Hex string display method

Parameters:
i - i is the value to convert to a hex string

hexo

public void hexo(java.lang.String s,
                 int i)
Labeled hex string display method

Parameters:
s - s is the label to prepend to the hex string
i - i is the value to convert to a hex string

hexo

public static void hexo(long i)
Hex string display method

Parameters:
i - i is the value to convert to a hex string

hexo

public static void hexo(java.lang.String s,
                        long i)
Labeled hex string display method

Parameters:
s - s is the label to prepend to the hex string
i - i is the value to convert to a hex string

o

public static void o(java.lang.String s)
Shortcut method for system.out.println

Parameters:
s - s is the string to write to standard out