Difference between revisions of "LlSetSoundQueueing"

From Second Life Wiki
Jump to navigation Jump to search
m
m (New functions don't have IDs)
 
(21 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{LSL_Function/boolean|queue|pd=sound queuing:|fd=disables (default)|bool=*}}
{{LSL_Function/Headless
{{LSL_Function
|inject-2={{Issues/SVC-4260}}{{LSL_Function/boolean|queue|pd=sound queuing:|bool=*|default=false}}{{LSL Function/link-face|link}}
 
|head={{LSL Function/Head
|func=llSetSoundQueueing
|p1_type=integer|p1_subtype=boolean|p1_name=queue
|func_id=208|func_sleep=0.0|func_energy=10.0
|func_id=208|func_sleep=0.0|func_energy=10.0
|func=llSetSoundQueueing
|p1_type=integer|p1_name=queue
|func_footnote
|func_footnote
|func_desc=Set whether attached sounds wait for the current sound to finish. If '''queue''' is [[TRUE]], queuing is enabled, if [[FALSE]] queuing is disabled. Sound queuing is disabled by default.
|func_desc
|return_text
}}
{{LSL Function/Head
|func=llLinkSetSoundQueueing
|p1_type=integer|p1_subtype=link|p1_name=link
|p2_type=integer|p2_subtype=boolean|p2_name=queue
|func_id=|func_sleep=0.0|func_energy=10.0
|func_footnote
|func_desc
|return_text
|return_text
|spec
}}
|summary=Set whether attached sounds wait for the current sound to finish. If {{LSLP|queue}} is [[TRUE]], queuing is enabled, if [[FALSE]] queuing is disabled. Sound queuing is disabled by default.
|caveats=
|caveats=
*It appears that only two sounds can be queued at a time.
*The sound queue is only 1 level deep - this means that beside the sound that is currently playing, there can only be 1 sound in reserve. The sound queue is first-come, first-serve.* [[#SVC-4260|SVC-4260]]
*Sound queuing is a property of the prim, not the script. It can be activated and deactivated by any script in the prim and survives script reset, rerez and script removal.
*Further to the above, the queue order is reversed when using [[llPlaySoundSlave]] - using the below example, the default behaviour would be to play SoundName1 and SoundName2, however when using the aforementioned function the order would be to play SoundName2 and SoundName3.
*Sound queuing is a property of the prim, not the script. It can be activated and deactivated by any script in the prim and survives script reset, re-rez and script removal.
*If used to make smooth transitions using slave/master sounds the sounds tend to go out of sync.
*Although sounds are queued, the volume of all sounds in the queue is set by the last item in the queue. If your application requires the use of differing volume values, you may wish to implement [[llAdjustSoundVolume]] alongside the sound queue
*There is a very small (but audible) gap of silence between sounds due to network latency and processing time.
*The queued sound must be fully loaded in the viewer, or else it will not play. [[llPreloadSound]] is not always reliable in doing its job.
*Queueing a sound that is identical to the one currently playing will fail. Use [[llLoopSound]] instead.
*While this function does not have a delay, enabling or disabling the sound queue is not instant. It seems to take approx ~0.1 seconds to set the queueing flag.
|constants
|constants
|examples=
|examples=
<lsl>
<syntaxhighlight lang="lsl2">
default
default
{
{
Line 20: Line 39:
         llPreloadSound("SoundName1");//This loads the sounds into all in range viewers and cuts delay between sounds.
         llPreloadSound("SoundName1");//This loads the sounds into all in range viewers and cuts delay between sounds.
         llPreloadSound("SoundName2");//All sound parameters can be the name of a sound in the prim's inventory or a UUID of a sound");
         llPreloadSound("SoundName2");//All sound parameters can be the name of a sound in the prim's inventory or a UUID of a sound");
        llPreloadSound("SoundName3"); //This sound will be skipped, as the queue is only 1 level deep.
     }
     }
     touch_start(integer detected)
     touch_start(integer detected)
     {
     {
         llSetSoundQueueing(TRUE);//Set to TRUE for queueing and SoundName2 plays after the SoundName1 has ended.
         llSetSoundQueueing(TRUE);//Set to TRUE for queueing and SoundName2 plays after the SoundName1 has ended.
         //Set to FALSE only the second will be played since the prim has only one sound emmiter and the second was called last.
         //Set to FALSE only the second will be played since the prim has only one sound emitter and the second was called last.
         //Can be set anywhere withing the script (if within an event it will activate when the event is triggered.
         //Can be set anywhere within the script (if within an event it will activate when the event is triggered.
         llPlaySound("SoundName1", 1.0);
         llPlaySound("SoundName1", 1.0);
         llPlaySound("SoundName2", 1.0);
         llPlaySound("SoundName2", 1.0);
        llPlaySound("SoundName3", 1.0); //This sound isn't played as the queue is already full, so this is discarded.
     }
     }
}
}
</lsl>
</syntaxhighlight>
|helpers
|helpers
|also_functions={{LSL DefineRow||[[llLoopSound]]}}
|also_functions={{LSL DefineRow||[[llLoopSound]]}}
{{LSL DefineRow||[[llLoopSoundSlave]]|3=Plays a sound {{HoverText|attached|The sound moves with the prim}}.}}
{{LSL DefineRow||[[llLoopSoundSlave]]|3=Plays a looped sound {{HoverText|attached|The sound moves with the prim}}, synced with the master.}}
{{LSL DefineRow||[[llPlaySoundSlave]]|3=Plays a sound once {{HoverText|attached|The sound moves with the prim}}, synced with the master.}}
{{LSL DefineRow||[[llAdjustSoundVolume]]|3=Adjusts the volume of playing sound(s).}}
|also_tests
|also_tests
|also_events
|also_events
Line 42: Line 65:
|cat3
|cat3
|cat4
|cat4
|history={{LSL Added|0.2.0|remote=http://secondlife.wikia.com/wiki/Version_0.2.0}}, the queue is only one level deep.
}}
}}

Latest revision as of 04:29, 3 February 2023

Summary

Summary: llSetSoundQueueing, llLinkSetSoundQueueing

Set whether attached sounds wait for the current sound to finish. If queue is TRUE, queuing is enabled, if FALSE queuing is disabled. Sound queuing is disabled by default.

llSetSoundQueueing

Function: llSetSoundQueueing( integer queue );
0.0 Forced Delay
10.0 Energy
• integer queue boolean, sound queuing: TRUE enables, FALSE (default) disables

llLinkSetSoundQueueing

Function: llLinkSetSoundQueueing( integer link, integer queue );
0.0 Forced Delay
10.0 Energy
• integer link Link number (0: unlinked, 1: root prim, >1: child prims and seated avatars) or a LINK_* flag
• integer queue boolean, sound queuing: TRUE enables, FALSE (default) disables
Flag Description
LINK_ROOT 1 refers to the root prim in a multi-prim linked set[1]
LINK_SET -1 refers to all prims
LINK_ALL_OTHERS -2 refers to all other prims
Flag Description
LINK_ALL_CHILDREN -3 refers to all children, (everything but the root)
LINK_THIS -4 refers to the prim the script is in

Caveats

  • The sound queue is only 1 level deep - this means that beside the sound that is currently playing, there can only be 1 sound in reserve. The sound queue is first-come, first-serve.* SVC-4260
  • Further to the above, the queue order is reversed when using llPlaySoundSlave - using the below example, the default behaviour would be to play SoundName1 and SoundName2, however when using the aforementioned function the order would be to play SoundName2 and SoundName3.
  • Sound queuing is a property of the prim, not the script. It can be activated and deactivated by any script in the prim and survives script reset, re-rez and script removal.
  • If used to make smooth transitions using slave/master sounds the sounds tend to go out of sync.
  • Although sounds are queued, the volume of all sounds in the queue is set by the last item in the queue. If your application requires the use of differing volume values, you may wish to implement llAdjustSoundVolume alongside the sound queue
  • There is a very small (but audible) gap of silence between sounds due to network latency and processing time.
  • The queued sound must be fully loaded in the viewer, or else it will not play. llPreloadSound is not always reliable in doing its job.
  • Queueing a sound that is identical to the one currently playing will fail. Use llLoopSound instead.
  • While this function does not have a delay, enabling or disabling the sound queue is not instant. It seems to take approx ~0.1 seconds to set the queueing flag.

Examples

default
{
    state_entry()
    {
        llPreloadSound("SoundName1");//This loads the sounds into all in range viewers and cuts delay between sounds.
        llPreloadSound("SoundName2");//All sound parameters can be the name of a sound in the prim's inventory or a UUID of a sound");
        llPreloadSound("SoundName3"); //This sound will be skipped, as the queue is only 1 level deep.
    }
    touch_start(integer detected)
    {
        llSetSoundQueueing(TRUE);//Set to TRUE for queueing and SoundName2 plays after the SoundName1 has ended.
        //Set to FALSE only the second will be played since the prim has only one sound emitter and the second was called last.
        //Can be set anywhere within the script (if within an event it will activate when the event is triggered.
        llPlaySound("SoundName1", 1.0);
        llPlaySound("SoundName2", 1.0);
        llPlaySound("SoundName3", 1.0); //This sound isn't played as the queue is already full, so this is discarded.
    }
}

Notes

Link Numbers

Each prim that makes up an object has an address, a link number. To access a specific prim in the object, the prim's link number must be known. In addition to prims having link numbers, avatars seated upon the object do as well.

  • If an object consists of only one prim, and there are no avatars seated upon it, the (root) prim's link number is zero.
  • However, if the object is made up of multiple prims or there is an avatar seated upon the object, the root prim's link number is one.

When an avatar sits on an object, it is added to the end of the link set and will have the largest link number. In addition to this, while an avatar is seated upon an object, the object is unable to link or unlink prims without unseating all avatars first.

Counting Prims & Avatars

There are two functions of interest when trying to find the number of prims and avatars on an object.

integer GetPrimCount() { //always returns only the number of prims
    if(llGetAttached())//Is it attached?
        return llGetNumberOfPrims();//returns avatars and prims but attachments can't be sat on.
    return llGetObjectPrimCount(llGetKey());//returns only prims but won't work on attachments.
}
See llGetNumberOfPrims for more about counting prims and avatars.

Errata

If a script located in a child prim erroneously attempts to access link 0, it will get or set the property of the linkset's root prim. This bug (BUG-5049) is preserved for broken legacy scripts.

See Also

Functions

•  llGetLinkNumber Returns the link number of the prim the script is in.
•  llGetLinkNumberOfSides Returns the number of faces of the linked prim.
•  llLoopSound
•  llLoopSoundSlave Plays a looped sound attached, synced with the master.
•  llPlaySoundSlave Plays a sound once attached, synced with the master.
•  llAdjustSoundVolume Adjusts the volume of playing sound(s).

Deep Notes

History

Footnotes

  1. ^ LINK_ROOT does not work on single prim objects. Unless there is an avatar sitting on the object.
  2. ^ Early release notes were not very accurate or thorough, they sometimes included information about features added in previous releases or failed to include information about features added in that release.

Signature

function void llSetSoundQueueing( integer queue );
function void llLinkSetSoundQueueing( integer link, integer queue );