LINE-BY-LINE EXPLANATION OF EXAMPLE PROGRAM 1:
|5||Set S to start of sound chip.|
|10||Clear all sound chip registers.|
|20|| Set Attack/Decay for voice 1 (A=O,D=9).|
Set Sustain/Release for voice 1 (S=O,R=O).
|30||Set volume at maximum.|
|40||Read high frequency, low frequency, duration of note.|
|50||When high frequency less than zero, song is over.|
|60||Poke high and low frequency of voice 1.|
|70||Gate sawtooth waveform for voice 1.|
|80||Timing loop for duration of note.|
|90||Release sawtooth waveform for voice 1.|
|100||Return for next note.|
|110-180||Data for song: high frequency, low frequency, duration (number of counts) for each note.|
|190||Last note of song and negative Is signaling end of song.|
Chip register 24 contains the overall volume control. The volume can be set anywhere between 0 and 15. The other four bits are used for purposes we'll get into later. For now it is enough to know volume is 0 to 15. Look at line 30 to see how it's set in Example Program 1.
Sound is created by the movement of air in waves. Think of throwing a stone into a pool and seeing the waves radiate outward. When similar waves are created in air, we hear it. If we measure the time between one peak of a wave and the next, we find the number of seconds for one cycle of the wave (n = number of seconds). The reciprocal of this number (1/n) gives you the cycles per second. Cycles per second are more commonly known as the frequency. The highness or lowness of a sound (pitch) is determined by the frequency of the sound waves produced.
The sound generator in your Commodore computer uses two locations to determine the frequency. Appendix E gives you the frequency values you need to reproduce a full eight octaves of musical notes. To create a
|This page has been created by Sami Rautiainen.|
|Read the small print.||Last updated February 10, 2002.|