examples_common_init(argc,argv);
out = new_fvec(2,channels);
- bt = new_aubio_tempo(type_onset,buffer_size,overlap_size,channels);
+ bt = new_aubio_tempo(onset_mode,buffer_size,overlap_size,channels);
examples_common_process(aubio_process,process_print);
/* energy,specdiff,hfc,complexdomain,phase */
-aubio_onsetdetection_type type_onset = aubio_onset_kl;
-aubio_onsetdetection_type type_onset2 = aubio_onset_complex;
+char_t * onset_mode = "default";
smpl_t threshold = 0.3;
smpl_t silence = -90.;
uint_t buffer_size = 512; //1024;
/* badly redeclare some things */
-aubio_onsetdetection_type type_onset;
smpl_t threshold;
smpl_t averaging;
const char *prog_name;
usejack = 1;
break;
case 'O': /*onset type */
- if (strcmp (optarg, "energy") == 0)
- type_onset = aubio_onset_energy;
- else if (strcmp (optarg, "specdiff") == 0)
- type_onset = aubio_onset_specdiff;
- else if (strcmp (optarg, "hfc") == 0)
- type_onset = aubio_onset_hfc;
- else if (strcmp (optarg, "complexdomain") == 0)
- type_onset = aubio_onset_complex;
- else if (strcmp (optarg, "complex") == 0)
- type_onset = aubio_onset_complex;
- else if (strcmp (optarg, "phase") == 0)
- type_onset = aubio_onset_phase;
- else if (strcmp (optarg, "mkl") == 0)
- type_onset = aubio_onset_mkl;
- else if (strcmp (optarg, "kl") == 0)
- type_onset = aubio_onset_kl;
- else if (strcmp (optarg, "specflux") == 0)
- type_onset = aubio_onset_specflux;
- else {
- errmsg ("unknown onset type.\n");
- abort ();
- }
- usedoubled = 0;
+ onset_mode = optarg;
break;
case 's': /* threshold value for onset */
silence = (smpl_t) atof (optarg);
pv = new_aubio_pvoc (buffer_size, overlap_size, channels);
/* onsets */
parms = new_aubio_peakpicker (threshold);
- o = new_aubio_onsetdetection (type_onset, buffer_size, channels);
+ o = new_aubio_onsetdetection (onset_mode, buffer_size, channels);
onset = new_fvec (1, channels);
- if (usedoubled) {
- o2 = new_aubio_onsetdetection (type_onset2, buffer_size, channels);
- onset2 = new_fvec (1, channels);
- }
}
/* energy,specdiff,hfc,complexdomain,phase */
-extern aubio_onsetdetection_type type_onset;
-extern aubio_onsetdetection_type type_onset2;
+extern char_t * onset_mode;
extern smpl_t threshold;
extern smpl_t silence;
extern uint_t buffer_size;
x->bufsize = 1024;
x->hopsize = x->bufsize / 2;
- x->o = new_aubio_onsetdetection(aubio_onset_complex, x->bufsize, 1);
+ x->o = new_aubio_onsetdetection("complex", x->bufsize, 1);
x->vec = (fvec_t *)new_fvec(x->hopsize,1);
x->pv = (aubio_pvoc_t *)new_aubio_pvoc(x->bufsize, x->hopsize, 1);
x->fftgrain = (cvec_t *)new_cvec(x->bufsize,1);
x->bufsize = 1024;
x->hopsize = x->bufsize / 2;
- x->t = new_aubio_tempo (aubio_onset_complex, x->bufsize, x->hopsize, 1);
+ x->t = new_aubio_tempo ("complex", x->bufsize, x->hopsize, 1);
aubio_tempo_set_silence(x->t,x->silence);
aubio_tempo_set_threshold(x->t,x->threshold);
x->output = (fvec_t *)new_fvec(2,1);
class onsetdetection:
""" class for aubio_onsetdetection """
- def __init__(self,type,buf,chan):
- self.od = new_aubio_onsetdetection(type,buf,chan)
+ def __init__(self,mode,buf,chan):
+ self.od = new_aubio_onsetdetection(mode,buf,chan)
def do(self,tc,tf):
aubio_onsetdetection_do(self.od,tc(),tf())
def __del__(self):
self.myfft = cvec(bufsize,channels)
self.pv = pvoc(bufsize,hopsize,channels)
if mode in ['dual'] :
- self.myod = onsetdetection(aubio_onset_hfc,bufsize,channels)
- self.myod2 = onsetdetection(aubio_onset_mkl,bufsize,channels)
+ self.myod = onsetdetection("hfc",bufsize,channels)
+ self.myod2 = onsetdetection("mkl",bufsize,channels)
self.myonset = fvec(1,channels)
self.myonset2 = fvec(1,channels)
else:
}
/* Allocate memory for an onset detection */
-aubio_onset_t * new_aubio_onset (aubio_onsetdetection_type type_onset,
+aubio_onset_t * new_aubio_onset (char_t * onset_mode,
uint_t buf_size, uint_t hop_size, uint_t channels)
{
aubio_onset_t * o = AUBIO_NEW(aubio_onset_t);
o->wasonset = 0;
o->pv = new_aubio_pvoc(buf_size, hop_size, channels);
o->pp = new_aubio_peakpicker(o->threshold);
- o->od = new_aubio_onsetdetection(type_onset,buf_size,channels);
+ o->od = new_aubio_onsetdetection(onset_mode,buf_size,channels);
o->fftgrain = new_cvec(buf_size,channels);
o->of = new_fvec(1, channels);
/*if (usedoubled) {
- o2 = new_aubio_onsetdetection(type_onset2,buffer_size,channels);
+ o2 = new_aubio_onsetdetection(onset_type2,buffer_size,channels);
onset2 = new_fvec(1 , channels);
}*/
return o;
\param channels number of channels
*/
-aubio_onset_t * new_aubio_onset (aubio_onsetdetection_type type_onset,
+aubio_onset_t * new_aubio_onset (char_t * onset_mode,
uint_t buf_size, uint_t hop_size, uint_t channels);
/** execute onset detection
*/
void aubio_onsetdetection_specflux(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
+/** onsetdetection types */
+typedef enum {
+ aubio_onset_energy, /**< energy based */
+ aubio_onset_specdiff, /**< spectral diff */
+ aubio_onset_hfc, /**< high frequency content */
+ aubio_onset_complex, /**< complex domain */
+ aubio_onset_phase, /**< phase fast */
+ aubio_onset_kl, /**< Kullback Liebler */
+ aubio_onset_mkl, /**< modified Kullback Liebler */
+ aubio_onset_specflux, /**< spectral flux */
+} aubio_onsetdetection_type;
+
/** structure to store object state */
struct _aubio_onsetdetection_t {
- aubio_onsetdetection_type type; /**< onset detection type */
+ aubio_onsetdetection_type onset_type; /**< onset detection type */
/** Pointer to aubio_onsetdetection_<type> function */
void (*funcpointer)(aubio_onsetdetection_t *o,
cvec_t * fftgrain, fvec_t * onset);
* depending on the choosen type, allocate memory as needed
*/
aubio_onsetdetection_t *
-new_aubio_onsetdetection (aubio_onsetdetection_type type,
+new_aubio_onsetdetection (char_t * onset_mode,
uint_t size, uint_t channels){
aubio_onsetdetection_t * o = AUBIO_NEW(aubio_onsetdetection_t);
uint_t rsize = size/2+1;
- switch(type) {
+ aubio_onsetdetection_type onset_type;
+ if (strcmp (onset_mode, "energy") == 0)
+ onset_type = aubio_onset_energy;
+ else if (strcmp (onset_mode, "specdiff") == 0)
+ onset_type = aubio_onset_specdiff;
+ else if (strcmp (onset_mode, "hfc") == 0)
+ onset_type = aubio_onset_hfc;
+ else if (strcmp (onset_mode, "complexdomain") == 0)
+ onset_type = aubio_onset_complex;
+ else if (strcmp (onset_mode, "complex") == 0)
+ onset_type = aubio_onset_complex;
+ else if (strcmp (onset_mode, "phase") == 0)
+ onset_type = aubio_onset_phase;
+ else if (strcmp (onset_mode, "mkl") == 0)
+ onset_type = aubio_onset_mkl;
+ else if (strcmp (onset_mode, "kl") == 0)
+ onset_type = aubio_onset_kl;
+ else if (strcmp (onset_mode, "specflux") == 0)
+ onset_type = aubio_onset_specflux;
+ else {
+ AUBIO_ERR("unknown onset type.\n");
+ return NULL;
+ }
+ switch(onset_type) {
/* for both energy and hfc, only fftgrain->norm is required */
case aubio_onset_energy:
break;
* detections on the fly. this would need getting rid of the switch
* above and always allocate all the structure */
- switch(type) {
+ switch(onset_type) {
case aubio_onset_energy:
o->funcpointer = aubio_onsetdetection_energy;
break;
default:
break;
}
- o->type = type;
+ o->onset_type = onset_type;
return o;
}
void del_aubio_onsetdetection (aubio_onsetdetection_t *o){
- switch(o->type) {
+ switch(o->onset_type) {
/* for both energy and hfc, only fftgrain->norm is required */
case aubio_onset_energy:
break;
extern "C" {
#endif
-/** onsetdetection types */
-typedef enum {
- aubio_onset_energy, /**< energy based */
- aubio_onset_specdiff, /**< spectral diff */
- aubio_onset_hfc, /**< high frequency content */
- aubio_onset_complex, /**< complex domain */
- aubio_onset_phase, /**< phase fast */
- aubio_onset_kl, /**< Kullback Liebler */
- aubio_onset_mkl, /**< modified Kullback Liebler */
- aubio_onset_specflux, /**< spectral flux */
-} aubio_onsetdetection_type;
-
/** onsetdetection structure */
typedef struct _aubio_onsetdetection_t aubio_onsetdetection_t;
/** execute onset detection function on a spectral frame
\param channels number of input channels
*/
-aubio_onsetdetection_t * new_aubio_onsetdetection(aubio_onsetdetection_type type, uint_t size, uint_t channels);
+aubio_onsetdetection_t * new_aubio_onsetdetection(char_t * onset_mode, uint_t buf_size, uint_t channels);
/** deletion of an onset detection object
\param o onset detection object as returned by new_aubio_onsetdetection()
}
/* Allocate memory for an tempo detection */
-aubio_tempo_t * new_aubio_tempo (aubio_onsetdetection_type type_onset,
+aubio_tempo_t * new_aubio_tempo (char_t * onset_mode,
uint_t buf_size, uint_t hop_size, uint_t channels)
{
aubio_tempo_t * o = AUBIO_NEW(aubio_tempo_t);
o->out = new_fvec(o->step,channels);
o->pv = new_aubio_pvoc(buf_size, hop_size, channels);
o->pp = new_aubio_peakpicker(o->threshold);
- o->od = new_aubio_onsetdetection(type_onset,buf_size,channels);
+ o->od = new_aubio_onsetdetection(onset_mode,buf_size,channels);
o->of = new_fvec(1, channels);
o->bt = new_aubio_beattracking(o->winlen,channels);
/*if (usedoubled) {
typedef struct _aubio_tempo_t aubio_tempo_t;
/** create tempo detection object */
-aubio_tempo_t * new_aubio_tempo (aubio_onsetdetection_type type_onset,
+aubio_tempo_t * new_aubio_tempo (char_t * mode,
uint_t buf_size, uint_t hop_size, uint_t channels);
/** execute tempo detection */
%#endif /* HAVE_SAMPLERATE */
/* onset detection */
-typedef enum {
- aubio_onset_energy,
- aubio_onset_specdiff,
- aubio_onset_hfc,
- aubio_onset_complex,
- aubio_onset_phase,
- aubio_onset_kl,
- aubio_onset_mkl,
- aubio_onset_specflux,
-} aubio_onsetdetection_type;
-aubio_onsetdetection_t * new_aubio_onsetdetection(aubio_onsetdetection_type type, uint_t size, uint_t channels);
+aubio_onsetdetection_t * new_aubio_onsetdetection(char * onset_mode, uint_t size, uint_t channels);
void aubio_onsetdetection_do (aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
void del_aubio_onsetdetection(aubio_onsetdetection_t *o);
uint_t channels = 1; /* number of channel */
fvec_t * in = new_fvec (win_s/4, channels); /* input buffer */
fvec_t * out = new_fvec (2, channels); /* input buffer */
- aubio_onset_t * onset = new_aubio_onset(aubio_onset_complex, win_s, win_s/4, channels);
+ aubio_onset_t * onset = new_aubio_onset("complex", win_s, win_s/4, channels);
uint_t i = 0;
while (i < 10) {
aubio_onsetdetection_t *o;
- o = new_aubio_onsetdetection (aubio_onset_energy, win_s, channels);
+ o = new_aubio_onsetdetection ("energy", win_s, channels);
aubio_onsetdetection_do (o, in, out);
del_aubio_onsetdetection (o);
- o = new_aubio_onsetdetection (aubio_onset_specdiff, win_s, channels);
+ o = new_aubio_onsetdetection ("energy", win_s, channels);
aubio_onsetdetection_do (o, in, out);
del_aubio_onsetdetection (o);
- o = new_aubio_onsetdetection (aubio_onset_hfc, win_s, channels);
+ o = new_aubio_onsetdetection ("hfc", win_s, channels);
aubio_onsetdetection_do (o, in, out);
del_aubio_onsetdetection (o);
- o = new_aubio_onsetdetection (aubio_onset_complex, win_s, channels);
+ o = new_aubio_onsetdetection ("complex", win_s, channels);
aubio_onsetdetection_do (o, in, out);
del_aubio_onsetdetection (o);
- o = new_aubio_onsetdetection (aubio_onset_phase, win_s, channels);
+ o = new_aubio_onsetdetection ("phase", win_s, channels);
aubio_onsetdetection_do (o, in, out);
del_aubio_onsetdetection (o);
- o = new_aubio_onsetdetection (aubio_onset_kl, win_s, channels);
+ o = new_aubio_onsetdetection ("kl", win_s, channels);
aubio_onsetdetection_do (o, in, out);
del_aubio_onsetdetection (o);
- o = new_aubio_onsetdetection (aubio_onset_mkl, win_s, channels);
+ o = new_aubio_onsetdetection ("mkl", win_s, channels);
aubio_onsetdetection_do (o, in, out);
del_aubio_onsetdetection (o);
uint_t channels = 1; /* number of channel */
fvec_t * in = new_fvec (win_s, channels); /* input buffer */
fvec_t * out = new_fvec (2, channels); /* input buffer */
- aubio_tempo_t * o = new_aubio_tempo(aubio_onset_complex, win_s, win_s/4, channels);
+ aubio_tempo_t * o = new_aubio_tempo("complex", win_s, win_s/4, channels);
uint_t i = 0;
smpl_t curtempo, curtempoconf;