]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man4/spkr.4
This commit was generated by cvs2svn to compensate for changes in r52279,
[FreeBSD/FreeBSD.git] / share / man / man4 / spkr.4
1 .\"
2 .\" $FreeBSD$
3 .\"
4 .Dd November 7, 1993
5 .Dt SPKR 4 i386
6 .Os FreeBSD
7 .Sh NAME
8 .Nm speaker ,
9 .Nm spkr
10 .Nd console speaker device driver
11 .Sh SYNOPSIS
12 .Cd pseudo-device speaker
13 .Fd #include <machine/speaker.h>
14 .Sh DESCRIPTION
15 The speaker device driver allows applications to control the PC console
16 speaker on an 
17 .Tn IBM-PC Ns --compatible
18 machine running
19 .Tn FreeBSD .
20 .Pp
21 Only one process may have this device open at any given time; 
22 .Xr open 2
23 and
24 .Xr close 2
25 are used to lock and relinquish it. An attempt to open when
26 another process has the device locked will return -1 with an
27 .Er EBUSY
28 error
29 indication. Writes to the device are interpreted as `play strings' in a
30 simple ASCII melody notation. An 
31 .Xr ioctl 2
32 request
33 for tone generation at arbitrary
34 frequencies is also supported.
35 .Pp
36 Sound-generation does not monopolize the processor; in fact, the driver
37 spends most of its time sleeping while the PC hardware is emitting
38 tones. Other processes may emit beeps while the driver is running.
39 .Pp
40 Applications may call 
41 .Xr ioctl 2
42 on a speaker file descriptor to control the
43 speaker driver directly; definitions for the 
44 .Xr ioctl 2
45 interface are in
46 .Pa /usr/include/machine/speaker.h .
47 The
48 .Li tone_t
49 structure used in these calls has two fields,
50 specifying a frequency (in Hz) and a duration (in 1/100ths of a second).
51 A frequency of zero is interpreted as a rest.
52 .Pp
53 At present there are two such
54 .Xr ioctl 2
55 calls.
56 .Dv SPKRTONE
57 accepts a pointer to a
58 single tone structure as third argument and plays it. 
59 .Dv SPKRTUNE
60 accepts a
61 pointer to the first of an array of tone structures and plays them in
62 continuous sequence; this array must be terminated by a final member with
63 a zero duration.
64 .Pp
65 The play-string language is modelled on the PLAY statement conventions of
66 .Tn IBM 
67 Advanced BASIC 2.0.  The
68 .Li MB ,
69 .Li MF ,
70 and
71 .Li X
72 primitives of PLAY are not
73 useful in a timesharing environment and are omitted. The `octave-tracking'
74 feature and the slur mark are new.
75 .Pp
76 There are 84 accessible notes numbered 1-84 in 7 octaves, each running from
77 C to B, numbered 0-6; the scale is equal-tempered A440 and octave 3 starts
78 with middle C.  By default, the play function emits half-second notes with the
79 last 1/16th second being `rest time'.
80 .Pp
81 Play strings are interpreted left to right as a series of play command groups;
82 letter case is ignored. Play command groups are as follows:
83 .Bl -tag -width CDEFGABxx
84 .It Li CDEFGAB
85 Letters A through G cause the corresponding note to be played in the
86 current octave.  A note letter may optionally be followed by an 
87 .Dq Em "accidental sign" , 
88 one of # + or -; the first two of these cause it to be sharped one
89 half-tone, the last causes it to be flatted one half-tone.  It may
90 also be followed by a time value number and by sustain dots (see
91 below).  Time values are interpreted as for the L command below.
92 .It Ns Li O Sy n
93 If
94 .Sy n
95 is numeric, this sets the current octave.
96 .Sy n
97 may also be one of
98 .Li L
99 or
100 .Li N
101 to enable or disable octave-tracking (it is disabled by default).
102 When octave-tracking is on, interpretation of a pair of letter notes
103 will change octaves if necessary in order to make the smallest
104 possible jump between notes. Thus ``olbc'' will be played as
105 ``olb>c'', and ``olcb'' as ``olc<b''.  Octave locking is disabled for
106 one letter note following >, < and O[0123456].  (The octave-locking
107 feature is not supported in 
108 .Tn IBM
109 BASIC.)
110 .It Li >
111 Bump the current octave up one.
112 .It Li <
113 Drop the current octave down one.
114 .It Ns Li N Sy n
115 Play note 
116 .Sy n ,
117 .Sy n
118 being 1 to 84 or 0 for a rest of current time value.
119 May be followed by sustain dots.
120 .It Ns Li L Sy n
121 Sets the current time value for notes.  The default is 
122 .Li L4 ,
123 quarter or crotchet notes. The lowest possible value is 1; values up
124 to 64 are accepted.
125 .Li L1
126 sets whole notes,
127 .Li L2
128 sets half notes,
129 .Li L4
130 sets quarter notes, etc.
131 .It Ns Li P Sy n
132 Pause (rest), with 
133 .Sy n
134 interpreted as for 
135 .Ns Li L Sy n .
136 May be followed by
137 sustain dots.  May also be written
138 .Li ~ .
139 .It Ns Li T Sy n
140 Sets the number of quarter notes per minute; default is 120.  Musical
141 names for common tempi are:
142
143 .Bd -literal -offset indent
144                 Tempo           Beats Per Minute
145 very slow       Larghissimo     
146                 Largo           40-60
147                 Larghetto       60-66
148                 Grave           
149                 Lento           
150                 Adagio          66-76
151 slow            Adagietto       
152                 Andante         76-108
153 medium          Andantino       
154                 Moderato        108-120
155 fast            Allegretto      
156                 Allegro         120-168
157                 Vivace          
158                 Veloce          
159                 Presto          168-208
160 very fast       Prestissimo     
161 .Ed
162 .It Li M[LNS]
163 Set articulation.
164 .Li MN
165 .Ns No ( Li N
166 for normal) is the default; the last 1/8th of
167 the note's value is rest time. You can set
168 .Li ML
169 for legato (no rest space) or
170 .Li MS
171 for staccato (1/4 rest space).
172 .El
173 .Pp
174 Notes (that is,
175 .Li CDEFGAB
176 or
177 .Li N
178 command character groups) may be followed by
179 sustain dots. Each dot causes the note's value to be lengthened by one-half
180 for each one. Thus, a note dotted once is held for 3/2 of its undotted value;
181 dotted twice, it is held 9/4, and three times would give 27/8. 
182 .Pp
183 A note and its sustain dots may also be followed by a slur mark (underscore).
184 This causes the normal micro-rest after the note to be filled in, slurring it
185 to the next one.  (The slur feature is not supported in 
186 .Tn IBM
187 BASIC.)
188 .Pp
189 Whitespace in play strings is simply skipped and may be used to separate
190 melody sections.
191 .Sh BUGS
192 Due to roundoff in the pitch tables and slop in the tone-generation and timer
193 hardware (neither of which was designed for precision), neither pitch accuracy
194 nor timings will be mathematically exact. There is no volume control.
195 .Pp
196 The action of two or more sustain dots does not reflect standard musical
197 notation, in which each dot adds half the value of the previous dot
198 modifier, not half the value of the note as modified.  Thus, a note dotted
199 once is held for 3/2 of its undotted value; dotted twice, it is held 7/4,
200 and three times would give 15/8.  The multiply-by-3/2 interpretation,
201 however, is specified in the 
202 .Tn IBM
203 BASIC manual and has been retained for
204 compatibility.
205 .Pp
206 In play strings which are very long (longer than your system's physical I/O
207 blocks) note suffixes or numbers may occasionally be parsed incorrectly due
208 to crossing a block boundary.
209 .Sh FILES
210 .Bl -tag -width /dev/speakerxx
211 .It Pa /dev/speaker
212 speaker device file
213 .El
214 .Sh SEE ALSO
215 .Xr spkrtest 8
216 .Sh AUTHORS
217 .An Eric S. Raymond Aq esr@snark.thyrsus.com
218 June 1990
219 .Sh "PORTED BY"
220 .An Andrew A. Chernov Aq ache@astral.msk.su
221 .Sh HISTORY
222 The
223 .Nm
224 device appeared in
225 .Fx 1.0 .