jaudio_NES: implement & link channel

This commit is contained in:
Cuyler36
2025-06-22 10:40:37 -04:00
parent 6fbc68f77b
commit a10e202517
11 changed files with 1074 additions and 72 deletions
+9
View File
@@ -138,6 +138,15 @@ typedef enum LpsCacheState {
/* 3 */ LPS_CACHE_STATE_DONE
} LpsCacheState;
typedef enum PhaseType {
PHASE_TYPE_0,
PHASE_TYPE_1,
PHASE_TYPE_2,
PHASE_TYPE_3,
PHASE_TYPE_NUM
} PhaseType;
#define VOICE_TYPE_PERCUSSION 0
#define VOICE_TYPE_SOUND_EFF 1
#define VOICE_TYPE_INSTRUMENT_START 2
+37 -36
View File
@@ -16,8 +16,8 @@ typedef struct link_ link;
/* sizeof(struct link_) == 0x10 */
struct link_ {
/* 0x00 */ link* next;
/* 0x04 */ link* prev;
/* 0x00 */ link* prev;
/* 0x04 */ link* next;
union {
/* 0x08 */ s32 numAfter; /* when link is head */
/* 0x08 */ void* pData; /* when link is node */
@@ -127,17 +127,24 @@ typedef struct wtstr_ {
/* sizeof(phase) == 0x01 */
typedef struct phase_ {
union {
struct {
/* 0x00 */ u8 _unused : 2;
/* 0x00 */ u8 type : 2;
/* 0x00 */ u8 strong_right : 1;
/* 0x00 */ u8 strong_left : 1;
/* 0x00 */ u8 strong_reverb_right : 1;
/* 0x00 */ u8 strong_reverb_left : 1;
};
/* 0x00 */ u8 asU8;
};
// union {
// struct {
// /* 0x00 */ u8 _unused : 2;
// /* 0x00 */ u8 type : 2;
// /* 0x00 */ u8 strong_right : 1;
// /* 0x00 */ u8 strong_left : 1;
// /* 0x00 */ u8 strong_reverb_right : 1;
// /* 0x00 */ u8 strong_reverb_left : 1;
// } flags;
// /* 0x00 */ u8 asU8;
// };
/* 0x00 */ u8 _unused : 2;
/* 0x00 */ u8 type : 2;
/* 0x00 */ u8 strong_right : 1;
/* 0x00 */ u8 strong_left : 1;
/* 0x00 */ u8 strong_reverb_right : 1;
/* 0x00 */ u8 strong_reverb_left : 1;
} phase;
/* sizeof(sweep) == 0x0C */
@@ -218,10 +225,10 @@ typedef struct commonch_ {
/* 0x00 */ u8 strong_right : 1;
/* 0x00 */ u8 strong_left : 1;
/* 0x00 */ u8 strong_reverb_right : 1;
/* 0x00 */ u8 storng_reverb_left : 1;
/* 0x00 */ u8 strong_reverb_left : 1;
/* 0x01 */ u8 reverb_idx : 3;
/* 0x01 */ u8 book_ofs : 2;
/* 0x01 */ u8 __book_ofs : 2;
/* 0x01 */ u8 is_synth_wave : 1;
/* 0x01 */ u8 has_two_parts : 1;
/* 0x01 */ u8 use_haas_effect : 1;
@@ -243,7 +250,7 @@ typedef struct commonch_ {
/* 0x14 */ s16* filter;
/* 0x18 */ u8 _18;
/* 0x19 */ u8 surround_effect_idx;
/* 0x1A */ u8 _1A;
/* 0x1A */ u8 book_ofs;
/* 0x1B */ u8 _1B[4];
} commonch;
@@ -289,7 +296,7 @@ typedef struct playbackparams_ {
/* 0x04 */ phase stereo_phase;
/* 0x05 */ u8 comb_filter_size;
/* 0x06 */ u16 comb_filter_gain;
/* 0x08 */ f32 frequency_scale;
/* 0x08 */ f32 pitch;
/* 0x0C */ f32 velocity;
/* 0x10 */ s16* filter;
/* 0x14 */ s16* filter_buf;
@@ -331,18 +338,10 @@ struct channel_ {
/* sizeof(drvparam) == 0x1C */
typedef struct drvparam_ {
/* 0x00 */ u8 _00;
/* 0x01 */ u8 _01;
/* 0x02 */ u8 _02;
/* 0x03 */ u8 _03;
/* 0x04 */ phase phase;
/* 0x08 */ f32 pitch;
/* 0x0C */ f32 volume;
/* 0x10 */ int _10;
/* 0x14 */ int _14;
/* 0x18 */ u8 _18;
/* 0x00 */ playbackparams playback;
/* 0x18 */ u8 comb_filter_size;
/* 0x19 */ u8 _19;
/* 0x1A */ u16 _1A;
/* 0x1A */ u16 comb_filter_gain;
} drvparam;
/* sizeof(voicetable) == 0x20 */
@@ -357,19 +356,19 @@ typedef struct voicetable_ {
/* 0x18 */ wtstr high_pitch_tuned_sample;
} voicetable;
/* sizeof(percvoicetable) == 0x10 */
typedef struct percvoicetable_ {
/* sizeof(perctable) == 0x10 */
typedef struct perctable_ {
/* 0x00 */ u8 adsr_decay_idx;
/* 0x01 */ u8 pan;
/* 0x02 */ u8 is_relocated;
/* 0x04 */ wtstr tuned_sample;
/* 0x0C */ envdat* envelope;
} percvoicetable;
} perctable;
/* sizeof(veffvoicetable) == 0x08 */
typedef struct veffvoicetable_ {
/* sizeof(percvoicetable) == 0x08 */
typedef struct percvoicetable_ {
/* 0x00 */ wtstr tuned_sample;
} veffvoicetable;
} percvoicetable;
/* sizeof(voiceinfo) == 0x14 */
typedef struct voiceinfo_ {
@@ -379,8 +378,8 @@ typedef struct voiceinfo_ {
/* 0x03 */ u8 wave_bank_id1;
/* 0x04 */ u16 num_sfx;
/* 0x08 */ voicetable** instruments;
/* 0x0C */ percvoicetable** percussion;
/* 0x10 */ veffvoicetable* effects;
/* 0x0C */ perctable** percussion;
/* 0x10 */ percvoicetable* effects;
} voiceinfo;
/* sizeof(delayparam) == 0x1C */
@@ -928,6 +927,8 @@ typedef struct AudioGlobals {
/* 0x92AC */ s32 _92AC;
} AudioGlobals;
#define NA_NO_NOTE ((note*)-1)
// typedef union SOUNDID_ {
// struct {
// u8 wave_id;
+8
View File
@@ -14,4 +14,12 @@ extern u8 DEFAULT_GTABLE[];
extern u8 BDB_SEQDATA[];
extern s16* WAVEMEM_TABLE[];
extern commonch NA_SVCINIT_TABLE[];
extern commonch NA_CHINIT_TABLE[];
extern u16 CDELAYTABLE[];
extern f32 PhoneLeft[];
extern f32 WideLeft[];
extern f32 StereoLeft[];
#endif
+5 -2
View File
@@ -9,8 +9,8 @@ extern channel* Nas_AllocationOnRequest(note* n);
extern wtstr* NoteToVoice(voicetable* voicetbl, s32 note);
extern voicetable* ProgToVp(s32 prog, s32 note);
extern percvoicetable* PercToPp(s32 perc, s32 note);
extern veffvoicetable* VpercToVep(s32 vperc, s32 note);
extern perctable* PercToPp(s32 perc, s32 note);
extern percvoicetable* VpercToVep(s32 vperc, s32 note);
extern void Nas_UpdateChannel(void);
@@ -19,5 +19,8 @@ extern void Nas_AllocVoices(chnode* node, s32 num);
extern void Nas_InitChNode(chnode* node);
extern void Nas_Release_Channel(note* n);
extern void Nas_Release_Channel_Force(note* n);
extern void Nas_EntryTrack(channel* chan, note* n);
extern void Nas_CutList(link* l);
#endif
+1
View File
@@ -7,6 +7,7 @@
extern void Nas_HeapInit(ALHeap* heap, u8* base, s32 len);
extern void* Nas_HeapAlloc(ALHeap* heap, s32 size);
extern void* Nas_HeapAlloc_CL(ALHeap* heap, s32 size);
extern void* Nas_NcHeapAlloc(ALHeap* heap, s32 size);
extern void* Nas_2ndHeapAlloc(ALHeap* heap, s32 size);
extern void* Nas_Alloc_Single(s32 size, s32 bank_id, u8* wave_addr, s8 medium, s32 cache);