shithub: dumb

Download patch

ref: c0fc19ef2e756ef25aa44ca3775b4afed3f02c9c
parent: bf42c55a9ad494b3bcbee5dc2959f03c1938fdfb
author: Chris Moeller <[email protected]>
date: Tue Jan 11 13:57:59 EST 2011

- Changed aliased resampler loop conditions a bit to fix some bugs
- Removed resampler loop unrolling, as it actually made things slightly slower
- Fixed a bug with songs triggering notes on the first order with instrument changes before any note commands have been triggered
- Version is now 0.9.9.24

git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C543

--- a/dumb/src/helpers/resamp3.inc
+++ b/dumb/src/helpers/resamp3.inc
@@ -124,13 +124,12 @@
 						todo_clocks_set = todo_clocks;
 						if ( todo_clocks_set > 256 * 65536 ) todo_clocks_set = 256 * 65536;
 						todo_clocks -= todo_clocks_set;
-						todo = ( todo_clocks_set - resampler->last_clock + inv_dt - 1 ) / inv_dt;
-						if ( todo < 0 ) todo = 0;
-						LOOP4(todo,
+						while ( resampler->last_clock < todo_clocks_set )
+						{
 							POKE_ALIAS(2);
 							pos--;
 							x -= SRC_CHANNELS;
-						);
+						}
 						todo = todo_clocks_set >> 16;
 						MIX_ALIAS( todo );
 					}
@@ -229,13 +228,12 @@
 						todo_clocks_set = todo_clocks;
 						if ( todo_clocks_set > 256 * 65536 ) todo_clocks_set = 256 * 65536;
 						todo_clocks -= todo_clocks_set;
-						todo = ( todo_clocks_set - resampler->last_clock + inv_dt - 1 ) / inv_dt;
-						if ( todo < 0 ) todo = 0;
-						LOOP4(todo,
+						while ( resampler->last_clock < todo_clocks_set )
+						{
 							POKE_ALIAS(-2);
 							pos++;
 							x += SRC_CHANNELS;
-						);
+						}
 						todo = todo_clocks_set >> 16;
 						MIX_ALIAS( todo );
 					}
--- a/dumb/src/helpers/resample.c
+++ b/dumb/src/helpers/resample.c
@@ -92,6 +92,7 @@
  * Clobbers the 'iterator' variable.
  * The loop is unrolled by four.
  */
+#if 0
 #define LOOP4(iterator, CONTENT) \
 { \
 	if ((iterator) & 2) { \
@@ -110,8 +111,15 @@
 		(iterator)--; \
 	} \
 }
-
-
+#else
+#define LOOP4(iterator, CONTENT) \
+{ \
+	while ( (iterator)-- ) \
+	{ \
+		CONTENT; \
+	} \
+}
+#endif
 
 #define PASTERAW(a, b) a ## b /* This does not expand macros in b ... */
 #define PASTE(a, b) PASTERAW(a, b) /* ... but b is expanded during this substitution. */
--- a/dumb/src/it/itrender.c
+++ b/dumb/src/it/itrender.c
@@ -149,13 +149,13 @@
 
 	dst->resampler = src->resampler;
 	dst->resampler.pickup_data = dst;
-	dst->resampler.blip_buffer[0] = blip_dup( dst->resampler.blip_buffer[0] );
+	dst->resampler.blip_buffer[0] = blip_dup( src->resampler.blip_buffer[0] );
 	if ( !dst->resampler.blip_buffer[0] )
 	{
 		free( dst );
 		return NULL;
 	}
-	dst->resampler.blip_buffer[1] = blip_dup( dst->resampler.blip_buffer[1] );
+	dst->resampler.blip_buffer[1] = blip_dup( src->resampler.blip_buffer[1] );
 	if ( !dst->resampler.blip_buffer[1] )
 	{
 		blip_delete( dst->resampler.blip_buffer[0] );
@@ -4845,7 +4845,7 @@
 		channel->channelvolume = sigdata->channel_volume[i];
 		channel->instrument = 0;
 		channel->sample = 0;
-		channel->note = 0;
+		channel->note = IT_NOTE_OFF;
 		channel->SFmacro = 0;
 		channel->filter_cutoff = 127;
 		channel->filter_resonance = 0;