source: python/aubio/task/utils.py @ 650e39b

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 650e39b was 650e39b, checked in by Paul Brossier <piem@altern.org>, 18 years ago

add yinfft method, make it default for pd plugin
add yinfft method, make it default for pd plugin

  • Property mode set to 100644
File size: 2.3 KB
Line 
1from aubio.aubioclass import *
2
3def 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
26def 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        elif nvalue == 'yinfft':
37                 return aubio_pitch_yinfft
38        else:
39                 import sys
40                 print "error: unknown pitch detection function selected"
41                 sys.exit(1)
42
43def 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
52def 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
60def 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
Note: See TracBrowser for help on using the repository browser.