Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
syn_driver.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)
 
AcmdalAudioFrame (Acmd *cmdList, s32 *cmdLen, s16 *outBuf, s32 outLen)
 
void au_use_global_volume (void)
 
void au_set_global_volume (s16 volume)
 
s16 au_get_global_volume (void)
 
void au_set_stereo_enabled (b8 enabled)
 
void au_bus_set_volume (u8 busID, u16 value)
 
u16 au_bus_get_volume (u8 busID)
 
void au_bus_set_effect (u8 busID, u8 effectType)
 
void au_bus_set_fx_params (u8 busID, s16 delayIndex, s16 paramID, s32 value)
 
void au_pvoice_set_bus (u8 voiceIdx, 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 pitchRatio, 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 numFrames)
 
void au_delay_left_channel (u8 busID)
 
void au_delay_right_channel (u8 busID)
 
void au_disable_channel_delay (void)
 
void au_init_delay_channel (s16 channel)
 
void alHeapInit (ALHeap *hp, u8 *base, s32 len)
 
voidalHeapAlloc (ALHeap *heap, s32 count, s32 size)
 
void alCopy (void *src, void *dst, s32 size)
 

Variables

BSS s16AuDelayBufferMain
 
BSS s16AuDelayBufferAux
 
BSS s32 AuDelayCounter
 
BSS u8 AuDelayedBusID
 
BSS s16 AuDelayedChannel
 
BSS s32 AuDelayCount
 
AuSynDrivergActiveSynDriverPtr = NULL
 
AuSynDrivergSynDriverPtr = NULL
 
u8 AuUseGlobalVolume = FALSE
 
u16 AuGlobalVolume = AU_MAX_VOLUME_16
 
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 syn_driver.c.

25 {
26 ALHeap* heap = config->heap;
27 s32 i;
28
30 return;
31 }
32
33 driver->num_pvoice = config->num_pvoice;
34 driver->num_bus = config->num_bus;
35 driver->curSamples = 0;
36 driver->unused_04 = 0;
37 driver->outputRate = config->outputRate;
38 driver->dmaNew = config->dmaNew;
39
45
46 gSynDriverPtr->pvoices = alHeapAlloc(heap, config->num_pvoice, sizeof(*gSynDriverPtr->pvoices));
47
48 // this is inlined alN_PVoiceNew
49 for (i = 0; i < config->num_pvoice; i++) {
51 voice->decoder.state = alHeapAlloc(heap, 1, sizeof(*voice->decoder.state));
52 voice->decoder.lstate = alHeapAlloc(heap, 1, sizeof(*voice->decoder.lstate));
53 voice->decoder.dmaFunc = gSynDriverPtr->dmaNew(&voice->decoder.dmaState);
54 voice->decoder.lastsam = 0;
55 voice->decoder.first = 1;
56 voice->decoder.memin = (s32)NULL;
57 voice->resampler.state = alHeapAlloc(heap, 1, sizeof(*voice->resampler.state));
58 voice->resampler.delta = 0;
59 voice->resampler.first = TRUE;
60 voice->resampler.ratio = 1.0f;
61 voice->envMixer.state = alHeapAlloc(heap, 1, sizeof(*voice->envMixer.state));
62 voice->envMixer.dirty = TRUE;
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->unused_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 au_fx_create(fxBus->fxL, fxBus->curEffectType, heap);
95 au_fx_create(fxBus->fxR, fxBus->curEffectType, heap);
96 }
97
100 AuDelayedBusID = 0;
102 AuDelayCount = 4;
103
106 for (i = 0; i < 4 * AUDIO_SAMPLES; i++) {
108 }
109
110 gSynDriverPtr->heap = heap;
111}
BSS s32 PopupMenu_SelectedIndex
u16 gain
Definition audio.h:561
@ AU_FX_NONE
Definition audio.h:155
s32 * dryAccumBuffer
Definition audio.h:644
ALDMANew2 dmaNew
Definition audio.h:640
u8 curEffectType
Definition audio.h:565
@ AU_DELAY_CHANNEL_NONE
Definition audio.h:241
AuLoadFilter decoder
Definition audio.h:623
ADPCM_STATE * state
Definition audio.h:578
#define AUDIO_SAMPLES
Definition audio.h:16
AuPVoice * pvoices
Definition audio.h:642
AuFxBus * fxBus
Definition audio.h:643
ALHeap * heap
Definition audio.h:641
@ FX_BUS_BGMA_MAIN
Definition audio.h:234
AuFX * fxR
Definition audio.h:564
struct AuPVoice * tail
Definition audio.h:568
struct AuPVoice * head
Definition audio.h:567
s32 * wetAccumBuffer
Definition audio.h:645
#define AU_MAX_VOLUME_16
Definition audio.h:62
AuFX * fxL
Definition audio.h:563
void au_fx_create(AuFX *fx, u8 mode, ALHeap *heap)
Definition reverb.c:138
BSS s16 AuDelayedChannel
Definition syn_driver.c:11
AuSynDriver * gActiveSynDriverPtr
Definition syn_driver.c:14
BSS s16 * AuDelayBufferAux
Definition syn_driver.c:8
BSS s16 * AuDelayBufferMain
Definition syn_driver.c:7
u8 AuUseGlobalVolume
Definition syn_driver.c:16
AuSynDriver * gSynDriverPtr
Definition syn_driver.c:15
u16 AuGlobalVolume
Definition syn_driver.c:17
void * alHeapAlloc(ALHeap *heap, s32 count, s32 size)
Definition syn_driver.c:765
BSS s32 AuDelayCount
Definition syn_driver.c:12
u8 AuSynStereoDirty
Definition syn_driver.c:18
BSS u8 AuDelayedBusID
Definition syn_driver.c:10

Referenced by create_audio_system().

◆ au_driver_release()

void au_driver_release ( void )

Definition at line 113 of file syn_driver.c.

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

◆ alAudioFrame()

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

Definition at line 119 of file syn_driver.c.

119 {
120 Acmd* cmdListPos = cmdList;
121 s16* bufPos = outBuf;
123 AuFxBus* fxBus;
124 s16 mainOut;
125 s16 auxOut;
126 s32 busID;
128
129 // sanity check: ensure audio system is initialized
130 if (gActiveSynDriverPtr == NULL) {
131 *cmdLen = 0;
132 return cmdListPos;
133 }
134
136
137 // reapply panning if dirty
138 if (AuSynStereoDirty) {
139 for (busID = 0; busID < gSynDriverPtr->num_pvoice; busID++) {
140 pvoice = &gSynDriverPtr->pvoices[busID];
141 if (pvoice->envMixer.motion == AL_PLAYING) {
142 au_syn_set_pan(busID, pvoice->envMixer.pan);
143 }
144 }
146 }
147
148 // process blocks of AUDIO_SAMPLES until outLen is consumed
149 while (outLen > 0) {
151
152 // organize all voices by which FX bus they send to
153 for (busID = 0; busID < gSynDriverPtr->num_pvoice; busID++) {
154 pvoice = &gSynDriverPtr->pvoices[busID];
155
156 if ((pvoice->busID != 0xFF) && (pvoice->busID < gSynDriverPtr->num_bus)) {
157 fxBus = &gSynDriverPtr->fxBus[pvoice->busID];
158 if (fxBus->tail != NULL) {
159 fxBus->tail->next = pvoice;
160 } else {
161 fxBus->head = pvoice;
162 }
163 fxBus->tail = pvoice;
164 }
165 }
166
167 // render each effects bus
168 firstBus = TRUE;
169 for (busID = 0; busID < gSynDriverPtr->num_bus; busID++) {
170 fxBus = &gSynDriverPtr->fxBus[busID];
171 if (fxBus->head != NULL) {
172 // clear all main and aux outputs (each is 2 * AUDIO_SAMPLES long, starting at N_AL_MAIN_L_OUT)
174
175 // render all voices for this bus
176 // these will implicitly accumulate dry to N_AL_MAIN_*_OUT and wet to N_AL_AUX_*_OUT
177 if (fxBus->head != NULL) {
178 AuPVoice* next;
179 do {
181 next = fxBus->head->next;
182 fxBus->head->next = NULL;
183 fxBus->head = next;
184 } while (next != NULL);
185 fxBus->tail = NULL;
186 }
187
188 // process fx for this bus
189 if (fxBus->curEffectType != AU_FX_NONE) {
192 }
193
194 // apply channel delay
195 if (busID == AuDelayedBusID) {
196 mainOut = -1;
197 switch (AuDelayedChannel) {
201 break;
205 break;
206 }
207 if (mainOut != -1) {
212 }
213 }
214
215 // wet mix down for this bus
216 if (firstBus) {
217 // clear accumulation buffer if first bus with output
219 } else {
220 // load accumulation buffer from DRAM
222 }
225 // save accumulation buffer to DRAM
227
228 // dry mix down for this bus
229 if (firstBus) {
230 // clear accumulation buffer if first bus with output
232 firstBus = FALSE;
233 } else {
234 // load accumulation buffer from DRAM
236 }
239 // save accumulation buffer to DRAM
241 }
242 }
243
244 // final output mix stage
249
250 // global volume control (used to fade out during console reset)
251 if (AuUseGlobalVolume) {
252 u16 vol;
258 }
259
263 bufPos += 2 * AUDIO_SAMPLES;
266 }
267 *cmdLen = (cmdListPos - cmdList);
268
269 return cmdListPos;
270}
struct AuPVoice * next
Definition audio.h:622
#define N_AL_AUX_R_OUT
Definition audio.h:38
s32 curSamples
Definition audio.h:635
@ AU_DELAY_CHANNEL_LEFT
Definition audio.h:242
@ AU_DELAY_CHANNEL_RIGHT
Definition audio.h:243
#define N_AL_TEMP_1
Definition audio.h:33
s32 num_pvoice
Definition audio.h:638
#define N_AL_TEMP_0
Definition audio.h:31
#define N_AL_MAIN_R_OUT
Definition audio.h:36
#define N_AL_AUX_L_OUT
Definition audio.h:37
s32 num_bus
Definition audio.h:639
#define N_AL_MAIN_L_OUT
Definition audio.h:35
s32 b32
void au_update_clients_for_video_frame(void)
this is called once per video frame update (50 or 60 times per second)
Definition engine.c:286
void au_update_clients_for_audio_frame(void)
this is called per audio frame generated by alAudioFrame (every 184 audio samples) there will be mult...
Definition engine.c:210
Acmd * au_pull_fx(AuFX *fx, Acmd *cmdBusPos, s16, s16)
Applies a chain of delay-line based effects to audio and mixes into output.
Definition reverb.c:281
Acmd * au_pull_voice(AuPVoice *pvoice, Acmd *cmdBufPos)
Definition pull_voice.c:33
BSS s32 AuDelayCounter
Definition syn_driver.c:9
void au_syn_set_pan(u8 voiceIdx, u8 pan)
Definition syn_driver.c:557

Referenced by nuAuMgr().

◆ au_use_global_volume()

void au_use_global_volume ( void )

Definition at line 272 of file syn_driver.c.

272 {
274}

Referenced by nuAuPreNMIProc().

◆ au_set_global_volume()

void au_set_global_volume ( s16 volume)

Definition at line 276 of file syn_driver.c.

276 {
277 AuGlobalVolume = volume;
278}

Referenced by nuAuPreNMIProc().

◆ au_get_global_volume()

s16 au_get_global_volume ( void )

Definition at line 280 of file syn_driver.c.

280 {
281 return AuGlobalVolume;
282}

Referenced by nuAuPreNMIProc().

◆ au_set_stereo_enabled()

void au_set_stereo_enabled ( b8 enabled)

Definition at line 284 of file syn_driver.c.

284 {
285 AuSynUseStereo = enabled;
287}
volatile u8 AuSynUseStereo
Definition system.c:10

Referenced by snd_set_mono(), and snd_set_stereo().

◆ au_bus_set_volume()

void au_bus_set_volume ( u8 busID,
u16 value )

Definition at line 289 of file syn_driver.c.

289 {
290 AuFxBus* fxBus = &gSynDriverPtr->fxBus[busID];
291
292 fxBus->gain = value & 0x7FFF;
293}

Referenced by au_fade_set_volume().

◆ au_bus_get_volume()

u16 au_bus_get_volume ( u8 busID)

Definition at line 295 of file syn_driver.c.

295 {
296 AuFxBus* fxBus = &gSynDriverPtr->fxBus[busID];
297
298 return fxBus->gain;
299}

◆ au_bus_set_effect()

void au_bus_set_effect ( u8 busID,
u8 effectType )

Definition at line 301 of file syn_driver.c.

301 {
302 AuFxBus* fxBus = &gSynDriverPtr->fxBus[busID];
303
304 fxBus->curEffectType = effectType;
305 au_fx_load_preset(fxBus->fxL, effectType);
306 au_fx_load_preset(fxBus->fxR, effectType);
307}
void au_fx_load_preset(AuFX *fx, u8 effectType)
Definition reverb.c:181

Referenced by au_syn_begin_audio_frame().

◆ au_bus_set_fx_params()

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

Definition at line 309 of file syn_driver.c.

309 {
310 AuFxBus* fxBus = &gSynDriverPtr->fxBus[busID];
311
312 au_fx_param_hdl(fxBus->fxL, delayIndex, paramID, value);
313 au_fx_param_hdl(fxBus->fxR, delayIndex, paramID, value);
314}
s32 au_fx_param_hdl(AuFX *fx, s16 index, s16 paramID, s32 value)
Definition reverb.c:416

◆ au_pvoice_set_bus()

void au_pvoice_set_bus ( u8 voiceIdx,
s8 busID )

Definition at line 316 of file syn_driver.c.

316 {
318
319 pvoice->busID = busID;
320}
u8 busID
Definition audio.h:628

Referenced by au_engine_init().

◆ au_syn_stop_voice()

void au_syn_stop_voice ( u8 voiceIdx)

Definition at line 323 of file syn_driver.c.

323 {
325 AuLoadFilter* decoder = &pvoice->decoder;
326
327 pvoice->envMixer.motion = AL_STOPPED;
328 pvoice->envMixer.dirty = TRUE;
329 pvoice->envMixer.volume = 1;
330 pvoice->resampler.delta = 0;
331 pvoice->resampler.first = 1;
332 decoder->lastsam = 0;
333 decoder->first = TRUE;
334 decoder->sample = 0;
335 if (decoder->instrument != NULL) {
336 decoder->memin = (s32)decoder->instrument->wavData;
337 if (decoder->instrument->type == AL_ADPCM_WAVE) {
338 if (decoder->instrument->loopEnd != 0){
339 decoder->loop.count = decoder->instrument->loopCount;
340 }
341 } else if (decoder->instrument->type == AL_RAW16_WAVE) {
342 if (decoder->instrument->loopEnd != 0){
343 decoder->loop.count = decoder->instrument->loopCount;
344 }
345 }
346 }
347}
s32 loopEnd
Definition audio.h:679
s32 loopCount
Definition audio.h:680
s32 lastsam
Definition audio.h:586
struct Instrument * instrument
Definition audio.h:581
u8 * wavData
Definition audio.h:675
ALRawLoop loop
Definition audio.h:580
s32 memin
Definition audio.h:588
u8 type
Definition audio.h:688
s32 first
Definition audio.h:587
s32 sample
Definition audio.h:585

Referenced by au_flush_finished_voices(), and au_syn_begin_audio_frame().

◆ au_syn_start_voice()

void au_syn_start_voice ( u8 voiceIdx)

Definition at line 350 of file syn_driver.c.

350 {
352
353 pvoice->envMixer.motion = AL_PLAYING;
354}

◆ au_syn_start_voice_params()

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

Definition at line 357 of file syn_driver.c.

357 {
359 AuLoadFilter* decoder = &pvoice->decoder;
360 AuEnvMixer* envMixer = &pvoice->envMixer;
361 AuResampler* resampler = &pvoice->resampler;
362
363 pvoice->busID = busID;
364 decoder->instrument = instrument;
365
366 pvoice->decoder.memin = (s32)decoder->instrument->wavData;
367 pvoice->decoder.sample = 0;
368
369 switch (decoder->instrument->type) {
370 case AL_ADPCM_WAVE:
371 decoder->instrument->wavDataLength = (decoder->instrument->wavDataLength / ADPCMFBYTES) * ADPCMFBYTES;
372 pvoice->decoder.bookSize = decoder->instrument->codebookSize;
373 if (decoder->instrument->loopEnd != 0) {
374 decoder->loop.start = decoder->instrument->loopStart;
375 decoder->loop.end = decoder->instrument->loopEnd;
376 decoder->loop.count = decoder->instrument->loopCount;
377 alCopy(decoder->instrument->loopState, decoder->lstate, sizeof(ADPCM_STATE));
378 } else {
379 decoder->loop.count = 0;
380 decoder->loop.end = 0;
381 decoder->loop.start = 0;
382 }
383 break;
384 case AL_RAW16_WAVE:
385 if (decoder->instrument->loopEnd != 0) {
386 decoder->loop.start = decoder->instrument->loopStart;
387 decoder->loop.end = decoder->instrument->loopEnd;
388 decoder->loop.count = decoder->instrument->loopCount;
389 } else {
390 decoder->loop.count = 0;
391 decoder->loop.end = 0;
392 decoder->loop.start = 0;
393 }
394 break;
395 }
396
397 envMixer->motion = AL_PLAYING;
398 envMixer->dirty = TRUE;
399 envMixer->delta = 0;
400 envMixer->segEnd = delta;
401 envMixer->pan = pan;
402 envMixer->volume = SQ(vol) >> 0xF;
403 envMixer->dryamt = AuEqPower[fxMix];
404 envMixer->wetamt = AuEqPower[AU_EQPOW_MAX_IDX - fxMix];
405 if (envMixer->segEnd != 0) {
406 envMixer->cvolL = 1;
407 envMixer->cvolR = 1;
408 } else {
409 if (!AuSynUseStereo) {
410 envMixer->cvolL = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
411 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
412 } else {
413 envMixer->cvolL = (envMixer->volume * AuEqPower[envMixer->pan]) >> 0xF;
414 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->pan]) >> 0xF;
415 }
416 }
417 resampler->ratio = pitchRatio;
418}
#define ADPCMFBYTES
Definition audio.h:57
#define SQ(x)
Definition macros.h:178
#define AU_EQPOW_MID_IDX
Definition syn_driver.c:22
#define AU_EQPOW_MAX_IDX
Definition syn_driver.c:23
void alCopy(void *src, void *dst, s32 size)
Definition syn_driver.c:777
s16 AuEqPower[128]
Definition pull_voice.c:10

Referenced by au_syn_begin_audio_frame().

◆ au_syn_set_wavetable()

void au_syn_set_wavetable ( u8 voiceIdx,
Instrument * instrument )

Definition at line 420 of file syn_driver.c.

420 {
422 AuLoadFilter* decoder = &pvoice->decoder;
423
424 pvoice->decoder.instrument = instrument;
425 pvoice->decoder.memin = (s32)decoder->instrument->wavData;
426 pvoice->decoder.sample = 0;
427
428 switch (decoder->instrument->type) {
429 case AL_ADPCM_WAVE:
430 decoder->instrument->wavDataLength = (decoder->instrument->wavDataLength / ADPCMFBYTES) * ADPCMFBYTES;
431 pvoice->decoder.bookSize = decoder->instrument->codebookSize;
432 if (decoder->instrument->loopEnd != 0) {
433 pvoice->decoder.loop.start = decoder->instrument->loopStart;
434 pvoice->decoder.loop.end = decoder->instrument->loopEnd;
435 pvoice->decoder.loop.count = decoder->instrument->loopCount;
436 alCopy(decoder->instrument->loopState, pvoice->decoder.lstate, sizeof(ADPCM_STATE));
437 } else {
438 pvoice->decoder.loop.count = 0;
439 pvoice->decoder.loop.end = 0;
440 pvoice->decoder.loop.start = 0;
441 }
442 break;
443 case AL_RAW16_WAVE:
444 if (decoder->instrument->loopEnd != 0) {
445 pvoice->decoder.loop.start = decoder->instrument->loopStart;
446 pvoice->decoder.loop.end = decoder->instrument->loopEnd;
447 pvoice->decoder.loop.count = decoder->instrument->loopCount;
448 } else {
449 pvoice->decoder.loop.count = 0;
450 pvoice->decoder.loop.end = 0;
451 pvoice->decoder.loop.start = 0;
452 }
453 break;
454 }
455}

Referenced by au_engine_init().

◆ au_syn_set_pitch()

void au_syn_set_pitch ( u8 voiceIdx,
f32 pitch )

Definition at line 458 of file syn_driver.c.

458 {
460
461 pvoice->resampler.ratio = pitch;
462}
f32 ratio
Definition audio.h:594
AuResampler resampler
Definition audio.h:624

Referenced by au_syn_begin_audio_frame().

◆ au_syn_set_mixer_params()

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

Definition at line 464 of file syn_driver.c.

464 {
466 AuEnvMixer* envMixer = &pvoice->envMixer;
467
468 if (envMixer->delta >= envMixer->segEnd) {
469 envMixer->delta = envMixer->segEnd;
470 if (!AuSynUseStereo) {
471 envMixer->cvolL = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
472 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
473 } else {
474 envMixer->cvolL = (envMixer->volume * AuEqPower[envMixer->pan]) >> 0xF;
475 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->pan]) >> 0xF;
476 }
477 } else {
478 envMixer->cvolL = _getVol(envMixer->cvolL, envMixer->delta, envMixer->lratm, envMixer->lratl);
479 envMixer->cvolR = _getVol(envMixer->cvolR, envMixer->delta, envMixer->rratm, envMixer->rratl);
480 }
481 if (envMixer->cvolL == 0) {
482 envMixer->cvolL = 1;
483 }
484 if (envMixer->cvolR == 0) {
485 envMixer->cvolR = 1;
486 }
487
488 envMixer->delta = 0;
489 envMixer->segEnd = delta;
490 envMixer->pan = pan;
491 envMixer->volume = SQ(volume) >> 0xF;
492 envMixer->dryamt = AuEqPower[fxMix];
493 envMixer->wetamt = AuEqPower[AU_EQPOW_MAX_IDX - fxMix];
494 envMixer->dirty = TRUE;
495}
s16 dryamt
Definition audio.h:606
s16 wetamt
Definition audio.h:607
s32 segEnd
Definition audio.h:615
s16 cvolR
Definition audio.h:605
s16 lratm
Definition audio.h:609
s16 rratm
Definition audio.h:612
s16 volume
Definition audio.h:603
s16 pan
Definition audio.h:602
s32 delta
Definition audio.h:614
s16 cvolL
Definition audio.h:604
s16 rratl
Definition audio.h:611
s16 lratl
Definition audio.h:608
b32 dirty
Definition audio.h:616

Referenced by au_syn_begin_audio_frame().

◆ au_syn_set_pan_fxmix()

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

Definition at line 497 of file syn_driver.c.

497 {
499 AuEnvMixer* envMixer = &pvoice->envMixer;
500
501 if (envMixer->delta >= envMixer->segEnd) {
502 envMixer->delta = envMixer->segEnd;
503 if (!AuSynUseStereo) {
504 envMixer->cvolL = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
505 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
506 } else {
507 envMixer->cvolL = (envMixer->volume * AuEqPower[envMixer->pan]) >> 0xF;
508 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->pan]) >> 0xF;
509 }
510 } else {
511 envMixer->cvolL = _getVol(envMixer->cvolL, envMixer->delta, envMixer->lratm, envMixer->lratl);
512 envMixer->cvolR = _getVol(envMixer->cvolR, envMixer->delta, envMixer->rratm, envMixer->rratl);
513 }
514 if (envMixer->cvolL == 0) {
515 envMixer->cvolL = 1;
516 }
517 if (envMixer->cvolR == 0) {
518 envMixer->cvolR = 1;
519 }
520
521 envMixer->pan = pan;
522 envMixer->dryamt = AuEqPower[fxMix];
523 envMixer->wetamt = AuEqPower[AU_EQPOW_MAX_IDX - fxMix];
524 envMixer->dirty = TRUE;
525}

Referenced by au_syn_begin_audio_frame().

◆ au_syn_set_volume_delta()

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

Definition at line 527 of file syn_driver.c.

527 {
529 AuEnvMixer* envMixer = &pvoice->envMixer;
530
531 if (envMixer->delta >= envMixer->segEnd) {
532 envMixer->delta = envMixer->segEnd;
533 if (!AuSynUseStereo) {
534 envMixer->cvolL = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
535 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
536 } else {
537 envMixer->cvolL = (envMixer->volume * AuEqPower[envMixer->pan]) >> 0xF;
538 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->pan]) >> 0xF;
539 }
540 } else {
541 envMixer->cvolL = _getVol(envMixer->cvolL, envMixer->delta, envMixer->lratm, envMixer->lratl);
542 envMixer->cvolR = _getVol(envMixer->cvolR, envMixer->delta, envMixer->rratm, envMixer->rratl);
543 }
544 if (envMixer->cvolL == 0) {
545 envMixer->cvolL = 1;
546 }
547 if (envMixer->cvolR == 0) {
548 envMixer->cvolR = 1;
549 }
550
551 envMixer->volume = SQ(vol) >> 0xF;
552 envMixer->delta = 0;
553 envMixer->segEnd = delta;
554 envMixer->dirty = TRUE;
555}

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 557 of file syn_driver.c.

557 {
559 AuEnvMixer* envMixer = &pvoice->envMixer;
560
561 if (envMixer->delta >= envMixer->segEnd) {
562 envMixer->delta = envMixer->segEnd;
563 if (!AuSynUseStereo) {
564 envMixer->cvolL = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
565 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
566 } else {
567 envMixer->cvolL = (envMixer->volume * AuEqPower[envMixer->pan]) >> 0xF;
568 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->pan]) >> 0xF;
569 }
570 } else {
571 envMixer->cvolL = _getVol(envMixer->cvolL, envMixer->delta, envMixer->lratm, envMixer->lratl);
572 envMixer->cvolR = _getVol(envMixer->cvolR, envMixer->delta, envMixer->rratm, envMixer->rratl);
573 }
574 if (envMixer->cvolL == 0) {
575 envMixer->cvolL = 1;
576 }
577 if (envMixer->cvolR == 0) {
578 envMixer->cvolR = 1;
579 }
580
581 envMixer->pan = pan;
582 envMixer->dirty = TRUE;
583}

Referenced by alAudioFrame().

◆ au_syn_set_fxmix()

void au_syn_set_fxmix ( u8 voiceIdx,
u8 fxMix )

Definition at line 585 of file syn_driver.c.

585 {
587 AuEnvMixer* envMixer = &pvoice->envMixer;
588
589 if (envMixer->delta >= envMixer->segEnd) {
590 envMixer->delta = envMixer->segEnd;
591 if (!AuSynUseStereo) {
592 envMixer->cvolL = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
593 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
594 } else {
595 envMixer->cvolL = (envMixer->volume * AuEqPower[envMixer->pan]) >> 0xF;
596 envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->pan]) >> 0xF;
597 }
598 } else {
599 envMixer->cvolL = _getVol(envMixer->cvolL, envMixer->delta, envMixer->lratm, envMixer->lratl);
600 envMixer->cvolR = _getVol(envMixer->cvolR, envMixer->delta, envMixer->rratm, envMixer->rratl);
601 }
602 if (envMixer->cvolL == 0) {
603 envMixer->cvolL = 1;
604 }
605 if (envMixer->cvolR == 0) {
606 envMixer->cvolR = 1;
607 }
608
609 envMixer->dryamt = AuEqPower[fxMix];
610 envMixer->wetamt = AuEqPower[AU_EQPOW_MAX_IDX - fxMix];
611 envMixer->dirty = TRUE;
612}

◆ au_syn_get_playing()

s32 au_syn_get_playing ( u8 voiceIdx)

Definition at line 614 of file syn_driver.c.

614 {
616
617 return pvoice->envMixer.motion;
618}
s32 motion
Definition audio.h:617
AuEnvMixer envMixer
Definition audio.h:625

◆ au_syn_get_bus()

s32 au_syn_get_bus ( u8 voiceIdx)

Definition at line 620 of file syn_driver.c.

620 {
622
623 return pvoice->busID;
624}

◆ au_syn_get_pitch()

f32 au_syn_get_pitch ( u8 voiceIdx)

Definition at line 626 of file syn_driver.c.

626 {
628
629 return pvoice->resampler.ratio;
630}

◆ au_syn_get_pan()

u8 au_syn_get_pan ( u8 voiceIdx)

Definition at line 632 of file syn_driver.c.

632 {
634
635 return pvoice->envMixer.pan;
636}

◆ au_syn_get_dryamt()

s16 au_syn_get_dryamt ( u8 voiceIdx)

Definition at line 638 of file syn_driver.c.

638 {
640
641 return pvoice->envMixer.dryamt;
642}

◆ au_syn_get_wetamt()

s16 au_syn_get_wetamt ( u8 voiceIdx)

Definition at line 644 of file syn_driver.c.

644 {
646
647 return pvoice->envMixer.wetamt;
648}

◆ au_syn_get_volume_left()

s32 au_syn_get_volume_left ( u8 voiceIdx)

Definition at line 650 of file syn_driver.c.

650 {
652 AuEnvMixer* envmixer = &pvoice->envMixer;
653 u32 retVal;
654
655 if (envmixer->delta >= envmixer->segEnd) {
656 if (!AuSynUseStereo) {
657 retVal = (envmixer->volume * AuEqPower[AU_EQPOW_MID_IDX] * 2) >> 0x10;
658 } else {
659 retVal = (envmixer->volume * AuEqPower[envmixer->pan] * 2) >> 0x10;
660 }
661 } else {
662 retVal = _getVol(envmixer->cvolL, envmixer->delta, envmixer->lratm, envmixer->lratl);
663 }
664 return retVal;
665}

◆ au_syn_get_volume_right()

s32 au_syn_get_volume_right ( u8 voiceIdx)

Definition at line 667 of file syn_driver.c.

667 {
669 AuEnvMixer* envmixer = &pvoice->envMixer;
670 u32 retVal;
671
672 if (envmixer->delta >= envmixer->segEnd) {
673 if (!AuSynUseStereo) {
674 retVal = (envmixer->volume * AuEqPower[AU_EQPOW_MID_IDX] * 2) >> 0x10;
675 } else {
676 retVal = (envmixer->volume * AuEqPower[AU_EQPOW_MAX_IDX - envmixer->pan] * 2) >> 0x10;
677 }
678 } else {
679 retVal = _getVol(envmixer->cvolL, envmixer->delta, envmixer->lratm, envmixer->lratl);
680 }
681 return retVal;
682}

◆ au_set_delay_time()

void au_set_delay_time ( s32 numFrames)

Definition at line 684 of file syn_driver.c.

684 {
685 if (numFrames < 2) {
686 AuDelayCount = 0;
688 }
689
691 if (numFrames > 4) {
692 AuDelayCount = 4;
693 }
694}

Referenced by au_syn_begin_audio_frame().

◆ au_delay_left_channel()

void au_delay_left_channel ( u8 busID)

Definition at line 696 of file syn_driver.c.

696 {
699 s32 i;
700
701 for (i = 0; i < 2 * AUDIO_SAMPLES; i++) {
702 *mainBuf++ = 0;
703 *auxBuf++ = 0;
704 }
705
706 AuDelayedBusID = busID;
708 AuDelayCounter = 0;
709}

Referenced by au_syn_begin_audio_frame().

◆ au_delay_right_channel()

void au_delay_right_channel ( u8 busID)

Definition at line 711 of file syn_driver.c.

711 {
714 s32 i;
715
716 for (i = 0; i < 2 * AUDIO_SAMPLES; i++) {
717 *mainBuf++ = 0;
718 *auxBuf++ = 0;
719 }
720
721 AuDelayedBusID = busID;
723 AuDelayCounter = 0;
724}

Referenced by au_syn_begin_audio_frame().

◆ au_disable_channel_delay()

void au_disable_channel_delay ( void )

Definition at line 726 of file syn_driver.c.

Referenced by au_syn_begin_audio_frame().

◆ au_init_delay_channel()

void au_init_delay_channel ( s16 channel)

Definition at line 732 of file syn_driver.c.

732 {
735 s32 i;
736
737 for (i = 0; i < 2 * AUDIO_SAMPLES; i++) {
738 *mainBuf++ = 0;
739 *auxBuf++ = 0;
740 }
741
742 AuDelayedBusID = 0;
744 AuDelayCounter = 0;
745}

Referenced by au_engine_init().

◆ alHeapInit()

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

Definition at line 747 of file syn_driver.c.

747 {
748 u32 i;
749 s32 alignBytes = 0x10 - ((s32)base & 0xF);
750
751 if (alignBytes != 0x10) {
752 hp->base = base + alignBytes;
753 } else {
754 hp->base = base;
755 }
756 hp->len = len;
757 hp->count = 0;
758 hp->cur = hp->base;
759
760 for (i = 0; i < (u32)(hp->len) >> 2; i++) {
761 ((u32*)hp->base)[i] = 0;
762 }
763}

Referenced by create_audio_system().

◆ alHeapAlloc()

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

Definition at line 765 of file syn_driver.c.

765 {
766 void* ret = NULL;
767 u8* newCur = &heap->cur[ALIGN16(count * size)];
768
769 if (&heap->base[heap->len] >= newCur) {
770 ret = heap->cur;
771 heap->cur = newCur;
772 }
773
774 return ret;
775}
#define ALIGN16(val)
Definition macros.h:20

Referenced by au_driver_init(), au_engine_init(), au_filter_create(), au_fx_create(), au_load_BK_to_bank(), au_load_INIT(), au_load_static_BK_to_bank(), and create_audio_system().

◆ alCopy()

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

Definition at line 777 of file syn_driver.c.

777 {
778 s32 i;
779 u8* srcIt = src;
780 u8* dstIt = dst;
781
782 for (i = 0; i < size; i++) {
783 *dstIt++ = *srcIt++;
784 }
785}

Referenced by au_syn_set_wavetable(), and au_syn_start_voice_params().

Variable Documentation

◆ AuDelayBufferMain

BSS s16* AuDelayBufferMain

◆ AuDelayBufferAux

◆ AuDelayCounter

◆ AuDelayedBusID

◆ AuDelayedChannel

◆ AuDelayCount

BSS s32 AuDelayCount

Definition at line 12 of file syn_driver.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 syn_driver.c.

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

◆ AuGlobalVolume

u16 AuGlobalVolume = AU_MAX_VOLUME_16

◆ AuSynStereoDirty

u8 AuSynStereoDirty = FALSE

Definition at line 18 of file syn_driver.c.

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

◆ AuEqPower

s16 AuEqPower[128]
extern

Definition at line 10 of file pull_voice.c.

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

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().