From d016bf80054ee09370809fc88f1e103532e5b03e Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 25 May 2025 21:57:46 +0200 Subject: [PATCH] snd_BasicPlayer OK --- .../rels/d_t_gate_to_groundNP/symbols.txt | 2 +- config/SOUE01/splits.txt | 5 ++ config/SOUE01/symbols.txt | 76 +++++++++---------- configure.py | 4 +- include/nw4r/snd/snd_AxManager.h | 13 ++-- include/nw4r/snd/snd_BasicPlayer.h | 5 +- src/nw4r/snd/snd_AxManager.cpp | 16 +++- src/nw4r/snd/snd_BasicPlayer.cpp | 13 ++++ 8 files changed, 84 insertions(+), 50 deletions(-) diff --git a/config/SOUE01/rels/d_t_gate_to_groundNP/symbols.txt b/config/SOUE01/rels/d_t_gate_to_groundNP/symbols.txt index 00eb2edf..49256b1d 100644 --- a/config/SOUE01/rels/d_t_gate_to_groundNP/symbols.txt +++ b/config/SOUE01/rels/d_t_gate_to_groundNP/symbols.txt @@ -10,7 +10,7 @@ draw__17dTgGateToGround_cFv = .text:0x000002F0; // type:function size:0x8 __dt__17dTgGateToGround_cFv = .text:0x00000300; // type:function size:0x70 _ctors = .ctors:0x00000000; // type:label scope:global _dtors = .dtors:0x00000000; // type:label scope:global -@20562 = .rodata:0x00000000; // type:object size:0x4 data:float scope:local +@20562 = .rodata:0x00000000; // type:object size:0x4 scope:local data:float g_profile_GATE2GND_TAG = .data:0x00000000; // type:object size:0x10 @20583 = .data:0x00000010; // type:object size:0xC scope:local __vt__17dTgGateToGround_c = .data:0x0000001C; // type:object size:0x74 diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index f07e4a94..e6a42f8c 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2895,6 +2895,9 @@ nw4r/snd/snd_AnimSound.cpp: nw4r/snd/snd_AxManager.cpp: .text start:0x804630E0 end:0x80464880 align:16 .ctors start:0x804DB958 end:0x804DB95C + .sbss start:0x80576650 end:0x80576668 + .sdata2 start:0x8057EF18 end:0x8057EF30 + .bss start:0x80658F80 end:0x80659390 nw4r/snd/snd_AxVoice.cpp: .text start:0x80464880 end:0x80467634 align:16 @@ -2913,6 +2916,8 @@ nw4r/snd/snd_BankFile.cpp: nw4r/snd/snd_BasicPlayer.cpp: .text start:0x80468910 end:0x80468B50 align:16 + .data start:0x8056DB38 end:0x8056DB60 + .sdata2 start:0x8057EF80 end:0x8057EF88 nw4r/snd/snd_BasicSound.cpp: .text start:0x80468B50 end:0x8046A36C align:16 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index c438e780..cfb5a8f4 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -21769,7 +21769,7 @@ fn_8039EDC0 = .text:0x8039EDC0; // type:function size:0x28C AXSetVoiceState = .text:0x8039F050; // type:function size:0x70 AXSetVoiceAddr = .text:0x8039F0C0; // type:function size:0xE8 AXGetLpfCoefs = .text:0x8039F1B0; // type:function size:0xBC -fn_8039F270 = .text:0x8039F270; // type:function size:0x8 +AXSetMaxDspCycles = .text:0x8039F270; // type:function size:0x8 AXGetMaxVoices = .text:0x8039F280; // type:function size:0x8 fn_8039F290 = .text:0x8039F290; // type:function size:0x40 fn_8039F2D0 = .text:0x8039F2D0; // type:function size:0x64 @@ -25031,10 +25031,10 @@ nw4r__snd__detail__AnimSoundFileReader__GetEventCount = .text:0x80462FB0; // typ nw4r__snd__detail__AnimSoundFileReader__GetEventRef = .text:0x80463000; // type:function size:0x58 nw4r__snd__detail__AnimSoundFileReader__GetEvent = .text:0x80463060; // type:function size:0x74 __ct__Q44nw4r3snd6detail9AxManagerFv = .text:0x804630E0; // type:function size:0x218 -__ct__Q34nw4r2ut30LinkListFv = .text:0x80463300; // type:function size:0x18 -__dt__Q34nw4r2ut30LinkListFv = .text:0x80463320; // type:function size:0x58 +__ct__Q34nw4r2ut30LinkListFv = .text:0x80463300; // type:function size:0x18 scope:weak +__dt__Q34nw4r2ut30LinkListFv = .text:0x80463320; // type:function size:0x58 scope:weak GetInstance__Q44nw4r3snd6detail9AxManagerFv = .text:0x80463380; // type:function size:0x64 -__dt__Q44nw4r3snd6detail9AxManagerFv = .text:0x804633F0; // type:function size:0x78 +__dt__Q44nw4r3snd6detail9AxManagerFv = .text:0x804633F0; // type:function size:0x78 scope:weak Init__Q44nw4r3snd6detail9AxManagerFv = .text:0x80463470; // type:function size:0x128 GetOutputVolume__Q44nw4r3snd6detail9AxManagerCFv = .text:0x804635A0; // type:function size:0x6C Update__Q44nw4r3snd6detail9AxManagerFv = .text:0x80463610; // type:function size:0x3CC @@ -25118,7 +25118,7 @@ SetBiquadFilter__Q44nw4r3snd6detail11BasicPlayerFif = .text:0x80468AD0; // type: SetRemoteFilter__Q44nw4r3snd6detail11BasicPlayerFi = .text:0x80468AE0; // type:function size:0x8 SetRemoteOutVolume__Q44nw4r3snd6detail11BasicPlayerFif = .text:0x80468AF0; // type:function size:0x10 GetRemoteOutVolume__Q44nw4r3snd6detail11BasicPlayerCFi = .text:0x80468B00; // type:function size:0x10 -__dt__Q44nw4r3snd6detail11BasicPlayerFv = .text:0x80468B10; // type:function size:0x40 +__dt__Q44nw4r3snd6detail11BasicPlayerFv = .text:0x80468B10; // type:function size:0x40 scope:weak __ct__Q44nw4r3snd6detail10BasicSoundFii = .text:0x80468B50; // type:function size:0xE0 InitParam__Q44nw4r3snd6detail10BasicSoundFv = .text:0x80468C30; // type:function size:0x154 StartPrepared__Q44nw4r3snd6detail10BasicSoundFv = .text:0x80468D90; // type:function size:0x18 @@ -38584,13 +38584,13 @@ __vt__Q34nw4r3g3d12ScnMdlSimple = .data:0x8056DA28; // type:object size:0x48 __vt__Q34nw4r3g3d6ScnMdl = .data:0x8056DA70; // type:object size:0x48 @10666 = .data:0x8056DAB8; // type:object size:0x46 scope:local data:string __vt__Q34nw4r3g3d7ScnProc = .data:0x8056DB00; // type:object size:0x34 -lbl_8056DB38 = .data:0x8056DB38; // type:object size:0x28 +__vt__Q44nw4r3snd6detail11BasicPlayer = .data:0x8056DB38; // type:object size:0x24 scope:weak lbl_8056DB60 = .data:0x8056DB60; // type:object size:0x38 -lbl_8056DB98 = .data:0x8056DB98; // type:object size:0x10 -lbl_8056DBA8 = .data:0x8056DBA8; // type:object size:0x10 -lbl_8056DBB8 = .data:0x8056DBB8; // type:object size:0x10 -lbl_8056DBC8 = .data:0x8056DBC8; // type:object size:0x10 -lbl_8056DBD8 = .data:0x8056DBD8; // type:object size:0x10 +__vt__Q44nw4r3snd6detail19BiquadFilterBpf2048 = .data:0x8056DB98; // type:object size:0x10 +__vt__Q44nw4r3snd6detail19BiquadFilterBpf1024 = .data:0x8056DBA8; // type:object size:0x10 +__vt__Q44nw4r3snd6detail18BiquadFilterBpf512 = .data:0x8056DBB8; // type:object size:0x10 +__vt__Q44nw4r3snd6detail15BiquadFilterHpf = .data:0x8056DBC8; // type:object size:0x10 +__vt__Q44nw4r3snd6detail15BiquadFilterLpf = .data:0x8056DBD8; // type:object size:0x10 lbl_8056DBE8 = .data:0x8056DBE8; // type:object size:0x68 lbl_8056DC50 = .data:0x8056DC50; // type:object size:0x20 lbl_8056DC70 = .data:0x8056DC70; // type:object size:0x28 @@ -40617,7 +40617,7 @@ lbl_8057406C = .sdata:0x8057406C; // type:object size:0x4 data:4byte lbl_80574070 = .sdata:0x80574070; // type:object size:0x8 lbl_80574078 = .sdata:0x80574078; // type:object size:0x8 lbl_80574080 = .sdata:0x80574080; // type:object size:0x8 -lbl_80574088 = .sdata:0x80574088; // type:object size:0x4 scope:local data:4byte +@14637 = .sdata:0x80574088; // type:object size:0x4 scope:local data:4byte lbl_80574090 = .sdata:0x80574090; // type:object size:0x8 lbl_80574098 = .sdata:0x80574098; // type:object size:0x4 lbl_8057409C = .sdata:0x8057409C; // type:object size:0x4 @@ -42415,13 +42415,13 @@ sTev__Q44nw4r3g3d8G3DState23@unnamed@g3d_state_cpp@ = .sbss:0x80576634; // type: @GUARD@GetViewNrmMtxPtr__Q54nw4r3g3d8G3DState23@unnamed@g3d_state_cpp@19PosNrmMtxArrayStateCFUl@m = .sbss:0x80576638; // type:object size:0x1 scope:weak data:byte sMisc__Q44nw4r3g3d8G3DState23@unnamed@g3d_state_cpp@ = .sbss:0x80576640; // type:object size:0x8 scope:local data:4byte gpCullingFrustum__Q24nw4r3g3d = .sbss:0x80576648; // type:object size:0x4 data:4byte -sBiquadFilterLpf = .sbss:0x80576650; // type:object size:0x4 data:4byte -sBiquadFilterHpf = .sbss:0x80576654; // type:object size:0x4 data:4byte -sBiquadFilterBpf512 = .sbss:0x80576658; // type:object size:0x4 data:4byte -sBiquadFilterBpf1024 = .sbss:0x8057665C; // type:object size:0x4 data:4byte -sBiquadFilterBpf2048 = .sbss:0x80576660; // type:object size:0x4 data:4byte -lbl_80576664 = .sbss:0x80576664; // type:object size:0x1 data:byte -lbl_80576665 = .sbss:0x80576665; // type:object size:0x1 data:byte +sBiquadFilterLpf__Q44nw4r3snd6detail9AxManager = .sbss:0x80576650; // type:object size:0x4 data:4byte +sBiquadFilterHpf__Q44nw4r3snd6detail9AxManager = .sbss:0x80576654; // type:object size:0x4 data:4byte +sBiquadFilterBpf512__Q44nw4r3snd6detail9AxManager = .sbss:0x80576658; // type:object size:0x4 data:4byte +sBiquadFilterBpf1024__Q44nw4r3snd6detail9AxManager = .sbss:0x8057665C; // type:object size:0x4 data:4byte +sBiquadFilterBpf2048__Q44nw4r3snd6detail9AxManager = .sbss:0x80576660; // type:object size:0x4 data:4byte +@GUARD@GetInstance__Q44nw4r3snd6detail9AxManagerFv@instance = .sbss:0x80576664; // type:object size:0x1 scope:weak data:byte +@LOCAL@AiDmaCallbackFunc__Q44nw4r3snd6detail9AxManagerFv@finishedFlag = .sbss:0x80576665; // type:object size:0x1 scope:weak data:byte lbl_80576668 = .sbss:0x80576668; // type:object size:0x8 data:byte lbl_80576670 = .sbss:0x80576670; // type:object size:0x4 data:4byte lbl_80576674 = .sbss:0x80576674; // type:object size:0x4 data:4byte @@ -48327,14 +48327,14 @@ lbl_8057D284 = .sdata2:0x8057D284; // type:object size:0x4 align:4 data:float lbl_8057D288 = .sdata2:0x8057D288; // type:object size:0x4 align:4 data:float lbl_8057D28C = .sdata2:0x8057D28C; // type:object size:0x4 align:4 data:float lbl_8057D290 = .sdata2:0x8057D290; // type:object size:0x4 align:4 data:float -lbl_8057D298 = .sdata2:0x8057D298; // type:object size:0x4 scope:local align:4 data:float -lbl_8057D29C = .sdata2:0x8057D29C; // type:object size:0x4 scope:local align:4 data:float -lbl_8057D2A0 = .sdata2:0x8057D2A0; // type:object size:0x4 scope:local align:4 data:float -lbl_8057D2A4 = .sdata2:0x8057D2A4; // type:object size:0x4 scope:local align:4 data:float -lbl_8057D2A8 = .sdata2:0x8057D2A8; // type:object size:0x4 scope:local align:4 data:float -lbl_8057D2AC = .sdata2:0x8057D2AC; // type:object size:0x4 scope:local align:4 data:float -lbl_8057D2B0 = .sdata2:0x8057D2B0; // type:object size:0x4 scope:local align:4 data:float -lbl_8057D2B4 = .sdata2:0x8057D2B4; // type:object size:0x4 scope:local align:4 data:float +@15358 = .sdata2:0x8057D298; // type:object size:0x4 scope:local align:4 data:float +@15812 = .sdata2:0x8057D29C; // type:object size:0x4 scope:local align:4 data:float +@15813 = .sdata2:0x8057D2A0; // type:object size:0x4 scope:local align:4 data:float +@15814 = .sdata2:0x8057D2A4; // type:object size:0x4 scope:local align:4 data:float +@15815 = .sdata2:0x8057D2A8; // type:object size:0x4 scope:local align:4 data:float +@15816 = .sdata2:0x8057D2AC; // type:object size:0x4 scope:local align:4 data:float +@15817 = .sdata2:0x8057D2B0; // type:object size:0x4 scope:local align:4 data:float +@15818 = .sdata2:0x8057D2B4; // type:object size:0x4 scope:local align:4 data:float lbl_8057D2B8 = .sdata2:0x8057D2B8; // type:object size:0x4 align:4 data:float lbl_8057D2C0 = .sdata2:0x8057D2C0; // type:object size:0x4 align:4 data:float lbl_8057D2C4 = .sdata2:0x8057D2C4; // type:object size:0x4 align:4 data:float @@ -49643,11 +49643,11 @@ lbl_8057EF00 = .sdata2:0x8057EF00; // type:object size:0x8 align:8 data:double lbl_8057EF08 = .sdata2:0x8057EF08; // type:object size:0x8 align:8 data:double lbl_8057EF10 = .sdata2:0x8057EF10; // type:object size:0x4 align:4 data:float lbl_8057EF14 = .sdata2:0x8057EF14; // type:object size:0x4 align:4 data:float -lbl_8057EF18 = .sdata2:0x8057EF18; // type:object size:0x4 align:4 data:float -lbl_8057EF1C = .sdata2:0x8057EF1C; // type:object size:0x4 align:4 data:float -lbl_8057EF20 = .sdata2:0x8057EF20; // type:object size:0x8 align:8 data:double -lbl_8057EF28 = .sdata2:0x8057EF28; // type:object size:0x4 align:4 data:float -lbl_8057EF2C = .sdata2:0x8057EF2C; // type:object size:0x4 align:4 data:float +@2457 = .sdata2:0x8057EF18; // type:object size:0x4 scope:local align:4 data:float +@2458 = .sdata2:0x8057EF1C; // type:object size:0x4 scope:local align:4 data:float +@2523 = .sdata2:0x8057EF20; // type:object size:0x8 scope:local align:8 data:double +@2626 = .sdata2:0x8057EF28; // type:object size:0x4 scope:local align:4 data:float +@3157 = .sdata2:0x8057EF2C; // type:object size:0x4 scope:local align:4 data:float lbl_8057EF30 = .sdata2:0x8057EF30; // type:object size:0x4 align:4 data:float lbl_8057EF34 = .sdata2:0x8057EF34; // type:object size:0x4 align:4 data:float lbl_8057EF38 = .sdata2:0x8057EF38; // type:object size:0x4 align:4 data:float @@ -49662,8 +49662,8 @@ lbl_8057EF60 = .sdata2:0x8057EF60; // type:object size:0x4 align:4 data:float lbl_8057EF68 = .sdata2:0x8057EF68; // type:object size:0x8 align:8 data:double lbl_8057EF70 = .sdata2:0x8057EF70; // type:object size:0x8 align:8 data:double lbl_8057EF78 = .sdata2:0x8057EF78; // type:object size:0x4 align:4 data:float -lbl_8057EF80 = .sdata2:0x8057EF80; // type:object size:0x4 align:4 data:float -lbl_8057EF84 = .sdata2:0x8057EF84; // type:object size:0x4 align:4 data:float +@608 = .sdata2:0x8057EF80; // type:object size:0x4 scope:local align:4 data:float +@609 = .sdata2:0x8057EF84; // type:object size:0x4 scope:local align:4 data:float lbl_8057EF88 = .sdata2:0x8057EF88; // type:object size:0x4 align:4 data:float lbl_8057EF8C = .sdata2:0x8057EF8C; // type:object size:0x4 align:4 data:float lbl_8057EF90 = .sdata2:0x8057EF90; // type:object size:0x8 align:8 data:double @@ -51930,10 +51930,10 @@ sRenderMode__Q44nw4r3g3d8G3DState23@unnamed@g3d_state_cpp@ = .bss:0x80640E48; // IndMtxOpDefault__Q44nw4r3g3d8G3DState23@unnamed@g3d_state_cpp@ = .bss:0x80640E88; // type:object size:0x98 scope:local data:4byte @LOCAL@GetViewNrmMtxPtr__Q54nw4r3g3d8G3DState23@unnamed@g3d_state_cpp@19PosNrmMtxArrayStateCFUl@m = .bss:0x80640F20; // type:object size:0x24 scope:weak sTemp__Q54nw4r3g3d6detail7workmem25@unnamed@g3d_workmem_cpp@ = .bss:0x80640F80; // type:object size:0x18000 scope:local -lbl_80658F80 = .bss:0x80658F80; // type:object size:0x100 -lbl_80659080 = .bss:0x80659080; // type:object size:0x200 -lbl_80659280 = .bss:0x80659280; // type:object size:0xC -lbl_8065928C = .bss:0x8065928C; // type:object size:0x104 data:4byte +sZeroBuffer__Q44nw4r3snd6detail9AxManager = .bss:0x80658F80; // type:object size:0x100 +sBiquadFilterCallbackTable__Q44nw4r3snd6detail9AxManager = .bss:0x80659080; // type:object size:0x200 +@1190 = .bss:0x80659280; // type:object size:0xC scope:local +@LOCAL@GetInstance__Q44nw4r3snd6detail9AxManagerFv@instance = .bss:0x8065928C; // type:object size:0x104 scope:weak data:4byte lbl_80659390 = .bss:0x80659390; // type:object size:0xC lbl_8065939C = .bss:0x8065939C; // type:object size:0x2C data:4byte lbl_806593C8 = .bss:0x806593C8; // type:object size:0x10 diff --git a/configure.py b/configure.py index 5f129583..cba8e03c 100644 --- a/configure.py +++ b/configure.py @@ -1013,13 +1013,13 @@ config.libs = [ "snd", [ Object(NonMatching, "nw4r/snd/snd_AnimSound.cpp"), - Object(NonMatching, "nw4r/snd/snd_AxManager.cpp"), + Object(Matching, "nw4r/snd/snd_AxManager.cpp"), Object(NonMatching, "nw4r/snd/snd_AxVoice.cpp"), Object(NonMatching, "nw4r/snd/snd_AxVoiceManager.cpp"), Object(NonMatching, "nw4r/snd/snd_AxfxImpl.cpp"), Object(NonMatching, "nw4r/snd/snd_Bank.cpp"), Object(NonMatching, "nw4r/snd/snd_BankFile.cpp"), - Object(NonMatching, "nw4r/snd/snd_BasicPlayer.cpp"), + Object(Matching, "nw4r/snd/snd_BasicPlayer.cpp"), Object(NonMatching, "nw4r/snd/snd_BasicSound.cpp"), Object(NonMatching, "nw4r/snd/snd_BiquadFilterPreset.cpp"), Object(NonMatching, "nw4r/snd/snd_Channel.cpp"), diff --git a/include/nw4r/snd/snd_AxManager.h b/include/nw4r/snd/snd_AxManager.h index e68069a0..01df41f9 100644 --- a/include/nw4r/snd/snd_AxManager.h +++ b/include/nw4r/snd/snd_AxManager.h @@ -117,11 +117,11 @@ namespace nw4r { namespace snd { namespace detail // static members private: - static u8 const AUX_CALLBACK_WAIT_FRAME; + static u8 const AUX_CALLBACK_WAIT_FRAME = 6; static u16 const AUX_RETURN_VOLUME_MAX = AX_MAX_VOLUME; - static int const FX_SAMPLE_RATE; - static SampleFormat const FX_SAMPLE_FORMAT; - static int const FX_BUFFER_SIZE; + static int const FX_SAMPLE_RATE = 32000; + static SampleFormat const FX_SAMPLE_FORMAT = SAMPLE_FORMAT_PCM_S32; + static int const FX_BUFFER_SIZE = 0x180; static int const ZERO_BUFFER_SIZE = 256; static int const SAMPLES_PAR_AUDIO_FRAME; static int const AUDIO_FRAME_INTERVAL; @@ -147,7 +147,7 @@ namespace nw4r { namespace snd { namespace detail MoveValue mMainOutVolume; // size 0x10, offset 0x2c MoveValue mVolumeForReset; // size 0x10, offset 0x3c AIDMACallback mOldAidCallback; // size 0x04, offset 0x4c - s32 mResetReadyCounter; // size 0x04, offset 0x50 + volatile s32 mResetReadyCounter; // size 0x04, offset 0x50 MoveValue mAuxFadeVolume[AUX_BUS_NUM]; // size 0x30, offset 0x54 MoveValue mAuxUserVolume[AUX_BUS_NUM]; // size 0x30, offset 0x84 FxBase::LinkList mFxList[AUX_BUS_NUM]; // size 0x24, offset 0xb4 @@ -156,7 +156,8 @@ namespace nw4r { namespace snd { namespace detail u8 mAuxCallbackWaitCounter[AUX_BUS_NUM]; // size 0x03, offset 0xf0 /* 1 byte padding */ u32 mEffectProcessTick[AUX_BUS_NUM]; // size 0x0c, offset 0xf4 - }; // size 0x100 + u32 field_0x100; + }; // size 0x104 }}} // namespace nw4r::snd::detail #endif // NW4R_SND_AX_MANAGER_H diff --git a/include/nw4r/snd/snd_BasicPlayer.h b/include/nw4r/snd/snd_BasicPlayer.h index ccd5d31e..a25f95fb 100644 --- a/include/nw4r/snd/snd_BasicPlayer.h +++ b/include/nw4r/snd/snd_BasicPlayer.h @@ -44,7 +44,8 @@ namespace nw4r { namespace snd { namespace detail PanMode panMode; // size 0x04, offset 0x28 PanCurve panCurve; // size 0x04, offset 0x2c f32 fxSend[AUX_BUS_NUM]; // size 0x0c, offset 0x30 - VoiceOutParam voiceOutParam[4]; // size 0x60, offset 0x3c + f32 remoteOutVolume[4]; // size 0x04, offset 0x3c + VoiceOutParam voiceOutParam[4]; // size 0x60, offset 0x5c }; // size 0x9c }}} // namespace nw4r::snd::detail @@ -75,6 +76,8 @@ namespace nw4r { namespace snd { namespace detail // methods void InitParam(); + void SetRemoteOutVolume(int remote, f32 volume); + f32 GetRemoteOutVolume(int remote) const; f32 GetVolume() const { return mPlayerParamSet.volume; } f32 GetPitch() const { return mPlayerParamSet.pitch; } diff --git a/src/nw4r/snd/snd_AxManager.cpp b/src/nw4r/snd/snd_AxManager.cpp index 1cb2c4b1..971f5e4b 100644 --- a/src/nw4r/snd/snd_AxManager.cpp +++ b/src/nw4r/snd/snd_AxManager.cpp @@ -68,7 +68,8 @@ AxManager::AxManager() : mInitialized (false), mUpdateVoicePrioFlag (true), mOldAidCallback (nullptr), - mResetReadyCounter (-1) + mResetReadyCounter (-1), + field_0x100(5) { mMainOutVolume.InitValue(1.0f); mMasterVolume.InitValue(1.0f); @@ -307,7 +308,10 @@ OutputMode AxManager::GetOutputMode() } void AxManager::SetMasterVolume(f32 volume, int frame) { - mMasterVolume.SetTarget(ut::Clamp(volume, 0.0f, 1.0f), (frame + 2) / 3); + if (volume < 0.0f) { + volume = 0.0f; + } + mMasterVolume.SetTarget(volume, (frame + 2) / 3); if (frame == 0) { VoiceManager::GetInstance().UpdateAllVoicesSync(Voice::SYNC_AX_VE); @@ -395,6 +399,9 @@ bool AxManager::AppendEffect(AuxBus bus, FxBase* pFx) { void AxManager::ClearEffect(AuxBus bus, int frame) { if (frame == 0) { ShutdownEffect(bus); + if (!mAuxFadeVolume[bus].IsFinished()) { + mAuxFadeVolume[bus].SetTarget(0.0f, 0); + } return; } @@ -447,6 +454,8 @@ void AxManager::AuxCallbackFunc(void* pChans, void* pContext) { void** ppChans = static_cast(pChans); AuxBus bus = static_cast(reinterpret_cast(pContext)); + int tick = OSGetTick(); + if (GetInstance().GetOutputMode() == OUTPUT_MODE_DPL2) { num = AX_DPL2_MAX; @@ -468,10 +477,12 @@ void AxManager::AuxCallbackFunc(void* pChans, void* pContext) { for (int i = 0; i < num; i++) { std::memset(buffer[i], 0, FX_BUFFER_SIZE); } + GetInstance().mEffectProcessTick[bus] = OSGetTick() - tick; } else if (GetInstance().GetEffectList(bus).IsEmpty()) { for (int i = 0; i < num; i++) { std::memset(buffer[i], 0, FX_BUFFER_SIZE); } + GetInstance().mEffectProcessTick[bus] = OSGetTick() - tick; } else { for (FxBase::LinkList::Iterator it = GetInstance().GetEffectList(bus).GetBeginIter(); @@ -480,6 +491,7 @@ void AxManager::AuxCallbackFunc(void* pChans, void* pContext) { it->UpdateBuffer(num, buffer, FX_BUFFER_SIZE, FX_SAMPLE_FORMAT, FX_SAMPLE_RATE, GetInstance().GetOutputMode()); } + GetInstance().mEffectProcessTick[bus] = OSGetTick() - tick; } } diff --git a/src/nw4r/snd/snd_BasicPlayer.cpp b/src/nw4r/snd/snd_BasicPlayer.cpp index e5695e31..4045f4b8 100644 --- a/src/nw4r/snd/snd_BasicPlayer.cpp +++ b/src/nw4r/snd/snd_BasicPlayer.cpp @@ -41,6 +41,9 @@ void PlayerParamSet::Init() for (int i = 0; i < AUX_BUS_NUM; i++) fxSend[i] = 0.0f; + for (int i = 0; i < 4; i++) + remoteOutVolume[i] = 1.0f; + for (int i = 0; i < (int)ARRAY_LENGTH(voiceOutParam); i++) { VoiceOutParam *param = &voiceOutParam[i]; @@ -99,4 +102,14 @@ void BasicPlayer::SetRemoteFilter(int filter) mPlayerParamSet.remoteFilter = filter; } +void BasicPlayer::SetRemoteOutVolume(int remote, f32 volume) +{ + mPlayerParamSet.remoteOutVolume[remote] = volume; +} + +f32 BasicPlayer::GetRemoteOutVolume(int remote) const +{ + return mPlayerParamSet.remoteOutVolume[remote]; +} + }}} // namespace nw4r::snd::detail