Class SpectralCentroidProcessor
- java.lang.Object
-
- com.tagtraum.jipes.AbstractSignalProcessor<LinearFrequencySpectrum,SpectralCentroidProcessor.Centroid>
-
- com.tagtraum.audiokern.audioprocessor.SpectralCentroidProcessor
-
- All Implemented Interfaces:
SignalProcessor<LinearFrequencySpectrum,SpectralCentroidProcessor.Centroid>
,SignalPullProcessor<LinearFrequencySpectrum,SpectralCentroidProcessor.Centroid>
,SignalSource<SpectralCentroidProcessor.Centroid>
public class SpectralCentroidProcessor extends AbstractSignalProcessor<LinearFrequencySpectrum,SpectralCentroidProcessor.Centroid>
Computes the frequency of the centroid of a given power spectrum. The centroid is computed as the ratio of the weighted sum of all power coefficients and the regular sum of all power coefficients. Note that theSpectralCentroidProcessor.WeightFunction
can be redefined. By default it'sINDEX_PLUS_1
.- Author:
- Hendrik Schreiber
- See Also:
FFT
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SpectralCentroidProcessor.Centroid
static interface
SpectralCentroidProcessor.WeightFunction
Weight function to be used when computing the weighted sum of all powers.
-
Field Summary
Fields Modifier and Type Field Description static SpectralCentroidProcessor.WeightFunction
DEFAULT_WEIGHT_FUNCTION
static SpectralCentroidProcessor.WeightFunction
INDEX_PLUS_1
index+1
(, because in beaTunes all indexes are zero-based).static SpectralCentroidProcessor.WeightFunction
LOG2_FREQ_DIV_1000
log2(frequency/1000)
.-
Fields inherited from class com.tagtraum.jipes.AbstractSignalProcessor
lastOut, signalProcessorSupport
-
-
Constructor Summary
Constructors Constructor Description SpectralCentroidProcessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
SpectralCentroidProcessor.WeightFunction
getWeightFunction()
int
hashCode()
boolean
isCollapseSub62_5Hz()
protected SpectralCentroidProcessor.Centroid
processNext(LinearFrequencySpectrum origSpectrum)
void
setCollapseSub62_5Hz(boolean collapseSub62_5Hz)
Collapses (sums) all coefficients below 62.5Hz into a single coefficient, in order to prevent non-zero DC-component or very low frequency components from having a disproportionate weight.void
setWeightFunction(SpectralCentroidProcessor.WeightFunction weightFunction)
String
toString()
-
Methods inherited from class com.tagtraum.jipes.AbstractSignalProcessor
connectTo, connectTo, connectTo, disconnectFrom, flush, getConnectedProcessors, getConnectedSource, getId, getOutput, process, read, reset, setId
-
-
-
-
Field Detail
-
LOG2_FREQ_DIV_1000
public static final SpectralCentroidProcessor.WeightFunction LOG2_FREQ_DIV_1000
log2(frequency/1000)
. Used by the MPEG7 Audio Spectral Centroid, together withsetCollapseSub62_5Hz(boolean)
.
-
INDEX_PLUS_1
public static final SpectralCentroidProcessor.WeightFunction INDEX_PLUS_1
index+1
(, because in beaTunes all indexes are zero-based).
-
DEFAULT_WEIGHT_FUNCTION
public static final SpectralCentroidProcessor.WeightFunction DEFAULT_WEIGHT_FUNCTION
-
-
Method Detail
-
isCollapseSub62_5Hz
public boolean isCollapseSub62_5Hz()
-
getWeightFunction
public SpectralCentroidProcessor.WeightFunction getWeightFunction()
-
setWeightFunction
public void setWeightFunction(SpectralCentroidProcessor.WeightFunction weightFunction)
-
setCollapseSub62_5Hz
public void setCollapseSub62_5Hz(boolean collapseSub62_5Hz)
Collapses (sums) all coefficients below 62.5Hz into a single coefficient, in order to prevent non-zero DC-component or very low frequency components from having a disproportionate weight. See MPEG-7 ASC.
This is set to
false
by default.- Parameters:
collapseSub62_5Hz
- true if you want to collapse the coefficients
-
processNext
protected SpectralCentroidProcessor.Centroid processNext(LinearFrequencySpectrum origSpectrum) throws IOException
- Specified by:
processNext
in classAbstractSignalProcessor<LinearFrequencySpectrum,SpectralCentroidProcessor.Centroid>
- Throws:
IOException
-
-