summaryrefslogtreecommitdiff
path: root/soh/src/code/audio_load.c
AgeCommit message (Collapse)Author
2026-07-13fix(audio): bounds-check fontId to stop OOB crash with large SAF packs (#6916)David Racine
AudioLoad_IsFontLoadComplete had a stub `return true` that bypassed all load-status checks, masking an out-of-bounds write: for large SAF packs (many custom sequences) SetFontLoadStatus indexed fontLoadStatus[] with fontId values larger than the fontMapSize-sized array, causing heap corruption and semi-random crashes. Remove the stub. Add a (size_t)fontId >= fontMapSize guard in both the check and the setter: out-of-range IDs (custom SAF sequences that carry no associated soundfont) are treated as "loaded" in the check and silently skipped in the write, matching prior observable behavior while eliminating the OOB access. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27Cleanup unused includes & remove remaining LUS umbrella includes (#6813)Tim Schneeberger
2026-06-18fix(audio): replace stray custom-sequence printf with a debug log (#6752)David Racine
The custom-sequence registration loop printed each assigned seqNum to stdout via a bare printf, spamming the console with context-free numbers on every launch. Convert it to LUSLOG_DEBUG and include the sequence name so it is hidden by default yet useful for diagnosing music-pack loading.
2026-06-13Fix custom music corruption past 256 sequences (#5989) (#6736)David Racine
The resolved replacement id (which can exceed 255) rode a single per-player seqToPlay slot, written at enqueue but consumed asynchronously on the audio thread; back-to-back starts and priority-queue promotions clobbered it. sSeqFlags[0x6F] was also indexed by raw id, reading out of bounds past the authentic range. - func_800F9280 resolves the replacement and packs the full 16-bit id into the 0x82/0x85 play command; the handler reads opArgs & 0xFFFF. Audio_QueueSeqCmd no longer pre-writes the shared slot. - SyncInitSeqPlayerInternal uses the command-carried id and bounds-checks it against the calloc'd sequence map (+0xF headroom for reserved-range skips). - Route sSeqFlags reads through a bounded Audio_GetSeqFlags helper. - Warn and skip gracefully past the 16-bit id limit. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-01-10Fix undefined behavior (#6089)Paul Schwabauer
Fix TimeSplit crash on empty name Initialize OptionValue::mVal to fix undefined behavior Fix undefined behavior in GraveHoleJumps surface type copy. The memcpy was reading 33 SurfaceTypes regardless of the actual count, causing a buffer overread since NTSC 1.0 only has 31 surface types and later versions have 32. Now uses the actual surfaceTypesCount from the collision header. Fix undefined behavior in framebuffer OTR signature check. Use calloc instead of malloc for framebuffer allocation to zero-initialize the memory. This fixes Valgrind warnings about reading uninitialized values when ResourceMgr_OTRSigCheck reads from framebuffer pointers to check for the "__OTR__" signature. Fix undefined behavior in fontLoadStatus initialization. Use calloc instead of malloc when allocating fontLoadStatus array to ensure zero-initialization. This fixes Valgrind warnings about conditional jumps depending on uninitialized values in AudioLoad_SetFontLoadStatus.
2026-01-10Fix memory leaks in MessageViewer and audio_load (#6124)Paul Schwabauer
Add destructor to MessageViewer to free allocated buffers Free individual strings from ResourceMgr_ListFiles before freeing the array in audio_load.c
2025-10-04sequence notifs (updated #5265) (#5824)briaguya
* Adds ability for Notifiations to not make a noise This is probably the only feature that will use it, the noise makes sense for most things we want to use notifications for, but it playing on every scene transition was a bit distracting. * Adds a hook for OnSeqPlayerInit * Uses new hook and displays notification instead of overlay text * Changes names to prevent collisions Will be registering other types of hooks that will need different ShipInitFuncs in this same file later. * Change Icon * Change CVarName and remove now-unused duration slider * Update ConfigMigrator for CVar changes. * clang-format * fix * bring back duration control * config v4 * fix v4 migration --------- Co-authored-by: Christopher Leggett <chris@leggett.dev> Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
2025-08-12Turn song text into a notification (#5712)Pepe20129
2025-06-27Backport 2ship streamed audio (#5457)louist103
* Bring over changes from 2ship # Conflicts: # .github/workflows/apt-deps.txt # soh/CMakeLists.txt # soh/soh/resource/importer/AudioSampleFactory.h # soh/soh/resource/importer/AudioSequenceFactory.cpp # soh/soh/resource/importer/AudioSequenceFactory.h # soh/soh/resource/importer/AudioSoundFontFactory.h * Update xml format * Format and fix mixer for Windows * Fixes for new LUS * Good ole clang-format
2025-04-01Apply clang-format to files (#5273)Archez
2024-11-19OTRGlobals cleanup (#4251)Pepe20129
* Remove unused headers * Move all "ResourceMgr_" functions to a new file * Don't transitively include SaveManager * Move cvar prefixes to a new header * Add missing includes * Update OTRGlobals.cpp * Fix build * Address review * Fix some of the errors * Update gameplaystats.h * Update z_en_in.c * Hopefully fix the linux issues * Fix Linux issues for real this time, I checked * Update ResourceManagerHelpers.cpp * Update z_obj_mure2.c * Post-merge fixes * Fix build (hopefully) * Post-merge fixes * Update z_file_nameset_PAL.c * cleanup some unnecessary headers (#7) --------- Co-authored-by: Archez <Archez@users.noreply.github.com>
2024-04-22support lus gameoverlay changes (and bump LUS) (#4067)briaguya
2023-09-01Add scene table (#3131)Pepe20129
* Add scene table * Re-add accidentally deleted entry * Update CrashHandlerExt.cpp * Update CrashHandlerExt.cpp
2023-08-30fix audio crash when trying to detect BGM_DISABLED (#3150)Adam Bird
2023-06-27Add an error for implicit functions (#3017)louist103
* Add the flag and fix errors * switch assert and skin matrix * new LUS * Use normal assert * hopefully fix WiiU Signed-off-by: Louis <louist103@pop-os.localdomain> --------- Signed-off-by: Louis <louist103@pop-os.localdomain> Co-authored-by: Louis <louist103@pop-os.localdomain> Co-authored-by: Christopher Leggett <chris@leggett.dev>
2023-03-31Fix Missing Custom Sequences (#2649)Malkierian
* Modifies custom sequence loading to bypass other sounds being loaded in AudioCollection to fix missing custom sequences on load. * Modified `audio_load`'s sequenceMap allocation to utilize `AudioCollection`'s sequenceMap size to account for all audio assets already loaded into that sequenceMap. This gives a non-arbitrary number in addition to the vanilla sequence count to allocate with for `audio_load`'s sequenceMap. Added `HasSequenceNum` to `AudioCollection` as well to streamline the check against `AudioCollection`'s sequenceMap to skip the non-sequence assets in there. Added clarification comment for seqNum and MAX_AUTHENTIC_SEQID section. * Clarified comment about AudioCollection seqNum and MAX_AUTHENTIC_SEQID. * A bit more on comment from the last commit.
2023-03-12Makes sequenceMap and seqLoadStatus a dynamic size (#2610)Christopher Leggett
Refactors to allow the above two arrays to be a dynamic size when the game launches, size is set during the AudioLoad_Init function.
2023-02-16don't show duped sequence names, don't repeat track intros on barinade (#2482)briaguya
* better fix for repeated sequence names, add delay to fix repeated bgm on barinade --------- Co-authored-by: briaguya <briaguya@alice>
2023-02-16exclude audio from shuffle (#2411)briaguya
* Rename "SFX Editor" to "Audio Editor" * Move some functionality out into a new class `AudioCollection` * Add a tab to exclude sfx/sequences from shuffle pool --------- Co-authored-by: briaguya <briaguya@alice> Co-authored-by: briaguya <briaguya> Co-authored-by: David Chavez <david@dcvz.io>
2023-01-20Enhancement: Adds Slider for Duration of Sequence Names on the Overlay (#2375)Christopher Leggett
* New function: overlay text duration in seconds. `Overlay_DisplayText` took a float as an argument, with no clear indication of what that float represented. That float also evaluates to different durations given different frame rates. However, since we know what the frame rate should be at any given time (since it's stored in a CVar) we can calculate what this duration should be based on the number of seconds we want the overlay to be displayed. That's what `Overlay_DisplayText_Seconds` does. * Adds Slider for Overlay Sequence Name Durations
2023-01-19Adds option for showing sequence names on the overlay (#2237)Christopher Leggett
* Adds option for showing sequence names on the overlay Allows sequences to appear on the overlay in the bottom right corner for a few seconds whenever a new one is loaded into the primary sequence player. This means it does not apply to fanfares or enemy bgm. Fanfares I chose not to display because it would cause a lot of text to display back to back in some areas, and enemy bgm would have some technical challenges with this due to the way it loads. Mainly because the Lost Woods music would load in Goron City the same way (as well as the opposite). * Fixes crash when a sequence without a name is attempted to be displayed. * Removes accidentally committed CMakeSettings.json * Updates CVar_GetS32 to CVarGetInteger
2023-01-17refactor: use LUS 1.0 RCbriaguya
Co-authored-by: kenix3 <kenixwhisperwind@gmail.com> Co-authored-by: David Chavez <david@dcvz.io> Co-authored-by: KiritoDv <kiritodev01@gmail.com> Co-authored-by: Christopher Leggett <chris@leggett.dev>
2022-12-13Always use authentic cache policy for replaced seqs (#2176)Christopher Leggett
2022-12-09fix: prevent oob access of sequenceMap (#2123)briaguya
Co-authored-by: briaguya <briaguya@alice>
2022-12-08Custom Sequences (#2066)Christopher Leggett
* Allows OTRExporter to parse pairs of .seq and .meta files * Gets added sequences available to SfxEditor and playing in game. * Some cleanup of the names appearing in the SfxEditor. * Moves sequence swap lower in the audio command stack. * Increases temp cache memory available on title/file-select screen. Certain sequences wouldn't play on the file select and title screen because they were too large to be cached. * Introduces workaround for 255 sequence limit. * Bug fixes and cleanup. * Fixes bug where fanfares would sometimes disable the sequence player. * Fixes bug causing certain areas to discard caches when loading enemy music. * Fixes potential config-related crash by replacing invalid characters. * Allows custom bgm to play in all BGM categories. * Properly randomizes the custom tracks. * Moves custom sequences to a patch OTR. * If custom music was not loaded, fall back to default values. * Prevents OOB crash on Synthwave array and adds octave drop feature. Added octave drop to experimental features, which drops the octave of a note that is too high for the audio engine to actually play. Without this, some custom sequences have notes which cap at a specific value and sound terrible. At least with this they will still harmonize with the other notes. Experimental tab added to the SfxEditor to house the checkbox for the octave drop feature. * Adds more pool memory for a few tracks that couldn't fit. * Some cleanup on the generated music archive process. * Fixes missed memory boost from earlier. * Adds ability to remove enemy proximity music. * Applies correct cache policy to fanfares to prevent unloading sequences. * Removes case-sensitiveness of the sequence type. * Fixes not reverting to sequence after miniboss. * Fixes transition to/from miniboss (again) and ocarina bug. To be clear, fixes the more rampant portable ocarina bug present in my earlier builds, not the authentic one. * Finally properly fixes transitions between sequences For miniboss fights and SfxEditor previews. * Removes unneeded boolean expression. * Adds randomize button to individual SFX Editor entries. * Fixes lost woods music overwriting goron city music. * Plays swapped Hyrule Field music when transitioning to daytime. * Fixes swapping Gerudo Valley music when transitioning from daytime. * Updates custom sequence OTRPath to match SequenceOTRizer. * Reverts changes to OTRExporter in favor of external tool * Fixes formatting issues. * Attempts to fix formatting issue in git diff. * Should actually fix formatting issues. * Should fix mac/linux exclusive build error. * Fixes segfault on macos. * sort custom seqs * Fixes audioseq crash when under 255 seqs * Removes magic numbers. * Removes commented out code. * fixes formatting in SfxEditor.h Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com> * Cleans up the one hardcoded QueueSeqCmd call. * Fixes unneeded erroneous memory boost applied earlier. * Applies additional formatting/cleanliness suggestions from review * Fixes small logic bug Co-authored-by: RaelCappra <rael.cappra@gmail.com> Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
2022-07-11Removed legacy audio mode and fixed ganon sound bug (#657)Nicholas Estelami
2022-07-05Use Macro for __FILE__ & __LINE__ when possible (#559)Baoulettes
* First batch some overlay * Almost all overlay * effect & gamestate * kaleido stuffs * more overlay * more left over from code folder * remaining hardcoded line and file * Open & Close _DISP __FILE__ & __LINE__ clean up * Some if (1) {} remove * LOG_xxxx __FILE__ , __LINE__ cleaned * ASSERT macro __FILE__ __LINE__ * mtx without line/file in functions * " if (1) {} " & "if (0) {}" and tab/white place * LogUtils as macro * GameState_, GameAlloc_, SystemArena_ & ZeldaArena_ * Revert "GameState_, GameAlloc_, SystemArena_ & ZeldaArena_" This reverts commit 0d85caaf7e342648c01a15fe21e93637352dc596. * Like last commit but as macro * Fix matrix not using macros * use function not macro * DebugArena_* functions GameAlloc_MallocDebug BgCheck_PosErrorCheck as macros removed issues with ; in macro file
2022-07-04Fix audio, boot commands, and save staes.louist103
2022-06-20Update soh/src/code/audio_load.cKenix3
2022-06-17Merge branch 'develop' into z64-devmergebriaguya
2022-06-16Merge branch 'zapd_audio_support' into zelda64Kevin Alexis Contreras
2022-06-16Fixed StormLib Forward Slash BackSlash issuesNicholas Estelami
2022-06-16Added names for the soundfonts.Nicholas Estelami
2022-06-16Fixed resample and corrupt audio bug. Minor documentation updates.Nicholas Estelami
2022-06-16Audio support nearly complete.Nicholas Estelami
2022-06-16Audio decompiled and WIP custom sample supportNicholas Estelami
2022-06-15Fixed StormLib Forward Slash BackSlash issuesNicholas Estelami
2022-06-15Added names for the soundfonts.Nicholas Estelami
2022-06-15Fixed resample and corrupt audio bug. Minor documentation updates.Nicholas Estelami
2022-06-15Audio support nearly complete.Nicholas Estelami
2022-06-15Audio decompiled and WIP custom sample supportNicholas Estelami
2022-06-15Updated zapd_audio_support into zelda64Kevin Alexis Contreras
2022-06-14Fixed StormLib Forward Slash BackSlash issuesNicholas Estelami
2022-06-14Added names for the soundfonts.Nicholas Estelami
2022-06-14Fixed resample and corrupt audio bug. Minor documentation updates.Nicholas Estelami
2022-06-14Audio support nearly complete.Nicholas Estelami
2022-06-14Audio decompiled and WIP custom sample supportNicholas Estelami
2022-06-13Updated zapd_audio_support on zelda64Kevin Alexis Contreras
2022-06-13Code cleanup and fixes on 64bitsKevin Alexis Contreras
2022-06-10Fixed resample and corrupt audio bug. Minor documentation updates.Nicholas Estelami