change how sounds work. May be bad.. needs testing
parent
5a7a609683
commit
c3b5a6c2ab
|
@ -48,6 +48,18 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||||
|
|
||||||
private Scene m_scene;
|
private Scene m_scene;
|
||||||
|
|
||||||
|
public enum SoundFlags: byte
|
||||||
|
{
|
||||||
|
NONE = 0,
|
||||||
|
LOOP = 1 << 0,
|
||||||
|
SYNC_MASTER = 1<<1,
|
||||||
|
SYNC_SLAVE = 1<<2,
|
||||||
|
SYNC_PENDING = 1<<3,
|
||||||
|
QUEUE = 1<<4,
|
||||||
|
STOP = 1<<5,
|
||||||
|
SYNC_MASK = SYNC_MASTER | SYNC_SLAVE | SYNC_PENDING
|
||||||
|
}
|
||||||
|
|
||||||
public bool Enabled { get; private set; }
|
public bool Enabled { get; private set; }
|
||||||
|
|
||||||
public float MaxDistance { get; private set; }
|
public float MaxDistance { get; private set; }
|
||||||
|
@ -124,26 +136,19 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||||
if (radius == 0)
|
if (radius == 0)
|
||||||
radius = MaxDistance;
|
radius = MaxDistance;
|
||||||
|
|
||||||
|
if (part.SoundQueueing)
|
||||||
|
flags |= (byte)SoundFlags.QUEUE;
|
||||||
|
|
||||||
m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
|
m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
|
||||||
{
|
{
|
||||||
double dis = Util.GetDistanceTo(sp.AbsolutePosition, position);
|
|
||||||
if (dis > MaxDistance) // Max audio distance
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (grp.IsAttachment)
|
if (grp.IsAttachment)
|
||||||
{
|
{
|
||||||
if (grp.HasPrivateAttachmentPoint && sp.ControllingClient.AgentId != grp.OwnerID)
|
if (grp.HasPrivateAttachmentPoint && sp.ControllingClient.AgentId != grp.OwnerID)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (sp.ControllingClient.AgentId == grp.OwnerID)
|
|
||||||
dis = 0;
|
|
||||||
}
|
}
|
||||||
|
// no radius ?
|
||||||
// Scale by distance
|
|
||||||
double thisSpGain = gain * ((radius - dis) / radius);
|
|
||||||
|
|
||||||
sp.ControllingClient.SendPlayAttachedSound(soundID, objectID,
|
sp.ControllingClient.SendPlayAttachedSound(soundID, objectID,
|
||||||
ownerID, (float)thisSpGain, flags);
|
ownerID, (float)gain, flags);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,9 +166,9 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||||
{
|
{
|
||||||
SceneObjectGroup grp = part.ParentGroup;
|
SceneObjectGroup grp = part.ParentGroup;
|
||||||
|
|
||||||
if (grp.IsAttachment && grp.AttachmentPoint > 30)
|
if (grp.IsAttachment && grp.HasPrivateAttachmentPoint)
|
||||||
{
|
{
|
||||||
objectID = ownerID;
|
// objectID = ownerID;
|
||||||
parentID = ownerID;
|
parentID = ownerID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,16 +179,12 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||||
m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
|
m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
|
||||||
{
|
{
|
||||||
double dis = Util.GetDistanceTo(sp.AbsolutePosition, position);
|
double dis = Util.GetDistanceTo(sp.AbsolutePosition, position);
|
||||||
|
if (dis > radius) // Max audio distance
|
||||||
if (dis > MaxDistance) // Max audio distance
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Scale by distance
|
|
||||||
double thisSpGain = gain * ((radius - dis) / radius);
|
|
||||||
|
|
||||||
sp.ControllingClient.SendTriggeredSound(soundId, ownerID,
|
sp.ControllingClient.SendTriggeredSound(soundId, ownerID,
|
||||||
objectID, parentID, handle, position,
|
objectID, parentID, handle, position,
|
||||||
(float)thisSpGain);
|
(float)gain);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,39 +200,12 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||||
private static void StopSound(SceneObjectPart m_host)
|
private static void StopSound(SceneObjectPart m_host)
|
||||||
{
|
{
|
||||||
m_host.AdjustSoundGain(0);
|
m_host.AdjustSoundGain(0);
|
||||||
// Xantor 20080528: Clear prim data of sound instead
|
m_host.Sound = UUID.Zero;
|
||||||
if (m_host.ParentGroup.LoopSoundSlavePrims.Contains(m_host))
|
m_host.SoundFlags = (byte)SoundFlags.STOP;
|
||||||
{
|
m_host.SoundRadius = 0;
|
||||||
if (m_host.ParentGroup.LoopSoundMasterPrim == m_host)
|
m_host.SoundGain = 0;
|
||||||
{
|
m_host.ScheduleFullUpdate();
|
||||||
foreach (SceneObjectPart part in m_host.ParentGroup.LoopSoundSlavePrims)
|
m_host.SendFullUpdateToAllClients();
|
||||||
{
|
|
||||||
part.Sound = UUID.Zero;
|
|
||||||
part.SoundFlags = 1 << 5;
|
|
||||||
part.SoundRadius = 0;
|
|
||||||
part.ScheduleFullUpdate();
|
|
||||||
part.SendFullUpdateToAllClients();
|
|
||||||
}
|
|
||||||
m_host.ParentGroup.LoopSoundMasterPrim = null;
|
|
||||||
m_host.ParentGroup.LoopSoundSlavePrims.Clear();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_host.Sound = UUID.Zero;
|
|
||||||
m_host.SoundFlags = 1 << 5;
|
|
||||||
m_host.SoundRadius = 0;
|
|
||||||
m_host.ScheduleFullUpdate();
|
|
||||||
m_host.SendFullUpdateToAllClients();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_host.Sound = UUID.Zero;
|
|
||||||
m_host.SoundFlags = 1 << 5;
|
|
||||||
m_host.SoundRadius = 0;
|
|
||||||
m_host.ScheduleFullUpdate();
|
|
||||||
m_host.SendFullUpdateToAllClients();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void PreloadSound(UUID objectID, UUID soundID, float radius)
|
public virtual void PreloadSound(UUID objectID, UUID soundID, float radius)
|
||||||
|
@ -248,7 +222,7 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||||
|
|
||||||
m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
|
m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
|
||||||
{
|
{
|
||||||
if (!(Util.GetDistanceTo(sp.AbsolutePosition, part.AbsolutePosition) >= MaxDistance))
|
if (Util.GetDistanceTo(sp.AbsolutePosition, part.AbsolutePosition) < radius)
|
||||||
sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID);
|
sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -262,21 +236,31 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||||
// 20080530 Updated to remove code duplication
|
// 20080530 Updated to remove code duplication
|
||||||
// 20080530 Stop sound if there is one, otherwise volume only changes don't work
|
// 20080530 Stop sound if there is one, otherwise volume only changes don't work
|
||||||
public void LoopSound(UUID objectID, UUID soundID,
|
public void LoopSound(UUID objectID, UUID soundID,
|
||||||
double volume, double radius, bool isMaster)
|
double volume, double radius, bool isMaster, bool isSlave)
|
||||||
{
|
{
|
||||||
SceneObjectPart m_host;
|
SceneObjectPart m_host;
|
||||||
if (!m_scene.TryGetSceneObjectPart(objectID, out m_host))
|
if (!m_scene.TryGetSceneObjectPart(objectID, out m_host))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (isMaster)
|
// if (isMaster)
|
||||||
m_host.ParentGroup.LoopSoundMasterPrim = m_host;
|
// m_host.ParentGroup.LoopSoundMasterPrim = m_host;
|
||||||
|
|
||||||
if (m_host.Sound != UUID.Zero)
|
// sl does not stop previus sound, volume changes don't work (wiki)
|
||||||
StopSound(m_host);
|
// if (m_host.Sound != UUID.Zero)
|
||||||
|
// StopSound(m_host);
|
||||||
|
|
||||||
|
byte iflags = 1; // looping
|
||||||
|
if (isMaster)
|
||||||
|
iflags |= (byte)SoundFlags.SYNC_MASTER;
|
||||||
|
// TODO check viewer seems to accept both
|
||||||
|
if (isSlave)
|
||||||
|
iflags |= (byte)SoundFlags.SYNC_SLAVE;
|
||||||
|
if (m_host.SoundQueueing)
|
||||||
|
iflags |= (byte)SoundFlags.QUEUE;
|
||||||
|
|
||||||
m_host.Sound = soundID;
|
m_host.Sound = soundID;
|
||||||
m_host.SoundGain = volume;
|
m_host.SoundGain = volume;
|
||||||
m_host.SoundFlags = 1; // looping
|
m_host.SoundFlags = iflags;
|
||||||
m_host.SoundRadius = radius;
|
m_host.SoundRadius = radius;
|
||||||
|
|
||||||
m_host.ScheduleFullUpdate();
|
m_host.ScheduleFullUpdate();
|
||||||
|
@ -301,42 +285,19 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||||
Vector3 position = part.AbsolutePosition; // region local
|
Vector3 position = part.AbsolutePosition; // region local
|
||||||
ulong regionHandle = m_scene.RegionInfo.RegionHandle;
|
ulong regionHandle = m_scene.RegionInfo.RegionHandle;
|
||||||
|
|
||||||
if (useMaster)
|
if(triggered)
|
||||||
{
|
TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius);
|
||||||
if (isMaster)
|
|
||||||
{
|
|
||||||
if (triggered)
|
|
||||||
TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius);
|
|
||||||
else
|
|
||||||
PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, flags, radius);
|
|
||||||
part.ParentGroup.PlaySoundMasterPrim = part;
|
|
||||||
if (triggered)
|
|
||||||
TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius);
|
|
||||||
else
|
|
||||||
PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, flags, radius);
|
|
||||||
foreach (SceneObjectPart prim in part.ParentGroup.PlaySoundSlavePrims)
|
|
||||||
{
|
|
||||||
position = prim.AbsolutePosition; // region local
|
|
||||||
if (triggered)
|
|
||||||
TriggerSound(soundID, part.OwnerID, prim.UUID, parentID, volume, position, regionHandle, radius);
|
|
||||||
else
|
|
||||||
PlayAttachedSound(soundID, part.OwnerID, prim.UUID, volume, position, flags, radius);
|
|
||||||
}
|
|
||||||
part.ParentGroup.PlaySoundSlavePrims.Clear();
|
|
||||||
part.ParentGroup.PlaySoundMasterPrim = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
part.ParentGroup.PlaySoundSlavePrims.Add(part);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (triggered)
|
byte bflags = 0;
|
||||||
TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius);
|
|
||||||
else
|
if (isMaster)
|
||||||
PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, flags, radius);
|
bflags |= (byte)SoundFlags.SYNC_MASTER;
|
||||||
}
|
// TODO check viewer seems to accept both
|
||||||
|
if (useMaster)
|
||||||
|
bflags |= (byte)SoundFlags.SYNC_SLAVE;
|
||||||
|
PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, bflags, radius);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TriggerSoundLimited(UUID objectID, UUID sound,
|
public void TriggerSoundLimited(UUID objectID, UUID sound,
|
||||||
|
|
|
@ -95,7 +95,7 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
/// <param name="radius">Sound radius</param>
|
/// <param name="radius">Sound radius</param>
|
||||||
/// <param name="isMaster">Set object to sync master if true</param>
|
/// <param name="isMaster">Set object to sync master if true</param>
|
||||||
void LoopSound(UUID objectID, UUID soundID, double gain,
|
void LoopSound(UUID objectID, UUID soundID, double gain,
|
||||||
double radius, bool isMaster);
|
double radius, bool isMaster, bool isSlave);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Trigger or play an attached sound in this part's inventory.
|
/// Trigger or play an attached sound in this part's inventory.
|
||||||
|
|
|
@ -908,14 +908,14 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// PlaySoundMasterPrim no longer in use to remove
|
||||||
private SceneObjectPart m_PlaySoundMasterPrim = null;
|
private SceneObjectPart m_PlaySoundMasterPrim = null;
|
||||||
public SceneObjectPart PlaySoundMasterPrim
|
public SceneObjectPart PlaySoundMasterPrim
|
||||||
{
|
{
|
||||||
get { return m_PlaySoundMasterPrim; }
|
get { return m_PlaySoundMasterPrim; }
|
||||||
set { m_PlaySoundMasterPrim = value; }
|
set { m_PlaySoundMasterPrim = value; }
|
||||||
}
|
}
|
||||||
|
// PlaySoundSlavePrims no longer in use to remove
|
||||||
private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>();
|
private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>();
|
||||||
public List<SceneObjectPart> PlaySoundSlavePrims
|
public List<SceneObjectPart> PlaySoundSlavePrims
|
||||||
{
|
{
|
||||||
|
@ -923,6 +923,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
set { m_PlaySoundSlavePrims = value; }
|
set { m_PlaySoundSlavePrims = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoopSoundMasterPrim no longer in use to remove
|
||||||
private SceneObjectPart m_LoopSoundMasterPrim = null;
|
private SceneObjectPart m_LoopSoundMasterPrim = null;
|
||||||
public SceneObjectPart LoopSoundMasterPrim
|
public SceneObjectPart LoopSoundMasterPrim
|
||||||
{
|
{
|
||||||
|
@ -930,6 +931,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
set { m_LoopSoundMasterPrim = value; }
|
set { m_LoopSoundMasterPrim = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// m_LoopSoundSlavePrims no longer in use to remove
|
||||||
private List<SceneObjectPart> m_LoopSoundSlavePrims = new List<SceneObjectPart>();
|
private List<SceneObjectPart> m_LoopSoundSlavePrims = new List<SceneObjectPart>();
|
||||||
public List<SceneObjectPart> LoopSoundSlavePrims
|
public List<SceneObjectPart> LoopSoundSlavePrims
|
||||||
{
|
{
|
||||||
|
|
|
@ -2844,7 +2844,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
m_SoundModule.SendSound(
|
m_SoundModule.SendSound(
|
||||||
m_host.UUID,
|
m_host.UUID,
|
||||||
ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound),
|
ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound),
|
||||||
volume, false, m_host.SoundQueueing ? (byte)SoundFlags.Queue : (byte)SoundFlags.None,
|
volume, false, 0,
|
||||||
0, false, false);
|
0, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2855,7 +2855,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
if (m_SoundModule != null)
|
if (m_SoundModule != null)
|
||||||
{
|
{
|
||||||
m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound),
|
m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound),
|
||||||
volume, 20, false);
|
volume, 20, false,false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2865,16 +2865,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
if (m_SoundModule != null)
|
if (m_SoundModule != null)
|
||||||
{
|
{
|
||||||
m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound),
|
m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound),
|
||||||
volume, 20, true);
|
volume, 20, true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void llLoopSoundSlave(string sound, double volume)
|
public void llLoopSoundSlave(string sound, double volume)
|
||||||
{
|
{
|
||||||
m_host.AddScriptLPS(1);
|
m_host.AddScriptLPS(1);
|
||||||
lock (m_host.ParentGroup.LoopSoundSlavePrims)
|
if (m_SoundModule != null)
|
||||||
{
|
{
|
||||||
m_host.ParentGroup.LoopSoundSlavePrims.Add(m_host);
|
m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound),
|
||||||
|
volume, 20, false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue