- 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
- Location:
- src
- Files:
-
- 2 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
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*/
Note: See TracChangeset
for help on using the changeset viewer.