summaryrefslogtreecommitdiff
path: root/share/man/man4/man4.i386/speaker.4
blob: 61860f2032734685fe1f8a41383d2af487401a65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
.\"	$OpenBSD: speaker.4,v 1.14 2003/06/06 10:29:42 jmc Exp $
.\"	$NetBSD: speaker.4,v 1.9 1998/08/18 08:16:56 augustss Exp $
.\"
.\" Copyright (c) 1993 Christopher G. Demetriou
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\"    must display the following acknowledgement:
.\"      This product includes software developed by Christopher G. Demetriou.
.\" 3. The name of the author may not be used to endorse or promote products
.\"    derived from this software without specific prior written permission
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd August 6, 1993
.Dt SPEAKER 4 i386
.Os
.Sh NAME
.Nm speaker
.Nd console speaker device driver
.Sh SYNOPSIS
.Cd "spkr0	at pcppi?"
.Sh DESCRIPTION
The
.Nm
device driver allows applications to control the PC console
speaker on an IBM-PC-compatible machine running UNIX.
.Pp
Only one process may have this device open at any given time;
.Xr open 2
and
.Xr close 2
are used to lock and relinquish it.
An attempt to
.Fn open
when another process has the device locked will return \-1 with an
.Er EBUSY
error indication.
Writes to the device are interpreted as
.Dq play strings
in a simple ASCII melody notation.
An
.Fn ioctl
for tone generation at arbitrary frequencies is also supported.
.Pp
Sound-generation does
.Em not
monopolize the processor; in fact, the driver
spends most of its time sleeping while the PC hardware is emitting tones.
Other processes may emit beeps while the driver is running.
.Pp
Applications may call
.Fn ioctl
on a speaker file descriptor to control the speaker driver directly;
definitions for the
.Fn ioctl
interface are in
.Aq Pa machine/spkr.h .
The
.Li tone_t
structure used in these calls has two fields,
specifying a frequency (in hz) and a duration (in 1/100ths of a second).
A frequency of zero is interpreted as a rest.
.Pp
At present there are two such ioctls.
The
.Dv SPKRTONE
ioctl accepts a pointer to a single tone structure as a third argument and
plays it.
The
.Dv SPKRTUNE
ioctl accepts a pointer to the first of an array of tone structures and plays
them in continuous sequence; this array must be terminated by a final member
with a zero duration.
.Pp
The play-string language is modelled on the PLAY statement conventions of
IBM BASIC 2.0.
The MB, MF and X primitives of PLAY are not useful in a UNIX environment and
are omitted.
The
.Dq octave-tracking
feature is also new.
.Pp
There are 84 accessible notes numbered 1-83 in 7 octaves, each running from
C to B, numbered 0-6; the scale is equal-tempered A440 and octave 3 starts
with middle C.
By default, the play function emits half-second notes with the last 1/16th
second being
.Dq rest time .
.Pp
Play strings are interpreted left to right as a series of play command groups;
letter case is ignored.
Play command groups are as follows:
.Bl -tag -width xxx
.It CDEFGAB
Letters A through G cause the corresponding note to be played in the current
octave.
A note letter may optionally be followed by an
.Dq accidental sign ,
one of
.Ql # ,
.Ql + ,
or
.Ql - ;
the first two of these cause it to be sharped one half-tone, the last causes
it to be flatted one half-tone.
It may also be followed by a time value number and by sustain dots (see below).
Time values are interpreted as for the L command below;.
.It O Aq Ar n
If
.Ar n
is numeric, this sets the current octave.
.Ar n
may also be one of
.Sq L
or
.Sq N
to enable or disable octave-tracking (it is disabled by default).
When octave-tracking is on, interpretation of a pair of letter notes will
change octaves if necessary in order to make the smallest possible jump between
notes.
Thus
.Qq olbc
will be played as
.Qq olb>c ,
and
.Qq olcb
as
.Qq olc<b .
Octave locking is disabled for one letter note following by
.Ql > ,
.Ql < ,
and
.Ql O[0123456] .
.Pp
.Bd -literal -offset indent
> -- bump the current octave up one.
< -- drop the current octave down one.
.Ed
.It N Aq Ar n
Play note
.Ar n ,
.Ar n
being 1 to 84 or 0 for a rest of current time value.
May be followed by sustain dots.
.It L Aq Ar n
Sets the current time value for notes.
The default is L4, quarter notes.
The lowest possible value is 1; values up to 64 are accepted.
L1 sets whole notes, L2 sets half notes, L4 sets quarter notes, etc.
.It P Aq Ar n
Pause (rest), with
.Ar n
interpreted as for L.
May be followed by sustain dots.
May also be written
.Ql ~ .
.It T Aq Ar n
Sets the number of quarter notes per minute; default is 120.
Musical names for common tempi are:
.Bl -column Description Tempo BPM -offset indent
.Em 	Tempo		Beats per Minute
very slow	Larghissimo
        	Largo	 	40-60
         	Larghetto	60-66
        	Grave
        	Lento
        	Adagio	 	66-76
slow    	Adagietto
        	Andante	 	76-108
medium   	Andantino
        	Moderato 	108-120
fast    	Allegretto
        	Allegro	 	120-168
        	Vivace
        	Veloce
        	Presto	 	168-208
very fast	Prestissimo
.El
.It M[LNS]
Set articulation.
MN (N for normal) is the default; the last 1/8th of the note's value is rest
time.
You can set ML for legato (no rest space) or MS (staccato) 1/4 rest space.
.El
.Pp
Notes (that is, CDEFGAB or N command character groups) may be followed by
sustain dots.
Each dot causes the note's value to be lengthened by one-half for each one.
Thus, a note dotted once is held for 3/2 of its undotted value;
dotted twice, it is held 9/4, and three times would give 27/8.
.Pp
Whitespace in play strings is simply skipped and may be used to separate
melody sections.
.Sh FILES
.Bl -tag -width Pa -compact
.It Pa /dev/speaker
.El
.Sh SEE ALSO
.Xr intro 4 ,
.Xr pcppi 4
.Sh AUTHORS
.An Eric S. Raymond Aq esr@snark.thyrsus.com ,
Feb 1990
.Sh BUGS
Due to roundoff in the pitch tables and slop in the tone-generation and timer
hardware (neither of which was designed for precision), neither pitch accuracy
nor timings will be mathematically exact.
.Pp
There is no volume control.
.Pp
In play strings which are very long (longer than your system's physical I/O
blocks) note suffixes or numbers may occasionally be parsed incorrectly due
to crossing a block boundary.