Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Synchronized sound from multiple prims

eldodo Fierrens
Registered User
Join date: 27 Feb 2008
Posts: 5
03-01-2009 09:48
Hi,

Synchronized sound/music playback from multiple prims
I've found this script from Huns Valen in the Library.

I would adapt the script below instead of the Player script, The Sound of Music, written by Sausage Turner.

CODE

string card;
integer line;
key query;

integer part=0;
integer channel=55000;
integer handle;
integer v;
integer w;

list soundlist = [];
list soundnames = [];
list b;

menu(key id)
{
if ( v < 13 )
{
b = soundnames;
}

else
{
if (part == 0)
b = llList2List(soundnames, 0, 1) + [">>"] + llList2List(soundnames, 2, 10);

else if (part == w)
b = llList2List(soundnames, part * 10 + 1, part * 10 + 2) + ["<<"] + llList2List(soundnames, part * 10 + 2, part * 10 + 10);

else if ( 0 < part < w)
b = llList2List(soundnames, part * 10 + 1, part * 10 + 1) + ["<<"] + [">>"] + llList2List(soundnames, part * 10 + 2, part * 10 + 10);
}
llDialog(id, "Choisissez un son:", b, 55000);
}

default
{
on_rez(integer start_param)
{
llSetText("Preloading....",<1,0,0>,1);
llPreloadSound(card);
llSetText("Touch To Play",<1,1,1>,1);
}
state_entry()
{
if (llGetInventoryNumber(INVENTORY_NOTECARD) == 0)
{
llOwnerSay("Aucune notecard n'a été détectée dans l'inventaire de l'objet.");
}
else
{
card = llGetInventoryName(INVENTORY_NOTECARD, 0);
query = llGetNotecardLine(card, line = 0);
}
}

changed(integer c)
{
if (c & CHANGED_INVENTORY) llResetScript();
}

dataserver(key id, string data)
{
if (query != id) return;
if (data == EOF) return;
integer i = llSubStringIndex(data, "=");
if (i >= 0) {
soundnames += [llGetSubString(data, 0, i - 1)];
soundlist += [llDeleteSubString(data, 0, i)];
}
query = llGetNotecardLine(card, ++line);
}

touch_start(integer total_number)
{
key id = llDetectedKey(0);
llListenRemove(handle);
handle = llListen(55000, "", id, "");
v = llGetListLength(soundnames);
w = llFloor( (v-3) / 10);
menu(id);
llSetTimerEvent(30.0);
}

timer()
{
llListenRemove(handle);
llSetTimerEvent(0.0);
}

listen(integer channel, string name, key id, string message)
{
if (message == ">>")
{
part += 1;
llSetTimerEvent(30.0);
menu(id);
return;
}

if (message == "<<")
{
part -= 1;
llSetTimerEvent(30.0);
menu(id);
return;
}

integer index = llListFindList(soundnames, [message]);
if (index < 0) return;
llPlaySound(llList2String(soundlist,index),1.0);
llListenRemove(handle);
llSetTimerEvent(0.0);
}
}


How to adapt the script with the slave speakers?
Thank for your help.
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
03-01-2009 23:05
instead of storing the names in the notecard, store the UUID key of the sounds, then replace the ...
llPlaySound(llList2String(soundlist,index),1.0);
with ...

llRegionSay (1234, llList2String(soundlist,index);


then, in each satellite prim, set up a listen event and listen on channel 1234, (or whatever non-zero channel you want to use), and perform an llPlaySound from there using the key instead of the sound's name.
_____________________
My tutes
http://www.youtube.com/johanlaurasia
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
03-02-2009 00:02
From: Johan Laurasia
instead of storing the names in the notecard, store the UUID key of the sounds, then replace the ...
llPlaySound(llList2String(soundlist,index),1.0);
with ...

llRegionSay (1234, llList2String(soundlist,index);


then, in each satellite prim, set up a listen event and listen on channel 1234, (or whatever non-zero channel you want to use), and perform an llPlaySound from there using the key instead of the sound's name.

oh, great idea! kind of "duh!" situation once you've thought about it or heard about it lol. can also be used with clocks and satellite chimes so you can "hear the clock" throughout the sim
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
03-02-2009 08:55
There is a script in the Library called something like Regular Timer, or Wall Clock. I forget. it behaves in accordance to the system clock rather than using messages.
_____________________
So many monkeys, so little Shakespeare.
eldodo Fierrens
Registered User
Join date: 27 Feb 2008
Posts: 5
03-06-2009 11:58
From: Johan Laurasia
instead of storing the names in the notecard, store the UUID key of the sounds, then replace the ...
llPlaySound(llList2String(soundlist,index),1.0);
with ...

llRegionSay (1234, llList2String(soundlist,index);


then, in each satellite prim, set up a listen event and listen on channel 1234, (or whatever non-zero channel you want to use), and perform an llPlaySound from there using the key instead of the sound's name.


Thank you Johan for your answer ;)
I forgot to say that the speakers are linked to the main prim that send uuid to them.