Skylicht Engine
Loading...
Searching...
No Matches
WavHeader.h
1#ifndef _WAVEHEADER_
2#define _WAVEHEADER_
3
4namespace Skylicht
5{
6 namespace Audio
7 {
8 enum ECompressionCode
9 {
10 CompressUnknown = 0x0000,
11 CompressPCM = 0x0001,
12 CompressMSADPCM = 0x0002,
13 CompressITUG_711_A_LAW = 0x0006,
14 CompressITUG_711_AMU_LAW = 0x0007,
15 CompressIMAADPCM = 0x0011,
16 CompressITUG_723_ADPCM = 0x0016,
17 CompressGSM_6_10 = 0x0031,
18 CompressITUG_721_ADPCM = 0x0040,
19 CompressMPEG = 0x0050
20 };
21
22 enum EChunkSize
23 {
24 ChunkHeaderSize = 8,
25 RiffChunkSize = 12,
26 FmtChunkSize = 24,
27 FactChunkSize = 12
28 };
29
31 {
32 char ChunkId[4]; // "RIFF"
33 unsigned int Filesize; // total file size -8 bytes for this header
34 char RiffType[4]; // usually "WAVE"
35 };
36
38 {
39 char ChunkId[4]; // "fmt "
40 unsigned int ChunkDataSize; // size of this header: 16 + extra format bytes
41 unsigned short CompressionCode; // 0x0001 = PCM, 0x0011 = IMA ADPCM
42 unsigned short NumChannels;
43 unsigned int SampleRate;
44 unsigned int AvgBytesPerSample;
45 unsigned short BlockAlign;
46 unsigned short SignificantBitsPerSample;
47 };
48
50 {
51 char ChunkId[4]; // "fact"
52 unsigned int ChunkDataSize; // for IMA ADPCM this is the # of samples
53 unsigned int FactData;
54 };
55
57 {
58 char ChunkId[4]; // "data"
59 unsigned int ChunkSize; // data size including any padding
60 };
61
63 {
64 char ChunkId[4];
65 unsigned int ChunkSize;
66 };
67
68 struct SDataNode
69 {
70 SDataNode():
71 FileOffset(0),
72 ByteSize(0),
73 Next(0)
74 {
75
76 }
77
78 SDataNode(int fileOffset, int byteSize):
79 FileOffset(fileOffset),
80 ByteSize(byteSize),
81 Next(0)
82 {
83 }
84
85 int FileOffset;
86 int ByteSize;
87 SDataNode* Next;
88
89 void AddNode(int fileOffset, int byteSize)
90 {
91 if (Next)
92 Next->AddNode( fileOffset, byteSize);
93 else
94 Next = new SDataNode(fileOffset, byteSize);
95 }
96
97 void DropNodes()
98 {
99 if (Next)
100 {
101 Next->DropNodes();
102 delete Next;
103 }
104 Next = NULL;
105 }
106 };
107
108 struct SWaveChunk
109 {
110 SWaveChunk():
111 DataNodes(0)
112 {
113 }
114
115 ~SWaveChunk()
116 {
117 if (DataNodes)
118 {
119 DataNodes->DropNodes();
120 delete DataNodes;
121 }
122 DataNodes = NULL;
123 }
124
125 SRiffHeader RiffHeader;
126 SFormatHeader FormatHeader;
127 SDataHeader DataHeader;
128 SFactHeader FactHeader;
129 SDataNode* DataNodes;
130 };
131 }
132}
133
134#endif
Handles all core audio functionality.
Definition AudioDebugLog.h:31
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29
Definition WavHeader.h:63
Definition WavHeader.h:57
Definition WavHeader.h:69
Definition WavHeader.h:50
Definition WavHeader.h:38
Definition WavHeader.h:31