Skip to content

Commit 4a04a48

Browse files
author
Sam Byass
committed
Update docs, bump to 1.1.0
1 parent acba2bc commit 4a04a48

5 files changed

Lines changed: 39 additions & 9 deletions

File tree

Fmod5Sharp/ChunkData/UnknownChunkData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace Fmod5Sharp.ChunkData
44
{
55
internal class UnknownChunkData : IChunkData
66
{
7-
public byte[] UnknownData;
7+
public byte[] UnknownData = new byte[0];
88

99
public void Read(BinaryReader reader, uint expectedSize)
1010
{

Fmod5Sharp/Fmod5Sharp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
77
<Configurations>Release;Debug</Configurations>
88
<Platforms>x86;x64;AnyCPU</Platforms>
9-
<Version>1.0.1</Version>
9+
<Version>1.1.0</Version>
1010
<PackageId>Fmod5Sharp</PackageId>
1111
<RepositoryType>git</RepositoryType>
1212
<RepositoryUrl>https://github.com/SamboyCoding/Fmod5Sharp.git</RepositoryUrl>

Fmod5Sharp/FmodGcadPcmRebuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private static short[] GetPcmData(FmodSample sample)
3939
{
4040
//Each byte is a scale and a predictor
4141
var combined = adpcm[inIndex++];
42-
var scale = (1 << (combined & 0xF));
42+
var scale = 1 << (combined & 0xF);
4343
var predictor = combined >> 4;
4444

4545
//Coefficients are based on the predictor value
@@ -55,7 +55,7 @@ private static short[] GetPcmData(FmodSample sample)
5555
var adpcmSample = (int) (s % 2 == 0 ? GetHighNibbleSigned(adpcm[inIndex]) : GetLowNibbleSigned(adpcm[inIndex++]));
5656

5757
//Adaptive processing
58-
adpcmSample = ((adpcmSample * scale) << 11);
58+
adpcmSample = (adpcmSample * scale) << 11;
5959
adpcmSample = (adpcmSample + 1024 + coeff1 * hist1 + coeff2 * hist2) >> 11;
6060
var clampedSample = Clamp16(adpcmSample);
6161

Fmod5Sharp/FmodSampleChunk.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ internal class FmodSampleChunk : IBinaryReadable
1111
public FmodSampleChunkType ChunkType;
1212
public uint ChunkSize;
1313
public bool MoreChunks;
14+
#pragma warning disable 8618 //Non-nullable value is not defined.
1415
internal IChunkData ChunkData;
16+
#pragma warning restore 8618
1517

1618
void IBinaryReadable.Read(BinaryReader reader)
1719
{

README.md

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![NuGet](https://img.shields.io/nuget/v/Fmod5Sharp?)](https://www.nuget.org/packages/Fmod5Sharp/)
55

66
This library allows you to read FMOD 5 sound bank files (they start with the characters FSB5) into their contained samples,
7-
and then export those samples to ogg files (assuming the contained data is vorbis-encoded).
7+
and then export those samples to standard file formats (assuming the contained data format is supported).
88

99
Support for more encodings can be added as requested.
1010

@@ -38,11 +38,39 @@ uint numChannels = samples[0].Channels; //2 for stereo, 1 for mono.
3838
```
3939

4040
And, you can convert the audio data back to a standard format.
41-
For example if `bank.Header.AudioType == FmodAudioType.VORBIS`:
4241
```c#
43-
var oggFileBytes = FmodVorbisRebuilder.RebuildOggFile(samples[0]);
44-
//Now you can save oggFileBytes to an .ogg file on your disk and play it using your favourite audio player.
42+
var success = samples[0].RebuildAsStandardFileFormat(out var dataBytes, out var fileExtension);
43+
//Assuming success == true, then this file format was supported and you should have some data and an extension (without the leading .).
44+
//Now you can save dataBytes to an file with the given extension on your disk and play it using your favourite audio player.
4545
//Or you can use any standard library to convert the byte array to a different format, if you so desire.
4646
```
4747

48-
If the user's system does not have libopus or libvorbis, this will throw a `DllNotFoundException`.
48+
If the user's system does not have libopus or libvorbis, and the data is vorbis-encoded, this will throw a `DllNotFoundException`.
49+
50+
You can also check if a given format type is supported and, if so, what extension it will result in, like so:
51+
```c#
52+
bool isSupported = bank.Header.AudioType.IsSupported();
53+
54+
//Null if not supported
55+
string? extension = bank.Header.AudioType.FileExtension();
56+
```
57+
58+
Alternatively, you can consult the table below:
59+
60+
| Format | Supported? | Extension | Notes |
61+
| :-----: | :--------------: | :---------: | :----------: |
62+
| PCM8 | ✔️ | wav | |
63+
| PCM16 | ✔️ | wav | |
64+
| PCM24 || | |
65+
| PCM32 | ✔️ | wav | |
66+
| PCMFLOAT || | |
67+
| GCADPCM | ✔️ | wav | Tested with single-channel files. Not tested with stereo, but should work in theory. |
68+
| IMAADPCM || | |
69+
| VAG || | |
70+
| HEVAG || | |
71+
| XMA || | |
72+
| MPEG || | |
73+
| CELT || | |
74+
| AT9 || | |
75+
| XWMA || | |
76+
| VORBIS | ✔️ | ogg | Requires native libraries on user's system. |

0 commit comments

Comments
 (0)