Populating an array with audio files?

I’m coming to oF from Processing and have basic programming skills. I’m teaching myself this stuff, but find myself easily stumped. So…

I want to populate an array with audio files and play them all back simultaneously.

I have this written in Processing:

  
import ddf.minim.*;  
  
AudioPlayer[] player = new AudioPlayer[3];  
Minim minim;  
  
void setup()  
{  
  size(512, 200);  
  minim = new Minim(this);  
    
  for (int i = 0; i < player.length; i++) {  
    String songNumber = nf(i,4) + ".mp3";  
    player[i] = minim.loadFile(songNumber);  
    player[i].play();  
  }  
    
}  

Which works fine. Here’s what I have in oF, but returns errors:
In my header I am declaring like this:

  
	  
  
ofSoundPlayer songArray[5];  
        string songNumber;  

And in my .cpp:

  
  
void testApp::setup(){  
    for(int i = 0; i<5; i++)  
    {  
        string songNumber = i + ".ogg";  
        songArray[i].loadSound(songNumber);  
        songArray[i].play();  
    }  
  
}  

The audio files are named “0.ogg”, “1.ogg”, etc. The files will load and play outside of the array, so it’s not a hardware/format issue. What am I doing wrong here? How do I do this right?

Any help is greatly appreciated.

I use an array of ofSoundPlayer pointers and I have no problem.
Maybe try this:

  
  
ofSoundPlayer *songArray[5];  
        string songNumber;  
  

  
  
void testApp::setup(){  
    for(int i = 0; i<5; i++)  
    {  
        string songNumber = i + ".ogg";  
        songArray[i] = new  ofSoundPlayer;  
        songArray[i]->loadSound(songNumber);  
        songArray[i]->play();  
    }  
  
}  
  

Thanks for your reply Bernard.
But I’m still stuck.

This is the error message I get after compiling:

  
  
OF_ERROR: ofSoundPlayer: Could not load sound file data/.ogg  
OF_ERROR: ofSoundPlayer: Could not load sound file data/ogg  
OF_ERROR: ofSoundPlayer: Could not load sound file data/gg  
OF_ERROR: ofSoundPlayer: Could not load sound file data/g  
  
terminate called after throwing an instand of 'std::out_of_range'  
what(): basic_string::substr  
Aborted  
  

I think the problem is concatenating my variable [i] with “.ogg”. I don’t know how to do this in oF. Or am I way off?

try something like:

  
  
char songNumber[1024];  
sprintf(songNumber, "%d.ogg", i);  
songArray[i].loadSound(songNumber);  
  

Thanks nemik,
Works like a charm.
J.