//-------------------------------------------------------------- void SoundManager::setup(ofxXmlSettings& settings) { m_driver = settings.getValue("murmur:soundOutput:driver", 0); printf("- setting sound output driver [%d]\n", m_driver); ofFmodSelectDriver(m_driver); m_driver = ofFmodGetDriverSelected(); printf("- selected driver is [%d]\n", m_driver); int nbOutputs = settings.getValue("murmur:soundOutput:nbSpeakers", 2); printf("- setting sound output for %d speakers\n", nbOutputs); ofFmodSetNumOutputs( nbOutputs ); settings.pushTag("murmur"); settings.pushTag("soundOutput"); settings.pushTag("soundMain"); int nbSpeakers = settings.getNumTags("speaker"); mp_soundMainSpeakers = new int[nbSpeakers]; for (int i=0;i<nbSpeakers;i++) { mp_soundMainSpeakers[i] = settings.getValue("speaker",0,i); printf("- adding for sound main speaker [%d]\n", i); } m_nbSoundMainSpeakers = nbSpeakers; settings.popTag(); settings.popTag(); string soundMainFile = settings.getAttribute("murmur:soundOutput:soundMain","file", "main.wav"); printf("- sound main is [%s]\n", soundMainFile.c_str()); ofDirectory dirSounds("Sounds"); if (dirSounds.exists()) { dirSounds.listDir(); printf("DIR %s [%d file(s)]\n", dirSounds.path().c_str(),dirSounds.size()); vector<ofFile> files = dirSounds.getFiles(); vector<ofFile>::iterator it; for (it = files.begin(); it != files.end(); ++it) { if ((*it).getExtension() == "mp3" || (*it).getExtension() == "wav") { string filename = (*it).getFileName(); printf("- [%s]\n", filename.c_str()); SoundPlayer* pSoundPlayer = new SoundPlayer(filename); pSoundPlayer->loadSound( "Sounds/"+filename ); pSoundPlayer->setLoop(false); pSoundPlayer->setMultiPlay(true); m_listSoundPlayer.push_back( pSoundPlayer ); } } } mp_soundMain = getSoundPlayer(soundMainFile); }
//-------------------------------------------------------------- void SoundManager::setup(ofxXmlSettings& settings) { OFAPPLOG->begin("SoundManager::setup()"); m_driver = settings.getValue("murmur:soundOutput:driver", 0); OFAPPLOG->println(" - setting sound output driver ["+ofToString(m_driver)+"]"); ofFmodSelectDriver(m_driver); m_driver = ofFmodGetDriverSelected(); OFAPPLOG->println(" - selected driver is "+ofToString(m_driver)); int nbOutputs = settings.getValue("murmur:soundOutput:nbSpeakers", 2); OFAPPLOG->println(" - setting sound output for "+ofToString(nbOutputs)+" speaker(s)"); ofFmodSetNumOutputs( nbOutputs ); settings.pushTag("murmur"); settings.pushTag("soundOutput"); settings.pushTag("soundMain"); int nbSpeakers = settings.getNumTags("speaker"); mp_soundMainSpeakers = new int[nbSpeakers]; for (int i=0;i<nbSpeakers;i++) { mp_soundMainSpeakers[i] = settings.getValue("speaker",0,i); OFAPPLOG->println(" - adding for sound main speaker ["+ofToString(i)+"]"); } m_nbSoundMainSpeakers = nbSpeakers; settings.popTag(); settings.popTag(); string soundMainFile = settings.getAttribute("murmur:soundOutput:soundMain","file", "main.wav"); OFAPPLOG->println(" - sound main is '"+soundMainFile+"'"); ofDirectory dirSounds("Sounds"); if (dirSounds.exists()) { dirSounds.listDir(); OFAPPLOG->println(" - DIR is '"+dirSounds.path()+"' ["+ofToString(dirSounds.size())+" file(s)]"); vector<ofFile> files = dirSounds.getFiles(); vector<ofFile>::iterator it; string strFileNames = ""; string strFileNamesSep = ""; for (it = files.begin(); it != files.end(); ++it) { if ((*it).getExtension() == "mp3" || (*it).getExtension() == "wav") { string filename = (*it).getFileName(); strFileNames += strFileNamesSep + filename; SoundPlayer* pSoundPlayer = new SoundPlayer(filename); pSoundPlayer->loadSound( "Sounds/"+filename ); pSoundPlayer->setLoop(false); pSoundPlayer->setMultiPlay(true); m_listSoundPlayer.push_back( pSoundPlayer ); strFileNamesSep = ", "; } } OFAPPLOG->println(" - FILES are '"+strFileNames+"'"); } mp_soundMain = getSoundPlayer(soundMainFile); OFAPPLOG->end(); }