2012-01-25 15:31:58 +00:00
|
|
|
|
using System;
|
2011-11-15 19:52:09 +00:00
|
|
|
|
using System.IO;
|
2012-01-25 15:31:58 +00:00
|
|
|
|
using ANX.Framework.NonXNA;
|
2012-02-11 23:53:03 +00:00
|
|
|
|
using ANX.Framework.NonXNA.SoundSystem;
|
2011-11-15 19:52:09 +00:00
|
|
|
|
|
2012-08-09 09:45:04 +00:00
|
|
|
|
// This file is part of the ANX.Framework created by the
|
|
|
|
|
// "ANX.Framework developer group" and released under the Ms-PL license.
|
|
|
|
|
// For details see: http://anxframework.codeplex.com/license
|
2011-11-15 19:52:09 +00:00
|
|
|
|
|
|
|
|
|
namespace ANX.Framework.Audio
|
|
|
|
|
{
|
2012-01-25 15:31:58 +00:00
|
|
|
|
public class SoundEffectInstance : IDisposable
|
|
|
|
|
{
|
|
|
|
|
#region Private
|
|
|
|
|
private SoundEffect parent;
|
|
|
|
|
|
|
|
|
|
private ISoundEffectInstance nativeInstance;
|
2012-02-12 11:28:59 +00:00
|
|
|
|
|
|
|
|
|
internal bool IsFireAndForget
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
private set;
|
|
|
|
|
}
|
2012-01-25 15:31:58 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
2012-02-11 23:53:03 +00:00
|
|
|
|
#region Public
|
|
|
|
|
#region IsDisposed
|
2012-01-25 15:31:58 +00:00
|
|
|
|
public bool IsDisposed
|
|
|
|
|
{
|
2012-02-11 23:53:03 +00:00
|
|
|
|
get;
|
|
|
|
|
private set;
|
2012-01-25 15:31:58 +00:00
|
|
|
|
}
|
2012-02-11 23:53:03 +00:00
|
|
|
|
#endregion
|
2012-01-25 15:31:58 +00:00
|
|
|
|
|
2012-02-11 23:53:03 +00:00
|
|
|
|
#region IsLooped
|
2012-01-25 15:31:58 +00:00
|
|
|
|
public virtual bool IsLooped
|
|
|
|
|
{
|
2012-02-11 23:53:03 +00:00
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return nativeInstance.IsLooped;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
nativeInstance.IsLooped = value;
|
|
|
|
|
}
|
2012-01-25 15:31:58 +00:00
|
|
|
|
}
|
2012-02-11 23:53:03 +00:00
|
|
|
|
#endregion
|
2012-01-25 15:31:58 +00:00
|
|
|
|
|
2012-02-11 23:53:03 +00:00
|
|
|
|
#region Pan
|
2012-01-25 15:31:58 +00:00
|
|
|
|
public float Pan
|
|
|
|
|
{
|
2012-02-11 23:53:03 +00:00
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return nativeInstance.Pan;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
nativeInstance.Pan = value;
|
|
|
|
|
}
|
2012-01-25 15:31:58 +00:00
|
|
|
|
}
|
2012-02-11 23:53:03 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Pitch
|
2012-01-25 15:31:58 +00:00
|
|
|
|
public float Pitch
|
|
|
|
|
{
|
2012-02-11 23:53:03 +00:00
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return nativeInstance.Pitch;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
nativeInstance.Pitch = value;
|
|
|
|
|
}
|
2012-01-25 15:31:58 +00:00
|
|
|
|
}
|
2012-02-11 23:53:03 +00:00
|
|
|
|
#endregion
|
2012-01-25 15:31:58 +00:00
|
|
|
|
|
2012-02-11 23:53:03 +00:00
|
|
|
|
#region State
|
2012-01-25 15:31:58 +00:00
|
|
|
|
public SoundState State
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2012-02-11 23:53:03 +00:00
|
|
|
|
return nativeInstance.State;
|
2012-01-25 15:31:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-02-11 23:53:03 +00:00
|
|
|
|
#endregion
|
2012-01-25 15:31:58 +00:00
|
|
|
|
|
2012-02-11 23:53:03 +00:00
|
|
|
|
#region Volume
|
2012-01-25 15:31:58 +00:00
|
|
|
|
public float Volume
|
|
|
|
|
{
|
2012-02-11 23:53:03 +00:00
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return nativeInstance.Volume;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
nativeInstance.Volume = value;
|
|
|
|
|
}
|
2012-01-25 15:31:58 +00:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
2012-02-11 23:53:03 +00:00
|
|
|
|
#endregion
|
2012-01-25 15:31:58 +00:00
|
|
|
|
|
|
|
|
|
#region Constructor
|
|
|
|
|
protected SoundEffectInstance()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-12 11:28:59 +00:00
|
|
|
|
internal SoundEffectInstance(SoundEffect setParent, bool setIsFireAndForget)
|
2012-01-25 15:31:58 +00:00
|
|
|
|
{
|
|
|
|
|
parent = setParent;
|
2012-02-12 11:28:59 +00:00
|
|
|
|
IsFireAndForget = setIsFireAndForget;
|
2012-01-25 15:31:58 +00:00
|
|
|
|
|
2012-02-12 11:28:59 +00:00
|
|
|
|
nativeInstance = GetCreator().CreateSoundEffectInstance(
|
|
|
|
|
setParent.nativeSoundEffect);
|
2012-01-25 15:31:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~SoundEffectInstance()
|
|
|
|
|
{
|
|
|
|
|
Dispose();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
2012-02-11 23:53:03 +00:00
|
|
|
|
#region GetCreator
|
|
|
|
|
private static ISoundSystemCreator GetCreator()
|
|
|
|
|
{
|
|
|
|
|
return AddInSystemFactory.Instance.GetDefaultCreator<ISoundSystemCreator>();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Apply3D
|
2012-01-25 15:31:58 +00:00
|
|
|
|
public void Apply3D(AudioListener listener, AudioEmitter emitter)
|
|
|
|
|
{
|
2012-02-11 23:53:03 +00:00
|
|
|
|
Apply3D(new AudioListener[] { listener }, emitter);
|
2012-01-25 15:31:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Apply3D(AudioListener[] listeners, AudioEmitter emitter)
|
|
|
|
|
{
|
2012-02-11 23:53:03 +00:00
|
|
|
|
nativeInstance.Apply3D(listeners, emitter);
|
2012-01-25 15:31:58 +00:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
2012-02-11 23:53:03 +00:00
|
|
|
|
#region Pause
|
2012-01-25 15:31:58 +00:00
|
|
|
|
public void Pause()
|
|
|
|
|
{
|
2012-02-11 23:53:03 +00:00
|
|
|
|
nativeInstance.Pause();
|
2012-01-25 15:31:58 +00:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
2012-02-11 23:53:03 +00:00
|
|
|
|
#region Play
|
2012-01-25 15:31:58 +00:00
|
|
|
|
public virtual void Play()
|
|
|
|
|
{
|
2012-02-11 23:53:03 +00:00
|
|
|
|
nativeInstance.Play();
|
2012-01-25 15:31:58 +00:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
2012-02-11 23:53:03 +00:00
|
|
|
|
#region Resume
|
2012-01-25 15:31:58 +00:00
|
|
|
|
public void Resume()
|
|
|
|
|
{
|
2012-02-11 23:53:03 +00:00
|
|
|
|
nativeInstance.Resume();
|
2012-01-25 15:31:58 +00:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
2012-02-11 23:53:03 +00:00
|
|
|
|
#region Stop
|
2012-01-25 15:31:58 +00:00
|
|
|
|
public void Stop()
|
|
|
|
|
{
|
2012-02-11 23:53:03 +00:00
|
|
|
|
Stop(true);
|
2012-01-25 15:31:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Stop(bool immediate)
|
|
|
|
|
{
|
2012-02-11 23:53:03 +00:00
|
|
|
|
nativeInstance.Stop(immediate);
|
2012-01-25 15:31:58 +00:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
2012-02-11 23:53:03 +00:00
|
|
|
|
#region Dispose
|
2012-01-25 15:31:58 +00:00
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
2012-02-11 23:53:03 +00:00
|
|
|
|
Dispose(true);
|
2012-01-25 15:31:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void Dispose(bool disposing)
|
|
|
|
|
{
|
2012-02-11 23:53:03 +00:00
|
|
|
|
if (nativeInstance != null)
|
|
|
|
|
{
|
|
|
|
|
nativeInstance.Dispose();
|
|
|
|
|
nativeInstance = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IsDisposed = true;
|
2012-01-25 15:31:58 +00:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
2011-11-15 19:52:09 +00:00
|
|
|
|
}
|