Not top of the pops perhaps, but try playing this
By NIGEL PETERS
THE Editor crept up behind me as I was finishing Peters' First
Concerto for BBC Micro (with optional disc drive accompaniment).
The first I knew of it was when he pressed Break and started cackling
as he saw the look on my face.
"Cheer up", he crowed, "you're taking all this
sound and music too seriously. It's getting out of proportion
".
"In fact", he added, "you should keep it all
in scale".
He reached his office before I reached him.
SURPRISINGLY he was more accurate than he thought because this
month we'll be covering musical scales. Not that I intend to give
you a music lesson - I wouldn't dare - but I will show you the
basics of producing simple tunes with your micro.
In the last article we examined the SOUND command and learned
how to use it to produce noises. Each of these separate noises
is technically called a note and by putting together a series
of notes we get a tune.
It should be pointed out that some series of notes are more
tuneful than others - as you may have found with the random music
generator!
This is because the human ear has come to expect a certain consistency
in the notes that make up tunes.
It wants them to go up and down, or change pitch, by regular
amounts.
Try running Program I.
10 REM PROGRAM 1
20 FOR pitch=0 TO 255 STEP 4
30 SOUND 1,-15,pitch,20
40 SOUND 1,0.pitch,20
50 NEXT pitch
Program I
This goes upwards in a series of steps called semitones. It
does this by adding four to the pitch parameter of the SOUND command
each time round the loop.
These semitones are the natural building blocks of western music.
When tunes go up and down in pitch (higher or lower, soprano or
bass) they tend to do so in semitones or groups of semitones.
Even though Program I will probably have you pressing Escape
before its end, you'll find it a lot more acceptable than Program
II which goes up in steps of one, a quarter of a semitone.
10 REM PROGRAM II
20 FOR pitch=0 TO 255 STEP 1
30 SOUND 1,-15,pitch,20
40 SOUND 1,0,pitch,20
50 NEXT pitch
Program II
Since we've been talking about semitones you might expect that
we'll be coming to whole tones and this we do with Program III.
10 REM PROGRAM III
20 FOR pitch=0 TO 255 STEP 8
30 SOUND 1,-15,pitch,20
40 SOUND 1,0,pitch,20
50 NEXT pitch
Program III
This program plays a series of notes, each successive note being
raised in pitch by one tone (or two semitones). So increasing
the pitch parameter by four raises the note by a semitone; increasing
it by eight produces a note one whole tone higher.
Higher notes require different combinations of four and eight
to be added to the pitch parameter.
The trouble with the previous programs is that although they
worked in tones and semitones, the natural building blocks of
music, they were boring.
They leave you with that "waiting for the other boot"
feeling!
This is because our ears not only expect tunes to be composed
of notes which vary in pitch by tones and semitones, but also
they prefer certain selections of the available notes. Try running
Program IV.
10 REM PROGRAM IV
20 pitch=50
30 REPEAT
40 SOUND 1,-15,pitch,20
50 READ increase
60 pitch=pitch+increase
70 UNTIL increased
80 DATA 8,8,4,8,8,8,4,0
Program IV
Much more satisfying, isn't it? It has a complete feeling about
it.
After the first note is played the following notes are increased
in pitch by the amounts shown in the DATA statement.
As you'll expect by now, these increments are all fours and
eights, but they are in an order that sounds pleasing to the ear.
This is known as a scale, and most tunes are made up of combinations
of notes picked from one scale.
To recap, nearly all the tunes you know consist of series of
notes whose pitch changes in multiples of tones and semitones.
The notes go up and down in discrete bundles made up of these
measures and most tunes confine themselves to a selection of the
available notes.
What this means for the BBC Micro is that if you're trying to
write a tune you know that after you've picked the start note
all the other notes will have the start note's pitch parameter
varied by factors of four or eight.
Of course the channel, loudness and duration of the note may
vary as well but in this article let's concentrate on the pitch.
It's much easier to use in practice than to describe. Try running
Program V.
10 REM PROGRAM V
20 REPEAT
30 READ note
40 IF note=0 THEN END
50 SOUND 1,-15,note,10
60 UNTIL FALSE
70 DATA 30,30,38,26,30,38,0
Program V
This produces a fairly uninspiring version of a well-known tune.
It's hardly wonderful music but you can see from the DATA statement
how the pitch parameter of the notes varies by factors of four
or eight from the pitch parameter of the first note.
Once I had the first note it was just a matter of figuring out
whether the next note was up or down and adding or subtracting
the fours and eights as necessary.
Then I just put them in a DATA statement and let the loop read
the pitch and play the tune.
You can play your own tunes by putting in your own DATA statements.
The problem is that you have to figure out which DATA statements
produce which notes. Program VI will help you with this.
It is a very simple one which allows you to write micro music
by ear.
It begins by asking you for the pitch and duration parameters
of the tune's first note. The micro then plays this and asks you
if you want to keep it.
If you do, it will save the note and ask you if you want to
play the tune. The program carries on like this, asking for the
parameters of notes, playing them and, if required, saving them.
When you finally decide to hear the tune it will play it and
display the DATA statement values used.
It's simple to write tunes using this program. When you want
to play them just modify PROCreadnote and PROCplaystring.
Of course, this has been a fairly limited treatment. Only one
of the BBC Micro's four channels has been used, and we haven't
varied the loudness at all. Also we've avoided playing more than
one note at a time and producing harmonies.
All this, and more, will follow. But I have to finish now. I've
been working for far too long for too little pay, so I'm going
into the Editor's office, waking him up and demanding a raise.
I call it making my pitch.