Skip to content

jorissteyn/php_pcspeak

Repository files navigation

PHP PCSpeak

This PHP extension exposes an API to control your PC speaker.

API Overview

A console terminal device is used to access the hardware. Before you can use the speaker, open a device:

pcspeak_open("/dev/tty");

Note that you must have privileges to access the device. Opening the TTY from your current session should work without special privileges.

To start and sustain a tone on the speaker, use:

pcspeak_sustain($note, $octave);

The pitch of the speaker is determined based on the two arguments passed to pcspeak_sustain. These arguments are integers mapped on the chromatic scale to the corresponding frequency. To sustain a 'central-C', pass $note=0 and $octave=4

To release the tone, use:

pcspeak_release();

By providing a "low level" sustain/release mechanism, it's possible to produce audible signals without blocking normal execution of the application.

When finished, close the device:

pcspeak_close();

Demo

The demo folder contains a music player, check it out!

demo $ ./demo.php --device=/dev/console

Random thoughts and further reading

About

A PC speaker API for PHP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published