Changeset ca1abdd
- Timestamp:
- Oct 19, 2009, 10:51:59 AM (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:
- b14107f
- Parents:
- 9f07d52
- Files:
-
- 10 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
plugins/puredata/aubiopitch~.c
r9f07d52 rca1abdd 26 26 t_int bufsize; 27 27 t_int hopsize; 28 aubio_pitch detection_t *o;28 aubio_pitch_t *o; 29 29 fvec_t *vec; 30 30 fvec_t *pitchvec; … … 44 44 if (x->pos == x->hopsize-1) { 45 45 /* block loop */ 46 aubio_pitch detection_do(x->o,x->vec, x->pitchvec);46 aubio_pitch_do(x->o,x->vec, x->pitchvec); 47 47 outlet_float(x->pitch, x->pitchvec->data[0][0]); 48 48 /* end of block loop */ … … 77 77 78 78 //FIXME: get the real samplerate 79 x->o = new_aubio_pitch detection(s->s_name, x->bufsize,79 x->o = new_aubio_pitch(s->s_name, x->bufsize, 80 80 x->hopsize, 1, 44100.); 81 aubio_pitch detection_set_tolerance (x->o, 0.7);81 aubio_pitch_set_tolerance (x->o, 0.7); 82 82 x->vec = (fvec_t *)new_fvec(x->hopsize,1); 83 83 x->pitchvec = (fvec_t *)new_fvec(1,1); … … 92 92 static void *aubiopitch_tilde_del(t_aubiopitch_tilde *x) 93 93 { 94 del_aubio_pitch detection(x->o);94 del_aubio_pitch(x->o); 95 95 del_fvec(x->vec); 96 96 del_fvec(x->pitchvec); -
python/aubio/aubioclass.py
r9f07d52 rca1abdd 127 127 return isonset, dval 128 128 129 class pitch detection:129 class pitch: 130 130 def __init__(self,mode="mcomb",bufsize=2048,hopsize=1024, 131 131 channels=1,samplerate=44100.,omode="freq",tolerance=0.1): 132 self.pitchp = new_aubio_pitch detection(mode,bufsize,hopsize,channels,132 self.pitchp = new_aubio_pitch(mode,bufsize,hopsize,channels, 133 133 samplerate) 134 134 self.mypitch = fvec(1, channels) 135 aubio_pitch detection_set_unit(self.pitchp,omode)136 aubio_pitch detection_set_tolerance(self.pitchp,tolerance)135 aubio_pitch_set_unit(self.pitchp,omode) 136 aubio_pitch_set_tolerance(self.pitchp,tolerance) 137 137 #self.filt = filter(srate,"adsgn") 138 138 def __del__(self): 139 del_aubio_pitch detection(self.pitchp)139 del_aubio_pitch(self.pitchp) 140 140 def __call__(self,myvec): 141 aubio_pitch detection_do(self.pitchp,myvec(), self.mypitch())141 aubio_pitch_do(self.pitchp,myvec(), self.mypitch()) 142 142 return self.mypitch.get(0,0) 143 143 -
python/aubio/task/notes.py
r9f07d52 rca1abdd 14 14 dcthreshold=self.params.dcthreshold, 15 15 derivate=self.params.derivate) 16 self.pitchdet = pitch detection(mode=self.params.pitchmode,16 self.pitchdet = pitch(mode=self.params.pitchmode, 17 17 bufsize=self.params.pbufsize, 18 18 hopsize=self.params.phopsize, -
python/aubio/task/pitch.py
r9f07d52 rca1abdd 13 13 else: 14 14 tolerance = 0. 15 self.pitchdet = pitch detection(mode=self.params.pitchmode,15 self.pitchdet = pitch(mode=self.params.pitchmode, 16 16 bufsize=self.params.bufsize, 17 17 hopsize=self.params.hopsize, -
src/Makefile.am
r9f07d52 rca1abdd 24 24 spectral/tss.h \ 25 25 spectral/spectral_centroid.h \ 26 pitch/pitch detection.h \26 pitch/pitch.h \ 27 27 pitch/pitchmcomb.h \ 28 28 pitch/pitchyin.h \ … … 59 59 spectral/tss.c \ 60 60 spectral/spectral_centroid.c \ 61 pitch/pitch detection.c \61 pitch/pitch.c \ 62 62 pitch/pitchmcomb.c \ 63 63 pitch/pitchyin.c \ -
src/aubio.h
r9f07d52 rca1abdd 82 82 #include "spectral/phasevoc.h" 83 83 #include "spectral/spectral_centroid.h" 84 #include "pitch/pitch detection.h"84 #include "pitch/pitch.h" 85 85 #include "pitch/pitchmcomb.h" 86 86 #include "pitch/pitchyin.h" -
src/pitch/pitch.c
r9f07d52 rca1abdd 30 30 #include "pitch/pitchschmitt.h" 31 31 #include "pitch/pitchyinfft.h" 32 #include "pitch/pitch detection.h"32 #include "pitch/pitch.h" 33 33 34 34 /** pitch detection algorithm */ 35 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_pitch detection_type;36 aubio_pitcht_yin, /**< YIN algorithm */ 37 aubio_pitcht_mcomb, /**< Multi-comb filter */ 38 aubio_pitcht_schmitt, /**< Schmitt trigger */ 39 aubio_pitcht_fcomb, /**< Fast comb filter */ 40 aubio_pitcht_yinfft, /**< Spectral YIN */ 41 aubio_pitcht_default = aubio_pitcht_yinfft, /**< the one used when "default" is asked */ 42 } aubio_pitch_type; 43 43 44 44 /** pitch detection output mode */ … … 49 49 aubio_pitchm_bin, /**< Frequency bin (0,bufsize) */ 50 50 aubio_pitchm_default = aubio_pitchm_freq, /**< the one used when "default" is asked */ 51 } aubio_pitch detection_mode;52 53 typedef void (*aubio_pitch detection_func_t)54 (aubio_pitch detection_t *p, fvec_t * ibuf, fvec_t *obuf);55 typedef smpl_t (*aubio_pitch detection_conv_t)51 } aubio_pitch_mode; 52 53 typedef void (*aubio_pitch_func_t) 54 (aubio_pitch_t *p, fvec_t * ibuf, fvec_t *obuf); 55 typedef smpl_t (*aubio_pitch_conv_t) 56 56 (smpl_t value, uint_t srate, uint_t bufsize); 57 57 58 void aubio_pitch detection_slideblock(aubio_pitchdetection_t *p, fvec_t *ibuf);59 60 void aubio_pitch detection_mcomb (aubio_pitchdetection_t *p, fvec_t *ibuf, fvec_t *obuf);61 void aubio_pitch detection_yin (aubio_pitchdetection_t *p, fvec_t *ibuf, fvec_t *obuf);62 void aubio_pitch detection_schmitt (aubio_pitchdetection_t *p, fvec_t *ibuf, fvec_t *obuf);63 void aubio_pitch detection_fcomb (aubio_pitchdetection_t *p, fvec_t *ibuf, fvec_t *obuf);64 void aubio_pitch detection_yinfft (aubio_pitchdetection_t *p, fvec_t *ibuf, fvec_t *obuf);58 void aubio_pitch_slideblock(aubio_pitch_t *p, fvec_t *ibuf); 59 60 void aubio_pitch_do_mcomb (aubio_pitch_t *p, fvec_t *ibuf, fvec_t *obuf); 61 void aubio_pitch_do_yin (aubio_pitch_t *p, fvec_t *ibuf, fvec_t *obuf); 62 void aubio_pitch_do_schmitt (aubio_pitch_t *p, fvec_t *ibuf, fvec_t *obuf); 63 void aubio_pitch_do_fcomb (aubio_pitch_t *p, fvec_t *ibuf, fvec_t *obuf); 64 void aubio_pitch_do_yinfft (aubio_pitch_t *p, fvec_t *ibuf, fvec_t *obuf); 65 65 66 66 /** generic pitch detection structure */ 67 struct _aubio_pitch detection_t {68 aubio_pitch detection_type type; /**< pitch detection mode */69 aubio_pitch detection_mode mode; /**< pitch detection output mode */67 struct _aubio_pitch_t { 68 aubio_pitch_type type; /**< pitch detection mode */ 69 aubio_pitch_mode mode; /**< pitch detection output mode */ 70 70 uint_t srate; /**< samplerate */ 71 71 uint_t bufsize; /**< buffer size */ … … 79 79 cvec_t * fftgrain; /**< spectral frame for mcomb */ 80 80 fvec_t * buf; /**< temporary buffer for yin */ 81 aubio_pitch detection_func_t callback; /**< pointer to current pitch detection method */82 aubio_pitch detection_conv_t freqconv; /**< pointer to current pitch conversion method */81 aubio_pitch_func_t callback; /**< pointer to current pitch detection method */ 82 aubio_pitch_conv_t freqconv; /**< pointer to current pitch conversion method */ 83 83 }; 84 84 … … 100 100 } 101 101 102 aubio_pitch detection_t *103 new_aubio_pitch detection(char_t * pitch_mode,102 aubio_pitch_t * 103 new_aubio_pitch (char_t * pitch_mode, 104 104 uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate) 105 105 { 106 aubio_pitch detection_t *p = AUBIO_NEW(aubio_pitchdetection_t);107 aubio_pitch detection_type pitch_type;106 aubio_pitch_t *p = AUBIO_NEW(aubio_pitch_t); 107 aubio_pitch_type pitch_type; 108 108 if (strcmp (pitch_mode, "mcomb") == 0) 109 pitch_type = aubio_pitch _mcomb;109 pitch_type = aubio_pitcht_mcomb; 110 110 else if (strcmp (pitch_mode, "yinfft") == 0) 111 pitch_type = aubio_pitch _yin;111 pitch_type = aubio_pitcht_yin; 112 112 else if (strcmp (pitch_mode, "yin") == 0) 113 pitch_type = aubio_pitch _yin;113 pitch_type = aubio_pitcht_yin; 114 114 else if (strcmp (pitch_mode, "schmitt") == 0) 115 pitch_type = aubio_pitch _schmitt;115 pitch_type = aubio_pitcht_schmitt; 116 116 else if (strcmp (pitch_mode, "fcomb") == 0) 117 pitch_type = aubio_pitch _fcomb;117 pitch_type = aubio_pitcht_fcomb; 118 118 else if (strcmp (pitch_mode, "default") == 0) 119 pitch_type = aubio_pitch _default;119 pitch_type = aubio_pitcht_default; 120 120 else { 121 121 AUBIO_ERR ("unknown pitch detection method %s, using default.\n", pitch_mode); 122 pitch_type = aubio_pitch _default;122 pitch_type = aubio_pitcht_default; 123 123 return NULL; 124 124 } 125 125 p->srate = samplerate; 126 126 p->type = pitch_type; 127 aubio_pitch detection_set_unit (p, "default");127 aubio_pitch_set_unit (p, "default"); 128 128 p->bufsize = bufsize; 129 129 switch(p->type) { 130 case aubio_pitch _yin:130 case aubio_pitcht_yin: 131 131 p->buf = new_fvec(bufsize,channels); 132 132 p->yin = new_aubio_pitchyin(bufsize); 133 p->callback = aubio_pitch detection_yin;133 p->callback = aubio_pitch_do_yin; 134 134 aubio_pitchyin_set_tolerance (p->yin, 0.15); 135 135 break; 136 case aubio_pitch _mcomb:136 case aubio_pitcht_mcomb: 137 137 p->pv = new_aubio_pvoc(bufsize, hopsize, channels); 138 138 p->fftgrain = new_cvec(bufsize, channels); 139 139 p->mcomb = new_aubio_pitchmcomb(bufsize,hopsize,channels); 140 140 p->filter = new_aubio_filter_c_weighting (samplerate, channels); 141 p->callback = aubio_pitch detection_mcomb;142 break; 143 case aubio_pitch _fcomb:141 p->callback = aubio_pitch_do_mcomb; 142 break; 143 case aubio_pitcht_fcomb: 144 144 p->buf = new_fvec(bufsize,channels); 145 145 p->fcomb = new_aubio_pitchfcomb(bufsize,hopsize,channels); 146 p->callback = aubio_pitch detection_fcomb;147 break; 148 case aubio_pitch _schmitt:146 p->callback = aubio_pitch_do_fcomb; 147 break; 148 case aubio_pitcht_schmitt: 149 149 p->buf = new_fvec(bufsize,channels); 150 150 p->schmitt = new_aubio_pitchschmitt(bufsize); 151 p->callback = aubio_pitch detection_schmitt;152 break; 153 case aubio_pitch _yinfft:151 p->callback = aubio_pitch_do_schmitt; 152 break; 153 case aubio_pitcht_yinfft: 154 154 p->buf = new_fvec(bufsize,channels); 155 155 p->yinfft = new_aubio_pitchyinfft(bufsize); 156 p->callback = aubio_pitch detection_yinfft;156 p->callback = aubio_pitch_do_yinfft; 157 157 aubio_pitchyinfft_set_tolerance (p->yinfft, 0.85); 158 158 break; … … 163 163 } 164 164 165 void del_aubio_pitch detection(aubio_pitchdetection_t * p) {165 void del_aubio_pitch(aubio_pitch_t * p) { 166 166 switch(p->type) { 167 case aubio_pitch _yin:167 case aubio_pitcht_yin: 168 168 del_fvec(p->buf); 169 169 del_aubio_pitchyin(p->yin); 170 170 break; 171 case aubio_pitch _mcomb:171 case aubio_pitcht_mcomb: 172 172 del_aubio_pvoc(p->pv); 173 173 del_cvec(p->fftgrain); … … 175 175 del_aubio_pitchmcomb(p->mcomb); 176 176 break; 177 case aubio_pitch _schmitt:177 case aubio_pitcht_schmitt: 178 178 del_fvec(p->buf); 179 179 del_aubio_pitchschmitt(p->schmitt); 180 180 break; 181 case aubio_pitch _fcomb:181 case aubio_pitcht_fcomb: 182 182 del_fvec(p->buf); 183 183 del_aubio_pitchfcomb(p->fcomb); 184 184 break; 185 case aubio_pitch _yinfft:185 case aubio_pitcht_yinfft: 186 186 del_fvec(p->buf); 187 187 del_aubio_pitchyinfft(p->yinfft); … … 193 193 } 194 194 195 void aubio_pitch detection_slideblock(aubio_pitchdetection_t *p, fvec_t *ibuf){195 void aubio_pitch_slideblock(aubio_pitch_t *p, fvec_t *ibuf){ 196 196 uint_t i,j = 0, overlap_size = 0; 197 197 overlap_size = p->buf->length-ibuf->length; … … 208 208 } 209 209 210 uint_t aubio_pitch detection_set_unit (aubio_pitchdetection_t *p, char_t * pitch_unit) {211 aubio_pitch detection_mode pitch_mode;210 uint_t aubio_pitch_set_unit (aubio_pitch_t *p, char_t * pitch_unit) { 211 aubio_pitch_mode pitch_mode; 212 212 if (strcmp (pitch_unit, "freq") == 0) 213 213 pitch_mode = aubio_pitchm_freq; … … 245 245 } 246 246 247 uint_t aubio_pitch detection_set_tolerance(aubio_pitchdetection_t *p, smpl_t tol) {247 uint_t aubio_pitch_set_tolerance(aubio_pitch_t *p, smpl_t tol) { 248 248 switch(p->type) { 249 case aubio_pitch _yin:249 case aubio_pitcht_yin: 250 250 aubio_pitchyin_set_tolerance (p->yin, tol); 251 251 break; 252 case aubio_pitch _yinfft:252 case aubio_pitcht_yinfft: 253 253 aubio_pitchyinfft_set_tolerance (p->yinfft, tol); 254 254 break; … … 259 259 } 260 260 261 void aubio_pitch detection_do (aubio_pitchdetection_t *p, fvec_t * ibuf, fvec_t *obuf) {261 void aubio_pitch_do (aubio_pitch_t *p, fvec_t * ibuf, fvec_t *obuf) { 262 262 uint_t i; 263 263 p->callback(p, ibuf, obuf); … … 267 267 } 268 268 269 void aubio_pitch detection_mcomb(aubio_pitchdetection_t *p, fvec_t *ibuf, fvec_t * obuf) {269 void aubio_pitch_do_mcomb(aubio_pitch_t *p, fvec_t *ibuf, fvec_t * obuf) { 270 270 uint_t i; 271 271 aubio_filter_do(p->filter,ibuf); … … 277 277 } 278 278 279 void aubio_pitch detection_yin(aubio_pitchdetection_t *p, fvec_t *ibuf, fvec_t * obuf) {279 void aubio_pitch_do_yin(aubio_pitch_t *p, fvec_t *ibuf, fvec_t * obuf) { 280 280 smpl_t pitch = 0.; 281 281 uint_t i; 282 aubio_pitch detection_slideblock(p,ibuf);282 aubio_pitch_slideblock(p,ibuf); 283 283 aubio_pitchyin_do(p->yin,p->buf, obuf); 284 284 for (i = 0; i < obuf->channels; i++) { … … 294 294 295 295 296 void aubio_pitch detection_yinfft(aubio_pitchdetection_t *p, fvec_t *ibuf, fvec_t * obuf){296 void aubio_pitch_do_yinfft(aubio_pitch_t *p, fvec_t *ibuf, fvec_t * obuf){ 297 297 smpl_t pitch = 0.; 298 298 uint_t i; 299 aubio_pitch detection_slideblock(p,ibuf);299 aubio_pitch_slideblock(p,ibuf); 300 300 aubio_pitchyinfft_do(p->yinfft,p->buf,obuf); 301 301 for (i = 0; i < obuf->channels; i++) { … … 310 310 } 311 311 312 void aubio_pitch detection_fcomb(aubio_pitchdetection_t *p, fvec_t *ibuf, fvec_t * out){313 uint_t i; 314 aubio_pitch detection_slideblock(p,ibuf);312 void aubio_pitch_do_fcomb(aubio_pitch_t *p, fvec_t *ibuf, fvec_t * out){ 313 uint_t i; 314 aubio_pitch_slideblock(p,ibuf); 315 315 aubio_pitchfcomb_do(p->fcomb,p->buf, out); 316 316 for (i = 0; i < out->channels; i++) { … … 319 319 } 320 320 321 void aubio_pitch detection_schmitt(aubio_pitchdetection_t *p, fvec_t *ibuf, fvec_t *out){321 void aubio_pitch_do_schmitt(aubio_pitch_t *p, fvec_t *ibuf, fvec_t *out){ 322 322 smpl_t period, pitch = 0.; 323 323 uint_t i; 324 aubio_pitch detection_slideblock(p,ibuf);324 aubio_pitch_slideblock(p,ibuf); 325 325 aubio_pitchschmitt_do(p->schmitt,p->buf, out); 326 326 for (i = 0; i < out->channels; i++) { -
src/pitch/pitch.h
r9f07d52 rca1abdd 17 17 */ 18 18 19 #ifndef PITCH AUTOTCORR_H20 #define PITCH AUTOTCORR_H19 #ifndef PITCH_H 20 #define PITCH_H 21 21 22 22 #ifdef __cplusplus … … 34 34 35 35 /** pitch detection object */ 36 typedef struct _aubio_pitch detection_t aubio_pitchdetection_t;36 typedef struct _aubio_pitch_t aubio_pitch_t; 37 37 38 38 /** execute pitch detection on an input signal frame 39 39 40 \param o pitch detection object as returned by new_aubio_pitch detection()40 \param o pitch detection object as returned by new_aubio_pitch() 41 41 \param in input signal of size [hopsize x channels] 42 42 \param out output pitch candidates of size [1 x channes] 43 43 44 44 */ 45 void aubio_pitch detection_do (aubio_pitchdetection_t * o, fvec_t * in,45 void aubio_pitch_do (aubio_pitch_t * o, fvec_t * in, 46 46 fvec_t * out); 47 47 48 48 /** change yin or yinfft tolerance threshold 49 49 50 \param o pitch detection object as returned by new_aubio_pitch detection()50 \param o pitch detection object as returned by new_aubio_pitch() 51 51 \param tol tolerance default is 0.15 for yin and 0.85 for yinfft 52 52 53 53 */ 54 uint_t aubio_pitch detection_set_tolerance (aubio_pitchdetection_t * o,54 uint_t aubio_pitch_set_tolerance (aubio_pitch_t * o, 55 55 smpl_t tol); 56 56 57 57 /** deletion of the pitch detection object 58 58 59 \param o pitch detection object as returned by new_aubio_pitch detection()59 \param o pitch detection object as returned by new_aubio_pitch() 60 60 61 61 */ 62 void del_aubio_pitch detection (aubio_pitchdetection_t * o);62 void del_aubio_pitch (aubio_pitch_t * o); 63 63 64 64 /** creation of the pitch detection object … … 71 71 72 72 */ 73 aubio_pitch detection_t *new_aubio_pitchdetection(char_t * mode,73 aubio_pitch_t * new_aubio_pitch (char_t * mode, 74 74 uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate); 75 75 76 76 /** set the output unit of the pitch detection object 77 77 78 \param o pitch detection object as returned by new_aubio_pitch detection()78 \param o pitch detection object as returned by new_aubio_pitch() 79 79 \param mode set pitch units for output 80 80 81 81 */ 82 uint_t aubio_pitch detection_set_unit (aubio_pitchdetection_t * o,82 uint_t aubio_pitch_set_unit (aubio_pitch_t * o, 83 83 char_t * mode); 84 84 … … 87 87 #endif 88 88 89 #endif /*PITCH DETECTION_H*/89 #endif /*PITCH_H*/ -
swig/aubio.i
r9f07d52 rca1abdd 171 171 172 172 /* pitch detection */ 173 aubio_pitch detection_t *new_aubio_pitchdetection(char *pitch_mode,173 aubio_pitch_t *new_aubio_pitch (char *pitch_mode, 174 174 uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate); 175 void aubio_pitch detection_do (aubio_pitchdetection_t * p, fvec_t * ibuf, fvec_t * obuf);176 uint_t aubio_pitch detection_set_tolerance(aubio_pitchdetection_t *p, smpl_t thres);177 uint_t aubio_pitch detection_set_unit(aubio_pitchdetection_t *p, char * pitch_unit);178 void del_aubio_pitch detection(aubio_pitchdetection_t * p);175 void aubio_pitch_do (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf); 176 uint_t aubio_pitch_set_tolerance(aubio_pitch_t *p, smpl_t thres); 177 uint_t aubio_pitch_set_unit(aubio_pitch_t *p, char * pitch_unit); 178 void del_aubio_pitch(aubio_pitch_t * p); 179 179 180 180 /* pitch mcomb */ -
tests/python/src/pitch/pitchdetection.py
r9f07d52 rca1abdd 7 7 samplerate = 44100. 8 8 9 class pitch detection_test_case(unittest.TestCase):9 class pitch_test_case(unittest.TestCase): 10 10 11 11 def setUp(self, type = aubio_pitch_yinfft, mode = aubio_pitchm_freq): … … 15 15 mode = aubio_pitchm_freq): 16 16 self.type = type 17 self.o = new_aubio_pitch detection(buf_size, hop_size,17 self.o = new_aubio_pitch(buf_size, hop_size, 18 18 channels, int(samplerate), type, mode) 19 19 20 20 def tearDown(self): 21 del_aubio_pitch detection(self.o)21 del_aubio_pitch(self.o) 22 22 23 def test_pitch detection(self):24 """ create and delete pitch detection"""23 def test_pitch(self): 24 """ create and delete pitch """ 25 25 pass 26 26 27 def test_pitch detection_run_zeroes(self):28 """ run pitch detectionon an empty buffer """27 def test_pitch_run_zeroes(self): 28 """ run pitch on an empty buffer """ 29 29 vec = new_fvec(buf_size, channels) 30 30 out = new_fvec(1, channels) 31 31 for i in range(100): 32 aubio_pitch detection_do(self.o,vec, out)32 aubio_pitch_do(self.o,vec, out) 33 33 self.assertEqual(fvec_read_sample(out, 0, 0),0.) 34 34 del vec 35 35 36 def test_pitch detection_run_4_impulses(self):37 """ run pitch detectionon a train of 4 impulses """36 def test_pitch_run_4_impulses(self): 37 """ run pitch on a train of 4 impulses """ 38 38 vec = new_fvec(buf_size, channels) 39 39 out = new_fvec(1, channels) … … 44 44 frequency = samplerate/2*4/buf_size 45 45 for i in range(100): 46 aubio_pitch detection_do(self.o,vec, out)46 aubio_pitch_do(self.o,vec, out) 47 47 self.assertEqual(fvec_read_sample(out, 0, 0),frequency) 48 48 del vec 49 49 50 def test_pitch detection_run_4_positive_impulses(self):51 """ run pitch detectionon a train of 4 positive impulses of arbitrary size """50 def test_pitch_run_4_positive_impulses(self): 51 """ run pitch on a train of 4 positive impulses of arbitrary size """ 52 52 vec = new_fvec(buf_size, channels) 53 53 out = new_fvec(1, channels) … … 58 58 fvec_write_sample(vec, 2.-.01*i,0, buf_size/2) 59 59 fvec_write_sample(vec, 2.-.01*i,0,3*buf_size/4) 60 aubio_pitch detection_do(self.o,vec, out)60 aubio_pitch_do(self.o,vec, out) 61 61 self.assertAlmostEqual(fvec_read_sample(out, 0, 0),frequency,1) 62 62 del vec 63 63 64 def test_pitch detection_run_4_negative_impulses(self):65 """ run pitch detectionon a train of 4 negative impulses of arbitrary size """64 def test_pitch_run_4_negative_impulses(self): 65 """ run pitch on a train of 4 negative impulses of arbitrary size """ 66 66 vec = new_fvec(buf_size, channels) 67 67 out = new_fvec(1, channels) … … 72 72 fvec_write_sample(vec,-.01*i,0, buf_size/2) 73 73 fvec_write_sample(vec,-.01*i,0,3*buf_size/4) 74 aubio_pitch detection_do(self.o,vec, out)74 aubio_pitch_do(self.o,vec, out) 75 75 self.assertAlmostEqual(fvec_read_sample(out, 0, 0),frequency,1) 76 76 del vec 77 77 78 def test_pitch detection_run_8_impulses(self):79 """ run pitch detectionon a train of 8 impulses """78 def test_pitch_run_8_impulses(self): 79 """ run pitch on a train of 8 impulses """ 80 80 vec = new_fvec(buf_size, channels) 81 81 out = new_fvec(1, channels) … … 89 89 fvec_write_sample(vec,-1.,0,7*buf_size/8) 90 90 for i in range(100): 91 aubio_pitch detection_do(self.o,vec, out)91 aubio_pitch_do(self.o,vec, out) 92 92 self.assertAlmostEqual(fvec_read_sample(out, 0, 0), 93 93 samplerate/2/buf_size*8, 1) … … 95 95 96 96 """ 97 class pitch detection_yin_test_case(pitchdetection_test_case):97 class pitch_yin_test_case(pitchdetection_test_case): 98 98 def setUp(self, type = aubio_pitch_yin): 99 99 self.create(type=type) 100 100 101 class pitch detection_fcomb_test_case(pitchdetection_test_case):101 class pitch_fcomb_test_case(pitchdetection_test_case): 102 102 def setUp(self, type = aubio_pitch_fcomb): 103 103 self.create(type=type) 104 104 105 class pitch detection_mcomb_test_case(pitchdetection_test_case):105 class pitch_mcomb_test_case(pitchdetection_test_case): 106 106 def setUp(self, type = aubio_pitch_mcomb): 107 107 self.create(type=type) 108 108 109 class pitch detection_schmitt_test_case(pitchdetection_test_case):109 class pitch_schmitt_test_case(pitchdetection_test_case): 110 110 def setUp(self, type = aubio_pitch_schmitt): 111 111 self.create(type=type) -
tests/src/Makefile.am
r9f07d52 rca1abdd 27 27 test-pitchfcomb \ 28 28 test-pitchmcomb \ 29 test-pitch detection\29 test-pitch \ 30 30 test-beattracking \ 31 31 test-onset \ -
tests/src/test-pitchdetection.c
r9f07d52 rca1abdd 11 11 fvec_t *in = new_fvec (hop_s, channels); /* input buffer */ 12 12 fvec_t *out = new_fvec (1, channels); /* input buffer */ 13 aubio_pitch detection_t *o =14 new_aubio_pitch detection("default", win_s, hop_s, channels, samplerate);13 aubio_pitch_t *o = 14 new_aubio_pitch ("default", win_s, hop_s, channels, samplerate); 15 15 uint_t i = 0; 16 16 17 17 while (i < 100) { 18 aubio_pitch detection_do (o, in, out);18 aubio_pitch_do (o, in, out); 19 19 i++; 20 20 }; 21 21 22 del_aubio_pitch detection(o);22 del_aubio_pitch (o); 23 23 del_fvec (in); 24 24 aubio_cleanup ();
Note: See TracChangeset
for help on using the changeset viewer.