void MixDeviceComposite::update() { long volAvg; volAvg = calculateVolume( Volume::PlaybackVT ); _compositePlaybackVolume->setAllVolumes(volAvg); volAvg = calculateVolume( Volume::CaptureVT ); // _compositeCaptureVolume->setAllVolumes(volAvg); }
Mesh::Mesh(string filename, bool ccw): mRot(0,0,0), mPos(0,0,0), mAABB(BVL_SIZE(BVL)), mAABBTriangles(BVL_SIZE(BVL)), mSphere(BVL_SIZE(BVL)), mSphereTriangles(BVL_SIZE(BVL)) { clock_t t = clock(); loadObj(filename, mVertices, mTriangles, ccw); createTriangleLists(); createBoundingVolHierarchy(); centerAlign(); createNormals(); calculateVolume(); printf ("Mesh loading took:\t%4.2f sec | %d triangles \n", ((float)clock()-t)/CLOCKS_PER_SEC, mTriangles.size()); for (int blevel=0; blevel<=BVL; blevel++) printf("Coverage Level %d: AABB %4.2f%%, Sphere %4.2f%% \n", blevel, 100*AABBCover[blevel], 100*sphereCover[blevel]); }
//------------------------------------------------------------------------------ void SoundSystem::updateCurrentSoundScene(const Vector3& _listenerPosition, const Quaternion& _listenerOrientation, Real _timeSinceLastUpdate) { // Suppose all the sounds' spheres are outside the listener's position SoundPlayInfos::iterator it; for(it = mSoundPlayInfos.begin(); it != mSoundPlayInfos.end(); ++it) { SoundPlayInfo* cp = &*it; cp->oldAllowedToPlay = cp->allowedToPlay; cp->allowedToPlay = false; // the enumerateSphereIntersects function cp->enumerated = false; // will set them to true for all sounds which can be listen } // Search sounds' spheres which are enabled and contain the listener's position; // i.e. search sounds which can be listened mCurrentSoundScene->bst.findSphereIntersects( Sphere(_listenerPosition, mPadding), this, const_cast<Vector3*>(&_listenerPosition)); // Checks number of sounds which are allowed to play, // and, if the number is too many, disallows sounds // with minimal priority. restrictNumAllowedToPlay(); // For each sound near the listener... it = mSoundPlayInfos.begin(); while(it != mSoundPlayInfos.end()) { SoundPlayInfo* cp = &(*it++); Sound* sound = cp->sound; cp->waitTime -= _timeSinceLastUpdate; // Processing moving of the sound relative to the listener bool allowChanged = (cp->allowedToPlay != cp->oldAllowedToPlay); if(cp->allowedToPlay) processPlayAllowance(cp, allowChanged); else processPlayDisallowance(cp, allowChanged); // Recalculate the volume of the sound calculateVolume(cp, _timeSinceLastUpdate); // The end of the sound track could be reached, process if(isSoundEnded(cp)) processSoundEnd(cp); // We can stop unlistenable sounds. if(cp->finalVolume == 0) stop(cp); // We can remove information about unlistenable sounds. if(cp->playContext.isNull() && !cp->allowedToPlay) { bool canRemovePI = false; if(!cp->enabled || !sound->mEnabled) canRemovePI = true; else if(!cp->enumerated) canRemovePI = true; else if(sound->mLoopMode == SoundLoopMode::PLAY_ONCE && sound->mNumPlayed != 0) canRemovePI = true; if(canRemovePI) removeSoundPlayInfo(cp); } } }