2 .\" $Id: spkr.4,v 1.10 1998/03/12 07:30:38 charnier Exp $
10 .Nd console speaker device driver
12 .Cd pseudo-device speaker
13 .Fd #include <machine/speaker.h>
15 The speaker device driver allows applications to control the PC console
17 .Tn IBM-PC Ns --compatible
21 Only one process may have this device open at any given time;
25 are used to lock and relinquish it. An attempt to open when
26 another process has the device locked will return -1 with an
29 indication. Writes to the device are interpreted as `play strings' in a
30 simple ASCII melody notation. An
33 for tone generation at arbitrary
34 frequencies is also supported.
36 Sound-generation does not monopolize the processor; in fact, the driver
37 spends most of its time sleeping while the PC hardware is emitting
38 tones. Other processes may emit beeps while the driver is running.
42 on a speaker file descriptor to control the
43 speaker driver directly; definitions for the
46 .Pa /usr/include/machine/speaker.h .
49 structure used in these calls has two fields,
50 specifying a frequency (in Hz) and a duration (in 1/100ths of a second).
51 A frequency of zero is interpreted as a rest.
53 At present there are two such
57 accepts a pointer to a
58 single tone structure as third argument and plays it.
61 pointer to the first of an array of tone structures and plays them in
62 continuous sequence; this array must be terminated by a final member with
65 The play-string language is modelled on the PLAY statement conventions of
67 Advanced BASIC 2.0. The
72 primitives of PLAY are not
73 useful in a timesharing environment and are omitted. The `octave-tracking'
74 feature and the slur mark are new.
76 There are 84 accessible notes numbered 1-84 in 7 octaves, each running from
77 C to B, numbered 0-6; the scale is equal-tempered A440 and octave 3 starts
78 with middle C. By default, the play function emits half-second notes with the
79 last 1/16th second being `rest time'.
81 Play strings are interpreted left to right as a series of play command groups;
82 letter case is ignored. Play command groups are as follows:
83 .Bl -tag -width CDEFGABxx
85 Letters A through G cause the corresponding note to be played in the
86 current octave. A note letter may optionally be followed by an
87 .Dq Em "accidental sign" ,
88 one of # + or -; the first two of these cause it to be sharped one
89 half-tone, the last causes it to be flatted one half-tone. It may
90 also be followed by a time value number and by sustain dots (see
91 below). Time values are interpreted as for the L command below.
95 is numeric, this sets the current octave.
101 to enable or disable octave-tracking (it is disabled by default).
102 When octave-tracking is on, interpretation of a pair of letter notes
103 will change octaves if necessary in order to make the smallest
104 possible jump between notes. Thus ``olbc'' will be played as
105 ``olb>c'', and ``olcb'' as ``olc<b''. Octave locking is disabled for
106 one letter note following >, < and O[0123456]. (The octave-locking
107 feature is not supported in
111 Bump the current octave up one.
113 Drop the current octave down one.
118 being 1 to 84 or 0 for a rest of current time value.
119 May be followed by sustain dots.
121 Sets the current time value for notes. The default is
123 quarter or crotchet notes. The lowest possible value is 1; values up
130 sets quarter notes, etc.
137 sustain dots. May also be written
140 Sets the number of quarter notes per minute; default is 120. Musical
141 names for common tempi are:
143 .Bd -literal -offset indent
144 Tempo Beats Per Minute
145 very slow Larghissimo
160 very fast Prestissimo
166 for normal) is the default; the last 1/8th of
167 the note's value is rest time. You can set
169 for legato (no rest space) or
171 for staccato (1/4 rest space).
178 command character groups) may be followed by
179 sustain dots. Each dot causes the note's value to be lengthened by one-half
180 for each one. Thus, a note dotted once is held for 3/2 of its undotted value;
181 dotted twice, it is held 9/4, and three times would give 27/8.
183 A note and its sustain dots may also be followed by a slur mark (underscore).
184 This causes the normal micro-rest after the note to be filled in, slurring it
185 to the next one. (The slur feature is not supported in
189 Whitespace in play strings is simply skipped and may be used to separate
192 Due to roundoff in the pitch tables and slop in the tone-generation and timer
193 hardware (neither of which was designed for precision), neither pitch accuracy
194 nor timings will be mathematically exact. There is no volume control.
196 The action of two or more sustain dots does not reflect standard musical
197 notation, in which each dot adds half the value of the previous dot
198 modifier, not half the value of the note as modified. Thus, a note dotted
199 once is held for 3/2 of its undotted value; dotted twice, it is held 7/4,
200 and three times would give 15/8. The multiply-by-3/2 interpretation,
201 however, is specified in the
203 BASIC manual and has been retained for
206 In play strings which are very long (longer than your system's physical I/O
207 blocks) note suffixes or numbers may occasionally be parsed incorrectly due
208 to crossing a block boundary.
210 .Bl -tag -width /dev/speakerxx
217 .An Eric S. Raymond Aq esr@snark.thyrsus.com
220 .An Andrew A. Chernov Aq ache@astral.msk.su