Changeset 741bdda for src/temporal/filter.c
- Timestamp:
- Dec 4, 2009, 1:39:30 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:
- d207300
- Parents:
- d95ff38
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/temporal/filter.c
rd95ff38 r741bdda 49 49 aubio_filter_do (aubio_filter_t * f, fvec_t * in) 50 50 { 51 uint_t i,j, l, order = f->order;52 lsmp_t *x ;53 lsmp_t *y ;54 lsmp_t *a = f->a->data [0];55 lsmp_t *b = f->b->data [0];51 uint_t j, l, order = f->order; 52 lsmp_t *x = f->x->data; 53 lsmp_t *y = f->y->data; 54 lsmp_t *a = f->a->data; 55 lsmp_t *b = f->b->data; 56 56 57 for (i = 0; i < in->channels; i++) { 58 x = f->x->data[i]; 59 y = f->y->data[i]; 60 for (j = 0; j < in->length; j++) { 61 /* new input */ 62 x[0] = KILL_DENORMAL (in->data[i][j]); 63 y[0] = b[0] * x[0]; 64 for (l = 1; l < order; l++) { 65 y[0] += b[l] * x[l]; 66 y[0] -= a[l] * y[l]; 67 } 68 /* new output */ 69 in->data[i][j] = y[0]; 70 /* store for next sample */ 71 for (l = order - 1; l > 0; l--) { 72 x[l] = x[l - 1]; 73 y[l] = y[l - 1]; 74 } 57 for (j = 0; j < in->length; j++) { 58 /* new input */ 59 x[0] = KILL_DENORMAL (in->data[j]); 60 y[0] = b[0] * x[0]; 61 for (l = 1; l < order; l++) { 62 y[0] += b[l] * x[l]; 63 y[0] -= a[l] * y[l]; 75 64 } 76 /* store for next run */ 77 f->x->data[i] = x; 78 f->y->data[i] = y; 65 /* new output */ 66 in->data[j] = y[0]; 67 /* store for next sample */ 68 for (l = order - 1; l > 0; l--) { 69 x[l] = x[l - 1]; 70 y[l] = y[l - 1]; 71 } 79 72 } 80 73 } … … 84 77 aubio_filter_do_filtfilt (aubio_filter_t * f, fvec_t * in, fvec_t * tmp) 85 78 { 86 uint_t j , i = 0;79 uint_t j; 87 80 uint_t length = in->length; 88 81 /* apply filtering */ … … 91 84 /* mirror */ 92 85 for (j = 0; j < length; j++) 93 tmp->data[ i][length - j - 1] = in->data[i][j];86 tmp->data[length - j - 1] = in->data[j]; 94 87 /* apply filtering on mirrored */ 95 88 aubio_filter_do (f, tmp); … … 97 90 /* invert back */ 98 91 for (j = 0; j < length; j++) 99 in->data[ i][j] = tmp->data[i][length - j - 1];92 in->data[j] = tmp->data[length - j - 1]; 100 93 } 101 94 … … 139 132 140 133 aubio_filter_t * 141 new_aubio_filter (uint_t order , uint_t channels)134 new_aubio_filter (uint_t order) 142 135 { 143 136 aubio_filter_t *f = AUBIO_NEW (aubio_filter_t); 144 f->x = new_lvec (order , channels);145 f->y = new_lvec (order , channels);146 f->a = new_lvec (order , 1);147 f->b = new_lvec (order , 1);137 f->x = new_lvec (order); 138 f->y = new_lvec (order); 139 f->a = new_lvec (order); 140 f->b = new_lvec (order); 148 141 /* by default, samplerate is not set */ 149 142 f->samplerate = 0; 150 143 f->order = order; 151 144 /* set default to identity */ 152 f->a->data[ 0][1] = 1.;145 f->a->data[1] = 1.; 153 146 return f; 154 147 }
Note: See TracChangeset
for help on using the changeset viewer.