Version
menu_open
link
Wwise SDK 2022.1.11
AkCommonDefs.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 // AkCommonDefs.h
28 
29 /// \file
30 /// AudioLib common defines, enums, and structs.
31 
32 
33 #ifndef _AK_COMMON_DEFS_H_
34 #define _AK_COMMON_DEFS_H_
35 
41 
42 //-----------------------------------------------------------------------------
43 // AUDIO DATA FORMAT
44 //-----------------------------------------------------------------------------
45 
46 // Audio data format.
47 // ------------------------------------------------
48 
49 const AkDataTypeID AK_INT = 0; ///< Integer data type (uchar, short, and so on)
50 const AkDataTypeID AK_FLOAT = 1; ///< Float data type
51 
52 const AkDataInterleaveID AK_INTERLEAVED = 0; ///< Interleaved data
53 const AkDataInterleaveID AK_NONINTERLEAVED = 1; ///< Non-interleaved data
54 
55 // Native format currently the same on all supported platforms, may become platform specific in the future
56 const AkUInt32 AK_LE_NATIVE_BITSPERSAMPLE = 32; ///< Native number of bits per sample.
57 const AkUInt32 AK_LE_NATIVE_SAMPLETYPE = AK_FLOAT; ///< Native data type.
58 const AkUInt32 AK_LE_NATIVE_INTERLEAVE = AK_NONINTERLEAVED; ///< Native interleaved setting.
59 
60 /// Defines the parameters of an audio buffer format.
62 {
63  AkUInt32 uSampleRate; ///< Number of samples per second
64 
65  AkChannelConfig channelConfig; ///< Channel configuration.
66 
67  AkUInt32 uBitsPerSample :6; ///< Number of bits per sample.
68  AkUInt32 uBlockAlign :10;///< Number of bytes per sample frame. (For example a 5.1 PCM 16bit should have a uBlockAlign equal to 6(5.1 channels)*2(16 bits per sample) = 12.
69  AkUInt32 uTypeID :2; ///< Data type ID (AkDataTypeID).
70  AkUInt32 uInterleaveID :1; ///< Interleave ID (AkDataInterleaveID).
71 
72  /// Get the number of channels.
73  /// \return The number of channels
75  {
77  }
78 
79  /// Query if LFE channel is present.
80  /// \return True when LFE channel is present
81  AkForceInline bool HasLFE() const
82  {
83  return channelConfig.HasLFE();
84  }
85 
86  /// Query if center channel is present.
87  /// Note that mono configurations have one channel which is arbitrary set to AK_SPEAKER_FRONT_CENTER,
88  /// so HasCenter() returns true for mono signals.
89  /// \return True when center channel is present and configuration has more than 2 channels.
90  AkForceInline bool HasCenter() const
91  {
92  return channelConfig.HasCenter();
93  }
94 
95  /// Get the number of bits per sample.
96  /// \return The number of bits per sample
98  {
99  return uBitsPerSample;
100  }
101 
102  /// Get the block alignment.
103  /// \return The block alignment
105  {
106  return uBlockAlign;
107  }
108 
109  /// Get the data sample format (Float or Integer).
110  /// \return The data sample format
112  {
113  return uTypeID;
114  }
115 
116  /// Get the interleaved type.
117  /// \return The interleaved type
119  {
120  return uInterleaveID;
121  }
122 
123  /// Set all parameters of the audio format structure.
124  /// Channels are specified by channel mask (standard configs).
125  void SetAll(
126  AkUInt32 in_uSampleRate, ///< Number of samples per second
127  AkChannelConfig in_channelConfig, ///< Channel configuration
128  AkUInt32 in_uBitsPerSample, ///< Number of bits per sample
129  AkUInt32 in_uBlockAlign, ///< Block alignment
130  AkUInt32 in_uTypeID, ///< Data sample format (Float or Integer)
131  AkUInt32 in_uInterleaveID ///< Interleaved type
132  )
133  {
134  uSampleRate = in_uSampleRate;
135  channelConfig = in_channelConfig;
136  uBitsPerSample = in_uBitsPerSample;
137  uBlockAlign = in_uBlockAlign;
138  uTypeID = in_uTypeID;
139  uInterleaveID = in_uInterleaveID;
140  }
141 
142  AkForceInline bool operator==(const AkAudioFormat & in_other) const
143  {
144  return uSampleRate == in_other.uSampleRate
145  && channelConfig == in_other.channelConfig
146  && uBitsPerSample == in_other.uBitsPerSample
147  && uBlockAlign == in_other.uBlockAlign
148  && uTypeID == in_other.uTypeID
149  && uInterleaveID == in_other.uInterleaveID;
150  }
151 
152  AkForceInline bool operator!=(const AkAudioFormat & in_other) const
153  {
154  return uSampleRate != in_other.uSampleRate
155  || channelConfig != in_other.channelConfig
156  || uBitsPerSample != in_other.uBitsPerSample
157  || uBlockAlign != in_other.uBlockAlign
158  || uTypeID != in_other.uTypeID
159  || uInterleaveID != in_other.uInterleaveID;
160  }
161 };
162 
163 typedef AkUInt8(*AkChannelMappingFunc)(const AkChannelConfig &config, AkUInt8 idx);
164 
166 {
167  SourceChannelOrdering_Standard = 0, // SMPTE L-R-C-LFE-RL-RR-RC-SL-SR-HL-HR-HC-HRL-HRR-HRC-T
168  // or ACN ordering + SN3D norm
169 
170  SourceChannelOrdering_Film, // L/C/R/Ls/Rs/Lfe
172 };
173 
174 #define AK_MAKE_CHANNELCONFIGOVERRIDE(_config,_order) ((AkInt64)_config.Serialize()|((AkInt64)_order<<32))
175 #define AK_GET_CHANNELCONFIGOVERRIDE_CONFIG(_over) (_over&UINT_MAX)
176 #define AK_GET_CHANNELCONFIGOVERRIDE_ORDERING(_over) ((AkSourceChannelOrdering)(_over>>32))
177 
178 // Build a 32 bit class identifier based on the Plug-in type,
179 // CompanyID and PluginID.
180 //
181 // Parameters:
182 // - in_pluginType: A value from enum AkPluginType (4 bits)
183 // - in_companyID: CompanyID as defined in the Plug-in's XML file (12 bits)
184 // * 0-63: Reserved for Audiokinetic
185 // * 64-255: Reserved for clients' in-house Plug-ins
186 // * 256-4095: Assigned by Audiokinetic to third-party plug-in developers
187 // - in_pluginID: PluginID as defined in the Plug-in's XML file (16 bits)
188 // * 0-32767: Set freely by the Plug-in developer
189 #define AKMAKECLASSID( in_pluginType, in_companyID, in_pluginID ) \
190  ( (in_pluginType) + ( (in_companyID) << 4 ) + ( (in_pluginID) << ( 4 + 12 ) ) )
191 
192 #define AKGETPLUGINTYPEFROMCLASSID( in_classID ) ( (in_classID) & AkPluginTypeMask )
193 #define AKGETCOMPANYIDFROMCLASSID( in_classID ) ( ( (in_classID) & 0x0000FFF0 ) >> 4 )
194 #define AKGETPLUGINIDFROMCLASSID( in_classID ) ( ( (in_classID) & 0xFFFF0000 ) >> ( 4 + 12 ) )
195 
196 #define CODECID_FROM_PLUGINID AKGETPLUGINIDFROMCLASSID
197 
198 
199 namespace AK
200 {
201  /// Struct containing metering information about a buffer. Depending on when this struct is generated, you may get metering data computed in the previous frame only.
202  struct AkMetering
203  {
204  /// Peak of each channel in this frame.
205  /// Vector of linear peak levels, corresponding to each channel. NULL if AK_EnableBusMeter_Peak is not set (see IAkMixerPluginContext::SetMeteringFlags() or AK::SoundEngine::RegisterBusMeteringCallback()).
207 
208  /// True peak of each channel (as defined by ITU-R BS.1770) in this frame.
209  /// Vector of linear true peak levels, corresponding to each channel. NULL if AK_EnableBusMeter_TruePeak is not set (see IAkMixerPluginContext::SetMeteringFlags() or AK::SoundEngine::RegisterBusMeteringCallback()).
211 
212  /// RMS value of each channel in this frame.
213  /// Vector of linear rms levels, corresponding to each channel. NULL if AK_EnableBusMeter_RMS is not set (see IAkMixerPluginContext::SetMeteringFlags() or AK::SoundEngine::RegisterBusMeteringCallback()).
215 
216  /// Mean k-weighted power value in this frame, used to compute loudness (as defined by ITU-R BS.1770).
217  /// Total linear k-weighted power of all channels. 0 if AK_EnableBusMeter_KPower is not set (see IAkMixerPluginContext::SetMeteringFlags() or AK::SoundEngine::RegisterBusMeteringCallback()).
219  };
220 
221  static inline bool IsBankCodecID(AkUInt32 in_codecID)
222  {
223  return in_codecID == AKCODECID_BANK ||
224  in_codecID == AKCODECID_BANK_EVENT ||
225  in_codecID == AKCODECID_BANK_BUS;
226  }
227 }
228 
229 // 3D Audio Object.
230 // ------------------------------------------------
231 
232 /// Default listener transform.
233 #define AK_DEFAULT_LISTENER_POSITION_X (0.0f) // at coordinate system's origin
234 #define AK_DEFAULT_LISTENER_POSITION_Y (0.0f)
235 #define AK_DEFAULT_LISTENER_POSITION_Z (0.0f)
236 #define AK_DEFAULT_LISTENER_FRONT_X (0.0f) // looking toward Z,
237 #define AK_DEFAULT_LISTENER_FRONT_Y (0.0f)
238 #define AK_DEFAULT_LISTENER_FRONT_Z (1.0f)
239 #define AK_DEFAULT_TOP_X (0.0f) // top towards Y
240 #define AK_DEFAULT_TOP_Y (1.0f)
241 #define AK_DEFAULT_TOP_Z (0.0f)
242 
243 
244 /// 3D data needed for 3D spatialization.
245 /// Undergoes transformations based on emitter-listener placement.
246 struct Ak3dData
247 {
249  : spread(1.f)
250  , focus(1.f)
251  , uEmitterChannelMask(0xffff)
252  {
254  }
255 
256  AkTransform xform; ///< Object position / orientation.
257  AkReal32 spread; ///< Spread [0,1]
258  AkReal32 focus; ///< Focus [0,1]
259  AkChannelMask uEmitterChannelMask; ///< Emitter channel mask. With 3D spatialization, zeroed channels should be dropped.
260 };
261 
262 /// Positioning data inherited from sound structures and mix busses.
264 {
266  : center(1.f)
267  , panLR(0.f)
268  , panBF(0.f)
269  , panDU(0.f)
270  , panSpatMix(1.f)
273  , enableHeightSpread(true)
274  {}
275 
276  AkReal32 center; ///< Center percentage [0,1]
277  AkReal32 panLR; ///< Pan left-right [-1,1]
278  AkReal32 panBF; ///< Pan back-front [-1,1]
279  AkReal32 panDU; ///< Pan down-up [-1,1]
280  AkReal32 panSpatMix; ///< Panning vs 3D spatialization mix ([0,1], 1 being 100% spatialized).
281  Ak3DSpatializationMode spatMode; ///< 3D spatialization mode.
282  AkSpeakerPanningType panType; ///< Speaker panning type.
283  bool enableHeightSpread; ///< When true, audio objects 3D spatialized onto a planar channel configuration will be given a minimum spread value based on their elevation angle, equal to sin(elevation)**2.
284 };
285 
286 /// Positioning data of 3D audio objects.
288 {
289  Ak3dData threeD; ///< 3D data used for 3D spatialization.
290  AkBehavioralPositioningData behavioral; ///< Positioning data inherited from sound structures and mix busses.
291 };
292 
293 // Forward defines
294 namespace AK
295 {
296  class IAkPluginParam;
297 }
298 
299 /// An audio object refers to an audio signal with some attached metadata going through the sound engine pipeline.
300 /// The AkAudioObject struct encapsulates the metadata part. The signal itself is contained in a separate AkAudioBuffer instance.
302 {
303  /// Constructor
306  ,cumulativeGain(1.f, 1.f)
309  {}
310 
311  /// Destructor
313  {
315  objectName.Term();
316  }
317 
318  AkAudioObjectID key; ///< Unique ID, local to a given bus.
319 
320  AkPositioningData positioning; ///< Positioning data for deferred 3D rendering.
321  AkRamp cumulativeGain; ///< Cumulative ramping gain to apply when mixing down to speaker bed or final endpoint
322 
323  /// Custom object metadata.
325  {
326  AkPluginID pluginID; ///< Full plugin ID, including company ID and plugin type. See AKMAKECLASSID macro.
327  AK::IAkPluginParam* pParam; ///< Custom, pluggable medata. Note: any custom metadata is expected to exist for only the current sound engine render tick, and persistent references to it should not be stored.
328  AkUniqueID contextID; ///< (Profiling) ID of the sound or bus from which the custom metadata was fetched.
329  };
330 
331  /// Array type for carrying custom metadata.
332  class ArrayCustomMetadata : public AkArray<CustomMetadata, const CustomMetadata&, AkPluginArrayAllocator>
333  {
334  public:
336 
337  ArrayType::Iterator FindByPluginID(AkPluginID pluginID) const
338  {
339  for (auto it = Begin(); it != End(); ++it)
340  {
341  if ((*it).pluginID == pluginID)
342  return it;
343  }
344  return End();
345  }
346  };
347 
348  ArrayCustomMetadata arCustomMetadata; ///< Array of custom metadata, gathered from visited objects. Note: any custom metadata is expected to exist for only the current sound engine render tick, and persistent references to it should not be stored.
349 
350  AkPipelineID instigatorID; ///< Profiling ID of the node from which the object stems (typically the voice, instance of an actor-mixer).
351 
352  typedef AkString<AkPluginArrayAllocator, char> String; ///< String type for use in 3D audio objects.
353  String objectName; ///< Name string of the object, to appear in the object profiler. This is normally used by out-of-place object processors for naming their output objects. Built-in sound engine structures don't use it.
354 
355  AkPriority priority; ///< Audio object playback priority. Object with a higher priority will be rendered using the hardware's object functionality on platforms that supports it, whereas objects with a lower priority will be downmixed to a lower resolution 3D bed. Audio object priorities should be retrieved, or set through IAkPluginServiceAudioObjectPriority to retain compatibility with future Wwise releases.
356 
357  /// Copy object metadata (everything but the key) from another object.
359  const AkAudioObject& in_src ///< Object from which metadata is copied.
360  )
361  {
362  positioning = in_src.positioning;
365  instigatorID = in_src.instigatorID;
366  objectName = in_src.objectName; // AkString performs a shallow copy when it can, like here.
367  priority = in_src.priority;
368  }
369 
370  void SetCustomMetadata(CustomMetadata* in_aCustomMetadata, AkUInt32 in_uLength)
371  {
372  if (arCustomMetadata.Resize(in_uLength))
373  {
374  for (int i = 0; i < (int)in_uLength; ++i)
375  {
376  arCustomMetadata[i] = in_aCustomMetadata[i];
377  }
378  }
379  }
380 
381  /// Transfer function for transfer move policies.
382  void Transfer(
383  AkAudioObject& in_from ///< Object from which data is transferred.
384  )
385  {
386  key = in_from.key;
387  positioning = in_from.positioning;
388  cumulativeGain = in_from.cumulativeGain;
390  instigatorID = in_from.instigatorID;
391  objectName.Transfer(in_from.objectName);
392  priority = in_from.priority;
393  }
394 
395  /// Object processors may give an explicit name to objects.
396  /// \return AK_Success if the string was allocated successfully, AK_InsufficientMemory otherwise.
398  AK::IAkPluginMemAlloc* in_pAllocator, ///< Memory allocator.
399  const char* in_szName ///< Null-terminated string to allocate and store on this object.
400  )
401  {
402  objectName.Init(in_pAllocator);
403  objectName = in_szName;
404  return objectName.AllocCopy();
405  }
406 
407  /// Reset object state in preparation for next frame.
408  void ResetState()
409  {
410  arCustomMetadata.Term(); // Reset custom metadata in preparation for next frame.
411  objectName.ClearReference(); // Clear reference to string in preparation for next frame.
412  }
413 };
414 
415 /// Structure containing information about system-level support for 3D audio.
416 /// "3D Audio" refers to a system's ability to position sound sources in a virtual 3D space, pan them accordingly on a range of physical speakers, and produce a binaural mix where appropriate.
417 /// We prefer "3D Audio" to "Spatial" to avoid ambiguity with spatial audio, which typically involves sound propagation and environment effects.
419 {
420  AkChannelConfig channelConfig; ///< Channel configuration of the main mix.
421  AkUInt32 uMaxSystemAudioObjects; ///< Maximum number of System Audio Objects that can be active concurrently. A value of zero indicates the system does not support this feature.
422  AkUInt32 uAvailableSystemAudioObjects; ///< How many System Audio Objects can currently be sent to the sink. This value can change at runtime depending on what is playing. Can never be higher than uMaxSystemAudioObjects.
423  bool bPassthrough; ///< Separate pass-through mix is supported.
424  bool bMultiChannelObjects; ///< Can handle multi-channel objects
425 };
426 
427 /// Enum of the possible object destinations when reaching a 3D audio-capable sink
429 {
430  eDefault = 0, // The destination will be chosen based on the audio object's metadata and channel configuration
431  eMainMix = 1, // The audio object will be mixed to the sink's main mix
432  ePassthrough = 2, // The audio object will be mixed to the sink's passthrough mix
433  eSystemAudioObject = 3 // The audio object will not be mixed; it will be sent separately to the system's 3D audio endpoint
434 };
435 
436 // Audio buffer.
437 // ------------------------------------------------
438 
439 /// Native sample type.
440 /// \remarks Sample values produced by insert effects must use this type.
441 /// \remarks Source plug-ins can produce samples of other types (specified through
442 /// according fields of AkAudioFormat, at initial handshaking), but these will be
443 /// format converted internally into the native format.
444 /// \sa
445 /// - \ref iaksourceeffect_init
446 /// - \ref iakmonadiceffect_init
447 typedef AkReal32 AkSampleType; ///< Audio sample data type (32 bit floating point)
448 
449 /// Audio buffer structure including the address of an audio buffer, the number of valid frames inside,
450 /// and the maximum number of frames the audio buffer can hold.
451 /// \sa
452 /// - \ref fx_audiobuffer_struct
454 {
455 public:
456 
457  /// Constructor.
459  {
460  Clear();
461  }
462 
463  /// Clear data pointer.
465  {
466  pData = NULL;
467  uValidFrames = 0;
468  }
469 
470  /// Clear members.
472  {
473  ClearData();
474  uMaxFrames = 0;
476  }
477 
478  /// \name Channel queries.
479  //@{
480  /// Get the number of channels.
482  {
484  }
485 
486  /// Returns true if there is an LFE channel present.
487  AkForceInline bool HasLFE() const
488  {
489  return channelConfig.HasLFE();
490  }
491 
493 
494  //@}
495 
496  /// \name Interleaved interface
497  //@{
498  /// Get address of data: to be used with interleaved buffers only.
499  /// \remarks Only source plugins can output interleaved data. This is determined at
500  /// initial handshaking.
501  /// \sa
502  /// - \ref fx_audiobuffer_struct
504  {
505  return pData;
506  }
507 
508  /// Attach interleaved data. Allocation is performed outside.
509  inline void AttachInterleavedData( void * in_pData, AkUInt16 in_uMaxFrames, AkUInt16 in_uValidFrames )
510  {
511  pData = in_pData;
512  uMaxFrames = in_uMaxFrames;
513  uValidFrames = in_uValidFrames;
515  }
516  /// Attach interleaved data with a new channel config. Allocation is performed outside.
517  inline void AttachInterleavedData( void * in_pData, AkUInt16 in_uMaxFrames, AkUInt16 in_uValidFrames, AkChannelConfig in_channelConfig )
518  {
519  pData = in_pData;
520  uMaxFrames = in_uMaxFrames;
521  uValidFrames = in_uValidFrames;
522  channelConfig = in_channelConfig;
523  }
524  //@}
525 
526  /// \name Deinterleaved interface
527  //@{
528 
529  /// Check if buffer has samples attached to it.
530  AkForceInline bool HasData() const
531  {
532  return ( NULL != pData );
533  }
534 
535  /// Convert a channel, identified by a single channel bit, to a buffer index used in GetChannel() below, for a given channel config.
536  /// Standard indexing follows channel bit order (see AkSpeakerConfig.h). Pipeline/buffer indexing is the same but the LFE is moved to the end.
538  AkChannelConfig in_channelConfig, ///< Channel configuration.
539  AkUInt32 in_uChannelIdx ///< Channel index in standard ordering to be converted to pipeline ordering.
540  )
541  {
542  if ( in_channelConfig.HasLFE() )
543  {
544  AKASSERT( in_channelConfig.eConfigType == AK_ChannelConfigType_Standard ); // in_channelConfig.HasLFE() would not have returned true otherwise.
545  AKASSERT( AK::GetNumNonZeroBits( in_channelConfig.uChannelMask ) );
546  AkUInt32 uIdxLFE = AK::GetNumNonZeroBits( ( AK_SPEAKER_LOW_FREQUENCY - 1 ) & in_channelConfig.uChannelMask );
547  if ( in_uChannelIdx == uIdxLFE )
548  return in_channelConfig.uNumChannels - 1;
549  else if ( in_uChannelIdx > uIdxLFE )
550  return in_uChannelIdx - 1;
551  }
552 
553  return in_uChannelIdx;
554  }
555 
556  /// Get the buffer of the ith channel.
557  /// Access to channel data is most optimal through this method. Use whenever the
558  /// speaker configuration is known, or when an operation must be made independently
559  /// for each channel.
560  /// \remarks When using a standard configuration, use ChannelMaskToBufferIndex() to convert channel bits to buffer indices.
561  /// \return Address of the buffer of the ith channel.
562  /// \sa
563  /// - \ref fx_audiobuffer_struct
564  /// - \ref fx_audiobuffer_struct_channels
566  AkUInt32 in_uIndex ///< Channel index [0,NumChannels()-1]
567  )
568  {
569  AKASSERT( in_uIndex < NumChannels() );
570  return (AkSampleType*)((AkUInt8*)(pData) + ( in_uIndex * sizeof(AkSampleType) * MaxFrames() ));
571  }
572 
573  /// Get the buffer of the LFE.
574  /// \return Address of the buffer of the LFE. Null if there is no LFE channel.
575  /// \sa
576  /// - \ref fx_audiobuffer_struct_channels
577  inline AkSampleType * GetLFE()
578  {
580  return GetChannel( NumChannels()-1 );
581 
582  return (AkSampleType*)0;
583  }
584 
585  /// Can be used to transform an incomplete into a complete buffer with valid data.
586  /// The invalid frames are made valid (zeroed out) for all channels and the validFrames count will be made equal to uMaxFrames.
588  {
589  AKASSERT(pData != nullptr || MaxFrames() == 0);
590  // The following members MUST be copied locally due to multi-core calls to this function.
591  const AkUInt32 uNumChannels = NumChannels();
592  const AkUInt32 uNumCurrentFrames = AkMin(uValidFrames, MaxFrames());
593  const AkUInt32 uNumZeroFrames = MaxFrames() - uNumCurrentFrames;
594  if ( uNumZeroFrames )
595  {
596  AKASSERT(pData != nullptr);
597  for ( AkUInt32 i = 0; i < uNumChannels; ++i )
598  {
599  AKPLATFORM::AkMemSet( GetChannel(i) + uNumCurrentFrames, 0, uNumZeroFrames * sizeof(AkSampleType) );
600  }
602  }
603  }
604 
605  /// Attach deinterleaved data where channels are contiguous in memory. Allocation is performed outside.
606  AkForceInline void AttachContiguousDeinterleavedData( void * in_pData, AkUInt16 in_uMaxFrames, AkUInt16 in_uValidFrames, AkChannelConfig in_channelConfig )
607  {
608  AttachInterleavedData( in_pData, in_uMaxFrames, in_uValidFrames, in_channelConfig );
609  }
610  /// Detach deinterleaved data where channels are contiguous in memory. The address of the buffer is returned and fields are cleared.
612  {
613  uMaxFrames = 0;
614  uValidFrames = 0;
616  void * pDataOld = pData;
617  pData = NULL;
618  return pDataOld;
619  }
620 
622 
623  //@}
624 
625  void RelocateMedia( AkUInt8* in_pNewMedia, AkUInt8* in_pOldMedia )
626  {
627  AkUIntPtr uMemoryOffset = (AkUIntPtr)in_pNewMedia - (AkUIntPtr)in_pOldMedia;
628  pData = (void*) (((AkUIntPtr)pData) + uMemoryOffset);
629  }
630 
631  /// Access to the number of sample frames the buffer can hold.
632  /// \return Number of sample frames the buffer can hold.
634 
635 protected:
636  void * pData; ///< Start of the audio buffer.
637  AkChannelConfig channelConfig; ///< Channel config.
638 
639 public:
640  AKRESULT eState; ///< Execution status
641 
642 protected:
643  AkUInt16 uMaxFrames; ///< Number of sample frames the buffer can hold. Access through AkAudioBuffer::MaxFrames().
644 
645 public:
646  AkUInt16 uValidFrames; ///< Number of valid sample frames in the audio buffer
647 };
648 
649 /// A collection of audio objects. Encapsulates the audio data and metadata of each audio object in separate arrays.
651 {
652  AkAudioObjects(AkUInt32 in_uNumObjects = 0, AkAudioBuffer** in_ppObjectBuffers = nullptr, AkAudioObject** in_ppObjects = nullptr)
653  : uNumObjects(in_uNumObjects)
654  , ppObjectBuffers(in_ppObjectBuffers)
655  , ppObjects(in_ppObjects)
656  {}
657 
658  AkUInt32 uNumObjects; ///< Number of audio objects.
659  AkAudioBuffer** ppObjectBuffers; ///< Array of pointers to audio object buffers.
660  AkAudioObject** ppObjects; ///< Array of pointers to audio objects.
661 };
662 
663 #endif // _AK_COMMON_DEFS_H_
void Transfer(AkAudioObject &in_from)
Transfer function for transfer move policies.
Definition: AkCommonDefs.h:382
AkString< AkPluginArrayAllocator, char > String
String type for use in 3D audio objects.
Definition: AkCommonDefs.h:352
AkForceInline bool HasLFE() const
Returns true if there is an LFE channel present.
Definition: AkCommonDefs.h:487
bool enableHeightSpread
When true, audio objects 3D spatialized onto a planar channel configuration will be given a minimum s...
Definition: AkCommonDefs.h:283
#define AkMin(x1, x2)
AkUInt8 AkDataInterleaveID
Data interleaved state ID.
Definition: AkTypes.h:138
@ AK_DirectSpeakerAssignment
No panning: route to matching channels between input and output.
Definition: AkTypes.h:1156
AkUInt32 uAvailableSystemAudioObjects
How many System Audio Objects can currently be sent to the sink. This value can change at runtime dep...
Definition: AkCommonDefs.h:422
AkSampleType * GetChannel(AkUInt32 in_uIndex)
Definition: AkCommonDefs.h:565
#define AK_DEFAULT_TOP_Z
Definition: AkCommonDefs.h:241
uint16_t AkUInt16
Unsigned 16-bit integer.
Audiokinetic namespace.
AkForceInline bool HasData() const
Check if buffer has samples attached to it.
Definition: AkCommonDefs.h:530
AkAudioObject()
Constructor.
Definition: AkCommonDefs.h:304
AkForceInline bool HasCenter() const
AkPositioningData positioning
Positioning data for deferred 3D rendering.
Definition: AkCommonDefs.h:320
@ SourceChannelOrdering_FuMa
Definition: AkCommonDefs.h:171
AkReal32 center
Center percentage [0,1].
Definition: AkCommonDefs.h:276
AkRamp cumulativeGain
Cumulative ramping gain to apply when mixing down to speaker bed or final endpoint.
Definition: AkCommonDefs.h:321
AkForceInline AkChannelConfig GetChannelConfig() const
Definition: AkCommonDefs.h:492
void Transfer(AkString< TAlloc, T_CHAR > &in_from)
Definition: AkString.h:108
AkUInt64 AkAudioObjectID
Audio Object ID.
Definition: AkTypes.h:156
AKRESULT Copy(const AkArray< T, ARG_T, TAlloc, TGrowBy, TMovePolicy > &in_rSource)
Definition: AkArray.h:827
@ SourceChannelOrdering_Standard
Definition: AkCommonDefs.h:167
AkReal32 panSpatMix
Panning vs 3D spatialization mix ([0,1], 1 being 100% spatialized).
Definition: AkCommonDefs.h:280
bool bMultiChannelObjects
Can handle multi-channel objects.
Definition: AkCommonDefs.h:424
AkUInt32 AkPipelineID
Unique node (bus, voice) identifier for profiling.
Definition: AkTypes.h:154
AkAudioBuffer()
Constructor.
Definition: AkCommonDefs.h:458
AkUInt32 uMaxSystemAudioObjects
Maximum number of System Audio Objects that can be active concurrently. A value of zero indicates the...
Definition: AkCommonDefs.h:421
AkUInt32 uNumChannels
Number of channels.
AkAudioObjectID key
Unique ID, local to a given bus.
Definition: AkCommonDefs.h:318
AkForceInline void * DetachContiguousDeinterleavedData()
Detach deinterleaved data where channels are contiguous in memory. The address of the buffer is retur...
Definition: AkCommonDefs.h:611
AkForceInline AkUInt32 NumChannels() const
Get the number of channels.
Definition: AkCommonDefs.h:481
AkForceInline void Clear()
Clear members.
Definition: AkCommonDefs.h:471
#define AK_DEFAULT_LISTENER_FRONT_Y
Definition: AkCommonDefs.h:237
AKRESULT
Standard function call result.
Definition: AkTypes.h:199
AkUInt32 uChannelMask
Channel mask (configuration).
static AkUInt32 StandardToPipelineIndex(AkChannelConfig in_channelConfig, AkUInt32 in_uChannelIdx)
Definition: AkCommonDefs.h:537
@ AK_ChannelConfigType_Standard
Channels must be identified with standard defines in AkSpeakerConfigs.
AkForceInline bool HasCenter() const
Definition: AkCommonDefs.h:90
void Set(const AkVector &in_position, const AkVector &in_orientationFront, const AkVector &in_orientationTop)
Set position and orientation. Orientation front and top should be orthogonal and normalized.
Definition: AkTypes.h:623
static const AkAudioObjectID AK_INVALID_AUDIO_OBJECT_ID
Invalid audio object ID.
Definition: AkTypes.h:177
AkUInt32 AkChannelMask
Channel mask (similar to WAVE_FORMAT_EXTENSIBLE). Bit values are defined in AkSpeakerConfig....
Definition: AkTypes.h:149
AkChannelConfig channelConfig
Channel configuration.
Definition: AkCommonDefs.h:65
#define AK_DEFAULT_LISTENER_POSITION_Z
Definition: AkCommonDefs.h:235
@ SourceChannelOrdering_Film
Definition: AkCommonDefs.h:170
void RelocateMedia(AkUInt8 *in_pNewMedia, AkUInt8 *in_pOldMedia)
Definition: AkCommonDefs.h:625
uint8_t AkUInt8
Unsigned 8-bit integer.
AkUInt32 uBitsPerSample
Number of bits per sample.
Definition: AkCommonDefs.h:67
#define AK_DEFAULT_LISTENER_POSITION_Y
Definition: AkCommonDefs.h:234
void CopyContents(const AkAudioObject &in_src)
Copy object metadata (everything but the key) from another object.
Definition: AkCommonDefs.h:358
Positioning data inherited from sound structures and mix busses.
Definition: AkCommonDefs.h:264
AkUInt32 uTypeID
Data type ID (AkDataTypeID).
Definition: AkCommonDefs.h:69
#define AK_DEFAULT_TOP_X
Definition: AkCommonDefs.h:239
Specific implementation of array.
Definition: AkArray.h:241
AK::SpeakerVolumes::VectorPtr rms
Definition: AkCommonDefs.h:214
#define NULL
Definition: AkTypes.h:46
float AkReal32
32-bit floating point
AKRESULT eState
Execution status.
Definition: AkCommonDefs.h:640
AK::SpeakerVolumes::VectorPtr truePeak
Definition: AkCommonDefs.h:210
AkReal32 panDU
Pan down-up [-1,1].
Definition: AkCommonDefs.h:279
AkUInt16 uValidFrames
Number of valid sample frames in the audio buffer.
Definition: AkCommonDefs.h:646
uintptr_t AkUIntPtr
Integer (unsigned) type for pointers.
static const AkPriority AK_DEFAULT_PRIORITY
Default sound / I/O priority.
Definition: AkTypes.h:180
AKRESULT SetName(AK::IAkPluginMemAlloc *in_pAllocator, const char *in_szName)
Definition: AkCommonDefs.h:397
#define AK_DEFAULT_TOP_Y
Definition: AkCommonDefs.h:240
AkForceInline void Init(AK::IAkPluginMemAlloc *in_pAllocator)
AkReal32 * VectorPtr
Volume vector. Access each element with the standard bracket [] operator.
void * pData
Start of the audio buffer.
Definition: AkCommonDefs.h:636
AkAudioObjectDestination
Enum of the possible object destinations when reaching a 3D audio-capable sink.
Definition: AkCommonDefs.h:429
AkChannelConfig channelConfig
Channel config.
Definition: AkCommonDefs.h:637
AkUInt32 AkUniqueID
Unique 32-bit ID.
Definition: AkTypes.h:120
bool Resize(AkUInt32 in_uiSize)
Resize the array to the specified size.
Definition: AkArray.h:784
AkAudioBuffer ** ppObjectBuffers
Array of pointers to audio object buffers.
Definition: AkCommonDefs.h:659
Ak3DSpatializationMode
3D spatialization mode.
Definition: AkTypes.h:1189
AkReal32 fMeanPowerK
Definition: AkCommonDefs.h:218
#define AK_DEFAULT_LISTENER_POSITION_X
Default listener transform.
Definition: AkCommonDefs.h:233
const AkDataTypeID AK_FLOAT
Float data type.
Definition: AkCommonDefs.h:50
AkUInt32 AkPluginID
Source or effect plug-in ID.
Definition: AkTypes.h:131
AkUInt16 AkDataTypeID
Data sample type ID.
Definition: AkTypes.h:137
void ResetState()
Reset object state in preparation for next frame.
Definition: AkCommonDefs.h:408
#define AKASSERT(Condition)
Definition: AkAssert.h:67
AkUInt32 uNumObjects
Number of audio objects.
Definition: AkCommonDefs.h:658
AkSpeakerPanningType panType
Speaker panning type.
Definition: AkCommonDefs.h:282
ArrayCustomMetadata arCustomMetadata
Array of custom metadata, gathered from visited objects. Note: any custom metadata is expected to exi...
Definition: AkCommonDefs.h:348
#define AKCODECID_BANK_BUS
Bank encoding for bus banks. These banks are contained in the /bus sub-folder.
Definition: AkTypes.h:1068
static const AkPipelineID AK_INVALID_PIPELINE_ID
Invalid pipeline ID (for profiling)
Definition: AkTypes.h:176
const AkUInt32 AK_LE_NATIVE_BITSPERSAMPLE
Native number of bits per sample.
Definition: AkCommonDefs.h:56
bool bPassthrough
Separate pass-through mix is supported.
Definition: AkCommonDefs.h:423
Volume ramp specified by end points "previous" and "next".
Definition: AkTypes.h:933
AkUInt16 uMaxFrames
Number of sample frames the buffer can hold. Access through AkAudioBuffer::MaxFrames().
Definition: AkCommonDefs.h:643
Iterator End() const
Returns the iterator to the end of the array.
Definition: AkArray.h:335
AkPluginID pluginID
Full plugin ID, including company ID and plugin type. See AKMAKECLASSID macro.
Definition: AkCommonDefs.h:326
AkInt8 AkPriority
Priority.
Definition: AkTypes.h:135
AkBehavioralPositioningData behavioral
Positioning data inherited from sound structures and mix busses.
Definition: AkCommonDefs.h:290
ArrayType::Iterator FindByPluginID(AkPluginID pluginID) const
Definition: AkCommonDefs.h:337
AkForceInline void Clear()
Clear the channel config. Becomes "invalid" (IsValid() returns false).
AkReal32 AkSampleType
Audio sample data type (32 bit floating point)
Definition: AkCommonDefs.h:447
AK::IAkPluginParam * pParam
Custom, pluggable medata. Note: any custom metadata is expected to exist for only the current sound e...
Definition: AkCommonDefs.h:327
void ClearReference()
Definition: AkString.h:49
const AkUInt32 AK_LE_NATIVE_SAMPLETYPE
Native data type.
Definition: AkCommonDefs.h:57
#define AK_DEFAULT_LISTENER_FRONT_X
Definition: AkCommonDefs.h:236
AkForceInline void AkMemSet(void *pDest, AkInt32 iVal, AkUInt32 uSize)
Platform Independent Helper.
void Transfer(AkArray< T, ARG_T, TAlloc, TGrowBy, TMovePolicy > &in_rSource)
Definition: AkArray.h:814
AkPipelineID instigatorID
Profiling ID of the node from which the object stems (typically the voice, instance of an actor-mixer...
Definition: AkCommonDefs.h:350
Iterator Begin() const
Returns the iterator to the first item of the array, will be End() if the array is empty.
Definition: AkArray.h:327
Ak3dData threeD
3D data used for 3D spatialization.
Definition: AkCommonDefs.h:289
AkForceInline AkUInt32 GetNumNonZeroBits(AkUInt32 in_uWord)
Struct containing metering information about a buffer. Depending on when this struct is generated,...
Definition: AkCommonDefs.h:203
AkForceInline AkUInt32 GetBitsPerSample() const
Definition: AkCommonDefs.h:97
@ AK_DataNeeded
The consumer needs more.
Definition: AkTypes.h:225
Positioning data of 3D audio objects.
Definition: AkCommonDefs.h:288
A collection of audio objects. Encapsulates the audio data and metadata of each audio object in separ...
Definition: AkCommonDefs.h:651
#define AKCODECID_BANK_EVENT
Bank encoding for event banks. These banks are contained in the /event sub-folder.
Definition: AkTypes.h:1067
AkUInt32 uBlockAlign
Number of bytes per sample frame. (For example a 5.1 PCM 16bit should have a uBlockAlign equal to 6(5...
Definition: AkCommonDefs.h:68
AkChannelConfig channelConfig
Channel configuration of the main mix.
Definition: AkCommonDefs.h:420
AkForceInline AkUInt32 GetInterleaveID() const
Definition: AkCommonDefs.h:118
#define AK_DEFAULT_LISTENER_FRONT_Z
Definition: AkCommonDefs.h:238
AkForceInline bool operator!=(const AkAudioFormat &in_other) const
Definition: AkCommonDefs.h:152
#define AKCODECID_BANK
Bank encoding.
Definition: AkTypes.h:1045
void ZeroPadToMaxFrames()
Definition: AkCommonDefs.h:587
AkForceInline bool HasLFE() const
Definition: AkCommonDefs.h:81
@ AK_SpatializationMode_None
No spatialization.
Definition: AkTypes.h:1190
AkForceInline AkUInt32 GetBlockAlign() const
Definition: AkCommonDefs.h:104
AKRESULT AllocCopy()
Definition: AkString.h:84
AkChannelMask uEmitterChannelMask
Emitter channel mask. With 3D spatialization, zeroed channels should be dropped.
Definition: AkCommonDefs.h:259
uint32_t AkUInt32
Unsigned 32-bit integer.
void SetCustomMetadata(CustomMetadata *in_aCustomMetadata, AkUInt32 in_uLength)
Definition: AkCommonDefs.h:370
AkUInt8(* AkChannelMappingFunc)(const AkChannelConfig &config, AkUInt8 idx)
Definition: AkCommonDefs.h:163
AkSpeakerPanningType
Speaker panning type: type of panning logic when object is not 3D spatialized (i.e....
Definition: AkTypes.h:1155
AkUInt32 eConfigType
Channel config type (AkChannelConfigType).
AkReal32 panLR
Pan left-right [-1,1].
Definition: AkCommonDefs.h:277
AkForceInline void AttachContiguousDeinterleavedData(void *in_pData, AkUInt16 in_uMaxFrames, AkUInt16 in_uValidFrames, AkChannelConfig in_channelConfig)
Attach deinterleaved data where channels are contiguous in memory. Allocation is performed outside.
Definition: AkCommonDefs.h:606
void Term()
Term the array. Must be called before destroying the object.
Definition: AkArray.h:537
AkReal32 spread
Spread [0,1].
Definition: AkCommonDefs.h:257
AkForceInline bool HasLFE() const
~AkAudioObject()
Destructor.
Definition: AkCommonDefs.h:312
AkPriority priority
Audio object playback priority. Object with a higher priority will be rendered using the hardware's o...
Definition: AkCommonDefs.h:355
AkForceInline bool operator==(const AkAudioFormat &in_other) const
Definition: AkCommonDefs.h:142
AkSampleType * GetLFE()
Definition: AkCommonDefs.h:577
AkForceInline void * GetInterleavedData()
Definition: AkCommonDefs.h:503
String objectName
Name string of the object, to appear in the object profiler. This is normally used by out-of-place ob...
Definition: AkCommonDefs.h:353
Custom object metadata.
Definition: AkCommonDefs.h:325
AkForceInline AkUInt32 GetNumChannels() const
Definition: AkCommonDefs.h:74
void Term()
Definition: AkString.h:39
#define AK_SPEAKER_LOW_FREQUENCY
Low-frequency speaker bit mask.
Array type for carrying custom metadata.
Definition: AkCommonDefs.h:333
static bool IsBankCodecID(AkUInt32 in_codecID)
Definition: AkCommonDefs.h:221
const AkDataTypeID AK_INT
Integer data type (uchar, short, and so on)
Definition: AkCommonDefs.h:49
#define AkForceInline
Definition: AkTypes.h:63
Defines the parameters of an audio buffer format.
Definition: AkCommonDefs.h:62
AkUInt32 uInterleaveID
Interleave ID (AkDataInterleaveID).
Definition: AkCommonDefs.h:70
AkUniqueID contextID
(Profiling) ID of the sound or bus from which the custom metadata was fetched.
Definition: AkCommonDefs.h:328
bool CheckValidSamples()
Position and orientation of objects in a "local" space.
Definition: AkTypes.h:594
AkForceInline AkUInt32 GetTypeID() const
Definition: AkCommonDefs.h:111
AkForceInline bool IsValid() const
Returns true if valid, false otherwise (as when it is constructed, or invalidated using Clear()).
AkReal32 focus
Focus [0,1].
Definition: AkCommonDefs.h:258
AkTransform xform
Object position / orientation.
Definition: AkCommonDefs.h:256
AkForceInline void ClearData()
Clear data pointer.
Definition: AkCommonDefs.h:464
void AttachInterleavedData(void *in_pData, AkUInt16 in_uMaxFrames, AkUInt16 in_uValidFrames)
Attach interleaved data. Allocation is performed outside.
Definition: AkCommonDefs.h:509
AkAudioObjects(AkUInt32 in_uNumObjects=0, AkAudioBuffer **in_ppObjectBuffers=nullptr, AkAudioObject **in_ppObjects=nullptr)
Definition: AkCommonDefs.h:652
AkAudioObject ** ppObjects
Array of pointers to audio objects.
Definition: AkCommonDefs.h:660
AkUInt32 uSampleRate
Number of samples per second.
Definition: AkCommonDefs.h:63
AK::SpeakerVolumes::VectorPtr peak
Definition: AkCommonDefs.h:206
const AkDataInterleaveID AK_NONINTERLEAVED
Non-interleaved data.
Definition: AkCommonDefs.h:53
Ak3DSpatializationMode spatMode
3D spatialization mode.
Definition: AkCommonDefs.h:281
AkReal32 panBF
Pan back-front [-1,1].
Definition: AkCommonDefs.h:278
const AkDataInterleaveID AK_INTERLEAVED
Interleaved data.
Definition: AkCommonDefs.h:52
AkSourceChannelOrdering
Definition: AkCommonDefs.h:166
void AttachInterleavedData(void *in_pData, AkUInt16 in_uMaxFrames, AkUInt16 in_uValidFrames, AkChannelConfig in_channelConfig)
Attach interleaved data with a new channel config. Allocation is performed outside.
Definition: AkCommonDefs.h:517
void SetAll(AkUInt32 in_uSampleRate, AkChannelConfig in_channelConfig, AkUInt32 in_uBitsPerSample, AkUInt32 in_uBlockAlign, AkUInt32 in_uTypeID, AkUInt32 in_uInterleaveID)
Definition: AkCommonDefs.h:125
const AkUInt32 AK_LE_NATIVE_INTERLEAVE
Native interleaved setting.
Definition: AkCommonDefs.h:58
AkForceInline AkUInt16 MaxFrames() const
Definition: AkCommonDefs.h:633

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