Changeset 66fb3ea for src/cvec.c
- Timestamp:
- Dec 4, 2009, 1:33:06 AM (14 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
- File:
-
- 1 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 }
Note: See TracChangeset
for help on using the changeset viewer.