Changeset 5181:ca57e34b2a35 in roaraudio for libroardsp/filter_highp.c
- Timestamp:
- 10/22/11 16:17:35 (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libroardsp/filter_highp.c
r4708 r5181 30 30 int roardsp_highp_init (struct roardsp_filter * filter, struct roar_stream * stream, int id) { 31 31 struct roardsp_highp * self = roar_mm_malloc(sizeof(struct roardsp_highp)); 32 float freq = 25;33 32 34 33 if ( self == NULL ) … … 39 38 filter->inst = (void*) self; 40 39 41 roardsp_highp_ctl(filter, ROARDSP_FCTL_FREQ, &freq); 42 43 return 0; 40 return roardsp_filter_reset(filter, ROARDSP_RESET_FULL); 44 41 } 45 42 … … 50 47 } 51 48 52 int roardsp_highp_calc16(struct roardsp_filter * filter, void * data, size_t samples) { 53 struct roardsp_highp * self = (struct roardsp_highp *) filter->inst; 54 int16_t * samp = (int16_t *) data; 55 register int32_t s, h; 56 int i, c; 57 int channels = filter->channels; 49 #define _calcX(bits,twobits) \ 50 int roardsp_highp_calc##bits (struct roardsp_filter * filter, void * data, size_t samples) { \ 51 struct roardsp_highp * self = (struct roardsp_highp *) filter->inst; \ 52 int##bits##_t * samp = (int##bits##_t *) data; \ 53 register int##twobits##_t s, h; \ 54 int i, c; \ 55 int channels = filter->channels; \ 56 \ 57 if ( channels > ROAR_MAX_CHANNELS ) \ 58 return -1; \ 59 \ 60 samples /= channels; \ 61 \ 62 ROAR_DBG("roardsp_highp_calc16(*): filtering %i frames of %i channels...", samples, channels); \ 63 \ 64 /* * output[N] = A0 * input[N] + A1 * input[N-1] + B1 * output[N-1] */ \ 65 \ 66 \ 67 for (i = 0; i < samples; i++) { \ 68 for (c = 0; c < channels; c++) { \ 69 h = samp[i*channels + c]; \ 70 s = (int##twobits##_t)samp[i*channels + c] * self->a + (int##twobits##_t)self->oldin[c] * self->b + (int##twobits##_t)self->oldout[c] * self->c; \ 71 \ 72 s /= 65536; \ 73 \ 74 self->oldin[ c] = h; \ 75 samp[i*channels + c] = s; \ 76 self->oldout[ c] = s; \ 77 } \ 78 } \ 79 \ 80 return 0; \ 81 } 58 82 59 if ( channels > ROAR_MAX_CHANNELS ) 60 return -1; 61 62 samples /= channels; 63 64 ROAR_DBG("roardsp_highp_calc16(*): filtering %i frames of %i channels...", samples, channels); 65 66 // * output[N] = A0 * input[N] + A1 * input[N-1] + B1 * output[N-1] 67 68 69 for (i = 0; i < samples; i++) { 70 for (c = 0; c < channels; c++) { 71 h = samp[i*channels + c]; 72 s = samp[i*channels + c] * self->a + self->oldin[c] * self->b + self->oldout[c] * self->c; 73 74 s /= 65536; 75 76 self->oldin[ c] = h; 77 samp[i*channels + c] = s; 78 self->oldout[ c] = s; 79 } 80 } 81 82 return 0; 83 } 83 _calcX(8,32) /* we need 32 bit not 16 bit here as we multiplay with 65536 internally */ 84 _calcX(16,32) 85 _calcX(32,64) 84 86 85 87 int roardsp_highp_ctl (struct roardsp_filter * filter, int cmd, void * data) { … … 114 116 int roardsp_highp_reset (struct roardsp_filter * filter, int what) { 115 117 struct roardsp_highp * self; 116 float freq = 25 ;118 float freq = 25.; 117 119 118 120 if ( filter == NULL )
Note: See TracChangeset
for help on using the changeset viewer.