// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Crossfade source receiver // Not compiled or tested in-world // Setup: Put a licensed ambience loop in each of two children. Name them audio_a and audio_b; use the paired root named audio_mixer. // Stop / restore: Owner-touch a source stops its own sound; a held touch on the mixer stops both. Remove only after stopping. // Notes: Use licensed inventory sounds in the specified prim. Audio is nearby, not private. Simulator timers and viewer loading are approximate. Receives only root messages on code 7910. Other scripts in the same linkset can still send messages; this is coordination, not a secret protocol. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Not compiled or tested in-world. integer playing; stop() { playing=FALSE; llStopSound(); } default { touch_start(integer n) { if(llDetectedKey(0)==llGetOwner())stop(); } link_message(integer sender,integer code,string s,key data) { if(sender!=1||llGetLinkName(1)!="audio_mixer"||code!=7910)return; if(s=="stop") { stop(); return; } integer i; integer dots; integer digits; if(llStringLength(s)>12)return; for(i=0;i1)return; } else if(llSubStringIndex("0123456789",c)<0)return; else ++digits; } if(!digits)return; float mix=(float)s; if(mix<0.0||mix>1.0)return; float volume=mix; if(llGetObjectName()=="audio_a")volume=1.0-mix; else if(llGetObjectName()!="audio_b")return; volume*=0.3; if(llGetInventoryType("ambience")!=INVENTORY_SOUND)return; if(!playing) { llLoopSound("ambience",volume); playing=TRUE; } else llAdjustSoundVolume(volume); } changed(integer change) { if(change&CHANGED_LINK)stop(); } }