I want to play a list of audio files, I create a single ofSoundPlayer object and load a file. When the file is done playing, I unload it and want to load a new file into the same object but oF is throwing me an error:
[ error ] ofOpenALSoundPlayer: loadSound(): couldn't create stereo buffers for "/home/pi/openFrameworks/apps/myApps/myPlayer/bin/content/zDistortion_Wave_04.wav": 40964 AL_INVALID_OPERATION
The file is definitely not the issue, the first file always plays fine the second gets this error, switching the files produces the same result.
Here a snippet of my setup:
ofSoundPlayer audio;
void ofApp::update(){
ofSoundUpdate();
if (playlistNumber>playlist.filePath.size()-1)
{
playlistNumber = 0;
cout << "Playlist reset"<< endl;
}
if (!itemLoaded){
cout << "Loading audio..."<< playlist.filePath[playlistNumber] << endl;
audio.loadSound(playlist.filePath[playlistNumber]);
audio.play();
itemLoaded = true;
}
}
//--------------------------------------------------------------
void ofApp::draw(){
if (audio.getIsPlaying())
{
cout << "Playing audio..."<< playlistNumber << " of " << playlist.filePath.size() <<endl;
audioImg.draw(0, 0);
}else{
audio.unloadSound();
playlistNumber++;
itemLoaded = false;
}
}
It then skips this file (I show some other non audio stuff from the playlist) and then it goes back to the first (successfully) played audio file and throws this error instead:
[ error ] ofOpenALSoundPlayer: loadSound(): couldn't create stereo buffers for "/home/pi/openFrameworks/apps/myApps/myPlayer/bin/content/Intro.mp3": 40961 AL_INVALID_NAME
Any ideas what is going wrong here? I’m really puzzled about this, especially the two different error messages for the seemingly same issue.
Edit: Seems the second error is resolved by unloading the sound in update, maybe I tried to play before unloading but the first error is still persistent which is now even weirder. I can load and unload the first file I loaded but not any other file.
Update now looks like this:
if (audio.isLoaded()) audio.unloadSound();
cout << "Loading audio..."<< playlist.filePath[playlistNumber] << endl;
audio.loadSound(playlist.filePath[playlistNumber]);
audio.play();