// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Ambient loop with graceful ending // Not compiled or tested in-world // Setup: Add bed and outro. Touch once starts; second touch plays outro; a further touch silences it. // Stop / restore: Touch cycles loop, outro, silent. Reach silent before removal. // Notes: Use licensed sounds in this prim. Audio is nearby, not private. Timer timing and asset loading are approximate; no sample synchronization is promised. Outro is not automatically crossfaded; it replaces the attached loop. Status cycles idle, loop, outro. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Not compiled or tested in-world. integer phase; default { touch_start(integer n) { if(llDetectedKey(0)!=llGetOwner())return; if(phase==0) { if(llGetInventoryType("bed")==INVENTORY_SOUND) { phase=1; llLoopSound("bed",0.25); } } else if(phase==1) { llStopSound(); phase=2; if(llGetInventoryType("outro")==INVENTORY_SOUND)llPlaySound("outro",0.25); } else { phase=0; llStopSound(); } } }