Functions | |
size_t | onsetsds_memneeded (int odftype, size_t fftsize, unsigned int medspan) |
void | onsetsds_init (OnsetsDS *ods, float *odsdata, int fftformat, int odftype, size_t fftsize, unsigned int medspan, float srate) |
bool | onsetsds_process (OnsetsDS *ods, float *fftbuf) |
size_t onsetsds_memneeded | ( | int | odftype, | |
size_t | fftsize, | |||
unsigned int | medspan | |||
) |
Determine how many bytes of memory must be allocated (e.g. using malloc) to accompany the OnsetsDS struct, operating using the specified settings (used to store part-processed FFT data etc). The user must call this, and then allocate the memory, BEFORE calling onsetsds_init().
odftype | Which onset detection function (ODF) you'll be using, chosen from onsetsds_odf_types | |
fftsize | Size of FFT: 512 is recommended. | |
medspan | The number of past frames that will be used for median calculation during triggering |
void onsetsds_init | ( | OnsetsDS * | ods, | |
float * | odsdata, | |||
int | fftformat, | |||
int | odftype, | |||
size_t | fftsize, | |||
unsigned int | medspan, | |||
float | srate | |||
) |
Initialise the OnsetsDS struct and its associated memory, ready to detect onsets using the specified settings. Must be called before any call to onsetsds_process().
Note: you can change the onset detection function type in mid-operation by calling onsetsds_init() again, but because memory will be reset this will behave as if starting from scratch (rather than being aware of the past few frames of sound). Do not attempt to change the onset detection function in a more hacky way (e.g. fiddling with the struct) because memory is set up differently for each of the different ODFs.
ods | An instance of the OnsetsDS struct | |
odsdata | A pointer to the memory allocated, size given by onsetsds_memneeded(). | |
fftformat | Which format of FFT data is to be expected, chosen from onsetsds_fft_types | |
odftype | Which onset detection function (ODF) you'll be using, chosen from onsetsds_odf_types | |
fftsize | Size of FFT: 512 or 1024 is recommended. | |
medspan | The number of past frames that will be used for median calculation during triggering | |
srate | The sampling rate of the input audio |
bool onsetsds_process | ( | OnsetsDS * | ods, | |
float * | fftbuf | |||
) |
Process a single FFT data frame in the audio signal. Note that processing assumes that each call to onsetsds_process() is on a subsequent frame in the same audio stream - to handle multiple streams you must use separate OnsetsDS structs and memory!
This function's main purpose is to call some of the library's other functions, in the expected sequence.