public class MultiBandSpectrum extends AbstractAudioSpectrum implements Cloneable
Represents an audio spectrum divided into bands as produced for example by
createLogarithmicBands(float, float, int)
or createMidiBands(int, int)
.
The bands do not have to be logarithmically spaced.
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 |
---|
MultiBandSpectrum(int frameNumber,
AudioSpectrum audioSpectrum,
float[] bandBoundariesInHz)
Creates a multi band spectrum from another spectrum.
|
MultiBandSpectrum(int frameNumber,
float[] real,
float[] imaginary,
AudioFormat audioFormat,
float[] bandBoundariesInHz)
Constructs a new multi band spectrum.
|
MultiBandSpectrum(MultiBandSpectrum multiBandSpectrum) |
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Creates an exact copy of this buffer.
|
static float[] |
createLinearBands(float lowFrequency,
float highFrequency,
int numberOfBands)
Creates linearly spaced frequency bands.
|
static float[] |
createLogarithmicBands(float lowFrequency,
float highFrequency,
int numberOfBands)
Creates logarithmically spaced frequency bands.
|
static float[] |
createMidiBands(int lowMidi,
int highMidi)
Creates and array of frequency boundaries exactly +-50 cents to the given MIDI
notes.
|
static float[] |
createMidiBands(int lowMidi,
int highMidi,
int binsPerSemitone)
Creates an array of frequency boundaries by dividing each note into the given number of bins.
|
static float[] |
createMidiBands(int lowMidi,
int highMidi,
int binsPerSemitone,
float centDeviation)
Creates an array of frequency boundaries by dividing each note into the given number of bins
and allowing for a different than the standard 440Hz tuning specified in cents.
|
MultiBandSpectrum |
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[] |
getBandBoundaries()
Array with frequency values in Hz corresponding to the band boundaries.
|
int |
getBin(float frequency)
Computes a bin for the given frequency.
|
float[] |
getFrequencies()
Array with center frequency values in Hz corresponding to the bin numbers.
Note that these values are simply the means of the upper and lower boundaries for each bin. |
int |
getNumberOfBands()
Number of bands.
|
int |
hashCode() |
String |
toString() |
computeMagnitudes, computePowers, getAudioFormat, getData, getFrameNumber, getFrequency, getImaginaryData, getMagnitudes, getNumberOfSamples, getPowers, getRealData, getTimestamp, getTimestamp, reuse
public MultiBandSpectrum(int frameNumber, AudioSpectrum audioSpectrum, float[] bandBoundariesInHz)
frameNumber
- frame numberaudioSpectrum
- audio spectrum to copy data frombandBoundariesInHz
- band boundaries in Hzpublic MultiBandSpectrum(int frameNumber, float[] real, float[] imaginary, AudioFormat audioFormat, float[] bandBoundariesInHz)
frameNumber
- frame numberreal
- realimaginary
- imaginaryaudioFormat
- audio formatbandBoundariesInHz
- band boundaries in Hzpublic MultiBandSpectrum(MultiBandSpectrum multiBandSpectrum)
public static float[] createLogarithmicBands(float lowFrequency, float highFrequency, int numberOfBands)
lowFrequency
- lower boundary in HzhighFrequency
- upper boundary in HznumberOfBands
- number of bands in between lower and upper boundarypublic static float[] createLinearBands(float lowFrequency, float highFrequency, int numberOfBands)
lowFrequency
- lower boundary in HzhighFrequency
- upper boundary in HznumberOfBands
- number of bands in between lower and upper boundarypublic static float[] createMidiBands(int lowMidi, int highMidi)
lowMidi
- low MIDI notehighMidi
- high MIDI notepublic static float[] createMidiBands(int lowMidi, int highMidi, int binsPerSemitone)
lowMidi
- low MIDI notehighMidi
- high MIDI notebinsPerSemitone
- bins/semitonepublic static float[] createMidiBands(int lowMidi, int highMidi, int binsPerSemitone, float centDeviation)
binsPerSemitone
- bins/semitonelowMidi
- low MIDI note (incl.)highMidi
- high MIDI note (excl.)centDeviation
- deviation in cent from concert pitch (A4=440Hz)public MultiBandSpectrum derive(float[] real, float[] imaginary)
AudioSpectrum
derive
in interface AudioBuffer
derive
in interface AudioSpectrum
real
- real dataimaginary
- imaginary datapublic float[] getBandBoundaries()
getNumberOfBands()
public int getNumberOfBands()
getBandBoundaries()
public int getBin(float frequency)
getBin
in interface AudioSpectrum
frequency
- frequencypublic float[] getFrequencies()
getFrequencies
in interface AudioSpectrum
AbstractAudioSpectrum.getFrequency(int)
public Object clone() throws CloneNotSupportedException
AudioBuffer
clone
in interface AudioBuffer
clone
in class AbstractAudioSpectrum
CloneNotSupportedException
Copyright © 2011–2020 tagtraum industries incorporated. All rights reserved.