blob: 60b334686bb59ae110ad65ab77918fb4607b232d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#ifndef NW4HBM_SND_WAVE_FILE_H
#define NW4HBM_SND_WAVE_FILE_H
#include "AxVoice.h"
#include "snd_types.h"
namespace nw4hbm {
namespace snd {
namespace detail {
namespace WaveFile {
typedef enum Format { FORMAT_PCM8 = 0, FORMAT_PCM16, FORMAT_ADPCM } Format;
typedef struct WaveInfo {
/* 0x00 */ u8 format;
/* 0x01 */ u8 loopFlag;
/* 0x02 */ u8 numChannels;
/* 0x03 */ u8 sampleRate24;
/* 0x04 */ u16 sampleRate;
/* 0x06 */ u16 padding2;
/* 0x08 */ u32 loopStart;
/* 0x0C */ u32 loopEnd;
/* 0x10 */ u32 channelInfoTableOffset;
/* 0x14 */ u32 dataOffset;
/* 0x18 */ u32 reserved;
} WaveInfo;
typedef struct WaveChannelInfo {
/* 0x00 */ u32 channelDataOffset;
/* 0x04 */ u32 adpcmOffset;
/* 0x08 */ u32 volumeFrontLeft;
/* 0x0C */ u32 volumeFrontRight;
/* 0x10 */ u32 volumeRearLeft;
/* 0x14 */ u32 volumeRearRight;
/* 0x18 */ u32 reserved;
} WaveChannelInfo;
} // namespace WaveFile
typedef struct ChannelParam {
/* 0x00 */ void* dataAddr;
/* 0x04 */ u32 volumeFrontLeft;
/* 0x08 */ u32 volumeFrontRight;
/* 0x0C */ u32 volumeRearLeft;
/* 0x10 */ u32 volumeRearRight;
/* 0x14 */ AdpcmInfo adpcmInfo;
} ChannelParam;
typedef struct WaveData {
/* 0x00 */ u8 format;
/* 0x01 */ u8 loopFlag;
/* 0x02 */ u8 numChannels;
/* 0x04 */ int sampleRate;
/* 0x08 */ u32 loopStart;
/* 0x0C */ u32 loopEnd;
/* 0x10 */ ChannelParam channelParam[CHANNEL_MAX];
} WaveData;
class WaveFileReader {
public:
explicit WaveFileReader(const WaveFile::WaveInfo* waveInfo);
bool ReadWaveParam(WaveData* waveData, const void* waveAddr) const;
static AxVoice::Format WaveFormatToAxFormat(u32 format);
private:
/* 0x00 */ const WaveFile::WaveInfo* mWaveInfo;
};
inline AxVoice::Format WaveFormatToAxFormat(u32 format) {
if (format == WaveFile::FORMAT_PCM16) {
return AxVoice::FORMAT_PCM16;
}
if (format == WaveFile::FORMAT_PCM8) {
return AxVoice::FORMAT_PCM8;
}
return AxVoice::FORMAT_ADPCM;
}
} // namespace detail
} // namespace snd
} // namespace nw4hbm
#endif
|