[13c3fba] | 1 | from aubio.aubioclass import * |
---|
| 2 | |
---|
| 3 | def get_onset_mode(nvalue): |
---|
| 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 get_pitch_mode(nvalue): |
---|
| 27 | """ utility function to convert a string to aubio_pitchdetection_type """ |
---|
| 28 | if nvalue == 'mcomb' : |
---|
| 29 | return aubio_pitch_mcomb |
---|
| 30 | elif nvalue == 'yin' : |
---|
| 31 | return aubio_pitch_yin |
---|
| 32 | elif nvalue == 'fcomb' : |
---|
| 33 | return aubio_pitch_fcomb |
---|
| 34 | elif nvalue == 'schmitt': |
---|
| 35 | return aubio_pitch_schmitt |
---|
[650e39b] | 36 | elif nvalue == 'yinfft': |
---|
| 37 | return aubio_pitch_yinfft |
---|
[13c3fba] | 38 | else: |
---|
| 39 | import sys |
---|
| 40 | print "error: unknown pitch detection function selected" |
---|
| 41 | sys.exit(1) |
---|
| 42 | |
---|
| 43 | def check_onset_mode(option, opt, value, parser): |
---|
| 44 | """ wrapper function to convert a list of modes to |
---|
| 45 | aubio_onsetdetection_type """ |
---|
| 46 | nvalues = parser.rargs[0].split(',') |
---|
| 47 | val = [] |
---|
| 48 | for nvalue in nvalues: |
---|
| 49 | val.append(get_onset_mode(nvalue)) |
---|
| 50 | setattr(parser.values, option.dest, val) |
---|
| 51 | |
---|
| 52 | def check_pitch_mode(option, opt, value, parser): |
---|
| 53 | """ utility function to convert a string to aubio_pitchdetection_type""" |
---|
| 54 | nvalues = parser.rargs[0].split(',') |
---|
| 55 | val = [] |
---|
| 56 | for nvalue in nvalues: |
---|
| 57 | val.append(get_pitch_mode(nvalue)) |
---|
| 58 | setattr(parser.values, option.dest, val) |
---|
| 59 | |
---|
| 60 | def check_pitchm_mode(option, opt, value, parser): |
---|
| 61 | """ utility function to convert a string to aubio_pitchdetection_mode """ |
---|
| 62 | nvalue = parser.rargs[0] |
---|
| 63 | if nvalue == 'freq' : |
---|
| 64 | setattr(parser.values, option.dest, aubio_pitchm_freq) |
---|
| 65 | elif nvalue == 'midi' : |
---|
| 66 | setattr(parser.values, option.dest, aubio_pitchm_midi) |
---|
| 67 | elif nvalue == 'cent' : |
---|
| 68 | setattr(parser.values, option.dest, aubio_pitchm_cent) |
---|
| 69 | elif nvalue == 'bin' : |
---|
| 70 | setattr(parser.values, option.dest, aubio_pitchm_bin) |
---|
| 71 | else: |
---|
| 72 | import sys |
---|
| 73 | print "error: unknown pitch detection output selected" |
---|
| 74 | sys.exit(1) |
---|
| 75 | |
---|
| 76 | |
---|