Changeset a7667ce for src/temporal/filter.c
- Timestamp:
- Dec 1, 2007, 10:59:25 PM (17 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:
- 6913434
- Parents:
- 2b6144dd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/temporal/filter.c
r2b6144dd ra7667ce 24 24 #include "aubio_priv.h" 25 25 #include "fvec.h" 26 #include "lvec.h" 26 27 #include "mathutils.h" 27 28 #include "temporal/filter.h" 28 29 #include "temporal/filter_priv.h" 29 30 30 /* bug: mono only */31 31 void aubio_filter_do(aubio_filter_t * f, fvec_t * in) { 32 uint_t i,j,l, order = f->order; 33 lsmp_t *x = f->x; 34 lsmp_t *y = f->y; 35 lsmp_t *a = f->a; 36 lsmp_t *b = f->b; 37 i=0;//for (i=0;i<in->channels;i++) { 38 for (j = 0; j < in->length; j++) { 39 /* new input */ 40 //AUBIO_DBG("befor %f\t", in->data[i][j]); 41 x[0] = in->data[i][j]; 42 y[0] = b[0] * x[0]; 43 for (l=1;l<order; l++) { 44 y[0] += b[l] * x[l]; 45 y[0] -= a[l] * y[l]; 46 } /* + 1e-37; for denormal ? */ 47 /* new output */ 48 in->data[i][j] = y[0]; 49 //AUBIO_DBG("after %f\n", in->data[i][j]); 50 /* store states for next sample */ 51 for (l=order-1; l>0; l--){ 52 x[l] = x[l-1]; 53 y[l] = y[l-1]; 54 } 55 } 56 /* store states for next buffer */ 57 f->x = x; 58 f->y = y; 59 //} 32 aubio_filter_do_outplace(f, in, in); 60 33 } 61 34 62 35 void aubio_filter_do_outplace(aubio_filter_t * f, fvec_t * in, fvec_t * out) { 63 36 uint_t i,j,l, order = f->order; 64 lsmp_t *x = f->x;65 lsmp_t *y = f->y;66 lsmp_t *a = f->a ;67 lsmp_t *b = f->b ;37 lsmp_t *x; 38 lsmp_t *y; 39 lsmp_t *a = f->a->data[0]; 40 lsmp_t *b = f->b->data[0]; 68 41 69 i=0; // works in mono only !!! 70 //for (i=0;i<in->channels;i++) { 71 for (j = 0; j < in->length; j++) { 72 /* new input */ 73 x[0] = in->data[i][j]; 74 y[0] = b[0] * x[0]; 75 for (l=1;l<order; l++) { 76 y[0] += b[l] * x[l]; 77 y[0] -= a[l] * y[l]; 42 for (i = 0; i < in->channels; i++) { 43 x = f->x->data[i]; 44 y = f->y->data[i]; 45 for (j = 0; j < in->length; j++) { 46 /* new input */ 47 if (ISDENORMAL(in->data[i][j])) { 48 x[0] = y[0] = 0.; 49 } else { 50 x[0] = in->data[i][j]; 51 y[0] = b[0] * x[0]; 52 for (l=1;l<order; l++) { 53 y[0] += b[l] * x[l]; 54 y[0] -= a[l] * y[l]; 55 } 56 } 57 /* new output */ 58 out->data[i][j] = y[0]; 59 /* store for next sample */ 60 for (l=order-1; l>0; l--){ 61 x[l] = x[l-1]; 62 y[l] = y[l-1]; 63 } 78 64 } 79 // + 1e-37; 80 /* new output */ 81 out->data[i][j] = y[0]; 82 /* store for next sample */ 83 for (l=order-1; l>0; l--){ 84 x[l] = x[l-1]; 85 y[l] = y[l-1]; 86 } 65 /* store for next run */ 66 f->x->data[i] = x; 67 f->y->data[i] = y; 87 68 } 88 /* store for next run */89 f->x = x;90 f->y = y;91 //}92 69 } 93 70 … … 126 103 } 127 104 128 aubio_filter_t * new_aubio_filter(uint_t samplerate UNUSED, uint_t order ) {105 aubio_filter_t * new_aubio_filter(uint_t samplerate UNUSED, uint_t order, uint_t channels) { 129 106 aubio_filter_t * f = AUBIO_NEW(aubio_filter_t); 130 lsmp_t * x = f->x;131 lsmp_t * y = f->y;132 lsmp_t * a = f->a;133 lsmp_t * b = f->b;134 uint_t l;107 f->x = new_lvec(order, channels); 108 f->y = new_lvec(order, channels); 109 f->a = new_lvec(order, 1); 110 f->b = new_lvec(order, 1); 111 f->a->data[0][1] = 1.; 135 112 f->order = order; 136 a = AUBIO_ARRAY(lsmp_t,f->order);137 b = AUBIO_ARRAY(lsmp_t,f->order);138 x = AUBIO_ARRAY(lsmp_t,f->order);139 y = AUBIO_ARRAY(lsmp_t,f->order);140 /* initial states to zeros */141 for (l=0; l<f->order; l++){142 x[l] = 0.;143 y[l] = 0.;144 }145 f->x = x;146 f->y = y;147 f->a = a;148 f->b = b;149 113 return f; 150 114 }
Note: See TracChangeset
for help on using the changeset viewer.