Changeset fbd3de6
- Timestamp:
- Mar 16, 2006, 4:37:59 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:
- f8a38c5
- Parents:
- 8595fe3
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/pitchfcomb.c
r8595fe3 rfbd3de6 31 31 #include "sample.h" 32 32 #include "mathutils.h" 33 #include " phasevoc.h"33 #include "fft.h" 34 34 #include "pitchfcomb.h" 35 35 … … 43 43 struct _aubio_pitchfcomb_t { 44 44 uint_t fftSize; 45 uint_t stepSize; 45 46 uint_t rate; 47 fvec_t * winput; 48 fvec_t * win; 46 49 cvec_t * fftOut; 47 50 fvec_t * fftLastPhase; 48 aubio_pvoc_t * pvoc; 51 aubio_mfft_t * fft; 52 //aubio_pvoc_t * pvoc; 49 53 }; 50 54 51 aubio_pitchfcomb_t * new_aubio_pitchfcomb (uint_t size, uint_t samplerate)55 aubio_pitchfcomb_t * new_aubio_pitchfcomb (uint_t bufsize, uint_t hopsize, uint_t samplerate) 52 56 { 53 57 aubio_pitchfcomb_t * p = AUBIO_NEW(aubio_pitchfcomb_t); 54 uint_t overlap_rate = 4;55 58 p->rate = samplerate; 56 p->fftSize = size; 57 p->fftOut = new_cvec(size,1); 58 p->fftLastPhase = new_fvec(size,1); 59 p->pvoc = new_aubio_pvoc(size, size/overlap_rate, 1); 59 p->fftSize = bufsize; 60 p->stepSize = hopsize; 61 p->winput = new_fvec(bufsize,1); 62 p->fftOut = new_cvec(bufsize,1); 63 p->fftLastPhase = new_fvec(bufsize,1); 64 p->fft = new_aubio_mfft(bufsize, 1); 65 p->win = new_fvec(bufsize,1); 66 aubio_window(p->win->data[0], bufsize, aubio_win_hanning); 60 67 return p; 61 68 } … … 64 71 smpl_t aubio_pitchfcomb_detect (aubio_pitchfcomb_t * p, fvec_t * input) 65 72 { 66 uint_t k, l, maxharm = 0 , stepSize = input->length;73 uint_t k, l, maxharm = 0; 67 74 smpl_t freqPerBin = p->rate/(smpl_t)p->fftSize, 68 phaseDifference = TWO_PI*(smpl_t) stepSize/(smpl_t)p->fftSize;75 phaseDifference = TWO_PI*(smpl_t)p->stepSize/(smpl_t)p->fftSize; 69 76 aubio_fpeak_t peaks[MAX_PEAKS]; 70 77 … … 74 81 } 75 82 76 aubio_pvoc_do (p->pvoc, input, p->fftOut); 83 for (k=0; k < input->length; k++){ 84 p->winput->data[0][k] = p->win->data[0][k] * input->data[0][k]; 85 } 86 aubio_mfft_do(p->fft,input,p->fftOut); 77 87 78 for (k=0; k<=p->fftSize; k++) { 79 //long qpd; 88 for (k=0; k<=p->fftSize/2; k++) { 80 89 smpl_t 81 90 magnitude = 20.*LOG10(2.*p->fftOut->norm[0][k]/(smpl_t)p->fftSize), … … 91 100 92 101 /* map delta phase into +/- Pi interval */ 93 tmp = aubio_unwrap2pi(tmp) ;102 tmp = aubio_unwrap2pi(tmp) + PI; 94 103 95 104 /* get deviation from bin frequency from the +/- Pi interval */ 96 tmp = p-> fftSize/input->length*tmp/(TWO_PI);105 tmp = p->stepSize/(smpl_t)p->fftSize*tmp/(TWO_PI); 97 106 98 107 /* compute the k-th partials' true frequency */ 99 108 freq = (smpl_t)k*freqPerBin + tmp*freqPerBin; 100 109 101 if (freq > 0.0 && magnitude > peaks[0].db && magnitude < 0) {110 if (freq > 0.0 && magnitude > peaks[0].db) { // && magnitude < 0) { 102 111 memmove(peaks+1, peaks, sizeof(aubio_fpeak_t)*(MAX_PEAKS-1)); 103 112 peaks[0].freq = freq; … … 129 138 del_cvec(p->fftOut); 130 139 del_fvec(p->fftLastPhase); 131 del_aubio_ pvoc(p->pvoc);140 del_aubio_mfft(p->fft); 132 141 AUBIO_FREE(p); 133 142 } -
src/pitchfcomb.h
r8595fe3 rfbd3de6 28 28 29 29 smpl_t aubio_pitchfcomb_detect (aubio_pitchfcomb_t *p, fvec_t * input); 30 aubio_pitchfcomb_t * new_aubio_pitchfcomb (uint_t size, uint_t samplerate);30 aubio_pitchfcomb_t * new_aubio_pitchfcomb (uint_t bufsize, uint_t hopsize, uint_t samplerate); 31 31 void del_aubio_pitchfcomb (aubio_pitchfcomb_t *p); 32 32
Note: See TracChangeset
for help on using the changeset viewer.