-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetStringPaths.cs
More file actions
45 lines (39 loc) · 1.58 KB
/
GetStringPaths.cs
File metadata and controls
45 lines (39 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using FMOD.Studio;
using System.Runtime.InteropServices;
namespace FSB5BankParser
{
public partial class MainForm
{
public void GetStringPaths(string BankFile)
{
// create the FMOD Studio system
FMOD.Studio.System.create(out FMOD.Studio.System FMODAPISystem);
FMODAPISystem.initialize(512, INITFLAGS.NORMAL, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);
FMODAPISystem.loadBankFile(BankFile, LOAD_BANK_FLAGS.NORMAL, out Bank FMODBank);
if (FMODBank.getStringCount(out int count) == FMOD.RESULT.OK)
{
for (var i = 0; i < count; i++)
{
if (FMODBank.getStringInfo(i, out FMOD.GUID FMODGUID, out string Path) == FMOD.RESULT.OK)
{
Guid GUID = ConvertFMODGuid(FMODGUID); // clean GUID, cuz FMOD API's wierd
// Save GUID and its corresponding path
FMODSystem.PathGUIDs.Add(new()
{
GUID = GUID,
Path = Path
});
}
}
}
// Clean up the FMOD Studio system
FMODBank.unload();
FMODAPISystem.unloadAll();
FMODAPISystem.release();
return;
// FMOD.GUID to System.Guid Convertor
static Guid ConvertFMODGuid(FMOD.GUID FMODGuid)
=> MemoryMarshal.Read<Guid>(MemoryMarshal.AsBytes(MemoryMarshal.CreateReadOnlySpan(ref FMODGuid, 1)));
}
}
}