Changeset 59c046d for src/temporal
- Timestamp:
- Oct 19, 2009, 1:52:04 PM (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:
- b01bd4a
- Parents:
- b14107f
- Location:
- src/temporal
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/temporal/a_weighting.c
rb14107f r59c046d 1 1 /* 2 3 2 Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org> 4 3 … … 27 26 #include "temporal/a_weighting.h" 28 27 29 uint_t aubio_filter_set_a_weighting (aubio_filter_t * f) { 30 31 uint_t samplerate = aubio_filter_get_samplerate (f); 28 uint_t 29 aubio_filter_set_a_weighting (aubio_filter_t * f, uint_t samplerate) 30 { 31 aubio_filter_set_samplerate (f, samplerate); 32 32 lvec_t *bs = aubio_filter_get_feedforward (f); 33 33 lvec_t *as = aubio_filter_get_feedback (f); … … 35 35 uint_t order = aubio_filter_get_order (f); 36 36 37 if ( order != 7) {38 AUBIO_ERROR ( "order of A-weighting filter must be 7, not %d\n", order);37 if (order != 7) { 38 AUBIO_ERROR ("order of A-weighting filter must be 7, not %d\n", order); 39 39 return 1; 40 40 } 41 41 42 42 /* select coefficients according to sampling frequency */ 43 switch ( samplerate ) { 44 45 // adsgn 8000 43 switch (samplerate) { 44 46 45 case 8000: 47 46 b[0] = 6.306209468238731519207362907764036208391189575195312500e-01; … … 61 60 break; 62 61 63 // adsgn 1102564 62 case 11025: 65 63 b[0] = 6.014684165832374640459079273568931967020034790039062500e-01; … … 79 77 break; 80 78 81 // adsgn 1600082 79 case 16000: 83 80 b[0] = 5.314898298235570806014038680586963891983032226562500000e-01; … … 97 94 break; 98 95 99 // adsgn 22050100 96 case 22050: 101 97 b[0] = 4.492998504299193784916610638902056962251663208007812500e-01; … … 115 111 break; 116 112 117 // adsgn 24000118 113 case 24000: 119 114 b[0] = 4.256263892891054001488271296693710610270500183105468750e-01; … … 133 128 break; 134 129 135 // adsgn 32000136 130 case 32000: 137 131 b[0] = 3.434583386824304196416335344110848382115364074707031250e-01; … … 151 145 break; 152 146 153 // adsgn 44100154 147 case 44100: 155 148 b[0] = 2.557411252042575133813784304948057979345321655273437500e-01; … … 169 162 break; 170 163 171 // adsgn 48000172 164 case 48000: 173 165 b[0] = 2.343017922995132285013397677175817079842090606689453125e-01; … … 187 179 break; 188 180 189 // adsgn 88200190 181 case 88200: 191 182 b[0] = 1.118876366882113199130444058937428053468465805053710938e-01; … … 205 196 break; 206 197 207 // adsgn 96000208 198 case 96000: 209 199 b[0] = 9.951898975972744976203898659150581806898117065429687500e-02; … … 223 213 break; 224 214 225 // adsgn 192000226 215 case 192000: 227 216 b[0] = 3.433213424548713782469278044118254911154508590698242188e-02; … … 241 230 break; 242 231 243 default: 244 AUBIO_ERROR ( "sampling rate of A-weighting filter is %d, should be one of\ 245 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88200, 96000, 192000.\n", 246 samplerate ); 232 default: 233 AUBIO_ERROR ("sampling rate of A-weighting filter is %d, should be one of\ 234 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88200, 96000, 192000.\n", samplerate); 247 235 return 1; 248 236 … … 252 240 } 253 241 254 aubio_filter_t * new_aubio_filter_a_weighting (uint_t samplerate, uint_t channels) { 255 aubio_filter_t * f = new_aubio_filter (samplerate, 7, channels); 256 aubio_filter_set_a_weighting (f); 242 aubio_filter_t * 243 new_aubio_filter_a_weighting (uint_t channels, uint_t samplerate) 244 { 245 aubio_filter_t *f = new_aubio_filter (7, channels); 246 aubio_filter_set_a_weighting (f, samplerate); 257 247 return f; 258 248 } 259 -
src/temporal/a_weighting.h
rb14107f r59c046d 69 69 70 70 */ 71 aubio_filter_t * new_aubio_filter_a_weighting (uint_t samplerate, uint_t channels); 71 aubio_filter_t *new_aubio_filter_a_weighting (uint_t channels, 72 uint_t samplerate); 72 73 73 74 /** set feedback and feedforward coefficients of a A-weighting filter … … 76 77 77 78 */ 78 uint_t aubio_filter_set_a_weighting (aubio_filter_t *f );79 uint_t aubio_filter_set_a_weighting (aubio_filter_t *f, uint_t samplerate); 79 80 80 81 #ifdef __cplusplus -
src/temporal/c_weighting.c
rb14107f r59c046d 26 26 #include "temporal/c_weighting.h" 27 27 28 uint_t aubio_filter_set_c_weighting (aubio_filter_t * f) { 29 30 uint_t samplerate = aubio_filter_get_samplerate (f); 31 lvec_t * bs = aubio_filter_get_feedforward (f); 32 lvec_t * as = aubio_filter_get_feedback (f); 28 uint_t 29 aubio_filter_set_c_weighting (aubio_filter_t * f, uint_t samplerate) 30 { 31 aubio_filter_set_samplerate (f, samplerate); 32 lvec_t *bs = aubio_filter_get_feedforward (f); 33 lvec_t *as = aubio_filter_get_feedback (f); 33 34 lsmp_t *b = bs->data[0], *a = as->data[0]; 34 35 uint_t order = aubio_filter_get_order (f); 35 36 36 37 if ( order != 5 ) { 37 AUBIO_ERROR ( "order of C-weighting filter must be 5, not %d\n", order);38 AUBIO_ERROR ("order of C-weighting filter must be 5, not %d\n", order); 38 39 return 1; 39 40 } 40 41 41 42 /* select coefficients according to sampling frequency */ 42 switch ( samplerate ) { 43 44 // cdsgn 8000 43 switch (samplerate) { 44 45 45 case 8000: 46 46 b[0] = 6.782173932405135552414776611840352416038513183593750000e-01; … … 56 56 break; 57 57 58 // cdsgn 1102559 58 case 11025: 60 59 b[0] = 6.002357155402652244546857218665536493062973022460937500e-01; … … 70 69 break; 71 70 72 // cdsgn 1600073 71 case 16000: 74 72 b[0] = 4.971057193673903418229542694461997598409652709960937500e-01; … … 84 82 break; 85 83 86 // cdsgn 2205087 84 case 22050: 88 85 b[0] = 4.033381299002754549754001800465630367398262023925781250e-01; … … 98 95 break; 99 96 100 // cdsgn 24000101 97 case 24000: 102 98 b[0] = 3.786678621924967069745093795063439756631851196289062500e-01; … … 112 108 break; 113 109 114 // cdsgn 32000115 110 case 32000: 116 111 b[0] = 2.977986488230693340462096330156782642006874084472656250e-01; … … 126 121 break; 127 122 128 // cdsgn 44100129 123 case 44100: 130 124 b[0] = 2.170085619492190254220531642204150557518005371093750000e-01; … … 140 134 break; 141 135 142 // cdsgn 48000143 136 case 48000: 144 137 b[0] = 1.978871200263932761398422144338837824761867523193359375e-01; … … 154 147 break; 155 148 156 // cdsgn 88200157 149 case 88200: 158 150 b[0] = 9.221909851156021020734954163344809785485267639160156250e-02; … … 168 160 break; 169 161 170 // cdsgn 96000171 162 case 96000: 172 163 b[0] = 8.182864044979756834585771230194950476288795471191406250e-02; … … 182 173 break; 183 174 184 // cdsgn 192000185 175 case 192000: 186 176 b[0] = 2.784755468532278815940728122768632601946592330932617188e-02; … … 207 197 } 208 198 209 aubio_filter_t * new_aubio_filter_c_weighting (uint_t samplerate, uint_t channels) {210 aubio_filter_t * f = new_aubio_filter( samplerate,5, channels);211 aubio_filter_set_c_weighting (f );199 aubio_filter_t * new_aubio_filter_c_weighting (uint_t channels, uint_t samplerate) { 200 aubio_filter_t * f = new_aubio_filter(5, channels); 201 aubio_filter_set_c_weighting (f, samplerate); 212 202 return f; 213 203 } -
src/temporal/c_weighting.h
rb14107f r59c046d 69 69 70 70 */ 71 aubio_filter_t * new_aubio_filter_c_weighting (uint_t samplerate, uint_t channels);71 aubio_filter_t * new_aubio_filter_c_weighting (uint_t channels, uint_t samplerate); 72 72 73 73 /** set feedback and feedforward coefficients of a C-weighting filter … … 76 76 77 77 */ 78 uint_t aubio_filter_set_c_weighting (aubio_filter_t *f );78 uint_t aubio_filter_set_c_weighting (aubio_filter_t *f, uint_t samplerate); 79 79 80 80 #ifdef __cplusplus -
src/temporal/filter.c
rb14107f r59c046d 138 138 } 139 139 140 uint_t 141 aubio_filter_set_samplerate (aubio_filter_t * f, uint_t samplerate) 142 { 143 f->samplerate = samplerate; 144 return AUBIO_OK; 145 } 146 140 147 aubio_filter_t * 141 new_aubio_filter (uint_t samplerate, uint_torder, uint_t channels)148 new_aubio_filter (uint_t order, uint_t channels) 142 149 { 143 150 aubio_filter_t *f = AUBIO_NEW (aubio_filter_t); … … 146 153 f->a = new_lvec (order, 1); 147 154 f->b = new_lvec (order, 1); 148 f->samplerate = samplerate; 155 /* by default, samplerate is not set */ 156 f->samplerate = 0; 149 157 f->order = order; 150 158 /* set default to identity */ -
src/temporal/filter.h
rb14107f r59c046d 131 131 uint_t aubio_filter_get_samplerate (aubio_filter_t * f); 132 132 133 /** get sampling rate of the filter 134 135 \param f filter to get sampling rate from 136 \param samplerate sample rate to set the filter to 137 138 \return the sampling rate of the filter, in Hz 139 140 */ 141 uint_t aubio_filter_set_samplerate (aubio_filter_t * f, uint_t samplerate); 142 133 143 /** create new filter object 134 144 … … 143 153 144 154 */ 145 aubio_filter_t *new_aubio_filter (uint_t samplerate, uint_t order, 146 uint_t channels); 155 aubio_filter_t *new_aubio_filter (uint_t order, uint_t channels); 147 156 148 157 /** delete a filter object
Note: See TracChangeset
for help on using the changeset viewer.