Table of Contents

include/AK/SpatialAudio/Common/AkSpatialAudioTypes.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 The content of this file includes portions of the AUDIOKINETIC Wwise Technology
00003 released in source code form as part of the SDK installer package.
00004 
00005 Commercial License Usage
00006 
00007 Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
00008 may use this file in accordance with the end user license agreement provided
00009 with the software or, alternatively, in accordance with the terms contained in a
00010 written agreement between you and Audiokinetic Inc.
00011 
00012 Apache License Usage
00013 
00014 Alternatively, this file may be used under the Apache License, Version 2.0 (the
00015 "Apache License"); you may not use this file except in compliance with the
00016 Apache License. You may obtain a copy of the Apache License at
00017 http://www.apache.org/licenses/LICENSE-2.0.
00018 
00019 Unless required by applicable law or agreed to in writing, software distributed
00020 under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
00021 OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
00022 the specific language governing permissions and limitations under the License.
00023 
00024 Version: <VERSION>  Build: <BUILDNUMBER>
00025 Copyright (c) <COPYRIGHTYEAR> Audiokinetic Inc.
00026 *******************************************************************************/
00027 
00028 /// \file 
00029 /// Spatial audio data type definitions.
00030 
00031 #pragma once
00032 
00033 #include <AK/Tools/Common/AkKeyArray.h>
00034 #include <AK/Tools/Common/AkSet.h>
00035 #include <AK/Tools/Common/AkString.h>
00036 #include <AK/Tools/Common/AkLock.h>
00037 
00038 class AkAcousticRoom;
00039 class AkAcousticPortal;
00040 class AkImageSourceTriangle;
00041 class AkImageSourcePlane;
00042 
00043 #define AK_MAX_REFLECT_ORDER 4
00044 #define AK_MAX_REFLECTION_PATH_LENGTH (AK_MAX_REFLECT_ORDER + 2)
00045 #define AK_MAX_SOUND_PROPAGATION_DEPTH 8
00046 #define AK_DEFAULT_DIFFR_SHADOW_DEGREES (30.0f)
00047 #define AK_DEFAULT_DIFFR_SHADOW_ATTEN (2.0f)
00048 #define AK_DEFAULT_MOVEMENT_THRESHOLD (1.0f)
00049 #define AK_SA_EPSILON (0.001f)
00050 #define AK_SA_DIFFRACTION_EPSILON (0.1f) // Radians
00051 #define AK_SA_PLANE_THICKNESS_RATIO (0.005f)
00052 
00053 const AkReal32 kDefaultMaxPathLength = 100.f;
00054 
00055 const AkUInt32 kDefaultDiffractionMaxEdges = 8;
00056 const AkUInt32 kDefaultDiffractionMaxPaths = 8;
00057 const AkReal32 kMaxDiffraction = 1.0f;
00058 
00059 // Max values that are used for calculating diffraction paths between the listener and a portal.
00060 const AkUInt32 kListenerDiffractionMaxEdges = 8;
00061 const AkUInt32 kListenerDiffractionMaxPaths = 8;
00062 const AkUInt32 kPortalToPortalDiffractionMaxPaths = 8;
00063 
00064 extern AkMemPoolId g_SpatialAudioPoolId;
00065 
00066 AK_DEFINE_ARRAY_POOL(_ArrayPoolSpatialAudio, g_SpatialAudioPoolId);
00067 typedef AkArrayAllocatorNoAlign<_ArrayPoolSpatialAudio> ArrayPoolSpatialAudio;
00068 typedef AkArrayAllocatorAlignedSimd<_ArrayPoolSpatialAudio> ArrayPoolSpatialAudioSIMD;
00069 
00070 namespace AK
00071 {
00072     namespace SpatialAudio
00073     {
00074         typedef AkString<ArrayPoolSpatialAudio, wchar_t> WString;       ///< Wide string type for use in Wwise Spatial Audio
00075         typedef AkString<ArrayPoolSpatialAudio, AkOSChar> OsString;     ///< OS string type for use in Wwise Spatial Audio
00076         typedef AkString<ArrayPoolSpatialAudio, char> String;           ///< String type for use in Wwise Spatial Audio
00077         typedef AkDbString<ArrayPoolSpatialAudio, char, CAkLock> DbString; ///< Instanced string type.
00078 
00079         typedef AkUInt16 Idx;
00080     }
00081 }
00082 
00083 typedef AkUInt16 AkVertIdx;
00084 typedef AkUInt16 AkTriIdx;
00085 typedef AkUInt16 AkSurfIdx;
00086 typedef AkUInt16 AkEdgeIdx;
00087 
00088 #define AK_INVALID_VERTEX ((AkVertIdx)(-1))
00089 #define AK_INVALID_TRIANGLE ((AkTriIdx)(-1))
00090 #define AK_INVALID_SURFACE ((AkSurfIdx)(-1))
00091 #define AK_INVALID_EDGE ((AkEdgeIdx)(-1))
00092 
00093 /// Base type for ID's used by Wwise spatial audio.  
00094 struct AkSpatialAudioID
00095 {
00096     /// Default constructor.  Creates an invalid ID.
00097     AkSpatialAudioID() : id((AkUInt64)-1) {}
00098     
00099     /// Construct from a 64-bit int.
00100     AkSpatialAudioID(AkUInt64 _id) : id(_id) {}
00101 
00102     /// Conversion from a pointer to a AkSpatialAudioID
00103     explicit AkSpatialAudioID(const void * ptr) : id(reinterpret_cast<AkUInt64>(ptr)) {}
00104 
00105     bool operator == (AkSpatialAudioID rhs) const { return id == rhs.id; }
00106     bool operator != (AkSpatialAudioID rhs) const { return id != rhs.id; }
00107     bool operator < (AkSpatialAudioID rhs) const { return id < rhs.id; }
00108     bool operator > (AkSpatialAudioID rhs) const { return id > rhs.id; }
00109     bool operator <= (AkSpatialAudioID rhs) const { return id <= rhs.id; }
00110     bool operator >= (AkSpatialAudioID rhs) const { return id >= rhs.id; }
00111 
00112     /// Determine if this ID is valid.
00113     bool IsValid() const { return id != (AkUInt64)-1; }
00114 
00115     /// Conversion function used internally to convert from a AkSpatialAudioID to a AkGameObjectID.
00116     AkGameObjectID AsGameObjectID() const { return (AkGameObjectID)id; }
00117     
00118     operator AkUInt64 () { return id; }
00119 
00120     AkUInt64 id;
00121 };
00122 
00123 /// 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
00124 /// 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 
00125 /// represent rooms using AkRoomID's provided by the client; AkRoomID's are convertied to AkGameObjectID's by calling AsGameObjectID(). 
00126 /// \sa 
00127 /// - \ref AK::SpatialAudio::SetRoom
00128 /// - \ref AK::SpatialAudio::RemoveRoom
00129 struct AkRoomID : public AkSpatialAudioID
00130 {
00131     /// A game object ID that is in the reserved range, used for 'outdoor' rooms, ie when not in a room.
00132     static const AkGameObjectID OutdoorsGameObjID = (AkGameObjectID)-4;
00133 
00134     /// Default constructor.  Creates an invalid ID.
00135     AkRoomID() : AkSpatialAudioID() {}
00136 
00137     /// Construct from a 64-bit int.
00138     AkRoomID(AkUInt64 _id) : AkSpatialAudioID(_id) {}
00139 
00140     /// Conversion from a pointer to a AkRoomID
00141     explicit AkRoomID(const void * ptr) : AkSpatialAudioID(ptr) {}
00142 
00143     /// Conversion function used internally to convert AkRoomID's to AkGameObjectIDs.
00144     AkGameObjectID AsGameObjectID() const { return IsValid() ? (AkGameObjectID)id : OutdoorsGameObjID; }
00145 };
00146 
00147 ///< 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
00148 /// 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 
00149 /// represent portals using AkPortalID's provided by the client; AkPortalID's are convertied to AkGameObjectID's by calling AsGameObjectID(). 
00150 /// \sa 
00151 /// - \ref AK::SpatialAudio::SetPortal
00152 /// - \ref AK::SpatialAudio::RemovePortal  
00153 typedef AkSpatialAudioID AkPortalID;        
00154 
00155 ///< Unique ID for identifying geometry sets.  Chosen by the client using any means desired.  
00156 /// \sa 
00157 /// - \ref AK::SpatialAudio::SetGeometry
00158 /// - \ref AK::SpatialAudio::RemoveGeometry
00159 typedef AkSpatialAudioID AkGeometrySetID;
00160 
00161