int main() { SoundEnvironment e; e.mainLoop(); return 0; }
extern "C" void sigproc(int signal_number) { DisplaySystem* ds = SystemManager::instance()->getDisplaySystem(); // Explicitly kill sound server SoundEnvironment* se = Engine::instance()->getSoundEnvironment(); if(se != NULL) { se->getSoundManager()->stopAllSounds(); se->getSoundManager()->cleanupAllSounds(); } ds->killCluster(); osleep(2000); }
SoundTest() { //soundManager = new SoundManager(); //soundManager->connectToServer("localhost",57120); // More concise method of above two lines soundManager = new SoundManager("localhost",57120); soundManager->showDebugInfo(true); // Get default sound environment env = soundManager->getSoundEnvironment(); while( !soundManager->isSoundServerRunning() ) { soundManager->startSoundServer(); } // Load sound assets //env->setAssetDirectory("menu_sounds"); showMenuSound = env->loadSoundFromFile("showMenuSound","menu_sounds/menu_load.wav"); hideMenuSound = env->loadSoundFromFile("hideMenuSound","menu_sounds/menu_closed.wav"); scrollMenuSound = env->loadSoundFromFile("scrollMenuSound","menu_sounds/menu_scroll.wav"); selectMenuSound = env->loadSoundFromFile("selectMenuSound","menu_sounds/menu_select.wav"); soundLoop = env->loadSoundFromFile("mus","Omega4Relay.wav"); SoundInstance* soundInstance = new SoundInstance(showMenuSound); soundInstance->setReverb( 1.0, 1.0 ); soundInstance->setVolume(1.0); soundInstance->setPosition( Vector3f(0,1,0) ); soundInstance->play(); rewindingSoundInstance = new SoundInstance(showMenuSound); }
void HelloApplication::handleEvent(const Event& evt) { if(evt.getServiceType() == Service::Wand) { xPos = evt.getPosition().x(); yPos = evt.getPosition().y(); zPos = evt.getPosition().z(); if( soundLoopInst != NULL ) soundLoopInst->setPosition( evt.getPosition() ); if( evt.getType() == Event::Down ) { if( evt.getFlags() == Event::Button3 ) // Wand cross button { // playStereo() is for ambient music. // Currently available functions: // setVolume(float) - amplitude from (0.0 - 1.0) // setLoop(bool) // stop() - this means this instance is finished and a new // sound instance will need to be created to play SoundInstance* musicInst = new SoundInstance(music); musicInst->setVolume(0.2f); musicInst->playStereo(); } else if( evt.getFlags() == Event::Button5 ) // Wand L1 { env->getSoundManager()->stopAllSounds(); } else if( evt.getFlags() == Event::ButtonLeft ) // DPad { SoundInstance* soundInst = new SoundInstance(sound); soundInst->setPosition( evt.getPosition() ); soundInst->play(); changeCubeColor = true; } else if( evt.getFlags() == Event::ButtonRight ) // DPad { if( soundLoopInst != NULL || !soundLoopInst->isPlaying() ) { // Positional sounds use play() // Currently available functions: // stop() - this means this instance is finished and a new // sound instance will need to be created to play // setPosition(Vector3f) // setVolume(float) - amplitude from (0.0 - 1.0) // setLoop(bool) // setMix(float) - wetness of sound (0.0 - 1.0) // setReverb(float) - room size / reverb amount (0.0 - 1.0) // setWidth(int) - number of speakers to spread sound across (1-20) // This will eventually be replaced with a sound radius soundLoopInst = new SoundInstance(sound1); soundLoopInst->setPosition( evt.getPosition() ); soundLoopInst->setLoop(true); soundLoopInst->setVolume(0.2f); soundLoopInst->setWidth(3); soundLoopInst->play(); } else if( soundLoopInst != NULL ) { soundLoopInst->stop(); } changeCubeColor = true; } else { SoundInstance* soundInst = new SoundInstance(sound); soundInst->setPosition( evt.getPosition() ); soundInst->setRoomSize(1.0); soundInst->setWetness(1.0); //soundInst->setVolume(0.5); soundInst->play(); changeCubeColor = true; } } else if( evt.getType() == Event::Up ) { changeCubeColor = false; } } }
void update() { soundManager->poll(); env->setListenerPosition( Vector3f(0,0,0) ); }
void MenuManager::initialize() { // Create the ui module if one is not available already myUiModule = UiModule::createAndInitialize(); if(SystemManager::settingExists("config/ui")) { Setting& sUi = SystemManager::settingLookup("config/ui"); myRayPlaceEnabled = Config::getBoolValue("menuRayPlaceEnabled", sUi, myRayPlaceEnabled); myDefaultMenuPosition = Config::getVector3fValue("menuDefaultPosition", sUi, myDefaultMenuPosition); myDefaultMenuScale = Config::getFloatValue("menuDefaultScale", sUi, myDefaultMenuScale); my3dMenuEnabled = Config::getBoolValue("menu3dEnabled", sUi, true); myNavigationSuspended = Config::getBoolValue("menuSuspendNavigation", sUi, myNavigationSuspended); myMenuInteractorId = Config::getIntValue("menuWandId", sUi, -1); // Parse menu toggle button name (if present) String toggleButtonName = Config::getStringValue("menuToggleButton", sUi, ""); if(toggleButtonName != "") { myMenuToggleButton = Event::parseButtonName(toggleButtonName); myUseMenuToggleButton = true; } myDefaultMenuScale *= 0.001f; } // See if we have a sound environment available. // If we don't it means sounds are disabled OR we are not the master node. SoundEnvironment* se = getEngine()->getSoundEnvironment(); if(se != NULL) { if(SystemManager::settingExists("config/sound")) { Setting& sUi = SystemManager::settingLookup("config/sound"); float volume = Config::getFloatValue("menuSoundVolume", sUi, 0.2f); float width = Config::getFloatValue("menuSoundWidth", sUi, 2.0); float mix = Config::getFloatValue("menuSoundMix", sUi, 0.0); float reverb = Config::getFloatValue("menuSoundReverb", sUi, 0.0); if( sUi.exists("showMenuSound") ){ //myShowMenuSound = se->createSound("showMenuSound"); //myShowMenuSound->loadFromFile( Config::getStringValue("showMenuSound", sUi ) ); myShowMenuSound = se->loadSoundFromFile("showMenuSound", Config::getStringValue("showMenuSound", sUi )); myShowMenuSound->setDefaultParameters(volume, width, mix, reverb, false, false); // Played from Menu class } if( sUi.exists("hideMenuSound") ){ //myHideSoundMenu = se->createSound("hideMenuSound"); //myHideSoundMenu->loadFromFile( Config::getStringValue("hideMenuSound", sUi ) ); myHideSoundMenu = se->loadSoundFromFile("hideMenuSound", Config::getStringValue("hideMenuSound", sUi )); myHideSoundMenu->setDefaultParameters(volume, width, mix, reverb, false, false); // Played from Menu class } if( sUi.exists("selectMenuSound") ){ //selectMenuSound = se->createSound("selectMenuSound"); //selectMenuSound->loadFromFile( Config::getStringValue("selectMenuSound", sUi ) ); selectMenuSound = se->loadSoundFromFile("selectMenuSound", Config::getStringValue("selectMenuSound", sUi )); selectMenuSound->setDefaultParameters(volume, width, mix, reverb, false, false); // Played from Button class } if( sUi.exists("scrollMenuSound") ){ //scrollMenuSound = se->createSound("scrollMenuSound"); //scrollMenuSound->loadFromFile( Config::getStringValue("scrollMenuSound", sUi ) ); scrollMenuSound = se->loadSoundFromFile("scrollMenuSound", Config::getStringValue("scrollMenuSound", sUi )); scrollMenuSound->setDefaultParameters(volume, width, mix, reverb, false, false); // Played from Widget class } } } // Read configuration parameters from system config //Setting& sSysCfg = SystemManager::instance()->getSystemConfig()->lookup("config"); //myMenu3dEnabled = Config::getBoolValue("menu3dEnabled", sSysCfg, false);nMenu //myMenu3dEnabled = true; //if(myMenu3dEnabled) //{ // myAutoPlaceEnabled = true; // myAutoPlaceDistance = Config::getFloatValue("menu3dDistance", sSysCfg, myAutoPlaceDistance); // myMenu3dScale = Config::getFloatValue("menu3dScale", sSysCfg, myMenu3dScale); //} }