WUT  0.1
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;
24 typedef struct AXVoiceSrc AXVoiceSrc;
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 CHECK_OFFSET(AXVoiceLink, 0x0, next);
105 CHECK_OFFSET(AXVoiceLink, 0x4, prev);
106 CHECK_SIZE(AXVoiceLink, 0x8);
107 
109 {
110  AXVoiceFormat dataType;
111  AXVoiceLoop loopingEnabled;
112  uint32_t loopOffset;
113  uint32_t endOffset;
114  uint32_t currentOffset;
115  const void *data;
116 };
117 CHECK_OFFSET(AXVoiceOffsets, 0x0, dataType);
118 CHECK_OFFSET(AXVoiceOffsets, 0x2, loopingEnabled);
119 CHECK_OFFSET(AXVoiceOffsets, 0x4, loopOffset);
120 CHECK_OFFSET(AXVoiceOffsets, 0x8, endOffset);
121 CHECK_OFFSET(AXVoiceOffsets, 0xc, currentOffset);
122 CHECK_OFFSET(AXVoiceOffsets, 0x10, data);
123 CHECK_SIZE(AXVoiceOffsets, 0x14);
124 
125 struct AXVoice
126 {
128  uint32_t index;
129 
131  AXVoiceState state;
132 
134  uint32_t volume;
135 
137  AXVoiceRenderer renderer;
138 
141 
144 
146  uint32_t priority;
147 
150 
152  void *userContext;
153 
155  uint32_t syncBits;
156 
157  UNKNOWN(0x8);
158 
161 
164 
166  uint32_t callbackReason;
167 
168  float unk0;
169  float unk1;
170 };
171 CHECK_OFFSET(AXVoice, 0x0, index);
172 CHECK_OFFSET(AXVoice, 0x4, state);
173 CHECK_OFFSET(AXVoice, 0x8, volume);
174 CHECK_OFFSET(AXVoice, 0xc, renderer);
175 CHECK_OFFSET(AXVoice, 0x10, link);
176 CHECK_OFFSET(AXVoice, 0x18, cbNext);
177 CHECK_OFFSET(AXVoice, 0x1c, priority);
178 CHECK_OFFSET(AXVoice, 0x20, callback);
179 CHECK_OFFSET(AXVoice, 0x24, userContext);
180 CHECK_OFFSET(AXVoice, 0x28, syncBits);
181 CHECK_OFFSET(AXVoice, 0x34, offsets);
182 CHECK_OFFSET(AXVoice, 0x48, callbackEx);
183 CHECK_OFFSET(AXVoice, 0x4c, callbackReason);
184 CHECK_OFFSET(AXVoice, 0x50, unk0);
185 CHECK_OFFSET(AXVoice, 0x54, unk1);
186 CHECK_SIZE(AXVoice, 0x58);
187 
189 {
190  uint16_t volume;
191  int16_t delta;
192 };
193 CHECK_OFFSET(AXVoiceDeviceBusMixData, 0x0, volume);
194 CHECK_OFFSET(AXVoiceDeviceBusMixData, 0x2, delta);
195 CHECK_SIZE(AXVoiceDeviceBusMixData, 0x4);
196 
198 {
200 };
201 CHECK_OFFSET(AXVoiceDeviceMixData, 0x0, bus);
202 CHECK_SIZE(AXVoiceDeviceMixData, 0x10);
203 
205 {
206  uint16_t volume;
207  int16_t delta;
208 };
209 CHECK_OFFSET(AXVoiceVeData, 0x0, volume);
210 CHECK_OFFSET(AXVoiceVeData, 0x2, delta);
211 CHECK_SIZE(AXVoiceVeData, 0x4);
212 
214 {
215  uint16_t predScale;
216  int16_t prevSample[2];
217 };
218 CHECK_OFFSET(AXVoiceAdpcmLoopData, 0x0, predScale);
219 CHECK_OFFSET(AXVoiceAdpcmLoopData, 0x2, prevSample);
220 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 CHECK_OFFSET(AXVoiceAdpcm, 0x0, coefficients);
230 CHECK_OFFSET(AXVoiceAdpcm, 0x20, gain);
231 CHECK_OFFSET(AXVoiceAdpcm, 0x22, predScale);
232 CHECK_OFFSET(AXVoiceAdpcm, 0x24, prevSample);
233 CHECK_SIZE(AXVoiceAdpcm, 0x28);
234 
235 #pragma pack(push, 1)
236 
241 {
243  uint32_t ratio;
244 
247  int16_t lastSample[4];
248 };
249 CHECK_OFFSET(AXVoiceSrc, 0x0, ratio);
250 CHECK_OFFSET(AXVoiceSrc, 0x4, currentOffsetFrac);
251 CHECK_OFFSET(AXVoiceSrc, 0x6, lastSample);
252 CHECK_SIZE(AXVoiceSrc, 0xe);
253 
254 #pragma pack(pop)
255 
256 AXVoice *
257 AXAcquireVoice(uint32_t priority,
258  AXVoiceCallbackFn callback,
259  void *userContext);
260 
261 AXVoice *
262 AXAcquireVoiceEx(uint32_t priority,
263  AXVoiceCallbackExFn callback,
264  void *userContext);
265 
266 BOOL
268 
269 void
270 AXFreeVoice(AXVoice *voice);
271 
272 uint32_t
274 
275 uint32_t
277  const void *samples);
278 
279 uint32_t
281 
282 void
284  AXVoiceOffsets *offsets);
285 
286 BOOL
287 AXIsVoiceRunning(AXVoice *voice);
288 
289 void
290 AXSetVoiceAdpcm(AXVoice *voice,
291  AXVoiceAdpcm *adpcm);
292 
293 void
295  AXVoiceAdpcmLoopData *loopData);
296 
297 void
299  uint32_t offset);
300 
301 AXResult
303  AXDeviceType type,
304  uint32_t id,
305  AXVoiceDeviceMixData *mixData);
306 
307 void
309  uint32_t offset);
310 
311 void
313  uint32_t offset,
314  const void *samples);
315 
316 AXResult
318  uint16_t delay);
319 
320 void
322  uint32_t offset);
323 
324 void
326  uint32_t offset,
327  const void *samples);
328 
329 void
330 AXSetVoiceLoop(AXVoice *voice,
331  AXVoiceLoop loop);
332 
333 void
335  AXVoiceOffsets *offsets);
336 
337 void
339  uint32_t priority);
340 
341 void
343  uint16_t filter,
344  ...);
345 
346 void
347 AXSetVoiceSrc(AXVoice *voice,
348  AXVoiceSrc *src);
349 
350 AXVoiceSrcRatioResult
352  float ratio);
353 
354 void
356  AXVoiceSrcType type);
357 
358 void
359 AXSetVoiceState(AXVoice *voice,
360  AXVoiceState state);
361 
362 void
363 AXSetVoiceType(AXVoice *voice,
364  AXVoiceType type);
365 
366 void
367 AXSetVoiceVe(AXVoice *voice,
368  AXVoiceVeData *veData);
369 
370 void
372  int16_t delta);
373 
374 #ifdef __cplusplus
375 }
376 #endif
377 
int16_t prevSample[2]
Definition: voice.h:216
void AXSetVoiceCurrentOffset(AXVoice *voice, uint32_t offset)
uint32_t volume
Current volume of this voice.
Definition: voice.h:134
uint32_t syncBits
A bitfield representing different things needing to be synced.
Definition: voice.h:155
AXVoiceRenderer renderer
The renderer to use for this voice.
Definition: voice.h:137
AXVoiceCallbackFn callback
The callback to call if this is force-free'd by another acquire.
Definition: voice.h:149
void AXSetVoiceAdpcm(AXVoice *voice, AXVoiceAdpcm *adpcm)
void AXGetVoiceOffsets(AXVoice *voice, AXVoiceOffsets *offsets)
void AXSetVoiceOffsets(AXVoice *voice, AXVoiceOffsets *offsets)
void AXSetVoiceEndOffsetEx(AXVoice *voice, uint32_t offset, const void *samples)
uint32_t AXVoiceRenderer
A value from enum AX_VOICE_RENDERER.
Definition: voice.h:40
float unk1
Definition: voice.h:169
void AXSetVoiceLoopOffsetEx(AXVoice *voice, uint32_t offset, const void *samples)
BOOL AXIsVoiceRunning(AXVoice *voice)
AXVoiceLoop loopingEnabled
Definition: voice.h:111
int16_t coefficients[16]
Definition: voice.h:224
uint16_t currentOffsetFrac
Used by the resampler, fixed 0.16.
Definition: voice.h:246
uint32_t priority
The priority of this voice used for force-acquiring a voice.
Definition: voice.h:146
void AXSetVoiceSrc(AXVoice *voice, AXVoiceSrc *src)
void AXSetVoiceAdpcmLoop(AXVoice *voice, AXVoiceAdpcmLoopData *loopData)
void(* AXVoiceCallbackExFn)(void *, uint32_t, uint32_t)
Definition: voice.h:49
void AXSetVoicePriority(AXVoice *voice, uint32_t priority)
void AXSetVoiceLoopOffset(AXVoice *voice, uint32_t offset)
uint32_t AXGetMaxVoices()
uint32_t AXVoiceState
A value from enum AX_VOICE_STATE.
Definition: voice.h:37
AX_VOICE_TYPE
Definition: voice.h:93
int32_t AXVoiceSrcRatioResult
A value from enum AX_VOICE_RATIO_RESULT.
Definition: voice.h:43
AX_VOICE_STATE
Definition: voice.h:87
AXVoiceState state
Current play state of this voice.
Definition: voice.h:131
AX_VOICE_LOOP
Definition: voice.h:58
uint16_t AXVoiceLoop
A value from enum AX_VOICE_LOOP.
Definition: voice.h:31
AXVoiceSrcRatioResult AXSetVoiceSrcRatio(AXVoice *voice, float ratio)
void AXSetVoiceVeDelta(AXVoice *voice, int16_t delta)
AXVoiceDeviceBusMixData bus[4]
Definition: voice.h:199
AXVoiceFormat dataType
Definition: voice.h:110
BOOL AXCheckVoiceOffsets(AXVoiceOffsets *offsets)
void AXSetVoiceEndOffset(AXVoice *voice, uint32_t offset)
uint32_t AXGetVoiceCurrentOffsetEx(AXVoice *voice, const void *samples)
AX_VOICE_FORMAT
Definition: voice.h:51
AXResult AXSetVoiceInitialTimeDelay(AXVoice *voice, uint16_t delay)
int16_t lastSample[4]
Definition: voice.h:247
AXVoice * cbNext
A link to the next callback to invoke.
Definition: voice.h:143
AXVoice * AXAcquireVoiceEx(uint32_t priority, AXVoiceCallbackExFn callback, void *userContext)
void AXSetVoiceSrcType(AXVoice *voice, AXVoiceSrcType type)
AX_VOICE_RATIO_RESULT
Definition: voice.h:71
uint16_t AXVoiceFormat
A value from enum AX_VOICE_FORMAT.
Definition: voice.h:28
uint32_t index
The index of this voice out of the total voices.
Definition: voice.h:128
const void * data
Definition: voice.h:115
uint16_t gain
Definition: voice.h:225
void AXSetVoiceRmtIIRCoefs(AXVoice *voice, uint16_t filter,...)
int BOOL
Definition: wut_types.h:5
int16_t prevSample[2]
Definition: voice.h:227
uint32_t AXDeviceType
A value from enum AX_DEVICE_TYPE.
Definition: device.h:23
AXVoiceCallbackExFn callbackEx
An extended version of the callback above.
Definition: voice.h:163
AX_VOICE_SRC_TYPE
Definition: voice.h:78
uint32_t callbackReason
The reason for the callback being invoked.
Definition: voice.h:166
int32_t AXResult
A value from enum AX_RESULT.
Definition: result.h:16
uint32_t currentOffset
Definition: voice.h:114
void(* AXVoiceCallbackFn)(void *)
Definition: voice.h:48
Definition: voice.h:125
uint16_t predScale
Definition: voice.h:226
AXVoice * AXAcquireVoice(uint32_t priority, AXVoiceCallbackFn callback, void *userContext)
uint32_t AXVoiceSrcType
A value from enum AX_VOICE_SRC_TYPE.
Definition: voice.h:34
AXResult AXSetVoiceDeviceMix(AXVoice *voice, AXDeviceType type, uint32_t id, AXVoiceDeviceMixData *mixData)
void AXSetVoiceVe(AXVoice *voice, AXVoiceVeData *veData)
void AXSetVoiceState(AXVoice *voice, AXVoiceState state)
float unk0
Definition: voice.h:168
void * userContext
The user context to send to the callbacks.
Definition: voice.h:152
uint16_t volume
Definition: voice.h:206
int16_t delta
Definition: voice.h:207
void AXSetVoiceLoop(AXVoice *voice, AXVoiceLoop loop)
AXVoiceLink link
this is a link used in the stack, we do this in host-memory currently
Definition: voice.h:140
uint32_t AXVoiceType
A value from enum AX_VOICE_TYPE.
Definition: voice.h:46
uint32_t endOffset
Definition: voice.h:113
AX_VOICE_RENDERER
Definition: voice.h:64
AXVoiceOffsets offsets
The current offset data!
Definition: voice.h:160
void AXFreeVoice(AXVoice *voice)
void AXSetVoiceType(AXVoice *voice, AXVoiceType type)
uint32_t ratio
Playback rate, fixed 16.16.
Definition: voice.h:243
uint16_t predScale
Definition: voice.h:215
uint32_t loopOffset
Definition: voice.h:112
uint32_t AXGetVoiceLoopCount(AXVoice *voice)