Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Chaining sounds

Pete Olihenge
Registered User
Join date: 9 Nov 2009
Posts: 315
01-29-2010 04:21
I'm pretty sure I've seen discussions about chaining sounds here, but can't seem to find anything now. Any suggestion from anyone? Thanks.
Dexter Ellisson
Registered User
Join date: 5 Aug 2009
Posts: 4
01-29-2010 06:13
The way I do it is probably wrong but it works a lot of the time (based on several 10 second clips):

llPlaySound("soundname1",1.0);
llSleep(9.8);
llPlaySound("soundname2",1.0);
llSleep(9.8);
llPlaySound("soundname3",1.0);
llSleep(9.8);
llPlaySound("soundname4",1.0);

I sometimes have to tweak the sleep by +/- 0.1 but generally works a treat.

That any good or does anyone have a better way of doing it?
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
01-29-2010 06:21
For the Human Trafficking exhibit that's up for this month at , I'm using a script that preloads a large stack of sound clips and then plays them back randomly through a timer event that looks like this

CODE

timer()
{
llSetSoundQueueing(TRUE);
string name = llGetInventoryName(INVENTORY_SOUND, (integer)llFrand(highsound-lowsound)+lowsound);
llPlaySound(name, 1.0);
}


where highsound and lowsound are global variables that I set elsewhere to define different subgroups of sound clips from the full inventory as people move from one portion of the exhibit to another, carrying this script in a personal player with them. I have the timer set to 10 seconds. My sound files are varying lengths, and llSetSoundQueueing keeps them from bumping into each other. If I really wanted to chain them smoothly (which isn't an issue in this particular case), I'd simply edit the clips to all be the same length. I've had success doing that before.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Pete Olihenge
Registered User
Join date: 9 Nov 2009
Posts: 315
01-29-2010 06:36
Unfortunately llSleep isn't an option here - the script needs to be awake enough to turn the sound off when requested.

What I've been trying so far - vaguely successfully - is to use a nine second timer that gets busier and polls llGetTime towards the end of each clip. I'd missed llSetSoundQueueing, and I think I can work that in to this method to good effect.

Many thanks for the suggestions.

ETA: yeah, I forgot to mention that the clips are all ten seconds long.
Pete Olihenge
Registered User
Join date: 9 Nov 2009
Posts: 315
01-29-2010 07:18
Further to this, is there any benefit to turning llSetSoundQueueing off when it's not needed, or is the act of doing so more wasteful than just leaving it on?
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
01-29-2010 10:16
I don't see any benefit, so I have just turned it on and left it. It's in the timer event in that little snippet I posted earlier, but it really should be elsewhere in the script since you only have to turn it on once. Not moving it was an oversight on my part ... an artifact of the way the script grew as I was testing it.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
01-29-2010 22:36
I used to use sleeps until I found llSetSoundQueueing(), it's definitely the way to go. One thing to consider though is that the sound while playing will continue to play until that chunk is done.
_____________________
My tutes
http://www.youtube.com/johanlaurasia