SPKR(4) BSD Programmer's Manual SPKR(4)
speaker, spkr - console speaker device driver
spkr0 at pcppi?
The speaker device driver allows applications to control the built-in speaker on machines providing a PCPPI speaker interface. Only one process may have this device open at any given time; open(2) and close(2) are used to lock and relinquish it. An attempt to open() when another process has the device locked will return -1 with an EBUSY error indication. Writes to the device are interpreted as "play strings" in a simple ASCII melody notation. An ioctl() for tone generation at arbitrary frequencies, within timer and device boundaries, is also supported. Sound-generation does not monopolize the processor; in fact, the driver spends most of its time sleeping while the PC hardware is emitting tones. Other processes may emit beeps while the driver is running. Applications may call ioctl() on a speaker file descriptor to control the speaker driver directly; definitions for the ioctl() interface are in <dev/isa/spkrio.h>. The tone_t structure used in these calls has two fields, specifying a frequency (in Hz) and a duration (in 1/100ths of a second). A frequency of zero is interpreted as a rest. At present there are two such ioctls. The SPKRTONE ioctl accepts a pointer to a single tone structure as a third argument and plays it. The SPKRTUNE ioctl accepts a pointer to the first of an array of tone struc- tures and plays them in continuous sequence; this array must be terminat- ed by a final member (sentinel) with a zero duration.
There are 84 accessible notes numbered 1-83 in 7 octaves, each running from C to B, numbered 0-6; octave 3 starts with Treble C (English C5, German c'' or lowercase c, superscript 2), which is also the lowest tone a soprano recorder (flute) can play; the scale is equal-tempered A440 (which is in octave 2, whose C (English C4, German c') is the tone between bass clef and violin/treble clef). By default, the play function emits half-second notes with the last 1/16th second being "rest time". Play strings are interpreted left to right as a series of play command groups; letter case is ignored. Play command groups are as follows: CDEFGAB[sign][len] Letters A through G cause the corresponding note (German: Letter B plays the note H) to be played in the current octave. A note letter may optionally be followed by an "accidental sign", one of '#', '+', or '-'; the first two of these cause it to be sharped one half-tone, the last causes it to be flatted one half-tone. (German: Combination B- plays the note B). It may also be followed by a time value number (see the L command below) and by sustain dots (see below). Ll Sets the current time value for notes. The default is L4, quarter 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. M[LNS] MN sets normal articulation; the last 1/8th of the note's value is rest time. MS is staccato, the last 1/4th is rest time. ML imple- ments both legato (Bindebogen) and slur (Haltebogen) with no rest. Nn Play note n, n being 1 to 84 or 0 for a rest of current time value. May be followed by sustain dots. Note 34 is A440, i.e. the note number is 15 less than its claviature, 34 less than its MIDI number. n defaults to 0 if omitted. Ox If x is numeric, this sets the current octave. x may also be one of 'L' or 'N' to enable or disable octave-tracking (it is disabled by default); when enabled, interpretation of a pair of letter notes will change octaves if necessary in order to make the smallest pos- sible jump between notes. Thus "olbc" will be played as "olb>c", and "olcb" as "olc<b". Octave tracking is disabled for one letter note following by '>', '<', and 'O'. x defaults to 4 if omitted. Pl Pause (rest) for the duration l, interpreted as for L; if omitted, the current time value is used. May be followed by sustain dots. Tt Sets the number of quarter notes per minute; values from 32 to 255 are accepted; default is 120. Musical names for common tempi are: Description Tempo Beats per Minute very slow Larghissimo 40-60 very slow Largo 40-60 very slow Larghetto 60-66 very slow Grave 60-66 very slow Lento 60-66 slow Adagio 66-76 slow Adagietto 66-76 medium Andante 76-108 medium Andantino 76-108 fast Moderato 108-120 fast Allegretto 108-120 fast Allegro 120-168 fast Vivace 120-168 fast Veloce 120-168 very fast Presto 168-208 very fast Prestissimo 168-208 . Notes (including pauses, that is, CDEFGAB, P, or N command character groups) may be followed (after all other arguments) by sustain dots. Each dot causes the note's time value to be lengthened by one-half. Thus, a note dotted once is held for 3/2 of its undotted value; dot- ted twice, it is held 9/4, and three times would give 27/8. > Bump the current octave up one. < Drop the current octave down one. Whitespace in play strings is simply skipped and may be used to separate melody sections. The default initialisation string is: MF MN ON O4 L4 T120
intro(4), pcppi(4) https://github.com/Natureshadow/mmllib
The play-string language is modelled on the PLAY statement conventions of IBM BASIC 2.0. It is also known as "modern MML" (music macro language). The MB, MF, and X directives, as well as variable references, are tied to the BASIC realisation and not useful in a UNIX environment; this imple- mentation skips the byte after an M, as well as from an X up to a semi- colon (';'). Passing a command argument as "=varname;" or its VARPTR$() form is not even parsed correctly, for obvious reasons. As extensions, if the arguments to L, N, O, P, and T are omitted, their default values are used; BASIC requires the arguments. The "accidental sign" can be applied abnormally (e.g. E# = F) and is ignored for O0C- and O6B#; too large values for immediate note lengths and the value for P use the current time value; for the values for L, O, and T, their respective default values are used; an N command with too large n is just ignored. As a local extension, a tilde ('~') can be used as an alias for P. Some implementations of modern MML use R (rest) instead of P for a pause; this is not supported, either in BASIC or by this implementation. The "octave-tracking" feature is also a local extension. Some implementations of parallel MML use the bar character ('|'), analog to bar lines, for synchronisation, as an extension. This implementation ignores these characters, allowing an individual staff from such MML file to be played without modification.
Eric S. Raymond <email@example.com>, Feb 1990 The driver and this manual page have been validated for correctness and completeness by mirabilos <firstname.lastname@example.org> for MirOS #11, Mar 2016.
Often-used file extensions for files containing play strings are .PLY (BASIC play) and .MML (often with extensions). Parallel MML files usually contain a per-file global header and multiple staff lines in an ordered fashion, akin to a container format for multiple MML tracks. ML articulation does not prohibit rearticulation, although it is expected that if a note played with ML articulation is followed immediately by another sound with the same frequency, their play times are merged. This implementation does not support merging; this is a known shortcoming.
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 nor timings will be mathematically exact. There is no volume control. In play strings which are very long (longer than your system's physical I/O blocks) note suffixes or numbers may occasionally be parsed in- correctly due to crossing a block boundary. This also applies to multi- character commands such as M or X. The original Microsoft(R) GW-BASIC(R) documentation, as well as the IBM Personal Computer Hardware Reference Library BASIC manual, Second Edition (May 1982), Version 1.10, already wrongly stated that octave 3 begins at the middle C; the middle C (German Schloss-C) begins octave 2, octave 3 begins with the "vocal" Tenor C, even in GW-BASIC(R) and BASICA. MirOS BSD #10-current March 29, 2016 2
Generated on 2016-04-09 18:24:16 by $MirOS: src/scripts/roff2htm,v 1.83 2016/03/26 23:38:28 tg Exp $
These manual pages and other documentation are copyrighted by their respective writers;
their source is available at our CVSweb,
AnonCVS, and other mirrors. The rest is Copyright © 2002–2016 The MirOS Project, Germany.
This product includes material provided by mirabilos.
This manual page’s HTML representation is supposed to be valid XHTML/1.1; if not, please send a bug report – diffs preferred.