From owner-freebsd-hackers Fri Mar 29 8:22:18 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from smtpproxy1.mitre.org (smtpproxy1.mitre.org [129.83.20.90]) by hub.freebsd.org (Postfix) with ESMTP id 9A7B437B41A for ; Fri, 29 Mar 2002 08:22:12 -0800 (PST) Received: from avsrv1.mitre.org (avsrv1.mitre.org [129.83.20.58]) by smtpproxy1.mitre.org (8.11.3/8.11.3) with ESMTP id g2TGLx819842; Fri, 29 Mar 2002 11:21:59 -0500 (EST) Received: from MAILHUB2 (mailhub2.mitre.org [129.83.221.18]) by smtpsrv1.mitre.org (8.11.3/8.11.3) with ESMTP id g2TGLwH09069; Fri, 29 Mar 2002 11:21:58 -0500 (EST) Received: from dhcp-105-164.mitre.org (128.29.105.164) by mailhub2.mitre.org with SMTP id 9729029; Fri, 29 Mar 2002 11:21:47 -0500 Message-ID: <3CA4949C.4D36CA1C@mitre.org> Date: Fri, 29 Mar 2002 11:21:48 -0500 From: Jason Andresen Organization: The MITRE Corporation X-Mailer: Mozilla 4.75 [en]C-20000818M (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: Sue Blake Cc: freebsd-hackers@freebsd.org Subject: Re: PC speaker tunes for everybody References: <20020329182638.D10242@welearn.com.au> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Sue Blake wrote: > > I'm looking for some general advice before I attempt to write a > program to play PC speaker tunes from abc music notation > http://www.gre.ac.uk/~c.walshaw/abc/ > (In case anyone notices a program called playabc which is > advertised as doing this, no, it actually produces a .au file > and sends it to the sound card, not the speaker.) > > For FreeBSD I could produce output in the format described > in spkr(4) and send it to /dev/speaker, using perl which is > already half fathomable to me. I'm not sure if there's another > way to play the speaker more directly, but I suspect there is > one that clever people know about and that would require C > or worse. I'm looking at /usr/local/src/sys/i386/isa/spkr.c > and wishing I understood what it's trying to tell me. Well, you can fiddle with the ioctl: Here's an exerpt from some code I used to make unique beeps for ICQ events: int speaker; int freq, dur; tone_t note; ... note.frequency = freq; /* in hertz */ note.duration = dur; /* in 1/100s of a second */ /* Play the beep sound */ if ( ioctl(speaker, SPKRTONE, ¬e) == -1 ) { perror("speakbeep: ioctl"); return(3); } That's the most direct way I know to access the speaker, unfortunatly the PC speaker is not a musical instrument, YMMV. BTW, the PC speaker is highly underrated as a notification service. For instance, I still get ICQ beeps (unique ones at that) even if the speakers are turned off or I have headphones plugged in or some other sounds sitting on the audio device (although this is less trouble now that Vchans and multiple play devices are supported). > Linux users report they have no speaker device, and I've > never found a Linux user who plays speaker tunes. > Other types of unix are even more of a mystery. > > So my question is, if I were to output strings to /dev/speaker, > would it only work on FreeBSD? And if so, is there another > approach I could take to make the program useful to more of > the PC speaker tune fanatics who might want to use it on > unix-like systems? If so it might be worth investing > considerably more effort. Or is in in the nature of these > wonderful antique musical instruments that any solution > has to be OS-dependent? > > (An email cc would be appreciated, since IANAH.) > -- \ |_ _|__ __|_ \ __| Jason Andresen jandrese@mitre.org |\/ | | | / _| Network and Distributed Systems Engineer _| _|___| _| _|_\___| Office: 703-883-7755 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message