Table of Contents

Wwise SDK 2018.1.11
AkFXTailHandler.h
Go to the documentation of this file.
1 /*******************************************************************************
2 The content of this file includes portions of the AUDIOKINETIC Wwise Technology
3 released in source code form as part of the SDK installer package.
4 
5 Commercial License Usage
6 
7 Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
8 may use this file in accordance with the end user license agreement provided
9 with the software or, alternatively, in accordance with the terms contained in a
10 written agreement between you and Audiokinetic Inc.
11 
12 Apache License Usage
13 
14 Alternatively, this file may be used under the Apache License, Version 2.0 (the
15 "Apache License"); you may not use this file except in compliance with the
16 Apache License. You may obtain a copy of the Apache License at
17 http://www.apache.org/licenses/LICENSE-2.0.
18 
19 Unless required by applicable law or agreed to in writing, software distributed
20 under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
21 OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
22 the specific language governing permissions and limitations under the License.
23 
24  Version: <VERSION> Build: <BUILDNUMBER>
25  Copyright (c) <COPYRIGHTYEAR> Audiokinetic Inc.
26 *******************************************************************************/
27 
28 #ifndef _AKFXTAILHANDLER_H_
29 #define _AKFXTAILHANDLER_H_
30 
34 
35 /// Default value when effect has not enterred tail mode yet.
36 #define AKFXTAILHANDLER_NOTINTAIL 0xFFFFFFFF
37 
38 /// Effect tail handling utility class.
39 /// Handles varying number of tail frames from frame to frame (i.e. based on RTPC parameters).
40 /// Handles effect revived (quit tail) and reenters etc.
42 {
43 public:
44  /// Constructor
45  inline AkFXTailHandler()
47  , uTotalTailFrames(0) {}
48 
49  /// Handle FX tail and zero pads AkAudioBuffer if necessary
50  inline void HandleTail(
51  AkAudioBuffer * io_pBuffer,
52  AkUInt32 in_uTotalTailFrames )
53  {
54  bool bPreStop = io_pBuffer->eState == AK_NoMoreData;
55  if ( bPreStop )
56  {
57  // Tail not yet finished processing
58  if ( uTailFramesRemaining > 0
59  || io_pBuffer->uValidFrames > 0 // <-- there are valid frames, so last (maybe partially filled) buffer.
60  )
61  {
62  // Not previously in tail, compute tail time
64  || io_pBuffer->uValidFrames > 0 // <- ANY valid frames in the buffer should reset the tail.
65  )
66  {
67  uTailFramesRemaining = in_uTotalTailFrames;
68  uTotalTailFrames = in_uTotalTailFrames;
69  }
70  // Tail time changed, augment if necessary but preserve where we are so that effect will
71  // still finish when constantly changing this based on RTPC parameters
72  else if ( in_uTotalTailFrames > uTotalTailFrames )
73  {
75  uTailFramesRemaining = in_uTotalTailFrames - uFramesElapsed;
76  uTotalTailFrames = in_uTotalTailFrames;
77  }
78  // Always full buffers while in tail
79  AkUInt32 uNumTailFrames = (AkUInt32)(io_pBuffer->MaxFrames()-io_pBuffer->uValidFrames);
80  uTailFramesRemaining -= AkMin( uTailFramesRemaining, uNumTailFrames );
81  io_pBuffer->ZeroPadToMaxFrames();
82  if ( uTailFramesRemaining > 0 )
83  io_pBuffer->eState = AK_DataReady;
84  }
85  }
86  else
87  {
88  // Reset tail mode for next time if exits tail mode (on bus only)
90  }
91  }
92 
93  inline bool HasTailRemaining() { return uTailFramesRemaining > 0; } // Also true when AKFXTAILHANDLER_NOTINTAIL
94 
95 protected:
96 
97  AkUInt32 uTailFramesRemaining; // AKFXTAILHANDLER_NOTINTAIL, otherwise value represents number of frames remaining in tail
99 
100 } AK_ALIGN_DMA;
101 
102 
103 
104 
105 
106 #endif // _AKFXTAILHANDLER_H_
AkFXTailHandler()
Constructor.
Definition: AkFXTailHandler.h:45
void HandleTail(AkAudioBuffer *io_pBuffer, AkUInt32 in_uTotalTailFrames)
Handle FX tail and zero pads AkAudioBuffer if necessary.
Definition: AkFXTailHandler.h:50
AkUInt16 uValidFrames
Number of valid sample frames in the audio buffer.
Definition: AkCommonDefs.h:463
AkForceInline AkUInt16 MaxFrames() const
Definition: AkCommonDefs.h:461
AKRESULT eState
Execution status.
Definition: AkCommonDefs.h:454
AkUInt32 uTotalTailFrames
Definition: AkFXTailHandler.h:98
#define AKFXTAILHANDLER_NOTINTAIL
Default value when effect has not enterred tail mode yet.
Definition: AkFXTailHandler.h:36
bool HasTailRemaining()
Definition: AkFXTailHandler.h:93
#define AkMin(x1, x2)
Definition: AkPlatformFuncs.h:94
No more data is available from the source.
Definition: AkTypes.h:145
uint32_t AkUInt32
Unsigned 32-bit integer.
Definition: AkTypes.h:79
void ZeroPadToMaxFrames()
Definition: AkCommonDefs.h:384
AkUInt32 uTailFramesRemaining
Definition: AkFXTailHandler.h:97
class AkFXTailHandler AK_ALIGN_DMA
The provider has available data.
Definition: AkTypes.h:173