Return to BSD News archive
Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!haven.umd.edu!uunet!pipex!uknet!mcsun!Germany.EU.net!unidus.rz.uni-duesseldorf.de!mueller.rz.uni-duesseldorf.de!dvs From: dvs@ze8.rz.uni-duesseldorf.de (Wolfgang R. Mueller) Newsgroups: comp.os.386bsd.misc Subject: [SOURCE] PC Speaker Player for Internet Talk Radio .au Files Date: Thu, 15 Apr 1993 14:03:50 GMT Organization: Computing Centre, Heinrich-Heine-University, Duesseldorf, Germany Lines: 32 Message-ID: <dvs.101.734882630@ze8.rz.uni-duesseldorf.de> NNTP-Posting-Host: mueller.rz.uni-duesseldorf.de Please find below a short player for Internet Talk Radio .au files over the normal PC speaker. The three delay loops "for(i=1;i<120;i++)" will need adjustments for other cpu speeds than a 486dx33. -------------------------------------------------------- #include <stdio.h> #define inb(y) \ ({ unsigned char _tmp__; \ asm volatile("inb %1, %0" : "=a" (_tmp__) : "d" ((unsigned short)(y))); \ _tmp__; }) #define outb(x, y) \ { asm volatile("outb %0, %1" : : "a" ((unsigned char)(y)) , "d" ((unsigned short)(x))); } void main() { unsigned char a,b,e,i,j, ulaw[256]; short l; FILE *fp; fp=fopen("/dev/mem","rw"); if (fp==NULL) { printf("can't get I/O permissions \n"); exit(-1); } for(l=0;l<256;l++) { b=(l&0x7f)>>2; ulaw[l]=l&0x80?63-b:b; } b=0x33; e=inb(0x61)|0x03; outb(0x43,0x92); outb(0x42,b); while(l!=EOF) { a=b; l=getchar(); b=ulaw[l&0xff]; for(j=1;j<120;j++); outb(0x61,e); outb(0x61,e-1); outb(0x42,(a+b)>>1); for(j=1;j<120;j++); outb(0x61,e); outb(0x61,e-1); outb(0x42,b); for(j=1;j<120;j++); outb(0x61,e); outb(0x61,e-1); outb(0x42,b); } putchar(7); fclose(fp); } ------------------------------- Have fun, Wolfgang R. Mueller <dvs@ze8.rz.uni-duesseldorf.de>, Computing Centre, Heinrich-Heine-University, Duesseldorf, Germany.