A synthesiser has many modules or sections which allow the synthesist to enhance and embellish the basic sounds he or she creates. Some of the resulting effects are quite intricate; many are subtle, some are not. The musician can buy a mountain of effects pedals and boxes to produce sustain, echo, reverberation, chorusing, phasing, flanging .. .. The list goes on. In this chapter we will see what effects we can produce on the BBC micro.
These are usually the first effects a synthesist learns to incorporate into his or her synthesiser patches. They are so much a part of natural sounds and music that they really do add an extra dimension to the relatively lifeless sine or square wave. There exists a certain amount of confusion over these two terms, even among musicians, so if any exists we'll clear it up now.
Vibrato is a frequency modulation, tremolo is an amplitude modulation. The modulation is usually regular and consists of an increase and decrease in pitch or volume above and below the note's pitch or volume level. A graph of this variation would be similar to the sine waves we saw in Chapter 1.
Not many instruments produce tremolo. Electronic organs produce it mechanically and electronically and singers often use vibrato or tremolo to enhance their tone. Vibrato is far more common and is often used by strings, woodwind and many brass instrumentalists.
The tremolo arm on a guitar, popular in the 1960s, actually produces vibrato. By stretching and relaxing the strings, the pitch rises and falls. If the arm is worked rapidly, it produces a regular vibrato; if it is used slowly it stretches the note, producing a portamento.
The most pleasant rate of modulation in both vibrato and tremolo is around seven cycles per second and the amount of modulation can vary from the subtle to the ridiculous. You have probably discovered examples of both in arcade-type games and you may have invented a few yourself with the program in the last chapter. Vibrato is probably the easier of the two to duplicate so we will look at that first.
The pitch variation in vibrato is not usually as great as a semitone and the quarter semitone increments of the sound chip are very useful in duplicating this effect. In a musical vibrato, the pitch varies regularly, rising and falling in a sine wave pattern moving above and below the pitch of the note. Extreme examples, where the pitch varies more rapidly and over larger intervals, are still technically vibrato but are really only produced by electronic means for special effects such as this:
10 ENVELOPE1,1,0,3,-3,0,20,20,63,-1,0, -4,126,100
20 SOUND1,1,101,l60
Alteration of the speed and degree of pitch variation will drastically alter the sound and, although we can create innumerable vibrato effects, only a few will be of any use in a strictly musical context.
Because of the rather subtle nature of vibrato, it is not always easy to tell the difference between one degree of vibrato and another unless they are considerably pronounced. The nature of the sound will change, too, as the note changes from one octave to another. What we need is a program which allows us to compare one envelope with another, alter a parameter here and there, and test out the new sound. The following program was designed as such a utility. It has been kept purposely short and is easily modified and adapted to cater for different requirements. Some suggestions for modifications are made after the listing.
10 REM PROGRAM 6.1
20 REM Envelope Comparisons
30
40 VDU15
50 ON ERROR GOTO 230
60 REM Reset Delay on Keys
70 *FX12,0
80 *KEY0 RUN|M
90 *KEY10 OLD|MLIST|M
100 PROCEnvelope
110
120 REPEAT
130 PRINT"Which Envelope?";
140 REPEAT
150 Env=GET-48
160 UNTIL Env>-1 AND Env<10
170 PRINT;TAB(16)Env
180 IF Env=0 SOUND1,-12,Pitch,40 ELSE
SOUND1,Env,Pitch,40
190 UNTIL FALSE
200
210 REM Escape Routine
220 REM Speed Up Key Repeat
230 *FX12,6
240 *FX11,20
250 ON ERROR WHEN 280,
260 ERROR
270
280 DEF PROCEnvelope
290 Pitch=149
300 ENVELOPE1,4,0,0,1,1,0,1,4,-1,0,-3,
126,80
310 ENVELOPE2,2,0,0,1,2,0,2,4,-1,0,-3,
126,80
320 ENVELOPE3,3,0,0,1,2,0,2,4,-1,0,-3,
126,80
330 ENVELOPE4,4,-2,1,1,1,1,1,4,-1,0,-3
,126,80
340 ENVELOPE5,6,1,-2,1,1,1,1,4,-1,0,-3
,126,80
350 ENVELOPE6,4,1,1,1,1,1,1,4,-1,0,-3,
126,80
360 ENVELOPE7,4,0,8,-8,0,1,1,16,-1,0,-
3,126,80
370 ENVELOPE8,4,0,28,-28,0,1,1,16,-1,0
,-3,126,80
380 ENVELOPE9,8,0,8,-12,1,1,1,16,-1,0,
-3,126,80
390 ENDPROC
Upon running, you will be asked to input an envelope number. This envelope will be used to produce a sound. If you input 0, an unmodified note will be heard.
To alter an envelope, press ESCAPE and PROCEnvelope will list to the screen. The key repeat period will be speeded up, too. I prefer these faster keys for editing but you can remove fines 70, 230 and 240 if you wish, or alter the repeat period to suit. The necessary envelopes can be edited and the program run again by pressing £0. In this way you will be able to compare two or more envelopes. If one immediately follows another, the release phase will not occur, which is how most sounds are heard in music.
When typing in the program, preface fines 50, 250 and 260 with REMs in case you enter some of the lines incorrectly. Otherwise, the program's error routines will take over and you will find debugging difficult.
Line 40 ensures that the screen is not in page mode. *KEYI0, the BREAK key, is programmed to LIST and pressing BREAK will, of course, set the key repeat periods to their default values. We do not want fast keys when we are entering envelope numbers, so they are set to default in line 70. When ESCAPE is pressed, control passes to fine 230 which speeds up the keys. The ON ERROR command at line 250 is immediately followed by an error in line 260. The word ERROR cannot stand alone and creates a syntax error which causes the program to list. You could just as easily substitute any other letters the computer does not recognise.
After altering the envelopes and pressing £0 to run, you will still be able to see the envelope parameters before they scroll off the screen.
As it stands, you can program up to nine envelopes. If this is not enough, you can expand the input parameters in lines 150 and 160 to take up to 16 envelopes.
By putting the envelope parameters into DATA statements, you could cause the envelopes to be printed to the screen as they sound. Also, by incorporating RESTORE xxx in the escape routine following line 210, where xxx is the line number containing the envelope parameters, you could cause only the last envelope called to be listed. That may seem to be taking a utility program just a step too far but you may find it helpful and it would be an interesting exercise.
Function keys 1 to 6 can be programmed to alter Pitch to produce a note from each octave. The fact that the sound does vary so much throughout the sound chip's range can be used to advantage both in music and sound effects.
You will soon find that there are few vibrato effects suitable for use in a purely musical context as extremes are simply not musical. However, the program will be useful for comparing some of the other musical ornaments detailed in this chapter. You may also want to use the program to compare more severe forms of vibrato which add so much to game programs. Alter the Pitch parameter, too, during your editing as this makes a tremendous difference to the note.
Only ENVELOPEs 1 to 6 produce a vibrato effect and you can see by comparing I and 2 that an alteration of the T parameter needs to be compensated for in the FN parameter. You will also notice that ENVELOPE 4 sounds lower than the pitch of the note. This is because P11 immediately sets the pitch down two steps for reasons that were discussed in the last chapter. The input 0 option lets you compare the actual pitch with the pitch after modification. This will tell you that ENVELOPE 4 is not quite right.
ENVELOPEs 7, 8 and 9 and their effects will be discussed under trills and echoes.
The ENVELOPE command provides a repeat option on the pitch envelope but not the amplitude envelope. To produce' tremolo, we ideally need the latter. In its absence we must use a loop. This in itself causes complications, especially if we want to use tremolo during the production of a tune. The next program demonstrates two tremolo production techniques.
10 REM PROGRAM 6.2
20 REM Tremolo Demonstration
30
40 PROCTremolo(&1,1,-1)
50 PROCTremolo(&1,1,-.25)
60 END
70
80 DEF PROCTremolo(Chan,Dur,Step)
90 PRINT"Chan=";Chan;" Dur=";Dur;" St
ep=";Step
100 REPEAT
110 FOR Amp=-2 TO -15 STEP Step
120 SOUND Chan,Amp,53,Dur
130 NEXT Amp
140 FOR Amp=-14 TO -3 STEP ABS(Step)
150 SOUND Chan,Amp,53,Dur
160 NEXT Amp
170 UNTIL INKEY$(2)=" "
180 ENDPROC
190
200 REM Tremolo Using Env Control
210
220 ENVELOPE1,5,0,0,0,0,0,0,8,-8,0,-8,
120,16
230 FOR Trem=1 TO 8
240 SOUND1,1,53,28
250 NEXT Trem
260 END
270
280 REM Faster Tremolo
290
300 ENVELOPE1,2,0,0,0,0,0,0,8,-8,0,-8,
120,104
310 FOR Trem=1 TO 30
320 SOUND1,1,53,2
330 NEXT Trem
PROCTremolo does it the hard way and alters the amplitude of the SOUND commands one at a time. Pressing the space bar will call the next tremolo effect - only two have been included.
The timing of the loop is actually controlled by the Dur parameter which, in the program, has been set to 1, its smallest value. This might seem to indicate that we can't get a faster tremolo; but if we flush the sound channel we can, and we are then only limited by the speed of the BASIC loop.
Alter line 40 to include a flush command:
40 PROCTremolo(&11,1,-1)
and notice the effect. It's not very musical because the tremolo takes the note through its complete amplitude range. The Step parameter in line 50 can be used to slow down the BASIC loop. The SOUND command will take no notice of non-integer values and making the loop step through more values than the SOUND command recognises is a good way to waste time.
To produce something more musical reduce the Amp range in fines 110 and 140.
The two short routines tacked on to the end of the program at fines 220 and 300 demonstrate how to produce tremolo with envelope control. The first example produces the same effect as fine 40.
To produce an even tremolo, it is necessary to calculate the attack and decay times and use that as the duration parameter in the SOUND command. If it is too short the sound will cut off during the decay phase and another attack phase will begin. If it is too long there will be a delay before the next cycle.
The tremolo at fine 300 is perhaps more useful and you should now be able to produce a more subtle example. If you do, you will probably notice how similar it is to vibrato. Try the last two examples again but include a vibrato in- the pitch envelope such as:
220 ENVELOPE1,5,1,-2,1 ,1,1,1,8,-8,0,-8,120,16
Experiments will produce many interesting sounds, with pitch figures produced by the pitch envelope fading in and out with the tremolo effect.
You can see the problem with loops - they take control away from the SOUND command and hold up the BASIC program. In order to put a constant tremolo into a piece of music, the controlling loop has to last for the length of each individual note. In this way, we are constantly interfering with the timing of the tune and we may find it necessary to make synchronization adjustments. This is dealt with in Chapter 9.
In practice, you are unlikely to want tremolo - or vibrato - all the way through a piece; as with all embellishments, too much ;and it ceases to be pleasant.
While vibrato is more musically useful and easier to apply, the full potential of tremolo has not been realised and its use as a source of sound effects can lead to something just that little bit different.
To produce vibrato on an instrument you need control over the pitches in between individual notes. You can't produce vibrato on a piano, for example, as the notes are fixed. The best you can do is to alternate rapidly between two adjacent notes and this is called a trill. ENVELOPE 7 in Program 6.1 produces a trill and you can hear the pitch vary between C (Pitch = 149) and D (Pitch = 157). The pitch does not follow a sine wave pattern as with vibrato and tremolo but, rather, a square wave pattern as it jumps up and down between notes.
You may have realised that the vibratos produced in Program 6.1 jump up and down in a similar way except they jump one pitch interval at a time, ie quarter of a semitone. If T is set fairly low, we can't hear the individual pitches and the ear assumes the pitch is varying in a smooth and continuous manner.
A trill is an oscillation between discrete notes and as such can be played by most instruments. If we want to include a trill in a piece of music, we can instruct the computer to play the two notes just as we would instruct it to play any others. With a duration value of I it will sound about fight, but it is often more convenient to switch control to an envelope which would then take the place of, perhaps, up to 16 pitch commands.
A trill can be played over any interval and ENVELOPE 8 in Program 6.1 plays a trill over an interval of a fifth (see Chapter 2 for further information about intervals).
A flute with the occasional trill sounds very effective, especially in military or brass band music, and a trill on a sustained note above a melody line is quite common.
10 REM PROGRAM 6.3
20 REM "Military Music" Introduction
30
40 ENVELOPE1,4,0,8,-8,0,1,1,63,0,0,-1
2,126,126
50 ENVELOPE2,3,0,0,1,2,0,2,126,-8,0,-
8,126,30
55 ENVELOPE3,4,0,0,1,1,0,1,32,-1,0,-8
,96,60
60 SOUND1,1,149,54
70 FOR Note=1 TO 9
80 READ Pitch,Dur
90 SOUND2,3,Pitch,Dur
100 SOUND3,2,Pitch+48,Dur
110 NEXT Note
120 END
130 DATA 53,12,49,4,45,12,41,4,33,4,25
,4,21,4,13,4,5,6
These are probably two of the most overused effects in the synthesist's armoury. They are great fun to play with, which is why they are overused, but in the right hands they are also capable of creative and beautiful effects.
Echoes are produced when sound waves are reflected from a smooth hard surface such as a cliff. If you stand before a cliff and shout, the sound waves produced by your voice will hit the cliff and bounce back. The time lag will depend upon your distance from the cliff\ In order to hear the reflected waves as a separate echo they must be separated from the original sound by at least one tenth of a second, which means that you must stand at least 54 feet away from the cliff. If you are closer than this, the echo will not seem distinct but will seem to be a continuation of your original shout.
A sound emitted in a room will bounce around the wall, floor and ceiling. As the reflections bounce back and forth, the result is a most complex series of multiple reflections. The net result is a reinforcement of the sound and it will seem to continue after the original sound source stops. This is a form of echo called reverberation, where the individual echoes are not discernible.
Reverberation or reverb time is the length of time required for the sound reflections in a room to fall to a certain level. Rooms with reflective surfaces have longer reverb times than rooms with insulated walls, which is why more people prefer to sing in the bathroom than in a padded cell.
Most commercial reverb units produce their effects by means of a spring or metal plate. Because of the enormous number of vibrations involved, reverb is not possible on the BBC micro (although you can feed the output to a reverb unit) but we can imitate an echo.
An echo is a single repeat of a note. Echo units are capable of producing from one to, say, five or six echoes. Many can produce even more and some are capable of an infinite number. A quality of natural echo, which you will be aware of, is that each echo is quieter than the preceding one. If an echo is repeated many times, there is a limit to how low the volume can go without becoming inaudible altogether and most units ,allow you to control the repeat volume so that the echoes fade quickly or slowly.
One type of unit popular with singers consists of a series of tape recorder heads. The first one records the sound and the following ones play it back.
Solid state echo units are available which use either analogue or digital techniques. The analogue units contain circuits which hold the signal for a short while to cause a delay before passing it to other circuits which do likewise. This form of echo production is known as a bucket brigade method for obvious reasons. As the signal passes from one circuit to another, the quality soon deteriorates and there are severe limits on how many times an echo produced in this way can repeat.
Digital units work on a similar principle, but as they pass around a series of numbers which do not deteriorate they can produce echoes which go on for ever.
There are several methods we can use to produce echo, depending upon the particular echo effect we require.
As a starting point, assume we want to repeat a single note. Ideally, we should be able to create this with a single ENVELOPE command - but we can't. To produce an echo, there must be a discernible gap between notes which means the volume has to drop to zero and rise again. We cannot do this with one envelope unless we play it twice, and that alone would not produce a drop in volume.
One method is to use a series of envelopes and play the sound using each in turn like this:
10 REM PROGRAM 6.4
20 REM Echo Production
30 REM Using Multiple Envelopes
40
50 Dur=3
60 ENVELOPE1,1,0,0,0,0,0,0,126,-4,-4,
-6,126,102
70 ENVELOPE2,1,0,0,0,0,0,0,102,-4,-4,
-6,102,78
80 ENVELOPE3,1,0,0,0,0,0,0,78,-4,-4,-
6,78,54
90 ENVELOPE4,1,0,0,0,0,0,0,54,-4,-4,-
6,54,30
100 ENVELOPE5,1,0,0,0,0,0,0,30,-4,-4,-
6,30,6
110 SOUND1,1,101,Dur
120 SOUND1,2,101,Dur
130 SOUND1,3,101,Dur
140 SOUND1,4,101,Dur
150 SOUND1,5,101,Dur
This produces a rather good echo but is wasteful of envelopes. Lines 110 to 150 could be replaced with a FOR . . . NEXT loop for neatness. Try doubling the SOUND commands like this:
110 SOUND1,1,101 ,Dur:SOUND1,1,101,Dur
The duration of the note determines the echo repeat time and long notes will not produce a very good effect.
The next program tries to reduce the envelope waste by using only one and repeatedly redefining it within a procedure. In doing this, we must be careful not to redefine an envelope before it's ready to be used. Try the program.
10 REM PROGRAM 6.5
20 REM Echo Using a Procedure
30
40 EchoSpeed=10
50 RateOfDecay=3
60
70 FOR Note=1 TO 5
80 READ Chan,Pitch,Dur
90 PROCEcho
100 NEXT
110 END
120
130 DATA 1,5,16,2,33,16,3,53,28,1,69,2
,2,65,32
140
150 DEF PROCEcho
160 AA=126
170 FOR Count=1 TO Dur
180 ALD=AA-RateOfDecay
190 ENVELOPE1,1,0,0,0,0,0,0,AA,-4,-4,-
1,AA,ALD
200 SOUNDChan,1,Pitch,1
210 TIME=0:REPEAT UNTIL TIME>EchoSpeed
220 AA=ALD
230 NEXT Count
240 ENDPROC
Line 210 holds up the whole program while the echo runs its course. If we try to build the delay into the SOUND command by, increasing the duration, it does not work. This is because the sound chip stores the commands and, while it is waiting to execute them, the rest of the program has already redefined the envelope the required number of times and we get no echo at all. Remove fine 210 and see what happens.
Note also that the durations given to the SOUND command from the DATA statement at fine 130 no longer determine the length of the note. This is determined by the variable, EchoSpeed. The duration values still maintain the note-length relationship between notes. Alter Echospeed and RateOfDecay and listen to the effect. It may be necessary to alter AD, AS and AR values in the envelope if your values become extreme.
The above examples assume that you want a drop in volume with the repeat. If we do away with the amplitude reduction it detracts from the echo effect which results in only a sequence of notes.
You can see that the implementation of a single note echo is not particularly easy, although the results can be very good and well worth the effort. Another alternative is to create a pseudo echo using the pitch envelope. This is often the easiest way and can lead to many unexpected results. The following fines contain sample envelopes for inclusion in the Envelope Comparison program:
10 REM PROGRAM 6.6
20 REM Pseudo Echoes Using
30 REM Single Envelopes
40 REM Insert in PROGRAM 6.1
50
60 ENVELOPE1,20,12,-12,0,1,1,0,126,-6
,-6,-6,126,0
70
80 ENVELOPE2,4,4,0,32,4,1,0,126,-1,-1
,-1,126,0
90
100 ENVELOPE3,4,4,16,12,1,1,1,126,-1,-
1,-1,126,0
110
120 ENVELOPE4,6,8,-16,8,8,4,2,126,-1,-
1,-1,126,0
130 ENVELOPE5,4,32,-64,4,1,1,16,126,-1
,-1,-1,126,0
ENVELOPE 9 in Program 6.1 also contains a pseudo echo.
If you want an echo of two or more notes this is the way to do it. Even if you don't, you can often get away with using two notes where you really only wanted one. In a particularly complicated program, this method will save you a lot of time and effort.
Program 6.6 contains a few ideas to start you off. The temptation is to forget your original purpose and design some complicated envelopes - which is not necessarily a bad thing provided you have the time.
Only one step away from the echo examples, we can devise envelopes that will play a tuneful sequence of notes. The little fanfare in the Motility Tester program in Chapter I could easily have been the result of a sequence of notes read in from a DATA statement. Instead, it was produced by one envelope which is repeated here for analysis:
10 ENVELOPE1,11,16,4,8,2,1,1 ,100,0,0,-100,100
20 SOUND1,1,101,20
The pitch changes in an envelope can be described as three variations, each variation being a number of rises or falls in pitch, each rise or fall being over the same interval.
There are five main points to consider when inventing envelope tunes and these are:
1) To stay within the western scale, all PI intervals should be in steps of multiples of four.
2) Remember that PI1 affects the pitch immediately so, in the example above, the starting note is E, not C as you might expect.
3) Consider the length of the sequence carefully. If AR is altered from -100 to -1, the release phase will occur and it will sound like another echo envelope and lose its impact. As it is, the envelope will last as long as the SOUND% duration parameter.
You can calculate the time, in hundredths of a second, of a single pitch envelope as follows:
Time = (PN1+PN2+PN3)*T
If you want to terminate the sound in the middle of a pitch envelope, as above, you can calculate the amount of time required and apply it to the SOUND command by dividing by five. In this case the envelope repeats once and has an extra note on the end. This is a total of 9 xT which is 99. Dividing by five gives us our duration of 19 or 20.
4) T controls the speed of the notes. It is sometimes easier io work with a large value to T so that you can hear what's happening, and then reduce it to the required level when your sequence is correct.
5) If the pitch in the SOUN.D statement is too high or too low, the envelope might take the pitch to the other end of its range. This can be used purposely to produce some good effects.
Correct planning, as they say in textbooks about structured programming, is very important. I will just repeat that, if you are looking for a specific effect, it helps to know first if it's possible and, if it is, how to set about producing it. If you know how the SOUND and ENVELOPE commands work you will not waste your time trying to produce something they can't do.
As a basis for further experiments, here are a few envelopes which play a musical sequence of notes. The first plays an arpeggio of a C diminished chord (see Chapter 2 for further information about chords) up four octaves, comes down in semitones to an octave lower than the start note and rises in semitones until it reaches C. The envelope does not repeat.
10 ENVELOPE1,136,12,-4,4,17,60,12,100,0,0,-100,100,100
20 SOUND1,1,41,144
Arpeggios of diminished and augmented chords are easy to program because they increase the start note by 3 and 4 semitones respectively.
Playing a scale other than in semitones is difficult because the western scale is composed of:
tone + tone + semitone + tone + tone + tone + semitone
which will not fit into the pitch envelope. We can fiddle our way around this by simply playing a scale in tones, known appropriately enough as a 'whole tone scale', but this may not harmonise exactly if it is used with other notes. See if you can tell the difference, though:
10 ENVELOPEl,10,8,-8,0,18,18,6,100,0,0,-100,100,100
20 SOUND1,1,45,84
Notice the use of a value in the PN3 parameter without a corresponding PI3 value to sustain the last note.
There are only two whole tone scales, one contains C and the other one doesn't! The other one contains C#. Check this out on the diagram in Figure 2.4. The whole tone scale is used in the introduction to Stevie Wonder's song, 'You Are the Sunshine of My Life'.
If the tune or effect is to stand alone, you need not restrict yourself to the western scale or pitch intervals. Try PI values in increments of 2, 3, 5 or 6, etc. I leave it to you to experiment further on these lines.
As an example of a sequence going off the top of the scale and coming up from the bottom, try this:
10 ENVELOPE1,9,20,20,0,10,10,5 ,100,0,0,-100,100,100
20 SOUND1,1,149,135
Finally, you can use two or more envelopes one after the other to produce even more complicated tunes. Having worked through this chapter, you should not find that too difficult.
These have been grouped under one heading because, although they each have their own character, their effects are produced by delaying a sound and/or varying its pitch or frequency. They are called spatial effects because they alter our perception of the environment which we think produced the sound - just as reverberation can make us think a sound originated in a big theatre.
When a group of musicians play in unison, they each play a slightly different pitch. This difference is very small but it tells the ear that there is more than one instrument. This is known as a chorus effect and is responsible for the beautiful sound of a string orchestra. Chorus units produce their effect by slightly altering the pitch and recombining it with the original sound.
Phasing, flanging and audio delay are very difficult to describe in words. They all produce a sort of whooshing sound and such effects can be heard on many electronic music albums. (The sound of a jet plane taking off creates a phasing effect.)
There is more than one story floating around the music world of how Hanging was invented. One version recalls how flanging was first produced by applying slight pressure to the flange of a spool of tape as it was playing, to cause a small delay. If you can imagine two such tapes being played in this manner and drifting in and out of sync with each other you will have a good idea what flanging sounds like - and an excellent imagination.
All these effects are produced by various forms of delay. These delays are reckoned in thousandths and hundredths of a second. When a sound is delayed and mixed back with the original sound, certain frequencies are cancelled. If the delay is varied, the range of cancelled frequencies will vary and produce a shifting effect.
We'll leave the description there because there is not a log we can do to recreate these effects exactly and you need to hear the' sounds to appreciate them. Perhaps your local music shop will demonstrate their range of effects pedals.
Because of the way the BBC micro's sound chip works, if we produce the same pitch on two or more different channels, the pitches will not be exactly the same. This is a chorus effect. The pitch difference is not as great as a pitch interval and, if we add 1 to one of the pitch values, the effect will be more pronounced and less subtle. We can really go to town and use three channels with a pitch difference of 1 between each. You may wish to set the volume of the main pitch SOUND command slightly higher than the others. This short program runs through some of the possibilities:
10 REM PROGRAM 6.7
20 REM Chorus Effects
30
40 REM Alter Pitch
50 REM To Other Values
60 Pitch=227
70
80 REM 2 Channels
90 SOUND1,-12,Pitch,120
100 SOUND2,-12,Pitch,120
110 Next=GET
120
130 REM 3 Channels
140 SOUND1,-12,Pitch,120
150 SOUND2,-12,Pitch,120
160 SOUND3,-12,Pitch,120
170 Next=GET
180
190 REM 2 Channels with Increased
200 REM Pitch Value
210 SOUND1,-12,Pitch,120
220 SOUND2,-12,Pitch+1,120
230 Next=GET
240
250 REM 3 Channels with Increased
260 REM Pitch Value
270 SOUND1,-12,Pitch,120
280 SOUND2,-12,Pitch+1,120
290 SOUND3,-12,Pitch-1,120
300 Next=GET
310
320 REM Pseudo Chorus
330 REM Using Fast Vibrato
340 ENVELOPE1,1,0,0,1,1,0,1,100,0,0,-1
00,100,100
350 SOUND1,1,Pitch,120
With Pitch set to 227, the first two effects are probably as near as you'll get to a scream - shorten the duration before use! More pleasing and musical effects occur in the lower octaves.
This example tries to produce its effect with the pitch envelope. How well it succeeds I leave to you to judge. At best, it's only half the effect because we only hear one pitch at a time and chorus relies on the interaction between two or more frequencies. You may find it useful, however, when you only have one spare channel.
The other spatial effects are really beyond the capability of the BBC micro's sound chip but we can content ourselves with the thought (even if it's not strictly true) that they just sound like a more sophisticated chorus effect.
Especially with lower notes, you will hear the frequencies weaving in and out and, at times, the note or notes almost cease. This pulse is called a beat and is produced whenever two notes sound at not quite the same frequency. The beat frequency is the difference between the two pitches. If we listen to this:
10 SOUND1,-12,52,120
20 SOUND2,-12,53,120
we should hear a beat frequency of 3 to 4Hz (cycles per second). A pitch value of 52 has a frequency of about 263.1 and 53 has a frequency of about 266.3. Beat frequencies can be heard when playing intervals, too, if the interval is not in tune.
The beat frequencies you will hear, as you run the above program and alter the pitch, will vary and you may find some pitches which produce no beats at all, indicating that they are exactly in tune.
As an example of how you can use this effect, the following program imitates an accordion.
10 REM PROGRAM 6.8
20 REM French Accordion Music
30 REM Using Chorus Effect
40
50 ENVELOPE1,3,0,0,0,0,0,0,8,-1,0,-6,
124,60
60
70 FOR Tune=1 TO 16
80 READ Note,Dur
90 IF Note=0 Amp=0 ELSE Amp=1
100 SOUND1,Amp,Note,Dur
110 SOUND2,Amp,Note,Dur
120 NEXT Tune
130 END
140
150 DATA 61,8,77,8,113,8,109,72
160 DATA 61,8,81,8,113,8,109,32
170 DATA 0,8,93,8,101,8,0,4,65,4,61,4,
53,4,61,4
This uses the natural beat frequencies of the sound chip. You can increase the effect by adding a whole pitch and, less subtle though it may be, I like this better:
110 SOUND2,Amp,Pitch+1,Dur
Notice also the way we create a gap in the music - switching from envelope control to a SOUND command with an amplitude of 0.
The last synthesiser module we will examine and try to duplicate is the ring modulator. This is responsible for producing bell-like and metallic sounds and works in a way unlike any of the modules or effects we have covered so far.
A standard ring modulator requires an input of two frequencies: it produces an output which is a compound of the sum of these two frequencies and the difference between them. To take an example, if the modulator was fed with a frequency of 440Hz and 1220 Hz, the output would be a compound of 1660Hz (the sum: 440 + 1220) and 760Hz (the difference: 1200-440).
That's fairly straightforward, but the BBC micro is not calibrated to work in hertz and so our choice of frequencies is limited. Also, we do not know what frequency is produced by each pitch command. The only way to discover this is to measure it. Figure 6.1 displays a table of the frequencies in hertz produced by the range of P values. The measurements were taken from a single BBC micro and it is quite likely that measurements taken from other machines will show slightly different figures, but for our purposes these will be accurate enough.
Before we see how to produce bell-like sounds, let us have a closer look at the results shown in Figure 6.1.
If you look at the table, you will notice that the sound chip is not terribly accurate and that some adjacent values of P produce very similar frequencies. Unless you want to compose music in quarter of a semitone intervals, this should make no difference. Although the ear is capable of distinguishing between differences in pitch of as little as 10 Hz, musically, it makes many allowances for such discrepancies. Only if you have perfect pitch (also called absolute pitch - the ability to identify the correct pitch of a note) or the tuning is out by about half a semitone will your ear be offended. Notice, in fact, how pleasing the difference of 1 in the P parameter can be, as illustrated by the last program.
Through our experiments with scales you will have realised that, when the range is stepped through in semitone intervals, the sound is quite acceptable. Only when you reach the very upper range of the sound chip may you find tuning problems.
Even if you are not a musician in the strictest sense of the word, you may have heard of the international tuning standard which stipulates a value of 440 Hz for A above middle C. A glance at our table reveals that this would be more accurately produced by a P value of 88, not 89. In fact, the whole of the scale seems to be one pitch value out Unless the sound chips vary throughout production (which they do not appear to do), it would appear we could get a more accurate musical tuning if we gave the lowest B a value of 0 and worked upwards from there in steps of 4. It would tend to make more sense, too, instead of starting with 1. In the fight of this, it is a bit of a mystery why the User Guide stipulates the scale as it does.
This whole topic, however, I leave to the purists. You can adjust the values if you wish but there is little to be gained. I have used the values given in the User Guide to avoid confusion and only the most sensitive ears are likely to know the difference. If you want to use your computer to play along with other instruments you may have to make adjustments to the basic pitch values.
Figure 6.1
P Param | Freq Hz | Note |
0 | 124.0 | |
1 | 125.7 | B |
2 | 127.5 | |
3 | 129.4 | |
4 | 131.4 | |
5 | 133.3 | C |
6 | 135.8 | |
7 | 136.9 | |
8 | 139.2 | |
9 | 141.8 | C# |
10 | 143.8 | |
11 | 144.9 | |
12 | 147.5 | |
13 | 149.7 | D |
14 | 151.8 | |
15 | 154.8 | |
16 | 156.2 | |
17 | 158.4 | D# |
18 | 160.6 | |
19 | 162.9 | |
20 | 165.5 | |
21 | 167.7 | E |
22 | 178.8 | |
23 | 172.3 | |
24 | 175.5 | |
25 | 178.8 | F |
26 | 188.5 | |
27 | 183.2 | |
28 | 185.9 | |
29 | 188.4 | F# |
30 | 191.8 | |
31 | 193.7 | |
32 | 196.8 | |
33 | 199.6 | G |
34 | 202.5 | |
35 | 205.5 | |
36 | 208.5 | |
37 | 211.4 | G# |
38 | 214.4 | |
39 | 217.3 | |
40 | 221.1 | |
41 | 224.3 | A |
42 | 227.5 | |
43 | 230.9 | |
44 | 234.8 | |
45 | 237.1 | A# |
46 | 240.3 | |
47 | 234.6 | |
48 | 247.9 | |
49 | 251.3 | B |
50 | 255.8 | |
51 | 258.7 | |
52 | 263.1 | |
53 | 266.3 | C |
54 | 278.4 | |
55 | 274.8 | |
56 | 278.4 | |
57 | 282.2 | C# |
58 | 285.9 | |
59 | 0.0 | |
60 | 295.3 | |
61 | 299.9 | D |
62 | 303.9 | |
63 | 308.4 | |
64 | 312.3 | |
65 | 317.2 | D# |
66 | 321.3 | |
67 | 326.3 | |
68 | 331.8 | |
69 | 335.8 | E |
70 | 348.4 | |
71 | 345.1 | |
72 | 358.9 | |
73 | 355.9 | F |
74 | 361.1 | |
75 | 366.3 | |
76 | 371.8 | |
77 | 377.6 | F# |
78 | 382.8 | |
79 | 388.8 | |
80 | 394.2 | |
81 | 399.8 | G |
82 | 485.8 | |
83 | 411.1 | |
84 | 418.3 | |
85 | 423.7 | G# |
86 | 429.4 | |
87 | 435.4 | |
88 | 443.1 | |
89 | 449.3 | A |
90 | 456.8 | |
91 | 462.7 | |
92 | 467.9 | |
93 | 475.8 | A# |
94 | 488.4 | |
95 | 488.8 | |
96 | 495.8 | |
97 | 583.7 | B |
98 | 589.9 | |
99 | 518.5 | |
100 | 524.0 | |
101 | 533.9 | C |
102 | 548.8 | |
103 | 547.9 | |
104 | 557.8 | |
105 | 566.8 | C# |
106 | 573.1 | |
107 | 581.1 | |
108 | 592.3 | |
109 | 600.9 | D |
110 | 609.6 | |
111 | 618.5 | |
112 | 625.3 | |
113 | 634.3 | D# |
114 | 644.4 | |
115 | 654.4 | |
116 | 664.5 | |
117 | 671.7 | E |
118 | 682.6 | |
119 | 690.2 | |
120 | 781.9 | |
121 | 714.1 | F |
122 | 722.1 | |
123 | 734.8 | |
124 | 743.6 | |
125 | 757.1 | F# |
126 | 766.4 | |
127 | 776.0 | |
128 | 790.8 | |
129 | 800.8 | G |
130 | 811.1 | |
131 | 821.9 | |
132 | 838.4 | |
133 | 849.8 | G# |
134 | 861.5 | |
135 | 873.5 | |
136 | 886.8 | |
137 | 898.7 | A |
138 | 911.8 | |
139 | 925.4 | |
140 | 939.3 | |
141 | 953.7 | A# |
142 | 961.1 | |
143 | 976.1 | |
144 | 991.4 | |
145 | 1007.9 | B |
146 | 1023.8 | |
147 | 1040.9 | |
148 | 1058.5 | |
149 | 1068.3 | C |
150 | 1087.0 | |
151 | 1095.8 | |
152 | 1115.3 | |
153 | 1135.9 | C# |
154 | 1146.3 | |
155 | 1167.4 | |
156 | 1198.3 | |
157 | 1281.7 | D |
158 | 1224.8 | |
159 | 1236.9 | |
160 | 1249.9 | |
161 | 1274.6 | D# |
162 | 1288.1 | |
163 | 1315.2 | |
164 | 1329.7 | |
165 | 1343.7 | E |
166 | 1372.8 | |
167 | 1388.3 | |
168 | 1484.1 | |
169 | 1436.8 | F |
170 | 1452.6 | |
171 | 1469.6 | |
172 | 1487.0 | |
173 | 1523.4 | F# |
174 | 1542.1 | |
175 | 1561.5 | |
176 | 1581.3 | |
177 | 1601.5 | G |
178 | 1622.3 | |
179 | 1643.8 | |
180 | 1688.3 | |
181 | 1711.2 | G# |
182 | 1735.0 | |
183 | 1759.7 | |
184 | 1784.5 | |
185 | 1818.5 | A |
186 | 1837.3 | |
187 | 1864.4 | |
188 | 1892.8 | |
189 | 1921.8 | A# |
190 | 1921.7 | |
191 | 1951.8 | |
192 | 1982.7 | |
193 | 2814.9 | B |
194 | 2847.8 | |
195 | 2681.8 | |
196 | 2117.3 | |
197 | 2153.8 | C |
198 | 2191.6 | |
199 | 2192.1 | |
200 | 2238.5 | |
201 | 2271.4 | C# |
202 | 2313.1 | |
203 | 2357.8 | |
204 | 2482.1 | |
205 | 2428.1 | D |
206 | 2451.5 | |
207 | 2588.5 | |
208 | 2581.3 | |
209 | 2549.2 | D# |
210 | 2686.3 | |
211 | 2661.3 | |
212 | 2663.8 | |
213 | 2715.6 | E |
214 | 2776.2 | |
215 | 2775.8 | |
216 | 2839.8 | |
217 | 2912.8 | F |
218 | 2914.6 | |
219 | 2979.8 | |
220 | 2980.9 | |
221 | 3851.8 | F# |
222 | 3123.8 | |
223 | 3123.2 | |
224 | 3211.1 | |
225 | 3213.3 | G |
226 | 3298.7 | |
227 | 3298.9 | |
228 | 3377.6 | |
229 | 3470.7 | G# |
230 | 3470.4 | |
231 | 3569.7 | |
232 | 3578.4 | |
233 | 3678.2 | A |
234 | 3681.4 | |
235 | 3785.6 | |
236 | 3786.0 | |
237 | 3983.6 | A# |
238 | 3984.8 | |
239 | 3983.9 | |
240 | 4029.4 | |
241 | 4038.8 | B |
242 | 4164.8 | |
243 | 4164.5 | |
244 | 4389.1 | |
245 | 4310.3 | C |
246 | 4482.9 | |
247 | 4484.9 | |
248 | 4489.1 | |
249 | 4638.3 | C# |
250 | 4636.2 | |
251 | 4811.5 | |
252 | 4811.6 | |
253 | 4808.5 | D |
254 | 4996.5 | |
255 | 4996.4 |
A ring modulator works best with sine waves and produces a fairly accurate output according to the formula we set out above. As the BBC micro does not produce sine waves and, more importantly, as we cannot specify pitch values in hertz, our results will be less than perfect. But, we can still experiment and produce some convincing sounds.
The way to calculate the output frequencies is as follows:
Of course, it is quite time-consuming to go through this process whenever you want a chime; especially if you're writing a piece of music for tubular bells. Sometimes your calculations will produce frequencies which are higher or lower than those available from the sound chip, in which case you will have to try other input values.
The lower frequency will give you the pitch of the note and the upper one will seem like a strong harmonic. You may like to try reducing the volume of the harmonic. You can also try adding one of the original pitches, in this case C3 or E3. Normally, the original frequencies do not appear at the output of the modulator.
You can base your calculations on any two frequencies at all. Intervals over a minor third tend to give the best results. The obvious thing to do is to write a program which allows you to input two pitches and which would output the two nearest P parameters. The programming would be simple but quite long as you would need to include all 256 frequencies. Bell effects are not used very often on the BBC micro, so perhaps you will find the exercise worthwhile.
Fortunately for the more eager among us, an unscientific but workable shortcut is possible. This consists of adding a fixed pitch difference to the melody notes. This will usually produce good results but be careful if the tune spreads over a large range. The next program illustrates this principle.
10 REM PROGRAM 6.9
20 REM Bells and Chimes
30
40 ENVELOPE1,4,0,0,0,0,0,0,126,-1,-1,
-1,126,0
50
60 FOR Pitch=1 TO 8
70 READ Note,Dur
80 SOUND1,1,Note,Dur
90 SOUND2,1,Note+120,Dur
100 NEXT Pitch
110
120 SOUND1,1,117,64
130 SOUND2,1,6,64
140 SOUND1,1,129,16
150 SOUND2,1,53,16
160 END
170
180 DATA 117,16,101,16,109,16,81,32
190 DATA 81,16,109,16,117,16,101,64
Try substituting different values for the pitch difference in line 90, and add a pitch difference to other tunes to hear them played by bells or chimes.
Finally, for pure cacophony, experiment along these lines:
10 FOR Bell=1 TO 20
20 SOUND1,-15,RND(101),1030 SOUND2,-15,RND(153)+102,10
40 NEXT Bell