Add 6-channel audio support.

This commit is contained in:
Tortuga veloz 2025-03-12 14:20:15 +01:00 committed by Alejandro Asenjo Nitti
parent 94553db6c1
commit 798f6fbe1f
13 changed files with 433 additions and 326 deletions

View file

@ -52,10 +52,14 @@ typedef void (*AudioCustomUpdateFunction)(void);
// Samples are processed in groups of 16 called a "frame"
#define SAMPLES_PER_FRAME ADPCMFSIZE
// The length of one left/right channel is 12 frames
#define MAX_NUM_AUDIO_CHANNELS 6
// The length of one channel is 12 frames
#define DMEM_1CH_SIZE (12 * SAMPLES_PER_FRAME * SAMPLE_SIZE)
// Both left and right channels
#define DMEM_2CH_SIZE (2 * DMEM_1CH_SIZE)
// 6 channels
#define DMEM_6CH_SIZE (6 * DMEM_1CH_SIZE)
#define AIBUF_LEN (170 * SAMPLES_PER_FRAME) // number of samples
#define AIBUF_SIZE (AIBUF_LEN * SAMPLE_SIZE) // number of bytes
@ -399,7 +403,8 @@ typedef struct {
typedef struct {
/* 0x00 */ u8 strongLeft : 1;
/* 0x00 */ u8 strongRight : 1;
/* 0x00 */ u8 bit2 : 2;
/* 0x00 */ u8 is_voice : 1;
/* 0x00 */ u8 is_sfx : 1;
/* 0x00 */ u8 unused : 2;
/* 0x00 */ u8 usesHeadsetPanEffects : 1;
/* 0x00 */ u8 stereoHeadsetEffects : 1;
@ -428,7 +433,8 @@ typedef struct SequenceChannel {
/* 0x00 */ u8 hasInstrument : 1;
/* 0x00 */ u8 stereoHeadsetEffects : 1;
/* 0x00 */ u8 largeNotes : 1; // notes specify duration and velocity
/* 0x00 */ u8 unused : 1;
/* 0x00 */ u8 is_voice : 1;
/* 0x00 */ u8 is_sfx : 1;
union {
struct {
/* 0x4 */ char pad_4 : 1;
@ -551,8 +557,12 @@ typedef struct {
/* 0x0C */ NoteSynthesisBuffers* synthesisBuffers;
/* 0x10 */ s16 curVolLeft;
/* 0x12 */ s16 curVolRight;
/* 0x14 */ char unk_14[0xC];
} NoteSynthesisState; // size = 0x20
/* 0x14 */ s16 curVolCenter;
/* 0x16 */ s16 curVolLfe;
/* 0x18 */ s16 curVolRLeft;
/* 0x1A */ s16 curVolRRight;
/* 0x1C */ char unk_14[0xC];
} NoteSynthesisState; // size = 0x1E
typedef struct {
/* 0x00 */ struct SequenceChannel* channel;
@ -609,9 +619,13 @@ typedef struct {
/* 0x05 */ u8 reverb;
/* 0x06 */ u16 panVolLeft;
/* 0x08 */ u16 panVolRight;
/* 0x0A */ u16 resampleRate;
/* 0x0C */ Sample** waveSampleAddr;
} NoteSubEu; // size = 0x10
/* 0x0A */ u16 panVolCenter;
/* 0x0C */ u16 panVolLfe;
/* 0x0E */ u16 panVolRLeft;
/* 0x10 */ u16 panVolRRight;
/* 0x12 */ u16 resampleRate;
/* 0x14 */ Sample** waveSampleAddr;
} NoteSubEu; // size = 0x16
typedef struct Note {
/* 0x00 */ AudioListItem listItem;