schellingb / TinySoundFont

SoundFont2 synthesizer library in a single C/C++ file
MIT License
608 stars 71 forks source link

sfo file created with sfo_tool fails to load with tsf_load_memory. #90

Closed SnowSnakz closed 2 months ago

SnowSnakz commented 2 months ago

tsf_load_memory makes a call to tsf_load which ends in the following branch at Line 1423

    else if (!rawBuffer && !floatBuffer)
    {
        // if (e) *e = TSF_INVALID_NOSAMPLEDATA;
    }

What I've tried:

I've attached these files (attachments.zip) because it might help to resolve the issue:

I will also be doing to more debugging on my own, I will post updates if I find anything.

SnowSnakz commented 2 months ago

I was able to fix the issue by moving #include "stb_vorbis.c" before #include "tsf.h", I didn't even realize I had done this.

schellingb commented 2 months ago

As you've figured out, TSF just silently enables or disables OGG decoding support if a define from stb_vorbis is present or not (with the #ifdef STB_VORBIS_INCLUDE_STB_VORBIS_H at tsf.h:865) and then silently at runtime fails (or succeeds) with a SoundFont that has OGG encoded samples.

We don't really have documentation for this stuff, not even an example, but I'm glad you were able to figure it out. Thanks for using TSF :-)