diff --git a/FModBankParser/FModBankParser.cs b/FModBankParser/FModBankParser.cs index c061c70..29cbfb2 100644 --- a/FModBankParser/FModBankParser.cs +++ b/FModBankParser/FModBankParser.cs @@ -1,13 +1,7 @@ using Fmod5Sharp.FmodTypes; -using FModBankParser; using FModBankParser.Extensions; using FModBankParser.Objects; -using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FModBankParser; @@ -121,9 +115,13 @@ public static AudioExportResult ExportAudio(FModReader reader, DirectoryInfo out { var sample = bank.Samples[i]; - string sampleName = string.IsNullOrWhiteSpace(sample.Name) - ? $"Sample_{i}" - : sample.Name; + var sampleName = sample.Name; + if (string.IsNullOrWhiteSpace(sampleName)) + { + sampleName = reader.SoundTable?.TryGetKeyByIndex(i, out var key) == true + ? $"Sample_{i}_hash_{key:X16}" + : $"Sample_{i}"; + } if (!sample.RebuildAsStandardFileFormat(out var dataBytes, out var fileExtension) || dataBytes is not { Length: > 0 }) { diff --git a/FModBankParser/Metadata/SoundTable.cs b/FModBankParser/Metadata/SoundTable.cs index 7189e6b..18c0252 100644 --- a/FModBankParser/Metadata/SoundTable.cs +++ b/FModBankParser/Metadata/SoundTable.cs @@ -1,9 +1,4 @@ using FModBankParser.Objects; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FModBankParser.Metadata; @@ -58,6 +53,21 @@ public int Find(ulong key) return -1; } + public bool TryGetKeyByIndex(int index, out ulong key) + { + for (var i = 0; i < Indices.Length; i++) + { + if (Indices[i].Value != index) + continue; + + key = Keys[i]; + return true; + } + + key = default; + return false; + } + #region Readers private static ulong[] ReadSimpleArrayImp(BinaryReader Ar) {