Making music on the BBC computer – Errata

Preamble

This excellent book, Making music on the BBC computer by Ian Waugh, first came to my attention whilst watching the video, Another Way of getting Audio out of the BBC Micro Model B.

However, there is a serious truncation in one of the BASIC program listings (listing 5.2), which unfortunately makes the Pitch Generator program fail miserably.

[image of cover]

However, there is a happy ending and I found the missing lines of BASIC code… although there was still one other bug that needed fixing.

See also

Links

Vaguely related:

Notes

About the author

There are a number of Ian Waugh’s mentioned in various Wiki sites across the web, who may or may not be the same person:

According to this post, he was a regular contributer to The Micro User from 1987, and had his own column.

About the book

Apart from the video, the only other good source of information is the thread about the boot on the StarDot forum, Making Music on the BBC Computer by Ian Waugh. It is upon this thread that I have commented about the truncated BASIC listing.

The OCR version of the book PDF is littered with typos: the “l” character is often an “f” leading to “fisting” and “fines”, instead of “listing” and “lines”. The spacing in the BASIC listings can be a bit messed up as well. However, at least it is possible to copy and paste the listings into Beebem.

The bitmap scanned version of the book PDF has no copiable text.

There are a number of bugs in the listings in the book, which, each time the reader comes upon them, slowly reduces the confidence that one has in the book itself, which is a shame.

Editions

There are at least two editions of this book, both of which are very similar, except that they were typeset by different companies:

  • First published 1983 – Sunshine Books (an imprint of Scot Press Ltd.)
    • PDF on 8bs.com
    • ISBN 0 946408 26 2
    • Typeset by Commercial Colour Press
    • Digitally remastered 2011 on RISC OS computers
  • 1984
    • Archive.org
    • ISBN 0 946408 26 2
    • Typeset by The Leagrave Press Ltd
  • 9 Feb 1984 (according to Amazon)
    • ISBN-10 ‏ : ‎ 0946408262
    • ISBN-13 ‏ : ‎ 978-0946408269

Errors in listing 5.2

  • Line 150 is missing
  • Program listing 5.2 is truncated.

Missing procedure definitions

I found that on page 68, listing 5.2 (the pitch generator) is missing (at least) three procedure definitions:

  • PROCAlterPit;
  • PROCFinalTimeCheck, and;
  • PROCOvertime.

The listing just ends at line 2350, in both the 1983 PDF on 8bs (OCR), and the 1984 version on archive.org (bitmap scan).

The text under Program notes on page 70 refers to various lines ranging from 2490-2590, as well as referring to PROCAlterPit, PROCFinalTimeCheck and PROCOvertime, so clearly a number of lines are missing and the listing has been truncated at the time of publication.

SSD saved version of the listing

The saved copy of a manually typed in listing (from the book) is in file PG5-2 in the making_music.zip file, which contains a DSD of the code, linked to in the first post on the StarDot thread. This saved copy is similarly incorrect, ending prematurely at line 2350.

In fact, the SSD/DSD version is even worse than the book listing as it has changed line 2330 from PROCAlterPit to PROCAlter, which while it exists, is incorrect and is certainly not a substitute for PROCAlterPit (even though they work similarly, but on amplitude and pitch respectively).

Another omission in the listing of program 5.2

The listing in the book shows in line 29

29 REM Altered Lines=150,810

However, whilst 810 is indeed altered, the new version of line 150 is not shown. This line should be:

150 IF Input$="C" PROCAxis:PROCAxis2

Typo in procedure name

[Ed. – actually, this is not an error at all, and the listing is correct]

In the listing in the book there is another error. The procedure dealing with the pitch envelope, PROCPitEnv (which is defined on line 2230), is named differently from one of the two calls to it.

The simplest fix

One fix is to change the typo in the one line that contains the mispelt call to that procedure:

1244 PROCPitchEnv

should be

1244 PROCPitEnv
Alternate fix

A much better fix, for the sake of readability, leave line 1244 as shown in the book and instead change the following lines to read PROCPitchEnv instead of PROCPitEnv:

145 IF Input$>="!" AND Input$<="'" Input=ASC(Input$):PROCPitEnv

and

2230 DEF PROCPitEnv

Like so,

145 IF Input$>="!" AND Input$<="'" Input=ASC(Input$):PROCPitchEnv

and

2230 DEF PROCPitchEnv

Another typo in procedure name?

[Ed. – actually, this is not an error at all, and the listing is correct]

The missing procedure name, PROCAlterPit, could also be incorrectly spelt, when one considers that listing 7.2 has a similar procedure called PROCAlterPitch.

Possible fixes to find the missing procedures

[Ed. – As the missing lines have been found this section is now redundant]

Taking PROCAlterPitch from listing 7.2

1190 DEF PROCAlterPitch
1200 PRINTTAB(2,11)CHR$133;" Enter Pitch 0 - 255 "
1210 REPEAT
1220 PRINTTAB(24,11)CHR$133;CHR$136;
1230 INPUT Pitch
1240 PRINTTAB(26,11)SPC8
1250 UNTIL Pitch>-1 AND Pitch<256
1260 ENDPROC

However, seeing as Program notes in the text, on page 70, refer to Pitch having an “assistant” variable called Pit1, and the function of this procedure from listing 7.2 is as a manual input mechanism to change the pitch, it seems unlikely that the above procedure is an actual substitute for the missing procedure in listing 5.2.

Help wanted!

[Ed. – As the missing lines have been found this section is now redundant]

Does anyone know what the missing lines are, or where they may be found? Was there an Errata sheet included in the book? Is the author, Ian Waugh, still around and able to be contacted?

Actual missing lines

Within the ZIP hosted on 8bs.com, there are two SSD images: SIDE0.SSD and SIDE2.SSD. On SIDE0.SSD there is an actual working listing of 5.2. The missing lines are as follows:

2360
2370 DEF PROCAlterPit
2380 INPUT NewVal$:PRINTTAB(0,2)SPC(6)
2390 IF NewVal$=“” PROCReset: PROCPrintEnv:ENDPROC
2400 NewVal=EVAL(NewVal$)
2410 PRINTTAB(30,0)SPC(20)
2420 ON (Input-32) GOTO 2430, 2440, 2450,2460,2470,2480
2430 PI1=NewVal:ENDPROC
2440 PI2=NewVal:ENDPROC
2450 PI3=NewVal:ENDPROC
2460 PN1=NewVal:ENDPROC
2470 PN2=NewVal:ENDPROC
2480 PN3=NewVal:ENDPROC
2490 ENDPROC
2500
2510 DEF PROCPitchEnv
2520 Time=0
2530 YScale=3
2540 MOVE 0,Pitch*YScale
2550 REPEAT
2560 Pitch=Pit1
2570 PROCP(PI1, PN1)
2580 PROCP(PI2, PN2)
2590 PROCP(PI3, PN3)
2600 UNTIL FTime OR T1>127
2610 ENDPROC
2620 
2630 DEF PROCFinalTimeCheck
2640 FTime=FALSE
2650 IF Time>Duration*5 Time=Duration*5:FTime=TRUE
2660 ENDPROC
2670

PitEnv or PitchEnv

[Ed. – actually, this is not an error at all, and the listing is correct]

It worth noting that even on this complete version on the SSD, there is still the same mis-spelling of PROCPitchEnv as in the book. So change the lines to be:

145 IF Input$>="!" AND Input$<="'" Input=ASC(Input$):PROCPitchEnv

and

2230 DEF PROCPitchEnv

Similarly named procedures

There are two similarly named PROCs: PROCPitEnv and PROCPitchEnv, which, to be frank, is ridiculous, and rather confusing. GIven the number of errata in the book, it isn’t unreasonable to assume that this is yet another example of a typo.

Now the full listing on SIDE0.SSD actually uses the same lines as in the book (145, 1244, 2230, as well as the newly discovered 2510:

145 IF Input$>="!" AND Input$<="'" Input=ASC(Input$):PROCPitEnv
...
1244 PROCPitchEnv
...
2230 DEF PROCPitEnv
...
2510 DEF PROCPitchEnv

However, even though this looks like another typographical error, in fact, it is not, and the listing is correct (for once!).

One last bug – Changing the Pitch

The code in the full listing on SIDE0.SSD doesn’t appear to run correctly, You can not change the pitch parameter of the envelope. The text of “Using the program” explicity states that the user should be able to change the pitch:

You now have control over pitch and the six pitch envelope parameters. These are accessed by pressing SHIFT and the keys 1 to 7, ie the characters !, “, #, $, %, & and ‘

However, if you hit ' (i.e. shift 7), then line 2420 gives an out of range for the ON x GOTO as follows:

ON range at line 2420

This is because there are only 6 options, not 7, and the code of ' is 39:

2420 ON (Input-32) GOTO 2430, 2440, 2450,2460,2470,2480

In addition, line 2310 seems to be incorrect, as it is a near duplicate of the preceding line.

...
2300 IF Input=38 pn3=1
2310 IF Input=39 pn3=1
...

Surely, it should set the colour of the displayed value of Pitch (i.e. p), rather than the colour of the displayed value of PN3 (i.e. pn3), as the key code of  ' is 39?

So, line 2310 should be

2310 IF Input=39 p=1

Finally, to fix the ON x GOTO range error and actually be able to change the value of Pitch, change line 2420 to add a seventh line option

2420 ON (Input-32) GOTO 2430,2440,2450,2460,2470,2480,2485

and then add a new line to change the pitch. However, whereas one might think that we have to update the Pitch variable, like so:

2485 Pitch=NewVal:ENDPROC

Actually, you have to update the pitch variable helper/”assistant”, Pit1instead:

2485 Pit1=NewVal:ENDPROC

Now, with these fixes, the program runs as expected and as described in the book.

In summary – the patches

The listing 5.2, as shown in the book, needs to be fixed at the following lines

  • 150
  • 2310
  • 2360-2670
  • 2420
  • 2485
150 IF Input$="C" PROCAxis:PROCAxis2
2310 IF Input=39 p=1
2420 ON (Input-32) GOTO 2430,2440,2450,2460,2470,2480,2485
2485 Pit1=NewVal:ENDPROC

The missing lines 2360-2670, as shown above, and repeated here

#### The missing lines 2360-2670 of listing 5.2

2360
2370 DEF PROCAlterPit
2380 INPUT NewVal$:PRINTTAB(0,2)SPC(6)
2390 IF NewVal$=“” PROCReset: PROCPrintEnv:ENDPROC
2400 NewVal=EVAL(NewVal$)
2410 PRINTTAB(30,0)SPC(20)
2420 ON (Input-32) GOTO 2430, 2440, 2450,2460,2470,2480
2430 PI1=NewVal:ENDPROC
2440 PI2=NewVal:ENDPROC
2450 PI3=NewVal:ENDPROC
2460 PN1=NewVal:ENDPROC
2470 PN2=NewVal:ENDPROC
2480 PN3=NewVal:ENDPROC
2490 ENDPROC
2500
2510 DEF PROCPitchEnv
2520 Time=0
2530 YScale=3
2540 MOVE 0,Pitch*YScale
2550 REPEAT
2560 Pitch=Pit1
2570 PROCP(PI1, PN1)
2580 PROCP(PI2, PN2)
2590 PROCP(PI3, PN3)
2600 UNTIL FTime OR T1>127
2610 ENDPROC
2620 
2630 DEF PROCFinalTimeCheck
2640 FTime=FALSE
2650 IF Time>Duration*5 Time=Duration*5:FTime=TRUE
2660 ENDPROC
2670

blah

Another bug in the flashing parameter to be changed?

The flashing of the changed parameter does not stop once the new value has been entered, or even after the sound has been played (by hitting space). The flashing only ends when:

  • a new parameter is selected, or;
  • the selected parameter is not actually changed – by just hitting the enter key without actually entering a new value.

However, if you check this behaviour against the “standard” behaviour of listing 5.1, the behaviours are consistant. So, it is just a “quirk” of the program.

Other issues

  • The Pitch scale on the Y-axis is drawn incorrectly, such that one or two pixels of each scale line are shown to the left of the Y axis
  • There is no “??” prompt shown when the program has finished drawing graph
    • This behaviour is the same for listing 5.1, although, for the book’s text, this would seem to be a feature added in 5.2
  • The Pitch graph appears to just end at the start of the release phase

This is the end, my friend.

Leave a comment