final class NativeAudioSpectrum extends java.lang.Object implements AudioSpectrum
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BANDS |
static double |
DEFAULT_INTERVAL |
static int |
DEFAULT_THRESHOLD |
private static float[] |
EMPTY_FLOAT_ARRAY |
private float[] |
magnitudes |
private long |
nativeRef
Handle to the native spectrum.
|
private float[] |
phases |
Constructor and Description |
---|
NativeAudioSpectrum(long refMedia)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
getBandCount()
Gets the number of bands in the audio spectrum
|
boolean |
getEnabled()
Returns whether audio spectrum is enabled or not.
|
double |
getInterval()
Returns the interval between
AudioSpectrumEvent |
float[] |
getMagnitudes(float[] mag)
Returns an array of the last available magnitudes.
|
float[] |
getPhases(float[] phs)
Returns an array of the last available phases.
|
int |
getSensitivityThreshold()
Returns sensitivity threshold in dB.
|
private boolean |
nativeGetEnabled(long nativeRef) |
private double |
nativeGetInterval(long nativeRef) |
private int |
nativeGetThreshold(long nativeRef) |
private void |
nativeSetBands(long nativeRef,
int bands,
float[] magnitudes,
float[] phases) |
private void |
nativeSetEnabled(long nativeRef,
boolean enable) |
private void |
nativeSetInterval(long nativeRef,
double interval) |
private void |
nativeSetThreshold(long nativeRef,
int threshold) |
void |
setBandCount(int bands)
Sets the number of bands in the audio spectrum
|
void |
setEnabled(boolean enabled)
Turns on or off audio spectrum support.
|
void |
setInterval(double interval)
Set the interval between
AudioSpectrumEvent |
void |
setSensitivityThreshold(int threshold)
Sets sensitivity threshold in dB.
|
private static final float[] EMPTY_FLOAT_ARRAY
public static final int DEFAULT_THRESHOLD
public static final int DEFAULT_BANDS
public static final double DEFAULT_INTERVAL
private final long nativeRef
private float[] magnitudes
private float[] phases
NativeAudioSpectrum(long refMedia)
refNativePlayer
- A reference to the native player.public boolean getEnabled()
AudioSpectrum
getEnabled
in interface AudioSpectrum
public void setEnabled(boolean enabled)
AudioSpectrum
setEnabled
in interface AudioSpectrum
public int getBandCount()
AudioSpectrum
getBandCount
in interface AudioSpectrum
public void setBandCount(int bands)
AudioSpectrum
setBandCount
in interface AudioSpectrum
bands
- integer valuepublic double getInterval()
AudioSpectrum
AudioSpectrumEvents in seconds.
getInterval
in interface AudioSpectrum
public void setInterval(double interval)
AudioSpectrum
AudioSpectrumEvents in seconds.
setInterval
in interface AudioSpectrum
interval
- double valuepublic int getSensitivityThreshold()
AudioSpectrum
getSensitivityThreshold
in interface AudioSpectrum
public void setSensitivityThreshold(int threshold)
AudioSpectrum
setSensitivityThreshold
in interface AudioSpectrum
threshold
- int valuepublic float[] getMagnitudes(float[] mag)
AudioSpectrum
setBandCount(int)
method.
A newly created array contains Float.NEGATIVE_INFINITY
values. When the number of bands is 0 this method returns an empty array.
If a non-null array large enough to hold the values is passed in, it will
be used; otherwise a newly allocated array will be returned.getMagnitudes
in interface AudioSpectrum
mag
- An optionally preallocated double array.public float[] getPhases(float[] phs)
AudioSpectrum
setBandCount(int)
method. A newly created array contains 0.0 values. When the number of bands
is 0 this method returns an empty array. If a non-null array large enough
to hold the values is passed in, it will be used; otherwise a newly
allocated array will be returned.getPhases
in interface AudioSpectrum
phs
- An optionally preallocated double array.private boolean nativeGetEnabled(long nativeRef)
private void nativeSetEnabled(long nativeRef, boolean enable)
private void nativeSetBands(long nativeRef, int bands, float[] magnitudes, float[] phases)
private double nativeGetInterval(long nativeRef)
private void nativeSetInterval(long nativeRef, double interval)
private int nativeGetThreshold(long nativeRef)
private void nativeSetThreshold(long nativeRef, int threshold)