# llLinkSetSoundQueueing

*LSL function*

```lsl
void llLinkSetSoundQueueing(integer link, integer queue);
```

- `integer link`: Link number (1 for root, >1 for children) or a LINK_* flag.
- `integer queue`: Boolean. If TRUE, sound queuing is enabled; if FALSE, it is disabled.

- Energy: 10

Set whether attached sounds wait for the current sound to finish. If **queue** is [TRUE](/constants/TRUE/), queuing is enabled, if [FALSE](/constants/FALSE/) queuing is disabled. Sound queuing is disabled by default.

```lsl title="How to use" frame="terminal"
llLinkSetSoundQueueing(0, 0);
```

## 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](#svc-4260)
- Further to the above, the queue order is reversed when using [llPlaySoundSlave](/functions/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](/functions/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](/functions/llPreloadSound/) is not always reliable in doing its job.
- Queueing a sound that is identical to the one currently playing will fail. Use [llLoopSound](/functions/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

<details open>
<summary>Example 1</summary>

```lsl
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.
    }
}
```

</details>

## History

Added in [SL 0.2.0](http://secondlife.wikia.com/wiki/Version_0.2.0), the queue is only one level deep.

## Known issues

From the issue templates included by the wiki article:

- SVC-4260 (fs): Since llSetSoundQueueing only allows two sounds to be played in queue can it be changed to allow more?

## Related functions

The original wiki page documents these functions together with this one:

- [llSetSoundQueueing](/functions/llSetSoundQueueing/)

## See also

### Functions

- [llLoopSound](/functions/llLoopSound/)
- [llLoopSoundSlave](/functions/llLoopSoundSlave/) — 3=Plays a looped sound `attached`, synced with the master.
- [llPlaySoundSlave](/functions/llPlaySoundSlave/) — 3=Plays a sound once `attached`, synced with the master.
- [llAdjustSoundVolume](/functions/llAdjustSoundVolume/) — 3=Adjusts the volume of playing sound(s).

---

*Source: [LlSetSoundQueueing](https://wiki.secondlife.com/wiki/LlSetSoundQueueing) on the Second Life Wiki. Content from the Second Life Wiki articles LlSetSoundQueueing (revision 1213226, 2023-02-03), Template:Issues/SVC-4260 (revision 375943, 2009-05-28), Template:LSL Function/boolean (revision 1185613, 2013-12-24) and Template:LSL Function/link-face (revision 1186827, 2014-01-12), CC BY-SA 3.0.*

---

From lsl.dev: https://lsl.dev/functions/llLinkSetSoundQueueing/
