Wwise Version
Wwise SDK 2019.2.13
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 Version: <VERSION> Build: <BUILDNUMBER>
25 Copyright (c) <COPYRIGHTYEAR> Audiokinetic Inc.
26 *******************************************************************************/
27 
28 /// \file
29 /// Spatial audio data type definitions.
30 
31 #pragma once
32 
34 #include <AK/Tools/Common/AkSet.h>
36 #include <AK/Tools/Common/AkLock.h>
37 
38 class AkAcousticRoom;
39 class AkAcousticPortal;
40 class AkImageSourceTriangle;
41 class AkImageSourcePlane;
42 
43 #define AK_MAX_REFLECT_ORDER 4
44 #define AK_MAX_REFLECTION_PATH_LENGTH (AK_MAX_REFLECT_ORDER + 4)
45 #define AK_MAX_SOUND_PROPAGATION_DEPTH 8
46 #define AK_DEFAULT_DIFFR_SHADOW_DEGREES (30.0f)
47 #define AK_DEFAULT_DIFFR_SHADOW_ATTEN (1.0f)
48 #define AK_DEFAULT_MOVEMENT_THRESHOLD (1.0f)
49 #define AK_DEFAULT_REFLECTIONS_ORDER (1)
50 #define AK_SA_EPSILON (0.001f)
51 #define AK_SA_DIFFRACTION_EPSILON (0.002f) // Radians
52 #define AK_SA_DIFFRACTION_DOT_EPSILON (0.000002) // 1.f - cos(AK_SA_DIFFRACTION_EPSILON)
53 #define AK_SA_PLANE_THICKNESS_RATIO (0.005f)
54 
56 
60 
61 // Max values that are used for calculating diffraction paths between the listener and a portal.
65 
68 
71 
74 
75 namespace AK
76 {
77  namespace SpatialAudio
78  {
79  typedef AkString<ArrayPoolSpatialAudio, wchar_t> WString; ///< Wide string type for use in Wwise Spatial Audio
80  typedef AkString<ArrayPoolSpatialAudio, AkOSChar> OsString; ///< OS string type for use in Wwise Spatial Audio
81  typedef AkString<ArrayPoolSpatialAudio, char> String; ///< String type for use in Wwise Spatial Audio
82  typedef AkDbString<ArrayPoolSpatialAudio, char, CAkLock> DbString; ///< Instanced string type.
83 
84  typedef AkUInt16 Idx;
85  }
86 }
87 
92 
93 #define AK_INVALID_VERTEX ((AkVertIdx)(-1))
94 #define AK_INVALID_TRIANGLE ((AkTriIdx)(-1))
95 #define AK_INVALID_SURFACE ((AkSurfIdx)(-1))
96 #define AK_INVALID_EDGE ((AkEdgeIdx)(-1))
97 
98 /// Base type for ID's used by Wwise spatial audio.
100 {
101  /// Default constructor. Creates an invalid ID.
103 
104  /// Construct from a 64-bit int.
105  AkSpatialAudioID(AkUInt64 _id) : id(_id) {}
106 
107  /// Conversion from a pointer to a AkSpatialAudioID
108  explicit AkSpatialAudioID(const void * ptr) : id(reinterpret_cast<AkUInt64>(ptr)) {}
109 
110  bool operator == (AkSpatialAudioID rhs) const { return id == rhs.id; }
111  bool operator != (AkSpatialAudioID rhs) const { return id != rhs.id; }
112  bool operator < (AkSpatialAudioID rhs) const { return id < rhs.id; }
113  bool operator > (AkSpatialAudioID rhs) const { return id > rhs.id; }
114  bool operator <= (AkSpatialAudioID rhs) const { return id <= rhs.id; }
115  bool operator >= (AkSpatialAudioID rhs) const { return id >= rhs.id; }
116 
117  /// Determine if this ID is valid.
118  bool IsValid() const { return id != (AkUInt64)-1; }
119 
120  /// Conversion function used internally to convert from a AkSpatialAudioID to a AkGameObjectID.
122 
123  operator</span> AkUInt64 () { return id; }
124 
126 };
127 
128 /// 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
129 /// 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
130 /// represent rooms using AkRoomID's provided by the client; AkRoomID's are converted to AkGameObjectID's by calling AsGameObjectID().
131 /// \sa
132 /// - \ref AK::SpatialAudio::SetRoom
133 /// - \ref AK::SpatialAudio::RemoveRoom
134 struct AkRoomID : public AkSpatialAudioID
135 {
136  /// Default constructor. Creates an invalid ID.
138 
139  /// Construct from a 64-bit int.
141 
142  /// Conversion from a pointer to a AkRoomID
143  explicit AkRoomID(const void * ptr) : AkSpatialAudioID(ptr) {}
144 
145  /// Conversion function used internally to convert AkRoomID's to AkGameObjectIDs.
146  AkGameObjectID AsGameObjectID() const { return IsValid() ? (AkGameObjectID)id : OutdoorsGameObjID; }
147 
148  /// Conversion function used internally to convert to AkGameObjectIDs to AkRoomID.
149  static AkRoomID FromGameObjectID(AkGameObjectID in_fromGameObject)
150  {
151  AkRoomID id;
152  if (in_fromGameObject != OutdoorsGameObjID)
153  id.id = (AkUInt64)in_fromGameObject;
154  return id;
155  }
156 
157 private:
158  /// A game object ID that is in the reserved range, used for 'outdoor' rooms, i.e. when not in a room.
159  /// \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
160  static const AkGameObjectID OutdoorsGameObjID = (AkGameObjectID)-4;
161 };
162 
163 namespace AK
164 {
165  namespace SpatialAudio
166  {
167  /// The outdoor room ID. This room is created automatically and is typically used for outdoors, i.e. when not in a room.
168  static const AkRoomID kOutdoorRoomID = AkRoomID();
169  }
170 }
171 
172 ///< 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
173 /// 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
174 /// represent portals using AkPortalID's provided by the client; AkPortalID's are convertied to AkGameObjectID's by calling AsGameObjectID().
175 /// \sa
176 /// - \ref AK::SpatialAudio::SetPortal
177 /// - \ref AK::SpatialAudio::RemovePortal
179 
180 ///< Unique ID for identifying geometry sets. Chosen by the client using any means desired.
181 /// \sa
182 /// - \ref AK::SpatialAudio::SetGeometry
183 /// - \ref AK::SpatialAudio::RemoveGeometry
185 
AkUInt16 AkTriIdx
bool operator>(AkSpatialAudioID rhs) const
uint64_t AkUInt64
Unsigned 64-bit integer.
Definition: AkTypes.h:86
const AkUInt32 kDefaultDiffractionMaxPaths
Audiokinetic namespace.
AkArrayAllocatorAlignedSimd< AkMemID_SpatialAudio > ArrayPoolSpatialAudioSIMD
AkArrayAllocatorNoAlign< AkMemID_SpatialAudioPaths > ArrayPoolSpatialAudioPaths
AkUInt64 AkGameObjectID
Game object ID.
Definition: AkTypes.h:65
static AkRoomID FromGameObjectID(AkGameObjectID in_fromGameObject)
Conversion function used internally 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.
AkUInt16 AkSurfIdx
AkRoomID()
Default constructor. Creates an invalid ID.
bool operator==(AkSpatialAudioID rhs) const
bool operator!=(AkSpatialAudioID rhs) const
static const AkRoomID kOutdoorRoomID
The outdoor room ID. This room is created automatically and is typically used for outdoors,...
const AkReal32 kMaxDiffraction
AkString< ArrayPoolSpatialAudio, AkOSChar > OsString
OS string type for use in Wwise Spatial Audio.
Definition: AkString.h:61
AkSpatialAudioID(const void *ptr)
Conversion from a pointer to a AkSpatialAudioID.
AkString< ArrayPoolSpatialAudio, char > String
String type for use in Wwise Spatial Audio.
AkSpatialAudioID AkGeometrySetID
AkGameObjectID AsGameObjectID() const
Conversion function used internally to convert AkRoomID's to AkGameObjectIDs.
uint16_t AkUInt16
Unsigned 16-bit integer.
Definition: AkTypes.h:84
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.
bool operator<(AkSpatialAudioID rhs) const
AkUInt16 AkEdgeIdx
AkRoomID(const void *ptr)
Conversion from a pointer to a AkRoomID.
bool operator<=(AkSpatialAudioID rhs) const
float AkReal32
32-bit floating point
Definition: AkTypes.h:103
AkArrayAllocatorNoAlign< AkMemID_SpatialAudio > ArrayPoolSpatialAudio
AkSpatialAudioID()
Default constructor. Creates an invalid ID.
AkUInt16 AkVertIdx
AkSpatialAudioID AkPortalID
AkArrayAllocatorAlignedSimd< AkMemID_SpatialAudioPaths > ArrayPoolSpatialAudioPathsSIMD
const AkUInt32 kDefaultDiffractionMaxEdges
uint32_t AkUInt32
Unsigned 32-bit integer.
Definition: AkTypes.h:85
const AkUInt32 kPortalToPortalDiffractionMaxPaths
const AkReal32 kDefaultMaxPathLength
AkString< ArrayPoolSpatialAudio, wchar_t > WString
Wide string type for use in Wwise Spatial Audio.
AkArrayAllocatorNoAlign< AkMemID_SpatialAudioGeometry > ArrayPoolSpatialAudioGeometry
const AkUInt32 kDiffractionMaxEdges
const AkUInt32 kDiffractionMaxPaths