Skip to content
Merged
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
16 changes: 7 additions & 9 deletions FModBankParser/FModBankParser.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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 })
{
Expand Down
20 changes: 15 additions & 5 deletions FModBankParser/Metadata/SoundTable.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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)
{
Expand Down