wut  v1.7.0
Wii U Toolchain
voice.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 #include "device.h"
4 #include "result.h"
5 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 typedef struct AXVoice AXVoice;
19 typedef struct AXVoiceAdpcm AXVoiceAdpcm;
22 typedef struct AXVoiceLink AXVoiceLink;
23 typedef struct AXVoiceOffsets AXVoiceOffsets;
24 typedef struct AXVoiceSrc AXVoiceSrc;
25 typedef struct AXVoiceVeData AXVoiceVeData;
26 
28 typedef uint16_t AXVoiceFormat;
29 
31 typedef uint16_t AXVoiceLoop;
32 
34 typedef uint32_t AXVoiceSrcType;
35 
37 typedef uint32_t AXVoiceState;
38 
40 typedef uint32_t AXVoiceRenderer;
41 
43 typedef int32_t AXVoiceSrcRatioResult;
44 
46 typedef uint32_t AXVoiceType;
47 
48 typedef void(*AXVoiceCallbackFn)(void *);
49 typedef void(*AXVoiceCallbackExFn)(void *, uint32_t, uint32_t);
50 
52 {
56 };
57 
59 {
62 };
63 
65 {
69 };
70 
72 {
76 };
77 
79 {
85 };
86 
88 {
91 };
92 
94 {
95  // Unknown
97 };
98 
100 {
103 };
104 WUT_CHECK_OFFSET(AXVoiceLink, 0x0, next);
105 WUT_CHECK_OFFSET(AXVoiceLink, 0x4, prev);
106 WUT_CHECK_SIZE(AXVoiceLink, 0x8);
107 
109 {
112  uint32_t loopOffset;
113  uint32_t endOffset;
114  uint32_t currentOffset;
115  const void *data;
116 };
117 WUT_CHECK_OFFSET(AXVoiceOffsets, 0x0, dataType);
118 WUT_CHECK_OFFSET(AXVoiceOffsets, 0x2, loopingEnabled);
119 WUT_CHECK_OFFSET(AXVoiceOffsets, 0x4, loopOffset);
120 WUT_CHECK_OFFSET(AXVoiceOffsets, 0x8, endOffset);
121 WUT_CHECK_OFFSET(AXVoiceOffsets, 0xc, currentOffset);
122 WUT_CHECK_OFFSET(AXVoiceOffsets, 0x10, data);
123 WUT_CHECK_SIZE(AXVoiceOffsets, 0x14);
124 
125 struct AXVoice
126 {
128  uint32_t index;
129 
132 
134  uint32_t volume;
135 
138 
141 
144 
146  uint32_t priority;
147 
150 
152  void *userContext;
153 
155  uint32_t syncBits;
156 
157  WUT_UNKNOWN_BYTES(0x8);
158 
161 
164 
166  uint32_t callbackReason;
167 
168  float unk0;
169  float unk1;
170 };
171 WUT_CHECK_OFFSET(AXVoice, 0x0, index);
172 WUT_CHECK_OFFSET(AXVoice, 0x4, state);
173 WUT_CHECK_OFFSET(AXVoice, 0x8, volume);
174 WUT_CHECK_OFFSET(AXVoice, 0xc, renderer);
175 WUT_CHECK_OFFSET(AXVoice, 0x10, link);
176 WUT_CHECK_OFFSET(AXVoice, 0x18, cbNext);
177 WUT_CHECK_OFFSET(AXVoice, 0x1c, priority);
178 WUT_CHECK_OFFSET(AXVoice, 0x20, callback);
179 WUT_CHECK_OFFSET(AXVoice, 0x24, userContext);
180 WUT_CHECK_OFFSET(AXVoice, 0x28, syncBits);
181 WUT_CHECK_OFFSET(AXVoice, 0x34, offsets);
182 WUT_CHECK_OFFSET(AXVoice, 0x48, callbackEx);
183 WUT_CHECK_OFFSET(AXVoice, 0x4c, callbackReason);
184 WUT_CHECK_OFFSET(AXVoice, 0x50, unk0);
185 WUT_CHECK_OFFSET(AXVoice, 0x54, unk1);
186 WUT_CHECK_SIZE(AXVoice, 0x58);
187 
189 {
190  uint16_t volume;
191  int16_t delta;
192 };
193 WUT_CHECK_OFFSET(AXVoiceDeviceBusMixData, 0x0, volume);
194 WUT_CHECK_OFFSET(AXVoiceDeviceBusMixData, 0x2, delta);
195 WUT_CHECK_SIZE(AXVoiceDeviceBusMixData, 0x4);
196 
198 {
200 };
201 WUT_CHECK_OFFSET(AXVoiceDeviceMixData, 0x0, bus);
202 WUT_CHECK_SIZE(AXVoiceDeviceMixData, 0x10);
203 
205 {
206  uint16_t volume;
207  int16_t delta;
208 };
209 WUT_CHECK_OFFSET(AXVoiceVeData, 0x0, volume);
210 WUT_CHECK_OFFSET(AXVoiceVeData, 0x2, delta);
211 WUT_CHECK_SIZE(AXVoiceVeData, 0x4);
212 
214 {
215  uint16_t predScale;
216  int16_t prevSample[2];
217 };
218 WUT_CHECK_OFFSET(AXVoiceAdpcmLoopData, 0x0, predScale);
219 WUT_CHECK_OFFSET(AXVoiceAdpcmLoopData, 0x2, prevSample);
220 WUT_CHECK_SIZE(AXVoiceAdpcmLoopData, 0x6);
221 
223 {
224  int16_t coefficients[16];
225  uint16_t gain;
226  uint16_t predScale;
227  int16_t prevSample[2];
228 };
229 WUT_CHECK_OFFSET(AXVoiceAdpcm, 0x0, coefficients);
230 WUT_CHECK_OFFSET(AXVoiceAdpcm, 0x20, gain);
231 WUT_CHECK_OFFSET(AXVoiceAdpcm, 0x22, predScale);
232 WUT_CHECK_OFFSET(AXVoiceAdpcm, 0x24, prevSample);
233 WUT_CHECK_SIZE(AXVoiceAdpcm, 0x28);
234 
235 #pragma pack(push, 1)
236 
241 {
243  uint32_t ratio;
244 
247  int16_t lastSample[4];
248 };
249 WUT_CHECK_OFFSET(AXVoiceSrc, 0x0, ratio);
250 WUT_CHECK_OFFSET(AXVoiceSrc, 0x4, currentOffsetFrac);
251 WUT_CHECK_OFFSET(AXVoiceSrc, 0x6, lastSample);
252 WUT_CHECK_SIZE(AXVoiceSrc, 0xe);
253 
254 #pragma pack(pop)
255 
256 int32_t
258 
259 int32_t
261 
262 AXVoice *
263 AXAcquireVoice(uint32_t priority,
264  AXVoiceCallbackFn callback,
265  void *userContext);
266 
267 AXVoice *
268 AXAcquireVoiceEx(uint32_t priority,
269  AXVoiceCallbackExFn callback,
270  void *userContext);
271 
272 BOOL
274 
275 void
277 
278 uint32_t
280 
281 uint32_t
283  const void *samples);
284 
285 uint32_t
287 
288 void
290  AXVoiceOffsets *offsets);
291 
292 BOOL
294 
295 void
297  AXVoiceAdpcm *adpcm);
298 
299 void
301  AXVoiceAdpcmLoopData *loopData);
302 
303 void
305  uint32_t offset);
306 
307 AXResult
309  AXDeviceType type,
310  uint32_t id,
311  AXVoiceDeviceMixData *mixData);
312 
313 void
315  uint32_t offset);
316 
317 void
319  uint32_t offset,
320  const void *samples);
321 
322 AXResult
324  uint16_t delay);
325 
326 void
328  uint32_t offset);
329 
330 void
332  uint32_t offset,
333  const void *samples);
334 
335 void
337  AXVoiceLoop loop);
338 
339 void
341  AXVoiceOffsets *offsets);
342 
343 void
345  uint32_t priority);
346 
347 void
349  uint16_t filter,
350  ...);
351 
352 void
354  AXVoiceSrc *src);
355 
358  float ratio);
359 
360 void
362  AXVoiceSrcType type);
363 
364 void
366  AXVoiceState state);
367 
368 void
370  AXVoiceType type);
371 
372 void
374  AXVoiceVeData *veData);
375 
376 void
378  int16_t delta);
379 
380 #ifdef __cplusplus
381 }
382 #endif
383 
uint32_t AXDeviceType
A value from enum AX_DEVICE_TYPE.
Definition: device.h:23
int32_t AXResult
A value from enum AX_RESULT.
Definition: result.h:16
AXVoiceState state
Current play state of this voice.
Definition: voice.h:131
AXVoiceLoop loopingEnabled
Definition: voice.h:111
const void * data
Definition: voice.h:115
uint32_t ratio
Playback rate, fixed 16.16.
Definition: voice.h:243
int16_t prevSample[2]
Definition: voice.h:216
AXVoiceFormat dataType
Definition: voice.h:110
uint16_t predScale
Definition: voice.h:215
AXVoiceDeviceBusMixData bus[4]
Definition: voice.h:199
AXVoice * next
Definition: voice.h:101
AXVoiceOffsets offsets
The current offset data!
Definition: voice.h:157
AXVoice * cbNext
A link to the next callback to invoke.
Definition: voice.h:143
uint16_t currentOffsetFrac
Used by the resampler, fixed 0.16.
Definition: voice.h:246
AXVoiceCallbackExFn callbackEx
An extended version of the callback above.
Definition: voice.h:163
int16_t coefficients[16]
Definition: voice.h:224
uint32_t endOffset
Definition: voice.h:113
AXVoiceCallbackFn callback
The callback to call if this is force-free'd by another acquire.
Definition: voice.h:149
uint16_t gain
Definition: voice.h:225
uint32_t currentOffset
Definition: voice.h:114
uint32_t priority
The priority of this voice used for force-acquiring a voice.
Definition: voice.h:146
uint32_t syncBits
A bitfield representing different things needing to be synced.
Definition: voice.h:155
uint32_t loopOffset
Definition: voice.h:112
AXVoiceLink link
this is a link used in the stack, we do this in host-memory currently
Definition: voice.h:140
uint32_t index
The index of this voice out of the total voices.
Definition: voice.h:128
float unk1
Definition: voice.h:169
AXVoice * prev
Definition: voice.h:102
AXVoiceRenderer renderer
The renderer to use for this voice.
Definition: voice.h:137
uint32_t volume
Current volume of this voice.
Definition: voice.h:134
int16_t lastSample[4]
Definition: voice.h:247
uint32_t callbackReason
The reason for the callback being invoked.
Definition: voice.h:166
void * userContext
The user context to send to the callbacks.
Definition: voice.h:152
float unk0
Definition: voice.h:168
uint32_t AXGetMaxVoices()
void AXSetVoiceVe(AXVoice *voice, AXVoiceVeData *veData)
AXVoice * AXAcquireVoice(uint32_t priority, AXVoiceCallbackFn callback, void *userContext)
void AXSetVoiceType(AXVoice *voice, AXVoiceType type)
AX_VOICE_TYPE
Definition: voice.h:94
void(* AXVoiceCallbackFn)(void *)
Definition: voice.h:48
void AXSetVoiceLoopOffsetEx(AXVoice *voice, uint32_t offset, const void *samples)
void AXSetVoiceVeDelta(AXVoice *voice, int16_t delta)
void AXSetVoiceState(AXVoice *voice, AXVoiceState state)
AX_VOICE_STATE
Definition: voice.h:88
BOOL AXCheckVoiceOffsets(AXVoiceOffsets *offsets)
void AXSetVoiceOffsets(AXVoice *voice, AXVoiceOffsets *offsets)
uint16_t AXVoiceFormat
A value from enum AX_VOICE_FORMAT.
Definition: voice.h:28
uint32_t AXGetVoiceCurrentOffsetEx(AXVoice *voice, const void *samples)
uint32_t AXVoiceRenderer
A value from enum AX_VOICE_RENDERER.
Definition: voice.h:40
void AXSetVoicePriority(AXVoice *voice, uint32_t priority)
AX_VOICE_SRC_TYPE
Definition: voice.h:79
AX_VOICE_RATIO_RESULT
Definition: voice.h:72
uint32_t AXVoiceType
A value from enum AX_VOICE_TYPE.
Definition: voice.h:46
void AXSetVoiceEndOffsetEx(AXVoice *voice, uint32_t offset, const void *samples)
AX_VOICE_LOOP
Definition: voice.h:59
void AXSetVoiceSrcType(AXVoice *voice, AXVoiceSrcType type)
uint16_t AXVoiceLoop
A value from enum AX_VOICE_LOOP.
Definition: voice.h:31
AXResult AXSetVoiceDeviceMix(AXVoice *voice, AXDeviceType type, uint32_t id, AXVoiceDeviceMixData *mixData)
AXVoiceSrcRatioResult AXSetVoiceSrcRatio(AXVoice *voice, float ratio)
BOOL AXIsVoiceRunning(AXVoice *voice)
void AXSetVoiceAdpcmLoop(AXVoice *voice, AXVoiceAdpcmLoopData *loopData)
void AXSetVoiceCurrentOffset(AXVoice *voice, uint32_t offset)
AX_VOICE_RENDERER
Definition: voice.h:65
AX_VOICE_FORMAT
Definition: voice.h:52
AXResult AXSetVoiceInitialTimeDelay(AXVoice *voice, uint16_t delay)
int32_t AXVoiceBegin(AXVoice *v)
void AXSetVoiceLoop(AXVoice *voice, AXVoiceLoop loop)
void AXSetVoiceRmtIIRCoefs(AXVoice *voice, uint16_t filter,...)
AXVoice * AXAcquireVoiceEx(uint32_t priority, AXVoiceCallbackExFn callback, void *userContext)
void(* AXVoiceCallbackExFn)(void *, uint32_t, uint32_t)
Definition: voice.h:49
uint32_t AXVoiceState
A value from enum AX_VOICE_STATE.
Definition: voice.h:37
void AXSetVoiceLoopOffset(AXVoice *voice, uint32_t offset)
void AXSetVoiceSrc(AXVoice *voice, AXVoiceSrc *src)
void AXFreeVoice(AXVoice *voice)
int32_t AXVoiceSrcRatioResult
A value from enum AX_VOICE_RATIO_RESULT.
Definition: voice.h:43
void AXSetVoiceEndOffset(AXVoice *voice, uint32_t offset)
uint32_t AXVoiceSrcType
A value from enum AX_VOICE_SRC_TYPE.
Definition: voice.h:34
void AXGetVoiceOffsets(AXVoice *voice, AXVoiceOffsets *offsets)
uint32_t AXGetVoiceLoopCount(AXVoice *voice)
int32_t AXVoiceEnd(AXVoice *v)
void AXSetVoiceAdpcm(AXVoice *voice, AXVoiceAdpcm *adpcm)
@ AX_VOICE_TYPE_UNKNOWN
Definition: voice.h:96
@ AX_VOICE_STATE_PLAYING
Definition: voice.h:90
@ AX_VOICE_STATE_STOPPED
Definition: voice.h:89
@ AX_VOICE_SRC_TYPE_NONE
Definition: voice.h:80
@ AX_VOICE_SRC_TYPE_UNK0
Definition: voice.h:82
@ AX_VOICE_SRC_TYPE_UNK2
Definition: voice.h:84
@ AX_VOICE_SRC_TYPE_LINEAR
Definition: voice.h:81
@ AX_VOICE_SRC_TYPE_UNK1
Definition: voice.h:83
@ AX_VOICE_RATIO_RESULT_LESS_THAN_ZERO
Definition: voice.h:74
@ AX_VOICE_RATIO_RESULT_GREATER_THAN_SOMETHING
Definition: voice.h:75
@ AX_VOICE_RATIO_RESULT_SUCCESS
Definition: voice.h:73
@ AX_VOICE_LOOP_ENABLED
Definition: voice.h:61
@ AX_VOICE_LOOP_DISABLED
Definition: voice.h:60
@ AX_VOICE_RENDERER_AUTO
Definition: voice.h:68
@ AX_VOICE_RENDERER_CPU
Definition: voice.h:67
@ AX_VOICE_RENDERER_DSP
Definition: voice.h:66
@ AX_VOICE_FORMAT_LPCM16
Definition: voice.h:54
@ AX_VOICE_FORMAT_ADPCM
Definition: voice.h:53
@ AX_VOICE_FORMAT_LPCM8
Definition: voice.h:55
Definition: voice.h:126
AXVoice Sample Rate Converter.
Definition: voice.h:241
int32_t BOOL
Definition: wut_types.h:7