25 #ifndef __GISTHEADER__
26 #define __GISTHEADER__
56 Gist(
int frameSize_,
int sampleRate_) :fftConfigured(false), onsetDetectionFunction(frameSize_), yin(sampleRate_), mfcc(frameSize_,sampleRate_)
75 frameSize = frameSize_;
77 audioFrame.resize(frameSize);
78 fftReal.resize(frameSize);
79 fftImag.resize(frameSize);
80 magnitudeSpectrum.resize(frameSize/2);
84 onsetDetectionFunction.setFrameSize(frameSize);
85 mfcc.setFrameSize(frameSize);
93 audioFrame = audioFrame_;
104 audioFrame.assign(buffer,buffer + numSamples);
113 return magnitudeSpectrum;
123 return coreTimeDomainFeatures.rootMeanSquare(audioFrame);
131 return coreTimeDomainFeatures.peakEnergy(audioFrame);
139 return coreTimeDomainFeatures.zeroCrossingRate(audioFrame);
149 return coreFrequencyDomainFeatures.spectralCentroid(magnitudeSpectrum);
157 return coreFrequencyDomainFeatures.spectralCrest(magnitudeSpectrum);
165 return coreFrequencyDomainFeatures.spectralFlatness(magnitudeSpectrum);
175 return onsetDetectionFunction.energyDifference(audioFrame);
183 return onsetDetectionFunction.spectralDifference(magnitudeSpectrum);
191 return onsetDetectionFunction.spectralDifferenceHWR(magnitudeSpectrum);
199 return onsetDetectionFunction.complexSpectralDifference(fftReal,fftImag);
207 return onsetDetectionFunction.highFrequencyContent(magnitudeSpectrum);
217 return yin.pitchYin(audioFrame);
227 return mfcc.melFrequencySpectrum(magnitudeSpectrum);
235 return mfcc.melFrequencyCepstralCoefficients(magnitudeSpectrum);
252 fftIn = (fftw_complex*) fftw_malloc(
sizeof(fftw_complex) * frameSize);
253 fftOut = (fftw_complex*) fftw_malloc(
sizeof(fftw_complex) * frameSize);
256 p = fftw_plan_dft_1d(frameSize, fftIn, fftOut, FFTW_FORWARD, FFTW_ESTIMATE);
258 fftConfigured =
true;
265 fftw_destroy_plan(p);
276 for (
int i = 0;i < frameSize;i++)
278 fftIn[i][0] = (double) audioFrame[i];
279 fftIn[i][1] = (double) 0.0;
286 for (
int i = 0;i < frameSize;i++)
288 fftReal[i] = (T) fftOut[i][0];
289 fftImag[i] = (T) fftOut[i][1];
293 for (
int i = 0;i < frameSize/2;i++)
295 magnitudeSpectrum[i] = sqrt(pow(fftReal[i],2) + pow(fftImag[i],2));
304 fftw_complex *fftOut;
308 std::vector<T> audioFrame;
309 std::vector<T> fftReal;
310 std::vector<T> fftImag;
311 std::vector<T> magnitudeSpectrum;
T pitchYin()
Calculates monophonic pitch according to the Yin algorithm.
Definition: gist.h:215
std::vector< T > getMagnitudeSpectrum()
Gist automatically calculates the magnitude spectrum when processAudioFrame() is called, this function returns it.
Definition: gist.h:111
Implementations of onset detection functions.
T spectralDifferenceHWR()
Calculates the complex spectral difference onset detection function sample for the magnitude spectrum...
Definition: gist.h:189
template class for the pitch detection algorithm Yin.
Definition: Yin.h:34
~Gist()
Destructor.
Definition: gist.h:62
std::vector< T > melFrequencyCepstralCoefficients()
Calculates Mel Frequency Cepstral Coefficients.
Definition: gist.h:233
void setAudioFrameSize(int frameSize_)
Set the audio frame size.
Definition: gist.h:73
T spectralCrest()
Calculates the spectral crest.
Definition: gist.h:155
T zeroCrossingRate()
Calculates the zero crossing rate of the currently stored audio frame.
Definition: gist.h:137
void processAudioFrame(std::vector< T > audioFrame_)
Process an audio frame.
Definition: gist.h:91
T energyDifference()
Calculates the energy difference onset detection function sample for the magnitude spectrum frame...
Definition: gist.h:173
template class for calculating common time domain audio features.
Definition: CoreTimeDomainFeatures.h:34
Implementation of the YIN pitch detection algorithm (de Cheveigné and Kawahara,2002) ...
T rootMeanSquare()
Calculates the root mean square (RMS) of the currently stored audio frame.
Definition: gist.h:121
T peakEnergy()
Calculates the peak energy of the currently stored audio frame.
Definition: gist.h:129
template class for calculating common frequency domain audio features.
Definition: CoreFrequencyDomainFeatures.h:35
void processAudioFrame(T *buffer, unsigned long numSamples)
Process an audio frame.
Definition: gist.h:102
T spectralCentroid()
Calculates the spectral centroid from the magnitude spectrum.
Definition: gist.h:147
T spectralFlatness()
Calculates the spectral flatness from the magnitude spectrum.
Definition: gist.h:163
Implementations of common time domain audio features.
std::vector< T > melFrequencySpectrum()
Calculates the Mel Frequency Spectrum.
Definition: gist.h:225
T spectralDifference()
Calculates the spectral difference onset detection function sample for the magnitude spectrum frame...
Definition: gist.h:181
Calculates Mel Frequency Cepstral Coefficients.
T complexSpectralDifference()
Calculates the complex spectral difference onset detection function sample for the magnitude spectrum...
Definition: gist.h:197
T highFrequencyContent()
Calculates the high frequency content onset detection function sample for the magnitude spectrum fram...
Definition: gist.h:205
Class for all performing all Gist audio analyses.
Definition: gist.h:48
Implementations of common frequency domain audio features.
Template class for calculating Mel Frequency Cepstral Coefficients Instantiations of the class should...
Definition: MFCC.h:35
Gist(int frameSize_, int sampleRate_)
Constructor.
Definition: gist.h:56
template class for calculating onset detection functions Instantiations of the class should be of eit...
Definition: OnsetDetectionFunction.h:36