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.

676 MUSICAL ApPLICATIONS OF MICROPROCESSORS<br />

a fixed argument array size <strong>of</strong>, say 32 bytes will be used for all Level 1<br />

routines.<br />

Figure 18-9 shows one possible way to arrange the five arguments into<br />

fields within the 32-byte sound control block. With the 6502,68000, and most<br />

other microcomputers, indexed addressing can be used to quickly access the<br />

fields in the sound control block. One simply loads the address <strong>of</strong> the control<br />

block passed by the caller into a register and then uses fixed <strong>of</strong>fsets to access<br />

the data. In a machine without indexed addressing, such as the 8080, the<br />

control block can be copied into a fixed memory area, the samples computed,<br />

and those descriptor elements changed by the execution (such as the table<br />

pointer) copied back. Alternatively, the order <strong>of</strong> the fields within the block<br />

can be carefully sequenced so that increment index instructions can be used<br />

to scan through them.<br />

The initial byte <strong>of</strong> activity flags is used by the upper level routines to<br />

keep track <strong>of</strong> which control blocks are actually generating sound. The sound<br />

10 byte identifies which Level 1 routine the control block is formatted for.<br />

The wave table address is the address <strong>of</strong> the first entry <strong>of</strong> the waveform table<br />

being used. The wave table pointer is shown as a 32-bit value, which consists<br />

<strong>of</strong> a 22-bit fractional part and a lO-bit integer part. The integer part is added<br />

to the wave table address to actually get a sample. The frequency parameter is<br />

also shown as 32 bits and is the waveform table pointer increment. The<br />

amplitude parameter gives the desired waveform amplitude, while the sample<br />

buffer address indicates where the 30-sample buffer is located.<br />

Figure 18-10 shows a flowchart for the tone generator subroutine.<br />

Essentially, it goes through a sample computation loop 30 times and returns.<br />

Note that the argument giving the address <strong>of</strong> the sample buffer is<br />

incremented during execution. This is desirable and minimizes the overhead<br />

associated with building up large sample blocks for mass storage devices,<br />

such as 3,000 samples for IBM-style magnetic tape. The other calculations<br />

perform standard waveform table lookup without interpolation as described<br />

in Chapter 13.<br />

The percussion generator routine is less straightforward than the tone<br />

generator. In Chapter 15, it was seen that a wide variety <strong>of</strong> mechanisms<br />

produce percussive sounds. Covering all <strong>of</strong> these in a single subroutine is not<br />

practical. Figure 18-11 shows a model that can be used to approximate the<br />

majority <strong>of</strong> common percussive instruments as well as numerous others. The<br />

pulse-excited bandpass filter is used to provide a damped sine wave, while<br />

the white noise source and multimode filter provide filtered noise. Three<br />

gain controls are shown, which allow a noise envelope, the ratio <strong>of</strong> noise to<br />

damped wave, and overall output amplitude to be independently controlled.<br />

For maximum efficiency, amplitude control <strong>of</strong> the damped wave is controlled<br />

by varying the intensity <strong>of</strong> the strike pulse, which only has to be done once,<br />

rather than doing a sample-by-sample multiplication <strong>of</strong> the generator output.

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

Saved successfully!

Ooh no, something went wrong!