Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
31650.c File Reference

Go to the source code of this file.

Macros

#define AU_EQPOW_MID_IDX   64
 
#define AU_EQPOW_MAX_IDX   127
 

Functions

void au_driver_init (AuSynDriver *driver, ALConfig *config)
 
void au_driver_release (void)
 
Acmd * alAudioFrame (Acmd *cmdList, s32 *cmdLen, s16 *outBuf, s32 outLen)
 
void au_use_global_volume (void)
 
void au_set_global_volume (s16 arg0)
 
s16 au_get_global_volume (void)
 
void func_80056D5C (u8 bStereoSound)
 
void au_bus_set_volume (u8 index, u16 arg1)
 
u16 au_bus_get_volume (u8 index, u16 arg1)
 
void au_bus_set_effect (u8 index, u8 effectType)
 
void au_bus_set_fx_params (u8 index, s16 delayIndex, s16 paramID, s32 value)
 
void au_pvoice_set_bus (u8 index, s8 busId)
 
void au_syn_stop_voice (u8 voiceIdx)
 
void au_syn_start_voice (u8 voiceIdx)
 
void au_syn_start_voice_params (u8 voiceIdx, u8 busId, Instrument *instrument, f32 pitch, s16 vol, u8 pan, u8 fxMix, s32 delta)
 
void au_syn_set_wavetable (u8 voiceIdx, Instrument *instrument)
 
void au_syn_set_pitch (u8 voiceIdx, f32 pitch)
 
void au_syn_set_mixer_params (u8 voiceIdx, s16 volume, s32 delta, u8 pan, u8 fxMix)
 
void au_syn_set_pan_fxmix (u8 voiceIdx, u8 pan, u8 fxMix)
 
void au_syn_set_volume_delta (u8 voiceIdx, s16 vol, s32 delta)
 
void au_syn_set_pan (u8 voiceIdx, u8 pan)
 
void au_syn_set_fxmix (u8 voiceIdx, u8 fxMix)
 
s32 au_syn_get_playing (u8 voiceIdx)
 
s32 au_syn_get_bus (u8 voiceIdx)
 
f32 au_syn_get_pitch (u8 voiceIdx)
 
u8 au_syn_get_pan (u8 voiceIdx)
 
s16 au_syn_get_dryamt (u8 voiceIdx)
 
s16 au_syn_get_wetamt (u8 voiceIdx)
 
s32 au_syn_get_volume_left (u8 voiceIdx)
 
s32 au_syn_get_volume_right (u8 voiceIdx)
 
void au_set_delay_time (s32 arg0)
 
void au_delay_left_channel (u8 groupIdx)
 
void au_delay_right_channel (u8 groupIdx)
 
void au_disable_channel_delay (void)
 
void au_delay_channel (s16 arg0)
 
void alHeapInit (ALHeap *hp, u8 *base, s32 len)
 
void * alHeapAlloc (ALHeap *heap, s32 count, s32 size)
 
void alCopy (void *src, void *dst, s32 size)
 

Variables

BSS s16 * AuDelayBufferMain
 
BSS s16 * AuDelayBufferAux
 
BSS s32 AuDelayCounter
 
BSS u8 AuDelayedVoiceGroup
 
BSS s16 AuDelayedChannel
 
BSS s32 AuDelayCount
 
AuSynDrivergActiveSynDriverPtr = NULL
 
AuSynDrivergSynDriverPtr = NULL
 
u8 AuUseGlobalVolume = FALSE
 
u16 AuGlobalVolume = 0x7FFF
 
u8 AuSynStereoDirty = FALSE
 
s16 AuEqPower [128]
 

Macro Definition Documentation

◆ AU_EQPOW_MID_IDX

◆ AU_EQPOW_MAX_IDX

Function Documentation

◆ au_driver_init()

void au_driver_init ( AuSynDriver * driver,
ALConfig * config )

Definition at line 25 of file 31650.c.

25 {
26 ALHeap* heap = config->heap;
27 s32 i;
28
29 if (gActiveSynDriverPtr != NULL) {
30 return;
31 }
32
33 driver->num_pvoice = config->num_pvoice;
34 driver->num_bus = config->num_bus;
35 driver->curSamples = 0;
36 driver->unk_04 = 0;
37 driver->outputRate = config->outputRate;
38 driver->dmaNew = config->dmaNew;
39
40 gActiveSynDriverPtr = driver;
41 gSynDriverPtr = driver;
42 AuUseGlobalVolume = FALSE;
43 AuGlobalVolume = 0x7FFF;
44 AuSynStereoDirty = TRUE;
45
47
48 // this is inlined alN_PVoiceNew
49 for (i = 0; i < config->num_pvoice; i++) {
50 AuPVoice* voice = &gSynDriverPtr->pvoices[i];
51 voice->decoder.state = alHeapAlloc(heap, 1, sizeof(*voice->decoder.state));
52 voice->decoder.lstate = alHeapAlloc(heap, 1, sizeof(*voice->decoder.lstate));
54 voice->decoder.lastsam = 0;
55 voice->decoder.first = 1;
56 voice->decoder.memin = NULL;
57 voice->resampler.state = alHeapAlloc(heap, 1, sizeof(*voice->resampler.state));
58 voice->resampler.delta = 0;
59 voice->resampler.first = 1;
60 voice->resampler.ratio = 1.0f;
61 voice->envMixer.state = alHeapAlloc(heap, 1, sizeof(*voice->envMixer.state));
62 voice->envMixer.first = 1;
63 voice->envMixer.motion = AL_STOPPED;
64 voice->envMixer.volume = 1;
65 voice->envMixer.ltgt = 1;
66 voice->envMixer.rtgt = 1;
67 voice->envMixer.cvolL = 1;
68 voice->envMixer.cvolR = 1;
69 voice->envMixer.dryamt = 0;
70 voice->envMixer.wetamt = 0;
71 voice->envMixer.lratm = 1;
72 voice->envMixer.lratl = 0;
73 voice->envMixer.rratm = 1;
74 voice->envMixer.rratl = 0;
75 voice->envMixer.delta = 0;
76 voice->envMixer.segEnd = 0;
77 voice->envMixer.pan = 64;
78 voice->unk_74 = 0;
79 voice->next = NULL;
80 voice->busId = FX_BUS_BGMA_MAIN;
81 voice->index = i;
82 }
83
84 gSynDriverPtr->fxBus = alHeapAlloc(heap, config->num_bus, sizeof(*gSynDriverPtr->fxBus));
85
86 for (i = 0; i < config->num_bus; i++) {
87 AuFxBus* fxBus = &gSynDriverPtr->fxBus[i];
88 fxBus->head = NULL;
89 fxBus->tail = NULL;
90 fxBus->gain = 0x7FFF;
92 fxBus->fxL = alHeapAlloc(heap, 1, sizeof(*fxBus->fxL));
93 fxBus->fxR = alHeapAlloc(heap, 1, sizeof(*fxBus->fxR));
94 func_80058E84(fxBus->fxL, fxBus->curEffectType, heap);
95 func_80058E84(fxBus->fxR, fxBus->curEffectType, heap);
96 }
97
102 AuDelayCount = 4;
103
106 for (i = 0; i < 4 * AUDIO_SAMPLES; i++) {
108 }
109
110 gSynDriverPtr->heap = heap;
111}
BSS s16 AuDelayedChannel
Definition 31650.c:11
BSS u8 AuDelayedVoiceGroup
Definition 31650.c:10
AuSynDriver * gActiveSynDriverPtr
Definition 31650.c:14
BSS s16 * AuDelayBufferAux
Definition 31650.c:8
BSS s16 * AuDelayBufferMain
Definition 31650.c:7
u8 AuUseGlobalVolume
Definition 31650.c:16
AuSynDriver * gSynDriverPtr
Definition 31650.c:15
u16 AuGlobalVolume
Definition 31650.c:17
void * alHeapAlloc(ALHeap *heap, s32 count, s32 size)
Definition 31650.c:743
BSS s32 AuDelayCount
Definition 31650.c:12
u8 AuSynStereoDirty
Definition 31650.c:18
ALHeap * heap
Definition audio.h:1186
s32 unk_04
Definition audio.h:511
f32 delta
Definition audio.h:470
s32 * savedMainOut
Definition audio.h:519
s16 dryamt
Definition audio.h:481
u16 gain
Definition audio.h:437
@ AU_FX_NONE
Definition audio.h:87
f32 ratio
Definition audio.h:469
s32 num_pvoice
Definition audio.h:1180
struct AuPVoice * next
Definition audio.h:497
s16 wetamt
Definition audio.h:482
s32 segEnd
Definition audio.h:490
s16 rtgt
Definition audio.h:488
s32 curSamples
Definition audio.h:510
s16 cvolR
Definition audio.h:480
ALDMANew2 dmaNew
Definition audio.h:515
s16 unk_74
Definition audio.h:501
s32 outputRate
Definition audio.h:512
u8 curEffectType
Definition audio.h:441
s16 lratm
Definition audio.h:484
s32 * savedAuxOut
Definition audio.h:520
AuLoadFilter decoder
Definition audio.h:498
ADPCM_STATE * state
Definition audio.h:453
void * dmaNew
Definition audio.h:1185
#define AUDIO_SAMPLES
Definition audio.h:44
s32 first
Definition audio.h:471
s16 rratm
Definition audio.h:487
s16 volume
Definition audio.h:478
AuPVoice * pvoices
Definition audio.h:517
s16 pan
Definition audio.h:477
s32 delta
Definition audio.h:489
ENVMIX_STATE * state
Definition audio.h:476
s32 lastsam
Definition audio.h:461
AuFxBus * fxBus
Definition audio.h:518
AuResampler resampler
Definition audio.h:499
ALHeap * heap
Definition audio.h:516
@ FX_BUS_BGMA_MAIN
Definition audio.h:119
s16 cvolL
Definition audio.h:479
s32 num_pvoice
Definition audio.h:513
s16 rratl
Definition audio.h:486
AuFX * fxR
Definition audio.h:440
s16 lratl
Definition audio.h:483
u8 index
Definition audio.h:504
struct AuPVoice * tail
Definition audio.h:444
ALDMAproc2 dmaFunc
Definition audio.h:458
s32 first
Definition audio.h:491
struct AuPVoice * head
Definition audio.h:443
u8 busId
Definition audio.h:503
s32 motion
Definition audio.h:492
ADPCM_STATE * lstate
Definition audio.h:454
NUDMAState * dmaState
Definition audio.h:459
s32 num_bus
Definition audio.h:514
s32 outputRate
Definition audio.h:1182
AuEnvMixer envMixer
Definition audio.h:500
s32 memin
Definition audio.h:463
RESAMPLE_STATE * state
Definition audio.h:468
s32 num_bus
Definition audio.h:1181
s16 ltgt
Definition audio.h:485
s32 first
Definition audio.h:462
AuFX * fxL
Definition audio.h:439
void func_80058E84(AuFX *fx, u8 mode, ALHeap *heap)
Definition reverb.c:137

Referenced by create_audio_system().

◆ au_driver_release()

void au_driver_release ( void )

Definition at line 113 of file 31650.c.

113 {
114 if (gActiveSynDriverPtr != NULL) {
115 gActiveSynDriverPtr = NULL;
116 }
117}

◆ alAudioFrame()

Acmd * alAudioFrame ( Acmd * cmdList,
s32 * cmdLen,
s16 * outBuf,
s32 outLen )

Definition at line 119 of file 31650.c.

119 {
120 Acmd* cmdListPos;
121 AuPVoice* pvoice;
122 AuFxBus* fxBus;
123
124 s16* bufPos;
125 s16 auxOut;
126 s16 mainOut;
127
128 s32 i;
129 s32 first = FALSE;
130
131 cmdListPos = cmdList;
132 bufPos = outBuf;
133 if (gActiveSynDriverPtr == NULL) {
134 *cmdLen = 0;
135 } else {
137 if (AuSynStereoDirty) {
138 for (i = 0; i < gSynDriverPtr->num_pvoice; i++) {
139 pvoice = &gSynDriverPtr->pvoices[i];
140 if (pvoice->envMixer.motion == AL_PLAYING) {
141 au_syn_set_pan(i, pvoice->envMixer.pan);
142 }
143 }
144 AuSynStereoDirty = FALSE;
145 }
146 while (outLen > 0) {
148 for (i = 0; i < gSynDriverPtr->num_pvoice; i++) {
149 pvoice = &gSynDriverPtr->pvoices[i];
150
151 if ((pvoice->busId != 0xFF) && (pvoice->busId < gSynDriverPtr->num_bus)) {
152 fxBus = &gSynDriverPtr->fxBus[pvoice->busId];
153 if (fxBus->tail != NULL) {
154 fxBus->tail->next = pvoice;
155 } else {
156 fxBus->head = pvoice;
157 }
158 fxBus->tail = pvoice;
159 }
160 }
161 first = TRUE;
162 for (i = 0; i < gSynDriverPtr->num_bus; i++) {
163 fxBus = &gSynDriverPtr->fxBus[i];
164 if (fxBus->head != NULL) {
165 // clear all main and aux outputs
166 aClearBuffer(cmdListPos++, N_AL_MAIN_L_OUT, 8 * AUDIO_SAMPLES);
167 if (fxBus->head != NULL) {
168 AuPVoice* next;
169 do {
170 cmdListPos = au_pull_voice(fxBus->head, cmdListPos);
171 next = fxBus->head->next;
172 fxBus->head->next = NULL;
173 fxBus->head = next;
174 } while (next != NULL);
175 fxBus->tail = NULL;
176 }
177 if (fxBus->curEffectType != AU_FX_NONE) {
178 cmdListPos = au_pull_fx(fxBus->fxL, cmdListPos, N_AL_AUX_L_OUT, 0);
179 cmdListPos = au_pull_fx(fxBus->fxR, cmdListPos, N_AL_AUX_R_OUT, 0);
180 }
181
182 // apply channel delay
183 if (i == AuDelayedVoiceGroup) {
184 mainOut = -1;
185 switch (AuDelayedChannel) {
186 case 1:
187 mainOut = N_AL_MAIN_L_OUT;
188 auxOut = N_AL_AUX_L_OUT;
189 break;
190 case 2:
191 mainOut = N_AL_MAIN_R_OUT;
192 auxOut = N_AL_AUX_R_OUT;
193 break;
194 }
195 if (mainOut != -1) {
196 n_aSaveBuffer(cmdListPos++, 2 * AUDIO_SAMPLES, mainOut, osVirtualToPhysical(AuDelayBufferMain + (AuDelayCounter % AuDelayCount) * AUDIO_SAMPLES));
197 n_aLoadBuffer(cmdListPos++, 2 * AUDIO_SAMPLES, mainOut, osVirtualToPhysical(AuDelayBufferMain + ((AuDelayCounter + 1) % AuDelayCount) * AUDIO_SAMPLES));
198 n_aSaveBuffer(cmdListPos++, 2 * AUDIO_SAMPLES, auxOut, osVirtualToPhysical(AuDelayBufferAux + (AuDelayCounter % AuDelayCount) * AUDIO_SAMPLES));
199 n_aLoadBuffer(cmdListPos++, 2 * AUDIO_SAMPLES, auxOut, osVirtualToPhysical(AuDelayBufferAux + ((AuDelayCounter + 1) % AuDelayCount) * AUDIO_SAMPLES));
200 }
201 }
202
203 // mix voice groups
204 if (first) {
205 aClearBuffer(cmdListPos++, 0, 4 * AUDIO_SAMPLES);
206 } else {
207 n_aLoadBuffer(cmdListPos++, 4 * AUDIO_SAMPLES, 0, osVirtualToPhysical(gSynDriverPtr->savedAuxOut));
208 }
209 aMix(cmdListPos++, 0, fxBus->gain, N_AL_AUX_L_OUT, 0);
210 aMix(cmdListPos++, 0, fxBus->gain, N_AL_AUX_R_OUT, 2 * AUDIO_SAMPLES);
211 n_aSaveBuffer(cmdListPos++, 4 * AUDIO_SAMPLES, 0, osVirtualToPhysical(gSynDriverPtr->savedAuxOut));
212 if (first) {
213 aClearBuffer(cmdListPos++, 0, 4 * AUDIO_SAMPLES);
214 first = FALSE;
215 } else {
216 n_aLoadBuffer(cmdListPos++, 4 * AUDIO_SAMPLES, 0, osVirtualToPhysical(gSynDriverPtr->savedMainOut));
217 }
218 aMix(cmdListPos++, 0, fxBus->gain, N_AL_MAIN_L_OUT, 0);
219 aMix(cmdListPos++, 0, fxBus->gain, N_AL_MAIN_R_OUT, 2 * AUDIO_SAMPLES);
220 n_aSaveBuffer(cmdListPos++, 4 * AUDIO_SAMPLES, 0, osVirtualToPhysical(gSynDriverPtr->savedMainOut));
221 }
222 }
223
224 aDMEMMove(cmdListPos++, 0, N_AL_MAIN_L_OUT, 4 * AUDIO_SAMPLES);
225 n_aLoadBuffer(cmdListPos++, 4 * AUDIO_SAMPLES, N_AL_AUX_L_OUT, osVirtualToPhysical(gSynDriverPtr->savedAuxOut));
226 aMix(cmdListPos++, 0, 0x7FFF, N_AL_AUX_L_OUT, N_AL_MAIN_L_OUT);
227 aMix(cmdListPos++, 0, 0x7FFF, N_AL_AUX_R_OUT, N_AL_MAIN_R_OUT);
228
229 if (AuUseGlobalVolume) {
230 u16 vol;
231 aDMEMMove(cmdListPos++, N_AL_MAIN_L_OUT, 0, 4 * AUDIO_SAMPLES);
232 aClearBuffer(cmdListPos++, N_AL_MAIN_L_OUT, 4 * AUDIO_SAMPLES);
233 vol = AuGlobalVolume;
234 aMix(cmdListPos++, 0, vol, 0, N_AL_MAIN_L_OUT);
235 aMix(cmdListPos++, 0, vol, 2 * AUDIO_SAMPLES, N_AL_MAIN_R_OUT);
236 }
237
238 outLen -= AUDIO_SAMPLES;
239 n_aInterleave(cmdListPos++);
240 n_aSaveBuffer(cmdListPos++, 4 * AUDIO_SAMPLES, 0, bufPos);
241 bufPos += 2 * AUDIO_SAMPLES;
244 }
245 *cmdLen = (cmdListPos - cmdList);
246 }
247 return cmdListPos;
248}
void au_update_players_main(void)
void au_update_clients_2(void)
BSS s32 AuDelayCounter
Definition 31650.c:9
void au_syn_set_pan(u8 voiceIdx, u8 pan)
Definition 31650.c:535
Acmd * au_pull_voice(AuPVoice *pvoice, Acmd *cmdBufPos)
Definition 33450.c:32
#define N_AL_AUX_R_OUT
Definition audio.h:37
#define N_AL_MAIN_R_OUT
Definition audio.h:35
#define N_AL_AUX_L_OUT
Definition audio.h:36
#define N_AL_MAIN_L_OUT
Definition audio.h:34
Acmd * au_pull_fx(AuFX *fx, Acmd *cmdBusPos, s16, s16)
Definition reverb.c:267

Referenced by nuAuMgr().

◆ au_use_global_volume()

void au_use_global_volume ( void )

Definition at line 250 of file 31650.c.

250 {
251 AuUseGlobalVolume = TRUE;
252}

Referenced by nuAuPreNMIProc().

◆ au_set_global_volume()

void au_set_global_volume ( s16 arg0)

Definition at line 254 of file 31650.c.

254 {
255 AuGlobalVolume = arg0;
256}

Referenced by nuAuPreNMIProc().

◆ au_get_global_volume()

s16 au_get_global_volume ( void )

Definition at line 258 of file 31650.c.

258 {
259 return AuGlobalVolume;
260}

Referenced by nuAuPreNMIProc().

◆ func_80056D5C()

void func_80056D5C ( u8 bStereoSound)

Definition at line 262 of file 31650.c.

262 {
263 AuSynUseStereo = bStereoSound;
264 AuSynStereoDirty = TRUE;
265}
volatile u8 AuSynUseStereo

Referenced by audio_set_mono(), and audio_set_stereo().

◆ au_bus_set_volume()

void au_bus_set_volume ( u8 index,
u16 arg1 )

Definition at line 267 of file 31650.c.

267 {
268 AuFxBus* fxBus = &gSynDriverPtr->fxBus[index];
269
270 fxBus->gain = arg1 & 0x7FFF;
271}

Referenced by au_fade_set_volume().

◆ au_bus_get_volume()

u16 au_bus_get_volume ( u8 index,
u16 arg1 )

Definition at line 273 of file 31650.c.

273 {
274 AuFxBus* fxBus = &gSynDriverPtr->fxBus[index];
275
276 return fxBus->gain;
277}

◆ au_bus_set_effect()

void au_bus_set_effect ( u8 index,
u8 effectType )

Definition at line 279 of file 31650.c.

279 {
280 AuFxBus* fxBus = &gSynDriverPtr->fxBus[index];
281
282 fxBus->curEffectType = effectType;
283 func_8005904C(fxBus->fxL, effectType);
284 func_8005904C(fxBus->fxR, effectType);
285}
void func_8005904C(AuFX *fx, u8 effectType)
Definition reverb.c:180

Referenced by au_syn_update().

◆ au_bus_set_fx_params()

void au_bus_set_fx_params ( u8 index,
s16 delayIndex,
s16 paramID,
s32 value )

Definition at line 287 of file 31650.c.

287 {
288 AuFxBus* fxBus = &gSynDriverPtr->fxBus[index];
289
290 au_fx_param_hdl(fxBus->fxL, delayIndex, paramID, value);
291 au_fx_param_hdl(fxBus->fxR, delayIndex, paramID, value);
292}
s32 au_fx_param_hdl(AuFX *fx, s16 index, s16 paramID, s32 value)
Definition reverb.c:384

◆ au_pvoice_set_bus()

void au_pvoice_set_bus ( u8 index,
s8 busId )

Definition at line 294 of file 31650.c.

294 {
295 AuPVoice* pvoice = &gSynDriverPtr->pvoices[index];
296
297 pvoice->busId = busId;
298}

Referenced by au_engine_init().

◆ au_syn_stop_voice()

void au_syn_stop_voice ( u8 voiceIdx)

Definition at line 301 of file 31650.c.

301 {
302 AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
303 AuLoadFilter* decoder = &pvoice->decoder;
304
305 pvoice->envMixer.motion = AL_STOPPED;
306 pvoice->envMixer.first = 1;
307 pvoice->envMixer.volume = 1;
308 pvoice->resampler.delta = 0;
309 pvoice->resampler.first = 1;
310 decoder->lastsam = 0;
311 decoder->first = 1;
312 decoder->sample = 0;
313 if (decoder->instrument != NULL) {
314 decoder->memin = (s32)decoder->instrument->base;
315 if (decoder->instrument->type == AL_ADPCM_WAVE) {
316 if (decoder->instrument->loopEnd != 0){
317 decoder->loop.count = decoder->instrument->loopCount;
318 }
319 } else if (decoder->instrument->type == AL_RAW16_WAVE) {
320 if (decoder->instrument->loopEnd != 0){
321 decoder->loop.count = decoder->instrument->loopCount;
322 }
323 }
324 }
325}
s32 loopEnd
Definition audio.h:554
s32 loopCount
Definition audio.h:555
u8 * base
Definition audio.h:550
struct Instrument * instrument
Definition audio.h:456
ALRawLoop loop
Definition audio.h:455
u8 type
Definition audio.h:563
s32 sample
Definition audio.h:460

Referenced by au_syn_update(), and au_update_stopped_voices().

◆ au_syn_start_voice()

void au_syn_start_voice ( u8 voiceIdx)

Definition at line 328 of file 31650.c.

328 {
329 AuPVoice* pvoice = (AuPVoice*)&gSynDriverPtr->pvoices[voiceIdx];
330
331 pvoice->envMixer.motion = AL_PLAYING;
332}

◆ au_syn_start_voice_params()

void au_syn_start_voice_params ( u8 voiceIdx,
u8 busId,
Instrument * instrument,
f32 pitch,
s16 vol,
u8 pan,
u8 fxMix,
s32 delta )

Definition at line 335 of file 31650.c.

335 {
336 AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
337 AuLoadFilter* decoder = &pvoice->decoder;
338 AuEnvMixer* envMixer = &pvoice->envMixer;
339 AuResampler* resampler = &pvoice->resampler;
340
341 pvoice->busId = busId;
342 decoder->instrument = instrument;
343
344 pvoice->decoder.memin = (s32)decoder->instrument->base;
345 pvoice->decoder.sample = 0;
346
347 switch (decoder->instrument->type) {
348 case AL_ADPCM_WAVE:
349 decoder->instrument->wavDataLength = (decoder->instrument->wavDataLength / ADPCMFBYTES) * ADPCMFBYTES;
350 pvoice->decoder.bookSize = decoder->instrument->dc_bookSize;
351 if (decoder->instrument->loopEnd == 0) {
352 decoder->loop.count = 0;
353 decoder->loop.end = 0;
354 decoder->loop.start = 0;
355 } else {
356 decoder->loop.start = decoder->instrument->loopStart;
357 decoder->loop.end = decoder->instrument->loopEnd;
358 decoder->loop.count = decoder->instrument->loopCount;
359 alCopy(decoder->instrument->loopPredictor, decoder->lstate, sizeof(ADPCM_STATE));
360 }
361 break;
362 case AL_RAW16_WAVE:
363 if (decoder->instrument->loopEnd != 0) {
364 decoder->loop.start = decoder->instrument->loopStart;
365 decoder->loop.end = decoder->instrument->loopEnd;
366 decoder->loop.count = decoder->instrument->loopCount;
367 } else {
368 decoder->loop.count = 0;
369 decoder->loop.end = 0;
370 decoder->loop.start = 0;
371 }
372 break;
373 }
374
375 envMixer->motion = AL_PLAYING;
376 envMixer->first = 1;
377 envMixer->delta = 0;
378 envMixer->segEnd = delta;
379 envMixer->pan = pan;
380 envMixer->volume = SQ(vol) >> 0xF;
381 envMixer->dryamt = AuEqPower[fxMix];
382 envMixer->wetamt = AuEqPower[AU_EQPOW_MAX_IDX - fxMix];
383 if (envMixer->segEnd != 0) {
384 envMixer->cvolL = 1;
385 envMixer->cvolR = 1;
386 } else {
387 if (!AuSynUseStereo) {
388 envMixer->cvolL = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
389 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
390 } else {
391 envMixer->cvolL = (envMixer->volume * AuEqPower[envMixer->pan]) >> 0xF;
392 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->pan]) >> 0xF;
393 }
394 }
395 resampler->ratio = pitch;
396}
#define AU_EQPOW_MID_IDX
Definition 31650.c:22
#define AU_EQPOW_MAX_IDX
Definition 31650.c:23
void alCopy(void *src, void *dst, s32 size)
Definition 31650.c:755
s16 AuEqPower[128]
Definition 33450.c:9
#define ADPCMFBYTES
Definition audio.h:47
#define SQ(x)
Definition macros.h:166

Referenced by au_syn_update().

◆ au_syn_set_wavetable()

void au_syn_set_wavetable ( u8 voiceIdx,
Instrument * instrument )

Definition at line 398 of file 31650.c.

398 {
399 AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
400 AuLoadFilter* decoder = &pvoice->decoder;
401
402 pvoice->decoder.instrument = instrument;
403 pvoice->decoder.memin = (s32)decoder->instrument->base;
404 pvoice->decoder.sample = 0;
405
406 switch (decoder->instrument->type) {
407 case AL_ADPCM_WAVE:
408 decoder->instrument->wavDataLength = (decoder->instrument->wavDataLength / ADPCMFBYTES) * ADPCMFBYTES;
409 pvoice->decoder.bookSize = decoder->instrument->dc_bookSize;
410 if (decoder->instrument->loopEnd == 0) {
411 pvoice->decoder.loop.count = 0;
412 pvoice->decoder.loop.end = 0;
413 pvoice->decoder.loop.start = 0;
414 } else {
415 pvoice->decoder.loop.start = decoder->instrument->loopStart;
416 pvoice->decoder.loop.end = decoder->instrument->loopEnd;
417 pvoice->decoder.loop.count = decoder->instrument->loopCount;
418 alCopy(decoder->instrument->loopPredictor, pvoice->decoder.lstate, sizeof(ADPCM_STATE));
419 }
420 break;
421 case AL_RAW16_WAVE:
422 if (decoder->instrument->loopEnd != 0) {
423 pvoice->decoder.loop.start = decoder->instrument->loopStart;
424 pvoice->decoder.loop.end = decoder->instrument->loopEnd;
425 pvoice->decoder.loop.count = decoder->instrument->loopCount;
426 } else {
427 pvoice->decoder.loop.count = 0;
428 pvoice->decoder.loop.end = 0;
429 pvoice->decoder.loop.start = 0;
430 }
431 break;
432 }
433}

Referenced by au_engine_init().

◆ au_syn_set_pitch()

void au_syn_set_pitch ( u8 voiceIdx,
f32 pitch )

Definition at line 436 of file 31650.c.

436 {
437 AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
438
439 pvoice->resampler.ratio = pitch;
440}

Referenced by au_syn_update().

◆ au_syn_set_mixer_params()

void au_syn_set_mixer_params ( u8 voiceIdx,
s16 volume,
s32 delta,
u8 pan,
u8 fxMix )

Definition at line 442 of file 31650.c.

442 {
443 AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
444 AuEnvMixer* envMixer = &pvoice->envMixer;
445
446 if (envMixer->delta >= envMixer->segEnd) {
447 envMixer->delta = envMixer->segEnd;
448 if (!AuSynUseStereo) {
449 envMixer->cvolL = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
450 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
451 } else {
452 envMixer->cvolL = (envMixer->volume * AuEqPower[envMixer->pan]) >> 0xF;
453 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->pan]) >> 0xF;
454 }
455 } else {
456 envMixer->cvolL = _getVol(envMixer->cvolL, envMixer->delta, envMixer->lratm, envMixer->lratl);
457 envMixer->cvolR = _getVol(envMixer->cvolR, envMixer->delta, envMixer->rratm, envMixer->rratl);
458 }
459 if (envMixer->cvolL == 0) {
460 envMixer->cvolL = 1;
461 }
462 if (envMixer->cvolR == 0) {
463 envMixer->cvolR = 1;
464 }
465
466 envMixer->delta = 0;
467 envMixer->segEnd = delta;
468 envMixer->pan = pan;
469 envMixer->volume = SQ(volume) >> 0xF;
470 envMixer->dryamt = AuEqPower[fxMix];
471 envMixer->wetamt = AuEqPower[AU_EQPOW_MAX_IDX - fxMix];
472 envMixer->first = 1;
473}

Referenced by au_syn_update().

◆ au_syn_set_pan_fxmix()

void au_syn_set_pan_fxmix ( u8 voiceIdx,
u8 pan,
u8 fxMix )

Definition at line 475 of file 31650.c.

475 {
476 AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
477 AuEnvMixer* envMixer = &pvoice->envMixer;
478
479 if (envMixer->delta >= envMixer->segEnd) {
480 envMixer->delta = envMixer->segEnd;
481 if (!AuSynUseStereo) {
482 envMixer->cvolL = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
483 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
484 } else {
485 envMixer->cvolL = (envMixer->volume * AuEqPower[envMixer->pan]) >> 0xF;
486 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->pan]) >> 0xF;
487 }
488 } else {
489 envMixer->cvolL = _getVol(envMixer->cvolL, envMixer->delta, envMixer->lratm, envMixer->lratl);
490 envMixer->cvolR = _getVol(envMixer->cvolR, envMixer->delta, envMixer->rratm, envMixer->rratl);
491 }
492 if (envMixer->cvolL == 0) {
493 envMixer->cvolL = 1;
494 }
495 if (envMixer->cvolR == 0) {
496 envMixer->cvolR = 1;
497 }
498
499 envMixer->pan = pan;
500 envMixer->dryamt = AuEqPower[fxMix];
501 envMixer->wetamt = AuEqPower[AU_EQPOW_MAX_IDX - fxMix];
502 envMixer->first = 1;
503}

Referenced by au_syn_update().

◆ au_syn_set_volume_delta()

void au_syn_set_volume_delta ( u8 voiceIdx,
s16 vol,
s32 delta )

Definition at line 505 of file 31650.c.

505 {
506 AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
507 AuEnvMixer* envMixer = &pvoice->envMixer;
508
509 if (envMixer->delta >= envMixer->segEnd) {
510 envMixer->delta = envMixer->segEnd;
511 if (!AuSynUseStereo) {
512 envMixer->cvolL = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
513 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
514 } else {
515 envMixer->cvolL = (envMixer->volume * AuEqPower[envMixer->pan]) >> 0xF;
516 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->pan]) >> 0xF;
517 }
518 } else {
519 envMixer->cvolL = _getVol(envMixer->cvolL, envMixer->delta, envMixer->lratm, envMixer->lratl);
520 envMixer->cvolR = _getVol(envMixer->cvolR, envMixer->delta, envMixer->rratm, envMixer->rratl);
521 }
522 if (envMixer->cvolL == 0) {
523 envMixer->cvolL = 1;
524 }
525 if (envMixer->cvolR == 0) {
526 envMixer->cvolR = 1;
527 }
528
529 envMixer->volume = SQ(vol) >> 0xF;
530 envMixer->delta = 0;
531 envMixer->segEnd = delta;
532 envMixer->first = 1;
533}

Referenced by au_reset_nonfree_voice(), and au_reset_voice().

◆ au_syn_set_pan()

void au_syn_set_pan ( u8 voiceIdx,
u8 pan )

Definition at line 535 of file 31650.c.

535 {
536 AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
537 AuEnvMixer* envMixer = &pvoice->envMixer;
538
539 if (envMixer->delta >= envMixer->segEnd) {
540 envMixer->delta = envMixer->segEnd;
541 if (!AuSynUseStereo) {
542 envMixer->cvolL = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
543 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
544 } else {
545 envMixer->cvolL = (envMixer->volume * AuEqPower[envMixer->pan]) >> 0xF;
546 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->pan]) >> 0xF;
547 }
548 } else {
549 envMixer->cvolL = _getVol(envMixer->cvolL, envMixer->delta, envMixer->lratm, envMixer->lratl);
550 envMixer->cvolR = _getVol(envMixer->cvolR, envMixer->delta, envMixer->rratm, envMixer->rratl);
551 }
552 if (envMixer->cvolL == 0) {
553 envMixer->cvolL = 1;
554 }
555 if (envMixer->cvolR == 0) {
556 envMixer->cvolR = 1;
557 }
558
559 envMixer->pan = pan;
560 envMixer->first = 1;
561}

Referenced by alAudioFrame().

◆ au_syn_set_fxmix()

void au_syn_set_fxmix ( u8 voiceIdx,
u8 fxMix )

Definition at line 563 of file 31650.c.

563 {
564 AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
565 AuEnvMixer* envMixer = &pvoice->envMixer;
566
567 if (envMixer->delta >= envMixer->segEnd) {
568 envMixer->delta = envMixer->segEnd;
569 if (!AuSynUseStereo) {
570 envMixer->cvolL = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
571 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
572 } else {
573 envMixer->cvolL = (envMixer->volume * AuEqPower[envMixer->pan]) >> 0xF;
574 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->pan]) >> 0xF;
575 }
576 } else {
577 envMixer->cvolL = _getVol(envMixer->cvolL, envMixer->delta, envMixer->lratm, envMixer->lratl);
578 envMixer->cvolR = _getVol(envMixer->cvolR, envMixer->delta, envMixer->rratm, envMixer->rratl);
579 }
580 if (envMixer->cvolL == 0) {
581 envMixer->cvolL = 1;
582 }
583 if (envMixer->cvolR == 0) {
584 envMixer->cvolR = 1;
585 }
586
587 envMixer->dryamt = AuEqPower[fxMix];
588 envMixer->wetamt = AuEqPower[AU_EQPOW_MAX_IDX - fxMix];
589 envMixer->first = 1;
590}

◆ au_syn_get_playing()

s32 au_syn_get_playing ( u8 voiceIdx)

Definition at line 592 of file 31650.c.

592 {
593 AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
594
595 return pvoice->envMixer.motion;
596}

◆ au_syn_get_bus()

s32 au_syn_get_bus ( u8 voiceIdx)

Definition at line 598 of file 31650.c.

598 {
599 AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
600
601 return pvoice->busId;
602}

◆ au_syn_get_pitch()

f32 au_syn_get_pitch ( u8 voiceIdx)

Definition at line 604 of file 31650.c.

604 {
605 AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
606
607 return pvoice->resampler.ratio;
608}

◆ au_syn_get_pan()

u8 au_syn_get_pan ( u8 voiceIdx)

Definition at line 610 of file 31650.c.

610 {
611 AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
612
613 return pvoice->envMixer.pan;
614}

◆ au_syn_get_dryamt()

s16 au_syn_get_dryamt ( u8 voiceIdx)

Definition at line 616 of file 31650.c.

616 {
617 AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
618
619 return pvoice->envMixer.dryamt;
620}

◆ au_syn_get_wetamt()

s16 au_syn_get_wetamt ( u8 voiceIdx)

Definition at line 622 of file 31650.c.

622 {
623 AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
624
625 return pvoice->envMixer.wetamt;
626}

◆ au_syn_get_volume_left()

s32 au_syn_get_volume_left ( u8 voiceIdx)

Definition at line 628 of file 31650.c.

628 {
629 AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
630 AuEnvMixer* envmixer = &pvoice->envMixer;
631 u32 retVal;
632
633 if (envmixer->delta >= envmixer->segEnd) {
634 if (!AuSynUseStereo) {
635 retVal = (envmixer->volume * AuEqPower[AU_EQPOW_MID_IDX] * 2) >> 0x10;
636 } else {
637 retVal = (envmixer->volume * AuEqPower[envmixer->pan] * 2) >> 0x10;
638 }
639 } else {
640 retVal = _getVol(envmixer->cvolL, envmixer->delta, envmixer->lratm, envmixer->lratl);
641 }
642 return retVal;
643}

◆ au_syn_get_volume_right()

s32 au_syn_get_volume_right ( u8 voiceIdx)

Definition at line 645 of file 31650.c.

645 {
646 AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
647 AuEnvMixer* envmixer = &pvoice->envMixer;
648 u32 retVal;
649
650 if (envmixer->delta >= envmixer->segEnd) {
651 if (!AuSynUseStereo) {
652 retVal = (envmixer->volume * AuEqPower[AU_EQPOW_MID_IDX] * 2) >> 0x10;
653 } else {
654 retVal = (envmixer->volume * AuEqPower[AU_EQPOW_MAX_IDX - envmixer->pan] * 2) >> 0x10;
655 }
656 } else {
657 retVal = _getVol(envmixer->cvolL, envmixer->delta, envmixer->lratm, envmixer->lratl);
658 }
659 return retVal;
660}

◆ au_set_delay_time()

void au_set_delay_time ( s32 arg0)

Definition at line 662 of file 31650.c.

662 {
663 if (arg0 < 2) {
664 AuDelayCount = 0;
666 }
667
668 AuDelayCount = arg0;
669 if (arg0 > 4) {
670 AuDelayCount = 4;
671 }
672}

Referenced by au_syn_update().

◆ au_delay_left_channel()

void au_delay_left_channel ( u8 groupIdx)

Definition at line 674 of file 31650.c.

674 {
675 s32* phi_a1 = (s32*)AuDelayBufferMain;
676 s32* phi_v1 = (s32*)AuDelayBufferAux;
677 s32 i;
678
679 for (i = 0; i < 2 * AUDIO_SAMPLES; i++) {
680 *phi_a1++ = 0;
681 *phi_v1++ = 0;
682 }
683
684 AuDelayedVoiceGroup = groupIdx;
686 AuDelayCounter = 0;
687}

Referenced by au_syn_update().

◆ au_delay_right_channel()

void au_delay_right_channel ( u8 groupIdx)

Definition at line 689 of file 31650.c.

689 {
690 s32* phi_a1 = (s32*)AuDelayBufferMain;
691 s32* phi_v1 = (s32*)AuDelayBufferAux;
692 s32 i;
693
694 for (i = 0; i < 2 * AUDIO_SAMPLES; i++) {
695 *phi_a1++ = 0;
696 *phi_v1++ = 0;
697 }
698
699 AuDelayedVoiceGroup = groupIdx;
701 AuDelayCounter = 0;
702}

Referenced by au_syn_update().

◆ au_disable_channel_delay()

void au_disable_channel_delay ( void )

Definition at line 704 of file 31650.c.

704 {
707 AuDelayCounter = 0;
708}

Referenced by au_syn_update().

◆ au_delay_channel()

void au_delay_channel ( s16 arg0)

Definition at line 710 of file 31650.c.

710 {
711 s32* phi_a1 = (s32*)AuDelayBufferMain;
712 s32* phi_v1 = (s32*)AuDelayBufferAux;
713 s32 i;
714
715 for (i = 0; i < 2 * AUDIO_SAMPLES; i++) {
716 *phi_a1++ = 0;
717 *phi_v1++ = 0;
718 }
719
721 AuDelayedChannel = arg0;
722 AuDelayCounter = 0;
723}

Referenced by au_engine_init().

◆ alHeapInit()

void alHeapInit ( ALHeap * hp,
u8 * base,
s32 len )

Definition at line 725 of file 31650.c.

725 {
726 u32 i;
727 s32 alignBytes = 0x10 - ((s32)base & 0xF);
728
729 if (alignBytes != 0x10) {
730 hp->base = base + alignBytes;
731 } else {
732 hp->base = base;
733 }
734 hp->len = len;
735 hp->count = 0;
736 hp->cur = hp->base;
737
738 for (i = 0; i < (u32)(hp->len) >> 2; i++) {
739 ((u32*)hp->base)[i] = 0;
740 }
741}

Referenced by create_audio_system().

◆ alHeapAlloc()

void * alHeapAlloc ( ALHeap * heap,
s32 count,
s32 size )

Definition at line 743 of file 31650.c.

743 {
744 void* ret = NULL;
745 u8* newCur = &heap->cur[ALIGN16(count * size)];
746
747 if (&heap->base[heap->len] >= newCur) {
748 ret = heap->cur;
749 heap->cur = newCur;
750 }
751
752 return ret;
753}
#define ALIGN16(val)
Definition macros.h:20

Referenced by au_driver_init(), au_engine_init(), au_load_BK_to_bank(), au_load_INIT(), create_audio_system(), func_80054AA0(), func_80058E84(), and func_80058F88().

◆ alCopy()

void alCopy ( void * src,
void * dst,
s32 size )

Definition at line 755 of file 31650.c.

755 {
756 s32 i;
757 u8* srcIt = src;
758 u8* dstIt = dst;
759
760 for (i = 0; i < size; i++) {
761 *dstIt++ = *srcIt++;
762 }
763}

Referenced by au_syn_set_wavetable(), and au_syn_start_voice_params().

Variable Documentation

◆ AuDelayBufferMain

BSS s16* AuDelayBufferMain

◆ AuDelayBufferAux

BSS s16* AuDelayBufferAux

◆ AuDelayCounter

BSS s32 AuDelayCounter

◆ AuDelayedVoiceGroup

◆ AuDelayedChannel

◆ AuDelayCount

BSS s32 AuDelayCount

Definition at line 12 of file 31650.c.

Referenced by alAudioFrame(), au_driver_init(), and au_set_delay_time().

◆ gActiveSynDriverPtr

AuSynDriver* gActiveSynDriverPtr = NULL

◆ gSynDriverPtr

◆ AuUseGlobalVolume

u8 AuUseGlobalVolume = FALSE

Definition at line 16 of file 31650.c.

Referenced by alAudioFrame(), au_driver_init(), and au_use_global_volume().

◆ AuGlobalVolume

u16 AuGlobalVolume = 0x7FFF

Definition at line 17 of file 31650.c.

Referenced by alAudioFrame(), au_driver_init(), au_get_global_volume(), and au_set_global_volume().

◆ AuSynStereoDirty

u8 AuSynStereoDirty = FALSE

Definition at line 18 of file 31650.c.

Referenced by alAudioFrame(), au_driver_init(), and func_80056D5C().

◆ AuEqPower

s16 AuEqPower[128]
extern

Definition at line 9 of file 33450.c.

9 {
10 32767, 32764, 32757, 32744, 32727, 32704, 32677, 32644,
11 32607, 32564, 32517, 32464, 32407, 32344, 32277, 32205,
12 32127, 32045, 31958, 31866, 31770, 31668, 31561, 31450,
13 31334, 31213, 31087, 30957, 30822, 30682, 30537, 30388,
14 30234, 30075, 29912, 29744, 29572, 29395, 29214, 29028,
15 28838, 28643, 28444, 28241, 28033, 27821, 27605, 27385,
16 27160, 26931, 26698, 26461, 26220, 25975, 25726, 25473,
17 25216, 24956, 24691, 24423, 24151, 23875, 23596, 23313,
18 23026, 22736, 22442, 22145, 21845, 21541, 21234, 20924,
19 20610, 20294, 19974, 19651, 19325, 18997, 18665, 18331,
20 17993, 17653, 17310, 16965, 16617, 16266, 15913, 15558,
21 15200, 14840, 14477, 14113, 13746, 13377, 13006, 12633,
22 12258, 11881, 11503, 11122, 10740, 10357, 9971, 9584,
23 9196, 8806, 8415, 8023, 7630, 7235, 6839, 6442,
24 6044, 5646, 5246, 4845, 4444, 4042, 3640, 3237,
25 2833, 2429, 2025, 1620, 1216, 810, 405, 0
26};

Referenced by au_pull_voice(), au_syn_get_volume_left(), au_syn_get_volume_right(), au_syn_set_fxmix(), au_syn_set_mixer_params(), au_syn_set_pan(), au_syn_set_pan_fxmix(), au_syn_set_volume_delta(), and au_syn_start_voice_params().