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_SA_EPSILON (0.001f)
00049 #define AK_SA_PLANE_THICKNESS_RATIO (0.005f)
00050 
00051 const AkReal32 kDefaultMaxPathLength = 100.f;
00052 
00053 const AkReal32 kMaxDiffraction = 1.0f;
00054 
00055 extern AkMemPoolId g_SpatialAudioPoolId;
00056 
00057 AK_DEFINE_ARRAY_POOL(_ArrayPoolSpatialAudio, g_SpatialAudioPoolId);
00058 typedef AkArrayAllocatorNoAlign<_ArrayPoolSpatialAudio> ArrayPoolSpatialAudio;
00059 typedef AkArrayAllocatorAlignedSimd<_ArrayPoolSpatialAudio> ArrayPoolSpatialAudioSIMD;
00060 
00061 namespace AK
00062 {
00063     namespace SpatialAudio
00064     {
00065         typedef AkString<ArrayPoolSpatialAudio, wchar_t> WString;       ///< Wide string type for use in Wwise Spatial Audio
00066         typedef AkString<ArrayPoolSpatialAudio, AkOSChar> OsString;     ///< OS string type for use in Wwise Spatial Audio
00067         typedef AkString<ArrayPoolSpatialAudio, char> String;           ///< String type for use in Wwise Spatial Audio
00068         typedef AkDbString<ArrayPoolSpatialAudio, char, CAkLock> DbString; ///< Instanced string type.
00069 
00070         typedef AkUInt16 Idx;
00071     }
00072 }
00073 
00074 typedef AkUInt16 AkVertIdx;
00075 typedef AkUInt16 AkTriIdx;
00076 typedef AkUInt16 AkSurfIdx;
00077 typedef AkUInt16 AkEdgeIdx;
00078 
00079 #define AK_INVALID_VERTEX ((AkVertIdx)(-1))
00080 #define AK_INVALID_TRIANGLE ((AkTriIdx)(-1))
00081 #define AK_INVALID_SURFACE ((AkSurfIdx)(-1))
00082 #define AK_INVALID_EDGE ((AkEdgeIdx)(-1))
00083 
00084 /// Base type for ID's used by Wwise spatial audio.  
00085 struct AkSpatialAudioID
00086 {
00087     /// Default constructor.  Creates an invalid ID.
00088     AkSpatialAudioID() : id((AkUInt64)-1) {}
00089     
00090     /// Construct from a 64-bit int.
00091     AkSpatialAudioID(AkUInt64 _id) : id(_id) {}
00092 
00093     /// Conversion from a pointer to a AkSpatialAudioID
00094     explicit AkSpatialAudioID(const void * ptr) : id(reinterpret_cast<AkUInt64>(ptr)) {}
00095 
00096     bool operator == (AkSpatialAudioID rhs) const { return id == rhs.id; }
00097     bool operator != (AkSpatialAudioID rhs) const { return id != rhs.id; }
00098     bool operator < (AkSpatialAudioID rhs) const { return id < rhs.id; }
00099     bool operator > (AkSpatialAudioID rhs) const { return id > rhs.id; }
00100     bool operator <= (AkSpatialAudioID rhs) const { return id <= rhs.id; }
00101     bool operator >= (AkSpatialAudioID rhs) const { return id >= rhs.id; }
00102 
00103     /// Determine if this ID is valid.
00104     bool IsValid() const { return id != (AkUInt64)-1; }
00105 
00106     /// Conversion function used internally to convert from a AkSpatialAudioID to a AkGameObjectID.
00107     AkGameObjectID AsGameObjectID() const { return (AkGameObjectID)id; }
00108     
00109     operator AkUInt64 () { return id; }
00110 
00111     AkUInt64 id;
00112 };
00113 
00114 /// 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
00115 /// 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 
00116 /// represent rooms using AkRoomID's provided by the client; AkRoomID's are convertied to AkGameObjectID's by calling AsGameObjectID(). 
00117 /// \sa 
00118 /// - \ref AK::SpatialAudio::SetRoom
00119 /// - \ref AK::SpatialAudio::RemoveRoom
00120 struct AkRoomID : public AkSpatialAudioID
00121 {
00122     /// A game object ID that is in the reserved range, used for 'outdoor' rooms, ie when not in a room.
00123     static const AkGameObjectID OutdoorsGameObjID = (AkGameObjectID)-4;
00124 
00125     /// Default constructor.  Creates an invalid ID.
00126     AkRoomID() : AkSpatialAudioID() {}
00127 
00128     /// Construct from a 64-bit int.
00129     AkRoomID(AkUInt64 _id) : AkSpatialAudioID(_id) {}
00130 
00131     /// Conversion from a pointer to a AkRoomID
00132     explicit AkRoomID(const void * ptr) : AkSpatialAudioID(ptr) {}
00133 
00134     /// Conversion function used internally to convert AkRoomID's to AkGameObjectIDs.
00135     AkGameObjectID AsGameObjectID() const { return IsValid() ? (AkGameObjectID)id : OutdoorsGameObjID; }
00136 };
00137 
00138 ///< 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
00139 /// 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 
00140 /// represent portals using AkPortalID's provided by the client; AkPortalID's are convertied to AkGameObjectID's by calling AsGameObjectID(). 
00141 /// \sa 
00142 /// - \ref AK::SpatialAudio::SetPortal
00143 /// - \ref AK::SpatialAudio::RemovePortal  
00144 typedef AkSpatialAudioID AkPortalID;        
00145 
00146 ///< Unique ID for identifying geometry sets.  Chosen by the client using any means desired.  
00147 /// \sa 
00148 /// - \ref AK::SpatialAudio::SetGeometry
00149 /// - \ref AK::SpatialAudio::RemoveGeometry
00150 typedef AkSpatialAudioID AkGeometrySetID;
00151 
00152