From c5a90f0f4231a3ec635d332db12686ffc83d3e1e Mon Sep 17 00:00:00 2001 From: mescalinum Date: Thu, 19 Aug 2010 22:35:25 +0000 Subject: messing up with samplerate svn path=/trunk/externals/ffext/; revision=13848 --- tms5220~/tms5220~.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'tms5220~/tms5220~.c') diff --git a/tms5220~/tms5220~.c b/tms5220~/tms5220~.c index ce119cd..ae9e630 100644 --- a/tms5220~/tms5220~.c +++ b/tms5220~/tms5220~.c @@ -80,20 +80,28 @@ t_int *tms5220_tilde_perform(t_int *w) { t_sample *out = (t_sample *)(w[3]); int n = (int)(w[4]); - unsigned char *bytebuf = (unsigned char *)malloc(sizeof(unsigned char)*n); + //TODO: figure out proper resampling here: +#define RESAMPLE_FACTOR 8 + int rc = 0; // resample counter + + unsigned char *bytebuf = (unsigned char *)malloc(sizeof(unsigned char)*n/RESAMPLE_FACTOR); if(!bytebuf) {error("FATAL: cannot allocate signal buffer"); return w;} - tms5220_process(bytebuf, n); + tms5220_process(bytebuf, n/RESAMPLE_FACTOR); unsigned char *pb = bytebuf; - while (n--) *out++ = (0.5+((t_sample)*pb++))/127.5; + while (n--) { + //FIXME: resampling without alias, please + *out++ = (0.5 + ((t_sample) *pb)) / 127.5; + if(!(rc = ((rc + 1) % RESAMPLE_FACTOR))) pb++; + } free(bytebuf); tms5220_tilde_update_status(x); - return (w+5); + return (w + 5); } void tms5220_tilde_dsp(t_tms5220_tilde *x, t_signal **sp) { -- cgit v1.2.1