Merge branch 'vendor/GDB'
[dragonfly.git] / share / man / man4 / man4.i386 / spkr.4
1 .\"
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 $
4 .\"
5 .Dd November 7, 1993
6 .Dt SPKR 4 i386
7 .Os
8 .Sh NAME
9 .Nm speaker ,
10 .Nm spkr
11 .Nd console speaker device driver
12 .Sh SYNOPSIS
13 .Cd pseudo-device speaker
14 .In machine/speaker.h
15 .Sh DESCRIPTION
16 The speaker device driver allows applications to control the PC console
17 speaker on an
18 .Tn IBM-PC Ns --compatible
19 machine running
20 .Fx .
21 .Pp
22 Only one process may have this device open at any given time;
23 .Xr open 2
24 and
25 .Xr close 2
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
29 .Er EBUSY
30 error
31 indication.
32 Writes to the device are interpreted as `play strings' in a
33 simple ASCII melody notation.
34 An
35 .Xr ioctl 2
36 request
37 for tone generation at arbitrary
38 frequencies is also supported.
39 .Pp
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
42 tones.
43 Other processes may emit beeps while the driver is running.
44 .Pp
45 Applications may call
46 .Xr ioctl 2
47 on a speaker file descriptor to control the
48 speaker driver directly; definitions for the
49 .Xr ioctl 2
50 interface are in
51 .In machine/speaker.h .
52 The
53 .Li tone_t
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.
57 .Pp
58 At present there are two such
59 .Xr ioctl 2
60 calls.
61 .Dv SPKRTONE
62 accepts a pointer to a
63 single tone structure as third argument and plays it.
64 .Dv SPKRTUNE
65 accepts a
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
68 a zero duration.
69 .Pp
70 The play-string language is modeled on the PLAY statement conventions of
71 .Tn IBM
72 Advanced BASIC 2.0.  The
73 .Li MB ,
74 .Li MF ,
75 and
76 .Li X
77 primitives of PLAY are not
78 useful in a timesharing environment and are omitted.
79 The `octave-tracking'
80 feature and the slur mark are new.
81 .Pp
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'.
86 .Pp
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
91 .It Li CDEFGAB
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.
99 .It Ns Li O Sy n
100 If
101 .Sy n
102 is numeric, this sets the current octave.
103 .Sy n
104 may also be one of
105 .Li L
106 or
107 .Li N
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
116 .Tn IBM
117 BASIC.)
118 .It Li >
119 Bump the current octave up one.
120 .It Li <
121 Drop the current octave down one.
122 .It Ns Li N Sy n
123 Play note
124 .Sy n ,
125 .Sy n
126 being 1 to 84 or 0 for a rest of current time value.
127 May be followed by sustain dots.
128 .It Ns Li L Sy n
129 Sets the current time value for notes.  The default is
130 .Li L4 ,
131 quarter or crotchet notes.
132 The lowest possible value is 1; values up
133 to 64 are accepted.
134 .Li L1
135 sets whole notes,
136 .Li L2
137 sets half notes,
138 .Li L4
139 sets quarter notes, etc.
140 .It Ns Li P Sy n
141 Pause (rest), with
142 .Sy n
143 interpreted as for
144 .Li L Sy n .
145 May be followed by
146 sustain dots.  May also be written
147 .Li ~ .
148 .It Ns Li T Sy n
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
154                 Largo           40-60
155                 Larghetto       60-66
156                 Grave
157                 Lento
158                 Adagio          66-76
159 slow            Adagietto
160                 Andante         76-108
161 medium          Andantino
162                 Moderato        108-120
163 fast            Allegretto
164                 Allegro         120-168
165                 Vivace
166                 Veloce
167                 Presto          168-208
168 very fast       Prestissimo
169 .Ed
170 .It Li M[LNS]
171 Set articulation.
172 .Li MN
173 .Li ( N
174 for normal) is the default; the last 1/8th of
175 the note's value is rest time.
176 You can set
177 .Li ML
178 for legato (no rest space) or
179 .Li MS
180 for staccato (\(14 rest space).
181 .El
182 .Pp
183 Notes (that is,
184 .Li CDEFGAB
185 or
186 .Li N
187 command character groups) may be followed by
188 sustain dots.
189 Each dot causes the note's value to be lengthened by one-half
190 for each one.
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.
193 .Pp
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
197 .Tn IBM
198 BASIC.)
199 .Pp
200 Whitespace in play strings is simply skipped and may be used to separate
201 melody sections.
202 .Sh FILES
203 .Bl -tag -width /dev/speakerxx
204 .It Pa /dev/speaker
205 speaker device file
206 .El
207 .Sh SEE ALSO
208 .Xr spkrtest 8
209 .Sh HISTORY
210 The
211 .Nm
212 device appeared in
213 .Fx 1.0 .
214 .Sh AUTHORS
215 .An Eric S. Raymond Aq esr@snark.thyrsus.com
216 June 1990
217 .Sh "PORTED BY"
218 .An Andrew A. Chernov Aq ache@astral.msk.su
219 .Sh BUGS
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.
224 .Pp
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
231 .Tn IBM
232 BASIC manual and has been retained for
233 compatibility.
234 .Pp
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.