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\ISoundEffect.cs" />
<Compile Include="NonXNA\SoundSystem\ISoundSystemCreator.cs" /> <Compile Include="NonXNA\SoundSystem\ISoundSystemCreator.cs" />
<Compile Include="NonXNA\SoundSystem\ISoundEffectInstance.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="Plane.cs" />
<Compile Include="PlaneIntersectionType.cs" /> <Compile Include="PlaneIntersectionType.cs" />
<Compile Include="PlayerIndex.cs" /> <Compile Include="PlayerIndex.cs" />

View File

@ -1,8 +1,5 @@
#region Using Statements using ANX.Framework.NonXNA;
using System; using ANX.Framework.NonXNA.SoundSystem;
using System.IO;
#endregion // Using Statements
#region License #region License
@ -53,13 +50,86 @@ using System.IO;
namespace ANX.Framework.Audio namespace ANX.Framework.Audio
{ {
public class AudioEmitter public class AudioEmitter
{ {
public AudioEmitter (){} #region Private
public float DopplerScale { get; set; } private IAudioEmitter nativeEmitter;
public Vector3 Forward { get; set; } #endregion
public Vector3 Position { get; set; }
public Vector3 Up { get; set; } #region Public
public Vector3 Velocity { get; set; } 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 ANX.Framework.NonXNA;
using System; using ANX.Framework.NonXNA.SoundSystem;
using System.IO;
#endregion // Using Statements
#region License #region License
@ -53,12 +50,74 @@ using System.IO;
namespace ANX.Framework.Audio namespace ANX.Framework.Audio
{ {
public class AudioListener public class AudioListener
{ {
public AudioListener (){} #region Private
public Vector3 Forward { get; set; } private IAudioListener nativeListener;
public Vector3 Position { get; set; } #endregion
public Vector3 Up { get; set; }
public Vector3 Velocity { get; set; } #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 #region License
using System;
#endregion // Using Statements
#region License
// //
// This file is part of the ANX.Framework created by the "ANX.Framework developer group". // 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 namespace ANX.Framework.Audio
{ {
public enum AudioStopOptions public enum AudioStopOptions
{ {
AsAuthored, AsAuthored,
Immediate Immediate
} }
} }

View File

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

View File

@ -1,7 +1,7 @@
using System; using System;
using System.IO; using System.IO;
using ANX.Framework.NonXNA.SoundSystem;
using ANX.Framework.NonXNA; using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.SoundSystem;
#region License #region License
@ -60,46 +60,81 @@ namespace ANX.Framework.Audio
private ISoundEffectInstance nativeInstance; private ISoundEffectInstance nativeInstance;
#endregion #endregion
#region Public (TODO) #region Public
#region IsDisposed
public bool IsDisposed public bool IsDisposed
{
get;
private set;
}
#endregion
#region IsLooped
public virtual bool IsLooped
{ {
get get
{ {
throw new NotImplementedException(); return nativeInstance.IsLooped;
}
set
{
nativeInstance.IsLooped = value;
} }
} }
#endregion
public virtual bool IsLooped #region Pan
{
get;
set;
}
public float Pan public float Pan
{ {
get; get
set; {
return nativeInstance.Pan;
}
set
{
nativeInstance.Pan = value;
}
} }
#endregion
#region Pitch
public float Pitch public float Pitch
{ {
get; get
set; {
return nativeInstance.Pitch;
}
set
{
nativeInstance.Pitch = value;
}
} }
#endregion
#region State
public SoundState State public SoundState State
{ {
get get
{ {
throw new NotImplementedException(); return nativeInstance.State;
} }
} }
#endregion
#region Volume
public float Volume public float Volume
{ {
get; get
set; {
return nativeInstance.Volume;
}
set
{
nativeInstance.Volume = value;
}
} }
#endregion #endregion
#endregion
#region Constructor #region Constructor
protected SoundEffectInstance() protected SoundEffectInstance()
@ -110,9 +145,7 @@ namespace ANX.Framework.Audio
{ {
parent = setParent; parent = setParent;
nativeInstance = nativeInstance = GetCreator().CreateSoundEffectInstance(setParent);
AddInSystemFactory.Instance.GetDefaultCreator<ISoundSystemCreator>()
.CreateSoundEffectInstance(setParent);
} }
~SoundEffectInstance() ~SoundEffectInstance()
@ -121,60 +154,73 @@ namespace ANX.Framework.Audio
} }
#endregion #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) public void Apply3D(AudioListener listener, AudioEmitter emitter)
{ {
throw new NotImplementedException(); Apply3D(new AudioListener[] { listener }, emitter);
} }
public void Apply3D(AudioListener[] listeners, AudioEmitter emitter) public void Apply3D(AudioListener[] listeners, AudioEmitter emitter)
{ {
throw new NotImplementedException(); nativeInstance.Apply3D(listeners, emitter);
} }
#endregion #endregion
#region Pause (TODO) #region Pause
public void Pause() public void Pause()
{ {
throw new NotImplementedException(); nativeInstance.Pause();
} }
#endregion #endregion
#region Play (TODO) #region Play
public virtual void Play() public virtual void Play()
{ {
throw new NotImplementedException(); nativeInstance.Play();
} }
#endregion #endregion
#region Resume (TODO) #region Resume
public void Resume() public void Resume()
{ {
throw new NotImplementedException(); nativeInstance.Resume();
} }
#endregion #endregion
#region Stop (TODO) #region Stop
public void Stop() public void Stop()
{ {
throw new NotImplementedException(); Stop(true);
} }
public void Stop(bool immediate) public void Stop(bool immediate)
{ {
throw new NotImplementedException(); nativeInstance.Stop(immediate);
} }
#endregion #endregion
#region Dispose (TODO) #region Dispose
public void Dispose() public void Dispose()
{ {
throw new NotImplementedException(); Dispose(true);
} }
protected virtual void Dispose(bool disposing) protected virtual void Dispose(bool disposing)
{ {
throw new NotImplementedException(); if (nativeInstance != null)
{
nativeInstance.Dispose();
nativeInstance = null;
}
IsDisposed = true;
} }
#endregion #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 System;
using ANX.Framework.Audio;
#region License #region License
@ -51,5 +52,43 @@ namespace ANX.Framework.NonXNA.SoundSystem
{ {
public interface ISoundEffectInstance : IDisposable 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.Audio;
using ANX.Framework.NonXNA.SoundSystem; using ANX.Framework.NonXNA.SoundSystem;
@ -54,6 +53,34 @@ namespace ANX.Framework.NonXNA
{ {
public interface ISoundSystemCreator : ICreator 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(Stream stream);
ISoundEffect CreateSoundEffect(byte[] buffer, int offset, int count, ISoundEffect CreateSoundEffect(byte[] buffer, int offset, int count,

View File

@ -56,6 +56,7 @@ namespace ANX.SoundSystem.OpenAL
public class Creator : ISoundSystemCreator public class Creator : ISoundSystemCreator
{ {
#region Public #region Public
#region Name
public string Name public string Name
{ {
get get
@ -63,7 +64,9 @@ namespace ANX.SoundSystem.OpenAL
return "OpenAL"; return "OpenAL";
} }
} }
#endregion
#region Priority
public int Priority public int Priority
{ {
get get
@ -71,7 +74,9 @@ namespace ANX.SoundSystem.OpenAL
return 100; return 100;
} }
} }
#endregion
#region IsSupported
public bool IsSupported public bool IsSupported
{ {
get get
@ -84,6 +89,63 @@ namespace ANX.SoundSystem.OpenAL
} }
#endregion #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 #region RegisterCreator
public void RegisterCreator(AddInSystemFactory factory) public void RegisterCreator(AddInSystemFactory factory)
{ {
@ -113,5 +175,19 @@ namespace ANX.SoundSystem.OpenAL
throw new NotImplementedException(); throw new NotImplementedException();
} }
#endregion #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.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using ANX.Framework.NonXNA; using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.SoundSystem;
using ANX.Framework.Audio;
#endregion // Using Statements #endregion // Using Statements
@ -58,51 +60,112 @@ using ANX.Framework.NonXNA;
namespace ANX.SoundSystem.Windows.XAudio namespace ANX.SoundSystem.Windows.XAudio
{ {
public class Creator : ISoundSystemCreator public class Creator : ISoundSystemCreator
{ {
public void RegisterCreator(AddInSystemFactory factory)
public void RegisterCreator(AddInSystemFactory factory) {
{ factory.AddCreator(this);
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 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
}
} }