Changeset 4a95f83
- Timestamp:
- Mar 16, 2013, 10:44:19 PM (12 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:
- 3a67894
- Parents:
- 8da0033
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/pitch/pitchyinfft.c
r8da0033 r4a95f83 31 31 fvec_t *win; /**< temporal weighting window */ 32 32 fvec_t *winput; /**< windowed spectrum */ 33 cvec_t *res; /**< complex vector to compute square difference function */34 33 fvec_t *sqrmag; /**< square difference function */ 35 34 fvec_t *weight; /**< spectral weighting window (psychoacoustic model) */ 36 cvec_t *fftout; /**< Fourier transform output */ 35 fvec_t *fftout; /**< Fourier transform output */ 36 fvec_t *res; /**< complex vector to compute square difference function */ 37 37 aubio_fft_t *fft; /**< fft object to compute square difference function */ 38 38 fvec_t *yinfft; /**< Yin function */ … … 59 59 p->winput = new_fvec (bufsize); 60 60 p->fft = new_aubio_fft (bufsize); 61 p->fftout = new_cvec (bufsize); 61 p->fftout = new_fvec (bufsize); 62 p->res = new_fvec (bufsize); 62 63 p->sqrmag = new_fvec (bufsize); 63 p->res = new_cvec (bufsize);64 64 p->yinfft = new_fvec (bufsize / 2 + 1); 65 65 p->tol = 0.85; … … 101 101 uint_t halfperiod; 102 102 smpl_t tmp, sum; 103 cvec_t *res = (cvec_t *) p->res;103 fvec_t *res = (fvec_t *) p->res; 104 104 fvec_t *yin = (fvec_t *) p->yinfft; 105 105 l = 0; … … 109 109 p->winput->data[l] = p->win->data[l] * input->data[l]; 110 110 } 111 aubio_fft_do (p->fft, p->winput, p->fftout); 112 p->sqrmag->data[0] = SQR (p->fftout->norm[0]); 111 aubio_fft_do_complex (p->fft, p->winput, p->fftout); 112 uint_t length = p->fftout->length; 113 p->sqrmag->data[0] = SQR(p->fftout->data[0]); 113 114 p->sqrmag->data[0] *= p->weight->data[0]; 114 for (l = 1; l < p->fftout->length; l++) {115 p->sqrmag->data[l] = SQR (p->fftout->norm[l]);115 for (l = 1; l < length / 2; l++) { 116 p->sqrmag->data[l] = SQR(p->fftout->data[l]) + SQR(p->fftout->data[length - l]); 116 117 p->sqrmag->data[l] *= p->weight->data[l]; 117 118 p->sqrmag->data[p->sqrmag->length - l] = p->sqrmag->data[l]; 118 119 } 119 for (l = 0; l < p->fftout->length; l++) { 120 p->sqrmag->data[length / 2] = SQR(p->fftout->data[length / 2]); 121 p->sqrmag->data[length / 2] *= p->weight->data[length / 2]; 122 for (l = 0; l < length / 2 + 1; l++) { 120 123 sum += p->sqrmag->data[l]; 121 124 } 122 125 sum *= 2.; 123 aubio_fft_do (p->fft, p->sqrmag, res);126 aubio_fft_do_complex (p->fft, p->sqrmag, res); 124 127 yin->data[0] = 1.; 125 128 for (tau = 1; tau < yin->length; tau++) { 126 yin->data[tau] = sum - res-> norm[tau] * COS (res->phas[tau]);129 yin->data[tau] = sum - res->data[tau]; 127 130 tmp += yin->data[tau]; 128 131 yin->data[tau] *= tau / tmp; … … 157 160 del_fvec (p->yinfft); 158 161 del_fvec (p->sqrmag); 159 del_ cvec (p->res);160 del_ cvec (p->fftout);162 del_fvec (p->fftout); 163 del_fvec (p->res); 161 164 del_fvec (p->winput); 162 165 del_fvec (p->weight);
Note: See TracChangeset
for help on using the changeset viewer.