1997-03-07 02:50:01 +00:00
|
|
|
.\"
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1997-03-07 02:50:01 +00:00
|
|
|
.\"
|
2005-11-11 09:57:32 +00:00
|
|
|
.Dd November 10, 2005
|
|
|
|
.Dt SPKR 4
|
2001-07-10 15:31:11 +00:00
|
|
|
.Os
|
1994-02-03 07:32:01 +00:00
|
|
|
.Sh NAME
|
1996-07-07 12:52:03 +00:00
|
|
|
.Nm speaker ,
|
1993-11-09 02:38:17 +00:00
|
|
|
.Nm spkr
|
|
|
|
.Nd console speaker device driver
|
1994-02-03 07:32:01 +00:00
|
|
|
.Sh SYNOPSIS
|
2001-05-01 09:15:30 +00:00
|
|
|
.Cd device speaker
|
2005-11-11 09:57:32 +00:00
|
|
|
.In dev/speaker/speaker.h
|
1994-02-03 07:32:01 +00:00
|
|
|
.Sh DESCRIPTION
|
1993-06-12 14:49:13 +00:00
|
|
|
The speaker device driver allows applications to control the PC console
|
2001-05-01 09:15:30 +00:00
|
|
|
speaker on an
|
1994-02-03 07:32:01 +00:00
|
|
|
.Tn IBM-PC Ns --compatible
|
1997-03-21 20:14:15 +00:00
|
|
|
machine running
|
2000-11-14 11:20:58 +00:00
|
|
|
.Fx .
|
1994-02-03 07:32:01 +00:00
|
|
|
.Pp
|
2001-05-01 09:15:30 +00:00
|
|
|
Only one process may have this device open at any given time;
|
1994-02-03 07:32:01 +00:00
|
|
|
.Xr open 2
|
|
|
|
and
|
|
|
|
.Xr close 2
|
2000-03-03 14:05:08 +00:00
|
|
|
are used to lock and relinquish it.
|
|
|
|
An attempt to open when
|
1994-02-03 07:32:01 +00:00
|
|
|
another process has the device locked will return -1 with an
|
|
|
|
.Er EBUSY
|
|
|
|
error
|
2000-03-03 14:05:08 +00:00
|
|
|
indication.
|
|
|
|
Writes to the device are interpreted as `play strings' in a
|
|
|
|
simple ASCII melody notation.
|
2001-05-01 09:15:30 +00:00
|
|
|
An
|
1994-02-03 07:32:01 +00:00
|
|
|
.Xr ioctl 2
|
|
|
|
request
|
|
|
|
for tone generation at arbitrary
|
1993-06-12 14:49:13 +00:00
|
|
|
frequencies is also supported.
|
1994-02-03 07:32:01 +00:00
|
|
|
.Pp
|
|
|
|
Sound-generation does not monopolize the processor; in fact, the driver
|
1993-06-12 14:49:13 +00:00
|
|
|
spends most of its time sleeping while the PC hardware is emitting
|
2000-03-03 14:05:08 +00:00
|
|
|
tones.
|
|
|
|
Other processes may emit beeps while the driver is running.
|
1994-02-03 07:32:01 +00:00
|
|
|
.Pp
|
2001-05-01 09:15:30 +00:00
|
|
|
Applications may call
|
1994-02-03 07:32:01 +00:00
|
|
|
.Xr ioctl 2
|
|
|
|
on a speaker file descriptor to control the
|
2001-05-01 09:15:30 +00:00
|
|
|
speaker driver directly; definitions for the
|
1994-02-03 07:32:01 +00:00
|
|
|
.Xr ioctl 2
|
|
|
|
interface are in
|
2005-11-11 09:57:32 +00:00
|
|
|
.In dev/speaker/speaker.h .
|
1994-02-03 07:32:01 +00:00
|
|
|
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).
|
1993-06-12 14:49:13 +00:00
|
|
|
A frequency of zero is interpreted as a rest.
|
1994-02-03 07:32:01 +00:00
|
|
|
.Pp
|
|
|
|
At present there are two such
|
|
|
|
.Xr ioctl 2
|
|
|
|
calls.
|
|
|
|
.Dv SPKRTONE
|
|
|
|
accepts a pointer to a
|
2001-05-01 09:15:30 +00:00
|
|
|
single tone structure as third argument and plays it.
|
1994-02-03 07:32:01 +00:00
|
|
|
.Dv SPKRTUNE
|
|
|
|
accepts a
|
1993-06-12 14:49:13 +00:00
|
|
|
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.
|
1994-02-03 07:32:01 +00:00
|
|
|
.Pp
|
2002-01-21 12:36:12 +00:00
|
|
|
The play-string language is modeled on the PLAY statement conventions of
|
2001-05-01 09:15:30 +00:00
|
|
|
.Tn IBM
|
2004-07-03 18:29:24 +00:00
|
|
|
Advanced BASIC 2.0.
|
|
|
|
The
|
1994-02-03 07:32:01 +00:00
|
|
|
.Li MB ,
|
|
|
|
.Li MF ,
|
|
|
|
and
|
|
|
|
.Li X
|
|
|
|
primitives of PLAY are not
|
2000-03-03 14:05:08 +00:00
|
|
|
useful in a timesharing environment and are omitted.
|
|
|
|
The `octave-tracking'
|
1994-02-03 07:32:01 +00:00
|
|
|
feature and the slur mark are new.
|
|
|
|
.Pp
|
1999-04-25 17:08:50 +00:00
|
|
|
There are 84 accessible notes numbered 1-84 in 7 octaves, each running from
|
1993-06-12 14:49:13 +00:00
|
|
|
C to B, numbered 0-6; the scale is equal-tempered A440 and octave 3 starts
|
2004-07-03 18:29:24 +00:00
|
|
|
with middle C.
|
|
|
|
By default, the play function emits half-second notes with the
|
1993-06-12 14:49:13 +00:00
|
|
|
last 1/16th second being `rest time'.
|
1994-02-03 07:32:01 +00:00
|
|
|
.Pp
|
1993-06-12 14:49:13 +00:00
|
|
|
Play strings are interpreted left to right as a series of play command groups;
|
2000-03-03 14:05:08 +00:00
|
|
|
letter case is ignored.
|
|
|
|
Play command groups are as follows:
|
1994-02-03 07:32:01 +00:00
|
|
|
.Bl -tag -width CDEFGABxx
|
|
|
|
.It Li CDEFGAB
|
|
|
|
Letters A through G cause the corresponding note to be played in the
|
2004-07-03 18:29:24 +00:00
|
|
|
current octave.
|
|
|
|
A note letter may optionally be followed by an
|
2001-05-01 09:15:30 +00:00
|
|
|
.Dq Em "accidental sign" ,
|
1994-02-03 07:32:01 +00:00
|
|
|
one of # + or -; the first two of these cause it to be sharped one
|
2004-07-03 18:29:24 +00:00
|
|
|
half-tone, the last causes it to be flatted one half-tone.
|
|
|
|
It may
|
1994-02-03 07:32:01 +00:00
|
|
|
also be followed by a time value number and by sustain dots (see
|
2004-07-03 18:29:24 +00:00
|
|
|
below).
|
|
|
|
Time values are interpreted as for the L command below.
|
1994-02-03 07:32:01 +00:00
|
|
|
.It Ns Li O Sy n
|
|
|
|
If
|
|
|
|
.Sy n
|
|
|
|
is numeric, this sets the current octave.
|
|
|
|
.Sy n
|
|
|
|
may also be one of
|
|
|
|
.Li L
|
|
|
|
or
|
|
|
|
.Li 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
|
2000-03-03 14:05:08 +00:00
|
|
|
possible jump between notes.
|
|
|
|
Thus ``olbc'' will be played as
|
2004-07-03 18:29:24 +00:00
|
|
|
``olb>c'', and ``olcb'' as ``olc<b''.
|
|
|
|
Octave locking is disabled for
|
|
|
|
one letter note following >, < and O[0123456].
|
|
|
|
(The octave-locking
|
2001-05-01 09:15:30 +00:00
|
|
|
feature is not supported in
|
1994-02-03 07:32:01 +00:00
|
|
|
.Tn IBM
|
|
|
|
BASIC.)
|
|
|
|
.It Li >
|
|
|
|
Bump the current octave up one.
|
|
|
|
.It Li <
|
|
|
|
Drop the current octave down one.
|
|
|
|
.It Ns Li N Sy n
|
2001-05-01 09:15:30 +00:00
|
|
|
Play note
|
1994-02-03 07:32:01 +00:00
|
|
|
.Sy n ,
|
|
|
|
.Sy n
|
|
|
|
being 1 to 84 or 0 for a rest of current time value.
|
1993-11-09 02:38:17 +00:00
|
|
|
May be followed by sustain dots.
|
1994-02-03 07:32:01 +00:00
|
|
|
.It Ns Li L Sy n
|
2004-07-03 18:29:24 +00:00
|
|
|
Sets the current time value for notes.
|
|
|
|
The default is
|
1994-02-03 07:32:01 +00:00
|
|
|
.Li L4 ,
|
2000-03-03 14:05:08 +00:00
|
|
|
quarter or crotchet notes.
|
|
|
|
The lowest possible value is 1; values up
|
1994-02-03 07:32:01 +00:00
|
|
|
to 64 are accepted.
|
|
|
|
.Li L1
|
|
|
|
sets whole notes,
|
|
|
|
.Li L2
|
|
|
|
sets half notes,
|
|
|
|
.Li L4
|
|
|
|
sets quarter notes, etc.
|
|
|
|
.It Ns Li P Sy n
|
2001-05-01 09:15:30 +00:00
|
|
|
Pause (rest), with
|
1994-02-03 07:32:01 +00:00
|
|
|
.Sy n
|
2001-05-01 09:15:30 +00:00
|
|
|
interpreted as for
|
2001-02-01 16:38:02 +00:00
|
|
|
.Li L Sy n .
|
1994-02-03 07:32:01 +00:00
|
|
|
May be followed by
|
2004-07-03 18:29:24 +00:00
|
|
|
sustain dots.
|
|
|
|
May also be written
|
1994-02-03 07:32:01 +00:00
|
|
|
.Li ~ .
|
|
|
|
.It Ns Li T Sy n
|
2004-07-03 18:29:24 +00:00
|
|
|
Sets the number of quarter notes per minute; default is 120.
|
|
|
|
Musical
|
1993-06-12 14:49:13 +00:00
|
|
|
names for common tempi are:
|
1994-02-03 07:32:01 +00:00
|
|
|
.Bd -literal -offset indent
|
1993-06-12 14:49:13 +00:00
|
|
|
Tempo Beats Per Minute
|
2001-07-14 19:41:16 +00:00
|
|
|
very slow Larghissimo
|
1993-06-12 14:49:13 +00:00
|
|
|
Largo 40-60
|
|
|
|
Larghetto 60-66
|
2001-07-14 19:41:16 +00:00
|
|
|
Grave
|
|
|
|
Lento
|
1993-06-12 14:49:13 +00:00
|
|
|
Adagio 66-76
|
2001-07-14 19:41:16 +00:00
|
|
|
slow Adagietto
|
1993-06-12 14:49:13 +00:00
|
|
|
Andante 76-108
|
2001-07-14 19:41:16 +00:00
|
|
|
medium Andantino
|
1993-06-12 14:49:13 +00:00
|
|
|
Moderato 108-120
|
2001-07-14 19:41:16 +00:00
|
|
|
fast Allegretto
|
1993-06-12 14:49:13 +00:00
|
|
|
Allegro 120-168
|
2001-07-14 19:41:16 +00:00
|
|
|
Vivace
|
|
|
|
Veloce
|
1993-06-12 14:49:13 +00:00
|
|
|
Presto 168-208
|
2001-07-14 19:41:16 +00:00
|
|
|
very fast Prestissimo
|
1994-02-03 07:32:01 +00:00
|
|
|
.Ed
|
|
|
|
.It Li M[LNS]
|
|
|
|
Set articulation.
|
|
|
|
.Li MN
|
2001-02-01 16:38:02 +00:00
|
|
|
.Li ( N
|
1994-02-03 07:32:01 +00:00
|
|
|
for normal) is the default; the last 1/8th of
|
2000-03-03 14:05:08 +00:00
|
|
|
the note's value is rest time.
|
|
|
|
You can set
|
1994-02-03 07:32:01 +00:00
|
|
|
.Li ML
|
|
|
|
for legato (no rest space) or
|
|
|
|
.Li MS
|
|
|
|
for staccato (1/4 rest space).
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
Notes (that is,
|
|
|
|
.Li CDEFGAB
|
|
|
|
or
|
|
|
|
.Li N
|
|
|
|
command character groups) may be followed by
|
2000-03-03 14:05:08 +00:00
|
|
|
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-05-01 09:15:30 +00:00
|
|
|
dotted twice, it is held 9/4, and three times would give 27/8.
|
1994-02-03 07:32:01 +00:00
|
|
|
.Pp
|
1993-11-09 02:38:17 +00:00
|
|
|
A note and its sustain dots may also be followed by a slur mark (underscore).
|
|
|
|
This causes the normal micro-rest after the note to be filled in, slurring it
|
2004-07-03 18:29:24 +00:00
|
|
|
to the next one.
|
|
|
|
(The slur feature is not supported in
|
1994-02-03 07:32:01 +00:00
|
|
|
.Tn IBM
|
|
|
|
BASIC.)
|
|
|
|
.Pp
|
1993-06-12 14:49:13 +00:00
|
|
|
Whitespace in play strings is simply skipped and may be used to separate
|
|
|
|
melody sections.
|
2005-01-21 08:36:40 +00:00
|
|
|
.Sh FILES
|
|
|
|
.Bl -tag -width /dev/speakerxx
|
|
|
|
.It Pa /dev/speaker
|
|
|
|
speaker device file
|
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr spkrtest 8
|
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
device appeared in
|
|
|
|
.Fx 1.0 .
|
|
|
|
.Sh AUTHORS
|
2014-06-26 21:46:14 +00:00
|
|
|
.An Eric S. Raymond Aq Mt esr@snark.thyrsus.com ,
|
2005-01-21 08:36:40 +00:00
|
|
|
June 1990
|
2014-06-26 21:46:14 +00:00
|
|
|
.Sh PORTED BY
|
|
|
|
.An Andrew A. Chernov Aq Mt ache@astral.msk.su
|
1994-02-03 07:32:01 +00:00
|
|
|
.Sh BUGS
|
1993-06-12 14:49:13 +00: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
|
2000-03-03 14:05:08 +00:00
|
|
|
nor timings will be mathematically exact.
|
|
|
|
There is no volume control.
|
1994-02-03 07:32:01 +00:00
|
|
|
.Pp
|
1993-11-09 02:38:17 +00:00
|
|
|
The action of two or more sustain dots does not reflect standard musical
|
|
|
|
notation, in which each dot adds half the value of the previous dot
|
2004-07-03 18:29:24 +00:00
|
|
|
modifier, not half the value of the note as modified.
|
|
|
|
Thus, a note dotted
|
1993-11-09 02:38:17 +00:00
|
|
|
once is held for 3/2 of its undotted value; dotted twice, it is held 7/4,
|
2004-07-03 18:29:24 +00:00
|
|
|
and three times would give 15/8.
|
|
|
|
The multiply-by-3/2 interpretation,
|
2001-05-01 09:15:30 +00:00
|
|
|
however, is specified in the
|
1994-02-03 07:32:01 +00:00
|
|
|
.Tn IBM
|
|
|
|
BASIC manual and has been retained for
|
1993-11-09 02:38:17 +00:00
|
|
|
compatibility.
|
1994-02-03 07:32:01 +00:00
|
|
|
.Pp
|
1993-06-12 14:49:13 +00: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.
|