Changeset fe163ad
- Timestamp:
- Oct 15, 2009, 6:54:23 PM (15 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:
- 515c7b2
- Parents:
- cd77c15
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/aubionotes.c
rcd77c15 rfe163ad 40 40 aubio_pvoc_do (pv,ibuf, fftgrain); 41 41 aubio_onsetdetection_do(o,fftgrain, onset); 42 if (usedoubled) {43 aubio_onsetdetection_do(o2,fftgrain, onset2);44 onset->data[0][0] *= onset2->data[0][0];45 }46 42 isonset = aubio_peakpicker_do(parms, onset); 47 43 -
examples/aubioonset.c
rcd77c15 rfe163ad 40 40 aubio_pvoc_do (pv,ibuf, fftgrain); 41 41 aubio_onsetdetection_do (o,fftgrain, onset); 42 if (usedoubled) {43 aubio_onsetdetection_do (o2,fftgrain, onset2);44 onset->data[0][0] *= onset2->data[0][0];45 }46 42 isonset = aubio_peakpicker_do(parms, onset); 47 43 if (isonset) { -
examples/utils.c
rcd77c15 rfe163ad 65 65 fvec_t *woodblock; 66 66 aubio_onsetdetection_t *o; 67 aubio_onsetdetection_t *o2;68 67 fvec_t *onset; 69 68 fvec_t *onset2; … … 75 74 smpl_t pitch = 0.; 76 75 aubio_pitchdetection_t *pitchdet; 77 aubio_pitchdetection_type type_pitch = aubio_pitch_yinfft; // aubio_pitch_mcomb 78 aubio_pitchdetection_mode mode_pitch = aubio_pitchm_freq;76 char_t * pitch_unit = "default"; 77 char_t * pitch_mode = "default"; 79 78 uint_t median = 6; 80 79 … … 177 176 break; 178 177 case 'p': 179 if (strcmp (optarg, "mcomb") == 0) 180 type_pitch = aubio_pitch_mcomb; 181 else if (strcmp (optarg, "yinfft") == 0) 182 type_pitch = aubio_pitch_yin; 183 else if (strcmp (optarg, "yin") == 0) 184 type_pitch = aubio_pitch_yin; 185 else if (strcmp (optarg, "schmitt") == 0) 186 type_pitch = aubio_pitch_schmitt; 187 else if (strcmp (optarg, "fcomb") == 0) 188 type_pitch = aubio_pitch_fcomb; 189 else { 190 errmsg ("unknown pitch type.\n"); 191 abort (); 192 } 178 pitch_mode = optarg; 193 179 break; 194 180 case 'a': … … 294 280 295 281 if (usepitch) { 296 pitchdet = new_aubio_pitchdetection ( buffer_size * 4,297 overlap_size, channels, samplerate , type_pitch, mode_pitch);282 pitchdet = new_aubio_pitchdetection (pitch_mode, buffer_size * 4, 283 overlap_size, channels, samplerate); 298 284 aubio_pitchdetection_set_tolerance (pitchdet, 0.7); 299 285 pitch_obuf = new_fvec (1, channels); … … 325 311 } 326 312 del_fvec (pitch_obuf); 327 }328 if (usedoubled) {329 del_aubio_onsetdetection (o2);330 del_fvec (onset2);331 313 } 332 314 del_aubio_onsetdetection (o); -
examples/utils.h
rcd77c15 rfe163ad 108 108 extern smpl_t pitch; 109 109 extern aubio_pitchdetection_t *pitchdet; 110 extern aubio_pitchdetection_type mode;111 110 extern uint_t median; 112 111 -
plugins/puredata/aubiopitch~.c
rcd77c15 rfe163ad 13 13 14 14 char aubiopitch_version[] = "aubiopitch~ version 0.1"; 15 16 aubio_pitchdetection_type type_pitch = aubio_pitch_yinfft;17 aubio_pitchdetection_mode mode_pitch = aubio_pitchm_freq;18 15 19 16 static t_class *aubiopitch_tilde_class; … … 79 76 x->hopsize = x->bufsize / 2; 80 77 81 if (strcmp(s->s_name,"mcomb") == 0)82 type_pitch = aubio_pitch_mcomb;83 else if (strcmp(s->s_name,"yinfft") == 0)84 type_pitch = aubio_pitch_yin;85 else if (strcmp(s->s_name,"yin") == 0)86 type_pitch = aubio_pitch_yin;87 else if (strcmp(s->s_name,"schmitt") == 0)88 type_pitch = aubio_pitch_schmitt;89 else if (strcmp(s->s_name,"fcomb") == 0)90 type_pitch = aubio_pitch_fcomb;91 else {92 post("unknown pitch type, using default.\n");93 }94 95 78 //FIXME: get the real samplerate 96 x->o = new_aubio_pitchdetection(x->bufsize,97 x->hopsize, 1, 44100., type_pitch, mode_pitch);79 x->o = new_aubio_pitchdetection(s->s_name, x->bufsize, 80 x->hopsize, 1, 44100.); 98 81 aubio_pitchdetection_set_tolerance (x->o, 0.7); 99 82 x->vec = (fvec_t *)new_fvec(x->hopsize,1); -
python/aubio/aubioclass.py
rcd77c15 rfe163ad 125 125 126 126 class pitchdetection: 127 def __init__(self,mode= aubio_pitch_mcomb,bufsize=2048,hopsize=1024,128 channels=1,samplerate=44100.,omode= aubio_pitchm_freq,tolerance=0.1):129 self.pitchp = new_aubio_pitchdetection( bufsize,hopsize,channels,130 samplerate,mode,omode)127 def __init__(self,mode="mcomb",bufsize=2048,hopsize=1024, 128 channels=1,samplerate=44100.,omode="freq",tolerance=0.1): 129 self.pitchp = new_aubio_pitchdetection(mode,bufsize,hopsize,channels, 130 samplerate) 131 131 self.mypitch = fvec(1, channels) 132 aubio_pitchdetection_set_unit(self.pitchp,omode) 132 133 aubio_pitchdetection_set_tolerance(self.pitchp,tolerance) 133 134 #self.filt = filter(srate,"adsgn") -
python/aubio/task/params.py
rcd77c15 rfe163ad 1 from aubio.aubioclass import aubio_pitchm_freq2 1 3 2 class taskparams(object): … … 30 29 self.pitchdelay = -0.5 31 30 self.dcthreshold = -1. 32 self.omode = aubio_pitchm_freq31 self.omode = "freq" 33 32 self.verbose = False 34 33 -
python/aubio/task/pitch.py
rcd77c15 rfe163ad 14 14 else: 15 15 tolerance = 0. 16 self.pitchdet = pitchdetection(mode= get_pitch_mode(self.params.pitchmode),16 self.pitchdet = pitchdetection(mode=self.params.pitchmode, 17 17 bufsize=self.params.bufsize, 18 18 hopsize=self.params.hopsize, -
python/aubio/task/utils.py
rcd77c15 rfe163ad 26 26 sys.exit(1) 27 27 28 def get_pitch_mode(nvalue):29 """ utility function to convert a string to aubio_pitchdetection_type """30 if nvalue == 'mcomb' :31 return aubio_pitch_mcomb32 elif nvalue == 'yin' :33 return aubio_pitch_yin34 elif nvalue == 'fcomb' :35 return aubio_pitch_fcomb36 elif nvalue == 'schmitt':37 return aubio_pitch_schmitt38 elif nvalue == 'yinfft':39 return aubio_pitch_yinfft40 else:41 import sys42 print "error: unknown pitch detection function selected"43 sys.exit(1)44 45 28 def check_onset_mode(option, opt, value, parser): 46 29 """ wrapper function to convert a list of modes to … … 59 42 val.append(get_pitch_mode(nvalue)) 60 43 setattr(parser.values, option.dest, val) 61 62 def check_pitchm_mode(option, opt, value, parser):63 """ utility function to convert a string to aubio_pitchdetection_mode """64 nvalue = parser.rargs[0]65 if nvalue == 'freq' :66 setattr(parser.values, option.dest, aubio_pitchm_freq)67 elif nvalue == 'midi' :68 setattr(parser.values, option.dest, aubio_pitchm_midi)69 elif nvalue == 'cent' :70 setattr(parser.values, option.dest, aubio_pitchm_cent)71 elif nvalue == 'bin' :72 setattr(parser.values, option.dest, aubio_pitchm_bin)73 else:74 import sys75 print "error: unknown pitch detection output selected"76 sys.exit(1)77 78 -
python/aubiopitch
rcd77c15 rfe163ad 18 18 help="input sound file") 19 19 parser.add_option("-m","--mode", 20 action="store", dest="mode", default=' mcomb',20 action="store", dest="mode", default='yinfft', 21 21 help="pitch detection mode [default=mcomb] \ 22 22 mcomb|yin|fcomb|schmitt") 23 parser.add_option("-u","--units", action="callback", 24 callback=check_pitchm_mode, dest="omode", 25 default=aubio_pitchm_freq, 23 parser.add_option("-u","--units", 24 action="store", dest="omode", default="freq", 26 25 help="output pitch in units [default=Hz] \ 27 26 freq|midi|cent|bin") … … 78 77 (options, args) = parser.parse_args() 79 78 if not options.bufsize: 80 if options.mode == aubio_pitch_yin: options.bufsize = 102481 if options.mode == aubio_pitch_schmitt: options.bufsize = 204882 if options.mode == aubio_pitch_mcomb: options.bufsize = 409683 if options.mode == aubio_pitch_fcomb: options.bufsize = 409679 if options.mode == "yin": options.bufsize = 1024 80 if options.mode == "schmitt": options.bufsize = 2048 81 if options.mode == "mcomb": options.bufsize = 4096 82 if options.mode == "fcomb": options.bufsize = 4096 84 83 else: options.bufsize = 2048 85 84 if not options.hopsize: … … 106 105 if options.pitchmax: params.pitchmax = int(options.pitchmax) 107 106 if options.pitchmin: params.pitchmin = int(options.pitchmin) 108 if options.omode: params.omode = int(options.omode)109 107 #mintol = float(options.mintol)*step 110 108 # default take back system delay -
src/pitch/pitchdetection.c
rcd77c15 rfe163ad 31 31 #include "pitch/pitchyinfft.h" 32 32 #include "pitch/pitchdetection.h" 33 34 /** pitch detection algorithm */ 35 typedef enum { 36 aubio_pitch_yin, /**< YIN algorithm */ 37 aubio_pitch_mcomb, /**< Multi-comb filter */ 38 aubio_pitch_schmitt, /**< Schmitt trigger */ 39 aubio_pitch_fcomb, /**< Fast comb filter */ 40 aubio_pitch_yinfft, /**< Spectral YIN */ 41 aubio_pitch_default = aubio_pitch_yinfft, /**< the one used when "default" is asked */ 42 } aubio_pitchdetection_type; 43 44 /** pitch detection output mode */ 45 typedef enum { 46 aubio_pitchm_freq, /**< Frequency (Hz) */ 47 aubio_pitchm_midi, /**< MIDI note (0.,127) */ 48 aubio_pitchm_cent, /**< Cent */ 49 aubio_pitchm_bin, /**< Frequency bin (0,bufsize) */ 50 aubio_pitchm_default = aubio_pitchm_freq, /**< the one used when "default" is asked */ 51 } aubio_pitchdetection_mode; 33 52 34 53 typedef void (*aubio_pitchdetection_func_t) … … 81 100 } 82 101 83 aubio_pitchdetection_t * new_aubio_pitchdetection(uint_t bufsize, 84 uint_t hopsize, 85 uint_t channels, 86 uint_t samplerate, 87 aubio_pitchdetection_type type, 88 aubio_pitchdetection_mode mode) 102 aubio_pitchdetection_t * 103 new_aubio_pitchdetection (char_t * pitch_mode, 104 uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate) 89 105 { 90 106 aubio_pitchdetection_t *p = AUBIO_NEW(aubio_pitchdetection_t); 107 aubio_pitchdetection_type pitch_type; 108 if (strcmp (pitch_mode, "mcomb") == 0) 109 pitch_type = aubio_pitch_mcomb; 110 else if (strcmp (pitch_mode, "yinfft") == 0) 111 pitch_type = aubio_pitch_yin; 112 else if (strcmp (pitch_mode, "yin") == 0) 113 pitch_type = aubio_pitch_yin; 114 else if (strcmp (pitch_mode, "schmitt") == 0) 115 pitch_type = aubio_pitch_schmitt; 116 else if (strcmp (pitch_mode, "fcomb") == 0) 117 pitch_type = aubio_pitch_fcomb; 118 else if (strcmp (pitch_mode, "default") == 0) 119 pitch_type = aubio_pitch_default; 120 else { 121 AUBIO_ERR ("unknown pitch detection method %s, using default.\n", pitch_mode); 122 pitch_type = aubio_pitch_default; 123 return NULL; 124 } 91 125 p->srate = samplerate; 92 p->type = type;93 p->mode = mode;126 p->type = pitch_type; 127 aubio_pitchdetection_set_unit (p, "default"); 94 128 p->bufsize = bufsize; 95 129 switch(p->type) { … … 126 160 break; 127 161 } 128 switch(p->mode) {129 case aubio_pitchm_freq:130 p->freqconv = freqconvpass;131 break;132 case aubio_pitchm_midi:133 p->freqconv = freqconvmidi;134 break;135 case aubio_pitchm_cent:136 /* bug: not implemented */137 p->freqconv = freqconvmidi;138 break;139 case aubio_pitchm_bin:140 p->freqconv = freqconvbin;141 break;142 default:143 break;144 }145 162 return p; 146 163 } … … 189 206 } 190 207 } 208 } 209 210 uint_t aubio_pitchdetection_set_unit (aubio_pitchdetection_t *p, char_t * pitch_unit) { 211 aubio_pitchdetection_mode pitch_mode; 212 if (strcmp (pitch_unit, "freq") == 0) 213 pitch_mode = aubio_pitchm_freq; 214 else if (strcmp (pitch_unit, "midi") == 0) 215 pitch_mode = aubio_pitchm_midi; 216 else if (strcmp (pitch_unit, "cent") == 0) 217 pitch_mode = aubio_pitchm_cent; 218 else if (strcmp (pitch_unit, "bin") == 0) 219 pitch_mode = aubio_pitchm_bin; 220 else if (strcmp (pitch_unit, "default") == 0) 221 pitch_mode = aubio_pitchm_default; 222 else { 223 AUBIO_ERR ("unknown pitch detection unit %s, using default\n", pitch_unit); 224 pitch_mode = aubio_pitchm_default; 225 } 226 p->mode = pitch_mode; 227 switch(p->mode) { 228 case aubio_pitchm_freq: 229 p->freqconv = freqconvpass; 230 break; 231 case aubio_pitchm_midi: 232 p->freqconv = freqconvmidi; 233 break; 234 case aubio_pitchm_cent: 235 /* bug: not implemented */ 236 p->freqconv = freqconvmidi; 237 break; 238 case aubio_pitchm_bin: 239 p->freqconv = freqconvbin; 240 break; 241 default: 242 break; 243 } 244 return 0; 191 245 } 192 246 -
src/pitch/pitchdetection.h
rcd77c15 rfe163ad 32 32 33 33 */ 34 35 /** pitch detection algorithm */36 typedef enum {37 aubio_pitch_yin, /**< YIN algorithm */38 aubio_pitch_mcomb, /**< Multi-comb filter */39 aubio_pitch_schmitt, /**< Schmitt trigger */40 aubio_pitch_fcomb, /**< Fast comb filter */41 aubio_pitch_yinfft /**< Spectral YIN */42 } aubio_pitchdetection_type;43 44 /** pitch detection output mode */45 typedef enum {46 aubio_pitchm_freq, /**< Frequency (Hz) */47 aubio_pitchm_midi, /**< MIDI note (0.,127) */48 aubio_pitchm_cent, /**< Cent */49 aubio_pitchm_bin /**< Frequency bin (0,bufsize) */50 } aubio_pitchdetection_mode;51 34 52 35 /** pitch detection object */ … … 85 68 86 69 */ 87 aubio_pitchdetection_t * new_aubio_pitchdetection(uint_t bufsize, 88 uint_t hopsize, 89 uint_t channels, 90 uint_t samplerate, 91 aubio_pitchdetection_type pitch_type, 92 aubio_pitchdetection_mode pitch_mode); 70 aubio_pitchdetection_t *new_aubio_pitchdetection (char_t * pitch_mode, 71 uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate); 72 73 /** set the output unit of the pitch detection object */ 74 uint_t aubio_pitchdetection_set_unit (aubio_pitchdetection_t *p, char_t * pitch_unit); 93 75 94 76 #ifdef __cplusplus -
swig/aubio.i
rcd77c15 rfe163ad 199 199 200 200 /* pitch detection */ 201 typedef enum { 202 aubio_pitch_yin, 203 aubio_pitch_mcomb, 204 aubio_pitch_schmitt, 205 aubio_pitch_fcomb, 206 aubio_pitch_yinfft 207 } aubio_pitchdetection_type; 208 209 typedef enum { 210 aubio_pitchm_freq, 211 aubio_pitchm_midi, 212 aubio_pitchm_cent, 213 aubio_pitchm_bin 214 } aubio_pitchdetection_mode; 215 201 aubio_pitchdetection_t *new_aubio_pitchdetection (char *pitch_mode, 202 uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate); 216 203 void aubio_pitchdetection_do (aubio_pitchdetection_t * p, fvec_t * ibuf, fvec_t * obuf); 217 218 204 void aubio_pitchdetection_set_tolerance(aubio_pitchdetection_t *p, smpl_t thres); 219 205 void aubio_pitchdetection_set_unit(aubio_pitchdetection_t *p, char * pitch_unit); 220 206 void del_aubio_pitchdetection(aubio_pitchdetection_t * p); 221 222 aubio_pitchdetection_t * new_aubio_pitchdetection(uint_t bufsize,223 uint_t hopsize,224 uint_t channels,225 uint_t samplerate,226 aubio_pitchdetection_type type,227 aubio_pitchdetection_mode mode);228 207 229 208 -
tests/src/test-pitchdetection.c
rcd77c15 rfe163ad 1 1 #include <aubio.h> 2 2 3 int main(){ 4 /* allocate some memory */ 5 uint_t win_s = 1024; /* window size */ 6 uint_t hop_s = win_s/4; /* hop size */ 7 uint_t samplerate = 44100; /* samplerate */ 8 uint_t channels = 1; /* number of channel */ 9 aubio_pitchdetection_mode mode = aubio_pitchm_freq; 10 aubio_pitchdetection_type type = aubio_pitch_yinfft; 11 fvec_t * in = new_fvec (hop_s, channels); /* input buffer */ 12 fvec_t * out = new_fvec (1, channels); /* input buffer */ 13 aubio_pitchdetection_t * o = new_aubio_pitchdetection( 14 win_s, hop_s, channels, samplerate, type, mode 15 ); 16 uint_t i = 0; 3 int 4 main () 5 { 6 /* allocate some memory */ 7 uint_t win_s = 1024; /* window size */ 8 uint_t hop_s = win_s / 4; /* hop size */ 9 uint_t samplerate = 44100; /* samplerate */ 10 uint_t channels = 1; /* number of channel */ 11 fvec_t *in = new_fvec (hop_s, channels); /* input buffer */ 12 fvec_t *out = new_fvec (1, channels); /* input buffer */ 13 aubio_pitchdetection_t *o = 14 new_aubio_pitchdetection ("default", win_s, hop_s, channels, samplerate); 15 uint_t i = 0; 17 16 18 19 aubio_pitchdetection_do (o,in, out);20 21 17 while (i < 100) { 18 aubio_pitchdetection_do (o, in, out); 19 i++; 20 }; 22 21 23 del_aubio_pitchdetection(o);24 del_fvec(in);25 aubio_cleanup();22 del_aubio_pitchdetection (o); 23 del_fvec (in); 24 aubio_cleanup (); 26 25 27 26 return 0; 28 27 }
Note: See TracChangeset
for help on using the changeset viewer.