public class MelSpectrum extends AbstractAudioSpectrum implements Cloneable
LinearFrequencySpectrum
created
by FFT
.
Each mel channel is computed by applying a triangular filter to the magnitudes or powers of the input spectrum and adding up
the result. The filters for consecutive channels overlap by 0.5 of their length.
audioFormat, frameNumber, imaginaryData, magnitudes, powers, realData
Constructor and Description |
---|
MelSpectrum(int frameNumber,
float[] real,
float[] imaginary,
AudioFormat audioFormat,
float[][] filterBank,
float[] channelBoundariesInHz) |
MelSpectrum(int frameNumber,
LinearFrequencySpectrum audioSpectrum,
float[][] filterBank,
float[] channelBoundariesInHz,
boolean filterPowers)
Creates a mel spectrum from a linear spectrum.
|
MelSpectrum(int frameNumber,
LinearFrequencySpectrum audioSpectrum,
float lowerFrequency,
float upperFrequency,
int channels,
boolean filterPowers)
Creates a mel spectrum from a linear spectrum.
|
MelSpectrum(MelSpectrum melSpectrum) |
Modifier and Type | Method and Description |
---|---|
static float[] |
channelBoundaries(float lowerFrequency,
float upperFrequency,
int boundaryCount)
Creates an array with
boundaryCount frequencies in Hz, dividing the given
frequency range into boundaryCount - 1 bins with equal mel-length. |
Object |
clone()
Creates an exact copy of this buffer.
|
static float[][] |
createFilterBank(float[] frequencies,
float[] channelBoundariesInHz)
Creates an array of filter coefficients.
|
MelSpectrum |
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) |
int |
getBin(float frequency)
Computes a bin for the given frequency.
|
float[] |
getFrequencies()
Array with frequency values in Hz corresponding to the bin numbers.
|
int |
getNumberOfBands()
Number of channels/bands.
|
int |
hashCode() |
String |
toString() |
computeMagnitudes, computePowers, getAudioFormat, getData, getFrameNumber, getFrequency, getImaginaryData, getMagnitudes, getNumberOfSamples, getPowers, getRealData, getTimestamp, getTimestamp, reuse
public MelSpectrum(int frameNumber, LinearFrequencySpectrum audioSpectrum, float lowerFrequency, float upperFrequency, int channels, boolean filterPowers)
frameNumber
- frame numberaudioSpectrum
- audio spectrum to copy data fromlowerFrequency
- lower frequency boundary for the lowest triangular filter in HzupperFrequency
- upper frequency boundary for the highest triangular filter in Hzchannels
- number of mel channelsfilterPowers
- if true, the power spectrum is filtered, if false, the magnitude spectrum is filteredpublic MelSpectrum(int frameNumber, LinearFrequencySpectrum audioSpectrum, float[][] filterBank, float[] channelBoundariesInHz, boolean filterPowers)
frameNumber
- frame numberaudioSpectrum
- audio spectrum to copy data fromfilterBank
- filterbank with coefficients for each channelchannelBoundariesInHz
- channel boundaries in HzfilterPowers
- if true, the power spectrum is filtered, if false, the magnitude spectrum is filteredcreateFilterBank(float[], float[])
,
channelBoundaries(float, float, int)
public MelSpectrum(MelSpectrum melSpectrum)
public MelSpectrum(int frameNumber, float[] real, float[] imaginary, AudioFormat audioFormat, float[][] filterBank, float[] channelBoundariesInHz)
public static float[] channelBoundaries(float lowerFrequency, float upperFrequency, int boundaryCount)
boundaryCount
frequencies in Hz, dividing the given
frequency range into boundaryCount - 1
bins with equal mel-length.lowerFrequency
- lowerFrequency in HzupperFrequency
- upperFrequency in HzboundaryCount
- number of boundariespublic static float[][] createFilterBank(float[] frequencies, float[] channelBoundariesInHz)
frequencies
- frequencies for a value input arraychannelBoundariesInHz
- channel boundariespublic MelSpectrum derive(float[] real, float[] imaginary)
AudioSpectrum
derive
in interface AudioBuffer
derive
in interface AudioSpectrum
real
- real dataimaginary
- imaginary datapublic int getNumberOfBands()
public int getBin(float frequency)
getBin
in interface AudioSpectrum
frequency
- frequencypublic float[] getFrequencies()
AudioSpectrum
getFrequencies
in interface AudioSpectrum
AudioSpectrum.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.