ref: cc986aa7dad019e2e4f8fe2d42013e50a1cd79d6
parent: 9a68144bfcd970e257b37ccc001d58c23cbe007e
parent: 8ba1f7e7c01eef9dac7dd79cf2026ae9c3364b8d
author: Chris Moeller <kode54@gmail.com>
date: Tue Feb 19 16:10:15 EST 2013
Fixed shit
--- a/dumb/src/it/itread.c
+++ b/dumb/src/it/itread.c
@@ -109,7 +109,7 @@
/** WARNING - do we even need to pass `right`? */
/** WARNING - why bother memsetting at all? The whole array is written... */
// if we do memset, dumb_silence() would be neater...
-static int decompress8(DUMBFILE *f, signed char *data, int len, int it215)
+static int decompress8(DUMBFILE *f, signed char *data, int len, int it215, int stereo)
{
int blocklen, blockpos;
byte bitwidth;
@@ -119,7 +119,8 @@
memset(&crap, 0, sizeof(crap));
- memset(data, 0, len * sizeof(*data));
+ for (blocklen = 0, blockpos = 0; blocklen < len; blocklen++, blockpos += 1 + stereo)
+ data[ blockpos ] = 0;
while (len > 0) {
//Read a block of compressed data:
@@ -185,6 +186,7 @@
* code. Yay, better compression :D
*/
*data++ = it215 ? d2 : d1;
+ data += stereo;
len--;
blockpos++;
}
@@ -195,7 +197,7 @@
-static int decompress16(DUMBFILE *f, short *data, int len, int it215)
+static int decompress16(DUMBFILE *f, short *data, int len, int it215, int stereo)
{
int blocklen, blockpos;
byte bitwidth;
@@ -205,7 +207,8 @@
memset(&crap, 0, sizeof(crap));
- memset(data, 0, len * sizeof(*data));
+ for ( blocklen = 0, blockpos = 0; blocklen < len; blocklen++, blockpos += 1 + stereo )
+ data[ blockpos ] = 0;
while (len > 0) {
//Read a block of compressed data:
@@ -270,6 +273,7 @@
* code. Yay, better compression :D
*/
*data++ = it215 ? d2 : d1;
+ data += stereo;
len--;
blockpos++;
}
@@ -652,21 +656,22 @@
} else if (sample->flags & 8) {
/* If the sample is packed, then we must unpack it. */
- /** WARNING - unresolved business here... test with ModPlug? */
+ /* Behavior as defined by greasemonkey's munch.py and observed by XMPlay and OpenMPT */
- if (sample->flags & IT_SAMPLE_STEREO)
- //exit(37); // TODO: if this ever happens, maybe sample->length should be doubled below?
- return -1;
-
-/*
-//#ifndef STEREO_SAMPLES_COUNT_AS_TWO
- ASSERT(!(sample->flags & IT_SAMPLE_STEREO));
-//#endif
-*/
- if (sample->flags & IT_SAMPLE_16BIT)
- decompress16(f, sample->data, datasize, ((cmwt >= 0x215) && (convert & 4)));
- else
- decompress8(f, sample->data, datasize, ((cmwt >= 0x215) && (convert & 4)));
+ if (sample->flags & IT_SAMPLE_STEREO) {
+ if (sample->flags & IT_SAMPLE_16BIT) {
+ decompress16(f, (short *) sample->data, datasize >> 1, ((cmwt >= 0x215) && (convert & 4)), 1);
+ decompress16(f, (short *) sample->data + 1, datasize >> 1, ((cmwt >= 0x215) && (convert & 4)), 1);
+ } else {
+ decompress8(f, (signed char *) sample->data, datasize >> 1, ((cmwt >= 0x215) && (convert & 4)), 1);
+ decompress8(f, (signed char *) sample->data + 1, datasize >> 1, ((cmwt >= 0x215) && (convert & 4)), 1);
+ }
+ } else {
+ if (sample->flags & IT_SAMPLE_16BIT)
+ decompress16(f, (short *) sample->data, datasize, ((cmwt >= 0x215) && (convert & 4)), 0);
+ else
+ decompress8(f, (signed char *) sample->data, datasize, ((cmwt >= 0x215) && (convert & 4)), 0);
+ }
} else if (sample->flags & IT_SAMPLE_16BIT) {
if (sample->flags & IT_SAMPLE_STEREO) {
if (convert & 2) {
--- a/dumb/src/it/itrender.c
+++ b/dumb/src/it/itrender.c
@@ -3980,20 +3980,20 @@
{
DUMB_IT_SIGDATA * sigdata = sigrenderer->sigdata;
int pan;
- float vol, span;
-
- if ((sigrenderer->n_channels == 2) && (sigdata->flags & IT_STEREO)) {
- pan = apply_pan_envelope(playing);
- span = pan * sigdata->pan_separation * (1.0f / ((64<<8) * 128));
- vol = 1.0;
- if (!IT_IS_SURROUND_SHIFTED(pan)) vol -= span;
- playing->float_volume[0] = vol;
- vol = -1.0;
- if (!IT_IS_SURROUND_SHIFTED(pan)) vol = span;
- playing->float_volume[1] = vol;
- } else {
- playing->float_volume[0] = 1.0f;
- playing->float_volume[1] = 1.0f;
+ float vol, span;
+
+ if ((sigrenderer->n_channels == 2) && (sigdata->flags & IT_STEREO)) {
+ pan = apply_pan_envelope(playing);
+ span = (pan - (32<<8)) * sigdata->pan_separation * (1.0f / ((32<<8) * 128));
+ vol = 0.5f;
+ if (!IT_IS_SURROUND_SHIFTED(pan)) vol *= 1.0f - span;
+ playing->float_volume[0] = vol;
+ vol = -vol;
+ if (!IT_IS_SURROUND_SHIFTED(pan)) vol += 1.0f;
+ playing->float_volume[1] = vol;
+ } else {
+ playing->float_volume[0] = 1.0f;
+ playing->float_volume[1] = 1.0f;
}
vol = calculate_volume(sigrenderer, playing, 1.0f);