speaker(4) - NetBSD Manual Pages

Command: Section: Arch: Collection:  
SPEAKER(4)              NetBSD Kernel Interfaces Manual             SPEAKER(4)

speaker -- console speaker audio device driver
spkr* at pcppi? spkr* at audio? #include <dev/spkrio.h>
The speaker device driver allows applications to control the console speaker on machines with a PC-like 8253 timer implementation or a synthe- sized speaker from an audio device/soundcard. Only one process may have this device open at any given time; open(2) and close(2) are used to lock and relinquish it. An attempt to open(2) when another process has the device locked will return -1 with an EBUSY error indication. Writes to the device are interpreted as ``play strings'' in a simple ASCII melody notation. An ioctl() for tone generation at arbi- trary frequencies is also supported. For the pcppi(4) device sound-generation does not monopolize the proces- sor; in fact, the driver spends most of its time sleeping while the PC hardware is emitting tones. Other processes may emit beeps while the driver is running. For the audio device speaker, the speaker uses one of the virtual audio channels. Enabling this device will also provide a wsbell(4) keyboard bell. Applications may call ioctl() on a speaker file descriptor to control the speaker driver directly; definitions for the ioctl() interface are in <dev/spkrio.h>. The tone_t structure is as follows: typedef struct { int frequency; /* in hertz */ int duration; /* in 1/100ths of a second */ } tone_t; A frequency of zero is interpreted as a rest. At present there are four ioctls: SPKRGETVOL Returns an integer, which is the current bell volume as a percentage (0-100). SPKRSETVOL Accepts an integer, which is the desired volume as a per- centage. SPKRTONE Accepts a pointer to a single tone structure as third argu- ment and plays it. SPKRTUNE Accepts a pointer to the first of an array of tone struc- tures and plays them in continuous sequence; this array must be terminated by a final member with a zero duration. Play string language The play string language is modelled on the PLAY statement conventions of IBM BASIC 2.0. The MB, MF and X commands of PLAY are not useful in a UNIX environment and are not implemented. The ``octave-tracking'' fea- ture is also new. There are 84 accessible notes numbered 1-84 in 7 octaves numbered 0-6; octave 2 starts with middle C. The tuning is equal-tempered A440. In the initial state the current octave is 4, the default note duration is quarter notes, the tempo is 120 bpm, and the articulation is non- legato or normal, i.e. half-second notes with the last 1/16th second being ``rest time''. Play strings are interpreted left to right as a series of play command groups. Letter case is ignored. Whitespace between groups is ignored and may be used to separate melody sections. Play command groups are as follows: C, D, E, F, G, A, B Letters `A' through `G' cause the corresponding note to be played in the current octave. A note letter may optionally be followed by an accidental sign, one of `#', `+', or `-'; the first two of these cause it to be sharped one half-tone, the last causes it to be flatted one half-tone. It may also be followed by a time value number and by sustain dots (see below). Time values are interpreted as for the `L' command below;. On, OL, ON If n is numeric, this sets the current octave. `OL' enables, and `ON' disables octave-tracking (it is disabled by default). When octave-tracking is on, interpretation of a pair of letter notes will change octaves if necessary in order to make the smallest possible jump between notes. Thus ``olbc'' will be played as ``olb>c'', and ``olcb'' as ``olc<b''. Octave tracking is temporarily disabled for one letter note that follows `>', `<' or `On'. > Bump the current octave up one. < Drop the current octave down one. Nn Play note n, n being 1 to 84 or 0 for a rest of current time value. May be followed by sustain dots. Ln Sets the current time value for notes. The default is ``L4'', quarter notes. The lowest possible value is 1; val- ues up to 64 are accepted. ``L1'' sets whole notes, ``L2'' sets half notes, ``L4'' sets quarter notes, etc... Pn, ~n Pause (rest), with n interpreted as for `L'. May be followed by sustain dots. Tn Sets the number of quarter notes per minute; default is 120. Musical names for common tempi are: Tempo BPM very slow Larghissimo Largo 40-60 Larghetto 60-66 Grave Lento Adagio 66-76 slow Adagietto Andante 76-108 medium Andantino Moderato 108-120 fast Allegretto Allegro 120-168 Vivace Veloce Presto 168-208 very fast Prestissimo ML, MN, MS Set articulation. `MN' (for normal) is the default; the last 1/8th of the note's value is rest time. You can set `ML' for legato (no rest time) or `MS' for staccato (1/4 rest time). Notes, that is, C, D, E, F, G, A, B, or N command character groups, may be followed by sustain dots. Each dot causes the note's value to be lengthened by one-half for each one. Thus, a note dotted once is held for 3/2 of its undotted value; dotted twice, it is held 9/4, and three times would give 27/8.
audio(4), pcppi(4), wsbell(4), sysctl(8)
This speaker device was originally for the pcppi PC timer interface. Support was added for a synthesized device by Nathanial Sloss, first appearing in NetBSD 8.0.
Eric S. Raymond <esr@snark.thyrsus.com>
Due to roundoff in the pitch tables and slop in the tone-generation and timer hardware (neither of which was designed for precision), neither pitch accuracy nor timings will be mathematically exact. There is no volume control. The action of two or more sustain dots does not reflect standard musical notation, in which each dot adds half the value of the previous dot modi- fier, not half the value of the note as modified. Thus, a note dotted once is held for 3/2 of its undotted value; dotted twice, it is held 7/4, and three times would give 15/8. The multiply-by-3/2 interpretation, however, is specified in the IBM BASIC manual and has been retained for compatibility. In play strings which are very long (longer than your system's physical I/O blocks) note suffixes or numbers may occasionally be parsed incor- rectly due to crossing a block boundary. NetBSD 10.99 June 13, 2017 NetBSD 10.99
Powered by man-cgi (2024-03-20). Maintained for NetBSD by Kimmo Suominen. Based on man-cgi by Panagiotis Christias.