Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -1,30 +1,35 @@ | |||
| 1 | from aubioclass import * | 1 | from aubioclass import * |
| 2 | 2 | ||
| 3 | def check_onset_mode(option, opt, value, parser): | 3 | def get_onset_mode(nvalue): |
| 4 | """ utility function to convert a string to aubio_onsetdetection_type """ | 4 | """ utility function to convert a string to aubio_onsetdetection_type """ |
| 5 | if nvalue == 'complexdomain' or nvalue == 'complex' : | ||
| 6 | return aubio_onset_complex | ||
| 7 | elif nvalue == 'hfc' : | ||
| 8 | return aubio_onset_hfc | ||
| 9 | elif nvalue == 'phase' : | ||
| 10 | return aubio_onset_phase | ||
| 11 | elif nvalue == 'specdiff' : | ||
| 12 | return aubio_onset_specdiff | ||
| 13 | elif nvalue == 'energy' : | ||
| 14 | return aubio_onset_energy | ||
| 15 | elif nvalue == 'kl' : | ||
| 16 | return aubio_onset_kl | ||
| 17 | elif nvalue == 'mkl' : | ||
| 18 | return aubio_onset_mkl | ||
| 19 | elif nvalue == 'dual' : | ||
| 20 | return 'dual' | ||
| 21 | else: | ||
| 22 | import sys | ||
| 23 | print "unknown onset detection function selected" | ||
| 24 | sys.exit(1) | ||
| 25 | |||
| 26 | def check_onset_mode(option, opt, value, parser): | ||
| 27 | """ wrapper function to convert a list of modes to | ||
| 28 | aubio_onsetdetection_type """ | ||
| 5 | nvalues = parser.rargs[0].split(',') | 29 | nvalues = parser.rargs[0].split(',') |
| 6 | val = [] | 30 | val = [] |
| 7 | for nvalue in nvalues: | 31 | for nvalue in nvalues: |
| 8 | if nvalue == 'complexdomain' or nvalue == 'complex' : | 32 | val.append(get_onset_mode(nvalue)) |
| 9 | val.append(aubio_onset_complex) | ||
| 10 | elif nvalue == 'hfc' : | ||
| 11 | val.append(aubio_onset_hfc) | ||
| 12 | elif nvalue == 'phase' : | ||
| 13 | val.append(aubio_onset_phase) | ||
| 14 | elif nvalue == 'specdiff' : | ||
| 15 | val.append(aubio_onset_specdiff) | ||
| 16 | elif nvalue == 'energy' : | ||
| 17 | val.append(aubio_onset_energy) | ||
| 18 | elif nvalue == 'kl' : | ||
| 19 | val.append(aubio_onset_kl) | ||
| 20 | elif nvalue == 'mkl' : | ||
| 21 | val.append(aubio_onset_mkl) | ||
| 22 | elif nvalue == 'dual' : | ||
| 23 | val.append('dual') | ||
| 24 | else: | ||
| 25 | import sys | ||
| 26 | print "unknown onset detection function selected" | ||
| 27 | sys.exit(1) | ||
| 28 | setattr(parser.values, option.dest, val) | 33 | setattr(parser.values, option.dest, val) |
| 29 | 34 | ||
| 30 | def check_pitch_mode(option, opt, value, parser): | 35 | def check_pitch_mode(option, opt, value, parser): |