Open Ar-Ess opened 1 year ago
I should work.
this is not an exact match, but use soloud ontop of PhysFS like so https://github.com/MadeOfJelly/MushMachine/blob/master/framework/sound/src/mm/soloud_filesystem_file_impl.cpp
Thanks for your answer, but I don't quite see my solution in there. Let me show you the usual code I use for reading files through a compressed file using PhysFS, and how I usually load it using SDL.
This example is for Texture loading:
SDL_Surface* surface = nullptr;
SDL_RWops* rW = nullptr;
if (release)
{
if (PHYSFS_exists(path) == 0)
{
LOG("ERROR - FILE %s DOESNT EXIST IN THE SEARCH PATH: %s\n", path, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
return;
}
rW = PHYSFSRWOPS_openRead(path);
if (!rW)
{
LOG("ERROR OPENING FILE %s FOR READING: %s\n", path, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
return;
}
surface = IMG_Load_RW(rW, 0);
}
In the case of loading audio, should be something similar... Something like this in pseudocode:
if (release)
{
if (PHYSFS_exists(path) == 0)
{
LOG("ERROR - FILE %s DOESNT EXIST IN THE SEARCH PATH: %s\n", path, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
return false;
}
SDL_RWops* rW = PHYSFSRWOPS_openRead(path);
if (!rW)
{
LOG("ERROR OPENING FILE %s FOR READING: %s\n", path, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
return false;
}
// Getting data from the rW
// Using some function inside "SoLoud::Wav" class to load data
return true;
}
I'm working right now on a low-level c++ Videogame Template, using SDL as the main core of the engine. SoLoud is the core of the AudioSystem of it. I'm trying to load all data from SDL_RWops when executing on Release Mode. This way I can mount a ".pak" file to have my assets compressed and not at pull sight.
Is there a way to load audio files with SoLoud using SDL_RWops class? I've tried to get the buffer data from the RWops, and load it using Wav::loadMem(), but SoLoud returns null data and the sound won't reproduce.
In case it does not exist, I think it could be a good feature, as SoLoud uses SDL as one of its backends...