It is a rectangular wave and you determine the length of the pulse cycle by defining the proportion of the wave which will be high. This is accomplished for voice 1 by using registers 2 and 3: Register 2 is the low byte of the pulse width (Lpw = 0 through 255). Register 3 is the high 4 bits (Hpw = 0 through 15).
Together these registers specify a 12-bit number for your pulse width, which you can determine by using the following formula:
PWn = Hpw*256 + Lpw
The pulse width is determined by the following equation:
PWout = (PWn/40.95) %
When PWn has a value of 2048, it will give you a square wave. That means that register 2 (Lpw) = 0 and register 3 (Hpw) = 8. Now try adding this line to your program:
Then change the start number in line 70 to 65 and the stop number in fine 90 to 64, and RUN the program. Now change the high pulse width (register 3 in line 15) from an 8 to a 1. Notice how dramatic the difference in sound quality is?
The last waveform available to you is white noise (shown here).
It is used mostly for sound effects and such. To hear how it sounds, try changing the start number in line 70 to 129 and the stop number in line 90 to 128.
When a note is played, it consists of a sine wave oscillating at the fundamental frequency and the harmonics of that wave.
|This page has been created by Sami Rautiainen.|
|Read the small print.||Last updated February 10, 2002.|