Jump to content
Sign in to follow this  
acoustic

Custom Sound Script makes game lag really bad

Recommended Posts

init.sqf

execvm "playsound.sqf";

description

class CfgSounds
{
 sounds[]={nam};
 class nam
 {
   name = "Azan_Mosque";
   sound[] = {\Sounds\Azan.ogg, 1, 1};
titles[] = {""};
 };
};

script to call sound

MISSION_ROOT = call { private "_arr"; _arr = toArray str missionConfigFile; _arr resize (count _arr - 15); toString _arr };


while {true} do

{

playSound3D [MISSION_ROOT + "Sounds\Azan.ogg", sound2, false, getPos sound2, 10, 1, 100];


};

I go from 70 - 5 fps whenever I'm around the sound. Sound is OGG format and 66 kb.

Share this post


Link to post
Share on other sites
Calling playsound3d in endless loop is a very very bad idea.

That and no suspension....

Share this post


Link to post
Share on other sites

while {true} do

{

playSound3D [MISSION_ROOT + "Sounds\Azan.ogg", sound2, false, getPos sound2, 10, 1, 100];


};

What happens is that the game attempts to start playing that sound again, for every frame (?). For every while loop you should have at least a small delay until the next loop starts, unless you really want something to happen 30 times per second.

So assuming your sound file is 10 seconds long, you should loop like this:

while {true} do

{

playSound3D [MISSION_ROOT + "Sounds\Azan.ogg", sound2, false, getPos sound2, 10, 1, 100];

sleep 10;  
};

I am not sure, but there should be a cleaner way to loop a sound endlessly.

Share this post


Link to post
Share on other sites
I am not sure, but there should be a cleaner way to loop a sound endlessly.

I thought that maybe one of the "play sound" commands would have a return on when the file was done playing, but that doesn't seem to be the case, or maybe I'm not looking in the right spots?

Share this post


Link to post
Share on other sites

trigger effect loops the sound automatically, not sure if it understands custom sounds added to mission config, if it does, best solution right there.

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  

×