[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 |
---|
| 36 | else: |
---|
| 37 | import sys |
---|
| 38 | print "error: unknown pitch detection function selected" |
---|
| 39 | sys.exit(1) |
---|
| 40 | |
---|
| 41 | def check_onset_mode(option, opt, value, parser): |
---|
| 42 | """ wrapper function to convert a list of modes to |
---|
| 43 | aubio_onsetdetection_type """ |
---|
| 44 | nvalues = parser.rargs[0].split(',') |
---|
| 45 | val = [] |
---|
| 46 | for nvalue in nvalues: |
---|
| 47 | val.append(get_onset_mode(nvalue)) |
---|
| 48 | setattr(parser.values, option.dest, val) |
---|
| 49 | |
---|
| 50 | def check_pitch_mode(option, opt, value, parser): |
---|
| 51 | """ utility function to convert a string to aubio_pitchdetection_type""" |
---|
| 52 | nvalues = parser.rargs[0].split(',') |
---|
| 53 | val = [] |
---|
| 54 | for nvalue in nvalues: |
---|
| 55 | val.append(get_pitch_mode(nvalue)) |
---|
| 56 | setattr(parser.values, option.dest, val) |
---|
| 57 | |
---|
| 58 | def check_pitchm_mode(option, opt, value, parser): |
---|
| 59 | """ utility function to convert a string to aubio_pitchdetection_mode """ |
---|
| 60 | nvalue = parser.rargs[0] |
---|
| 61 | if nvalue == 'freq' : |
---|
| 62 | setattr(parser.values, option.dest, aubio_pitchm_freq) |
---|
| 63 | elif nvalue == 'midi' : |
---|
| 64 | setattr(parser.values, option.dest, aubio_pitchm_midi) |
---|
| 65 | elif nvalue == 'cent' : |
---|
| 66 | setattr(parser.values, option.dest, aubio_pitchm_cent) |
---|
| 67 | elif nvalue == 'bin' : |
---|
| 68 | setattr(parser.values, option.dest, aubio_pitchm_bin) |
---|
| 69 | else: |
---|
| 70 | import sys |
---|
| 71 | print "error: unknown pitch detection output selected" |
---|
| 72 | sys.exit(1) |
---|
| 73 | |
---|
| 74 | |
---|