From 63da4d3f99a292aff6963f4d453ec3911be51b62 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 9 Apr 2018 00:15:45 +0100 Subject: mantis 8305: add several ossl sound funtions that accept a link number for the prim associated to that sound. The link number must point to a single prim --- .../Shared/Api/Implementation/OSSL_Api.cs | 193 +++++++++++++++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 11 ++ .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 49 ++++++ 3 files changed, 253 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 253bb06..d81054e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -144,6 +144,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api internal bool m_debuggerSafe = false; internal Dictionary m_FunctionPerms = new Dictionary(); protected IUrlModule m_UrlModule = null; + protected ISoundModule m_SoundModule = null; internal IConfig m_osslconfig; public void Initialize( @@ -160,6 +161,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); m_UrlModule = m_ScriptEngine.World.RequestModuleInterface(); + m_SoundModule = m_ScriptEngine.World.RequestModuleInterface(); + if (m_osslconfig.GetBoolean("AllowOSFunctions", false)) { m_OSFunctionsEnabled = true; @@ -4832,5 +4835,195 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api double mcross = LSL_Vector.Mag(LSL_Vector.Cross(a,b)); return Math.Atan2(mcross, dot); } + + +//******* link sound + public void osAdjustSoundVolume(LSL_Integer linknum, LSL_Float volume) + { + m_host.AddScriptLPS(1); + SceneObjectPart sop = GetSingleLinkPart(linknum); + if(sop == null) + return; + sop.AdjustSoundGain(volume); + ScriptSleep(100); + } + + public void osSetSoundRadius(LSL_Integer linknum, LSL_Float radius) + { + m_host.AddScriptLPS(1); + SceneObjectPart sop = GetSingleLinkPart(linknum); + if(sop == null) + return; + m_host.SoundRadius = radius; + } + + public void osPlaySound(LSL_Integer linknum, LSL_String sound, LSL_Float volume) + { + m_host.AddScriptLPS(1); + + if (m_SoundModule == null) + return; + + SceneObjectPart sop = GetSingleLinkPart(linknum); + if(sop == null) + return; + + UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); + if(soundID == UUID.Zero) + return; + + // send the sound, once, to all clients in range + m_SoundModule.SendSound(sop.UUID, soundID, volume, false, 0, 0, false, false); + } + + public void osLoopSound(LSL_Integer linknum, LSL_String sound, LSL_Float volume) + { + m_host.AddScriptLPS(1); + + if (m_SoundModule == null) + return; + + SceneObjectPart sop = GetSingleLinkPart(linknum); + if(sop == null) + return; + + UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); + if(soundID == UUID.Zero) + return; + + m_SoundModule.LoopSound(sop.UUID, soundID, volume, 20, false,false); + } + + public void osLoopSoundMaster(LSL_Integer linknum, LSL_String sound, LSL_Float volume) + { + m_host.AddScriptLPS(1); + + SceneObjectPart sop = GetSingleLinkPart(linknum); + if(sop == null) + return; + + UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); + if(soundID == UUID.Zero) + return; + + m_SoundModule.LoopSound(sop.UUID, soundID, volume, 20, true, false); + } + + public void osLoopSoundSlave(LSL_Integer linknum, LSL_String sound, LSL_Float volume) + { + m_host.AddScriptLPS(1); + + if (m_SoundModule == null) + return; + + SceneObjectPart sop = GetSingleLinkPart(linknum); + if(sop == null) + return; + + UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); + if(soundID == UUID.Zero) + return; + + m_SoundModule.LoopSound(sop.UUID, soundID, volume, 20, false, true); + } + + public void osPlaySoundSlave(LSL_Integer linknum, LSL_String sound, LSL_Float volume) + { + m_host.AddScriptLPS(1); + + if (m_SoundModule == null) + return; + + SceneObjectPart sop = GetSingleLinkPart(linknum); + if(sop == null) + return; + + UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); + if(soundID == UUID.Zero) + return; + + // send the sound, once, to all clients in range + m_SoundModule.SendSound(sop.UUID, soundID, volume, false, 0, 0, true, false); + } + + public void osTriggerSound(LSL_Integer linknum, LSL_String sound, LSL_Float volume) + { + m_host.AddScriptLPS(1); + + if (m_SoundModule == null) + return; + + SceneObjectPart sop = GetSingleLinkPart(linknum); + if(sop == null) + return; + + UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); + if(soundID == UUID.Zero) + return; + + // send the sound, once, to all clients in rangeTrigger or play an attached sound in this part's inventory. + m_SoundModule.SendSound(sop.UUID, soundID, volume, true, 0, 0, false, false); + } + + public void osStopSound(LSL_Integer linknum) + { + m_host.AddScriptLPS(1); + + if (m_SoundModule == null) + return; + + SceneObjectPart sop = GetSingleLinkPart(linknum); + if(sop == null) + return; + + m_SoundModule.StopSound(sop.UUID); + } + + public void osPreloadSound(LSL_Integer linknum, LSL_String sound) + { + m_host.AddScriptLPS(1); + + if (m_SoundModule == null) + return; + + SceneObjectPart sop = GetSingleLinkPart(linknum); + if(sop == null) + return; + + UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); + if(soundID == UUID.Zero) + return; + + m_SoundModule.PreloadSound(sop.UUID, soundID, 0); + ScriptSleep(1000); + } + + // get only one part + private SceneObjectPart GetSingleLinkPart(int linkType) + { + if (m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) + return null; + + switch (linkType) + { + case ScriptBaseClass.LINK_SET: + case ScriptBaseClass.LINK_ALL_OTHERS: + case ScriptBaseClass.LINK_ALL_CHILDREN: + return null; + + case 0: + case ScriptBaseClass.LINK_ROOT: + return m_host.ParentGroup.RootPart; + + case ScriptBaseClass.LINK_THIS: + return m_host; + + default: + if(linkType < 0) + return null; + + return m_host.ParentGroup.GetLinkNumPart(linkType); + } + } } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 5cabf30..818c1c4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -512,5 +512,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_Float osVecMagSquare(vector a); LSL_Float osVecDistSquare(vector a, vector b); LSL_Float osAngleBetween(vector a, vector b); + + void osAdjustSoundVolume(LSL_Integer linknum, LSL_Float volume); + void osLoopSound(LSL_Integer linknum, LSL_String sound, LSL_Float volume); + void osLoopSoundMaster(LSL_Integer linknum, LSL_String sound, LSL_Float volume); + void osLoopSoundSlave(LSL_Integer linknum, LSL_String sound, LSL_Float volume); + void osPlaySound(LSL_Integer linknum, LSL_String sound, LSL_Float volume); + void osPlaySoundSlave(LSL_Integer linknum, LSL_String sound, LSL_Float volume); + void osPreloadSound(LSL_Integer linknum, LSL_String sound); + void osSetSoundRadius(LSL_Integer linknum, LSL_Float radius); + void osStopSound(LSL_Integer linknum); + void osTriggerSound(LSL_Integer linknum, LSL_String sound, LSL_Float volume); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 16b368c..aa37159 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -1216,5 +1216,54 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osAngleBetween(a, b); } + public void osAdjustSoundVolume(LSL_Integer linknum, LSL_Float volume) + { + m_OSSL_Functions.osAdjustSoundVolume(linknum, volume); + } + + public void osSetSoundRadius(LSL_Integer linknum, LSL_Float radius) + { + m_OSSL_Functions.osSetSoundRadius(linknum, radius); + } + + public void osPlaySound(LSL_Integer linknum, LSL_String sound, LSL_Float volume) + { + m_OSSL_Functions.osPlaySound(linknum, sound, volume); + } + + public void osLoopSound(LSL_Integer linknum, LSL_String sound, LSL_Float volume) + { + m_OSSL_Functions.osLoopSound(linknum, sound, volume); + } + + public void osLoopSoundMaster(LSL_Integer linknum, LSL_String sound, LSL_Float volume) + { + m_OSSL_Functions.osLoopSoundMaster(linknum, sound, volume); + } + + public void osLoopSoundSlave(LSL_Integer linknum, LSL_String sound, LSL_Float volume) + { + m_OSSL_Functions.osLoopSoundSlave(linknum, sound, volume); + } + + public void osPlaySoundSlave(LSL_Integer linknum, LSL_String sound, LSL_Float volume) + { + m_OSSL_Functions.osPlaySoundSlave(linknum, sound, volume); + } + + public void osTriggerSound(LSL_Integer linknum, LSL_String sound, LSL_Float volume) + { + m_OSSL_Functions.osTriggerSound(linknum, sound, volume); + } + + public void osStopSound(LSL_Integer linknum) + { + m_OSSL_Functions.osStopSound(linknum); + } + + public void osPreloadSound(LSL_Integer linknum, LSL_String sound) + { + m_OSSL_Functions.osPreloadSound(linknum, sound); + } } } -- cgit v1.1