Version
menu_open
link
Wwise SDK 2019.1.11
AkSpatialAudioTypes.h
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 
33 #include <AK/Tools/Common/AkKeyArray.h>
34 #include <AK/Tools/Common/AkSet.h>
35 #include <AK/Tools/Common/AkString.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 + 2)
45 #define AK_MAX_SOUND_PROPAGATION_DEPTH 8
46 #define AK_DEFAULT_DIFFR_SHADOW_DEGREES (30.0f)
47 #define AK_DEFAULT_DIFFR_SHADOW_ATTEN (2.0f)
48 #define AK_DEFAULT_MOVEMENT_THRESHOLD (1.0f)
49 #define AK_SA_EPSILON (0.001f)
50 #define AK_SA_DIFFRACTION_EPSILON (0.1f) // Radians
51 #define AK_SA_PLANE_THICKNESS_RATIO (0.005f)
52 
53 const AkReal32 kDefaultMaxPathLength = 100.f;
54 
55 const AkUInt32 kDefaultDiffractionMaxEdges = 8;
56 const AkUInt32 kDefaultDiffractionMaxPaths = 8;
57 const AkReal32 kMaxDiffraction = 1.0f;
58 
59 // Max values that are used for calculating diffraction paths between the listener and a portal.
60 const AkUInt32 kListenerDiffractionMaxEdges = 8;
61 const AkUInt32 kListenerDiffractionMaxPaths = 8;
62 const AkUInt32 kPortalToPortalDiffractionMaxPaths = 8;
63 
64 extern AkMemPoolId g_SpatialAudioPoolId;
65 
66 AK_DEFINE_ARRAY_POOL(_ArrayPoolSpatialAudio, g_SpatialAudioPoolId);
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 
83 typedef AkUInt16 AkVertIdx;
84 typedef AkUInt16 AkTriIdx;
85 typedef AkUInt16 AkSurfIdx;
86 typedef AkUInt16 AkEdgeIdx;
87 
88 #define AK_INVALID_VERTEX ((AkVertIdx)(-1))
89 #define AK_INVALID_TRIANGLE ((AkTriIdx)(-1))
90 #define AK_INVALID_SURFACE ((AkSurfIdx)(-1))
91 #define AK_INVALID_EDGE ((AkEdgeIdx)(-1))
92 
93 /// Base type for ID's used by Wwise spatial audio.
95 {
96  /// Default constructor. Creates an invalid ID.
97  AkSpatialAudioID() : id((AkUInt64)-1) {}
98 
99  /// Construct from a 64-bit int.
100  AkSpatialAudioID(AkUInt64 _id) : id(_id) {}
101 
102  /// Conversion from a pointer to a AkSpatialAudioID
103  explicit AkSpatialAudioID(const void * ptr) : id(reinterpret_cast<AkUInt64>(ptr)) {}
104 
105  bool operator == (AkSpatialAudioID rhs) const { return id == rhs.id; }
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 
112  /// Determine if this ID is valid.
113  bool IsValid() const { return id != (AkUInt64)-1; }
114 
115  /// Conversion function used internally to convert from a AkSpatialAudioID to a AkGameObjectID.
116  AkGameObjectID AsGameObjectID() const { return (AkGameObjectID)id; }
117 
118  operator</span> AkUInt64 () { return id; }
119 
120  AkUInt64 id;
121 };
122 
123 /// 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
124 /// 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
125 /// represent rooms using AkRoomID's provided by the client; AkRoomID's are convertied to AkGameObjectID's by calling AsGameObjectID().
126 /// \sa
127 /// - \ref AK::SpatialAudio::SetRoom
128 /// - \ref AK::SpatialAudio::RemoveRoom
129 struct AkRoomID : public AkSpatialAudioID
130 {
131  /// A game object ID that is in the reserved range, used for 'outdoor' rooms, ie when not in a room.
132  static const AkGameObjectID OutdoorsGameObjID = (AkGameObjectID)-4;
133 
134  /// Default constructor. Creates an invalid ID.
136 
137  /// Construct from a 64-bit int.
138  AkRoomID(AkUInt64 _id) : AkSpatialAudioID(_id) {}
139 
140  /// Conversion from a pointer to a AkRoomID
141  explicit AkRoomID(const void * ptr) : AkSpatialAudioID(ptr) {}
142 
143  /// Conversion function used internally to convert AkRoomID's to AkGameObjectIDs.
144  AkGameObjectID AsGameObjectID() const { return IsValid() ? (AkGameObjectID)id : OutdoorsGameObjID; }
145 };
146 
147 ///< 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
148 /// 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
149 /// represent portals using AkPortalID's provided by the client; AkPortalID's are convertied to AkGameObjectID's by calling AsGameObjectID().
150 /// \sa
151 /// - \ref AK::SpatialAudio::SetPortal
152 /// - \ref AK::SpatialAudio::RemovePortal
154 
155 ///< Unique ID for identifying geometry sets. Chosen by the client using any means desired.
156 /// \sa
157 /// - \ref AK::SpatialAudio::SetGeometry
158 /// - \ref AK::SpatialAudio::RemoveGeometry
160 
161 
bool operator>(AkSpatialAudioID rhs) const
Audiokinetic namespace.
AkSpatialAudioID(AkUInt64 _id)
Construct from a 64-bit int.
AkDbString< ArrayPoolSpatialAudio, char, CAkLock > DbString
Instanced string type.
AkRoomID()
Default constructor. Creates an invalid ID.
bool operator==(AkSpatialAudioID rhs) const
bool operator!=(AkSpatialAudioID rhs) const
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.
AkGameObjectID AsGameObjectID() const
Conversion function used internally 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.
bool operator<(AkSpatialAudioID rhs) const
AkRoomID(const void *ptr)
Conversion from a pointer to a AkRoomID.
bool operator<=(AkSpatialAudioID rhs) const
AkSpatialAudioID()
Default constructor. Creates an invalid ID.
static const AkGameObjectID OutdoorsGameObjID
A game object ID that is in the reserved range, used for 'outdoor' rooms, ie when not in a room.
AkString< ArrayPoolSpatialAudio, wchar_t > WString
Wide string type for use in Wwise Spatial Audio.

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