llLoopSoundMaster
function
Function syntax
llLoopSoundMaster(string sound,// Name of a sound in the prim's inventory, or a UUID.float volume// Volume level to set, between 0.0 (silent) and 1.0 (loud).
);- Energy
- 10
Plays the attached sound looping indefinitely at the specified volume and declares it a Sync Master, forcing slave sounds to synchronize with it.
Plays attached sound looping at volume, declares it a sync master.
llLoopSoundMaster("", 0.0);Caveats
Section titled “Caveats”- This function is affected by the Sound Queueing property of the parent prim - this means it’s possible to queue a slave sound prior to starting a master, without having to use more than one prim as an emitter. (See below).
Examples
Section titled “Examples”Example 1
// for an uploaded .wav file called "MasterLoop" in inventoryllLoopSoundMaster("MasterLoop", 1.0);The script below is an example of how using llSetSoundQueueing affects the interaction between master and slave sounds. In the example, it is used to run a car engine.
15 collapsed lines
integer playState; //see LUT below.
list lut = ["Engine start, idle.","Accelerate, speed loop.","Decelerate, idle.", "Idle, stop"];
default{ state_entry() { llSetSoundQueueing(TRUE); //Set this so the we don't skip the 1st 'slave' sound. }
touch_start(integer total_number) { llWhisper(0, "Sound: " + llList2String(lut,playState)); if(!playState) //start engine. { llPlaySoundSlave("engine start",1); //This sound is skipped if Sound Queueing is not set. llLoopSoundMaster("idle",1); } else if(playState == 1) //accelerate, then play driving loop { llPlaySoundSlave("accelerate",1); llLoopSoundMaster("speed",1); } else if(playState == 2) //decelerate to idle. { llPlaySoundSlave("decelerate",1); llLoopSoundMaster("idle",1); } else //stop the engine.9 collapsed lines
{ llPlaySoundSlave("engine stop",1); llSleep(2); //Wait until the above sound completes. llStopSound(); //Call this to prevent the master loop from restarting randomly (e.g. upon script reset or region change). playState = -1; //This actually resets to 0, as it's incremented below. } ++playState; //increment playState. }}The script below can be added to an object, to toggle a SoundMaster on and off. Note that the script requires a sound in inventory called MasterLoop, or you need to change the argument in the function for it to work.
17 collapsed lines
//This integer (actually a boolean) will be used to manage the toggle effect.integer soundState = FALSE;//Change MasterLoop to the sound clip you want to use.string soundClip = "MasterLoop";default { state_entry() { //Displays red "OFF" as floating text above the prim llSetText("OFF", <1,0,0>, 1.0); } touch_start(integer num_detected) { //When touched, soundState inverts its current boolean value. 1 becomes 0, 0 becomes 1. soundState = !soundState; if(soundState) { //Run this code when entering soundState 'on' //Displays green "ON" as floating text above the prim llSetText("ON", <0,1,0>, 1.0); llLoopSoundMaster(soundClip, 1.0); }else { //Run this code when entering soundState 'off'6 collapsed lines
//When touched, stop sound & display red "OFF" as floating text. llSetText("OFF", <1,0,0>, 1.0); llStopSound(); } }}See also
Section titled “See also”Functions
Section titled “Functions”llLoopSound— 3=Plays a soundattachedindefinitely.llLoopSoundSlave— 3=Plays a soundattachedindefinitely, and declares it as a sync slave.llPlaySoundSlave— 3=Plays a soundattachedonce.llSetSoundQueueing— 3=Enables the ability to queue sounds.
Original wiki source
Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.