1 .\" $NetBSD: speaker.4,v 1.12 2003/04/16 13:35:18 wiz Exp $
3 .\" Copyright (c) 1993 Christopher G. Demetriou
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. All advertising materials mentioning features or use of this software
15 .\" must display the following acknowledgement:
16 .\" This product includes software developed for the
17 .\" NetBSD Project. See http://www.NetBSD.org/ for
18 .\" information about NetBSD.
19 .\" 4. The name of the author may not be used to endorse or promote products
20 .\" derived from this software without specific prior written permission.
22 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 .\" <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
40 .Nd console speaker audio device driver
46 The speaker device driver allows applications to control the console
47 speaker on machines with a PC-like 8253 timer implementation.
49 Only one process may have this device open at any given time; open() and
50 close() are used to lock and relinquish it. An attempt to open() when
51 another process has the device locked will return -1 with an
53 error indication. Writes to the device are interpreted as 'play strings' in a
54 simple ASCII melody notation. An
56 for tone generation at arbitrary frequencies is also supported.
60 monopolize the processor; in fact, the driver
61 spends most of its time sleeping while the PC hardware is emitting
62 tones. Other processes may emit beeps while the driver is running.
66 on a speaker file descriptor to control the speaker driver directly;
70 .Aq Pa machine/spkr.h .
71 The tone_t structure used in these calls has two fields,
72 specifying a frequency (in hz) and a duration (in 1/100ths of a second).
73 A frequency of zero is interpreted as a rest.
75 At present there are two such ioctls. SPKRTONE accepts a pointer to a
76 single tone structure as third argument and plays it. SPKRTUNE accepts a
77 pointer to the first of an array of tone structures and plays them in
78 continuous sequence; this array must be terminated by a final member with
81 The play-string language is modelled on the PLAY statement conventions of
82 IBM BASIC 2.0. The MB, MF and X primitives of PLAY are not useful in a UNIX
83 environment and are omitted. The `octave-tracking' feature is also new.
85 There are 84 accessible notes numbered 1-83 in 7 octaves, each running from
86 C to B, numbered 0-6; the scale is equal-tempered A440 and octave 3 starts
87 with middle C. By default, the play function emits half-second notes with the
88 last 1/16th second being `rest time'.
90 Play strings are interpreted left to right as a series of play command groups;
91 letter case is ignored. Play command groups are as follows:
93 CDEFGAB -- letters A through G cause the corresponding note to be played in the
94 current octave. A note letter may optionally be followed by an
96 one of # + or -; the first two of these cause it to be sharped one
97 half-tone, the last causes it to be flatted one half-tone. It may also be
98 followed by a time value number and by sustain dots (see below). Time values
99 are interpreted as for the L command below;.
101 O \*[Lt]n\*[Gt] -- if \*[Lt]n\*[Gt] is numeric, this sets the current octave. \*[Lt]n\*[Gt] may also be one
102 of 'L' or 'N' to enable or disable octave-tracking (it is disabled by default).
103 When octave-tracking is on, interpretation of a pair of letter notes will
104 change octaves if necessary in order to make the smallest possible jump between
105 notes. Thus "olbc" will be played as "olb\*[Gt]c", and "olcb" as "olc\*[Lt]b". Octave
106 locking is disabled for one letter note following by \*[Gt], \*[Lt] and O[0123456].
108 \*[Gt] -- bump the current octave up one.
110 \*[Lt] -- drop the current octave down one.
112 N \*[Lt]n\*[Gt] -- play note n, n being 1 to 84 or 0 for a rest of current time value.
113 May be followed by sustain dots.
115 L \*[Lt]n\*[Gt] -- sets the current time value for notes. The default is L4, quarter
116 notes. The lowest possible value is 1; values up to 64 are accepted. L1 sets
117 whole notes, L2 sets half notes, L4 sets quarter notes, etc..
119 P \*[Lt]n\*[Gt] -- pause (rest), with \*[Lt]n\*[Gt] interpreted as for L. May be followed by
120 sustain dots. May also be written '~'.
122 T \*[Lt]n\*[Gt] -- Sets the number of quarter notes per minute; default is 120. Musical
123 names for common tempi are:
124 .Bl -column Description Prestissimo "Beats per Minute" -offset indent
125 .It Ta Sy Tempo Ta Sy "Beats per Minute"
126 .It very slow Ta Larghissimo Ta ""
127 .It Ta Largo Ta 40-60
128 .It Ta Larghetto Ta 60-66
131 .It Ta Adagio Ta 66-76
132 .It slow Ta Adagietto Ta ""
133 .It Ta Andante Ta 76-108
134 .It medium Ta Andantino Ta ""
135 .It Ta Moderato Ta 108-120
136 .It fast Ta Allegretto Ta ""
137 .It Ta Allegro Ta 120-168
140 .It Ta Presto Ta 168-208
141 .It very fast Ta Prestissimo Ta ""
144 M[LNS] -- set articulation. MN (N for normal) is the default; the last 1/8th of
145 the note's value is rest time. You can set ML for legato (no rest space) or
146 MS (staccato) 1/4 rest space.
148 Notes (that is, CDEFGAB or N command character groups) may be followed by
149 sustain dots. Each dot causes the note's value to be lengthened by one-half
150 for each one. Thus, a note dotted once is held for 3/2 of its undotted value;
151 dotted twice, it is held 9/4, and three times would give 27/8.
153 Whitespace in play strings is simply skipped and may be used to separate
156 .Bl -tag -width Pa -compact
162 .An Eric S. Raymond Aq esr@snark.thyrsus.com
164 Due to roundoff in the pitch tables and slop in the tone-generation and timer
165 hardware (neither of which was designed for precision), neither pitch accuracy
166 nor timings will be mathematically exact.
168 There is no volume control.
170 In play strings which are very long (longer than your system's physical I/O
171 blocks) note suffixes or numbers may occasionally be parsed incorrectly due
172 to crossing a block boundary.