Nw4r splits (#28)

* snd / math / g3d
This commit is contained in:
Elijah Thomas
2024-09-15 14:55:25 -04:00
committed by GitHub
parent 2f7ceff5b1
commit 732a119127
167 changed files with 6174 additions and 2706 deletions
+389
View File
@@ -556,6 +556,395 @@ nw4r/db/db_assert.cpp:
.text start:0x804373C0 end:0x804373D0
.sbss start:0x80576610 end:0x80576618
nw4r/math/math_arithmetic.cpp:
.text start:0x804373D0 end:0x804375AC
nw4r/math/math_triangular.cpp:
.text start:0x804375B0 end:0x804378D0
nw4r/math/math_types.cpp:
.text start:0x804378D0 end:0x80437D34
nw4r/math/math_geometry.cpp:
.text start:0x80437D40 end:0x80438F4C
nw4r/g3d/res/g3d_rescommon.cpp:
.text start:0x80438F50 end:0x804390F4
nw4r/g3d/res/g3d_resdict.cpp:
.text start:0x80439100 end:0x80439420
nw4r/g3d/res/g3d_resfile.cpp:
.text start:0x80439420 end:0x80439FC4
nw4r/g3d/res/g3d_resmdl.cpp:
.text start:0x80439FD0 end:0x8043B244
nw4r/g3d/res/g3d_resshp.cpp:
.text start:0x8043B250 end:0x8043BD48
nw4r/g3d/res/g3d_restev.cpp:
.text start:0x8043BD50 end:0x8043C2B8
nw4r/g3d/res/g3d_resmat.cpp:
.text start:0x8043C2C0 end:0x8043E17C
nw4r/g3d/res/g3d_resvtx.cpp:
.text start:0x8043E180 end:0x8043E5B8
nw4r/g3d/res/g3d_restex.cpp:
.text start:0x8043E5C0 end:0x8043E74C
nw4r/g3d/res/g3d_resnode.cpp:
.text start:0x8043E750 end:0x8043EA58
nw4r/g3d/res/g3d_resanm.cpp:
.text start:0x8043EA60 end:0x8043ECB8
nw4r/g3d/res/g3d_resanmvis.cpp:
.text start:0x8043ECC0 end:0x8043EDE0
nw4r/g3d/res/g3d_resanmclr.cpp:
.text start:0x8043EDE0 end:0x8043EF4C
nw4r/g3d/res/g3d_resanmtexpat.cpp:
.text start:0x8043EF50 end:0x8043F320
nw4r/g3d/res/g3d_resanmtexsrt.cpp:
.text start:0x8043F320 end:0x8043F734
nw4r/g3d/res/g3d_resanmchr.cpp:
.text start:0x8043F740 end:0x804419EC
nw4r/g3d/res/g3d_reslightset.cpp:
.text start:0x804419F0 end:0x80441B5C
nw4r/g3d/res/g3d_resanmamblight.cpp:
.text start:0x80441B60 end:0x80441C30
nw4r/g3d/res/g3d_resanmlight.cpp:
.text start:0x80441C30 end:0x80442018
nw4r/g3d/res/g3d_resanmcamera.cpp:
.text start:0x80442020 end:0x80442330
nw4r/g3d/res/g3d_resanmscn.cpp:
.text start:0x80442330 end:0x8044297C
nw4r/g3d/res/g3d_resanmshp.cpp:
.text start:0x80442980 end:0x80442AE8
nw4r/g3d/g3d_transform.cpp:
.text start:0x80442AF0 end:0x80442DF4
nw4r/g3d/g3d_anmvis.cpp:
.text start:0x80442E00 end:0x8044358C
nw4r/g3d/g3d_anmclr.cpp:
.text start:0x80443590 end:0x80444D5C
nw4r/g3d/g3d_anmtexpat.cpp:
.text start:0x80444D60 end:0x8044635C
nw4r/g3d/g3d_anmtexsrt.cpp:
.text start:0x80446360 end:0x804479AC
nw4r/g3d/g3d_anmchr.cpp:
.text start:0x804479B0 end:0x804499CC
nw4r/g3d/g3d_anmshp.cpp:
.text start:0x804499D0 end:0x8044A3BC
nw4r/g3d/g3d_anmscn.cpp:
.text start:0x8044A3C0 end:0x8044A6E8
nw4r/g3d/g3d_obj.cpp:
.text start:0x8044A6F0 end:0x8044A85C
nw4r/g3d/g3d_anmobj.cpp:
.text start:0x8044A860 end:0x8044A928
nw4r/g3d/platform/g3d_gpu.cpp:
.text start:0x8044A930 end:0x8044AE50
nw4r/g3d/platform/g3d_tmem.cpp:
.text start:0x8044AE50 end:0x8044B1B0
nw4r/g3d/platform/g3d_cpu.cpp:
.text start:0x8044B1B0 end:0x8044B35C
nw4r/g3d/g3d_state.cpp:
.text start:0x8044B360 end:0x8044EAB0
.ctors start:0x804DB954 end:0x804DB958
nw4r/g3d/g3d_draw1mat1shp.cpp:
.text start:0x8044EAB0 end:0x8044F7F4
nw4r/g3d/g3d_calcview.cpp:
.text start:0x8044F800 end:0x80451A9C
nw4r/g3d/g3d_dcc.cpp:
.text start:0x80451AA0 end:0x80451B84
nw4r/g3d/g3d_workmem.cpp:
.text start:0x80451B90 end:0x80451BDC
nw4r/g3d/g3d_calcworld.cpp:
.text start:0x80451BE0 end:0x8045274C
nw4r/g3d/g3d_draw.cpp:
.text start:0x80452750 end:0x804545F0
nw4r/g3d/g3d_camera.cpp:
.text start:0x804545F0 end:0x804556AC
nw4r/g3d/dcc/g3d_basic.cpp:
.text start:0x804556B0 end:0x80455978
nw4r/g3d/dcc/g3d_maya.cpp:
.text start:0x80455980 end:0x80456684
nw4r/g3d/dcc/g3d_xsi.cpp:
.text start:0x80456690 end:0x804572A4
nw4r/g3d/dcc/g3d_3dsmax.cpp:
.text start:0x804572B0 end:0x80457DCC
nw4r/g3d/g3d_scnobj.cpp:
.text start:0x80457DD0 end:0x8045980C
nw4r/g3d/g3d_scnroot.cpp:
.text start:0x80459810 end:0x8045B1BC
nw4r/g3d/g3d_scnmdlsmpl.cpp:
.text start:0x8045B1C0 end:0x8045D25C
nw4r/g3d/g3d_scnmdl.cpp:
.text start:0x8045D260 end:0x8045FDAC
nw4r/g3d/g3d_calcmaterial.cpp:
.text start:0x8045FDB0 end:0x8045FFE4
nw4r/g3d/g3d_init.cpp:
.text start:0x8045FFF0 end:0x804600E8
nw4r/g3d/g3d_scnproc.cpp:
.text start:0x804600F0 end:0x804603F0
nw4r/g3d/g3d_fog.cpp:
.text start:0x804603F0 end:0x80460560
nw4r/g3d/g3d_light.cpp:
.text start:0x80460560 end:0x80460F68
nw4r/g3d/g3d_calcvtx.cpp:
.text start:0x80460F70 end:0x804616F8
nw4r/snd/snd_AnimSound.cpp:
.text start:0x80461700 end:0x804630D4
nw4r/snd/snd_AxManager.cpp:
.text start:0x804630E0 end:0x80464880
.ctors start:0x804DB958 end:0x804DB95C
nw4r/snd/snd_AxVoice.cpp:
.text start:0x80464880 end:0x80467634
nw4r/snd/snd_AxVoiceManager.cpp:
.text start:0x80467640 end:0x80467DC8
nw4r/snd/snd_AxfxImpl.cpp:
.text start:0x80467DD0 end:0x80467FC8
nw4r/snd/snd_Bank.cpp:
.text start:0x80467FD0 end:0x80468248
nw4r/snd/snd_BankFile.cpp:
.text start:0x80468250 end:0x8046890C
nw4r/snd/snd_BasicPlayer.cpp:
.text start:0x80468910 end:0x80468B50
nw4r/snd/snd_BasicSound.cpp:
.text start:0x80468B50 end:0x8046A36C
.ctors start:0x804DB95C end:0x804DB960
nw4r/snd/snd_BiquadFilterPreset.cpp:
.text start:0x8046A370 end:0x8046A7B0
nw4r/snd/snd_Channel.cpp:
.text start:0x8046A7B0 end:0x8046B7C8
nw4r/snd/snd_DisposeCallbackManager.cpp:
.text start:0x8046B7D0 end:0x8046BB5C
nw4r/snd/snd_DvdSoundArchive.cpp:
.text start:0x8046BB60 end:0x8046C1C8
nw4r/snd/snd_EnvGenerator.cpp:
.text start:0x8046C1D0 end:0x8046C5C0
nw4r/snd/snd_ExternalSoundPlayer.cpp:
.text start:0x8046C5C0 end:0x8046CB18
nw4r/snd/snd_FrameHeap.cpp:
.text start:0x8046CB20 end:0x8046D2E0
nw4r/snd/snd_FxReverbStdDpl2.cpp:
.text start:0x8046D2E0 end:0x8046DA10
nw4r/snd/snd_InstancePool.cpp:
.text start:0x8046DA10 end:0x8046DCF8
nw4r/snd/snd_Lfo.cpp:
.text start:0x8046DD00 end:0x8046DF08
nw4r/snd/snd_MemorySoundArchive.cpp:
.text start:0x8046DF10 end:0x8046E3B0
nw4r/snd/snd_MidiSeqPlayer.cpp:
.text start:0x8046E3B0 end:0x8046E458
nw4r/snd/snd_MmlParser.cpp:
.text start:0x8046E460 end:0x8046F63C
nw4r/snd/snd_MmlSeqTrack.cpp:
.text start:0x8046F640 end:0x8046F6F8
nw4r/snd/snd_MmlSeqTrackAllocator.cpp:
.text start:0x8046F700 end:0x8046F850
nw4r/snd/snd_NandSoundArchive.cpp:
.text start:0x8046F850 end:0x804700B8
nw4r/snd/snd_PlayerHeap.cpp:
.text start:0x804700C0 end:0x804702DC
nw4r/snd/snd_RemoteSpeaker.cpp:
.text start:0x804702E0 end:0x80470C90
nw4r/snd/snd_RemoteSpeakerManager.cpp:
.text start:0x80470C90 end:0x80470ED8
nw4r/snd/snd_SeqFile.cpp:
.text start:0x80470EE0 end:0x80471018
nw4r/snd/snd_SeqPlayer.cpp:
.text start:0x80471020 end:0x804727F8
nw4r/snd/snd_SeqSound.cpp:
.text start:0x80472800 end:0x8047316C
.ctors start:0x804DB960 end:0x804DB964
nw4r/snd/snd_SeqSoundHandle.cpp:
.text start:0x80473170 end:0x804732A8
nw4r/snd/snd_SeqTrack.cpp:
.text start:0x804732B0 end:0x80474818
nw4r/snd/snd_Sound3DActor.cpp:
.text start:0x80474820 end:0x80474BD8
nw4r/snd/snd_Sound3DCalculator.cpp:
.text start:0x80474BE0 end:0x804756B0
nw4r/snd/snd_Sound3DEngine.cpp:
.text start:0x804756E0 end:0x804759F8
nw4r/snd/snd_Sound3DListener.cpp:
.text start:0x80475A00 end:0x80475C88
nw4r/snd/snd_Sound3DManager.cpp:
.text start:0x80475C90 end:0x80475F78
.ctors start:0x804DB964 end:0x804DB968
nw4r/snd/snd_SoundActor.cpp:
.text start:0x80475F80 end:0x80476264
nw4r/snd/snd_SoundArchive.cpp:
.text start:0x80476270 end:0x8047697C
nw4r/snd/snd_SoundArchiveFile.cpp:
.text start:0x80476980 end:0x80477C90
nw4r/snd/snd_SoundArchiveLoader.cpp:
.text start:0x80477C90 end:0x8047855C
nw4r/snd/snd_SoundArchivePlayer.cpp:
.text start:0x80478560 end:0x8047B018
nw4r/snd/snd_SoundHandle.cpp:
.text start:0x8047B020 end:0x8047B110
nw4r/snd/snd_SoundHeap.cpp:
.text start:0x8047B110 end:0x8047B418
nw4r/snd/snd_SoundPlayer.cpp:
.text start:0x8047B420 end:0x8047C050
nw4r/snd/snd_SoundStartable.cpp:
.text start:0x8047C050 end:0x8047C3AC
nw4r/snd/snd_SoundSystem.cpp:
.text start:0x8047C3B0 end:0x8047C708
.ctors start:0x804DB968 end:0x804DB96C
nw4r/snd/snd_SoundThread.cpp:
.text start:0x8047C710 end:0x8047CD10
nw4r/snd/snd_StrmChannel.cpp:
.text start:0x8047CD10 end:0x8047CF50
nw4r/snd/snd_StrmFile.cpp:
.text start:0x8047CF50 end:0x8047D8D4
nw4r/snd/snd_StrmPlayer.cpp:
.text start:0x8047D8E0 end:0x80480588
nw4r/snd/snd_StrmSound.cpp:
.text start:0x80480590 end:0x80480D8C
.ctors start:0x804DB96C end:0x804DB970
nw4r/snd/snd_StrmSoundHandle.cpp:
.text start:0x80480D90 end:0x80480EC8
nw4r/snd/snd_Task.cpp:
.text start:0x80480ED0 end:0x80480F10
nw4r/snd/snd_TaskManager.cpp:
.text start:0x80480F10 end:0x804815D0
nw4r/snd/snd_TaskThread.cpp:
.text start:0x804815D0 end:0x80481798
nw4r/snd/snd_Voice.cpp:
.text start:0x804817A0 end:0x80484034
nw4r/snd/snd_VoiceManager.cpp:
.text start:0x80484040 end:0x804846F4
nw4r/snd/snd_Util.cpp:
.text start:0x80484700 end:0x80484BD4
nw4r/snd/snd_WaveFile.cpp:
.text start:0x80484BE0 end:0x80484F54
nw4r/snd/snd_WaveSound.cpp:
.text start:0x80484F60 end:0x8048531C
.ctors start:0x804DB970 end:0x804DB974
nw4r/snd/snd_WaveSoundHandle.cpp:
.text start:0x80485320 end:0x80485458
nw4r/snd/snd_WsdFile.cpp:
.text start:0x80485460 end:0x80485824
nw4r/snd/snd_WsdPlayer.cpp:
.text start:0x80485830 end:0x804869D8
nw4r/snd/snd_adpcm.cpp:
.text start:0x804869E0 end:0x80486A6C
nw4r/lyt/lyt_init.cpp:
.text start:0x80486A70 end:0x80486AC4
.data start:0x8056E3E8 end:0x8056E430
+645 -646
View File
File diff suppressed because it is too large Load Diff
+156 -1
View File
@@ -188,7 +188,7 @@ cflags_base = [
"-i include",
"-i include/MSL_C",
f"-i build/{config.version}/include",
f"-DVERSION={version_num}",
f"-DGAME_VERSION={version_num}",
]
# Debug flags
@@ -460,6 +460,161 @@ config.libs = [
Object(Matching, "nw4r/ut/ut_TextWriterBase.cpp"),
],
),
nw4rLib(
"math",
[
Object(NonMatching, "nw4r/math/math_arithmetic.cpp"),
Object(NonMatching, "nw4r/math/math_triangular.cpp"),
Object(NonMatching, "nw4r/math/math_types.cpp"),
Object(NonMatching, "nw4r/math/math_geometry.cpp"),
]
),
nw4rLib(
"g3d",
[
Object(NonMatching, "nw4r/g3d/res/g3d_rescommon.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resdict.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resfile.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resmdl.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resshp.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_restev.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resmat.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resvtx.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_restex.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resnode.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanm.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanmvis.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanmclr.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanmtexpat.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanmtexsrt.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanmchr.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_reslightset.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanmamblight.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanmlight.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanmfog.cpp: .tex"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanmcamera.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanmscn.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanmshp.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_transform.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_anmvis.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_anmclr.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_anmtexpat.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_anmtexsrt.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_anmchr.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_anmshp.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_anmscn.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_obj.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_anmobj.cpp"),
Object(NonMatching, "nw4r/g3d/platform/g3d_gpu.cpp"),
Object(NonMatching, "nw4r/g3d/platform/g3d_tmem.cpp"),
Object(NonMatching, "nw4r/g3d/platform/g3d_cpu.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_state.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_draw1mat1shp.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_calcview.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_dcc.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_workmem.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_calcworld.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_draw.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_camera.cpp"),
Object(NonMatching, "nw4r/g3d/dcc/g3d_basic.cpp"),
Object(NonMatching, "nw4r/g3d/dcc/g3d_maya.cpp"),
Object(NonMatching, "nw4r/g3d/dcc/g3d_xsi.cpp"),
Object(NonMatching, "nw4r/g3d/dcc/g3d_3dsmax.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_scnobj.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_scnroot.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_scnmdlsmpl.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_scnmdl.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_scnchoice.cpp: .tex"),
Object(NonMatching, "nw4r/g3d/g3d_scngroupex.cpp: .tex"),
Object(NonMatching, "nw4r/g3d/g3d_scnmdl1mat1shp.cpp: .tex"),
Object(NonMatching, "nw4r/g3d/g3d_scnmdlexpand.cpp: .tex"),
Object(NonMatching, "nw4r/g3d/g3d_calcmaterial.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_init.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_scnproc.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_fog.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_light.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_calcvtx.cpp"),
]
),
nw4rLib(
"snd",
[
Object(NonMatching, "nw4r/snd/snd_AnimSound.cpp"),
Object(NonMatching, "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(NonMatching, "nw4r/snd/snd_BasicSound.cpp"),
Object(NonMatching, "nw4r/snd/snd_BiquadFilterPreset.cpp"),
Object(NonMatching, "nw4r/snd/snd_Channel.cpp"),
Object(NonMatching, "nw4r/snd/snd_DisposeCallbackManager.cpp"),
Object(NonMatching, "nw4r/snd/snd_debug.cpp"),
Object(NonMatching, "nw4r/snd/snd_DvdSoundArchive.cpp"),
Object(NonMatching, "nw4r/snd/snd_EnvGenerator.cpp"),
Object(NonMatching, "nw4r/snd/snd_ExternalSoundPlayer.cpp"),
Object(NonMatching, "nw4r/snd/snd_FrameHeap.cpp"),
Object(NonMatching, "nw4r/snd/snd_FxBase.cpp"),
Object(NonMatching, "nw4r/snd/snd_FxChorus.cpp"),
Object(NonMatching, "nw4r/snd/snd_FxDelay.cpp"),
Object(NonMatching, "nw4r/snd/snd_FxReverbHi.cpp"),
Object(NonMatching, "nw4r/snd/snd_FxReverbHiDpl2.cpp"),
Object(NonMatching, "nw4r/snd/snd_FxReverbStd.cpp"),
Object(NonMatching, "nw4r/snd/snd_FxReverbStdDpl2.cpp"),
Object(NonMatching, "nw4r/snd/snd_InstancePool.cpp"),
Object(NonMatching, "nw4r/snd/snd_Lfo.cpp"),
Object(NonMatching, "nw4r/snd/snd_MemorySoundArchive.cpp"),
Object(NonMatching, "nw4r/snd/snd_MidiSeqPlayer.cpp"),
Object(NonMatching, "nw4r/snd/snd_MmlParser.cpp"),
Object(NonMatching, "nw4r/snd/snd_MmlSeqTrack.cpp"),
Object(NonMatching, "nw4r/snd/snd_MmlSeqTrackAllocator.cpp"),
Object(NonMatching, "nw4r/snd/snd_NandSoundArchive.cpp"),
Object(NonMatching, "nw4r/snd/snd_PlayerHeap.cpp"),
Object(NonMatching, "nw4r/snd/snd_RemoteSpeaker.cpp"),
Object(NonMatching, "nw4r/snd/snd_RemoteSpeakerManager.cpp"),
Object(NonMatching, "nw4r/snd/snd_SeqFile.cpp"),
Object(NonMatching, "nw4r/snd/snd_SeqPlayer.cpp"),
Object(NonMatching, "nw4r/snd/snd_SeqSound.cpp"),
Object(NonMatching, "nw4r/snd/snd_SeqSoundHandle.cpp"),
Object(NonMatching, "nw4r/snd/snd_SeqTrack.cpp"),
Object(NonMatching, "nw4r/snd/snd_Sound3DActor.cpp"),
Object(NonMatching, "nw4r/snd/snd_Sound3DCalculator.cpp"),
Object(NonMatching, "nw4r/snd/snd_Sound3DEngine.cpp"),
Object(NonMatching, "nw4r/snd/snd_Sound3DListener.cpp"),
Object(NonMatching, "nw4r/snd/snd_Sound3DManager.cpp"),
Object(NonMatching, "nw4r/snd/snd_SoundActor.cpp"),
Object(NonMatching, "nw4r/snd/snd_SoundArchive.cpp"),
Object(NonMatching, "nw4r/snd/snd_SoundArchiveFile.cpp"),
Object(NonMatching, "nw4r/snd/snd_SoundArchiveLoader.cpp"),
Object(NonMatching, "nw4r/snd/snd_SoundArchivePlayer.cpp"),
Object(NonMatching, "nw4r/snd/snd_SoundHandle.cpp"),
Object(NonMatching, "nw4r/snd/snd_SoundHeap.cpp"),
Object(NonMatching, "nw4r/snd/snd_SoundPlayer.cpp"),
Object(NonMatching, "nw4r/snd/snd_SoundStartable.cpp"),
Object(NonMatching, "nw4r/snd/snd_SoundSystem.cpp"),
Object(NonMatching, "nw4r/snd/snd_SoundThread.cpp"),
Object(NonMatching, "nw4r/snd/snd_StrmChannel.cpp"),
Object(NonMatching, "nw4r/snd/snd_StrmFile.cpp"),
Object(NonMatching, "nw4r/snd/snd_StrmPlayer.cpp"),
Object(NonMatching, "nw4r/snd/snd_StrmSound.cpp"),
Object(NonMatching, "nw4r/snd/snd_StrmSoundHandle.cpp"),
Object(NonMatching, "nw4r/snd/snd_Task.cpp"),
Object(NonMatching, "nw4r/snd/snd_TaskManager.cpp"),
Object(NonMatching, "nw4r/snd/snd_TaskThread.cpp"),
Object(NonMatching, "nw4r/snd/snd_Voice.cpp"),
Object(NonMatching, "nw4r/snd/snd_VoiceManager.cpp"),
Object(NonMatching, "nw4r/snd/snd_Util.cpp"),
Object(NonMatching, "nw4r/snd/snd_WaveArchive.cpp"),
Object(NonMatching, "nw4r/snd/snd_WaveFile.cpp"),
Object(NonMatching, "nw4r/snd/snd_WaveSound.cpp"),
Object(NonMatching, "nw4r/snd/snd_WaveSoundHandle.cpp"),
Object(NonMatching, "nw4r/snd/snd_WsdFile.cpp"),
Object(NonMatching, "nw4r/snd/snd_WsdPlayer.cpp"),
Object(NonMatching, "nw4r/snd/snd_adpcm.cpp"),
]
),
nw4rLib(
"lyt",
[
+4
View File
@@ -0,0 +1,4 @@
#ifndef MSL_CPP_CLIMITS_H
#define MSL_CPP_CLIMITS_H
#include <limits.h>
#endif
+3
View File
@@ -21,6 +21,9 @@
#define DECL_WEAK __declspec(weak)
#define DONT_INLINE __attribute__((never_inline))
// TODO - Fix MSL (stddef.h)
#define offsetof(ST, M) ((size_t) & (((ST*)0)->M))
// Codewarrior tricks for matching decomp
// (Functions are given prototypes for -requireprotos)
#ifdef __MWERKS__
+2 -2
View File
@@ -5,8 +5,8 @@
extern "C" {
void *memset(void *dest, s32 value, u32 count);
void *memcpy(void *dest, const void *src, u32 count);
// void *memset(void *dest, s32 value, u32 count);
// void *memcpy(void *dest, const void *src, u32 count);
void *checkedMemcpy(void *dest, u16 destLen, const void *src, u16 count);
}
+1 -1
View File
@@ -86,7 +86,7 @@ public:
return TypeObj(TYPE_NAME);
}
static AnmObjShpRes *Construct(MEMAllocator *, u32 *, ResAnmShp, ResMdl, int);
static AnmObjShpRes *Construct(MEMAllocator *, u32 *, ResAnmShp, ResMdl, bool);
private:
ResAnmShp mResAnmShp; // at 0x2C
+57
View File
@@ -5,17 +5,74 @@
#include <nw4r/snd/snd_AxVoice.h>
#include <nw4r/snd/snd_AxVoiceManager.h>
#include <nw4r/snd/snd_AxfxImpl.h>
#include <nw4r/snd/snd_Bank.h>
#include <nw4r/snd/snd_BankFile.h>
#include <nw4r/snd/snd_BasicPlayer.h>
#include <nw4r/snd/snd_BasicSound.h>
#include <nw4r/snd/snd_Channel.h>
#include <nw4r/snd/snd_ChannelManager.h>
#include <nw4r/snd/snd_Common.h>
#include <nw4r/snd/snd_DisposeCallback.h>
#include <nw4r/snd/snd_DisposeCallbackManager.h>
#include <nw4r/snd/snd_DvdSoundArchive.h>
#include <nw4r/snd/snd_EnvGenerator.h>
#include <nw4r/snd/snd_ExternalSoundPlayer.h>
#include <nw4r/snd/snd_FrameHeap.h>
#include <nw4r/snd/snd_FxBase.h>
#include <nw4r/snd/snd_FxChorus.h>
#include <nw4r/snd/snd_FxDelay.h>
#include <nw4r/snd/snd_FxReverbHi.h>
#include <nw4r/snd/snd_FxReverbHiDpl2.h>
#include <nw4r/snd/snd_InstancePool.h>
#include <nw4r/snd/snd_Lfo.h>
#include <nw4r/snd/snd_MemorySoundArchive.h>
#include <nw4r/snd/snd_MmlParser.h>
#include <nw4r/snd/snd_MmlSeqTrack.h>
#include <nw4r/snd/snd_MmlSeqTrackAllocator.h>
#include <nw4r/snd/snd_MoveValue.h>
#include <nw4r/snd/snd_NandSoundArchive.h>
#include <nw4r/snd/snd_NoteOnCallback.h>
#include <nw4r/snd/snd_PlayerHeap.h>
#include <nw4r/snd/snd_RemoteSpeaker.h>
#include <nw4r/snd/snd_RemoteSpeakerManager.h>
#include <nw4r/snd/snd_SeqFile.h>
#include <nw4r/snd/snd_SeqPlayer.h>
#include <nw4r/snd/snd_SeqSound.h>
#include <nw4r/snd/snd_SeqSoundHandle.h>
#include <nw4r/snd/snd_SeqTrack.h>
#include <nw4r/snd/snd_SeqTrackAllocator.h>
#include <nw4r/snd/snd_Sound3DActor.h>
#include <nw4r/snd/snd_Sound3DListener.h>
#include <nw4r/snd/snd_Sound3DManager.h>
#include <nw4r/snd/snd_SoundActor.h>
#include <nw4r/snd/snd_SoundArchive.h>
#include <nw4r/snd/snd_SoundArchiveFile.h>
#include <nw4r/snd/snd_SoundArchiveLoader.h>
#include <nw4r/snd/snd_SoundArchivePlayer.h>
#include <nw4r/snd/snd_SoundHandle.h>
#include <nw4r/snd/snd_SoundHeap.h>
#include <nw4r/snd/snd_SoundInstanceManager.h>
#include <nw4r/snd/snd_SoundMemoryAllocatable.h>
#include <nw4r/snd/snd_SoundPlayer.h>
#include <nw4r/snd/snd_SoundStartable.h>
#include <nw4r/snd/snd_SoundSystem.h>
#include <nw4r/snd/snd_SoundThread.h>
#include <nw4r/snd/snd_StrmChannel.h>
#include <nw4r/snd/snd_StrmFile.h>
#include <nw4r/snd/snd_StrmPlayer.h>
#include <nw4r/snd/snd_StrmSound.h>
#include <nw4r/snd/snd_StrmSoundHandle.h>
#include <nw4r/snd/snd_Task.h>
#include <nw4r/snd/snd_TaskManager.h>
#include <nw4r/snd/snd_TaskThread.h>
#include <nw4r/snd/snd_Util.h>
#include <nw4r/snd/snd_Voice.h>
#include <nw4r/snd/snd_VoiceManager.h>
#include <nw4r/snd/snd_WaveFile.h>
#include <nw4r/snd/snd_WaveSound.h>
#include <nw4r/snd/snd_WaveSoundHandle.h>
#include <nw4r/snd/snd_WsdFile.h>
#include <nw4r/snd/snd_WsdPlayer.h>
#include <nw4r/snd/snd_adpcm.h>
#endif
+41 -27
View File
@@ -1,10 +1,13 @@
#ifndef NW4R_SND_AX_MANAGER_H
#define NW4R_SND_AX_MANAGER_H
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_Common.h>
#include <nw4r/snd/snd_FxBase.h>
#include <nw4r/snd/snd_MoveValue.h>
#include <nw4r/types_nw4r.h>
#include <nw4r/ut.h>
#include <rvl/AI.h>
#include <rvl/AX.h>
@@ -22,32 +25,30 @@ public:
NW4R_UT_LIST_TYPEDEF_DECL(CallbackListNode);
public:
static AxManager &GetInstance();
static AxManager& GetInstance();
AxManager();
~AxManager() {}
void Init();
void Shutdown();
void Update();
void PrepareReset();
bool CheckInit() {
return mInitialized;
}
bool IsDiskError() const {
return mDiskError;
}
s32 GetResetReadyTimer() const {
return mResetReadyTimer;
}
FxBaseList &GetEffectList(AuxBus bus) {
return mFxList[bus];
bool IsResetReady() const {
return mResetReadyCounter == 0;
}
void Init();
void Shutdown();
f32 GetOutputVolume() const;
void Update();
void *GetZeroBufferAddress();
void* GetZeroBufferAddress();
void RegisterCallback(CallbackListNode *node, AXOutCallback callback);
void UnregisterCallback(CallbackListNode *node);
void RegisterCallback(CallbackListNode* pNode, AXOutCallback pCallback);
void UnregisterCallback(CallbackListNode* pNode);
void SetOutputMode(OutputMode mode);
OutputMode GetOutputMode();
@@ -57,38 +58,51 @@ public:
}
void SetMasterVolume(f32 volume, int frame);
bool AppendEffect(AuxBus bus, FxBase *fx);
bool AppendEffect(AuxBus bus, FxBase* pFx);
void ClearEffect(AuxBus bus, int frame);
void ShutdownEffect(AuxBus bus);
void PrepareReset();
FxBaseList& GetEffectList(AuxBus bus) {
return mFxList[bus];
}
private:
static const u8 AUX_CALLBACK_WAIT_FRAME = 6;
static const int FX_SAMPLE_RATE = AX_SAMPLE_RATE;
static const SampleFormat FX_SAMPLE_FORMAT = SAMPLE_FORMAT_PCM_S32;
static const int FX_BUFFER_SIZE = AX_FRAME_SIZE;
static const int ZERO_BUFFER_SIZE = 256;
private:
AxManager();
static void AxCallbackFunc();
static void AuxCallbackFunc(void *chans, void *context);
static void AuxCallbackFunc(void* pChans, void* pContext);
static void AiDmaCallbackFunc();
private:
static u8 sZeroBuffer[0x100];
OutputMode mOutputMode; // at 0x0
void *mZeroBuffer; // at 0x4
void* mZeroBufferAddress; // at 0x4
CallbackListNodeList mCallbackList; // at 0x8
AXOutCallback mOldAxCallback; // at 0x14
AXOutCallback mNextAxRegisterCallback; // at 0x14
bool mInitialized; // at 0x18
bool mUpdateVoicePrio; // at 0x19
bool mUpdateVoicePrioFlag; // at 0x19
bool mDiskError; // at 0x1A
MoveValue<f32, int> mMasterVolume; // at 0x1C
MoveValue<f32, int> mMainOutVolume; // at 0x2C
MoveValue<f32, int> mVolumeForReset; // at 0x3C
AIDMACallback mOldAiCallback; // at 0x4C
s32 mResetReadyTimer; // at 0x50
AIDMACallback mOldAidCallback; // at 0x4C
volatile s32 mResetReadyCounter; // at 0x50
MoveValue<f32, int> mAuxFadeVolume[AUX_BUS_NUM]; // at 0x54
MoveValue<f32, int> mAuxUserVolume[AUX_BUS_NUM]; // at 0x84
FxBaseList mFxList[AUX_BUS_NUM]; // at 0xB4
AXAuxCallback mAuxCallback[AUX_BUS_NUM]; // at 0xD8
void *mAuxCallbackContext[AUX_BUS_NUM]; // at 0xE4
u8 mAuxCallbackWait[AUX_BUS_NUM]; // at 0xF0
void* mAuxCallbackContext[AUX_BUS_NUM]; // at 0xE4
u8 mAuxCallbackWaitCounter[AUX_BUS_NUM]; // at 0xF0
static u8 sZeroBuffer[ZERO_BUFFER_SIZE];
};
} // namespace detail
+77 -56
View File
@@ -1,22 +1,22 @@
#ifndef NW4R_SND_AX_VOICE_H
#define NW4R_SND_AX_VOICE_H
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_Common.h>
#include <nw4r/ut.h>
#include <rvl/AX.h>
namespace nw4r {
namespace snd {
namespace detail {
inline int CalcAxvpbDelta(u16 init, u16 target) {
return (target - init) / AX_SAMPLES_PER_FRAME;
}
class AxVoiceParamBlock {
public:
AxVoiceParamBlock();
operator AXVPB *() {
operator AXVPB*() {
return mVpb;
}
@@ -41,7 +41,8 @@ public:
return 0;
}
return (mVpb->pb.addr.currentAddressHi << 16) + mVpb->pb.addr.currentAddressLo;
return (mVpb->pb.addr.currentAddressHi << 16) +
mVpb->pb.addr.currentAddressLo;
}
u32 GetLoopAddress() const {
@@ -49,7 +50,8 @@ public:
return 0;
}
return (mVpb->pb.addr.loopAddressHi << 16) + mVpb->pb.addr.loopAddressLo;
return (mVpb->pb.addr.loopAddressHi << 16) +
mVpb->pb.addr.loopAddressLo;
}
u32 GetEndAddress() const {
@@ -60,16 +62,16 @@ public:
return (mVpb->pb.addr.endAddressHi << 16) + mVpb->pb.addr.endAddressLo;
}
void SetVoiceAddr(const AXPBADDR &addr) {
void SetVoiceAddr(const AXPBADDR& rAddr) {
if (IsAvailable()) {
// AXSetVoiceAddr doesn't actually modify the object
AXSetVoiceAddr(mVpb, const_cast<AXPBADDR *>(&addr));
AXSetVoiceAddr(mVpb, const_cast<AXPBADDR*>(&rAddr));
}
}
void SetVoicePriority(u32 prio) {
void SetVoicePriority(u32 priority) {
if (IsAvailable()) {
AXSetVoicePriority(mVpb, prio);
AXSetVoicePriority(mVpb, priority);
}
}
@@ -88,43 +90,50 @@ public:
void Sync();
bool IsRmtIirEnable() const;
void Set(AXVPB *vpb);
void Set(AXVPB* pVpb);
void Clear();
void SetVoiceType(u16 type);
void SetVoiceVe(u16 volume, u16 initVolume);
void SetVoiceMix(const AXPBMIX &mix, bool syncNow);
void SetVoiceMix(const AXPBMIX& rMix, bool syncNow);
void SetVoiceLoop(u16 loop);
void SetVoiceLoopAddr(u32 addr);
void SetVoiceEndAddr(u32 addr);
void SetVoiceAdpcm(const AXPBADPCM &adpcm);
void SetVoiceAdpcm(const AXPBADPCM& rAdpcm);
void SetVoiceSrcType(u32 type);
void SetVoiceSrc(const AXPBSRC &src);
void SetVoiceSrc(const AXPBSRC& rSrc);
void SetVoiceSrcRatio(f32 ratio);
void SetVoiceAdpcmLoop(const AXPBADPCMLOOP &loop);
void SetVoiceLpf(const AXPBLPF &lpf);
void SetVoiceAdpcmLoop(const AXPBADPCMLOOP& rLoop);
void SetVoiceLpf(const AXPBLPF& rLpf);
void SetVoiceLpfCoefs(u16 a0, u16 b0);
void SetVoiceRmtOn(u16 on);
void SetVoiceRmtMix(const AXPBRMTMIX &mix);
void SetVoiceRmtIIR(const AXPBRMTIIR &iir);
void SetVoiceRmtMix(const AXPBRMTMIX& rMix);
void SetVoiceRmtIIR(const AXPBRMTIIR& rIir);
void SetVoiceRmtIIRCoefs(u16 type, ...);
void UpdateDelta();
private:
AXVPB *mVpb; // at 0x0
u32 mSync; // at 0x4
volatile AXPBVE mVePrev; // at 0x8
bool mFirstVeUpdate; // at 0xC
u16 mVolume; // at 0xE
static const u16 DEFAULT_VOLUME = AX_MAX_VOLUME;
private:
AXVPB* mVpb; // at 0x0
u32 mSync; // at 0x4
volatile AXPBVE mPrevVeSetting; // at 0x8
bool mFirstVeUpdateFlag; // at 0xC
u16 mVolume; // at 0xE
};
class AxVoice {
friend class AxVoiceManager;
public:
enum AxVoiceCallbackStatus { CALLBACK_STATUS_CANCEL, CALLBACK_STATUS_DROP_DSP };
enum AxVoiceCallbackStatus {
CALLBACK_STATUS_CANCEL,
CALLBACK_STATUS_DROP_DSP
};
typedef void (*Callback)(AxVoice *voice, AxVoiceCallbackStatus status, void *arg);
typedef void (*AxVoiceCallback)(AxVoice* pDropVoice,
AxVoiceCallbackStatus status, void* pArg);
enum Format {
FORMAT_ADPCM = 0,
@@ -173,12 +182,6 @@ public:
};
public:
static u32 GetDspAddressBySample(const void *base, u32 samples, Format fmt);
static u32 GetSampleByDspAddress(const void *base, u32 addr, Format fmt);
static u32 GetSampleByByte(u32 addr, Format fmt);
static void CalcOffsetAdpcmParam(u16 *outPredScale, u16 *outYn1, u16 *outYn2, u32 offset, const void *data,
const AdpcmParam &param);
AxVoice();
~AxVoice();
@@ -199,55 +202,65 @@ public:
return mFormat;
}
void SetBaseAddress(const void *base) {
mWaveData = base;
void SetBaseAddress(const void* pBase) {
mWaveData = pBase;
}
f32 GetDspRatio(f32 ratio) const {
return (ratio * mSampleRate) / AX_SAMPLE_RATE;
}
void Setup(const void *wave, Format fmt, int rate);
void Setup(const void* pWave, Format fmt, int rate);
bool IsPlayFinished() const;
void SetLoopStart(const void *base, u32 samples);
void SetLoopEnd(const void *base, u32 samples);
void SetLoopStart(const void* pBase, u32 samples);
void SetLoopEnd(const void* pBase, u32 samples);
void SetLoopFlag(bool loop);
void StopAtPoint(const void *base, u32 samples);
void StopAtPoint(const void* pBase, u32 samples);
bool IsDataAddressCoverd(const void *begin, const void *end) const;
bool IsDataAddressCoverd(const void* pBegin, const void* pEnd) const;
u32 GetCurrentPlayingSample() const;
u32 GetCurrentPlayingDspAddress() const;
u32 GetLoopEndDspAddress() const;
void SetPriority(u32 prio);
void SetPriority(u32 priority);
void SetVoiceType(VoiceType type);
void EnableRemote(bool enable);
void ResetDelta();
void SetAddr(bool loop, const void *wave, u32 offset, u32 loopStart, u32 loopEnd);
void SetAddr(bool loop, const void* pWave, u32 offset, u32 loopStart,
u32 loopEnd);
void SetSrcType(SrcType type, f32 pitch);
void SetAdpcm(const AdpcmParam *param);
void SetAdpcmLoop(const AdpcmLoopParam *param);
bool SetMix(const MixParam &param);
void SetRmtMix(const RemoteMixParam &param);
void SetAdpcm(const AdpcmParam* pParam);
void SetAdpcmLoop(const AdpcmLoopParam* pParam);
bool SetMix(const MixParam& rParam);
void SetRmtMix(const RemoteMixParam& rParam);
void SetSrc(f32 ratio, bool initial);
void SetVe(f32 volume, f32 initVolume);
void SetLpf(u16 freq);
void SetRemoteFilter(u8 filter);
private:
static void VoiceCallback(void *arg);
static u32 GetDspAddressBySample(const void* pBase, u32 samples,
Format fmt);
static u32 GetSampleByDspAddress(const void* pBase, u32 addr, Format fmt);
static u32 GetSampleByByte(u32 addr, Format fmt);
static void CalcOffsetAdpcmParam(u16* pPredScale, u16* pYN1, u16* pYN2,
u32 offset, const void* pData,
const AdpcmParam& rParam);
private:
AxVoiceParamBlock mVpb; // at 0x0
const void *mWaveData; // at 0x10
Format mFormat; // at 0x14
int mSampleRate; // at 0x18
bool mFirstMixUpdate; // at 0x1C
bool mReserveForFree; // at 0x1D
MixParam mMixPrev; // at 0x1E
Callback mCallback; // at 0x38
void *mCallbackArg; // at 0x3C
static void VoiceCallback(void* pArg);
private:
AxVoiceParamBlock mVpb; // at 0x0
const void* mWaveData; // at 0x10
Format mFormat; // at 0x14
int mSampleRate; // at 0x18
bool mFirstMixUpdateFlag; // at 0x1C
bool mReserveForFreeFlag; // at 0x1D
MixParam mMixPrev; // at 0x1E
AxVoiceCallback mCallback; // at 0x38
void* mCallbackData; // at 0x3C
public:
NW4R_UT_LIST_NODE_DECL(); // at 0x40
@@ -255,6 +268,14 @@ public:
NW4R_UT_LIST_TYPEDEF_DECL(AxVoice);
inline int CalcAxvpbDelta(u16 init, u16 target) {
return (target - init) / AX_SAMPLES_PER_FRAME;
}
inline u16 CalcMixVolume(f32 volume) {
return ut::Min<u32>(0xFFFF, AX_MAX_VOLUME * volume);
}
} // namespace detail
} // namespace snd
} // namespace nw4r
+22 -15
View File
@@ -1,39 +1,46 @@
#ifndef NW4R_SND_AX_VOICE_MANAGER_H
#define NW4R_SND_AX_VOICE_MANAGER_H
#include <nw4r/snd/snd_AxVoice.h>
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_AxVoice.h>
namespace nw4r {
namespace snd {
namespace detail {
class AxVoiceManager {
public:
static const int VOICE_MARGIN = 16;
static const int VOICE_MAX = AX_VOICE_MAX + VOICE_MARGIN;
static const int WORK_SIZE_MAX = VOICE_MAX * sizeof(AxVoice);
public:
static AxVoiceManager& GetInstance();
AxVoiceManager();
~AxVoiceManager() {}
u32 GetRequiredMemSize();
void Setup(void* work, u32 size);
void Setup(void* pBuffer, u32 size);
void Shutdown();
AxVoice* AcquireAxVoice(u32 prio, AxVoice::Callback callback, void* arg);
void FreeAxVoice(AxVoice* voice);
void ReserveForFreeAxVoice(AxVoice* voice);
AxVoice* AcquireAxVoice(u32 priority, AxVoice::AxVoiceCallback pCallback,
void* pArg);
void FreeAxVoice(AxVoice* pVoice);
void ReserveForFreeAxVoice(AxVoice* pVoice);
void FreeAllReservedAxVoice();
private:
AxVoiceManager();
AxVoice* Alloc();
void Free(AxVoice* voice);
void ReserveForFree(AxVoice* voice);
void Free(AxVoice* pVoice);
void ReserveForFree(AxVoice* pVoice);
private:
AxVoiceList mActiveList; // at 0x0
AxVoiceList mFreeList; // at 0xC
AxVoiceList mFreeReservedList; // at 0x18
bool mInitialized; // at 0x24
int mVoiceCount; // at 0x28
AxVoiceList mActiveVoiceList; // at 0x0
AxVoiceList mFreeVoiceList; // at 0xC
AxVoiceList mFreeReservedVoiceList; // at 0x18
bool mInitialized; // at 0x24
int mVoiceCount; // at 0x28
};
} // namespace detail
+13 -9
View File
@@ -1,6 +1,7 @@
#ifndef NW4R_SND_AXFX_IMPL_H
#define NW4R_SND_AXFX_IMPL_H
#include <nw4r/types_nw4r.h>
#include <rvl/AXFX.h>
#include <rvl/MEM.h>
@@ -9,11 +10,17 @@ namespace snd {
namespace detail {
struct AxfxImpl {
static void *Alloc(u32 size);
static void Free(void *block);
bool mIsActive; // at 0x0
MEMiHeapHead* mHeap; // at 0x4
u32 mAllocCount; // at 0x8
static const u32 HEAP_SIZE_MIN = MEM_FRM_HEAP_MIN_SIZE + 32;
AxfxImpl() : mIsActive(false), mHeap(NULL), mAllocCount(0) {}
bool CreateHeap(void* pBuffer, u32 size);
void DestroyHeap();
u32 GetHeapTotalSize() {
if (mHeap == NULL) {
return 0;
@@ -22,16 +29,13 @@ struct AxfxImpl {
return MEMGetHeapTotalSize(mHeap);
}
bool CreateHeap(void *buffer, u32 size);
void DestroyHeap();
void HookAlloc(AXFXAllocHook *allocHook, AXFXFreeHook *freeHook);
void HookAlloc(AXFXAllocHook* pAllocHook, AXFXFreeHook* pFreeHook);
void RestoreAlloc(AXFXAllocHook allocHook, AXFXFreeHook freeHook);
bool mIsActive; // at 0x0
MEMiHeapHead *mHeap; // at 0x4
u32 mAllocCount; // at 0x8
static void* Alloc(u32 size);
static void Free(void* pBlock);
static AxfxImpl *mCurrentFx;
static AxfxImpl* mCurrentFx;
static u32 mAllocatedSize;
};
+31 -22
View File
@@ -1,26 +1,35 @@
#ifndef NW4R_SND_BANK_H
#define NW4R_SND_BANK_H
#include "snd_BankFile.h"
#include "snd_Channel.h"
#include "snd_NoteOn.h"
#include <nw4r/types_nw4r.h>
namespace nw4r
{
namespace snd
{
namespace detail
{
struct Bank
{
Bank(const void *);
~Bank();
Channel * NoteOn(const NoteOnInfo &) const;
BankFileReader mFileReader; // at 0x0
const UNKTYPE * PTR_0xC;
};
}
}
}
#include <nw4r/snd/snd_BankFile.h>
#include <nw4r/snd/snd_NoteOnCallback.h>
#endif
namespace nw4r {
namespace snd {
namespace detail {
// Forward declarations
class Channel;
class Bank {
public:
explicit Bank(const void* pBankBin);
~Bank();
Channel* NoteOn(const NoteOnInfo& rInfo) const;
void SetWaveDataAddress(const void* pData) {
mWaveDataAddress = pData;
}
private:
BankFileReader mBankReader; // at 0x0
const void* mWaveDataAddress; // at 0xC
};
} // namespace detail
} // namespace snd
} // namespace nw4r
#endif
+93 -75
View File
@@ -1,88 +1,106 @@
#ifndef NW4R_SND_BANK_FILE_H
#define NW4R_SND_BANK_FILE_H
#include "common.h"
#include "snd_Util.h"
#include "snd_WaveFile.h"
#include "ut_algorithm.h"
#include "ut_binaryFileFormat.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_Util.h>
#include <nw4r/snd/snd_WaveFile.h>
#include <nw4r/ut.h>
namespace nw4r {
namespace snd {
namespace detail {
namespace BankFile {
struct InstParam {
s32 waveIndex; // at 0x0
u8 attack; // at 0x4
u8 decay; // at 0x5
u8 sustain; // at 0x6
u8 release; // at 0x7
char UNK_0x8[0x4];
u8 originalKey; // at 0xC
u8 volume; // at 0xD
u8 pan; // at 0xE
f32 tune; // at 0x10
};
struct RangeTable {
u8 tableSize; // at 0x0
u8 key[]; // at 0x1
};
struct IndexTable {
u8 min; // at 0x0
u8 max; // at 0x1
u16 reserved; // at 0x2
u8 ref[]; // at 0x4
};
typedef Util::DataRef<void, InstParam, RangeTable, IndexTable> DataRegion;
typedef Util::DataRef<WaveFile::WaveInfo> WaveRegion;
struct Header {
ut::BinaryFileHeader fileHeader; // at 0x0
u32 dataBlockOffset; // at 0x10
u32 dataBlockSize; // at 0x14
u32 waveBlockOffset; // at 0x18
u32 waveBlockSize; // at 0x1C
};
struct DataBlock {
ut::BinaryBlockHeader blockHeader; // at 0x0
Util::Table<DataRegion> instTable; // at 0x8
};
struct WaveBlock {
ut::BinaryBlockHeader blockHeader; // at 0x0
Util::Table<WaveRegion> waveInfoTable; // at 0x8
};
} // namespace BankFile
struct InstInfo {
int WORD_0x0;
u8 mAttack; // at 0x4
u8 mDecay; // at 0x5
u8 mSustain; // at 0x6
u8 mRelease; // at 0x7
u8 BYTE_0x8;
u8 BYTE_0x9;
u8 BYTE_0xA;
float FLOAT_0xC;
s32 waveIndex; // at 0x0
u8 attack; // at 0x4
u8 decay; // at 0x5
u8 sustain; // at 0x6
u8 release; // at 0x7
u8 originalKey; // at 0x8
u8 pan; // at 0x9
u8 volume; // at 0xA
f32 tune; // at 0xC
};
struct BankFile {
struct InstParam {
int WORD_0x0;
u8 mAttack; // at 0x4
u8 mDecay; // at 0x5
u8 mSustain; // at 0x6
u8 mRelease; // at 0x7
char UNK_0x8[0x4];
char BYTE_0xC;
u8 BYTE_0xD;
char BYTE_0xE;
float FLOAT_0x10;
};
struct RangeTable {
u8 BYTE_0x0;
u8 BYTES_0x1[];
};
struct IndexTable {
u8 BYTE_0x0;
u8 BYTE_0x1;
};
ut::BinaryFileHeader mHeader; // at 0x0
u32 OFFSET_0x10;
char UNK_0x14[0x4];
u32 OFFSET_0x18;
typedef Util::DataRef<void, InstParam, RangeTable, IndexTable> Region;
};
struct BankFileReader {
struct UNKBLOCK_DATA {
ut::BinaryBlockHeader mHeader; // at 0x0
int INT_0x8;
BankFile::Region ARR_0xC[];
};
struct UNKBLOCK_WAVE {
ut::BinaryBlockHeader mHeader; // at 0x0
u32 INT_0x8;
WaveFile::Region ARR_0xC[];
};
bool IsValidFileHeader(const void *);
BankFileReader(const void *);
bool ReadInstInfo(InstInfo *, int, int, int) const;
const BankFile::Region *GetReferenceToSubRegion(const BankFile::Region *, int) const;
bool ReadWaveParam(WaveData *, int, const void *) const;
const BankFile *mFile; // at 0x0
const UNKBLOCK_DATA *PTR_0x4;
const UNKBLOCK_WAVE *PTR_0x8;
};
inline u8 ReadByte(const void *ptr) {
return *static_cast<const u8 *>(ptr);
inline u8 ReadByte(const void* pAddr) {
return *static_cast<const u8*>(pAddr);
}
class BankFileReader {
public:
static const u32 SIGNATURE = 'RBNK';
static const int VERSION = NW4R_VERSION(1, 1);
public:
explicit BankFileReader(const void* pBankBin);
bool IsValidFileHeader(const void* pBankBin);
bool ReadInstInfo(InstInfo* pInfo, int prgNo, int key, int velocity) const;
bool ReadWaveParam(WaveData* pData, int waveIndex,
const void* pWaveAddr) const;
private:
const BankFile::DataRegion*
GetReferenceToSubRegion(const BankFile::DataRegion* pRef,
int splitKey) const;
private:
const BankFile::Header* mHeader; // at 0x0
const BankFile::DataBlock* mDataBlock; // at 0x4
const BankFile::WaveBlock* mWaveBlock; // at 0x8
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+10 -9
View File
@@ -1,7 +1,11 @@
#ifndef NW4R_SND_BASIC_PLAYER_H
#define NW4R_SND_BASIC_PLAYER_H
#include <nw4r/snd/snd_Common.h>
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_Common.h>
#include <nw4r/ut.h>
#include <rvl/WPAD.h>
namespace nw4r {
@@ -88,18 +92,17 @@ public:
void SetFxSend(AuxBus bus, f32 send);
f32 GetFxSend(AuxBus bus) const;
void SetRemoteOutVolume(int remote, f32 vol);
void SetRemoteOutVolume(int remote, f32 volume);
f32 GetRemoteOutVolume(int remote) const;
f32 GetRemoteSend(int remote) const;
f32 GetRemoteFxSend(int remote) const;
int GetRemoteFilter() const {
return mRemoteFilter;
}
void SetRemoteFilter(int filter) {
mRemoteFilter = ut::Clamp(filter, FILTER_MIN, FILTER_MAX);
mRemoteFilter = ut::Clamp(filter, 0, REMOTE_FILTER_MAX);
}
PanMode GetPanMode() const {
@@ -116,18 +119,16 @@ public:
mPanCurve = curve;
}
public:
static const int FILTER_MIN = 0;
static const int FILTER_MAX = 127;
private:
u32 mId; // at 0x4
u32 mId; // at 0x4
f32 mVolume; // at 0x8
f32 mPitch; // at 0xC
f32 mPan; // at 0x10
f32 mSurroundPan; // at 0x14
f32 mLpfFreq; // at 0x18
char UNK_0x1C[0x4];
int mOutputLine; // at 0x20
f32 mMainOutVolume; // at 0x24
f32 mMainSend; // at 0x28
+112 -84
View File
@@ -1,9 +1,12 @@
#ifndef NW4R_SND_BASIC_SOUND_H
#define NW4R_SND_BASIC_SOUND_H
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_Common.h>
#include <nw4r/snd/snd_MoveValue.h>
#include <nw4r/types_nw4r.h>
#include <nw4r/ut.h>
#include <rvl/WPAD.h>
namespace nw4r {
@@ -17,26 +20,42 @@ public:
NW4R_UT_RTTI_DECL(BasicSound);
struct AmbientParamUpdateCallback {
virtual void detail_Update(SoundParam *param, u32 id, BasicSound *sound, const void *arg, u32 flags) = 0;
enum ParamUpdateFlags {
PARAM_UPDATE_VOLUME = (1 << 0),
PARAM_UPDATE_PAN = (1 << 1),
PARAM_UPDATE_SURROUND_PAN = (1 << 2),
PARAM_UPDATE_PRIORITY = (1 << 3),
};
virtual void detail_Update(SoundParam* pParam, u32 id,
BasicSound* pSound, const void* pArg,
u32 flags) = 0; // at 0xC
};
struct AmbientArgUpdateCallback {
virtual void detail_Update(void *arg, const BasicSound *sound) = 0;
virtual void detail_Update(void* pArg,
const BasicSound* pSound) = 0; // at 0xC
};
struct AmbientArgAllocaterCallback {
virtual void *detail_AllocAmbientArg(u32 size) = 0;
virtual void detail_FreeAmbientArg(void *arg, const BasicSound *sound) = 0;
virtual void* detail_AllocAmbientArg(u32 size) = 0; // at 0xC
virtual void
detail_FreeAmbientArg(void* pArg,
const BasicSound* pSound) = 0; // at 0x10
};
struct AmbientArgInfo {
AmbientParamUpdateCallback *mParamUpdateCallback; // at 0x0
AmbientArgUpdateCallback *mArgUpdateCallback; // at 0x4
AmbientArgAllocaterCallback *mArgAllocaterCallback; // at 0x8
void *arg; // at 0xC
u32 argSize; // at 0x10
AmbientParamUpdateCallback* paramUpdateCallback; // at 0x0
AmbientArgUpdateCallback* argUpdateCallback; // at 0x4
AmbientArgAllocaterCallback* argAllocaterCallback; // at 0x8
void* arg; // at 0xC
u32 argSize; // at 0x10
};
static const u32 INVALID_ID = 0xFFFFFFFF;
static const int PRIORITY_MAX = 127;
public:
BasicSound();
virtual ~BasicSound() {} // at 0xC
@@ -51,27 +70,29 @@ public:
virtual bool IsPrepared() const = 0; // at 0x2C
virtual bool IsPause() const; // at 0x30
virtual void SetInitialVolume(f32 vol); // at 0x34
virtual void SetVolume(f32 vol, int frames); // at 0x38
virtual void SetPitch(f32 pitch); // at 0x3C
virtual void SetPan(f32 pan); // at 0x40
virtual void SetSurroundPan(f32 pan); // at 0x44
virtual void SetLpfFreq(f32 freq); // at 0x48
virtual void SetPlayerPriority(int prio); // at 0x4C
virtual void SetRemoteFilter(int filter); // at 0x50
virtual void SetPanMode(PanMode mode); // at 0x54
virtual void SetPanCurve(PanCurve curve); // at 0x58
virtual bool IsAttachedTempSpecialHandle() = 0; // at 0x5C
virtual void DetachTempSpecialHandle() = 0; // at 0x60
virtual void InitParam(); // at 0x64
virtual BasicPlayer *GetBasicPlayer() = 0; // at 0x68
virtual const BasicPlayer *GetBasicPlayer() const = 0; // at 0x6C
virtual void SetInitialVolume(f32 vol); // at 0x34
virtual void SetVolume(f32 vol, int frames); // at 0x38
virtual void SetPitch(f32 pitch); // at 0x3C
virtual void SetPan(f32 pan); // at 0x40
virtual void SetSurroundPan(f32 pan); // at 0x44
virtual void SetLpfFreq(f32 freq); // at 0x48
virtual void SetPlayerPriority(int priority); // at 0x4C
virtual void SetRemoteFilter(int filter); // at 0x50
virtual void SetPanMode(PanMode mode); // at 0x54
virtual void SetPanCurve(PanCurve curve); // at 0x58
PlayerHeap *GetPlayerHeap() {
return mPlayerHeap;
virtual bool IsAttachedTempSpecialHandle() = 0; // at 0x5C
virtual void DetachTempSpecialHandle() = 0; // at 0x60
virtual void InitParam(); // at 0x64
virtual BasicPlayer& GetBasicPlayer() = 0; // at 0x68
virtual const BasicPlayer& GetBasicPlayer() const = 0; // at 0x6C
PlayerHeap* GetPlayerHeap() {
return mHeap;
}
void SetPlayerHeap(PlayerHeap *heap) {
mPlayerHeap = heap;
void SetPlayerHeap(PlayerHeap* pHeap) {
mHeap = pHeap;
}
bool IsAttachedGeneralHandle();
@@ -80,45 +101,51 @@ public:
bool IsAttachedTempGeneralHandle();
void DetachTempGeneralHandle();
SoundPlayer *GetSoundPlayer() {
SoundPlayer* GetSoundPlayer() {
return mSoundPlayer;
}
void SetSoundPlayer(SoundPlayer *player) {
mSoundPlayer = player;
void SetSoundPlayer(SoundPlayer* pPlayer) {
mSoundPlayer = pPlayer;
}
ExternalSoundPlayer *GetExternalSoundPlayer() {
ExternalSoundPlayer* GetExternalSoundPlayer() {
return mExtSoundPlayer;
}
void SetExternalSoundPlayer(ExternalSoundPlayer *player) {
mExtSoundPlayer = player;
void SetExternalSoundPlayer(ExternalSoundPlayer* pExtPlayer) {
mExtSoundPlayer = pExtPlayer;
}
AmbientParamUpdateCallback *GetAmbientParamUpdateCallback() {
return mParamUpdateCallback;
AmbientParamUpdateCallback* GetAmbientParamUpdateCallback() {
return mAmbientParamUpdateCallback;
}
AmbientArgUpdateCallback *GetAmbientArgUpdateCallback() {
return mArgUpdateCallback;
AmbientArgUpdateCallback* GetAmbientArgUpdateCallback() {
return mAmbientArgUpdateCallback;
}
void ClearAmbientArgUpdateCallback() {
mArgUpdateCallback = NULL;
mAmbientArgUpdateCallback = NULL;
}
AmbientArgAllocaterCallback *GetAmbientArgAllocaterCallback() {
return mArgAllocCallback;
AmbientArgAllocaterCallback* GetAmbientArgAllocaterCallback() {
return mAmbientArgAllocaterCallback;
}
void *GetAmbientArg() {
return mCallbackArg;
void* GetAmbientArg() {
return mAmbientArg;
}
SoundParam &GetAmbientParam() {
SoundParam& GetAmbientParam() {
return mAmbientParam;
}
void SetAmbientParamCallback(AmbientParamUpdateCallback *paramUpdate, AmbientArgUpdateCallback *argUpdate,
AmbientArgAllocaterCallback *argAlloc, void *arg);
void SetAmbientParamCallback(AmbientParamUpdateCallback* pParamUpdate,
AmbientArgUpdateCallback* pArgUpdate,
AmbientArgAllocaterCallback* pArgAlloc,
void* pArg);
void SetPriority(int priority) {
mPriority = priority;
}
u32 GetId() const {
return mId;
@@ -126,7 +153,7 @@ public:
void SetId(u32 id);
f32 GetMoveVolume() {
return mExtVolume.GetValue();
return mExtMoveVolume.GetValue();
}
f32 GetInitialVolume() const;
@@ -147,45 +174,46 @@ public:
void SetFxSend(AuxBus bus, f32 send);
int CalcCurrentPlayerPriority() const {
return ut::Clamp(mPriority + mAmbientParam.priority, PRIORITY_MIN, PRIORITY_MAX);
return ut::Clamp(mPriority + mAmbientParam.priority, 0, PRIORITY_MAX);
}
public:
static const int PRIORITY_MIN = 0;
static const int PRIORITY_MAX = 127;
private:
PlayerHeap *mPlayerHeap; // at 0x4
SoundHandle *mGeneralHandle; // at 0x8
SoundHandle *mTempGeneralHandle; // at 0xC
SoundPlayer *mSoundPlayer; // at 0x10
ExternalSoundPlayer *mExtSoundPlayer; // at 0x14
AmbientParamUpdateCallback *mParamUpdateCallback; // at 0x18
AmbientArgUpdateCallback *mArgUpdateCallback; // at 0x1C
AmbientArgAllocaterCallback *mArgAllocCallback; // at 0x20
void *mCallbackArg; // at 0x24
SoundParam mAmbientParam; // at 0x28
MoveValue<f32, int> mFadeVolume; // at 0x44
MoveValue<f32, int> mPauseFadeVolume; // at 0x54
bool mIsStarting; // at 0x64
bool mIsStarted; // at 0x65
bool mIsAutoStop; // at 0x66
bool mIsPause; // at 0x67
bool mIsPauseFade; // at 0x68
bool mIsFadeOut; // at 0x69
int mAutoStopCounter; // at 0x6C
u32 mUpdateCounter; // at 0x70
u8 mPriority; // at 0x74
u32 mId; // at 0x78
MoveValue<f32, int> mExtVolume; // at 0x7C
f32 mInitVolume; // at 0x8C
f32 mExtPan; // at 0x90
f32 mExtSurroundPan; // at 0x94
f32 mExtPitch; // at 0x98
bool mEnableOutputLine; // at 0x9C
int mOutputLine; // at 0xA0
f32 mMainOutVolume; // at 0xA4
f32 mRemoteOutVolumes[WPAD_MAX_CONTROLLERS]; // at 0xA8
PlayerHeap* mHeap; // at 0x4
SoundHandle* mGeneralHandle; // at 0x8
SoundHandle* mTempGeneralHandle; // at 0xC
SoundPlayer* mSoundPlayer; // at 0x10
ExternalSoundPlayer* mExtSoundPlayer; // at 0x14
AmbientParamUpdateCallback* mAmbientParamUpdateCallback; // at 0x18
AmbientArgUpdateCallback* mAmbientArgUpdateCallback; // at 0x1C
AmbientArgAllocaterCallback* mAmbientArgAllocaterCallback; // at 0x20
void* mAmbientArg; // at 0x24
SoundParam mAmbientParam; // at 0x28
MoveValue<f32, int> mFadeVolume; // at 0x44
MoveValue<f32, int> mPauseFadeVolume; // at 0x54
bool mStartFlag; // at 0x64
bool mStartedFlag; // at 0x65
bool mAutoStopFlag; // at 0x66
bool mPauseFlag; // at 0x67
bool mPauseFadeFlag; // at 0x68
bool mFadeOutFlag; // at 0x69
int mAutoStopCounter; // at 0x6C
u32 mUpdateCounter; // at 0x70
u8 mPriority; // at 0x74
u32 mId; // at 0x78
MoveValue<f32, int> mExtMoveVolume; // at 0x7C
f32 mInitVolume; // at 0x8C
f32 mExtPan; // at 0x90
f32 mExtSurroundPan; // at 0x94
f32 mExtPitch; // at 0x98
bool mOutputLineFlagEnable; // at 0x9C
int mOutputLineFlag; // at 0xA0
f32 mMainOutVolume; // at 0xA4
f32 mRemoteOutVolume[WPAD_MAX_CONTROLLERS]; // at 0xA8
public:
NW4R_UT_LIST_NODE_DECL_EX(Prio); // at 0xB8
+220 -109
View File
@@ -1,143 +1,254 @@
#ifndef NW4R_SND_CHANNEL_H
#define NW4R_SND_CHANNEL_H
#include "common.h"
#include "snd_EnvGenerator.h"
#include "snd_InstancePool.h"
#include "snd_Lfo.h"
#include "snd_MoveValue.h"
#include "snd_Voice.h"
#include "snd_WaveFile.h"
#include "ut_LinkList.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_Common.h>
#include <nw4r/snd/snd_EnvGenerator.h>
#include <nw4r/snd/snd_Lfo.h>
#include <nw4r/snd/snd_MoveValue.h>
#include <nw4r/snd/snd_Voice.h>
#include <nw4r/ut.h>
namespace nw4r {
namespace snd {
namespace detail {
struct Channel {
enum ChannelCallbackStatus { CALLBACK_STATUS_0, CALLBACK_STATUS_1, CALLBACK_STATUS_2, CALLBACK_STATUS_3 };
typedef void (*ChannelCallback)(Channel *, ChannelCallbackStatus, u32);
class Channel {
public:
enum ChannelCallbackStatus {
CALLBACK_STATUS_STOPPED,
CALLBACK_STATUS_DROP,
CALLBACK_STATUS_FINISH,
CALLBACK_STATUS_CANCEL
};
static void VoiceCallbackFunc(Voice *, Voice::VoiceCallbackStatus, void *);
typedef void (*ChannelCallback)(Channel* pDropChannel,
ChannelCallbackStatus status,
u32 callbackArg);
static Channel *AllocChannel(int, int, int, ChannelCallback, u32);
static void FreeChannel(Channel *);
enum LfoTarget { LFO_TARGET_PITCH, LFO_TARGET_VOLUME, LFO_TARGET_PAN };
public:
Channel();
~Channel();
UNKTYPE InitParam(ChannelCallback, u32);
void Update(bool);
UNKTYPE Start(const WaveData &, int, u32);
UNKTYPE Release();
UNKTYPE Stop();
void InitParam(ChannelCallback pCallback, u32 callbackArg);
void Update(bool periodic);
void Start(const WaveData& rData, int length, u32 offset);
void Release();
void Stop();
float GetSweepValue() const;
void UpdateSweep(int);
void SetSweepParam(float, int, bool);
void SetAttack(int attack) {
mEnvelope.SetAttack(attack);
}
void SetDecay(int decay) {
mEnvelope.SetDecay(decay);
}
void SetSustain(int sustain) {
mEnvelope.SetSustain(sustain);
}
void SetRelease(int release) {
mEnvelope.SetRelease(release);
}
bool IsRelease() const {
return mEnvelope.GetStatus() == EnvGenerator::STATUS_RELEASE;
}
EnvGenerator mEnvGenerator; // at 0x0
Lfo mLfo; // at 0x18
u8 BYTE_0x30;
bool mPauseFlag; // at 0x31
bool mActiveFlag; // at 0x32
bool BOOL_0x33;
bool mAutoUpdateSweepFlag; // at 0x34
bool mReleasePriorityFixFlag; // at 0x35
void SetLfoParam(const LfoParam& rParam) {
mLfo.SetParam(rParam);
}
void SetLfoTarget(LfoTarget target) {
mLfoTarget = target;
}
float FLOAT_0x38;
float FLOAT_0x3C;
float FLOAT_0x40;
float FLOAT_0x44;
float FLOAT_0x48;
void Pause(bool pause) {
mPauseFlag = pause;
mVoice->Pause(pause);
}
void SetReleasePriorityFix(bool fix) {
mReleasePriorityFixFlag = fix;
}
int mRemoteFilter; // at 0x4c
int mOutputLine; // at 0x50
float FLOAT_0x54;
float FLOAT_0x58;
float ARR_0x5C[3];
float mRemoteOutVolumes[4]; // at 0x68
float ARR_0x78[4];
float ARR_0x88[4];
float FLOAT_0x98;
float FLOAT_0x9C;
int INT_0xA0;
int INT_0xA4;
float FLOAT_0xA8;
float FLOAT_0xAC;
float FLOAT_0xB0;
float FLOAT_0xB4;
MoveValue<u8, u16> MV_0xB8;
UNKWORD INT_0xC0;
UNKWORD INT_0xC4;
int mLength; // at 0xc8
PanMode mPanMode; // at 0xcc
PanCurve mPanCurve; // at 0xd0
ChannelCallback mCallback; // at 0xd4
u32 INT_0xD8;
Voice *mVoice; // at 0xdc
Channel *mNext; // at 0xe0
ut::LinkListNode mNode; // at 0xe4
inline bool IsActive() const {
bool IsPause() const {
return mPauseFlag != false;
}
bool IsActive() const {
return mActiveFlag;
}
inline void SetRelease(int release) {
if (release >= 0) {
mEnvGenerator.SetRelease(release);
}
Release();
bool IsAutoUpdateSweep() const {
return mAutoSweep;
}
inline bool IsAutoUpdateSweep() const {
return mAutoUpdateSweepFlag;
void SetUserVolume(f32 volume) {
mUserVolume = volume;
}
void SetUserPitch(f32 pitch) {
mUserPitch = pitch;
}
void SetUserPitchRatio(f32 ratio) {
mUserPitchRatio = ratio;
}
void SetUserPan(f32 pan) {
mUserPan = pan;
}
void SetUserSurroundPan(f32 pan) {
mUserSurroundPan = pan;
}
void SetUserLpfFreq(f32 freq) {
mUserLpfFreq = freq;
}
inline bool IsPause() const {
return mPauseFlag;
void SetRemoteFilter(int filter) {
mRemoteFilter = filter;
}
void SetOutputLine(int flag) {
mOutputLineFlag = flag;
}
inline void Pause(bool flag) {
mPauseFlag = flag;
mVoice->Pause(flag);
void SetMainOutVolume(f32 volume) {
mMainOutVolume = volume;
}
void SetMainSend(f32 send) {
mMainSend = send;
}
void SetFxSend(AuxBus bus, f32 send) {
mFxSend[bus] = send;
}
inline void SetLfoParam(const LfoParam &lfoParam) {
mLfo.SetParam(lfoParam);
void SetRemoteOutVolume(int remote, f32 volume) {
mRemoteOutVolume[remote] = volume;
}
void SetRemoteSend(int remote, f32 send) {
mRemoteSend[remote] = send;
}
void SetRemoteFxSend(int remote, f32 send) {
mRemoteFxSend[remote] = send;
}
inline void SetSilence(bool silentFlag, int time) {
MV_0xB8.SetTarget(silentFlag ? 0 : 0xFF, time);
void UpdateSweep(int count);
void SetSweepParam(f32 pitch, int time, bool autoUpdate);
f32 GetSweepValue() const;
void SetInitVolume(f32 volume) {
mInitVolume = volume;
}
void SetInitPan(f32 pan) {
mInitPan = pan;
}
void SetInitSurroundPan(f32 pan) {
mInitSurroundPan = pan;
}
void SetTune(f32 tune) {
mTune = tune;
}
void SetSilence(bool silence, int fadeTime) {
mSilenceVolume.SetTarget(silence ? 0 : SILENCE_VOLUME_MAX, fadeTime);
}
void SetKey(int key) {
mKey = key;
}
void SetOriginalKey(int key) {
mOriginalKey = key;
}
s32 GetLength() const {
return mLength;
}
void SetLength(s32 length) {
mLength = length;
}
void SetPanMode(PanMode mode) {
mPanMode = mode;
}
void SetPanCurve(PanCurve curve) {
mPanCurve = curve;
}
Channel* GetNextTrackChannel() const {
return mNextLink;
}
void SetNextTrackChannel(Channel* pChannel) {
mNextLink = pChannel;
}
static Channel* AllocChannel(int channels, int voices, int priority,
ChannelCallback pCallback, u32 callbackArg);
static void FreeChannel(Channel* pChannel);
private:
static const u8 SILENCE_VOLUME_MAX = 255;
static const int KEY_INIT = 60;
static const int ORIGINAL_KEY_INIT = 60;
static const int PRIORITY_RELEASE = 1;
private:
static void VoiceCallbackFunc(Voice* pDropVoice,
Voice::VoiceCallbackStatus status,
void* pCallbackArg);
private:
EnvGenerator mEnvelope; // at 0x0
Lfo mLfo; // at 0x18
u8 mLfoTarget; // at 0x30
bool mPauseFlag; // at 0x31
bool mActiveFlag; // at 0x32
bool mAllocFlag; // at 0x33
bool mAutoSweep; // at 0x34
bool mReleasePriorityFixFlag; // at 0x35
f32 mUserVolume; // at 0x38
f32 mUserPitchRatio; // at 0x3C
f32 mUserPan; // at 0x40
f32 mUserSurroundPan; // at 0x44
f32 mUserLpfFreq; // at 0x48
int mRemoteFilter; // at 0x4C
int mOutputLineFlag; // at 0x50
f32 mMainOutVolume; // at 0x54
f32 mMainSend; // at 0x58
f32 mFxSend[AUX_BUS_NUM]; // at 0x5C
f32 mRemoteOutVolume[WPAD_MAX_CONTROLLERS]; // at 0x68
f32 mRemoteSend[WPAD_MAX_CONTROLLERS]; // at 0x78
f32 mRemoteFxSend[WPAD_MAX_CONTROLLERS]; // at 0x88
f32 mUserPitch; // at 0x98
f32 mSweepPitch; // at 0x9C
int mSweepCounter; // at 0xA0
int mSweepLength; // at 0xA4
f32 mInitVolume; // at 0xA8
f32 mInitPan; // at 0xAC
f32 mInitSurroundPan; // at 0xB0
f32 mTune; // at 0xB4
MoveValue<u8, u16> mSilenceVolume; // at 0xB8
int mKey; // at 0xC0
int mOriginalKey; // at 0xC4
int mLength; // at 0xC8
PanMode mPanMode; // at 0xCC
PanCurve mPanCurve; // at 0xD0
ChannelCallback mCallback; // at 0xD4
u32 mCallbackData; // at 0xD8
Voice* mVoice; // at 0xDC
Channel* mNextLink; // at 0xE0
public:
NW4R_UT_LIST_NODE_DECL(); // at 0xE4
};
struct ChannelManager {
ChannelManager();
NW4R_UT_LIST_TYPEDEF_DECL(Channel);
u32 GetRequiredMemSize();
void Setup(void *, u32);
void Shutdown();
UNKTYPE UpdateAllChannel();
static void Free(Channel *); // inlined
Channel *Alloc(); // inlined
static ChannelManager *GetInstance();
InstancePool<Channel> mPool; // at 0x0
ut::LinkList<Channel, 0xE4> mList; // at 0x4
bool BOOL_0x10;
u32 INT_0x14;
UNKTYPE *PTR_0x18;
u32 INT_0x1C;
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+34 -3
View File
@@ -1,15 +1,46 @@
#ifndef NW4R_SND_CHANNEL_MANAGER_H
#define NW4R_SND_CHANNEL_MANAGER_H
#include "common.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_Channel.h>
#include <nw4r/snd/snd_InstancePool.h>
namespace nw4r {
namespace snd {
namespace detail {
struct ChannelManager {
static ChannelManager *GetInstance();
class ChannelManager {
friend class Channel; // Alloc/Free intended through Channel only
public:
static const int VOICE_MARGIN = 1;
static const int VOICE_MAX = AX_VOICE_MAX + VOICE_MARGIN;
static const int WORK_SIZE_MAX = VOICE_MAX * sizeof(Channel);
public:
static ChannelManager& GetInstance();
u32 GetRequiredMemSize();
void Setup(void* pWork, u32 workSize);
void Shutdown();
void UpdateAllChannel();
private:
ChannelManager();
Channel* Alloc();
void Free(Channel* pChannel);
private:
InstancePool<Channel> mPool; // at 0x0
ChannelList mChannelList; // at 0x4
bool mInitialized; // at 0x10
u32 mChannelCount; // at 0x14
void* mMem; // at 0x18
u32 mMemSize; // at 0x1C
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+27
View File
@@ -5,6 +5,26 @@
namespace nw4r {
namespace snd {
static const int CHANNEL_MIN = 1;
static const int CHANNEL_MAX = 2;
static const int REMOTE_FILTER_MAX = 127;
// 12 notes each with 256 microtones
static const int SEMITONE_MAX = 12;
static const int MICROTONE_MAX = 256;
// Volume in range [-90.4db, 6.0db]
static const f32 VOLUME_MIN_DB = -90.4f;
static const f32 VOLUME_MAX_DB = 6.0f;
static const f32 VOLUME_RANGE_DB = -(VOLUME_MIN_DB - VOLUME_MAX_DB);
static const int VOLUME_RANGE_MB = static_cast<int>(10 * VOLUME_RANGE_DB);
enum OutputLineFlag {
OUTPUT_LINE_MAIN = (1 << 0),
OUTPUT_LINE_REMOTE_N = (1 << 1),
};
enum AuxBus { AUX_A, AUX_B, AUX_C, AUX_BUS_NUM };
enum OutputMode {
@@ -30,6 +50,7 @@ enum PanMode {
PAN_MODE_DUAL,
PAN_MODE_BALANCE,
};
enum PanCurve {
PAN_CURVE_SQRT,
PAN_CURVE_SQRT_0DB,
@@ -56,6 +77,12 @@ struct AdpcmLoopParam {
u16 loop_yn2; // at 0x4
};
struct AdpcmInfo {
AdpcmParam param; // at 0x0
AdpcmLoopParam loopParam; // at 0x28
u16 padding;
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+17 -7
View File
@@ -1,18 +1,28 @@
#ifndef NW4R_SND_DISPOSE_CALLBACK_H
#define NW4R_SND_DISPOSE_CALLBACK_H
#include "common.h"
#include "ut_LinkList.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/ut.h>
namespace nw4r {
namespace snd {
namespace detail {
struct DisposeCallback {
ut::LinkListNode mNode; // at 0x0
inline virtual ~DisposeCallback() {} // at 0x8
virtual void InvalidateData(const void *, const void *) = 0; // at 0xc
virtual void InvalidateWaveData(const void *, const void *) = 0; // at 0x10
class DisposeCallback {
public:
NW4R_UT_LIST_NODE_DECL(); // at 0x0
public:
virtual ~DisposeCallback() {} // at 0x8
virtual void InvalidateData(const void* pStart,
const void* pEnd) = 0; // at 0xC
virtual void InvalidateWaveData(const void* pStart,
const void* pEnd) = 0; // at 0x10
};
NW4R_UT_LIST_TYPEDEF_DECL(DisposeCallback);
} // namespace detail
} // namespace snd
} // namespace nw4r
+17 -10
View File
@@ -1,23 +1,30 @@
#ifndef NW4R_SND_DISPOSE_CALLBACK_MANAGER_H
#define NW4R_SND_DISPOSE_CALLBACK_MANAGER_H
#include "common.h"
#include "snd_DisposeCallback.h"
#include "ut_LinkList.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_DisposeCallback.h>
namespace nw4r {
namespace snd {
namespace detail {
struct DisposeCallbackManager {
static DisposeCallbackManager *GetInstance();
ut::LinkList<DisposeCallback, 0x0> mList; // at 0x0
class DisposeCallbackManager {
public:
static DisposeCallbackManager& GetInstance();
UNKTYPE RegisterDisposeCallback(DisposeCallback *);
UNKTYPE UnregisterDisposeCallback(DisposeCallback *);
void RegisterDisposeCallback(DisposeCallback* pCallback);
void UnregisterDisposeCallback(DisposeCallback* pCallback);
UNKTYPE Dispose(void *, u32, void *);
UNKTYPE DisposeWave(void *, u32, void *);
void Dispose(void* pData, u32 size, void* pArg);
void DisposeWave(void* pData, u32 size, void* pArg);
private:
DisposeCallbackManager();
private:
DisposeCallbackList mCallbackList; // at 0x0
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+61 -35
View File
@@ -1,41 +1,67 @@
#ifndef NW4R_SND_DVD_SOUND_ARCHIVE_H
#define NW4R_SND_DVD_SOUND_ARCHIVE_H
#include <dvd.h>
#include "ut_DvdLockedFileStream.h"
#include "snd_SoundArchive.h"
#include "snd_SoundArchiveFile.h"
#include <nw4r/types_nw4r.h>
namespace nw4r
{
namespace snd
{
struct DvdSoundArchive : SoundArchive
{
struct DvdFileStream;
detail::SoundArchiveFileReader mFileReader; // at 0x108
DVDFileInfo mFileInfo; // at 0x14c
bool mOpenFlag; // at 0x188
DvdSoundArchive();
#include <nw4r/snd/snd_SoundArchive.h>
#include <nw4r/snd/snd_SoundArchiveFile.h>
virtual ~DvdSoundArchive(); // at 0x8
virtual const void * detail_GetFileAddress(u32) const; // at 0xC
virtual const void * detail_GetWaveDataFileAddress(u32) const; // at 0x10
virtual int detail_GetRequiredStreamBufferSize() const; // at 0x14
virtual ut::FileStream * OpenStream(void *, int, u32, u32) const; // at 0x18
virtual ut::FileStream * OpenExtStream(void *, int, const char *, u32, u32) const; // at 0x1c
#include <nw4r/ut.h>
bool Open(s32); //inlined
bool Open(const char *);
void Close();
bool LoadFileHeader(); //inlined
bool LoadHeader(void *, u32);
bool LoadLabelStringData(void *, u32);
};
}
}
#include <rvl/DVD.h>
#endif
namespace nw4r {
namespace snd {
class DvdSoundArchive : public SoundArchive {
private:
class DvdFileStream;
public:
DvdSoundArchive();
virtual ~DvdSoundArchive(); // at 0x8
virtual const void* detail_GetFileAddress(u32 /* id */) const {
return NULL;
} // at 0xC
virtual const void* detail_GetWaveDataFileAddress(u32 /* id */) const {
return NULL;
} // at 0x10
virtual int detail_GetRequiredStreamBufferSize() const; // at 0x14
virtual ut::FileStream* OpenStream(void* pBuffer, int size, u32 offset,
u32 length) const; // at 0x18
virtual ut::FileStream* OpenExtStream(void* pBuffer, int size,
const char* pExtPath, u32 offset,
u32 length) const; // at 0x1C
bool Open(s32 entrynum);
bool Open(const char* pPath);
void Close();
bool LoadHeader(void* pBuffer, u32 size);
bool LoadLabelStringData(void* pBuffer, u32 size);
u32 GetHeaderSize() const {
return mFileReader.GetInfoChunkSize();
}
u32 GetLabelStringDataSize() const {
return mFileReader.GetLabelStringChunkSize();
}
private:
bool LoadFileHeader();
private:
detail::SoundArchiveFileReader mFileReader; // at 0x108
DVDFileInfo mFileInfo; // at 0x14C
bool mOpen; // at 0x188
};
} // namespace snd
} // namespace nw4r
#endif
+20 -7
View File
@@ -13,32 +13,45 @@ public:
public:
EnvGenerator();
void Init(f32 db);
void Reset(f32 db);
void Init(f32 db = VOLUME_INIT);
void Reset(f32 db = VOLUME_INIT);
f32 GetValue() const;
void Update(int msec);
Status GetStatus() const { return mStatus; }
void SetStatus(Status status) { mStatus = status; }
Status GetStatus() const {
return mStatus;
}
void SetStatus(Status status) {
mStatus = status;
}
void SetAttack(int attack);
void SetDecay(int decay);
void SetSustain(int sustain);
void SetRelease(int release);
private:
static const int DECIBEL_SQUARE_TABLE_SIZE = 128;
static const volatile f32 VOLUME_INIT;
static const int ATTACK_INIT = 127;
static const int DECAY_INIT = 127;
static const int SUSTAIN_INIT = 127;
static const int RELEASE_INIT = 127;
private:
f32 CalcRelease(int release);
int CalcDecibelSquare(int scale);
private:
static const volatile f32 VOLUME_INIT;
static const s16 DecibelSquareTable[128];
Status mStatus; // at 0x0
f32 mValue; // at 0x4
f32 mDecay; // at 0x8
f32 mRelease; // at 0xC
f32 mAttack; // at 0x10
u8 mSustain; // at 0x14
static const s16 DecibelSquareTable[DECIBEL_SQUARE_TABLE_SIZE];
};
} // namespace detail
+21 -18
View File
@@ -1,8 +1,9 @@
#ifndef NW4R_SND_EXTERNAL_SOUND_PLAYER_H
#define NW4R_SND_EXTERNAL_SOUND_PLAYER_H
#include <nw4r/snd/snd_BasicSound.h>
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_BasicSound.h>
namespace nw4r {
namespace snd {
namespace detail {
@@ -12,19 +13,25 @@ public:
ExternalSoundPlayer();
~ExternalSoundPlayer();
int GetPlayableSoundCount() const { return mPlayableSoundCount; }
int GetPlayableSoundCount() const {
return mPlayableCount;
}
void SetPlayableSoundCount(int count);
int GetPlayingSoundCount() const { return mSoundList.GetSize(); }
int GetPlayingSoundCount() const {
return mSoundList.GetSize();
}
f32 detail_GetVolume() const { return mVolume; }
f32 detail_GetVolume() const {
return mVolume;
}
BasicSound* GetLowestPrioritySound();
void InsertSoundList(BasicSound* sound);
void RemoveSoundList(BasicSound* sound);
void InsertSoundList(BasicSound* pSound);
void RemoveSoundList(BasicSound* pSound);
template <typename TForEachFunc>
TForEachFunc ForEachSound(TForEachFunc func, bool reverse) {
TForEachFunc ForEachSound(TForEachFunc pFunction, bool reverse) {
if (reverse) {
BasicSoundExtPlayList::RevIterator it =
mSoundList.GetBeginReverseIter();
@@ -34,30 +41,26 @@ public:
SoundHandle handle;
handle.detail_AttachSoundAsTempHandle(&*curr);
func(handle);
pFunction(handle);
if (handle.IsAttachedSound()) {
++it;
}
}
} else {
BasicSoundExtPlayList::Iterator it = mSoundList.GetBeginIter();
while (it != mSoundList.GetEndIter()) {
BasicSoundExtPlayList::Iterator curr = it++;
NW4R_UT_LIST_SAFE_FOREACH(mSoundList,
SoundHandle handle;
handle.detail_AttachSoundAsTempHandle(&*curr);
func(handle);
}
handle.detail_AttachSoundAsTempHandle(&*it);
pFunction(handle);
);
}
return func;
return pFunction;
}
private:
BasicSoundExtPlayList mSoundList; // at 0x0
u16 mPlayableSoundCount; // at 0xC
u16 mPlayableCount; // at 0xC
f32 mVolume; // at 0x10
};
+71 -52
View File
@@ -1,73 +1,92 @@
#ifndef NW4R_SND_FRAME_HEAP_H
#define NW4R_SND_FRAME_HEAP_H
#include "common.h"
#include "ut_LinkList.h"
#include "ut_algorithm.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/ut.h>
#include <rvl/MEM.h>
namespace nw4r {
namespace snd {
namespace detail {
struct FrameHeap {
typedef void (*AllocCallback)(void *, u32, void *);
struct Block {
ut::LinkListNode mNode; // at 0x0
u32 mSize; // at 0x8
AllocCallback mCallback; // at 0xc
void *PTR_0x10;
inline Block(u32 size, AllocCallback callback, void *ptr) : mSize(size), mCallback(callback), PTR_0x10(ptr) {}
inline void *GetBufferAddr() {
return reinterpret_cast<u8 *>(this) + ut::RoundUp<u32>(sizeof(Block), 0x20);
}
inline ~Block() {
if (mCallback) {
mCallback(PTR_0x10, mSize, GetBufferAddr());
}
}
};
struct Section {
ut::LinkListNode mNode; // at 0x0
ut::LinkList<Block, 0x0> mList; // at 0x8
inline void AppendBlock(Block *pBlock) {
mList.PushBack(pBlock);
}
inline ~Section() {
ut::LinkList<Block, 0x0>::Iterator iter = mList.GetEndIter();
while (iter != mList.GetBeginIter()) {
(--iter)->~Block();
}
}
};
bool NewSection(); // inlined
UNKTYPE ClearSection(); // inlined
class FrameHeap {
public:
typedef void (*FreeCallback)(void* pBuffer, u32 size, void* pCallbackArg);
public:
FrameHeap();
~FrameHeap();
bool Create(void *, u32);
UNKTYPE Destroy();
bool Create(void* pBase, u32 size);
void Destroy();
void Clear();
void *Alloc(u32, AllocCallback, void *);
void* Alloc(u32 size, FreeCallback pCallback, void* pCallbackArg);
int SaveState();
void LoadState(int);
void LoadState(int id);
int GetCurrentLevel() const;
u32 GetFreeSize() const;
UNKTYPE *PTR_0x0;
ut::LinkList<Section, 0x0> mList; // at 0x4
inline bool IsValid() const {
return mList.GetSize();
bool IsValid() const {
return mHandle != NULL;
}
private:
struct Block {
NW4R_UT_LIST_NODE_DECL(); // at 0x0
u32 mSize; // at 0x8
FreeCallback mCallback; // at 0xc
void* mCallbackArg; // at 0x10
Block(u32 size, FreeCallback pCallback, void* pCallbackArg)
: mSize(size), mCallback(pCallback), mCallbackArg(pCallbackArg) {}
~Block() {
if (mCallback != NULL) {
mCallback(GetBufferAddr(), mSize, mCallbackArg);
}
}
void* GetBufferAddr() {
return ut::AddOffsetToPtr(this, BLOCK_BUFFER_SIZE);
}
};
NW4R_UT_LIST_TYPEDEF_DECL(Block);
struct Section {
NW4R_UT_LIST_NODE_DECL(); // at 0x0
BlockList mBlockList; // at 0x8
~Section() {
for (BlockList::Iterator it = mBlockList.GetEndIter();
it != mBlockList.GetBeginIter();) {
(--it)->~Block();
}
}
void AppendBlock(Block* pBlock) {
mBlockList.PushBack(pBlock);
}
};
NW4R_UT_LIST_TYPEDEF_DECL(Section);
static const int BLOCK_BUFFER_SIZE = ROUND_UP(sizeof(Block), 32);
static const int HEAP_ALIGN = 32;
private:
bool NewSection();
void ClearSection();
private:
MEMiHeapHead* mHandle; // at 0x0
SectionList mSectionList; // at 0x4
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+28 -9
View File
@@ -1,23 +1,42 @@
#ifndef NW4R_SND_FX_BASE_H
#define NW4R_SND_FX_BASE_H
#include "common.h"
#include "snd_Common.h"
#include "ut_LinkList.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_Common.h>
#include <nw4r/ut.h>
namespace nw4r {
namespace snd {
enum SampleFormat { SAMPLE_FORMAT_PCM_S32, SAMPLE_FORMAT_PCM_S16, SAMPLE_FORMAT_PCM_S8, SAMPLE_FORMAT_DSP_ADPCM };
struct FxBase {
inline virtual ~FxBase() {} // at 0x8
inline virtual bool StartUp() {} // at 0xc
inline virtual UNKTYPE Shutdown() {} // at 0x10
inline virtual UNKTYPE UpdateBuffer(int, void **, u32, SampleFormat, float, OutputMode) {} // at 0x14
enum SampleFormat {
SAMPLE_FORMAT_PCM_S32,
SAMPLE_FORMAT_PCM_S16,
SAMPLE_FORMAT_PCM_S8,
SAMPLE_FORMAT_DSP_ADPCM
};
class FxBase : private ut::NonCopyable {
public:
virtual ~FxBase() {} // at 0x8
virtual bool StartUp() {
return true;
} // at 0xC
virtual void Shutdown() {} // at 0x10
virtual void UpdateBuffer(int /* channels */, void** /* ppBuffer */,
u32 /* size */, SampleFormat /* format */,
f32 /* sampleRate */, OutputMode /* mode */) {
} // at 0x14
public:
NW4R_UT_LIST_NODE_DECL(); // at 0x4
};
NW4R_UT_LIST_TYPEDEF_DECL(FxBase);
} // namespace snd
} // namespace nw4r
+30 -21
View File
@@ -1,41 +1,50 @@
#ifndef NW4R_SND_FX_CHORUS_H
#define NW4R_SND_FX_CHORUS_H
#include "snd_AxfxImpl.h"
#include "snd_FxBase.h"
#include <AXFXChorus.h>#include "common.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_AxfxImpl.h>
#include <nw4r/snd/snd_FxBase.h>
#include <rvl/AXFX.h>
namespace nw4r {
namespace snd {
struct FxChorus : FxBase {
// sizeof(ChorusParam) = 0xc
class FxChorus : public FxBase {
public:
struct ChorusParam {
float FLOAT_0x0;
float FLOAT_0x4;
float FLOAT_0x8;
f32 delayTime; // at 0x0
f32 depth; // at 0x4
f32 rate; // at 0x8
};
public:
FxChorus();
inline ~FxChorus() {
virtual ~FxChorus() {
Shutdown();
ReleaseWorkBuffer();
}
} // at 0x8
virtual bool StartUp(); // at 0xC
virtual void Shutdown(); // at 0x10
virtual void UpdateBuffer(int channels, void** ppBuffer, u32 size,
SampleFormat format, f32 sampleRate,
OutputMode mode); // at 0x14
virtual bool AssignWorkBuffer(void* pBuffer, u32 size); // at 0x18
virtual void ReleaseWorkBuffer(); // at 0x1C
u32 GetRequiredMemSize();
virtual UNKTYPE AssignWorkBuffer(void *, u32); // at 0x18
virtual UNKTYPE ReleaseWorkBuffer(); // at 0x1c
bool SetParam(const ChorusParam& rParam);
bool StartUp(); // at 0xc
UNKTYPE Shutdown(); // at 0x10
bool SetParam(const ChorusParam &);
UNKTYPE UpdateBuffer(int, void **, u32, SampleFormat, float, OutputMode); // at 0x14
detail::AxfxImpl mAxfxImpl;
ChorusParam mParam; // at 0x18
AXFX_CHORUS mAXFXChorus; // 0x24
private:
detail::AxfxImpl mImpl; // at 0xC
ChorusParam mParam; // at 0x18
AXFX_CHORUS mAxfxParam; // at 0x24
};
} // namespace snd
} // namespace nw4r
+31 -22
View File
@@ -1,41 +1,50 @@
#ifndef NW4R_SND_FX_DELAY_H
#define NW4R_SND_FX_DELAY_H
#include "common.h"
#include "snd_AxfxImpl.h"
#include "snd_FxBase.h"
#include <AXFXDelay.h>
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_AxfxImpl.h>
#include <nw4r/snd/snd_FxBase.h>
#include <rvl/AXFX.h>
namespace nw4r {
namespace snd {
struct FxDelay : FxBase {
// sizeof(FxDelayParam) = 0xc
class FxDelay : public FxBase {
public:
struct DelayParam {
float FLOAT_0x0;
float FLOAT_0x4;
float FLOAT_0x8;
f32 delay; // at 0x0
f32 feedback; // at 0x4
f32 outGain; // at 0x8
};
public:
FxDelay();
inline ~FxDelay() {
virtual ~FxDelay() {
Shutdown();
ReleaseWorkBuffer();
}
} // at 0x8
virtual bool StartUp(); // at 0xC
virtual void Shutdown(); // at 0x10
virtual void UpdateBuffer(int channels, void** ppBuffer, u32 size,
SampleFormat format, f32 sampleRate,
OutputMode mode); // at 0x14
virtual bool AssignWorkBuffer(void* pBuffer, u32 size); // at 0x18
virtual void ReleaseWorkBuffer(); // at 0x1C
u32 GetRequiredMemSize();
virtual UNKTYPE AssignWorkBuffer(void *, u32); // at 0x18
virtual UNKTYPE ReleaseWorkBuffer(); // at 0x1c
bool SetParam(const DelayParam& rParam);
bool StartUp(); // at 0xc
UNKTYPE Shutdown(); // at 0x10
bool SetParam(const DelayParam &);
UNKTYPE UpdateBuffer(int, void **, u32, SampleFormat, float, OutputMode); // at 0x14
detail::AxfxImpl mAxfxImpl; // at 0xc
DelayParam mParam; // at 0x18
AXFX_DELAY mAXFXDelay; // at 0x24
private:
detail::AxfxImpl mImpl; // at 0xC
DelayParam mParam; // at 0x18
AXFX_DELAY mAxfxParam; // at 0x24
};
} // namespace snd
} // namespace nw4r
+34 -25
View File
@@ -1,44 +1,53 @@
#ifndef NW4R_SND_FX_REVERB_HI_H
#define NW4R_SND_FX_REVERB_HI_H
#include "common.h"
#include "snd_AxfxImpl.h"
#include "snd_FxBase.h"
#include <AXFXReverbHi.h>
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_AxfxImpl.h>
#include <nw4r/snd/snd_FxBase.h>
#include <rvl/AXFX.h>
namespace nw4r {
namespace snd {
struct FxReverbHi : FxBase {
// sizeof(ReverbHiParam) = 0x18
class FxReverbHi : public FxBase {
public:
struct ReverbHiParam {
float FLOAT_0x0;
float FLOAT_0x4;
float FLOAT_0x8;
float FLOAT_0xC;
float FLOAT_0x10;
float FLOAT_0x14;
f32 preDelayTime; // at 0x0
f32 fusedTime; // at 0x4
f32 coloration; // at 0x8
f32 damping; // at 0xC
f32 crossTalk; // at 0x10
f32 outGain; // at 0x14
};
public:
FxReverbHi();
inline ~FxReverbHi() {
virtual ~FxReverbHi() {
Shutdown();
ReleaseWorkBuffer();
}
} // at 0x8
virtual bool StartUp(); // at 0xC
virtual void Shutdown(); // at 0x10
virtual void UpdateBuffer(int channels, void** ppBuffer, u32 size,
SampleFormat format, f32 sampleRate,
OutputMode mode); // at 0x14
virtual bool AssignWorkBuffer(void* pBuffer, u32 size); // at 0x18
virtual void ReleaseWorkBuffer(); // at 0x1C
u32 GetRequiredMemSize();
virtual UNKTYPE AssignWorkBuffer(void *, u32); // at 0x18
virtual UNKTYPE ReleaseWorkBuffer(); // at 0x1c
bool SetParam(const ReverbHiParam& rParam);
bool StartUp(); // at 0xc
UNKTYPE Shutdown(); // at 0x10
bool SetParam(const ReverbHiParam &);
UNKTYPE UpdateBuffer(int, void **, u32, SampleFormat, float, OutputMode); // at 0x14
detail::AxfxImpl mAxfxImpl; // at 0xc
ReverbHiParam mParam; // at 0x18
AXFX_REVERBHI mAXFXReverbHi; // at 0x30
private:
detail::AxfxImpl mImpl; // at 0xC
ReverbHiParam mParam; // at 0x18
AXFX_REVERBHI mAxfxParam; // at 0x30
};
} // namespace snd
} // namespace nw4r
+54
View File
@@ -0,0 +1,54 @@
#ifndef NW4R_SND_FX_REVERB_HI_DPL2_H
#define NW4R_SND_FX_REVERB_HI_DPL2_H
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_AxfxImpl.h>
#include <nw4r/snd/snd_FxBase.h>
#include <rvl/AXFX.h>
namespace nw4r {
namespace snd {
class FxReverbHiDpl2 : public FxBase {
public:
struct ReverbHiDpl2Param {
f32 preDelayTime; // at 0x0
f32 fusedTime; // at 0x4
f32 coloration; // at 0x8
f32 damping; // at 0xC
f32 crossTalk; // at 0x10
f32 outGain; // at 0x14
};
public:
FxReverbHiDpl2();
virtual ~FxReverbHiDpl2() {
Shutdown();
ReleaseWorkBuffer();
} // at 0x8
virtual bool StartUp(); // at 0xC
virtual void Shutdown(); // at 0x10
virtual void UpdateBuffer(int channels, void** ppBuffer, u32 size,
SampleFormat format, f32 sampleRate,
OutputMode mode); // at 0x14
virtual bool AssignWorkBuffer(void* pBuffer, u32 size); // at 0x18
virtual void ReleaseWorkBuffer(); // at 0x1C
u32 GetRequiredMemSize();
bool SetParam(const ReverbHiDpl2Param& rParam);
private:
detail::AxfxImpl mImpl; // at 0xC
ReverbHiDpl2Param mParam; // at 0x18
AXFX_REVERBHI_DPL2 mAxfxParam; // at 0x30
};
} // namespace snd
} // namespace nw4r
#endif
+49 -36
View File
@@ -1,68 +1,81 @@
#ifndef NW4R_SND_INSTANCE_POOL_H
#define NW4R_SND_INSTANCE_POOL_H
#include "common.h"
#include <MSL_C/new.h>
#include <nw4r/types_nw4r.h>
namespace nw4r {
namespace snd {
namespace detail {
struct PoolImpl {
struct Member {
Member *mNext; // at 0x0
};
u32 CreateImpl(void *, u32, u32);
void DestroyImpl(void *, u32);
u32 CountImpl() const;
void *AllocImpl();
void FreeImpl(void *);
class PoolImpl {
public:
PoolImpl() : mNext(NULL) {}
Member mHead; // at 0x0
protected:
u32 CreateImpl(void* pBuffer, u32 size, u32 stride);
void DestroyImpl(void* pBuffer, u32 size);
int CountImpl() const;
inline PoolImpl() {
mHead.mNext = NULL;
}
void* AllocImpl();
void FreeImpl(void* pElem);
private:
PoolImpl* mNext; // at 0x0
};
template <typename T>
struct InstancePool : PoolImpl {
inline u32 Create(void *ptr, u32 num) {
return CreateImpl(ptr, num, sizeof(T));
template <typename T> class InstancePool : private PoolImpl {
public:
u32 Create(void* pBuffer, u32 size) {
return CreateImpl(pBuffer, size, sizeof(T));
}
inline T *Alloc() {
void *ptr = AllocImpl();
void Destroy(void* pPtr, u32 size) {
DestroyImpl(pPtr, size);
}
if (!ptr) {
int Count() const {
return CountImpl();
}
T* Alloc() {
void* pPtr = AllocImpl();
if (pPtr == NULL) {
return NULL;
}
return new (ptr) T;
return new (pPtr) T;
}
inline void Free(T *ptr) {
if (ptr) {
ptr->~T();
FreeImpl(ptr);
void Free(T* pElem) {
if (pElem != NULL) {
pElem->~T();
FreeImpl(pElem);
}
}
};
inline void Destroy(void *ptr, u32 num) {
DestroyImpl(ptr, num);
template <typename T> class MemoryPool : private PoolImpl {
public:
u32 Create(void* pBuffer, u32 size) {
return CreateImpl(pBuffer, size, sizeof(T));
}
inline u32 Count() const {
void Destroy(void* pPtr, u32 size) {
DestroyImpl(pPtr, size);
}
int Count() const {
return CountImpl();
}
};
template <typename T>
struct MemoryPool : PoolImpl {
inline void Free(T *ptr) {
ptr->~T();
FreeImpl(ptr);
T* Alloc() {
return static_cast<T*>(AllocImpl());
}
void Free(T* pElem) {
FreeImpl(pElem);
}
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+21 -9
View File
@@ -7,29 +7,41 @@ namespace snd {
namespace detail {
struct LfoParam {
LfoParam() { Init(); }
LfoParam() {
Init();
}
void Init();
f32 depth; // at 0x0
f32 speed; // at 0x4
u32 delay; // at 0x8
u8 range; // at 0xC
f32 depth; // at 0x0
f32 speed; // at 0x4
u32 delay; // at 0x8
u8 range; // at 0xC
u8 padding[3]; // at 0xD
};
class Lfo {
public:
static s8 GetSinIdx(int i);
Lfo() : mDelayCounter(0), mCounter(0.0f) {}
LfoParam& GetParam() { return mParam; }
void SetParam(const LfoParam& param) { mParam = param; }
LfoParam& GetParam() {
return mParam;
}
void SetParam(const LfoParam& rParam) {
mParam = rParam;
}
void Reset();
void Update(int msec);
f32 GetValue() const;
private:
static const int TABLE_SIZE = 32;
private:
static s8 GetSinIdx(int i);
private:
LfoParam mParam; // at 0x0
u32 mDelayCounter; // at 0x10
+40 -29
View File
@@ -1,33 +1,44 @@
#ifndef NW4R_SND_MEMORY_SOUND_ARCHIVE_H
#define NW4R_SND_MEMORY_SOUND_ARCHIVE_H
#include "ut_FileStream.h"
#include "snd_SoundArchive.h"
#include "snd_SoundArchiveFile.h"
#include <nw4r/types_nw4r.h>
namespace nw4r
{
namespace snd
{
struct MemorySoundArchive : SoundArchive
{
struct MemoryFileStream;
const void * mMemory; // at 0x108
detail::SoundArchiveFileReader mFileReader; // at 0x10c
MemorySoundArchive();
virtual ~MemorySoundArchive(); // at 0x8
bool Setup(const void *);
void Shutdown();
virtual const void * detail_GetFileAddress(u32) const;
virtual const void * detail_GetWaveDataFileAddress(u32) const;
virtual int detail_GetRequiredStreamBufferSize() const;
virtual ut::FileStream * OpenStream(void *, int, u32, u32) const; // at 0x18
virtual ut::FileStream * OpenExtStream(void *, int, const char *, u32, u32) const; // at 0x1c
};
}
}
#include <nw4r/snd/snd_SoundArchive.h>
#include <nw4r/snd/snd_SoundArchiveFile.h>
#endif
#include <nw4r/ut.h>
namespace nw4r {
namespace snd {
class MemorySoundArchive : public SoundArchive {
private:
class MemoryFileStream;
public:
MemorySoundArchive();
virtual ~MemorySoundArchive(); // at 0x8
virtual const void* detail_GetFileAddress(u32 id) const; // at 0xC
virtual const void* detail_GetWaveDataFileAddress(u32 id) const; // at 0x10
virtual int detail_GetRequiredStreamBufferSize() const; // at 0x14
virtual ut::FileStream* OpenStream(void* pBuffer, int size, u32 offset,
u32 length) const; // at 0x18
virtual ut::FileStream* OpenExtStream(void* pBuffer, int size,
const char* pExtPath, u32 offset,
u32 length) const; // at 0x1C
bool Setup(const void* pBuffer);
void Shutdown();
private:
const void* mData; // at 0x108
detail::SoundArchiveFileReader mFileReader; // at 0x10C
};
} // namespace snd
} // namespace nw4r
#endif
+140 -19
View File
@@ -1,38 +1,159 @@
#ifndef NW4R_SND_MML_PARSER_H
#define NW4R_SND_MML_PARSER_H
#include "common.h"
#include "snd_MmlSeqTrack.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_SeqTrack.h>
namespace nw4r {
namespace snd {
namespace detail {
struct MmlParser {
u16 Read16(const u8 **) const; // inlined
u32 Read24(const u8 **) const; // inlined
u32 ReadVar(const u8 **) const; // inlined
volatile s16 *GetVariablePtr(SeqPlayer *, SeqTrack *, int) const;
UNKWORD Parse(MmlSeqTrack *, bool) const;
virtual void CommandProc(MmlSeqTrack *, u32, s32, s32) const; // at 0x8
virtual Channel *NoteOnCommandProc(MmlSeqTrack *, int, int, s32, bool) const; // at 0xc
// Forward declarations
class MmlSeqTrack;
class SeqPlayer;
class MmlParser {
public:
enum SeqArgType {
SEQ_ARG_TYPE_IMMEDIATE_BYTE,
SEQ_ARG_TYPE_IMMEDIATE_16,
SEQ_ARG_TYPE_IMMEDIATE_VAR,
SEQ_ARG_TYPE_RANDOM,
SEQ_ARG_TYPE_VARIABLE
SEQ_ARG_U8,
SEQ_ARG_S16,
SEQ_ARG_VMIDI,
SEQ_ARG_RANDOM,
SEQ_ARG_VARIABLE
};
s32 ReadArg(const u8 **, SeqPlayer *, SeqTrack *, SeqArgType) const;
static const int CALL_STACK_MAX_DEPTH = 3;
inline u8 ReadByte(const u8 **pPointer) const {
return *(*pPointer)++;
public:
virtual void CommandProc(MmlSeqTrack* pTrack, u32 command, s32 arg1,
s32 arg2) const; // at 0x8
virtual Channel* NoteOnCommandProc(MmlSeqTrack* pTrack, int key,
int velocity, s32 length,
bool tie) const; // at 0xC
ParseResult Parse(MmlSeqTrack* pTrack, bool doNoteOn) const;
volatile s16* GetVariablePtr(SeqPlayer* pPlayer, SeqTrack* pTrack,
int i) const;
static void EnablePrintVar(bool enable) {
mPrintVarEnabledFlag = enable;
}
private:
enum MmlSeqData {
MML_CMD_MIN = 0x80, // <80 -> MML note, not a command
MML_WAIT = 0x80, // 0x80
MML_SET_PRGNO, // 0x81
MML_OPENTRACK = 0x88, // 0x88
MML_JUMP, // 0x89
MML_CALL, // 0x8A
MML_RNDPARAM = 0xA0, // 0xA0
MML_INDPARAM, // 0xA1
MML_EXECIF, // 0xA2
MML_SET_TIMEBASE = 0xB0, // 0xB0
MML_SET_PAN = 0xC0, // 0xC0
MML_SET_TRACK_VOLUME, // 0xC1
MML_SET_PLAYER_VOLUME, // 0xC2
MML_SET_TRANSPOSE, // 0xC3
MML_SET_PITCHBEND, // 0xC4
MML_SET_BENDRANGE, // 0xC5
MML_SET_PRIORITY, // 0xC6
MML_SET_NOTEWAIT, // 0xC7
MML_SET_TIE, // 0xC8
MML_SET_PORTAMENTO, // 0xC9
MML_SET_LFODEPTH, // 0xCA
MML_SET_LFOSPEED, // 0xCB
MML_SET_LFOTARGET, // 0xCC
MML_SET_LFORANGE, // 0xCD
MML_SET_PORTASPEED, // 0xCE
MML_SET_PORTATIME, // 0xCF
MML_SET_ATTACK = 0xD0, // 0xD0
MML_SET_DECAY, // 0xD1
MML_SET_SUSTAIN, // 0xD2
MML_SET_RELEASE, // 0xD3
MML_LOOP_START, // 0xD4
MML_SET_TRACK_VOLUME2, // 0xD5
MML_PRINTVAR, // 0xD6
MML_SET_SURROUNDPAN, // 0xD7
MML_SET_LPFFREQ, // 0xD8
MML_SET_FXSEND_A, // 0xD9
MML_SET_FXSEND_B, // 0xDA
MML_SET_MAINSEND, // 0xDB
MML_SET_INITPAN, // 0xDC
MML_SET_MUTE, // 0xDD
MML_SET_FXSEND_C, // 0xDE
MML_SET_DAMPER, // 0xDF
MML_SET_LFODELAY = 0xE0, // 0xE0
MML_SET_TEMPO, // 0xE1
MML_CMD_E2h, // 0xE2
MML_SET_SWEEPPITCH, // 0xE3
MML_LOOP_END = 0xFC, // 0xFC
MML_RET, // 0xFD
MML_ALLOCTRACK, // 0xFE
MML_EOF, // 0xFF
MML_CMD_MASK = 0x80,
MML_CMD_SET_MASK = 0xF0,
MML_CMD_MAX = 0xFF, // >FF -> EX command
// (MML_EX_COMMAND << 8) | Command
MML_EX_COMMAND = 0xF0,
// MML EX arithmetic command set
MML_EX_ARITHMETIC = 0x80, // 0xF0 0x8X
MML_EX_SET = 0x80, // 0xF0 0x80
MML_EX_APL, // 0xF0 0x81
MML_EX_AMI, // 0xF0 0x82
MML_EX_AMU, // 0xF0 0x83
MML_EX_ADV, // 0xF0 0x84
MML_EX_ALS, // 0xF0 0x85
MML_EX_RND, // 0xF0 0x86
MML_EX_AAD, // 0xF0 0x87
MML_EX_AOR, // 0xF0 0x88
MML_EX_AER, // 0xF0 0x89
MML_EX_ACO, // 0xF0 0x8A
MML_EX_AMD, // 0xF0 0x8B
// MML EX logic command set
MML_EX_LOGIC = 0x90, // 0xF0 0x9X
MML_EX_EQ = 0x90, // 0xF0 0x90
MML_EX_GE, // 0xF0 0x91
MML_EX_GT, // 0xF0 0x92
MML_EX_LE, // 0xF0 0x93
MML_EX_LT, // 0xF0 0x94
MML_EX_NE, // 0xF0 0x95
// MML EX userproc callback
MML_EX_USERPROC = 0xE0, // 0xF0 0xE0
MML_EX_CMD_MAX = 0xFFFF, // >FFFF -> Invalid command
};
private:
u8 ReadByte(const u8** ppData) const {
return *(*ppData)++;
}
u16 Read16(const u8** ppData) const;
u32 Read24(const u8** ppData) const;
s32 ReadVar(const u8** ppData) const;
s32 ReadArg(const u8** ppData, SeqPlayer* pPlayer, SeqTrack* pTrack,
SeqArgType type) const;
private:
static bool mPrintVarEnabledFlag;
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+28 -14
View File
@@ -1,31 +1,45 @@
#ifndef NW4R_SND_MML_SEQ_TRACK_H
#define NW4R_SND_MML_SEQ_TRACK_H
#include "common.h"
#include "snd_SeqTrack.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_MmlParser.h>
#include <nw4r/snd/snd_SeqTrack.h>
namespace nw4r {
namespace snd {
namespace detail {
struct MmlSeqTrack : SeqTrack {
enum { STACK_FRAME_COUNT = 3 };
// Forward declarations
class MmlParser;
class MmlSeqTrack : public SeqTrack {
public:
struct MmlParserParam {
bool mPredicate; // at 0x0
bool BOOL_0x1;
bool BOOL_0x2;
u8 mLoopCounters[STACK_FRAME_COUNT]; // at 0x3
u8 mStackIndex; // at 0x6
const u8 *mReturnAddresses[STACK_FRAME_COUNT]; // at 0x8
bool cmpFlag; // at 0x0
bool noteWaitFlag; // at 0x1
bool tieFlag; // at 0x2
u8 loopCount[MmlParser::CALL_STACK_MAX_DEPTH]; // at 0x3
u8 callStackDepth; // at 0x6
const u8* callStack[MmlParser::CALL_STACK_MAX_DEPTH]; // at 0x8
};
MmlParser *mParser; // at 0xc0
MmlParserParam mMmlParserParam; // at 0xc4
public:
MmlSeqTrack();
virtual ParseResult Parse(bool doNoteOn); // at 0xC
UNKWORD Parse(bool); // at 0xc
void SetMmlParser(const MmlParser* pParser) {
mParser = pParser;
}
MmlParserParam& GetMmlParserParam() {
return mMmlParserParam;
}
private:
const MmlParser* mParser; // at 0xC0
MmlParserParam mMmlParserParam; // at 0xC4
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+25 -12
View File
@@ -1,25 +1,38 @@
#ifndef NW4R_SND_MML_SEQ_TRACK_ALLOCATOR_H
#define NW4R_SND_MML_SEQ_TRACK_ALLOCATOR_H
#include "common.h"
#include "snd_InstancePool.h"
#include "snd_MmlParser.h"
#include "snd_MmlSeqTrack.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_InstancePool.h>
#include <nw4r/snd/snd_SeqTrackAllocator.h>
namespace nw4r {
namespace snd {
namespace detail {
struct MmlSeqTrackAllocator : SeqTrackAllocator {
MmlParser *mParser;
InstancePool<MmlSeqTrack> mPool; // at 0x8
SeqTrack *AllocTrack(SeqPlayer *); // at 0xc
void FreeTrack(SeqTrack *); // at 0x10
// Forward declarations
class MmlParser;
class SeqPlayer;
class SeqTrack;
u32 Create(void *, u32);
void Destroy(void *, u32);
class MmlSeqTrackAllocator : public SeqTrackAllocator {
public:
MmlSeqTrackAllocator(MmlParser* pParser) : mParser(pParser) {}
int GetAllocatableTrackCount() const; // at 0x14
virtual SeqTrack* AllocTrack(SeqPlayer* pPlayer); // at 0xC
virtual void FreeTrack(SeqTrack* pTrack); // at 0x10
virtual int GetAllocatableTrackCount() const {
return mTrackPool.Count();
} // at 0x14
u32 Create(void* pBuffer, u32 size);
void Destroy(void* pBuffer, u32 size);
private:
MmlParser* mParser; // at 0x4
InstancePool<MmlSeqTrack> mTrackPool; // at 0x8
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+3 -1
View File
@@ -21,7 +21,9 @@ public:
mCounter = 0;
}
bool IsFinished() const { return mCounter >= mFrame; }
bool IsFinished() const {
return mCounter >= mFrame;
}
TValue GetValue() const {
if (IsFinished()) {
+59 -34
View File
@@ -1,40 +1,65 @@
#ifndef NW4R_SND_NAND_SOUND_ARCHIVE_H
#define NW4R_SND_NAND_SOUND_ARCHIVE_H
#include <nand.h>
#include "ut_NandFileStream.h"
#include "snd_SoundArchive.h"
#include "snd_SoundArchiveFile.h"
#include <nw4r/types_nw4r.h>
namespace nw4r
{
namespace snd
{
struct NandSoundArchive : SoundArchive
{
struct NandFileStream;
detail::SoundArchiveFileReader mFileReader; // at 0x108
NANDFileInfo mFileInfo; // at 0x14c
bool mOpenFlag; // at 0x1d8
NandSoundArchive();
#include <nw4r/snd/snd_SoundArchive.h>
#include <nw4r/snd/snd_SoundArchiveFile.h>
virtual ~NandSoundArchive(); // at 0x8
virtual const void * detail_GetFileAddress(u32) const; // at 0xC
virtual const void * detail_GetWaveDataFileAddress(u32) const; // at 0x10
virtual int detail_GetRequiredStreamBufferSize() const; // at 0x14
virtual ut::FileStream * OpenStream(void *, int, u32, u32) const; // at 0x18
virtual ut::FileStream * OpenExtStream(void *, int, const char *, u32, u32) const; // at 0x1c
#include <nw4r/ut.h>
bool Open(const char *);
void Close();
bool LoadFileHeader();
bool LoadHeader(void *, u32);
bool LoadLabelStringData(void *, u32);
};
}
}
#include <rvl/NAND.h>
#endif
namespace nw4r {
namespace snd {
class NandSoundArchive : public SoundArchive {
private:
struct NandFileStream;
public:
NandSoundArchive();
virtual ~NandSoundArchive(); // at 0x8
virtual const void* detail_GetFileAddress(u32 /* id */) const {
return NULL;
} // at 0xC
virtual const void* detail_GetWaveDataFileAddress(u32 /* id */) const {
return NULL;
} // at 0x10
virtual int detail_GetRequiredStreamBufferSize() const; // at 0x14
virtual ut::FileStream* OpenStream(void* pBuffer, int size, u32 offset,
u32 length) const; // at 0x18
virtual ut::FileStream* OpenExtStream(void* pBuffer, int size,
const char* pExtPath, u32 offset,
u32 length) const; // at 0x1C
bool Open(const char* pPath);
void Close();
bool LoadHeader(void* pBuffer, u32 size);
bool LoadLabelStringData(void* pBuffer, u32 size);
u32 GetHeaderSize() const {
return mFileReader.GetInfoChunkSize();
}
u32 GetLabelStringDataSize() const {
return mFileReader.GetLabelStringChunkSize();
}
private:
bool LoadFileHeader() DECOMP_DONT_INLINE;
private:
detail::SoundArchiveFileReader mFileReader; // at 0x108
NANDFileInfo mFileInfo; // at 0x14C
bool mOpen; // at 0x1D8
};
} // namespace snd
} // namespace nw4r
#endif
-29
View File
@@ -1,29 +0,0 @@
#ifndef NW4R_SND_NOTE_ON_H
#define NW4R_SND_NOTE_ON_H
#include "common.h"
#include "snd_Channel.h"
namespace nw4r {
namespace snd {
namespace detail {
struct NoteOnInfo {
int INT_0x0;
int INT_0x4;
int INT_0x8;
int INT_0xC;
int INT_0x10;
int INT_0x14;
int INT_0x18;
Channel::ChannelCallback mChannelCallback; // at 0x1c
u32 INT_0x20;
};
struct NoteOnCallback {
virtual ~NoteOnCallback(); // at 0x8
virtual bool NoteOn(SeqPlayer *, int, const NoteOnInfo &) = 0; // at 0xc
};
} // namespace detail
} // namespace snd
} // namespace nw4r
#endif
+38
View File
@@ -0,0 +1,38 @@
#ifndef NW4R_SND_NOTE_ON_CALLBACK_H
#define NW4R_SND_NOTE_ON_CALLBACK_H
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_Channel.h>
namespace nw4r {
namespace snd {
namespace detail {
// Forward declarations
class SeqPlayer;
struct NoteOnInfo {
int prgNo; // at 0x0
int key; // at 0x4
int velocity; // at 0x8
int length; // at 0xC
int initPan; // at 0x10
int priority; // at 0x14
int voiceOutCount; // at 0x18
Channel::ChannelCallback channelCallback; // at 0x1C
u32 channelCallbackData; // at 0x20
};
class NoteOnCallback {
public:
virtual ~NoteOnCallback() {} // at 0x8
virtual Channel* NoteOn(SeqPlayer* pPlayer, int bankNo,
const NoteOnInfo& rInfo) = 0; // at 0xC
};
} // namespace detail
} // namespace snd
} // namespace nw4r
#endif
+33 -5
View File
@@ -1,15 +1,43 @@
#ifndef NW4R_SND_PLAYER_HEAP_H
#define NW4R_SND_PLAYER_HEAP_H
#include "common.h"
#include "snd_SoundHeap.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_SoundHeap.h>
namespace nw4r {
namespace snd {
// Forward declarations
class SoundPlayer;
namespace detail {
struct PlayerHeap : SoundHeap {
~PlayerHeap();
UNKTYPE *Alloc(u32);
// Forward declarations
class BasicSound;
class PlayerHeap : public SoundHeap {
public:
PlayerHeap() : mSound(NULL), mPlayer(NULL) {}
virtual ~PlayerHeap() {} // at 0x8
void SetSound(BasicSound* pSound) {
mSound = pSound;
}
void SetSoundPlayer(SoundPlayer* pPlayer) {
mPlayer = pPlayer;
}
public:
NW4R_UT_LIST_NODE_DECL(); // at 0x2C
private:
BasicSound* mSound; // at 0x34
SoundPlayer* mPlayer; // at 0x38
};
NW4R_UT_LIST_TYPEDEF_DECL(PlayerHeap);
} // namespace detail
} // namespace snd
} // namespace nw4r
+75 -46
View File
@@ -1,68 +1,97 @@
#ifndef NW4R_SND_REMOTE_SPEAKER_H
#define NW4R_SND_REMOTE_SPEAKER_H
#include <OS.h>
#include <OSAlarm.h>#include "common.h"
#include <nw4r/types_nw4r.h>
#include <rvl/OS.h>
#include <rvl/WENC.h>
#include <rvl/WPAD.h>
namespace nw4r {
namespace snd {
struct RemoteSpeaker {
typedef void (*RemoteSpeakerCallback)(s32, s32);
enum SpeakerCommand {
SpeakerCommand_None,
SpeakerCommand_On,
SpeakerCommand_Play,
SpeakerCommand_Off,
class RemoteSpeaker {
public:
enum SpeakerState {
STATE_INVALID,
STATE_EXEC_SPEAKER_ON,
STATE_SPEAKER_ON,
STATE_EXEC_SPEAKER_PLAY,
STATE_SPEAKER_PLAY,
STATE_EXEC_SPEAKER_OFF,
STATE_SPEAKER_OFF
};
bool mPoweredFlag; // at 0x0
bool BOOL_0x1;
bool mEnabledOutputFlag; // at 0x2
bool BOOL_0x3;
bool BOOL_0x4;
bool BOOL_0x5;
bool BOOL_0x6;
bool BOOL_0x7;
volatile bool BOOL_0x8;
enum SpeakerCommand {
COMMAND_NONE,
COMMAND_SPEAKER_ON,
COMMAND_SPEAKER_PLAY,
COMMAND_SPEAKER_OFF
};
UNKWORD WORD_0xC;
SpeakerCommand CMD_0x10;
SpeakerCommand CMD_0x14;
char UNK_0x18[0x20];
s32 mChannelIndex; // at 0x38
RemoteSpeakerCallback mCallback; // at 0x3c
OSAlarm ALARM_0x40;
OSAlarm ALARM_0x70;
s64 mTime; // at 0xa0
static const int SAMPLES_PER_AUDIO_PACKET = 40;
public:
RemoteSpeaker();
void ClearParam(); // inlined
void InitParam(); // inlined
bool Setup(RemoteSpeakerCallback);
void Shutdown(RemoteSpeakerCallback);
void InitParam();
bool Setup(WPADCallback pCallback);
void Shutdown(WPADCallback pCallback);
bool EnableOutput(bool);
bool EnableOutput(bool enable);
bool IsEnabledOutput() const;
void Update();
void ExecCommand(SpeakerCommand);
void UpdateStreamData(const s16* pRmtSamples);
bool IsAllSampleZero(const s16 *); // inlined
void UpdateStreamData(const s16 *);
void NotifyCallback(s32, s32); // inlined
static void SpeakerOnCallback(s32, s32);
static void SpeakerPlayCallback(s32, s32);
static void SpeakerOffCallback(s32, s32);
static void ContinueAlarmHandler(OSAlarm *, OSContext *);
static void IntervalAlarmHandler(OSAlarm *, OSContext *);
inline void SetChannelIndex(int channelIndex) {
mChannelIndex = channelIndex;
bool IsAvailable() const {
return mState == STATE_SPEAKER_PLAY;
}
void SetChannelIndex(int index) {
mChannelIndex = index;
}
private:
static const int SAMPLES_PER_ENCODED_PACKET =
(SAMPLES_PER_AUDIO_PACKET + 1) / 2;
static const int CONTINUOUS_PLAY_INTERVAL_MINUTES = 8;
private:
void ClearParam();
void ExecCommand(SpeakerCommand command);
bool IsAllSampleZero(const s16* pRmtSamples);
void NotifyCallback(s32 chan, s32 result);
static void SpeakerOnCallback(s32 chan, s32 result);
static void SpeakerPlayCallback(s32 chan, s32 result);
static void SpeakerOffCallback(s32 chan, s32 result);
static void ContinueAlarmHandler(OSAlarm* pAlarm, OSContext* pCtx);
static void IntervalAlarmHandler(OSAlarm* pAlarm, OSContext* pCtx);
private:
bool mInitFlag; // at 0x0
bool mPlayFlag; // at 0x1
bool mEnableFlag; // at 0x2
bool mFirstEncodeFlag; // at 0x3
bool mValidCallbackFlag; // at 0x4
bool mCommandBusyFlag; // at 0x5
bool mForceResumeFlag; // at 0x6
bool mContinueFlag; // at 0x7
volatile bool mIntervalFlag; // at 0x8
SpeakerState mState; // at 0xC
SpeakerCommand mUserCommand; // at 0x10
SpeakerCommand mInternalCommand; // at 0x14
WENCInfo mEncodeInfo; // at 0x18
int mChannelIndex; // at 0x38
WPADCallback mWpadCallback; // at 0x3C
OSAlarm mContinueAlarm; // at 0x40
OSAlarm mIntervalAlarm; // at 0x70
s64 mContinueBeginTime; // at 0xA0
};
} // namespace snd
} // namespace nw4r
+40 -30
View File
@@ -1,34 +1,44 @@
#ifndef NW4R_SND_REMOTE_SPEAKER_MANAGER_H
#define NW4R_SND_REMOTE_SPEAKER_MANAGER_H
#include <OSAlarm.h>
#include "snd_RemoteSpeaker.h"
#include <nw4r/types_nw4r.h>
namespace nw4r
{
namespace snd
{
namespace detail
{
struct RemoteSpeakerManager
{
bool mPoweredFlag; // at 0x0
char UNK_0x4[4];
OSAlarm mAlarm; // at 0x8
RemoteSpeaker mRemoteSpeakers[4];
RemoteSpeakerManager(); //inlined
static RemoteSpeakerManager * GetInstance();
RemoteSpeaker * GetRemoteSpeaker(int);
void Setup();
void Shutdown();
static void RemoteSpeakerAlarmProc(OSAlarm *, OSContext *);
};
}
}
}
#include <nw4r/snd/snd_RemoteSpeaker.h>
#endif
#include <rvl/OS.h>
#include <rvl/WPAD.h>
namespace nw4r {
namespace snd {
namespace detail {
class RemoteSpeakerManager {
public:
static RemoteSpeakerManager& GetInstance();
RemoteSpeaker& GetRemoteSpeaker(int i);
void Setup();
void Shutdown();
private:
static const int SPEAKER_ALARM_HZ = 150;
static const int SPEAKER_ALARM_PERIOD_NSEC =
static_cast<int>(1.0f / SPEAKER_ALARM_HZ * 1000 * 1000 * 1000);
private:
RemoteSpeakerManager();
static void RemoteSpeakerAlarmProc(OSAlarm* pAlarm, OSContext* pCtx);
private:
bool mInitialized; // at 0x0
OSAlarm mRemoteSpeakerAlarm; // at 0x8
RemoteSpeaker mSpeaker[WPAD_MAX_CONTROLLERS]; // at 0x38
};
} // namespace detail
} // namespace snd
} // namespace nw4r
#endif
+34 -17
View File
@@ -1,29 +1,46 @@
#ifndef NW4R_SND_SEQ_FILE_H
#define NW4R_SND_SEQ_FILE_H
#include "common.h"
#include "ut_binaryFileFormat.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/ut.h>
namespace nw4r {
namespace snd {
namespace detail {
struct SeqFile {
ut::BinaryFileHeader mHeader; // at 0x0
u32 OFFSET_0x10; // at 0x10
namespace SeqFile {
struct Header {
ut::BinaryFileHeader fileHeader; // at 0x0
u32 dataBlockOffset; // at 0x10
u32 dataBlockSize; // at 0x14
u32 labelBlockOffset; // at 0x18
u32 labelBlockSize; // at 0x1C
};
struct SeqFileReader {
struct UNKBLOCK {
ut::BinaryBlockHeader mHeader; // at 0x0
u32 OFFSET_0x8;
};
const SeqFile *mFile; // at 0x0
const UNKBLOCK *PTR_0x4;
bool IsValidFileHeader(const void *);
SeqFileReader(const void *);
const void *GetBaseAddress() const;
struct DataBlock {
ut::BinaryBlockHeader blockHeader; // at 0x0
u32 baseOffset; // at 0x8
};
} // namespace SeqFile
class SeqFileReader {
public:
static const u32 SIGNATURE = 'RSEQ';
static const int VERSION = NW4R_VERSION(1, 0);
public:
explicit SeqFileReader(const void* pSeqBin);
bool IsValidFileHeader(const void* pSeqBin);
const void* GetBaseAddress() const;
private:
const SeqFile::Header* mHeader; // at 0x0
const SeqFile::DataBlock* mDataBlock; // at 0x4
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+154 -82
View File
@@ -1,119 +1,191 @@
#ifndef NW4R_SND_SEQ_PLAYER_H
#define NW4R_SND_SEQ_PLAYER_H
#include "common.h"
#include "snd_BasicPlayer.h"
#include "snd_DisposeCallback.h"
#include "snd_InstancePool.h"
#include "snd_NoteOn.h"
#include "snd_SoundThread.h"
#include "ut_lock.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_BasicPlayer.h>
#include <nw4r/snd/snd_DisposeCallback.h>
#include <nw4r/snd/snd_SoundThread.h>
#include <nw4r/ut.h>
namespace nw4r {
namespace snd {
namespace detail {
// Used an anonymous enum instead of a macro
// because I wanted the magic number to have
// namespace scope
enum { SEQ_TRACKS_PER_PLAYER = 0x10, SEQ_VARIABLE_COUNT = 0x10 };
// sizeof(SeqPlayer) = 0x11C
struct SeqPlayer : BasicPlayer, DisposeCallback, SoundThread::PlayerCallback {
enum OffsetType { OFFSET_TYPE_0, OFFSET_TYPE_1 };
// Forward declarations
class Channel;
class NoteOnInfo;
class NoteOnCallback;
class SeqTrack;
class SeqTrackAllocator;
bool Start(); // at 0xc
void Stop(); // at 0x10
void Pause(bool); // at 0x14
bool IsActive() const; // at 0x18
bool IsStarted() const; // at 0x1c
bool IsPause() const; // at 0x20
class SeqPlayer : public BasicPlayer,
public DisposeCallback,
public SoundThread::PlayerCallback {
public:
struct ParserPlayerParam {
u8 volume; // at 0x0
u8 priority; // at 0x1
u8 timebase; // at 0x2
u16 tempo; // at 0x4
NoteOnCallback* callback; // at 0x8
};
void InvalidateData(const void *, const void *);
inline void InvalidateWaveData(const void *, const void *) {}
inline virtual void ChannelCallback(Channel *) {}
enum OffsetType { OFFSET_TYPE_TICK, OFFSET_TYPE_MILLISEC };
bool mActiveFlag; // at 0x8c
bool mStartedFlag; // at 0x8d
bool mPauseFlag; // at 0x8e
enum SetupResult {
SETUP_SUCCESS,
SETUP_ERR_CANNOT_ALLOCATE_TRACK,
SETUP_ERR_UNKNOWN
};
bool mReleasePriorityFixFlag; // at 0x8f
float FLOAT_0x90;
float mTempoRatio; // at 0x94
float FLOAT_0x98;
int OFFSET_0x9C;
float OFFSET_0xA0;
int INT_0xA4;
char BYTE_0xA8;
u8 mChannelPriority; // at 0xa9
u8 BYTE_0xAA;
u16 SHORT_0xAC;
static const int LOCAL_VARIABLE_NUM = 16;
static const int GLOBAL_VARIABLE_NUM = 16;
static const int VARIABLE_NUM = LOCAL_VARIABLE_NUM + GLOBAL_VARIABLE_NUM;
NoteOnCallback *mNoteOnCallback; // at 0xb0
SeqTrackAllocator *mTrackAllocator; // at 0xb4
SeqTrack *mPlayerTracks[SEQ_TRACKS_PER_PLAYER]; // at 0xb8
volatile s16 mLocalVariables[SEQ_VARIABLE_COUNT]; // at 0xf8
int INT_0x118;
static const int TRACK_NUM = 16;
public:
SeqPlayer();
~SeqPlayer();
virtual ~SeqPlayer(); // at 0x8
UNKTYPE InitParam(int, NoteOnCallback *);
void CloseTrack(int);
void FinishPlayer(); // inlined
virtual bool Start(); // at 0xC
virtual void Stop(); // at 0x10
virtual void Pause(bool flag); // at 0x14
bool Setup(SeqTrackAllocator *, u32, int, NoteOnCallback *);
void SetSeqData(const void *, s32);
void Skip(OffsetType, int);
virtual bool IsActive() const {
return mActiveFlag;
} // at 0x18
void SetTempoRatio(float);
void SetChannelPriority(int);
void SetReleasePriorityFix(bool);
void SetLocalVariable(int, short);
static void InitGlobalVariable(); // inline
static void SetGlobalVariable(int, short);
virtual bool IsStarted() const {
return mStartedFlag;
} // at 0x1C
virtual bool IsPause() const {
return mPauseFlag;
} // at 0x20
virtual void InvalidateData(const void* pStart,
const void* pEnd); // at 0x50
virtual void InvalidateWaveData(const void* /* pStart */,
const void* /* pEnd */) {} // at 0x54
virtual void ChannelCallback(Channel* /* pChannel */) {} // at 0x58
virtual void OnUpdateFrameSoundThread() {
Update();
} // at 0x5C
virtual void OnShutdownSoundThread() {
Stop();
} // at 0x60
void InitParam(int voices, NoteOnCallback* pCallback);
SetupResult Setup(SeqTrackAllocator* pAllocator, u32 allocTrackFlags,
int voices, NoteOnCallback* pCallback);
void SetSeqData(const void* pBase, s32 offset);
void Skip(OffsetType type, int offset);
void SetTempoRatio(f32 tempo);
void SetChannelPriority(int priority);
void SetReleasePriorityFix(bool flag);
void SetLocalVariable(int i, s16 value);
static void SetGlobalVariable(int i, s16 value);
void SetTrackVolume(u32 trackFlags, f32 volume);
void SetTrackPitch(u32 trackFlags, f32 pitch);
SeqTrack* GetPlayerTrack(int i);
volatile s16* GetVariablePtr(int i);
void Update();
Channel* NoteOn(int bankNo, const NoteOnInfo& rInfo);
template <typename T>
inline void SetTrackParam(u32 flags, void (SeqTrack::*pSetter)(T), T param) {
void SetTrackParam(u32 trackFlags, void (SeqTrack::*pSetter)(T), T param) {
ut::AutoInterruptLock lock;
for (int i = 0; i < SEQ_TRACKS_PER_PLAYER && flags; flags >>= 1, i++) {
if (flags & 1) {
SeqTrack *pPlayerTrack = GetPlayerTrack(i);
for (int i = 0; i < TRACK_NUM && trackFlags != 0;
trackFlags >>= 1, i++) {
if (pPlayerTrack) {
(pPlayerTrack->*pSetter)(param);
if (trackFlags & 1) {
SeqTrack* pTrack = GetPlayerTrack(i);
if (pTrack != NULL) {
(pTrack->*pSetter)(param);
}
}
}
}
void SetTrackVolume(u32, float);
void SetTrackPitch(u32, float);
void SetPlayerTrack(int, SeqTrack *); // inlined
SeqTrack *GetPlayerTrack(int);
bool ParseNextTick(bool);
volatile s16 *GetVariablePtr(int);
void UpdateChannelParam(); // inlined
void Update();
void UpdateTick();
void UpdateTick(int);
bool NoteOn(int, const NoteOnInfo &);
inline void OnUpdateFrameSoundThread() {
Update();
bool IsReleasePriorityFix() const {
return mReleasePriorityFixFlag;
}
inline void OnShutdownSoundThread() {
Stop();
f32 GetPanRange() const {
return mPanRange;
}
inline float GetBaseTempo() const {
return mTempoRatio * (BYTE_0xAA * SHORT_0xAC) / 60000.0f;
f32 GetBaseTempo() const {
return mTempoRatio * (mParserParam.timebase * mParserParam.tempo) /
60000.0f;
}
static volatile s16 mGlobalVariable[SEQ_VARIABLE_COUNT];
static bool mGobalVariableInitialized; // typo
int GetVoiceOutCount() const {
return mVoiceOutCount;
}
ParserPlayerParam& GetParserPlayerParam() {
return mParserParam;
}
private:
static const int DEFAULT_TEMPO = 120;
static const int DEFAULT_TIMEBASE = 48;
static const int DEFAULT_PRIORITY = 64;
static const int DEFAULT_VARIABLE_VALUE = -1;
static const int MAX_SKIP_TICK_PER_FRAME = 768;
private:
void CloseTrack(int i);
void SetPlayerTrack(int i, SeqTrack* pTrack);
void FinishPlayer();
void UpdateChannelParam();
int ParseNextTick(bool doNoteOn);
void UpdateTick(int msec);
void SkipTick();
static void InitGlobalVariable();
private:
bool mActiveFlag; // at 0x8C
bool mStartedFlag; // at 0x8D
bool mPauseFlag; // at 0x8E
bool mReleasePriorityFixFlag; // at 0x8F
f32 mPanRange; // at 0x90
f32 mTempoRatio; // at 0x94
f32 mTickFraction; // at 0x98
u32 mSkipTickCounter; // at 0x9C
f32 mSkipTimeCounter; // at 0xA0
int mVoiceOutCount; // at 0xA4
ParserPlayerParam mParserParam; // at 0xA8
SeqTrackAllocator* mSeqTrackAllocator; // at 0xB4
SeqTrack* mTracks[TRACK_NUM]; // at 0xB8
volatile s16 mLocalVariable[LOCAL_VARIABLE_NUM]; // at 0xF8
u32 mTickCounter; // at 0x118
static volatile s16 mGlobalVariable[LOCAL_VARIABLE_NUM];
static bool mGobalVariableInitialized; // TYPO
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+105 -70
View File
@@ -1,93 +1,128 @@
#ifndef NW4R_SND_SEQ_SOUND_H
#define NW4R_SND_SEQ_SOUND_H
#include "snd_BasicSound.h"
#include "snd_NoteOn.h"
#include "snd_SeqPlayer.h"
#include "snd_SoundInstanceManager.h"
#include "snd_Task.h"
#include "ut_FileStream.h"
#include <OSMutex.h>#include "common.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_BasicSound.h>
#include <nw4r/snd/snd_SeqPlayer.h>
#include <nw4r/snd/snd_Task.h>
#include <nw4r/ut.h>
#include <rvl/OS.h>
namespace nw4r {
namespace snd {
// Forward declarations
class SeqSoundHandle;
namespace detail {
struct SeqSound : BasicSound {
typedef void (*SeqLoadCallback)(bool, const void *, void *);
// sizeof(SeqLoadTask) = 0x24
struct SeqLoadTask : Task {
ut::FileStream *mFileStream; // at 0x10
void *mData; // at 0x14
int mSize; // at 0x18
SeqLoadCallback mCallback; // at 0x1c
SeqSound *mSound; // at 0x20
// Forward declarations
template <typename T> class SoundInstanceManager;
inline SeqLoadTask() : mFileStream(NULL), mData(NULL), mCallback(NULL), mSound(NULL) {}
class SeqSound : public BasicSound {
friend class SeqSoundHandle;
void Execute();
void Cancel();
void OnCancel();
public:
NW4R_UT_RTTI_DECL(SeqSound);
public:
explicit SeqSound(SoundInstanceManager<SeqSound>* pManager);
virtual void Shutdown(); // at 0x28
virtual bool IsPrepared() const {
return mPreparedFlag;
} // at 0x2C
virtual void SetPlayerPriority(int priority); // at 0x4C
virtual bool IsAttachedTempSpecialHandle(); // at 0x5C
virtual void DetachTempSpecialHandle(); // at 0x60
virtual void InitParam(); // at 0x64
virtual BasicPlayer& GetBasicPlayer() {
return mSeqPlayer;
} // at 0x68
virtual const BasicPlayer& GetBasicPlayer() const {
return mSeqPlayer;
} // at 0x6C
SeqPlayer::SetupResult Setup(SeqTrackAllocator* pAllocator,
u32 allocTrackFlags, int voices,
NoteOnCallback* pCallback);
void Prepare(const void* pBase, s32 seqOffset,
SeqPlayer::OffsetType startType, int startOffset);
void Prepare(ut::FileStream* pStream, s32 seqOffset,
SeqPlayer::OffsetType startType, int startOffset);
void Skip(SeqPlayer::OffsetType offsetType, int offset);
void SetTempoRatio(f32 tempo);
void SetChannelPriority(int priority);
void SetReleasePriorityFix(bool flag);
void SetTrackVolume(u32 trackFlags, f32 volume);
void SetTrackPitch(u32 trackFlags, f32 pitch);
bool WriteVariable(int i, s16 value);
static bool WriteGlobalVariable(int i, s16 value);
void* GetFileStreamBuffer() {
return mFileStreamBuffer;
}
s32 GetFileStreamBufferSize() {
return sizeof(mFileStreamBuffer);
}
private:
typedef void (*SeqLoadCallback)(bool success, const void* pBase,
void* pCallbackArg);
struct SeqLoadTask : public Task {
SeqLoadTask();
virtual void Execute(); // at 0xC
virtual void Cancel(); // at 0x10
virtual void OnCancel(); // at 0x14
ut::FileStream* fileStream; // at 0x10
void* buffer; // at 0x14
int bufferSize; // at 0x18
SeqLoadCallback callback; // at 0x1C
SeqSound* callbackData; // at 0x20
};
static ut::detail::RuntimeTypeInfo typeInfo;
static const int FILE_STREAM_BUFFER_SIZE = 512;
SeqPlayer mPlayer; // at 0xd8
SeqSoundHandle *mTempSpecialHandle; // at 0x1f4
SoundInstanceManager<SeqSound> *mManager; // at 0x1f8
s32 INT_0x1FC;
SeqPlayer::OffsetType mOffsetType; // at 0x200
int mOffset; // at 0x204
bool mLoadingFlag; // at 0x208
volatile bool mPreparedFlag; // at 0x209
ut::FileStream *mFileStream; // at 0x20c
char UNK_0x210[0x200];
SeqLoadTask mLoadTask; // at 0x410
OSMutex MUTEX_0x434; // at 0x434
private:
bool LoadData(SeqLoadCallback pCalllback, void* pCallbackArg);
SeqSound(SoundInstanceManager<SeqSound> *);
UNKTYPE InitParam();
UNKTYPE Setup(SeqTrackAllocator *, u32, int, NoteOnCallback *);
static void NotifyLoadAsyncEndSeqData(bool success, const void* pBase,
void* pCallbackArg);
UNKTYPE Skip(SeqPlayer::OffsetType, int); // inlined
bool LoadData(SeqLoadCallback, void *); // inlined
void Prepare(const void *, s32, SeqPlayer::OffsetType, int);
void Prepare(ut::FileStream *, s32, SeqPlayer::OffsetType, int);
static void NotifyLoadAsyncEndSeqData(bool, const void *, void *);
private:
SeqPlayer mSeqPlayer; // at 0xD8
SeqSoundHandle* mTempSpecialHandle; // at 0x1F4
SoundInstanceManager<SeqSound>* mManager; // at 0x1F8
void Shutdown();
s32 mSeqOffset; // at 0x1FC
SeqPlayer::OffsetType mStartOffsetType; // at 0x200
int mStartOffset; // at 0x204
UNKTYPE SetTempoRatio(float);
UNKTYPE SetChannelPriority(int);
UNKTYPE SetReleasePriorityFix(bool);
bool mLoadingFlag; // at 0x208
volatile bool mPreparedFlag; // at 0x209
UNKTYPE SetPlayerPriority(int);
ut::FileStream* mFileStream; // at 0x20C
char mFileStreamBuffer[FILE_STREAM_BUFFER_SIZE]; // at 0x210
UNKTYPE SetTrackVolume(u32, float);
UNKTYPE SetTrackPitch(u32, float);
bool WriteVariable(int, short);
static bool WriteGlobalVariable(int, short);
bool IsAttachedTempSpecialHandle();
UNKTYPE DetachTempSpecialHandle();
inline const BasicPlayer *GetBasicPlayer() const {
return &mPlayer;
}
inline BasicPlayer *GetBasicPlayer() {
return &mPlayer;
}
inline bool IsPrepared() const {
return mPreparedFlag;
}
inline const ut::detail::RuntimeTypeInfo *GetRuntimeTypeInfo() const {
return &typeInfo;
}
SeqLoadTask mSeqLoadTask; // at 0x410
mutable OSMutex mMutex; // at 0x434
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+40 -6
View File
@@ -1,18 +1,52 @@
#ifndef NW4R_SND_SEQ_SOUND_HANDLE_H
#define NW4R_SND_SEQ_SOUND_HANDLE_H
#include "common.h"
#include "snd_SoundHandle.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_SeqSound.h>
#include <nw4r/ut.h>
namespace nw4r {
namespace snd {
using namespace detail;
struct SeqSoundHandle {
detail::SeqSound *mSound; // at 0x0
// Forward declarations
class SoundHandle;
class SeqSoundHandle : private ut::NonCopyable {
public:
explicit SeqSoundHandle(SoundHandle* pHandle);
~SeqSoundHandle() {
DetachSound();
}
bool IsAttachedSound() const {
return mSound != NULL;
}
SeqSoundHandle(SoundHandle *);
void DetachSound();
void SetTempoRatio(f32 tempo) {
if (IsAttachedSound()) {
mSound->SetTempoRatio(tempo);
}
}
void SetTrackVolume(u32 trackFlags, f32 volume) {
if (IsAttachedSound()) {
mSound->SetTrackVolume(trackFlags, volume);
}
}
void WriteVariable(int i, s16 value) {
if (IsAttachedSound()) {
mSound->WriteVariable(i, value);
}
}
private:
detail::SeqSound* mSound; // at 0x0
};
} // namespace snd
} // namespace nw4r
+122 -78
View File
@@ -1,117 +1,161 @@
#ifndef NW4R_SND_SEQ_TRACK_H
#define NW4R_SND_SEQ_TRACK_H
#include "common.h"
#include "snd_Channel.h"
#include "snd_Lfo.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_Channel.h>
#include <nw4r/snd/snd_Lfo.h>
#include <rvl/WPAD.h>
namespace nw4r {
namespace snd {
enum SeqMute { SEQ_MUTE_0, SEQ_MUTE_1, SEQ_MUTE_2, SEQ_MUTE_3 };
enum SeqMute { MUTE_OFF, MUTE_NO_STOP, MUTE_RELEASE, MUTE_STOP };
enum ParseResult { PARSE_RESULT_CONTINUE, PARSE_RESULT_FINISH };
namespace detail {
struct SeqTrack {
virtual ~SeqTrack();
virtual UNKWORD Parse(bool) = 0;
u8 mPlayerTrackNo; // at 0x4
bool mOpenFlag; // at 0x5
class SeqTrack {
public:
static const int VARIABLE_NUM = 16;
static const int PRGNO_MAX = 0xFFFF;
float mVolume; // at 0x8
float mPitch; // at 0xc
float FLOAT_0x10;
float FLOAT_0x14;
float FLOAT_0x18;
float FLOAT_0x1C;
float FLOAT_0x20;
float FLOATS_0x24[3];
float FLOATS_0x30[4];
float FLOATS_0x40[4];
struct ParserTrackParam {
const u8* baseAddr; // at 0x0
const u8* currentAddr; // at 0x4
s32 wait; // at 0x8
const u8 *PTR_0x50;
const u8 *PTR_0x54;
bool muteFlag; // at 0xC
bool silenceFlag; // at 0xD
bool noteFinishWait; // at 0xE
bool portaFlag; // at 0xF
bool damperFlag; // at 0x10
int TIMER_0x58;
int bankNo; // at 0x14
int prgNo; // at 0x18
bool BOOL_0x5C;
char BYTE_0x5D;
bool BOOL_0x5E;
bool BOOL_0x5F;
bool BOOL_0x60;
LfoParam lfoParam; // at 0x1C
int INT_0x64;
UNKWORD WORD_0x68;
u8 lfoTarget; // at 0x2C
f32 sweepPitch; // at 0x30
LfoParam mLfoParam; // at 0x6c
u8 volume; // at 0x34
u8 volume2; // at 0x35
u8 BYTE_0x7C;
float FLOAT_0x80;
u8 BYTE_0x84;
u8 BYTE_0x85;
s8 BYTE_0x86;
u8 BYTE_0x87;
s8 BYTE_0x88;
s8 BYTE_0x89;
s8 BYTE_0x8A;
char BYTE_0x8B;
u8 BYTE_0x8C;
char BYTE_0x8D;
u8 BYTE_0x8E;
s8 pitchBend; // at 0x36
u8 bendRange; // at 0x37
u8 mAttack; // at 0x8f
u8 mDecay; // at 0x90
u8 mSustain; // at 0x91
u8 mRelease; // at 0x92
s8 pan; // at 0x38
s8 initPan; // at 0x39
s8 surroundPan; // at 0x3A
u8 BYTE_0x93;
u8 BYTES_0x94[3];
char BYTE_0x97;
s8 transpose; // at 0x3B
u8 priority; // at 0x3C
s16 mVariables[0x10]; // at 0x98
u8 portaKey; // at 0x3D
u8 portaTime; // at 0x3E
SeqPlayer *mPlayer; // at 0xb8
Channel *mChannel; // at 0xbc
u8 attack; // at 0x3F
u8 decay; // at 0x40
u8 sustain; // at 0x41
u8 release; // at 0x42
void SetPlayerTrackNo(int);
u8 mainSend; // at 0x43
u8 fxSend[AUX_BUS_NUM]; // at 0x44
u8 lpfFreq; // at 0x47
};
public:
SeqTrack();
virtual ~SeqTrack(); // at 0x8
UNKTYPE InitParam();
virtual ParseResult Parse(bool doNoteOn) = 0; // at 0xC
void SetSeqData(const void *, s32);
bool IsOpened() const {
return mOpenFlag;
}
void SetPlayerTrackNo(int no);
u8 GetPlayerTrackNo() const {
return mPlayerTrackNo;
}
void InitParam();
void SetSeqData(const void* pBase, s32 offset);
void Open();
void Close();
void UpdateChannelRelease(Channel *); // inlined
void UpdateChannelLength();
UNKWORD ParseNextTick(bool);
void ReleaseAllChannel(int);
UNKTYPE PauseAllChannel(bool);
void UpdateChannelRelease(Channel* pChannel);
int ParseNextTick(bool doNoteOn);
void StopAllChannel();
void ReleaseAllChannel(int release);
void PauseAllChannel(bool flag);
void AddChannel(Channel* pChannel);
void UpdateChannelParam();
UNKTYPE FreeAllChannel();
void FreeAllChannel();
static void ChannelCallbackFunc(Channel *, Channel::ChannelCallbackStatus, u32);
void SetMute(SeqMute mute);
void SetVolume(f32 volume);
void SetPitch(f32 pitch);
void StopAllChannel(); // inlined
void SetMute(SeqMute);
void SetVolume(float);
void SetPitch(float);
s16 *GetVariablePtr(int);
void AddChannel(Channel *); // inlined
Channel *NoteOn(int, int, s32, bool);
inline bool IsOpened() const {
return mOpenFlag;
ParserTrackParam& GetParserTrackParam() {
return mParserTrackParam;
}
volatile s16* GetVariablePtr(int i);
SeqPlayer* GetSeqPlayer() {
return mPlayer;
}
void SetSeqPlayer(SeqPlayer* pPlayer) {
mPlayer = pPlayer;
}
Channel* GetLastChannel() const {
return mChannelList;
}
Channel* NoteOn(int key, int velocity, s32 length, bool tie);
private:
static const int DEFAULT_PRIORITY = 64;
static const int DEFAULT_BENDRANGE = 2;
static const int DEFAULT_PORTA_KEY = 60;
static const int DEFAULT_VARIABLE_VALUE = -1;
private:
static void ChannelCallbackFunc(Channel* pDropChannel,
Channel::ChannelCallbackStatus status,
u32 callbackArg);
private:
u8 mPlayerTrackNo; // at 0x4
bool mOpenFlag; // at 0x5
f32 mExtVolume; // at 0x8
f32 mExtPitch; // at 0xC
f32 mExtPan; // at 0x10
f32 mExtSurroundPan; // at 0x14
f32 mPanRange; // at 0x18
f32 mExtLpfFreq; // at 0x1C
f32 mExtMainSend; // at 0x20
f32 mExtFxSend[AUX_BUS_NUM]; // at 0x24
f32 mExtRemoteSend[WPAD_MAX_CONTROLLERS]; // at 0x30
f32 mExtRemoteFxSend[WPAD_MAX_CONTROLLERS]; // at 0x40
ParserTrackParam mParserTrackParam; // at 0x50
volatile s16 mTrackVariable[VARIABLE_NUM]; // at 0x98
SeqPlayer* mPlayer; // at 0xB8
Channel* mChannelList; // at 0xBC
};
struct SeqTrackAllocator {
inline virtual ~SeqTrackAllocator() {}
virtual SeqTrack *AllocTrack(SeqPlayer *) = 0;
virtual void FreeTrack(SeqTrack *) = 0;
virtual int GetAllocatableTrackCount() const = 0;
};
} // namespace detail
} // namespace snd
} // namespace nw4r
#endif
+26
View File
@@ -0,0 +1,26 @@
#ifndef NW4R_SND_SEQ_TRACK_ALLOCATOR_H
#define NW4R_SND_SEQ_TRACK_ALLOCATOR_H
#include <nw4r/types_nw4r.h>
namespace nw4r {
namespace snd {
namespace detail {
// Forward declarations
class SeqPlayer;
class SeqTrack;
class SeqTrackAllocator {
public:
virtual ~SeqTrackAllocator() {} // at 0x8
virtual SeqTrack* AllocTrack(SeqPlayer* pPlayer) = 0; // at 0xC
virtual void FreeTrack(SeqTrack* pTrack) = 0; // at 0x10
virtual int GetAllocatableTrackCount() const = 0; // at 0x14
};
} // namespace detail
} // namespace snd
} // namespace nw4r
#endif
+38 -34
View File
@@ -1,40 +1,44 @@
#ifndef NW4R_SND_SOUND_3D_ACTOR_H
#define NW4R_SND_SOUND_3D_ACTOR_H
#include "snd_BasicSound.h"
#include "snd_SoundActor.h"
#include "nw4r/math/math_types.h"
#include <nw4r/types_nw4r.h>
namespace nw4r
{
namespace snd
{
struct Sound3DActor :
detail::SoundActor,
detail::BasicSound::AmbientArgUpdateCallback
{
Sound3DManager & mManager; // at 0xac
SoundArchivePlayer & mArchivePlayer; // at 0xb0
UNKWORD WORD_0xB4;
math::VEC3 mPosition; // at 0xb8
Sound3DActor(SoundArchivePlayer &, Sound3DManager &);
~Sound3DActor();
UNKWORD detail_SetupSound(SoundHandle *,
u32,
detail::BasicSound::AmbientArgInfo *,
detail::ExternalSoundPlayer *,
bool,
const SoundStartable::StartInfo *);
void SetPosition(const math::VEC3 &);
void detail_Update(void *, const detail::BasicSound *);
#include <nw4r/snd/snd_BasicSound.h>
#include <nw4r/snd/snd_SoundActor.h>
static void ClearUpdateCallback(SoundHandle& handle);
};
}
}
#include <nw4r/math.h>
namespace nw4r {
namespace snd {
class Sound3DActor : public detail::SoundActor,
public detail::BasicSound::AmbientArgUpdateCallback {
public:
Sound3DActor(SoundArchivePlayer& rPlayer, Sound3DManager& rManager);
virtual ~Sound3DActor(); // at 0x8
virtual StartResult
detail_SetupSound(SoundHandle* pHandle, u32 id,
detail::BasicSound::AmbientArgInfo* pArgInfo,
detail::ExternalSoundPlayer* pPlayer, bool hold,
const StartInfo* pStartInfo); // at 0xC
virtual void detail_Update(void* pArg,
const detail::BasicSound* pSound); // at 0xC
void SetPosition(const math::VEC3& rPosition);
private:
static void ClearUpdateCallback(SoundHandle& rHandle);
private:
Sound3DManager& m3DManager; // at 0xAC
SoundArchivePlayer& mSoundArchivePlayer; // at 0xB0
u32 mUserParam; // at 0xB4
math::VEC3 mPosition; // at 0xB8
};
} // namespace snd
} // namespace nw4r
#endif
+37 -8
View File
@@ -1,19 +1,48 @@
#ifndef NW4R_SND_SOUND_3D_LISTENER_H
#define NW4R_SND_SOUND_3D_LISTENER_H
#include "common.h"
#include "nw4r/math/math_types.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/math.h>
namespace nw4r {
namespace snd {
struct Sound3DListener {
math::MTX34 mMatrix; // at 0x0
float mInteriorSize; // at 0x30
float mMaxVolumeDistance; // at 0x34
float mUnitDistance; // at 0x38
class Sound3DListener {
public:
Sound3DListener();
const math::MTX34& GetMatrix() const {
return mMtx;
}
f32 GetInteriorSize() const {
return mInteriorSize;
}
void SetInteriorSize(f32 size) {
mInteriorSize = size;
}
f32 GetMaxVolumeDistance() const {
return mMaxVolumeDistance;
}
void SetMaxVolumeDistance(f32 distance) {
mMaxVolumeDistance = distance;
}
f32 GetUnitDistance() const {
return mUnitDistance;
}
void SetUnitDistance(f32 distance) {
mUnitDistance = distance;
}
private:
math::MTX34 mMtx; // at 0x0
f32 mInteriorSize; // at 0x30
f32 mMaxVolumeDistance; // at 0x34
f32 mUnitDistance; // at 0x38
};
} // namespace snd
} // namespace nw4r
+78 -48
View File
@@ -1,53 +1,83 @@
#ifndef NW4R_SND_SOUND_3D_MANAGER_H
#define NW4R_SND_SOUND_3D_MANAGER_H
#include "snd_BasicSound.h"
#include "snd_SoundArchive.h"
#include "snd_SoundActor.h"
#include "snd_InstancePool.h"
#include "nw4r/math/math_types.h"
#include <nw4r/types_nw4r.h>
namespace nw4r
{
namespace snd
{
struct Sound3DManager :
detail::BasicSound::AmbientParamUpdateCallback,
detail::BasicSound::AmbientArgAllocaterCallback
{
struct Sound3DActorParam
{
u32 WORD_0x0;
SoundArchive::Sound3DParam mSound3DParam; // at 0x4
math::VEC3 mPosition; // at 0xc
Sound3DActorParam();
};
detail::InstancePool<Sound3DActorParam> mPool; // at 0x8
Sound3DListener * mListener; // at 0xc
int INT_0x10;
float FLOAT_0x14;
float FLOAT_0x18;
float FLOAT_0x1C;
float FLOAT_0x20;
float FLOAT_0x24;
Sound3DManager();
u32 GetRequiredMemSize(const SoundArchive *);
bool Setup(const SoundArchive *, void *, u32);
void detail_Update(SoundParam *, u32, detail::BasicSound *, const void *, u32);
virtual void Update(SoundParam *, u32, SoundHandle *, const void *, u32);
void * detail_AllocAmbientArg(u32);
void detail_FreeAmbientArg(void *, const detail::BasicSound *);
};
}
}
#include <nw4r/snd/snd_BasicSound.h>
#include <nw4r/snd/snd_InstancePool.h>
#include <nw4r/snd/snd_SoundArchive.h>
#include <nw4r/math.h>
namespace nw4r {
namespace snd {
class Sound3DManager : public detail::BasicSound::AmbientParamUpdateCallback,
public detail::BasicSound::AmbientArgAllocaterCallback {
public:
struct Sound3DActorParam {
u32 userParam; // at 0x0
SoundArchive::Sound3DParam soundParam; // at 0x4
math::VEC3 position; // at 0xC
Sound3DActorParam();
};
public:
Sound3DManager();
virtual void detail_Update(SoundParam* pParam, u32 id,
detail::BasicSound* pSound, const void* pArg,
u32 flags); // at 0x8
virtual void Update(SoundParam* pParam, u32 id, SoundHandle* pHandle,
const void* pArg,
u32 flags); // at 0x10
virtual void* detail_AllocAmbientArg(u32 size); // at 0x14
virtual void
detail_FreeAmbientArg(void* pArg,
const detail::BasicSound* pSound); // at 0x18
u32 GetRequiredMemSize(const SoundArchive* pArchive);
bool Setup(const SoundArchive* pArchive, void* pBuffer, u32 size);
Sound3DListener* GetListener() const {
return mListener;
}
int GetMaxPriorityReduction() const {
return mMaxPriorityReduction;
}
void SetMaxPriorityReduction(int max) {
mMaxPriorityReduction = max;
}
f32 GetPanRange() const {
return mPanRange;
}
private:
enum ParamDecayCurve {
DECAY_CURVE_NONE,
DECAY_CURVE_LOGARITHMIC,
DECAY_CURVE_LINEAR,
};
private:
detail::InstancePool<Sound3DActorParam> mParamPool; // at 0x8
Sound3DListener* mListener; // at 0xC
s32 mMaxPriorityReduction; // at 0x10
f32 mSpeakerAngleStereo; // at 0x14
f32 mFrontSpeakerAngleDpl2; // at 0x18
f32 mRearSpeakerAngleDpl2; // at 0x1C
f32 mInitPan; // at 0x20
f32 mPanRange; // at 0x24
};
} // namespace snd
} // namespace nw4r
#endif
+54 -47
View File
@@ -1,56 +1,63 @@
#ifndef NW4R_SND_SOUND_ACTOR_H
#define NW4R_SND_SOUND_ACTOR_H
#include "snd_SoundStartable.h"
#include "snd_ExternalSoundPlayer.h"
#include <nw4r/types_nw4r.h>
namespace nw4r
{
namespace snd
{
namespace detail
{
enum
{
SOUND_PLAYERS_PER_ACTOR = 8
};
struct SoundActor : SoundStartable
{
SoundStartable & mStartable; // at 0x4
ExternalSoundPlayer mPlayers[SOUND_PLAYERS_PER_ACTOR]; // at 0x8
#include <nw4r/snd/snd_ExternalSoundPlayer.h>
#include <nw4r/snd/snd_SoundStartable.h>
inline SoundActor(SoundStartable & startable) : mStartable(startable)
{
mPlayers[0].SetPlayableSoundCount(0x7FFFFFFF);
}
inline UNKWORD detail_ConvertLabelStringToSoundId(const char * labelString)
{
return mStartable.detail_ConvertLabelStringToSoundId(labelString);
}
#include <climits>
template <typename TForEachFunc>
TForEachFunc ForEachSound(TForEachFunc func, bool reverse) {
int i;
ExternalSoundPlayer* player = mPlayers;
namespace nw4r {
namespace snd {
namespace detail {
for (i = 0; i < SOUND_PLAYERS_PER_ACTOR; i++) {
player->ForEachSound(func, reverse);
player++;
}
class SoundActor : public SoundStartable {
public:
explicit SoundActor(SoundStartable& rStartable) : mStartable(rStartable) {
detail_GetActorSoundPlayer(0)->SetPlayableSoundCount(INT_MAX);
}
return func;
}
virtual StartResult
detail_SetupSound(SoundHandle* pHandle, u32 id,
detail::BasicSound::AmbientArgInfo* pArgInfo,
detail::ExternalSoundPlayer* pPlayer, bool hold,
const StartInfo* pStartInfo); // at 0xC
virtual UNKWORD detail_SetupSound(SoundHandle *,
u32,
detail::BasicSound::AmbientArgInfo *,
detail::ExternalSoundPlayer *,
bool,
const StartInfo *);
};
}
}
}
virtual u32 detail_ConvertLabelStringToSoundId(const char* pLabel) {
return mStartable.detail_ConvertLabelStringToSoundId(pLabel);
} // at 0x10
#endif
ExternalSoundPlayer* detail_GetActorSoundPlayer(int i) {
if (i < 0 || i >= ACTOR_PLAYER_COUNT) {
return NULL;
}
return &mActorPlayer[i];
}
template <typename TForEachFunc>
TForEachFunc ForEachSound(TForEachFunc pFunction, bool reverse) {
int i;
ExternalSoundPlayer* pPlayer = detail_GetActorSoundPlayer(0);
for (i = 0; i < ACTOR_PLAYER_COUNT; i++) {
pPlayer->ForEachSound(pFunction, reverse);
pPlayer++;
}
return pFunction;
}
private:
static const int ACTOR_PLAYER_COUNT = 8;
private:
SoundStartable& mStartable; // at 0x4
ExternalSoundPlayer mActorPlayer[ACTOR_PLAYER_COUNT]; // at 0x8
};
} // namespace detail
} // namespace snd
} // namespace nw4r
#endif
+117 -86
View File
@@ -1,146 +1,177 @@
#ifndef NW4R_SND_SOUND_ARCHIVE_H
#define NW4R_SND_SOUND_ARCHIVE_H
#include "common.h"
#include "ut_FileStream.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_Common.h>
#include <nw4r/ut.h>
namespace nw4r {
namespace snd {
struct SoundArchive {
struct Sound3DParam {
UNKWORD WORD_0x0;
u8 BYTE_0x4;
u8 BYTE_0x5;
};
struct SoundArchivePlayerInfo {
u32 SIZE_0x0;
UNKWORD WORD_0x4;
u32 SIZE_0x8;
UNKWORD WORD_0xC;
UNKWORD WORD_0x10;
u32 SIZE_0x14;
UNKWORD WORD_0x18;
};
enum SoundType {
SOUND_TYPE_INVALID,
SOUND_TYPE_SEQ,
SOUND_TYPE_STRM,
SOUND_TYPE_WAVE
};
class SoundArchive {
public:
struct SoundInfo {
UNKWORD WORD_0x0;
UNKWORD WORD_0x4;
UNKWORD WORD_0x8;
UNKWORD WORD_0xC;
UNKWORD WORD_0x10;
UNKWORD WORD_0x14;
UNKWORD WORD_0x18;
u32 fileId; // at 0x0
u32 playerId; // at 0x4
int playerPriority; // at 0x8
int volume; // at 0xC
int remoteFilter; // at 0x10
detail::PanMode panMode; // at 0x14
detail::PanCurve panCurve; // at 0x18
};
struct SeqSoundInfo {
UNKWORD WORD_0x0;
UNKWORD WORD_0x4;
UNKWORD WORD_0x8;
UNKWORD WORD_0xC;
bool BOOL_0x10;
u32 dataOffset; // at 0x0
u32 bankId; // at 0x4
u32 allocTrack; // at 0x8
int channelPriority; // at 0xC
bool releasePriorityFixFlag; // at 0x10
};
struct StrmSoundInfo {};
struct WaveSoundInfo {
UNKWORD WORD_0x0;
UNKWORD WORD_0x4;
bool BOOL_0x8;
int subNo; // at 0x0
int channelPriority; // at 0x4
bool releasePriorityFixFlag; // at 0x8
};
struct Sound3DParam {
u32 flags; // at 0x0
u8 decayCurve; // at 0x4
u8 decayRatio; // at 0x5
};
struct BankInfo {
UNKWORD WORD_0x0;
u32 fileId; // at 0x0
};
struct PlayerInfo {
UNKWORD WORD_0x0;
UNKWORD WORD_0x4;
int playableSoundCount; // at 0x0
u32 heapSize; // at 0x4
};
struct GroupInfo {
u32 mCount; // at 0x0
const char *mExternalFileName; // at 0x4
u32 INT_0x8;
u32 INT_0xC;
u32 INT_0x10;
u32 INT_0x14;
u32 itemCount; // at 0x0
const char* extFilePath; // at 0x4
u32 offset; // at 0x8
u32 size; // at 0xC
u32 waveDataOffset; // at 0x10
u32 waveDataSize; // at 0x14
};
struct GroupItemInfo {
UNKWORD WORD_0x0;
u32 INT_0x4;
u32 INT_0x8;
u32 INT_0xC;
UNKWORD WORD_0x10;
u32 fileId; // at 0x0
u32 offset; // at 0x4
u32 size; // at 0x8
u32 waveDataOffset; // at 0xC
u32 waveDataSize; // at 0x10
};
struct FileInfo {
UNKWORD WORD_0x0;
UNKWORD WORD_0x4;
const char *mExternalFileName; // at 0x8
u32 SIZE_0xC;
u32 fileSize; // at 0x0
u32 waveDataFileSize; // at 0x4
const char* extFilePath; // at 0x8
u32 filePosCount; // at 0xC
};
struct FilePos {
u32 mGroupIndex; // at 0x0
u32 mGroupItemIndex; // at 0x4
u32 groupId; // at 0x0
u32 index; // at 0x4
};
virtual ~SoundArchive(); // at 0x8
virtual const void *detail_GetFileAddress(u32) const = 0; // at 0xc
virtual const void *detail_GetWaveDataFileAddress(u32) const = 0; // at 0x10
virtual int detail_GetRequiredStreamBufferSize() const = 0; // at 0x14
virtual ut::FileStream *OpenStream(void *, int, u32, u32) const = 0; // at 0x18
virtual ut::FileStream *OpenExtStream(void *, int, const char *, u32, u32) const = 0; // at 0x1c
struct SoundArchivePlayerInfo {
int seqSoundCount; // at 0x0
int seqTrackCount; // at 0x4
int strmSoundCount; // at 0x8
int strmTrackCount; // at 0xC
int strmChannelCount; // at 0x10
int waveSoundCount; // at 0x14
int waveTrackCount; // at 0x18
};
detail::SoundArchiveFileReader *mFileReader; // at 0x4
char mExternalFileRoot[0x100]; // at 0x8
static const u32 INVALID_ID = 0xFFFFFFFF;
public:
SoundArchive();
virtual ~SoundArchive(); // at 0x8
virtual const void* detail_GetFileAddress(u32 id) const = 0; // at 0xC
virtual const void*
detail_GetWaveDataFileAddress(u32 id) const = 0; // at 0x10
virtual int detail_GetRequiredStreamBufferSize() const = 0; // at 0x14
virtual ut::FileStream* OpenStream(void* pBuffer, int bufferSize,
u32 offset,
u32 length) const = 0; // at 0x18
virtual ut::FileStream* OpenExtStream(void* pBuffer, int bufferSize,
const char* pExtPath, u32 offset,
u32 length) const = 0; // at 0x1C
bool IsAvailable() const;
void Setup(detail::SoundArchiveFileReader *);
void Setup(detail::SoundArchiveFileReader* pReader);
void Shutdown();
u32 GetPlayerCount() const;
u32 GetGroupCount() const;
const char *GetSoundLabelString(u32) const;
const char* GetSoundLabelString(u32 id) const;
u32 ConvertLabelStringToSoundId(const char* pLabel) const;
u32 ConvertLabelStringToPlayerId(const char* pLabel) const;
u32 ConvertLabelStringToGroupId(const char* pLabel) const;
u32 ConvertLabelStringToSoundId(const char *) const;
u32 ConvertLabelStringToPlayerId(const char *) const;
u32 ConvertLabelStringToGroupId(const char *) const;
u32 GetSoundUserParam(u32 id) const;
SoundType GetSoundType(u32 id) const;
UNKWORD GetSoundUserParam(u32) const;
UNKWORD GetSoundType(u32) const;
bool ReadSoundInfo(u32 id, SoundInfo* pInfo) const;
bool detail_ReadSeqSoundInfo(u32 id, SeqSoundInfo* pInfo) const;
bool detail_ReadStrmSoundInfo(u32 id, StrmSoundInfo* pInfo) const;
bool detail_ReadWaveSoundInfo(u32 id, WaveSoundInfo* pInfo) const;
bool ReadSoundInfo(u32, SoundInfo *) const;
bool ReadPlayerInfo(u32 id, PlayerInfo* pInfo) const;
bool ReadSoundArchivePlayerInfo(SoundArchivePlayerInfo* pInfo) const;
bool detail_ReadSeqSoundInfo(u32, SeqSoundInfo *) const;
bool detail_ReadStrmSoundInfo(u32, StrmSoundInfo *) const;
bool detail_ReadWaveSoundInfo(u32, WaveSoundInfo *) const;
bool detail_ReadSound3DParam(u32 id, Sound3DParam* pParam) const;
bool detail_ReadBankInfo(u32 id, BankInfo* pInfo) const;
bool detail_ReadGroupInfo(u32 id, GroupInfo* pInfo) const;
bool detail_ReadGroupItemInfo(u32 groupId, u32 itemId,
GroupItemInfo* pInfo) const;
bool ReadPlayerInfo(u32, PlayerInfo *) const;
bool detail_ReadFileInfo(u32 id, FileInfo* pInfo) const;
bool detail_ReadFilePos(u32 fileId, u32 posId, FilePos* pPos) const;
bool ReadSoundArchivePlayerInfo(SoundArchivePlayerInfo *) const;
ut::FileStream* detail_OpenFileStream(u32 id, void* pBuffer,
int bufferSize) const;
ut::FileStream* detail_OpenGroupStream(u32 id, void* pBuffer,
int bufferSize) const;
ut::FileStream* detail_OpenGroupWaveDataStream(u32 id, void* pBuffer,
int bufferSize) const;
bool detail_ReadSound3DParam(u32, Sound3DParam *) const;
void SetExternalFileRoot(const char* pExtFileRoot);
bool detail_ReadBankInfo(u32, BankInfo *) const;
bool detail_ReadGroupInfo(u32, GroupInfo *) const;
bool detail_ReadGroupItemInfo(u32, u32, GroupItemInfo *) const;
bool detail_ReadFileInfo(u32, FileInfo *) const;
bool detail_ReadFilePos(u32, u32, FilePos *) const;
protected:
static const int FILE_PATH_MAX = 256;
ut::FileStream *OpenExtStreamImpl(void *, int, const char *, u32, u32) const; // inlined
ut::FileStream *detail_OpenFileStream(u32, void *, int) const;
ut::FileStream *detail_OpenGroupStream(u32, void *, int) const;
ut::FileStream *detail_OpenGroupWaveDataStream(u32, void *, int) const;
private:
ut::FileStream* OpenExtStreamImpl(void* pBuffer, int bufferSize,
const char* pExtPath, u32 offset,
u32 size) const;
UNKTYPE SetExternalFileRoot(const char *);
private:
detail::SoundArchiveFileReader* mFileReader; // at 0x4
char mExtFileRoot[FILE_PATH_MAX]; // at 0x8
};
} // namespace snd
} // namespace nw4r
+234 -177
View File
@@ -1,243 +1,300 @@
#ifndef NW4R_SND_SOUND_ARCHIVE_FILE_H
#define NW4R_SND_SOUND_ARCHIVE_FILE_H
#include "common.h"
#include "snd_SoundArchive.h"
#include "snd_Util.h"
#include "ut_binaryFileFormat.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_SoundArchive.h>
#include <nw4r/snd/snd_Util.h>
#include <nw4r/ut.h>
namespace nw4r {
namespace snd {
namespace detail {
namespace SoundArchiveFile {
struct Header {
ut::BinaryFileHeader mHeader; // at 0x0
u32 mLabelStringChunkOffset; // at 0x10
u32 mLabelStringChunkSize; // at 0x14
u32 mInfoChunkOffset; // at 0x18
u32 mInfoChunkSize; // at 0x1c
UNKWORD UNK_0x20[0x8 / sizeof(UNKWORD)]; // at 0x20
/******************************************************************************
*
* Symbol (SYMB) block
*
******************************************************************************/
struct StringTreeNode {
u16 flags; // at 0x0
u16 bit; // at 0x2
u32 leftIdx; // at 0x4
u32 rightIdx; // at 0x8
u32 strIdx; // at 0xC
u32 id; // at 0x10
};
struct Sound3DParam {
UNKWORD WORD_0x0;
u8 BYTE_0x4;
u8 BYTE_0x5;
struct StringTree {
u32 rootIdx; // at 0x0
Util::Table<StringTreeNode> nodeTable; // at 0x4
};
struct StringTable {
Util::Table<u32> offsetTable; // at 0x0
};
struct StringChunk {
u32 tableOffset; // at 0x0
u32 soundTreeOffset; // at 0x4
u32 playerTreeOffset; // at 0x8
u32 groupTreeOffset; // at 0xC
u32 bankTreeOffset; // at 0x10
};
struct StringBlock {
union {
StringTable stringTable;
StringChunk stringChunk;
}; // at 0x0
};
struct SymbolBlock {
ut::BinaryBlockHeader blockHeader; // at 0x0
StringBlock stringBlock; // at 0x8
};
/******************************************************************************
*
* Info (INFO) block
*
******************************************************************************/
struct SeqSoundInfo {
UNKWORD WORD_0x0;
UNKWORD WORD_0x4;
UNKWORD WORD_0x8;
u8 BYTE_0xC;
u8 BYTE_0xD;
u32 dataOffset; // at 0x0
u32 bankId; // at 0x4
u32 allocTrack; // at 0x8
u8 channelPriority; // at 0xC
u8 releasePriorityFix; // at 0xD
};
struct StrmSoundInfo {};
struct WaveSoundInfo {
UNKWORD WORD_0x0;
char UNK_0x4[0x4];
u8 BYTE_0x8;
u8 BYTE_0x9;
s32 subNo; // at 0x0
u32 allocTrack; // at 0x4
u8 channelPriority; // at 0x8
u8 releasePriorityFix; // at 0x9
};
typedef Util::DataRef<void, SeqSoundInfo, StrmSoundInfo, WaveSoundInfo>
SoundInfoOffset;
typedef Util::DataRef<void, SeqSoundInfo, StrmSoundInfo, WaveSoundInfo> SoundInfoOffset;
struct Sound3DParam {
u32 flags; // at 0x0
u8 decayCurve; // at 0x4
u8 decayRatio; // at 0x5
};
struct SoundCommonInfo {
u32 mSoundStringId; // at 0x0
UNKWORD WORD_0x4;
UNKWORD WORD_0x8;
Util::DataRef<Sound3DParam, void, void, void> mSound3DParam; // at 0xc
u8 BYTE_0x14;
u8 BYTE_0x15;
u8 mType; // at 0x16
u8 BYTE_0x17;
SoundInfoOffset mSoundInfoOffset; // at 0x18
UNKWORD mSoundUserParam; // at 0x20
char UNK_0x24[0x4];
u8 BYTE_0x28;
u8 BYTE_0x29;
u32 stringId; // at 0x0
u32 fileId; // at 0x4
u32 playerId; // at 0x8
Util::DataRef<Sound3DParam> param3dRef; // at 0xC
u8 volume; // at 0x14
u8 playerPriority; // at 0x15
u8 soundType; // at 0x16
u8 remoteFilter; // at 0x17
SoundInfoOffset soundInfoRef; // at 0x18
u32 userParam[2]; // at 0x20
u8 panMode; // at 0x28
u8 panCurve; // at 0x29
};
typedef Util::Table<Util::DataRef<SoundCommonInfo, void, void, void>> SoundCommonTable;
typedef Util::Table<Util::DataRef<SoundCommonInfo> > SoundCommonTable;
struct BankInfo {
char UNK_0x0[0x4];
UNKWORD WORD_0x4;
u32 stringId; // at 0x0
u32 fileId; // at 0x4
};
typedef Util::Table<Util::DataRef<BankInfo, void, void, void>> BankTable;
typedef Util::Table<Util::DataRef<BankInfo> > BankTable;
struct PlayerInfo {
char UNK_0x0[0x4];
u8 BYTE_0x4;
UNKWORD WORD_0x8;
u32 stringId; // at 0x0
u8 playableSoundCount; // at 0x4
u32 heapSize; // at 0x8
};
typedef Util::Table<Util::DataRef<PlayerInfo> > PlayerTable;
typedef Util::Table<Util::DataRef<PlayerInfo, void, void, void>> PlayerTable;
struct GroupItemInfo {
UNKWORD WORD_0x0;
u32 INT_0x4;
u32 INT_0x8;
u32 INT_0xC;
UNKWORD WORD_0x10;
};
typedef Util::Table<Util::DataRef<GroupItemInfo, void, void, void>> GroupItemTable;
struct GroupInfo {
char UNK_0x0[0x8];
Util::DataRef<char, void, void, void> mExternalFileName; // at 0x8
u32 INT_0x10;
u32 INT_0x14;
u32 INT_0x18;
u32 INT_0x1C;
Util::DataRef<GroupItemTable, void, void, void> mGroupItemTable; // at 0x20
};
typedef Util::Table<Util::DataRef<GroupInfo, void, void, void>> GroupTable;
struct SoundArchivePlayerInfo {
u16 SIZE_0x0;
u16 SHORT_0x2;
u16 SIZE_0x4;
u16 SHORT_0x6;
u16 SHORT_0x8;
u16 SIZE_0xA;
u16 SHORT_0xC;
};
typedef Util::Table<Util::DataRef<SoundArchive::FilePos, void, void, void>> FilePosTable;
typedef Util::Table<Util::DataRef<SoundArchive::FilePos> > FilePosTable;
struct FileInfo {
UNKWORD WORD_0x0;
UNKWORD WORD_0x4;
char UNK_0x8[0x4];
Util::DataRef<char, void, void, void> mExternalFileName; // at 0xc
Util::DataRef<FilePosTable, void, void, void> TABLE_0x14;
u32 fileSize; // at 0x0
u32 waveDataSize; // at 0x4
s32 entryNum; // at 0x8
Util::DataRef<char> extFilePathRef; // at 0xC
Util::DataRef<FilePosTable> filePosTableRef; // at 0x14
};
typedef Util::Table<Util::DataRef<FileInfo> > FileTable;
struct GroupItemInfo {
u32 fileId; // at 0x0
u32 offset; // at 0x4
u32 size; // at 0x8
u32 waveDataOffset; // at 0xC
u32 waveDataSize; // at 0x10
};
typedef Util::Table<Util::DataRef<GroupItemInfo> > GroupItemTable;
struct GroupInfo {
u32 stringId; // at 0x0
s32 entryNum; // at 0x4
Util::DataRef<char> extFilePathRef; // at 0x8
u32 offset; // at 0x10
u32 size; // at 0x14
u32 waveDataOffset; // at 0x18
u32 waveDataSize; // at 0x1C
Util::DataRef<GroupItemTable> itemTableRef; // at 0x20
};
typedef Util::Table<Util::DataRef<GroupInfo> > GroupTable;
struct SoundArchivePlayerInfo {
u16 seqSoundCount; // at 0x0
u16 seqTrackCount; // at 0x2
u16 strmSoundCount; // at 0x4
u16 strmTrackCount; // at 0x6
u16 strmChannelCount; // at 0x8
u16 waveSoundCount; // at 0xA
u16 waveTrackCount; // at 0xC
};
typedef Util::Table<Util::DataRef<FileInfo, void, void, void>> FileTable;
struct StringNode {
enum { FLAG_LEAF = 0x0001 };
u16 mFlags; // at 0x0
u16 SHORT_0x2;
u32 mLeftIndex; // at 0x4
u32 mRightIndex; // at 0x8
u32 mStringId; // at 0xc
u32 mId; // at 0x10
struct Info {
Util::DataRef<SoundCommonTable> soundTableRef; // at 0x0
Util::DataRef<BankTable> bankTableRef; // at 0x8
Util::DataRef<PlayerTable> playerTableRef; // at 0x10
Util::DataRef<FileTable> fileTableRef; // at 0x18
Util::DataRef<GroupTable> groupTableRef; // at 0x20
Util::DataRef<SoundArchivePlayerInfo> soundArchivePlayerInfoRef; // at 0x28
};
struct StringTree {
u32 mRootIndex; // at 0x0
u32 INT_0x4;
StringNode mNodes[]; // at 0x8
struct InfoBlock {
ut::BinaryBlockHeader blockHeader; // at 0x0
Info info; // at 0x8
};
struct StringChunk {
u32 mTableOffset; // at 0x0
u32 mSoundTreeOffset; // at 0x4
u32 mPlayerTreeOffset; // at 0x8
u32 mGroupTreeOffset; // at 0xc
u32 OFFSET_0x10;
/******************************************************************************
*
* File header
*
******************************************************************************/
struct Header {
ut::BinaryFileHeader fileHeader; // at 0x0
u32 symbolDataOffset; // at 0x10
u32 symbolDataSize; // at 0x14
u32 infoOffset; // at 0x18
u32 infoSize; // at 0x1C
u32 fileImageOffset; // at 0x20
u32 fileImageSize; // at 0x24
};
struct InfoChunk {
Util::DataRef<SoundCommonTable, void, void, void> mSoundCommonTable; // at 0x0
Util::DataRef<BankTable, void, void, void> mBankTable; // at 0x8
Util::DataRef<PlayerTable, void, void, void> mPlayerTable; // at 0x10
Util::DataRef<FileTable, void, void, void> mFileTable; // at 0x18
Util::DataRef<GroupTable, void, void, void> mGroupTable; // at 0x20
Util::DataRef<SoundArchivePlayerInfo, void, void, void> mSoundArchivePlayerInfo; // at 0x28
};
}; // namespace SoundArchiveFile
// TODO: How is this calculated?
static const int HEADER_AREA_SIZE = ROUND_UP(sizeof(Header), 32) + 40;
struct SoundArchiveFileReader {
struct StringBlock {
ut::BinaryBlockHeader mHeader; // at 0x0
SoundArchiveFile::StringChunk mChunk; // at 0x8
};
} // namespace SoundArchiveFile
struct InfoBlock {
ut::BinaryBlockHeader mHeader; // at 0x0
SoundArchiveFile::InfoChunk mChunk; // at 0x8
};
SoundArchiveFile::Header mHeader; // at 0x0
const SoundArchiveFile::InfoChunk *mInfoChunk; // at 0x28
const SoundArchiveFile::StringChunk *mStringChunk; // at 0x2c
const Util::Table<u32> *mStringTable; // at 0x30
const SoundArchiveFile::StringTree *mSoundStringTree; // at 0x34
const SoundArchiveFile::StringTree *mPlayerStringTree; // at 0x38
const SoundArchiveFile::StringTree *mGroupStringTree; // at 0x3c
const UNKTYPE *PTR_0x40;
class SoundArchiveFileReader {
public:
static const u32 SIGNATURE = 'RSAR';
static const int VERSION = NW4R_VERSION(1, 3);
public:
SoundArchiveFileReader();
bool IsValidFileHeader(const void *); // inlined
void Init(const void *);
void Init(const void* pSoundArchiveBin);
bool IsValidFileHeader(const void* pSoundArchiveBin);
const void *GetPtrConst(const void *, u32) const; // inlined
void SetStringChunk(const void* pChunk, u32 size);
void SetInfoChunk(const void* pChunk, u32 size);
void SetStringChunk(const void *, u32);
void SetInfoChunk(const void *, u32);
UNKWORD GetSoundType(u32) const;
const SoundArchiveFile::SoundCommonInfo *impl_GetSoundInfo(u32) const; // inlined
bool ReadSoundInfo(u32, SoundArchive::SoundInfo *) const;
bool ReadSound3DParam(u32, SoundArchive::Sound3DParam *) const;
bool ReadSeqSoundInfo(u32, SoundArchive::SeqSoundInfo *) const;
bool ReadStrmSoundInfo(u32, SoundArchive::StrmSoundInfo *) const;
bool ReadWaveSoundInfo(u32, SoundArchive::WaveSoundInfo *) const;
const SoundArchiveFile::BankInfo *impl_GetBankInfo(u32) const; // inlined
bool ReadBankInfo(u32, SoundArchive::BankInfo *) const;
const SoundArchiveFile::PlayerInfo *impl_GetPlayerInfo(u32) const; // inlined
bool ReadPlayerInfo(u32, SoundArchive::PlayerInfo *) const;
const SoundArchiveFile::GroupInfo *impl_GetGroupInfo(u32) const; // inlined
bool ReadGroupInfo(u32, SoundArchive::GroupInfo *) const;
bool ReadGroupItemInfo(u32, u32, SoundArchive::GroupItemInfo *) const;
bool ReadSoundArchivePlayerInfo(SoundArchive::SoundArchivePlayerInfo *) const;
SoundType GetSoundType(u32 id) const;
bool ReadSoundInfo(u32 id, SoundArchive::SoundInfo* pInfo) const;
bool ReadSound3DParam(u32 id, SoundArchive::Sound3DParam* pParam) const;
bool ReadSeqSoundInfo(u32 id, SoundArchive::SeqSoundInfo* pInfo) const;
bool ReadStrmSoundInfo(u32 id, SoundArchive::StrmSoundInfo* pInfo) const;
bool ReadWaveSoundInfo(u32 id, SoundArchive::WaveSoundInfo* pInfo) const;
bool ReadBankInfo(u32 id, SoundArchive::BankInfo* pInfo) const;
bool ReadPlayerInfo(u32 id, SoundArchive::PlayerInfo* pInfo) const;
bool ReadGroupInfo(u32 id, SoundArchive::GroupInfo* pInfo) const;
bool ReadGroupItemInfo(u32 groupId, u32 itemId,
SoundArchive::GroupItemInfo* pInfo) const;
bool ReadSoundArchivePlayerInfo(
SoundArchive::SoundArchivePlayerInfo* pInfo) const;
u32 GetSoundStringId(u32 id) const;
u32 GetPlayerCount() const;
u32 GetGroupCount() const;
u32 GetSoundStringId(u32) const; // inlined
const char *GetString(u32) const; // inlined
const char *GetSoundLabelString(u32) const;
UNKWORD GetSoundUserParam(u32) const;
const char* GetSoundLabelString(u32 id) const;
u32 GetSoundUserParam(u32 id) const;
bool ReadFileInfo(u32, SoundArchive::FileInfo *) const;
bool ReadFilePos(u32, u32, SoundArchive::FilePos *) const;
bool ReadFileInfo(u32 id, SoundArchive::FileInfo* pInfo) const;
bool ReadFilePos(u32 fileId, u32 id, SoundArchive::FilePos* pPos) const;
u32 ConvertLabelStringToId(const SoundArchiveFile::StringTree *, const char *) const;
const char* GetString(u32 id) const;
SoundArchiveFile::SoundInfoOffset impl_GetSoundInfoOffset(u32) const;
inline u16 GetVersion() const {
return mHeader.mHeader.version;
u32 ConvertLabelStringToSoundId(const char* pLabel) const {
return ConvertLabelStringToId(mStringTreeSound, pLabel);
}
u32 ConvertLabelStringToPlayerId(const char* pLabel) const {
return ConvertLabelStringToId(mStringTreePlayer, pLabel);
}
u32 ConvertLabelStringToGroupId(const char* pLabel) const {
return ConvertLabelStringToId(mStringTreeGroup, pLabel);
}
inline u32 GetLabelStringChunkOffset() const {
return mHeader.mLabelStringChunkOffset;
u16 GetVersion() const {
return mHeader.fileHeader.version;
}
inline u32 GetLabelStringChunkSize() const {
return mHeader.mLabelStringChunkSize;
u32 GetLabelStringChunkOffset() const {
return mHeader.symbolDataOffset;
}
inline u32 GetInfoChunkOffset() const {
return mHeader.mInfoChunkOffset;
u32 GetLabelStringChunkSize() const {
return mHeader.symbolDataSize;
}
inline u32 GetInfoChunkSize() const {
return mHeader.mInfoChunkSize;
u32 GetInfoChunkOffset() const {
return mHeader.infoOffset;
}
u32 GetInfoChunkSize() const {
return mHeader.infoSize;
}
private:
u32 ConvertLabelStringToId(const SoundArchiveFile::StringTree* pTree,
const char* pLabel) const;
const SoundArchiveFile::SoundCommonInfo* impl_GetSoundInfo(u32 id) const;
SoundArchiveFile::SoundInfoOffset impl_GetSoundInfoOffset(u32 id) const
DECOMP_DONT_INLINE;
const SoundArchiveFile::SeqSoundInfo* impl_GetSeqSoundInfo(u32 id) const;
const SoundArchiveFile::StrmSoundInfo* impl_GetStrmSoundInfo(u32 id) const;
const SoundArchiveFile::WaveSoundInfo* impl_GetWaveSoundInfo(u32 id) const;
const SoundArchiveFile::BankInfo* impl_GetBankInfo(u32 id) const;
const SoundArchiveFile::PlayerInfo* impl_GetPlayerInfo(u32 id) const;
const SoundArchiveFile::GroupInfo* impl_GetGroupInfo(u32 id) const;
const void* GetPtrConst(const void* pBase, u32 offset) const {
if (offset == 0) {
return NULL;
}
return ut::AddOffsetToPtr(pBase, offset);
}
private:
SoundArchiveFile::Header mHeader; // at 0x0
const SoundArchiveFile::Info* mInfo; // at 0x28
const void* mStringBase; // at 0x2C
const SoundArchiveFile::StringTable* mStringTable; // at 0x30
const SoundArchiveFile::StringTree* mStringTreeSound; // at 0x34
const SoundArchiveFile::StringTree* mStringTreePlayer; // at 0x38
const SoundArchiveFile::StringTree* mStringTreeGroup; // at 0x3C
const SoundArchiveFile::StringTree* mStringTreeBank; // at 0x40
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+37 -22
View File
@@ -1,45 +1,60 @@
#ifndef NW4R_SND_SOUND_ARCHIVE_LOADER_H
#define NW4R_SND_SOUND_ARCHIVE_LOADER_H
#include "common.h"
#include "snd_SoundMemoryAllocatable.h"
#include "ut_FileStream.h"
#include <OSMutex.h>
#include <nw4r/types_nw4r.h>
#include <nw4r/ut.h>
#include <rvl/OS.h>
namespace nw4r {
namespace snd {
// Forward declarations
class SoundMemoryAllocatable;
namespace detail {
struct FileStreamHandle {
ut::FileStream *mFileStream;
inline FileStreamHandle(ut::FileStream *pFileStream) : mFileStream(pFileStream) {}
class FileStreamHandle {
public:
FileStreamHandle(ut::FileStream* pFileStream) : mStream(pFileStream) {}
inline ~FileStreamHandle() {
if (mFileStream) {
mFileStream->Close();
~FileStreamHandle() {
if (mStream != NULL) {
mStream->Close();
}
}
inline operator bool() const {
return mFileStream;
ut::FileStream* GetFileStream() {
return mStream;
}
inline ut::FileStream *operator->() {
return mFileStream;
ut::FileStream* operator->() {
return mStream;
}
operator bool() const {
return mStream;
}
private:
ut::FileStream* mStream; // at 0x0
};
struct SoundArchiveLoader {
OSMutex mMutex; // at 0x0
const SoundArchive &mArchive; // at 0x18
u8 mBuffer[0x200]; // at 0x1c
ut::FileStream *mFileStream; // at 0x21c
SoundArchiveLoader(const SoundArchive &);
class SoundArchiveLoader {
public:
explicit SoundArchiveLoader(const SoundArchive& rArchive);
~SoundArchiveLoader();
void *LoadGroup(u32, SoundMemoryAllocatable *, void **, u32);
void* LoadGroup(u32 id, SoundMemoryAllocatable* pAllocatable,
void** ppWaveBuffer, u32 blockSize);
private:
mutable OSMutex mMutex; // at 0x0
const SoundArchive& mArc; // at 0x18
u8 mStreamArea[512]; // at 0x1C
ut::FileStream* mStream; // at 0x21C
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+202 -24
View File
@@ -1,45 +1,223 @@
#ifndef NW4R_SND_SOUND_ARCHIVE_PLAYER_H
#define NW4R_SND_SOUND_ARCHIVE_PLAYER_H
#include "common.h"
#include "snd_DisposeCallback.h"
#include "snd_SoundHandle.h"
#include "snd_SoundMemoryAllocatable.h"
#include "snd_SoundStartable.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_DisposeCallback.h>
#include <nw4r/snd/snd_MmlParser.h>
#include <nw4r/snd/snd_MmlSeqTrackAllocator.h>
#include <nw4r/snd/snd_NoteOnCallback.h>
#include <nw4r/snd/snd_SeqSound.h>
#include <nw4r/snd/snd_SoundArchive.h>
#include <nw4r/snd/snd_SoundInstanceManager.h>
#include <nw4r/snd/snd_SoundStartable.h>
#include <nw4r/snd/snd_StrmChannel.h>
#include <nw4r/snd/snd_StrmSound.h>
#include <nw4r/snd/snd_Util.h>
#include <nw4r/snd/snd_WaveSound.h>
#include <nw4r/snd/snd_WsdPlayer.h>
namespace nw4r {
namespace snd {
struct SoundArchivePlayer : detail::DisposeCallback, SoundStartable {
// Forward declarations
namespace detail {
class SeqTrackAllocator;
}
class SoundMemoryAllocatable;
class SoundPlayer;
class SoundArchivePlayer_FileManager {
public:
virtual const void* GetFileAddress(u32 id) = 0; // at 0x8
virtual const void* GetFileWaveDataAddress(u32 id) = 0; // at 0x8
};
class SoundArchivePlayer : public detail::DisposeCallback,
public SoundStartable {
public:
SoundArchivePlayer();
~SoundArchivePlayer();
virtual ~SoundArchivePlayer(); // at 0x8
virtual void InvalidateData(const void* pStart,
const void* pEnd); // at 0xC
virtual void InvalidateWaveData(const void* pStart,
const void* pEnd); // at 0x10
virtual StartResult
detail_SetupSound(SoundHandle* pHandle, u32 id,
detail::BasicSound::AmbientArgInfo* pArgInfo,
detail::ExternalSoundPlayer* pPlayer, bool hold,
const StartInfo* pStartInfo); // at 0x28
virtual u32 detail_ConvertLabelStringToSoundId(const char* pLabel) {
return mSoundArchive->ConvertLabelStringToSoundId(pLabel);
} // at 0x2C
bool IsAvailable() const;
bool Setup(const SoundArchive *, void *, u32, void *, u32);
bool Setup(const SoundArchive* pArchive, void* pMramBuffer,
u32 mramBufferSize, void* pStrmBuffer, u32 strmBufferSize);
void Shutdown();
u32 GetRequiredMemSize(const SoundArchive *);
u32 GetRequiredStrmBufferSize(const SoundArchive *);
u32 GetRequiredMemSize(const SoundArchive* pArchive);
u32 GetRequiredStrmBufferSize(const SoundArchive* pArchive);
void Update();
SoundArchive *GetSoundArchive() const;
SoundPlayer *GetSoundPlayer(u32);
const SoundArchive& GetSoundArchive() const;
UNKWORD detail_SetupSound(SoundHandle *, u32, detail::BasicSound::AmbientArgInfo *, detail::ExternalSoundPlayer *,
bool, const StartInfo *);
SoundPlayer& GetSoundPlayer(u32 i);
SoundPlayer& GetSoundPlayer(int i) {
return GetSoundPlayer(static_cast<u32>(i));
}
UNKWORD LoadGroup(u32, SoundMemoryAllocatable *, u32);
UNKWORD LoadGroup(const char *, SoundMemoryAllocatable *, u32);
const void* detail_GetFileAddress(u32 id) const;
const void* detail_GetFileWaveDataAddress(u32 id) const;
virtual void InvalidateData(const void *, const void *);
virtual void InvalidateWaveData(const void *, const void *);
virtual UNKWORD detail_ConvertLabelStringToSoundId(const char *);
const void* GetGroupAddress(u32 id) const;
void SetGroupAddress(u32 id, const void* pAddr);
char UNK_0x4[0x8];
SoundHandle mHandle; // at 0xC
char UNK_0x1C[0x14];
u32 WORD_0x30;
char UNK_0x34[0xAC];
const void* GetGroupWaveDataAddress(u32 id) const;
void SetGroupWaveDataAddress(u32 id, const void* pAddr);
bool LoadGroup(u32 id, SoundMemoryAllocatable* pAllocatable, u32 blockSize);
bool LoadGroup(const char* pLabel, SoundMemoryAllocatable* pAllocatable,
u32 blockSize);
bool LoadGroup(int id, SoundMemoryAllocatable* pAllocatable,
u32 blockSize) {
return LoadGroup(static_cast<u32>(id), pAllocatable, blockSize);
}
bool LoadGroup(unsigned int id, SoundMemoryAllocatable* pAllocatable,
u32 blockSize) {
return LoadGroup(static_cast<u32>(id), pAllocatable, blockSize);
}
u32 GetSoundPlayerCount() const {
return mSoundPlayerCount;
}
u32 GetFreeSeqSoundCount() const {
return mSeqSoundInstanceManager.GetFreeCount();
}
u32 GetFreeStrmSoundCount() const {
return mStrmSoundInstanceManager.GetFreeCount();
}
u32 GetFreeWaveSoundCount() const {
return mWaveSoundInstanceManager.GetFreeCount();
}
private:
struct Group {
const void* address; // at 0x0
const void* waveDataAddress; // at 0x4
};
typedef detail::Util::Table<Group> GroupTable;
class SeqNoteOnCallback : public detail::NoteOnCallback {
public:
explicit SeqNoteOnCallback(const SoundArchivePlayer& rPlayer)
: mSoundArchivePlayer(rPlayer) {}
virtual detail::Channel*
NoteOn(detail::SeqPlayer* pPlayer, int bankNo,
const detail::NoteOnInfo& rInfo); // at 0xC
private:
const SoundArchivePlayer& mSoundArchivePlayer; // at 0x0
};
class WsdCallback : public detail::WsdPlayer::WsdCallback {
public:
explicit WsdCallback(const SoundArchivePlayer& rPlayer)
: mSoundArchivePlayer(rPlayer) {}
virtual bool GetWaveSoundData(detail::WaveSoundInfo* pSoundInfo,
detail::WaveSoundNoteInfo* pNoteInfo,
detail::WaveData* pWaveData,
const void* pWsdData, int index,
int noteIndex,
u32 callbackArg) const; // at 0xC
private:
const SoundArchivePlayer& mSoundArchivePlayer; // at 0x0
};
private:
bool SetupMram(const SoundArchive* pArchive, void* pBuffer, u32 bufferSize);
detail::PlayerHeap* CreatePlayerHeap(void* pBuffer, u32 bufferSize);
bool SetupSoundPlayer(const SoundArchive* pArchive, void** ppBuffer,
void* pEnd);
bool CreateGroupAddressTable(const SoundArchive* pArchive, void** ppBuffer,
void* pEnd);
bool SetupSeqSound(const SoundArchive* pArchive, int sounds,
void** ppBuffer, void* pEnd);
bool SetupWaveSound(const SoundArchive* pArchive, int sounds,
void** ppBuffer, void* pEnd);
bool SetupStrmSound(const SoundArchive* pArchive, int sounds,
void** ppBuffer, void* pEnd);
bool SetupSeqTrack(const SoundArchive* pArchive, int tracks,
void** ppBuffer, void* pEnd);
bool SetupStrmBuffer(const SoundArchive* pArchive, void* pBuffer,
u32 bufferSize);
StartResult
PrepareSeqImpl(detail::SeqSound* pSound,
const SoundArchive::SoundInfo* pSndInfo,
const SoundArchive::SeqSoundInfo* pSeqInfo,
SoundStartable::StartInfo::StartOffsetType startType,
int startOffset, int voices);
StartResult
PrepareStrmImpl(detail::StrmSound* pSound,
const SoundArchive::SoundInfo* pSndInfo,
const SoundArchive::StrmSoundInfo* pStrmInfo,
SoundStartable::StartInfo::StartOffsetType startType,
int startOffset, int voices);
StartResult
PrepareWaveSoundImpl(detail::WaveSound* pSound,
const SoundArchive::SoundInfo* pSndInfo,
const SoundArchive::WaveSoundInfo* pWsdInfo,
SoundStartable::StartInfo::StartOffsetType startType,
int startOffset, int voices);
private:
const SoundArchive* mSoundArchive; // at 0x10
GroupTable* mGroupTable; // at 0x14
SoundArchivePlayer_FileManager* mFileManager; // at 0x18
detail::SeqTrackAllocator* mSeqTrackAllocator; // at 0x1C
SeqNoteOnCallback mSeqCallback; // at 0x20
WsdCallback mWsdCallback; // at 0x28
u32 mSoundPlayerCount; // at 0x30
SoundPlayer* mSoundPlayers; // at 0x34
detail::SoundInstanceManager<detail::SeqSound>
mSeqSoundInstanceManager; // at 0x38
detail::SoundInstanceManager<detail::StrmSound>
mStrmSoundInstanceManager; // at 0x60
detail::SoundInstanceManager<detail::WaveSound>
mWaveSoundInstanceManager; // at 0x88
detail::MmlSeqTrackAllocator mMmlSeqTrackAllocator; // at 0xB0
detail::StrmBufferPool mStrmBufferPool; // at 0xBC
detail::MmlParser mMmlParser; // at 0xD4
void* mSetupBufferAddress; // at 0xD8
u32 mSetupBufferSize; // at 0xDC
};
} // namespace snd
} // namespace nw4r
+88 -19
View File
@@ -1,41 +1,110 @@
#ifndef NW4R_SND_SOUND_HANDLE_H
#define NW4R_SND_SOUND_HANDLE_H
#include "common.h"
#include "snd_BasicSound.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_BasicSound.h>
#include <nw4r/ut.h>
namespace nw4r {
namespace snd {
struct SoundHandle {
detail::BasicSound *mSound; // at 0x0
void detail_AttachSound(detail::BasicSound *);
void detail_AttachSoundAsTempHandle(detail::BasicSound *);
void DetachSound();
inline SoundHandle() : mSound(NULL) {}
inline ~SoundHandle() {
class SoundHandle : private ut::NonCopyable {
public:
SoundHandle() : mSound(NULL) {}
~SoundHandle() {
DetachSound();
}
inline detail::BasicSound *detail_GetAttachedSound() {
return mSound;
}
void detail_AttachSound(detail::BasicSound* pSound);
void detail_AttachSoundAsTempHandle(detail::BasicSound* pSound);
inline bool IsAttachedSound() const {
bool IsAttachedSound() const {
return mSound != NULL;
}
inline void StartPrepared() {
detail::BasicSound* detail_GetAttachedSound() {
return mSound;
}
void DetachSound();
bool IsPrepared() const {
if (IsAttachedSound()) {
return mSound->IsPrepared();
}
return false;
}
u32 GetId() const {
if (IsAttachedSound()) {
return mSound->GetId();
}
return -1;
}
void StartPrepared() {
if (IsAttachedSound()) {
mSound->StartPrepared();
}
}
inline u32 GetId() const {
return IsAttachedSound() ? mSound->GetId() : -1;
void Stop(int frames) {
if (IsAttachedSound()) {
mSound->Stop(frames);
}
}
void Pause(bool flag, int frames) {
if (IsAttachedSound()) {
mSound->Pause(flag, frames);
}
}
void SetVolume(f32 volume, int frames) {
if (IsAttachedSound()) {
mSound->SetVolume(volume, frames);
}
}
void SetPan(f32 pan) {
if (IsAttachedSound()) {
mSound->SetPan(pan);
}
}
void SetPitch(f32 pitch) {
if (IsAttachedSound()) {
mSound->SetPitch(pitch);
}
}
void SetOutputLine(int flag) {
if (IsAttachedSound()) {
mSound->SetOutputLine(flag);
}
}
void SetMainOutVolume(f32 volume) {
if (IsAttachedSound()) {
mSound->SetMainOutVolume(volume);
}
}
void SetRemoteOutVolume(int remote, f32 volume) {
if (IsAttachedSound()) {
mSound->SetRemoteOutVolume(remote, volume);
}
}
void SetFxSend(AuxBus bus, f32 send) {
if (IsAttachedSound()) {
mSound->SetFxSend(bus, send);
}
}
private:
detail::BasicSound* mSound; // at 0x0
};
} // namespace snd
} // namespace nw4r
+41 -14
View File
@@ -1,31 +1,58 @@
#ifndef NW4R_SND_SOUND_HEAP_H
#define NW4R_SND_SOUND_HEAP_H
#include "common.h"
#include "snd_FrameHeap.h"
#include "snd_SoundMemoryAllocatable.h"
#include <OSMutex.h>
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_FrameHeap.h>
#include <nw4r/snd/snd_SoundMemoryAllocatable.h>
#include <nw4r/ut.h>
#include <rvl/OS.h>
namespace nw4r {
namespace snd {
struct SoundHeap : SoundMemoryAllocatable {
class SoundHeap : public SoundMemoryAllocatable {
public:
SoundHeap();
virtual ~SoundHeap(); // VMT 0x8
bool Create(void *, u32);
virtual ~SoundHeap(); // at 0x8
virtual void* Alloc(u32 size); // at 0xC
void* Alloc(u32 size, detail::FrameHeap::FreeCallback pCallback,
void* pCallbackArg);
bool Create(void* pBase, u32 size);
void Destroy();
virtual void *Alloc(u32); // VMT 0xC
void *Alloc(u32, detail::FrameHeap::AllocCallback, void *);
void Clear();
int SaveState();
void LoadState(int);
static void DisposeCallbackFunc(void *, u32, void *);
void LoadState(int id);
bool IsValid() {
return mFrameHeap.PTR_0x0 != NULL;
return mFrameHeap.IsValid();
}
OSMutex mMutex; // 0x00
detail::FrameHeap mFrameHeap; // 0x1C
int GetCurrentLevel() const {
ut::detail::AutoLock<OSMutex> lock(mMutex);
return mFrameHeap.GetCurrentLevel();
}
u32 GetFreeSize() const {
ut::detail::AutoLock<OSMutex> lock(mMutex);
return mFrameHeap.GetFreeSize();
}
private:
static void DisposeCallbackFunc(void* pBuffer, u32 size,
void* pCallbackArg);
private:
mutable OSMutex mMutex; // at 0x0
detail::FrameHeap mFrameHeap; // at 0x1C
};
} // namespace snd
} // namespace nw4r
+113 -26
View File
@@ -1,55 +1,142 @@
#ifndef NW4R_SND_SOUND_INSTANCE_MANAGER_H
#define NW4R_SND_SOUND_INSTANCE_MANAGER_H
#include "snd_InstancePool.h"
#include "ut_LinkList.h"
#include "ut_lock.h"
#include <OSMutex.h>#include "common.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_InstancePool.h>
#include <nw4r/ut.h>
#include <rvl/OS.h>
namespace nw4r {
namespace snd {
namespace detail {
template <typename T>
struct SoundInstanceManager {
MemoryPool<T> mPool; // at 0x0
ut::LinkList<T, 0xB8> mPriorityList; // at 0x4
OSMutex mMutex; // at 0x10
inline void Free(T *pInstance) {
template <typename T> class SoundInstanceManager {
private:
NW4R_UT_LIST_TYPEDEF_DECL_EX(T, Prio);
public:
SoundInstanceManager() {
OSInitMutex(&mMutex);
}
u32 Create(void* pBuffer, u32 size) {
ut::detail::AutoLock<OSMutex> lock(mMutex);
return mPool.Create(pBuffer, size);
}
void Destroy(void* pBuffer, u32 size) {
ut::detail::AutoLock<OSMutex> lock(mMutex);
mPool.Destroy(pBuffer, size);
}
T* Alloc(int priority) {
ut::detail::AutoLock<OSMutex> lock(mMutex);
T* pSound = NULL;
while (pSound == NULL) {
void* pBuffer = mPool.Alloc();
if (pBuffer != NULL) {
pSound = new (pBuffer) T(this);
} else {
T* pLowest = GetLowestPrioritySound();
if (pLowest == NULL) {
return NULL;
}
if (priority < pLowest->CalcCurrentPlayerPriority()) {
return NULL;
}
OSUnlockMutex(&mMutex);
pLowest->Stop(0);
OSLockMutex(&mMutex);
}
}
InsertPriorityList(pSound, priority);
return pSound;
}
void Free(T* pSound) {
ut::detail::AutoLock<OSMutex> lock(mMutex);
if (mPriorityList.IsEmpty()) {
return;
}
mPriorityList.Erase(pInstance);
mPool.Free(pInstance);
RemovePriorityList(pSound);
pSound->~T();
mPool.Free(pSound);
}
inline void InsertPriorityList(T *pInstance, int priority) {
ut::LinkList<T, 0xB8>::Iterator iter = mPriorityList.GetBeginIter();
int curPriority;
u32 GetActiveCount() const {
return mPriorityList.GetSize();
}
while (iter != mPriorityList.GetEndIter()) {
curPriority = iter->CalcCurrentPlayerPriority();
u32 GetFreeCount() const {
return mPool.Count();
}
if (priority < curPriority) {
break;
}
iter++;
T* GetLowestPrioritySound() {
if (mPriorityList.IsEmpty()) {
return NULL;
}
mPriorityList.Insert(iter, pInstance);
return static_cast<T*>(&mPriorityList.GetFront());
}
inline void UpdatePriority(T *pInstance, int priority) {
void InsertPriorityList(T* pSound, int priority) {
TPrioList::Iterator it = mPriorityList.GetBeginIter();
for (; it != mPriorityList.GetEndIter(); ++it) {
if (priority < it->CalcCurrentPlayerPriority()) {
break;
}
}
mPriorityList.Insert(it, pSound);
}
void RemovePriorityList(T* pSound) {
mPriorityList.Erase(pSound);
}
void SortPriorityList() {
TPrioList listsByPrio[T::PRIORITY_MAX + 1];
ut::detail::AutoLock<OSMutex> lock(mMutex);
mPriorityList.Erase(pInstance);
InsertPriorityList(pInstance, priority);
while (!mPriorityList.IsEmpty()) {
T& rSound = mPriorityList.GetFront();
mPriorityList.PopFront();
listsByPrio[rSound.CalcCurrentPlayerPriority()].PushBack(&rSound);
}
for (int i = 0; i < T::PRIORITY_MAX + 1; i++) {
while (!listsByPrio[i].IsEmpty()) {
T& rSound = listsByPrio[i].GetFront();
listsByPrio[i].PopFront();
mPriorityList.PushBack(&rSound);
}
}
}
void UpdatePriority(T* pSound, int priority) {
ut::detail::AutoLock<OSMutex> lock(mMutex);
RemovePriorityList(pSound);
InsertPriorityList(pSound, priority);
}
private:
MemoryPool<T> mPool; // at 0x0
TPrioList mPriorityList; // at 0x4
mutable OSMutex mMutex; // at 0x10
};
} // namespace detail
} // namespace snd
} // namespace nw4r
@@ -1,13 +1,17 @@
#ifndef NW4R_SOUND_MEMORY_ALLOCATABLE_H
#define NW4R_SOUND_MEMORY_ALLOCATABLE_H
#include "common.h"
#ifndef NW4R_SND_SOUND_MEMORY_ALLOCATABLE_H
#define NW4R_SND_SOUND_MEMORY_ALLOCATABLE_H
#include <nw4r/types_nw4r.h>
namespace nw4r {
namespace snd {
struct SoundMemoryAllocatable {
class SoundMemoryAllocatable {
public:
virtual ~SoundMemoryAllocatable() {} // at 0x8
virtual void *Alloc(u32) = 0; // at 0xc
virtual void* Alloc(u32 size) = 0; // at 0xC
};
} // namespace snd
} // namespace nw4r
+104 -16
View File
@@ -1,35 +1,123 @@
#ifndef NW4R_SND_SOUND_PLAYER_H
#define NW4R_SND_SOUND_PLAYER_H
#include "common.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_BasicSound.h>
#include <nw4r/snd/snd_PlayerHeap.h>
#include <rvl/OS.h>
#include <rvl/WPAD.h>
namespace nw4r {
namespace snd {
// Forward declarations
namespace detail {
class ExternalSoundPlayer;
class SeqSound;
class StrmSound;
class WaveSound;
template <typename T> class SoundInstanceManager;
} // namespace detail
class SoundPlayer {
public:
SoundPlayer();
~SoundPlayer();
void InitParam();
void Update();
void StopAllSound(int frames);
void PauseAllSound(bool flag, int frames);
void SetVolume(f32 volume);
int detail_GetOutputLine() const;
bool detail_IsEnabledOutputLine() const;
f32 detail_GetRemoteOutVolume(int i) const;
void detail_InsertSoundList(detail::BasicSound* pSound);
void detail_RemoveSoundList(detail::BasicSound* pSound);
void detail_InsertPriorityList(detail::BasicSound* pSound);
void detail_RemovePriorityList(detail::BasicSound* pSound);
void detail_SortPriorityList();
detail::SeqSound* detail_AllocSeqSound(
int priority, int startPriority,
detail::BasicSound::AmbientArgInfo* pArgInfo,
detail::ExternalSoundPlayer* pExtPlayer, u32 id,
detail::SoundInstanceManager<detail::SeqSound>* pManager);
detail::StrmSound* detail_AllocStrmSound(
int priority, int startPriority,
detail::BasicSound::AmbientArgInfo* pArgInfo,
detail::ExternalSoundPlayer* pExtPlayer, u32 id,
detail::SoundInstanceManager<detail::StrmSound>* pManager);
detail::WaveSound* detail_AllocWaveSound(
int priority, int startPriority,
detail::BasicSound::AmbientArgInfo* pArgInfo,
detail::ExternalSoundPlayer* pExtPlayer, u32 id,
detail::SoundInstanceManager<detail::WaveSound>* pManager);
int CalcPriorityReduction(detail::BasicSound::AmbientArgInfo* pArgInfo,
u32 id);
void InitAmbientArg(detail::BasicSound* pSound,
detail::BasicSound::AmbientArgInfo* pArgInfo);
void SetPlayableSoundCount(int count);
void detail_SetPlayableSoundLimit(int limit);
bool CheckPlayableSoundCount(int startPriority,
detail::ExternalSoundPlayer* pExtPlayer);
void detail_AppendPlayerHeap(detail::PlayerHeap* pHeap);
detail::PlayerHeap* detail_AllocPlayerHeap(detail::BasicSound* pSound);
void detail_FreePlayerHeap(detail::BasicSound* pSound);
int GetPlayingSoundCount() const {
return mSoundList.GetSize();
}
int GetPlayableSoundCount() const {
return mPlayableCount;
}
f32 GetVolume() const {
return mVolume;
}
detail::BasicSound* detail_GetLowestPrioritySound() {
// @bug UB when the list is empty
return &mPriorityList.GetFront();
}
f32 detail_GetMainOutVolume() const {
return mMainOutVolume;
}
void StopAllSound(int);
bool detail_IsEnabledOutputLine() const;
int detail_GetOutputLine() const;
f32 detail_GetRemoteOutVolume(int) const;
UNKTYPE detail_FreePlayerHeap(detail::BasicSound *);
UNKTYPE detail_InsertPriorityList(detail::BasicSound *);
UNKTYPE detail_RemoveSoundList(detail::BasicSound *);
UNKTYPE detail_RemovePriorityList(detail::BasicSound *);
private:
char UNK_0x0[0x28];
f32 mVolume; // at 0x28
bool mEnableOutputLine; // at 0x2C
int mOutputLine; // at 0x30
f32 mMainOutVolume; // at 0x34
detail::BasicSoundPlayerPlayList mSoundList; // at 0x0
detail::BasicSoundPlayerPrioList mPriorityList; // at 0xC
detail::PlayerHeapList mHeapList; // at 0x18
u16 mPlayableCount; // at 0x24
u16 mPlayableLimit; // at 0x26
f32 mVolume; // at 0x28
bool mOutputLineFlagEnable; // at 0x2C
bool mUsePlayerHeap; // at 0x2D
int mOutputLineFlag; // at 0x30
f32 mMainOutVolume; // at 0x34
f32 mRemoteOutVolume[WPAD_MAX_CONTROLLERS]; // at 0x38
mutable OSMutex mMutex; // at 0x48
};
} // namespace snd
} // namespace nw4r
+111 -16
View File
@@ -1,30 +1,125 @@
#ifndef NW4R_SND_SOUND_STARTABLE_H
#define NW4R_SND_SOUND_STARTABLE_H
#include "common.h"
#include "snd_BasicSound.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_BasicSound.h>
namespace nw4r {
namespace snd {
struct SoundStartable {
struct StartInfo {};
inline SoundStartable() {}
inline virtual ~SoundStartable() {} // at 0x8
virtual UNKWORD detail_SetupSound(SoundHandle *, u32, detail::BasicSound::AmbientArgInfo *,
detail::ExternalSoundPlayer *, bool,
const StartInfo *) = 0; // at 0xc
virtual UNKWORD detail_ConvertLabelStringToSoundId(const char *) = 0; // at 0x10
// Forward declarations
class SoundHandle;
namespace detail {
class ExternalSoundPlayer;
}
UNKWORD detail_StartSound(SoundHandle *, u32, detail::BasicSound::AmbientArgInfo *, detail::ExternalSoundPlayer *,
const StartInfo *);
class SoundStartable {
public:
enum StartResult {
START_SUCCESS,
START_ERR_LOW_PRIORITY,
START_ERR_INVALID_LABEL_STRING,
START_ERR_INVALID_SOUNDID,
START_ERR_NOT_DATA_LOADED,
START_ERR_NOT_ENOUGH_PLAYER_HEAP,
START_ERR_CANNOT_OPEN_FILE,
START_ERR_NOT_AVAILABLE,
START_ERR_CANNOT_ALLOCATE_TRACK,
START_ERR_NOT_ENOUGH_INSTANCE,
START_ERR_INVALID_PARAMETER,
START_ERR_INVALID_SEQ_START_LOCATION_LABEL,
UNKWORD detail_HoldSound(SoundHandle *, u32, detail::BasicSound::AmbientArgInfo *, detail::ExternalSoundPlayer *,
const StartInfo *);
START_ERR_USER = 128,
START_ERR_UNKNOWN = 255,
};
UNKWORD detail_PrepareSound(SoundHandle *, u32, detail::BasicSound::AmbientArgInfo *, detail::ExternalSoundPlayer *,
const StartInfo *);
struct StartInfo {
enum EnableFlag {
ENABLE_START_OFFSET = (1 << 0),
ENABLE_PLAYER_ID = (1 << 1),
ENABLE_PLAYER_PRIORITY = (1 << 2)
};
enum StartOffsetType {
START_OFFSET_TYPE_MILLISEC,
START_OFFSET_TYPE_TICK,
START_OFFSET_TYPE_SAMPLE
};
u32 enableFlag; // at 0x0
StartOffsetType startOffsetType; // at 0x4
int startOffset; // at 0x8
u32 playerId; // at 0xC
int playerPriority; // at 0x10
int voiceOutCount; // at 0x14
};
public:
virtual ~SoundStartable() {} // at 0x8
virtual StartResult
detail_SetupSound(SoundHandle* pHandle, u32 id,
detail::BasicSound::AmbientArgInfo* pArgInfo,
detail::ExternalSoundPlayer* pPlayer, bool hold,
const StartInfo* pStartInfo) = 0; // at 0xC
virtual u32
detail_ConvertLabelStringToSoundId(const char* pLabel) = 0; // at 0x10
bool StartSound(SoundHandle* pHandle, u32 id) {
return detail_StartSound(pHandle, id, NULL, NULL, NULL) ==
START_SUCCESS;
}
bool StartSound(SoundHandle* pHandle, unsigned int id) {
return detail_StartSound(pHandle, id, NULL, NULL, NULL) ==
START_SUCCESS;
}
bool StartSound(SoundHandle* pHandle, int id) {
return detail_StartSound(pHandle, id, NULL, NULL, NULL) ==
START_SUCCESS;
}
bool HoldSound(SoundHandle* pHandle, u32 id) {
return detail_HoldSound(pHandle, id, NULL, NULL, NULL) == START_SUCCESS;
}
bool HoldSound(SoundHandle* pHandle, unsigned int id) {
return detail_HoldSound(pHandle, id, NULL, NULL, NULL) == START_SUCCESS;
}
bool HoldSound(SoundHandle* pHandle, int id) {
return detail_HoldSound(pHandle, id, NULL, NULL, NULL) == START_SUCCESS;
}
bool PrepareSound(SoundHandle* pHandle, u32 id) {
return detail_PrepareSound(pHandle, id, NULL, NULL, NULL) ==
START_SUCCESS;
}
bool PrepareSound(SoundHandle* pHandle, unsigned int id) {
return detail_PrepareSound(pHandle, id, NULL, NULL, NULL) ==
START_SUCCESS;
}
bool PrepareSound(SoundHandle* pHandle, int id) {
return detail_PrepareSound(pHandle, id, NULL, NULL, NULL) ==
START_SUCCESS;
}
private:
StartResult detail_StartSound(SoundHandle* pHandle, u32 id,
detail::BasicSound::AmbientArgInfo* pArgInfo,
detail::ExternalSoundPlayer* pPlayer,
const StartInfo* pStartInfo);
StartResult detail_HoldSound(SoundHandle* pHandle, u32 id,
detail::BasicSound::AmbientArgInfo* pArgInfo,
detail::ExternalSoundPlayer* pPlayer,
const StartInfo* pStartInfo);
StartResult
detail_PrepareSound(SoundHandle* pHandle, u32 id,
detail::BasicSound::AmbientArgInfo* pArgInfo,
detail::ExternalSoundPlayer* pPlayer,
const StartInfo* pStartInfo);
};
} // namespace snd
} // namespace nw4r
+62 -13
View File
@@ -1,27 +1,76 @@
#ifndef NW4R_SND_SOUND_SYSTEM_H
#define NW4R_SND_SOUND_SYSTEM_H
#include "common.h"
#include "snd_AxManager.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_AxManager.h>
#include <nw4r/snd/snd_RemoteSpeakerManager.h>
#include <nw4r/snd/snd_TaskThread.h>
namespace nw4r {
namespace snd {
struct SoundSystem {
struct SoundSystemParam {};
static inline f32 GetMasterVolume() {
return detail::AxManager::GetInstance().GetMasterVolume();
}
class SoundSystem {
public:
struct SoundSystemParam {
s32 soundThreadPriority; // at 0x0
u32 soundThreadStackSize; // at 0x4
s32 dvdThreadPriority; // at 0x8
u32 dvdThreadStackSize; // at 0xC
static inline void PrepareReset() {
SoundSystemParam()
: soundThreadPriority(DEFAULT_SOUND_THREAD_PRIORITY),
soundThreadStackSize(DEFAULT_SOUND_THREAD_STACK_SIZE),
dvdThreadPriority(DEFAULT_DVD_THREAD_PRIORITY),
dvdThreadStackSize(DEFAULT_DVD_THREAD_STACK_SIZE) {}
};
public:
static void InitSoundSystem(s32 soundThreadPrio, s32 dvdThreadPriority);
static u32 GetRequiredMemSize(const SoundSystemParam& rParam);
static void InitSoundSystem(const SoundSystemParam& rParam, void* pWork,
u32 workSize);
static void ShutdownSoundSystem();
static void WaitForResetReady();
static void PrepareReset() {
detail::AxManager::GetInstance().PrepareReset();
}
void InitSoundSystem(s32, s32);
void InitSoundSystem(const SoundSystemParam &, void *, u32);
static void ShutdownSoundSystem();
static void WaitForResetReady();
UNKWORD GetRequiredMemSize(const SoundSystemParam &);
static void SetOutputMode(OutputMode mode) {
detail::AxManager::GetInstance().SetOutputMode(mode);
}
static f32 GetMasterVolume() {
return detail::AxManager::GetInstance().GetMasterVolume();
}
static void SetMasterVolume(f32 volume, int frame) {
detail::AxManager::GetInstance().SetMasterVolume(volume, frame);
}
static RemoteSpeaker& GetRemoteSpeaker(int i) {
return detail::RemoteSpeakerManager::GetInstance().GetRemoteSpeaker(i);
}
static void AppendEffect(AuxBus bus, FxBase* pFx) {
detail::AxManager::GetInstance().AppendEffect(bus, pFx);
}
static void ClearEffect(AuxBus bus, int frame) {
detail::AxManager::GetInstance().ClearEffect(bus, frame);
}
private:
static const int DEFAULT_DVD_THREAD_PRIORITY = 3;
static const int DEFAULT_DVD_THREAD_STACK_SIZE = 0x4000;
static const int DEFAULT_SOUND_THREAD_PRIORITY = 4;
static const int DEFAULT_SOUND_THREAD_STACK_SIZE = 0x4000;
private:
static detail::TaskThread sTaskThread;
};
} // namespace snd
} // namespace nw4r
+70 -45
View File
@@ -1,49 +1,81 @@
#ifndef NW4R_SND_SOUND_THREAD_H
#define NW4R_SND_SOUND_THREAD_H
#include "common.h"
#include "snd_AxManager.h"
#include "ut_LinkList.h"
#include <rvl/OS/OSMessage.h>
#include <rvl/OS/OSMutex.h>
#include <rvl/OS/OSThread.h>
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_AxManager.h>
#include <nw4r/ut.h>
#include <rvl/OS.h>
namespace nw4r {
namespace snd {
namespace detail {
class SoundThread {
friend class AutoLock; // Prevent locking without AutoLock
public:
struct SoundThreadCallback {
ut::LinkListNode mNode; // at 0x0
class SoundFrameCallback {
public:
NW4R_UT_LIST_NODE_DECL(); // at 0x0
inline virtual ~SoundThreadCallback() {} // at 0x8
inline virtual void VF_0xC() {} // at 0xC
inline virtual void VF_0x10() {} // at 0x10
virtual ~SoundFrameCallback() {} // at 0x8
virtual void OnBeginSoundFrame() {} // at 0xC
virtual void OnEndSoundFrame() {} // at 0x10
};
struct PlayerCallback {
ut::LinkListNode mNode; // at 0x0
NW4R_UT_LIST_TYPEDEF_DECL(SoundFrameCallback);
inline virtual ~PlayerCallback() {} // at 0x8
inline virtual void OnUpdateFrameSoundThread() {} // at 0xc
inline virtual void OnUpdateVoiceSoundThread() {} // at 0x10
inline virtual void OnShutdownSoundThread() {} // at 0x14
class PlayerCallback {
public:
NW4R_UT_LIST_NODE_DECL(); // at 0x0
virtual ~PlayerCallback() {} // at 0x8
virtual void OnUpdateFrameSoundThread() {} // at 0xC
virtual void OnUpdateVoiceSoundThread() {} // at 0x10
virtual void OnShutdownSoundThread() {} // at 0x14
};
struct AutoLock {
inline AutoLock() {
GetInstance()->Lock();
NW4R_UT_LIST_TYPEDEF_DECL(PlayerCallback);
class AutoLock : private ut::NonCopyable {
public:
AutoLock() {
SoundThread::GetInstance().Lock();
}
inline ~AutoLock() {
GetInstance()->Unlock();
~AutoLock() {
SoundThread::GetInstance().Unlock();
}
};
public:
static SoundThread *GetInstance();
static SoundThread& GetInstance();
bool Create(s32 priority, void* pStack, u32 stackSize);
void Shutdown();
void RegisterPlayerCallback(PlayerCallback* pCallback);
void UnregisterPlayerCallback(PlayerCallback* pCallback);
private:
enum ThreadMessage {
MSG_NONE,
MSG_AX_CALLBACK,
MSG_SHUTDOWN,
};
static const int MSG_QUEUE_CAPACITY = 4;
private:
SoundThread();
~SoundThread() {}
static void AxCallbackFunc();
void AxCallbackProc();
static void* SoundThreadFunc(void* pArg);
void SoundThreadProc();
void Lock() {
OSLockMutex(&mMutex);
@@ -52,29 +84,22 @@ public:
OSUnlockMutex(&mMutex);
}
bool Create(s32, void *, u32);
void Shutdown();
static void AxCallbackFunc();
void AxCallbackProc();
static void *SoundThreadFunc(void *);
void RegisterPlayerCallback(PlayerCallback *);
void UnregisterPlayerCallback(PlayerCallback *);
void SoundThreadProc();
private:
OSThread mThread; // at 0x0
OSThreadQueue mThreadQueue; // at 0x318
OSMessageQueue mMesgQueue; // at 0x320
OSMessage mMesgBuffer; // at 0x340
char UNK_0x344[0x350 - 0x344];
void *mStackEnd; // at 0x350
OSMutex mMutex; // at 0x354
AxManager::CallbackListNode mAxNode; // at 0x36C
ut::LinkList<SoundThreadCallback, 0> mThreadCbList; // at 0x378
ut::LinkList<PlayerCallback, 0> mPlayerCbList; // at 0x384
s32 mLastUpdateTime; // at 0x390
bool mIsCreated; // at 0x394
OSThread mThread; // at 0x0
OSThreadQueue mThreadQueue; // at 0x318
OSMessageQueue mMsgQueue; // at 0x320
OSMessage mMsgBuffer[MSG_QUEUE_CAPACITY]; // at 0x340
void* mStackEnd; // at 0x350
mutable OSMutex mMutex; // at 0x354
AxManager::CallbackListNode mAxCallbackNode; // at 0x36C
SoundFrameCallbackList mSoundFrameCallbackList; // at 0x378
PlayerCallbackList mPlayerCallbackList; // at 0x384
u32 mProcessTick; // at 0x390
bool mCreateFlag; // at 0x394
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+36 -15
View File
@@ -1,25 +1,46 @@
#ifndef NW4R_SND_STRMCHANNEL_H
#define NW4R_SND_STRMCHANNEL_H
#include "common.h"
#ifndef NW4R_SND_STRM_CHANNEL_H
#define NW4R_SND_STRM_CHANNEL_H
#include <nw4r/types_nw4r.h>
#define BLOCK_MAX 0x20
#include <nw4r/snd/snd_Common.h>
namespace nw4r {
namespace snd {
namespace detail {
struct StrmBufferPool {
void Setup(void *, u32, int);
void Shutdown();
void *Alloc();
void Free(void *);
void *mBuffer; // at 0x0
u32 mStrmBufferSize; // at 0x4
u32 mBlockSize; // at 0x8
s32 mBlockCount; // at 0xC (< BLOCK_MAX)
s32 mAllocCount; // at 0x10
u8 mAllocFlags[4]; // at 0x14 (1 bit per block)
struct StrmChannel {
void* bufferAddress; // at 0x0
u32 bufferSize; // at 0x4
AdpcmInfo adpcmInfo; // at 0x8
};
class StrmBufferPool {
public:
void Setup(void* pBase, u32 size, int count);
void Shutdown();
void* Alloc();
void Free(void* pBuffer);
u32 GetBlockSize() const {
return mBlockSize;
}
private:
static const int BLOCK_MAX = 32;
static const int BITS_PER_BYTE = 8;
private:
void* mBuffer; // at 0x0
u32 mBufferSize; // at 0x4
u32 mBlockSize; // at 0x8
int mBlockCount; // at 0xC
int mAllocCount; // at 0x10
u8 mAllocFlags[BLOCK_MAX / BITS_PER_BYTE]; // at 0x14
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+161
View File
@@ -0,0 +1,161 @@
#ifndef NW4R_SND_STRM_FILE_H
#define NW4R_SND_STRM_FILE_H
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_Common.h>
#include <nw4r/snd/snd_Util.h>
#include <nw4r/ut.h>
namespace nw4r {
namespace snd {
namespace detail {
namespace StrmFile {
struct StrmDataInfo {
u8 format; // at 0x0
u8 loopFlag; // at 0x1
u8 numChannels; // at 0x2
u8 sampleRate24; // at 0x3
u16 sampleRate; // at 0x4
u16 blockHeaderOffset; // at 0x6
u32 loopStart; // at 0x8
u32 loopEnd; // at 0xC
u32 dataOffset; // at 0x10
u32 numBlocks; // at 0x14
u32 blockSize; // at 0x18
u32 blockSamples; // at 0x1C
u32 lastBlockSize; // at 0x20
u32 lastBlockSamples; // at 0x24
u32 lastBlockPaddedSize; // at 0x28
u32 adpcmDataInterval; // at 0x2C
u32 adpcmDataSize; // at 0x30
};
struct TrackInfo {
u8 channelCount; // at 0x0
u8 channelIndexTable[]; // at 0x1
};
struct TrackTable {
u8 trackCount; // at 0x0
u8 trackDataType; // at 0x1
Util::DataRef<TrackInfo> refTrackHeader[]; // at 0x4
};
struct ChannelInfo {
Util::DataRef<AdpcmInfo> refAdpcmInfo; // at 0x0
};
struct ChannelTable {
u8 channelCount; // at 0x0
Util::DataRef<ChannelInfo> refChannelHeader[]; // at 0x4
};
struct Header {
ut::BinaryFileHeader fileHeader; // at 0x0
u32 headBlockOffset; // at 0x10
u32 headBlockSize; // at 0x14
u32 adpcBlockOffset; // at 0x18
u32 adpcBlockSize; // at 0x1C
u32 dataBlockOffset; // at 0x20
u32 dataBlockSize; // at 0x24
};
struct HeadBlock {
ut::BinaryBlockHeader blockHeader; // at 0x0
Util::DataRef<StrmDataInfo> refDataHeader; // at 0x8
Util::DataRef<TrackTable> refTrackTable; // at 0x10
Util::DataRef<ChannelTable> refChannelTable; // at 0x18
};
} // namespace StrmFile
struct StrmInfo {
u8 format; // at 0x0
u8 loopFlag; // at 0x1
u8 numChannels; // at 0x2
int sampleRate; // at 0x4
u16 blockHeaderOffset; // at 0x8
u32 loopStart; // at 0xC
u32 loopEnd; // at 0x10
u32 dataOffset; // at 0x14
u32 numBlocks; // at 0x18
u32 blockSize; // at 0x1C
u32 blockSamples; // at 0x20
u32 lastBlockSize; // at 0x24
u32 lastBlockSamples; // at 0x28
u32 lastBlockPaddedSize; // at 0x2C
u32 adpcmDataInterval; // at 0x30
u32 adpcmDataSize; // at 0x34
};
class StrmFileReader {
public:
static const u32 SIGNATURE = 'RSTM';
static const int VERSION = NW4R_VERSION(1, 0);
public:
StrmFileReader();
bool IsAvailable() const {
return mHeader != NULL;
}
bool IsValidFileHeader(const void* pStrmBin);
void Setup(const void* pStrmBin);
bool ReadStrmInfo(StrmInfo* pStrmInfo) const;
bool ReadAdpcmInfo(AdpcmInfo* pAdpcmInfo, int channels) const;
u32 GetAdpcBlockOffset() const {
if (IsAvailable()) {
return mHeader->adpcBlockOffset;
}
return 0;
}
private:
const StrmFile::Header* mHeader; // at 0x0
const StrmFile::HeadBlock* mHeadBlock; // at 0x4
};
class StrmFileLoader {
public:
explicit StrmFileLoader(ut::FileStream& rFileStream)
: mStream(rFileStream) {}
bool LoadFileHeader(void* pStrmBin, u32 size);
bool ReadAdpcBlockData(u16* pYN1, u16* pYN2, int block, int channels);
bool ReadStrmInfo(StrmInfo* pStrmInfo) const {
if (!mReader.IsAvailable()) {
return false;
}
return mReader.ReadStrmInfo(pStrmInfo);
}
bool ReadAdpcmInfo(AdpcmInfo* pAdpcmInfo, int channel) const {
if (!mReader.IsAvailable()) {
return false;
}
return mReader.ReadAdpcmInfo(pAdpcmInfo, channel);
}
private:
static const int HEADER_ALIGNED_SIZE =
ROUND_UP(sizeof(StrmFile::Header), 32);
private:
ut::FileStream& mStream; // at 0x0
StrmFileReader mReader; // at 0x4
};
} // namespace detail
} // namespace snd
} // namespace nw4r
#endif
+203 -36
View File
@@ -1,56 +1,223 @@
#ifndef NW4R_SND_STRMPLAYER_H
#define NW4R_SND_STRMPLAYER_H
#include "common.h"
#include "snd_BasicPlayer.h"
#include "snd_SoundThread.h"
#ifndef NW4R_SND_STRM_PLAYER_H
#define NW4R_SND_STRM_PLAYER_H
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_BasicPlayer.h>
#include <nw4r/snd/snd_InstancePool.h>
#include <nw4r/snd/snd_SoundThread.h>
#include <nw4r/snd/snd_StrmChannel.h>
#include <nw4r/snd/snd_StrmFile.h>
#include <nw4r/snd/snd_Task.h>
#include <nw4r/snd/snd_Voice.h>
#include <nw4r/ut.h>
#include <rvl/OS.h>
namespace nw4r {
namespace snd {
namespace detail {
struct StrmPlayer : BasicPlayer, SoundThread::PlayerCallback {
class StrmPlayer : public BasicPlayer, public SoundThread::PlayerCallback {
friend class StrmHeaderLoadTask;
friend class StrmDataLoadTask;
public:
enum StartOffsetType {
START_OFFSET_TYPE_SAMPLE,
START_OFFSET_TYPE_MILLISEC
};
virtual ~StrmPlayer(); // at 0x8
virtual bool Start(); // at 0xc
virtual void Stop(); // at 0x10
virtual void Pause(bool); // at 0x14
virtual bool IsActive() const; // at 0x18
virtual bool IsStarted() const; // at 0x1c
virtual bool IsPause() const; // at 0x20
struct StrmHeader {
// TODO: Why 8 if the player only supports 2???
static const int STRM_CHANNEL_MAX = 8;
virtual void OnUpdateFrameSoundThread(); // at 0xc
virtual void OnUpdateVoiceSoundThread(); // at 0x10
virtual void OnShutdownSoundThread(); // at 0x14
struct StrmDataLoadTask {
virtual ~StrmDataLoadTask();
virtual UNKTYPE Execute();
virtual UNKTYPE Cancel();
virtual UNKTYPE OnCancel();
StrmInfo strmInfo; // at 0x0
AdpcmInfo adpcmInfo[STRM_CHANNEL_MAX]; // at 0x38
u16 loopYn1[STRM_CHANNEL_MAX]; // at 0x1B8
u16 loopYn2[STRM_CHANNEL_MAX]; // at 0x1D8
};
struct StrmHeaderLoadTask {
virtual ~StrmHeaderLoadTask();
virtual UNKTYPE Execute();
virtual UNKTYPE Cancel();
virtual UNKTYPE OnCancel();
};
public:
StrmPlayer();
virtual ~StrmPlayer(); // at 0x8
virtual bool Start(); // at 0xc
virtual void Stop(); // at 0x10
virtual void Pause(bool flag); // at 0x14
virtual bool IsActive() const {
return mActiveFlag;
} // at 0x18
virtual bool IsStarted() const {
return mStartedFlag;
} // at 0x1c
virtual bool IsPause() const {
return mPauseFlag;
}; // at 0x20
virtual void OnUpdateFrameSoundThread() {
Update();
} // at 0xc
virtual void OnUpdateVoiceSoundThread() {
UpdateBuffer();
} // at 0x10
virtual void OnShutdownSoundThread() {
Stop();
} // at 0x14
bool IsPrepared() const {
return mIsPrepared;
return mPreparedFlag;
}
StrmPlayer();
bool Setup(StrmBufferPool *);
bool Prepare(ut::FileStream *, int, StartOffsetType, int);
void SetTaskErrorFlag() {
mTaskErrorFlag = true;
}
void SetTaskCancelFlag() {
mTaskCancelFlag = true;
}
bool Setup(StrmBufferPool* pBufferPool);
void Shutdown();
char UNK_D8[0x113 - 0xD8];
bool mIsPrepared; // at 0x113
char UNK_120[0x78C];
bool Prepare(ut::FileStream* pFileStream, int voices,
StartOffsetType offsetType, int offset);
void InitParam();
void Update();
private:
struct StrmHeaderLoadTask : public Task {
StrmHeaderLoadTask();
virtual void Execute(); // at 0xC
virtual void Cancel(); // at 0x10
virtual void OnCancel(); // at 0x14
StrmPlayer* strmPlayer; // at 0x10
ut::FileStream* fileStream; // at 0x14
StartOffsetType startOffsetType; // at 0x18
s32 startOffset; // at 0x1C
};
struct StrmDataLoadTask : public Task {
StrmDataLoadTask();
virtual void Execute(); // at 0xC
virtual void Cancel(); // at 0x10
virtual void OnCancel(); // at 0x14
StrmPlayer* strmPlayer; // at 0x10
ut::FileStream* fileStream; // at 0x14
u32 size; // at 0x18
s32 offset; // at 0x1C
u32 blockSize; // at 0x20
s32 bufferBlockIndex; // at 0x24
bool needUpdateAdpcmLoop; // at 0x28
NW4R_UT_LIST_NODE_DECL(); // at 0x2C
};
NW4R_UT_LIST_TYPEDEF_DECL(StrmDataLoadTask);
static const int DATA_BLOCK_COUNT_MIN = 4;
static const int DATA_BLOCK_COUNT_MAX = 32;
static const int DATA_BLOCK_SIZE_MAX = 0x2000;
// TODO: How is this calculated?
static const int LOAD_BUFFER_SIZE = 0x4000 + 32;
private:
bool LoadHeader(ut::FileStream* pFileStream, StartOffsetType offsetType,
int offset);
bool LoadStreamData(ut::FileStream* pFileStream, int offset, u32 size,
u32 blockSize, int blockIndex,
bool needUpdateAdpcmLoop);
bool SetupPlayer(const StrmHeader* pStrmHeader);
bool AllocChannels(int channels, int voices);
void FreeChannels();
void UpdateBuffer();
void UpdateLoopAddress(u32 startSample, u32 endSample);
void UpdatePlayingBlockIndex();
void UpdateDataLoopAddress(s32 endBlock);
void SetLoopEndToZeroBuffer(int endBlock);
void UpdateLoadingBlockIndex();
void UpdatePauseStatus();
int CalcLoadingBufferBlockCount() const;
bool CalcStartOffset(s32* pBlockIndex, u32* pBlockOffset, s32* pLoopCount);
static void VoiceCallbackFunc(Voice* pDropVoice,
Voice::VoiceCallbackStatus status,
void* pCallbackArg);
void SetAdpcmLoopContext(int channels, u16* pPredScale);
private:
StrmInfo mStrmInfo; // at 0x80
bool mSetupFlag; // at 0xB8
bool mActiveFlag; // at 0xB9
bool mStartedFlag; // at 0xBA
bool mPreparedFlag; // at 0xBB
bool mTaskErrorFlag; // at 0xBC
bool mTaskCancelFlag; // at 0xBD
bool mLoadingDelayFlag; // at 0xBE
bool mPauseFlag; // at 0xBF
bool mPauseStatus; // at 0xC0
bool mLoadWaitFlag; // at 0xC1
bool mNoRealtimeLoadFlag; // at 0xC2
bool mSkipUpdateAdpcmLoop; // at 0xC3
bool mValidAdpcmLoop; // at 0xC4
bool mPlayFinishFlag; // at 0xC5
bool mLoadFinishFlag; // at 0xC6
s32 mLoopCounter; // at 0xC8
int mPrepareCounter; // at 0xCC
int mChangeNumBlocks; // at 0xD0
int mDataBlockSize; // at 0xD4
int mBufferBlockCount; // at 0xD8
int mBufferBlockCountBase; // at 0xDC
int mLoadingBufferBlockCount; // at 0xE0
int mLoadingBufferBlockIndex; // at 0xE4
int mLoadingDataBlockIndex; // at 0xE8
int mPlayingBufferBlockCount; // at 0xEC
int mPlayingBufferBlockIndex; // at 0xF0
int mPlayingDataBlockIndex; // at 0xF4
int mLoopStartBlockIndex; // at 0xF8
int mLastBlockIndex; // at 0xFC
StartOffsetType mStartOffsetType; // at 0x100
int mStartOffset; // at 0x104
StrmHeaderLoadTask mStrmHeaderLoadTask; // at 0x108
StrmDataLoadTaskList mStrmDataLoadTaskList; // at 0x128
InstancePool<StrmDataLoadTask> mStrmDataLoadTaskPool; // at 0x134
StrmDataLoadTask mStrmDataLoadTaskArea[DATA_BLOCK_COUNT_MAX]; // at 0x138
StrmBufferPool* mBufferPool; // at 0x7B8
ut::FileStream* mFileStream; // at 0x7BC
Voice* mVoice; // at 0x7C0
s32 mChannelCount; // at 0x7C4
s32 mVoiceOutCount; // at 0x7C8
StrmChannel mChannels[CHANNEL_MAX]; // at 0x7CC
u16 mAdpcmLoopPredScale[CHANNEL_MAX]; // at 0x83C
u16 mAdpcmLoopYn1[CHANNEL_MAX]; // at 0x840
u16 mAdpcmLoopYn2[CHANNEL_MAX]; // at 0x844
static u8 sLoadBuffer[LOAD_BUFFER_SIZE] ALIGN(32);
static OSMutex sLoadBufferMutex;
static bool sStaticInitFlag;
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+58 -22
View File
@@ -1,33 +1,69 @@
#ifndef NW4R_SND_STRMSOUND_H
#define NW4R_SND_STRMSOUND_H
#include "common.h"
#include "snd_BasicSound.h"
#include "snd_StrmPlayer.h"
#include "ut_RuntimeTypeInfo.h"
#ifndef NW4R_SND_STRM_SOUND_H
#define NW4R_SND_STRM_SOUND_H
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_BasicSound.h>
#include <nw4r/snd/snd_StrmPlayer.h>
#include <nw4r/ut.h>
namespace nw4r {
namespace snd {
// Forward declarations
class StrmSoundHandle;
namespace detail {
struct StrmSound : BasicSound {
StrmPlayer mPlayer; // at 0xD8
StrmSoundHandle *mTempSpecialHandle; // at 0x920
SoundInstanceManager<StrmSound> *mManager; // at 0x924
StrmSound(SoundInstanceManager<StrmSound> *);
bool Prepare(StrmBufferPool *, StrmPlayer::StartOffsetType, s32, int, ut::FileStream *);
// Forward declarations
template <typename T> class SoundInstanceManager;
static ut::detail::RuntimeTypeInfo typeInfo;
class StrmSound : public BasicSound {
friend class StrmSoundHandle;
virtual const ut::detail::RuntimeTypeInfo *GetRuntimeTypeInfo() const; // at 0x8
virtual ~StrmSound(); // at 0xc
virtual UNKTYPE Shutdown(); // at 0x28
virtual bool IsPrepared() const; // at 0x2c
virtual void SetPlayerPriority(int); // at 0x4c
virtual bool IsAttachedTempSpecialHandle(); // at 0x5c
virtual UNKTYPE DetachTempSpecialHandle(); // at 0x60
virtual BasicPlayer *GetBasicPlayer(); // at 0x68
virtual const BasicPlayer *GetBasicPlayer() const; // at 0x6c
public:
NW4R_UT_RTTI_DECL(StrmSound);
public:
explicit StrmSound(SoundInstanceManager<StrmSound>* pManager);
virtual void Shutdown(); // at 0x28
virtual bool IsPrepared() const {
return mStrmPlayer.IsPrepared();
} // at 0x2C
virtual void SetPlayerPriority(int priority); // at 0x4C
virtual bool IsAttachedTempSpecialHandle(); // at 0x5C
virtual void DetachTempSpecialHandle(); // at 0x60
virtual BasicPlayer& GetBasicPlayer() {
return mStrmPlayer;
} // at 0x68
virtual const BasicPlayer& GetBasicPlayer() const {
return mStrmPlayer;
} // at 0x6C
bool Prepare(StrmBufferPool* pPool, StrmPlayer::StartOffsetType offsetType,
s32 offset, int voices, ut::FileStream* pStream);
void* GetFileStreamBuffer() {
return mFileStreamBuffer;
}
s32 GetFileStreamBufferSize() {
return sizeof(mFileStreamBuffer);
}
private:
static const int FILE_STREAM_BUFFER_SIZE = 512;
private:
StrmPlayer mStrmPlayer; // at 0xD8
StrmSoundHandle* mTempSpecialHandle; // at 0x920
SoundInstanceManager<StrmSound>* mManager; // at 0x924
char UNK_0x928[0x93C - 0x928];
char mFileStreamBuffer[FILE_STREAM_BUFFER_SIZE]; // at 0x93C
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+16 -9
View File
@@ -1,19 +1,26 @@
#ifndef NW4R_SND_STRMSOUNDHANDLE_H
#define NW4R_SND_STRMSOUNDHANDLE_H
#include "common.h"
#ifndef NW4R_SND_STRM_SOUND_HANDLE_H
#define NW4R_SND_STRM_SOUND_HANDLE_H
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_StrmSound.h>
#include <nw4r/ut.h>
namespace nw4r {
namespace snd {
struct StrmSoundHandle {
detail::StrmSound *mStrmSound; // at 0x0
inline StrmSoundHandle() : mStrmSound(NULL) {}
inline bool IsAttachedSound() {
return mStrmSound != NULL;
class StrmSoundHandle : private ut::NonCopyable {
public:
void DetachSound();
bool IsAttachedSound() {
return mSound != NULL;
}
void DetachSound();
private:
detail::StrmSound* mSound; // at 0x0
};
} // namespace snd
} // namespace nw4r
+19 -8
View File
@@ -1,22 +1,33 @@
#ifndef NW4R_SND_TASK_H
#define NW4R_SND_TASK_H
#include "common.h"
#include "ut_LinkList.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/ut.h>
namespace nw4r {
namespace snd {
namespace detail {
struct Task {
virtual ~Task(); // at 0x8
virtual void Execute() = 0; // at 0xc
class Task : private ut::NonCopyable {
friend class TaskManager;
public:
Task() : mBusyFlag(false) {}
virtual ~Task(); // at 0x8
virtual void Execute() = 0; // at 0xC
virtual void Cancel() = 0; // at 0x10
virtual void OnCancel() = 0; // at 0x14
ut::LinkListNode mNode; // at 0x4
char BYTE_0xC;
public:
NW4R_UT_LIST_NODE_DECL(); // at 0x4
inline Task() : BYTE_0xC() {}
private:
bool mBusyFlag; // at 0xC
};
NW4R_UT_LIST_TYPEDEF_DECL(Task);
} // namespace detail
} // namespace snd
} // namespace nw4r
+37 -29
View File
@@ -1,46 +1,54 @@
#ifndef NW4R_SND_TASK_MANAGER_H
#define NW4R_SND_TASK_MANAGER_H
#include "common.h"
#include "snd_Task.h"
#include "ut_LinkList.h"
#include "ut_lock.h"
#include <rvl/OS/OSThread.h>
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_Task.h>
#include <nw4r/ut.h>
#include <rvl/OS.h>
namespace nw4r {
namespace snd {
namespace detail {
struct TaskManager {
class TaskManager {
public:
enum TaskPriority {
PRIORITY_0 = 0,
PRIORITY_1 = 1,
PRIORITY_2 = 2
// PRIORITY_MAX = 3
PRIORITY_LOW = 0,
PRIORITY_MIDDLE = 1,
PRIORITY_HIGH = 2,
PRIORITY_MAX
};
inline TaskManager() : mTaskStacks(), WORD_0x24(0), BYTE_0x28(0) {
OSInitThreadQueue(&mQueue_0x2C);
OSInitThreadQueue(&mQueue_0x34);
}
public:
static TaskManager& GetInstance();
static TaskManager *GetInstance();
void AppendTask(Task* pTask, TaskPriority priority = PRIORITY_MIDDLE);
~TaskManager();
void AppendTask(Task *, TaskPriority);
Task *PopTask();
UNKTYPE GetNextTask();
UNKTYPE ExecuteTask();
UNKTYPE CancelTask(Task *);
UNKTYPE CancelAllTask();
UNKTYPE WaitTask();
UNKTYPE CancelWaitTask();
Task* ExecuteTask();
void CancelTask(Task* pTask);
void CancelAllTask();
ut::LinkList<Task, 4> mTaskStacks[3];
u32 WORD_0x24;
u8 BYTE_0x28;
OSThreadQueue mQueue_0x2C;
OSThreadQueue mQueue_0x34;
void WaitTask();
void CancelWaitTask();
private:
TaskManager();
Task* PopTask();
Task* GetNextTask();
Task* GetNextTask(TaskPriority priority, bool remove);
private:
TaskList mTaskList[PRIORITY_MAX]; // at 0x0
Task* volatile mCurrentTask; // at 0x24
bool mCancelWaitTaskFlag; // at 0x28
OSThreadQueue mAppendThreadQueue; // at 0x2C
OSThreadQueue mDoneThreadQueue; // at 0x34
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+19 -10
View File
@@ -1,24 +1,33 @@
#ifndef NW4R_SND_TASKTHREAD_H
#define NW4R_SND_TASKTHREAD_H
#include "common.h"
#include <rvl/OS/OSThread.h>
#ifndef NW4R_SND_TASK_THREAD_H
#define NW4R_SND_TASK_THREAD_H
#include <nw4r/types_nw4r.h>
#include <rvl/OS.h>
namespace nw4r {
namespace snd {
namespace detail {
struct TaskThread {
static void *ThreadFunc(void *);
class TaskThread {
public:
TaskThread();
~TaskThread();
bool Create(s32, void *, u32);
bool Create(s32 priority, void* pStack, u32 stackSize);
void Destroy();
private:
static void* ThreadFunc(void* pArg);
void ThreadProc();
private:
OSThread mThread; // at 0x0
void *mStackEnd; // at 0x318
bool mIsExiting; // at 0x31C
bool mIsAlive; // at 0x31D
u32* mStackEnd; // at 0x318
volatile bool mFinishFlag; // at 0x31C
bool mCreateFlag; // at 0x31D
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+79 -30
View File
@@ -1,63 +1,112 @@
#ifndef NW4R_SND_UTIL_H
#define NW4R_SND_UTIL_H
#include "common.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_Common.h>
namespace nw4r {
namespace snd {
namespace detail {
namespace Util {
enum PanCurve {
PAN_CURVE_SQRT,
PAN_CURVE_SINCOS,
PAN_CURVE_LINEAR,
};
struct PanInfo {
PanCurve curve; // at 0x0
bool centerZero; // at 0x4
bool zeroClamp; // at 0x5
PanInfo() : curve(PAN_CURVE_SQRT), centerZero(false), zeroClamp(false) {}
};
enum RefType {
REFTYPE_ADDRESS,
REFTYPE_OFFSET,
};
template <typename T0, typename T1, typename T2, typename T3>
enum DataType {
DATATYPE_T0,
DATATYPE_T1,
DATATYPE_T2,
DATATYPE_T3,
DATATYPE_INVALID
};
template <typename T0, typename T1 = void, typename T2 = void,
typename T3 = void>
struct DataRef {
u8 mType; // at 0x0
u8 BYTE_0x1;
u32 INT_0x4;
u8 refType; // at 0x0
u8 dataType; // at 0x1
u16 reserved; // at 0x2
u32 value; // at 0x4
};
template <typename T>
struct Table {
u32 mCount; // at 0x0
T mEntries[]; // at 0x4
};
struct PanInfo {
u32 mPanTableID; // 0x0, (PanTableTable)
bool BOOL_0x4;
bool BOOL_0x5;
template <typename T> struct Table {
u32 count; // at 0x0
T items[]; // at 0x4
};
template <typename T0, typename T1, typename T2, typename T3>
inline const T0 *GetDataRefAddress0(const DataRef<T0, T1, T2, T3> &dataRef, const void *ptr) {
return (const T0 *)GetDataRefAddressImpl((RefType)dataRef.mType, dataRef.INT_0x4, ptr);
inline const T0* GetDataRefAddress0(const DataRef<T0, T1, T2, T3>& rRef,
const void* pBase) {
return static_cast<const T0*>(GetDataRefAddressImpl(
static_cast<RefType>(rRef.refType), rRef.value, pBase));
}
template <typename T0, typename T1, typename T2, typename T3>
inline const T1 *GetDataRefAddress1(const DataRef<T0, T1, T2, T3> &dataRef, const void *ptr) {
return (const T1 *)GetDataRefAddressImpl((RefType)dataRef.mType, dataRef.INT_0x4, ptr);
inline const T1* GetDataRefAddress1(const DataRef<T0, T1, T2, T3>& rRef,
const void* pBase) {
return static_cast<const T1*>(GetDataRefAddressImpl(
static_cast<RefType>(rRef.refType), rRef.value, pBase));
}
template <typename T0, typename T1, typename T2, typename T3>
inline const T2 *GetDataRefAddress2(const DataRef<T0, T1, T2, T3> &dataRef, const void *ptr) {
return (const T2 *)GetDataRefAddressImpl((RefType)dataRef.mType, dataRef.INT_0x4, ptr);
inline const T2* GetDataRefAddress2(const DataRef<T0, T1, T2, T3>& rRef,
const void* pBase) {
return static_cast<const T2*>(GetDataRefAddressImpl(
static_cast<RefType>(rRef.refType), rRef.value, pBase));
}
template <typename T0, typename T1, typename T2, typename T3>
inline const T3 *GetDataRefAddress3(const DataRef<T0, T1, T2, T3> &dataRef, const void *ptr) {
return (const T3 *)GetDataRefAddressImpl((RefType)dataRef.mType, dataRef.INT_0x4, ptr);
inline const T3* GetDataRefAddress3(const DataRef<T0, T1, T2, T3>& rRef,
const void* pBase) {
return static_cast<const T3*>(GetDataRefAddressImpl(
static_cast<RefType>(rRef.refType), rRef.value, pBase));
}
f32 CalcPitchRatio(int);
f32 CalcVolumeRatio(f32);
f32 CalcPanRatio(f32, const PanInfo &);
f32 CalcSurroundPanRatio(f32, const PanInfo &);
int CalcLpfFreq(f32);
void GetRemoteFilterCoefs(int, u16 *, u16 *, u16 *, u16 *, u16 *);
#ifdef NW4R_LITLE_ENDIAN
inline u16 ReadBigEndian(u16 x) {
return x >> 8 | x << 8;
}
inline u32 ReadBigEndian(u32 x) {
return (x >> 24) & 0x000000FF | (x >> 8) & 0x0000FF00 |
(x << 8) & 0x00FF0000 | (x << 24) & 0xFF000000;
}
#else
inline u16 ReadBigEndian(u16 x) {
return x;
}
inline u32 ReadBigEndian(u32 x) {
return x;
}
#endif
f32 CalcPitchRatio(int pitch);
f32 CalcVolumeRatio(f32 db);
f32 CalcPanRatio(f32 pan, const PanInfo& rInfo);
f32 CalcSurroundPanRatio(f32 pan, const PanInfo& rInfo);
int CalcLpfFreq(f32 scale);
void GetRemoteFilterCoefs(int filter, u16* pB0, u16* pB1, u16* pB2, u16* pA1,
u16* pA2);
u16 CalcRandom();
const void *GetDataRefAddressImpl(RefType, u32, const void *);
const void* GetDataRefAddressImpl(RefType type, u32 value, const void* pBase);
} // namespace Util
} // namespace detail
} // namespace snd
+166 -29
View File
@@ -1,15 +1,35 @@
#ifndef NW4R_SND_VOICE_H
#define NW4R_SND_VOICE_H
#include "common.h"
#include "snd_AxManager.h"
#include "snd_Common.h"
#include "snd_WaveFile.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_AxVoice.h>
#include <nw4r/snd/snd_Common.h>
#include <nw4r/snd/snd_DisposeCallback.h>
#include <nw4r/ut.h>
#include <rvl/WPAD.h>
namespace nw4r {
namespace snd {
namespace detail {
struct Voice {
enum VoiceCallbackStatus { STATUS_0, STATUS_1, STATUS_2, STATUS_3 };
// Forward declarations
class WaveData;
class Voice : public DisposeCallback {
friend class VoiceManager;
public:
enum VoiceCallbackStatus {
CALLBACK_STATUS_FINISH_WAVE,
CALLBACK_STATUS_CANCEL,
CALLBACK_STATUS_DROP_VOICE,
CALLBACK_STATUS_DROP_DSP,
};
typedef void (*VoiceCallback)(Voice* pDropVoice, VoiceCallbackStatus status,
void* pCallbackArg);
enum VoiceSyncFlag {
SYNC_AX_SRC_INITIAL = (1 << 0),
@@ -22,34 +42,151 @@ struct Voice {
SYNC_AX_BIQUAD = (1 << 8),
};
typedef void (*VoiceCallback)(Voice *, VoiceCallbackStatus, void *);
static const int PRIORITY_MAX = 255;
UNKTYPE Start();
UNKTYPE Setup(const WaveData &, u32);
UNKTYPE SetPriority(int);
UNKTYPE Stop();
UNKTYPE Free();
UNKTYPE SetPanMode(PanMode);
UNKTYPE SetPanCurve(PanCurve);
UNKTYPE SetVolume(float);
UNKTYPE SetVeVolume(float, float);
UNKTYPE SetPitch(float);
UNKTYPE SetPan(float);
UNKTYPE SetSurroundPan(float);
UNKTYPE SetLpfFreq(float);
UNKTYPE SetRemoteFilter(int);
UNKTYPE SetOutputLine(int);
UNKTYPE SetMainOutVolume(float);
UNKTYPE SetMainSend(float);
public:
Voice();
virtual ~Voice(); // at 0x8
UNKTYPE SetFxSend(AuxBus, float);
virtual void InvalidateData(const void* /* pStart */,
const void* /* pEnd */) {} // at 0xC
UNKTYPE SetRemoteOutVolume(int, float);
UNKTYPE SetRemoteSend(int, float);
UNKTYPE SetRemoteFxSend(int, float);
virtual void InvalidateWaveData(const void* pStart,
const void* pEnd); // at 0x10
UNKTYPE Pause(bool);
int GetPriority() const {
return mPriority;
}
int GetAxVoiceCount() const {
return mChannelCount * mVoiceOutCount;
}
bool IsActive() const {
return mAxVoice[0][0] != NULL;
}
bool IsPlayFinished() const {
return IsActive() && mAxVoice[0][0]->IsPlayFinished();
}
void InitParam(int channels, int voices, VoiceCallback pCallback,
void* pCallbackArg);
void StopFinished();
void Calc();
void Update();
bool Acquire(int channels, int voices, int priority,
VoiceCallback pCallback, void* pCallbackArg);
void Free();
void Setup(const WaveData& rData, u32 offset);
void Start();
void Stop();
void Pause(bool flag);
AxVoice::Format GetFormat() const;
void SetVolume(f32 volume);
void SetVeVolume(f32 target, f32 init);
void SetPitch(f32 pitch);
void SetPanMode(PanMode mode);
void SetPanCurve(PanCurve curve);
void SetPan(f32 pan);
void SetSurroundPan(f32 pan);
void SetLpfFreq(f32 freq);
void SetRemoteFilter(int filter);
void SetOutputLine(int flag);
void SetMainOutVolume(f32 volume);
void SetMainSend(f32 send);
void SetFxSend(AuxBus bus, f32 send);
void SetRemoteOutVolume(int remote, f32 volume);
void SetRemoteSend(int remote, f32 send);
void SetRemoteFxSend(int remote, f32 send);
void SetPriority(int priority);
void UpdateVoicesPriority();
void SetAdpcmLoop(int channel, const AdpcmLoopParam* pParam);
u32 GetCurrentPlayingSample() const;
void SetLoopStart(int channel, const void* pBase, u32 samples);
void SetLoopEnd(int channel, const void* pBase, u32 samples);
void SetLoopFlag(bool loop);
void StopAtPoint(int channel, const void* pBase, u32 samples);
void SetVoiceType(AxVoice::VoiceType type);
void CalcAxSrc(bool initial);
void CalcAxVe();
bool CalcAxMix();
void CalcAxLpf();
void CalcAxRemoteFilter();
private:
static const int VOICES_MIN = 1;
static const int VOICES_MAX = 4;
private:
void SyncAxVoice();
void ResetDelta();
static void AxVoiceCallbackFunc(AxVoice* pVoice,
AxVoice::AxVoiceCallbackStatus status,
void* pCallbackArg);
void TransformDpl2Pan(f32* pPan, f32* pSurroundPan, f32 pan,
f32 surroundPan);
void CalcMixParam(int channel, int voice, AxVoice::MixParam* pMix,
AxVoice::RemoteMixParam* pRmtMix);
void RunAllAxVoice();
void StopAllAxVoice();
private:
AxVoice* mAxVoice[CHANNEL_MAX][VOICES_MAX]; // at 0xC
SoundParam mVoiceOutParam[VOICES_MAX]; // at 0x2C
int mChannelCount; // at 0x9C
int mVoiceOutCount; // at 0xA0
VoiceCallback mCallback; // at 0xA4
void* mCallbackArg; // at 0xA8
bool mIsActive; // at 0xAC
bool mIsStarting; // at 0xAD
bool mIsStarted; // at 0xAE
bool mIsPause; // at 0xAF
bool mIsPausing; // at 0xB0
u8 mSyncFlag; // at 0xB1
u8 mRemoteFilter; // at 0xB2
u8 mBiquadType; // at 0xB3
int mPriority; // at 0xB4
f32 mPan; // at 0xB8
f32 mSurroundPan; // at 0xBC
f32 mLpfFreq; // at 0xC0
int mOutputLineFlag; // at 0xC4
f32 mMainOutVolume; // at 0xC8
f32 mMainSend; // at 0xCC
f32 mFxSend[AUX_BUS_NUM]; // at 0xD0
f32 mRemoteOutVolume[WPAD_MAX_CONTROLLERS]; // at 0xDC
f32 mRemoteSend[WPAD_MAX_CONTROLLERS]; // at 0xEC
f32 mRemoteFxSend[WPAD_MAX_CONTROLLERS]; // at 0xFC
f32 mPitch; // at 0x10C
f32 mVolume; // at 0x110
f32 mVeInitVolume; // at 0x114
f32 mVeTargetVolume; // at 0x118
PanMode mPanMode; // at 0x11C
PanCurve mPanCurve; // at 0x120
public:
NW4R_UT_LIST_NODE_DECL(); // at 0x124
};
NW4R_UT_LIST_TYPEDEF_DECL(Voice);
} // namespace detail
} // namespace snd
} // namespace nw4r
+44 -6
View File
@@ -1,19 +1,57 @@
#ifndef NW4R_SND_VOICE_MANAGER_H
#define NW4R_SND_VOICE_MANAGER_H
#include "common.h"
#include "snd_Voice.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_Voice.h>
namespace nw4r {
namespace snd {
namespace detail {
struct VoiceManager {
static VoiceManager &GetInstance();
Voice *AllocVoice(int, int, int, Voice::VoiceCallback, void *);
class VoiceManager {
public:
static const int VOICE_MAX = AX_VOICE_MAX;
static const int WORK_SIZE_MAX = VOICE_MAX * sizeof(Voice);
public:
static VoiceManager& GetInstance();
u32 GetRequiredMemSize();
void Setup(void* pBuffer, u32 size);
void Shutdown();
void StopAllVoices();
Voice* AllocVoice(int channels, int voices, int priority,
Voice::VoiceCallback pCallback, void* pCallbackArg);
void FreeVoice(Voice* pVoice);
void UpdateAllVoices();
void NotifyVoiceUpdate();
UNKTYPE UpdateAllVoicesSync(u32);
void ChangeVoicePriority(Voice* pVoice);
void UpdateAllVoicesSync(u32 syncFlag);
const VoiceList& GetVoiceList() const {
return mPrioVoiceList;
}
private:
VoiceManager();
void AppendVoiceList(Voice* pVoice);
void RemoveVoiceList(Voice* pVoice);
void UpdateEachVoicePriority(const VoiceList::Iterator& rBegin,
const VoiceList::Iterator& rEnd);
int DropLowestPriorityVoice(int priority);
private:
bool mInitialized; // at 0x0
VoiceList mPrioVoiceList; // at 0x4
VoiceList mFreeVoiceList; // at 0x10
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+73 -13
View File
@@ -1,28 +1,88 @@
#ifndef NW4R_SND_WAVE_FILE_H
#define NW4R_SND_WAVE_FILE_H
#include "common.h"
#include "snd_Util.h"
#include "ut_binaryFileFormat.h"
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_AxVoice.h>
#include <nw4r/snd/snd_Common.h>
#include <nw4r/ut.h>
namespace nw4r {
namespace snd {
namespace detail {
namespace WaveFile {
enum Format { FORMAT_PCM8, FORMAT_PCM16, FORMAT_ADPCM };
struct WaveInfo {
u8 format; // at 0x0
u8 loopFlag; // at 0x1
u8 numChannels; // at 0x2
u8 sampleRate24; // at 0x3
u16 sampleRate; // at 0x4
u16 padding2; // at 0x6
u32 loopStart; // at 0x8
u32 loopEnd; // at 0xC
u32 channelInfoTableOffset; // at 0x10
u32 dataOffset; // at 0x14
u32 reserved; // at 0x18
};
struct WaveChannelInfo {
u32 channelDataOffset; // at 0x0
u32 adpcmOffset; // at 0x4
u32 volumeFrontLeft; // at 0x8
u32 volumeFrontRight; // at 0xC
u32 volumeRearLeft; // at 0x10
u32 volumeRearRight; // at 0x14
u32 reserved; // at 0x18
};
}; // namespace WaveFile
struct ChannelParam {
void* dataAddr; // at 0x0
u32 volumeFrontLeft; // at 0x4
u32 volumeFrontRight; // at 0x8
u32 volumeRearLeft; // at 0xC
u32 volumeRearRight; // at 0x10
AdpcmInfo adpcmInfo; // at 0x14
};
struct WaveData {
char UNK_0x0[0x2];
u8 BYTE_0x2;
char UNK_0x4[0x90];
u8 sampleFormat; // at 0x0
u8 loopFlag; // at 0x1
u8 numChannels; // at 0x2
u32 sampleRate; // at 0x4
u32 loopStart; // at 0x8
u32 loopEnd; // at 0xC
ChannelParam channelParam[CHANNEL_MAX]; // at 0x10
};
struct WaveFile {
struct WaveInfo {};
class WaveFileReader {
public:
explicit WaveFileReader(const WaveFile::WaveInfo* pWaveInfo);
typedef Util::DataRef<WaveInfo, void, void, void> Region;
bool ReadWaveParam(WaveData* pWaveData, const void* pWaveAddr) const;
static AxVoice::Format GetAxVoiceFormatFromWaveFileFormat(u32 format);
private:
const WaveFile::WaveInfo* mWaveInfo; // at 0x0
};
struct WaveFileReader {
WaveFileReader(const WaveFile::WaveInfo *);
bool ReadWaveParam(WaveData *, const void *) const;
};
inline AxVoice::Format WaveFormatToAxFormat(u32 format) {
if (format == WaveFile::FORMAT_PCM16) {
return AxVoice::FORMAT_PCM16;
}
if (format == WaveFile::FORMAT_PCM8) {
return AxVoice::FORMAT_PCM8;
}
return AxVoice::FORMAT_ADPCM;
}
} // namespace detail
} // namespace snd
} // namespace nw4r
+51 -25
View File
@@ -1,37 +1,63 @@
#ifndef NW4R_SND_WAVESOUND_H
#define NW4R_SND_WAVESOUND_H
#include "common.h"
#include "snd_BasicSound.h"
#include "snd_WsdPlayer.h"
#include "ut_RuntimeTypeInfo.h"
#ifndef NW4R_SND_WAVE_SOUND_H
#define NW4R_SND_WAVE_SOUND_H
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_BasicSound.h>
#include <nw4r/snd/snd_WsdPlayer.h>
#include <nw4r/ut.h>
namespace nw4r {
namespace snd {
// Forward declarations
class WaveSoundHandle;
namespace detail {
struct WaveSound : BasicSound {
WsdPlayer mPlayer; // at 0xD8
WaveSoundHandle *mTempSpecialHandle; // at 0x1B0
SoundInstanceManager<WaveSound> *mManager; // at 0x1B4
bool mIsPrepared; // at 0x1B8
WaveSound(SoundInstanceManager<WaveSound> *);
bool Prepare(const void *, s32, WsdPlayer::StartOffsetType, s32, int, const WsdPlayer::WsdCallback *, u32);
void SetChannelPriority(int);
void SetReleasePriorityFix(bool);
// Forward declarations
template <typename T> class SoundInstanceManager;
static ut::detail::RuntimeTypeInfo typeInfo;
class WaveSound : public BasicSound {
friend class WaveSoundHandle;
virtual const ut::detail::RuntimeTypeInfo *GetRuntimeTypeInfo() const; // at 0x8
virtual ~WaveSound(); // at 0xc
virtual UNKTYPE Shutdown(); // at 0x28
virtual bool IsPrepared() const; // at 0x2c
virtual void SetPlayerPriority(int); // at 0x4c
virtual bool IsAttachedTempSpecialHandle(); // at 0x5c
virtual UNKTYPE DetachTempSpecialHandle(); // at 0x60
virtual BasicPlayer *GetBasicPlayer(); // at 0x68
virtual const BasicPlayer *GetBasicPlayer() const; // at 0x6c
public:
NW4R_UT_RTTI_DECL(WaveSound);
public:
explicit WaveSound(SoundInstanceManager<WaveSound>* pManager);
virtual void Shutdown(); // at 0x28
virtual bool IsPrepared() const {
return mPreparedFlag;
} // at 0x2C
virtual void SetPlayerPriority(int priority); // at 0x4C
virtual bool IsAttachedTempSpecialHandle(); // at 0x5C
virtual void DetachTempSpecialHandle(); // at 0x60
virtual BasicPlayer& GetBasicPlayer() {
return mWsdPlayer;
} // at 0x68
virtual const BasicPlayer& GetBasicPlayer() const {
return mWsdPlayer;
} // at 0x6C
bool Prepare(const void* pWsdData, s32 wsdOffset,
WsdPlayer::StartOffsetType startType, s32 startOffset,
int voices, const WsdPlayer::WsdCallback* pCallback,
u32 callbackArg);
void SetChannelPriority(int priority);
void SetReleasePriorityFix(bool flag);
private:
WsdPlayer mWsdPlayer; // at 0xD8
WaveSoundHandle* mTempSpecialHandle; // at 0x1B0
SoundInstanceManager<WaveSound>* mManager; // at 0x1B4
bool mPreparedFlag; // at 0x1B8
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+19 -8
View File
@@ -1,19 +1,30 @@
#ifndef NW4R_SND_WAVESOUNDHANDLE_H
#define NW4R_SND_WAVESOUNDHANDLE_H
#include "common.h"
#ifndef NW4R_SND_WAVE_SOUND_HANDLE_H
#define NW4R_SND_WAVE_SOUND_HANDLE_H
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_WaveSound.h>
#include <nw4r/ut.h>
namespace nw4r {
namespace snd {
struct WaveSoundHandle {
detail::WaveSound *mWaveSound; // at 0x0
inline WaveSoundHandle() : mWaveSound(NULL) {}
inline bool IsAttachedSound() {
return mWaveSound != NULL;
class WaveSoundHandle : private ut::NonCopyable {
public:
~WaveSoundHandle() {
DetachSound();
}
void DetachSound();
bool IsAttachedSound() const {
return mSound != NULL;
}
private:
detail::WaveSound* mSound; // at 0x0
};
} // namespace snd
} // namespace nw4r
+133
View File
@@ -0,0 +1,133 @@
#ifndef NW4R_SND_WSD_FILE_H
#define NW4R_SND_WSD_FILE_H
#include <nw4r/snd/snd_Util.h>
#include <nw4r/ut.h>
namespace nw4r {
namespace snd {
namespace detail {
namespace WsdFile {
struct WsdInfo {
f32 pitch; // at 0x0
u8 pan; // at 0x4
u8 surroundPan; // at 0x5
u8 fxSendA; // at 0x6
u8 fxSendB; // at 0x7
u8 fxSendC; // at 0x8
u8 mainSend; // at 0x9
Util::DataRef<UNKTYPE> graphEnvTableRef; // at 0xC
Util::DataRef<UNKTYPE> randomizerTableRef; // at 0x14
u32 reserved; // at 0x1C
};
struct TrackInfo {};
struct NoteInfo {
s32 waveIndex; // at 0x0
u8 attack; // at 0x4
u8 decay; // at 0x5
u8 sustain; // at 0x6
u8 release; // at 0x7
u16 hold; // at 0x8
u16 padding; // at 0xA
u8 originalKey; // at 0xC
u8 volume; // at 0xD
u8 pan; // at 0xE
u8 surroundPan; // at 0xF
f32 pitch; // at 0x10
Util::DataRef<UNKTYPE> lfoTableRef; // at 0x14
Util::DataRef<UNKTYPE> graphEnvTablevRef; // at 0x1C
Util::DataRef<UNKTYPE> randomizerTableRef; // at 0x24
u32 reserved; // at 0x2C
};
typedef Util::Table<Util::DataRef<TrackInfo> > TrackTable;
typedef Util::Table<Util::DataRef<NoteInfo> > NoteTable;
struct Wsd {
Util::DataRef<WsdInfo> refWsdInfo; // at 0x0
Util::DataRef<TrackTable> refTrackTable; // at 0x8
Util::DataRef<NoteTable> refNoteTable; // at 0x10
};
struct Header {
ut::BinaryFileHeader fileHeader; // at 0x0
u32 dataBlockOffset; // at 0x10
u32 dataBlockSize; // at 0x14
u32 waveBlockOffset; // at 0x18
u32 waveBlockSize; // at 0x1C
};
struct DataBlock {
ut::BinaryBlockHeader blockHeader; // at 0x0
u32 wsdCount; // at 0x8
Util::DataRef<Wsd> refWsd[]; // at 0xC
};
struct WaveBlock {
ut::BinaryBlockHeader blockHeader; // at 0x0
u32 waveCount; // at 0x8
u32 offsetTable[]; // at 0xC
};
// <= NW4R_VERSION(1, 0)
struct WaveBlockOld {
ut::BinaryBlockHeader blockHeader; // at 0x0
u32 offsetTable[]; // at 0x8
};
}; // namespace WsdFile
struct WaveSoundInfo {
f32 pitch; // at 0x0
u8 pan; // at 0x4
u8 surroundPan; // at 0x5
u8 fxSendA; // at 0x6
u8 fxSendB; // at 0x7
u8 fxSendC; // at 0x8
u8 mainSend; // at 0x9
};
struct WaveSoundNoteInfo {
s32 waveIndex; // at 0x0
u8 attack; // at 0x4
u8 decay; // at 0x6
u8 sustain; // at 0x7
u8 release; // at 0x8
u8 originalKey; // at 0x9
u8 pan; // at 0xA
u8 surroundPan; // at 0xB
u8 volume; // at 0xC
f32 pitch; // at 0x10
};
class WsdFileReader {
public:
static const u32 SIGNATURE = 'RWSD';
static const int VERSION = NW4R_VERSION(1, 2);
public:
explicit WsdFileReader(const void* pWsdBin);
bool IsValidFileHeader(const void* pWsdBin);
bool ReadWaveSoundInfo(WaveSoundInfo* pSoundInfo, int id) const;
bool ReadWaveSoundNoteInfo(WaveSoundNoteInfo* pSoundNoteInfo, int id,
int note) const;
bool ReadWaveParam(int id, WaveData* pWaveData,
const void* pWaveAddr) const;
private:
const WsdFile::Header* mHeader; // at 0x0
const WsdFile::DataBlock* mDataBlock; // at 0x4
const WsdFile::WaveBlock* mWaveBlock; // at 0x8
};
} // namespace detail
} // namespace snd
} // namespace nw4r
#endif
+129 -32
View File
@@ -1,45 +1,142 @@
#ifndef NW4R_SND_WSDPLAYER_H
#define NW4R_SND_WSDPLAYER_H
#include "common.h"
#include "snd_BasicPlayer.h"
#include "snd_DisposeCallback.h"
#include "snd_Lfo.h"
#include "snd_SoundThread.h"
#ifndef NW4R_SND_WSD_PLAYER_H
#define NW4R_SND_WSD_PLAYER_H
#include <nw4r/types_nw4r.h>
#include <nw4r/snd/snd_BasicPlayer.h>
#include <nw4r/snd/snd_Channel.h>
#include <nw4r/snd/snd_DisposeCallback.h>
#include <nw4r/snd/snd_Lfo.h>
#include <nw4r/snd/snd_SoundThread.h>
#include <nw4r/snd/snd_WsdFile.h>
#include <nw4r/ut.h>
namespace nw4r {
namespace snd {
namespace detail {
struct WsdPlayer : BasicPlayer, DisposeCallback, SoundThread::PlayerCallback {
class WsdPlayer : public BasicPlayer,
public DisposeCallback,
public SoundThread::PlayerCallback {
public:
class WsdCallback {
public:
virtual ~WsdCallback() {} // at 0x8
virtual bool GetWaveSoundData(WaveSoundInfo* pSoundInfo,
WaveSoundNoteInfo* pNoteInfo,
WaveData* pWaveData, const void* pWsdData,
int index, int noteIndex,
u32 callbackArg) const = 0; // at 0xC
};
enum StartOffsetType {
};
virtual ~WsdPlayer() {} // at 0x8
virtual bool Start(); // at 0xc
virtual void Stop(); // at 0x10
virtual void Pause(bool); // at 0x14
virtual bool IsActive() const; // at 0x18
virtual bool IsStarted() const; // at 0x1c
virtual bool IsPause() const; // at 0x20
virtual void OnUpdateFrameSoundThread(); // at 0xc
virtual void OnUpdateVoiceSoundThread(); // at 0x10
virtual void OnShutdownSoundThread(); // at 0x14
virtual void InvalidateData(const void *, const void *); // at 0xc
virtual void InvalidateWaveData(const void *, const void *); // at 0x10
struct WsdCallback {
virtual ~WsdCallback();
START_OFFSET_TYPE_SAMPLE,
START_OFFSET_TYPE_MILLISEC
};
public:
WsdPlayer();
bool Prepare(const void *, int, WsdPlayer::StartOffsetType, int, int, const WsdPlayer::WsdCallback *, u32);
void SetChannelPriority(int);
void SetReleasePriorityFix(bool);
char UNK_0xE4[0x4C];
virtual bool Start(); // at 0xC
virtual void Stop(); // at 0x10
virtual void Pause(bool flag); // at 0x14
virtual bool IsActive() const {
return mActiveFlag != 0;
} // at 0x18
virtual bool IsStarted() const {
return mStartedFlag != 0;
} // at 0x1C
virtual bool IsPause() const {
return mPauseFlag != 0;
} // at 0x20
virtual void InvalidateData(const void* pStart,
const void* pEnd); // at 0x50
virtual void InvalidateWaveData(const void* /* pStart */,
const void* /* pEnd */) {} // at 0x54
virtual void OnUpdateFrameSoundThread() {
Update();
} // at 0x58
virtual void OnShutdownSoundThread() {
Stop();
} // at 0x60
void InitParam(int voices, const WsdCallback* pCallback, u32 callbackArg);
bool Prepare(const void* pWsdData, int index, StartOffsetType startType,
int startOffset, int voices, const WsdCallback* pCallback,
u32 callbackArg);
void SetChannelPriority(int priority);
void SetReleasePriorityFix(bool flag);
f32 GetPanRange() const {
return mPanRange;
}
int GetVoiceOutCount() const {
return mVoiceOutCount;
}
int GetChannelPriority() const {
return mPriority;
}
const void* GetWsdDataAddress() const {
return mWsdData;
}
bool IsChannelActive() const {
return mChannel != NULL && mChannel->IsActive();
}
private:
static const int DEFAULT_PRIORITY = 64;
private:
void FinishPlayer();
void Update();
bool StartChannel(const WsdCallback* pCallback, u32 callbackArg);
void CloseChannel();
void UpdateChannel();
static void ChannelCallbackFunc(Channel* pDropChannel,
Channel::ChannelCallbackStatus status,
u32 callbackArg);
private:
bool mActiveFlag; // at 0x8C
bool mStartedFlag; // at 0x8D
bool mPauseFlag; // at 0x8E
bool mWavePlayFlag; // at 0x8F
bool mReleasePriorityFixFlag; // at 0x90
f32 mPanRange; // at 0x94
int mVoiceOutCount; // at 0x98
u8 mPriority; // at 0x9C
const WsdCallback* mCallback; // at 0xA0
u32 mCallbackData; // at 0xA4
const void* mWsdData; // at 0xA8
int mWsdIndex; // at 0xAC
StartOffsetType mStartOffsetType; // at 0xB0
int mStartOffset; // at 0xB4
LfoParam mLfoParam; // at 0xB8
WaveSoundInfo mWaveSoundInfo; // at 0xC8
Channel* mChannel; // at 0xD4
};
} // namespace detail
} // namespace snd
} // namespace nw4r
+2 -1
View File
@@ -1,13 +1,14 @@
#ifndef NW4R_SND_ADPCM_H
#define NW4R_SND_ADPCM_H
#include <nw4r/types_nw4r.h>
#include <rvl/AX.h>
namespace nw4r {
namespace snd {
namespace detail {
s16 DecodeDspAdpcm(AXPBADPCM *adpcm, u8 bits);
s16 DecodeDspAdpcm(AXPBADPCM* pAdpcm, u8 bits);
} // namespace detail
} // namespace snd
+2 -2
View File
@@ -9,8 +9,8 @@ namespace ut {
class FileStream : public IOStream {
public:
NW4R_UT_RTTI_DECL(FileStream);
enum SeekOrigin { SEEK_BEG, SEEK_CUR, SEEK_END };
enum SeekOrigin { SEEKORG_BEG, SEEKORG_CUR, SEEKORG_END };
class FilePosition {
public:
+27 -35
View File
@@ -9,29 +9,24 @@ namespace {
/**
* Value operations
*/
template <typename T>
inline T Max(T t1, T t2) {
template <typename T> inline T Max(T t1, T t2) {
return (t1 < t2) ? t2 : t1;
}
template <typename T>
inline T Min(T t1, T t2) {
template <typename T> inline T Min(T t1, T t2) {
return (t1 > t2) ? t2 : t1;
}
template <typename T>
inline T Clamp(T value, T min, T max) {
template <typename T> inline T Clamp(T value, T min, T max) {
return value > max ? max : (value < min ? min : value);
}
template <typename T>
inline T Abs(T x) {
template <typename T> inline T Abs(T x) {
// Static cast needed to break abs optimization during instruction selection
return x < 0 ? static_cast<T>(-x) : static_cast<T>(x);
}
template <>
f32 inline Abs(register f32 x) {
template <> f32 inline Abs(register f32 x) {
register f32 ax;
// clang-format off
@@ -46,62 +41,59 @@ f32 inline Abs(register f32 x) {
/**
* Bit operations
*/
template <typename T>
inline T BitExtract(T bits, int pos, int len) {
template <typename T> inline T BitExtract(T bits, int pos, int len) {
T mask = (1 << len) - 1;
return (bits >> pos) & mask;
}
template <typename T>
inline bool TestBit(T t, int bitIndexLSB) {
return BitExtract<T>(t, sizeof(T), bitIndexLSB);
template <typename T> inline bool TestBit(T t, int pos) {
return BitExtract<T>(t, sizeof(T), pos);
}
/**
* Pointer operations
*/
inline u32 GetIntPtr(const void *ptr) {
return reinterpret_cast<u32>(ptr);
inline u32 GetIntPtr(const void* pPtr) {
return reinterpret_cast<u32>(pPtr);
}
template <typename T>
inline const void *AddOffsetToPtr(const void *ptr, T offset) {
return reinterpret_cast<const void *>(GetIntPtr(ptr) + offset);
inline const void* AddOffsetToPtr(const void* pBase, T offset) {
return reinterpret_cast<const void*>(GetIntPtr(pBase) + offset);
}
template <typename T> inline void* AddOffsetToPtr(void* pBase, T offset) {
return reinterpret_cast<void*>(GetIntPtr(pBase) + offset);
}
inline s32 GetOffsetFromPtr(const void *start, const void *end) {
return static_cast<s32>(GetIntPtr(end) - GetIntPtr(start));
inline s32 GetOffsetFromPtr(const void* pStart, const void* pEnd) {
return static_cast<s32>(GetIntPtr(pEnd) - GetIntPtr(pStart));
}
inline int ComparePtr(const void *p1, const void *p2) {
return static_cast<int>(GetIntPtr(p1) - GetIntPtr(p2));
inline int ComparePtr(const void* pPtr1, const void* pPtr2) {
return static_cast<int>(GetIntPtr(pPtr1) - GetIntPtr(pPtr2));
}
/**
* Rounding
*/
template <typename T>
inline T RoundUp(T t, unsigned int alignment) {
template <typename T> inline T RoundUp(T t, unsigned int alignment) {
return (alignment + t - 1) & ~(alignment - 1);
}
template <typename T>
inline void *RoundUp(T *t, unsigned int alignment) {
u32 value = reinterpret_cast<u32>(t);
template <typename T> inline void* RoundUp(T* pPtr, unsigned int alignment) {
u32 value = reinterpret_cast<u32>(pPtr);
u32 rounded = (alignment + value - 1) & ~(alignment - 1);
return reinterpret_cast<void *>(rounded);
return reinterpret_cast<void*>(rounded);
}
template <typename T>
inline T RoundDown(T t, unsigned int alignment) {
template <typename T> inline T RoundDown(T t, unsigned int alignment) {
return t & ~(alignment - 1);
}
template <typename T>
inline void *RoundDown(T *t, unsigned int alignment) {
u32 value = reinterpret_cast<u32>(t);
template <typename T> inline void* RoundDown(T* pPtr, unsigned int alignment) {
u32 value = reinterpret_cast<u32>(pPtr);
u32 rounded = value & ~(alignment - 1);
return reinterpret_cast<void *>(rounded);
return reinterpret_cast<void*>(rounded);
}
} // namespace
+5 -5
View File
@@ -4,11 +4,11 @@
extern "C" {
#endif
#include "rvl/MEM/mem_heapCommon.h"
#include "rvl/MEM/mem_allocator.h"
#include "rvl/MEM/mem_expHeap.h"
#include "rvl/MEM/mem_frameHeap.h"
#include "rvl/MEM/mem_list.h"
#include <rvl/MEM/mem_allocator.h>
#include <rvl/MEM/mem_expHeap.h>
#include <rvl/MEM/mem_frameHeap.h>
#include <rvl/MEM/mem_heapCommon.h>
#include <rvl/MEM/mem_list.h>
#ifdef __cplusplus
}
+4
View File
@@ -5,6 +5,10 @@
extern "C" {
#endif
#define MEM_EXP_HEAP_MIN_SIZE \
(sizeof(MEMiHeapHead) + sizeof(MEMiExpHeapHead) + \
sizeof(MEMiExpHeapMBlock) + 4)
// Forward declarations
typedef struct MEMiHeapHead;
+9 -1
View File
@@ -5,11 +5,19 @@
extern "C" {
#endif
#define MEM_FRM_HEAP_MIN_SIZE (sizeof(MEMiHeapHead) + sizeof(MEMiFrmHeapHead))
// Forward declarations
typedef struct MEMiHeapHead;
// Specify how to free memory
typedef enum { MEM_FRM_HEAP_FREE_TO_HEAD = (1 << 0), MEM_FRM_HEAP_FREE_TO_TAIL = (1 << 1) } MEMiFrmFreeFlag;
typedef enum {
MEM_FRM_HEAP_FREE_TO_HEAD = (1 << 0),
MEM_FRM_HEAP_FREE_TO_TAIL = (1 << 1),
MEM_FRM_HEAP_FREE_ALL =
MEM_FRM_HEAP_FREE_TO_HEAD | MEM_FRM_HEAP_FREE_TO_TAIL
} MEMiFrmFreeFlag;
typedef struct MEMiFrmHeapState {
u32 id; // at 0x0
+13 -1
View File
@@ -2,7 +2,9 @@
#define RVL_SDK_MEM_HEAP_COMMON_H
#include "rvl/MEM/mem_list.h"
#include "rvl/OS.h"
#include <MSL_C/string.h>
#include <common.h>
// #include "string.h"
#ifdef __cplusplus
extern "C" {
@@ -73,12 +75,22 @@ static inline void LockHeap(MEMiHeapHead *heap) {
}
}
static inline void UnlockHeap(MEMiHeapHead *heap) {
static void UnlockHeap(MEMiHeapHead* heap) {
if (GetOptForHeap(heap) & MEM_HEAP_OPT_CAN_LOCK) {
OSUnlockMutex(&heap->mutex);
}
}
static void FillAllocMemory(MEMiHeapHead* heap, void* memBlock, u32 size) {
if (GetOptForHeap(heap) & MEM_HEAP_OPT_CLEAR_ALLOC) {
memset(memBlock, 0, size);
}
}
static s32 MEMGetHeapTotalSize(MEMiHeapHead* heap) {
return GetOffsetFromPtr(heap, heap->end);
}
static void FillAllocMemory(MEMiHeapHead *heap, void *memBlock, u32 size);
#ifdef __cplusplus
+12
View File
@@ -0,0 +1,12 @@
#ifndef RVL_SDK_PUBLIC_WENC_H
#define RVL_SDK_PUBLIC_WENC_H
#ifdef __cplusplus
extern "C" {
#endif
#include <rvl/WENC/wenc.h>
#ifdef __cplusplus
}
#endif
#endif
+28
View File
@@ -0,0 +1,28 @@
#ifndef RVL_SDK_WENC_H
#define RVL_SDK_WENC_H
#include <common.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
WENC_FLAG_USER_INFO = (1 << 0),
} WENCFlag;
typedef struct WENCInfo {
s32 xn; // at 0x0
s32 dl; // at 0x4
s32 qn; // at 0x8
s32 dn; // at 0xC
s32 dlh; // at 0x10
s32 dlq; // at 0x14
u8 padding[8]; // at 0x18
} WENCInfo;
s32 WENCGetEncodeData(WENCInfo* info, u32 flag, const s16* pcmData, s32 samples,
u8* adpcmData);
#ifdef __cplusplus
}
#endif
#endif
+1
View File
@@ -0,0 +1 @@
// #include <nw4r/snd/snd_AnimSound.h>
+1
View File
@@ -0,0 +1 @@
#include <nw4r/snd/snd_AxManager.h>
+1
View File
@@ -0,0 +1 @@
#include <nw4r/snd/snd_AxVoice.h>
+1
View File
@@ -0,0 +1 @@
#include <nw4r/snd/snd_AxVoiceManager.h>
+1
View File
@@ -0,0 +1 @@
#include <nw4r/snd/snd_AxfxImpl.h>
+1
View File
@@ -0,0 +1 @@
#include <nw4r/snd/snd_Bank.h>
+1
View File
@@ -0,0 +1 @@
#include <nw4r/snd/snd_BankFile.h>
+1
View File
@@ -0,0 +1 @@
#include <nw4r/snd/snd_BasicPlayer.h>
+1
View File
@@ -0,0 +1 @@
#include <nw4r/snd/snd_BasicSound.h>
+1
View File
@@ -0,0 +1 @@
// #include <nw4r/snd/snd_BiquadFilterPreset.h>

Some files were not shown because too many files have changed in this diff Show More