Package ipsk.audio.dsp
Class AudioFrameProcessor
- java.lang.Object
-
- ipsk.audio.dsp.AudioSampleProcessor
-
- ipsk.audio.dsp.AudioFrameProcessor
-
- Direct Known Subclasses:
AudioBufferProcessor
,PeakDetector
public class AudioFrameProcessor extends AudioSampleProcessor
Calculates amplitude values for an audio frame. An audio frame contains the samples for all channels.- Author:
- K.Jaensch, klausj@phonetik.uni-muenchen.de
-
-
Field Summary
-
Fields inherited from class ipsk.audio.dsp.AudioSampleProcessor
ae, af, AUDITORY_THRESHOLD, bigEndian, channels, DEFAULT_0DB_SOUND_PRESSURE, frameSize, maxValue, minValue, pp, resolutionBits, sampleSize, signed
-
-
Constructor Summary
Constructors Constructor Description AudioFrameProcessor(javax.sound.sampled.AudioFormat af)
Create a frame processor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
encode(double[][] values, int srcOffset, byte[] buf, int offset, int frames)
Encode normalized double values to byte buffer.void
encode(double[] values, int srcOffset, byte[] buf, int offset, int samples)
Encode normalized double values to byte buffer.void
encodeToFloatValues(float[] values, byte[] buf, int offset)
Encode one frame of normalized float values to byte buffer.void
encodeValues(double[] values, byte[] buf, int offset)
Encode one frame of normalized double values to byte buffer.void
encodeValues(float[] values, byte[] buf, int offset)
Encode one frame of normalized float values to byte buffer.void
getDoubleValues(byte[] frameData, int offset, double[] buffer)
Converts to normalized double values (amplitudes) of the given data.float[]
getFloatValues(byte[] frameData)
Returns the normalized float values (amplitudes) of the given frame.float[]
getFloatValues(byte[] frameData, int offset)
Returns the normalized float values (amplitudes) of the given data.void
getFloatValues(byte[] frameData, int offset, float[] buffer)
Converts to normalized float values (amplitudes) of the given data.void
getNormalizedInterleavedValues(byte[] frameData, int frames, double[][] normBuffer, int normBufferFrameOffset)
Converts PCM coded data to normalized double values (amplitudes).void
getNormalizedInterleavedValues(byte[] frameData, int frameDataOffset, int frames, double[][] normBuffer, int normBufferFrameOffset)
Converts PCM coded data to normalized double values (amplitudes).void
getNormalizedValues(byte[] frameData, int offset, double[] normBuffer)
Converts to normalized float values (amplitudes) of the given data.-
Methods inherited from class ipsk.audio.dsp.AudioSampleProcessor
amplitudeToSoundPressure, encodeValue, getChannels, getDoubleValue, getEncodedValue, getFloatValue, getFloatValue, getFrameSize, getNormalizedValue, getNormalizedValue, getSampleSize, setAudioFormat
-
-
-
-
Constructor Detail
-
AudioFrameProcessor
public AudioFrameProcessor(javax.sound.sampled.AudioFormat af) throws AudioFormatNotSupportedException
Create a frame processor.- Parameters:
af
- frame must have this audio format- Throws:
AudioFormatNotSupportedException
-
-
Method Detail
-
getFloatValues
public float[] getFloatValues(byte[] frameData)
Returns the normalized float values (amplitudes) of the given frame.- Parameters:
frameData
- PCM coded data array- Returns:
- values (range -0.5 ... +0.5)
-
getFloatValues
public float[] getFloatValues(byte[] frameData, int offset)
Returns the normalized float values (amplitudes) of the given data.- Parameters:
frameData
- PCM coded data arrayoffset
- offset in the data- Returns:
- values (range -0.5 ... +0.5)
-
getNormalizedInterleavedValues
public void getNormalizedInterleavedValues(byte[] frameData, int frames, double[][] normBuffer, int normBufferFrameOffset)
Converts PCM coded data to normalized double values (amplitudes).- Parameters:
frameData
- PCM coded data arrayframes
- count of frames to processnormBuffer
- buffer for normalized audio data (value range -1.0 ... +1.0)normBufferFrameOffset
- offset in frames from where to write converted values
-
getNormalizedInterleavedValues
public void getNormalizedInterleavedValues(byte[] frameData, int frameDataOffset, int frames, double[][] normBuffer, int normBufferFrameOffset)
Converts PCM coded data to normalized double values (amplitudes).- Parameters:
frameData
- PCM coded data arrayframeDataOffset
- offset in frameDataframes
- count of frames to processnormBuffer
- buffer for normalized audio data (value range -1.0 ... +1.0)normBufferFrameOffset
- offset in frames from where to write converted values
-
getNormalizedValues
public void getNormalizedValues(byte[] frameData, int offset, double[] normBuffer)
Converts to normalized float values (amplitudes) of the given data.- Parameters:
frameData
- PCM coded data arrayoffset
- offset (of bytes) in PCM input datanormBuffer
- buffer for normalized audio data (value range -1.0 ... +1.0)
-
getDoubleValues
public void getDoubleValues(byte[] frameData, int offset, double[] buffer)
Converts to normalized double values (amplitudes) of the given data.- Parameters:
frameData
- PCM coded data arrayoffset
- offset (of bytes) in PCM input databuffer
- buffer for audio data values (range -0.5 ... +0.5)
-
getFloatValues
public void getFloatValues(byte[] frameData, int offset, float[] buffer)
Converts to normalized float values (amplitudes) of the given data.- Parameters:
frameData
- PCM coded data arrayoffset
- offset (of bytes) in PCM input databuffer
- buffer for audio data values (range -0.5 ... +0.5)
-
encodeToFloatValues
public void encodeToFloatValues(float[] values, byte[] buf, int offset)
Encode one frame of normalized float values to byte buffer.- Parameters:
values
- float values for all channelsbuf
- the bufferoffset
- bufPos in the buffer
-
encodeValues
public void encodeValues(float[] values, byte[] buf, int offset)
Encode one frame of normalized float values to byte buffer.- Parameters:
values
- float values for all channelsbuf
- the bufferoffset
- bufPos in the buffer
-
encodeValues
public void encodeValues(double[] values, byte[] buf, int offset)
Encode one frame of normalized double values to byte buffer.- Parameters:
values
- double values for all channelsbuf
- the bufferoffset
- bufPos in the buffer
-
encode
public void encode(double[][] values, int srcOffset, byte[] buf, int offset, int frames)
Encode normalized double values to byte buffer.- Parameters:
values
- double values for all channelsbuf
- the bufferoffset
- bufPos in the buffer
-
encode
public void encode(double[] values, int srcOffset, byte[] buf, int offset, int samples)
Encode normalized double values to byte buffer.- Parameters:
values
- double values (one value per sample)srcOffset
- offset in the source bufferbuf
- the bufferoffset
- offset in the target byte buffersamples
- sample count to convert
-
-