Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Gaming > Development Programming Algorithms > Re: need sound ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 637 of 679
Post > Topic >>

Re: need sound fading algorithm please

by Tom Plunket <gamedev@[EMAIL PROTECTED] > Aug 12, 2007 at 07:02 PM

Bill wrote:

> void Sound::Fade::Update( void )
> {
>      const double elapsedFadeTime( GetTickCount() - m_startTime );
> 
>      if( elapsedFadeTime > m_duration )
>      {
>          m_duration = 0;
>          m_currentGain = m_endGain;
>      }
>      else
>      {
>          m_currentGain = static_cast<float>( m_beginGain + ( ( 
> elapsedFadeTime / m_duration ) * ( m_endGain - m_beginGain ) ) );
>     }
> }

While not exactly logarithmic, you can get a similar effect by taking
the square root of m_currentGain, assuming it's in the range of [0, 1]
(Where 0 means "no sound" and 1 means "full loudness").

Otherwise, you can just call logf with m_currentGain and be done with
it, but I'm not familiar with that function or its arguments, plus you'd
need some sort of offset to make it work, since log_n(0) is undefined.

Good luck.

-tom!

--
 




 2 Posts in Topic:
need sound fading algorithm please
Bill <Bill@[EMAIL PROT  2007-08-07 12:06:42 
Re: need sound fading algorithm please
Tom Plunket <gamedev@[  2007-08-12 19:02:23 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 18 19:39:12 CDT 2008.