As a matter of fact...

PC Speaker support with linux

Fixed frequency sounds

A part of console driver (do not require sound support).
Documentation: man console_ioctl (in /usr/man/man4)

"WARNING: If you use the following information you are going to burn yourself." (as said in the man page)

/*---------------------------------------*/
/* A sample program to play C major      */
/* through a PC speaker                  */
/*---------------------------------------*/
/* This won't work if standard output is */
/* re-directed to a non-tty device, or   */
/* PC speaker wave output is active      */
/*---------------------------------------*/
/* M.G. 27-Nov-99                        */
/*---------------------------------------*/
#include <sys/ioctl.h>
#include <unistd.h>
#include <linux/kd.h>
int main(void)
{
	int freq[] = { /* C   D    E    F    G    A    B    C */
			523, 587, 659, 698, 784, 880, 988, 1046 };
	int i;

	for (i=0; i<8; i++)
	{
		ioctl(STDOUT_FILENO, KIOCSOUND, 1193180/freq[i]);
		usleep(500000);
	}
	ioctl(STDOUT_FILENO, KIOCSOUND, 0); /*Stop silly sound*/
	return 0;
}

Back Next