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.

666 MUSICAL ApPLICATIONS OF MICROPROCESSORS<br />

0353 210E 83<br />

0354 2116 8A<br />

0355 211E 96<br />

0356 2126 A6<br />

0357 212E B9<br />

0358 2136 CF<br />

0359 213E E7<br />

0360 2146 00<br />

0361 214E 19<br />

0362 2156 31<br />

0363 215E 47<br />

0364 2166 5A<br />

0365 216E 6A<br />

0366 2176 76<br />

0367 217E 7D<br />

0368 2186<br />

0369 2186<br />

o ERRORS IN PASS 2<br />

.BYTE $83,$83,$84,$85,$86,$87,$88,$89<br />

.BYTE $8A,$8B,$8D,$8E,$8F,$91,$93,$94<br />

.BYTE $96,$98,$9A,$9B,$9D,$9F,$A2,$A4<br />

.8YTE $A6,$A8,$AA,$AD,$AF,$B2,$B4,$B7<br />

.BYTE $B9,$BC,$BF,$Cl,$C4,$C7,$CA,$CD<br />

.BYTE $CF,$D2,$D5,$D8,$DB,$DE,$El,$E4<br />

.BYTE $E7,$EA,$EE,$Fl,$F4,$F7,$FA,$FD<br />

.BYTE $00,$03,$06,$09,$OC,$OF,$12,$16<br />

.BYTE $19,$IC,$IF,$22,$25,$28,$2B,$2E<br />

.BYTE $31,$33,$36,$39,$3C,$3F,$41,$44<br />

.BYTE $47,$49,$4C,$4E,$51,$53,$56,$58<br />

.BYTE $5A,$5C,$5E,$61,$63,$65,$66,$68<br />

.BYTE $6A,$6C,$6D,$6F,$71,$72,$73,$75<br />

.BYTE $76,$77,$78,$79,$7A,$7B,$7C,$7D<br />

.BYTE $7D,$7E,$7E,$7F,$7F,$7F,$7F,$7F<br />

.END<br />

Fig. 18--7. Waveform table filler (cant.).<br />

sidered with smaller values giving faster computation. The scaling logic<br />

assumes that NHARM is never greater than 16, although this can be extended<br />

by modifying the scaling computation or restricting the amplitude<br />

sum to less than 16.<br />

Looking closer at FSEVAL, it is seen that the product <strong>of</strong> a harmonic<br />

amplitude and a sine table entry is a full 16 bits. To avoid almost certain<br />

overflow when other harmonics are added in, the product is shifted right four<br />

times, which effectively moves the binary point between bits 11 and 10. This<br />

increases the range to 16 and reduces the resolution to 1/2,048. The increased<br />

range positively insures against overflow for up to 16 harmonics.<br />

In scale, only the most significant byte <strong>of</strong> the 16-bit samples produced<br />

by FSEVAL is examined. Peak determination is by comparing the absolure<br />

value <strong>of</strong> the upper sample bytes with a current maximum, which is kept in<br />

MAX. This maximum is incremented by one before returning. Note that the<br />

binary point position <strong>of</strong> MAX is between bits 3 and 2.<br />

The FILL routine normalizes the samples by simply dividing the 16-bit<br />

sample returned by FSEVAL by MAX. Since the binary points are in equivalent<br />

positions, the point position for the quotient will be between bits 6 and<br />

7, making it a signed fraction ready for storage in the waveform table.<br />

Incrementing MAX by one in SCALE is required to avoid overflow in the<br />

division, which would occur when the peak point is divided by itself. U nfortunately,<br />

this action also introduces an error that reduces the scaled<br />

amplitude somewhat. Large values <strong>of</strong> MAX minimize this error, however.<br />

Thus, when a harmonic spectrum is prepared, the strongest harmonic should<br />

be given an amplitude <strong>of</strong> 0.996 (O.FF). A 16/32-bit arithmetic package<br />

would reduce the error to insignificance but would be about three times<br />

slower on the 6502. It is important to note that this error is only an<br />

amplitude error; it does not introduce excess noise beyond that due to the<br />

lower amplitude. Also note that only the highest peak is normalized. It is

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

Saved successfully!

Ooh no, something went wrong!