Changeset 651b97e
- Timestamp:
- Aug 8, 2005, 10:08:21 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:
- 54bf847
- Parents:
- f841b81
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/pitchdetection.c
rf841b81 r651b97e 30 30 typedef smpl_t (*aubio_pitchdetection_func_t)(aubio_pitchdetection_t *p, 31 31 fvec_t * ibuf); 32 void aubio_pitchdetection_slideblock(aubio_pitchdetection_t *p, fvec_t *ibuf); 32 33 33 34 struct _aubio_pitchdetection_t { … … 73 74 break; 74 75 case aubio_fcomb: 76 p->buf = new_fvec(bufsize,channels); 75 77 p->fcomb = new_aubio_pitchfcomb(bufsize,samplerate); 76 78 p->callback = aubio_pitchdetection_fcomb; 77 79 break; 78 80 case aubio_schmitt: 81 p->buf = new_fvec(bufsize,channels); 79 82 p->schmitt = new_aubio_pitchschmitt(bufsize,samplerate); 80 p->callback = aubio_pitchdetection_ mcomb;83 p->callback = aubio_pitchdetection_schmitt; 81 84 break; 82 85 default: … … 98 101 break; 99 102 case aubio_schmitt: 103 del_fvec(p->buf); 100 104 del_aubio_pitchschmitt(p->schmitt); 101 105 break; 102 106 case aubio_fcomb: 107 del_fvec(p->buf); 103 108 del_aubio_pitchfcomb(p->fcomb); 104 109 break; … … 107 112 } 108 113 AUBIO_FREE(p); 114 } 115 116 void aubio_pitchdetection_slideblock(aubio_pitchdetection_t *p, fvec_t *ibuf){ 117 uint_t i,j = 0, overlap_size = 0; 118 overlap_size = p->buf->length-ibuf->length; 119 for (i=0;i<p->buf->channels;i++){ 120 for (j=0;j<overlap_size;j++){ 121 p->buf->data[i][j] = 122 p->buf->data[i][j+ibuf->length]; 123 } 124 } 125 for (i=0;i<ibuf->channels;i++){ 126 for (j=0;j<ibuf->length;j++){ 127 p->buf->data[i][j+overlap_size] = 128 ibuf->data[i][j]; 129 } 130 } 109 131 } 110 132 … … 128 150 smpl_t aubio_pitchdetection_yin(aubio_pitchdetection_t *p, fvec_t *ibuf) { 129 151 smpl_t pitch = 0.; 130 uint_t i,j = 0, overlap_size = 0; 131 overlap_size = p->buf->length-ibuf->length; 132 /* do sliding window blocking */ 133 for (i=0;i<p->buf->channels;i++){ 134 for (j=0;j<overlap_size;j++){ 135 p->buf->data[i][j] = 136 p->buf->data[i][j+ibuf->length]; 137 } 138 } 139 for (i=0;i<ibuf->channels;i++){ 140 for (j=0;j<ibuf->length;j++){ 141 p->buf->data[i][j+overlap_size] = 142 ibuf->data[i][j]; 143 } 144 } 152 aubio_pitchdetection_slideblock(p,ibuf); 145 153 pitch = aubio_pitchyin_getpitchfast(p->buf,p->yin, 0.5); 146 154 if (pitch>0) { … … 154 162 155 163 smpl_t aubio_pitchdetection_fcomb(aubio_pitchdetection_t *p, fvec_t *ibuf){ 156 return aubio_pitchfcomb_detect(p->fcomb,ibuf); 164 aubio_pitchdetection_slideblock(p,ibuf); 165 return aubio_pitchfcomb_detect(p->fcomb,p->buf); 157 166 } 158 167 159 168 smpl_t aubio_pitchdetection_schmitt(aubio_pitchdetection_t *p, fvec_t *ibuf){ 160 return aubio_pitchschmitt_detect(p->schmitt,ibuf); 169 aubio_pitchdetection_slideblock(p,ibuf); 170 return aubio_pitchschmitt_detect(p->schmitt,p->buf); 161 171 }
Note: See TracChangeset
for help on using the changeset viewer.