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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

418 MUSICAL ApPLICATIONS OF MICROPROCESSORS<br />

One <strong>of</strong> the big problems with the generation <strong>of</strong> tones <strong>of</strong> arbitrary<br />

frequency and waveform is the avoidance <strong>of</strong> alias distortion. As it turns out,<br />

it is quite possible, sometimes unavoidable, to digitally generate a tone<br />

having frequency components above one-half the sample rate. When this<br />

occurs, the higher frequencies are reflected down as lower frequencies that<br />

then sail right through the DAC's low-pass filt~r, no matter how sophisticated.<br />

The audible effect is usually harsh distortion or excessive noise, and it<br />

occurs even with single tones. The only way to positively avoid this source <strong>of</strong><br />

alias distortion is to avoid generating significant amounts <strong>of</strong> excessively high<br />

frequencies.<br />

Direct Waveform Computation<br />

One <strong>of</strong> the easiest ways to generate tones digitally is to simulate the<br />

operation <strong>of</strong> an analog voltage-controlled oscillator. In an actual synthesis<br />

program, the "oscillator" would probably be a subroutine that accepts some<br />

arguments (control "voltages") such as one or more frequency parameters and<br />

returr~s one or more results representing samples on one or more output<br />

waveforms. The subroutine would probably also require some carryover storage<br />

from one sample to the next.<br />

The analog VCO that was described in Chapter 6 consisted <strong>of</strong> three<br />

major parts: control input acquisition, the sawtooth oscillator proper, and<br />

waveshaping circuits. A digital equivalent will require the same setup. Concentrating<br />

on the oscillator part, it was seen to consist <strong>of</strong> a current source, an<br />

integrator, a comparator, and a discharge (reset) circuit. Fortunately, the<br />

digital equivalents to all <strong>of</strong> these are exceptionally simple and, most important,<br />

require very little computation time.<br />

Digital Sawtooth Oscillator<br />

An integrator is an accumulator, somewhat like a bucket that integrates<br />

the flow rate <strong>of</strong> water entering it. A computer accumulator is also an<br />

integrator;. it accumulates discrete-sized "pieces" represented by numbers<br />

added to it via the "add" instruction. When a bucket overflows, it remains<br />

full and only the excess water is lost. When an accumulator overflows, its<br />

entire contents are dumped and integration starts anew. Thus, it should be<br />

apparent that if one considers a number that is repeatedly added to a computer's<br />

accumulator to be a "current," the accumulator contents to be the<br />

integrator's output, and the overflow phenomenon <strong>of</strong> binary arithmetic to be<br />

a combination comparator/discharge circuit, one has a sawtooth oscillator<br />

just like the analog one.<br />

This can be clarified by examining the program segment below, written<br />

in 6502 assembly language:

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

Saved successfully!

Ooh no, something went wrong!