/* energy,specdiff,hfc,complexdomain,phase */
-aubio_onsetdetection_type type_onset = kl;
-aubio_onsetdetection_type type_onset2 = complexdomain;
+aubio_onsetdetection_type type_onset = aubio_onset_kl;
+aubio_onsetdetection_type type_onset2 = aubio_onset_complex;
smpl_t threshold = 0.3;
smpl_t threshold2 = -90.;
uint_t buffer_size = 512; //1024;
break;
case 'O': /*onset type*/
if (strcmp(optarg,"energy") == 0)
- type_onset = energy;
+ type_onset = aubio_onset_energy;
else if (strcmp(optarg,"specdiff") == 0)
- type_onset = specdiff;
+ type_onset = aubio_onset_specdiff;
else if (strcmp(optarg,"hfc") == 0)
- type_onset = hfc;
+ type_onset = aubio_onset_hfc;
else if (strcmp(optarg,"complexdomain") == 0)
- type_onset = complexdomain;
+ type_onset = aubio_onset_complex;
+ else if (strcmp(optarg,"complex") == 0)
+ type_onset = aubio_onset_complex;
else if (strcmp(optarg,"phase") == 0)
- type_onset = phase;
+ 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 {
debug("could not get onset type.\n");
abort();
x->bufsize = 1024;
x->hopsize = x->bufsize / 2;
- x->o = new_aubio_onsetdetection(complexdomain, x->bufsize, 1);
+ x->o = new_aubio_onsetdetection(aubio_onset_complex, x->bufsize, 1);
x->vec = (fvec_t *)new_fvec(x->hopsize,1);
x->pv = new_aubio_pvoc(x->bufsize, x->hopsize, 1);
x->fftgrain = new_cvec(x->bufsize,1);
self.myfft = cvec(bufsize,channels)
self.pv = pvoc(bufsize,hopsize,channels)
if mode in ['dual'] :
- self.myod = onsetdetection(hfc,bufsize,channels)
- self.myod2 = onsetdetection(complexdomain,bufsize,channels)
+ self.myod = onsetdetection(aubio_onset_hfc,bufsize,channels)
+ self.myod2 = onsetdetection(aubio_onset_complex,bufsize,channels)
self.myonset = fvec(1,channels)
self.myonset2 = fvec(1,channels)
else:
else: self.myonset.set(0.,0,0)
return self.pp.do(self.myonset),self.myonset.get(0,0)
+def check_onset_mode(option, opt, value, parser):
+ nvalue = parser.rargs[0]
+ if nvalue == 'complexdomain' or nvalue == 'complex' :
+ setattr(parser.values, option.dest, aubio_onset_complex)
+ elif nvalue == 'hfc' :
+ setattr(parser.values, option.dest, aubio_onset_hfc)
+ elif nvalue == 'phase' :
+ setattr(parser.values, option.dest, aubio_onset_phase)
+ elif nvalue == 'specdiff' :
+ setattr(parser.values, option.dest, aubio_onset_specdiff)
+ elif nvalue == 'energy' :
+ setattr(parser.values, option.dest, aubio_onset_energy)
+ elif nvalue == 'kl' :
+ setattr(parser.values, option.dest, aubio_onset_kl)
+ elif nvalue == 'mkl' :
+ setattr(parser.values, option.dest, aubio_onset_mkl)
+ elif nvalue == 'dual' :
+ setattr(parser.values, option.dest, 'dual')
+ else:
+ print "unknown detection function selected\n", usage
+ sys.exit(1)
+
+def check_pitch_mode(option, opt, value, parser):
+ nvalue = parser.rargs[0]
+ if nvalue == 'mcomb' :
+ setattr(parser.values, option.dest, aubio_pitch_mcomb)
+ elif nvalue == 'yin' :
+ setattr(parser.values, option.dest, aubio_pitch_yin)
+ elif nvalue == 'fcomb' :
+ setattr(parser.values, option.dest, aubio_pitch_fcomb)
+ elif nvalue == 'schmitt' :
+ setattr(parser.values, option.dest, aubio_pitch_schmitt)
+ else:
+ print "unknown detection function selected\n", usage
+ sys.exit(1)
+
+
def getonsets(filein,threshold=0.2,silence=-70.,bufsize=1024,hopsize=512,
mode='dual',localmin=False,storefunc=False,derivate=False):
frameread = 0
usage = "usage: %s [options] -i soundfile" % sys.argv[0]
-def check_mode(option, opt, value, parser):
- nvalue = parser.rargs[0]
- if nvalue == 'complexdomain' :
- setattr(parser.values, option.dest, complexdomain)
- elif nvalue == 'hfc' :
- setattr(parser.values, option.dest, hfc)
- elif nvalue == 'phase' :
- setattr(parser.values, option.dest, phase)
- elif nvalue == 'specdiff' :
- setattr(parser.values, option.dest, specdiff)
- elif nvalue == 'energy' :
- setattr(parser.values, option.dest, energy)
- elif nvalue == 'kl' :
- setattr(parser.values, option.dest, kl)
- elif nvalue == 'mkl' :
- setattr(parser.values, option.dest, mkl)
- elif nvalue == 'dual' :
- setattr(parser.values, option.dest, 'dual')
- else:
- print "unknown detection function selected\n", usage
- sys.exit(1)
-
def parse_args():
from optparse import OptionParser
parser = OptionParser(usage=usage)
action="store", dest="filename",
help="input sound file")
parser.add_option("-m","--mode", action="callback",
- callback=check_mode, dest="mode", default='dual',
+ callback=check_onset_mode, dest="mode", default='dual',
help="onset detection mode [default=dual] \
complexdomain|hfc|phase|specdiff|energy|kl|mkl|dual")
parser.add_option("-B","--bufsize",
usage = "usage: %s [options] -i soundfile" % sys.argv[0]
-def check_mode(option, opt, value, parser):
- nvalue = parser.rargs[0]
- if nvalue == 'mcomb' :
- setattr(parser.values, option.dest, aubio_pitch_mcomb)
- elif nvalue == 'yin' :
- setattr(parser.values, option.dest, aubio_pitch_yin)
- elif nvalue == 'fcomb' :
- setattr(parser.values, option.dest, aubio_pitch_fcomb)
- elif nvalue == 'schmitt' :
- setattr(parser.values, option.dest, aubio_pitch_schmitt)
-
def parse_args():
from optparse import OptionParser
action="store", dest="filename",
help="input sound file")
parser.add_option("-m","--mode", action="callback",
- callback=check_mode, dest="mode", default=aubio_pitch_mcomb,
+ callback=check_pitch_mode, dest="mode",
+ default=aubio_pitch_mcomb,
help="pitch detection mode [default=mcomb] \
mcomb|yin|fcomb|schmitt")
parser.add_option("-B","--bufsize",
uint_t rsize = size/2+1;
switch(type) {
/* for both energy and hfc, only fftgrain->norm is required */
- case energy:
+ case aubio_onset_energy:
break;
- case hfc:
+ case aubio_onset_hfc:
break;
/* the other approaches will need some more memory spaces */
- case complexdomain:
+ case aubio_onset_complex:
o->oldmag = new_fvec(rsize,channels);
/** bug: must be complex array */
o->meas = AUBIO_ARRAY(fft_data_t,size);
o->theta1 = new_fvec(rsize,channels);
o->theta2 = new_fvec(rsize,channels);
break;
- case phase:
+ case aubio_onset_phase:
o->dev1 = new_fvec(rsize,channels);
o->theta1 = new_fvec(rsize,channels);
o->theta2 = new_fvec(rsize,channels);
o->histog = new_aubio_hist(0.0f, PI, 10, channels);
o->threshold = 0.1;
break;
- case specdiff:
+ case aubio_onset_specdiff:
o->oldmag = new_fvec(rsize,channels);
o->dev1 = new_fvec(rsize,channels);
o->histog = new_aubio_hist(0.0f, PI, 10, channels);
o->threshold = 0.1;
break;
- case kl:
+ case aubio_onset_kl:
o->oldmag = new_fvec(rsize,channels);
break;
- case mkl:
+ case aubio_onset_mkl:
o->oldmag = new_fvec(rsize,channels);
break;
default:
* above and always allocate all the structure */
switch(type) {
- case energy:
+ case aubio_onset_energy:
o->funcpointer = aubio_onsetdetection_energy;
break;
- case hfc:
+ case aubio_onset_hfc:
o->funcpointer = aubio_onsetdetection_hfc;
break;
- case complexdomain:
+ case aubio_onset_complex:
o->funcpointer = aubio_onsetdetection_complex;
break;
- case phase:
+ case aubio_onset_phase:
o->funcpointer = aubio_onsetdetection_phase;
break;
- case specdiff:
+ case aubio_onset_specdiff:
o->funcpointer = aubio_onsetdetection_specdiff;
break;
- case kl:
+ case aubio_onset_kl:
o->funcpointer = aubio_onsetdetection_kl;
break;
- case mkl:
+ case aubio_onset_mkl:
o->funcpointer = aubio_onsetdetection_mkl;
break;
default:
switch(o->type) {
/* for both energy and hfc, only fftgrain->norm is required */
- case energy:
+ case aubio_onset_energy:
break;
- case hfc:
+ case aubio_onset_hfc:
break;
/* the other approaches will need some more memory spaces */
- case complexdomain:
+ case aubio_onset_complex:
AUBIO_FREE(o->meas);
del_fvec(o->oldmag);
del_fvec(o->dev1);
del_fvec(o->theta1);
del_fvec(o->theta2);
break;
- case phase:
+ case aubio_onset_phase:
del_fvec(o->dev1);
del_fvec(o->theta1);
del_fvec(o->theta2);
del_aubio_hist(o->histog);
break;
- case specdiff:
+ case aubio_onset_specdiff:
del_fvec(o->oldmag);
del_fvec(o->dev1);
del_aubio_hist(o->histog);
/** onsetdetection types */
typedef enum {
- energy, /**< energy based */
- specdiff, /**< spectral diff */
- hfc, /**< high frequency content */
- complexdomain, /**< complex domain */
- phase, /**< phase fast */
- kl, /**< Kullback Liebler (Hainsworth et al., Onset detection in musical audio signals) */
- mkl /**< modified Kullback Liebler (Hainsworth et al., Onset detection in musical audio signals) */
+ 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 (Hainsworth et al., Onset detection in musical audio signals) */
+ aubio_onset_mkl /**< modified Kullback Liebler (Hainsworth et al., Onset detection in musical audio signals) */
} aubio_onsetdetection_type;
/** onsetdetection structure */
extern void del_aubio_resampler(aubio_resampler_t *s);
/* onset detection */
-typedef enum { energy, specdiff, hfc, complexdomain, phase, kl, mkl } aubio_onsetdetection_type;
+typedef enum {
+ aubio_onset_energy,
+ aubio_onset_specdiff,
+ aubio_onset_hfc,
+ aubio_onset_complex,
+ aubio_onset_phase,
+ aubio_onset_kl,
+ aubio_onset_mkl
+} aubio_onsetdetection_type;
aubio_onsetdetection_t * new_aubio_onsetdetection(aubio_onsetdetection_type type, uint_t size, uint_t channels);
void aubio_onsetdetection(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
void aubio_onsetdetection_free(aubio_onsetdetection_t *o);
/* should these still be exposed ? */
void aubio_onsetdetection_energy (aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
-void aubio_onsetdetection_hfc (aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
+void aubio_onsetdetection_hfc (aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
void aubio_onsetdetection_complex (aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
void aubio_onsetdetection_phase (aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
void aubio_onsetdetection_specdiff(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
+void aubio_onsetdetection_kl (aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
+void aubio_onsetdetection_mkl (aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
/* pvoc */
aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s, uint_t channels);