Jump to content
Sign in to follow this  
Guest

Localized loud sound, short fade out distance

Recommended Posts

Guest

Hey

After wasting a good few hours trying to get a positional sound (music) for a bar to eminate loudly for a short range around the bar, I am switching to using music while in the bar only, which is alot less realistic and less immersive, but the sound just carries to far. The very lowest decibal setting I could live with was around db-15, and at that you could hear the dang music half a mile away, I really only want the music heard from maybe 40 - 50 meters from the bar. I also tried fadesound once player at certain distance, course all sound gone then.

Anyone got any suggestions would be great, I cant find anything else myself, so im switching to music, and using fade music once outside of bar, so there wont be anymore residual music from outside the bar, but it will work lol..

Again, any suggestions welcome wink_o.gif

Edit/ There is one last possibility im gonna try, that I was avoiding. I can use the sound (music) in its original short form (had it merged to itself 4 times) and loop it in the script, my concern is that if lag occurs during gameplay the music may have pauses between each sound play, which is kinda tough to test..

Share this post


Link to post
Share on other sites
Guest

Well here I am relpying to myself  tounge2.gif

Tried the loop scripted shortened version of the sound, and it does allow me to stop the sound at any range, problem is now theres a 'skip' between every sound playing cycle, man, this is a pain lol - and worse seems the skip wont go away as I have even set the delay between each sound playing to less than the sound length which is only 2.2 secs, so I set it to 2, then tried 1.5 ... still skips.

Bummer

Edit// If anyone knows how to get rid of this infernal skipping between looped sounds, would be great, I have everything to perfection, but there is still a one sec pause between each sound no matter what the delay setting is. I cant just make long merged files of sound music, cause then it would take 30 secs to get the sound to stop once player left sound area, gahh, prolly gonna be music files here...

Share this post


Link to post
Share on other sites

Hey Ed

I asked this too. Here's the replies they gave:

How do I Fade in / out music

For fading out, put this in the Activation Field of a trigger/waypoint:

10 FadeMusic 0

10 is the seconds that it takes to fade the music.

0 is here the volume of the music.

You may also choose 0.4 for a background music. 0 is no sound. 1 is full volume.

For fading out, you must put up a trigger that makes the sound mute at the beginning.

0 Fademusic 0

Then put in the trigger or waypoint where you want to start the music fading in:

12 Fademusic 1

.......You can do the same with the command FadeSound

----------------------------------------------------

place a radio at your music source desired position,

name it radio1,

into its init field write

[]exec"radio1.sqs"

And create radio1.sqs as follows:

#waitforinrange

@(player distance radio1) <= 20.0

0 fadeMusic 0

playMusic "Track15"

#checkrange

_dist = player distance radio1

? _dist > 20.0: 0 fadeMusic 0;goto "waitforinrange"

_vol = 1.0 - _dist/20.0

0 fadeMusic _vol

~0.05

goto "checkrange"

exit

--------------explained-----------------

I tested it and it smoothly increases or decreases in volumen from 0 to 1.

I will comment every line of code so you can tweak it better

for example

[radio1, 50.0, "Track15", 0.0, 0.05]exec"radio1.sqs"

;Usage:

;[object, maxsoundrange, track, time_to_reach_cacl_vol, loopdelay]exec"radio1.sqs"

; Object generating music

_object = _this select 0

; Range in meters to have any volume

_meters = _this select 1

; Music track to be played

_music = _this select 2

; Time in seconds to reach the calculated volume

_fadetime = _this select 3

; Time to wait between checks

_delay = _this select 4

#waitforinrange

;Is player inside sound range?

@(player distance radio1) <= _meters

;As soon as you get in range, you get 0 volume

; set 0 volume in 0 seconds (vol fademusic secs)

0 fadeMusic 0

; Lets start playing this track (you may try any other)

; Initially at volume 0

playMusic _music

;Now that we are in range, lets regulate volumen

;depending on range

#checkrange

_dist = player distance _object

;If we get out of range, volume 0 again and

;goto initial check point

? _dist > _meters: 0 fadeMusic 0;goto "waitforinrange"

;If we are still into range we calculate the corresponding

;volume (maximum 1.0 for range near 0m,

;minimum 0 for range = _meters)

_vol = 1.0 - _dist/_meters

;Change the music vol in the indicated time

_fadetime fadeMusic _vol

~_delay

goto "checkrange"

exit

Take into consideration that some music tracks starts also with a very

low volume (they are composed this way).

If you have time and some patience, you should try the next method too,

this way the sound source will be really placed in the OFP world.

You will not have only an increase of the sound as you aproach the sound source,

but also the sound will reach you focused from the indicated coordinates.

--------------------------------------------------

*************OR (trapper)*************

What you're really looking for is the creation of an engine based sound effect with dynamic range, not a script.

1. Lets say your custom sound is radiomusic.ogg.

If you want to create more than one, think about normalizing all of the files.

2. You'll need this part in your description.ext

class CfgSounds

{

class radiomusic{name = "";sound[] = {"radiomusic.ogg", db-55, 1.0};titles[] = {0};};

};

The most important part in this case is the db value.

It represents virtual db's in OFP's island world. Start with 0 and

adjust it to the positive or negative by trial and error in game. T

he lower the value the less it's gone to be heared over distance.

Important: When you make changes to the description.ext, you have to

reload the mission in the editor for the changes to take effect.

Btw when you make use of name = "radiomusic" you can find your own

sound easily in the trigger effects menu, too.

3. Place an object somewhere that emits the sound. For now I'll name it radio.

Or use objectID to let any tree ect be the source.

4. Create a script to loop your sound.

#l1

if (player distance radio < 100) then {radio say "radiomusic"}

~10

goto "l1"

This script will also stop playing the sound when the player is too far

away to hear anything (100 meters).

~10 has to be the lenght of radiomusic.ogg in seconds.

If you don't need a looped sound the simple command line radio say radiomusic

will play it once.

-------------------------------------------------------

I went searching for this too recently,

Trappers way is what i got to work, simple and efective.

I edited the sound to make it small and feel continuous.

give the radio a name (radio).

use a small loop script to keep it playing:

#loop

radio say "radiosong"

~56

goto "loop"

Radiosong is the name of the sound file, 56 seconds is

the duration of the sound i used. Call it on a trigger

like: this exec "whateveryounamedyourscript.sqs".

And like he said adjust the db in the sound or in the description

file (dont forget the saving part).

Simple, nice and functional

Share this post


Link to post
Share on other sites

Thx IceFlyer thumbs-up.gif

With such a 3d positioned sound there also should be no need to split the sound file anymore.

But Special Ed, you already mentioned the db setting...

Keep in mind that you're searching for a 3d FX sound solution, not some ingame background music.

Are you really defining your music as CfgSound class? It's the only class in description.ext where db works as virtual reality volume/travel distance.

With CfgMusic it's only a "normal" volume setting, because CfgMusic works like virtual headphones.

Share this post


Link to post
Share on other sites

Wow it's very nice idea, Trapper.

I'll be looking for some disco add-on. If I will not find it... maybe I can get work on it smile_o.gif

In distance of 10-100 only the bass voice will be played but while getting into the disco you can play loud music biggrin_o.gif

Try to imagine the SWAT mission smile_o.gif Arresting some two drug pricks in the disco where nice puttas/bitchas/kurevki is looking at action pistols.gifbiggrin_o.gif

Share this post


Link to post
Share on other sites
Guest

Thanks al for the help, I hafta make this breif as I am doing some work right now, but heres what I discovered:

I did all these option that iceFlyer listed, there is a pause that occurs between sounds when 'say' is used, so to attempt to use this in repetative short sound bursts sounds like a record skipping, simply put the 'say' sound coming from one object will not overlap another sound that comes next, playsound and playmusci WILL overlap, you can cut right into a sound/music being played and it will start the new sound without waiting to finish the current sound, hence its smooth.

There is a way to get 'say' to not skip in repetetive playings, thought of this last night, merley switch back and forth between to objects that are on top of each other (gamelogics, whatever), say sound at one, then at next loop say sound at other, and back and forth, therefore the sounds wont have that lil brief pause between them, as each time a sound is 'said' the object saying it isnt finishing a current sound(which caused the pause).

And I finally just decided to go with the music anyhow, as I really wanted only limited sound eminating from outside the bar till u get in there, then crank it up - I can do that with that very nice fade music script as players get within like 20 m of the bar, make it get a little louder as you get closer, then have a trigger rectangle covering the extact bar interior perimeter, so when someone actually goes in the fade music gets removed and hence the music is cranked up, and lastly a trigger that will show if player leaves.

Certainly learned alot on this one, too bad I dont plan on having any more of this type of sound/music applications to later on apply my new found knowledge. crazy_o.gif

Edit/ Do want to add that this 'pause' that occurs between 'say' sounds isnt in the sound itself that im using, I had merged a few copies of the sound into one, and it plays smooth, and that ive tried various delay settings, from the exact time of the sound to less, more, always pauses between sounds with 'say'.

Also that A big problem with using sounds instead of music in a positional manner is that the sound carries far for music played from within a building, is there a way to edit the db value so that its very loud say within like 10 meters then quickly fades with like 20 or 30? Dont think so, thru my testing I found that once in the building the volume was appropriate at about db - 10 , but when you walk outside the sound carries on for a very long ways, more less wrecking the atmosphere in the town outside the pub.

Thanks again for the help guys.

Share this post


Link to post
Share on other sites
Guest

Thanks again IceFlyer, do appreciate you putting that stuff up there for me, just got the music script running and theres some work to do to get a loop going and add some other stuff, but the fadeout can be changed to whatever I need without worrying about fading all other sounds.

Hopefully about time to wrap this app up.

Thanks again

@TYsiEK

Was told there is a disco bar in here, havent tried it myself as im liking the bar I got, thought you might want to look at this:

ftp://ftp.gamepark.cz/ofpd/unofaddons2/Sity_objects_Pack_(v1.0).rar

Share this post


Link to post
Share on other sites
Also that A big problem with using sounds instead of music in a positional manner is that the sound carries far for music played from within a building, is there a way to edit the db value so that its very loud say within like 10 meters then quickly fades with like 20 or 30? Dont think so, thru my testing I found that once in the building the volume was appropriate at about db - 10 , but when you walk outside the sound carries on for a very long ways, more less wrecking the atmosphere in the town outside the pub.

Probably the OFP 3d sound system doesn't know "inside". Every soundCfg positioned on the map will sound like a radio placed somewhere outside. No matter if it's placed inside of an 3d model, or if the player is inside somewhere.

This time fading a musicCfg with scripting really is the better option.

Share this post


Link to post
Share on other sites
Guest

@Trapper

Yup, and actually if the time is spent to get a good fade in/out distance and volume depeding on the sound app the music approach can work really good, cause im very happy to say this thing is up and running yay.gif

yay.gifyay.gif

Theres a nice almost ambient music that starts at 50 m from the pub, as you near it slowly gets louder up to .7 of max volume at the building walls, once you step inside it cranks to max volume, and then goes back to backgroundish ambient when you leave, very happy.

Thanks for the help everyone, moving on.

Just for the hey of it, if anyone wants I can post the additional scripts for this to be done for enterable building music, but id suppose some gurus out here would prolly point out better ways to script it, but I can say it works, and while looping a sound too..

Share this post


Link to post
Share on other sites

hey Ed

please post the script you used

or if you want to private message it to me

thanks!

---IceFLYER

Share this post


Link to post
Share on other sites
Guest

Im finishing up the script doc right now and checking it over, gimme a few and ill post it.

Share this post


Link to post
Share on other sites
Guest

You can change script names and distances to whatever you want, here is an editable example from my mission:

The first part is for lag purposes, isplayerintown.sqs will activate the sounds emitting from building if player is within a

certain radius of the gamelogic merchantlogic

In your Init.sqs put these variables in:

playeratclub = 0

endmusic = 0

In this script example the music file named "clubbeatone" is used, which lasts for 57 seconds, alter this name in

clubmusicloop.sqs(at bottome) and the delay setting for your particualr music file, only works with MUSIC files, not sound

Editor Stuff:

at the center of the town area that you will have your sound emitting building in:

make a gamelogic that is named merchantlogic

in its init feild: [] exec "isplayerintown.sqs"

in isplayerintown.sqs you can change all of the: '150.0' radius numbers to cover your town area (change all of them)

within roughly center of your desired building:

make a gamelogic that is named clublogic

make a trigger, make it rectange and make its area slightly larger than the walls of your sound emitting building(annoying

part)

set to anyone, present

set to repeatable

set name to triggerone

in condition line : player in (list triggerone) && playeratclub == 0

activation: playeratclub = 1

copy that trigger in editor, place new copy of trigger perfectly over that one (same coverage area overlapping)

be sure its set to anyone, present

repeatable

set name to triggertwo

in condition line: !(player in (list triggertwo)) && playeratclub == 1

activation: playeratclub = 0

Script Stuff:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

isplayerintown.sqs

;this will initiate music if player in town

#merchantdistance

@(player distance merchantlogic) < 150.0

;set any variables before executing merchant scripts

endmusic = 0

;execute all merchant town interactable scripts

[] exec "clubmusic.sqs"

[] exec "clubmusicloop.sqs"

;if player leaves merchant town set variables to deactivate interactable scripts

@(player distance merchantlogic) > 150.0

endmusic = 1

goto "merchantdistance"

This script will alter music fade until player gets inside building (or is right at building walls)

This script will end when player leaves town area.

clubmusic.sqs

#waitforinrange

?(endmusic == 1):exit

?(player distance clublogic) <= 70.0:0 fadeMusic 0;goto "checkrange"

~2

goto "waitforinrange"

#checkrange

_dist = player distance clublogic

? _dist > 70.0: 0 fadeMusic 0;goto "waitforinrange"

_vol = .6 - _dist/70.0

0 fadeMusic _vol

~0.05

?(playeratclub == 1):goto "playerin"

goto "checkrange"

#playerin

0 fademusic 1

?(playeratclub == 0):goto "checkrange"

~0.05

goto "playerin"

exit

This script will loop the music, and will end once player leaves town area.

In this script example the music file named "clubbeatone" is used, which lasts for 57 seconds, alter this name in

clubmusicloop.sqs and the delay setting for your particualr music file, only works with MUSIC files, not sound

clubmusicloop.sqs

0 fademusic 0

#playmusic

?(endmusic == 1):exit

playmusic "clubbeatone"

~57

goto "playmusic"

Alright, well, went thru the editor and checked the trigger scripts, this all should be right, if any problems arise let me

know, its late, im tired lol, but this should be correct.

There indeed may be one or more hidden bugs, this has been tested, but not thouroughly, but the script form should be easy to slightly modify in case an issue may arise.

Share this post


Link to post
Share on other sites

SpecialED,

What IceFLYER requested in the past was a bit different than your needs. He asked for music volume controlled by distance to object, which is accomplished by radio1.sqs. But you are asking for localized sound. PlayMusic will never generate localized sounds, the music will be stereo and you will not have any sense of the "source" of the music.

Sound/Music script question thread

Share this post


Link to post
Share on other sites
Guest

I am completely aware of this Mandoble wink_o.gif

There were too many issues in regards to using positional sound files for building music tho, as you well know the sound carries right through the walls as if there is no building, and carries off for a long ways, in this app the sound must be loud at its origin, and so the louder the sound the farther it carries, and stopping the sound at 100 m doesent sound right at those db levels.

In this script, simply put, you will get a low ambient music which will slightly increase as you near the building, once you enter the building the music will crank up to full blast, when you walk out of the building it will go back to the low ambient music and will fade as you walk away, you cant do this with positional sound, not at these sound levels anyhow without blasting the sound allover the place outside the building.

So, this script is for in building music that would be somewhat loud in the building itself (like a bar atmosphere) and the script will also add low ambient sound around the building for a short range, so you still get a realistic effect as you approach the building, rather than dead silence then was you walk in all the sudden being blasted with music.

Best I can describe, but ya, its a different app, but it does work good, in fact really good, you cant really tell as you approach the building that the sound is coming from you really, as it does increase in volume as you near the building..

Edit// forgot to mention that the isplayerintown.sqs script is universal, it can be used to start/end any in town functions depending on if the player is in that area or not, therefore removing any possible lag while your somewhere else on the island by having that stuff temporarily shut off.

Share this post


Link to post
Share on other sites

Special Ed, I got and tested a good solution for your problem. I'll try to explain the concept.

1 - You have a gamelogic and a sound or two gamelogics and two similar sounds (this case applies only if you cannot loop the first sound without interruption, so you overlap first and second sounds with Say commands respectively for logic1 and logic2, one sound starting after half the duration of first sound).

2 - You get the position of center of your pub.

3 - The logic (or logics if you use two) will keep looping the sounds all the time. If you use two logics, both sounds should be similar in length and base volume.

4 - All the time you calculate a position X meters away of the pub and opposite to your side. X is your distance to the pub + an offset. If you are inside the pub, the offset is 0, if you are outside the pub the offset is 60 (for example). You place your gamelogic/s at this position everytime you recalculate it.

This way, if you are outside the pub, you will hear the pub sounds comming from the pub direction, but, in fact, much farther than your distance to the pub. When you get inside the pub, the sounds will come directly from the pubcenter plus your range to that center, so, as you move inside the pub, the origin of the sound will move also inside the pub.

Change it if you only need one gamelogic.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

;pub3dsound.sqs by Mandoble

;

;Arguments:

;object for bar or pub

;minimum distance of player to bar or pub to consider you are inside

;extra range to the sound source when you are outside

;logic source of sound1

;logic source of sound2

;

;Example:

;[pub,5,60,log1,log2]exec"pub3dsound.sqs"

_pub = _this select 0

_mindist = _this select 1

_extradst = _this select 2

_log1 = _this select 3

_log2 = _this select 4

#check

_dst = player distance _pub

_offset = _extradst

;Is the player inside? If so, offset 0

?_dst < _mindist:_offset = 0

_posp = getPos player

_pospub = getPos _pub

;Angle between player and pub

_ang = ((_pospub select 0)-(_posp select 0)) atan2 ((_pospub select 1)-(_posp select 1))

;Distance to the player of the sound source

_rad = _dst*2.0 + _offset

;Position of sound source

_pos = [(_posp select 0) + sin(_ang)*_rad, (_posp select 1) + cos(_ang)*_rad, 0]

_log1 setPos _pos

_log2 setPos _pos

;You can use the next line with a real object

;So you can see how it moves around

;objeto setPos _pos

~0.1

goto "check"

exit

Now you only need a simple script that will keep looping the sound with a Say command per gamelogic.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

;Example:

;[log1,120,60,"pubsound1"]exec"pubsound.sqs"

_gl = _this select 0

_duration = _this select 1

_wait = _this select 2

_sound = _this select 3

~_wait

#sound

_gl say _sound

~_duration

goto "sound"

Lets say you want to use the same sound for both logics, a sound with 120 secs duration, to start everything:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

[pub,5,60,log1,log2]exec"pub3dsound.sqs"

[log1,120,0,"pubsound1"]exec"pubsound.sqs"

[log2,120,60,"pubsound1"]exec"pubsound.sqs"

Share this post


Link to post
Share on other sites
Guest

Wow.

Thanks for that Mandoble.

Looks like it took some work to put that together wow_o.gif

I havent yet tried it, I have some things to do, let me try it and put up what ive discovered.

Share this post


Link to post
Share on other sites
Guest

I did try it, unfortunatley there were a number of familiar issues still.

Even at a low pitch volume from the sound eminating from a long distance away I found you could still hear the music throughout the interior of the entire town quite clearly, and at that particular decibal level when you walked up to the pub it was still very faint, until you walked in and moved towards center of room, it didnt increase as soon as I walked in tho. If the script is supposed to use the building object (pub) as a location check for if player is inside or not, then maybe the bar addon itself is a little screwey and its script - refferable actual area size is much smaller than its true size, dont know.

I do appreciate the help, but really I am quite satisfied with the set up I have using the music, because at 70 meters I can make the sound coming from the building fadeout completely, and can make it so it increases quickly from that distance to the bar, which really restricts the atmosphere of the bar to a certain small area, leaving the rest of the town to its own.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×