diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index fbff92a4..4ef4740f 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2365,8 +2365,9 @@ d/snd/d_snd_3d_engine.cpp: .data start:0x80548710 end:0x80548730 .sdata2 start:0x8057D308 end:0x8057D368 -d/snd/d_snd_unk_component_1.cpp: +d/snd/d_snd_sound.cpp: .text start:0x8035C3F0 end:0x8035DA88 align:16 + .sdata2 start:0x8057D368 end:0x8057D380 d/snd/d_snd_player_mgr.cpp: .text start:0x8035DA90 end:0x8035F010 align:16 @@ -2386,10 +2387,23 @@ d/snd/mgr/d_snd_mgr_enemy.cpp: .ctors start:0x804DB918 end:0x804DB91C d/snd/d_snd_unk_component_2.cpp: - .text start:0x80366430 end:0x8037D800 align:16 + .text start:0x80366430 end:0x8036B8D0 align:16 + +d/snd/d_snd_sound_ex.cpp: + .text start:0x8036B8D0 end:0x8036C090 align:16 + +d/snd/d_snd_control_sound.cpp: + .text start:0x8036C090 end:0x8036C444 align:16 + .data start:0x80548B78 end:0x80548C38 + .sdata2 start:0x8057D920 end:0x8057D938 + +d/snd/d_snd_control_player.cpp: + .text start:0x8036C450 end:0x8036C6A8 align:16 + .data start:0x80548C38 end:0x80548CC8 + .sdata2 start:0x8057D938 end:0x8057D940 d/snd/mgr/d_snd_mgr_effect.cpp: - .text start:0x8037D800 end:0x8037F8B4 align:16 + .text start:0x8036C6B0 end:0x8037F8B4 align:16 d/snd/mgr/d_snd_mgr_unk_5.cpp: .text start:0x8037F8C0 end:0x803864C8 align:16 @@ -2424,7 +2438,7 @@ d/snd/mgr/d_snd_mgr_unk_11.cpp: .text start:0x80393E00 end:0x8039A848 align:16 .ctors start:0x804DB934 end:0x804DB938 -d/snd/mgr/d_snd_mgr_unk_12.cpp: +d/snd/d_snd_calc_pitch.cpp: .text start:0x8039A850 end:0x8039A960 align:16 RVL_SDK/kpr/KPR.c: diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index e6b43ec2..143697b6 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -19842,9 +19842,9 @@ __ct__13dSnd3DActor_cFPvUc = .text:0x8035A8A0; // type:function size:0xE8 d_vt_0x34__13dSnd3DActor_cFRCQ34nw4r4math4VEC3 = .text:0x8035A990; // type:function size:0x40 fn_8035A9D0 = .text:0x8035A9D0; // type:function size:0x2C fn_8035AA00 = .text:0x8035AA00; // type:function size:0x30 -fn_8035AA30 = .text:0x8035AA30; // type:function size:0x44 -fn_8035AA80 = .text:0x8035AA80; // type:function size:0x28 -fn_8035AAB0 = .text:0x8035AAB0; // type:function size:0x50 +updatePositionRelativeToListener__13dSnd3DActor_cFv = .text:0x8035AA30; // type:function size:0x44 +calculatePositionRelativeToListener__13dSnd3DActor_cFv = .text:0x8035AA80; // type:function size:0x28 +updateDistanceToListener__13dSnd3DActor_cFv = .text:0x8035AAB0; // type:function size:0x50 fn_8035AB00 = .text:0x8035AB00; // type:function size:0x54 fn_8035AB60 = .text:0x8035AB60; // type:function size:0x78 fn_8035ABE0 = .text:0x8035ABE0; // type:function size:0x44 @@ -19881,30 +19881,30 @@ CalcPitch__FPCQ34nw4r4math4VEC3fRCQ34nw4r3snd14Sound3DManagerRCQ34nw4r3snd15Soun fn_8035C1C0 = .text:0x8035C1C0; // type:function size:0xDC fn_8035C2A0 = .text:0x8035C2A0; // type:function size:0x110 __dt__14dSnd3DEngine_cFv = .text:0x8035C3B0; // type:function size:0x40 -fn_8035C3F0 = .text:0x8035C3F0; // type:function size:0x2F8 -fn_8035C6F0 = .text:0x8035C6F0; // type:function size:0x44 -fn_8035C740 = .text:0x8035C740; // type:function size:0x44 -fn_8035C790 = .text:0x8035C790; // type:function size:0x40 -fn_8035C7D0 = .text:0x8035C7D0; // type:function size:0x40 -fn_8035C810 = .text:0x8035C810; // type:function size:0xA0 +__ct__11dSndSound_cFv = .text:0x8035C3F0; // type:function size:0x2F8 +__ct__32dSndControlSoundSeqTrackVolume_cFv = .text:0x8035C6F0; // type:function size:0x44 +__ct__33dSndControlSoundStrmTrackVolume_cFv = .text:0x8035C740; // type:function size:0x44 +__dt__32dSndControlSoundSeqTrackVolume_cFv = .text:0x8035C790; // type:function size:0x40 +__dt__33dSndControlSoundStrmTrackVolume_cFv = .text:0x8035C7D0; // type:function size:0x40 +__dt__11dSndSound_cFv = .text:0x8035C810; // type:function size:0xA0 fn_8035C8B0 = .text:0x8035C8B0; // type:function size:0x84 -fn_8035C940 = .text:0x8035C940; // type:function size:0xE8 +reset__11dSndSound_cFv = .text:0x8035C940; // type:function size:0xE8 fn_8035CA30 = .text:0x8035CA30; // type:function size:0xD8 -fn_8035CB10 = .text:0x8035CB10; // type:function size:0x6C +fadeIn__11dSndSound_cFUli = .text:0x8035CB10; // type:function size:0x6C fn_8035CB80 = .text:0x8035CB80; // type:function size:0xD4 fn_8035CC60 = .text:0x8035CC60; // type:function size:0xCC -fn_8035CD30 = .text:0x8035CD30; // type:function size:0x58 -fn_8035CD90 = .text:0x8035CD90; // type:function size:0x58 -fn_8035CDF0 = .text:0x8035CDF0; // type:function size:0x58 +isStrmSound__11dSndSound_cFv = .text:0x8035CD30; // type:function size:0x58 +isWaveSound__11dSndSound_cFv = .text:0x8035CD90; // type:function size:0x58 +isSeqSound__11dSndSound_cFv = .text:0x8035CDF0; // type:function size:0x58 fn_8035CE50 = .text:0x8035CE50; // type:function size:0x28 fn_8035CE80 = .text:0x8035CE80; // type:function size:0x28 -fn_8035CEB0 = .text:0x8035CEB0; // type:function size:0x84 -fn_8035CF40 = .text:0x8035CF40; // type:function size:0x78 +readSeqTrackVariable__11dSndSound_cFi = .text:0x8035CEB0; // type:function size:0x84 +writeSeqTrackVariable__11dSndSound_cFis = .text:0x8035CF40; // type:function size:0x78 fn_8035CFC0 = .text:0x8035CFC0; // type:function size:0x90 fn_8035D050 = .text:0x8035D050; // type:function size:0x1C -fn_8035D070 = .text:0x8035D070; // type:function size:0x1C +setPitchRelated__11dSndSound_cFfl = .text:0x8035D070; // type:function size:0x1C fn_8035D090 = .text:0x8035D090; // type:function size:0x1C -fn_8035D0B0 = .text:0x8035D0B0; // type:function size:0xE8 +resetTrackVolumes__11dSndSound_cFv = .text:0x8035D0B0; // type:function size:0xE8 fn_8035D1A0 = .text:0x8035D1A0; // type:function size:0x114 fn_8035D2C0 = .text:0x8035D2C0; // type:function size:0xC0 fn_8035D380 = .text:0x8035D380; // type:function size:0xA0 @@ -19913,12 +19913,12 @@ fn_8035D4C0 = .text:0x8035D4C0; // type:function size:0xB8 fn_8035D580 = .text:0x8035D580; // type:function size:0xB8 fn_8035D640 = .text:0x8035D640; // type:function size:0x24 fn_8035D670 = .text:0x8035D670; // type:function size:0x60 -fn_8035D6D0 = .text:0x8035D6D0; // type:function size:0x78 +setSeqTrackMute__11dSndSound_cFUlQ34nw4r3snd7SeqMute = .text:0x8035D6D0; // type:function size:0x78 fn_8035D750 = .text:0x8035D750; // type:function size:0x1E8 fn_8035D940 = .text:0x8035D940; // type:function size:0x58 fn_8035D9A0 = .text:0x8035D9A0; // type:function size:0x68 -fn_8035DA10 = .text:0x8035DA10; // type:function size:0x4C -fn_8035DA60 = .text:0x8035DA60; // type:function size:0x28 +stop__11dSndSound_cFv = .text:0x8035DA10; // type:function size:0x4C +configure__13dSndControl_cFfff = .text:0x8035DA60; // type:function size:0x28 getSoundArchivePath__15dSndPlayerMgr_cFv = .text:0x8035DA90; // type:function size:0xC __dt__33SndMgrDisposer<15dSndPlayerMgr_c>Fv = .text:0x8035DAA0; // type:function size:0x78 create__33SndMgrDisposer<15dSndPlayerMgr_c>Fv = .text:0x8035DB20; // type:function size:0x48 @@ -19977,9 +19977,9 @@ fn_8035EC10 = .text:0x8035EC10; // type:function size:0x5C fn_8035EC70 = .text:0x8035EC70; // type:function size:0x84 convertLabelStringToSoundId__15dSndPlayerMgr_cCFPCc = .text:0x8035ED00; // type:function size:0x3C getSoundArchivePlayerForType__15dSndPlayerMgr_cFUc = .text:0x8035ED40; // type:function size:0x44 -fn_8035ED90 = .text:0x8035ED90; // type:function size:0x5C +canUseThisPlayer__15dSndPlayerMgr_cCFUc = .text:0x8035ED90; // type:function size:0x5C loadDemoArchive__15dSndPlayerMgr_cFPCc = .text:0x8035EDF0; // type:function size:0x198 -fn_8035EF90 = .text:0x8035EF90; // type:function size:0x38 +shutdown__15dSndPlayerMgr_cFv = .text:0x8035EF90; // type:function size:0x38 calc__15dSndPlayerMgr_cFv = .text:0x8035EFD0; // type:function size:0x40 fn_8035F010 = .text:0x8035F010; // type:function size:0x20 fn_8035F030 = .text:0x8035F030; // type:function size:0x1C @@ -20381,29 +20381,29 @@ fn_8036BDB0 = .text:0x8036BDB0; // type:function size:0x30 fn_8036BDE0 = .text:0x8036BDE0; // type:function size:0xA8 fn_8036BE90 = .text:0x8036BE90; // type:function size:0x158 fn_8036BFF0 = .text:0x8036BFF0; // type:function size:0xA0 -fn_8036C090 = .text:0x8036C090; // type:function size:0x20 -fn_8036C0B0 = .text:0x8036C0B0; // type:function size:0x1C -fn_8036C0D0 = .text:0x8036C0D0; // type:function size:0xA8 -fn_8036C180 = .text:0x8036C180; // type:function size:0x84 -fn_8036C210 = .text:0x8036C210; // type:function size:0x20 -fn_8036C230 = .text:0x8036C230; // type:function size:0x1C -fn_8036C250 = .text:0x8036C250; // type:function size:0x48 -fn_8036C2A0 = .text:0x8036C2A0; // type:function size:0x70 -fn_8036C310 = .text:0x8036C310; // type:function size:0x3C -fn_8036C350 = .text:0x8036C350; // type:function size:0x4C -fn_8036C3A0 = .text:0x8036C3A0; // type:function size:0x50 -fn_8036C3F0 = .text:0x8036C3F0; // type:function size:0x54 -fn_8036C450 = .text:0x8036C450; // type:function size:0x48 -fn_8036C4A0 = .text:0x8036C4A0; // type:function size:0x40 -fn_8036C4E0 = .text:0x8036C4E0; // type:function size:0x44 -fn_8036C530 = .text:0x8036C530; // type:function size:0x44 -fn_8036C580 = .text:0x8036C580; // type:function size:0x44 -fn_8036C5D0 = .text:0x8036C5D0; // type:function size:0x10 -fn_8036C5E0 = .text:0x8036C5E0; // type:function size:0xC -fn_8036C5F0 = .text:0x8036C5F0; // type:function size:0x10 -fn_8036C600 = .text:0x8036C600; // type:function size:0xC -fn_8036C610 = .text:0x8036C610; // type:function size:0x40 -fn_8036C650 = .text:0x8036C650; // type:function size:0x58 +reset__13dSndControl_cFv = .text:0x8036C090; // type:function size:0x20 +stop__13dSndControl_cFv = .text:0x8036C0B0; // type:function size:0x1C +set__13dSndControl_cFfl = .text:0x8036C0D0; // type:function size:0xA8 +calc__13dSndControl_cFv = .text:0x8036C180; // type:function size:0x84 +apply__24dSndControlSoundVolume_cFP11dSndSound_c = .text:0x8036C210; // type:function size:0x20 +apply__23dSndControlSoundPitch_cFP11dSndSound_c = .text:0x8036C230; // type:function size:0x1C +__ct__29dSndControlSoundPitchLinear_cFv = .text:0x8036C250; // type:function size:0x48 +set__29dSndControlSoundPitchLinear_cFfl = .text:0x8036C2A0; // type:function size:0x70 +apply__29dSndControlSoundPitchLinear_cFP11dSndSound_c = .text:0x8036C310; // type:function size:0x3C +apply__36dSndControlSoundSeqTrackTempoRatio_cFP11dSndSound_c = .text:0x8036C350; // type:function size:0x4C +apply__32dSndControlSoundSeqTrackVolume_cFP11dSndSound_c = .text:0x8036C3A0; // type:function size:0x50 +apply__33dSndControlSoundStrmTrackVolume_cFP11dSndSound_c = .text:0x8036C3F0; // type:function size:0x54 +__ct__29dSndControlPlayerVolumeBase_cFv = .text:0x8036C450; // type:function size:0x48 +reset__19dSndControlPlayer_cFv = .text:0x8036C4A0; // type:function size:0x40 +setIndex1__19dSndControlPlayer_cFl = .text:0x8036C4E0; // type:function size:0x44 +setIndex2__19dSndControlPlayer_cFl = .text:0x8036C530; // type:function size:0x44 +stop__19dSndControlPlayer_cFv = .text:0x8036C580; // type:function size:0x44 +apply__25dSndControlPlayerVolume_cFv = .text:0x8036C5D0; // type:function size:0x10 +getAppliedValue__25dSndControlPlayerVolume_cFv = .text:0x8036C5E0; // type:function size:0xC +apply__26dSndControlPlayerLpfFreq_cFv = .text:0x8036C5F0; // type:function size:0x10 +getAppliedValue__26dSndControlPlayerLpfFreq_cFv = .text:0x8036C600; // type:function size:0xC +apply__25dSndControlPlayerFxSend_cFv = .text:0x8036C610; // type:function size:0x40 +getAppliedValue__25dSndControlPlayerFxSend_cFv = .text:0x8036C650; // type:function size:0x58 fn_8036C6B0 = .text:0x8036C6B0; // type:function size:0x64 isInvalidSoundId = .text:0x8036C720; // type:function size:0x10 FanfareSoundMgr__dtor = .text:0x8036C730; // type:function size:0x78 @@ -20550,7 +20550,7 @@ fn_80372E30 = .text:0x80372E30; // type:function size:0x40 fn_80372E70 = .text:0x80372E70; // type:function size:0xB0 fn_80372F20 = .text:0x80372F20; // type:function size:0x6C AnotherSoundMgr__playSound = .text:0x80372F90; // type:function size:0x264 -fn_80373200 = .text:0x80373200; // type:function size:0x8 +vt_0xF4__14dSoundSource_cFv = .text:0x80373200; // type:function size:0x8 fn_80373210 = .text:0x80373210; // type:function size:0xB4 fn_803732D0 = .text:0x803732D0; // type:function size:0x44 fn_80373320 = .text:0x80373320; // type:function size:0x8C @@ -20591,8 +20591,8 @@ fn_80374DB0 = .text:0x80374DB0; // type:function size:0x24 fn_80374DE0 = .text:0x80374DE0; // type:function size:0x58 fn_80374E40 = .text:0x80374E40; // type:function size:0x10 fn_80374E50 = .text:0x80374E50; // type:function size:0x330 -fn_80375180 = .text:0x80375180; // type:function size:0x28 -fn_803751B0 = .text:0x803751B0; // type:function size:0x10 +vt_0x38__14dSoundSource_cFv = .text:0x80375180; // type:function size:0x28 +vt_0x3C__14dSoundSource_cFv = .text:0x803751B0; // type:function size:0x10 fn_803751C0 = .text:0x803751C0; // type:function size:0x70 fn_80375230 = .text:0x80375230; // type:function size:0xA4 fn_803752E0 = .text:0x803752E0; // type:function size:0xC8 @@ -20877,7 +20877,7 @@ fn_8037F0E0 = .text:0x8037F0E0; // type:function size:0xC fn_8037F0F0 = .text:0x8037F0F0; // type:function size:0x60 fn_8037F150 = .text:0x8037F150; // type:function size:0x6D0 d_s_vt_0x17C__14dSoundSource_cFv = .text:0x8037F820; // type:function size:0x8 -fn_8037F830 = .text:0x8037F830; // type:function size:0x8 +vt_0x18__14dSoundSource_cFv = .text:0x8037F830; // type:function size:0x8 fn_8037F840 = .text:0x8037F840; // type:function size:0x74 fn_8037F8C0 = .text:0x8037F8C0; // type:function size:0x78 fn_8037F940 = .text:0x8037F940; // type:function size:0x48 @@ -20986,7 +20986,7 @@ fn_80384960 = .text:0x80384960; // type:function size:0x8C fn_803849F0 = .text:0x803849F0; // type:function size:0xC fn_80384A00 = .text:0x80384A00; // type:function size:0x174 fn_80384B80 = .text:0x80384B80; // type:function size:0x178 -fn_80384D00 = .text:0x80384D00; // type:function size:0x8 +vt_0x10__14dSoundSource_cFv = .text:0x80384D00; // type:function size:0x8 fn_80384D10 = .text:0x80384D10; // type:function size:0x78 fn_80384D90 = .text:0x80384D90; // type:function size:0x98 fn_80384E30 = .text:0x80384E30; // type:function size:0xBC @@ -21017,32 +21017,32 @@ fn_80385830 = .text:0x80385830; // type:function size:0x44 fn_80385880 = .text:0x80385880; // type:function size:0x50 fn_803858D0 = .text:0x803858D0; // type:function size:0xA0 fn_80385970 = .text:0x80385970; // type:function size:0x90 -fn_80385A00 = .text:0x80385A00; // type:function size:0x8 -fn_80385A10 = .text:0x80385A10; // type:function size:0x4 +vt_0x118__14dSoundSource_cFv = .text:0x80385A00; // type:function size:0x8 +vt_0x114__14dSoundSource_cFv = .text:0x80385A10; // type:function size:0x4 d_s_vt_0x1D4__14dSoundSource_cFv = .text:0x80385A20; // type:function size:0x8 -fn_80385A30 = .text:0x80385A30; // type:function size:0x4 -fn_80385A40 = .text:0x80385A40; // type:function size:0x4 -fn_80385A50 = .text:0x80385A50; // type:function size:0x4 -fn_80385A60 = .text:0x80385A60; // type:function size:0x8 -fn_80385A70 = .text:0x80385A70; // type:function size:0x4 +setRate__14dSoundSource_cFf = .text:0x80385A30; // type:function size:0x4 +setFrame__14dSoundSource_cFf = .text:0x80385A40; // type:function size:0x4 +load__14dSoundSource_cFPvPCc = .text:0x80385A50; // type:function size:0x4 +isReadyMaybe__14dSoundSource_cFv = .text:0x80385A60; // type:function size:0x8 +vt_0xF0__14dSoundSource_cFv = .text:0x80385A70; // type:function size:0x4 d_s_vt_0x1CC__14dSoundSource_cFv = .text:0x80385A80; // type:function size:0x4 d_s_vt_0x1C0__14dSoundSource_cFv = .text:0x80385A90; // type:function size:0x34 -fn_80385AD0 = .text:0x80385AD0; // type:function size:0x8 -fn_80385AE0 = .text:0x80385AE0; // type:function size:0x8 -fn_80385AF0 = .text:0x80385AF0; // type:function size:0x4 -fn_80385B00 = .text:0x80385B00; // type:function size:0x4 -fn_80385B10 = .text:0x80385B10; // type:function size:0x8 -fn_80385B20 = .text:0x80385B20; // type:function size:0x8 -fn_80385B30 = .text:0x80385B30; // type:function size:0x8 -fn_80385B40 = .text:0x80385B40; // type:function size:0x8 -fn_80385B50 = .text:0x80385B50; // type:function size:0x10 -fn_80385B60 = .text:0x80385B60; // type:function size:0x10 -fn_80385B70 = .text:0x80385B70; // type:function size:0x8 +vt_0xE8__14dSoundSource_cFv = .text:0x80385AD0; // type:function size:0x8 +vt_0xEC__14dSoundSource_cFv = .text:0x80385AE0; // type:function size:0x8 +vt_0xE0__14dSoundSource_cFv = .text:0x80385AF0; // type:function size:0x4 +vt_0xE4__14dSoundSource_cFv = .text:0x80385B00; // type:function size:0x4 +vt_0xDC__14dSoundSource_cFv = .text:0x80385B10; // type:function size:0x8 +vt_0xD4__14dSoundSource_cFv = .text:0x80385B20; // type:function size:0x8 +vt_0x54__14dSoundSource_cFv = .text:0x80385B30; // type:function size:0x8 +vt_0x40__14dSoundSource_cFv = .text:0x80385B40; // type:function size:0x8 +vt_0x34__14dSoundSource_cFv = .text:0x80385B50; // type:function size:0x10 +vt_0x30__14dSoundSource_cFv = .text:0x80385B60; // type:function size:0x10 +vt_0xF8__14dSoundSource_cFv = .text:0x80385B70; // type:function size:0x8 d_s_vt_0x188__14dSoundSource_cFv = .text:0x80385B80; // type:function size:0x4 -fn_80385B90 = .text:0x80385B90; // type:function size:0x4 -fn_80385BA0 = .text:0x80385BA0; // type:function size:0x8 -fn_80385BB0 = .text:0x80385BB0; // type:function size:0x14 -fn_80385BD0 = .text:0x80385BD0; // type:function size:0x14 +vt_0x20__14dSoundSource_cFv = .text:0x80385B90; // type:function size:0x4 +vt_0x24__14dSoundSource_cFv = .text:0x80385BA0; // type:function size:0x8 +vt_0x1C__14dSoundSource_cFv = .text:0x80385BB0; // type:function size:0x14 +vt_0x14__14dSoundSource_cFv = .text:0x80385BD0; // type:function size:0x14 fn_80385BF0 = .text:0x80385BF0; // type:function size:0xC fn_80385C00 = .text:0x80385C00; // type:function size:0xC fn_80385C10 = .text:0x80385C10; // type:function size:0xC @@ -21132,63 +21132,63 @@ fn_80386F70 = .text:0x80386F70; // type:function size:0x1A4C soundForActorInitRelated_803889c0 = .text:0x803889C0; // type:function size:0x4 __ct__14dSoundSource_cFUcP9dAcBase_cii = .text:0x803889D0; // type:function size:0x108 __dt__14dSoundSource_cFv = .text:0x80388AE0; // type:function size:0xC4 -fn_80388BB0 = .text:0x80388BB0; // type:function size:0x118 -fn_80388CD0 = .text:0x80388CD0; // type:function size:0x9C +vt_0x0C__14dSoundSource_cFv = .text:0x80388BB0; // type:function size:0x118 +vt_0x44__14dSoundSource_cFv = .text:0x80388CD0; // type:function size:0x9C fn_80388D70 = .text:0x80388D70; // type:function size:0x80 -fn_80388DF0 = .text:0x80388DF0; // type:function size:0xC -fn_80388E00 = .text:0x80388E00; // type:function size:0x88 +getListenerPosition__14dSoundSource_cCFv = .text:0x80388DF0; // type:function size:0xC +vt_0x2C__14dSoundSource_cFv = .text:0x80388E00; // type:function size:0x88 d_s_vt_0x184__14dSoundSource_cFv = .text:0x80388E90; // type:function size:0x84 d_s_vt_0x18C__14dSoundSource_cFv = .text:0x80388F20; // type:function size:0x4 hasPlayingSounds__14dSoundSource_cCFv = .text:0x80388F30; // type:function size:0x8 -fn_80388F40 = .text:0x80388F40; // type:function size:0x8 -fn_80388F50 = .text:0x80388F50; // type:function size:0x48 +isPlayingSound__14dSoundSource_cFUl = .text:0x80388F40; // type:function size:0x8 +isPlayingSound__14dSoundSource_cFPCc = .text:0x80388F50; // type:function size:0x48 fn_80388FA0 = .text:0x80388FA0; // type:function size:0x14 fn_80388FC0 = .text:0x80388FC0; // type:function size:0x84 fn_80389050 = .text:0x80389050; // type:function size:0x68 -fn_803890C0 = .text:0x803890C0; // type:function size:0x18 -fn_803890E0 = .text:0x803890E0; // type:function size:0x1C +vt_0x5C__14dSoundSource_cFv = .text:0x803890C0; // type:function size:0x18 +vt_0x58__14dSoundSource_cFv = .text:0x803890E0; // type:function size:0x1C fn_80389100 = .text:0x80389100; // type:function size:0x60 d_s_vt_0x190__14dSoundSource_cFv = .text:0x80389160; // type:function size:0x40 d_vt_0x38__14dSoundSource_cFbi = .text:0x803891A0; // type:function size:0xB0 -fn_80389250 = .text:0x80389250; // type:function size:0x30 -fn_80389280 = .text:0x80389280; // type:function size:0x48 -fn_803892D0 = .text:0x803892D0; // type:function size:0x64 -fn_80389340 = .text:0x80389340; // type:function size:0x58 -fn_803893A0 = .text:0x803893A0; // type:function size:0x60 -fn_80389400 = .text:0x80389400; // type:function size:0x58 -fn_80389460 = .text:0x80389460; // type:function size:0x88 -fn_803894F0 = .text:0x803894F0; // type:function size:0x68 -fn_80389560 = .text:0x80389560; // type:function size:0x94 +vt_0x60__14dSoundSource_cFv = .text:0x80389250; // type:function size:0x30 +vt_0x70__14dSoundSource_cFv = .text:0x80389280; // type:function size:0x48 +vt_0x64__14dSoundSource_cFv = .text:0x803892D0; // type:function size:0x64 +vt_0x74__14dSoundSource_cFv = .text:0x80389340; // type:function size:0x58 +vt_0x68__14dSoundSource_cFv = .text:0x803893A0; // type:function size:0x60 +vt_0x78__14dSoundSource_cFv = .text:0x80389400; // type:function size:0x58 +vt_0x6C__14dSoundSource_cFv = .text:0x80389460; // type:function size:0x88 +vt_0x7C__14dSoundSource_cFv = .text:0x803894F0; // type:function size:0x68 +vt_0xA0__14dSoundSource_cFv = .text:0x80389560; // type:function size:0x94 fn_80389600 = .text:0x80389600; // type:function size:0x74 fn_80389680 = .text:0x80389680; // type:function size:0x40 fn_803896C0 = .text:0x803896C0; // type:function size:0x1A8 -fn_80389870 = .text:0x80389870; // type:function size:0x11C -fn_80389990 = .text:0x80389990; // type:function size:0x58 -fn_803899F0 = .text:0x803899F0; // type:function size:0x184 -fn_80389B80 = .text:0x80389B80; // type:function size:0x68 -fn_80389BF0 = .text:0x80389BF0; // type:function size:0x160 -fn_80389D50 = .text:0x80389D50; // type:function size:0x78 -fn_80389DD0 = .text:0x80389DD0; // type:function size:0x11C -fn_80389EF0 = .text:0x80389EF0; // type:function size:0x58 +vt_0x80__14dSoundSource_cFv = .text:0x80389870; // type:function size:0x11C +vt_0x8C__14dSoundSource_cFv = .text:0x80389990; // type:function size:0x58 +vt_0x84__14dSoundSource_cFv = .text:0x803899F0; // type:function size:0x184 +vt_0x90__14dSoundSource_cFv = .text:0x80389B80; // type:function size:0x68 +vt_0x88__14dSoundSource_cFv = .text:0x80389BF0; // type:function size:0x160 +vt_0x94__14dSoundSource_cFv = .text:0x80389D50; // type:function size:0x78 +vt_0x98__14dSoundSource_cFv = .text:0x80389DD0; // type:function size:0x11C +vt_0x9C__14dSoundSource_cFv = .text:0x80389EF0; // type:function size:0x58 fn_80389F50 = .text:0x80389F50; // type:function size:0x208 d_s_vt_0x19C__14dSoundSource_cFv = .text:0x8038A160; // type:function size:0x6C fn_8038A1D0 = .text:0x8038A1D0; // type:function size:0xD8 -fn_8038A2B0 = .text:0x8038A2B0; // type:function size:0x48 +vt_0xD8__14dSoundSource_cFv = .text:0x8038A2B0; // type:function size:0x48 fn_8038A300 = .text:0x8038A300; // type:function size:0x10 -fn_8038A310 = .text:0x8038A310; // type:function size:0xB8 -fn_8038A3D0 = .text:0x8038A3D0; // type:function size:0x58 -fn_8038A430 = .text:0x8038A430; // type:function size:0x30 -fn_8038A460 = .text:0x8038A460; // type:function size:0x48 -fn_8038A4B0 = .text:0x8038A4B0; // type:function size:0x64 -fn_8038A520 = .text:0x8038A520; // type:function size:0x58 -fn_8038A580 = .text:0x8038A580; // type:function size:0x60 -fn_8038A5E0 = .text:0x8038A5E0; // type:function size:0x58 -fn_8038A640 = .text:0x8038A640; // type:function size:0x88 -fn_8038A6D0 = .text:0x8038A6D0; // type:function size:0x68 +vt_0xA4__14dSoundSource_cFv = .text:0x8038A310; // type:function size:0xB8 +vt_0xA8__14dSoundSource_cFv = .text:0x8038A3D0; // type:function size:0x58 +vt_0xAC__14dSoundSource_cFv = .text:0x8038A430; // type:function size:0x30 +vt_0xBC__14dSoundSource_cFv = .text:0x8038A460; // type:function size:0x48 +vt_0xB0__14dSoundSource_cFv = .text:0x8038A4B0; // type:function size:0x64 +vt_0xC0__14dSoundSource_cFv = .text:0x8038A520; // type:function size:0x58 +vt_0xB4__14dSoundSource_cFv = .text:0x8038A580; // type:function size:0x60 +vt_0xC4__14dSoundSource_cFv = .text:0x8038A5E0; // type:function size:0x58 +vt_0xB8__14dSoundSource_cFv = .text:0x8038A640; // type:function size:0x88 +vt_0xC8__14dSoundSource_cFv = .text:0x8038A6D0; // type:function size:0x68 fn_8038A740 = .text:0x8038A740; // type:function size:0x1E8 fn_8038A930 = .text:0x8038A930; // type:function size:0x1D0 -fn_8038AB00 = .text:0x8038AB00; // type:function size:0x258 -fn_8038AD60 = .text:0x8038AD60; // type:function size:0x58 +vt_0xCC__14dSoundSource_cFv = .text:0x8038AB00; // type:function size:0x258 +vt_0xD0__14dSoundSource_cFv = .text:0x8038AD60; // type:function size:0x58 SetupSound__14dSoundSource_cFPQ34nw4r3snd11SoundHandleUlPCQ44nw4r3snd14SoundStartable9StartInfoPv = .text:0x8038ADC0; // type:function size:0xAC d_s_vt_0x1AC__14dSoundSource_cFv = .text:0x8038AE70; // type:function size:0x98 d_s_vt_0x1B0__14dSoundSource_cFv = .text:0x8038AF10; // type:function size:0x254 @@ -21221,8 +21221,8 @@ fn_8038BA80 = .text:0x8038BA80; // type:function size:0x90 fn_8038BB10 = .text:0x8038BB10; // type:function size:0x6C fn_8038BB80 = .text:0x8038BB80; // type:function size:0x6C fn_8038BBF0 = .text:0x8038BBF0; // type:function size:0x144 -fn_8038BD40 = .text:0x8038BD40; // type:function size:0x20 -fn_8038BD60 = .text:0x8038BD60; // type:function size:0xC +vt_0xFC__14dSoundSource_cFv = .text:0x8038BD40; // type:function size:0x20 +vt_0x110__14dSoundSource_cFv = .text:0x8038BD60; // type:function size:0xC d_s_vt_0x1E4__14dSoundSource_cFv = .text:0x8038BD70; // type:function size:0x4 fn_8038BD80 = .text:0x8038BD80; // type:function size:0xB8 fn_8038BE40 = .text:0x8038BE40; // type:function size:0xC4 @@ -21627,7 +21627,7 @@ __dt__32SndMgrDisposer<14SndMgr80399c20>Fv = .text:0x80399BA0; // type:function create__32SndMgrDisposer<14SndMgr80399c20>Fv = .text:0x80399C20; // type:function size:0x84 remove__32SndMgrDisposer<14SndMgr80399c20>Fv = .text:0x80399CB0; // type:function size:0x10 fn_80399CC0 = .text:0x80399CC0; // type:function size:0x34 -fn_80399D00 = .text:0x80399D00; // type:function size:0x5C +__dt__14SndMgr80399c20Fv = .text:0x80399D00; // type:function size:0x5C fn_80399D60 = .text:0x80399D60; // type:function size:0x44 fn_80399DB0 = .text:0x80399DB0; // type:function size:0x34 fn_80399DF0 = .text:0x80399DF0; // type:function size:0x15C @@ -21656,9 +21656,9 @@ fn_8039A7E0 = .text:0x8039A7E0; // type:function size:0x38 fn_8039A820 = .text:0x8039A820; // type:function size:0x8 fn_8039A830 = .text:0x8039A830; // type:function size:0x8 fn_8039A840 = .text:0x8039A840; // type:function size:0x8 -fn_8039A850 = .text:0x8039A850; // type:function size:0x2C -fn_8039A880 = .text:0x8039A880; // type:function size:0x58 -fn_8039A8E0 = .text:0x8039A8E0; // type:function size:0x80 +pitchScaleForPitchIdx = .text:0x8039A850; // type:function size:0x2C +pitchScaleForPitchIdxTenths__Ff = .text:0x8039A880; // type:function size:0x58 +pitchIdxTenthsForPitchScale__Ff = .text:0x8039A8E0; // type:function size:0x80 fn_8039A960 = .text:0x8039A960; // type:function size:0x10 fn_8039A970 = .text:0x8039A970; // type:function size:0x5C fn_8039A9D0 = .text:0x8039A9D0; // type:function size:0x14 @@ -37636,7 +37636,7 @@ __vt__11dSndActor_c = .data:0x80548684; // type:object size:0x1C scope:weak __vt__23IsCurrentSoundIdChecker = .data:0x805486A0; // type:object size:0x10 __vt__13dSnd3DActor_c = .data:0x805486B0; // type:object size:0x60 __vt__14dSnd3DEngine_c = .data:0x80548710; // type:object size:0x20 -lbl_80548730 = .data:0x80548730; // type:object size:0x28 +__vt__11dSndSound_c = .data:0x80548730; // type:object size:0x28 lbl_80548758 = .data:0x80548758; // type:object size:0x14 data:string lbl_8054876C = .data:0x8054876C; // type:object size:0x14 data:string __vt__15dSndPlayerMgr_c = .data:0x80548780; // type:object size:0x10 @@ -37696,16 +37696,16 @@ lbl_80548B1C = .data:0x80548B1C; // type:object size:0x10 lbl_80548B2C = .data:0x80548B2C; // type:object size:0xC lbl_80548B38 = .data:0x80548B38; // type:object size:0x10 lbl_80548B48 = .data:0x80548B48; // type:object size:0x30 -lbl_80548B78 = .data:0x80548B78; // type:object size:0x20 -lbl_80548B98 = .data:0x80548B98; // type:object size:0x20 -lbl_80548BB8 = .data:0x80548BB8; // type:object size:0x20 -lbl_80548BD8 = .data:0x80548BD8; // type:object size:0x20 -lbl_80548BF8 = .data:0x80548BF8; // type:object size:0x20 -lbl_80548C18 = .data:0x80548C18; // type:object size:0x20 -lbl_80548C38 = .data:0x80548C38; // type:object size:0x24 -lbl_80548C5C = .data:0x80548C5C; // type:object size:0x24 -lbl_80548C80 = .data:0x80548C80; // type:object size:0x24 -lbl_80548CA4 = .data:0x80548CA4; // type:object size:0x24 +__vt__33dSndControlSoundStrmTrackVolume_c = .data:0x80548B78; // type:object size:0x20 +__vt__32dSndControlSoundSeqTrackVolume_c = .data:0x80548B98; // type:object size:0x20 +__vt__36dSndControlSoundSeqTrackTempoRatio_c = .data:0x80548BB8; // type:object size:0x20 +__vt__29dSndControlSoundPitchLinear_c = .data:0x80548BD8; // type:object size:0x20 +__vt__23dSndControlSoundPitch_c = .data:0x80548BF8; // type:object size:0x20 +__vt__24dSndControlSoundVolume_c = .data:0x80548C18; // type:object size:0x20 +__vt__25dSndControlPlayerFxSend_c = .data:0x80548C38; // type:object size:0x24 +__vt__26dSndControlPlayerLpfFreq_c = .data:0x80548C5C; // type:object size:0x24 +__vt__25dSndControlPlayerVolume_c = .data:0x80548C80; // type:object size:0x24 +__vt__29dSndControlPlayerVolumeBase_c = .data:0x80548CA4; // type:object size:0x24 scope:weak jumptable_80548CC8 = .data:0x80548CC8; // type:object size:0x34 scope:local jumptable_80548CFC = .data:0x80548CFC; // type:object size:0x284 scope:local lbl_80548F80 = .data:0x80548F80; // type:object size:0xC @@ -48608,12 +48608,12 @@ lbl_8057D90C = .sdata2:0x8057D90C; // type:object size:0x4 align:4 data:float lbl_8057D910 = .sdata2:0x8057D910; // type:object size:0x4 align:4 data:float lbl_8057D914 = .sdata2:0x8057D914; // type:object size:0x4 align:4 data:float lbl_8057D918 = .sdata2:0x8057D918; // type:object size:0x4 align:4 data:float -lbl_8057D920 = .sdata2:0x8057D920; // type:object size:0x8 align:8 data:double -lbl_8057D928 = .sdata2:0x8057D928; // type:object size:0x4 align:4 data:float -lbl_8057D92C = .sdata2:0x8057D92C; // type:object size:0x4 align:4 data:float -lbl_8057D930 = .sdata2:0x8057D930; // type:object size:0x4 align:4 data:float -lbl_8057D938 = .sdata2:0x8057D938; // type:object size:0x4 align:4 data:float -lbl_8057D93C = .sdata2:0x8057D93C; // type:object size:0x4 align:4 data:float +@2743 = .sdata2:0x8057D920; // type:object size:0x8 scope:local align:8 data:double +@2762 = .sdata2:0x8057D928; // type:object size:0x4 scope:local align:4 data:float +@2763 = .sdata2:0x8057D92C; // type:object size:0x4 scope:local align:4 data:float +@2767 = .sdata2:0x8057D930; // type:object size:0x4 scope:local align:4 data:float +@1614 = .sdata2:0x8057D938; // type:object size:0x4 scope:local align:4 data:float +@1615 = .sdata2:0x8057D93C; // type:object size:0x4 scope:local align:4 data:float lbl_8057D940 = .sdata2:0x8057D940; // type:object size:0x4 align:4 data:float lbl_8057D944 = .sdata2:0x8057D944; // type:object size:0x4 align:4 data:float lbl_8057D948 = .sdata2:0x8057D948; // type:object size:0x4 align:4 data:float diff --git a/configure.py b/configure.py index 448b5746..ec055e44 100644 --- a/configure.py +++ b/configure.py @@ -706,12 +706,15 @@ config.libs = [ Object(Matching, "d/snd/d_snd_actor.cpp"), Object(NonMatching, "d/snd/d_snd_3d_actor.cpp"), Object(NonMatching, "d/snd/d_snd_3d_engine.cpp"), - Object(NonMatching, "d/snd/d_snd_unk_component_1.cpp"), + Object(NonMatching, "d/snd/d_snd_sound.cpp"), Object(NonMatching, "d/snd/d_snd_player_mgr.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk1.cpp"), Object(Matching, "d/snd/d_snd_3d_manager.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_enemy.cpp"), Object(NonMatching, "d/snd/d_snd_unk_component_2.cpp"), + Object(NonMatching, "d/snd/d_snd_sound_ex.cpp"), + Object(Matching, "d/snd/d_snd_control_sound.cpp"), + Object(Matching, "d/snd/d_snd_control_player.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_effect.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_5.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_13.cpp"), @@ -721,7 +724,7 @@ config.libs = [ Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_9.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_10.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_11.cpp"), - Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_12.cpp"), + Object(NonMatching, "d/snd/d_snd_calc_pitch.cpp"), ], }, { diff --git a/include/d/a/d_a_base.h b/include/d/a/d_a_base.h index b223b88a..51944c33 100644 --- a/include/d/a/d_a_base.h +++ b/include/d/a/d_a_base.h @@ -4,7 +4,7 @@ #include "UnknownTypeBelongings.h" #include "common.h" #include "d/d_base.h" -#include "d/snd/d_snd_source.h" +#include "d/snd/d_snd_source_if.h" #include "m/m_allocator.h" #include "m/m_angle.h" #include "m/m_vec.h" diff --git a/include/d/snd/d_snd_3d_actor.h b/include/d/snd/d_snd_3d_actor.h index 6fa7fafa..5136d7be 100644 --- a/include/d/snd/d_snd_3d_actor.h +++ b/include/d/snd/d_snd_3d_actor.h @@ -41,12 +41,20 @@ public: virtual void d_vt_0x58() = 0; virtual void d_vt_0x5C() = 0; + void calculatePositionRelativeToListener(); + void updatePositionRelativeToListener(); + void updateDistanceToListener(); + void resetFloats(); bool checkFlag(u16 flag) const { return (mFlags & flag); } + void setFlag(u16 flag) { + mFlags |= flag; + } + bool hasPlayingSounds() const; bool isPlayingSound(u32 id); @@ -63,10 +71,12 @@ protected: /* 0x88 */ f32 a_field_0x88; /* 0x8C */ f32 a_field_0x8C; /* 0x90 */ f32 a_field_0x90; - /* 0x94 */ f32 a_field_0x94; + /* 0x94 */ f32 mDistanceToListener; /* 0x98 */ f32 a_field_0x98; /* 0x9C */ f32 a_field_0x9C; - /* 0xA0 */ u8 a_0xA0[0xC8 - 0xA0]; + /* 0xA0 */ nw4r::math::VEC3 mPositionRelativeToListener; + /* 0xAC */ nw4r::math::VEC3 mPositionTransformedByListener; + /* 0xB8 */ u8 a_0xB8[0xC8 - 0xB8]; /* 0xC8 */ UNKTYPE *a_field_0xC8; /* 0xCC */ u16 mFlags; /* 0xD0 */ nw4r::math::VEC3 mPositionRelativeToPlayer; diff --git a/include/d/snd/d_snd_3d_manager.h b/include/d/snd/d_snd_3d_manager.h index b0a86b90..eb09988b 100644 --- a/include/d/snd/d_snd_3d_manager.h +++ b/include/d/snd/d_snd_3d_manager.h @@ -42,21 +42,25 @@ public: return mManager; } - const mVec3_c &getListenerPos() const { - return mSoundListenerPosition; + const mVec3_c &getCameraTargetPos() const { + return mCameraTargetPosition; + } + + const nw4r::math::VEC3 &getSndListenerPos() const { + return mListener.GetPosition(); } private: void updateListenerPos(f32); /* 0x10 */ bool mIsSetup; - /* 0x11 */ u8 field_0x11; + /* 0x11 */ bool mCalculationsFresh; /* 0x14 */ dSnd3DEngine_c *mpEngine; /* 0x18 */ nw4r::snd::Sound3DManager mManager; /* 0x44 */ nw4r::snd::Sound3DListener mListener; /* 0xB0 */ EGG::LookAtCamera mCamera; - /* 0x138 */ mVec3_c field_0x138; - /* 0x144 */ mVec3_c mSoundListenerPosition; + /* 0x138 */ mVec3_c mCameraDirectionNormalized; + /* 0x144 */ mVec3_c mCameraTargetPosition; /* 0x150 */ f32 mCameraPosSqVelocity; /* 0x154 */ f32 mCameraAtSqVelocity; /* 0x158 */ f32 mCamDistance; diff --git a/include/d/snd/d_snd_calc_pitch.h b/include/d/snd/d_snd_calc_pitch.h new file mode 100644 index 00000000..5365e1e3 --- /dev/null +++ b/include/d/snd/d_snd_calc_pitch.h @@ -0,0 +1,10 @@ +#ifndef D_SND_CALC_PITCH_H +#define D_SND_CALC_PITCH_H + +#include "common.h" + +f32 pitchScaleForPitchIdx(s32 idx); +f32 pitchScaleForPitchIdxTenths(f32 idx); +f32 pitchIdxTenthsForPitchScale(f32 scale); + +#endif diff --git a/include/d/snd/d_snd_control_player.h b/include/d/snd/d_snd_control_player.h new file mode 100644 index 00000000..fc0096ef --- /dev/null +++ b/include/d/snd/d_snd_control_player.h @@ -0,0 +1,53 @@ +#ifndef D_SND_CONTROL_PLAYER_H +#define D_SND_CONTROL_PLAYER_H + +#include "d/snd/d_snd_sound.h" +#include "nw4r/snd/snd_SoundPlayer.h" + +class dSndControlPlayer_c : public dSndControl_c { +public: + dSndControlPlayer_c(f32 value, f32 min, f32 max) : dSndControl_c(value, min, max) {} + virtual void reset() override; // vt 0x0C + + virtual void stop() override; // vt 0x18 + virtual void apply() = 0; // vt 0x1C + virtual f32 getAppliedValue() = 0; // vt 0x20 + + void setIndex1(s32 idx); + void setIndex2(s32 idx); + +protected: + /* 0x30 */ nw4r::snd::SoundPlayer *mpPlayer; + /* 0x34 */ s32 mIndex; +}; + +class dSndControlPlayerVolumeBase_c : public dSndControlPlayer_c { +public: + dSndControlPlayerVolumeBase_c(); +}; + +class dSndControlPlayerVolume_c : public dSndControlPlayerVolumeBase_c { +public: + dSndControlPlayerVolume_c() {} + + virtual void apply() override; // vt 0x1C + virtual f32 getAppliedValue() override; // vt 0x20 +}; + +class dSndControlPlayerLpfFreq_c : public dSndControlPlayer_c { +public: + dSndControlPlayerLpfFreq_c() : dSndControlPlayer_c(0.0f, -1.0f, 0.0f) {} + + virtual void apply() override; // vt 0x1C + virtual f32 getAppliedValue() override; // vt 0x20 +}; + +class dSndControlPlayerFxSend_c : public dSndControlPlayer_c { +public: + dSndControlPlayerFxSend_c() : dSndControlPlayer_c(0.0f, -1.0f, 0.0f) {} + + virtual void apply() override; // vt 0x1C + virtual f32 getAppliedValue() override; // vt 0x20 +}; + +#endif diff --git a/include/d/snd/d_snd_player_mgr.h b/include/d/snd/d_snd_player_mgr.h index 2578fcb4..26026b10 100644 --- a/include/d/snd/d_snd_player_mgr.h +++ b/include/d/snd/d_snd_player_mgr.h @@ -29,13 +29,16 @@ private: public: dSndPlayerMgr_c(); + void shutdown(); void calc(); u32 getFreeSize(); bool loadDemoArchive(const char *demoArchiveName); const char *getSoundArchivePath(); u32 convertLabelStringToSoundId(const char *label) const; + nw4r::snd::SoundArchivePlayer &getSoundArchivePlayerForType(u8 type); + bool canUseThisPlayer(u8 type) const; bool checkFlag(u32 mask) const { return mFlags & mask; diff --git a/include/d/snd/d_snd_sound.h b/include/d/snd/d_snd_sound.h new file mode 100644 index 00000000..3f4f9fd9 --- /dev/null +++ b/include/d/snd/d_snd_sound.h @@ -0,0 +1,169 @@ +#ifndef D_SND_SOUND_H +#define D_SND_SOUND_H + +#include "common.h" +#include "nw4r/snd/snd_SeqTrack.h" +#include "nw4r/snd/snd_SoundHandle.h" +#include "nw4r/ut/ut_list.h" + +class dSndSound_c; + +// Not sure, handles a bunch of floats, exists in a ton of variants +class dSndControl_c { +public: + dSndControl_c(f32 value, f32 min, f32 max) + : mResetValue(value), + mMax(max), + mMin(min), + mCurrValue(value), + mStartValue(value), + mTargetValue(value), + mDuration(0), + mTimer(0), + mIsLinked(false) {} + + ~dSndControl_c() {} + + virtual void configure(f32 value, f32 min, f32 max); // vt 0x08 + virtual void reset(); // vt 0x0C + virtual void set(f32 value, s32 frames); // vt 0x10 + virtual void calc(); // vt 0x14 + virtual void stop(); // vt 0x18 + + bool isLinked() const { + return mIsLinked; + } + + void setLinked(bool linked) { + mIsLinked = linked; + } + + f32 getCurrentValue() const { + return mCurrValue; + } + +protected: + /* 0x04 */ f32 mResetValue; + /* 0x08 */ f32 mMax; + /* 0x0C */ f32 mMin; + /* 0x10 */ f32 mCurrValue; + /* 0x14 */ f32 mStartValue; + /* 0x18 */ f32 mTargetValue; + /* 0x1C */ s32 mDuration; + /* 0x20 */ s32 mTimer; + /* 0x24 */ nw4r::ut::Node mNode; + /* 0x2C */ bool mIsLinked; +}; + +class dSndControlSound_c : public dSndControl_c { +public: + dSndControlSound_c(f32 value, f32 min, f32 max) : dSndControl_c(value, min, max) {} + virtual void apply(dSndSound_c *pHandle) = 0; // vt 0x1C + +private: +}; + +class dSndControlSoundVolume_c : public dSndControlSound_c { +public: + dSndControlSoundVolume_c() : dSndControlSound_c(1.0f, 0.0f, 2.0f) {} + virtual void apply(dSndSound_c *pHandle) override; +}; + +class dSndControlSoundPitch_c : public dSndControlSound_c { +public: + dSndControlSoundPitch_c() : dSndControlSound_c(1.0f, 0.25f, 4.0f) {} + virtual void apply(dSndSound_c *pHandle) override; +}; + +/** Stores pitch as a value from -24 to 24, exponentially scaling it to 0.25-4.0 */ +class dSndControlSoundPitchLinear_c : public dSndControlSound_c { +public: + dSndControlSoundPitchLinear_c(); + virtual void apply(dSndSound_c *pHandle) override; + virtual void set(f32 value, s32 frames) override; + + void setControl(dSndControlSound_c *ctrl) { + mpOtherControl = ctrl; + } + +private: + /* 0x30 */ dSndControlSound_c *mpOtherControl; +}; + +class dSndControlSoundSeqTrackTempoRatio_c : public dSndControlSound_c { +public: + dSndControlSoundSeqTrackTempoRatio_c() : dSndControlSound_c(1.0f, 0.25f, 4.0f) {} + virtual void apply(dSndSound_c *pHandle) override; +}; + +class dSndControlSoundSeqTrackVolume_c : public dSndControlSound_c { +public: + dSndControlSoundSeqTrackVolume_c() : dSndControlSound_c(1.0f, 0.0f, 2.0f) {} + virtual void apply(dSndSound_c *pHandle) override; + + void setMask(u16 mask) { + mMask = mask; + } + +private: + /* 0x2E */ u16 mMask; +}; + +class dSndControlSoundStrmTrackVolume_c : public dSndControlSound_c { +public: + dSndControlSoundStrmTrackVolume_c() : dSndControlSound_c(1.0f, 0.0f, 2.0f) {} + virtual void apply(dSndSound_c *pHandle) override; + + void setMask(u16 mask) { + mMask = mask; + } + +private: + /* 0x2E */ u16 mMask; +}; + +class dSndSound_c : public nw4r::snd::SoundHandle { +public: + dSndSound_c(); + ~dSndSound_c(); + + virtual void vt_0x08(); // 0x08 + virtual void vt_0x0C(); // 0x0C + virtual void fadeIn(u32 id, int fadeFrames); // 0x10 + + bool isStrmSound(); + bool isWaveSound(); + bool isSeqSound(); + + void setPitchRelated(f32 pitch, s32 frames); + + void setSeqTrackMute(u32 trackFlags, nw4r::snd::SeqMute mute); + void stop(); + + s16 readSeqTrackVariable(int varNo); + void writeSeqTrackVariable(int varNo, s16 value); + + void linkCtrl(dSndControlSound_c *); + void unlinkCtrl(dSndControlSound_c *); + +private: + void reset(); + void resetTrackVolumes(); + + /* 0x08 */ u8 _0x08[0x10 - 0x08]; + + /* 0x10 */ UNKWORD field_0x10; + /* 0x14 */ u8 field_0x14; + /* 0x15 */ u8 field_0x15; + /* 0x16 */ u8 field_0x16; + /* 0x17 */ u8 field_0x17; + /* 0x18 */ dSndControlSoundVolume_c mCtrlVolume; + /* 0x48 */ dSndControlSoundPitch_c mCtrlPitch; + /* 0x78 */ dSndControlSoundPitchLinear_c mCtrlUnk; + /* 0xAC */ dSndControlSoundSeqTrackVolume_c *mpCtrlSeqTrackVolume; + /* 0xB0 */ dSndControlSoundStrmTrackVolume_c *mpCtrlStrmTrackVolume; + /* 0xB4 */ dSndControlSoundSeqTrackTempoRatio_c mpCtrlSeqTrackTempoRatio; + /* 0xE4 */ nw4r::ut::List mList; +}; + +#endif diff --git a/include/d/snd/d_snd_source.h b/include/d/snd/d_snd_source.h index 65d8be13..64a3eaad 100644 --- a/include/d/snd/d_snd_source.h +++ b/include/d/snd/d_snd_source.h @@ -3,87 +3,9 @@ #include "common.h" #include "d/snd/d_snd_3d_actor.h" +#include "d/snd/d_snd_source_if.h" #include "nw4r/ut/ut_list.h" - -class dAcBase_c; - -class dSoundSourceIf_c { -public: - virtual ~dSoundSourceIf_c() {} -#define SOUNDSOURCE_VIRTUAL(offset) virtual void vt_##offset() = 0; - SOUNDSOURCE_VIRTUAL(0x0C); - SOUNDSOURCE_VIRTUAL(0x10); - SOUNDSOURCE_VIRTUAL(0x14); - SOUNDSOURCE_VIRTUAL(0x18); - SOUNDSOURCE_VIRTUAL(0x1C); - SOUNDSOURCE_VIRTUAL(0x20); - SOUNDSOURCE_VIRTUAL(0x24); - SOUNDSOURCE_VIRTUAL(0x28); - SOUNDSOURCE_VIRTUAL(0x2C); - SOUNDSOURCE_VIRTUAL(0x30); - SOUNDSOURCE_VIRTUAL(0x34); - SOUNDSOURCE_VIRTUAL(0x38); - SOUNDSOURCE_VIRTUAL(0x3C); - SOUNDSOURCE_VIRTUAL(0x40); - SOUNDSOURCE_VIRTUAL(0x44); - virtual bool hasPlayingSounds() const = 0; // 0x48 - SOUNDSOURCE_VIRTUAL(0x4C); - SOUNDSOURCE_VIRTUAL(0x50); - SOUNDSOURCE_VIRTUAL(0x54); - SOUNDSOURCE_VIRTUAL(0x58); - SOUNDSOURCE_VIRTUAL(0x5C); - SOUNDSOURCE_VIRTUAL(0x60); - SOUNDSOURCE_VIRTUAL(0x64); - SOUNDSOURCE_VIRTUAL(0x68); - SOUNDSOURCE_VIRTUAL(0x6C); - SOUNDSOURCE_VIRTUAL(0x70); - SOUNDSOURCE_VIRTUAL(0x74); - SOUNDSOURCE_VIRTUAL(0x78); - SOUNDSOURCE_VIRTUAL(0x7C); - SOUNDSOURCE_VIRTUAL(0x80); - SOUNDSOURCE_VIRTUAL(0x84); - SOUNDSOURCE_VIRTUAL(0x88); - SOUNDSOURCE_VIRTUAL(0x8C); - SOUNDSOURCE_VIRTUAL(0x90); - SOUNDSOURCE_VIRTUAL(0x94); - SOUNDSOURCE_VIRTUAL(0x98); - SOUNDSOURCE_VIRTUAL(0x9C); - SOUNDSOURCE_VIRTUAL(0xA0); - SOUNDSOURCE_VIRTUAL(0xA4); - SOUNDSOURCE_VIRTUAL(0xA8); - SOUNDSOURCE_VIRTUAL(0xAC); - SOUNDSOURCE_VIRTUAL(0xB0); - SOUNDSOURCE_VIRTUAL(0xB4); - SOUNDSOURCE_VIRTUAL(0xB8); - SOUNDSOURCE_VIRTUAL(0xBC); - SOUNDSOURCE_VIRTUAL(0xC0); - SOUNDSOURCE_VIRTUAL(0xC4); - SOUNDSOURCE_VIRTUAL(0xC8); - SOUNDSOURCE_VIRTUAL(0xCC); - SOUNDSOURCE_VIRTUAL(0xD0); - SOUNDSOURCE_VIRTUAL(0xD4); - SOUNDSOURCE_VIRTUAL(0xD8); - SOUNDSOURCE_VIRTUAL(0xDC); - SOUNDSOURCE_VIRTUAL(0xE0); - SOUNDSOURCE_VIRTUAL(0xE4); - SOUNDSOURCE_VIRTUAL(0xE8); - SOUNDSOURCE_VIRTUAL(0xEC); - SOUNDSOURCE_VIRTUAL(0xF0); - SOUNDSOURCE_VIRTUAL(0xF4); - SOUNDSOURCE_VIRTUAL(0xF8); - SOUNDSOURCE_VIRTUAL(0xFC); - - virtual bool isReadyMaybe() = 0; // 0x100 - virtual bool load(void *data, const char *name) = 0; // 0x104 - virtual void setFrame(f32 frame) = 0; // 0x108 - virtual void setRate(f32 frame) = 0; // 0x10C - virtual void set_0x164(UNKWORD val) = 0; // 0x114 - - SOUNDSOURCE_VIRTUAL(0x118); - SOUNDSOURCE_VIRTUAL(0x11C); -}; - class dSoundSource_c : public dSoundSourceIf_c, public dSnd3DActor_c { public: dSoundSource_c(u8, dAcBase_c *, UNKWORD, UNKWORD); @@ -131,7 +53,19 @@ public: virtual void d_s_vt_0x1E8(); // Overrides of dSoundSourceIf_c - virtual bool hasPlayingSounds() const override; + + virtual const nw4r::math::VEC3 &getListenerPosition() const override; + + virtual bool hasPlayingSounds() const override; // 0x48 + virtual bool isPlayingSound(u32 soundId) override; // 0x4C + virtual bool isPlayingSound(const char *soundId) override; // 0x50 + + virtual bool isReadyMaybe() override { + return false; + } // 0x100 + virtual void load(void *data, const char *name) override {} // 0x104 + virtual void setFrame(f32 frame) override {} // 0x108 + virtual void setRate(f32 frame) override {} // 0x10C private: // at 0x00: dSoundSourceIf_c vtable diff --git a/include/d/snd/d_snd_source_if.h b/include/d/snd/d_snd_source_if.h new file mode 100644 index 00000000..32973df0 --- /dev/null +++ b/include/d/snd/d_snd_source_if.h @@ -0,0 +1,85 @@ +#ifndef D_SOUND_SOURCE_IF_H +#define D_SOUND_SOURCE_IF_H + +#include "common.h" +#include "nw4r/math/math_types.h" + +class dAcBase_c; + +class dSoundSourceIf_c { +public: + virtual ~dSoundSourceIf_c() {} +#define SOUNDSOURCE_VIRTUAL(offset) virtual void vt_##offset() = 0; + SOUNDSOURCE_VIRTUAL(0x0C); + SOUNDSOURCE_VIRTUAL(0x10); + SOUNDSOURCE_VIRTUAL(0x14); + SOUNDSOURCE_VIRTUAL(0x18); + SOUNDSOURCE_VIRTUAL(0x1C); + SOUNDSOURCE_VIRTUAL(0x20); + SOUNDSOURCE_VIRTUAL(0x24); + virtual const nw4r::math::VEC3 &getListenerPosition() const = 0; // 0x28 + SOUNDSOURCE_VIRTUAL(0x2C); + SOUNDSOURCE_VIRTUAL(0x30); + SOUNDSOURCE_VIRTUAL(0x34); + SOUNDSOURCE_VIRTUAL(0x38); + SOUNDSOURCE_VIRTUAL(0x3C); + SOUNDSOURCE_VIRTUAL(0x40); + SOUNDSOURCE_VIRTUAL(0x44); + virtual bool hasPlayingSounds() const = 0; // 0x48 + virtual bool isPlayingSound(u32 soundId) = 0; // 0x4C + virtual bool isPlayingSound(const char *soundId) = 0; // 0x50 + SOUNDSOURCE_VIRTUAL(0x54); + SOUNDSOURCE_VIRTUAL(0x58); + SOUNDSOURCE_VIRTUAL(0x5C); + SOUNDSOURCE_VIRTUAL(0x60); + SOUNDSOURCE_VIRTUAL(0x64); + SOUNDSOURCE_VIRTUAL(0x68); + SOUNDSOURCE_VIRTUAL(0x6C); + SOUNDSOURCE_VIRTUAL(0x70); + SOUNDSOURCE_VIRTUAL(0x74); + SOUNDSOURCE_VIRTUAL(0x78); + SOUNDSOURCE_VIRTUAL(0x7C); + SOUNDSOURCE_VIRTUAL(0x80); + SOUNDSOURCE_VIRTUAL(0x84); + SOUNDSOURCE_VIRTUAL(0x88); + SOUNDSOURCE_VIRTUAL(0x8C); + SOUNDSOURCE_VIRTUAL(0x90); + SOUNDSOURCE_VIRTUAL(0x94); + SOUNDSOURCE_VIRTUAL(0x98); + SOUNDSOURCE_VIRTUAL(0x9C); + SOUNDSOURCE_VIRTUAL(0xA0); + SOUNDSOURCE_VIRTUAL(0xA4); + SOUNDSOURCE_VIRTUAL(0xA8); + SOUNDSOURCE_VIRTUAL(0xAC); + SOUNDSOURCE_VIRTUAL(0xB0); + SOUNDSOURCE_VIRTUAL(0xB4); + SOUNDSOURCE_VIRTUAL(0xB8); + SOUNDSOURCE_VIRTUAL(0xBC); + SOUNDSOURCE_VIRTUAL(0xC0); + SOUNDSOURCE_VIRTUAL(0xC4); + SOUNDSOURCE_VIRTUAL(0xC8); + SOUNDSOURCE_VIRTUAL(0xCC); + SOUNDSOURCE_VIRTUAL(0xD0); + SOUNDSOURCE_VIRTUAL(0xD4); + SOUNDSOURCE_VIRTUAL(0xD8); + SOUNDSOURCE_VIRTUAL(0xDC); + SOUNDSOURCE_VIRTUAL(0xE0); + SOUNDSOURCE_VIRTUAL(0xE4); + SOUNDSOURCE_VIRTUAL(0xE8); + SOUNDSOURCE_VIRTUAL(0xEC); + SOUNDSOURCE_VIRTUAL(0xF0); + SOUNDSOURCE_VIRTUAL(0xF4); + SOUNDSOURCE_VIRTUAL(0xF8); + SOUNDSOURCE_VIRTUAL(0xFC); + + virtual bool isReadyMaybe() = 0; // 0x100 + virtual void load(void *data, const char *name) = 0; // 0x104 + virtual void setFrame(f32 frame) = 0; // 0x108 + virtual void setRate(f32 frame) = 0; // 0x10C + + SOUNDSOURCE_VIRTUAL(0x110); + SOUNDSOURCE_VIRTUAL(0x114); + SOUNDSOURCE_VIRTUAL(0x118); +}; + +#endif diff --git a/include/nw4r/snd/snd_SeqSoundHandle.h b/include/nw4r/snd/snd_SeqSoundHandle.h index 709701ed..374a966c 100644 --- a/include/nw4r/snd/snd_SeqSoundHandle.h +++ b/include/nw4r/snd/snd_SeqSoundHandle.h @@ -8,6 +8,7 @@ #include "common.h" // nullptr #include "nw4r/snd/snd_SeqSound.h" +#include "nw4r/snd/snd_SeqTrack.h" #include "nw4r/ut/ut_NonCopyable.h" // ut::NonCopyable /******************************************************************************* @@ -29,6 +30,7 @@ namespace nw4r { namespace snd // methods public: SeqSoundHandle(SoundHandle*); + ~SeqSoundHandle() { DetachSound(); } // methods bool IsAttachedSound() const { return mSound != nullptr; } @@ -39,6 +41,26 @@ namespace nw4r { namespace snd mSound->WriteVariable(varNo, value); } + void ReadVariable(int varNo, s16 *value) { + if (IsAttachedSound()) + mSound->ReadVariable(varNo, value); + } + + void SetTrackMute(u32 trackFlags, SeqMute mute) { + if (IsAttachedSound()) + mSound->SetTrackMute(trackFlags, mute); + } + + void SetTempoRatio(f32 tempoRatio) { + if (IsAttachedSound()) + mSound->SetTempoRatio(tempoRatio); + } + + void SetVolume(u32 trackFlags, f32 volume) { + if (IsAttachedSound()) + mSound->SetTrackVolume(trackFlags, volume); + } + // members private: /* base ut::NonCopyable */ // size 0x00, offset 0x00 diff --git a/include/nw4r/snd/snd_SoundHandle.h b/include/nw4r/snd/snd_SoundHandle.h index cf1ed317..e8d1a3c0 100644 --- a/include/nw4r/snd/snd_SoundHandle.h +++ b/include/nw4r/snd/snd_SoundHandle.h @@ -34,6 +34,22 @@ namespace nw4r { namespace snd const detail::BasicSound *detail_GetAttachedSound() const { return mSound; } void DetachSound(); + + void FadeIn(int fadeFrames) { + if (IsAttachedSound()) + mSound->FadeIn(fadeFrames); + } + + void SetVolume(f32 volume, int frames) { + if (IsAttachedSound()) + mSound->SetVolume(volume, frames); + } + + void SetPitch(f32 volume) { + if (IsAttachedSound()) + mSound->SetPitch(volume); + } + void Stop() { if (IsAttachedSound()) mSound->Stop(0); diff --git a/include/nw4r/snd/snd_StrmSoundHandle.h b/include/nw4r/snd/snd_StrmSoundHandle.h index 3e92331c..e377ed9a 100644 --- a/include/nw4r/snd/snd_StrmSoundHandle.h +++ b/include/nw4r/snd/snd_StrmSoundHandle.h @@ -8,6 +8,7 @@ #include "common.h" // nullptr #include "nw4r/snd/snd_SoundHandle.h" +#include "nw4r/snd/snd_StrmSound.h" #include "nw4r/ut/ut_NonCopyable.h" // ut::NonCopyable /******************************************************************************* @@ -30,10 +31,16 @@ namespace nw4r { namespace snd public: // methods StrmSoundHandle(SoundHandle*); + ~StrmSoundHandle() { DetachSound(); } bool IsAttachedSound() const { return mSound != nullptr; } void DetachSound(); + void SetVolume(u32 trackFlags, f32 volume, int fadeFrames) { + if (IsAttachedSound()) + mSound->SetTrackVolume(trackFlags, volume, fadeFrames); + } + // members private: /* base NonCopyable */ // size 0x00, offset 0x00 diff --git a/src/REL/d/t/d_t_sound_area.cpp b/src/REL/d/t/d_t_sound_area.cpp index 46112c97..655caa73 100644 --- a/src/REL/d/t/d_t_sound_area.cpp +++ b/src/REL/d/t/d_t_sound_area.cpp @@ -52,7 +52,7 @@ int dTgSndAr_c::actorExecute() { link->setBit_field_0xE8(params & 0xFF); } if (dSnd3DManager_c::GetInstance() != nullptr) { - mVec3_c pos = dSnd3DManager_c::GetInstance()->getListenerPos(); + mVec3_c pos = dSnd3DManager_c::GetInstance()->getCameraTargetPos(); if (checkPosInArea(pos) && dTgSndMg_c::GetInstance() != nullptr) { dTgSndMg_c::GetInstance()->setBgmFlag(params & 0xFF); } diff --git a/src/d/snd/d_snd_3d_actor.cpp b/src/d/snd/d_snd_3d_actor.cpp index 4ca49c4b..b96ad650 100644 --- a/src/d/snd/d_snd_3d_actor.cpp +++ b/src/d/snd/d_snd_3d_actor.cpp @@ -20,7 +20,7 @@ dSnd3DActor_c::dSnd3DActor_c(UNKTYPE *a1, u8 a2) a_field_0x88(0.0f), a_field_0x8C(0.0f), a_field_0x90(INFINITY), - a_field_0x94(INFINITY), + mDistanceToListener(INFINITY), a_field_0x98(0.0f), a_field_0x9C(0.0f), a_field_0xC8(a1), @@ -41,13 +41,34 @@ void dSnd3DActor_c::d_vt_0x34(const nw4r::math::VEC3 &rPosition) { mFlags = 0; } +void dSnd3DActor_c::updatePositionRelativeToListener() { + if (!checkFlag(1)) { + calculatePositionRelativeToListener(); + setFlag(1); + } +} + +void dSnd3DActor_c::calculatePositionRelativeToListener() { + nw4r::math::VEC3Sub( + &mPositionRelativeToListener, &GetPosition(), &dSnd3DManager_c::GetInstance()->getSndListenerPos() + ); +} + +void dSnd3DActor_c::updateDistanceToListener() { + if (!checkFlag(2)) { + updatePositionRelativeToListener(); + mDistanceToListener = VEC3Len(&mPositionRelativeToListener); + setFlag(2); + } +} + void dSnd3DActor_c::updatePositionRelativeToPlayer() { if (!checkFlag(0x40)) { nw4r::math::VEC3 linkTranslation = dAcPy_c::GetLink()->getCenterTranslation(); nw4r::math::VEC3 pos = GetPosition(); nw4r::math::VEC3Sub(&mPositionRelativeToPlayer, &pos, &linkTranslation); - mFlags |= 0x40; + setFlag(0x40); } } @@ -68,7 +89,7 @@ void dSnd3DActor_c::updateDistanceToPlayer() { } else { mDistanceToPlayer = nw4r::math::VEC3Len(&mPositionRelativeToPlayer); } - mFlags |= 0x80; + setFlag(0x80); } } diff --git a/src/d/snd/d_snd_3d_manager.cpp b/src/d/snd/d_snd_3d_manager.cpp index 39e18a63..1bbf9717 100644 --- a/src/d/snd/d_snd_3d_manager.cpp +++ b/src/d/snd/d_snd_3d_manager.cpp @@ -11,15 +11,15 @@ template class SndMgrDisposer; -dSnd3DManager_c::dSnd3DManager_c() : mIsSetup(false), field_0x11(0) { +dSnd3DManager_c::dSnd3DManager_c() : mIsSetup(false), mCalculationsFresh(0) { mCameraPosSqVelocity = 0.0f; mCameraAtSqVelocity = 0.0f; mCamDistance = 0.9f; mTimer = 0; mpEngine = new dSnd3DEngine_c(); - field_0x138.x = 0.0f; - field_0x138.y = 0.0f; - field_0x138.z = 1.0f; + mCameraDirectionNormalized.x = 0.0f; + mCameraDirectionNormalized.y = 0.0f; + mCameraDirectionNormalized.z = 1.0f; } void dSnd3DManager_c::setup() { @@ -51,12 +51,14 @@ void dSnd3DManager_c::resetCamDistance() { void dSnd3DManager_c::setCamDistance(f32 value) { // @bug ? not actually clamped - nw4r::ut::Clamp(value, -1.0f, 2.0f); + (void)nw4r::ut::Clamp(value, -1.0f, 2.0f); mCamDistance = value; } void dSnd3DManager_c::calc() { - field_0x11 = 0; + // Don't actually calculate anything, + // but allow re-calculations this frame. + mCalculationsFresh = false; } void dSnd3DManager_c::clearState() { @@ -67,7 +69,7 @@ void dSnd3DManager_c::clearState() { void dSnd3DManager_c::updateFromCamera(EGG::LookAtCamera &camera) { - if (field_0x11) { + if (mCalculationsFresh) { return; } @@ -122,14 +124,14 @@ void dSnd3DManager_c::updateFromCamera(EGG::LookAtCamera &camera) { mCamera = camera; updateListenerPos(dist); - field_0x11 = 1; + mCalculationsFresh = true; } void dSnd3DManager_c::updateListenerPos(f32 f) { const EGG::Matrix34f &mtx = mCamera.getViewMatrix(); mListener.SetMatrix(*mtx); EGG::Vector3f dir = mCamera.getDirection(); - VECNormalize(dir, field_0x138); + VECNormalize(dir, mCameraDirectionNormalized); dir *= f; - mSoundListenerPosition = mCamera.mPos + dir; + mCameraTargetPosition = mCamera.mPos + dir; } diff --git a/src/d/snd/d_snd_control_player.cpp b/src/d/snd/d_snd_control_player.cpp new file mode 100644 index 00000000..d82931f7 --- /dev/null +++ b/src/d/snd/d_snd_control_player.cpp @@ -0,0 +1,71 @@ +#include "d/snd/d_snd_control_player.h" + +#include "common.h" +#include "d/snd/d_snd_sound.h" +#include "nw4r/snd/snd_SoundPlayer.h" +#include "nw4r/snd/snd_global.h" + +dSndControlPlayerVolumeBase_c::dSndControlPlayerVolumeBase_c() : dSndControlPlayer_c(1.0f, 0.0f, 1.0f) { + mpPlayer = nullptr; + mIndex = 0; +} + +void dSndControlPlayer_c::reset() { + dSndControl_c::reset(); + apply(); +} + +extern "C" void *lbl_80575D4C; +extern "C" nw4r::snd::SoundPlayer *fn_803600B0(void *, s32); +extern "C" nw4r::snd::SoundPlayer *fn_80360120(void *, s32); + +void dSndControlPlayer_c::setIndex1(s32 idx) { + mpPlayer = fn_803600B0(lbl_80575D4C, idx); + mIndex = idx; +} + +void dSndControlPlayer_c::setIndex2(s32 idx) { + mpPlayer = fn_80360120(lbl_80575D4C, idx); + mIndex = idx; +} + +void dSndControlPlayer_c::stop() { + mCurrValue = getAppliedValue(); + dSndControl_c::stop(); +} + +void dSndControlPlayerVolume_c::apply() { + mpPlayer->SetVolume(mCurrValue); +} + +f32 dSndControlPlayerVolume_c::getAppliedValue() { + return mpPlayer->GetVolume(); +} + +void dSndControlPlayerLpfFreq_c::apply() { + mpPlayer->SetLpfFreq(mCurrValue); +} + +f32 dSndControlPlayerLpfFreq_c::getAppliedValue() { + return mpPlayer->GetLpfFreq(); +} + +void dSndControlPlayerFxSend_c::apply() { + if (mCurrValue < mMin) { + mCurrValue = mMin; + } + if (mCurrValue >= mMax) { + mCurrValue = mMax; + } + mpPlayer->SetFxSend(nw4r::snd::AUX_B, mCurrValue); +} + +extern "C" bool fn_8035F030(s32); + +f32 dSndControlPlayerFxSend_c::getAppliedValue() { + int auxBus = nw4r::snd::AUX_A; + if (fn_8035F030(mIndex)) { + auxBus = nw4r::snd::AUX_B; + } + return mpPlayer->GetFxSend(auxBus); +} diff --git a/src/d/snd/d_snd_control_sound.cpp b/src/d/snd/d_snd_control_sound.cpp new file mode 100644 index 00000000..cdffeaf1 --- /dev/null +++ b/src/d/snd/d_snd_control_sound.cpp @@ -0,0 +1,100 @@ + +#include "common.h" +#include "d/snd/d_snd_calc_pitch.h" +#include "d/snd/d_snd_sound.h" +#include "nw4r/snd/snd_SeqSoundHandle.h" +#include "nw4r/snd/snd_StrmSoundHandle.h" + +// I'm not super happy with these base class function in a separate file, +// but either we add another intermediate class or this is ok. It's weird +// that d_snd_sound has dSndControl_c::stop though + +void dSndControl_c::reset() { + mCurrValue = mResetValue; + mStartValue = mResetValue; + mTargetValue = mResetValue; + mDuration = 0; + mTimer = 0; +} + +void dSndControl_c::stop() { + // field_0x10 = field_0x04; + mStartValue = mCurrValue; + mTargetValue = mCurrValue; + mDuration = 0; + mTimer = 0; +} + +void dSndControl_c::set(f32 value, s32 frames) { + stop(); + f32 clamped = value; + if (clamped > mMax) { + clamped = mMax; + } else if (clamped < mMin) { + clamped = mMin; + } + if (clamped != mCurrValue) { + mTargetValue = clamped; + if (frames == 0) { + mCurrValue = clamped; + } else { + mDuration = frames; + mTimer = 0; + } + } +} + +void dSndControl_c::calc() { + if (mTimer < mDuration) { + mTimer++; + if (mTimer == mDuration) { + mCurrValue = mTargetValue; + } else { + mCurrValue = mStartValue + (mTimer * (mTargetValue - mStartValue) / mDuration); + } + } +} + +void dSndControlSoundVolume_c::apply(dSndSound_c *sound) { + sound->SetVolume(mCurrValue, 0); +} + +void dSndControlSoundPitch_c::apply(dSndSound_c *sound) { + sound->SetPitch(mCurrValue); +} + +void d_snd_control_sound_float_order() { + -24.0f; + 24.0f; +} + +dSndControlSoundPitchLinear_c::dSndControlSoundPitchLinear_c() : dSndControlSound_c(0.0f, -24.0f, 24.0f) { + mpOtherControl = nullptr; +} + +void dSndControlSoundPitchLinear_c::set(f32 value, s32 frames) { + if (mpOtherControl != nullptr) { + mCurrValue = pitchIdxTenthsForPitchScale(mpOtherControl->getCurrentValue()); + } + + dSndControlSound_c::set(value, frames); +} + +void dSndControlSoundPitchLinear_c::apply(dSndSound_c *pHandle) { + pHandle->setPitchRelated(pitchScaleForPitchIdxTenths(mCurrValue), 0); +} + +void dSndControlSoundSeqTrackTempoRatio_c::apply(dSndSound_c *sound) { + nw4r::snd::SeqSoundHandle handle(sound); + handle.SetTempoRatio(mCurrValue); +} + +void dSndControlSoundSeqTrackVolume_c::apply(dSndSound_c *sound) { + nw4r::snd::SeqSoundHandle handle(sound); + handle.SetVolume(mMask, mCurrValue); +} + +void dSndControlSoundStrmTrackVolume_c::apply(dSndSound_c *sound) { + nw4r::snd::StrmSoundHandle handle(sound); + handle.SetVolume(mMask, mCurrValue, 0); +} diff --git a/src/d/snd/d_snd_player_mgr.cpp b/src/d/snd/d_snd_player_mgr.cpp index 0edee554..9fdf769a 100644 --- a/src/d/snd/d_snd_player_mgr.cpp +++ b/src/d/snd/d_snd_player_mgr.cpp @@ -52,6 +52,26 @@ u32 dSndPlayerMgr_c::convertLabelStringToSoundId(const char *label) const { return dSndMgr_c::GetInstance()->changeNameToId(label); } +nw4r::snd::SoundArchivePlayer &dSndPlayerMgr_c::getSoundArchivePlayerForType(u8 type) { + if (canUseThisPlayer(type)) { + return mSoundArchivePlayer; + } + return *dSndMgr_c::getPlayer(); +} + +bool dSndPlayerMgr_c::canUseThisPlayer(u8 type) const { + if (!mSoundArchivePlayer.IsAvailable()) { + return false; + } + + int ty = type; + + if ((ty >= 0 && ty <= 1) || ty == 58) { + return true; + } + return false; +} + bool dSndPlayerMgr_c::loadDemoArchive(const char *demoArchiveName) { if (demoArchiveName == nullptr) { return false; @@ -84,3 +104,15 @@ bool dSndPlayerMgr_c::loadDemoArchive(const char *demoArchiveName) { } return ok; } + +void dSndPlayerMgr_c::shutdown() { + mSoundArchivePlayer.Shutdown(); + mSoundArchive.Shutdown(); +} + + +void dSndPlayerMgr_c::calc() { + if (mSoundArchivePlayer.IsAvailable()) { + mSoundArchivePlayer.Update(); + } +} diff --git a/src/d/snd/d_snd_sound.cpp b/src/d/snd/d_snd_sound.cpp new file mode 100644 index 00000000..03d3b20d --- /dev/null +++ b/src/d/snd/d_snd_sound.cpp @@ -0,0 +1,135 @@ +#include "d/snd/d_snd_sound.h" + +#include "common.h" +#include "d/snd/d_snd_mgr.h" +#include "nw4r/snd/snd_SeqSoundHandle.h" +#include "nw4r/snd/snd_SoundArchive.h" +#include "nw4r/ut/ut_list.h" + +dSndSound_c::dSndSound_c() : field_0x10(0), field_0x14(0), field_0x15(0), field_0x16(0), field_0x17(0) { + nw4r::ut::List_Init(&mList, 0x24); + + mpCtrlSeqTrackVolume = new dSndControlSoundSeqTrackVolume_c[16](); + for (int i = 0; i < 16; i++) { + mpCtrlSeqTrackVolume[i].setMask(1 << i); + } + + mpCtrlStrmTrackVolume = new dSndControlSoundStrmTrackVolume_c[3](); + // @bug should be 3, not 16 + for (int i = 0; i < 16; i++) { + mpCtrlStrmTrackVolume[i].setMask(1 << i); + } + + mCtrlUnk.setControl(&mCtrlPitch); + reset(); +} + +dSndSound_c::~dSndSound_c() { + if (mpCtrlSeqTrackVolume != nullptr) { + delete[] mpCtrlSeqTrackVolume; + } + if (mpCtrlStrmTrackVolume != nullptr) { + delete[] mpCtrlStrmTrackVolume; + } +} + +void dSndSound_c::reset() { + mCtrlVolume.reset(); + mCtrlVolume.apply(this); + mCtrlPitch.reset(); + mCtrlPitch.apply(this); + mCtrlUnk.reset(); + mCtrlUnk.apply(this); + mpCtrlSeqTrackTempoRatio.reset(); + mpCtrlSeqTrackTempoRatio.apply(this); + field_0x15 = 0; + resetTrackVolumes(); +} + +void dSndSound_c::fadeIn(u32 id, int fadeFrames) { + if (id != -1) { + if (fadeFrames != 0) { + FadeIn(fadeFrames); + } + vt_0x08(); + field_0x16 = 1; + } +} + +bool dSndSound_c::isStrmSound() { + if (!IsAttachedSound()) { + return false; + } + return dSndMgr_c::GetInstance()->getArchive()->GetSoundType(GetId()) == nw4r::snd::SoundArchive::SOUND_TYPE_STRM; +} + +bool dSndSound_c::isWaveSound() { + if (!IsAttachedSound()) { + return false; + } + return dSndMgr_c::GetInstance()->getArchive()->GetSoundType(GetId()) == nw4r::snd::SoundArchive::SOUND_TYPE_WAVE; +} + +bool dSndSound_c::isSeqSound() { + if (!IsAttachedSound()) { + return false; + } + return dSndMgr_c::GetInstance()->getArchive()->GetSoundType(GetId()) == nw4r::snd::SoundArchive::SOUND_TYPE_SEQ; +} + +s16 dSndSound_c::readSeqTrackVariable(int varNo) { + if (!isSeqSound()) { + return -1; + } + s16 val = -1; + nw4r::snd::SeqSoundHandle handle(this); + handle.ReadVariable(varNo, &val); + return val; +} + +void dSndSound_c::writeSeqTrackVariable(int varNo, s16 value) { + if (!isSeqSound()) { + return; + } + nw4r::snd::SeqSoundHandle handle(this); + handle.WriteVariable(varNo, value); +} + +void dSndSound_c::resetTrackVolumes() { + if (mpCtrlSeqTrackVolume != nullptr) { + for (int i = 0; i < 16; i++) { + mpCtrlSeqTrackVolume[i].reset(); + mpCtrlSeqTrackVolume[i].apply(this); + } + } + + if (mpCtrlStrmTrackVolume != nullptr) { + for (int i = 0; i < 3; i++) { + mpCtrlStrmTrackVolume[i].reset(); + mpCtrlStrmTrackVolume[i].apply(this); + } + } +} + +void dSndSound_c::setSeqTrackMute(u32 trackFlags, nw4r::snd::SeqMute mute) { + if (isSeqSound()) { + nw4r::snd::SeqSoundHandle handle(this); + handle.SetTrackMute(trackFlags, mute); + } +} + +void dSndSound_c::stop() { + vt_0x08(); + Stop(); +} + +// Might be a separate file +void dSndControl_c::configure(f32 value, f32 min, f32 max) { + mResetValue = value; + mMin = min; + mMax = max; + mCurrValue = value; + mStartValue = value; + mTargetValue = value; + reset(); +} diff --git a/src/d/snd/d_snd_source.cpp b/src/d/snd/d_snd_source.cpp index 68a312bb..11a1589e 100644 --- a/src/d/snd/d_snd_source.cpp +++ b/src/d/snd/d_snd_source.cpp @@ -2,6 +2,7 @@ #include "common.h" #include "d/snd/d_snd_3d_actor.h" +#include "d/snd/d_snd_3d_manager.h" #include "nw4r/snd/snd_SoundStartable.h" #include "nw4r/ut/ut_list.h" #include "sized_string.h" @@ -56,10 +57,22 @@ dSoundSource_c::~dSoundSource_c() { fn_80386C70(this); } +const nw4r::math::VEC3 &dSoundSource_c::getListenerPosition() const { + return dSnd3DManager_c::GetInstance()->getSndListenerPos(); +} + bool dSoundSource_c::hasPlayingSounds() const { return dSnd3DActor_c::hasPlayingSounds(); } +bool dSoundSource_c::isPlayingSound(u32 soundId) { + return dSnd3DActor_c::isPlayingSound(soundId); +} + +bool dSoundSource_c::isPlayingSound(const char *soundId) { + return isPlayingSound(soundLabelToSoundId(soundId)); +} + void dSoundSource_c::d_vt_0x38(bool flag, int fadeFrames) { if (flag == 0) { PauseAllSound(flag, fadeFrames); diff --git a/src/nw4r/snd/snd_AnimSound.cpp b/src/nw4r/snd/snd_AnimSound.cpp index ab8151aa..0ba0b144 100644 --- a/src/nw4r/snd/snd_AnimSound.cpp +++ b/src/nw4r/snd/snd_AnimSound.cpp @@ -426,7 +426,6 @@ void AnimEventPlayer::SetVariable(const AnimEvent *event, u32 varNo, f32 f) { SeqSoundHandle handle(GetHandle()); int iVal = f * 100.0f; handle.WriteVariable(varNo, ut::Clamp(iVal, -0x8000, 0x7FFF)); - handle.DetachSound(); } } else if (varNo < 32) { int iVal = f * 100.0f;