Date: Fri, 22 Oct 2021 10:31:45 -0700 From: Gleb Smirnoff <glebius@freebsd.org> To: Warner Losh <imp@bsdimp.com> Cc: Alexey Dokuchaev <danfe@freebsd.org>, src-committers <src-committers@freebsd.org>, "<dev-commits-src-all@freebsd.org>" <dev-commits-src-all@freebsd.org>, dev-commits-src-main@freebsd.org Subject: Re: git: 225639e7db68 - main - vt: Disable bell by default Message-ID: <YXL1gTvL/NHsF4G1@FreeBSD.org> In-Reply-To: <CANCZdfpMyOgKvnkHvH_Cwg_s9=3dxaon4PRe2kBJYTxtc6qzVg@mail.gmail.com> References: <20211019133700.77c0ca7ac488eb99df50551b@bidouilliste.com> <20211020095206.GA77338@zxy.spb.ru> <20211020134237.17596440e1fabda5d40f6985@bidouilliste.com> <YXBNqdMe2y1bJj43@FreeBSD.org> <20211021080214.GB77338@zxy.spb.ru> <YXGdSdBWvHzHqK4J@FreeBSD.org> <99e7aecf-9ab7-8b8f-ff30-b5fce3e031c2@FreeBSD.org> <CANCZdfrPMLBSzuo1XzWroVMpzG_mLDeZxTbo3r0-_7SQz_C8%2Bg@mail.gmail.com> <YXItLjwMQ58k9kOu@FreeBSD.org> <CANCZdfpMyOgKvnkHvH_Cwg_s9=3dxaon4PRe2kBJYTxtc6qzVg@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Warner, sorry for top quoting. I love this email very much :) Can we please improve the tone of the bell? On Thu, Oct 21, 2021 at 10:55:00PM -0600, Warner Losh wrote: W> FreeBSD controls the pitch and duration of the noise. And there's W> at least one bug in it. W> W> It looks like we want 800Hz: W> W> #define VT_BELLPITCH 800 W> W> But we ring the bell with W> W> sysbeep(1193182 / VT_BELLPITCH, VT_BELLDURATION); W> W> which looks almost sane. 1.193182MHz is the clock frequency W> of the IBM PC PIT square wave generator. And normally it's programmed W> by dividing this base clock by the desired clock. So we're passing W> in 1491 into sysbeep. We have a tuneable for the 8254 frequency that W> the PIT uses, so it's a bug that we're ignoring that and hard coding this W> value. W> W> Now, sysbeep is only defined on x86, where this is W> timer_spkr_setfreq(pitch); W> otherwise it's nothing. So, timer_spkr_setfreq looks like: W> freq = i8254_freq / freq; W> outb(TIMER_CNTR2, freq & 0xff); W> outb(TIMER_CNTR2, freq >> 8); W> so this computation means we are actually playing a 1491Hz tone for 50ms. W> You can verify this will be the frequency with any PC speaker tutorial. W> W> This corresponds to no natural note in western music. F#6 is 1480Hz and F6 W> is 1397Hz. So the tone that's generated is a dissonant note. C4 is middle C, W> so this is two octaves higher and a little bit. W> W> Even the 800Hz is between G5 and G5#. Not a great note, but at least W> it's an octave lower. So even the desired beep is dissonant. W> W> Since most people find music pleasing, that makes it objectively annoying. W> A similar analysis for the other common tunings (where A4 is one of 432, W> 436, W> 438, 440 (the most common these days), 442, 444, and 446Hz) yields W> similar results with varying degrees of subtonal dissonance. W> W> Also, 50ms is 1/20th of a second (give of take), which translates to about W> 600 beats per minute, which is annoyingly fast, as any musician would W> tell you. The only saving grace is that it's done only once. W> W> Also, the poll is running 4 to 1 for silence by default. While any bias in W> wording mighthave pushed it a little one way or the other, when it's this W> lopsided it's hard to argue that such bias affected the actual outcome. Our W> users aren't so unsophisticated as to be totally swayed by the choice of W> wording. The reply tweets suggest people know exactly what I'm talking W> about. Iknow it isn't scientific, but it is highly suggestive given the 60 W> point spread. Even had I used differentwording, my followers on twitter W> are self selecting which is likely a biggersource of error, and lord knows W> what Twitter's algorithms do to distort who sees it. And likely a dozen W> other W> factors I've not even thought of. W> W> Warner W> W> P.S. We likely should fix this bug, and also change the note to 880, which W> is W> A5 (the second A above middle C). Please see W> https://reviews.freebsd.org/D32594 W> for a fix for the bug I found here. -- Gleb Smirnoff
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?YXL1gTvL/NHsF4G1>