From nobody Fri Oct 22 17:31:45 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 36BFA17F238C; Fri, 22 Oct 2021 17:31:48 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from cell.glebi.us (glebi.us [162.251.186.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HbWcM6B4Qz3CRb; Fri, 22 Oct 2021 17:31:47 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.16.1/8.16.1) with ESMTPS id 19MHVjGC006036 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 22 Oct 2021 10:31:45 -0700 (PDT) (envelope-from glebius@freebsd.org) Received: (from glebius@localhost) by cell.glebi.us (8.16.1/8.16.1/Submit) id 19MHVjKY006035; Fri, 22 Oct 2021 10:31:45 -0700 (PDT) (envelope-from glebius@freebsd.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@freebsd.org using -f Date: Fri, 22 Oct 2021 10:31:45 -0700 From: Gleb Smirnoff To: Warner Losh Cc: Alexey Dokuchaev , src-committers , "" , dev-commits-src-main@freebsd.org Subject: Re: git: 225639e7db68 - main - vt: Disable bell by default Message-ID: References: <20211019133700.77c0ca7ac488eb99df50551b@bidouilliste.com> <20211020095206.GA77338@zxy.spb.ru> <20211020134237.17596440e1fabda5d40f6985@bidouilliste.com> <20211021080214.GB77338@zxy.spb.ru> <99e7aecf-9ab7-8b8f-ff30-b5fce3e031c2@FreeBSD.org> List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 4HbWcM6B4Qz3CRb X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N 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