Playing sounds at half the volume

Playing sounds at half the volume

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

Playing sounds at half the volume

Post by colorblind »

Sean Mirrsen wrote:(...) unit replies that are always full volume when on screen, and half volume when off screen, just as it was in TA. (Check this post for the quote)
This is also how I'd like to see it, and I'm almost done coding it. There's one problem left: I can't get sounds to play at half the volume.

Full volume is no problem; you just use the CSound::PlaySound(int id) function. But I can't figure out how to get exactly half the volume with the CSound::PlaySound(int id,const float3& p,float volume) function. The volume float doesn't behave as I would expect (0=no volume, 1=full volume). But no, it gets multiplied with strange numbers and divides the volume you end up with ... sigh ... I'm sure it's logical and all, but I just don't get it.
Any info on how it behaves and how to get the "half volume thing" working is appreciated.

As a sidenote I might poll what unit sounds should be played at what volume. Imho greater audibility of important sounds leads to greater playability.
According to UnitDef.h there are 10 unit sounds:

Code: Select all

	struct SoundStruct {
		GuiSound select;
		GuiSound ok;
		GuiSound arrived;
		GuiSound build;
		GuiSound repair;
		GuiSound working;
		GuiSound underattack;
		GuiSound cant;
		GuiSound activate;
		GuiSound deactivate;
	};
I currently got the "ok" sound working at full volume onscreen. Should any of the others also be changed?
Post Reply

Return to “Engine”