Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
sgt_hawkins

Localized Sound

Recommended Posts

did anyone manage to get it to work so the sound fades away if one increases the distance to the sound source?

I attached a trigger playing a voice sound to a car and it fades as the car drives away. You can see this effect in this demo.

Share this post


Link to post
Share on other sites

hmm.. that works with default sounds of the game but it doesn't work with my custom sound for some reason. I checked the possible error sources - changed the description.ext to have my sound in it and renamed the objects apropiately. still doesnt work with custom sounds..

still, thank you for sharing kylania. you're the best! :)

Share this post


Link to post
Share on other sites

Uhm, his example already uses custom sounds...

If .ogg, make sure to use constant bitrate.

For wav, make sure to convert to wss.

Rules:

1) Mono sound for all localized sounds. Mono or stereo for everything else.

2) 44100 or 22050Hz, where the latter is especially used for cfgEnvSounds SFX parts (not the ambient loops), maybe also cfgRadio, not sure.

Share this post


Link to post
Share on other sites
Uhm, his example already uses custom sounds...

If .ogg, make sure to use constant bitrate.

For wav, make sure to convert to wss.

Rules:

1) Mono sound for all localized sounds. Mono or stereo for everything else.

2) 44100 or 22050Hz, where the latter is especially used for cfgEnvSounds SFX parts (not the ambient loops), maybe also cfgRadio, not sure.

no, it uses a soundeffect that is available in the effects list.

(except the "clothes.ogg", which is not the sound we are talking about - we are talking about the radiosound wich fades away as the distance to it increases).

Edited by Bulldog Six

Share this post


Link to post
Share on other sites

Oh, my bad. I didn't test it, just browsed through the scripts and description.ext. Yes I see mission.sqm uses a sound class called RadioMusic2_EP1. Note that this sound class may often not be the same as what is listed under effects, which has a displayname shown instead.

soundDet="RadioMusic2_EP1";

Means it is a cfgSFX based sound. Biki is sadly not very updated regarding cfgSFX and cfgEnvSound based sounds.

Here is one custom sound like this I use myself that I know works:

class CfgSFX
{
sounds[] = {};
class fx_well {name = "fx_well_triggerlistname";sounds[]={sound1};sound1[]={"sounds\fx_well.ogg",1,1,50,1,0,0,0};empty[]= {"",0,0,0,0,0,0,0};};
};

"path\filename"

1: Volume

1: Pitch

50: How far away, or reach

1: Chance of getting played

0: Min random delay

0: Med random delay

0: Max random delay

The empty section as is there will allow a perfectly looped sample (if sample is already perfect). Other examples I've tried gives some wacky pause. Note that the format of the empty list is equal to the format of the sound. Sometimes you can find examples of empty lists going as:

empty[]= {"","","",0,0,0,0,0};

which is basically the same. I think it's just how the interpreter works, in that number tokens may be expressed as strings. But you can't change the first "" to 0, as that one expects a string. Confused? So was I :) And I won't guarantee that this is correct, this is just guesswork for a highly undocumented feature... I believe the empty list is there to provide a total pause when it is hit. My post #16 should maybe have the three last numbers defined instead of all zeros. But it has to the there or the game will crash.

Edited by CarlGustaffa

Share this post


Link to post
Share on other sites
Oh, my bad. I didn't test it, just browsed through the scripts and description.ext. Yes I see mission.sqm uses a sound class called RadioMusic2_EP1. Note that this sound class may often not be the same as what is listed under effects, which has a displayname shown instead.

soundDet="RadioMusic2_EP1";

Means it is a cfgSFX based sound. Biki is sadly not very updated regarding cfgSFX and cfgEnvSound based sounds.

Here is one custom sound like this I use myself that I know works:

class CfgSFX
{
sounds[] = {};
class fx_well {name = "fx_well_triggerlistname";sounds[]={sound1};sound1[]={"sounds\fx_well.ogg",1,1,50,1,0,0,0};empty[]= {"",0,0,0,0,0,0,0};};
};

"path\filename"

1: Volume

1: Pitch

50: How far away, or reach

1: Chance of getting played

0: Min random

0: Med random

0: Max random

The empty section as is there will allow a perfectly looped sample (if sample is already perfect). Other examples I've tried gives some wacky pause. Note that the format of the empty list is equal to the format of the sound. Sometimes you can find examples of empty lists going as:

empty[]= {"","","",0,0,0,0,0};

which is basically the same. I think it's just how the interpreter works, in that number tokens may be expressed as strings. But you can't change the first "" to 0, as that one expects a string. Confused? So was I :) And I won't guarantee that this is correct, this is just guesswork for a highly undocumented feature... I believe the empty list is there to provide a total pause when it is hit. My post #16 should maybe have the three last numbers defined instead of all zeros. But it has to the there or the game will crash.

cool, this works! thx a lot CG!

one more thing though: how do I modify this to make it a non-loop if needed? (plays 1 time AND chances to be played again by some other player are.. lets say 25%)

Share this post


Link to post
Share on other sites

Sound config only lets you determine how a sound is played. It can have timings and randomness to choose samples, but not any randomness in relation to players. I'm not even sure if the playback is synchronized between players (I have reason to believe they are not, to keep the net traffic down).

For a one time play, try putting 60,60,60 in the delay fields (edited my original post) to wait a minute, then delete it, then recreate dynamically - gets a bit messy. But for that I would go with normal say type sound instead (cfgSound), and have some object "say" it (HeliHEmpty) on all clients. CfgSFX is a bit special purpose to handle loops and randomized samples. CfgSound is general purpose but used mostly for non looping sounds.

Probably just coincidence that kylania chose to use a trigger sound (CfgSFX). Could as well have used a "voice" type sound (CfgSounds). They are both "localized" (at least with mono sounds) as long as the volume value isn't too high.

For randomized playback of a CfgSound sound using say command, just make a regular script for it. First time player in area activates the trigger that starts the script with it's first play, then delays a random amount of time, waits for second player to be within trigger list, and have a 25% chance of saying the sound again.

Here a cfgSound that works for me:

class CfgSounds {
sounds[] = {
class FlareDeploy {name="FlareDeploy";sound[]={\sounds\FlareDeploy.ogg,db-2,1.0};titles[] = {};};
};

Btw, just to make things a little more confusing... CfgSounds are in both the voice section (in a trigger effect list) and in the anonymous section. Voice = say/say3D etc, while anonymous = playSound. Using say commands it will be localized but can only say one thing at a time. Using playSound command it will not be localized, can play several samples without waiting to finish, and supports stereo.

If you want an alarm or radio, go with say. If you want a fast typewriter, go with playSound. If you want birds (randomized playback) or loops, use triggers (cfgSFX). And then there are cfgEnvSounds and cfgRadio and cfgMusic, but I think I'll leave those out for now... :p

Edited by CarlGustaffa

Share this post


Link to post
Share on other sites

my goodness, you are a master of this language, aren't you?! :D

that's really amazing!

thing is: I want to play a conversation audiofile, which is not supposed to play whenever EACH player triggers the trigger, it should be a little more seldom so players are still surprised by it AND (most importantly) it should fade away as the distance between player and soundsource increases (i.e. player walks away and is not eavesdropping).

ohman.. I really wish I had your knowledge about this things.. my map would be finished within one or two days instead of one or two months.

however, thanks for your help! I'll try the delay right away!

EDIT:

this is how I have it so far. the first sound works, but the second sound doesn't even appear on the dropdown menue of the effects list. I tried a couple of variations to solve this, without any success. do you find an error?

class CfgSFX

{

sounds[] = {spy,int_wind};

class spy

{

name = "SPY";

sounds[]={sound1};

sound1[]={"sound\spy.ogg",1,1,30,1,60,90,120};

empty[]= {"",0,0,0,0,0,0,0};};

};

class int_wind

{

name = "WIND";

sounds[]={sound2};

sound2[]={"sound\wind.ogg",1,1,30,1,0,0,0};

empty[]= {"",0,0,0,0,0,0,0};};

};

I need the second soundfile (wind.ogg) to loop forever (or at least as long someone is there to hear it to save memory ressources) and to fade off at increased distance. Not sure if it's this part "sounds[]={sound2};" which is wrong or this part "sound2[]={"sound\wind.ogg"..." or something else..

Edited by Bulldog Six

Share this post


Link to post
Share on other sites
my goodness, you are a master of this language, aren't you?! :D

Not really, I'm learning this stuff as I type ;) Not really, but I am figuring out some stuff right now. Some of the stuff I've mentioned seems to not be relevant when doing it from description.ext, although it works if defined in a config (such as random[] in CfgEnvSounds). Or I'm messing up something else. No clue yet.

thing is: I want to play a conversation audiofile

Definitely go with cfgSounds and say command rather than cfgSFX and triggers. It is much more suitable for the job, and it does support localization if sound is mono and not too loud (the number, not the sample).

Your brackets are wrong. Class int_wind is not included in cfgSFX, but outside as a standalone class. Try this (not tested):

class CfgSFX
{
sounds[] = {spy,int_wind};

class spy
{
	name = "SPY";
	sounds[]={sound1};
	sound1[]={"sound\spy.ogg",1,1,30,1,60,90,120};
	empty[]= {"",0,0,0,0,0,0,0};
};

class int_wind
{
	name = "WIND";
	sounds[]={sound2};
	sound2[]={"sound\wind.ogg",1,1,30,1,0,0,0};
	empty[]= {"",0,0,0,0,0,0,0};
};
};

Use code tags rather than quote tags. Preserves indents and doesn't autocorrect anything.

Share this post


Link to post
Share on other sites
Not really, I'm learning this stuff as I type ;) Not really, but I am figuring out some stuff right now. Some of the stuff I've mentioned seems to not be relevant when doing it from description.ext, although it works if defined in a config (such as random[] in CfgEnvSounds). Or I'm messing up something else. No clue yet.

what about a custom music track? how do you recommend playing those? so far I used playSound for that. is there a better way?

Definitely go with cfgSounds and say command rather than cfgSFX and triggers. It is much more suitable for the job, and it does support localization if sound is mono and not too loud (the number, not the sample).

you were right! I had to set the sound volume number really low (0.2) to have a pleasant result. but how do I add a delay this way? do I select Countdown in the trigger and set the MIN MID MAX range in the trigger? (i.e. 60,90,120)

Use code tags rather than quote tags. Preserves indents and doesn't autocorrect anything.

roger that! thx a lot Carl!

slightly different topic, but while we're at it: typewriter text (as in campaign)

I created a trigger which displays the typo text, but everyone else (MP) gets the message as well when I trigger it. would you know how I would have to edit it so that only people who trigger it get the message?

i.e.

waitUntil{!(isNil "BIS_fnc_init")};
["Bla bla bla"] call BIS_fnc_infoText;

Edited by Bulldog Six

Share this post


Link to post
Share on other sites

Use commands playMusic (maybe also fadeMusic) or add is as a track effect in the trigger, by defining the music in cfgMusic. Look up description.ext on biki. Music can't be localized though. If you need that you have to convert it to mono, and add it to the mission.

Yeah I would go with countdown delays in the trigger.

Try trigger condition field: (local player) && (player in thislist)

Share this post


Link to post
Share on other sites

Yeah I would go with countdown delays in the trigger.

It didn't work properly - the countdown actually DELAYED the playback, so it wasn't played as soon as the trigger was activated but after a certain time it started to play even if I wasn't in the trigger area anymore. sometimes the sound overlapped over each other as well.

but I need the replay delay AFTER the playback. how do I do this? (using say )

Try trigger condition field: (local player) && (player in thislist)

I tried that - I put

[i](local player) && (player in thislist)[/i]

into the condition field, but the typo text did not get displayed at all that way (this is the propper post about this specifical typo-topic: http://forums.bistudio.com/showthread.php?p=1767881#post1767881 ).

Edited by Bulldog Six

Share this post


Link to post
Share on other sites

I would script it. Start/spawn a script that uses its own delays. Yeah the idea about delays is that condition aren't true until delays have passed.

Instant activation instead of delayed, then on act:

0 = [] spawn { ...code ... }

where code could be:

u1 say "something"; sleep 4; u2 say "somethingelse"; sleep (10 + random 10); u1 say "whoa"

I think you get the point :)

Share this post


Link to post
Share on other sites

I do ^^

You're a big help Carl, I hope you're not getting tired of it ;)

You mentioned converting *.wav files to *.wss before. Can I access the ingame *.wss files as well somehow (I tried, didn't work for me for some reason, maybe I got the path wrong or something) or do I have to extract them into my mission\sounds folder?

or is the command to play *.wss files different?

Edited by Bulldog Six

Share this post


Link to post
Share on other sites

I've tried plenty of times use sounds from other addons already in the vanilla game, without cloning them to the mission folder. Without success. Use this tool to convert from wss to a good wav format. The ones I've tried from here I've had problems with. To convert from wav back to wss the first link contains tool to do that too, but I have something called WSSFileConverter.exe that does a better (faster job). Note that WSSFileConverter.exe may work well on some wss files, while others produce just garble (sounds like 22050 samples interpreted as 44100, producing mostly white noise). I have no idea where I got it from though.

So WSSFileConverter.exe normally and for converting too wss, and the first link when WSSFileConverter.exe fails converting from wss.

Share this post


Link to post
Share on other sites

This may or may not be of any help, but I resently noticed that when using MPF and rsay with the local option the sound does fade off as your walking away from the sound source and back in as your walking toward the sound source.

Share this post


Link to post
Share on other sites
This may or may not be of any help, but I resently noticed that when using MPF and rsay with the local option the sound does fade off as your walking away from the sound source and back in as your walking toward the sound source.

hmm.. I just read something about this r-commands.. *tabswitch & link-copy*

Is that related to the yellow warning box on this page (link below)?

http://community.bistudio.com/wiki/Multiplayer_framework

I'm new here and have no clue what MPF is. But it seems like those r-commands might cause issues with this MP framework module.

But it is certainly interesting. Thank you for sharing this information!

Share this post


Link to post
Share on other sites

another question about the ClassSFX sounds:

how do I use these?

playSFX "soundclassname"; ?

and about music on game start: what is the optimal way and location to start to play a custom music track when the game is joined (after clicking continue on the mapscreen)? descirption.ext? init.sqm?

I need it to be that only the one joining hears the music, not everybody. so far I've improvised this using a trigger at the spawn location, but then everybody hears the music again when a player joins at a later time.

ps: same with init.sqm - so far improvised execution through spawnpoint trigger. is there a better way to run it?

Edited by Bulldog Six

Share this post


Link to post
Share on other sites
hmm.. I just read something about this r-commands.. *tabswitch & link-copy*

Is that related to the yellow warning box on this page (link below)?

http://community.bistudio.com/wiki/Multiplayer_framework

I'm new here and have no clue what MPF is. But it seems like those r-commands might cause issues with this MP framework module.

But it is certainly interesting. Thank you for sharing this information!

I think what that is trying to tell us is that if you are going to use the MPF then you should not use rCOMMAND in your mission unless you are calling the MPF with it.

Share this post


Link to post
Share on other sites

@Bulldog Six: Uhh, huh? PlaySFX where? Afaik the only way to play cfgSFX sounds are via triggers (or script command setSoundEffect which targets a trigger). If you know any playSFX command I would love to check it out.

Btw, normal say commands have this ability too, as long as they are mono and have a low enough volume. Nothing special about the MPF command afaik.

Edited by CarlGustaffa

Share this post


Link to post
Share on other sites
command[/i] afaik.

I dunno but I have both and the normal does not fade as I walk away from it, I think it has something to do with the fact that I specified the sound be played for players local to it with the MPF, but again I don't know, I just know that it works.

 
[nil,_car,"loc"+"per",rSay,"siren"] call RE;

There are of course other reasons to use the MPF too, for example, we know with the MPF everyone can hear it including JIP, anyway that one fades, the following does not.

 
class Pub 
{
name     = "Pub";
sound[]  = {"\Pub.ogg", 1, 1};
titles[] = {};

logicPub say ["Pub",5];

Share this post


Link to post
Share on other sites

The volume is too high, so you may need to go further away to notice it. Volume 1 is like db+0 (I think). What is missing is your siren config to compare with.

For cfgSound I'm using:

class Transmit {name="Transmit";sound[]={\sounds\Transmit.ogg,db-30,1.0};titles[] = {};};

class AlarmMonoTone {name="AlarmMonoTone";sound[]={\sounds\AlarmMonoTone.ogg,db+10,1.0};titles[] = {};};

Transmit fades away quite nicely, while AlarmMonoTone can be heard for a very long distance.

Yes, the purpose of using MPF is to avoid locality issues. But I don't expect the behaviors of the commands to change. I'm betting it's still the original commands being used but on the client side.

Share this post


Link to post
Share on other sites

Your right, that was the difference, but I tend to lean toward the MPF anyway since the whole MP and JIP things is rather a pain without it, personally I think everything should work with MP and JIP, this is the first game I've ever had that makes them so damn complicated.

Share this post


Link to post
Share on other sites

Hello guys! Thanks for this thread! It helped me a lot!

One question:

Is there a way to stop a CfgSFX sound which comes from a trigger?

I thought that the sound was attached the trigger and if I deleted the trigger the sound would "be gone" too. But this doesn't work.

Setpossing the trigger far away also doesn't work. It only stops the sound when you leave the area the sound is played in and come back in again - in this case the sound is no more there.

Does anyone know a workaround to make the CfgSFX sounds from a trigger stop?

Edited by Undeceived

Share this post


Link to post
Share on other sites

I was messing with CfgSFX the other night and couldn't even get it working at all. Deleting the trigger should work, it does for alarms for example.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×