Changeset f88a326
- Timestamp:
- May 28, 2005, 2:53:13 AM (20 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:
- 946cad3
- Parents:
- f8714ee
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/fft.c
rf8714ee rf88a326 78 78 void del_aubio_fft(aubio_fft_t * s) { 79 79 aubio_fft_free(s); 80 AUBIO_FREE(s); 80 81 } 81 82 … … 111 112 } 112 113 114 115 /* new interface aubio_mfft */ 116 struct _aubio_mfft_t { 117 aubio_fft_t * fft; /* fftw interface */ 118 fft_data_t ** spec; /* complex spectral data */ 119 uint_t winsize; 120 uint_t channels; 121 }; 122 123 aubio_mfft_t * new_aubio_mfft(uint_t winsize, uint_t channels){ 124 uint_t i; 125 aubio_mfft_t * fft = AUBIO_NEW(aubio_mfft_t); 126 fft->winsize = winsize; 127 fft->channels = channels; 128 fft->fft = new_aubio_fft(winsize); 129 fft->spec = AUBIO_ARRAY(fft_data_t*,channels); 130 for (i=0; i < channels; i++) 131 fft->spec[i] = AUBIO_ARRAY(fft_data_t,winsize); 132 return fft; 133 } 134 135 /* execute stft */ 136 void aubio_mfft_do (aubio_mfft_t * fft,fvec_t * in,cvec_t * fftgrain){ 137 uint_t i=0; 138 /* execute stft */ 139 for (i=0; i < fft->channels; i++) { 140 aubio_fft_do (fft->fft,in->data[i],fft->spec[i],fft->winsize); 141 /* put norm and phase into fftgrain */ 142 aubio_fft_getnorm(fftgrain->norm[i], fft->spec[i], fft->winsize/2+1); 143 aubio_fft_getphas(fftgrain->phas[i], fft->spec[i], fft->winsize/2+1); 144 } 145 } 146 147 /* execute inverse fourier transform */ 148 void aubio_mfft_rdo(aubio_mfft_t * fft,cvec_t * fftgrain, fvec_t * out){ 149 uint_t i=0,j; 150 for (i=0; i < fft->channels; i++) { 151 for (j=0; j<fft->winsize/2+1; j++) { 152 fft->spec[i][j] = CEXPC(I*unwrap2pi(fftgrain->phas[i][j])); 153 fft->spec[i][j] *= fftgrain->norm[i][j]; 154 } 155 aubio_fft_rdo(fft->fft,fft->spec[i],out->data[i],fft->winsize); 156 } 157 } 158 159 void del_aubio_mfft(aubio_mfft_t * fft) { 160 uint_t i; 161 for (i=0; i < fft->channels; i++) 162 AUBIO_FREE(fft->spec[i]); 163 AUBIO_FREE(fft->spec); 164 aubio_fft_free(fft->fft); 165 AUBIO_FREE(fft); 166 } -
src/fft.h
rf8714ee rf88a326 56 56 void aubio_fft_getphas(smpl_t * phase, fft_data_t * spectrum, uint_t size); 57 57 58 59 typedef struct _aubio_mfft_t aubio_mfft_t; 60 aubio_mfft_t * new_aubio_mfft(uint_t winsize, uint_t channels); 61 void aubio_mfft_do (aubio_mfft_t * fft,fvec_t * in,cvec_t * fftgrain); 62 void aubio_mfft_rdo(aubio_mfft_t * fft,cvec_t * fftgrain, fvec_t * out); 63 void del_aubio_mfft(aubio_mfft_t * fft); 64 65 58 66 #ifdef __cplusplus 59 67 } -
src/phasevoc.c
rf8714ee rf88a326 33 33 uint_t channels; 34 34 /** spectral data */ 35 aubio_ fft_t * spectrum;35 aubio_mfft_t * fft; 36 36 /**cur output grain [win_s] */ 37 37 fvec_t * synth; 38 38 /**last input frame [win_s-hop_s] */ 39 39 fvec_t * synthold; 40 /**current spectrum [win_s] */41 fft_data_t ** spec;42 40 /**current input grain [win_s] */ 43 41 fvec_t * data; … … 49 47 50 48 51 /** memory allocation */52 static aubio_pvoc_t * aubio_pvoc_malloc (uint_t win_s, uint_t hop_s, uint_t channels);53 /** object deletion */54 static void aubio_pvoc_free (aubio_pvoc_t *pv);55 49 /** returns data and dataold slided by hop_s */ 56 50 static void aubio_pvoc_swapbuffers( … … 75 69 /* windowing */ 76 70 for (j=0; j<pv->win_s; j++) pv->data->data[i][j] *= pv->w[j]; 77 /* fftshift */ 78 vec_shift(pv->data); 79 /* calculate fft */ 80 aubio_fft_do(pv->spectrum,pv->data->data[i],pv->spec[i],pv->win_s); 81 /* put norm and phase to fftgrain */ 82 aubio_fft_getnorm(fftgrain->norm[i], pv->spec[i], pv->win_s/2+1); 83 aubio_fft_getphas(fftgrain->phas[i], pv->spec[i], pv->win_s/2+1); 84 } 71 } 72 /* shift */ 73 vec_shift(pv->data); 74 /* calculate fft */ 75 aubio_mfft_do (pv->fft,pv->data,fftgrain); 85 76 } 86 77 87 78 void aubio_pvoc_rdo(aubio_pvoc_t *pv,cvec_t * fftgrain, fvec_t * synthnew) { 88 79 uint_t i,j; 80 /* calculate rfft */ 81 aubio_mfft_rdo(pv->fft,fftgrain,pv->synth); 82 /* unshift */ 83 vec_shift(pv->synth); 89 84 for (i=0; i<pv->channels; i++) { 90 for (j=0; j<pv->win_s/2+1; j++) {91 pv->spec[i][j] = CEXPC(I*unwrap2pi(fftgrain->phas[i][j]));92 pv->spec[i][j] *= fftgrain->norm[i][j];93 }94 aubio_fft_rdo(pv->spectrum,pv->spec[i],pv->synth->data[i],pv->win_s);95 vec_shift(pv->synth);96 85 for (j=0; j<pv->win_s; j++) pv->synth->data[i][j] *= pv->w[j]; 97 86 aubio_pvoc_addsynth(pv->synth->data[i],pv->synthold->data[i], … … 100 89 } 101 90 102 void del_aubio_pvoc(aubio_pvoc_t *pv) {103 aubio_pvoc_free(pv);104 }105 106 91 aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s, uint_t channels) { 107 aubio_pvoc_t * pv = aubio_pvoc_malloc(win_s, hop_s, channels);108 window(pv->w,pv->win_s,hanningz);109 return pv;110 }111 112 static aubio_pvoc_t * aubio_pvoc_malloc (uint_t win_s, uint_t hop_s, uint_t channels) {113 uint_t i;114 115 92 aubio_pvoc_t * pv = AUBIO_NEW(aubio_pvoc_t); 116 93 117 94 if (win_s < 2*hop_s) { 118 AUBIO_ERR("Window size is smaller than twice the hop size!\n"); 119 return 0; 95 AUBIO_ERR("Hop size bigger than half the window size!\n"); 96 AUBIO_ERR("Resetting hop size to half the window size.\n"); 97 hop_s = win_s / 2; 120 98 } 121 99 122 100 if (hop_s < 1) { 123 101 AUBIO_ERR("Hop size is smaller than 1!\n"); 124 return 0; 102 AUBIO_ERR("Resetting hop size to half the window size.\n"); 103 hop_s = win_s / 2; 125 104 } 126 105 127 pv-> spectrum = new_aubio_fft(win_s);106 pv->fft = new_aubio_mfft(win_s,channels); 128 107 129 108 /* remember old */ … … 135 114 pv->synthold = new_fvec (win_s-hop_s, channels); 136 115 pv->w = AUBIO_ARRAY(smpl_t,win_s); 137 138 pv->spec = AUBIO_ARRAY(fft_data_t*,channels); 139 for (i=0; i<channels; i++) 140 pv->spec[i] = AUBIO_ARRAY(fft_data_t,win_s); 116 window(pv->w,win_s,hanningz); 141 117 142 118 pv->channels = channels; … … 147 123 } 148 124 149 static void aubio_pvoc_free (aubio_pvoc_t *pv) { 150 uint_t i; 151 del_aubio_fft(pv->spectrum); 125 void del_aubio_pvoc(aubio_pvoc_t *pv) { 152 126 del_fvec(pv->data); 153 127 del_fvec(pv->synth); … … 155 129 del_fvec(pv->synthold); 156 130 AUBIO_FREE(pv->w); 157 for (i=0; i< pv->channels; i++) {158 AUBIO_FREE(pv->spec[i]);159 }160 AUBIO_FREE(pv->spec);161 131 AUBIO_FREE(pv); 162 132 } 163 133 164 static void aubio_pvoc_swapbuffers(smpl_t * data, smpl_t * dataold, const smpl_t * datanew,165 134 static void aubio_pvoc_swapbuffers(smpl_t * data, smpl_t * dataold, 135 const smpl_t * datanew, uint_t win_s, uint_t hop_s) 166 136 { 167 137 uint_t i; … … 174 144 } 175 145 176 static void aubio_pvoc_addsynth(const smpl_t * synth, smpl_t * synthold, smpl_t * synthnew,177 146 static void aubio_pvoc_addsynth(const smpl_t * synth, smpl_t * synthold, 147 smpl_t * synthnew, uint_t win_s, uint_t hop_s) 178 148 { 179 149 uint_t i;
Note: See TracChangeset
for help on using the changeset viewer.