Jump to content

Playing sounds longer than 10 seconds...


Domitan Redenblack
 Share

You are about to reply to a thread that has been inactive for 298 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

if I have music or sounds longer than 10 seconds, is there a way to play them without resorting to parcel media or media on a prim?

I see that setting up sound queuing only allows two sounds to be played, e.g. 20 seconds.

Are there any workaround or clever hacks?

btw- I have a piano in SL that will play long musical pieces, very nicely too, but the creator has not responded to me at all about getting more sounds, or how he was achieved this.

Link to comment
Share on other sites

Hmmm, a typical LL mess. Just enough control left out for it to be a total bitch to do anything right.

One thing I am not clear on: When you set sound queuing, does that allow only two sounds to be queued, or only two-at-a-time?

If I queue two 10 second sounds, then wait 11 seconds and queue another, will that work seamlessly?

 

Link to comment
Share on other sites

Only two at a time.  If you studied that thread, you probably saw that the way to handle sequential sound clips smoothly is to create them all with identical lengths and then play one clip while preloading the next one.  Stay one clip ahead of the listener so that there are no loading gaps in between them.  If the clips truly are exactly the same length, and if your timer is set to that length, then sound queueing is not necessary, in theory.  In practice, it helps to set the timer to be just slightly shorter than the clip lengths and let sound queueing buffer the difference.  If you set the timer to be longer than the clip lengths, then you'll hear gaps, even if sound queueing is active.

  • Like 1
Link to comment
Share on other sites

Rolig, so you are saying there is no way to actually butt two sounds up tight, other than the first pair? Have I misunderstood?

From then on, it's blind luck?

I would think sometimes lag or server-side delays of each a second would totally muck up any attempt to "blink lock" two sounds.

If the time delay is a smidgen too short, then you clip off the end of the previous sound, yes? And if it's a smidgen too long, then you get a silent gap?

Is there seriously no other way to do this that truly butts sequential sounds together after the first pair?

LL are the Three Stooges of coporate management
Woob woob woob woob °͜°

Link to comment
Share on other sites

No, that's not what I'm saying at all.  You get the sequential clips to butt smoothly by doing exactly what I said... Make them as close to identical length as you can, use llSetSoundQueueing, and set a timer to play one clip and preload the next at the same time, using a cycle time that is just slightly shorter than the length of your clips.  There's no way you can get around the fact that lag can still make things choppy, but aside from that inevitable issue, you should hear smooth sequencing.

Link to comment
Share on other sites

Right.  That's why it works to set the timer cycle just a tiny bit short of the clip length.

(1) Clip #1 plays, Clip #2 preloads

(2) Timer cycle ends, but Clip #1 continues to play to its end because of queueing, Clip #2 is ready to play

(3) Clip #2 plays, Clip #3 preloads

(4) Timer cycle ends, but Clip #2 continues to play to its end bcause of queueing, Clip #3 is ready to play

And so on.  The next clip is played a little bit later in each timer cycle because the previous clip is still playing, but that's OK. So long as the difference between the length of your sound clips and the length of the timer cycle is tiny, those accumulated offsets don't amount to much and they keep being pushed forward.  You get to the end of the long sequence of clips and the script resets, clearing everything to start again.

Link to comment
Share on other sites

this should play as many chained sounds as memory allows...

float vFltSndLen = 9.0; //-- length of each sound file in sequence (last one can be any length)list  vLstSndNms = ["a", "b", "c", "d"]; //-- names of all the sound files in orderinteger vIdxSndNum; //-- used to track which sound to playdefault{	state_entry(){		vFltSndLen *= 2.0; //-- double length now so the timer function is simpler		llSetSoundQueueing( TRUE );	}		touch_end( integer vIntTch ){		if (vIdxSndNum){			llSay( 0, "wait for it to finish" );		}else{			vIdxSnd = ([] != vLstSndNms); //-- same as (-llGetlistLength( vLstSndNms ))			llPlaySound( llList2String( vLstSndNms, vIdxSnd ), 1.0 );			llResetTime();			llSetTimerEvent( 1.0 ); //-- pad the start time for the next sound		}	}		timer(){		if (++vIdxSndNum){			llPlaySound( llList2String( vLstSndNms, vIdxSnd ), 1.0 );			llSetTimerEvent( vFltSndLen - (llGetAndResetTime() - vFltSndLen) );			//-- time will never be less than actual sound length thanks to time dilation //-- this ensures that we continually adjust to hit the realtime mark loading just after pad time //-- and shouldn't fail unless the average dilation was below ~0.6		}else{			llSetTimerEvent( 0.0 );		}	}}

 

  • Like 2
Link to comment
Share on other sites

  • 6 months later...
  • 1 year later...

To play a sequence of sounds having different lengths you could use a code like this:

// Variableslist sound = ["sound1","sound2","sound3"];list sleep = [7.5, 8.5, 7.5, 8.5, 6.0];        integer index;        default{    state_entry(){        llSetSoundQueueing( TRUE );            }        touch_end( integer vIntTch )    {        integer length = (llGetListLength(sound)-1);            while (index < length)        {            llPlaySound( llList2String( sound, index ), 1.0 );                    llPreloadSound(llList2String( sound, (index+1)));                llSleep(llList2Float( sleep, index ));            ++index;        }        if (index == length)        {            llPlaySound( llList2String( sound, index ), 1.0 );                llSleep(llList2Float( sleep, index ));            llResetScript();        }    }}

 

Link to comment
Share on other sites

Yes, although it might still be smart to use something like Void's suggestion to deal with any effects of lag.  That also has the advantage of avoiding llSleep, which makes your entire script non-responsive.  That's an important consideration if there are other potential events (collision, listen, sensor ...) that may need to get the script's attention while it is sleeping.

Link to comment
Share on other sites

I am trying to use a timer for dealing with sounds with different length but I get ERROR: Name not defined within scope in // line 22

list sound = ["sound1", "sound2", "sound3", "sound4", "sound5", "sound6"];list SndLength = [7.5, 8.5, 7.5, 8.5, 6.0]; // Aproximate length of each sound    integer Sound2Play; //-- used to track which sound to playdefault{    state_entry(){        llSetSoundQueueing( TRUE );    }        touch_end( integer vIntTch ){        if (Sound2Play){            llSay( 0, "wait for it to finish" );        }else{            integer index = (-llGetlistLength( sound ));            integer indexSndLength = (-llGetlistLength( SndLength));			llPlaySound( llList2String( sound, index ), 1.0 );            llSetTimerEvent(llList2Float( SndLength, indexSndLength ));        }    }        timer(){        if (++Sound2Play){
// Line 22 below: llPlaySound( llList2String( sound, index ), 1.0 ); llSetTimerEvent(llList2Float( SndLength, indexSndLength )); }else{ llSetTimerEvent( 0.0 ); } }}

 

 

Link to comment
Share on other sites

If I place

integer index = (-llGetlistLength( sound ));integer indexSndLength = (-llGetlistLength( SndLength));

 Before "default{"

I get Error: syntax error.

So far I just left "Sound2Play" as it is since the original script says its used to track which sound to play. I'll deal with that after I know how to set a global variable.

 

Link to comment
Share on other sites

Ah right!

You can't do any sort of calculation when you declare globals so llGetListLength() is out.  All you put there is 'integer index;' and 'integer indexSndLength'.  Leave the instructions that set these in your touch_end() event handler BUT remove the type-declaration 'integer's (because you've now already defined them that way as globals).

They'll then be declared as globals at the start of the script, set in touch_end() and available in time().

Link to comment
Share on other sites

Finally I got it right as follows, thanks everyone for the help :)

list sound = ["sound1", "sound2", "sound3", "sound4", "sound5", "sound6"];integer index; // used to track which sound to playinteger length; // used to cound number of soundslist ST = [7.5, 8.5, 7.5, 8.5, 6.0]; // Aproximate length of each sound   default{	on_rez(integer start_param){		llResetScript(); 	}	    state_entry(){        llSetSoundQueueing( TRUE );            length = llGetListLength(sound); 		llSetTimerEvent( 0.0 );    }       touch_end( integer vIntTch ){        if (index != 0){            llSay( 0, "wait for it to finish" );        }else if (index == 0){		            llPlaySound( llList2String( sound, index ), 1.0 );            llSetTimerEvent(llList2Float( ST, index ));			++index;        }    }    timer(){        if (index < (length-1)){            llPlaySound( llList2String( sound, index ), 1.0 );            llSetTimerEvent(llList2Float( ST, index ));			++index;        }else{		            llPlaySound( llList2String( sound, index ), 1.0 );			index = 0;			llSetTimerEvent(0.0);        }    }    }

 

Link to comment
Share on other sites

  • 1 year later...

I've been playing around with this script however it doesn't seem to work past the forth sound. 

 

list sound = ["Jaguarapart01", "jaguarapart02", "jaguarapart03", "jaguarapart04", "Jaguarapart05", "Jaguarapart06", "Jaguarapart07", "Jaguarapart08", "Jaguarapart09", "Jaguarapart10", "Jaguarapart11", "Jaguarapart12", "Jaguarapart13", "Jaguarapart14", "Jaguarapart15", "Jaguarapart16", "Jaguarapart17", "Jaguarapart18", "Jaguarapart19"];
integer index; // used to track which sound to play
integer length; // used to cound number of sounds
list ST = [9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0]; // Aproximate length of each sound

default{
on_rez(integer start_param){
llResetScript();
}

state_entry(){
llSetSoundQueueing( TRUE );
length = llGetListLength(sound);
llSetTimerEvent( 0.0 );
}

touch_end( integer vIntTch ){
if (index != 0){
llSay( 0, "wait for it to finish" );
}else if (index == 0){
llPlaySound( llList2String( sound, index ), 1.0 );
llSetTimerEvent(llList2Float( ST, index ));
++index;
}
}

timer(){
if (index < (length-1)){
llPlaySound( llList2String( sound, index ), 1.0 );
llSetTimerEvent(llList2Float( ST, index ));
++index;
}else{
llPlaySound( llList2String( sound, index ), 1.0 );
index = 0;
llSetTimerEvent(0.0);
}
}
}

Link to comment
Share on other sites

  • 11 months later...
You are about to reply to a thread that has been inactive for 298 days.

Please take a moment to consider if this thread is worth bumping.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...