Class AudioSpectrumFunctions
- java.lang.Object
-
- com.tagtraum.audiokern.audioprocessor.AudioSpectrumFunctions
-
public class AudioSpectrumFunctions extends Object
AudioSpectrumFunctions.- Author:
- Hendrik Schreiber
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AudioSpectrumFunctions.AudioSpectrumAveraging
Effectively combining every three bins in a row into a single bins containing the weighted average.static class
AudioSpectrumFunctions.LinearBackgroundRemoval
Implements a noise reduction/whitening scheme for linear-frequency spectra.static class
AudioSpectrumFunctions.LogFrequencyBackgroundRemoval
Implements a noise reduction/whitening scheme for log-frequency spectra with an integer number of bins per semitone similar to the pre-processing defined in "Approximate note transcription for the improved identification of difficult chords" by M.static class
AudioSpectrumFunctions.LogFrequencySpectrumToPitchAveraging
Effectively down-samples the bin resolution of aLogFrequencySpectrum
to one bin per semitone by calculating a weighted average.static class
AudioSpectrumFunctions.LogFrequencySpectrumToPitchDownsampling
Effectively down-samples the bin resolution of aLogFrequencySpectrum
to one bin per semitone by picking one of multiple bins and discarding the others.
-
Field Summary
Fields Modifier and Type Field Description static MapFunction<AudioSpectrum>
PITCH_TO_CHROMA
Adds all corresponding semitones to a chroma vector.static AggregateFunction<AudioSpectrum,Float>
SPECTRAL_CENTROID
static AggregateFunction<AudioSpectrum,Float>
SPECTRAL_SPREAD
static AggregateFunction<AudioSpectrum,Float>
STRONGEST_PARTIAL
-
Constructor Summary
Constructors Constructor Description AudioSpectrumFunctions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AggregateFunction<AudioSpectrum,Float>
createBrightnessFunction(float cutoffFrequency)
Creates anAggregateFunction
that can be used to compute brightness in anAggregate
.static MapFunction<AudioSpectrum>
createGroupPowerSpectrumFunction()
Transforms a given spectrum into aLogFrequencySpectrum
grouped according to rules similar to the ones defined in MPEG-7 for ASF (spectral flatness).static MapFunction<AudioSpectrum>
createHighPassFilter(float minFrequency)
Creates a high pass filter that zeroes all real and imaginary values below a given frequency.static MapFunction<AudioSpectrum>
createHighPassFilter(int minBin)
Creates a high pass filter that zeroes all real and imaginary values below a given sample/bin number.static MapFunction<AudioSpectrum>
createLowPassFilter(float maxFrequency)
Creates a low pass filter that zeroes all real and imaginary values above a given frequency.static MapFunction<AudioSpectrum>
createLowPassFilter(int maxBin)
Creates a low pass filter that zeroes all real and imaginary values above a given bin/sample number.static AggregateFunction<AudioSpectrum,Integer>
createRollOffBinFunction(float percentThreshold)
Returns the bin below which the given percentage of this spectrum's magnitude resides.static AggregateFunction<AudioSpectrum,Float>
createRollOffFunction(float percentThreshold)
Creates anAggregateFunction
that can be used to compute roll-off in anAggregate
.static MapFunction<AudioSpectrum>
createSpectralFlatnessFunction(int n, int bands)
Transforms a given spectrum into aMultiBandSpectrum
containing spectral flatness values similar to MPEG-7 ASF.
-
-
-
Field Detail
-
STRONGEST_PARTIAL
public static AggregateFunction<AudioSpectrum,Float> STRONGEST_PARTIAL
-
SPECTRAL_CENTROID
public static AggregateFunction<AudioSpectrum,Float> SPECTRAL_CENTROID
-
SPECTRAL_SPREAD
public static AggregateFunction<AudioSpectrum,Float> SPECTRAL_SPREAD
-
PITCH_TO_CHROMA
public static MapFunction<AudioSpectrum> PITCH_TO_CHROMA
Adds all corresponding semitones to a chroma vector. Note that this function requires the spectrum to be in semitones already, i.e. one bin per semitone. The resultingLogFrequencySpectrum
uses the first 12 frequencies of the source spectrum as its frequencies.
-
-
Method Detail
-
createSpectralFlatnessFunction
public static MapFunction<AudioSpectrum> createSpectralFlatnessFunction(int n, int bands)
Transforms a given spectrum into aMultiBandSpectrum
containing spectral flatness values similar to MPEG-7 ASF. Values range between0.0f
and1.0f
, where1.0f
represents total flatness, i.e. random noise and0.0f
very pronounced tonality.- Parameters:
n
- defines the lower frequency boundary with2^(0.25*n) * 1kHz
, e.g.-8
bands
- number of bands, e.g. 24.- Returns:
- map function
- See Also:
- Spectral Flatness on Wikipedia
-
createGroupPowerSpectrumFunction
public static MapFunction<AudioSpectrum> createGroupPowerSpectrumFunction()
Transforms a given spectrum into aLogFrequencySpectrum
grouped according to rules similar to the ones defined in MPEG-7 for ASF (spectral flatness).- Returns:
- map function
- See Also:
- Spectral Flatness on Wikipedia
-
createRollOffFunction
public static AggregateFunction<AudioSpectrum,Float> createRollOffFunction(float percentThreshold)
Creates anAggregateFunction
that can be used to compute roll-off in anAggregate
.- Parameters:
percentThreshold
- threshold in percent (i.e. 0 <= threshold <= 1), typically 0.85f or 0.95f- Returns:
- a function object that computes spectral roll-off
-
createRollOffBinFunction
public static AggregateFunction<AudioSpectrum,Integer> createRollOffBinFunction(float percentThreshold)
Returns the bin below which the given percentage of this spectrum's magnitude resides. Note that roll-off values tend to be fairly random for spectra with very little overall energy.- Parameters:
percentThreshold
- threshold in percent (i.e. 0 <= threshold <= 1), typical values are 0.85f (G. Tzanetakis, P. Cook. Musical genre classification of audio signals. IEEE Tr. Speech and Audio Processing, 10(5),293-302, 2002) or 0.95f (T. Pohle, E. Pampalk, G. Widmer. Evaluation of Frequently Used Audio Features for Classification of Music Into Perceptual Categories, Proceedings of the 4th International Workshop on Content-Based Multimedia Indexing, Riga, Latvia, June 2005.)- Returns:
- a function for computing the RollOffBin
- See Also:
createRollOffFunction(float)
-
createBrightnessFunction
public static AggregateFunction<AudioSpectrum,Float> createBrightnessFunction(float cutoffFrequency)
Creates an
AggregateFunction
that can be used to compute brightness in anAggregate
.Brightness gives an indication of what percentage of the overall energy of a spectrum resides above a given cutoff frequency. Typical values are 1000Hz, 1500Hz, 3000Hz. 1500Hz can be considered a default value.
- Parameters:
cutoffFrequency
- cutoff frequency in Hz- Returns:
- a function object that computes brightness values between 0.0f and 1.0f based on a spectrum
- See Also:
- Juslin, P. N. (2000).
Cue utilization in communication of emotion in music performance: relating performance to perception.
J Exp Psychol Hum Percept Perform. 2000 Dec;26(6):1797-813.,
Laukka, P., Juslin, P. N.,
and Bresin, R. (2005). A dimensional approach to vocal expression of emotion. Cognition and Emotion, 19, 633-653.,
createRollOffFunction(float)
-
createLowPassFilter
public static MapFunction<AudioSpectrum> createLowPassFilter(float maxFrequency)
Creates a low pass filter that zeroes all real and imaginary values above a given frequency.- Parameters:
maxFrequency
- cut off frequency- Returns:
- low pass filter function suitable for
Mapping
-
createLowPassFilter
public static MapFunction<AudioSpectrum> createLowPassFilter(int maxBin)
Creates a low pass filter that zeroes all real and imaginary values above a given bin/sample number.- Parameters:
maxBin
- cut off bin- Returns:
- low pass filter function suitable for
Mapping
-
createHighPassFilter
public static MapFunction<AudioSpectrum> createHighPassFilter(float minFrequency)
Creates a high pass filter that zeroes all real and imaginary values below a given frequency.- Parameters:
minFrequency
- cut off frequency- Returns:
- high pass filter function suitable for
Mapping
-
createHighPassFilter
public static MapFunction<AudioSpectrum> createHighPassFilter(int minBin)
Creates a high pass filter that zeroes all real and imaginary values below a given sample/bin number.- Parameters:
minBin
- cut off bin- Returns:
- high pass filter function suitable for
Mapping
-
-