AkWavDefs.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. Commercial License Usage
  5. Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
  6. may use this file in accordance with the end user license agreement provided
  7. with the software or, alternatively, in accordance with the terms contained in a
  8. written agreement between you and Audiokinetic Inc.
  9. Apache License Usage
  10. Alternatively, this file may be used under the Apache License, Version 2.0 (the
  11. "Apache License"); you may not use this file except in compliance with the
  12. Apache License. You may obtain a copy of the Apache License at
  13. http://www.apache.org/licenses/LICENSE-2.0.
  14. Unless required by applicable law or agreed to in writing, software distributed
  15. under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
  16. OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
  17. the specific language governing permissions and limitations under the License.
  18. Copyright (c) 2023 Audiokinetic Inc.
  19. *******************************************************************************/
  20. #pragma once
  21. /// \file
  22. /// Basic definitions for WAV / WEM file parsers.
  23. #include <AK/SoundEngine/Common/AkSpeakerConfig.h>
  24. #include <AK/SoundEngine/Common/AkTypes.h>
  25. //-----------------------------------------------------------------------------
  26. // Constants.
  27. //-----------------------------------------------------------------------------
  28. // Standard IDs
  29. constexpr AkFourcc RIFXChunkId = AkmmioFOURCC('R', 'I', 'F', 'X');
  30. constexpr AkFourcc RIFFChunkId = AkmmioFOURCC('R', 'I', 'F', 'F');
  31. constexpr AkFourcc WAVEChunkId = AkmmioFOURCC('W', 'A', 'V', 'E');
  32. constexpr AkFourcc PLUGINChunkId = AkmmioFOURCC('P', 'L', 'U', 'G');
  33. constexpr AkFourcc MIDIChunkId = AkmmioFOURCC('M', 'I', 'D', 'I');
  34. constexpr AkFourcc fmtChunkId = AkmmioFOURCC('f', 'm', 't', ' ');
  35. constexpr AkFourcc dataChunkId = AkmmioFOURCC('d', 'a', 't', 'a');
  36. constexpr AkFourcc cueChunkId = AkmmioFOURCC('c', 'u', 'e', ' ');
  37. constexpr AkFourcc LISTChunkId = AkmmioFOURCC('L', 'I', 'S', 'T');
  38. constexpr AkFourcc adtlChunkId = AkmmioFOURCC('a', 'd', 't', 'l');
  39. constexpr AkFourcc lablChunkId = AkmmioFOURCC('l', 'a', 'b', 'l');
  40. constexpr AkFourcc smplChunkId = AkmmioFOURCC('s', 'm', 'p', 'l');
  41. constexpr AkFourcc junkChunkId = AkmmioFOURCC('j', 'u', 'n', 'k');
  42. // AK-specific IDs
  43. constexpr AkFourcc akdChunkId = AkmmioFOURCC('a', 'k', 'd', ' ');
  44. constexpr AkFourcc hashChunkId = AkmmioFOURCC('h', 'a', 's', 'h');
  45. constexpr AkFourcc seekChunkId = AkmmioFOURCC('s', 'e', 'e', 'k');
  46. constexpr AkFourcc irmdChunkId = AkmmioFOURCC('i', 'r', 'm', 'd');
  47. //-----------------------------------------------------------------------------
  48. // Structs.
  49. //-----------------------------------------------------------------------------
  50. #pragma pack(push, 1)
  51. /// Standard WAV chunk header
  52. struct AkChunkHeader
  53. {
  54. AkFourcc ChunkId;
  55. AkUInt32 dwChunkSize;
  56. };
  57. /// Standard WAV format header
  58. struct WaveFormatEx
  59. {
  60. AkUInt16 wFormatTag;
  61. AkUInt16 nChannels;
  62. AkUInt32 nSamplesPerSec;
  63. AkUInt32 nAvgBytesPerSec;
  64. AkUInt16 nBlockAlign;
  65. AkUInt16 wBitsPerSample;
  66. AkUInt16 cbSize; // size of extra chunk of data, after end of this struct
  67. };
  68. /// WEM format header: equivalent to WAVEFORMATEXTENSIBLE, with an AkChannelConfig
  69. /// instead of dwChannelMask+SubFormat. Codecs that require format-specific chunks
  70. /// should extend this structure.
  71. struct WaveFormatExtensible : public WaveFormatEx
  72. {
  73. AkUInt16 wSamplesPerBlock;
  74. AkUInt32 uChannelConfig; // Serialized AkChannelConfig
  75. inline AkChannelConfig GetChannelConfig() const
  76. {
  77. AkChannelConfig channelConfig;
  78. channelConfig.Deserialize(uChannelConfig);
  79. return channelConfig;
  80. }
  81. };
  82. static_assert(sizeof(WaveFormatExtensible) == 24, "Incorrect padding for WaveFormatExtensible");
  83. #pragma pack(pop)