designing PWM sounds

How would one go about creating a specific sound effect for crude piezo PWM playback. I am specifically trying to make the sound of an explosion.

how did they do it back in the day on the game & watch for example.

I really want the piezo, not a wave shield.

fubbi

I've seen people make the arduino play small sound samples, or you could maybe make an unrealistic chiptune-sounding explosion. Or,if you are just avoiding the waveshield because of cost, you could buy a cheap voice recording thing (I think they have little boards that do that at radioshack) and use the arduino to trigger it. As simple as turning on a pin.

Hey

I am specifically looking for the "unrealistic chiptune-sounding explosion"!

How do I go from sound to code though? or is maybe there a chip I should work with here?

Thanks

fub

I am specifically looking for the "unrealistic chiptune-sounding explosion"!

You get a burst of noise if you just feed the PWM chip with random numbers. That sounds like an explosion, well to a first approximation.

How do I go from sound to code though?

I assume you mean from code to sound. Simple loop for N samples, output a random number to the PWM and delay. As the default PWM frequency is in the region of 600 HZ you will get better results if you up the frequency to something like 10KHz. Then make your delay equal to a PWM cycle.

or is maybe there a chip I should work with here?

Chips will produce a better sound, See:- http://www.arduino.cc/playground/Main/InterfacingWithHardware#audio_generation