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

miniaudio file name hashing fix #568

Merged
merged 8 commits into from
Nov 19, 2024

Conversation

a740g
Copy link
Contributor

@a740g a740g commented Nov 18, 2024

This PR works around miniaudio's file name hashing which causes the following issues:

  1. When multiple files are extracted (e.g., from a game data archive) into the same temporary file (e.g., temp.wav) and loaded sequentially, all files are resolved to the first-loaded sound due to the static file name.

  2. The MIDI file decoder allows user-defined SoundFonts (.sf2). However, reloading the same MIDI file with a different SoundFont causes a conflict due to file name hashing. For example: If MIDI file A.mid is loaded with SoundFont A.sf2 and later with B.sf2, playback defaults to the first-loaded SoundFont (A.sf2), even if B.sf2 is specified.

Additionally, _MEMSOUND now works correctly with fully decoded MEMORY sounds, expanding its functionality.

Quality of life improvements:

  1. Removed usage of unsafe C macros.
  2. Eliminated reliance on ma_decoder to simplify audio library.

Special thanks to @mkilgore for proposing the workaround and providing the original implementation.

@a740g a740g added bug Something isn't working enhancement New feature or request labels Nov 18, 2024
@a740g a740g self-assigned this Nov 18, 2024
@a740g a740g changed the title Audio ma vfs test miniaudio file name hashing fix Nov 18, 2024
Copy link
Contributor

@mkilgore mkilgore left a comment

Choose a reason for hiding this comment

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

Thanks for turning this into a full-fledged solution :)

internal/c/parts/audio/audio.cpp Outdated Show resolved Hide resolved
@a740g a740g merged commit 4f2bd9e into QB64-Phoenix-Edition:main Nov 19, 2024
4 checks passed
@a740g a740g deleted the audio-ma_vfs-test branch November 19, 2024 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants