A way to get music from your PC beeper in any Linux program. Implements most of the functionality from PLAY in GW/Q-basic.
There you have it, a library ready to compile into your own alarm clock,
midi player or whatever. The library is dropped into
A program called
beeplibdemo will appear in
Look at the
Makefile, decide what you need, what you want
to adjust and just do it.
void noteon(int i)
Turns on note i. Silences any previously playing note.
can range from 0 to 84 (0 meaning pause).
Turns off the playing note.
int play(char *str)
Plays the contents of
str, check out the music macro
void retune(int pos, float hz, int type)
Retune with frequency
hz in position
type can be
There is also a constant
MID_A defined for using as
demo.c is an example of how to use libbeep.
Compile it (
-lm) and feed
wasted_years.txt to see if everything works. To try out
retuning you can use the -n [frequency] and -e [frequency] options. And
remember to turn off the noise if your own program gets signalled!
As the speaker is part of the Linux console your finished program should have console access (either run from the console or root privileges). I don't think root privileges is a good idea, there is always a potential for dangerous bugs in that.
Don't even try to build this on anything else than Linux if you don't know exactly what you're doing. I haven't given portability the slightest thought.
This is the stuff you can feed the play(char *string) function. And it's case INsensitive.
MS=staccato (shorter notes),
ML=legato (notes run together)
+turn it sharp, - flattens.
<l>is present, change length only for this note.
C##4....plays a long D
n, see previous paragraph for explanation of periods. The range is 0..84 (0 means pause!) and the length is always the default one.
How could this take 8 months? Beats me :-)
Xcommands are not recognized. (read your Q-Basic manual if you care...)
-ansi. That's simply because
usleep(3)isn't ANSI C.
play()function eats anything. Try
(echo "T255L8"; cat demo.c) | beeplibdemofor some modern music in C major.
Raine M. Ekman, firstname.lastname@example.org. (Visit my home page)
I'm not a programmer. I'm a slacker, don't expect any new versions to appear. This is just a way of destroying some of that rare spare time when an urge to do something comes over me.