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, getTimestamp
public LinearFrequencySpectrum(int frameNumber, float[] realData, float[] imaginaryData, AudioFormat audioFormat)
public LinearFrequencySpectrum(LinearFrequencySpectrum linearFrequencySpectrum)
public void reuse(int frameNumber, float[] realData, float[] imaginaryData, AudioFormat audioFormat)
AbstractAudioSpectrum
reuse
in class AbstractAudioSpectrum
frameNumber
- 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 AudioSpectrum
numberOfSamples/2
due to symmetrygetFrequency(int)
protected float[] computeFrequencies()
public float getFrequency(int bin)
getFrequencies()
, as it is more efficient.getFrequency
in interface AudioSpectrum
getFrequency
in class AbstractAudioSpectrum
bin
- bin numbergetFrequencies()
public int getBin(float frequency)
getBin
in interface AudioSpectrum
frequency
- frequencypublic float[] getPowers()
getPowers
in interface AudioBuffer
getPowers
in class AbstractAudioSpectrum
getMagnitudes()
public float[] getMagnitudes()
getMagnitudes
in interface AudioBuffer
getMagnitudes
in class AbstractAudioSpectrum
getPowers()
public float[] getPhases()
public LinearFrequencySpectrum derive(float[] real, float[] imaginary)
AudioSpectrum
derive
in interface AudioBuffer
derive
in interface AudioSpectrum
real
- real dataimaginary
- imaginary datapublic Object clone() throws CloneNotSupportedException
AudioBuffer
clone
in interface AudioBuffer
clone
in class AbstractAudioSpectrum
CloneNotSupportedException
Copyright © 2011–2020 tagtraum industries incorporated. All rights reserved.