shithub: dumb

Download patch

ref: a39b4d41f63ed34754bcfe94e1638ab2fe9ecb71
parent: 80e1e1a33c3b1b64012ef24a6537176ea0cc7fd0
author: Chris Moeller <kode54@gmail.com>
date: Sat Jan 10 17:15:47 EST 2015

Added a way to configure the load-time panning separation of hard panned channels, now defaulting to 25%

--- a/dumb/include/dumb.h
+++ b/dumb/include/dumb.h
@@ -768,6 +768,11 @@
 void dumb_resample_get_current_sample_n_2_2(int n, DUMB_RESAMPLER *resampler, DUMB_VOLUME_RAMP_INFO * volume_left, DUMB_VOLUME_RAMP_INFO * volume_right, sample_t *dst);
 void dumb_end_resampler_n(int n, DUMB_RESAMPLER *resampler);
 
+/* This sets the default panning separation for hard panned formats,
+   or for formats with default panning information. This must be set
+   before using any readers or loaders, and is not really thread safe. */
+
+extern int dumb_it_default_panning_separation; /* in percent, default 25 */
 
 /* DUH Construction */
 
--- a/dumb/src/it/itmisc.c
+++ b/dumb/src/it/itmisc.c
@@ -21,6 +21,8 @@
 #include "internal/it.h"
 
 
+int dumb_it_default_panning_separation = 25;
+
 
 DUMB_IT_SIGDATA *duh_get_it_sigdata(DUH *duh)
 {
--- a/dumb/src/it/read669.c
+++ b/dumb/src/it/read669.c
@@ -413,8 +413,9 @@
 	memset(sigdata->channel_volume, 64, DUMB_IT_N_CHANNELS);
 
 	for (i = 0; i < DUMB_IT_N_CHANNELS; i += 2) {
-		sigdata->channel_pan[i+0] = 48;
-		sigdata->channel_pan[i+1] = 16;
+		int sep = 32 * dumb_it_default_panning_separation / 100;
+		sigdata->channel_pan[i+0] = 32 + sep;
+		sigdata->channel_pan[i+1] = 32 - sep;
 	}
 
 	_dumb_it_fix_invalid_orders(sigdata);
--- a/dumb/src/it/readam.c
+++ b/dumb/src/it/readam.c
@@ -347,10 +347,11 @@
 	memset(sigdata->channel_volume, 64, DUMB_IT_N_CHANNELS);
 
 	for (n = 0; n < DUMB_IT_N_CHANNELS; n += 4) {
-		sigdata->channel_pan[n  ] = 16;
-		sigdata->channel_pan[n+1] = 48;
-		sigdata->channel_pan[n+2] = 48;
-		sigdata->channel_pan[n+3] = 16;
+		int sep = 32 * dumb_it_default_panning_separation / 100;
+		sigdata->channel_pan[n  ] = 32 - sep;
+		sigdata->channel_pan[n+1] = 32 + sep;
+		sigdata->channel_pan[n+2] = 32 + sep;
+		sigdata->channel_pan[n+3] = 32 - sep;
 	}
 
     for ( n = 0; (unsigned)n < stream->chunk_count; ++n )
@@ -578,10 +579,11 @@
 	memset(sigdata->channel_volume, 64, DUMB_IT_N_CHANNELS);
 
 	for (n = 0; n < DUMB_IT_N_CHANNELS; n += 4) {
-		sigdata->channel_pan[n  ] = 16;
-		sigdata->channel_pan[n+1] = 48;
-		sigdata->channel_pan[n+2] = 48;
-		sigdata->channel_pan[n+3] = 16;
+		int sep = 32 * dumb_it_default_panning_separation / 100;
+		sigdata->channel_pan[n  ] = 32 - sep;
+		sigdata->channel_pan[n+1] = 32 + sep;
+		sigdata->channel_pan[n+2] = 32 + sep;
+		sigdata->channel_pan[n+3] = 32 - sep;
 	}
 
     for ( n = 0; (unsigned)n < stream->chunk_count; ++n )
--- a/dumb/src/it/readamf.c
+++ b/dumb/src/it/readamf.c
@@ -334,8 +334,9 @@
 		}
 	}
 	else {
+		int sep = 32 * dumb_it_default_panning_separation / 100;
 		for ( i = 0; i < 16; i++ ) {
-			sigdata->channel_pan[ i ] = ( dumbfile_getc( f ) & 1 ) ? 16 : 48;
+			sigdata->channel_pan[ i ] = ( dumbfile_getc( f ) & 1 ) ? 32 - sep : 32 + sep;
 		}
 	}
 
--- a/dumb/src/it/readasy.c
+++ b/dumb/src/it/readasy.c
@@ -303,10 +303,11 @@
 	memset(sigdata->channel_volume, 64, DUMB_IT_N_CHANNELS);
 
 	for (i = 0; i < DUMB_IT_N_CHANNELS; i += 4) {
-		sigdata->channel_pan[i+0] = 16;
-		sigdata->channel_pan[i+1] = 48;
-		sigdata->channel_pan[i+2] = 48;
-		sigdata->channel_pan[i+3] = 16;
+		int sep = 32 * dumb_it_default_panning_separation / 100;
+		sigdata->channel_pan[i+0] = 32 - sep;
+		sigdata->channel_pan[i+1] = 32 + sep;
+		sigdata->channel_pan[i+2] = 32 + sep;
+		sigdata->channel_pan[i+3] = 32 - sep;
 	}
 
 	_dumb_it_fix_invalid_orders(sigdata);
--- a/dumb/src/it/readdsmf.c
+++ b/dumb/src/it/readdsmf.c
@@ -272,10 +272,11 @@
 	memset(sigdata->channel_volume, 64, DUMB_IT_N_CHANNELS);
 
 	for (n = 0; n < DUMB_IT_N_CHANNELS; n += 4) {
-		sigdata->channel_pan[n  ] = 16;
-		sigdata->channel_pan[n+1] = 48;
-		sigdata->channel_pan[n+2] = 48;
-		sigdata->channel_pan[n+3] = 16;
+		int sep = 32 * dumb_it_default_panning_separation / 100;
+		sigdata->channel_pan[n  ] = 32 - sep;
+		sigdata->channel_pan[n+1] = 32 + sep;
+		sigdata->channel_pan[n+2] = 32 + sep;
+		sigdata->channel_pan[n+3] = 32 - sep;
 	}
 
     for ( n = 0; (unsigned)n < stream->chunk_count; ++n )
--- a/dumb/src/it/readmod.c
+++ b/dumb/src/it/readmod.c
@@ -596,10 +596,11 @@
 	memset(sigdata->channel_volume, 64, DUMB_IT_N_CHANNELS);
 
 	for (i = 0; i < DUMB_IT_N_CHANNELS; i += 4) {
-		sigdata->channel_pan[i+0] = 16;
-		sigdata->channel_pan[i+1] = 48;
-		sigdata->channel_pan[i+2] = 48;
-		sigdata->channel_pan[i+3] = 16;
+		int sep = 32 * dumb_it_default_panning_separation / 100;
+		sigdata->channel_pan[i+0] = 32 - sep;
+		sigdata->channel_pan[i+1] = 32 + sep;
+		sigdata->channel_pan[i+2] = 32 + sep;
+		sigdata->channel_pan[i+3] = 32 - sep;
 	}
 
 	_dumb_it_fix_invalid_orders(sigdata);
--- a/dumb/src/it/readmtm.c
+++ b/dumb/src/it/readmtm.c
@@ -229,10 +229,11 @@
 	}
 
 	for (n = 32; n < DUMB_IT_N_CHANNELS; n += 4) {
-		sigdata->channel_pan[n  ] = 16;
-		sigdata->channel_pan[n+1] = 48;
-		sigdata->channel_pan[n+2] = 48;
-		sigdata->channel_pan[n+3] = 16;
+		int sep = 32 * dumb_it_default_panning_separation / 100;
+		sigdata->channel_pan[n  ] = 32 - sep;
+		sigdata->channel_pan[n+1] = 32 + sep;
+		sigdata->channel_pan[n+2] = 32 + sep;
+		sigdata->channel_pan[n+3] = 32 - sep;
 	}
 
 	sigdata->sample = malloc(sigdata->n_samples * sizeof(*sigdata->sample));
--- a/dumb/src/it/readoldpsm.c
+++ b/dumb/src/it/readoldpsm.c
@@ -598,10 +598,11 @@
 	memset(sigdata->channel_volume, 64, DUMB_IT_N_CHANNELS);
 
 	for (n = 0; n < DUMB_IT_N_CHANNELS; n += 4) {
-		sigdata->channel_pan[n  ] = 16;
-		sigdata->channel_pan[n+1] = 48;
-		sigdata->channel_pan[n+2] = 48;
-		sigdata->channel_pan[n+3] = 16;
+		int sep = 32 * dumb_it_default_panning_separation / 100;
+		sigdata->channel_pan[n  ] = 32 - sep;
+		sigdata->channel_pan[n+1] = 32 + sep;
+		sigdata->channel_pan[n+2] = 32 + sep;
+		sigdata->channel_pan[n+3] = 32 - sep;
 	}
 
 	for (n = 0; n < n_components; n++)
--- a/dumb/src/it/readpsm.c
+++ b/dumb/src/it/readpsm.c
@@ -659,10 +659,11 @@
 	memset(sigdata->channel_volume, 64, DUMB_IT_N_CHANNELS);
 
 	for (n = 0; n < DUMB_IT_N_CHANNELS; n += 4) {
-		sigdata->channel_pan[n  ] = 16;
-		sigdata->channel_pan[n+1] = 48;
-		sigdata->channel_pan[n+2] = 48;
-		sigdata->channel_pan[n+3] = 16;
+		int sep = 32 * dumb_it_default_panning_separation / 100;
+		sigdata->channel_pan[n  ] = 32 - sep;
+		sigdata->channel_pan[n+1] = 32 + sep;
+		sigdata->channel_pan[n+2] = 32 + sep;
+		sigdata->channel_pan[n+3] = 32 - sep;
 	}
 
 	for (n = 0; n < n_song_chunks; n++) {
--- a/dumb/src/it/reads3m.c
+++ b/dumb/src/it/reads3m.c
@@ -557,12 +557,13 @@
 	/* Channel settings for 32 channels, 255=unused, +128=disabled */
 	{
 		int i;
+		int sep = (7 * dumb_it_default_panning_separation + 50) / 100;
 		for (i = 0; i < 32; i++) {
 			int c = dumbfile_getc(f);
 			if (!(c & (128 | 16))) { /* +128=disabled, +16=Adlib */
 				if (sigdata->n_pchannels < i + 1) sigdata->n_pchannels = i + 1;
 				sigdata->channel_volume[i] = 64;
-				sigdata->channel_pan[i] = c & 8 ? 12 : 3;
+				sigdata->channel_pan[i] = c & 8 ? 7 + sep : 7 - sep;
 				/** WARNING: ah, but it should be 7 for mono... */
 			} else {
 				/** WARNING: this could be improved if we support channel muting... */
--- a/dumb/src/it/readstm.c
+++ b/dumb/src/it/readstm.c
@@ -279,10 +279,11 @@
 	}
 
 	memset( sigdata->channel_volume, 64, 4 );
-	sigdata->channel_pan[ 0 ] = 48;
-	sigdata->channel_pan[ 1 ] = 16;
-	sigdata->channel_pan[ 2 ] = 48;
-	sigdata->channel_pan[ 3 ] = 16;
+	n = 32 * dumb_it_default_panning_separation / 100;
+	sigdata->channel_pan[ 0 ] = 32 + n;
+	sigdata->channel_pan[ 1 ] = 32 - n;
+	sigdata->channel_pan[ 2 ] = 32 + n;
+	sigdata->channel_pan[ 3 ] = 32 - n;
 
 	for ( n = 0; n < sigdata->n_samples; ++n ) {
 		if ( it_stm_read_sample_header( &sigdata->sample[ n ], f, &sample_offset[ n ] ) ) {