- Timestamp:
- Dec 4, 2009, 1:32:43 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:
- 66fb3ea
- Parents:
- c6d0169
- Location:
- src
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/fvec.c
rc6d0169 rc7860af 22 22 #include "fvec.h" 23 23 24 fvec_t * new_fvec( uint_t length , uint_t channels) {24 fvec_t * new_fvec( uint_t length) { 25 25 fvec_t * s = AUBIO_NEW(fvec_t); 26 uint_t i,j; 27 s->channels = channels; 26 uint_t j; 28 27 s->length = length; 29 s->data = AUBIO_ARRAY(smpl_t*,s->channels); 30 for (i=0; i< s->channels; i++) { 31 s->data[i] = AUBIO_ARRAY(smpl_t, s->length); 32 for (j=0; j< s->length; j++) { 33 s->data[i][j]=0.; 34 } 28 s->data = AUBIO_ARRAY(smpl_t, s->length); 29 for (j=0; j< s->length; j++) { 30 s->data[j]=0.; 35 31 } 36 32 return s; … … 38 34 39 35 void del_fvec(fvec_t *s) { 40 uint_t i;41 for (i=0; i<s->channels; i++) {42 AUBIO_FREE(s->data[i]);43 }44 36 AUBIO_FREE(s->data); 45 37 AUBIO_FREE(s); 46 38 } 47 39 48 void fvec_write_sample(fvec_t *s, smpl_t data, uint_t channel, uint_t position) { 49 s->data[channel][position] = data; 50 } 51 smpl_t fvec_read_sample(fvec_t *s, uint_t channel, uint_t position) { 52 return s->data[channel][position]; 53 } 54 void fvec_put_channel(fvec_t *s, smpl_t * data, uint_t channel) { 55 s->data[channel] = data; 56 } 57 smpl_t * fvec_get_channel(fvec_t *s, uint_t channel) { 58 return s->data[channel]; 40 void fvec_write_sample(fvec_t *s, smpl_t data, uint_t position) { 41 s->data[position] = data; 59 42 } 60 43 61 smpl_t ** fvec_get_data(fvec_t *s) { 44 smpl_t fvec_read_sample(fvec_t *s, uint_t position) { 45 return s->data[position]; 46 } 47 48 smpl_t * fvec_get_data(fvec_t *s) { 62 49 return s->data; 63 50 } … … 66 53 67 54 void fvec_print(fvec_t *s) { 68 uint_t i,j; 69 for (i=0; i< s->channels; i++) { 70 for (j=0; j< s->length; j++) { 71 AUBIO_MSG(AUBIO_SMPL_FMT " ", s->data[i][j]); 72 } 73 AUBIO_MSG("\n"); 55 uint_t j; 56 for (j=0; j< s->length; j++) { 57 AUBIO_MSG(AUBIO_SMPL_FMT " ", s->data[j]); 74 58 } 59 AUBIO_MSG("\n"); 75 60 } 76 61 77 62 void fvec_set(fvec_t *s, smpl_t val) { 78 uint_t i,j; 79 for (i=0; i< s->channels; i++) { 80 for (j=0; j< s->length; j++) { 81 s->data[i][j] = val; 82 } 63 uint_t j; 64 for (j=0; j< s->length; j++) { 65 s->data[j] = val; 83 66 } 84 67 } … … 93 76 94 77 void fvec_rev(fvec_t *s) { 95 uint_t i,j; 96 for (i=0; i< s->channels; i++) { 97 for (j=0; j< FLOOR(s->length/2); j++) { 98 ELEM_SWAP(s->data[i][j], s->data[i][s->length-1-j]); 99 } 78 uint_t j; 79 for (j=0; j< FLOOR(s->length/2); j++) { 80 ELEM_SWAP(s->data[j], s->data[s->length-1-j]); 100 81 } 101 82 } 102 83 103 84 void fvec_weight(fvec_t *s, fvec_t *weight) { 104 uint_t i,j;85 uint_t j; 105 86 uint_t length = MIN(s->length, weight->length); 106 for (i=0; i< s->channels; i++) { 107 for (j=0; j< length; j++) { 108 s->data[i][j] *= weight->data[0][j]; 109 } 87 for (j=0; j< length; j++) { 88 s->data[j] *= weight->data[j]; 110 89 } 111 90 } 112 91 113 92 void fvec_copy(fvec_t *s, fvec_t *t) { 114 uint_t i,j; 115 uint_t channels = MIN(s->channels, t->channels); 93 uint_t j; 116 94 uint_t length = MIN(s->length, t->length); 117 if (s->channels != t->channels) {118 AUBIO_ERR("warning, trying to copy %d channels to %d channels\n",119 s->channels, t->channels);120 }121 95 if (s->length != t->length) { 122 AUBIO_ ERR("warning,trying to copy %d elements to %d elements \n",96 AUBIO_WRN("trying to copy %d elements to %d elements \n", 123 97 s->length, t->length); 124 98 } 125 for (i=0; i< channels; i++) { 126 for (j=0; j< length; j++) { 127 t->data[i][j] = s->data[i][j]; 128 } 99 for (j=0; j< length; j++) { 100 t->data[j] = s->data[j]; 129 101 } 130 102 } -
src/fvec.h
rc6d0169 rc7860af 38 38 typedef struct { 39 39 uint_t length; /**< length of buffer */ 40 uint_t channels; /**< number of channels */ 41 smpl_t **data; /**< data array of size [length] * [channels] */ 40 smpl_t *data; /**< data array of size [length] */ 42 41 } fvec_t; 43 42 … … 45 44 46 45 \param length the length of the buffer to create 47 \param channels the number of channels in the buffer48 46 49 47 */ 50 fvec_t * new_fvec(uint_t length , uint_t channels);48 fvec_t * new_fvec(uint_t length); 51 49 /** fvec_t buffer deletion function 52 50 … … 58 56 59 57 Note that this function is not used in the aubio library, since the same 60 result can be obtained using vec->data[ channel][position]. Its purpose is to58 result can be obtained using vec->data[position]. Its purpose is to 61 59 access these values from wrappers, as created by swig. 62 60 63 61 \param s vector to read from 64 \param channel channel to read from65 62 \param position sample position to read from 66 63 67 64 */ 68 smpl_t fvec_read_sample(fvec_t *s, uint_t channel, uint_tposition);65 smpl_t fvec_read_sample(fvec_t *s, uint_t position); 69 66 /** write sample value in a buffer 70 67 71 68 Note that this function is not used in the aubio library, since the same 72 result can be obtained by assigning vec->data[ channel][position]. Its purpose69 result can be obtained by assigning vec->data[position]. Its purpose 73 70 is to access these values from wrappers, as created by swig. 74 71 75 72 \param s vector to write to 76 \param data value to write in s->data[channel][position] 77 \param channel channel to write to 73 \param data value to write in s->data[position] 78 74 \param position sample position to write to 79 75 80 76 */ 81 void fvec_write_sample(fvec_t *s, smpl_t data, uint_t channel, uint_t position); 82 /** read channel vector from a buffer 77 void fvec_write_sample(fvec_t *s, smpl_t data, uint_t position); 83 78 84 Note that this function is not used in the aubio library, since the same85 result can be obtained with vec->data[channel]. Its purpose is to access86 these values from wrappers, as created by swig.87 88 \param s vector to read from89 \param channel channel to read from90 91 */92 smpl_t * fvec_get_channel(fvec_t *s, uint_t channel);93 /** write channel vector into a buffer94 95 Note that this function is not used in the aubio library, since the same96 result can be obtained by assigning vec->data[channel]. Its purpose is to97 access these values from wrappers, as created by swig.98 99 \param s vector to write to100 \param data vector of [length] values to write101 \param channel channel to write to102 103 */104 void fvec_put_channel(fvec_t *s, smpl_t * data, uint_t channel);105 79 /** read data from a buffer 106 80 … … 112 86 113 87 */ 114 smpl_t * *fvec_get_data(fvec_t *s);88 smpl_t * fvec_get_data(fvec_t *s); 115 89 116 90 /** print out fvec data -
src/lvec.c
rc6d0169 rc7860af 22 22 #include "lvec.h" 23 23 24 lvec_t * new_lvec( uint_t length , uint_t channels) {24 lvec_t * new_lvec( uint_t length) { 25 25 lvec_t * s = AUBIO_NEW(lvec_t); 26 uint_t i,j; 27 s->channels = channels; 26 uint_t j; 28 27 s->length = length; 29 s->data = AUBIO_ARRAY(lsmp_t*,s->channels); 30 for (i=0; i< s->channels; i++) { 31 s->data[i] = AUBIO_ARRAY(lsmp_t, s->length); 32 for (j=0; j< s->length; j++) { 33 s->data[i][j]=0.; 34 } 28 s->data = AUBIO_ARRAY(lsmp_t, s->length); 29 for (j=0; j< s->length; j++) { 30 s->data[j]=0.; 35 31 } 36 32 return s; … … 38 34 39 35 void del_lvec(lvec_t *s) { 40 uint_t i;41 for (i=0; i<s->channels; i++) {42 AUBIO_FREE(s->data[i]);43 }44 36 AUBIO_FREE(s->data); 45 37 AUBIO_FREE(s); 46 38 } 47 39 48 void lvec_write_sample(lvec_t *s, lsmp_t data, uint_t channel, uint_tposition) {49 s->data[ channel][position] = data;40 void lvec_write_sample(lvec_t *s, lsmp_t data, uint_t position) { 41 s->data[position] = data; 50 42 } 51 lsmp_t lvec_read_sample(lvec_t *s, uint_t channel, uint_t position) { 52 return s->data[channel][position]; 53 } 54 void lvec_put_channel(lvec_t *s, lsmp_t * data, uint_t channel) { 55 s->data[channel] = data; 56 } 57 lsmp_t * lvec_get_channel(lvec_t *s, uint_t channel) { 58 return s->data[channel]; 43 lsmp_t lvec_read_sample(lvec_t *s, uint_t position) { 44 return s->data[position]; 59 45 } 60 46 61 lsmp_t * *lvec_get_data(lvec_t *s) {47 lsmp_t * lvec_get_data(lvec_t *s) { 62 48 return s->data; 63 49 } … … 66 52 67 53 void lvec_print(lvec_t *s) { 68 uint_t i,j; 69 for (i=0; i< s->channels; i++) { 70 for (j=0; j< s->length; j++) { 71 AUBIO_MSG(AUBIO_LSMP_FMT " ", s->data[i][j]); 72 } 73 AUBIO_MSG("\n"); 54 uint_t j; 55 for (j=0; j< s->length; j++) { 56 AUBIO_MSG(AUBIO_LSMP_FMT " ", s->data[j]); 74 57 } 58 AUBIO_MSG("\n"); 75 59 } 76 60 77 61 void lvec_set(lvec_t *s, smpl_t val) { 78 uint_t i,j; 79 for (i=0; i< s->channels; i++) { 80 for (j=0; j< s->length; j++) { 81 s->data[i][j] = val; 82 } 62 uint_t j; 63 for (j=0; j< s->length; j++) { 64 s->data[j] = val; 83 65 } 84 66 } -
src/lvec.h
rc6d0169 rc7860af 39 39 typedef struct { 40 40 uint_t length; /**< length of buffer */ 41 uint_t channels; /**< number of channels */ 42 lsmp_t **data; /**< data array of size [length] * [channels] */ 41 lsmp_t *data; /**< data array of size [length] */ 43 42 } lvec_t; 44 43 … … 46 45 47 46 \param length the length of the buffer to create 48 \param channels the number of channels in the buffer49 47 50 48 */ 51 lvec_t * new_lvec(uint_t length , uint_t channels);49 lvec_t * new_lvec(uint_t length); 52 50 /** lvec_t buffer deletion function 53 51 … … 59 57 60 58 Note that this function is not used in the aubio library, since the same 61 result can be obtained using vec->data[ channel][position]. Its purpose is to59 result can be obtained using vec->data[position]. Its purpose is to 62 60 access these values from wrappers, as created by swig. 63 61 64 62 \param s vector to read from 65 \param channel channel to read from66 63 \param position sample position to read from 67 64 68 65 */ 69 lsmp_t lvec_read_sample(lvec_t *s, uint_t channel, uint_tposition);66 lsmp_t lvec_read_sample(lvec_t *s, uint_t position); 70 67 /** write sample value in a buffer 71 68 72 69 Note that this function is not used in the aubio library, since the same 73 result can be obtained by assigning vec->data[ channel][position]. Its purpose70 result can be obtained by assigning vec->data[position]. Its purpose 74 71 is to access these values from wrappers, as created by swig. 75 72 76 73 \param s vector to write to 77 \param data value to write in s->data[channel][position] 78 \param channel channel to write to 74 \param data value to write in s->data[position] 79 75 \param position sample position to write to 80 76 81 77 */ 82 void lvec_write_sample(lvec_t *s, lsmp_t data, uint_t channel, uint_t position); 83 /** read channel vector from a buffer 78 void lvec_write_sample(lvec_t *s, lsmp_t data, uint_t position); 84 79 85 Note that this function is not used in the aubio library, since the same86 result can be obtained with vec->data[channel]. Its purpose is to access87 these values from wrappers, as created by swig.88 89 \param s vector to read from90 \param channel channel to read from91 92 */93 lsmp_t * lvec_get_channel(lvec_t *s, uint_t channel);94 /** write channel vector into a buffer95 96 Note that this function is not used in the aubio library, since the same97 result can be obtained by assigning vec->data[channel]. Its purpose is to98 access these values from wrappers, as created by swig.99 100 \param s vector to write to101 \param data vector of [length] values to write102 \param channel channel to write to103 104 */105 void lvec_put_channel(lvec_t *s, lsmp_t * data, uint_t channel);106 80 /** read data from a buffer 107 81 … … 113 87 114 88 */ 115 lsmp_t * *lvec_get_data(lvec_t *s);89 lsmp_t * lvec_get_data(lvec_t *s); 116 90 117 91 /** print out lvec data
Note: See TracChangeset
for help on using the changeset viewer.