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

Suggestion/Question: SoLoad and SDL_RWops audio loading #355

Open
Ar-Ess opened this issue Feb 19, 2023 · 2 comments
Open

Suggestion/Question: SoLoad and SDL_RWops audio loading #355

Ar-Ess opened this issue Feb 19, 2023 · 2 comments

Comments

@Ar-Ess
Copy link

Ar-Ess commented Feb 19, 2023

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...

@Green-Sky
Copy link

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

@Ar-Ess
Copy link
Author

Ar-Ess commented Feb 19, 2023

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;
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants