2003-04-16 17:34:34 +04:00
|
|
|
.\" $NetBSD: speaker.4,v 1.12 2003/04/16 13:35:18 wiz Exp $
|
1993-08-07 11:42:13 +04:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 1993 Christopher G. Demetriou
|
|
|
|
.\" All rights reserved.
|
2001-09-12 02:52:52 +04:00
|
|
|
.\"
|
1993-08-07 11:42:13 +04:00
|
|
|
.\" 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:
|
2000-06-14 21:24:02 +04:00
|
|
|
.\" This product includes software developed for the
|
2003-02-14 18:20:17 +03:00
|
|
|
.\" NetBSD Project. See http://www.NetBSD.org/ for
|
2000-06-14 21:24:02 +04:00
|
|
|
.\" information about NetBSD.
|
1999-04-07 00:24:37 +04:00
|
|
|
.\" 4. The name of the author may not be used to endorse or promote products
|
2000-06-14 21:24:02 +04:00
|
|
|
.\" derived from this software without specific prior written permission.
|
2001-09-12 02:52:52 +04:00
|
|
|
.\"
|
1993-08-07 11:42:13 +04:00
|
|
|
.\" 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.
|
2001-09-12 02:52:52 +04:00
|
|
|
.\"
|
2000-06-14 21:24:02 +04:00
|
|
|
.\" <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
|
1993-08-07 11:42:13 +04:00
|
|
|
.\"
|
|
|
|
.Dd August 6, 1993
|
2000-01-23 17:29:12 +03:00
|
|
|
.Dt SPEAKER 4
|
1999-03-16 04:19:14 +03:00
|
|
|
.Os
|
1993-08-07 11:42:13 +04:00
|
|
|
.Sh NAME
|
1999-12-16 02:44:51 +03:00
|
|
|
.Nm speaker
|
|
|
|
.Nd console speaker audio device driver
|
1993-08-07 11:42:13 +04:00
|
|
|
.Sh SYNOPSIS
|
1998-08-12 13:08:38 +04:00
|
|
|
.Cd "spkr0 at pcppi?"
|
2003-04-16 17:34:34 +04:00
|
|
|
.In machine/spkr.h
|
1996-03-25 00:18:34 +03:00
|
|
|
.Pa /dev/speaker
|
1993-08-07 11:42:13 +04:00
|
|
|
.Sh DESCRIPTION
|
2000-01-23 17:29:12 +03:00
|
|
|
The speaker device driver allows applications to control the console
|
|
|
|
speaker on machines with a PC-like 8253 timer implementation.
|
1993-08-07 11:42:13 +04:00
|
|
|
.Pp
|
1993-05-07 09:26:13 +04:00
|
|
|
Only one process may have this device open at any given time; open() and
|
|
|
|
close() are used to lock and relinquish it. An attempt to open() when
|
2002-09-04 04:41:40 +04:00
|
|
|
another process has the device locked will return -1 with an
|
|
|
|
.Er EBUSY
|
|
|
|
error indication. Writes to the device are interpreted as 'play strings' in a
|
|
|
|
simple ASCII melody notation. An
|
|
|
|
.Fn ioctl
|
|
|
|
for tone generation at arbitrary frequencies is also supported.
|
1993-08-07 11:42:13 +04:00
|
|
|
.Pp
|
2002-01-21 20:58:19 +03:00
|
|
|
Sound-generation does
|
|
|
|
.Em not
|
|
|
|
monopolize the processor; in fact, the driver
|
1993-05-07 09:26:13 +04:00
|
|
|
spends most of its time sleeping while the PC hardware is emitting
|
|
|
|
tones. Other processes may emit beeps while the driver is running.
|
1993-08-07 11:42:13 +04:00
|
|
|
.Pp
|
2002-09-04 04:41:40 +04:00
|
|
|
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 tone_t structure used in these calls has two fields,
|
1993-05-07 09:26:13 +04:00
|
|
|
specifying a frequency (in hz) and a duration (in 1/100ths of a second).
|
|
|
|
A frequency of zero is interpreted as a rest.
|
1993-08-07 11:42:13 +04:00
|
|
|
.Pp
|
1993-05-07 09:26:13 +04:00
|
|
|
At present there are two such ioctls. SPKRTONE accepts a pointer to a
|
|
|
|
single tone structure as third argument and plays it. SPKRTUNE 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.
|
1993-08-07 11:42:13 +04:00
|
|
|
.Pp
|
1993-05-07 09:26:13 +04:00
|
|
|
The play-string language is modelled on the PLAY statement conventions of
|
2001-09-12 02:52:52 +04:00
|
|
|
IBM BASIC 2.0. The MB, MF and X primitives of PLAY are not useful in a UNIX
|
1993-05-07 09:26:13 +04:00
|
|
|
environment and are omitted. The `octave-tracking' feature is also new.
|
1993-08-07 11:42:13 +04:00
|
|
|
.Pp
|
1993-05-07 09:26:13 +04:00
|
|
|
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 `rest time'.
|
1993-08-07 11:42:13 +04:00
|
|
|
.Pp
|
1993-05-07 09:26:13 +04:00
|
|
|
Play strings are interpreted left to right as a series of play command groups;
|
|
|
|
letter case is ignored. Play command groups are as follows:
|
1993-08-07 11:42:13 +04:00
|
|
|
.Pp
|
1993-05-07 09:26:13 +04:00
|
|
|
CDEFGAB -- letters A through G cause the corresponding note to be played in the
|
2002-01-21 20:58:19 +03:00
|
|
|
current octave. A note letter may optionally be followed by an
|
|
|
|
.Em accidental sign ,
|
|
|
|
one of # + or -; the first two of these cause it to be sharped one
|
1993-05-07 09:26:13 +04:00
|
|
|
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;.
|
1993-08-07 11:42:13 +04:00
|
|
|
.Pp
|
2002-02-13 11:17:26 +03:00
|
|
|
O \*[Lt]n\*[Gt] -- if \*[Lt]n\*[Gt] is numeric, this sets the current octave. \*[Lt]n\*[Gt] may also be one
|
1993-05-07 09:26:13 +04:00
|
|
|
of 'L' or '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
|
2002-02-13 11:17:26 +03:00
|
|
|
notes. Thus "olbc" will be played as "olb\*[Gt]c", and "olcb" as "olc\*[Lt]b". Octave
|
|
|
|
locking is disabled for one letter note following by \*[Gt], \*[Lt] and O[0123456].
|
1993-08-07 11:42:13 +04:00
|
|
|
.Pp
|
2002-02-13 11:17:26 +03:00
|
|
|
\*[Gt] -- bump the current octave up one.
|
1993-08-07 11:42:13 +04:00
|
|
|
.Pp
|
2002-02-13 11:17:26 +03:00
|
|
|
\*[Lt] -- drop the current octave down one.
|
1993-08-07 11:42:13 +04:00
|
|
|
.Pp
|
2002-02-13 11:17:26 +03:00
|
|
|
N \*[Lt]n\*[Gt] -- play note n, n being 1 to 84 or 0 for a rest of current time value.
|
1999-10-17 00:17:29 +04:00
|
|
|
May be followed by sustain dots.
|
1993-08-07 11:42:13 +04:00
|
|
|
.Pp
|
2002-02-13 11:17:26 +03:00
|
|
|
L \*[Lt]n\*[Gt] -- sets the current time value for notes. The default is L4, quarter
|
1993-05-07 09:26:13 +04:00
|
|
|
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..
|
1993-08-07 11:42:13 +04:00
|
|
|
.Pp
|
2002-02-13 11:17:26 +03:00
|
|
|
P \*[Lt]n\*[Gt] -- pause (rest), with \*[Lt]n\*[Gt] interpreted as for L. May be followed by
|
1993-05-07 09:26:13 +04:00
|
|
|
sustain dots. May also be written '~'.
|
1993-08-07 11:42:13 +04:00
|
|
|
.Pp
|
2002-02-13 11:17:26 +03:00
|
|
|
T \*[Lt]n\*[Gt] -- Sets the number of quarter notes per minute; default is 120. Musical
|
1993-05-07 09:26:13 +04:00
|
|
|
names for common tempi are:
|
1993-08-07 11:42:13 +04:00
|
|
|
.Bl -column Description Tempo BPM -offset indent
|
|
|
|
.Em Tempo Beats per Minute
|
2001-09-12 02:52:52 +04:00
|
|
|
very slow Larghissimo
|
1993-08-07 11:42:13 +04:00
|
|
|
Largo 40-60
|
|
|
|
Larghetto 60-66
|
2001-09-12 02:52:52 +04:00
|
|
|
Grave
|
|
|
|
Lento
|
1993-08-07 11:42:13 +04:00
|
|
|
Adagio 66-76
|
2001-09-12 02:52:52 +04:00
|
|
|
slow Adagietto
|
1993-08-07 11:42:13 +04:00
|
|
|
Andante 76-108
|
2001-09-12 02:52:52 +04:00
|
|
|
medium Andantino
|
1993-08-07 11:42:13 +04:00
|
|
|
Moderato 108-120
|
2001-09-12 02:52:52 +04:00
|
|
|
fast Allegretto
|
1993-08-07 11:42:13 +04:00
|
|
|
Allegro 120-168
|
2001-09-12 02:52:52 +04:00
|
|
|
Vivace
|
|
|
|
Veloce
|
1993-08-07 11:42:13 +04:00
|
|
|
Presto 168-208
|
2001-09-12 02:52:52 +04:00
|
|
|
very fast Prestissimo
|
1993-08-07 11:42:13 +04:00
|
|
|
.El
|
|
|
|
.Pp
|
1993-05-07 09:26:13 +04:00
|
|
|
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.
|
1993-08-07 11:42:13 +04:00
|
|
|
.Pp
|
1993-05-07 09:26:13 +04:00
|
|
|
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;
|
2001-09-12 02:52:52 +04:00
|
|
|
dotted twice, it is held 9/4, and three times would give 27/8.
|
1993-08-07 11:42:13 +04:00
|
|
|
.Pp
|
1993-05-07 09:26:13 +04:00
|
|
|
Whitespace in play strings is simply skipped and may be used to separate
|
|
|
|
melody sections.
|
2001-09-22 20:21:42 +04:00
|
|
|
.Sh FILES
|
|
|
|
.Bl -tag -width Pa -compact
|
|
|
|
.It Pa /dev/speaker
|
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr pcppi 4
|
|
|
|
.Sh AUTHORS
|
2002-09-04 04:41:40 +04:00
|
|
|
.An Eric S. Raymond Aq esr@snark.thyrsus.com
|
1993-08-07 11:42:13 +04:00
|
|
|
.Sh BUGS
|
1993-05-07 09:26:13 +04:00
|
|
|
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
|
1996-03-25 00:15:50 +03:00
|
|
|
nor timings will be mathematically exact.
|
|
|
|
.Pp
|
|
|
|
There is no volume control.
|
1993-08-07 11:42:13 +04:00
|
|
|
.Pp
|
1993-05-07 09:26:13 +04:00
|
|
|
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.
|