Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: strazer on Sun 25/04/2004 04:29:43

Title: Tracker: Adjust volume with scaling / distance
Post by: strazer on Sun 25/04/2004 04:29:43
If you assign (footstep) sounds to a character view, shouldn't they be less audible the farther he is away?
Title: Re:Suggestion: Adjust volume with scaling
Post by: .. on Sun 25/04/2004 10:50:00
That's a good idea. And the same could be applied to talkie games possibly. Where you could have characters talking as they walk off (Muttering Maybe).
Title: Re:Suggestion: Adjust volume with scaling
Post by: Pumaman on Sun 25/04/2004 13:50:20
That's a pretty neat idea, actually.

So it would only apply to view-linked sounds, and only if they were part of a character animation?
Title: Re:Suggestion: Adjust volume with scaling
Post by: strazer on Sun 25/04/2004 13:58:22
Right, the volume would depend on the scaling factor of the character that is using the view the sounds are linked to.
Title: Re:Suggestion: Adjust volume with scaling
Post by: Ben on Sun 25/04/2004 18:00:01
Heh.. I was just thinking about that yesterday. I just put a long, narrow hallway in my game, and thought the character was awfully loud when he was fifty feet away. This would be a great feature :)

Hmm.. I just had an idea. With the repeatedly_execute_always function, you could add an echo at the same time that stays the same volume.. That would bake it even more realistic.
Title: Re:Suggestion: Adjust volume with scaling
Post by: TerranRich on Mon 26/04/2004 17:02:42
Quote from: strazer on Sun 25/04/2004 13:58:22
Right, the volume would depend on the scaling factor of the character that is using the view the sounds are linked to.

1. Would this be possible to do using a workaround code?

2. Don't forget to make it optional for each room, like maybe a global variable (game.footsteps_scaled perhaps?), because there might be a larger room or a room with sizing effects where scaling doesn't necessarily relate to virtal distance from the player.

Know what I mean? :P
Title: Re:Suggestion: Adjust volume with scaling
Post by: strazer on Mon 26/04/2004 17:06:59
1. I wouldn't know how, as you can't seem to assign a certain channel to view-linked sounds, can you? They just play in a free channel.

2. It should be optional, absolutely. I was thinking of making a checkbox for each character?
Title: Re:Suggestion: Adjust volume with scaling
Post by: on Mon 26/04/2004 17:35:40
How about something like:

if (character[EGO].walking == 1) PlaySoundEx (3, 3);

in 'Repeatedly Execute' (where sound 3 is the footstep sound), to force the footsteps into a specific channel, then a series of

if (GetScalingAt(player.x, player.y) == n) {
 SetChannelVolume (3, 50);
}
else if (GetScalingAt(player.x, player.y) == n=1) {
 SetChannelVolume (3, 60);
}

etc., to set the volume. It's not particularly elegant, but it should work.
Title: Re:Suggestion: Adjust volume with scaling
Post by: TerranRich on Mon 26/04/2004 22:14:38
Quote from: Ashen on Mon 26/04/2004 17:35:40
How about something like:

if (character[EGO].walking == 1) PlaySoundEx (3, 3);

in 'Repeatedly Execute' (where sound 3 is the footstep sound), to force the footsteps into a specific channel...

Nah, that wouldn't match the footsteps of the animation. Perhaps a frame check? Something like:

if ( (character[EGO].frame==2) || (character[EGO].frame==7) ) PlaySoundEx(3, 3);

Hmm, good stuff for the Tech Archive.
Title: Re:Suggestion: Adjust volume with scaling
Post by: on Mon 26/04/2004 23:02:29
Yeah, I was worried about it not syncing up. For some reason character[].frame just didn't occur to me, even though I'd read it about 5 times. Funny that. Does it work otehrwise? I haven't had a chance to try it out.
Title: Re:Suggestion: Adjust volume with scaling
Post by: Alynn on Tue 27/04/2004 12:21:30
Could this be expanded to character to character... so if you have multiple characters in the room, say a scrolling room, and the character is walking or animating outside the viewport, as the viewport gets closer to the character, or even as the PC gets closer to the character, the sound gets louder...

Currently I have to do a bunch of scripting to change the volume of a character chopping wood in a certain scene. This feature would get rid of the need of all that scripting. Maybe something like camera_is_ear and player_is_ear for each character... so you could set the pc as camera_is_ear so the farther away the quieter his view sounds, and all other characters as player_is_ear so their sounds get louder as the PC gets closer to them.

Just a thought....

On second thought why not have a combonation of both... for instance an animating character with a sound is in a walkable area at 50% height so his sound affect is at 50% volume, as long as the character is within the current viewport, the farther the character is away from the viewport edge the volume is slowly decreased from there....

thinking about it... it may take some coding to check the viewport and character position and all that jazz to make it work properly, but if anyone can do it... its CJ!!!!!!one!11one!!1
Title: Re:Suggestion: Adjust volume with scaling
Post by: a-v-o on Wed 28/04/2004 09:32:47
Could it be implemented in the region like scaling in the walkable area?
Regions have a sound level which could be the same for the whole region or continous between the two different values for front and back.
Characters have a checkbox "ignore room area sound volume".
Then the volume for all sounds that a character produces (footsteps, voice) is adjusted to the current volume.
And a variable giving the current volume level of a character would be good for scripting: something like character[].volume. Then other sounds could be adjusted to the character's sound.
Title: Re:Suggestion: Adjust volume with scaling
Post by: Pumaman on Thu 29/04/2004 21:03:49
There are two different issues here - adjusting with scaling and adjusting with distance. I'll add it to my list.

With the repeatedly_execute_always function, it's fairly easy to do it yourself using the manner Ashen suggested, for the time being.