| 791 | //----------------------------------------------------------------------------- |
| 792 | |
| 793 | void SFXSource::_updateVolume( const MatrixF& listener ) |
| 794 | { |
| 795 | if (!mDescription) |
| 796 | return; |
| 797 | |
| 798 | // Handle fades (compute mFadedVolume). |
| 799 | |
| 800 | mFadedVolume = mPreFadeVolume; |
| 801 | if( mFadeSegmentType != FadeSegmentNone ) |
| 802 | { |
| 803 | // We have a temporary fade segment. |
| 804 | |
| 805 | F32 elapsed; |
| 806 | if( mDescription->mIsLooping && !mDescription->mFadeLoops ) |
| 807 | elapsed = getElapsedPlayTime(); |
| 808 | else |
| 809 | elapsed = getElapsedPlayTimeCurrentCycle(); |
| 810 | |
| 811 | if( elapsed < mFadeSegmentEndPoint ) |
| 812 | { |
| 813 | const F32 duration = mFadeSegmentEndPoint - mFadeSegmentStartPoint; |
| 814 | |
| 815 | if( mFadeSegmentType == FadeSegmentPlay ) |
| 816 | { |
| 817 | const F32 time = elapsed - mFadeSegmentStartPoint; |
| 818 | mFadedVolume = mFadeSegmentEase->getValue |
| 819 | ( time, 0.f, mPreFadeVolume, duration ); |
| 820 | } |
| 821 | else |
| 822 | { |
| 823 | // If the end-point to the ease functions is 0, |
| 824 | // we'll always get out the start point. Thus do the whole |
| 825 | // thing backwards here. |
| 826 | |
| 827 | const F32 time = mFadeSegmentEndPoint - elapsed; |
| 828 | mFadedVolume = mFadeSegmentEase->getValue |
| 829 | ( time, 0.f, mPreFadeVolume, duration ); |
| 830 | } |
| 831 | } |
| 832 | else |
| 833 | { |
| 834 | // The fade segment has played. Remove it. |
| 835 | |
| 836 | switch( mFadeSegmentType ) |
| 837 | { |
| 838 | case FadeSegmentStop: |
| 839 | stop( 0.f ); |
| 840 | break; |
| 841 | |
| 842 | case FadeSegmentPause: |
| 843 | pause( 0.f ); |
| 844 | break; |
| 845 | |
| 846 | case FadeSegmentPlay: // Nothing to do. |
| 847 | default: |
| 848 | break; |
| 849 | } |
| 850 |
nothing calls this directly
no test coverage detected