NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Typo in speaker(4) man page



The speaker(4) man page says this about the number of notes:

> There are 84 accessible notes numbered 1-83 in 7 octaves

The numbers 1-83 is 83 notes, not 84. Lower down, the man page supports
the fact that there are 84 notes:

> N ⟨n⟩    Play note n, n being 1 to 84 or 0 for a rest of current time
>         value. May be followed by sustain dots.

Finally, I checked the source code (src/sys/dev/spkr.c) to find out for
sure how many notes there are.

   static int pitchtab[] =
   {
   /*        C     C#    D     D#    E     F     F#    G     G#    A     A#    B*/
   /* 0 */   65,   69,   73,   78,   82,   87,   93,   98,  103,  110,  117,  123,
   /* 1 */  131,  139,  147,  156,  165,  175,  185,  196,  208,  220,  233,  247,
   /* 2 */  262,  277,  294,  311,  330,  349,  370,  392,  415,  440,  466,  494,
   /* 3 */  523,  554,  587,  622,  659,  698,  740,  784,  831,  880,  932,  988,
   /* 4 */ 1047, 1109, 1175, 1245, 1319, 1397, 1480, 1568, 1661, 1760, 1865, 1975,
   /* 5 */ 2093, 2217, 2349, 2489, 2637, 2794, 2960, 3136, 3322, 3520, 3729, 3951,
   /* 6 */ 4186, 4435, 4698, 4978, 5274, 5588, 5920, 6272, 6644, 7040, 7459, 7902,
   };

7 octaves times 12 notes per octave; that is definitely 84 notes. Of
course, the maximum index in this array is 83. The playtone() function
accepts pitches in the range -1 to 83. Still the parser expects the
array index + 1, with a range of 0 to 84. It subtracts 1 before passing
the pitch to playtone.

   case 'N':
   	GETNUM(cp, pitch);
   	for (sustain = 0; slen > 0 && cp[1] == '.'; cp++) {
   		slen--;
   		sustain++;
   	}
   	playtone(sc, pitch - 1, sc->sc_value, sustain);
   	break;

It looks like OpenBSD has the same bug. FreeBSD fixed it in 1998[1].

[1]: 
https://github.com/freebsd/freebsd/commit/6940406ec18a77f73b31f890526ab1963d028b05
Index: src/share/man/man4/speaker.4
===================================================================
RCS file: /cvsroot/src/share/man/man4/speaker.4,v
retrieving revision 1.23
diff -u -r1.23 speaker.4
--- src/share/man/man4/speaker.4	13 Jun 2017 06:25:20 -0000	1.23
+++ src/share/man/man4/speaker.4	3 Jul 2020 21:19:50 -0000
@@ -118,7 +118,7 @@
 environment and are omitted.
 The `octave-tracking' feature is also new.
 .Pp
-There are 84 accessible notes numbered 1-83 in 7 octaves, each running from
+There are 84 accessible notes numbered 1-84 in 7 octaves, each running from
 C to B, numbered 0-6; the scale is equal-tempered A440 and octave 3 starts
 with middle C.
 By default, the play function emits half-second notes with the


Home | Main Index | Thread Index | Old Index