Use sound player to achieve “A Cappella”

Hello all!

These days I try to use openFrameworks to build a project like “A Cappella”. My idea is to use 5 sound player to control 5 instruments such as guitar, drums, bass and try to visualize them separated at last. However, I found it very difficult to analyze one of them separately. Whenever I put an instrument on it, the entire spectrum changes. I want to know if there is a way to analyze several sound inputs simultaneously in openFrameworks?

Another problem is that when I load several kinds of music in the setup() function, the final playback effect shows that there is a certain delay between different music, which destroys the originally designed timeline. How to solve this delay?

Here is some of my code, look forward to your reply and advice! Thanks! :wink:

void ofApp::setup(){
   ofBackground(31, 123, 216);
   
   mode = 0;
   
   //GUITAR================
   guitarEditor.setup();
   //set guitar as basic music
   guitarPlayer.load("MySong_guitar.mp3");
   // Set the song playing to a loop.
   guitarPlayer.setLoop(true);
   guitarPlayer_extended.setLoop(true);
   guitarPlayer.play();
   
   //CLAPS==================
   clapsEditor.setup();
   clapsPlayer.load("MySong_claps.mp3");
   clapsPlayer.setLoop(true);
   clapsPlayer_extended.setLoop(true);
   clapsPlayer.play();
   clapsPlayer.setVolume(0.0);
  
}

//--------------------------------------------------------------
void ofApp::update(){
   ofSoundUpdate();
   float * guitar_spectrumValue = ofSoundGetSpectrum(guitarEditor.getNumberOfBands());
   guitarEditor.update(guitar_spectrumValue);
   
   if(mode == 1){
       float * claps_spectrumValue = ofSoundGetSpectrum(clapsEditor.getNumberOfBands());
       clapsEditor.update(claps_spectrumValue);
   }
}

Hi,
I suggest you first load all the files, and then simultaneously call play();
The load() function takes some time, that leads to the delay.

   clapsPlayer.play();
   guitarPlayer.play(); // This starts them simultaneously as possible

And about the isolated FFT: ofSoundGetSpectrum() takes the sum of all your ofSoundPlayer objects, so that won’t work.
Here is an option you can try: Multiple FFTs/RMS

Thanks a lot Jildert!!! I used some functions of the soundPlayerObject addon and solved the problem now.:smiley: