From 7473074757703200d2e46af482fe5aaaa10875c0 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Fri, 16 Dec 2005 01:21:17 +0000 Subject: [PATCH] separate get_onset_mode separate get_onset_mode --- python/aubio/tasks.py | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/python/aubio/tasks.py b/python/aubio/tasks.py index be6bc75b..cb7ef76b 100644 --- a/python/aubio/tasks.py +++ b/python/aubio/tasks.py @@ -1,30 +1,35 @@ from aubioclass import * -def check_onset_mode(option, opt, value, parser): +def get_onset_mode(nvalue): """ utility function to convert a string to aubio_onsetdetection_type """ + if nvalue == 'complexdomain' or nvalue == 'complex' : + return aubio_onset_complex + elif nvalue == 'hfc' : + return aubio_onset_hfc + elif nvalue == 'phase' : + return aubio_onset_phase + elif nvalue == 'specdiff' : + return aubio_onset_specdiff + elif nvalue == 'energy' : + return aubio_onset_energy + elif nvalue == 'kl' : + return aubio_onset_kl + elif nvalue == 'mkl' : + return aubio_onset_mkl + elif nvalue == 'dual' : + return 'dual' + else: + import sys + print "unknown onset detection function selected" + sys.exit(1) + +def check_onset_mode(option, opt, value, parser): + """ wrapper function to convert a list of modes to + aubio_onsetdetection_type """ nvalues = parser.rargs[0].split(',') val = [] for nvalue in nvalues: - if nvalue == 'complexdomain' or nvalue == 'complex' : - val.append(aubio_onset_complex) - elif nvalue == 'hfc' : - val.append(aubio_onset_hfc) - elif nvalue == 'phase' : - val.append(aubio_onset_phase) - elif nvalue == 'specdiff' : - val.append(aubio_onset_specdiff) - elif nvalue == 'energy' : - val.append(aubio_onset_energy) - elif nvalue == 'kl' : - val.append(aubio_onset_kl) - elif nvalue == 'mkl' : - val.append(aubio_onset_mkl) - elif nvalue == 'dual' : - val.append('dual') - else: - import sys - print "unknown onset detection function selected" - sys.exit(1) + val.append(get_onset_mode(nvalue)) setattr(parser.values, option.dest, val) def check_pitch_mode(option, opt, value, parser): -- 2.11.0