diff options
author | mescalinum <mescalinum@users.sourceforge.net> | 2010-08-19 22:35:25 +0000 |
---|---|---|
committer | mescalinum <mescalinum@users.sourceforge.net> | 2010-08-19 22:35:25 +0000 |
commit | c5a90f0f4231a3ec635d332db12686ffc83d3e1e (patch) | |
tree | 5a9d90cac27d5e7a907700f9d918a14cb10cac1b /tms5220~ | |
parent | c725c0f989d6c9f8af0d04f017efb8eef03c3574 (diff) |
messing up with samplerate
svn path=/trunk/externals/ffext/; revision=13848
Diffstat (limited to 'tms5220~')
-rw-r--r-- | tms5220~/tms5220~.c | 16 |
1 files changed, 12 insertions, 4 deletions
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) { |