Changes in src/pitch/pitchyin.c [fddfa64:168337e]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/pitch/pitchyin.c
rfddfa64 r168337e 65 65 { 66 66 aubio_pitchyin_t *o = AUBIO_NEW (aubio_pitchyin_t); 67 o->yin = new_fvec (bufsize / 2 , 1);67 o->yin = new_fvec (bufsize / 2); 68 68 o->tol = 0.15; 69 69 return o; … … 81 81 aubio_pitchyin_diff (fvec_t * input, fvec_t * yin) 82 82 { 83 uint_t c,j, tau;83 uint_t j, tau; 84 84 smpl_t tmp; 85 for (c = 0; c < input->channels; c++) { 86 for (tau = 0; tau < yin->length; tau++) { 87 yin->data[c][tau] = 0.; 88 } 89 for (tau = 1; tau < yin->length; tau++) { 90 for (j = 0; j < yin->length; j++) { 91 tmp = input->data[c][j] - input->data[c][j + tau]; 92 yin->data[c][tau] += SQR (tmp); 93 } 85 for (tau = 0; tau < yin->length; tau++) { 86 yin->data[tau] = 0.; 87 } 88 for (tau = 1; tau < yin->length; tau++) { 89 for (j = 0; j < yin->length; j++) { 90 tmp = input->data[j] - input->data[j + tau]; 91 yin->data[tau] += SQR (tmp); 94 92 } 95 93 } … … 100 98 aubio_pitchyin_getcum (fvec_t * yin) 101 99 { 102 uint_t c,tau;100 uint_t tau; 103 101 smpl_t tmp; 104 for (c = 0; c < yin->channels; c++) { 105 tmp = 0.; 106 yin->data[c][0] = 1.; 107 //AUBIO_DBG("%f\t",yin->data[c][0]); 108 for (tau = 1; tau < yin->length; tau++) { 109 tmp += yin->data[c][tau]; 110 yin->data[c][tau] *= tau / tmp; 111 //AUBIO_DBG("%f\t",yin->data[c][tau]); 112 } 113 //AUBIO_DBG("\n"); 102 tmp = 0.; 103 yin->data[0] = 1.; 104 //AUBIO_DBG("%f\t",yin->data[0]); 105 for (tau = 1; tau < yin->length; tau++) { 106 tmp += yin->data[tau]; 107 yin->data[tau] *= tau / tmp; 108 //AUBIO_DBG("%f\t",yin->data[tau]); 114 109 } 110 //AUBIO_DBG("\n"); 115 111 } 116 112 … … 118 114 aubio_pitchyin_getpitch (fvec_t * yin) 119 115 { 120 uint_t c = 0,tau = 1;116 uint_t tau = 1; 121 117 do { 122 if (yin->data[ c][tau] < 0.1) {123 while (yin->data[ c][tau + 1] < yin->data[c][tau]) {118 if (yin->data[tau] < 0.1) { 119 while (yin->data[tau + 1] < yin->data[tau]) { 124 120 tau++; 125 121 } … … 139 135 smpl_t tol = o->tol; 140 136 fvec_t *yin = o->yin; 141 uint_t c,j, tau = 0;137 uint_t j, tau = 0; 142 138 sint_t period; 143 139 smpl_t tmp = 0., tmp2 = 0.; 144 for (c = 0; c < input->channels; c++) { 145 yin->data[c][0] = 1.; 146 for (tau = 1; tau < yin->length; tau++) { 147 yin->data[c][tau] = 0.; 148 for (j = 0; j < yin->length; j++) { 149 tmp = input->data[c][j] - input->data[c][j + tau]; 150 yin->data[c][tau] += SQR (tmp); 151 } 152 tmp2 += yin->data[c][tau]; 153 yin->data[c][tau] *= tau / tmp2; 154 period = tau - 3; 155 if (tau > 4 && (yin->data[c][period] < tol) && 156 (yin->data[c][period] < yin->data[c][period + 1])) { 157 out->data[c][0] = fvec_quadint (yin, period, c); 158 goto beach; 159 } 140 yin->data[0] = 1.; 141 for (tau = 1; tau < yin->length; tau++) { 142 yin->data[tau] = 0.; 143 for (j = 0; j < yin->length; j++) { 144 tmp = input->data[j] - input->data[j + tau]; 145 yin->data[tau] += SQR (tmp); 160 146 } 161 out->data[c][0] = fvec_quadint (yin, fvec_min_elem (yin), c); 162 beach: 163 continue; 147 tmp2 += yin->data[tau]; 148 yin->data[tau] *= tau / tmp2; 149 period = tau - 3; 150 if (tau > 4 && (yin->data[period] < tol) && 151 (yin->data[period] < yin->data[period + 1])) { 152 out->data[0] = fvec_quadint (yin, period); 153 goto beach; 154 } 164 155 } 165 //return 0; 156 out->data[0] = fvec_quadint (yin, fvec_min_elem (yin)); 157 beach: 158 return; 166 159 } 167 160
Note: See TracChangeset
for help on using the changeset viewer.