Difference between revisions of "LlLinkPlaySound"
Rider Linden (talk | contribs) (Created page with "{{LSL_Function |inject-2={{LSL Function/link-face|link}} {{LSL_Function/inventory|sound|uuid=true|type=sound|volume=volume}}{{LSL Function/link-face|link}} |func_id=86|func_sl...") |
m (New functions don't have ids) |
||
Line 2: | Line 2: | ||
|inject-2={{LSL Function/link-face|link}} | |inject-2={{LSL Function/link-face|link}} | ||
{{LSL_Function/inventory|sound|uuid=true|type=sound|volume=volume}}{{LSL Function/link-face|link}} | {{LSL_Function/inventory|sound|uuid=true|type=sound|volume=volume}}{{LSL Function/link-face|link}} | ||
|func_id= | |func_id=|func_sleep=0.0|func_energy=10.0 | ||
|func=llLinkPlaySound|sort=LinkPlaySound | |func=llLinkPlaySound|sort=LinkPlaySound | ||
|p1_type=integer|p1_subtype=link|p1_name=link | |p1_type=integer|p1_subtype=link|p1_name=link |
Revision as of 04:27, 3 February 2023
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: llLinkPlaySound( integer link, string sound, float volume, integer flags );0.0 | Forced Delay |
10.0 | Energy |
Plays attached sound once at volume
• integer | link | – | Link number (0: unlinked, 1: root prim, >1: child prims and seated avatars) or a LINK_* flag
|
|
• string | sound | – | a sound in the inventory of the prim this script is in or a UUID of a sound | |
• float | volume | – | between 0.0 (silent) and 1.0 (loud) (0.0 <= volume <= 1.0 )
|
|
• integer | flags | – | Bit flags used to control how the sound is played. |
|
|
Constant | Value | Description | LSL Function |
---|---|---|---|
SOUND_PLAY | 0x00 | This is the default behavior. Plays the sound once, attached to the linked primitive. | llPlaySound |
SOUND_LOOP | 0x01 | Loops the sound attached to the linked primitive. | llLoopSound |
SOUND_TRIGGER | 0x02 | Triggers the sound at the location of the linked prim. The sound is not attached and does not move with the prim.
If this flag is set it overrides all others. |
llTriggerSound |
SOUND_SYNC | 0x04 | Synchronizes sound playback to the nearest sound master. Please see llLoopSoundMaster. |
Caveats
- If sound is missing from the prim's inventory and it is not a UUID or it is not a sound then an error is shouted on DEBUG_CHANNEL.
- If sound is a UUID then there are no new asset permissions consequences for the object.
- The resulting object develops no new usage restrictions that might have occurred if the asset had been placed in the prims inventory.
- A call to llPlaySound replaces any other sound (so that only one sound can be played at the same time from the same prim), except sounds started with the deprecated llSound which always plays sound files till the end.
- Sound files must be 30 seconds or shorter.
- Sounds are always sampled at 44.1KHz, 16-bit, mono (stereo files will have one channel dropped--merged (as in combined)--when uploading).
- If the object playing the sound is a HUD, the sound is only heard by the user the HUD is attached to.
- To play a sound inworld from a HUD use llTriggerSound.
- It is impossible to play two (or more) sounds at the same time and have them start playing at exactly the same time ~ VWR-15663
- If multiple sound emitters play the same exact sound within range of the viewer at the same time, they are usually not in sync due to latency between the server/client and script execution & communication delays. This can produce echos, odd resonance, and other strange effects that you (probably) do not want.
- When used in conjunction with llSetSoundQueueing, sounds may incorrectly play more than once. This can be fixed by disabling the sound queue if only a single sound sample is to be played.
Examples
default
{
state_entry()
{
llPlaySound("some_sound",1.0);
}
}
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.
llGetNumberOfPrims()
- Returns the number of prims and seated avatars.llGetObjectPrimCount(llGetKey())
- Returns only the number of prims in the object but will return zero for attachments.
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.
}
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. | |
• | llGetLinkNumberOfSides | – | Returns the number of faces of the linked prim. | |
• | llTriggerSound | – | Plays a sound unattached. | |
• | llTriggerSoundLimited | |||
• | llLoopSound | – | Plays a sound attached. | |
• | llLoopSoundMaster | |||
• | llLoopSoundSlave | |||
• | llPlaySoundSlave | |||
• | llSetSoundQueueing | – | Sets a prim property which allows sounds to be queued, instead of overwriting eachother. | |
• | llStopSound |