Version
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 #ifndef _AKFXTAILHANDLER_H_ 00029 #define _AKFXTAILHANDLER_H_ 00030 00031 #include <AK/SoundEngine/Common/AkTypes.h> 00032 #include <AK/SoundEngine/Common/AkCommonDefs.h> 00033 #include <AK/Tools/Common/AkPlatformFuncs.h> 00034 00035 /// Default value when effect has not enterred tail mode yet. 00036 #define AKFXTAILHANDLER_NOTINTAIL 0xFFFFFFFF 00037 00038 /// Effect tail handling utility class. 00039 /// Handles varying number of tail frames from frame to frame (i.e. based on RTPC parameters). 00040 /// Handles effect revived (quit tail) and reenters etc. 00041 class AkFXTailHandler 00042 { 00043 public: 00044 /// Constructor 00045 inline AkFXTailHandler() 00046 : uTailFramesRemaining( AKFXTAILHANDLER_NOTINTAIL ) 00047 , uTotalTailFrames(0) {} 00048 00049 /// Handle FX tail and zero pads AkAudioBuffer if necessary 00050 inline void HandleTail( 00051 AkAudioBuffer * io_pBuffer, 00052 AkUInt32 in_uTotalTailFrames ) 00053 { 00054 bool bPreStop = io_pBuffer->eState == AK_NoMoreData; 00055 if ( bPreStop ) 00056 { 00057 // Tail not yet finished processing 00058 if ( uTailFramesRemaining > 0 00059 || io_pBuffer->uValidFrames > 0 // <-- there are valid frames, so last (maybe partially filled) buffer. 00060 ) 00061 { 00062 // Not previously in tail, compute tail time 00063 if (uTailFramesRemaining == AKFXTAILHANDLER_NOTINTAIL 00064 || io_pBuffer->uValidFrames > 0 // <- ANY valid frames in the buffer should reset the tail. 00065 ) 00066 { 00067 uTailFramesRemaining = in_uTotalTailFrames; 00068 uTotalTailFrames = in_uTotalTailFrames; 00069 } 00070 // Tail time changed, augment if necessary but preserve where we are so that effect will 00071 // still finish when constantly changing this based on RTPC parameters 00072 else if ( in_uTotalTailFrames > uTotalTailFrames ) 00073 { 00074 AkUInt32 uFramesElapsed = uTotalTailFrames - uTailFramesRemaining; 00075 uTailFramesRemaining = in_uTotalTailFrames - uFramesElapsed; 00076 uTotalTailFrames = in_uTotalTailFrames; 00077 } 00078 // Always full buffers while in tail 00079 AkUInt32 uNumTailFrames = (AkUInt32)(io_pBuffer->MaxFrames()-io_pBuffer->uValidFrames); 00080 uTailFramesRemaining -= AkMin( uTailFramesRemaining, uNumTailFrames ); 00081 io_pBuffer->ZeroPadToMaxFrames(); 00082 if ( uTailFramesRemaining > 0 ) 00083 io_pBuffer->eState = AK_DataReady; 00084 } 00085 } 00086 else 00087 { 00088 // Reset tail mode for next time if exits tail mode (on bus only) 00089 uTailFramesRemaining = AKFXTAILHANDLER_NOTINTAIL; 00090 } 00091 } 00092 00093 protected: 00094 00095 AkUInt32 uTailFramesRemaining; // AKFXTAILHANDLER_NOTINTAIL, otherwise value represents number of frames remaining in tail 00096 AkUInt32 uTotalTailFrames; 00097 00098 } AK_ALIGN_DMA; 00099 00100 00101 00102 00103 00104 #endif // _AKFXTAILHANDLER_H_
Questions? Problems? Need more info? Contact us, and we can help!
Visit our Support pageRegister your project and we'll help you get started with no strings attached!
Get started with Wwise