public class LinearFrequencySpectrum extends AbstractAudioSpectrum implements Cloneable
Represents a spectrum with linear frequencies (as opposed to a LogFrequencySpectrum)
as generated by a suitable SignalProcessor.
Even though instances are meant to be immutable, all methods return the original, internally used arrays to increase efficiency and reduce memory consumption. As a consequence you must never modify any of those arrays returned to you.
audioFormat, frameNumber, imaginaryData, magnitudes, powers, realData| Constructor and Description |
|---|
LinearFrequencySpectrum(int frameNumber,
float[] realData,
float[] imaginaryData,
AudioFormat audioFormat) |
LinearFrequencySpectrum(LinearFrequencySpectrum linearFrequencySpectrum) |
| Modifier and Type | Method and Description |
|---|---|
Object |
clone()
Creates an exact copy of this buffer.
|
protected float[] |
computeFrequencies() |
LinearFrequencySpectrum |
derive(float[] real,
float[] imaginary)
Creates a copy of this spectrum, but replaces its values with the given real and imaginary data.
|
boolean |
equals(Object o) |
float |
getBandwidth()
Returns the bandwidth (or frequency resolution) of this buffer.
|
int |
getBin(float frequency)
Computes a bin/index for the given frequency.
|
int[] |
getDeviationInSemitoneFractions(int resolution)
Computes the deviation of the frequency at index
i from a standard semitone in fractions of this semitone. |
int[] |
getDeviationsInCents()
Computes the deviation of the frequency at index
i from a standard semitone in cents. |
float[] |
getFrequencies()
Array with frequency values in Hz corresponding to the bin numbers.
|
float |
getFrequency(int bin)
Returns the frequency of a given bin.
|
float[] |
getMagnitudes()
Magnitudes (square root of the powers) of the spectrum.
|
float[] |
getPhases()
Phases in radians.
|
float[] |
getPowers()
Powers (sum of the squares of the real and imaginary part) of the spectrum.
|
int |
hashCode() |
void |
reuse(int frameNumber,
float[] realData,
float[] imaginaryData,
AudioFormat audioFormat)
Refills this spectrum with new data.
|
String |
toString() |
computeMagnitudes, computePowers, getAudioFormat, getData, getFrameNumber, getImaginaryData, getNumberOfSamples, getRealData, getTimestamp, getTimestamppublic LinearFrequencySpectrum(int frameNumber,
float[] realData,
float[] imaginaryData,
AudioFormat audioFormat)
public LinearFrequencySpectrum(LinearFrequencySpectrum linearFrequencySpectrum)
public void reuse(int frameNumber,
float[] realData,
float[] imaginaryData,
AudioFormat audioFormat)
AbstractAudioSpectrumreuse in class AbstractAudioSpectrumframeNumber - frame numberrealData - real dataimaginaryData - imaginary dataaudioFormat - audio formatpublic float getBandwidth()
public int[] getDeviationsInCents()
i from a standard semitone in cents.public int[] getDeviationInSemitoneFractions(int resolution)
i from a standard semitone in fractions of this semitone.resolution - number of possible fractions. E.g. 100 for cents resolutionpublic float[] getFrequencies()
getFrequencies in interface AudioSpectrumnumberOfSamples/2 due to symmetrygetFrequency(int)protected float[] computeFrequencies()
public float getFrequency(int bin)
getFrequencies(), as it is more efficient.getFrequency in interface AudioSpectrumgetFrequency in class AbstractAudioSpectrumbin - bin numbergetFrequencies()public int getBin(float frequency)
getBin in interface AudioSpectrumfrequency - frequencypublic float[] getPowers()
getPowers in interface AudioBuffergetPowers in class AbstractAudioSpectrumgetMagnitudes()public float[] getMagnitudes()
getMagnitudes in interface AudioBuffergetMagnitudes in class AbstractAudioSpectrumgetPowers()public float[] getPhases()
public LinearFrequencySpectrum derive(float[] real, float[] imaginary)
AudioSpectrumderive in interface AudioBufferderive in interface AudioSpectrumreal - real dataimaginary - imaginary datapublic Object clone() throws CloneNotSupportedException
AudioBufferclone in interface AudioBufferclone in class AbstractAudioSpectrumCloneNotSupportedExceptionCopyright © 2011–2020 tagtraum industries incorporated. All rights reserved.