Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 05 Jan 1999 14:13:31 +0100
From:      Stefan Bethke <stefan.bethke@hanse.de>
To:        Poul-Henning Kamp <phk@FreeBSD.ORG>, isdn@FreeBSD.ORG
Subject:   Re: isdn4bsd in freebsd current
Message-ID:  <1031949.3124534411@d235.promo.de>
In-Reply-To: <86538.915012047@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
--==========01048950==========
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

A bit late, but:

Poul-Henning Kamp <phk@FreeBSD.ORG> wrote:

> *   We need somebody to figure out if the g711 files are bit-flipped.
>     Please try out the various tools under ports/audio, and see if
>     they can handle the file 'msg.g711a' as a 8bit, 8khz aLaw file.
>     If it can't, try to flip the bits around in the file and try
>     again.  Flipping bits means that 0x1a should becore 0x58.

They are, by any means I can think of. The attached patch has a fix for
this. Additionally, it contains new tables for "raw a-Law" to u-Law and
vice versa translation, which I believe are better (produced with sox).

> Please join me in a big thankyou to Hellmuth for this Xmas present
> to the FreeBSD project, and lets together make sure that he 
> doesn't regret it!

Yep!


Cheers,
Stefan

--
M=FChlendamm 12           |  Voice +49-40-256848, +49-177-3504009
D-22089 Hamburg         |  e-mail: stefan.bethke@hanse.de
Germany                 |          stb@freebsd.org

--==========01048950==========
Content-Type: text/plain; charset=us-ascii; name="audio-patch.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="audio-patch.txt"; size=24466

--- ./alawulaw/alaw2ulaw.c.orig	Wed Dec 30 23:48:47 1998
+++ ./alawulaw/alaw2ulaw.c	Wed Dec 30 23:50:45 1998
@@ -41,8 +41,9 @@
 
 #define BUF_SIZ	2048
 
-unsigned char alaw_ulaw[];
-unsigned char ulaw_alaw[];
+static unsigned char raw_ulaw[];
+static unsigned char ulaw_raw[];
+
 	
 int main(int argc, char *argv[])
 {
@@ -58,11 +59,11 @@
 
 	if(!strcmp(p, "ulaw2alaw"))
 	{
-		cp = ulaw_alaw;
+		cp = ulaw_raw;
 	}
 	else if(!strcmp(p, "alaw2ulaw"))
 	{
-		cp = alaw_ulaw;
+		cp = raw_ulaw;
 	}
 	else
 	{
@@ -78,74 +79,50 @@
 	return(0);
 }
 
-unsigned char alaw_ulaw[] = {
-	0x002a, 0x00a9, 0x005f, 0x00e3, 0x001f, 0x009f, 0x0048, 0x00c8,
-	0x0039, 0x00b9, 0x006f, 0x00f7, 0x001f, 0x009f, 0x0055, 0x00d7,
-	0x0022, 0x00a1, 0x005b, 0x00dd, 0x001f, 0x009f, 0x0040, 0x00c0,
-	0x0031, 0x00b1, 0x0067, 0x00eb, 0x001f, 0x009f, 0x004e, 0x00cf,
-	0x002e, 0x00ad, 0x0063, 0x00e7, 0x001f, 0x009f, 0x004c, 0x00cc,
-	0x003d, 0x00bd, 0x0077, 0x00ff, 0x001f, 0x009f, 0x0059, 0x00db,
-	0x0026, 0x00a5, 0x005d, 0x00df, 0x001f, 0x009f, 0x0044, 0x00c4,
-	0x0035, 0x00b5, 0x006b, 0x00ef, 0x001f, 0x009f, 0x0051, 0x00d3,
-	0x0028, 0x00a7, 0x005f, 0x00e3, 0x001f, 0x009f, 0x0046, 0x00c6,
-	0x0037, 0x00b7, 0x006f, 0x00f7, 0x001f, 0x009f, 0x0053, 0x00d5,
-	0x0020, 0x009f, 0x005b, 0x00dd, 0x001f, 0x009f, 0x003f, 0x00bf,
-	0x002f, 0x00af, 0x0067, 0x00eb, 0x001f, 0x009f, 0x004d, 0x00ce,
-	0x002c, 0x00ab, 0x0063, 0x00e7, 0x001f, 0x009f, 0x004a, 0x00ca,
-	0x003b, 0x00bb, 0x0077, 0x00ff, 0x001f, 0x009f, 0x0057, 0x00d9,
-	0x0024, 0x00a3, 0x005d, 0x00df, 0x001f, 0x009f, 0x0042, 0x00c2,
-	0x0033, 0x00b3, 0x006b, 0x00ef, 0x001f, 0x009f, 0x004f, 0x00d1,
-	0x002b, 0x00aa, 0x0063, 0x00e3, 0x001f, 0x009f, 0x0049, 0x00c9,
-	0x003a, 0x00ba, 0x0077, 0x00f7, 0x001f, 0x009f, 0x0057, 0x00d7,
-	0x0023, 0x00a2, 0x005d, 0x00dd, 0x001f, 0x009f, 0x0041, 0x00c1,
-	0x0032, 0x00b2, 0x006b, 0x00eb, 0x001f, 0x009f, 0x004f, 0x00cf,
-	0x002f, 0x00ae, 0x0067, 0x00e7, 0x001f, 0x009f, 0x004d, 0x00cd,
-	0x003e, 0x00be, 0x00ff, 0x00ff, 0x001f, 0x009f, 0x005b, 0x00db,
-	0x0027, 0x00a6, 0x005f, 0x00df, 0x001f, 0x009f, 0x0045, 0x00c5,
-	0x0036, 0x00b6, 0x006f, 0x00ef, 0x001f, 0x009f, 0x0053, 0x00d3,
-	0x0029, 0x00a8, 0x005f, 0x00e3, 0x001f, 0x009f, 0x0047, 0x00c7,
-	0x0038, 0x00b8, 0x006f, 0x00f7, 0x001f, 0x009f, 0x0055, 0x00d5,
-	0x0021, 0x00a0, 0x005b, 0x00dd, 0x001f, 0x009f, 0x003f, 0x00bf,
-	0x0030, 0x00b0, 0x0067, 0x00eb, 0x001f, 0x009f, 0x004e, 0x00ce,
-	0x002d, 0x00ac, 0x0063, 0x00e7, 0x001f, 0x009f, 0x004b, 0x00cb,
-	0x003c, 0x00bc, 0x0077, 0x00ff, 0x001f, 0x009f, 0x0059, 0x00d9,
-	0x0025, 0x00a4, 0x005d, 0x00df, 0x001f, 0x009f, 0x0043, 0x00c3,
-	0x0034, 0x00b4, 0x006b, 0x00ef, 0x001f, 0x009f, 0x0051, 0x00d1
+
+/*-------------------------------------------------------------------------
--*
+ *	Line format to mu-law conversion
+
*---------------------------------------------------------------------------
*/
+static unsigned char raw_ulaw[256] = {
+	0x2a, 0xa9, 0x62, 0xe1, 0x0a, 0x8a, 0x48, 0xc8, 0x39, 0xb9, 0x75, 0xf3,
0x1a, 0x9a, 0x56, 0xd6,
+	0x22, 0xa1, 0x5d, 0xdc, 0x02, 0x82, 0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73, 0xf1,
0x19, 0x99, 0x55, 0xd5,
+	0x21, 0xa0, 0x5c, 0xdc, 0x01, 0x81, 0x3f, 0xbf, 0x30, 0xb0, 0x69, 0xe8,
0x11, 0x91, 0x4e, 0xce,
+	0x2d, 0xac, 0x65, 0xe4, 0x0d, 0x8d, 0x4b, 0xcb, 0x3c, 0xbc, 0x7b, 0xf9,
0x1d, 0x9d, 0x59, 0xd9,
+	0x25, 0xa4, 0x5e, 0xde, 0x05, 0x85, 0x43, 0xc3, 0x34, 0xb4, 0x6d, 0xec,
0x15, 0x95, 0x51, 0xd1,
 };
 
-unsigned char ulaw_alaw[] = {
-	0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc,
-	0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc,
-	0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc,
-	0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00ac,
-	0x0050, 0x00d0, 0x0010, 0x0090, 0x0070, 0x00f0, 0x0030, 0x00b0,
-	0x0040, 0x00c0, 0x0000, 0x0080, 0x0060, 0x00e0, 0x0020, 0x00a0,
-	0x00d8, 0x0018, 0x0098, 0x0078, 0x00f8, 0x0038, 0x00b8, 0x0048,
-	0x00c8, 0x0008, 0x0088, 0x0068, 0x00e8, 0x0028, 0x00a8, 0x00d6,
-	0x0096, 0x0076, 0x00f6, 0x0036, 0x00b6, 0x0046, 0x00c6, 0x0006,
-	0x0086, 0x0066, 0x00e6, 0x0026, 0x00a6, 0x00de, 0x009e, 0x00fe,
-	0x00fe, 0x00be, 0x00be, 0x00ce, 0x00ce, 0x008e, 0x008e, 0x00ee,
-	0x00ee, 0x00d2, 0x00d2, 0x00f2, 0x00f2, 0x00c2, 0x00c2, 0x00e2,
-	0x00e2, 0x00e2, 0x00da, 0x00da, 0x00da, 0x00da, 0x00fa, 0x00fa,
-	0x00fa, 0x00fa, 0x00ca, 0x00ca, 0x00ca, 0x00ca, 0x00ea, 0x00ea,
-	0x00ea, 0x00ea, 0x00ea, 0x00ea, 0x00eb, 0x00eb, 0x00eb, 0x00eb,
-	0x00eb, 0x00eb, 0x00eb, 0x00eb, 0x00eb, 0x00eb, 0x00eb, 0x00eb,
-	0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd,
-	0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd,
-	0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd,
-	0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd,
-	0x00d1, 0x0011, 0x0091, 0x0071, 0x00f1, 0x0031, 0x00b1, 0x0041,
-	0x00c1, 0x0001, 0x0081, 0x0061, 0x00e1, 0x0021, 0x00a1, 0x0059,
-	0x00d9, 0x0019, 0x0099, 0x0079, 0x00f9, 0x0039, 0x00b9, 0x0049,
-	0x00c9, 0x0009, 0x0089, 0x0069, 0x00e9, 0x0029, 0x00a9, 0x0057,
-	0x0017, 0x0097, 0x0077, 0x00f7, 0x0037, 0x00b7, 0x0047, 0x00c7,
-	0x0007, 0x0087, 0x0067, 0x00e7, 0x0027, 0x00a7, 0x00df, 0x009f,
-	0x009f, 0x00ff, 0x00ff, 0x00bf, 0x00bf, 0x00cf, 0x00cf, 0x008f,
-	0x008f, 0x00ef, 0x00ef, 0x00af, 0x00af, 0x00d3, 0x00d3, 0x00f3,
-	0x00f3, 0x00f3, 0x00c3, 0x00c3, 0x00c3, 0x00c3, 0x00e3, 0x00e3,
-	0x00e3, 0x00e3, 0x00db, 0x00db, 0x00db, 0x00db, 0x00fb, 0x00fb,
-	0x00fb, 0x00fb, 0x00fb, 0x00fb, 0x00cb, 0x00cb, 0x00cb, 0x00cb,
-	0x00cb, 0x00cb, 0x00cb, 0x00cb, 0x00eb, 0x00eb, 0x00eb, 0x00eb
+
+/*-------------------------------------------------------------------------
--*
+ *	mu-law to line format conversion
+
*---------------------------------------------------------------------------
*/
+static unsigned char ulaw_raw[256] = {
+	0x54, 0xd4, 0x14, 0x94, 0x74, 0xf4, 0x34, 0xb4, 0x44, 0xc4, 0x04, 0x84,
0x64, 0xe4, 0x24, 0xa4,
+	0x5c, 0xdc, 0x1c, 0x9c, 0x7c, 0xfc, 0x3c, 0xbc, 0x4c, 0xcc, 0x0c, 0x8c,
0x6c, 0xec, 0x2c, 0xac,
+	0xd0, 0x10, 0x90, 0x70, 0xf0, 0x30, 0xb0, 0x40, 0xc0, 0x00, 0x80, 0x60,
0xe0, 0x20, 0xa0, 0x58,
+	0xd8, 0x18, 0x98, 0x78, 0xf8, 0x38, 0xb8, 0x48, 0xc8, 0x08, 0x88, 0x68,
0xe8, 0x28, 0xa8, 0xd6,
+	0x16, 0x96, 0x76, 0xf6, 0x36, 0xb6, 0x46, 0xc6, 0x06, 0x86, 0x66, 0xe6,
0x26, 0xa6, 0xde, 0x9e,
+	0x7e, 0xfe, 0x3e, 0xbe, 0x4e, 0xce, 0x0e, 0x8e, 0x6e, 0xee, 0x2e, 0xae,
0xd2, 0x92, 0xf2, 0xb2,
+	0xc2, 0x02, 0x82, 0x62, 0xe2, 0x22, 0xa2, 0x5a, 0xda, 0x1a, 0x9a, 0x7a,
0xfa, 0x3a, 0xba, 0x4a,
+	0x4a, 0xca, 0xca, 0x0a, 0x0a, 0x8a, 0x8a, 0x6a, 0x6a, 0xea, 0xea, 0x2a,
0x2a, 0xaa, 0xab, 0xab,
+	0x55, 0xd5, 0x15, 0x95, 0x75, 0xf5, 0x35, 0xb5, 0x45, 0xc5, 0x05, 0x85,
0x65, 0xe5, 0x25, 0xa5,
+	0x5d, 0xdd, 0x1d, 0x9d, 0x7d, 0xfd, 0x3d, 0xbd, 0x4d, 0xcd, 0x0d, 0x8d,
0x6d, 0xed, 0x2d, 0xad,
+	0x51, 0xd1, 0x11, 0x91, 0x71, 0xf1, 0x31, 0xb1, 0x41, 0xc1, 0x01, 0x81,
0x61, 0xe1, 0x21, 0xa1,
+	0xd9, 0x19, 0x99, 0x79, 0xf9, 0x39, 0xb9, 0x49, 0xc9, 0x09, 0x89, 0x69,
0xe9, 0x29, 0xa9, 0x57,
+	0x17, 0x97, 0x77, 0xf7, 0x37, 0xb7, 0x47, 0xc7, 0x07, 0x87, 0x67, 0xe7,
0x27, 0xa7, 0x5f, 0x1f,
+	0x7f, 0xff, 0x3f, 0xbf, 0x4f, 0xcf, 0x0f, 0x8f, 0x6f, 0xef, 0x2f, 0xaf,
0x53, 0x13, 0x73, 0x33,
+	0x43, 0xc3, 0x03, 0x83, 0x63, 0xe3, 0x23, 0xa3, 0x5b, 0xdb, 0x1b, 0x9b,
0x7b, 0xfb, 0x3b, 0xbb,
+	0xbb, 0x4b, 0x4b, 0xcb, 0xcb, 0x0b, 0x0b, 0x8b, 0x8b, 0x6b, 0x6b, 0xeb,
0xeb, 0x2b, 0x2b, 0xab,
 };
 
 /* EOF */
--- ./driver/i4b_tel.c.orig	Wed Dec 30 22:17:48 1998
+++ ./driver/i4b_tel.c	Wed Dec 30 22:40:45 1998
@@ -87,6 +87,8 @@
 #define ST_RDWAITDATA	0x04		/* userland read waiting */
 #define ST_WRWAITEMPTY	0x08		/* userland write waiting */
 	int 			audiofmt;	/* audio format conversion */
+	u_char			*rcvttab;	/* conversion table on read */
+	u_char			*wcvttab;	/* conversion table on write */
 	call_desc_t		*cdp;		/* call descriptor pointer */
 #ifdef DEVFS
         void                    *devfs_token;   /* token for DEVFS */
@@ -103,8 +105,10 @@
 static void tel_connect(int unit, void *cdp);
 static void tel_disconnect(int unit, void *cdp);
 
+/* audio format conversion tables */
 static unsigned char alaw_ulaw[];
 static unsigned char ulaw_alaw[];
+static unsigned char bitreverse[];
 
 #ifndef __FreeBSD__
 #define	PDEVSTATIC	/* - not static - */
@@ -184,6 +188,8 @@
 	{
 		tel_sc[i].devstate = ST_IDLE;
 		tel_sc[i].audiofmt = CVT_NONE;
+		tel_sc[i].rcvttab = 0;
+		tel_sc[i].wcvttab = 0;
 		tel_init_linktab(i);
 #ifdef DEVFS
 	  	tel_sc[i].devfs_token
@@ -208,8 +214,15 @@
 
 	sc = &tel_sc[unit];		
 
+#ifdef notdef
+/* 
+ * XXX
+ * With this code enabled, one cannot set or get the audio format 
+ * while not connected. 
+*/
 	if(!(sc->devstate & ST_CONNECTED))
 		return(EIO);
+#endif
 
 	if(sc->devstate & ST_ISOPEN)
 		return(EBUSY);
@@ -274,7 +287,26 @@
 			break;
 		
 		case I4B_TEL_SETAUDIOFMT:
-			sc->audiofmt = *(int *)data;
+			switch (*(int *)data)
+			{
+				case CVT_NONE:
+					sc->rcvttab = 0;
+					sc->wcvttab = 0;
+					break;
+				case CVT_ALAW2ULAW:
+					sc->rcvttab = alaw_ulaw;
+					sc->wcvttab = ulaw_alaw;
+					break;
+				case CVT_ALAW_CANON:
+					sc->rcvttab = bitreverse;
+					sc->wcvttab = bitreverse;
+					break;
+				default:
+					error = ENODEV;
+					break;
+			}
+			if(error == 0)
+				sc->audiofmt = *(int *)data;
 			break;
 
 		case I4B_TEL_EMPTYINPUTQUEUE:
@@ -355,13 +387,13 @@
 
 	IF_DEQUEUE(sc->isdn_linktab->rx_queue, m);
 
-	if(m && m->m_len)
+	if(m && m->m_len > 0)
 	{
-		if(sc->audiofmt == CVT_ALAW2ULAW)
+		if(sc->rcvttab)
 		{
 			int i;
 		        for(i = 0; i < m->m_len; i++)
-                                m->m_data[i] =
alaw_ulaw[(int)m->m_data[i]];
+                                mtod(m,u_char *)[i] =
sc->rcvttab[mtod(m,u_char *)[i]];
                 }
 		error = uiomove(m->m_data, m->m_len, uio);
 	}
@@ -450,11 +482,11 @@
 
 		error = uiomove(m->m_data, m->m_len, uio);
 
-		if(sc->audiofmt == CVT_ALAW2ULAW)
+		if(sc->wcvttab)
 		{
 			int i;
 		        for(i = 0; i < m->m_len; i++)
-                                m->m_data[i] =
ulaw_alaw[(int)m->m_data[i]];
+                                mtod(m,u_char *)[i] =
sc->wcvttab[mtod(m,u_char *)[i]];
                 }
 		
 		IF_ENQUEUE(sc->isdn_linktab->tx_queue, m);
@@ -633,80 +665,73 @@
 
*===========================================================================
*/
 
 /*-------------------------------------------------------------------------
--*
- *	A-law to mu-law conversion
+ *	Line format to mu-law conversion
+
*---------------------------------------------------------------------------
*/
+static unsigned char alaw_ulaw[256] = {
+	0x2a, 0xa9, 0x62, 0xe1, 0x0a, 0x8a, 0x48, 0xc8, 0x39, 0xb9, 0x75, 0xf3,
0x1a, 0x9a, 0x56, 0xd6,
+	0x22, 0xa1, 0x5d, 0xdc, 0x02, 0x82, 0x40, 0xc0, 0x31, 0xb1, 0x6a, 0xe9,
0x12, 0x92, 0x4f, 0xcf,
+	0x2e, 0xad, 0x66, 0xe5, 0x0e, 0x8e, 0x4c, 0xcc, 0x3d, 0xbd, 0x7d, 0xfb,
0x1e, 0x9e, 0x5a, 0xda,
+	0x26, 0xa5, 0x5f, 0xde, 0x06, 0x86, 0x44, 0xc4, 0x35, 0xb5, 0x6e, 0xed,
0x16, 0x96, 0x52, 0xd2,
+	0x28, 0xa7, 0x60, 0xdf, 0x08, 0x88, 0x46, 0xc6, 0x37, 0xb7, 0x71, 0xef,
0x18, 0x98, 0x54, 0xd4,
+	0x20, 0x9f, 0x5c, 0xdb, 0x00, 0x80, 0x3f, 0xbf, 0x2f, 0xaf, 0x68, 0xe7,
0x10, 0x90, 0x4e, 0xce,
+	0x2c, 0xab, 0x64, 0xe3, 0x0c, 0x8c, 0x4a, 0xca, 0x3b, 0xbb, 0x79, 0xf7,
0x1c, 0x9c, 0x58, 0xd8,
+	0x24, 0xa3, 0x5e, 0xdd, 0x04, 0x84, 0x42, 0xc2, 0x33, 0xb3, 0x6c, 0xeb,
0x14, 0x94, 0x50, 0xd0,
+	0x2b, 0xaa, 0x63, 0xe2, 0x0b, 0x8b, 0x49, 0xc9, 0x3a, 0xba, 0x77, 0xf5,
0x1b, 0x9b, 0x57, 0xd7,
+	0x23, 0xa2, 0x5d, 0xdd, 0x03, 0x83, 0x41, 0xc1, 0x32, 0xb2, 0x6b, 0xea,
0x13, 0x93, 0x4f, 0xcf,
+	0x2f, 0xae, 0x67, 0xe6, 0x0f, 0x8f, 0x4d, 0xcd, 0x3e, 0xbe, 0xff, 0xfd,
0x1f, 0x9f, 0x5b, 0xdb,
+	0x27, 0xa6, 0x5f, 0xdf, 0x07, 0x87, 0x45, 0xc5, 0x36, 0xb6, 0x6f, 0xee,
0x17, 0x97, 0x53, 0xd3,
+	0x29, 0xa8, 0x61, 0xe0, 0x09, 0x89, 0x47, 0xc7, 0x38, 0xb8, 0x73, 0xf1,
0x19, 0x99, 0x55, 0xd5,
+	0x21, 0xa0, 0x5c, 0xdc, 0x01, 0x81, 0x3f, 0xbf, 0x30, 0xb0, 0x69, 0xe8,
0x11, 0x91, 0x4e, 0xce,
+	0x2d, 0xac, 0x65, 0xe4, 0x0d, 0x8d, 0x4b, 0xcb, 0x3c, 0xbc, 0x7b, 0xf9,
0x1d, 0x9d, 0x59, 0xd9,
+	0x25, 0xa4, 0x5e, 0xde, 0x05, 0x85, 0x43, 0xc3, 0x34, 0xb4, 0x6d, 0xec,
0x15, 0x95, 0x51, 0xd1,
+};
+
+
+/*-------------------------------------------------------------------------
--*
+ *	mu-law to line format conversion
 
*---------------------------------------------------------------------------
*/
-static unsigned char alaw_ulaw[] = {
-	0x002a, 0x00a9, 0x005f, 0x00e3, 0x001f, 0x009f, 0x0048, 0x00c8,
-	0x0039, 0x00b9, 0x006f, 0x00f7, 0x001f, 0x009f, 0x0055, 0x00d7,
-	0x0022, 0x00a1, 0x005b, 0x00dd, 0x001f, 0x009f, 0x0040, 0x00c0,
-	0x0031, 0x00b1, 0x0067, 0x00eb, 0x001f, 0x009f, 0x004e, 0x00cf,
-	0x002e, 0x00ad, 0x0063, 0x00e7, 0x001f, 0x009f, 0x004c, 0x00cc,
-	0x003d, 0x00bd, 0x0077, 0x00ff, 0x001f, 0x009f, 0x0059, 0x00db,
-	0x0026, 0x00a5, 0x005d, 0x00df, 0x001f, 0x009f, 0x0044, 0x00c4,
-	0x0035, 0x00b5, 0x006b, 0x00ef, 0x001f, 0x009f, 0x0051, 0x00d3,
-	0x0028, 0x00a7, 0x005f, 0x00e3, 0x001f, 0x009f, 0x0046, 0x00c6,
-	0x0037, 0x00b7, 0x006f, 0x00f7, 0x001f, 0x009f, 0x0053, 0x00d5,
-	0x0020, 0x009f, 0x005b, 0x00dd, 0x001f, 0x009f, 0x003f, 0x00bf,
-	0x002f, 0x00af, 0x0067, 0x00eb, 0x001f, 0x009f, 0x004d, 0x00ce,
-	0x002c, 0x00ab, 0x0063, 0x00e7, 0x001f, 0x009f, 0x004a, 0x00ca,
-	0x003b, 0x00bb, 0x0077, 0x00ff, 0x001f, 0x009f, 0x0057, 0x00d9,
-	0x0024, 0x00a3, 0x005d, 0x00df, 0x001f, 0x009f, 0x0042, 0x00c2,
-	0x0033, 0x00b3, 0x006b, 0x00ef, 0x001f, 0x009f, 0x004f, 0x00d1,
-	0x002b, 0x00aa, 0x0063, 0x00e3, 0x001f, 0x009f, 0x0049, 0x00c9,
-	0x003a, 0x00ba, 0x0077, 0x00f7, 0x001f, 0x009f, 0x0057, 0x00d7,
-	0x0023, 0x00a2, 0x005d, 0x00dd, 0x001f, 0x009f, 0x0041, 0x00c1,
-	0x0032, 0x00b2, 0x006b, 0x00eb, 0x001f, 0x009f, 0x004f, 0x00cf,
-	0x002f, 0x00ae, 0x0067, 0x00e7, 0x001f, 0x009f, 0x004d, 0x00cd,
-	0x003e, 0x00be, 0x00ff, 0x00ff, 0x001f, 0x009f, 0x005b, 0x00db,
-	0x0027, 0x00a6, 0x005f, 0x00df, 0x001f, 0x009f, 0x0045, 0x00c5,
-	0x0036, 0x00b6, 0x006f, 0x00ef, 0x001f, 0x009f, 0x0053, 0x00d3,
-	0x0029, 0x00a8, 0x005f, 0x00e3, 0x001f, 0x009f, 0x0047, 0x00c7,
-	0x0038, 0x00b8, 0x006f, 0x00f7, 0x001f, 0x009f, 0x0055, 0x00d5,
-	0x0021, 0x00a0, 0x005b, 0x00dd, 0x001f, 0x009f, 0x003f, 0x00bf,
-	0x0030, 0x00b0, 0x0067, 0x00eb, 0x001f, 0x009f, 0x004e, 0x00ce,
-	0x002d, 0x00ac, 0x0063, 0x00e7, 0x001f, 0x009f, 0x004b, 0x00cb,
-	0x003c, 0x00bc, 0x0077, 0x00ff, 0x001f, 0x009f, 0x0059, 0x00d9,
-	0x0025, 0x00a4, 0x005d, 0x00df, 0x001f, 0x009f, 0x0043, 0x00c3,
-	0x0034, 0x00b4, 0x006b, 0x00ef, 0x001f, 0x009f, 0x0051, 0x00d1
+static unsigned char ulaw_alaw[256] = {
+	0x54, 0xd4, 0x14, 0x94, 0x74, 0xf4, 0x34, 0xb4, 0x44, 0xc4, 0x04, 0x84,
0x64, 0xe4, 0x24, 0xa4,
+	0x5c, 0xdc, 0x1c, 0x9c, 0x7c, 0xfc, 0x3c, 0xbc, 0x4c, 0xcc, 0x0c, 0x8c,
0x6c, 0xec, 0x2c, 0xac,
+	0xd0, 0x10, 0x90, 0x70, 0xf0, 0x30, 0xb0, 0x40, 0xc0, 0x00, 0x80, 0x60,
0xe0, 0x20, 0xa0, 0x58,
+	0xd8, 0x18, 0x98, 0x78, 0xf8, 0x38, 0xb8, 0x48, 0xc8, 0x08, 0x88, 0x68,
0xe8, 0x28, 0xa8, 0xd6,
+	0x16, 0x96, 0x76, 0xf6, 0x36, 0xb6, 0x46, 0xc6, 0x06, 0x86, 0x66, 0xe6,
0x26, 0xa6, 0xde, 0x9e,
+	0x7e, 0xfe, 0x3e, 0xbe, 0x4e, 0xce, 0x0e, 0x8e, 0x6e, 0xee, 0x2e, 0xae,
0xd2, 0x92, 0xf2, 0xb2,
+	0xc2, 0x02, 0x82, 0x62, 0xe2, 0x22, 0xa2, 0x5a, 0xda, 0x1a, 0x9a, 0x7a,
0xfa, 0x3a, 0xba, 0x4a,
+	0x4a, 0xca, 0xca, 0x0a, 0x0a, 0x8a, 0x8a, 0x6a, 0x6a, 0xea, 0xea, 0x2a,
0x2a, 0xaa, 0xab, 0xab,
+	0x55, 0xd5, 0x15, 0x95, 0x75, 0xf5, 0x35, 0xb5, 0x45, 0xc5, 0x05, 0x85,
0x65, 0xe5, 0x25, 0xa5,
+	0x5d, 0xdd, 0x1d, 0x9d, 0x7d, 0xfd, 0x3d, 0xbd, 0x4d, 0xcd, 0x0d, 0x8d,
0x6d, 0xed, 0x2d, 0xad,
+	0x51, 0xd1, 0x11, 0x91, 0x71, 0xf1, 0x31, 0xb1, 0x41, 0xc1, 0x01, 0x81,
0x61, 0xe1, 0x21, 0xa1,
+	0xd9, 0x19, 0x99, 0x79, 0xf9, 0x39, 0xb9, 0x49, 0xc9, 0x09, 0x89, 0x69,
0xe9, 0x29, 0xa9, 0x57,
+	0x17, 0x97, 0x77, 0xf7, 0x37, 0xb7, 0x47, 0xc7, 0x07, 0x87, 0x67, 0xe7,
0x27, 0xa7, 0x5f, 0x1f,
+	0x7f, 0xff, 0x3f, 0xbf, 0x4f, 0xcf, 0x0f, 0x8f, 0x6f, 0xef, 0x2f, 0xaf,
0x53, 0x13, 0x73, 0x33,
+	0x43, 0xc3, 0x03, 0x83, 0x63, 0xe3, 0x23, 0xa3, 0x5b, 0xdb, 0x1b, 0x9b,
0x7b, 0xfb, 0x3b, 0xbb,
+	0xbb, 0x4b, 0x4b, 0xcb, 0xcb, 0x0b, 0x0b, 0x8b, 0x8b, 0x6b, 0x6b, 0xeb,
0xeb, 0x2b, 0x2b, 0xab,
 };
 
+
 /*-------------------------------------------------------------------------
--*
- *	mu-law to A-law conversion
+ *	bit-reverse the sample to convert from/to canonical A-law
 
*---------------------------------------------------------------------------
*/
-static unsigned char ulaw_alaw[] = {
-	0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc,
-	0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc,
-	0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc,
-	0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00ac,
-	0x0050, 0x00d0, 0x0010, 0x0090, 0x0070, 0x00f0, 0x0030, 0x00b0,
-	0x0040, 0x00c0, 0x0000, 0x0080, 0x0060, 0x00e0, 0x0020, 0x00a0,
-	0x00d8, 0x0018, 0x0098, 0x0078, 0x00f8, 0x0038, 0x00b8, 0x0048,
-	0x00c8, 0x0008, 0x0088, 0x0068, 0x00e8, 0x0028, 0x00a8, 0x00d6,
-	0x0096, 0x0076, 0x00f6, 0x0036, 0x00b6, 0x0046, 0x00c6, 0x0006,
-	0x0086, 0x0066, 0x00e6, 0x0026, 0x00a6, 0x00de, 0x009e, 0x00fe,
-	0x00fe, 0x00be, 0x00be, 0x00ce, 0x00ce, 0x008e, 0x008e, 0x00ee,
-	0x00ee, 0x00d2, 0x00d2, 0x00f2, 0x00f2, 0x00c2, 0x00c2, 0x00e2,
-	0x00e2, 0x00e2, 0x00da, 0x00da, 0x00da, 0x00da, 0x00fa, 0x00fa,
-	0x00fa, 0x00fa, 0x00ca, 0x00ca, 0x00ca, 0x00ca, 0x00ea, 0x00ea,
-	0x00ea, 0x00ea, 0x00ea, 0x00ea, 0x00eb, 0x00eb, 0x00eb, 0x00eb,
-	0x00eb, 0x00eb, 0x00eb, 0x00eb, 0x00eb, 0x00eb, 0x00eb, 0x00eb,
-	0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd,
-	0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd,
-	0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd,
-	0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd,
-	0x00d1, 0x0011, 0x0091, 0x0071, 0x00f1, 0x0031, 0x00b1, 0x0041,
-	0x00c1, 0x0001, 0x0081, 0x0061, 0x00e1, 0x0021, 0x00a1, 0x0059,
-	0x00d9, 0x0019, 0x0099, 0x0079, 0x00f9, 0x0039, 0x00b9, 0x0049,
-	0x00c9, 0x0009, 0x0089, 0x0069, 0x00e9, 0x0029, 0x00a9, 0x0057,
-	0x0017, 0x0097, 0x0077, 0x00f7, 0x0037, 0x00b7, 0x0047, 0x00c7,
-	0x0007, 0x0087, 0x0067, 0x00e7, 0x0027, 0x00a7, 0x00df, 0x009f,
-	0x009f, 0x00ff, 0x00ff, 0x00bf, 0x00bf, 0x00cf, 0x00cf, 0x008f,
-	0x008f, 0x00ef, 0x00ef, 0x00af, 0x00af, 0x00d3, 0x00d3, 0x00f3,
-	0x00f3, 0x00f3, 0x00c3, 0x00c3, 0x00c3, 0x00c3, 0x00e3, 0x00e3,
-	0x00e3, 0x00e3, 0x00db, 0x00db, 0x00db, 0x00db, 0x00fb, 0x00fb,
-	0x00fb, 0x00fb, 0x00fb, 0x00fb, 0x00cb, 0x00cb, 0x00cb, 0x00cb,
-	0x00cb, 0x00cb, 0x00cb, 0x00cb, 0x00eb, 0x00eb, 0x00eb, 0x00eb
+static unsigned char bitreverse[256] = {
+	0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0,
0x30, 0xb0, 0x70, 0xf0, 
+	0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8,
0x38, 0xb8, 0x78, 0xf8, 
+	0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4,
0x34, 0xb4, 0x74, 0xf4, 
+	0x0c, 0x8c, 0x4c, 0x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a7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7,
0x37, 0xb7, 0x77, 0xf7, 
+	0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf,
0x3f, 0xbf, 0x7f, 0xff, 
 };
+
 
 /*=========================================================================
==*/
 
--- ./isdntelctl/main.c.orig	Mon Dec 14 11:31:57 1998
+++ ./isdntelctl/main.c	Wed Dec 30 22:18:21 1998
@@ -58,6 +58,7 @@
 int opt_U = 0;
 int opt_A = 0;
 int opt_C = 0;
+int opt_R = 0;
 
 /*-------------------------------------------------------------------------
--*
  *	program entry
@@ -70,7 +71,7 @@
 	int telfd;
 	char namebuffer[128];
 	
-	while ((c = getopt(argc, argv, "cgu:AU?")) != EOF)
+	while ((c = getopt(argc, argv, "cgu:AUR?")) != EOF)
 	{
 		switch(c)
 		{
@@ -96,6 +97,10 @@
 				opt_U = 1;
 				break;
 
+			case 'R':
+				opt_R = 1;
+				break;
+
 			case '?':
 			default:
 				usage();
@@ -103,12 +108,12 @@
 		}
 	}
 
-	if(opt_get == 0 && opt_U == 0 && opt_A && opt_C == 0)
+	if(opt_get == 0 && opt_R == 0 && opt_U == 0 && opt_A == 0 && opt_C == 0)
 	{
 		opt_get = 1;
 	}
 
-	if((opt_get + opt_U + opt_A + opt_C) > 1)
+	if((opt_get + opt_R + opt_U + opt_A + opt_C) > 1)
 	{
 		usage();
 	}
@@ -139,6 +144,10 @@
 		{
 			printf("device %s uses u-Law sound format\n", namebuffer);
 		}
+		else if(format == CVT_ALAW_CANON)
+		{
+			printf("device %s uses canonical A-Law sound format\n", namebuffer);
+		}
 		else
 		{
 			printf("ERROR, device %s uses unknown format %d!\n", namebuffer,
format);
@@ -169,6 +178,17 @@
 		}
 		exit(0);
 	}
+	if(opt_R)
+	{
+		int format = CVT_ALAW_CANON;
+		
+		if((ret = ioctl(telfd, I4B_TEL_SETAUDIOFMT, &format)) < 0)
+		{
+			fprintf(stderr, "ioctl I4B_TEL_SETAUDIOFMT failed: %s",
strerror(errno));
+			exit(1);
+		}
+		exit(0);
+	}
 	if(opt_C)
 	{
 		int dummy;
@@ -195,6 +215,7 @@
 	fprintf(stderr, "       -u unit       specify unit number\n");	
 	fprintf(stderr, "       -A            set interface to A-Law coding\n");
 	fprintf(stderr, "       -U            set interface to u-Law coding\n");
+	fprintf(stderr, "       -R            set interface to canonical (regular)
A-Law coding\n");
 	fprintf(stderr, "       -c            clear input queue\n");
 	fprintf(stderr, "\n");
 	exit(1);
--- ./isdntelctl/isdntelctl.8.orig	Mon Dec 14 11:31:55 1998
+++ ./isdntelctl/isdntelctl.8	Wed Dec 30 22:18:21 1998
@@ -38,6 +38,7 @@
 .Op Fl u Ar unit
 .Op Fl A
 .Op Fl U
+.Op Fl R
 .Sh DESCRIPTION
 .Nm isdntelctl
 is part of the isdn4bsd package and is used to configure the sound format
@@ -56,6 +57,14 @@
 Set sound format to A-Law.
 .It Fl U
 Set sound format to u-Law.
+.It Fl R
+Set sound format to canonical (regular) A-Law format.
+.El
+.Pp
+By default, isdn4bsd sends and receives audio in A-Law as provided by the
+hardware. However, these samples cannot easily be processed further as the
+sample word is bit-reversed. Both the u-Law and canonical A-Law formats
+store samples in a way suitable for post-processing by e.\ g. sox(1).
 .Pp
 .Sh FILES
 /dev/i4btel<n>
--- ./machine/i4b_tel_ioctl.h.orig	Mon Dec 14 11:31:58 1998
+++ ./machine/i4b_tel_ioctl.h	Wed Dec 30 22:18:21 1998
@@ -40,6 +40,7 @@
 
 #define CVT_NONE	0		/* no format conversion	*/
 #define CVT_ALAW2ULAW	1		/* kernel A-law, userland mu-law */
+#define CVT_ALAW_CANON	2		/* kernel A-law, userland canonical A-law */
       
 /*-------------------------------------------------------------------------
--*
  *	get / set audio format 

--==========01048950==========--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-isdn" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1031949.3124534411>