Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Audio Support #778

Open
wants to merge 92 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
dd59a56
Implement custom sequences and the audio editor.
louist103 Jun 28, 2024
e90cab7
Fix implicit function declaration `AudioEditor_GetReplacementSeq`
louist103 Jun 28, 2024
79cd020
Fix mac again.
louist103 Jun 28, 2024
cac05a1
String and header cleanup
louist103 Jun 28, 2024
a6fae26
Oops
louist103 Jun 28, 2024
eb9f3e6
WIP ZIP Sound fonts
louist103 Jun 30, 2024
65a1405
The game opens and audio seems to play correctly. Needs extensive tes…
louist103 Jun 30, 2024
5b25e62
Name sequences
louist103 Jul 1, 2024
bc92ebf
Cleanup the SF importer a little.
louist103 Jul 1, 2024
aae5f59
XML Sequences good
louist103 Jul 3, 2024
eadf08d
Fix mac
louist103 Jul 3, 2024
3e9e50a
Destructor
louist103 Jul 4, 2024
6a0bcbe
Bump submodule
louist103 Jul 4, 2024
e0d55e7
Thread safe queue
louist103 Jul 18, 2024
92d4eee
Add WAV decoder
louist103 Jul 18, 2024
0eb669f
sequenceMap->mSequenceMap and a string fix
louist103 Jul 18, 2024
c46d738
Streamed sequence importer
louist103 Jul 18, 2024
ae494b0
Add s16 sample processing.
louist103 Aug 17, 2024
36033f3
Fix drwave define
louist103 Aug 17, 2024
953ba73
Fix STB
louist103 Aug 17, 2024
93296bc
Reorder the loading to enable custom sound fonts
louist103 Aug 24, 2024
d6f0e20
New streamed solution
louist103 Aug 24, 2024
ca56117
Bump exporter
louist103 Aug 24, 2024
1465f7b
Generate 1 minute long looping sequence.
louist103 Aug 25, 2024
0cf00df
Very long sample support (113 minutes or so)
louist103 Aug 27, 2024
63b305e
MP3 Decoding
louist103 Aug 27, 2024
915169b
Don't byteswap the crc from XML.
louist103 Aug 27, 2024
6bcf490
WIP OGG
louist103 Sep 1, 2024
bb16026
add windows cmake stuff (broken) and fixes to OGG
louist103 Sep 5, 2024
cc7f341
Just throw more cores at the problem
louist103 Sep 5, 2024
ce93ca0
Dynamically allocate fontMap
louist103 Sep 6, 2024
bb2c084
Re-add OOB read fix from old branch
louist103 Sep 6, 2024
2a73ed4
FLAC decoder, threads for the other compressed formats
louist103 Sep 6, 2024
a5c7dfc
Remove thread from class
louist103 Sep 6, 2024
b43edd4
timings
louist103 Sep 23, 2024
d0fc330
cleanup conflicts
louist103 Sep 24, 2024
3f404df
update submodules
louist103 Sep 24, 2024
d0b2c97
update submodules
louist103 Sep 24, 2024
5c0225b
update submodules
louist103 Sep 25, 2024
d8ea4ed
loop or not to loop
louist103 Oct 3, 2024
a58ed3d
named audio XML
louist103 Oct 3, 2024
734726e
Update submodules
louist103 Oct 5, 2024
49d9fe8
merge
louist103 Oct 5, 2024
bfa9706
format
louist103 Oct 5, 2024
9f3d846
format again cause git didnt see it for some reason
louist103 Oct 5, 2024
2019e98
move drlib to submodule
louist103 Oct 5, 2024
e186dce
Conflict
louist103 Oct 5, 2024
6ccc5fc
Merge branch 'develop' into customAudio2
louist103 Oct 5, 2024
628b823
Update apt-deps.txt
louist103 Oct 5, 2024
15ce6e9
Fix for new cmake
louist103 Oct 5, 2024
d4411b5
fix game interactor
louist103 Oct 5, 2024
fb2302f
Update macports-deps.txt
louist103 Oct 5, 2024
a4cdbc1
PR fixes and fix OTRExporter for mac
louist103 Oct 5, 2024
a41d090
Merge branch 'customAudio2' of https://github.com/louist103/2ship2har…
louist103 Oct 5, 2024
dc96e96
format
louist103 Oct 5, 2024
158648f
format
louist103 Oct 6, 2024
955a329
ifdef intrin header
louist103 Oct 6, 2024
fd97c91
Merge branch 'customAudio2' of https://github.com/louist103/2ship2har…
louist103 Oct 6, 2024
07c9a08
Docs
louist103 Oct 6, 2024
27c2522
use macro for preview
louist103 Oct 8, 2024
da1cf35
Small fixes
louist103 Oct 8, 2024
96cd60f
format
louist103 Oct 8, 2024
c24f0d2
fix 2nd day clock town
louist103 Oct 9, 2024
e3a7e82
Update exporter
louist103 Oct 10, 2024
dc779a5
Fix duplicate global in stubs.c
louist103 Oct 11, 2024
3493553
restore editor to use cvars again sadge
louist103 Oct 11, 2024
414b832
Format
louist103 Oct 11, 2024
0fb8f67
Merge branch 'develop' into customAudio2
louist103 Oct 11, 2024
a14ba79
warn if more than 255 sequences
louist103 Oct 12, 2024
d6615c5
use main seq player to avoid an overflow
louist103 Oct 12, 2024
1917d67
Merge branch 'customAudio2' of https://github.com/louist103/2ship2har…
louist103 Oct 12, 2024
852e1e1
fix the wrong seq playing in the editor again
louist103 Oct 14, 2024
379bc5d
16 bit seqIds
louist103 Oct 18, 2024
ae29eb7
fix shop crash
louist103 Oct 19, 2024
795586e
format
louist103 Oct 19, 2024
dd17321
cleanups
louist103 Oct 19, 2024
69cc9cc
Delete audio collection
louist103 Oct 20, 2024
3b92153
Add entry to modern menu
louist103 Oct 20, 2024
5a184a5
Cleanup the audio collection
louist103 Oct 20, 2024
9f1e6ab
fix clock town randomization
louist103 Oct 20, 2024
98af18f
format
louist103 Oct 20, 2024
e3f9cc5
format again
louist103 Oct 22, 2024
0433a89
some fixes for custom audio (#1)
mckinlee Oct 23, 2024
a53439e
how I would sort the sequences (#2)
louist103 Oct 24, 2024
edfa595
Adjustments to ocarina song types
louist103 Oct 27, 2024
754bc74
stereo
louist103 Oct 28, 2024
0645457
format
louist103 Oct 31, 2024
e4d0941
Loop point support
louist103 Nov 3, 2024
7f0e6ae
Merge branch 'customAudio2' of https://github.com/louist103/2ship2har…
louist103 Nov 3, 2024
3afe66a
Merge branch 'develop' into customAudio2
louist103 Nov 5, 2024
c4021da
Merge remote-tracking branch 'upstream/develop' into customAudio2
louist103 Nov 7, 2024
5e44d8c
Part of a PR review
louist103 Nov 7, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/apt-deps.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
libusb-dev libusb-1.0-0-dev libsdl2-dev libsdl2-net-dev libpng-dev libglew-dev nlohmann-json3-dev libtinyxml2-dev libspdlog-dev ninja-build
libusb-dev libusb-1.0-0-dev libsdl2-dev libsdl2-net-dev libpng-dev libglew-dev nlohmann-json3-dev libtinyxml2-dev libspdlog-dev ninja-build libogg-dev libvorbis-dev
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "ZAPDTR"]
path = ZAPDTR
url = https://github.com/louist103/ZAPDTR.git
[submodule "mm/2s2h/Enhancements/Audio/dr_libs"]
Copy link
Contributor

@Archez Archez Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just fetch the drlibs via cmake with Fetch_Content, this way it's controlled like our other dependencies.

Here is LUS doing it https://github.com/Kenix3/libultraship/blob/main/cmake/dependencies/common.cmake

path = mm/2s2h/Enhancements/Audio/dr_libs
url = https://github.com/mackron/dr_libs.git
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ elseif ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
endif()

vcpkg_bootstrap()
vcpkg_install_packages(zlib bzip2 libzip libpng sdl2 sdl2-net glew glfw3 nlohmann-json tinyxml2 spdlog)
vcpkg_install_packages(zlib bzip2 libzip libpng sdl2 sdl2-net glew glfw3 nlohmann-json tinyxml2 spdlog libogg libvorbis)
endif()

################################################################################
Expand Down
2 changes: 1 addition & 1 deletion OTRExporter
2 changes: 1 addition & 1 deletion ZAPDTR
Submodule ZAPDTR updated 2 files
+40 −41 ZAPD/ZAudio.cpp
+9 −12 ZAPD/ZAudio.h
6 changes: 6 additions & 0 deletions mm/2s2h/BenGui/BenGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <Fast3D/gfx_pc.h>
#include "UIWidgets.hpp"
#include "HudEditor.h"
#include "../Enhancements/Audio/AudioEditor.h"
louist103 marked this conversation as resolved.
Show resolved Hide resolved

#ifdef __APPLE__
#include "graphic/Fast3D/gfx_metal.h"
Expand All @@ -34,6 +35,7 @@ std::shared_ptr<HudEditorWindow> mHudEditorWindow;
std::shared_ptr<ActorViewerWindow> mActorViewerWindow;
std::shared_ptr<CollisionViewerWindow> mCollisionViewerWindow;
std::shared_ptr<EventLogWindow> mEventLogWindow;
std::shared_ptr<AudioEditor> mAudioEditorWindow;
std::shared_ptr<BenMenu> mBenMenu;
std::shared_ptr<BenInputEditorWindow> mBenInputEditorWindow;

Expand Down Expand Up @@ -92,6 +94,8 @@ void SetupGuiElements() {

mEventLogWindow = std::make_shared<EventLogWindow>("gWindows.EventLog", "Event Log", ImVec2(520, 600));
gui->AddGuiWindow(mEventLogWindow);
mAudioEditorWindow = std::make_shared<AudioEditor>("gWindows.AudioEditor", "Audio Editor");
gui->AddGuiWindow(mAudioEditorWindow);
gui->SetPadBtnTogglesMenu();
}

Expand All @@ -108,5 +112,7 @@ void Destroy() {
mSaveEditorWindow = nullptr;
mHudEditorWindow = nullptr;
mActorViewerWindow = nullptr;

mAudioEditorWindow = nullptr;
}
} // namespace BenGui
10 changes: 10 additions & 0 deletions mm/2s2h/BenGui/BenMenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include <string>
#include "2s2h/Enhancements/Enhancements.h"
#include "2s2h/DeveloperTools/DeveloperTools.h"
#include "2s2h/Enhancements/Cheats/Cheats.h"
#include "2s2h/Enhancements/Player/Player.h"
#include "2s2h/Enhancements/Audio/AudioEditor.h"
#include "HudEditor.h"

extern "C" {
Expand Down Expand Up @@ -747,6 +750,8 @@ extern std::shared_ptr<ActorViewerWindow> mActorViewerWindow;
extern std::shared_ptr<CollisionViewerWindow> mCollisionViewerWindow;
extern std::shared_ptr<EventLogWindow> mEventLogWindow;

extern std::shared_ptr<AudioEditor> mAudioEditorWindow;

const char* logLevels[] = {
"trace", "debug", "info", "warn", "error", "critical", "off",
};
Expand Down Expand Up @@ -872,6 +877,11 @@ void DrawDeveloperToolsMenu() {
if (mEventLogWindow) {
UIWidgets::WindowButton("Event Log", "gWindows.EventLog", mEventLogWindow);
}

if (mAudioEditorWindow) {
UIWidgets::WindowButton("Audio Editor", "gWindows.AudioEditor", mAudioEditorWindow);
}

ImGui::EndMenu();
}
}
Expand Down
25 changes: 24 additions & 1 deletion mm/2s2h/BenPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "z64animation.h"
#include "z64bgcheck.h"
#include <libultraship/libultra/gbi.h>
#include "stb_image.h"
#include <Fonts.h>
#ifdef _WIN32
#include <Windows.h>
Expand Down Expand Up @@ -55,6 +56,7 @@ CrowdControl* CrowdControl::Instance;
#include "2s2h/DeveloperTools/DebugConsole.h"
#include "2s2h/DeveloperTools/DeveloperTools.h"
#include "2s2h/SaveManager/SaveManager.h"
#include "2s2h/Enhancements/Audio/AudioCollection.h"

// Resource Types/Factories
#include "resource/type/Blob.h"
Expand Down Expand Up @@ -101,6 +103,7 @@ CrowdControl* CrowdControl::Instance;

OTRGlobals* OTRGlobals::Instance;
GameInteractor* GameInteractor::Instance;
AudioCollection* AudioCollection::Instance;

extern "C" char** cameraStrings;
bool prevAltAssets = false;
Expand Down Expand Up @@ -208,14 +211,24 @@ OTRGlobals::OTRGlobals() {
"Cutscene", static_cast<uint32_t>(SOH::ResourceType::SOH_Cutscene), 0);
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryTextMMV0>(), RESOURCE_FORMAT_BINARY,
"TextMM", static_cast<uint32_t>(SOH::ResourceType::TSH_TextMM), 0);

loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryAudioSampleV2>(), RESOURCE_FORMAT_BINARY,
"AudioSample", static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSample), 2);
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryXMLAudioSampleV0>(), RESOURCE_FORMAT_XML,
"Sample", static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSample), 0);

loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryAudioSoundFontV2>(),
RESOURCE_FORMAT_BINARY, "AudioSoundFont",
static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSoundFont), 2);
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryXMLSoundFontV0>(), RESOURCE_FORMAT_XML,
"SoundFont", static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSoundFont), 0);

loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryAudioSequenceV2>(),
RESOURCE_FORMAT_BINARY, "AudioSequence",
static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSequence), 2);
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryXMLAudioSequenceV0>(), RESOURCE_FORMAT_XML,
"Sequence", static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSequence), 0);

loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryBackgroundV0>(), RESOURCE_FORMAT_BINARY,
"Background", static_cast<uint32_t>(SOH::ResourceType::SOH_Background), 0);
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryTextureAnimationV0>(),
Expand Down Expand Up @@ -512,6 +525,7 @@ extern "C" void InitOTR() {

OTRGlobals::Instance = new OTRGlobals();
GameInteractor::Instance = new GameInteractor();
AudioCollection::Instance = new AudioCollection();
BenGui::SetupGuiElements();
InitEnhancements();
InitDeveloperTools();
Expand Down Expand Up @@ -1180,6 +1194,10 @@ extern "C" SequenceData ResourceMgr_LoadSeqByName(const char* path) {
SequenceData* sequence = (SequenceData*)ResourceGetDataByName(path);
return *sequence;
}
extern "C" SequenceData* ResourceMgr_LoadSeqPtrByName(const char* path) {
SequenceData* sequence = (SequenceData*)ResourceGetDataByName(path);
return sequence;
}
extern "C" KeyFrameSkeleton* ResourceMgr_LoadKeyFrameSkelByName(const char* path) {
return (KeyFrameSkeleton*)ResourceGetDataByName(path);
}
Expand Down Expand Up @@ -1250,9 +1268,14 @@ extern "C" SoundFontSample* ResourceMgr_LoadAudioSample(const char* path) {
}
#endif

extern "C" SoundFont* ResourceMgr_LoadAudioSoundFont(const char* path) {
extern "C" SoundFont* ResourceMgr_LoadAudioSoundFontByName(const char* path) {
return (SoundFont*)ResourceGetDataByName(path);
}

extern "C" SoundFont* ResourceMgr_LoadAudioSoundFontByCRC(uint64_t crc) {
return (SoundFont*)ResourceGetDataByCrc(crc);
}

extern "C" int ResourceMgr_OTRSigCheck(char* imgData) {
uintptr_t i = (uintptr_t)(imgData);

Expand Down
2 changes: 1 addition & 1 deletion mm/2s2h/BenPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Vtx* ResourceMgr_LoadVtxByCRC(uint64_t crc);
char* ResourceMgr_LoadVtxArrayByName(const char* path);
size_t ResourceMgr_GetVtxArraySizeByName(const char* path);
Vtx* ResourceMgr_LoadVtxByName(char* path);

SequenceData* ResourceMgr_LoadSeqPtrByName(const char* path);
KeyFrameSkeleton* ResourceMgr_LoadKeyFrameSkelByName(const char* path);
KeyFrameAnimation* ResourceMgr_LoadKeyFrameAnimByName(const char* path);

Expand Down
Loading
Loading