Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extended KotD #21: _MIDISOUNDBANK
#9
(08-30-2024, 03:31 PM)a740g Wrote: @Steffan-68 I've found out why the _DELAY makes your code work. So, miniaudio (our audio backend) does file-name hashing when loading audio files. The following is a direct quote from the miniaudio docs.
Quote:When loading a sound from a file path, the engine will reference count the file to prevent it from being loaded if it's already in memory. When you uninitialize a sound, the reference count will be decremented, and if it hits zero, the sound will be unloaded from memory. This reference counting system is not used for streams. The engine will use a 64-bit hash of the file name when comparing file paths which means there's a small chance you might encounter a name collision. If this is an issue, you'll need to use a different name for one of the colliding file paths, or just not load from files and instead load from a data source.
The _DELAY in your code gives the miniaudio thread enough time to purge the audio data and file name out of its system which allows it to load the same sound file afresh with the new soundbank.
Another way to work around this is to load the MIDI file with a different file name (or a different MIDI file).
You can also pass the "STREAM" flag to see if that works for you. Ideally, from the midiaudio docs it seems like it should work.
Unfortunately, currently, there is no direct way in the miniaudio API that we can use to bypass the file name hashing and reference counting behavior. We have reported this to the miniaudio authors and hopefully will have a long-term solution soon.
Thanks for your effort in finding this out.
I know that my example won't actually appear in any normal program. 
I just noticed it because I just wanted to hear how different sound sources make a sound sound very different. 
And it's crazy how big the differences are.
  
Great job what you all are doing here.
Reply


Messages In This Thread
Extended KotD #21: _MIDISOUNDBANK - by a740g - 08-25-2024, 04:07 PM
RE: Extended KotD #20: _MIDISOUNDBANK - by Dav - 08-25-2024, 04:22 PM
RE: Extended KotD #21: _MIDISOUNDBANK - by a740g - 08-25-2024, 08:40 PM
RE: Extended KotD #21: _MIDISOUNDBANK - by Pete - 08-28-2024, 08:09 PM
RE: Extended KotD #21: _MIDISOUNDBANK - by a740g - 08-29-2024, 03:30 AM
RE: Extended KotD #21: _MIDISOUNDBANK - by a740g - 08-30-2024, 03:31 PM
RE: Extended KotD #21: _MIDISOUNDBANK - by Steffan-68 - 08-30-2024, 07:32 PM



Users browsing this thread: 2 Guest(s)