Making sounds audible again

Making sounds audible again

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
colorblind
Spring Developer
Posts: 374
Joined: 14 Mar 2005, 12:32

Making sounds audible again

Post by colorblind »

Many feel that the current model for rendering sounds is not quite fit when the camera is zoomed out; see the thread http://taspring.clan-sy.com/phpbb/viewtopic.php?t=1248 for a reference.

Forget the models I proposed there for a moment, 'cause I got a new one (with matching diagram, of course). I suggest that the volume of the sound is determined by how far events are located from the middle of the screen. Here's what it would look like:

Image

The white plane is a portion of the map, and the camera sees everything in within the blue line (I used the approximation that the camera sees a circle, not a square). The purple line is the direction along which the camera looks. Now the bright green dot is the location of a sound event. The green line runs from the the sound event to purple line to which it is perpendicular, and lies in the yellow plane.

In the current situation in Spring the red line (from the camera to the sound event) is used for calculating the volume; I propose we use the green line instead. This way the sounds won't fade away when you zoom out a bit: the volume only depends on how far things are from the center of your screen.

There is a minor problem though: I don't know how to implement this nicely. It can be done with the camera->rot.x and camera->rot.y properties, but I think OpenGL (of which I know absolutely nothing) has a few commands that will come in handy. I'm thinking in the direction of "getting rotation matrix, rotate locations of camera and sound event, calculate the length of the green line," but that's as far as I get.

Any suggestions?
Doomweaver
Posts: 704
Joined: 30 Oct 2004, 14:14

Post by Doomweaver »

Dude, you have got it all wrong.
Use the distance, but when calculating the distance have the 'height' component affect it less than the XY component.
User avatar
[K.B.] Napalm Cobra
Posts: 1222
Joined: 16 Aug 2004, 06:15

Post by [K.B.] Napalm Cobra »

I'm sure there are sound libraries out there that do this sort of carry on.
colorblind
Spring Developer
Posts: 374
Joined: 14 Mar 2005, 12:32

Post by colorblind »

Doomweaver wrote:Dude, you have got it all wrong.
Use the distance, but when calculating the distance have the 'height' component affect it less than the XY component.
I don't think I have (and frankly I believe you haven't given this enough thought).
With my 'solution' you have a "what you hear is what you see" situation, whereas with your idea you can easily hear things coming from the back of the camera. This is of course not necessarily an evil situation, but it's nothing like the thing you had in OTA.

It's all just a matter of taste though. Do we want a soundmodel with which we can hear the things we see, or do we go for the more realistic version in which you don't hear crap? (As you many notice I'm not enterily objective in this part).
User avatar
Delta
Posts: 127
Joined: 09 May 2005, 15:33

Post by Delta »

colorblind, your idea sounds nice, but how does it work in "fps-mode" or in "C" mode?

Then you whant to hear whats around you and not what you are looking at.
colorblind
Spring Developer
Posts: 374
Joined: 14 Mar 2005, 12:32

Post by colorblind »

Good point. Guess we'll have to have 2 soundmodi: one for the TA camera and one for the FPS camera.
Doomweaver
Posts: 704
Joined: 30 Oct 2004, 14:14

Post by Doomweaver »

Guys, we don't need this complexity. In real life you hear sounds from all round! If a plane flies over you, and then is suddenly audible as it's wing brushes the camera's FOV, then that's lame!
You can make it so that we have something more complex than the current distance volume relationship.
If you want, you can say the audibility of a sound is drops of with Height^0.5, or XY distance^2. Because as you have pointed out, if we just make sounds louder than that's fine for zoomed out view, but when you zoom in it's too damn loud.
Infact, you can calculate the area of that blue circle and rig your XY dropoff so that volume only really starts dropping off there. Then, as i said, use the square root of the height distance, so planes are not uber loud. But the key is to treat the XY and Z components differently. The angle your camera is at should not affect how loud stuff is!
colorblind
Spring Developer
Posts: 374
Joined: 14 Mar 2005, 12:32

Post by colorblind »

I'm sorry, but I'm afraid you still don't get it. (And I'm also sorry for the long reply; next time I'll try to write a shorter one).

My proposal was not concerned with 'real life', or making the simulation as real as possible. It is concerned with gameplay. I want to hear the stuff I see. For example: when a unit is at the center of my screen, I want it to have 100% sound volume. But when it is, say, halfway my screen, I want it to have less (say 75%) sound volume. When it's outside my screen, I want it to have significantly less volume.

In order to make this work, you need the angle of the camera. It's the location of the event coordinate system of the camera that's important, not the location in map-coordinates. You have to let go of the standard xyz-coordinates and rotate them to the camera's frame of reference.

Also, you agree to most of 'this complexity', although you formulate things a bit different. I believe my model brings about the 'What You See Is What You Hear'-experience in more straightforward and natural manner than your kind of handwaving approach.

But there's only one way to find out: code it. Concercing that my original question still stands: is there any library or API that already does this kind of thing? I've digged through the DS3D reference, but I couldn't find anything ...
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Post by zwzsg »

The important point is to make sure the dgun sound volume is the same if you're looking at the commander from very far above or if you're inside the commander.

Currently sound is deafening in FPS mode and barely audible in overview. That is what must be fixed. Read the thread this one is a spin-off of.
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Post by SinbadEV »

Image
Basically this is my idea... the distance from your "point on the ground" to camera determines how loud EVERYTHING is, distance from "point on the ground" to sound objects determines how loud those will be in relationship to other sounds...
User avatar
Ace07
Posts: 348
Joined: 21 Apr 2005, 20:46

Post by Ace07 »

I like Colorblind's proposal. I would edit the code and make a patch that the devs can test to see how it works. Then it will get integrated if the SY's think it should.

Also, you will definitely need other models for the different camera modes.
colorblind
Spring Developer
Posts: 374
Joined: 14 Mar 2005, 12:32

Post by colorblind »

zwzsg wrote:The important point is to make sure the dgun sound volume is the same if you're looking at the commander from very far above or if you're inside the commander.
I think that's already been taking care of. The CSound class has multiple functions for playing a sound:

Code: Select all

void PlaySound(int id);
void PlaySound(int id,CWorldObject* p,float volume=1);
void PlaySound(int id,const float3& p,float volume=1);
The first one is used for sounds that you want to have 100% volume, no matter where the camera is. The other two are distance dependent; these are the ones we have to modify.

@Ace07: Thanks. The simplest implementation would probably be to first rotate to the frame of reference of the camera, after which you can simply calculate the length of the green line by subtraction.
I'm only bumped as to what the easiest way of rotation is. You can do this with the camera->rot.x & camera->rot.y properties. But I'm quite sure the properties of the camera are also somewhere stored in an OpenGL variable, and OpenGL probably has some nifty features for point rotation. The thing is I'm not an OpenGL hero ...
User avatar
Delta
Posts: 127
Joined: 09 May 2005, 15:33

Post by Delta »

The first one is used for sounds that you want to have 100% volume, no matter where the camera is.
D-gun, this shuld be altered imo. Anoying almost blowing your speakers everytime there is a d-gun somewhere, shure d-gun shuld be loud, but not THAT loud.

if you start messing with the code, don't forget to so something about this...
Sean Mirrsen
Posts: 578
Joined: 19 Aug 2004, 17:38

Post by Sean Mirrsen »

I completely and absolutely object to "hearing what you see". You should hear what you should hear, not as if you have a directional mic. You don't want to hear gunfire and all the blasts when you're looking at a battle, but you rather want to hear the unit replies. That's my proposition. The system remains as it is (with a limit to maximum sound volume), with the exception of unit replies that are always full volume when on screen, and half volume when off screen, just as it was in TA.
Doomweaver
Posts: 704
Joined: 30 Oct 2004, 14:14

Post by Doomweaver »

Yeah, hearing what you see would I think really take away from the experience.
I mean, generally the camera is looking more or less strait down, so you pretty much would hear what you see if you just used the squareroot method. Because double the distance from the center of the camera in the XY plane means you get half the volume, whearas a unit that rushes by your screen isn't going to blow up the speakers and possibly cause the user a electric shock.
colorblind
Spring Developer
Posts: 374
Joined: 14 Mar 2005, 12:32

Post by colorblind »

Sean Mirrsen wrote:Unit replies (...) are always full volume when on screen, and half volume when off screen, just as it was in TA.
I'm with that. Unit replies are the single most important thing you want to hear, and have to be louder than anything else.

But still, I don't like the current situation where you almost hear no gunfire whatsoever when you're zoomed out. I want that to. (Frankly, I can't imagine why you would want to stick to the current situation.)

Your proposition can be accomodated by my model; you just have to make the distance dependent sound less loud than the unit replies. And that can be easily built in (I think).
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Post by SinbadEV »

ANother glitch that should be looked into, when building a block of buildings (this sometimes locks out the game too so might need other looks at too) it multiplies the confirmation sound volume and just comes out as a loud booming screechy noise...
Sean Mirrsen
Posts: 578
Joined: 19 Aug 2004, 17:38

Post by Sean Mirrsen »

Yeah, I noticed that.

colorblind, I really like the current system. If I remember correctly, there were even mods to remove overly loud repeating sounds (i.e. EMG fire), and now you will only hear gunfire if you really want (and need) to hear it. Maybe make the sound volume be dependant on the XZ coord difference, rather than total distance between sound and camera.... I'm still not sure if I'd like that. A much milder solution would be to reduce sound falloff, maybe even via a slider. So, you will be able to hear gunfire and explosions even from a considerable distance. Unit replies should still be louder than anything else though... and any command given to any number of units should always yield one single reply sound.
Post Reply

Return to “Engine”