Advertisement

PCM basics

Started by February 09, 2006 03:28 AM
4 comments, last by Kylotan 18 years, 10 months ago
I'm sure this is an obvious FAQ, but I can't find an explanation anywhere. What's the logic when sounds should use negative values in the PCM (Wav file) format. I understand something artifical like a sinewave has to be based around some point so that might as well be zero. But what is the logic for real world sounds going negative. For something like a car engine sound that I asked about earlier here I would have thought all ignitions would be spikes on the positive side of the scale, yet looking at recordings of engine sounds there generally seem to be an equal number of positive and negative spikes. If I do something like alternate cylinder ignitions between positive and negative I then get a problem when they overlap and cancel each other out. So currently I've got everything positive, it sounds ok, but it strikes me as wrong because that's simply not how the real life recordings come out.
<a href="http://www.Oval-Racer.com&lt;/a>
The waveform in a PCM stream is analogous to the voltage transmitted by the microphone, which is analogous to the movement of the microphone diaphragm, which is analogous to the movement of the sound waves interacting with it.

If you bang a large flat surface does it move up and down around its resting position or does it only move between its utmost position and rest? Of course, it moves up and down around resting position (or 0) and the air around it moves analogous to this movement which will move your eardrum, or a microphone diaphragm, analogous to its movement.

Jumping on a trampoline; when it sends you flying upwards will the surface of the trampoline stop flat, at its resting position, or will it vibrate up past this?

It's not that artificial sounds must be based around some point, it's that all sounds are based around some point because vibration, and the transmission of kinetic energy (sound waves), inherently involves going backwards and forwards. If you make all your sounds happen in the positive side of the axis then the speaker cone will still have to go backwards and forwards, all you've done is move its origin (and given it an impossible sound to accurately replicate).

Cheers,

K
Advertisement
Thanks, the logic of all that makes sense. So for something like my engine sound would I be right in making each ignition cause a positive spike, but instead of just letting these drop down to zero and stop, I should actually be letting them fall back down past zero and back up, with possible additional oscillations before totally fading out.

<a href="http://www.Oval-Racer.com&lt;/a>
The sound of an engine is a very complex waveform - synthesising one from scratch is beyond me...

You've rightly identified that an engine gets its frequency/pitch/note from the number of combustions per second. Some game car engine synthesisers make use of this fact by using granular synthesis; an engine sample is dissected in to its individual "combustions" and these are played back at the appropriate speed to replicate the car engine changing in pitch. One of the most important steps in getting a good sounding car engine in a game is having it hooked up to a well tuned physics system. Great samples or synthesis are wasted if it is getting sent bad info from the physics.

As for the behaviour of the waves - it's complicated stuff. If you add a 1KHz sine wave to a 1Hz sine wave you end up with a hybrid of the two. Similarly, the noisy/chaotic aspect of engine combustion ensures that the waveform has a whole lot more in it than just lots individual "spikes" - every part of the car is vibrating and that creates an enormously complicated waveform. I'd say you could describe an engine as controlled chaos - that's also an excellent description for the sound one produces!
Here's what I've come up with so far, not bad considering it's all generated on the fly on a phone, even sounds better on the phone than it does on a pc and is ahead of anything else I've heard from phone games.

Rookie 4-Cyl

Racer 6-cyl

Elite 8-cyl

Trackside pack of cars going past, mixes 4 loudest engine sounds together:
Trackside
<a href="http://www.Oval-Racer.com&lt;/a>
That's pretty effective. :)

This topic is closed to new replies.

Advertisement