"Sound Shaper" manipulates volume and frequency to give the VIC a smoother, more musical sound. We've also included versions for the 64, Atari, and TI. See the "Automatic Proofreader" article on page 60 before typing in the 64 and Atari versions.
One of the main differences between the sound the Commodore 64 can produce and sound produced by the VIC is the shape of the sound's waveform. The VIC produces only square waves. One microsecond the sound is off, the next it's on. This abrupt onset of sound produces somewhat nonmusical music. The tones sound electronic and unlike any acoustic instrument.
The Commodore 64, on the other hand, can simulate musical instruments by controlling the waveshape of the sound produced. Instead of turning the sound on and off abruptly, it can increase and decrease the amplitude (volume) more gradually under control of the programmer. It is important to bear in mind that the onset-offset or rise-fall time is still on the order of fractions of milliseconds, but it is not instantaneous as is the case with the VIC. It is this programmable rise-fall time that allows the Commodore 64 to sound more like a traditional acoustic instrument. We cannot control the actual waveshape of sounds on the VIC, but we can simulate wave-shaping by modulating the volume.
The first part of Program 1 demonstrates a simple application of this technique. It plays the entire frequency range for one of the VIC's four voices. First, the program asks for two inputs, the rise time and the fall time. Values between .5 and 10 seem to work best. Then the frequency value is POKEd into the appropriate register (line 140). Two separate FOR-NEXT loops (lines 150 and 180) control the rise and fall times. As the volume varies between 0 and 15, the input variables control the rate of volume change. Experiment with different rise-fall time values.
Frequency manipulation can also be used to produce unique effects. The second part of Program 1 shows how to produce an echo effect by rapidly alternating a frequency with its complementary frequency. Again we move through the frequency scale. In line 270 we use the amplitude modulation technique described above. Lines 280 and 300 POKE the frequency and then the frequency subtracted from 383 into the appropriate voice register.
On the first time through the loop, voice 2 (36875) is POKEd with 128 and then rapidly alternated with 255 (255 = 383 -128) while the sound fades as variable DB decreases. The timing loops in 290 and 310 as well as the step value in line 270 can be manipulated to increase or decrease the reverberation effect. Voice 2 was chosen for the example, but any of the four voices will produce interesting sounds.
Notes For 64, Atari, And TI Versions
Since the Commodore 64 has a programmable sound envelope, we added Program 2 to make the SID chip more accessible. By changing values entered for attack, decay, sustain and release, you can control the shape of the sounds produced by the program. The second part of the program produces an echo effect very similar to the effect produced in the VIC version. The parameters set in the first part are also used for the sounds produced in the second part.
The Atari and TI versions of "Sound Shaper" are designed to alter the shape of sounds in the same fashion as the VIC version. Since sound generation in these computers is similar to the VIC's, the logic in these versions is essentially the same as in the VIC version. In the Atari version (Program 3), you may also change the distortion quality of the sound. Since the execution speed differs considerably between TI console and Extended BASIC, users with console BASIC will not hear a smooth shaping of the sounds in the first part of the TI version (Program 4). Extended BASIC provides much better results.