Code Monkey home page Code Monkey logo

Comments (9)

cnSchwarzer avatar cnSchwarzer commented on June 18, 2024

I changed the code

if (exportEntry.ClassName == "SoundNodeWave")
{
CurrentLoadedExport = exportEntry;
ExportInformationList.Add($"#{exportEntry.UIndex} {exportEntry.ClassName} : {exportEntry.ObjectName.Instanced}");
var soundNodeWave = exportEntry.GetBinaryData<SoundNodeWave>();
if (soundNodeWave.RawData.Length > 0)
{
ISACTBankPair ibp = ISACTHelper.GetPairedBanks(soundNodeWave.RawData);
foreach (var isbC in ibp.ISBBank.GetAllBankChunks().Where(x => x.ChunkName == "data"))
{
var objectParent = isbC.GetParent();
if (objectParent != null)
{
ExportInformationList.Add(objectParent);
}
}
}
else
{
var bsd = exportEntry.GetProperty<ObjectProperty>("BioStreamingData");
if (bsd == null)
{
ExportInformationList.Add("This export contains no embedded audio");
return;
}
// Imports are very unreliable here and will be slow to load
if (bsd.ResolveToEntry(exportEntry.FileRef) is ExportEntry streamingData)
{
// Remove the ISB: prefix
var indexEntryName = exportEntry.ObjectName.Instanced.Substring(exportEntry.ObjectName.Instanced.IndexOf(":") + 1);
ISACTBankPair ibp = ISACTHelper.GetPairedBanks(streamingData.GetBinaryData().Skip(4).ToArray());
IndexEntry foundICBInfo = null;
if (ibp.ICBBank.GetAllBankChunks().FirstOrDefault(x => x.ChunkName == ContentIndexBankChunk.FixedChunkTitle) is ContentIndexBankChunk contentIndex)
{
// Find info about sample in ICB so we can get entry in ISB
foreach (var p in contentIndex.IndexPages)
{
if (foundICBInfo != null)
break;
foreach (var indexEntry in p.IndexEntries)
{
if (indexEntry.Title == indexEntryName)
{
foundICBInfo = indexEntry;
break;
}
}
}
if (foundICBInfo == null)
{
ExportInformationList.Add("Could not find information about this sound in the streaming data ICB");
return;
}
}
ISACTListBankChunk referencedSampChunk = null;
var sampChunks = ibp.ISBBank.GetAllBankChunks().OfType<ISACTListBankChunk>().Where(x => x.ObjectType == "samp").ToList();
foreach (var sampChunk in sampChunks)
{
var indexChunk = sampChunk.SubChunks.Find(x => x is IntBankChunk intC && intC.ChunkName == "indx") as IntBankChunk;
if (indexChunk == null)
{
continue; // This shouldn't happen
}
if (indexChunk.Value == foundICBInfo.ObjectIndex)
{
// found!
referencedSampChunk = sampChunk;
break;
}
}
if (referencedSampChunk == null)
{
ExportInformationList.Add($"Could not find samp resource index {foundICBInfo.ObjectIndex} in streaming ISB referenced by ICB");
return;
}
if (referencedSampChunk.SampleOffset != null)
{
ExportInformationList.Add(referencedSampChunk);
ExportInfoListBox.SelectedItem = referencedSampChunk; // Select it so playback is easier to start
}
else
{
ExportInformationList.Add("The ISB data for this entry does not list an external ISB offset for some reason");
}
}
else
{
ExportInformationList.Add("Audio data can only load in the toolset if the streaming data is an export");
}
}
}

to the following, and now can correcly reference the audio in LE1 now. Please check!

if (exportEntry.ClassName == "SoundNodeWave") {
    CurrentLoadedExport = exportEntry;

    ExportInformationList.Add($"#{exportEntry.UIndex} {exportEntry.ClassName} : {exportEntry.ObjectName.Instanced}");
    var soundNodeWave = exportEntry.GetBinaryData<SoundNodeWave>();
    if (soundNodeWave.RawData.Length > 0) {
        ISACTBankPair ibp = ISACTHelper.GetPairedBanks(soundNodeWave.RawData);
        foreach (var isbC in ibp.ISBBank.GetAllBankChunks().Where(x => x.ChunkName == "data")) {
            var objectParent = isbC.GetParent();
            if (objectParent != null) {
                ExportInformationList.Add(objectParent);
            }
        }
    } else {
        var bsd = exportEntry.GetProperty<ObjectProperty>("BioStreamingData");
        if (bsd == null) {
            ExportInformationList.Add("This export contains no embedded audio");
            return;
        }

        // Imports are very unreliable here and will be slow to load
        if (bsd.ResolveToEntry(exportEntry.FileRef) is ExportEntry streamingData) {
            // Remove the ISB: prefix
            var indexEntryName = exportEntry.ObjectName.Instanced.Substring(exportEntry.ObjectName.Instanced.IndexOf(":") + 1);
            ISACTBankPair ibp = ISACTHelper.GetPairedBanks(streamingData.GetBinaryData().Skip(4).ToArray());
            IndexEntry foundICBInfo = null;
            if (ibp.ICBBank.GetAllBankChunks().FirstOrDefault(x => x.ChunkName == ContentIndexBankChunk.FixedChunkTitle) is ContentIndexBankChunk contentIndex) {
                // Find info about sample in ICB so we can get entry in ISB
                foreach (var p in contentIndex.IndexPages) {
                    if (foundICBInfo != null)
                        break;
                    foreach (var indexEntry in p.IndexEntries) {
                        if (indexEntry.Title == indexEntryName) {
                            foundICBInfo = indexEntry;
                            break;
                        }
                    }
                }
            }

            if (foundICBInfo == null) {
                ExportInformationList.Add("Could not find information about this sound in the streaming data ICB");
                return;
            }

            var referencedSndeChunk = ibp.ICBBank.GetAllBankChunks().OfType<ISACTListBankChunk>().FirstOrDefault(x =>
                x.GetAllSubChunks().Any(a => a is IntBankChunk { ChunkName: "indx" } ac && ac.Value == foundICBInfo.ObjectIndex));
            if (referencedSndeChunk == null) {
                ExportInformationList.Add("Could not find snde chunk about this sound in the streaming data ICB");
                return;
            }

            var soundTracks = referencedSndeChunk.GetAllSubChunks().OfType<SoundEventSoundTracksFour>().FirstOrDefault();
            if (soundTracks == null) {
                ExportInformationList.Add("Could not find sound track about this sound in the streaming data ICB");
                return;
            }

            foreach (var soundTrack in soundTracks.SoundTracks) {
                var isbIndex = soundTrack.BufferIndex & 0xFFFF;
                var sampChunk = ibp.ISBBank.GetAllBankChunks().OfType<ISACTListBankChunk>().FirstOrDefault(x =>
                    x.ObjectType == "samp" && x.GetAllSubChunks().Any(a => a is IntBankChunk { ChunkName: "indx" } ac && ac.Value == isbIndex));
                if (sampChunk == null) {
                    ExportInformationList.Add($"Could not find samp resource index {isbIndex} in streaming ISB referenced by ICB");
                    continue;
                }

                if (sampChunk.SampleOffset != null) {
                    ExportInformationList.Add(sampChunk);
                    ExportInfoListBox.SelectedItem = sampChunk; // Select it so playback is easier to start
                } else {
                    ExportInformationList.Add("The ISB data for this entry does not list an external ISB offset for some reason");
                }
            }
        } else {
            ExportInformationList.Add("Audio data can only load in the toolset if the streaming data is an export");
        }
    }
}

from legendaryexplorer.

cnSchwarzer avatar cnSchwarzer commented on June 18, 2024

And in

foreach (var filePath in files) //handle cases of mods/dlc having same file.
{
bool isBaseFile = cdir.ToLower() == "biogame";
bool isDLCFile = filePath.ToLower().Contains("dlc");
if (isBaseFile == isDLCFile)
{
continue;
}
audioPcc = MEPackageHandler.OpenMEPackage(filePath);
var stream = audioPcc.Exports.FirstOrDefault(x => x.ClassName == "WwiseStream" && x.ObjectNameString.ToLower().Contains(searchWav));
if (stream != null)
{
SoundpanelWPF_ADB.LoadExport(stream);
break;
}
audioPcc.Dispose();
}

Changes to

foreach (var filePath in files)  //handle cases of mods/dlc having same file.
{
    bool isBaseFile = cdir.ToLower() == "biogame";
    bool isDLCFile = filePath.ToLower().Contains("dlc");
    if (isBaseFile == isDLCFile)
    {
        continue;
    }
    audioPcc = MEPackageHandler.OpenMEPackage(filePath);
    if (currentGame.IsGame1()) {
        var stream = audioPcc.Exports.FirstOrDefault(x => x.ClassName == "SoundNodeWave" && x.InstancedFullPath.ToLower().EndsWith(searchWav));
        if (stream != null) {
            SoundpanelWPF_ADB.LoadExport(stream);
            break;
        }
        audioPcc.Dispose();
    } else {
        var stream = audioPcc.Exports.FirstOrDefault(x => x.ClassName == "WwiseStream" && x.ObjectNameString.ToLower().Contains(searchWav));
        if (stream != null) {
            SoundpanelWPF_ADB.LoadExport(stream);
            break;
        }
        audioPcc.Dispose();
    }
}

from legendaryexplorer.

Mgamerz avatar Mgamerz commented on June 18, 2024

Hi, I'll dig through my notes and see what I have for this. I know the lookup code was jank - it worked on some but not on all, but then I got busy working on other things.

from legendaryexplorer.

cnSchwarzer avatar cnSchwarzer commented on June 18, 2024

Hi, I'll dig through my notes and see what I have for this. I know the lookup code was jank - it worked on some but not on all, but then I got busy working on other things.

Thanks, I just run through all lines in LE1 and these code matches all texts & voices nicely.

Currently I'm not able to create a PR, so I'll just leave it to you ~

from legendaryexplorer.

Mgamerz avatar Mgamerz commented on June 18, 2024

If you want to make a pull request for this, I can merge it for you.

from legendaryexplorer.

cnSchwarzer avatar cnSchwarzer commented on June 18, 2024

I created the PR #395

from legendaryexplorer.

Mgamerz avatar Mgamerz commented on June 18, 2024

Looking at my notes, I have notes that this the buffer index is indeed a 32bit unsigned long. I'm not really sure why ISACT stores it like this, internally maybe the upper bits were used for something else, but as far I can tell, they aren't.

from legendaryexplorer.

cnSchwarzer avatar cnSchwarzer commented on June 18, 2024

LOL, I cannot find literally anything about this format. But it works, yeahy~

from legendaryexplorer.

Mgamerz avatar Mgamerz commented on June 18, 2024

Please remove the change to GetConvoLinesBackground(), as it does not have to do with this PR. I will commit it separately.

from legendaryexplorer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.