Revision 3:15345ae708d6
| doc/mainpage.dox | ||
|---|---|---|
| 42 | 42 |
|
| 43 | 43 |
///////// (1) INITIALISATION: ///////// |
| 44 | 44 |
|
| 45 |
// There are various types of onset detector available, we must choose one |
|
| 46 |
odftype = ODS_ODF_RCOMPLEX; |
|
| 47 |
|
|
| 45 | 48 |
// Allocate contiguous memory using malloc or whatever is reasonable. |
| 46 | 49 |
float* odsdata = (float*) malloc( onsetsds_memneeded(odftype, 512, 11) ); |
| 47 | 50 |
|
| 48 |
// There are various types of onset detector available, we must choose one |
|
| 49 |
odftype = ODS_ODF_RCOMPLEX; |
|
| 50 |
|
|
| 51 | 51 |
// Now initialise the OnsetsDS struct and its associated memory |
| 52 |
onsetsds_init(ods, odsdata, ODS_FFT_FFTW3_HC, odftype, 512, 11);
|
|
| 52 |
onsetsds_init(&ods, odsdata, ODS_FFT_FFTW3_HC, odftype, 512, 11, 44100.f);
|
|
| 53 | 53 |
|
| 54 | 54 |
|
| 55 | 55 |
///////// (2) EXECUTION: ///////// |
| 56 | 56 |
|
| 57 | 57 |
bool onset; |
| 58 | 58 |
while(running){
|
| 59 |
// Grab your 512-point, 50%-overlap, nicely-windowed FFT data, into "fftdata" |
|
| 59 |
// Grab your 512- or 1024-point, 50%-overlap, nicely-windowed FFT data, into "fftdata"
|
|
| 60 | 60 |
|
| 61 | 61 |
// Then detect. "onset" will be true when there's an onset, false otherwise |
| 62 |
onset = onsetsds_process(ods, fftdata); |
|
| 62 |
onset = onsetsds_process(&ods, fftdata);
|
|
| 63 | 63 |
} |
| 64 | 64 |
|
| 65 | 65 |
|
| src/onsetsds.h | ||
|---|---|---|
| 59 | 59 |
* data comes from in order to interpret it correctly. |
| 60 | 60 |
*/ |
| 61 | 61 |
enum onsetsds_fft_types {
|
| 62 |
ODS_FFT_SC3_COMPLEX, ///< SuperCollider, cartesian co-ords ("SCComplexBuf") - NB it's more efficient to provide polar data from SC
|
|
| 63 |
ODS_FFT_SC3_POLAR, ///< SuperCollider, polar co-ords ("SCPolarBuf")
|
|
| 64 |
ODS_FFT_FFTW3_HC, ///< FFTW <a href="http://www.fftw.org/fftw3_doc/The-Halfcomplex_002dformat-DFT.html">"halfcomplex"</a> format |
|
| 62 |
ODS_FFT_SC3_COMPLEX, ///< SuperCollider, cartesian co-ords ("SCComplexBuf") [dc, nyq, real[1], imag[1], real[2], imag[2]...] - NB it's more efficient to provide polar data from SC
|
|
| 63 |
ODS_FFT_SC3_POLAR, ///< SuperCollider, polar co-ords ("SCPolarBuf") [dc, nyq, mag[1], phase[1], mag[2], phase[2]...]
|
|
| 64 |
ODS_FFT_FFTW3_HC, ///< FFTW <a href="http://www.fftw.org/fftw3_doc/The-Halfcomplex_002dformat-DFT.html">"halfcomplex"</a> format - [dc, real[1], real[2] ... nyq, imag[nyq-1] ... imag[1]]
|
|
| 65 | 65 |
ODS_FFT_FFTW3_R2C ///< FFTW regular format, typically produced using <a href="http://www.fftw.org/fftw3_doc/One_002dDimensional-DFTs-of-Real-Data.html#One_002dDimensional-DFTs-of-Real-Data">real-to-complex</a> transform |
| 66 | 66 |
}; |
| 67 | 67 |
|
Also available in: Unified diff