stratagus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Stratagus-CVS] stratagus doc/ChangeLog.html src/sound/sound_se...


From: Russell Smith
Subject: [Stratagus-CVS] stratagus doc/ChangeLog.html src/sound/sound_se...
Date: Mon, 15 Sep 2003 01:51:01 -0400

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     Russell Smith <address@hidden>  03/09/15 01:51:00

Modified files:
        doc            : ChangeLog.html 
        src/sound      : sound_server.c 

Log message:
        Fixed Bug #4721: Sound effects are white noise

Patches:
Index: stratagus/doc/ChangeLog.html
diff -u stratagus/doc/ChangeLog.html:1.527 stratagus/doc/ChangeLog.html:1.528
--- stratagus/doc/ChangeLog.html:1.527  Sun Sep 14 07:51:32 2003
+++ stratagus/doc/ChangeLog.html        Mon Sep 15 01:51:00 2003
@@ -2,7 +2,7 @@
 <html>
 <head>
 <!--
-----   $Id: ChangeLog.html,v 1.527 2003/09/14 11:51:32 martinxyz Exp $
+----   $Id: ChangeLog.html,v 1.528 2003/09/15 05:51:00 mr-russ Exp $
 
 ----   (c) Copyright 1998-2003 by Lutz Sammer
 
@@ -36,6 +36,7 @@
 <li>Future 1.19 Release<p>
     <ul>
     <li>++
+    <li>Fixed Bug #4721: Sound effects are white noise (from Nehal Mistry and 
Russell Smith).
     <li>NEW_UI: Can highlight buttons now to show actions (from Martin Renold).
     <li>Removed old pathfinder, A-Star is not an option now (from Russell 
Smith).
     <li>Added MinRange to Orders, Pathfinder finds correct paths for a ranged 
attack now (from Russell Smith).
Index: stratagus/src/sound/sound_server.c
diff -u stratagus/src/sound/sound_server.c:1.119 
stratagus/src/sound/sound_server.c:1.120
--- stratagus/src/sound/sound_server.c:1.119    Sat Aug  2 09:34:25 2003
+++ stratagus/src/sound/sound_server.c  Mon Sep 15 01:51:00 2003
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: sound_server.c,v 1.119 2003/08/02 13:34:25 grumbel Exp $
+//     $Id: sound_server.c,v 1.120 2003/09/15 05:51:00 mr-russ Exp $
 
 //@{
 
@@ -332,13 +332,12 @@
 global int ConvertToStereo32(const char *src, char *dest, int frequency, 
     int chansize, int channels, int bytes)
 {
-    int s;              // sample index
-    int b;              // byte index
-    int c;              // channel index
+    int s;                     // sample index
+    int c;                     // channel index
     int freqratio;
     int chanratio;
     int brratio;
-    int samplesize;     // number of bytes per sample
+    int samplesize;            // number of bytes per sample
     int divide;
     int offset;
 
@@ -346,23 +345,23 @@
     samplesize = chansize * channels;
     brratio = 4 / samplesize;
     chanratio = 2 / channels;
-    divide = freqratio * brratio / chanratio;
+    divide = freqratio * brratio;
 
     // s is the sample
-    for (s = 0; s < bytes*divide; s += 4) {
-        // c is the channel in the sample
-        for (c = 0; c < 2; ++c) {
-            // b is the byte in the channel
-            for (b = 0; b < 2; ++b) {
-                offset=( ((s/4)/freqratio)*samplesize*chanratio +
-                    (c/chanratio)*chansize + b/(2/chansize));
-                dest[s + c*2 + b] = src[offset] + (chansize == 1 ? 127 : 0);
-                // FIXME: should this be 127 or 128?
-            }
-        }
+    for (s = 0; s < bytes * divide; s += 4) {
+       // c is the channel in the sample
+       for (c = 0; c < 2; ++c) {
+           offset = (((s / 4) / freqratio) * samplesize + (c / chanratio) * 
chansize);
+           if (chansize == 2) {
+               *(short *)(dest + s + c*2) = *(short *)(src + offset);
+           } else {
+               *(dest + s + c * 2) = *(src + offset) + 128;
+               *(dest + s + c * 2 + 1) = *(src + offset) + 128;
+           }
+       }
     }
 
-    return bytes*divide;
+    return bytes * divide;
 }
 
 global SoundChannel Channels[MaxChannels];




reply via email to

[Prev in Thread] Current Thread [Next in Thread]