00001 //----------------------------------------------------------------------------------- 00002 // 00003 // Pro-Vocation Light Engine (PVLE) 00004 // Copyright (C) 2007-2009 Sukender, KinoX & Buzib 00005 // For more information, contact us : sukender@free.fr 00006 // 00007 // This program is free software; you can redistribute it and/or modify 00008 // it under the terms of the GNU General Public License as published by 00009 // the Free Software Foundation; either version 3 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // For any use that is not compatible with the terms of the GNU 00013 // General Public License, please contact the authors for alternative 00014 // licensing options. 00015 // 00016 // This program is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU General Public License along 00022 // with this program; if not, write to the Free Software Foundation, Inc., 00023 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00024 // 00025 //----------------------------------------------------------------------------------- 00026 00027 #include <PVLE/Sound/Common.h> 00028 00029 //#include <PVLE/3D/Utility3D.h> 00030 //#include <PVLE/3D/CameraShake.h> 00031 00032 #ifdef PVLE_AUDIO 00033 # include <osgAL/SoundNode> 00034 # include <osgAL/SoundManager> 00035 //# include <osgAL/SoundState> 00036 //# include <PVLE/Sound/AutoSoundNodeCallback.h> 00037 # include <float.h> 00038 00039 osgAL::SoundNode * createStdSoundNode(const boost::filesystem::path & samplePath, unsigned int priority, float gain, bool useCache) { 00040 if (gain <= 0) return NULL; 00041 00042 openalpp::Sample * pSample; 00043 pSample = osgAL::SoundManager::instance()->getSample(samplePath.native_file_string(), useCache); 00044 osgAL::SoundState * pSoundState = new osgAL::SoundState(); 00045 if (!pSoundState->allocateSource(priority, false)) { 00046 // No available source 00047 return NULL; 00048 } 00049 pSoundState->setSample(pSample); 00050 pSoundState->setPlay(true); 00051 pSoundState->setLooping(false); 00052 pSoundState->setGain(gain); 00053 pSoundState->setAmbient(false); 00054 00055 pSoundState->setReferenceDistance(1); // Min distance (if clamped) 00056 pSoundState->setMaxDistance(FLT_MAX); // Max distance 00057 //pSoundState->setRolloffFactor(.01f); 00058 pSoundState->setRolloffFactor(.001f); 00059 pSoundState->apply(); 00060 00061 // Add the soundstate to the sound manager, so we can find it later on if we want to 00062 //osgAL::SoundManager::instance()->addSoundState(pSoundState); 00063 00064 osgAL::SoundNode * pNode = new osgAL::SoundNode(pSoundState); 00065 return pNode; 00066 } 00067 00068 #endif // PVLE_AUDIO