10 .Nd console speaker device driver
13 .In dev/speaker/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.
26 An attempt to open when
27 another process has the device locked will return -1 with an
31 Writes to the device are interpreted as `play strings' in a
32 simple ASCII melody notation.
36 for tone generation at arbitrary
37 frequencies is also supported.
39 Sound-generation does not monopolize the processor; in fact, the driver
40 spends most of its time sleeping while the PC hardware is emitting
42 Other processes may emit beeps while the driver is running.
46 on a speaker file descriptor to control the
47 speaker driver directly; definitions for the
50 .In dev/speaker/speaker.h .
53 structure used in these calls has two fields,
54 specifying a frequency (in Hz) and a duration (in 1/100ths of a second).
55 A frequency of zero is interpreted as a rest.
57 At present there are two such
61 accepts a pointer to a
62 single tone structure as third argument and plays it.
65 pointer to the first of an array of tone structures and plays them in
66 continuous sequence; this array must be terminated by a final member with
69 The play-string language is modeled on the PLAY statement conventions of
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
85 By default, the play function emits half-second notes with the
86 last 1/16th second being `rest time'.
88 Play strings are interpreted left to right as a series of play command groups;
89 letter case is ignored.
90 Play command groups are as follows:
91 .Bl -tag -width CDEFGABxx
93 Letters A through G cause the corresponding note to be played in the
95 A note letter may optionally be followed by an
96 .Dq Em "accidental sign" ,
97 one of # + or -; the first two of these cause it to be sharped one
98 half-tone, the last causes it to be flatted one half-tone.
100 also be followed by a time value number and by sustain dots (see
102 Time values are interpreted as for the L command below.
106 is numeric, this sets the current octave.
112 to enable or disable octave-tracking (it is disabled by default).
113 When octave-tracking is on, interpretation of a pair of letter notes
114 will change octaves if necessary in order to make the smallest
115 possible jump between notes.
116 Thus ``olbc'' will be played as
117 ``olb>c'', and ``olcb'' as ``olc<b''.
118 Octave locking is disabled for
119 one letter note following >, < and O[0123456].
121 feature is not supported in
125 Bump the current octave up one.
127 Drop the current octave down one.
132 being 1 to 84 or 0 for a rest of current time value.
133 May be followed by sustain dots.
135 Sets the current time value for notes.
138 quarter or crotchet notes.
139 The lowest possible value is 1; values up
146 sets quarter notes, etc.
157 Sets the number of quarter notes per minute; default is 120.
159 names for common tempi are:
160 .Bd -literal -offset indent
161 Tempo Beats Per Minute
162 very slow Larghissimo
177 very fast Prestissimo
183 for normal) is the default; the last 1/8th of
184 the note's value is rest time.
187 for legato (no rest space) or
189 for staccato (1/4 rest space).
196 command character groups) may be followed by
198 Each dot causes the note's value to be lengthened by one-half
200 Thus, a note dotted once is held for 3/2 of its undotted value;
201 dotted twice, it is held 9/4, and three times would give 27/8.
203 A note and its sustain dots may also be followed by a slur mark (underscore).
204 This causes the normal micro-rest after the note to be filled in, slurring it
206 (The slur feature is not supported in
210 Whitespace in play strings is simply skipped and may be used to separate
213 .Bl -tag -width /dev/speakerxx
225 .An Eric S. Raymond Aq esr@snark.thyrsus.com
228 .An Andrew A. Chernov Aq ache@astral.msk.su
230 Due to roundoff in the pitch tables and slop in the tone-generation and timer
231 hardware (neither of which was designed for precision), neither pitch accuracy
232 nor timings will be mathematically exact.
233 There is no volume control.
235 The action of two or more sustain dots does not reflect standard musical
236 notation, in which each dot adds half the value of the previous dot
237 modifier, not half the value of the note as modified.
239 once is held for 3/2 of its undotted value; dotted twice, it is held 7/4,
240 and three times would give 15/8.
241 The multiply-by-3/2 interpretation,
242 however, is specified in the
244 BASIC manual and has been retained for
247 In play strings which are very long (longer than your system's physical I/O
248 blocks) note suffixes or numbers may occasionally be parsed incorrectly due
249 to crossing a block boundary.