aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorMax Horn2002-07-17 23:50:38 +0000
committerMax Horn2002-07-17 23:50:38 +0000
commit5317b473b2f41f30c0d89b9e8ffab40aa2d34672 (patch)
treec389f028c6d608509879b450e3b41b52ff20b72d /sound
parent344690c522fc0f32cd3b9f0afba2b77650e03e86 (diff)
downloadscummvm-rg350-5317b473b2f41f30c0d89b9e8ffab40aa2d34672.tar.gz
scummvm-rg350-5317b473b2f41f30c0d89b9e8ffab40aa2d34672.tar.bz2
scummvm-rg350-5317b473b2f41f30c0d89b9e8ffab40aa2d34672.zip
added cubic spline interpolation (only to mix_unsigned_mono_8 because that's what I used to test); next step will be to put this into a seperate function which all the 9 mixers (8 normal ones and one for MP3) will then use, but I gotta sleep now :-)
svn-id: r4585
Diffstat (limited to 'sound')
-rw-r--r--sound/mixer.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index cc24bf3a17..e5677bbde0 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -261,6 +261,7 @@ static int16 *mix_signed_mono_8(int16 *data, uint * len_ptr, byte **s_ptr, uint3
static int16 *mix_unsigned_mono_8(int16 *data, uint * len_ptr, byte **s_ptr, uint32 *fp_pos_ptr,
int fp_speed, const int16 *vol_tab, byte *s_end)
{
+#if OLD
uint32 fp_pos = *fp_pos_ptr;
byte *s = *s_ptr;
uint len = *len_ptr;
@@ -277,6 +278,49 @@ static int16 *mix_unsigned_mono_8(int16 *data, uint * len_ptr, byte **s_ptr, uin
*len_ptr = len;
return data;
+#else
+ uint32 fp_pos = *fp_pos_ptr;
+ byte *s = *s_ptr;
+ uint len = *len_ptr;
+ int x0, x1, x2, x3;
+ int a, b, c, d;
+ int inc = 1, result, t;
+ x0 = x1 = vol_tab[*s ^ 0x80];
+ x2 = vol_tab[*(s+1) ^ 0x80];
+ x3 = vol_tab[*(s+2) ^ 0x80];
+ do {
+ a = ((-x0*2)+(x1*5)-(x2*4)+x3);
+ b = ((x0+x2-(2*x1))*6) << 8;
+ c = ((-4*x0)+x1+(x2*4)-x3) << 8;
+ d = (x1*6) << 8;
+ do {
+ t = fp_pos >> 8;
+ result = (a*t + b) >> 8;
+ result = (result * t + c) >> 8;
+ result = (result * t + d) >> 8;
+ result = (result/3 + 1) >> 1;
+
+ *data++ += result;
+ *data++ += result;
+
+ fp_pos += fp_speed;
+ inc = fp_pos >> 16;
+ s += inc;
+ fp_pos &= 0x0000FFFF;
+ } while ((--len) && !inc && (s < s_end));
+ x0 = x1;
+ x1 = x2;
+ x2 = x3;
+ if (s+2 < s_end)
+ x3 = vol_tab[*(s+2) ^ 0x80];
+ } while (len && (s < s_end));
+
+ *fp_pos_ptr = fp_pos;
+ *s_ptr = s;
+ *len_ptr = len;
+
+ return data;
+#endif
}
static int16 *mix_signed_stereo_8(int16 *data, uint * len_ptr, byte **s_ptr, uint32 *fp_pos_ptr,
int fp_speed, const int16 *vol_tab, byte *s_end)