Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Fmod5Sharp/CodecRebuilders/FmodVorbisRebuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private static void ReadSamplePackets(BinaryReader inputReader, out List<int> pa
{
var packetSize = inputReader.ReadUInt16();

if (packetSize == 0)
if (packetSize == 0 || packetSize == 0xFFFF)
break; //EOS

packetLengths.Add(packetSize);
Expand Down
17 changes: 12 additions & 5 deletions Fmod5Sharp/FmodTypes/FmodSampleMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

namespace Fmod5Sharp.FmodTypes
{
public class FmodSampleMetadata : IBinaryReadable
//Can be verified against "FMOD::CodecFSB5::decodeSubSoundHeader" in fmod.dll
public class FmodSampleMetadata : IBinaryReadable
{
internal bool HasAnyChunks;
internal uint FrequencyId;
Expand All @@ -24,10 +25,16 @@ void IBinaryReadable.Read(BinaryReader reader)

HasAnyChunks = (encoded & 1) == 1; //Bit 0
FrequencyId = (uint) encoded.Bits( 1, 4); //Bits 1-4
var pow2 = (int) encoded.Bits(5, 2); //Bits 5-6
NumChannels = 1 << pow2;
if (NumChannels > 2)
throw new("> 2 channels not supported");

int channelBits = (int)encoded.Bits(5, 2); //Bits 5-6
NumChannels = channelBits switch
{
0 => 1,
1 => 2,
2 => 6,
3 => 8,
_ => 0
};

IsStereo = NumChannels == 2;

Expand Down
5 changes: 3 additions & 2 deletions Fmod5Sharp/FsbLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ public static class FsbLoader
{
internal static readonly Dictionary<uint, int> Frequencies = new()
{
{ 1, 8000 },
{ 0, 4_000 },
{ 1, 8_000 },
{ 2, 11_000 },
{ 3, 11_025 },
{ 3, 12_000 },
{ 4, 16_000 },
{ 5, 22_050 },
{ 6, 24_000 },
Expand Down