Sound
A prim plays sounds from its inventory or by asset key. Attached sounds follow the prim, and a prim has one attached sound at a time. Triggered sounds play at a fixed position and can overlap.
Volume runs from 0.0 to 1.0. Sound radius, queueing and preloading help sounds start on time and stay in range.
Streaming music is not a prim sound: it belongs to the parcel.
Concepts
- Attached sounds: play once,
looporstop - Triggered sounds play at the prim’s position without being attached to it, optionally limited to a box
- They do not move with the object and cannot be stopped or adjusted
- Adjust the volume of a playing sound, limit how far it carries, and preload sounds so they play without delay
- With
queueingon, the next sound waits for the current one to finish- Engines and weapons play a start sound, a loop for as long as needed, and an end sound without a pop at the transitions
- A master loop and slave sounds keep several prims in time with each other
- Replace the default collision sound; rezzed projectiles get their sounds at rez time
Functions and events
void | llPlaySound(string sound, float volume) |
void | llLoopSound(string sound, float volume) |
void | llStopSound() |
void | llTriggerSound(string sound, float volume) |
void | llLinkPlaySound(integer link, string sound, float volume, integer flags) |
void | llAdjustSoundVolume(float volume) |
void | llSetSoundRadius(float radius) |
void | llPreloadSound(string sound) |
void | llSetSoundQueueing(integer queue) |
Start-loop-end sounds
Call llSetSoundQueueing(TRUE), then queue a start sound, a looped sound and an end sound; each waits for the one before it. The queue is one level deep.
Parcel music
Streaming music belongs to the parcel, not the prim. The object owner must match the landowner or land group.
Scripting Details
void | llPlaySound(string sound, float volume)Plays the specified sound once at volume, attached to the object. Only one sound can be attached to a prim at a time; new sounds or calling llStopSound stops previous playback. A second call with the same sound adjusts the volume without restarting it. |
void | llLoopSound(string sound, float volume)Plays the attached sound looping indefinitely at the specified volume. Only one sound can be attached to a prim at a time; new loops adjust the volume of the currently playing sound without restarting it. |
void | llStopSound()Stops playback of the currently playing attached sound. |
void | llTriggerSound(string sound, float volume)Plays specified sound once at volume, centered at the object's current position but not attached (does not move with the object and cannot be stopped or adjusted). Does not affect attached sounds. |
void | llTriggerSoundLimited(string sound, float volume, vector top_north_east, vector bottom_south_west)Plays the specified sound once at volume, centered at the object but not attached, restricted to the axis-aligned bounding box defined by the coordinates top_north_east and bottom_south_west. |
void | llLinkPlaySound(integer link, string sound, float volume, integer flags)Plays the specified sound on the linked prim link (once or looping) at volume. Only one sound can be attached to a prim at a time; new attachments or calling llStopSound stops previous playback. Controlled by flags. |
void | llLinkStopSound(integer link)Stops the playback of any currently playing attached sound on the linked prim link. |
void | llAdjustSoundVolume(float volume)Adjusts the volume of the currently playing attached sound (has no effect on sounds started with llTriggerSound). |
void | llLinkAdjustSoundVolume(integer link, float volume)Adjusts the volume of the currently playing sound attached to the linked prim link (has no effect on sounds started with llTriggerSound). |
void | llSetSoundRadius(float radius)Limits the audibility radius of attached and triggered scripted sounds to distance radius. |
void | llLinkSetSoundRadius(integer link, float radius)Limits the audibility radius of attached and triggered scripted sounds to distance radius (in meters) around the linked prim link. |
void | llPreloadSound(string sound)Causes nearby viewers in range to preload the specified sound from the object's inventory to prevent playback delays. |
void | llSetSoundQueueing(integer queue)Sets whether attached sounds wait for the current sound to end before playing (enables queuing if queue is TRUE, disables if FALSE). The queue is one level deep. |
void | llLinkSetSoundQueueing(integer link, integer queue)Enables or disables sound queuing on the linked prim link. When set to TRUE, sounds will queue and play in sequence. |
void | llLoopSoundMaster(string sound, float volume)Plays the attached sound looping indefinitely at the specified volume and declares it a Sync Master, forcing slave sounds to synchronize with it. |
void | llLoopSoundSlave(string sound, float volume)Plays the attached sound looping indefinitely at the specified volume, synchronized to the most audible active Sync Master in range. |
void | llPlaySoundSlave(string sound, float volume)Plays the attached sound once at volume, synchronized to the next loop point of the most audible active Sync Master. |
void | llCollisionSound(string impact_sound, float impact_volume)Suppresses default collision sounds and replaces default impact sounds with impact_sound at the volume level specified by impact_volume. Supply an empty string to only suppress collision sounds. |
Additional
llLinkPlaySound— playback flags (PlaySoundFlag)SOUND_PLAY— Play once, attached (default)SOUND_LOOP— Loop until stoppedSOUND_TRIGGER— Trigger once at the prim’s position, not attached; overrides the other flagsSOUND_SYNC— Synchronise to the nearest sound master
llRezObjectWithParams— set a projectile’s sounds before the object existsREZ_SOUND— Attach and play a sound, optionally loopingREZ_SOUND_COLLIDE— Sound to play on collision with an object, the ground or an avatar
llCollisionSound— an empty string only suppresses collision sounds (Physics)llSetParcelMusicURLandllGetParcelMusicURL— the parcel’s streaming music URL (Land)
Constant groups
Section titled “Constant groups”Constant groups PlaySoundFlag 4
Related
Section titled “Related”See also Feature PhysicsFeature Parcels & RegionsCategory SoundSL Wiki LSL SoundPlanned Recipe: trigger a random sound from a list of keysPlanned Guide: start-loop-end sounds for engines and weapons