Skip to content
lsl.devlsl.devLSL Dev

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

Functions and events

voidllPlaySound(string sound, float volume)
voidllLoopSound(string sound, float volume)
voidllStopSound()
voidllTriggerSound(string sound, float volume)
voidllLinkPlaySound(integer link, string sound, float volume, integer flags)
voidllAdjustSoundVolume(float volume)
voidllSetSoundRadius(float radius)
voidllPreloadSound(string sound)
voidllSetSoundQueueing(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

voidllPlaySound(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.
voidllLoopSound(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.
voidllStopSound()
Stops playback of the currently playing attached sound.
voidllTriggerSound(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.
voidllTriggerSoundLimited(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.
voidllLinkPlaySound(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.
voidllLinkStopSound(integer link)
Stops the playback of any currently playing attached sound on the linked prim link.
voidllAdjustSoundVolume(float volume)
Adjusts the volume of the currently playing attached sound (has no effect on sounds started with llTriggerSound).
voidllLinkAdjustSoundVolume(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).
voidllSetSoundRadius(float radius)
Limits the audibility radius of attached and triggered scripted sounds to distance radius.
voidllLinkSetSoundRadius(integer link, float radius)
Limits the audibility radius of attached and triggered scripted sounds to distance radius (in meters) around the linked prim link.
voidllPreloadSound(string sound)
Causes nearby viewers in range to preload the specified sound from the object's inventory to prevent playback delays.
voidllSetSoundQueueing(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.
voidllLinkSetSoundQueueing(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.
voidllLoopSoundMaster(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.
voidllLoopSoundSlave(string sound, float volume)
Plays the attached sound looping indefinitely at the specified volume, synchronized to the most audible active Sync Master in range.
voidllPlaySoundSlave(string sound, float volume)
Plays the attached sound once at volume, synchronized to the next loop point of the most audible active Sync Master.
voidllCollisionSound(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

Constant groups PlaySoundFlag 4

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