Version
menu

Wwise SDK 2025.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) 2025 Audiokinetic Inc.
25 *******************************************************************************/
26 
27 #ifndef _AK_SOUNDENGINE_AKDYNAMICSEQUENCE_H
28 #define _AK_SOUNDENGINE_AKDYNAMICSEQUENCE_H
29 
32 
33 namespace AK
34 {
35  namespace SoundEngine
36  {
37  /// 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, see \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>.
38  /// \remarks The functions in this namespace are thread-safe, unless stated otherwise.
39  namespace DynamicSequence
40  {
41  /// Playlist Item for Dynamic Sequence Playlist.
42  /// \sa
43  /// - AK::SoundEngine::DynamicSequence::Playlist
44  /// - AK::SoundEngine::PostEvent
45  /// - \ref integrating_external_sources
47  {
48  public:
50  PlaylistItem(const PlaylistItem& in_rCopy);
52 
53  PlaylistItem& operator=(const PlaylistItem& in_rCopy);
54  bool operator==(const PlaylistItem& in_rCopy)
55  {
57  return audioNodeID == in_rCopy.audioNodeID &&
58  msDelay == in_rCopy.msDelay &&
59  pCustomInfo == in_rCopy.pCustomInfo;
60  };
61 
62  /// Sets the external sources used by this item.
63  /// \sa
64  /// \ref integrating_external_sources
65  AKRESULT SetExternalSources(AkUInt32 in_nExternalSrc, AkExternalSourceInfo* in_pExternalSrc);
66 
67  AkUniqueID audioNodeID; ///< Unique ID of Audio Node
68  AkTimeMs msDelay; ///< Delay before playing this item, in milliseconds
69  void * pCustomInfo; ///< Optional user data
71  };
72 
73  /// List of items to play in a Dynamic Sequence.
74  /// \sa
75  /// - AK::SoundEngine::DynamicSequence::LockPlaylist
76  /// - AK::SoundEngine::DynamicSequence::UnlockPlaylist
77  class Playlist
78  : public AkArray<PlaylistItem, const PlaylistItem&>
79  {
80  public:
81  /// Enqueue an Audio Node.
82  /// \return AK_Success if successful, AK_Fail otherwise
84  AkUniqueID in_audioNodeID, ///< Unique ID of Audio Node
85  AkTimeMs in_msDelay = 0, ///< Delay before playing this item, in milliseconds
86  void * in_pCustomInfo = NULL, ///< Optional user data
87  AkUInt32 in_cExternals = 0, ///< Optional count of external source structures
88  AkExternalSourceInfo *in_pExternalSources = NULL///< Optional array of external source resolution information
89  )
90  {
91  PlaylistItem * pItem = AddLast();
92  if ( !pItem )
93  return AK_InsufficientMemory;
94 
95  pItem->audioNodeID = in_audioNodeID;
96  pItem->msDelay = in_msDelay;
97  pItem->pCustomInfo = in_pCustomInfo;
98  return pItem->SetExternalSources(in_cExternals, in_pExternalSources);
99  }
100  };
101 
102  // \deprecated Use AkDynamicSequenceType in the global scope.
107 
108  /// Open a new Dynamic Sequence.
109  /// \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
110  ///
111  /// If \c AK_DynamicSequenceSelect bit is set in \c in_uFlags, the dynamic sequence uses the callback for determining the next item to play.
112  /// If this bit is not set, then the dynamic sequence uses the Playlist to determine the next item to play.
113  ///
114  /// \sa
115  /// - AK::SoundEngine::DynamicSequence::DynamicSequenceType
117  AkGameObjectID in_gameObjectID, ///< Associated game object ID
118  AkUInt32 in_uFlags = 0, ///< Bitmask: see \ref AkCallbackType
119  AkCallbackFunc in_pfnCallback = NULL, ///< Callback function
120  void* in_pCookie = NULL, ///< Callback cookie that will be sent to the callback function along with additional information;
121  AkDynamicSequenceType in_eDynamicSequenceType = AkDynamicSequenceType_SampleAccurate ///< See : \ref AkDynamicSequenceType
122  );
123 
124  /// Close specified Dynamic Sequence. The Dynamic Sequence will play until finished and then
125  /// deallocate itself.
126  /// \return
127  /// - AK_Success if the command was successfully queued
128  /// - AK_PlayingIDNotFound if the playing ID does not match to any open Dynamic Sequence
130  AkPlayingID in_playingID ///< AkPlayingID returned by DynamicSequence::Open
131  );
132 
133  /// Play specified Dynamic Sequence.
134  /// \return
135  /// - AK_Success if the command was successfully queued
136  /// - AK_PlayingIDNotFound if the playing ID does not match to any open Dynamic Sequence
138  AkPlayingID in_playingID, ///< AkPlayingID returned by DynamicSequence::Open
139  AkTimeMs in_uTransitionDuration = 0, ///< Fade duration
140  AkCurveInterpolation in_eFadeCurve = AkCurveInterpolation_Linear ///< Curve type to be used for the transition
141  );
142 
143  /// Pause specified Dynamic Sequence.
144  /// To restart the sequence, call Resume. The item paused will resume its playback, followed by the rest of the sequence.
145  /// \return
146  /// - AK_Success if the command was successfully queued
147  /// - AK_PlayingIDNotFound if the playing ID does not match to any open Dynamic Sequence
149  AkPlayingID in_playingID, ///< AkPlayingID returned by DynamicSequence::Open
150  AkTimeMs in_uTransitionDuration = 0, ///< Fade duration
151  AkCurveInterpolation in_eFadeCurve = AkCurveInterpolation_Linear ///< Curve type to be used for the transition
152  );
153 
154  /// Resume specified Dynamic Sequence.
155  /// \return
156  /// - AK_Success if the command was successfully queued
157  /// - AK_PlayingIDNotFound if the playing ID does not match to any open Dynamic Sequence
159  AkPlayingID in_playingID, ///< AkPlayingID returned by DynamicSequence::Open
160  AkTimeMs in_uTransitionDuration = 0, ///< Fade duration
161  AkCurveInterpolation in_eFadeCurve = AkCurveInterpolation_Linear ///< Curve type to be used for the transition
162  );
163 
164  /// Stop specified Dynamic Sequence immediately.
165  /// To restart the sequence, call Play. The sequence will restart with the item that was in the
166  /// playlist after the item that was stopped.
167  /// \return
168  /// - AK_Success if the command was successfully queued
169  /// - AK_PlayingIDNotFound if the playing ID does not match to any open Dynamic Sequence
171  AkPlayingID in_playingID, ///< AkPlayingID returned by DynamicSequence::Open
172  AkTimeMs in_uTransitionDuration = 0, ///< Fade duration
173  AkCurveInterpolation in_eFadeCurve = AkCurveInterpolation_Linear ///< Curve type to be used for the transition
174  );
175 
176  /// Break specified Dynamic Sequence. The sequence will stop after the current item.
177  /// \return
178  /// - AK_Success if the command was successfully queued
179  /// - AK_PlayingIDNotFound if the playing ID does not match to any open Dynamic Sequence
181  AkPlayingID in_playingID ///< AkPlayingID returned by DynamicSequence::Open
182  );
183 
184  /// Seek inside specified Dynamic Sequence.
185  /// It is only possible to seek in the first item of the sequence.
186  /// 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.
187  /// All the other items in the sequence will continue to play normally.
188  /// \return
189  /// - AK_Success if the command was successfully queued
190  /// - AK_PlayingIDNotFound if the playing ID does not match to any open Dynamic Sequence
192  AkPlayingID in_playingID, ///< AkPlayingID returned by DynamicSequence::Open
193  AkTimeMs in_iPosition, ///< Position into the the sound, in milliseconds
194  bool in_bSeekToNearestMarker ///< Snap to the marker nearest to the seek position.
195  );
196 
197  /// Seek inside specified Dynamic Sequence.
198  /// It is only possible to seek in the first item of the sequence.
199  /// 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.
200  /// All the other items in the sequence will continue to play normally.
201  /// \return
202  /// - AK_Success if the command was successfully queued
203  /// - AK_PlayingIDNotFound if the playing ID does not match to any open Dynamic Sequence
205  AkPlayingID in_playingID, ///< AkPlayingID returned by DynamicSequence::Open
206  AkReal32 in_fPercent, ///< Position into the the sound, in percentage of the whole duration.
207  bool in_bSeekToNearestMarker ///< Snap to the marker nearest to the seek position.
208  );
209 
210  /// Get pause times.
211  /// \return
212  /// - AK_Success if successful
213  /// - AK_PlayingIDNotFound if the playing ID does not match to any open Dynamic Sequence
215  AkPlayingID in_playingID, ///< AkPlayingID returned by DynamicSequence::Open
216  AkUInt32 &out_uTime, ///< If sequence is currently paused, returns time when pause started, else 0.
217  AkUInt32 &out_uDuration ///< Returns total pause duration since last call to GetPauseTimes, excluding the time elapsed in the current pause.
218  );
219 
220  /// Get currently playing item. Note that this may be different from the currently heard item
221  /// when sequence is in sample-accurate mode.
222  /// \return
223  /// - AK_Success if successful
224  /// - AK_PlayingIDNotFound if the playing ID does not match to any open Dynamic Sequence
226  AkPlayingID in_playingID, ///< AkPlayingID returned by DynamicSequence::Open
227  AkUniqueID & out_audioNodeID, ///< Returned audio node ID of playing item.
228  void *& out_pCustomInfo ///< Returned user data of playing item.
229  );
230 
231  /// Lock the Playlist for editing. Needs a corresponding UnlockPlaylist call.
232  /// \return Pointer to locked Playlist if successful, NULL otherwise (in_playingID not found)
233  ///
234  /// \akwarning
235  /// When opening a dynamic sequence with the callback flag \c AK_DynamicSequenceSelect, the callback is the ONLY way to determine the next item to play.
236  /// \c AK::SoundEngine::DynamicSequence::LockPlaylist always returns \c NULL for dynamic sequences opened with \c AK_DynamicSequenceSelect.
237  /// \endakwarning
238  ///
239  /// \sa
240  /// - AK::SoundEngine::DynamicSequence::UnlockPlaylist
242  AkPlayingID in_playingID ///< AkPlayingID returned by DynamicSequence::Open
243  );
244 
245  /// Unlock the playlist.
246  /// \return
247  /// - AK_Success if successful
248  /// - AK_PlayingIDNotFound if the playing ID does not match to any open Dynamic Sequence
249  /// \sa
250  /// - AK::SoundEngine::DynamicSequence::LockPlaylist
252  AkPlayingID in_playingID ///< AkPlayingID returned by DynamicSequence::Open
253  );
254  }
255  }
256 }
257 
258 #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)
AkEventCallbackFunc AkCallbackFunc
AKSOUNDENGINE_API AKRESULT GetPlayingItem(AkPlayingID in_playingID, AkUniqueID &out_audioNodeID, void *&out_pCustomInfo)
AkDynamicSequenceType
Definition: AkEnums.h:378
void * AkExternalSourceArray
Definition: AkTypedefs.h:95
Definition of data structures for AkAudioObject.
AkUniqueID audioNodeID
Unique ID of Audio Node.
AkUInt64 AkGameObjectID
Game object ID.
Definition: AkTypedefs.h:47
#define AK_EXTERNAPIFUNC(_type, _name)
AkCurveInterpolation
Curve interpolation types.
Definition: AkEnums.h:185
AkTimeMs msDelay
Delay before playing this item, in milliseconds.
@ AkDynamicSequenceType_Last
End of enum, invalid value.
Definition: AkEnums.h:381
PlaylistItem & operator=(const PlaylistItem &in_rCopy)
AKSOUNDENGINE_API AKRESULT Resume(AkPlayingID in_playingID, AkTimeMs in_uTransitionDuration=0, AkCurveInterpolation in_eFadeCurve=AkCurveInterpolation_Linear)
AkUInt32 AkUniqueID
Unique 32-bit ID.
Definition: AkTypedefs.h:39
const AkDynamicSequenceType DynamicSequenceType_NormalTransition
Specific implementation of array.
Definition: AkArray.h:260
float AkReal32
32-bit floating point
AKSOUNDENGINE_API AKRESULT Pause(AkPlayingID in_playingID, AkTimeMs in_uTransitionDuration=0, AkCurveInterpolation in_eFadeCurve=AkCurveInterpolation_Linear)
const AkDynamicSequenceType DynamicSequenceType_Last
PlaylistItem(const PlaylistItem &in_rCopy)
AkInt32 AkTimeMs
Time in ms.
Definition: AkTypedefs.h:43
AKSOUNDENGINE_API Playlist * LockPlaylist(AkPlayingID in_playingID)
AKSOUNDENGINE_API AKRESULT Play(AkPlayingID in_playingID, AkTimeMs in_uTransitionDuration=0, AkCurveInterpolation in_eFadeCurve=AkCurveInterpolation_Linear)
@ AkDynamicSequenceType_SampleAccurate
Sample accurate mode.
Definition: AkEnums.h:379
#define AKASSERT(Condition)
Definition: AkAssert.h:67
@ AK_InsufficientMemory
Memory error.
Definition: AkEnums.h:62
AKSOUNDENGINE_API AkPlayingID Open(AkGameObjectID in_gameObjectID, AkUInt32 in_uFlags=0, AkCallbackFunc in_pfnCallback=NULL, void *in_pCookie=NULL, AkDynamicSequenceType in_eDynamicSequenceType=AkDynamicSequenceType_SampleAccurate)
AkForceInline AKRESULT Enqueue(AkUniqueID in_audioNodeID, AkTimeMs in_msDelay=0, void *in_pCustomInfo=NULL, AkUInt32 in_cExternals=0, AkExternalSourceInfo *in_pExternalSources=NULL)
#define NULL
Definition: AkTypedefs.h:33
AKRESULT
Definition: AkEnums.h:32
AKSOUNDENGINE_API AKRESULT Seek(AkPlayingID in_playingID, AkTimeMs in_iPosition, bool in_bSeekToNearestMarker)
@ AkCurveInterpolation_Linear
Linear (Default)
Definition: AkEnums.h:192
AkForceInline PlaylistItem * AddLast()
Definition: AkArray.h:594
AKSOUNDENGINE_API AKRESULT UnlockPlaylist(AkPlayingID in_playingID)
uint32_t AkUInt32
Unsigned 32-bit integer.
const AkDynamicSequenceType DynamicSequenceType_SampleAccurate
#define AkForceInline
Definition: AkTypes.h:63
AKSOUNDENGINE_API AKRESULT GetPauseTimes(AkPlayingID in_playingID, AkUInt32 &out_uTime, AkUInt32 &out_uDuration)
AkUInt32 AkPlayingID
A unique identifier generated whenever a PostEvent is called (or when a Dynamic Sequence is created)....
Definition: AkTypedefs.h:42
@ AkDynamicSequenceType_NormalTransition
Normal transition mode, allows the entire playlist to be edited at all times.
Definition: AkEnums.h:380
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