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