Mario Kart 64
Loading...
Searching...
No Matches
synthesis.h
Go to the documentation of this file.
1#ifndef AUDIO_SYNTHESIS_H
2#define AUDIO_SYNTHESIS_H
3
4#include "audio/internal.h"
5#include <libultra/gbi.h>
6
7#define DEFAULT_LEN_1CH 0x180
8#define DEFAULT_LEN_2CH 0x300
9
10#define DMEM_ADDR_TEMP 0x0
11#define DMEM_ADDR_RESAMPLED 0x20
12#define DMEM_ADDR_RESAMPLED2 0x1A0
13#define DMEM_ADDR_UNCOMPRESSED_NOTE 0x180
14#define DMEM_ADDR_NOTE_PAN_TEMP 0x200
15#define DMEM_ADDR_STEREO_STRONG_TEMP_DRY 0x200
16#define DMEM_ADDR_STEREO_STRONG_TEMP_WET 0x340
17#define DMEM_ADDR_COMPRESSED_ADPCM_DATA 0x3f0
18#define DMEM_ADDR_LEFT_CH 0x540
19#define DMEM_ADDR_RIGHT_CH 0x6C0
20#define DMEM_ADDR_WET_LEFT_CH 0x840
21#define DMEM_ADDR_WET_RIGHT_CH 0x9C0
22
23
24/*
25Its not clear what values these macros should have. Neither version seem to
26line up for MK64. Maybe each game has unique values for these? I don't know
27enough about the Audio engine stuff to speculate beyond that.
28
29Non-Shindou SM64
30#define DMEM_ADDR_TEMP 0x0
31#define DMEM_ADDR_RESAMPLED 0x20
32#define DMEM_ADDR_RESAMPLED2 0x160
33#define DMEM_ADDR_UNCOMPRESSED_NOTE 0x180
34#define DMEM_ADDR_NOTE_PAN_TEMP 0x200
35#define DMEM_ADDR_STEREO_STRONG_TEMP_DRY 0x200
36#define DMEM_ADDR_STEREO_STRONG_TEMP_WET 0x340
37#define DMEM_ADDR_COMPRESSED_ADPCM_DATA 0x3f0
38#define DMEM_ADDR_LEFT_CH 0x4c0
39#define DMEM_ADDR_RIGHT_CH 0x600
40#define DMEM_ADDR_WET_LEFT_CH 0x740
41#define DMEM_ADDR_WET_RIGHT_CH 0x880
42
43Shindou SM64
44#define DMEM_ADDR_TEMP 0x450
45#define DMEM_ADDR_RESAMPLED 0x470
46#define DMEM_ADDR_RESAMPLED2 0x5f0
47#define DMEM_ADDR_UNCOMPRESSED_NOTE 0x5f0
48#define DMEM_ADDR_NOTE_PAN_TEMP 0x650
49#define DMEM_ADDR_COMPRESSED_ADPCM_DATA 0x990
50#define DMEM_ADDR_LEFT_CH 0x990
51#define DMEM_ADDR_RIGHT_CH 0xb10
52#define DMEM_ADDR_WET_LEFT_CH 0xc90
53#define DMEM_ADDR_WET_RIGHT_CH 0xe10
54*/
55
56#define MAX_UPDATES_PER_FRAME 5
57
60 /* 0x02 */ s16 chunkLen; // never read
61 /* 0x04 */ s16* toDownsampleLeft;
62 /* 0x08 */ s16* toDownsampleRight; // data pointed to by left and right are adjacent in memory
63 /* 0x0C */ s32 startPos; // start pos in ring buffer
64 /* 0x10 */ s16 lengthA; // first length in ring buffer (from startPos, at most until end)
65 /* 0x12 */ s16 lengthB; // second length in ring buffer (from pos 0)
66}; // size = 0x14
67
69 /* 0x00 */ u8 resampleFlags;
70 /* 0x01 */ u8 useReverb;
71 /* 0x02 */ u8 framesLeftToIgnore;
72 /* 0x03 */ u8 curFrame;
73 /* 0x04 */ u8 downsampleRate;
74 /* 0x05 */ // u8 compilerPadding;
75 /* 0x06 */ u16 windowSize; // same as bufSizePerChannel
76 /* 0x08 */ u16 reverbGain;
77 /* 0x0A */ u16 resampleRate;
78 /* 0x0C */ s32 nextRingBufferPos;
79 /* 0x10 */ s32 unkC; // never read
80 /* 0x14 */ s32 bufSizePerChannel;
81 struct {
82 /* 0x18 */ s16* left;
83 /* 0x1C */ s16* right;
85 /* 0x20 */ s16* resampleStateLeft;
86 /* 0x24 */ s16* resampleStateRight;
87 /* 0x28 */ s16* unk24; // never read
88 /* 0x2C */ s16* unk28; // never read
90 /* 0xF8 */ s16* unkF8;
91 /* 0xFC */ s16* unkFC;
92 /* 0x100 */ s16* unk100;
93 /* 0x104 */ s16* unk104;
94}; // size = 0x108
95
96#define ALIGN(val, amnt) (((val) + (1 << amnt) - 1) & ~((1 << amnt) - 1))
97
98void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex, s32 reverbIndex);
99Acmd* synthesis_load_reverb_ring_buffer(Acmd*, u16, u16, s32, s32);
100Acmd* synthesis_save_reverb_ring_buffer(Acmd*, u16, u16, s32, s32);
101void func_800B6FB4(s32 updateIndexStart, s32 noteIndex);
102void synthesis_load_note_subs_eu(s32 updateIndex);
103Acmd* synthesis_execute(Acmd*, s32*, s16*, s32);
104Acmd* synthesis_resample_and_mix_reverb(Acmd*, s32, s16, s16);
105Acmd* synthesis_save_reverb_samples(Acmd*, s16, s16);
106Acmd* synthesis_do_one_audio_update(s16*, s32, Acmd*, s32);
107Acmd* synthesis_process_note(s32 noteIndex, struct NoteSubEu* noteSubEu, struct NoteSynthesisState* synthesisState,
108 s16* aiBuf, s32 inBuf, Acmd* cmd, s32 updateIndex);
109Acmd* load_wave_samples(Acmd* acmd, struct NoteSubEu* noteSubEu, struct NoteSynthesisState* synthesisState,
110 s32 nSamplesToLoad);
111Acmd* final_resample(Acmd* acmd, struct NoteSynthesisState* synthesisState, s32 count, u16 pitch, u16 dmemIn,
112 u32 flags);
113Acmd* func_800B86A0(Acmd* cmd, struct NoteSubEu* note, struct NoteSynthesisState* synthesisState, s32 nSamples,
114 u16 inBuf, s32 headsetPanSettings, u32 flags);
115Acmd* note_apply_headset_pan_effects(Acmd* acmd, struct NoteSubEu* noteSubEu, struct NoteSynthesisState* note,
116 s32 bufLen, s32 flags, s32 leftRight);
117
118extern struct SynthesisReverb gSynthesisReverbs[4];
119
120/*
121SO
122gLeftVolRampings is almost certainly gAudioSessionPool (D_803AFBC8) in disguise, but since
123synthesis' ro/data has already been broken out it'll be very hard to fix that.
124
125extern f32 gLeftVolRampings[3][1024];
126extern f32 gRightVolRampings[3][1024];
127extern f32 *gCurrentLeftVolRamping; // Points to any of the three left buffers above
128extern f32 *gCurrentRightVolRamping; // Points to any of the three right buffers above
129*/
130
131#endif // AUDIO_SYNTHESIS_H
Definition internal.h:410
Definition internal.h:383
Definition synthesis.h:58
s32 startPos
Definition synthesis.h:63
s16 * toDownsampleLeft
Definition synthesis.h:61
s16 lengthB
Definition synthesis.h:65
s16 lengthA
Definition synthesis.h:64
s16 * toDownsampleRight
Definition synthesis.h:62
s16 numSamplesAfterDownsampling
Definition synthesis.h:59
s16 chunkLen
Definition synthesis.h:60
Definition synthesis.h:68
s16 * unk28
Definition synthesis.h:88
struct ReverbRingBufferItem items[2][MAX_UPDATES_PER_FRAME]
Definition synthesis.h:89
u8 resampleFlags
Definition synthesis.h:69
u16 reverbGain
Definition synthesis.h:76
s32 unkC
Definition synthesis.h:79
s16 * resampleStateLeft
Definition synthesis.h:85
s16 * left
Definition synthesis.h:82
s16 * unk24
Definition synthesis.h:87
s32 bufSizePerChannel
Definition synthesis.h:80
u8 useReverb
Definition synthesis.h:70
s16 * right
Definition synthesis.h:83
u8 framesLeftToIgnore
Definition synthesis.h:71
u8 curFrame
Definition synthesis.h:72
s16 * resampleStateRight
Definition synthesis.h:86
s16 * unk100
Definition synthesis.h:92
u16 resampleRate
Definition synthesis.h:77
s16 * unkF8
Definition synthesis.h:90
s16 * unkFC
Definition synthesis.h:91
u8 downsampleRate
Definition synthesis.h:73
u16 windowSize
Definition synthesis.h:75
s32 nextRingBufferPos
Definition synthesis.h:78
struct SynthesisReverb::@054127357066234323373230206214007112033153245205 ringBuffer
s16 * unk104
Definition synthesis.h:93
struct SynthesisReverb gSynthesisReverbs[4]
Definition synthesis.c:35
Acmd * synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s16 *aiBuf, s32 inBuf, Acmd *cmd, s32 updateIndex)
Acmd * synthesis_execute(Acmd *, s32 *, s16 *, s32)
Definition synthesis.c:154
Acmd * synthesis_save_reverb_ring_buffer(Acmd *, u16, u16, s32, s32)
Definition synthesis.c:118
Acmd * synthesis_resample_and_mix_reverb(Acmd *, s32, s16, s16)
Definition synthesis.c:198
void func_800B6FB4(s32 updateIndexStart, s32 noteIndex)
Definition synthesis.c:125
Acmd * synthesis_load_reverb_ring_buffer(Acmd *, u16, u16, s32, s32)
Definition synthesis.c:111
void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex, s32 reverbIndex)
Definition synthesis.c:62
void synthesis_load_note_subs_eu(s32 updateIndex)
Definition synthesis.c:137
Acmd * note_apply_headset_pan_effects(Acmd *acmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *note, s32 bufLen, s32 flags, s32 leftRight)
Definition synthesis.c:702
Acmd * synthesis_do_one_audio_update(s16 *, s32, Acmd *, s32)
Definition synthesis.c:262
Acmd * func_800B86A0(Acmd *cmd, struct NoteSubEu *note, struct NoteSynthesisState *synthesisState, s32 nSamples, u16 inBuf, s32 headsetPanSettings, u32 flags)
#define MAX_UPDATES_PER_FRAME
Definition synthesis.h:56
Acmd * synthesis_save_reverb_samples(Acmd *, s16, s16)
Definition synthesis.c:236
Acmd * load_wave_samples(Acmd *acmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s32 nSamplesToLoad)
Definition synthesis.c:615
Acmd * final_resample(Acmd *acmd, struct NoteSynthesisState *synthesisState, s32 count, u16 pitch, u16 dmemIn, u32 flags)
Definition synthesis.c:633