Version

menu_open

include/AK/Plugin/PluginServices/AkValueRamp.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 The content of this file includes portions of the AUDIOKINETIC Wwise Technology
00003 released in source code form as part of the SDK installer package.
00004 
00005 Commercial License Usage
00006 
00007 Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
00008 may use this file in accordance with the end user license agreement provided 
00009 with the software or, alternatively, in accordance with the terms contained in a
00010 written agreement between you and Audiokinetic Inc.
00011 
00012 Apache License Usage
00013 
00014 Alternatively, this file may be used under the Apache License, Version 2.0 (the 
00015 "Apache License"); you may not use this file except in compliance with the 
00016 Apache License. You may obtain a copy of the Apache License at 
00017 http://www.apache.org/licenses/LICENSE-2.0.
00018 
00019 Unless required by applicable law or agreed to in writing, software distributed
00020 under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
00021 OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
00022 the specific language governing permissions and limitations under the License.
00023 
00024   Version: <VERSION>  Build: <BUILDNUMBER>
00025   Copyright (c) <COPYRIGHTYEAR> Audiokinetic Inc.
00026 *******************************************************************************/
00027 
00028 // AkValueRamp.h
00029 
00032 
00033 #ifndef _AK_VALUERAMP_H_
00034 #define _AK_VALUERAMP_H_
00035 
00036 #include <AK/SoundEngine/Common/AkTypes.h>
00037 #include <AK/Tools/Common/AkAssert.h>
00038 #include <math.h>
00039 
00040 namespace AK
00041 {
00042 
00049     class CAkValueRamp
00050     {
00051     public:
00052 
00054         CAkValueRamp() :
00055         m_fStepIncrement( 0.f ),    // Step increment sign
00056             m_fInc( 0.f ),          // Signed increment
00057             m_fTarget( 0.f ),       // Target gain for ramping
00058             m_fCurrent( 0.f ),      // Current interpolated value
00059             m_uRampCount( 0 ),      // Position in interpolation ramp
00060             m_uRampLength( 0 )      // Total duration of interpolation ramp
00061         {
00062         }
00063 
00065         ~CAkValueRamp()
00066         {
00067         }
00068 
00070         inline void RampSetup( 
00071             AkReal32 fStepIncrement,    
00072             AkReal32 fInitVal           
00073             )
00074         {
00075             AKASSERT( fStepIncrement > 0.f );
00076             m_fStepIncrement = fStepIncrement;
00077             m_fCurrent = fInitVal;
00078             SetTarget( fInitVal );
00079         }
00080 
00082         AkForceInline void SetTarget( 
00083             AkReal32 fTarget        
00084             ) 
00085         {
00086             m_fTarget = fTarget;
00087             m_uRampCount = 0;
00088             AkReal32 fDiff = m_fTarget - m_fCurrent;
00089             m_uRampLength = static_cast<AkUInt32>( fabs(fDiff) / m_fStepIncrement );
00090             m_fInc = fDiff > 0 ? m_fStepIncrement : -m_fStepIncrement;
00091         }
00092 
00095         AkForceInline AkReal32 Tick()
00096         {
00097             if ( m_uRampCount >= m_uRampLength )
00098                 m_fCurrent = m_fTarget;
00099             else
00100             {
00101                 ++m_uRampCount;
00102                 m_fCurrent += m_fInc;
00103             }
00104             return m_fCurrent;
00105         }
00106         
00109         AkReal32 GetCurrent()                       { return m_fCurrent; }
00110         
00112         void SetCurrent(AkReal32 in_fCurrent)       { m_fCurrent = in_fCurrent; }
00113 
00116         AkUInt32 GetRampCount()                     { return m_uRampCount; }
00117 
00119         void SetRampCount(AkUInt32 in_uRampCount)   { m_uRampCount = in_uRampCount; }
00120 
00122         void StopRamp()
00123         {
00124             m_fCurrent = m_fTarget;
00125             m_uRampCount = m_uRampLength;
00126         }
00127 
00128     private:
00129 
00130         AkReal32            m_fStepIncrement;       // Step increment size
00131         AkReal32            m_fInc;                 // Signed increment
00132         AkReal32            m_fTarget;              // Target for interpolation ramp
00133         AkReal32            m_fCurrent;             // Current interpolated value
00134         AkUInt32            m_uRampCount;           // Position in interpolation ramp
00135         AkUInt32            m_uRampLength;          // Total duration of interpolation ramp
00136     } AK_ALIGN_DMA;
00137 }
00138 
00139 #endif  //_AK_VALUERAMP_H_

Cette page a-t-elle été utile ?

Besoin d'aide ?

Des questions ? Des problèmes ? Besoin de plus d'informations ? Contactez-nous, nous pouvons vous aider !

Visitez notre page d'Aide

Décrivez-nous de votre projet. Nous sommes là pour vous aider.

Enregistrez votre projet et nous vous aiderons à démarrer sans aucune obligation !

Partir du bon pied avec Wwise