Changeset aa17581
- Timestamp:
- Aug 22, 2005, 9:52:17 PM (19 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- c29dae2
- Parents:
- f97445c
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
python/aubio/aubioclass.py
rf97445c raa17581 125 125 setattr(parser.values, option.dest, 'dual') 126 126 else: 127 print "unknown detection function selected\n", usage127 print "unknown onset detection function selected" 128 128 sys.exit(1) 129 129 130 130 def check_pitch_mode(option, opt, value, parser): 131 131 nvalue = parser.rargs[0] 132 if nvalue == 'mcomb' :132 if nvalue == 'mcomb' : 133 133 setattr(parser.values, option.dest, aubio_pitch_mcomb) 134 elif nvalue == 'yin' 134 elif nvalue == 'yin' : 135 135 setattr(parser.values, option.dest, aubio_pitch_yin) 136 elif nvalue == 'fcomb' 136 elif nvalue == 'fcomb' : 137 137 setattr(parser.values, option.dest, aubio_pitch_fcomb) 138 elif nvalue == 'schmitt' 138 elif nvalue == 'schmitt': 139 139 setattr(parser.values, option.dest, aubio_pitch_schmitt) 140 140 else: 141 print "unknown detection function selected\n", usage 141 print "error: unknown pitch detection function selected" 142 sys.exit(1) 143 144 def check_pitchm_mode(option, opt, value, parser): 145 nvalue = parser.rargs[0] 146 if nvalue == 'freq' : 147 setattr(parser.values, option.dest, aubio_pitchm_freq) 148 elif nvalue == 'midi' : 149 setattr(parser.values, option.dest, aubio_pitchm_midi) 150 elif nvalue == 'cent' : 151 setattr(parser.values, option.dest, aubio_pitchm_cent) 152 elif nvalue == 'bin' : 153 setattr(parser.values, option.dest, aubio_pitchm_bin) 154 else: 155 print "error: unknown pitch detection output selected" 142 156 sys.exit(1) 143 157 … … 192 206 framestep = hopsize/(filei.samplerate()+0.) 193 207 channels = filei.channels() 194 newname = "%s%s% f%s%s" % (filein.split(".")[0].split("/")[-1],".",208 newname = "%s%s%09.5f%s%s" % (filein.split(".")[0].split("/")[-1],".", 195 209 frameread*framestep,".",filein.split(".")[-1]) 196 210 fileo = sndfile(newname,model=filei) … … 214 228 zerocross += 1 215 229 del fileo 216 fileo = sndfile("%s%s% f%s%s" %230 fileo = sndfile("%s%s%09.5f%s%s" % 217 231 (filein.split(".")[0].split("/")[-1],".", 218 232 frameread*framestep,".",filein.split(".")[-1]),model=filei) … … 261 275 mylist.append(freq) 262 276 else: 263 mylist.append( 0)277 mylist.append(-1.) 264 278 frameread += 1 265 279 return mylist -
python/aubiopitch
rf97445c raa17581 23 23 help="pitch detection mode [default=mcomb] \ 24 24 mcomb|yin|fcomb|schmitt") 25 parser.add_option("-u","--units", action="callback", 26 callback=check_pitchm_mode, dest="omode", 27 default=aubio_pitchm_freq, 28 help="output pitch in units [default=Hz] \ 29 freq|midi|cent|bin") 25 30 parser.add_option("-B","--bufsize", 26 action="store", dest="bufsize", default= 1024,31 action="store", dest="bufsize", default=None, 27 32 help="buffer size [default=1024]") 28 33 parser.add_option("-H","--hopsize", 29 action="store", dest="hopsize", default= 512,34 action="store", dest="hopsize", default=None, 30 35 help="overlap size [default=512]") 31 36 parser.add_option("-t","--threshold", … … 64 69 help="be quiet") 65 70 (options, args) = parser.parse_args() 71 if not options.bufsize: 72 if options.mode == aubio_pitch_yin: options.bufsize = 1024 73 if options.mode == aubio_pitch_schmitt: options.bufsize = 2048 74 if options.mode == aubio_pitch_mcomb: options.bufsize = 4096 75 if options.mode == aubio_pitch_fcomb: options.bufsize = 4096 76 if not options.hopsize: 77 options.hopsize = float(options.bufsize) / 2 66 78 if not options.filename: 67 68 79 print "no file name given\n", usage 80 sys.exit(1) 69 81 return options, args 70 82 71 83 options, args = parse_args() 84 85 #print options.bufsize, options.hopsize 72 86 73 87 filename = options.filename … … 86 100 exit("not implemented yet") 87 101 else: 88 pitch = getpitch(filename, #threshold, silence,102 pitch = getpitch(filename, #threshold, 89 103 mode=options.mode, 90 bufsize=bufsize,hopsize=hopsize) 104 omode=options.omode, 105 bufsize=bufsize,hopsize=hopsize, 106 silence=silence) 91 107 92 108 ## take back system delay -
src/pitchdetection.c
rf97445c raa17581 28 28 #include "pitchdetection.h" 29 29 30 smpl_t freqconvpass(smpl_t f); 31 smpl_t freqconvpass(smpl_t f){ 32 return f; 33 } 34 30 35 typedef smpl_t (*aubio_pitchdetection_func_t)(aubio_pitchdetection_t *p, 31 36 fvec_t * ibuf); 37 typedef smpl_t (*aubio_pitchdetection_conv_t)(smpl_t value); 32 38 void aubio_pitchdetection_slideblock(aubio_pitchdetection_t *p, fvec_t *ibuf); 33 39 … … 48 54 fvec_t * yin; 49 55 aubio_pitchdetection_func_t callback; 56 aubio_pitchdetection_conv_t freqconv; 50 57 }; 51 58 … … 60 67 p->srate = samplerate; 61 68 p->type = type; 69 p->mode = mode; 62 70 p->bufsize = bufsize; 63 71 switch(p->type) { … … 86 94 break; 87 95 } 96 switch(p->mode) { 97 case aubio_pitchm_freq: 98 p->freqconv = freqconvpass; 99 break; 100 case aubio_pitchm_midi: 101 p->freqconv = aubio_freqtomidi; 102 break; 103 case aubio_pitchm_cent: 104 /** bug: not implemented */ 105 p->freqconv = freqconvpass; 106 break; 107 case aubio_pitchm_bin: 108 /** bug: not implemented */ 109 p->freqconv = freqconvpass; 110 break; 111 default: 112 break; 113 } 88 114 return p; 89 115 } … … 132 158 133 159 smpl_t aubio_pitchdetection(aubio_pitchdetection_t *p, fvec_t * ibuf) { 134 return p-> callback(p,ibuf);160 return p->freqconv(p->callback(p,ibuf)); 135 161 } 136 162
Note: See TracChangeset
for help on using the changeset viewer.