From 67c9efa6cf94b548aa863f560e3623f438dd0677 Mon Sep 17 00:00:00 2001 From: "SND\\AstrorEnales_cp" Date: Wed, 29 Aug 2012 18:07:54 +0000 Subject: [PATCH] - Moved the Wave loading/conversion to an extra project (WaveUtils) - Started implementation of the Wave Content Pipeline - Fixed GraphicsDeviceWindowsGL3 --- .../ANX.Framework.Content.Pipeline.csproj | 8 ++ .../Audio/AudioContent.cs | 31 ++++-- .../Audio/ConversionQuality.cs | 28 +++--- .../ContentImporter.cs | 10 +- .../Importer/EffectImporter.cs | 6 +- .../Importer/WavImporter.cs | 28 ++++++ .../Processors/SoundEffectContent.cs | 23 +++-- .../Processors/SoundEffectProcessor.cs | 56 ++++++++--- .../GraphicTypeWriters/EffectWriter.cs | 5 +- .../MediaTypeWriters/SoundEffectWriter.cs | 42 ++++++++ .../Tasks/ImporterManager.cs | 6 +- ANX.Framework.sln | 19 ++++ ANX.Framework/Audio/SoundEffect.cs | 4 +- ANX.Framework/Audio/SoundEffectInstance.cs | 5 +- .../MediaTypeReaders/SoundEffectReader.cs | 2 +- ANX.Framework/Graphics/ConstantBuffer.cs | 9 +- ANX.Framework/Properties/AssemblyInfo.cs | 3 +- .../ANX.Framework.Windows.GL3/EffectGL3.cs | 52 +++------- .../GraphicsDeviceWindowsGL3.cs | 86 +++++----------- Samples/SimpleSprite/Program.cs | 36 ++++--- .../ANX.SoundSystem.OpenAL.csproj | 10 +- .../OpenALSoundEffect.cs | 41 ++++---- .../ANX.SoundSystem.OpenAL/Wave/WaveInfo.cs | 60 ------------ Tools/WaveUtils/ALFormat.cs | 10 ++ .../Wave => Tools/WaveUtils}/ALaw.cs | 29 +++--- Tools/WaveUtils/IEEEFloat.cs | 40 ++++++++ .../Wave => Tools/WaveUtils}/MsAdpcm.cs | 2 +- .../Wave => Tools/WaveUtils}/MuLaw.cs | 29 +++--- Tools/WaveUtils/Properties/AssemblyInfo.cs | 36 +++++++ Tools/WaveUtils/WaveConverter.cs | 50 ++++++++++ .../Wave => Tools/WaveUtils}/WaveFile.cs | 97 +++---------------- .../Wave => Tools/WaveUtils}/WaveFormat.cs | 2 +- Tools/WaveUtils/WaveInfo.cs | 36 +++++++ Tools/WaveUtils/WaveUtils.csproj | 65 +++++++++++++ 34 files changed, 577 insertions(+), 389 deletions(-) create mode 100644 ANX.Framework.Content.Pipeline/Importer/WavImporter.cs create mode 100644 ANX.Framework.Content.Pipeline/Serialization/Compiler/MediaTypeWriters/SoundEffectWriter.cs delete mode 100644 SoundSystems/ANX.SoundSystem.OpenAL/Wave/WaveInfo.cs create mode 100644 Tools/WaveUtils/ALFormat.cs rename {SoundSystems/ANX.SoundSystem.OpenAL/Wave => Tools/WaveUtils}/ALaw.cs (83%) create mode 100644 Tools/WaveUtils/IEEEFloat.cs rename {SoundSystems/ANX.SoundSystem.OpenAL/Wave => Tools/WaveUtils}/MsAdpcm.cs (95%) rename {SoundSystems/ANX.SoundSystem.OpenAL/Wave => Tools/WaveUtils}/MuLaw.cs (84%) create mode 100644 Tools/WaveUtils/Properties/AssemblyInfo.cs create mode 100644 Tools/WaveUtils/WaveConverter.cs rename {SoundSystems/ANX.SoundSystem.OpenAL/Wave => Tools/WaveUtils}/WaveFile.cs (60%) rename {SoundSystems/ANX.SoundSystem.OpenAL/Wave => Tools/WaveUtils}/WaveFormat.cs (92%) create mode 100644 Tools/WaveUtils/WaveInfo.cs create mode 100644 Tools/WaveUtils/WaveUtils.csproj diff --git a/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline.csproj b/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline.csproj index d04a9fa6..c8b9bf4a 100644 --- a/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline.csproj +++ b/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline.csproj @@ -21,6 +21,7 @@ DEBUG;TRACE prompt 4 + true pdbonly @@ -29,6 +30,7 @@ TRACE prompt 4 + true @@ -104,6 +106,7 @@ + @@ -158,6 +161,7 @@ + @@ -189,6 +193,10 @@ {EB8258E0-6741-4DB9-B756-1EBDF67B1ED6} ANX.RenderSystem.Windows.GL3 + + {1986B0ED-3D28-4FEE-82D0-BCC39C87C18C} + WaveUtils + diff --git a/ANX.Framework.Content.Pipeline/Audio/AudioContent.cs b/ANX.Framework.Content.Pipeline/Audio/AudioContent.cs index 954b6521..eb7ec9a6 100644 --- a/ANX.Framework.Content.Pipeline/Audio/AudioContent.cs +++ b/ANX.Framework.Content.Pipeline/Audio/AudioContent.cs @@ -1,11 +1,6 @@ -#region Using Statements -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System; using System.Collections.ObjectModel; - -#endregion +using WaveUtils; // This file is part of the ANX.Framework created by the // "ANX.Framework developer group" and released under the Ms-PL license. @@ -24,14 +19,32 @@ namespace ANX.Framework.Content.Pipeline.Audio public int LoopLength { get; internal set; } public int LoopStart { get; internal set; } + internal WaveInfo LoadedWaveData { get; private set; } + + internal AudioContent(WaveInfo setLoadedWaveData) + { + LoadedWaveData = setLoadedWaveData; + } + public void ConvertFormat(ConversionFormat formatType, ConversionQuality quality, string targetFileName) { - throw new NotImplementedException(); + var converter = new WaveConverter(LoadedWaveData); + + int resultChannelCount = LoadedWaveData.Channels; + // Make mono on mobile devices which is totally enough. + if (quality == ConversionQuality.Low) + resultChannelCount = 1; + + if (formatType == ConversionFormat.Pcm) + converter.ConvertToPcm(resultChannelCount); + else + throw new NotImplementedException(); + + Data = new ReadOnlyCollection(LoadedWaveData.Data); } public void Dispose() { - throw new NotImplementedException(); } } } diff --git a/ANX.Framework.Content.Pipeline/Audio/ConversionQuality.cs b/ANX.Framework.Content.Pipeline/Audio/ConversionQuality.cs index 29793b6a..07918ff0 100644 --- a/ANX.Framework.Content.Pipeline/Audio/ConversionQuality.cs +++ b/ANX.Framework.Content.Pipeline/Audio/ConversionQuality.cs @@ -1,18 +1,22 @@ -#region Using Statements -using System; - -#endregion - -// This file is part of the ANX.Framework created by the +// 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 namespace ANX.Framework.Content.Pipeline.Audio { - public enum ConversionQuality - { - Low, - Medium, - Best, - } + public enum ConversionQuality + { + /// + /// 96 KBit/s + /// + Low, + /// + /// 128 KBit/s + /// + Medium, + /// + /// 192 KBit/s + /// + Best, + } } diff --git a/ANX.Framework.Content.Pipeline/ContentImporter.cs b/ANX.Framework.Content.Pipeline/ContentImporter.cs index 9802b76e..23132bc5 100644 --- a/ANX.Framework.Content.Pipeline/ContentImporter.cs +++ b/ANX.Framework.Content.Pipeline/ContentImporter.cs @@ -1,12 +1,4 @@ -#region Using Statements -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -#endregion - -// This file is part of the ANX.Framework created by the +// 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 diff --git a/ANX.Framework.Content.Pipeline/Importer/EffectImporter.cs b/ANX.Framework.Content.Pipeline/Importer/EffectImporter.cs index 5d6140f7..407f24cf 100644 --- a/ANX.Framework.Content.Pipeline/Importer/EffectImporter.cs +++ b/ANX.Framework.Content.Pipeline/Importer/EffectImporter.cs @@ -1,10 +1,6 @@ #region Using Statements -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using ANX.Framework.Content.Pipeline.Graphics; using System.IO; +using ANX.Framework.Content.Pipeline.Graphics; using ANX.Framework.NonXNA; #endregion diff --git a/ANX.Framework.Content.Pipeline/Importer/WavImporter.cs b/ANX.Framework.Content.Pipeline/Importer/WavImporter.cs new file mode 100644 index 00000000..b4daa73b --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Importer/WavImporter.cs @@ -0,0 +1,28 @@ +using System.IO; +using ANX.Framework.Content.Pipeline.Audio; +using WaveUtils; + +// 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 + +namespace ANX.Framework.Content.Pipeline.Importer +{ + [ContentImporter(new string[] { ".wav" }, DefaultProcessor = "SoundEffectProcessor")] + public class WavImporter : ContentImporter + { + public override AudioContent Import(string filename, ContentImporterContext context) + { + WaveInfo loadedData; + using (Stream filestream = File.OpenRead(filename)) + loadedData = WaveFile.LoadData(filestream); + + return new AudioContent(loadedData) + { + FileName = filename, + Identity = new ContentIdentity(filename, null, null), + FileType = AudioFileType.Wav, + }; + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Processors/SoundEffectContent.cs b/ANX.Framework.Content.Pipeline/Processors/SoundEffectContent.cs index bf627234..5c3bd975 100644 --- a/ANX.Framework.Content.Pipeline/Processors/SoundEffectContent.cs +++ b/ANX.Framework.Content.Pipeline/Processors/SoundEffectContent.cs @@ -1,10 +1,5 @@ -#region Using Statements -using System; +using System; using System.Collections.Generic; -using System.Linq; -using System.Text; - -#endregion // This file is part of the ANX.Framework created by the // "ANX.Framework developer group" and released under the Ms-PL license. @@ -13,6 +8,20 @@ using System.Text; namespace ANX.Framework.Content.Pipeline.Processors { public sealed class SoundEffectContent - { + { + internal List Format { get; private set; } + internal List Data { get; private set; } + internal int LoopStart { get; private set; } + internal int LoopLength { get; private set; } + internal int Duration { get; private set; } + + internal SoundEffectContent(List setFormat, List setData, int setLoopStart, int setLoopLength, int setDuration) + { + Format = setFormat; + Data = setData; + LoopStart = setLoopStart; + LoopLength = setLoopLength; + Duration = setDuration; + } } } diff --git a/ANX.Framework.Content.Pipeline/Processors/SoundEffectProcessor.cs b/ANX.Framework.Content.Pipeline/Processors/SoundEffectProcessor.cs index d3a2fa6f..b45d0ede 100644 --- a/ANX.Framework.Content.Pipeline/Processors/SoundEffectProcessor.cs +++ b/ANX.Framework.Content.Pipeline/Processors/SoundEffectProcessor.cs @@ -1,11 +1,9 @@ -#region Using Statements -using System; +using System; using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.ComponentModel; +using System.Runtime.InteropServices; using ANX.Framework.Content.Pipeline.Audio; - -#endregion +using WaveUtils; // This file is part of the ANX.Framework created by the // "ANX.Framework developer group" and released under the Ms-PL license. @@ -13,18 +11,48 @@ using ANX.Framework.Content.Pipeline.Audio; namespace ANX.Framework.Content.Pipeline.Processors { - [ContentProcessor] + [ContentProcessor(DisplayName = "Sound Effect - ANX Framework")] public class SoundEffectProcessor : ContentProcessor - { - public ConversionQuality Quality - { - get; - set; - } + { + private struct WAVEFORMATEX + { + public ushort wFormatTag; + public ushort nChannels; + public int nSamplesPerSec; + public int nAvgBytesPerSec; + public ushort nBlockAlign; + public ushort wBitsPerSample; + public ushort cbSize; + } + [DefaultValue(ConversionQuality.Medium)] + public ConversionQuality Quality { get; set; } + public override SoundEffectContent Process(AudioContent input, ContentProcessorContext context) { - throw new NotImplementedException(); + input.ConvertFormat(ConversionFormat.Pcm, Quality, null); + + var waveHeader = new WAVEFORMATEX() + { + wFormatTag = (ushort)WaveFormat.PCM, + nChannels = (ushort)input.LoadedWaveData.Channels, + nSamplesPerSec = input.LoadedWaveData.SampleRate, + nAvgBytesPerSec = 0, // TODO + nBlockAlign = (ushort)input.LoadedWaveData.BlockAlign, + wBitsPerSample = (ushort)input.LoadedWaveData.BitsPerSample, + cbSize = 0, // TODO + }; + + int length = Marshal.SizeOf(waveHeader.GetType()); + byte[] array = new byte[length]; + + IntPtr ptr = Marshal.AllocHGlobal(length); + Marshal.StructureToPtr(waveHeader, ptr, true); + Marshal.Copy(ptr, array, 0, length); + Marshal.FreeHGlobal(ptr); + + return new SoundEffectContent(new List(array), new List(input.Data), input.LoopStart, input.LoopLength, + (int)input.Duration.TotalMilliseconds); } } } diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/GraphicTypeWriters/EffectWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/GraphicTypeWriters/EffectWriter.cs index aaf07c6a..9cee016e 100644 --- a/ANX.Framework.Content.Pipeline/Serialization/Compiler/GraphicTypeWriters/EffectWriter.cs +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/GraphicTypeWriters/EffectWriter.cs @@ -1,10 +1,7 @@ #region Using Statements using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using ANX.Framework.Content.Pipeline.Processors; using System.Reflection; +using ANX.Framework.Content.Pipeline.Processors; using ANX.Framework.Graphics; #endregion diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/MediaTypeWriters/SoundEffectWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MediaTypeWriters/SoundEffectWriter.cs new file mode 100644 index 00000000..d725f636 --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MediaTypeWriters/SoundEffectWriter.cs @@ -0,0 +1,42 @@ +using System; +using ANX.Framework.Audio; +using ANX.Framework.Content.Pipeline.Processors; + +// 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 + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler +{ + [ContentTypeWriter] + internal class SoundEffectWriter : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, SoundEffectContent value) + { + if (output == null) + throw new ArgumentNullException("ouput"); + if (value == null) + throw new ArgumentNullException("value"); + + output.Write(value.Format.Count); + output.Write(value.Format.ToArray()); + + output.Write(value.Data.Count); + output.Write(value.Data.ToArray()); + + output.Write(value.LoopStart); + output.Write(value.LoopLength); + output.Write(value.Duration); + } + + protected internal override bool ShouldCompressContent(TargetPlatform targetPlatform, object value) + { + return false; + } + + public override string GetRuntimeType(TargetPlatform targetPlatform) + { + return ContentTypeWriter.GetStrongTypeName(typeof(SoundEffect), targetPlatform); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Tasks/ImporterManager.cs b/ANX.Framework.Content.Pipeline/Tasks/ImporterManager.cs index 0490bdc4..043c375f 100644 --- a/ANX.Framework.Content.Pipeline/Tasks/ImporterManager.cs +++ b/ANX.Framework.Content.Pipeline/Tasks/ImporterManager.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Reflection; +using ANX.Framework.NonXNA.Reflection; #endregion @@ -21,9 +22,10 @@ namespace ANX.Framework.Content.Pipeline.Tasks { foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { - foreach (Type type in assembly.GetTypes()) + + foreach (Type type in TypeHelper.SafelyExtractTypesFrom(assembly)) { - ContentImporterAttribute[] value = (ContentImporterAttribute[]) type.GetCustomAttributes(typeof(ContentImporterAttribute), true); + ContentImporterAttribute[] value = (ContentImporterAttribute[])type.GetCustomAttributes(typeof(ContentImporterAttribute), true); if (value.Length > 0) { importerTypes[type.Name] = type; diff --git a/ANX.Framework.sln b/ANX.Framework.sln index d5891031..c8a211d3 100644 --- a/ANX.Framework.sln +++ b/ANX.Framework.sln @@ -179,6 +179,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ANX.SoundSystem.PsVita", "S EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AudioSample", "Samples\AudioSample\AudioSample.csproj", "{4A048A8C-C31D-4FC8-AAF3-C387B9E0309B}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WaveUtils", "Tools\WaveUtils\WaveUtils.csproj", "{1986B0ED-3D28-4FEE-82D0-BCC39C87C18C}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ANX.ContentCompiler.GUI", "Tools\ANXContentCompilerGUI\ANX.ContentCompiler.GUI.csproj", "{45DD7B40-C498-4DD2-A16B-FD6C4E6991B3}" EndProject Global @@ -691,6 +693,18 @@ Global {4A048A8C-C31D-4FC8-AAF3-C387B9E0309B}.Release|Mixed Platforms.Build.0 = Release|x86 {4A048A8C-C31D-4FC8-AAF3-C387B9E0309B}.Release|x86.ActiveCfg = Release|x86 {4A048A8C-C31D-4FC8-AAF3-C387B9E0309B}.Release|x86.Build.0 = Release|x86 +<<<<<<< .mine + {1986B0ED-3D28-4FEE-82D0-BCC39C87C18C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1986B0ED-3D28-4FEE-82D0-BCC39C87C18C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1986B0ED-3D28-4FEE-82D0-BCC39C87C18C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {1986B0ED-3D28-4FEE-82D0-BCC39C87C18C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {1986B0ED-3D28-4FEE-82D0-BCC39C87C18C}.Debug|x86.ActiveCfg = Debug|Any CPU + {1986B0ED-3D28-4FEE-82D0-BCC39C87C18C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1986B0ED-3D28-4FEE-82D0-BCC39C87C18C}.Release|Any CPU.Build.0 = Release|Any CPU + {1986B0ED-3D28-4FEE-82D0-BCC39C87C18C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {1986B0ED-3D28-4FEE-82D0-BCC39C87C18C}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {1986B0ED-3D28-4FEE-82D0-BCC39C87C18C}.Release|x86.ActiveCfg = Release|Any CPU +======= {45DD7B40-C498-4DD2-A16B-FD6C4E6991B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {45DD7B40-C498-4DD2-A16B-FD6C4E6991B3}.Debug|Any CPU.Build.0 = Debug|Any CPU {45DD7B40-C498-4DD2-A16B-FD6C4E6991B3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -701,6 +715,7 @@ Global {45DD7B40-C498-4DD2-A16B-FD6C4E6991B3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {45DD7B40-C498-4DD2-A16B-FD6C4E6991B3}.Release|Mixed Platforms.Build.0 = Release|Any CPU {45DD7B40-C498-4DD2-A16B-FD6C4E6991B3}.Release|x86.ActiveCfg = Release|Any CPU +>>>>>>> .r17804 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -715,7 +730,11 @@ Global {10F7894D-E8B5-4DCA-BB08-5C99FA792388} = {B24A8593-562A-4A25-BB08-46C163F10F3F} {938D5F88-B888-4B04-BEEE-EE701FBA51EF} = {B24A8593-562A-4A25-BB08-46C163F10F3F} {14B39F89-C9B0-407E-877A-B515C985E96E} = {B24A8593-562A-4A25-BB08-46C163F10F3F} +<<<<<<< .mine + {1986B0ED-3D28-4FEE-82D0-BCC39C87C18C} = {B24A8593-562A-4A25-BB08-46C163F10F3F} +======= {45DD7B40-C498-4DD2-A16B-FD6C4E6991B3} = {B24A8593-562A-4A25-BB08-46C163F10F3F} +>>>>>>> .r17804 {5BE49183-2F6F-4527-AC90-D816911FCF90} = {D421509A-9AE3-4D7E-881B-EAFED598B028} {EB8258E0-6741-4DB9-B756-1EBDF67B1ED6} = {D421509A-9AE3-4D7E-881B-EAFED598B028} {B30DE9C2-0926-46B6-8351-9AF276C472D5} = {D421509A-9AE3-4D7E-881B-EAFED598B028} diff --git a/ANX.Framework/Audio/SoundEffect.cs b/ANX.Framework/Audio/SoundEffect.cs index 6d132a7c..95aa8829 100644 --- a/ANX.Framework/Audio/SoundEffect.cs +++ b/ANX.Framework/Audio/SoundEffect.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.IO; using ANX.Framework.NonXNA; -using ANX.Framework.NonXNA.SoundSystem; using ANX.Framework.NonXNA.Development; +using ANX.Framework.NonXNA.SoundSystem; // This file is part of the ANX.Framework created by the // "ANX.Framework developer group" and released under the Ms-PL license. @@ -12,6 +12,8 @@ using ANX.Framework.NonXNA.Development; namespace ANX.Framework.Audio { [PercentageComplete(100)] + [TestState(TestStateAttribute.TestState.InProgress)] + [Developer("AstrorEnales")] public sealed class SoundEffect : IDisposable { #region Static diff --git a/ANX.Framework/Audio/SoundEffectInstance.cs b/ANX.Framework/Audio/SoundEffectInstance.cs index f6013daa..59406b4c 100644 --- a/ANX.Framework/Audio/SoundEffectInstance.cs +++ b/ANX.Framework/Audio/SoundEffectInstance.cs @@ -1,8 +1,7 @@ using System; -using System.IO; using ANX.Framework.NonXNA; -using ANX.Framework.NonXNA.SoundSystem; using ANX.Framework.NonXNA.Development; +using ANX.Framework.NonXNA.SoundSystem; // This file is part of the ANX.Framework created by the // "ANX.Framework developer group" and released under the Ms-PL license. @@ -11,6 +10,8 @@ using ANX.Framework.NonXNA.Development; namespace ANX.Framework.Audio { [PercentageComplete(100)] + [TestState(TestStateAttribute.TestState.InProgress)] + [Developer("AstrorEnales")] public class SoundEffectInstance : IDisposable { #region Private diff --git a/ANX.Framework/Content/MediaTypeReaders/SoundEffectReader.cs b/ANX.Framework/Content/MediaTypeReaders/SoundEffectReader.cs index 6321e8e1..8ecf7029 100644 --- a/ANX.Framework/Content/MediaTypeReaders/SoundEffectReader.cs +++ b/ANX.Framework/Content/MediaTypeReaders/SoundEffectReader.cs @@ -36,7 +36,7 @@ namespace ANX.Framework.Content int loopStart = input.ReadInt32(); int loopLength = input.ReadInt32(); - int num = input.ReadInt32(); + int duration = input.ReadInt32(); byte[] soundData = null; using (MemoryStream mStream = new MemoryStream(20 + header.Length + 8 + data.Length)) diff --git a/ANX.Framework/Graphics/ConstantBuffer.cs b/ANX.Framework/Graphics/ConstantBuffer.cs index c84ba1e9..14a2a03f 100644 --- a/ANX.Framework/Graphics/ConstantBuffer.cs +++ b/ANX.Framework/Graphics/ConstantBuffer.cs @@ -1,14 +1,7 @@ -#region Using Statements -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using ANX.Framework.NonXNA; using ANX.Framework.NonXNA.Development; -using ANX.Framework.NonXNA; using ANX.Framework.NonXNA.RenderSystem; -#endregion - // 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 diff --git a/ANX.Framework/Properties/AssemblyInfo.cs b/ANX.Framework/Properties/AssemblyInfo.cs index 9df749d3..776ab484 100644 --- a/ANX.Framework/Properties/AssemblyInfo.cs +++ b/ANX.Framework/Properties/AssemblyInfo.cs @@ -48,4 +48,5 @@ using System.Runtime.InteropServices; [assembly: InternalsVisibleTo("ANX.PlatformSystem.Linux")] [assembly: InternalsVisibleTo("ANX.PlatformSystem.Metro")] [assembly: InternalsVisibleTo("ANX.PlatformSystem.PsVita")] -[assembly: InternalsVisibleTo("ANX.Tools.XNBInspector")] \ No newline at end of file +[assembly: InternalsVisibleTo("ANX.Tools.XNBInspector")] +[assembly: InternalsVisibleTo("ANX.Framework.Content.Pipeline")] \ No newline at end of file diff --git a/RenderSystems/ANX.Framework.Windows.GL3/EffectGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/EffectGL3.cs index 005e0ad0..4ccc3101 100644 --- a/RenderSystems/ANX.Framework.Windows.GL3/EffectGL3.cs +++ b/RenderSystems/ANX.Framework.Windows.GL3/EffectGL3.cs @@ -14,46 +14,27 @@ namespace ANX.RenderSystem.Windows.GL3 { /// /// Native OpenGL Effect implementation. - /// /// http://wiki.delphigl.com/index.php/Tutorial_glsl /// public class EffectGL3 : INativeEffect { #region Private - /// - /// The managed effect instance of this shader. - /// private Effect managedEffect; - - /// - /// The loaded shader data from the shader file. - /// private ShaderData shaderData; - - /// - /// The available techniques of this shader. - /// + private List parameters; private List techniques; + internal bool IsDisposed; - /// - /// The current native technique. - /// internal EffectTechniqueGL3 CurrentTechnique { get { if (managedEffect.CurrentTechnique == null) - { return null; - } return managedEffect.CurrentTechnique.NativeTechnique as EffectTechniqueGL3; } } - - private List parameters; - - internal bool IsDisposed; #endregion #region Public @@ -92,7 +73,6 @@ namespace ANX.RenderSystem.Windows.GL3 /// /// Private helper constructor for the basic initialization. /// - /// private EffectGL3(Effect setManagedEffect) { GraphicsResourceManager.UpdateResource(this, true); @@ -112,8 +92,7 @@ namespace ANX.RenderSystem.Windows.GL3 /// /// The vertex shader code. /// The fragment shader code. - public EffectGL3(Effect setManagedEffect, Stream vertexShaderByteCode, - Stream pixelShaderByteCode) + public EffectGL3(Effect setManagedEffect, Stream vertexShaderByteCode, Stream pixelShaderByteCode) : this(setManagedEffect) { // TODO: this is probably not right! @@ -153,16 +132,13 @@ namespace ANX.RenderSystem.Windows.GL3 #region Compile vertex shaders foreach (string vertexName in shaderData.VertexShaderCodes.Keys) { - string vertexSource = shaderData.VertexGlobalCode + - shaderData.VertexShaderCodes[vertexName]; + string vertexSource = shaderData.VertexGlobalCode + shaderData.VertexShaderCodes[vertexName]; int vertexShader = GL.CreateShader(ShaderType.VertexShader); string vertexError = CompileShader(vertexShader, vertexSource); if (String.IsNullOrEmpty(vertexError) == false) - { - throw new InvalidDataException("Failed to compile the vertex " + - "shader '" + vertexName + "' because of: " + vertexError); - } + throw new InvalidDataException("Failed to compile the vertex shader '" + vertexName + "' cause of: " + + vertexError); vertexShaders.Add(vertexName, vertexShader); } @@ -171,16 +147,13 @@ namespace ANX.RenderSystem.Windows.GL3 #region Compile fragment shaders foreach (string fragmentName in shaderData.FragmentShaderCodes.Keys) { - string fragmentSource = shaderData.FragmentGlobalCode + - shaderData.FragmentShaderCodes[fragmentName]; + string fragmentSource = shaderData.FragmentGlobalCode + shaderData.FragmentShaderCodes[fragmentName]; int fragmentShader = GL.CreateShader(ShaderType.FragmentShader); - string vertexError = CompileShader(fragmentShader, fragmentSource); - if (String.IsNullOrEmpty(vertexError) == false) - { - throw new InvalidDataException("Failed to compile the fragment " + - "shader '" + fragmentName + "' because of: " + vertexError); - } + string fragmentError = CompileShader(fragmentShader, fragmentSource); + if (String.IsNullOrEmpty(fragmentError) == false) + throw new InvalidDataException("Failed to compile the fragment shader '" + fragmentName + "' cause of: " + + fragmentError); fragmentShaders.Add(fragmentName, fragmentShader); } @@ -210,8 +183,7 @@ namespace ANX.RenderSystem.Windows.GL3 programName + "' because of: " + programError); } - EffectTechniqueGL3 technique = - new EffectTechniqueGL3(managedEffect, programName, programHandle); + EffectTechniqueGL3 technique = new EffectTechniqueGL3(managedEffect, programName, programHandle); techniques.Add(new EffectTechnique(managedEffect, technique)); AddParametersFrom(programHandle, parameterNames, technique); } diff --git a/RenderSystems/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs index a690de7b..e5e119bd 100644 --- a/RenderSystems/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs +++ b/RenderSystems/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs @@ -90,28 +90,16 @@ namespace ANX.RenderSystem.Windows.GL3 #endregion #region ResetDevice - /// - /// Reset the graphics device with the given presentation paramters. - /// If a device is currently set, then we dispose the old one. - /// - /// Parameters for the - /// graphics device. private void ResetDevice(PresentationParameters presentationParameters) { - #region Validation if (nativeContext != null) - { Dispose(); - } - #endregion - // Reset the previous set buffers, effects and targets. boundVertexBuffers = new VertexBufferGL3[0]; boundRenderTargets = new RenderTarget2DGL3[0]; boundIndexBuffer = null; activeEffect = null; - // OpenGL Depth Buffer Size: 0/16/24/32 int depth = 0; int stencil = 0; switch (presentationParameters.DepthStencilFormat) @@ -133,52 +121,28 @@ namespace ANX.RenderSystem.Windows.GL3 break; } - graphicsMode = new GraphicsMode( - DatatypesMapping.SurfaceToColorFormat( - presentationParameters.BackBufferFormat), - depth, - stencil, - // AntiAlias Samples: 2/4/8/16/32 - presentationParameters.MultiSampleCount); + ResizeRenderWindow(presentationParameters); - CreateWindowInfo(presentationParameters.DeviceWindowHandle, - graphicsMode.Index.Value); + var colorFormat = DatatypesMapping.SurfaceToColorFormat(presentationParameters.BackBufferFormat); + graphicsMode = new GraphicsMode(colorFormat, depth, stencil, presentationParameters.MultiSampleCount); - GetOpenGLVersion(); + CreateWindowInfo(presentationParameters.DeviceWindowHandle, graphicsMode.Index.Value); - //ResizeRenderWindow(presentationParameters); - - nativeContext = new GraphicsContext(graphicsMode, nativeWindowInfo, - cachedVersionMajor, cachedVersionMinor, GraphicsContextFlags.Default); + nativeContext = new GraphicsContext(graphicsMode, nativeWindowInfo); nativeContext.MakeCurrent(nativeWindowInfo); nativeContext.LoadAll(); + string version = GL.GetString(StringName.Version); + string[] parts = version.Split(new char[] { '.', ' ' }); + cachedVersionMajor = int.Parse(parts[0]); + cachedVersionMinor = int.Parse(parts[1]); + + GL.Viewport(0, 0, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight); + GraphicsResourceManager.RecreateAllResources(); } #endregion - #region GetOpenGLVersion - private void GetOpenGLVersion() - { - if (cachedVersionMinor == -1 && - cachedVersionMajor == -1) - { - GraphicsContext context = new GraphicsContext( - graphicsMode, nativeWindowInfo); - context.MakeCurrent(nativeWindowInfo); - context.LoadAll(); - - string version = GL.GetString(StringName.Version); - string[] parts = version.Split(new char[] { '.', ' ' }); - cachedVersionMajor = int.Parse(parts[0]); - cachedVersionMinor = int.Parse(parts[1]); - - context.Dispose(); - context = null; - } - } - #endregion - #region CreateWindowInfo private void CreateWindowInfo(IntPtr windowHandle, IntPtr graphicsModeHandle) { @@ -288,10 +252,10 @@ namespace ANX.RenderSystem.Windows.GL3 /// public void Present() { - if (nativeContext != null) - { - nativeContext.SwapBuffers(); - } + if (nativeContext != null) + { + nativeContext.SwapBuffers(); + } } #endregion @@ -375,17 +339,17 @@ namespace ANX.RenderSystem.Windows.GL3 } #endregion + #region SetConstantBuffer (TODO) #if XNAEXT - public void SetConstantBuffer(int slot, ANX.Framework.Graphics.ConstantBuffer constantBuffer) - { - if (constantBuffer == null) - { - throw new ArgumentNullException("constantBuffer"); - } + public void SetConstantBuffer(int slot, ConstantBuffer constantBuffer) + { + if (constantBuffer == null) + throw new ArgumentNullException("constantBuffer"); - throw new NotImplementedException(); - } + throw new NotImplementedException(); + } #endif + #endregion #region SetVertexBuffers public void SetVertexBuffers(VertexBufferBinding[] vertexBuffers) @@ -432,7 +396,7 @@ namespace ANX.RenderSystem.Windows.GL3 } } #endregion - + #region SetRenderTargets public void SetRenderTargets(params RenderTargetBinding[] renderTargets) { diff --git a/Samples/SimpleSprite/Program.cs b/Samples/SimpleSprite/Program.cs index 530785ee..717203bd 100644 --- a/Samples/SimpleSprite/Program.cs +++ b/Samples/SimpleSprite/Program.cs @@ -1,24 +1,28 @@ +#define USE_GL3 + using System; using ANX.Framework.NonXNA; namespace WindowsGame1 { - static class Program - { - /// - /// The main entry point for the application. - /// - static void Main(string[] args) - { - AddInSystemFactory.Instance.SetPreferredSystem( - //AddInType.RenderSystem, "OpenGL3"); - AddInType.RenderSystem, "DirectX10"); + static class Program + { + /// + /// The main entry point for the application. + /// + static void Main(string[] args) + { +#if USE_GL3 + AddInSystemFactory.Instance.SetPreferredSystem(AddInType.RenderSystem, "OpenGL3"); +#else + AddInSystemFactory.Instance.SetPreferredSystem(AddInType.RenderSystem, "DirectX10"); +#endif - using (Game1 game = new Game1()) - { - game.Run(); - } - } - } + using (Game1 game = new Game1()) + { + game.Run(); + } + } + } } diff --git a/SoundSystems/ANX.SoundSystem.OpenAL/ANX.SoundSystem.OpenAL.csproj b/SoundSystems/ANX.SoundSystem.OpenAL/ANX.SoundSystem.OpenAL.csproj index 30df5594..450f385e 100644 --- a/SoundSystems/ANX.SoundSystem.OpenAL/ANX.SoundSystem.OpenAL.csproj +++ b/SoundSystems/ANX.SoundSystem.OpenAL/ANX.SoundSystem.OpenAL.csproj @@ -70,18 +70,16 @@ - - - - - - {6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35} ANX.Framework + + {1986B0ED-3D28-4FEE-82D0-BCC39C87C18C} + WaveUtils + + \ No newline at end of file