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.

426<br />

MUSICAL ApPLICATIONS OF MICROPROCESSORS<br />

AOORESS OF TABLE ENTRY<br />

,<br />

3 BYTES IN<br />

MEMORY<br />

PAGE NUMBER<br />

Fig. 13-4. Table scanning in an a-bit microprocessor<br />

entries skipped is less than one-half the period <strong>of</strong> the highest significant<br />

harmonic in the tabulated waveform, nothing is lost and no audible noise is<br />

added. If the number <strong>of</strong> entries skipped becomes larger than this, alias<br />

distortion occurS. Also, the fact that each trip around the table is likely to be<br />

different is <strong>of</strong> no significance, since the effect would be the same as sampling<br />

a waveform at a rate that is not an exact multiple <strong>of</strong> its frequency.<br />

As before, only a very few frequencies can be generated with integer<br />

increments, so it will be necessary to extend the precision <strong>of</strong> the increment by<br />

adding afractional part. Now, the pointer increment and the table pointer are<br />

mixed numbers having an integer part and a fractional part. Note that the<br />

fractional part <strong>of</strong> the pointer implies some kind <strong>of</strong> interpolation between<br />

adjacent table entries. For maximum speed, however, the fractional part <strong>of</strong><br />

the pointer can be ignored and the integer part used to select the table entry<br />

as before.<br />

A simple example should clarify this some. Let us assume a moderateperformance<br />

direct synthesis sytem with a sample rate <strong>of</strong> 15 ks/s and<br />

waveform tables having 256 entries <strong>of</strong> 8 bits each. If a tone frequency <strong>of</strong> 220<br />

Hz (A below middle C) is desired, the pointer increment should be 3.75466<br />

according to the formula: I = NFIFs, where I is the increment, N is the<br />

number <strong>of</strong> table entries, F is the tone frequency, and Fs is the sample rate. In<br />

an 8-bit machine, it is convenient to make the pointer and the increment<br />

double-byte mixed numbers with the upper byte being the integer part and<br />

the lower byte being the fractional part. Thus, the decimal mixed number,<br />

3.75466 would have an integer part <strong>of</strong> 3 and a fractional part <strong>of</strong> 193, the<br />

latter being 0.75466 multiplied by 256.<br />

To get the next sample from the table, the increment would be<br />

double-precision added to the pointer with overflow from the integer parts<br />

ignored. Then the integer part <strong>of</strong> the pointer would be used to access the<br />

table. If the microprocessor has an indirect addressing mode through memory<br />

like the 6502, then Fig. 13-4 illustrates how utterly simple these<br />

operations are. A three-byte vector in memory is used for each tone. The<br />

most significant byte gives the page address <strong>of</strong> the waveform table, while the<br />

remaining two bytes are the pointer. An indirect load through the leftmost<br />

two bytes <strong>of</strong> the vector are all that is necessary for the table lookup! In the<br />

6502, the entire operation <strong>of</strong> adding the increment and getting the next

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

Saved successfully!

Ooh no, something went wrong!