From 764705b67c1129028c58bc39644e1ddc5d93342e Mon Sep 17 00:00:00 2001 From: Unnunu Date: Tue, 6 May 2025 16:47:08 +0300 Subject: [PATCH] match and document audio_spatial.c (#555) * match func_80004668 and adjust types * match _handleEvent * documentation WIP * wip * document audiosfx.c * fix build * a few type renames * update score * remove comment * fix type * wip * match func_80008438 * update score * documentation almost done * documented audio_spatial.c * update score * format and update score * remove duplicated lines * PR suggestions --- README.md | 50 +- include/macros.h | 3 +- include/structs.h | 29 +- src/audio.c | 28 +- src/audio.h | 17 +- src/audio_spatial.c | 1153 +++++++++++++------------- src/audio_spatial.h | 113 +-- src/audio_vehicle.c | 39 +- src/audiosfx.h | 21 +- src/game.c | 2 +- src/game_ui.c | 9 +- src/menu.c | 8 +- src/object_functions.c | 187 +++-- src/objects.c | 10 +- src/objects.h | 2 +- src/racer.c | 73 +- src/thread3_main.c | 2 +- src/vehicle_smokey.c | 10 +- src/vehicle_tricky.c | 2 +- src/weather.c | 8 +- ver/symbols/symbol_addrs.jpn.v79.txt | 58 +- ver/symbols/symbol_addrs.pal.v77.txt | 58 +- ver/symbols/symbol_addrs.pal.v80.txt | 58 +- ver/symbols/symbol_addrs.us.v77.txt | 58 +- ver/symbols/symbol_addrs.us.v80.txt | 58 +- 25 files changed, 1034 insertions(+), 1022 deletions(-) diff --git a/README.md b/README.md index 18205f7a..f42ce40b 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ All versions are supported, and the US 1.0 version (SHA1 = 0cb115d8716dbbc2922fd As of May 6, 2025, this is our current score: -    Decomp progress: 85.28% +    Decomp progress: 85.64% -    Documentation progress: 54.50% +    Documentation progress: 55.54% --- @@ -119,28 +119,28 @@ s32 is_drumstick_unlocked(void) { As of May 6, 2025, this is our current score: ``` - ======================================================== - ADVENTURE ONE (ASM -> C Decompilation) - -------- 85.28% Complete (86.44% NON_MATCHING) --------- - # Decompiled functions: 1881 - # GLOBAL_ASM remaining: 70 - # NON_MATCHING functions: 7 - # NON_EQUIVALENT WIP functions: 26 - --------------------- Game Status ---------------------- - Balloons: 39/47, Keys: 4/4, Trophies: 4/5 - T.T. Amulets: 4/4, Wizpig Amulets: 4/4 - -------------------------------------------------------- - We are racing in Spacedust Alley. (Lap 1/3) - ======================================================== - ADVENTURE TWO (Cleanup & Documentation) - ------------------- 54.50% Complete -------------------- - # Documented functions: 1155 - # Undocumented remaining: 499 - --------------------- Game Status ---------------------- - Balloons: 26/47, Keys: 3/4, Trophies: 2/5 - T.T. Amulets: 2/4, Wizpig Amulets: 2/4 - -------------------------------------------------------- - We are battling in Darkwater Beach. (1 opponent remains) - ======================================================== + =============================================================== + ADVENTURE ONE (ASM -> C Decompilation) + ------------ 85.64% Complete (86.80% NON_MATCHING) ------------ + # Decompiled functions: 1882 + # GLOBAL_ASM remaining: 69 + # NON_MATCHING functions: 7 + # NON_EQUIVALENT WIP functions: 25 + ------------------------- Game Status ------------------------- + Balloons: 39/47, Keys: 4/4, Trophies: 4/5 + T.T. Amulets: 4/4, Wizpig Amulets: 4/4 + --------------------------------------------------------------- + We are racing in Spacedust Alley. (Lap 2/3) + =============================================================== + ADVENTURE TWO (Cleanup & Documentation) + ----------------------- 55.54% Complete ----------------------- + # Documented functions: 1170 + # Undocumented remaining: 484 + ------------------------- Game Status ------------------------- + Balloons: 26/47, Keys: 3/4, Trophies: 2/5 + T.T. Amulets: 3/4, Wizpig Amulets: 2/4 + --------------------------------------------------------------- + We are collecting silver coins in Whale Bay. (5/8 silver coins) + =============================================================== ``` diff --git a/include/macros.h b/include/macros.h index 30e374e5..061f7106 100644 --- a/include/macros.h +++ b/include/macros.h @@ -58,9 +58,10 @@ #else #define inline #define ABSF(x) (x < 0.f ? -x : x) -#define ABS(x) ((x) >= 0 ? (x) : -(x)) #endif +#define ABS2(x) ((x) >= 0 ? (x) : -(x)) + // convert a virtual address to physical. #define VIRTUAL_TO_PHYSICAL(addr) ((uintptr_t)(addr) & 0x1FFFFFFF) diff --git a/include/structs.h b/include/structs.h index 3589b523..e4196c9e 100644 --- a/include/structs.h +++ b/include/structs.h @@ -100,23 +100,6 @@ typedef struct Vec2i { }; } Vec2i; -/* Size: 0x24 / 36 bytes */ -typedef struct SoundMask { - /* 0x00 */ Vec3f pos; - /* 0x0C */ u16 soundId; - /* 0x0E */ u8 volume; - /* 0x0F */ u8 pitch; - /* 0x10 */ u8 unk10; - /* 0x11 */ u8 unk11; - /* 0x12 */ u8 unk12; - /* 0x14 */ s32 distance; - /* 0x18 */ SoundHandle soundPtr; - /* 0x1C */ struct SoundMask **soundMask; - /* 0x20 */ u8 unk20; - /* 0x21 */ u8 unk21; - /* 0x22 */ u8 unk22; -} SoundMask; - /* Size: 0x20 bytes */ typedef struct TextureHeader { /* 0x00 */ u8 width; @@ -1231,7 +1214,7 @@ typedef struct Object_Racer { /* 0x018 */ SoundHandle unk18; /* 0x01C */ SoundHandle unk1C; /* 0x020 */ SoundHandle unk20; - /* 0x024 */ SoundMask *soundMask; + /* 0x024 */ struct AudioPoint *soundMask; /* 0x028 */ u16 lastSoundID; /* 0x02A */ u16 unk2A; /* 0x02C */ f32 velocity; @@ -1314,8 +1297,8 @@ typedef struct Object_Racer { /* 0x175 */ s8 magnetTimer; /* 0x176 */ s16 unk176; /* 0x178 */ SoundHandle magnetSoundMask; - /* 0x17C */ SoundMask *shieldSoundMask; - /* 0x180 */ SoundMask *bananaSoundMask; + /* 0x17C */ struct AudioPoint *shieldSoundMask; + /* 0x180 */ struct AudioPoint *bananaSoundMask; /* 0x184 */ s8 magnetModelID; /* 0x185 */ s8 bananas; /* 0x186 */ u8 unk186; @@ -1435,7 +1418,7 @@ typedef struct Object_Racer { typedef struct Object_Door { /* 0x00 */ f32 homeY; - /* 0x04 */ SoundHandle soundMask; + /* 0x04 */ struct AudioPoint* soundMask; /* 0x08 */ s32 jingleTimer; /* 0x0A */ s16 jingleCooldown; /* 0x0E */ s8 doorID; @@ -1467,7 +1450,7 @@ typedef struct Object_Audio { /* 0x05 */ u8 unk5; /* 0x06 */ u8 unk6; /* 0x07 */ u8 unk7; - /* 0x08 */ SoundMask *soundMask; + /* 0x08 */ struct AudioPoint *soundMask; /* 0x0C */ u8 unkC; /* 0x0D */ u8 unkD; } Object_Audio; @@ -1552,7 +1535,7 @@ typedef struct Object_TT { typedef struct Object_Bridge_WhaleRamp { /* 0x0 */ f32 homeY; - /* 0x4 */ SoundHandle soundMask; + /* 0x4 */ struct AudioPoint *soundMask; } Object_Bridge_WhaleRamp; typedef struct Object_64_80021400 { diff --git a/src/audio.c b/src/audio.c index 6a9eaa0c..ee444a6a 100644 --- a/src/audio.c +++ b/src/audio.c @@ -787,7 +787,7 @@ u16 sound_distance(u16 soundId) { if (soundId > gSoundCount) { return 0; } - return gSoundTable[soundId].distance; + return gSoundTable[soundId].range; } /** @@ -814,14 +814,14 @@ void sound_play(u16 soundID, SoundHandle *handlePtr) { } pitch = gSoundTable[soundID].pitch / 100.0f; if (handlePtr != NULL) { - sndp_play_with_priority(gSoundBank->bankArray[0], soundBite, gSoundTable[soundID].unk8, handlePtr); + sndp_play_with_priority(gSoundBank->bankArray[0], soundBite, gSoundTable[soundID].priority, handlePtr); if (*handlePtr != NULL) { sndp_set_param(*handlePtr, AL_SNDP_VOL_EVT, gSoundTable[soundID].volume * 256); sndp_set_param(*handlePtr, AL_SNDP_PITCH_EVT, *((u32 *) &pitch)); } } else { handlePtr = &gGlobalSoundMask; - sndp_play_with_priority(gSoundBank->bankArray[0], soundBite, gSoundTable[soundID].unk8, &gGlobalSoundMask); + sndp_play_with_priority(gSoundBank->bankArray[0], soundBite, gSoundTable[soundID].priority, &gGlobalSoundMask); if (*handlePtr != NULL) { sndp_set_param(*handlePtr, AL_SNDP_VOL_EVT, gSoundTable[soundID].volume * 256); sndp_set_param(*handlePtr, AL_SNDP_PITCH_EVT, *((u32 *) &pitch)); @@ -834,28 +834,28 @@ void sound_play(u16 soundID, SoundHandle *handlePtr) { * This then makes the audio pan around in 3D space. * If it is not given a mask, then it will use the global mask. */ -void sound_play_spatial(u16 soundID, f32 x, f32 y, f32 z, SoundHandle *soundMask) { - if (soundMask == NULL) { - soundMask = (s32 **) &gSpatialSoundMask; +void sound_play_spatial(u16 soundID, f32 x, f32 y, f32 z, SoundHandle *handlePtr) { + if (handlePtr == NULL) { + handlePtr = &gSpatialSoundMask; } - sound_play(soundID, (s32 *) soundMask); + sound_play(soundID, handlePtr); - if (*soundMask != NULL) { - audioline_reverb(*soundMask, x, y, z); + if (*handlePtr != NULL) { + audspat_calculate_echo(*handlePtr, x, y, z); } } -void func_80001F14(u16 soundID, s32 *soundMask) { +void func_80001F14(u16 soundID, SoundHandle *handlePtr) { if (soundID <= 0 || sound_count() < soundID) { stubbed_printf("amSndPlayDirect: Somebody tried to play illegal sound %d\n", soundID); - if (soundMask) { - *soundMask = NULL; + if (handlePtr) { + *handlePtr = NULL; } return; } - if (soundMask) { - sndp_play(gSoundBank->bankArray[0], (s16) soundID, soundMask); + if (handlePtr) { + sndp_play(gSoundBank->bankArray[0], (s16) soundID, handlePtr); } else { sndp_play(gSoundBank->bankArray[0], (s16) soundID, &gRacerSoundMask); } diff --git a/src/audio.h b/src/audio.h index de3fa7ca..9e56df4c 100644 --- a/src/audio.h +++ b/src/audio.h @@ -20,11 +20,11 @@ typedef struct ALSoundState* SoundHandle; typedef struct SoundData { u16 soundBite; // Audio file index. u8 volume; // Multiplied by 256. 128 = 32768, max volume. - u8 unk3; + u8 minVolume; u8 pitch; // Fractional. 100 = 1.0f. u8 unk5; - u16 distance; // Ingame units distance, same as any other. - u8 unk8; + u16 range; // Ingame units distance, same as any other. + u8 priority; u8 unk9; } SoundData; @@ -40,7 +40,7 @@ typedef struct MusicData { typedef struct DelayedSound { /* 0x00 */ u16 soundId; /* 0x02 */ s16 timer; - /* 0x04 */ SoundHandle handlePtr; + /* 0x04 */ SoundHandle *handlePtr; } DelayedSound; void alCSPNew(ALCSPlayer *seqp, ALSeqpConfig *config); //lib/src/al/csplayer.c @@ -74,7 +74,7 @@ void music_jingle_voicelimit_set(u8 voiceLimit); void music_fade(s32 time); void music_volume_reset(void); void sound_update_queue(u8 updateRate); -void sound_play_delayed(u16 soundId, SoundHandle *handlePtr, f32 delayTime); +void sound_play_delayed(u16 soundId, SoundHandle *soundMask, f32 delayTime); void sound_clear_delayed(void); u16 music_channel_get_mask(void); void music_dynamic_set(u16 channelMask); @@ -106,8 +106,8 @@ void music_jingle_pan_set(ALPan pan); void music_jingle_play(u8 seqID); u32 music_jingle_playing(void); u16 sound_distance(u16 soundId); -void sound_play_spatial(u16 soundID, f32 x, f32 y, f32 z, SoundHandle*soundMask); -void func_80001F14(u16 soundID, s32 *soundMask); +void sound_play_spatial(u16 soundID, f32 x, f32 y, f32 z, SoundHandle *soundMask); +void func_80001F14(u16 soundID, SoundHandle *handlePtr); u16 sound_count(void); u8 music_sequence_count(void); void sound_table_properties(SoundData **table, s32 *size, s32 *count); @@ -118,9 +118,10 @@ void music_sequence_stop(ALCSPlayer *seqPlayer); void sound_reverb_set(u8 setting); void alSeqFileNew(ALSeqFile *file, u8 *base); void func_80063A90(ALCSPlayer *seqp, u8 channel); -void sound_volume_set_relative(u16 soundID, SoundHandle soundHandle, u8 volume); +void sound_volume_set_relative(u16 soundID, SoundHandle soundState, u8 volume); void music_sequence_init(ALCSPlayer *seqp, void *sequence, u8 *seqID, ALCSeq *seq); void sound_play(u16 soundID, SoundHandle* handlePtr); +void sound_play(u16 soundID, SoundHandle* handlePtr); f32 music_animation_fraction(void); #endif diff --git a/src/audio_spatial.c b/src/audio_spatial.c index 26fe76ea..a19f2906 100644 --- a/src/audio_spatial.c +++ b/src/audio_spatial.c @@ -10,9 +10,14 @@ #include "tracks.h" #include "math_util.h" +#define MAX_AUDIO_POINTS 40 +#define MAX_AUDIO_LINES 7 +#define MAX_REVERB_LINES 7 +#define MIN_VOLUME_THRESHOLD 10 + /************ .data ************/ -u16 gUsedMasks = 0; +u16 gNumAudioPoints = 0; /*******************************/ @@ -33,484 +38,427 @@ UNUSED const char D_800E4EDC[] = "Reverb line definition error (line=%d, vertex= /************ .bss ************/ -SoundData *D_80119C40; -SoundMask **gSoundMaskHeapUsed; -SoundMask *gSoundMaskHeap; // 0x24 struct size - 0x5A0 total size - should be 40 elements -u8 gFreeMasks; -SoundMask **gSoundMaskHeapFree; -unk80119C58 D_80119C58[7]; -unk8011A6D8 D_8011A6D8[7]; // Reverb stuff -u8 gAudioLinesOff; +SoundData *gSpatialSoundTable; +AudioPoint **gAudioPoints; +AudioPoint *gAudioPointsPool; // 0x24 struct size - 0x5A0 total size - should be 40 elements +u8 gLastFreePointIndex; +AudioPoint **gFreeAudioPoints; +AudioLine gAudioLines[MAX_AUDIO_LINES]; +ReverbLine gReverbLines[MAX_REVERB_LINES]; // Reverb stuff +u8 gJinglesOff; s32 D_8011AC1C; -#define SOUND_MASK_HEAP_COUNT 40 - /*******************************/ -void audioline_init(void) { +/** + * Initializes the audio spatial system. + */ +void audspat_init(void) { s32 i; - sound_table_properties(&D_80119C40, NULL, NULL); - gSoundMaskHeap = mempool_alloc_safe(sizeof(SoundMask) * SOUND_MASK_HEAP_COUNT, COLOUR_TAG_CYAN); - gSoundMaskHeapFree = mempool_alloc_safe(sizeof(uintptr_t) * SOUND_MASK_HEAP_COUNT, COLOUR_TAG_CYAN); - gSoundMaskHeapUsed = mempool_alloc_safe(sizeof(uintptr_t) * SOUND_MASK_HEAP_COUNT, COLOUR_TAG_CYAN); - gUsedMasks = 0; - for (i = 0; i < ARRAY_COUNT(D_80119C58); i++) { - D_80119C58[i].soundPtr = NULL; + sound_table_properties(&gSpatialSoundTable, NULL, NULL); + gAudioPointsPool = mempool_alloc_safe(sizeof(AudioPoint) * MAX_AUDIO_POINTS, COLOUR_TAG_CYAN); + gFreeAudioPoints = mempool_alloc_safe(sizeof(uintptr_t) * MAX_AUDIO_POINTS, COLOUR_TAG_CYAN); + gAudioPoints = mempool_alloc_safe(sizeof(uintptr_t) * MAX_AUDIO_POINTS, COLOUR_TAG_CYAN); + gNumAudioPoints = 0; + for (i = 0; i < ARRAY_COUNT(gAudioLines); i++) { + gAudioLines[i].soundHandle = NULL; } - for (i = 0; i < SOUND_MASK_HEAP_COUNT; i++) { - gSoundMaskHeap[i].soundPtr = NULL; + for (i = 0; i < MAX_AUDIO_POINTS; i++) { + gAudioPointsPool[i].soundHandle = NULL; } - audioline_reset(); + audspat_reset(); } /** * Stop any playing jingles, then block audio lines from playing anymore. + * Does not stop audio lines that are playing sounds of type AUDIO_LINE_TYPE_SOUND. * Official Name: amAmbientPause */ -void audioline_off(void) { +void audspat_jingle_off(void) { music_jingle_stop(); - gAudioLinesOff = TRUE; + gJinglesOff = TRUE; } /** * Allow audio lines to play jingles. * Official Name: amAmbientRestart */ -void audioline_on(void) { - gAudioLinesOff = FALSE; +void audspat_jingle_on(void) { + gJinglesOff = FALSE; } -void audioline_reset(void) { +/** + * Stops all sounds and deletes all created audio points and lines. + */ +void audspat_reset(void) { s32 i; s32 j; SoundHandle sound; - SoundMask *heap; - f32 *ptr; + AudioPoint *audioPoint; + f32 *coords; - heap = gSoundMaskHeap; - gFreeMasks = 0; - while (gFreeMasks < SOUND_MASK_HEAP_COUNT) { - gSoundMaskHeapFree[gFreeMasks] = heap; - heap++; - gFreeMasks++; + audioPoint = gAudioPointsPool; + gLastFreePointIndex = 0; + while (gLastFreePointIndex < MAX_AUDIO_POINTS) { + gFreeAudioPoints[gLastFreePointIndex] = audioPoint; + audioPoint++; + gLastFreePointIndex++; } - gFreeMasks--; + gLastFreePointIndex--; - for (i = 0; i < gUsedMasks; i++) { - sound = gSoundMaskHeapUsed[i]->soundPtr; - gSoundMaskHeapUsed[i]->unk12 = 0; + for (i = 0; i < gNumAudioPoints; i++) { + sound = gAudioPoints[i]->soundHandle; + gAudioPoints[i]->inRange = FALSE; if (sound != NULL) { sndp_stop(sound); } } - gUsedMasks = 0; + gNumAudioPoints = 0; - for (i = 0; i < 7; i++) { - D_80119C58[i].soundID = 0; - if (D_80119C58[i].soundPtr != 0) { - if (D_80119C58[i].unk0_02 == 0) { - sndp_stop(D_80119C58[i].soundPtr); - } else if (D_80119C58[i].unk0_02 == 1) { + for (i = 0; i < MAX_AUDIO_LINES; i++) { + gAudioLines[i].soundBite = 0; + if (gAudioLines[i].soundHandle != 0) { + if (gAudioLines[i].type == AUDIO_LINE_TYPE_SOUND) { + sndp_stop(gAudioLines[i].soundHandle); + } else if (gAudioLines[i].type == AUDIO_LINE_TYPE_JINGLE) { music_jingle_stop(); } - D_80119C58[i].soundPtr = NULL; + gAudioLines[i].soundHandle = NULL; } - D_80119C58[i].unk17C = -1; + gAudioLines[i].numSegments = -1; - ptr = D_80119C58[i].unk4_floats; + coords = gAudioLines[i].coords; for (j = 0; j < 30; j++) { - *ptr++ = -100000.0f; - *ptr++ = -100000.0f; - *ptr++ = -100000.0f; + *coords++ = -100000.0f; + *coords++ = -100000.0f; + *coords++ = -100000.0f; } } - for (i = 0; i < 7; i++) { - D_8011A6D8[i].unkB8 = -1; - D_8011A6D8[i].unk0_02 = 0; - D_8011A6D8[i].unkBC = 0.0f; + for (i = 0; i < MAX_REVERB_LINES; i++) { + gReverbLines[i].numSegments = -1; + gReverbLines[i].reverbAmount = 0; + gReverbLines[i].totalLength = 0.0f; - ptr = D_8011A6D8[i].unk4_floats; + coords = gReverbLines[i].coords; for (j = 0; j < 15; j++) { - *ptr++ = -100000.0f; - *ptr++ = -100000.0f; - *ptr++ = -100000.0f; + *coords++ = -100000.0f; + *coords++ = -100000.0f; + *coords++ = -100000.0f; } } - gAudioLinesOff = FALSE; + gJinglesOff = FALSE; } -// audioline_ambient -// Official Name: amPlayAudioMap -#ifdef NON_EQUIVALENT -void func_80008438(Object **objRacers, s32 numRacers, s32 updateRate) { - s32 sp260; - s32 sp254; - s32 sp250; - s32 sp24C; - s32 sp248; - s32 sp244; - f32 sp22C; - f32 sp228; - f32 sp224; - s32 sp1A8; - s32 sp12C; - s32 numActivePlayers; //numActivePlayers - ObjectSegment *spAC; - f32 spA8; - f32 sp98; - f32 sp90; - unk80119C58 *sp88; - f32 *sp70; - ObjectSegment *temp_s3; - ObjectSegment *var_s3; - ObjectSegment *var_s3_2; - f32 *var_s4_2; - f32 temp_f0; - f32 temp_f0_2; - f32 temp_f0_3; - f32 temp_f0_4; - f32 temp_f0_5; - f32 temp_f12; - f32 temp_f16_3; - f32 temp_f20; - f32 temp_f20_2; - f32 temp_f20_3; - f32 temp_f22; - f32 temp_f22_2; - f32 temp_f22_3; - f32 temp_f2; - f32 temp_f4; - f32 var_f24; - s32 *temp_v1_3; - s32 *var_s0; - s32 *var_s0_2; - s32 *var_s1; - s32 *var_s1_2; - s32 *var_v0_5; - s32 *var_v0_6; - s32 temp_a0; - s32 temp_a0_2; - s32 temp_f16; - s32 temp_f16_2; - s32 temp_f8; - s32 temp_v1; - s32 temp_v1_2; - s32 var_a0; - s32 var_a0_2; - s32 var_a2; - s32 var_at; - s32 var_fp; - s32 var_fp_2; - s32 var_s2; - s32 var_s2_2; +/** + * Updates the parameters for audio points and lines, and invokes the handler for vehicle sounds. + * Official Name: amPlayAudioMap + */ +void audspat_update_all(Object **objList, s32 numObjects, s32 updateRate) { + s32 viewportCount; s32 i; - s32 var_s5; - s32 var_s6; - s32 var_v0; - s32 var_v0_4; - s32 var_v1; - s8 var_v1_2; - unk80119C58 *var_v0_3; - SoundMask *temp_s1; - s32 *spB8; + s32 j; + s32 k; + s32 volume; + s32 pan; + s32 jingleVolume; + s32 jinglePan; + s32 jingleSound; + f32 dx, dy, dz; + s32 distance; + AudioPoint *audioPoint; + f32 outX; + f32 outY; + f32 outZ; + s32 minDist; + s32 adjustedVolume; + s32 lineDistances[29]; + s32 pan2; + s32 inverseSum; + s32 linePans[29]; + s32 inverseDistances[29]; + s32 sumOfDistances; + s32 numCameras; + ObjectSegment *cameras; + f32 pitch1; + f32 temp; + f32 minDistance; + f32 *coords; + f32 pitch2; + s32 unused; + f32 pitch3; - sp24C = 0; - numActivePlayers = set_active_viewports_and_max(get_viewport_count()); - spAC = get_cutscene_camera_segment(); - sp260 = 0; - if (gUsedMasks > 0) { - i = 0; - do { - temp_s1 = gSoundMaskHeapUsed[i]; - sp254 = 0; - if (temp_s1->unk11 & 2) { - if (numActivePlayers == 1) { - temp_f20 = temp_s1->pos.x - spAC->trans.x_position; - temp_f0 = temp_s1->pos.y - spAC->trans.y_position; - temp_f22 = temp_s1->pos.z - spAC->trans.z_position; - temp_f16 = sqrtf((temp_f20 * temp_f20) + (temp_f0 * temp_f0) + (temp_f22 * temp_f22)); - if ((temp_f16 < temp_s1->distance) && ((temp_s1->unk12 == 0))) { - if (temp_s1->soundPtr == NULL && (temp_s1->unk22 == 0 || !(temp_s1->unk11 & 4))) { - func_80001F14(temp_s1->soundId, &temp_s1->soundPtr); - temp_s1->unk22 = 1; - } - if (temp_s1->soundPtr != NULL) { - spA8 = temp_s1->pitch / 100.0f; - sndp_set_param(temp_s1->soundPtr, AL_SNDP_VOL_EVT, temp_s1->volume << 8); - sndp_set_param(temp_s1->soundPtr, AL_SNDP_PITCH_EVT, *((u32 *) &spA8)); - var_a2 = func_800090C0(temp_f20, temp_f22, spAC->trans.rotation.x); - if (numActivePlayers != 1) { - var_a2 = 0x40; - } - sndp_set_param(temp_s1->soundPtr, AL_SNDP_PAN_EVT, var_a2); - audioline_reverb(temp_s1->soundPtr, temp_s1->pos.x, temp_s1->pos.y, temp_s1->pos.z); - sndp_set_priority(temp_s1->soundPtr, temp_s1->unk21); - } - temp_s1->unk12 = 1; - } else if (temp_s1->distance < temp_f16 && temp_s1->unk12 != 0) { - temp_s1->unk12 = 0; + jingleVolume = 0; + viewportCount = get_viewport_count(); + numCameras = set_active_viewports_and_max(viewportCount); + cameras = get_cutscene_camera_segment(); + + // Update audio points + for (i = 0; i < gNumAudioPoints; i++) { + audioPoint = gAudioPoints[i]; + volume = 0; + + if (audioPoint->flags & AUDIO_POINT_FLAG_SINGLE_PLAYER) { + if (numCameras == 1) { + dx = audioPoint->pos.x - cameras[0].trans.x_position; + dy = audioPoint->pos.y - cameras[0].trans.y_position; + dz = audioPoint->pos.z - cameras[0].trans.z_position; + distance = sqrtf(dx * dx + dy * dy + dz * dz); + if (distance < audioPoint->range && !audioPoint->inRange) { + if (audioPoint->soundHandle == NULL && + (!audioPoint->triggeredOnce || !(audioPoint->flags & AUDIO_POINT_FLAG_ONE_TIME_TRIGGER))) { + func_80001F14(audioPoint->soundBite, &audioPoint->soundHandle); + audioPoint->triggeredOnce = TRUE; } + + if (audioPoint->soundHandle != NULL) { + pitch1 = audioPoint->pitch / 100.0f; + sndp_set_param(audioPoint->soundHandle, AL_SNDP_VOL_EVT, audioPoint->volume * 256); + sndp_set_param(audioPoint->soundHandle, AL_SNDP_PITCH_EVT, *(s32 *) &pitch1); + pan2 = audspat_calculate_spatial_pan(dx, dz, cameras[0].trans.rotation.y_rotation); + if (numCameras != 1) { + pan2 = 64; + } + sndp_set_param(audioPoint->soundHandle, AL_SNDP_PAN_EVT, pan2); + audspat_calculate_echo(audioPoint->soundHandle, audioPoint->pos.x, audioPoint->pos.y, + audioPoint->pos.z); + sndp_set_priority(audioPoint->soundHandle, audioPoint->priority); + } + + audioPoint->inRange = TRUE; + } else if (distance > audioPoint->range && audioPoint->inRange) { + audioPoint->inRange = FALSE; + } + } + } else { + // Calculate volume and pan for all cameras and find the max volume + for (j = 0; j < numCameras; j++) { + dx = audioPoint->pos.x - cameras[j].trans.x_position; + dy = audioPoint->pos.y - cameras[j].trans.y_position; + dz = audioPoint->pos.z - cameras[j].trans.z_position; + distance = sqrtf(dx * dx + dy * dy + dz * dz); + if (distance < audioPoint->range) { + if (!audioPoint->fastFalloff) { + adjustedVolume = (1.0f - (f32) distance / (f32) audioPoint->range) * audioPoint->volume; + } else { + temp = (f32) (audioPoint->range - distance) / (f32) audioPoint->range; + adjustedVolume = temp * temp * audioPoint->volume; + } + + if (volume < adjustedVolume) { + volume = adjustedVolume; + pan = audspat_calculate_spatial_pan(dx, dz, cameras[j].trans.rotation.y_rotation); + } + } + } + + // If all cameras are far enough then set volume to minVolume + // and calculate pan based on the closest camera + if (volume < audioPoint->minVolume) { + minDistance = 999999.0f; + + for (j = 0; j < numCameras; j++) { + dx = audioPoint->pos.x - cameras[j].trans.x_position; + dy = audioPoint->pos.y - cameras[j].trans.y_position; + dz = audioPoint->pos.z - cameras[j].trans.z_position; + distance = sqrtf(dx * dx + dy * dy + dz * dz); + if (distance < minDistance) { + pan = audspat_calculate_spatial_pan(dx, dz, cameras[j].trans.rotation.y_rotation); + minDistance = distance; + } + } + + volume = audioPoint->minVolume; + } + + if (volume > MIN_VOLUME_THRESHOLD) { + if (audioPoint->soundHandle == NULL && + (!audioPoint->triggeredOnce || !(audioPoint->flags & AUDIO_POINT_FLAG_ONE_TIME_TRIGGER))) { + func_80001F14(audioPoint->soundBite, &audioPoint->soundHandle); + audioPoint->triggeredOnce = TRUE; + } + + if (audioPoint->soundHandle != NULL) { + pitch2 = audioPoint->pitch / 100.0f; + sndp_set_param(audioPoint->soundHandle, AL_SNDP_VOL_EVT, volume * 256); + sndp_set_param(audioPoint->soundHandle, AL_SNDP_PITCH_EVT, *(s32 *) &pitch2); + if (numCameras != 1) { + pan = 64; + } + sndp_set_param(audioPoint->soundHandle, AL_SNDP_PAN_EVT, pan); + sndp_set_priority(audioPoint->soundHandle, audioPoint->priority); + audspat_calculate_echo(audioPoint->soundHandle, audioPoint->pos.x, audioPoint->pos.y, + audioPoint->pos.z); } } else { - var_fp = 0; - if (numActivePlayers > 0) { - var_s3 = spAC; - do { - temp_f20 = temp_s1->pos.x - var_s3->trans.x_position; - temp_f0 = temp_s1->pos.y - var_s3->trans.y_position; - temp_f22 = temp_s1->pos.z - var_s3->trans.z_position; - temp_f16 = sqrtf((temp_f20 * temp_f20) + (temp_f0 * temp_f0) + (temp_f22 * temp_f22)); - if (temp_f16 < temp_s1->distance) { - if (temp_s1->unk20 == 0) { - var_v0 = ((1.0f - ((f32) temp_f16 / (f32) temp_s1->distance)) * temp_s1->volume); - } else { - temp_f0_3 = (temp_s1->distance - temp_f16) / (f32) temp_s1->distance; - var_v0 = (temp_f0_3 * temp_f0_3 * temp_s1->volume); - } - if (sp254 < var_v0) { - sp254 = var_v0; - sp250 = func_800090C0(temp_f20, temp_f22, var_s3->trans.rotation.x); - } - } - var_fp++; - var_s3++; - } while (var_fp != numActivePlayers); + if (audioPoint->soundHandle != NULL) { + sndp_stop(audioPoint->soundHandle); + } else { + audioPoint->triggeredOnce = TRUE; } - if (sp254 < temp_s1->unk10) { - var_fp = 0; - var_f24 = 999999.0f; - if (numActivePlayers > 0) { - var_s3 = spAC; - do { - temp_f20 = temp_s1->pos.x - var_s3->trans.x_position; - temp_f0 = temp_s1->pos.y - var_s3->trans.y_position; - temp_f22 = temp_s1->pos.z - var_s3->trans.z_position; - temp_f16 = sqrtf((temp_f20 * temp_f20) + (temp_f0 * temp_f0) + (temp_f22 * temp_f22)); - if (temp_f16 < var_f24) { - sp250 = func_800090C0(temp_f20, temp_f22, var_s3->trans.rotation.x); - var_f24 = temp_f16; - } - var_fp++; - var_s3++; - } while (var_fp != numActivePlayers); + } + + if ((audioPoint->flags & AUDIO_POINT_FLAG_ONE_TIME_TRIGGER) && audioPoint->triggeredOnce && + audioPoint->soundHandle == NULL) { + audspat_point_stop_by_index(i); + } + } + } + + // Update audio lines + for (i = 0; i < MAX_AUDIO_LINES; i++) { + AudioLine *line = &gAudioLines[i]; + + if (line->soundBite != SOUND_NONE && audspat_line_validate(i)) { + volume = 0; + + for (j = 0; j < numCameras; j++) { + coords = line->coords; + sumOfDistances = 0; + minDist = line->range; + for (k = 0; k < line->numSegments; k++) { + lineDistances[k] = + audspat_distance_to_segment(cameras[j].trans.x_position, cameras[j].trans.y_position, + cameras[j].trans.z_position, coords, &outX, &outY, &outZ); + linePans[k] = audspat_calculate_spatial_pan(outX - cameras[j].trans.x_position, + outZ - cameras[j].trans.z_position, + cameras[j].trans.rotation.y_rotation); + if (minDist > lineDistances[k]) { + minDist = lineDistances[k]; } - sp254 = temp_s1->unk10; + coords += 3; + sumOfDistances += lineDistances[k]; } - if (sp254 > 10) { - if ((temp_s1->soundPtr == NULL) && ((temp_s1->unk22 == 0) || !(temp_s1->unk11 & 4))) { - func_80001F14(temp_s1->soundId, &temp_s1->soundPtr); - temp_s1->unk22 = 1; - } - if (temp_s1->soundPtr != NULL) { - sp98 = temp_s1->pitch / 100.0f; - sndp_set_param(temp_s1->soundPtr, AL_SNDP_VOL_EVT, sp254 << 8); - sndp_set_param(temp_s1->soundPtr, AL_SNDP_PITCH_EVT, *((u32 *) &sp98)); - if (numActivePlayers != 1) { - sp250 = 0x40; + + if (!line->fastFalloff) { + adjustedVolume = (1.0f - (f32) minDist / (f32) line->range) * line->unk174; + } else { + temp = (f32) (line->range - minDist) / (f32) line->range; + adjustedVolume = temp * temp * line->unk174; + } + + if (volume <= adjustedVolume) { + volume = adjustedVolume; + + if (line->numSegments == 1) { + pan = linePans[0]; + } else { + inverseSum = 0; + for (k = 0; k < line->numSegments; k++) { + inverseDistances[k] = sumOfDistances - lineDistances[k]; + inverseSum += inverseDistances[k]; } - sndp_set_param(temp_s1->soundPtr, AL_SNDP_PAN_EVT, sp250); - sndp_set_priority(temp_s1->soundPtr, temp_s1->unk21); - audioline_reverb(temp_s1->soundPtr, temp_s1->pos.x, temp_s1->pos.y, temp_s1->pos.z); + + pan = 0; + for (k = 0; k < line->numSegments; k++) { + pan += (f32) inverseDistances[k] / (f32) inverseSum * (f32) linePans[k]; + } + } + + if (minDist < 400) { + pan = (pan - 64) * (minDist / 400.0f) + 64; + } + } + } + + if (line->type == AUDIO_LINE_TYPE_SOUND) { + if (volume < line->maxVolume) { + volume = line->maxVolume; + } + + if (volume > MIN_VOLUME_THRESHOLD) { + pitch3 = line->unk176 / 100.0f; + + if (line->soundHandle == NULL) { + func_80001F14(line->soundBite, &line->soundHandle); + } + + if (line->soundHandle != NULL) { + sndp_set_param(line->soundHandle, AL_SNDP_VOL_EVT, volume * 256); + sndp_set_param(line->soundHandle, AL_SNDP_PITCH_EVT, *(s32 *) &pitch3); + if (numCameras != 1) { + pan = 64; + } + sndp_set_param(line->soundHandle, AL_SNDP_PAN_EVT, pan); + sndp_set_priority(line->soundHandle, line->priority); } } else { - if (temp_s1->soundPtr != NULL) { - sndp_stop(temp_s1->soundPtr); - } else { - temp_s1->unk22 = 1; + if (line->soundHandle != NULL) { + sndp_stop(line->soundHandle); } } - if ((temp_s1->unk11 & 4) && temp_s1->unk22 && temp_s1->soundPtr == NULL) { - func_8000A2E8(sp260); - } + } else if (line->type == AUDIO_LINE_TYPE_JINGLE && volume > jingleVolume) { + jingleVolume = volume; + jinglePan = pan; + jingleSound = line->soundBite; } - sp260++; - i++; - } while (sp260 < gUsedMasks); - sp260 = 0; + } } - var_v0_3 = D_80119C58; - do { - sp88 = var_v0_3; - if (var_v0_3->soundID != 0) { - sp88 = var_v0_3; - if (func_800099EC(var_v0_3->unk0_02/*unksp263*/) != 0) { - sp254 = 0; - i = 0; - if (numActivePlayers > 0) { - sp70 = sp88->unk4_floats; - do { - var_s4_2 = sp70; - var_v1 = sp88->unk170; - var_s5 = 0; - var_s2 = 0; - var_s6 = var_v1; - if (sp88->unk17C > 0) { - var_s0 = &sp1A8; - var_s1 = &sp12C; - temp_s3 = &spAC[i]; - do { - *var_s0 = audioline_distance(temp_s3->trans.x_position, temp_s3->trans.y_position, temp_s3->trans.z_position, var_s4_2, &sp22C, &sp228, &sp224); - temp_v1 = *var_s0; - *var_s1 = func_800090C0(sp22C - temp_s3->trans.x_position, sp224 - temp_s3->trans.z_position, temp_s3->trans.rotation.x); - var_s4_2 += 0xC; - if (temp_v1 < var_s6) { - var_s6 = temp_v1; - } - var_s2 += 1; - var_s0 += 4; - var_s1 += 4; - var_s5 += temp_v1; - } while (var_s2 < var_v0_3->unk17C); - var_v1 = sp88->unk170; - } - temp_f2 = (f32) var_v1; - temp_f12 = (f32) sp88->unk174; - if (sp88->unk17D == 0) { - var_v0_4 = (s32) ((1.0f - ((f32) var_s6 / temp_f2)) * temp_f12); - } else { - temp_f0_5 = (f32) (var_v1 - var_s6) / temp_f2; - var_v0_4 = (s32) (temp_f0_5 * temp_f0_5 * temp_f12); - } - if (var_v0_4 >= sp254) { - sp254 = var_v0_4; - var_v1_2 = sp88->unk17C; - var_a0 = 0; - if (var_v1_2 == 1) { - sp250 = sp12C; - } else { - var_s2_2 = 0; - sp250 = 0; - if (var_v1_2 > 0) { - var_s0_2 = &sp1A8; - var_v0_5 = &spB8[0]; - do { - var_s2_2 += 1; - temp_v1_2 = var_s5 - *var_s0_2; - *var_v0_5 = temp_v1_2; - var_s0_2 += 4; - var_v0_5 += 4; - var_a0 += temp_v1_2; - } while (var_s2_2 < var_v0_3->unk17C); - var_v1_2 = sp88->unk17C; - } - var_s1_2 = &sp12C; - if (var_v1_2 > 0) { - var_v0_6 = &spB8[0]; - var_a0_2 = sp250; - temp_v1_3 = &var_v0_6[var_v0_3->unk17C]; - do { - temp_f16_3 = (f32) *var_v0_6; - var_v0_6 += 4; - temp_f4 = (f32) *var_s1_2; - var_s1_2 += 4; - var_a0_2 = (s32) ((f32) var_a0_2 + ((temp_f16_3 / (f32) var_a0) * temp_f4)); - } while ((u32) var_v0_6 < (u32) temp_v1_3); - sp250 = var_a0_2; - } - } - if (var_s6 < 400) { - sp250 = (((sp250 - 64) * (var_s6 / 400.0f)) + 64.0f); - } - } - i++; - } while (i != numActivePlayers); - } - if (sp88->unk0_02 == 0) { - if (sp254 < sp88->unk175) { - sp254 = sp88->unk175; - } - if (sp254 > 10) { - sp90 = sp88->unk176 / 100.0f; - if (sp88->soundPtr == NULL) { - func_80001F14(sp88->soundID, &sp88->soundPtr); - } - if (sp88->soundPtr != NULL) { - sndp_set_param(sp88->soundPtr, AL_SNDP_VOL_EVT, sp254 << 8); - sndp_set_param(sp88->soundPtr, AL_SNDP_PITCH_EVT, *((u32 *) &sp90)); - if (numActivePlayers != 1) { - sp250 = 0x40; - } - sndp_set_param(sp88->soundPtr, AL_SNDP_PAN_EVT, (u32) sp250); - sndp_set_priority(sp88->soundPtr, sp88->unk17E); - } - } else { - if (sp88->soundPtr != NULL) { - sndp_stop(sp88->soundPtr); - } - } - } else if (sp88->unk0_02 == 1 && sp24C < sp254) { - sp24C = sp254; - sp248 = sp250; - sp244 = sp88->soundID; - } - } + + // Update jingle parameters + if (jingleVolume > MIN_VOLUME_THRESHOLD && !gJinglesOff) { + if (music_jingle_current() != jingleSound) { + music_jingle_play_safe(jingleSound); } - sp260++; - var_v0_3 = &sp88[1]; - } while (sp260 != 7); - if (sp24C > 10 && gAudioLinesOff == FALSE) { - if (sp244 != music_jingle_current()) { - music_jingle_play_safe(var_v0_3->unk0_02/*unksp247*/); - } - music_jingle_volume_set(var_v0_3->unk0_05/*unksp24F*/); - music_jingle_pan_set(var_v0_3->unk0_03/*unksp24B*/); + music_jingle_volume_set(jingleVolume); + music_jingle_pan_set(jinglePan); } else { music_jingle_stop(); } - if (numRacers != 0) { - func_80006FC8(objRacers, numRacers, spAC, spB8[0]/*unkspB3*/, updateRate); + + // Update vehicle sounds + if (numObjects != 0) { + func_80006FC8(objList, numObjects, cameras, numCameras, updateRate); } } -#else -#pragma GLOBAL_ASM("asm/nonmatchings/audio_spatial/func_80008438.s") -#endif /** + * Computes the pan value based on the camera's position and orientation relative to the sound source. * Official Name: amCalcSfxStereo */ -s32 func_800090C0(f32 x, f32 z, s32 yRot) { - s32 temp_v1; - s32 ret; - f32 sp1C; +s32 audspat_calculate_spatial_pan(f32 x, f32 z, s32 yaw) { + s32 angle; + s32 pan; + f32 distance; - sp1C = sqrtf((x * x) + (z * z)); - temp_v1 = 0xFFFF - arctan2_f(x, z); + distance = sqrtf((x * x) + (z * z)); + angle = 0xFFFF - arctan2_f(x, z); - if (temp_v1 < yRot) { - if (sp1C <= 1.0f) { - ret = 64 - ((sins_s16(yRot - temp_v1) / 1024) * (sp1C * 1)); + if (angle < yaw) { + if (distance <= 1.0f) { + pan = 64 - ((sins_s16(yaw - angle) / 1024) * (distance * 1)); } else { - ret = 64 - (sins_2(yRot - temp_v1) / 1024); + pan = 64 - (sins_2(yaw - angle) / 1024); } - } else if (sp1C <= 1.0f) { - ret = (sins_s16(temp_v1 - yRot) / 1024) * (sp1C * 1) + 64; } else { - ret = (sins_2(temp_v1 - yRot) / 1024) + 64; + if (distance <= 1.0f) { + pan = (sins_s16(angle - yaw) / 1024) * (distance * 1) + 64; + } else { + pan = (sins_2(angle - yaw) / 1024) + 64; + } } if (get_filtered_cheats() & CHEAT_MIRRORED_TRACKS) { - ret = 128 - ret; + pan = 128 - pan; } - return ret; + return pan; } /** - * Calculates the position between two points, then the distance from the nearest point. - * Write the adjusted positions to the arguments. - * Returns the distance between the input and the nearest endpoint. + * Computes the distance from a point to a line segment in 3D space, + * and returns the coordinates of the closest point on the segment. */ -s32 audioline_distance(f32 inX, f32 inY, f32 inZ, f32 coords[6], f32 *outX, f32 *outY, f32 *outZ) { +s32 audspat_distance_to_segment(f32 inX, f32 inY, f32 inZ, f32 coords[6], f32 *outX, f32 *outY, f32 *outZ) { f32 dx, dy, dz; f32 x1, y1, z1; f32 x2, y2, z2; - f32 mag; - f32 ret; + f32 projection; + f32 distance; x1 = coords[0]; y1 = coords[1]; @@ -518,263 +466,304 @@ s32 audioline_distance(f32 inX, f32 inY, f32 inZ, f32 coords[6], f32 *outX, f32 x2 = coords[3]; y2 = coords[4]; z2 = coords[5]; - mag = 0.0f; + projection = 0.0f; dx = x2 - x1; dy = y2 - y1; dz = z2 - z1; if (dx == 0.0 && dy == 0.0 && dz == 0.0) { - mag = 0.0f; + projection = 0.0f; } else { - mag = ((inX - x1) * dx + (inY - y1) * dy + (inZ - z1) * dz) / (dx * dx + dy * dy + dz * dz); + projection = ((inX - x1) * dx + (inY - y1) * dy + (inZ - z1) * dz) / (dx * dx + dy * dy + dz * dz); } - if (mag < 0.0f) { + if (projection < 0.0f) { + // First vertex is the closest *outX = x1; *outY = y1; *outZ = z1; dx = x1 - inX; dy = y1 - inY; dz = z1 - inZ; - ret = sqrtf(dx * dx + dy * dy + dz * dz); - } else if (mag > 1.0f) { + distance = sqrtf(dx * dx + dy * dy + dz * dz); + } else if (projection > 1.0f) { + // Second vertex is the closest *outX = x2; *outY = y2; *outZ = z2; dx = x2 - inX; dy = y2 - inY; dz = z2 - inZ; - ret = sqrtf(dx * dx + dy * dy + dz * dz); + distance = sqrtf(dx * dx + dy * dy + dz * dz); } else { - *outX = mag * dx + x1, // Comma required here as this was likely all one line. - *outY = mag * dy + y1, *outZ = mag * dz + z1; - - ret = sqrtf((*outX - inX) * (*outX - inX) + (*outY - inY) * (*outY - inY) + (*outZ - inZ) * (*outZ - inZ)); + // Closest point is between the two vertices + // Calculate the point on the line + *outX = projection * dx + x1, *outY = projection * dy + y1, *outZ = projection * dz + z1; + distance = sqrtf((*outX - inX) * (*outX - inX) + (*outY - inY) * (*outY - inY) + (*outZ - inZ) * (*outZ - inZ)); } - return ret; + return distance; } /** * Play Sound at position * Official Name: amSndPlayXYZ */ -void play_sound_at_position(u16 soundId, f32 x, f32 y, f32 z, u8 arg4, SoundMask **soundMask) { - func_8000974C(D_80119C40[soundId].soundBite, x, y, z, arg4, D_80119C40[soundId].unk3, D_80119C40[soundId].volume, - D_80119C40[soundId].distance, 0, D_80119C40[soundId].pitch, D_80119C40[soundId].unk8, soundMask); +void audspat_play_sound_at_position(u16 soundId, f32 x, f32 y, f32 z, u8 flags, AudioPoint **handlePtr) { + audspat_point_create(gSpatialSoundTable[soundId].soundBite, x, y, z, flags, gSpatialSoundTable[soundId].minVolume, + gSpatialSoundTable[soundId].volume, gSpatialSoundTable[soundId].range, FALSE, + gSpatialSoundTable[soundId].pitch, gSpatialSoundTable[soundId].priority, handlePtr); } /** + * Uncertain of the exact purpose of this function, but it directly takes a sound ID + * and bypasses the sound table. * Official Name: amSndPlayDirectXYZ */ -void func_800095E8(u16 soundId, f32 x, f32 y, f32 z, u8 arg4, u8 arg5, f32 pitch, SoundMask **soundMask) { - func_8000974C(soundId, x, y, z, arg4, 100, arg5, 15000, 0, pitch, 0x3F, soundMask); +void audspat_play_sound_direct(u16 soundBite, f32 x, f32 y, f32 z, u8 flags, u8 volume, f32 pitch, + AudioPoint **handlePtr) { + audspat_point_create(soundBite, x, y, z, flags, /* minVolume */ 100, volume, /* range */ 15000, FALSE, pitch, + /* priority */ 63, handlePtr); } /** - * I think this function is used to update the world position of any sound associated with the given soundmask. + * Sets the position of an audio point. * Official Name: amSndSetXYZ */ -void update_spatial_audio_position(SoundMask *soundMask, f32 x, f32 y, f32 z) { - soundMask->pos.x = x; - soundMask->pos.y = y; - soundMask->pos.z = z; +void audspat_point_set_position(AudioPoint *audioPoint, f32 x, f32 y, f32 z) { + audioPoint->pos.x = x; + audioPoint->pos.y = y; + audioPoint->pos.z = z; } /** * Official Name: amSndStopXYZ + * Stops the sound associated with the audio point. */ -void func_800096F8(SoundMask *soundMask) { +void audspat_point_stop(AudioPoint *point) { s32 i; - for (i = 0; i < SOUND_MASK_HEAP_COUNT; i++) { - if (soundMask == gSoundMaskHeapUsed[i]) { - func_8000A2E8(i); + for (i = 0; i < MAX_AUDIO_POINTS; i++) { + if (point == gAudioPoints[i]) { + audspat_point_stop_by_index(i); break; } } } /** + * Creates a point sound source and sets its parameters * Official Name: amCreateAudioPoint */ -void func_8000974C(u16 soundBite, f32 x, f32 y, f32 z, u8 arg4, u8 arg5, u8 volume, u16 distance, u8 arg8, u8 pitch, - u8 argA, SoundMask **soundMask) { - SoundMask *newMask; +void audspat_point_create(u16 soundBite, f32 x, f32 y, f32 z, u8 flags, u8 minVolume, u8 volume, u16 range, + u8 fastFalloff, u8 pitch, u8 priority, AudioPoint **handlePtr) { + AudioPoint *audioPoint; - if (soundMask != NULL) { + if (handlePtr != NULL) { func_800245B4(soundBite | 0xE000); } - if (gUsedMasks == SOUND_MASK_HEAP_COUNT) { - if (soundMask != NULL) { - *soundMask = NULL; + if (gNumAudioPoints == MAX_AUDIO_POINTS) { + if (handlePtr != NULL) { + *handlePtr = NULL; } func_800245B4(0xAA55); return; } - newMask = gSoundMaskHeapFree[gFreeMasks--]; - newMask->pos.x = x; - newMask->pos.y = y; - newMask->pos.z = z; - newMask->soundId = soundBite; - newMask->unk11 = arg4; - newMask->unk10 = arg5; - newMask->volume = volume; - newMask->pitch = pitch; - newMask->distance = distance; - newMask->unk20 = arg8; - newMask->unk21 = argA; - newMask->unk22 = 0; - newMask->soundMask = soundMask; - gSoundMaskHeapUsed[gUsedMasks++] = newMask; - if (soundMask != NULL) { - *soundMask = newMask; + audioPoint = gFreeAudioPoints[gLastFreePointIndex--]; + audioPoint->pos.x = x; + audioPoint->pos.y = y; + audioPoint->pos.z = z; + audioPoint->soundBite = soundBite; + audioPoint->flags = flags; + audioPoint->minVolume = minVolume; + audioPoint->volume = volume; + audioPoint->pitch = pitch; + audioPoint->range = range; + audioPoint->fastFalloff = fastFalloff; + audioPoint->priority = priority; + audioPoint->triggeredOnce = 0; + audioPoint->userHandlePtr = handlePtr; + gAudioPoints[gNumAudioPoints++] = audioPoint; + if (handlePtr != NULL) { + *handlePtr = audioPoint; } } -void audioline_ambient_create(u8 arg0, u16 soundId, f32 x, f32 y, f32 z, u8 arg5, u8 arg6, u8 arg7, u8 arg8, u16 arg9, - u8 argA, u8 lineID, u8 argC) { - unk80119C58 *temp_v1; - f32 *temp_a0; +/** + * Adds a vertex to the audio line. + * An audio line is a sound source in the form of a polyline + * The first vertex defines the sound ID and other properties. + */ +void audspat_line_add_vertex(u8 type, u16 soundBite, f32 x, f32 y, f32 z, u8 arg5, u8 arg6, u8 arg7, u8 priority, + u16 arg9, u8 argA, u8 lineID, u8 vertexIndex) { + AudioLine *line; + f32 *coords; - if (lineID < 7 && argC < 30) { - temp_v1 = &D_80119C58[lineID]; - temp_a0 = &temp_v1->unk4_floats[argC * 3]; - temp_a0[0] = x; - temp_a0[1] = y; - temp_a0[2] = z; - if (argC == 0) { - temp_v1->soundID = soundId; - temp_v1->unk0_02 = arg0; - temp_v1->unk170 = arg9; - temp_v1->unk17D = argA; - temp_v1->unk174 = arg6; - temp_v1->unk175 = arg5; - temp_v1->unk176 = arg7; - temp_v1->unk17E = arg8; + if (lineID < MAX_AUDIO_LINES && vertexIndex < 30) { + line = &gAudioLines[lineID]; + coords = &line->coords[vertexIndex * 3]; + coords[0] = x; + coords[1] = y; + coords[2] = z; + if (vertexIndex == 0) { + line->soundBite = soundBite; + line->type = type; + line->range = arg9; + line->fastFalloff = argA; + line->unk174 = arg6; + line->maxVolume = arg5; + line->unk176 = arg7; + line->priority = priority; } - if (temp_v1->unk17C < argC) { - temp_v1->unk17C = argC; + if (line->numSegments < vertexIndex) { + line->numSegments = vertexIndex; } } } -void audioline_reverb_create(f32 x, f32 y, f32 z, u8 arg3, u8 arg4, u8 arg5) { - unk8011A6D8 *temp; - if (arg4 < ARRAY_COUNT(D_8011A6D8) && arg5 < 15) { - temp = &D_8011A6D8[arg4]; - temp->unk4_floats[3 * arg5 + 0] = x; - temp->unk4_floats[3 * arg5 + 1] = y; - temp->unk4_floats[3 * arg5 + 2] = z; - if (arg5 == 0) { - temp->unk0_02 = arg3; +/** + * Adds a vertex to a reverb line. + * Reverb lines are used to calculate echo effects in the game. + * The first vertex defines the reverb intensity. + */ +void audspat_reverb_add_vertex(f32 x, f32 y, f32 z, u8 reverbAmount, u8 lineID, u8 vertexIndex) { + ReverbLine *line; + if (lineID < ARRAY_COUNT(gReverbLines) && vertexIndex < 15) { + line = &gReverbLines[lineID]; + line->coords[3 * vertexIndex + 0] = x; + line->coords[3 * vertexIndex + 1] = y; + line->coords[3 * vertexIndex + 2] = z; + if (vertexIndex == 0) { + line->reverbAmount = reverbAmount; } - if (temp->unkB8 < arg5) { - temp->unkB8 = arg5; + if (line->numSegments < vertexIndex) { + line->numSegments = vertexIndex; } } } -s32 func_800099EC(u8 arg0) { +/** + * Checks that all vertex coordinates are defined. + */ +s32 audspat_line_validate(u8 lineID) { s32 ret; s32 i; - unk80119C58 *temp_v0; - f32 *var_a2; + AudioLine *line; + f32 *coords; - ret = 1; - temp_v0 = &D_80119C58[arg0]; - var_a2 = temp_v0->unk4_floats; + ret = TRUE; + line = &gAudioLines[lineID]; + coords = line->coords; - if (temp_v0->unk17C <= 0) { - return 0; + if (line->numSegments <= 0) { + return FALSE; } - for (i = 0; i < temp_v0->unk17C; i++) { - //@bug should be *(var_a2 + 0), *(var_a2 + 1), *(var_a2 + 2) - if (*var_a2 + 0 == -100000.0 || *var_a2 + 1 == -100000.0 || *var_a2 + 2 == -100000.0) { - ret = 0; + for (i = 0; i < line->numSegments; i++) { + //@bug should be *(coords + 0), *(coords + 1), *(coords + 2) + if (*coords + 0 == -100000.0 || *coords + 1 == -100000.0 || *coords + 2 == -100000.0) { + ret = FALSE; } - var_a2 += 3; + coords += 3; } return ret; } -s32 func_80009AB4(u8 arg0) { +/** + * Checks that all vertex coordinates are defined. + */ +s32 audspat_reverb_validate(u8 reverbLineID) { s32 ret; s32 i; - unk8011A6D8 *temp_v0; - f32 *var_a2; + ReverbLine *line; + f32 *coords; - ret = 1; - temp_v0 = &D_8011A6D8[arg0]; - var_a2 = temp_v0->unk4_floats; + ret = TRUE; + line = &gReverbLines[reverbLineID]; + coords = line->coords; - if (temp_v0->unkB8 <= 0) { - return 0; + if (line->numSegments <= 0) { + return FALSE; } - for (i = 0; i < temp_v0->unkB8; i++) { - //@bug should be *(var_a2 + 0), *(var_a2 + 1), *(var_a2 + 2) - if (*var_a2 == -100000.0 || *var_a2 + 1 == -100000.0 || *var_a2 + 2 == -100000.0) { - ret = 0; + for (i = 0; i < line->numSegments; i++) { + //@bug should be *(coords + 0), *(coords + 1), *(coords + 2) + if (*coords == -100000.0 || *coords + 1 == -100000.0 || *coords + 2 == -100000.0) { + ret = FALSE; } - var_a2 += 3; + coords += 3; } return ret; } -void audioline_reverb(SoundHandle soundHandle, f32 x, f32 y, f32 z) { +/** + * Calculates and sets the reverb amount for a sound at the given position. + * It checks all ReverbLine curves and finds the closest one to the specified point. + * Reverberation is disabled if there is no surface above the point (i.e., the point is not inside a tunnel). + */ +void audspat_calculate_echo(SoundHandle soundHandle, f32 x, f32 y, f32 z) { s32 i; s32 j; - unk8011A6D8 *temp; + ReverbLine *reverbLine; s32 k; f32 outX; f32 outY; f32 outZ; - s32 distBetween; - s32 maxDist; + s32 distToSegment; + s32 minDist; s32 levelSegmentIndex; s32 numOfYVals; - u8 volume; - u8 temp_v0_4; + u8 maxReverbAmt; + u8 reverbAmt; f32 *coords; f32 yVals[10]; levelSegmentIndex = get_level_segment_index_from_position(x, y, z); - volume = 0; - maxDist = 400; - for (i = 0; i < ARRAY_COUNT(D_8011A6D8); i++) { - temp = &D_8011A6D8[i]; - if (temp->unk0_02 != 0) { - if (func_80009AB4(i) != 0) { - coords = temp->unk4_floats; - for (j = 0; j < temp->unkB8; j++) { - distBetween = audioline_distance(x, y, z, coords, &outX, &outY, &outZ); - if (distBetween < maxDist) { - numOfYVals = func_8002BAB0(levelSegmentIndex, x, z, yVals); - for (k = 0; k < numOfYVals; k++) { - if (y < yVals[k]) { - maxDist = distBetween; - temp_v0_4 = func_80009D6C(&D_8011A6D8[i], outX, outY, outZ); - if (volume < temp_v0_4) { - volume = temp_v0_4; - } + maxReverbAmt = 0; + minDist = 400; + + for (i = 0; i < MAX_REVERB_LINES; i++) { + reverbLine = &gReverbLines[i]; + if (reverbLine->reverbAmount != 0 && audspat_reverb_validate(i)) { + coords = reverbLine->coords; + for (j = 0; j < reverbLine->numSegments; j++) { + distToSegment = audspat_distance_to_segment(x, y, z, coords, &outX, &outY, &outZ); + // There seems to be a logic mistake here: the maximum reverb effect may not necessarily come from the + // nearest segment. The closest segment could be near the beginning of the curve and not contribute much + // to the echo. It would be better to iterate through all segments, but this approach would be slower. + if (distToSegment < minDist) { + // Check if the point is below the ceiling (indicating it is inside a tunnel). + // This check should ideally be performed only once per call. + numOfYVals = func_8002BAB0(levelSegmentIndex, x, z, yVals); + for (k = 0; k < numOfYVals; k++) { + if (y < yVals[k]) { + minDist = distToSegment; + reverbAmt = audspat_reverb_get_strength_at_point(reverbLine, outX, outY, outZ); + if (maxReverbAmt < reverbAmt) { + maxReverbAmt = reverbAmt; } } } - coords += 3; } + coords += 3; } } } + if (soundHandle != NULL) { - sndp_set_param((SoundHandle) (s32) soundHandle, AL_SNDP_FX_EVT, (u32) volume); + sndp_set_param(soundHandle, AL_SNDP_FX_EVT, maxReverbAmt); } } -u8 func_80009D6C(unk8011A6D8 *arg0, f32 arg1, f32 arg2, f32 arg3) { +/** + * Returns the reverb strength at a point along the line. + * The strength is calculated based on the distance from the start or the end of the line. + * Maximum strength is returned if the point is not within 300 units of the start or end. + * The strength is linearly interpolated between 0 and the maximum reverb amount. + */ +u8 audspat_reverb_get_strength_at_point(ReverbLine *line, f32 x, f32 y, f32 z) { f32 deltaX; f32 deltaY; f32 deltaZ; @@ -782,28 +771,28 @@ u8 func_80009D6C(unk8011A6D8 *arg0, f32 arg1, f32 arg2, f32 arg3) { f32 x1, y1, z1; f32 x2, y2, z2; f32 dx, dy, dz; - f32 f20; - f32 sp5C; - f32 length; - u8 sp57; - f32 f12; + f32 i; + f32 distanceAlong; + f32 segmentLength; + u8 segmentFound; + f32 projection; - if (arg0->unkBC == 0.0f) { - coords = arg0->unk4_floats; - for (f20 = 0.0f; f20 < arg0->unkB8; f20 += 1.0f) { + if (line->totalLength == 0.0f) { + coords = line->coords; + for (i = 0.0f; i < line->numSegments; i += 1.0f) { deltaX = coords[3] - coords[0]; deltaY = coords[4] - coords[1]; deltaZ = coords[5] - coords[2]; - arg0->unkBC += sqrtf((deltaX * deltaX) + (deltaY * deltaY) + (deltaZ * deltaZ)); + line->totalLength += sqrtf((deltaX * deltaX) + (deltaY * deltaY) + (deltaZ * deltaZ)); coords += 3; } } - coords = arg0->unk4_floats; - sp5C = 0.0f; - sp57 = FALSE; + coords = line->coords; + distanceAlong = 0.0f; + segmentFound = FALSE; - for (; !sp57; coords += 3) { + for (; !segmentFound; coords += 3) { x1 = coords[0]; y1 = coords[1]; z1 = coords[2]; @@ -813,83 +802,93 @@ u8 func_80009D6C(unk8011A6D8 *arg0, f32 arg1, f32 arg2, f32 arg3) { dx = x2 - x1; dy = y2 - y1; dz = z2 - z1; - length = sqrtf((dx * dx) + (dy * dy) + (dz * dz)); + segmentLength = sqrtf((dx * dx) + (dy * dy) + (dz * dz)); - if ((arg1 >= x1 && arg1 <= x2) || (arg1 >= x2 && arg1 <= x1)) { + if ((x >= x1 && x <= x2) || (x >= x2 && x <= x1)) { if (dx != 0.0f) { - f12 = (arg1 - x1) / dx; + projection = (x - x1) / dx; } else if (dy != 0.0f) { - f12 = (arg2 - y1) / dy; + projection = (y - y1) / dy; } else if (dz != 0.0f) { - f12 = (arg3 - z1) / dz; + projection = (z - z1) / dz; } else { - f12 = 0.0f; + projection = 0.0f; } - if (ABS(dy * f12 + y1 - arg2) < 2.0f && ABS(dz * f12 + z1 - arg3) < 2.0f) { - sp57 = TRUE; - sp5C += f12 * length; + if (ABS2(dy * projection + y1 - y) < 2.0f && ABS2(dz * projection + z1 - z) < 2.0f) { + segmentFound = TRUE; + distanceAlong += projection * segmentLength; } else { - sp5C += length; + distanceAlong += segmentLength; } } else { - sp5C += length; + distanceAlong += segmentLength; } } - if (sp5C > arg0->unkBC / 2) { - sp5C = arg0->unkBC - sp5C; + if (distanceAlong > line->totalLength / 2) { + distanceAlong = line->totalLength - distanceAlong; } - if (sp5C < 300.0f) { - return arg0->unk0_02 * sp5C / 300.0f; + if (distanceAlong < 300.0f) { + return line->reverbAmount * distanceAlong / 300.0f; } else { - return arg0->unk0_02; + return line->reverbAmount; } } -void debug_render_audio_effects(Gfx **dList, Vertex **verts, Triangle **tris) { +/** + * Makes audio and reverb lines visible, useful for debugging. + */ +void audspat_debug_render_lines(Gfx **dList, Vertex **verts, Triangle **tris) { s32 i, j; f32 *coords; - unk80119C58 *var_s2; - unk8011A6D8 *var_s2_2; + AudioLine *audioLine; + ReverbLine *reverbLine; - for (i = 0; i < ARRAY_COUNT(D_80119C58); i++) { - var_s2 = &D_80119C58[i]; - coords = var_s2->unk4_floats; - if (D_80119C58[i].soundID != 0) { - for (j = 0; j < var_s2->unk17C; j++) { - debug_render_line(dList, verts, tris, coords, 255, 255, 0); + for (i = 0; i < ARRAY_COUNT(gAudioLines); i++) { + audioLine = &gAudioLines[i]; + coords = audioLine->coords; + if (gAudioLines[i].soundBite != 0) { + for (j = 0; j < audioLine->numSegments; j++) { + audspat_debug_render_line(dList, verts, tris, coords, 255, 255, 0); coords += 3; } } } - for (i = 0; i < ARRAY_COUNT(D_8011A6D8); i++) { - var_s2_2 = &D_8011A6D8[i]; - coords = var_s2_2->unk4_floats; - if (D_8011A6D8[i].unk0_02 != 0) { - for (j = 0; j < var_s2_2->unkB8; j++) { - debug_render_line(dList, verts, tris, coords, 255, 0, 255); + for (i = 0; i < ARRAY_COUNT(gReverbLines); i++) { + reverbLine = &gReverbLines[i]; + coords = reverbLine->coords; + if (gReverbLines[i].reverbAmount != 0) { + for (j = 0; j < reverbLine->numSegments; j++) { + audspat_debug_render_line(dList, verts, tris, coords, 255, 0, 255); coords += 3; } } } } -void func_8000A2E8(s32 arg0) { - if (gUsedMasks != 0) { - if (gSoundMaskHeapUsed[arg0]->soundPtr != 0) { - sndp_stop(gSoundMaskHeapUsed[arg0]->soundPtr); +/** + * Stops the sound associated with the given audio point. + * If the sound is currently playing, it stops it and removes the audio point from the list. + */ +void audspat_point_stop_by_index(s32 index) { + if (gNumAudioPoints != 0) { + if (gAudioPoints[index]->soundHandle != NULL) { + sndp_stop(gAudioPoints[index]->soundHandle); } - if (gSoundMaskHeapUsed[arg0]->soundMask != NULL) { - *gSoundMaskHeapUsed[arg0]->soundMask = NULL; - func_800245B4(gSoundMaskHeapUsed[arg0]->soundId | 0x5000); + if (gAudioPoints[index]->userHandlePtr != NULL) { + *gAudioPoints[index]->userHandlePtr = NULL; + func_800245B4(gAudioPoints[index]->soundBite | 0x5000); } - gFreeMasks++; - gSoundMaskHeapFree[gFreeMasks] = gSoundMaskHeapUsed[arg0]; - gSoundMaskHeapUsed[arg0] = gSoundMaskHeapUsed[gUsedMasks - 1]; - gUsedMasks--; + + // put it to the free list + gLastFreePointIndex++; + gFreeAudioPoints[gLastFreePointIndex] = gAudioPoints[index]; + // move the last element to the index of the one we are removing + gAudioPoints[index] = gAudioPoints[gNumAudioPoints - 1]; + gNumAudioPoints--; } } @@ -897,7 +896,7 @@ void func_8000A2E8(s32 arg0) { * Generates and renders a coloured line visible from anywhere. * Allows use of a colour, that interpolates from bright to dark from the beginning to the end of the line. */ -void debug_render_line(Gfx **dList, Vertex **verts, Triangle **tris, f32 coords[6], u8 red, u8 green, u8 blue) { +void audspat_debug_render_line(Gfx **dList, Vertex **verts, Triangle **tris, f32 coords[6], u8 red, u8 green, u8 blue) { Gfx *temp_dlist; Vertex *temp_verts; Triangle *temp_tris; diff --git a/src/audio_spatial.h b/src/audio_spatial.h index f1247125..1e7b4ee7 100644 --- a/src/audio_spatial.h +++ b/src/audio_spatial.h @@ -7,67 +7,78 @@ #include "PR/gbi.h" #include "PR/libaudio.h" -typedef struct floatXYZVals { - f32 x1; - f32 y1; - f32 z1; - f32 x2; - f32 y2; - f32 z2; -} floatXYZVals; +#define AUDIO_LINE_TYPE_SOUND 0 +#define AUDIO_LINE_TYPE_JINGLE 1 + +#define AUDIO_POINT_FLAG_1 1 // Unused +#define AUDIO_POINT_FLAG_SINGLE_PLAYER 2 +#define AUDIO_POINT_FLAG_ONE_TIME_TRIGGER 4 + +/* Size: 0x24 / 36 bytes */ +typedef struct AudioPoint { + /* 0x00 */ Vec3f pos; + /* 0x0C */ u16 soundBite; + /* 0x0E */ u8 volume; + /* 0x0F */ u8 pitch; + /* 0x10 */ u8 minVolume; + /* 0x11 */ u8 flags; + /* 0x12 */ u8 inRange; + /* 0x14 */ s32 range; + /* 0x18 */ SoundHandle soundHandle; + /* 0x1C */ struct AudioPoint **userHandlePtr; + /* 0x20 */ u8 fastFalloff; + /* 0x21 */ u8 priority; + /* 0x22 */ u8 triggeredOnce; +} AudioPoint; /* Size: 0x180 / 384 bytes */ -typedef struct unk80119C58 { - /* 0x000 */ u8 unk0_02; - /* 0x000 */ u8 unk0_03; - /* 0x000 */ u8 unk0_04; - /* 0x000 */ u8 unk0_05; - /* 0x004 */ f32 unk4_floats[30 * 3]; // Should be a Vec3f, but that just doesn't match - /* 0x16C */ s32 soundID; - /* 0x170 */ s32 unk170; +typedef struct AudioLine { + /* 0x000 */ u8 type; // 0 - sound, 1 - jingle + /* 0x004 */ f32 coords[30 * 3]; + /* 0x16C */ s32 soundBite; + /* 0x170 */ s32 range; /* 0x174 */ u8 unk174; - /* 0x175 */ u8 unk175; + /* 0x175 */ u8 maxVolume; /* 0x176 */ u8 unk176; /* 0x177 */ u8 unk177; - /* 0x178 */ SoundHandle soundPtr; - /* 0x17C */ s8 unk17C; - /* 0x17D */ u8 unk17D; - /* 0x17E */ u8 unk17E; -} unk80119C58; + /* 0x178 */ SoundHandle soundHandle; + /* 0x17C */ s8 numSegments; + /* 0x17D */ u8 fastFalloff; + /* 0x17E */ u8 priority; +} AudioLine; -/* Size: 0xC0 / 192 bytes - Thought it was a LevelHeader, but that didn't match other usages */ -typedef struct unk8011A6D8 { - /* 0x00 */ u8 unk0_02; - /* 0x04 */ f32 unk4_floats[15 * 3]; - /* 0xB8 */ s8 unkB8; - /* 0xB9 */ u8 padB9[0x03]; - /* 0xBC */ f32 unkBC; -} unk8011A6D8; +/* Size: 0xC0 / 192 bytes */ +typedef struct ReverbLine { + /* 0x00 */ u8 reverbAmount; + /* 0x04 */ f32 coords[15 * 3]; + /* 0xB8 */ s8 numSegments; + /* 0xBC */ f32 totalLength; +} ReverbLine; -void audioline_on(void); -void func_800096F8(SoundMask *); -void audioline_off(void); -void func_8000974C(u16 soundBite, f32 x, f32 y, f32 z, u8 arg4, u8 arg5, u8 volume, u16 distance, u8 arg8, u8 pitch, - u8 argA, SoundMask **soundMask); -void play_sound_at_position(u16 soundId, f32 x, f32 y, f32 z, u8 arg4, SoundMask **soundMask); -void func_8000A2E8(s32 arg0); -s32 func_800090C0(f32, f32, s32); -void func_800095E8(u16 soundId, f32 x, f32 y, f32 z, u8 arg4, u8 arg5, f32 pitch, SoundMask **soundMask); -void audioline_ambient_create(u8 arg0, u16 soundId, f32 x, f32 y, f32 z, u8 arg5, u8 arg6, u8 arg7, u8 arg8, u16 arg9, +void audspat_jingle_on(void); +void audspat_point_stop(AudioPoint *); +void audspat_jingle_off(void); +void audspat_point_create(u16 soundBite, f32 x, f32 y, f32 z, u8 arg4, u8 arg5, u8 volume, u16 distance, u8 arg8, u8 pitch, + u8 argA, AudioPoint **handlePtr); +void audspat_play_sound_at_position(u16 soundId, f32 x, f32 y, f32 z, u8 flags, AudioPoint **handlePtr); +void audspat_point_stop_by_index(s32 arg0); +s32 audspat_calculate_spatial_pan(f32, f32, s32); +void audspat_play_sound_direct(u16 soundId, f32 x, f32 y, f32 z, u8 arg4, u8 arg5, f32 pitch, AudioPoint **handlePtr); +void audspat_line_add_vertex(u8 arg0, u16 soundId, f32 x, f32 y, f32 z, u8 arg5, u8 arg6, u8 arg7, u8 arg8, u16 arg9, u8 argA, u8 lineID, u8 argC); -s32 func_800099EC(u8 arg0); -void debug_render_line(Gfx **dList, Vertex **verts, Triangle **tris, f32 coords[6], u8 red, u8 green, u8 blue); +s32 audspat_line_validate(u8 arg0); +void audspat_debug_render_line(Gfx **dList, Vertex **verts, Triangle **tris, f32 coords[6], u8 red, u8 green, u8 blue); void func_80006BFC(Object *obj, ObjectSegment *segment, Object *obj2, s32 updateRate); -void update_spatial_audio_position(SoundMask *soundMask, f32 x, f32 y, f32 z); -s32 func_80009AB4(u8 arg0); -void audioline_init(void); -void audioline_reverb_create(f32, f32, f32, u8, u8, u8); -void audioline_reverb(SoundHandle soundHandle, f32 x, f32 y, f32 z); +void audspat_point_set_position(AudioPoint *arg0, f32 x, f32 y, f32 z); +s32 audspat_reverb_validate(u8 arg0); +void audspat_init(void); +void audspat_reverb_add_vertex(f32, f32, f32, u8, u8, u8); +void audspat_calculate_echo(SoundHandle soundState, f32 x, f32 y, f32 z); -s32 audioline_distance(f32 inX, f32 inY, f32 inZ, f32 coords[6], f32 *outX, f32 *outY, f32 *outZ); -void audioline_reset(void); -void func_80008438(Object **arg0, s32 numRacers, s32 updateRate); // Non Matching +s32 audspat_distance_to_segment(f32 inX, f32 inY, f32 inZ, f32 coords[6], f32 *outX, f32 *outY, f32 *outZ); +void audspat_reset(void); +void audspat_update_all(Object **arg0, s32 numRacers, s32 updateRate); // Non Matching void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3, s32 updateRate); // Non Matching -u8 func_80009D6C(unk8011A6D8 *, f32, f32, f32); +u8 audspat_reverb_get_strength_at_point(ReverbLine *, f32, f32, f32); #endif diff --git a/src/audio_vehicle.c b/src/audio_vehicle.c index b3e5bf85..1b88daa9 100644 --- a/src/audio_vehicle.c +++ b/src/audio_vehicle.c @@ -321,7 +321,7 @@ void func_80005254(Object *obj, u32 buttonsPressed, u32 buttonsHeld, s32 updateR if (var_f20 > 12.0f) { var_f20 = 12.0f; } - func_80001F14(25, (s32 *) &gRacerSound->unkA8); + func_80001F14(25, &gRacerSound->unkA8); sp6C = (((var_f20 * 0.5) / 12.0) + 0.5); temp_a0_4 = (s32) gRacerSound->unkA8; if (temp_a0_4 != 0) { @@ -337,11 +337,11 @@ void func_80005254(Object *obj, u32 buttonsPressed, u32 buttonsHeld, s32 updateR gRacerSound->unkD0 = 0; } if (gRacerSound->unkD0 >= 10) { - sndp_set_param((s32) gRacerSound->unkA8, AL_SNDP_VOL_EVT, 0); + sndp_set_param(gRacerSound->unkA8, AL_SNDP_VOL_EVT, 0); } else { - sndp_set_param((s32) gRacerSound->unkA8, AL_SNDP_VOL_EVT, gRacerSound->unkAC << 8); - audioline_reverb((s32 *) gRacerSound->unkA8, obj->segment.trans.x_position, obj->segment.trans.y_position, - obj->segment.trans.z_position); + sndp_set_param(gRacerSound->unkA8, AL_SNDP_VOL_EVT, gRacerSound->unkAC << 8); + audspat_calculate_echo(gRacerSound->unkA8, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position); } } gRacerSound->unkA0 = var_s0; @@ -705,8 +705,8 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3 var_f26 = 2250000.0f; //(1500.0f * 1500.0f) var_f26 = (var_f26 - (gRacerSound->unk84 * gRacerSound->unk84)) / var_f26; var_f26 *= var_f26; - gRacerSound->unk91[0] = - func_800090C0(tempxPos, tempzPos, segment[loopCount1].trans.rotation.y_rotation); + gRacerSound->unk91[0] = audspat_calculate_spatial_pan( + tempxPos, tempzPos, segment[loopCount1].trans.rotation.y_rotation); } else { var_f26 = 0.0f; } @@ -724,20 +724,21 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3 temp_s3 = (gRacerSound->unk37 - (gRacerSound->unk37 * temp_f20_2)) * var_f26; if (temp_s3 >= 16) { if (gRacerSound->unk50 == NULL) { - func_80001F14(gRacerSound->unk36, (s32 *) &gRacerSound->unk50); + func_80001F14(gRacerSound->unk36, &gRacerSound->unk50); } temp_f0_3 = gRacerSound->unk38 / 100.0f; sp8C = temp_f0_3 + ((((f32) gRacerSound->unk39 / 100.0f) - temp_f0_3) * temp_f20_2); if (gRacerSound->unk50 != NULL) { - audioline_reverb((s32 *) gRacerSound->unk50, objs[loopCount1]->segment.trans.x_position, - objs[loopCount1]->segment.trans.y_position, - objs[loopCount1]->segment.trans.z_position); + audspat_calculate_echo(gRacerSound->unk50, objs[loopCount1]->segment.trans.x_position, + objs[loopCount1]->segment.trans.y_position, + objs[loopCount1]->segment.trans.z_position); sndp_set_param(gRacerSound->unk50, AL_SNDP_VOL_EVT, temp_s3 << 8); sndp_set_param(gRacerSound->unk50, AL_SNDP_PITCH_EVT, *((u32 *) &sp8C)); sndp_set_priority(gRacerSound->unk50, 80); sndp_set_param(gRacerSound->unk50, AL_SNDP_PAN_EVT, gRacerSound->unk91[0]); } } else if (gRacerSound->unk50 != NULL) { + sndp_stop(gRacerSound->unk50); sndp_stop(gRacerSound->unk50); gRacerSound->unk50 = 0; } @@ -763,11 +764,11 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3 gRacerSound->unk48[loopCount2] = NULL; } else { if (gRacerSound->unk48[loopCount2] == NULL) { - func_80001F14(gRacerSound->unk0[loopCount2], (s32 *) &gRacerSound->unk48[loopCount2]); + func_80001F14(gRacerSound->unk0[loopCount2], &gRacerSound->unk48[loopCount2]); } if (gRacerSound->unk48[loopCount2] != NULL) { - audioline_reverb( - (s32 *) gRacerSound->unk48[loopCount2], objs[loopCount1]->segment.trans.x_position, + audspat_calculate_echo( + gRacerSound->unk48[loopCount2], objs[loopCount1]->segment.trans.x_position, objs[loopCount1]->segment.trans.y_position, objs[loopCount1]->segment.trans.z_position); sndp_set_param(gRacerSound->unk48[loopCount2], AL_SNDP_VOL_EVT, temp_s3 << 8); sndp_set_param(gRacerSound->unk48[loopCount2], AL_SNDP_PITCH_EVT, *((u32 *) &sp8C)); @@ -825,8 +826,8 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3 temp_s3 *= 0.8; if (gRacerSound->unk88 < temp_s3) { gRacerSound->unk88 = temp_s3; - gRacerSound->unk91[0] = - func_800090C0(tempxPos, tempzPos, segment->trans.rotation.y_rotation); + gRacerSound->unk91[0] = audspat_calculate_spatial_pan( + tempxPos, tempzPos, segment->trans.rotation.y_rotation); if (racer->raceFinished != 0) { func_80006BFC(objs[loopCount1], segment, objs[loopCount2], updateRate); } else { @@ -905,11 +906,11 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3 temp->unk74 = 2; } else { if (temp->unk48[0] == NULL) { - func_80001F14(temp->unk0[0], (s32 *) &temp->unk48[0]); + func_80001F14(temp->unk0[0], &temp->unk48[0]); } if (temp->unk48[0] != NULL) { - audioline_reverb((s32 *) temp->unk48[0], temp->racerPos.x, temp->racerPos.y, - temp->racerPos.z); + audspat_calculate_echo(temp->unk48[0], temp->racerPos.x, temp->racerPos.y, + temp->racerPos.z); sndp_set_param(temp->unk48[0], AL_SNDP_VOL_EVT, temp->unk88 << 8); sndp_set_param(temp->unk48[0], AL_SNDP_PITCH_EVT, *((u32 *) &temp->unk8C)); if (arg3 != 1) { diff --git a/src/audiosfx.h b/src/audiosfx.h index dad0fd0d..6bc66aa5 100644 --- a/src/audiosfx.h +++ b/src/audiosfx.h @@ -11,6 +11,7 @@ #define AL_SNDP_PLAY_EVT (1 << 0) #define AL_SNDP_RELEASE_EVT (1 << 1) +#define AL_SNDP_RELEASE_EVT (1 << 1) #define AL_SNDP_PAN_EVT (1 << 2) #define AL_SNDP_VOL_EVT (1 << 3) #define AL_SNDP_PITCH_EVT (1 << 4) @@ -116,23 +117,23 @@ extern void alEvtqPostEvent(ALEventQueue *evtq, ALEvent *evt, ALMicroTime delta) void sndp_set_global_volume(u32 volume); s32 sndp_get_global_volume(void); -void sndp_set_active_sound_limit(s32 numSounds); +void sndp_set_active_sound_limit(s32 numChannels); void sndp_init_player(audioMgrConfig *c); ALMicroTime sndp_voice_handler(void *node); void sndp_end(ALSoundState *state); u16 sndp_get_state_counts(u16 *numFree, u16 *numAllocated); void sndp_set_priority(ALSoundState *sndp, u8 priority); -ALSoundState *sndp_play(ALBank *bnk, s16 sndIndx, SoundHandle *handlePtr); +ALSoundState *sndp_play(ALBank *bnk, s16 sndIndx, SoundHandle *soundMask); void sndp_stop_all_looped(void); -void sndp_set_param(SoundHandle soundMask, s16 type, u32 paramValue); -u16 sndp_get_group_volume(u8 groupID); -void sndp_set_group_volume(u8 groupID, u16 volume); -void sndp_apply_pitch_slide(ALSoundState *soundState); -void sndp_stop_with_flags(u8 flags); -void sndp_stop(SoundHandle state); -ALSoundState *sndp_allocate(UNUSED ALBank *arg0, ALSound *sound); +void sndp_set_param(SoundHandle soundMask, s16 type, u32 volume); +u16 sndp_get_group_volume(u8 channel); +void sndp_set_group_volume(u8 channel, u16 volume); +void sndp_apply_pitch_slide(ALSoundState *voiceState); +void sndp_stop_with_flags(u8 event); +void sndp_stop(SoundHandle soundMask); +ALSoundState *sndp_allocate(UNUSED ALBank *arg0, ALSound *arg1); void sndp_deallocate(ALSoundState *); -ALSoundState *sndp_play_with_priority(ALBank *bank, s16 sndIndx, u8 priority, SoundHandle *handlePtr); +ALSoundState *sndp_play_with_priority(ALBank *bnk, s16 sndIndx, u8 priority, SoundHandle *soundMask); void sndp_handle_event(SoundPlayer *sndp, ALSndpEvent *event); #endif diff --git a/src/game.c b/src/game.c index 21e08ac2..f0ccc952 100644 --- a/src/game.c +++ b/src/game.c @@ -704,7 +704,7 @@ void clear_audio_and_track(void) { music_channel_reset_all(); free_lights(); free_track(); - audioline_reset(); + audspat_reset(); sound_volume_change(VOLUME_NORMAL); if (gCurrentLevelHeader->weatherEnable > 0) { weather_free(); diff --git a/src/game_ui.c b/src/game_ui.c index 66b4ccd4..091f9dd8 100644 --- a/src/game_ui.c +++ b/src/game_ui.c @@ -1864,10 +1864,11 @@ void hud_race_start(s32 countdown, s32 updateRate) { if (racer->vehicleID == VEHICLE_CAR) { if (get_random_number_from_range(0, 100) >= 96) { frequency = 1.25 - ((get_random_number_from_range(0, 7) * 0.5) / 7.0); - func_800095E8(76, randomRacer->segment.trans.x_position, randomRacer->segment.trans.y_position, - randomRacer->segment.trans.z_position, 4, - ((get_random_number_from_range(0, 7) * 63) / 7) + 24, frequency * 100.0f, - &gRaceStartSoundMask); + audspat_play_sound_direct( + 76, randomRacer->segment.trans.x_position, randomRacer->segment.trans.y_position, + randomRacer->segment.trans.z_position, AUDIO_POINT_FLAG_ONE_TIME_TRIGGER, + ((get_random_number_from_range(0, 7) * 63) / 7) + 24, frequency * 100.0f, + &gRaceStartSoundMask); } } } diff --git a/src/menu.c b/src/menu.c index 0f8905a3..a36c65ba 100644 --- a/src/menu.c +++ b/src/menu.c @@ -145,7 +145,7 @@ u16 gGhostChecksumIDsPak[6]; u8 gGhostLevelIDsMenu[6]; u8 gGhostCharacterIDsMenu[6]; UNUSED s32 D_801282D2_EEA82; -SoundMask *gMenuSoundMasks[MAXCONTROLLERS]; // Soundmask values +AudioPoint *gMenuSoundMasks[MAXCONTROLLERS]; // Soundmask values u8 gGhostVehicleIDsMenu[6]; UNUSED s8 sUnused_80126828; // Set to 0 in menu_init, and never used again. u16 gGhostChecksumIDsMenu[6]; @@ -167,9 +167,9 @@ s16 gMenuStickY[5]; s16 D_8012683A; s32 gCinematicSkipA; s32 gPostraceScaleOut; -SoundMask *gTrackTTSoundMask; +AudioPoint *gTrackTTSoundMask; s32 gCinematicSkipB; -SoundMask *D_80126848; +AudioPoint *D_80126848; s32 gCinematicMusicChangeOff; s32 gTitleDemoIndex; s32 gTitleRevealTimer; @@ -202,7 +202,7 @@ f32 gTrackSelectTargetY; char *gTrackMenuHubName; s32 gSelectedTrackX; s32 gSelectedTrackY; -SoundMask *gSoundOptionMask; +AudioPoint *gSoundOptionMask; s32 gSaveMenuOptionCountLower; SaveFileData *gSaveMenuFilesDest; s32 gSaveMenuOptionCountUpper; diff --git a/src/object_functions.c b/src/object_functions.c index e6a727fe..5e838a6e 100644 --- a/src/object_functions.c +++ b/src/object_functions.c @@ -150,8 +150,8 @@ void obj_loop_scenery(Object *obj, s32 updateRate) { properties->hitTimer -= updateRate; } if (obj->interactObj->flags & INTERACT_FLAGS_COLLIDED && properties->hitTimer <= 0) { - play_sound_at_position(SOUND_TWANG, obj->segment.trans.x_position, obj->segment.trans.y_position, - obj->segment.trans.z_position, 4, NULL); + audspat_play_sound_at_position(SOUND_TWANG, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, AUDIO_POINT_FLAG_ONE_TIME_TRIGGER, NULL); properties->interactObj = obj->interactObj->obj; properties->angleVel = 0x71C; properties->hitTimer = 10; @@ -309,8 +309,8 @@ void obj_loop_fireball_octoweapon(Object *obj, s32 updateRate) { if (soundMask != NULL) { sndp_stop(soundMask); } - play_sound_at_position(SOUND_POP, obj->segment.trans.x_position, obj->segment.trans.y_position, - obj->segment.trans.z_position, 4, NULL); + audspat_play_sound_at_position(SOUND_POP, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, AUDIO_POINT_FLAG_ONE_TIME_TRIGGER, NULL); free_object(obj); } } @@ -381,8 +381,9 @@ void obj_loop_lasergun(Object *obj, s32 updateRate) { spawnObj.z = obj->segment.trans.z_position; spawnObj.size = sizeof(LevelObjectEntryCommon); spawnObj.objectID = ASSET_OBJECT_ID_LASERBOLT; - play_sound_at_position(SOUND_LASER_GUN, obj->segment.trans.x_position, obj->segment.trans.y_position, - obj->segment.trans.z_position, 4, NULL); + audspat_play_sound_at_position(SOUND_LASER_GUN, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, + AUDIO_POINT_FLAG_ONE_TIME_TRIGGER, NULL); laserBoltObj = spawn_object(&spawnObj, 1); if (laserBoltObj != NULL) { laserBoltObj->segment.level_entry = NULL; @@ -1942,9 +1943,10 @@ void obj_loop_wizpigship(Object *wizShipObj, s32 updateRate) { newObj->properties.lasergun.timer = 0x3C; guMtxXFMF(laserMtx, 0.0f, 0.0f, -30.0f, &newObj->segment.x_velocity, &newObj->segment.y_velocity, &newObj->segment.z_velocity); - play_sound_at_position(SOUND_LASER_GUN, wizShipObj->segment.trans.x_position, - wizShipObj->segment.trans.y_position, - wizShipObj->segment.trans.z_position, 4, NULL); + audspat_play_sound_at_position(SOUND_LASER_GUN, wizShipObj->segment.trans.x_position, + wizShipObj->segment.trans.y_position, + wizShipObj->segment.trans.z_position, + AUDIO_POINT_FLAG_ONE_TIME_TRIGGER, NULL); } } } @@ -2021,11 +2023,12 @@ void obj_loop_snowball(Object *obj, s32 updateRate) { } if (obj64->currentSound != SOUND_NONE) { if (obj64->soundMask == NULL) { - play_sound_at_position(obj64->currentSound, obj->segment.trans.x_position, obj->segment.trans.y_position, - obj->segment.trans.z_position, 1, (SoundMask **) &obj64->soundMask); + audspat_play_sound_at_position(obj64->currentSound, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, + AUDIO_POINT_FLAG_1, (AudioPoint **) &obj64->soundMask); } else { - update_spatial_audio_position((SoundMask *) obj64->soundMask, obj->segment.trans.x_position, - obj->segment.trans.y_position, obj->segment.trans.z_position); + audspat_point_set_position((AudioPoint *) obj64->soundMask, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position); } } func_8001F460(obj, updateRate, obj); @@ -2496,8 +2499,9 @@ void obj_loop_dino_whale(Object *obj, s32 updateRate) { if (obj->interactObj->distance < 255) { if (obj->properties.common.unk0 == 0) { obj->properties.common.unk0 = 60; - play_sound_at_position(SOUND_VOICE_BRONTO_ROAR, obj->segment.trans.x_position, - obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); + audspat_play_sound_at_position(SOUND_VOICE_BRONTO_ROAR, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, + AUDIO_POINT_FLAG_ONE_TIME_TRIGGER, NULL); } } } @@ -2618,7 +2622,7 @@ void obj_loop_parkwarden(Object *obj, s32 updateRate) { racer_sound_free(racerObj); racer->vehicleSound = NULL; } - audioline_off(); + audspat_jingle_off(); arctan = arctan2_f(racerObj->segment.trans.x_position - obj->segment.trans.x_position, racerObj->segment.trans.z_position - obj->segment.trans.z_position); arctan -= (racerObj->segment.trans.rotation.y_rotation & 0xFFFF); @@ -2776,7 +2780,7 @@ void obj_loop_parkwarden(Object *obj, s32 updateRate) { music_voicelimit_set(levelHeader->voiceLimit); music_play(levelHeader->music); music_dynamic_set(levelHeader->instruments); - audioline_on(); + audspat_jingle_on(); } if (dialogueID & 0x80) { gTajDialogueChoice = dialogueID & 0x7F; @@ -3045,7 +3049,7 @@ void obj_loop_parkwarden(Object *obj, s32 updateRate) { temp_v0_22 = get_cutscene_camera_segment(); xPosDiff = obj->segment.trans.x_position - temp_v0_22->trans.x_position; zPosDiff = obj->segment.trans.z_position - temp_v0_22->trans.z_position; - arctan = func_800090C0(xPosDiff, zPosDiff, temp_v0_22->trans.rotation.y_rotation); + arctan = audspat_calculate_spatial_pan(xPosDiff, zPosDiff, temp_v0_22->trans.rotation.y_rotation); temp = arctan; music_channel_fade_set(10, sp3C); music_channel_fade_set(11, sp3C); @@ -3331,9 +3335,9 @@ void obj_loop_bonus(Object *obj, UNUSED s32 updateRate) { if (temp < 0.0f) { if (racer->bananas < 10) { racer->bananas = 10; - play_sound_at_position(SOUND_SELECT, racerObj->segment.trans.x_position, - racerObj->segment.trans.y_position, - racerObj->segment.trans.z_position, 4, NULL); + audspat_play_sound_at_position( + SOUND_SELECT, racerObj->segment.trans.x_position, racerObj->segment.trans.y_position, + racerObj->segment.trans.z_position, AUDIO_POINT_FLAG_ONE_TIME_TRIGGER, NULL); sound_play_spatial(racer->characterId + SOUND_UNK_7B, racerObj->segment.trans.x_position, racerObj->segment.trans.y_position, racerObj->segment.trans.z_position, NULL); @@ -3569,7 +3573,7 @@ void obj_loop_door(Object *doorObj, s32 updateRate) { music_fade(-8); door->jingleTimer = 140; // PAL users once again forsaken. music_jingle_voicelimit_set(16); - audioline_off(); + audspat_jingle_off(); music_jingle_play(SEQUENCE_NO_TROPHY_FOR_YOU); set_textbox_display_value(door->balloonCount); set_current_text(door->textID & 0xFF); @@ -3588,7 +3592,7 @@ void obj_loop_door(Object *doorObj, s32 updateRate) { door->jingleTimer = 0; music_fade(8); music_jingle_voicelimit_set(6); - audioline_on(); + audspat_jingle_on(); } } if (door->jingleCooldown > 0) { @@ -3697,14 +3701,14 @@ void obj_loop_door(Object *doorObj, s32 updateRate) { } if (playSound) { if (door->soundMask == NULL) { - play_sound_at_position(SOUND_DOOR_OPEN, doorObj->segment.trans.x_position, - doorObj->segment.trans.y_position, doorObj->segment.trans.z_position, 1, - &door->soundMask); + audspat_play_sound_at_position(SOUND_DOOR_OPEN, doorObj->segment.trans.x_position, + doorObj->segment.trans.y_position, doorObj->segment.trans.z_position, + AUDIO_POINT_FLAG_1, &door->soundMask); } } else { door->openDir = DOOR_CLOSED; if (door->soundMask != NULL) { - func_800096F8((SoundMask *) (s32) door->soundMask); + audspat_point_stop((AudioPoint *) (s32) door->soundMask); door->soundMask = NULL; } } @@ -3839,11 +3843,12 @@ void obj_loop_ttdoor(Object *obj, s32 updateRate) { } if (openDoor) { if (ttDoor->soundMask == NULL) { - play_sound_at_position(SOUND_DOOR_OPEN, obj->segment.trans.x_position, obj->segment.trans.y_position, - obj->segment.trans.z_position, 1, &ttDoor->soundMask); + audspat_play_sound_at_position(SOUND_DOOR_OPEN, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, 1, + &ttDoor->soundMask); } } else if (ttDoor->soundMask != NULL) { - func_800096F8((SoundMask *) ((s32) ttDoor->soundMask)); + audspat_point_stop((AudioPoint *) ((s32) ttDoor->soundMask)); ttDoor->soundMask = NULL; } obj->interactObj->distance = 0xFF; @@ -4020,19 +4025,19 @@ void obj_loop_bridge_whaleramp(Object *obj, s32 updateRate) { } if (whaleRamp->soundMask == NULL) { obj_bridge_pos(entry->unkA, &bellX1, &bellY1, &bellZ1); - play_sound_at_position(SOUND_DRAWBRIDGE_BELL, bellX1, bellY1, bellZ1, 1, &whaleRamp->soundMask); + audspat_play_sound_at_position(SOUND_DRAWBRIDGE_BELL, bellX1, bellY1, bellZ1, 1, &whaleRamp->soundMask); } } else { if (obj->segment.trans.rotation.x_rotation < 0) { obj->segment.trans.rotation.x_rotation += updateRate * 0x28; if (whaleRamp->soundMask == NULL) { obj_bridge_pos(entry->unkA, &bellX2, &bellY2, &bellZ2); - play_sound_at_position(SOUND_DRAWBRIDGE_BELL, bellX2, bellY2, bellZ2, 1, &whaleRamp->soundMask); + audspat_play_sound_at_position(SOUND_DRAWBRIDGE_BELL, bellX2, bellY2, bellZ2, 1, &whaleRamp->soundMask); } } else { obj->segment.trans.rotation.x_rotation = 0; if (whaleRamp->soundMask != NULL) { - func_800096F8(whaleRamp->soundMask); + audspat_point_stop(whaleRamp->soundMask); } } } @@ -4340,7 +4345,7 @@ void obj_loop_banana(Object *obj, s32 updateRate) { s8 sp43; Object_Banana *banana; ObjPropertyBanana *properties; - SoundMask *prevSoundMask; + AudioPoint *prevSoundMask; updateRateF = updateRate; if (osTvType == OS_TV_TYPE_PAL) { @@ -4432,11 +4437,11 @@ void obj_loop_banana(Object *obj, s32 updateRate) { racer = (Object_Racer *) racerObj->unk64; if (get_current_level_race_type() != RACETYPE_CHALLENGE_BANANAS || racer->bananas < 2) { prevSoundMask = racer->bananaSoundMask; - play_sound_at_position(SOUND_SELECT, racerObj->segment.trans.x_position, - racerObj->segment.trans.y_position, racerObj->segment.trans.z_position, 4, - &racer->bananaSoundMask); + audspat_play_sound_at_position(SOUND_SELECT, racerObj->segment.trans.x_position, + racerObj->segment.trans.y_position, + racerObj->segment.trans.z_position, 4, &racer->bananaSoundMask); if (prevSoundMask) { - func_800096F8(prevSoundMask); + audspat_point_stop(prevSoundMask); } if (racer->playerIndex != PLAYER_COMPUTER && racer->bananas == 9) { sound_play_spatial(racer->characterId + SOUND_UNK_7B, racerObj->segment.trans.x_position, @@ -4739,9 +4744,9 @@ void obj_loop_weaponballoon(Object *weaponBalloonObj, s32 updateRate) { weaponBalloonObj->properties.weaponBalloon.particleTimer = 16; } if (racer->playerIndex == PLAYER_COMPUTER) { - play_sound_at_position(SOUND_BALLOON_POP, weaponBalloonObj->segment.trans.x_position, - weaponBalloonObj->segment.trans.y_position, - weaponBalloonObj->segment.trans.z_position, 4, NULL); + audspat_play_sound_at_position(SOUND_BALLOON_POP, weaponBalloonObj->segment.trans.x_position, + weaponBalloonObj->segment.trans.y_position, + weaponBalloonObj->segment.trans.z_position, 4, NULL); } else { if (levelMask == racer->balloon_level) { if (racer->raceFinished == FALSE) { @@ -4753,10 +4758,10 @@ void obj_loop_weaponballoon(Object *weaponBalloonObj, s32 updateRate) { } sound_play(SOUND_COLLECT_ITEM + prevBalloonQuantity, NULL); } else { - play_sound_at_position(SOUND_BALLOON_POP, - weaponBalloonObj->segment.trans.x_position, - weaponBalloonObj->segment.trans.y_position, - weaponBalloonObj->segment.trans.z_position, 4, NULL); + audspat_play_sound_at_position(SOUND_BALLOON_POP, + weaponBalloonObj->segment.trans.x_position, + weaponBalloonObj->segment.trans.y_position, + weaponBalloonObj->segment.trans.z_position, 4, NULL); } } } else if (racer->raceFinished == FALSE) { @@ -5132,17 +5137,17 @@ void play_rocket_trailing_sound(Object *obj, struct Object_Weapon *weapon, u16 s if (shouldPlaySound) { if (weapon->soundMask == NULL) { if (gRocketSoundTimer < 8) { - play_sound_at_position(soundID, obj->segment.trans.x_position, obj->segment.trans.y_position, - obj->segment.trans.z_position, 1, &weapon->soundMask); + audspat_play_sound_at_position(soundID, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 1, &weapon->soundMask); gRocketSoundTimer++; } } else { - update_spatial_audio_position(weapon->soundMask, obj->segment.trans.x_position, - obj->segment.trans.y_position, obj->segment.trans.z_position); + audspat_point_set_position(weapon->soundMask, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position); } } else { if (weapon->soundMask) { - func_800096F8(weapon->soundMask); + audspat_point_stop(weapon->soundMask); weapon->soundMask = NULL; gRocketSoundTimer -= 1; } @@ -5255,12 +5260,12 @@ void weapon_trap(Object *weaponObj, s32 updateRate) { if (weaponProperties->submerged > 120) { weaponProperties->status = WEAPON_DESTROY; if (weapon->soundMask != NULL) { - func_800096F8(weapon->soundMask); + audspat_point_stop(weapon->soundMask); weapon->soundMask = NULL; } - play_sound_at_position(SOUND_POP, weaponObj->segment.trans.x_position, - weaponObj->segment.trans.y_position, weaponObj->segment.trans.z_position, 4, - NULL); + audspat_play_sound_at_position(SOUND_POP, weaponObj->segment.trans.x_position, + weaponObj->segment.trans.y_position, weaponObj->segment.trans.z_position, + 4, NULL); } } if (weaponProperties->status == WEAPON_DESTROY) { @@ -5308,16 +5313,16 @@ void weapon_trap(Object *weaponObj, s32 updateRate) { if (weaponHit->shieldTimer > 0 && weaponHit->shieldType >= SHIELD_LEVEL3) { weaponProperties->status = WEAPON_DESTROY; - play_sound_at_position(SOUND_POP, weaponObj->segment.trans.x_position, - weaponObj->segment.trans.y_position, - weaponObj->segment.trans.z_position, 4, NULL); + audspat_play_sound_at_position(SOUND_POP, weaponObj->segment.trans.x_position, + weaponObj->segment.trans.y_position, + weaponObj->segment.trans.z_position, 4, NULL); } else { weapon->target = weaponInteractObj; - play_sound_at_position(SOUND_BUBBLE, weaponInteractObj->segment.trans.x_position, - weaponInteractObj->segment.trans.y_position, - weaponInteractObj->segment.trans.z_position, 4, - &weapon->soundMask); + audspat_play_sound_at_position( + SOUND_BUBBLE, weaponInteractObj->segment.trans.x_position, + weaponInteractObj->segment.trans.y_position, + weaponInteractObj->segment.trans.z_position, 4, &weapon->soundMask); weaponHit->attackType = ATTACK_BUBBLE; weaponProperties->status = WEAPON_TRIGGERED; weaponProperties->submerged = 0; @@ -5348,9 +5353,9 @@ void weapon_trap(Object *weaponObj, s32 updateRate) { weaponProperties->status = WEAPON_TRIGGERED; } else if (weapon->weaponID == WEAPON_BUBBLE_TRAP) { weaponProperties->status = WEAPON_DESTROY; - play_sound_at_position(SOUND_POP, weaponObj->segment.trans.x_position, - weaponObj->segment.trans.y_position, weaponObj->segment.trans.z_position, 4, - NULL); + audspat_play_sound_at_position(SOUND_POP, weaponObj->segment.trans.x_position, + weaponObj->segment.trans.y_position, + weaponObj->segment.trans.z_position, 4, NULL); } else { obj_spawn_effect(weaponObj->segment.trans.x_position, weaponObj->segment.trans.y_position, weaponObj->segment.trans.z_position, ASSET_OBJECT_ID_BOMBEXPLOSION, @@ -5385,7 +5390,7 @@ void obj_spawn_effect(f32 x, f32 y, f32 z, s32 objectID, s32 soundID, f32 scale, newObj->segment.trans.scale = newObj->segment.trans.scale * 3.5 * scale; } if (soundID != SOUND_NONE) { - play_sound_at_position(soundID, x, y, z, 4, NULL); + audspat_play_sound_at_position(soundID, x, y, z, 4, NULL); } } @@ -5402,11 +5407,11 @@ void obj_init_audio(Object *obj, LevelObjectEntry_Audio *entry) { obj64->unkD = entry->unk10; obj64->soundMask = NULL; if (gSoundBank_GetSoundDecayTime(obj64->soundId)) { - func_8000974C(obj64->soundId, entry->common.x, entry->common.y, entry->common.z, 9, obj64->unk5, obj64->unk4, - obj64->unk2, obj64->unkC, obj64->unk6, obj64->unkD, &obj64->soundMask); + audspat_point_create(obj64->soundId, entry->common.x, entry->common.y, entry->common.z, 9, obj64->unk5, + obj64->unk4, obj64->unk2, obj64->unkC, obj64->unk6, obj64->unkD, &obj64->soundMask); } else { - func_8000974C(obj64->soundId, entry->common.x, entry->common.y, entry->common.z, 10, obj64->unk5, obj64->unk4, - obj64->unk2, obj64->unkC, obj64->unk6, obj64->unkD, &obj64->soundMask); + audspat_point_create(obj64->soundId, entry->common.x, entry->common.y, entry->common.z, 10, obj64->unk5, + obj64->unk4, obj64->unk2, obj64->unkC, obj64->unk6, obj64->unkD, &obj64->soundMask); } free_object(obj); } @@ -5427,9 +5432,9 @@ void obj_init_audioline(Object *obj, LevelObjectEntry_AudioLine *entry) { audLine->unkE = entry->unk9; audLine->unkF = entry->unk10; audLine->unk12 = entry->unk13; - audioline_ambient_create(audLine->unk0, audLine->soundID, entry->common.x, entry->common.y, entry->common.z, - audLine->unkF, audLine->unkE, audLine->unk10, audLine->unk12, audLine->unk4, - audLine->unk11, audLine->lineID, audLine->unkD); + audspat_line_add_vertex(audLine->unk0, audLine->soundID, entry->common.x, entry->common.y, entry->common.z, + audLine->unkF, audLine->unkE, audLine->unk10, audLine->unk12, audLine->unk4, audLine->unk11, + audLine->lineID, audLine->unkD); free_object(obj); } @@ -5440,8 +5445,8 @@ void obj_init_audioreverb(Object *obj, LevelObjectEntry_AudioReverb *entry) { temp = entry->lineID; reverb->lineID = temp & 0xFF; reverb->unk5 = entry->unkA; - audioline_reverb_create(entry->common.x, entry->common.y, entry->common.z, reverb->unk2, reverb->lineID, - reverb->unk5); + audspat_reverb_add_vertex(entry->common.x, entry->common.y, entry->common.z, reverb->unk2, reverb->lineID, + reverb->unk5); free_object(obj); } @@ -6411,8 +6416,9 @@ void obj_loop_frog(Object *obj, s32 updateRate) { diffZ = obj->segment.trans.z_position - racerObj->segment.trans.z_position; if (frog->squishCooldown <= 0 && (diffX * diffX) + (diffY * diffY) + (diffZ * diffZ) < 40.0f * 40.0f) { if (frog->drumstick) { - play_sound_at_position(SOUND_VOICE_DRUMSTICK_POSITIVE2, obj->segment.trans.x_position, - obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); + audspat_play_sound_at_position(SOUND_VOICE_DRUMSTICK_POSITIVE2, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, 4, + NULL); set_eeprom_settings_value(2); set_magic_code_flags(CHEAT_CONTROL_DRUMSTICK); set_drumstick_unlock_transition(); @@ -6420,8 +6426,9 @@ void obj_loop_frog(Object *obj, s32 updateRate) { break; } else { frog->action = FROG_SQUISH; - play_sound_at_position(SOUND_SPLAT, obj->segment.trans.x_position, - obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); + audspat_play_sound_at_position(SOUND_SPLAT, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, 4, + NULL); } } else { frog->forwardVel = 72.0f; @@ -6458,11 +6465,13 @@ void obj_loop_frog(Object *obj, s32 updateRate) { frog->hopDirection = arctan2_f(diffX, diffZ); } if (frog->drumstick) { - play_sound_at_position(SOUND_VOICE_DRUMSTICK_POSITIVE6, obj->segment.trans.x_position, - obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); + audspat_play_sound_at_position(SOUND_VOICE_DRUMSTICK_POSITIVE6, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, 4, + NULL); } else { - play_sound_at_position(SOUND_RIBBIT, obj->segment.trans.x_position, obj->segment.trans.y_position, - obj->segment.trans.z_position, 4, NULL); + audspat_play_sound_at_position(SOUND_RIBBIT, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, 4, + NULL); } frog->action = FROG_HOP; frog->hopStartX = obj->segment.trans.x_position; @@ -6500,16 +6509,18 @@ void obj_loop_frog(Object *obj, s32 updateRate) { if (obj_dist_racer(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 40.0f, 0, &racerObj)) { if (frog->drumstick) { - play_sound_at_position(SOUND_VOICE_DRUMSTICK_POSITIVE2, obj->segment.trans.x_position, - obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); + audspat_play_sound_at_position(SOUND_VOICE_DRUMSTICK_POSITIVE2, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, 4, + NULL); set_eeprom_settings_value(2); set_magic_code_flags(CHEAT_CONTROL_DRUMSTICK); set_drumstick_unlock_transition(); free_object(obj); } else { frog->action = FROG_SQUISH; - play_sound_at_position(SOUND_SPLAT, obj->segment.trans.x_position, - obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); + audspat_play_sound_at_position(SOUND_SPLAT, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, 4, + NULL); } } } @@ -6526,8 +6537,8 @@ void obj_loop_frog(Object *obj, s32 updateRate) { frog->hopTimer -= updateRate; if (frog->hopTimer < 0) { frog->action = FROG_UNSQUISH; - play_sound_at_position(SOUND_PLOP2, obj->segment.trans.x_position, obj->segment.trans.y_position, - obj->segment.trans.z_position, 4, NULL); + audspat_play_sound_at_position(SOUND_PLOP2, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); } break; case FROG_UNSQUISH: diff --git a/src/objects.c b/src/objects.c index 51347490..05c52dea 100644 --- a/src/objects.c +++ b/src/objects.c @@ -2386,7 +2386,7 @@ void obj_update(s32 updateRate) { race_transition_adventure(updateRate); } } - func_80008438(gRacersByPort, gNumRacers, updateRate); + audspat_update_all(gRacersByPort, gNumRacers, updateRate); gPathUpdateOff = TRUE; gObjectUpdateRateF = (f32) updateRate; D_8011AD24[0] = 0; @@ -2565,8 +2565,8 @@ s32 play_footstep_sounds(Object *obj, s32 arg1, s32 frame, s32 oddSoundId, s32 e } else { soundId = evenSoundId; // Always set to SOUND_STOMP3 } - play_sound_at_position(soundId, obj->segment.trans.x_position, obj->segment.trans.y_position, - obj->segment.trans.z_position, 4, NULL); + audspat_play_sound_at_position(soundId, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 4, NULL); ret = i + 1; i = asset0; // Come on, just use break! } @@ -4482,7 +4482,7 @@ void race_transition_adventure(s32 updateRate) { sndp_stop(racer->magnetSoundMask); } if (racer->shieldSoundMask != NULL) { - func_800096F8(racer->shieldSoundMask); + audspat_point_stop(racer->shieldSoundMask); } } prevPort0Racer = (*gRacers)[0]; @@ -6479,7 +6479,7 @@ void mode_end_taj_race(s32 reason) { music_change_on(); music_stop(); set_next_taj_challenge_menu(0); - audioline_on(); + audspat_jingle_on(); if (reason == CHALLENGE_END_OOB) { set_current_text(ASSET_GAME_TEXT_0); } diff --git a/src/objects.h b/src/objects.h index 829d2f5d..bd90c9fb 100644 --- a/src/objects.h +++ b/src/objects.h @@ -537,7 +537,7 @@ void spectate_update(void); void func_8001E93C(void); void func_80019808(s32 updateRate); void func_80014090(Object*, s32, ObjectHeader*); -void func_80008438(Object**, s32, s32); +void audspat_update_all(Object**, s32, s32); void func_8001E89C(void); CheckpointNode *func_800230D0(Object*, Object_Racer*); void obj_update(s32 updateRate); diff --git a/src/racer.c b/src/racer.c index 4e28f4cb..e0939e72 100644 --- a/src/racer.c +++ b/src/racer.c @@ -2854,14 +2854,15 @@ void update_player_racer(Object *obj, s32 updateRate) { if (tempRacer->shieldTimer > 0) { if (tempRacer->shieldTimer > 60) { if (tempRacer->shieldSoundMask) { - update_spatial_audio_position(tempRacer->shieldSoundMask, obj->segment.trans.x_position, - obj->segment.trans.y_position, obj->segment.trans.z_position); + audspat_point_set_position(tempRacer->shieldSoundMask, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position); } else if (tempRacer->vehicleSound) { - play_sound_at_position(SOUND_SHIELD, obj->segment.trans.x_position, obj->segment.trans.y_position, - obj->segment.trans.z_position, 1, &tempRacer->shieldSoundMask); + audspat_play_sound_at_position(SOUND_SHIELD, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, 1, + &tempRacer->shieldSoundMask); } } else if (tempRacer->shieldSoundMask) { - func_800096F8(tempRacer->shieldSoundMask); + audspat_point_stop(tempRacer->shieldSoundMask); tempRacer->shieldSoundMask = NULL; } tempRacer->shieldTimer -= updateRate; @@ -2870,15 +2871,15 @@ void update_player_racer(Object *obj, s32 updateRate) { } } if (tempRacer->bananaSoundMask) { - update_spatial_audio_position(tempRacer->bananaSoundMask, obj->segment.trans.x_position, - obj->segment.trans.y_position, obj->segment.trans.z_position); + audspat_point_set_position(tempRacer->bananaSoundMask, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position); } if (is_in_time_trial() && tempRacer->playerIndex == PLAYER_ONE && gRaceStartTimer == 0) { timetrial_ghost_write(obj, updateRate); } if (tempRacer->soundMask) { - update_spatial_audio_position(tempRacer->soundMask, obj->segment.trans.x_position, - obj->segment.trans.y_position, obj->segment.trans.z_position); + audspat_point_set_position(tempRacer->soundMask, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position); } gRacerInputBlocked = 0; if (tempRacer->unk150 && gRaceStartTimer == 0) { @@ -2907,8 +2908,9 @@ void update_player_racer(Object *obj, s32 updateRate) { } else { tempRacer->delaySoundTimer = 0; if (tempRacer->playerIndex == PLAYER_COMPUTER) { - play_sound_at_position(tempRacer->delaySoundID, obj->segment.trans.x_position, - obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); + audspat_play_sound_at_position(tempRacer->delaySoundID, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, 4, + NULL); } else { sound_play_spatial(tempRacer->delaySoundID, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, NULL); @@ -3056,7 +3058,7 @@ void func_8004F7F4(s32 updateRate, f32 updateRateF, Object *racerObj, Object_Rac update_car_velocity_offground(racerObj, racer, updateRate, updateRateF); } if (racer->unk1C != 0) { - sndp_stop((SoundHandle) (s32) racer->unk1C); // type cast required to match + sndp_stop((s32) racer->unk1C); // type cast required to match racer->unk1C = 0; } if (racer->buoyancy != 0.0f && racer->vehicleIDPrev != VEHICLE_BUBBLER) { @@ -3519,23 +3521,23 @@ void func_80050A28(Object *obj, Object_Racer *racer, s32 updateRate, f32 updateR sound_play_spatial(SOUND_CAR_SLIDE, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, &racer->unk10); } else { - audioline_reverb((SoundHandle) (s32) racer->unk10, obj->segment.trans.x_position, obj->segment.trans.y_position, - obj->segment.trans.z_position); + audspat_calculate_echo((s32) racer->unk10, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position); } if (racer->unk14) { - sndp_stop((SoundHandle) (s32) racer->unk14); // type cast required to match + sndp_stop((s32) racer->unk14); // type cast required to match } } else { if (racer->unk10) { - sndp_stop((SoundHandle) (s32) racer->unk10); // type cast required to match + sndp_stop((s32) racer->unk10); // type cast required to match } } } else { if (racer->unk10) { - sndp_stop((SoundHandle) (s32) racer->unk10); // type cast required to match + sndp_stop((s32) racer->unk10); // type cast required to match } if (racer->unk14) { - sndp_stop((SoundHandle) (s32) racer->unk14); // type cast required to match + sndp_stop((s32) racer->unk14); // type cast required to match } } // Velocity of steering input @@ -3714,7 +3716,7 @@ void func_80050A28(Object *obj, Object_Racer *racer, s32 updateRate, f32 updateR sound_play(surfaceType, &racer->unk18); } if (racer->unk18 != 0 && (surfaceType == SOUND_NONE || racer->velocity > -2.0)) { - sndp_stop((SoundHandle) (s32) racer->unk18); // type cast required to match + sndp_stop((s32) racer->unk18); // type cast required to match } // Apply a bobbing effect when on grass and sand. if (racer->velocity < -2.0 && sp68 >= 4) { @@ -4170,13 +4172,13 @@ void update_car_velocity_offground(Object *obj, Object_Racer *racer, s32 updateR racer->x_rotation_vel += (angle >> 3); //!@Delta } if (racer->unk18) { - sndp_stop((SoundHandle) (s32) racer->unk18); // type cast required to match + sndp_stop((s32) racer->unk18); // type cast required to match } if (racer->unk10) { - sndp_stop((SoundHandle) (s32) racer->unk10); // type cast required to match + sndp_stop((s32) racer->unk10); // type cast required to match } if (racer->unk14) { - sndp_stop((SoundHandle) (s32) racer->unk14); // type cast required to match + sndp_stop((s32) racer->unk14); // type cast required to match } if (racer->unk1FE == 1 || racer->unk1FE == 3) { racer->unk1E8 = racer->steerAngle; @@ -5470,9 +5472,9 @@ void handle_racer_items(Object *obj, Object_Racer *racer, UNUSED s32 updateRate) } if (soundID != SOUND_NONE) { if (racer->playerIndex == PLAYER_COMPUTER) { - play_sound_at_position(soundID, obj->segment.trans.x_position, - obj->segment.trans.y_position, obj->segment.trans.z_position, 4, - NULL); + audspat_play_sound_at_position(soundID, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, + 4, NULL); } else { if (racer->weaponSoundMask) { sndp_stop(racer->weaponSoundMask); @@ -5671,7 +5673,7 @@ void play_random_character_voice(Object *obj, s32 soundID, s32 range, s32 flags) if (tempRacer->exitObj == 0 && (!(flags & 0x80) || gCurrentPlayerIndex != PLAYER_COMPUTER)) { if (flags == 2) { if (tempRacer->soundMask != NULL && soundID != tempRacer->unk2A) { - func_800096F8(tempRacer->soundMask); + audspat_point_stop(tempRacer->soundMask); tempRacer->soundMask = 0; } } @@ -5684,8 +5686,8 @@ void play_random_character_voice(Object *obj, s32 soundID, s32 range, s32 flags) soundIndex = (get_random_number_from_range(0, range - 1) * 12) + soundID; } } - play_sound_at_position(soundIndex, obj->segment.trans.x_position, obj->segment.trans.y_position, - obj->segment.trans.z_position, 4, &tempRacer->soundMask); + audspat_play_sound_at_position(soundIndex, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 4, &tempRacer->soundMask); tempRacer->lastSoundID = soundIndex; } } @@ -7180,15 +7182,16 @@ void update_AI_racer(Object *obj, Object_Racer *racer, s32 updateRate, f32 updat if (racer->shieldTimer > 0) { if (racer->shieldTimer > 60) { if (racer->shieldSoundMask) { - update_spatial_audio_position(racer->shieldSoundMask, obj->segment.trans.x_position, - obj->segment.trans.y_position, obj->segment.trans.z_position); + audspat_point_set_position(racer->shieldSoundMask, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position); } else if (racer->vehicleSound) { - play_sound_at_position(SOUND_SHIELD, obj->segment.trans.x_position, obj->segment.trans.y_position, - obj->segment.trans.z_position, 1, &racer->shieldSoundMask); + audspat_play_sound_at_position(SOUND_SHIELD, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, 1, + &racer->shieldSoundMask); } } else { if (racer->shieldSoundMask) { - func_800096F8(racer->shieldSoundMask); + audspat_point_stop(racer->shieldSoundMask); racer->shieldSoundMask = NULL; } } @@ -7198,8 +7201,8 @@ void update_AI_racer(Object *obj, Object_Racer *racer, s32 updateRate, f32 updat } } if (racer->soundMask != NULL) { - update_spatial_audio_position(racer->soundMask, obj->segment.trans.x_position, obj->segment.trans.y_position, - obj->segment.trans.z_position); + audspat_point_set_position(racer->soundMask, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position); } gRacerInputBlocked = FALSE; if ((racer->unk150 != NULL) && (gRaceStartTimer == 0)) { diff --git a/src/thread3_main.c b/src/thread3_main.c index ab98c8a4..a11081a3 100644 --- a/src/thread3_main.c +++ b/src/thread3_main.c @@ -212,7 +212,7 @@ void init_game(void) { init_PI_mesg_queue(); gfxtask_init(&gMainSched); audio_init(&gMainSched); - audioline_init(); + audspat_init(); sControllerStatus = input_init(); tex_init_textures(); allocate_object_model_pools(); diff --git a/src/vehicle_smokey.c b/src/vehicle_smokey.c index 1734d86b..a0c9bfb8 100644 --- a/src/vehicle_smokey.c +++ b/src/vehicle_smokey.c @@ -227,8 +227,8 @@ void update_smokey(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r stepFrame = 3; } if (animFrame == stepFrame && stepFrame + 1 == obj->segment.animFrame >> 4) { - play_sound_at_position(SOUND_UNK_223, obj->segment.trans.x_position, obj->segment.trans.y_position, - obj->segment.trans.z_position, 4, NULL); + audspat_play_sound_at_position(SOUND_UNK_223, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 4, NULL); } } if (racer->vehicleIDPrev == VEHICLE_SMOKEY && racer->playerIndex == PLAYER_COMPUTER && func_80023568()) { @@ -318,9 +318,9 @@ void spawn_boss_hazard(Object *obj, Object_Racer *racer, f32 offset, s32 objectI newObj->properties.racer.unk0 = tempObj; newObj->properties.racer.unk4 = (s8) entry->animation.y_rotation * 60; newObj->segment.animFrame = get_random_number_from_range(0, 255); - play_sound_at_position(soundID, newObj->segment.trans.x_position, - newObj->segment.trans.y_position, newObj->segment.trans.z_position, - 4, NULL); + audspat_play_sound_at_position(soundID, newObj->segment.trans.x_position, + newObj->segment.trans.y_position, + newObj->segment.trans.z_position, 4, NULL); } } } else { diff --git a/src/vehicle_tricky.c b/src/vehicle_tricky.c index fff21263..c4ceb017 100644 --- a/src/vehicle_tricky.c +++ b/src/vehicle_tricky.c @@ -232,7 +232,7 @@ void racer_boss_sound_spatial(f32 x, f32 y, f32 z, s32 offset) { randomOffset = 0; } offset += randomOffset; - play_sound_at_position(gBossSoundIDOffset[offset], x, y, z, 4, NULL); + audspat_play_sound_at_position(gBossSoundIDOffset[offset], x, y, z, 4, NULL); } /** diff --git a/src/weather.c b/src/weather.c index 21de1a9f..7c5a7608 100644 --- a/src/weather.c +++ b/src/weather.c @@ -116,7 +116,7 @@ s32 gRainSplashDelay = 0; TextureHeader *gRainOverlayUnusedValue = NULL; // Set, but never read. Sprite *gRainSplashGfx = NULL; s32 gRainVertexFlip = 0; -SoundMask *gWeatherSoundMask = NULL; +AudioPoint *gWeatherSoundMask = NULL; FadeTransition gThunderTransition = FADE_TRANSITION(FADE_FULLSCREEN, FADE_FLAG_INVERT, FADE_COLOR_WHITE, 5, 2); @@ -831,7 +831,7 @@ void free_rain_memory(void) { } if (gWeatherSoundMask != NULL) { - func_800096F8(gWeatherSoundMask); + audspat_point_stop(gWeatherSoundMask); gWeatherSoundMask = NULL; } @@ -1066,9 +1066,9 @@ void rain_sound(UNUSED s32 updateRate) { yPos = gWeatherCamera->trans.y_position; zPos = gWeatherCamera->trans.z_position + (-sineOffset - cosOffset); if (gWeatherSoundMask) { - update_spatial_audio_position(gWeatherSoundMask, xPos, yPos, zPos); + audspat_point_set_position(gWeatherSoundMask, xPos, yPos, zPos); } else { - play_sound_at_position(SOUND_RAIN, xPos, yPos, zPos, 1, &gWeatherSoundMask); + audspat_play_sound_at_position(SOUND_RAIN, xPos, yPos, zPos, 1, &gWeatherSoundMask); } } diff --git a/ver/symbols/symbol_addrs.jpn.v79.txt b/ver/symbols/symbol_addrs.jpn.v79.txt index 19630e77..be746fac 100644 --- a/ver/symbols/symbol_addrs.jpn.v79.txt +++ b/ver/symbols/symbol_addrs.jpn.v79.txt @@ -133,27 +133,27 @@ sound_vehicle_check = 0x80007F94; func_80007FA4 = 0x80007FA4; // audio_spatial.c .text -audioline_init = 0x80008040; -audioline_off = 0x80008140; -audioline_on = 0x80008168; -audioline_reset = 0x80008174; -func_80008438 = 0x80008438; -func_800090C0 = 0x800090C0; -audioline_distance = 0x800092A8; -play_sound_at_position = 0x80009558; -func_800095E8 = 0x800095E8; -update_spatial_audio_position = 0x800096D8; -func_800096F8 = 0x800096F8; -func_8000974C = 0x8000974C; -audioline_ambient_create = 0x800098A4; -audioline_reverb_create = 0x80009968; -func_800099EC = 0x800099EC; -func_80009AB4 = 0x80009AB4; -audioline_reverb = 0x80009B7C; -func_80009D6C = 0x80009D6C; -debug_render_audio_effects = 0x8000A184; -func_8000A2E8 = 0x8000A2E8; -debug_render_line = 0x8000A414; +audspat_init = 0x80008040; +audspat_jingle_off = 0x80008140; +audspat_jingle_on = 0x80008168; +audspat_reset = 0x80008174; +audspat_update_all = 0x80008438; +audspat_calculate_spatial_pan = 0x800090C0; +audspat_distance_to_segment = 0x800092A8; +audspat_play_sound_at_position = 0x80009558; +audspat_play_sound_direct = 0x800095E8; +audspat_point_set_position = 0x800096D8; +audspat_point_stop = 0x800096F8; +audspat_point_create = 0x8000974C; +audspat_line_add_vertex = 0x800098A4; +audspat_reverb_add_vertex = 0x80009968; +audspat_line_validate = 0x800099EC; +audspat_reverb_validate = 0x80009AB4; +audspat_calculate_echo = 0x80009B7C; +audspat_reverb_get_strength_at_point = 0x80009D6C; +audspat_debug_render_lines = 0x8000A184; +audspat_point_stop_by_index = 0x8000A2E8; +audspat_debug_render_line = 0x8000A414; // seqplayer.c .text dummy_8000A710 = 0x8000A710; @@ -2197,7 +2197,7 @@ D_800DC6D4 = 0x800DE064; D_800DC6D8 = 0x800DE068; // audio_spatial.c .data -gUsedMasks = 0x800DE070; +gNumAudioPoints = 0x800DE070; // objects.c .data gTajChallengeTransition = 0x800DE080; @@ -3563,14 +3563,14 @@ gSoundGroupVolume = 0x8011B698; D_80119C30 = 0x8011B6A0; gRacerSound = 0x8011B6A8; gSoundRacerObj = 0x8011B6AC; -D_80119C40 = 0x8011B6B0; -gSoundMaskHeapUsed = 0x8011B6B4; +gSpatialSoundTable = 0x8011B6B0; +gAudioPoints = 0x8011B6B4; gSoundMaskHeap = 0x8011B6B8; -gFreeMasks = 0x8011B6BC; -gSoundMaskHeapFree = 0x8011B6C0; -D_80119C58 = 0x8011B6C8; // size:0xA80 -D_8011A6D8 = 0x8011C148; // size:0x540 -gAudioLinesOff = 0x8011C688; +gLastFreePointIndex = 0x8011B6BC; +gFreeAudioPoints = 0x8011B6C0; +gAudioLines = 0x8011B6C8; // size:0xA80 +gReverbLines = 0x8011C148; // size:0x540 +gJinglesOff = 0x8011C688; D_8011AC1C = 0x8011C68C; // objects .bss diff --git a/ver/symbols/symbol_addrs.pal.v77.txt b/ver/symbols/symbol_addrs.pal.v77.txt index 787c885a..f177ddd3 100644 --- a/ver/symbols/symbol_addrs.pal.v77.txt +++ b/ver/symbols/symbol_addrs.pal.v77.txt @@ -133,27 +133,27 @@ sound_vehicle_check = 0x80007F94; func_80007FA4 = 0x80007FA4; // audio_spatial.c .text -audioline_init = 0x80008040; -audioline_off = 0x80008140; -audioline_on = 0x80008168; -audioline_reset = 0x80008174; -func_80008438 = 0x80008438; -func_800090C0 = 0x800090C0; -audioline_distance = 0x800092A8; -play_sound_at_position = 0x80009558; -func_800095E8 = 0x800095E8; -update_spatial_audio_position = 0x800096D8; -func_800096F8 = 0x800096F8; -func_8000974C = 0x8000974C; -audioline_ambient_create = 0x800098A4; -audioline_reverb_create = 0x80009968; -func_800099EC = 0x800099EC; -func_80009AB4 = 0x80009AB4; -audioline_reverb = 0x80009B7C; -func_80009D6C = 0x80009D6C; -debug_render_audio_effects = 0x8000A184; -func_8000A2E8 = 0x8000A2E8; -debug_render_line = 0x8000A414; +audspat_init = 0x80008040; +audspat_jingle_off = 0x80008140; +audspat_jingle_on = 0x80008168; +audspat_reset = 0x80008174; +audspat_update_all = 0x80008438; +audspat_calculate_spatial_pan = 0x800090C0; +audspat_distance_to_segment = 0x800092A8; +audspat_play_sound_at_position = 0x80009558; +audspat_play_sound_direct = 0x800095E8; +audspat_point_set_position = 0x800096D8; +audspat_point_stop = 0x800096F8; +audspat_point_create = 0x8000974C; +audspat_line_add_vertex = 0x800098A4; +audspat_reverb_add_vertex = 0x80009968; +audspat_line_validate = 0x800099EC; +audspat_reverb_validate = 0x80009AB4; +audspat_calculate_echo = 0x80009B7C; +audspat_reverb_get_strength_at_point = 0x80009D6C; +audspat_debug_render_lines = 0x8000A184; +audspat_point_stop_by_index = 0x8000A2E8; +audspat_debug_render_line = 0x8000A414; // seqplayer.c .text dummy_8000A710 = 0x8000A710; @@ -2099,7 +2099,7 @@ gNumActiveSounds = 0x800DC754; gVehicleSounds = 0x800DC760; D_800DC6D4 = 0x800DC764; D_800DC6D8 = 0x800DC768; -gUsedMasks = 0x800DC770; +gNumAudioPoints = 0x800DC770; gTajChallengeTransition = 0x800DC780; gBalloonCutsceneTransition = 0x800DC788; D_800DC700 = 0x800DC790; @@ -3303,14 +3303,14 @@ gSoundGroupVolume = 0x80119CB8; D_80119C30 = 0x80119CC0; gRacerSound = 0x80119CC8; gSoundRacerObj = 0x80119CCC; -D_80119C40 = 0x80119CD0; -gSoundMaskHeapUsed = 0x80119CD4; +gSpatialSoundTable = 0x80119CD0; +gAudioPoints = 0x80119CD4; gSoundMaskHeap = 0x80119CD8; -gFreeMasks = 0x80119CDC; -gSoundMaskHeapFree = 0x80119CE0; -D_80119C58 = 0x80119CE8; // size:0xA80 -D_8011A6D8 = 0x8011A768; // size:0x540 -gAudioLinesOff = 0x8011ACA8; +gLastFreePointIndex = 0x80119CDC; +gFreeAudioPoints = 0x80119CE0; +gAudioLines = 0x80119CE8; // size:0xA80 +gReverbLines = 0x8011A768; // size:0x540 +gJinglesOff = 0x8011ACA8; D_8011AC1C = 0x8011ACAC; D_8011AC20 = 0x8011ACB0; // size:0x100 D_8011AD20 = 0x8011ADB0; diff --git a/ver/symbols/symbol_addrs.pal.v80.txt b/ver/symbols/symbol_addrs.pal.v80.txt index 1f07a460..1e13730a 100644 --- a/ver/symbols/symbol_addrs.pal.v80.txt +++ b/ver/symbols/symbol_addrs.pal.v80.txt @@ -133,27 +133,27 @@ sound_vehicle_check = 0x80007F94; func_80007FA4 = 0x80007FA4; // audio_spatial.c .text -audioline_init = 0x80008040; -audioline_off = 0x80008140; -audioline_on = 0x80008168; -audioline_reset = 0x80008174; -func_80008438 = 0x80008438; -func_800090C0 = 0x800090C0; -audioline_distance = 0x800092A8; -play_sound_at_position = 0x80009558; -func_800095E8 = 0x800095E8; -update_spatial_audio_position = 0x800096D8; -func_800096F8 = 0x800096F8; -func_8000974C = 0x8000974C; -audioline_ambient_create = 0x800098A4; -audioline_reverb_create = 0x80009968; -func_800099EC = 0x800099EC; -func_80009AB4 = 0x80009AB4; -audioline_reverb = 0x80009B7C; -func_80009D6C = 0x80009D6C; -debug_render_audio_effects = 0x8000A184; -func_8000A2E8 = 0x8000A2E8; -debug_render_line = 0x8000A414; +audspat_init = 0x80008040; +audspat_jingle_off = 0x80008140; +audspat_jingle_on = 0x80008168; +audspat_reset = 0x80008174; +audspat_update_all = 0x80008438; +audspat_calculate_spatial_pan = 0x800090C0; +audspat_distance_to_segment = 0x800092A8; +audspat_play_sound_at_position = 0x80009558; +audspat_play_sound_direct = 0x800095E8; +audspat_point_set_position = 0x800096D8; +audspat_point_stop = 0x800096F8; +audspat_point_create = 0x8000974C; +audspat_line_add_vertex = 0x800098A4; +audspat_reverb_add_vertex = 0x80009968; +audspat_line_validate = 0x800099EC; +audspat_reverb_validate = 0x80009AB4; +audspat_calculate_echo = 0x80009B7C; +audspat_reverb_get_strength_at_point = 0x80009D6C; +audspat_debug_render_lines = 0x8000A184; +audspat_point_stop_by_index = 0x8000A2E8; +audspat_debug_render_line = 0x8000A414; // seqplayer.c .text dummy_8000A710 = 0x8000A710; @@ -2026,7 +2026,7 @@ gNumActiveSounds = 0x800DCCC4; gVehicleSounds = 0x800DCCD0; D_800DC6D4 = 0x800DCCD4; D_800DC6D8 = 0x800DCCD8; -gUsedMasks = 0x800DCCE0; +gNumAudioPoints = 0x800DCCE0; gTajChallengeTransition = 0x800DCCF0; gBalloonCutsceneTransition = 0x800DCCF8; D_800DC700 = 0x800DCD00; @@ -3233,14 +3233,14 @@ gSoundGroupVolume = 0x8011A238; D_80119C30 = 0x8011A240; gRacerSound = 0x8011A248; gSoundRacerObj = 0x8011A24C; -D_80119C40 = 0x8011A250; -gSoundMaskHeapUsed = 0x8011A254; +gSpatialSoundTable = 0x8011A250; +gAudioPoints = 0x8011A254; gSoundMaskHeap = 0x8011A258; -gFreeMasks = 0x8011A25C; -gSoundMaskHeapFree = 0x8011A260; -D_80119C58 = 0x8011A268; // size:0xA80 -D_8011A6D8 = 0x8011ACE8; // size:0x540 -gAudioLinesOff = 0x8011B228; +gLastFreePointIndex = 0x8011A25C; +gFreeAudioPoints = 0x8011A260; +gAudioLines = 0x8011A268; // size:0xA80 +gReverbLines = 0x8011ACE8; // size:0x540 +gJinglesOff = 0x8011B228; D_8011AC1C = 0x8011B22C; D_8011AC20 = 0x8011B230; // size:0x100 D_8011AD20 = 0x8011B330; diff --git a/ver/symbols/symbol_addrs.us.v77.txt b/ver/symbols/symbol_addrs.us.v77.txt index 0012bd06..1e1a3644 100644 --- a/ver/symbols/symbol_addrs.us.v77.txt +++ b/ver/symbols/symbol_addrs.us.v77.txt @@ -133,27 +133,27 @@ sound_vehicle_check = 0x80007F94; func_80007FA4 = 0x80007FA4; // audio_spatial.c .text -audioline_init = 0x80008040; -audioline_off = 0x80008140; -audioline_on = 0x80008168; -audioline_reset = 0x80008174; -func_80008438 = 0x80008438; -func_800090C0 = 0x800090C0; -audioline_distance = 0x800092A8; -play_sound_at_position = 0x80009558; -func_800095E8 = 0x800095E8; -update_spatial_audio_position = 0x800096D8; -func_800096F8 = 0x800096F8; -func_8000974C = 0x8000974C; -audioline_ambient_create = 0x800098A4; -audioline_reverb_create = 0x80009968; -func_800099EC = 0x800099EC; -func_80009AB4 = 0x80009AB4; -audioline_reverb = 0x80009B7C; -func_80009D6C = 0x80009D6C; -debug_render_audio_effects = 0x8000A184; -func_8000A2E8 = 0x8000A2E8; -debug_render_line = 0x8000A414; +audspat_init = 0x80008040; +audspat_jingle_off = 0x80008140; +audspat_jingle_on = 0x80008168; +audspat_reset = 0x80008174; +audspat_update_all = 0x80008438; +audspat_calculate_spatial_pan = 0x800090C0; +audspat_distance_to_segment = 0x800092A8; +audspat_play_sound_at_position = 0x80009558; +audspat_play_sound_direct = 0x800095E8; +audspat_point_set_position = 0x800096D8; +audspat_point_stop = 0x800096F8; +audspat_point_create = 0x8000974C; +audspat_line_add_vertex = 0x800098A4; +audspat_reverb_add_vertex = 0x80009968; +audspat_line_validate = 0x800099EC; +audspat_reverb_validate = 0x80009AB4; +audspat_calculate_echo = 0x80009B7C; +audspat_reverb_get_strength_at_point = 0x80009D6C; +audspat_debug_render_lines = 0x8000A184; +audspat_point_stop_by_index = 0x8000A2E8; +audspat_debug_render_line = 0x8000A414; // seqplayer.c .text dummy_8000A710 = 0x8000A710; @@ -2192,7 +2192,7 @@ D_800DC6D4 = 0x800DC6D4; D_800DC6D8 = 0x800DC6D8; // audio_spatial.c .data -gUsedMasks = 0x800DC6E0; +gNumAudioPoints = 0x800DC6E0; // objects.c .data gTajChallengeTransition = 0x800DC6F0; @@ -3678,14 +3678,14 @@ gRacerSound = 0x80119C38; gSoundRacerObj = 0x80119C3C; // audio_spatial .bss -D_80119C40 = 0x80119C40; -gSoundMaskHeapUsed = 0x80119C44; +gSpatialSoundTable = 0x80119C40; +gAudioPoints = 0x80119C44; gSoundMaskHeap = 0x80119C48; -gFreeMasks = 0x80119C4C; -gSoundMaskHeapFree = 0x80119C50; -D_80119C58 = 0x80119C58; // size:0xA80 -D_8011A6D8 = 0x8011A6D8; // size:0x540 -gAudioLinesOff = 0x8011AC18; +gLastFreePointIndex = 0x80119C4C; +gFreeAudioPoints = 0x80119C50; +gAudioLines = 0x80119C58; // size:0xA80 +gReverbLines = 0x8011A6D8; // size:0x540 +gJinglesOff = 0x8011AC18; D_8011AC1C = 0x8011AC1C; // objects .bss diff --git a/ver/symbols/symbol_addrs.us.v80.txt b/ver/symbols/symbol_addrs.us.v80.txt index e26e7460..6af8bb1f 100644 --- a/ver/symbols/symbol_addrs.us.v80.txt +++ b/ver/symbols/symbol_addrs.us.v80.txt @@ -133,27 +133,27 @@ sound_vehicle_check = 0x80007F94; func_80007FA4 = 0x80007FA4; // audio_spatial.c .text -audioline_init = 0x80008040; -audioline_off = 0x80008140; -audioline_on = 0x80008168; -audioline_reset = 0x80008174; -func_80008438 = 0x80008438; -func_800090C0 = 0x800090C0; -audioline_distance = 0x800092A8; -play_sound_at_position = 0x80009558; -func_800095E8 = 0x800095E8; -update_spatial_audio_position = 0x800096D8; -func_800096F8 = 0x800096F8; -func_8000974C = 0x8000974C; -audioline_ambient_create = 0x800098A4; -audioline_reverb_create = 0x80009968; -func_800099EC = 0x800099EC; -func_80009AB4 = 0x80009AB4; -audioline_reverb = 0x80009B7C; -func_80009D6C = 0x80009D6C; -debug_render_audio_effects = 0x8000A184; -func_8000A2E8 = 0x8000A2E8; -debug_render_line = 0x8000A414; +audspat_init = 0x80008040; +audspat_jingle_off = 0x80008140; +audspat_jingle_on = 0x80008168; +audspat_reset = 0x80008174; +audspat_update_all = 0x80008438; +audspat_calculate_spatial_pan = 0x800090C0; +audspat_distance_to_segment = 0x800092A8; +audspat_play_sound_at_position = 0x80009558; +audspat_play_sound_direct = 0x800095E8; +audspat_point_set_position = 0x800096D8; +audspat_point_stop = 0x800096F8; +audspat_point_create = 0x8000974C; +audspat_line_add_vertex = 0x800098A4; +audspat_reverb_add_vertex = 0x80009968; +audspat_line_validate = 0x800099EC; +audspat_reverb_validate = 0x80009AB4; +audspat_calculate_echo = 0x80009B7C; +audspat_reverb_get_strength_at_point = 0x80009D6C; +audspat_debug_render_lines = 0x8000A184; +audspat_point_stop_by_index = 0x8000A2E8; +audspat_debug_render_line = 0x8000A414; // seqplayer.c .text dummy_8000A710 = 0x8000A710; @@ -2023,7 +2023,7 @@ gNumActiveSounds = 0x800DCC34; gVehicleSounds = 0x800DCC40; D_800DC6D4 = 0x800DCC44; D_800DC6D8 = 0x800DCC48; -gUsedMasks = 0x800DCC50; +gNumAudioPoints = 0x800DCC50; gTajChallengeTransition = 0x800DCC60; gBalloonCutsceneTransition = 0x800DCC68; D_800DC700 = 0x800DCC70; @@ -3229,14 +3229,14 @@ gSoundGroupVolume = 0x8011A1A8; D_80119C30 = 0x8011A1B0; gRacerSound = 0x8011A1B8; gSoundRacerObj = 0x8011A1BC; -D_80119C40 = 0x8011A1C0; -gSoundMaskHeapUsed = 0x8011A1C4; +gSpatialSoundTable = 0x8011A1C0; +gAudioPoints = 0x8011A1C4; gSoundMaskHeap = 0x8011A1C8; -gFreeMasks = 0x8011A1CC; -gSoundMaskHeapFree = 0x8011A1D0; -D_80119C58 = 0x8011A1D8; // size:0xA80 -D_8011A6D8 = 0x8011AC58; // size:0x540 -gAudioLinesOff = 0x8011B198; +gLastFreePointIndex = 0x8011A1CC; +gFreeAudioPoints = 0x8011A1D0; +gAudioLines = 0x8011A1D8; // size:0xA80 +gReverbLines = 0x8011AC58; // size:0x540 +gJinglesOff = 0x8011B198; D_8011AC1C = 0x8011B19C; D_8011AC20 = 0x8011B1A0; // size:0x100 D_8011AD20 = 0x8011B2A0;