From a5e12c6d28f4264e0cfec79074cf9d39f6f940ee Mon Sep 17 00:00:00 2001 From: RileyTheFox Date: Mon, 8 May 2023 21:02:03 +0100 Subject: [PATCH] Change mogg loading stuff (#283) --- Assets/Script/Audio/Bass/BassAudioManager.cs | 16 ++++++++++++---- Assets/Script/Audio/Interfaces/IAudioManager.cs | 3 +-- Assets/Script/PlayMode/Play.cs | 10 +--------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Assets/Script/Audio/Bass/BassAudioManager.cs b/Assets/Script/Audio/Bass/BassAudioManager.cs index 8261dd3a3..4fcf36f2d 100644 --- a/Assets/Script/Audio/Bass/BassAudioManager.cs +++ b/Assets/Script/Audio/Bass/BassAudioManager.cs @@ -204,10 +204,18 @@ public void LoadSong(ICollection stems, bool isSpeedUp) { IsAudioLoaded = true; } - public void LoadMogg(byte[] moggArray, - Dictionary stemMaps, float[,] matrixRatios, bool isSpeedUp) { + public void LoadMogg(ExtractedConSongEntry exConSong, bool isSpeedUp) { Debug.Log("Loading mogg song"); UnloadSong(); + + byte[] moggArray; + + if (exConSong is ConSongEntry conSong) { + moggArray = XboxCONInnerFileRetriever.RetrieveFile(conSong.Location, conSong.MoggPath, + conSong.MoggFileSize, conSong.MoggFileMemBlockOffsets)[conSong.MoggAddressAudioOffset..]; + } else { + moggArray = File.ReadAllBytes(exConSong.MoggPath)[exConSong.MoggAddressAudioOffset..]; + } int moggStreamHandle = Bass.CreateStream(moggArray, 0, moggArray.Length, BassFlags.Prescan | BassFlags.Decode | BassFlags.AsyncFile); if (moggStreamHandle == 0) { @@ -215,7 +223,7 @@ public void LoadMogg(byte[] moggArray, return; } - _mixer = new BassStemMixer(this, moggStreamHandle, stemMaps, matrixRatios); + _mixer = new BassStemMixer(this, moggStreamHandle, exConSong.StemMaps, exConSong.MatrixRatios); if (!_mixer.Create()) { throw new Exception($"Failed to create mixer: {Bass.LastError}"); } @@ -244,7 +252,7 @@ public void UnloadSong() { public void LoadPreviewAudio(SongEntry song) { if (song is ExtractedConSongEntry conSong) { - LoadMogg(conSong.MoggInfo, false); + LoadMogg(conSong, false); } else { LoadSong(AudioHelpers.GetSupportedStems(song.Location), false); } diff --git a/Assets/Script/Audio/Interfaces/IAudioManager.cs b/Assets/Script/Audio/Interfaces/IAudioManager.cs index 6a47f4ea8..a19280535 100644 --- a/Assets/Script/Audio/Interfaces/IAudioManager.cs +++ b/Assets/Script/Audio/Interfaces/IAudioManager.cs @@ -27,8 +27,7 @@ public interface IAudioManager { public void LoadSfx(); public void LoadSong(ICollection stems, bool isSpeedUp); - // public void LoadMogg(XboxMoggData moggData, bool isSpeedUp); - public void LoadMogg(byte[] moggArray, Dictionary stemMaps, float[,] matrixRatios, bool isSpeedUp); + public void LoadMogg(ExtractedConSongEntry exConSong, bool isSpeedUp); public void UnloadSong(); public void LoadPreviewAudio(SongEntry song); diff --git a/Assets/Script/PlayMode/Play.cs b/Assets/Script/PlayMode/Play.cs index 35f38542e..5b31a3eb4 100644 --- a/Assets/Script/PlayMode/Play.cs +++ b/Assets/Script/PlayMode/Play.cs @@ -118,15 +118,7 @@ private void StartSong() { if (song is ExtractedConSongEntry rawConSongEntry) { Debug.Log(rawConSongEntry.MatrixRatios.GetLength(0)); - GameManager.AudioManager.LoadMogg(File.ReadAllBytes(rawConSongEntry.MoggPath)[rawConSongEntry.MoggAddressAudioOffset..], - rawConSongEntry.StemMaps, rawConSongEntry.MatrixRatios, isSpeedUp); - } - else if(song is ConSongEntry conSongEntry){ - Debug.Log(conSongEntry.MatrixRatios.GetLength(0)); - - GameManager.AudioManager.LoadMogg(XboxCONInnerFileRetriever.RetrieveFile(conSongEntry.Location, conSongEntry.MoggPath, - conSongEntry.MoggFileSize, conSongEntry.MoggFileMemBlockOffsets)[conSongEntry.MoggAddressAudioOffset..], - conSongEntry.StemMaps, conSongEntry.MatrixRatios, isSpeedUp); + GameManager.AudioManager.LoadMogg(rawConSongEntry, isSpeedUp); } else { var stems = AudioHelpers.GetSupportedStems(song.Location);