forked from zeldaret/oot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseqcmd.h
512 lines (466 loc) · 26.1 KB
/
seqcmd.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
#ifndef SEQCMD_H
#define SEQCMD_H
#include "sequence.h"
// ==== Primary commands ====
#define SEQCMD_OP_MASK 0xF0000000
typedef enum SeqCmdOp {
/* 0x0 */ SEQCMD_OP_PLAY_SEQUENCE,
/* 0x1 */ SEQCMD_OP_STOP_SEQUENCE,
/* 0x2 */ SEQCMD_OP_QUEUE_SEQUENCE,
/* 0x3 */ SEQCMD_OP_UNQUEUE_SEQUENCE,
/* 0x4 */ SEQCMD_OP_SET_SEQPLAYER_VOLUME,
/* 0x5 */ SEQCMD_OP_SET_SEQPLAYER_FREQ,
/* 0x6 */ SEQCMD_OP_SET_CHANNEL_VOLUME,
/* 0x7 */ SEQCMD_OP_SET_SEQPLAYER_IO,
/* 0x8 */ SEQCMD_OP_SET_CHANNEL_IO,
/* 0x9 */ SEQCMD_OP_SET_CHANNEL_IO_DISABLE_MASK,
/* 0xA */ SEQCMD_OP_SET_CHANNEL_DISABLE_MASK,
/* 0xB */ SEQCMD_OP_TEMPO_CMD,
/* 0xC */ SEQCMD_OP_SETUP_CMD,
/* 0xD */ SEQCMD_OP_SET_CHANNEL_FREQ,
/* 0xE */ SEQCMD_OP_GLOBAL_CMD,
/* 0xF */ SEQCMD_OP_RESET_AUDIO_HEAP
} SeqCmdOp;
// ==== Secondary commands ====
// Subset of `SEQCMD_OP_TEMPO_CMD`
typedef enum SeqCmdTempoCmdOp {
/* 0x0 */ SEQCMD_SUB_OP_TEMPO_SET,
/* 0x1 */ SEQCMD_SUB_OP_TEMPO_SPEED_UP,
/* 0x2 */ SEQCMD_SUB_OP_TEMPO_SLOW_DOWN,
/* 0x3 */ SEQCMD_SUB_OP_TEMPO_SCALE,
/* 0x4 */ SEQCMD_SUB_OP_TEMPO_RESET
} SeqCmdTempoCmdOp;
// Subset of `SEQCMD_OP_SETUP_CMD`
typedef enum SeqCmdSetupCmdOp {
/* 0x0 */ SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME,
/* 0x1 */ SEQCMD_SUB_OP_SETUP_SEQ_UNQUEUE,
/* 0x2 */ SEQCMD_SUB_OP_SETUP_RESTART_SEQ,
/* 0x3 */ SEQCMD_SUB_OP_SETUP_TEMPO_SCALE,
/* 0x4 */ SEQCMD_SUB_OP_SETUP_TEMPO_RESET,
/* 0x5 */ SEQCMD_SUB_OP_SETUP_PLAY_SEQ,
/* 0x6 */ SEQCMD_SUB_OP_SETUP_SET_FADE_TIMER,
/* 0x7 */ SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME_IF_QUEUED,
/* 0x8 */ SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME_WITH_SCALE_INDEX,
/* 0x9 */ SEQCMD_SUB_OP_SETUP_SET_CHANNEL_DISABLE_MASK,
/* 0xA */ SEQCMD_SUB_OP_SETUP_SET_SEQPLAYER_FREQ,
/* 0xE */ SEQCMD_SUB_OP_SETUP_POP_PERSISTENT_CACHE = 0xE,
/* 0xF */ SEQCMD_SUB_OP_SETUP_RESET_SETUP_CMDS
} SeqCmdSetupCmdOp;
// Subset of `SEQCMD_OP_GLOBAL_CMD`
typedef enum SeqCmdSubCmdOp {
/* 0x0 */ SEQCMD_SUB_OP_GLOBAL_SET_SOUND_MODE,
/* 0x1 */ SEQCMD_SUB_OP_GLOBAL_DISABLE_NEW_SEQUENCES
} SeqCmdSubCmdOp;
// ==== Audio Sequence Primary Commands ====
/**
* Play a sequence on a given seqPlayer
*
* @param seqPlayerIndex the index of the seqPlayer to play the sequence
* @param fadeInDuration effect will depend on seqArg. See below
* @param seqArg no effect: < 0x7F, skip ahead: = 0x7F, will not play: >= 0x80 (see note)
* @param seqId the id of the sequence to play, see `SeqId`
*
* @note seqArg will also be stored in gActiveSeqs.seqId, any check against that seqId must also include seqArg.
* seqArg < 0x7F: fade in the sequence over `fadeInDuration` in units of (1/30th) seconds
* seqArg = 0x7F: start the sequence immediately, but begins `fadeInDuration` number of second into the sequence.
* seqArg >= 0x80: no sequence will play. Intended to load a soundFont asynchronously but was only half implemented
* (inferred from MM).
*/
#define SEQCMD_PLAY_SEQUENCE(seqPlayerIndex, fadeInDuration, seqArg, seqId) \
Audio_QueueSeqCmd((SEQCMD_OP_PLAY_SEQUENCE << 28) | ((u8)(seqPlayerIndex) << 24) | ((u8)(fadeInDuration) << 16) | \
((u8)(seqArg) << 8) | (u16)(seqId))
/**
* Stop a sequence on a given seqPlayer
*
* @param seqPlayerIndex the index of the seqPlayer to stop the sequence
* @param fadeOutDuration duration the sequence will fade out over
*
* @note the 0xFF in the command is not read from at all, but is common in all Stop SeqPlayer Commands
*/
#define SEQCMD_STOP_SEQUENCE(seqPlayerIndex, fadeOutDuration) \
Audio_QueueSeqCmd((SEQCMD_OP_STOP_SEQUENCE << 28) | 0xFF | ((u8)(seqPlayerIndex) << 24) | \
((u8)(fadeOutDuration) << 16))
/**
* Add a sequence to a queue of sequences associated with a given seqPlayer.
* If the sequence is first in queue, play the sequence
*
* @param seqPlayerIndex the index of the seqPlayer to queue the sequence
* @param fadeInDuration if the sequence is played, duration the sequence will fade in over
* @param priority priority in the queue. The highest valued priority will be queued to play first. Also used as `seqArg`.
* @param seqId the id of the sequence to play, see `SeqId`
*
* @note for the next sequence in the queue to play, the current sequence must be unqueued with the unqueue command
* @note for a priority >= 0x7F, similar effects happen as `seqArg` in the play sequence command
*/
#define SEQCMD_QUEUE_SEQUENCE(seqPlayerIndex, fadeInDuration, priority, seqId) \
Audio_QueueSeqCmd((SEQCMD_OP_QUEUE_SEQUENCE << 28) | ((u8)(seqPlayerIndex) << 24) | ((u8)(fadeInDuration) << 16) | \
((u8)(priority) << 8) | (u8)(seqId))
/**
* Remove a sequence from a queue of sequences associated with a given seqPlayer.
* If the sequence is first in queue, stop the sequence, and play the next one in queue if any
*
* @param seqPlayerIndex the index of the seqPlayer to queue the sequence
* @param fadeInDuration if the sequence is stopped, duration the sequence will fade out over, and duration the next seq will fade in over
* @param seqId the id of the sequence to remove, see `SeqId`
*
* @note for the next sequence in the queue to play, the current sequence must be unqueued with this command
*/
#define SEQCMD_UNQUEUE_SEQUENCE(seqPlayerIndex, fadeOutInDuration, seqId) \
Audio_QueueSeqCmd((SEQCMD_OP_UNQUEUE_SEQUENCE << 28) | ((u8)(seqPlayerIndex) << 24) | \
((u8)(fadeOutInDuration) << 16) | (seqId))
/**
* Set the volume of an entire sequence on a given seqPlayer. Fade to the volume over a specified duration
*
* @param seqPlayerIndex the index of the seqPlayer to modify
* @param duration duration to transition to the volume
* @param volume the target volume for the sequence. Ranged from 0-0xFF, with 0x7F mapping to 1.0f
*/
#define SEQCMD_SET_SEQPLAYER_VOLUME(seqPlayerIndex, duration, volume) \
Audio_QueueSeqCmd((SEQCMD_OP_SET_SEQPLAYER_VOLUME << 28) | ((u8)(seqPlayerIndex) << 24) | ((duration) << 16) | \
(volume))
/**
* Scale the frequency of every channel on a given seqPlayer over a specified duration.
*
* @param seqPlayerIndex the index of the seqPlayer to modify
* @param duration duration to transition to the frequency
* @param freqScale the scaling factor to shift the pitch. Ranged from 0-0xFFFF, with 1000 mapping to 1.0f
*
* @note 2000 will double the frequency (raise an octave), 500 will halve the frequency (lower an octave).
* Cannot be used with `SEQCMD_SET_CHANNEL_FREQ` as they will overwrite one another.
*/
#define SEQCMD_SET_SEQPLAYER_FREQ(seqPlayerIndex, duration, freqScale) \
Audio_QueueSeqCmd((SEQCMD_OP_SET_SEQPLAYER_FREQ << 28) | ((u8)(seqPlayerIndex) << 24) | ((duration) << 16) | \
(freqScale))
/**
* Scale the frequency of a specific channel on a given seqPlayer over a specified duration
*
* @param seqPlayerIndex the index of the seqPlayer to modify
* @param channelIndex the index of the channel to modify
* @param duration duration to transition to the frequency
* @param freqScale the scaling factor to shift the pitch. Ranged from 0-0xFFF, with 1000 mapping to 1.0f
*
* @note a frequency of 2000 will double the frequency (raise an octave), 500 will halve the frequency (lower an octave).
* Cannot be used with `SEQCMD_SET_SEQPLAYER_FREQ` as they will overwrite one another.
*/
#define SEQCMD_SET_CHANNEL_FREQ(seqPlayerIndex, channelIndex, duration, freqScale) \
Audio_QueueSeqCmd((SEQCMD_OP_SET_CHANNEL_FREQ << 28) | ((u8)(seqPlayerIndex) << 24) | ((duration) << 16) | \
((channelIndex) << 12) | (freqScale))
/**
* Set the volume of a specific channel on a given seqPlayer. Fade to the volume over a specified duration
*
* @param seqPlayerIndex the index of the seqPlayer to modify
* @param channelIndex the index of the channel to modify
* @param duration duration to transition to the volume
* @param volume the target volume for the sequence. Ranged from 0-0xFF, with 0x7F mapping to 1.0f
*/
#define SEQCMD_SET_CHANNEL_VOLUME(seqPlayerIndex, channelIndex, duration, volume) \
Audio_QueueSeqCmd((SEQCMD_OP_SET_CHANNEL_VOLUME << 28) | ((u8)(seqPlayerIndex) << 24) | ((u8)(duration) << 16) | \
((u8)(channelIndex) << 8) | ((u8)volume))
/**
* Write a value that can be read as input directly by the sequence itself. This will be set to the global
* ioPort, which can affect the entire sequence.
*
* @param seqPlayerIndex the index of the seqPlayer to write the input to
* @param ioPort the index of the array to store the input-output value
* @param ioData the value s8 that's written to the input-output array
*
* @note Each seqPlayer has 8 global ioPorts indexed 0-7.
* ioPort 0 and 1 are read-only-once, and will reset after being read by the sequence.
* ioPort 2-7 can be read multiple times.
*/
#define SEQCMD_SET_SEQPLAYER_IO(seqPlayerIndex, ioPort, ioData) \
Audio_QueueSeqCmd((SEQCMD_OP_SET_SEQPLAYER_IO << 28) | ((u8)(seqPlayerIndex) << 24) | ((u8)(ioPort) << 16) | \
(u8)(ioData))
/**
* Write a value that can be read as input directly by the sequence itself. This will be set to the channel
* ioPort, which will only affect a single channel.
*
* @param seqPlayerIndex the index of the seqPlayer to write the input to
* @param channelIndex the index of the channel to write the input to
* @param ioPort the index of the array to store the input-output value
* @param ioData the value s8 that's written to the input-output array
*
* @note Each channel has 8 channel ioPorts indexed 0-7.
* ioPort 0 and 1 are read-only-once, and will reset after being read by the sequence.
* ioPort 2-7 can be read multiple times.
*/
#define SEQCMD_SET_CHANNEL_IO(seqPlayerIndex, channelIndex, ioPort, ioData) \
Audio_QueueSeqCmd((SEQCMD_OP_SET_CHANNEL_IO << 28) | ((u8)(seqPlayerIndex) << 24) | ((u8)(ioPort) << 16) | \
((u8)(channelIndex) << 8) | (u8)(ioData))
/**
* Disable (or reenable) specific channels from receiving input set by `SEQCMD_SET_CHANNEL_IO`
*
* @param seqPlayerIndex the index of the seqPlayer to modify
* @param channelMask a 16 bit mask where each bit maps to a channel. Bitflag on to disable
*
* @note using AUDIOCMD_CHANNEL_SET_IO will bypass this channelMask
*/
#define SEQCMD_SET_CHANNEL_IO_DISABLE_MASK(seqPlayerIndex, channelMask) \
Audio_QueueSeqCmd((SEQCMD_OP_SET_CHANNEL_IO_DISABLE_MASK << 28) | ((u8)(seqPlayerIndex) << 24) | (u16)(channelMask))
/**
* Disable (or reenable) specific channels
*
* @param seqPlayerIndex the index of the seqPlayer to modify
* @param channelMask a 16 bit mask where each bit maps to a channel. Bitflag on to disable
*/
#define SEQCMD_SET_CHANNEL_DISABLE_MASK(seqPlayerIndex, channelMask) \
Audio_QueueSeqCmd((SEQCMD_OP_SET_CHANNEL_DISABLE_MASK << 28) | ((u8)(seqPlayerIndex) << 24) | (u16)(channelMask))
// ==== Audio Sequence Tempo Commands ====
/**
* Set the absolute tempo of a sequence on a given seqPlayer, fading over a specified duration
*
* @param seqPlayerIndex the index of the seqPlayer to modify
* @param duration duration to transition to the tempo
* @param tempoTarget the target tempo for the sequence
*
* @note the absolute tempo is constrained to a maximum of 300
*/
#define SEQCMD_SET_TEMPO(seqPlayerIndex, duration, tempoTarget) \
Audio_QueueSeqCmd((SEQCMD_OP_TEMPO_CMD << 28) | (SEQCMD_SUB_OP_TEMPO_SET << 12) | ((u8)(seqPlayerIndex) << 24) | \
((u8)(duration) << 16) | (u16)(tempoTarget))
/**
* Increase the tempo of a sequence by a relative value on a given seqPlayer over a specified duration
*
* @param seqPlayerIndex the index of the seqPlayer to modify
* @param duration duration to transition to the tempo
* @param tempoIncrease the change to add to the current tempo
*
* @note the absolute tempo is constrained to a maximum of 300
*/
#define SEQCMD_SPEED_UP_TEMPO(seqPlayerIndex, duration, tempoIncrease) \
Audio_QueueSeqCmd((SEQCMD_OP_TEMPO_CMD << 28) | (SEQCMD_SUB_OP_TEMPO_SPEED_UP << 12) | \
((u8)(seqPlayerIndex) << 24) | ((u8)(duration) << 16) | (u16)(tempoIncrease))
/**
* Decrease the tempo of a sequence by a relative value on a given seqPlayer over a specified duration
*
* @param seqPlayerIndex the index of the seqPlayer to modify
* @param duration duration to transition to the tempo
* @param tempoDecrease the change to subtract to the current tempo
*
* @note the absolute tempo is constrained to a maximum of 300
*/
#define SEQCMD_SLOW_DOWN_TEMPO(seqPlayerIndex, duration, tempoDecrease) \
Audio_QueueSeqCmd((SEQCMD_OP_TEMPO_CMD << 28) | (SEQCMD_SUB_OP_TEMPO_SLOW_DOWN << 12) | \
((u8)(seqPlayerIndex) << 24) | ((u8)(duration) << 16) | (u16)(tempoDecrease))
/**
* Scale the tempo of a sequence by a multiplicative value on a given seqPlayer over a specified duration
*
* @param seqPlayerIndex the index of the seqPlayer to modify
* @param duration duration to transition to the tempo
* @param tempoScale the scaling factor of the tempo, relative to 100
*
* @note a tempoScale of 200 will go double-time, 50 will go half-time.
* the absolute tempo is constrained to a maximum of 300
*/
#define SEQCMD_SCALE_TEMPO(seqPlayerIndex, duration, tempoScale) \
Audio_QueueSeqCmd((SEQCMD_OP_TEMPO_CMD << 28) | (SEQCMD_SUB_OP_TEMPO_SCALE << 12) | ((u8)(seqPlayerIndex) << 24) | \
((u8)(duration) << 16) | (u16)(tempoScale))
/**
* Reset the tempo of a sequence to the original tempo on a given seqPlayer over a specified duration
*
* @param seqPlayerIndex the index of the seqPlayer to modify
* @param duration duration to transition to the tempo
*/
#define SEQCMD_RESET_TEMPO(seqPlayerIndex, duration) \
Audio_QueueSeqCmd((SEQCMD_OP_TEMPO_CMD << 28) | (SEQCMD_SUB_OP_TEMPO_RESET << 12) | ((u8)(seqPlayerIndex) << 24) | \
((u8)(duration) << 16))
/**
* ==== Audio Sequence Setup Commands ====
*
* The setup commands are designed to wait to be executed.
* Up to 8 commands can be queued per `seqPlayerIndex`.
* These commands will only execute once that `seqPlayerIndex` is finished playing and is no longer enabled.
* They will often target a different player (`targetSeqPlayerIndex`) but not always.
*/
/**
* Setup a request to restore a volume on target seqPlayer once a setup seqPlayer is finished playing and disabled
*
* @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled
* @param targetSeqPlayerIndex the index of the seqPlayer to modify
* @param duration duration to transition to the volume
*/
#define SEQCMD_SETUP_RESTORE_SEQPLAYER_VOLUME(setupSeqPlayerIndex, targetSeqPlayerIndex, duration) \
Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME << 20) | \
((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | (u8)(duration))
/**
* Setup a request to unqueue a seqPlayer once that same setup seqPlayer is finished playing and disabled
*
* @param setupSeqPlayerIndex the index of the seqPlayer to unqueue once the same seqPlayer is disabled
*
* @bug this command was misimplemented and fails to unqueue. The command relies on `gActiveSeqs.seqId` for
* unqueueing, but seqId is reset before being used to unqueue. A simple fix is to unqueue based on
* `gActiveSeqs.prevSeqId` instead.
*/
#define SEQCMD_SETUP_UNQUEUE_SEQUENCE(setupSeqPlayerIndex) \
Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_SEQ_UNQUEUE << 20) | \
((u8)(setupSeqPlayerIndex) << 24))
/**
* Setup a request to restart and play an active sequence currently playing on a target seqPlayer
* once a setup seqPlayer is finished playing and disabled
*
* @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled
* @param targetSeqPlayerIndex the index of the seqPlayer to restart its active sequence
*/
#define SEQCMD_SETUP_RESTART_SEQUENCE(setupSeqPlayerIndex, targetSeqPlayerIndex) \
Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_RESTART_SEQ << 20) | \
((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16))
/**
* Setup a request to scale the tempo of a sequence by a multiplicative value on a target seqPlayer
* once a setup seqPlayer is finished playing and disabled
*
* @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled
* @param targetSeqPlayerIndex the index of the seqPlayer to modify
* @param duration duration to transition to the tempo
* @param tempoScale the scaling factor of the tempo, relative to 100
*
* @note a tempoScale of 200 will go double-time, 50 will go half-time.
* the absolute tempo is constrained to a maximum of 300
*/
#define SEQCMD_SETUP_SCALE_TEMPO(setupSeqPlayerIndex, targetSeqPlayerIndex, duration, tempoScale) \
Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_TEMPO_SCALE << 20) | \
((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | ((u8)(duration) << 8) | \
(u8)(tempoScale))
/**
* Setup a request to reset the tempo of a sequence to the original tempo on a target seqPlayer
* once a setup seqPlayer is finished playing and disabled
*
* @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled
* @param targetSeqPlayerIndex the index of the seqPlayer to modify
* @param duration duration to transition to the tempo
*/
#define SEQCMD_SETUP_RESET_TEMPO(setupSeqPlayerIndex, targetSeqPlayerIndex, duration) \
Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_TEMPO_RESET << 20) | \
((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | (u8)(duration))
/**
* Setup a request to play a sequence on a target seqPlayer once a setup seqPlayer is finished playing and disabled.
* This command is optionally paired with `SEQCMD_SETUP_SET_FADE_IN_TIMER` to set the fade in duration
*
* @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled
* @param targetSeqPlayerIndex the index of the seqPlayer to play the sequence
* @param seqId the id of the sequence to play, see `SeqId`
*/
#define SEQCMD_SETUP_PLAY_SEQUENCE(setupSeqPlayerIndex, targetSeqPlayerIndex, seqId) \
Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_PLAY_SEQ << 20) | \
((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | (u16)(seqId))
/**
* This command is an optional command before `SEQCMD_SETUP_PLAY_SEQUENCE` to set the fade in duration
* (see cmd above)
*
* @param targetSeqPlayerIndex the index of the seqPlayer to play the sequence
* @param fadeInDuration duration the sequence will fade in over
*/
#define SEQCMD_SETUP_SET_FADE_IN_TIMER(targetSeqPlayerIndex, fadeInDuration) \
Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_SET_FADE_TIMER << 20) | \
((u8)(targetSeqPlayerIndex) << 24) | ((u8)(fadeInDuration) << 8))
/**
* Setup a request to restore a volume on target seqPlayer once a setup seqPlayer is finished playing and disabled.
* Specifically, it will only restore volume if the number of queued requests on the setup seqPlayer matches
* the number of sequences queued
*
* @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled
* @param targetSeqPlayerIndex the index of the seqPlayer to modify
* @param duration duration to transition to the volume
* @param numSeqRequests the number of sequence requests queued that must match the actual number of sequence requests
*/
#define SEQCMD_SETUP_RESTORE_SEQPLAYER_VOLUME_IF_QUEUED(setupSeqPlayerIndex, targetSeqPlayerIndex, duration, \
numSeqRequests) \
Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME_IF_QUEUED << 20) | \
((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | ((u8)(duration) << 8) | \
(u8)(numSeqRequests))
/**
* Setup a request to restore a volume on target seqPlayer once a setup seqPlayer is finished playing and disabled.
* Allows `scaleIndex` to be specified.
*
* @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled
* @param targetSeqPlayerIndex the index of the seqPlayer to modify
* @param scaleIndex the scale index of a seqPlayer
* @param duration duration to transition to the volume
*/
#define SEQCMD_SETUP_RESTORE_SEQPLAYER_VOLUME_WITH_SCALE_INDEX(setupSeqPlayerIndex, targetSeqPlayerIndex, scaleIndex, \
duration) \
Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | \
(SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME_WITH_SCALE_INDEX << 20) | \
((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | \
((u8)(scaleIndex) << 8) | (u8)(duration))
/**
* Setup a request to disable (or reenable) specific channels on a target seqPlayer
* once a setup seqPlayer is finished playing and disabled.
*
* @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled
* @param targetSeqPlayerIndex the index of the seqPlayer to modify
* @param channelMask a 16 bit mask where each bit maps to a channel. Bitflag on to disable
*/
#define SEQCMD_SETUP_SET_CHANNEL_DISABLE_MASK(setupSeqPlayerIndex, targetSeqPlayerIndex, channelMask) \
Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_SET_CHANNEL_DISABLE_MASK << 20) | \
((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | (u16)(channelMask))
/**
* Queue a request to scale the frequency of an entire sequence on a target seqPlayer
* once a setup seqPlayer is finished playing and disabled.
*
* @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled
* @param targetSeqPlayerIndex the index of the seqPlayer to modify
* @param duration duration to transition to the frequency
* @param freqScale the scaling factor to shift the pitch. Ranged from 0-0xFF, with 100 mapping to 1.0f
*
* @note The base value for frequency, 100, is 10 times smaller than other frequency commands.
* 200 will double the frequency (raise an octave), 50 will halve the frequency (lower an octave).
*/
#define SEQCMD_SETUP_SET_SEQPLAYER_FREQ(setupSeqPlayerIndex, targetSeqPlayerIndex, duration, freqScale) \
Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_SET_SEQPLAYER_FREQ << 20) | \
((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | ((u8)(duration) << 8) | \
(u8)(freqScale))
/**
* Queue a request to discard audio data by popping an entry from the persistent caches on the audio heap,
* once a setup seqPlayer is finished playing and disabled.
*
* @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled
* @param tableTypeFlag All tables with the flag `(tableTypeFlag & (1 << tableType))` will be discarded. Specifically:
* `(tableTypeFlag & 1)` will discard the `SEQUENCE_TABLE`
* `(tableTypeFlag & 2)` will discard the `FONT_TABLE`
* `(tableTypeFlag & 4)` will discard the `SAMPLE_TABLE`
*/
#define SEQCMD_SETUP_POP_PERSISTENT_CACHE(setupSeqPlayerIndex, tableTypeFlag) \
Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_POP_PERSISTENT_CACHE << 20) | \
((u8)(setupSeqPlayerIndex) << 24) | ((u8)tableTypeFlag))
/**
* Discard all setup command requests on a seqPlayerIndex by resetting the setup command queue
*
* @param setupSeqPlayerIndex the index of the seqPlayer to disable all setup commands
*/
#define SEQCMD_RESET_SETUP_CMDS(setupSeqPlayerIndex) \
Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_RESET_SETUP_CMDS << 20) | \
((u8)(setupSeqPlayerIndex) << 24))
/**
* ==== Audio Sequence Global Commands ====
*
* The global commands will apply to the entire audio system and all 4 sequence players
*/
/**
* Change the sound mode of audio
*
* @param soundMode see the `SoundMode` enum
*/
#define SEQCMD_SET_SOUND_MODE(soundMode) \
Audio_QueueSeqCmd((SEQCMD_OP_GLOBAL_CMD << 28) | (SEQCMD_SUB_OP_GLOBAL_SET_SOUND_MODE << 8) | (u8)(soundMode))
/**
* Disable (or reenable) new sequences from starting
*
* @param isDisabled true to disable, false to enable
*
* @note this does not disable the sfx player
*/
#define SEQCMD_DISABLE_PLAY_SEQUENCES(isDisabled) \
Audio_QueueSeqCmd((SEQCMD_OP_GLOBAL_CMD << 28) | (SEQCMD_SUB_OP_GLOBAL_DISABLE_NEW_SEQUENCES << 8) | \
(u16)(isDisabled))
/**
* Restart the audio heap with the specified settings
*
* @param sfxChannelLayout index for different mappings between the 7 banks and the 16 channels
* @param specId index for the audio specifications to set high-level audio parameters
*
* @note: For sfxChannelLayout, There are 4 possible layouts indexed by 0-3.
* However, only index 0 is properly implemented. Other indices lead to bugs and softlocks.
*/
#define SEQCMD_RESET_AUDIO_HEAP(sfxChannelLayout, specId) \
Audio_QueueSeqCmd((SEQCMD_OP_RESET_AUDIO_HEAP << 28) | ((u8)(sfxChannelLayout) << 8) | (u8)(specId))
#endif