From a8e4c9dbbf1cf403d157a0cc74cb4d8501fd7e73 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Sun, 11 Jan 2015 16:16:42 -0800 Subject: [PATCH] Bugfix for playptmod --- Frameworks/playptmod/playptmod/playptmod.c | 29 ++++++---------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/Frameworks/playptmod/playptmod/playptmod.c b/Frameworks/playptmod/playptmod/playptmod.c index 5d3348495..a427d88c3 100644 --- a/Frameworks/playptmod/playptmod/playptmod.c +++ b/Frameworks/playptmod/playptmod/playptmod.c @@ -242,7 +242,6 @@ typedef struct float *mixBufferL; float *mixBufferR; void * blep[MAX_CHANNELS]; - void * blepVol[MAX_CHANNELS]; unsigned int orderPlayed[256]; MODULE *source; } player; @@ -472,7 +471,6 @@ static void mixerSetChSource(player *p, int ch, const signed char *src, int leng v->interpolating = 1; resampler_clear(p->blep[ch]); - resampler_clear(p->blepVol[ch]); // Check external 9xx usage (Set Sample Offset) if (v->loopFlag) @@ -529,7 +527,6 @@ static void mixerCutChannels(player *p) for (i = 0; i < MAX_CHANNELS; ++i) { resampler_clear(p->blep[i]); - resampler_clear(p->blepVol[i]); } memset(&p->filter, 0, sizeof (p->filter)); @@ -570,7 +567,6 @@ static void outputAudio(player *p, int *target, int numSamples) Voice *v; void *bSmp; - void *bVol; memset(p->mixBufferL, 0, numSamples * sizeof (float)); memset(p->mixBufferR, 0, numSamples * sizeof (float)); @@ -581,26 +577,21 @@ static void outputAudio(player *p, int *target, int numSamples) v = &p->v[i]; bSmp = p->blep[i]; - bVol = p->blepVol[i]; if (v->data && v->rate) { step = v->step; interpolating = v->interpolating; resampler_set_rate(bSmp, v->rate); - resampler_set_rate(bVol, v->rate); for (j = 0; j < numSamples;) { - tempVolume = (v->data && !v->mute ? v->vol : 0); - while (interpolating && (resampler_get_free_count(bSmp) || !resampler_get_sample_count(bSmp))) { tempSample = (v->data ? (step == 2 ? (v->data[v->index] + v->data[v->index + 1] * 0x100) : v->data[v->index] * 0x100) : 0); resampler_write_sample_fixed(bSmp, tempSample, 1); - resampler_write_sample_fixed(bVol, tempVolume, 1); if (v->data) { @@ -667,11 +658,12 @@ static void outputAudio(player *p, int *target, int numSamples) v->interpolating = interpolating; + tempVolume = (v->data && !v->mute ? v->vol : 0); + while (j < numSamples && resampler_get_sample_count(bSmp)) { - t_vol = resampler_get_sample_float(bVol); + t_vol = tempVolume; t_smp = resampler_get_sample_float(bSmp); - resampler_remove_sample(bVol, 0); resampler_remove_sample(bSmp, 1); t_smp *= t_vol; @@ -683,7 +675,7 @@ static void outputAudio(player *p, int *target, int numSamples) j++; } - if (!interpolating && j < numSamples) + if (!interpolating) { v->data = NULL; break; @@ -693,10 +685,10 @@ static void outputAudio(player *p, int *target, int numSamples) } if (p->numChans <= 4) - downscale = 1.0f / 172.0f; + downscale = 1.0f / 194.0f; else - downscale = 1.0f / 208.0f; - + downscale = 1.0f / 234.0f; + out = target; for (i = 0; i < numSamples; ++i) @@ -2808,12 +2800,6 @@ void *playptmod_Create(int samplingFrequency) resampler_set_quality(p->blep[i], RESAMPLER_QUALITY_BLEP); } - for (i = 0; i < MAX_CHANNELS; ++i) - { - p->blepVol[i] = resampler_create(); - resampler_set_quality(p->blepVol[i], RESAMPLER_QUALITY_BLEP); - } - mixerCutChannels(p); return p; @@ -2950,7 +2936,6 @@ void playptmod_Free(void *_p) for (i = 0; i < MAX_CHANNELS; ++i) { resampler_delete(p->blep[i]); - resampler_delete(p->blepVol[i]); } free(p);