add FNA dependency
parent
b6bf39e3c9
commit
dbfcd15ca2
|
@ -0,0 +1,3 @@
|
|||
bin
|
||||
obj
|
||||
.vs
|
|
@ -0,0 +1,12 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FNA\FNA.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,12 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FNA\FNA.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -1,8 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace MoonWorks.Audio
|
||||
namespace FineAudio
|
||||
{
|
||||
public class AudioDevice : IDisposable
|
||||
{
|
||||
|
@ -34,7 +35,7 @@ namespace MoonWorks.Audio
|
|||
|
||||
if (devices == 0)
|
||||
{
|
||||
Logger.LogError("No audio devices found!");
|
||||
FNALoggerEXT.LogError("No audio devices found!");
|
||||
Handle = IntPtr.Zero;
|
||||
FAudio.FAudio_Release(Handle);
|
||||
return;
|
||||
|
@ -81,7 +82,7 @@ namespace MoonWorks.Audio
|
|||
IntPtr.Zero
|
||||
) != 0)
|
||||
{
|
||||
Logger.LogError("No mastering voice found!");
|
||||
FNALoggerEXT.LogError("No mastering voice found!");
|
||||
Handle = IntPtr.Zero;
|
||||
FAudio.FAudio_Release(Handle);
|
||||
return;
|
|
@ -1,8 +1,8 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using MoonWorks.Math;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace MoonWorks.Audio
|
||||
namespace FineAudio
|
||||
{
|
||||
public class AudioEmitter : AudioResource
|
||||
{
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using MoonWorks.Math;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace MoonWorks.Audio
|
||||
namespace FineAudio
|
||||
{
|
||||
public class AudioListener : AudioResource
|
||||
{
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
|
||||
namespace MoonWorks.Audio
|
||||
namespace FineAudio
|
||||
{
|
||||
public abstract class AudioResource : IDisposable
|
||||
{
|
|
@ -1,8 +1,8 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using MoonWorks.Math;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace MoonWorks.Audio
|
||||
namespace FineAudio
|
||||
{
|
||||
public abstract class SoundInstance : AudioResource
|
||||
{
|
||||
|
@ -195,7 +195,7 @@ namespace MoonWorks.Audio
|
|||
|
||||
if (Handle == IntPtr.Zero)
|
||||
{
|
||||
Logger.LogError("SoundInstance failed to initialize!");
|
||||
FNALoggerEXT.LogError("SoundInstance failed to initialize!");
|
||||
return;
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
namespace MoonWorks.Audio
|
||||
namespace FineAudio
|
||||
{
|
||||
public enum SoundState
|
||||
{
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace MoonWorks.Audio
|
||||
namespace FineAudio
|
||||
{
|
||||
public class StaticSound : AudioResource
|
||||
{
|
||||
|
@ -19,37 +19,6 @@ namespace MoonWorks.Audio
|
|||
|
||||
private Stack<StaticSoundInstance> Instances = new Stack<StaticSoundInstance>();
|
||||
|
||||
public static StaticSound LoadOgg(AudioDevice device, string filePath)
|
||||
{
|
||||
var filePointer = FAudio.stb_vorbis_open_filename(filePath, out var error, IntPtr.Zero);
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
throw new AudioLoadException("Error loading file!");
|
||||
}
|
||||
var info = FAudio.stb_vorbis_get_info(filePointer);
|
||||
var bufferSize = FAudio.stb_vorbis_stream_length_in_samples(filePointer) * info.channels;
|
||||
var buffer = new float[bufferSize];
|
||||
|
||||
FAudio.stb_vorbis_get_samples_float_interleaved(
|
||||
filePointer,
|
||||
info.channels,
|
||||
buffer,
|
||||
(int) bufferSize
|
||||
);
|
||||
|
||||
FAudio.stb_vorbis_close(filePointer);
|
||||
|
||||
return new StaticSound(
|
||||
device,
|
||||
(ushort) info.channels,
|
||||
info.sample_rate,
|
||||
buffer,
|
||||
0,
|
||||
(uint) buffer.Length
|
||||
);
|
||||
}
|
||||
|
||||
// mostly borrowed from https://github.com/FNA-XNA/FNA/blob/b71b4a35ae59970ff0070dea6f8620856d8d4fec/src/Audio/SoundEffect.cs#L385
|
||||
public static StaticSound LoadWav(AudioDevice device, string filePath)
|
||||
{
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
|
||||
namespace MoonWorks.Audio
|
||||
namespace FineAudio
|
||||
{
|
||||
public class StaticSoundInstance : SoundInstance
|
||||
{
|
|
@ -2,7 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace MoonWorks.Audio
|
||||
namespace FineAudio
|
||||
{
|
||||
/// <summary>
|
||||
/// For streaming long playback.
|
|
@ -1,8 +1,9 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace MoonWorks.Audio
|
||||
namespace FineAudio
|
||||
{
|
||||
public class StreamingSoundOgg : StreamingSound
|
||||
{
|
||||
|
@ -26,9 +27,9 @@ namespace MoonWorks.Audio
|
|||
if (error != 0)
|
||||
{
|
||||
((GCHandle) fileDataPtr).Free();
|
||||
Logger.LogError("Error opening OGG file!");
|
||||
Logger.LogError("Error: " + error);
|
||||
throw new AudioLoadException("Error opening OGG file!");
|
||||
FNALoggerEXT.LogError("Error opening OGG file!");
|
||||
FNALoggerEXT.LogError("Error: " + error);
|
||||
throw new System.ArgumentException("OGG file not valid!");
|
||||
}
|
||||
var info = FAudio.stb_vorbis_get_info(vorbisHandle);
|
||||
|
Loading…
Reference in New Issue