2 .\" $FreeBSD: src/share/man/man4/man4.i386/spkr.4,v 1.13.2.6 2001/12/17 11:30:13 ru Exp $
3 .\" $DragonFly: src/share/man/man4/man4.i386/spkr.4,v 1.6 2007/05/17 08:19:01 swildner Exp $
11 .Nd console speaker device driver
13 .Cd pseudo-device speaker
16 The speaker device driver allows applications to control the PC console
18 .Tn IBM-PC Ns --compatible
22 Only one process may have this device open at any given time;
26 are used to lock and relinquish it.
27 An attempt to open when
28 another process has the device locked will return -1 with an
32 Writes to the device are interpreted as `play strings' in a
33 simple ASCII melody notation.
37 for tone generation at arbitrary
38 frequencies is also supported.
40 Sound-generation does not monopolize the processor; in fact, the driver
41 spends most of its time sleeping while the PC hardware is emitting
43 Other processes may emit beeps while the driver is running.
47 on a speaker file descriptor to control the
48 speaker driver directly; definitions for the
51 .In machine/speaker.h .
54 structure used in these calls has two fields,
55 specifying a frequency (in Hz) and a duration (in 1/100ths of a second).
56 A frequency of zero is interpreted as a rest.
58 At present there are two such
62 accepts a pointer to a
63 single tone structure as third argument and plays it.
66 pointer to the first of an array of tone structures and plays them in
67 continuous sequence; this array must be terminated by a final member with
70 The play-string language is modeled on the PLAY statement conventions of
72 Advanced BASIC 2.0. The
77 primitives of PLAY are not
78 useful in a timesharing environment and are omitted.
80 feature and the slur mark are new.
82 There are 84 accessible notes numbered 1-84 in 7 octaves, each running from
83 C to B, numbered 0-6; the scale is equal-tempered A440 and octave 3 starts
84 with middle C. By default, the play function emits half-second notes with the
85 last 1/16th second being `rest time'.
87 Play strings are interpreted left to right as a series of play command groups;
88 letter case is ignored.
89 Play command groups are as follows:
90 .Bl -tag -width CDEFGABxx
92 Letters A through G cause the corresponding note to be played in the
93 current octave. A note letter may optionally be followed by an
94 .Dq Em "accidental sign" ,
95 one of # + or -; the first two of these cause it to be sharped one
96 half-tone, the last causes it to be flatted one half-tone. It may
97 also be followed by a time value number and by sustain dots (see
98 below). Time values are interpreted as for the L command below.
102 is numeric, this sets the current octave.
108 to enable or disable octave-tracking (it is disabled by default).
109 When octave-tracking is on, interpretation of a pair of letter notes
110 will change octaves if necessary in order to make the smallest
111 possible jump between notes.
112 Thus ``olbc'' will be played as
113 ``olb>c'', and ``olcb'' as ``olc<b''. Octave locking is disabled for
114 one letter note following >, < and O[0123456]. (The octave-locking
115 feature is not supported in
119 Bump the current octave up one.
121 Drop the current octave down one.
126 being 1 to 84 or 0 for a rest of current time value.
127 May be followed by sustain dots.
129 Sets the current time value for notes. The default is
131 quarter or crotchet notes.
132 The lowest possible value is 1; values up
139 sets quarter notes, etc.
146 sustain dots. May also be written
149 Sets the number of quarter notes per minute; default is 120. Musical
150 names for common tempi are:
151 .Bd -literal -offset indent
152 Tempo Beats Per Minute
153 very slow Larghissimo
168 very fast Prestissimo
174 for normal) is the default; the last 1/8th of
175 the note's value is rest time.
178 for legato (no rest space) or
180 for staccato (\(14 rest space).
187 command character groups) may be followed by
189 Each dot causes the note's value to be lengthened by one-half
191 Thus, a note dotted once is held for 3/2 of its undotted value;
192 dotted twice, it is held 9/4, and three times would give 27/8.
194 A note and its sustain dots may also be followed by a slur mark (underscore).
195 This causes the normal micro-rest after the note to be filled in, slurring it
196 to the next one. (The slur feature is not supported in
200 Whitespace in play strings is simply skipped and may be used to separate
203 .Bl -tag -width /dev/speakerxx
215 .An Eric S. Raymond Aq esr@snark.thyrsus.com
218 .An Andrew A. Chernov Aq ache@astral.msk.su
220 Due to roundoff in the pitch tables and slop in the tone-generation and timer
221 hardware (neither of which was designed for precision), neither pitch accuracy
222 nor timings will be mathematically exact.
223 There is no volume control.
225 The action of two or more sustain dots does not reflect standard musical
226 notation, in which each dot adds half the value of the previous dot
227 modifier, not half the value of the note as modified. Thus, a note dotted
228 once is held for 3/2 of its undotted value; dotted twice, it is held 7/4,
229 and three times would give 15/8. The multiply-by-3/2 interpretation,
230 however, is specified in the
232 BASIC manual and has been retained for
235 In play strings which are very long (longer than your system's physical I/O
236 blocks) note suffixes or numbers may occasionally be parsed incorrectly due
237 to crossing a block boundary.