I’m getting really desperate. I already made a thread with the same background goal here: Issue with loading new sound into existing ofSoundPlayer object (RPi)
tldr; I want to load a list of audio files that changes based on the user but is fixed at app runtime.
I can NOT create and load a player object for each file, I have extremly limited RAM (Raspberry Pi) and the lenght of the file list is theoretically unlimited.
It seems there isn’t anyone who knows a solution to my old issue.
So I tried to create ofSoundPlayer object dynamically by using:
ofSoundPlayer* audio = new ofSoundPlayer();
and then pushing that object into a vector <ofSoundPlayer*>
that I declared publicly in ofApp.h
audioPlayers.push_back(audio);
Then I load and play an audio file (all this happens in update()).
In draw() I check if its playing and if its done playing I advance by doing:
audioPlayers[0]->unloadSound();
delete audioPlayers[0];
audioPlayers.erase(audioPlayers.begin());
and then I try to do the same thing over again.
ofSoundPlayer* audio = new ofSoundPlayer();
audioPlayers.push_back(audio);
etc.
The issue is the same as in my other thread, I get a AL_INVALID_OPERATION on the second audio file and every other file coming after it and the if I come back to the first I get AL_INVALID_NAME. It also seems that unloadSound() has no effect when using pointers. Atleast in my old code I could get rid of AL_INVALID_NAME by using unloadSound() right before loading the file again.
How would you guys do this? I feel like this is a really common thing to do and I’m just doing it horribly wrong.
I really don’t care how its done in the end, just that it can be done.