22.09.2015 Views

of Microprocessors

Musical-Applications-of-Microprocessors-2ed-Chamberlin-H-1987

Musical-Applications-of-Microprocessors-2ed-Chamberlin-H-1987

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

116 MUSICAL ApPLICATIONS OF MICROPROCESSORS<br />

distinct loss <strong>of</strong> bass is the result. Also, any power line hum in the recording<br />

will be reproduced at a much more audible 120 Hz.<br />

As mentioned earlier, the low-pass filter following the DAC is critical.<br />

One might think that if the sample rate is above 40 ks/s a filter is not needed<br />

at all, since all unwanted frequencies are above the audible range anyway.<br />

However, since these frequencies are so strong, they can easily mix with the<br />

bias oscillator in an audio tape recorder and result in audible beat notes.<br />

Thus, a filter <strong>of</strong> at least moderate effectiveness is required with high sample<br />

rates. The filter becomes more critical at the lower sample rates 'used for<br />

experimentation because these unwanted frequencies are audible and sound<br />

terrible. Sharp cut<strong>of</strong>f low-pass filter design will be discussed in detail in<br />

Chapter 12.<br />

Computation <strong>of</strong> Sound Waveforms<br />

Now that it has been established that computers can generate sound <strong>of</strong><br />

the highest quality directly, the next topic <strong>of</strong> interest is the techniques used<br />

for computing sound waveforms. Although one could theoretically sit down<br />

at a computer console and type in sample values, just about anything that<br />

could be done without recourse to a pocket calculator would sound like white<br />

noise on playback. The problem is similar to the one experienced when<br />

drawing waveforms directly onto movie film. Of course, this does not even<br />

address the difficulty <strong>of</strong> providing tens <strong>of</strong> thousands <strong>of</strong> samples for every<br />

second <strong>of</strong> sound output.<br />

In this section, a general overview <strong>of</strong> practical methods <strong>of</strong> sound<br />

waveform computation will be presented. A more detailed description <strong>of</strong><br />

these techniques and others along with example programs will be given in<br />

Section III.<br />

Sin and Other Built-in Functions<br />

An obvious method <strong>of</strong> generating a single sine wave with a computer is<br />

to use the sin function found in nearly all high-level programming<br />

languages. The general expression for the Nth sample <strong>of</strong> a sine wave <strong>of</strong><br />

frequency F and the amplitude A is Sn = Asin(2'TrFTIFs), where T is time in<br />

seconds and Fs is the sample rate in samples per second. Since time and<br />

sample number are directly proportional and the sample rate is constant,<br />

considerable computer time may be saved by defining a constant K = 2'TrIFJ<br />

and using the form Sn = Asin(KnF). Samples for the sine wave are computed<br />

simply by defining values for the variables A and F and then evaluating the<br />

expression for sample numbers 0, 1, 2, up to M, where MIFJ is the duration<br />

in seconds desired for the wave.<br />

Of course, during the calculations the values <strong>of</strong> A and F can change.<br />

Often separate expressions that are also evaluated every sample time determine<br />

the value <strong>of</strong> A and F to be used in the "tone generation" expression

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!