Version

menu_open
Wwise SDK 2024.1.0
AkDynamicSequence.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  Copyright (c) 2024 Audiokinetic Inc.
25 *******************************************************************************/
26 
27 #ifndef _AK_SOUNDENGINE_AKDYNAMICSEQUENCE_H
28 #define _AK_SOUNDENGINE_AKDYNAMICSEQUENCE_H
29 
32 
33 class AkExternalSourceArray;
34 
35 namespace AK
36 {
37  namespace SoundEngine
38  {
39  /// Dynamic Sequence namespace. Use the Dynamic Sequence API to play and sequence Dialogue Events dynamically, according to a set of rules and conditions. For more information, refer to \ref integrating_elements_dynamicdialogue and <a href="https://www.audiokinetic.com/library/edge/?source=Help&id=understanding_dynamic_dialogue_system" target="_blank">Understanding the Dynamic Dialogue System</a>.
40  /// \remarks The functions in this namespace are thread-safe, unless stated otherwise.
41  namespace DynamicSequence
42  {
43  /// Playlist Item for Dynamic Sequence Playlist.
44  /// \sa
45  /// - AK::SoundEngine::DynamicSequence::Playlist
46  /// - AK::SoundEngine::PostEvent
47  /// - \ref integrating_external_sources
49  {
50  public:
52  PlaylistItem(const PlaylistItem& in_rCopy);
54 
55  PlaylistItem& operator=(const PlaylistItem& in_rCopy);
56  bool operator==(const PlaylistItem& in_rCopy)
57  {
58  AKASSERT(pExternalSrcs == NULL);
59  return audioNodeID == in_rCopy.audioNodeID &&
60  msDelay == in_rCopy.msDelay &&
61  pCustomInfo == in_rCopy.pCustomInfo;
62  };
63 
64  /// Sets the external sources used by this item.
65  /// \sa
66  /// \ref integrating_external_sources
67  AKRESULT SetExternalSources(AkUInt32 in_nExternalSrc, AkExternalSourceInfo* in_pExternalSrc);
68 
69  /// Get the external source array. Internal use only.
70  AkExternalSourceArray* GetExternalSources(){return pExternalSrcs;}
71 
72  AkUniqueID audioNodeID; ///< Unique ID of Audio Node
73  AkTimeMs msDelay; ///< Delay before playing this item, in milliseconds
74  void * pCustomInfo; ///< Optional user data
75 
76  private:
77  AkExternalSourceArray *pExternalSrcs;
78  };
79 
80  /// List of items to play in a Dynamic Sequence.
81  /// \sa
82  /// - AK::SoundEngine::DynamicSequence::LockPlaylist
83  /// - AK::SoundEngine::DynamicSequence::UnlockPlaylist
84  class Playlist
85  : public AkArray<PlaylistItem, const PlaylistItem&>
86  {
87  public:
88  /// Enqueue an Audio Node.
89  /// \return AK_Success if successful, AK_Fail otherwise
91  AkUniqueID in_audioNodeID, ///< Unique ID of Audio Node
92  AkTimeMs in_msDelay = 0, ///< Delay before playing this item, in milliseconds
93  void * in_pCustomInfo = NULL, ///< Optional user data
94  AkUInt32 in_cExternals = 0, ///< Optional count of external source structures
95  AkExternalSourceInfo *in_pExternalSources = NULL///< Optional array of external source resolution information
96  )
97  {
98  PlaylistItem * pItem = AddLast();
99  if ( !pItem )
100  return AK_InsufficientMemory;
101 
102  pItem->audioNodeID = in_audioNodeID;
103  pItem->msDelay = in_msDelay;
104  pItem->pCustomInfo = in_pCustomInfo;
105  return pItem->SetExternalSources(in_cExternals, in_pExternalSources);
106  }
107  };
108 
109  /// The DynamicSequenceType is specified when creating a new dynamic sequence.\n
110  /// \n
111  /// The default option is DynamicSequenceType_SampleAccurate. \n
112  /// \n
113  /// In sample accurate mode, when a dynamic sequence item finishes playing and there is another item\n
114  /// pending in its playlist, the next sound will be stitched to the end of the ending sound. In this \n
115  /// mode, if there are one or more pending items in the playlist while the dynamic sequence is playing,\n
116  /// or if something is added to the playlist during the playback, the dynamic sequence\n
117  /// can remove the next item to be played from the playlist and prepare it for sample accurate playback before\n
118  /// the first sound is finished playing. This mechanism helps keep sounds sample accurate, but then\n
119  /// you might not be able to remove that next item from the playlist if required.\n
120  /// \n
121  /// If your game requires the capability of removing the next to be played item from the\n
122  /// playlist at any time, then you should use the DynamicSequenceType_NormalTransition option instead.\n
123  /// In this mode, you cannot ensure sample accuracy between sounds.\n
124  /// \n
125  /// Note that a Stop or a Break will always prevent the next to be played sound from actually being played.
126  ///
127  /// \sa
128  /// - AK::SoundEngine::DynamicSequence::Open
130  {
131  DynamicSequenceType_SampleAccurate, ///< Sample accurate mode
132  DynamicSequenceType_NormalTransition, ///< Normal transition mode, allows the entire playlist to be edited at all times.
133  DynamicSequenceType_Last ///< End of enum, invalid value.
134  };
135 
136  /// Open a new Dynamic Sequence.
137  /// \return Playing ID of the dynamic sequence, or AK_INVALID_PLAYING_ID in failure case and an error message in the debug console and Wwise Profiler
138  ///
139  /// \sa
140  /// - AK::SoundEngine::DynamicSequence::DynamicSequenceType
142  AkGameObjectID in_gameObjectID, ///< Associated game object ID
143  AkUInt32 in_uFlags = 0, ///< Bitmask: see \ref AkCallbackType
144  AkCallbackFunc in_pfnCallback = NULL, ///< Callback function
145  void* in_pCookie = NULL, ///< Callback cookie that will be sent to the callback function along with additional information;
146  DynamicSequenceType in_eDynamicSequenceType = DynamicSequenceType_SampleAccurate ///< See : \ref AK::SoundEngine::DynamicSequence::DynamicSequenceType
147  );
148 
149  /// Close specified Dynamic Sequence. The Dynamic Sequence will play until finished and then
150  /// deallocate itself.
151  /// \return
152  /// - AK_Success if the command was successfully queued
153  /// - AK_PlayingIDNotFound if the playing ID does not match to any open Dynamic Sequence
155  AkPlayingID in_playingID ///< AkPlayingID returned by DynamicSequence::Open
156  );
157 
158  /// Play specified Dynamic Sequence.
159  /// \return
160  /// - AK_Success if the command was successfully queued
161  /// - AK_PlayingIDNotFound if the playing ID does not match to any open Dynamic Sequence
163  AkPlayingID in_playingID, ///< AkPlayingID returned by DynamicSequence::Open
164  AkTimeMs in_uTransitionDuration = 0, ///< Fade duration
165  AkCurveInterpolation in_eFadeCurve = AkCurveInterpolation_Linear ///< Curve type to be used for the transition
166  );
167 
168  /// Pause specified Dynamic Sequence.
169  /// To restart the sequence, call Resume. The item paused will resume its playback, followed by the rest of the sequence.
170  /// \return
171  /// - AK_Success if the command was successfully queued
172  /// - AK_PlayingIDNotFound if the playing ID does not match to any open Dynamic Sequence
174  AkPlayingID in_playingID, ///< AkPlayingID returned by DynamicSequence::Open
175  AkTimeMs in_uTransitionDuration = 0, ///< Fade duration
176  AkCurveInterpolation in_eFadeCurve = AkCurveInterpolation_Linear ///< Curve type to be used for the transition
177  );
178 
179  /// Resume specified Dynamic Sequence.
180  /// \return
181  /// - AK_Success if the command was successfully queued
182  /// - AK_PlayingIDNotFound if the playing ID does not match to any open Dynamic Sequence
184  AkPlayingID in_playingID, ///< AkPlayingID returned by DynamicSequence::Open
185  AkTimeMs in_uTransitionDuration = 0, ///< Fade duration
186  AkCurveInterpolation in_eFadeCurve = AkCurveInterpolation_Linear ///< Curve type to be used for the transition
187  );
188 
189  /// Stop specified Dynamic Sequence immediately.
190  /// To restart the sequence, call Play. The sequence will restart with the item that was in the
191  /// playlist after the item that was stopped.
192  /// \return
193  /// - AK_Success if the command was successfully queued
194  /// - AK_PlayingIDNotFound if the playing ID does not match to any open Dynamic Sequence
196  AkPlayingID in_playingID, ///< AkPlayingID returned by DynamicSequence::Open
197  AkTimeMs in_uTransitionDuration = 0, ///< Fade duration
198  AkCurveInterpolation in_eFadeCurve = AkCurveInterpolation_Linear ///< Curve type to be used for the transition
199  );
200 
201  /// Break specified Dynamic Sequence. The sequence will stop after the current item.
202  /// \return
203  /// - AK_Success if the command was successfully queued
204  /// - AK_PlayingIDNotFound if the playing ID does not match to any open Dynamic Sequence
206  AkPlayingID in_playingID ///< AkPlayingID returned by DynamicSequence::Open
207  );
208 
209  /// Seek inside specified Dynamic Sequence.
210  /// It is only possible to seek in the first item of the sequence.
211  /// If you seek past the duration of the first item, it will be skipped and an error will reported in the Capture Log and debug output.
212  /// All the other items in the sequence will continue to play normally.
213  /// \return
214  /// - AK_Success if the command was successfully queued
215  /// - AK_PlayingIDNotFound if the playing ID does not match to any open Dynamic Sequence
217  AkPlayingID in_playingID, ///< AkPlayingID returned by DynamicSequence::Open
218  AkTimeMs in_iPosition, ///< Position into the the sound, in milliseconds
219  bool in_bSeekToNearestMarker ///< Snap to the marker nearest to the seek position.
220  );
221 
222  /// Seek inside specified Dynamic Sequence.
223  /// It is only possible to seek in the first item of the sequence.
224  /// If you seek past the duration of the first item, it will be skipped and an error will reported in the Capture Log and debug output.
225  /// All the other items in the sequence will continue to play normally.
226  /// \return
227  /// - AK_Success if the command was successfully queued
228  /// - AK_PlayingIDNotFound if the playing ID does not match to any open Dynamic Sequence
230  AkPlayingID in_playingID, ///< AkPlayingID returned by DynamicSequence::Open
231  AkReal32 in_fPercent, ///< Position into the the sound, in percentage of the whole duration.
232  bool in_bSeekToNearestMarker ///< Snap to the marker nearest to the seek position.
233  );
234 
235  /// Get pause times.
236  /// \return
237  /// - AK_Success if successful
238  /// - AK_PlayingIDNotFound if the playing ID does not match to any open Dynamic Sequence
240  AkPlayingID in_playingID, ///< AkPlayingID returned by DynamicSequence::Open
241  AkUInt32 &out_uTime, ///< If sequence is currently paused, returns time when pause started, else 0.
242  AkUInt32 &out_uDuration ///< Returns total pause duration since last call to GetPauseTimes, excluding the time elapsed in the current pause.
243  );
244 
245  /// Get currently playing item. Note that this may be different from the currently heard item
246  /// when sequence is in sample-accurate mode.
247  /// \return
248  /// - AK_Success if successful
249  /// - AK_PlayingIDNotFound if the playing ID does not match to any open Dynamic Sequence
251  AkPlayingID in_playingID, ///< AkPlayingID returned by DynamicSequence::Open
252  AkUniqueID & out_audioNodeID, ///< Returned audio node ID of playing item.
253  void *& out_pCustomInfo ///< Returned user data of playing item.
254  );
255 
256  /// Lock the Playlist for editing. Needs a corresponding UnlockPlaylist call.
257  /// \return Pointer to locked Playlist if successful, NULL otherwise (in_playingID not found)
258  /// \sa
259  /// - AK::SoundEngine::DynamicSequence::UnlockPlaylist
261  AkPlayingID in_playingID ///< AkPlayingID returned by DynamicSequence::Open
262  );
263 
264  /// Unlock the playlist.
265  /// \return
266  /// - AK_Success if successful
267  /// - AK_PlayingIDNotFound if the playing ID does not match to any open Dynamic Sequence
268  /// \sa
269  /// - AK::SoundEngine::DynamicSequence::LockPlaylist
271  AkPlayingID in_playingID ///< AkPlayingID returned by DynamicSequence::Open
272  );
273  }
274  }
275 }
276 
277 #endif // _AK_SOUNDENGINE_AKDYNAMICSEQUENCE_H
AKSOUNDENGINE_API AKRESULT Stop(AkPlayingID in_playingID, AkTimeMs in_uTransitionDuration=0, AkCurveInterpolation in_eFadeCurve=AkCurveInterpolation_Linear)
AKRESULT SetExternalSources(AkUInt32 in_nExternalSrc, AkExternalSourceInfo *in_pExternalSrc)
AKSOUNDENGINE_API AKRESULT GetPlayingItem(AkPlayingID in_playingID, AkUniqueID &out_audioNodeID, void *&out_pCustomInfo)
@ DynamicSequenceType_Last
End of enum, invalid value.
AkInt32 AkTimeMs
Time in ms.
Definition: AkTypes.h:56
Definition of data structures for AkAudioObject.
AkUniqueID audioNodeID
Unique ID of Audio Node.
AkUInt64 AkGameObjectID
Game object ID.
Definition: AkTypes.h:60
#define AK_EXTERNAPIFUNC(_type, _name)
AkTimeMs msDelay
Delay before playing this item, in milliseconds.
AKRESULT
Standard function call result.
Definition: AkTypes.h:134
PlaylistItem & operator=(const PlaylistItem &in_rCopy)
AKSOUNDENGINE_API AKRESULT Resume(AkPlayingID in_playingID, AkTimeMs in_uTransitionDuration=0, AkCurveInterpolation in_eFadeCurve=AkCurveInterpolation_Linear)
Specific implementation of array.
Definition: AkArray.h:259
#define NULL
Definition: AkTypes.h:46
float AkReal32
32-bit floating point
AKSOUNDENGINE_API AKRESULT Pause(AkPlayingID in_playingID, AkTimeMs in_uTransitionDuration=0, AkCurveInterpolation in_eFadeCurve=AkCurveInterpolation_Linear)
PlaylistItem(const PlaylistItem &in_rCopy)
AKSOUNDENGINE_API Playlist * LockPlaylist(AkPlayingID in_playingID)
AKSOUNDENGINE_API AKRESULT Play(AkPlayingID in_playingID, AkTimeMs in_uTransitionDuration=0, AkCurveInterpolation in_eFadeCurve=AkCurveInterpolation_Linear)
AkUInt32 AkUniqueID
Unique 32-bit ID.
Definition: AkTypes.h:52
#define AKASSERT(Condition)
Definition: AkAssert.h:67
@ DynamicSequenceType_SampleAccurate
Sample accurate mode.
void(* AkCallbackFunc)(AkCallbackType in_eType, AkCallbackInfo *in_pCallbackInfo)
Definition: AkCallback.h:286
AkForceInline AKRESULT Enqueue(AkUniqueID in_audioNodeID, AkTimeMs in_msDelay=0, void *in_pCustomInfo=NULL, AkUInt32 in_cExternals=0, AkExternalSourceInfo *in_pExternalSources=NULL)
AkCurveInterpolation
Curve interpolation types.
Definition: AkTypes.h:860
@ AkCurveInterpolation_Linear
Linear (Default)
Definition: AkTypes.h:867
AKSOUNDENGINE_API AKRESULT Seek(AkPlayingID in_playingID, AkTimeMs in_iPosition, bool in_bSeekToNearestMarker)
AkExternalSourceArray * GetExternalSources()
Get the external source array. Internal use only.
AkForceInline PlaylistItem * AddLast()
Definition: AkArray.h:593
AKSOUNDENGINE_API AKRESULT UnlockPlaylist(AkPlayingID in_playingID)
uint32_t AkUInt32
Unsigned 32-bit integer.
AKSOUNDENGINE_API AkPlayingID Open(AkGameObjectID in_gameObjectID, AkUInt32 in_uFlags=0, AkCallbackFunc in_pfnCallback=NULL, void *in_pCookie=NULL, DynamicSequenceType in_eDynamicSequenceType=DynamicSequenceType_SampleAccurate)
@ AK_InsufficientMemory
Memory error.
Definition: AkTypes.h:164
#define AkForceInline
Definition: AkTypes.h:63
AkUInt32 AkPlayingID
Playing ID.
Definition: AkTypes.h:55
@ DynamicSequenceType_NormalTransition
Normal transition mode, allows the entire playlist to be edited at all times.
AKSOUNDENGINE_API AKRESULT GetPauseTimes(AkPlayingID in_playingID, AkUInt32 &out_uTime, AkUInt32 &out_uDuration)
bool operator==(const PlaylistItem &in_rCopy)
AKSOUNDENGINE_API AKRESULT Close(AkPlayingID in_playingID)
AKSOUNDENGINE_API AKRESULT Break(AkPlayingID in_playingID)

Was this page helpful?

Need Support?

Questions? Problems? Need more info? Contact us, and we can help!

Visit our Support page

Tell us about your project. We're here to help.

Register your project and we'll help you get started with no strings attached!

Get started with Wwise