JK and MotS Editing >> Cog, AI, and Templates >> Sound priority     (Moderator: Admins) Previous Topic | Next Topic
Page 1 of 1
 Author 
 Post 
Post 05-Jul-2012 20:45        

So I made this cog that plays .wavs for an in game soundtrack and the first line of code plays a sound once through and the second line loops a second sound over and over. The first track has problems cause sometimes when multiple sounds are played in game the track stops but it never happens with the looping track. I was wondering if it had something to do with sound priorities that are set in the .cog? If it does I would appreciate it if someone could tell me how to fix it. If its something else then I would appreciate any help with that too.
Post 09-Jul-2012 19:33        

The only priority I've seen for sound has been this one flag in the PlaySound cog verbs.

JK has a maximum of up to 24 channels, which is set in the Setup -> Sound. If you were to play more than 24 sounds (or what is set in the Setup), the first ones would be cut if not looped. If all are looped, the last ones won't play.

You would have to either be stingy with your sounds, optimize to play sounds only if they are in earshot, or set the loop flag on the first part of the tune and after the timer (sleep, whatever) stop the first loop before the main loop.

Here's a nice line of code:

if( VectorDist( GetThingPos( soundEmitter ), GetThingPos( GetPrimaryFocus( GetCurrentCamera() ) ) ) < soundMaxDistance / 10 )

if the distance between the soundEmitter and the current camera is less than the max distance that the sound can be heard (and converted to JKUnits)...

Hope this helps.
/Edward
Post 11-Jul-2012 06:13        

K, thanks, I'll see what I cant do. One other thing I was wondering. Can you change the volume of the sound? Cause for me the music is a little too quiet.
Post 11-Jul-2012 06:30        

Oh, fixed it. Put 0x100 flags in the line of code and haven't had problems with it yet, even with only 8 digie channels set.
Post 14-Jul-2012 12:42        

The volume part of the PlaySound verb can only go from 0.00 (off) to 1.00 (full). If it is at full and still too quiet, then you'll have to edit the WAV file and BOOST!

/Edward
*** Post commands are unavailable for guests. ***