forked from Ares-Developers/YRpp
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Audio.h
166 lines (131 loc) · 3.79 KB
/
Audio.h
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#pragma once
#include <GeneralDefinitions.h>
#include <Helpers/CompileTime.h>
class RawFileClass;
class CCFileClass;
class VocClass;
struct AudioIDXHeader {
unsigned int Magic;
unsigned int Version;
unsigned int numSamples;
};
struct AudioIDXEntry { // assert (IDXHeader.version != 1);
char Name[16];
int Offset;
int Size;
unsigned int SampleRate;
unsigned int Flags;
unsigned int ChunkSize;
bool operator < (const AudioIDXEntry& rhs) const {
return _strcmpi(this->Name, rhs.Name) < 0;
}
};
struct AudioSampleData {
AudioSampleData() :
Data(0),
Format(0),
SampleRate(0),
NumChannels(0),
BytesPerSample(0),
ByteRate(0),
BlockAlign(0),
Flags(0)
{ }
unsigned int Data;
unsigned int Format;
unsigned int SampleRate;
unsigned int NumChannels;
unsigned int BytesPerSample;
unsigned int ByteRate;
unsigned int BlockAlign;
unsigned int Flags;
};
class AudioIDXData {
public:
static constexpr reference<AudioIDXData*, 0x87E294u> const Instance{};
static AudioIDXData* __fastcall Create(const char* pFilename, const char* pPath)
{ JMP_STD(0x4011C0); };
AudioIDXData() {
memset(this, 0, sizeof(*this));
}
~AudioIDXData()
{ JMP_THIS(0x401580); }
void ClearCurrentSample()
{ JMP_THIS(0x401910); }
int __fastcall FindSampleIndex(const char* pName) const
{ JMP_STD(0x4015C0); }
const char* __fastcall GetSampleName(int index) const
{ JMP_STD(0x401600); }
int __fastcall GetSampleSize(int index) const
{ JMP_STD(0x401620); }
AudioSampleData* __fastcall GetSampleInformation(int index, AudioSampleData* pBuffer) const
{ JMP_STD(0x401640); }
AudioIDXEntry* Samples;
int SampleCount;
char Path[MAX_PATH];
CCFileClass* BagFile;
RawFileClass* ExternalFile;
BOOL PathFound;
RawFileClass* CurrentSampleFile;
int CurrentSampleSize;
DWORD unknown_120;
};
class Audio {
public:
static bool __fastcall ReadWAVFile(RawFileClass* pFile, AudioSampleData* pAudioSample, int* pDataSize)
{ JMP_STD(0x408610); }
};
class AudioStream {
public:
static constexpr reference<AudioStream*, 0xB1D4D8u> const Instance{};
bool __fastcall PlayWAV(const char* pFilename, bool bUnk)
{ JMP_STD(0x407B60); }
};
struct TauntDataStruct {
DWORD tauntIdx : 4;
DWORD countryIdx : 4;
};
struct AudioController
{
void* Event; // Pointer to audio event (AudioEventTag) associated with this controller, type not implemented in YRpp as of current.
DWORD Stamp;
VocClass* EventType;
AudioIDXData** AudioIndex;
DWORD Unused;
AudioController() :
Event(nullptr),
Stamp(0),
EventType(nullptr),
AudioIndex(&AudioIDXData::Instance),
Unused(0)
{ }
~AudioController()
{ JMP_THIS(0x405C00); }
// Stops the audio event associated with this controller instantly.
void Stop()
{ JMP_THIS(0x405D40); }
// Ends the audio event associated with this controller, allowing it to fade out.
void End()
{ JMP_THIS(0x405FD0); }
// Stops the looping of audio event associated with this controller instantly.
void StopLooping()
{ JMP_THIS(0x405E80); }
// Ends the looping of audio event associated with this controller, allowing it to fade out.
void EndLooping()
{ JMP_THIS(0x406060); }
void SetEvent(void* event, VocClass* eventType)
{ JMP_THIS(0x4060F0); }
void* GetEvent()
{ JMP_THIS(0x406130); }
VocClass* GetEventType()
{ JMP_THIS(0x406170); }
// Not actually AudioController function, adjusts volume of a given audio event.
static void __fastcall AdjustAudioEventVolume(void* event, unsigned int volume)
{ JMP_STD(0x4061D0); }
// Not actually AudioController function, adjusts panning of a given audio event.
static void __fastcall AdjustAudioEventPanning(void* event, unsigned int pan)
{ JMP_THIS(0x406270); }
// Not actually AudioController function, gets event type (VocClass) of given audio event.
static VocClass* __fastcall GetEventType(void* event)
{ JMP_STD(0x406310); }
};