> I've never done it. However, I know that there are sound drivers that produce > fairly decent sound out of the PC's cheap speaker. I presume they use some sort > of pulse width modulation scheme and let the speaker's relatively low frequency > response smooth things out. There are two things that you would need to control > to get the 'gentle' waveforms: amplitude and frequency. The pulse width > variation > can control the perceived amplitude, while the pulse frequency controls the > perceived > frequency. It's theoretically possible... PWM is a good way to get nice sounds out of a speaker, BUT your PWM frequency should be higher than your output wave frequency: a pulse-modulated wave will be harmonically very rich and if the harmonics are audible things will sound tinny or worse. Just to illustrate, if your wave goes through the stages: ________--------________--------________-------- ________------__________------__________------__ ________----____________----____________----____ ________--______________--______________--______ the resulting sound will be somewhat wierd at the end (try it--you might always like it). If you want a more bell-like sound, you should do your modulation more like this: ________--------________--------________-------- ________---_---_________---_---_________---_---_ ________-_-_-_-_________-_-_-_-_________-_-_-_-_ ________-___-___________-___-___________-___-___ [preferably with the waves being chopped more finely]. Alternatively, if your only need for PWM'ing is to produce "dings" and if you can conveniently alter the tris'age of your output port pin, you could wire your piezo speaker to the port pin along in parallel with a series RC to ground. PORT PIN------+-------+ R | | Peizo C | | | gnd gnd When your tone is hard-off, set the port pin active high. This will leave the cap charged; most piezos are capacitive and don't pass DC current. When it's necessary to produce a tone, alternate the port between active-low and tristate. As long as the cap has charge, the voltage to the speaker will be set by the cap voltage. As that voltage decreases [which it will probably do more or less exponentially] the piezo will get quieter. The biggest problem with the circuit--remediable with another port pin--is that it's necessary to let the cap charge between tones. If another port pin were wired "directly" to the cap, the cap could be charged quickly bet- ween tones; otherwise charging the cap will take some time. [adding a diode across the resistor might improve this].