Guiliani  Version 2.5 revision 7293 (documentation build 13)
WaveLoader.h
1#ifndef __WAVELOADER_H__
2#define __WAVELOADER_H__
3
4#include "eC_Types.h"
5#include "GUITrace.h"
6
7// some magic bytes within wavefiles
8#define WAVE_FILETYPE_RIFF "RIFF"
9#define WAVE_DATATYPE_WAVE "WAVE"
10#define WAVE_CHUNKID_FMT "fmt "
11#define WAVE_CHUNKID_DATA "data"
12
13// namespace for fileloaders
14namespace FileLoader
15{
20 {
21 public:
24 {
25 eC_Short sFormatTag;
26 eC_UShort usChannels;
29 eC_UShort usBlockAlign;
30 eC_UShort usBitsPerSample;
31 };
32
35 {
36 eC_UInt uiDataSize;
37 eC_UByte *pubData;
38 };
39
40 private:
42 struct WaveHeader_t
43 {
44 char ubIdRiff[4];
45 eC_UInt uiFileSize;
46 char ubIdWave[4];
47 };
48
50 struct Chunk_t
51 {
52 char ubChunkID[4];
53 eC_UInt uiChunkSize;
54 };
55
56 public:
58 WaveLoader() { memset(&m_kWaveFormat, 0, sizeof(m_kWaveFormat)); memset(&m_kWaveData, 0, sizeof(m_kWaveData)); }
59
62
68 eC_Bool Load(const eC_String &pkPath);
69
74 FormatChunk_t GetWaveFormat() const { return m_kWaveFormat; }
75
80 DataChunk_t GetWaveData() const { return m_kWaveData; }
81
85 void Unload();
86
87 private:
89 enum { BUFFER_SIZE = 1024 };
90
91 private:
92 eC_Bool CompareU32(const eC_UByte* pkData, const char* pkValue) const;
93
94 private:
95 FormatChunk_t m_kWaveFormat;
96 DataChunk_t m_kWaveData;
97 };
98}
99
100#endif
Definition: WaveLoader.h:20
FormatChunk_t GetWaveFormat() const
Definition: WaveLoader.h:74
WaveLoader()
Default constructor.
Definition: WaveLoader.h:58
eC_Bool Load(const eC_String &pkPath)
~WaveLoader()
Default destructor.
Definition: WaveLoader.h:61
DataChunk_t GetWaveData() const
Definition: WaveLoader.h:80
Structure of data chunk of wave-file.
Definition: WaveLoader.h:35
eC_UByte * pubData
Allocated memory block for sound data.
Definition: WaveLoader.h:37
eC_UInt uiDataSize
Size of sound data.
Definition: WaveLoader.h:36
Structure of format chunk of wave-file.
Definition: WaveLoader.h:24
eC_UShort usBitsPerSample
Number of bits per sample.
Definition: WaveLoader.h:30
eC_UInt uiAvgBytesPerSec
Number of bytes per second.
Definition: WaveLoader.h:28
eC_Short sFormatTag
Format of data (1 is non-compressed data)
Definition: WaveLoader.h:25
eC_UShort usBlockAlign
Size of sample in bytes.
Definition: WaveLoader.h:29
eC_UInt uiSamplesPerSec
Samplerate of file.
Definition: WaveLoader.h:27
eC_UShort usChannels
Number of channels.
Definition: WaveLoader.h:26