Sat Jul 4 23:09:43 2020 UTC ()
Add more markup.  Edit for clarity.


(uwe)
diff -r1.24 -r1.25 src/share/man/man4/speaker.4

cvs diff -r1.24 -r1.25 src/share/man/man4/speaker.4 (expand / switch to unified diff)

--- src/share/man/man4/speaker.4 2020/07/04 19:25:24 1.24
+++ src/share/man/man4/speaker.4 2020/07/04 23:09:43 1.25
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1.\" $NetBSD: speaker.4,v 1.24 2020/07/04 19:25:24 uwe Exp $ 1.\" $NetBSD: speaker.4,v 1.25 2020/07/04 23:09:43 uwe Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Nathanial Sloss <nathanialsloss@yahoo.com.au> 3.\" Copyright (c) 2016 Nathanial Sloss <nathanialsloss@yahoo.com.au>
4.\" All rights reserved. 4.\" All rights reserved.
5.\" 5.\"
6.\" Copyright (c) 1993 Christopher G. Demetriou 6.\" Copyright (c) 1993 Christopher G. Demetriou
7.\" All rights reserved. 7.\" All rights reserved.
8.\" 8.\"
9.\" Redistribution and use in source and binary forms, with or without 9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions 10.\" modification, are permitted provided that the following conditions
11.\" are met: 11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright 12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer. 13.\" notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" 2. Redistributions in binary form must reproduce the above copyright
@@ -52,167 +52,241 @@ The speaker device driver allows applica @@ -52,167 +52,241 @@ The speaker device driver allows applica
52speaker on machines with a PC-like 8253 timer implementation or a synthesized 52speaker on machines with a PC-like 8253 timer implementation or a synthesized
53speaker from an audio device/soundcard. 53speaker from an audio device/soundcard.
54.Pp 54.Pp
55Only one process may have this device open at any given time; 55Only one process may have this device open at any given time;
56.Xr open 2 56.Xr open 2
57and 57and
58.Xr close 2 58.Xr close 2
59are used to lock and relinquish it. 59are used to lock and relinquish it.
60An attempt to 60An attempt to
61.Xr open 2 61.Xr open 2
62when another process has the device locked will return \-1 with an 62when another process has the device locked will return \-1 with an
63.Er EBUSY 63.Er EBUSY
64error indication. 64error indication.
65Writes to the device are interpreted as 'play strings' in a 65Writes to the device are interpreted as
66simple ASCII melody notation. 66.Dq play strings
 67in a simple
 68.Tn ASCII
 69melody notation.
67An 70An
68.Fn ioctl 71.Fn ioctl
69for tone generation at arbitrary frequencies is also supported. 72for tone generation at arbitrary frequencies is also supported.
70.Pp 73.Pp
71For the pcppi device sound-generation does 74For the
 75.Xr pcppi 4
 76device sound-generation does
72.Em not 77.Em not
73monopolize the processor; in fact, the driver 78monopolize the processor; in fact, the driver
74spends most of its time sleeping while the PC hardware is emitting 79spends most of its time sleeping while the PC hardware is emitting
75tones. 80tones.
76Other processes may emit beeps while the driver is running. 81Other processes may emit beeps while the driver is running.
77.Pp 82.Pp
78For the audio device speaker, the speaker uses one of the virtual audio 83For the audio device speaker, the speaker uses one of the virtual audio
79channels. 84channels.
80Enabling this device will also provide a 85Enabling this device will also provide a
81.Xr wsbell 4 86.Xr wsbell 4
82keyboard bell. 87keyboard bell.
83.Pp 88.Pp
84Applications may call 89Applications may call
85.Fn ioctl 90.Fn ioctl
86on a speaker file descriptor to control the speaker driver directly; 91on a speaker file descriptor to control the speaker driver directly;
87definitions for the 92definitions for the
88.Fn ioctl 93.Fn ioctl
89interface are in 94interface are in
90.In dev/spkrio.h . 95.In dev/spkrio.h .
91.Pp 96.Pp
92The tone_t structure is as follows: 97The
93.Bd -literal 98.Vt tone_t
 99structure is as follows:
 100.Bd -literal -offset indent
94typedef struct { 101typedef struct {
95 int frequency; /* in hertz */ 102 int frequency; /* in hertz */
96 int duration; /* in 1/100ths of a second */ 103 int duration; /* in 1/100ths of a second */
97} tone_t; 104} tone_t;
98.Ed 105.Ed
 106.Pp
99A frequency of zero is interpreted as a rest. 107A frequency of zero is interpreted as a rest.
100.Pp 108.Pp
101At present there are four ioctls: 109At present there are four ioctls:
102.Bl -tag -width Dv 110.Bl -tag -width Dv
103.It Dv SPKRGETVOL 111.It Dv SPKRGETVOL
104Returns an integer, which is the current bell volume as a percentage (0-100). 112Returns an integer, which is the current bell volume as a percentage (0\(en100).
105.It Dv SPKRSETVOL 113.It Dv SPKRSETVOL
106Accepts an integer, which is the desired volume as a percentage. 114Accepts an integer, which is the desired volume as a percentage.
107.It Dv SPKRTONE 115.It Dv SPKRTONE
108Accepts a pointer to a single tone structure as third argument and plays it. 116Accepts a pointer to a single tone structure as third argument and plays it.
109.It Dv SPKRTUNE 117.It Dv SPKRTUNE
110Accepts a pointer to the first of an array of tone structures and plays 118Accepts a pointer to the first of an array of tone structures and plays
111them in continuous sequence; this array must be terminated by a final member 119them in continuous sequence; this array must be terminated by a final member
112with a zero duration. 120with a zero duration.
113.El 121.El
114.Pp 122.\"
115The play-string language is modelled on the PLAY statement conventions of 123.Ss Play string language
116IBM BASIC 2.0. 124.\"
117The MB, MF and X primitives of PLAY are not useful in a UNIX 125The play string language is modelled on the
 126.Ic PLAY
 127statement conventions of
 128.Tn IBM BASIC No 2.0 .
 129The
 130.Ic MB ,
 131.Ic MF
 132and
 133.Ic X
 134primitives of
 135.Ic PLAY
 136are not useful in a
 137.Tn UNIX
118environment and are omitted. 138environment and are omitted.
119The `octave-tracking' feature is also new. 139The
 140.Dq octave-tracking
 141feature is also new.
120.Pp 142.Pp
121There are 84 accessible notes numbered 1-84 in 7 octaves, each running from 143There are 84 accessible notes numbered 1\(en84 in 7 octaves, each running from
122C to B, numbered 0-6; the scale is equal-tempered A440 and octave 3 starts 144C to B, numbered 0\(en6; the scale is equal-tempered A440 and octave\~3 starts
123with middle C. 145with middle C.
124By default, the play function emits half-second notes with the 146By default, the play function emits half-second notes with the
125last 1/16th second being `rest time'. 147last 1/16th second being
 148.Dq rest time .
126.Pp 149.Pp
127Play strings are interpreted left to right as a series of play command groups; 150Play strings are interpreted left to right as a series of play command groups.
128letter case is ignored. 151Letter case is ignored.
 152Whitespace is ignored and may be used to separate melody sections.
129Play command groups are as follows: 153Play command groups are as follows:
130.Pp 154.Bl -tag -width Ic
131CDEFGAB -- letters A through G cause the corresponding note to be played in the 155.It Ic C , D , E , F , G , A , B
132current octave. 156Letters
 157.Sq Ic A
 158through
 159.Sq Ic G
 160cause the corresponding note to be played in the current octave.
133A note letter may optionally be followed by an 161A note letter may optionally be followed by an
134.Em accidental sign , 162.Em accidental sign ,
135one of # + or -; the first two of these cause it to be sharped one 163one of
 164.Sq Ic \&# ,
 165.Sq Ic \&+ ,
 166or
 167.Sq Ic \&- ;
 168the first two of these cause it to be sharped one
136half-tone, the last causes it to be flatted one half-tone. 169half-tone, the last causes it to be flatted one half-tone.
137It may also be 170It may also be
138followed by a time value number and by sustain dots (see below). 171followed by a time value number and by sustain dots (see below).
139Time values 172Time values are interpreted as for the
140are interpreted as for the L command below;. 173.Sq Ic L
141.Pp 174command below;.
142O <n> -- if <n> is numeric, this sets the current octave. 175.\"
143<n> may also be one 176.It Ic O Ns Ar n , Ic OL , Ic ON
144of 'L' or 'N' to enable or disable octave-tracking (it is disabled by default). 177If
 178.Ar n
 179is numeric, this sets the current octave.
 180.Sq Ic OL
 181enables, and
 182.Sq Ic ON
 183disables
 184.Em octave-tracking
 185(it is disabled by default).
145When octave-tracking is on, interpretation of a pair of letter notes will 186When octave-tracking is on, interpretation of a pair of letter notes will
146change octaves if necessary in order to make the smallest possible jump between 187change octaves if necessary in order to make the smallest possible jump between
147notes. 188notes.
148Thus "olbc" will be played as "olb>c", and "olcb" as "olc<b". 189Thus
149Octave 190.Dq Li olbc
150locking is disabled for one letter note following by >, < and O[0123456]. 191will be played as
151.Pp 192.Dq Li olb>c ,
152> -- bump the current octave up one. 193and
153.Pp 194.Dq Li olcb
154< -- drop the current octave down one. 195as
155.Pp 196.Dq Li olc<b .
156N <n> -- play note n, n being 1 to 84 or 0 for a rest of current time value. 197Octave tracking is temporarily disabled for one letter note that follows
 198.Sq Ic \&> ,
 199.Sq Ic \&<
 200or
 201.Sq Ic O Ns Ar n .
 202.\"
 203.It Ic \&>
 204Bump the current octave up one.
 205.\"
 206.It Ic \&<
 207Drop the current octave down one.
 208.\"
 209.It Ic N Ns Ar n
 210Play note
 211.Ar n ,
 212.Ar n
 213being 1 to 84 or 0 for a rest of current time value.
157May be followed by sustain dots. 214May be followed by sustain dots.
158.Pp 215.\"
159L <n> -- sets the current time value for notes. 216.It Ic L Ns Ar n
160The default is L4, quarter notes. 217Sets the current time value for notes.
 218The default is
 219.Dq Li L4 ,
 220quarter notes.
161The lowest possible value is 1; values up to 64 are accepted. 221The lowest possible value is 1; values up to 64 are accepted.
162L1 sets whole notes, L2 sets half notes, L4 sets quarter notes, etc.. 222.Dq Li L1
163.Pp 223sets whole notes,
164P <n> -- pause (rest), with <n> interpreted as for L. 224.Dq Li L2
165May be followed by 225sets half notes,
166sustain dots. 226.Dq Li L4
167May also be written '~'. 227sets quarter notes, etc...
168.Pp 228.\"
169T <n> -- Sets the number of quarter notes per minute; default is 120. 229.It Ic P Ns Ar n , Ic \&~ Ns Ar n
 230Pause (rest), with
 231.Ar n
 232interpreted as for
 233.Sq Ic L .
 234May be followed by sustain dots.
 235.\"
 236.It Ic T Ns Ar n
 237Sets the number of quarter notes per minute; default is 120.
170Musical names for common tempi are: 238Musical names for common tempi are:
171.Bl -column Description Prestissimo "Beats per Minute" -offset indent 239.Bl -column "very slow" "Larghissimo" "999\(en999" -offset indent
172.It Ta Sy Tempo Ta Sy "Beats per Minute" 240.It Ta Sy "Tempo" Ta Sy "BPM"
173.It very slow Ta Larghissimo Ta "" 241.It very slow Ta Larghissimo Ta ""
174.It Ta Largo Ta 40-60 242.It Ta Largo Ta 40\(en60
175.It Ta Larghetto Ta 60-66 243.It Ta Larghetto Ta 60\(en66
176.It Ta Grave Ta "" 244.It Ta Grave Ta ""
177.It Ta Lento Ta "" 245.It Ta Lento Ta ""
178.It Ta Adagio Ta 66-76 246.It Ta Adagio Ta 66\(en76
179.It slow Ta Adagietto Ta "" 247.It slow Ta Adagietto Ta ""
180.It Ta Andante Ta 76-108 248.It Ta Andante Ta 76\(en108
181.It medium Ta Andantino Ta "" 249.It medium Ta Andantino Ta ""
182.It Ta Moderato Ta 108-120 250.It Ta Moderato Ta 108\(en120
183.It fast Ta Allegretto Ta "" 251.It fast Ta Allegretto Ta ""
184.It Ta Allegro Ta 120-168 252.It Ta Allegro Ta 120\(en168
185.It Ta Vivace Ta "" 253.It Ta Vivace Ta ""
186.It Ta Veloce Ta "" 254.It Ta Veloce Ta ""
187.It Ta Presto Ta 168-208 255.It Ta Presto Ta 168\(en208
188.It very fast Ta Prestissimo Ta "" 256.It very fast Ta Prestissimo Ta ""
189.El 257.El
190.Pp 258.\"
191M[LNS] -- set articulation. 259.It Ic ML , Ic MN , Ic MS
192MN (N for normal) is the default; the last 1/8th of 260Set articulation.
 261.Sq Ic MN
 262(for normal) is the default; the last 1/8th of
193the note's value is rest time. 263the note's value is rest time.
194You can set ML for legato (no rest space) or 264You can set
195MS (staccato) 1/4 rest space. 265.Sq Ic ML
 266for legato (no rest time) or
 267.Sq Ic MS
 268for staccato (1/4 rest time).
 269.El
196.Pp 270.Pp
197Notes (that is, CDEFGAB or N command character groups) may be followed by 271Notes, that is,
198sustain dots. 272.Ic C , D , E , F , G , A , B ,
 273or
 274.Ic N
 275command character groups, may be followed by sustain dots.
199Each dot causes the note's value to be lengthened by one-half 276Each dot causes the note's value to be lengthened by one-half
200for each one. 277for each one.
201Thus, a note dotted once is held for 3/2 of its undotted value; 278Thus, a note dotted once is held for 3/2 of its undotted value;
202dotted twice, it is held 9/4, and three times would give 27/8. 279dotted twice, it is held 9/4, and three times would give 27/8.
203.Pp 
204Whitespace in play strings is simply skipped and may be used to separate 
205melody sections. 
206.Sh FILES 280.Sh FILES
207.Bl -tag -width Pa -compact 281.Bl -tag -width Pa -compact
208.It Pa /dev/speaker 282.It Pa /dev/speaker
209.El 283.El
210.Sh SEE ALSO 284.Sh SEE ALSO
211.Xr audio 4 , 285.Xr audio 4 ,
212.Xr pcppi 4 , 286.Xr pcppi 4 ,
213.Xr wsbell 4 , 287.Xr wsbell 4 ,
214.Xr sysctl 8 288.Xr sysctl 8
215.Sh HISTORY 289.Sh HISTORY
216This 290This
217.Nm 291.Nm
218device was originally for the pcppi PC timer interface. 292device was originally for the pcppi PC timer interface.