|
4 | 4 | [](https://www.nuget.org/packages/Fmod5Sharp/) |
5 | 5 |
|
6 | 6 | 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). |
8 | 8 |
|
9 | 9 | Support for more encodings can be added as requested. |
10 | 10 |
|
@@ -38,11 +38,39 @@ uint numChannels = samples[0].Channels; //2 for stereo, 1 for mono. |
38 | 38 | ``` |
39 | 39 |
|
40 | 40 | And, you can convert the audio data back to a standard format. |
41 | | -For example if `bank.Header.AudioType == FmodAudioType.VORBIS`: |
42 | 41 | ```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. |
45 | 45 | //Or you can use any standard library to convert the byte array to a different format, if you so desire. |
46 | 46 | ``` |
47 | 47 |
|
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