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.

764 MUSICAL "ApPLICATIONS OF MICROPROCESSORS<br />

0061 0748 CA DEX DECREMENT AND CHECK TEMPO COUNT<br />

0062 0749 D005 BNE CHORD2 BRANCH TO TIME WASTE IF NOT RUN OUT<br />

0063 074B C609 DEC DUR DECREMENT AND CHECK DURATION COUNTER<br />

0064 074D DOB3 BNE CHORDO GO RELOAD TEMPO AND CONTINUE IF 0<br />

0065 074F 60 RTS ELSE RETURN IF DURATION RAN OUT<br />

0066 0750 EA CHORD2 NOP EQUALIZE LOOP TIME BETWEEN RELOAD<br />

0067 0751 EA NOP TEMPO AND NOT RELAOD TEMPO<br />

0068 0752 4C0407 JMP CHORD1<br />

Fig. 20-2. Simplified four-voice waveform table scan for 6502 (cant.)<br />

R-C filter or a judiciously selected wo<strong>of</strong>er-type speaker can usually provide<br />

sufficient low-pass filtering. Once an audio DAC is present, whether it be in<br />

a game or a personal computer, the sounds producible are limited only by the<br />

imagination and skill <strong>of</strong> the programmer.<br />

The most straightforward synthesis algorithm to use is waveform table<br />

scanning. Typically, the waveform table will be 256 entries with 8 bits per<br />

entry and no interpolation. For 6502 and similar microprocessors, the<br />

general scheme illustrated in Fig. 13-4 can be used to scan the waveform<br />

table. In fact, a complete routine capable <strong>of</strong> producing four simultaneous<br />

tones at a sample rate <strong>of</strong>8.33 ks/s (for a I-MHz 6502) requires only 85 bytes.<br />

Such a routine is listed in Fig. 20-2. It is called with the 16-bit<br />

frequency parameters for the four voices (zero is used for silence) stored in<br />

FREQI-FREQ4, a duration parameter stored in DUR, and a tempo<br />

parameter stored in TEMPO. The number <strong>of</strong> samples produced before<br />

returning is the product <strong>of</strong> TEMPO and DUR. Note that the four voice<br />

samples are mixed by presenting them successively to the D-to-A converter<br />

rather than adding them up. This avoids scaling and as written makes the<br />

fourth voice somewhat louder than the other three due to its increased dwell<br />

time. In effect, the low-pass filter performs the mixing function. With a<br />

smooth waveform stored in the table (to avoid aliasing <strong>of</strong> high harmonics),<br />

the routine is very effective in producing four-part organ music with just a<br />

hint <strong>of</strong> roughness due to the short table and programming shortcuts taken.<br />

In fact, including a Fourier series routine to compute the waveform table<br />

(perhaps from random harmonic amplitudes) requires just a couple <strong>of</strong><br />

hundred additional bytes.<br />

Other synthesis techniques have also been used in a similar context.<br />

Most 8-bit microprocessors are capable <strong>of</strong> producing one or two FM or<br />

nonlinear waveshaping voices. The VOSIM alogrithm has even been used to<br />

produce remarkably good synthesized speech, in real time, with nothing<br />

more than the audio DAC and some exceptionally clever programming. The<br />

increasing use <strong>of</strong> 16-bit internal architecture microprocessors with multiply<br />

instructions in even cost-sensitive products will extend further what can be<br />

done with two to three dollars worth <strong>of</strong> sound generation hardware.

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

Saved successfully!

Ooh no, something went wrong!