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