Added AudioSample and testsound.wav as a testcase for SoundEffect and SoundEffectInstance which now work with the OpenAL SoundSystem.

This commit is contained in:
SND\AstrorEnales_cp 2012-08-29 13:04:22 +00:00
parent 00dabcf111
commit 1a429e25d5
32 changed files with 470 additions and 31 deletions

View File

@ -32,6 +32,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing" />
</ItemGroup>
<ItemGroup>
<Compile Include="AnxContentImporterContext.cs" />
@ -102,6 +103,7 @@
<Compile Include="Graphics\VertexContent.cs" />
<Compile Include="IContentImporter.cs" />
<Compile Include="IContentProcessor.cs" />
<Compile Include="Importer\TextureImporter.cs" />
<Compile Include="NamedValueDictionary.cs" />
<Compile Include="OpaqueDataDictionary.cs" />
<Compile Include="Processors\CompiledEffectContent.cs" />
@ -142,6 +144,7 @@
<Compile Include="Serialization\Compiler\GenericContentTypeWriter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Serialization\Compiler\GraphicTypeWriters\EffectWriter.cs" />
<Compile Include="Serialization\Compiler\GraphicTypeWriters\TextureWriter.cs" />
<Compile Include="Serialization\Compiler\MathTypeWriters\BoundingBoxWriter.cs" />
<Compile Include="Serialization\Compiler\MathTypeWriters\BoundingSphereWriter.cs" />
<Compile Include="Serialization\Compiler\MathTypeWriters\BoundingFrustumWriter.cs" />
@ -172,7 +175,6 @@
<Compile Include="TargetPlatform.cs" />
<Compile Include="Tasks\BuildContent.cs" />
<Compile Include="Tasks\BuildItem.cs" />
<Compile Include="Tasks\BuildRequest.cs" />
<Compile Include="Tasks\ImporterManager.cs" />
<Compile Include="Tasks\ProcessorManager.cs" />
<Compile Include="VideoContent.cs" />

View File

@ -32,6 +32,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
@ -103,6 +104,7 @@
<Compile Include="Graphics\VertexContent.cs" />
<Compile Include="IContentImporter.cs" />
<Compile Include="IContentProcessor.cs" />
<Compile Include="Importer\TextureImporter.cs" />
<Compile Include="NamedValueDictionary.cs" />
<Compile Include="OpaqueDataDictionary.cs" />
<Compile Include="Processors\CompiledEffectContent.cs" />
@ -143,6 +145,7 @@
<Compile Include="Serialization\Compiler\GenericContentTypeWriter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Serialization\Compiler\GraphicTypeWriters\EffectWriter.cs" />
<Compile Include="Serialization\Compiler\GraphicTypeWriters\TextureWriter.cs" />
<Compile Include="Serialization\Compiler\MathTypeWriters\BoundingBoxWriter.cs" />
<Compile Include="Serialization\Compiler\MathTypeWriters\BoundingSphereWriter.cs" />
<Compile Include="Serialization\Compiler\MathTypeWriters\BoundingFrustumWriter.cs" />
@ -173,7 +176,6 @@
<Compile Include="TargetPlatform.cs" />
<Compile Include="Tasks\BuildContent.cs" />
<Compile Include="Tasks\BuildItem.cs" />
<Compile Include="Tasks\BuildRequest.cs" />
<Compile Include="Tasks\ImporterManager.cs" />
<Compile Include="Tasks\ProcessorManager.cs" />
<Compile Include="VideoContent.cs" />

View File

@ -177,6 +177,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ANX.InputDevices.PsVita", "
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ANX.SoundSystem.PsVita", "SoundSystems\ANX.SoundSystem.PsVita\ANX.SoundSystem.PsVita.csproj", "{E2EE2D12-A98E-4C21-AFFA-35F48D2B2A94}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AudioSample", "Samples\AudioSample\AudioSample.csproj", "{4A048A8C-C31D-4FC8-AAF3-C387B9E0309B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -677,6 +679,16 @@ Global
{E2EE2D12-A98E-4C21-AFFA-35F48D2B2A94}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{E2EE2D12-A98E-4C21-AFFA-35F48D2B2A94}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{E2EE2D12-A98E-4C21-AFFA-35F48D2B2A94}.Release|x86.ActiveCfg = Release|Any CPU
{4A048A8C-C31D-4FC8-AAF3-C387B9E0309B}.Debug|Any CPU.ActiveCfg = Debug|x86
{4A048A8C-C31D-4FC8-AAF3-C387B9E0309B}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{4A048A8C-C31D-4FC8-AAF3-C387B9E0309B}.Debug|Mixed Platforms.Build.0 = Debug|x86
{4A048A8C-C31D-4FC8-AAF3-C387B9E0309B}.Debug|x86.ActiveCfg = Debug|x86
{4A048A8C-C31D-4FC8-AAF3-C387B9E0309B}.Debug|x86.Build.0 = Debug|x86
{4A048A8C-C31D-4FC8-AAF3-C387B9E0309B}.Release|Any CPU.ActiveCfg = Release|x86
{4A048A8C-C31D-4FC8-AAF3-C387B9E0309B}.Release|Mixed Platforms.ActiveCfg = Release|x86
{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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -711,6 +723,7 @@ Global
{EFC485F7-3E0A-40AB-B79D-E07FE86FC386} = {9B0DD48B-3912-4F33-AF3F-691AF02B73F9}
{ED081799-AB02-4793-96F8-F9EA7F3192E3} = {9B0DD48B-3912-4F33-AF3F-691AF02B73F9}
{160150D5-38E6-482D-97F5-2624F322A854} = {9B0DD48B-3912-4F33-AF3F-691AF02B73F9}
{4A048A8C-C31D-4FC8-AAF3-C387B9E0309B} = {9B0DD48B-3912-4F33-AF3F-691AF02B73F9}
{DB88DDEB-7281-405D-8FCA-5681B6B2BD7A} = {7AD65E6B-2A48-437F-81D9-4CA9C9A85C64}
{49066074-3B7B-4A55-B122-6BD33AB73558} = {7AD65E6B-2A48-437F-81D9-4CA9C9A85C64}
{60D08399-244F-46A3-91F1-4CFD26D961A3} = {7AD65E6B-2A48-437F-81D9-4CA9C9A85C64}

View File

@ -98,6 +98,7 @@
<Compile Include="Content\MathTypeReaders\RectangleReader.cs" />
<Compile Include="Content\MathTypeReaders\Vector2Reader.cs" />
<Compile Include="Content\MathTypeReaders\Vector3Reader.cs" />
<Compile Include="Content\MediaTypeReaders\SoundEffectReader.cs" />
<Compile Include="Content\PrimitiveTypeReaders\BooleanReader.cs" />
<Compile Include="Content\PrimitiveTypeReaders\ByteReader.cs" />
<Compile Include="Content\PrimitiveTypeReaders\CharReader.cs" />
@ -502,9 +503,7 @@
<Compile Include="Vector3.cs" />
<Compile Include="Vector4.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Content\MediaTypeReaders\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -1,5 +1,6 @@
using System;
using System.IO;
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -7,6 +8,7 @@ using System.IO;
namespace ANX.Framework.Audio
{
[PercentageComplete(30)]
public struct AudioCategory : IEquatable<AudioCategory>
{
#region Internal helper enums

View File

@ -1,5 +1,6 @@
using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.SoundSystem;
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -7,6 +8,7 @@ using ANX.Framework.NonXNA.SoundSystem;
namespace ANX.Framework.Audio
{
[PercentageComplete(100)]
public class AudioEmitter
{
#region Private

View File

@ -1,9 +1,10 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using ANX.Framework.Audio.XactParser;
using System.Collections.Generic;
using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -11,6 +12,7 @@ using ANX.Framework.NonXNA;
namespace ANX.Framework.Audio
{
[PercentageComplete(50)]
public class AudioEngine : IDisposable
{
#region Constants

View File

@ -1,5 +1,6 @@
using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.SoundSystem;
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -7,6 +8,7 @@ using ANX.Framework.NonXNA.SoundSystem;
namespace ANX.Framework.Audio
{
[PercentageComplete(100)]
public class AudioListener
{
#region Private

View File

@ -1,4 +1,5 @@
using System;
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -6,6 +7,7 @@
namespace ANX.Framework.Audio
{
[PercentageComplete(5)]
public sealed class Cue : IDisposable
{
#region Events

View File

@ -1,4 +1,5 @@
using System;
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -6,6 +7,7 @@
namespace ANX.Framework.Audio
{
[PercentageComplete(0)]
public sealed class DynamicSoundEffectInstance : SoundEffectInstance
{
#region Events

View File

@ -1,8 +1,6 @@
#region Using Statements
using System;
using System;
using System.Runtime.InteropServices;
#endregion // Using Statements
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -13,6 +11,7 @@ namespace ANX.Framework.Audio
#if !WINDOWSMETRO //TODO: search replacement for Win8
[Serializable]
#endif
[PercentageComplete(100)]
public sealed class InstancePlayLimitException : ExternalException
{
#region Constructor

View File

@ -2,6 +2,7 @@
using System.Collections.ObjectModel;
using ANX.Framework.NonXNA.SoundSystem;
using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -9,6 +10,7 @@ using ANX.Framework.NonXNA;
namespace ANX.Framework.Audio
{
[PercentageComplete(90)]
public sealed class Microphone
{
#region Private

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -10,6 +11,7 @@ namespace ANX.Framework.Audio
#if !WINDOWSMETRO //TODO: search replacement for Win8
[SerializableAttribute]
#endif
[PercentageComplete(100)]
public sealed class NoAudioHardwareException : ExternalException
{
public NoAudioHardwareException()

View File

@ -1,4 +1,5 @@
using System;
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -6,6 +7,7 @@
namespace ANX.Framework.Audio
{
[PercentageComplete(100)]
public sealed class NoMicrophoneConnectedException : Exception
{
public NoMicrophoneConnectedException()

View File

@ -1,4 +1,5 @@
using System;
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -6,6 +7,7 @@
namespace ANX.Framework.Audio
{
[PercentageComplete(100)]
public struct RendererDetail
{
#region Private

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.SoundSystem;
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -10,6 +11,7 @@ using ANX.Framework.NonXNA.SoundSystem;
namespace ANX.Framework.Audio
{
[PercentageComplete(100)]
public sealed class SoundEffect : IDisposable
{
#region Static
@ -118,7 +120,8 @@ namespace ANX.Framework.Audio
private SoundEffect(Stream stream)
: this()
{
nativeSoundEffect = GetCreator().CreateSoundEffect(this, stream);
var creator = GetCreator();
nativeSoundEffect = creator.CreateSoundEffect(this, stream);
}
public SoundEffect(byte[] buffer, int sampleRate, AudioChannels channels)
@ -126,12 +129,11 @@ namespace ANX.Framework.Audio
{
}
public SoundEffect(byte[] buffer, int offset, int count, int sampleRate,
AudioChannels channels, int loopStart, int loopLength)
public SoundEffect(byte[] buffer, int offset, int count, int sampleRate, AudioChannels channels, int loopStart, int loopLength)
: this()
{
nativeSoundEffect = GetCreator().CreateSoundEffect(this, buffer, offset,
count, sampleRate, channels, loopStart, loopLength);
var creator = GetCreator();
nativeSoundEffect = creator.CreateSoundEffect(this, buffer, offset, count, sampleRate, channels, loopStart, loopLength);
}
~SoundEffect()
@ -181,7 +183,7 @@ namespace ANX.Framework.Audio
#region Play
public bool Play()
{
return Play(1f, 0f, 0f);
return Play(1f, 1f, 0f);
}
public bool Play(float volume, float pitch, float pan)
@ -207,8 +209,9 @@ namespace ANX.Framework.Audio
newInstance.Play();
}
catch
catch (Exception ex)
{
Logger.Warning("Failed to play sound effect cause of: " + ex);
return false;
}

View File

@ -2,6 +2,7 @@
using System.IO;
using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.SoundSystem;
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -9,6 +10,7 @@ using ANX.Framework.NonXNA.SoundSystem;
namespace ANX.Framework.Audio
{
[PercentageComplete(100)]
public class SoundEffectInstance : IDisposable
{
#region Private

View File

@ -40,16 +40,15 @@ namespace ANX.Framework.Audio.XactParser
{
BinaryReader reader = new BinaryReader(stream);
ValidateMagic(reader);
ValidateVersion(reader);
ValidateToolVersion(reader);
ValidateFormatVersion(reader);
// unknown, but seems to be 0x002A across all files
reader.ReadUInt16();
// unknown, maybe something to do with the last modified values
reader.ReadUInt16();
DateTime lastModifiedDate = DateTime.FromFileTime(reader.ReadInt64());
// unknown, seems to stay 0x03
// seems to stay 0x03, probably platform
reader.ReadByte();
Categories = new AudioCategory[reader.ReadUInt16()];
@ -112,8 +111,8 @@ namespace ANX.Framework.Audio.XactParser
}
#endregion
#region ValidateVersion
private static void ValidateVersion(BinaryReader reader)
#region ValidateToolVersion
private static void ValidateToolVersion(BinaryReader reader)
{
ushort version = reader.ReadUInt16();
if (version != 47 && version != 46 && version != 45)
@ -121,6 +120,15 @@ namespace ANX.Framework.Audio.XactParser
}
#endregion
#region ValidateFormatVersion
private static void ValidateFormatVersion(BinaryReader reader)
{
ushort version = reader.ReadUInt16();
if (version != 42)
throw new InvalidVersionException();
}
#endregion
#region ParseNames
private static string[] ParseNames(int count, BinaryReader reader)
{

View File

@ -0,0 +1,64 @@
using System;
using ANX.Framework.Audio;
using System.IO;
using System.Runtime.InteropServices;
namespace ANX.Framework.Content
{
internal class SoundEffectReader : ContentTypeReader<SoundEffect>
{
private struct WAVEFORMATEX
{
public ushort wFormatTag;
public ushort nChannels;
public int nSamplesPerSec;
public int nAvgBytesPerSec;
public ushort nBlockAlign;
public ushort wBitsPerSample;
public ushort cbSize;
}
protected internal override SoundEffect Read(ContentReader input, SoundEffect existingInstance)
{
int formatCount = input.ReadInt32();
byte[] header = input.ReadBytes(formatCount);
WAVEFORMATEX headerStruct;
unsafe
{
fixed(byte* ptr = &header[0])
headerStruct = (WAVEFORMATEX)Marshal.PtrToStructure((IntPtr)ptr, typeof(WAVEFORMATEX));
}
int dataCount = input.ReadInt32();
byte[] data = input.ReadBytes(dataCount);
int loopStart = input.ReadInt32();
int loopLength = input.ReadInt32();
int num = input.ReadInt32();
byte[] soundData = null;
using (MemoryStream mStream = new MemoryStream(20 + header.Length + 8 + data.Length))
{
BinaryWriter writer = new BinaryWriter(mStream);
writer.Write("RIFF".ToCharArray());
writer.Write(20 + header.Length + data.Length);
writer.Write("WAVE".ToCharArray());
writer.Write("fmt ".ToCharArray());
writer.Write(header.Length);
writer.Write(header);
writer.Write("data".ToCharArray());
writer.Write(data.Length);
writer.Write(data);
soundData = mStream.ToArray();
}
return new SoundEffect(soundData, 0, soundData.Length, headerStruct.nSamplesPerSec,
(AudioChannels)headerStruct.nChannels, loopStart, loopLength);
}
}
}

View File

@ -0,0 +1,145 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{4A048A8C-C31D-4FC8-AAF3-C387B9E0309B}</ProjectGuid>
<ProjectTypeGuids>{6D335F3A-9D43-41b4-9D22-F6F17C4BE596};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AudioSample</RootNamespace>
<AssemblyName>AudioSample</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<XnaFrameworkVersion>v4.0</XnaFrameworkVersion>
<XnaPlatform>Windows</XnaPlatform>
<XnaProfile>HiDef</XnaProfile>
<XnaCrossPlatformGroupID>4b57417a-c755-4652-a34c-9beb83e18811</XnaCrossPlatformGroupID>
<XnaOutputType>Game</XnaOutputType>
<ApplicationIcon>Game.ico</ApplicationIcon>
<Thumbnail>GameThumbnail.png</Thumbnail>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\x86\Debug</OutputPath>
<DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoStdLib>true</NoStdLib>
<UseVSHostingProcess>false</UseVSHostingProcess>
<PlatformTarget>x86</PlatformTarget>
<XnaCompressContent>false</XnaCompressContent>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\x86\Release</OutputPath>
<DefineConstants>TRACE;WINDOWS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoStdLib>true</NoStdLib>
<UseVSHostingProcess>false</UseVSHostingProcess>
<PlatformTarget>x86</PlatformTarget>
<XnaCompressContent>true</XnaCompressContent>
</PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="System">
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Program.cs" />
<Compile Include="Game1.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Game.ico" />
<Content Include="GameThumbnail.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ANX.Framework\ANX.Framework.csproj">
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
<Name>ANX.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\..\InputSystems\ANX.InputDevices.Windows.XInput\ANX.InputDevices.Windows.XInput.csproj">
<Project>{60D08399-244F-46A3-91F1-4CFD26D961A3}</Project>
<Name>ANX.InputDevices.Windows.XInput</Name>
</ProjectReference>
<ProjectReference Include="..\..\InputSystems\ANX.InputSystem.Standard\ANX.InputSystem.Standard.csproj">
<Project>{49066074-3B7B-4A55-B122-6BD33AB73558}</Project>
<Name>ANX.InputSystem.Standard</Name>
</ProjectReference>
<ProjectReference Include="..\..\PlatformSystems\ANX.PlatformSystem.Windows\ANX.PlatformSystem.Windows.csproj">
<Project>{068EB2E9-963C-4E1B-8831-E25011F11FFE}</Project>
<Name>ANX.PlatformSystem.Windows</Name>
</ProjectReference>
<ProjectReference Include="..\..\RenderSystems\ANX.Framework.Windows.DX10\ANX.RenderSystem.Windows.DX10.csproj">
<Project>{5BE49183-2F6F-4527-AC90-D816911FCF90}</Project>
<Name>ANX.RenderSystem.Windows.DX10</Name>
</ProjectReference>
<ProjectReference Include="..\..\SoundSystems\ANX.SoundSystem.OpenAL\ANX.SoundSystem.OpenAL.csproj">
<Project>{14EF49AB-6D3F-458D-9D5C-D120B86EDD7A}</Project>
<Name>ANX.SoundSystem.OpenAL</Name>
</ProjectReference>
<ProjectReference Include="..\SampleContent\SampleContent.contentproj">
<Project>{FA6E229D-4504-47B1-8A23-2D3FCC13F778}</Project>
<Name>SampleContent</Name>
<XnaReferenceType>Content</XnaReferenceType>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4 Client Profile %28x86 und x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Xna.Framework.4.0">
<Visible>False</Visible>
<ProductName>Microsoft XNA Framework Redistributable 4.0</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
<!--
To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -0,0 +1,58 @@
using System;
using ANX.Framework;
using ANX.Framework.Audio;
// 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 AudioSample
{
public class Game1 : Game
{
GraphicsDeviceManager graphics;
SoundEffect sound;
float timer;
float duration;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "SampleContent";
}
protected override void Initialize()
{
base.Initialize();
}
protected override void LoadContent()
{
sound = Content.Load<SoundEffect>("Sounds\\testsound");
timer = duration = (float)sound.Duration.TotalSeconds;
}
protected override void UnloadContent()
{
}
protected override void Update(GameTime gameTime)
{
timer += (float)gameTime.ElapsedGameTime.TotalSeconds;
if (timer >= duration)
{
timer -= duration;
sound.Play();
}
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
base.Draw(gameTime);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@ -0,0 +1,20 @@
using System;
// 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 AudioSample
{
static class Program
{
static void Main(string[] args)
{
using (Game1 game = new Game1())
{
game.Run();
}
}
}
}

View File

@ -0,0 +1,34 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("AudioSample")]
[assembly: AssemblyProduct("AudioSample")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyCompany("ANX.Framework Team")]
[assembly: AssemblyCopyright("Copyright © ANX.Framework Team 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. Only Windows
// assemblies support COM.
[assembly: ComVisible(false)]
// On Windows, the following GUID is for the ID of the typelib if this
// project is exposed to COM. On other platforms, it unique identifies the
// title storage container when deploying this assembly to the device.
[assembly: Guid("674b3101-ca72-41a5-ab23-a756f2013299")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]

View File

@ -149,6 +149,16 @@
</Tags>
</Sample>
<Sample>
<Name>AudioSample</Name>
<Description>A sample playing a SoundEffect over and over again</Description>
<ExecPath>AudioSample\bin\x86\Debug\AudioSample.exe</ExecPath>
<Categorie>Rendering</Categorie>
<Tags>
<Tag>Forms</Tag>
</Tags>
</Sample>

View File

@ -127,6 +127,13 @@
<ProcessorParameters_OutputFormat>DX10_HLSL</ProcessorParameters_OutputFormat>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Sounds\testsound.wav">
<Name>testsound</Name>
<Importer>WavImporter</Importer>
<Processor>SoundEffectProcessor</Processor>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

Binary file not shown.

View File

@ -4,6 +4,7 @@ using System.IO;
using ANX.Framework.Audio;
using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.SoundSystem;
using OpenTK;
using OpenTK.Audio.OpenAL;
// This file is part of the ANX.Framework created by the
@ -46,11 +47,12 @@ namespace ANX.SoundSystem.OpenAL
{
get
{
throw new NotImplementedException();
return 1f;
//throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
//throw new NotImplementedException();
}
}
@ -70,11 +72,12 @@ namespace ANX.SoundSystem.OpenAL
{
get
{
throw new NotImplementedException();
return 1f;
//throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
//throw new NotImplementedException();
}
}
@ -91,6 +94,28 @@ namespace ANX.SoundSystem.OpenAL
}
#endregion
public Creator()
{
Init();
}
private void Init()
{
IntPtr deviceHandle;
ContextHandle context = Alc.GetCurrentContext();
if (context.Handle != IntPtr.Zero)
{
deviceHandle = Alc.GetContextsDevice(context);
}
else
{
deviceHandle = Alc.OpenDevice(Alc.GetString(IntPtr.Zero, AlcGetString.DefaultDeviceSpecifier));
context = Alc.CreateContext(deviceHandle, new int[0]);
}
bool isNowCurrent = Alc.MakeContextCurrent(context);
}
#region CreateSoundEffectInstance
public ISoundEffectInstance CreateSoundEffectInstance(ISoundEffect nativeSoundEffect)
{
@ -107,12 +132,12 @@ namespace ANX.SoundSystem.OpenAL
}
#endregion
#region CreateSoundEffect (TODO)
#region CreateSoundEffect
public ISoundEffect CreateSoundEffect(SoundEffect parent, byte[] buffer, int offset, int count, int sampleRate,
AudioChannels channels, int loopStart, int loopLength)
{
PreventSystemChange();
throw new NotImplementedException();
return new OpenALSoundEffect(parent, buffer, offset, count, sampleRate, channels, loopStart, loopLength);
}
#endregion

View File

@ -45,6 +45,29 @@ namespace ANX.SoundSystem.OpenAL
bufferHandle = AL.GenBuffer();
AL.BufferData(bufferHandle, waveInfo.OpenALFormat, waveInfo.Data, waveInfo.Data.Length, waveInfo.SampleRate);
}
internal OpenALSoundEffect(SoundEffect setParent, byte[] buffer, int offset, int count, int sampleRate,
AudioChannels channels, int loopStart, int loopLength)
{
parent = setParent;
MemoryStream stream = new MemoryStream();
BinaryWriter writer = new BinaryWriter(stream);
writer.Write(buffer, offset, count);
stream.Position = 0;
waveInfo = WaveFile.LoadData(stream);
float sizeMulBlockAlign = waveInfo.Data.Length / ((int)waveInfo.Channels * 2);
duration = TimeSpan.FromMilliseconds((double)(sizeMulBlockAlign * 1000f / (float)waveInfo.SampleRate));
bufferHandle = AL.GenBuffer();
AL.BufferData(bufferHandle, waveInfo.OpenALFormat, waveInfo.Data, waveInfo.Data.Length, waveInfo.SampleRate);
ALError error = AL.GetError();
if (error != ALError.NoError)
throw new Exception("OpenAL error " + error + ": " + AL.GetErrorString(error));
}
#endregion
#region Dispose

View File

@ -36,11 +36,12 @@ namespace ANX.SoundSystem.OpenAL
{
get
{
throw new NotImplementedException();
return 0f;
//throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
//throw new NotImplementedException();
}
}
@ -92,6 +93,10 @@ namespace ANX.SoundSystem.OpenAL
Pitch = 1f;
Volume = 1f;
// TODO: Pan = 0f;
ALError error = AL.GetError();
if (error != ALError.NoError)
throw new Exception("OpenAL error " + error + ": " + AL.GetErrorString(error));
}
#endregion

BIN
media/testsound.wav Normal file

Binary file not shown.