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 [EMAIL PROTECTED]
|\/ | | | / _| Network and Distributed Systems Engineer
_| _|___| _| _|_\___| Office: 703-883-7755
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message