Further work on the sound system creator process

This commit is contained in:
SND\AstrorEnales_cp 2012-02-11 23:53:03 +00:00
parent 8d9abfeccb
commit d8ab2ef4cc
12 changed files with 681 additions and 139 deletions

View File

@ -456,6 +456,8 @@
<Compile Include="NonXNA\SoundSystem\ISoundEffect.cs" />
<Compile Include="NonXNA\SoundSystem\ISoundSystemCreator.cs" />
<Compile Include="NonXNA\SoundSystem\ISoundEffectInstance.cs" />
<Compile Include="NonXNA\SoundSystem\IAudioListener.cs" />
<Compile Include="NonXNA\SoundSystem\IAudioEmitter.cs" />
<Compile Include="Plane.cs" />
<Compile Include="PlaneIntersectionType.cs" />
<Compile Include="PlayerIndex.cs" />

View File

@ -1,8 +1,5 @@
#region Using Statements
using System;
using System.IO;
#endregion // Using Statements
using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.SoundSystem;
#region License
@ -53,13 +50,86 @@ using System.IO;
namespace ANX.Framework.Audio
{
public class AudioEmitter
{
public AudioEmitter (){}
public float DopplerScale { get; set; }
public Vector3 Forward { get; set; }
public Vector3 Position { get; set; }
public Vector3 Up { get; set; }
public Vector3 Velocity { get; set; }
}
public class AudioEmitter
{
#region Private
private IAudioEmitter nativeEmitter;
#endregion
#region Public
public float DopplerScale
{
get
{
return nativeEmitter.DopplerScale;
}
set
{
nativeEmitter.DopplerScale = value;
}
}
public Vector3 Forward
{
get
{
return nativeEmitter.Forward;
}
set
{
nativeEmitter.Forward = value;
}
}
public Vector3 Position
{
get
{
return nativeEmitter.Position;
}
set
{
nativeEmitter.Position = value;
}
}
public Vector3 Up
{
get
{
return nativeEmitter.Up;
}
set
{
nativeEmitter.Up = value;
}
}
public Vector3 Velocity
{
get
{
return nativeEmitter.Velocity;
}
set
{
nativeEmitter.Velocity = value;
}
}
#endregion
#region Constructor
public AudioEmitter()
{
nativeEmitter = GetCreator().CreateAudioEmitter();
}
#endregion
#region GetCreator
private static ISoundSystemCreator GetCreator()
{
return AddInSystemFactory.Instance.GetDefaultCreator<ISoundSystemCreator>();
}
#endregion
}
}

View File

@ -1,8 +1,5 @@
#region Using Statements
using System;
using System.IO;
#endregion // Using Statements
using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.SoundSystem;
#region License
@ -53,12 +50,74 @@ using System.IO;
namespace ANX.Framework.Audio
{
public class AudioListener
{
public AudioListener (){}
public Vector3 Forward { get; set; }
public Vector3 Position { get; set; }
public Vector3 Up { get; set; }
public Vector3 Velocity { get; set; }
}
public class AudioListener
{
#region Private
private IAudioListener nativeListener;
#endregion
#region Public
public Vector3 Forward
{
get
{
return nativeListener.Forward;
}
set
{
nativeListener.Forward = value;
}
}
public Vector3 Position
{
get
{
return nativeListener.Position;
}
set
{
nativeListener.Position = value;
}
}
public Vector3 Up
{
get
{
return nativeListener.Up;
}
set
{
nativeListener.Up = value;
}
}
public Vector3 Velocity
{
get
{
return nativeListener.Velocity;
}
set
{
nativeListener.Velocity = value;
}
}
#endregion
#region Constructor
public AudioListener()
{
nativeListener = GetCreator().CreateAudioListener();
}
#endregion
#region GetCreator
private static ISoundSystemCreator GetCreator()
{
return AddInSystemFactory.Instance.GetDefaultCreator<ISoundSystemCreator>();
}
#endregion
}
}

View File

@ -1,9 +1,4 @@
#region Using Statements
using System;
#endregion // Using Statements
#region License
#region License
//
// This file is part of the ANX.Framework created by the "ANX.Framework developer group".
@ -52,9 +47,9 @@ using System;
namespace ANX.Framework.Audio
{
public enum AudioStopOptions
{
AsAuthored,
Immediate
}
public enum AudioStopOptions
{
AsAuthored,
Immediate
}
}

View File

@ -55,58 +55,58 @@ namespace ANX.Framework.Audio
public sealed class SoundEffect : IDisposable
{
#region Static
#region DistanceScale (TODO)
#region DistanceScale
public static float DistanceScale
{
get
{
throw new NotImplementedException();
return GetCreator().DistanceScale;
}
set
{
throw new NotImplementedException();
GetCreator().DistanceScale = value;
}
}
#endregion
#region DopplerScale (TODO)
#region DopplerScale
public static float DopplerScale
{
get
{
throw new NotImplementedException();
return GetCreator().DopplerScale;
}
set
{
throw new NotImplementedException();
GetCreator().DopplerScale = value;
}
}
#endregion
#region MasterVolume (TODO)
#region MasterVolume
public static float MasterVolume
{
get
{
throw new NotImplementedException();
return GetCreator().MasterVolume;
}
set
{
throw new NotImplementedException();
GetCreator().MasterVolume = value;
}
}
#endregion
#region SpeedOfSound (TODO)
#region SpeedOfSound
public static float SpeedOfSound
{
get
{
throw new NotImplementedException();
return GetCreator().SpeedOfSound;
}
set
{
throw new NotImplementedException();
GetCreator().SpeedOfSound = value;
}
}
#endregion
@ -141,9 +141,7 @@ namespace ANX.Framework.Audio
#region Constructor
private SoundEffect(Stream stream)
{
nativeSoundEffect =
AddInSystemFactory.Instance.GetDefaultCreator<ISoundSystemCreator>()
.CreateSoundEffect(stream);
nativeSoundEffect = GetCreator().CreateSoundEffect(stream);
}
public SoundEffect(byte[] buffer, int sampleRate, AudioChannels channels)
@ -154,10 +152,8 @@ namespace ANX.Framework.Audio
public SoundEffect(byte[] buffer, int offset, int count, int sampleRate,
AudioChannels channels, int loopStart, int loopLength)
{
nativeSoundEffect =
AddInSystemFactory.Instance.GetDefaultCreator<ISoundSystemCreator>()
.CreateSoundEffect(buffer, offset, count, sampleRate, channels,
loopStart, loopLength);
nativeSoundEffect = GetCreator().CreateSoundEffect(buffer, offset,
count, sampleRate, channels, loopStart, loopLength);
}
~SoundEffect()
@ -166,6 +162,13 @@ namespace ANX.Framework.Audio
}
#endregion
#region GetCreator
private static ISoundSystemCreator GetCreator()
{
return AddInSystemFactory.Instance.GetDefaultCreator<ISoundSystemCreator>();
}
#endregion
#region CreateInstance
public SoundEffectInstance CreateInstance()
{

View File

@ -1,7 +1,7 @@
using System;
using System.IO;
using ANX.Framework.NonXNA.SoundSystem;
using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.SoundSystem;
#region License
@ -60,46 +60,81 @@ namespace ANX.Framework.Audio
private ISoundEffectInstance nativeInstance;
#endregion
#region Public (TODO)
#region Public
#region IsDisposed
public bool IsDisposed
{
get;
private set;
}
#endregion
#region IsLooped
public virtual bool IsLooped
{
get
{
throw new NotImplementedException();
return nativeInstance.IsLooped;
}
set
{
nativeInstance.IsLooped = value;
}
}
#endregion
public virtual bool IsLooped
{
get;
set;
}
#region Pan
public float Pan
{
get;
set;
get
{
return nativeInstance.Pan;
}
set
{
nativeInstance.Pan = value;
}
}
#endregion
#region Pitch
public float Pitch
{
get;
set;
get
{
return nativeInstance.Pitch;
}
set
{
nativeInstance.Pitch = value;
}
}
#endregion
#region State
public SoundState State
{
get
{
throw new NotImplementedException();
return nativeInstance.State;
}
}
#endregion
#region Volume
public float Volume
{
get;
set;
get
{
return nativeInstance.Volume;
}
set
{
nativeInstance.Volume = value;
}
}
#endregion
#endregion
#region Constructor
protected SoundEffectInstance()
@ -110,9 +145,7 @@ namespace ANX.Framework.Audio
{
parent = setParent;
nativeInstance =
AddInSystemFactory.Instance.GetDefaultCreator<ISoundSystemCreator>()
.CreateSoundEffectInstance(setParent);
nativeInstance = GetCreator().CreateSoundEffectInstance(setParent);
}
~SoundEffectInstance()
@ -121,60 +154,73 @@ namespace ANX.Framework.Audio
}
#endregion
#region Apply3D (TODO)
#region GetCreator
private static ISoundSystemCreator GetCreator()
{
return AddInSystemFactory.Instance.GetDefaultCreator<ISoundSystemCreator>();
}
#endregion
#region Apply3D
public void Apply3D(AudioListener listener, AudioEmitter emitter)
{
throw new NotImplementedException();
Apply3D(new AudioListener[] { listener }, emitter);
}
public void Apply3D(AudioListener[] listeners, AudioEmitter emitter)
{
throw new NotImplementedException();
nativeInstance.Apply3D(listeners, emitter);
}
#endregion
#region Pause (TODO)
#region Pause
public void Pause()
{
throw new NotImplementedException();
nativeInstance.Pause();
}
#endregion
#region Play (TODO)
#region Play
public virtual void Play()
{
throw new NotImplementedException();
nativeInstance.Play();
}
#endregion
#region Resume (TODO)
#region Resume
public void Resume()
{
throw new NotImplementedException();
nativeInstance.Resume();
}
#endregion
#region Stop (TODO)
#region Stop
public void Stop()
{
throw new NotImplementedException();
Stop(true);
}
public void Stop(bool immediate)
{
throw new NotImplementedException();
nativeInstance.Stop(immediate);
}
#endregion
#region Dispose (TODO)
#region Dispose
public void Dispose()
{
throw new NotImplementedException();
Dispose(true);
}
protected virtual void Dispose(bool disposing)
{
throw new NotImplementedException();
if (nativeInstance != null)
{
nativeInstance.Dispose();
nativeInstance = null;
}
IsDisposed = true;
}
#endregion
}

View File

@ -0,0 +1,84 @@
using System;
#region License
//
// This file is part of the ANX.Framework created by the "ANX.Framework developer group".
//
// This file is released under the Ms-PL license.
//
//
//
// Microsoft Public License (Ms-PL)
//
// This license governs use of the accompanying software. If you use the software, you accept this license.
// If you do not accept the license, do not use the software.
//
// 1.Definitions
// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning
// here as under U.S. copyright law.
// A "contribution" is the original software, or any additions or changes to the software.
// A "contributor" is any person that distributes its contribution under this license.
// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
//
// 2.Grant of Rights
// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations
// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to
// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution
// or any derivative works that you create.
// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in
// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed
// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution
// in the software or derivative works of the contribution in the software.
//
// 3.Conditions and Limitations
// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your
// patent license from such contributor to the software ends automatically.
// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
// notices that are present in the software.
// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or
// object code form, you may only do so under a license that complies with this license.
// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees,
// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the
// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a
// particular purpose and non-infringement.
#endregion // License
namespace ANX.Framework.NonXNA.SoundSystem
{
public interface IAudioEmitter
{
float DopplerScale
{
get;
set;
}
Vector3 Forward
{
get;
set;
}
Vector3 Position
{
get;
set;
}
Vector3 Up
{
get;
set;
}
Vector3 Velocity
{
get;
set;
}
}
}

View File

@ -0,0 +1,78 @@
using System;
#region License
//
// This file is part of the ANX.Framework created by the "ANX.Framework developer group".
//
// This file is released under the Ms-PL license.
//
//
//
// Microsoft Public License (Ms-PL)
//
// This license governs use of the accompanying software. If you use the software, you accept this license.
// If you do not accept the license, do not use the software.
//
// 1.Definitions
// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning
// here as under U.S. copyright law.
// A "contribution" is the original software, or any additions or changes to the software.
// A "contributor" is any person that distributes its contribution under this license.
// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
//
// 2.Grant of Rights
// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations
// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to
// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution
// or any derivative works that you create.
// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in
// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed
// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution
// in the software or derivative works of the contribution in the software.
//
// 3.Conditions and Limitations
// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your
// patent license from such contributor to the software ends automatically.
// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
// notices that are present in the software.
// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or
// object code form, you may only do so under a license that complies with this license.
// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees,
// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the
// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a
// particular purpose and non-infringement.
#endregion // License
namespace ANX.Framework.NonXNA.SoundSystem
{
public interface IAudioListener
{
Vector3 Forward
{
get;
set;
}
Vector3 Position
{
get;
set;
}
Vector3 Up
{
get;
set;
}
Vector3 Velocity
{
get;
set;
}
}
}

View File

@ -1,4 +1,5 @@
using System;
using ANX.Framework.Audio;
#region License
@ -51,5 +52,43 @@ namespace ANX.Framework.NonXNA.SoundSystem
{
public interface ISoundEffectInstance : IDisposable
{
bool IsLooped
{
get;
set;
}
float Pan
{
get;
set;
}
float Pitch
{
get;
set;
}
SoundState State
{
get;
}
float Volume
{
get;
set;
}
void Play();
void Pause();
void Stop(bool immediate);
void Resume();
void Apply3D(AudioListener[] listeners, AudioEmitter emitter);
}
}

View File

@ -1,5 +1,4 @@
using System;
using System.IO;
using System.IO;
using ANX.Framework.Audio;
using ANX.Framework.NonXNA.SoundSystem;
@ -54,6 +53,34 @@ namespace ANX.Framework.NonXNA
{
public interface ISoundSystemCreator : ICreator
{
float DistanceScale
{
get;
set;
}
float DopplerScale
{
get;
set;
}
float MasterVolume
{
get;
set;
}
float SpeedOfSound
{
get;
set;
}
IAudioListener CreateAudioListener();
IAudioEmitter CreateAudioEmitter();
ISoundEffect CreateSoundEffect(Stream stream);
ISoundEffect CreateSoundEffect(byte[] buffer, int offset, int count,

View File

@ -56,6 +56,7 @@ namespace ANX.SoundSystem.OpenAL
public class Creator : ISoundSystemCreator
{
#region Public
#region Name
public string Name
{
get
@ -63,7 +64,9 @@ namespace ANX.SoundSystem.OpenAL
return "OpenAL";
}
}
#endregion
#region Priority
public int Priority
{
get
@ -71,7 +74,9 @@ namespace ANX.SoundSystem.OpenAL
return 100;
}
}
#endregion
#region IsSupported
public bool IsSupported
{
get
@ -84,6 +89,63 @@ namespace ANX.SoundSystem.OpenAL
}
#endregion
#region DistanceScale
public float DistanceScale
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
#endregion
#region DopplerScale
public float DopplerScale
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
#endregion
#region MasterVolume
public float MasterVolume
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
#endregion
#region SpeedOfSound
public float SpeedOfSound
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
#endregion
#endregion
#region RegisterCreator
public void RegisterCreator(AddInSystemFactory factory)
{
@ -113,5 +175,19 @@ namespace ANX.SoundSystem.OpenAL
throw new NotImplementedException();
}
#endregion
#region CreateAudioListener (TODO)
public IAudioListener CreateAudioListener()
{
throw new NotImplementedException();
}
#endregion
#region CreateAudioEmitter (TODO)
public IAudioEmitter CreateAudioEmitter()
{
throw new NotImplementedException();
}
#endregion
}
}

View File

@ -6,6 +6,8 @@ using System.Text;
using System.IO;
using System.Runtime.InteropServices;
using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.SoundSystem;
using ANX.Framework.Audio;
#endregion // Using Statements
@ -58,51 +60,112 @@ using ANX.Framework.NonXNA;
namespace ANX.SoundSystem.Windows.XAudio
{
public class Creator : ISoundSystemCreator
{
public void RegisterCreator(AddInSystemFactory factory)
{
factory.AddCreator(this);
}
public string Name
{
get { return "XAudio"; }
}
public int Priority
{
get { return 10; }
}
public bool IsSupported
{
get
{
//TODO: this is just a very basic version of test for support
return AddInSystemFactory.Instance.OperatingSystem.Platform == PlatformID.Win32NT;
}
}
#region ISoundSystemCreator Member
public Framework.NonXNA.SoundSystem.ISoundEffect CreateSoundEffect(Stream stream)
{
throw new NotImplementedException();
}
public Framework.NonXNA.SoundSystem.ISoundEffect CreateSoundEffect(byte[] buffer, int offset, int count, int sampleRate, Framework.Audio.AudioChannels channels, int loopStart, int loopLength)
{
throw new NotImplementedException();
}
public Framework.NonXNA.SoundSystem.ISoundEffectInstance CreateSoundEffectInstance(Framework.Audio.SoundEffect parent)
{
throw new NotImplementedException();
}
#endregion
public class Creator : ISoundSystemCreator
{
public void RegisterCreator(AddInSystemFactory factory)
{
factory.AddCreator(this);
}
public string Name
{
get { return "XAudio"; }
}
public int Priority
{
get { return 10; }
}
public bool IsSupported
{
get
{
//TODO: this is just a very basic version of test for support
return AddInSystemFactory.Instance.OperatingSystem.Platform == PlatformID.Win32NT;
}
}
public float DistanceScale
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public float DopplerScale
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public float MasterVolume
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public float SpeedOfSound
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
#region ISoundSystemCreator Member
public ISoundEffect CreateSoundEffect(Stream stream)
{
throw new NotImplementedException();
}
public ISoundEffect CreateSoundEffect(byte[] buffer, int offset, int count, int sampleRate, AudioChannels channels, int loopStart, int loopLength)
{
throw new NotImplementedException();
}
public ISoundEffectInstance CreateSoundEffectInstance(SoundEffect parent)
{
throw new NotImplementedException();
}
#endregion
#region CreateAudioListener (TODO)
public IAudioListener CreateAudioListener()
{
throw new NotImplementedException();
}
#endregion
#region CreateAudioEmitter (TODO)
public IAudioEmitter CreateAudioEmitter()
{
throw new NotImplementedException();
}
#endregion
}
}