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