Archived

This topic is now archived and is closed to further replies.

Do any games factor in the speed of sound?

This topic is 5015 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was thinking the other day about how sound doesn''t travel at instantaneous speed (obviously) but I think most if not all games model it this way. As an example: Imagine you are standing on a virtual mountain and about 1 KM away an apache helicopter gets hit by a missile and crashes into the ground. You see the helicopter crash into the earth and explode in a fiery explosion. You also hear this explosion as you are seeing it explode. This is the scenario most game engines would do, but in reality you would hear the explosion shortly after seeing the explosion. Does anyone know if any games (or game engines) actually take this type of thing into consideration? I was thinking of modifying my engine to create a sound sphere which would increase in diameter at the speed of the sound, and when that sphere first enveloped a listener, the sound would be instructed to be played.... I dont know if it is worth the effort, but I figure if noone else does it, then maybe I will just to be the first Also, anyone else have an alternative method of implementing this effect? A naive approach would be to get the position of the listener and the position of the sound and precalc how long it would take the sound to reach the listener and then just tell the sound subsystem to start playing the sound in X seconds from now, but this wouldnt handle the case properly in situations where the listener suddenly starts moving towards the sound or perhaps even instantly changes location via a mechanishm such as teleporting or what not. I think my sphere case above would handle that. Well I called it a naive approach, it is actually probably a fairly good approach if you dont mind it not working in some cases. Alternatively, you could create a ton of sound particles and then make them radiate outward from the source and they could be put through collision detection so it would also support occlusion and perhaps even reverberation but I suspect that might suck up a lot more cpu than it is worth... Jeff

Share this post


Link to post
Share on other sites
I personally don''t know any game that does this. The reason for this is that perhaps most of the games don''t envolve great distances in their worlds. For example, in a fps, you see things "in your face" and most worlds don''t have more than a "square mile" in it.

Another reason might be the fact that certain effects, although fisically correct, might look strange to the person playing the game. For example, those movies where there are explosions in space and you can ear them. Although this is fisically incorrect, it seems much more natural to us then not earing a thing when the ship in front of us just explodes. Sometimes fiction feels more realistic than reality.

Share this post


Link to post
Share on other sites
operation flashpoint and ofp: resistance by codemasters do this but i dont know how they implement it. you can shoot something from say 800 meters and see the explosion and then a second passes and you hear the boom. i havent heard of any others.

Share this post


Link to post
Share on other sites
Battlefield 1942 seems to do this with artillery explosions, but I'm not sure how realistic the delay is.

Also, Mechwarrior II seemed to do this, but that's an old one.

Implementing it is easy. You just set up a timed sound play event with location parameters and play the sound when the timer elapses. It gets more complicated if NPC's can be alerted by sounds. Each of them would need a separate timer for realism.

EDIT: Expanding sound spheres would work too, but might be overkill calculation-wise, especially if noone in the area is travelling fast enough for it to make much of a difference.


[edited by - Waverider on March 24, 2004 9:10:15 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I''d have thought the simpler way would be just as good; after all the player will surely move a negligable distance in the time the sound takes to reach him - assuming he''s moving at a realistic speed

Share this post


Link to post
Share on other sites
Extreme-G 2+3 sorta did this. When you drove above the sound barrier, the music would fade out and get really quiet. Then when you drop back down it would come back with a KABOOM!

Share this post


Link to post
Share on other sites
This is how most (or every) 3D sound libraries work. If your using headfones, it calculates the distance of the sound to each ear and plays the sound at the correct time. If your in a 5.1 enviroment, it takes 5 calculations

Hope this helps,


JVFF

Share this post


Link to post
Share on other sites
quote:
Original post by AndreTheGiant
I think RTCW did this.
Sometimes if you were getting shot by a sniper from super far away, you would loose health and about 1 second later you would hear the gunshot.


Indeed, and it was a nice effect. You could see the flash of the sniper rifle in the tower, and the report came a short time later. I don''t know how accurate it was, but then again I''ve never been shot at with a Mauser rifle at a great distance.

That game had great sound effects all the way around.

Share this post


Link to post
Share on other sites
The MMOG "WW2 Online" uses the speed of sound to great effect (in fact, it makes it really immersive). When you hear an explosion you can pretty much judge how far away it was due to the way the sound also distorts over the distance. Gun fire becomes simple cracks (if you ever watch actual war footage on the news you''ll know what I mean by that). So if you are running towards a battle and see flashes of light and hear the crack of gunfire, it really makes you feel you are there.

Share this post


Link to post
Share on other sites
I think a new flight sim called "Lock On" did it. Basically if you flew above mach 1 and were in an external view outside of the "cone" you wouldn''t hear anything - at least not the plane engine anymore.

Share this post


Link to post
Share on other sites
Actually I suspect that many of the games that use real-time doppler etc. (ie. Battlefield to name one) probably do this to extent, because the calculations would be similar... can''t say for sure but I suspect a few do, but we just don''t notice

My guess would be that this type of thing will become completely the realm of the sound hardware in future years... ie. I will tell DirectSound to play this sound, as if it was coming from this exact position in space, relative to where I am. It will figure out all the other fun stuff

Share this post


Link to post
Share on other sites
3D audio cards already do this - they definetly do doppler shift etc... and I think the result of the correct convolutions is a gross atenutation (silencing) of the audio that works out to the speed-of-sound calculation.


There already is a 3D portion to DirectSound too.

Share this post


Link to post
Share on other sites
This would be an absolute nightmare to implement on your own, I would imagine. Using your sound sphere idea, you'd have to store a list of players for every sound. If someone is inside the sphere, you can't play the sound over and over again. And you can't assume that a player isn't going to be moving into the sphere anytime soon (if you implement some sort of teleportation method).

Also if you teleport right beside the object, you're in the sphere but the sound has already travelled passed you and thus you can't hear the sound anymore, you'd have to be at the edge.

I'd call it a nightmare not worth the effect =P


[edited by - GroZZleR on March 24, 2004 9:29:50 PM]

Share this post


Link to post
Share on other sites
I''m pretty sure both OpenAL and DirectSound are capable of dealing with those effects, so you shouldn''t have to code it yourself anymore People have already mentioned some very good games that make use of it.

Share this post


Link to post
Share on other sites
There''s a difference between doppler/localization, and start delay because of propagation. Most sound APIs do the first, but not the second; you have to do that yourself.

The best way of doing it is probably to just queue an event to play the sound in the future. If you move really quickly towards the sound source, the event will start too late, but that''s probably acceptable.

Also, sound is really quite pokish in air (about 340 m/s) -- you probably want to model sound that travels faster, for increased gaming enjoyment.

Share this post


Link to post
Share on other sites
it shouldn''t be that hard ... just hand a specialized event to every actor that can "hear", a structure that holds the origin, the velocity of the wave (if it isn''t constant), the velocity of the source (if it isn''t a sudden, point sound), and the time of the sound''s generation. If the actor''s distence is within the sound''s range, the event resolves and gets cleared. Kinda like a mousetrap. You should then have the distence, both velocities for the dopler, and a convenient way to store any additional agent data.
If you want to get really complicated, have the sound do a variation on raycasting -- deteremine vectors that will end up reflecting off various surfaces, and generating new sound objects that are virtually behind that surface. Look at a mirror and gauge where an object appears to be, behind the mirror, against where it is, for a real-life example.
Generating echos based on surfaces *without* tracing if it''ll actually be heard first would likely cause too much overhead. Rather than one check per sound per cycle, it''d be one check per sound one face per cycle. Ouch.

-"Sta7ic" Matt

Share this post


Link to post
Share on other sites