Package ipsk.audio.dsp
Class AudioSampleProcessor
- java.lang.Object
-
- ipsk.audio.dsp.AudioSampleProcessor
-
- Direct Known Subclasses:
AudioFrameProcessor
,AudioSampleProcessorTest.AudioSampleProcessorImpl
public abstract class AudioSampleProcessor extends java.lang.Object
Calculates amplitude values for an audio sample.- Author:
- K.Jaensch, klausj@phonetik.uni-muenchen.de
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.sound.sampled.AudioFormat.Encoding
ae
protected javax.sound.sampled.AudioFormat
af
static double
AUDITORY_THRESHOLD
protected boolean
bigEndian
protected int
channels
static double
DEFAULT_0DB_SOUND_PRESSURE
protected int
frameSize
protected double
maxValue
protected double
minValue
protected double
pp
protected int
resolutionBits
protected int
sampleSize
protected boolean
signed
-
Constructor Summary
Constructors Constructor Description AudioSampleProcessor()
Creates new audio sample processor.AudioSampleProcessor(javax.sound.sampled.AudioFormat af)
Creates new audio sample processor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
amplitudeToSoundPressure(double ampl)
void
encodeValue(double f, byte[] buf, int offset)
Encodes double values into byte array.int
getChannels()
double
getDoubleValue(byte[] sample, int offset)
Returns the double value (amplitude) of the given data.byte[]
getEncodedValue(double f)
Encodes normalized double values to byte array.float
getFloatValue(byte[] sample)
Returns the normalized float value (amplitude) of the given sample.float
getFloatValue(byte[] sample, int offset)
Returns the normalized float value (amplitude) of the given data.int
getFrameSize()
double
getNormalizedValue(byte[] sample)
Returns the normalized double value (amplitude) of the given sample.double
getNormalizedValue(byte[] sample, int offset)
Returns the float value (amplitude) of the given data.int
getSampleSize()
void
setAudioFormat(javax.sound.sampled.AudioFormat af)
Sets audio format of the samples to process.
-
-
-
Field Detail
-
AUDITORY_THRESHOLD
public static final double AUDITORY_THRESHOLD
- See Also:
- Constant Field Values
-
DEFAULT_0DB_SOUND_PRESSURE
public static final double DEFAULT_0DB_SOUND_PRESSURE
- See Also:
- Constant Field Values
-
af
protected javax.sound.sampled.AudioFormat af
-
ae
protected javax.sound.sampled.AudioFormat.Encoding ae
-
bigEndian
protected boolean bigEndian
-
signed
protected boolean signed
-
channels
protected int channels
-
frameSize
protected int frameSize
-
sampleSize
protected int sampleSize
-
maxValue
protected double maxValue
-
minValue
protected double minValue
-
resolutionBits
protected int resolutionBits
-
pp
protected double pp
-
-
Constructor Detail
-
AudioSampleProcessor
public AudioSampleProcessor()
Creates new audio sample processor.
-
AudioSampleProcessor
public AudioSampleProcessor(javax.sound.sampled.AudioFormat af) throws AudioFormatNotSupportedException
Creates new audio sample processor.- Parameters:
af
- audio format of the samples to process- Throws:
AudioFormatNotSupportedException
-
-
Method Detail
-
setAudioFormat
public void setAudioFormat(javax.sound.sampled.AudioFormat af) throws AudioFormatNotSupportedException
Sets audio format of the samples to process.- Parameters:
af
- audio format of the samples- Throws:
AudioFormatNotSupportedException
-
getNormalizedValue
public double getNormalizedValue(byte[] sample)
Returns the normalized double value (amplitude) of the given sample.- Parameters:
sample
-- Returns:
- normalized value (-1.0 ... +1.0)
-
getFloatValue
public float getFloatValue(byte[] sample)
Returns the normalized float value (amplitude) of the given sample.- Parameters:
sample
- audio sample data buffer- Returns:
- double value (-0.5 ... +0.5)
-
getDoubleValue
public double getDoubleValue(byte[] sample, int offset)
Returns the double value (amplitude) of the given data.- Parameters:
sample
- audio sample data bufferoffset
- offset in the buffer- Returns:
- double value
-
getNormalizedValue
public double getNormalizedValue(byte[] sample, int offset)
Returns the float value (amplitude) of the given data.- Parameters:
sample
- audio sample data bufferoffset
- offset in the buffer- Returns:
- normalized float value (-1.0 ... +1.0)
-
getFloatValue
public float getFloatValue(byte[] sample, int offset)
Returns the normalized float value (amplitude) of the given data.- Parameters:
sample
- audio sample data bufferoffset
- offset in the buffer- Returns:
- normalized float value (-0.5 ... +0.5)
-
encodeValue
public void encodeValue(double f, byte[] buf, int offset)
Encodes double values into byte array.- Parameters:
f
- normalized amplitude value (-1.0 ... 1.0)buf
- target data bufferoffset
- offset in the buffer
-
amplitudeToSoundPressure
public double amplitudeToSoundPressure(double ampl)
-
getEncodedValue
public byte[] getEncodedValue(double f)
Encodes normalized double values to byte array.- Parameters:
f
- normalized amplitude value (-1.0 ... 1.0)- Returns:
- encoded buffer
-
getChannels
public int getChannels()
-
getFrameSize
public int getFrameSize()
-
getSampleSize
public int getSampleSize()
-
-