public class RealAudioBuffer extends Object implements AudioBuffer, Cloneable
Buffer that holds real, time domain audio data and some meta information in the form of
an AudioFormat
instance. The imaginary part of the represented data
is always zero.
SignalPullProcessor
,
SignalProcessor
,
ComplexAudioBuffer
Constructor and Description |
---|
RealAudioBuffer(int frameNumber,
float[] realData,
AudioFormat audioFormat) |
RealAudioBuffer(RealAudioBuffer buffer)
Copy constructor that creates a deep copy of the data, but a shallow (reference) copy of the format.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Creates an exact copy of this buffer.
|
RealAudioBuffer |
derive(float[] real,
float[] imaginary)
Creates a copy of this buffer, but replaces its values with the given real and imaginary data.
|
boolean |
equals(Object o) |
AudioFormat |
getAudioFormat()
Describes the audio data contained in this buffer.
|
float[] |
getData()
Because this is a real-only buffer, the result is the same as calling
getRealData() . |
int |
getFrameNumber()
Number of the first frame at the beginning of this buffer.
|
float[] |
getImaginaryData()
Imaginary part of the data in this buffer.
|
float[] |
getMagnitudes()
Magnitudes for this buffer - since this is a real-only buffer, this is equivalent to
abs(getRealData()) . |
int |
getNumberOfSamples()
Returns the number of samples this buffer was built from.
|
float[] |
getPowers()
Powers for this buffer - since this a real-only buffer, this is equivalent to
square(getRealData()) . |
float[] |
getRealData()
Real part of this buffer's data.
|
long |
getTimestamp()
Time from the beginning of the track to the beginning of this buffer in ms.
|
long |
getTimestamp(TimeUnit timeUnit)
Time from the beginning of the track to the beginning of this buffer in the requested unit.
|
int |
hashCode() |
void |
reuse(int frameNumber,
float[] realData,
AudioFormat audioFormat)
Refills this buffer with new data.
|
String |
toString() |
public RealAudioBuffer(int frameNumber, float[] realData, AudioFormat audioFormat)
public RealAudioBuffer(RealAudioBuffer buffer)
buffer
- buffer to copypublic void reuse(int frameNumber, float[] realData, AudioFormat audioFormat)
frameNumber
- frameNumberrealData
- realDataaudioFormat
- audioFormatpublic long getTimestamp()
AudioBuffer
AudioBuffer.getTimestamp(java.util.concurrent.TimeUnit)
with a
finer unit.
If we didn't start reading at the beginning of the file (i.e. timestamp == 0),
the offset may not be 100% precise.getTimestamp
in interface AudioBuffer
AudioBuffer.getFrameNumber()
,
AudioBuffer.getTimestamp(java.util.concurrent.TimeUnit)
public long getTimestamp(TimeUnit timeUnit)
AudioBuffer
getTimestamp
in interface AudioBuffer
timeUnit
- time unitAudioBuffer.getTimestamp()
public int getFrameNumber()
AudioBuffer
AudioBuffer.getTimestamp()
, this method may not be the most accurate, if you didn't
start reading at the beginning of the file.getFrameNumber
in interface AudioBuffer
AudioBuffer.getTimestamp()
,
AudioFormat
public AudioFormat getAudioFormat()
AudioBuffer
getAudioFormat
in interface AudioBuffer
public float[] getData()
getRealData()
.
Note that this is different from calling getMagnitudes()
in that the result contains positive
and negative numbers, while the magnitudes are positive-only.getData
in interface AudioBuffer
AbstractAudioSpectrum.getData()
public float[] getRealData()
getRealData
in interface AudioBuffer
public float[] getImaginaryData()
getImaginaryData
in interface AudioBuffer
public float[] getPowers()
square(getRealData())
.getPowers
in interface AudioBuffer
AudioBuffer.getMagnitudes()
public float[] getMagnitudes()
abs(getRealData())
.getMagnitudes
in interface AudioBuffer
AudioBuffer.getPowers()
public int getNumberOfSamples()
AudioBuffer
getNumberOfSamples
in interface AudioBuffer
public RealAudioBuffer derive(float[] real, float[] imaginary)
AudioBuffer
derive
in interface AudioBuffer
real
- real dataimaginary
- imaginary datapublic Object clone() throws CloneNotSupportedException
AudioBuffer
clone
in interface AudioBuffer
clone
in class Object
CloneNotSupportedException
Copyright © 2011–2020 tagtraum industries incorporated. All rights reserved.