100% found this document useful (1 vote)
940 views340 pages

BBC Music Masterclass

Uploaded by

nikpap82
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
940 views340 pages

BBC Music Masterclass

Uploaded by

nikpap82
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 340

BBC Micro Music Masterclass

Pan/Personal Computer News


Computer Library

lan Ritchie

BBC Micro
Music Masterclass
Pan Books London and Sydney

Contents
Da Capo

1. The SOUND Statement 11


2. The ENVELOPE Statement 28
3. The Sound of Noise 43
4. More on SOUND and ENVELOPE 53
5. Music Theory for Micros 70
6. Chords and Harmony 85
7. Music Graphics 101
8. Automatic Composition 129
9. Applications 147
10. Computers in Modern Music 197
11. Interfacing and Peripherals 207
12. Al Fine

Index 237

Front cover Back cover

First published 1984 by Pan Books Ltd,

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm.htm (1 of 2)20/06/2012 08:45:54


BBC Micro Music Masterclass

Cavaye Place, London SW10 9PG


in association with Personal Computer News
987654321
© Ian Ritchie 1984
ISBN 330 28673 0

Photoset by Parker Typesetting Service, Leicester


Printed and bound in Great Britain by
Richard Clay (The Chaucer Press) Ltd, Bungay, Suffolk

This book is sold subject to the condition that it shall not, by way of trade or otherwise, be lent, re-sold,
hired out or otherwise circulated without the publisher's prior consent in any form of binding or cover
other than that in which it is published and without a similar condition including this condition being
imposed on the subsequent purchaser

Please note:

All of the programs in this book have been thoroughly tested on a BBC Model B microcomputer fitted
with BASIC 2. Most programs will also work with the earlier BASIC l. If you are in doubt about the
version in your machine, please contact your local BBC Micro dealer.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm.htm (2 of 2)20/06/2012 08:45:54


BBC Micro Music Masterclass: Da Capo

BBC Micro Music Masterclass

Da Capo
Over the past few years computers have increasingly come to feature in the creation of pop music,
invading a new and exciting field of human creativity. Bands like Orchestral Manoeuvres In the Dark,
The Human League and Depeche Mode have spearheaded this development through the use of
synthesisers and drum machines. As a result, it has become acceptable for machines to play a major role
in the creation of the modern record.

Take, for example, the popularity of the MC-4 Microcomposer, much favoured by Yazoo, which makes
it unnecessary for a human being to lay even one finger on a musical instrument. This computer has
completely taken over the mechanical business of playing an instrument, so that all the individual
musician has to do is to provide the inspiration.

One of the most recent developments in the mastering and playing of instruments has been a trend away
from the traditional specialised musical tool altogether. In their place, standard microcomputers are
increasingly utilised both as composing aids and as sound producers in their own right The Fairlight
Computer Musical Instrument is a good example of the next generation of computers, which not only
have a range of excellent musical software, but can also be put to work as word processors or calculators.

As a result of observing these trends and changes, I decided that it was about time someone wrote a
book about the use of computers in music from a practical standpoint. It seemed only logical to base the
book around a computer with good musical potential, sophisticated sound generation and reasonably
straightforward interfacing capabilities. In addition, the computer needed to have a flexible and powerful
version of the BASIC language and be in widespread use. Bearing all these prerequisites in mind, I came
to the conclusion that the only possible candidate which satisfied the requirements was the BBC
Microcomputer.

Once the best model was identified all that remained was for someone to put pen to paper (or fingers to
word processor in my case). At this point it occurred to me that I was reasonably well qualified for the
job, since I am musician by profession. Having started my playing career as a saxophonist, in recent
years I have branched out into composing and keyboard programming. In the process of so doing, I
found myself entrusted wit the MC-4 programming on David Grant’s album, as well as creating drum
programming and supervising computer input on various records by Dee C. Lee, Steve Levine, SPK,
Beggars and Co and Miro Miroe.

My musical interests are wide ranging, embracing pop, jazz and classical and, apart from music, my
other endearing passion in life is computers, having started years ago on a Sinclair ZX81 and graduating
to a BBC Model B. The BBC’s versatile sound commands soon had me up to my ears in various

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_da_capo.htm (1 of 3)20/06/2012 08:45:55


BBC Micro Music Masterclass: Da Capo

programs, many of which you will come across in the course of working your way through this book.

As I have said, one of the strengths of the BBC Microcomputer is the range and versatility of its sound
commands. The SOUND command itself allows control over channel, pitch, volume and duration of
note, while the complex ENVELOPE command has parameters too numerous to mention in a short
introduction.

Nevertheless, there is a drawback to this very versatility since it is no simple matter to master the
necessary techniques to get the best out of your BBC. Lesser computers go for the option of pre-defined
scales and envelopes, which greatly facilitates mastering the superficial and limited uses of sound
however, it is worth aiming higher, since none of these machines come close to emulating the breadth of
application possible on the BBC.

This book sets out to bring that same breadth of application within the reach of every BBC owner, not
only by supplying you with self-contained and entertaining programs, but also by clarifying the ins and
outs of BBC BASIC’S SOUND and ENVELOPE statements, and indicating the multifarious uses to
which they can be applied.

The first three chapters are therefore devoted exclusively to the language of sound on the BBC: Chapter
One will explore the use of the SOUND command to play simple melodies and scales. Chapter Two
deals with the somewhat complicated ENVELOPE statement. By breaking this rather confusing
command into smaller, more manageable sections, its use and applications shine out much more clearly.
Chapter Three delves into channel zero, the noise channel. This essential feature is used to create sound
effects and percussive musical sounds.

Chapter Four contains more information about the SOUND and ENVELOPE statements and looks at
how the remaining sound channels can be synchronised together.

At this point in the book, before going too deeply into crotchets, quavers and cadenzas, it seemed a good
idea for us to go back to school in Chapter Five and learn a bit of music theory, so that all the potential
Mozarts and Liszts out there can get off on the right foot! A rudimentary knowledge of music will prove
tremendously valuable when we move on and look at auto-composition and harmonising melodies in
later chapters.

Chapter Six deals with the problem of multi-part music. A computer is very good at dealing with
sequential problems, however when a number of things happen simultaneously, as often happens in
music, we must provide the computer with a sensible way of dealing with the information.

Chapter Seven will give you some ideas on the various methods of displaying music. Although music
has a complex sign language of its own, microcomputers are ideally suited to embracing this language
and presenting it in an exciting new way.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_da_capo.htm (2 of 3)20/06/2012 08:45:55


BBC Micro Music Masterclass: Da Capo

Chapter Eight touches on the interesting field of automatic composition, Can computers really create
original, innovative music? You will be in a better position to judge the possibilities after RUNning the
programs contained in this chapter.

Chapter Nine is intended to give you still further ideas about applications of music and sound. The
programs in this chapter stand up by themselves, as well as illustrating methods and techniques which
are explored elsewhere in the book.

Chapter Ten is intended as an inspiration to anyone interested in modern electronic music. Most, if not
all, of the new modern instruments are built using the same microchip technology as that of the
computer and hence every computer, especially the adaptable BBC, has the potential to be transformed
into the equivalent of portions of the effective circuitries of instruments like the Fairlight CMI or the
Casio VL-Tone.

Chapter Eleven has been designed to give you a start in the interesting area of interfacing. Another of the
BBC’s strong points is the breadth of interfacing possibilities. We will look at a number of useful but
simple techniques, none of which require cartloads of additional hardware or, come to that, practical
electronic skill.

In the final chapter I turn to contemplating what we can expect in the future. The microcomputer is
coming to play a central part in the world of music just as it is infiltrating virtually every other field of
human activity. I see this as an exciting development which promises a new era of music just around the
corner...

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_da_capo.htm (3 of 3)20/06/2012 08:45:55


BBC Micro Music Masterclass: The SOUND Statement

BBC Micro Music Masterclass

1 The SOUND Statement


As I mentioned in the Introduction, the basic command used for producing any form of noise on the BBC is the SOUND command. In this chapter we will deal with the use of SOUND to produce music and, for simplicity's sake, we
will temporarily ignore the fact that SOUND can also produce white noise and chords, and concentrate solely on the monophonic (one note at a time) case.

The format of the SOUND statement is:

SOUND C,A,P,D

where

C is the channel number.


A is the amplitude (volume) of the note.
P is the pitch (frequency) of the note.
D is the duration (length) of the note.

The channel number c can take values from zero to three, but for the purposes of this chapter it will always be set to one. Channel one produces a square wave tone which can be heard by typing CTRL-G and holding both keys
depressed.

The amplitude parameter A can take values between -15 and 15 but, again for the purposes of this chapter, we need only concentrate on the range zero to -15, which produces a range from silent to loud.

P can take values from zero to 255 and each single value is equivalent to 1/8th of a tone in musical terminology. A semitone (the basic musical building block) would therefore equal an increment of four.

The final parameter, D, can take any value between 0 and 255. In this case each increment is equal to 1/20th of a second, so a value of 20 for D would give a note length of one second.

These cold facts do not provide us with an accurate reflection of the vast possibilities inherent in the SOUND command. To see where we could use this command we must first explore the individual parameters and relate them in
some way to everyday musical experience. Let us begin by looking at the effect of volume by trying the following short routine:

10 REM *** AMPLITUDE DEMO ***

20 FOR A=1 TO 15

30 SOUND 1, -A,53, 20

40 NEXT A

None of these volumes are exactly ear-splitting, but it is the range of dynamics available, rather than mere volume, that is important for most musical applications. We will, however, be looking at the potential for squeezing more
decibels out of the sound chip in a later chapter.

The range of frequencies available can be heard by RUNning the following:

10 REM *** PITCH DEMO ***

20 FOR P=0 TO 255

30 SOUND 1,-10,P,3

40 NEXT P

At this juncture you might think that, as music goes, this program is not exhilaratingly exciting, so bear in mind that its function is to illustrate the range of P! The value of P is obviously one of the more important parameters for
musical applications. Whoever designed the BBC Micro obviously knew this, because we can take the above program and simply change Line 20 to read:

20 FOR P= 0 TO 255 STEP 4


file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (1 of 23)20/06/2012 08:46:03
BBC Micro Music Masterclass: The SOUND Statement

We can now hear intervals that are more familiar to most of us: these are known as semitones. Moving on, and using RND(100)*4 to specify pitch, we can now persuade the BBC to compose rather erratic melodies:

10

20 REM *** RANDOM ***

40

50 REPEAT

60 P=RND (100)*4

90 SOUND 1, -10, P, 5

100 UNTIL P=999

Before we become totally involved in trying out and defining values for pitch, try RUNning the following routine which will give you an idea of duration:

10 REM *** DURATION DEMO ***

20 FOR D=1 TO 100

30 SOUND 1,-10,73,D

40 SOUND 1,0,0,D

50 NEXT D

Line 40 has been inserted to provide a period of silence between sounds. This is of equal duration to the sounds themselves. It should be noted at this point that setting the duration D equal to 255 will result in a note without end -
presumably a device only of interest to admirers of John Cage!

The pitch parameter

Let us now return to pitch and relate values of P to musical notes by looking at the table below.

Note Octave
Name 1 2 3 4 5 6 7
B 1 49 97 145 193 241
A# 0 45 93 141 189 237
A 41 89 137 185 233
G# 37 85 133 181 229
G 33 81 129 177 225
F# 29 77 125 173 221
F 25 73 121 169 217
E 21 69 117 165 213
D# 17 65 113 161 209
D 13 61 109 157 205 253
C# 9 57 105 153 201 249
C 5 53 101 149 197 245

The first column contains the notes listed as musical symbols. (Refer to Chapter Five for any problems you may have with musical terminology or notation.) The equivalent P values are listed in columns according to octave. These P
file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (2 of 23)20/06/2012 08:46:03
BBC Micro Music Masterclass: The SOUND Statement

values are simply an arbitrary choice made by the BBC’s programmer and therefore have no direct significance in themselves. Middle C has a value of 53 in this table and its actual measured frequency is 261.625Hz (cycles per
second).

Another point to note before we go much further is the accuracy of P. Up to values of one hundred, P is basically equivalent to text book frequencies. Beyond this, however, the pitch has a tendency to drift, a vagary shared with most
normal musical instruments. For most practical purposes this will not be a problem, so from now on let us give the tone generator the benefit of the doubt and treat it as if it has perfect pitch.

Scales

One of the fundamental building blocks of music is the scale. Many of you will either remember, or still be experiencing, singing Doh, Re, Mes ad infinitum at school or in an organised music class - which is simply the traditional and
rather crude method of instilling the Western harmonic scales into the brains of budding but reluctant Andre Previns. Using a computer is a much less painful method of learning scales and how they relate to Wham or the Eurythmics.
(In this chapter we are dealing with how music in the real world relates to SOUND as it is played by the BBC, so it will be necessary for me to assume a certain knowledge of music theory. If any of the concepts or terminology are
unfamiliar to you I strongly advise reading Chapter Five, Music Theory for Micros, before proceeding any further.)

The first scale we will look at is the scale of C major:

10 REM

20 REM *** Scale at C Major ***

30 REM

40 FOR N=1 TO 4

50 REPEAT

60 READ A

70 SOUND 1, – 10, A, 10

80 UNTIL A= 101

90 RESTORE

100 NEXT

110 DATA 53,61,69,73,81,89,97, 101

This program uses a DATA statement to store the actual P values required for the scale. This method of remembering a sequence of notes will come in very handy when we want to program tunes at a later stage. Another method of
playing the same scale is shown in the following program:

10 REM

20 REM *** SCALE-2 ***

30 REM

40 P=53

50 REPEAT

60 SOUND 1, -10, P, 10

70 READ increase

80 P=P+increase

90 UNTIL increase=0

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (3 of 23)20/06/2012 08:46:03


BBC Micro Music Masterclass: The SOUND Statement

100 DATA 8,8,4,8,8,8,4,0

In this example the DATA statement holds the increase in pitch. Using this method, you can change the key of the scale by the single expedient of changing P in Line 40. Thus for example:

If P =61 the scale would be D Major.


If P=77 the scale would be F# Major.

Let us now see this in practise and create a program which simulates violin practise in action:

10

20 REM *** Violin Practise ***

30

40 FOR p=53 TO 101 STEP 4

50 Pitch=P

60 REPEAT

70 SOUND 1, -10, Pitch, 10

80 READ increase

90 Pitch=Pitch+increase

100 UNTIL increase=0

110 RESTORE 130

l20 NEXT P

130 DATA 8,8,4,8,8,8,4,0

This program has a major advantage over real violin practise in that the computer never makes a mistake. Anyone who has ever been subjected to listening to an inexperienced violinist will greatly appreciate this advantage.

In practise, you will discover that the scale program which uses actual pitch values is the universally used method, for the simple reason that, in practise, working out the increase or decrease in value for melodies more complex than
steadily increasing scales becomes mind-bogglingly complex. Ease of use is a crucial criterion in all music programs since, ultimately, all the methods suggested in this book have been singled out to be used for creative ends. Bear in
mind that spontanteity is essential to composition, so we should also aim to program with this in mind as far as practicably possible.

The DATA used in the scale of C Major could easily be used to convert the computer into a simple musical keyboard. The following program allows you to play the notes of the C Major scale using keys 1 to 8.

10

20 REM *** KEYBOARD ***

30

40 DATA 53,61,69,73,81,89,97,101

50 DIM P(8)

60 FOR N=1 TO 8

70 READ P(N)

80 NEXT N
file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (4 of 23)20/06/2012 08:46:03
BBC Micro Music Masterclass: The SOUND Statement

90 P$=INKEY$(0)

100 IF P$="" THEN GOTO 90

110 SOUND 1,-15,P(VAL(P$)),2

120 GOTO 90

The DATA is first READ into the array P(s). The keyboard is then scanned for a key press using the INKEY$ statement in Line 90. Since the bracketed number is zero, the computer does not wait at Line 90 but immediately returns to
Line 100, which in turn sends the computer back to 90 if no key has been pressed. If a key press is detected the program jumps to Line 110 and a note that is equivalent to the value of the number pressed is played. For example; If 1 is
pressed then P(1)=53, therefore C is SOUNDed, and if 5 is pressed then P(5)=81, therefore G is SOUNDed.
This program could be extended to produce the full chromatic scale demonstrated earlier:

10

20 REM *** Chromatic Keyboard ***

30

40 K$="ZSXCFVGBNJMK,L./"

50 *FX11,1

60 *FX12,1

70 POTE$=GET$

80 REPEAT

90 P=INSTR(K$,POTE$)*4+37

100 SOUND 1,-10,P,-1

110 REPEAT

120 note$=INKEY$(2)

130 UNTIL note$<>POTE$

140 SOUND &11,0,0,0

150 IF note$="" THEN POTE$=GET$ ELSE POTE$=note$

160 UNTIL POTE$=" "

170 *FX12,0

180 END

This program uses the array K$ to store its key names. Line 90 then returns a value for P (pitch) by using the INSTR command to obtain the position of POTE$ in K$. This is then returned as a number from 1 to 16 (sixteen is the
number of elements in K$). P is then derived by multiplying by 4, and adding 37. Thus if C is pressed POTE$=C, the INSTR expression will return 4 (i.e. 4th in the array), and P will have the value of (4*4)+37=53 (Middle C).

The *FX commands are used to speed up the auto repeat. *FX 11,1 sets the delay before repeats start to 1/100 of a second. *FX 12,1 sets the repeat period to 1/100th of a second as well. Note that the space bar must be pressed to
END the program. If you ESCAPE from the program before Line 170 the new auto repeat values will stay in operation. This will make it very difficult to type any further program information. In Line 170 the statement *FX12,0
resets both the auto repeat and the auto repeat delay values to normal.

The chromatic scale program serves to illustrate the point that a typewriter keyboard is not the easiest musical device to play. Segovia is unlikely to ever trade in his guitar for a BBC and a copy of the above program! This is not to
file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (5 of 23)20/06/2012 08:46:03
BBC Micro Music Masterclass: The SOUND Statement

deny the fact that the computer does have a useful role to play in creating music. This is due to the computer’s unique memory and its capacity to repeat series of events accurately and consis-tently without feeling the human emotion
of boredom or exhibiting human fallibility. One obvious use for this talent is in controlling a sequencer.

The sequencer is a fairly recently developed phenomenon which was originally created for controlling analogue synthesisers. The first sequencers were clumsy modular machines. Each module was set to generate a particular voltage
and each voltage was triggered in sequence using a low frequency oscillator (LFO). These voltages were then fed into the synthesiser, which played notes related to the voltages at a speed controlled by the LFO.

Any system which consists of a number of identical modules which work in sequence is obviously very inefficient. It soon struck the designers that there should be some way of remembering the list of voltages so that only one
voltage generator would be required. After a period of tinkering and experimentation computer controlled sequencers were born. The logical extension of solely storing note values is to remember timings as well. Once both pitch and
note length are recorded the sequencer becomes a very flexible musical tool.

At present sequencers are enjoying great popularity amongst musicians of all persuasions. Depeche Mode, the Human League and Yazoo, to name but a few of the better known bands committed to sequences, would be completely
helpless in the studio without the assistance of such machines as the Roland MC-4 Microcomposer and the Fairlight CMI.

The above mentioned machines are not musical instruments in the standard sense of the word, but are in fact complete music compositional system. (For a fuller description of modern electronic instruments see Chapter Ten.) Both are
basically computers that have been programmed to control external synthesisers (in the case of the MC-4) or control and generate sampled sounds (in case of the Fairlight CMI). At present, then, these instruments represent the state of
the art of professional machines. Although it is beyond the scope of this book to break down and dissect their wide-ranging facilities, we will go a long way towards indicating both how this type of system works and the type of
software that makes it tick. The following program serves to illustrate the basic workings of a simple sequencer:

5 REM

6 REM *** SEQUENCE ***

7 REM

10 MODE6: VDU 19,0,4,0,0,0

20 DIM

30 CLS

35 REM Enter Pitch" A(N)

36 REM

40 FOR N=1 TO 8

50 INPUT "Enter Pitch" A(N)

60 SOUND 1,-10,A(N), 10

70 NEXT

75 REM Play Sequence

76 REM

60 FOR N=1 TO 8

90 SOUND 1,-10,A(N),10

100 NEXT N

The program first sets up the array A(8) to hold the pitch information. An INPUT statement then asks for pitches to be entered. When all eight pitches have been entered the sequence plays four times then stops.

"Sequence" has a number of obvious limitations. Pitches must be entered as P values (i.e. adding four for every semitone) so the note/pitch table has to be referred to constantly. In addition, exactly eight notes must be entered and no
variation in the tempo or the number of times the sequence is played is possible.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (6 of 23)20/06/2012 08:46:03


BBC Micro Music Masterclass: The SOUND Statement

These drawbacks make "Sequence" less than a powerful musical tool, but don’t lose heart or believe I’ve led you up a blind alley. By constantly refining this program as we learn more about the SOUND statement, we will eventually
end up with a considerably more flexible program.

Before going any further with the sequencer program let us take a further look at DATA statements as a way of storing musical information. The following examples take the ideas explored in the scale programs and apply them to
that well known Scandinavian melody ‘Hall of the Mountain King’.

10 REM

20 REM *** HALL ***

30 REM

40 REPEAT

50 READ P

60 IF P=0 THEN END

70 SOUND 1,-10,P,5

80 UNTIL FALSE

90

100 DATA 61,69,73,81,89,73,89,89,85,69,

85,85,81,65,81,81,61,69,73,81,89,73,89,

109,101,89,73,89,101,101,101,101,0

“Hall” uses the form of our first scale program but also incorporates a small amount of rhythmical variation by repeating DATA to produce a longer note. Using this method, one DATA entry must equal the shortest note in the place.
In this case one entry equals a quaver (1/8 note). The following diagram shows how the numbers in the DATA statement relate to conventional musical notation:

HALL OF THE MOUNTAIN KING

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (7 of 23)20/06/2012 08:46:03


BBC Micro Music Masterclass: The SOUND Statement

As you will note from the above, this second version is arrived at by recording the note differences. “Hall-2” not only repeats itself after each completed sequence but also changes key by one semitone.

10 REM

20 REM *** HALL-2 ***

30 REM

40 P=61

50 REPEAT

60 count=1

70 P=P+4

80 RESTORE 170

90 pitch=P

100 REPEAT

110 READ increase

120 count =count+1

130 pitch=pitch+increase

140 SOUND 1,-10,pitch,5

150 UNTIL count=32

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (8 of 23)20/06/2012 08:46:03


BBC Micro Music Masterclass: The SOUND Statement

160 UNTIL FALSE

170 DATA 0,8,4,8,8,-16, 16,0,-4,-16,16,

0,-4,-16, 16,0,-20,8,4,8,8,-16,16,20,-8, -12, -16, 16,12,0,0,0,1

The value of P, in Line 40, gives the starting note which, in this case, is D. Two REPEAT... UNTIL loops are used to cycle the program. On completion of each cycle a semitone increment of four is added to P (Line 70) which results
in a semitone shift. This program still uses multiple entry of P values to give rhythmical variation. There are more satisfactory ways of achieving this, one of which would be to record values for the duration parameter D as separate
items of DATA.

The duration parameter


It is obviously time to say that, in many forms of music, rhythm is as important a factor to consider as pitch. The duration parameter D is the key to providing our control of rhythm on the BBC. In reality, D actually dictates two
separate musical quantities, tempo and timing.

The tempo of a piece of music is defined as its speed in beats per minute. The length of one crotchet is equal to the length of one beat, so for a tempo of 120bpm we would hear 120 crotchets go by. Since o is given in 1/20ths of a
second the value for D for a crotchet at 120bpm would be given by:

120bpm=120/60 beats per second=2 bps.

As calculated earlier, D=20 gives a duration of 1 second, and therefore the value of D for one beat would equal 20/2=10. The general formula is D=20/Tempo/60, or D=1200/Tempo where Tempo is given in beats per minute.

At this juncture let me introduce a program called “Metronome”, an electronic metronome program with a difference. Instead of entering values for the tempo in beats per minute, you are asked to supply a value for D. Once the
metronome is running the tempo can be changed using the up- and down- cursor keys. This program illustrates the important point that, since only integer values of D can be entered and a value of 1 for D = 1/20th of a second at fast
tempos, only certain values for TEMPO are available.

This point can be further illustrated by looking at an example. If TEMPO is 120 the value of D is 10 (1200/120), whereas if TEMPO were 110, then D=1200/110=10.9 which is not an integer value and would be interpreted by the
SOUND statement as 10, rounding down.

10 MODE7

20 VDU23;8202;0;0;0;

30 PRINT TAB(5,4);CHR$(129);CHR$(141);"* * * ";CHR$(132);"METRONOME";CHR$(129); "* * * "

40 PRINT TAB(5,5);CHR$(129);CHR$(141);"* * * ";CHR$(132);"METRONOME";CHR$(129); "* * * "

50 PRINT TAB(7,13);CHR$(131);"TEMPO"; TAB(23,13);"Duration"

60 PRINT T4B(2,20);CHR$(134);"Press cursor up to increase TEMPO"

70 PRINT TAB(2,21);CHR$(134);"Press cursor down to decrease TEMPO"

80 PRINT TAB(2,22);CHR$(134);"Press cursor left to restart"

90 PRINT TAB(2,23);CHR$(134);"Press cursor right to END"

100 *FX4,1

110 ENVELOPE 1,1,0,0,0,0,0,0,126,-6,0,-4,120,0

120 REPEAT

130 INPUT TAB(8,8)"STARTING D VALUE",D

140 correct=D>0 AND D<255

150 IF NOT correct THEN PRINT TAB(25,8 );"?? try again"


file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (9 of 23)20/06/2012 08:46:03
BBC Micro Music Masterclass: The SOUND Statement

160 UNTIL correct

170 PRINT TAB(8,8)"

"

180 REPEAT

190 TEMPO=INT(1200/D)

200 PRINTTAB(9,15);TEMPO;"

";D;" "

210 SOUND 1,1,100,D

220 K=INKEY(0)

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (10 of 23)20/06/2012 08:46:03


BBC Micro Music Masterclass: The SOUND Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (11 of 23)20/06/2012 08:46:03


BBC Micro Music Masterclass: The SOUND Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (12 of 23)20/06/2012 08:46:03


BBC Micro Music Masterclass: The SOUND Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (13 of 23)20/06/2012 08:46:03


BBC Micro Music Masterclass: The SOUND Statement

“Amazing Grace” is in 3/4 time, that is to say three beats to the bar. A value of D equal to 12 for a one crotchet duration was chosen both because it seemed a reasonable tempo and also because this number is easily divided by three.
As a result, the crotchet triplets in the first bar have D values of 4.

AMAZING GRACE

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (14 of 23)20/06/2012 08:46:03


BBC Micro Music Masterclass: The SOUND Statement

At this juncture we could also incorporate variable durations into our sequencer program:

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (15 of 23)20/06/2012 08:46:03


BBC Micro Music Masterclass: The SOUND Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (16 of 23)20/06/2012 08:46:03


BBC Micro Music Masterclass: The SOUND Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (17 of 23)20/06/2012 08:46:03


BBC Micro Music Masterclass: The SOUND Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (18 of 23)20/06/2012 08:46:03


BBC Micro Music Masterclass: The SOUND Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (19 of 23)20/06/2012 08:46:03


BBC Micro Music Masterclass: The SOUND Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (20 of 23)20/06/2012 08:46:04


BBC Micro Music Masterclass: The SOUND Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (21 of 23)20/06/2012 08:46:04


BBC Micro Music Masterclass: The SOUND Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (22 of 23)20/06/2012 08:46:04


BBC Micro Music Masterclass: The SOUND Statement

“Ambulance” is an effect program which has been devised to simulate an ambulance passing. Not only does it include a volume change which alters by one during each step of the loops, this program also simulates a Doppler
frequency shift effect by changing pitch. As the ambulance approaches the siren both increase in volume and rises in pitch. Realistically enough, the sequence occurs in reverse when the vehicle ‘passes by’.

So far we have dealt with amplitudes in the range 0 to -15. Positive values for A call up ENVELOPES, which we will look at in detail in the following chapter. Fifteen such ENVELOPES are available to give the sound a rather more
interesting ‘shape’ than the on-off tones we have used up to this point.

During the course of this chapter we have dealt with the major uses of the SOUND statement in isolation. The SOUND statement generates Pitch, Duration and Amplitude. In combination, these parameters provide most of the INPUT
required to create music and produce certain types of sound effects.

People of refined sensibilities might well be disappointed that the actual sound produced by SOUND appears to be a rather flat, square wave note. Do not despair, for this note can be made to sound much more interesting by utilising
the second of the BBC’s Sound of Music commands: ENVELOPE! Undaunted, then, let us proceed to the next chapter...

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_01.htm (23 of 23)20/06/2012 08:46:04


BBC Micro Music Masterclass: The ENVELOPE Statement

BBC Micro Music Masterclass

2 The ENVELOPE Statement


It is worth noting at this point that different musical instruments obviously have very different sound qualities. A
flute has a pure, mellow sound and is generally played using continuous notes. A harpsichord on the other hand, is
said to have a more abrasive quality of sound and, by the very nature of its construction and capabilities, must be
played percussively.

Of course, the difference in sound mentioned above between these instruments is due not to one but to a number
of factors - the most significant of which concern their volume envelopes and the actual sound source. In the case
of the flute we are faced with what is almost a pure sine wave as a sound source, and an envelope which is in the
main generated and controlled by the player. In the case of a harpsichord, by contrast, we are encountering a
vibrating string capable of creating a rich and varied harmonic colour as a sound source, and a short envelope
which ‘rings’ if the sustain pedal is pressed. The diagrammatic version of this explanation should help you
appreciate what I’m talking about:

VOLUME ENVELOPES

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_02.htm (1 of 21)20/06/2012 08:46:17


BBC Micro Music Masterclass: The ENVELOPE Statement

SOUND WAVEFORMS

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_02.htm (2 of 21)20/06/2012 08:46:17


BBC Micro Music Masterclass: The ENVELOPE Statement

The sound chip in the BBC Micro uses an electronically generated square wave as a sound source. Harmonics can
be added to its basic sound by mixing together more than one channel, a topic with which we shall deal at a later
point in this text. The basic sound, however, will be electronic. Do not despair! The most important factor that
contributes to recognisability in most musical instruments is volume envelope. Thus, if we take the sound of a

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_02.htm (3 of 21)20/06/2012 08:46:17


BBC Micro Music Masterclass: The ENVELOPE Statement

clarinet and electronically give it a percussive envelope, the instruments sound is immediately transformed into
something which akin to a marimba. By embracing this approach we can use the BBC’s square wave and convert
it into a range of different-sounding instruments. ENVELOPE is the tool we will use to create these new sounds.

It needs to be emphasised that ENVELOPE actually does more than merely control the volume (amplitude)
envelope of a SOUND, for it also has a pitch envelope component. The sophistication of the ENVELOPE
statement means that a large number of parameters are required. This chapter will therefore set about explaining
these parameters and demonstrating their use in sound shaping.

The form of the ENVELOPE statement is as follows:

ENVELOPE n,s,Pi1,Pi2,Pi3,Pnl,Pn2,Pn3,AA,AD,AS,AR,ALA,ALD

where:

n is the envelope number

s is the length of each step in 1/100ths of a second

Pi1, Pi2 and Pi3 are the changes in pitch per step during sections 1, 2 and 3

Pnl, Pn2 and Pn3 are the number of steps in sections 1, 2 and 3 respectively

AA is the rate of change of amplitude during the attack phase

AD is the rate of change of amplitude during the decay phase

AS is the rate of change of amplitude during the sustain phase

AR is the rate of change of amplitude during the release phase

ALA is the target amplitude for the attack phase

ALD is the target amplitude for the decay phase

The ENVELOPE number n can take values from 1 to 16, and simply allows you to identify which ENVELOPE
you have defined. The SOUND statement’s A value then specifies which ENVELOPE is to be used, allowing you
to predefine up to sixteen ENVELOPEs and call them up simply by changing A. It should be noted, however, that
if the BASIC statement BPUT# is being used, the number of available ENVELOPEs is reduced to four.

Both the Amplitude and the Pitch ENVELOPEs are worked out in terms of steps, and s specifies the length of
time assigned to each step. This parameter has one other function, which is to either enable or disable the
ENVELOPE auto-repeat. For values of s up to 127, the ENVELOPE automatically repeats itself. Values of s over
127 disable this function. For example:
3=3/100ths of a second steps with repeat ENVELOPE
130= 127+ 3=3/100ths of a second steps with no repeats.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_02.htm (4 of 21)20/06/2012 08:46:17


BBC Micro Music Masterclass: The ENVELOPE Statement

The six parameters following s define the pitch envelope part of the ENVELOPE statement. The length of the
defined pitch envelope is com-pletely independent of the amplitude envelope, however no sound will be heard
unless a positive amplitude value is maintained.

Pi1, Pi2 and Pi3 can take values from -128 to 127. The ENVELOPE is divided into three regions and Pi1-3 control
the degree of pitch change in each of these regions. Pitch can either rise or fall, and this accounts for the option of
positive or negative values for Pi1-3. These values cannot be examined in isolation, but must also be related to the
number of steps in each region.

Pnl, Pn2 and Pn3 can have values from 0 to 255. These parameters control the number of steps over which the
specified pitch change will occur. This is best explained using the example below:

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_02.htm (5 of 21)20/06/2012 08:46:17


BBC Micro Music Masterclass: The ENVELOPE Statement

For the first region, let Pi1 equal 2 and Pnl equal 3. this would mean that for every step in region one the value of I
would change by 2. Since the length of region one, specified by Pnl, is three steps, P would change by a total of 6
over the complete section. For example: if v=53 initially then at the end of the first section (region one) I will have
the value 59. (See the diagram.)

If we decided that we wished the value of P to fall subsequent to this point, a negative value for Pi2 would be used.

If values are chosen such that Pi2 = -4 and Pn2 = 4 then the total pitch change over region two would be (-4 * 4)
giving us a change of -16. So at the end of the second section (region two) P will equal 59 - 16 = 43.

The length of time each section will take is derived by taking the Pn value and multiplying by the value of s. The
length of the complete ENVELOPE would then be given by the formula: (Pnl+Pn2+Pn3)*s. Thus, if in the above
example s=100 then the length of each step would be one second. (100 * 1/100secs.) Since Pnl=3 and Pn2=4, the
total envelope would hence take seven seconds to complete.

We should note at this point, however, that the duration of SOUND is also controlled by the o parameter in the
SOUND statement. If D is less than the total pitch envelope time then the envelope will be cut off. If D is

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_02.htm (6 of 21)20/06/2012 08:46:17


BBC Micro Music Masterclass: The ENVELOPE Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_02.htm (7 of 21)20/06/2012 08:46:17


BBC Micro Music Masterclass: The ENVELOPE Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_02.htm (8 of 21)20/06/2012 08:46:17


BBC Micro Music Masterclass: The ENVELOPE Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_02.htm (9 of 21)20/06/2012 08:46:17


BBC Micro Music Masterclass: The ENVELOPE Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_02.htm (10 of 21)20/06/2012 08:46:17


BBC Micro Music Masterclass: The ENVELOPE Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_02.htm (11 of 21)20/06/2012 08:46:17


BBC Micro Music Masterclass: The ENVELOPE Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_02.htm (12 of 21)20/06/2012 08:46:17


BBC Micro Music Masterclass: The ENVELOPE Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_02.htm (13 of 21)20/06/2012 08:46:17


BBC Micro Music Masterclass: The ENVELOPE Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_02.htm (14 of 21)20/06/2012 08:46:17


BBC Micro Music Masterclass: The ENVELOPE Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_02.htm (15 of 21)20/06/2012 08:46:17


BBC Micro Music Masterclass: The ENVELOPE Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_02.htm (16 of 21)20/06/2012 08:46:17


BBC Micro Music Masterclass: The ENVELOPE Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_02.htm (17 of 21)20/06/2012 08:46:17


BBC Micro Music Masterclass: The ENVELOPE Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_02.htm (18 of 21)20/06/2012 08:46:17


BBC Micro Music Masterclass: The ENVELOPE Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_02.htm (19 of 21)20/06/2012 08:46:17


BBC Micro Music Masterclass: The ENVELOPE Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_02.htm (20 of 21)20/06/2012 08:46:17


BBC Micro Music Masterclass: The ENVELOPE Statement

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_02.htm (21 of 21)20/06/2012 08:46:17


BBC Micro Music Masterclass: The Sound of Noise

BBC Micro Music Masterclass

3 The Sound of Noise


Up until now we have been dealing exclusively with channel one, which produces what should by now
be a familiar square wave tone. Both channel two and channel three produce identical sounds, and we
will soon turn to look at how chords and tunes with accompaniment can be produced. In this chapter,
however, we shall concentrate on the functions of channel zero, the noise channel.

Unlike the other channels, channel zero is incapable of producing melodies by varying the pitch
parameter. In the case of channel zero the pitch parameter has an entirely different effect, being used to
select one of eight possible noises. These can be described as in the table which follows:

0 High frequency sawtooth type tone

1 Medium frequency sawtooth type tone

2 Low frequency sawtooth type tone

3 Periodic noise of variable frequency

4 High frequency ‘white’ noise

5 Medium frequency ‘white’ noise

6 Low frequency ‘white’ noise

7 Random noise of variable frequency

Noises 0, 1 and 2 can be viewed as one group of noises. These are, in fact, strictly speaking tones rather
than noises and have musical pitches of C in three octaves. It is not possible to vary these pitches,
however, so you will find that the application of this group is to a large extent limited.

Noises 4, 5 and 6 make up another separate group, comprising three frequencies of white noise. The best
way to describe white noise is to think of the sound a transistor radio gives out when it is not tuned to a
station. White noise is versatile and has a whole range of applications, mostly in the sound effect area, as
we shall see later on.

The final group is made up of pitch values 3 and 7. These can be thought of as ‘pitched noises’. The
frequency of both these noises is directly related to the current frequency specified for channel one.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_03.htm (1 of 13)20/06/2012 08:46:19


BBC Micro Music Masterclass: The Sound of Noise

Thus, for example, if pitch of channel one equals 0 both 3 and 7 give out clicking noises. The clicks
from 3 appear regular, whereas 7 gives out random clicks which somewhat resemble the sound of a
geiger counter.

If the pitch of channel one equals 200, noise three gives out a definite pitched note, whereas 7 gives a
high-pitched white noise.

As practise clarifies matters much better than simply absorbing theory, of course, you ought to
experience these sounds for yourself by running the following program. The program has been derived
to play each noise in turn, as well as display its pitch value on the screen.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_03.htm (2 of 13)20/06/2012 08:46:19


BBC Micro Music Masterclass: The Sound of Noise

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_03.htm (3 of 13)20/06/2012 08:46:19


BBC Micro Music Masterclass: The Sound of Noise

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_03.htm (4 of 13)20/06/2012 08:46:19


BBC Micro Music Masterclass: The Sound of Noise

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_03.htm (5 of 13)20/06/2012 08:46:19


BBC Micro Music Masterclass: The Sound of Noise

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_03.htm (6 of 13)20/06/2012 08:46:19


BBC Micro Music Masterclass: The Sound of Noise

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_03.htm (7 of 13)20/06/2012 08:46:19


BBC Micro Music Masterclass: The Sound of Noise

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_03.htm (8 of 13)20/06/2012 08:46:19


BBC Micro Music Masterclass: The Sound of Noise

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_03.htm (9 of 13)20/06/2012 08:46:19


BBC Micro Music Masterclass: The Sound of Noise

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_03.htm (10 of 13)20/06/2012 08:46:19


BBC Micro Music Masterclass: The Sound of Noise

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_03.htm (11 of 13)20/06/2012 08:46:19


BBC Micro Music Masterclass: The Sound of Noise

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_03.htm (12 of 13)20/06/2012 08:46:19


BBC Micro Music Masterclass: The Sound of Noise

140 SOUND 2,3,80,2

150 SOUND 3, 4, 200, 1

160 UNTIL FALSE

In the previous example two sounds were played simultaneously simply by writing two SOUND
statements for different channels. This method of layering sounds is perfectly acceptable for a large
number of applications. Chords can be built up using this method, and providing only one chord is to be
played all the notes will be sounded at approximately the same time. If, however, a string of chords is to
be played or the sound is to be synchronised with graphics, another method must be found.

The BBC Micro comes to our aid at this juncture and supplies just such a method, which we shall look at
in the chapter which follows.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_03.htm (13 of 13)20/06/2012 08:46:19


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

BBC Micro Music Masterclass

4. More on SOUND and ENVELOPE


In this chapter we will expand our range of activities to include the remaining SOUND channels two and
three and then carry on to take a look at some further applications of ENVELOPE. It should come as no
surprise to you to discover that the use of two or more channels simultaneously brings a number of
problems in its stead. How do we go about synchronizing channels? Why is it that SOUND commands
apparently act out of sync with screen displays? Over the next few pages we will find an answer to these
questions and apply our new-found knowledge to programs such as a polyphonic organ, screen sync and
polyphonic melody playing. One of the first new concepts we need to examine at this juncture is the
SOUND queue.

THE SOUND Queue


Each SOUND channel has a small portion of memory set aside to store up to five SOUND statements.
This memory stores SOUND statements in a queue. the queue is a useful device which allows short
strings of SoUND state-ments to be executed without holding up a program for the duration of the
routine. To clarify this point let us look at the following program:

10 REM QUEUE

20 PRINT"C"

30 SOUND 1,-10,53,50

40 PRINT"E"

50 SOUND 1,-10,69,50

60 PRINT"6"

70 SOUND 1,-10,81,50

At first glance, you might think that when this program is RUN, C will be printed and simultaneously
played. Following this you might imagine that E will be printed and accompanied by E SOUNDing, and
finally G will appear on the screen at the same time as the sound G is heard.

In fact, this is not the way it happens at all, for C, E and G are PRINTed on the screen before the first
note has finished playing. Has the BBC gone loopy? Has it decided to read Lines 20, 40 and 60 before

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (1 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

going back for the SOUND commands? This apparent leaping around the program can be simply
explained with reference to the SOUND queue.

The machine in fact read and executed the program lines as normal. This is what happens: Line 20 is
read and executed immediately. C is PRINTed on the screen. Line 30 is read and executed immediately.
The note of pitch C is heard. At this point things do not go quite as expected. Instead of waiting for the
note to finish before proceeding, the computer now reads and executes line 40. As a result, E is printed
while c is still being heard. Line 50 is then read and the SOUND information for this line is stored in the
buffer memory for channel one. This allows the computer to proceed to Line 60, PRINT G and carry on
to the final Line, 70. Line 70’s SOUND information also goes into the buffer memory, coming after E in
the queue. At this point C E G is seen on the screen, while c is still being SOUNDed. Control of the
computer is returned to the user even though E and o are still to come. Since the BBC operates so
quickly the initial c notes has not yet ended and the computer continues to play all three notes in the
channel one SOUND queue, even though it is possible to type new information into the computer. Only
by pressing ESCAPE or BREAK will you find it possible to terminate the sound.

The SOUND queue comes in very handy when you want to play a quick fanfare, of the kind found in a
computer game, for example. Providing the number of notes in the fanfare does not exceed five, the
program will not be held up. When you come to read the ‘Applications’ chapter, you will see that a
number of examples of music which may be used in games are explored.

The program below “Queue 2”, will give you a clearer idea of how the queue works. As it is written
“Queue 2” PRINTs READING P% INTO Queue for values of P% from 1 to 6. Since there are then six
SOUND commands, one is played straight away and the remaining five are held in the queue, to be
played in turn. FINISHED is PRINTed immediately.

10 REM QUEUE

20 CLS

30 FOR P%=1 TO 6

40 SOUND 1,-l0, P%*24, 20

50 PRINT "READING "; P%;" INTO QUEUE"

60 NEXT

70 PRINT "FINISHED!!!"

If we try to add just one more SOUND statement to the queue the program as a whole is held up. Try
changing Line 30 to read:

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (2 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

FOR P%=1 TO 7

In this case we find that the ‘READING’ message for each value of P% up to 6

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (3 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (4 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (5 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (6 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (7 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (8 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (9 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (10 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (11 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (12 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (13 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (14 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (15 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (16 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (17 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (18 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (19 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (20 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (21 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (22 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: More on SOUND and ENVELOPE

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_04.htm (23 of 23)20/06/2012 08:46:22


BBC Micro Music Masterclass: Music Theory for Micros

BBC Micro Music Masterclass

5. Music Theory for Micros


If you stop to consider the matter you will realise that literally every subject of any complexity inevitably acquires its own specialist vocabulary. Music is no exception to this general rule for just as the pioneers discovered that it was
necessary to develop languages like BASIC and FORTH to facilitate the use and development of computer technology, so the world of music also has a special language all of its own. Since the scope of music only encompasses pitched
notes and rhythm, however, its structure is considerably simpler than that of any computer language. For this reason I believe that most newcomers to music theory who have had some general computer experience will pick up the
rudiments of music theory quite easily.

I have felt it necessary to digress somewhat and emphasize this point because of the experience of music teaching many of you will doubtlessly have had at school. For me, school music lessons comprised of note learning, primarily
concerned with absorbing key signatures, composers’ names and other pieces of musical gobbledygook. In this chapter I do not intend to bombard you with meaningless nmemonics designed to make it easier for you to remember the
notes of the treble clef. This type of knowledge can be acquired quite naturally through growing familiarity with music itself. Instead, I intend to provide you with a vocabulary which will allow you to understand the more musically
technical sections of this book and, show you how easy it is to use sheet music as reference material.

PITCH NOTATION
In order to make it possible for us to speak about individual note pitches we must first start off by giving each note a name. The accepted method for doing this is to call them after the letters in the alphabet between A and G. If you look
at a piano keyboard, you will see that the notes are found at the positions shown below:

On the BBC Micro we have pitch values such that the A note above Middle C=89, B=97, C=101, D=109, E=117, F=121, G=129 and, for the A note one octave above the first, A=137. As you can see, this method of notation has its
drawbacks. All the As, in whatever octave, have the same name. Bear in mind that a note which is one octave above another has double that note’s frequency.

A better method for illustrating pitch is to abandon numbers and letters altogether and draw them on a musical stave, as is illustrated below:

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_05.htm (1 of 18)20/06/2012 08:46:32


BBC Micro Music Masterclass: Music Theory for Micros

In this case there is no ambiguity in discriminating between notes of different octaves. In addition, the concept of higher notes being situated higher up the stave is both extremely helpful and logical. A stave is, of course, the name given
to the standard arrangement of five lines!

The symbol at the beginning of the stave is called a Treble Clef. This clef is used for the treble register of a piano and all instruments that play in that range, such as flutes, oboes, guitars etc. Bass instruments have their own clef,
unsurprisingly called the Bass Clef. This is used by instruments such as trombones, bassoons and double basses. It looks like this:

A piano covers such a large range that it uses both clefs, and we can correlate piano keyboard and notation as follows, with each white note having its own line or space. BBC Micro pitch values are shown also.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_05.htm (2 of 18)20/06/2012 08:46:32


BBC Micro Music Masterclass: Music Theory for Micros

The above diagram includes extra notes which are either a semitone higher (sharp) or lower (flat) to the white notes. The sharp sign is # and the flat sign . These are the black notes on the piano and make up the full complement of
twelve notes used in Western music.

It is worth pointing out at this juncture that the rules and notations described in this chapter apply only to Western music. If we were playing Indian music, for instance, a completely different set of rules would apply. This is analogous to
the use of different languages in computers for while the vocabulary itself might seem to be different, the general principles which apply are, of course, the same.

The only other area you need to know about before you are ready to read and write musical pitches concerns key signatures and keys. Different keys arise because of the particular tone intervals used in Western scales. An interval is the
pitch difference between any two notes. Turning back to the piano keyboard, you, will see that if you play two adjacent notes, ie.: C to C or E to F, the interval would be one semitone. This is the smallest interval possible in Western
music.

There are twelve semitones in every octave, but as most of you will know the scales normally used only use eight of these notes. For example, the scale of C Major comprises of the notes:

CDEFGABC

This is because the intervals between the notes of a Major scale always conform to a particular pattern:

Where a 2 indicates 2 semitones or one full tone difference and 1 shows a 1 semitone change between the notes. As you can probably guess, if you start your scale on a note other than C, say F#, it would be necessary to play some black
notes on the piano and include some sharps or flats in the notation of the scale.

Let us look at the scale of F#, which would be:

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_05.htm (3 of 18)20/06/2012 08:46:32


BBC Micro Music Masterclass: Music Theory for Micros

You have probably guessed that it would prove rather tedious writing sharps every time they occurred in F # Major so they are written on the stave just once, at the beginning of the piece of music to be played in that key, as follows:

This is called the key signature and each of the twelve possible scales (count them!) has its own unique signature.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_05.htm (4 of 18)20/06/2012 08:46:32


BBC Micro Music Masterclass: Music Theory for Micros

Should we need a note which is not to be played sharp or flat as required by the Key signature it has a natural sign, , placed before it. This effect lasts for a bar, and if the same note reverts to the key it requires a sharp or flat sign to
signify this.

You will no doubt be gratified to learn that you are now equipped with enough information to take a piece of sheet music and convert the musical notation into pitch information for the computer - and vice versa! Alternatively, you could
write a program to do the job for you, but you would be well advised to wait until you’ve availed yourself of the techniques still to come!

DURATION NOTATION

The use of the stave form of musical notation really comes into its own when dealing with durations. Various symbols are used to indicate the length of a note. These are as follows:

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_05.htm (5 of 18)20/06/2012 08:46:32


BBC Micro Music Masterclass: Music Theory for Micros

A dot after a note increases its value by half, so that is equivalent to

These note lengths are defined relative to each other, and are completely independent from the tempo or speed of the music, which defines the length of a bar (see below). Each note duration symbol has it equivalent note rest symbol,
which is used to mark the periods of silence which fall between notes:

It would of course be perfectly possible simply to string crotchets and quavers in a line across the page, with the only breaks in the line consequently being the ends of pages. This would, however, prove rather confusing, don’t you agree!
One better way of dealing with this problem would be to group them in easy-to-cope-with bundles, rather like stringing words together within a sentence. The musical name for one of these bundles is a Bar and the length of each bar is
file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_05.htm (6 of 18)20/06/2012 08:46:32
BBC Micro Music Masterclass: Music Theory for Micros

given by the time signature. The time signature is written at the beginning of a piece of music, directly after the key signature:

The upper figure is the number of beats per bar length and the lower figure gives the length of each beat. Hence 3/4 indicates three beats per bar with each beat a quarter note, i.e. a crotchet. 6/8 would indicate six beats per bar with each
beat an eighth note, i.e. six quavers per bar. The most common time signatures you will encounter are 4/4 (four crotchets per bar) and 3/4, waltz time.

All that now remains to be added to this body of information is the final piece which is required to define that rhythm of a tune. And that is the tempo. Tempo is normally given in terms of crotchets per minute. So =120 would mean
120 beats per minutes. If you look at classical music, you will notice that various Italian words are used to indicate the overall tempo of a piece. A selection of the commonly encountered terms are listed below.

Classical Tempo Terms

Adagio Slow, leisurely


Allegro Lively, reasonably fast
Andante Moderate pace
Grave Very slow
Largo Slow and stately
Lento Slowly
Presto Very quick
Prestissimo As fast as possible
Vivace Quick

When programming music on the BBC tempos can be converted into time values by using the updated Metronome program which follows below. You will notice that I use the words ‘time values’ and not ‘duration’ in this case. As I
mentioned earlier, this is because the duration parameter’s 1/20th of a second resolution is not great enough to provide for the full range of possible tempos. For instance, if a tempo of 120bpm is required, then there is no problem. That is
to say 120bpm=2bps or 10 (20/10) duration values for a crotchet. However, if, say, we wanted a tempo of 119bpm this would give 1.95bps or 20/1.95=10.256... duration values.

The BBC would round this non-integer value down to ten, which would produce a tempo of 120bpm just as before. The next slower usable tempo is 100, for a crotchet value of 12. Not only would this be true, but even at 120bpm quavers
are the shortest notes allowed. Semiquavers would give a D value of 2.5, which is also unacceptable. Refer to the table given on page 22.

Let us now get back to Metronome, shall we? The first thing we notice is that this means an alternative method for inputting timing must be found. One possible available method is to use the TIME variable. By controlling the length of a
REPEAT... UNTIL loop of the type:

TIME=0: REPEAT:UNTIL TIME < length%

we could resolve our timing down to around 1/100th of a second. It must be noted that for certain applications this is still not fine enough, however.

Another method would be to resort to a machine code routine. The simplest and most effective BASIC method available is to use a FOR... NEXT loop, however, as is done here:

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_05.htm (7 of 18)20/06/2012 08:46:32


BBC Micro Music Masterclass: Music Theory for Micros

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_05.htm (8 of 18)20/06/2012 08:46:32


BBC Micro Music Masterclass: Music Theory for Micros

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_05.htm (9 of 18)20/06/2012 08:46:32


BBC Micro Music Masterclass: Music Theory for Micros

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_05.htm (10 of 18)20/06/2012 08:46:32


BBC Micro Music Masterclass: Music Theory for Micros

the rest of this chapter I should like to turn to the consideration of some of the more useful musical ideas that have been developed over the past few hundred years. Let us start this quest by seeing how musicians gradually came to
assemble notes into scales and arpeggios.

SCALES AND ARPEGGIOS

As Western music gradually developed over the centuries it was found that of the twelve possible notes (including sharps and flats) some were used more than others. Initially this was because crumhorns, bagpipes and the like were only
capable of playing certain notes of the scales. It was left to Bach to devise a system whereby the scales of all the instruments played in his day were incorporated into one ‘even-tempered’ scale called the chromatic scales.

With the arrival of the chromatic scale any number of scales (sequences of notes) could henceforth be derived. The most common of these is the Major scale, as illustrated previously. The importance of the scale lies in establishing a note
priority. In the key of C Major any note from the scale will sound more ‘in tune’ than any note outside it. Older forms of music such as that popularized by Bach, as well as fledgling jazz, seldom if ever strayed to notes outside the scale
in use. More modern forms, such as bebop or music of composers like Bartok, on the other hand, positively revel in the use of ‘outside’ notes. Either way, it goes without saying that the scale is still an invaluable melodic framework.

Other scales commonly used in various forms of music are the Harmonic and Melodic Minor, the Natural Minor, Blues and the primitive Pentatonic. In addition to scales, a second level of note priority is provided by arpeggios, so let us
now turn to survey precisely what is meant by the term.

An arpeggio, in its basic form, is a broken chord made up of the 1st, 3rd and 5th notes of whatever scale happens to be in use. For instance, this sequence would make the arpeggio of C Major:

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_05.htm (11 of 18)20/06/2012 08:46:32


BBC Micro Music Masterclass: Music Theory for Micros

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_05.htm (12 of 18)20/06/2012 08:46:32


BBC Micro Music Masterclass: Music Theory for Micros

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_05.htm (13 of 18)20/06/2012 08:46:32


BBC Micro Music Masterclass: Music Theory for Micros

generating accompaniment by supplying notes which can be played simul-taneously with the melody notes. For an example, see the “Happy Birthday” program in the previous chapter. A chord sequence is the name given to the order in
which the chords are played underneath any given melody. Because of the importance of the chord sequence in defining a harmonic accompaniment a method of notating chords had to be developed over the centuries. The basic chord
symbol defines the note triad (three note chord) to be used. Look at the table below to see what I mean:

C... C,E,G 1st, 3rd and 5th notes of the C Major scale
A... A,C,E 1st, 3rd and 5th notes of the A Major scale
Dm... D,F,A 1st, 3rd and 5th notes of the D Minor scale

In these cases the lack of a subscript indicates a Major chord. A small m indicates a Minor chord. There are various other symbols which you also might come across, including Dim, which indicates the 1st, 3rd and 5th of a diminished
scale, and Aug, which indicates a Major chord with an augmented 5th note, i.e. the 5th is made a semitone sharper than it would be otherwise.

A number of additional notes can be added to the basic three-note chord if you wish to make 4,5 or even 6 note chords. Using the key of C, here are some examples:

Name Added Notes Notes Chord


MAJ7 7th note of Major scale CEGB CMAJ7
7 Minor 7th note CEGB C7
6 6th note of Major scale CEGA C6
9 9th+Minor 7th notes CEGB D C9
11 11th+9th+7 CEGB DF C11

These symbols are then written above the part of the melody to which they apply. This can be seen if you look at most sheet music, as well as examples scattered throughout the pages of this book.

You will doubtlessly remember me saying earlier on in the text that melodies suggest particular chord sequences; it is equally true to say that chord sequences also suggest certain melodies. Melodies could be generated by describing a
chord sequence and letting the computer generate rhythms and melodies. This can be accomplished using a constrained random numbers generator, the constraints, in their most basic form, being the harmonic considerations mentioned
above. Further constraints which would also need to be considered would include song or piece structure and rhythm.

MUSICAL STYLES

Rhythm, or lack of it, is very important in determining the impact of a particular piece of music. Most of the popular styles of music, such as pop, folk and jazz, embrace and are distinguished by their strong and distinctive rhythms. More
esoteric forms of classical music, however, are slightly less simple to pin down. We will therefore limit our discussion to general points of style and structure and go into more detail about specific areas in the chapter which concentrates
on pinning down and therefore explaining automatic composition.

Virtually every form of music you can think of relies on and uses a certain amount of repetition as a structural device. If you think of the popular children’s song, ‘Frere Jacques’, for example, you will see how this device makes it
possible to reinforce and emphasise themes by creating memorable refrains.

FRERE JACQUES
file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_05.htm (14 of 18)20/06/2012 08:46:32
BBC Micro Music Masterclass: Music Theory for Micros

You will notice that this melody has a total of eight bars. Each bar contains a distinct phrase, and these phrases appear in the pattern AA BB CC DD, i.e. the first bar is played, and is then repeated. a new phrase is introduced in the third
bar, then this is repeated - and so on.

While this may not be a particularly common type of structure, it does provide us with a very clear example, since each phrase is repeated exactly. It is, however, more common to have slightly different endings to each phrase.

The structures A A B A or sometimes A A B C are frequently encountered. The latter is a frequently used structure both in classical pieces and in popular songs. In this case, first the main theme is stated (this could be of any length and is
usually eight bars in the case of songs) and then the theme is repeated. Sometimes it incorporates a variant ending which leads the song into the new theme (or middle eight, in the case of song structure). At the end of the middle eight
either of two possibilities is open to the composer: In classical music, the most common option is the recapitulation of the original theme; in the case of the song either a recapitulation or the introduction of an ending-theme are equally
common.

One device commonly used in composing both folk and pop music is to include a verse of eight or sixteen bars followed by a chorus. The purpose of the verse is to relate the song’s narrative, and the chorus usually contains a simple,
memorable ‘hook’ line which the audience can easily remember. This type of structure can still be used even when no words are being sung. The following original piece employs the verse/chorus format:

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_05.htm (15 of 18)20/06/2012 08:46:32


BBC Micro Music Masterclass: Music Theory for Micros

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_05.htm (16 of 18)20/06/2012 08:46:32


BBC Micro Music Masterclass: Music Theory for Micros

Another common musical form is known as the twelve-bar blues. This form employs what could be described as an A A B structure. The main theme is played, then repeated, after which a concluding theme is played. In this example the
chords which are played are changed in a traditional sequence, as is illustrated below for the key of C:

C/// C/// C/// C///


file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_05.htm (17 of 18)20/06/2012 08:46:32
BBC Micro Music Masterclass: Music Theory for Micros

F/// F/// C/// C///


G/// F/// C/// C///

Let us leave this topic for the moment, since blues and various other types and styles of music can be explored in greater depth when we come to apply some of our new-found musical knowledge to programming and BBC Micro. In the
chapters which follow we shall also attempt to draw musical symbols and staves, generate random music in particular styles, interface the BBC with synthesisers and program from sheet music. Hopefully, on the basis of the expertise we
have so effortlessly accumulated in this chapter, none of these tasks will prove insurmountable, and all will enhance our musical enjoyment and output.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_05.htm (18 of 18)20/06/2012 08:46:32


BBC Micro Music Masterclass:Chords and Harmony

BBC Micro Music Masterclass

6 Chords and Harmony


As we saw when we tried to create a three-note organ on the BBC, polyphony presents special' problems
for the programmer and the musician. The techniques we use for single note situations do not always
transpose happily or smoothly into the multi-note case. Modifications are therefore essential. In this
chapter we shall look at the problems which need to be summoned when creating polyphonic pieces of
music.

If you think back to Chapter Four, you will remember that we dealt with a special case of polyphonic
playback. In the piece ‘Happy Birthday’ the entire tune was played in three-part harmony; this was only
possible because, rhythmically, each harmony part was identical. As soon as the harmony parts become
rhythmically independent we are immediately faced with a problem. This is best illustrated by looking at
the simplest possible example, a two-part melody.

TWO PART TUNE SYNCHRONISATION


If The BBC was endowed with infinitely long SOUND queues, synchronisation would be
straightforward. We would simply transfer our SOUND information into the channel one and channel
two buffers and, providing we had INPUT the durations for each part correctly, the two channels would
play back in perfect sync. However, since these queues are limited to five requests, if one channel is
made up of short duration statements and the other of long duration statements, a breakdown in sync will
eventually occur.

The program “Synchronisation Demo” illustrates this effect quite clearly. The program uses a pair of
two-dimensional arrays to store the Pitch and Duration DATA for channels one and two. This
information then feeds the SOUND statements in Line 120. Channel one is made up of long duration
notes and channel two of short duration notes. RUN the program and see what happens...

10

20 REM"SYNCHRONISATION DEMO

30

40 DIM Pitch%(2,20),Duration%(2,20)

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_06.htm (1 of 21)20/06/2012 08:46:45


BBC Micro Music Masterclass:Chords and Harmony

This program starts, as expected, with a long note on channel one synchronised with short notes on

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_06.htm (2 of 21)20/06/2012 08:46:45


BBC Micro Music Masterclass:Chords and Harmony

channel two. Four notes on channel two should be played for every note played on one. When the
second long note is played, however, channel two ties up and plays notes at the same time as each new
notes on one. The display will show each channel starting a note and putting five notes in each queue.
Since channel two is playing notes more frequently than one, by the end of the first note on one, four
SOUNDs have been played on two.

At this point one more SOUND is added to each queue, but note that channel two is continuing to use up
notes quicker than one. The SOUND statement in Line 120 controls how quickly new SOUND
statements are put on both queues. Since this is filling the buffers at the rate of the slowest duration, by
the end of the second note on channel one the channel two buffer is exhausted. From this point on, a new
SOUND is only added to the channel two queue at the same rate as to the queue on channel one. As a
result, channel one’s queue will always be full, and two’s will always be empty. This is why we get the
effect of both parts SOUNDing together, even though their durations are quite different.

One solution to this problem is to arrange for the channel two buffer to be topped up more frequently
than the channel one buffer. We could accomplish this in a number of ways.

Our first option is instead of having two separate DATA sources, to combine them into one. By
recording the channel number as well as its duration and pitch, only one SOUND statement would be
required. If you look back at the “Synchronisation Demo” example we met with earlier on, you will note
that we could then arrange for each channel one DATA item to be followed by four items of channel two
DATA. If we did this, the channel two buffer would never become exhausted, so synchronisation would
necessarily have to occur. This technique makes program writing simple, but arranging the music DATA
for a complicated piece tends to present horrendous difficulties. As a result the musical problems
involved make this method impractical.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_06.htm (3 of 21)20/06/2012 08:46:45


BBC Micro Music Masterclass:Chords and Harmony

The second option is to retain our separate DATA statements and com-bine the musical information
inside the program. One way of doing this would be to keep a record of the total duration played on each
channel. In the case of the “Synchronisation Demo”, if the total duration on channel one exceeds that of
channel two, channel two needs to be topped up. This technique can be thought of as something akin to
keeping a clock for each channel.

As each channel is SOUNDed the duration for that statement is added to the clock for that channel. At
any given time the channel with the clock reading the smallest value (channel two in the diagram) will
be SOUNDed. This would give a statement which looks like the following formula:

IF clockl > clock2 SOUND 2 ELSE SOUND 1

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_06.htm (4 of 21)20/06/2012 08:46:45


BBC Micro Music Masterclass:Chords and Harmony

or equally well...

IF clock2 > clockl SOUND 1 ELSE SOUND 2

We could incorporate this type of statement into our synchronisation demonstration as follows:

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_06.htm (5 of 21)20/06/2012 08:46:45


BBC Micro Music Masterclass:Chords and Harmony

This second demonstration RUNs in perfect sync throughout. A REPEAT... UNTIL loop is used in this
case because the two channels must be allowed to run independently of each other. Two step counting
variables, respectively A% and a%, are used to keep track of where we are at any given point in each of
the two channel arrays. These are set to one at Line 13 and are increased by one every time a SOUND is
inserted in a channel queue.

In this case, when the program first reaches Line 190 clock1 equals clock2. Channel two will therefore
be SOUNDed. We then have clocks equalling 5 and a% equal to 2. The program will then go round the
loop and the next visit to Line 190 will see clock2 > clock1 as a result of which channel one will be
SOUNDed. Since this loop is executed in a fraction of a second both channels one and two will appear
to be SOUNDing simultaneously. At this point clock1=20 and A%=2. On the third visit to line 190
clock2=5 and clock1=20, so clock2 < clockl and therefore channel two will add another SOUND to its
queue. Now clock2=10 and a%=3. On a fourth visit clock2=15 and a%=4. As you can see channel two is
filling its queue far more rapidly than channel one. Since it is also emptying its queue faster, the end

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_06.htm (6 of 21)20/06/2012 08:46:45


BBC Micro Music Masterclass:Chords and Harmony

result balances out at precisely what we want.

This approach will work for any set of two-part musical DATA, not merely for the example I have
chosen. As you can see, therefore, we do have a general method for writing two-part tunes which allows
the musical DATA for both parts to be listed separately. Over the rest of the chapter we will develop this
method further, in order to make it easy for us to cope with more complex musical examples. The first of
these is a melody with bass accompaniment, which includes rests and repetitions.

“Blood and Sand” is an original piece of music which has been written especially for this book by the
author. The two parts consist of a melody line and a bass part.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_06.htm (7 of 21)20/06/2012 08:46:45


BBC Micro Music Masterclass:Chords and Harmony

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_06.htm (8 of 21)20/06/2012 08:46:45


BBC Micro Music Masterclass:Chords and Harmony

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_06.htm (9 of 21)20/06/2012 08:46:45


BBC Micro Music Masterclass:Chords and Harmony

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_06.htm (10 of 21)20/06/2012 08:46:45


BBC Micro Music Masterclass:Chords and Harmony

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_06.htm (11 of 21)20/06/2012 08:46:45


BBC Micro Music Masterclass:Chords and Harmony

When the program is RUN you will notice a slight pause which occurs as the arrays load up before the
actual melody starts. In this piece we are being presented with an example which is similar to our Sync
Demo. Thus, you will notice that the bass part consistently plays more notes than the melody part. It
should be obvious to you by now that any attempt to relate the two parts when writing the DATA
statements would be next to impossible. The program falls into three parts; as follows.

1. Initialisation: ‘Blood and Sand’ is PRINTed on the screen using MODE 7 double height text. Both
clocks are set to zero and three ENVELOPE are defined. The first and second are for channels one and
two, while the third is a zero volume ENVELOPE called up for rests. When the pitch and duration
information is READ into the arrays, Pitch%(P%-1,C%)=0 is tested to indicate the end of DATA for
that channel when the condition is satisfied. This allows this program to be used for any set of two-part
DATA providing zeroes are placed at the end of each set of channel information. C% is the channel
number and Line 250 RESTOREs the program to the channel two set of DATA.

2. The Program: Line 300 sets the step counters to one. Lines 320 and 330 allow for rests in the music
by INPUTting -1 as the pitch DATA. If Pitch= -1 then the silent ENVELOPE 3 is called. The main part
of the program is in a slightly different form from that which we have already seen in the demo. Line

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_06.htm (12 of 21)20/06/2012 08:46:45


BBC Micro Music Masterclass:Chords and Harmony

340 synchronises the channels if their SOUND statements fall on the same beat, i.e. when clock1
=clock2. This move makes sure that the two parts start exactly at the same time and are periodically
pulled back into time. Even though the duration values of the sound generator are highly accurate, the
relative slowness of BASIC can sometimes cause a time delay to occur between the two parts. This line
ensures any delay which might be generated as a result of this flaw has no effect. Because of the
addition of this line it becomes necessary to split the clock comparison statement into two lines, 350 and
360. Overall, these three lines have the same effect as we have noted earlier on. The channel with the
smallest clock reading always SOUNDs. Line 370 tests for zeros in the DATA statements and, if found,
sends the program back to Line 300 where the step counters are reset, causing the tune to play from the
beginning. This program will REPEAT indefinitely and stay in perfect synchronisation.

3. The Music DATA: The DATA is written as BBC pitch and duration values, pitch followed by
duration followed by pitch and so on. There is no reason why any of the other available forms for
recording musical information, such as music nomenclature or symbols, MC-4 synthesiser code or a
form of your own devising, should not be used. Providing the translation of DATA into BBC BASIC is
carried out before being stored in the pitch and duration arrays, no slowing down of the program will
occur apart from the unavoidable pause as the arrays load, which we have already noted and considered.
It is a good idea to be systematic about the amount of information you put in each DATA statement. In
this example, two bars per statement seemed reasonable. A systematic approach also has the additional
benefit of making it fairly easy to trace back and eradicate the inevitable typing errors when you become
horrified to hear that the playback sounds like some form of avant garde jazz!

Now that we have successfully tackled two-part tune synchronisation we can try a similar technique on
three- and four-part works.

MULTIPLE PART TUNE SYNCHRONISATION


I have written another original piece as a demonstration of multiple part synchronisation. “Vermillion
Sands” has been composed as an electronic piece of music suitable for four voices. It comprises lead
part on channel one, bass on two, counter melody on three and snare drum on channel zero, the noise
channel.

10

20

30 REM" ***FOUR VOICE SYNC***

31

32 REM "*****VERMILLION SANDS*****

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_06.htm (13 of 21)20/06/2012 08:46:45


BBC Micro Music Masterclass:Chords and Harmony

41

42 REM" SET UP

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_06.htm (14 of 21)20/06/2012 08:46:45


BBC Micro Music Masterclass:Chords and Harmony

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_06.htm (15 of 21)20/06/2012 08:46:45


BBC Micro Music Masterclass:Chords and Harmony

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_06.htm (16 of 21)20/06/2012 08:46:45


BBC Micro Music Masterclass:Chords and Harmony

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_06.htm (17 of 21)20/06/2012 08:46:45


BBC Micro Music Masterclass:Chords and Harmony

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_06.htm (18 of 21)20/06/2012 08:46:45


BBC Micro Music Masterclass:Chords and Harmony

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_06.htm (19 of 21)20/06/2012 08:46:45


BBC Micro Music Masterclass:Chords and Harmony

4020 DATA 5,20,5,20,5,20,5,20,5,20,5,20,

5,20,5,20,4,20,4,20,4,20,4,20,4,20,4,20,

4,15,5,5,4,5,5,5

5000 DATA 0,0,0,0,0,0,0,0

The program will RUN, after a short pause, with a regular bass pattern and off-beat snare. The melody is
divided into verse, bridge and chorus, with the counter melody changing pattern during each section.
The entire piece REPEATS UNTIL the <ESCAPE> key is pressed. It works as follows.

1. Initialisation: This is done as we mentioned earlier on in the chapter but with a four-DIMensional
array and four ENVELOPE statements. The array loading section of the program has to be tackled in a
specific PROCedure which we look at in the following paragraph.

2. Load Arrays: First PROCinit is called from the main program and is fed a value from zero to four for
channel%. Line 360 RESTOREs the program to the correct set of DATA. The pitch and duration
information is then READ into the array and a zero value for pitch is tested for, as before, to indicate the
end of DATA.

3. The Program: In this example the program consists of PROCinit called four times, once for each of
the four sets of DATA, and PROCsync, which in turn calls PROCplay.

4. Synchronise Voices: PROCsync can logically be divided into two distinct parts. The first part uses the
extended SOUND statement’s s parameter to synchronise the start of the piece. If this part of the
program is omitted you will hear timing discrepancies between the four parts. Line 180 zeroes the
channel clocks and step numbers, both of which are held in arrays. This allows a general play procedure
to be created. The second part of PROCsync controls which channel will play at any given time. You
will notice that this step replaces the previously noted technique, the three lines we included for this
purpose in ‘Blood and Sand’. The channel clocks are then compared and the channel with the slowest
clock is passed to PROCplay. Line 260 allows the loop to REPEAT... UNTIL a value of zero is detected
for the expression Pitch%(1,N%(1) - 1). The piece is restarted when this is TRUE.

5. Play Channel: Line 290 increments the step number N% of the current channel by one and for the rest
of the PROCedure this is stored in the variable A%. Line 310 updates the channel clock. Line 320
selects the ENVELOPE to be used (ENVELOPE I for channel zero, ENVELOPE 2 for channel 1, etc.)

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_06.htm (20 of 21)20/06/2012 08:46:45


BBC Micro Music Masterclass:Chords and Harmony

or zero amplitude if a rest is detected (pitch= -1). Line 330 SOUNDs the channel.

6. The Pitch and Durations: These are BBC values which are arranged in two bar segments just as
before. Each set of DATA starts at a particular line number (1000 2000 3000 4000) in order to make the
RESTORE statement in Line 360 as general as possible. Note that using the RENUMBER command
will require Line 360 to be rewritten.

This program can be used for any set of four part DATA, though the note arrays may have to be
increased in size for particularly long pieces. (They can accept up to three hundred notes as the program
stands). Three or two part tunes can be INPUT by filling the channel three and four DATA statements
with rests or zeros. It should be noted that because the program only synchronises the voices using the s
parameter at the very start of the program, and not during REPEATs, the parts will eventually slip out of
time. This is a result of the time BASIC takes to process the various synchronisation and play
commands. This phenomenon should only become noticeable after four or five REPEATS.

There is yet another available alternative to the single DATA stream method of multi-channel sync. This
would involve dividing durations up into small increments which, at any given point in a tune, could
either be considered notes or rests. The channel synchronisation parameter could then be used to keep
each increment on each channel in step:

Using this method we could ensure absolute synchronisation of each channel at all times. This technique
is particularly useful when dealing with real time playing. If a melody is played in from the keyboard the
timing is automatically corrected to the nearest increment and stored in an array. This is equivalent to
the MC-4 type of programming. One example of this type of multi-channel synching can be seen in the
drum machine program presented in Chapter Nine: Applications. One or more of the drum channels
could be programmed to accept note information, as well as timing information, direct from the
keyboard. I will leave it up to you to experiment with the possibilities made available by this technique.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_06.htm (21 of 21)20/06/2012 08:46:45


BBC Micro Music Masterclass: Music Graphics

BBC Micro Music Masterclass

7. Music Graphics
Music incorporates a diverse range of signs and symbols and, unhelpfully enough, you will see that the way in which they are used is often incon-sistent with theoretically immutable rules. Using a
computer to display these sharps, flats, clefs and quavers brings with it a variety of problems which we will have to learn to overcome. In this chapter we shall meet these problems head-on and develop
the necessary techniques required to dismantle and solve them.

As is the case with many graphics applications there are two basic approaches to displaying music. The first is to use the PLOT, MOVE and DRAW commands to draw the symbols, etc., onto the graphics
screen. This method has the advantage of flexibility in terms of object size and the ease of drawing straight lines. The disadvantage of this method is that it is slow. The second approach lies in the use of
user-defined characters PRINTed on the graphics screen. This method is faster than the graphics technique and is very detailed; its main disadvantage centres on the size restrictions which are implicit in
its use.

In practice I have found that it is best to use a mixture of the two techniques, with DRAW to display the stave (and possibly the clefs), and employing user-defined characters to PRINT notes, sharps and
flats. Let us embark on this topic by taking a look at graphics techniques utilising MOVE and DRAW.

GRAPHICS METHODS
Before attempting to draw notes or clefs it is necessary to display the traditional group of five lines known as the stave. To do this we need to use the two graphics commands MOVE and DRAW.

MOVE moves the graphics cursor from the initial position to co-ordinates X, Y without drawing on the screen. The command takes the form: MOVE X, Y.

DRAW draws a line from the previous graphics cursor position to a new position given by the co-ordinates A, B. The command takes the form: DRAW A,B.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (1 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (2 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (3 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (4 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (5 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (6 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (7 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (8 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (9 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (10 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (11 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (12 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (13 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (14 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (15 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (16 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

design is completed pressing ‘Q’ causes the VDU 23 statement to be PRINTed. At this stage you may continue adding to the design, reset to a blank square (press ‘R’) or end the program (press ‘E’). It is
important to exit the program using ‘E’ rather than so that cursor editing can promptly be, restored using *FX 4,0. VDU 23 values and PRINTs them on the screen.

The program itself uses two VDU 23 statements. One is necessary to produce a blank square (all zeros) and one produces a completely filled square (all 255). The call *FX 4,1 in Line 80 turns off cursor
editing and allows the cursor keys to be used to control horizontal and vertical movement within the square. Lines 220 to 230 draw the red square. Lines 270 to 300 control position within the square and
create a boundary. Lines 310 and 320 cause either a filled or blank square to be PRINTed at position X,Y. This fact is then recorded as a 1 or zero in the array HEX%(I,S). Finally, PROChex works out the
VDU 23 values and PRINTs them on the screen.

Once a character has been created the next problem which presents itself is how to control its position on the screen. One useful aid to this end is the alternative graphics planning sheet explained on page
494 of the User Guide. This grid relates character positions to the graphics dimensions. A sensible arrangement for positioning the lines of the stave would be on five of the horizontal planning sheet lines.
This would correspond to one text character in height, or 32 graphics divisions apart, as we indeed did to draw staves earlier.

Once text characters for notes have been created their position on the stave can be controlled by adding 16 for the next note position

The following example uses the above techniques to draw a piano-type double stave on the screen. Notes can then be selected using the notes’ alphabetical name. (We could have equally well used a
keyboard arrange-ment for this purpose.) The octave of the note is controlled by pressing ‘O’. The sequence of notes can then be played back by pressing ‘P’.

10

20

30 REM"****WRITE****

40

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (17 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

50

60 VDU23,224,3,3,3,3,3,3,3,3

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (18 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (19 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (20 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (21 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (22 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (23 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (24 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

Lines 60 to 200 are devoted to defining the user-programmable characters. The two clefs and the crotchet shape are constructed in this way. In the set-up part of the program the VDU 28 command sets up
a text window to contain the octave and tempo information. The array P% contains Pitch DATA which is READ into the array at Line 380.

The main part of the program consists of a REPEAT... UNTIL loop containing a GET$ statement. The GET$ line waits for various INPUTS on which to act. “O” causes the O% variable to increase and so
changes the octave of the INPUT Pitch. “T” acts in the same way on tempo. The smaller the Tempo% variable the faster the tempo. “P” causes the program to go to PROCplay and play the notes INPUT
so far. If the INPUT does not consist of “O”, “T” or “P” the program compares the contents of A$ with the components of Note$, the alphabetical note names. If A$ is contained in Note$, a value of Note%
>0 will be returned and the program will exit the inside loop and go to PROCnote. This draws the note as a crotchet on the screen and records the pitch value in Pote%(100). The x co-ordinate screen
position is increased by 100 at Line 550 and end of screen is tested for in Line 560.

The PROClines routine draws the stave lines just as before, but incorporates a modification which makes it possible to draw a double stave. The lines then appear on the screen at Y co-ordinates 896, 864,
832, 800, 768 and 704, 672, 640, 608, 576. VDU 5 turns on PRINTing at the graphics cursor and VDU 4 turns it off. These commands have been included at the beginning and end of each PRocedure to
facilitate the use of the entire PROC in your own programs. GCOL 0,3 selects white as the colour of the lines.

PROCclef uses the user-defined character method of PRINTing the treble and bass clef symbols. The top left-hand point of the character is positioned at the cursor. The character therefore appears below
the line it is MOVEd to. GCOL 0,2 selects yellow.

PROCnewline is called up whenever the current stave is full. It simply erases the current screen and displays an empty stave in its place.

PROCNote converts the P% pitch and O% octave information into a note value Pote% which is stored in a 100 note array. T% is the number of pitches currently in the array.

PROCoct sets up the text display in the text window. COLOUR 1 selects red.

PROCplay plays all the notes currently stored in array Pote% at a tempo determined by Tempo%.

When PROCrite is called, this procedure draws a crotchet in yellow on the correct line or space of the stave. The lowest note possible in this program is F, on the space below the bass clef. This would
require the top left-hand corner of the crotchet ball to be placed on the bottom line, 576. The Note% value for F is 1. The octave O% value would be zero, so the Y co-ordinate value can be calculated as:

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (25 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (26 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (27 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

Island Logic for which I have been writing tunes.

My own solution to the expansion of ‘Write’ into a program of greater flexibility is given below. Digest, absorb and work with it, and then transpose it into your own ideal.

ADVANCED MUSIC WRITER

The Advanced Music Writer lets the user write melodies on the screen using standard musical nomenclature. Letter keys select the notes displayed and if an error is made it is a simple matter to delete the
mistake and try again. The filing system allows you to save your finished works on tape or disc and makes it possible to build a library of your favourite tunes or compositions.

On RUNning the program the screen display is as follows:

Octave: 0 :'O' Press 'S' for Sharp

Tempo : 4 :'T' Press 'D' to Delete

Duration: 4 'L' Press 'P’ to Play

'Z'..Transpose Press to Stop

To Reset 'R'...Read File

Press <BREAK> 'W' .. Write File

Current File: IRISH

Most of the extra facilities can be seen, displayed beneath the stave. Octave and Tempo values are changed in an identical fashion to the “Write” program. If ‘0’ is pressed the Octave value changes, in the
range 0 to 4, with zero being the lowest octave and 4 the highest.

Tempo has a larger range of possible values with 1 being the fastest tempo and larger values progressively slower. Duration is a new addition. This value allows you to change the length of note displayed
on the stave.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (28 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (29 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (30 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (31 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (32 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (33 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (34 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (35 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (36 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (37 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (38 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (39 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (40 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (41 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (42 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (43 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (44 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (45 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (46 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (47 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (48 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (49 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (50 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (51 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (52 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

The program uses PROCload and PROCplay from “Advanced Music Writer”. A small Menu program using a GETS statement is set up to allow the choice of reading a new file, playing the current file or
changing tempo. The program repeats melodies indefinitely or until <ESCAPE> is pressed to return control to the menu.

On RUNning you are immediately displayed the only page of the pro-gram. Your first action must be to press ‘R’, for Read, to load a file. Once loaded you may play it back by typing ‘P’ and stop the tune
file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (53 of 56)20/06/2012 08:46:51
BBC Micro Music Masterclass: Music Graphics

by pressing <ESCAPE>. The only other control is for varying the tempo, which is identical to that of the “Advanced Music Writer”.

Music graphics need not be entirely practical, of course. If you look forward to the interfacing chapter, you will see that I have included a program which draws graphs of sounds entering through the
Beeb’s analogue interface. The following program PRINTs coloured bars on the screen at a position related to the pitch of notes played on the keyboard.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (54 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (55 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Music Graphics

230 *FX 12,0

240 VDU4

250 PRINT "THE END"

This array, which should be familiar to you by now, is used to hold the active key information. In this example, the top two lines of letters correspond to the white and black notes. VDU 5 makes it
possible to PRINT at the text cursor and Lines 130 and 140 set the key auto repeat. Line 160 tests for a keypress using INKEY$(4) and this value is compared with P$ in Line 170. If a valid key has been
pressed a coloured bar is PLOTted on the screen at a Y co-ordinate position decided by N% and PROCNOTE is called with a positive value for N%. If there is no valid keypress nothing is drawn on the
screen and PROCNOTE is called with a zero value for N%.

PROCNOTE plays all three SOUND channels with a value of one for the flush parameter of the extended SOUND statement. This means that the queue for each channel is constantly being flushed. If N%
=0 then SOUND statements with zero amplitudes are called, which causes immediate silencing of the tone generators. If N%>0 the three tone generators play notes of a pitch calculated as N% * 4 + 28.
To exit the program <ESCAPE> can be pressed. This causes an error 17, which sends the program to Line 230. The keyboard auto-repeat is then set to default, normal cursor control is returned and the
program ends.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_07.htm (56 of 56)20/06/2012 08:46:51


BBC Micro Music Masterclass: Automatic Composition

BBC Micro Music Masterclass

8: Automatic Composition
One of the most interesting areas being developed in the field of computer music is called
autocomposition. As its name suggests, this technique involves allowing the computer to compose music
without the direct influence of a human being.

The crudest method of achieving autocomposition is simply to feed random numbers into the SOUND
statement as Pitch values. The following program is unlikely to enthral anyone who is not completely
tone deaf for longer than about fifteen seconds but ably illustrates the results of the above-mentioned
method:

10 REPEAT:Pitch=RND(64): SOUND 1,-15,Pitch*4,5:UNTIL0

One of the reasons why this type of ‘music’ is extremely unsatisfying to listen to is because it is virtually
structureless. Over the decades, human beings have come to expect certain musical guidelines to be
adhered to and while these guidelines vary from culture to culture their absence jars on the ears and the
brain. A Japanese audience, by contrast with their Western equivalent, can remain riveted to their futons
for hours on end listening to the musical structures which their ears have been trained to appreciate.
Outsiders, however, would find it difficult to stifle yawns before a few minutes were up! Of course, this
does not make the Japanese better or worse musicians than Westerners, but simply emphasises the fact
that their musical vocabulary is different to ours.

The BBC Microcomputer has no inherent musical vocabulary whatsoever. To persuade it to compose
sensible music we must first identify the basic principles involved in making music, then find a way of
inputting this information into the Beeb. It is not feasible to attempt to give the computer a general
musical education, for the simple reason that we would come up against memory constraints. Luckily
this is not necessary (or even desirable). Most human musicians are actually severely limited in the
range of music they can play and these limitations are much more severe than just a matter of
Norwegian musicians being unable to play Indian tunes and vice versa. Most Jazz musicians have little
experience of classical music and few classical musicians spend their leisure hours playing jazz.
Consequently, when we try to musically educate the BBC, we must try to follow the human example and
stick to a narrow stylistic vocabulary.

As I indicated in the Music Theory chapter over the centuries music has developed from being a matter
of simple modes and scales to the plethora of styles and techniques which we enjoy and appreciate
today. If you look around, you will notice that, of late, both jazz and classical music seem to have
removed all harmonic restrictions from the shoulders of the composer. For this reason, amongst others
the computer does not find it at all daunting to emulate modern avant garde styles!

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (1 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

...

In this program the random number generator is only restricted to values for Pitch within the BBC’s
range and Durations which are reasonably short. Lovers of Shoenberg and the like should find this
program extremely satisfying! In order to titillate the rest of us, I have also included a second avant
garde program. Avant Garde 2 restricts the pitch interval from one note to the next. This is accomplished
simply by introducing a variable P% which remembers the previous Pitch value. The REPEAT... UNTIL
loop at Line 35 then holds back Pitches which would precipitate too big a leap:

...

OK, I admit it. This is not a fantastic improvement on our first attempt. Nevertheless, the technique of
restricting intervals does make for more natural-sounding musical lines. You will doubtlessly be pleased
to hear that further progress towards harmony are still possible. By far the biggest step towards
aesthetically pleasing music is taken when we restrict the computer to scales. The next program sets up
an array P%(22) which contains notes of the C Major scale. Line 150 then randomly picks values from
the array.

10 REM"***MUSIC 1***

...

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (2 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (3 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

Note that in all the remaining programs in this chapter I have chosen a particular convention for
recording Pitch values. Since at no point will we be dealing with intervals which are smaller than a
semitone, I have made a semitone interval equal to 1 unit. Bearing in mind that this is the generally
accepted convention for synthesisers, I have used the following formula to convert to BBC nomenclature
from the absolute pitch values used by instruments such as the Roland MC -202 and the MC-4:

(Pitch*4)+5=BBC Pitch value

The table which follows accordingly gives the conversion from music symbols. You should quickly find
that you can remember all the value of the notes which we use frequently.

For example, the C Major scale becomes:

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (4 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

The “Music 1” program contains all the main components required for auto composition:

1. A note source, usually a DATA statement containing, in this case, three octaves of the C Major scale.

2. An array to hold this note information while the program is operating (in this example P%(22)). Since

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (5 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

each entry in the note source is numbered it is a simple matter to set up a random select routine which
picks notes from the array.

3. A random choice statement. In “Music 1” this takes the form:

Pitch% = P%(RND(21)+ 1)*4+ 5

Random values of P%(22) between 1 and 22 are chosen and converted to BBC Pitch values using the
formula as shown.

4. The pitch interval restriction is accomplished first by remembering the previous Pitch% in Line 190,
with P% =Pitch%. The value of P% is then compared with the new Pitch% in Line 160. If the difference
between the values (i.e. the size of interval) is greater than a set value (32 in this case, equalling 8
semitones) the loop is forced to REPEAT... UNTIL an acceptable value is generated.

Different intervals can be tried in order to hear their effect. Basically, the larger the interval the more
erratic the music. The smaller the interval the more predictable the sound. As is so frequently the case in
music, we are obliged to play off the twin evils of monotony and chaos...

The combination of restricted interval jumps and a scalar note source has given us harmonically
acceptable music (for the moment we will neglect timing). Nevertheless merely listening to all the
possible note combinations within a single Major scale eventually does get a little dull. The following
program accordingly improves on “Music 1” in two areas. It first introduces a further note priority
within the scale, and secondly a chord change is also introduced.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (6 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (7 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (8 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

The note source in this program has been modified to include the Major chord in addition to the Major
scale. This means that the notes C, E and G (0,4,7...) for C Major and G, B and D (2,7,11...) occur twice
in their respective arrays. This makes it twice as likely that a chord note will be randomly chosen. This
simple assumption is in fact, very effective in making the computer’s musical doodling more
reminiscent of a human-style effort at composition.

Note that one further interval restriction has also been added. If Pitch%=P% then a REPEAT is forced.
This stops the computer repeating the same note.

A chord change is introduced simply by setting up a two dimensional pitch array, P%(42,2) and
alternating between the two dimensions every eight notes. It should be noted that since the key of this
piece is C, I have used a mode of C Major as G scale information. As a general rule, the scale
information should remain fixed no matter what chords are being played. The exception to this rule
occurs when a key change occurs during a piece.

A key change was common to the ‘standard’ songs of the 40s and 50s but is less frequently encountered
when you look at contemporary pop and folk music. For this reason the computers improvisations are
more closely related to these simpler genres than the musically sophisticated standards of yesterday.

You might like to try substituting a G Major scale for the C mode as an experiment. As well as this, you
should try different scales and arpeg-gios as note sources. The listing below gives the DATA for
Pentatonic scales and Natural Minor scales, with arpeggios. Other possibilities include blues, diminished
and whole tone scales, and these scales are given here:

Scale Interval sequence

Major 8 8 4 8 8 8 4

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (9 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

Diminished 4 8 4 8 4 8 4 8

Blues 12 8 4 4 12 8

Hindu 8 8 4 8 4 8 8

Wholetone 8 8 8 8 8 8

Dorian Minor 8 4 8 8 8 4 8

Aeolian Minor 8 4 8 8 4 8 8

Harmonic Minor 8 4 8 8 4 12 4

Pentatonic 8 8 12 8 12

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (10 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

The music the computer is now composing closely follows many of the basic musical rules laid down by
J. S. Bach and his predecessors. It is solidly grounded in the notes of the relevant chord and also
employs scale notes to a lesser degree. No accidentals (sharp or flat) are used at all. It is, however, rather
difficult to assess how well the computer is sticking to the chord changes. To make this easier why don’t
you try the program “Bach 1”. This uses the same melody generation routine as “Music 2” but adds a
two note chord accompaniment.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (11 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (12 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (13 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

640

650 DATA 2,4,7,9, 11, 14, 16,


19,21,23,26,28,31,33,35,38,40,43,45,47,50,52,55,57,59,62

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (14 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

If we think of the melody line as a series of quavers (1/8th notes) then the chords only sound on the beat
(every 1/4 note). In point of fact, a chord SOUND statement is put in the queue each time a melody note
is played. This makes for easy SOUND synchronisation using the extended SOUND statement. The S
value is set at 2 (two statements on other channels must be collected before all three can SOUND
together), and the off beat rests are attained by using a silent volume ENVELOPE (ENVELOPE 3).

The loop Notes% is split in half and another loop C% is inserted. When C%=1 (an on beat) ENVELOPE
2 is selected and a chord is heard. When C%=2 (an off beat) ENVELOPE 3 is selected and no chord is
heard.

“Bach 1” also lets you select either a Pentatonic or a Major chord/scale note source. Note that as it
stands the program must be restarted to select the opposing set of DATA.

One possible extension of letting the computer compose melodies would be giving it control over
chords. In practice, this move generates very unsatisfactory music. This is because even though there are
a large number of possible sequences in theory, only a few are actually employed. A more constructive
improvement to the program would be to let the user INPUT his or her own sequence and have the
computer improvise variations over the changes. The next program allows you to do just that.

10

20

30 REM"***BACH 2 ***

40

50

60 REM"Set up and READ's DATA

70 REM" into the Arrays....

80

90 CLS

100 ENVELOPE 1,1,0,0,0,0,0,0,126,-1,0,-1,110,80

110 ENVELOPE 2,1,0,0,0,0,0,0, 100,-3,-20, -40, 90, 0

120 ENVELOPE 3,1,0,0,0,0,0,0,0,0,0,0,0,0

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (15 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

130 S%=42:DIM P%(S%,7),Chord%(2,7),SEQ%(8)

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (16 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (17 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (18 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (19 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (20 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (21 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (22 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (23 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (24 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (25 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (26 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Automatic Composition

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_08.htm (27 of 27)20/06/2012 08:46:55


BBC Micro Music Masterclass: Applications

BBC Micro Music Masterclass

9 Applications
In this chapter we shall explore some of the possible applications of our expertise with SOUND and
ENVELOPE. Many uses have already been covered in earlier chapters so in the following pages I shall
restrict myself to what can best be described as ‘more developed programs’ than those listed to date.

Apart from a few exceptions, the programs we have looked at up till now have been stripped down to
their basic components. For example, our use of graphics has been purely functional, and many routines
which would certainly have to be included in any program intended for serious applications have been
omitted. The main category of omissions in this area come under the general heading of ‘Idiot Trapping’
routines, routines which are intended to prevent a program crash when a wrong key is hit accidentally.

The programs which follow now are immune to all but the most determined ‘Idiot’ who is going to press
<BREAK> or <ESCAPE> come hell or high water! I could, of course, have disabled these keys too.
Programming the <BREAK> key to list the program is accomplished by the simple expedient:

*KEY 10 OLD M LIST M <RETURN>

We could equally well program the key to re-enter the program at the <BREAK> point. To disable the
<ESCAPE> key we use the *FX command *FX 229,1. To re-enable this key you only need to type *FX
229,0.

Nevertheless, all misgivings pushed aside, idiot trapping of this type has been left out - as a result the
programs are more easily keyed-in and do not become over-long.

The programs in this section are not arranged in any particular order so I would suggest that you look
through, and then start with whichever one most takes your fancy. The ‘Patriotic Program’ plays a
stirring three-part version of ‘Rule Britannia’ while hauling a Union Jack up and down a flag pole.
‘Clypso 2’ is an autocomposition program with, appropriately enough, a distinctly Caribbean feel. The
‘Chord Organ’ program is a short routine which lets you play three-note chords by pressing keys on the
keyboard. ‘Multi 1’ (courtesy of Igor Thomas), on the other hand, is a neat

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (1 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (2 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (3 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (4 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (5 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (6 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (7 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (8 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (9 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (10 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (11 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (12 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (13 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (14 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (15 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (16 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (17 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (18 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (19 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (20 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (21 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (22 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (23 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (24 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (25 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (26 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (27 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (28 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (29 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (30 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (31 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (32 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (33 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (34 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (35 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (36 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (37 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (38 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (39 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (40 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (41 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (42 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (43 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (44 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (45 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (46 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (47 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (48 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (49 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (50 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (51 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (52 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (53 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (54 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (55 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (56 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (57 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (58 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (59 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (60 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (61 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (62 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (63 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (64 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (65 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (66 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (67 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (68 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (69 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (70 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (71 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Applications

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_09.htm (72 of 72)20/06/2012 08:47:04


BBC Micro Music Masterclass: Computers in Modern Music

BBC Micro Music Masterclass

10 Computers in Modern Music


Until fairly recently, if you hoped to play music of reasonable standard, you had to resign yourself to
years of arduous practise on a saxophone, guitar or, worse still, violin. Ah, you may argue, surely this
wasn’t true of the new wave bands? Yes, even during the punk phase of pop music bands still had to get
together for hours on end, even if they were simply deciding in what order to play the songs at their next
gig. Computers have completely changed this state of affairs. Modern musicians now find themselves
able to create technically sophisticated music in their own bedrooms by using a bewildering array of
drum machines, synthesisers and sequencers that would put the BBC Radiophonic Workshop to shame.

All the above mentioned machines are basically microcomputers which are dedicated to the particular
task in hand, such as producing drum beats or digitally synthesising sounds. We can learn a great deal
about the best ways of programming sound on the BBC Micro from examining these devices, so in this
chapter I would like to describe how some of them operate.

Drum Machines
Computers are ideally suited to act as substitute drummers. They are accurate, unimaginative, stupid and
do not mind undertaking boring and repetitive tasks for hours on end. It is not surprising then, that when
computers began to infiltrate music one of the first tasks they were set was to act as a drum machine.

The original drum boxes that came attached to home organs contained a small selection of fairly
standard and uninteresting pre-programmed rhythms and sounds. This was obviously an unsatisfactory
state of affairs and everyone soon realised that it would be much better if a rhythm was programmed by
the musician to fit the particular tune being played at any given time. The problem with this scenario
was to make the programming simple enough for machine-shy musicians, a not inconsiderable
percentage of the music community both then and now. One of the first drum boxes devised to solve this
problem was called the Roland Dr Rhythm.

This machine was cheap and straightforward enough for even the most recalcitrant musician to feel at
home with and approach optimistically.

The sounds were produced by pre-set noise producing circuitry, but the small on-board computer
allowed almost limitless variations of rhythm to be tapped in by the user. On the Dr Rhythm each bar of
music is simply divided into sixteen subdivisions for 4/4 time or twelve subdivisions for 3/4 time. The
rhythm for each drum (bass drum, snare, sidestick and accent) is tapped in rather like sending morse
code, using one button for a drum hit and another for a rest. Once a bar of rhythm has been completed
for a particular drum it can then be checked against the inbuilt eighths or sixteenths hi-hat before

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_10.htm (1 of 10)20/06/2012 08:47:05


BBC Micro Music Masterclass: Computers in Modern Music

proceeding to another drum. The diagram below shows how we would produce a pattern of on beat brass
drum and off beat snare drum against hi-hat eigths:

This method of breaking down a bar into subdivisions is fundamental to all drum machine programming.
After the introduction and success of Dr Rhythm, drum boxes which incorporated larger memories and
more facilities soon became generally available. The Roland Drumatix and TR808 machines were
amongst the most popular and had a wider selection of drum sounds to their credit, as well as the ability
to chain together bar length patterns. This chaining technique allows complex drum parts to be
programmed, complete with fills, tempo and time changes.

However, looked at objectively, one sees that these machines are only superficially more sophisticated
than the Dr Rhythm. To gain a substantial improvement the number of subdivisions per bar must
increase. In the Dr Rhythm and its Soundmaster counterpart semiquavers are the shortest playable notes.
In 4/4 time it would thus not be possible to play triplets (16/3). This limitation could be overcome by
increasing the number of subdivisions to forty-eight per bar. A machine which could subdivide bars this
finely could not only play semiquavers (since a semiquaver is 1/16 of a bar, and therefore would equal
48/16=3 divisions) but also quaver triplets (quaver triplets occupy 1/12 of a bar and therefore would
occupy 48/12=4 divisions). The first machine to reach and make available this level of sophistication
was Roger Linn’s LM-1.

Digital Drum Computers


To call a Linn Drum (or the Oberheim, MXR, etc., counterpart) a drum box would be rather like
referring to a Stradivarius violin as a fiddle. We are in a completely new ball game here, for these
machines are very far removed from the more primitive devices we have been looking at to date. They

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_10.htm (2 of 10)20/06/2012 08:47:05


BBC Micro Music Masterclass: Computers in Modern Music

differ in two main areas. Firstly let us look at the sounds. Linn sounds are digital recordings of real
drums which are captured in Rows (Read Only Memory). D/A (Digital to Analogue) converters are then
used to turn this digital information back into noises.

Secondly, in the programming area, all these machines are capable of far more subdivisions per bar than,
say, the Tp808. In Linn terminology we talk about correcting to the nearest 1/16, 1/32 or 1/48th of a bar
or recording in real time. This is because all these computers have abandoned the morse code method of
the Dr Rhythm, for tap buttons which allow you to play the drum rhythms into the machine. Needless to
say, this gives a much more spontaneous feel to the music produced by this new and exciting generation
of machines.

In addition to pattern entry we are also able to choose a song mode which allows easy construction of
complex arrangements. As the sophistication and size of memory increases, so editing facilities also
have to be refined accordingly. All Digital Drum computers allow the deletion, insertion and copying of
both overall and individual drum patterns. At least half of the pop records which are currently being
aired on the radio are made by using computer drums of one kind or another. For a simple application of
some of these principles, see the ‘Drum Machine’ program in Chapter Nine.

Drum machines are by no means the only musical area into which computers are insinuating their
technology, merits and effects. In ten short years, for example synthesisers have changed from being
gangling giants which took up half a room to the sleek, keyboard size instruments which we now find in
virtually every well-equipped studio.

Monophonic Synthesisers
The early synthesiser developed by Robert Moog and used by Walter Carlos to produce his famous Bach
recordings looks quite unlike the instruments we see Depeche Mode and other contemporary bands play
today. This is because the original Moogs were built as a series of modules, connected together in
different ways to produce the various effects. These modules had the following functions:

VCO: the Voltage Controlled Oscillator produced the actual sound in the form of a sine, square (like the
BBC) or sawtooth wave.

VCF: the Voltage Controlled Filter alters the nature of the basic sound by filtering out certain
frequencies.

ENVELOPE: which acts in a similar way to the BBC’s volume envelope.

KEYBOARD: the keyboard in these early instrument had to provide two sets of voltages. The control
voltage (CV) controls the pitch of the note played by supplying set voltages to the VCO. A standard of
one volt per octave is now widely used such that a CV of one volt gives a pitch of C. The gate voltage
controls the duration for which the note is played. This voltage was normally zero for no note, and 2.5

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_10.htm (3 of 10)20/06/2012 08:47:05


BBC Micro Music Masterclass: Computers in Modern Music

volts or more for a keypress.

Of course, various other modules were often included, for instance to introduce vibrato into the sound
using a low frequency oscillator (LFO) output or to generate white noise, but the above VCO, VCF and
ENVELOPE generator are all that is needed, when amplified, to produce the familiar synthesiser sound
we have come to know and love.

Voltage Voltage Voltage Controlled Controlled Controlled Oscillator Filter Amplifier OUTPUT

Envelope Shaper
A modern synthesiser still includes the traditional components but instead of connecting together these
elements with patch leads, a microprocessor is used to achieve the same effect. This computer’s function
varies according to the machine. Thus, it can merely be used to connect the keyboard to the various
modules, as in the case of monophonic synths, such as the Sequent-ial Circuits PRO ONE or the Roland
SH-101, or it can be utilised to memorise entire sets of control settings, as with the polyphonic
Oberheim OB8 and Roland Jupiter 8 machines.

In Britain, a cheap but impressive-sounding synth called the Wasp was the first computer-controlled
instrument to become widely used in the music business. Like the more modern SH-101 and the Pro
One, this synthesiser employs a microprocessor to interface the piano keyboard with the analogue
oscillators and filters. Opposite, courtesy of the manufacturers, is a block diagram of the Roland SH –
101 elements to illustrate the current state of the art.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_10.htm (4 of 10)20/06/2012 08:47:05


BBC Micro Music Masterclass: Computers in Modern Music

POLYPHONIC SYNTHESISERS
A polyphonic synth is simply the amalgam of a number of monophonic synths which are put in the same
box and controlled by the same keyboard (five in the case of Prophet, eight in the case of Jupiter). These
added voices create extra work for the computer, however, in more ways than one!

First of all, the computer has to convert up to eight keypresses into control codes in order to be able to
define pitches for the VCOs. Then it has to decide which VCO will generate which note. Finally, just as
before, it has to send gate information to the relevant envelope generator. This can prove quite a problem
when the player could be anyone from Semprini to my tone-deaf cat running up and down the keys! If
you turn to look at the organ program in the previous chapter you will find a scaled down solution to this
problem.

In the process of developing better and faster synthesisers it soon occurred to the manufacturers that
since a computer was needed on board anyway, it might as well be used to its full capacity. Soon
afterwards the programmable polysynth was born. One immediate benefit was that instead of having to
keep drawings of control knob settings to hand to reproduce your favourite sound, it now became

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_10.htm (5 of 10)20/06/2012 08:47:05


BBC Micro Music Masterclass: Computers in Modern Music

available at the Hick of a switch. This is because, after a sound is set up on a programmable synth, the
knob settings are stored in the computer memory. The sound is also assigned a number, and whenever
the number is typed in, the sound is called up.

This development changed the face of music. Previously, in order to fully exploit the possibilities
introduced by the synthesiser musicians also had to have a boffin like mentality. The patch leads and
bewildering array of knobs and switches put many a potential synthesist off the whole idea of tackling
this promising but daunting hardware. Now that sounds are available simply by pressing a button, all
that twiddling and tweaking can be done in the privacy of your own home, thus, saving hours of
valuable studio time (and a lot of red faces at concerts).

SEQUENCERS
One logical extension of using a computer to create rhythms is to get it to play melodies. A machine that
does precisely this job is known as a sequencer. A sequencer, therefore, is any device which is used for
the automatic control of an external sound synthesiser.

Sequencers originally functioned entirely without the use of computer technology, for they were simply
a series of modules which could be set to particular voltages and were then triggered sequentially. These
voltages caused the external synthesiser to play a sequence of notes. Since such a repetitive task is
ideally suited to computers, this old-fashioned analogue

method of sequencing was quickly abandoned in favour of digital technology.

Simple sequencers capable of recalling up to one hundred steps are now built into modern synthesisers
as a standard facility. The Roland SH 101 and the PRO ONE can both be interfaced with a drum box,
which makes it possible for the sequence stepping to be synchronised with the drum machine’s tempo. If
you hunt out some of their records and listen to them bearing this in mind you will soon realise that this
type of mechanical sequencing is used extensively by Georgio Moroder and Kraftwerk.

More sophisticated sequencers such as the Roland MC-4 and the Oberheim DSX allow many channels
of music to be recorded along with phrasing and dynamics. These machines have developed from the
single channel one hundred note sequencers in the same way that the Linn Drum developed out of the
early rhythm boxes. By recording the sequence using increasingly smaller and smaller time intervals,
you arrive at an effect which precisely mirrors real time playing.

The MC-4 Microcomposer, for example, is a music-dedicated 48k microcomputer. Musical information
is entered into the computer using a combination of the function keys and a numeric keypad. To input a
melody three types of information must be entered:

1. Pitch: A 125 note chromatic scale is numbered as follows:

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_10.htm (6 of 10)20/06/2012 08:47:05


BBC Micro Music Masterclass: Computers in Modern Music

12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 C C# D D# E F F# G G# A A# B C C# D D#

To enter pitches the edit mode is selected and the chromatic pitch values (CV’s) typed in sequence. A
bar structure can be set up at this stage by pressing the <<>MEASURE END<>> key whenever a barline
is required.

2.Step: The step time is defined as the number of steps from the start of one note to the start of the next
in the sequence. Suppose, for example, we decided to define a bar of 4/4 as 192 steps:

Note Value Step Time

semibreve 1 192

minim 1/2 96

crotchet 1/4 48

quaver 1/8 24

semiquaver 1/16 12

This high number of subdivisions per bar is chosen because the larger this figure the more subtle the
phrasing that results when we input the final set of information.

3. Gate: The gate value defines the phrasing of the notes and can be any number from zero to the step
time. For example it the gate value equals the step then legato phrasing results. If the gate value is less
than the step then stacatto phrasing results. A zero value for gate produces a rest. The following musical
example should make the functions of Pitch, Step and Gate clearer. CV’s for Pitch are entered as above.
The Step time is the entire length from the start of one note to the start of the next, and the two quavers
hence have a quaver rest added (24+24=48). The Gate time input then gives the phrasing of the music:

Time Base = 48

Pitch (CV): 21 23 24 26 21

Step: 72 24 48 48 192

Gate: 70 20 24 24 144

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_10.htm (7 of 10)20/06/2012 08:47:05


BBC Micro Music Masterclass: Computers in Modern Music

Measure End

The MC-4 has four channels each with two pitches, one step and one gate. As a result, it becomes
possible for the musician to compose harmonically complex music. In practise, this would be next to
impossible, were it not for the sophisticated editing commands. Any part of a piece can be deleted,
copied, transposed or inserted by means of a fairly straight-forward command syntax. For instance, if we
wished to copy bars 1 to 16 at the end of a 32 bar tune the following syntax would be used:

COPY 1,16,1 <>>;ENTER<>>;

The cursor is set at bar 33 (the end of bar 32), the COPY key is pressed followed by 1(bar 1 start), 16
(bar16 finish), 1 (one time), and .

This refined form of sequencing is a long way from the haphazard analogue approach and would be
totally impossible to achieve without a micro - and a very clever piece of software.

DIGITAL SYNTHESISERS

This latest giant leap in synth technology has seen the computer take over the production of certain
forms of musical composition almost entirely. Not content with just controlling and storing sounds,
some ambitious microchip decided it should get in on the act and generate the sounds as well!
Instruments such as the Yamaha DX7 and the PPG Wave 2.2 are simply microcomputers disguised as
keyboards.

Wave shapes are generated digitally rather than using simple sine or square wave oscillators. These
waves are processed and shaped inside the computer and finally appear as analogue sounds, courtesy of
a D/A converter. The most sophisticated electronic instrument available to date belongs to this class of
digital synthesisers and is called the Fairlight CMI. Unlike the instruments described so far, the Fairlight
makes no pretense of being anything other than a computer. The alphanumeric keyboard, twin disc
drives and VDU are enough to send the average musician screaming from the studio. Music makers such
as Vince from the Assembly (ne Yazoo), Depeche Mode and the world famous producer Steve Levine,
on the other hand, have taken to the revolutionary new instrument like the proverbial duck to water.

The Fairlight can best be described as a complete music production system in one box. It can either
generate sounds itself, from digitally produced sine and square waves, or sample noises from the real
world, create a scale of similar sounds and play them back. Once in the computer, the sound waveforms
can also be displayed on the VDU and directly modified to create startling new effects. Once the sound
has been chosen it can be played manually on a piano keyboard (with eight note polyphony) or
programmmed, using a variety of compositional languages. Using any one of these languages, the
Fairlight can play up to eight different sounds at the same time to create complex arrangements which
were previously only made possible by using a large group of highly trained musicians.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_10.htm (8 of 10)20/06/2012 08:47:05


BBC Micro Music Masterclass: Computers in Modern Music

Because the Fairlight is a software-based instrument it is much less prone to obsolescence than its more
traditional counterpart such as the Wave 2.2. Since its inception many modifications have been made in
order to improve its sampling and refine the programming languages.

For those of you who are as yet unfamiliar with the concept of sampling I should insert a short
explanation of the term at this point in the text. Sound sampling involves digitally recording a natural
sound into a computer memory. Basically, the amplitude of the wave shape of the sound is measured
against time and then this information is recorded (as a series of numbers) by the computer.

AMPLITUDE AMPLITUDE VALUES

SOUNDWAVE TIME SAMPLING TIME SEQUENCE

The quality of the sample is dependent on the frequency with which the sampling takes place. The
Fairlight samples at a maximum frequency of 30000Hz (30000 samples per second). Once in the
computer, the sound can be displayed and changed using a light pen or numerical input.

Vibrato, filtering and tuning changes can all be made simply by using the correct commands. Since the
facilities of the CMI are so wide ranging each area is designated as a separate ‘page’. These are as
follows:

Page No. Title Functions

1 INDEX Self explanatory

2 DISK CONTROL Loading/saving files and programs

3 KEYBOARD CONTROL Tuning, polyphony, scaling, instrument files

4 HARMONIC Graphs, looping

ENVELOPES

5 WAVEFORM Additive synthesis

GENERATION

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_10.htm (9 of 10)20/06/2012 08:47:05


BBC Micro Music Masterclass: Computers in Modern Music

6 WAVEFORM Light pen, merging, display

DRAWING

7 CONTROL Key velocity, portamento, vibrato

PARAMETERS

8 SAMPLING Rates, filtering

9 SEQUENCER Basic sequencing

D WAVEFORM DISPLAY Display

L LIBRARY Disk library, files

C MCL Music Composition language

R PAGER Rhythm sequencer

From a brief survey of the above; you have doubtlessly realised that it is beyond the scope of this book
to go into detail about the Fairlight or any of the other instruments mentioned in this chapter. However
they have provided the inspiration for many of the programs contained in this book and, hopefully,
knowing something about them will provide you with a few ideas of your own for further
experimentation.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_10.htm (10 of 10)20/06/2012 08:47:05


BBC Micro Music Masterclass: Interfacing and Peripherals

BBC Micro Music Masterclass

11 Interfacing and Peripherals


The musical interfacing potential of the BBC is so great that it well deserves a book devoted entirely to the topic.
The user port, the one megahertz bus and the printer port can all accept and transmit digital information which
can in turn be used to control synthesisers, Digital to Analogue and Analogue to Digital converters, relays and
any number of similar devices. The on-board Analogue to Digital port can also accept analogue voltage
information, such as that generated by a synthesiser or a tape recorder. It is beyond the scope of this book to go
into the details of the design and construction of the sort of interfaces which would, for instance, allow the BBC
to generate the voltages required to drive a synthesiser, or sample frequencies via a fast A/D converter. Other
books and magazines can supply this information, a partial list of which can be found in the appendix. There are,
however, a number of straightforward add-ons we can use or construct without embarking on a university
electronics course. So let us begin by taking a look at the first of these, namely the common or garden joystick.

Joysticks
The humble joystick can be put to a number of other uses apart from the traditional and well documented one of
controlling laser cannons or manoeuvring Pacmen. Before we come to use the stick to control elements of a
program, however, we should start by RUNning the following test program.

10

20 REM *** Stick Test ***

30

40 MODE 7

50 VDU23;8202;0;0;0;

60

70 REPEAT

80 X%=ADVAL1DIV1024

90 Y%=ADVAL2DIV1024

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (1 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (2 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (3 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (4 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (5 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (6 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (7 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

The variable attenuator (resistor) controlling ADVAL2 should be adjusted to give a zero reading when no key is
pressed, and a reading greater than 10 when a key is being pressed. The attenuator for ADVAL1 should be
adjusted to read multiples of 12 when the key ‘C’ is pressed. Test this over the complete extent of the range
(including using octave controls if any). The lowest C on the keyboard should read 12. ADVAL1 is now reading
control voltages and ADVAL2 gates from the synth. It should be possible to play the keyboard and hear the
computer produce the correct notes.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (8 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

The main part of the program lies in Line 160. If a positive gate (Y% value from ADVAL2) is detected it will
SOUND a note and PRINT a value proportional to the control voltage (ADVAL1). If no gate is detected it will
shut off the SOUND.

Assuming everything appears to be working hunky dory with your system so far, we can now all move on to the
next program, “Keyboard Recognition”. This program could be used as the starting point for a series of music
tuition programs revolving around the piano keyboard. With this version the computer displays a note on a treble
clef stave and then waits until the correct piano key is pressed. The number of tries is then displayed,
accompanied by a suitable comment and the note SOUNDing. The process is then repeated until, hopefully, the
pupil gains a thorough knowledge of the keyboard. Brief instructions are displayed as an option when the
program is RUN.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (9 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (10 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (11 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (12 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (13 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (14 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (15 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (16 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

The program is made up of a number of PROCedures, most of which you will notice are devoted to graphics.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (17 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

Many of these will be familiar to you by this point from the graphics discussion of Chapter Seven.

1. Set Up: The instruction option is offered in Lines 130 to 160. Array b%(21,3) is used to relate the stave
position with note numbers and symbols. CHR$(225) is defined as the note ball and CHR$(224) as half of a
sharp symbol.

2. The Program: The main part of the program consists of calling up the various PROCedures inside a
REPEAT... UNTIL loop.

3. PROCLEF: As you may have come to expect from what we have discussed so far in this book, PROCLEF
DRAW s a treble clef and five lines using MOVE and DRAW commands, rather than defined text characters.
This technique is described fully in the earlier chapter which deals with graphics.

4. PROCchoose. Once the clef and stave have been drawn a note is chosen randomly by PROCchoose. Line 940
makes sure that the new note chosen is different to the previous note. Line 950 gives the vertical position of the
note (Z%) by relating the random number R% to the b%() array. This rather complicated arrangement is required
because the stave is related to Major scale notes, while, in contrast, SOUND statements are based on the
chromatic scale. Some way must therefore be found to equate an eight note scale with a twelve note system. The b
% array holds vertical step positions far every chromatic note. Line 960 then decides whether the chosen note is
sharp or natural. It does this by examining the second dimension of the array. If we have b%(R%,2)=1 the
program calls PROCsharp and a sharp is drawn at the correct position on the stave. The complete sharp is the two
halves of the sharp stacked one on top of the other.

5. PROCNote. PROCNote not only PRINTs the note ball on the correct line or space, using VDU 5 to PRINT at
the graphics cursor, but also DRAWs the stem of the note, either up or down depending on its position on the
stave. Notes that are above the middle line are sent to PROCdown, the rest are sent to PROCup. These DRAW
the stem relative to the note position variable Z%, using graphics techniques. Once the note has been displayed
the analogue port input is used to test if the correct note is being pressed. ADVAL 2 tests for a keypress. If a key
is pressed ADVAL 1 is read and its value compared with the previous value L% and the current note (P%=R%
+14) derived from PROCchoose. Q% is used to count the number of attempts which have been made at guessing
the correct note. When the correct note is chosen, so that N%=P%, it is SOUNDed in Line 1430, the number of
attempts is PRINTed in Line 1450, the time in seconds is displayed and a comment, dependent on the number of
goes, is PRINTed. If the number of goes is greater than six, the computer becomes frustrated and gives up!

Many changes and additions could be made to this program, depending on the use to which you wanted to put it.
For example ‘Tutor’ could be modified to play a note and make a comment after every attempt. In addition an
overall score could be kept, and a time limit introduced, to add an element of competition. Different clefs and
keys could also be tested. If a piano type keyboard was not available the standard alphanumeric keyboard could
be used either to type in symbols or to be labelled as white and black notes.

One logical extension of the parameters of this program is to display groups of notes in phrases of differing
timings. A horizontal scroll technique could even be used to test sight reading of fairly complex pieces of music.
A sideways scroll can be accomplished by re-programming register 13 of the 6845 video controller chip. VDU
23 is used to bring this about. See the Advanced User Guide for more information on this subject. The inclusion
of the next program was requested by my editor. It is a revised version of the program given above. It was
pointed out to me that people not possessing a musical keyboard capable of interfacing with the Beeb might be a

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (18 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

bit miffed at missing out on this whizzo program. Thus the revised program that follows, using many of the same
PROCedures as the aforementioned program, has had a keyboard display included and the ability to accept input
from the alphanumeric keypad.

KEYBOARD RECOGNITION VERSION 2


On RUNning the program you are first asked if you wish to see the instruction page, revised from that of the
original program. Once into the test the screen displays a treble clef with a note on the stave. Underneath a piano
keyboard is displayed with each key labelled with a letter from the “qwerty...” and “12345...” key sequences of
the computer keyboard.

The idea is to identify the note on the screen and press the corresponding key in as short a time as possible. If an
incorrect key is pressed that note will be SOUNDed quietly and the note will continue to be displayed. If the
correct note is pressed the note will SOUND loudly and a message will be displayed on the screen along with the
time you took. If you got the note right first time the message will be congratulatory, otherwise...

This process will continue until either you fail to get the correct note so many times that the computer gives up,
or you press . On escaping your overall score will be given as the number of successful first time attempts, out of
the total number of notes.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (19 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (20 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (21 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (22 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (23 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (24 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (25 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (26 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (27 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (28 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

The program initialisation is similar to that of the original with the addition of two variables, SCORE and NOS,
which keep track of the score and number of turns respectively. After the instructions have been called, the
computer keyboard keys that are to be used are defined (as KEY$) in Line 170. The array b%(21,3) is then
loaded from a DATA statement and is used to relate the position of a note on the musical stave with its SOUND
statement number and symbol.

The main program is contained within a loop and follows the following sequence:

1. Draws the clef and stave (PROCCLEF)


2. Draws the keyboard (PROCKEYBOARD)
3. Randomly chooses a note (PROCchoose)
4. Draws the note on the stave (PROCNote)
5. Waits for input then reacts to answer (PROCrecog)

PROCCLEF draws the treble clef using graphics techniques described earlier. PROCNote positions and draws
the note on the stave and calls either PROCup for an upward stem or PROCdown for a downward stem.
PROCchoose randomly chooses the next note, making sure that it is different to the previous value. PROCsharp

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (29 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

draws a sharp symbol in front of the chosen note if appropriate.

PROCabuse is called when the computer decides there is no hope for you as a piano player. In addition to
berating you over your musical ability it also displays your overall score. PROCinstr contains your initial
instructions.

PROCrecog differs from the PROCedure in the earlier version of the program in that instead of using the
ADVAL function to test for a keypress on a keyboard attached to the analogue port, in this case GET$ is used to
give us a value for PITCH$, which is converted to a numerical value, using INSTR, in Line 1390. N% is then
compared with the computer’s chosen value P%. The computer’s reaction to your attempts depend on the value
of Q%, the number of goes.

PROCKEYBOARD is concerned with drawing and labelling the piano diagram. It uses a series of different sized
boxes to make up the keyboard. Since we are in a four colour mode the choice of colours for this purpose is
somewhat limited. Due to the inconsistent pattern of piano keys PROCBOX must be called a number of times.
PROCNOTES labels the keys using two strings for the white and black keys. Spaces are included in BLACKS to
take account of the missing notes between B and C and between E and F.

PERIPHERALS
Common peripheral devices for the BBC microcomputer include cassette recorders, disc systems, monitors and
printers. The currently available models of printers and monitors are so varied that any comments I could
possibly venture would only backfire immediately since chances are that they would only apply to a small
percentage of users. For this reason I will leave the interesting subject of printer graphics to others! Many
commercially available printer drivers will give hard copies of our music graphics.

Cassette recorders and disc systems can be used for recording DATA RS well as complete programs. We can
therefore save our musical compositions in files separate from the program which will play them back. The BBC
is so designed that the same set of commands will allow us to create both cassette and disc files. The program
“Files” indicates how this might be done in the simple case of a note sequence.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (30 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (31 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (32 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

This is a very basic example of file handling. If you were interested in adapting it for practical use, obviously a
number of refinements would have to be added. For instance, as it stands, file names larger than ten letters would
cause the system to crash, as would a file name which could not be found, for whatever reason, when loading.

There is one other external device that can be connected to the BBC. Note, however, that one disadvantage to
embracing the device lies in the fact that this does involve opening up the case of the computer and having a
quick root around inside.

EXTERNAL AMPLIFIERS AND RECORDERS


The BBC’s sound chip drives the internal speaker directly, without utilising any external form of amplification.
This means that the volume levels which are attainable from the computer are not exactly ear-splitting. If this
situation suits you down to the ground then you need read no further. If you have ever felt the need to play your
latest computer composition to the whole street, however, then this is how you go about doing it. Do not attempt
this unless you are confident of your mechanical and soldering skills, however, as it means opening up your BBC

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (33 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

Micro.

Since most of you probably possess some form of amplifier and speaker arrangement, be it a Quad Hifi or a
‘Ghetto Blaster’, I will not describe the construction of an amplifier! I will simply indicate how your BBC can be
connected to one of these devices, either for live performance or direct recording into a tape recorder (i.e. not via
a microphone).

The parts which you will require for this modification include a length of two-core wire (about a foot) and a
socket (the exact type is entirely dependent on what you wish to hook it up to).

Solder the two cores at one end of the wire length to the socket in preparation for connection to the computer.
The computer case can be removed by unfastening four Philips screws, the two underneath nearest the front and
the two on the back of the BBC. It is also necessary to remove the keyboard by unfastening two additional screws
underneath the computer. This done, the keyboard can now be removed entirely by carefully unplugging the
multi-pin connecting cable and speaker lead. Once you have done this, the speaker can be clearly seen on the left
of the keyboard.

Unfasten the speaker from the board by removing the restraining screw and solder the free ends of the two-core
wire to the speaker connection. The socket end of the cable can be fed out through the Econet port or the hole in
the computer casing which is to be found next to it. Now reass-emble the computer so that you can connect the
new sound output to the tape or tuner input of your amplifier.

A more sophisticated arrangement would include an internal/external sound switch as well as a volume control,
but I will leave you to either work this out for yourself, or find someone who can! This type of connection will
also allow you to make good quality recordings of your own computer compositions.

EXTERNAL SYNCHRONISATION
It is possible, using the analogue input port, to synchronise music programs to an external clock such as that
provided by a drum machine or sequencer. This external clock would replace whatever timing loops were
contained in the program and allow, say, the Drum Program to be run from a synthesiser/sequencer such as the
Roland SH – 101 or Bassline or another drum machine.

To accomplish this we must first connect a few simple electronic components to the analogue input as shown in
the following diagram:

TRIGGER INPUT

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (34 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (35 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: Interfacing and Peripherals

ANALOGUE INPUT PORT

An NPN type transistor is used, such as the BC109 or the 2N3904. Other components include two 10Kohm
resistors and a connector of your choice. The transistor should be labelled with the letters B C E (though not
necessarily in that order) and must be connected in the fashion shown. The following PROCedure (PROCsync)
can be then used to sense the incoming trigger pulse:

100 REM SINGLE TRANSISTOR SYNCHRONISER

110

120 REPEAT:PROCsync:VDU7:UNTIL FALSE

130

140 DEF PROCsync:REPEAT:UNTIL(16 AND ?&FE40)=0:ENDPROC

The above program allows you to test if your circuit is working correctly. The computer should ring its bell every
time it senses an input. Once you have determined that your interface is operational, PROCsync can be
incorporated into a program. For instance in the drum machine program PROCsync could be used to move
through the sixteen steps rather than being controlled by the computer via tempo.

The circuit should be capable of sensing any trigger whose voltage exceeds 2 volts. Other factors that affect how
well the circuit performs include the length of the trigger pulse and the polarity. It is up to you to experiment with
the suggested set up to make it work under your particular conditions. At this point we must leave our final topic,
as it becomes more a matter for the circuit-builder than the budding micro-musician.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_11.htm (36 of 36)20/06/2012 08:47:09


BBC Micro Music Masterclass: The SOUND Statement

BBC Micro Music Masterclass

12: Al Fine
We have now come to the end of our voyage of discovery into ways of making music on the BBC
Microcomputer. Of course, we have by no means covered all the possible and useful methods and
techniques which can make our quest more enjoyable. Instead, I have imparted to you what I consider to
be a good starting point for further explorations of your own. My choice of subjects and programs has
been made from the standpoint of a professional musician - and computer enthusiast. All I can hope is
that the material contained in these pages will have inspired you to experiment further in this totally
fascinating field of pleasure and endeavour.

It should now be possible for you to combine and expand various programs in order to create practical
musical tools in whatever area grabs your interest most firmly. Some of the graphics techniques used in
Chapter Seven could greatly enhance the sequencer programs contained in the Applications chapter.
Autocompositional techniques could well provide bass accompaniment to the three-note organ program.
The drum synth program could be combined with the microcomposer program, in order to create rhythm
and melody parts synchronised together. As you can see, the possibilities are endless!

Of course, there are also various other techniques which I have not had the time or space to explore in
depth which should be tried at your leisure. It should be possible not only to step a synthesiser program
externally, either in the fashion I indicated via the analogue interface or else employing the user port, to
allow interconnection and synchronisation between synths, drum machines or other Micros (BBC or
otherwise). The opposite could also be tried, i.e. triggering a drum machine from pulses generated at the
user port or one megahertz bus. The possibilities are within your grasp now, so forge ahead and expand
the musical cosmos.

I also need to mention again that one of the major limitations of the BBC SOUND command is the poor
resolution possible for the timing of duration. As stated earlier on, for most practical musical purposes
1/20th of a second is, generally speaking an insufficiently small timing increment, but in many of the
programs included in the text I have made do with this limitation, for the sake of additional simplicity
and clarity. All the programs that fall into this category are intended as a demonstration of a particular
programming technique and should therefore be altered to incorporate one of the other timing methods
when it comes to practical use.

My autocompositional method is based on a thorough practical knowledge of musical composition and


improvisation. This knowledge was used to provide the computer with a set of rules to constrain its
random number generator and choose musical-sounding note patterns. A more mathe-matical, although
still artistically manipulated, technique has been explored by Jim McGregor and Alan Watt in their
excellent book, Advanced Programming Techniques for the BBC Micro. The authors employ first,

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_12.htm (1 of 3)20/06/2012 08:47:10


BBC Micro Music Masterclass: The SOUND Statement

second and third order probability tables of various melodies. These tables tell the computer the most
likely preceding and subsequent notes and thereby constrain the computer’s random choice of notes in a
different way. Since I saw no point in duplicating their already published work, I have presented an
alternative method which relies on a more directly pragmatic and practical approach to the technique.

Autocomposition just about touches on a currently fashionable area of computer programming, namely
artificial intelligence and expert systems. Might it be possible, rather than teaching the computer your
own set of musical rules, to let it develop its own? You would then only have to act as a computer critic
or A and R man giving the BBC the thumbs up or thumbs down for each new work it produced. An
exciting and daunting thought, and, copping out somewhat, I will leave entirely up to you as to precisely
how you might go about tackling this mammoth task!

One of the important subjects I have barely touched on in this study is that of interfacing. I make no
excuses for this omission, as it is a large and complicated subject in its own right. There is, however, one
type of interface which I should mention before concluding - and that is the MIDI interface.

The reason why this is worth mentioning at this late point in the book is because, by the time you read
this, interfacing devices using this new standard are likely to be available for the BBC Micro. This will
make it possible to drive keyboards such as the Yamaha DX7 and the Sequential Circuits Prophet T8, as
well as various drum machines, direct from the computer, using software based on the microcomposer
program and similar techniques. Since easy access to these interface devices is imminent at the time of
writing, and they should be readily available at a reasonable price, I came to the conclusion that it would
be redundant exploring into the electronic area of chips, transistors, bits and bytes. After all, once
commercially available, it will be possible for you to adapt your existing musical software to run these
new interface devices. For now, you can sit back and flex your new-found musical muscles using the
internal sound chip!

So let me bid you farewell for the moment and leave you in the hope that you will enjoy RUNning and
experimenting with the programs in the book just as much as I enjoyed writing them! Computers are the
future of music, welcome to the future...

Useful Reading

Magazines:

Acorn User - May 83: ‘Auto composition’


Acorn User - Dec 83: ‘Envelope Shaper program’
Acorn User - April 83: ‘Auto composition’

Electronic Soundmaker: Often has interesting articles relating computing to music.

The Micro User - Jan 84: Note Play program plus general Sound advice

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_12.htm (2 of 3)20/06/2012 08:47:10


BBC Micro Music Masterclass: The SOUND Statement

The Micro User - Dec 83: Sound advice (an extended series of articles with many helpful hints and tips)

Electronics and Computing - July/Aug 83: A two part series on how to build a digital to analogue
synthesiser interface for the BBC. An excellent constructional project for the more technical amongst
you.

Books:

The BBC Micro Book by Jim McGregor and Alan Watt

This book has a clear introductory chapter on SOUND and ENVELOPE Advance Programming
Techniques for the BBC Micro. It deals with multi-channel synchronisation, plus a mathematical
approach to automatic composition using probability tables.

Computers in Music by John Hammond

A comprehensive coverage of computer-based musical instruments from the Casio to the Fairlight.

The Advanced User Guide by Bray, Dickens and Holmes

A vital tool for further exploration into interfacing techniques. This book is filled with useful technical
information about the BBC.

If you have any problems finding information about computer music and the like, there is a company
who keep a library of current books, leaflets, technical manuals, etc. They are called ESSP. (Electronic
Synthesiser Projects) and can be contacted at the following address: ESSP, The Sound House, PO Box
37b, East Molesey, Surrey, KT8 9JB
Telephone: (01) 979 9997.

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_12.htm (3 of 3)20/06/2012 08:47:10


BBC Micro Music Masterclass: Index

BBC Micro Music Masterclass

Index

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_index.shtml (1 of 9)20/06/2012 08:47:12


BBC Micro Music Masterclass: Index

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_index.shtml (2 of 9)20/06/2012 08:47:12


BBC Micro Music Masterclass: Index

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_index.shtml (3 of 9)20/06/2012 08:47:12


BBC Micro Music Masterclass: Index

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_index.shtml (4 of 9)20/06/2012 08:47:12


BBC Micro Music Masterclass: Index

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_index.shtml (5 of 9)20/06/2012 08:47:12


BBC Micro Music Masterclass: Index

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_index.shtml (6 of 9)20/06/2012 08:47:12


BBC Micro Music Masterclass: Index

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_index.shtml (7 of 9)20/06/2012 08:47:12


BBC Micro Music Masterclass: Index

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_index.shtml (8 of 9)20/06/2012 08:47:12


BBC Micro Music Masterclass: Index

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_index.shtml (9 of 9)20/06/2012 08:47:12


file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_front.jpg

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_front.jpg (1 of 2)20/06/2012 08:47:14


file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_front.jpg

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_front.jpg (2 of 2)20/06/2012 08:47:14


BBC Micro Music Masterclass: back cover

BBC Micro Music Masterclass

YOUR MICRO AS MUSIC MACHINE!


The world of computer music is explored through the medium of the micro in this, the first book
produced by a professional musician for the Beeb. Starting with the essentials of programming sound
and music, Ian Ritchie harnesses bytes and beat to show you the way to the harmony of clefs and chips
that is modern electronic music.

At your command the versatile BBC Micro can be drum machine or synthesizer, instrument or interface,
component or composer - Music Masterclass gives you the tools and techniques you need to turn your
micro into a music machine.

Ian Ritchie introduces musical notation and the theory of chords and harmony and investigates each of
the complex programming parameters of BBC BASIC's sound commands, before developing the
Micro's music applications. These provide auto-composition, sequencer, synthesiser and drum machine
facilities, and the potential of the BBC is compared to the performance and characteristics of
commercial machines.

Music Masterclass goes on to describe and explore the simple interfacing techniques which illustrate
how the BBC's computing power can be incorporated into more complex systems as well as the potential
of graphics displays.

ISBN 0-330-28673-0

U.K. £5.95

9 780330 286732

file:///C|/Documents%20and%20Settings/Chris%20Richardson/Desktop/New%20Folder/bbc_mm_back.htm20/06/2012 08:47:15

You might also like