onsetsds.h File Reference

#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

Data Structures

struct  OdsPolarBin
struct  OdsPolarBuf
struct  OnsetsDS
 The main data structure for the onset detection routine. More...

Defines

#define ods_log1   -2.30258509
#define PI   3.1415926535898f
#define MINUSPI   -3.1415926535898f
#define TWOPI   6.28318530717952646f
#define INV_TWOPI   0.1591549430919f
#define ods_abs(a)   ((a)<0? -(a) : (a))
#define ods_max(a, b)   (((a) > (b)) ? (a) : (b))
#define ods_min(a, b)   (((a) < (b)) ? (a) : (b))
#define ODS_LOG_LOWER_LIMIT   2e-42
#define ODS_LOGOF_LOG_LOWER_LIMIT   -96.0154267
#define ODS_ABSINVOF_LOGOF_LOG_LOWER_LIMIT   0.010414993

Enumerations

enum  onsetsds_fft_types { ODS_FFT_SC3_COMPLEX, ODS_FFT_SC3_POLAR, ODS_FFT_FFTW3_HC, ODS_FFT_FFTW3_R2C }
enum  onsetsds_odf_types {
  ODS_ODF_POWER, ODS_ODF_MAGSUM, ODS_ODF_COMPLEX, ODS_ODF_RCOMPLEX,
  ODS_ODF_PHASE, ODS_ODF_WPHASE, ODS_ODF_MKL
}
enum  onsetsds_wh_types { ODS_WH_NONE, ODS_WH_ADAPT_MAX1, ODS_WH_NORMMAX, ODS_WH_NORMMEAN }

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)
void onsetsds_setrelax (OnsetsDS *ods, float time, size_t hopsize)
void onsetsds_loadframe (OnsetsDS *ods, float *fftbuf)
void onsetsds_whiten (OnsetsDS *ods)
void onsetsds_odf (OnsetsDS *ods)
void onsetsds_detect (OnsetsDS *ods)

Detailed Description


Define Documentation

#define ods_log1   -2.30258509

#define PI   3.1415926535898f

#define MINUSPI   -3.1415926535898f

#define TWOPI   6.28318530717952646f

#define INV_TWOPI   0.1591549430919f

#define ods_abs (  )     ((a)<0? -(a) : (a))

#define ods_max ( a,
 )     (((a) > (b)) ? (a) : (b))

#define ods_min ( a,
 )     (((a) < (b)) ? (a) : (b))

#define ODS_LOG_LOWER_LIMIT   2e-42

#define ODS_LOGOF_LOG_LOWER_LIMIT   -96.0154267

#define ODS_ABSINVOF_LOGOF_LOG_LOWER_LIMIT   0.010414993


Enumeration Type Documentation

enum onsetsds_fft_types

Types of incoming FFT data format. OnsetsDS needs to know where the FFT data comes from in order to interpret it correctly.

Enumerator:
ODS_FFT_SC3_COMPLEX  SuperCollider, cartesian co-ords ("SCComplexBuf") - NB it's more efficient to provide polar data from SC.
ODS_FFT_SC3_POLAR  SuperCollider, polar co-ords ("SCPolarBuf").
ODS_FFT_FFTW3_HC  FFTW "halfcomplex" format.
ODS_FFT_FFTW3_R2C  FFTW regular format, typically produced using real-to-complex transform.

enum onsetsds_odf_types

Types of onset detection function

Enumerator:
ODS_ODF_POWER  Power.
ODS_ODF_MAGSUM  Sum of magnitudes.
ODS_ODF_COMPLEX  Complex-domain deviation.
ODS_ODF_RCOMPLEX  Complex-domain deviation, rectified (only increases counted).
ODS_ODF_PHASE  Phase deviation.
ODS_ODF_WPHASE  Weighted phase deviation.
ODS_ODF_MKL  Modified Kullback-Liebler deviation.

enum onsetsds_wh_types

Types of whitening - may not all be implemented yet.

Enumerator:
ODS_WH_NONE  No whitening - onsetsds_whiten() becomes a no-op.
ODS_WH_ADAPT_MAX1  Adaptive whitening - tracks recent-peak-magnitude in each bin, normalises that to 1.
ODS_WH_NORMMAX  Simple normalisation - each frame is normalised (independent of others) so largest magnitude becomes 1. Not implemented.
ODS_WH_NORMMEAN  Simple normalisation - each frame is normalised (independent of others) so mean magnitude becomes 1. Not implemented.