- Timestamp:
- Dec 4, 2009, 1:33:06 AM (15 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:
- 0b9a02a
- Parents:
- c7860af
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/cvec.c
rc7860af r66fb3ea 22 22 #include "cvec.h" 23 23 24 cvec_t * new_cvec( uint_t length , uint_t channels) {24 cvec_t * new_cvec( uint_t length) { 25 25 cvec_t * s = AUBIO_NEW(cvec_t); 26 uint_t i,j; 27 s->channels = channels; 26 uint_t j; 28 27 s->length = length/2 + 1; 29 s->norm = AUBIO_ARRAY(smpl_t*,s->channels); 30 s->phas = AUBIO_ARRAY(smpl_t*,s->channels); 31 for (i=0; i< s->channels; i++) { 32 s->norm[i] = AUBIO_ARRAY(smpl_t,s->length); 33 s->phas[i] = AUBIO_ARRAY(smpl_t,s->length); 34 for (j=0; j< s->length; j++) { 35 s->norm[i][j]=0.; 36 s->phas[i][j]=0.; 37 } 28 s->norm = AUBIO_ARRAY(smpl_t,s->length); 29 s->phas = AUBIO_ARRAY(smpl_t,s->length); 30 for (j=0; j< s->length; j++) { 31 s->norm[j]=0.; 32 s->phas[j]=0.; 38 33 } 39 34 return s; … … 41 36 42 37 void del_cvec(cvec_t *s) { 43 uint_t i;44 for (i=0; i<s->channels; i++) {45 AUBIO_FREE(s->norm[i]);46 AUBIO_FREE(s->phas[i]);47 }48 38 AUBIO_FREE(s->norm); 49 39 AUBIO_FREE(s->phas); … … 51 41 } 52 42 53 void cvec_write_norm(cvec_t *s, smpl_t data, uint_t channel, uint_tposition) {54 s->norm[ channel][position] = data;43 void cvec_write_norm(cvec_t *s, smpl_t data, uint_t position) { 44 s->norm[position] = data; 55 45 } 56 void cvec_write_phas(cvec_t *s, smpl_t data, uint_t channel, uint_tposition) {57 s->phas[ channel][position] = data;46 void cvec_write_phas(cvec_t *s, smpl_t data, uint_t position) { 47 s->phas[position] = data; 58 48 } 59 smpl_t cvec_read_norm(cvec_t *s, uint_t channel, uint_tposition) {60 return s->norm[ channel][position];49 smpl_t cvec_read_norm(cvec_t *s, uint_t position) { 50 return s->norm[position]; 61 51 } 62 smpl_t cvec_read_phas(cvec_t *s, uint_t channel, uint_tposition) {63 return s->phas[ channel][position];52 smpl_t cvec_read_phas(cvec_t *s, uint_t position) { 53 return s->phas[position]; 64 54 } 65 void cvec_put_norm_channel(cvec_t *s, smpl_t * data, uint_t channel) { 66 s->norm[channel] = data; 67 } 68 void cvec_put_phas_channel(cvec_t *s, smpl_t * data, uint_t channel) { 69 s->phas[channel] = data; 70 } 71 smpl_t * cvec_get_norm_channel(cvec_t *s, uint_t channel) { 72 return s->norm[channel]; 73 } 74 smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel) { 75 return s->phas[channel]; 76 } 77 smpl_t ** cvec_get_norm(cvec_t *s) { 55 smpl_t * cvec_get_norm(cvec_t *s) { 78 56 return s->norm; 79 57 } 80 smpl_t * *cvec_get_phas(cvec_t *s) {58 smpl_t * cvec_get_phas(cvec_t *s) { 81 59 return s->phas; 82 60 } … … 85 63 86 64 void cvec_print(cvec_t *s) { 87 uint_t i,j; 88 for (i=0; i< s->channels; i++) { 89 AUBIO_MSG("norm: "); 90 for (j=0; j< s->length; j++) { 91 AUBIO_MSG(AUBIO_SMPL_FMT " ", s->norm[i][j]); 92 } 93 AUBIO_MSG("\n"); 94 AUBIO_MSG("phas: "); 95 for (j=0; j< s->length; j++) { 96 AUBIO_MSG(AUBIO_SMPL_FMT " ", s->phas[i][j]); 97 } 98 AUBIO_MSG("\n"); 65 uint_t j; 66 AUBIO_MSG("norm: "); 67 for (j=0; j< s->length; j++) { 68 AUBIO_MSG(AUBIO_SMPL_FMT " ", s->norm[j]); 99 69 } 70 AUBIO_MSG("\n"); 71 AUBIO_MSG("phas: "); 72 for (j=0; j< s->length; j++) { 73 AUBIO_MSG(AUBIO_SMPL_FMT " ", s->phas[j]); 74 } 75 AUBIO_MSG("\n"); 100 76 } 101 77 102 78 void cvec_set(cvec_t *s, smpl_t val) { 103 uint_t i,j; 104 for (i=0; i< s->channels; i++) { 105 for (j=0; j< s->length; j++) { 106 s->norm[i][j] = val; 107 } 79 uint_t j; 80 for (j=0; j< s->length; j++) { 81 s->norm[j] = val; 108 82 } 109 83 } -
src/cvec.h
rc7860af r66fb3ea 39 39 typedef struct { 40 40 uint_t length; /**< length of buffer = (requested length)/2 + 1 */ 41 uint_t channels; /**< number of channels */ 42 smpl_t **norm; /**< norm array of size [length] * [channels] */ 43 smpl_t **phas; /**< phase array of size [length] * [channels] */ 41 smpl_t *norm; /**< norm array of size [length] */ 42 smpl_t *phas; /**< phase array of size [length] */ 44 43 } cvec_t; 45 44 … … 47 46 48 47 This function creates a cvec_t structure holding two arrays of size 49 [length/2+1] * channels, corresponding to the norm and phase values of the48 [length/2+1], corresponding to the norm and phase values of the 50 49 spectral frame. The length stored in the structure is the actual size of both 51 50 arrays, not the length of the complex and symetrical vector, specified as … … 53 52 54 53 \param length the length of the buffer to create 55 \param channels the number of channels in the buffer56 54 57 55 */ 58 cvec_t * new_cvec(uint_t length , uint_t channels);56 cvec_t * new_cvec(uint_t length); 59 57 /** cvec_t buffer deletion function 60 58 … … 66 64 67 65 Note that this function is not used in the aubio library, since the same 68 result can be obtained by assigning vec->norm[ channel][position]. Its purpose66 result can be obtained by assigning vec->norm[position]. Its purpose 69 67 is to access these values from wrappers, as created by swig. 70 68 71 69 \param s vector to write to 72 \param data norm value to write in s->norm[channel][position] 73 \param channel channel to write to 70 \param data norm value to write in s->norm[position] 74 71 \param position sample position to write to 75 72 76 73 */ 77 void cvec_write_norm(cvec_t *s, smpl_t data, uint_t channel, uint_tposition);74 void cvec_write_norm(cvec_t *s, smpl_t data, uint_t position); 78 75 /** write phase value in a complex buffer 79 76 80 77 Note that this function is not used in the aubio library, since the same 81 result can be obtained by assigning vec->phas[ channel][position]. Its purpose78 result can be obtained by assigning vec->phas[position]. Its purpose 82 79 is to access these values from wrappers, as created by swig. 83 80 84 81 \param s vector to write to 85 \param data phase value to write in s->phas[channel][position] 86 \param channel channel to write to 82 \param data phase value to write in s->phas[position] 87 83 \param position sample position to write to 88 84 89 85 */ 90 void cvec_write_phas(cvec_t *s, smpl_t data, uint_t channel, uint_tposition);86 void cvec_write_phas(cvec_t *s, smpl_t data, uint_t position); 91 87 /** read norm value from a complex buffer 92 88 93 89 Note that this function is not used in the aubio library, since the same 94 result can be obtained with vec->norm[ channel][position]. Its purpose is to90 result can be obtained with vec->norm[position]. Its purpose is to 95 91 access these values from wrappers, as created by swig. 96 92 97 93 \param s vector to read from 98 \param channel channel to read from99 94 \param position sample position to read from 100 95 101 96 */ 102 smpl_t cvec_read_norm(cvec_t *s, uint_t channel, uint_tposition);97 smpl_t cvec_read_norm(cvec_t *s, uint_t position); 103 98 /** read phase value from a complex buffer 104 99 105 100 Note that this function is not used in the aubio library, since the same 106 result can be obtained with vec->phas[ channel][position]. Its purpose is to101 result can be obtained with vec->phas[position]. Its purpose is to 107 102 access these values from wrappers, as created by swig. 108 103 109 104 \param s vector to read from 110 \param channel channel to read from111 105 \param position sample position to read from 112 106 113 107 */ 114 smpl_t cvec_read_phas(cvec_t *s, uint_t channel, uint_t position); 115 /** write norm channel in a complex buffer 116 117 Note that this function is not used in the aubio library, since the same 118 result can be obtained by assigning vec->norm[channel]. Its purpose is to 119 access these values from wrappers, as created by swig. 120 121 \param s vector to write to 122 \param data norm vector of [length] samples to write in s->norm[channel] 123 \param channel channel to write to 124 125 */ 126 void cvec_put_norm_channel(cvec_t *s, smpl_t * data, uint_t channel); 127 /** write phase channel in a complex buffer 128 129 Note that this function is not used in the aubio library, since the same 130 result can be obtained by assigning vec->phas[channel]. Its purpose is to 131 access these values from wrappers, as created by swig. 132 133 \param s vector to write to 134 \param data phase vector of [length] samples to write in s->phas[channel] 135 \param channel channel to write to 136 137 */ 138 void cvec_put_phas_channel(cvec_t *s, smpl_t * data, uint_t channel); 139 /** read norm channel from a complex buffer 140 141 Note that this function is not used in the aubio library, since the same 142 result can be obtained with vec->norm[channel]. Its purpose is to access 143 these values from wrappers, as created by swig. 144 145 \param s vector to read from 146 \param channel channel to read from 147 148 */ 149 smpl_t * cvec_get_norm_channel(cvec_t *s, uint_t channel); 150 /** write phase channel in a complex buffer 151 152 Note that this function is not used in the aubio library, since the same 153 result can be obtained with vec->phas[channel]. Its purpose is to access 154 these values from wrappers, as created by swig. 155 156 \param s vector to read from 157 \param channel channel to read from 158 159 */ 160 smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel); 108 smpl_t cvec_read_phas(cvec_t *s, uint_t position); 161 109 /** read norm data from a complex buffer 162 110 … … 168 116 169 117 */ 170 smpl_t * *cvec_get_norm(cvec_t *s);118 smpl_t * cvec_get_norm(cvec_t *s); 171 119 /** read phase data from a complex buffer 172 120 … … 178 126 179 127 */ 180 smpl_t * *cvec_get_phas(cvec_t *s);128 smpl_t * cvec_get_phas(cvec_t *s); 181 129 182 130 /** print out cvec data
Note: See TracChangeset
for help on using the changeset viewer.