버전
menu_open
link

include/AK/Plugin/PluginServices/AkFXTailHandler.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 #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     inline bool HasTailRemaining() { return uTailFramesRemaining > 0; } // Also true when AKFXTAILHANDLER_NOTINTAIL
00094 
00095 protected:
00096 
00097     AkUInt32    uTailFramesRemaining; // AKFXTAILHANDLER_NOTINTAIL, otherwise value represents number of frames remaining in tail
00098     AkUInt32    uTotalTailFrames;
00099     
00100 } AK_ALIGN_DMA;
00101 
00102 
00103 
00104 
00105 
00106 #endif // _AKFXTAILHANDLER_H_

이 페이지가 도움이 되었나요?

지원이 필요하신가요?

질문이 있으신가요? 문제를 겪고 계신가요? 더 많은 정보가 필요하신가요? 저희에게 문의해주시면 도와드리겠습니다!

지원 페이지를 방문해 주세요

작업하는 프로젝트에 대해 알려주세요. 언제든지 도와드릴 준비가 되어 있습니다.

프로젝트를 등록하세요. 아무런 조건이나 의무 사항 없이 빠른 시작을 도와드리겠습니다.

Wwise를 시작해 보세요