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

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