- Timestamp:
- Nov 21, 2007, 12:53:28 PM (17 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:
- 9668a37
- Parents:
- c7f32b1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/pitchyin.c
rc7f32b1 ra2f3555 33 33 /* outputs the difference function */ 34 34 void aubio_pitchyin_diff(fvec_t * input, fvec_t * yin){ 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 35 uint_t c,j,tau; 36 smpl_t tmp; 37 for (c=0;c<input->channels;c++) 38 { 39 for (tau=0;tau<yin->length;tau++) 40 { 41 yin->data[c][tau] = 0.; 42 } 43 for (tau=1;tau<yin->length;tau++) 44 { 45 for (j=0;j<yin->length;j++) 46 { 47 tmp = input->data[c][j] - input->data[c][j+tau]; 48 yin->data[c][tau] += SQR(tmp); 49 } 50 } 51 } 52 52 } 53 53 54 54 /* cumulative mean normalized difference function */ 55 55 void aubio_pitchyin_getcum(fvec_t * yin) { 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 56 uint_t c,tau; 57 smpl_t tmp; 58 for (c=0;c<yin->channels;c++) 59 { 60 tmp = 0.; 61 yin->data[c][0] = 1.; 62 //AUBIO_DBG("%f\t",yin->data[c][0]); 63 for (tau=1;tau<yin->length;tau++) 64 { 65 tmp += yin->data[c][tau]; 66 yin->data[c][tau] *= tau/tmp; 67 //AUBIO_DBG("%f\t",yin->data[c][tau]); 68 } 69 //AUBIO_DBG("\n"); 70 } 71 71 } 72 72 73 73 uint_t aubio_pitchyin_getpitch(fvec_t * yin) { 74 75 76 77 78 79 80 81 82 83 84 85 86 74 uint_t c=0,tau=1; 75 do 76 { 77 if(yin->data[c][tau] < 0.1) { 78 while (yin->data[c][tau+1] < yin->data[c][tau]) { 79 tau++; 80 } 81 return tau; 82 } 83 tau++; 84 } while (tau<yin->length); 85 //AUBIO_DBG("No pitch found"); 86 return 0; 87 87 } 88 88 … … 90 90 /* all the above in one */ 91 91 smpl_t aubio_pitchyin_getpitchfast(fvec_t * input, fvec_t * yin, smpl_t tol){ 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 92 uint_t c=0,j,tau = 0; 93 sint_t period; 94 smpl_t tmp = 0., tmp2 = 0.; 95 yin->data[c][0] = 1.; 96 for (tau=1;tau<yin->length;tau++) 97 { 98 yin->data[c][tau] = 0.; 99 for (j=0;j<yin->length;j++) 100 { 101 tmp = input->data[c][j] - input->data[c][j+tau]; 102 yin->data[c][tau] += SQR(tmp); 103 } 104 tmp2 += yin->data[c][tau]; 105 yin->data[c][tau] *= tau/tmp2; 106 period = tau-3; 107 if(tau > 4 && (yin->data[c][period] < tol) && 108 (yin->data[c][period] < yin->data[c][period+1])) { 109 return vec_quadint_min(yin,period,1); 110 } 111 } 112 return vec_quadint_min(yin,vec_min_elem(yin),1); 113 //return 0; 114 114 } 115 115
Note: See TracChangeset
for help on using the changeset viewer.