Version
menu_open
link
Wwise SDK 2022.1.12
AkSpatialAudioTypes.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 /// \file
28 /// Spatial audio data type definitions.
29 
30 #pragma once
31 
33 #include <AK/Tools/Common/AkLock.h>
34 
35 class AkAcousticRoom;
36 class AkAcousticPortal;
37 class AkImageSourceTriangle;
38 class AkImageSourcePlane;
39 
40 #define AK_MAX_REFLECT_ORDER 4
41 #define AK_MAX_REFLECTION_PATH_LENGTH (AK_MAX_REFLECT_ORDER + 4)
42 #define AK_MAX_SOUND_PROPAGATION_DEPTH 8
43 #define AK_MAX_SOUND_PROPAGATION_WIDTH 8
44 #define AK_DEFAULT_MOVEMENT_THRESHOLD (1.0f)
45 #define AK_SA_EPSILON (0.001f)
46 #define AK_SA_DIFFRACTION_EPSILON (0.002f) // Radians
47 #define AK_SA_DIFFRACTION_DOT_EPSILON (0.000002) // 1.f - cos(AK_SA_DIFFRACTION_EPSILON)
48 #define AK_SA_PLANE_THICKNESS_RATIO (0.005f)
49 #define AK_SA_MIN_ENVIRONMENT_ABSORPTION (0.1f)
50 #define AK_SA_MIN_ENVIRONMENT_SURFACE_AREA (1.0f)
51 
55 
56 // Max values that are used for calculating diffraction paths between the listener and a portal.
60 
63 
66 
69 
70 namespace AK
71 {
72  namespace SpatialAudio
73  {
74  typedef AkString<ArrayPoolSpatialAudio, wchar_t> WString; ///< Wide string type for use in Wwise Spatial Audio
75  typedef AkString<ArrayPoolSpatialAudio, AkOSChar> OsString; ///< OS string type for use in Wwise Spatial Audio
76  typedef AkString<ArrayPoolSpatialAudio, char> String; ///< String type for use in Wwise Spatial Audio
77  typedef AkDbString<ArrayPoolSpatialAudio, char, CAkLock> DbString; ///< Instanced string type.
78 
79  typedef AkUInt16 Idx;
80  }
81 }
82 
88 
89 #define AK_INVALID_VERTEX ((AkVertIdx)(-1))
90 #define AK_INVALID_TRIANGLE ((AkTriIdx)(-1))
91 #define AK_INVALID_SURFACE ((AkSurfIdx)(-1))
92 #define AK_INVALID_EDGE ((AkEdgeIdx)(-1))
93 
94 /// Base type for ID's used by Wwise spatial audio.
96 {
97  /// Default constructor. Creates an invalid ID.
98  constexpr AkSpatialAudioID() : id((AkUInt64)-1) {}
99 
100  /// Construct from a 64-bit int.
101  AkSpatialAudioID(AkUInt64 _id) : id(_id) {}
102 
103  /// Conversion from a pointer to a AkSpatialAudioID
104  explicit AkSpatialAudioID(const void * ptr) : id(reinterpret_cast<AkUInt64>(ptr)) {}
105 
106  bool operator == (AkSpatialAudioID rhs) const { return id == rhs.id; }
107  bool operator != (AkSpatialAudioID rhs) const { return id != rhs.id; }
108  bool operator < (AkSpatialAudioID rhs) const { return id < rhs.id; }
109  bool operator > (AkSpatialAudioID rhs) const { return id > rhs.id; }
110  bool operator <= (AkSpatialAudioID rhs) const { return id <= rhs.id; }
111  bool operator >= (AkSpatialAudioID rhs) const { return id >= rhs.id; }
112 
113  /// Determine if this ID is valid.
114  bool IsValid() const { return id != (AkUInt64)-1; }
115 
116  /// Conversion function used internally to convert from a AkSpatialAudioID to a AkGameObjectID.
118 
119  operator</span> AkUInt64 () const { return id; }
120 
122 };
123 
124 /// Spatial Audio Room ID type. This ID type exists in the same ID-space as game object ID's. The client is responsible for not choosing room ID's
125 /// that conflict with registered game objects' ID's. Internally, the spatial audio rooms and portals API manages registration and un-registration of game objects that
126 /// represent rooms using AkRoomID's provided by the client; AkRoomID's are converted to AkGameObjectID's by calling AsGameObjectID().
127 /// \sa
128 /// - \ref AK::SpatialAudio::SetRoom
129 /// - \ref AK::SpatialAudio::RemoveRoom
130 struct AkRoomID : public AkSpatialAudioID
131 {
132  /// Default constructor. Creates an invalid ID.
133  constexpr AkRoomID() : AkSpatialAudioID() {}
134 
135  /// Construct from a 64-bit int.
137 
138  /// Conversion from a pointer to a AkRoomID
139  explicit AkRoomID(const void * ptr) : AkSpatialAudioID(ptr) {}
140 
141  /// Conversion function used to convert AkRoomID's to AkGameObjectIDs.
142  AkGameObjectID AsGameObjectID() const { return IsValid() ? (AkGameObjectID)id : OutdoorsGameObjID; }
143 
144  /// Conversion function used to convert to AkGameObjectIDs to AkRoomID.
145  static AkRoomID FromGameObjectID(AkGameObjectID in_fromGameObject)
146  {
147  AkRoomID id;
148  if (in_fromGameObject != OutdoorsGameObjID)
149  id.id = (AkUInt64)in_fromGameObject;
150  return id;
151  }
152 
153 private:
154  /// A game object ID that is in the reserved range, used for 'outdoor' rooms, i.e. when not in a room.
155  /// \akwarning This AkGameObjectID is the underlying game object ID of the outdoor room, and should not be confused with the actual outdoor room's ID, AK::SpatialAudio::kOutdoorRoomID.\endakwarning
156  static const AkGameObjectID OutdoorsGameObjID = (AkGameObjectID)-4;
157 };
158 
159 namespace AK
160 {
161  namespace SpatialAudio
162  {
163  /// The outdoor room ID. This room is created automatically and is typically used for outdoors, i.e. when not in a room.
165  }
166 }
167 
168 ///< Unique ID for portals. This ID type exists in the same ID-space as game object ID's. The client is responsible for not choosing portal ID's
169 /// that conflict with registered game objects' ID's. Internally, the spatial audio rooms and portals API manages registration and un-registration of game objects that
170 /// represent portals using AkPortalID's provided by the client; AkPortalID's are convertied to AkGameObjectID's by calling AsGameObjectID().
171 /// \sa
172 /// - \ref AK::SpatialAudio::SetPortal
173 /// - \ref AK::SpatialAudio::RemovePortal
175 
176 ///< Unique ID for identifying geometry sets. Chosen by the client using any means desired.
177 /// \sa
178 /// - \ref AK::SpatialAudio::SetGeometry
179 /// - \ref AK::SpatialAudio::RemoveGeometry
181 
182 ///< Unique ID for identifying geometry set instances. Chosen by the client using any means desired.
183 /// \sa
184 /// - \ref AK::SpatialAudio::SetGeometry
185 /// - \ref AK::SpatialAudio::RemoveGeometry
AkUInt16 AkTriIdx
bool operator>(AkSpatialAudioID rhs) const
uint16_t AkUInt16
Unsigned 16-bit integer.
const AkUInt32 kDefaultDiffractionMaxPaths
Audiokinetic namespace.
AkArrayAllocatorAlignedSimd< AkMemID_SpatialAudio > ArrayPoolSpatialAudioSIMD
AkArrayAllocatorNoAlign< AkMemID_SpatialAudioPaths > ArrayPoolSpatialAudioPaths
AkUInt64 AkGameObjectID
Game object ID.
Definition: AkTypes.h:128
static AkRoomID FromGameObjectID(AkGameObjectID in_fromGameObject)
Conversion function used to convert to AkGameObjectIDs to AkRoomID.
AkArrayAllocatorAlignedSimd< AkMemID_SpatialAudioGeometry > ArrayPoolSpatialAudioGeometrySIMD
AkSpatialAudioID(AkUInt64 _id)
Construct from a 64-bit int.
AkDbString< ArrayPoolSpatialAudio, char, CAkLock > DbString
Instanced string type.
float AkReal32
32-bit floating point
AkUInt16 AkSurfIdx
bool operator==(AkSpatialAudioID rhs) const
bool operator!=(AkSpatialAudioID rhs) const
const AkReal32 kMaxDiffraction
AkString< ArrayPoolSpatialAudio, AkOSChar > OsString
OS string type for use in Wwise Spatial Audio.
AkSpatialAudioID(const void *ptr)
Conversion from a pointer to a AkSpatialAudioID.
AkString< ArrayPoolSpatialAudio, char > String
String type for use in Wwise Spatial Audio.
AkUInt16 AkEdgeReceptorIdx
AkSpatialAudioID AkGeometrySetID
AkGameObjectID AsGameObjectID() const
Conversion function used to convert AkRoomID's to AkGameObjectIDs.
AkRoomID(AkUInt64 _id)
Construct from a 64-bit int.
bool operator>=(AkSpatialAudioID rhs) const
AkGameObjectID AsGameObjectID() const
Conversion function used internally to convert from a AkSpatialAudioID to a AkGameObjectID.
Base type for ID's used by Wwise spatial audio.
bool IsValid() const
Determine if this ID is valid.
constexpr AkSpatialAudioID()
Default constructor. Creates an invalid ID.
bool operator<(AkSpatialAudioID rhs) const
constexpr AkRoomID kOutdoorRoomID
The outdoor room ID. This room is created automatically and is typically used for outdoors,...
constexpr AkRoomID()
Default constructor. Creates an invalid ID.
AkUInt16 AkEdgeIdx
AkRoomID(const void *ptr)
Conversion from a pointer to a AkRoomID.
uint64_t AkUInt64
Unsigned 64-bit integer.
bool operator<=(AkSpatialAudioID rhs) const
uint32_t AkUInt32
Unsigned 32-bit integer.
AkArrayAllocatorNoAlign< AkMemID_SpatialAudio > ArrayPoolSpatialAudio
AkUInt16 AkVertIdx
AkSpatialAudioID AkPortalID
AkArrayAllocatorAlignedSimd< AkMemID_SpatialAudioPaths > ArrayPoolSpatialAudioPathsSIMD
const AkUInt32 kDefaultDiffractionMaxEdges
const AkUInt32 kPortalToPortalDiffractionMaxPaths
AkString< ArrayPoolSpatialAudio, wchar_t > WString
Wide string type for use in Wwise Spatial Audio.
AkArrayAllocatorNoAlign< AkMemID_SpatialAudioGeometry > ArrayPoolSpatialAudioGeometry
const AkUInt32 kDiffractionMaxEdges
const AkUInt32 kDiffractionMaxPaths
AkSpatialAudioID AkGeometryInstanceID

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