From: liljeber@hydra.Helsinki.FI (Mika Liljeberg)
Subject: Re: ANNOUNCE: Sound for Linux 0.99 (Sound driver v 0.4)
Organization: Department of Computer Science, University of Helsinki, Finland
Date: Thu, 17 Dec 1992 22:10:16 GMT

In article <kenc.724299040@sol> kenc@sol.acs.unt.edu (Ken Corey - Operator) wrote:
> hsavolai@cs.Helsinki.FI (Hannu Savolainen) writes:
>>The version 0.4 of the Sound Card Driver is available at nic.funet.fi
>>(pub/OS/Linux/xtra/snd-kit/snd-driv-0.4.tar.Z)
> 
> Pardon me if my stupidity is hanging out here...but what exactly can a Sound 
> Blaster Pro be used for when running linux?  Are there programs to let us 
> play SunOS sounds (Whatever the format they're in is called)?

Sure, just pluck in the following patch. :-) I took a few moments to
write it, since the capability was still missing from 0.4 (/dev/audio
is there, mind you, just the conversion code was absent).

I have a weird (latency?) problem with my modem, though. DTR and RTS
go down almost immediately, when I copy something to /dev/audio (only
with my patch). I'd like to hear, if everyone has this problem. I
don't understand this behaviour at all. Oh, consider this a WARNING!
Don't try to play Sun audio files, while using the modem :-)

The patch should also support digitizing Sun-style samples. I haven't
been able to test this, though.

Have fun,

	Mika

------------------------------------------------------------------------------
--- audio.c.org	Tue Dec 15 00:02:00 1992
+++ audio.c	Tue Dec 15 03:11:02 1992
@@ -23,6 +23,8 @@
 
 #ifdef CONFIGURE_SOUNDCARD
 
+#include "ulaw.h"
+
 #define OUTB outb
 #define DEB(WHAT)		/* (WHAT) */
 #define DEB1(WHAT)		/* (WHAT) */
@@ -68,6 +70,16 @@
   DMAbuf_release (dev, mode);
 }
 
+extern inline void translate_bytes(const void *table, void *buff, unsigned long n)
+{
+  __asm__("cld\n"
+	  "1:\tlodsb\n\t"
+	  "xlatb\n\t"
+	  "stosb\n\t"
+	  "loop 1b\n\t"
+	  ::"b" ((long)table), "c" (n), "D" ((long)buff), "S" ((long)buff)
+	  :"bx","cx","di","si");
+}
 
 int
 audio_write (struct inode *inode, struct file *file, char *buf, int count)
@@ -107,7 +119,8 @@
 
       memcpy_fromfs (&wr_dma_buf[wr_buff_ptr], &buf[p], l);
 
-      /* Insert local processing here 	 */
+      /* Insert local processing here */
+      translate_bytes(ulaw_dsp, &wr_dma_buf[wr_buff_ptr], l);
 
       c -= l;
       p += l;
@@ -148,6 +161,7 @@
 	l = c;
 
       /* Insert any local processing here. */
+      translate_bytes(dsp_ulaw, dmabuf, l);
 
       memcpy_tofs (buf, dmabuf, l);
 
--- /dev/null	Fri Aug  7 22:53:49 1992
+++ ulaw.h	Tue Dec 15 01:51:44 1992
@@ -0,0 +1,69 @@
+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 unsigned char dsp_ulaw[] = {
+    31,   31,   31,   32,   32,   32,   32,   33, 
+    33,   33,   33,   34,   34,   34,   34,   35, 
+    35,   35,   35,   36,   36,   36,   36,   37, 
+    37,   37,   37,   38,   38,   38,   38,   39, 
+    39,   39,   39,   40,   40,   40,   40,   41, 
+    41,   41,   41,   42,   42,   42,   42,   43, 
+    43,   43,   43,   44,   44,   44,   44,   45, 
+    45,   45,   45,   46,   46,   46,   46,   47, 
+    47,   47,   47,   48,   48,   49,   49,   50, 
+    50,   51,   51,   52,   52,   53,   53,   54, 
+    54,   55,   55,   56,   56,   57,   57,   58, 
+    58,   59,   59,   60,   60,   61,   61,   62, 
+    62,   63,   63,   64,   65,   66,   67,   68, 
+    69,   70,   71,   72,   73,   74,   75,   76, 
+    77,   78,   79,   81,   83,   85,   87,   89, 
+    91,   93,   95,   99,  103,  107,  111,  119, 
+   255,  247,  239,  235,  231,  227,  223,  221, 
+   219,  217,  215,  213,  211,  209,  207,  206, 
+   205,  204,  203,  202,  201,  200,  199,  198, 
+   197,  196,  195,  194,  193,  192,  191,  191, 
+   190,  190,  189,  189,  188,  188,  187,  187, 
+   186,  186,  185,  185,  184,  184,  183,  183, 
+   182,  182,  181,  181,  180,  180,  179,  179, 
+   178,  178,  177,  177,  176,  176,  175,  175, 
+   175,  175,  174,  174,  174,  174,  173,  173, 
+   173,  173,  172,  172,  172,  172,  171,  171, 
+   171,  171,  170,  170,  170,  170,  169,  169, 
+   169,  169,  168,  168,  168,  168,  167,  167, 
+   167,  167,  166,  166,  166,  166,  165,  165, 
+   165,  165,  164,  164,  164,  164,  163,  163, 
+   163,  163,  162,  162,  162,  162,  161,  161, 
+   161,  161,  160,  160,  160,  160,  159,  159, 
+};

--
Mika Liljeberg			Email:	liljeber@hydra.Helsinki.FI
Helsinki University			Mika.Liljeberg@Helsinki.FI
Dept. of Computer Science
Newsgroups: comp.os.linux