Talk About Network



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 > need sound fadi...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 637 of 670
Post > Topic >>

need sound fading algorithm please

by Bill <Bill@[EMAIL PROTECTED] > Aug 7, 2007 at 12:06 PM

Hi,

I have written a small c++ audio library that supports basic 
functionality including linear fading in and out of gain. I would like 
to implement logarithmic fading instead of linear but I do not know how 
to go about it. Here is the update fade function which gets called on 
every frame, can anyone suggest some code I can use to replace my linear 
solution?, thanks


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 ) ) );
    }
}




 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 Tue May 13 12:12:38 CDT 2008.