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.

762 MUSICAL ApPLICATIONS OF MICROPROCESSORS<br />

0001 0000 ; STRAGE SOUND EFFECT GENERATOR<br />

0002 0000<br />

0003 BFFO PORT $BFFO OUTPUT PORT BITS TO AMPLIFIER<br />

0004 0000<br />

0005 0000 *= 0 SIMULATED REGISTERS IN PAGE 0<br />

0006 0000 0000 REGI •WORD 0 16-BIT OUTPUT REGISTER<br />

0007 0002 0100 REG2 •WORD 1 16-BIT INCREMENT REGISTER<br />

0008 0004<br />

0009 0004 *= $700 PROGRAM ORIGIN<br />

0010 0700 •ENTRY<br />

0011 0700 A500 SSOUND LDA REG1 ADD REG2 TO REG1 WITH<br />

0012 0702 18 CLC RESULT IN REG1<br />

0013 0703 6502 ADC REG2 LOWER BYTE<br />

0014 0705 8500 STA REG1<br />

0015 0707 BDFOBF STA PORT MAKE LOWER BYTE AUDIBLE<br />

0016 070A AS01 LOA REG1+l UPPER BYTE<br />

0017 070C 6503 ADC REG2+l<br />

0018 070E 8501 STA REGl+l<br />

0019 0710 90EE BCC SSOUND REPEAT UNTIL REGI OVERFLOWS<br />

0020 0712 E602 INC REG2 INCREMENT REG2 WHEN REGI OVERFLOWS<br />

0021 0714 DOEA BNE SSOUND AND REPEAT INDEFINITELY<br />

0022 0716 E603 INC REG2+l<br />

0023 0718 DOE6 BNE SSOUND<br />

0024 071A E602 INC REG2 ; DON'T LET REG2=0<br />

0025 071C 4COO07 JMP SSOUND<br />

Fig. 20-1. Sound effects generator<br />

and enter the program into virtually any kind <strong>of</strong> computer. As written, the<br />

sequence <strong>of</strong> sounds repeats every 20 sec on a I-MHz 6502-based computer.<br />

For practical use, as a sound-effects generator, desirable points in the<br />

sequence are determined, and the registers initialized to the corresponding<br />

values. The loop is then run the desired number <strong>of</strong> iterations and terminated.<br />

One difficulty with timed loops is that the microprocessor is fully<br />

occupied while producing sound. Enough time for simple tasks, such as<br />

looking at a control panel, can be taken between notes, however, with little<br />

audible effect. A related problem is that the microprocessor must execute<br />

instructions at a known, stable rate. Computers that stop or interrupt the<br />

microprocessor to refresh memory, for example, would probably produce very<br />

rough sounding tones.<br />

Simplified Direct Synthesis<br />

For much more controlled sound effects and listenable music, many <strong>of</strong><br />

the digital synthesis techniques described in Chapter 13 can be used, in<br />

simplified form, for low-cost sound generation. A common requirement,<br />

however, is a cheap D-to-A converter and a linear power amplifier (the singlebit<br />

timed-loop techniques could use a one-transistor switch). In large<br />

volumes, 8-bit D-to-A converter chips are well under $2, while half-watt<br />

audio amplifier ICs are under a dollar. For really low cost, one can get by with<br />

an 8-bit CMOS register, eight weighted 1% resistors, and a power<br />

Darlington transistor emitter-follower amplifier. In either case, a two-stage

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

Saved successfully!

Ooh no, something went wrong!