MTG / essentia

C++ library for audio and music analysis, description and synthesis, including Python bindings
http://essentia.upf.edu
GNU Affero General Public License v3.0
2.82k stars 526 forks source link

OnSet Detection usage #190

Closed q-depot closed 9 years ago

q-depot commented 9 years ago

Hi,

I'm not sure what I'm doing wrong, but the OnSetDetection doesn't seem to be working.

Also a more generic question, are all the features supposed to be working in real-time or some are for offline analysis only?

mOnsetDetection = factory.create("OnsetDetection");
mFft                      = factory.create("FFT");
mCart2polar         = factory.create("CartesianToPolar");

// Fft
mFft->input("frame").set(mWindowedFrameData);
mFft->output("fft").set(mFftData);

// set conversion from cartesian to polar:
mCart2polar->input("complex").set(mFftData);
mCart2polar->output("magnitude").set(mFftMagData);
mCart2polar->output("phase").set(mFftPhaseData);

// OnSet
mOnsetDetection->input( "spectrum" ).set( mFftMagData );
mOnsetDetection->input( "phase" ).set( mFftPhaseData );
mOnsetDetection->output( "onsetDetection" ).set( mOnsetDetectionData );
mOnsetDetection->configure("method", Parameter("hfc") );
mOnsetDetection->configure("sampleRate", Parameter(sampleRate) );

// ...

mFft->compute();
mCart2polar->compute();
mOnsetDetection->compute();
dbogdanov commented 9 years ago

Some of the algorithms, such as OnsetDetectionGlobal, are only for offline mode.

This example extracts onsets:

You can see how OnsetRate is implemented here