Right now to ring the bell, 386BSD provided a MD function sysbeep. we pass in the frequency ofThis took two arguments (pitch
and period). Pitch was jammed into the PIT's divisor directly (which
means the argument was expected to sound a tone at '1193182 / pitch'
Hz). FreeBSD inherited this interface.
In commit e46598588587 (svn 177642, Mar 26 2008), phk changed this
function to take a tone to sound in hz. He converted all in-tree
instances of 1193182 / hz to just hz (and kept the few misguided folks
that passed hz directly unchanged -- this was part of what motivated the
change). He converted the places where we pre-computed the 8254 divisor
from being pitch to 1193182 / pitch (since that converts the divisor to
the frequency and the interfaces that were exposed to userland exposed
it in these units in places, continuing the tradition inherited from SCO
System V/386 Unix in spots).
In 2009, Ed Shouten was contracted by the FreeBSD Foundation to write /
finish newcons. This work was done in perforce and was imported into
subversion in user/ed/newcons in revision 199072
(https://svnweb.freebsd.org/base?view=revision&revision=199072) which
was later imported into FreeBSD by ray@ (Aleksandr Rybalko).
From that earliest import into svn import to this date, we ring the bell
with:
sysbeep(1193182 / VT_BELLPITCH, VT_BELLDURATION);
however, that's bogus where VT_BELLPITCH was defined to be 800. The magic number is the PIT/i8254 frequency onThis results in a bell
the IBM-PC, and we have a tuneable for that (hw.i8254.freq).
But it's wrong on another level frequency of 1491Hz, more or less today. This frequency is passed to timer_spkr_setfreqis similar to the
which uses the following calculation: frequency that syscons and pcvt used (1493Hz and 1500Hz respectively).
freq = i8254_freq / freq; This in turn was inherited from 386BSD, it seems, which used the hard
outb(TIMER_CNTR2, freq & 0xff); coded value 0x31b which is 795 -> 1500Hz.
outb(TIMER_CNTR2, freq >> 8);
This '800' was intended to be the bell tone (eg 800Hz) and this
to mak interface was one the noiseat wasn't converted. So instead of getting a 800Hz note like we want,The most common terminal prior
we're really getting a 1491Hz note, which is an aweful and harsh note.
Correct the calculation to not pre-scale it by the nominal 8254 to the rise of PCs was the VT100, which had an approximately 800Hz
frequency. In addition, bump the requested note to 880Hz, bell. which is A5,Ed Shouten has confirmed that the original intent was 800Hz and
the second A above middle C. This is high enough changing this was overlooked after the change to be heard over the-current was made.
din of most enviroments, a regular musical note This restors that original intent and yet a little lessmakes the bell less obnoxious in
harsh than the current bug the produces. This is more in keeping with thecess.
original intent.