Changeset 673:69300e477dca in roaraudio
- Timestamp:
- 08/27/08 14:33:28 (16 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
include/libroardsp/libroardsp.h
r672 r673 26 26 int channels; 27 27 int bits; 28 int rate; 28 29 void * inst; 29 30 int (*calc )(struct roardsp_filter * filter, void * data, size_t samples); -
libroardsp/filter.c
r671 r673 77 77 filter->channels = stream->info.channels; 78 78 filter->bits = stream->info.bits; 79 filter->rate = stream->info.rate; 79 80 80 81 bytes = stream->info.bits / 8; -
libroardsp/filter_lowp.c
r666 r673 25 25 #include "libroardsp.h" 26 26 27 int roardsp_lowp_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); 28 int roardsp_lowp_uninit(struct roardsp_filter * filter); 29 int roardsp_lowp_calc (struct roardsp_filter * filter, void * data, size_t samples); 27 int roardsp_lowp_init (struct roardsp_filter * filter, struct roar_stream * stream, int id) { 28 struct roardsp_lowp * self = malloc(sizeof(struct roardsp_lowp)); 29 float freq = 25; 30 31 if ( self == NULL ) 32 return -1; 33 34 memset(self, 0, sizeof(struct roardsp_lowp)); 35 36 filter->inst = (void*) self; 37 38 roardsp_lowp_ctl(filter, ROARDSP_FCTL_FREQ, &freq); 39 40 return 0; 41 } 42 43 int roardsp_lowp_uninit(struct roardsp_filter * filter) { 44 45 free(filter->inst); 46 return 0; 47 } 48 49 int roardsp_lowp_calc16 (struct roardsp_filter * filter, void * data, size_t samples) { 50 struct roardsp_lowp * self = (struct roardsp_lowp *) filter->inst; 51 int16_t * samp = (int16_t *) data; 52 register int32_t s; 53 int i, c; 54 int channels = filter->channels; 55 56 if ( channels > ROAR_MAX_CHANNELS ) 57 return -1; 58 59 samples /= channels; 60 61 // * output[N] = input[N] * A + output[N-1] * B 62 63 for (i = 0; i < samples; i++) { 64 for (c = 0; c < channels; c++) { 65 s = samp[i*channels + c] * self->a + self->old[c] * self->b; 66 67 s /= 65536; 68 69 samp[i*channels + c] = s; 70 self->old[ c] = s; 71 } 72 } 73 74 return 0; 75 } 76 77 int roardsp_lowp_ctl (struct roardsp_filter * filter, int cmd, void * data) { 78 struct roardsp_lowp * self = (struct roardsp_lowp *) filter->inst; 79 float lp; 80 float oldfreq; 81 82 if ( cmd != ROARDSP_FCTL_FREQ ) 83 return -1; 84 85 lp = exp(-2 * M_PI * *(float*)data / filter->rate) * 65536; 86 87 self->b = lp; 88 self->a = 65536 - lp; 89 90 oldfreq = self->freq / 1000; 91 self->freq = *(float*)data * 1000; 92 93 *(float*)data = oldfreq; 94 95 return 0; 96 } 30 97 31 98 //ll
Note: See TracChangeset
for help on using the changeset viewer.