diff -urN xboing-orig/audio/LINUXaudio2.c xboing/audio/LINUXaudio2.c
--- xboing-orig/audio/LINUXaudio2.c	1996-11-22 10:28:33 +0900
+++ xboing/audio/LINUXaudio2.c	2015-04-16 06:01:51 +0900
@@ -72,48 +72,48 @@
 static int samplecount;
 static Sample *snd;
 
-static unsigned char ulaw_dsp[] = {
-     0,    0,    0,    0,    0,    0,    0,    0, 
-     0,    0,    0,    0,    0,    0,    0,    0, 
-     0,    0,    0,    0,    0,    0,    0,    0, 
-     0,    0,    0,    0,    0,    0,    0,    2, 
-     5,    9,   13,   17,   21,   25,   29,   33, 
-    37,   41,   45,   49,   53,   57,   61,   65, 
-    68,   70,   72,   74,   76,   78,   80,   82, 
-    84,   86,   88,   90,   92,   94,   96,   98, 
-   100,  101,  102,  103,  104,  105,  106,  107, 
-   108,  109,  110,  111,  112,  113,  114,  115, 
-   115,  116,  116,  117,  117,  118,  118,  119, 
-   119,  120,  120,  121,  121,  122,  122,  123, 
-   123,  123,  124,  124,  124,  124,  125,  125, 
-   125,  125,  126,  126,  126,  126,  127,  127, 
-   127,  127,  127,  127,  128,  128,  128,  128, 
-   128,  128,  128,  128,  128,  128,  128,  128, 
-   255,  255,  255,  255,  255,  255,  255,  255, 
-   255,  255,  255,  255,  255,  255,  255,  255, 
-   255,  255,  255,  255,  255,  255,  255,  255, 
-   255,  255,  255,  255,  255,  255,  255,  255, 
-   252,  248,  244,  240,  236,  232,  228,  224, 
-   220,  216,  212,  208,  204,  200,  196,  192, 
-   189,  187,  185,  183,  181,  179,  177,  175, 
-   173,  171,  169,  167,  165,  163,  161,  159, 
-   157,  156,  155,  154,  153,  152,  151,  150, 
-   149,  148,  147,  146,  145,  144,  143,  142, 
-   142,  141,  141,  140,  140,  139,  139,  138, 
-   138,  137,  137,  136,  136,  135,  135,  134, 
-   134,  134,  133,  133,  133,  133,  132,  132, 
-   132,  132,  131,  131,  131,  131,  130,  130, 
-   130,  130,  130,  130,  129,  129,  129,  129, 
-   129,  129,  129,  129,  128,  128,  128,  128, 
+static short ulaw_dsp[] = {
+    -32124, -31100, -30076, -29052, -28028, -27004, -25980, -24956,
+    -23932, -22908, -21884, -20860, -19836, -18812, -17788, -16764,
+    -15996, -15484, -14972, -14460, -13948, -13436, -12924, -12412,
+    -11900, -11388, -10876, -10364,  -9852,  -9340,  -8828,  -8316,
+     -7932,  -7676,  -7420,  -7164,  -6908,  -6652,  -6396,  -6140,
+     -5884,  -5628,  -5372,  -5116,  -4860,  -4604,  -4348,  -4092,
+     -3900,  -3772,  -3644,  -3516,  -3388,  -3260,  -3132,  -3004,
+     -2876,  -2748,  -2620,  -2492,  -2364,  -2236,  -2108,  -1980,
+     -1884,  -1820,  -1756,  -1692,  -1628,  -1564,  -1500,  -1436,
+     -1372,  -1308,  -1244,  -1180,  -1116,  -1052,   -988,   -924,
+      -876,   -844,   -812,   -780,   -748,   -716,   -684,   -652,
+      -620,   -588,   -556,   -524,   -492,   -460,   -428,   -396,
+      -372,   -356,   -340,   -324,   -308,   -292,   -276,   -260,
+      -244,   -228,   -212,   -196,   -180,   -164,   -148,   -132,
+      -120,   -112,   -104,    -96,    -88,    -80,    -72,    -64,
+       -56,    -48,    -40,    -32,    -24,    -16,     -8,      0,
+     32124,  31100,  30076,  29052,  28028,  27004,  25980,  24956,
+     23932,  22908,  21884,  20860,  19836,  18812,  17788,  16764,
+     15996,  15484,  14972,  14460,  13948,  13436,  12924,  12412,
+     11900,  11388,  10876,  10364,   9852,   9340,   8828,   8316,
+      7932,   7676,   7420,   7164,   6908,   6652,   6396,   6140,
+      5884,   5628,   5372,   5116,   4860,   4604,   4348,   4092,
+      3900,   3772,   3644,   3516,   3388,   3260,   3132,   3004,
+      2876,   2748,   2620,   2492,   2364,   2236,   2108,   1980,
+      1884,   1820,   1756,   1692,   1628,   1564,   1500,   1436,
+      1372,   1308,   1244,   1180,   1116,   1052,    988,    924,
+       876,    844,    812,    780,    748,    716,    684,    652,
+       620,    588,    556,    524,    492,    460,    428,    396,
+       372,    356,    340,    324,    308,    292,    276,    260,
+       244,    228,    212,    196,    180,    164,    148,    132,
+       120,    112,    104,     96,     88,     80,     72,     64,
+        56,     48,     40,     32,     24,     16,      8,      0,
 };
 
 /* Now the functions. */
 
-void translate_bytes (const unsigned char *table, unsigned char *buff, int n)
+void translate_bytes (const short *table, unsigned char *buff, int n)
 {
   int i;
 
-  for (i = 0; i < n; i++) buff[i] = table[buff[i]];
+  for (i = n-1; i >= 0; i--) ((short *)buff)[i] = table[buff[i]];
 }
 
 int Snd_loadUlawSample( const char *file, Sample *sample )
@@ -122,7 +122,7 @@
 
  sample->data = NULL;
  sample->len  = 0;
-   
+
  fp = fopen(file,"r");   
    
  if (fp==NULL) return -1;
@@ -133,8 +133,8 @@
  /* go back to beginning of file */
  lseek( fileno(fp), 0, SEEK_SET );
 
- /* alloc memory for sample */
- sample->data = (unsigned char *)malloc( sample->len );
+ /* alloc memory for sample (will be unpacked to 16 bits/sample) */
+ sample->data = (unsigned char *)malloc( sample->len * 2 );
    
  if (sample->data==NULL)
   {
@@ -143,8 +143,20 @@
   }
    
  fread( sample->data, 1, sample->len, fp ); 	
+
+ /* strip .snd header if present */
+ if (sample->len > 8 && memcmp(sample->data, ".snd", 4) == 0)
+  {
+  unsigned char *data = sample->data;
+  int headersize = data[4]<<24 | data[5]<<16 | data[6]<<8 | data[7];
+  if (sample->len > headersize)
+   {
+   sample->len -= headersize;
+   memmove(data, data + headersize, sample->len);
+   }
+  }
   
- translate_bytes(ulaw_dsp, sample->data, sample->len);
+ translate_bytes(ulaw_dsp, (unsigned char *)sample->data, sample->len);
 
  fclose(fp);
    
diff -urN xboing-orig/audio/soundIt.c xboing/audio/soundIt.c
--- xboing-orig/audio/soundIt.c	2015-04-16 05:22:00 +0900
+++ xboing/audio/soundIt.c	2015-04-16 06:43:18 +0900
@@ -24,13 +24,13 @@
 /* the mix buff, where the channels are mixed into. The mix buffer is then
    dumped to the sound device (/dev/dsp). Samples are mixed in
    Vunclipbuf (buffer of ints), then the values in Vunclipbuf are clipped to
-   values between 0 and 255, and stored into Vclippedbuf (buffer of unsigned
-   chars).
+   values between -32768 and 32767, and stored into Vclippedbuf (buffer of
+   shorts).
 */
 
 struct Mix
     {
-    unsigned char *Vclippedbuf;	
+    short *Vclippedbuf;	
     int *Vunclipbuf;
     int Vsize;
     };
@@ -39,9 +39,9 @@
 /*==========================================================================*/
 struct Channel
     {
-    unsigned char *Vstart,*Vcurrent;	/* ptr's into a playing sample */
+    short *Vstart,*Vcurrent;		/* ptr's into a playing sample */
     int	Vlen;				/* length of sample in bytes */
-    int	Vleft;				/* bytes left of sample to play */
+    int	Vleft;				/* frames left of sample to play */
     };
 typedef struct Channel Channel;
 
@@ -240,9 +240,22 @@
 		frag = FRAG_SPEC; /*defined in soundIt.h */
 		
  		ioctl(S_fd_snddev, SNDCTL_DSP_SETFRAGMENT, &frag);
+
+		i = AFMT_S16_LE;
+		ioctl(S_fd_snddev, SNDCTL_DSP_SETFMT, &i);
+		if ( i != AFMT_S16_LE )
+			fprintf(stderr, "S16LE output not supported\n");
+
+		i = 2;
+		ioctl(S_fd_snddev, SNDCTL_DSP_CHANNELS, &i);
+		if ( i != 2 )
+			fprintf(stderr, "Stereo output not supported (got %d channels)\n", i);
  
-		if ( ioctl(S_fd_snddev,SNDCTL_DSP_SPEED, &S_playback_freq)==-1 )
+		i = S_playback_freq;
+		if ( ioctl(S_fd_snddev,SNDCTL_DSP_SPEED, &i)==-1 )
 			perror("Sound driver ioctl ");
+		if ( i != S_playback_freq )
+			fprintf(stderr, "Playback frequency %d not supported (got %d)\n", S_playback_freq, i);
 
 		fragsize=0;
 		if ( ioctl(S_fd_snddev,SNDCTL_DSP_GETBLKSIZE, &fragsize)==-1 ) 
@@ -282,7 +295,7 @@
 				}
 			
 			Chan_mixAll(&mix,chan);
-			write(S_fd_snddev, mix.Vclippedbuf, fragsize );
+			write(S_fd_snddev, mix.Vclippedbuf, fragsize*4 );
 			}
 
 		Mix_dealloc( &mix );			
@@ -342,7 +355,7 @@
     /* fill the remaining (if any) part of the mix buffer with silence */
     while (i<mix->Vsize) 
             { 
-            *p++ = 128; 
+            *p++ = 0; 
             i++; 
             }
     return result;            
@@ -358,7 +371,7 @@
     
     for(i=0; i<min; i++)
         {
-        *p++ += (int) (*chan->Vcurrent++) - 128;
+        *p++ += *chan->Vcurrent++;
         }
 
     chan->Vleft -= i;
@@ -366,11 +379,11 @@
     }
 
 /*========================================================================*/
-/* clip an int to a value between 0 and 255 */
+/* clip an int to a value between -32768 and 32767 */
 static inline 
-unsigned char clip(int i)
+short clip(int i)
     {
-    return (i<0) ? 0 : ( (i>255) ? 255 : i );
+    return (i<-32768) ? -32768 : ( (i>32767) ? 32767 : i );
     }
     
 /*==========================================================================*/
@@ -378,22 +391,26 @@
     {
     register int    i;
     int   *p = mix->Vunclipbuf, result, min;
-    unsigned char *final = mix->Vclippedbuf;
+    short *final = mix->Vclippedbuf;
 
     result = (chan->Vleft>0) ? 1 : 0;
     min = (chan->Vleft < mix->Vsize) ? chan->Vleft : mix->Vsize;
     
     for(i=0; i<min; i++)
         {
-        *p += (int) (*chan->Vcurrent++) - 128;
-        *final++ = clip(*p++);
+        *p += *chan->Vcurrent++;
+        *final++ = clip(*p);
+        *final++ = clip(*p);
+        p++;
         }
     chan->Vleft -= i;
 
     /* copy rest of Vunclipbuf over to Vclippedbuf */
     while (i<mix->Vsize) 
             {
-            *final++ = clip(*p++);
+            *final++ = clip(*p);
+            *final++ = clip(*p);
+            p++;
             i++;
             }
             
@@ -404,7 +421,7 @@
 /*==========================================================================*/
 void Mix_alloc(Mix *mix, int size)
     {
-    mix->Vclippedbuf = (unsigned char *)calloc( sizeof(char), size);
+    mix->Vclippedbuf = (short *)calloc( sizeof(short), size*2);
     mix->Vunclipbuf = (int *)calloc( sizeof(int), size);
     mix->Vsize  = size;
     
@@ -452,6 +469,7 @@
 Snd_loadRawSample( const char *file, Sample *sample )
    {
    FILE *fp;
+   int i;
 
    sample->data = NULL;
    sample->len  = 0;
@@ -467,7 +485,7 @@
    lseek( fileno(fp), 0, SEEK_SET );
 
    /* alloc memory for sample */
-   sample->data = (unsigned char *)malloc( sample->len );
+   sample->data = (short *)malloc( sample->len * 2 );
    
    if (sample->data==NULL)
    	{
@@ -476,6 +494,10 @@
    	}
    
    fread( sample->data, 1, sample->len, fp ); 	
+   for (i = sample->len-1; i >= 0; i--)
+        {
+        sample->data[i] = ((int)((unsigned char *)sample->data)[i] - 128) << 8;
+        }
   
    fclose(fp);
    
diff -urN xboing-orig/audio/soundIt.h xboing/audio/soundIt.h
--- xboing-orig/audio/soundIt.h	2015-04-16 05:22:00 +0900
+++ xboing/audio/soundIt.h	2015-04-16 05:58:11 +0900
@@ -33,7 +33,7 @@
 /*==========================================================================*/
 struct Sample
     {
-    unsigned char *data;	/* unsigned 8-bit raw samples */
+    short *data;		/* signed 16-bit raw samples */
     int len;			/* length of sample in bytes  */
     };
 
