Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ speaker(4) — AOS 4.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

SPEAKER(4)  —  

NAME

speaker − console speaker interface

DESCRIPTION

The speaker driver provides a write-only interface to the console speaker.  There are no ioctls.  The speaker is controlled by multiple writes of struct spk_blk defined in <machineio/speakerio.h>.  Writes of less than sizeof(struct spk_blk) are not accepted. 

The spk_blk structure is defined below:
 

/∗ spk_blk is how a user level program passes a note to the speaker ∗/
 
struct spk_blk {
unsigned charvolume;
unsigned charfreqhigh;
unsigned charfreqlow;
unsigned short duration;
};

Values written to /dev/speaker are checked according to the following rules:

 
1) volume must be 0,1,2, or 3.
 
2) freqhigh must be a non-negative integer power of two (i.e. a single bit) ≤ 64.
 
3) freqlow must be ≥ 19 if freqhigh = 1,
otherwise freqlow ≥ 120 (note all characters are unsigned.)
 
4) duration must be < 0x8000.

If the values written do not conform to the above rules, the values are changed to the nearest legal value before processing (for example, writing a volume of 10 gets changed to a volume of 3; writing a freqhigh of 18 gets changed to a freqhigh of 16). 

Units for the values are as follows:

 
a) Volume: 0 is off, 1 is low, 2 is medium, 3 is high.
   Only 0 for off and non-zero for on are recognized by the
   IBM 6152 Academic System.
 
b) Freqhigh/Freqlow:  To convert a frequency in hertz to freqhigh and
freqlow, use the following algorithm:
 
if (freq < 23) {
b.freqhigh=0;
b.freqlow=SPKOLOMIN;
} else if (freq < 46) {
b.freqhigh=64;
b.freqlow = (char) ((6000.0 /(float) freq) - 9.31);
} else if (freq < 91) {
b.freqhigh=32;
b.freqlow = (char) ((12000.0 /(float) freq) - 9.37);
} else if (freq < 182) {
b.freqhigh=16;
b.freqlow = (char) ((24000.0 /(float) freq) - 9.48);
} else if (freq < 363) {
b.freqhigh=8;
b.freqlow = (char) ((48000.0 /(float) freq) - 9.71);
} else if (freq < 725) {
b.freqhigh=4;
b.freqlow = (char) ((96000.0 /(float) freq) - 10.18);
} else if (freq < 1433) {
b.freqhigh=2;
b.freqlow = (char) ((192000.0 /(float) freq) - 11.10);
} else if (freq < 12020) {
b.freqhigh=1;
b.freqlow = (char) ((384000.0 /(float) freq) - 12.95);
} else {
b.freqhigh=0;
    b.freqlow=SPKOLOMIN;
}
 
 
c) Duration is in 1/128ths of a second.
   The IBM 6152 Academic System rounds this to a granularity
   of 1/18.5ths of a second.

FILES

/dev/speaker

BUGS

It is possible to queue 20 minutes of sound (5 notes with duration > 4 minutes) to the speaker which cannot be stopped (short of resetting the system). 

Because of blocking requirements, output cannot generally be redirected to /dev/speaker.  It must be sent to a program, such as dd(1), that will issue writes in multiples of sizeof (struct spk_blk). 

Control over volume is currently unimplemented on the IBM 6152 Academic System. 

PRPQs 5799-WZQ/5799-PFF: IBM/4.3  —  Dec 1987

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026