Home -> Magazines -> Issues -> Articles in this issue -> View

| |

## Digital Signal Processing (Part 3) | |

*Part 3 of this exciting digital signal processing project offering a 5 second delay program for your Sinclair Spectrum!*

**Extended Echo Delay and Fourier Synthesis using the Digital Conversion Hardware.**

The previous article in August'83 E&MM concluded with setting up the analogue to digital and digital to analogue converters presented in this series, together with an introduction to the echo program contained in the DIGISOUNDER 3 software.

For the delay routine we set aside a fixed block of 30K of memory within a 48K SPECTRUM and so to change the maximum delay time we simply vary the rate of writing information into memory. In other words, the slower the rate of entering data into memory the greater the maximum echo time. On using 'e' to enter the real time echo program, the sampling rate is set to 14.8 kHz, which happens to be the same rate as the digital storage oscilloscope routine (not 12 kHz as initially estimated). This rate combined with 30K of memory gives a maximum delay of just over two seconds and you have the option of entering any delay time between one millisecond and the maximum value shown on the TV display. As stated in earlier parts, the sampling rate determines the bandwidth of the input signal, which must be less than half the sampling rate if one is to avoid excessive noise and distortion. Thus with the default value of 14.8 kHz the input signal should not contain components having a frequency above about 7 kHz. The filters on the converters may be adjusted to meet any bandwidth requirements.

In some instances one may be willing to reduce the maximum echo time in order to obtain a greater bandwidth. There are also other situations, such as vocals, where the bandwidth may be reduced so as to obtain a longer echo. The program therefore contains an *expansion* facility which is accessed by entering 'x'. One then has the opportunity to enter any bandwidth within the range of 5.6 kHz to 22.4 kHz which corresponds to maximum echo times from greater than five seconds to about 1.3 seconds. When you return to the echo program with an 'e' the new sampling rate is displayed, together with the values of minimum and maximum delay times that may be entered. For example, if a sample rate of 10 kHz was entered in the expansion routine, then the display will show that any delay time between 1 and 2999 milliseconds may be obtained.

Any waveforms which are periodic in nature, such as musical signals, can be expressed as a series of harmonically related sine and cosine waves. This is termed a *Fourier series* in honour of the French mathematician who discovered this technique of describing and analysing waveforms.

The Fourier series is the foundation of electronic music and in fact the early works of the German school made extensive use of banks of sinewave generators. Nowadays we can re-create the effect of this type of hardware by using a microprocessor to combine any number of sinewaves together in the desired proportions and then listening to the resultant sound by converting the digital data into analogue form. To demonstrate this, start by running the following program on the SPECTRUM:

10 FOR n=0 TO 255

20 PLOT n, 88+80*SIN(n/128*PI)+26.77*SIN(n/42.66*PI)+16.06*SIN(n/25.6*PI)

30 NEXT n

The plot is shown in Figure A and line 20 is simply the sum of three sinewaves representing the first three odd harmonics which make up a square wave. Even with just three harmonics the square wave is quite distinct. One can also plot the three individual sinewaves, but remember to add the 88 each time so as to centre the plot on the screen.

Next substitute line 20 by the following which represents the first five harmonics of a sawtooth waveform, as shown in Figure B.

20 PLOT n, 88+50.9*SIN(n/128*PI)+25.4*SIN(n/64*PI)+17*SIN(n/42.66*PI)+12.7*SIN(n/32*PI)+10.2*SIN(n/25.6*PI)

For a triangle wave, illustrated in Figure C, line 20 should be as follows, which again is the first three odd harmonics:

20 PLOT n,88+72.9*SIN(n/128*PI)-8.1*SIN(n/42.66*PI)+2.9*SIN(n/25.6*PI)

Note the minus sign for the third harmonic and if a sinewave of the same proportion was added, instead of being subtracted, at this point we would obtain the waveform shown in Figure D.

DIGISOUNDER 3 contains a program for producing waveforms using Fourier synthesis. Enter 's' for synthesise and you will be prompted for the amplitude of the first harmonic (fundamental). Any number between 0 and 380 may be used in response to any of the amplitude prompts. After entering the first number a prompt appears for the second, and so on up to and including the fifth. After five the prompt is then for the phase angle to be used and there is a choice of 0 or 180 degrees. A zero will produce an addition of the harmonic whereas 180 will result in a subtraction, as in the case of the triangle waveform of Figure C.

Try out the program by entering the numbers 318,159,106,79.5 and 63.5 for the amplitudes and then 0,0,0,0 and 0 for the phase. When the last phase has been entered the information supplied will be displayed in the form of a frequency spectrum and a table of phase angles. A copy of the screen display is shown in Figure E. The micro will then calculate the 256 terms of a wavetable at a rate of about two a second and so you can sit back for a couple of minutes. After this it goes into an automatic scaling routine, which takes about fifteen seconds, and finally loads the waveform into the 30K of reserved storage memory.

Apart from the memory loading routine, the remainder of the program is in Basic to make it easier for the user to modify. For example, if one wishes to study this aspect of synthesis in greater detail then the number of harmonics and the choice of phase may be extended although five is adequate for most demonstration purposes. When memory loading is complete, a pair of inverted commas will appear as a prompt for the next command. Entering W at this time will plot the waveform that has been computed and the result for the above set of data is shown in Figure F. This is the same sawtooth as Figure B but the display looks a bit more ragged due to compression which is necessary in order to generate a satisfactory frequency on conversion.

The 'w' command may in fact be used with all programs to display the contents of the first 127 bytes of storage memory. Likewise, entering 't' will recall the spectrum display of the current synthesised waveform. The command 'p' for print can also be used to print out the TV screen display at any time the inverted comma prompt is showing.

The synthesise routine is principally educational and offers an excellent opportunity to demonstrate the sounds produced by different waveforms, many of which may not be readily available using analogue equipment. Try the following:

a. harmonic amplitudes of 203,0,68,0,41 and phases of 0,0,0,0,0: Figure G

b. harmonic amplitudes of 203,0,68,0,41 and phases of 0,0,180,0,0: Figure H

c. harmonic amplitudes of 324,0,36,0,12.8 and phases of 0,0,180,0,0: Figure I

Note that the frequency spectrum of the waveform in Figure G is exactly the same as that in Figure H. Does the latter sound more like a square wave or is it closer to the triangle waveform of Figure I?

The synthesise routine may also be extended to the most common technique of analogue synthesis, namely, generating a waveform of high harmonic content such as a sawtooth or pulse and then modifying the harmonics by filtering. The effect of a 24dB/octave low pass filter can be quickly examined after any synthesis by using the filter on the digital to analogue controller. The frequency measurement routine from DIGISCOPE 3 is also available with the current programs and this allows the cut-off frequency of the filter to be determined when required. The latter is done by connecting 'f TEST' on the D to A Controller to the '+ GATE' on the A to D Controller (make sure the gate select switch is on +), switching the filter into oscillation and entering 'f'. The frequency is displayed on the TV screen and continually updated so as to allow precise setting of filter frequency.

By using numbers, however, we are able to simulate any type of filter. We can even examine effects which are beyond the capabilities of most analogue synthesisers, for example, the effect of a super notch filter capable of completely removing a harmonic. This is easily achieved by entering zero for the amplitude of the harmonic to be removed and Figure J shows the sawtooth waveform of Figure F with the second harmonic removed, which makes it look more like a square wave. More conventional filters can also be simulated by reducing the amplitude by the cut-off rate. Thus a 12dB/octave filter will remove successive harmonics beyond the cut-off frequency by -12dB, -24dB, -36dB and so on.

To calculate what this means in decimals use the formula 1/antilog(dB/20) and so -12dB necessitates multiplying by 0.251; -24dB by 0.063; and -36dB by 0.016. Using our earlier example of a sawtooth with amplitudes of 318, 159, 106, 79.5 and 63.5 and a 12dB/octave low pass filter set above the second harmonic yields new amplitudes of 318, 159, 26.6, 5 and 1 and the resultant waveform is illustrated in Figure K. Substituting a 24dB/octave low pass filter yields amplitudes of 318, 159, 6.7, 0.3 and 0 and the waveform is shown in Figure L. Both waveforms still show a marked sawtooth shape and this is another example of sound being more relevant than shape since the two are audibly quite different — with the 24dB/octave filter the 4th harmonic is some 60dB down on the fundamental and the 5th harmonic is absent.

Hopefully the above examples illustrate the power and usefulness of Fourier synthesis. The main problem when using the technique for comparing the sound of different waveforms is that some minutes elapse between samples which makes such comparisons difficult. Although the waveforms may be recorded digitally using the 'save' program it will probably prove simpler to make conventional tape/cassette recordings of the sounds and to compare them later by sequential playback. First, however, we have to get the data converted into analogue form and three such playback methods are available. These are: 'i' which provides a single shot replay; 'h' which is called 'pitch shift' and is a continuous replay routine, and 'z' which is a sequencer program. In this article we will describe the 'h' (continuous replay).

After entering 'h' you will be successively prompted with three questions: (a) transpose?, which is any whole number between 1 and 255 and this response determines the frequency of the waveform on playback. From 'synthesise' a value of 1 will give a frequency of 1264Hz, 10 gives 542Hz and 50 yields 153Hz. The higher the number the lower the frequency and so the longer it will take to play out a given length of memory; (b) length?, which means the length of memory to be played back before returning to the beginning of the memory and starting again. The value can be any number up to 30,000 and generally the higher the value the better.

The reason for this is that the analogue voltage equivalent for the last byte in storage memory may not be the same as for the first byte in memory and so each time a new cycle commences an audible 'glitch' may occur and the time between glitches will be longer the higher the length entered. In fact this glitch may be eliminated by slightly altering the length of memory so that the start and end of the waveform will be the same. A length of 29,850 with a synthesised waveform will give a noticeable improvement and this could be improved with a little experimentation (patience!).

(c) forwards or backwards?, which is obviously the capability to play the contents of memory either forwards or backwards. This is useful with some other forms of signal processing but playing our sawtooth waveform backwards means that the voltage will ramp up instead of down.

After entering 'f' or 'b' for the last response, the contents of memory will De continuously played back through the digital to analogue converter and the output filter should be adjusted for the best signal to noise ratio. Pressing the 'HOLD' button on the D to A Controller will stop the playback and put up the inverted commas prompt.

In the next issue we will complete the description of the routines in DIGISOUNDER 3 as well as covering outstanding matters from earlier articles.

*For sales and technical information relating to hardware and software for this series please contact Digisound Limited, (Contact Details).*

Read the next part in this series:

Digital Signal Processing (Part 4)

**Computer Musician**

Topic:

Series:

Part 1 | Part 2 | Part 3 (Viewing) | Part 4

*Feature
by Charles Blakey, Steve Thornton, David Hall*

mu:zines is the result of thousands of hours of effort, and will require many thousands more going forward to reach our goals of getting all this content online.

If you value this resource, you can support this project - it really helps!

*New issues that have been donated or scanned for us this month.*

*All donations and support are gratefully appreciated - thank you.*