버전
menu_open
알림: 고객님의 주요 출시 버전( 2019.1.11.7296 )에 해당하는 최신 설명서로 이동했습니다. 특정 버전의 설명서를 보시려면 Audiokinetic 런처에서 오프라인 설명서를 다운로드하고 Wwise Authoring의 Offline Documentation을 확인하세요.
link
Wwise SDK 2019.1.11
AkBankReadHelpers.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 #ifndef _AK_BANKREADHELPERS_H_
29 #define _AK_BANKREADHELPERS_H_
30 
31 namespace AK
32 {
33  template< typename T >
34  inline T ReadUnaligned(const AkUInt8* in_pVal)
35  {
36 #if defined(__GNUC__)
37  typedef T __attribute__((aligned(1))) UnalignedT;
38  return *reinterpret_cast<const UnalignedT *>(in_pVal);
39 #elif defined(_MSC_VER) && !defined(AK_CPU_X86)
40  return *reinterpret_cast<const T __unaligned *>(in_pVal); // __unaligned not supported on 32-bit x86
41 #else
42  return *reinterpret_cast<const T *>(in_pVal);
43 #endif
44  }
45 
46  template< typename T >
47  inline void WriteUnaligned(AkUInt8* out_pVal, const T in_val)
48  {
49 #if defined(__GNUC__)
50  typedef T __attribute__((aligned(1))) UnalignedT;
51  *reinterpret_cast<UnalignedT *>(out_pVal) = in_val;
52 #elif defined(_MSC_VER) && !defined(AK_CPU_X86)
53  *reinterpret_cast<T __unaligned *>(out_pVal) = in_val; // __unaligned not supported on 32-bit x86
54 #else
55  *reinterpret_cast<T *>(out_pVal) = in_val;
56 #endif
57  }
58 
59  /// Read data from bank and advance pointer.
60  template< typename T >
61  inline T ReadBankData(
62  AkUInt8*& in_rptr
63 #ifdef _DEBUG
64  , AkUInt32& in_rSize
65 #endif
66  )
67  {
68  T l_Value = ReadUnaligned<T>(in_rptr);
69 
70  in_rptr += sizeof(T);
71 #ifdef _DEBUG
72  in_rSize -= sizeof(T);
73 #endif
74  return l_Value;
75  }
76 
77  template< typename T >
79  AkUInt8*& in_rptr
80 #ifdef _DEBUG
81  , AkUInt32& in_rSize
82 #endif
83  )
84  {
85  AkUInt32 l_Value = 0;
86 
87  AkUInt8 currentByte = *in_rptr;
88  ++in_rptr;
89 #ifdef _DEBUG
90  --in_rSize;
91 #endif
92  l_Value = (currentByte & 0x7F);
93  while (0x80 & currentByte)
94  {
95  currentByte = *in_rptr;
96  ++in_rptr;
97 #ifdef _DEBUG
98  --in_rSize;
99 #endif
100  l_Value = l_Value << 7;
101  l_Value |= (currentByte & 0x7F);
102  }
103 
104  return (T)l_Value;
105  }
106 
107  inline char * ReadBankStringUtf8(
108  AkUInt8*& in_rptr
109 #ifdef _DEBUG
110  , AkUInt32& in_rSize
111 #endif
112  , AkUInt32& out_uStringSize)
113  {
114  out_uStringSize = ReadBankData<AkUInt32>(in_rptr
115 #ifdef _DEBUG
116  , in_rSize
117 #endif
118  );
119 
120  char * pString = 0;
121  if (out_uStringSize > 0)
122  {
123  pString = reinterpret_cast<char*>(in_rptr);
124  in_rptr += out_uStringSize;
125 #ifdef _DEBUG
126  in_rSize -= out_uStringSize;
127 #endif
128  }
129  return pString;
130  }
131 }
132 
133 
134 #ifdef _DEBUG
135 
136 /// Read and return bank data of a given type, incrementing running pointer and decrementing block size for debug tracking purposes
137 #define READBANKDATA( _Type, _Ptr, _Size ) \
138  AK::ReadBankData<_Type>( _Ptr, _Size )
139 
140 #define READVARIABLESIZEBANKDATA( _Type, _Ptr, _Size ) \
141  AK::ReadVariableSizeBankData<_Type>( _Ptr, _Size )
142 
143 /// Read and return non-null-terminatd UTF-8 string stored in bank, and its size.
144 #define READBANKSTRING_UTF8( _Ptr, _Size, _out_StringSize ) \
145  AK::ReadBankStringUtf8( _Ptr, _Size, _out_StringSize )
146 
147 /// Read and return non-null-terminatd string stored in bank, and its size.
148 #define READBANKSTRING( _Ptr, _Size, _out_StringSize ) \
149  AK::ReadBankStringUtf8( _Ptr, _Size, _out_StringSize ) //same as UTF-8 for now.
150 
151 /// Skip over some bank data of a given type, incrementing running pointer and decrementing block size for debug tracking purposes
152 #define SKIPBANKDATA( _Type, _Ptr, _Size ) \
153  ( _Ptr ) += sizeof( _Type ); \
154  ( _Size ) -= sizeof( _Type )
155 
156 /// Skip over some bank data by a given size in bytes, incrementing running pointer and decrementing block size for debug tracking purposes
157 #define SKIPBANKBYTES( _NumBytes, _Ptr, _Size ) \
158  ( _Ptr ) += _NumBytes; \
159  ( _Size ) -= _NumBytes
160 
161 #else
162 
163 /// Read and return bank data of a given type, incrementing running pointer and decrementing block size for debug tracking purposes
164 #define READBANKDATA( _Type, _Ptr, _Size ) \
165  AK::ReadBankData<_Type>( _Ptr )
166 
167 #define READVARIABLESIZEBANKDATA( _Type, _Ptr, _Size ) \
168  AK::ReadVariableSizeBankData<_Type>( _Ptr )
169 
170 #define READBANKSTRING_UTF8( _Ptr, _Size, _out_StringSize ) \
171  AK::ReadBankStringUtf8( _Ptr, _out_StringSize )
172 
173 #define READBANKSTRING( _Ptr, _Size, _out_StringSize ) \
174  AK::ReadBankStringUtf8( _Ptr, _out_StringSize )
175 
176 /// Skip over some bank data of a given type, incrementing running pointer and decrementing block size for debug tracking purposes
177 #define SKIPBANKDATA( _Type, _Ptr, _Size ) \
178  ( _Ptr ) += sizeof( _Type )
179 
180 /// Skip over some bank data by a given size in bytes, incrementing running pointer and decrementing block size for debug tracking purposes
181 #define SKIPBANKBYTES( _NumBytes, _Ptr, _Size ) \
182  ( _Ptr ) += _NumBytes;
183 
184 #endif
185 
186 #define GETBANKDATABIT( _Data, _Shift ) \
187  (((_Data) >> (_Shift)) & 0x1)
188 
189 /// Helper macro to determine whether the full content of a block of memory was properly parsed
190 #ifdef _DEBUG
191  #define CHECKBANKDATASIZE( _DATASIZE_, _ERESULT_ ) AKASSERT( _DATASIZE_ == 0 || _ERESULT_ != AK_Success );
192 #else
193  #define CHECKBANKDATASIZE(_DATASIZE_, _ERESULT_ )
194 #endif
195 
196 #endif //_AK_BANKREADHELPERS_H_
Audiokinetic namespace
void WriteUnaligned(AkUInt8 *out_pVal, const T in_val)
T ReadBankData(AkUInt8 *&in_rptr)
Read data from bank and advance pointer.
T ReadVariableSizeBankData(AkUInt8 *&in_rptr)
T ReadUnaligned(const AkUInt8 *in_pVal)
char * ReadBankStringUtf8(AkUInt8 *&in_rptr, AkUInt32 &out_uStringSize)

이 페이지가 도움이 되었나요?

지원이 필요하신가요?

질문이 있으신가요? 문제를 겪고 계신가요? 더 많은 정보가 필요하신가요? 저희에게 문의해주시면 도와드리겠습니다!

지원 페이지를 방문해 주세요

작업하는 프로젝트에 대해 알려주세요. 언제든지 도와드릴 준비가 되어 있습니다.

프로젝트를 등록하세요. 아무런 조건이나 의무 사항 없이 빠른 시작을 도와드리겠습니다.

Wwise를 시작해 보세요