Skip to content

Commit 005c055

Browse files
author
Sam Byass
committed
Initial commit
0 parents  commit 005c055

26 files changed

+1108
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
7+
<IsPackable>false</IsPackable>
8+
9+
<Configurations>Release;Debug</Configurations>
10+
11+
<Platforms>AnyCPU;x64</Platforms>
12+
</PropertyGroup>
13+
14+
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
15+
<PlatformTarget>x86</PlatformTarget>
16+
</PropertyGroup>
17+
18+
<ItemGroup>
19+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
20+
<PackageReference Include="xunit" Version="2.4.1" />
21+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
22+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
23+
<PrivateAssets>all</PrivateAssets>
24+
</PackageReference>
25+
<PackageReference Include="coverlet.collector" Version="3.0.2">
26+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
27+
<PrivateAssets>all</PrivateAssets>
28+
</PackageReference>
29+
</ItemGroup>
30+
31+
<ItemGroup>
32+
<ProjectReference Include="..\Fmod5Sharp\Fmod5Sharp.csproj" />
33+
</ItemGroup>
34+
35+
<ItemGroup>
36+
<None Remove="TestResources\short_vorbis.fsb" />
37+
<EmbeddedResource Include="TestResources\short_vorbis.fsb" />
38+
</ItemGroup>
39+
40+
</Project>

Fmod5Sharp.Tests/Fmod5SharpTests.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System;
2+
using System.IO;
3+
using System.Reflection;
4+
using Fmod5Sharp.FmodVorbis;
5+
using Xunit;
6+
7+
namespace Fmod5Sharp.Tests
8+
{
9+
10+
public class Fmod5SharpTests
11+
{
12+
private static byte[] LoadResource(string filename)
13+
{
14+
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream($"Fmod5Sharp.Tests.TestResources.{filename}") ?? throw new Exception($"File {filename} not found.");
15+
using BinaryReader reader = new BinaryReader(stream);
16+
17+
return reader.ReadBytes((int)stream.Length);
18+
}
19+
20+
[Fact]
21+
public void SoundBanksCanBeLoaded()
22+
{
23+
var rawData = LoadResource("short_vorbis.fsb");
24+
25+
var samples = FsbLoader.LoadFsbFromByteArray(rawData).Samples;
26+
27+
Assert.Single(samples, s => !s.Metadata.IsStereo && s.SampleBytes.Length > 0);
28+
}
29+
30+
[Fact]
31+
public void VorbisAudioCanBeRestoredWithoutExceptions()
32+
{
33+
var rawData = LoadResource("short_vorbis.fsb");
34+
35+
var samples = FsbLoader.LoadFsbFromByteArray(rawData).Samples;
36+
37+
var sample = samples[0];
38+
39+
var oggBytes = FmodVorbisRebuilder.RebuildOggFile(sample);
40+
41+
Assert.NotEmpty(oggBytes);
42+
43+
//Cannot assert on length output bytes because it changes with the version of libvorbis you use.
44+
}
45+
}
46+
}
5.59 KB
Binary file not shown.

Fmod5Sharp.sln

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fmod5Sharp", "Fmod5Sharp\Fmod5Sharp.csproj", "{6D7552B5-7A84-4F8D-9714-11C43E080234}"
4+
EndProject
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fmod5Sharp.Tests", "Fmod5Sharp.Tests\Fmod5Sharp.Tests.csproj", "{28048C08-DAC2-4DC2-82EB-C2CF5C9DC772}"
6+
EndProject
7+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeaderGenerator", "HeaderGenerator\HeaderGenerator.csproj", "{433DFB57-A200-4238-B3EE-B4C5FB378E83}"
8+
EndProject
9+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{05ED0354-9E7F-43BA-8F4C-0E05FBBB86F4}"
10+
ProjectSection(SolutionItems) = preProject
11+
README.md = README.md
12+
EndProjectSection
13+
EndProject
14+
Global
15+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
16+
Release|Any CPU = Release|Any CPU
17+
Debug|x64 = Debug|x64
18+
EndGlobalSection
19+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
20+
{6D7552B5-7A84-4F8D-9714-11C43E080234}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{6D7552B5-7A84-4F8D-9714-11C43E080234}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{6D7552B5-7A84-4F8D-9714-11C43E080234}.Debug|x64.ActiveCfg = Release|Any CPU
23+
{6D7552B5-7A84-4F8D-9714-11C43E080234}.Debug|x64.Build.0 = Release|Any CPU
24+
{28048C08-DAC2-4DC2-82EB-C2CF5C9DC772}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{28048C08-DAC2-4DC2-82EB-C2CF5C9DC772}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{28048C08-DAC2-4DC2-82EB-C2CF5C9DC772}.Debug|x64.ActiveCfg = Debug|x64
27+
{28048C08-DAC2-4DC2-82EB-C2CF5C9DC772}.Debug|x64.Build.0 = Debug|x64
28+
{433DFB57-A200-4238-B3EE-B4C5FB378E83}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{433DFB57-A200-4238-B3EE-B4C5FB378E83}.Release|Any CPU.Build.0 = Release|Any CPU
30+
{433DFB57-A200-4238-B3EE-B4C5FB378E83}.Debug|x64.ActiveCfg = Debug|Any CPU
31+
{433DFB57-A200-4238-B3EE-B4C5FB378E83}.Debug|x64.Build.0 = Debug|Any CPU
32+
EndGlobalSection
33+
EndGlobal
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.IO;
2+
3+
namespace Fmod5Sharp.ChunkData
4+
{
5+
internal class ChannelChunkData : IChunkData
6+
{
7+
public byte NumChannels;
8+
9+
public void Read(BinaryReader reader, uint expectedSize)
10+
{
11+
NumChannels = reader.ReadByte();
12+
}
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.IO;
2+
3+
namespace Fmod5Sharp.ChunkData
4+
{
5+
internal class FrequencyChunkData : IChunkData
6+
{
7+
public uint ActualFrequencyId;
8+
9+
public void Read(BinaryReader reader, uint expectedSize)
10+
{
11+
ActualFrequencyId = reader.ReadUInt32();
12+
}
13+
}
14+
}

Fmod5Sharp/ChunkData/IChunkData.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System.IO;
2+
3+
namespace Fmod5Sharp.ChunkData
4+
{
5+
internal interface IChunkData
6+
{
7+
public void Read(BinaryReader reader, uint expectedSize);
8+
}
9+
}

Fmod5Sharp/ChunkData/LoopChunkData.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.IO;
2+
3+
namespace Fmod5Sharp.ChunkData
4+
{
5+
internal class LoopChunkData : IChunkData
6+
{
7+
public uint LoopStart;
8+
public uint LoopEnd;
9+
10+
public void Read(BinaryReader reader, uint expectedSize)
11+
{
12+
LoopStart = reader.ReadUInt32();
13+
LoopEnd = reader.ReadUInt32();
14+
}
15+
}
16+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.IO;
2+
3+
namespace Fmod5Sharp.ChunkData
4+
{
5+
internal class UnknownChunkData : IChunkData
6+
{
7+
public byte[] UnknownData;
8+
9+
public void Read(BinaryReader reader, uint expectedSize)
10+
{
11+
UnknownData = reader.ReadBytes((int)expectedSize);
12+
}
13+
}
14+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.IO;
2+
3+
namespace Fmod5Sharp.ChunkData
4+
{
5+
internal class VorbisChunkData : IChunkData
6+
{
7+
public uint Crc32;
8+
9+
public void Read(BinaryReader reader, uint expectedSize)
10+
{
11+
Crc32 = reader.ReadUInt32();
12+
byte[] unknown = reader.ReadBytes((int)(expectedSize - 4));
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)