From 500a40c7aaf1ba7850df33293170d1faabea1866 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 23 Aug 2026 18:13:57 -0400 Subject: [PATCH 001/785] atk: Add `nn::atk` header files Filenames are based on DWARF info from the `.nss` inside Bloons TD5's romFS --- CMakeLists.txt | 137 ++++++++++++++++-- include/nn/atk/atk_Adpcm.h | 0 .../atk/atk_AudioRendererPerformanceReader.h | 0 include/nn/atk/atk_BiquadFilterCallback.h | 0 include/nn/atk/atk_ChannelMixVolume.h | 0 include/nn/atk/atk_DeviceOutRecorder.h | 0 include/nn/atk/atk_EffectAux.h | 0 include/nn/atk/atk_EffectBase.h | 0 include/nn/atk/atk_FinalMix.h | 0 include/nn/atk/atk_FsSoundArchive.h | 0 include/nn/atk/atk_Global.h | 0 include/nn/atk/atk_OutputMixer.h | 0 include/nn/atk/atk_OutputReceiver.h | 0 include/nn/atk/atk_ProfileReader.h | 0 include/nn/atk/atk_SequenceSoundHandle.h | 0 include/nn/atk/atk_SoundActor.h | 0 include/nn/atk/atk_SoundArchive.h | 0 ...chivePlayer.h => atk_SoundArchivePlayer.h} | 10 +- ...ndDataManager.h => atk_SoundDataManager.h} | 0 include/nn/atk/atk_SoundHandle.h | 0 include/nn/atk/atk_SoundHeap.h | 0 include/nn/atk/atk_SoundMemoryAllocatable.h | 0 .../atk/{SoundPlayer.h => atk_SoundPlayer.h} | 0 include/nn/atk/atk_SoundStartable.h | 0 include/nn/atk/atk_SoundSystem.h | 0 include/nn/atk/atk_StreamSoundHandle.h | 0 include/nn/atk/atk_SubMix.h | 0 include/nn/atk/atk_TaskProfileReader.h | 0 .../detail/atk_AddonSoundArchiveContainer.h | 0 include/nn/atk/detail/atk_AdvancedWaveSound.h | 0 .../nn/atk/detail/atk_AdvancedWaveSoundFile.h | 0 .../detail/atk_AdvancedWaveSoundFileReader.h | 0 ...ntime.h => atk_AdvancedWaveSoundRuntime.h} | 0 include/nn/atk/detail/atk_BankFile.h | 0 include/nn/atk/detail/atk_BankFileReader.h | 0 .../detail/{BasicSound.h => atk_BasicSound.h} | 0 include/nn/atk/detail/atk_BinaryFileFormat.h | 0 include/nn/atk/detail/atk_BinaryTypes.h | 0 .../nn/atk/detail/atk_BiquadFilterPresets.h | 0 .../nn/atk/detail/atk_BusMixVolumePacket.h | 0 include/nn/atk/detail/atk_Command.h | 0 include/nn/atk/detail/atk_CommandManager.h | 0 include/nn/atk/detail/atk_Config.h | 0 include/nn/atk/detail/atk_CurveAdshr.h | 0 include/nn/atk/detail/atk_CurveLfo.h | 0 include/nn/atk/detail/atk_Debug.h | 0 include/nn/atk/detail/atk_DriverCommand.h | 0 include/nn/atk/detail/atk_DspadpcmReader.h | 0 include/nn/atk/detail/atk_ElementType.h | 0 .../nn/atk/detail/atk_ExternalSoundPlayer.h | 0 include/nn/atk/detail/atk_FrameHeap.h | 0 include/nn/atk/detail/atk_GroupFile.h | 0 include/nn/atk/detail/atk_GroupFileReader.h | 0 .../nn/atk/detail/atk_IRegionInfoReadable.h | 0 .../nn/atk/detail/atk_IStreamDataDecoder.h | 0 include/nn/atk/detail/atk_InstancePool.h | 0 include/nn/atk/detail/atk_IntrusiveList.h | 0 include/nn/atk/detail/atk_ItemType.h | 0 include/nn/atk/detail/atk_LoaderManager.h | 0 include/nn/atk/detail/atk_LowLevelVoice.h | 0 include/nn/atk/detail/atk_MemoryFileStream.h | 0 include/nn/atk/detail/atk_MoveValue.h | 0 .../nn/atk/detail/atk_OutputAdditionalParam.h | 0 include/nn/atk/detail/atk_PlayerHeap.h | 0 .../nn/atk/detail/atk_PlayerHeapDataManager.h | 0 include/nn/atk/detail/atk_RegionManager.h | 0 include/nn/atk/detail/atk_SequenceSound.h | 0 include/nn/atk/detail/atk_SequenceSoundFile.h | 0 .../atk/detail/atk_SequenceSoundFileReader.h | 0 ...ndRuntime.h => atk_SequenceSoundRuntime.h} | 0 include/nn/atk/detail/atk_SoundArchiveFile.h | 0 .../atk/detail/atk_SoundArchiveFileReader.h | 0 .../nn/atk/detail/atk_SoundArchiveLoader.h | 0 ...iveManager.h => atk_SoundArchiveManager.h} | 0 .../nn/atk/detail/atk_SoundInstanceManager.h | 0 .../nn/atk/detail/atk_SoundRuntimeUtility.h | 0 include/nn/atk/detail/atk_StartInfoReader.h | 0 include/nn/atk/detail/atk_StreamSound.h | 0 include/nn/atk/detail/atk_StreamSoundFile.h | 0 .../nn/atk/detail/atk_StreamSoundFileLoader.h | 0 .../nn/atk/detail/atk_StreamSoundFileReader.h | 0 .../atk/detail/atk_StreamSoundPrefetchFile.h | 0 .../atk_StreamSoundPrefetchFileReader.h | 0 ...oundRuntime.h => atk_StreamSoundRuntime.h} | 0 include/nn/atk/detail/atk_Task.h | 0 include/nn/atk/detail/atk_TaskManager.h | 0 include/nn/atk/detail/atk_TaskThread.h | 0 include/nn/atk/detail/atk_ThreadInfoReader.h | 0 include/nn/atk/detail/atk_Util.h | 0 include/nn/atk/detail/atk_ValueArray.h | 0 include/nn/atk/detail/atk_Voice.h | 0 include/nn/atk/detail/atk_VoiceCommand.h | 0 .../atk/detail/atk_VolumeThroughModePacket.h | 0 include/nn/atk/detail/atk_WavBinary.h | 0 include/nn/atk/detail/atk_WavOutFileStream.h | 0 include/nn/atk/detail/atk_WaveArchiveFile.h | 0 .../nn/atk/detail/atk_WaveArchiveFileReader.h | 0 include/nn/atk/detail/atk_WaveFile.h | 0 include/nn/atk/detail/atk_WaveFileReader.h | 0 include/nn/atk/detail/atk_WaveSound.h | 0 include/nn/atk/detail/atk_WaveSoundFile.h | 0 .../nn/atk/detail/atk_WaveSoundFileReader.h | 0 ...eSoundRuntime.h => atk_WaveSoundRuntime.h} | 0 .../driver/atk_AdvancedWaveSoundPlayer.h | 0 include/nn/atk/detail/driver/atk_Bank.h | 0 .../atk/detail/driver/atk_BasicSoundPlayer.h | 0 include/nn/atk/detail/driver/atk_Channel.h | 0 .../nn/atk/detail/driver/atk_ChannelManager.h | 0 .../atk/detail/driver/atk_DisposeCallback.h | 0 .../driver/atk_DisposeCallbackManager.h | 0 .../atk/detail/driver/atk_HardwareManager.h | 0 include/nn/atk/detail/driver/atk_MmlCommand.h | 0 include/nn/atk/detail/driver/atk_MmlParser.h | 0 .../atk/detail/driver/atk_MmlSequenceTrack.h | 0 .../driver/atk_MmlSequenceTrackAllocator.h | 0 include/nn/atk/detail/driver/atk_MultiVoice.h | 0 .../atk/detail/driver/atk_MultiVoiceManager.h | 0 .../nn/atk/detail/driver/atk_NoteOnCallback.h | 0 .../detail/driver/atk_SequenceSoundPlayer.h | 0 .../nn/atk/detail/driver/atk_SequenceTrack.h | 0 .../driver/atk_SequenceTrackAllocator.h | 0 .../nn/atk/detail/driver/atk_SoundThread.h | 0 .../atk/detail/driver/atk_StreamBufferPool.h | 0 .../atk/detail/driver/atk_StreamSoundLoader.h | 0 .../atk/detail/driver/atk_StreamSoundPlayer.h | 0 .../nn/atk/detail/driver/atk_StreamTrack.h | 0 .../atk/detail/driver/atk_WaveSoundLoader.h | 0 .../atk/detail/driver/atk_WaveSoundPlayer.h | 0 128 files changed, 132 insertions(+), 15 deletions(-) create mode 100644 include/nn/atk/atk_Adpcm.h create mode 100644 include/nn/atk/atk_AudioRendererPerformanceReader.h create mode 100644 include/nn/atk/atk_BiquadFilterCallback.h create mode 100644 include/nn/atk/atk_ChannelMixVolume.h create mode 100644 include/nn/atk/atk_DeviceOutRecorder.h create mode 100644 include/nn/atk/atk_EffectAux.h create mode 100644 include/nn/atk/atk_EffectBase.h create mode 100644 include/nn/atk/atk_FinalMix.h create mode 100644 include/nn/atk/atk_FsSoundArchive.h create mode 100644 include/nn/atk/atk_Global.h create mode 100644 include/nn/atk/atk_OutputMixer.h create mode 100644 include/nn/atk/atk_OutputReceiver.h create mode 100644 include/nn/atk/atk_ProfileReader.h create mode 100644 include/nn/atk/atk_SequenceSoundHandle.h create mode 100644 include/nn/atk/atk_SoundActor.h create mode 100644 include/nn/atk/atk_SoundArchive.h rename include/nn/atk/{SoundArchivePlayer.h => atk_SoundArchivePlayer.h} (76%) rename include/nn/atk/{SoundDataManager.h => atk_SoundDataManager.h} (100%) create mode 100644 include/nn/atk/atk_SoundHandle.h create mode 100644 include/nn/atk/atk_SoundHeap.h create mode 100644 include/nn/atk/atk_SoundMemoryAllocatable.h rename include/nn/atk/{SoundPlayer.h => atk_SoundPlayer.h} (100%) create mode 100644 include/nn/atk/atk_SoundStartable.h create mode 100644 include/nn/atk/atk_SoundSystem.h create mode 100644 include/nn/atk/atk_StreamSoundHandle.h create mode 100644 include/nn/atk/atk_SubMix.h create mode 100644 include/nn/atk/atk_TaskProfileReader.h create mode 100644 include/nn/atk/detail/atk_AddonSoundArchiveContainer.h create mode 100644 include/nn/atk/detail/atk_AdvancedWaveSound.h create mode 100644 include/nn/atk/detail/atk_AdvancedWaveSoundFile.h create mode 100644 include/nn/atk/detail/atk_AdvancedWaveSoundFileReader.h rename include/nn/atk/detail/{AdvancedWaveSoundRuntime.h => atk_AdvancedWaveSoundRuntime.h} (100%) create mode 100644 include/nn/atk/detail/atk_BankFile.h create mode 100644 include/nn/atk/detail/atk_BankFileReader.h rename include/nn/atk/detail/{BasicSound.h => atk_BasicSound.h} (100%) create mode 100644 include/nn/atk/detail/atk_BinaryFileFormat.h create mode 100644 include/nn/atk/detail/atk_BinaryTypes.h create mode 100644 include/nn/atk/detail/atk_BiquadFilterPresets.h create mode 100644 include/nn/atk/detail/atk_BusMixVolumePacket.h create mode 100644 include/nn/atk/detail/atk_Command.h create mode 100644 include/nn/atk/detail/atk_CommandManager.h create mode 100644 include/nn/atk/detail/atk_Config.h create mode 100644 include/nn/atk/detail/atk_CurveAdshr.h create mode 100644 include/nn/atk/detail/atk_CurveLfo.h create mode 100644 include/nn/atk/detail/atk_Debug.h create mode 100644 include/nn/atk/detail/atk_DriverCommand.h create mode 100644 include/nn/atk/detail/atk_DspadpcmReader.h create mode 100644 include/nn/atk/detail/atk_ElementType.h create mode 100644 include/nn/atk/detail/atk_ExternalSoundPlayer.h create mode 100644 include/nn/atk/detail/atk_FrameHeap.h create mode 100644 include/nn/atk/detail/atk_GroupFile.h create mode 100644 include/nn/atk/detail/atk_GroupFileReader.h create mode 100644 include/nn/atk/detail/atk_IRegionInfoReadable.h create mode 100644 include/nn/atk/detail/atk_IStreamDataDecoder.h create mode 100644 include/nn/atk/detail/atk_InstancePool.h create mode 100644 include/nn/atk/detail/atk_IntrusiveList.h create mode 100644 include/nn/atk/detail/atk_ItemType.h create mode 100644 include/nn/atk/detail/atk_LoaderManager.h create mode 100644 include/nn/atk/detail/atk_LowLevelVoice.h create mode 100644 include/nn/atk/detail/atk_MemoryFileStream.h create mode 100644 include/nn/atk/detail/atk_MoveValue.h create mode 100644 include/nn/atk/detail/atk_OutputAdditionalParam.h create mode 100644 include/nn/atk/detail/atk_PlayerHeap.h create mode 100644 include/nn/atk/detail/atk_PlayerHeapDataManager.h create mode 100644 include/nn/atk/detail/atk_RegionManager.h create mode 100644 include/nn/atk/detail/atk_SequenceSound.h create mode 100644 include/nn/atk/detail/atk_SequenceSoundFile.h create mode 100644 include/nn/atk/detail/atk_SequenceSoundFileReader.h rename include/nn/atk/detail/{SequenceSoundRuntime.h => atk_SequenceSoundRuntime.h} (100%) create mode 100644 include/nn/atk/detail/atk_SoundArchiveFile.h create mode 100644 include/nn/atk/detail/atk_SoundArchiveFileReader.h create mode 100644 include/nn/atk/detail/atk_SoundArchiveLoader.h rename include/nn/atk/detail/{SoundArchiveManager.h => atk_SoundArchiveManager.h} (100%) create mode 100644 include/nn/atk/detail/atk_SoundInstanceManager.h create mode 100644 include/nn/atk/detail/atk_SoundRuntimeUtility.h create mode 100644 include/nn/atk/detail/atk_StartInfoReader.h create mode 100644 include/nn/atk/detail/atk_StreamSound.h create mode 100644 include/nn/atk/detail/atk_StreamSoundFile.h create mode 100644 include/nn/atk/detail/atk_StreamSoundFileLoader.h create mode 100644 include/nn/atk/detail/atk_StreamSoundFileReader.h create mode 100644 include/nn/atk/detail/atk_StreamSoundPrefetchFile.h create mode 100644 include/nn/atk/detail/atk_StreamSoundPrefetchFileReader.h rename include/nn/atk/detail/{StreamSoundRuntime.h => atk_StreamSoundRuntime.h} (100%) create mode 100644 include/nn/atk/detail/atk_Task.h create mode 100644 include/nn/atk/detail/atk_TaskManager.h create mode 100644 include/nn/atk/detail/atk_TaskThread.h create mode 100644 include/nn/atk/detail/atk_ThreadInfoReader.h create mode 100644 include/nn/atk/detail/atk_Util.h create mode 100644 include/nn/atk/detail/atk_ValueArray.h create mode 100644 include/nn/atk/detail/atk_Voice.h create mode 100644 include/nn/atk/detail/atk_VoiceCommand.h create mode 100644 include/nn/atk/detail/atk_VolumeThroughModePacket.h create mode 100644 include/nn/atk/detail/atk_WavBinary.h create mode 100644 include/nn/atk/detail/atk_WavOutFileStream.h create mode 100644 include/nn/atk/detail/atk_WaveArchiveFile.h create mode 100644 include/nn/atk/detail/atk_WaveArchiveFileReader.h create mode 100644 include/nn/atk/detail/atk_WaveFile.h create mode 100644 include/nn/atk/detail/atk_WaveFileReader.h create mode 100644 include/nn/atk/detail/atk_WaveSound.h create mode 100644 include/nn/atk/detail/atk_WaveSoundFile.h create mode 100644 include/nn/atk/detail/atk_WaveSoundFileReader.h rename include/nn/atk/detail/{WaveSoundRuntime.h => atk_WaveSoundRuntime.h} (100%) create mode 100644 include/nn/atk/detail/driver/atk_AdvancedWaveSoundPlayer.h create mode 100644 include/nn/atk/detail/driver/atk_Bank.h create mode 100644 include/nn/atk/detail/driver/atk_BasicSoundPlayer.h create mode 100644 include/nn/atk/detail/driver/atk_Channel.h create mode 100644 include/nn/atk/detail/driver/atk_ChannelManager.h create mode 100644 include/nn/atk/detail/driver/atk_DisposeCallback.h create mode 100644 include/nn/atk/detail/driver/atk_DisposeCallbackManager.h create mode 100644 include/nn/atk/detail/driver/atk_HardwareManager.h create mode 100644 include/nn/atk/detail/driver/atk_MmlCommand.h create mode 100644 include/nn/atk/detail/driver/atk_MmlParser.h create mode 100644 include/nn/atk/detail/driver/atk_MmlSequenceTrack.h create mode 100644 include/nn/atk/detail/driver/atk_MmlSequenceTrackAllocator.h create mode 100644 include/nn/atk/detail/driver/atk_MultiVoice.h create mode 100644 include/nn/atk/detail/driver/atk_MultiVoiceManager.h create mode 100644 include/nn/atk/detail/driver/atk_NoteOnCallback.h create mode 100644 include/nn/atk/detail/driver/atk_SequenceSoundPlayer.h create mode 100644 include/nn/atk/detail/driver/atk_SequenceTrack.h create mode 100644 include/nn/atk/detail/driver/atk_SequenceTrackAllocator.h create mode 100644 include/nn/atk/detail/driver/atk_SoundThread.h create mode 100644 include/nn/atk/detail/driver/atk_StreamBufferPool.h create mode 100644 include/nn/atk/detail/driver/atk_StreamSoundLoader.h create mode 100644 include/nn/atk/detail/driver/atk_StreamSoundPlayer.h create mode 100644 include/nn/atk/detail/driver/atk_StreamTrack.h create mode 100644 include/nn/atk/detail/driver/atk_WaveSoundLoader.h create mode 100644 include/nn/atk/detail/driver/atk_WaveSoundPlayer.h diff --git a/CMakeLists.txt b/CMakeLists.txt index cc3c5030..171e0eb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -209,16 +209,6 @@ add_library(NintendoSDK OBJECT include/nn/nn.h include/nn/settings.h include/nn/hid.h - include/nn/atk/detail/StreamSoundRuntime.h - include/nn/atk/detail/BasicSound.h - include/nn/atk/detail/WaveSoundRuntime.h - include/nn/atk/detail/SequenceSoundRuntime.h - include/nn/atk/detail/SoundArchiveManager.h - include/nn/atk/detail/AdvancedWaveSoundRuntime.h - include/nn/atk/AuxBus.h - include/nn/atk/SoundArchivePlayer.h - include/nn/atk/SoundPlayer.h - include/nn/atk/SoundDataManager.h include/nn/nfp.h include/nn/nfp/nfp.h include/nn/nfp/nfp_types.h @@ -240,6 +230,133 @@ add_library(NintendoSDK OBJECT include/nn/friends.h include/nn/mem.h + include/nn/atk/atk_Adpcm.h + include/nn/atk/atk_AudioRendererPerformanceReader.h + include/nn/atk/atk_BiquadFilterCallback.h + include/nn/atk/atk_ChannelMixVolume.h + include/nn/atk/atk_DeviceOutRecorder.h + include/nn/atk/atk_EffectAux.h + include/nn/atk/atk_EffectBase.h + include/nn/atk/atk_FinalMix.h + include/nn/atk/atk_FsSoundArchive.h + include/nn/atk/atk_Global.h + include/nn/atk/atk_OutputMixer.h + include/nn/atk/atk_OutputReceiver.h + include/nn/atk/atk_ProfileReader.h + include/nn/atk/atk_SequenceSoundHandle.h + include/nn/atk/atk_SoundActor.h + include/nn/atk/atk_SoundArchive.h + include/nn/atk/atk_SoundArchivePlayer.h + include/nn/atk/atk_SoundDataManager.h + include/nn/atk/atk_SoundHandle.h + include/nn/atk/atk_SoundHeap.h + include/nn/atk/atk_SoundMemoryAllocatable.h + include/nn/atk/atk_SoundPlayer.h + include/nn/atk/atk_SoundStartable.h + include/nn/atk/atk_SoundSystem.h + include/nn/atk/atk_StreamSoundHandle.h + include/nn/atk/atk_SubMix.h + include/nn/atk/atk_TaskProfileReader.h + include/nn/atk/detail/atk_AddonSoundArchiveContainer.h + include/nn/atk/detail/atk_AdvancedWaveSound.h + include/nn/atk/detail/atk_AdvancedWaveSoundFile.h + include/nn/atk/detail/atk_AdvancedWaveSoundFileReader.h + include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h + include/nn/atk/detail/atk_BankFile.h + include/nn/atk/detail/atk_BankFileReader.h + include/nn/atk/detail/atk_BasicSound.h + include/nn/atk/detail/atk_BinaryFileFormat.h + include/nn/atk/detail/atk_BinaryTypes.h + include/nn/atk/detail/atk_BiquadFilterPresets.h + include/nn/atk/detail/atk_BusMixVolumePacket.h + include/nn/atk/detail/atk_Command.h + include/nn/atk/detail/atk_CommandManager.h + include/nn/atk/detail/atk_Config.h + include/nn/atk/detail/atk_CurveAdshr.h + include/nn/atk/detail/atk_CurveLfo.h + include/nn/atk/detail/atk_Debug.h + include/nn/atk/detail/atk_DriverCommand.h + include/nn/atk/detail/atk_DspadpcmReader.h + include/nn/atk/detail/atk_ElementType.h + include/nn/atk/detail/atk_ExternalSoundPlayer.h + include/nn/atk/detail/atk_FrameHeap.h + include/nn/atk/detail/atk_GroupFile.h + include/nn/atk/detail/atk_GroupFileReader.h + include/nn/atk/detail/atk_InstancePool.h + include/nn/atk/detail/atk_IntrusiveList.h + include/nn/atk/detail/atk_IRegionInfoReadable.h + include/nn/atk/detail/atk_IStreamDataDecoder.h + include/nn/atk/detail/atk_ItemType.h + include/nn/atk/detail/atk_LoaderManager.h + include/nn/atk/detail/atk_LowLevelVoice.h + include/nn/atk/detail/atk_MemoryFileStream.h + include/nn/atk/detail/atk_MoveValue.h + include/nn/atk/detail/atk_OutputAdditionalParam.h + include/nn/atk/detail/atk_PlayerHeap.h + include/nn/atk/detail/atk_PlayerHeapDataManager.h + include/nn/atk/detail/atk_RegionManager.h + include/nn/atk/detail/atk_SequenceSound.h + include/nn/atk/detail/atk_SequenceSoundFile.h + include/nn/atk/detail/atk_SequenceSoundFileReader.h + include/nn/atk/detail/atk_SequenceSoundRuntime.h + include/nn/atk/detail/atk_SoundArchiveFile.h + include/nn/atk/detail/atk_SoundArchiveFileReader.h + include/nn/atk/detail/atk_SoundArchiveLoader.h + include/nn/atk/detail/atk_SoundArchiveManager.h + include/nn/atk/detail/atk_SoundInstanceManager.h + include/nn/atk/detail/atk_SoundRuntimeUtility.h + include/nn/atk/detail/atk_StartInfoReader.h + include/nn/atk/detail/atk_StreamSound.h + include/nn/atk/detail/atk_StreamSoundFile.h + include/nn/atk/detail/atk_StreamSoundFileLoader.h + include/nn/atk/detail/atk_StreamSoundFileReader.h + include/nn/atk/detail/atk_StreamSoundPrefetchFile.h + include/nn/atk/detail/atk_StreamSoundPrefetchFileReader.h + include/nn/atk/detail/atk_StreamSoundRuntime.h + include/nn/atk/detail/atk_Task.h + include/nn/atk/detail/atk_TaskManager.h + include/nn/atk/detail/atk_TaskThread.h + include/nn/atk/detail/atk_ThreadInfoReader.h + include/nn/atk/detail/atk_Util.h + include/nn/atk/detail/atk_ValueArray.h + include/nn/atk/detail/atk_Voice.h + include/nn/atk/detail/atk_VoiceCommand.h + include/nn/atk/detail/atk_VolumeThroughModePacket.h + include/nn/atk/detail/atk_WavBinary.h + include/nn/atk/detail/atk_WaveArchiveFile.h + include/nn/atk/detail/atk_WaveArchiveFileReader.h + include/nn/atk/detail/atk_WaveFile.h + include/nn/atk/detail/atk_WaveSound.h + include/nn/atk/detail/atk_WaveSoundFile.h + include/nn/atk/detail/atk_WaveSoundFileReader.h + include/nn/atk/detail/atk_WaveSoundRuntime.h + include/nn/atk/detail/atk_WavOutFileStream.h + include/nn/atk/detail/driver/atk_AdvancedWaveSoundPlayer.h + include/nn/atk/detail/driver/atk_Bank.h + include/nn/atk/detail/driver/atk_BasicSoundPlayer.h + include/nn/atk/detail/driver/atk_Channel.h + include/nn/atk/detail/driver/atk_ChannelManager.h + include/nn/atk/detail/driver/atk_DisposeCallback.h + include/nn/atk/detail/driver/atk_DisposeCallbackManager.h + include/nn/atk/detail/driver/atk_HardwareManager.h + include/nn/atk/detail/driver/atk_MmlCommand.h + include/nn/atk/detail/driver/atk_MmlParser.h + include/nn/atk/detail/driver/atk_MmlSequenceTrack.h + include/nn/atk/detail/driver/atk_MmlSequenceTrackAllocator.h + include/nn/atk/detail/driver/atk_MultiVoice.h + include/nn/atk/detail/driver/atk_MultiVoiceManager.h + include/nn/atk/detail/driver/atk_NoteOnCallback.h + include/nn/atk/detail/driver/atk_SequenceSoundPlayer.h + include/nn/atk/detail/driver/atk_SequenceTrack.h + include/nn/atk/detail/driver/atk_SequenceTrackAllocator.h + include/nn/atk/detail/driver/atk_SoundThread.h + include/nn/atk/detail/driver/atk_StreamBufferPool.h + include/nn/atk/detail/driver/atk_StreamSoundLoader.h + include/nn/atk/detail/driver/atk_StreamSoundPlayer.h + include/nn/atk/detail/driver/atk_StreamTrack.h + include/nn/atk/detail/driver/atk_WaveSoundLoader.h + include/nn/atk/detail/driver/atk_WaveSoundPlayer.h + include/nvn/nvn_Cpp.h include/nvn/nvn_CppFuncPtrBase.h include/nvn/nvn_CppMethods.h diff --git a/include/nn/atk/atk_Adpcm.h b/include/nn/atk/atk_Adpcm.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/atk_AudioRendererPerformanceReader.h b/include/nn/atk/atk_AudioRendererPerformanceReader.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/atk_BiquadFilterCallback.h b/include/nn/atk/atk_BiquadFilterCallback.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/atk_ChannelMixVolume.h b/include/nn/atk/atk_ChannelMixVolume.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/atk_DeviceOutRecorder.h b/include/nn/atk/atk_DeviceOutRecorder.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/atk_EffectAux.h b/include/nn/atk/atk_EffectAux.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/atk_EffectBase.h b/include/nn/atk/atk_EffectBase.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/atk_FinalMix.h b/include/nn/atk/atk_FinalMix.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/atk_FsSoundArchive.h b/include/nn/atk/atk_FsSoundArchive.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/atk_OutputMixer.h b/include/nn/atk/atk_OutputMixer.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/atk_OutputReceiver.h b/include/nn/atk/atk_OutputReceiver.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/atk_ProfileReader.h b/include/nn/atk/atk_ProfileReader.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/atk_SequenceSoundHandle.h b/include/nn/atk/atk_SequenceSoundHandle.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/atk_SoundActor.h b/include/nn/atk/atk_SoundActor.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/SoundArchivePlayer.h b/include/nn/atk/atk_SoundArchivePlayer.h similarity index 76% rename from include/nn/atk/SoundArchivePlayer.h rename to include/nn/atk/atk_SoundArchivePlayer.h index c3646646..616d3fed 100644 --- a/include/nn/atk/SoundArchivePlayer.h +++ b/include/nn/atk/atk_SoundArchivePlayer.h @@ -5,11 +5,11 @@ #pragma once -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace nn { namespace atk { diff --git a/include/nn/atk/SoundDataManager.h b/include/nn/atk/atk_SoundDataManager.h similarity index 100% rename from include/nn/atk/SoundDataManager.h rename to include/nn/atk/atk_SoundDataManager.h diff --git a/include/nn/atk/atk_SoundHandle.h b/include/nn/atk/atk_SoundHandle.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/atk_SoundHeap.h b/include/nn/atk/atk_SoundHeap.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/atk_SoundMemoryAllocatable.h b/include/nn/atk/atk_SoundMemoryAllocatable.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/SoundPlayer.h b/include/nn/atk/atk_SoundPlayer.h similarity index 100% rename from include/nn/atk/SoundPlayer.h rename to include/nn/atk/atk_SoundPlayer.h diff --git a/include/nn/atk/atk_SoundStartable.h b/include/nn/atk/atk_SoundStartable.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/atk_SoundSystem.h b/include/nn/atk/atk_SoundSystem.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/atk_StreamSoundHandle.h b/include/nn/atk/atk_StreamSoundHandle.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/atk_SubMix.h b/include/nn/atk/atk_SubMix.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/atk_TaskProfileReader.h b/include/nn/atk/atk_TaskProfileReader.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h b/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_AdvancedWaveSound.h b/include/nn/atk/detail/atk_AdvancedWaveSound.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h b/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundFileReader.h b/include/nn/atk/detail/atk_AdvancedWaveSoundFileReader.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/AdvancedWaveSoundRuntime.h b/include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h similarity index 100% rename from include/nn/atk/detail/AdvancedWaveSoundRuntime.h rename to include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h diff --git a/include/nn/atk/detail/atk_BankFile.h b/include/nn/atk/detail/atk_BankFile.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_BankFileReader.h b/include/nn/atk/detail/atk_BankFileReader.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/BasicSound.h b/include/nn/atk/detail/atk_BasicSound.h similarity index 100% rename from include/nn/atk/detail/BasicSound.h rename to include/nn/atk/detail/atk_BasicSound.h diff --git a/include/nn/atk/detail/atk_BinaryFileFormat.h b/include/nn/atk/detail/atk_BinaryFileFormat.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_BinaryTypes.h b/include/nn/atk/detail/atk_BinaryTypes.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_BiquadFilterPresets.h b/include/nn/atk/detail/atk_BiquadFilterPresets.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_BusMixVolumePacket.h b/include/nn/atk/detail/atk_BusMixVolumePacket.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_Command.h b/include/nn/atk/detail/atk_Command.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_CommandManager.h b/include/nn/atk/detail/atk_CommandManager.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_Config.h b/include/nn/atk/detail/atk_Config.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_CurveAdshr.h b/include/nn/atk/detail/atk_CurveAdshr.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_CurveLfo.h b/include/nn/atk/detail/atk_CurveLfo.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_Debug.h b/include/nn/atk/detail/atk_Debug.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_DriverCommand.h b/include/nn/atk/detail/atk_DriverCommand.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_DspadpcmReader.h b/include/nn/atk/detail/atk_DspadpcmReader.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_ElementType.h b/include/nn/atk/detail/atk_ElementType.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_ExternalSoundPlayer.h b/include/nn/atk/detail/atk_ExternalSoundPlayer.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_FrameHeap.h b/include/nn/atk/detail/atk_FrameHeap.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_GroupFile.h b/include/nn/atk/detail/atk_GroupFile.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_GroupFileReader.h b/include/nn/atk/detail/atk_GroupFileReader.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_IRegionInfoReadable.h b/include/nn/atk/detail/atk_IRegionInfoReadable.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_IStreamDataDecoder.h b/include/nn/atk/detail/atk_IStreamDataDecoder.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_InstancePool.h b/include/nn/atk/detail/atk_InstancePool.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_IntrusiveList.h b/include/nn/atk/detail/atk_IntrusiveList.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_ItemType.h b/include/nn/atk/detail/atk_ItemType.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_LoaderManager.h b/include/nn/atk/detail/atk_LoaderManager.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_LowLevelVoice.h b/include/nn/atk/detail/atk_LowLevelVoice.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_MemoryFileStream.h b/include/nn/atk/detail/atk_MemoryFileStream.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_MoveValue.h b/include/nn/atk/detail/atk_MoveValue.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_OutputAdditionalParam.h b/include/nn/atk/detail/atk_OutputAdditionalParam.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_PlayerHeap.h b/include/nn/atk/detail/atk_PlayerHeap.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_PlayerHeapDataManager.h b/include/nn/atk/detail/atk_PlayerHeapDataManager.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_RegionManager.h b/include/nn/atk/detail/atk_RegionManager.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_SequenceSound.h b/include/nn/atk/detail/atk_SequenceSound.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_SequenceSoundFile.h b/include/nn/atk/detail/atk_SequenceSoundFile.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_SequenceSoundFileReader.h b/include/nn/atk/detail/atk_SequenceSoundFileReader.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/SequenceSoundRuntime.h b/include/nn/atk/detail/atk_SequenceSoundRuntime.h similarity index 100% rename from include/nn/atk/detail/SequenceSoundRuntime.h rename to include/nn/atk/detail/atk_SequenceSoundRuntime.h diff --git a/include/nn/atk/detail/atk_SoundArchiveFile.h b/include/nn/atk/detail/atk_SoundArchiveFile.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_SoundArchiveFileReader.h b/include/nn/atk/detail/atk_SoundArchiveFileReader.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_SoundArchiveLoader.h b/include/nn/atk/detail/atk_SoundArchiveLoader.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/SoundArchiveManager.h b/include/nn/atk/detail/atk_SoundArchiveManager.h similarity index 100% rename from include/nn/atk/detail/SoundArchiveManager.h rename to include/nn/atk/detail/atk_SoundArchiveManager.h diff --git a/include/nn/atk/detail/atk_SoundInstanceManager.h b/include/nn/atk/detail/atk_SoundInstanceManager.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_SoundRuntimeUtility.h b/include/nn/atk/detail/atk_SoundRuntimeUtility.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_StartInfoReader.h b/include/nn/atk/detail/atk_StartInfoReader.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_StreamSound.h b/include/nn/atk/detail/atk_StreamSound.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_StreamSoundFile.h b/include/nn/atk/detail/atk_StreamSoundFile.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_StreamSoundFileLoader.h b/include/nn/atk/detail/atk_StreamSoundFileLoader.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_StreamSoundFileReader.h b/include/nn/atk/detail/atk_StreamSoundFileReader.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_StreamSoundPrefetchFile.h b/include/nn/atk/detail/atk_StreamSoundPrefetchFile.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_StreamSoundPrefetchFileReader.h b/include/nn/atk/detail/atk_StreamSoundPrefetchFileReader.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/StreamSoundRuntime.h b/include/nn/atk/detail/atk_StreamSoundRuntime.h similarity index 100% rename from include/nn/atk/detail/StreamSoundRuntime.h rename to include/nn/atk/detail/atk_StreamSoundRuntime.h diff --git a/include/nn/atk/detail/atk_Task.h b/include/nn/atk/detail/atk_Task.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_TaskManager.h b/include/nn/atk/detail/atk_TaskManager.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_TaskThread.h b/include/nn/atk/detail/atk_TaskThread.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_ThreadInfoReader.h b/include/nn/atk/detail/atk_ThreadInfoReader.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_Util.h b/include/nn/atk/detail/atk_Util.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_ValueArray.h b/include/nn/atk/detail/atk_ValueArray.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_Voice.h b/include/nn/atk/detail/atk_Voice.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_VoiceCommand.h b/include/nn/atk/detail/atk_VoiceCommand.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_VolumeThroughModePacket.h b/include/nn/atk/detail/atk_VolumeThroughModePacket.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_WavBinary.h b/include/nn/atk/detail/atk_WavBinary.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_WavOutFileStream.h b/include/nn/atk/detail/atk_WavOutFileStream.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_WaveArchiveFile.h b/include/nn/atk/detail/atk_WaveArchiveFile.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_WaveArchiveFileReader.h b/include/nn/atk/detail/atk_WaveArchiveFileReader.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_WaveFile.h b/include/nn/atk/detail/atk_WaveFile.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_WaveFileReader.h b/include/nn/atk/detail/atk_WaveFileReader.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_WaveSound.h b/include/nn/atk/detail/atk_WaveSound.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_WaveSoundFile.h b/include/nn/atk/detail/atk_WaveSoundFile.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/atk_WaveSoundFileReader.h b/include/nn/atk/detail/atk_WaveSoundFileReader.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/WaveSoundRuntime.h b/include/nn/atk/detail/atk_WaveSoundRuntime.h similarity index 100% rename from include/nn/atk/detail/WaveSoundRuntime.h rename to include/nn/atk/detail/atk_WaveSoundRuntime.h diff --git a/include/nn/atk/detail/driver/atk_AdvancedWaveSoundPlayer.h b/include/nn/atk/detail/driver/atk_AdvancedWaveSoundPlayer.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_Bank.h b/include/nn/atk/detail/driver/atk_Bank.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_BasicSoundPlayer.h b/include/nn/atk/detail/driver/atk_BasicSoundPlayer.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_Channel.h b/include/nn/atk/detail/driver/atk_Channel.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_ChannelManager.h b/include/nn/atk/detail/driver/atk_ChannelManager.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_DisposeCallback.h b/include/nn/atk/detail/driver/atk_DisposeCallback.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_DisposeCallbackManager.h b/include/nn/atk/detail/driver/atk_DisposeCallbackManager.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_HardwareManager.h b/include/nn/atk/detail/driver/atk_HardwareManager.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_MmlCommand.h b/include/nn/atk/detail/driver/atk_MmlCommand.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_MmlParser.h b/include/nn/atk/detail/driver/atk_MmlParser.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_MmlSequenceTrack.h b/include/nn/atk/detail/driver/atk_MmlSequenceTrack.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_MmlSequenceTrackAllocator.h b/include/nn/atk/detail/driver/atk_MmlSequenceTrackAllocator.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_MultiVoice.h b/include/nn/atk/detail/driver/atk_MultiVoice.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_MultiVoiceManager.h b/include/nn/atk/detail/driver/atk_MultiVoiceManager.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_NoteOnCallback.h b/include/nn/atk/detail/driver/atk_NoteOnCallback.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_SequenceSoundPlayer.h b/include/nn/atk/detail/driver/atk_SequenceSoundPlayer.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_SequenceTrack.h b/include/nn/atk/detail/driver/atk_SequenceTrack.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_SequenceTrackAllocator.h b/include/nn/atk/detail/driver/atk_SequenceTrackAllocator.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_SoundThread.h b/include/nn/atk/detail/driver/atk_SoundThread.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_StreamBufferPool.h b/include/nn/atk/detail/driver/atk_StreamBufferPool.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_StreamSoundLoader.h b/include/nn/atk/detail/driver/atk_StreamSoundLoader.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_StreamSoundPlayer.h b/include/nn/atk/detail/driver/atk_StreamSoundPlayer.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_StreamTrack.h b/include/nn/atk/detail/driver/atk_StreamTrack.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_WaveSoundLoader.h b/include/nn/atk/detail/driver/atk_WaveSoundLoader.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/driver/atk_WaveSoundPlayer.h b/include/nn/atk/detail/driver/atk_WaveSoundPlayer.h new file mode 100644 index 00000000..e69de29b From d400f629b1e70996f870002ba77a0c81e87a4908 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 19 Feb 2026 19:14:27 -0300 Subject: [PATCH 002/785] atk: Add `AudioRendererPermanceReader` class and members --- .../atk/atk_AudioRendererPerformanceReader.h | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/include/nn/atk/atk_AudioRendererPerformanceReader.h b/include/nn/atk/atk_AudioRendererPerformanceReader.h index e69de29b..3a17174b 100644 --- a/include/nn/atk/atk_AudioRendererPerformanceReader.h +++ b/include/nn/atk/atk_AudioRendererPerformanceReader.h @@ -0,0 +1,35 @@ +#pragma once + +#include + +#include +#include + +namespace nn::atk { +class AudioRendererPerformanceReader { +public: + struct PerformanceInfo { + void* performanceBuffer; + size_t performanceBufferSize; + os::Tick tick; + }; + + AudioRendererPerformanceReader(); + + static size_t GetRequiredMemorySize(s32); + + void Initialize(s32, void*, u64); + PerformanceInfo* ReadPerformanceInfo(); + + void Record(const void* performanceFrameBuffer, size_t performanceFrameBufferSize, os::Tick tick); + +private: + PerformanceInfo* m_pPerformanceInfo{}; + s32 m_PerformanceInfoCount{0}; + std::atomic_int m_WriteIndex{0}; + std::atomic_int m_ReadIndex{0}; + bool m_IsInitialized{false}; +}; +static_assert(sizeof(AudioRendererPerformanceReader) == 0x18); + +} // namespace nn::atk \ No newline at end of file From e77d9cb99dadd9764d5de42215d0358dc1e26348 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 19 Feb 2026 19:16:00 -0300 Subject: [PATCH 003/785] atk: Add global types and enums --- include/nn/atk/atk_Adpcm.h | 6 + include/nn/atk/atk_Global.h | 421 +++++++++++++++++++++++++++++ include/nn/atk/detail/atk_Config.h | 8 + 3 files changed, 435 insertions(+) diff --git a/include/nn/atk/atk_Adpcm.h b/include/nn/atk/atk_Adpcm.h index e69de29b..77ea43a4 100644 --- a/include/nn/atk/atk_Adpcm.h +++ b/include/nn/atk/atk_Adpcm.h @@ -0,0 +1,6 @@ +#pragma once + +namespace nn::atk { +struct AdpcmContext; + +}; \ No newline at end of file diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h index e69de29b..7d4b99a7 100644 --- a/include/nn/atk/atk_Global.h +++ b/include/nn/atk/atk_Global.h @@ -0,0 +1,421 @@ +#pragma once + +#include +#include + +namespace nn::atk { +enum WaveType { + WaveType_Invalid = -1, + WaveType_Nwwav, + WaveType_Dspadpcm, +}; + +struct WaveBuffer { + enum Status { + Status_Free, + Status_Wait, + Status_Play, + Status_Done, + }; + + void* bufferAddress; + size_t bufferSize; + size_t sampleLength; + position_t sampleOffset; + AdpcmContext* pAdpcmContext; + void* userParam; + bool loopFlag; + Status status; + WaveBuffer* next; +}; +static_assert(sizeof(WaveBuffer) == 0x40); + +enum AuxBus { + AuxBus_A, + AuxBus_B, + AuxBus_C, + AuxBus_Count, +}; + +enum BiquadFilterType { + BiquadFilterType_Inherit = -1, + BiquadFilterType_Min = -1, + BiquadFilterType_DataMin = 0, + + BiquadFilterType_None = 0, + BiquadFilterType_LowPassFilter, + BiquadFilterType_HighPassFilter, + BiquadFilterType_BandPassFilter512, + BiquadFilterType_BandPassFilter1024, + BiquadFilterType_BandPassFilter2048, + BiquadFilterType_LowPassFilterNw4fCompatible48k, + BiquadFilterType_HighPassFilterNw4fCompatible48k, + BiquadFilterType_BandPassFilter512Nw4fCompatible48k, + BiquadFilterType_BandPassFilter1024Nw4fCompatible48k, + BiquadFilterType_BandPassFilter2048Nw4fCompatible48k, + + BiquadFilterType_UserMin = 0x40, + + BiquadFilterType_User0 = BiquadFilterType_UserMin, + BiquadFilterType_User1, + BiquadFilterType_User2, + BiquadFilterType_User3, + BiquadFilterType_User4, + BiquadFilterType_User5, + BiquadFilterType_User6, + BiquadFilterType_User7, + BiquadFilterType_User8, + BiquadFilterType_User9, + BiquadFilterType_User10, + BiquadFilterType_User11, + BiquadFilterType_User12, + BiquadFilterType_User13, + BiquadFilterType_User14, + BiquadFilterType_User15, + BiquadFilterType_User16, + BiquadFilterType_User17, + BiquadFilterType_User18, + BiquadFilterType_User19, + BiquadFilterType_User20, + BiquadFilterType_User21, + BiquadFilterType_User22, + BiquadFilterType_User23, + BiquadFilterType_User24, + BiquadFilterType_User25, + BiquadFilterType_User26, + BiquadFilterType_User27, + BiquadFilterType_User28, + BiquadFilterType_User29, + BiquadFilterType_User30, + BiquadFilterType_User31, + BiquadFilterType_User32, + BiquadFilterType_User33, + BiquadFilterType_User34, + BiquadFilterType_User35, + BiquadFilterType_User36, + BiquadFilterType_User37, + BiquadFilterType_User38, + BiquadFilterType_User39, + BiquadFilterType_User40, + BiquadFilterType_User41, + BiquadFilterType_User42, + BiquadFilterType_User43, + BiquadFilterType_User44, + BiquadFilterType_User45, + BiquadFilterType_User46, + BiquadFilterType_User47, + BiquadFilterType_User48, + BiquadFilterType_User49, + BiquadFilterType_User50, + BiquadFilterType_User51, + BiquadFilterType_User52, + BiquadFilterType_User53, + BiquadFilterType_User54, + BiquadFilterType_User55, + BiquadFilterType_User56, + BiquadFilterType_User57, + BiquadFilterType_User58, + BiquadFilterType_User59, + BiquadFilterType_User60, + BiquadFilterType_User61, + BiquadFilterType_User62, + BiquadFilterType_User63, + + BiquadFilterType_Max = 0x7f, + BiquadFilterType_UserMax = 0x7f, +}; + +enum ChannelIndex { + ChannelIndex_FrontLeft, + ChannelIndex_FrontRight, + ChannelIndex_RearLeft, + ChannelIndex_RearRight, + ChannelIndex_FrontCenter, + ChannelIndex_Lfe, + ChannelIndex_Count, +}; + +enum CircularBufferSinkState { + CircularBufferSinkState_Invalid, + CircularBufferSinkState_Started, + CircularBufferSinkState_Stopped, +}; + +enum FsPriority { + FsPriority_RealTime, + FsPriority_Normal, + FsPriority_Low, +}; + +class AdshrCurve { +private: + u8 m_Attack; + u8 m_Decay; + u8 m_Sustain; + u8 m_Hold; + u8 m_Release; +}; +static_assert(sizeof(AdshrCurve) == 0x5); + +struct BiquadFilterCoefficients { + s16 b0; + s16 b1; + s16 b2; + s16 a1; + s16 a2; +}; +static_assert(sizeof(BiquadFilterCoefficients) == 0xa); + +struct DspAdpcmParam { + u16 coef[8][2]; + u16 predScale; + u16 yn1; + u16 yn2; +}; +static_assert(sizeof(DspAdpcmParam) == 0x26); + +enum MixMode { + MixMode_Pan = 0, + MixMode_MixVolume = 1, + MixMode_Mixparameter = 1, + MixMode_Count = 2, +}; + +struct MixParameter { + union { + struct { + f32 fL; + f32 fR; + f32 rL; + f32 rR; + f32 fC; + f32 lfe; + }; + float ch[6]; + }; +}; +static_assert(sizeof(MixParameter) == 0x18); + +struct MixVolume { + union { + struct { + f32 frontLeft; + f32 frontRight; + f32 rearLeft; + f32 rearRight; + f32 frontCenter; + f32 lowFrequencyEffect; + }; + float channel[6]; + }; +}; +static_assert(sizeof(MixVolume) == 0x18); + +enum OutputDevice { + OutputDevice_Main, + OutputDevice_Count, +}; + +enum OutputDeviceIndex { + OutputDeviceIndex_Main, + OutputDeviceIndex_Count, +}; + +enum OutputLine { + OutputLine_Main = 1, + OutputLine_ReservedMax = 2, + + OutputLine_User0 = 0x10000, + OutputLine_User1 = 0x20000, + OutputLine_User2 = 0x40000, + OutputLine_User3 = 0x80000, +}; + +enum OutputLineIndex { + OutputLineIndex_Main = 1, + OutputLineIndex_ReservedMax = 2, + + OutputLineIndex_User0 = 0x10000, + OutputLineIndex_User1 = 0x20000, + OutputLineIndex_User2 = 0x40000, + OutputLineIndex_User3 = 0x80000, +}; + +enum OutputMode { + OutputMode_Monaural, + OutputMode_Stereo, + OutputMode_Surround, + OutputMode_Dpl2, + OutputMode_Count, +}; + +struct OutputMix { + float channelGain[24]; +}; +static_assert(sizeof(OutputMix) == 0x60); + +enum PanCurve { + PanCurve_Sqrt, + PanCurve_Sqrt0Db, + PanCurve_Sqrt0DbClamp, + PanCurve_Sincos, + PanCurve_Sincos0Db, + PanCurve_Sincos0DbClamp, + PanCurve_Linear, + PanCurve_Linear0Db, + PanCurve_Linear0DbClamp, + PanCurve_Invalid, +}; + +enum PanMode { + PanMode_Dual, + PanMode_Balance, + PanMode_Invalid, +}; + +enum PauseMode { + PauseMode_Default = 0, + + PauseMode_Nw4fSndCompatible = PauseMode_Default, + PauseMode_PauseImmediately, +}; + +enum SampleFormat { + SampleFormat_PcmS8, + SampleFormat_PcmS16, + SampleFormat_DspAdpcm, + SampleFormat_PcmS32, +}; + +enum SampleRateConverterType { + SampleRateConverterType_None, + SampleRateConverterType_Linear, + SampleRateConverterType_4Tap, +}; + +enum SequenceMute { + SequenceMute_Off, + SequenceMute_NoStop, + SequenceMute_Release, + SequenceMute_Stop, +}; + +enum SinglePlayType { + SinglePlayType_None, + SinglePlayType_PrioritizeOldest, + SinglePlayType_PrioritizeOldestEffectiveDuration, + SinglePlayType_PrioritizeOldestWithDuration = SinglePlayType_PrioritizeOldestEffectiveDuration, + + SinglePlayType_PrioritizeNewest, + SinglePlayType_PrioritizeNewestEffectiveDuration, + SinglePlayType_PrioritizeNewestWithDuration = SinglePlayType_PrioritizeNewestEffectiveDuration, +}; + +enum UpdateType { + UpdateType_AudioFrame, + UpdateType_GameFrame, +}; + +enum VolumeThroughModeBitFlag { + VolumeThroughMode_Binary = 1, +}; + +namespace detail { + enum DecodeMode { + DecodeMode_Invalid = -1, + DecodeMode_Default, + DecodeMode_Cpu, + DecodeMode_Accelerator, + }; + + struct DspAdpcmLoopParam { + u16 loopPredScale; + u16 loopYn1; + u16 loopYn2; + }; + static_assert(sizeof(DspAdpcmLoopParam) == 0x6); + + struct OutputBusMixVolume { + float volume[2][24]; + }; + static_assert(sizeof(OutputBusMixVolume) == 0xc0); + + struct OutputParam { + float volume; + u32 mixMode; + MixParameter mixParameter[2]; + float pan; + float span; + float send[4]; + }; + static_assert(sizeof(OutputParam) == 0x50); + + struct SoundInstanceConfig { + bool isBusMixVolumeEnabled; + bool isVolumeThroughModeEnabled; + s32 busCount; + }; + static_assert(sizeof(SoundInstanceConfig) == 8); + + enum StreamFileType { + StreamFileType_Bfstm, + StreamFileType_Opus, + }; + + enum VoiceState { + VoiceState_Play, + VoiceState_Stop, + VoiceState_Pause, + }; + + struct VoiceInfo { + VoiceState voiceState; + WaveBuffer::Status waveBufferStatus; + void* waveBufferTag; + u32 playPosition; + void* userId; + }; + static_assert(sizeof(VoiceInfo) == 0x20); + + class VoiceParam { + private: + float m_Volume; + float m_Pitch; + OutputMix m_TvMix; + bool m_MonoFilterFlag; + bool m_BiquadFilterFlag; + BiquadFilterCoefficients m_BiquadFilterCoefficients; + u16 m_MonoFilterCutoff; + u8 m_InterpolationType; + }; + static_assert(sizeof(VoiceParam) == 0x78); + + struct WaveInfo { + struct ChannelParam { + void* dataAddress; + s32 dataSize; + DspAdpcmParam adpcmParam; + DspAdpcmLoopParam adpcmLoopParam; + }; + static_assert(sizeof(ChannelParam) == 0x38); + + SampleFormat sampleFormat; + bool loopFlag; + s32 channelCount; + s32 sampleRate; + position_t loopStartFrame; + position_t loopEndFrame; + position_t originalLoopStartFrame; + size_t dataSize; + ChannelParam channelParam[2]; + }; + static_assert(sizeof(WaveInfo) == 0xa0); +} + +// typedef -- SoundFrameUserCallback; +// typedef -- SoundThreadUserCallback; +// typedef -- SoundStopCallback; + + + +} // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/detail/atk_Config.h b/include/nn/atk/detail/atk_Config.h index e69de29b..82213268 100644 --- a/include/nn/atk/detail/atk_Config.h +++ b/include/nn/atk/detail/atk_Config.h @@ -0,0 +1,8 @@ +#pragma once + +#include + +namespace nn::atk { +typedef std::ptrdiff_t position_t; + +} // namespace nn::atk \ No newline at end of file From 7326fa8a07ff9d5f5240388a31a201af1496253e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 19 Feb 2026 19:19:25 -0300 Subject: [PATCH 004/785] atk: Define `BiquadFilterCallback` --- include/nn/atk/atk_BiquadFilterCallback.h | 15 +++++++++++++++ include/nn/atk/atk_Global.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/include/nn/atk/atk_BiquadFilterCallback.h b/include/nn/atk/atk_BiquadFilterCallback.h index e69de29b..9deb2c62 100644 --- a/include/nn/atk/atk_BiquadFilterCallback.h +++ b/include/nn/atk/atk_BiquadFilterCallback.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +#include + +namespace nn::atk { +class BiquadFilterCallback { +public: + typedef BiquadFilterCoefficients Coefficients; + + virtual ~BiquadFilterCallback(); +}; + +} \ No newline at end of file diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h index 7d4b99a7..83d57af1 100644 --- a/include/nn/atk/atk_Global.h +++ b/include/nn/atk/atk_Global.h @@ -4,6 +4,8 @@ #include namespace nn::atk { +static u32 gWarningFlag = 0x1f; + enum WaveType { WaveType_Invalid = -1, WaveType_Nwwav, From 62ef55c7b656647e2f8b5752f57c65a2ac7c035b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 19 Feb 2026 19:56:51 -0300 Subject: [PATCH 005/785] atk: Define `detail::driver::DisposeCallback` --- .../nn/atk/detail/driver/atk_DisposeCallback.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/nn/atk/detail/driver/atk_DisposeCallback.h b/include/nn/atk/detail/driver/atk_DisposeCallback.h index e69de29b..5d4198be 100644 --- a/include/nn/atk/detail/driver/atk_DisposeCallback.h +++ b/include/nn/atk/detail/driver/atk_DisposeCallback.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +namespace nn::atk::detail::driver { +class DisposeCallback { +public: + virtual ~DisposeCallback() = default; + +private: + util::IntrusiveListNode m_DisposeLink; +}; +static_assert(sizeof(DisposeCallback) == 0x18); + +} // namespace nn::atk::detail::driver \ No newline at end of file From 5f46c09b0a044864c731febf5f8170352f92e41b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 19 Feb 2026 20:05:48 -0300 Subject: [PATCH 006/785] atk: Define `SoundMemoryAllocatable` --- include/nn/atk/atk_SoundMemoryAllocatable.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/nn/atk/atk_SoundMemoryAllocatable.h b/include/nn/atk/atk_SoundMemoryAllocatable.h index e69de29b..aad67efa 100644 --- a/include/nn/atk/atk_SoundMemoryAllocatable.h +++ b/include/nn/atk/atk_SoundMemoryAllocatable.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +namespace nn::atk { +class SoundMemoryAllocatable { +public: + typedef void(*DisposeCallback)(void*); + + virtual ~SoundMemoryAllocatable() = 0; + virtual void* Allocate(size_t size) = 0; + virtual void* Allocate(size_t size, DisposeCallback callback, void* callbackArg) = 0; + virtual void* GetAllocateSize(size_t size, bool needMemoryPool) = 0; +}; +} // namespace nn::atk \ No newline at end of file From c23a1bdc0e24503448ea43ccf5cf761c39782138 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 19 Feb 2026 20:31:45 -0300 Subject: [PATCH 007/785] atk: Defined `BinaryTypes` structs --- include/nn/atk/detail/atk_BinaryTypes.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/include/nn/atk/detail/atk_BinaryTypes.h b/include/nn/atk/detail/atk_BinaryTypes.h index e69de29b..5ce66cec 100644 --- a/include/nn/atk/detail/atk_BinaryTypes.h +++ b/include/nn/atk/detail/atk_BinaryTypes.h @@ -0,0 +1,25 @@ +#pragma once + +#include +#include + +namespace nn::atk::detail { +struct BinaryTypes { + NN_NO_COPY(BinaryTypes); + NN_NO_MOVE(BinaryTypes); + + template + struct Table { + CountType count; + T item[1]; + }; + + struct Reference { + u32 offset; + }; + static_assert(sizeof(Reference) == 0x4); + + struct ReferenceTable : Table {}; +}; + +}; \ No newline at end of file From 1db438478bd46baa2f2f4606b5500ce86d7e1a9e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 19 Feb 2026 20:32:18 -0300 Subject: [PATCH 008/785] atk: Defined `AdvancedWaveSoundFile` and its member structs --- .../nn/atk/detail/atk_AdvancedWaveSoundFile.h | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h b/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h index e69de29b..9ee04838 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h @@ -0,0 +1,44 @@ +#pragma once + +#include + +#include + +namespace nn::atk::detail { +struct AdvancedWaveSoundFile { + struct InfoBlockBody { + u32 offsetToTrackTableReference; + BinaryTypes::Reference toTrackTable; + }; + static_assert(sizeof(InfoBlockBody) == 0x8); + + struct InfoBlock { + util::BinaryBlockHeader blockHeader; + InfoBlockBody body; + + }; + static_assert(sizeof(InfoBlock) == 0x18); + + struct WaveSoundClip { + u32 waveIndex; + u32 position; + u32 duration; + u32 startOffset; + float pitch; + u8 volume; + u8 pan; + u8 padding[2]; + }; + static_assert(sizeof(WaveSoundClip) == 0x18); + + struct WaveSoundTrack { + u32 offsetToCurveTableReference; + u32 offsetToClipTableReference; + BinaryTypes::Reference toClipTable; + }; + + util::BinaryFileHeader fileHeader; +}; +static_assert(sizeof(AdvancedWaveSoundFile) == 0x20); + +} // namespace nn::atk::detail \ No newline at end of file From 225293b68257c7ad615650fb06130f6be914a4fa Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 19 Feb 2026 20:40:46 -0300 Subject: [PATCH 009/785] atk: Defined structs in `atk_BinaryFileFormat.h` --- include/nn/atk/detail/atk_BinaryFileFormat.h | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/nn/atk/detail/atk_BinaryFileFormat.h b/include/nn/atk/detail/atk_BinaryFileFormat.h index e69de29b..2fa628ed 100644 --- a/include/nn/atk/detail/atk_BinaryFileFormat.h +++ b/include/nn/atk/detail/atk_BinaryFileFormat.h @@ -0,0 +1,24 @@ +#pragma once + +#include + +namespace nn::atk::detail { +struct BinaryFileHeader { + s32 signature; + u16 byteOrder; + u16 headerSize; + u32 version; + u32 fileSize; + u16 dataBlocks; + u16 reserved; +}; +static_assert(sizeof(BinaryFileHeader) == 0x14); + +struct BinaryBlockHeader { + // Named "kind", but functionally the same as BinaryFileHeader.signature + s32 kind; + u32 size; +}; +static_assert(sizeof(BinaryBlockHeader) == 0x8); + +} // namespace nn::atk::detail \ No newline at end of file From 80d5bfc4cd629d851501b6d7dc7457823ad18cce Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 19 Feb 2026 21:33:11 -0300 Subject: [PATCH 010/785] atk: Define `atk_Util.h` header --- include/nn/atk/detail/atk_Util.h | 141 +++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) diff --git a/include/nn/atk/detail/atk_Util.h b/include/nn/atk/detail/atk_Util.h index e69de29b..ac41fb9e 100644 --- a/include/nn/atk/detail/atk_Util.h +++ b/include/nn/atk/detail/atk_Util.h @@ -0,0 +1,141 @@ +#pragma once + +#include + +#include +#include + +namespace nn::atk::detail { +struct Util { + NN_NO_COPY(Util); + NN_NO_MOVE(Util); + + constexpr static u16 CalcLpfFreqTable[24] { + 80, 100, 128, 160, + 200, 256, 320, 400, + 500, 640, 800, 1000, + 1280, 1600, 2000, 2560, + 3200, 4000, 5120, 6400, + 8000, 10240, 12800, 16000 + }; + + struct Reference { + // Id from ElementTypes enum + u16 typeId; + u8 padding[2]; + s32 offset; + }; + static_assert(sizeof(Reference) == 8); + + struct ReferenceWithSize : Reference { + u32 size; + }; + static_assert(sizeof(ReferenceWithSize) == 0xc); + + struct BlockReferenceTable { + ReferenceWithSize item[1]; + }; + + struct SoundFileHeader { + BinaryFileHeader header; + BlockReferenceTable blockReferenceTable; + }; + + template + struct Table { + CountType count; + T item[1]; + }; + + struct ReferenceTable : Table {}; + struct ReferenceWithSizeTable : Table {}; + + struct BitFlag { + u32 bitFlag; + }; + static_assert(sizeof(BitFlag) == 0x4); + + enum PanCurve { + PanCurve_Sqrt, + PanCurve_Sincos, + PanCurve_Linear, + }; + + struct PanInfo { + PanCurve curve; + bool centerZeroFlag; + bool zeroClampFlag; + bool isEnableFrontBypass; + }; + static_assert(sizeof(PanInfo) == 0x8); + + enum WaveArchiveLoadStatus { + WaveArchiveLoadStatus_Error = -2, + WaveArchiveLoadStatus_NotYet, + WaveArchiveLoadStatus_Ok, + WaveArchiveLoadStatus_Noneed, + WaveArchiveLoadStatus_Partly + }; + + struct WaveId { + u32 waveArchiveId; + u32 waveIndex; + }; + static_assert(sizeof(WaveId) == 0x8); + + struct WaveIdTable { + Table table; + }; + + class WarningLogger { + public: + enum LogId { + LogId_ChannelAllocationFailed, + LogId_SoundthreadFailedWakeup, + LogId_LogbufferFull, + LogId_Max, + }; + + struct LogBuffer { + struct Element { + s32 logId; + s32 arg0; + s32 arg1; + }; + static_assert(sizeof(Element) == 0xc); + + Element element[64]; + s32 counter; + }; + static_assert(sizeof(LogBuffer) == 0x304); + + void Log(s32 logId, s32 arg0, s32 arg1); + void SwapBuffer(); + void Print(); + + private: + LogBuffer m_Buffer0; + LogBuffer m_Buffer1; + LogBuffer* m_pCurrentBuffer; + }; + static_assert(sizeof(WarningLogger) == 0x610); + + u16 CalcLpfFreq(float scale); + BiquadFilterCoefficients CalcLowPassFilterCoefficients(s32 frequency, s32 sampleRate, + bool isTableUsed); + float CalcPanRatio(float pan, PanInfo* info, OutputMode mode); + float CalcSurroundPanRatio(float surroundPan, PanInfo* info); + float CalcPitchRatio(float pitch_); + float CalcVolumeRatio(float dB); + float CalcRandom(); + + WaveArchiveLoadStatus GetWaveArchiveOfBank(class LoadItemInfo* warcLoadInfo, + bool* isLoadIndividual, void* bankFile, + class SoundArchive* arc, class SoundArchiveLoader* mgr); + void* GetWaveFileOfWaveSound(void* wsdFile, u32 index, SoundArchive* arc, SoundArchiveLoader* mgr); + size_t GetByteBySample(size_t samples, SampleFormat format); + + bool IsValidMemoryForDsp(void* ptr, size_t size); +}; + +} // namespace nn::atk::detail \ No newline at end of file From 36ba6f95ff5cdf1e2990a7f22e6e4aea6bbe0a9f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 20 Feb 2026 09:09:55 -0300 Subject: [PATCH 011/785] atk: Define members in `detail::StreamSoundFile` --- include/nn/atk/detail/atk_StreamSoundFile.h | 121 ++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/include/nn/atk/detail/atk_StreamSoundFile.h b/include/nn/atk/detail/atk_StreamSoundFile.h index e69de29b..d84e0b44 100644 --- a/include/nn/atk/detail/atk_StreamSoundFile.h +++ b/include/nn/atk/detail/atk_StreamSoundFile.h @@ -0,0 +1,121 @@ +#pragma once + +#include +#include +#include + +namespace nn::atk::detail { +class StreamSoundFile { +public: + struct FileHeader : BinaryFileHeader { + Util::ReferenceWithSize toBlocks[4]; + + bool HasSeekBlock(); + bool HasRegionBlock(); + + u32 GetInfoBlockSize(); + u32 GetInfoBlockOffset(); + u32 GetSeekBlockOffset(); + u32 GetDataBlockOffset(); + u32 GetRegionBlockOffset(); + }; + static_assert(sizeof(FileHeader) == 0x44); + + struct StreamSoundInfo { + u8 encodeMethod; + bool isLoop; + u8 channelCount; + u8 regionCount; + u32 sampleRate; + u32 loopStart; + u32 frameCount; + u32 blockCount; + u32 oneBlockBytes; + u32 oneBlockSamples; + u32 lastBlockBytes; + u32 lastBlockSamples; + u32 lastBlockPaddedBytes; + u32 sizeofSeekInfoAtom; + u32 seekInfoIntervalSamples; + Util::Reference sampleDataOffset; + u16 regionInfoBytes; + u8 padding[2]; + Util::Reference regionDataOffset; + u32 originalLoopStart; + u32 originalLoopEnd; + u32 crc32Value; + }; + static_assert(sizeof(StreamSoundInfo) == 0x50); + + struct TrackInfo { + u8 volume; + u8 pan; + u8 span; + u8 flags; + + Util::Reference toGlobalChannelIndexTable; + }; + + struct TrackInfoTable { + Util::ReferenceTable table; + + TrackInfo* GetTrackInfo(u32 index); + }; + + struct DspAdpcmChannelInfo { + DspAdpcmParam param; + DspAdpcmLoopParam loopParam; + }; + static_assert(sizeof(DspAdpcmChannelInfo) == 0x2c); + + struct ChannelInfo { + Util::Reference toDetailChannelInfo; + + DspAdpcmChannelInfo* GetDspAdpcmChannelInfo(); + }; + static_assert(sizeof(ChannelInfo) == 0x8); + + struct ChannelInfoTable { + Util::ReferenceTable table; + + ChannelInfo* GetChannelInfo(u32 index); + }; + + struct InfoBlockBody { + Util::Reference toStreamSoundInfo; + Util::Reference toTrackInfoTable; + Util::Reference toChannelInfoTable; + + StreamSoundInfo* GetStreamSoundInfo(); + TrackInfoTable* GetTrackInfoTable(); + ChannelInfoTable* GetChannelInfoTable(); + }; + static_assert(sizeof(InfoBlockBody) == 0x18); + + struct InfoBlock { + BinaryBlockHeader header; + InfoBlockBody body; + }; + static_assert(sizeof(InfoBlock) == 0x20); + + struct RegionInfo { + u32 start; + u32 end; + DspAdpcmLoopParam adpcmContext[16]; + bool isEnabled; + u8 padding[87]; + char regionName[64]; + }; + static_assert(sizeof(RegionInfo) == 0x100); + + struct RegionBlock { + BinaryBlockHeader header; + RegionInfo info; + }; + static_assert(sizeof(RegionBlock) == 0x108); + + struct GlobalChannelIndexTable { + Util::Table table; + }; +}; +} // namespace nn::atk::detail \ No newline at end of file From b4f3224791917abb9e61943a8d92d50805a3b524 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 20 Feb 2026 09:34:59 -0300 Subject: [PATCH 012/785] atk: Define members in `detail::StreamSoundPrefetchFile` --- .../atk/detail/atk_StreamSoundPrefetchFile.h | 49 +++++++++++++++++++ include/nn/atk/detail/atk_Util.h | 5 ++ 2 files changed, 54 insertions(+) diff --git a/include/nn/atk/detail/atk_StreamSoundPrefetchFile.h b/include/nn/atk/detail/atk_StreamSoundPrefetchFile.h index e69de29b..5ee2cf19 100644 --- a/include/nn/atk/detail/atk_StreamSoundPrefetchFile.h +++ b/include/nn/atk/detail/atk_StreamSoundPrefetchFile.h @@ -0,0 +1,49 @@ +#pragma once + +#include +#include +#include + +namespace nn::atk::detail { +class StreamSoundPrefetchFile { +public: + struct PrefetchDataBlock; + struct FileHeader : Util::SoundFileHeader { + + StreamSoundFile::InfoBlock* GetInfoBlock(); + + u32 GetPrefetchDataBlockSize(); + PrefetchDataBlock* GetPrefetchDataBlock(); + + bool HasRegionBlock(); + u32 GetRegionBlockOffset(); + u32 GetRegionBlockSize(); + StreamSoundFile::RegionBlock* GetRegionBlock(); + }; + + struct PrefetchSample { + u8 data[1]; + + void* GetSampleAddress(); + }; + + struct PrefetchData { + u32 startFrame; + u32 prefetchSize; + u32 reserved[1]; + Util::Reference toPrefetchSample; + + PrefetchSample* GetPrefetchSample(); + }; + static_assert(sizeof(PrefetchData) == 0x14); + + struct PrefetchDataBlockBody { + Util::Table prefetchDataTable; + }; + + struct PrefetchDataBlock { + BinaryBlockHeader header; + PrefetchDataBlockBody body; + }; +}; +} // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/atk_Util.h b/include/nn/atk/detail/atk_Util.h index ac41fb9e..dd290a13 100644 --- a/include/nn/atk/detail/atk_Util.h +++ b/include/nn/atk/detail/atk_Util.h @@ -20,6 +20,8 @@ struct Util { }; struct Reference { + constexpr static s32 InvalidOffset = -1; + // Id from ElementTypes enum u16 typeId; u8 padding[2]; @@ -51,6 +53,8 @@ struct Util { struct ReferenceWithSizeTable : Table {}; struct BitFlag { + constexpr static u32 BitNumberMax = 31; + u32 bitFlag; }; static_assert(sizeof(BitFlag) == 0x4); @@ -134,6 +138,7 @@ struct Util { class SoundArchive* arc, class SoundArchiveLoader* mgr); void* GetWaveFileOfWaveSound(void* wsdFile, u32 index, SoundArchive* arc, SoundArchiveLoader* mgr); size_t GetByteBySample(size_t samples, SampleFormat format); + size_t GetSampleByByte(size_t samples, SampleFormat format); bool IsValidMemoryForDsp(void* ptr, size_t size); }; From dc4e9ac46d6148ebac980208c69848015c09c66d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 20 Feb 2026 10:07:31 -0300 Subject: [PATCH 013/785] atk: Add `fnd` headers --- include/nn/atk/detail/fnd/atkfnd_Config.h | 0 include/nn/atk/detail/fnd/atkfnd_CriticalSection.h | 0 include/nn/atk/detail/fnd/atkfnd_FileStream.h | 0 include/nn/atk/detail/fnd/atkfnd_FileStreamImpl.h | 0 include/nn/atk/detail/fnd/atkfnd_FileStreamProxy.h | 0 include/nn/atk/detail/fnd/atkfnd_FrameHeapImpl.h | 0 include/nn/atk/detail/fnd/atkfnd_HeapBase.h | 0 include/nn/atk/detail/fnd/atkfnd_PrimitiveTypes.h | 0 include/nn/atk/detail/fnd/atkfnd_Result.h | 0 include/nn/atk/detail/fnd/atkfnd_RuntimeTypeInfo.h | 0 include/nn/atk/detail/fnd/atkfnd_ScopedLock.h | 0 include/nn/atk/detail/fnd/atkfnd_Stream.h | 0 include/nn/atk/detail/fnd/atkfnd_StreamCache.h | 0 include/nn/atk/detail/fnd/atkfnd_Thread.h | 0 include/nn/atk/detail/fnd/atkfnd_Time.h | 0 include/nn/atk/detail/fnd/atkfnd_WorkBufferAllocator.h | 0 16 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 include/nn/atk/detail/fnd/atkfnd_Config.h create mode 100644 include/nn/atk/detail/fnd/atkfnd_CriticalSection.h create mode 100644 include/nn/atk/detail/fnd/atkfnd_FileStream.h create mode 100644 include/nn/atk/detail/fnd/atkfnd_FileStreamImpl.h create mode 100644 include/nn/atk/detail/fnd/atkfnd_FileStreamProxy.h create mode 100644 include/nn/atk/detail/fnd/atkfnd_FrameHeapImpl.h create mode 100644 include/nn/atk/detail/fnd/atkfnd_HeapBase.h create mode 100644 include/nn/atk/detail/fnd/atkfnd_PrimitiveTypes.h create mode 100644 include/nn/atk/detail/fnd/atkfnd_Result.h create mode 100644 include/nn/atk/detail/fnd/atkfnd_RuntimeTypeInfo.h create mode 100644 include/nn/atk/detail/fnd/atkfnd_ScopedLock.h create mode 100644 include/nn/atk/detail/fnd/atkfnd_Stream.h create mode 100644 include/nn/atk/detail/fnd/atkfnd_StreamCache.h create mode 100644 include/nn/atk/detail/fnd/atkfnd_Thread.h create mode 100644 include/nn/atk/detail/fnd/atkfnd_Time.h create mode 100644 include/nn/atk/detail/fnd/atkfnd_WorkBufferAllocator.h diff --git a/include/nn/atk/detail/fnd/atkfnd_Config.h b/include/nn/atk/detail/fnd/atkfnd_Config.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/fnd/atkfnd_CriticalSection.h b/include/nn/atk/detail/fnd/atkfnd_CriticalSection.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/fnd/atkfnd_FileStream.h b/include/nn/atk/detail/fnd/atkfnd_FileStream.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/fnd/atkfnd_FileStreamImpl.h b/include/nn/atk/detail/fnd/atkfnd_FileStreamImpl.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/fnd/atkfnd_FileStreamProxy.h b/include/nn/atk/detail/fnd/atkfnd_FileStreamProxy.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/fnd/atkfnd_FrameHeapImpl.h b/include/nn/atk/detail/fnd/atkfnd_FrameHeapImpl.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/fnd/atkfnd_HeapBase.h b/include/nn/atk/detail/fnd/atkfnd_HeapBase.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/fnd/atkfnd_PrimitiveTypes.h b/include/nn/atk/detail/fnd/atkfnd_PrimitiveTypes.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/fnd/atkfnd_Result.h b/include/nn/atk/detail/fnd/atkfnd_Result.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/fnd/atkfnd_RuntimeTypeInfo.h b/include/nn/atk/detail/fnd/atkfnd_RuntimeTypeInfo.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/fnd/atkfnd_ScopedLock.h b/include/nn/atk/detail/fnd/atkfnd_ScopedLock.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/fnd/atkfnd_Stream.h b/include/nn/atk/detail/fnd/atkfnd_Stream.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/fnd/atkfnd_StreamCache.h b/include/nn/atk/detail/fnd/atkfnd_StreamCache.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/fnd/atkfnd_Thread.h b/include/nn/atk/detail/fnd/atkfnd_Thread.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/fnd/atkfnd_Time.h b/include/nn/atk/detail/fnd/atkfnd_Time.h new file mode 100644 index 00000000..e69de29b diff --git a/include/nn/atk/detail/fnd/atkfnd_WorkBufferAllocator.h b/include/nn/atk/detail/fnd/atkfnd_WorkBufferAllocator.h new file mode 100644 index 00000000..e69de29b From b39dca476f5db6674c8bbbb9c0b258e9ddb5e734 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 20 Feb 2026 10:42:10 -0300 Subject: [PATCH 014/785] atk: Define some of `SoundArchive` Only defined member variables and virtual functions, not general functions --- CMakeLists.txt | 1 + include/nn/atk/atk_SoundArchive.h | 36 +++++++++++++++++++ include/nn/atk/detail/atk_Config.h | 4 ++- include/nn/atk/detail/fnd/atkfnd_Config.h | 7 ++++ include/nn/atk/detail/fnd/atkfnd_FileStream.h | 8 +++++ include/nn/atk/detail/fnd/atkfnd_Stream.h | 8 +++++ 6 files changed, 63 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 171e0eb4..31d32f35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,6 +182,7 @@ add_library(NintendoSDK OBJECT include/nn/util/util_BytePtr.h include/nn/util/util_IntrusiveList.h include/nn/util/util_BitUtil.h + include/nn/util/util_IntrusiveList.h include/nn/util/util_ResDic.h include/nn/util/util_StringUtil.h include/nn/util/util_StringView.h diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index e69de29b..53ed578e 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -0,0 +1,36 @@ +#pragma once + +#include +#include + +#include + +namespace nn::atk { +class SoundArchive { +public: + using ItemId = u32; + + SoundArchive(); + + virtual ~SoundArchive(); + + virtual void* detail_GetFileAddress(ItemId itemId) = 0; + virtual size_t detail_GetRequiredStreamBufferSize() = 0; + + virtual void FileAccessBegin(); + virtual void FileAccessEnd(); + + virtual bool IsAddon(); + + virtual detail::fnd::FileStream* OpenStream(void* buffer, size_t size, + position_t begin, size_t length) = 0; + +private: + detail::SoundArchiveFileReader* m_pFileReader{}; + detail::SoundArchiveParametersHook* m_pParametersHook{}; + char m_ExtFileRoot[639]; + u32 m_FileBlockOffset; +}; +static_assert(sizeof(SoundArchive) == 0x2a0); + +} // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/atk_Config.h b/include/nn/atk/detail/atk_Config.h index 82213268..cfd0e1f6 100644 --- a/include/nn/atk/detail/atk_Config.h +++ b/include/nn/atk/detail/atk_Config.h @@ -2,7 +2,9 @@ #include +#include + namespace nn::atk { -typedef std::ptrdiff_t position_t; +using position_t = detail::fnd::position_t; } // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/detail/fnd/atkfnd_Config.h b/include/nn/atk/detail/fnd/atkfnd_Config.h index e69de29b..f805308d 100644 --- a/include/nn/atk/detail/fnd/atkfnd_Config.h +++ b/include/nn/atk/detail/fnd/atkfnd_Config.h @@ -0,0 +1,7 @@ +#pragma once + +#include + +namespace nn::atk::detail::fnd { +using position_t = std::ptrdiff_t; +} // namespace nn::atk::detail::fnd \ No newline at end of file diff --git a/include/nn/atk/detail/fnd/atkfnd_FileStream.h b/include/nn/atk/detail/fnd/atkfnd_FileStream.h index e69de29b..f7cf7da0 100644 --- a/include/nn/atk/detail/fnd/atkfnd_FileStream.h +++ b/include/nn/atk/detail/fnd/atkfnd_FileStream.h @@ -0,0 +1,8 @@ +#pragma once + +namespace nn::atk::detail::fnd { +class FileStream { +public: + virtual ~FileStream(); +}; +} // namespace nn::atk::detail::fnd \ No newline at end of file diff --git a/include/nn/atk/detail/fnd/atkfnd_Stream.h b/include/nn/atk/detail/fnd/atkfnd_Stream.h index e69de29b..70db1dcc 100644 --- a/include/nn/atk/detail/fnd/atkfnd_Stream.h +++ b/include/nn/atk/detail/fnd/atkfnd_Stream.h @@ -0,0 +1,8 @@ +#pragma once + +namespace nn::atk::detail::fnd { +class Stream { +public: + virtual ~Stream(); +}; +} // namespace nn::atk::detail::fnd \ No newline at end of file From 712472dff8cb5645d45ffd27deca50adfb8fe29f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 20 Feb 2026 11:33:17 -0300 Subject: [PATCH 015/785] atk: Define `detail::SoundArchiveFileReader` `detail::SoundArchiveFileReader` required definitions from other files, which were added as needed --- include/nn/atk/atk_SoundArchive.h | 164 +++++++++++++++++- include/nn/atk/detail/atk_SoundArchiveFile.h | 41 +++++ .../atk/detail/atk_SoundArchiveFileReader.h | 49 ++++++ include/nn/atk/detail/atk_Util.h | 10 +- 4 files changed, 259 insertions(+), 5 deletions(-) diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index 53ed578e..b8a148ce 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -1,14 +1,174 @@ #pragma once +#include #include -#include - +#include #include namespace nn::atk { +namespace detail{ +class SoundArchiveFileReader; +struct SoundArchiveParametersHook; +} // namespace nn::atk::detail + class SoundArchive { public: using ItemId = u32; + using FileId = ItemId; + using StringId = ItemId; + + enum SoundType { + SoundType_Invalid, + SoundType_Sequence, + SoundType_Stream, + SoundType_Wave, + SoundType_AdvancedWave, + }; + + enum DecodeMode { + DecodeMode_Default, + DecodeMode_Cpu, + DecodeMode_Accelerator, + }; + + struct SoundInfo { + FileId fileId; + ItemId playerId; + u8 actorPlayerId; + u8 playerPriority; + u8 volume; + u8 remoteFilter; + PanMode panMode; + PanCurve panCurve; + SinglePlayType singlePlayType; + u16 singlePlayEffectiveDuration; + bool isFrontBypass; + }; + static_assert(sizeof(SoundInfo) == 0x1c); + + struct BankInfo { + FileId fileId; + }; + static_assert(sizeof(BankInfo) == 0x4); + + struct PlayerInfo { + s32 playableSoundMax; + u32 playerHeapSize; + }; + static_assert(sizeof(PlayerInfo) == 0x8); + + struct SoundGroupInfo { + ItemId startId; + ItemId endId; + detail::Util::Table fileIdTable; + }; + static_assert(sizeof(SoundGroupInfo) == 0x10); + + struct GroupInfo { + FileId fileId; + u32 groupFileSize; + }; + static_assert(sizeof(GroupInfo) == 0x8); + + struct FileInfo { + u32 fileSize; + u32 offsetFromFileBlockHead; + char* externalFilePath; + }; + static_assert(sizeof(FileInfo) == 0x10); + + struct WaveArchiveInfo { + u32 fileId; + u32 waveCount; + bool isLoadIndividual; + u8 padding[3]; + }; + static_assert(sizeof(WaveArchiveInfo) == 0xC); + + struct SoundArchivePlayerInfo { + s32 sequenceSoundCount; + s32 sequenceTrackCount; + s32 streamSoundCount; + s32 streamTrackCount; + s32 streamChannelCount; + s32 waveSoundCount; + s32 waveTrackCount; + s32 streamBufferTimes; + bool isAdvancedWaveSoundEnabled; + }; + static_assert(sizeof(SoundArchivePlayerInfo) == 0x24); + + struct SequenceSoundInfo { + u32 startOffset; + u32 bankIds[4]; + u32 allocateTrackFlags; + u8 channelPriority; + bool isReleasePriorityFix; + }; + static_assert(sizeof(SequenceSoundInfo) == 0x1C); + + enum StreamFileType { + StreamFileType_Invalid = 0, + StreamFileType_NwStreamBinary = 1, + StreamFileType_Opus = 3, + }; + + struct StreamTrackInfo { + u8 volume; + u8 pan; + u8 surroundPan; + u8 flags; + u8 mainSend; + u8 fxSend[3]; + u8 lowPassFilterFrequency; + u8 biquadType; + u8 biquadValue; + u8 channelCount; + s8 globalChannelIndex[2]; + }; + static_assert(sizeof(StreamTrackInfo) == 0xE); + + struct StreamSoundInfo { + u16 allocateTrackFlags; + u16 allocateChannelCount; + f32 pitch; + u8 mainSend; + u8 fxSend[3]; + StreamTrackInfo trackInfo[8]; + StreamFileType streamFileType; + DecodeMode decodeMode; + FileId prefetchFileId; + void* streamBufferPool; + }; + static_assert(sizeof(StreamSoundInfo) == 0x90); + + struct StreamSoundInfo2 { + bool isLoop; + u32 loopStartFrame; + u32 loopEndFrame; + }; + static_assert(sizeof(StreamSoundInfo2) == 0xC); + + struct WaveSoundInfo { + u32 index; + u32 allocateTrackCount; + u8 channelPriority; + bool isReleasePriorityFix; + }; + static_assert(sizeof(WaveSoundInfo) == 0xC); + + struct AdvancedWaveSoundInfo { + u32 waveArchiveId; + }; + static_assert(sizeof(AdvancedWaveSoundInfo) == 0x4); + + struct Sound3DInfo { + u32 flags; + f32 decayRatio; + u8 decayCurve; + u8 dopplerFactor; + }; + static_assert(sizeof(Sound3DInfo) == 0xC); SoundArchive(); diff --git a/include/nn/atk/detail/atk_SoundArchiveFile.h b/include/nn/atk/detail/atk_SoundArchiveFile.h index e69de29b..bd391fe8 100644 --- a/include/nn/atk/detail/atk_SoundArchiveFile.h +++ b/include/nn/atk/detail/atk_SoundArchiveFile.h @@ -0,0 +1,41 @@ +#pragma once + +#include + +namespace nn::atk::detail { +struct SoundArchiveParametersHook; + +class SoundArchiveFile { +public: + struct FileHeader : BinaryFileHeader { + Util::ReferenceWithSize toBlocks[3]; + + Util::ReferenceWithSize* GetReferenceBy(u16); + + u32 GetStringBlockSize(); + u32 GetInfoBlockSize(); + u32 GetFileBlockSize(); + + s32 GetStringBlockOffset(); + s32 GetInfoBlockOffset(); + s32 GetFileBlockOffset(); + }; + static_assert(sizeof(FileHeader) == 0x38); + + struct StringBlockBody { + Util::Reference toSection[1]; + }; + + struct InfoBlockBody { + Util::Reference toSoundInfoReferenceTable; + Util::Reference toSoundGroupInfoReferenceTable; + Util::Reference toBankInfoReferenceTable; + Util::Reference toWaveArchiveInfoReferenceTable; + Util::Reference toGroupInfoReferenceTable; + Util::Reference toPlayerInfoReferenceTable; + Util::Reference toFileInfoReferenceTable; + Util::Reference toSoundArchivePlayerInfo; + }; + static_assert(sizeof(InfoBlockBody) == 0x40); +}; +} // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/atk_SoundArchiveFileReader.h b/include/nn/atk/detail/atk_SoundArchiveFileReader.h index e69de29b..f904a18b 100644 --- a/include/nn/atk/detail/atk_SoundArchiveFileReader.h +++ b/include/nn/atk/detail/atk_SoundArchiveFileReader.h @@ -0,0 +1,49 @@ +#pragma once + +#include +#include + +namespace nn::atk::detail { +class SoundArchiveFileReader { +public: + SoundArchiveFileReader(); + + void Initialize(void* soundArchiveData); + void Finalize(); + + void SetStringBlock(void* stringBlock); + void SetInfoBlock(void* infoBlock); + + SoundArchive::ItemId GetItemId(char* pStr); + char* GetItemLabel(SoundArchive::ItemId id); + + SoundArchive::FileId GetItemFileId(SoundArchive::ItemId id); + SoundArchive::FileId GetItemPrefetchFileId(SoundArchive::ItemId id); + + u32 GetPlayerCount(); + u32 GetWaveArchiveCount(); + u32 GetFileCount(); + + bool ReadSoundInfo(SoundArchive::ItemId soundId, SoundArchive::SoundInfo* info); + bool ReadBankInfo(SoundArchive::ItemId bankId, SoundArchive::BankInfo* info); + bool ReadPlayerInfo(SoundArchive::ItemId playerId, SoundArchive::PlayerInfo* info); + bool ReadSoundGroupInfo(SoundArchive::ItemId soundGroupId, SoundArchive::SoundGroupInfo* info); + bool ReadGroupInfo(SoundArchive::ItemId groupId, SoundArchive::GroupInfo* info); + bool ReadFileInfo(SoundArchive::FileId id, SoundArchive::FileInfo* info, s32 index); + bool ReadWaveArchiveInfo(SoundArchive::ItemId warcId, SoundArchive::WaveArchiveInfo* info); + bool ReadSoundArchivePlayerInfo(SoundArchive::SoundArchivePlayerInfo* info); + bool ReadSequenceSoundInfo(SoundArchive::ItemId soundId, SoundArchive::SequenceSoundInfo* info); + bool ReadStreamSoundInfo(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo* info); + bool ReadStreamSoundInfo2(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo2* info); + bool ReadWaveSoundInfo(SoundArchive::ItemId soundId, SoundArchive::WaveSoundInfo* info); + bool ReadAdvancedWaveSoundInfo(SoundArchive::ItemId soundId, SoundArchive::AdvancedWaveSoundInfo* info); + + Util::Table* GetWaveArchiveIdTable(SoundArchive::ItemId id); + SoundArchive::SoundType GetSoundType(SoundArchive::ItemId soundId); + +private: + detail::SoundArchiveFile::FileHeader m_pHeader; + detail::SoundArchiveFile::StringBlockBody* m_pStringBlockBody; + detail::SoundArchiveFile::InfoBlockBody* m_pInfoBlockBody; +}; +} // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/atk_Util.h b/include/nn/atk/detail/atk_Util.h index dd290a13..028fac97 100644 --- a/include/nn/atk/detail/atk_Util.h +++ b/include/nn/atk/detail/atk_Util.h @@ -5,7 +5,10 @@ #include #include -namespace nn::atk::detail { +namespace nn::atk { +class SoundArchive; + +namespace detail { struct Util { NN_NO_COPY(Util); NN_NO_MOVE(Util); @@ -135,7 +138,7 @@ struct Util { WaveArchiveLoadStatus GetWaveArchiveOfBank(class LoadItemInfo* warcLoadInfo, bool* isLoadIndividual, void* bankFile, - class SoundArchive* arc, class SoundArchiveLoader* mgr); + SoundArchive* arc, class SoundArchiveLoader* mgr); void* GetWaveFileOfWaveSound(void* wsdFile, u32 index, SoundArchive* arc, SoundArchiveLoader* mgr); size_t GetByteBySample(size_t samples, SampleFormat format); size_t GetSampleByByte(size_t samples, SampleFormat format); @@ -143,4 +146,5 @@ struct Util { bool IsValidMemoryForDsp(void* ptr, size_t size); }; -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail +} // namespace nn::atk \ No newline at end of file From 92d64a4e97e2eb7645be88957f8ef8333be30083 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 20 Feb 2026 16:08:32 -0300 Subject: [PATCH 016/785] atk: Define `ElementType` enum --- include/nn/atk/detail/atk_ElementType.h | 142 ++++++++++++++++++++++++ 1 file changed, 142 insertions(+) diff --git a/include/nn/atk/detail/atk_ElementType.h b/include/nn/atk/detail/atk_ElementType.h index e69de29b..fcb4d186 100644 --- a/include/nn/atk/detail/atk_ElementType.h +++ b/include/nn/atk/detail/atk_ElementType.h @@ -0,0 +1,142 @@ +#pragma once + +namespace nn::atk::detail { +enum ElementType { + ElementType_Category_Tables = 0x100, + ElementType_Category_Parameters = 0x200, + ElementType_Category_Codecs = 0x300, + + ElementType_Category_General = 0x1F00, + + ElementType_Category_SoundArchiveFile_Blocks = 0x2000, + ElementType_Category_SoundArchiveFile_InfoSections = 0x2100, + ElementType_Category_SoundArchiveFile_ItemInfos = 0x2200, + ElementType_Category_SoundArchiveFile_Parameters = 0x2300, + ElementType_Category_SoundArchiveFile_General = 0x2400, + + ElementType_Category_StreamSoundFile_Blocks = 0x4000, + ElementType_Category_StreamSoundFile_ItemInfos = 0x4100, + + ElementType_Category_WaveSoundFile_Blocks = 0x4800, + ElementType_Category_WaveSoundFile_ItemInfos = 0x4900, + + ElementType_Category_SequenceSoundFile_Blocks = 0x5000, + ElementType_Category_SequenceSoundFile_ItemInfos = 0x5100, + + ElementType_Category_BankFile_Blocks = 0x5800, + ElementType_Category_BankFile_Items = 0x5900, + ElementType_Category_BankFile_ItemTables = 0x6000, + + ElementType_Category_WaveArchiveFile_Blocks = 0x6800, + + ElementType_Category_WaveFile_Blocks = 0x7000, + ElementType_Category_WaveFile_ItemInfos = 0x7100, + + ElementType_Category_GroupFile_Blocks = 0x7800, + ElementType_Category_GroupFile_ItemInfos = 0x7900, + + ElementType_Category_AnimSoundFile_Blocks = 0x8000, + ElementType_Category_AnimSoundFile_Items = 0x8100, + + ElementType_Table_EmbeddingTable = ElementType_Category_Tables, + ElementType_Table_ReferenceTable, + ElementType_Table_ReferenceWithSizeTable, + + ElementType_Parameter_Sound3d = ElementType_Category_Parameters, + ElementType_Parameter_Sends, + ElementType_Parameter_Envelope, + ElementType_Parameter_AdshrEnvelope, + + ElementType_Codec_DspAdpcmInfo = ElementType_Category_Codecs, + ElementType_Codec_ImaAdpcmInfo, + + ElementType_General_ByteStream = ElementType_Category_General, + ElementType_General_String, + + ElementType_SoundArchiveFile_StringBlock = ElementType_Category_SoundArchiveFile_Blocks, + ElementType_SoundArchiveFile_InfoBlock, + ElementType_SoundArchiveFile_FileBlock, + + ElementType_SoundArchiveFile_SoundInfoSection = ElementType_Category_SoundArchiveFile_InfoSections, + ElementType_SoundArchiveFile_BankInfoSection, + ElementType_SoundArchiveFile_PlayerInfoSection, + ElementType_SoundArchiveFile_WaveArchiveInfoSection, + ElementType_SoundArchiveFile_SoundGroupInfoSection, + ElementType_SoundArchiveFile_GroupInfoSection, + ElementType_SoundArchiveFile_FileInfoSection, + + ElementType_SoundArchiveFile_SoundInfo = ElementType_Category_SoundArchiveFile_ItemInfos, + ElementType_SoundArchiveFile_StreamSoundInfo, + ElementType_SoundArchiveFile_WaveSoundInfo, + ElementType_SoundArchiveFile_SequenceSoundInfo, + ElementType_SoundArchiveFile_SoundGroupInfo, + ElementType_SoundArchiveFile_WaveSoundGroupInfo, + ElementType_SoundArchiveFile_BankInfo, + ElementType_SoundArchiveFile_WaveArchiveInfo, + ElementType_SoundArchiveFile_GroupInfo, + ElementType_SoundArchiveFile_PlayerInfo, + ElementType_SoundArchiveFile_FileInfo, + ElementType_SoundArchiveFile_SoundArchivePlayerInfo, + ElementType_SoundArchiveFile_InternalFileInfo, + ElementType_SoundArchiveFile_ExternalFileInfo, + ElementType_SoundArchiveFile_StreamSoundTrackInfo, + ElementType_SoundArchiveFile_SendInfo, + ElementType_SoundArchiveFile_StreamSoundExtensionInfo, + + ElementType_SoundArchiveFile_StringTable = ElementType_Category_SoundArchiveFile_General, + ElementType_SoundArchiveFile_PatriciaTree, + + ElementType_StreamSoundFile_InfoBlock = ElementType_Category_StreamSoundFile_Blocks, + ElementType_StreamSoundFile_SeekBlock, + ElementType_StreamSoundFile_DataBlock, + ElementType_StreamSoundFile_RegionBlock, + ElementType_StreamSoundFile_PrefetchDataBlock, + + ElementType_StreamSoundFile_StreamSoundInfo = ElementType_Category_StreamSoundFile_ItemInfos, + ElementType_StreamSoundFile_TrackInfo, + ElementType_StreamSoundFile_ChannelInfo, + + ElementType_WaveSoundFile_WaveSoundMetaData = ElementType_Category_WaveSoundFile_ItemInfos, + ElementType_WaveSoundFile_WaveSoundInfo, + ElementType_WaveSoundFile_NoteInfo, + ElementType_WaveSoundFile_TrackInfo, + ElementType_WaveSoundFile_NoteEvent, + + ElementType_SequenceSoundFile_DataBlock = ElementType_Category_SequenceSoundFile_Blocks, + ElementType_SequenceSoundFile_LabelBlock, + + ElementType_SequenceSoundFile_LabelInfo = ElementType_Category_SequenceSoundFile_ItemInfos, + + ElementType_BankFile_InfoBlock = ElementType_Category_BankFile_Blocks, + + ElementType_BankFile_InstrumentInfo = ElementType_Category_BankFile_Items, + ElementType_BankFile_KeyRegionInfo, + ElementType_BankFile_VelocityRegionInfo, + ElementType_BankFile_NullInfo, + + ElementType_BankFile_DirectReferenceTable = ElementType_Category_BankFile_ItemTables, + ElementType_BankFile_RangeReferenceTable, + ElementType_BankFile_IndexReferenceTable, + + ElementType_WaveArchiveFile_InfoBlock = ElementType_Category_WaveArchiveFile_Blocks, + ElementType_WaveArchiveFile_FileBlock, + + ElementType_WaveSoundFile_InfoBlock = ElementType_Category_WaveArchiveFile_Blocks, + + ElementType_WaveFile_InfoBlock = ElementType_Category_WaveFile_Blocks, + ElementType_WaveFile_DataBlock, + + ElementType_WaveFile_ChannelInfo = ElementType_Category_WaveFile_ItemInfos, + + ElementType_GroupFile_InfoBlock = ElementType_Category_GroupFile_Blocks, + ElementType_GroupFile_FileBlock, + ElementType_GroupFile_InfoExBlock, + + ElementType_GroupFile_GroupItemInfo = ElementType_Category_GroupFile_ItemInfos, + ElementType_GroupFile_GroupItemInfoEx, + + ElementType_AnimSoundFile_DataBlock = ElementType_Category_AnimSoundFile_Blocks, + + ElementType_AnimSoundFile_EventInfo = ElementType_Category_AnimSoundFile_Items +}; +} // namespace nn::atk::detail \ No newline at end of file From b8c6946a90b66d2c45bf0f92b54ea820dcd08b3b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 21 Feb 2026 09:53:05 -0300 Subject: [PATCH 017/785] atk: Define `detail::WaveFile` and its member structs --- include/nn/atk/detail/atk_WaveFile.h | 58 ++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/include/nn/atk/detail/atk_WaveFile.h b/include/nn/atk/detail/atk_WaveFile.h index e69de29b..5337c822 100644 --- a/include/nn/atk/detail/atk_WaveFile.h +++ b/include/nn/atk/detail/atk_WaveFile.h @@ -0,0 +1,58 @@ +#pragma once + +#include + +namespace nn::atk::detail { +struct WaveFile { + struct InfoBlock; + struct DataBlock; + struct FileHeader : Util::SoundFileHeader { + InfoBlock* GetInfoBlock(); + DataBlock* GetDataBlock(); + }; + + struct ChannelInfo; + struct InfoBlockBody { + u8 encoding; + u8 isLoop; + u8 padding; + u32 sampleRate; + u32 loopStartFrame; + u32 loopEndFrame; + u32 originalLoopStartFrame; + Util::ReferenceTable channelInfoReferenceTable; + + ChannelInfo* GetChannelInfo(s32 channelIndex); + }; + + struct InfoBlock { + BinaryBlockHeader header; + InfoBlockBody body; + }; + + struct DspAdpcmInfo { + DspAdpcmParam adpcmParam; + DspAdpcmLoopParam adpcmLoopParam; + }; + static_assert(sizeof(DspAdpcmInfo) == 0x2C); + + struct ChannelInfo { + Util::Reference referToSamples; + Util::Reference referToAdpcmInfo; + u32 reserved; + + void* GetSamplesAddress(void* dataBlockBodyAddress); + DspAdpcmInfo* GetDspAdpcmInfo(); + }; + static_assert(sizeof(ChannelInfo) == 0x14); + + struct DataBlock { + BinaryBlockHeader header; + union { + s8 pcm8[1]; + s16 pcm16[1]; + u8 byte[1]; + }; + }; +}; +} // namespace nn::atk::detail \ No newline at end of file From 17df5e26dbcac9a0337166bde35d3724e5f1ae32 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 21 Feb 2026 10:12:53 -0300 Subject: [PATCH 018/785] atk: Define `detail::WaveSoundFile` and its member structs --- include/nn/atk/detail/atk_WaveSoundFile.h | 72 +++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/include/nn/atk/detail/atk_WaveSoundFile.h b/include/nn/atk/detail/atk_WaveSoundFile.h index e69de29b..50b8334d 100644 --- a/include/nn/atk/detail/atk_WaveSoundFile.h +++ b/include/nn/atk/detail/atk_WaveSoundFile.h @@ -0,0 +1,72 @@ +#pragma once + +#include + +namespace nn::atk::detail { +struct WaveSoundFile { + struct InfoBlock; + struct FileHeader : Util::SoundFileHeader { + InfoBlock* GetInfoBlock(); + }; + + struct WaveSoundData; + struct InfoBlockBody { + Util::Reference toWaveIdTable; + Util::Reference toWaveSoundDataReferenceTable; + + WaveSoundData* GetWaveSoundData(u32 index); + Util::WaveIdTable* GetWaveIdTable(); + }; + static_assert(sizeof(InfoBlockBody) == 0x10); + + struct InfoBlock { + BinaryBlockHeader header; + InfoBlockBody body; + }; + static_assert(sizeof(InfoBlock) == 0x18); + + struct NoteInfo; + struct WaveSoundInfo; + struct WaveSoundData { + Util::Reference toWaveSoundInfo; + Util::Reference toTrackInfoReferenceTable; + Util::Reference toNoteInfoReferenceTable; + + WaveSoundInfo* GetWaveSoundInfo(); + NoteInfo* GetNoteInfo(u32 index); + }; + static_assert(sizeof(WaveSoundData) == 0x18); + + struct WaveSoundInfo { + Util::BitFlag optionParameter; + + u8 GetPan(); + s8 GetSurroundPan(); + f32 GetPitch(); + void GetSendValue(u8* mainSend, u8* fxSend, u8 fxSendCount); + AdshrCurve* GetAdshrCurve(); + u8 GetLpfFreq(); + u8 GetBiquadType(); + u8 GetBiquadValue(); + }; + static_assert(sizeof(WaveSoundInfo) == 0x4); + + struct NoteInfo { + u32 waveIdTableIndex; + Util::BitFlag optionParameter; + + u8 GetOriginalKey(); + u8 GetVolume(); + u8 GetPan(); + u8 GetSurroundPan(); + f32 GetPitch(); + AdshrCurve* GetAdshrCurve(); + }; + static_assert(sizeof(NoteInfo) == 0x8); + + struct TrackInfo { + Util::Reference toNoteEventReferenceTable; + }; + static_assert(sizeof(TrackInfo) == 0x8); +}; +} // namespace nn::atk::detail \ No newline at end of file From 2af3d30f74391fc0a5c4cf8bd796e98a95668077 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 21 Feb 2026 10:24:01 -0300 Subject: [PATCH 019/785] atk: Define `detail::WaveArchiveFile` and its member structs --- include/nn/atk/detail/atk_WaveArchiveFile.h | 35 +++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/include/nn/atk/detail/atk_WaveArchiveFile.h b/include/nn/atk/detail/atk_WaveArchiveFile.h index e69de29b..eb7ca6d2 100644 --- a/include/nn/atk/detail/atk_WaveArchiveFile.h +++ b/include/nn/atk/detail/atk_WaveArchiveFile.h @@ -0,0 +1,35 @@ +#pragma once + +#include + +namespace nn::atk::detail { +struct WaveArchiveFile { + struct InfoBlock; + struct FileBlock; + struct FileHeader : BinaryFileHeader { + Util::ReferenceWithSize toBlocks[2]; + + InfoBlock* GetInfoBlock(); + u32 GetInfoBlockOffset(); + + FileBlock* GetFileBlock(); + u32 GetFileBlockOffset(); + }; + static_assert(sizeof(FileHeader) == 0x2C); + + struct FileBlockBody { /* Unknown structure */ }; + struct FileBlock { + BinaryBlockHeader header; + FileBlockBody body; + }; + + struct InfoBlockBody { + Util::ReferenceWithSizeTable table; + }; + + struct InfoBlock { + BinaryBlockHeader header; + InfoBlockBody body; + }; +}; +} // namespace nn::atk::detail \ No newline at end of file From c8fafccd18ab7e72d4c229ccfdd5dd9467cab426 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 21 Feb 2026 20:09:55 -0300 Subject: [PATCH 020/785] atk: Define `detail::SequenceSoundFile` --- include/nn/atk/detail/atk_SequenceSoundFile.h | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/include/nn/atk/detail/atk_SequenceSoundFile.h b/include/nn/atk/detail/atk_SequenceSoundFile.h index e69de29b..3e20155c 100644 --- a/include/nn/atk/detail/atk_SequenceSoundFile.h +++ b/include/nn/atk/detail/atk_SequenceSoundFile.h @@ -0,0 +1,45 @@ +#pragma once + +#include + +namespace nn::atk::detail { +struct SequenceSoundFile { + struct DataBlock; + struct LabelBlock; + struct FileHeader : Util::SoundFileHeader { + DataBlock* GetDataBlock(); + LabelBlock* GetLabelBlock(); + }; + + struct LabelInfo { + Util::Reference referToSequenceData; + u32 labelStringLength; + char label[1]; + }; + + struct LabelBlockBody { + Util::ReferenceTable labelInfoReferenceTable; + + LabelInfo* GetLabelInfo(s32 index) const; + char* GetLabel(s32 index) const; + char* GetLabelByOffest(s32 labelOffset) const; + + u32 GetOffset(s32 index, u32* offsetPtr) const; + bool GetOffsetByLabel(char* label, u32* offsetPtr) const; + }; + + struct LabelBlock { + BinaryBlockHeader header; + LabelBlockBody body; + }; + + struct DataBlockBody { + u8 sequenceData[1]; + }; + + struct DataBlock { + BinaryBlockHeader header; + DataBlockBody body; + }; +}; +} // namespace nn::atk::detail \ No newline at end of file From f819d899b0b6648007fef58b730c935c10b71db7 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 21 Feb 2026 20:34:48 -0300 Subject: [PATCH 021/785] atk: Define `detail::BankFile` --- .../nn/atk/detail/atk_AdvancedWaveSoundFile.h | 4 +- include/nn/atk/detail/atk_BankFile.h | 63 +++++++++++++++++++ 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h b/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h index 9ee04838..1039cf63 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h @@ -6,6 +6,8 @@ namespace nn::atk::detail { struct AdvancedWaveSoundFile { + util::BinaryFileHeader fileHeader; + struct InfoBlockBody { u32 offsetToTrackTableReference; BinaryTypes::Reference toTrackTable; @@ -36,8 +38,6 @@ struct AdvancedWaveSoundFile { u32 offsetToClipTableReference; BinaryTypes::Reference toClipTable; }; - - util::BinaryFileHeader fileHeader; }; static_assert(sizeof(AdvancedWaveSoundFile) == 0x20); diff --git a/include/nn/atk/detail/atk_BankFile.h b/include/nn/atk/detail/atk_BankFile.h index e69de29b..53c24fa3 100644 --- a/include/nn/atk/detail/atk_BankFile.h +++ b/include/nn/atk/detail/atk_BankFile.h @@ -0,0 +1,63 @@ +#pragma once + +#include +#include "nn/atk/atk_Global.h" + +namespace nn::atk::detail { +struct BankFile { + struct InfoBlock; + struct FileHeader : Util::SoundFileHeader { + InfoBlock* GetInfoBlock() const; + }; + + struct Instrument; + struct InfoBlockBody { + Util::Reference toWaveIdTable; + Util::Reference toInstrumentReferenceTable; + + Util::WaveIdTable* GetWaveIdTable() const; + Util::ReferenceTable GetInstrumentReferenceTable() const; + Instrument* GetInstrument(s32 programNo) const; + }; + static_assert(sizeof(InfoBlockBody) == 0x10); + + struct InfoBlock { + BinaryBlockHeader header; + InfoBlockBody body; + }; + static_assert(sizeof(InfoBlock) == 0x18); + + struct KeyRegion; + struct Instrument { + Util::Reference toKeyRegionChunk; + + KeyRegion* GetKeyRegion(u32 key) const; + }; + static_assert(sizeof(Instrument) == 0x8); + + struct VelocityRegion; + struct KeyRegion { + Util::Reference toVelocityRegionChunk; + + VelocityRegion* GetVelocityRegion(u32 velocity) const; + }; + static_assert(sizeof(KeyRegion) == 0x8); + + struct RegionParameter; + struct VelocityRegion { + u32 waveIdTableIndex; + Util::BitFlag optionParameter; + + u8 GetOriginalKey() const; + u8 GetVolume() const; + u8 GetPan() const; + f32 GetPitch() const ; + bool IsIgnoreNoteOff() const; + u8 GetKeyGroup() const; + u8 GetInterpolationType() const; + AdshrCurve* GetAdshrCurve() const; + RegionParameter* GetRegionParameter() const; + }; + static_assert(sizeof(VelocityRegion) == 0x8); +}; +} // namespace nn::atk::detail \ No newline at end of file From fba649ea9ee18eed26c5567dd79bea95e434c361 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 21 Feb 2026 20:45:48 -0300 Subject: [PATCH 022/785] atk: Define `detail::GroupFile` --- include/nn/atk/detail/atk_GroupFile.h | 55 +++++++++++++++++++++ include/nn/atk/detail/atk_WaveArchiveFile.h | 2 +- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/detail/atk_GroupFile.h b/include/nn/atk/detail/atk_GroupFile.h index e69de29b..62101203 100644 --- a/include/nn/atk/detail/atk_GroupFile.h +++ b/include/nn/atk/detail/atk_GroupFile.h @@ -0,0 +1,55 @@ +#pragma once + +#include + +namespace nn::atk::detail { +struct GroupFile { + struct FileHeader : Util::SoundFileHeader { + struct InfoBlock* GetInfoBlock(); + struct FileBlock* GetFileBlock(); + struct InfoExBlock* GetInfoExBlock(); + }; + + struct InfoBlockBody { + Util::ReferenceTable referenceTableOfGroupItemInfo; + }; + + struct InfoBlock { + BinaryBlockHeader header; + InfoBlockBody body; + }; + + struct FileBlockBody {/* unknown structure */}; + + struct FileBlock { + BinaryBlockHeader header; + FileBlockBody body; + }; + + struct InfoExBlockBody { + Util::ReferenceTable referenceTableOfGroupItemInfoEx; + }; + + struct InfoExBlock { + BinaryBlockHeader header; + InfoExBlockBody body; + }; + + struct GroupItemInfo { + constexpr static s32 OffsetForLink = -1; + constexpr static s32 SizeForLink = -1; + + u32 fileId; + Util::ReferenceWithSize embeddedItemInfo; + }; + static_assert(sizeof(GroupItemInfo) == 0x10); + + struct GroupItemInfoEx { + u32 itemId; + u32 loadFlag; + }; + static_assert(sizeof(GroupItemInfoEx) == 0x8); + +}; + +} // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/atk_WaveArchiveFile.h b/include/nn/atk/detail/atk_WaveArchiveFile.h index eb7ca6d2..929681b0 100644 --- a/include/nn/atk/detail/atk_WaveArchiveFile.h +++ b/include/nn/atk/detail/atk_WaveArchiveFile.h @@ -17,7 +17,7 @@ struct WaveArchiveFile { }; static_assert(sizeof(FileHeader) == 0x2C); - struct FileBlockBody { /* Unknown structure */ }; + struct FileBlockBody { /* unknown structure */ }; struct FileBlock { BinaryBlockHeader header; FileBlockBody body; From 62e4b234180db84caf15db2411c12cdfc39989c2 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 21 Feb 2026 22:36:54 -0300 Subject: [PATCH 023/785] atk: Define `SoundSystem` Some methods have been left as comments because of undeclared classes needed for them --- include/nn/atk/atk_SoundSystem.h | 244 +++++++++++++++++++++++++++++++ 1 file changed, 244 insertions(+) diff --git a/include/nn/atk/atk_SoundSystem.h b/include/nn/atk/atk_SoundSystem.h index e69de29b..3329eb7b 100644 --- a/include/nn/atk/atk_SoundSystem.h +++ b/include/nn/atk/atk_SoundSystem.h @@ -0,0 +1,244 @@ +#pragma once + +#include +#include +#include + +#include +#include + +namespace nn::audio { +struct MemoryPoolType; +} // namespace nn::audio + +namespace nn::atk { +struct SoundSystem { + static bool g_IsInitialized; + static bool g_IsStreamLoadWait; + static bool g_IsInitializedDriverCommandManager; + + static std::uintptr_t g_LoadThreadStackPtr; + static std::size_t g_LoadThreadStackSize; + + static std::uintptr_t g_SoundThreadStackPtr; + static std::size_t g_SoundThreadStackSize; + + static std::uintptr_t g_PerformanceFrameBuffer; + static std::size_t g_PerformanceFrameBufferSize; + + static std::size_t g_SoundThreadCommandBufferSize; + static std::size_t g_TaskThreadCommandBufferSize; + + static s32 g_RendererSampleRate; + static s32 g_CustomSubMixSubMixCount; + static s32 g_CustomSubMixMixBufferCount; + + static bool g_IsProfilerEnabled; + static bool g_IsDetailSoundThreadProfilerEnabled; + static bool g_IsAdditionalEffectBusEnabled; + static bool g_IsAdditionalSubMixEnabled; + static bool g_IsEffectEnabled; + static bool g_IsRecordingEnabled; + static bool g_IsCircularBufferSinkEnabled; + static bool g_IsCircularBufferSinkWarningDisplayed; + static bool g_IsVoiceDropEnabled; + static bool g_IsPreviousSdkVersionLowPassFilterCompatible; + static bool g_IsUnusedEffectChannelMutingEnabled; + static bool g_IsUserThreadRenderingEnabled; + static bool g_IsCustomSubMixEnabled; + static bool g_IsMemoryPoolAttachCheckEnabled; + static bool g_IsBusMixVolumeEnabled; + static bool g_IsVolumeThroughModeEnabled; + + const static s32 g_TaskThreadFsPriority; // = 1; + const static bool g_IsStreamOpenFailureHalt; // = true; + const static bool g_IsTaskThreadEnabled; // = true; + const static bool g_IsManagingMemoryPool; // = true; + const static u32 g_VoiceCountMax; // = 96; + const static u32 g_UserEffectCount; // = 10; + const static bool g_IsSubMixEnabled; // = true; + const static bool g_IsPresetSubMixEnabled; // = true; + const static bool g_IsStereoModeEnabled; // = true; + const static bool g_IsSoundThreadEnabled; // = true; + const static s32 g_BusCountMax; // = 4; + + struct SoundSystemParam { + s32 soundThreadPriority{4}; + std::size_t soundThreadStackSize{0x4000}; + std::size_t soundThreadCommandBufferSize{0x20000}; + std::size_t voiceCommandBufferSize; + s32 taskThreadPriority{3}; + std::size_t taskThreadStackSize{0x4000}; + std::size_t taskThreadCommandBufferSize{0x2000}; + FsPriority taskThreadFsPriority{FsPriority_Normal}; + bool enableNwRenderer{}; + u32 nwVoiceSynthesizeBufferCount; + s32 rendererSampleRate{48000}; + s32 effectCount{10}; + s32 voiceCountMax{96}; + s32 voiceCommandWaveBufferPacketCount{0x200}; + bool enableProfiler{false}; + bool enableDetailSoundThreadProfile{false}; + bool enableRecordingFinalOutputs{false}; + bool enableCircularBufferSink{false}; + s32 recordingAudioFrameCount{8}; + s32 soundThreadCoreNumber; + s32 taskThreadCoreNumber; + bool enableAdditionalEffectBus{false}; + bool enableAdditionalSubMix{false}; + bool enableTaskThread{true}; + bool enableSoundThread{true}; + bool enableMemoryPoolManagement{true}; + bool enableCircularBufferSinkBufferManagement{true}; + bool enableEffect{true}; + bool enableSubMix{true}; + bool enableStereoMode{false}; + bool enableVoiceDrop{true}; + bool enableCompatibleDownMixSetting{false}; + bool enableCompatibleLowPassFilter; + bool enableUnusedEffectChannelMuting; + bool enableCompatibleBusVolume; + bool enableUserThreadRendering; + bool enableCustomSubMix; + s32 subMixCount{0}; + s32 subMixTotalChannelCount{0}; + s32 mixBufferCount{-1}; + s32 busCountMax{4}; + bool enableMemoryPoolAttachCheck{false}; + bool enableBusMixVolume{false}; + bool enableVolumeThroughMode{false}; + + SoundSystemParam(); + }; + static_assert(sizeof(SoundSystemParam) == 0x88); + + struct InitializeBufferSet { + std::uintptr_t workMem; + std::size_t workMemSize; + std::uintptr_t memoryPoolMem; + std::size_t memoryPoolMemSize; + std::uintptr_t circularBufferSinkMem; + std::size_t circularBufferSinkMemSize; + }; + static_assert(sizeof(InitializeBufferSet) == 0x30); + + static std::size_t GetRequiredMemSize(const SoundSystemParam& param); + static std::size_t GetRequiredMemSizeForCircularBufferSink(const SoundSystemParam& param); + static std::size_t GetRequiredMemSizeForMemoryPool(const SoundSystemParam& param); + + static void SetupHardwareManagerParameter(class HardwareManagerParameter* pOutValue, SoundSystemParam* parameter); + + static bool detail_InitializeSoundSystem(Result* pOutResult, const SoundSystemParam& param, const InitializeBufferSet& bufferSet); + static void detail_InitializeDriverCommandManager(const SoundSystemParam& param, u64, u64, u64, u64); + + static bool Initialize(SoundSystemParam* param, std::uintptr_t workMem, std::size_t workMemSize); + static bool Initialize(Result* pOutResult, const SoundSystemParam& param, std::uintptr_t workMem, std::size_t workMemSize); + + static void SetupInitializeBufferSet(InitializeBufferSet* pOutValue, SoundSystemParam* param, InitializeBufferSet* bufferSet); + + static bool Initialize(SoundSystemParam* param, u64, u64, u64, u64); + static bool Initialize(Result* pOutResult, const SoundSystemParam& param, u64, u64, u64, u64); + + static bool Initialize(const SoundSystemParam& param, const InitializeBufferSet& bufferSet); + static bool Initialize(Result* pOutResult, const SoundSystemParam& param, const InitializeBufferSet& bufferSet); + + static void Finalize(); + + static void SetSoundThreadBeginUserCallback(void(*threadBeginUserCallback)(u64), std::uintptr_t threadBeginUserCallbackArg); + static void ClearSoundThreadBeginUserCallback(); + + static void SetSoundThreadEndUserCallback(void(*threadEndUserCallback)(u64), std::uintptr_t threadEndUserCallbackArg); + static void ClearSoundThreadEndUserCallback(); + + static bool IsInitialized(); + + static void SuspendAudioRenderer(TimeSpan timeSpan); + static void ResumeAudioRenderer(TimeSpan timeSpan); + + static void AttachMemoryPool(audio::MemoryPoolType* pMemoryPool, void* address, std::size_t size); + static void DetachMemoryPool(audio::MemoryPoolType* pMemoryPool); + + static void DumpMemory(); + + static std::size_t GetAudioRendererBufferSize(); + + // void SetupHardwareManagerParameterFromCurrentSetting(detail::driver::HardwareManager::HardwareManagerParameter* pHardwareManagerParameter); + + static std::size_t GetRecorderBufferSize(); + static std::size_t GetUserCircularBufferSinkBufferSize(); + static std::size_t GetLowLevelVoiceAllocatorBufferSize(); + static std::size_t GetMultiVoiceManagerBufferSize(); + static std::size_t GetChannelManagerBufferSize(); + static std::size_t GetDriverCommandBufferSize(); + static std::size_t GetAllocatableDriverCommandSize(); + static std::size_t GetAllocatedDriverCommandBufferSize(); + static std::size_t GetAllocatedDriverCommandCount(); + + static void RegisterAudioRendererPerformanceReader(AudioRendererPerformanceReader& audioRendererPerformanceReader); + + // static bool AppendEffect(AuxBus auxBus, EffectBase* pEffectBase, void*, u64); + // static bool AppendEffect(AuxBus auxBus, EffectBase* pEffectBase, void*, u64, OutputDevice); + // static bool AppendEffect(AuxBus auxBus, EffectBase* pEffectBase, void*, u64, OutputDevice, s32); + + // static bool AppendEffect(AuxBus auxBus, EffectAux* pEffectAux, void*, u64); + // static bool AppendEffect(AuxBus auxBus, EffectAux* pEffectAux, void*, u64, OutputDevice); + // static bool AppendEffect(AuxBus auxBus, EffectAux* pEffectAux, void*, u64, OutputDevice, s32); + + // static bool AppendEffectToFinalMix(EffectAux* pEffectAux, void*, u64); + // static bool AppendEffectToAdditionalSubMix(EffectAux* pEffectAux, void*, u64); + + // static std::size_t GetRequiredEffectAuxBufferSize(EffectAux* pEffectAux); + + // static void RemoveEffect(AuxBus auxBus, EffectBase* pEffectBase); + // static void RemoveEffect(AuxBus auxBus, EffectBase* pEffectBase, OutputDevice outputDevice); + // static void RemoveEffect(AuxBus auxBus, EffectBase* pEffectBase, OutputDevice outputDevice, s32); + + // static void RemoveEffect(AuxBus auxBus, EffectAux* pEffectAux); + // static void RemoveEffect(AuxBus auxBus, EffectAux* pEffectAux, OutputDevice outputDevice); + // static void RemoveEffect(AuxBus auxBus, EffectAux* pEffectAux, OutputDevice outputDevice, s32); + + // static void RemoveEffectFromFinalMix(EffectAux* pEffectAux); + // static void RemoveEffectFromAdditionalSubMix(EffectAux* pEffectAux); + + static void ClearEffect(AuxBus auxBus); + static void ClearEffect(AuxBus auxBus, OutputDevice outputDevice); + static void ClearEffect(AuxBus auxBus, OutputDevice outputDevice, s32); + + static void ClearEffectFromFinalMix(); + static void ClearEffectFromAdditionalSubMix(); + + static bool IsClearEffectFinished(AuxBus auxBus); + static bool IsClearEffectFinished(AuxBus auxBus, OutputDevice outputDevice); + static bool IsClearEffectFinished(AuxBus auxBus, OutputDevice outputDevice, s32); + + static bool IsClearEffectFromFinalMixFinished(); + static bool IsClearEffectFromAdditionalSubMixFinished(); + + static void SetAuxBusVolume(AuxBus auxBus, f32 volume, TimeSpan timeSpan); + static void SetAuxBusVolume(AuxBus auxBus, f32 volume, TimeSpan timeSpan, s32); + + static f32 GetAuxBusVolume(AuxBus auxBus); + static f32 GetAuxBusVolume(AuxBus auxBus, s32); + + static void VoiceCommandProcess(UpdateType updateType, u32); + static void VoiceCommandProcess(u32); + + static void VoiceCommandUpdate(); + + static std::size_t GetPerformanceFrameBufferSize(); + + static s32 GetDroppedLowLevelVoiceCount(); + + // static void RegisterSoundThreadUpdateProfileReader(AtkProfileReader&); + // static void UnregisterSoundThreadUpdateProfileReader(AtkProfileReader&); + + static bool ReadCircularBufferSink(void*, u64); + + static std::size_t GetCircularBufferSinkBufferSize(); + + static u32 GetRendererSampleCount(); + static u32 GetRendererChannelCountMax(); + + static detail::SoundInstanceConfig GetSoundInstanceConfig(); +}; +} // namespace nn::atk \ No newline at end of file From a8ccdffe96bf74f8e43503dffedc33d7a6ff38c2 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 21 Feb 2026 22:57:37 -0300 Subject: [PATCH 024/785] atk: Define `atk_Adpcm.h` header structs An extra header for `nn::audio` was added as it was used in `atk_Adpcm.h` --- CMakeLists.txt | 2 ++ include/nn/atk/atk_Adpcm.h | 15 +++++++++++++-- include/nn/audio/audio_Adpcm.h | 16 ++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 include/nn/audio/audio_Adpcm.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 31d32f35..52b8cc8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,6 +231,8 @@ add_library(NintendoSDK OBJECT include/nn/friends.h include/nn/mem.h + include/nn/audio/audio_Adpcm.h + include/nn/atk/atk_Adpcm.h include/nn/atk/atk_AudioRendererPerformanceReader.h include/nn/atk/atk_BiquadFilterCallback.h diff --git a/include/nn/atk/atk_Adpcm.h b/include/nn/atk/atk_Adpcm.h index 77ea43a4..09704a19 100644 --- a/include/nn/atk/atk_Adpcm.h +++ b/include/nn/atk/atk_Adpcm.h @@ -1,6 +1,17 @@ #pragma once +#include + namespace nn::atk { -struct AdpcmContext; +using AdpcmParam = audio::AdpcmParameter; + +struct alignas(64) AdpcmContext { + audio::AdpcmContext audioAdpcmContext; +}; +static_assert(sizeof(AdpcmContext) == 0x40); -}; \ No newline at end of file +struct AdpcmContextNotAligned { + audio::AdpcmContext audioAdpcmContext; +}; +static_assert(sizeof(AdpcmContextNotAligned) == 0x6); +} // namespace nn::atk \ No newline at end of file diff --git a/include/nn/audio/audio_Adpcm.h b/include/nn/audio/audio_Adpcm.h new file mode 100644 index 00000000..123e8abc --- /dev/null +++ b/include/nn/audio/audio_Adpcm.h @@ -0,0 +1,16 @@ +#pragma once + +#include + +namespace nn::audio { +struct AdpcmContext { + u16 predScale; + s16 history[2]; +}; +static_assert(sizeof(AdpcmContext) == 0x6); + +struct AdpcmParameter { + u16 coefficients[16]; +}; +static_assert(sizeof(AdpcmParameter) == 0x20); +} // namespace nn::audio \ No newline at end of file From 6eb5622b000c85bb53f4498e17e4b57e90d52fae Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 21 Feb 2026 23:22:22 -0300 Subject: [PATCH 025/785] atk: Define `ChannelMixVolume` --- include/nn/atk/atk_BiquadFilterCallback.h | 2 +- include/nn/atk/atk_ChannelMixVolume.h | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_BiquadFilterCallback.h b/include/nn/atk/atk_BiquadFilterCallback.h index 9deb2c62..76f30e8a 100644 --- a/include/nn/atk/atk_BiquadFilterCallback.h +++ b/include/nn/atk/atk_BiquadFilterCallback.h @@ -7,7 +7,7 @@ namespace nn::atk { class BiquadFilterCallback { public: - typedef BiquadFilterCoefficients Coefficients; + using Coefficients = BiquadFilterCoefficients; virtual ~BiquadFilterCallback(); }; diff --git a/include/nn/atk/atk_ChannelMixVolume.h b/include/nn/atk/atk_ChannelMixVolume.h index e69de29b..941d5a2e 100644 --- a/include/nn/atk/atk_ChannelMixVolume.h +++ b/include/nn/atk/atk_ChannelMixVolume.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace nn::atk { +class ChannelMixVolume { +public: +private: + s32 m_ChannelCount; + f32 m_ChannelVolume[24]; +}; +} // namespace nn::atk \ No newline at end of file From e5a41f2256ba6d88cce9cafe2acb4846d3b31546 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 22 Feb 2026 00:28:21 -0300 Subject: [PATCH 026/785] atk: File restructure to match path strings in BTD5 --- CMakeLists.txt | 158 ++++++++++-------- include/nn/atk/atk_SoundArchive.h | 4 +- include/nn/atk/atk_SoundArchivePlayer.h | 8 +- include/nn/atk/atk_SoundSystem.h | 2 +- .../atk_AdvancedWaveSoundPlayer.h | 0 .../{driver => }/atk_BasicSoundPlayer.h | 0 include/nn/atk/detail/atk_Config.h | 2 +- .../detail/{driver => }/atk_DisposeCallback.h | 0 .../{driver => }/atk_DisposeCallbackManager.h | 0 include/nn/atk/detail/atk_GroupFile.h | 2 +- .../detail/{driver => }/atk_NoteOnCallback.h | 0 include/nn/atk/detail/atk_SoundArchiveFile.h | 2 +- include/nn/atk/detail/atk_WaveArchiveFile.h | 2 +- include/nn/atk/detail/atk_WaveFile.h | 2 +- include/nn/atk/detail/{ => debug}/atk_Debug.h | 0 .../{ => dsp}/atk_BiquadFilterPresets.h | 0 .../atk/detail/{ => dsp}/atk_DspadpcmReader.h | 0 .../{driver => dsp}/atk_HardwareManager.h | 0 .../nn/atk/detail/{driver => seq}/atk_Bank.h | 0 .../nn/atk/detail/{ => seq}/atk_BankFile.h | 3 +- .../atk/detail/{ => seq}/atk_BankFileReader.h | 0 .../detail/{driver => seq}/atk_MmlCommand.h | 0 .../detail/{driver => seq}/atk_MmlParser.h | 0 .../{driver => seq}/atk_MmlSequenceTrack.h | 0 .../atk_MmlSequenceTrackAllocator.h | 0 .../atk/detail/{ => seq}/atk_SequenceSound.h | 0 .../detail/{ => seq}/atk_SequenceSoundFile.h | 2 +- .../{ => seq}/atk_SequenceSoundFileReader.h | 0 .../{driver => seq}/atk_SequenceSoundPlayer.h | 0 .../{ => seq}/atk_SequenceSoundRuntime.h | 0 .../{driver => seq}/atk_SequenceTrack.h | 0 .../atk_SequenceTrackAllocator.h | 0 .../{driver => strm}/atk_StreamBufferPool.h | 0 .../atk/detail/{ => strm}/atk_StreamSound.h | 0 .../detail/{ => strm}/atk_StreamSoundFile.h | 4 +- .../{ => strm}/atk_StreamSoundFileLoader.h | 0 .../{ => strm}/atk_StreamSoundFileReader.h | 0 .../{driver => strm}/atk_StreamSoundLoader.h | 0 .../{driver => strm}/atk_StreamSoundPlayer.h | 0 .../{ => strm}/atk_StreamSoundPrefetchFile.h | 5 +- .../atk_StreamSoundPrefetchFileReader.h | 0 .../{ => strm}/atk_StreamSoundRuntime.h | 0 .../detail/{driver => strm}/atk_StreamTrack.h | 0 .../nn/atk/detail/{ => thread}/atk_Command.h | 0 .../detail/{ => thread}/atk_CommandManager.h | 0 .../detail/{ => thread}/atk_DriverCommand.h | 0 .../{driver => thread}/atk_SoundThread.h | 0 include/nn/atk/detail/{ => thread}/atk_Task.h | 0 .../atk/detail/{ => thread}/atk_TaskManager.h | 0 .../atk/detail/{ => thread}/atk_TaskThread.h | 0 .../{ => thread}/atk_ThreadInfoReader.h | 0 .../nn/atk/detail/{ => util}/atk_CurveAdshr.h | 0 .../nn/atk/detail/{ => util}/atk_CurveLfo.h | 0 .../nn/atk/detail/{ => util}/atk_FrameHeap.h | 0 .../atk/detail/{ => util}/atk_InstancePool.h | 0 .../detail/{ => util}/atk_MemoryFileStream.h | 0 include/nn/atk/detail/{ => util}/atk_Util.h | 0 .../detail/{driver => voice}/atk_Channel.h | 0 .../{driver => voice}/atk_ChannelManager.h | 0 .../detail/{ => voice}/atk_LowLevelVoice.h | 0 .../detail/{driver => voice}/atk_MultiVoice.h | 0 .../{driver => voice}/atk_MultiVoiceManager.h | 0 include/nn/atk/detail/{ => voice}/atk_Voice.h | 0 .../atk/detail/{ => voice}/atk_VoiceCommand.h | 0 .../nn/atk/detail/{ => wsd}/atk_WaveSound.h | 0 .../atk/detail/{ => wsd}/atk_WaveSoundFile.h | 2 +- .../{ => wsd}/atk_WaveSoundFileReader.h | 0 .../{driver => wsd}/atk_WaveSoundLoader.h | 0 .../{driver => wsd}/atk_WaveSoundPlayer.h | 0 .../detail/{ => wsd}/atk_WaveSoundRuntime.h | 0 include/nn/atk/{ => effect}/atk_EffectAux.h | 0 include/nn/atk/{ => effect}/atk_EffectBase.h | 0 .../{detail/fnd => fnd/basis}/atkfnd_Config.h | 0 .../basis}/atkfnd_CriticalSection.h | 0 .../fnd => fnd/basis}/atkfnd_FrameHeapImpl.h | 0 .../fnd => fnd/basis}/atkfnd_HeapBase.h | 0 .../fnd => fnd/basis}/atkfnd_PrimitiveTypes.h | 0 .../{detail/fnd => fnd/basis}/atkfnd_Result.h | 0 .../basis}/atkfnd_RuntimeTypeInfo.h | 0 .../fnd => fnd/basis}/atkfnd_ScopedLock.h | 0 .../{detail/fnd => fnd/basis}/atkfnd_Time.h | 0 .../basis}/atkfnd_WorkBufferAllocator.h | 0 .../fnd => fnd/io}/atkfnd_FileStream.h | 0 .../fnd => fnd/io}/atkfnd_FileStreamImpl.h | 0 .../fnd => fnd/io}/atkfnd_FileStreamProxy.h | 0 .../{detail/fnd => fnd/io}/atkfnd_Stream.h | 0 .../fnd => fnd/io}/atkfnd_StreamCache.h | 0 .../{detail/fnd => fnd/os}/atkfnd_Thread.h | 0 .../atk/{ => submix}/atk_ChannelMixVolume.h | 0 include/nn/atk/{ => submix}/atk_FinalMix.h | 0 include/nn/atk/{ => submix}/atk_OutputMixer.h | 0 include/nn/atk/{ => submix}/atk_SubMix.h | 0 .../atk_AudioRendererPerformanceReader.h | 0 .../nn/atk/{ => util}/atk_DeviceOutRecorder.h | 0 include/nn/atk/{ => util}/atk_ProfileReader.h | 0 .../nn/atk/{ => util}/atk_TaskProfileReader.h | 0 96 files changed, 105 insertions(+), 93 deletions(-) rename include/nn/atk/detail/{driver => }/atk_AdvancedWaveSoundPlayer.h (100%) rename include/nn/atk/detail/{driver => }/atk_BasicSoundPlayer.h (100%) rename include/nn/atk/detail/{driver => }/atk_DisposeCallback.h (100%) rename include/nn/atk/detail/{driver => }/atk_DisposeCallbackManager.h (100%) rename include/nn/atk/detail/{driver => }/atk_NoteOnCallback.h (100%) rename include/nn/atk/detail/{ => debug}/atk_Debug.h (100%) rename include/nn/atk/detail/{ => dsp}/atk_BiquadFilterPresets.h (100%) rename include/nn/atk/detail/{ => dsp}/atk_DspadpcmReader.h (100%) rename include/nn/atk/detail/{driver => dsp}/atk_HardwareManager.h (100%) rename include/nn/atk/detail/{driver => seq}/atk_Bank.h (100%) rename include/nn/atk/detail/{ => seq}/atk_BankFile.h (96%) rename include/nn/atk/detail/{ => seq}/atk_BankFileReader.h (100%) rename include/nn/atk/detail/{driver => seq}/atk_MmlCommand.h (100%) rename include/nn/atk/detail/{driver => seq}/atk_MmlParser.h (100%) rename include/nn/atk/detail/{driver => seq}/atk_MmlSequenceTrack.h (100%) rename include/nn/atk/detail/{driver => seq}/atk_MmlSequenceTrackAllocator.h (100%) rename include/nn/atk/detail/{ => seq}/atk_SequenceSound.h (100%) rename include/nn/atk/detail/{ => seq}/atk_SequenceSoundFile.h (96%) rename include/nn/atk/detail/{ => seq}/atk_SequenceSoundFileReader.h (100%) rename include/nn/atk/detail/{driver => seq}/atk_SequenceSoundPlayer.h (100%) rename include/nn/atk/detail/{ => seq}/atk_SequenceSoundRuntime.h (100%) rename include/nn/atk/detail/{driver => seq}/atk_SequenceTrack.h (100%) rename include/nn/atk/detail/{driver => seq}/atk_SequenceTrackAllocator.h (100%) rename include/nn/atk/detail/{driver => strm}/atk_StreamBufferPool.h (100%) rename include/nn/atk/detail/{ => strm}/atk_StreamSound.h (100%) rename include/nn/atk/detail/{ => strm}/atk_StreamSoundFile.h (96%) rename include/nn/atk/detail/{ => strm}/atk_StreamSoundFileLoader.h (100%) rename include/nn/atk/detail/{ => strm}/atk_StreamSoundFileReader.h (100%) rename include/nn/atk/detail/{driver => strm}/atk_StreamSoundLoader.h (100%) rename include/nn/atk/detail/{driver => strm}/atk_StreamSoundPlayer.h (100%) rename include/nn/atk/detail/{ => strm}/atk_StreamSoundPrefetchFile.h (89%) rename include/nn/atk/detail/{ => strm}/atk_StreamSoundPrefetchFileReader.h (100%) rename include/nn/atk/detail/{ => strm}/atk_StreamSoundRuntime.h (100%) rename include/nn/atk/detail/{driver => strm}/atk_StreamTrack.h (100%) rename include/nn/atk/detail/{ => thread}/atk_Command.h (100%) rename include/nn/atk/detail/{ => thread}/atk_CommandManager.h (100%) rename include/nn/atk/detail/{ => thread}/atk_DriverCommand.h (100%) rename include/nn/atk/detail/{driver => thread}/atk_SoundThread.h (100%) rename include/nn/atk/detail/{ => thread}/atk_Task.h (100%) rename include/nn/atk/detail/{ => thread}/atk_TaskManager.h (100%) rename include/nn/atk/detail/{ => thread}/atk_TaskThread.h (100%) rename include/nn/atk/detail/{ => thread}/atk_ThreadInfoReader.h (100%) rename include/nn/atk/detail/{ => util}/atk_CurveAdshr.h (100%) rename include/nn/atk/detail/{ => util}/atk_CurveLfo.h (100%) rename include/nn/atk/detail/{ => util}/atk_FrameHeap.h (100%) rename include/nn/atk/detail/{ => util}/atk_InstancePool.h (100%) rename include/nn/atk/detail/{ => util}/atk_MemoryFileStream.h (100%) rename include/nn/atk/detail/{ => util}/atk_Util.h (100%) rename include/nn/atk/detail/{driver => voice}/atk_Channel.h (100%) rename include/nn/atk/detail/{driver => voice}/atk_ChannelManager.h (100%) rename include/nn/atk/detail/{ => voice}/atk_LowLevelVoice.h (100%) rename include/nn/atk/detail/{driver => voice}/atk_MultiVoice.h (100%) rename include/nn/atk/detail/{driver => voice}/atk_MultiVoiceManager.h (100%) rename include/nn/atk/detail/{ => voice}/atk_Voice.h (100%) rename include/nn/atk/detail/{ => voice}/atk_VoiceCommand.h (100%) rename include/nn/atk/detail/{ => wsd}/atk_WaveSound.h (100%) rename include/nn/atk/detail/{ => wsd}/atk_WaveSoundFile.h (97%) rename include/nn/atk/detail/{ => wsd}/atk_WaveSoundFileReader.h (100%) rename include/nn/atk/detail/{driver => wsd}/atk_WaveSoundLoader.h (100%) rename include/nn/atk/detail/{driver => wsd}/atk_WaveSoundPlayer.h (100%) rename include/nn/atk/detail/{ => wsd}/atk_WaveSoundRuntime.h (100%) rename include/nn/atk/{ => effect}/atk_EffectAux.h (100%) rename include/nn/atk/{ => effect}/atk_EffectBase.h (100%) rename include/nn/atk/{detail/fnd => fnd/basis}/atkfnd_Config.h (100%) rename include/nn/atk/{detail/fnd => fnd/basis}/atkfnd_CriticalSection.h (100%) rename include/nn/atk/{detail/fnd => fnd/basis}/atkfnd_FrameHeapImpl.h (100%) rename include/nn/atk/{detail/fnd => fnd/basis}/atkfnd_HeapBase.h (100%) rename include/nn/atk/{detail/fnd => fnd/basis}/atkfnd_PrimitiveTypes.h (100%) rename include/nn/atk/{detail/fnd => fnd/basis}/atkfnd_Result.h (100%) rename include/nn/atk/{detail/fnd => fnd/basis}/atkfnd_RuntimeTypeInfo.h (100%) rename include/nn/atk/{detail/fnd => fnd/basis}/atkfnd_ScopedLock.h (100%) rename include/nn/atk/{detail/fnd => fnd/basis}/atkfnd_Time.h (100%) rename include/nn/atk/{detail/fnd => fnd/basis}/atkfnd_WorkBufferAllocator.h (100%) rename include/nn/atk/{detail/fnd => fnd/io}/atkfnd_FileStream.h (100%) rename include/nn/atk/{detail/fnd => fnd/io}/atkfnd_FileStreamImpl.h (100%) rename include/nn/atk/{detail/fnd => fnd/io}/atkfnd_FileStreamProxy.h (100%) rename include/nn/atk/{detail/fnd => fnd/io}/atkfnd_Stream.h (100%) rename include/nn/atk/{detail/fnd => fnd/io}/atkfnd_StreamCache.h (100%) rename include/nn/atk/{detail/fnd => fnd/os}/atkfnd_Thread.h (100%) rename include/nn/atk/{ => submix}/atk_ChannelMixVolume.h (100%) rename include/nn/atk/{ => submix}/atk_FinalMix.h (100%) rename include/nn/atk/{ => submix}/atk_OutputMixer.h (100%) rename include/nn/atk/{ => submix}/atk_SubMix.h (100%) rename include/nn/atk/{ => util}/atk_AudioRendererPerformanceReader.h (100%) rename include/nn/atk/{ => util}/atk_DeviceOutRecorder.h (100%) rename include/nn/atk/{ => util}/atk_ProfileReader.h (100%) rename include/nn/atk/{ => util}/atk_TaskProfileReader.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52b8cc8f..446b89c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -234,18 +234,10 @@ add_library(NintendoSDK OBJECT include/nn/audio/audio_Adpcm.h include/nn/atk/atk_Adpcm.h - include/nn/atk/atk_AudioRendererPerformanceReader.h include/nn/atk/atk_BiquadFilterCallback.h - include/nn/atk/atk_ChannelMixVolume.h - include/nn/atk/atk_DeviceOutRecorder.h - include/nn/atk/atk_EffectAux.h - include/nn/atk/atk_EffectBase.h - include/nn/atk/atk_FinalMix.h include/nn/atk/atk_FsSoundArchive.h include/nn/atk/atk_Global.h - include/nn/atk/atk_OutputMixer.h include/nn/atk/atk_OutputReceiver.h - include/nn/atk/atk_ProfileReader.h include/nn/atk/atk_SequenceSoundHandle.h include/nn/atk/atk_SoundActor.h include/nn/atk/atk_SoundArchive.h @@ -258,50 +250,35 @@ add_library(NintendoSDK OBJECT include/nn/atk/atk_SoundStartable.h include/nn/atk/atk_SoundSystem.h include/nn/atk/atk_StreamSoundHandle.h - include/nn/atk/atk_SubMix.h - include/nn/atk/atk_TaskProfileReader.h include/nn/atk/detail/atk_AddonSoundArchiveContainer.h include/nn/atk/detail/atk_AdvancedWaveSound.h include/nn/atk/detail/atk_AdvancedWaveSoundFile.h include/nn/atk/detail/atk_AdvancedWaveSoundFileReader.h + include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h - include/nn/atk/detail/atk_BankFile.h - include/nn/atk/detail/atk_BankFileReader.h include/nn/atk/detail/atk_BasicSound.h + include/nn/atk/detail/atk_BasicSoundPlayer.h include/nn/atk/detail/atk_BinaryFileFormat.h include/nn/atk/detail/atk_BinaryTypes.h - include/nn/atk/detail/atk_BiquadFilterPresets.h include/nn/atk/detail/atk_BusMixVolumePacket.h - include/nn/atk/detail/atk_Command.h - include/nn/atk/detail/atk_CommandManager.h include/nn/atk/detail/atk_Config.h - include/nn/atk/detail/atk_CurveAdshr.h - include/nn/atk/detail/atk_CurveLfo.h - include/nn/atk/detail/atk_Debug.h - include/nn/atk/detail/atk_DriverCommand.h - include/nn/atk/detail/atk_DspadpcmReader.h + include/nn/atk/detail/atk_DisposeCallback.h + include/nn/atk/detail/atk_DisposeCallbackManager.h include/nn/atk/detail/atk_ElementType.h include/nn/atk/detail/atk_ExternalSoundPlayer.h - include/nn/atk/detail/atk_FrameHeap.h include/nn/atk/detail/atk_GroupFile.h include/nn/atk/detail/atk_GroupFileReader.h - include/nn/atk/detail/atk_InstancePool.h include/nn/atk/detail/atk_IntrusiveList.h include/nn/atk/detail/atk_IRegionInfoReadable.h include/nn/atk/detail/atk_IStreamDataDecoder.h include/nn/atk/detail/atk_ItemType.h include/nn/atk/detail/atk_LoaderManager.h - include/nn/atk/detail/atk_LowLevelVoice.h - include/nn/atk/detail/atk_MemoryFileStream.h include/nn/atk/detail/atk_MoveValue.h + include/nn/atk/detail/atk_NoteOnCallback.h include/nn/atk/detail/atk_OutputAdditionalParam.h include/nn/atk/detail/atk_PlayerHeap.h include/nn/atk/detail/atk_PlayerHeapDataManager.h include/nn/atk/detail/atk_RegionManager.h - include/nn/atk/detail/atk_SequenceSound.h - include/nn/atk/detail/atk_SequenceSoundFile.h - include/nn/atk/detail/atk_SequenceSoundFileReader.h - include/nn/atk/detail/atk_SequenceSoundRuntime.h include/nn/atk/detail/atk_SoundArchiveFile.h include/nn/atk/detail/atk_SoundArchiveFileReader.h include/nn/atk/detail/atk_SoundArchiveLoader.h @@ -309,56 +286,95 @@ add_library(NintendoSDK OBJECT include/nn/atk/detail/atk_SoundInstanceManager.h include/nn/atk/detail/atk_SoundRuntimeUtility.h include/nn/atk/detail/atk_StartInfoReader.h - include/nn/atk/detail/atk_StreamSound.h - include/nn/atk/detail/atk_StreamSoundFile.h - include/nn/atk/detail/atk_StreamSoundFileLoader.h - include/nn/atk/detail/atk_StreamSoundFileReader.h - include/nn/atk/detail/atk_StreamSoundPrefetchFile.h - include/nn/atk/detail/atk_StreamSoundPrefetchFileReader.h - include/nn/atk/detail/atk_StreamSoundRuntime.h - include/nn/atk/detail/atk_Task.h - include/nn/atk/detail/atk_TaskManager.h - include/nn/atk/detail/atk_TaskThread.h - include/nn/atk/detail/atk_ThreadInfoReader.h - include/nn/atk/detail/atk_Util.h include/nn/atk/detail/atk_ValueArray.h - include/nn/atk/detail/atk_Voice.h - include/nn/atk/detail/atk_VoiceCommand.h include/nn/atk/detail/atk_VolumeThroughModePacket.h include/nn/atk/detail/atk_WavBinary.h include/nn/atk/detail/atk_WaveArchiveFile.h include/nn/atk/detail/atk_WaveArchiveFileReader.h include/nn/atk/detail/atk_WaveFile.h - include/nn/atk/detail/atk_WaveSound.h - include/nn/atk/detail/atk_WaveSoundFile.h - include/nn/atk/detail/atk_WaveSoundFileReader.h - include/nn/atk/detail/atk_WaveSoundRuntime.h include/nn/atk/detail/atk_WavOutFileStream.h - include/nn/atk/detail/driver/atk_AdvancedWaveSoundPlayer.h - include/nn/atk/detail/driver/atk_Bank.h - include/nn/atk/detail/driver/atk_BasicSoundPlayer.h - include/nn/atk/detail/driver/atk_Channel.h - include/nn/atk/detail/driver/atk_ChannelManager.h - include/nn/atk/detail/driver/atk_DisposeCallback.h - include/nn/atk/detail/driver/atk_DisposeCallbackManager.h - include/nn/atk/detail/driver/atk_HardwareManager.h - include/nn/atk/detail/driver/atk_MmlCommand.h - include/nn/atk/detail/driver/atk_MmlParser.h - include/nn/atk/detail/driver/atk_MmlSequenceTrack.h - include/nn/atk/detail/driver/atk_MmlSequenceTrackAllocator.h - include/nn/atk/detail/driver/atk_MultiVoice.h - include/nn/atk/detail/driver/atk_MultiVoiceManager.h - include/nn/atk/detail/driver/atk_NoteOnCallback.h - include/nn/atk/detail/driver/atk_SequenceSoundPlayer.h - include/nn/atk/detail/driver/atk_SequenceTrack.h - include/nn/atk/detail/driver/atk_SequenceTrackAllocator.h - include/nn/atk/detail/driver/atk_SoundThread.h - include/nn/atk/detail/driver/atk_StreamBufferPool.h - include/nn/atk/detail/driver/atk_StreamSoundLoader.h - include/nn/atk/detail/driver/atk_StreamSoundPlayer.h - include/nn/atk/detail/driver/atk_StreamTrack.h - include/nn/atk/detail/driver/atk_WaveSoundLoader.h - include/nn/atk/detail/driver/atk_WaveSoundPlayer.h + include/nn/atk/detail/debug/atk_Debug.h + include/nn/atk/detail/dsp/atk_BiquadFilterPresets.h + include/nn/atk/detail/dsp/atk_DspadpcmReader.h + include/nn/atk/detail/dsp/atk_HardwareManager.h + include/nn/atk/detail/seq/atk_Bank.h + include/nn/atk/detail/seq/atk_BankFile.h + include/nn/atk/detail/seq/atk_BankFileReader.h + include/nn/atk/detail/seq/atk_MmlCommand.h + include/nn/atk/detail/seq/atk_MmlParser.h + include/nn/atk/detail/seq/atk_MmlSequenceTrack.h + include/nn/atk/detail/seq/atk_MmlSequenceTrackAllocator.h + include/nn/atk/detail/seq/atk_SequenceSound.h + include/nn/atk/detail/seq/atk_SequenceSoundFile.h + include/nn/atk/detail/seq/atk_SequenceSoundFileReader.h + include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h + include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h + include/nn/atk/detail/seq/atk_SequenceTrack.h + include/nn/atk/detail/seq/atk_SequenceTrackAllocator.h + include/nn/atk/detail/strm/atk_StreamBufferPool.h + include/nn/atk/detail/strm/atk_StreamSound.h + include/nn/atk/detail/strm/atk_StreamSoundFile.h + include/nn/atk/detail/strm/atk_StreamSoundFileLoader.h + include/nn/atk/detail/strm/atk_StreamSoundFileReader.h + include/nn/atk/detail/strm/atk_StreamSoundLoader.h + include/nn/atk/detail/strm/atk_StreamSoundPlayer.h + include/nn/atk/detail/strm/atk_StreamSoundPrefetchFile.h + include/nn/atk/detail/strm/atk_StreamSoundPrefetchFileReader.h + include/nn/atk/detail/strm/atk_StreamSoundRuntime.h + include/nn/atk/detail/strm/atk_StreamTrack.h + include/nn/atk/detail/thread/atk_Command.h + include/nn/atk/detail/thread/atk_CommandManager.h + include/nn/atk/detail/thread/atk_DriverCommand.h + include/nn/atk/detail/thread/atk_SoundThread.h + include/nn/atk/detail/thread/atk_Task.h + include/nn/atk/detail/thread/atk_TaskManager.h + include/nn/atk/detail/thread/atk_TaskThread.h + include/nn/atk/detail/thread/atk_ThreadInfoReader.h + include/nn/atk/detail/util/atk_CurveAdshr.h + include/nn/atk/detail/util/atk_CurveLfo.h + include/nn/atk/detail/util/atk_FrameHeap.h + include/nn/atk/detail/util/atk_InstancePool.h + include/nn/atk/detail/util/atk_MemoryFileStream.h + include/nn/atk/detail/util/atk_Util.h + include/nn/atk/detail/voice/atk_Channel.h + include/nn/atk/detail/voice/atk_ChannelManager.h + include/nn/atk/detail/voice/atk_LowLevelVoice.h + include/nn/atk/detail/voice/atk_MultiVoice.h + include/nn/atk/detail/voice/atk_MultiVoiceManager.h + include/nn/atk/detail/voice/atk_Voice.h + include/nn/atk/detail/voice/atk_VoiceCommand.h + include/nn/atk/detail/wsd/atk_WaveSound.h + include/nn/atk/detail/wsd/atk_WaveSoundFile.h + include/nn/atk/detail/wsd/atk_WaveSoundFileReader.h + include/nn/atk/detail/wsd/atk_WaveSoundLoader.h + include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h + include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h + include/nn/atk/effect/atk_EffectAux.h + include/nn/atk/effect/atk_EffectBase.h + include/nn/atk/submix/atk_ChannelMixVolume.h + include/nn/atk/submix/atk_FinalMix.h + include/nn/atk/submix/atk_OutputMixer.h + include/nn/atk/submix/atk_SubMix.h + include/nn/atk/util/atk_AudioRendererPerformanceReader.h + include/nn/atk/util/atk_DeviceOutRecorder.h + include/nn/atk/util/atk_ProfileReader.h + include/nn/atk/util/atk_TaskProfileReader.h + include/nn/atk/fnd/basis/atkfnd_Config.h + include/nn/atk/fnd/basis/atkfnd_CriticalSection.h + include/nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h + include/nn/atk/fnd/basis/atkfnd_HeapBase.h + include/nn/atk/fnd/basis/atkfnd_PrimitiveTypes.h + include/nn/atk/fnd/basis/atkfnd_Result.h + include/nn/atk/fnd/basis/atkfnd_RuntimeTypeInfo.h + include/nn/atk/fnd/basis/atkfnd_ScopedLock.h + include/nn/atk/fnd/basis/atkfnd_Time.h + include/nn/atk/fnd/basis/atkfnd_WorkBufferAllocator.h + include/nn/atk/fnd/io/atkfnd_FileStream.h + include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h + include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h + include/nn/atk/fnd/io/atkfnd_Stream.h + include/nn/atk/fnd/io/atkfnd_StreamCache.h + include/nn/atk/fnd/os/atkfnd_Thread.h include/nvn/nvn_Cpp.h include/nvn/nvn_CppFuncPtrBase.h diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index b8a148ce..d1c22dbc 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -2,8 +2,8 @@ #include #include -#include -#include +#include +#include namespace nn::atk { namespace detail{ diff --git a/include/nn/atk/atk_SoundArchivePlayer.h b/include/nn/atk/atk_SoundArchivePlayer.h index 616d3fed..a42848b3 100644 --- a/include/nn/atk/atk_SoundArchivePlayer.h +++ b/include/nn/atk/atk_SoundArchivePlayer.h @@ -5,11 +5,11 @@ #pragma once -#include -#include #include -#include -#include +#include +#include +#include +#include namespace nn { namespace atk { diff --git a/include/nn/atk/atk_SoundSystem.h b/include/nn/atk/atk_SoundSystem.h index 3329eb7b..a41fa5e2 100644 --- a/include/nn/atk/atk_SoundSystem.h +++ b/include/nn/atk/atk_SoundSystem.h @@ -4,8 +4,8 @@ #include #include -#include #include +#include namespace nn::audio { struct MemoryPoolType; diff --git a/include/nn/atk/detail/driver/atk_AdvancedWaveSoundPlayer.h b/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h similarity index 100% rename from include/nn/atk/detail/driver/atk_AdvancedWaveSoundPlayer.h rename to include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h diff --git a/include/nn/atk/detail/driver/atk_BasicSoundPlayer.h b/include/nn/atk/detail/atk_BasicSoundPlayer.h similarity index 100% rename from include/nn/atk/detail/driver/atk_BasicSoundPlayer.h rename to include/nn/atk/detail/atk_BasicSoundPlayer.h diff --git a/include/nn/atk/detail/atk_Config.h b/include/nn/atk/detail/atk_Config.h index cfd0e1f6..6c47205f 100644 --- a/include/nn/atk/detail/atk_Config.h +++ b/include/nn/atk/detail/atk_Config.h @@ -2,7 +2,7 @@ #include -#include +#include namespace nn::atk { using position_t = detail::fnd::position_t; diff --git a/include/nn/atk/detail/driver/atk_DisposeCallback.h b/include/nn/atk/detail/atk_DisposeCallback.h similarity index 100% rename from include/nn/atk/detail/driver/atk_DisposeCallback.h rename to include/nn/atk/detail/atk_DisposeCallback.h diff --git a/include/nn/atk/detail/driver/atk_DisposeCallbackManager.h b/include/nn/atk/detail/atk_DisposeCallbackManager.h similarity index 100% rename from include/nn/atk/detail/driver/atk_DisposeCallbackManager.h rename to include/nn/atk/detail/atk_DisposeCallbackManager.h diff --git a/include/nn/atk/detail/atk_GroupFile.h b/include/nn/atk/detail/atk_GroupFile.h index 62101203..24f01d17 100644 --- a/include/nn/atk/detail/atk_GroupFile.h +++ b/include/nn/atk/detail/atk_GroupFile.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { struct GroupFile { diff --git a/include/nn/atk/detail/driver/atk_NoteOnCallback.h b/include/nn/atk/detail/atk_NoteOnCallback.h similarity index 100% rename from include/nn/atk/detail/driver/atk_NoteOnCallback.h rename to include/nn/atk/detail/atk_NoteOnCallback.h diff --git a/include/nn/atk/detail/atk_SoundArchiveFile.h b/include/nn/atk/detail/atk_SoundArchiveFile.h index bd391fe8..cb170a30 100644 --- a/include/nn/atk/detail/atk_SoundArchiveFile.h +++ b/include/nn/atk/detail/atk_SoundArchiveFile.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { struct SoundArchiveParametersHook; diff --git a/include/nn/atk/detail/atk_WaveArchiveFile.h b/include/nn/atk/detail/atk_WaveArchiveFile.h index 929681b0..a865a0f8 100644 --- a/include/nn/atk/detail/atk_WaveArchiveFile.h +++ b/include/nn/atk/detail/atk_WaveArchiveFile.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { struct WaveArchiveFile { diff --git a/include/nn/atk/detail/atk_WaveFile.h b/include/nn/atk/detail/atk_WaveFile.h index 5337c822..ccf7e2fa 100644 --- a/include/nn/atk/detail/atk_WaveFile.h +++ b/include/nn/atk/detail/atk_WaveFile.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { struct WaveFile { diff --git a/include/nn/atk/detail/atk_Debug.h b/include/nn/atk/detail/debug/atk_Debug.h similarity index 100% rename from include/nn/atk/detail/atk_Debug.h rename to include/nn/atk/detail/debug/atk_Debug.h diff --git a/include/nn/atk/detail/atk_BiquadFilterPresets.h b/include/nn/atk/detail/dsp/atk_BiquadFilterPresets.h similarity index 100% rename from include/nn/atk/detail/atk_BiquadFilterPresets.h rename to include/nn/atk/detail/dsp/atk_BiquadFilterPresets.h diff --git a/include/nn/atk/detail/atk_DspadpcmReader.h b/include/nn/atk/detail/dsp/atk_DspadpcmReader.h similarity index 100% rename from include/nn/atk/detail/atk_DspadpcmReader.h rename to include/nn/atk/detail/dsp/atk_DspadpcmReader.h diff --git a/include/nn/atk/detail/driver/atk_HardwareManager.h b/include/nn/atk/detail/dsp/atk_HardwareManager.h similarity index 100% rename from include/nn/atk/detail/driver/atk_HardwareManager.h rename to include/nn/atk/detail/dsp/atk_HardwareManager.h diff --git a/include/nn/atk/detail/driver/atk_Bank.h b/include/nn/atk/detail/seq/atk_Bank.h similarity index 100% rename from include/nn/atk/detail/driver/atk_Bank.h rename to include/nn/atk/detail/seq/atk_Bank.h diff --git a/include/nn/atk/detail/atk_BankFile.h b/include/nn/atk/detail/seq/atk_BankFile.h similarity index 96% rename from include/nn/atk/detail/atk_BankFile.h rename to include/nn/atk/detail/seq/atk_BankFile.h index 53c24fa3..d91fcb38 100644 --- a/include/nn/atk/detail/atk_BankFile.h +++ b/include/nn/atk/detail/seq/atk_BankFile.h @@ -1,7 +1,6 @@ #pragma once -#include -#include "nn/atk/atk_Global.h" +#include namespace nn::atk::detail { struct BankFile { diff --git a/include/nn/atk/detail/atk_BankFileReader.h b/include/nn/atk/detail/seq/atk_BankFileReader.h similarity index 100% rename from include/nn/atk/detail/atk_BankFileReader.h rename to include/nn/atk/detail/seq/atk_BankFileReader.h diff --git a/include/nn/atk/detail/driver/atk_MmlCommand.h b/include/nn/atk/detail/seq/atk_MmlCommand.h similarity index 100% rename from include/nn/atk/detail/driver/atk_MmlCommand.h rename to include/nn/atk/detail/seq/atk_MmlCommand.h diff --git a/include/nn/atk/detail/driver/atk_MmlParser.h b/include/nn/atk/detail/seq/atk_MmlParser.h similarity index 100% rename from include/nn/atk/detail/driver/atk_MmlParser.h rename to include/nn/atk/detail/seq/atk_MmlParser.h diff --git a/include/nn/atk/detail/driver/atk_MmlSequenceTrack.h b/include/nn/atk/detail/seq/atk_MmlSequenceTrack.h similarity index 100% rename from include/nn/atk/detail/driver/atk_MmlSequenceTrack.h rename to include/nn/atk/detail/seq/atk_MmlSequenceTrack.h diff --git a/include/nn/atk/detail/driver/atk_MmlSequenceTrackAllocator.h b/include/nn/atk/detail/seq/atk_MmlSequenceTrackAllocator.h similarity index 100% rename from include/nn/atk/detail/driver/atk_MmlSequenceTrackAllocator.h rename to include/nn/atk/detail/seq/atk_MmlSequenceTrackAllocator.h diff --git a/include/nn/atk/detail/atk_SequenceSound.h b/include/nn/atk/detail/seq/atk_SequenceSound.h similarity index 100% rename from include/nn/atk/detail/atk_SequenceSound.h rename to include/nn/atk/detail/seq/atk_SequenceSound.h diff --git a/include/nn/atk/detail/atk_SequenceSoundFile.h b/include/nn/atk/detail/seq/atk_SequenceSoundFile.h similarity index 96% rename from include/nn/atk/detail/atk_SequenceSoundFile.h rename to include/nn/atk/detail/seq/atk_SequenceSoundFile.h index 3e20155c..d001cb44 100644 --- a/include/nn/atk/detail/atk_SequenceSoundFile.h +++ b/include/nn/atk/detail/seq/atk_SequenceSoundFile.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { struct SequenceSoundFile { diff --git a/include/nn/atk/detail/atk_SequenceSoundFileReader.h b/include/nn/atk/detail/seq/atk_SequenceSoundFileReader.h similarity index 100% rename from include/nn/atk/detail/atk_SequenceSoundFileReader.h rename to include/nn/atk/detail/seq/atk_SequenceSoundFileReader.h diff --git a/include/nn/atk/detail/driver/atk_SequenceSoundPlayer.h b/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h similarity index 100% rename from include/nn/atk/detail/driver/atk_SequenceSoundPlayer.h rename to include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h diff --git a/include/nn/atk/detail/atk_SequenceSoundRuntime.h b/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h similarity index 100% rename from include/nn/atk/detail/atk_SequenceSoundRuntime.h rename to include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h diff --git a/include/nn/atk/detail/driver/atk_SequenceTrack.h b/include/nn/atk/detail/seq/atk_SequenceTrack.h similarity index 100% rename from include/nn/atk/detail/driver/atk_SequenceTrack.h rename to include/nn/atk/detail/seq/atk_SequenceTrack.h diff --git a/include/nn/atk/detail/driver/atk_SequenceTrackAllocator.h b/include/nn/atk/detail/seq/atk_SequenceTrackAllocator.h similarity index 100% rename from include/nn/atk/detail/driver/atk_SequenceTrackAllocator.h rename to include/nn/atk/detail/seq/atk_SequenceTrackAllocator.h diff --git a/include/nn/atk/detail/driver/atk_StreamBufferPool.h b/include/nn/atk/detail/strm/atk_StreamBufferPool.h similarity index 100% rename from include/nn/atk/detail/driver/atk_StreamBufferPool.h rename to include/nn/atk/detail/strm/atk_StreamBufferPool.h diff --git a/include/nn/atk/detail/atk_StreamSound.h b/include/nn/atk/detail/strm/atk_StreamSound.h similarity index 100% rename from include/nn/atk/detail/atk_StreamSound.h rename to include/nn/atk/detail/strm/atk_StreamSound.h diff --git a/include/nn/atk/detail/atk_StreamSoundFile.h b/include/nn/atk/detail/strm/atk_StreamSoundFile.h similarity index 96% rename from include/nn/atk/detail/atk_StreamSoundFile.h rename to include/nn/atk/detail/strm/atk_StreamSoundFile.h index d84e0b44..dfebc389 100644 --- a/include/nn/atk/detail/atk_StreamSoundFile.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundFile.h @@ -1,8 +1,6 @@ #pragma once -#include -#include -#include +#include namespace nn::atk::detail { class StreamSoundFile { diff --git a/include/nn/atk/detail/atk_StreamSoundFileLoader.h b/include/nn/atk/detail/strm/atk_StreamSoundFileLoader.h similarity index 100% rename from include/nn/atk/detail/atk_StreamSoundFileLoader.h rename to include/nn/atk/detail/strm/atk_StreamSoundFileLoader.h diff --git a/include/nn/atk/detail/atk_StreamSoundFileReader.h b/include/nn/atk/detail/strm/atk_StreamSoundFileReader.h similarity index 100% rename from include/nn/atk/detail/atk_StreamSoundFileReader.h rename to include/nn/atk/detail/strm/atk_StreamSoundFileReader.h diff --git a/include/nn/atk/detail/driver/atk_StreamSoundLoader.h b/include/nn/atk/detail/strm/atk_StreamSoundLoader.h similarity index 100% rename from include/nn/atk/detail/driver/atk_StreamSoundLoader.h rename to include/nn/atk/detail/strm/atk_StreamSoundLoader.h diff --git a/include/nn/atk/detail/driver/atk_StreamSoundPlayer.h b/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h similarity index 100% rename from include/nn/atk/detail/driver/atk_StreamSoundPlayer.h rename to include/nn/atk/detail/strm/atk_StreamSoundPlayer.h diff --git a/include/nn/atk/detail/atk_StreamSoundPrefetchFile.h b/include/nn/atk/detail/strm/atk_StreamSoundPrefetchFile.h similarity index 89% rename from include/nn/atk/detail/atk_StreamSoundPrefetchFile.h rename to include/nn/atk/detail/strm/atk_StreamSoundPrefetchFile.h index 5ee2cf19..c215febd 100644 --- a/include/nn/atk/detail/atk_StreamSoundPrefetchFile.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundPrefetchFile.h @@ -1,8 +1,7 @@ #pragma once -#include -#include -#include +#include +#include namespace nn::atk::detail { class StreamSoundPrefetchFile { diff --git a/include/nn/atk/detail/atk_StreamSoundPrefetchFileReader.h b/include/nn/atk/detail/strm/atk_StreamSoundPrefetchFileReader.h similarity index 100% rename from include/nn/atk/detail/atk_StreamSoundPrefetchFileReader.h rename to include/nn/atk/detail/strm/atk_StreamSoundPrefetchFileReader.h diff --git a/include/nn/atk/detail/atk_StreamSoundRuntime.h b/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h similarity index 100% rename from include/nn/atk/detail/atk_StreamSoundRuntime.h rename to include/nn/atk/detail/strm/atk_StreamSoundRuntime.h diff --git a/include/nn/atk/detail/driver/atk_StreamTrack.h b/include/nn/atk/detail/strm/atk_StreamTrack.h similarity index 100% rename from include/nn/atk/detail/driver/atk_StreamTrack.h rename to include/nn/atk/detail/strm/atk_StreamTrack.h diff --git a/include/nn/atk/detail/atk_Command.h b/include/nn/atk/detail/thread/atk_Command.h similarity index 100% rename from include/nn/atk/detail/atk_Command.h rename to include/nn/atk/detail/thread/atk_Command.h diff --git a/include/nn/atk/detail/atk_CommandManager.h b/include/nn/atk/detail/thread/atk_CommandManager.h similarity index 100% rename from include/nn/atk/detail/atk_CommandManager.h rename to include/nn/atk/detail/thread/atk_CommandManager.h diff --git a/include/nn/atk/detail/atk_DriverCommand.h b/include/nn/atk/detail/thread/atk_DriverCommand.h similarity index 100% rename from include/nn/atk/detail/atk_DriverCommand.h rename to include/nn/atk/detail/thread/atk_DriverCommand.h diff --git a/include/nn/atk/detail/driver/atk_SoundThread.h b/include/nn/atk/detail/thread/atk_SoundThread.h similarity index 100% rename from include/nn/atk/detail/driver/atk_SoundThread.h rename to include/nn/atk/detail/thread/atk_SoundThread.h diff --git a/include/nn/atk/detail/atk_Task.h b/include/nn/atk/detail/thread/atk_Task.h similarity index 100% rename from include/nn/atk/detail/atk_Task.h rename to include/nn/atk/detail/thread/atk_Task.h diff --git a/include/nn/atk/detail/atk_TaskManager.h b/include/nn/atk/detail/thread/atk_TaskManager.h similarity index 100% rename from include/nn/atk/detail/atk_TaskManager.h rename to include/nn/atk/detail/thread/atk_TaskManager.h diff --git a/include/nn/atk/detail/atk_TaskThread.h b/include/nn/atk/detail/thread/atk_TaskThread.h similarity index 100% rename from include/nn/atk/detail/atk_TaskThread.h rename to include/nn/atk/detail/thread/atk_TaskThread.h diff --git a/include/nn/atk/detail/atk_ThreadInfoReader.h b/include/nn/atk/detail/thread/atk_ThreadInfoReader.h similarity index 100% rename from include/nn/atk/detail/atk_ThreadInfoReader.h rename to include/nn/atk/detail/thread/atk_ThreadInfoReader.h diff --git a/include/nn/atk/detail/atk_CurveAdshr.h b/include/nn/atk/detail/util/atk_CurveAdshr.h similarity index 100% rename from include/nn/atk/detail/atk_CurveAdshr.h rename to include/nn/atk/detail/util/atk_CurveAdshr.h diff --git a/include/nn/atk/detail/atk_CurveLfo.h b/include/nn/atk/detail/util/atk_CurveLfo.h similarity index 100% rename from include/nn/atk/detail/atk_CurveLfo.h rename to include/nn/atk/detail/util/atk_CurveLfo.h diff --git a/include/nn/atk/detail/atk_FrameHeap.h b/include/nn/atk/detail/util/atk_FrameHeap.h similarity index 100% rename from include/nn/atk/detail/atk_FrameHeap.h rename to include/nn/atk/detail/util/atk_FrameHeap.h diff --git a/include/nn/atk/detail/atk_InstancePool.h b/include/nn/atk/detail/util/atk_InstancePool.h similarity index 100% rename from include/nn/atk/detail/atk_InstancePool.h rename to include/nn/atk/detail/util/atk_InstancePool.h diff --git a/include/nn/atk/detail/atk_MemoryFileStream.h b/include/nn/atk/detail/util/atk_MemoryFileStream.h similarity index 100% rename from include/nn/atk/detail/atk_MemoryFileStream.h rename to include/nn/atk/detail/util/atk_MemoryFileStream.h diff --git a/include/nn/atk/detail/atk_Util.h b/include/nn/atk/detail/util/atk_Util.h similarity index 100% rename from include/nn/atk/detail/atk_Util.h rename to include/nn/atk/detail/util/atk_Util.h diff --git a/include/nn/atk/detail/driver/atk_Channel.h b/include/nn/atk/detail/voice/atk_Channel.h similarity index 100% rename from include/nn/atk/detail/driver/atk_Channel.h rename to include/nn/atk/detail/voice/atk_Channel.h diff --git a/include/nn/atk/detail/driver/atk_ChannelManager.h b/include/nn/atk/detail/voice/atk_ChannelManager.h similarity index 100% rename from include/nn/atk/detail/driver/atk_ChannelManager.h rename to include/nn/atk/detail/voice/atk_ChannelManager.h diff --git a/include/nn/atk/detail/atk_LowLevelVoice.h b/include/nn/atk/detail/voice/atk_LowLevelVoice.h similarity index 100% rename from include/nn/atk/detail/atk_LowLevelVoice.h rename to include/nn/atk/detail/voice/atk_LowLevelVoice.h diff --git a/include/nn/atk/detail/driver/atk_MultiVoice.h b/include/nn/atk/detail/voice/atk_MultiVoice.h similarity index 100% rename from include/nn/atk/detail/driver/atk_MultiVoice.h rename to include/nn/atk/detail/voice/atk_MultiVoice.h diff --git a/include/nn/atk/detail/driver/atk_MultiVoiceManager.h b/include/nn/atk/detail/voice/atk_MultiVoiceManager.h similarity index 100% rename from include/nn/atk/detail/driver/atk_MultiVoiceManager.h rename to include/nn/atk/detail/voice/atk_MultiVoiceManager.h diff --git a/include/nn/atk/detail/atk_Voice.h b/include/nn/atk/detail/voice/atk_Voice.h similarity index 100% rename from include/nn/atk/detail/atk_Voice.h rename to include/nn/atk/detail/voice/atk_Voice.h diff --git a/include/nn/atk/detail/atk_VoiceCommand.h b/include/nn/atk/detail/voice/atk_VoiceCommand.h similarity index 100% rename from include/nn/atk/detail/atk_VoiceCommand.h rename to include/nn/atk/detail/voice/atk_VoiceCommand.h diff --git a/include/nn/atk/detail/atk_WaveSound.h b/include/nn/atk/detail/wsd/atk_WaveSound.h similarity index 100% rename from include/nn/atk/detail/atk_WaveSound.h rename to include/nn/atk/detail/wsd/atk_WaveSound.h diff --git a/include/nn/atk/detail/atk_WaveSoundFile.h b/include/nn/atk/detail/wsd/atk_WaveSoundFile.h similarity index 97% rename from include/nn/atk/detail/atk_WaveSoundFile.h rename to include/nn/atk/detail/wsd/atk_WaveSoundFile.h index 50b8334d..62dd56e1 100644 --- a/include/nn/atk/detail/atk_WaveSoundFile.h +++ b/include/nn/atk/detail/wsd/atk_WaveSoundFile.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { struct WaveSoundFile { diff --git a/include/nn/atk/detail/atk_WaveSoundFileReader.h b/include/nn/atk/detail/wsd/atk_WaveSoundFileReader.h similarity index 100% rename from include/nn/atk/detail/atk_WaveSoundFileReader.h rename to include/nn/atk/detail/wsd/atk_WaveSoundFileReader.h diff --git a/include/nn/atk/detail/driver/atk_WaveSoundLoader.h b/include/nn/atk/detail/wsd/atk_WaveSoundLoader.h similarity index 100% rename from include/nn/atk/detail/driver/atk_WaveSoundLoader.h rename to include/nn/atk/detail/wsd/atk_WaveSoundLoader.h diff --git a/include/nn/atk/detail/driver/atk_WaveSoundPlayer.h b/include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h similarity index 100% rename from include/nn/atk/detail/driver/atk_WaveSoundPlayer.h rename to include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h diff --git a/include/nn/atk/detail/atk_WaveSoundRuntime.h b/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h similarity index 100% rename from include/nn/atk/detail/atk_WaveSoundRuntime.h rename to include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h diff --git a/include/nn/atk/atk_EffectAux.h b/include/nn/atk/effect/atk_EffectAux.h similarity index 100% rename from include/nn/atk/atk_EffectAux.h rename to include/nn/atk/effect/atk_EffectAux.h diff --git a/include/nn/atk/atk_EffectBase.h b/include/nn/atk/effect/atk_EffectBase.h similarity index 100% rename from include/nn/atk/atk_EffectBase.h rename to include/nn/atk/effect/atk_EffectBase.h diff --git a/include/nn/atk/detail/fnd/atkfnd_Config.h b/include/nn/atk/fnd/basis/atkfnd_Config.h similarity index 100% rename from include/nn/atk/detail/fnd/atkfnd_Config.h rename to include/nn/atk/fnd/basis/atkfnd_Config.h diff --git a/include/nn/atk/detail/fnd/atkfnd_CriticalSection.h b/include/nn/atk/fnd/basis/atkfnd_CriticalSection.h similarity index 100% rename from include/nn/atk/detail/fnd/atkfnd_CriticalSection.h rename to include/nn/atk/fnd/basis/atkfnd_CriticalSection.h diff --git a/include/nn/atk/detail/fnd/atkfnd_FrameHeapImpl.h b/include/nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h similarity index 100% rename from include/nn/atk/detail/fnd/atkfnd_FrameHeapImpl.h rename to include/nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h diff --git a/include/nn/atk/detail/fnd/atkfnd_HeapBase.h b/include/nn/atk/fnd/basis/atkfnd_HeapBase.h similarity index 100% rename from include/nn/atk/detail/fnd/atkfnd_HeapBase.h rename to include/nn/atk/fnd/basis/atkfnd_HeapBase.h diff --git a/include/nn/atk/detail/fnd/atkfnd_PrimitiveTypes.h b/include/nn/atk/fnd/basis/atkfnd_PrimitiveTypes.h similarity index 100% rename from include/nn/atk/detail/fnd/atkfnd_PrimitiveTypes.h rename to include/nn/atk/fnd/basis/atkfnd_PrimitiveTypes.h diff --git a/include/nn/atk/detail/fnd/atkfnd_Result.h b/include/nn/atk/fnd/basis/atkfnd_Result.h similarity index 100% rename from include/nn/atk/detail/fnd/atkfnd_Result.h rename to include/nn/atk/fnd/basis/atkfnd_Result.h diff --git a/include/nn/atk/detail/fnd/atkfnd_RuntimeTypeInfo.h b/include/nn/atk/fnd/basis/atkfnd_RuntimeTypeInfo.h similarity index 100% rename from include/nn/atk/detail/fnd/atkfnd_RuntimeTypeInfo.h rename to include/nn/atk/fnd/basis/atkfnd_RuntimeTypeInfo.h diff --git a/include/nn/atk/detail/fnd/atkfnd_ScopedLock.h b/include/nn/atk/fnd/basis/atkfnd_ScopedLock.h similarity index 100% rename from include/nn/atk/detail/fnd/atkfnd_ScopedLock.h rename to include/nn/atk/fnd/basis/atkfnd_ScopedLock.h diff --git a/include/nn/atk/detail/fnd/atkfnd_Time.h b/include/nn/atk/fnd/basis/atkfnd_Time.h similarity index 100% rename from include/nn/atk/detail/fnd/atkfnd_Time.h rename to include/nn/atk/fnd/basis/atkfnd_Time.h diff --git a/include/nn/atk/detail/fnd/atkfnd_WorkBufferAllocator.h b/include/nn/atk/fnd/basis/atkfnd_WorkBufferAllocator.h similarity index 100% rename from include/nn/atk/detail/fnd/atkfnd_WorkBufferAllocator.h rename to include/nn/atk/fnd/basis/atkfnd_WorkBufferAllocator.h diff --git a/include/nn/atk/detail/fnd/atkfnd_FileStream.h b/include/nn/atk/fnd/io/atkfnd_FileStream.h similarity index 100% rename from include/nn/atk/detail/fnd/atkfnd_FileStream.h rename to include/nn/atk/fnd/io/atkfnd_FileStream.h diff --git a/include/nn/atk/detail/fnd/atkfnd_FileStreamImpl.h b/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h similarity index 100% rename from include/nn/atk/detail/fnd/atkfnd_FileStreamImpl.h rename to include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h diff --git a/include/nn/atk/detail/fnd/atkfnd_FileStreamProxy.h b/include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h similarity index 100% rename from include/nn/atk/detail/fnd/atkfnd_FileStreamProxy.h rename to include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h diff --git a/include/nn/atk/detail/fnd/atkfnd_Stream.h b/include/nn/atk/fnd/io/atkfnd_Stream.h similarity index 100% rename from include/nn/atk/detail/fnd/atkfnd_Stream.h rename to include/nn/atk/fnd/io/atkfnd_Stream.h diff --git a/include/nn/atk/detail/fnd/atkfnd_StreamCache.h b/include/nn/atk/fnd/io/atkfnd_StreamCache.h similarity index 100% rename from include/nn/atk/detail/fnd/atkfnd_StreamCache.h rename to include/nn/atk/fnd/io/atkfnd_StreamCache.h diff --git a/include/nn/atk/detail/fnd/atkfnd_Thread.h b/include/nn/atk/fnd/os/atkfnd_Thread.h similarity index 100% rename from include/nn/atk/detail/fnd/atkfnd_Thread.h rename to include/nn/atk/fnd/os/atkfnd_Thread.h diff --git a/include/nn/atk/atk_ChannelMixVolume.h b/include/nn/atk/submix/atk_ChannelMixVolume.h similarity index 100% rename from include/nn/atk/atk_ChannelMixVolume.h rename to include/nn/atk/submix/atk_ChannelMixVolume.h diff --git a/include/nn/atk/atk_FinalMix.h b/include/nn/atk/submix/atk_FinalMix.h similarity index 100% rename from include/nn/atk/atk_FinalMix.h rename to include/nn/atk/submix/atk_FinalMix.h diff --git a/include/nn/atk/atk_OutputMixer.h b/include/nn/atk/submix/atk_OutputMixer.h similarity index 100% rename from include/nn/atk/atk_OutputMixer.h rename to include/nn/atk/submix/atk_OutputMixer.h diff --git a/include/nn/atk/atk_SubMix.h b/include/nn/atk/submix/atk_SubMix.h similarity index 100% rename from include/nn/atk/atk_SubMix.h rename to include/nn/atk/submix/atk_SubMix.h diff --git a/include/nn/atk/atk_AudioRendererPerformanceReader.h b/include/nn/atk/util/atk_AudioRendererPerformanceReader.h similarity index 100% rename from include/nn/atk/atk_AudioRendererPerformanceReader.h rename to include/nn/atk/util/atk_AudioRendererPerformanceReader.h diff --git a/include/nn/atk/atk_DeviceOutRecorder.h b/include/nn/atk/util/atk_DeviceOutRecorder.h similarity index 100% rename from include/nn/atk/atk_DeviceOutRecorder.h rename to include/nn/atk/util/atk_DeviceOutRecorder.h diff --git a/include/nn/atk/atk_ProfileReader.h b/include/nn/atk/util/atk_ProfileReader.h similarity index 100% rename from include/nn/atk/atk_ProfileReader.h rename to include/nn/atk/util/atk_ProfileReader.h diff --git a/include/nn/atk/atk_TaskProfileReader.h b/include/nn/atk/util/atk_TaskProfileReader.h similarity index 100% rename from include/nn/atk/atk_TaskProfileReader.h rename to include/nn/atk/util/atk_TaskProfileReader.h From bbd50beaaa21e852857b9ac31609aef178e064a7 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 22 Feb 2026 11:07:13 -0300 Subject: [PATCH 027/785] atk: Define enums in `detail::fnd::Stream` and `detail::fnd::FileStream` --- include/nn/atk/fnd/io/atkfnd_FileStream.h | 16 ++++++++++++++-- include/nn/atk/fnd/io/atkfnd_Stream.h | 7 +++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/fnd/io/atkfnd_FileStream.h b/include/nn/atk/fnd/io/atkfnd_FileStream.h index f7cf7da0..608aa271 100644 --- a/include/nn/atk/fnd/io/atkfnd_FileStream.h +++ b/include/nn/atk/fnd/io/atkfnd_FileStream.h @@ -1,8 +1,20 @@ #pragma once +#include + namespace nn::atk::detail::fnd { -class FileStream { +class FileStream : Stream { public: - virtual ~FileStream(); + enum AccessMode { + AccessMode_None, + AccessMode_Read, + AccessMode_Write, + AccessMode_ReadAndWrite, + AccessMode_AllowAppend, + AccessMode_AllowAppendAndWrite = 6, + }; + + ~FileStream() override; }; +static_assert(sizeof(FileStream) == 0x8); } // namespace nn::atk::detail::fnd \ No newline at end of file diff --git a/include/nn/atk/fnd/io/atkfnd_Stream.h b/include/nn/atk/fnd/io/atkfnd_Stream.h index 70db1dcc..17a58b6e 100644 --- a/include/nn/atk/fnd/io/atkfnd_Stream.h +++ b/include/nn/atk/fnd/io/atkfnd_Stream.h @@ -3,6 +3,13 @@ namespace nn::atk::detail::fnd { class Stream { public: + enum SeekOrigin { + SeekOrigin_Begin, + SeekOrigin_End, + SeekOrigin_Current, + }; + virtual ~Stream(); }; +static_assert(sizeof(Stream) == 0x8); } // namespace nn::atk::detail::fnd \ No newline at end of file From 84709bdd423f06af18ee878f3986622ff5c07470 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 22 Feb 2026 12:05:44 -0300 Subject: [PATCH 028/785] atk: Define `nn::atk::detail::fnd::FndResult` and `FndResultType` enum --- include/nn/atk/fnd/basis/atkfnd_Result.h | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/include/nn/atk/fnd/basis/atkfnd_Result.h b/include/nn/atk/fnd/basis/atkfnd_Result.h index e69de29b..74879b2a 100644 --- a/include/nn/atk/fnd/basis/atkfnd_Result.h +++ b/include/nn/atk/fnd/basis/atkfnd_Result.h @@ -0,0 +1,38 @@ +#pragma once + +#include + +namespace nn::atk::detail::fnd { +enum FndResultType { + FndResultType_CodeMask = 0xffffff, + FndResultType_CategoryMask = 0x7f000000, + FndResultType_ErrorFlagMask = ~(FndResultType_CategoryMask | FndResultType_CodeMask), + + FndResultType_CategorySystem = 0x0, + FndResultType_CategoryBitOffset = 0x18, + FndResultType_CategoryIo = 0x1000000, + + FndResultType_ErrorFlag = FndResultType_ErrorFlagMask, + + FndResultType_Failed = FndResultType_ErrorFlag, + FndResultType_NotInitialized, + FndResultType_NotSupported, + FndResultType_NotOpened, + FndResultType_OutOfMemory, + FndResultType_InvalidArgument, + FndResultType_InvalidStatus, + + FndResultType_IoError = -0x7f000000, + FndResultType_IoFileNotFound, + FndResultType_IoInvalidAccess, + FndResultType_IoTargetLocked, + + FndResultType_True = 0, + FndResultType_False, +}; + +struct FndResult { + u32 value; +}; +static_assert(sizeof(FndResult) == 0x4); +} // namespace nn::atk::detail::fnd \ No newline at end of file From 04bec8c4fc14c5b140b54722f6a2c125b1e841a4 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 22 Feb 2026 12:15:59 -0300 Subject: [PATCH 029/785] atk: Define `nn::atk::detail::fnd::StreamCache` --- include/nn/atk/fnd/io/atkfnd_StreamCache.h | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/include/nn/atk/fnd/io/atkfnd_StreamCache.h b/include/nn/atk/fnd/io/atkfnd_StreamCache.h index e69de29b..4c7cf255 100644 --- a/include/nn/atk/fnd/io/atkfnd_StreamCache.h +++ b/include/nn/atk/fnd/io/atkfnd_StreamCache.h @@ -0,0 +1,47 @@ +#pragma once + +#include +#include +#include + +namespace nn::atk::detail::fnd { +struct FsAccessLog; + +class StreamCache { +public: + StreamCache(); + StreamCache(Stream* sourceStream, void* buffer, std::size_t length); + + void Initialize(Stream* sourceStream, void* buffer, std::size_t length); + void Finalize(); + + std::size_t Read(void* buf, std::size_t length, FndResult* result, FsAccessLog* log, void* pFileStream); + + void FlushWriteCache(); + + std::size_t GetReadCacheHitLength(std::size_t) const; + + FndResult SyncStreamCurrentPosition(position_t position); + + void ClearCache(); + + std::size_t Write(void* buf, std::size_t length, FndResult* result); + + std::size_t GetWritableCacheLength(std::size_t) const; + + FndResult Seek(position_t offset, Stream::SeekOrigin origin); + + virtual ~StreamCache(); + +private: + Stream* m_Stream{}; + position_t m_CurrentPosition{0}; + void* m_CacheBuffer{}; + std::size_t m_CacheBufferLength{0}; + position_t m_CachePosition{-1}; + std::size_t m_CachedLength{0}; + u8 m_CacheState{0}; + u8 m_Padding[3]; +}; +static_assert(sizeof(StreamCache) == 0x40); +} // namespace nn::atk::detail::fnd \ No newline at end of file From 9b9b102e0755f0a3c8c0159b0c81e38cc73b597a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 22 Feb 2026 12:55:43 -0300 Subject: [PATCH 030/785] atk: Add virtual methods to `detail::fnd::Stream` --- include/nn/atk/fnd/io/atkfnd_Stream.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/nn/atk/fnd/io/atkfnd_Stream.h b/include/nn/atk/fnd/io/atkfnd_Stream.h index 17a58b6e..fb357003 100644 --- a/include/nn/atk/fnd/io/atkfnd_Stream.h +++ b/include/nn/atk/fnd/io/atkfnd_Stream.h @@ -1,5 +1,10 @@ #pragma once +#include + +#include +#include + namespace nn::atk::detail::fnd { class Stream { public: @@ -10,6 +15,20 @@ class Stream { }; virtual ~Stream(); + + virtual void Close() = 0; + virtual bool IsOpened() const = 0; + + virtual std::size_t Read(void* buf, std::size_t length, FndResult* result) = 0; + virtual std::size_t Write(void* buf, std::size_t length, FndResult* result) = 0; + virtual FndResult Seek(position_t offset, SeekOrigin origin) = 0; + + virtual position_t GetCurrentPosition() const = 0; + virtual std::size_t GetSize() const = 0; + + virtual bool CanRead() const = 0; + virtual bool CanWrite() const = 0; + virtual bool CanSeek() const = 0; }; static_assert(sizeof(Stream) == 0x8); } // namespace nn::atk::detail::fnd \ No newline at end of file From 3f4f20caa3f89ef4495737ca5a6fa154651d2217 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 22 Feb 2026 12:56:44 -0300 Subject: [PATCH 031/785] atk: Define `detail::fnd::FileStreamImpl` --- include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h | 84 +++++++++++++++++++ include/nn/atk/fnd/io/atkfnd_StreamCache.h | 2 - 2 files changed, 84 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h b/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h index e69de29b..b2f0d022 100644 --- a/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h +++ b/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h @@ -0,0 +1,84 @@ +#pragma once + +#include + +#include +#include + +namespace nn::atk::detail::fnd { +class FileStreamImpl : FileStream { +public: + class DirectStream : fnd::Stream { + public: + ~DirectStream() override; + + void Close() override; + bool IsOpened() const override; + + std::size_t Read(void* buf, std::size_t length, FndResult* result) override; + std::size_t Write(void* buf, std::size_t length, FndResult* result) override; + FndResult Seek(position_t offset, SeekOrigin origin) override; + + position_t GetCurrentPosition() const override; + std::size_t GetSize() const override; + + bool CanRead() const override; + bool CanWrite() const override; + bool CanSeek() const override; + + private: + FileStreamImpl* m_Owner; + }; + static_assert(sizeof(DirectStream) == 0x10); + + FileStreamImpl(); + ~FileStreamImpl() override; + + std::size_t Read(void* buf, std::size_t length, FndResult* result) override; + std::size_t Write(void* buf, std::size_t length, FndResult* result) override; + FndResult Seek(position_t offset, fnd::Stream::SeekOrigin origin) override; + + bool CanRead() const override; + bool CanWrite() const override; + bool CanSeek() const override; + + void ValidateAlignment(void* buf); + + FndResult Open(char* filePath, AccessMode accessMode); + void Close() override; + + bool IsOpened() const override; + + std::size_t GetSize() const override; + position_t GetCurrentPosition() const override; + + std::size_t ReadDirect(void* buf, std::size_t length, FndResult* result); + std::size_t WriteDirect(void* buf, std::size_t length, FndResult* result); + FndResult SeekDirect(position_t offset, fnd::Stream::SeekOrigin origin); + + virtual void Flush(); + + virtual void EnableCache(void* buffer, std::size_t length); + virtual void DisableCache(); + virtual bool IsCacheEnabled(); + + virtual s32 GetIoBufferAlignment(); + + virtual bool CanSetFsAccessLog(); + virtual void* SetFsAccessLog(FsAccessLog* pFsAccessLog); + + virtual position_t GetCachePosition(); + virtual std::size_t GetCachedLength(); + +private: + fs::FileHandle m_FileHandle; + bool m_IsOpened; + u8 m_Padding[3]; + std::size_t m_FileSize; + position_t m_CurrentPosition; + StreamCache m_StreamCache; + DirectStream m_DirectStream; + FsAccessLog* m_pAccessLog; +}; +static_assert(sizeof(FileStreamImpl) == 0x80); +} // namespace nn::atk::detail::fnd \ No newline at end of file diff --git a/include/nn/atk/fnd/io/atkfnd_StreamCache.h b/include/nn/atk/fnd/io/atkfnd_StreamCache.h index 4c7cf255..35878826 100644 --- a/include/nn/atk/fnd/io/atkfnd_StreamCache.h +++ b/include/nn/atk/fnd/io/atkfnd_StreamCache.h @@ -1,7 +1,5 @@ #pragma once -#include -#include #include namespace nn::atk::detail::fnd { From ec68c24b41cb5ec7515afa1d09bc2bd68ad95139 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 22 Feb 2026 13:43:53 -0300 Subject: [PATCH 032/785] atk: Define `detail::fnd::CriticalSection` --- CMakeLists.txt | 2 +- .../nn/atk/fnd/basis/atkfnd_CriticalSection.h | 0 include/nn/atk/fnd/os/atkfnd_CriticalSection.h | 16 ++++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) delete mode 100644 include/nn/atk/fnd/basis/atkfnd_CriticalSection.h create mode 100644 include/nn/atk/fnd/os/atkfnd_CriticalSection.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 446b89c7..fbea66ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -360,7 +360,6 @@ add_library(NintendoSDK OBJECT include/nn/atk/util/atk_ProfileReader.h include/nn/atk/util/atk_TaskProfileReader.h include/nn/atk/fnd/basis/atkfnd_Config.h - include/nn/atk/fnd/basis/atkfnd_CriticalSection.h include/nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h include/nn/atk/fnd/basis/atkfnd_HeapBase.h include/nn/atk/fnd/basis/atkfnd_PrimitiveTypes.h @@ -374,6 +373,7 @@ add_library(NintendoSDK OBJECT include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h include/nn/atk/fnd/io/atkfnd_Stream.h include/nn/atk/fnd/io/atkfnd_StreamCache.h + include/nn/atk/fnd/os/atkfnd_CriticalSection.h include/nn/atk/fnd/os/atkfnd_Thread.h include/nvn/nvn_Cpp.h diff --git a/include/nn/atk/fnd/basis/atkfnd_CriticalSection.h b/include/nn/atk/fnd/basis/atkfnd_CriticalSection.h deleted file mode 100644 index e69de29b..00000000 diff --git a/include/nn/atk/fnd/os/atkfnd_CriticalSection.h b/include/nn/atk/fnd/os/atkfnd_CriticalSection.h new file mode 100644 index 00000000..be2b3efd --- /dev/null +++ b/include/nn/atk/fnd/os/atkfnd_CriticalSection.h @@ -0,0 +1,16 @@ +#pragma once + +#include + +namespace nn::atk::detail::fnd { +class CriticalSection { +public: + void lock(); + bool tryLock(); + void unlock(); + +private: + nn::os::Mutex m_Mutex; +}; +static_assert(sizeof(CriticalSection) == 0x20); +} // namespace nn::atk::detail::fnd \ No newline at end of file From 596824364401ed1e9b91103940014095b99c1562 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 22 Feb 2026 14:01:35 -0300 Subject: [PATCH 033/785] atk: Define `FsSoundArchive` --- include/nn/atk/atk_FsSoundArchive.h | 49 +++++++++++++++++++++++++++++ include/nn/atk/atk_SoundArchive.h | 10 +++--- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/include/nn/atk/atk_FsSoundArchive.h b/include/nn/atk/atk_FsSoundArchive.h index e69de29b..dd3fcf79 100644 --- a/include/nn/atk/atk_FsSoundArchive.h +++ b/include/nn/atk/atk_FsSoundArchive.h @@ -0,0 +1,49 @@ +#pragma once + +#include +#include +#include +#include + +namespace nn::atk { +class FsSoundArchive : SoundArchive { +public: + enum FileAccessMode { + FileAccessMode_Always, + FileAccessMode_InFunction + }; + + FsSoundArchive(); + ~FsSoundArchive() override; + + void Close(); + bool Open(const char* path); + + detail::fnd::FileStream* OpenStream(void* buffer, std::size_t size, + position_t begin, std::size_t length) const override; + + detail::fnd::FileStream* OpenExtStream(void* buffer, std::size_t size, const char* extFilePath, + void* cacheBuffer, std::size_t cacheSize) const; + + std::size_t detail_GetRequiredStreamBufferSize() const override; + + bool LoadHeader(void* buffer, std::size_t size); + bool LoadLabelStringData(void* buffer, std::size_t size); + + void FileAccessBegin() const override; + void FileAccessEnd() const override; + + void* detail_GetFileAddress(ItemId itemId) override; + +private: + detail::SoundArchiveFileReader m_ArchiveReader; + detail::fnd::FileStreamImpl m_FileStream; + bool m_IsOpened; + u8 m_FileAccessMode; + u8 m_Padding[2]; + u32 m_FileAccessCount; + char m_SoundArchiveFullPath[639]; + detail::fnd::CriticalSection m_FileOpenCloseLock; +}; +static_assert(sizeof(FsSoundArchive) == 0x610); +} // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index d1c22dbc..94180437 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -175,15 +175,15 @@ class SoundArchive { virtual ~SoundArchive(); virtual void* detail_GetFileAddress(ItemId itemId) = 0; - virtual size_t detail_GetRequiredStreamBufferSize() = 0; + virtual std::size_t detail_GetRequiredStreamBufferSize() const = 0; - virtual void FileAccessBegin(); - virtual void FileAccessEnd(); + virtual void FileAccessBegin() const; + virtual void FileAccessEnd() const; virtual bool IsAddon(); - virtual detail::fnd::FileStream* OpenStream(void* buffer, size_t size, - position_t begin, size_t length) = 0; + virtual detail::fnd::FileStream* OpenStream(void* buffer, std::size_t size, + position_t begin, std::size_t length) const = 0; private: detail::SoundArchiveFileReader* m_pFileReader{}; From 8816f7f50c400dc83abdb30357bd90c641a62186 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 22 Feb 2026 14:08:11 -0300 Subject: [PATCH 034/785] atk: Define `OutputReceiver` --- include/nn/atk/atk_OutputReceiver.h | 0 include/nn/atk/submix/atk_OutputReceiver.h | 14 ++++++++++++++ 2 files changed, 14 insertions(+) delete mode 100644 include/nn/atk/atk_OutputReceiver.h create mode 100644 include/nn/atk/submix/atk_OutputReceiver.h diff --git a/include/nn/atk/atk_OutputReceiver.h b/include/nn/atk/atk_OutputReceiver.h deleted file mode 100644 index e69de29b..00000000 diff --git a/include/nn/atk/submix/atk_OutputReceiver.h b/include/nn/atk/submix/atk_OutputReceiver.h new file mode 100644 index 00000000..cb9d1cd1 --- /dev/null +++ b/include/nn/atk/submix/atk_OutputReceiver.h @@ -0,0 +1,14 @@ +#pragma once + +namespace nn::atk { +class OutputReceiver { +public: + enum ReceiverType { + ReceiverType_SubMix, + ReceiverType_FinalMix, + }; + + virtual ~OutputReceiver() = 0; +}; +static_assert(sizeof(OutputReceiver) == 0x8); +} // namespace nn::atk \ No newline at end of file From f13f13583c5c7015f55e5766a5becd1f6fcc7095 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 22 Feb 2026 15:08:08 -0300 Subject: [PATCH 035/785] atk: Define `detail::CurveAdshr` --- include/nn/atk/atk_SoundMemoryAllocatable.h | 2 +- include/nn/atk/detail/util/atk_CurveAdshr.h | 76 +++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_SoundMemoryAllocatable.h b/include/nn/atk/atk_SoundMemoryAllocatable.h index aad67efa..0d4b1e1a 100644 --- a/include/nn/atk/atk_SoundMemoryAllocatable.h +++ b/include/nn/atk/atk_SoundMemoryAllocatable.h @@ -5,7 +5,7 @@ namespace nn::atk { class SoundMemoryAllocatable { public: - typedef void(*DisposeCallback)(void*); + using DisposeCallback = void(*)(void*); virtual ~SoundMemoryAllocatable() = 0; virtual void* Allocate(size_t size) = 0; diff --git a/include/nn/atk/detail/util/atk_CurveAdshr.h b/include/nn/atk/detail/util/atk_CurveAdshr.h index e69de29b..5f9101dd 100644 --- a/include/nn/atk/detail/util/atk_CurveAdshr.h +++ b/include/nn/atk/detail/util/atk_CurveAdshr.h @@ -0,0 +1,76 @@ +#pragma once + +#include + +namespace nn::atk::detail { +class CurveAdshr { +public: + enum Status { + Status_Attack, + Status_Hold, + Status_Decay, + Status_Sustain, + Status_Release, + }; + + constexpr static f32 VolumeInit = -90.4; + constexpr static f32 AttackInit = 127; + constexpr static u32 HoldInit = 0; + constexpr static f32 DecayInit = 127; + constexpr static f32 SustainInit = 127; + constexpr static f32 ReleaseInit = 127; + + constexpr static u32 DecibelSquareTableSize = 128; + constexpr static u32 CalcDecibelScaleMax = 127; + + constexpr static u16 DecibelSquareTable[DecibelSquareTableSize] = { + 64813, 64814, 64815, 64885, 64935, 64974, 65006, 65033, + 65056, 65076, 65094, 65111, 65126, 65140, 65153, 65165, + 65176, 65187, 65197, 65206, 65215, 65223, 65231, 65239, + 65247, 65254, 65260, 65267, 65273, 65279, 65285, 65291, + 65297, 65302, 65307, 65312, 65317, 65322, 65326, 65331, + 65335, 65340, 65344, 65348, 65352, 65356, 65360, 65363, + 65367, 65371, 65374, 65378, 65381, 65384, 65387, 65391, + 65394, 65397, 65400, 65403, 65406, 65409, 65411, 65414, + 65417, 65420, 65422, 65425, 65427, 65430, 65433, 65435, + 65437, 65440, 65442, 65445, 65447, 65449, 65451, 65454, + 65456, 65458, 65460, 65462, 65464, 65466, 65468, 65470, + 65472, 65474, 65476, 65478, 65480, 65482, 65484, 65486, + 65487, 65489, 65491, 65493, 65494, 65496, 65498, 65500, + 65501, 65503, 65505, 65506, 65508, 65509, 65511, 65513, + 65514, 65516, 65517, 65519, 65520, 65522, 65523, 65525, + 65526, 65528, 65529, 65530, 65532, 65533, 65535, 0, + }; + + CurveAdshr(); + + void Initialize(f32 initDecibel); + + void SetAttack(s32 attack); + void SetHold(s32 hold); + void SetDecay(s32 decay); + void SetSustain(s32 sustain); + void SetRelease(s32 release); + + void Reset(f32 initDecibel); + + f32 GetValue() const; + + void Update(s32 msec); + + static u16 CalcDecibelSquare(s32); + static f32 CalcRelease(s32); + +private: + Status m_Status{Status_Attack}; + f32 m_Value{-904.0}; + f32 m_Decay{65535.0}; + f32 m_Release{65535.0}; + f32 m_Attack{0.0}; + u16 m_Hold{0}; + u16 m_HoldCounter; + u8 m_Sustain{127}; + u8 m_Padding[3]; +}; +static_assert(sizeof(CurveAdshr) == 0x1c); +} // namespace nn::atk::detail \ No newline at end of file From 5d5737a6c878b89dd62966a64003056868d46c90 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 22 Feb 2026 15:19:06 -0300 Subject: [PATCH 036/785] atk: Define `detail::CurveLfo` --- include/nn/atk/detail/util/atk_CurveLfo.h | 55 +++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/include/nn/atk/detail/util/atk_CurveLfo.h b/include/nn/atk/detail/util/atk_CurveLfo.h index e69de29b..e81eaa10 100644 --- a/include/nn/atk/detail/util/atk_CurveLfo.h +++ b/include/nn/atk/detail/util/atk_CurveLfo.h @@ -0,0 +1,55 @@ +#pragma once + +#include + +namespace nn::atk::detail { +struct CurveLfoParam { + enum CurveType { + CurveType_Min, + CurveType_UserMin = 0x40, + CurveType_Max = 0x7f, + CurveType_UserMax = CurveType_Max, + + CurveType_Sine = CurveType_Min, + CurveType_Triangle, + CurveType_Saw, + CurveType_Square, + CurveType_Random, + + CurveType_Count = 0x80, + }; + + f32 depth; + f32 speed; + u32 delay; + u8 range; + u8 curve; + u8 phase; + u8 padding[1]; + + void Initialize(); +}; +static_assert(sizeof(CurveLfoParam) == 0x10); + +class CurveLfo { +public: + using CurveFunc = f32(*)(f32); + + static void InitializeCurveTable(); + + void Reset(); + void Update(s32 msec); + + f32 GetValue(); + +private: + CurveLfoParam m_Param; + u32 m_DelayCounter; + f32 m_Counter; + f32 m_RandomValue; + bool m_IsStart; + bool m_IsNext; + u8 m_Padding[2]; +}; +static_assert(sizeof(CurveLfo) == 0x20); +} // namespace nn::atk::detail \ No newline at end of file From f21311506cfe32fb490df7a4ba60f95dcdbc27f9 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 22 Feb 2026 19:54:13 -0300 Subject: [PATCH 037/785] atk: Define `detail::BusMixVolumePacket` --- .../nn/atk/detail/atk_BusMixVolumePacket.h | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/nn/atk/detail/atk_BusMixVolumePacket.h b/include/nn/atk/detail/atk_BusMixVolumePacket.h index e69de29b..b8486f4e 100644 --- a/include/nn/atk/detail/atk_BusMixVolumePacket.h +++ b/include/nn/atk/detail/atk_BusMixVolumePacket.h @@ -0,0 +1,21 @@ +#pragma once + +#include + +namespace nn::atk::detail { +class BusMixVolumePacket { +public: + static std::size_t GetRequiredMemSize(s32 busCount); + + bool Initialize(void* buffer, std::size_t size, s32 busCount); + + void Reset(); + +private: + OutputBusMixVolume m_BusMixVolume; + bool m_IsUsed; + bool* m_pIsEnabledTable; + s32 m_BusCount; +}; +static_assert(sizeof(BusMixVolumePacket) == 0xd8); +} // namespace nn::atk::detail \ No newline at end of file From 4b6c41583ed89aa7dd494d97c5915b62ba64e7e6 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 22 Feb 2026 20:01:32 -0300 Subject: [PATCH 038/785] atk: Define `detail::ValueArray` --- include/nn/atk/detail/atk_ValueArray.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/nn/atk/detail/atk_ValueArray.h b/include/nn/atk/detail/atk_ValueArray.h index e69de29b..4c20b6fc 100644 --- a/include/nn/atk/detail/atk_ValueArray.h +++ b/include/nn/atk/detail/atk_ValueArray.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +namespace nn::atk::detail { +template +class ValueArray { +public: +private: + T* m_pValue; + s32 m_Count; +}; +} // namespace nn::atk::detail \ No newline at end of file From e5eff5c66227c740083d603522dbaeb7d34be71f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 22 Feb 2026 20:08:47 -0300 Subject: [PATCH 039/785] atk: Define `detail::VolumeThroughModePacket` --- .../atk/detail/atk_VolumeThroughModePacket.h | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/nn/atk/detail/atk_VolumeThroughModePacket.h b/include/nn/atk/detail/atk_VolumeThroughModePacket.h index e69de29b..e371f28b 100644 --- a/include/nn/atk/detail/atk_VolumeThroughModePacket.h +++ b/include/nn/atk/detail/atk_VolumeThroughModePacket.h @@ -0,0 +1,24 @@ +#pragma once + +#include + +namespace nn::atk::detail { +class VolumeThroughModePacket { +public: + using VolumeThroughModeArray = ValueArray; + + static std::size_t GetRequiredMemSize(s32 busCount); + + bool Initialize(void* buffer, std::size_t size, s32 busCount); + + void Reset(); + + VolumeThroughModePacket& operator=(const VolumeThroughModePacket& rhs); + +private: + VolumeThroughModeArray m_VolumeThroughMode; + bool m_IsVolumeThroughModeUsed; + f32 m_BinaryVolume; +}; +static_assert(sizeof(VolumeThroughModePacket) == 0x18); +} // namespace nn::atk::detail \ No newline at end of file From d27a75b2fc304a9b7fb0319b6890b2a0a8e40bc3 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 22 Feb 2026 20:21:36 -0300 Subject: [PATCH 040/785] atk: Define `detail::OutputAdditionalParam` --- .../nn/atk/detail/atk_OutputAdditionalParam.h | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/include/nn/atk/detail/atk_OutputAdditionalParam.h b/include/nn/atk/detail/atk_OutputAdditionalParam.h index e69de29b..9d5f9de7 100644 --- a/include/nn/atk/detail/atk_OutputAdditionalParam.h +++ b/include/nn/atk/detail/atk_OutputAdditionalParam.h @@ -0,0 +1,53 @@ +#pragma once + +#include + +#include +#include +#include + +namespace nn::atk::detail { +class OutputAdditionalParam { +public: + using SendArray = ValueArray; + + static std::size_t GetRequiredMemSize(SoundInstanceConfig* config); + + void Initialize(void* buffer, std::size_t bufferSize, SoundInstanceConfig* config); + + void Reset(); + + void* GetBufferAddr(); + + SendArray* GetAdditionalSendAddr(); + f32 TryGetAdditionalSend(s32 bus); + bool IsAdditionalSendEnabled(); + void TrySetAdditionalSend(s32 bus, f32 send); + + BusMixVolumePacket* GetBusMixVolumePacketAddr(); + f32 GetBusMixVolume(s32 waveChannel, s32 mixChannel); + OutputBusMixVolume* GetBusMixVolume(); + void SetBusMixVolume(OutputBusMixVolume* param); + bool IsBusMixVolumeUsed(); + void SetBusMixVolumeUsed(bool isUsed); + bool IsBusMixVolumeEnabledForBus(s32 bus); + void SetBusMixVolumeEnabledForBus(s32 bus, bool isEnabled); + bool IsBusMixVolumeEnabled(); + + VolumeThroughModePacket* GetVolumeThroughModePacketAddr(); + f32 GetBinaryVolume(); + void SetBinaryVolume(f32 volume); + u8 TryGetVolumeThroughMode(s32 bus); + bool IsVolumeThroughModeEnabled(); + bool IsVolumeThroughModeUsed(); + void SetVolumeThroughModeUsed(bool isUsed); + + OutputAdditionalParam& operator=(const OutputAdditionalParam& rhs); + +private: + SendArray* m_pAdditionalSend; + BusMixVolumePacket* m_pBusMixVolumePacket; + VolumeThroughModePacket* VolumeThroughModePacket; +}; +static_assert(sizeof(OutputAdditionalParam) == 0x18); +} // namespace nn::atk::detail \ No newline at end of file From 1ce61f3dd74362b9fa56191bc9e5a829ae43a313 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 22 Feb 2026 20:29:59 -0300 Subject: [PATCH 041/785] atk: Define `detail::MoveValue` --- include/nn/atk/detail/atk_MoveValue.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/nn/atk/detail/atk_MoveValue.h b/include/nn/atk/detail/atk_MoveValue.h index e69de29b..e995a92e 100644 --- a/include/nn/atk/detail/atk_MoveValue.h +++ b/include/nn/atk/detail/atk_MoveValue.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +namespace nn::atk::detail { +template +class MoveValue { +public: +private: + T1 m_Origin; + T1 m_Target; + T2 m_Frame; + T2 m_Counter; +}; +} // namespace nn::atk::detail \ No newline at end of file From 571072410193fe93048b95fef339b1b21c408701 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 22 Feb 2026 20:40:08 -0300 Subject: [PATCH 042/785] audio: Define VoiceTypes header --- include/nn/audio/audio_VoiceTypes.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 include/nn/audio/audio_VoiceTypes.h diff --git a/include/nn/audio/audio_VoiceTypes.h b/include/nn/audio/audio_VoiceTypes.h new file mode 100644 index 00000000..e5337725 --- /dev/null +++ b/include/nn/audio/audio_VoiceTypes.h @@ -0,0 +1,25 @@ +#pragma once + +#include + +namespace nn::audio { +struct VoiceInfo; + +struct VoiceType { + enum PlayState { + PlayState_Play, + PlayState_Stop, + PlayState_Pause, + }; + + VoiceInfo* _pVoiceInfo; +}; +static_assert(sizeof(VoiceType) == 0x8); + +struct BiquadFilterParameter { + bool enable; + s16 numerator[3]; + s16 denominator[2]; +}; +static_assert(sizeof(BiquadFilterParameter) == 0xc); +} // namespace nn::audio \ No newline at end of file From 5b9a1640de89bf8f6942697cc4df0c634c55a7ae Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 22 Feb 2026 20:44:28 -0300 Subject: [PATCH 043/785] audio: Define Common header --- CMakeLists.txt | 4 +++- include/nn/audio/audio_Common.h | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 include/nn/audio/audio_Common.h diff --git a/CMakeLists.txt b/CMakeLists.txt index fbea66ae..f8072cf1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,12 +232,13 @@ add_library(NintendoSDK OBJECT include/nn/mem.h include/nn/audio/audio_Adpcm.h + include/nn/audio/audio_Common.h + include/nn/audio/audio_VoiceTypes.h include/nn/atk/atk_Adpcm.h include/nn/atk/atk_BiquadFilterCallback.h include/nn/atk/atk_FsSoundArchive.h include/nn/atk/atk_Global.h - include/nn/atk/atk_OutputReceiver.h include/nn/atk/atk_SequenceSoundHandle.h include/nn/atk/atk_SoundActor.h include/nn/atk/atk_SoundArchive.h @@ -354,6 +355,7 @@ add_library(NintendoSDK OBJECT include/nn/atk/submix/atk_ChannelMixVolume.h include/nn/atk/submix/atk_FinalMix.h include/nn/atk/submix/atk_OutputMixer.h + include/nn/atk/submix/atk_OutputReceiver.h include/nn/atk/submix/atk_SubMix.h include/nn/atk/util/atk_AudioRendererPerformanceReader.h include/nn/atk/util/atk_DeviceOutRecorder.h diff --git a/include/nn/audio/audio_Common.h b/include/nn/audio/audio_Common.h new file mode 100644 index 00000000..dfcc5018 --- /dev/null +++ b/include/nn/audio/audio_Common.h @@ -0,0 +1,7 @@ +#pragma once + +#include + +namespace nn::audio { +using NodeId = uint32_t; +} // namespace nn::audio \ No newline at end of file From 0b1ad68d7e8947e48d4f43213b58ebaabd200461 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 22 Feb 2026 21:39:13 -0300 Subject: [PATCH 044/785] atk: Define `detail::LowLevelVoice` and `detail::LowLevelVoiceAllocator` --- .../nn/atk/detail/voice/atk_LowLevelVoice.h | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/include/nn/atk/detail/voice/atk_LowLevelVoice.h b/include/nn/atk/detail/voice/atk_LowLevelVoice.h index e69de29b..6d3878cc 100644 --- a/include/nn/atk/detail/voice/atk_LowLevelVoice.h +++ b/include/nn/atk/detail/voice/atk_LowLevelVoice.h @@ -0,0 +1,104 @@ +#pragma once + +#include + +#include +#include + +#include +#include +#include +#include + +namespace nn::atk::detail { +class Voice; + +class alignas(256) LowLevelVoice { +public: + void FreeAllWaveBuffer(); + + bool IsAvailable() const; + void SetAvailable(bool isAvailable); + + bool IsVoiceDroppedFlagOn() const; + + void AppendWaveBuffer(WaveBuffer* waveBuffer); + + void UpdateState(OutputMode outputMode); + void UpdateStatePlay(bool isRun, OutputMode outputMode); + void UpdateStatePause(bool isRun, OutputMode outputMode); + + void SetPriority(s32 priority); + + bool AllocVoice(); + + void SetState(VoiceState state); + + void UpdateVoiceInfo(VoiceInfo* voiceInfo) const; + void UpdateVoiceParam(const VoiceParam& voiceParam, OutputMode outputMode); + void UpdateVolume(const VoiceParam& voiceParam); + void UpdatePitch(const VoiceParam& voiceParam); + void UpdateBiquadFilter(const VoiceParam& voiceParam); + void UpdateLowPassFilter(const VoiceParam& voiceParam); + void UpdateMixVolume(const OutputMix& outputMix, OutputMode outputMode); + void UpdateWaveBuffer(bool isRun, OutputMode outputMode); + void UpdatePlayPosition(); + void UpdateWaveBufferOnPlayState(); + void UpdateWaveBufferOnStopState(OutputMode outputMode); + + bool AppendWaveBufferToVoice(WaveBuffer* waveBuffer); + + void UpdateMixVolumeOnSubMix(const OutputMix& outputMix, OutputMode outputMode); + void UpdateMixVolumeOnFinalMix(const OutputMix& outputMix, OutputMode outputMode); + + void SetVoiceMixVolume(f32, s32); + + static f32 GetClampedVoiceVolume(f32); + +private: + AdpcmParam m_AdpcmParam; + audio::VoiceType m_Voice; + bool m_IsAvailable; + bool m_IsSetVoiceSlot; + VoiceParam m_VoiceParam; + s32 m_Priority; + VoiceState m_State; + u32 m_SampleRate; + SampleFormat m_SampleFormat; + position_t m_PlayPosition; + OutputReceiver* m_pOutputReceiver; + WaveBuffer* m_WaveBufferListBegin; + WaveBuffer* m_WaveBufferListEnd; + WaveBuffer* m_LastAppendBuffer; + Voice* m_pVoice; + audio::NodeId nodeId; +}; +static_assert(sizeof(LowLevelVoice) == 0x100); + +class LowLevelVoiceAllocator { +public: + LowLevelVoiceAllocator(); + + std::size_t GetRequiredMemSize(s32 voiceCount); + + void Initialize(s32 voiceCount, void* mem, std::size_t memSize); + void Finalize(); + + void UpdateAllVoiceState(OutputMode outputMode); + + LowLevelVoice* AllocVoice(); + u64 GetVoiceArrayIndex(LowLevelVoice* pVoice); + void FreeVoice(LowLevelVoice* pVoice); + + s32* GetDroppedVoiceCount(); + +private: + void* m_pVoiceArray{}; + LowLevelVoice** m_ppVoiceTable{}; + s32 m_UsingCount{0}; + s32* m_pAssignedTableIndex{}; + s32 m_VoiceCount{}; + std::atomic m_DroppedVoiceCount{0}; +}; +static_assert(sizeof(LowLevelVoiceAllocator) == 0x28); +} // namespace nn::atk::detail \ No newline at end of file From 4f392305b76e26d20e15bcfc20af1c908b444042 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 22 Feb 2026 21:54:15 -0300 Subject: [PATCH 045/785] atk: Define `detail::Voice` --- include/nn/atk/detail/voice/atk_Voice.h | 49 +++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/include/nn/atk/detail/voice/atk_Voice.h b/include/nn/atk/detail/voice/atk_Voice.h index e69de29b..a4a1ca64 100644 --- a/include/nn/atk/detail/voice/atk_Voice.h +++ b/include/nn/atk/detail/voice/atk_Voice.h @@ -0,0 +1,49 @@ +#pragma once + +#include + +namespace nn::atk::detail { +class Voice { +public: + Voice(); + ~Voice(); + + void Initialize(u32); + + bool IsAvailable() const; + + bool AllocVoice(u32 priority); + void Free(); + + void SetPriority(u32 priority); + void SetState(VoiceState state); + + void AppendWaveBuffer(WaveBuffer* waveBuffer); + + void UpdateParam(); + + position_t GetPlayPosition() const; + + bool SetMonoFilter(bool enable, u16 cutoff); + void SetBiquadFilter(bool enable, const BiquadFilterCoefficients* coef); + + void UpdateVoiceStatus(); + +private: + u32 m_Priority; + VoiceState m_State; + VoiceParam m_VoiceParam; + SampleFormat m_SampleFormat; + u32 m_SampleRate; + AdpcmParam m_AdpcmParam; + OutputReceiver* m_pOutputReceiver; + u32 m_VoiceId; + position_t m_PlayPosition; + u32 m_VoiceInfoEnableFlag; + u32 m_CommandTag; + WaveBuffer* m_WaveBufferListBegin; + WaveBuffer* m_WaveBufferListEnd; + LowLevelVoice* m_pLowLevelVoice; +}; +static_assert(sizeof(Voice) == 0xe0); +} // namespace nn::atk::voice \ No newline at end of file From 2d3a71313b42d228a20cad5f26ae1df66a59ec0e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 22 Feb 2026 22:01:59 -0300 Subject: [PATCH 046/785] atk: Define `detail::VirtualVoiceManager` --- include/nn/atk/atk_Global.h | 2 +- .../nn/atk/detail/atk_OutputAdditionalParam.h | 4 +-- include/nn/atk/detail/voice/atk_Voice.h | 34 +++++++++++++++++++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h index 83d57af1..dc22a4a7 100644 --- a/include/nn/atk/atk_Global.h +++ b/include/nn/atk/atk_Global.h @@ -252,7 +252,7 @@ enum OutputMode { }; struct OutputMix { - float channelGain[24]; + f32 channelGain[24]; }; static_assert(sizeof(OutputMix) == 0x60); diff --git a/include/nn/atk/detail/atk_OutputAdditionalParam.h b/include/nn/atk/detail/atk_OutputAdditionalParam.h index 9d5f9de7..081d9134 100644 --- a/include/nn/atk/detail/atk_OutputAdditionalParam.h +++ b/include/nn/atk/detail/atk_OutputAdditionalParam.h @@ -7,10 +7,10 @@ #include namespace nn::atk::detail { +using SendArray = ValueArray; + class OutputAdditionalParam { public: - using SendArray = ValueArray; - static std::size_t GetRequiredMemSize(SoundInstanceConfig* config); void Initialize(void* buffer, std::size_t bufferSize, SoundInstanceConfig* config); diff --git a/include/nn/atk/detail/voice/atk_Voice.h b/include/nn/atk/detail/voice/atk_Voice.h index a4a1ca64..8e970435 100644 --- a/include/nn/atk/detail/voice/atk_Voice.h +++ b/include/nn/atk/detail/voice/atk_Voice.h @@ -1,10 +1,16 @@ #pragma once +#include + #include namespace nn::atk::detail { class Voice { public: + constexpr static s32 PriorityMin = 0; + constexpr static s32 PriorityMax = 255; + constexpr static s32 PriorityNoDrop = 255; + Voice(); ~Voice(); @@ -46,4 +52,32 @@ class Voice { LowLevelVoice* m_pLowLevelVoice; }; static_assert(sizeof(Voice) == 0xe0); + +class VirtualVoiceManager { +public: + constexpr static s32 InvalidVoiceId = -1; + + constexpr static u32 VirtualVoiceCount = 256; + constexpr static u32 VirtualVoiceElementCount = 8; + + static VirtualVoiceManager* GetInstance(); + + bool AllocVirtualVoice(); + void FreeVirtualVoice(u32); + + void Initialize(); + + void UpdateVoiceInfo(); + + s32 GetAllocatedVirtualVoiceCount() const; + s32 GetUnreleasedLowLevelVoiceCount() const; + +private: + u32 m_VirtualVoiceAllocationTable[8]; + u32 m_VoiceInfoTableRead; + LowLevelVoice* m_LowLevelVoiceTable[256]; + VoiceInfo m_VoiceInfoTable[2][256]; + util::BitFlagSet<256, void> m_VoiceInfoDirtyTable[2]; +}; +static_assert(sizeof(VirtualVoiceManager) == 0x4868); } // namespace nn::atk::voice \ No newline at end of file From defacb01ab06637d6655781b15a186864d6a7983 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 22 Feb 2026 22:54:05 -0300 Subject: [PATCH 047/785] atk: Define `detail::driver::MultiVoice` --- include/nn/atk/detail/voice/atk_MultiVoice.h | 173 +++++++++++++++++++ 1 file changed, 173 insertions(+) diff --git a/include/nn/atk/detail/voice/atk_MultiVoice.h b/include/nn/atk/detail/voice/atk_MultiVoice.h index e69de29b..d9920f52 100644 --- a/include/nn/atk/detail/voice/atk_MultiVoice.h +++ b/include/nn/atk/detail/voice/atk_MultiVoice.h @@ -0,0 +1,173 @@ +#pragma once + +#include + +#include +#include + +namespace nn::atk::detail::driver { +class MultiVoice { +public: + struct PreMixVolume { + f32 volume[24]; + }; + static_assert(sizeof(PreMixVolume) == 0x60); + + enum VoiceCallbackStatus { + VoiceCallbackStatus_FinishWave, + VoiceCallbackStatus_Cancel, + VoiceCallbackStatus_DropVoice, + VoiceCallbackStatus_DropDsp, + }; + + using VoiceCallback = void(*)(MultiVoice*,VoiceCallbackStatus,void*); + + constexpr static u32 UpdateStart = 1; + constexpr static u32 UpdatePause = 2; + constexpr static u32 UpdateSrc = 4; + constexpr static u32 UpdateMix = 8; + constexpr static u32 UpdateLpf = 16; + constexpr static u32 UpdateBiquad = 32; + constexpr static u32 UpdateVe = 64; + + constexpr static u32 PriorityNoDrop = 255; + + constexpr static f32 VolumeMin = 0.0; + constexpr static f32 VolumeDefault = 1.0; + constexpr static f32 VolumeMax = 2.0; + + constexpr static f32 PanLeft = -1.0; + constexpr static f32 PanCenter = 0.0; + constexpr static f32 PanRight = 1.0; + + constexpr static f32 SpanFront = 0.0; + constexpr static f32 SpanCenter = 1.0; + constexpr static f32 SpanRear = 2.0; + + constexpr static f32 CutoffFreqMin = 0.0; + constexpr static f32 CutoffFreqMax = 1.0; + + constexpr static f32 BiquadValueMin = 0.0; + constexpr static f32 BiquadValueMax = 1.0; + + constexpr static f32 SendMin = 0.0; + constexpr static f32 SendMax = 1.0; + + explicit MultiVoice(); + explicit MultiVoice(OutputAdditionalParam* pAdditionalParam); + ~MultiVoice(); + + bool Alloc(s32 channelCount, s32 priority, VoiceCallback callback, void* callbackData); + void InitParam(VoiceCallback callback, void* callbackData); + void Free(); + + void Start(); + void Stop(); + void StopAllSdkVoice(); + + void UpdateVoiceStatus(); + + bool IsPlayFinished() const; + + void Pause(bool flag); + + void Calc(); + void CalcSrc(bool); + void CalcVe(); + void CalcMix(); + void CalcLpf(); + void CalcBiquadFilter(); + + void Update(); + + void RunAllSdkVoice(); + void PauseAllSdkVoice(); + + void SetSampleFormat(SampleFormat format); + void SetSampleRate(s32 sampleRate); + void SetVolume(f32 volume); + void SetPitch(f32 pitch); + void SetPanMode(PanMode panMode); + void SetPanCurve(PanCurve panCurve); + void SetLpfFreq(f32 lpfFreq); + void SetBiquadFilter(s32 type, f32 value); + void SetPriority(s32 priority); + void SetOutputLine(u32 lineFlag); + void SetOutputParamImpl(const OutputParam& in, const OutputParam& out); + void SetOutputAdditionalParamImpl(SendArray* pAdditionalSend, + BusMixVolumePacket* pBusMixVolumePacket, + OutputBusMixVolume* pBusMixVolume, + VolumeThroughModePacket* pVolumeThroughModePacket); + void SetOutputBusMixVolumeImpl(BusMixVolumePacket* in, + OutputBusMixVolume* busMixVolume, + BusMixVolumePacket* out); + void SetTvParam(const OutputParam& param); + void SetTvAdditionalParam(OutputAdditionalParam* param); + void SetTvAdditionalParam(SendArray* pAdditionalSend, + BusMixVolumePacket* pBusMixVolumePacket, + OutputBusMixVolume* pBusMixVolume, + VolumeThroughModePacket* pVolumeThroughModePacket); + void SetOutputReceiver(OutputReceiver* pOutputReceiver); + void SetSubMixIndex(s32 subMixIndex); + + void CalcPreMixVolume(PreMixVolume* mix, const OutputParam& param, + s32 channelIndex, OutputDevice device); + void CalcPreMixVolume(PreMixVolume* mix, const OutputParam& param, + OutputAdditionalParam* pAdditionalParam, s32 channelIndex, + OutputDevice device); + void CalcTvMix(OutputMix* mix, const PreMixVolume& pre); + void CalcMixImpl(OutputMix* mix, u32 outputDeviceIndex, + const OutputParam& param, const PreMixVolume& pre); + void CalcMixImpl(OutputMix* mix, u32 outputDeviceIndex, const OutputParam& param, + OutputAdditionalParam* pAdditionalParam, const PreMixVolume& pre); + + MultiVoice* detail_GetSdkVoice(s32) const; + + position_t GetCurrentPlayingSample() const; + SampleFormat GetFormat() const; + + bool IsRun() const; + + void SetInterpolationType(u8 interpolationType); + + void AppendWaveBuffer(s32 channelIndex, WaveBuffer* pBuffer, bool lastFlag); + + void SetAdpcmParam(s32 channelIndex, const AdpcmParam& param); + + static u64 FrameToByte(s64, SampleFormat); + static void CalcOffsetAdpcmParam(AdpcmContext* context, const AdpcmParam& param, + position_t offsetSamples, const void* dataAddress); + +private: + Voice m_Voice[2]; + s32 m_ChannelCount; + VoiceCallback m_Callback; + void* m_pCallbackData; + bool m_IsActive; + bool m_IsStart; + bool m_IsStarted; + bool m_IsPause; + bool m_IsPausing; + bool m_IsInitialized; + WaveBuffer* m_pLastWaveBuffer; + u16 m_SyncFlag; + u8 m_BiquadType; + bool m_IsEnableFrontBypass; + f32 m_Volume; + f32 m_Pitch; + PanMode m_PanMode; + PanCurve m_PanCurve; + f32 m_LpfFreq; + f32 m_BiquadValue; + s32 m_Priority; + u32 m_OutputLineFlag; + OutputParam m_TvParam; + OutputAdditionalParam* m_pTvAdditionalParam; + SampleFormat m_Format; + std::uintptr_t m_VoiceUser; + UpdateType m_UpdateType; + OutputReceiver* m_pOutputReceiver; + util::IntrusiveListNode m_LinkNode; +}; +static_assert(sizeof(MultiVoice) == 0x298); +} // namespace nn::atk::detail \ No newline at end of file From 9a34f62d01a6c70311f7e5800e03fb1819ee73d8 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 23 Feb 2026 12:42:54 -0300 Subject: [PATCH 048/785] atk: Define `detail::driver::Channel` --- include/nn/atk/detail/util/atk_Util.h | 6 + include/nn/atk/detail/voice/atk_Channel.h | 149 ++++++++++++++++++++++ include/nn/atk/detail/voice/atk_Voice.h | 5 +- 3 files changed, 157 insertions(+), 3 deletions(-) diff --git a/include/nn/atk/detail/util/atk_Util.h b/include/nn/atk/detail/util/atk_Util.h index 028fac97..515b971d 100644 --- a/include/nn/atk/detail/util/atk_Util.h +++ b/include/nn/atk/detail/util/atk_Util.h @@ -22,6 +22,12 @@ struct Util { 8000, 10240, 12800, 16000 }; + template + class Singleton { + public: + static Class* GetInstance(); + }; + struct Reference { constexpr static s32 InvalidOffset = -1; diff --git a/include/nn/atk/detail/voice/atk_Channel.h b/include/nn/atk/detail/voice/atk_Channel.h index e69de29b..6e105ecc 100644 --- a/include/nn/atk/detail/voice/atk_Channel.h +++ b/include/nn/atk/detail/voice/atk_Channel.h @@ -0,0 +1,149 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace nn::atk::detail::driver { +class Channel { +public: + enum ChannelCallbackStatus { + ChannelCallbackStatus_Stopped, + ChannelCallbackStatus_Drop, + ChannelCallbackStatus_Finish, + ChannelCallbackStatus_Cancel, + }; + + enum LfoTarget { + LfoTarget_Pitch, + LfoTarget_Volume, + LfoTarget_Pan, + LfoTarget_Invalid = 0xff, + }; + + using ChannelCallback = void(*)(Channel*,ChannelCallbackStatus,void*); + + constexpr static u32 ChannelCount = 97; + constexpr static u32 ChannelMin = 0; + constexpr static u32 ChannelMax = 96; + + constexpr static u32 PriorityRelease = 1; + + constexpr static u32 KeyInit = 60; + constexpr static u32 OriginalKeyInit = KeyInit; + + constexpr static u8 SilenceVolumeMax = 255; + constexpr static u8 SilenceVolumeMin = 0; + + constexpr static u32 WaveBufferMax = 2; + + constexpr static u32 ModCount = 4; + + constexpr static f32 SilenceVolumeMaxR = 1.0 / SilenceVolumeMax; + + class Disposer : DisposeCallback { + public: + ~Disposer() override; + + void InvalidateData(void* start, void* end); + + private: + Channel* m_pChannel; + }; + + Channel(); + ~Channel(); + + void InitParam(ChannelCallback callback, void* callbackData); + + void Update(bool doPeriodicProc); + void Stop(); + + s32 GetSweepValue() const; + void UpdateSweep(s32 count); + + void Start(const WaveInfo& waveInfo, s32 length, position_t startOffsetSamples); + void Start(const WaveInfo& waveInfo, s32 length, position_t startOffsetSamples, + bool isContextCalculationSkipMode); + + void AppendWaveBuffer(const WaveInfo& waveInfo, position_t startOffsetSamples); + void AppendWaveBuffer(const WaveInfo& waveInfo, position_t startOffsetSamples, + bool isContextCalculationSkipMode); + + void Release(); + + void NoteOff(); + + void SetSweepParam(f32 sweepPitch, s32 sweepTime, bool autoUpdate); + void SetBiquadFilter(s32 type, f32 value); + void SetTvAdditionalParam(OutputAdditionalParam* param); + + position_t GetCurrentPlayingSample(bool) const; + + static void VoiceCallbackFunc(MultiVoice* voice, + MultiVoice::VoiceCallbackStatus status, void* arg); + + void CallChannelCallback(ChannelCallbackStatus status); + + static Channel* AllocChannel(s32 voiceChannelCount, s32 priority, + ChannelCallback callback, void* callbackData); + + void FreeChannel(); + void DetachChannel(); + +private: + Disposer m_Disposer; + CurveAdshr m_CurveAdshr; + CurveLfo m_Lfo[4]; + u8 m_LfoTarget[4]; + u8 m_PauseFlag; + u8 m_ActiveFlag; + u8 m_AllocFlag; + u8 m_AutoSweep; + u8 m_ReleasePriorityFixFlag; + u8 m_IsIgnoreNoteOff; + u8 m_BiquadType; + u8 m_Padding[1]; + f32 m_UserVolume; + f32 m_UserPitchRatio; + f32 m_UserLpfFreq; + f32 m_BiquadValue; + u32 m_OutputLineFlag; + detail::OutputParam m_TvParam; + detail::OutputAdditionalParam* m_pTvAdditionalParam; + f32 m_UserPitch; + f32 m_SweepPitch; + s32 m_SweepCounter; + s32 m_SweepLength; + f32 m_InitPan; + f32 m_InitSurroundPan; + f32 m_Tune; + detail::MoveValue m_SilenceVolume; + f32 m_Cent; + f32 m_CentPitch; + s32 m_Length; + PanMode m_PanMode; + PanCurve m_PanCurve; + u8 m_Key; + u8 m_OriginalKey; + u8 m_KeyGroupId; + u8 m_InterpolationType; + f32 m_InstrumentVolume; + f32 m_Velocity; + ChannelCallback m_Callback; + void* m_CallbackData; + MultiVoice* m_pVoice; + Channel* m_pNextLink; + WaveBuffer m_WaveBuffer[2][2]; + AdpcmContext m_AdpcmContext[2]; + AdpcmContext m_AdpcmLoopContext[2]; + position_t m_LoopStartFrame; + position_t m_OriginalLoopStartFrame; + bool m_LoopFlag; + util::IntrusiveListNode m_Link; +}; +static_assert(sizeof(Channel) == 0x400); +} // namespace nn::atk::detail::driver \ No newline at end of file diff --git a/include/nn/atk/detail/voice/atk_Voice.h b/include/nn/atk/detail/voice/atk_Voice.h index 8e970435..962c271e 100644 --- a/include/nn/atk/detail/voice/atk_Voice.h +++ b/include/nn/atk/detail/voice/atk_Voice.h @@ -3,6 +3,7 @@ #include #include +#include namespace nn::atk::detail { class Voice { @@ -53,15 +54,13 @@ class Voice { }; static_assert(sizeof(Voice) == 0xe0); -class VirtualVoiceManager { +class VirtualVoiceManager : Util::Singleton { public: constexpr static s32 InvalidVoiceId = -1; constexpr static u32 VirtualVoiceCount = 256; constexpr static u32 VirtualVoiceElementCount = 8; - static VirtualVoiceManager* GetInstance(); - bool AllocVirtualVoice(); void FreeVirtualVoice(u32); From ff90f1bffdb23ef8423dcf4f690f150f75e1250d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 23 Feb 2026 13:17:45 -0300 Subject: [PATCH 049/785] atk: Define `detail::BankFileReader` --- .../nn/atk/detail/seq/atk_BankFileReader.h | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/include/nn/atk/detail/seq/atk_BankFileReader.h b/include/nn/atk/detail/seq/atk_BankFileReader.h index e69de29b..3aeff634 100644 --- a/include/nn/atk/detail/seq/atk_BankFileReader.h +++ b/include/nn/atk/detail/seq/atk_BankFileReader.h @@ -0,0 +1,41 @@ +#pragma once + +#include + +namespace nn::atk::detail { +class BankFileReader { +public: + constexpr static s32 SignatureFile = 0x4b4e4246; // FBNK + + struct VelocityRegionInfo { + u32 waveArchiveId; + u32 waveIndex; + f32 pitch; + AdshrCurve adshrCurve; + u8 originalKey; + u8 volume; + u8 pan; + bool isIgnoreNoteOff; + u8 keyGroup; + u8 interpolationType; + }; + static_assert(sizeof(VelocityRegionInfo) == 0x18); + + BankFileReader(); + explicit BankFileReader(const void* bankFile); + + void Initialize(const void* bankFile); + void Finalize(); + + bool ReadVelocityRegionInfo(VelocityRegionInfo* info, s32 programNo, + s32 key, s32 velocity) const; + + Util::WaveIdTable* GetWaveIdTable() const; + +private: + BankFile::FileHeader* m_pHeader; + BankFile::InfoBlockBody* m_pInfoBlockBody; + bool m_IsInitialized; +}; +static_assert(sizeof(BankFileReader) == 0x18); +} // namespace nn::atk::detail \ No newline at end of file From 0c2c2749cc67525fa8c3ee8fd68c92de77af2ef4 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 23 Feb 2026 13:53:42 -0300 Subject: [PATCH 050/785] atk: Define `detail::WaveArchiveFileReader` --- .../nn/atk/detail/atk_WaveArchiveFileReader.h | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/include/nn/atk/detail/atk_WaveArchiveFileReader.h b/include/nn/atk/detail/atk_WaveArchiveFileReader.h index e69de29b..0ab0a049 100644 --- a/include/nn/atk/detail/atk_WaveArchiveFileReader.h +++ b/include/nn/atk/detail/atk_WaveArchiveFileReader.h @@ -0,0 +1,40 @@ +#pragma once + +#include + +namespace nn::atk::detail { +class WaveArchiveFileReader { +public: + constexpr static s32 SignatureFile = 0x52415746; // FWAR + constexpr static s32 SignatureWarcTable = 0x54415746; //FWAT + + struct IndividualLoadTable { + void* waveFile[1]; + }; + + WaveArchiveFileReader(); + WaveArchiveFileReader(const void* pWaveArchiveFile, bool isIndividual); + + void Initialize(const void* pWaveArchiveFile, bool isIndividual); + + bool HasIndividualLoadTable() const; + + void Finalize(); + + void InitializeFileTable(); + + u32 GetWaveFileCount() const; + void* GetWaveFile(u32 waveIndex) const; + u32 GetWaveFileSize(u32 waveIndex) const; + u32 GetWaveFileOffsetFromFileHead(u32 waveIndex) const; + + void* SetWaveFile(u32 waveIndex, const void* pWaveFile); + +private: + WaveArchiveFile::FileHeader* m_pHeader; + WaveArchiveFile::InfoBlockBody* m_pInfoBlockBody; + IndividualLoadTable* m_pLoadTable; + bool m_IsInitialized; +}; +static_assert(sizeof(WaveArchiveFileReader) == 0x20); +} // namespace nn::atk::detail \ No newline at end of file From a32e43fd0738d3b1fc00d7190b4b232fc6479af0 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 23 Feb 2026 14:01:17 -0300 Subject: [PATCH 051/785] atk: Define `detail::driver::NoteOnInfo` and `detail::driver::NoteOnCallback` --- include/nn/atk/detail/atk_NoteOnCallback.h | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/include/nn/atk/detail/atk_NoteOnCallback.h b/include/nn/atk/detail/atk_NoteOnCallback.h index e69de29b..e4d53ebd 100644 --- a/include/nn/atk/detail/atk_NoteOnCallback.h +++ b/include/nn/atk/detail/atk_NoteOnCallback.h @@ -0,0 +1,25 @@ +#pragma once + +#include + +namespace nn::atk::detail::driver { +struct NoteOnInfo { + s32 prgNo; + s32 key; + s32 velocity; + s32 length; + s32 initPan; + s32 priority; + driver::Channel::ChannelCallback channelCallback; + void* channelCallbackData; + OutputReceiver* pOutputReceiver; + UpdateType updateType; +}; +static_assert(sizeof(NoteOnInfo) == 0x38); + +class NoteOnCallback { +public: + virtual ~NoteOnCallback(); +}; +static_assert(sizeof(NoteOnCallback) == 0x8); +} // namespace nn::atk::detail \ No newline at end of file From f1258624b4950188547f3cb50d2e5d22cb97c044 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 23 Feb 2026 14:03:55 -0300 Subject: [PATCH 052/785] atk: Define `detail::driver::Bank` --- include/nn/atk/detail/seq/atk_Bank.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/nn/atk/detail/seq/atk_Bank.h b/include/nn/atk/detail/seq/atk_Bank.h index e69de29b..d8e5a274 100644 --- a/include/nn/atk/detail/seq/atk_Bank.h +++ b/include/nn/atk/detail/seq/atk_Bank.h @@ -0,0 +1,19 @@ +#pragma once + +#include +#include +#include + +namespace nn::atk::detail::driver { +class Bank { +public: + Bank(); + ~Bank(); + + Channel* NoteOn(const BankFileReader& bankReader, + const WaveArchiveFileReader& warcReader, + const NoteOnInfo& noteOnInfo) const; + + static f32 CalcChannelVelocityVolume(u8 velocity); +}; +} // namespace nn::atk::detail::driver \ No newline at end of file From dd6ea0273d7fdde30a33b075dbead2d38aa3a5b5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 23 Feb 2026 16:45:44 -0300 Subject: [PATCH 053/785] atk: Define header `atk_BasicSound.h` --- include/nn/atk/atk_Global.h | 6 +- include/nn/atk/detail/atk_BasicSound.h | 412 ++++++++++++++++++++----- 2 files changed, 338 insertions(+), 80 deletions(-) diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h index dc22a4a7..d40f912c 100644 --- a/include/nn/atk/atk_Global.h +++ b/include/nn/atk/atk_Global.h @@ -414,9 +414,9 @@ namespace detail { static_assert(sizeof(WaveInfo) == 0xa0); } -// typedef -- SoundFrameUserCallback; -// typedef -- SoundThreadUserCallback; -// typedef -- SoundStopCallback; +using SoundFrameUserCallback = void(*)(std::uintptr_t); +using SoundThreadUserCallback = void(*)(std::uintptr_t); +using SoundStopCallback = void(*)(); diff --git a/include/nn/atk/detail/atk_BasicSound.h b/include/nn/atk/detail/atk_BasicSound.h index eb196477..5e50049e 100644 --- a/include/nn/atk/detail/atk_BasicSound.h +++ b/include/nn/atk/detail/atk_BasicSound.h @@ -1,31 +1,212 @@ -/** - * @file BasicSound.h - * @brief A basic sound. - */ - #pragma once -#include +#include +#include + +#include +#include +#include +#include -namespace nn { -namespace atk { +namespace nn::atk { class SoundActor; class SoundPlayer; +class SoundHandle; + +class OutputAmbientParam { +private: + f32 m_Volume; + f32 m_Pan; + f32 m_SurroundPan; + f32 m_FxSend[3]; +}; +static_assert(sizeof(OutputAmbientParam) == 0x18); -enum MixMode { +class SoundAmbientParam { +private: + f32 m_Volume; + f32 m_Pitch; + f32 m_Lpf; + f32 m_BiquadFilterValue; + s32 m_BiquadFilterType; + s32 m_Priority; + u32 m_UserData; + s32 m_OutputLineFlag; + OutputAmbientParam m_TvParam; +}; +static_assert(sizeof(SoundAmbientParam) == 0x38); +class SoundParam { +private: + f32 m_Volume; + f32 m_Pitch; + f32 m_Lpf; + f32 m_BiquadFilterValue; + s32 m_BiquadFilterType; + s32 m_Priority; + s32 m_OutputLineFlag; + u32 m_UserData; + OutputAmbientParam m_TvParam; +}; +static_assert(sizeof(SoundParam) == 0x38); + +struct SoundParamCalculationValues { + struct SoundArchiveParam { + f32 volume; + }; + static_assert(sizeof(SoundArchiveParam) == 0x4); + + struct SoundPlayerParam { + f32 volume; + f32 lpf; + s32 bqfType; + f32 bqfValue; + f32 outputVolume[1]; + f32 outputMainSend[1]; + f32 outputEffectSend[1][3]; + }; + + struct Sound3DParam { + f32 volume; + f32 pitch; + f32 lpf; + s32 bqfType; + f32 bqfValue; + u32 outputLineFlag; + f32 outputVolume[1]; + f32 outputPan[1]; + f32 outputSurroundPan[1]; + f32 outputEffectSend[1][3]; + s32 playerPriority; + }; + + struct SoundActorParam { + f32 volume; + f32 pitch; + f32 lpf; + f32 outputVolume[1]; + f32 outputPan[1]; + }; + + struct SoundHandleParam { + f32 volume; + f32 pitch; + f32 lpf; + s32 bqfType; + s32 bqfValue; + u32 outputLineFlag; + f32 outputVolume[1]; + f32 outputPan[1]; + f32 outputSurroundPan[1]; + f32 outputMainSend[1]; + f32 outputEffectSend[1][3]; + MixParameter outputMixParameter[1][2]; + MixMode mixMode; + f32 pan; + f32 surroundPan; + f32 mainSend; + f32 effectSend[3]; + s32 playerPriority; + }; + + struct ResultParam { + f32 volume; + f32 pitch; + f32 lpf; + s32 bqfType; + f32 bqfValue; + u32 outputLineFlag; + detail::OutputParam outputParamResult[1]; + s32 playerPriority; + }; + + struct FadeVolumeParam { + f32 stopFadeVolume; + f32 pauseFadeVolume; + f32 muteFadeVolume; + bool isMuted; + }; + + SoundArchiveParam soundArchiveParam; + SoundPlayerParam soundPlayerParam; + Sound3DParam sound3DParam; + SoundActorParam soundActorParam; + SoundHandleParam soundHandleParam; + ResultParam resultParam; + FadeVolumeParam fadeVolumeParam; }; namespace detail { class PlayerHeap; class ExternalSoundPlayer; +struct SoundActorParam { + f32 volume; + f32 pitch; + f32 tvVolume; + f32 tvPan; + f32 lpf; + s32 biquadFilterType; + f32 biquadFilterValue; +}; +static_assert(sizeof(SoundActorParam) == 0x1c); + class BasicSound { public: + enum State { + State_Constructed, + State_Initialized, + State_Finalized, + State_Destructed, + }; + + enum MuteState { + MuteState_Normal, + MuteState_Muting, + MuteState_Muted, + MuteState_Unmuting, + }; + + enum PauseState { + PauseState_Normal, + PauseState_Pausing, + PauseState_Paused, + PauseState_Unpausing, + }; + + enum PlayerState { + PlayerState_Init, + PlayerState_Play, + PlayerState_Stop, + }; + + struct AmbientParamUpdateCallback{}; + struct AmbientArgUpdateCallback{}; + struct AmbientArgAllocatorCallback{}; + + struct AmbientInfo { + AmbientParamUpdateCallback* paramUpdateCallback; + AmbientArgUpdateCallback* argUpdateCallback; + AmbientArgAllocatorCallback* argAllocatorCallback; + void* arg; + u64 argSize; + }; + static_assert(sizeof(AmbientInfo) == 0x28); + + struct CommonParam { + detail::MoveValue volume; + MixMode mixMode; + f32 pan; + f32 span; + f32 send[4]; + }; + static_assert(sizeof(CommonParam) == 0x2c); + BasicSound(); virtual ~BasicSound(); - virtual void Initialize(); + virtual bool Initialize(); + virtual bool Initialize(OutputReceiver* pOutputReceiver); virtual void Finalize(); virtual bool IsPrepared() const = 0; virtual bool IsAttachedTempSpecialHandle() = 0; @@ -34,104 +215,181 @@ class BasicSound { virtual void UpdateMoveValue(); virtual void OnUpdateParam(); - void SetPriority(s32, s32); - void GetPriority(s32*, s32*) const; + void SetPriority(s32 priority, s32 ambientPriority); + void GetPriority(s32* pPlayerAvailable, s32* pPriority) const; + void ClearIsFinalizedForCannotAllocatedResourceFlag(); - void SetId(u32 newID); + + void SetId(u32 id); + bool IsAttachedGeneralHandle(); void DetachGeneralHandle(); + bool IsAttachedTempGeneralHandle(); void DetachTempGeneralHandle(); + void StartPrepared(); - void Stop(s32); - void SetPlayerPriority(s32); + void Stop(s32 fadeFrames); + + void SetPlayerPriority(s32 priority); + void ForceStop(); void Pause(bool, s32); + void Pause(bool, s32, PauseMode pauseMode); void Mute(bool, s32); + void SetAutoStopCounter(s32); + void FadeIn(s32); + bool IsPause() const; bool IsMute() const; + void Update(); void UpdateParam(); - void CalculateVolume() const; + + f32 CalculateVolume() const; f32 CalculatePitch() const; f32 CalculateLpfFrequency() const; u32 CalculateOutLineFlag() const; - void CalculateBiquadFilter(s32*, f32*) const; - void AttachPlayerHeap(nn::atk::detail::PlayerHeap*); - void DetachPlayerHeap(nn::atk::detail::PlayerHeap*); - void AttachSoundPlayer(nn::atk::SoundPlayer*); - void DetachSoundPlayer(nn::atk::SoundPlayer*); - void AttachSoundActor(nn::atk::SoundActor*); - void DetachSoundActor(nn::atk::SoundActor*); - void AttachExternalSoundPlayer(nn::atk::detail::ExternalSoundPlayer*); - void DetachExternalSoundPlayer(nn::atk::detail::ExternalSoundPlayer*); + void CalculateBiquadFilter(s32* pBiquadFilterType, f32* pBiquadFilterValue) const; + void CalculateOutputParam(OutputParam*, OutputDevice) const; + + void ApplyCommonParam(OutputParam&) const; + + void AttachPlayerHeap(PlayerHeap* heap); + void DetachPlayerHeap(PlayerHeap* heap); + + void AttachSoundPlayer(SoundPlayer* player); + void DetachSoundPlayer(SoundPlayer* player); + + void AttachSoundActor(SoundActor* actor); + void DetachSoundActor(SoundActor* actor); + + void AttachExternalSoundPlayer(ExternalSoundPlayer* extPlayer); + void DetachExternalSoundPlayer(ExternalSoundPlayer* extPlayer); + u32 GetRemainingFadeFrames() const; u32 GetRemainingPauseFadeFrames() const; u32 GetRemainingMuteFadeFrames() const; - void SetInitialVolume(f32 vol); + + void CalculateSoundParamCalculationValues(SoundParamCalculationValues* pParamCalcValues) const; + + void SetInitialVolume(f32 volume); f32 GetInitialVolume() const; - void SetVolume(f32, s32); + + void SetVolume(f32 volume, s32 frames); s32 GetVolume() const; - void SetPitch(f32); + + void SetPitch(f32 pitch); f32 GetPitch() const; - void SetLpfFreq(f32); + + void SetLpfFreq(f32 lpf); f32 GetLpfFreq() const; - void SetBiquadFilter(s32, f32); + + void SetBiquadFilter(s32 biquadFilterType, f32 biquadFilterValue); void GetBiquadFilter(s32*, f32*) const; - void SetOutputLine(u32); + + void SetOutputLine(u32 outputLine); u32 GetOutputLine() const; void ResetOutputLine(); - void SetMixMode(nn::atk::MixMode); - nn::atk::MixMode GetMixMode(); - void SetPan(f32); + + void SetOutputAdditionalParamAddr(OutputDevice device, OutputAdditionalParam* addr, + OutputAdditionalParam* addrForPlayer); + + void SetMixMode(MixMode mode); + MixMode GetMixMode() const; + + void SetPan(f32 pan); f32 GetPan() const; - void SetSurroundPan(f32); + + void SetSurroundPan(f32 surroundPan); f32 GetSurroundPan() const; - void SetMainSend(f32); + + void SetMainSend(f32 mainSend); f32 GetMainSend() const; - u64* _8; // nn::atk::detail::PlayerHeap* - u64* _10; // nn::atk::SoundHandle* - u64* _18; // nn::atk::SoundHandle* - nn::atk::SoundPlayer* mSoundPlayer; // _20 - u64* _28; // nn::atk::SoundActor* - u64* _30; // nn::atk::detail::ExternalSoundPlayer* - u64* _38; // nn::atk::SoundArchive* - u8 _40[0xF0 - 0x40]; - s32 mPriority; // _F0 - u32 _F4; - u32 _F8; - s32 mAutoStopCounter; // _FC - u64 _100; - u32 mID; // _108 - u32 _10C; - u32 _110; - u32 _114; - f32 mInitialVolume; // _118 - f32 mPitch; // _11C - f32 mLpfFreq; // _120 - f32 _124; - u32 mOutputLine; // _128 - f32 _12C; - f32 mVolume; // _130 - u32 _134; - u32 _138; - nn::atk::MixMode mMixMode; // _13C - f32 mPan; // _140 - f32 mSurroundPan; // _144 - f32 mMainSend; // _148 - u8 _14C[0x158 - 0x14C]; - f32 mOutputVol; // _158 - u8 _15C[0x190 - 0x15C]; - f32 mOutputPan; // _190 - f32 mOutputSurroundPan; // _194 - f32 mOutputMainSend; // _198 - f32 mOutputFxSend; // _19C - - static u64 g_LastInstanceId; + void SetFxSend(AuxBus auxBus, f32 fxSend); + f32 GetFxSend(AuxBus auxBus) const; + + void SetOutputVolume(OutputDevice device, f32 volume); + void SetOutputChannelMixParameter(OutputDevice, u32, MixParameter); + void SetOutputPan(OutputDevice device, f32 pan); + void SetOutputSurroundPan(OutputDevice device, f32 surroundPan); + void SetOutputMainSend(OutputDevice device, f32 mainSend); + void SetOutputFxSend(OutputDevice device, f32 fxSend); + + f32 GetOutputVolume(OutputDevice device) const; + MixParameter GetOutputChannelMixParameter(OutputDevice, u32); + f32 GetOutputPan(OutputDevice device) const; + f32 GetOutputSurroundPan(OutputDevice device) const; + f32 GetOutputMainSend(OutputDevice device) const; + f32 GetOutputFxSend(OutputDevice device) const; + + void SetPanMode(PanMode mode); + void SetPanCurve(PanCurve curve); + void SetAmbientInfo(AmbientInfo* ambientArgInfo); + + PanMode GetPanMode() const; + PanCurve GetPanCurve() const; + AmbientInfo* GetAmbientInfo() const; + + static s32 GetAmbientPriority(const AmbientInfo& ambientInfo, u32 soundId); + + void SetSetupTick(const os::Tick& tick); + + void SetSoundArchive(const SoundArchive* soundArchive); + + PlayerHeap* m_pPlayerHeap; + SoundHandle* m_pGeneralHandle; + SoundHandle* m_pTempGeneralHandle; + SoundPlayer* m_pSoundPlayer; + SoundActor* m_pSoundActor; + ExternalSoundPlayer* m_pExtSoundPlayer; + SoundArchive* m_pSoundArchive; + AmbientInfo m_AmbientInfo; + SoundParam m_AmbientParam; + SoundActorParam m_ActorParam; + MoveValue m_FadeVolume; + MoveValue m_PauseFadeVolume; + MoveValue m_MuteFadeVolume; + bool m_StartFlag; + bool m_StartedFlag; + bool m_AutoStopFlag; + bool m_FadeOutFlag; + bool m_PlayerAvailableFlag; + bool m_UnPauseFlag; + PauseMode m_PauseMode; + u8 m_Priority; + s8 m_BiquadFilterType; + State m_State; + u8 m_PlayerState; + u8 m_PauseState; + u8 m_MuteState; + u8 m_Padding[1]; + s32 m_AutoStopCounter; + u32 m_UpdateCounter; + u32 m_PlayingCounter; + u32 m_Id; + u32 m_InstanceId; + os::Tick m_SetupTick; + f32 m_InitVolume; + f32 m_Pitch; + f32 m_LpfFreq; + f32 m_BiquadFilterValue; + u32 m_OutputLineFlag; + OutputReceiver* m_pOutputReceiver; + CommonParam m_CommonParam; + OutputParam m_OutputParam[1]; + OutputAdditionalParam* m_pOutputAdditionalParam; + void* m_pUserParam; + std::size_t m_UserParamSize; + SoundStopCallback m_SoundStopCallback; + util::IntrusiveListNode m_SoundPlayerPlayLink; + util::IntrusiveListNode m_SoundPlayerPriorityLink; + util::IntrusiveListNode m_ExtSoundPlayerPlayLink; + + static s32 g_LastInstanceId; }; } // namespace detail -} // namespace atk -} // namespace nn +} // namespace nn::atk From 20bc3011318c571e840229bfd6065751b508a5f9 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 23 Feb 2026 17:59:27 -0300 Subject: [PATCH 054/785] atk: Define `detail::PlayerHeap` and `detail::CallbackNode` --- include/nn/atk/atk_SoundMemoryAllocatable.h | 2 +- include/nn/atk/detail/atk_PlayerHeap.h | 51 +++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_SoundMemoryAllocatable.h b/include/nn/atk/atk_SoundMemoryAllocatable.h index 0d4b1e1a..8c1cde1e 100644 --- a/include/nn/atk/atk_SoundMemoryAllocatable.h +++ b/include/nn/atk/atk_SoundMemoryAllocatable.h @@ -10,6 +10,6 @@ class SoundMemoryAllocatable { virtual ~SoundMemoryAllocatable() = 0; virtual void* Allocate(size_t size) = 0; virtual void* Allocate(size_t size, DisposeCallback callback, void* callbackArg) = 0; - virtual void* GetAllocateSize(size_t size, bool needMemoryPool) = 0; + virtual std::size_t GetAllocateSize(size_t size, bool needMemoryPool) = 0; }; } // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/detail/atk_PlayerHeap.h b/include/nn/atk/detail/atk_PlayerHeap.h index e69de29b..079b57cc 100644 --- a/include/nn/atk/detail/atk_PlayerHeap.h +++ b/include/nn/atk/detail/atk_PlayerHeap.h @@ -0,0 +1,51 @@ +#pragma once + +#include + +#include + +namespace nn::atk::detail { +class PlayerHeap; +class SoundPlayer; + +class CallbackNode { +private: + friend PlayerHeap; + + util::IntrusiveListNode m_Link; + SoundMemoryAllocatable::DisposeCallback m_Callback; + void* m_CallbackArg; +}; +static_assert(sizeof(CallbackNode) == 0x20); + +class PlayerHeap : SoundMemoryAllocatable { +public: + using CallbackList = util::IntrusiveList< + CallbackNode, util::IntrusiveListMemberNodeTraits< + CallbackNode, &CallbackNode::m_Link>>; + + PlayerHeap(); + ~PlayerHeap() override; + + bool Create(void* startAddress, std::size_t size); + void Clear(); + + void* Allocate(std::size_t size) override; + void* Allocate(std::size_t size, + SoundMemoryAllocatable::DisposeCallback callback, void* callbackArg) override; + + std::size_t GetAllocateSize(std::size_t size, bool needMemoryPool) override; + std::size_t GetFreeSize() const; + +private: + SoundPlayer* m_pPlayer; + void* m_pStartAddress; + void* m_pEndAddress; + void* m_pAllocAddress; + u8 m_State; + u8 m_Padding[3]; + util::IntrusiveListNode m_Link; + CallbackList m_CallbackList; +}; +static_assert(sizeof(PlayerHeap) == 0x50); +} // namespace nn::atk::detail \ No newline at end of file From 3f0638f23f3c894610b5cce8e46808670aee7deb Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 23 Feb 2026 22:06:17 -0300 Subject: [PATCH 055/785] atk: Define `SoundHandle` --- include/nn/atk/atk_SoundHandle.h | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/include/nn/atk/atk_SoundHandle.h b/include/nn/atk/atk_SoundHandle.h index e69de29b..de85296c 100644 --- a/include/nn/atk/atk_SoundHandle.h +++ b/include/nn/atk/atk_SoundHandle.h @@ -0,0 +1,39 @@ +#pragma once + +#include + +namespace nn::atk { +class SoundHandle { +public: + enum MuteState { + MuteState_Normal, + MuteState_Muting, + MuteState_Muted, + MuteState_Unmuting, + MuteState_Invalid, + }; + + enum PauseState { + PauseState_Normal, + PauseState_Pausing, + PauseState_Paused, + PauseState_Unpausing, + PauseState_Invalid + }; + + ~SoundHandle() = default; + + void DetachSound(); + + void detail_DuplicateHandle(SoundHandle* other); + + void detail_AttachSound(detail::BasicSound* sound); + void detail_AttachSoundAsTempHandle(detail::BasicSound* sound); + + void CalculateSoundParamCalculationValues(SoundParamCalculationValues* calcValues) const; + +private: + detail::BasicSound* m_pSound; +}; +static_assert(sizeof(SoundHandle) == 0x8); +} // namespace nn::atk \ No newline at end of file From 956b578d686c5eef53ae954791f1e14f49ebebf6 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 23 Feb 2026 22:43:34 -0300 Subject: [PATCH 056/785] atk: Define `SoundPlayer` --- include/nn/atk/atk_SoundPlayer.h | 111 ++++++++++++++++--------- include/nn/atk/detail/atk_PlayerHeap.h | 10 ++- 2 files changed, 80 insertions(+), 41 deletions(-) diff --git a/include/nn/atk/atk_SoundPlayer.h b/include/nn/atk/atk_SoundPlayer.h index 3711c774..ad2c0d03 100644 --- a/include/nn/atk/atk_SoundPlayer.h +++ b/include/nn/atk/atk_SoundPlayer.h @@ -1,56 +1,91 @@ -/** - * @file SoundPlayer.h - * @brief Sound player. - */ - #pragma once -#include - -namespace nn { -namespace atk { -enum PauseMode { +#include +#include -}; +#include +#include +#include +namespace nn::atk { class SoundPlayer { public: + using SoundList = util::IntrusiveList< + detail::BasicSound, util::IntrusiveListMemberNodeTraits< + detail::BasicSound, &detail::BasicSound::m_SoundPlayerPlayLink>>; + using PriorityList = util::IntrusiveList< + detail::BasicSound, util::IntrusiveListMemberNodeTraits< + detail::BasicSound, &detail::BasicSound::m_SoundPlayerPriorityLink>>; + using PlayerHeapList = util::IntrusiveList< + detail::PlayerHeap, util::IntrusiveListMemberNodeTraits< + detail::PlayerHeap, &detail::PlayerHeap::m_Link>>; + struct OutputParam { + f32 volume; + f32 mainSend; + f32 fxSend[3]; + }; + static_assert(sizeof(OutputParam) == 0x14); + SoundPlayer(); + explicit SoundPlayer(detail::OutputAdditionalParam* pParam); ~SoundPlayer(); - void StopAllSound(s32); + void StopAllSound(s32 fadeFrames); + void Update(); + void DoFreePlayerHeap(); - void detail_SortPriorityList(bool); + + void detail_SortPriorityList(bool reverse); + + f32 GetSend(s32 subMixBus); + void PauseAllSound(s32, bool); - void PauseAllSound(bool, s32, nn::atk::PauseMode); - void SetVolume(f32 vol); - void SetLowPassFilterFrequency(f32 filterFreq); - void SetBiquadFilter(s32 filterType, f32 baseFreq); + void PauseAllSound(bool, s32, PauseMode); + + void SetVolume(f32 volume); + void SetLowPassFilterFrequency(f32 lpfFreq); + void SetBiquadFilter(s32 biquadFilterType, f32 biquadFilterValue); void SetDefaultOutputLine(u32 line); + void SetOutputVolume(OutputDevice device, f32 volume); + + void RemoveSoundList(detail::BasicSound* pSound); + + void InsertPriorityList(detail::BasicSound* pSound); + void RemovePriorityList(detail::BasicSound* pSound); + + void detail_SortPriorityList(detail::BasicSound* pSound); + + bool detail_AppendSound(detail::BasicSound* pSound); + bool detail_RemoveSound(detail::BasicSound* pSound); + + void SetPlayableSoundCount(s32 count); void detail_SetPlayableSoundLimit(s32 limit); + + bool detail_CanPlaySound(s32 startPriority); bool CanPlaySound(s32); - u64 _0; - u64 _8; - u64 _10; - u64 _18; - u64 _20; - u64 _28; - u64 _30; - u64 _38; - s32 _40; - s32 mPlayableSoundCount; // _44 - s32 _48; - f32 mVolume; // _4C - f32 mLowPassFreq; // _50 - s32 mFilterType; // _54 - f32 mBaseFreq; // _58 - u32 mDefaultOutputLine; // _5C - f32 mOutputVolume; // _60 - u64 _64; - u64 _6C; + void detail_AppendPlayerHeap(detail::PlayerHeap* pHeap); + detail::PlayerHeap* detail_AllocPlayerHeap(); + void detail_FreePlayerHeap(detail::PlayerHeap* pHeap); + +private: + SoundList m_SoundList; + PriorityList m_PriorityList; + PlayerHeapList m_PlayerHeapFreeList; + PlayerHeapList m_PlayerHeapFreeReqList; + s32 m_PlayableCount; + s32 m_PlayableLimit; + u32 m_PlayerHeapCount; + f32 m_Volume; + f32 m_LpfFreq; + s32 m_BiquadType; + f32 m_BiquadValue; + u32 m_OutputLineFlag; + OutputParam m_TvParam; + detail::OutputAdditionalParam* m_pOutputAdditionalParam; + bool m_IsFirstComeBased; }; -} // namespace atk -} // namespace nn +static_assert(sizeof(SoundPlayer) == 0x88); +} // namespace nn::atk diff --git a/include/nn/atk/detail/atk_PlayerHeap.h b/include/nn/atk/detail/atk_PlayerHeap.h index 079b57cc..dcea5c80 100644 --- a/include/nn/atk/detail/atk_PlayerHeap.h +++ b/include/nn/atk/detail/atk_PlayerHeap.h @@ -4,10 +4,11 @@ #include -namespace nn::atk::detail { -class PlayerHeap; +namespace nn::atk { class SoundPlayer; +namespace detail { +class PlayerHeap; class CallbackNode { private: friend PlayerHeap; @@ -38,6 +39,8 @@ class PlayerHeap : SoundMemoryAllocatable { std::size_t GetFreeSize() const; private: + friend SoundPlayer; + SoundPlayer* m_pPlayer; void* m_pStartAddress; void* m_pEndAddress; @@ -48,4 +51,5 @@ class PlayerHeap : SoundMemoryAllocatable { CallbackList m_CallbackList; }; static_assert(sizeof(PlayerHeap) == 0x50); -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail +} // namespace nn::atk \ No newline at end of file From 7520e88bd62d132f7d0d4c28470db11cc9cb5c0a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 23 Feb 2026 23:03:42 -0300 Subject: [PATCH 057/785] atk: Define `detail::ExternalSoundPlayer` --- .../nn/atk/detail/atk_ExternalSoundPlayer.h | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/include/nn/atk/detail/atk_ExternalSoundPlayer.h b/include/nn/atk/detail/atk_ExternalSoundPlayer.h index e69de29b..530c3977 100644 --- a/include/nn/atk/detail/atk_ExternalSoundPlayer.h +++ b/include/nn/atk/detail/atk_ExternalSoundPlayer.h @@ -0,0 +1,37 @@ +#pragma once + +#include + +#include + +namespace nn::atk::detail { +class ExternalSoundPlayer { +public: + using SoundList = util::IntrusiveList< + BasicSound, util::IntrusiveListMemberNodeTraits< + BasicSound, &BasicSound::m_ExtSoundPlayerPlayLink>>; + + virtual ~ExternalSoundPlayer(); + virtual bool CanPlaySound(s32); + + ExternalSoundPlayer(); + + void StopAllSound(s32 fadeFrames); + void PauseAllSound(bool, s32); + void PauseAllSound(bool, s32, PauseMode); + + void Finalize(SoundActor* actor); + + void RemoveSound(BasicSound* sound); + bool AppendSound(BasicSound* sound); + + BasicSound* GetLowestPrioritySound(); + + void SetPlayableSoundCount(s32 count); + +private: + SoundList m_SoundList; + s32 m_PlayableCount; +}; +static_assert(sizeof(ExternalSoundPlayer) == 0x20); +} // namespace nn::atk::detail \ No newline at end of file From 39948e389fd9f5b3767c073daaf28c13b948970e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 23 Feb 2026 23:04:41 -0300 Subject: [PATCH 058/785] atk: Define `detail::SoundActor` --- include/nn/atk/atk_SoundActor.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/nn/atk/atk_SoundActor.h b/include/nn/atk/atk_SoundActor.h index e69de29b..8700089e 100644 --- a/include/nn/atk/atk_SoundActor.h +++ b/include/nn/atk/atk_SoundActor.h @@ -0,0 +1,10 @@ +#pragma once + +#include + +namespace nn::atk { +class SoundActor { +public: + using ActorPlayer = detail::ExternalSoundPlayer; +}; +} // namespace nn::atk \ No newline at end of file From b1a45a39de2e3a3e0a168d4d593d22b5306aefd3 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 24 Feb 2026 10:17:08 -0300 Subject: [PATCH 059/785] audio: Define `AuxType` --- include/nn/audio/audio_EffectTypes.h | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 include/nn/audio/audio_EffectTypes.h diff --git a/include/nn/audio/audio_EffectTypes.h b/include/nn/audio/audio_EffectTypes.h new file mode 100644 index 00000000..f1cf46fe --- /dev/null +++ b/include/nn/audio/audio_EffectTypes.h @@ -0,0 +1,9 @@ +#pragma once + +namespace nn::audio { +struct EffectInfo {}; + +struct AuxType { + EffectInfo* _pEffectInfo; +}; +} // namespace nn::audio \ No newline at end of file From 57447ec82a5d0f8e2631c40dd7fd5282905b32d4 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 24 Feb 2026 10:17:35 -0300 Subject: [PATCH 060/785] audio: Define AudioRenderer types --- include/nn/audio/audio_AudioRendererTypes.h | 57 +++++++++++++++++++++ include/nn/audio/audio_Common.h | 9 ++++ 2 files changed, 66 insertions(+) create mode 100644 include/nn/audio/audio_AudioRendererTypes.h diff --git a/include/nn/audio/audio_AudioRendererTypes.h b/include/nn/audio/audio_AudioRendererTypes.h new file mode 100644 index 00000000..964c3a3b --- /dev/null +++ b/include/nn/audio/audio_AudioRendererTypes.h @@ -0,0 +1,57 @@ +#pragma once + +#include + +namespace nn::audio { +enum AudioRendererRenderingDevice { + AudioRendererRenderingDevice_AudioCoprocessor, + AudioRendererRenderingDevice_Cpu, +}; + +enum AudioRendererExecutionMode { + AudioRendererExecutionMode_AutoExecution, + AudioRendererExecutionMode_ManualExecution, +}; + +struct AudioRendererParameter { + s32 sampleRate; + s32 sampleCount; + s32 mixBufferCount; + s32 subMixCount; + s32 voiceCount; + s32 sinkCount; + s32 effectCount; + s32 performanceFrameCount; + bool isVoiceDropEnabled; + s32 splitterCount; + s32 splitterSendChannelCount; + AudioRendererRenderingDevice renderingDevice; + AudioRendererExecutionMode executionMode; + u32 _magic; +}; +static_assert(sizeof(AudioRendererParameter) == 0x38); + +struct AudioRendererConfig { + VoiceInfoManager* _pVoiceInfoManager; + MixManager* _pMixManager; + EffectManager* _pEffectManager; + SinkManager* _pSinkManager; + PerformanceBufferManager* _pPerformanceBufferManager; + MemoryPoolManager* _pMemoryPoolManager; + BehaviorManager* _pBehaviorManager; + SplitterInfoManager* _pSplitterInfoManager; + void* _pInParameter; + std::size_t _pInParameterSize; + void* _pOutStatus; + std::size_t _pOutStatusSize; + void* _pConfigBuffer; + std::size_t _configBufferSize; +}; +static_assert(sizeof(AudioRendererConfig) == 0x70); + +struct AudioRendererHandle { + void* _handle; + void* _context; +}; +static_assert(sizeof(AudioRendererHandle) == 0x10); +} // namespace nn::audio \ No newline at end of file diff --git a/include/nn/audio/audio_Common.h b/include/nn/audio/audio_Common.h index dfcc5018..aa9c002e 100644 --- a/include/nn/audio/audio_Common.h +++ b/include/nn/audio/audio_Common.h @@ -4,4 +4,13 @@ namespace nn::audio { using NodeId = uint32_t; + +class VoiceInfoManager {}; +class MixManager {}; +class EffectManager {}; +class SinkManager {}; +class PerformanceBufferManager {}; +class MemoryPoolManager {}; +class BehaviorManager {}; +class SplitterInfoManager {}; } // namespace nn::audio \ No newline at end of file From 5c126d358c44c5985c5f8d36e8993c1b96fc5275 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 24 Feb 2026 10:19:25 -0300 Subject: [PATCH 061/785] audio: Add files to CMakeLists --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f8072cf1..dcd9c0af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,7 +232,9 @@ add_library(NintendoSDK OBJECT include/nn/mem.h include/nn/audio/audio_Adpcm.h + include/nn/audio/audio_AudioRendererTypes.h include/nn/audio/audio_Common.h + include/nn/audio/audio_EffectTypes.h include/nn/audio/audio_VoiceTypes.h include/nn/atk/atk_Adpcm.h From e4e0148ebf259193426bde5ffe95fa98362434ed Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 24 Feb 2026 10:30:32 -0300 Subject: [PATCH 062/785] audio: Add `audio_FinalMixTypes.h` --- CMakeLists.txt | 1 + include/nn/audio/audio_FinalMixTypes.h | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 include/nn/audio/audio_FinalMixTypes.h diff --git a/CMakeLists.txt b/CMakeLists.txt index dcd9c0af..cfbaa668 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -235,6 +235,7 @@ add_library(NintendoSDK OBJECT include/nn/audio/audio_AudioRendererTypes.h include/nn/audio/audio_Common.h include/nn/audio/audio_EffectTypes.h + include/nn/audio/audio_FinalMixTypes.h include/nn/audio/audio_VoiceTypes.h include/nn/atk/atk_Adpcm.h diff --git a/include/nn/audio/audio_FinalMixTypes.h b/include/nn/audio/audio_FinalMixTypes.h new file mode 100644 index 00000000..c09cc11b --- /dev/null +++ b/include/nn/audio/audio_FinalMixTypes.h @@ -0,0 +1,9 @@ +#pragma once + +namespace nn::audio { +struct MixInfo {}; + +struct FinalMixType { + MixInfo* _pMixInfo; +}; +} // namespace nn::audio \ No newline at end of file From bd7aec07d0f0b38045674607a5915f03e4c50aaf Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 24 Feb 2026 10:37:40 -0300 Subject: [PATCH 063/785] audio: Add `audio_SubMixTypes.h` Also moved some structs to `audio_Common.h` --- CMakeLists.txt | 1 + include/nn/audio/audio_Common.h | 3 +++ include/nn/audio/audio_EffectTypes.h | 4 ++-- include/nn/audio/audio_FinalMixTypes.h | 4 ++-- include/nn/audio/audio_SubMixTypes.h | 9 +++++++++ 5 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 include/nn/audio/audio_SubMixTypes.h diff --git a/CMakeLists.txt b/CMakeLists.txt index cfbaa668..0fad8d16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -236,6 +236,7 @@ add_library(NintendoSDK OBJECT include/nn/audio/audio_Common.h include/nn/audio/audio_EffectTypes.h include/nn/audio/audio_FinalMixTypes.h + include/nn/audio/audio_SubMixTypes.h include/nn/audio/audio_VoiceTypes.h include/nn/atk/atk_Adpcm.h diff --git a/include/nn/audio/audio_Common.h b/include/nn/audio/audio_Common.h index aa9c002e..fcd8a963 100644 --- a/include/nn/audio/audio_Common.h +++ b/include/nn/audio/audio_Common.h @@ -5,6 +5,9 @@ namespace nn::audio { using NodeId = uint32_t; +struct EffectInfo {}; +struct MixInfo {}; + class VoiceInfoManager {}; class MixManager {}; class EffectManager {}; diff --git a/include/nn/audio/audio_EffectTypes.h b/include/nn/audio/audio_EffectTypes.h index f1cf46fe..31d0c147 100644 --- a/include/nn/audio/audio_EffectTypes.h +++ b/include/nn/audio/audio_EffectTypes.h @@ -1,8 +1,8 @@ #pragma once -namespace nn::audio { -struct EffectInfo {}; +#include +namespace nn::audio { struct AuxType { EffectInfo* _pEffectInfo; }; diff --git a/include/nn/audio/audio_FinalMixTypes.h b/include/nn/audio/audio_FinalMixTypes.h index c09cc11b..08434bee 100644 --- a/include/nn/audio/audio_FinalMixTypes.h +++ b/include/nn/audio/audio_FinalMixTypes.h @@ -1,8 +1,8 @@ #pragma once -namespace nn::audio { -struct MixInfo {}; +#include +namespace nn::audio { struct FinalMixType { MixInfo* _pMixInfo; }; diff --git a/include/nn/audio/audio_SubMixTypes.h b/include/nn/audio/audio_SubMixTypes.h new file mode 100644 index 00000000..69faf8ee --- /dev/null +++ b/include/nn/audio/audio_SubMixTypes.h @@ -0,0 +1,9 @@ +#pragma once + +#include + +namespace nn::audio { +struct SubMixType { + MixInfo* _pMixInfo; +}; +} // namespace nn::audio \ No newline at end of file From 580fc910ecb1286e355274f30e7399eb56e4cf89 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 24 Feb 2026 10:47:50 -0300 Subject: [PATCH 064/785] atk: Define `EffectAux` --- include/nn/atk/effect/atk_EffectAux.h | 101 ++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/include/nn/atk/effect/atk_EffectAux.h b/include/nn/atk/effect/atk_EffectAux.h index e69de29b..e1fc7d25 100644 --- a/include/nn/atk/effect/atk_EffectAux.h +++ b/include/nn/atk/effect/atk_EffectAux.h @@ -0,0 +1,101 @@ +#pragma once + +#include + +#include +#include +#include +#include +#include + +#include + +namespace nn::atk { +class OutputMixer; + +class EffectAux { +public: + constexpr static s32 ChannelCountMax = 6; + + struct BufferSet { + void* sendBuffer; + void* returnBuffer; + void* readBuffer; + }; + static_assert(sizeof(BufferSet) == 0x18); + + struct UpdateSamplesArg { + s32 sampleCountPerAudioFrame; + s32 sampleRate; + s32 audioFrameCount; + s32 channelCount; + s32 readSampleCount; + OutputMode outputMode; + }; + static_assert(sizeof(UpdateSamplesArg) == 0x18); + + EffectAux(); + virtual ~EffectAux(); + virtual void Initialize(); + virtual void Finalize(); + virtual void OnChangeOutputMode(); + virtual void UpdateSamples(s32, const UpdateSamplesArg&); + + void ResetChannelIndex(); + + std::size_t GetRequiredMemSize(const audio::AudioRendererParameter& parameter) const; + + bool AddEffect(audio::AudioRendererConfig* pConfig, + const audio::AudioRendererParameter& parameter, + OutputMixer* pOutputMixer); + + bool AddEffect(audio::AudioRendererConfig* pConfig, + const audio::AudioRendererParameter& parameter, + audio::FinalMixType* pFinalMixType); + + void SplitEffectBuffer(BufferSet* pBufferSet, void* effectBuffer, + std::size_t effectBufferSize); + + bool AddEffect(audio::AudioRendererConfig* pConfig, + const audio::AudioRendererParameter& parameter, + audio::SubMixType* pSubMixType); + + void SetEffectInputOutput(const s8* input, const s8* output, s32 inputCount, s32 outputCount); + + void RemoveEffect(audio::AudioRendererConfig* pConfig, OutputMixer* pOutputMixer); + void RemoveEffect(audio::AudioRendererConfig* pConfig, audio::FinalMixType* pFinalMixType); + void RemoveEffect(audio::AudioRendererConfig* pConfig, audio::SubMixType* pSubMixType); + + bool SetChannelCount(s32 channelCount); + bool SetChannelIndex(ChannelIndex* pChannel, s32 channelCount); + + s32 GetChannelCount() const; + void GetChannelIndex(ChannelIndex* pChannel, s32 channelCount) const; + + bool SetAudioFrameCount(s32 audioFrameCount); + s32 GetAudioFrameCount() const; + + bool IsRemovable() const; + bool IsClearable(); + bool IsEnabled() const; + + void SetEnabled(bool isEnabled); + void SetEffectBuffer(void* effectBuffer, std::size_t effectBufferSize); + + void Update(); + +private: + util::IntrusiveListNode m_AuxLinkNode; + audio::AuxType m_AuxType; + std::atomic_uint64_t m_AudioRendererUpdateCountWhenAddedAux; + s32 m_AudioFrameCount; + s32 m_ChannelCount; + bool m_IsActive; + bool m_IsEnabled; + void* m_EffectBuffer; + std::size_t m_EffectBufferSize; + s32* m_AuxReadBuffer; + ChannelIndex m_ChannelSetting[ChannelCountMax]; +}; +static_assert(sizeof(EffectAux) == 0x50 + sizeof(ChannelIndex) * EffectAux::ChannelCountMax); +} // namespace nn::atk \ No newline at end of file From d158d6cd234838b4a7c7990af3a25a5c7ecba5e2 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 24 Feb 2026 19:46:31 -0300 Subject: [PATCH 065/785] atk: Define `EffectBase` --- include/nn/atk/effect/atk_EffectBase.h | 64 ++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/include/nn/atk/effect/atk_EffectBase.h b/include/nn/atk/effect/atk_EffectBase.h index e69de29b..d1b05398 100644 --- a/include/nn/atk/effect/atk_EffectBase.h +++ b/include/nn/atk/effect/atk_EffectBase.h @@ -0,0 +1,64 @@ +#pragma once + +#include +#include +#include +#include + +#include + +namespace nn::atk { +class EffectBase { +public: + enum ChannelMode { + ChannelMode_1Ch, + ChannelMode_2Ch, + ChannelMode_4Ch, + ChannelMode_6Ch, + }; + + enum SampleRate { + SampleRate_32000, + SampleRate_48000, + }; + + constexpr static u8 ChannelModeCountMax = 6; + + EffectBase(); + + virtual ~EffectBase(); + virtual void unk1() = 0; + virtual void unk2() = 0; + virtual void unk3() = 0; + virtual void unk4() = 0; + virtual void unk5() = 0; + virtual void unk6() = 0; + virtual void unk7() = 0; + virtual void UpdateBuffer(s32, void**, std::size_t, SampleFormat, s32, OutputMode); + virtual void GetChannelIndex(ChannelIndex* pChannel, s32 channelCount) const; + virtual s32 GetChannelSettingCountMax() const; + virtual void OnChangeOutputMode(); + virtual void SetEffectBuffer(void* effectBuffer, std::size_t effectBufferSize); + + bool AddEffect(audio::AudioRendererConfig* pConfig, audio::FinalMixType* pFinalMixType); + bool AddEffect(audio::AudioRendererConfig* pConfig, audio::SubMixType* pFinalMixType); + + void SetEffectInputOutput(const s8* input, const s8* output, s32 inputCount, s32 outputCount); + + void RemoveEffect(audio::AudioRendererConfig* pConfig, audio::FinalMixType* pFinalMixType); + void RemoveEffect(audio::AudioRendererConfig* pConfig, audio::SubMixType* pSubMixType); + + static s32 ConvertChannelModeToInt(ChannelMode channelMode); + + SampleRate GetSampleRate() const; + bool SetSampleRate(SampleRate sampleRate); + +private: + util::IntrusiveListNode m_Link; + bool m_IsActive; + SampleRate m_SampleRate; + void* m_EffectBuffer; + std::size_t m_EffectBufferSize; +}; +static_assert(sizeof(EffectBase) == 0x30); +} // namespace nn::atk \ No newline at end of file From e3265e7f324da93612d83edb90ccbb5dc2ac5fcf Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 24 Feb 2026 20:10:04 -0300 Subject: [PATCH 066/785] atk: Define `detail::fnd::FileStreamProxy` --- include/nn/atk/fnd/io/atkfnd_FileStream.h | 16 ++++++ include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h | 25 +++++---- .../nn/atk/fnd/io/atkfnd_FileStreamProxy.h | 51 +++++++++++++++++++ include/nn/atk/fnd/io/atkfnd_Stream.h | 2 +- 4 files changed, 80 insertions(+), 14 deletions(-) diff --git a/include/nn/atk/fnd/io/atkfnd_FileStream.h b/include/nn/atk/fnd/io/atkfnd_FileStream.h index 608aa271..7a91f274 100644 --- a/include/nn/atk/fnd/io/atkfnd_FileStream.h +++ b/include/nn/atk/fnd/io/atkfnd_FileStream.h @@ -1,6 +1,7 @@ #pragma once #include +#include namespace nn::atk::detail::fnd { class FileStream : Stream { @@ -14,6 +15,21 @@ class FileStream : Stream { AccessMode_AllowAppendAndWrite = 6, }; + virtual FndResult Open(const char* filePath, AccessMode openMode); + virtual void Flush(); + + virtual void EnableCache(void* buffer, std::size_t length); + virtual void DisableCache(); + virtual bool IsCacheEnabled() const; + + virtual s32 GetIoBufferAlignment() const; + + virtual bool CanSetFsAccessLog() const; + virtual void* SetFsAccessLog(FsAccessLog* pFsAccessLog); + + virtual position_t GetCachePosition(); + virtual std::size_t GetCachedLength(); + ~FileStream() override; }; static_assert(sizeof(FileStream) == 0x8); diff --git a/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h b/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h index b2f0d022..7a9502bc 100644 --- a/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h +++ b/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h @@ -3,7 +3,6 @@ #include #include -#include namespace nn::atk::detail::fnd { class FileStreamImpl : FileStream { @@ -16,7 +15,7 @@ class FileStreamImpl : FileStream { bool IsOpened() const override; std::size_t Read(void* buf, std::size_t length, FndResult* result) override; - std::size_t Write(void* buf, std::size_t length, FndResult* result) override; + std::size_t Write(const void* buf, std::size_t length, FndResult* result) override; FndResult Seek(position_t offset, SeekOrigin origin) override; position_t GetCurrentPosition() const override; @@ -35,7 +34,7 @@ class FileStreamImpl : FileStream { ~FileStreamImpl() override; std::size_t Read(void* buf, std::size_t length, FndResult* result) override; - std::size_t Write(void* buf, std::size_t length, FndResult* result) override; + std::size_t Write(const void* buf, std::size_t length, FndResult* result) override; FndResult Seek(position_t offset, fnd::Stream::SeekOrigin origin) override; bool CanRead() const override; @@ -44,7 +43,7 @@ class FileStreamImpl : FileStream { void ValidateAlignment(void* buf); - FndResult Open(char* filePath, AccessMode accessMode); + FndResult Open(const char* filePath, AccessMode accessMode) override; void Close() override; bool IsOpened() const override; @@ -56,19 +55,19 @@ class FileStreamImpl : FileStream { std::size_t WriteDirect(void* buf, std::size_t length, FndResult* result); FndResult SeekDirect(position_t offset, fnd::Stream::SeekOrigin origin); - virtual void Flush(); + void Flush() override; - virtual void EnableCache(void* buffer, std::size_t length); - virtual void DisableCache(); - virtual bool IsCacheEnabled(); + void EnableCache(void* buffer, std::size_t length) override; + void DisableCache() override; + bool IsCacheEnabled() const override; - virtual s32 GetIoBufferAlignment(); + s32 GetIoBufferAlignment() const override; - virtual bool CanSetFsAccessLog(); - virtual void* SetFsAccessLog(FsAccessLog* pFsAccessLog); + bool CanSetFsAccessLog() const override; + void* SetFsAccessLog(FsAccessLog* pFsAccessLog) override; - virtual position_t GetCachePosition(); - virtual std::size_t GetCachedLength(); + position_t GetCachePosition() override; + std::size_t GetCachedLength() override; private: fs::FileHandle m_FileHandle; diff --git a/include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h b/include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h index e69de29b..6c0d2eb0 100644 --- a/include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h +++ b/include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h @@ -0,0 +1,51 @@ +#pragma once + +#include + +namespace nn::atk::detail::fnd { +class FileStreamProxy : FileStream { +public: + FileStreamProxy(const FileStream& fileStream, + position_t offset, std::size_t fileSize); + + ~FileStreamProxy() override; + + FndResult Open(const char* filePath, AccessMode openMode) override; + void Close() override; + void Flush() override; + + bool IsOpened() const override; + + bool CanRead() const override; + bool CanWrite() const override; + bool CanSeek() const override; + + std::size_t GetSize() const override; + + std::size_t Read(void* buffer, std::size_t length, FndResult* result) override; + std::size_t Write(const void* buffer, std::size_t length, FndResult* result) override; + FndResult Seek(position_t offset, fnd::Stream::SeekOrigin origin) override; + + position_t GetCurrentPosition() const override; + + void EnableCache(void* buffer, std::size_t length) override; + void DisableCache() override; + bool IsCacheEnabled() const override; + + s32 GetIoBufferAlignment() const override; + + bool CanSetFsAccessLog() const override; + + void* SetFsAccessLog(FsAccessLog* pFsAccessLog) override; + + position_t GetCachePosition() override; + + std::size_t GetCachedLength() override; + +private: + FileStream* m_pFileStream; + position_t m_Offset; + std::size_t m_FileSize; +}; +static_assert(sizeof(FileStreamProxy) == 0x20); +} // namespace nn::atk::detail::fnd \ No newline at end of file diff --git a/include/nn/atk/fnd/io/atkfnd_Stream.h b/include/nn/atk/fnd/io/atkfnd_Stream.h index fb357003..179b375f 100644 --- a/include/nn/atk/fnd/io/atkfnd_Stream.h +++ b/include/nn/atk/fnd/io/atkfnd_Stream.h @@ -20,7 +20,7 @@ class Stream { virtual bool IsOpened() const = 0; virtual std::size_t Read(void* buf, std::size_t length, FndResult* result) = 0; - virtual std::size_t Write(void* buf, std::size_t length, FndResult* result) = 0; + virtual std::size_t Write(const void* buf, std::size_t length, FndResult* result) = 0; virtual FndResult Seek(position_t offset, SeekOrigin origin) = 0; virtual position_t GetCurrentPosition() const = 0; From 3d90e9e38435cec385e84f211215f3084f162089 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 25 Feb 2026 12:35:26 -0300 Subject: [PATCH 067/785] atk: Define `detail::AddonSoundArchiveContainer` --- .../detail/atk_AddonSoundArchiveContainer.h | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h b/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h index e69de29b..24fe6d57 100644 --- a/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h +++ b/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h @@ -0,0 +1,40 @@ +#pragma once + +#include +#include +#include + +#include +#include + +namespace nn::atk { +class AddonSoundArchive; + +namespace detail { +class AddonSoundArchiveContainer { +public: + AddonSoundArchiveContainer(); + ~AddonSoundArchiveContainer(); + + bool Initialize(const char* name, + const AddonSoundArchive* pAddonSoundArchive, + const SoundDataManager* pSoundDataManager); + + void Finalize(); + + bool IsSameName(const char* name) const; + + void SetAddTick(const os::Tick& addTick); + +private: + util::IntrusiveListNode m_ElementLink; + bool m_IsActive; + u8 m_Padding[3]; + SoundArchive* m_pSoundArchive; + SoundDataManager* m_pSoundDataManager; + char m_SoundArchiveName[64]; + os::Tick m_AddTick; +}; +static_assert(sizeof(AddonSoundArchiveContainer) == 0x70); +} // namespace nn::atk::detail +} // namespace nn::atk \ No newline at end of file From 7757583f7adf636764baddebe5b77a6a9a7e3b14 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 25 Feb 2026 13:08:27 -0300 Subject: [PATCH 068/785] atk: Define `detail::AdvancedWaveSoundFileReader` Other changes: - Defined other structs accompanying `AdvancedWaveSoundFileReader` - Declared methods for structs in `AdvancedWaveSoundFile` --- .../nn/atk/detail/atk_AdvancedWaveSoundFile.h | 21 +++++++--- .../detail/atk_AdvancedWaveSoundFileReader.h | 42 +++++++++++++++++++ 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h b/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h index 1039cf63..46bb16f5 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h @@ -8,19 +8,32 @@ namespace nn::atk::detail { struct AdvancedWaveSoundFile { util::BinaryFileHeader fileHeader; + struct WaveSoundTrack; struct InfoBlockBody { u32 offsetToTrackTableReference; BinaryTypes::Reference toTrackTable; + + BinaryTypes::ReferenceTable* GetTrackReferenceTable() const; + WaveSoundTrack* GetWaveSoundTrack(s32 index) const; }; static_assert(sizeof(InfoBlockBody) == 0x8); struct InfoBlock { util::BinaryBlockHeader blockHeader; InfoBlockBody body; - }; static_assert(sizeof(InfoBlock) == 0x18); + struct WaveSoundClip; + struct WaveSoundTrack { + u32 offsetToCurveTableReference; + u32 offsetToClipTableReference; + BinaryTypes::Reference toClipTable; + + BinaryTypes::ReferenceTable* GetClipReferenceTable() const; + WaveSoundClip* GetWaveSoundClip(s32 index) const; + }; + struct WaveSoundClip { u32 waveIndex; u32 position; @@ -33,11 +46,7 @@ struct AdvancedWaveSoundFile { }; static_assert(sizeof(WaveSoundClip) == 0x18); - struct WaveSoundTrack { - u32 offsetToCurveTableReference; - u32 offsetToClipTableReference; - BinaryTypes::Reference toClipTable; - }; + InfoBlock* GetBlock() const; }; static_assert(sizeof(AdvancedWaveSoundFile) == 0x20); diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundFileReader.h b/include/nn/atk/detail/atk_AdvancedWaveSoundFileReader.h index e69de29b..850b69a0 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundFileReader.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundFileReader.h @@ -0,0 +1,42 @@ +#pragma once + +#include + +namespace nn::atk::detail { +struct AdvancedWaveSoundClipInfo { + u32 waveIndex; + u32 position; + u32 duration; + u32 startOffset; + f32 pitch; + u8 volume; + u8 pan; +}; +static_assert(sizeof(AdvancedWaveSoundClipInfo) == 0x18); + +struct AdvancedWaveSoundTrackInfo { + s32 waveSoundClipCount; + AdvancedWaveSoundClipInfo waveSoundClipInfo[10]; +}; +static_assert(sizeof(AdvancedWaveSoundTrackInfo) == 0xf4); + +struct AdvancedWaveSoundTrackInfoSet { + s32 waveSoundTrackCount; + AdvancedWaveSoundTrackInfo waveSoundTrackInfo[4]; +}; +static_assert(sizeof(AdvancedWaveSoundTrackInfoSet) == 0x3d4); + +class AdvancedWaveSoundFileReader { +public: + explicit AdvancedWaveSoundFileReader(const void* pFile); + + s32 GetWaveSoundTrackCount(); + s32 GetWaveSoundClipCount(s32 index); + + bool ReadWaveSoundTrackInfoSet(AdvancedWaveSoundTrackInfoSet* pTrackInfoSet); + +private: + AdvancedWaveSoundFile::InfoBlockBody* m_pInfoBlockBody; +}; +static_assert(sizeof(AdvancedWaveSoundFileReader) == 0x8); +} // namespace nn::atk::detail \ No newline at end of file From 6205e8c2adf86ad5740ed66ad8e436e68a5eefbd Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 25 Feb 2026 13:38:48 -0300 Subject: [PATCH 069/785] atk: Define `SequenceSoundHandle` --- include/nn/atk/atk_SequenceSoundHandle.h | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/include/nn/atk/atk_SequenceSoundHandle.h b/include/nn/atk/atk_SequenceSoundHandle.h index e69de29b..bde9626e 100644 --- a/include/nn/atk/atk_SequenceSoundHandle.h +++ b/include/nn/atk/atk_SequenceSoundHandle.h @@ -0,0 +1,36 @@ +#pragma once + +#include + +#include + +namespace nn::atk { +namespace detail { +class SequenceSound; +} // namespace nn::atk::detail + +class SequenceSoundHandle { +public: + using TrackBitFlagSet = util::BitFlagSet<16, void>; + + constexpr static u32 BankIndexMin = 0; + constexpr static u32 BankIndexMax = 3; + + constexpr static u8 TransposeMin = 192; + constexpr static u8 TransposeMax = 63; + + constexpr static u8 VelocityRangeMin = 0; + constexpr static u8 VelocityRangeMax = 127; + + constexpr static u32 VariableIndexMax = 15; + constexpr static u32 TrackIndexMax = 15; + + explicit SequenceSoundHandle(SoundHandle* pSoundHandle); + + void detail_AttachSoundAsTempHandle(detail::SequenceSound* pSound); + void DetachSound(); + +private: + detail::SequenceSound* m_pSound; +}; +} // namespace nn::atk \ No newline at end of file From 9cf3f3dde646a558ea58672fdd3ec77fdc21f497 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 25 Feb 2026 14:03:28 -0300 Subject: [PATCH 070/785] atk: Define `detail::SoundArchiveLoader` --- .../nn/atk/detail/atk_SoundArchiveLoader.h | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/include/nn/atk/detail/atk_SoundArchiveLoader.h b/include/nn/atk/detail/atk_SoundArchiveLoader.h index e69de29b..519448c5 100644 --- a/include/nn/atk/detail/atk_SoundArchiveLoader.h +++ b/include/nn/atk/detail/atk_SoundArchiveLoader.h @@ -0,0 +1,98 @@ +#pragma once + +#include +#include + +namespace nn::atk::detail { +struct LoadItemInfo { + SoundArchive::ItemId itemId; + void* address; +}; +static_assert(sizeof(LoadItemInfo) == 0x10); + +class SoundArchiveLoader { +public: + enum LoadFlag { + LoadFlag_All = -1, + LoadFlag_Seq = 1, + LoadFlag_Wsd = 2, + LoadFlag_Bank = 4, + LoadFlag_Warc = 8, + }; + + struct IndividualWaveInfo { + u32 signature; + u32 fileId; + u32 waveIndex; + u32 padding[5]; + u32 padding2[8]; + }; + static_assert(sizeof(IndividualWaveInfo) == 0x40); + + SoundArchiveLoader(); + virtual ~SoundArchiveLoader(); + + void SetSoundArchive(SoundArchive* arc); + + bool LoadData(SoundArchive::ItemId itemId, + SoundMemoryAllocatable* pAllocator, + u32 loadFlag, std::size_t loadBlockSize); + bool LoadSequenceSound(SoundArchive::ItemId soundId, + SoundMemoryAllocatable* pAllocator, + u32 loadFlag, std::size_t loadBlockSize); + bool LoadAdvancedWaveSound(SoundArchive::ItemId soundId, + SoundMemoryAllocatable* pAllocator, + u32 loadFlag, std::size_t loadBlockSize); + bool LoadWaveSound(SoundArchive::ItemId soundId, + SoundMemoryAllocatable* pAllocator, + u32 loadFlag, std::size_t loadBlockSize, + SoundArchive::ItemId waveSoundSetId); + bool LoadBank(SoundArchive::ItemId bankId, + SoundMemoryAllocatable* pAllocator, + u32 loadFlag, std::size_t loadBlockSize); + bool LoadSoundGroup(SoundArchive::ItemId soundGroupId, + SoundMemoryAllocatable* pAllocator, + u32 loadFlag, std::size_t loadBlockSize); + bool LoadData(char* pItemName, SoundMemoryAllocatable* pAllocator, + u32 loadFlag, std::size_t loadBlockSize); + void* LoadImpl(SoundArchive::FileId fileId, + SoundMemoryAllocatable* pAllocator, + std::size_t loadBlockSize, bool needMemoryPool); + bool LoadIndividualWave(SoundArchive::ItemId warcId, u32 waveIndex, + SoundMemoryAllocatable* pAllocator, + std::size_t loadBlockSize); + void* LoadWaveArchiveTable(SoundArchive::ItemId warcId, + SoundMemoryAllocatable* pAllocator, + std::size_t loadBlockSize); + + std::size_t ReadFile(SoundArchive::FileId fileId, void* buffer, + std::size_t size, s32 offset, + std::size_t loadBlockSize); + + bool PostProcessForLoadedGroupFile(void* pGroupFile, + SoundMemoryAllocatable* pAllocator, + std::size_t loadBlockSize); + + void SetWaveArchiveTableWithSeqInEmbeddedGroup(SoundArchive::ItemId seqId, + SoundMemoryAllocatable* pAllocator); + void SetWaveArchiveTableWithWsdInEmbeddedGroup(SoundArchive::ItemId wsdId, + SoundMemoryAllocatable* pAllocator); + void SetWaveArchiveTableInEmbeddedGroupImpl(SoundArchive::ItemId warcId, + SoundMemoryAllocatable* pAllocator); + + void* GetFileAddressFromSoundArchive(SoundArchive::FileId fileId); + + void* detail_GetFileAddressByItemId(SoundArchive::ItemId itemId); + bool detail_LoadWaveArchiveByBankFile(void* bankFile, + SoundMemoryAllocatable* pAllocator); + bool detail_LoadWaveArchiveByWaveSoundFile(void* wsdFile, s32 wsdIndex, + SoundMemoryAllocatable* pAllocator); + +private: + SoundArchive* m_pSoundArchive; + u32 m_StreamArea[128]; + u16 m_LoadDataCallCount; + bool m_IsCancelLoading; +}; +static_assert(sizeof(SoundArchiveLoader) == 0x218); +} // namespace nn::atk::detail \ No newline at end of file From a514db80447c8795f3a180d8b991d702a05ad066 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 25 Feb 2026 16:43:07 -0300 Subject: [PATCH 071/785] atk: Define `detail::SoundInstanceManager` Other changes: - util: Added type-aliases --- .../nn/atk/detail/atk_SoundInstanceManager.h | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/include/nn/atk/detail/atk_SoundInstanceManager.h b/include/nn/atk/detail/atk_SoundInstanceManager.h index e69de29b..49fa6bbc 100644 --- a/include/nn/atk/detail/atk_SoundInstanceManager.h +++ b/include/nn/atk/detail/atk_SoundInstanceManager.h @@ -0,0 +1,30 @@ +#pragma once + +#include + +#include +#include + +namespace nn::atk::detail { +template +class SoundInstanceManager { +public: + using PriorityList = util::IntrusiveList>; + using Iterator = typename PriorityList::iterator; + + T* Alloc(s32 priority, s32 ambientPriority); + T* Alloc(s32 priority, s32 ambientPriority, OutputReceiver* pOutputReceiver); + + s32 Create(void* buffer, std::size_t size, const SoundInstanceConfig& config); + + void SortPriorityList(); + +private: + void* m_pBuffer; + std::size_t m_BufferSize; + SoundInstanceConfig m_SoundInstanceConfig; + PriorityList m_PriorityList; + PriorityList m_FreeList; +}; +} // namespace nn::atk::detail \ No newline at end of file From 4b948a718c77d166010dc43957ab48431d30f53a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 11:20:32 -0300 Subject: [PATCH 072/785] atk: Define `detail::fnd::Thread` --- include/nn/atk/fnd/os/atkfnd_Thread.h | 129 ++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/include/nn/atk/fnd/os/atkfnd_Thread.h b/include/nn/atk/fnd/os/atkfnd_Thread.h index e69de29b..34dbe34b 100644 --- a/include/nn/atk/fnd/os/atkfnd_Thread.h +++ b/include/nn/atk/fnd/os/atkfnd_Thread.h @@ -0,0 +1,129 @@ +#pragma once + +#include +#include + +namespace nn::atk::detail::fnd { +class TimeSpan; + +class Thread { +public: + enum AffinityMask { + AffinityMask_CoreAll = -1, + AffinityMask_CoreDefault, + AffinityMask_Core0, + AffinityMask_Core1 = AffinityMask_Core0 * 2, + AffinityMask_Core2 = AffinityMask_Core1 * 2, + AffinityMask_Core3 = AffinityMask_Core2 * 2, + AffinityMask_Core4 = AffinityMask_Core3 * 2, + AffinityMask_Core5 = AffinityMask_Core4 * 2, + AffinityMask_Core6 = AffinityMask_Core5 * 2, + AffinityMask_Core7 = AffinityMask_Core6 * 2, + AffinityMask_Core8 = AffinityMask_Core7 * 2, + AffinityMask_Core9 = AffinityMask_Core8 * 2, + AffinityMask_Core10 = AffinityMask_Core9 * 2, + AffinityMask_Core11 = AffinityMask_Core10 * 2, + AffinityMask_Core12 = AffinityMask_Core11 * 2, + AffinityMask_Core13 = AffinityMask_Core12 * 2, + AffinityMask_Core14 = AffinityMask_Core13 * 2, + AffinityMask_Core15 = AffinityMask_Core14 * 2, + AffinityMask_Core16 = AffinityMask_Core15 * 2, + AffinityMask_Core17 = AffinityMask_Core16 * 2, + AffinityMask_Core18 = AffinityMask_Core17 * 2, + AffinityMask_Core19 = AffinityMask_Core18 * 2, + AffinityMask_Core20 = AffinityMask_Core19 * 2, + AffinityMask_Core21 = AffinityMask_Core20 * 2, + AffinityMask_Core22 = AffinityMask_Core21 * 2, + AffinityMask_Core23 = AffinityMask_Core22 * 2, + AffinityMask_Core24 = AffinityMask_Core23 * 2, + AffinityMask_Core25 = AffinityMask_Core24 * 2, + AffinityMask_Core26 = AffinityMask_Core25 * 2, + AffinityMask_Core27 = AffinityMask_Core26 * 2, + AffinityMask_Core28 = AffinityMask_Core27 * 2, + AffinityMask_Core29 = AffinityMask_Core28 * 2, + AffinityMask_Core30 = AffinityMask_Core29 * 2, + AffinityMask_Core31 = -AffinityMask_Core30 * 2, + }; + + enum FsPriority { + FsPriority_RealTime, + FsPriority_Normal, + FsPriority_Low, + }; + + enum State { + State_NotRun, + State_Running, + State_Exited, + State_Released, + }; + + using Handle = os::ThreadType; + + class Handler { + public: + virtual ~Handler(); + }; + static_assert(sizeof(Handler) == 0x8); + + struct RunArgs { + RunArgs(); + + bool IsValid() const; + + char* name; + void* stack; + std::size_t stackSize; + s32 idealCoreNumber; + AffinityMask affinityMask; + s32 priority; + FsPriority fsPriority; + void* param; + Handler* handler; + }; + static_assert(sizeof(RunArgs) == 0x38); + + ~Thread(); + + bool Run(const RunArgs& args); + void WaitForExit(); + void Release(); + + void SetState(State state); + + s32 GetPriority() const; + State GetState() const; + + void OnRun(); + void OnExit(); + + Thread(); + + void SetPriority(s32 priority); + + static void Sleep(const TimeSpan& timeSpan); + + bool Create(const Handle& handle, const s64& id, const RunArgs& args); + + void Detach(); + + bool IsTerminated() const; + + void SetName(const char* name); + void SetAffinityMask(s32 idealCoreNumber, AffinityMask value); + + void Resume(); + void Join(); + +private: + u32 m_State; + Handle m_Handle; + s64 m_Id; + s32 m_Priority; + FsPriority m_FsPriority; + void* m_Param; + Handler* m_Handler; + bool m_IsTerminated; +}; +static_assert(sizeof(Thread) == 0x1f0); +} // nn::atk::detail::fnd \ No newline at end of file From 6a935f25af6cbb0adc9608e3496c5f6bd18a23c8 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 11:28:55 -0300 Subject: [PATCH 073/785] os: Define `MessageQueue` --- include/nn/os/os_MessageQueue.h | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 include/nn/os/os_MessageQueue.h diff --git a/include/nn/os/os_MessageQueue.h b/include/nn/os/os_MessageQueue.h new file mode 100644 index 00000000..ebc3cc15 --- /dev/null +++ b/include/nn/os/os_MessageQueue.h @@ -0,0 +1,11 @@ +#pragma once + +#include + +namespace nn::os { +class MessageQueue { +public: +private: + MessageQueueType m_MessageQueue; +}; +} // namespace nn::os \ No newline at end of file From 785dd710aeb66d5d029c5dc3d041d33489366c8e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 12:21:12 -0300 Subject: [PATCH 074/785] atk: Define `ProfileReader` --- include/nn/atk/util/atk_ProfileReader.h | 83 +++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/include/nn/atk/util/atk_ProfileReader.h b/include/nn/atk/util/atk_ProfileReader.h index e69de29b..5fb79e4d 100644 --- a/include/nn/atk/util/atk_ProfileReader.h +++ b/include/nn/atk/util/atk_ProfileReader.h @@ -0,0 +1,83 @@ +#pragma once + +#include + +#include +#include +#include + +namespace nn::atk { +struct TimeRange { + os::Tick begin; + os::Tick end; +}; +static_assert(sizeof(TimeRange) == 0x10); + +struct SoundProfile { + TimeRange nwFrameProcess; + TimeRange mainMixProcess; + TimeRange finalMixProcess; + TimeRange voiceProcess; + TimeRange sinkProcess; + TimeRange circularBufferSinkProcess; + TimeRange rendererFrameProcess; + u32 totalVoiceCount; + u32 rendererVoiceCount; + u32 nwVoiceCount; + u64 nwFrameProcessTick; + TimeRange _additionalSubMixProcess; + TimeRange _voiceProcessTable[192]; + audio::NodeId _voiceIdTable[192]; +}; +static_assert(sizeof(SoundProfile) == 0xf98); + +struct SoundThreadUpdateProfile { + TimeRange soundThreadProcess; + TimeRange _updateLowLevelVoiceProcess; + TimeRange _updateRendererProcess; + TimeRange _waitRendererEventProcess; + TimeRange _userEffectFrameProcess; + TimeRange _frameProcess; +}; +static_assert(sizeof(SoundThreadUpdateProfile) == 0x60); + +class ProfileReader { +public: + ProfileReader(); + + void Record(const SoundProfile& src); + + std::size_t Read(SoundProfile*, s32); + + util::IntrusiveListNode m_Link; + +private: + SoundProfile m_ProfileBuffer[32]; + s32 m_ProfileBufferRead; + s32 m_ProfileBufferWrite; +}; + +using ProfileReaderList = util::IntrusiveList>; + +class TaskProfile; +template +class AtkProfileReader { +public: + util::IntrusiveListNode m_List; + +private: + bool m_IsInitialized; + TaskProfile* m_pProfile; + s32 m_ProfileCount; + s32 m_RecordIndex; + s32 m_ReadIndex; + std::atomic_int m_ReadableCount; +}; + +using SoundThreadUpdateProfileReader = AtkProfileReader; +using SoundThreadUpdateProfileReaderList = util::IntrusiveList>; +} // namespace nn::atk \ No newline at end of file From f93b2b370a0f24688a168325c0192096eeef6db0 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 12:47:59 -0300 Subject: [PATCH 075/785] atk: Define header `atk_ThreadInfoReader.h` --- .../atk/detail/thread/atk_ThreadInfoReader.h | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/include/nn/atk/detail/thread/atk_ThreadInfoReader.h b/include/nn/atk/detail/thread/atk_ThreadInfoReader.h index e69de29b..2f86cd0c 100644 --- a/include/nn/atk/detail/thread/atk_ThreadInfoReader.h +++ b/include/nn/atk/detail/thread/atk_ThreadInfoReader.h @@ -0,0 +1,28 @@ +#pragma once + +#include + +#include + +namespace nn::atk { +namespace detail { +class ThreadInfoRecorder { +public: + util::IntrusiveListNode m_List; + +private: + void* m_Buffer; + std::size_t m_BufferSize; + std::size_t m_WritePosition; + std::atomic_ulong m_ReadPosition; + std::atomic_int m_RecordFrameCount; + std::atomic_bool m_IsAllocationFailed; +}; +static_assert(sizeof(ThreadInfoRecorder) == 0x38); +} // namespace nn::atk::detail + +using SoundThreadInfoRecorder = detail::ThreadInfoRecorder; +using SoundThreadInfoRecorderList = util::IntrusiveList>; +} // namespace nn::atk \ No newline at end of file From 1b0de8ec0328b979db3f91616da6ea349510b2ef Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 13:01:50 -0300 Subject: [PATCH 076/785] audio: Add `audio_PerformanceMetricsTypes.h` --- CMakeLists.txt | 1 + .../nn/audio/audio_PerformanceMetricsTypes.h | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 include/nn/audio/audio_PerformanceMetricsTypes.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fad8d16..397ca48c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -236,6 +236,7 @@ add_library(NintendoSDK OBJECT include/nn/audio/audio_Common.h include/nn/audio/audio_EffectTypes.h include/nn/audio/audio_FinalMixTypes.h + include/nn/audio/audio_PerformanceMetricsTypes.h include/nn/audio/audio_SubMixTypes.h include/nn/audio/audio_VoiceTypes.h diff --git a/include/nn/audio/audio_PerformanceMetricsTypes.h b/include/nn/audio/audio_PerformanceMetricsTypes.h new file mode 100644 index 00000000..7e114294 --- /dev/null +++ b/include/nn/audio/audio_PerformanceMetricsTypes.h @@ -0,0 +1,26 @@ +#pragma once + +#include + +namespace nn::audio { +enum PerformanceEntryType { + PerformanceEntryType_Unknown, + PerformanceEntryType_Voice, + PerformanceEntryType_SubMix, + PerformanceEntryType_FinalMix, + PerformanceEntryType_Sink, + PerformanceEntryType_Count +}; + +struct PerformanceEntry { + NodeId id; + s32 startTime; + s32 processingTime; + s8 entryType; + s8 _padding[3]; +}; +static_assert(sizeof(PerformanceEntry) == 0x10); + +struct PerformanceFrameHeader {}; +struct PerformanceDetail {}; +} // namespace nn::audio \ No newline at end of file From 6d58e1fc93e6cdea6764f908d3df22baae4c933e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 13:15:09 -0300 Subject: [PATCH 077/785] audio: Add `audio_PerformanceMetrics.h` --- CMakeLists.txt | 1 + include/nn/atk/fnd/os/atkfnd_Thread.h | 3 ++- include/nn/audio/audio_PerformanceMetrics.h | 27 +++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 include/nn/audio/audio_PerformanceMetrics.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 397ca48c..f7382194 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -236,6 +236,7 @@ add_library(NintendoSDK OBJECT include/nn/audio/audio_Common.h include/nn/audio/audio_EffectTypes.h include/nn/audio/audio_FinalMixTypes.h + include/nn/audio/audio_PerformanceMetrics.h include/nn/audio/audio_PerformanceMetricsTypes.h include/nn/audio/audio_SubMixTypes.h include/nn/audio/audio_VoiceTypes.h diff --git a/include/nn/atk/fnd/os/atkfnd_Thread.h b/include/nn/atk/fnd/os/atkfnd_Thread.h index 34dbe34b..c8247a3e 100644 --- a/include/nn/atk/fnd/os/atkfnd_Thread.h +++ b/include/nn/atk/fnd/os/atkfnd_Thread.h @@ -62,7 +62,8 @@ class Thread { class Handler { public: - virtual ~Handler(); + virtual ~Handler() = 0; + virtual u32 Run(void* param) = 0; }; static_assert(sizeof(Handler) == 0x8); diff --git a/include/nn/audio/audio_PerformanceMetrics.h b/include/nn/audio/audio_PerformanceMetrics.h new file mode 100644 index 00000000..272f3fbb --- /dev/null +++ b/include/nn/audio/audio_PerformanceMetrics.h @@ -0,0 +1,27 @@ +#pragma once + +#include + +#include + +namespace nn::audio { +class PerformanceInfo { +public: + PerformanceInfo(); + ~PerformanceInfo(); + + void SetBuffer(const void* buffer, std::size_t bufferSize); + void MoveToNextFrame(); + + PerformanceEntry* GetEntries(s32*); + void GetTotalProcessingTime(); + +private: + void* m_Buffer; + std::size_t m_BufferSize; + PerformanceFrameHeader* m_Header; + PerformanceEntry* m_Entries; + PerformanceDetail* m_Details; +}; +static_assert(sizeof(PerformanceInfo) == 0x28); +} // namespace nn::audio \ No newline at end of file From a161a5054adf4c5ffdff3e0a498ee0b527b155b7 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 13:41:50 -0300 Subject: [PATCH 078/785] atk: Define `detail::driver::SoundThread` --- .../nn/atk/detail/thread/atk_SoundThread.h | 151 ++++++++++++++++++ 1 file changed, 151 insertions(+) diff --git a/include/nn/atk/detail/thread/atk_SoundThread.h b/include/nn/atk/detail/thread/atk_SoundThread.h index e69de29b..0d478f44 100644 --- a/include/nn/atk/detail/thread/atk_SoundThread.h +++ b/include/nn/atk/detail/thread/atk_SoundThread.h @@ -0,0 +1,151 @@ +#pragma once + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace nn::atk::detail::driver { +struct SoundThreadLock {}; +struct AtkStateAndParameterUpdateLock {}; + +class SoundThread : fnd::Thread::Handler { +public: + enum Message { + Message_HwCallback = 0x10000000, + Message_Shutdown = 0x20000000, + Message_ForceWakeup = 0x30000000, + }; + + using ProfileFunc = void(*)(os::Tick*); + + constexpr static u32 ThreadMessageBuffferSize = 32; + constexpr static u64 RendererEventWaitTimeoutMilliSeconds = 100; + + class SoundFrameCallback { + public: + virtual ~SoundFrameCallback(); + + void OnEndSoundFrame(); + + private: + friend SoundThread; + + util::IntrusiveListNode m_Link; + }; + + using SoundFrameCallbackList = util::IntrusiveList>; + + class PlayerCallback { + public: + virtual ~PlayerCallback(); + + private: + friend SoundThread; + + util::IntrusiveListNode m_Link; + }; + + using PlayerCallbackList = util::IntrusiveList>; + + ~SoundThread() override; + + bool CreateSoundThread(s32 threadPriority, void* stackBase, std::size_t stackSize, + s32 idealCoreNumber, u32 affinityMask); + + void Initialize(void* performanceFrameBuffer, std::size_t performanceFrameBufferSize, + bool isProfilingEnabled); + void Initialize(void* performanceFrameBuffer, std::size_t performanceFrameBufferSize, + bool isProfilingEnabled, bool isDetailSoundThreadProfilerEnabled, + bool isUserThreadRenderingEnabled); + + void Destroy(); + + void Finalize(); + + void UpdateLowLevelVoices(); + + void ForceWakeup(); + + void RegisterSoundFrameUserCallback(SoundFrameUserCallback callback, std::uintptr_t callbackArg); + void ClearSoundFrameUserCallback(); + + void RegisterThreadBeginUserCallback(SoundThreadUserCallback, std::uintptr_t callbackArg); + void ClearThreadBeginUserCallback(); + + void RegisterThreadEndUserCallback(SoundThreadUserCallback, std::uintptr_t callbackArg); + void ClearThreadEndUserCallback(); + + void RegisterSoundFrameCallback(SoundFrameCallback* callback); + void UnregisterSoundFrameCallback(SoundFrameCallback* callback); + + void RegisterPlayerCallback(PlayerCallback* callback); + void UnregisterPlayerCallback(PlayerCallback* callback); + + void LockAtkStateAndParameterUpdate(); + void UnlockAtkStateAndParameterUpdate(); + + void RegisterAudioRendererPerformanceReader(AudioRendererPerformanceReader& performanceReader); + + void RegisterSoundThreadUpdateProfileReader(SoundThreadUpdateProfileReader& profileReader); + void UnregisterSoundThreadUpdateProfileReader(SoundThreadUpdateProfileReader& profileReader); + + void FrameProcess(UpdateType updateType); + + void RecordPerformanceInfo(audio::PerformanceInfo* src, os::Tick beginTick, + os::Tick endTick, u32 nwVoiceCount); + + void EffectFrameProcess(); + + void RecordUpdateProfile(const SoundThreadUpdateProfile& threadUpdateProfile); + + u32 Run(void* param) override; + +private: + fnd::Thread m_Thread; + os::MessageQueue m_BlockingQueue; + std::uintptr_t m_MsgBuffer[32]; + u32 m_AxCallbackCounter; + fnd::CriticalSection m_CriticalSection; + fnd::CriticalSection m_UpdateAtkStateAndParameterSection; + SoundFrameCallbackList m_SoundFrameCallbackList; + PlayerCallbackList m_PlayerCallbackList; + SoundFrameUserCallback m_UserCallback; + std::uintptr_t m_UserCallbackArg; + SoundThreadUserCallback m_ThreadBeginUserCallback; + std::uintptr_t m_ThreadBeginUserCallbackArg; + SoundThreadUserCallback m_ThreadEndUserCallback; + std::uintptr_t m_ThreadEndUserCallbackArg; + s32 m_SoundThreadAffinityMask; + bool m_CreateFlag; + bool m_PauseFlag; + os::Tick m_LastPerformanceFrameBegin; + os::Tick m_LastPerformanceFrameEnd; + void* m_pPerformanceFrameUpdateBuffer[3]; + std::size_t m_PerformanceFrameUpdateBufferSize; + s32 m_CurrentPerformanceFrameBufferIndex; + bool m_IsProfilingEnabled; + ProfileFunc m_pSoundThreadProfileFunc; + bool m_IsUserThreadRenderingEnabled; + ProfileReaderList m_ProfileReaderList; + AudioRendererPerformanceReader* m_pAudioRendererPerformanceReader; + SoundThreadInfoRecorderList m_InfoRecorderList; + fnd::CriticalSection m_LockRecordInfo; + SoundThreadUpdateProfile m_LastUpdateProfile; + SoundThreadUpdateProfileReaderList m_UpdateProfileReaderList; + fnd::CriticalSection m_LockUpdateProfile; + std::atomic_int m_RendererEventWaitTimeMilliSeconds; +}; +static_assert(sizeof(SoundThread) == 0x508); +} // namespace nn::atk::detail::driver \ No newline at end of file From c771aa6373017f60f762afe4e277551185c8bc6d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 14:10:36 -0300 Subject: [PATCH 079/785] atk: Define `detail::PlayerHeapDataManager` --- include/nn/atk/detail/atk_DisposeCallback.h | 2 + .../nn/atk/detail/atk_PlayerHeapDataManager.h | 37 +++++++++++++++++++ .../nn/atk/detail/atk_SoundArchiveLoader.h | 4 ++ 3 files changed, 43 insertions(+) diff --git a/include/nn/atk/detail/atk_DisposeCallback.h b/include/nn/atk/detail/atk_DisposeCallback.h index 5d4198be..19fe670e 100644 --- a/include/nn/atk/detail/atk_DisposeCallback.h +++ b/include/nn/atk/detail/atk_DisposeCallback.h @@ -7,6 +7,8 @@ class DisposeCallback { public: virtual ~DisposeCallback() = default; + virtual void InvalidateData(void*,void*) = 0; + private: util::IntrusiveListNode m_DisposeLink; }; diff --git a/include/nn/atk/detail/atk_PlayerHeapDataManager.h b/include/nn/atk/detail/atk_PlayerHeapDataManager.h index e69de29b..b28829e5 100644 --- a/include/nn/atk/detail/atk_PlayerHeapDataManager.h +++ b/include/nn/atk/detail/atk_PlayerHeapDataManager.h @@ -0,0 +1,37 @@ +#pragma once + +#include +#include +#include + +namespace nn::atk::detail { +class PlayerHeapDataManager : driver::DisposeCallback, SoundArchiveLoader { +public: + struct FileAddress { + SoundArchive::FileId fileId; + void* address; + }; + static_assert(sizeof(FileAddress) == 0x10); + + PlayerHeapDataManager(); + ~PlayerHeapDataManager() override; + + void Finalize(); + void Initialize(const SoundArchive* arc); + + void* SetFileAddress(SoundArchive::FileId fileId, const void* address); + void* GetFileAddress(SoundArchive::FileId fileId); + + void InvalidateData(void*, void*) override; + + void* SetFileAddressToTable(SoundArchive::FileId fileId, const void* address) override; + void* GetFileAddressFromTable(SoundArchive::FileId fileId) override; + void* GetFileAddressImpl(SoundArchive::FileId fileId) override; + +private: + FileAddress m_FileAddress[9]; + bool m_IsInitialized; + bool m_IsFinalized; +}; +static_assert(sizeof(PlayerHeapDataManager) == 0x2c8); +} // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/atk_SoundArchiveLoader.h b/include/nn/atk/detail/atk_SoundArchiveLoader.h index 519448c5..bbb885d0 100644 --- a/include/nn/atk/detail/atk_SoundArchiveLoader.h +++ b/include/nn/atk/detail/atk_SoundArchiveLoader.h @@ -31,6 +31,10 @@ class SoundArchiveLoader { SoundArchiveLoader(); virtual ~SoundArchiveLoader(); + + virtual void* SetFileAddressToTable(SoundArchive::FileId fileId, const void* address) = 0; + virtual void* GetFileAddressFromTable(SoundArchive::FileId fileId) = 0; + virtual void* GetFileAddressImpl(SoundArchive::FileId fileId) = 0; void SetSoundArchive(SoundArchive* arc); From d8bbabc4f4645af40ba794f24249d55d14f285db Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 14:18:19 -0300 Subject: [PATCH 080/785] atk: Define `detail::driver::BasicSoundPlayer` --- include/nn/atk/detail/atk_BasicSoundPlayer.h | 45 ++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/include/nn/atk/detail/atk_BasicSoundPlayer.h b/include/nn/atk/detail/atk_BasicSoundPlayer.h index e69de29b..ae4b38d4 100644 --- a/include/nn/atk/detail/atk_BasicSoundPlayer.h +++ b/include/nn/atk/detail/atk_BasicSoundPlayer.h @@ -0,0 +1,45 @@ +#pragma once + +#include + +#include +#include +#include +#include + +namespace nn::atk::detail::driver { +struct PlayerParamSet { + f32 volume; + f32 pitch; + f32 lpfFreq; + f32 biquadValue; + s8 biquadType; + PanMode panMode; + PanCurve panCurve; + u32 outputLineFlag; + OutputParam tvParam; +}; + +class BasicSoundPlayer { +public: + virtual ~BasicSoundPlayer(); + virtual void Initialize(OutputReceiver* pOutputReceiver); + virtual void Finalize(); + + BasicSoundPlayer(); + void SetBiquadFilter(s32 type, f32 value); + +private: + os::Event m_Event; + OutputReceiver* m_pOutputReceiver; + bool m_ActiveFlag; + bool m_StartedFlag; + bool m_PauseFlag; + bool m_FinishFlag; + bool m_IsFinalizedForCannotAllocateResource; + PlayerParamSet m_PlayerParamSet; + OutputAdditionalParam* m_pTvAdditionalParam; + PlayerHeapDataManager* m_pPlayerHeapDataManager; +}; +static_assert(sizeof(BasicSoundPlayer) == 0xc0); +} //namespace nn::atk::detail::driver \ No newline at end of file From 4a1d676261d2aa50104498a671b048973194420a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 14:55:34 -0300 Subject: [PATCH 081/785] atk: Define `detail::driver::AdvancedWaveSoundPlayer` --- .../atk/detail/atk_AdvancedWaveSoundPlayer.h | 85 +++++++++++++++++++ include/nn/atk/detail/atk_BasicSoundPlayer.h | 3 + .../nn/atk/detail/thread/atk_SoundThread.h | 4 + 3 files changed, 92 insertions(+) diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h b/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h index e69de29b..28d258c5 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h @@ -0,0 +1,85 @@ +#pragma once + +#include +#include +#include +#include +#include + +namespace nn::atk::detail::driver { +class AdvancedWaveSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { +public: + struct ClipParam { + bool isPlayed; + Channel* pChannel; + }; + static_assert(sizeof(ClipParam) == 0x10); + + struct TrackParam { + bool isPlayed; + ClipParam clipParam[10]; + }; + static_assert(sizeof(TrackParam) == 0xa8); + + struct TrackParamSet { + bool isPlayed; + TrackParam trackParam[4]; + }; + static_assert(sizeof(TrackParamSet) == 0x2a8); + + struct PrepareParameter { + SoundArchive::AdvancedWaveSoundInfo advancedWaveSoundInfo; + UpdateType updateType; + void* pAwsdFile; + void* pWarcFile; + }; + static_assert(sizeof(PrepareParameter) == 0x18); + + AdvancedWaveSoundPlayer(); + ~AdvancedWaveSoundPlayer() override; + + void Initialize(OutputReceiver* pOutputReceiver) override; + void Finalize() override; + + void TearDownPlayer(); + void ReleaseTracks(); + + void Start() override; + void Stop() override; + void Pause(bool isPauseEnabled) override; + + void Prepare(const PrepareParameter& parameter); + + void SetupPlayer(); + bool SetupTracks(); + + void Update(); + bool UpdateTracks(); + + void InitializeTrackParams(); + + bool StartClip(ClipParam* pClipParam, + SoundArchive::AdvancedWaveSoundInfo* pWaveSoundClipInfo); + bool UpdateClip(ClipParam* pClipParam, + SoundArchive::AdvancedWaveSoundInfo* pWaveSoundClipInfo); + void ReleaseClip(ClipParam* pClipParam); + void StopClip(ClipParam* pClipParam); + + void OnUpdateFrameSoundThread() override; + void OnUpdateFrameSoundThreadWithAudioFrameFrequency() override; + void OnShutdownSoundThread() override; + +private: + SoundArchive::AdvancedWaveSoundInfo m_AdvancedWaveSoundInfo; + AdvancedWaveSoundTrackInfoSet m_AdvancedWaveSoundTrackInfoSet; + TrackParamSet m_TrackParamSet; + void* m_pAwsdFile; + void* m_pWarcFile; + UpdateType m_UpdateType; + u32 m_CurrentTime; + bool m_IsPrepared; + bool m_IsInitialized; + bool m_IsRegisterPlayerCallback; +}; +static_assert(sizeof(AdvancedWaveSoundPlayer) == 0x778); +} // namespace nn::atk::detail::driver \ No newline at end of file diff --git a/include/nn/atk/detail/atk_BasicSoundPlayer.h b/include/nn/atk/detail/atk_BasicSoundPlayer.h index ae4b38d4..9696c2cb 100644 --- a/include/nn/atk/detail/atk_BasicSoundPlayer.h +++ b/include/nn/atk/detail/atk_BasicSoundPlayer.h @@ -25,6 +25,9 @@ class BasicSoundPlayer { virtual ~BasicSoundPlayer(); virtual void Initialize(OutputReceiver* pOutputReceiver); virtual void Finalize(); + virtual void Start() = 0; + virtual void Stop() = 0; + virtual void Pause(bool isPauseEnabled) = 0; BasicSoundPlayer(); void SetBiquadFilter(s32 type, f32 value); diff --git a/include/nn/atk/detail/thread/atk_SoundThread.h b/include/nn/atk/detail/thread/atk_SoundThread.h index 0d478f44..629f9b6a 100644 --- a/include/nn/atk/detail/thread/atk_SoundThread.h +++ b/include/nn/atk/detail/thread/atk_SoundThread.h @@ -49,6 +49,10 @@ class SoundThread : fnd::Thread::Handler { public: virtual ~PlayerCallback(); + virtual void OnUpdateFrameSoundThread() = 0; + virtual void OnUpdateFrameSoundThreadWithAudioFrameFrequency() = 0; + virtual void OnShutdownSoundThread() = 0; + private: friend SoundThread; From 458ef2f93211731ca0431efe9b206a5a4a1622e3 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 15:17:19 -0300 Subject: [PATCH 082/785] atk: Define `detail::AdvancedWaveSound` --- include/nn/atk/detail/atk_AdvancedWaveSound.h | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/include/nn/atk/detail/atk_AdvancedWaveSound.h b/include/nn/atk/detail/atk_AdvancedWaveSound.h index e69de29b..1b9d0b33 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSound.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSound.h @@ -0,0 +1,40 @@ +#pragma once + +#include +#include +#include + +namespace nn::atk::detail { +class AdvancedWaveSound; +class AdvancedWaveSoundHandle; +using AdvancedWaveSoundInstanceManager = SoundInstanceManager; + +class AdvancedWaveSound : BasicSound { +public: + explicit AdvancedWaveSound(const AdvancedWaveSoundInstanceManager& manager); + ~AdvancedWaveSound() override; + + bool Initialize(OutputReceiver* pOutputReceiver) override; + void Finalize() override; + + void Prepare(const driver::AdvancedWaveSoundPlayer::PrepareParameter& parameter); + + void OnUpdatePlayerPriority() override; + + bool IsAttachedTempSpecialHandle() override; + void DetachTempSpecialHandle() override; + + bool IsPrepared(); + + driver::BasicSoundPlayer* GetBasicSoundPlayerHandle(); + +private: + util::IntrusiveListNode m_PriorityLink; + AdvancedWaveSoundHandle* m_pTempSpecialHandle; + AdvancedWaveSoundInstanceManager* m_InstanceManager; + driver::AdvancedWaveSoundPlayer m_PlayerInstance; + bool m_IsInitialized; + u8 m_Padding[3]; +}; +static_assert(sizeof(AdvancedWaveSound) == 0x9b0); +} // namespace nn::atk::detail From 69293742d0b503047227ea5954bb4ab09baffd04 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 15:38:28 -0300 Subject: [PATCH 083/785] atk: Define `SoundDataManager` --- include/nn/atk/atk_SoundDataManager.h | 65 ++++++++++++++----- include/nn/atk/detail/atk_DisposeCallback.h | 2 +- .../nn/atk/detail/atk_PlayerHeapDataManager.h | 6 +- .../nn/atk/detail/atk_SoundArchiveLoader.h | 4 +- include/nn/atk/detail/voice/atk_Channel.h | 2 +- 5 files changed, 56 insertions(+), 23 deletions(-) diff --git a/include/nn/atk/atk_SoundDataManager.h b/include/nn/atk/atk_SoundDataManager.h index f9366c6e..8bb7e1e9 100644 --- a/include/nn/atk/atk_SoundDataManager.h +++ b/include/nn/atk/atk_SoundDataManager.h @@ -1,25 +1,58 @@ -/** - * @file SoundDataManager.h - * @brief Sound data management implementation. - */ - #pragma once #include -namespace nn { -namespace atk { -class SoundDataManager { +#include +#include +#include + +namespace nn::atk { + +namespace detail { +class SoundFileManager; +} // namespace nn::atk::detail + +class SoundDataManager : detail::driver::DisposeCallback, detail::SoundArchiveLoader { public: + struct FileAddress { + void* address; + }; + + using FileTable = detail::Util::Table; + + constexpr static u32 BufferAlignSize = 8; + SoundDataManager(); - virtual ~SoundDataManager(); + ~SoundDataManager() override; + + std::size_t GetRequiredMemSize(const SoundArchive* arc); + + bool Initialize(const SoundArchive* pArchive, void* buffer, std::size_t size); + + bool CreateTables(void**, const SoundArchive* pArchive, void*); + + void Finalize(); + + void InvalidateData(const void* start, const void* end) override; + + void* detail_GetFileAddress(SoundArchive::FileId fileId) const; + void* GetFileAddressImpl(SoundArchive::FileId fileId) const override; + + void* SetFileAddressToTable(SoundArchive::FileId fileId, const void* address) override; + void* GetFileAddressFromTable(SoundArchive::FileId fileId) const override; + + void* SetFileAddress(SoundArchive::FileId fileId, const void* address); + + SoundArchive::FileId detail_GetFileIdFromTable(const void*) const; + + bool SetFileAddressInGroupFile(const void*, std::size_t); + void ClearFileAddressInGroupFile(const void*, std::size_t); - virtual void InvalidateData(void const*, void const*); - virtual void SetFileAddressToTable(u32, void const*); - virtual u64 GetFileAddressFromTable(u32) const; - virtual u32 GetFileAddressImpl(u32) const; + void InvalidateSoundData(const void*, std::size_t); - u8 _0[0x240]; +private: + FileTable* m_pFileTable; + detail::SoundFileManager* m_pFileManager; }; -} // namespace atk -} // namespace nn +static_assert(sizeof(SoundDataManager) == 0x240); +} // namespace nn::atk diff --git a/include/nn/atk/detail/atk_DisposeCallback.h b/include/nn/atk/detail/atk_DisposeCallback.h index 19fe670e..8a6d14cc 100644 --- a/include/nn/atk/detail/atk_DisposeCallback.h +++ b/include/nn/atk/detail/atk_DisposeCallback.h @@ -7,7 +7,7 @@ class DisposeCallback { public: virtual ~DisposeCallback() = default; - virtual void InvalidateData(void*,void*) = 0; + virtual void InvalidateData(const void* start, const void* end) = 0; private: util::IntrusiveListNode m_DisposeLink; diff --git a/include/nn/atk/detail/atk_PlayerHeapDataManager.h b/include/nn/atk/detail/atk_PlayerHeapDataManager.h index b28829e5..902e7db6 100644 --- a/include/nn/atk/detail/atk_PlayerHeapDataManager.h +++ b/include/nn/atk/detail/atk_PlayerHeapDataManager.h @@ -22,11 +22,11 @@ class PlayerHeapDataManager : driver::DisposeCallback, SoundArchiveLoader { void* SetFileAddress(SoundArchive::FileId fileId, const void* address); void* GetFileAddress(SoundArchive::FileId fileId); - void InvalidateData(void*, void*) override; + void InvalidateData(const void* start, const void* end) override; void* SetFileAddressToTable(SoundArchive::FileId fileId, const void* address) override; - void* GetFileAddressFromTable(SoundArchive::FileId fileId) override; - void* GetFileAddressImpl(SoundArchive::FileId fileId) override; + void* GetFileAddressFromTable(SoundArchive::FileId fileId) const override; + void* GetFileAddressImpl(SoundArchive::FileId fileId) const override; private: FileAddress m_FileAddress[9]; diff --git a/include/nn/atk/detail/atk_SoundArchiveLoader.h b/include/nn/atk/detail/atk_SoundArchiveLoader.h index bbb885d0..4563bc23 100644 --- a/include/nn/atk/detail/atk_SoundArchiveLoader.h +++ b/include/nn/atk/detail/atk_SoundArchiveLoader.h @@ -33,8 +33,8 @@ class SoundArchiveLoader { virtual ~SoundArchiveLoader(); virtual void* SetFileAddressToTable(SoundArchive::FileId fileId, const void* address) = 0; - virtual void* GetFileAddressFromTable(SoundArchive::FileId fileId) = 0; - virtual void* GetFileAddressImpl(SoundArchive::FileId fileId) = 0; + virtual void* GetFileAddressFromTable(SoundArchive::FileId fileId) const = 0; + virtual void* GetFileAddressImpl(SoundArchive::FileId fileId) const = 0; void SetSoundArchive(SoundArchive* arc); diff --git a/include/nn/atk/detail/voice/atk_Channel.h b/include/nn/atk/detail/voice/atk_Channel.h index 6e105ecc..1b52fdfe 100644 --- a/include/nn/atk/detail/voice/atk_Channel.h +++ b/include/nn/atk/detail/voice/atk_Channel.h @@ -48,7 +48,7 @@ class Channel { public: ~Disposer() override; - void InvalidateData(void* start, void* end); + void InvalidateData(const void* start, const void* end) override; private: Channel* m_pChannel; From bb3771429e6f17f1c327d812db684cea7d397209 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 16:15:09 -0300 Subject: [PATCH 084/785] atk: Define `detail::IRegionInfoReadable` --- include/nn/atk/detail/atk_IRegionInfoReadable.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/nn/atk/detail/atk_IRegionInfoReadable.h b/include/nn/atk/detail/atk_IRegionInfoReadable.h index e69de29b..8743fda9 100644 --- a/include/nn/atk/detail/atk_IRegionInfoReadable.h +++ b/include/nn/atk/detail/atk_IRegionInfoReadable.h @@ -0,0 +1,9 @@ +#pragma once + +namespace nn::atk::detail { +class IRegionInfoReadable { +public: + virtual ~IRegionInfoReadable() = default; +}; +static_assert(sizeof(IRegionInfoReadable) == 0x8); +} // namespace nn::atk::detail \ No newline at end of file From 90f8d53158f89d3cf85a5745493949b6b7717067 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 16:31:32 -0300 Subject: [PATCH 085/785] atk: Define `detail::RegionManager` --- include/nn/atk/detail/atk_RegionManager.h | 73 +++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/include/nn/atk/detail/atk_RegionManager.h b/include/nn/atk/detail/atk_RegionManager.h index e69de29b..e88d5d8f 100644 --- a/include/nn/atk/detail/atk_RegionManager.h +++ b/include/nn/atk/detail/atk_RegionManager.h @@ -0,0 +1,73 @@ +#pragma once + +#include + +#include +#include +#include + +namespace nn::atk { +enum StreamRegionCallbackResult { + StreamRegionCallbackResult_Finish, + StreamRegionCallbackResult_Continue, +}; + +struct StreamRegionCallbackParam { + s32 regionNo; + char regionName[64]; + bool isRegionNameEnabled; + s32 regionCount; + detail::IRegionInfoReadable* pRegionInfoReader; +}; +static_assert(sizeof(StreamRegionCallbackParam) == 0x58); + +using StreamRegionCallback = StreamRegionCallbackResult(*)(StreamRegionCallbackParam*,void*); + +namespace detail { +struct StreamDataInfoDetail; + +class RegionManager { +public: + struct Region { + position_t current; + position_t begin; + position_t end; + bool isEnabled; + }; + + void Initialize(); + bool InitializeRegion(IRegionInfoReadable* pRegionReader, + StreamDataInfoDetail* pStreamDataInfo); + + bool IsPreparedForRegionJump() const; + + bool ChangeRegion(s32 currentRegionNo, IRegionInfoReadable* pRegionReader, + StreamDataInfoDetail* pStreamDataInfo); + bool SetRegionInfo(s32 regionNo, IRegionInfoReadable* pRegionReader, + StreamDataInfoDetail* pStreamDataInfo); + + bool TryMoveNextRegion(IRegionInfoReadable* pRegionReader, + StreamDataInfoDetail* pStreamDataInfo); + + void SetPosition(position_t position); + void AddPosition(position_t position); + + bool IsInFirstRegion() const; + +private: + bool m_IsRegionInfoEnabled; + bool m_IsRegionIndexCheckEnabled; + bool m_IsRegionInitialized; + bool m_IsCurrentRegionNameEnabled; + StreamRegionCallback m_StreamRegionCallbackFunc; + void* m_StreamRegionCallbackArg; + s32 m_CurrentRegionNo; + char* m_pCurrentRegionName; + Region m_CurrentRegion; + position_t m_AdpcmContextForStartOffsetFrame; + AdpcmContext m_AdpcmContextForStartOffset[16]; + char m_CurrentRegionName[64]; +}; +static_assert(sizeof(RegionManager) == 0x4c0); +} // namespace nn::atk::detail +} // namespace nn::atk \ No newline at end of file From c6fac0600195379c4f0f61d0077dce44e0a0e6ef Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 16:38:45 -0300 Subject: [PATCH 086/785] atk: Define `detail::driver::StreamBufferPool` --- .../nn/atk/detail/strm/atk_StreamBufferPool.h | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/nn/atk/detail/strm/atk_StreamBufferPool.h b/include/nn/atk/detail/strm/atk_StreamBufferPool.h index e69de29b..f2f8a7be 100644 --- a/include/nn/atk/detail/strm/atk_StreamBufferPool.h +++ b/include/nn/atk/detail/strm/atk_StreamBufferPool.h @@ -0,0 +1,26 @@ +#pragma once + +#include + +namespace nn::atk::detail::driver { +class StreamBufferPool { +public: + constexpr static u32 BlockMax = 32; + constexpr static u8 BitPerByte = 8; + + void Initialize(void* buffer, std::size_t size, s32 blockCount); + void Finalize(); + + void* Alloc(); + void Free(void* pPtr); + +private: + void* m_Buffer; + std::size_t m_BufferSize; + std::size_t m_BlockSize; + s32 m_BlockCount; + s32 m_AllocCount; + u8 m_AllocFlags[4]; +}; +static_assert(sizeof(StreamBufferPool) == 0x28); +} // namespace nn::atk::detail \ No newline at end of file From e712d014a29d280d1009b57a8018bc56fdb20dee Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 17:32:33 -0300 Subject: [PATCH 087/785] atk: Define `SoundStartable` --- include/nn/atk/atk_SoundArchive.h | 12 +- include/nn/atk/atk_SoundStartable.h | 160 ++++++++++++++++++++++++++ include/nn/atk/fnd/os/atkfnd_Thread.h | 64 +++++------ 3 files changed, 198 insertions(+), 38 deletions(-) diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index 94180437..31131a30 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -83,7 +83,7 @@ class SoundArchive { bool isLoadIndividual; u8 padding[3]; }; - static_assert(sizeof(WaveArchiveInfo) == 0xC); + static_assert(sizeof(WaveArchiveInfo) == 0xc); struct SoundArchivePlayerInfo { s32 sequenceSoundCount; @@ -105,7 +105,7 @@ class SoundArchive { u8 channelPriority; bool isReleasePriorityFix; }; - static_assert(sizeof(SequenceSoundInfo) == 0x1C); + static_assert(sizeof(SequenceSoundInfo) == 0x1c); enum StreamFileType { StreamFileType_Invalid = 0, @@ -126,7 +126,7 @@ class SoundArchive { u8 channelCount; s8 globalChannelIndex[2]; }; - static_assert(sizeof(StreamTrackInfo) == 0xE); + static_assert(sizeof(StreamTrackInfo) == 0xe); struct StreamSoundInfo { u16 allocateTrackFlags; @@ -147,7 +147,7 @@ class SoundArchive { u32 loopStartFrame; u32 loopEndFrame; }; - static_assert(sizeof(StreamSoundInfo2) == 0xC); + static_assert(sizeof(StreamSoundInfo2) == 0xc); struct WaveSoundInfo { u32 index; @@ -155,7 +155,7 @@ class SoundArchive { u8 channelPriority; bool isReleasePriorityFix; }; - static_assert(sizeof(WaveSoundInfo) == 0xC); + static_assert(sizeof(WaveSoundInfo) == 0xc); struct AdvancedWaveSoundInfo { u32 waveArchiveId; @@ -168,7 +168,7 @@ class SoundArchive { u8 decayCurve; u8 dopplerFactor; }; - static_assert(sizeof(Sound3DInfo) == 0xC); + static_assert(sizeof(Sound3DInfo) == 0xc); SoundArchive(); diff --git a/include/nn/atk/atk_SoundStartable.h b/include/nn/atk/atk_SoundStartable.h index e69de29b..6ae7f6f0 100644 --- a/include/nn/atk/atk_SoundStartable.h +++ b/include/nn/atk/atk_SoundStartable.h @@ -0,0 +1,160 @@ +#pragma once + +#include +#include +#include +#include +#include + +namespace nn::atk { +class SoundStartable { +public: + struct StartInfo { + enum StartOffsetType { + StartOffsetType_MilliSeconds, + StartOffsetType_Tick, + StartOffsetType_Sample, + }; + + enum EnableFlagBit { + EnableFlagBit_StartOffset = 1 << 0, + EnableFlagBit_PlayerId = 1 << 1, + EnableFlagBit_PlayerPriority = 1 << 2, + EnableFlagBit_ActorPlayerId = 1 << 3, + EnableFlagBit_SequenceSoundInfo = 1 << 4, + EnableFlagBit_StreamSoundInfo = 1 << 5, + EnableFlagBit_WaveSoundInfo = 1 << 6, + EnableFlagBit_VoiceRendererType = 1 << 7, + EnableFlagBit_FadeFrame = 1 << 8, + EnableFlagBit_SoundStopCallback = 1 << 9, + EnableFlagBit_StreamSoundMetaInfo = 1 << 10, + EnableFlagBit_StreamSoundMetaInfo2 = 1 << 11, + EnableFlagBit_DelayTime = 1 << 12, + EnableFlagBit_DelayCount = 1 << 13, + EnableFlagBit_UpdateType = 1 << 14, + EnableFlagBit_SubMixIndex = 1 << 15, + EnableFlagBit_OutputReceiver = 1 << 16, + }; + + struct SequenceSoundInfo { + void* sequenceDataAddress; + char* startLocationLabel; + SoundArchive::ItemId bankIds[4]; + }; + static_assert(sizeof(SequenceSoundInfo) == 0x20); + + struct StreamSoundInfo { + char* externalPath; + void* pExternalData; + std::size_t externalDataSize; + StreamRegionCallback regionCallback; + void* regionCallbackArg; + void* prefetchData; + bool forcePlayPrefetchFlag; + detail::driver::StreamBufferPool* pStreamBufferPool; + }; + static_assert(sizeof(StreamSoundInfo) == 0x40); + + struct WaveSoundInfo { + enum EnableParameterFlagBit { + EnableParameterFlagBit_Release = 1, + EnableParameterFlagBit_ContextCalculationSkipMode, + }; + + void* waveAddress; + s8 waveType; + u8 m_Padding[3]; + s32 enableParameterFlag; + s32 release; + bool isContextCalculationSkipMode; + }; + static_assert(sizeof(WaveSoundInfo) == 0x18); + + u32 enableFlag; + StartOffsetType startOffsetType; + s32 startOffset; + SoundArchive::ItemId playerId; + s32 playerPriority; + s32 actorPlayerId; + SequenceSoundInfo sequenceSoundInfo; + StreamSoundInfo streamSoundInfo; + SoundArchive::StreamSoundInfo streamSoundMetaInfo; + SoundArchive::StreamSoundInfo2 streamSoundMetaInfo2; + WaveSoundInfo waveSoundInfo; + u8 voiceRendererType; + s32 fadeFrame; + SoundStopCallback soundStopCallback; + s32 delayTime; + s32 delayCount; + UpdateType updateType; + s32 subMixIndex; + OutputReceiver* pOutputReceiver; + }; + + struct StartResult { + enum ResultCode { + ResultCode_Success, + ResultCode_ErrorLowPriority, + ResultCode_ErrorInvalidLabelString, + ResultCode_ErrorInvalidSoundId, + ResultCode_CanceledBySinglePlay, + ResultCode_ErrorCanceledForPrioritizingOldest = ResultCode_CanceledBySinglePlay, + ResultCode_ErrorNotDataLoaded, + ResultCode_ErrorNotSequenceLoaded, + ResultCode_ErrorNotBankLoaded, + ResultCode_ErrorNotWsdLoaded, + ResultCode_ErrorNotWarcLoaded, + ResultCode_ErrorNotEnoughPlayerHeap, + ResultCode_ErrorCannotOpenFile, + ResultCode_ErrorNotAvailable, + ResultCode_ErrorCannotAllocateTrack, + ResultCode_ErrorNotEnoughInstance, + ResultCode_ErrorInvalidParameter, + ResultCode_ErrorInvalidSequenceStartLocationLabel, + ResultCode_ErrorActorNotInitialized, + ResultCode_ErrorInvalidWarcId, + ResultCode_ErrorInvalidBankData, + ResultCode_ErrorInvalidStreamFileId, + ResultCode_ErrorInvalidStreamFilePath, + + ResultCode_ErrorUser = 0x80, + ResultCode_ErrorUnknown = 0xff, + }; + + ResultCode m_Code; + }; + + virtual ~SoundStartable() = 0; + + virtual StartResult detail_SetupSound(SoundHandle* handle, + u32 soundId, bool holdFlag, + const char* soundArchiveName, + const StartInfo* startInfo) = 0; + virtual SoundArchive::ItemId detail_GetItemId(char* pString) = 0; + virtual SoundArchive::ItemId detail_GetItemId(char* pString, const char* soundArchiveName) = 0; + + StartResult StartSound(SoundHandle* handle, u32 soundId, + const char* soundArchiveName, const StartInfo* startInfo); + StartResult StartSound(SoundHandle* handle, u32 soundId, const StartInfo* startInfo); + StartResult StartSound(SoundHandle* handle, const char* pString, + const char* soundArchiveName, const StartInfo* startInfo); + StartResult StartSound(SoundHandle* handle, const char* soundArchiveName, + const StartInfo* startInfo); + + StartResult HoldSound(SoundHandle* handle, u32 soundId, const char* soundArchiveName, + const StartInfo* startInfo); + StartResult HoldSound(SoundHandle* handle, u32 soundId, const StartInfo* startInfo); + StartResult HoldSound(SoundHandle* handle, const char* pString, const StartInfo* startInfo); + StartResult HoldSound(SoundHandle* handle, const char* pString, const char* soundArchiveName, + const StartInfo* startInfo); + + StartResult PrepareSound(SoundHandle* handle, u32 soundId, const char* soundArchiveName, + const StartInfo* startInfo); + StartResult PrepareSound(SoundHandle* handle, u32 soundId, const StartInfo* startInfo); + StartResult PrepareSound(SoundHandle* handle, const char* pString, + const char* soundArchiveName, const StartInfo* startInfo); + StartResult PrepareSound(SoundHandle* handle, const char* soundArchiveName, + const StartInfo* startInfo); +}; +static_assert(sizeof(SoundStartable) == 0x8); +} // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/fnd/os/atkfnd_Thread.h b/include/nn/atk/fnd/os/atkfnd_Thread.h index c8247a3e..fc879c47 100644 --- a/include/nn/atk/fnd/os/atkfnd_Thread.h +++ b/include/nn/atk/fnd/os/atkfnd_Thread.h @@ -11,38 +11,38 @@ class Thread { enum AffinityMask { AffinityMask_CoreAll = -1, AffinityMask_CoreDefault, - AffinityMask_Core0, - AffinityMask_Core1 = AffinityMask_Core0 * 2, - AffinityMask_Core2 = AffinityMask_Core1 * 2, - AffinityMask_Core3 = AffinityMask_Core2 * 2, - AffinityMask_Core4 = AffinityMask_Core3 * 2, - AffinityMask_Core5 = AffinityMask_Core4 * 2, - AffinityMask_Core6 = AffinityMask_Core5 * 2, - AffinityMask_Core7 = AffinityMask_Core6 * 2, - AffinityMask_Core8 = AffinityMask_Core7 * 2, - AffinityMask_Core9 = AffinityMask_Core8 * 2, - AffinityMask_Core10 = AffinityMask_Core9 * 2, - AffinityMask_Core11 = AffinityMask_Core10 * 2, - AffinityMask_Core12 = AffinityMask_Core11 * 2, - AffinityMask_Core13 = AffinityMask_Core12 * 2, - AffinityMask_Core14 = AffinityMask_Core13 * 2, - AffinityMask_Core15 = AffinityMask_Core14 * 2, - AffinityMask_Core16 = AffinityMask_Core15 * 2, - AffinityMask_Core17 = AffinityMask_Core16 * 2, - AffinityMask_Core18 = AffinityMask_Core17 * 2, - AffinityMask_Core19 = AffinityMask_Core18 * 2, - AffinityMask_Core20 = AffinityMask_Core19 * 2, - AffinityMask_Core21 = AffinityMask_Core20 * 2, - AffinityMask_Core22 = AffinityMask_Core21 * 2, - AffinityMask_Core23 = AffinityMask_Core22 * 2, - AffinityMask_Core24 = AffinityMask_Core23 * 2, - AffinityMask_Core25 = AffinityMask_Core24 * 2, - AffinityMask_Core26 = AffinityMask_Core25 * 2, - AffinityMask_Core27 = AffinityMask_Core26 * 2, - AffinityMask_Core28 = AffinityMask_Core27 * 2, - AffinityMask_Core29 = AffinityMask_Core28 * 2, - AffinityMask_Core30 = AffinityMask_Core29 * 2, - AffinityMask_Core31 = -AffinityMask_Core30 * 2, + AffinityMask_Core0 = 1 << 0, + AffinityMask_Core1 = 1 << 1, + AffinityMask_Core2 = 1 << 2, + AffinityMask_Core3 = 1 << 3, + AffinityMask_Core4 = 1 << 4, + AffinityMask_Core5 = 1 << 5, + AffinityMask_Core6 = 1 << 6, + AffinityMask_Core7 = 1 << 7, + AffinityMask_Core8 = 1 << 8, + AffinityMask_Core9 = 1 << 9, + AffinityMask_Core10 = 1 << 10, + AffinityMask_Core11 = 1 << 11, + AffinityMask_Core12 = 1 << 12, + AffinityMask_Core13 = 1 << 13, + AffinityMask_Core14 = 1 << 14, + AffinityMask_Core15 = 1 << 15, + AffinityMask_Core16 = 1 << 16, + AffinityMask_Core17 = 1 << 17, + AffinityMask_Core18 = 1 << 18, + AffinityMask_Core19 = 1 << 19, + AffinityMask_Core20 = 1 << 20, + AffinityMask_Core21 = 1 << 21, + AffinityMask_Core22 = 1 << 22, + AffinityMask_Core23 = 1 << 23, + AffinityMask_Core24 = 1 << 24, + AffinityMask_Core25 = 1 << 25, + AffinityMask_Core26 = 1 << 26, + AffinityMask_Core27 = 1 << 27, + AffinityMask_Core28 = 1 << 28, + AffinityMask_Core29 = 1 << 29, + AffinityMask_Core30 = 1 << 30, + AffinityMask_Core31 = 1 << 31, }; enum FsPriority { From 4ee238dfd4ea01ea94284c452876b15fbdf2f5e8 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 18:55:14 -0300 Subject: [PATCH 088/785] atk: Define `detail::StartInfoReader` --- include/nn/atk/detail/atk_StartInfoReader.h | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/include/nn/atk/detail/atk_StartInfoReader.h b/include/nn/atk/detail/atk_StartInfoReader.h index e69de29b..a5e57d67 100644 --- a/include/nn/atk/detail/atk_StartInfoReader.h +++ b/include/nn/atk/detail/atk_StartInfoReader.h @@ -0,0 +1,30 @@ +#pragma once + +#include + +namespace nn::atk::detail { +class StartInfoReader { +public: + explicit StartInfoReader(const SoundArchive::SoundInfo& soundInfo); + + void Read(const SoundStartable::StartInfo* startInfo); + +private: + SoundStartable::StartInfo::StartOffsetType m_StartOffsetType; + s32 m_StartOffset; + s32 m_DelayTime; + s32 m_DelayCount; + UpdateType m_UpdateType; + s32 m_PlayerPriority; + SoundArchive::ItemId m_PlayerId; + s32 m_ActorPlayerId; + SoundStartable::StartInfo::SequenceSoundInfo* m_pSeqInfo; + SoundStartable::StartInfo::StreamSoundInfo* m_pStrmInfo; + SoundArchive::StreamSoundInfo* m_pStrmMetaInfo; + SoundArchive::StreamSoundInfo2* m_pStrmMetaInfo2; + SoundStartable::StartInfo::WaveSoundInfo* m_pWsdInfo; + s32 m_SubMixIndex; + OutputReceiver* m_pOutputReceiver; +}; +static_assert(sizeof(StartInfoReader) == 0x58); +} // namespace nn::atk::detail \ No newline at end of file From e42c65375ebf51d8730eb5853b8c49eee00ccf6e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 19:01:42 -0300 Subject: [PATCH 089/785] atk: Redefine `detail::AdvancedWaveSoundRuntime` --- include/nn/atk/detail/atk_AdvancedWaveSound.h | 2 + .../atk/detail/atk_AdvancedWaveSoundRuntime.h | 50 +++++++++++++------ 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/include/nn/atk/detail/atk_AdvancedWaveSound.h b/include/nn/atk/detail/atk_AdvancedWaveSound.h index 1b9d0b33..7f1776d1 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSound.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSound.h @@ -29,6 +29,8 @@ class AdvancedWaveSound : BasicSound { driver::BasicSoundPlayer* GetBasicSoundPlayerHandle(); private: + friend AdvancedWaveSoundInstanceManager; + util::IntrusiveListNode m_PriorityLink; AdvancedWaveSoundHandle* m_pTempSpecialHandle; AdvancedWaveSoundInstanceManager* m_InstanceManager; diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h b/include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h index 9807b84d..99197a1a 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h @@ -1,28 +1,50 @@ -/** - * @file AdvancedWaveSoundRuntime.h - * @brief Runtime wave sound api. - */ - #pragma once #include -namespace nn { -namespace atk { -namespace detail { +#include +#include +#include +#include +#include + +namespace nn::atk::detail { class AdvancedWaveSoundRuntime { public: AdvancedWaveSoundRuntime(); ~AdvancedWaveSoundRuntime(); - void Initialize(s32, void**, void const*); + void Initialize(s32 soundCount, void** pOutAllocatedAddr, const void* endAddr); void Finalize(); + + static std::size_t GetRequiredMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, + std::size_t alignmentSize); + + s32 GetActiveCount() const; - void SetupUserParam(void**, u64); + s32 GetFreeAdvancedWaveSoundCount() const; + + void SetupUserParam(void** startAddr, std::size_t adjustSize); + void Update(); - u8 _0[0x30]; + AdvancedWaveSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, + s32 ambientPriority, BasicSound::AmbientInfo* ambientArgInfo); + AdvancedWaveSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, + s32 ambientPriority, BasicSound::AmbientInfo* ambientArgInfo, + OutputReceiver* pOutputReceiver); + + SoundStartable::StartResult PrepareImpl(const SoundArchive* pSoundArchive, + const SoundDataManager* pSoundDataManager, + SoundArchive::ItemId soundId, + AdvancedWaveSound* sound, + const SoundArchive::SoundInfo* commonInfo, + const StartInfoReader& startInfoReader); + + void DumpMemory(const SoundArchive*) const; + +private: + AdvancedWaveSoundInstanceManager m_InstanceManager; }; -} // namespace detail -} // namespace atk -} // namespace nn +static_assert(sizeof(AdvancedWaveSoundRuntime) == 0x38); +} // namespace nn::atk::detail From 9e3426bb258b07bde37bb8091db5731e1eebf7c8 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 19:15:06 -0300 Subject: [PATCH 090/785] atk: Define `detail::driver::DisposeCallbackManager` --- include/nn/atk/detail/atk_DisposeCallback.h | 2 ++ .../atk/detail/atk_DisposeCallbackManager.h | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/nn/atk/detail/atk_DisposeCallback.h b/include/nn/atk/detail/atk_DisposeCallback.h index 8a6d14cc..a71f557a 100644 --- a/include/nn/atk/detail/atk_DisposeCallback.h +++ b/include/nn/atk/detail/atk_DisposeCallback.h @@ -10,6 +10,8 @@ class DisposeCallback { virtual void InvalidateData(const void* start, const void* end) = 0; private: + friend class DisposeCallbackManager; + util::IntrusiveListNode m_DisposeLink; }; static_assert(sizeof(DisposeCallback) == 0x18); diff --git a/include/nn/atk/detail/atk_DisposeCallbackManager.h b/include/nn/atk/detail/atk_DisposeCallbackManager.h index e69de29b..ebcc4757 100644 --- a/include/nn/atk/detail/atk_DisposeCallbackManager.h +++ b/include/nn/atk/detail/atk_DisposeCallbackManager.h @@ -0,0 +1,27 @@ +#pragma once + +#include + +#include + +namespace nn::atk::detail::driver { +class DisposeCallbackManager { +public: + using CallbackList = util::IntrusiveList>; + + DisposeCallbackManager(); + + void RegisterDisposeCallback(DisposeCallback* callback); + void UnregisterDisposeCallback(DisposeCallback* callback); + + u64 GetCallbackCount() const; + + void Dispose(const void* mem, std::size_t size); + +private: + CallbackList m_CallbackList; +}; +static_assert(sizeof(DisposeCallbackManager) == 0x10); +} // namespace nn::atk::detail \ No newline at end of file From 36569db9d5c8b8a952a5572faecea970cce20dda Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 19:23:02 -0300 Subject: [PATCH 091/785] atk: Define `detail::GroupFileReader` --- include/nn/atk/detail/atk_GroupFileReader.h | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/include/nn/atk/detail/atk_GroupFileReader.h b/include/nn/atk/detail/atk_GroupFileReader.h index e69de29b..a3d5cdc9 100644 --- a/include/nn/atk/detail/atk_GroupFileReader.h +++ b/include/nn/atk/detail/atk_GroupFileReader.h @@ -0,0 +1,30 @@ +#pragma once + +#include + +namespace nn::atk::detail { +struct GroupItemLocationInfo { + u32 fileId; + void* address; +}; +static_assert(sizeof(GroupItemLocationInfo) == 0x10); + +class GroupFileReader { +public: + constexpr static u64 SignatureFile = 0x50524746; // FGRP + + explicit GroupFileReader(const void* groupFile); + + bool ReadGroupItemLocationInfo(GroupItemLocationInfo* out, u32 index) const; + + u32 GetGroupItemExCount() const; + + bool ReadGroupItemInfoEx(GroupFile::GroupItemInfoEx* out, u32 index) const; + +private: + GroupFile::InfoBlockBody* m_pInfoBlockBody; + GroupFile::FileBlockBody* m_pFileBlockBody; + GroupFile::InfoExBlockBody* m_pInfoExBlockBody; +}; +static_assert(sizeof(GroupFileReader) == 0x18); +} // namespace nn::atk::detail \ No newline at end of file From bfd7c769b3b5ddc4e0985381f4865258d01040f0 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 19:31:49 -0300 Subject: [PATCH 092/785] atk: Define `detail::IntrusiveList` --- include/nn/atk/detail/atk_IntrusiveList.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/nn/atk/detail/atk_IntrusiveList.h b/include/nn/atk/detail/atk_IntrusiveList.h index e69de29b..def3e50e 100644 --- a/include/nn/atk/detail/atk_IntrusiveList.h +++ b/include/nn/atk/detail/atk_IntrusiveList.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +namespace nn::atk::detail { +using IntrusiveListNode = util::IntrusiveListNode; + +template +class IntrusiveList { +public: + using ElementList = util::IntrusiveList>; + using Iterator = typename ElementList::iterator; + using ConstIterator = typename ElementList::const_iterator; + +private: + ElementList m_ListImpl; +}; +} // namespace nn::atk::detail \ No newline at end of file From c1f267a0c355856b90bdaeea412ecf90e339b5db Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 19:38:09 -0300 Subject: [PATCH 093/785] atk: Define `detail::IStreamDataDecoder` --- .../nn/atk/detail/atk_IStreamDataDecoder.h | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/include/nn/atk/detail/atk_IStreamDataDecoder.h b/include/nn/atk/detail/atk_IStreamDataDecoder.h index e69de29b..7487f856 100644 --- a/include/nn/atk/detail/atk_IStreamDataDecoder.h +++ b/include/nn/atk/detail/atk_IStreamDataDecoder.h @@ -0,0 +1,47 @@ +#pragma once + +#include + +#include + +namespace nn::atk::detail { +namespace driver { +class StreamSoundPlayer; +} // namespace nn::atk::detail::driver + +class IStreamDataDecoder { +public: + enum DecodeType { + DecodeType_Normal, + DecodeType_Loop, + DecodeType_Idling, + DecodeType_Count + }; + + struct DataInfo { + s32 channelCount; + s32 sampleRate; + s32 blockSampleCount; + std::size_t blockSize; + }; + static_assert(sizeof(DataInfo) == 0x18); + + struct DecodeProfile { + os::Tick decodeTick; + s32 decodedSampleCount; + os::Tick fsAccessTick; + std::size_t fsReadSize; + }; + static_assert(sizeof(DecodeProfile) == 0x20); + + struct CacheProfile { + position_t cacheStartPosition; + std::size_t cachedLength; + position_t cacheCurrentPosition; + driver::StreamSoundPlayer* player; + }; + static_assert(sizeof(CacheProfile) == 0x20); + + virtual ~IStreamDataDecoder(); +}; +} // namespace nn::atk::detail \ No newline at end of file From cfb024400b6ccd107f151b00c64c4a03f7e21023 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 19:39:21 -0300 Subject: [PATCH 094/785] atk: Define `ItemType` enum --- include/nn/atk/detail/atk_ItemType.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/nn/atk/detail/atk_ItemType.h b/include/nn/atk/detail/atk_ItemType.h index e69de29b..574f6ca7 100644 --- a/include/nn/atk/detail/atk_ItemType.h +++ b/include/nn/atk/detail/atk_ItemType.h @@ -0,0 +1,12 @@ +#pragma once + +namespace nn::atk::detail { +enum ItemType { + ItemType_Sound = 1, + ItemType_SoundGroup, + ItemType_Bank, + ItemType_Player, + ItemType_WaveArchive, + ItemType_Group, +}; +} // namespace nn::atk::detail \ No newline at end of file From a13b38182982eaa09e78056c0ed8ebee2f78c541 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 19:53:39 -0300 Subject: [PATCH 095/785] atk: Define `detail::LoaderManager` Other changes: - Added virtual functions to `detail::driver::SoundThread::SoundFrameCallback` --- include/nn/atk/detail/atk_LoaderManager.h | 26 +++++++++++++++++++ include/nn/atk/detail/atk_MoveValue.h | 2 -- .../nn/atk/detail/thread/atk_SoundThread.h | 3 ++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/include/nn/atk/detail/atk_LoaderManager.h b/include/nn/atk/detail/atk_LoaderManager.h index e69de29b..705da2db 100644 --- a/include/nn/atk/detail/atk_LoaderManager.h +++ b/include/nn/atk/detail/atk_LoaderManager.h @@ -0,0 +1,26 @@ +#pragma once + +#include + +namespace nn::atk::detail { +template +class LoaderManager : driver::SoundThread::SoundFrameCallback { +public: + using List = util::IntrusiveList>; + using Iterator = typename List::iterator; + + LoaderManager(); + ~LoaderManager() override; + + void OnBeginSoundFrame() override; + + void Destroy(); + +private: + void* m_pBuffer; + std::size_t m_BufferSize; + List m_FreeList; + List m_FreeReqList; +}; + +} // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/atk_MoveValue.h b/include/nn/atk/detail/atk_MoveValue.h index e995a92e..0a8ea461 100644 --- a/include/nn/atk/detail/atk_MoveValue.h +++ b/include/nn/atk/detail/atk_MoveValue.h @@ -1,7 +1,5 @@ #pragma once -#include - namespace nn::atk::detail { template class MoveValue { diff --git a/include/nn/atk/detail/thread/atk_SoundThread.h b/include/nn/atk/detail/thread/atk_SoundThread.h index 629f9b6a..f1585588 100644 --- a/include/nn/atk/detail/thread/atk_SoundThread.h +++ b/include/nn/atk/detail/thread/atk_SoundThread.h @@ -33,7 +33,8 @@ class SoundThread : fnd::Thread::Handler { public: virtual ~SoundFrameCallback(); - void OnEndSoundFrame(); + virtual void OnBeginSoundFrame(); + virtual void OnEndSoundFrame(); private: friend SoundThread; From 0939c4dac0b23e685acf3dd579bc7174fbef0a7b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 20:10:00 -0300 Subject: [PATCH 096/785] atk: Redefine `detail::SoundArchiveManager` --- .../detail/atk_AddonSoundArchiveContainer.h | 3 +- .../nn/atk/detail/atk_SoundArchiveManager.h | 72 +++++++++++-------- 2 files changed, 43 insertions(+), 32 deletions(-) diff --git a/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h b/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h index 24fe6d57..51780d12 100644 --- a/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h +++ b/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h @@ -26,8 +26,9 @@ class AddonSoundArchiveContainer { void SetAddTick(const os::Tick& addTick); -private: util::IntrusiveListNode m_ElementLink; + +private: bool m_IsActive; u8 m_Padding[3]; SoundArchive* m_pSoundArchive; diff --git a/include/nn/atk/detail/atk_SoundArchiveManager.h b/include/nn/atk/detail/atk_SoundArchiveManager.h index e96b93e3..1be2e523 100644 --- a/include/nn/atk/detail/atk_SoundArchiveManager.h +++ b/include/nn/atk/detail/atk_SoundArchiveManager.h @@ -1,42 +1,52 @@ -/** - * @file SoundArchiveManager.h - * @brief Sound archive manager implementation. - */ - #pragma once -#include - -namespace nn { -namespace atk { -class SoundHandle; -class SoundArchive; -class SoundDataManager; - -namespace detail { -class AddonSoundArchiveContainer; +#include +#include +#include +#include +namespace nn::atk::detail { class SoundArchiveManager { public: + using ContainerList = IntrusiveList; + + class Snapshot { + public: + private: + SoundArchive* m_MainSoundArchive; + SoundDataManager* m_MainSoundDataManager; + SoundArchive* m_CurrentSoundArchive; + SoundDataManager* m_CurrentSoundDataManager; + }; + SoundArchiveManager(); + ~SoundArchiveManager(); + + void Initialize(const SoundArchive* pSoundArchive, const SoundDataManager* pSoundDataManager); - virtual ~SoundArchiveManager(); + void ChangeTargetArchive(const char* soundArchiveName); - void Initialize(nn::atk::SoundArchive const*, nn::atk::SoundDataManager const*); - void ChangeTargetArchive(char const*); void Finalize(); + + void Add(AddonSoundArchiveContainer&); + void Remove(AddonSoundArchiveContainer&); + bool IsAvailable() const; - nn::atk::detail::AddonSoundArchiveContainer* GetAddonSoundArchive(char const*) const; - - u64 _8; - u64* _10; - nn::atk::detail::AddonSoundArchiveContainer* _18; - u64* _20; - nn::atk::SoundArchive* mSoundArchive; // _28 - u64 _30; - u64 _38; - u64 _40; + + AddonSoundArchive* GetAddonSoundArchive(const char*) const; + SoundDataManager* GetAddonSoundDataManager(const char*) const; + AddonSoundArchiveContainer* GetAddonSoundArchiveContainer(s32) const; + AddonSoundArchiveContainer* GetAddonSoundArchiveContainer(s32); + + void SetParametersHook(SoundArchiveParametersHook*); + +private: + SoundArchive* m_pMainSoundArchive; + SoundDataManager* m_pMainSoundDataManager; + ContainerList m_ContainerList; + SoundArchive* m_pCurrentSoundArchive; + SoundDataManager* m_pCurrentSoundDataManager; + SoundArchiveParametersHook* m_pParametersHook; }; -} // namespace detail -} // namespace atk -} // namespace nn +static_assert(sizeof(SoundArchiveManager) == 0x38); +} // namespace nn::atk::detail From ee58b8e06d245606b08f137aae3b161ef9e3f92c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 20:12:40 -0300 Subject: [PATCH 097/785] atk: Declare `detail::SoundRuntimeUtility` --- include/nn/atk/detail/atk_SoundRuntimeUtility.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/nn/atk/detail/atk_SoundRuntimeUtility.h b/include/nn/atk/detail/atk_SoundRuntimeUtility.h index e69de29b..6f3504d2 100644 --- a/include/nn/atk/detail/atk_SoundRuntimeUtility.h +++ b/include/nn/atk/detail/atk_SoundRuntimeUtility.h @@ -0,0 +1,5 @@ +#pragma once + +namespace nn::atk::detail { +class SoundRuntimeUtility {}; +} // namespace nn::atk::detail \ No newline at end of file From 82be6ac0948696b2f31465ba67f77e9101121533 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 20:27:41 -0300 Subject: [PATCH 098/785] atk: Define `atk_WavBinary.h` header --- include/nn/atk/detail/atk_WavBinary.h | 42 +++++++++++++++++++ .../nn/atk/fnd/basis/atkfnd_PrimitiveTypes.h | 8 ++++ 2 files changed, 50 insertions(+) diff --git a/include/nn/atk/detail/atk_WavBinary.h b/include/nn/atk/detail/atk_WavBinary.h index e69de29b..0bea0947 100644 --- a/include/nn/atk/detail/atk_WavBinary.h +++ b/include/nn/atk/detail/atk_WavBinary.h @@ -0,0 +1,42 @@ +#pragma once + +#include + +#include + +namespace nn::atk::detail { +struct ChunkHeader { + u32 id; + fnd::PcBinU32 size; +}; +static_assert(sizeof(ChunkHeader) == 0x8); + +struct RiffChunk { + ChunkHeader header; + u32 formatType; +}; +static_assert(sizeof(RiffChunk) == 0xc); + +struct FmtChunk { + ChunkHeader header; + fnd::PcBinU16 formatTag; + fnd::PcBinU16 channels; + fnd::PcBinU32 samplesPerSec; + fnd::PcBinU32 avgBytesPerSec; + fnd::PcBinU16 blockAlign; + fnd::PcBinU16 bitsPerSample; +}; +static_assert(sizeof(FmtChunk) == 0x18); + +struct DataChunk { + ChunkHeader header; +}; +static_assert(sizeof(DataChunk) == 0x8); + +struct WaveBinaryHeader { + RiffChunk riffChunk; + FmtChunk fmtChunk; + DataChunk dataChunk; +}; +static_assert(sizeof(WaveBinaryHeader) == 0x2c); +} // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/fnd/basis/atkfnd_PrimitiveTypes.h b/include/nn/atk/fnd/basis/atkfnd_PrimitiveTypes.h index e69de29b..ab767f25 100644 --- a/include/nn/atk/fnd/basis/atkfnd_PrimitiveTypes.h +++ b/include/nn/atk/fnd/basis/atkfnd_PrimitiveTypes.h @@ -0,0 +1,8 @@ +#pragma once + +#include + +namespace nn::atk::detail::fnd { +using PcBinU16 = std::uint16_t; +using PcBinU32 = std::uint32_t; +} // namespace nn::atk::detail::fnd \ No newline at end of file From 5e129777c53be3217ca812e59936b6a4af38d7d6 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 20:35:17 -0300 Subject: [PATCH 099/785] atk: Define `detail::DspadpcmReader` --- include/nn/atk/detail/dsp/atk_DspadpcmReader.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/nn/atk/detail/dsp/atk_DspadpcmReader.h b/include/nn/atk/detail/dsp/atk_DspadpcmReader.h index e69de29b..5af01154 100644 --- a/include/nn/atk/detail/dsp/atk_DspadpcmReader.h +++ b/include/nn/atk/detail/dsp/atk_DspadpcmReader.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +namespace nn::atk::detail { +class DspadpcmReader { +public: + DspadpcmReader(); + + bool ReadWaveInfo(WaveInfo* info); + +private: + void* m_pDspadpcmData; +}; +} // namespace nn::atk::detail \ No newline at end of file From c1bd09611e45c927ef36b20116433d57ac1d9320 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 21:28:04 -0300 Subject: [PATCH 100/785] atk: Define `detail::WaveFileReader` --- include/nn/atk/detail/atk_GroupFileReader.h | 2 +- include/nn/atk/detail/atk_WaveFileReader.h | 29 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/detail/atk_GroupFileReader.h b/include/nn/atk/detail/atk_GroupFileReader.h index a3d5cdc9..1f4eba2e 100644 --- a/include/nn/atk/detail/atk_GroupFileReader.h +++ b/include/nn/atk/detail/atk_GroupFileReader.h @@ -11,7 +11,7 @@ static_assert(sizeof(GroupItemLocationInfo) == 0x10); class GroupFileReader { public: - constexpr static u64 SignatureFile = 0x50524746; // FGRP + constexpr static s64 SignatureFile = 0x50524746; // FGRP explicit GroupFileReader(const void* groupFile); diff --git a/include/nn/atk/detail/atk_WaveFileReader.h b/include/nn/atk/detail/atk_WaveFileReader.h index e69de29b..31c1bd0e 100644 --- a/include/nn/atk/detail/atk_WaveFileReader.h +++ b/include/nn/atk/detail/atk_WaveFileReader.h @@ -0,0 +1,29 @@ +#pragma once + +#include +#include + +namespace nn::atk::detail { +class WaveFileReader { +public: + constexpr static s32 SignatureFile = 0x56415746; // FWAV + + static SampleFormat GetSampleFormat(u8 format); + + WaveFileReader(void* waveFile, s8 waveType); + + bool IsOriginalLoopAvailable() const; + + bool ReadWaveInfo(WaveInfo* info, const void* waveDataOffsetOrigin) const; + + void* GetWaveDataAddress(const WaveFile::ChannelInfo* channelInfo, const void*) const; + +private: + WaveFile::FileHeader* m_pHeader; + WaveFile::InfoBlockBody* m_pInfoBlockBody; + void* m_pDataBlockBody; + DspadpcmReader m_DspadpcmReader; + s8 m_WaveType; +}; +static_assert(sizeof(WaveFileReader) == 0x28); +} // namespace nn::atk::detail \ No newline at end of file From 74fd04c613787fa8083e38e8e04fb5d2030875d0 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 21:40:57 -0300 Subject: [PATCH 101/785] atk: Define `detail::WavOutFileStream` --- include/nn/atk/detail/atk_WavOutFileStream.h | 42 ++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/include/nn/atk/detail/atk_WavOutFileStream.h b/include/nn/atk/detail/atk_WavOutFileStream.h index e69de29b..bc48d62f 100644 --- a/include/nn/atk/detail/atk_WavOutFileStream.h +++ b/include/nn/atk/detail/atk_WavOutFileStream.h @@ -0,0 +1,42 @@ +#pragma once + +#include +#include + +namespace nn::atk::detail { +class WavOutFileStream { +public: + constexpr static u8 FileIoBufferAlignment = 8; + + WavOutFileStream(); + ~WavOutFileStream(); + + bool Open(fnd::FileStream& stream, s32, u64); + + bool WriteHeader(s32, u64); + + void Close(); + + bool FlushBuffer(); + + u64 CalcRiffChunkSize(u64); + + bool UpdateRiffChunkSize(); + bool UpdateDataChunkSize(); + + std::size_t Write(const void* buffer, std::size_t size); + std::size_t WriteDirect(const void* buf, std::size_t length, fnd::FndResult* result); + + bool Seek(position_t offset, fnd::Stream::SeekOrigin origin); + + void SetCacheBuffer(char* cacheBuffer, std::size_t cacheBufferSize); + +private: + fnd::FileStream* m_pFileStream; + std::size_t m_WaveDataSize; + bool m_IsWaveDataSizeCalculating; + char* m_Buffer; + std::size_t m_BufferLength; + std::size_t m_ValidBufferLength; +}; +} // namespace nn::atk::detail \ No newline at end of file From 6282eb1eb6028cbd6d1f440d84921dd4e60740d9 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 21:49:37 -0300 Subject: [PATCH 102/785] atk: Define `detail::driver::MmlCommand` --- include/nn/atk/detail/seq/atk_MmlCommand.h | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/include/nn/atk/detail/seq/atk_MmlCommand.h b/include/nn/atk/detail/seq/atk_MmlCommand.h index e69de29b..6a9852cc 100644 --- a/include/nn/atk/detail/seq/atk_MmlCommand.h +++ b/include/nn/atk/detail/seq/atk_MmlCommand.h @@ -0,0 +1,79 @@ +#pragma once + +namespace nn::atk::detail::driver { +class MmlCommand { +public: + enum Mml { + Mml_Wait = 0x80, + Mml_Prg, + + Mml_OpenTrack = 0x88, + Mml_Jump, + Mml_Call, + + Mml_Random = 0xa0, + Mml_Variable, + Mml_If, + Mml_Time, + Mml_TimeRandom, + Mml_TimeVariable, + + Mml_Timebase = 0xb0, + Mml_EnvHold, + Mml_Monophonic, + Mml_VelocityRange, + Mml_BiquadType, + Mml_BiquadValue, + Mml_BankSelect, + + Mml_ModPhase = 0xbd, + Mml_ModCurve, + Mml_FrontBypass, + Mml_Pan, + Mml_Volume, + Mml_MainVolume, + Mml_Transpose, + Mml_PitchBend, + Mml_BendRange, + Mml_Prio, + Mml_NoteWait, + Mml_Tie, + Mml_Porta, + Mml_ModDepth, + Mml_ModSpeed, + Mml_ModType, + Mml_ModRange, + Mml_PortaSw, + Mml_PortaTime, + Mml_Attack, + Mml_Decay, + Mml_Sustain, + Mml_Release, + Mml_LoopStart, + Mml_Volume2, + Mml_Printvar, + Mml_SurroundPan, + Mml_LpfCutoff, + Mml_FxsendA, + Mml_FxsendB, + Mml_Mainsend, + Mml_InitPan, + Mml_Mute, + Mml_FxsendC, + Mml_Damper, + Mml_ModDelay, + Mml_Tempo, + + Mml_SweepPitch = 0xe3, + Mml_ModPeriod, + + Mml_ExCommand = 0xf0, + + Mml_EnvReset = 0xfb, + Mml_LoopEnd, + Mml_Ret, + Mml_AllocTrack, + Mml_Fin, + }; +}; +} // namespace nn::atk::detail::driver \ No newline at end of file From f2d2f290f70218e10cde906d2708921cfb63bbfe Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 22:28:07 -0300 Subject: [PATCH 103/785] atk: Define `detail::StreamSoundFileReader` --- .../detail/strm/atk_StreamSoundFileReader.h | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/include/nn/atk/detail/strm/atk_StreamSoundFileReader.h b/include/nn/atk/detail/strm/atk_StreamSoundFileReader.h index e69de29b..7119bb9e 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundFileReader.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundFileReader.h @@ -0,0 +1,28 @@ +#pragma once + +#include + +namespace nn::atk::detail { +class StreamSoundFileReader { +public: + StreamSoundFileReader(); + + void Initialize(const void* streamSoundFile); + + bool IsValidFileHeader(const void* streamSoundFile) const; + + bool IsTrackInfoAvailable() const; + bool IsCrc32CheckAvailable() const; + bool IsRegionIndexCheckAvailable() const; + + bool ReadStreamSoundInfo(StreamSoundFile::StreamSoundInfo* strmInfo) const; + bool ReadStreamTrackInfo(StreamSoundFile::TrackInfo* pTrackInfo, s32 trackIndex) const; + bool ReadDspAdpcmChannelInfo(DspAdpcmParam* pParam, DspAdpcmLoopParam* pLoopParam, + s32 channelIndex) const; + +private: + StreamSoundFile::FileHeader* m_pHeader; + StreamSoundFile::InfoBlockBody* m_pInfoBlockBody; +}; +static_assert(sizeof(StreamSoundFileReader) == 0x10); +} // namespace nn::atk::detail \ No newline at end of file From 7d98b58d527055560f8bcf6a1fcb4d60ee6bb664 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 22:32:09 -0300 Subject: [PATCH 104/785] atk: Define `detail::StreamSoundFileLoader` --- .../nn/atk/detail/atk_IRegionInfoReadable.h | 4 +++ .../detail/strm/atk_StreamSoundFileLoader.h | 25 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/nn/atk/detail/atk_IRegionInfoReadable.h b/include/nn/atk/detail/atk_IRegionInfoReadable.h index 8743fda9..f0f5ca70 100644 --- a/include/nn/atk/detail/atk_IRegionInfoReadable.h +++ b/include/nn/atk/detail/atk_IRegionInfoReadable.h @@ -1,9 +1,13 @@ #pragma once +#include + namespace nn::atk::detail { class IRegionInfoReadable { public: virtual ~IRegionInfoReadable() = default; + virtual bool ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo, + u32 regionIndex) const = 0; }; static_assert(sizeof(IRegionInfoReadable) == 0x8); } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/strm/atk_StreamSoundFileLoader.h b/include/nn/atk/detail/strm/atk_StreamSoundFileLoader.h index e69de29b..e925912b 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundFileLoader.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundFileLoader.h @@ -0,0 +1,25 @@ +#pragma once + +#include +#include +#include + +namespace nn::atk::detail { +class StreamSoundFileLoader : IRegionInfoReadable { +public: + StreamSoundFileLoader(); + ~StreamSoundFileLoader() override; + + bool LoadFileHeader(StreamSoundFileReader* reader, void* buffer, u64 size); + + bool ReadSeekBlockData(u16* yn1, u16 yn2, s32 blockIndex, s32 channelCount); + bool ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo, u32 regionIndex) const override; + +private: + fnd::FileStream* m_pStream; + u32 m_SeekBlockOffset; + u32 m_RegionDataOffset; + u16 m_RegionInfoBytes; +}; +static_assert(sizeof(StreamSoundFileLoader) == 0x20); +} // namespace nn::atk::detail \ No newline at end of file From 79cf6be26e3de7da2becb26dd534933af952df6d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 23:17:31 -0300 Subject: [PATCH 105/785] atk: Define `TaskProfile` and `TaskProfileLogger` --- include/nn/atk/util/atk_ProfileReader.h | 3 +- include/nn/atk/util/atk_TaskProfileReader.h | 106 ++++++++++++++++++++ 2 files changed, 108 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/util/atk_ProfileReader.h b/include/nn/atk/util/atk_ProfileReader.h index 5fb79e4d..1d443b51 100644 --- a/include/nn/atk/util/atk_ProfileReader.h +++ b/include/nn/atk/util/atk_ProfileReader.h @@ -61,7 +61,8 @@ using ProfileReaderList = util::IntrusiveList>; -class TaskProfile; +struct TaskProfile; + template class AtkProfileReader { public: diff --git a/include/nn/atk/util/atk_TaskProfileReader.h b/include/nn/atk/util/atk_TaskProfileReader.h index e69de29b..91ffaff0 100644 --- a/include/nn/atk/util/atk_TaskProfileReader.h +++ b/include/nn/atk/util/atk_TaskProfileReader.h @@ -0,0 +1,106 @@ +#pragma once + +#include +#include + +#include +#include +#include +#include + +namespace nn::atk { + +namespace detail::driver { +class StreamSoundPlayer; +} // namespace nn::atk::detail::driver + +struct TaskProfile { + enum TaskProfileType { + TaskProfileType_LoadStreamBlock, + TaskProfileType_LoadOpusStreamBlock, + }; + + class LoadStreamBlock { + public: + TimeSpan GetTotalTime() const; + u64 GetBeginTick() const; + u64 GetEndTick() const; + + void SetTick(const os::Tick& beginTick, const os::Tick& endTick); + void SetData(os::Tick* beginTick, os::Tick* endTick, + detail::IStreamDataDecoder::CacheProfile* cacheProfile); + + private: + u64 m_BeginTick; + u64 m_EndTick; + position_t m_CacheStartPosition; + std::size_t m_CachedLength; + position_t m_CacheCurrentPosition; + detail::driver::StreamSoundPlayer* m_pPlayer; + }; + static_assert(sizeof(LoadStreamBlock) == 0x30); + + class LoadOpusStreamBlock { + public: + TimeSpan GetTotalTime() const; + u64 GetBeginTick() const; + u64 GetEndTick() const; + TimeSpan GetDecodeTime() const; + s32 GetDecodedSampleCount() const; + TimeSpan GetFsAccessTime(); + std::size_t GetFsReadSize(); + + void SetData(os::Tick* beginTick, os::Tick* endTick, + detail::IStreamDataDecoder::DecodeProfile* decodeProfile); + void SetData(os::Tick* beginTick, os::Tick* endTick, + detail::IStreamDataDecoder::DecodeProfile* decodeProfile, + detail::IStreamDataDecoder::CacheProfile* cacheProfile); + + private: + u64 m_BeginTick; + u64 m_EndTick; + position_t m_CacheStartPosition; + std::size_t m_CachedLength; + position_t m_CacheCurrentPosition; + u64 m_DecodeTick; + u64 m_FsAccessTick; + std::size_t m_FsReadSize; + s32 m_DecodedSampleCount; + detail::driver::StreamSoundPlayer* m_pPlayer; + }; + static_assert(sizeof(LoadOpusStreamBlock) == 0x50); + + TaskProfileType type; + union { + LoadStreamBlock loadStreamBlock; + LoadOpusStreamBlock loadOpusStreamBlock; + }; +}; +static_assert(sizeof(TaskProfile) == 0x58); + +using TaskProfileReader = AtkProfileReader; + +class TaskProfileLogger { +public: + using TaskProfileReaderList = util::IntrusiveList>; + + TaskProfileLogger(); + + void Record(const TaskProfile& profile); + + void RegisterReader(TaskProfileReader& profileReader); + void UnregisterReader(const TaskProfileReader& profileReader); + + void SetProfilingEnabled(bool isEnabledProfiling); + + void Finalize(); + +private: + TaskProfileReaderList m_List; + detail::fnd::CriticalSection m_Lock; + bool m_IsProfilingEnabled; +}; +static_assert(sizeof(TaskProfileLogger) == 0x38); +} // namespace nn::atk \ No newline at end of file From 6b62b4c046fba793e4bd3c44e6678324a3c2b0f4 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 23:19:30 -0300 Subject: [PATCH 106/785] atk: Define `detail::Task` --- include/nn/atk/detail/thread/atk_Task.h | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/include/nn/atk/detail/thread/atk_Task.h b/include/nn/atk/detail/thread/atk_Task.h index e69de29b..03c062fd 100644 --- a/include/nn/atk/detail/thread/atk_Task.h +++ b/include/nn/atk/detail/thread/atk_Task.h @@ -0,0 +1,28 @@ +#pragma once + +#include + +namespace nn::atk::detail { +class Task { +public: + enum Status { + Status_Free, + Status_Append, + Status_Execute, + Status_Done, + Status_Cancel, + }; + + Task(); + + virtual ~Task(); + virtual void Execute(TaskProfileLogger& logger) = 0; + +private: + util::IntrusiveListNode m_TaskLink; + os::Event m_Event; + Status m_Status; + u32 m_Id; +}; +static_assert(sizeof(Task) == 0x48); +} // namespace nn::atk::detail \ No newline at end of file From 4c896cb4539d5dc7a5f0a0831f92f5b8813dc1d7 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 26 Feb 2026 23:37:44 -0300 Subject: [PATCH 107/785] atk: Define `detail::InstancePool` and `detail::BufferPool` --- include/nn/atk/detail/util/atk_InstancePool.h | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/include/nn/atk/detail/util/atk_InstancePool.h b/include/nn/atk/detail/util/atk_InstancePool.h index e69de29b..5478fb82 100644 --- a/include/nn/atk/detail/util/atk_InstancePool.h +++ b/include/nn/atk/detail/util/atk_InstancePool.h @@ -0,0 +1,31 @@ +#pragma once + +#include + +namespace nn::atk::detail { +class PoolImpl { +public: + s32 CreateImpl(void* buffer, std::size_t size, std::size_t objSize); + s32 CreateImpl(void* buffer, std::size_t size, std::size_t objSize, + std::size_t alignment); + + void DestroyImpl(); + + s32 CountImpl() const; + + void* AllocImpl(); + + void FreeImpl(void* ptr); + +private: + PoolImpl* m_pNext; + void* m_pBuffer; + std::size_t m_BufferSize; +}; +static_assert(sizeof(PoolImpl) == 0x18); + +class BufferPool : PoolImpl {}; + +template +class InstancePool : PoolImpl {}; +} // namespace nn::atk::detail \ No newline at end of file From f42cf62e6d9ce4e19b7a27a169e44a20cd9fc19b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 27 Feb 2026 09:42:37 -0300 Subject: [PATCH 108/785] atk: Define `detail::Command` --- include/nn/atk/detail/thread/atk_Command.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/nn/atk/detail/thread/atk_Command.h b/include/nn/atk/detail/thread/atk_Command.h index e69de29b..05134198 100644 --- a/include/nn/atk/detail/thread/atk_Command.h +++ b/include/nn/atk/detail/thread/atk_Command.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +namespace nn::atk::detail { +struct Command { + Command* next; + u32 id; + u32 tag; + std::uintptr_t memory_next; +}; +static_assert(sizeof(Command) == 0x18); +} // namespace nn::atk::detail \ No newline at end of file From b13f8bd7a5a6885921b42d57ef325903b73e9c6b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 27 Feb 2026 10:49:27 -0300 Subject: [PATCH 109/785] atk: Define `detail::driver::StreamSoundLoader` Other changes: - Also defined other structs present in `atk_StreamSoundLoader.h` --- .../atk/detail/strm/atk_StreamSoundLoader.h | 273 ++++++++++++++++++ 1 file changed, 273 insertions(+) diff --git a/include/nn/atk/detail/strm/atk_StreamSoundLoader.h b/include/nn/atk/detail/strm/atk_StreamSoundLoader.h index e69de29b..131b80dc 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundLoader.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundLoader.h @@ -0,0 +1,273 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace nn::atk::detail { +struct IStreamDataDecoderManager; +struct DriverCommandStreamSoundLoadHeader; +struct DriverCommandStreamSoundLoadData; + +struct TrackDataInfo { + u8 volume; + u8 pan; + u8 span; + u8 flags; + u8 mainSend; + u8 fxSend[3]; + u8 lpfFreq; + u8 biquadType; + u8 biquadValue; + u8 channelCount; + u8 channelIndex[2]; +}; +static_assert(sizeof(TrackDataInfo) == 0xe); + +struct TrackDataInfos { + TrackDataInfo track[8]; +}; +static_assert(sizeof(TrackDataInfos) == 0x70); + +struct StreamDataInfoDetail { + SampleFormat sampleFormat; + s32 sampleRate; + bool loopFlag; + position_t loopStart; + std::size_t sampleCount; + position_t originalLoopStart; + position_t originalLoopEnd; + bool isRevisionCheckEnabled; + bool isRegionIndexCheckEnabled; + u32 revisionValue; + std::size_t blockSampleCount; + std::size_t blockSize; + std::size_t lastBlockSize; + std::size_t lastBlockSampleCount; + s32 channelCount; + s32 trackCount; + TrackDataInfo trackInfo[8]; + s32 regionCount; +}; +static_assert(sizeof(StreamDataInfoDetail) == 0xd8); + +struct LoadDataParam { + u32 blockIndex; + std::size_t samples; + position_t sampleBegin; + position_t sampleOffset; + std::size_t sampleBytes; + bool adpcmContextEnable; + AdpcmContextNotAligned adpcmContext[16]; + s32 loopCount; + bool lastBlockFlag; + bool isStartOffsetOfLastBlockApplied; +}; +static_assert(sizeof(LoadDataParam) == 0x98); + +struct SoundArchiveFilesHook; +struct FileStreamHookParam { + SoundArchiveFilesHook* pSoundArchiveFilesHook; + char* itemLabel; +}; +static_assert(sizeof(FileStreamHookParam) == 0x10); + +namespace driver { +class StreamSoundPlayer; + +class StreamSoundLoader { +public: + class StreamHeaderLoadTask : Task { + public: + StreamHeaderLoadTask(); + ~StreamHeaderLoadTask() override; + + void Execute(TaskProfileLogger& logger) override; + + private: + StreamSoundLoader* m_pLoader; + }; + static_assert(sizeof(StreamHeaderLoadTask) == 0x50); + + class StreamCloseTask : Task { + public: + StreamCloseTask(); + ~StreamCloseTask() override; + + void Execute(TaskProfileLogger& logger) override; + + private: + StreamSoundLoader* m_pLoader; + }; + static_assert(sizeof(StreamCloseTask) == 0x50); + + class StreamDataLoadTask : Task { + public: + StreamDataLoadTask(); + ~StreamDataLoadTask() override; + + void Execute(TaskProfileLogger& logger) override; + + private: + friend StreamSoundLoader; + + void* m_BufferAddress[16]; + u32 m_BufferBlockIndex; + position_t m_StartOffsetSamples; + position_t m_PrefetchOffsetSamples; + StreamSoundLoader* m_pLoader; + util::IntrusiveListNode m_Link; + }; + static_assert(sizeof(StreamDataLoadTask) == 0xf8); + + using StreamDataLoadTaskList = util::IntrusiveList>; + + struct AdpcmInfo { + AdpcmParam param; + AdpcmContext beginContext; + AdpcmContext loopContext; + }; + static_assert(sizeof(AdpcmInfo) == 0xc0); + + struct BlockInfo { + std::size_t size; + std::size_t samples; + std::size_t startOffsetSamples; + std::size_t startOffsetSamplesAlign; + std::size_t startOffsetByte; + std::size_t copyByte; + + }; + static_assert(sizeof(BlockInfo) == 0x30); + + StreamSoundLoader(); + ~StreamSoundLoader(); + + void WaitFinalize(); + + void Initialize(); + void Finalize(); + + void CancelRequest(); + void RequestClose(); + + void* detail_SetFsAccessLog(fnd::FsAccessLog* pFsAccessLog); + + void RequestLoadHeader(); + void RequestLoadData(void** bufferAddress, u32 bufferBlockIndex, position_t startOffsetSamples, + position_t prefetchOffsetSamples, s32 priority); + + void Update(); + void ForceFinish(); + + bool IsBusy() const; + bool IsInUse(); + + fnd::FndResult Open(); + void Close(); + + void LoadHeader(); + bool LoadHeader1(DriverCommandStreamSoundLoadHeader* command); + bool LoadHeaderForOpus(DriverCommandStreamSoundLoadHeader* command, + StreamFileType type, DecodeMode decodeMode); + + bool ReadTrackInfoFromStreamSoundFile(StreamSoundFileReader& reader); + + bool SetAdpcmInfo(StreamSoundFileReader& reader, s32 channelCount, AdpcmParam** adpcmParam); + + void UpdateLoadingDataBlockIndex(); + + void SetStreamSoundInfoForOpus(const IStreamDataDecoder::DataInfo& dataInfo); + + void LoadData(void** bufferAddress, u32 bufferBlockIndex, std::size_t startOffsetSamples, + std::size_t prefetchOffsetSamples, TaskProfileLogger& logger); + bool LoadData1(DriverCommandStreamSoundLoadData* command, void** bufferAddress, + u32 bufferBlockIndex, std::size_t startOffsetSamples, + std::size_t prefetchOffsetSamples, TaskProfileLogger& logger); + bool LoadDataForOpus(DriverCommandStreamSoundLoadData* command, void** bufferAddress, + u32 bufferBlockIndex, std::size_t startOffsetSamples, + std::size_t prefetchOffsetSamples, TaskProfileLogger& logger); + + bool ApplyStartOffset(s64, s32*); + + void CalculateBlockInfo(BlockInfo&); + + bool LoadAdpcmContextForStartOffset(); + + bool LoadOneBlockDataViaCache(void** bufferAddress, const BlockInfo& blockInfo, + position_t destAddressOffset, bool firstBlock, + bool updateAdpcmContext); + bool LoadOneBlockData(void** bufferAddress, const BlockInfo& blockInfo, + position_t destAddressOffset, bool firstBlock, + bool updateAdpcmContext); + + bool MoveNextRegion(s32*); + + bool DecodeStreamData(void**, IStreamDataDecoder::DecodeType); + + void UpdateLoadingDataBlockIndexForOpus(void**); + + bool IsLoopStartFilePos(u32); + + s32 GetLoadChannelCount(s32); + + bool LoadStreamBuffer(u8*, const BlockInfo&, u32); + bool LoadStreamBuffer(u8*, u64); + + bool SkipStreamBuffer(u64); + + void UpdateAdpcmInfoForStartOffset(const void*, s32, const BlockInfo&); + +private: + StreamSoundFileLoader m_FileLoader; + StreamSoundPlayer* m_PlayerHandle; + fnd::FileStream* m_pFileStream; + StreamDataInfoDetail* m_DataInfo; + StreamFileType m_FileType; + DecodeMode m_DecodeMode; + FileStreamHookParam m_FileStreamHookParam; + s32 m_ChannelCount; + u16 m_AssignNumber; + bool m_LoopFlag; + bool m_IsStreamOpenFailureHalt; + position_t m_LoopStart; + position_t m_LoopEnd; + char m_FilePath[639]; + void* m_pExternalData; + std::size_t m_ExternalDataSize; + void* m_pCacheBuffer; + std::size_t m_CacheSize; + u32 m_LoadingDataBlockIndex; + u32 m_LastBlockIndex; + u32 m_LoopStartBlockIndex; + position_t m_DataStartFilePos; + position_t m_LoopStartFilePos; + position_t m_LoopStartBlockSampleOffset; + bool m_LoopJumpFlag; + bool m_LoadFinishFlag; + RegionManager m_RegionManager; + StreamHeaderLoadTask m_StreamHeaderLoadTask; + StreamCloseTask m_StreamCloseTask; + StreamDataLoadTaskList m_StreamDataLoadTaskList; + InstancePool m_StreamDataLoadTaskPool; + u8 m_StreamDataLoadTaskArea[7936]; + SampleFormat m_SampleFormat; + AdpcmInfo m_AdpcmInfo[16]; + u32 m_FileStreamBuffer[128]; + IStreamDataDecoder* m_pStreamDataDecoder; + IStreamDataDecoderManager* m_pStreamDataDecoderManager; + util::IntrusiveListNode m_LinkForLoaderManager; +}; +static_assert(sizeof(StreamSoundLoader) == 0x3640); + +using StreamSoundLoaderManager = LoaderManager; +} // namespace nn::atk::detail::driver +} // namespace nn::atk::detail \ No newline at end of file From 869ed5ee0c536f1d486d7eb3af5931e34e597fc7 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 27 Feb 2026 12:08:04 -0300 Subject: [PATCH 110/785] atk: Define `detail::StreamSoundPrefetchFileReader` --- .../nn/atk/detail/atk_IRegionInfoReadable.h | 1 + .../detail/strm/atk_StreamSoundFileReader.h | 1 - .../strm/atk_StreamSoundPrefetchFileReader.h | 44 +++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/detail/atk_IRegionInfoReadable.h b/include/nn/atk/detail/atk_IRegionInfoReadable.h index f0f5ca70..0352f6d4 100644 --- a/include/nn/atk/detail/atk_IRegionInfoReadable.h +++ b/include/nn/atk/detail/atk_IRegionInfoReadable.h @@ -6,6 +6,7 @@ namespace nn::atk::detail { class IRegionInfoReadable { public: virtual ~IRegionInfoReadable() = default; + virtual bool ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo, u32 regionIndex) const = 0; }; diff --git a/include/nn/atk/detail/strm/atk_StreamSoundFileReader.h b/include/nn/atk/detail/strm/atk_StreamSoundFileReader.h index 7119bb9e..51b88e2c 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundFileReader.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundFileReader.h @@ -10,7 +10,6 @@ class StreamSoundFileReader { void Initialize(const void* streamSoundFile); bool IsValidFileHeader(const void* streamSoundFile) const; - bool IsTrackInfoAvailable() const; bool IsCrc32CheckAvailable() const; bool IsRegionIndexCheckAvailable() const; diff --git a/include/nn/atk/detail/strm/atk_StreamSoundPrefetchFileReader.h b/include/nn/atk/detail/strm/atk_StreamSoundPrefetchFileReader.h index e69de29b..f149d841 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundPrefetchFileReader.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundPrefetchFileReader.h @@ -0,0 +1,44 @@ +#pragma once + +#include +#include + +namespace nn::atk::detail { +class StreamSoundPrefetchFileReader : IRegionInfoReadable { +public: + struct PrefetchDataInfo { + u32 startFrame; + u32 prefetchSize; + void* dataAddress; + }; + + StreamSoundPrefetchFileReader(); + ~StreamSoundPrefetchFileReader() override; + + void Initialize(const void* streamSoundPrefetchFile); + + bool IsValidFileHeader(const void* streamSoundPrefetchFile) const; + + s32 GetRegionDataOffset() const; + u16 GetRegionInfoBytes() const; + + bool IsIncludeRegionInfo() const; + bool IsCrc32CheckAvailable() const; + bool IsRegionIndexCheckAvailable() const; + + bool ReadStreamSoundInfo(StreamSoundFile::StreamSoundInfo* strmInfo) const; + bool ReadDspAdpcmChannelInfo(DspAdpcmParam* pParam, DspAdpcmLoopParam* pLoopParam, + s32 channelIndex) const; + bool ReadPrefetchDataInfo(PrefetchDataInfo* pDataInfo, s32 prefetchIndex) const; + bool ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo, + u32 regionIndex) const override; + +private: + StreamSoundPrefetchFile::FileHeader* m_pHeader; + StreamSoundFile::InfoBlockBody* m_pInfoBlockBody; + StreamSoundPrefetchFile::PrefetchDataBlockBody* m_pPrefetchDataBlockBody; + u32 m_RegionDataOffset; + u16 m_RegionInfoBytes; +}; +static_assert(sizeof(StreamSoundPrefetchFileReader) == 0x28); +} // namespace nn::atk::detail \ No newline at end of file From 4d1a29b4e96f8d6e7b62ebf99f082017c49b010c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 27 Feb 2026 12:13:47 -0300 Subject: [PATCH 111/785] atk: Define `detail::driver::StreamChannel` --- include/nn/atk/detail/strm/atk_StreamTrack.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/nn/atk/detail/strm/atk_StreamTrack.h b/include/nn/atk/detail/strm/atk_StreamTrack.h index e69de29b..fdddd695 100644 --- a/include/nn/atk/detail/strm/atk_StreamTrack.h +++ b/include/nn/atk/detail/strm/atk_StreamTrack.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +namespace nn::atk::detail::driver { +class StreamChannel { +public: + void AppendWaveBuffer(WaveBuffer* pBuffer, bool lastFlag); + +private: + void* m_pBufferAddress; + MultiVoice* m_pVoice; + WaveBuffer m_WaveBuffer[32]; + AdpcmContext m_AdpcmContext[32]; + UpdateType m_UpdateType; +}; +static_assert(sizeof(StreamChannel) == 0x1080); +} // namespace nn::atk::detail::driver \ No newline at end of file From b1b9e8a38d47dfd386456f5d4e19d48a359a7f7f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 27 Feb 2026 12:24:54 -0300 Subject: [PATCH 112/785] atk: Define `detail::driver::StreamTrack` --- include/nn/atk/detail/strm/atk_StreamTrack.h | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/nn/atk/detail/strm/atk_StreamTrack.h b/include/nn/atk/detail/strm/atk_StreamTrack.h index fdddd695..b0c5c4d2 100644 --- a/include/nn/atk/detail/strm/atk_StreamTrack.h +++ b/include/nn/atk/detail/strm/atk_StreamTrack.h @@ -15,4 +15,28 @@ class StreamChannel { UpdateType m_UpdateType; }; static_assert(sizeof(StreamChannel) == 0x1080); + +class StreamTrack { +public: + StreamTrack(); + ~StreamTrack(); + +private: + bool m_ActiveFlag; + StreamChannel* m_pChannels[2]; + u8 channelCount; + u8 volume; + u8 pan; + u8 span; + u8 mainSend; + u8 fxSend[3]; + u8 lpfFreq; + s8 biquadType; + u8 biquadValue; + u8 flags; + f32 m_Volume; + s32 m_OutputLine; + OutputParam m_TvParam; +}; +static_assert(sizeof(StreamTrack) == 0x80); } // namespace nn::atk::detail::driver \ No newline at end of file From 3b5d77ae6e75640a32e9aecadf533c69de0b2ecd Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 27 Feb 2026 14:19:51 -0300 Subject: [PATCH 113/785] atk: Define `detail::driver::StreamSoundPlayer` Other changes: - Defined other classes and structs in `atk_StreamSoundPlayer.h` --- include/nn/atk/atk_Global.h | 2 + .../atk/detail/strm/atk_StreamSoundPlayer.h | 317 ++++++++++++++++++ 2 files changed, 319 insertions(+) diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h index d40f912c..0b26ce6d 100644 --- a/include/nn/atk/atk_Global.h +++ b/include/nn/atk/atk_Global.h @@ -313,6 +313,8 @@ enum SinglePlayType { SinglePlayType_PrioritizeNewestWithDuration = SinglePlayType_PrioritizeNewestEffectiveDuration, }; +struct StreamDataInfo {}; + enum UpdateType { UpdateType_AudioFrame, UpdateType_GameFrame, diff --git a/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h b/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h index e69de29b..4708b38d 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h @@ -0,0 +1,317 @@ +#pragma once + +#include +#include +#include +#include +#include + +namespace nn::atk::detail { +struct StreamSoundDataInfo { + bool loopFlag; + s32 sampleRate; + s64 loopStart; + s64 loopEnd; + s64 compatibleLoopStart; + s64 compatibleLoopEnd; + s32 channelCount; +}; +static_assert(sizeof(StreamSoundDataInfo) == 0x30); + +struct StreamSoundRegionDataInfo { + u32 startSamplePosition; + u32 endSamplePosition; + s32 regionNo; + char regionName[64]; +}; +static_assert(sizeof(StreamSoundRegionDataInfo) == 0x4c); + +namespace driver { +class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { +public: + enum StartOffsetType { + StartOffsetType_Sample, + StartOffsetType_Millisec, + }; + + struct SetupArg; + struct ItemData { + f32 pitch; + f32 mainSend; + f32 fxSend[3]; + + void Set(const SetupArg& arg); + }; + static_assert(sizeof(ItemData) == 0x14); + + struct TrackData { + f32 volume; + f32 lpfFreq; + s32 biquadType; + f32 biquadValue; + f32 pan; + f32 span; + f32 mainSend; + f32 fxSend[3]; + + void Set(const StreamTrack* pStreamTrack); + }; + static_assert(sizeof(TrackData) == 0x28); + + struct WaveBufferInfo { + position_t sampleBegin; + std::size_t sampleLength; + s32 loopCount; + }; + static_assert(sizeof(WaveBufferInfo) == 0x18); + + struct PrepareBaseArg { + StartOffsetType startOffsetType; + position_t offset; + s32 delayTime; + s32 delayCount; + UpdateType updateType; + StreamRegionCallback regionCallback; + void* regionCallbackArg; + char filePath[639]; + void* pExternalData; + std::size_t externalDataSize; + FileStreamHookParam fileStreamHookParam; + }; + static_assert(sizeof(PrepareBaseArg) == 0x2d0); + + struct PrepareArg { + PrepareBaseArg baseArg; + void* cacheBuffer; + std::size_t cacheSize; + }; + static_assert(sizeof(PrepareArg) == 0x2e0); + + struct PreparePrefetchArg { + PrepareBaseArg baseArg; + void* strmPrefetchFile; + }; + static_assert(sizeof(PreparePrefetchArg) == 0x2d8); + + struct SetupArg { + StreamBufferPool* pBufferPool; + u32 allocChannelCount; + u16 allocTrackFlag; + u8 fileType; + bool loopFlag; + TrackDataInfos trackInfos; + position_t loopStart; + position_t loopEnd; + f32 pitch; + u8 mainSend; + u8 fxSend[3]; + DecodeMode decodeMode; + }; + static_assert(sizeof(SetupArg) == 0xa0); + + struct PrefetchIndexInfo { + u32 lastBlockIndex; + position_t loopStartInBlock; + u32 loopStartBlockIndex; + s32 loopBlockCount; + + void Initialize(const StreamDataInfoDetail& streamDataInfo); + }; + static_assert(sizeof(PrefetchIndexInfo) == 0x18); + + struct PrefetchLoadDataParam : LoadDataParam { + u32 prefetchBlockIndex; + std::size_t prefetchBlockBytes; + }; + static_assert(sizeof(PrefetchLoadDataParam) == 0xa8); + + StreamSoundPlayer(); + ~StreamSoundPlayer() override; + + void Initialize(); + void Initialize(OutputReceiver* pOutputReceiver) override; + + bool TryAllocLoader(); + + void Finalize() override; + + void FinishPlayer(); + + void FreeStreamBuffers(); + void FreeVoices(); + void FreeLoader(); + + void Setup(const SetupArg& arg); + void SetupTrack(const SetupArg& arg); + + void Prepare(const PrepareArg& arg); + + void SetPrepareBaseArg(const PrepareBaseArg& arg); + + void RequestLoadHeader(const PrepareArg& arg); + + void PreparePrefetch(const PreparePrefetchArg& arg); + + bool ReadPrefetchFile(StreamSoundPrefetchFileReader& reader); + + bool ApplyStreamDataInfo(const StreamDataInfoDetail& streamDataInfo); + + bool SetupPlayer(); + + bool AllocVoices(); + + bool LoadPrefetchBlocks(StreamSoundPrefetchFileReader& reader); + + void Start() override; + void StartPlayer(); + + void Stop() override; + + void Pause(bool flag) override; + + void UpdatePauseStatus(); + + bool IsLoadingDelayState() const; + bool IsBufferEmpty() const; + + bool ReadStreamDataInfo(StreamDataInfo* strmDataInfo) const; + + position_t GetPlaySamplePosition(bool) const; + f32 GetFilledBufferPercentage() const; + s32 GetBufferBlockCount(WaveBuffer::Status waveBufferStatus) const; + s32 GetTotalBufferBlockCount() const; + + bool LoadHeader(bool result, AdpcmParam** adpcmParam, u16 assignNumber); + + bool CheckPrefetchRevision(const StreamDataInfoDetail& streamDataInfo) const; + + bool AllocStreamBuffers(); + + void UpdateLoadingBlockIndex(); + + bool LoadStreamData(bool result, const LoadDataParam& loadDataParam, u16 assignNumber); + bool LoadStreamData(bool result, const LoadDataParam& loadDataParam, u16 assignNumber, + bool usePrefetchFlag, u32 currentPrefetchBlockIndex, + std::size_t currentPrefetchBlockBytes); + + bool IsStoppedByLoadingDelay() const; + + static void VoiceCallbackFunc(MultiVoice* voice, + MultiVoice::VoiceCallbackStatus status, void* arg); + + void Update(); + void UpdateBuffer(); + void UpdateVoiceParams(StreamTrack* track); + + bool CheckDiskDriveError(); + + void SetOutputParam(const OutputParam*, const OutputParam&, const TrackData&); + + void ApplyTvOutputParamForMultiChannel(OutputParam* outputParam, + MultiVoice* MultiVoice, s32 channelIndex, + MixMode mixMode); + void ApplyTvOutputParamForMultiChannel(OutputParam* outputParam, + OutputAdditionalParam* pOutputAdditionalParam, + MultiVoice* MultiVoice, s32 channelIndex, + MixMode mixMode); + + void MixSettingForOutputParam(OutputParam* outputParam, s32 channelIndex, MixMode mixMode); + + position_t GetOriginalPlaySamplePosition(position_t, const StreamDataInfoDetail& streamDataInfo) const; + + bool IsValidStartOffset(const StreamDataInfoDetail& streamDataInfo); + + void ApplyTrackDataInfo(const StreamDataInfoDetail& streamDataInfo); + + u64 GetStartOffsetSamples(const StreamDataInfoDetail& streamDataInfo); + + void PreparePrefetchOnLastBlock(PrefetchLoadDataParam*, const PrefetchIndexInfo&); + void PreparePrefetchOnLoopStartBlock(PrefetchLoadDataParam*, const PrefetchIndexInfo&, + StreamSoundPrefetchFileReader& reader); + void PreparePrefetchOnLoopBlock(PrefetchLoadDataParam*, const PrefetchIndexInfo&, u32); + bool PreparePrefetchOnNormalBlock(PrefetchLoadDataParam*, u32, + StreamSoundPrefetchFileReader* reader); + + bool SetAdpcmLoopInfo(StreamSoundPrefetchFileReader& reader, + const StreamDataInfoDetail& streamDataInfo, AdpcmParam* adpcmParam, + AdpcmContextNotAligned* adpcmContext); + bool SetAdpcmInfo(StreamSoundPrefetchFileReader& reader, + const StreamDataInfoDetail& streamDataInfo, AdpcmParam* adpcmParam, + AdpcmContextNotAligned* adpcmContext); + + void SetTrackVolume(u32 trackBitFlag, f32 volume); + void SetTrackInitialVolume(u32 trackBitFlag, u32 volume); + + void SetTrackOutputLine(u32 trackBitFlag, u32 outputLine); + void ResetTrackOutputLine(u32 trackBitFlag); + + void SetTrackTvVolume(u32 trackBitFlag, f32 volume); + void SetTrackChannelTvMixParameter(u32 trackBitFlag, u32 srcChNo, const MixParameter& param); + void SetTrackTvPan(u32 trackBitFlag, f32 pan); + void SetTrackTvSurroundPan(u32 trackBitFlag, f32 span); + void SetTrackTvMainSend(u32 trackBitFlag, f32 send); + void SetTrackTvFxSend(u32 trackBitFlag, AuxBus bus, f32 send); + + StreamTrack* GetPlayerTrack(s32 index); + StreamTrack* GetPlayerTrack(s32 index) const; + + void OnUpdateFrameSoundThread() override; + void OnUpdateFrameSoundThreadWithAudioFrameFrequency() override; + void OnShutdownSoundThread() override; + +private: + bool m_IsInitialized; + bool m_IsPrepared; + bool m_IsFinalizing; + bool m_IsPreparedPrefetch; + bool m_PauseStatus; + bool m_LoadWaitFlag; + bool m_LoadFinishFlag; + bool m_ReportLoadingDelayFlag; + bool m_IsStoppedByLoadingDelay; + bool m_IsRegisterPlayerCallback; + bool m_UseDelayCount; + u8 m_Padding1[2]; + s32 m_LoopCounter; + s32 m_PlayingBlockLoopCounter; + s32 m_PrepareCounter; + StreamSoundLoaderManager* m_pLoaderManager; + StreamSoundLoader* m_pLoader; + detail::driver::StreamBufferPool* m_pBufferPool; + s32 m_BufferBlockCount; + u32 m_LoadingBufferBlockIndex; + u32 m_PlayingBufferBlockIndex; + u32 m_LastPlayFinishBufferBlockIndex; + StartOffsetType m_StartOffsetType; + position_t m_StartOffset; + s32 m_DelayCount; + u16 m_AssignNumber; + u8 m_FileType; + DecodeMode m_DecodeMode; + bool m_LoopFlag; + u8 m_Padding2[2]; + StreamDataInfoDetail m_StreamDataInfo; + position_t m_LoopStart; + position_t m_LoopEnd; + ItemData m_ItemData; + void* m_pStreamPrefetchFile; + AdpcmParam m_PrefetchAdpcmParam[16]; + StreamSoundPrefetchFileReader::PrefetchDataInfo m_PrefetchDataInfo; + position_t m_PrefetchOffset; + bool m_IsPrefetchRevisionCheckEnabled; + u32 m_PrefetchRevisionValue; + s32 m_ChannelCount; + s32 m_TrackCount; + StreamChannel m_Channels[16]; + StreamTrack m_Tracks[8]; + UpdateType m_UpdateType; + WaveBufferInfo m_WaveBufferInfo[32]; + PrepareArg m_PrepareArg; + bool m_IsSucceedPrepare; + SetupArg m_SetupArg; + position_t m_PlaySamplePosition; + position_t m_OriginalPlaySamplePosition; +}; +static_assert(sizeof(StreamSoundPlayer) == 0x11740); +} // namespace nn::atk::detail::driver +} // namespace nn::atk::detail \ No newline at end of file From de22ee742881eab0a2f60a63b538df4c1d22f59d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 27 Feb 2026 15:34:07 -0300 Subject: [PATCH 114/785] atk: Define `detail::driver::SequenceTrack` --- include/nn/atk/detail/seq/atk_SequenceTrack.h | 136 ++++++++++++++++++ 1 file changed, 136 insertions(+) diff --git a/include/nn/atk/detail/seq/atk_SequenceTrack.h b/include/nn/atk/detail/seq/atk_SequenceTrack.h index e69de29b..e18d20d6 100644 --- a/include/nn/atk/detail/seq/atk_SequenceTrack.h +++ b/include/nn/atk/detail/seq/atk_SequenceTrack.h @@ -0,0 +1,136 @@ +#pragma once + +#include + +namespace nn::atk::detail::driver { +class SequenceSoundPlayer; + +class SequenceTrack { +public: + enum ParseResult { + ParseResult_Continue, + ParseResult_Finish, + }; + + struct ParserTrackParam { + struct CallStack { + u8 loopFlag; + u8 loopCount; + u8 padding[2]; + u8* address; + }; + static_assert(sizeof(CallStack) == 0x10); + + u8* baseAddr; + u8* currentAddr; + bool cmpFlag; + bool noteWaitFlag; + bool tieFlag; + bool monophonicFlag; + CallStack callStack[10]; + u8 callStackDepth; + bool frontBypassFlag; + bool muteFlag; + bool silenceFlag; + s32 wait; + bool noteFinishWait; + bool portaFlag; + bool damperFlag; + u8 bankIndex; + s32 prgNo; + f32 sweepPitch; + MoveValue volume; + MoveValue volume2; + MoveValue pan; + MoveValue surroundPan; + MoveValue pitchBend; + CurveLfoParam lfoParam[4]; + u8 lfoTarget[4]; + u8 velocityRange; + u8 bendRange; + s8 initPan; + u8 padding1[1]; + s8 transpose; + u8 priority; + u8 portaKey; + u8 portaTime; + u8 attack; + u8 decay; + u8 sustain; + u8 release; + s16 envHold; + s8 biquadType; + u8 mainSend; + u8 fxSend[3]; + u8 padding2[1]; + f32 lpfFreq; + f32 biquadValue; + s32 outputLine; + }; + static_assert(sizeof(ParserTrackParam) == 0x150); + + virtual ~SequenceTrack(); + virtual ParseResult Parse(bool doNoteOn) = 0; + + SequenceTrack(); + + void SetPlayerTrackNo(s32 playerTrackNo); + + void InitParam(); + + void Close(); + + void SetSeqData(const void* seqBase, s32 seqOffset); + + void Open(); + + void ReleaseAllChannel(s32 release); + void FreeAllChannel(); + + void UpdateChannelLength(); + void UpdateChannelRelease(Channel*); + + s32 ParseNextTick(bool doNoteOn); + + void StopAllChannel(); + void UpdateChannelParam(); + void PauseAllChannel(bool flag); + + void AddChannel(Channel*); + + s32 GetChannelCount() const; + + static void ChannelCallbackFunc(Channel* dropChannel, + Channel::ChannelCallbackStatus callbackStatus, void* userData); + + void SetMute(SequenceMute mute); + void SetSilence(bool silenceFlag, s32 fadeTimes); + void SetBiquadFilter(s32 type, f32 value); + void SetBankIndex(s32 bankIndex); + void SetTranspose(s8 transpose); + void SetVelocityRange(u8 range); + void SetOutputLine(s32 outputLine); + void SetTvMixParameter(u32 srcChNo, s32 mixChNo, f32 param); + + s16 GetTrackVariable(s32) const; + void SetTrackVariable(s32 varNo, s16 var); + + s16* GetVariablePtr(s32 varNo); + + Channel* NoteOn(s32 key, s32 velocity, s32 length, bool tieFlag); + +private: + u8 m_PlayerTrackNo; + bool m_OpenFlag; + bool m_ForceMute; + f32 m_ExtVolume; + f32 m_ExtPitch; + f32 m_PanRange; + OutputParam m_TvParam; + ParserTrackParam m_ParserTrackParam; + s16 m_TrackVariable[16]; + SequenceSoundPlayer* m_pSequenceSoundPlayer; + Channel* m_pChannelList; +}; +static_assert(sizeof(SequenceTrack) == 0x1e8); +} // namespace nn::atk::detail::driver \ No newline at end of file From 4773dc0232a163e899082fca06023c546ef7fe3e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 27 Feb 2026 15:35:51 -0300 Subject: [PATCH 115/785] atk: Define `detail::driver::SequenceTrackAllocator` --- .../nn/atk/detail/seq/atk_SequenceTrackAllocator.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/nn/atk/detail/seq/atk_SequenceTrackAllocator.h b/include/nn/atk/detail/seq/atk_SequenceTrackAllocator.h index e69de29b..9dd5ba5e 100644 --- a/include/nn/atk/detail/seq/atk_SequenceTrackAllocator.h +++ b/include/nn/atk/detail/seq/atk_SequenceTrackAllocator.h @@ -0,0 +1,13 @@ +#pragma once + +#include +#include + +namespace nn::atk::detail::driver { +class SequenceTrackAllocator { +public: + virtual ~SequenceTrackAllocator() = default; + virtual SequenceTrack* AllocTrack(SequenceSoundPlayer* player) = 0; +}; +static_assert(sizeof(SequenceTrackAllocator) == 0x8); +} // namespace nn::atk::detail::driver \ No newline at end of file From 6d2123ad1170de9001317b17eabe959c3c0ba1fc Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 27 Feb 2026 15:37:19 -0300 Subject: [PATCH 116/785] atk: Define `detail::driver::SequenceSoundLoader` Other changes: - Also defined `SequenceUserProcCallbackParam` --- .../atk/detail/seq/atk_SequenceSoundPlayer.h | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) diff --git a/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h b/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h index e69de29b..395b8c2f 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h +++ b/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h @@ -0,0 +1,115 @@ +#pragma once + +#include "nn/atk/atk_SoundDataManager.h" +#include "nn/atk/atk_SoundPlayer.h" +#include "nn/atk/detail/atk_BasicSoundPlayer.h" +#include "nn/atk/detail/atk_DisposeCallback.h" +#include "nn/atk/detail/atk_LoaderManager.h" +#include "nn/atk/detail/atk_NoteOnCallback.h" +#include "nn/atk/detail/atk_PlayerHeap.h" +#include "nn/atk/detail/atk_PlayerHeapDataManager.h" +#include "nn/atk/detail/atk_SoundArchiveLoader.h" +#include "nn/atk/detail/thread/atk_SoundThread.h" +#include "nn/atk/detail/thread/atk_Task.h" + +namespace nn::atk { +struct SequenceUserProcCallbackParam { + s16* localVariable; + s16* globalVariable; + s16* trackVariable; + bool cmpFlag; +}; +static_assert(sizeof(SequenceUserProcCallbackParam) == 0x20); + +using SequenceUserProcCallback = void(*)(u16,SequenceUserProcCallbackParam*,void*); + +namespace detail::driver { +class SequenceSoundLoader { +public: + struct LoadInfo { + LoadInfo(SoundArchive* arc, SoundDataManager* mgr, + LoadItemInfo* seq, LoadItemInfo* banks, SoundPlayer* player); + + SoundArchive* soundArchive; + SoundDataManager* soundDataManager; + LoadItemInfo* loadInfoSeq; + LoadItemInfo* loadInfoBanks[4]; + SoundPlayer* soundPlayer; + }; + static_assert(sizeof(LoadInfo) == 0x40); + + struct Arg { + SoundArchive* soundArchive; + SoundDataManager* soundDataManager; + SoundPlayer* soundPlayer; + LoadItemInfo loadInfoSeq; + LoadItemInfo loadInfoBanks[4]; + }; + static_assert(sizeof(Arg) == 0x68); + + struct Data { + void* seqFile; + void* bankFiles[4]; + void* warcFiles[4]; + bool warcIsIndividuals[4]; + }; + static_assert(sizeof(Data) == 0x50); + + class DataLoadTask : Task { + public: + DataLoadTask(); + ~DataLoadTask() override; + + bool TryAllocPlayerHeap(); + + void Execute(TaskProfileLogger& logger) override; + + private: + Arg m_Arg; + Data m_Data; + PlayerHeap* m_pPlayerHeap; + PlayerHeapDataManager* m_pPlayerHeapDataManager; + bool m_IsLoadSuccess; + u8 m_Padding[3]; + }; + static_assert(sizeof(DataLoadTask) == 0x118); + + class FreePlayerHeapTask : Task { + public: + FreePlayerHeapTask(); + ~FreePlayerHeapTask() override; + + void Initialize(); + void Execute(TaskProfileLogger& logger) override; + + private: + Arg m_Arg; + PlayerHeap* m_pPlayerHeap; + PlayerHeapDataManager* m_pPlayerHeapDataManager; + + }; + + ~SequenceSoundLoader(); + + void Initialize(const Arg& arg); + + void Finalize(); + + bool IsInUse(); + + bool TryWait(); + +private: + friend LoaderManager; + + DataLoadTask m_Task; + FreePlayerHeapTask m_FreePlayerHeapTask; + PlayerHeapDataManager m_PlayerHeapDataManager; + util::IntrusiveListNode m_LinkForLoaderManager; +}; +static_assert(sizeof(SequenceSoundLoader) == 0x4b0); + +using SequenceSoundLoaderManager = LoaderManager; + +} // namespace nn::atk::detail::driver +} // namespace nn::atk \ No newline at end of file From 45c228895f6d0b01f75b44811e714dda05a23bde Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 27 Feb 2026 16:11:54 -0300 Subject: [PATCH 117/785] atk: Define `detail::driver::SequenceSoundPlayer` --- .../atk/detail/seq/atk_SequenceSoundPlayer.h | 195 +++++++++++++++++- .../atk/detail/strm/atk_StreamSoundPlayer.h | 2 + 2 files changed, 186 insertions(+), 11 deletions(-) diff --git a/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h b/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h index 395b8c2f..ab9d60e7 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h +++ b/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h @@ -1,16 +1,14 @@ #pragma once -#include "nn/atk/atk_SoundDataManager.h" -#include "nn/atk/atk_SoundPlayer.h" -#include "nn/atk/detail/atk_BasicSoundPlayer.h" -#include "nn/atk/detail/atk_DisposeCallback.h" -#include "nn/atk/detail/atk_LoaderManager.h" -#include "nn/atk/detail/atk_NoteOnCallback.h" -#include "nn/atk/detail/atk_PlayerHeap.h" -#include "nn/atk/detail/atk_PlayerHeapDataManager.h" -#include "nn/atk/detail/atk_SoundArchiveLoader.h" -#include "nn/atk/detail/thread/atk_SoundThread.h" -#include "nn/atk/detail/thread/atk_Task.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace nn::atk { struct SequenceUserProcCallbackParam { @@ -111,5 +109,180 @@ static_assert(sizeof(SequenceSoundLoader) == 0x4b0); using SequenceSoundLoaderManager = LoaderManager; +class SequenceSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::PlayerCallback { +public: + enum StartOffsetType { + StartOffsetType_Tick, + StartOffsetType_Millisec, + }; + + enum ResState { + ResState_Invalid, + ResState_RecvLoadReq, + ResState_AppendLoadTask, + ResState_Assigned, + }; + + constexpr static s32 PlayerVariableCount = 16; + constexpr static s32 GlobalVariableCount = 16; + constexpr static s32 TrackCountPerPlayer = 16; + + constexpr static u32 AllTrackBitFlag = 0x0000FFFF; + + constexpr static s32 VariableDefaultValue = -1; + constexpr static s32 DefaultTimebase = 48; + constexpr static s32 DefaultTempo = 120; + constexpr static u64 DefaultSkipIntervalTick = 0x300; + + struct ParserPlayerParam { + u8 priority; + u8 timebase; + u16 tempo; + MoveValue volume; + NoteOnCallback* callback; + }; + static_assert(sizeof(ParserPlayerParam) == 0x18); + + struct StartInfo { + s32 seqOffset; + StartOffsetType startOffsetType; + s32 startOffset; + s32 delayTime; + s32 delayCount; + UpdateType updateType; + }; + static_assert(sizeof(StartInfo) == 0x18); + + struct PrepareArg { + void* seqFile; + void* bankFiles[4]; + void* warcFiles[4]; + bool warcIsIndividuals[4]; + s32 seqOffset; + s32 delayTime; + s32 delayCount; + UpdateType updateType; + }; + static_assert(sizeof(PrepareArg) == 0x60); + + struct SetupArg { + SequenceTrackAllocator* trackAllocator; + u32 allocTracks; + NoteOnCallback* callback; + }; + static_assert(sizeof(SetupArg) == 0x18); + + static void InitSequenceSoundPlayer(); + + SequenceSoundPlayer(); + ~SequenceSoundPlayer() override; + + void Initialize(); + void Initialize(OutputReceiver* pOutputReceiver) override; + void Finalize() override; + + void FinishPlayer(); + + void FreeLoader(); + + void Setup(const SetupArg& arg); + + void SetPlayerTrack(s32 trackNo, SequenceTrack* track); + SequenceTrack* GetPlayerTrack(s32 trackNo); + + void Start() override; + void Stop() override; + void Pause(bool flag) override; + void Skip(StartOffsetType offsetType, s32 offset); + + void SetTempoRatio(f32 tempoRatio); + void SetPanRange(f32 panRange); + void SetChannelPriority(s32 priority); + void SetReleasePriorityFix(bool fix); + void SetSequenceUserprocCallback(SequenceUserProcCallback callback, void* arg); + + void CallSequenceUserprocCallback(u16 procId, SequenceTrack* track); + + s16* GetVariablePtr(s32 varNo); + void GetLocalVariable(s32 varNo) const; + void SetLocalVariable(s32 varNo, s16 var); + static void SetGlobalVariable(s32 varNo, s16 var); + + void SetTrackMute(u32 trackBitFlag, SequenceMute mute); + void SetTrackSilence(u64 trackBitFlag, bool silenceFlag, s32 fadeTimes); + void SetTrackVolume(u32 trackBitFlag, f32 volume); + void SetTrackPitch(u32 trackBitFlag, f32 pitch); + void SetTrackLpfFreq(u32 trackBitFlag, f32 lpfFreq); + void SetTrackBiquadFilter(u32 trackBitFlag, s32 type, f32 value); + bool SetTrackBankIndex(u32 trackBitFlag, s32 bankIndex); + void SetTrackTranspose(u32 trackBitFlag, s8 transpose); + void SetTrackVelocityRange(u32 trackBitFlag, u8 range); + + void SetTrackOutputLine(u32 trackBitFlag, u32 outputLine); + void ResetTrackOutputLine(u32 trackBitFlag); + + void SetTrackTvVolume(u32 trackBitFlag, f32 volume); + void SetTrackChannelTvMixParameter(u32 trackBitFlag, u32 srcChNo, const MixParameter& param); + void SetTrackTvPan(u32 trackBitFlag, f32 pan); + void SetTrackTvSurroundPan(u32 trackBitFlag, f32 surroundPan); + void SetTrackTvMainSend(u32 trackBitFlag, f32 send); + void SetTrackTvFxSend(u32 trackBitFlag, AuxBus bus, f32 send); + + void InvalidateData(const void* start, const void* end) override; + + SequenceTrack* GetPlayerTrack(s32 trackNo) const; + void CloseTrack(s32 trackNo); + + void UpdateChannelParam(); + + s32 ParseNextTick(bool doNoteOn); + + void Update(); + + void PrepareForPlayerHeap(PrepareArg* arg); + + void SkipTick(); + void UpdateTick(); + + Channel* NoteOn(u8 bankIndex, NoteOnInfo* noteOnInfo); + + void Prepare(PrepareArg* arg); + + void RequestLoad(StartInfo* info, SequenceSoundLoader::Arg* arg); + + bool TryAllocLoader(); + +private: + bool m_ReleasePriorityFixFlag; + bool m_IsPrepared; + f32 m_PanRange; + f32 m_TempoRatio; + f32 m_TickFraction; + u32 m_SkipTickCounter; + f32 m_SkipTimeCounter; + s32 m_DelayCount; + ParserPlayerParam m_ParserParam; + SequenceTrackAllocator* m_pSequenceTrackAllocator; + SequenceUserProcCallback m_SequenceUserprocCallback; + void* m_pSequenceUserprocCallbackArg; + SequenceTrack* m_pTracks[TrackCountPerPlayer]; + s16 m_LocalVariable[PlayerVariableCount]; + u32 m_TickCounter; + WaveArchiveFileReader m_WarcFileReader[4]; + BankFileReader m_BankFileReader[4]; + u8 m_ResState; + bool m_IsInitialized; + bool m_IsRegisterPlayerCallback; + u8 m_Padding[1]; + StartInfo m_StartInfo; + SequenceSoundLoaderManager* m_pLoaderManager; + SequenceSoundLoader* m_pLoader; + SequenceSoundLoader::Arg m_LoaderArg; + UpdateType m_UpdateType; + + static s16 m_GlobalVariable[GlobalVariableCount]; + static s32 m_SkipIntervalTickPerFrame; +}; +static_assert(sizeof(SequenceSoundPlayer) == 0x368); } // namespace nn::atk::detail::driver } // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h b/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h index 4708b38d..c5c6a2ec 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h @@ -311,6 +311,8 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { SetupArg m_SetupArg; position_t m_PlaySamplePosition; position_t m_OriginalPlaySamplePosition; + + static u16 g_TaskRequestIndexCount; }; static_assert(sizeof(StreamSoundPlayer) == 0x11740); } // namespace nn::atk::detail::driver From 7f340062596b99103db2493a5a9ee87ead88697a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 27 Feb 2026 16:25:09 -0300 Subject: [PATCH 118/785] atk: Define `detail::driver::MmlSequenceTrack` --- .../nn/atk/detail/seq/atk_MmlSequenceTrack.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/nn/atk/detail/seq/atk_MmlSequenceTrack.h b/include/nn/atk/detail/seq/atk_MmlSequenceTrack.h index e69de29b..5b1c66c0 100644 --- a/include/nn/atk/detail/seq/atk_MmlSequenceTrack.h +++ b/include/nn/atk/detail/seq/atk_MmlSequenceTrack.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +namespace nn::atk::detail::driver { +class MmlParser; +class MmlSequenceTrack : SequenceTrack { +public: + MmlSequenceTrack(); + ~MmlSequenceTrack() override; + + ParseResult Parse(bool doNoteOn) override; + +private: + MmlParser* m_pParser; +}; +static_assert(sizeof(MmlSequenceTrack) == 0x1f0); +} // namespace nn::atk::detail::driver \ No newline at end of file From 4c234fdeecf75632907a620045645ff04e2fed34 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 27 Feb 2026 16:34:44 -0300 Subject: [PATCH 119/785] atk: Define `detail::driver::MmlParser` --- include/nn/atk/detail/seq/atk_MmlParser.h | 39 +++++++++++++++++++ .../detail/seq/atk_SequenceTrackAllocator.h | 3 +- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/detail/seq/atk_MmlParser.h b/include/nn/atk/detail/seq/atk_MmlParser.h index e69de29b..9f47f623 100644 --- a/include/nn/atk/detail/seq/atk_MmlParser.h +++ b/include/nn/atk/detail/seq/atk_MmlParser.h @@ -0,0 +1,39 @@ +#pragma once + +#include + +namespace nn::atk::detail::driver { +class MmlParser { +public: + enum SeqArgType { + SeqArgType_None, + SeqArgType_U8, + SeqArgType_S16, + SeqArgType_Vmidi, + SeqArgType_Random, + SeqArgType_Variable, + }; + + MmlParser(); + virtual ~MmlParser(); + + SequenceTrack::ParseResult Parse(MmlSequenceTrack* track, bool doNoteOn) const; + + s32 ReadArg(const u8** ptr, SequenceSoundPlayer* player, SequenceTrack* track, + SeqArgType argType) const; + + s32 Read24(const u8** ptr) const; + s16 Read16(const u8** ptr) const; + + void CommandProc(MmlSequenceTrack* track, u32 command, s32 commandArg1, s32 commandArg2) const; + + s16* GetVariablePtr(SequenceSoundPlayer* player, SequenceTrack* track, s32 varNo) const; + + void NoteOnCommandProc(MmlSequenceTrack* track, s32 key, s32 velocity, s32 length, bool tieFlag) const; + + s16 ReadVar(const u8** ptr) const; + + static u32 ParseAllocTrack(const void* baseAddress, u32 seqOffset, u32* allocTrack); +}; +static_assert(sizeof(MmlParser) == 0x8); +} // namespace nn::atk::detail::driver \ No newline at end of file diff --git a/include/nn/atk/detail/seq/atk_SequenceTrackAllocator.h b/include/nn/atk/detail/seq/atk_SequenceTrackAllocator.h index 9dd5ba5e..91ad028a 100644 --- a/include/nn/atk/detail/seq/atk_SequenceTrackAllocator.h +++ b/include/nn/atk/detail/seq/atk_SequenceTrackAllocator.h @@ -1,9 +1,10 @@ #pragma once #include -#include namespace nn::atk::detail::driver { +class SequenceSoundPlayer; + class SequenceTrackAllocator { public: virtual ~SequenceTrackAllocator() = default; From 68937f7deb6cc7d3853f5564d032eabd6621f1ba Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 27 Feb 2026 17:33:28 -0300 Subject: [PATCH 120/785] atk: Define `detail::driver::MmlSequenceTrackAllocator` --- .../seq/atk_MmlSequenceTrackAllocator.h | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/nn/atk/detail/seq/atk_MmlSequenceTrackAllocator.h b/include/nn/atk/detail/seq/atk_MmlSequenceTrackAllocator.h index e69de29b..bb0a09ea 100644 --- a/include/nn/atk/detail/seq/atk_MmlSequenceTrackAllocator.h +++ b/include/nn/atk/detail/seq/atk_MmlSequenceTrackAllocator.h @@ -0,0 +1,27 @@ +#pragma once + +#include +#include +#include + +namespace nn::atk::detail::driver { +class MmlSequenceTrackAllocator : SequenceTrackAllocator { +public: + using MmlSequenceTrackPool = InstancePool; + + SequenceTrack* AllocTrack(SequenceSoundPlayer* player) override; + + void FreeTrack(SequenceTrack* track); + + s32 Create(void* buffer, std::size_t size); + + void Destroy(); + + s32 GetAllocatableTrackCount(); + +private: + MmlParser* m_pParser; + MmlSequenceTrackPool m_TrackPool; +}; +static_assert(sizeof(MmlSequenceTrackAllocator) == 0x28); +} // namespace nn::atk::detail \ No newline at end of file From 900c25a8139e6dd70051c0dcfa290d23f1bae26e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 27 Feb 2026 17:48:39 -0300 Subject: [PATCH 121/785] atk: Define `detail::SequenceSoundFileReader` --- .../nn/atk/detail/seq/atk_SequenceSoundFile.h | 4 ++-- .../detail/seq/atk_SequenceSoundFileReader.h | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/detail/seq/atk_SequenceSoundFile.h b/include/nn/atk/detail/seq/atk_SequenceSoundFile.h index d001cb44..cb2077ae 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSoundFile.h +++ b/include/nn/atk/detail/seq/atk_SequenceSoundFile.h @@ -7,8 +7,8 @@ struct SequenceSoundFile { struct DataBlock; struct LabelBlock; struct FileHeader : Util::SoundFileHeader { - DataBlock* GetDataBlock(); - LabelBlock* GetLabelBlock(); + DataBlock* GetDataBlock() const; + LabelBlock* GetLabelBlock() const; }; struct LabelInfo { diff --git a/include/nn/atk/detail/seq/atk_SequenceSoundFileReader.h b/include/nn/atk/detail/seq/atk_SequenceSoundFileReader.h index e69de29b..5401ed37 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSoundFileReader.h +++ b/include/nn/atk/detail/seq/atk_SequenceSoundFileReader.h @@ -0,0 +1,23 @@ +#pragma once + +#include + +namespace nn::atk::detail { +class SequenceSoundFileReader { +public: + constexpr static s32 SignatureFile = 51455346; // FSEQ + + explicit SequenceSoundFileReader(void* sequenceFile); + + void* GetSequenceData(); + + bool GetOffsetByLabel(const char* label, u32* offsetPtr) const; + bool GetLabelByOffset(u32 offset) const; + +private: + SequenceSoundFile::FileHeader* m_pHeader; + SequenceSoundFile::DataBlockBody* m_pDataBlockBody; + SequenceSoundFile::LabelBlockBody* m_pLabelBlockBody; +}; +static_assert(sizeof(SequenceSoundFileReader) == 0x18); +} // namespace nn::atk::detail \ No newline at end of file From 0c5315bd5620695c548849d7093f7127ffbe469b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 27 Feb 2026 18:29:50 -0300 Subject: [PATCH 122/785] atk: Define `detail::SequenceSound` --- include/nn/atk/detail/seq/atk_SequenceSound.h | 95 +++++++++++++++++++ .../atk/detail/seq/atk_SequenceSoundPlayer.h | 5 + 2 files changed, 100 insertions(+) diff --git a/include/nn/atk/detail/seq/atk_SequenceSound.h b/include/nn/atk/detail/seq/atk_SequenceSound.h index e69de29b..f06cc73a 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSound.h +++ b/include/nn/atk/detail/seq/atk_SequenceSound.h @@ -0,0 +1,95 @@ +#pragma once + +#include +#include +#include + +namespace nn::atk::detail { +class SequenceSound; +using SequenceSoundInstanceManager = SoundInstanceManager; + +class SequenceSound : BasicSound { +public: + struct Resource { + void* seq; + void* banks[4]; + void* warcs[4]; + bool warcIsIndividuals[4]; + }; + static_assert(sizeof(Resource) == 0x50); + + explicit SequenceSound(SequenceSoundInstanceManager& manager); + ~SequenceSound() override; + + bool Initialize() override; + bool Initialize(OutputReceiver* pOutputReceiver) override; + void Finalize() override; + + void Setup(driver::SequenceTrackAllocator* trackAllocator, u32 allocTracks, + driver::NoteOnCallback* noteOnCallback, s32 channelPriority, + bool isReleasePriorityFix, SequenceUserProcCallback userproc, void* userprocArg); + + void Prepare(const Resource& res, const driver::SequenceSoundPlayer::StartInfo& startInfo); + + void Skip(driver::SequenceSoundPlayer::StartOffsetType, s32); + + void SetTempoRatio(f32 tempoRatio); + + void SetChannelPriority(s32 priority); + void OnUpdatePlayerPriority() override; + + void SetTrackMute(u32 trackBitFlag, SequenceMute mute); + void SetTrackMute(u32 trackBitFlag, bool); + void SetTrackSilence(u32 trackBitFlag, bool, s32); + void SetTrackVolume(u32 trackBitFlag, f32 volume); + void SetTrackPitch(u32 trackBitFlag, f32 pitch); + void SetTrackMainOutVolume(u32 trackBitFlag, f32 volume); + void SetTrackChannelMixParameter(u32 trackBitFlag, u32 srcChNo, const MixParameter& param); + void SetTrackPan(u32 trackBitFlag, f32 pan); + void SetTrackSurroundPan(u32 trackBitFlag, f32 surroundPan); + void SetTrackMainSend(u32 trackBitFlag, f32 send); + void SetTrackFxSend(u32 trackBitFlag, AuxBus bus, f32 send); + void SetTrackLpfFreq(u32 trackBitFlag, f32 lpfFreq); + void SetTrackBiquadFilter(u32 trackBitFlag, s32 type, f32 value); + void SetTrackBankIndex(u32 trackBitFlag, s32 bankIndex); + void SetTrackTranspose(u32 trackBitFlag, s8 transpose); + void SetTrackVelocityRange(u32 trackBitFlag, u8 range); + void SetTrackOutputLine(u32 trackBitFlag, u32 outputLine); + + void ResetTrackOutputLine(u32 trackBitFlag); + + bool ReadVariable(s32 varNo, s16* varPtr) const; + static bool ReadGlobalVariable(s32 varNo, s16* varPtr); + bool ReadTrackVariable(s32, s32, s16*) const; + + void WriteVariable(s32 varNo, s16 var); + static void WriteGlobalVariable(s32 varNo, s16 var); + void WriteTrackVariable(s32, s32, s16 var); + + u64 GetTick() const; + + bool IsAttachedTempSpecialHandle() override; + void DetachTempSpecialHandle() override; + + void RegisterDataLoadTask(const driver::SequenceSoundLoader::LoadInfo& loadInfo, + const driver::SequenceSoundPlayer::StartInfo& startInfo); + + bool IsPrepared() const override; + + driver::BasicSoundPlayer* GetBasicSoundPlayerHandle(); + + void OnUpdateParam() override; + + util::IntrusiveListNode m_PriorityLink; + +private: + SequenceSoundHandle* m_pTempSpecialHandle; + SequenceSoundInstanceManager* m_Manager; + bool m_InitializeFlag; + bool m_CanUseTask; + bool m_IsCalledPrepare; + u8 m_Padding[1]; + driver::SequenceSoundPlayer m_PlayerInstance; +}; +static_assert(sizeof(SequenceSound) == 0x5a0); +} // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h b/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h index ab9d60e7..3bfd25d3 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h +++ b/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h @@ -252,6 +252,11 @@ class SequenceSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::Play bool TryAllocLoader(); + void ChannelCallback(Channel* channel); + void OnUpdateFrameSoundThread() override; + void OnUpdateFrameSoundThreadWithAudioFrameFrequency() override; + void OnShutdownSoundThread() override; + private: bool m_ReleasePriorityFixFlag; bool m_IsPrepared; From 40f0b4eaccc666d50bbb5a86dcd756bc7385e5c1 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 27 Feb 2026 19:47:26 -0300 Subject: [PATCH 123/785] atk: Some virtual function fixes --- include/nn/atk/detail/atk_AdvancedWaveSound.h | 4 ++++ include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h | 6 +++++- include/nn/atk/detail/atk_BasicSound.h | 8 ++++++-- include/nn/atk/detail/atk_BasicSoundPlayer.h | 6 +++++- include/nn/atk/detail/seq/atk_SequenceSound.h | 5 ++++- include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h | 7 +++++-- 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/include/nn/atk/detail/atk_AdvancedWaveSound.h b/include/nn/atk/detail/atk_AdvancedWaveSound.h index 7f1776d1..1e5fe526 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSound.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSound.h @@ -14,7 +14,11 @@ class AdvancedWaveSound : BasicSound { explicit AdvancedWaveSound(const AdvancedWaveSoundInstanceManager& manager); ~AdvancedWaveSound() override; +#if NN_SDK_VER < NN_MAKE_VER(5, 3, 0) + bool Initialize() override; +#else bool Initialize(OutputReceiver* pOutputReceiver) override; +#endif void Finalize() override; void Prepare(const driver::AdvancedWaveSoundPlayer::PrepareParameter& parameter); diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h b/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h index 28d258c5..a7a6a050 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h @@ -38,7 +38,11 @@ class AdvancedWaveSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { AdvancedWaveSoundPlayer(); ~AdvancedWaveSoundPlayer() override; - void Initialize(OutputReceiver* pOutputReceiver) override; +#if NN_SDK_VER < NN_MAKE_VER(5, 3, 0) + bool Initialize() override; +#else + bool Initialize(OutputReceiver* pOutputReceiver) override; +#endif void Finalize() override; void TearDownPlayer(); diff --git a/include/nn/atk/detail/atk_BasicSound.h b/include/nn/atk/detail/atk_BasicSound.h index 5e50049e..ad2839cb 100644 --- a/include/nn/atk/detail/atk_BasicSound.h +++ b/include/nn/atk/detail/atk_BasicSound.h @@ -4,9 +4,10 @@ #include #include +#include #include -#include #include +#include namespace nn::atk { class SoundActor; @@ -204,13 +205,16 @@ class BasicSound { BasicSound(); virtual ~BasicSound(); - +#if NN_SDK_VER < NN_MAKE_VER(5, 3, 0) virtual bool Initialize(); +#else virtual bool Initialize(OutputReceiver* pOutputReceiver); +#endif virtual void Finalize(); virtual bool IsPrepared() const = 0; virtual bool IsAttachedTempSpecialHandle() = 0; virtual void DetachTempSpecialHandle() = 0; + virtual driver::BasicSoundPlayer* GetBasicSoundPlayerHandle() = 0; virtual void OnUpdatePlayerPriority(); virtual void UpdateMoveValue(); virtual void OnUpdateParam(); diff --git a/include/nn/atk/detail/atk_BasicSoundPlayer.h b/include/nn/atk/detail/atk_BasicSoundPlayer.h index 9696c2cb..df6c0570 100644 --- a/include/nn/atk/detail/atk_BasicSoundPlayer.h +++ b/include/nn/atk/detail/atk_BasicSoundPlayer.h @@ -23,7 +23,11 @@ struct PlayerParamSet { class BasicSoundPlayer { public: virtual ~BasicSoundPlayer(); - virtual void Initialize(OutputReceiver* pOutputReceiver); +#if NN_SDK_VER < NN_MAKE_VER(5, 3, 0) + virtual bool Initialize(); +#else + virtual bool Initialize(OutputReceiver* pOutputReceiver); +#endif virtual void Finalize(); virtual void Start() = 0; virtual void Stop() = 0; diff --git a/include/nn/atk/detail/seq/atk_SequenceSound.h b/include/nn/atk/detail/seq/atk_SequenceSound.h index f06cc73a..479a9fd8 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSound.h +++ b/include/nn/atk/detail/seq/atk_SequenceSound.h @@ -21,8 +21,11 @@ class SequenceSound : BasicSound { explicit SequenceSound(SequenceSoundInstanceManager& manager); ~SequenceSound() override; +#if NN_SDK_VER < NN_MAKE_VER(5, 3, 0) bool Initialize() override; +#else bool Initialize(OutputReceiver* pOutputReceiver) override; +#endif void Finalize() override; void Setup(driver::SequenceTrackAllocator* trackAllocator, u32 allocTracks, @@ -76,7 +79,7 @@ class SequenceSound : BasicSound { bool IsPrepared() const override; - driver::BasicSoundPlayer* GetBasicSoundPlayerHandle(); + driver::BasicSoundPlayer* GetBasicSoundPlayerHandle() override; void OnUpdateParam() override; diff --git a/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h b/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h index 3bfd25d3..5cca307b 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h +++ b/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h @@ -177,8 +177,11 @@ class SequenceSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::Play SequenceSoundPlayer(); ~SequenceSoundPlayer() override; - void Initialize(); - void Initialize(OutputReceiver* pOutputReceiver) override; +#if NN_SDK_VER < NN_MAKE_VER(5, 3, 0) + bool Initialize() override; +#else + bool Initialize(OutputReceiver* pOutputReceiver) override; +#endif void Finalize() override; void FinishPlayer(); From 2fce86768c03664bec3c2ac4fde29635c217b46e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 27 Feb 2026 20:42:47 -0300 Subject: [PATCH 124/785] atk: Define `detail::SequenceSoundRuntime` --- include/nn/atk/detail/atk_NoteOnCallback.h | 4 + .../nn/atk/detail/atk_SoundArchiveManager.h | 2 +- .../atk/detail/seq/atk_SequenceSoundPlayer.h | 7 + .../atk/detail/seq/atk_SequenceSoundRuntime.h | 121 ++++++++++++++---- .../atk/detail/strm/atk_StreamSoundPlayer.h | 8 +- 5 files changed, 117 insertions(+), 25 deletions(-) diff --git a/include/nn/atk/detail/atk_NoteOnCallback.h b/include/nn/atk/detail/atk_NoteOnCallback.h index e4d53ebd..e3e65bfc 100644 --- a/include/nn/atk/detail/atk_NoteOnCallback.h +++ b/include/nn/atk/detail/atk_NoteOnCallback.h @@ -3,6 +3,8 @@ #include namespace nn::atk::detail::driver { +class SequenceSoundPlayer; + struct NoteOnInfo { s32 prgNo; s32 key; @@ -20,6 +22,8 @@ static_assert(sizeof(NoteOnInfo) == 0x38); class NoteOnCallback { public: virtual ~NoteOnCallback(); + virtual Channel* NoteOn(SequenceSoundPlayer* seqPlayer, u8 bankIndex, + const NoteOnInfo& noteOnInfo) = 0; }; static_assert(sizeof(NoteOnCallback) == 0x8); } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/atk_SoundArchiveManager.h b/include/nn/atk/detail/atk_SoundArchiveManager.h index 1be2e523..d30ef9e2 100644 --- a/include/nn/atk/detail/atk_SoundArchiveManager.h +++ b/include/nn/atk/detail/atk_SoundArchiveManager.h @@ -10,7 +10,7 @@ class SoundArchiveManager { public: using ContainerList = IntrusiveList; - class Snapshot { + class SnapShot { public: private: SoundArchive* m_MainSoundArchive; diff --git a/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h b/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h index 5cca307b..8df451cd 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h +++ b/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h @@ -253,6 +253,10 @@ class SequenceSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::Play void RequestLoad(StartInfo* info, SequenceSoundLoader::Arg* arg); + u64 GetProcessTick(SoundProfile&); + + void PrepareForMidi(const void**, const void**, bool*); + bool TryAllocLoader(); void ChannelCallback(Channel* channel); @@ -260,6 +264,9 @@ class SequenceSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::Play void OnUpdateFrameSoundThreadWithAudioFrameFrequency() override; void OnShutdownSoundThread() override; + static void SetSkipIntervalTick(s32); + static s32 GetSkipIntervalTick(); + private: bool m_ReleasePriorityFixFlag; bool m_IsPrepared; diff --git a/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h b/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h index 5401a5f3..3efe1ebc 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h +++ b/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h @@ -1,37 +1,114 @@ -/** - * @file SequenceSoundRuntime.h - * @brief Sequenced Sound Runtime Info - */ - #pragma once -#include - -namespace nn { -namespace atk { -namespace detail { -class SoundArchiveManager; +#include +#include +#include +#include +#include +#include +namespace nn::atk::detail { class SequenceSoundRuntime { public: + class SequenceNoteOnCallback : driver::NoteOnCallback { + public: + ~SequenceNoteOnCallback() override; + + driver::Channel* NoteOn(driver::SequenceSoundPlayer* seqPlayer, u8 bankIndex, + const driver::NoteOnInfo& noteOnInfo) override; + private: + SequenceSoundRuntime* m_pSequenceSoundRuntime; + }; + static_assert(sizeof(SequenceNoteOnCallback) == 0x10); + + struct PrepareContext { + SequenceSoundFile* pSequenceSoundFile; + u32 sequenceOffset; + u32 allocateTrackFlags; + LoadItemInfo loadTargetSequenceInfo; + LoadItemInfo loadTargetBankInfos[4]; + LoadItemInfo loadTargetWaveArchiveInfos[4]; + bool isLoadIndividuals[4]; + bool canUsePlayerHeap; + bool isRegisterDataLoadTaskNeeded; + }; + static_assert(sizeof(PrepareContext) == 0xa8); + SequenceSoundRuntime(); ~SequenceSoundRuntime(); - void Initialize(s32, void**, void const*); + void Initialize(s32 soundCount, void** pOutAllocatedAddr, const void* endAddr); void Finalize(); - void SetupSequenceTrack(s32, void**, void const*); - void SetupUserParam(void**, u64); + + void SetupSequenceTrack(s32 trackCount, void** pOutAllocatedAddr, const void* endAddr); + void SetupUserParam(void** pOutAllocatedAddr, std::size_t adjustSize); + + static std::size_t GetRequiredMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, + s32 alignment); + static std::size_t GetRequiredSequenceTrackMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, + s32 alignment); + bool IsSoundArchiveAvailable() const; + s32 GetActiveCount() const; s32 GetFreeCount() const; - void SetSequenceSkipIntervalTick(s32 tick); - s32 GetSequenceSkipIntervalTick(); + + static void SetSequenceSkipIntervalTick(s32 tick); + static s32 GetSequenceSkipIntervalTick(); + void Update(); - u8 _0[0xD0]; - nn::atk::detail::SoundArchiveManager* mArchiveManager; // _D0 - u64 _D8; + SequenceSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, + BasicSound::AmbientInfo* ambientArgInfo); + SequenceSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, + BasicSound::AmbientInfo* ambientArgInfo, OutputReceiver* pOutputReceiver); + + SoundStartable::StartResult PrepareImpl(const SoundArchiveManager::SnapShot& snapShot, + SoundArchive::ItemId soundId, + SequenceSound* sound, + const SoundArchive::SoundInfo* commonInfo, + const StartInfoReader& startInfoReader); + + SoundStartable::StartResult SetupSequenceSoundInfo(SoundStartable::StartInfo::SequenceSoundInfo* sequenceSoundInfo, + SoundArchive::ItemId soundId, + const SoundArchive& soundArchive, + const SoundStartable::StartInfo::SequenceSoundInfo* pExternalSequenceSoundInfo); + + SoundStartable::StartResult SetupSequenceSoundFile(PrepareContext* pOutContext, + const SequenceSound& sound, + const SoundArchive& soundArchive, + const SoundDataManager& soundDataManager, + const SoundArchive::SoundInfo& commonInfo, + const SoundStartable::StartInfo::SequenceSoundInfo* pExternalSequenceSoundInfo); + + SoundStartable::StartResult SetupBankFileAndWaveArchiveFile(PrepareContext* pOutContext, + const SequenceSound& sound, + const SoundStartable::StartInfo::SequenceSoundInfo& sequenceSoundInfo, + const SoundArchiveManager::SnapShot& snapShot, + const SoundStartable::StartInfo::SequenceSoundInfo* pExternalSequenceSoundInfo); + + void SetupSequenceSoundPlayerStartInfo(SoundStartable::StartInfo* startInfo, + SoundArchive::ItemId soundId, + const StartInfoReader& startInfoReader); + + void DumpMemory(const SoundArchive*) const; + + void SetupBankFileAndWaveArchiveFileFromHook(PrepareContext* pOutContext, + SequenceSound* sound, + SoundArchive* soundArchive); + + +private: + SequenceSoundInstanceManager m_SequenceSoundInstanceManager; + driver::SequenceSoundLoaderManager m_SequenceSoundLoaderManager; + driver::SequenceTrackAllocator* m_pSequenceTrackAllocator; + driver::MmlSequenceTrackAllocator m_MmlSequenceTrackAllocator; + driver::MmlParser m_MmlParser; + SequenceNoteOnCallback m_SequenceCallback; + SequenceUserProcCallback m_SequenceUserProcCallback; + void* m_pSequenceUserProcCallbackArg; + SoundArchiveManager* m_pSoundArchiveManager; + SoundArchiveFilesHook* m_pSoundArchiveFilesHook; }; -} // namespace detail -} // namespace atk -} // namespace nn +static_assert(sizeof(SequenceSoundRuntime) == 0xe8); +} // namespace nn::atk::detail diff --git a/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h b/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h index c5c6a2ec..9d7368e3 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h @@ -128,8 +128,12 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { StreamSoundPlayer(); ~StreamSoundPlayer() override; - void Initialize(); - void Initialize(OutputReceiver* pOutputReceiver) override; + +#if NN_SDK_VER < NN_MAKE_VER(5, 3, 0) + bool Initialize() override; +#else + bool Initialize(OutputReceiver* pOutputReceiver) override; +#endif bool TryAllocLoader(); From e6ac85b8a87ef5fb8aea58037749034906c0f5b5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 27 Feb 2026 20:56:07 -0300 Subject: [PATCH 125/785] atk: Define `StreamSoundHandle` --- include/nn/atk/atk_StreamSoundHandle.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/nn/atk/atk_StreamSoundHandle.h b/include/nn/atk/atk_StreamSoundHandle.h index e69de29b..6f7fe0a2 100644 --- a/include/nn/atk/atk_StreamSoundHandle.h +++ b/include/nn/atk/atk_StreamSoundHandle.h @@ -0,0 +1,24 @@ +#pragma once + +#include + +#include + +namespace nn::atk { +namespace detail { +class StreamSound; +} // namespace nn::atk::detail + +class StreamSoundHandle { +public: + using TrackBitFlagSet = util::BitFlagSet<8, void>; + + explicit StreamSoundHandle(SoundHandle* pSoundHandle); + + void detail_AttachSoundAsTempHandle(detail::StreamSound* pSound); + void DetachSound(); + +private: + detail::StreamSound* m_pSound; +}; +} // namespace nn::atk \ No newline at end of file From b60d222313a1e96dea4cd7450b0ac05ec60b8154 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 27 Feb 2026 21:15:38 -0300 Subject: [PATCH 126/785] atk: Define `detail::StreamSound` --- include/nn/atk/atk_SoundSystem.h | 5 +- include/nn/atk/detail/atk_AdvancedWaveSound.h | 4 +- include/nn/atk/detail/strm/atk_StreamSound.h | 79 +++++++++++++++++++ 3 files changed, 84 insertions(+), 4 deletions(-) diff --git a/include/nn/atk/atk_SoundSystem.h b/include/nn/atk/atk_SoundSystem.h index a41fa5e2..653bdcbd 100644 --- a/include/nn/atk/atk_SoundSystem.h +++ b/include/nn/atk/atk_SoundSystem.h @@ -6,6 +6,7 @@ #include #include +#include namespace nn::audio { struct MemoryPoolType; @@ -229,8 +230,8 @@ struct SoundSystem { static s32 GetDroppedLowLevelVoiceCount(); - // static void RegisterSoundThreadUpdateProfileReader(AtkProfileReader&); - // static void UnregisterSoundThreadUpdateProfileReader(AtkProfileReader&); + static void RegisterSoundThreadUpdateProfileReader(AtkProfileReader&); + static void UnregisterSoundThreadUpdateProfileReader(AtkProfileReader&); static bool ReadCircularBufferSink(void*, u64); diff --git a/include/nn/atk/detail/atk_AdvancedWaveSound.h b/include/nn/atk/detail/atk_AdvancedWaveSound.h index 1e5fe526..dbadae17 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSound.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSound.h @@ -28,9 +28,9 @@ class AdvancedWaveSound : BasicSound { bool IsAttachedTempSpecialHandle() override; void DetachTempSpecialHandle() override; - bool IsPrepared(); + bool IsPrepared() const override; - driver::BasicSoundPlayer* GetBasicSoundPlayerHandle(); + driver::BasicSoundPlayer* GetBasicSoundPlayerHandle() override; private: friend AdvancedWaveSoundInstanceManager; diff --git a/include/nn/atk/detail/strm/atk_StreamSound.h b/include/nn/atk/detail/strm/atk_StreamSound.h index e69de29b..76e0ed0f 100644 --- a/include/nn/atk/detail/strm/atk_StreamSound.h +++ b/include/nn/atk/detail/strm/atk_StreamSound.h @@ -0,0 +1,79 @@ +#pragma once + +#include +#include +#include + +namespace nn::atk::detail { +class StreamSound; +using StreamSoundInstanceManager = SoundInstanceManager; + +class StreamSound : BasicSound { +public: + explicit StreamSound(const StreamSoundInstanceManager& manager); + +#if NN_SDK_VER < NN_MAKE_VER(5, 3, 0) + bool Initialize() override; +#else + bool Initialize(OutputReceiver* pOutputReceiver) override; +#endif + void Finalize() override; + + void Setup(const driver::StreamSoundPlayer::SetupArg& arg); + + void Prepare(const driver::StreamSoundPlayer::PrepareArg& arg); + void PreparePrefetch(const void* strmPrefetchFile, + const driver::StreamSoundPlayer::PrepareArg& arg); + + void UpdateMoveValue() override; + + void OnUpdateParam() override; + + void SetTrackVolume(u32 trackBitFlag, f32 volume, s32); + void SetTrackInitialVolume(u32 trackBitFlag, u32 volume); + + void SetTrackOutputLine(u32 trackBitFlag, u32 outputLine); + void ResetTrackOutputLine(u32 trackBitFlag); + + void SetTrackMainOutVolume(u32 trackBitFlag, f32 volume); + void SetTrackChannelMixParameter(u32 trackBitFlag, u32 srcChNo, const MixParameter& param); + void SetTrackPan(u32 trackBitFlag, f32 pan); + void SetTrackSurroundPan(u32 trackBitFlag, f32 span); + void SetTrackMainSend(u32 trackBitFlag, f32 send); + void SetTrackFxSend(u32 trackBitFlag, AuxBus bus, f32 send); + + void OnUpdatePlayerPriority() override; + + bool IsAttachedTempSpecialHandle() override; + void DetachTempSpecialHandle() override; + + bool ReadStreamDataInfo(StreamDataInfo*) const; + + s32 GetPlayLoopCount() const; + position_t GetPlaySamplePosition() const; + f32 GetFilledBufferPercentage() const; + s32 GetBufferBlockCount(WaveBuffer::Status waveBufferStatus) const; + s32 GetTotalBufferBlockCount() const; + + bool IsPrepared() const override; + bool IsSuspendByLoadingDelay() const; + bool IsLoadingDelayState() const; + + driver::BasicSoundPlayer * GetBasicSoundPlayerHandle() override; + + util::IntrusiveListNode m_PriorityLink; + +private: + StreamSoundHandle* m_pTempSpecialHandle; + StreamSoundInstanceManager* m_Manager; + MoveValue m_TrackVolume[8]; + u16 m_AllocTrackFlag; + bool m_InitializeFlag; + u8 m_Padding[1]; + u32 m_AvailableTrackBitFlag[2]; + void* m_pCacheBuffer; + std::size_t m_CacheSize; + driver::StreamSoundPlayer m_PlayerInstance; +}; +static_assert(sizeof(StreamSound) == 0x11a40); +} // namespace nn::atk::detail \ No newline at end of file From b632c986817231a09e0ca1831170da49abba0b95 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 27 Feb 2026 21:25:48 -0300 Subject: [PATCH 127/785] atk: Define `detail::WaveSoundFileReader` --- .../atk/detail/wsd/atk_WaveSoundFileReader.h | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/include/nn/atk/detail/wsd/atk_WaveSoundFileReader.h b/include/nn/atk/detail/wsd/atk_WaveSoundFileReader.h index e69de29b..6a4aee86 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSoundFileReader.h +++ b/include/nn/atk/detail/wsd/atk_WaveSoundFileReader.h @@ -0,0 +1,50 @@ +#pragma once + +#include + +namespace nn::atk::detail { +struct WaveSoundInfo { + f32 pitch; + AdshrCurve adshr; + u8 pan; + u8 surroundPan; + u8 mainSend; + u8 fxSend[3]; + u8 lpfFreq; + u8 biquadType; + u8 biquadValue; +}; +static_assert(sizeof(WaveSoundInfo) == 0x14); + +struct WaveSoundNoteInfo { + u32 waveArchiveId; + s32 waveIndex; + AdshrCurve adshr; + u8 originalKey; + u8 pan; + u8 surroundPan; + u8 volume; + f32 pitch; +}; +static_assert(sizeof(WaveSoundNoteInfo) == 0x18); + +class WaveSoundFileReader { +public: + explicit WaveSoundFileReader(const void* waveSoundFile); + + s32 GetWaveSoundCount() const; + s32 GetNoteInfoCount(u32) const; + s32 GetTrackInfoCount(u32) const; + + bool ReadWaveSoundInfo(WaveSoundInfo* dst, u32 index) const; + + bool IsFilterSupportedVersion() const; + + bool ReadNoteInfo(WaveSoundNoteInfo* dst, u32 index, u32 noteIndex) const; + +private: + WaveSoundFile::FileHeader* m_pHeader; + WaveSoundFile::InfoBlockBody* m_pInfoBlockBody; +}; +static_assert(sizeof(WaveSoundFileReader) == 0x10); +} // namespace nn::atk::detail \ No newline at end of file From dac7a04782d19a28e5b085acc2b407268edee627 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 28 Feb 2026 10:46:32 -0300 Subject: [PATCH 128/785] atk: Define `detail::WaveSoundLoader` --- .../atk/detail/seq/atk_SequenceSoundPlayer.h | 7 +- .../nn/atk/detail/wsd/atk_WaveSoundLoader.h | 90 +++++++++++++++++++ 2 files changed, 94 insertions(+), 3 deletions(-) diff --git a/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h b/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h index 8df451cd..db2544ec 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h +++ b/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h @@ -22,6 +22,9 @@ static_assert(sizeof(SequenceUserProcCallbackParam) == 0x20); using SequenceUserProcCallback = void(*)(u16,SequenceUserProcCallbackParam*,void*); namespace detail::driver { +class SequenceSoundLoader; +using SequenceSoundLoaderManager = LoaderManager; + class SequenceSoundLoader { public: struct LoadInfo { @@ -98,7 +101,7 @@ class SequenceSoundLoader { bool TryWait(); private: - friend LoaderManager; + friend SequenceSoundLoaderManager; DataLoadTask m_Task; FreePlayerHeapTask m_FreePlayerHeapTask; @@ -107,8 +110,6 @@ class SequenceSoundLoader { }; static_assert(sizeof(SequenceSoundLoader) == 0x4b0); -using SequenceSoundLoaderManager = LoaderManager; - class SequenceSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::PlayerCallback { public: enum StartOffsetType { diff --git a/include/nn/atk/detail/wsd/atk_WaveSoundLoader.h b/include/nn/atk/detail/wsd/atk_WaveSoundLoader.h index e69de29b..581ffc1c 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSoundLoader.h +++ b/include/nn/atk/detail/wsd/atk_WaveSoundLoader.h @@ -0,0 +1,90 @@ +#pragma once + +#include +#include +#include +#include +#include + +namespace nn::atk::detail::driver { +class WaveSoundLoader; +using WaveSoundLoaderManager = LoaderManager; + +class WaveSoundLoader { +public: + struct Arg { + SoundArchive* soundArchive; + SoundDataManager* soundDataManager; + SoundPlayer* soundPlayer; + LoadItemInfo loadInfoWsd; + s32 index; + }; + static_assert(sizeof(Arg) == 0x30); + + struct Data { + void* wsdFile; + void* waveFile; + }; + static_assert(sizeof(Data) == 0x10); + + struct LoadInfo { + SoundArchive* soundArchive; + SoundDataManager* soundDataManager; + LoadItemInfo* loadInfoWsd; + SoundPlayer* soundPlayer; + }; + static_assert(sizeof(LoadInfo) == 0x20); + + class DataLoadTask : Task { + public: + ~DataLoadTask() override; + + void Initialize(); + + bool TryAllocPlayerHeap(); + + void Execute(TaskProfileLogger& logger) override; + + private: + Arg m_Arg; + Data m_Data; + PlayerHeap* m_pPlayerHeap; + PlayerHeapDataManager* m_pPlayerHeapDataManager; + bool m_IsLoadSuccess; + u8 m_Padding[3]; + }; + static_assert(sizeof(DataLoadTask) == 0xa0); + + class FreePlayerHeapTask : Task { + public: + ~FreePlayerHeapTask() override; + + void Initialize(); + + void Execute(TaskProfileLogger& logger) override; + + private: + Arg m_Arg; + PlayerHeap* m_pPlayerHeap; + PlayerHeapDataManager* m_pPlayerHeapDataManager; + }; + + WaveSoundLoader(); + ~WaveSoundLoader(); + + void Initialize(const Arg& arg); + void Finalize(); + + bool TryWait(); + + bool IsInUse(); + +private: + friend WaveSoundLoaderManager; + + DataLoadTask m_Task; + FreePlayerHeapTask m_FreePlayerHeapTask; + PlayerHeapDataManager m_PlayerHeapDataManager; + util::IntrusiveListNode m_LinkForLoaderManager; +}; +} // namespace nn::atk::detail::driver \ No newline at end of file From f34aa71582ea2a48181c5af80098a7624270407d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 28 Feb 2026 11:30:51 -0300 Subject: [PATCH 129/785] atk: Define `detail::driver::WaveSoundPlayer` --- .../nn/atk/detail/wsd/atk_WaveSoundPlayer.h | 138 ++++++++++++++++++ 1 file changed, 138 insertions(+) diff --git a/include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h b/include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h index e69de29b..c0473071 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h +++ b/include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h @@ -0,0 +1,138 @@ +#pragma once + +#include +#include +#include +#include + +namespace nn::atk::detail { +struct WaveSoundDataInfo { + bool loopFlag; + s32 sampleRate; + s64 loopStart; + s64 loopEnd; + s64 compatibleLoopStart; + s64 compatibleLoopEnd; + s32 channelCount; +}; +static_assert(sizeof(WaveSoundDataInfo) == 0x30); + +namespace driver { +class WaveSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::PlayerCallback { +public: + enum StartOffsetType { + StartOffsetType_Sample, + StartOffsetType_Millisec, + }; + + enum ResState { + ResState_Invalid, + ResState_ReceiveLoadReq, + ResState_AppendLoadTask, + ResState_Assigned, + }; + + constexpr static s32 SignatureFile = 0x44535746; // FWSD + + constexpr static u32 PauseReleaseValue = 127; + constexpr static u32 MuteReleaseValue = 127; + constexpr static u8 DefaultPriority = 64; + + struct StartInfo { + s32 index; + StartOffsetType startOffsetType; + s32 startOffset; + s32 delayTime; + s32 delayCount; + s32 waveSoundParameterFlag; + s32 release; + bool isContextCalculationSkipMode; + UpdateType updateType; + }; + static_assert(sizeof(StartInfo) == 0x24); + + struct PrepareArg { + void* wsdFile; + void* waveFile; + s8 waveType; + u8 padding[3]; + }; + static_assert(sizeof(PrepareArg) == 0x18); + + WaveSoundPlayer(); + ~WaveSoundPlayer() override; + +#if NN_SDK_VER < NN_MAKE_VER(5, 3, 0) + bool Initialize() override; +#else + bool Initialize(OutputReceiver* pOutputReceiver) override; +#endif + void Finalize() override; + + void FinishPlayer(); + + void CloseChannel(); + + void FreeLoader(); + + void Prepare(const StartInfo& info, const PrepareArg& arg); + void PrepareForPlayerHeap(const PrepareArg& arg); + + void RequestLoad(const StartInfo& info, const PrepareArg& arg); + + void Start() override; + void Stop() override; + void Pause(bool flag) override; + + void SetPanRange(f32 range); + void SetChannelPriority(s32 priority); + void SetReleasePriorityFix(bool fix); + + void InvalidateData(const void* start, const void* end) override; + + position_t GetPlaySamplePosition(bool) const; + + void Update(); + + bool TryAllocLoader(); + + bool StartChannel(); + void UpdateChannel(); + + static void ChannelCallbackFunc(Channel* dropChannel, + Channel::ChannelCallbackStatus status, void* userData); + + void OnUpdateFrameSoundThread() override; + void OnUpdateFrameSoundThreadWithAudioFrameFrequency() override; + void OnShutdownSoundThread() override; + +private: + bool m_WavePlayFlag; + bool m_ReleasePriorityFixFlag; + u8 m_Priority; + s8 m_WaveType; + f32 m_PanRange; + void* m_pWsdFile; + void* m_pWaveFile; + s32 m_WaveSoundIndex; + StartOffsetType m_StartOffsetType; + position_t m_StartOffset; + s32 m_DelayCount; + s32 m_Release; + s32 m_WaveSoundParameterFlag; + bool m_IsContextCalculationSkipMode; + CurveLfoParam m_LfoParam; + WaveSoundInfo m_WaveSoundInfo; + Channel* m_pChannel; + UpdateType m_UpdateType; + u8 m_ResState; + bool m_IsInitialized; + bool m_IsRegisterPlayerCallback; + u8 m_Padding[1]; + WaveSoundLoaderManager* m_pLoaderManager; + WaveSoundLoader* m_pLoader; + WaveSoundLoader::Arg m_LoaderArg; +}; +static_assert(sizeof(WaveSoundPlayer) == 0x1a0); +} // namespace nn::atk::detail::driver +} // namespace nn::atk::detail \ No newline at end of file From 56775fbe4a7b3cc1800ccf78744509cf6711c374 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 28 Feb 2026 12:19:08 -0300 Subject: [PATCH 130/785] atk: Define `detail::WaveSound` --- include/nn/atk/atk_SoundArchive.h | 1 + include/nn/atk/detail/atk_BasicSound.h | 1 + include/nn/atk/detail/seq/atk_SequenceSound.h | 4 +- .../atk/detail/seq/atk_SequenceSoundRuntime.h | 1 - include/nn/atk/detail/strm/atk_StreamSound.h | 7 +- .../atk/detail/strm/atk_StreamSoundLoader.h | 2 +- include/nn/atk/detail/wsd/atk_WaveSound.h | 67 +++++++++++++++++++ 7 files changed, 77 insertions(+), 6 deletions(-) diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index 31131a30..392fb35e 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -9,6 +9,7 @@ namespace nn::atk { namespace detail{ class SoundArchiveFileReader; struct SoundArchiveParametersHook; +struct SoundArchiveFilesHook; } // namespace nn::atk::detail class SoundArchive { diff --git a/include/nn/atk/detail/atk_BasicSound.h b/include/nn/atk/detail/atk_BasicSound.h index ad2839cb..4ecd47fd 100644 --- a/include/nn/atk/detail/atk_BasicSound.h +++ b/include/nn/atk/detail/atk_BasicSound.h @@ -204,6 +204,7 @@ class BasicSound { static_assert(sizeof(CommonParam) == 0x2c); BasicSound(); + virtual ~BasicSound(); #if NN_SDK_VER < NN_MAKE_VER(5, 3, 0) virtual bool Initialize(); diff --git a/include/nn/atk/detail/seq/atk_SequenceSound.h b/include/nn/atk/detail/seq/atk_SequenceSound.h index 479a9fd8..3e29c36f 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSound.h +++ b/include/nn/atk/detail/seq/atk_SequenceSound.h @@ -83,9 +83,11 @@ class SequenceSound : BasicSound { void OnUpdateParam() override; - util::IntrusiveListNode m_PriorityLink; private: + friend SequenceSoundInstanceManager; + + util::IntrusiveListNode m_PriorityLink; SequenceSoundHandle* m_pTempSpecialHandle; SequenceSoundInstanceManager* m_Manager; bool m_InitializeFlag; diff --git a/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h b/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h index 3efe1ebc..9d165a04 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h +++ b/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h @@ -5,7 +5,6 @@ #include #include #include -#include namespace nn::atk::detail { class SequenceSoundRuntime { diff --git a/include/nn/atk/detail/strm/atk_StreamSound.h b/include/nn/atk/detail/strm/atk_StreamSound.h index 76e0ed0f..a0eb4984 100644 --- a/include/nn/atk/detail/strm/atk_StreamSound.h +++ b/include/nn/atk/detail/strm/atk_StreamSound.h @@ -50,7 +50,7 @@ class StreamSound : BasicSound { bool ReadStreamDataInfo(StreamDataInfo*) const; s32 GetPlayLoopCount() const; - position_t GetPlaySamplePosition() const; + position_t GetPlaySamplePosition(bool) const; f32 GetFilledBufferPercentage() const; s32 GetBufferBlockCount(WaveBuffer::Status waveBufferStatus) const; s32 GetTotalBufferBlockCount() const; @@ -61,9 +61,10 @@ class StreamSound : BasicSound { driver::BasicSoundPlayer * GetBasicSoundPlayerHandle() override; - util::IntrusiveListNode m_PriorityLink; - private: + friend StreamSoundInstanceManager; + + util::IntrusiveListNode m_PriorityLink; StreamSoundHandle* m_pTempSpecialHandle; StreamSoundInstanceManager* m_Manager; MoveValue m_TrackVolume[8]; diff --git a/include/nn/atk/detail/strm/atk_StreamSoundLoader.h b/include/nn/atk/detail/strm/atk_StreamSoundLoader.h index 131b80dc..8e266556 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundLoader.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundLoader.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include @@ -71,7 +72,6 @@ struct LoadDataParam { }; static_assert(sizeof(LoadDataParam) == 0x98); -struct SoundArchiveFilesHook; struct FileStreamHookParam { SoundArchiveFilesHook* pSoundArchiveFilesHook; char* itemLabel; diff --git a/include/nn/atk/detail/wsd/atk_WaveSound.h b/include/nn/atk/detail/wsd/atk_WaveSound.h index e69de29b..40978cd0 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSound.h +++ b/include/nn/atk/detail/wsd/atk_WaveSound.h @@ -0,0 +1,67 @@ +#pragma once + +#include +#include +#include + +namespace nn::atk { +class WaveSoundHandle; + +namespace detail { +class WaveSound; +using WaveSoundInstanceManager = SoundInstanceManager; + +class WaveSound : BasicSound { +public: + explicit WaveSound(WaveSoundInstanceManager& manager); + ~WaveSound() override; + +#if NN_SDK_VER < NN_MAKE_VER(5, 3, 0) + bool Initialize() override; +#else + bool Initialize(OutputReceiver* pOutputReceiver) override; +#endif + void Finalize() override; + + void Prepare(const void* wsdFile, const void* waveFile, + const driver::WaveSoundPlayer::StartInfo& startInfo, s8 waveType); + + void RegisterDataLoadTask(const driver::WaveSoundLoader::LoadInfo& loadInfo, + const driver::WaveSoundPlayer::StartInfo& startInfo); + + void SetChannelPriority(s32 priority); + + void InitializeChannelParam(s32 priority, bool isReleasePriorityFix); + + void OnUpdatePlayerPriority() override; + + bool IsAttachedTempSpecialHandle() override; + void DetachTempSpecialHandle() override; + + bool ReadWaveSoundDataInfo(WaveSoundDataInfo*) const; + + position_t GetPlaySamplePosition(bool) const; + + bool IsPrepared() const override; + + driver::BasicSoundPlayer* GetBasicSoundPlayerHandle() override; + + void OnUpdateParam() override; + +private: + friend WaveSoundInstanceManager; + + util::IntrusiveListNode m_PriorityLink; + WaveSoundHandle* m_pTempSpecialHandle; + WaveSoundInstanceManager* m_Manager; + void* m_pWaveFile; + s8 m_WaveType; + bool m_InitializeFlag; + bool m_IsCalledPrepare; + u8 m_Padding[1]; + u32 m_ChannelCount; + driver::WaveSoundPlayer m_PlayerInstance; +}; +static_assert(sizeof(WaveSound) == 0x3e0); +} // namespace nn::atk::detail +} // namespace nn::atk \ No newline at end of file From efb0cd3f557e4d7a8ac666ef3315126f94bd3535 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 28 Feb 2026 12:19:27 -0300 Subject: [PATCH 131/785] atk: Redefine `detail::WaveSoundRuntime` --- .../nn/atk/detail/wsd/atk_WaveSoundRuntime.h | 46 +++++++++++++------ 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h b/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h index c956da89..096545a9 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h +++ b/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h @@ -1,29 +1,45 @@ -/** - * @file WaveSoundRuntime.h - * @brief Wave sound runtime info. - */ - #pragma once -#include +#include +#include -namespace nn { -namespace atk { -namespace detail { +namespace nn::atk::detail { class WaveSoundRuntime { public: WaveSoundRuntime(); ~WaveSoundRuntime(); - void Initialize(s32, void**, void const*); + void Initialize(s32 soundCount, void** pOutAllocatedAddr, const void* endAddr); void Finalize(); + + static std::size_t GetRequiredMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, + s32 alignment); + s32 GetActiveCount() const; s32 GetFreeWaveSoundCount() const; - void SetupUserParam(void**, u64); + + void SetupUserParam(void** startAddr, std::size_t adjustSize); + void Update(); + + WaveSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, + BasicSound::AmbientInfo* ambientArgInfo); + WaveSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, + BasicSound::AmbientInfo* ambientArgInfo, OutputReceiver* pOutputReceiver); + + SoundStartable::StartResult PrepareImpl(SoundArchive* pSoundArchive, + SoundDataManager* pSoundDataManager, + SoundArchive::ItemId soundId, + WaveSound* sound, + SoundArchive::SoundInfo* commonInfo, + StartInfoReader* startInfoReader); + + void DumpMemory(const SoundArchive*); - u8 _0[0x80]; +private: + WaveSoundInstanceManager m_WaveSoundInstanceManager; + driver::WaveSoundLoaderManager m_WaveSoundLoaderManager; + SoundArchiveFilesHook* m_pSoundArchiveFilesHook; }; -} // namespace detail -} // namespace atk -} // namespace nn +static_assert(sizeof(WaveSoundRuntime) == 0x88); +} // namespace nn::atk::detail From 3194f7b6401ef50388d79ee71a607728633cfa23 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 28 Feb 2026 12:53:18 -0300 Subject: [PATCH 132/785] atk: Redefine `detail::StreamSoundRuntime` --- .../atk/detail/seq/atk_SequenceSoundRuntime.h | 2 +- .../atk/detail/strm/atk_StreamSoundLoader.h | 7 +- .../atk/detail/strm/atk_StreamSoundRuntime.h | 72 +++++++++++++++---- .../nn/atk/detail/wsd/atk_WaveSoundRuntime.h | 10 +-- 4 files changed, 70 insertions(+), 21 deletions(-) diff --git a/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h b/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h index 9d165a04..5e6a0148 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h +++ b/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h @@ -36,7 +36,7 @@ class SequenceSoundRuntime { SequenceSoundRuntime(); ~SequenceSoundRuntime(); - void Initialize(s32 soundCount, void** pOutAllocatedAddr, const void* endAddr); + bool Initialize(s32 soundCount, void** pOutAllocatedAddr, const void* endAddr); void Finalize(); void SetupSequenceTrack(s32 trackCount, void** pOutAllocatedAddr, const void* endAddr); diff --git a/include/nn/atk/detail/strm/atk_StreamSoundLoader.h b/include/nn/atk/detail/strm/atk_StreamSoundLoader.h index 8e266556..d01c2e42 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundLoader.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundLoader.h @@ -81,6 +81,9 @@ static_assert(sizeof(FileStreamHookParam) == 0x10); namespace driver { class StreamSoundPlayer; +class StreamSoundLoader; +using StreamSoundLoaderManager = LoaderManager; + class StreamSoundLoader { public: class StreamHeaderLoadTask : Task { @@ -227,6 +230,8 @@ class StreamSoundLoader { void UpdateAdpcmInfoForStartOffset(const void*, s32, const BlockInfo&); private: + friend StreamSoundLoaderManager; + StreamSoundFileLoader m_FileLoader; StreamSoundPlayer* m_PlayerHandle; fnd::FileStream* m_pFileStream; @@ -267,7 +272,5 @@ class StreamSoundLoader { util::IntrusiveListNode m_LinkForLoaderManager; }; static_assert(sizeof(StreamSoundLoader) == 0x3640); - -using StreamSoundLoaderManager = LoaderManager; } // namespace nn::atk::detail::driver } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h b/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h index 16863f41..60c47e9c 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h @@ -1,22 +1,68 @@ -/** - * @file StreamSoundRuntime.h - * @brief Stream sound runtime information. - */ - #pragma once -#include +#include +#include +#include -namespace nn { -namespace atk { -namespace detail { +namespace nn::atk::detail { class StreamSoundRuntime { public: StreamSoundRuntime(); ~StreamSoundRuntime(); - u8 _0[0xB0]; + bool Initialize(s32 soundCount, void** pOutAllocatedAddr, const void* endAddr, + void* streamInstanceBuffer, std::size_t streamInstanceBufferSize); + + static std::size_t GetRequiredStreamInstanceSize(s32 soundCount); + + bool SetupStreamBuffer(const SoundArchive* pSoundArchive, void* strmBuffer, + std::size_t strmBufferSize); + bool SetupStreamBuffer(const SoundArchive* pSoundArchive, void* strmBuffer, + std::size_t strmBufferSize, driver::StreamBufferPool* strmBufferPool); + + std::size_t GetRequiredStreamBufferSize(const SoundArchive* soundArchive) const; + static u32 GetRequiredStreamBufferTimes(const SoundArchive* soundArchive); + + bool SetupStreamCacheBuffer(const SoundArchive* pSoundArchive, void* streamCacheBuffer, + std::size_t streamCacheSize); + + void Finalize(); + + static std::size_t GetRequiredMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, + s32 alignment); + + static std::size_t GetRequiredStreamCacheSize(const SoundArchive* pSoundArchive, + std::size_t); + + s32 GetActiveCount() const; + s32 GetActiveChannelCount() const; + s32 GetActiveTrackCount() const; + s32 GetFreeCount() const; + + void SetupUserParam(void** pOutAllocatedAddr, std::size_t adjustSize); + + void Update(); + + StreamSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, + BasicSound::AmbientInfo* ambientArgInfo); + StreamSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, + BasicSound::AmbientInfo* ambientArgInfo, OutputReceiver* pOutputReceiver); + + SoundStartable::StartResult PrepareImpl(const SoundArchive* pSoundArchive, + const SoundDataManager* pSoundDataManager, + SoundArchive::ItemId soundId, + StreamSound* sound, + const SoundArchive::SoundInfo* commonInfo, + const StartInfoReader& startInfoReader); + + void DumpMemory(const SoundArchive* pSoundArchive); + +private: + StreamSoundInstanceManager m_StreamSoundInstanceManager; + driver::StreamSoundLoaderManager m_StreamSoundLoaderManager; + driver::StreamBufferPool m_StreamBufferPool; + SoundArchiveFilesHook* m_pSoundArchiveFilesHook; + s32 m_StreamBlockCount; }; -} // namespace detail -} // namespace atk -} // namespace nn +static_assert(sizeof(StreamSoundRuntime) == 0xb8); +} // namespace nn::atk::detail diff --git a/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h b/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h index 096545a9..2519b574 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h +++ b/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h @@ -9,7 +9,7 @@ class WaveSoundRuntime { WaveSoundRuntime(); ~WaveSoundRuntime(); - void Initialize(s32 soundCount, void** pOutAllocatedAddr, const void* endAddr); + bool Initialize(s32 soundCount, void** pOutAllocatedAddr, const void* endAddr); void Finalize(); static std::size_t GetRequiredMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, @@ -27,12 +27,12 @@ class WaveSoundRuntime { WaveSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, BasicSound::AmbientInfo* ambientArgInfo, OutputReceiver* pOutputReceiver); - SoundStartable::StartResult PrepareImpl(SoundArchive* pSoundArchive, - SoundDataManager* pSoundDataManager, + SoundStartable::StartResult PrepareImpl(const SoundArchive* pSoundArchive, + const SoundDataManager* pSoundDataManager, SoundArchive::ItemId soundId, WaveSound* sound, - SoundArchive::SoundInfo* commonInfo, - StartInfoReader* startInfoReader); + const SoundArchive::SoundInfo* commonInfo, + const StartInfoReader& startInfoReader); void DumpMemory(const SoundArchive*); From 2c7161282744ac361d6ff4a756048909c991606a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 28 Feb 2026 13:21:30 -0300 Subject: [PATCH 133/785] audio: Define `MemoryPoolType` --- CMakeLists.txt | 1 + include/nn/audio/audio_MemoryPoolTypes.h | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 include/nn/audio/audio_MemoryPoolTypes.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f7382194..14dba657 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -236,6 +236,7 @@ add_library(NintendoSDK OBJECT include/nn/audio/audio_Common.h include/nn/audio/audio_EffectTypes.h include/nn/audio/audio_FinalMixTypes.h + include/nn/audio/audio_MemoryPoolTypes.h include/nn/audio/audio_PerformanceMetrics.h include/nn/audio/audio_PerformanceMetricsTypes.h include/nn/audio/audio_SubMixTypes.h diff --git a/include/nn/audio/audio_MemoryPoolTypes.h b/include/nn/audio/audio_MemoryPoolTypes.h new file mode 100644 index 00000000..a7a0c405 --- /dev/null +++ b/include/nn/audio/audio_MemoryPoolTypes.h @@ -0,0 +1,17 @@ +#pragma once + +namespace nn::audio { +struct MemoryPoolInfo {}; + +struct MemoryPoolType { + enum State { + State_RequestAttach, + State_Attached, + State_RequestDetach, + State_Detached, + }; + + MemoryPoolInfo* _pMemoryPoolInfo; +}; +static_assert(sizeof(MemoryPoolType) == 0x8); +} // namespace nn::audio From 82593d08c7028535c98f236274bc56c24763fef1 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 28 Feb 2026 15:08:40 -0300 Subject: [PATCH 134/785] atk: Redefine `SoundArchivePlayer` Other changes: - Modified valid NN_SDK_VER for some functions --- include/nn/atk/atk_SoundArchivePlayer.h | 213 ++++++++++++++++-- include/nn/atk/atk_SoundStartable.h | 6 +- include/nn/atk/detail/atk_AdvancedWaveSound.h | 2 +- .../atk/detail/atk_AdvancedWaveSoundPlayer.h | 2 +- include/nn/atk/detail/atk_BasicSound.h | 2 +- include/nn/atk/detail/atk_BasicSoundPlayer.h | 2 +- include/nn/atk/detail/seq/atk_SequenceSound.h | 2 +- .../atk/detail/seq/atk_SequenceSoundPlayer.h | 2 +- include/nn/atk/detail/strm/atk_StreamSound.h | 2 +- .../atk/detail/strm/atk_StreamSoundPlayer.h | 2 +- .../atk/detail/strm/atk_StreamSoundRuntime.h | 2 +- include/nn/atk/detail/wsd/atk_WaveSound.h | 2 +- .../nn/atk/detail/wsd/atk_WaveSoundPlayer.h | 2 +- .../nn/atk/detail/wsd/atk_WaveSoundRuntime.h | 2 +- 14 files changed, 207 insertions(+), 36 deletions(-) diff --git a/include/nn/atk/atk_SoundArchivePlayer.h b/include/nn/atk/atk_SoundArchivePlayer.h index a42848b3..ef27d053 100644 --- a/include/nn/atk/atk_SoundArchivePlayer.h +++ b/include/nn/atk/atk_SoundArchivePlayer.h @@ -1,37 +1,208 @@ -/** - * @file SoundArchivePlayer.h - * @brief Basic sound player from a sound archive. - */ - #pragma once -#include +#include + #include #include #include #include -namespace nn { -namespace atk { -class SoundArchivePlayer { +namespace nn::atk { +class SoundArchivePlayer : SoundStartable { public: - SoundArchivePlayer(); + constexpr static u32 BufferAlignSize = 4096; + constexpr static u32 StreamBufferTimesMax = 4; + constexpr static u8 UserParamBoundary = 4; + + struct InitializeParam { + SoundArchive* pSoundArchive; + SoundDataManager* pSoundDataManager; + void* pSetupBuffer; + std::size_t setupBufferSize; + void* pStreamBuffer; + std::size_t streamBufferSize; + void* pStreamCacheBuffer; + std::size_t streamCacheSize; + bool enablePreparingStreamInstanceBufferFromSetupBuffer; + void* pStreamInstanceBuffer; + std::size_t streamInstanceBufferSize; + std::size_t userParamSizePerSound; + s32 addonSoundArchiveCount; + }; + static_assert(sizeof(InitializeParam) == 0x68); + + struct StreamSoundInstanceState { + s32 activeStreamSoundInstanceCount; + s32 activeStreamChannelCount; + s32 activeStreamTrackCount; + }; + static_assert(sizeof(StreamSoundInstanceState) == 0xc); - virtual ~SoundArchivePlayer(); + SoundArchivePlayer(); + ~SoundArchivePlayer() override; bool IsAvailable() const; + + bool Initialize(const SoundArchive* arc, const SoundDataManager* manager, void* buffer, + std::size_t size, void* strmBuffer, std::size_t strmBufferSize, + std::size_t userParamSizePerSound); + bool Initialize(const InitializeParam& param); + void Finalize(); + void StopAllSound(s32, bool); void DisposeInstances(); - nn::atk::detail::SoundArchiveManager mArchiveManager; // _8 - nn::atk::detail::SequenceSoundRuntime mSeqSoundRuntime; // _50 - nn::atk::detail::WaveSoundRuntime mWaveSoundRuntime; // _130 - nn::atk::detail::AdvancedWaveSoundRuntime mAdvancedWaveSound; // _1B0 - nn::atk::detail::StreamSoundRuntime mStreamSoundRuntime; // _1E0 - u64 _290; - u32 _298; - u8 _29C[0x2E8 - 0x29C]; + static std::size_t GetRequiredMemSize(const SoundArchive* arc); + static std::size_t GetRequiredMemSize(const SoundArchive* arc, std::size_t userParamSizePerSound, + s32 addonSoundArchiveCount); + static std::size_t GetRequiredMemSize(const SoundArchive* arc, std::size_t userParamSizePerSound); + static std::size_t GetRequiredMemSize(const InitializeParam& param); + + static std::size_t GetRequiredStreamInstanceSize(const SoundArchive* arc); + + std::size_t GetRequiredStreamBufferSize(const SoundArchive* arc) const; + std::size_t GetRequiredStreamBufferTimes(const SoundArchive* arc) const; + + static std::size_t GetRequiredStreamCacheSize(const SoundArchive* arc, std::size_t); + + + bool SetupMram(const SoundArchive* pArc, void* buffer, std::size_t size, + std::size_t userParamSizePerSound, s32 addonSoundArchiveCount, + void* streamSoundInstanceBuffer, std::size_t streamSoundInstanceBufferSize); + + bool SetupSoundPlayer(const SoundArchive* pArc, void** pOutAllocatedAddr, const void* endAddr); + bool SetupAddonSoundArchiveContainer(s32 containerCount, void** pOutAllocatedAddr, const void* endAddr); + bool SetupUserParamForBasicSound(const SoundArchive::SoundArchivePlayerInfo& playerInfo, + void** pOutAllocatedAddr, const void* endAddr, std::size_t); + + detail::PlayerHeap* CreatePlayerHeap(void** pOutAllocatedAddr, const void* endAddr, std::size_t); + + void Update(); + + SoundPlayer* GetSoundPlayer(u32); + + SoundArchive* GetSoundArchive() const; + AddonSoundArchive* GetAddonSoundArchive(const char*) const; + AddonSoundArchive* GetAddonSoundArchive(s32) const; + char* GetAddonSoundArchiveName(s32) const; + os::Tick* GetAddonSoundArchiveAddTick(s32) const; + SoundDataManager* GetAddonSoundDataManager(const char*) const; + + SoundPlayer* GetSoundPlayer(u32) const; + SoundPlayer* GetSoundPlayer(const char*); + SoundPlayer* GetSoundPlayer(const char*) const; + + void* detail_GetFileAddress(SoundArchive::FileId fileId) const; + + void AddAddonSoundArchive(const char*, const AddonSoundArchive*, const SoundDataManager*); + void RemoveAddonSoundArchive(const AddonSoundArchive*); + + void SetDefaultOutputReceiver(OutputReceiver* pOutputReceiver); + + StartResult detail_SetupSound(SoundHandle* handle, u32 soundId, bool holdFlag, + const char* soundArchiveName, const StartInfo* startInfo) override; + StartResult detail_SetupSoundImpl(SoundHandle* handle, u32 soundId, + detail::BasicSound::AmbientInfo* ambientArgInfo, + SoundActor* actor, bool holdFlag, const char* soundArchiveName, + const StartInfo* startInfo); + + bool IsSoundArchiveFileHooksEnabled() const; + + void LockSoundArchiveFileHooks(); + + bool IsSequenceSoundEdited(const char*) const; + bool IsStreamSoundEdited(const char*) const; + bool IsWaveSoundEdited(const char*) const; + + void EnableHook(const SoundArchive*, bool); + + StartResult PreprocessSinglePlay(const SoundArchive::SoundInfo& info, u32 soundId, + SoundPlayer& player); + + void SetCommonSoundParam(detail::BasicSound* pSound, const SoundArchive::SoundInfo* info); + + void UnlockSoundArchiveFileHooks(); + + void SetSequenceUserProcCallback(SequenceUserProcCallback callback, void* arg); + + static void SetSequenceSkipIntervalTick(s32 tick); + static s32 GetSequenceSkipIntervalTick(); + + Result ReadWaveSoundDataInfo(detail::WaveSoundDataInfo*, u32, const SoundArchive*, + const SoundDataManager*) const; + Result ReadWaveSoundDataInfo(detail::WaveSoundDataInfo*, u32, const char*) const; + Result ReadWaveSoundDataInfo(detail::WaveSoundDataInfo*, const char*, const char*) const; + Result ReadWaveSoundDataInfo(detail::WaveSoundDataInfo*, u32) const; + Result ReadWaveSoundDataInfo(detail::WaveSoundDataInfo*, const char*) const; + + Result ReadStreamSoundDataInfo(detail::StreamSoundDataInfo*, const SoundArchive*, u32) const; + Result ReadStreamSoundDataInfo(detail::StreamSoundDataInfo*, u32, const char*) const; + Result ReadStreamSoundDataInfo(detail::StreamSoundDataInfo*, const char*, const char*) const; + Result ReadStreamSoundDataInfo(detail::StreamSoundDataInfo*, u32) const; + Result ReadStreamSoundDataInfo(detail::StreamSoundDataInfo*, const char*) const; + + static std::size_t GetRequiredWorkBufferSizeToReadStreamSoundHeader(); + + Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, u32, + const char* const*, s32, const SoundArchive*, + void*, std::size_t) const; + Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, u32, const char*, + void*, std::size_t) const; + Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, u32, + const char* const*, s32, void*, std::size_t, + const char*) const; + Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, const char*, + const char*, void*, std::size_t) const; + Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, const char*, + const char* const*, s32, void*, std::size_t, + const char*) const; + Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, u32, + const char* const*, s32, void*, std::size_t) const; + Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, const char*, + const char* const*, s32, void*, std::size_t) const; + Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, const char*, + const char*, void*, std::size_t, + const char* soundArchiveName) const; + Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, u32, const char*, + void*, std::size_t, const char* soundArchiveName) const; + + void DumpMemory() const; + + bool ReadStreamSoundInstanceState(StreamSoundInstanceState*) const; + + Result CheckStreamSoundFileExisting(u32) const; + Result CheckStreamSoundFileExisting(u32, const char* soundArchiveName) const; + Result CheckStreamSoundFileExisting(char* streamSoundName) const; + Result CheckStreamSoundFileExisting(const char*, const char*) const; + Result CheckStreamSoundFileExisting(const SoundArchive*, u32) const; + + SoundArchive::ItemId detail_GetItemId(char* pString) override; + SoundArchive::ItemId detail_GetItemId(char* pString, const char* soundArchiveName) override; + + +private: + detail::SoundArchiveManager m_SoundArchiveManager; + u32 m_SoundPlayerCount; + SoundPlayer* m_pSoundPlayers; + detail::SequenceSoundRuntime m_SequenceSoundRuntime; + detail::WaveSoundRuntime m_WaveSoundRuntime; + detail::AdvancedWaveSoundRuntime m_AdvancedWaveSoundRuntime; + detail::StreamSoundRuntime m_StreamSoundRuntime; + std::size_t m_SoundUserParamSize; + s32 m_ArchiveContainerCount; + detail::AddonSoundArchiveContainer* m_pArchiveContainers; + os::Tick m_AddonSoundArchiveLastAddTick; + audio::MemoryPoolType m_MemoryPoolForStreamInstance; + bool m_IsMemoryPoolForStreamInstanceAttached; + audio::MemoryPoolType m_MemoryPoolForPlayerHeap; + bool m_IsMemoryPoolForPlayerHeapAttached; + detail::SoundArchiveFilesHook* m_pSoundArchiveFilesHook; + bool m_IsEnableWarningPrint; + bool m_IsInitialized; + bool m_IsAdvancedWaveSoundEnabled; + OutputReceiver* m_pDefaultOutputReceiver; + u8 m_Padding[1]; }; -} // namespace atk -} // namespace nn +static_assert(sizeof(SoundArchivePlayer) == 0x310); +} // namespace nn::atk diff --git a/include/nn/atk/atk_SoundStartable.h b/include/nn/atk/atk_SoundStartable.h index 6ae7f6f0..24a3e9d5 100644 --- a/include/nn/atk/atk_SoundStartable.h +++ b/include/nn/atk/atk_SoundStartable.h @@ -126,10 +126,10 @@ class SoundStartable { virtual ~SoundStartable() = 0; - virtual StartResult detail_SetupSound(SoundHandle* handle, - u32 soundId, bool holdFlag, - const char* soundArchiveName, + virtual StartResult detail_SetupSound(SoundHandle* handle, u32 soundId, + bool holdFlag, const char* soundArchiveName, const StartInfo* startInfo) = 0; + virtual SoundArchive::ItemId detail_GetItemId(char* pString) = 0; virtual SoundArchive::ItemId detail_GetItemId(char* pString, const char* soundArchiveName) = 0; diff --git a/include/nn/atk/detail/atk_AdvancedWaveSound.h b/include/nn/atk/detail/atk_AdvancedWaveSound.h index dbadae17..1da59b2d 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSound.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSound.h @@ -14,7 +14,7 @@ class AdvancedWaveSound : BasicSound { explicit AdvancedWaveSound(const AdvancedWaveSoundInstanceManager& manager); ~AdvancedWaveSound() override; -#if NN_SDK_VER < NN_MAKE_VER(5, 3, 0) +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) bool Initialize() override; #else bool Initialize(OutputReceiver* pOutputReceiver) override; diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h b/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h index a7a6a050..cc23ecde 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h @@ -38,7 +38,7 @@ class AdvancedWaveSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { AdvancedWaveSoundPlayer(); ~AdvancedWaveSoundPlayer() override; -#if NN_SDK_VER < NN_MAKE_VER(5, 3, 0) +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) bool Initialize() override; #else bool Initialize(OutputReceiver* pOutputReceiver) override; diff --git a/include/nn/atk/detail/atk_BasicSound.h b/include/nn/atk/detail/atk_BasicSound.h index 4ecd47fd..601c9c18 100644 --- a/include/nn/atk/detail/atk_BasicSound.h +++ b/include/nn/atk/detail/atk_BasicSound.h @@ -206,7 +206,7 @@ class BasicSound { BasicSound(); virtual ~BasicSound(); -#if NN_SDK_VER < NN_MAKE_VER(5, 3, 0) +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) virtual bool Initialize(); #else virtual bool Initialize(OutputReceiver* pOutputReceiver); diff --git a/include/nn/atk/detail/atk_BasicSoundPlayer.h b/include/nn/atk/detail/atk_BasicSoundPlayer.h index df6c0570..911aa98c 100644 --- a/include/nn/atk/detail/atk_BasicSoundPlayer.h +++ b/include/nn/atk/detail/atk_BasicSoundPlayer.h @@ -23,7 +23,7 @@ struct PlayerParamSet { class BasicSoundPlayer { public: virtual ~BasicSoundPlayer(); -#if NN_SDK_VER < NN_MAKE_VER(5, 3, 0) +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) virtual bool Initialize(); #else virtual bool Initialize(OutputReceiver* pOutputReceiver); diff --git a/include/nn/atk/detail/seq/atk_SequenceSound.h b/include/nn/atk/detail/seq/atk_SequenceSound.h index 3e29c36f..dd893676 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSound.h +++ b/include/nn/atk/detail/seq/atk_SequenceSound.h @@ -21,7 +21,7 @@ class SequenceSound : BasicSound { explicit SequenceSound(SequenceSoundInstanceManager& manager); ~SequenceSound() override; -#if NN_SDK_VER < NN_MAKE_VER(5, 3, 0) +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) bool Initialize() override; #else bool Initialize(OutputReceiver* pOutputReceiver) override; diff --git a/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h b/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h index db2544ec..9a888e54 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h +++ b/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h @@ -178,7 +178,7 @@ class SequenceSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::Play SequenceSoundPlayer(); ~SequenceSoundPlayer() override; -#if NN_SDK_VER < NN_MAKE_VER(5, 3, 0) +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) bool Initialize() override; #else bool Initialize(OutputReceiver* pOutputReceiver) override; diff --git a/include/nn/atk/detail/strm/atk_StreamSound.h b/include/nn/atk/detail/strm/atk_StreamSound.h index a0eb4984..db17a276 100644 --- a/include/nn/atk/detail/strm/atk_StreamSound.h +++ b/include/nn/atk/detail/strm/atk_StreamSound.h @@ -12,7 +12,7 @@ class StreamSound : BasicSound { public: explicit StreamSound(const StreamSoundInstanceManager& manager); -#if NN_SDK_VER < NN_MAKE_VER(5, 3, 0) +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) bool Initialize() override; #else bool Initialize(OutputReceiver* pOutputReceiver) override; diff --git a/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h b/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h index 9d7368e3..ab3a2cd6 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h @@ -129,7 +129,7 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { ~StreamSoundPlayer() override; -#if NN_SDK_VER < NN_MAKE_VER(5, 3, 0) +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) bool Initialize() override; #else bool Initialize(OutputReceiver* pOutputReceiver) override; diff --git a/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h b/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h index 60c47e9c..b2588877 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h @@ -55,7 +55,7 @@ class StreamSoundRuntime { const SoundArchive::SoundInfo* commonInfo, const StartInfoReader& startInfoReader); - void DumpMemory(const SoundArchive* pSoundArchive); + void DumpMemory(const SoundArchive* pSoundArchive) const; private: StreamSoundInstanceManager m_StreamSoundInstanceManager; diff --git a/include/nn/atk/detail/wsd/atk_WaveSound.h b/include/nn/atk/detail/wsd/atk_WaveSound.h index 40978cd0..e71be46e 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSound.h +++ b/include/nn/atk/detail/wsd/atk_WaveSound.h @@ -16,7 +16,7 @@ class WaveSound : BasicSound { explicit WaveSound(WaveSoundInstanceManager& manager); ~WaveSound() override; -#if NN_SDK_VER < NN_MAKE_VER(5, 3, 0) +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) bool Initialize() override; #else bool Initialize(OutputReceiver* pOutputReceiver) override; diff --git a/include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h b/include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h index c0473071..58a84061 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h +++ b/include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h @@ -62,7 +62,7 @@ class WaveSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::PlayerCa WaveSoundPlayer(); ~WaveSoundPlayer() override; -#if NN_SDK_VER < NN_MAKE_VER(5, 3, 0) +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) bool Initialize() override; #else bool Initialize(OutputReceiver* pOutputReceiver) override; diff --git a/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h b/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h index 2519b574..2114fcd7 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h +++ b/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h @@ -34,7 +34,7 @@ class WaveSoundRuntime { const SoundArchive::SoundInfo* commonInfo, const StartInfoReader& startInfoReader); - void DumpMemory(const SoundArchive*); + void DumpMemory(const SoundArchive*) const; private: WaveSoundInstanceManager m_WaveSoundInstanceManager; From 11db93bd516cd712522f6d603639f8582c158e85 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 28 Feb 2026 15:12:59 -0300 Subject: [PATCH 135/785] audio: Add `audio_SampleFormat.h` header --- CMakeLists.txt | 1 + include/nn/audio/audio_SampleFormat.h | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 include/nn/audio/audio_SampleFormat.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 14dba657..f545fe97 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -239,6 +239,7 @@ add_library(NintendoSDK OBJECT include/nn/audio/audio_MemoryPoolTypes.h include/nn/audio/audio_PerformanceMetrics.h include/nn/audio/audio_PerformanceMetricsTypes.h + include/nn/audio/audio_SampleFormat.h include/nn/audio/audio_SubMixTypes.h include/nn/audio/audio_VoiceTypes.h diff --git a/include/nn/audio/audio_SampleFormat.h b/include/nn/audio/audio_SampleFormat.h new file mode 100644 index 00000000..4380b223 --- /dev/null +++ b/include/nn/audio/audio_SampleFormat.h @@ -0,0 +1,13 @@ +#pragma once + +namespace nn::audio { +enum SampleFormat { + SampleFormat_Invalid, + SampleFormat_PcmInt8, + SampleFormat_PcmInt16, + SampleFormat_PcmInt24, + SampleFormat_PcmInt32, + SampleFormat_PcmFloat, + SampleFormat_Adpcm, +}; +} // namespace nn::audio \ No newline at end of file From 2116452b4dc7d229ea8bfab815b0689d50d5b3aa Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 28 Feb 2026 15:15:38 -0300 Subject: [PATCH 136/785] audio: Add `audio_SinkTypes.h` header --- CMakeLists.txt | 1 + include/nn/audio/audio_SinkTypes.h | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 include/nn/audio/audio_SinkTypes.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f545fe97..c9b48bd7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -240,6 +240,7 @@ add_library(NintendoSDK OBJECT include/nn/audio/audio_PerformanceMetrics.h include/nn/audio/audio_PerformanceMetricsTypes.h include/nn/audio/audio_SampleFormat.h + include/nn/audio/audio_SinkTypes.h include/nn/audio/audio_SubMixTypes.h include/nn/audio/audio_VoiceTypes.h diff --git a/include/nn/audio/audio_SinkTypes.h b/include/nn/audio/audio_SinkTypes.h new file mode 100644 index 00000000..d9775fff --- /dev/null +++ b/include/nn/audio/audio_SinkTypes.h @@ -0,0 +1,20 @@ +#pragma once + +namespace nn::audio { +struct SinkInfo {}; + +struct DeviceSinkType { + struct DownMixParameter { + float coeff[16]; + }; + static_assert(sizeof(DownMixParameter) == 0x40); + + SinkInfo* _handle; +}; +static_assert(sizeof(DeviceSinkType) == 0x8); + +struct CircularBufferSinkType { + SinkInfo* _handle; +}; +static_assert(sizeof(CircularBufferSinkType) == 0x8); +} // namespace nn::audio \ No newline at end of file From 8eb7cc0f3a85d9cd3554f36981bdee270d78c772 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 28 Feb 2026 15:18:46 -0300 Subject: [PATCH 137/785] audio: Add `audio_WaveBuffer.h` header --- CMakeLists.txt | 1 + include/nn/audio/audio_WaveBuffer.h | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 include/nn/audio/audio_WaveBuffer.h diff --git a/CMakeLists.txt b/CMakeLists.txt index c9b48bd7..9a73dc27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -243,6 +243,7 @@ add_library(NintendoSDK OBJECT include/nn/audio/audio_SinkTypes.h include/nn/audio/audio_SubMixTypes.h include/nn/audio/audio_VoiceTypes.h + include/nn/audio/audio_WaveBuffer.h include/nn/atk/atk_Adpcm.h include/nn/atk/atk_BiquadFilterCallback.h diff --git a/include/nn/audio/audio_WaveBuffer.h b/include/nn/audio/audio_WaveBuffer.h new file mode 100644 index 00000000..282ae5d7 --- /dev/null +++ b/include/nn/audio/audio_WaveBuffer.h @@ -0,0 +1,17 @@ +#pragma once + +#include + +namespace nn::audio { +struct WaveBuffer { + void* buffer; + size_t size; + s32 startSampleOffset; + s32 endSampleOffset; + bool loop; + bool isEndOfStream; + void* pContext; + size_t contextSize; +}; +static_assert(sizeof(WaveBuffer) == 0x30); +} // namespace nn::audio \ No newline at end of file From f9e9e345af293ed3cba1ddc57752f96ec49e1e0c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 28 Feb 2026 15:33:06 -0300 Subject: [PATCH 138/785] atk: Define `detail::driver::ChannelManager` --- include/nn/atk/detail/voice/atk_Channel.h | 4 ++ .../nn/atk/detail/voice/atk_ChannelManager.h | 39 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/include/nn/atk/detail/voice/atk_Channel.h b/include/nn/atk/detail/voice/atk_Channel.h index 1b52fdfe..a5b53cd7 100644 --- a/include/nn/atk/detail/voice/atk_Channel.h +++ b/include/nn/atk/detail/voice/atk_Channel.h @@ -8,6 +8,8 @@ #include namespace nn::atk::detail::driver { +class ChannelManager; + class Channel { public: enum ChannelCallbackStatus { @@ -95,6 +97,8 @@ class Channel { void DetachChannel(); private: + friend ChannelManager; + Disposer m_Disposer; CurveAdshr m_CurveAdshr; CurveLfo m_Lfo[4]; diff --git a/include/nn/atk/detail/voice/atk_ChannelManager.h b/include/nn/atk/detail/voice/atk_ChannelManager.h index e69de29b..2a0718af 100644 --- a/include/nn/atk/detail/voice/atk_ChannelManager.h +++ b/include/nn/atk/detail/voice/atk_ChannelManager.h @@ -0,0 +1,39 @@ +#pragma once + +#include +#include + +namespace nn::atk::detail::driver { +class ChannelManager { +public: + using ChannelPool = InstancePool; + using ChannelList = util::IntrusiveList>; + + ChannelManager(); + + size_t GetObjectSize(const SoundInstanceConfig& config); + size_t GetRequiredMemSize(s32 channelCount, const SoundInstanceConfig& config); + + void Initialize(void* mem, size_t memSize, s32 channelCount, const SoundInstanceConfig* config); + void Finalize(); + + void Free(Channel* channel); + + Channel* Alloc(); + + void UpdateAllChannel(); + void UpdateAudioFrameChannel(); + +private: + ChannelPool m_Pool; + ChannelList m_ChannelList; + bool m_IsInitialized; + s32 m_ChannelCount; + InstancePool* m_pAdditionalParamPool; + BufferPool* m_pAdditionalParamBufferPool; + std::size_t m_AdditionalParamBufferSizePerChannel; + SoundInstanceConfig m_SoundInstanceConfig; +}; +static_assert(sizeof(ChannelManager) == 0x50); +} // namespace nn::atk::detail::driver \ No newline at end of file From 9118a45855d0bc49a223bbc6de4353aba054f1ff Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 28 Feb 2026 15:46:47 -0300 Subject: [PATCH 139/785] atk: Define `detail::driver::MultiVoiceManager` --- include/nn/atk/detail/voice/atk_MultiVoice.h | 4 ++ .../atk/detail/voice/atk_MultiVoiceManager.h | 53 +++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/include/nn/atk/detail/voice/atk_MultiVoice.h b/include/nn/atk/detail/voice/atk_MultiVoice.h index d9920f52..c4bb420b 100644 --- a/include/nn/atk/detail/voice/atk_MultiVoice.h +++ b/include/nn/atk/detail/voice/atk_MultiVoice.h @@ -6,6 +6,8 @@ #include namespace nn::atk::detail::driver { +class MultiVoiceManager; + class MultiVoice { public: struct PreMixVolume { @@ -139,6 +141,8 @@ class MultiVoice { position_t offsetSamples, const void* dataAddress); private: + friend MultiVoiceManager; + Voice m_Voice[2]; s32 m_ChannelCount; VoiceCallback m_Callback; diff --git a/include/nn/atk/detail/voice/atk_MultiVoiceManager.h b/include/nn/atk/detail/voice/atk_MultiVoiceManager.h index e69de29b..dedc9004 100644 --- a/include/nn/atk/detail/voice/atk_MultiVoiceManager.h +++ b/include/nn/atk/detail/voice/atk_MultiVoiceManager.h @@ -0,0 +1,53 @@ +#pragma once + +#include + +namespace nn::atk::detail::driver { +class MultiVoiceManager { +public: + using VoiceList = util::IntrusiveList>; + + MultiVoiceManager(); + + size_t GetObjectSize(const SoundInstanceConfig& config); + size_t GetRequiredMemSize(s32 voiceCount, const SoundInstanceConfig& config); + + void Initialize(void* mem, size_t memSize, const SoundInstanceConfig& config); + void Finalize(); + + void StopAllVoices(); + + MultiVoice* AllocVoice(s32 voiceChannelCount, s32 priority, + MultiVoice::VoiceCallback callback, void* callbackData); + + bool DropLowestPriorityVoice(s32); + + void AppendVoiceList(MultiVoice* voice); + + void FreeVoice(MultiVoice* voice); + + void RemoveVoiceList(MultiVoice* voice); + + void UpdateAllVoiceStatus(); + void UpdateAudioFrameVoiceStatus(); + void UpdateAllVoices(); + void UpdateAudioFrameVoices(); + + void ChangeVoicePriority(MultiVoice* voice); + + void UpdateAllVoicesSync(u32 syncFlag); + + s32 GetVoiceCount() const; + s32 GetActiveCount() const; + s32 GetFreeCount() const; + + VoiceList* GetVoiceList() const; + +private: + bool m_Initialized; + VoiceList m_PrioVoiceList; + VoiceList m_FreeVoiceList; +}; +static_assert(sizeof(MultiVoiceManager) == 0x28); +} // namespace nn::atk::detail::driver \ No newline at end of file From 205e9f669f27766fb9dfe09cc84451d4b0008a92 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 28 Feb 2026 16:12:16 -0300 Subject: [PATCH 140/785] atk: Define `detail::CommandManager` --- .../nn/atk/detail/thread/atk_CommandManager.h | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/include/nn/atk/detail/thread/atk_CommandManager.h b/include/nn/atk/detail/thread/atk_CommandManager.h index e69de29b..c2c5a1ba 100644 --- a/include/nn/atk/detail/thread/atk_CommandManager.h +++ b/include/nn/atk/detail/thread/atk_CommandManager.h @@ -0,0 +1,96 @@ +#pragma once + +#include +#include + +#include + +namespace nn::atk::detail { +class CommandBuffer { +public: + CommandBuffer(); + ~CommandBuffer(); + + void Finalize(); + + void Initialize(void* buffer, size_t bufferSize); + + void* AllocMemory(size_t size); + + void FreeMemory(Command* command); + + size_t GetCommandBufferSize() const; + size_t GetAllocatableCommandSize() const; + size_t GetAllocatedCommandBufferSize() const; + +private: + u32* m_CommandMemoryArea; + size_t m_CommandMemoryAreaSize; + std::uintptr_t m_CommandMemoryAreaBegin; + std::uintptr_t m_CommandMemoryAreaEnd; + bool m_CommandMemoryAreaZeroFlag; +}; +static_assert(sizeof(CommandBuffer) == 0x28); + +class CommandManager { +public: + using ProcessCommandListFunc = void(*)(Command*); + using RequestProcessCommandFunc = void(*)(); + + constexpr static s32 SendCommandQueueCount = 32; + constexpr static s32 RecvCommandQueueCount = 33; + constexpr static s32 InvalidCommand = -1; + + CommandManager(); + ~CommandManager(); + + void Finalize(); + void Initialize(void* commandBuffer, size_t commandBufferSize, ProcessCommandListFunc func); + + void* AllocMemory(size_t size, bool forceProcessCommandFlag); + + bool TryAllocMemory(size_t size); + + void RecvCommandReply(); + + u32 FlushCommand(bool forceFlag, bool forceProcessCommandFlag); + + void WaitCommandReply(u32 tag); + + void RecvCommandReplySync(); + + u32 PushCommand(Command* command); + u32 FlushCommand(bool forceFlag); + + void FinalizeCommandList(Command* command); + + bool IsFinishCommand(u32) const; + + size_t GetCommandBufferSize() const; + size_t GetAllocatableCommandSize() const; + size_t GetAllocatedCommandBufferSize() const; + + s32 GetAllocatedCommandCount() const; + + bool ProcessCommand(); + +private: + bool m_Available; + ProcessCommandListFunc m_pProcessCommandListFunc; + RequestProcessCommandFunc m_pRequestProcessCommandFunc; + os::MessageQueueType m_SendCommandQueue; + std::uintptr_t m_SendCommandQueueBuffer[SendCommandQueueCount]; + bool m_IsInitializedSendMessageQueue; + os::MessageQueueType m_RecvCommandQueue; + std::uintptr_t m_RecvCommandQueueBuffer[RecvCommandQueueCount]; + bool m_IsInitializedRecvMessageQueue; + Command* m_CommandListBegin; + Command* m_CommandListEnd; + std::atomic_int m_CommandListCount; + u32 m_CommandTag; + u32 m_FinishCommandTag; + CommandBuffer m_CommandBuffer; + s32 m_AllocatedCommandCount; +}; +static_assert(sizeof(CommandManager) == 0x310); +} // namespace nn::atk::detail \ No newline at end of file From 386aa2ac0c2ec38739bae7e62ffb37a8f17c7cea Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 28 Feb 2026 16:20:53 -0300 Subject: [PATCH 141/785] atk: Define `atk_VoiceCommand.h` header --- .../nn/atk/detail/voice/atk_VoiceCommand.h | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/include/nn/atk/detail/voice/atk_VoiceCommand.h b/include/nn/atk/detail/voice/atk_VoiceCommand.h index e69de29b..ff03e101 100644 --- a/include/nn/atk/detail/voice/atk_VoiceCommand.h +++ b/include/nn/atk/detail/voice/atk_VoiceCommand.h @@ -0,0 +1,88 @@ +#pragma once + +#include +#include + +namespace nn::atk::detail { +struct VoiceCommandPlay : Command { + u32 voiceId; + SampleFormat sampleFormat; + u32 sampleRate; + AdpcmParam adpcmParam; + OutputReceiver* pOutputReceiver; +}; +static_assert(sizeof(VoiceCommandPlay) == 0x50); + +struct VoiceCommandPause : Command { + u32 voiceId; +}; +static_assert(sizeof(VoiceCommandPause) == 0x20); + +struct VoiceCommandFree : Command { + u32 voiceId; +}; +static_assert(sizeof(VoiceCommandFree) == 0x20); + +struct VoiceCommandParam : Command { + u32 voiceId; + VoiceParam voiceParam; +}; +static_assert(sizeof(VoiceCommandParam) == 0x98); + +struct VoiceCommandPriority : Command { + u32 voiceId; + u32 priority; +}; +static_assert(sizeof(VoiceCommandPriority) == 0x20); + +struct VoiceCommandAlloc : Command { + u32 voiceId; + u32 priority; + void* userId; +}; +static_assert(sizeof(VoiceCommandAlloc) == 0x28); + +struct VoiceCommandAppendWaveBuffer : Command { + u32 voiceId; + void* tag; + void* bufferAddress; + size_t bufferSize; + size_t sampleLength; + position_t sampleOffset; + bool adpcmContextEnable; + AdpcmContext adpcmContext; + bool loopFlag; +}; +static_assert(sizeof(VoiceCommandAppendWaveBuffer) == 0x100); + +class VoiceReplyCommand : CommandManager { +public: + static void ProcessCommandList(Command* commandList); + +}; +static_assert(sizeof(VoiceReplyCommand) == 0x310); + +class LowLevelVoiceCommand : CommandManager { +public: + struct WaveBufferPacket { + AdpcmContext adpcmContext; + WaveBuffer waveBuffer; + }; + static_assert(sizeof(WaveBufferPacket) == 0x80); + + void Initialize(void*, size_t, void*, size_t, s32); + + static void ProcessCommandList(Command* commandList); + + static size_t GetRequiredWaveBufferMemSize(s32); + + static void LowLevelVoiceDisposeCallback(LowLevelVoice*, void*); + + void* GetFreeWaveBuffer(); + +private: + WaveBufferPacket* m_pWaveBufferPacket; + s32 m_WaveBufferPacketCount; +}; +static_assert(sizeof(LowLevelVoiceCommand) == 0x320); +} // namespace nn::atk::detail \ No newline at end of file From 3dc80bafb56c41877d3bab5e5f1b08f1da296a4b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 28 Feb 2026 17:19:33 -0300 Subject: [PATCH 142/785] atk: Define `atk_DriverCommand.h` header --- .../nn/atk/detail/thread/atk_DriverCommand.h | 511 ++++++++++++++++++ 1 file changed, 511 insertions(+) diff --git a/include/nn/atk/detail/thread/atk_DriverCommand.h b/include/nn/atk/detail/thread/atk_DriverCommand.h index e69de29b..1ebf1132 100644 --- a/include/nn/atk/detail/thread/atk_DriverCommand.h +++ b/include/nn/atk/detail/thread/atk_DriverCommand.h @@ -0,0 +1,511 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include "nn/atk/atk_Adpcm.h" +#include "nn/atk/atk_Global.h" +#include "nn/atk/detail/seq/atk_SequenceSoundPlayer.h" +#include "nn/atk/detail/strm/atk_StreamSoundLoader.h" +#include "nn/atk/detail/strm/atk_StreamSoundPlayer.h" +#include "nn/atk/detail/thread/atk_CommandManager.h" +#include "nn/atk/detail/voice/atk_MultiVoice.h" +#include "nn/atk/detail/wsd/atk_WaveSoundLoader.h" +#include "nn/atk/detail/wsd/atk_WaveSoundPlayer.h" +#include "nn/atk/submix/atk_OutputReceiver.h" + +namespace nn::atk::detail { +enum DriverCommandId { + DriverCommandId_Dummy, + DriverCommandId_Debug, + DriverCommandId_Reply, + DriverCommandId_PlayerInit, + DriverCommandId_PlayerPanmode, + DriverCommandId_PlayerPancurve, + DriverCommandId_PlayerFinalize, + DriverCommandId_PlayerStart, + DriverCommandId_PlayerStop, + DriverCommandId_PlayerPause, + DriverCommandId_PlayerParam, + DriverCommandId_PlayerAdditionalSend, + DriverCommandId_PlayerBusMixVolumeUsed, + DriverCommandId_PlayerBusMixVolume, + DriverCommandId_PlayerBusMixVolumeEnabled, + DriverCommandId_PlayerBinaryVolume, + DriverCommandId_PlayerVolumeThroughModeUsed, + DriverCommandId_PlayerVolumeThroughMode, + DriverCommandId_PlayerClearResourceFlag, + DriverCommandId_SeqSetup, + DriverCommandId_SeqLoad, + DriverCommandId_SeqPrepare, + DriverCommandId_SeqSkip, + DriverCommandId_SeqTempoRatio, + DriverCommandId_SeqChannelPrio, + DriverCommandId_SeqSetVar, + DriverCommandId_SeqSetGvar, + DriverCommandId_SeqSetTvar, + DriverCommandId_SeqTrackMute, + DriverCommandId_SeqTrackSilence, + DriverCommandId_SeqTrackVolume, + DriverCommandId_SeqTrackPitch, + DriverCommandId_SeqTrackLpf, + DriverCommandId_SeqTrackBiquad, + DriverCommandId_SeqTrackBankIndex, + DriverCommandId_SeqTrackTranspose, + DriverCommandId_SeqTrackVelocityRange, + DriverCommandId_SeqTrackOutputline, + DriverCommandId_SeqTrackOutputlineReset, + DriverCommandId_SeqTrackTvVolume, + DriverCommandId_SeqTrackTvMixParameter, + DriverCommandId_SeqTrackTvPan, + DriverCommandId_SeqTrackTvSpan, + DriverCommandId_SeqTrackTvMainSend, + DriverCommandId_SeqTrackTvFxSend, + DriverCommandId_WsdPrepare, + DriverCommandId_WsdLoad, + DriverCommandId_WsdChannelPrio, + DriverCommandId_WsdChannelParam, + DriverCommandId_AwsdPrepare, + DriverCommandId_StrmSetup, + DriverCommandId_StrmPrepare, + DriverCommandId_StrmPreparePrefetch, + DriverCommandId_StrmLoadHeader, + DriverCommandId_StrmLoadData, + DriverCommandId_StrmForceFinish, + DriverCommandId_StrmTrackVolume, + DriverCommandId_StrmTrackInitialVolume, + DriverCommandId_StrmTrackOutputline, + DriverCommandId_StrmTrackOutputlineReset, + DriverCommandId_StrmTrackTvVolume, + DriverCommandId_StrmTrackTvMixParameter, + DriverCommandId_StrmTrackTvPan, + DriverCommandId_StrmTrackTvSpan, + DriverCommandId_StrmTrackTvMainSend, + DriverCommandId_StrmTrackTvFxSend, + DriverCommandId_InvalidateData, + DriverCommandId_RegistDisposeCallback, + DriverCommandId_UnregistDisposeCallback, + DriverCommandId_AppendEffect, + DriverCommandId_AppendEffectAux, + DriverCommandId_RemoveEffect, + DriverCommandId_RemoveEffectAux, + DriverCommandId_ClearEffect, + DriverCommandId_SubMixApplyDestination, + DriverCommandId_SubMixUpdateMixVolume, + DriverCommandId_AuxBusVolume, + DriverCommandId_AllVoicesSync, + DriverCommandId_VoicePlay, + DriverCommandId_VoiceWaveInfo, + DriverCommandId_VoiceAdpcmParam, + DriverCommandId_VoiceAppendWaveBuffer, + DriverCommandId_VoicePriority, + DriverCommandId_VoiceVolume, + DriverCommandId_VoicePitch, + DriverCommandId_VoicePanMode, + DriverCommandId_VoicePanCurve, + DriverCommandId_VoicePan, + DriverCommandId_VoiceSpan, + DriverCommandId_VoiceLpf, + DriverCommandId_VoiceBiquad, + DriverCommandId_VoiceOutputLine, + DriverCommandId_VoiceMainOutVolume, + DriverCommandId_VoiceMainSend, + DriverCommandId_VoiceFxSend, +}; + +struct DriverCommandReply : Command { + bool* ptr; +}; +static_assert(sizeof(DriverCommandReply) == 0x20); + +struct DriverCommandPlayerInit : Command { + driver::BasicSoundPlayer* player; + OutputReceiver* pOutputReceiver; + bool* availableFlagPtr; +}; +static_assert(sizeof(DriverCommandPlayerInit) == 0x30); + +struct DriverCommandPlayerPanParam : Command { + driver::BasicSoundPlayer* player; + u8 panMode; + u8 panCurve; + u8 padding[2]; +}; +static_assert(sizeof(DriverCommandPlayerPanParam) == 0x28); + +struct DriverCommandPlayer : Command { + driver::BasicSoundPlayer* player; + bool flag; + u8 padding[3]; +}; +static_assert(sizeof(DriverCommandPlayer) == 0x28); + +struct DriverCommandPlayerParam : Command { + driver::BasicSoundPlayer* player; + f32 volume; + f32 pitch; + f32 lpfFreq; + s32 biquadFilterType; + f32 biquadFilterValue; + u32 outputLineFlag; + OutputParam tvParam; +}; +static_assert(sizeof(DriverCommandPlayerParam) == 0x88); + +struct DriverCommandPlayerAdditionalSend : Command { + driver::BasicSoundPlayer* player; + s32 bus; + f32 send; +}; +static_assert(sizeof(DriverCommandPlayerAdditionalSend) == 0x28); + +struct DriverCommandPlayerBusMixVolumeUsed : Command { + driver::BasicSoundPlayer* player; + bool isUsed; +}; +static_assert(sizeof(DriverCommandPlayerBusMixVolumeUsed) == 0x28); + +struct DriverCommandPlayerBusMixVolume : Command { + driver::BasicSoundPlayer* player; + OutputBusMixVolume tvBusMixVolume; +}; +static_assert(sizeof(DriverCommandPlayerBusMixVolume) == 0xe0); + +struct DriverCommandPlayerBusMixVolumeEnabled : Command { + driver::BasicSoundPlayer* player; + s32 bus; + bool isEnabled; +}; +static_assert(sizeof(DriverCommandPlayerBusMixVolumeEnabled) == 0x28); + +struct DriverCommandPlayerBinaryVolume : Command { + driver::BasicSoundPlayer* player; + f32 volume; +}; +static_assert(sizeof(DriverCommandPlayerBinaryVolume) == 0x28); + +struct DriverCommandPlayerVolumeThroughModeUsed : Command { + driver::BasicSoundPlayer* player; + bool isVolumeThroughModeUsed; +}; +static_assert(sizeof(DriverCommandPlayerVolumeThroughModeUsed) == 0x28); + +struct DriverCommandPlayerVolumeThroughMode : Command { + driver::BasicSoundPlayer* player; + s32 bus; + u8 volumeThroughMode; +}; +static_assert(sizeof(DriverCommandPlayerVolumeThroughMode) == 0x28); + +struct DriverCommandPlayerClearResourceFlag : Command { + driver::BasicSoundPlayer* player; +}; +static_assert(sizeof(DriverCommandPlayerClearResourceFlag) == 0x20); + +struct DriverCommandSequenceSoundSetup : Command { + driver::SequenceSoundPlayer* player; + driver::SequenceSoundPlayer::SetupArg arg; + u8 channelPriority; + bool isReleasePriorityFix; + std::uintptr_t userproc; + void* userprocArg; +}; +static_assert(sizeof(DriverCommandSequenceSoundSetup) == 0x50); + +struct DriverCommandSequenceSoundLoad : Command { + driver::SequenceSoundPlayer* player; + driver::SequenceSoundPlayer::StartInfo startInfo; + driver::SequenceSoundLoader::Arg arg; +}; +static_assert(sizeof(DriverCommandSequenceSoundLoad) == 0xa0); + +struct DriverCommandSequenceSoundPrepare : Command { + driver::SequenceSoundPlayer* player; + driver::SequenceSoundPlayer::PrepareArg arg; +}; +static_assert(sizeof(DriverCommandSequenceSoundPrepare) == 0x80); + +struct DriverCommandSequenceSoundSkip : Command { + driver::SequenceSoundPlayer* player; + s32 offsetType; + s32 offset; +}; +static_assert(sizeof(DriverCommandSequenceSoundSkip) == 0x28); + +struct DriverCommandSequenceSoundTempoRatio : Command { + driver::SequenceSoundPlayer* player; + f32 tempoRatio; +}; +static_assert(sizeof(DriverCommandSequenceSoundTempoRatio) == 0x28); + +struct DriverCommandSequenceSoundChannelPrio : Command { + driver::SequenceSoundPlayer* player; + u8 priority; + u8 padding[3]; +}; +static_assert(sizeof(DriverCommandSequenceSoundChannelPrio) == 0x28); + +struct DriverCommandSequenceSoundSetVar : Command { + driver::SequenceSoundPlayer* player; + s32 trackNo; + s32 varNo; + s32 var; +}; +static_assert(sizeof(DriverCommandSequenceSoundSetVar) == 0x30); + +struct DriverCommandSequenceSoundTrack : Command { + driver::SequenceSoundPlayer* player; + u32 trackBitFlag; +}; +static_assert(sizeof(DriverCommandSequenceSoundTrack) == 0x28); + +struct DriverCommandSequenceSoundTrackMute : DriverCommandSequenceSoundTrack { + s32 mute; +}; +static_assert(sizeof(DriverCommandSequenceSoundTrackMute) == 0x28); + +struct DriverCommandSequenceSoundTrackSilence : DriverCommandSequenceSoundTrack { + bool silenceFlag; + s32 fadeFrames; +}; +static_assert(sizeof(DriverCommandSequenceSoundTrackSilence) == 0x30); + +struct DriverCommandSequenceSoundTrackParam : DriverCommandSequenceSoundTrack { + f32 value; + u32 uint32Value; +}; +static_assert(sizeof(DriverCommandSequenceSoundTrackParam) == 0x30); + +struct DriverCommandSequenceSoundTrackBiquad : DriverCommandSequenceSoundTrack { + s32 type; + f32 value; +}; +static_assert(sizeof(DriverCommandSequenceSoundTrackBiquad) == 0x30); + +struct DriverCommandSequenceSoundTrackBankIndex : DriverCommandSequenceSoundTrack { + s32 bankIndex; +}; +static_assert(sizeof(DriverCommandSequenceSoundTrackBankIndex) == 0x28); + +struct DriverCommandSequenceSoundTrackTranspose : DriverCommandSequenceSoundTrack { + s8 transpose; +}; +static_assert(sizeof(DriverCommandSequenceSoundTrackTranspose) == 0x28); + +struct DriverCommandSequenceSoundTrackVelocityRange : DriverCommandSequenceSoundTrack { + u8 range; +}; +static_assert(sizeof(DriverCommandSequenceSoundTrackVelocityRange) == 0x28); + +struct DriverCommandSequenceSoundTrackOutputLine : DriverCommandSequenceSoundTrack { + u32 outputLine; +}; +static_assert(sizeof(DriverCommandSequenceSoundTrackOutputLine) == 0x28); + +struct DriverCommandSequenceSoundTrackMixParameter : DriverCommandSequenceSoundTrack { + u32 trackBitFlag; + u32 srcChNo; + MixParameter param; + u32 drcIndex; +}; +static_assert(sizeof(DriverCommandSequenceSoundTrackMixParameter) == 0x48); + +struct DriverCommandWaveSoundPrepare : Command { + driver::WaveSoundPlayer* player; + driver::WaveSoundPlayer::StartInfo startInfo; + driver::WaveSoundPlayer::PrepareArg arg; +}; +static_assert(sizeof(DriverCommandWaveSoundPrepare) == 0x60); + +struct DriverCommandWaveSoundLoad : Command { + driver::WaveSoundPlayer* player; + driver::WaveSoundPlayer::StartInfo startInfo; + driver::WaveSoundLoader::Arg arg; +}; +static_assert(sizeof(DriverCommandWaveSoundLoad) == 0x78); + +struct DriverCommandWaveSoundChannelPrio : Command { + driver::WaveSoundPlayer* player; + u8 priority; + u8 padding[3]; +}; +static_assert(sizeof(DriverCommandWaveSoundChannelPrio) == 0x28); + +struct DriverCommandWaveSoundChannelParam : Command { + driver::WaveSoundPlayer* player; + u8 priority; + bool isReleasePriorityFix; + u8 padding[2]; +}; +static_assert(sizeof(DriverCommandWaveSoundChannelParam) == 0x28); + +struct DriverCommandAdvancedWaveSoundPrepare : Command { + driver::AdvancedWaveSoundPlayer* player; + driver::AdvancedWaveSoundPlayer::PrepareParameter parameter; +}; +static_assert(sizeof(DriverCommandAdvancedWaveSoundPrepare) == 0x38); + +struct DriverCommandStreamSoundSetup : Command { + driver::StreamSoundPlayer* player; + driver::StreamSoundPlayer::SetupArg arg; +}; +static_assert(sizeof(DriverCommandStreamSoundSetup) == 0xc0); + +struct DriverCommandStreamSoundPrepare : Command { + driver::StreamSoundPlayer* player; + driver::StreamSoundPlayer::PrepareArg arg; +}; +static_assert(sizeof(DriverCommandStreamSoundPrepare) == 0x300); + +struct DriverCommandStreamSoundPreparePrefetch : Command { + driver::StreamSoundPlayer* player; + driver::StreamSoundPlayer::PreparePrefetchArg arg; +}; +static_assert(sizeof(DriverCommandStreamSoundPreparePrefetch) == 0x2f8); + +struct DriverCommandStreamSoundLoadHeader : Command { + driver::StreamSoundPlayer* player; + AdpcmParam* adpcmParam[16]; + bool result; + u16 assignNumber; +}; +static_assert(sizeof(DriverCommandStreamSoundLoadHeader) == 0xa8); + +struct DriverCommandStreamSoundLoadData : Command { + driver::StreamSoundPlayer* player; + LoadDataParam loadDataParam; + bool result; + u16 assignNumber; +}; +static_assert(sizeof(DriverCommandStreamSoundLoadData) == 0xc0); + +struct DriverCommandStreamSoundForceFinish : Command { + driver::StreamSoundPlayer* player; +}; +static_assert(sizeof(DriverCommandStreamSoundForceFinish) == 0x20); + +struct DriverCommandStreamSoundTrackParam : Command { + driver::StreamSoundPlayer* player; + u32 trackBitFlag; + f32 value; + u32 uint32Value; + u32 drcIndex; +}; +static_assert(sizeof(DriverCommandStreamSoundTrackParam) == 0x30); + +struct DriverCommandStreamSoundTrackInitialVolume : Command { + driver::StreamSoundPlayer* player; + u32 trackBitFlag; + u32 value; +}; +static_assert(sizeof(DriverCommandStreamSoundTrackInitialVolume) == 0x28); + +struct DriverCommandStreamSoundTrackMixParameter : Command { + driver::StreamSoundPlayer* player; + u32 trackBitFlag; + u32 srcChNo; + MixParameter param; + u32 drcIndex; +}; +static_assert(sizeof(DriverCommandStreamSoundTrackMixParameter) == 0x48); + +struct DriverCommandInvalidateData : Command { + void* mem; + std::size_t size; +}; +static_assert(sizeof(DriverCommandInvalidateData) == 0x28); + +struct DriverCommandDisposeCallback : Command { + driver::DisposeCallback* callback; +}; +static_assert(sizeof(DriverCommandDisposeCallback) == 0x20); + +struct DriverCommandEffect : Command { + s32 bus; + EffectBase* effect; + void* effectBuffer; + std::size_t effectBufferSize; + OutputMixer* pOutputMixer; +}; +static_assert(sizeof(DriverCommandEffect) == 0x40); + +struct DriverCommandEffectAux : Command { + s32 bus; + EffectAux* effect; + void* effectBuffer; + std::size_t effectBufferSize; + OutputMixer* pOutputMixer; +}; +static_assert(sizeof(DriverCommandEffectAux) == 0x40); + +struct DriverCommandSubMixApplyDestination : Command { + OutputReceiver* pReceiver; +}; +static_assert(sizeof(DriverCommandSubMixApplyDestination) == 0x20); + +struct DriverCommandSubMixUpdateMixVolume : Command { + OutputReceiver* pReceiver; + s32 srcBus; + s32 srcChannel; + s32 dstBus; + s32 dstChannel; +}; +static_assert(sizeof(DriverCommandSubMixUpdateMixVolume) == 0x30); + +struct DriverCommandAuxBusVolume : Command { + AuxBus bus; + s32 subMixIndex; + f32 volume; + s32 fadeFrames; +}; +static_assert(sizeof(DriverCommandAuxBusVolume) == 0x28); + +struct DriverCommandAllVoicesSync : Command { + u32 syncFlag; +}; +static_assert(sizeof(DriverCommandAllVoicesSync) == 0x20); + +struct DriverCommandVoice : Command { + driver::MultiVoice* voice; +}; +static_assert(sizeof(DriverCommandVoice) == 0x20); + +struct DriverCommandVoicePlay : DriverCommandVoice { + enum State { + State_Start, + State_Stop, + State_PauseOn, + State_PauseOff, + }; + + State state; +}; +static_assert(sizeof(DriverCommandVoicePlay) == 0x28); + +struct DriverCommandVoiceWaveInfo : DriverCommandVoice { + SampleFormat format; + s32 sampleRate; + s32 interpolationType; +}; +static_assert(sizeof(DriverCommandVoiceWaveInfo) == 0x30); + +struct DriverCommandVoiceAdpcmParam : DriverCommandVoice { + s32 channel; + s32 voiceOut; + AdpcmParam* param; +}; +static_assert(sizeof(DriverCommandVoiceAdpcmParam) == 0x30); + +class DriverCommand : CommandManager { +public: + static void ProcessCommandList(Command* commandList); + + void Initialize(void* commandBuffer, size_t commandBufferSize); + + void RequestProcessCommand(); +}; +static_assert(sizeof(DriverCommand) == 0x310); +} // namespace nn::atk::detail \ No newline at end of file From acbc1ec84d30a7d3768f8284df8b8565d665c61f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 28 Feb 2026 19:24:21 -0300 Subject: [PATCH 143/785] atk: Define `DeviceOutRecorder` --- .../nn/atk/detail/thread/atk_DriverCommand.h | 17 +- include/nn/atk/util/atk_DeviceOutRecorder.h | 148 ++++++++++++++++++ 2 files changed, 152 insertions(+), 13 deletions(-) diff --git a/include/nn/atk/detail/thread/atk_DriverCommand.h b/include/nn/atk/detail/thread/atk_DriverCommand.h index 1ebf1132..67da6365 100644 --- a/include/nn/atk/detail/thread/atk_DriverCommand.h +++ b/include/nn/atk/detail/thread/atk_DriverCommand.h @@ -1,21 +1,12 @@ #pragma once #include -#include -#include -#include #include #include -#include "nn/atk/atk_Adpcm.h" -#include "nn/atk/atk_Global.h" -#include "nn/atk/detail/seq/atk_SequenceSoundPlayer.h" -#include "nn/atk/detail/strm/atk_StreamSoundLoader.h" -#include "nn/atk/detail/strm/atk_StreamSoundPlayer.h" -#include "nn/atk/detail/thread/atk_CommandManager.h" -#include "nn/atk/detail/voice/atk_MultiVoice.h" -#include "nn/atk/detail/wsd/atk_WaveSoundLoader.h" -#include "nn/atk/detail/wsd/atk_WaveSoundPlayer.h" -#include "nn/atk/submix/atk_OutputReceiver.h" +#include +#include +#include +#include namespace nn::atk::detail { enum DriverCommandId { diff --git a/include/nn/atk/util/atk_DeviceOutRecorder.h b/include/nn/atk/util/atk_DeviceOutRecorder.h index e69de29b..f0695ab7 100644 --- a/include/nn/atk/util/atk_DeviceOutRecorder.h +++ b/include/nn/atk/util/atk_DeviceOutRecorder.h @@ -0,0 +1,148 @@ +#pragma once + +#include +#include +#include +#include + +#include +#include +#include + +namespace nn::atk { +class DeviceOutRecorder : detail::fnd::Thread::Handler { +public: + enum State { + State_NotInitialized, + State_Initialized, + State_Recording, + State_Recorded, + }; + + enum Message { + Message_Prepare, + Message_WriteSamples, + Message_RequestStop, + Message_Exit, + }; + + constexpr static u32 RecordingBufferSize = 0x5a000; + constexpr static u32 DefaultWriteBlockPerSamples = 0x10000; + constexpr static u32 RequiredThreadStackSize = 0x10000; + + struct RecordingOptions { + u32 m_Channels; + bool m_IsLeadSilenceTrimmingEnabled; + u32 m_MaxFrames; + u32 m_WriteBlockPerSamples; + }; + static_assert(sizeof(RecordingOptions) == 0x10); + + struct InitializationOptions { + u32 m_Priority; + s32 m_IdealCoreNumber; + }; + static_assert(sizeof(InitializationOptions) == 0x8); + + struct RecorderBuffer { + struct WriteState { + u32 channelIndex; + u32 writtenSampleCount; + }; + static_assert(sizeof(WriteState) == 0x8); + + explicit RecorderBuffer(const char* deviceName); + + void Initialize(s16* sampleBuffer, u32 maxSamples); + + void UpdateMaxSamples(); + + void Clear(); + + void Finalize(); + + u32 Push(const s16* sampleBuffer, u32 samples); + + u32 Pop(u32); + + s64 Peek(); + + void SetReadBlockSamples(u32 readBlockSamples); + + s16* m_SampleBuffer; + u32 m_MaxBufferSamples; + u32 m_MaxSamples; + std::atomic_uint m_ValidSamples; + u32 m_ReadPosition; + u32 m_WritePosition; + u32 m_ReadBlockSamples; + WriteState m_WriteState; + char* m_DeviceName; + }; + static_assert(sizeof(RecorderBuffer) == 0x30); + + explicit DeviceOutRecorder(const char* deviceName); + ~DeviceOutRecorder() override; + + void Finalize(); + + bool Initialize(void*, size_t, void*, size_t); + bool Initialize(void*, size_t, void*, size_t, const InitializationOptions& options); + + bool StartThread(u32, s32); + + static size_t GetRequiredMemorySizeForRecording(); + + void Stop(bool); + void StopThread(); + + bool Start(detail::fnd::FileStream&, const RecordingOptions& options); + + s32 GetReadBlockSamples(u32) const; + + s32 Prepare(); + + bool SendMessage(Message message); + + void RecordSamples(const s16* sampleBuffer, u32 samples); + + bool PostMessage(Message message); + + u32 Run(void* param) override; + + s32 OnPrepare(); + bool OnWriteSamples(bool); + void OnRequestStop(); + void OnExit(); + + u64 GetLeadSilenceSamples(const s16* sampleBuffer, u32 sampleCount, u32) const; + u32 GetWritableSamples(u32) const; + + bool IsNoMoreSamples() const; + + void OnStart(); + void OnStop(); + + u32 OnProcessSamples(s16* sampleBuffer, u32 samples); + +private: + State m_State; + u32 m_Channels; + OutputMode m_OutputMode; + bool m_IsLeadSilenceTrimming; + u32 m_MaxSamples; + u32 m_WrittenSamples; + detail::fnd::Thread m_Thread; + void* m_ThreadStack; + os::MessageQueue m_MessageQueue; + std::uintptr_t m_Message; + s32 m_MessageResult; + os::Event m_MessageDoneEvent; + detail::fnd::FileStream* m_Stream; + detail::WavOutFileStream m_WavOutStream; + RecorderBuffer m_RecordingBuffer; + util::BytePtr m_WorkBuffer; + u32 m_WriteBlockPerSamples; +}; +static_assert(sizeof(DeviceOutRecorder) == 0x310);; +} // namespace nn::atk \ No newline at end of file From 31f51801fc06e1d3cba5b7c5fe90cb19d9216c8e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 11:28:47 -0300 Subject: [PATCH 144/785] atk: Define `OutputMixer` --- include/nn/atk/effect/atk_EffectAux.h | 2 + include/nn/atk/effect/atk_EffectBase.h | 4 ++ include/nn/atk/submix/atk_OutputMixer.h | 54 +++++++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/include/nn/atk/effect/atk_EffectAux.h b/include/nn/atk/effect/atk_EffectAux.h index e1fc7d25..5c46ca7b 100644 --- a/include/nn/atk/effect/atk_EffectAux.h +++ b/include/nn/atk/effect/atk_EffectAux.h @@ -85,6 +85,8 @@ class EffectAux { void Update(); private: + friend OutputMixer; + util::IntrusiveListNode m_AuxLinkNode; audio::AuxType m_AuxType; std::atomic_uint64_t m_AudioRendererUpdateCountWhenAddedAux; diff --git a/include/nn/atk/effect/atk_EffectBase.h b/include/nn/atk/effect/atk_EffectBase.h index d1b05398..42ae92bc 100644 --- a/include/nn/atk/effect/atk_EffectBase.h +++ b/include/nn/atk/effect/atk_EffectBase.h @@ -8,6 +8,8 @@ #include namespace nn::atk { +class OutputMixer; + class EffectBase { public: enum ChannelMode { @@ -54,6 +56,8 @@ class EffectBase { bool SetSampleRate(SampleRate sampleRate); private: + friend OutputMixer; + util::IntrusiveListNode m_Link; bool m_IsActive; SampleRate m_SampleRate; diff --git a/include/nn/atk/submix/atk_OutputMixer.h b/include/nn/atk/submix/atk_OutputMixer.h index e69de29b..a769aa56 100644 --- a/include/nn/atk/submix/atk_OutputMixer.h +++ b/include/nn/atk/submix/atk_OutputMixer.h @@ -0,0 +1,54 @@ +#pragma once + +#include + +#include +#include +#include +#include + +namespace nn::atk { +class OutputMixer : OutputReceiver { +public: + using EffectList = util::IntrusiveList>; + using EffectAuxList = util::IntrusiveList>; + + OutputMixer(); + + static size_t GetRequiredMemorySize(s32 bus, bool isEffectEnabled); + + void Initialize(s32 bus, bool isEffectEnabled, void* buffer, size_t bufferSize); + void Finalize(); + + bool HasEffect(s32 bus) const; + + bool AppendEffect(EffectBase* pEffect, s32 bus, void* buffer, size_t bufferSize); + bool AppendEffect(EffectAux* pEffect, s32 bus, void* buffer, size_t bufferSize); + + bool RemoveEffect(EffectBase* pEffect, s32 bus); + bool RemoveEffect(EffectAux* pEffect, s32 bus); + + void ClearEffect(s32 bus); + + void UpdateEffectAux(); + + void OnChangeOutputMode(); + + void AppendEffectImpl(EffectBase* pEffect, s32 bus, void* buffer, size_t bufferSize); + void AppendEffectImpl(EffectAux* pEffect, s32 bus, void* buffer, size_t bufferSize); + + void RemoveEffectImpl(EffectBase* pEffect, s32 bus); + void RemoveEffectImpl(EffectAux* pEffect, s32 bus); + + void ClearEffectImpl(s32 bus); + +private: + detail::fnd::CriticalSection m_EffectListLock; + EffectList* m_pEffectList; + EffectAuxList* m_pEffectAuxList; + bool m_IsEffectEnabled; +}; +static_assert(sizeof(OutputMixer) == 0x40); +} // namespace nn::atk \ No newline at end of file From 8d7b53c365d3ecd723fc7ead88042af0f741b008 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 11:41:26 -0300 Subject: [PATCH 145/785] atk: Define `FinalMix` --- include/nn/atk/submix/atk_FinalMix.h | 43 ++++++++++++++++++++++ include/nn/atk/submix/atk_OutputMixer.h | 6 +-- include/nn/atk/submix/atk_OutputReceiver.h | 8 +++- 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/include/nn/atk/submix/atk_FinalMix.h b/include/nn/atk/submix/atk_FinalMix.h index e69de29b..4de88fc1 100644 --- a/include/nn/atk/submix/atk_FinalMix.h +++ b/include/nn/atk/submix/atk_FinalMix.h @@ -0,0 +1,43 @@ +#pragma once + +#include +#include +#include + +#include + +namespace nn::atk { +class FinalMix : OutputMixer { +public: + static size_t GetRequiredMemorySize(bool isEffectEnabled); + + bool Initialize(audio::AudioRendererConfig* pConfig, s32 channelCount, + bool isEffectEnabled, void* buffer, size_t bufferSize); + + void Finalize(audio::AudioRendererConfig* pConfig); + + bool AppendEffect(EffectBase* pEffect, void* buffer, size_t bufferSize); + bool AppendEffect(EffectAux* pEffect, void* buffer, size_t bufferSize); + + bool RemoveEffect(EffectBase* pEffect); + bool RemoveEffect(EffectAux* pEffect); + + void ClearEffect(); + + bool IsEffectEnabled() const; + + ReceiverType GetReceiverType() const override; + s32 GetChannelCount() const override; + s32 GetBusCount() const override; + + void AddReferenceCount(s32 value) override; + + bool IsSoundSendClampEnabled(s32 bus) const override; + +private: + audio::FinalMixType m_FinalMix; + std::atomic_uint m_ReferenceCount; + s32 m_ChannelCount; +}; +static_assert(sizeof(FinalMix) == 0x50); +} // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/submix/atk_OutputMixer.h b/include/nn/atk/submix/atk_OutputMixer.h index a769aa56..c2128563 100644 --- a/include/nn/atk/submix/atk_OutputMixer.h +++ b/include/nn/atk/submix/atk_OutputMixer.h @@ -8,7 +8,7 @@ #include namespace nn::atk { -class OutputMixer : OutputReceiver { +class OutputMixer : protected OutputReceiver { public: using EffectList = util::IntrusiveList>; @@ -36,8 +36,8 @@ class OutputMixer : OutputReceiver { void OnChangeOutputMode(); - void AppendEffectImpl(EffectBase* pEffect, s32 bus, void* buffer, size_t bufferSize); - void AppendEffectImpl(EffectAux* pEffect, s32 bus, void* buffer, size_t bufferSize); + virtual void AppendEffectImpl(EffectBase* pEffect, s32 bus, void* buffer, size_t bufferSize); + virtual void AppendEffectImpl(EffectAux* pEffect, s32 bus, void* buffer, size_t bufferSize); void RemoveEffectImpl(EffectBase* pEffect, s32 bus); void RemoveEffectImpl(EffectAux* pEffect, s32 bus); diff --git a/include/nn/atk/submix/atk_OutputReceiver.h b/include/nn/atk/submix/atk_OutputReceiver.h index cb9d1cd1..1630a728 100644 --- a/include/nn/atk/submix/atk_OutputReceiver.h +++ b/include/nn/atk/submix/atk_OutputReceiver.h @@ -1,5 +1,7 @@ #pragma once +#include + namespace nn::atk { class OutputReceiver { public: @@ -8,7 +10,11 @@ class OutputReceiver { ReceiverType_FinalMix, }; - virtual ~OutputReceiver() = 0; + virtual ReceiverType GetReceiverType() const = 0; + virtual s32 GetChannelCount() const = 0; + virtual s32 GetBusCount() const = 0; + virtual void AddReferenceCount(s32 value) = 0; + virtual bool IsSoundSendClampEnabled(s32 bus) const = 0; }; static_assert(sizeof(OutputReceiver) == 0x8); } // namespace nn::atk \ No newline at end of file From 26583dbb91e7ee86ea9e71ad4bfa9faec210f4b8 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 12:22:02 -0300 Subject: [PATCH 146/785] atk: Define `SubMix` --- include/nn/atk/submix/atk_SubMix.h | 181 +++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) diff --git a/include/nn/atk/submix/atk_SubMix.h b/include/nn/atk/submix/atk_SubMix.h index e69de29b..245fb537 100644 --- a/include/nn/atk/submix/atk_SubMix.h +++ b/include/nn/atk/submix/atk_SubMix.h @@ -0,0 +1,181 @@ +#pragma once + +#include +#include + +#include +#include + +namespace nn::atk { +class SubMix : OutputMixer { +public: + class VolumeData { + public: + VolumeData(); + + bool Update(); + + private: + detail::MoveValue m_Volume; + bool m_IsMute; + bool m_IsPrevMute; + bool m_IsDirtyFlag; + }; + static_assert(sizeof(VolumeData) == 0x14); + + class SubMixParam { + public: + SubMixParam(); + + void SetSrcBusCount(s32 srcBusCount); + s32 GetSrcBusCount() const; + + void SetSrcChannelCount(s32 srcChannelCount); + s32 GetSrcChannelCount() const; + + void SetDstBusCount(s32 dstBusCount); + s32 GetDstBusCount() const; + + void SetDstChannelCount(s32 dstChannelCount); + s32 GetDstChannelCount() const; + + void SetOutputReceiver(const OutputReceiver* pOutputReceiver); + OutputReceiver* GetOutputReceiver() const; + + void SetEffectEnabled(bool isEffectEnabled); + bool IsEffectEnabled() const; + + void SetSoundSendClampEnabled(s32 index, bool IsSoundSendClampEnabled); + bool GetSoundSendClampEnabled(s32 index) const; + + private: + s32 m_SrcBusCount; + s32 m_SrcChannelCount; + s32 m_DstBusCount; + s32 m_DstChannelCount; + OutputReceiver* m_pOutputReceiver; + bool m_IsEffectEnabled; + bool m_IsSoundSendClampEnabledArray[24]; + }; + static_assert(sizeof(SubMixParam) == 0x38); + + SubMix(); + static size_t GetRequiredMemorySize(s32 srcBusCount, s32 srcChannelCount, + s32 dstBusCount, s32 dstChannelCount); + static size_t GetRequiredMemorySize(s32 srcBusCount, s32 srcChannelCount, + s32 dstBusCount, s32 dstChannelCount, + bool isEffectEnabled); + static size_t GetRequiredMemorySize(s32 srcBusCount, s32 srcChannelCount, + s32 dstBusCount, s32 dstChannelCount, + bool isEffectEnabled, bool isInternalCall); + + static size_t GetRequiredMemorySizeImpl(const SubMixParam& param); + + static size_t GetRequiredMemorySize(s32 srcBusCount, s32 dstBusCount, + const OutputReceiver* pReceiver, + bool isEffectEnabled); + + static size_t GetRequiredMemorySize(const SubMixParam& param); + + bool Initialize(s32 srcBusCount, s32 srcChannelCount, s32 dstBusCount, + s32 dstChannelCount, void* buffer, size_t bufferSize); + bool Initialize(s32 srcBusCount, s32 srcChannelCount, s32 dstBusCount, + s32 dstChannelCount, bool isEffectEnabled, void* buffer, + size_t bufferSize); + bool Initialize(s32 srcBusCount, s32 srcChannelCount, s32 dstBusCount, + s32 dstChannelCount, bool isEffectEnabled, bool isInternalCall, + void* buffer, size_t bufferSize); + + bool InitializeImpl(const SubMixParam& param, void* buffer, size_t bufferSize); + bool InitializeImpl(const SubMixParam& param, void* buffer, size_t bufferSize, bool isInternalCall); + + bool Initialize(s32 srcBusCount, s32 dstBusCount, const OutputReceiver* pReceiver, + void* buffer, size_t bufferSize); + bool Initialize(s32 srcBusCount, s32 dstBusCount, const OutputReceiver* pReceiver, + bool isEffectEnabled, void* buffer, size_t bufferSize); + bool Initialize(const SubMixParam& param, void* buffer, size_t bufferSize); + + void Finalize(); + + bool IsRemovable() const; + + void Update(); + + void UpdateBusMixVolume(s32 bus); + void UpdateChannelMixVolume(s32 bus); + void UpdateMixVolume(s32 srcBus, s32 srcChannel,s32 dstBus,s32 dstChannel); + + void SetDestination(OutputReceiver* pReceiver); + void ApplyDestination(); + + f32 GetSend(s32 srcBus, s32 dstBus) const; + f32 GetSendImpl(s32 srcBus, s32 srcChannel,s32 dstBus,s32 dstChannel) const; + + void SetSend(s32 srcBus, s32 dstBus, f32 send); + void SetSendImpl(s32 srcBus, s32 srcChannel,s32 dstBus,s32 dstChannel, f32 send); + + void SetBusVolume(s32 bus, f32 volume, s32 fadeFrame); + f32 GetBusVolume(s32 bus) const; + + void SetBusMute(s32 bus, bool isMute); + bool IsBusMuted(s32 bus) const; + + bool IsSoundSendClampEnabled(s32 bus) const override; + + void SetChannelVolume(s32 channel, f32 volume, s32 fadeFrame); + f32 GetChannelVolume(s32 channel) const; + + void SetChannelMute(s32 channel, bool isMute); + bool IsChannelMuted(s32 channel) const; + + void SetSubMixVolume(f32 volume, s32 fadeFrame); + f32 GetSubMixVolume() const; + + void SetSubMixMute(bool isMute); + bool IsSubMixMuted() const; + + void SetMuteUnusedEffectChannel(bool isUnusedEffectChannelMuted); + void IsUnusedEffectChannelMuted() const; + + void MuteUnusedEffectChannel(ChannelIndex* effectChannelIndex, s32 effectChannelCount, s32 bus); + + bool AppendEffect(EffectBase* pEffect, s32 bus, void* buffer, size_t bufferSize); + bool AppendEffect(EffectAux* pEffect, s32 bus, void* buffer, size_t bufferSize); + + bool RemoveEffect(EffectBase* pEffect, s32 bus); + bool RemoveEffect(EffectAux* pEffect, s32 bus); + + bool ClearEffect(s32 bus); + + bool IsEffectEnabled() const; + + void AppendEffectImpl(EffectBase* pEffect, s32 bus, void* buffer, size_t bufferSize) override; + void AppendEffectImpl(EffectAux* pEffect, s32 bus, void* buffer, size_t bufferSize) override; + + ReceiverType GetReceiverType() const override; + s32 GetChannelCount() const override; + s32 GetBusCount() const override; + + void AddReferenceCount(s32 value) override; + +private: + util::IntrusiveListNode m_Link; + audio::SubMixType m_SubMix; + std::atomic_uint m_ReferenceCount; + OutputReceiver* m_pReceiver; + VolumeData* m_pBusVolume; + VolumeData* m_pChannelVolume; + VolumeData m_SubMixVolume; + bool* m_pIsSoundSendClampEnabledArray; + f32** m_ppSendVolume; + s32 m_ChannelCount; + s32 m_BusCount; + s32 m_ReceiverChannelCountMax; + detail::fnd::CriticalSection m_VolumeLock; + detail::fnd::CriticalSection m_DestinationLock; + bool m_IsInitialized; + bool m_IsUnusedEffectChannelMuted; + bool m_IsAppliedOutputReceiver; +}; +static_assert(sizeof(SubMix) == 0xf8); +} // namespace nn::atk \ No newline at end of file From 659cbf0a68152851e154811fce877afdd78a0168 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 12:34:52 -0300 Subject: [PATCH 147/785] atk: Better define `ChannelMixVolume` --- include/nn/atk/submix/atk_ChannelMixVolume.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/submix/atk_ChannelMixVolume.h b/include/nn/atk/submix/atk_ChannelMixVolume.h index 941d5a2e..49fdbe21 100644 --- a/include/nn/atk/submix/atk_ChannelMixVolume.h +++ b/include/nn/atk/submix/atk_ChannelMixVolume.h @@ -1,12 +1,26 @@ #pragma once -#include +#include namespace nn::atk { class ChannelMixVolume { public: + ChannelMixVolume(); + void InitializeChannelVolume(); + + explicit ChannelMixVolume(const MixVolume& mixVolume); + ChannelMixVolume(const f32* channelVolumes, s32 channelCount); + + bool SetChannelCount(s32 channelCount); + + bool SetChannelVolume(s32 channel, f32 volume); + f32 GetChannelVolume(s32 channel) const; + + bool SetChannelVolume(s32 channel, const f32*, s32); + private: s32 m_ChannelCount; f32 m_ChannelVolume[24]; }; +static_assert(sizeof(ChannelMixVolume) == 0x64); } // namespace nn::atk \ No newline at end of file From cfede4c5ba4afd8753c2c4f49583efa4d4c3de4b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 13:49:28 -0300 Subject: [PATCH 148/785] atk: Define Biquad Filter presets --- include/nn/atk/atk_BiquadFilterCallback.h | 4 +- .../atk/detail/dsp/atk_BiquadFilterPresets.h | 105 ++++++++++++++++++ 2 files changed, 108 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_BiquadFilterCallback.h b/include/nn/atk/atk_BiquadFilterCallback.h index 76f30e8a..c97efed5 100644 --- a/include/nn/atk/atk_BiquadFilterCallback.h +++ b/include/nn/atk/atk_BiquadFilterCallback.h @@ -10,6 +10,8 @@ class BiquadFilterCallback { using Coefficients = BiquadFilterCoefficients; virtual ~BiquadFilterCallback(); -}; + virtual void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) = 0; +}; +static_assert(sizeof(BiquadFilterCallback) == 0x8); } \ No newline at end of file diff --git a/include/nn/atk/detail/dsp/atk_BiquadFilterPresets.h b/include/nn/atk/detail/dsp/atk_BiquadFilterPresets.h index e69de29b..2fda28b2 100644 --- a/include/nn/atk/detail/dsp/atk_BiquadFilterPresets.h +++ b/include/nn/atk/detail/dsp/atk_BiquadFilterPresets.h @@ -0,0 +1,105 @@ +#pragma once + +#include + +namespace nn::atk::detail { +class BiquadFilterLpf : BiquadFilterCallback { +public: + static Coefficients CoefficientsTable32000[112]; + + ~BiquadFilterLpf() override; + + void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) override; +}; +static_assert(sizeof(BiquadFilterLpf) == 0x8); + +class BiquadFilterHpf : BiquadFilterCallback { +public: + static Coefficients CoefficientsTable32000[97]; + + ~BiquadFilterHpf() override; + + void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) override; +}; +static_assert(sizeof(BiquadFilterHpf) == 0x8); + +class BiquadFilterBpf512 : BiquadFilterCallback { +public: + static Coefficients CoefficientsTable32000[122]; + + ~BiquadFilterBpf512() override; + + void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) override; +}; +static_assert(sizeof(BiquadFilterBpf512) == 0x8); + +class BiquadFilterBpf1024 : BiquadFilterCallback { +public: + static Coefficients CoefficientsTable32000[93]; + + ~BiquadFilterBpf1024() override; + + void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) override; +}; +static_assert(sizeof(BiquadFilterBpf1024) == 0x8); + +class BiquadFilterBpf2048 : BiquadFilterCallback { +public: + static Coefficients CoefficientsTable32000[93]; + + ~BiquadFilterBpf2048() override; + + void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) override; +}; +static_assert(sizeof(BiquadFilterBpf2048) == 0x8); + +class BiquadFilterLpfNw4fCompatible48k : BiquadFilterCallback { +public: + static Coefficients CoefficientsTable48000[112]; + + ~BiquadFilterLpfNw4fCompatible48k() override; + + void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) override; +}; +static_assert(sizeof(BiquadFilterLpfNw4fCompatible48k) == 0x8); + +class BiquadFilterHpfNw4fCompatible48k : BiquadFilterCallback { +public: + static Coefficients CoefficientsTable48000[97]; + + ~BiquadFilterHpfNw4fCompatible48k() override; + + void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) override; +}; +static_assert(sizeof(BiquadFilterHpfNw4fCompatible48k) == 0x8); + +class BiquadFilterBpf512Nw4fCompatible48k : BiquadFilterCallback { +public: + static Coefficients CoefficientsTable48000[122]; + + ~BiquadFilterBpf512Nw4fCompatible48k() override; + + void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) override; +}; +static_assert(sizeof(BiquadFilterBpf512Nw4fCompatible48k) == 0x8); + +class BiquadFilterBpf1024Nw4fCompatible48k : BiquadFilterCallback { +public: + static Coefficients CoefficientsTable48000[93]; + + ~BiquadFilterBpf1024Nw4fCompatible48k() override; + + void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) override; +}; +static_assert(sizeof(BiquadFilterBpf1024Nw4fCompatible48k) == 0x8); + +class BiquadFilterBpf2048Nw4fCompatible48k : BiquadFilterCallback { +public: + static Coefficients CoefficientsTable48000[93]; + + ~BiquadFilterBpf2048Nw4fCompatible48k() override; + + void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) override; +}; +static_assert(sizeof(BiquadFilterBpf2048Nw4fCompatible48k) == 0x8); +} // namespace nn::atk::detail \ No newline at end of file From f68806c254a5606378d2bac7b946dc287dfb8c83 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 14:19:56 -0300 Subject: [PATCH 149/785] atk: Define `detail::fnd::HeapBase` --- include/nn/atk/fnd/basis/atkfnd_HeapBase.h | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/include/nn/atk/fnd/basis/atkfnd_HeapBase.h b/include/nn/atk/fnd/basis/atkfnd_HeapBase.h index e69de29b..c7cde758 100644 --- a/include/nn/atk/fnd/basis/atkfnd_HeapBase.h +++ b/include/nn/atk/fnd/basis/atkfnd_HeapBase.h @@ -0,0 +1,74 @@ +#pragma once + +#include +#include + +namespace nn::atk::detail::fnd { +class HeapBase : util::IntrusiveListBaseNode { +public: + using HeapList = util::IntrusiveList>; + + enum HeapType { + HeapType_Exp, + HeapType_Frame, + HeapType_Unit, + HeapTyep_Unknown, + }; + + enum FillType { + FillType_NoUse, + FillType_Alloc, + FillType_Free, + FillType_Max, + }; + + constexpr static u32 DefaultAlignment = 4; + + constexpr static s32 ExpHeapSignature = 0x45585048; // HPXE + constexpr static s32 FrameHeapSignature = 0x46524D48; // HMRF + constexpr static s32 UnitHeapSignature = 0x554E5448; // HTNU + + constexpr static u32 OptionZeroClear = 1; + constexpr static u32 OptionDebugFill = 1 << 1; + constexpr static u32 OptionThreadSafe = 1 << 2; + + constexpr static u32 ErrorPrint = 1; + + constexpr static u8 MIN_ALIGNMENT = 4; + + HeapList* FindListContainHeap(); + static HeapBase* FindContainHeap(HeapList* pList, const void* memBlock); + static HeapBase* FindContainHeap(const void* memBlock); + static HeapBase* FindParentHeap(HeapBase* pChild); + + u32 SetFillValue(FillType type, u32 value); + u32 GetFillValue(FillType type); + + HeapType GetHeapType(); + + void Initialize(u32 signature, void* heapStart, void* heapEnd, u16 optFlag); + + void SetOptionFlag(u16 optFlag); + + void FillNoUseMemory(void* address, size_t size); + + void Finalize(); + + void LockHeap(); + void UnlockHeap(); + + void FillFreeMemory(void* address, size_t size); + + u16 GetOptionFlag(); + + void FillAllocMemory(void* address, size_t size); + +private: + void* mHeapStart; + void* mHeapEnd; + u32 m_Signature; + HeapList m_ChildList; + u32 m_Attribute; +}; +static_assert(sizeof(HeapBase) == 0x40); +} // namespace nn::atk::detail::fnd \ No newline at end of file From c5f0e2ba013d67b2b06c8b7b788f9797b34cd115 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 14:30:22 -0300 Subject: [PATCH 150/785] atk: Define `detail::fnd::FrameHeapImpl` --- .../nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/include/nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h b/include/nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h index e69de29b..a884dd4d 100644 --- a/include/nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h +++ b/include/nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h @@ -0,0 +1,48 @@ +#pragma once + +#include + +namespace nn::atk::detail::fnd { +class FrameHeapImpl : HeapBase { +public: + constexpr static s32 FreeHeadMode = 1; + constexpr static s32 FreeTailMode = 2; + constexpr static s32 FreeAllMode = 3; + + struct HeapState { + u32 tagName; + void* headAllocator; + void* tailAllocator; + HeapState* pPrevState; + }; + static_assert(sizeof(HeapState) == 0x20); + + static FrameHeapImpl* Create(void* startAddress, size_t size, u16 optFlag); + + void* Destroy(); + + void* Alloc(size_t size, s32 alignment); + void* AllocFromHead(size_t size, s32 alignment); + void* AllocFromTail(size_t size, s32 alignment); + + u64 ResizeForMBlock(void* memBlock, size_t size); + + size_t GetAllocatableSize(s32); + + void Free(s32 mode); + void FreeHead(); + void FreeTail(); + + bool RecordState(u32); + + bool FreeByState(u32); + + s32 Adjust(); + +private: + void* m_pHeadAllocator; + void* m_pTailAllocator; + HeapState* m_pState; +}; +static_assert(sizeof(FrameHeapImpl) == 0x58); +} // namespace nn::atk::detail::fnd \ No newline at end of file From c53b9442085d3309596cd538ab87b69f9c2c373b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 14:34:29 -0300 Subject: [PATCH 151/785] atk: Define `detail::fnd::ScopedLock` --- include/nn/atk/fnd/basis/atkfnd_ScopedLock.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/nn/atk/fnd/basis/atkfnd_ScopedLock.h b/include/nn/atk/fnd/basis/atkfnd_ScopedLock.h index e69de29b..2f972fd2 100644 --- a/include/nn/atk/fnd/basis/atkfnd_ScopedLock.h +++ b/include/nn/atk/fnd/basis/atkfnd_ScopedLock.h @@ -0,0 +1,9 @@ +#pragma once + +namespace nn::atk::detail::fnd { +template +class ScopedLock { +public: + LockObj* m_LockObj; +}; +} // namespace nn::atk::detail::fnd \ No newline at end of file From 21ed45f11b1dbee85924f4bd9105d28ad9bc92a1 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 14:45:07 -0300 Subject: [PATCH 152/785] atk: Define `detail::fnd::TimeSpan` and `detail::fnd::Time` --- include/nn/atk/fnd/basis/atkfnd_Time.h | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/nn/atk/fnd/basis/atkfnd_Time.h b/include/nn/atk/fnd/basis/atkfnd_Time.h index e69de29b..a291f48f 100644 --- a/include/nn/atk/fnd/basis/atkfnd_Time.h +++ b/include/nn/atk/fnd/basis/atkfnd_Time.h @@ -0,0 +1,27 @@ +#pragma once + +#include + +namespace nn::atk::detail::fnd { +class TimeSpan { +public: + using TickType = s64; + + os::Tick FromNanoSeconds(TickType); + os::Tick FromMicroSeconds(TickType); + os::Tick FromMilliSeconds(TickType); + + TickType ToNanoSeconds() const; + TickType ToMicroSeconds() const; + TickType ToMilliSeconds() const; + +private: + TickType m_TickSpan; +}; +static_assert(sizeof(TimeSpan) == 0x8); + +class Time { +public: + s64 Current(); +}; +} // namespace nn::atk::detail::fnd \ No newline at end of file From ed7452a99891fba47e4497c90a2b5ff87537f9e4 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 14:48:31 -0300 Subject: [PATCH 153/785] atk: Define `detail::fnd::WorkBufferAllocator` --- include/nn/atk/fnd/basis/atkfnd_Time.h | 6 +++--- .../fnd/basis/atkfnd_WorkBufferAllocator.h | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/include/nn/atk/fnd/basis/atkfnd_Time.h b/include/nn/atk/fnd/basis/atkfnd_Time.h index a291f48f..2710b3fb 100644 --- a/include/nn/atk/fnd/basis/atkfnd_Time.h +++ b/include/nn/atk/fnd/basis/atkfnd_Time.h @@ -7,9 +7,9 @@ class TimeSpan { public: using TickType = s64; - os::Tick FromNanoSeconds(TickType); - os::Tick FromMicroSeconds(TickType); - os::Tick FromMilliSeconds(TickType); + static TimeSpan FromNanoSeconds(TickType); + static TimeSpan FromMicroSeconds(TickType); + static TimeSpan FromMilliSeconds(TickType); TickType ToNanoSeconds() const; TickType ToMicroSeconds() const; diff --git a/include/nn/atk/fnd/basis/atkfnd_WorkBufferAllocator.h b/include/nn/atk/fnd/basis/atkfnd_WorkBufferAllocator.h index e69de29b..49239c6a 100644 --- a/include/nn/atk/fnd/basis/atkfnd_WorkBufferAllocator.h +++ b/include/nn/atk/fnd/basis/atkfnd_WorkBufferAllocator.h @@ -0,0 +1,19 @@ +#pragma once + +#include + +namespace nn::atk::detail::fnd { +class WorkBufferAllocator { +public: + WorkBufferAllocator(void* buffer, size_t size); + + void* Allocate(size_t size, size_t alignment); + void* Allocate(size_t size, size_t alignment, s32 count); + +private: + std::uintptr_t m_Buffer; + size_t m_Offset; + size_t m_Size; +}; +static_assert(sizeof(WorkBufferAllocator) == 0x18); +} // namespace nn::atk::detail::fnd \ No newline at end of file From 28022169314d3e46defeb4616b4bf2f49485e8cc Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 14:54:09 -0300 Subject: [PATCH 154/785] atk: Define `detail::fnd::RuntimeTypeInfo` --- include/nn/atk/fnd/basis/atkfnd_RuntimeTypeInfo.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/nn/atk/fnd/basis/atkfnd_RuntimeTypeInfo.h b/include/nn/atk/fnd/basis/atkfnd_RuntimeTypeInfo.h index e69de29b..5e5c2061 100644 --- a/include/nn/atk/fnd/basis/atkfnd_RuntimeTypeInfo.h +++ b/include/nn/atk/fnd/basis/atkfnd_RuntimeTypeInfo.h @@ -0,0 +1,10 @@ +#pragma once + +namespace nn::atk::detail::fnd { +class RuntimeTypeInfo { +public: +private: + RuntimeTypeInfo* m_ParentTypeInfo; +}; +static_assert(sizeof(RuntimeTypeInfo) == 0x8); +} // namespace nn::atk::detail::fnd \ No newline at end of file From 36c846c340334a6736dbe195799145392cfb8f32 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 14:58:16 -0300 Subject: [PATCH 155/785] atk: Define `atk_Debug.h` header --- include/nn/atk/detail/debug/atk_Debug.h | 22 +++++++++++++++++++ .../atk/detail/dsp/atk_BiquadFilterPresets.h | 13 +++++++++++ 2 files changed, 35 insertions(+) diff --git a/include/nn/atk/detail/debug/atk_Debug.h b/include/nn/atk/detail/debug/atk_Debug.h index e69de29b..cdfb98cf 100644 --- a/include/nn/atk/detail/debug/atk_Debug.h +++ b/include/nn/atk/detail/debug/atk_Debug.h @@ -0,0 +1,22 @@ +#pragma once + +namespace nn::atk { +enum DebugWarningFlag { + DebugWarningFlag_NotEnoughInstance, + DebugWarningFlag_NotEnoughSeqsound, + DebugWarningFlag_NotEnoughStrmsound, + DebugWarningFlag_NotEnoughWavesound, + DebugWarningFlag_NotEnoughSeqtrack, + DebugWarningFlag_NotEnoughStrmchannel, +}; + +namespace detail { +enum DebugSoundType { + DebugSoundType_Seqsound, + DebugSoundType_Strmsound, + DebugSoundType_Wavesound, +}; + +using DebugLogFunc = void(*)(char*); +} // namespace nn::atk::detail +} // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/detail/dsp/atk_BiquadFilterPresets.h b/include/nn/atk/detail/dsp/atk_BiquadFilterPresets.h index 2fda28b2..d452cfbb 100644 --- a/include/nn/atk/detail/dsp/atk_BiquadFilterPresets.h +++ b/include/nn/atk/detail/dsp/atk_BiquadFilterPresets.h @@ -102,4 +102,17 @@ class BiquadFilterBpf2048Nw4fCompatible48k : BiquadFilterCallback { void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) override; }; static_assert(sizeof(BiquadFilterBpf2048Nw4fCompatible48k) == 0x8); + +namespace driver { +static BiquadFilterLpf BiquadFilterInstanceLpf {}; +static BiquadFilterHpf BiquadFilterInstanceHpf {}; +static BiquadFilterBpf512 BiquadFilterInstanceBpf512 {}; +static BiquadFilterBpf1024 BiquadFilterInstanceBpf1024 {}; +static BiquadFilterBpf2048 BiquadFilterInstanceBpf2048 {}; +static BiquadFilterLpfNw4fCompatible48k BiquadFilterInstanceLpfNw4fCompatible48k {}; +static BiquadFilterHpfNw4fCompatible48k BiquadFilterInstanceHpfNw4fCompatible48k {}; +static BiquadFilterBpf512Nw4fCompatible48k BiquadFilterInstanceBpf512Nw4fCompatible48k {}; +static BiquadFilterBpf1024Nw4fCompatible48k BiquadFilterInstanceBpf1024Nw4fCompatible48k {}; +static BiquadFilterBpf2048Nw4fCompatible48k BiquadFilterInstanceBpf2048Nw4fCompatible48k {}; +}; } // namespace nn::atk::detail \ No newline at end of file From f24fd29cf9abbb8eb31724972568a7cbb817b9a6 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 15:18:01 -0300 Subject: [PATCH 156/785] atk: Define `detail::FrameHeap` --- include/nn/atk/detail/util/atk_FrameHeap.h | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/include/nn/atk/detail/util/atk_FrameHeap.h b/include/nn/atk/detail/util/atk_FrameHeap.h index e69de29b..a2862b69 100644 --- a/include/nn/atk/detail/util/atk_FrameHeap.h +++ b/include/nn/atk/detail/util/atk_FrameHeap.h @@ -0,0 +1,85 @@ +#pragma once + +#include + +#include +#include + +namespace nn::atk::detail { +class FrameHeap { +public: + using DisposeCallback = void(*)(void*, size_t, void*); + using HeapCallback = void(*)(void*); + + class Block { + public: + Block(); + + private: + friend FrameHeap; + + util::IntrusiveListNode m_Link; + void* m_pBuffer; + size_t m_Size; + DisposeCallback m_Callback; + void* m_pCallbackArg; + HeapCallback m_HeapCallback; + void* m_pHeapCallbackArg; + }; + + using BlockList = util::IntrusiveList>; + + class Section { + public: + Section(); + ~Section(); + + void* AppendBlock(Block* block); + + void Dump(const SoundDataManager&, const SoundArchive&) const; + + private: + friend FrameHeap; + + util::IntrusiveListNode m_Link; + BlockList m_BlockList; + bool m_UseCallback; + }; + + using SectionList = util::IntrusiveList>; + + FrameHeap(); + ~FrameHeap(); + + void Destroy(); + + bool Create(void* startAddress, size_t size); + + bool NewSection(); + void ClearSection(); + + void Clear(); + + void* Alloc(size_t size, DisposeCallback callback, void* callbackArg, + HeapCallback heapCallback, void* heapCallbackArg); + + s32 SaveState(); + + bool ProcessCallback(s32 level); + + void LoadState(s32 state); + + s32 GetCurrentLevel() const; + size_t GetSize() const; + size_t GetFreeSize() const; + + void Dump(const SoundDataManager&, const SoundArchive&) const; + +private: + fnd::FrameHeapImpl* m_pHeap; + SectionList m_SectionList; +}; +static_assert(sizeof(FrameHeap) == 0x18); +} // namespace nn::atk::detail \ No newline at end of file From 488d339d80684622d0ec8c11c481e497df0ca918 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 15:29:26 -0300 Subject: [PATCH 157/785] atk: Define `detail::MemoryFileStream` --- .../nn/atk/detail/util/atk_MemoryFileStream.h | 50 +++++++++++++++++++ include/nn/atk/fnd/io/atkfnd_FileStream.h | 4 +- include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h | 22 ++++---- 3 files changed, 63 insertions(+), 13 deletions(-) diff --git a/include/nn/atk/detail/util/atk_MemoryFileStream.h b/include/nn/atk/detail/util/atk_MemoryFileStream.h index e69de29b..8c1b69a4 100644 --- a/include/nn/atk/detail/util/atk_MemoryFileStream.h +++ b/include/nn/atk/detail/util/atk_MemoryFileStream.h @@ -0,0 +1,50 @@ +#pragma once + +#include +#include + +namespace nn::atk::detail { +class MemoryFileStream : fnd::FileStream { +public: + MemoryFileStream(void* buffer, size_t size); + ~MemoryFileStream() override; + + void Close() override; + + size_t Read(void* buf, size_t length, fnd::FndResult* result) override; + fnd::FndResult Seek(position_t offset, fnd::Stream::SeekOrigin origin) override; + + bool IsOpened() const override; + + size_t Write(const void* buf, size_t length, fnd::FndResult* result) override; + + position_t GetCurrentPosition() const override; + + size_t GetSize() const override; + + bool CanRead() const override; + bool CanWrite() const override; + bool CanSeek() const override; + + fnd::FndResult Open(const char* filePath, AccessMode openMode) override; + void Flush() override; + + void EnableCache(void* buffer, size_t length) override; + void DisableCache() override; + bool IsCacheEnabled() const override; + + s32 GetIoBufferAlignment() const override; + + bool CanSetFsAccessLog() const override; + void* SetFsAccessLog(fnd::FsAccessLog* pFsAccessLog) override; + + position_t GetCachePosition() override; + size_t GetCachedLength() override; + +private: + void* m_pBuffer; + size_t m_Size; + position_t m_Position; +}; +static_assert(sizeof(MemoryFileStream) == 0x20); +} // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/fnd/io/atkfnd_FileStream.h b/include/nn/atk/fnd/io/atkfnd_FileStream.h index 7a91f274..967658ae 100644 --- a/include/nn/atk/fnd/io/atkfnd_FileStream.h +++ b/include/nn/atk/fnd/io/atkfnd_FileStream.h @@ -18,7 +18,7 @@ class FileStream : Stream { virtual FndResult Open(const char* filePath, AccessMode openMode); virtual void Flush(); - virtual void EnableCache(void* buffer, std::size_t length); + virtual void EnableCache(void* buffer, size_t length); virtual void DisableCache(); virtual bool IsCacheEnabled() const; @@ -28,7 +28,7 @@ class FileStream : Stream { virtual void* SetFsAccessLog(FsAccessLog* pFsAccessLog); virtual position_t GetCachePosition(); - virtual std::size_t GetCachedLength(); + virtual size_t GetCachedLength(); ~FileStream() override; }; diff --git a/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h b/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h index 7a9502bc..079fc876 100644 --- a/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h +++ b/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h @@ -14,12 +14,12 @@ class FileStreamImpl : FileStream { void Close() override; bool IsOpened() const override; - std::size_t Read(void* buf, std::size_t length, FndResult* result) override; - std::size_t Write(const void* buf, std::size_t length, FndResult* result) override; + size_t Read(void* buf, size_t length, FndResult* result) override; + size_t Write(const void* buf, size_t length, FndResult* result) override; FndResult Seek(position_t offset, SeekOrigin origin) override; position_t GetCurrentPosition() const override; - std::size_t GetSize() const override; + size_t GetSize() const override; bool CanRead() const override; bool CanWrite() const override; @@ -33,8 +33,8 @@ class FileStreamImpl : FileStream { FileStreamImpl(); ~FileStreamImpl() override; - std::size_t Read(void* buf, std::size_t length, FndResult* result) override; - std::size_t Write(const void* buf, std::size_t length, FndResult* result) override; + size_t Read(void* buf, size_t length, FndResult* result) override; + size_t Write(const void* buf, size_t length, FndResult* result) override; FndResult Seek(position_t offset, fnd::Stream::SeekOrigin origin) override; bool CanRead() const override; @@ -48,16 +48,16 @@ class FileStreamImpl : FileStream { bool IsOpened() const override; - std::size_t GetSize() const override; + size_t GetSize() const override; position_t GetCurrentPosition() const override; - std::size_t ReadDirect(void* buf, std::size_t length, FndResult* result); - std::size_t WriteDirect(void* buf, std::size_t length, FndResult* result); + size_t ReadDirect(void* buf, size_t length, FndResult* result); + size_t WriteDirect(void* buf, size_t length, FndResult* result); FndResult SeekDirect(position_t offset, fnd::Stream::SeekOrigin origin); void Flush() override; - void EnableCache(void* buffer, std::size_t length) override; + void EnableCache(void* buffer, size_t length) override; void DisableCache() override; bool IsCacheEnabled() const override; @@ -67,13 +67,13 @@ class FileStreamImpl : FileStream { void* SetFsAccessLog(FsAccessLog* pFsAccessLog) override; position_t GetCachePosition() override; - std::size_t GetCachedLength() override; + size_t GetCachedLength() override; private: fs::FileHandle m_FileHandle; bool m_IsOpened; u8 m_Padding[3]; - std::size_t m_FileSize; + size_t m_FileSize; position_t m_CurrentPosition; StreamCache m_StreamCache; DirectStream m_DirectStream; From 21252103e8859b01192b071699bc25414701fc52 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 15:39:11 -0300 Subject: [PATCH 158/785] atk: Define `detail::SoundHeap` --- include/nn/atk/atk_SoundHeap.h | 43 ++++++++++++++++++++++++++++++++ include/nn/atk/atk_SoundSystem.h | 5 +--- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/include/nn/atk/atk_SoundHeap.h b/include/nn/atk/atk_SoundHeap.h index e69de29b..11c9858b 100644 --- a/include/nn/atk/atk_SoundHeap.h +++ b/include/nn/atk/atk_SoundHeap.h @@ -0,0 +1,43 @@ +#pragma once + +#include +#include + +#include +#include +#include + +namespace nn::atk::detail { +class SoundHeap : SoundMemoryAllocatable { +public: + SoundHeap(); + ~SoundHeap() override; + + void Destroy(); + + bool Create(void* startAddress, size_t size); + bool Create(void* startAddress, size_t size, bool); + + void Clear(); + + void* Allocate(size_t size) override; + + static void DisposeCallbackFunc(void* mem, size_t size, void* arg); + + void* Allocate(size_t size, + SoundMemoryAllocatable::DisposeCallback heapCallback, + void* heapCallbackArg) override; + + size_t GetAllocateSize(size_t size, bool needMemoryPool) override; + + s32 SaveState(); + void LoadState(s32 state); + +private: + fnd::CriticalSection m_CriticalSection; + FrameHeap m_FrameHeap; + audio::MemoryPoolType m_MemoryPool; + bool m_IsAutoMemoryPoolManagementEnabled; +}; +static_assert(sizeof(SoundHeap) == 0x50); +} // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/atk_SoundSystem.h b/include/nn/atk/atk_SoundSystem.h index 653bdcbd..9e28ebf9 100644 --- a/include/nn/atk/atk_SoundSystem.h +++ b/include/nn/atk/atk_SoundSystem.h @@ -2,16 +2,13 @@ #include #include +#include #include #include #include #include -namespace nn::audio { -struct MemoryPoolType; -} // namespace nn::audio - namespace nn::atk { struct SoundSystem { static bool g_IsInitialized; From 6a6f93cdf8f3ff4df3bee3fe069ed5bd110e8339 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 15:45:16 -0300 Subject: [PATCH 159/785] atk: Define `detail::TaskThread` --- include/nn/atk/detail/thread/atk_TaskThread.h | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/include/nn/atk/detail/thread/atk_TaskThread.h b/include/nn/atk/detail/thread/atk_TaskThread.h index e69de29b..eae3d2b2 100644 --- a/include/nn/atk/detail/thread/atk_TaskThread.h +++ b/include/nn/atk/detail/thread/atk_TaskThread.h @@ -0,0 +1,28 @@ +#pragma once + +#include +#include +#include + +namespace nn::atk::detail { +class TaskThread : fnd::Thread::Handler { +public: + TaskThread(); + ~TaskThread() override; + + void Destroy(); + + bool Create(s32 priority, void* stackBase, size_t stackSize, + s32 idealCoreNumber, u32 affinityMask, FsPriority fsPriority); + + u32 Run(void* param) override; + +private: + fnd::Thread m_Thread; + fnd::CriticalSection m_CriticalSection; + bool m_IsFinished; + bool m_IsCreated; + FsPriority m_FsPriority; +}; +static_assert(sizeof(TaskThread) == 0x220); +} // namespace nn::atk::detail \ No newline at end of file From 1b1808f30c6b0058226633c670d95591a2859760 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 15:47:21 -0300 Subject: [PATCH 160/785] atk: Move `atk_VoiceCommand.h` --- CMakeLists.txt | 2 +- include/nn/atk/detail/{voice => thread}/atk_VoiceCommand.h | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename include/nn/atk/detail/{voice => thread}/atk_VoiceCommand.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a73dc27..ec81104e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -341,6 +341,7 @@ add_library(NintendoSDK OBJECT include/nn/atk/detail/thread/atk_TaskManager.h include/nn/atk/detail/thread/atk_TaskThread.h include/nn/atk/detail/thread/atk_ThreadInfoReader.h + include/nn/atk/detail/thread/atk_VoiceCommand.h include/nn/atk/detail/util/atk_CurveAdshr.h include/nn/atk/detail/util/atk_CurveLfo.h include/nn/atk/detail/util/atk_FrameHeap.h @@ -353,7 +354,6 @@ add_library(NintendoSDK OBJECT include/nn/atk/detail/voice/atk_MultiVoice.h include/nn/atk/detail/voice/atk_MultiVoiceManager.h include/nn/atk/detail/voice/atk_Voice.h - include/nn/atk/detail/voice/atk_VoiceCommand.h include/nn/atk/detail/wsd/atk_WaveSound.h include/nn/atk/detail/wsd/atk_WaveSoundFile.h include/nn/atk/detail/wsd/atk_WaveSoundFileReader.h diff --git a/include/nn/atk/detail/voice/atk_VoiceCommand.h b/include/nn/atk/detail/thread/atk_VoiceCommand.h similarity index 100% rename from include/nn/atk/detail/voice/atk_VoiceCommand.h rename to include/nn/atk/detail/thread/atk_VoiceCommand.h From b77210d9e97633e3a662bd72059fc3136ba07cd5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 16:13:51 -0300 Subject: [PATCH 161/785] atk: Define `detail::TaskManager` --- include/nn/atk/detail/thread/atk_Task.h | 4 ++ .../nn/atk/detail/thread/atk_TaskManager.h | 57 +++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/include/nn/atk/detail/thread/atk_Task.h b/include/nn/atk/detail/thread/atk_Task.h index 03c062fd..a89cf9b4 100644 --- a/include/nn/atk/detail/thread/atk_Task.h +++ b/include/nn/atk/detail/thread/atk_Task.h @@ -3,6 +3,8 @@ #include namespace nn::atk::detail { +class TaskManager; + class Task { public: enum Status { @@ -19,6 +21,8 @@ class Task { virtual void Execute(TaskProfileLogger& logger) = 0; private: + friend TaskManager; + util::IntrusiveListNode m_TaskLink; os::Event m_Event; Status m_Status; diff --git a/include/nn/atk/detail/thread/atk_TaskManager.h b/include/nn/atk/detail/thread/atk_TaskManager.h index e69de29b..e43ac07b 100644 --- a/include/nn/atk/detail/thread/atk_TaskManager.h +++ b/include/nn/atk/detail/thread/atk_TaskManager.h @@ -0,0 +1,57 @@ +#pragma once + +#include + +#include + +namespace nn::atk::detail { +class TaskManager { +public: + using TaskList = util::IntrusiveList>; + + enum Message { + Message_Append, + }; + + enum TaskPriority { + TaskPriority_Low, + TaskPriority_Middle, + TaskPriority_High, + }; + + TaskManager(); + ~TaskManager(); + + void Initialize(bool isEnableProfiling); + void Finalize(); + + void AppendTask(Task* task, TaskPriority priority); + + Task* GetNextTask(TaskPriority priority, bool); + + Task* PopTask(); + Task* PeekTask(); + + void ExecuteTask(); + void CancelTask(Task* task); + + bool TryRemoveTask(Task* task); + + void CancelTaskById(u32 id); + void RemoveTaskById(u32 id); + + void CancelAllTask(); + + void WaitTask(); + void CancelWaitTask(); + +private: + TaskList m_TaskList[3]; + bool m_IsWaitTaskCancel; + fnd::CriticalSection m_CriticalSection; + os::MessageQueue m_BlockingQueue; + std::uintptr_t m_MsgBuffer[32]; + TaskProfileLogger m_TaskProfileLogger; +}; +static_assert(sizeof(TaskManager) == 0x1d8); +} // namespace nn::atk::detail \ No newline at end of file From f928066b521bdf2baced69dfadeb9e9aa5daf43f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 17:08:53 -0300 Subject: [PATCH 162/785] atk: Define `detail::HardwareManager` --- .../nn/atk/detail/dsp/atk_HardwareManager.h | 246 ++++++++++++++++++ .../nn/atk/detail/voice/atk_LowLevelVoice.h | 2 +- include/nn/atk/submix/atk_SubMix.h | 6 + include/nn/audio/audio_MemoryPoolTypes.h | 10 + 4 files changed, 263 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/detail/dsp/atk_HardwareManager.h b/include/nn/atk/detail/dsp/atk_HardwareManager.h index e69de29b..0c9e04b2 100644 --- a/include/nn/atk/detail/dsp/atk_HardwareManager.h +++ b/include/nn/atk/detail/dsp/atk_HardwareManager.h @@ -0,0 +1,246 @@ +#pragma once + +#include + +#include +#include + +#include +#include +#include +#include +#include + +namespace nn::atk::detail::driver { +class HardwareManager { // inherits nn::atk::Util::Singleton +public: + using SubMixList = util::IntrusiveList>; + + class EffectAuxListScopedLock { + public: + EffectAuxListScopedLock(); + ~EffectAuxListScopedLock(); + }; + void LockEffectAuxList(); + void UnlockEffectAuxList(); + + class EffectAuxListForFinalMixScopedLock { + public: + EffectAuxListForFinalMixScopedLock(); + ~EffectAuxListForFinalMixScopedLock(); + }; + void LockEffectAuxListForFinalMix(); + void UnlockEffectAuxListForFinalMix(); + + class EffectAuxListForAdditionalSubMixScopedLock { + public: + EffectAuxListForAdditionalSubMixScopedLock(); + ~EffectAuxListForAdditionalSubMixScopedLock(); + }; + void LockEffectAuxListForAdditionalSubMix(); + void UnlockEffectAuxListForAdditionalSubMix(); + + class SubMixListScopedLock { + public: + SubMixListScopedLock(); + ~SubMixListScopedLock(); + }; + void LockSubMixList(); + void UnlockSubMixList(); + + class UpdateAudioRendererScopedLock { + public: + UpdateAudioRendererScopedLock(); + ~UpdateAudioRendererScopedLock(); + }; + + class HardwareManagerParameter { + public: + void SetSubMixParameter(bool isStereoModeEnabled, bool isEffectEnabled, + bool isSubMixEnabled, bool isAdditionalEffectBusEnabled, + bool isAdditionalSubMixEnabled, bool isCustomSubMixEnabled, + s32 customSubMixCount, s32 customMixTotalChannelCount); + + private: + s32 m_RendererSampleRate; + s32 m_UserEffectCount; + s32 m_VoiceCount; + s32 m_RecordingAudioFrameCount; + s32 m_SubMixCount; + s32 m_MixBufferCount; + bool m_IsProfilerEnabled; + bool m_IsAdditionalEffectBusEnabled; + bool m_IsAdditionalSubMixEnabled; + bool m_IsEffectEnabled; + bool m_IsRecordingEnabled; + bool m_IsUserCircularBufferSinkEnabled; + bool m_IsPresetSubMixEnabled; + bool m_IsStereoModeEnabled; + bool m_IsSoundThreadEnabled; + bool m_IsVoiceDropEnabled; + bool m_IsCompatibleDownMixSettingEnabled; + bool m_IsPreviousSdkVersionLowPassFilterCompatible; + bool m_IsUnusedEffectChannelMutingEnabled; + bool m_IsCompatibleBusVolumeEnabled; + bool m_IsUserThreadRenderingEnabled; + bool m_IsCustomSubMixEnabled; + bool m_IsMemoryPoolAttachCheckEnabled; + }; + static_assert(sizeof(HardwareManagerParameter) == 0x2c); + + HardwareManager(); + + void ResetParameters(); + + audio::MemoryPoolState GetMemoryPoolState(audio::MemoryPoolType* pPool); + + void SetupAudioRendererParameter(audio::AudioRendererParameter* audioRendererParameter, + const HardwareManagerParameter& hardwareManagerParameter) const; + + size_t GetRequiredMemSize(const HardwareManagerParameter& hardwareManagerParameter) const; + size_t GetRequiredMemSizeForMemoryPool(s32 voiceCount) const; + size_t GetRequiredRecorderWorkBufferSize(const HardwareManagerParameter& hardwareManagerParameter) const; + size_t GetRequiredCircularBufferSinkWithMemoryPoolBufferSize(const HardwareManagerParameter& hardwareManagerParameter) const; + size_t GetRequiredCircularBufferSinkBufferSize(const HardwareManagerParameter& hardwareManagerParameter) const; + + s32 GetChannelCountMax() const; + + bool RegisterRecorder(DeviceOutRecorder* pRecorder); + bool UnregisterRecorder(DeviceOutRecorder* pRecorder); + void UpdateRecorder(); + + u64 ReadRecordingCircularBufferSink(void* buffer, size_t bufferSize); + audio::CircularBufferSinkType* AllocateRecordingCircularBufferSink(); + void FreeRecordingCircularBufferSink(audio::CircularBufferSinkType* circularBufferSink); + void StartRecordingCircularBufferSink(); + + void StopUserCircularBufferSink(); + void StartUserCircularBufferSink(bool isForceStartMode); + u64 ReadUserCircularBufferSink(void* buffer, size_t bufferSize); + + void AttachMemoryPool(audio::MemoryPoolType* pPool, void* buffer, + size_t bufferSize, bool isSoundThreadEnabled); + + Result RequestUpdateAudioRenderer(); + + void DetachMemoryPool(audio::MemoryPoolType* pPool, bool isSoundThreadEnabled); + + void ExecuteAudioRendererRendering(); + + void WaitAudioRendererEvent(); + + s32* GetDroppedLowLevelVoiceCount() const; + + size_t GetRequiredPerformanceFramesBufferSize(HardwareManagerParameter* hardwareManagerParameter); + + Result Initialize(void* buffer, size_t bufferSize, void* memoryPoolBuffer, size_t memoryPoolBufferSize, + void* circularBufferSinkBuffer, size_t circularBufferSinkBufferSize, + HardwareManagerParameter* parameter); + + void SetBiquadFilterCallback(s32, const BiquadFilterCallback* callback); + void SetOutputMode(OutputMode mode,OutputDevice device); + + void UpdateEndUserOutputMode(); + + void Finalize(); + + void Update(); + void UpdateEffect(); + + void SuspendAudioRenderer(); + void ResumeAudioRenderer(); + + bool TimedWaitAudioRendererEvent(TimeSpan timeout); + + void SetAudioRendererRenderingTimeLimit(s32 timeLimit); + s32 GetAudioRendererRenderingTimeLimit(); + + void PrepareReset(); + + bool IsResetReady() const; + + void AddSubMix(SubMix* pSubMix); + void RemoveSubMix(SubMix* pSubMix); + + SubMix* GetSubMix(s32 subMixNumber); + SubMix* GetSubMix(s32 subMixNumber) const; + + s32 GetSubMixCount() const; + s32 GetChannelCount() const; + f32 GetOutputVolume() const; + + void SetOutputDeviceFlag(s32, u8); + + void SetMasterVolume(f32 volume, s32 fadeFrames); + void SetSrcType(SampleRateConverterType sampleRateConverter); + + size_t GetRequiredEffectAuxBufferSize(const EffectAux* pEffect) const; + + void SetAuxBusVolume(AuxBus bus, f32 volume, s32 fadeFrames, s32 subMixIndex); + f32 GetAuxBusVolume(AuxBus bus, s32 subMixIndex) const; + + void SetMainBusChannelVolumeForAdditionalEffect(f32 send, s32 srcChannel, s32 dstChannel); + f32 GetMainBusChannelVolumeForAdditionalEffect(s32 srcChannel, s32 dstChannel) const; + + void SetAuxBusChannelVolumeForAdditionalEffect(AuxBus bus, f32 send, s32 srcChannel, s32 dstChannel); + f32 GetAuxBusChannelVolumeForAdditionalEffect(AuxBus bus, s32 srcChannel, s32 dstChannel) const; + + static void FlushDataCache(void* address, size_t length); + +private: + bool m_IsInitialized; + audio::AudioRendererHandle m_RendererHandle; + audio::AudioRendererConfig m_Config; + os::SystemEvent m_SystemEvent; + s32 m_AudioRendererSuspendCount; + std::atomic_ulong m_AudioRendererUpdateCount; + void* m_pAudioRendererWorkBuffer; + void* m_pAudioRendererConfigWorkBuffer; + OutputMode m_OutputMode[1]; + OutputMode m_EndUserOutputMode[1]; + SampleRateConverterType m_SrcType; + MoveValue m_MasterVolume; + MoveValue m_VolumeForReset; + BiquadFilterCallback* m_BiquadFilterCallbackTable[128]; + u8 m_OutputDeviceFlag[32]; + LowLevelVoiceAllocator m_LowLevelVoiceAllocator; + FinalMix m_FinalMix; + SubMix m_SubMix[2]; + SubMix m_AdditionalSubMix; + SubMixList m_SubMixList; + fnd::CriticalSection m_SubMixListLock; + audio::AudioRendererParameter m_AudioRendererParameter; + audio::DeviceSinkType m_Sink; + MoveValue m_AuxUserVolume[3]; + MoveValue m_AuxUserVolumeForAdditionalEffect[2]; + bool m_IsInitializedEffect; + bool m_IsPresetSubMixEnabled; + bool m_IsAdditionalEffectEnabled; + bool m_IsAdditionalSubMixEnabled; + bool m_IsStereoModeEnabled; + bool m_IsInitializedSoundThread; + bool m_IsPreviousSdkVersionLowPassFilterCompatible; + bool m_IsMemoryPoolAttachCheckEnabled; + fnd::CriticalSection m_UpdateAudioRendererLock; + fnd::CriticalSection m_UpdateHardwareManagerLock; + fnd::CriticalSection m_EffectAuxListLock; + fnd::CriticalSection m_EffectAuxListForFinalMixLock; + fnd::CriticalSection m_EffectAuxListForAdditionalSubMixLock; + audio::CircularBufferSinkType m_RecordingCircularBufferSink; + CircularBufferSinkState m_RecordingCircularBufferSinkState; + audio::MemoryPoolType m_RecordingCircularBufferSinkMemoryPool; + void* m_RecordingCircularBufferSinkBuffer; + bool m_IsRecordingCircularBufferSinkAllocated; + void* m_RecordingBuffer; + size_t m_RecordingBufferSize; + DeviceOutRecorder* m_pRecorder; + audio::CircularBufferSinkType m_UserCircularBufferSink; + audio::MemoryPoolType m_UserCircularBufferSinkMemoryPool; + void* m_UserCircularBufferSinkBuffer; + size_t m_UserCircularBufferSinkBufferSize; + CircularBufferSinkState m_UserCircularBufferSinkState; + bool m_IsCompatibleBusVolumeEnabled; + bool m_IsUserThreadRenderingEnabled; +}; +static_assert(sizeof(HardwareManager) == 0xa58); +} // namespace nn::atk::detail::driver \ No newline at end of file diff --git a/include/nn/atk/detail/voice/atk_LowLevelVoice.h b/include/nn/atk/detail/voice/atk_LowLevelVoice.h index 6d3878cc..8940e09f 100644 --- a/include/nn/atk/detail/voice/atk_LowLevelVoice.h +++ b/include/nn/atk/detail/voice/atk_LowLevelVoice.h @@ -2,8 +2,8 @@ #include -#include #include +#include #include #include diff --git a/include/nn/atk/submix/atk_SubMix.h b/include/nn/atk/submix/atk_SubMix.h index 245fb537..b1c33c8d 100644 --- a/include/nn/atk/submix/atk_SubMix.h +++ b/include/nn/atk/submix/atk_SubMix.h @@ -7,6 +7,10 @@ #include namespace nn::atk { +namespace detail::driver { +class HardwareManager; +}; + class SubMix : OutputMixer { public: class VolumeData { @@ -159,6 +163,8 @@ class SubMix : OutputMixer { void AddReferenceCount(s32 value) override; private: + friend detail::driver::HardwareManager; + util::IntrusiveListNode m_Link; audio::SubMixType m_SubMix; std::atomic_uint m_ReferenceCount; diff --git a/include/nn/audio/audio_MemoryPoolTypes.h b/include/nn/audio/audio_MemoryPoolTypes.h index a7a0c405..7c976024 100644 --- a/include/nn/audio/audio_MemoryPoolTypes.h +++ b/include/nn/audio/audio_MemoryPoolTypes.h @@ -1,6 +1,16 @@ #pragma once namespace nn::audio { +enum MemoryPoolState { + MemoryPoolState_Invalid, + MemoryPoolState_New, + MemoryPoolState_RequestDetach, + MemoryPoolState_Detached, + MemoryPoolState_RequestAttach, + MemoryPoolState_Attached, + MemoryPoolState_Released, +}; + struct MemoryPoolInfo {}; struct MemoryPoolType { From 173f9071f3f646998ced459f22683cb1950674a5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 17:15:05 -0300 Subject: [PATCH 163/785] audio: Move types to their respective headers Also include all `nn::audio` headers in audio.h --- include/nn/audio.h | 212 ++---------------- include/nn/audio/audio_Common.h | 9 + .../nn/audio/audio_PerformanceMetricsTypes.h | 14 ++ 3 files changed, 37 insertions(+), 198 deletions(-) diff --git a/include/nn/audio.h b/include/nn/audio.h index ab140895..ba115227 100644 --- a/include/nn/audio.h +++ b/include/nn/audio.h @@ -6,151 +6,29 @@ #pragma once #include -#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace nn { namespace audio { // Common audio -struct AudioDeviceName { - char raw_name[0x100]; -}; - -static_assert(sizeof(AudioDeviceName) == 0x100); - void AcquireAudioDeviceSwitchNotification(nn::os::SystemEvent* event); s32 ListAudioDeviceName(nn::audio::AudioDeviceName* buffer, s32 bufferCount); Result SetAudioDeviceOutputVolume(nn::audio::AudioDeviceName const* device, float volume); u32 GetActiveChannelCount(); -struct AudioRendererConfig { - u64* _0; - u64* _8; - u64* _10; - u64* _18; - u64* _20; - u64* _28; - u64* _30; - u64* _38; - u64* _40; - u64* _48; - u64* _50; -}; - -enum AudioRendererRenderingDevice : u32 { - AudioRendererRenderingDevice_Cpu, - AudioRendererRenderingDevice_Dsp -}; - -enum AudioRendererExecutionMode : u32 { - AudioRendererExecutionMode_Manual, - AudioRendererExecutionMode_Auto, -}; - -enum SampleFormat : u32 { - SampleFormat_Invalid, - SampleFormat_PcmInt8, - SampleFormat_PcmInt16, - SampleFormat_PcmInt24, - SampleFormat_PcmInt32, - SampleFormat_PcmFloat, - SampleFormat_Adpcm, -}; - -enum MemoryPoolState : u32 { - MemoryPoolState_Invalid, - MemoryPoolState_New, - MemoryPoolState_RequestDetach, - MemoryPoolState_Detached, - MemoryPoolState_RequestAttach, - MemoryPoolState_Attached, - MemoryPoolState_Released, -}; - -struct AudioRendererParameter { - u32 sampleRate; - u32 sampleCount; - u32 mixBufferCount; - u32 subMixCount; - u32 voiceCount; - u32 sinkCount; - u32 effectCount; - u32 performanceFrameCount; - bool isVoiceDropEnabled; - u32 splitterCount; - u32 splitterSendChannelCount; - AudioRendererRenderingDevice renderingDevice; - AudioRendererExecutionMode executionMode; - u32 _34; - u32 revision; -}; - -static_assert(sizeof(AudioRendererParameter) == 0x3C); - -struct BiquadFilterParameter { - bool enabled; - s16 numerator[3]; - s16 denominator[2]; -}; - -static_assert(sizeof(BiquadFilterParameter) == 0xC); - -struct WaveBuffer { - void* buffer; - size_t bufferSize; - s32 startSampleOffset; - s32 endSampleOffset; - bool shouldLoop; - bool isEndOfStream; - void* context; - size_t contextSize; -}; - -static_assert(sizeof(WaveBuffer) == 0x30); - -struct AudioRendererHandle { - u64* _0; - u64* _8; -}; - -struct MemoryPoolType { - u64* _0; -}; - -struct CircularBufferSinkType { - u64* _0; -}; - -struct AuxType { - u64* _0; -}; - -struct DelayType { - u64* _0; -}; - -struct FinalMixType { - u64* _0; -}; - -struct SubMixType { - u64* _0; -}; - -struct VoiceType { - u64* _0; - - enum PlayState : u32 { - PlayState_Start, - PlayState_Stop, - PlayState_Pause, - }; -}; - -struct DeviceSinkType { - struct DownMixParameter; - u64* _0; -}; - // Audio Renderer base APIs void InitializeAudioRendererParameter(nn::audio::AudioRendererParameter* inParameter); bool IsValidAudioRendererParameter(nn::audio::AudioRendererParameter const& inParameter); @@ -212,68 +90,6 @@ GetRequiredBufferSizeForPerformanceFrames(nn::audio::AudioRendererParameter cons void* SetPerformanceFrameBuffer(nn::audio::AudioRendererConfig* config, void* buffer, size_t bufferSize); -enum PerformanceEntryType : u8 { - PerformanceEntryType_Invalid, - PerformanceEntryType_Voice, - PerformanceEntryType_SubMix, - PerformanceEntryType_FinalMix, - PerformanceEntryType_Sink -}; - -struct PerformanceEntry { - s32 nodeId; - s32 startTime; - s32 processingTime; - PerformanceEntryType entryType; -}; - -static_assert(sizeof(PerformanceEntry) == 0x10); - -enum PerformanceDetailType : u8 { - PerformanceDetailType_Unknown, - PerformanceDetailType_PcmInt16, - PerformanceDetailType_Adpcm, - PerformanceDetailType_VolumeRamp, - PerformanceDetailType_BiquadFilter, - PerformanceDetailType_Mix, - PerformanceDetailType_Delay, - PerformanceDetailType_Aux, - PerformanceDetailType_Reverb, - PerformanceDetailType_Reverb3d, - PerformanceDetailType_PcmFloat -}; - -struct PerformanceDetail { - s32 nodeId; - s32 startTime; - s32 processingTime; - PerformanceDetailType detailType; - PerformanceEntryType entryType; -}; - -static_assert(sizeof(PerformanceDetail) == 0x10); - -class PerformanceInfo { -public: - PerformanceInfo(); - ~PerformanceInfo(); - - bool SetBuffer(void const* buffer, size_t bufferSize); - bool MoveToNextFrame(); - s32 GetTotalProcessingTime(); - PerformanceEntry GetEntries(s32* count); - PerformanceDetail GetDetails(s32* count); - -private: - void* buffer; - size_t bufferSize; - void* header; - PerformanceEntry* entries; - PerformanceDetail* details; -}; - -static_assert(sizeof(PerformanceInfo) == 0x28); - // Audio Renderer Sink APIs Result AddDeviceSink(nn::audio::AudioRendererConfig* config, nn::audio::DeviceSinkType* sink, nn::audio::FinalMixType* mix, s8 const* input, s32 inputCount, diff --git a/include/nn/audio/audio_Common.h b/include/nn/audio/audio_Common.h index fcd8a963..7cc0ed32 100644 --- a/include/nn/audio/audio_Common.h +++ b/include/nn/audio/audio_Common.h @@ -5,6 +5,15 @@ namespace nn::audio { using NodeId = uint32_t; +struct AudioDeviceName { + char raw_name[0x100]; +}; +static_assert(sizeof(AudioDeviceName) == 0x100); + +struct DelayType { + u64* _0; +}; + struct EffectInfo {}; struct MixInfo {}; diff --git a/include/nn/audio/audio_PerformanceMetricsTypes.h b/include/nn/audio/audio_PerformanceMetricsTypes.h index 7e114294..483a91f5 100644 --- a/include/nn/audio/audio_PerformanceMetricsTypes.h +++ b/include/nn/audio/audio_PerformanceMetricsTypes.h @@ -12,6 +12,20 @@ enum PerformanceEntryType { PerformanceEntryType_Count }; +enum PerformanceDetailType : u8 { + PerformanceDetailType_Unknown, + PerformanceDetailType_PcmInt16, + PerformanceDetailType_Adpcm, + PerformanceDetailType_VolumeRamp, + PerformanceDetailType_BiquadFilter, + PerformanceDetailType_Mix, + PerformanceDetailType_Delay, + PerformanceDetailType_Aux, + PerformanceDetailType_Reverb, + PerformanceDetailType_Reverb3d, + PerformanceDetailType_PcmFloat +}; + struct PerformanceEntry { NodeId id; s32 startTime; From d010424d29f156c814aab5c5bbe1464a3b550bc1 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 17:24:00 -0300 Subject: [PATCH 164/785] atk: Add static variables to `detail::driver::HardwareManager` --- .../nn/atk/detail/dsp/atk_HardwareManager.h | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/include/nn/atk/detail/dsp/atk_HardwareManager.h b/include/nn/atk/detail/dsp/atk_HardwareManager.h index 0c9e04b2..4a16daac 100644 --- a/include/nn/atk/detail/dsp/atk_HardwareManager.h +++ b/include/nn/atk/detail/dsp/atk_HardwareManager.h @@ -16,6 +16,37 @@ class HardwareManager { // inherits nn::atk::Util::Singleton public: using SubMixList = util::IntrusiveList>; + constexpr static u32 SoundFrameIntervalMsec = 5; + constexpr static u32 SoundFrameIntervalUsec = 5000; + + constexpr static u32 DefaultRendererSampleRate = 48000; + constexpr static u32 DefaultRendererUserEffectCount = 10; + constexpr static u32 DefaultRendererVoiceCountMax = 96; + + constexpr static u32 DefaultRecordingAudioFrameCount = 8; + + constexpr static u32 AtkVoiceCountMax = 192; + constexpr static u32 MixerCount = 3; + constexpr static u32 ChannelCountMax = 6; + constexpr static u32 BusCount = 4; + + constexpr static u32 DefaultRendererSampleCount = 140; + constexpr static u32 DefaultRendererMixBufferCount = 30; + constexpr static u32 DefaultRendererSubMixCount = 1; + constexpr static u32 DefaultRendererSinkCount = 1; + constexpr static u32 DefaultRendererPerformanceFrameCount = 0; + + constexpr static u32 DefaultRendererSystemEffectCount = 4; + + constexpr static u32 SubMixCountMax = 2; + constexpr static u32 SubMixCountForAdditionalEffect = 1; + constexpr static u32 ChannelCountForAdditionalEffect = 2; + + constexpr static u32 AuxBusCountForAdditionalEffect = 2; + constexpr static u32 MixBufferCountForAdditionalEffect = 6; + + constexpr static bool DefaultRendererIsVoiceDropEnabled = false; + class EffectAuxListScopedLock { public: EffectAuxListScopedLock(); @@ -205,14 +236,14 @@ class HardwareManager { // inherits nn::atk::Util::Singleton u8 m_OutputDeviceFlag[32]; LowLevelVoiceAllocator m_LowLevelVoiceAllocator; FinalMix m_FinalMix; - SubMix m_SubMix[2]; + SubMix m_SubMix[SubMixCountMax]; SubMix m_AdditionalSubMix; SubMixList m_SubMixList; fnd::CriticalSection m_SubMixListLock; audio::AudioRendererParameter m_AudioRendererParameter; audio::DeviceSinkType m_Sink; - MoveValue m_AuxUserVolume[3]; - MoveValue m_AuxUserVolumeForAdditionalEffect[2]; + MoveValue m_AuxUserVolume[MixerCount]; + MoveValue m_AuxUserVolumeForAdditionalEffect[AuxBusCountForAdditionalEffect]; bool m_IsInitializedEffect; bool m_IsPresetSubMixEnabled; bool m_IsAdditionalEffectEnabled; From 44976b1c9eeeb73b6b61f22e53e9e488a4d99d7b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 17:49:24 -0300 Subject: [PATCH 165/785] atk: Define global functions and variables --- include/nn/atk/atk_Adpcm.h | 8 ++++++++ include/nn/atk/atk_Global.h | 2 -- include/nn/atk/detail/debug/atk_Debug.h | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_Adpcm.h b/include/nn/atk/atk_Adpcm.h index 09704a19..f7dd0a53 100644 --- a/include/nn/atk/atk_Adpcm.h +++ b/include/nn/atk/atk_Adpcm.h @@ -2,6 +2,8 @@ #include +#include + namespace nn::atk { using AdpcmParam = audio::AdpcmParameter; @@ -14,4 +16,10 @@ struct AdpcmContextNotAligned { audio::AdpcmContext audioAdpcmContext; }; static_assert(sizeof(AdpcmContextNotAligned) == 0x6); + +namespace detail { +void DecodeDspAdpcm(position_t playPosition, AdpcmContext* context, + AdpcmParam* param, void* adpcmData, size_t decodeSamples, + s16* dest); +}; } // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h index 0b26ce6d..3c04924e 100644 --- a/include/nn/atk/atk_Global.h +++ b/include/nn/atk/atk_Global.h @@ -4,8 +4,6 @@ #include namespace nn::atk { -static u32 gWarningFlag = 0x1f; - enum WaveType { WaveType_Invalid = -1, WaveType_Nwwav, diff --git a/include/nn/atk/detail/debug/atk_Debug.h b/include/nn/atk/detail/debug/atk_Debug.h index cdfb98cf..bd90d139 100644 --- a/include/nn/atk/detail/debug/atk_Debug.h +++ b/include/nn/atk/detail/debug/atk_Debug.h @@ -1,5 +1,7 @@ #pragma once +#include + namespace nn::atk { enum DebugWarningFlag { DebugWarningFlag_NotEnoughInstance, @@ -10,6 +12,11 @@ enum DebugWarningFlag { DebugWarningFlag_NotEnoughStrmchannel, }; +static u8 gWarningFlag = 0b11111; +static const u32 gWarningBitFlags[6] = {0b11111, 0b00001, 0b00010, 0b00100, 0b01000, 0b10000}; + +void Debug_SetWarningFlag(DebugWarningFlag warning, bool); + namespace detail { enum DebugSoundType { DebugSoundType_Seqsound, @@ -17,6 +24,14 @@ enum DebugSoundType { DebugSoundType_Wavesound, }; +static const char* gSoundTypeStrings[3] = {"seq", "strm", "wave"}; + +bool Debug_GetWarningFlag(DebugWarningFlag warning); +DebugWarningFlag Debug_GetDebugWarningFlagFromSoundType(DebugSoundType type); +char* Debug_GetSoundTypeString(DebugSoundType type); + using DebugLogFunc = void(*)(char*); + +static DebugLogFunc g_DebugLogHookFunc; } // namespace nn::atk::detail } // namespace nn::atk \ No newline at end of file From 2d8ea458f77604a3d2c73564fe28d31ab4b89c34 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 18:15:46 -0300 Subject: [PATCH 166/785] os: Change variable access in `MessageQueue` --- include/nn/atk/atk_Global.h | 172 ++++++++++++++++---------------- include/nn/os/os_MessageQueue.h | 1 - 2 files changed, 84 insertions(+), 89 deletions(-) diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h index 3c04924e..c633a8cb 100644 --- a/include/nn/atk/atk_Global.h +++ b/include/nn/atk/atk_Global.h @@ -147,8 +147,7 @@ enum FsPriority { FsPriority_Low, }; -class AdshrCurve { -private: +struct AdshrCurve { u8 m_Attack; u8 m_Decay; u8 m_Sustain; @@ -323,101 +322,98 @@ enum VolumeThroughModeBitFlag { }; namespace detail { - enum DecodeMode { - DecodeMode_Invalid = -1, - DecodeMode_Default, - DecodeMode_Cpu, - DecodeMode_Accelerator, - }; +enum DecodeMode { + DecodeMode_Invalid = -1, + DecodeMode_Default, + DecodeMode_Cpu, + DecodeMode_Accelerator, +}; - struct DspAdpcmLoopParam { - u16 loopPredScale; - u16 loopYn1; - u16 loopYn2; - }; - static_assert(sizeof(DspAdpcmLoopParam) == 0x6); +struct DspAdpcmLoopParam { + u16 loopPredScale; + u16 loopYn1; + u16 loopYn2; +}; +static_assert(sizeof(DspAdpcmLoopParam) == 0x6); - struct OutputBusMixVolume { - float volume[2][24]; - }; - static_assert(sizeof(OutputBusMixVolume) == 0xc0); - - struct OutputParam { - float volume; - u32 mixMode; - MixParameter mixParameter[2]; - float pan; - float span; - float send[4]; - }; - static_assert(sizeof(OutputParam) == 0x50); +struct OutputBusMixVolume { + float volume[2][24]; +}; +static_assert(sizeof(OutputBusMixVolume) == 0xc0); + +struct OutputParam { + float volume; + u32 mixMode; + MixParameter mixParameter[2]; + float pan; + float span; + float send[4]; +}; +static_assert(sizeof(OutputParam) == 0x50); - struct SoundInstanceConfig { - bool isBusMixVolumeEnabled; - bool isVolumeThroughModeEnabled; - s32 busCount; - }; - static_assert(sizeof(SoundInstanceConfig) == 8); +struct SoundInstanceConfig { + bool isBusMixVolumeEnabled; + bool isVolumeThroughModeEnabled; + s32 busCount; +}; +static_assert(sizeof(SoundInstanceConfig) == 8); - enum StreamFileType { - StreamFileType_Bfstm, - StreamFileType_Opus, - }; +enum StreamFileType { + StreamFileType_Bfstm, + StreamFileType_Opus, +}; - enum VoiceState { - VoiceState_Play, - VoiceState_Stop, - VoiceState_Pause, - }; +enum VoiceState { + VoiceState_Play, + VoiceState_Stop, + VoiceState_Pause, +}; - struct VoiceInfo { - VoiceState voiceState; - WaveBuffer::Status waveBufferStatus; - void* waveBufferTag; - u32 playPosition; - void* userId; - }; - static_assert(sizeof(VoiceInfo) == 0x20); - - class VoiceParam { - private: - float m_Volume; - float m_Pitch; - OutputMix m_TvMix; - bool m_MonoFilterFlag; - bool m_BiquadFilterFlag; - BiquadFilterCoefficients m_BiquadFilterCoefficients; - u16 m_MonoFilterCutoff; - u8 m_InterpolationType; - }; - static_assert(sizeof(VoiceParam) == 0x78); - - struct WaveInfo { - struct ChannelParam { - void* dataAddress; - s32 dataSize; - DspAdpcmParam adpcmParam; - DspAdpcmLoopParam adpcmLoopParam; - }; - static_assert(sizeof(ChannelParam) == 0x38); - - SampleFormat sampleFormat; - bool loopFlag; - s32 channelCount; - s32 sampleRate; - position_t loopStartFrame; - position_t loopEndFrame; - position_t originalLoopStartFrame; - size_t dataSize; - ChannelParam channelParam[2]; +struct VoiceInfo { + VoiceState voiceState; + WaveBuffer::Status waveBufferStatus; + void* waveBufferTag; + u32 playPosition; + void* userId; +}; +static_assert(sizeof(VoiceInfo) == 0x20); + +class VoiceParam { +private: + float m_Volume; + float m_Pitch; + OutputMix m_TvMix; + bool m_MonoFilterFlag; + bool m_BiquadFilterFlag; + BiquadFilterCoefficients m_BiquadFilterCoefficients; + u16 m_MonoFilterCutoff; + u8 m_InterpolationType; +}; +static_assert(sizeof(VoiceParam) == 0x78); + +struct WaveInfo { + struct ChannelParam { + void* dataAddress; + s32 dataSize; + DspAdpcmParam adpcmParam; + DspAdpcmLoopParam adpcmLoopParam; }; - static_assert(sizeof(WaveInfo) == 0xa0); -} + static_assert(sizeof(ChannelParam) == 0x38); + + SampleFormat sampleFormat; + bool loopFlag; + s32 channelCount; + s32 sampleRate; + position_t loopStartFrame; + position_t loopEndFrame; + position_t originalLoopStartFrame; + size_t dataSize; + ChannelParam channelParam[2]; +}; +static_assert(sizeof(WaveInfo) == 0xa0); +} // namespace nn::atk::detail using SoundFrameUserCallback = void(*)(std::uintptr_t); using SoundThreadUserCallback = void(*)(std::uintptr_t); using SoundStopCallback = void(*)(); - - - } // namespace nn::atk \ No newline at end of file diff --git a/include/nn/os/os_MessageQueue.h b/include/nn/os/os_MessageQueue.h index ebc3cc15..22084b10 100644 --- a/include/nn/os/os_MessageQueue.h +++ b/include/nn/os/os_MessageQueue.h @@ -5,7 +5,6 @@ namespace nn::os { class MessageQueue { public: -private: MessageQueueType m_MessageQueue; }; } // namespace nn::os \ No newline at end of file From d7edfa6d7b52f6113103bb29682e3deb6aa3be20 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 19:04:36 -0300 Subject: [PATCH 167/785] atk: Cleanup --- include/nn/atk/atk_FsSoundArchive.h | 16 +++++++++------- include/nn/atk/submix/atk_ChannelMixVolume.h | 6 ++++-- .../util/atk_AudioRendererPerformanceReader.h | 3 ++- include/nn/atk/util/atk_DeviceOutRecorder.h | 2 -- include/nn/atk/util/atk_ProfileReader.h | 4 ++-- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/include/nn/atk/atk_FsSoundArchive.h b/include/nn/atk/atk_FsSoundArchive.h index dd3fcf79..862a02bf 100644 --- a/include/nn/atk/atk_FsSoundArchive.h +++ b/include/nn/atk/atk_FsSoundArchive.h @@ -19,16 +19,18 @@ class FsSoundArchive : SoundArchive { void Close(); bool Open(const char* path); - detail::fnd::FileStream* OpenStream(void* buffer, std::size_t size, - position_t begin, std::size_t length) const override; + bool LoadFileHeader(); - detail::fnd::FileStream* OpenExtStream(void* buffer, std::size_t size, const char* extFilePath, - void* cacheBuffer, std::size_t cacheSize) const; + detail::fnd::FileStream* OpenStream(void* buffer, size_t size, + position_t begin, size_t length) const override; - std::size_t detail_GetRequiredStreamBufferSize() const override; + detail::fnd::FileStream* OpenExtStream(void* buffer, size_t size, const char* extFilePath, + void* cacheBuffer, size_t cacheSize) const override; - bool LoadHeader(void* buffer, std::size_t size); - bool LoadLabelStringData(void* buffer, std::size_t size); + size_t detail_GetRequiredStreamBufferSize() const override; + + bool LoadHeader(void* buffer, size_t size); + bool LoadLabelStringData(void* buffer, size_t size); void FileAccessBegin() const override; void FileAccessEnd() const override; diff --git a/include/nn/atk/submix/atk_ChannelMixVolume.h b/include/nn/atk/submix/atk_ChannelMixVolume.h index 49fdbe21..436b239e 100644 --- a/include/nn/atk/submix/atk_ChannelMixVolume.h +++ b/include/nn/atk/submix/atk_ChannelMixVolume.h @@ -5,6 +5,8 @@ namespace nn::atk { class ChannelMixVolume { public: + constexpr static u8 ChannelCountMax = 24; + ChannelMixVolume(); void InitializeChannelVolume(); @@ -20,7 +22,7 @@ class ChannelMixVolume { private: s32 m_ChannelCount; - f32 m_ChannelVolume[24]; + f32 m_ChannelVolume[ChannelCountMax]; }; -static_assert(sizeof(ChannelMixVolume) == 0x64); +static_assert(sizeof(ChannelMixVolume) == 4 + ChannelMixVolume::ChannelCountMax * sizeof(f32)); } // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/util/atk_AudioRendererPerformanceReader.h b/include/nn/atk/util/atk_AudioRendererPerformanceReader.h index 3a17174b..9105d936 100644 --- a/include/nn/atk/util/atk_AudioRendererPerformanceReader.h +++ b/include/nn/atk/util/atk_AudioRendererPerformanceReader.h @@ -2,12 +2,13 @@ #include -#include #include namespace nn::atk { class AudioRendererPerformanceReader { public: + constexpr static u32 PerformanceInfoCountMin = 2; + struct PerformanceInfo { void* performanceBuffer; size_t performanceBufferSize; diff --git a/include/nn/atk/util/atk_DeviceOutRecorder.h b/include/nn/atk/util/atk_DeviceOutRecorder.h index f0695ab7..9aad63ba 100644 --- a/include/nn/atk/util/atk_DeviceOutRecorder.h +++ b/include/nn/atk/util/atk_DeviceOutRecorder.h @@ -62,9 +62,7 @@ class DeviceOutRecorder : detail::fnd::Thread::Handler { void Finalize(); u32 Push(const s16* sampleBuffer, u32 samples); - u32 Pop(u32); - s64 Peek(); void SetReadBlockSamples(u32 readBlockSamples); diff --git a/include/nn/atk/util/atk_ProfileReader.h b/include/nn/atk/util/atk_ProfileReader.h index 1d443b51..1f869dec 100644 --- a/include/nn/atk/util/atk_ProfileReader.h +++ b/include/nn/atk/util/atk_ProfileReader.h @@ -45,10 +45,10 @@ class ProfileReader { public: ProfileReader(); - void Record(const SoundProfile& src); - std::size_t Read(SoundProfile*, s32); + void Record(const SoundProfile& src); + util::IntrusiveListNode m_Link; private: From d7a4cb6ea10c797d443ca72adfa404cb8836deba Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 19:05:12 -0300 Subject: [PATCH 168/785] atk: Add missing functions and static vars to `SoundArchive` --- include/nn/atk/atk_SoundArchive.h | 82 +++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 5 deletions(-) diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index 392fb35e..b541edb4 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -18,6 +18,16 @@ class SoundArchive { using FileId = ItemId; using StringId = ItemId; + constexpr static ItemId InvalidId = -1; + + constexpr static u32 UserParamIndexMax = 3; + constexpr static u32 ResultInvalidSoundId = 0; + constexpr static u32 InvalidUserParam = -1; + constexpr static u32 SequenceBankMax = 4; + constexpr static u32 StreamTrackCount = 8; + + constexpr static s32 FilePathMax = 639; + enum SoundType { SoundType_Invalid, SoundType_Sequence, @@ -130,6 +140,8 @@ class SoundArchive { static_assert(sizeof(StreamTrackInfo) == 0xe); struct StreamSoundInfo { + void Setup(); + u16 allocateTrackFlags; u16 allocateChannelCount; f32 pitch; @@ -175,23 +187,83 @@ class SoundArchive { virtual ~SoundArchive(); + bool IsAvailable() const; + + void Initialize(detail::SoundArchiveFileReader* reader); + void Finalize(); + + s32 GetSoundCount() const; + s32 GetPlayerCount() const; + s32 GetSoundGroupCount() const; + s32 GetGroupCount() const; + s32 GetBankCount() const; + s32 GetWaveArchiveCount() const; + + s32 detail_GetFileCount() const; + + char* GetItemLabel(ItemId id) const; + FileId GetItemFileId(ItemId id) const; + FileId GetItemPrefetchFileId(ItemId id) const; + + void* GetSoundUserParam(u32) const; + + bool ReadSoundUserParam(u32*, u32, s32) const; + + u32 GetSoundType(u32) const; + + bool ReadSoundInfo(SoundInfo* info, u32) const; + bool ReadSequenceSoundInfo(SequenceSoundInfo* info, u32) const; + bool ReadStreamSoundInfo(StreamSoundInfo* info, u32) const; + + bool detail_ReadStreamSoundInfo2(u32, StreamSoundInfo2*) const; + bool detail_ReadWaveSoundInfo(u32, WaveSoundInfo*) const; + bool detail_ReadAdvancedWaveSoundInfo(u32, AdvancedWaveSoundInfo*) const; + + bool ReadPlayerInfo(PlayerInfo*, u32) const; + bool ReadSoundArchivePlayerInfo(SoundArchivePlayerInfo*) const; + bool ReadSound3DInfo(Sound3DInfo*, u32) const; + bool ReadBankInfo(BankInfo*, u32) const; + bool ReadWaveArchiveInfo(u32, WaveArchiveInfo*) const; + + bool detail_ReadSoundGroupInfo(u32, SoundGroupInfo*) const; + + bool ReadGroupInfo(GroupInfo*, u32) const; + + bool detail_ReadFileInfo(u32, FileInfo*) const; + + detail::Util::Table* detail_GetWaveArchiveIdTable(ItemId id); + + bool detail_OpenFileStream(FileId id, void*, size_t, void*, size_t) const; + + void OpenExtStreamImpl(void*, size_t, const char*, void*, size_t) const; + + char* detail_GetExternalFileFullPath(const char*, char*, size_t) const; + + void SetExternalFileRoot(const char*); + + bool ReadStreamSoundFilePath(char*, size_t, u32); + + void* detail_GetAttachedGroupTable(u32) const; + virtual void* detail_GetFileAddress(ItemId itemId) = 0; - virtual std::size_t detail_GetRequiredStreamBufferSize() const = 0; + virtual size_t detail_GetRequiredStreamBufferSize() const = 0; virtual void FileAccessBegin() const; virtual void FileAccessEnd() const; virtual bool IsAddon(); - virtual detail::fnd::FileStream* OpenStream(void* buffer, std::size_t size, - position_t begin, std::size_t length) const = 0; + virtual detail::fnd::FileStream* OpenStream(void* buffer, size_t size, + position_t begin, size_t length) const = 0; + + virtual detail::fnd::FileStream* OpenExtStream(void* buffer, size_t size, const char* extFilePath, + void* cacheBuffer, size_t cacheSize) const = 0; private: detail::SoundArchiveFileReader* m_pFileReader{}; detail::SoundArchiveParametersHook* m_pParametersHook{}; - char m_ExtFileRoot[639]; + char m_ExtFileRoot[FilePathMax]; u32 m_FileBlockOffset; }; static_assert(sizeof(SoundArchive) == 0x2a0); - } // namespace nn::atk::detail \ No newline at end of file From b0c5d166975c263bd1da1837a4ca065899909e46 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 19:56:00 -0300 Subject: [PATCH 169/785] atk: Cleanup 2 --- include/nn/atk/atk_SoundArchivePlayer.h | 54 +++++++++---------- include/nn/atk/atk_SoundDataManager.h | 12 ++--- include/nn/atk/atk_SoundHandle.h | 6 +-- include/nn/atk/atk_SoundPlayer.h | 15 ++++-- .../nn/atk/detail/dsp/atk_HardwareManager.h | 4 +- 5 files changed, 49 insertions(+), 42 deletions(-) diff --git a/include/nn/atk/atk_SoundArchivePlayer.h b/include/nn/atk/atk_SoundArchivePlayer.h index ef27d053..4138aa09 100644 --- a/include/nn/atk/atk_SoundArchivePlayer.h +++ b/include/nn/atk/atk_SoundArchivePlayer.h @@ -44,39 +44,40 @@ class SoundArchivePlayer : SoundStartable { bool IsAvailable() const; bool Initialize(const SoundArchive* arc, const SoundDataManager* manager, void* buffer, - std::size_t size, void* strmBuffer, std::size_t strmBufferSize, - std::size_t userParamSizePerSound); + size_t size, void* strmBuffer, size_t strmBufferSize, + size_t userParamSizePerSound); bool Initialize(const InitializeParam& param); void Finalize(); void StopAllSound(s32, bool); + void DisposeInstances(); - static std::size_t GetRequiredMemSize(const SoundArchive* arc); - static std::size_t GetRequiredMemSize(const SoundArchive* arc, std::size_t userParamSizePerSound, + static size_t GetRequiredMemSize(const SoundArchive* arc); + static size_t GetRequiredMemSize(const SoundArchive* arc, size_t userParamSizePerSound, s32 addonSoundArchiveCount); - static std::size_t GetRequiredMemSize(const SoundArchive* arc, std::size_t userParamSizePerSound); - static std::size_t GetRequiredMemSize(const InitializeParam& param); + static size_t GetRequiredMemSize(const SoundArchive* arc, size_t userParamSizePerSound); + static size_t GetRequiredMemSize(const InitializeParam& param); - static std::size_t GetRequiredStreamInstanceSize(const SoundArchive* arc); + static size_t GetRequiredStreamInstanceSize(const SoundArchive* arc); - std::size_t GetRequiredStreamBufferSize(const SoundArchive* arc) const; - std::size_t GetRequiredStreamBufferTimes(const SoundArchive* arc) const; + size_t GetRequiredStreamBufferSize(const SoundArchive* arc) const; + size_t GetRequiredStreamBufferTimes(const SoundArchive* arc) const; - static std::size_t GetRequiredStreamCacheSize(const SoundArchive* arc, std::size_t); + static size_t GetRequiredStreamCacheSize(const SoundArchive* arc, size_t); - bool SetupMram(const SoundArchive* pArc, void* buffer, std::size_t size, - std::size_t userParamSizePerSound, s32 addonSoundArchiveCount, - void* streamSoundInstanceBuffer, std::size_t streamSoundInstanceBufferSize); + bool SetupMram(const SoundArchive* pArc, void* buffer, size_t size, + size_t userParamSizePerSound, s32 addonSoundArchiveCount, + void* streamSoundInstanceBuffer, size_t streamSoundInstanceBufferSize); bool SetupSoundPlayer(const SoundArchive* pArc, void** pOutAllocatedAddr, const void* endAddr); bool SetupAddonSoundArchiveContainer(s32 containerCount, void** pOutAllocatedAddr, const void* endAddr); bool SetupUserParamForBasicSound(const SoundArchive::SoundArchivePlayerInfo& playerInfo, - void** pOutAllocatedAddr, const void* endAddr, std::size_t); + void** pOutAllocatedAddr, const void* endAddr, size_t); - detail::PlayerHeap* CreatePlayerHeap(void** pOutAllocatedAddr, const void* endAddr, std::size_t); + detail::PlayerHeap* CreatePlayerHeap(void** pOutAllocatedAddr, const void* endAddr, size_t); void Update(); @@ -142,30 +143,30 @@ class SoundArchivePlayer : SoundStartable { Result ReadStreamSoundDataInfo(detail::StreamSoundDataInfo*, u32) const; Result ReadStreamSoundDataInfo(detail::StreamSoundDataInfo*, const char*) const; - static std::size_t GetRequiredWorkBufferSizeToReadStreamSoundHeader(); + static size_t GetRequiredWorkBufferSizeToReadStreamSoundHeader(); Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, u32, const char* const*, s32, const SoundArchive*, - void*, std::size_t) const; + void*, size_t) const; Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, u32, const char*, - void*, std::size_t) const; + void*, size_t) const; Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, u32, - const char* const*, s32, void*, std::size_t, + const char* const*, s32, void*, size_t, const char*) const; Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, const char*, - const char*, void*, std::size_t) const; + const char*, void*, size_t) const; Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, const char*, - const char* const*, s32, void*, std::size_t, + const char* const*, s32, void*, size_t, const char*) const; Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, u32, - const char* const*, s32, void*, std::size_t) const; + const char* const*, s32, void*, size_t) const; Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, const char*, - const char* const*, s32, void*, std::size_t) const; + const char* const*, s32, void*, size_t) const; Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, const char*, - const char*, void*, std::size_t, + const char*, void*, size_t, const char* soundArchiveName) const; Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, u32, const char*, - void*, std::size_t, const char* soundArchiveName) const; + void*, size_t, const char* soundArchiveName) const; void DumpMemory() const; @@ -180,7 +181,6 @@ class SoundArchivePlayer : SoundStartable { SoundArchive::ItemId detail_GetItemId(char* pString) override; SoundArchive::ItemId detail_GetItemId(char* pString, const char* soundArchiveName) override; - private: detail::SoundArchiveManager m_SoundArchiveManager; u32 m_SoundPlayerCount; @@ -189,7 +189,7 @@ class SoundArchivePlayer : SoundStartable { detail::WaveSoundRuntime m_WaveSoundRuntime; detail::AdvancedWaveSoundRuntime m_AdvancedWaveSoundRuntime; detail::StreamSoundRuntime m_StreamSoundRuntime; - std::size_t m_SoundUserParamSize; + size_t m_SoundUserParamSize; s32 m_ArchiveContainerCount; detail::AddonSoundArchiveContainer* m_pArchiveContainers; os::Tick m_AddonSoundArchiveLastAddTick; diff --git a/include/nn/atk/atk_SoundDataManager.h b/include/nn/atk/atk_SoundDataManager.h index 8bb7e1e9..1a086af5 100644 --- a/include/nn/atk/atk_SoundDataManager.h +++ b/include/nn/atk/atk_SoundDataManager.h @@ -1,7 +1,5 @@ #pragma once -#include - #include #include #include @@ -25,9 +23,9 @@ class SoundDataManager : detail::driver::DisposeCallback, detail::SoundArchiveLo SoundDataManager(); ~SoundDataManager() override; - std::size_t GetRequiredMemSize(const SoundArchive* arc); + size_t GetRequiredMemSize(const SoundArchive* arc) const; - bool Initialize(const SoundArchive* pArchive, void* buffer, std::size_t size); + bool Initialize(const SoundArchive* pArchive, void* buffer, size_t size); bool CreateTables(void**, const SoundArchive* pArchive, void*); @@ -45,10 +43,10 @@ class SoundDataManager : detail::driver::DisposeCallback, detail::SoundArchiveLo SoundArchive::FileId detail_GetFileIdFromTable(const void*) const; - bool SetFileAddressInGroupFile(const void*, std::size_t); - void ClearFileAddressInGroupFile(const void*, std::size_t); + bool SetFileAddressInGroupFile(const void*, size_t); + void ClearFileAddressInGroupFile(const void*, size_t); - void InvalidateSoundData(const void*, std::size_t); + void InvalidateSoundData(const void*, size_t); private: FileTable* m_pFileTable; diff --git a/include/nn/atk/atk_SoundHandle.h b/include/nn/atk/atk_SoundHandle.h index de85296c..3aac003e 100644 --- a/include/nn/atk/atk_SoundHandle.h +++ b/include/nn/atk/atk_SoundHandle.h @@ -23,12 +23,12 @@ class SoundHandle { ~SoundHandle() = default; - void DetachSound(); - void detail_DuplicateHandle(SoundHandle* other); - void detail_AttachSound(detail::BasicSound* sound); + void DetachSound(); + void detail_AttachSoundAsTempHandle(detail::BasicSound* sound); + void detail_AttachSound(detail::BasicSound* sound); void CalculateSoundParamCalculationValues(SoundParamCalculationValues* calcValues) const; diff --git a/include/nn/atk/atk_SoundPlayer.h b/include/nn/atk/atk_SoundPlayer.h index ad2c0d03..e2068ae5 100644 --- a/include/nn/atk/atk_SoundPlayer.h +++ b/include/nn/atk/atk_SoundPlayer.h @@ -38,15 +38,24 @@ class SoundPlayer { void detail_SortPriorityList(bool reverse); - f32 GetSend(s32 subMixBus); - void PauseAllSound(s32, bool); + void PauseAllSound(bool, s32); void PauseAllSound(bool, s32, PauseMode); void SetVolume(f32 volume); void SetLowPassFilterFrequency(f32 lpfFreq); void SetBiquadFilter(s32 biquadFilterType, f32 biquadFilterValue); void SetDefaultOutputLine(u32 line); + + void SetMainSend(f32 send); + f32 GetMainSend() const; + + void SetEffectSend(AuxBus bus, f32 send); + void GetEffectSend(AuxBus bus) const; + + void SetSend(s32 subMixBus, f32 send); + f32 GetSend(s32 subMixBus); + void SetOutputVolume(OutputDevice device, f32 volume); void RemoveSoundList(detail::BasicSound* pSound); @@ -64,7 +73,7 @@ class SoundPlayer { void detail_SetPlayableSoundLimit(s32 limit); bool detail_CanPlaySound(s32 startPriority); - bool CanPlaySound(s32); + bool CanPlaySound(s32 startPriority); void detail_AppendPlayerHeap(detail::PlayerHeap* pHeap); detail::PlayerHeap* detail_AllocPlayerHeap(); diff --git a/include/nn/atk/detail/dsp/atk_HardwareManager.h b/include/nn/atk/detail/dsp/atk_HardwareManager.h index 4a16daac..c5ce83df 100644 --- a/include/nn/atk/detail/dsp/atk_HardwareManager.h +++ b/include/nn/atk/detail/dsp/atk_HardwareManager.h @@ -210,10 +210,10 @@ class HardwareManager { // inherits nn::atk::Util::Singleton void SetAuxBusVolume(AuxBus bus, f32 volume, s32 fadeFrames, s32 subMixIndex); f32 GetAuxBusVolume(AuxBus bus, s32 subMixIndex) const; - void SetMainBusChannelVolumeForAdditionalEffect(f32 send, s32 srcChannel, s32 dstChannel); + void SetMainBusChannelVolumeForAdditionalEffect(f32 volume, s32 srcChannel, s32 dstChannel); f32 GetMainBusChannelVolumeForAdditionalEffect(s32 srcChannel, s32 dstChannel) const; - void SetAuxBusChannelVolumeForAdditionalEffect(AuxBus bus, f32 send, s32 srcChannel, s32 dstChannel); + void SetAuxBusChannelVolumeForAdditionalEffect(AuxBus bus, f32 volume, s32 srcChannel, s32 dstChannel); f32 GetAuxBusChannelVolumeForAdditionalEffect(AuxBus bus, s32 srcChannel, s32 dstChannel) const; static void FlushDataCache(void* address, size_t length); From 7791f0b45ea4e3081b337d5a92fdd034be680d08 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 19:56:34 -0300 Subject: [PATCH 170/785] atk: Cleanup and defined more methods of `SoundSystem` --- include/nn/atk/atk_SoundSystem.h | 191 ++++++++++++++++++------------- 1 file changed, 113 insertions(+), 78 deletions(-) diff --git a/include/nn/atk/atk_SoundSystem.h b/include/nn/atk/atk_SoundSystem.h index 9e28ebf9..b200a517 100644 --- a/include/nn/atk/atk_SoundSystem.h +++ b/include/nn/atk/atk_SoundSystem.h @@ -6,6 +6,10 @@ #include #include +#include +#include +#include +#include #include #include @@ -15,17 +19,17 @@ struct SoundSystem { static bool g_IsStreamLoadWait; static bool g_IsInitializedDriverCommandManager; - static std::uintptr_t g_LoadThreadStackPtr; - static std::size_t g_LoadThreadStackSize; + static uintptr_t g_LoadThreadStackPtr; + static size_t g_LoadThreadStackSize; - static std::uintptr_t g_SoundThreadStackPtr; - static std::size_t g_SoundThreadStackSize; + static uintptr_t g_SoundThreadStackPtr; + static size_t g_SoundThreadStackSize; - static std::uintptr_t g_PerformanceFrameBuffer; - static std::size_t g_PerformanceFrameBufferSize; + static uintptr_t g_PerformanceFrameBuffer; + static size_t g_PerformanceFrameBufferSize; - static std::size_t g_SoundThreadCommandBufferSize; - static std::size_t g_TaskThreadCommandBufferSize; + static size_t g_SoundThreadCommandBufferSize; + static size_t g_TaskThreadCommandBufferSize; static s32 g_RendererSampleRate; static s32 g_CustomSubMixSubMixCount; @@ -48,26 +52,28 @@ struct SoundSystem { static bool g_IsBusMixVolumeEnabled; static bool g_IsVolumeThroughModeEnabled; - const static s32 g_TaskThreadFsPriority; // = 1; - const static bool g_IsStreamOpenFailureHalt; // = true; - const static bool g_IsTaskThreadEnabled; // = true; - const static bool g_IsManagingMemoryPool; // = true; - const static u32 g_VoiceCountMax; // = 96; - const static u32 g_UserEffectCount; // = 10; - const static bool g_IsSubMixEnabled; // = true; - const static bool g_IsPresetSubMixEnabled; // = true; - const static bool g_IsStereoModeEnabled; // = true; - const static bool g_IsSoundThreadEnabled; // = true; - const static s32 g_BusCountMax; // = 4; + constexpr static s32 g_TaskThreadFsPriority = 1; + constexpr static bool g_IsStreamOpenFailureHalt = true; + constexpr static bool g_IsTaskThreadEnabled = true; + constexpr static bool g_IsManagingMemoryPool = true; + constexpr static u32 g_VoiceCountMax = 96; + constexpr static u32 g_UserEffectCount = 10; + constexpr static bool g_IsSubMixEnabled = true; + constexpr static bool g_IsPresetSubMixEnabled = true; + constexpr static bool g_IsStereoModeEnabled = true; + constexpr static bool g_IsSoundThreadEnabled = true; + constexpr static s32 g_BusCountMax = 4; struct SoundSystemParam { + SoundSystemParam(); + s32 soundThreadPriority{4}; - std::size_t soundThreadStackSize{0x4000}; - std::size_t soundThreadCommandBufferSize{0x20000}; - std::size_t voiceCommandBufferSize; + size_t soundThreadStackSize{0x4000}; + size_t soundThreadCommandBufferSize{0x20000}; + size_t voiceCommandBufferSize; s32 taskThreadPriority{3}; - std::size_t taskThreadStackSize{0x4000}; - std::size_t taskThreadCommandBufferSize{0x2000}; + size_t taskThreadStackSize{0x4000}; + size_t taskThreadCommandBufferSize{0x2000}; FsPriority taskThreadFsPriority{FsPriority_Normal}; bool enableNwRenderer{}; u32 nwVoiceSynthesizeBufferCount; @@ -105,47 +111,50 @@ struct SoundSystem { bool enableMemoryPoolAttachCheck{false}; bool enableBusMixVolume{false}; bool enableVolumeThroughMode{false}; - - SoundSystemParam(); }; static_assert(sizeof(SoundSystemParam) == 0x88); struct InitializeBufferSet { - std::uintptr_t workMem; - std::size_t workMemSize; - std::uintptr_t memoryPoolMem; - std::size_t memoryPoolMemSize; - std::uintptr_t circularBufferSinkMem; - std::size_t circularBufferSinkMemSize; + uintptr_t workMem; + size_t workMemSize; + uintptr_t memoryPoolMem; + size_t memoryPoolMemSize; + uintptr_t circularBufferSinkMem; + size_t circularBufferSinkMemSize; }; static_assert(sizeof(InitializeBufferSet) == 0x30); - static std::size_t GetRequiredMemSize(const SoundSystemParam& param); - static std::size_t GetRequiredMemSizeForCircularBufferSink(const SoundSystemParam& param); - static std::size_t GetRequiredMemSizeForMemoryPool(const SoundSystemParam& param); + static size_t GetRequiredMemSize(const SoundSystemParam& param); + static size_t GetRequiredMemSizeForCircularBufferSink(const SoundSystemParam& param); + static size_t GetRequiredMemSizeForMemoryPool(const SoundSystemParam& param); - static void SetupHardwareManagerParameter(class HardwareManagerParameter* pOutValue, SoundSystemParam* parameter); + static void SetupHardwareManagerParameter(detail::driver::HardwareManager::HardwareManagerParameter* pOutValue, + SoundSystemParam* parameter); static bool detail_InitializeSoundSystem(Result* pOutResult, const SoundSystemParam& param, const InitializeBufferSet& bufferSet); static void detail_InitializeDriverCommandManager(const SoundSystemParam& param, u64, u64, u64, u64); - static bool Initialize(SoundSystemParam* param, std::uintptr_t workMem, std::size_t workMemSize); - static bool Initialize(Result* pOutResult, const SoundSystemParam& param, std::uintptr_t workMem, std::size_t workMemSize); + static bool Initialize(SoundSystemParam* param, uintptr_t workMem, size_t workMemSize); + static bool Initialize(Result* pOutResult, const SoundSystemParam& param, + uintptr_t workMem, size_t workMemSize); - static void SetupInitializeBufferSet(InitializeBufferSet* pOutValue, SoundSystemParam* param, InitializeBufferSet* bufferSet); + static void SetupInitializeBufferSet(InitializeBufferSet* pOutValue, + SoundSystemParam* param, InitializeBufferSet* bufferSet); - static bool Initialize(SoundSystemParam* param, u64, u64, u64, u64); - static bool Initialize(Result* pOutResult, const SoundSystemParam& param, u64, u64, u64, u64); + static bool Initialize(SoundSystemParam* param, uintptr_t workMem, size_t workMemSize, + uintptr_t memoryPoolMem, size_t memoryPoolMemSize); + static bool Initialize(Result* pOutResult, const SoundSystemParam& param, uintptr_t workMem, + size_t workMemSize, uintptr_t memoryPoolMem, size_t memoryPoolMemSize); static bool Initialize(const SoundSystemParam& param, const InitializeBufferSet& bufferSet); static bool Initialize(Result* pOutResult, const SoundSystemParam& param, const InitializeBufferSet& bufferSet); static void Finalize(); - static void SetSoundThreadBeginUserCallback(void(*threadBeginUserCallback)(u64), std::uintptr_t threadBeginUserCallbackArg); + static void SetSoundThreadBeginUserCallback(void(*threadBeginUserCallback)(u64), uintptr_t threadBeginUserCallbackArg); static void ClearSoundThreadBeginUserCallback(); - static void SetSoundThreadEndUserCallback(void(*threadEndUserCallback)(u64), std::uintptr_t threadEndUserCallbackArg); + static void SetSoundThreadEndUserCallback(void(*threadEndUserCallback)(u64), uintptr_t threadEndUserCallbackArg); static void ClearSoundThreadEndUserCallback(); static bool IsInitialized(); @@ -153,61 +162,71 @@ struct SoundSystem { static void SuspendAudioRenderer(TimeSpan timeSpan); static void ResumeAudioRenderer(TimeSpan timeSpan); - static void AttachMemoryPool(audio::MemoryPoolType* pMemoryPool, void* address, std::size_t size); + static void ExecuteRendering(); + + static void AttachMemoryPool(audio::MemoryPoolType* pMemoryPool, void* address, size_t size); static void DetachMemoryPool(audio::MemoryPoolType* pMemoryPool); static void DumpMemory(); - static std::size_t GetAudioRendererBufferSize(); + static size_t GetAudioRendererBufferSize(); - // void SetupHardwareManagerParameterFromCurrentSetting(detail::driver::HardwareManager::HardwareManagerParameter* pHardwareManagerParameter); + static void SetupHardwareManagerParameterFromCurrentSetting(detail::driver::HardwareManager::HardwareManagerParameter* pHardwareManagerParameter); - static std::size_t GetRecorderBufferSize(); - static std::size_t GetUserCircularBufferSinkBufferSize(); - static std::size_t GetLowLevelVoiceAllocatorBufferSize(); - static std::size_t GetMultiVoiceManagerBufferSize(); - static std::size_t GetChannelManagerBufferSize(); - static std::size_t GetDriverCommandBufferSize(); - static std::size_t GetAllocatableDriverCommandSize(); - static std::size_t GetAllocatedDriverCommandBufferSize(); - static std::size_t GetAllocatedDriverCommandCount(); + static size_t GetRecorderBufferSize(); + static size_t GetUserCircularBufferSinkBufferSize(); + static size_t GetLowLevelVoiceAllocatorBufferSize(); + static size_t GetMultiVoiceManagerBufferSize(); + static size_t GetChannelManagerBufferSize(); + static size_t GetDriverCommandBufferSize(); + static size_t GetAllocatableDriverCommandSize(); + static size_t GetAllocatedDriverCommandBufferSize(); + static size_t GetAllocatedDriverCommandCount(); static void RegisterAudioRendererPerformanceReader(AudioRendererPerformanceReader& audioRendererPerformanceReader); - // static bool AppendEffect(AuxBus auxBus, EffectBase* pEffectBase, void*, u64); - // static bool AppendEffect(AuxBus auxBus, EffectBase* pEffectBase, void*, u64, OutputDevice); - // static bool AppendEffect(AuxBus auxBus, EffectBase* pEffectBase, void*, u64, OutputDevice, s32); + static bool AppendEffect(AuxBus auxBus, EffectBase* pEffectBase, + void* buffer, size_t bufferSize); + static bool AppendEffect(AuxBus auxBus, EffectBase* pEffectBase, + void* buffer, size_t bufferSize, OutputDevice device); + static bool AppendEffect(AuxBus auxBus, EffectBase* pEffectBase, + void* buffer, size_t bufferSize, OutputDevice device, s32 subMixNumber); - // static bool AppendEffect(AuxBus auxBus, EffectAux* pEffectAux, void*, u64); - // static bool AppendEffect(AuxBus auxBus, EffectAux* pEffectAux, void*, u64, OutputDevice); - // static bool AppendEffect(AuxBus auxBus, EffectAux* pEffectAux, void*, u64, OutputDevice, s32); + static bool AppendEffect(AuxBus auxBus, EffectAux* pEffectAux, + void* buffer, size_t bufferSize); + static bool AppendEffect(AuxBus auxBus, EffectAux* pEffectAux, + void* buffer, size_t bufferSize, OutputDevice device); + static bool AppendEffect(AuxBus auxBus, EffectAux* pEffectAux, + void* buffer, size_t bufferSize, OutputDevice device, s32 subMixNumber); - // static bool AppendEffectToFinalMix(EffectAux* pEffectAux, void*, u64); - // static bool AppendEffectToAdditionalSubMix(EffectAux* pEffectAux, void*, u64); + static bool AppendEffectToFinalMix(EffectAux* pEffectAux, void* buffer, size_t bufferSize); + static bool AppendEffectToAdditionalSubMix(EffectAux* pEffectAux, void* buffer, size_t bufferSize); - // static std::size_t GetRequiredEffectAuxBufferSize(EffectAux* pEffectAux); + static size_t GetRequiredEffectAuxBufferSize(const EffectAux* pEffectAux); - // static void RemoveEffect(AuxBus auxBus, EffectBase* pEffectBase); - // static void RemoveEffect(AuxBus auxBus, EffectBase* pEffectBase, OutputDevice outputDevice); - // static void RemoveEffect(AuxBus auxBus, EffectBase* pEffectBase, OutputDevice outputDevice, s32); + static void RemoveEffect(AuxBus auxBus, EffectBase* pEffectBase); + static void RemoveEffect(AuxBus auxBus, EffectBase* pEffectBase, OutputDevice outputDevice); + static void RemoveEffect(AuxBus auxBus, EffectBase* pEffectBase, OutputDevice outputDevice, + s32 subMixNumber); - // static void RemoveEffect(AuxBus auxBus, EffectAux* pEffectAux); - // static void RemoveEffect(AuxBus auxBus, EffectAux* pEffectAux, OutputDevice outputDevice); - // static void RemoveEffect(AuxBus auxBus, EffectAux* pEffectAux, OutputDevice outputDevice, s32); + static void RemoveEffect(AuxBus auxBus, EffectAux* pEffectAux); + static void RemoveEffect(AuxBus auxBus, EffectAux* pEffectAux, OutputDevice outputDevice); + static void RemoveEffect(AuxBus auxBus, EffectAux* pEffectAux, OutputDevice outputDevice, + s32 subMixNumber); - // static void RemoveEffectFromFinalMix(EffectAux* pEffectAux); - // static void RemoveEffectFromAdditionalSubMix(EffectAux* pEffectAux); + static void RemoveEffectFromFinalMix(EffectAux* pEffectAux); + static void RemoveEffectFromAdditionalSubMix(EffectAux* pEffectAux); static void ClearEffect(AuxBus auxBus); static void ClearEffect(AuxBus auxBus, OutputDevice outputDevice); - static void ClearEffect(AuxBus auxBus, OutputDevice outputDevice, s32); + static void ClearEffect(AuxBus auxBus, OutputDevice outputDevice, s32 subMixNumber); static void ClearEffectFromFinalMix(); static void ClearEffectFromAdditionalSubMix(); static bool IsClearEffectFinished(AuxBus auxBus); static bool IsClearEffectFinished(AuxBus auxBus, OutputDevice outputDevice); - static bool IsClearEffectFinished(AuxBus auxBus, OutputDevice outputDevice, s32); + static bool IsClearEffectFinished(AuxBus auxBus, OutputDevice outputDevice, s32 subMixNumber); static bool IsClearEffectFromFinalMixFinished(); static bool IsClearEffectFromAdditionalSubMixFinished(); @@ -216,27 +235,43 @@ struct SoundSystem { static void SetAuxBusVolume(AuxBus auxBus, f32 volume, TimeSpan timeSpan, s32); static f32 GetAuxBusVolume(AuxBus auxBus); - static f32 GetAuxBusVolume(AuxBus auxBus, s32); + static f32 GetAuxBusVolume(AuxBus auxBus, s32 subMixIndex); + + static void SetMainBusChannelVolumeForAdditionalEffect(f32 volume, s32 srcChannel, s32 dstChannel); + static f32 GetMainBusChannelVolumeForAdditionalEffect(s32 srcChannel, s32 dstChannel); + + static void SetAuxBusChannelVolumeForAdditionalEffect(AuxBus auxBus, f32 volume, s32 srcChannel, s32 dstChannel); + static f32 GetAuxBusChannelVolumeForAdditionalEffect(AuxBus auxBus, s32 srcChannel, s32 dstChannel); + + static void SetAllAuxBusChannelVolumeForAdditionalEffect(f32 volume, s32 srcChannel, s32 dstChannel); + static void SetAllBusChannelVolumeForAdditionalEffect(f32 volume, s32 srcChannel, s32 dstChannel); static void VoiceCommandProcess(UpdateType updateType, u32); static void VoiceCommandProcess(u32); static void VoiceCommandUpdate(); - static std::size_t GetPerformanceFrameBufferSize(); + static size_t GetPerformanceFrameBufferSize(); static s32 GetDroppedLowLevelVoiceCount(); static void RegisterSoundThreadUpdateProfileReader(AtkProfileReader&); static void UnregisterSoundThreadUpdateProfileReader(AtkProfileReader&); - static bool ReadCircularBufferSink(void*, u64); + static void RegisterSoundThreadInfoRecorder(detail::ThreadInfoRecorder&); + static void UnregisterSoundThreadInfoRecorder(detail::ThreadInfoRecorder&); - static std::size_t GetCircularBufferSinkBufferSize(); + static bool ReadCircularBufferSink(void* buffer, size_t bufferSize); + + static size_t GetCircularBufferSinkBufferSize(); static u32 GetRendererSampleCount(); static u32 GetRendererChannelCountMax(); + static void StopCircularBufferSink(); + static void StartCircularBufferSink(); + + static CircularBufferSinkState GetCircularBufferSinkState(); static detail::SoundInstanceConfig GetSoundInstanceConfig(); }; } // namespace nn::atk \ No newline at end of file From fbaf5080fafcedb109b9dcdc6c7073a3dde743a5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 22:07:56 -0300 Subject: [PATCH 171/785] atk: More cleanup and more missing methods --- CMakeLists.txt | 7 +-- include/nn/atk/atk_SoundArchive.h | 1 - include/nn/atk/atk_SoundPlayer.h | 1 - include/nn/atk/atk_SoundSystem.h | 2 +- include/nn/atk/atk_WaveSoundHandle.h | 27 ++++++++++ .../atk/detail/atk_AdvancedWaveSoundRuntime.h | 10 ++-- include/nn/atk/detail/atk_BasicSound.h | 52 +++++++++++++++---- include/nn/atk/detail/atk_BasicSoundPlayer.h | 1 - .../nn/atk/detail/atk_BusMixVolumePacket.h | 2 +- .../nn/atk/detail/atk_ExternalSoundPlayer.h | 2 + .../nn/atk/detail/atk_OutputAdditionalParam.h | 43 ++++++++++----- include/nn/atk/detail/atk_PlayerHeap.h | 3 ++ include/nn/atk/detail/atk_RegionManager.h | 2 +- .../nn/atk/detail/atk_SoundInstanceManager.h | 2 +- include/nn/atk/{ => detail/dsp}/atk_Adpcm.h | 0 .../dsp}/atk_BiquadFilterCallback.h | 4 +- .../nn/atk/detail/dsp/atk_HardwareManager.h | 2 +- .../atk/detail/strm/atk_StreamSoundLoader.h | 2 +- .../nn/atk/detail/thread/atk_SoundThread.h | 2 +- include/nn/atk/detail/util/atk_Util.h | 2 +- .../nn/atk/detail/voice/atk_LowLevelVoice.h | 4 +- include/nn/atk/detail/wsd/atk_WaveSound.h | 9 ++-- include/nn/atk/effect/atk_EffectAux.h | 2 +- include/nn/atk/effect/atk_EffectBase.h | 2 +- include/nn/atk/submix/atk_ChannelMixVolume.h | 4 +- include/nn/atk/util/atk_DeviceOutRecorder.h | 5 +- include/nn/atk/{ => util}/atk_Global.h | 2 +- 27 files changed, 135 insertions(+), 60 deletions(-) create mode 100644 include/nn/atk/atk_WaveSoundHandle.h rename include/nn/atk/{ => detail/dsp}/atk_Adpcm.h (100%) rename include/nn/atk/{ => detail/dsp}/atk_BiquadFilterCallback.h (84%) rename include/nn/atk/{ => util}/atk_Global.h (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec81104e..9d1c1623 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -245,10 +245,7 @@ add_library(NintendoSDK OBJECT include/nn/audio/audio_VoiceTypes.h include/nn/audio/audio_WaveBuffer.h - include/nn/atk/atk_Adpcm.h - include/nn/atk/atk_BiquadFilterCallback.h include/nn/atk/atk_FsSoundArchive.h - include/nn/atk/atk_Global.h include/nn/atk/atk_SequenceSoundHandle.h include/nn/atk/atk_SoundActor.h include/nn/atk/atk_SoundArchive.h @@ -261,6 +258,7 @@ add_library(NintendoSDK OBJECT include/nn/atk/atk_SoundStartable.h include/nn/atk/atk_SoundSystem.h include/nn/atk/atk_StreamSoundHandle.h + include/nn/atk/atk_WaveSoundHandle.h include/nn/atk/detail/atk_AddonSoundArchiveContainer.h include/nn/atk/detail/atk_AdvancedWaveSound.h include/nn/atk/detail/atk_AdvancedWaveSoundFile.h @@ -305,6 +303,8 @@ add_library(NintendoSDK OBJECT include/nn/atk/detail/atk_WaveFile.h include/nn/atk/detail/atk_WavOutFileStream.h include/nn/atk/detail/debug/atk_Debug.h + include/nn/atk/detail/dsp/atk_Adpcm.h + include/nn/atk/detail/dsp/atk_BiquadFilterCallback.h include/nn/atk/detail/dsp/atk_BiquadFilterPresets.h include/nn/atk/detail/dsp/atk_DspadpcmReader.h include/nn/atk/detail/dsp/atk_HardwareManager.h @@ -369,6 +369,7 @@ add_library(NintendoSDK OBJECT include/nn/atk/submix/atk_SubMix.h include/nn/atk/util/atk_AudioRendererPerformanceReader.h include/nn/atk/util/atk_DeviceOutRecorder.h + include/nn/atk/util/atk_Global.h include/nn/atk/util/atk_ProfileReader.h include/nn/atk/util/atk_TaskProfileReader.h include/nn/atk/fnd/basis/atkfnd_Config.h diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index b541edb4..6538b3a2 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include #include diff --git a/include/nn/atk/atk_SoundPlayer.h b/include/nn/atk/atk_SoundPlayer.h index e2068ae5..74dbc299 100644 --- a/include/nn/atk/atk_SoundPlayer.h +++ b/include/nn/atk/atk_SoundPlayer.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include diff --git a/include/nn/atk/atk_SoundSystem.h b/include/nn/atk/atk_SoundSystem.h index b200a517..c79032e5 100644 --- a/include/nn/atk/atk_SoundSystem.h +++ b/include/nn/atk/atk_SoundSystem.h @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/nn/atk/atk_WaveSoundHandle.h b/include/nn/atk/atk_WaveSoundHandle.h new file mode 100644 index 00000000..2d221b3b --- /dev/null +++ b/include/nn/atk/atk_WaveSoundHandle.h @@ -0,0 +1,27 @@ +#pragma once + +#include + +#include + +namespace nn::atk { +namespace detail { +class WaveSound; +} // namespace nn::atk::detail + +class WaveSoundHandle { +public: + using TrackBitFlagSet = util::BitFlagSet<8, void>; + + explicit WaveSoundHandle(SoundHandle* pSoundHandle); + + void detail_AttachSoundAsTempHandle(detail::WaveSound* pSound); + + void ForceStop(); + + void DetachSound(); + +private: + detail::WaveSound* m_pSound; +}; +} // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h b/include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h index 99197a1a..55129aa6 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h @@ -17,22 +17,24 @@ class AdvancedWaveSoundRuntime { void Initialize(s32 soundCount, void** pOutAllocatedAddr, const void* endAddr); void Finalize(); - static std::size_t GetRequiredMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, - std::size_t alignmentSize); - + static size_t GetRequiredMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, + size_t alignmentSize); s32 GetActiveCount() const; s32 GetFreeAdvancedWaveSoundCount() const; - void SetupUserParam(void** startAddr, std::size_t adjustSize); + void SetupUserParam(void** startAddr, size_t adjustSize); void Update(); +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) AdvancedWaveSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, BasicSound::AmbientInfo* ambientArgInfo); +#else AdvancedWaveSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, BasicSound::AmbientInfo* ambientArgInfo, OutputReceiver* pOutputReceiver); +#endif SoundStartable::StartResult PrepareImpl(const SoundArchive* pSoundArchive, const SoundDataManager* pSoundDataManager, diff --git a/include/nn/atk/detail/atk_BasicSound.h b/include/nn/atk/detail/atk_BasicSound.h index 601c9c18..7bbda1b5 100644 --- a/include/nn/atk/detail/atk_BasicSound.h +++ b/include/nn/atk/detail/atk_BasicSound.h @@ -7,6 +7,7 @@ #include #include #include +#include #include namespace nn::atk { @@ -241,9 +242,10 @@ class BasicSound { void ForceStop(); void Pause(bool, s32); void Pause(bool, s32, PauseMode pauseMode); + void Mute(bool, s32); - void SetAutoStopCounter(s32); + void SetAutoStopCounter(s32 autoStopCounter); void FadeIn(s32); @@ -259,6 +261,9 @@ class BasicSound { u32 CalculateOutLineFlag() const; void CalculateBiquadFilter(s32* pBiquadFilterType, f32* pBiquadFilterValue) const; void CalculateOutputParam(OutputParam*, OutputDevice) const; + void CalculateOutputBusMixVolume(OutputBusMixVolume*, OutputDevice) const; + + bool IsVolumeThroughModeUsed() const; void ApplyCommonParam(OutputParam&) const; @@ -299,9 +304,6 @@ class BasicSound { u32 GetOutputLine() const; void ResetOutputLine(); - void SetOutputAdditionalParamAddr(OutputDevice device, OutputAdditionalParam* addr, - OutputAdditionalParam* addrForPlayer); - void SetMixMode(MixMode mode); MixMode GetMixMode() const; @@ -317,34 +319,62 @@ class BasicSound { void SetFxSend(AuxBus auxBus, f32 fxSend); f32 GetFxSend(AuxBus auxBus) const; + void SetSend(s32, f32 send); + void SetOutputAdditionalSend(OutputDevice device, s32, f32 send); + + f32 GetSend(s32) const; + void GetOutputAdditionalSend(OutputDevice device, s32) const; + + void SetVolumeThroughMode(s32, u8); + void SetOutputVolumeThroughMode(OutputDevice device, s32, u8); + + void GetVolumeThroughMode(s32); + void GetOutputVolumeThroughMode(OutputDevice device, s32) const; + + s32 GetSendBusCount(); + s32 GetSendChannelCount(); + + void SetOutputAdditionalParamAddr(OutputDevice device, OutputAdditionalParam* addr, + OutputAdditionalParam* addrForPlayer); + void SetOutputVolume(OutputDevice device, f32 volume); + void SetOutputBusMixVolume(OutputDevice, u32, u32, ChannelMixVolume); void SetOutputChannelMixParameter(OutputDevice, u32, MixParameter); void SetOutputPan(OutputDevice device, f32 pan); void SetOutputSurroundPan(OutputDevice device, f32 surroundPan); void SetOutputMainSend(OutputDevice device, f32 mainSend); + void SetOutputFxSend(OutputDevice device, AuxBus auxBus, f32 fxSend); void SetOutputFxSend(OutputDevice device, f32 fxSend); + void SetOutputBusMixVolumeEnabled(OutputDevice device, s32, bool); f32 GetOutputVolume(OutputDevice device) const; - MixParameter GetOutputChannelMixParameter(OutputDevice, u32); + MixParameter GetOutputChannelMixParameter(OutputDevice, u32) const; f32 GetOutputPan(OutputDevice device) const; f32 GetOutputSurroundPan(OutputDevice device) const; f32 GetOutputMainSend(OutputDevice device) const; + f32 GetOutputFxSend(OutputDevice device, AuxBus auxBus) const; f32 GetOutputFxSend(OutputDevice device) const; + bool IsOutputBusMixVolumeEnabled(OutputDevice device, s32) const; + void GetOutputBusMixVolume(OutputDevice device, s32, s32) const; + void SetPanMode(PanMode mode); void SetPanCurve(PanCurve curve); void SetAmbientInfo(AmbientInfo* ambientArgInfo); - PanMode GetPanMode() const; - PanCurve GetPanCurve() const; - AmbientInfo* GetAmbientInfo() const; - static s32 GetAmbientPriority(const AmbientInfo& ambientInfo, u32 soundId); - + void SetSetupTick(const os::Tick& tick); - void SetSoundArchive(const SoundArchive* soundArchive); + PanMode GetPanMode() const; + PanCurve GetPanCurve() const; + AmbientInfo* GetAmbientInfo() const; + +private: + friend SoundPlayer; + friend ExternalSoundPlayer; + PlayerHeap* m_pPlayerHeap; SoundHandle* m_pGeneralHandle; SoundHandle* m_pTempGeneralHandle; diff --git a/include/nn/atk/detail/atk_BasicSoundPlayer.h b/include/nn/atk/detail/atk_BasicSoundPlayer.h index 911aa98c..ceca709a 100644 --- a/include/nn/atk/detail/atk_BasicSoundPlayer.h +++ b/include/nn/atk/detail/atk_BasicSoundPlayer.h @@ -2,7 +2,6 @@ #include -#include #include #include #include diff --git a/include/nn/atk/detail/atk_BusMixVolumePacket.h b/include/nn/atk/detail/atk_BusMixVolumePacket.h index b8486f4e..7c7e900b 100644 --- a/include/nn/atk/detail/atk_BusMixVolumePacket.h +++ b/include/nn/atk/detail/atk_BusMixVolumePacket.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { class BusMixVolumePacket { diff --git a/include/nn/atk/detail/atk_ExternalSoundPlayer.h b/include/nn/atk/detail/atk_ExternalSoundPlayer.h index 530c3977..c1220fc5 100644 --- a/include/nn/atk/detail/atk_ExternalSoundPlayer.h +++ b/include/nn/atk/detail/atk_ExternalSoundPlayer.h @@ -29,6 +29,8 @@ class ExternalSoundPlayer { void SetPlayableSoundCount(s32 count); + bool CanPlaySound(); + private: SoundList m_SoundList; s32 m_PlayableCount; diff --git a/include/nn/atk/detail/atk_OutputAdditionalParam.h b/include/nn/atk/detail/atk_OutputAdditionalParam.h index 081d9134..39cfefd6 100644 --- a/include/nn/atk/detail/atk_OutputAdditionalParam.h +++ b/include/nn/atk/detail/atk_OutputAdditionalParam.h @@ -11,34 +11,51 @@ using SendArray = ValueArray; class OutputAdditionalParam { public: - static std::size_t GetRequiredMemSize(SoundInstanceConfig* config); + static std::size_t GetRequiredMemSize(const SoundInstanceConfig& config); - void Initialize(void* buffer, std::size_t bufferSize, SoundInstanceConfig* config); + void Initialize(void* buffer, std::size_t bufferSize, const SoundInstanceConfig& config); + void Finalize(); void Reset(); void* GetBufferAddr(); SendArray* GetAdditionalSendAddr(); - f32 TryGetAdditionalSend(s32 bus); - bool IsAdditionalSendEnabled(); + SendArray* GetAdditionalSendAddr() const; + + f32 TryGetAdditionalSend(s32 bus) const; + + bool IsAdditionalSendEnabled() const; + void TrySetAdditionalSend(s32 bus, f32 send); BusMixVolumePacket* GetBusMixVolumePacketAddr(); - f32 GetBusMixVolume(s32 waveChannel, s32 mixChannel); - OutputBusMixVolume* GetBusMixVolume(); - void SetBusMixVolume(OutputBusMixVolume* param); - bool IsBusMixVolumeUsed(); + BusMixVolumePacket* GetBusMixVolumePacketAddr() const; + + f32 GetBusMixVolume(s32 waveChannel, s32 mixChannel) const; + OutputBusMixVolume* GetBusMixVolume() const; + + void SetBusMixVolume(s32 waveChannel, s32 mixChannel, f32 volume); + void SetBusMixVolume(const OutputBusMixVolume& param); + + bool IsBusMixVolumeUsed() const; void SetBusMixVolumeUsed(bool isUsed); - bool IsBusMixVolumeEnabledForBus(s32 bus); + + bool IsBusMixVolumeEnabledForBus(s32 bus) const; void SetBusMixVolumeEnabledForBus(s32 bus, bool isEnabled); - bool IsBusMixVolumeEnabled(); + + bool IsBusMixVolumeEnabled() const; VolumeThroughModePacket* GetVolumeThroughModePacketAddr(); - f32 GetBinaryVolume(); + VolumeThroughModePacket* GetVolumeThroughModePacketAddr() const; + + f32 GetBinaryVolume() const; void SetBinaryVolume(f32 volume); - u8 TryGetVolumeThroughMode(s32 bus); - bool IsVolumeThroughModeEnabled(); + + u8 TryGetVolumeThroughMode(s32 bus) const; + void TrySetVolumeThroughMode(s32 bus, u8 volumeThroughMode); + bool IsVolumeThroughModeEnabled() const; + bool IsVolumeThroughModeUsed(); void SetVolumeThroughModeUsed(bool isUsed); diff --git a/include/nn/atk/detail/atk_PlayerHeap.h b/include/nn/atk/detail/atk_PlayerHeap.h index dcea5c80..61921eb0 100644 --- a/include/nn/atk/detail/atk_PlayerHeap.h +++ b/include/nn/atk/detail/atk_PlayerHeap.h @@ -28,7 +28,10 @@ class PlayerHeap : SoundMemoryAllocatable { PlayerHeap(); ~PlayerHeap() override; + void Destroy(); + bool Create(void* startAddress, std::size_t size); + void Clear(); void* Allocate(std::size_t size) override; diff --git a/include/nn/atk/detail/atk_RegionManager.h b/include/nn/atk/detail/atk_RegionManager.h index e88d5d8f..eb0d9f67 100644 --- a/include/nn/atk/detail/atk_RegionManager.h +++ b/include/nn/atk/detail/atk_RegionManager.h @@ -2,9 +2,9 @@ #include -#include #include #include +#include namespace nn::atk { enum StreamRegionCallbackResult { diff --git a/include/nn/atk/detail/atk_SoundInstanceManager.h b/include/nn/atk/detail/atk_SoundInstanceManager.h index 49fa6bbc..a13d2a8f 100644 --- a/include/nn/atk/detail/atk_SoundInstanceManager.h +++ b/include/nn/atk/detail/atk_SoundInstanceManager.h @@ -2,7 +2,7 @@ #include -#include +#include #include namespace nn::atk::detail { diff --git a/include/nn/atk/atk_Adpcm.h b/include/nn/atk/detail/dsp/atk_Adpcm.h similarity index 100% rename from include/nn/atk/atk_Adpcm.h rename to include/nn/atk/detail/dsp/atk_Adpcm.h diff --git a/include/nn/atk/atk_BiquadFilterCallback.h b/include/nn/atk/detail/dsp/atk_BiquadFilterCallback.h similarity index 84% rename from include/nn/atk/atk_BiquadFilterCallback.h rename to include/nn/atk/detail/dsp/atk_BiquadFilterCallback.h index c97efed5..65751258 100644 --- a/include/nn/atk/atk_BiquadFilterCallback.h +++ b/include/nn/atk/detail/dsp/atk_BiquadFilterCallback.h @@ -1,8 +1,6 @@ #pragma once -#include - -#include +#include namespace nn::atk { class BiquadFilterCallback { diff --git a/include/nn/atk/detail/dsp/atk_HardwareManager.h b/include/nn/atk/detail/dsp/atk_HardwareManager.h index c5ce83df..4855ca11 100644 --- a/include/nn/atk/detail/dsp/atk_HardwareManager.h +++ b/include/nn/atk/detail/dsp/atk_HardwareManager.h @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/nn/atk/detail/strm/atk_StreamSoundLoader.h b/include/nn/atk/detail/strm/atk_StreamSoundLoader.h index d01c2e42..d50fbbd6 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundLoader.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundLoader.h @@ -1,11 +1,11 @@ #pragma once -#include #include #include #include #include #include +#include #include #include #include diff --git a/include/nn/atk/detail/thread/atk_SoundThread.h b/include/nn/atk/detail/thread/atk_SoundThread.h index f1585588..bd50ed3b 100644 --- a/include/nn/atk/detail/thread/atk_SoundThread.h +++ b/include/nn/atk/detail/thread/atk_SoundThread.h @@ -5,10 +5,10 @@ #include #include -#include #include #include #include +#include #include #include diff --git a/include/nn/atk/detail/util/atk_Util.h b/include/nn/atk/detail/util/atk_Util.h index 515b971d..0c195a41 100644 --- a/include/nn/atk/detail/util/atk_Util.h +++ b/include/nn/atk/detail/util/atk_Util.h @@ -2,7 +2,7 @@ #include -#include +#include #include namespace nn::atk { diff --git a/include/nn/atk/detail/voice/atk_LowLevelVoice.h b/include/nn/atk/detail/voice/atk_LowLevelVoice.h index 8940e09f..87320cc5 100644 --- a/include/nn/atk/detail/voice/atk_LowLevelVoice.h +++ b/include/nn/atk/detail/voice/atk_LowLevelVoice.h @@ -5,10 +5,10 @@ #include #include -#include -#include #include +#include #include +#include namespace nn::atk::detail { class Voice; diff --git a/include/nn/atk/detail/wsd/atk_WaveSound.h b/include/nn/atk/detail/wsd/atk_WaveSound.h index e71be46e..151f6cec 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSound.h +++ b/include/nn/atk/detail/wsd/atk_WaveSound.h @@ -1,13 +1,11 @@ #pragma once +#include #include #include #include -namespace nn::atk { -class WaveSoundHandle; - -namespace detail { +namespace nn::atk::detail { class WaveSound; using WaveSoundInstanceManager = SoundInstanceManager; @@ -63,5 +61,4 @@ class WaveSound : BasicSound { driver::WaveSoundPlayer m_PlayerInstance; }; static_assert(sizeof(WaveSound) == 0x3e0); -} // namespace nn::atk::detail -} // namespace nn::atk \ No newline at end of file +} // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/effect/atk_EffectAux.h b/include/nn/atk/effect/atk_EffectAux.h index 5c46ca7b..814b4587 100644 --- a/include/nn/atk/effect/atk_EffectAux.h +++ b/include/nn/atk/effect/atk_EffectAux.h @@ -8,7 +8,7 @@ #include #include -#include +#include namespace nn::atk { class OutputMixer; diff --git a/include/nn/atk/effect/atk_EffectBase.h b/include/nn/atk/effect/atk_EffectBase.h index 42ae92bc..379b1a46 100644 --- a/include/nn/atk/effect/atk_EffectBase.h +++ b/include/nn/atk/effect/atk_EffectBase.h @@ -5,7 +5,7 @@ #include #include -#include +#include namespace nn::atk { class OutputMixer; diff --git a/include/nn/atk/submix/atk_ChannelMixVolume.h b/include/nn/atk/submix/atk_ChannelMixVolume.h index 436b239e..e588b46d 100644 --- a/include/nn/atk/submix/atk_ChannelMixVolume.h +++ b/include/nn/atk/submix/atk_ChannelMixVolume.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk { class ChannelMixVolume { @@ -24,5 +24,5 @@ class ChannelMixVolume { s32 m_ChannelCount; f32 m_ChannelVolume[ChannelCountMax]; }; -static_assert(sizeof(ChannelMixVolume) == 4 + ChannelMixVolume::ChannelCountMax * sizeof(f32)); +static_assert(sizeof(ChannelMixVolume) == 0x64); } // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/util/atk_DeviceOutRecorder.h b/include/nn/atk/util/atk_DeviceOutRecorder.h index 9aad63ba..daeed1b8 100644 --- a/include/nn/atk/util/atk_DeviceOutRecorder.h +++ b/include/nn/atk/util/atk_DeviceOutRecorder.h @@ -1,13 +1,14 @@ #pragma once #include + #include #include #include -#include #include #include +#include namespace nn::atk { class DeviceOutRecorder : detail::fnd::Thread::Handler { @@ -142,5 +143,5 @@ class DeviceOutRecorder : detail::fnd::Thread::Handler { util::BytePtr m_WorkBuffer; u32 m_WriteBlockPerSamples; }; -static_assert(sizeof(DeviceOutRecorder) == 0x310);; +static_assert(sizeof(DeviceOutRecorder) == 0x310); } // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/util/atk_Global.h similarity index 99% rename from include/nn/atk/atk_Global.h rename to include/nn/atk/util/atk_Global.h index c633a8cb..2bd9db6a 100644 --- a/include/nn/atk/atk_Global.h +++ b/include/nn/atk/util/atk_Global.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include namespace nn::atk { enum WaveType { From 5e595ba9869c16251388bc40f827f70e4b726228 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 1 Mar 2026 22:08:22 -0300 Subject: [PATCH 172/785] atk: Fully define `detail::SoundArchiveFile` --- include/nn/atk/detail/atk_SoundArchiveFile.h | 326 ++++++++++++++++++- 1 file changed, 318 insertions(+), 8 deletions(-) diff --git a/include/nn/atk/detail/atk_SoundArchiveFile.h b/include/nn/atk/detail/atk_SoundArchiveFile.h index cb170a30..558ee2c3 100644 --- a/include/nn/atk/detail/atk_SoundArchiveFile.h +++ b/include/nn/atk/detail/atk_SoundArchiveFile.h @@ -1,5 +1,6 @@ #pragma once +#include #include namespace nn::atk::detail { @@ -8,25 +9,101 @@ struct SoundArchiveParametersHook; class SoundArchiveFile { public: struct FileHeader : BinaryFileHeader { - Util::ReferenceWithSize toBlocks[3]; - Util::ReferenceWithSize* GetReferenceBy(u16); + Util::ReferenceWithSize* GetReferenceBy(u16) const; + + u32 GetStringBlockSize() const; + u32 GetInfoBlockSize() const; + u32 GetFileBlockSize() const; - u32 GetStringBlockSize(); - u32 GetInfoBlockSize(); - u32 GetFileBlockSize(); + s32 GetStringBlockOffset() const; + s32 GetInfoBlockOffset() const; + s32 GetFileBlockOffset() const; - s32 GetStringBlockOffset(); - s32 GetInfoBlockOffset(); - s32 GetFileBlockOffset(); + Util::ReferenceWithSize toBlocks[3]; }; static_assert(sizeof(FileHeader) == 0x38); struct StringBlockBody { + enum Sections { + Sections_StringTable, + Sections_PatriciaTree, + Sections_Max, + }; + + void* GetSection(Sections section) const; + char* GetString(u32) const; + u32 GetItemIdImpl(Sections section, char* str) const; + + void DumpTree() const; + Util::Reference toSection[1]; }; + struct StringBlock { + BinaryBlockHeader header; + StringBlockBody body; + }; + + struct PatriciaTree { + struct NodeData { + u32 stringId; + u32 itemId; + }; + static_assert(sizeof(NodeData) == 0x8); + + struct Node { + u16 flags; + u16 bit; + u32 leftIdx; + u32 rightIdx; + NodeData nodeData; + }; + static_assert(sizeof(Node) == 0x14); + + void* GetNodeDataBy(const char*, u64); + + u32 rootIdx; + Util::Table nodeTable; + }; + + struct SoundInfo; + struct BankInfo; + struct PlayerInfo; + struct SoundGroupInfo; + struct GroupInfo; + struct WaveArchiveInfo; + struct FileInfo; + struct SoundArchivePlayerInfo; struct InfoBlockBody { + + SoundInfo* GetSoundInfo(SoundArchive::ItemId itemId) const; + Util::ReferenceTable* GetSoundInfoReferenceTable() const; + + BankInfo* GetBankInfo(SoundArchive::ItemId itemId) const; + Util::ReferenceTable* GetBankInfoReferenceTable() const; + + PlayerInfo* GetPlayerInfo(SoundArchive::ItemId itemId) const; + Util::ReferenceTable* GetPlayerInfoReferenceTable() const; + + SoundGroupInfo* GetSoundGroupInfo(SoundArchive::ItemId itemId) const; + Util::ReferenceTable* GetSoundGroupInfoReferenceTable() const; + + GroupInfo* GetGroupInfo(SoundArchive::ItemId itemId) const; + Util::ReferenceTable* GetGroupInfoReferenceTable() const; + + WaveArchiveInfo* GetWaveArchiveInfo(SoundArchive::ItemId itemId) const; + Util::ReferenceTable* GetWaveArchiveInfoReferenceTable() const; + + FileInfo* GetFileInfo(SoundArchive::FileId itemId) const; + Util::ReferenceTable* GetFileInfoReferenceTable() const; + + SoundArchive::FileId GetItemFileId(SoundArchive::ItemId id) const; + SoundArchive::FileId GetItemPrefetchFileId(SoundArchive::ItemId id) const; + SoundArchive::StringId GetItemStringId(SoundArchive::ItemId id) const; + + SoundArchivePlayerInfo* GetSoundArchivePlayerInfo() const; + Util::Reference toSoundInfoReferenceTable; Util::Reference toSoundGroupInfoReferenceTable; Util::Reference toBankInfoReferenceTable; @@ -37,5 +114,238 @@ class SoundArchiveFile { Util::Reference toSoundArchivePlayerInfo; }; static_assert(sizeof(InfoBlockBody) == 0x40); + + struct InfoBlock { + BinaryBlockHeader header; + InfoBlockBody body; + }; + static_assert(sizeof(InfoBlock) == 0x48); + + struct StreamSoundInfo; + struct WaveSoundInfo; + struct AdvancedWaveSoundInfo; + struct SequenceSoundInfo; + struct Sound3DInfo; + struct SoundInfo { + + SoundArchive::SoundType GetSoundType() const; + StreamSoundInfo* GetStreamSoundInfo() const; + + SoundArchive::StringId GetStringId() const; + + WaveSoundInfo* GetWaveSoundInfo() const; + AdvancedWaveSoundInfo* GetAdvancedWaveSoundInfo() const; + SequenceSoundInfo* GetSequenceSoundInfo() const; + Sound3DInfo* GetSound3DInfo() const; + + PanMode GetPanMode() const; + PanCurve GetPanCurve() const; + SinglePlayType GetSinglePlayType() const; + u16 GetSinglePlayEffectiveDuration() const; + u8 GetPlayerPriority() const; + u8 GetActorPlayerId() const; + u32 GetUserParam() const; + + bool ReadUserParam(u32*, s32) const; + + bool IsFrontBypass() const; + + u32 fileId; + u32 playerId; + u8 volume; + u8 remoteFilter; + u8 padding[2]; + Util::Reference toDetailSoundInfo; + Util::BitFlag optionParameter; + }; + static_assert(sizeof(SoundInfo) == 0x18); + + struct StreamTrackInfo { + u8 volume; + u8 pan; + u8 span; + u8 flags; + Util::Reference toGlobalChannelIndexTable; + Util::Reference toSendValue; + u8 lpfFreq; + u8 biquadType; + u8 biquadValue; + u8 padding[1]; + }; + static_assert(sizeof(StreamTrackInfo) == 0x18); + + struct StreamTrackInfoTable { + Util::ReferenceTable table; + }; + + struct StreamSoundExtension { + u32 streamTypeInfo; + u32 loopStartFrame; + u32 loopEndFrame; + }; + static_assert(sizeof(StreamSoundExtension) == 0xc); + + struct SendValue { + u8 mainSend; + u8 fxSend[3]; + }; + static_assert(sizeof(SendValue) == 0x4); + + struct StreamSoundInfo { + + StreamTrackInfoTable* GetTrackInfoTable() const; + StreamSoundExtension* GetStreamSoundExtension() const; + SendValue* GetSendValue() const; + + u16 allocateTrackFlags; + u16 allocateChannelCount; + Util::Reference toTrackInfoTable; + f32 pitch; + Util::Reference toSendValue; + Util::Reference toStreamSoundExtension; + u32 prefetchFileId; + }; + static_assert(sizeof(StreamSoundInfo) == 0x24); + + struct WaveSoundInfo { + + u8 GetChannelPriority() const; + u8 GetIsReleasePriorityFix() const; + + u32 index; + u32 allocateTrackCount; + Util::BitFlag optionParameter; + }; + static_assert(sizeof(WaveSoundInfo) == 0xc); + + struct AdvancedWaveSoundInfo { + u32 waveArchiveId; + }; + static_assert(sizeof(AdvancedWaveSoundInfo) == 0x4); + + struct SequenceSoundInfo { + + Util::ReferenceTable* GetBankIdTable() const; + void GetBankIds(u32* bankIds) const; + u32 GetStartOffset() const; + u8 GetChannelPriority() const; + + bool IsReleasePriorityFix() const; + + Util::Reference toBankIdTable; + u32 allocateTrackFlags; + Util::BitFlag optionParameter; + }; + static_assert(sizeof(SequenceSoundInfo) == 0x10); + + struct Sound3DInfo { + u32 flags; + f32 decayRatio; + u8 decayCurve; + u8 dopplerFactor; + u8 padding[2]; + Util::BitFlag optionParameter; + }; + static_assert(sizeof(Sound3DInfo) == 0x10); + + struct BankInfo { + + SoundArchive::StringId GetStringId() const; + + u32 fileId; + Util::Reference toWaveArchiveItemIdTable; + Util::BitFlag optionParameter; + }; + static_assert(sizeof(BankInfo) == 0x10); + + struct PlayerInfo { + + SoundArchive::StringId GetStringId() const; + u32 GetPlayerHeapSize() const; + + u32 playableSoundMax; + Util::BitFlag optionParameter; + }; + static_assert(sizeof(PlayerInfo) == 0x8); + + struct SoundGroupInfo { + + SoundArchive::StringId GetStringId() const; + + u32 startId; + u32 endId; + Util::Reference toFileIdTable; + Util::Reference toDetailSoundGroupInfo; + Util::BitFlag optionParameter; + }; + static_assert(sizeof(SoundGroupInfo) == 0x1c); + + struct GroupInfo { + + SoundArchive::StringId GetStringId() const; + + u32 fileId; + Util::BitFlag optionParameter; + }; + static_assert(sizeof(GroupInfo) == 0x8); + + struct WaveArchiveInfo { + + SoundArchive::StringId GetStringId() const; + u32 GetWaveCount() const; + + u32 fileId; + bool isLoadIndividual; + u8 padding[3]; + Util::BitFlag optionParameter; + }; + static_assert(sizeof(WaveArchiveInfo) == 0xc); + + struct SoundArchivePlayerInfo { + u16 sequenceSoundCount; + u16 sequenceTrackCount; + u16 streamSoundCount; + u16 streamTrackCount; + u16 streamChannelCount; + u16 waveSoundCount; + u16 waveTrackCount; + u8 streamBufferTimes; + u8 developFlags; + u32 options; + }; + static_assert(sizeof(SoundArchivePlayerInfo) == 0x14); + + struct WaveSoundGroupInfo { + Util::Reference toWaveArchiveItemIdTable; + Util::BitFlag optionParameter; + }; + static_assert(sizeof(WaveSoundGroupInfo) == 0xc); + + enum FileLocationType { + FileLocationType_Internal, + FileLocationType_External, + FileLocationType_None, + }; + + struct InternalFileInfo { + Util::ReferenceWithSize toFileImageFromFileBlockBody; + Util::Reference toAttachedGroupIdTable; + }; + static_assert(sizeof(InternalFileInfo) == 0x14); + + struct ExternalFileInfo { + char filePath[1]; + }; + + struct FileInfo { + + FileLocationType GetFileLocationType() const; + InternalFileInfo* GetInternalFileInfo() const; + ExternalFileInfo* GetExternalFileInfo() const; + + Util::Reference toFileLocation; + Util::BitFlag optionParameter; + }; + static_assert(sizeof(FileInfo) == 0xc); }; } // namespace nn::atk::detail \ No newline at end of file From 5a22432445be7778fba1bc8cf77c07b4db776c73 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 2 Mar 2026 17:54:07 -0300 Subject: [PATCH 173/785] atk: More cleanup Defined more methods that were missing, static variables and fixed some signatures. Also added macro checks for the nnSdk version for files that might need it. --- CMakeLists.txt | 16 +-- include/nn/atk/{detail/dsp => }/atk_Adpcm.h | 0 .../dsp => }/atk_BiquadFilterCallback.h | 2 +- include/nn/atk/atk_FsSoundArchive.h | 4 +- include/nn/atk/{util => }/atk_Global.h | 15 ++- include/nn/atk/atk_SoundArchive.h | 3 + include/nn/atk/atk_SoundArchivePlayer.h | 8 ++ include/nn/atk/atk_SoundPlayer.h | 8 ++ include/nn/atk/atk_SoundStartable.h | 2 + include/nn/atk/atk_SoundSystem.h | 24 ++++- .../detail/atk_AddonSoundArchiveContainer.h | 4 +- include/nn/atk/detail/atk_AdvancedWaveSound.h | 5 + .../nn/atk/detail/atk_AdvancedWaveSoundFile.h | 8 +- .../detail/atk_AdvancedWaveSoundFileReader.h | 8 +- .../atk/detail/atk_AdvancedWaveSoundPlayer.h | 12 ++- include/nn/atk/detail/atk_BasicSound.h | 9 ++ include/nn/atk/detail/atk_BasicSoundPlayer.h | 10 ++ .../nn/atk/detail/atk_BusMixVolumePacket.h | 3 +- include/nn/atk/detail/atk_GroupFile.h | 11 +- include/nn/atk/detail/atk_NoteOnCallback.h | 6 ++ .../nn/atk/detail/atk_PlayerHeapDataManager.h | 4 +- include/nn/atk/detail/atk_RegionManager.h | 7 +- include/nn/atk/detail/atk_SoundArchiveFile.h | 9 +- .../atk/detail/atk_SoundArchiveFileReader.h | 85 ++++++++++----- .../nn/atk/detail/atk_SoundArchiveLoader.h | 100 +++++++++++------- .../nn/atk/detail/atk_SoundArchiveManager.h | 3 +- .../nn/atk/detail/atk_SoundInstanceManager.h | 7 +- include/nn/atk/detail/atk_StartInfoReader.h | 6 ++ .../atk/detail/atk_VolumeThroughModePacket.h | 2 + include/nn/atk/detail/atk_WaveArchiveFile.h | 20 +++- .../nn/atk/detail/atk_WaveArchiveFileReader.h | 2 +- include/nn/atk/detail/atk_WaveFile.h | 15 +-- include/nn/atk/detail/atk_WaveFileReader.h | 2 +- .../atk/detail/dsp/atk_BiquadFilterPresets.h | 30 ++++-- .../nn/atk/detail/dsp/atk_DspadpcmReader.h | 2 +- .../nn/atk/detail/dsp/atk_HardwareManager.h | 5 +- include/nn/atk/detail/seq/atk_BankFile.h | 18 ++-- include/nn/atk/detail/seq/atk_MmlParser.h | 9 ++ include/nn/atk/detail/seq/atk_SequenceSound.h | 15 ++- .../nn/atk/detail/seq/atk_SequenceSoundFile.h | 8 +- .../detail/seq/atk_SequenceSoundFileReader.h | 2 +- .../atk/detail/seq/atk_SequenceSoundPlayer.h | 34 ++++-- .../atk/detail/seq/atk_SequenceSoundRuntime.h | 13 ++- include/nn/atk/detail/seq/atk_SequenceTrack.h | 25 ++++- .../nn/atk/detail/strm/atk_StreamBufferPool.h | 2 +- include/nn/atk/detail/strm/atk_StreamSound.h | 8 +- .../nn/atk/detail/strm/atk_StreamSoundFile.h | 37 ++++--- .../detail/strm/atk_StreamSoundFileReader.h | 9 +- .../atk/detail/strm/atk_StreamSoundLoader.h | 26 ++++- .../atk/detail/strm/atk_StreamSoundPlayer.h | 4 + .../detail/strm/atk_StreamSoundPrefetchFile.h | 23 ++-- .../strm/atk_StreamSoundPrefetchFileReader.h | 1 + .../atk/detail/strm/atk_StreamSoundRuntime.h | 7 +- .../nn/atk/detail/thread/atk_DriverCommand.h | 20 ++++ .../nn/atk/detail/thread/atk_SoundThread.h | 14 ++- .../nn/atk/detail/thread/atk_TaskManager.h | 7 +- .../detail/{ => util}/atk_BinaryFileFormat.h | 0 .../atk/detail/{ => util}/atk_BinaryTypes.h | 0 include/nn/atk/detail/util/atk_CurveLfo.h | 17 ++- include/nn/atk/detail/util/atk_FrameHeap.h | 2 + include/nn/atk/detail/util/atk_Util.h | 89 ++++++++++++---- .../nn/atk/detail/{ => util}/atk_WavBinary.h | 0 .../detail/{ => util}/atk_WavOutFileStream.h | 0 include/nn/atk/detail/voice/atk_Channel.h | 4 + .../nn/atk/detail/voice/atk_ChannelManager.h | 8 +- .../nn/atk/detail/voice/atk_LowLevelVoice.h | 21 +++- include/nn/atk/detail/voice/atk_MultiVoice.h | 59 +++++++---- include/nn/atk/detail/voice/atk_Voice.h | 20 ++-- .../{thread => voice}/atk_VoiceCommand.h | 8 ++ include/nn/atk/detail/wsd/atk_WaveSound.h | 4 + include/nn/atk/detail/wsd/atk_WaveSoundFile.h | 78 +++++++++----- .../atk/detail/wsd/atk_WaveSoundFileReader.h | 2 + .../nn/atk/detail/wsd/atk_WaveSoundPlayer.h | 8 +- .../nn/atk/detail/wsd/atk_WaveSoundRuntime.h | 3 + include/nn/atk/effect/atk_EffectAux.h | 25 +++-- include/nn/atk/effect/atk_EffectBase.h | 11 +- include/nn/atk/fnd/basis/atkfnd_HeapBase.h | 6 +- include/nn/atk/fnd/basis/atkfnd_Time.h | 10 +- include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h | 16 +-- include/nn/atk/fnd/io/atkfnd_StreamCache.h | 4 +- include/nn/atk/fnd/os/atkfnd_Thread.h | 17 ++- include/nn/atk/submix/atk_ChannelMixVolume.h | 3 +- include/nn/atk/submix/atk_SubMix.h | 29 ++--- .../util/atk_AudioRendererPerformanceReader.h | 2 +- include/nn/atk/util/atk_DeviceOutRecorder.h | 7 +- include/nn/atk/util/atk_TaskProfileReader.h | 24 +++-- 86 files changed, 883 insertions(+), 333 deletions(-) rename include/nn/atk/{detail/dsp => }/atk_Adpcm.h (100%) rename include/nn/atk/{detail/dsp => }/atk_BiquadFilterCallback.h (89%) rename include/nn/atk/{util => }/atk_Global.h (94%) rename include/nn/atk/detail/{ => util}/atk_BinaryFileFormat.h (100%) rename include/nn/atk/detail/{ => util}/atk_BinaryTypes.h (100%) rename include/nn/atk/detail/{ => util}/atk_WavBinary.h (100%) rename include/nn/atk/detail/{ => util}/atk_WavOutFileStream.h (100%) rename include/nn/atk/detail/{thread => voice}/atk_VoiceCommand.h (92%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d1c1623..83e5dc80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -245,7 +245,10 @@ add_library(NintendoSDK OBJECT include/nn/audio/audio_VoiceTypes.h include/nn/audio/audio_WaveBuffer.h + include/nn/atk/atk_Adpcm.h + include/nn/atk/atk_BiquadFilterCallback.h include/nn/atk/atk_FsSoundArchive.h + include/nn/atk/atk_Global.h include/nn/atk/atk_SequenceSoundHandle.h include/nn/atk/atk_SoundActor.h include/nn/atk/atk_SoundArchive.h @@ -267,8 +270,6 @@ add_library(NintendoSDK OBJECT include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h include/nn/atk/detail/atk_BasicSound.h include/nn/atk/detail/atk_BasicSoundPlayer.h - include/nn/atk/detail/atk_BinaryFileFormat.h - include/nn/atk/detail/atk_BinaryTypes.h include/nn/atk/detail/atk_BusMixVolumePacket.h include/nn/atk/detail/atk_Config.h include/nn/atk/detail/atk_DisposeCallback.h @@ -297,14 +298,10 @@ add_library(NintendoSDK OBJECT include/nn/atk/detail/atk_StartInfoReader.h include/nn/atk/detail/atk_ValueArray.h include/nn/atk/detail/atk_VolumeThroughModePacket.h - include/nn/atk/detail/atk_WavBinary.h include/nn/atk/detail/atk_WaveArchiveFile.h include/nn/atk/detail/atk_WaveArchiveFileReader.h include/nn/atk/detail/atk_WaveFile.h - include/nn/atk/detail/atk_WavOutFileStream.h include/nn/atk/detail/debug/atk_Debug.h - include/nn/atk/detail/dsp/atk_Adpcm.h - include/nn/atk/detail/dsp/atk_BiquadFilterCallback.h include/nn/atk/detail/dsp/atk_BiquadFilterPresets.h include/nn/atk/detail/dsp/atk_DspadpcmReader.h include/nn/atk/detail/dsp/atk_HardwareManager.h @@ -341,19 +338,23 @@ add_library(NintendoSDK OBJECT include/nn/atk/detail/thread/atk_TaskManager.h include/nn/atk/detail/thread/atk_TaskThread.h include/nn/atk/detail/thread/atk_ThreadInfoReader.h - include/nn/atk/detail/thread/atk_VoiceCommand.h include/nn/atk/detail/util/atk_CurveAdshr.h + include/nn/atk/detail/util/atk_BinaryFileFormat.h + include/nn/atk/detail/util/atk_BinaryTypes.h include/nn/atk/detail/util/atk_CurveLfo.h include/nn/atk/detail/util/atk_FrameHeap.h include/nn/atk/detail/util/atk_InstancePool.h include/nn/atk/detail/util/atk_MemoryFileStream.h include/nn/atk/detail/util/atk_Util.h + include/nn/atk/detail/util/atk_WavBinary.h + include/nn/atk/detail/util/atk_WavOutFileStream.h include/nn/atk/detail/voice/atk_Channel.h include/nn/atk/detail/voice/atk_ChannelManager.h include/nn/atk/detail/voice/atk_LowLevelVoice.h include/nn/atk/detail/voice/atk_MultiVoice.h include/nn/atk/detail/voice/atk_MultiVoiceManager.h include/nn/atk/detail/voice/atk_Voice.h + include/nn/atk/detail/voice/atk_VoiceCommand.h include/nn/atk/detail/wsd/atk_WaveSound.h include/nn/atk/detail/wsd/atk_WaveSoundFile.h include/nn/atk/detail/wsd/atk_WaveSoundFileReader.h @@ -369,7 +370,6 @@ add_library(NintendoSDK OBJECT include/nn/atk/submix/atk_SubMix.h include/nn/atk/util/atk_AudioRendererPerformanceReader.h include/nn/atk/util/atk_DeviceOutRecorder.h - include/nn/atk/util/atk_Global.h include/nn/atk/util/atk_ProfileReader.h include/nn/atk/util/atk_TaskProfileReader.h include/nn/atk/fnd/basis/atkfnd_Config.h diff --git a/include/nn/atk/detail/dsp/atk_Adpcm.h b/include/nn/atk/atk_Adpcm.h similarity index 100% rename from include/nn/atk/detail/dsp/atk_Adpcm.h rename to include/nn/atk/atk_Adpcm.h diff --git a/include/nn/atk/detail/dsp/atk_BiquadFilterCallback.h b/include/nn/atk/atk_BiquadFilterCallback.h similarity index 89% rename from include/nn/atk/detail/dsp/atk_BiquadFilterCallback.h rename to include/nn/atk/atk_BiquadFilterCallback.h index 65751258..1647e9ba 100644 --- a/include/nn/atk/detail/dsp/atk_BiquadFilterCallback.h +++ b/include/nn/atk/atk_BiquadFilterCallback.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk { class BiquadFilterCallback { diff --git a/include/nn/atk/atk_FsSoundArchive.h b/include/nn/atk/atk_FsSoundArchive.h index 862a02bf..8f541747 100644 --- a/include/nn/atk/atk_FsSoundArchive.h +++ b/include/nn/atk/atk_FsSoundArchive.h @@ -13,6 +13,8 @@ class FsSoundArchive : SoundArchive { FileAccessMode_InFunction }; + constexpr static u32 BufferAlignSize = 64; + FsSoundArchive(); ~FsSoundArchive() override; @@ -44,7 +46,7 @@ class FsSoundArchive : SoundArchive { u8 m_FileAccessMode; u8 m_Padding[2]; u32 m_FileAccessCount; - char m_SoundArchiveFullPath[639]; + char m_SoundArchiveFullPath[SoundArchive::FilePathMax]; detail::fnd::CriticalSection m_FileOpenCloseLock; }; static_assert(sizeof(FsSoundArchive) == 0x610); diff --git a/include/nn/atk/util/atk_Global.h b/include/nn/atk/atk_Global.h similarity index 94% rename from include/nn/atk/util/atk_Global.h rename to include/nn/atk/atk_Global.h index 2bd9db6a..3231c668 100644 --- a/include/nn/atk/util/atk_Global.h +++ b/include/nn/atk/atk_Global.h @@ -1,7 +1,7 @@ #pragma once +#include #include -#include namespace nn::atk { enum WaveType { @@ -156,6 +156,9 @@ struct AdshrCurve { }; static_assert(sizeof(AdshrCurve) == 0x5); +static const AdshrCurve DefaultAdshrCurve = {127, 127, 127, 127, 127}; +static const AdshrCurve WsdDefaultAdshrCurve = {127, 127, 127, 127, 127}; + struct BiquadFilterCoefficients { s16 b0; s16 b1; @@ -379,6 +382,11 @@ struct VoiceInfo { static_assert(sizeof(VoiceInfo) == 0x20); class VoiceParam { +public: + VoiceParam(); + + void Initialize(); + private: float m_Volume; float m_Pitch; @@ -411,6 +419,11 @@ struct WaveInfo { ChannelParam channelParam[2]; }; static_assert(sizeof(WaveInfo) == 0xa0); + +static const OutputMix DefaultTvMix{1.0, 1.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; } // namespace nn::atk::detail using SoundFrameUserCallback = void(*)(std::uintptr_t); diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index 6538b3a2..222d9386 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -81,6 +81,9 @@ class SoundArchive { static_assert(sizeof(GroupInfo) == 0x8); struct FileInfo { + constexpr static u32 InvalidOffset = -1; + constexpr static u32 InvalidSize = -1; + u32 fileSize; u32 offsetFromFileBlockHead; char* externalFilePath; diff --git a/include/nn/atk/atk_SoundArchivePlayer.h b/include/nn/atk/atk_SoundArchivePlayer.h index 4138aa09..113644fa 100644 --- a/include/nn/atk/atk_SoundArchivePlayer.h +++ b/include/nn/atk/atk_SoundArchivePlayer.h @@ -99,7 +99,9 @@ class SoundArchivePlayer : SoundStartable { void AddAddonSoundArchive(const char*, const AddonSoundArchive*, const SoundDataManager*); void RemoveAddonSoundArchive(const AddonSoundArchive*); +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) void SetDefaultOutputReceiver(OutputReceiver* pOutputReceiver); +#endif StartResult detail_SetupSound(SoundHandle* handle, u32 soundId, bool holdFlag, const char* soundArchiveName, const StartInfo* startInfo) override; @@ -201,8 +203,14 @@ class SoundArchivePlayer : SoundStartable { bool m_IsEnableWarningPrint; bool m_IsInitialized; bool m_IsAdvancedWaveSoundEnabled; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) OutputReceiver* m_pDefaultOutputReceiver; +#endif u8 m_Padding[1]; }; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(SoundArchivePlayer) == 0x310); +#else +static_assert(sizeof(SoundArchivePlayer) == 0x300); +#endif } // namespace nn::atk diff --git a/include/nn/atk/atk_SoundPlayer.h b/include/nn/atk/atk_SoundPlayer.h index 74dbc299..881a1521 100644 --- a/include/nn/atk/atk_SoundPlayer.h +++ b/include/nn/atk/atk_SoundPlayer.h @@ -26,7 +26,9 @@ class SoundPlayer { static_assert(sizeof(OutputParam) == 0x14); SoundPlayer(); +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) explicit SoundPlayer(detail::OutputAdditionalParam* pParam); +#endif ~SoundPlayer(); void StopAllSound(s32 fadeFrames); @@ -92,8 +94,14 @@ class SoundPlayer { f32 m_BiquadValue; u32 m_OutputLineFlag; OutputParam m_TvParam; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) detail::OutputAdditionalParam* m_pOutputAdditionalParam; +#endif bool m_IsFirstComeBased; }; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(SoundPlayer) == 0x88); +#else +static_assert(sizeof(SoundPlayer) == 0x78); +#endif } // namespace nn::atk diff --git a/include/nn/atk/atk_SoundStartable.h b/include/nn/atk/atk_SoundStartable.h index 24a3e9d5..28ec5c75 100644 --- a/include/nn/atk/atk_SoundStartable.h +++ b/include/nn/atk/atk_SoundStartable.h @@ -88,7 +88,9 @@ class SoundStartable { s32 delayCount; UpdateType updateType; s32 subMixIndex; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) OutputReceiver* pOutputReceiver; +#endif }; struct StartResult { diff --git a/include/nn/atk/atk_SoundSystem.h b/include/nn/atk/atk_SoundSystem.h index c79032e5..f86d0adc 100644 --- a/include/nn/atk/atk_SoundSystem.h +++ b/include/nn/atk/atk_SoundSystem.h @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include #include @@ -17,6 +17,7 @@ namespace nn::atk { struct SoundSystem { static bool g_IsInitialized; static bool g_IsStreamLoadWait; + static bool g_IsEnterSleep; static bool g_IsInitializedDriverCommandManager; static uintptr_t g_LoadThreadStackPtr; @@ -30,6 +31,9 @@ struct SoundSystem { static size_t g_SoundThreadCommandBufferSize; static size_t g_TaskThreadCommandBufferSize; + static size_t g_VoiceCommandBufferSize; + + static uintptr_t g_MemoryPoolForSoundSystem; static s32 g_RendererSampleRate; static s32 g_CustomSubMixSubMixCount; @@ -52,11 +56,15 @@ struct SoundSystem { static bool g_IsBusMixVolumeEnabled; static bool g_IsVolumeThroughModeEnabled; + constexpr static u32 VoiceCountMax = 96; + constexpr static u32 WorkMemoryAlignSize = 4; + constexpr static u32 VoiceCommandManagerCountMax = 2; + constexpr static u32 SoundThreadIntervalUsec = 5000; + constexpr static s32 g_TaskThreadFsPriority = 1; constexpr static bool g_IsStreamOpenFailureHalt = true; constexpr static bool g_IsTaskThreadEnabled = true; constexpr static bool g_IsManagingMemoryPool = true; - constexpr static u32 g_VoiceCountMax = 96; constexpr static u32 g_UserEffectCount = 10; constexpr static bool g_IsSubMixEnabled = true; constexpr static bool g_IsPresetSubMixEnabled = true; @@ -65,6 +73,18 @@ struct SoundSystem { constexpr static s32 g_BusCountMax = 4; struct SoundSystemParam { + constexpr static u32 DefaultSoundThreadPriority = 0; + constexpr static u32 DefaultTaskThreadPriority = 0; + constexpr static u32 DefaultSoundThreadStackSize = 0x4000; + constexpr static u32 DefaultTaskThreadStackSize = 0x4000; + constexpr static u32 DefaultSoundThreadCommandBufferSize = 0x20000; + constexpr static u32 DefaultTaskThreadCommandBufferSize = 0x2000; + constexpr static u32 DefaultUserEffectCount = 10; + constexpr static u32 DefaultVoiceCountMax = 96; + constexpr static u32 DefaultSoundThreadCoreNumber = 0; + constexpr static u32 DefaultTaskThreadCoreNumber = 0; + constexpr static u32 DefaultRecordingAudioFrameCount = 8; + SoundSystemParam(); s32 soundThreadPriority{4}; diff --git a/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h b/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h index 51780d12..8b125d4b 100644 --- a/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h +++ b/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h @@ -13,6 +13,8 @@ class AddonSoundArchive; namespace detail { class AddonSoundArchiveContainer { public: + constexpr static s32 SoundArchiveNameCountMax = 64; + AddonSoundArchiveContainer(); ~AddonSoundArchiveContainer(); @@ -33,7 +35,7 @@ class AddonSoundArchiveContainer { u8 m_Padding[3]; SoundArchive* m_pSoundArchive; SoundDataManager* m_pSoundDataManager; - char m_SoundArchiveName[64]; + char m_SoundArchiveName[SoundArchiveNameCountMax]; os::Tick m_AddTick; }; static_assert(sizeof(AddonSoundArchiveContainer) == 0x70); diff --git a/include/nn/atk/detail/atk_AdvancedWaveSound.h b/include/nn/atk/detail/atk_AdvancedWaveSound.h index 1da59b2d..77b578ea 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSound.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSound.h @@ -7,6 +7,7 @@ namespace nn::atk::detail { class AdvancedWaveSound; class AdvancedWaveSoundHandle; + using AdvancedWaveSoundInstanceManager = SoundInstanceManager; class AdvancedWaveSound : BasicSound { @@ -42,5 +43,9 @@ class AdvancedWaveSound : BasicSound { bool m_IsInitialized; u8 m_Padding[3]; }; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(AdvancedWaveSound) == 0x9b0); +#else +static_assert(sizeof(AdvancedWaveSound) == 0x988); +#endif } // namespace nn::atk::detail diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h b/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h index 46bb16f5..b7b2c9c7 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h @@ -2,12 +2,10 @@ #include -#include +#include namespace nn::atk::detail { -struct AdvancedWaveSoundFile { - util::BinaryFileHeader fileHeader; - +struct AdvancedWaveSoundFile { struct WaveSoundTrack; struct InfoBlockBody { u32 offsetToTrackTableReference; @@ -47,6 +45,8 @@ struct AdvancedWaveSoundFile { static_assert(sizeof(WaveSoundClip) == 0x18); InfoBlock* GetBlock() const; + + util::BinaryFileHeader fileHeader; }; static_assert(sizeof(AdvancedWaveSoundFile) == 0x20); diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundFileReader.h b/include/nn/atk/detail/atk_AdvancedWaveSoundFileReader.h index 850b69a0..2d546c55 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundFileReader.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundFileReader.h @@ -15,14 +15,18 @@ struct AdvancedWaveSoundClipInfo { static_assert(sizeof(AdvancedWaveSoundClipInfo) == 0x18); struct AdvancedWaveSoundTrackInfo { + constexpr static u32 AdvancedWaveSoundClipInfoCountMax = 10; + s32 waveSoundClipCount; - AdvancedWaveSoundClipInfo waveSoundClipInfo[10]; + AdvancedWaveSoundClipInfo waveSoundClipInfo[AdvancedWaveSoundClipInfoCountMax]; }; static_assert(sizeof(AdvancedWaveSoundTrackInfo) == 0xf4); struct AdvancedWaveSoundTrackInfoSet { + constexpr static u32 AdvancedWaveSoundTrackInfoCountMax = 4; + s32 waveSoundTrackCount; - AdvancedWaveSoundTrackInfo waveSoundTrackInfo[4]; + AdvancedWaveSoundTrackInfo waveSoundTrackInfo[AdvancedWaveSoundTrackInfoCountMax]; }; static_assert(sizeof(AdvancedWaveSoundTrackInfoSet) == 0x3d4); diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h b/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h index cc23ecde..fdb17581 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h @@ -16,14 +16,18 @@ class AdvancedWaveSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { static_assert(sizeof(ClipParam) == 0x10); struct TrackParam { + constexpr static u32 ClipParamCountMax = 10; + bool isPlayed; - ClipParam clipParam[10]; + ClipParam clipParam[ClipParamCountMax]; }; static_assert(sizeof(TrackParam) == 0xa8); struct TrackParamSet { + constexpr static u32 TrackParamCountMax = 4; + bool isPlayed; - TrackParam trackParam[4]; + TrackParam trackParam[TrackParamCountMax]; }; static_assert(sizeof(TrackParamSet) == 0x2a8); @@ -85,5 +89,9 @@ class AdvancedWaveSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { bool m_IsInitialized; bool m_IsRegisterPlayerCallback; }; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(AdvancedWaveSoundPlayer) == 0x778); +#else +static_assert(sizeof(AdvancedWaveSoundPlayer) == 0x768); +#endif } // namespace nn::atk::detail::driver \ No newline at end of file diff --git a/include/nn/atk/detail/atk_BasicSound.h b/include/nn/atk/detail/atk_BasicSound.h index 7bbda1b5..21d63124 100644 --- a/include/nn/atk/detail/atk_BasicSound.h +++ b/include/nn/atk/detail/atk_BasicSound.h @@ -25,6 +25,9 @@ class OutputAmbientParam { static_assert(sizeof(OutputAmbientParam) == 0x18); class SoundAmbientParam { +public: + constexpr static u32 OutputLineFlagInherit = -1; + private: f32 m_Volume; f32 m_Pitch; @@ -334,8 +337,10 @@ class BasicSound { s32 GetSendBusCount(); s32 GetSendChannelCount(); +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) void SetOutputAdditionalParamAddr(OutputDevice device, OutputAdditionalParam* addr, OutputAdditionalParam* addrForPlayer); +#endif void SetOutputVolume(OutputDevice device, f32 volume); void SetOutputBusMixVolume(OutputDevice, u32, u32, ChannelMixVolume); @@ -413,10 +418,14 @@ class BasicSound { f32 m_LpfFreq; f32 m_BiquadFilterValue; u32 m_OutputLineFlag; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) OutputReceiver* m_pOutputReceiver; +#endif CommonParam m_CommonParam; OutputParam m_OutputParam[1]; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) OutputAdditionalParam* m_pOutputAdditionalParam; +#endif void* m_pUserParam; std::size_t m_UserParamSize; SoundStopCallback m_SoundStopCallback; diff --git a/include/nn/atk/detail/atk_BasicSoundPlayer.h b/include/nn/atk/detail/atk_BasicSoundPlayer.h index ceca709a..afc24ccc 100644 --- a/include/nn/atk/detail/atk_BasicSoundPlayer.h +++ b/include/nn/atk/detail/atk_BasicSoundPlayer.h @@ -8,6 +8,8 @@ namespace nn::atk::detail::driver { struct PlayerParamSet { + void Initialize(); + f32 volume; f32 pitch; f32 lpfFreq; @@ -37,15 +39,23 @@ class BasicSoundPlayer { private: os::Event m_Event; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) OutputReceiver* m_pOutputReceiver; +#endif bool m_ActiveFlag; bool m_StartedFlag; bool m_PauseFlag; bool m_FinishFlag; bool m_IsFinalizedForCannotAllocateResource; PlayerParamSet m_PlayerParamSet; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) OutputAdditionalParam* m_pTvAdditionalParam; +#endif PlayerHeapDataManager* m_pPlayerHeapDataManager; }; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(BasicSoundPlayer) == 0xc0); +#else +static_assert(sizeof(BasicSoundPlayer) == 0xb0); +#endif } //namespace nn::atk::detail::driver \ No newline at end of file diff --git a/include/nn/atk/detail/atk_BusMixVolumePacket.h b/include/nn/atk/detail/atk_BusMixVolumePacket.h index 7c7e900b..c214a286 100644 --- a/include/nn/atk/detail/atk_BusMixVolumePacket.h +++ b/include/nn/atk/detail/atk_BusMixVolumePacket.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { class BusMixVolumePacket { @@ -8,6 +8,7 @@ class BusMixVolumePacket { static std::size_t GetRequiredMemSize(s32 busCount); bool Initialize(void* buffer, std::size_t size, s32 busCount); + void Finalize(); void Reset(); diff --git a/include/nn/atk/detail/atk_GroupFile.h b/include/nn/atk/detail/atk_GroupFile.h index 24f01d17..9e5d70ed 100644 --- a/include/nn/atk/detail/atk_GroupFile.h +++ b/include/nn/atk/detail/atk_GroupFile.h @@ -4,10 +4,15 @@ namespace nn::atk::detail { struct GroupFile { + struct InfoBlock; + struct FileBlock; + struct InfoExBlock; struct FileHeader : Util::SoundFileHeader { - struct InfoBlock* GetInfoBlock(); - struct FileBlock* GetFileBlock(); - struct InfoExBlock* GetInfoExBlock(); + + InfoBlock* GetInfoBlock() const; + FileBlock* GetFileBlock() const; + InfoExBlock* GetInfoExBlock() const; + }; struct InfoBlockBody { diff --git a/include/nn/atk/detail/atk_NoteOnCallback.h b/include/nn/atk/detail/atk_NoteOnCallback.h index e3e65bfc..86e83c73 100644 --- a/include/nn/atk/detail/atk_NoteOnCallback.h +++ b/include/nn/atk/detail/atk_NoteOnCallback.h @@ -14,10 +14,16 @@ struct NoteOnInfo { s32 priority; driver::Channel::ChannelCallback channelCallback; void* channelCallbackData; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) OutputReceiver* pOutputReceiver; +#endif UpdateType updateType; }; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(NoteOnInfo) == 0x38); +#else +static_assert(sizeof(NoteOnInfo) == 0x30); +#endif class NoteOnCallback { public: diff --git a/include/nn/atk/detail/atk_PlayerHeapDataManager.h b/include/nn/atk/detail/atk_PlayerHeapDataManager.h index 902e7db6..1a37d53b 100644 --- a/include/nn/atk/detail/atk_PlayerHeapDataManager.h +++ b/include/nn/atk/detail/atk_PlayerHeapDataManager.h @@ -7,6 +7,8 @@ namespace nn::atk::detail { class PlayerHeapDataManager : driver::DisposeCallback, SoundArchiveLoader { public: + constexpr static u8 FileAddressCount = 9; + struct FileAddress { SoundArchive::FileId fileId; void* address; @@ -20,7 +22,7 @@ class PlayerHeapDataManager : driver::DisposeCallback, SoundArchiveLoader { void Initialize(const SoundArchive* arc); void* SetFileAddress(SoundArchive::FileId fileId, const void* address); - void* GetFileAddress(SoundArchive::FileId fileId); + void* GetFileAddress(SoundArchive::FileId fileId) const; void InvalidateData(const void* start, const void* end) override; diff --git a/include/nn/atk/detail/atk_RegionManager.h b/include/nn/atk/detail/atk_RegionManager.h index eb0d9f67..9d203fe1 100644 --- a/include/nn/atk/detail/atk_RegionManager.h +++ b/include/nn/atk/detail/atk_RegionManager.h @@ -2,9 +2,9 @@ #include +#include #include #include -#include namespace nn::atk { enum StreamRegionCallbackResult { @@ -43,8 +43,9 @@ class RegionManager { bool ChangeRegion(s32 currentRegionNo, IRegionInfoReadable* pRegionReader, StreamDataInfoDetail* pStreamDataInfo); - bool SetRegionInfo(s32 regionNo, IRegionInfoReadable* pRegionReader, - StreamDataInfoDetail* pStreamDataInfo); + + bool SetRegionInfo(const StreamSoundFile::RegionInfo* pRegionInfo, + const StreamDataInfoDetail* pStreamDataInfo); bool TryMoveNextRegion(IRegionInfoReadable* pRegionReader, StreamDataInfoDetail* pStreamDataInfo); diff --git a/include/nn/atk/detail/atk_SoundArchiveFile.h b/include/nn/atk/detail/atk_SoundArchiveFile.h index 558ee2c3..10ae3d7f 100644 --- a/include/nn/atk/detail/atk_SoundArchiveFile.h +++ b/include/nn/atk/detail/atk_SoundArchiveFile.h @@ -8,6 +8,8 @@ struct SoundArchiveParametersHook; class SoundArchiveFile { public: + constexpr static u32 BlockCount = 3; + struct FileHeader : BinaryFileHeader { Util::ReferenceWithSize* GetReferenceBy(u16) const; @@ -20,7 +22,7 @@ class SoundArchiveFile { s32 GetInfoBlockOffset() const; s32 GetFileBlockOffset() const; - Util::ReferenceWithSize toBlocks[3]; + Util::ReferenceWithSize toBlocks[BlockCount]; }; static_assert(sizeof(FileHeader) == 0x38); @@ -53,6 +55,8 @@ class SoundArchiveFile { static_assert(sizeof(NodeData) == 0x8); struct Node { + constexpr static u32 FlagLeaf = 1; + u16 flags; u16 bit; u32 leftIdx; @@ -328,6 +332,9 @@ class SoundArchiveFile { }; struct InternalFileInfo { + constexpr static s32 InvalidOffset = -1; + constexpr static s32 InvalidSize = -1; + Util::ReferenceWithSize toFileImageFromFileBlockBody; Util::Reference toAttachedGroupIdTable; }; diff --git a/include/nn/atk/detail/atk_SoundArchiveFileReader.h b/include/nn/atk/detail/atk_SoundArchiveFileReader.h index f904a18b..fa39b157 100644 --- a/include/nn/atk/detail/atk_SoundArchiveFileReader.h +++ b/include/nn/atk/detail/atk_SoundArchiveFileReader.h @@ -6,44 +6,79 @@ namespace nn::atk::detail { class SoundArchiveFileReader { public: + constexpr static s32 SignatureFile = 0x52415346; // FSAR + constexpr static s32 InvalidOffset = -1; + constexpr static s32 InvalidSize = -1; + SoundArchiveFileReader(); - void Initialize(void* soundArchiveData); + void Initialize(const void* soundArchiveData); void Finalize(); - void SetStringBlock(void* stringBlock); - void SetInfoBlock(void* infoBlock); + bool IsStreamSendAvailable() const; + bool IsFilterSupportedVersion() const; + bool IsStreamPrefetchAvailable() const; + + void SetStringBlock(const void* stringBlock); + void SetInfoBlock(const void* infoBlock); + + s32 GetStringCount() const; + char* GetString(u32) const; + + void DumpTree() const; - SoundArchive::ItemId GetItemId(char* pStr); - char* GetItemLabel(SoundArchive::ItemId id); + SoundArchive::ItemId GetItemId(const char* pStr); + char* GetItemLabel(SoundArchive::ItemId id) const; - SoundArchive::FileId GetItemFileId(SoundArchive::ItemId id); - SoundArchive::FileId GetItemPrefetchFileId(SoundArchive::ItemId id); + SoundArchive::FileId GetItemFileId(SoundArchive::ItemId id) const; + SoundArchive::FileId GetItemPrefetchFileId(SoundArchive::ItemId id) const; - u32 GetPlayerCount(); - u32 GetWaveArchiveCount(); - u32 GetFileCount(); + s32 GetSoundCount() const; + s32 GetBankCount() const; + s32 GetPlayerCount() const; + s32 GetSoundGroupCount() const; + s32 GetGroupCount() const; + s32 GetWaveArchiveCount() const; + s32 GetFileCount() const; - bool ReadSoundInfo(SoundArchive::ItemId soundId, SoundArchive::SoundInfo* info); - bool ReadBankInfo(SoundArchive::ItemId bankId, SoundArchive::BankInfo* info); - bool ReadPlayerInfo(SoundArchive::ItemId playerId, SoundArchive::PlayerInfo* info); - bool ReadSoundGroupInfo(SoundArchive::ItemId soundGroupId, SoundArchive::SoundGroupInfo* info); - bool ReadGroupInfo(SoundArchive::ItemId groupId, SoundArchive::GroupInfo* info); - bool ReadFileInfo(SoundArchive::FileId id, SoundArchive::FileInfo* info, s32 index); - bool ReadWaveArchiveInfo(SoundArchive::ItemId warcId, SoundArchive::WaveArchiveInfo* info); - bool ReadSoundArchivePlayerInfo(SoundArchive::SoundArchivePlayerInfo* info); - bool ReadSequenceSoundInfo(SoundArchive::ItemId soundId, SoundArchive::SequenceSoundInfo* info); - bool ReadStreamSoundInfo(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo* info); - bool ReadStreamSoundInfo2(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo2* info); - bool ReadWaveSoundInfo(SoundArchive::ItemId soundId, SoundArchive::WaveSoundInfo* info); - bool ReadAdvancedWaveSoundInfo(SoundArchive::ItemId soundId, SoundArchive::AdvancedWaveSoundInfo* info); + bool ReadSoundInfo(SoundArchive::ItemId soundId, SoundArchive::SoundInfo* info) const; + bool ReadBankInfo(SoundArchive::ItemId bankId, SoundArchive::BankInfo* info) const; + bool ReadPlayerInfo(SoundArchive::ItemId playerId, SoundArchive::PlayerInfo* info) const; + bool ReadSoundGroupInfo(SoundArchive::ItemId soundGroupId, SoundArchive::SoundGroupInfo* info) const; + bool ReadGroupInfo(SoundArchive::ItemId groupId, SoundArchive::GroupInfo* info) const; + bool ReadFileInfo(SoundArchive::FileId id, SoundArchive::FileInfo* info, s32 index) const; + bool ReadWaveArchiveInfo(SoundArchive::ItemId warcId, SoundArchive::WaveArchiveInfo* info) const; + bool ReadSoundArchivePlayerInfo(SoundArchive::SoundArchivePlayerInfo* info) const; + bool ReadSound3DInfo(SoundArchive::ItemId soundId, SoundArchive::Sound3DInfo* info) const; + bool ReadSequenceSoundInfo(SoundArchive::ItemId soundId, SoundArchive::SequenceSoundInfo* info) const; + bool ReadStreamSoundInfo(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo* info) const; + bool ReadStreamSoundInfo2(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo2* info) const; + bool ReadWaveSoundInfo(SoundArchive::ItemId soundId, SoundArchive::WaveSoundInfo* info) const; + bool ReadAdvancedWaveSoundInfo(SoundArchive::ItemId soundId, SoundArchive::AdvancedWaveSoundInfo* info) const; - Util::Table* GetWaveArchiveIdTable(SoundArchive::ItemId id); - SoundArchive::SoundType GetSoundType(SoundArchive::ItemId soundId); + Util::Table* GetWaveArchiveIdTable(SoundArchive::ItemId id) const; + SoundArchive::SoundType GetSoundType(SoundArchive::ItemId soundId) const; + u32 GetSoundUserParam(u32) const; + + bool ReadSoundUserParam(u32*, u32, s32) const; + void* GetAttachedGroupTable(u32) const; // unknown return type private: detail::SoundArchiveFile::FileHeader m_pHeader; detail::SoundArchiveFile::StringBlockBody* m_pStringBlockBody; detail::SoundArchiveFile::InfoBlockBody* m_pInfoBlockBody; }; + +struct SoundArchiveFilesHook { + constexpr static const char* ItemTypeStreamSound = "stm"; + constexpr static const char* ItemTypeWaveSound = "wsd"; + constexpr static const char* ItemTypeSequenceSound = "seq"; + + constexpr static const char* FileTypeStreamBinary = "bxstm"; + constexpr static const char* FileTypeWaveSoundBinary = "bxwsd"; + constexpr static const char* FileTypeSequenceBinary = "bxseq"; + constexpr static const char* FileTypeBankBinary = "bxbnk"; + constexpr static const char* FileTypeWaveArchiveBinary = "bxwar"; + constexpr static const char* FileTypeStreamPrefetchBinary = "bxstp"; +}; } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/atk_SoundArchiveLoader.h b/include/nn/atk/detail/atk_SoundArchiveLoader.h index 4563bc23..c2c2d970 100644 --- a/include/nn/atk/detail/atk_SoundArchiveLoader.h +++ b/include/nn/atk/detail/atk_SoundArchiveLoader.h @@ -20,6 +20,9 @@ class SoundArchiveLoader { LoadFlag_Warc = 8, }; + constexpr static s32 SignatureIndividualWave = 0x56574946; // FWIV + constexpr static u8 WaveBufferAlignSize = 64; + struct IndividualWaveInfo { u32 signature; u32 fileId; @@ -36,57 +39,72 @@ class SoundArchiveLoader { virtual void* GetFileAddressFromTable(SoundArchive::FileId fileId) const = 0; virtual void* GetFileAddressImpl(SoundArchive::FileId fileId) const = 0; - void SetSoundArchive(SoundArchive* arc); - - bool LoadData(SoundArchive::ItemId itemId, - SoundMemoryAllocatable* pAllocator, - u32 loadFlag, std::size_t loadBlockSize); - bool LoadSequenceSound(SoundArchive::ItemId soundId, - SoundMemoryAllocatable* pAllocator, - u32 loadFlag, std::size_t loadBlockSize); - bool LoadAdvancedWaveSound(SoundArchive::ItemId soundId, - SoundMemoryAllocatable* pAllocator, - u32 loadFlag, std::size_t loadBlockSize); - bool LoadWaveSound(SoundArchive::ItemId soundId, - SoundMemoryAllocatable* pAllocator, - u32 loadFlag, std::size_t loadBlockSize, - SoundArchive::ItemId waveSoundSetId); - bool LoadBank(SoundArchive::ItemId bankId, - SoundMemoryAllocatable* pAllocator, - u32 loadFlag, std::size_t loadBlockSize); - bool LoadSoundGroup(SoundArchive::ItemId soundGroupId, - SoundMemoryAllocatable* pAllocator, - u32 loadFlag, std::size_t loadBlockSize); + void SetSoundArchive(const SoundArchive* arc); + + bool IsAvailable() const; + + bool LoadData(SoundArchive::ItemId itemId, SoundMemoryAllocatable* pAllocator, + u32 loadFlag, size_t loadBlockSize); + bool LoadSequenceSound(SoundArchive::ItemId soundId, SoundMemoryAllocatable* pAllocator, + u32 loadFlag, size_t loadBlockSize); + bool LoadAdvancedWaveSound(SoundArchive::ItemId soundId, SoundMemoryAllocatable* pAllocator, + u32 loadFlag, size_t loadBlockSize); + bool LoadWaveSound(SoundArchive::ItemId soundId, SoundMemoryAllocatable* pAllocator, + u32 loadFlag, size_t loadBlockSize, SoundArchive::ItemId waveSoundSetId); + bool LoadStreamSoundPrefetch(SoundArchive::ItemId soundId, SoundMemoryAllocatable* pAllocator, + size_t loadBlockSize); + bool LoadBank(SoundArchive::ItemId bankId, SoundMemoryAllocatable* pAllocator, + u32 loadFlag, size_t loadBlockSize); + bool LoadWaveArchive(SoundArchive::ItemId bankId, SoundMemoryAllocatable* pAllocator, + u32 loadFlag, size_t loadBlockSize); + bool LoadGroup(SoundArchive::ItemId soundGroupId, SoundMemoryAllocatable* pAllocator, + size_t loadBlockSize); + bool LoadSoundGroup(SoundArchive::ItemId soundGroupId, SoundMemoryAllocatable* pAllocator, + u32 loadFlag, size_t loadBlockSize); + bool LoadData(char* pItemName, SoundMemoryAllocatable* pAllocator, - u32 loadFlag, std::size_t loadBlockSize); - void* LoadImpl(SoundArchive::FileId fileId, - SoundMemoryAllocatable* pAllocator, - std::size_t loadBlockSize, bool needMemoryPool); - bool LoadIndividualWave(SoundArchive::ItemId warcId, u32 waveIndex, - SoundMemoryAllocatable* pAllocator, - std::size_t loadBlockSize); - void* LoadWaveArchiveTable(SoundArchive::ItemId warcId, - SoundMemoryAllocatable* pAllocator, - std::size_t loadBlockSize); - - std::size_t ReadFile(SoundArchive::FileId fileId, void* buffer, - std::size_t size, s32 offset, - std::size_t loadBlockSize); - - bool PostProcessForLoadedGroupFile(void* pGroupFile, - SoundMemoryAllocatable* pAllocator, - std::size_t loadBlockSize); + u32 loadFlag, size_t loadBlockSize); + void* LoadImpl(SoundArchive::FileId fileId, SoundMemoryAllocatable* pAllocator, + size_t loadBlockSize, bool needMemoryPool); + void* LoadFile(SoundArchive::FileId fileId, SoundMemoryAllocatable* pAllocator, + size_t loadBlockSize, bool needMemoryPool); + + void* LoadWaveArchiveImpl(SoundArchive::ItemId warcId, SoundMemoryAllocatable* pAllocator, + size_t loadBlockSize, bool needMemoryPool); + bool LoadIndividualWave(SoundArchive::ItemId warcId, u32 waveIndex, SoundMemoryAllocatable* pAllocator, + size_t loadBlockSize); + void* LoadWaveArchiveTable(SoundArchive::ItemId warcId, SoundMemoryAllocatable* pAllocator, + size_t loadBlockSize); + + size_t ReadFile(SoundArchive::FileId fileId, void* buffer, size_t size, s32 offset, + size_t loadBlockSize); + + bool PostProcessForLoadedGroupFile(void* pGroupFile, SoundMemoryAllocatable* pAllocator, + size_t loadBlockSize); void SetWaveArchiveTableWithSeqInEmbeddedGroup(SoundArchive::ItemId seqId, SoundMemoryAllocatable* pAllocator); + void SetWaveArchiveTableWithBankInEmbeddedGroup(SoundArchive::ItemId bankId, + SoundMemoryAllocatable* pAllocator); void SetWaveArchiveTableWithWsdInEmbeddedGroup(SoundArchive::ItemId wsdId, SoundMemoryAllocatable* pAllocator); void SetWaveArchiveTableInEmbeddedGroupImpl(SoundArchive::ItemId warcId, SoundMemoryAllocatable* pAllocator); - void* GetFileAddressFromSoundArchive(SoundArchive::FileId fileId); + bool IsDataLoaded(const char*, u32) const; + bool IsDataLoaded(u32, u32) const; + + bool IsSequenceSoundDataLoaded(u32, u32) const; + bool IsWaveSoundDataLoaded(u32, u32) const; + bool IsBankDataLoaded(u32, u32) const; + bool IsWaveArchiveDataLoaded(u32, u32) const; + bool IsGroupDataLoaded(u32) const; + bool IsSoundGroupDataLoaded(u32, u32) const; + + void* GetFileAddressFromSoundArchive(SoundArchive::FileId fileId) const; + + void* detail_GetFileAddressByItemId(SoundArchive::ItemId itemId) const; - void* detail_GetFileAddressByItemId(SoundArchive::ItemId itemId); bool detail_LoadWaveArchiveByBankFile(void* bankFile, SoundMemoryAllocatable* pAllocator); bool detail_LoadWaveArchiveByWaveSoundFile(void* wsdFile, s32 wsdIndex, diff --git a/include/nn/atk/detail/atk_SoundArchiveManager.h b/include/nn/atk/detail/atk_SoundArchiveManager.h index d30ef9e2..58b31c38 100644 --- a/include/nn/atk/detail/atk_SoundArchiveManager.h +++ b/include/nn/atk/detail/atk_SoundArchiveManager.h @@ -39,7 +39,8 @@ class SoundArchiveManager { AddonSoundArchiveContainer* GetAddonSoundArchiveContainer(s32); void SetParametersHook(SoundArchiveParametersHook*); - + SoundArchiveParametersHook* GetParametersHook() const; + private: SoundArchive* m_pMainSoundArchive; SoundDataManager* m_pMainSoundDataManager; diff --git a/include/nn/atk/detail/atk_SoundInstanceManager.h b/include/nn/atk/detail/atk_SoundInstanceManager.h index a13d2a8f..214f83e8 100644 --- a/include/nn/atk/detail/atk_SoundInstanceManager.h +++ b/include/nn/atk/detail/atk_SoundInstanceManager.h @@ -1,8 +1,9 @@ #pragma once +#include #include -#include +#include #include namespace nn::atk::detail { @@ -13,9 +14,11 @@ class SoundInstanceManager { util::IntrusiveListMemberNodeTraits>; using Iterator = typename PriorityList::iterator; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) T* Alloc(s32 priority, s32 ambientPriority); +#else T* Alloc(s32 priority, s32 ambientPriority, OutputReceiver* pOutputReceiver); - +#endif s32 Create(void* buffer, std::size_t size, const SoundInstanceConfig& config); void SortPriorityList(); diff --git a/include/nn/atk/detail/atk_StartInfoReader.h b/include/nn/atk/detail/atk_StartInfoReader.h index a5e57d67..25db7d3e 100644 --- a/include/nn/atk/detail/atk_StartInfoReader.h +++ b/include/nn/atk/detail/atk_StartInfoReader.h @@ -24,7 +24,13 @@ class StartInfoReader { SoundArchive::StreamSoundInfo2* m_pStrmMetaInfo2; SoundStartable::StartInfo::WaveSoundInfo* m_pWsdInfo; s32 m_SubMixIndex; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) OutputReceiver* m_pOutputReceiver; +#endif }; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(StartInfoReader) == 0x58); +#else +static_assert(sizeof(StartInfoReader) == 0x50); +#endif } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/atk_VolumeThroughModePacket.h b/include/nn/atk/detail/atk_VolumeThroughModePacket.h index e371f28b..a8e757be 100644 --- a/include/nn/atk/detail/atk_VolumeThroughModePacket.h +++ b/include/nn/atk/detail/atk_VolumeThroughModePacket.h @@ -11,6 +11,8 @@ class VolumeThroughModePacket { bool Initialize(void* buffer, std::size_t size, s32 busCount); + void Finalize(); + void Reset(); VolumeThroughModePacket& operator=(const VolumeThroughModePacket& rhs); diff --git a/include/nn/atk/detail/atk_WaveArchiveFile.h b/include/nn/atk/detail/atk_WaveArchiveFile.h index a865a0f8..660968c5 100644 --- a/include/nn/atk/detail/atk_WaveArchiveFile.h +++ b/include/nn/atk/detail/atk_WaveArchiveFile.h @@ -4,16 +4,24 @@ namespace nn::atk::detail { struct WaveArchiveFile { + constexpr static s32 BlockCount = 2; + struct InfoBlock; struct FileBlock; struct FileHeader : BinaryFileHeader { - Util::ReferenceWithSize toBlocks[2]; + InfoBlock* GetInfoBlock() const; + u32 GetInfoBlockOffset() const; + + FileBlock* GetFileBlock() const; + u32 GetFileBlockOffset() const; + + u32 GetInfoBlockSize() const; - InfoBlock* GetInfoBlock(); - u32 GetInfoBlockOffset(); + Util::Reference* GetReferenceBy(u16); - FileBlock* GetFileBlock(); - u32 GetFileBlockOffset(); + u32 GetFileBlockSize() const; + + Util::ReferenceWithSize toBlocks[BlockCount]; }; static_assert(sizeof(FileHeader) == 0x2C); @@ -24,6 +32,8 @@ struct WaveArchiveFile { }; struct InfoBlockBody { + constexpr static s32 InvalidOffset = -1; + Util::ReferenceWithSizeTable table; }; diff --git a/include/nn/atk/detail/atk_WaveArchiveFileReader.h b/include/nn/atk/detail/atk_WaveArchiveFileReader.h index 0ab0a049..e0ee9850 100644 --- a/include/nn/atk/detail/atk_WaveArchiveFileReader.h +++ b/include/nn/atk/detail/atk_WaveArchiveFileReader.h @@ -6,7 +6,7 @@ namespace nn::atk::detail { class WaveArchiveFileReader { public: constexpr static s32 SignatureFile = 0x52415746; // FWAR - constexpr static s32 SignatureWarcTable = 0x54415746; //FWAT + constexpr static s32 SignatureWarcTable = 0x54415746; // FWAT struct IndividualLoadTable { void* waveFile[1]; diff --git a/include/nn/atk/detail/atk_WaveFile.h b/include/nn/atk/detail/atk_WaveFile.h index ccf7e2fa..08dd6f49 100644 --- a/include/nn/atk/detail/atk_WaveFile.h +++ b/include/nn/atk/detail/atk_WaveFile.h @@ -7,12 +7,17 @@ struct WaveFile { struct InfoBlock; struct DataBlock; struct FileHeader : Util::SoundFileHeader { - InfoBlock* GetInfoBlock(); - DataBlock* GetDataBlock(); + + InfoBlock* GetInfoBlock() const; + DataBlock* GetDataBlock() const; + }; struct ChannelInfo; struct InfoBlockBody { + + ChannelInfo* GetChannelInfo(s32 channelIndex) const; + u8 encoding; u8 isLoop; u8 padding; @@ -21,8 +26,6 @@ struct WaveFile { u32 loopEndFrame; u32 originalLoopStartFrame; Util::ReferenceTable channelInfoReferenceTable; - - ChannelInfo* GetChannelInfo(s32 channelIndex); }; struct InfoBlock { @@ -41,8 +44,8 @@ struct WaveFile { Util::Reference referToAdpcmInfo; u32 reserved; - void* GetSamplesAddress(void* dataBlockBodyAddress); - DspAdpcmInfo* GetDspAdpcmInfo(); + void* GetSamplesAddress(const void* dataBlockBodyAddress) const; + DspAdpcmInfo* GetDspAdpcmInfo() const; }; static_assert(sizeof(ChannelInfo) == 0x14); diff --git a/include/nn/atk/detail/atk_WaveFileReader.h b/include/nn/atk/detail/atk_WaveFileReader.h index 31c1bd0e..1987dcf4 100644 --- a/include/nn/atk/detail/atk_WaveFileReader.h +++ b/include/nn/atk/detail/atk_WaveFileReader.h @@ -10,7 +10,7 @@ class WaveFileReader { static SampleFormat GetSampleFormat(u8 format); - WaveFileReader(void* waveFile, s8 waveType); + WaveFileReader(const void* waveFile, s8 waveType); bool IsOriginalLoopAvailable() const; diff --git a/include/nn/atk/detail/dsp/atk_BiquadFilterPresets.h b/include/nn/atk/detail/dsp/atk_BiquadFilterPresets.h index d452cfbb..7d0a67cf 100644 --- a/include/nn/atk/detail/dsp/atk_BiquadFilterPresets.h +++ b/include/nn/atk/detail/dsp/atk_BiquadFilterPresets.h @@ -5,7 +5,9 @@ namespace nn::atk::detail { class BiquadFilterLpf : BiquadFilterCallback { public: - static Coefficients CoefficientsTable32000[112]; + constexpr static u32 CoefficientsTableSize = 112; + + static Coefficients CoefficientsTable32000[CoefficientsTableSize]; ~BiquadFilterLpf() override; @@ -15,7 +17,9 @@ static_assert(sizeof(BiquadFilterLpf) == 0x8); class BiquadFilterHpf : BiquadFilterCallback { public: - static Coefficients CoefficientsTable32000[97]; + constexpr static u32 CoefficientsTableSize = 97; + + static Coefficients CoefficientsTable32000[CoefficientsTableSize]; ~BiquadFilterHpf() override; @@ -25,7 +29,9 @@ static_assert(sizeof(BiquadFilterHpf) == 0x8); class BiquadFilterBpf512 : BiquadFilterCallback { public: - static Coefficients CoefficientsTable32000[122]; + constexpr static u32 CoefficientsTableSize = 122; + + static Coefficients CoefficientsTable32000[CoefficientsTableSize]; ~BiquadFilterBpf512() override; @@ -35,7 +41,9 @@ static_assert(sizeof(BiquadFilterBpf512) == 0x8); class BiquadFilterBpf1024 : BiquadFilterCallback { public: - static Coefficients CoefficientsTable32000[93]; + constexpr static u32 CoefficientsTableSize = 93; + + static Coefficients CoefficientsTable32000[CoefficientsTableSize]; ~BiquadFilterBpf1024() override; @@ -45,7 +53,9 @@ static_assert(sizeof(BiquadFilterBpf1024) == 0x8); class BiquadFilterBpf2048 : BiquadFilterCallback { public: - static Coefficients CoefficientsTable32000[93]; + constexpr static u32 CoefficientsTableSize = 93; + + static Coefficients CoefficientsTable32000[CoefficientsTableSize]; ~BiquadFilterBpf2048() override; @@ -55,7 +65,7 @@ static_assert(sizeof(BiquadFilterBpf2048) == 0x8); class BiquadFilterLpfNw4fCompatible48k : BiquadFilterCallback { public: - static Coefficients CoefficientsTable48000[112]; + static Coefficients CoefficientsTable48000[BiquadFilterLpf::CoefficientsTableSize]; ~BiquadFilterLpfNw4fCompatible48k() override; @@ -65,7 +75,7 @@ static_assert(sizeof(BiquadFilterLpfNw4fCompatible48k) == 0x8); class BiquadFilterHpfNw4fCompatible48k : BiquadFilterCallback { public: - static Coefficients CoefficientsTable48000[97]; + static Coefficients CoefficientsTable48000[BiquadFilterHpf::CoefficientsTableSize]; ~BiquadFilterHpfNw4fCompatible48k() override; @@ -75,7 +85,7 @@ static_assert(sizeof(BiquadFilterHpfNw4fCompatible48k) == 0x8); class BiquadFilterBpf512Nw4fCompatible48k : BiquadFilterCallback { public: - static Coefficients CoefficientsTable48000[122]; + static Coefficients CoefficientsTable48000[BiquadFilterBpf512::CoefficientsTableSize]; ~BiquadFilterBpf512Nw4fCompatible48k() override; @@ -85,7 +95,7 @@ static_assert(sizeof(BiquadFilterBpf512Nw4fCompatible48k) == 0x8); class BiquadFilterBpf1024Nw4fCompatible48k : BiquadFilterCallback { public: - static Coefficients CoefficientsTable48000[93]; + static Coefficients CoefficientsTable48000[BiquadFilterBpf1024::CoefficientsTableSize]; ~BiquadFilterBpf1024Nw4fCompatible48k() override; @@ -95,7 +105,7 @@ static_assert(sizeof(BiquadFilterBpf1024Nw4fCompatible48k) == 0x8); class BiquadFilterBpf2048Nw4fCompatible48k : BiquadFilterCallback { public: - static Coefficients CoefficientsTable48000[93]; + static Coefficients CoefficientsTable48000[BiquadFilterBpf2048::CoefficientsTableSize]; ~BiquadFilterBpf2048Nw4fCompatible48k() override; diff --git a/include/nn/atk/detail/dsp/atk_DspadpcmReader.h b/include/nn/atk/detail/dsp/atk_DspadpcmReader.h index 5af01154..68bacadb 100644 --- a/include/nn/atk/detail/dsp/atk_DspadpcmReader.h +++ b/include/nn/atk/detail/dsp/atk_DspadpcmReader.h @@ -7,7 +7,7 @@ class DspadpcmReader { public: DspadpcmReader(); - bool ReadWaveInfo(WaveInfo* info); + bool ReadWaveInfo(WaveInfo* info) const; private: void* m_pDspadpcmData; diff --git a/include/nn/atk/detail/dsp/atk_HardwareManager.h b/include/nn/atk/detail/dsp/atk_HardwareManager.h index 4855ca11..73335467 100644 --- a/include/nn/atk/detail/dsp/atk_HardwareManager.h +++ b/include/nn/atk/detail/dsp/atk_HardwareManager.h @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include #include @@ -35,13 +35,12 @@ class HardwareManager { // inherits nn::atk::Util::Singleton constexpr static u32 DefaultRendererSubMixCount = 1; constexpr static u32 DefaultRendererSinkCount = 1; constexpr static u32 DefaultRendererPerformanceFrameCount = 0; - constexpr static u32 DefaultRendererSystemEffectCount = 4; constexpr static u32 SubMixCountMax = 2; + constexpr static u32 SubMixCountForAdditionalEffect = 1; constexpr static u32 ChannelCountForAdditionalEffect = 2; - constexpr static u32 AuxBusCountForAdditionalEffect = 2; constexpr static u32 MixBufferCountForAdditionalEffect = 6; diff --git a/include/nn/atk/detail/seq/atk_BankFile.h b/include/nn/atk/detail/seq/atk_BankFile.h index d91fcb38..e888c78b 100644 --- a/include/nn/atk/detail/seq/atk_BankFile.h +++ b/include/nn/atk/detail/seq/atk_BankFile.h @@ -6,17 +6,20 @@ namespace nn::atk::detail { struct BankFile { struct InfoBlock; struct FileHeader : Util::SoundFileHeader { + InfoBlock* GetInfoBlock() const; + }; struct Instrument; struct InfoBlockBody { - Util::Reference toWaveIdTable; - Util::Reference toInstrumentReferenceTable; Util::WaveIdTable* GetWaveIdTable() const; Util::ReferenceTable GetInstrumentReferenceTable() const; Instrument* GetInstrument(s32 programNo) const; + + Util::Reference toWaveIdTable; + Util::Reference toInstrumentReferenceTable; }; static_assert(sizeof(InfoBlockBody) == 0x10); @@ -28,24 +31,24 @@ struct BankFile { struct KeyRegion; struct Instrument { - Util::Reference toKeyRegionChunk; KeyRegion* GetKeyRegion(u32 key) const; + + Util::Reference toKeyRegionChunk; }; static_assert(sizeof(Instrument) == 0x8); struct VelocityRegion; struct KeyRegion { - Util::Reference toVelocityRegionChunk; VelocityRegion* GetVelocityRegion(u32 velocity) const; + + Util::Reference toVelocityRegionChunk; }; static_assert(sizeof(KeyRegion) == 0x8); struct RegionParameter; struct VelocityRegion { - u32 waveIdTableIndex; - Util::BitFlag optionParameter; u8 GetOriginalKey() const; u8 GetVolume() const; @@ -56,6 +59,9 @@ struct BankFile { u8 GetInterpolationType() const; AdshrCurve* GetAdshrCurve() const; RegionParameter* GetRegionParameter() const; + + u32 waveIdTableIndex; + Util::BitFlag optionParameter; }; static_assert(sizeof(VelocityRegion) == 0x8); }; diff --git a/include/nn/atk/detail/seq/atk_MmlParser.h b/include/nn/atk/detail/seq/atk_MmlParser.h index 9f47f623..62f369fd 100644 --- a/include/nn/atk/detail/seq/atk_MmlParser.h +++ b/include/nn/atk/detail/seq/atk_MmlParser.h @@ -14,6 +14,12 @@ class MmlParser { SeqArgType_Variable, }; + constexpr static u32 PanCenter = 64; + constexpr static u32 SurroundPanCenter = PanCenter; + + constexpr static u32 TempoMin = 0; + constexpr static u32 TempoMax = 1023; + MmlParser(); virtual ~MmlParser(); @@ -34,6 +40,9 @@ class MmlParser { s16 ReadVar(const u8** ptr) const; static u32 ParseAllocTrack(const void* baseAddress, u32 seqOffset, u32* allocTrack); + +private: + static bool* mPrintVarEnabledFlag; }; static_assert(sizeof(MmlParser) == 0x8); } // namespace nn::atk::detail::driver \ No newline at end of file diff --git a/include/nn/atk/detail/seq/atk_SequenceSound.h b/include/nn/atk/detail/seq/atk_SequenceSound.h index dd893676..292bbb0d 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSound.h +++ b/include/nn/atk/detail/seq/atk_SequenceSound.h @@ -10,6 +10,15 @@ using SequenceSoundInstanceManager = SoundInstanceManager; class SequenceSound : BasicSound { public: + constexpr static u32 BankIndexMin = 0; + constexpr static u32 BankIndexMax = 3; + + constexpr static u8 TransposeMin = 192; + constexpr static u8 TransposeMax = 63; + + constexpr static u8 VelocityRangeMin = 0; + constexpr static u32 VelocityRangeMax = 0x7f00; + struct Resource { void* seq; void* banks[4]; @@ -57,8 +66,8 @@ class SequenceSound : BasicSound { void SetTrackBankIndex(u32 trackBitFlag, s32 bankIndex); void SetTrackTranspose(u32 trackBitFlag, s8 transpose); void SetTrackVelocityRange(u32 trackBitFlag, u8 range); - void SetTrackOutputLine(u32 trackBitFlag, u32 outputLine); + void SetTrackOutputLine(u32 trackBitFlag, u32 outputLine); void ResetTrackOutputLine(u32 trackBitFlag); bool ReadVariable(s32 varNo, s16* varPtr) const; @@ -96,5 +105,9 @@ class SequenceSound : BasicSound { u8 m_Padding[1]; driver::SequenceSoundPlayer m_PlayerInstance; }; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(SequenceSound) == 0x5a0); +#else +static_assert(sizeof(SequenceSound) == 0x578); +#endif } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/seq/atk_SequenceSoundFile.h b/include/nn/atk/detail/seq/atk_SequenceSoundFile.h index cb2077ae..d93969f1 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSoundFile.h +++ b/include/nn/atk/detail/seq/atk_SequenceSoundFile.h @@ -7,6 +7,7 @@ struct SequenceSoundFile { struct DataBlock; struct LabelBlock; struct FileHeader : Util::SoundFileHeader { + DataBlock* GetDataBlock() const; LabelBlock* GetLabelBlock() const; }; @@ -18,14 +19,15 @@ struct SequenceSoundFile { }; struct LabelBlockBody { - Util::ReferenceTable labelInfoReferenceTable; - + LabelInfo* GetLabelInfo(s32 index) const; char* GetLabel(s32 index) const; char* GetLabelByOffest(s32 labelOffset) const; - + u32 GetOffset(s32 index, u32* offsetPtr) const; bool GetOffsetByLabel(char* label, u32* offsetPtr) const; + + Util::ReferenceTable labelInfoReferenceTable; }; struct LabelBlock { diff --git a/include/nn/atk/detail/seq/atk_SequenceSoundFileReader.h b/include/nn/atk/detail/seq/atk_SequenceSoundFileReader.h index 5401ed37..9a060697 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSoundFileReader.h +++ b/include/nn/atk/detail/seq/atk_SequenceSoundFileReader.h @@ -5,7 +5,7 @@ namespace nn::atk::detail { class SequenceSoundFileReader { public: - constexpr static s32 SignatureFile = 51455346; // FSEQ + constexpr static s32 SignatureFile = 0x51455346; // FSEQ explicit SequenceSoundFileReader(void* sequenceFile); diff --git a/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h b/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h index 9a888e54..8653ea87 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h +++ b/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h @@ -28,7 +28,7 @@ using SequenceSoundLoaderManager = LoaderManager; class SequenceSoundLoader { public: struct LoadInfo { - LoadInfo(SoundArchive* arc, SoundDataManager* mgr, + LoadInfo(const SoundArchive* arc, const SoundDataManager* mgr, LoadItemInfo* seq, LoadItemInfo* banks, SoundPlayer* player); SoundArchive* soundArchive; @@ -61,6 +61,8 @@ class SequenceSoundLoader { DataLoadTask(); ~DataLoadTask() override; + void Initialize(); + bool TryAllocPlayerHeap(); void Execute(TaskProfileLogger& logger) override; @@ -131,9 +133,10 @@ class SequenceSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::Play constexpr static u32 AllTrackBitFlag = 0x0000FFFF; constexpr static s32 VariableDefaultValue = -1; + constexpr static s32 DefaultTimebase = 48; constexpr static s32 DefaultTempo = 120; - constexpr static u64 DefaultSkipIntervalTick = 0x300; + constexpr static u32 DefaultSkipIntervalTick = 16 * DefaultTimebase; struct ParserPlayerParam { u8 priority; @@ -192,6 +195,9 @@ class SequenceSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::Play void Setup(const SetupArg& arg); void SetPlayerTrack(s32 trackNo, SequenceTrack* track); + + void ForceTrackMute(u32); + SequenceTrack* GetPlayerTrack(s32 trackNo); void Start() override; @@ -208,7 +214,10 @@ class SequenceSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::Play void CallSequenceUserprocCallback(u16 procId, SequenceTrack* track); s16* GetVariablePtr(s32 varNo); + void GetLocalVariable(s32 varNo) const; + static s16 GetGlobalVariable(s32 varNo); + void SetLocalVariable(s32 varNo, s16 var); static void SetGlobalVariable(s32 varNo, s16 var); @@ -243,31 +252,32 @@ class SequenceSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::Play void Update(); + bool TryAllocLoader(); + void PrepareForPlayerHeap(PrepareArg* arg); void SkipTick(); void UpdateTick(); - Channel* NoteOn(u8 bankIndex, NoteOnInfo* noteOnInfo); + Channel* NoteOn(u8 bankIndex, const NoteOnInfo& noteOnInfo); - void Prepare(PrepareArg* arg); + void Prepare(const PrepareArg& arg); - void RequestLoad(StartInfo* info, SequenceSoundLoader::Arg* arg); + void RequestLoad(const StartInfo& info, const SequenceSoundLoader::Arg& arg); - u64 GetProcessTick(SoundProfile&); + u64 GetProcessTick(const SoundProfile&); void PrepareForMidi(const void**, const void**, bool*); - bool TryAllocLoader(); + static void SetSkipIntervalTick(s32); + static s32 GetSkipIntervalTick(); void ChannelCallback(Channel* channel); + void OnUpdateFrameSoundThread() override; void OnUpdateFrameSoundThreadWithAudioFrameFrequency() override; void OnShutdownSoundThread() override; - static void SetSkipIntervalTick(s32); - static s32 GetSkipIntervalTick(); - private: bool m_ReleasePriorityFixFlag; bool m_IsPrepared; @@ -299,6 +309,10 @@ class SequenceSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::Play static s16 m_GlobalVariable[GlobalVariableCount]; static s32 m_SkipIntervalTickPerFrame; }; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(SequenceSoundPlayer) == 0x368); +#else +static_assert(sizeof(SequenceSoundPlayer) == 0x358); +#endif } // namespace nn::atk::detail::driver } // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h b/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h index 5e6a0148..e02c9e2f 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h +++ b/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h @@ -40,12 +40,12 @@ class SequenceSoundRuntime { void Finalize(); void SetupSequenceTrack(s32 trackCount, void** pOutAllocatedAddr, const void* endAddr); - void SetupUserParam(void** pOutAllocatedAddr, std::size_t adjustSize); + void SetupUserParam(void** pOutAllocatedAddr, size_t adjustSize); - static std::size_t GetRequiredMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, - s32 alignment); - static std::size_t GetRequiredSequenceTrackMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, - s32 alignment); + static size_t GetRequiredMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, + s32 alignment); + static size_t GetRequiredSequenceTrackMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, + s32 alignment); bool IsSoundArchiveAvailable() const; @@ -57,10 +57,13 @@ class SequenceSoundRuntime { void Update(); +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) SequenceSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, BasicSound::AmbientInfo* ambientArgInfo); +#else SequenceSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, BasicSound::AmbientInfo* ambientArgInfo, OutputReceiver* pOutputReceiver); +#endif SoundStartable::StartResult PrepareImpl(const SoundArchiveManager::SnapShot& snapShot, SoundArchive::ItemId soundId, diff --git a/include/nn/atk/detail/seq/atk_SequenceTrack.h b/include/nn/atk/detail/seq/atk_SequenceTrack.h index e18d20d6..230020c3 100644 --- a/include/nn/atk/detail/seq/atk_SequenceTrack.h +++ b/include/nn/atk/detail/seq/atk_SequenceTrack.h @@ -12,6 +12,23 @@ class SequenceTrack { ParseResult_Finish, }; + constexpr static u32 CallStackDepth = 10; + + constexpr static u32 DefaultPriority = 64; + constexpr static u32 DefaultBendRange = 2; + constexpr static u32 DefaultPortaKey = 60; + + constexpr static s32 InvalidEnvelope = 255; + constexpr static s32 MaxEnvelopeValue = 127; + + constexpr static s32 ParserParamSize = 32; + + constexpr static s32 TrackVariableCount = 16; + + constexpr static s32 PauseReleaseValue = 16; + constexpr static s32 MuteReleaseValue = 127; + + struct ParserTrackParam { struct CallStack { u8 loopFlag; @@ -27,7 +44,7 @@ class SequenceTrack { bool noteWaitFlag; bool tieFlag; bool monophonicFlag; - CallStack callStack[10]; + CallStack callStack[CallStackDepth]; u8 callStackDepth; bool frontBypassFlag; bool muteFlag; @@ -104,6 +121,8 @@ class SequenceTrack { Channel::ChannelCallbackStatus callbackStatus, void* userData); void SetMute(SequenceMute mute); + void ForceMute(); + void SetSilence(bool silenceFlag, s32 fadeTimes); void SetBiquadFilter(s32 type, f32 value); void SetBankIndex(s32 bankIndex); @@ -112,7 +131,7 @@ class SequenceTrack { void SetOutputLine(s32 outputLine); void SetTvMixParameter(u32 srcChNo, s32 mixChNo, f32 param); - s16 GetTrackVariable(s32) const; + s16 GetTrackVariable(s32 varNo) const; void SetTrackVariable(s32 varNo, s16 var); s16* GetVariablePtr(s32 varNo); @@ -128,7 +147,7 @@ class SequenceTrack { f32 m_PanRange; OutputParam m_TvParam; ParserTrackParam m_ParserTrackParam; - s16 m_TrackVariable[16]; + s16 m_TrackVariable[TrackVariableCount]; SequenceSoundPlayer* m_pSequenceSoundPlayer; Channel* m_pChannelList; }; diff --git a/include/nn/atk/detail/strm/atk_StreamBufferPool.h b/include/nn/atk/detail/strm/atk_StreamBufferPool.h index f2f8a7be..6209d14d 100644 --- a/include/nn/atk/detail/strm/atk_StreamBufferPool.h +++ b/include/nn/atk/detail/strm/atk_StreamBufferPool.h @@ -20,7 +20,7 @@ class StreamBufferPool { std::size_t m_BlockSize; s32 m_BlockCount; s32 m_AllocCount; - u8 m_AllocFlags[4]; + u8 m_AllocFlags[BlockMax / BitPerByte]; }; static_assert(sizeof(StreamBufferPool) == 0x28); } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/strm/atk_StreamSound.h b/include/nn/atk/detail/strm/atk_StreamSound.h index db17a276..dd5f330c 100644 --- a/include/nn/atk/detail/strm/atk_StreamSound.h +++ b/include/nn/atk/detail/strm/atk_StreamSound.h @@ -21,9 +21,9 @@ class StreamSound : BasicSound { void Setup(const driver::StreamSoundPlayer::SetupArg& arg); - void Prepare(const driver::StreamSoundPlayer::PrepareArg& arg); + void Prepare(const driver::StreamSoundPlayer::PrepareBaseArg& arg); void PreparePrefetch(const void* strmPrefetchFile, - const driver::StreamSoundPlayer::PrepareArg& arg); + const driver::StreamSoundPlayer::PrepareBaseArg& arg); void UpdateMoveValue() override; @@ -76,5 +76,9 @@ class StreamSound : BasicSound { std::size_t m_CacheSize; driver::StreamSoundPlayer m_PlayerInstance; }; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(StreamSound) == 0x11a40); +#else +static_assert(sizeof(StreamSound) == 0x11a00); +#endif } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/strm/atk_StreamSoundFile.h b/include/nn/atk/detail/strm/atk_StreamSoundFile.h index dfebc389..a417527e 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundFile.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundFile.h @@ -6,16 +6,25 @@ namespace nn::atk::detail { class StreamSoundFile { public: struct FileHeader : BinaryFileHeader { - Util::ReferenceWithSize toBlocks[4]; - bool HasSeekBlock(); - bool HasRegionBlock(); + constexpr static u8 BlockCount = 4; + + Util::Reference* GetReferenceBy(u16) const; + + bool HasSeekBlock() const; + bool HasRegionBlock() const; - u32 GetInfoBlockSize(); - u32 GetInfoBlockOffset(); - u32 GetSeekBlockOffset(); - u32 GetDataBlockOffset(); - u32 GetRegionBlockOffset(); + u32 GetInfoBlockSize() const; + u32 GetSeekBlockSize() const; + u32 GetDataBlockSize() const; + u32 GetRegionBlockSize() const; + + u32 GetInfoBlockOffset() const; + u32 GetSeekBlockOffset() const; + u32 GetDataBlockOffset() const; + u32 GetRegionBlockOffset() const; + + Util::ReferenceWithSize toBlocks[BlockCount]; }; static_assert(sizeof(FileHeader) == 0x44); @@ -57,7 +66,7 @@ class StreamSoundFile { struct TrackInfoTable { Util::ReferenceTable table; - TrackInfo* GetTrackInfo(u32 index); + TrackInfo* GetTrackInfo(u32 index) const; }; struct DspAdpcmChannelInfo { @@ -69,14 +78,14 @@ class StreamSoundFile { struct ChannelInfo { Util::Reference toDetailChannelInfo; - DspAdpcmChannelInfo* GetDspAdpcmChannelInfo(); + DspAdpcmChannelInfo* GetDspAdpcmChannelInfo() const; }; static_assert(sizeof(ChannelInfo) == 0x8); struct ChannelInfoTable { Util::ReferenceTable table; - ChannelInfo* GetChannelInfo(u32 index); + ChannelInfo* GetChannelInfo(u32 index) const; }; struct InfoBlockBody { @@ -84,9 +93,9 @@ class StreamSoundFile { Util::Reference toTrackInfoTable; Util::Reference toChannelInfoTable; - StreamSoundInfo* GetStreamSoundInfo(); - TrackInfoTable* GetTrackInfoTable(); - ChannelInfoTable* GetChannelInfoTable(); + StreamSoundInfo* GetStreamSoundInfo() const; + TrackInfoTable* GetTrackInfoTable() const; + ChannelInfoTable* GetChannelInfoTable() const; }; static_assert(sizeof(InfoBlockBody) == 0x18); diff --git a/include/nn/atk/detail/strm/atk_StreamSoundFileReader.h b/include/nn/atk/detail/strm/atk_StreamSoundFileReader.h index 51b88e2c..c38c8bc6 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundFileReader.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundFileReader.h @@ -9,8 +9,15 @@ class StreamSoundFileReader { void Initialize(const void* streamSoundFile); - bool IsValidFileHeader(const void* streamSoundFile) const; + static bool IsValidFileHeader(const void* streamSoundFile); + + void Finalize(); + bool IsTrackInfoAvailable() const; + bool IsOriginalLoopAvailable() const; + + static bool IsOriginalLoopAvailableImpl(const StreamSoundFile::FileHeader* header); + bool IsCrc32CheckAvailable() const; bool IsRegionIndexCheckAvailable() const; diff --git a/include/nn/atk/detail/strm/atk_StreamSoundLoader.h b/include/nn/atk/detail/strm/atk_StreamSoundLoader.h index d50fbbd6..5f98db55 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundLoader.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundLoader.h @@ -1,11 +1,11 @@ #pragma once +#include #include #include #include #include #include -#include #include #include #include @@ -37,6 +37,8 @@ struct TrackDataInfos { static_assert(sizeof(TrackDataInfos) == 0x70); struct StreamDataInfoDetail { + void SetStreamSoundInfo(const StreamSoundFile::StreamSoundInfo&, bool); + SampleFormat sampleFormat; s32 sampleRate; bool loopFlag; @@ -86,6 +88,14 @@ using StreamSoundLoaderManager = LoaderManager; class StreamSoundLoader { public: + constexpr static size_t DataBlockSizeBase = 0x2000; + constexpr static size_t DataBlockSizeMargin = 0x900; + constexpr static size_t DataBlockSizeMax = DataBlockSizeBase + DataBlockSizeMargin; + + constexpr static u32 FileStreamBufferSize = 0x200; + constexpr static u32 LoadBufferChannelCount = 2; + constexpr static size_t LoadBufferSize = 0x5200; + class StreamHeaderLoadTask : Task { public: StreamHeaderLoadTask(); @@ -162,8 +172,16 @@ class StreamSoundLoader { void CancelRequest(); void RequestClose(); + void RegisterStreamDataDecoderManager(IStreamDataDecoderManager* manager); + void UnregisterStreamDataDecoderManager(IStreamDataDecoderManager* manager); + void* detail_SetFsAccessLog(fnd::FsAccessLog* pFsAccessLog); + position_t detail_GetCurrentPosition(); + position_t detail_GetCachePosition(); + + size_t detail_GetCachedLength(); + void RequestLoadHeader(); void RequestLoadData(void** bufferAddress, u32 bufferBlockIndex, position_t startOffsetSamples, position_t prefetchOffsetSamples, s32 priority); @@ -188,6 +206,8 @@ class StreamSoundLoader { void UpdateLoadingDataBlockIndex(); + IStreamDataDecoderManager* SelectStreamDataDecoderManager(StreamFileType, DecodeMode); + void SetStreamSoundInfoForOpus(const IStreamDataDecoder::DataInfo& dataInfo); void LoadData(void** bufferAddress, u32 bufferBlockIndex, std::size_t startOffsetSamples, @@ -245,7 +265,7 @@ class StreamSoundLoader { bool m_IsStreamOpenFailureHalt; position_t m_LoopStart; position_t m_LoopEnd; - char m_FilePath[639]; + char m_FilePath[SoundArchive::FilePathMax]; void* m_pExternalData; std::size_t m_ExternalDataSize; void* m_pCacheBuffer; @@ -270,6 +290,8 @@ class StreamSoundLoader { IStreamDataDecoder* m_pStreamDataDecoder; IStreamDataDecoderManager* m_pStreamDataDecoderManager; util::IntrusiveListNode m_LinkForLoaderManager; + + static u8 g_LoadBuffer[LoadBufferSize]; }; static_assert(sizeof(StreamSoundLoader) == 0x3640); } // namespace nn::atk::detail::driver diff --git a/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h b/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h index ab3a2cd6..96ec48d6 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h @@ -211,13 +211,16 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { void SetOutputParam(const OutputParam*, const OutputParam&, const TrackData&); +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) void ApplyTvOutputParamForMultiChannel(OutputParam* outputParam, MultiVoice* MultiVoice, s32 channelIndex, MixMode mixMode); +#else void ApplyTvOutputParamForMultiChannel(OutputParam* outputParam, OutputAdditionalParam* pOutputAdditionalParam, MultiVoice* MultiVoice, s32 channelIndex, MixMode mixMode); +#endif void MixSettingForOutputParam(OutputParam* outputParam, s32 channelIndex, MixMode mixMode); @@ -317,6 +320,7 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { position_t m_OriginalPlaySamplePosition; static u16 g_TaskRequestIndexCount; + static u16 g_AssignNumberCount; }; static_assert(sizeof(StreamSoundPlayer) == 0x11740); } // namespace nn::atk::detail::driver diff --git a/include/nn/atk/detail/strm/atk_StreamSoundPrefetchFile.h b/include/nn/atk/detail/strm/atk_StreamSoundPrefetchFile.h index c215febd..06f493d4 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundPrefetchFile.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundPrefetchFile.h @@ -9,30 +9,33 @@ class StreamSoundPrefetchFile { struct PrefetchDataBlock; struct FileHeader : Util::SoundFileHeader { - StreamSoundFile::InfoBlock* GetInfoBlock(); + StreamSoundFile::InfoBlock* GetInfoBlock() const; + StreamSoundFile::RegionBlock* GetRegionBlock() const; + PrefetchDataBlock* GetPrefetchDataBlock() const; - u32 GetPrefetchDataBlockSize(); - PrefetchDataBlock* GetPrefetchDataBlock(); + u32 GetPrefetchDataBlockSize() const; - bool HasRegionBlock(); - u32 GetRegionBlockOffset(); - u32 GetRegionBlockSize(); - StreamSoundFile::RegionBlock* GetRegionBlock(); + bool HasRegionBlock() const; + u32 GetRegionBlockSize() const; + u32 GetRegionBlockOffset() const; + }; struct PrefetchSample { - u8 data[1]; void* GetSampleAddress(); + + u8 data[1]; }; struct PrefetchData { + + PrefetchSample* GetPrefetchSample(); + u32 startFrame; u32 prefetchSize; u32 reserved[1]; Util::Reference toPrefetchSample; - - PrefetchSample* GetPrefetchSample(); }; static_assert(sizeof(PrefetchData) == 0x14); diff --git a/include/nn/atk/detail/strm/atk_StreamSoundPrefetchFileReader.h b/include/nn/atk/detail/strm/atk_StreamSoundPrefetchFileReader.h index f149d841..4b59d803 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundPrefetchFileReader.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundPrefetchFileReader.h @@ -16,6 +16,7 @@ class StreamSoundPrefetchFileReader : IRegionInfoReadable { ~StreamSoundPrefetchFileReader() override; void Initialize(const void* streamSoundPrefetchFile); + void Finalize(); bool IsValidFileHeader(const void* streamSoundPrefetchFile) const; diff --git a/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h b/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h index b2588877..3f9ad7ec 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h @@ -7,6 +7,8 @@ namespace nn::atk::detail { class StreamSoundRuntime { public: + constexpr static u32 DefaultStreamBlockCount = 5; + StreamSoundRuntime(); ~StreamSoundRuntime(); @@ -42,12 +44,13 @@ class StreamSoundRuntime { void SetupUserParam(void** pOutAllocatedAddr, std::size_t adjustSize); void Update(); - +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) StreamSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, BasicSound::AmbientInfo* ambientArgInfo); +#else StreamSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, BasicSound::AmbientInfo* ambientArgInfo, OutputReceiver* pOutputReceiver); - +#endif SoundStartable::StartResult PrepareImpl(const SoundArchive* pSoundArchive, const SoundDataManager* pSoundDataManager, SoundArchive::ItemId soundId, diff --git a/include/nn/atk/detail/thread/atk_DriverCommand.h b/include/nn/atk/detail/thread/atk_DriverCommand.h index 67da6365..bc7835f6 100644 --- a/include/nn/atk/detail/thread/atk_DriverCommand.h +++ b/include/nn/atk/detail/thread/atk_DriverCommand.h @@ -114,10 +114,16 @@ static_assert(sizeof(DriverCommandReply) == 0x20); struct DriverCommandPlayerInit : Command { driver::BasicSoundPlayer* player; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) OutputReceiver* pOutputReceiver; +#endif bool* availableFlagPtr; }; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(DriverCommandPlayerInit) == 0x30); +#else +static_assert(sizeof(DriverCommandPlayerInit) == 0x28); +#endif struct DriverCommandPlayerPanParam : Command { driver::BasicSoundPlayer* player; @@ -433,18 +439,30 @@ struct DriverCommandEffectAux : Command { static_assert(sizeof(DriverCommandEffectAux) == 0x40); struct DriverCommandSubMixApplyDestination : Command { +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) OutputReceiver* pReceiver; +#endif }; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(DriverCommandSubMixApplyDestination) == 0x20); +#else +static_assert(sizeof(DriverCommandSubMixApplyDestination) == 0x18); +#endif struct DriverCommandSubMixUpdateMixVolume : Command { +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) OutputReceiver* pReceiver; +#endif s32 srcBus; s32 srcChannel; s32 dstBus; s32 dstChannel; }; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(DriverCommandSubMixUpdateMixVolume) == 0x30); +#else +static_assert(sizeof(DriverCommandSubMixUpdateMixVolume) == 0x28); +#endif struct DriverCommandAuxBusVolume : Command { AuxBus bus; @@ -494,6 +512,8 @@ class DriverCommand : CommandManager { public: static void ProcessCommandList(Command* commandList); + DriverCommand(); + void Initialize(void* commandBuffer, size_t commandBufferSize); void RequestProcessCommand(); diff --git a/include/nn/atk/detail/thread/atk_SoundThread.h b/include/nn/atk/detail/thread/atk_SoundThread.h index bd50ed3b..385555c3 100644 --- a/include/nn/atk/detail/thread/atk_SoundThread.h +++ b/include/nn/atk/detail/thread/atk_SoundThread.h @@ -5,10 +5,10 @@ #include #include +#include #include #include #include -#include #include #include @@ -19,15 +19,16 @@ struct AtkStateAndParameterUpdateLock {}; class SoundThread : fnd::Thread::Handler { public: enum Message { - Message_HwCallback = 0x10000000, - Message_Shutdown = 0x20000000, + Message_HwCallback = 0x10000000, + Message_Shutdown = 0x20000000, Message_ForceWakeup = 0x30000000, }; using ProfileFunc = void(*)(os::Tick*); constexpr static u32 ThreadMessageBuffferSize = 32; - constexpr static u64 RendererEventWaitTimeoutMilliSeconds = 100; + + constexpr static u32 RendererEventWaitTimeoutMilliSeconds = 100; class SoundFrameCallback { public: @@ -106,6 +107,9 @@ class SoundThread : fnd::Thread::Handler { void RegisterSoundThreadUpdateProfileReader(SoundThreadUpdateProfileReader& profileReader); void UnregisterSoundThreadUpdateProfileReader(SoundThreadUpdateProfileReader& profileReader); + void RegisterSoundThreadInfoRecorder(ThreadInfoRecorder& recorder); + void UnregisterSoundThreadInfoRecorder(ThreadInfoRecorder& recorder); + void FrameProcess(UpdateType updateType); void RecordPerformanceInfo(audio::PerformanceInfo* src, os::Tick beginTick, @@ -120,7 +124,7 @@ class SoundThread : fnd::Thread::Handler { private: fnd::Thread m_Thread; os::MessageQueue m_BlockingQueue; - std::uintptr_t m_MsgBuffer[32]; + std::uintptr_t m_MsgBuffer[ThreadMessageBuffferSize]; u32 m_AxCallbackCounter; fnd::CriticalSection m_CriticalSection; fnd::CriticalSection m_UpdateAtkStateAndParameterSection; diff --git a/include/nn/atk/detail/thread/atk_TaskManager.h b/include/nn/atk/detail/thread/atk_TaskManager.h index e43ac07b..52c010fb 100644 --- a/include/nn/atk/detail/thread/atk_TaskManager.h +++ b/include/nn/atk/detail/thread/atk_TaskManager.h @@ -19,6 +19,9 @@ class TaskManager { TaskPriority_High, }; + constexpr static u32 PriorityCount = 3; + constexpr static u32 ThreadMessageBufferSize = 32; + TaskManager(); ~TaskManager(); @@ -46,11 +49,11 @@ class TaskManager { void CancelWaitTask(); private: - TaskList m_TaskList[3]; + TaskList m_TaskList[PriorityCount]; bool m_IsWaitTaskCancel; fnd::CriticalSection m_CriticalSection; os::MessageQueue m_BlockingQueue; - std::uintptr_t m_MsgBuffer[32]; + std::uintptr_t m_MsgBuffer[ThreadMessageBufferSize]; TaskProfileLogger m_TaskProfileLogger; }; static_assert(sizeof(TaskManager) == 0x1d8); diff --git a/include/nn/atk/detail/atk_BinaryFileFormat.h b/include/nn/atk/detail/util/atk_BinaryFileFormat.h similarity index 100% rename from include/nn/atk/detail/atk_BinaryFileFormat.h rename to include/nn/atk/detail/util/atk_BinaryFileFormat.h diff --git a/include/nn/atk/detail/atk_BinaryTypes.h b/include/nn/atk/detail/util/atk_BinaryTypes.h similarity index 100% rename from include/nn/atk/detail/atk_BinaryTypes.h rename to include/nn/atk/detail/util/atk_BinaryTypes.h diff --git a/include/nn/atk/detail/util/atk_CurveLfo.h b/include/nn/atk/detail/util/atk_CurveLfo.h index e81eaa10..ed90e6e2 100644 --- a/include/nn/atk/detail/util/atk_CurveLfo.h +++ b/include/nn/atk/detail/util/atk_CurveLfo.h @@ -3,6 +3,12 @@ #include namespace nn::atk::detail { +f32 CurveSine(f32 arg); +f32 CurveTriangle(f32 arg); +f32 CurveSaw(f32 arg); +f32 CurveSquare(f32 arg); +f32 CurveRandom(f32 arg); + struct CurveLfoParam { enum CurveType { CurveType_Min, @@ -19,6 +25,8 @@ struct CurveLfoParam { CurveType_Count = 0x80, }; + void Initialize(); + f32 depth; f32 speed; u32 delay; @@ -26,8 +34,6 @@ struct CurveLfoParam { u8 curve; u8 phase; u8 padding[1]; - - void Initialize(); }; static_assert(sizeof(CurveLfoParam) == 0x10); @@ -37,10 +43,13 @@ class CurveLfo { static void InitializeCurveTable(); + void RegisterUserCurve(CurveFunc curveFunc, u32); + void UnregisterUserCurve(u32); + void Reset(); void Update(s32 msec); - f32 GetValue(); + f32 GetValue() const; private: CurveLfoParam m_Param; @@ -52,4 +61,6 @@ class CurveLfo { u8 m_Padding[2]; }; static_assert(sizeof(CurveLfo) == 0x20); + +static CurveLfo::CurveFunc g_CurveFuncTable[5]; } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/util/atk_FrameHeap.h b/include/nn/atk/detail/util/atk_FrameHeap.h index a2862b69..0333dc9f 100644 --- a/include/nn/atk/detail/util/atk_FrameHeap.h +++ b/include/nn/atk/detail/util/atk_FrameHeap.h @@ -11,6 +11,8 @@ class FrameHeap { using DisposeCallback = void(*)(void*, size_t, void*); using HeapCallback = void(*)(void*); + constexpr static s32 HeapAlign = 64; + class Block { public: Block(); diff --git a/include/nn/atk/detail/util/atk_Util.h b/include/nn/atk/detail/util/atk_Util.h index 0c195a41..df860475 100644 --- a/include/nn/atk/detail/util/atk_Util.h +++ b/include/nn/atk/detail/util/atk_Util.h @@ -2,18 +2,33 @@ #include -#include -#include +#include +#include namespace nn::atk { class SoundArchive; +class SoundArchivePlayer; +class OutputReceiver; namespace detail { +class PlayerHeapDataManager; +class SoundArchiveLoader; +struct LoadItemInfo; struct Util { NN_NO_COPY(Util); NN_NO_MOVE(Util); - constexpr static u16 CalcLpfFreqTable[24] { + constexpr static s32 VolumeDbMin = -904; + constexpr static s32 VolumeDbMax = 60; + + constexpr static s32 PitchDivisionBit = 0b1000; + constexpr static s32 PitchDivisionRange = 256; + + constexpr static s32 CalcLpfFreqTableSize = 24; + constexpr static u32 CalcLpfFreqIntercept = 0x3E0ADE7F; + constexpr static u32 CalcLpfFreqThreshold = 0x3F666666; + + constexpr static u16 CalcLpfFreqTable[CalcLpfFreqTableSize] { 80, 100, 128, 160, 200, 256, 320, 400, 500, 640, 800, 1000, @@ -22,6 +37,9 @@ struct Util { 8000, 10240, 12800, 16000 }; + constexpr static BiquadFilterCoefficients LowPassFilterCoefficientsTable32000[CalcLpfFreqTableSize] {}; + constexpr static BiquadFilterCoefficients LowPassFilterCoefficientsTable48000[CalcLpfFreqTableSize] {}; + template class Singleton { public: @@ -36,7 +54,7 @@ struct Util { u8 padding[2]; s32 offset; }; - static_assert(sizeof(Reference) == 8); + static_assert(sizeof(Reference) == 0x8); struct ReferenceWithSize : Reference { u32 size; @@ -110,14 +128,22 @@ struct Util { }; struct LogBuffer { + constexpr static u32 LogCount = 64; + struct Element { + + void Print(); + s32 logId; s32 arg0; s32 arg1; }; static_assert(sizeof(Element) == 0xc); - Element element[64]; + void Log(s32 logId, s32 arg0, s32 arg1); + void Print(); + + Element element[LogCount]; s32 counter; }; static_assert(sizeof(LogBuffer) == 0x304); @@ -133,24 +159,49 @@ struct Util { }; static_assert(sizeof(WarningLogger) == 0x610); - u16 CalcLpfFreq(float scale); - BiquadFilterCoefficients CalcLowPassFilterCoefficients(s32 frequency, s32 sampleRate, + static u16 CalcLpfFreq(f32 scale); + static BiquadFilterCoefficients CalcLowPassFilterCoefficients(s32 frequency, s32 sampleRate, bool isTableUsed); - float CalcPanRatio(float pan, PanInfo* info, OutputMode mode); - float CalcSurroundPanRatio(float surroundPan, PanInfo* info); - float CalcPitchRatio(float pitch_); - float CalcVolumeRatio(float dB); - float CalcRandom(); + + static s32 FindLpfFreqTableIndex(s32); + + static f32 CalcPanRatio(f32 pan, PanInfo* info, OutputMode mode); + static f32 CalcSurroundPanRatio(f32 surroundPan, PanInfo* info); + static f32 CalcPitchRatio(f32 pitch_); + static f32 CalcVolumeRatio(f32 dB); + static f32 CalcRandom(); - WaveArchiveLoadStatus GetWaveArchiveOfBank(class LoadItemInfo* warcLoadInfo, - bool* isLoadIndividual, void* bankFile, - SoundArchive* arc, class SoundArchiveLoader* mgr); - void* GetWaveFileOfWaveSound(void* wsdFile, u32 index, SoundArchive* arc, SoundArchiveLoader* mgr); - size_t GetByteBySample(size_t samples, SampleFormat format); - size_t GetSampleByByte(size_t samples, SampleFormat format); + static void* GetWaveFile(u32, u32, const SoundArchive&, const SoundArchivePlayer&); + static void* GetWaveFile(u32, u32, const SoundArchive&, const PlayerHeapDataManager&); + + static WaveArchiveLoadStatus GetWaveArchiveOfBank(const LoadItemInfo& warcLoadInfo, + bool& isLoadIndividual, const void* bankFile, + const SoundArchive& arc, const SoundArchiveLoader& mgr); + + static void* GetWaveFileOfWaveSound(const void* wsdFile, u32 index, + const SoundArchive& arc, const SoundArchiveLoader& mgr); + + static s32 GetOutputReceiverMixBufferIndex(OutputReceiver*, s32, s32); + + static size_t GetSampleByByte(size_t samples, SampleFormat format); + static size_t GetByteBySample(size_t samples, SampleFormat format); - bool IsValidMemoryForDsp(void* ptr, size_t size); + static bool IsValidMemoryForDsp(const void* ptr, size_t size); }; +static const f32 NoteTable[12] {}; +static const f32 PitchTable[Util::PitchDivisionRange] {}; +static const f32 Decibel2RatioTable[965] {}; + +static const f32 Pan2RatioTableSqrtSurround[257] {}; +static const f32 Pan2RatioTableSinCosSurround[257] {}; +static const f32 Pan2RatioTableLinearSurround[257] {}; + +static const f32 Pan2RatioTableSqrt[257] {}; +static const f32 Pan2RatioTableSinCos[257] {}; +static const f32 Pan2RatioTableLinear[257] {}; + +static const f32* PanTableTable[3] {Pan2RatioTableSqrt, Pan2RatioTableSinCos, Pan2RatioTableLinear}; +static const f32* PanTableTableForSurround[3] {Pan2RatioTableSqrtSurround, Pan2RatioTableSinCosSurround, Pan2RatioTableLinearSurround}; } // namespace nn::atk::detail } // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/detail/atk_WavBinary.h b/include/nn/atk/detail/util/atk_WavBinary.h similarity index 100% rename from include/nn/atk/detail/atk_WavBinary.h rename to include/nn/atk/detail/util/atk_WavBinary.h diff --git a/include/nn/atk/detail/atk_WavOutFileStream.h b/include/nn/atk/detail/util/atk_WavOutFileStream.h similarity index 100% rename from include/nn/atk/detail/atk_WavOutFileStream.h rename to include/nn/atk/detail/util/atk_WavOutFileStream.h diff --git a/include/nn/atk/detail/voice/atk_Channel.h b/include/nn/atk/detail/voice/atk_Channel.h index a5b53cd7..c795ee4e 100644 --- a/include/nn/atk/detail/voice/atk_Channel.h +++ b/include/nn/atk/detail/voice/atk_Channel.h @@ -81,7 +81,9 @@ class Channel { void SetSweepParam(f32 sweepPitch, s32 sweepTime, bool autoUpdate); void SetBiquadFilter(s32 type, f32 value); +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) void SetTvAdditionalParam(OutputAdditionalParam* param); +#endif position_t GetCurrentPlayingSample(bool) const; @@ -117,7 +119,9 @@ class Channel { f32 m_BiquadValue; u32 m_OutputLineFlag; detail::OutputParam m_TvParam; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) detail::OutputAdditionalParam* m_pTvAdditionalParam; +#endif f32 m_UserPitch; f32 m_SweepPitch; s32 m_SweepCounter; diff --git a/include/nn/atk/detail/voice/atk_ChannelManager.h b/include/nn/atk/detail/voice/atk_ChannelManager.h index 2a0718af..a80ca9af 100644 --- a/include/nn/atk/detail/voice/atk_ChannelManager.h +++ b/include/nn/atk/detail/voice/atk_ChannelManager.h @@ -15,7 +15,7 @@ class ChannelManager { size_t GetObjectSize(const SoundInstanceConfig& config); size_t GetRequiredMemSize(s32 channelCount, const SoundInstanceConfig& config); - void Initialize(void* mem, size_t memSize, s32 channelCount, const SoundInstanceConfig* config); + void Initialize(void* mem, size_t memSize, s32 channelCount, const SoundInstanceConfig& config); void Finalize(); void Free(Channel* channel); @@ -30,10 +30,16 @@ class ChannelManager { ChannelList m_ChannelList; bool m_IsInitialized; s32 m_ChannelCount; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) InstancePool* m_pAdditionalParamPool; +#endif BufferPool* m_pAdditionalParamBufferPool; std::size_t m_AdditionalParamBufferSizePerChannel; SoundInstanceConfig m_SoundInstanceConfig; }; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(ChannelManager) == 0x50); +#else +static_assert(sizeof(ChannelManager) == 0x48); +#endif } // namespace nn::atk::detail::driver \ No newline at end of file diff --git a/include/nn/atk/detail/voice/atk_LowLevelVoice.h b/include/nn/atk/detail/voice/atk_LowLevelVoice.h index 87320cc5..b7ec5dd6 100644 --- a/include/nn/atk/detail/voice/atk_LowLevelVoice.h +++ b/include/nn/atk/detail/voice/atk_LowLevelVoice.h @@ -2,19 +2,25 @@ #include +#include #include #include +#include +#include #include -#include #include -#include namespace nn::atk::detail { class Voice; class alignas(256) LowLevelVoice { public: + LowLevelVoice(); + + void Initialize(); + void Finalize(); + void FreeAllWaveBuffer(); bool IsAvailable() const; @@ -26,6 +32,7 @@ class alignas(256) LowLevelVoice { void UpdateState(OutputMode outputMode); void UpdateStatePlay(bool isRun, OutputMode outputMode); + void UpdateStateStop(bool isRun); void UpdateStatePause(bool isRun, OutputMode outputMode); void SetPriority(s32 priority); @@ -51,9 +58,9 @@ class alignas(256) LowLevelVoice { void UpdateMixVolumeOnSubMix(const OutputMix& outputMix, OutputMode outputMode); void UpdateMixVolumeOnFinalMix(const OutputMix& outputMix, OutputMode outputMode); - void SetVoiceMixVolume(f32, s32); + static f32 GetClampedVoiceVolume(f32 volume); - static f32 GetClampedVoiceVolume(f32); + void SetVoiceMixVolume(f32 volume, s32 dstIndex); private: AdpcmParam m_AdpcmParam; @@ -66,7 +73,9 @@ class alignas(256) LowLevelVoice { u32 m_SampleRate; SampleFormat m_SampleFormat; position_t m_PlayPosition; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) OutputReceiver* m_pOutputReceiver; +#endif WaveBuffer* m_WaveBufferListBegin; WaveBuffer* m_WaveBufferListEnd; WaveBuffer* m_LastAppendBuffer; @@ -77,6 +86,8 @@ static_assert(sizeof(LowLevelVoice) == 0x100); class LowLevelVoiceAllocator { public: + constexpr static u32 Unassigned = -1; + LowLevelVoiceAllocator(); std::size_t GetRequiredMemSize(s32 voiceCount); @@ -90,7 +101,7 @@ class LowLevelVoiceAllocator { u64 GetVoiceArrayIndex(LowLevelVoice* pVoice); void FreeVoice(LowLevelVoice* pVoice); - s32* GetDroppedVoiceCount(); + s32* GetDroppedVoiceCount() const; private: void* m_pVoiceArray{}; diff --git a/include/nn/atk/detail/voice/atk_MultiVoice.h b/include/nn/atk/detail/voice/atk_MultiVoice.h index c4bb420b..83580cef 100644 --- a/include/nn/atk/detail/voice/atk_MultiVoice.h +++ b/include/nn/atk/detail/voice/atk_MultiVoice.h @@ -24,13 +24,13 @@ class MultiVoice { using VoiceCallback = void(*)(MultiVoice*,VoiceCallbackStatus,void*); - constexpr static u32 UpdateStart = 1; - constexpr static u32 UpdatePause = 2; - constexpr static u32 UpdateSrc = 4; - constexpr static u32 UpdateMix = 8; - constexpr static u32 UpdateLpf = 16; - constexpr static u32 UpdateBiquad = 32; - constexpr static u32 UpdateVe = 64; + constexpr static u32 UpdateStart = 0b0000001; + constexpr static u32 UpdatePause = 0b0000010; + constexpr static u32 UpdateSrc = 0b0000100; + constexpr static u32 UpdateMix = 0b0001000; + constexpr static u32 UpdateLpf = 0b0010000; + constexpr static u32 UpdateBiquad = 0b0100000; + constexpr static u32 UpdateVe = 0b1000000; constexpr static u32 PriorityNoDrop = 255; @@ -56,7 +56,9 @@ class MultiVoice { constexpr static f32 SendMax = 1.0; explicit MultiVoice(); +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) explicit MultiVoice(OutputAdditionalParam* pAdditionalParam); +#endif ~MultiVoice(); bool Alloc(s32 channelCount, s32 priority, VoiceCallback callback, void* callbackData); @@ -96,32 +98,43 @@ class MultiVoice { void SetPriority(s32 priority); void SetOutputLine(u32 lineFlag); void SetOutputParamImpl(const OutputParam& in, const OutputParam& out); - void SetOutputAdditionalParamImpl(SendArray* pAdditionalSend, - BusMixVolumePacket* pBusMixVolumePacket, - OutputBusMixVolume* pBusMixVolume, - VolumeThroughModePacket* pVolumeThroughModePacket); - void SetOutputBusMixVolumeImpl(BusMixVolumePacket* in, - OutputBusMixVolume* busMixVolume, - BusMixVolumePacket* out); +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) + void SetOutputAdditionalParamImpl(const SendArray* pAdditionalSend, + const BusMixVolumePacket* pBusMixVolumePacket, + const OutputBusMixVolume* pBusMixVolume, + const VolumeThroughModePacket* pVolumeThroughModePacket); +#endif + void SetOutputBusMixVolumeImpl(const BusMixVolumePacket& in, + const OutputBusMixVolume& busMixVolume, + const BusMixVolumePacket& out); + void SetOutputVolumeThroughModePacketImpl(const VolumeThroughModePacket&, + const VolumeThroughModePacket&); void SetTvParam(const OutputParam& param); - void SetTvAdditionalParam(OutputAdditionalParam* param); - void SetTvAdditionalParam(SendArray* pAdditionalSend, - BusMixVolumePacket* pBusMixVolumePacket, - OutputBusMixVolume* pBusMixVolume, - VolumeThroughModePacket* pVolumeThroughModePacket); +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) + void SetTvAdditionalParam(const OutputAdditionalParam& param); + void SetTvAdditionalParam(const SendArray* pAdditionalSend, + const BusMixVolumePacket* pBusMixVolumePacket, + const OutputBusMixVolume* pBusMixVolume, + const VolumeThroughModePacket* pVolumeThroughModePacket); void SetOutputReceiver(OutputReceiver* pOutputReceiver); +#endif void SetSubMixIndex(s32 subMixIndex); +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) void CalcPreMixVolume(PreMixVolume* mix, const OutputParam& param, s32 channelIndex, OutputDevice device); +#else void CalcPreMixVolume(PreMixVolume* mix, const OutputParam& param, OutputAdditionalParam* pAdditionalParam, s32 channelIndex, OutputDevice device); +#endif void CalcTvMix(OutputMix* mix, const PreMixVolume& pre); void CalcMixImpl(OutputMix* mix, u32 outputDeviceIndex, const OutputParam& param, const PreMixVolume& pre); +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) void CalcMixImpl(OutputMix* mix, u32 outputDeviceIndex, const OutputParam& param, OutputAdditionalParam* pAdditionalParam, const PreMixVolume& pre); +#endif MultiVoice* detail_GetSdkVoice(s32) const; @@ -166,12 +179,20 @@ class MultiVoice { s32 m_Priority; u32 m_OutputLineFlag; OutputParam m_TvParam; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) OutputAdditionalParam* m_pTvAdditionalParam; +#endif SampleFormat m_Format; std::uintptr_t m_VoiceUser; UpdateType m_UpdateType; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) OutputReceiver* m_pOutputReceiver; +#endif util::IntrusiveListNode m_LinkNode; }; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(MultiVoice) == 0x298); +#else +static_assert(sizeof(MultiVoice) == 0x270); +#endif } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/voice/atk_Voice.h b/include/nn/atk/detail/voice/atk_Voice.h index 962c271e..ec8e4303 100644 --- a/include/nn/atk/detail/voice/atk_Voice.h +++ b/include/nn/atk/detail/voice/atk_Voice.h @@ -27,6 +27,8 @@ class Voice { void AppendWaveBuffer(WaveBuffer* waveBuffer); + void FreeAllWaveBuffer(); + void UpdateParam(); position_t GetPlayPosition() const; @@ -43,7 +45,9 @@ class Voice { SampleFormat m_SampleFormat; u32 m_SampleRate; AdpcmParam m_AdpcmParam; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) OutputReceiver* m_pOutputReceiver; +#endif u32 m_VoiceId; position_t m_PlayPosition; u32 m_VoiceInfoEnableFlag; @@ -52,7 +56,11 @@ class Voice { WaveBuffer* m_WaveBufferListEnd; LowLevelVoice* m_pLowLevelVoice; }; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(Voice) == 0xe0); +#else +static_assert(sizeof(Voice) == 0xd8); +#endif class VirtualVoiceManager : Util::Singleton { public: @@ -61,10 +69,10 @@ class VirtualVoiceManager : Util::Singleton { constexpr static u32 VirtualVoiceCount = 256; constexpr static u32 VirtualVoiceElementCount = 8; + void Initialize(); + bool AllocVirtualVoice(); void FreeVirtualVoice(u32); - - void Initialize(); void UpdateVoiceInfo(); @@ -72,11 +80,11 @@ class VirtualVoiceManager : Util::Singleton { s32 GetUnreleasedLowLevelVoiceCount() const; private: - u32 m_VirtualVoiceAllocationTable[8]; + u32 m_VirtualVoiceAllocationTable[VirtualVoiceElementCount]; u32 m_VoiceInfoTableRead; - LowLevelVoice* m_LowLevelVoiceTable[256]; - VoiceInfo m_VoiceInfoTable[2][256]; - util::BitFlagSet<256, void> m_VoiceInfoDirtyTable[2]; + LowLevelVoice* m_LowLevelVoiceTable[VirtualVoiceCount]; + VoiceInfo m_VoiceInfoTable[2][VirtualVoiceCount]; + util::BitFlagSet m_VoiceInfoDirtyTable[2]; }; static_assert(sizeof(VirtualVoiceManager) == 0x4868); } // namespace nn::atk::voice \ No newline at end of file diff --git a/include/nn/atk/detail/thread/atk_VoiceCommand.h b/include/nn/atk/detail/voice/atk_VoiceCommand.h similarity index 92% rename from include/nn/atk/detail/thread/atk_VoiceCommand.h rename to include/nn/atk/detail/voice/atk_VoiceCommand.h index ff03e101..456846df 100644 --- a/include/nn/atk/detail/thread/atk_VoiceCommand.h +++ b/include/nn/atk/detail/voice/atk_VoiceCommand.h @@ -1,5 +1,7 @@ #pragma once +#include + #include #include @@ -9,9 +11,15 @@ struct VoiceCommandPlay : Command { SampleFormat sampleFormat; u32 sampleRate; AdpcmParam adpcmParam; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) OutputReceiver* pOutputReceiver; +#endif }; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(VoiceCommandPlay) == 0x50); +#else +static_assert(sizeof(VoiceCommandPlay) == 0x48); +#endif struct VoiceCommandPause : Command { u32 voiceId; diff --git a/include/nn/atk/detail/wsd/atk_WaveSound.h b/include/nn/atk/detail/wsd/atk_WaveSound.h index 151f6cec..a2630dcd 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSound.h +++ b/include/nn/atk/detail/wsd/atk_WaveSound.h @@ -60,5 +60,9 @@ class WaveSound : BasicSound { u32 m_ChannelCount; driver::WaveSoundPlayer m_PlayerInstance; }; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(WaveSound) == 0x3e0); +#else +static_assert(sizeof(WaveSound) == 0x3b8); +#endif } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/wsd/atk_WaveSoundFile.h b/include/nn/atk/detail/wsd/atk_WaveSoundFile.h index 62dd56e1..22769474 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSoundFile.h +++ b/include/nn/atk/detail/wsd/atk_WaveSoundFile.h @@ -6,16 +6,21 @@ namespace nn::atk::detail { struct WaveSoundFile { struct InfoBlock; struct FileHeader : Util::SoundFileHeader { - InfoBlock* GetInfoBlock(); + + InfoBlock* GetInfoBlock() const; + }; struct WaveSoundData; struct InfoBlockBody { + + WaveSoundData* GetWaveSoundData(u32 index) const; + Util::ReferenceTable* GetWaveSoundDataReferenceTable() const; + + Util::WaveIdTable* GetWaveIdTable() const; + Util::Reference toWaveIdTable; Util::Reference toWaveSoundDataReferenceTable; - - WaveSoundData* GetWaveSoundData(u32 index); - Util::WaveIdTable* GetWaveIdTable(); }; static_assert(sizeof(InfoBlockBody) == 0x10); @@ -25,48 +30,63 @@ struct WaveSoundFile { }; static_assert(sizeof(InfoBlock) == 0x18); - struct NoteInfo; struct WaveSoundInfo; + struct TrackInfo; + struct NoteInfo; struct WaveSoundData { + + WaveSoundInfo* GetWaveSoundInfo() const; + + Util::ReferenceTable* GetTrackInfoReferenceTable() const; + Util::ReferenceTable* GetNoteInfoReferenceTable() const; + + TrackInfo* GetTrackInfo(u32 index) const; + NoteInfo* GetNoteInfo(u32 index) const; + Util::Reference toWaveSoundInfo; Util::Reference toTrackInfoReferenceTable; Util::Reference toNoteInfoReferenceTable; - - WaveSoundInfo* GetWaveSoundInfo(); - NoteInfo* GetNoteInfo(u32 index); }; static_assert(sizeof(WaveSoundData) == 0x18); struct WaveSoundInfo { - Util::BitFlag optionParameter; - u8 GetPan(); - s8 GetSurroundPan(); - f32 GetPitch(); - void GetSendValue(u8* mainSend, u8* fxSend, u8 fxSendCount); - AdshrCurve* GetAdshrCurve(); - u8 GetLpfFreq(); - u8 GetBiquadType(); - u8 GetBiquadValue(); - }; - static_assert(sizeof(WaveSoundInfo) == 0x4); + u8 GetPan() const; + s8 GetSurroundPan() const; + f32 GetPitch() const; + void GetSendValue(u8* mainSend, u8* fxSend, u8 fxSendCount) const; + AdshrCurve* GetAdshrCurve() const; + u8 GetLpfFreq() const; + u8 GetBiquadType() const; + u8 GetBiquadValue() const; - struct NoteInfo { - u32 waveIdTableIndex; Util::BitFlag optionParameter; - - u8 GetOriginalKey(); - u8 GetVolume(); - u8 GetPan(); - u8 GetSurroundPan(); - f32 GetPitch(); - AdshrCurve* GetAdshrCurve(); }; - static_assert(sizeof(NoteInfo) == 0x8); + static_assert(sizeof(WaveSoundInfo) == 0x4); + struct NoteEvent; struct TrackInfo { + + Util::ReferenceTable* GetNoteEventReferenceTable() const; + NoteEvent* GetNoteEvent(u32 index) const; + Util::Reference toNoteEventReferenceTable; }; static_assert(sizeof(TrackInfo) == 0x8); + + struct NoteInfo { + + u8 GetOriginalKey() const; + u8 GetVolume() const; + u8 GetPan() const; + u8 GetSurroundPan() const; + f32 GetPitch() const; + f32 GetSendValue(u8*, u8**, u8) const; + AdshrCurve* GetAdshrCurve() const; + + u32 waveIdTableIndex; + Util::BitFlag optionParameter; + }; + static_assert(sizeof(NoteInfo) == 0x8); }; } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/wsd/atk_WaveSoundFileReader.h b/include/nn/atk/detail/wsd/atk_WaveSoundFileReader.h index 6a4aee86..5416b723 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSoundFileReader.h +++ b/include/nn/atk/detail/wsd/atk_WaveSoundFileReader.h @@ -30,6 +30,8 @@ static_assert(sizeof(WaveSoundNoteInfo) == 0x18); class WaveSoundFileReader { public: + constexpr static s32 SignatureFile = 0x44535746; // FWSD + explicit WaveSoundFileReader(const void* waveSoundFile); s32 GetWaveSoundCount() const; diff --git a/include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h b/include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h index 58a84061..6872f520 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h +++ b/include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h @@ -36,7 +36,7 @@ class WaveSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::PlayerCa constexpr static u32 PauseReleaseValue = 127; constexpr static u32 MuteReleaseValue = 127; - constexpr static u8 DefaultPriority = 64; + constexpr static u32 DefaultPriority = 64; struct StartInfo { s32 index; @@ -78,7 +78,7 @@ class WaveSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::PlayerCa void Prepare(const StartInfo& info, const PrepareArg& arg); void PrepareForPlayerHeap(const PrepareArg& arg); - void RequestLoad(const StartInfo& info, const PrepareArg& arg); + void RequestLoad(const StartInfo& info, const WaveSoundLoader::Arg& arg); void Start() override; void Stop() override; @@ -133,6 +133,10 @@ class WaveSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::PlayerCa WaveSoundLoader* m_pLoader; WaveSoundLoader::Arg m_LoaderArg; }; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(WaveSoundPlayer) == 0x1a0); +#else +static_assert(sizeof(WaveSoundPlayer) == 0x190); +#endif } // namespace nn::atk::detail::driver } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h b/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h index 2114fcd7..f6730c5f 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h +++ b/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h @@ -22,10 +22,13 @@ class WaveSoundRuntime { void Update(); +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) WaveSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, BasicSound::AmbientInfo* ambientArgInfo); +#else WaveSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, BasicSound::AmbientInfo* ambientArgInfo, OutputReceiver* pOutputReceiver); +#endif SoundStartable::StartResult PrepareImpl(const SoundArchive* pSoundArchive, const SoundDataManager* pSoundDataManager, diff --git a/include/nn/atk/effect/atk_EffectAux.h b/include/nn/atk/effect/atk_EffectAux.h index 814b4587..e80d5b5c 100644 --- a/include/nn/atk/effect/atk_EffectAux.h +++ b/include/nn/atk/effect/atk_EffectAux.h @@ -2,13 +2,14 @@ #include +#include #include #include #include #include #include -#include +#include namespace nn::atk { class OutputMixer; @@ -45,29 +46,33 @@ class EffectAux { std::size_t GetRequiredMemSize(const audio::AudioRendererParameter& parameter) const; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) bool AddEffect(audio::AudioRendererConfig* pConfig, const audio::AudioRendererParameter& parameter, - OutputMixer* pOutputMixer); - + audio::FinalMixType* pFinalMixType); bool AddEffect(audio::AudioRendererConfig* pConfig, const audio::AudioRendererParameter& parameter, - audio::FinalMixType* pFinalMixType); + audio::SubMixType* pSubMixType); +#else + bool AddEffect(audio::AudioRendererConfig* pConfig, + const audio::AudioRendererParameter& parameter, + OutputMixer* pOutputMixer); +#endif void SplitEffectBuffer(BufferSet* pBufferSet, void* effectBuffer, std::size_t effectBufferSize); - bool AddEffect(audio::AudioRendererConfig* pConfig, - const audio::AudioRendererParameter& parameter, - audio::SubMixType* pSubMixType); - void SetEffectInputOutput(const s8* input, const s8* output, s32 inputCount, s32 outputCount); - void RemoveEffect(audio::AudioRendererConfig* pConfig, OutputMixer* pOutputMixer); +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) void RemoveEffect(audio::AudioRendererConfig* pConfig, audio::FinalMixType* pFinalMixType); void RemoveEffect(audio::AudioRendererConfig* pConfig, audio::SubMixType* pSubMixType); +#else + void RemoveEffect(audio::AudioRendererConfig* pConfig, OutputMixer* pOutputMixer); +#endif bool SetChannelCount(s32 channelCount); - bool SetChannelIndex(ChannelIndex* pChannel, s32 channelCount); + bool SetChannelIndex(const ChannelIndex* pChannel, s32 channelCount); s32 GetChannelCount() const; void GetChannelIndex(ChannelIndex* pChannel, s32 channelCount) const; diff --git a/include/nn/atk/effect/atk_EffectBase.h b/include/nn/atk/effect/atk_EffectBase.h index 379b1a46..56b0763d 100644 --- a/include/nn/atk/effect/atk_EffectBase.h +++ b/include/nn/atk/effect/atk_EffectBase.h @@ -1,11 +1,12 @@ #pragma once +#include #include #include #include #include -#include +#include namespace nn::atk { class OutputMixer; @@ -42,13 +43,21 @@ class EffectBase { virtual void OnChangeOutputMode(); virtual void SetEffectBuffer(void* effectBuffer, std::size_t effectBufferSize); +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) bool AddEffect(audio::AudioRendererConfig* pConfig, audio::FinalMixType* pFinalMixType); bool AddEffect(audio::AudioRendererConfig* pConfig, audio::SubMixType* pFinalMixType); +#else + bool AddEffect(audio::AudioRendererConfig* pConfig, OutputMixer* pOutputMixer); +#endif void SetEffectInputOutput(const s8* input, const s8* output, s32 inputCount, s32 outputCount); +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) void RemoveEffect(audio::AudioRendererConfig* pConfig, audio::FinalMixType* pFinalMixType); void RemoveEffect(audio::AudioRendererConfig* pConfig, audio::SubMixType* pSubMixType); +#else + void RemoveEffect(audio::AudioRendererConfig* pConfig, OutputMixer* pOutputMixer); +#endif static s32 ConvertChannelModeToInt(ChannelMode channelMode); diff --git a/include/nn/atk/fnd/basis/atkfnd_HeapBase.h b/include/nn/atk/fnd/basis/atkfnd_HeapBase.h index c7cde758..d0a83a33 100644 --- a/include/nn/atk/fnd/basis/atkfnd_HeapBase.h +++ b/include/nn/atk/fnd/basis/atkfnd_HeapBase.h @@ -34,9 +34,10 @@ class HeapBase : util::IntrusiveListBaseNode { constexpr static u32 ErrorPrint = 1; - constexpr static u8 MIN_ALIGNMENT = 4; + constexpr static u32 MIN_ALIGNMENT = 4; HeapList* FindListContainHeap(); + static HeapBase* FindContainHeap(HeapList* pList, const void* memBlock); static HeapBase* FindContainHeap(const void* memBlock); static HeapBase* FindParentHeap(HeapBase* pChild); @@ -71,4 +72,7 @@ class HeapBase : util::IntrusiveListBaseNode { u32 m_Attribute; }; static_assert(sizeof(HeapBase) == 0x40); + +static u8 sFillVals[12]; +static HeapBase::HeapList sRootList {}; } // namespace nn::atk::detail::fnd \ No newline at end of file diff --git a/include/nn/atk/fnd/basis/atkfnd_Time.h b/include/nn/atk/fnd/basis/atkfnd_Time.h index 2710b3fb..7cc2bbcc 100644 --- a/include/nn/atk/fnd/basis/atkfnd_Time.h +++ b/include/nn/atk/fnd/basis/atkfnd_Time.h @@ -3,6 +3,11 @@ #include namespace nn::atk::detail::fnd { +class Time { +public: + s64 Current(); +}; + class TimeSpan { public: using TickType = s64; @@ -19,9 +24,4 @@ class TimeSpan { TickType m_TickSpan; }; static_assert(sizeof(TimeSpan) == 0x8); - -class Time { -public: - s64 Current(); -}; } // namespace nn::atk::detail::fnd \ No newline at end of file diff --git a/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h b/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h index 079fc876..a243f79c 100644 --- a/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h +++ b/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h @@ -41,28 +41,28 @@ class FileStreamImpl : FileStream { bool CanWrite() const override; bool CanSeek() const override; + void EnableCache(void* buffer, size_t length) override; + void DisableCache() override; + void ValidateAlignment(void* buf); FndResult Open(const char* filePath, AccessMode accessMode) override; void Close() override; + void Flush() override; bool IsOpened() const override; size_t GetSize() const override; - position_t GetCurrentPosition() const override; + s32 GetIoBufferAlignment() const override; size_t ReadDirect(void* buf, size_t length, FndResult* result); - size_t WriteDirect(void* buf, size_t length, FndResult* result); + size_t WriteDirect(const void* buf, size_t length, FndResult* result); FndResult SeekDirect(position_t offset, fnd::Stream::SeekOrigin origin); - - void Flush() override; - void EnableCache(void* buffer, size_t length) override; - void DisableCache() override; + position_t GetCurrentPosition() const override; + bool IsCacheEnabled() const override; - s32 GetIoBufferAlignment() const override; - bool CanSetFsAccessLog() const override; void* SetFsAccessLog(FsAccessLog* pFsAccessLog) override; diff --git a/include/nn/atk/fnd/io/atkfnd_StreamCache.h b/include/nn/atk/fnd/io/atkfnd_StreamCache.h index 35878826..67d44b8c 100644 --- a/include/nn/atk/fnd/io/atkfnd_StreamCache.h +++ b/include/nn/atk/fnd/io/atkfnd_StreamCache.h @@ -7,6 +7,8 @@ struct FsAccessLog; class StreamCache { public: + constexpr static position_t InvalidPosition = -1; + StreamCache(); StreamCache(Stream* sourceStream, void* buffer, std::size_t length); @@ -23,7 +25,7 @@ class StreamCache { void ClearCache(); - std::size_t Write(void* buf, std::size_t length, FndResult* result); + std::size_t Write(const void* buf, std::size_t length, FndResult* result); std::size_t GetWritableCacheLength(std::size_t) const; diff --git a/include/nn/atk/fnd/os/atkfnd_Thread.h b/include/nn/atk/fnd/os/atkfnd_Thread.h index fc879c47..d904ba2b 100644 --- a/include/nn/atk/fnd/os/atkfnd_Thread.h +++ b/include/nn/atk/fnd/os/atkfnd_Thread.h @@ -60,6 +60,14 @@ class Thread { using Handle = os::ThreadType; + constexpr static u64 InvalidId = 0xFFFFFFFF; + + constexpr static u32 DefaultThreadPriority = 16; + constexpr static u32 MinThreadPriority = 0; + constexpr static u32 MaxThreadPriority = 31; + + constexpr static u32 StackAlignment = 4096; + class Handler { public: virtual ~Handler() = 0; @@ -68,6 +76,7 @@ class Thread { static_assert(sizeof(Handler) == 0x8); struct RunArgs { + RunArgs(); bool IsValid() const; @@ -87,7 +96,9 @@ class Thread { ~Thread(); bool Run(const RunArgs& args); + void WaitForExit(); + void Release(); void SetState(State state); @@ -104,18 +115,18 @@ class Thread { static void Sleep(const TimeSpan& timeSpan); - bool Create(const Handle& handle, const s64& id, const RunArgs& args); + bool Create(const Handle& handle, s64& id, const RunArgs& args); void Detach(); - bool IsTerminated() const; - void SetName(const char* name); void SetAffinityMask(s32 idealCoreNumber, AffinityMask value); void Resume(); void Join(); + bool IsTerminated() const; + private: u32 m_State; Handle m_Handle; diff --git a/include/nn/atk/submix/atk_ChannelMixVolume.h b/include/nn/atk/submix/atk_ChannelMixVolume.h index e588b46d..17ad816d 100644 --- a/include/nn/atk/submix/atk_ChannelMixVolume.h +++ b/include/nn/atk/submix/atk_ChannelMixVolume.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk { class ChannelMixVolume { @@ -8,6 +8,7 @@ class ChannelMixVolume { constexpr static u8 ChannelCountMax = 24; ChannelMixVolume(); + void InitializeChannelVolume(); explicit ChannelMixVolume(const MixVolume& mixVolume); diff --git a/include/nn/atk/submix/atk_SubMix.h b/include/nn/atk/submix/atk_SubMix.h index b1c33c8d..fd1ce9f3 100644 --- a/include/nn/atk/submix/atk_SubMix.h +++ b/include/nn/atk/submix/atk_SubMix.h @@ -13,20 +13,6 @@ class HardwareManager; class SubMix : OutputMixer { public: - class VolumeData { - public: - VolumeData(); - - bool Update(); - - private: - detail::MoveValue m_Volume; - bool m_IsMute; - bool m_IsPrevMute; - bool m_IsDirtyFlag; - }; - static_assert(sizeof(VolumeData) == 0x14); - class SubMixParam { public: SubMixParam(); @@ -62,8 +48,23 @@ class SubMix : OutputMixer { bool m_IsSoundSendClampEnabledArray[24]; }; static_assert(sizeof(SubMixParam) == 0x38); + + class VolumeData { + public: + VolumeData(); + + bool Update(); + + private: + detail::MoveValue m_Volume; + bool m_IsMute; + bool m_IsPrevMute; + bool m_IsDirtyFlag; + }; + static_assert(sizeof(VolumeData) == 0x14); SubMix(); + static size_t GetRequiredMemorySize(s32 srcBusCount, s32 srcChannelCount, s32 dstBusCount, s32 dstChannelCount); static size_t GetRequiredMemorySize(s32 srcBusCount, s32 srcChannelCount, diff --git a/include/nn/atk/util/atk_AudioRendererPerformanceReader.h b/include/nn/atk/util/atk_AudioRendererPerformanceReader.h index 9105d936..9f58ecce 100644 --- a/include/nn/atk/util/atk_AudioRendererPerformanceReader.h +++ b/include/nn/atk/util/atk_AudioRendererPerformanceReader.h @@ -19,7 +19,7 @@ class AudioRendererPerformanceReader { static size_t GetRequiredMemorySize(s32); - void Initialize(s32, void*, u64); + void Initialize(s32, void*, size_t); PerformanceInfo* ReadPerformanceInfo(); void Record(const void* performanceFrameBuffer, size_t performanceFrameBufferSize, os::Tick tick); diff --git a/include/nn/atk/util/atk_DeviceOutRecorder.h b/include/nn/atk/util/atk_DeviceOutRecorder.h index daeed1b8..47cc76a0 100644 --- a/include/nn/atk/util/atk_DeviceOutRecorder.h +++ b/include/nn/atk/util/atk_DeviceOutRecorder.h @@ -6,9 +6,9 @@ #include #include -#include +#include +#include #include -#include namespace nn::atk { class DeviceOutRecorder : detail::fnd::Thread::Handler { @@ -45,7 +45,7 @@ class DeviceOutRecorder : detail::fnd::Thread::Handler { }; static_assert(sizeof(InitializationOptions) == 0x8); - struct RecorderBuffer { + class RecorderBuffer { struct WriteState { u32 channelIndex; u32 writtenSampleCount; @@ -68,6 +68,7 @@ class DeviceOutRecorder : detail::fnd::Thread::Handler { void SetReadBlockSamples(u32 readBlockSamples); + private: s16* m_SampleBuffer; u32 m_MaxBufferSamples; u32 m_MaxSamples; diff --git a/include/nn/atk/util/atk_TaskProfileReader.h b/include/nn/atk/util/atk_TaskProfileReader.h index 91ffaff0..32565053 100644 --- a/include/nn/atk/util/atk_TaskProfileReader.h +++ b/include/nn/atk/util/atk_TaskProfileReader.h @@ -26,9 +26,14 @@ struct TaskProfile { u64 GetBeginTick() const; u64 GetEndTick() const; + f32 GetRemainingCachePercentage() const; + size_t GetCachedLength() const; + + detail::driver::StreamSoundPlayer* GetStreamSoundPlayer() const; + void SetTick(const os::Tick& beginTick, const os::Tick& endTick); - void SetData(os::Tick* beginTick, os::Tick* endTick, - detail::IStreamDataDecoder::CacheProfile* cacheProfile); + void SetData(const os::Tick& beginTick, const os::Tick& endTick, + const detail::IStreamDataDecoder::CacheProfile& cacheProfile); private: u64 m_BeginTick; @@ -45,16 +50,23 @@ struct TaskProfile { TimeSpan GetTotalTime() const; u64 GetBeginTick() const; u64 GetEndTick() const; + + f32 GetRemainingCachePercentage() const; + size_t GetCachedLength() const; + TimeSpan GetDecodeTime() const; s32 GetDecodedSampleCount() const; + TimeSpan GetFsAccessTime(); std::size_t GetFsReadSize(); - void SetData(os::Tick* beginTick, os::Tick* endTick, + detail::driver::StreamSoundPlayer* GetStreamSoundPlayer() const; + + void SetData(const os::Tick& beginTick, const os::Tick& endTick, detail::IStreamDataDecoder::DecodeProfile* decodeProfile); - void SetData(os::Tick* beginTick, os::Tick* endTick, - detail::IStreamDataDecoder::DecodeProfile* decodeProfile, - detail::IStreamDataDecoder::CacheProfile* cacheProfile); + void SetData(const os::Tick& beginTick, const os::Tick& endTick, + const detail::IStreamDataDecoder::DecodeProfile& decodeProfile, + const detail::IStreamDataDecoder::CacheProfile& cacheProfile); private: u64 m_BeginTick; From bc10661649e705d84fe8e013144d4319cd2d0caf Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 2 Mar 2026 18:00:42 -0300 Subject: [PATCH 174/785] util: Incorporate changes from master branch --- include/nn/util/util_IntrusiveList.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/nn/util/util_IntrusiveList.h b/include/nn/util/util_IntrusiveList.h index 486a7fc2..23868b7a 100644 --- a/include/nn/util/util_IntrusiveList.h +++ b/include/nn/util/util_IntrusiveList.h @@ -378,5 +378,4 @@ class IntrusiveListMemberNodeTraits { return reinterpret_cast(&(reinterpret_cast(0)->*Member)); } }; - } // namespace nn::util From de98145ca7b99c83df6cc3154e08b2fb7f85cf45 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 2 Mar 2026 20:42:07 -0300 Subject: [PATCH 175/785] atk: Modify `SoundActorParam` for versions below 4.0.0 --- include/nn/atk/detail/atk_AdvancedWaveSound.h | 2 +- include/nn/atk/detail/atk_BasicSound.h | 11 +++++++++++ include/nn/atk/detail/seq/atk_SequenceSound.h | 2 +- include/nn/atk/detail/wsd/atk_WaveSound.h | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/nn/atk/detail/atk_AdvancedWaveSound.h b/include/nn/atk/detail/atk_AdvancedWaveSound.h index 77b578ea..ef58a05a 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSound.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSound.h @@ -46,6 +46,6 @@ class AdvancedWaveSound : BasicSound { #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(AdvancedWaveSound) == 0x9b0); #else -static_assert(sizeof(AdvancedWaveSound) == 0x988); +static_assert(sizeof(AdvancedWaveSound) == 0x980); #endif } // namespace nn::atk::detail diff --git a/include/nn/atk/detail/atk_BasicSound.h b/include/nn/atk/detail/atk_BasicSound.h index 21d63124..7b3d9f33 100644 --- a/include/nn/atk/detail/atk_BasicSound.h +++ b/include/nn/atk/detail/atk_BasicSound.h @@ -151,10 +151,16 @@ struct SoundActorParam { f32 tvVolume; f32 tvPan; f32 lpf; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) s32 biquadFilterType; f32 biquadFilterValue; +#endif }; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(SoundActorParam) == 0x1c); +#else +static_assert(sizeof(SoundActorParam) == 0x14); +#endif class BasicSound { public: @@ -435,5 +441,10 @@ class BasicSound { static s32 g_LastInstanceId; }; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) +static_assert(sizeof(BasicSound) == 0x210); +#else +static_assert(sizeof(BasicSound) == 0x1f0); +#endif } // namespace detail } // namespace nn::atk diff --git a/include/nn/atk/detail/seq/atk_SequenceSound.h b/include/nn/atk/detail/seq/atk_SequenceSound.h index 292bbb0d..54746d2b 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSound.h +++ b/include/nn/atk/detail/seq/atk_SequenceSound.h @@ -108,6 +108,6 @@ class SequenceSound : BasicSound { #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(SequenceSound) == 0x5a0); #else -static_assert(sizeof(SequenceSound) == 0x578); +static_assert(sizeof(SequenceSound) == 0x570); #endif } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/wsd/atk_WaveSound.h b/include/nn/atk/detail/wsd/atk_WaveSound.h index a2630dcd..776a5c3c 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSound.h +++ b/include/nn/atk/detail/wsd/atk_WaveSound.h @@ -63,6 +63,6 @@ class WaveSound : BasicSound { #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) static_assert(sizeof(WaveSound) == 0x3e0); #else -static_assert(sizeof(WaveSound) == 0x3b8); +static_assert(sizeof(WaveSound) == 0x3b0); #endif } // namespace nn::atk::detail \ No newline at end of file From 7059d3f984d541ea5ee064725c055e40e3d7f9c4 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 3 Mar 2026 11:51:44 -0300 Subject: [PATCH 176/785] atk: Delete `AuxBus.h` --- include/nn/atk/AuxBus.h | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 include/nn/atk/AuxBus.h diff --git a/include/nn/atk/AuxBus.h b/include/nn/atk/AuxBus.h deleted file mode 100644 index a954c4b5..00000000 --- a/include/nn/atk/AuxBus.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include - -namespace nn { -namespace atk { -enum class AuxBus : s32 { AuxBus_A, AuxBus_B, AuxBus_C }; -} -} // namespace nn From efa02514e693778a666fc8b48d7e48d7ec7769e4 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 3 Mar 2026 11:52:28 -0300 Subject: [PATCH 177/785] atk: Fix `detail::DecodeDspAdpcm` --- include/nn/atk/atk_Adpcm.h | 6 +++--- include/nn/atk/detail/atk_AddonSoundArchiveContainer.h | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/nn/atk/atk_Adpcm.h b/include/nn/atk/atk_Adpcm.h index f7dd0a53..720973b5 100644 --- a/include/nn/atk/atk_Adpcm.h +++ b/include/nn/atk/atk_Adpcm.h @@ -18,8 +18,8 @@ struct AdpcmContextNotAligned { static_assert(sizeof(AdpcmContextNotAligned) == 0x6); namespace detail { -void DecodeDspAdpcm(position_t playPosition, AdpcmContext* context, - AdpcmParam* param, void* adpcmData, size_t decodeSamples, - s16* dest); +void DecodeDspAdpcm(position_t playPosition, AdpcmContext& context, + const AdpcmParam& param, const void* adpcmData, + size_t decodeSamples, s16* dest); }; } // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h b/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h index 8b125d4b..cf2453bc 100644 --- a/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h +++ b/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include From 8e8135d711309cf7c9c5363d20c8b21d03796438 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 4 Mar 2026 11:47:48 -0300 Subject: [PATCH 178/785] atk: Define `detail::BankFile::RegionParameter` --- include/nn/atk/detail/seq/atk_BankFile.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/nn/atk/detail/seq/atk_BankFile.h b/include/nn/atk/detail/seq/atk_BankFile.h index e888c78b..98dd8efb 100644 --- a/include/nn/atk/detail/seq/atk_BankFile.h +++ b/include/nn/atk/detail/seq/atk_BankFile.h @@ -64,5 +64,24 @@ struct BankFile { Util::BitFlag optionParameter; }; static_assert(sizeof(VelocityRegion) == 0x8); + + struct RegionParameter { + u8 originalKey; + u8 padding1[3]; + u8 volume; + u8 padding2[3]; + u8 pan; + s8 surroundPan; + u8 padding3[2]; + f32 pitch; + bool isIgnoreNoteOff; + u8 keyGroup; + u8 interpolationType; + u8 padding4[1]; + u32 offset; + Util::Reference refToAdshrCurve; + AdshrCurve adshrCurve; + }; + static_assert(sizeof(RegionParameter) == 0x28); }; } // namespace nn::atk::detail \ No newline at end of file From 32806c402a234cfeb5986be084beba4990a2cf83 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 6 Mar 2026 13:22:17 -0300 Subject: [PATCH 179/785] atk: Incorporate more versions differences --- include/nn/atk/atk_FsSoundArchive.h | 4 +++ include/nn/atk/atk_SoundArchivePlayer.h | 8 ++--- include/nn/atk/atk_SoundPlayer.h | 6 ++-- include/nn/atk/detail/atk_AdvancedWaveSound.h | 6 ++-- .../nn/atk/detail/atk_AdvancedWaveSoundFile.h | 12 ++++---- .../atk/detail/atk_AdvancedWaveSoundPlayer.h | 16 ++++++++-- .../atk/detail/atk_AdvancedWaveSoundRuntime.h | 6 +++- include/nn/atk/detail/atk_BasicSound.h | 12 ++++---- include/nn/atk/detail/atk_BasicSoundPlayer.h | 8 +++-- include/nn/atk/detail/atk_NoteOnCallback.h | 6 ++-- .../nn/atk/detail/atk_PlayerHeapDataManager.h | 2 +- include/nn/atk/detail/atk_RegionManager.h | 10 +++++++ include/nn/atk/detail/atk_SoundArchiveFile.h | 2 ++ .../atk/detail/atk_SoundArchiveFileReader.h | 5 +++- .../nn/atk/detail/atk_SoundInstanceManager.h | 2 ++ include/nn/atk/detail/atk_StartInfoReader.h | 6 ++-- include/nn/atk/detail/atk_WaveArchiveFile.h | 1 + include/nn/atk/detail/seq/atk_SequenceSound.h | 6 ++-- .../atk/detail/seq/atk_SequenceSoundPlayer.h | 8 ++--- .../atk/detail/seq/atk_SequenceSoundRuntime.h | 4 +++ include/nn/atk/detail/strm/atk_StreamSound.h | 6 ++-- .../atk/detail/strm/atk_StreamSoundLoader.h | 10 ++++++- .../atk/detail/strm/atk_StreamSoundPlayer.h | 21 +++++++++++-- .../atk/detail/strm/atk_StreamSoundRuntime.h | 4 +++ .../nn/atk/detail/thread/atk_DriverCommand.h | 27 ++++++++++------- .../nn/atk/detail/thread/atk_SoundThread.h | 8 +++++ .../nn/atk/detail/thread/atk_TaskManager.h | 7 +++++ include/nn/atk/detail/voice/atk_Channel.h | 6 ++-- .../nn/atk/detail/voice/atk_ChannelManager.h | 8 ++--- .../nn/atk/detail/voice/atk_LowLevelVoice.h | 4 ++- include/nn/atk/detail/voice/atk_MultiVoice.h | 6 ++-- include/nn/atk/detail/voice/atk_Voice.h | 10 ++++--- .../nn/atk/detail/voice/atk_VoiceCommand.h | 6 ++-- include/nn/atk/detail/wsd/atk_WaveSound.h | 6 ++-- .../nn/atk/detail/wsd/atk_WaveSoundPlayer.h | 11 +++++-- .../nn/atk/detail/wsd/atk_WaveSoundRuntime.h | 4 +++ include/nn/atk/util/atk_ProfileReader.h | 14 +++++++++ include/nn/atk/util/atk_TaskProfileReader.h | 30 ++++++++++++++++++- 38 files changed, 234 insertions(+), 84 deletions(-) diff --git a/include/nn/atk/atk_FsSoundArchive.h b/include/nn/atk/atk_FsSoundArchive.h index 8f541747..2ef5a183 100644 --- a/include/nn/atk/atk_FsSoundArchive.h +++ b/include/nn/atk/atk_FsSoundArchive.h @@ -49,5 +49,9 @@ class FsSoundArchive : SoundArchive { char m_SoundArchiveFullPath[SoundArchive::FilePathMax]; detail::fnd::CriticalSection m_FileOpenCloseLock; }; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) +static_assert(sizeof(FsSoundArchive) == 0x618); +#else static_assert(sizeof(FsSoundArchive) == 0x610); +#endif } // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/atk_SoundArchivePlayer.h b/include/nn/atk/atk_SoundArchivePlayer.h index 113644fa..8f08a120 100644 --- a/include/nn/atk/atk_SoundArchivePlayer.h +++ b/include/nn/atk/atk_SoundArchivePlayer.h @@ -205,12 +205,12 @@ class SoundArchivePlayer : SoundStartable { bool m_IsAdvancedWaveSoundEnabled; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) OutputReceiver* m_pDefaultOutputReceiver; -#endif u8 m_Padding[1]; +#endif }; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) -static_assert(sizeof(SoundArchivePlayer) == 0x310); +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) +static_assert(sizeof(SoundArchivePlayer) == 0x2e0); #else -static_assert(sizeof(SoundArchivePlayer) == 0x300); +static_assert(sizeof(SoundArchivePlayer) == 0x310); #endif } // namespace nn::atk diff --git a/include/nn/atk/atk_SoundPlayer.h b/include/nn/atk/atk_SoundPlayer.h index 881a1521..113065ba 100644 --- a/include/nn/atk/atk_SoundPlayer.h +++ b/include/nn/atk/atk_SoundPlayer.h @@ -99,9 +99,9 @@ class SoundPlayer { #endif bool m_IsFirstComeBased; }; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) -static_assert(sizeof(SoundPlayer) == 0x88); -#else +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(SoundPlayer) == 0x78); +#else +static_assert(sizeof(SoundPlayer) == 0x88); #endif } // namespace nn::atk diff --git a/include/nn/atk/detail/atk_AdvancedWaveSound.h b/include/nn/atk/detail/atk_AdvancedWaveSound.h index ef58a05a..52b02afd 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSound.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSound.h @@ -43,9 +43,9 @@ class AdvancedWaveSound : BasicSound { bool m_IsInitialized; u8 m_Padding[3]; }; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) -static_assert(sizeof(AdvancedWaveSound) == 0x9b0); -#else +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(AdvancedWaveSound) == 0x980); +#else +static_assert(sizeof(AdvancedWaveSound) == 0x9b0); #endif } // namespace nn::atk::detail diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h b/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h index b7b2c9c7..e5c7d875 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h @@ -8,11 +8,12 @@ namespace nn::atk::detail { struct AdvancedWaveSoundFile { struct WaveSoundTrack; struct InfoBlockBody { - u32 offsetToTrackTableReference; - BinaryTypes::Reference toTrackTable; BinaryTypes::ReferenceTable* GetTrackReferenceTable() const; WaveSoundTrack* GetWaveSoundTrack(s32 index) const; + + u32 offsetToTrackTableReference; + BinaryTypes::Reference toTrackTable; }; static_assert(sizeof(InfoBlockBody) == 0x8); @@ -24,12 +25,13 @@ struct AdvancedWaveSoundFile { struct WaveSoundClip; struct WaveSoundTrack { - u32 offsetToCurveTableReference; - u32 offsetToClipTableReference; - BinaryTypes::Reference toClipTable; BinaryTypes::ReferenceTable* GetClipReferenceTable() const; WaveSoundClip* GetWaveSoundClip(s32 index) const; + + u32 offsetToCurveTableReference; + u32 offsetToClipTableReference; + BinaryTypes::Reference toClipTable; }; struct WaveSoundClip { diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h b/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h index fdb17581..368baf5d 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h @@ -34,10 +34,17 @@ class AdvancedWaveSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { struct PrepareParameter { SoundArchive::AdvancedWaveSoundInfo advancedWaveSoundInfo; UpdateType updateType; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) + s32 subMixIndex; +#endif void* pAwsdFile; void* pWarcFile; }; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) + static_assert(sizeof(PrepareParameter) == 0x20); +#else static_assert(sizeof(PrepareParameter) == 0x18); +#endif AdvancedWaveSoundPlayer(); ~AdvancedWaveSoundPlayer() override; @@ -84,14 +91,17 @@ class AdvancedWaveSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { void* m_pAwsdFile; void* m_pWarcFile; UpdateType m_UpdateType; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) + s32 m_SubMixIndex; +#endif u32 m_CurrentTime; bool m_IsPrepared; bool m_IsInitialized; bool m_IsRegisterPlayerCallback; }; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) -static_assert(sizeof(AdvancedWaveSoundPlayer) == 0x778); -#else +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(AdvancedWaveSoundPlayer) == 0x768); +#else +static_assert(sizeof(AdvancedWaveSoundPlayer) == 0x778); #endif } // namespace nn::atk::detail::driver \ No newline at end of file diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h b/include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h index 55129aa6..dbc9ed44 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h @@ -14,7 +14,7 @@ class AdvancedWaveSoundRuntime { AdvancedWaveSoundRuntime(); ~AdvancedWaveSoundRuntime(); - void Initialize(s32 soundCount, void** pOutAllocatedAddr, const void* endAddr); + bool Initialize(s32 soundCount, void** pOutAllocatedAddr, const void* endAddr); void Finalize(); static size_t GetRequiredMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, @@ -48,5 +48,9 @@ class AdvancedWaveSoundRuntime { private: AdvancedWaveSoundInstanceManager m_InstanceManager; }; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) +static_assert(sizeof(AdvancedWaveSoundRuntime) == 0x30); +#else static_assert(sizeof(AdvancedWaveSoundRuntime) == 0x38); +#endif } // namespace nn::atk::detail diff --git a/include/nn/atk/detail/atk_BasicSound.h b/include/nn/atk/detail/atk_BasicSound.h index 7b3d9f33..96c18e5d 100644 --- a/include/nn/atk/detail/atk_BasicSound.h +++ b/include/nn/atk/detail/atk_BasicSound.h @@ -156,10 +156,10 @@ struct SoundActorParam { f32 biquadFilterValue; #endif }; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) -static_assert(sizeof(SoundActorParam) == 0x1c); -#else +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(SoundActorParam) == 0x14); +#else +static_assert(sizeof(SoundActorParam) == 0x1c); #endif class BasicSound { @@ -441,10 +441,10 @@ class BasicSound { static s32 g_LastInstanceId; }; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) -static_assert(sizeof(BasicSound) == 0x210); -#else +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(BasicSound) == 0x1f0); +#else +static_assert(sizeof(BasicSound) == 0x210); #endif } // namespace detail } // namespace nn::atk diff --git a/include/nn/atk/detail/atk_BasicSoundPlayer.h b/include/nn/atk/detail/atk_BasicSoundPlayer.h index afc24ccc..1c17d11c 100644 --- a/include/nn/atk/detail/atk_BasicSoundPlayer.h +++ b/include/nn/atk/detail/atk_BasicSoundPlayer.h @@ -8,6 +8,7 @@ namespace nn::atk::detail::driver { struct PlayerParamSet { + void Initialize(); f32 volume; @@ -20,6 +21,7 @@ struct PlayerParamSet { u32 outputLineFlag; OutputParam tvParam; }; +static_assert(sizeof(PlayerParamSet) == 0x70); class BasicSoundPlayer { public: @@ -53,9 +55,9 @@ class BasicSoundPlayer { #endif PlayerHeapDataManager* m_pPlayerHeapDataManager; }; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) -static_assert(sizeof(BasicSoundPlayer) == 0xc0); -#else +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(BasicSoundPlayer) == 0xb0); +#else +static_assert(sizeof(BasicSoundPlayer) == 0xc0); #endif } //namespace nn::atk::detail::driver \ No newline at end of file diff --git a/include/nn/atk/detail/atk_NoteOnCallback.h b/include/nn/atk/detail/atk_NoteOnCallback.h index 86e83c73..232f0e45 100644 --- a/include/nn/atk/detail/atk_NoteOnCallback.h +++ b/include/nn/atk/detail/atk_NoteOnCallback.h @@ -19,10 +19,10 @@ struct NoteOnInfo { #endif UpdateType updateType; }; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) -static_assert(sizeof(NoteOnInfo) == 0x38); -#else +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(NoteOnInfo) == 0x30); +#else +static_assert(sizeof(NoteOnInfo) == 0x38); #endif class NoteOnCallback { diff --git a/include/nn/atk/detail/atk_PlayerHeapDataManager.h b/include/nn/atk/detail/atk_PlayerHeapDataManager.h index 1a37d53b..10118349 100644 --- a/include/nn/atk/detail/atk_PlayerHeapDataManager.h +++ b/include/nn/atk/detail/atk_PlayerHeapDataManager.h @@ -31,7 +31,7 @@ class PlayerHeapDataManager : driver::DisposeCallback, SoundArchiveLoader { void* GetFileAddressImpl(SoundArchive::FileId fileId) const override; private: - FileAddress m_FileAddress[9]; + FileAddress m_FileAddress[FileAddressCount]; bool m_IsInitialized; bool m_IsFinalized; }; diff --git a/include/nn/atk/detail/atk_RegionManager.h b/include/nn/atk/detail/atk_RegionManager.h index 9d203fe1..d6ecf2ef 100644 --- a/include/nn/atk/detail/atk_RegionManager.h +++ b/include/nn/atk/detail/atk_RegionManager.h @@ -32,7 +32,9 @@ class RegionManager { position_t current; position_t begin; position_t end; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) bool isEnabled; +#endif }; void Initialize(); @@ -63,12 +65,20 @@ class RegionManager { StreamRegionCallback m_StreamRegionCallbackFunc; void* m_StreamRegionCallbackArg; s32 m_CurrentRegionNo; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) char* m_pCurrentRegionName; +#endif Region m_CurrentRegion; position_t m_AdpcmContextForStartOffsetFrame; AdpcmContext m_AdpcmContextForStartOffset[16]; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) char m_CurrentRegionName[64]; +#endif }; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) +static_assert(sizeof(RegionManager) == 0x440); +#else static_assert(sizeof(RegionManager) == 0x4c0); +#endif } // namespace nn::atk::detail } // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/detail/atk_SoundArchiveFile.h b/include/nn/atk/detail/atk_SoundArchiveFile.h index 10ae3d7f..cb71738d 100644 --- a/include/nn/atk/detail/atk_SoundArchiveFile.h +++ b/include/nn/atk/detail/atk_SoundArchiveFile.h @@ -354,5 +354,7 @@ class SoundArchiveFile { Util::BitFlag optionParameter; }; static_assert(sizeof(FileInfo) == 0xc); + + struct FileBlock {}; }; } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/atk_SoundArchiveFileReader.h b/include/nn/atk/detail/atk_SoundArchiveFileReader.h index fa39b157..6fb95c69 100644 --- a/include/nn/atk/detail/atk_SoundArchiveFileReader.h +++ b/include/nn/atk/detail/atk_SoundArchiveFileReader.h @@ -64,9 +64,12 @@ class SoundArchiveFileReader { void* GetAttachedGroupTable(u32) const; // unknown return type private: - detail::SoundArchiveFile::FileHeader m_pHeader; + detail::SoundArchiveFile::FileHeader m_Header; detail::SoundArchiveFile::StringBlockBody* m_pStringBlockBody; detail::SoundArchiveFile::InfoBlockBody* m_pInfoBlockBody; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) + detail::SoundArchiveFile::FileBlock* m_pFileBlock; +#endif }; struct SoundArchiveFilesHook { diff --git a/include/nn/atk/detail/atk_SoundInstanceManager.h b/include/nn/atk/detail/atk_SoundInstanceManager.h index 214f83e8..8797c6d3 100644 --- a/include/nn/atk/detail/atk_SoundInstanceManager.h +++ b/include/nn/atk/detail/atk_SoundInstanceManager.h @@ -26,7 +26,9 @@ class SoundInstanceManager { private: void* m_pBuffer; std::size_t m_BufferSize; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) SoundInstanceConfig m_SoundInstanceConfig; +#endif PriorityList m_PriorityList; PriorityList m_FreeList; }; diff --git a/include/nn/atk/detail/atk_StartInfoReader.h b/include/nn/atk/detail/atk_StartInfoReader.h index 25db7d3e..c84db918 100644 --- a/include/nn/atk/detail/atk_StartInfoReader.h +++ b/include/nn/atk/detail/atk_StartInfoReader.h @@ -28,9 +28,9 @@ class StartInfoReader { OutputReceiver* m_pOutputReceiver; #endif }; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) -static_assert(sizeof(StartInfoReader) == 0x58); -#else +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(StartInfoReader) == 0x50); +#else +static_assert(sizeof(StartInfoReader) == 0x58); #endif } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/atk_WaveArchiveFile.h b/include/nn/atk/detail/atk_WaveArchiveFile.h index 660968c5..8e0f684e 100644 --- a/include/nn/atk/detail/atk_WaveArchiveFile.h +++ b/include/nn/atk/detail/atk_WaveArchiveFile.h @@ -9,6 +9,7 @@ struct WaveArchiveFile { struct InfoBlock; struct FileBlock; struct FileHeader : BinaryFileHeader { + InfoBlock* GetInfoBlock() const; u32 GetInfoBlockOffset() const; diff --git a/include/nn/atk/detail/seq/atk_SequenceSound.h b/include/nn/atk/detail/seq/atk_SequenceSound.h index 54746d2b..405cf9c9 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSound.h +++ b/include/nn/atk/detail/seq/atk_SequenceSound.h @@ -105,9 +105,9 @@ class SequenceSound : BasicSound { u8 m_Padding[1]; driver::SequenceSoundPlayer m_PlayerInstance; }; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) -static_assert(sizeof(SequenceSound) == 0x5a0); -#else +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(SequenceSound) == 0x570); +#else +static_assert(sizeof(SequenceSound) == 0x5a0); #endif } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h b/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h index 8653ea87..51b72906 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h +++ b/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h @@ -89,8 +89,8 @@ class SequenceSoundLoader { Arg m_Arg; PlayerHeap* m_pPlayerHeap; PlayerHeapDataManager* m_pPlayerHeapDataManager; - }; + static_assert(sizeof(FreePlayerHeapTask) == 0xc0); ~SequenceSoundLoader(); @@ -309,10 +309,10 @@ class SequenceSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::Play static s16 m_GlobalVariable[GlobalVariableCount]; static s32 m_SkipIntervalTickPerFrame; }; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) -static_assert(sizeof(SequenceSoundPlayer) == 0x368); -#else +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(SequenceSoundPlayer) == 0x358); +#else +static_assert(sizeof(SequenceSoundPlayer) == 0x368); #endif } // namespace nn::atk::detail::driver } // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h b/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h index e02c9e2f..a947befc 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h +++ b/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h @@ -112,5 +112,9 @@ class SequenceSoundRuntime { SoundArchiveManager* m_pSoundArchiveManager; SoundArchiveFilesHook* m_pSoundArchiveFilesHook; }; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) +static_assert(sizeof(SequenceSoundRuntime) == 0xe0); +#else static_assert(sizeof(SequenceSoundRuntime) == 0xe8); +#endif } // namespace nn::atk::detail diff --git a/include/nn/atk/detail/strm/atk_StreamSound.h b/include/nn/atk/detail/strm/atk_StreamSound.h index dd5f330c..d152ea64 100644 --- a/include/nn/atk/detail/strm/atk_StreamSound.h +++ b/include/nn/atk/detail/strm/atk_StreamSound.h @@ -76,9 +76,9 @@ class StreamSound : BasicSound { std::size_t m_CacheSize; driver::StreamSoundPlayer m_PlayerInstance; }; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) -static_assert(sizeof(StreamSound) == 0x11a40); -#else +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(StreamSound) == 0x11a00); +#else +static_assert(sizeof(StreamSound) == 0x11a40); #endif } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/strm/atk_StreamSoundLoader.h b/include/nn/atk/detail/strm/atk_StreamSoundLoader.h index 5f98db55..985bf63d 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundLoader.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundLoader.h @@ -283,16 +283,24 @@ class StreamSoundLoader { StreamCloseTask m_StreamCloseTask; StreamDataLoadTaskList m_StreamDataLoadTaskList; InstancePool m_StreamDataLoadTaskPool; - u8 m_StreamDataLoadTaskArea[7936]; + u8 m_StreamDataLoadTaskArea[0x1f00]; SampleFormat m_SampleFormat; AdpcmInfo m_AdpcmInfo[16]; u32 m_FileStreamBuffer[128]; IStreamDataDecoder* m_pStreamDataDecoder; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) + static IStreamDataDecoderManager* g_pStreamDataDecoderManager; +#else IStreamDataDecoderManager* m_pStreamDataDecoderManager; +#endif util::IntrusiveListNode m_LinkForLoaderManager; static u8 g_LoadBuffer[LoadBufferSize]; }; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) +static_assert(sizeof(StreamSoundLoader) == 0x35c0); +#else static_assert(sizeof(StreamSoundLoader) == 0x3640); +#endif } // namespace nn::atk::detail::driver } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h b/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h index 96ec48d6..03740e9a 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h @@ -71,6 +71,9 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { s32 delayTime; s32 delayCount; UpdateType updateType; +#if NN_SDK_VER < NN_MAKE_VER(4, 4 ,1) + u32 subMixIndex; +#endif StreamRegionCallback regionCallback; void* regionCallbackArg; char filePath[639]; @@ -105,17 +108,24 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { f32 pitch; u8 mainSend; u8 fxSend[3]; +#if NN_SDK_VER >= NN_MAKE_VER(4, 4 ,1) DecodeMode decodeMode; +#endif }; +#if NN_SDK_VER < NN_MAKE_VER(4, 4 ,1) + static_assert(sizeof(SetupArg) == 0x98); +#else static_assert(sizeof(SetupArg) == 0xa0); +#endif struct PrefetchIndexInfo { + + void Initialize(const StreamDataInfoDetail& streamDataInfo); + u32 lastBlockIndex; position_t loopStartInBlock; u32 loopStartBlockIndex; s32 loopBlockCount; - - void Initialize(const StreamDataInfoDetail& streamDataInfo); }; static_assert(sizeof(PrefetchIndexInfo) == 0x18); @@ -278,7 +288,9 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { bool m_IsStoppedByLoadingDelay; bool m_IsRegisterPlayerCallback; bool m_UseDelayCount; +#if NN_SDK_VER >= NN_MAKE_VER(5, 3, 0) u8 m_Padding1[2]; +#endif s32 m_LoopCounter; s32 m_PlayingBlockLoopCounter; s32 m_PrepareCounter; @@ -294,7 +306,9 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { s32 m_DelayCount; u16 m_AssignNumber; u8 m_FileType; +#if NN_SDK_VER >= NN_MAKE_VER(4, 4 ,1) DecodeMode m_DecodeMode; +#endif bool m_LoopFlag; u8 m_Padding2[2]; StreamDataInfoDetail m_StreamDataInfo; @@ -312,6 +326,9 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { StreamChannel m_Channels[16]; StreamTrack m_Tracks[8]; UpdateType m_UpdateType; +#if NN_SDK_VER < NN_MAKE_VER(4, 4 ,1) + u32 m_SubMixIndex; +#endif WaveBufferInfo m_WaveBufferInfo[32]; PrepareArg m_PrepareArg; bool m_IsSucceedPrepare; diff --git a/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h b/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h index 3f9ad7ec..eb5b81a3 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h @@ -67,5 +67,9 @@ class StreamSoundRuntime { SoundArchiveFilesHook* m_pSoundArchiveFilesHook; s32 m_StreamBlockCount; }; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) +static_assert(sizeof(StreamSoundRuntime) == 0xb0); +#else static_assert(sizeof(StreamSoundRuntime) == 0xb8); +#endif } // namespace nn::atk::detail diff --git a/include/nn/atk/detail/thread/atk_DriverCommand.h b/include/nn/atk/detail/thread/atk_DriverCommand.h index bc7835f6..1f7c8ee4 100644 --- a/include/nn/atk/detail/thread/atk_DriverCommand.h +++ b/include/nn/atk/detail/thread/atk_DriverCommand.h @@ -119,10 +119,10 @@ struct DriverCommandPlayerInit : Command { #endif bool* availableFlagPtr; }; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) -static_assert(sizeof(DriverCommandPlayerInit) == 0x30); -#else +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(DriverCommandPlayerInit) == 0x28); +#else +static_assert(sizeof(DriverCommandPlayerInit) == 0x30); #endif struct DriverCommandPlayerPanParam : Command { @@ -343,14 +343,21 @@ struct DriverCommandAdvancedWaveSoundPrepare : Command { driver::AdvancedWaveSoundPlayer* player; driver::AdvancedWaveSoundPlayer::PrepareParameter parameter; }; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) +static_assert(sizeof(DriverCommandAdvancedWaveSoundPrepare) == 0x40); +#else static_assert(sizeof(DriverCommandAdvancedWaveSoundPrepare) == 0x38); +#endif struct DriverCommandStreamSoundSetup : Command { driver::StreamSoundPlayer* player; driver::StreamSoundPlayer::SetupArg arg; }; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) +static_assert(sizeof(DriverCommandStreamSoundSetup) == 0xb8); +#else static_assert(sizeof(DriverCommandStreamSoundSetup) == 0xc0); - +#endif struct DriverCommandStreamSoundPrepare : Command { driver::StreamSoundPlayer* player; driver::StreamSoundPlayer::PrepareArg arg; @@ -443,10 +450,10 @@ struct DriverCommandSubMixApplyDestination : Command { OutputReceiver* pReceiver; #endif }; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) -static_assert(sizeof(DriverCommandSubMixApplyDestination) == 0x20); -#else +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(DriverCommandSubMixApplyDestination) == 0x18); +#else +static_assert(sizeof(DriverCommandSubMixApplyDestination) == 0x20); #endif struct DriverCommandSubMixUpdateMixVolume : Command { @@ -458,10 +465,10 @@ struct DriverCommandSubMixUpdateMixVolume : Command { s32 dstBus; s32 dstChannel; }; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) -static_assert(sizeof(DriverCommandSubMixUpdateMixVolume) == 0x30); -#else +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(DriverCommandSubMixUpdateMixVolume) == 0x28); +#else +static_assert(sizeof(DriverCommandSubMixUpdateMixVolume) == 0x30); #endif struct DriverCommandAuxBusVolume : Command { diff --git a/include/nn/atk/detail/thread/atk_SoundThread.h b/include/nn/atk/detail/thread/atk_SoundThread.h index 385555c3..4a0cb3f5 100644 --- a/include/nn/atk/detail/thread/atk_SoundThread.h +++ b/include/nn/atk/detail/thread/atk_SoundThread.h @@ -145,16 +145,24 @@ class SoundThread : fnd::Thread::Handler { std::size_t m_PerformanceFrameUpdateBufferSize; s32 m_CurrentPerformanceFrameBufferIndex; bool m_IsProfilingEnabled; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) ProfileFunc m_pSoundThreadProfileFunc; bool m_IsUserThreadRenderingEnabled; +#endif ProfileReaderList m_ProfileReaderList; AudioRendererPerformanceReader* m_pAudioRendererPerformanceReader; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) SoundThreadInfoRecorderList m_InfoRecorderList; fnd::CriticalSection m_LockRecordInfo; +#endif SoundThreadUpdateProfile m_LastUpdateProfile; SoundThreadUpdateProfileReaderList m_UpdateProfileReaderList; fnd::CriticalSection m_LockUpdateProfile; std::atomic_int m_RendererEventWaitTimeMilliSeconds; }; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) +static_assert(sizeof(SoundThread) == 0x4c8); +#else static_assert(sizeof(SoundThread) == 0x508); +#endif } // namespace nn::atk::detail::driver \ No newline at end of file diff --git a/include/nn/atk/detail/thread/atk_TaskManager.h b/include/nn/atk/detail/thread/atk_TaskManager.h index 52c010fb..d962b5fe 100644 --- a/include/nn/atk/detail/thread/atk_TaskManager.h +++ b/include/nn/atk/detail/thread/atk_TaskManager.h @@ -50,11 +50,18 @@ class TaskManager { private: TaskList m_TaskList[PriorityCount]; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) + Task* m_ActiveTask; +#endif bool m_IsWaitTaskCancel; fnd::CriticalSection m_CriticalSection; os::MessageQueue m_BlockingQueue; std::uintptr_t m_MsgBuffer[ThreadMessageBufferSize]; TaskProfileLogger m_TaskProfileLogger; }; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) +static_assert(sizeof(TaskManager) == 0x1e0); +#else static_assert(sizeof(TaskManager) == 0x1d8); +#endif } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/voice/atk_Channel.h b/include/nn/atk/detail/voice/atk_Channel.h index c795ee4e..69424c83 100644 --- a/include/nn/atk/detail/voice/atk_Channel.h +++ b/include/nn/atk/detail/voice/atk_Channel.h @@ -93,7 +93,7 @@ class Channel { void CallChannelCallback(ChannelCallbackStatus status); static Channel* AllocChannel(s32 voiceChannelCount, s32 priority, - ChannelCallback callback, void* callbackData); + ChannelCallback callback, void* callbackData); void FreeChannel(); void DetachChannel(); @@ -118,7 +118,7 @@ class Channel { f32 m_UserLpfFreq; f32 m_BiquadValue; u32 m_OutputLineFlag; - detail::OutputParam m_TvParam; + OutputParam m_TvParam; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) detail::OutputAdditionalParam* m_pTvAdditionalParam; #endif @@ -129,7 +129,7 @@ class Channel { f32 m_InitPan; f32 m_InitSurroundPan; f32 m_Tune; - detail::MoveValue m_SilenceVolume; + MoveValue m_SilenceVolume; f32 m_Cent; f32 m_CentPitch; s32 m_Length; diff --git a/include/nn/atk/detail/voice/atk_ChannelManager.h b/include/nn/atk/detail/voice/atk_ChannelManager.h index a80ca9af..ba66d783 100644 --- a/include/nn/atk/detail/voice/atk_ChannelManager.h +++ b/include/nn/atk/detail/voice/atk_ChannelManager.h @@ -32,14 +32,14 @@ class ChannelManager { s32 m_ChannelCount; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) InstancePool* m_pAdditionalParamPool; -#endif BufferPool* m_pAdditionalParamBufferPool; std::size_t m_AdditionalParamBufferSizePerChannel; SoundInstanceConfig m_SoundInstanceConfig; +#endif }; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) -static_assert(sizeof(ChannelManager) == 0x50); +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) +static_assert(sizeof(ChannelManager) == 0x30); #else -static_assert(sizeof(ChannelManager) == 0x48); +static_assert(sizeof(ChannelManager) == 0x50); #endif } // namespace nn::atk::detail::driver \ No newline at end of file diff --git a/include/nn/atk/detail/voice/atk_LowLevelVoice.h b/include/nn/atk/detail/voice/atk_LowLevelVoice.h index b7ec5dd6..852d65f6 100644 --- a/include/nn/atk/detail/voice/atk_LowLevelVoice.h +++ b/include/nn/atk/detail/voice/atk_LowLevelVoice.h @@ -73,7 +73,9 @@ class alignas(256) LowLevelVoice { u32 m_SampleRate; SampleFormat m_SampleFormat; position_t m_PlayPosition; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) + void* _c0; // 0xc0 +#else OutputReceiver* m_pOutputReceiver; #endif WaveBuffer* m_WaveBufferListBegin; diff --git a/include/nn/atk/detail/voice/atk_MultiVoice.h b/include/nn/atk/detail/voice/atk_MultiVoice.h index 83580cef..7c24b5e8 100644 --- a/include/nn/atk/detail/voice/atk_MultiVoice.h +++ b/include/nn/atk/detail/voice/atk_MultiVoice.h @@ -190,9 +190,9 @@ class MultiVoice { #endif util::IntrusiveListNode m_LinkNode; }; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) -static_assert(sizeof(MultiVoice) == 0x298); -#else +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(MultiVoice) == 0x270); +#else +static_assert(sizeof(MultiVoice) == 0x298); #endif } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/voice/atk_Voice.h b/include/nn/atk/detail/voice/atk_Voice.h index ec8e4303..1d02a0f4 100644 --- a/include/nn/atk/detail/voice/atk_Voice.h +++ b/include/nn/atk/detail/voice/atk_Voice.h @@ -45,7 +45,9 @@ class Voice { SampleFormat m_SampleFormat; u32 m_SampleRate; AdpcmParam m_AdpcmParam; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) + s32 m_SubMixIndex; +#else OutputReceiver* m_pOutputReceiver; #endif u32 m_VoiceId; @@ -56,10 +58,10 @@ class Voice { WaveBuffer* m_WaveBufferListEnd; LowLevelVoice* m_pLowLevelVoice; }; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) -static_assert(sizeof(Voice) == 0xe0); -#else +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(Voice) == 0xd8); +#else +static_assert(sizeof(Voice) == 0xe0); #endif class VirtualVoiceManager : Util::Singleton { diff --git a/include/nn/atk/detail/voice/atk_VoiceCommand.h b/include/nn/atk/detail/voice/atk_VoiceCommand.h index 456846df..431426e6 100644 --- a/include/nn/atk/detail/voice/atk_VoiceCommand.h +++ b/include/nn/atk/detail/voice/atk_VoiceCommand.h @@ -15,10 +15,10 @@ struct VoiceCommandPlay : Command { OutputReceiver* pOutputReceiver; #endif }; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) -static_assert(sizeof(VoiceCommandPlay) == 0x50); -#else +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(VoiceCommandPlay) == 0x48); +#else +static_assert(sizeof(VoiceCommandPlay) == 0x50); #endif struct VoiceCommandPause : Command { diff --git a/include/nn/atk/detail/wsd/atk_WaveSound.h b/include/nn/atk/detail/wsd/atk_WaveSound.h index 776a5c3c..7390f905 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSound.h +++ b/include/nn/atk/detail/wsd/atk_WaveSound.h @@ -60,9 +60,9 @@ class WaveSound : BasicSound { u32 m_ChannelCount; driver::WaveSoundPlayer m_PlayerInstance; }; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) -static_assert(sizeof(WaveSound) == 0x3e0); -#else +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(WaveSound) == 0x3b0); +#else +static_assert(sizeof(WaveSound) == 0x3e0); #endif } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h b/include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h index 6872f520..a62096ab 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h +++ b/include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h @@ -120,11 +120,16 @@ class WaveSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::PlayerCa s32 m_DelayCount; s32 m_Release; s32 m_WaveSoundParameterFlag; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) bool m_IsContextCalculationSkipMode; +#endif CurveLfoParam m_LfoParam; WaveSoundInfo m_WaveSoundInfo; Channel* m_pChannel; UpdateType m_UpdateType; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) + u32 m_SubMixIndex; +#endif u8 m_ResState; bool m_IsInitialized; bool m_IsRegisterPlayerCallback; @@ -133,10 +138,10 @@ class WaveSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::PlayerCa WaveSoundLoader* m_pLoader; WaveSoundLoader::Arg m_LoaderArg; }; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) -static_assert(sizeof(WaveSoundPlayer) == 0x1a0); -#else +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(WaveSoundPlayer) == 0x190); +#else +static_assert(sizeof(WaveSoundPlayer) == 0x1a0); #endif } // namespace nn::atk::detail::driver } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h b/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h index f6730c5f..39999b6b 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h +++ b/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h @@ -44,5 +44,9 @@ class WaveSoundRuntime { driver::WaveSoundLoaderManager m_WaveSoundLoaderManager; SoundArchiveFilesHook* m_pSoundArchiveFilesHook; }; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) +static_assert(sizeof(WaveSoundRuntime) == 0x80); +#else static_assert(sizeof(WaveSoundRuntime) == 0x88); +#endif } // namespace nn::atk::detail diff --git a/include/nn/atk/util/atk_ProfileReader.h b/include/nn/atk/util/atk_ProfileReader.h index 1f869dec..21a43e66 100644 --- a/include/nn/atk/util/atk_ProfileReader.h +++ b/include/nn/atk/util/atk_ProfileReader.h @@ -26,10 +26,19 @@ struct SoundProfile { u32 nwVoiceCount; u64 nwFrameProcessTick; TimeRange _additionalSubMixProcess; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) + TimeRange _voiceProcessTable[96]; + audio::NodeId _voiceIdTable[96]; +#else TimeRange _voiceProcessTable[192]; audio::NodeId _voiceIdTable[192]; +#endif }; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) +static_assert(sizeof(SoundProfile) == 0x818); +#else static_assert(sizeof(SoundProfile) == 0xf98); +#endif struct SoundThreadUpdateProfile { TimeRange soundThreadProcess; @@ -56,6 +65,11 @@ class ProfileReader { s32 m_ProfileBufferRead; s32 m_ProfileBufferWrite; }; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) +static_assert(sizeof(ProfileReader) == 0x10318); +#else +static_assert(sizeof(ProfileReader) == 0x1f318); +#endif using ProfileReaderList = util::IntrusiveList= NN_MAKE_VER(4, 0, 0) detail::driver::StreamSoundPlayer* GetStreamSoundPlayer() const; +#endif +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) void SetTick(const os::Tick& beginTick, const os::Tick& endTick); +#else void SetData(const os::Tick& beginTick, const os::Tick& endTick, const detail::IStreamDataDecoder::CacheProfile& cacheProfile); +#endif private: u64 m_BeginTick; u64 m_EndTick; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) position_t m_CacheStartPosition; std::size_t m_CachedLength; position_t m_CacheCurrentPosition; detail::driver::StreamSoundPlayer* m_pPlayer; +#endif }; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) + static_assert(sizeof(LoadStreamBlock) == 0x10); +#else static_assert(sizeof(LoadStreamBlock) == 0x30); +#endif class LoadOpusStreamBlock { public: @@ -59,28 +70,41 @@ struct TaskProfile { TimeSpan GetFsAccessTime(); std::size_t GetFsReadSize(); - + +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) detail::driver::StreamSoundPlayer* GetStreamSoundPlayer() const; +#endif +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) void SetData(const os::Tick& beginTick, const os::Tick& endTick, detail::IStreamDataDecoder::DecodeProfile* decodeProfile); +#else void SetData(const os::Tick& beginTick, const os::Tick& endTick, const detail::IStreamDataDecoder::DecodeProfile& decodeProfile, const detail::IStreamDataDecoder::CacheProfile& cacheProfile); +#endif private: u64 m_BeginTick; u64 m_EndTick; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) position_t m_CacheStartPosition; std::size_t m_CachedLength; position_t m_CacheCurrentPosition; +#endif u64 m_DecodeTick; u64 m_FsAccessTick; std::size_t m_FsReadSize; s32 m_DecodedSampleCount; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) detail::driver::StreamSoundPlayer* m_pPlayer; +#endif }; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) + static_assert(sizeof(LoadOpusStreamBlock) == 0x30); +#else static_assert(sizeof(LoadOpusStreamBlock) == 0x50); +#endif TaskProfileType type; union { @@ -88,7 +112,11 @@ struct TaskProfile { LoadOpusStreamBlock loadOpusStreamBlock; }; }; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) +static_assert(sizeof(TaskProfile) == 0x38); +#else static_assert(sizeof(TaskProfile) == 0x58); +#endif using TaskProfileReader = AtkProfileReader; From 372bfe99d61a13c24f4b84e0ceeedbd688c12ea8 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 6 Mar 2026 13:46:00 -0300 Subject: [PATCH 180/785] atk: Code cleanup --- include/nn/atk/atk_SoundArchivePlayer.h | 10 ++--- include/nn/atk/atk_SoundMemoryAllocatable.h | 2 +- include/nn/atk/atk_SoundStartable.h | 2 +- include/nn/atk/detail/atk_BasicSound.h | 4 +- .../nn/atk/detail/atk_BusMixVolumePacket.h | 4 +- .../atk/detail/atk_DisposeCallbackManager.h | 2 +- .../nn/atk/detail/atk_IStreamDataDecoder.h | 6 +-- include/nn/atk/detail/atk_LoaderManager.h | 2 +- include/nn/atk/detail/atk_NoteOnCallback.h | 2 +- .../nn/atk/detail/atk_OutputAdditionalParam.h | 4 +- include/nn/atk/detail/atk_PlayerHeap.h | 12 +++--- .../atk/detail/atk_SoundArchiveFileReader.h | 8 ++-- .../nn/atk/detail/atk_SoundInstanceManager.h | 4 +- .../atk/detail/atk_VolumeThroughModePacket.h | 4 +- .../seq/atk_MmlSequenceTrackAllocator.h | 2 +- .../nn/atk/detail/strm/atk_StreamBufferPool.h | 6 +-- include/nn/atk/detail/strm/atk_StreamSound.h | 2 +- .../nn/atk/detail/strm/atk_StreamSoundFile.h | 16 ++++--- .../atk/detail/strm/atk_StreamSoundLoader.h | 42 +++++++++---------- .../atk/detail/strm/atk_StreamSoundPlayer.h | 10 ++--- .../atk/detail/strm/atk_StreamSoundRuntime.h | 20 ++++----- .../nn/atk/detail/thread/atk_DriverCommand.h | 6 +-- .../nn/atk/detail/thread/atk_SoundThread.h | 8 ++-- .../atk/detail/thread/atk_ThreadInfoReader.h | 4 +- include/nn/atk/detail/util/atk_InstancePool.h | 8 ++-- .../nn/atk/detail/util/atk_WavOutFileStream.h | 12 +++--- .../nn/atk/detail/voice/atk_ChannelManager.h | 2 +- .../nn/atk/detail/voice/atk_LowLevelVoice.h | 4 +- .../nn/atk/detail/wsd/atk_WaveSoundRuntime.h | 6 +-- include/nn/atk/effect/atk_EffectAux.h | 8 ++-- include/nn/atk/effect/atk_EffectBase.h | 6 +-- .../nn/atk/fnd/io/atkfnd_FileStreamProxy.h | 14 +++---- include/nn/atk/fnd/io/atkfnd_Stream.h | 6 +-- include/nn/atk/fnd/io/atkfnd_StreamCache.h | 16 +++---- .../nn/atk/fnd/os/atkfnd_CriticalSection.h | 2 +- include/nn/atk/fnd/os/atkfnd_Thread.h | 2 +- include/nn/atk/util/atk_ProfileReader.h | 2 +- include/nn/atk/util/atk_TaskProfileReader.h | 8 ++-- include/nn/audio/audio_AudioRendererTypes.h | 6 +-- include/nn/audio/audio_PerformanceMetrics.h | 4 +- 40 files changed, 146 insertions(+), 142 deletions(-) diff --git a/include/nn/atk/atk_SoundArchivePlayer.h b/include/nn/atk/atk_SoundArchivePlayer.h index 8f08a120..cfed52ae 100644 --- a/include/nn/atk/atk_SoundArchivePlayer.h +++ b/include/nn/atk/atk_SoundArchivePlayer.h @@ -18,15 +18,15 @@ class SoundArchivePlayer : SoundStartable { SoundArchive* pSoundArchive; SoundDataManager* pSoundDataManager; void* pSetupBuffer; - std::size_t setupBufferSize; + size_t setupBufferSize; void* pStreamBuffer; - std::size_t streamBufferSize; + size_t streamBufferSize; void* pStreamCacheBuffer; - std::size_t streamCacheSize; + size_t streamCacheSize; bool enablePreparingStreamInstanceBufferFromSetupBuffer; void* pStreamInstanceBuffer; - std::size_t streamInstanceBufferSize; - std::size_t userParamSizePerSound; + size_t streamInstanceBufferSize; + size_t userParamSizePerSound; s32 addonSoundArchiveCount; }; static_assert(sizeof(InitializeParam) == 0x68); diff --git a/include/nn/atk/atk_SoundMemoryAllocatable.h b/include/nn/atk/atk_SoundMemoryAllocatable.h index 8c1cde1e..eb2a56d3 100644 --- a/include/nn/atk/atk_SoundMemoryAllocatable.h +++ b/include/nn/atk/atk_SoundMemoryAllocatable.h @@ -10,6 +10,6 @@ class SoundMemoryAllocatable { virtual ~SoundMemoryAllocatable() = 0; virtual void* Allocate(size_t size) = 0; virtual void* Allocate(size_t size, DisposeCallback callback, void* callbackArg) = 0; - virtual std::size_t GetAllocateSize(size_t size, bool needMemoryPool) = 0; + virtual size_t GetAllocateSize(size_t size, bool needMemoryPool) = 0; }; } // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/atk_SoundStartable.h b/include/nn/atk/atk_SoundStartable.h index 28ec5c75..e9fa3616 100644 --- a/include/nn/atk/atk_SoundStartable.h +++ b/include/nn/atk/atk_SoundStartable.h @@ -46,7 +46,7 @@ class SoundStartable { struct StreamSoundInfo { char* externalPath; void* pExternalData; - std::size_t externalDataSize; + size_t externalDataSize; StreamRegionCallback regionCallback; void* regionCallbackArg; void* prefetchData; diff --git a/include/nn/atk/detail/atk_BasicSound.h b/include/nn/atk/detail/atk_BasicSound.h index 96c18e5d..d234db41 100644 --- a/include/nn/atk/detail/atk_BasicSound.h +++ b/include/nn/atk/detail/atk_BasicSound.h @@ -205,7 +205,7 @@ class BasicSound { static_assert(sizeof(AmbientInfo) == 0x28); struct CommonParam { - detail::MoveValue volume; + MoveValue volume; MixMode mixMode; f32 pan; f32 span; @@ -433,7 +433,7 @@ class BasicSound { OutputAdditionalParam* m_pOutputAdditionalParam; #endif void* m_pUserParam; - std::size_t m_UserParamSize; + size_t m_UserParamSize; SoundStopCallback m_SoundStopCallback; util::IntrusiveListNode m_SoundPlayerPlayLink; util::IntrusiveListNode m_SoundPlayerPriorityLink; diff --git a/include/nn/atk/detail/atk_BusMixVolumePacket.h b/include/nn/atk/detail/atk_BusMixVolumePacket.h index c214a286..7e786bda 100644 --- a/include/nn/atk/detail/atk_BusMixVolumePacket.h +++ b/include/nn/atk/detail/atk_BusMixVolumePacket.h @@ -5,9 +5,9 @@ namespace nn::atk::detail { class BusMixVolumePacket { public: - static std::size_t GetRequiredMemSize(s32 busCount); + static size_t GetRequiredMemSize(s32 busCount); - bool Initialize(void* buffer, std::size_t size, s32 busCount); + bool Initialize(void* buffer, size_t size, s32 busCount); void Finalize(); void Reset(); diff --git a/include/nn/atk/detail/atk_DisposeCallbackManager.h b/include/nn/atk/detail/atk_DisposeCallbackManager.h index ebcc4757..f615ad3f 100644 --- a/include/nn/atk/detail/atk_DisposeCallbackManager.h +++ b/include/nn/atk/detail/atk_DisposeCallbackManager.h @@ -18,7 +18,7 @@ class DisposeCallbackManager { u64 GetCallbackCount() const; - void Dispose(const void* mem, std::size_t size); + void Dispose(const void* mem, size_t size); private: CallbackList m_CallbackList; diff --git a/include/nn/atk/detail/atk_IStreamDataDecoder.h b/include/nn/atk/detail/atk_IStreamDataDecoder.h index 7487f856..98cff4d0 100644 --- a/include/nn/atk/detail/atk_IStreamDataDecoder.h +++ b/include/nn/atk/detail/atk_IStreamDataDecoder.h @@ -22,7 +22,7 @@ class IStreamDataDecoder { s32 channelCount; s32 sampleRate; s32 blockSampleCount; - std::size_t blockSize; + size_t blockSize; }; static_assert(sizeof(DataInfo) == 0x18); @@ -30,13 +30,13 @@ class IStreamDataDecoder { os::Tick decodeTick; s32 decodedSampleCount; os::Tick fsAccessTick; - std::size_t fsReadSize; + size_t fsReadSize; }; static_assert(sizeof(DecodeProfile) == 0x20); struct CacheProfile { position_t cacheStartPosition; - std::size_t cachedLength; + size_t cachedLength; position_t cacheCurrentPosition; driver::StreamSoundPlayer* player; }; diff --git a/include/nn/atk/detail/atk_LoaderManager.h b/include/nn/atk/detail/atk_LoaderManager.h index 705da2db..0d4cbbd1 100644 --- a/include/nn/atk/detail/atk_LoaderManager.h +++ b/include/nn/atk/detail/atk_LoaderManager.h @@ -18,7 +18,7 @@ class LoaderManager : driver::SoundThread::SoundFrameCallback { private: void* m_pBuffer; - std::size_t m_BufferSize; + size_t m_BufferSize; List m_FreeList; List m_FreeReqList; }; diff --git a/include/nn/atk/detail/atk_NoteOnCallback.h b/include/nn/atk/detail/atk_NoteOnCallback.h index 232f0e45..4f64e69e 100644 --- a/include/nn/atk/detail/atk_NoteOnCallback.h +++ b/include/nn/atk/detail/atk_NoteOnCallback.h @@ -12,7 +12,7 @@ struct NoteOnInfo { s32 length; s32 initPan; s32 priority; - driver::Channel::ChannelCallback channelCallback; + Channel::ChannelCallback channelCallback; void* channelCallbackData; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) OutputReceiver* pOutputReceiver; diff --git a/include/nn/atk/detail/atk_OutputAdditionalParam.h b/include/nn/atk/detail/atk_OutputAdditionalParam.h index 39cfefd6..bd4d02b9 100644 --- a/include/nn/atk/detail/atk_OutputAdditionalParam.h +++ b/include/nn/atk/detail/atk_OutputAdditionalParam.h @@ -11,9 +11,9 @@ using SendArray = ValueArray; class OutputAdditionalParam { public: - static std::size_t GetRequiredMemSize(const SoundInstanceConfig& config); + static size_t GetRequiredMemSize(const SoundInstanceConfig& config); - void Initialize(void* buffer, std::size_t bufferSize, const SoundInstanceConfig& config); + void Initialize(void* buffer, size_t bufferSize, const SoundInstanceConfig& config); void Finalize(); void Reset(); diff --git a/include/nn/atk/detail/atk_PlayerHeap.h b/include/nn/atk/detail/atk_PlayerHeap.h index 61921eb0..b7f854b3 100644 --- a/include/nn/atk/detail/atk_PlayerHeap.h +++ b/include/nn/atk/detail/atk_PlayerHeap.h @@ -30,16 +30,16 @@ class PlayerHeap : SoundMemoryAllocatable { void Destroy(); - bool Create(void* startAddress, std::size_t size); + bool Create(void* startAddress, size_t size); void Clear(); - void* Allocate(std::size_t size) override; - void* Allocate(std::size_t size, - SoundMemoryAllocatable::DisposeCallback callback, void* callbackArg) override; + void* Allocate(size_t size) override; + void* Allocate(size_t size, SoundMemoryAllocatable::DisposeCallback callback, + void* callbackArg) override; - std::size_t GetAllocateSize(std::size_t size, bool needMemoryPool) override; - std::size_t GetFreeSize() const; + size_t GetAllocateSize(size_t size, bool needMemoryPool) override; + size_t GetFreeSize() const; private: friend SoundPlayer; diff --git a/include/nn/atk/detail/atk_SoundArchiveFileReader.h b/include/nn/atk/detail/atk_SoundArchiveFileReader.h index 6fb95c69..4a326f82 100644 --- a/include/nn/atk/detail/atk_SoundArchiveFileReader.h +++ b/include/nn/atk/detail/atk_SoundArchiveFileReader.h @@ -64,11 +64,11 @@ class SoundArchiveFileReader { void* GetAttachedGroupTable(u32) const; // unknown return type private: - detail::SoundArchiveFile::FileHeader m_Header; - detail::SoundArchiveFile::StringBlockBody* m_pStringBlockBody; - detail::SoundArchiveFile::InfoBlockBody* m_pInfoBlockBody; + SoundArchiveFile::FileHeader m_Header; + SoundArchiveFile::StringBlockBody* m_pStringBlockBody; + SoundArchiveFile::InfoBlockBody* m_pInfoBlockBody; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) - detail::SoundArchiveFile::FileBlock* m_pFileBlock; + SoundArchiveFile::FileBlock* m_pFileBlock; #endif }; diff --git a/include/nn/atk/detail/atk_SoundInstanceManager.h b/include/nn/atk/detail/atk_SoundInstanceManager.h index 8797c6d3..aadf7d02 100644 --- a/include/nn/atk/detail/atk_SoundInstanceManager.h +++ b/include/nn/atk/detail/atk_SoundInstanceManager.h @@ -19,13 +19,13 @@ class SoundInstanceManager { #else T* Alloc(s32 priority, s32 ambientPriority, OutputReceiver* pOutputReceiver); #endif - s32 Create(void* buffer, std::size_t size, const SoundInstanceConfig& config); + s32 Create(void* buffer, size_t size, const SoundInstanceConfig& config); void SortPriorityList(); private: void* m_pBuffer; - std::size_t m_BufferSize; + size_t m_BufferSize; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) SoundInstanceConfig m_SoundInstanceConfig; #endif diff --git a/include/nn/atk/detail/atk_VolumeThroughModePacket.h b/include/nn/atk/detail/atk_VolumeThroughModePacket.h index a8e757be..44641efc 100644 --- a/include/nn/atk/detail/atk_VolumeThroughModePacket.h +++ b/include/nn/atk/detail/atk_VolumeThroughModePacket.h @@ -7,9 +7,9 @@ class VolumeThroughModePacket { public: using VolumeThroughModeArray = ValueArray; - static std::size_t GetRequiredMemSize(s32 busCount); + static size_t GetRequiredMemSize(s32 busCount); - bool Initialize(void* buffer, std::size_t size, s32 busCount); + bool Initialize(void* buffer, size_t size, s32 busCount); void Finalize(); diff --git a/include/nn/atk/detail/seq/atk_MmlSequenceTrackAllocator.h b/include/nn/atk/detail/seq/atk_MmlSequenceTrackAllocator.h index bb0a09ea..468ebda2 100644 --- a/include/nn/atk/detail/seq/atk_MmlSequenceTrackAllocator.h +++ b/include/nn/atk/detail/seq/atk_MmlSequenceTrackAllocator.h @@ -13,7 +13,7 @@ class MmlSequenceTrackAllocator : SequenceTrackAllocator { void FreeTrack(SequenceTrack* track); - s32 Create(void* buffer, std::size_t size); + s32 Create(void* buffer, size_t size); void Destroy(); diff --git a/include/nn/atk/detail/strm/atk_StreamBufferPool.h b/include/nn/atk/detail/strm/atk_StreamBufferPool.h index 6209d14d..e22a8cbb 100644 --- a/include/nn/atk/detail/strm/atk_StreamBufferPool.h +++ b/include/nn/atk/detail/strm/atk_StreamBufferPool.h @@ -8,7 +8,7 @@ class StreamBufferPool { constexpr static u32 BlockMax = 32; constexpr static u8 BitPerByte = 8; - void Initialize(void* buffer, std::size_t size, s32 blockCount); + void Initialize(void* buffer, size_t size, s32 blockCount); void Finalize(); void* Alloc(); @@ -16,8 +16,8 @@ class StreamBufferPool { private: void* m_Buffer; - std::size_t m_BufferSize; - std::size_t m_BlockSize; + size_t m_BufferSize; + size_t m_BlockSize; s32 m_BlockCount; s32 m_AllocCount; u8 m_AllocFlags[BlockMax / BitPerByte]; diff --git a/include/nn/atk/detail/strm/atk_StreamSound.h b/include/nn/atk/detail/strm/atk_StreamSound.h index d152ea64..ac15a7f6 100644 --- a/include/nn/atk/detail/strm/atk_StreamSound.h +++ b/include/nn/atk/detail/strm/atk_StreamSound.h @@ -73,7 +73,7 @@ class StreamSound : BasicSound { u8 m_Padding[1]; u32 m_AvailableTrackBitFlag[2]; void* m_pCacheBuffer; - std::size_t m_CacheSize; + size_t m_CacheSize; driver::StreamSoundPlayer m_PlayerInstance; }; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) diff --git a/include/nn/atk/detail/strm/atk_StreamSoundFile.h b/include/nn/atk/detail/strm/atk_StreamSoundFile.h index a417527e..f43d87ae 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundFile.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundFile.h @@ -64,9 +64,10 @@ class StreamSoundFile { }; struct TrackInfoTable { - Util::ReferenceTable table; TrackInfo* GetTrackInfo(u32 index) const; + + Util::ReferenceTable table; }; struct DspAdpcmChannelInfo { @@ -76,26 +77,29 @@ class StreamSoundFile { static_assert(sizeof(DspAdpcmChannelInfo) == 0x2c); struct ChannelInfo { - Util::Reference toDetailChannelInfo; DspAdpcmChannelInfo* GetDspAdpcmChannelInfo() const; + + Util::Reference toDetailChannelInfo; }; static_assert(sizeof(ChannelInfo) == 0x8); struct ChannelInfoTable { - Util::ReferenceTable table; ChannelInfo* GetChannelInfo(u32 index) const; + + Util::ReferenceTable table; }; struct InfoBlockBody { - Util::Reference toStreamSoundInfo; - Util::Reference toTrackInfoTable; - Util::Reference toChannelInfoTable; StreamSoundInfo* GetStreamSoundInfo() const; TrackInfoTable* GetTrackInfoTable() const; ChannelInfoTable* GetChannelInfoTable() const; + + Util::Reference toStreamSoundInfo; + Util::Reference toTrackInfoTable; + Util::Reference toChannelInfoTable; }; static_assert(sizeof(InfoBlockBody) == 0x18); diff --git a/include/nn/atk/detail/strm/atk_StreamSoundLoader.h b/include/nn/atk/detail/strm/atk_StreamSoundLoader.h index 985bf63d..8338e962 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundLoader.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundLoader.h @@ -43,16 +43,16 @@ struct StreamDataInfoDetail { s32 sampleRate; bool loopFlag; position_t loopStart; - std::size_t sampleCount; + size_t sampleCount; position_t originalLoopStart; position_t originalLoopEnd; bool isRevisionCheckEnabled; bool isRegionIndexCheckEnabled; u32 revisionValue; - std::size_t blockSampleCount; - std::size_t blockSize; - std::size_t lastBlockSize; - std::size_t lastBlockSampleCount; + size_t blockSampleCount; + size_t blockSize; + size_t lastBlockSize; + size_t lastBlockSampleCount; s32 channelCount; s32 trackCount; TrackDataInfo trackInfo[8]; @@ -62,10 +62,10 @@ static_assert(sizeof(StreamDataInfoDetail) == 0xd8); struct LoadDataParam { u32 blockIndex; - std::size_t samples; + size_t samples; position_t sampleBegin; position_t sampleOffset; - std::size_t sampleBytes; + size_t sampleBytes; bool adpcmContextEnable; AdpcmContextNotAligned adpcmContext[16]; s32 loopCount; @@ -151,12 +151,12 @@ class StreamSoundLoader { static_assert(sizeof(AdpcmInfo) == 0xc0); struct BlockInfo { - std::size_t size; - std::size_t samples; - std::size_t startOffsetSamples; - std::size_t startOffsetSamplesAlign; - std::size_t startOffsetByte; - std::size_t copyByte; + size_t size; + size_t samples; + size_t startOffsetSamples; + size_t startOffsetSamplesAlign; + size_t startOffsetByte; + size_t copyByte; }; static_assert(sizeof(BlockInfo) == 0x30); @@ -210,14 +210,14 @@ class StreamSoundLoader { void SetStreamSoundInfoForOpus(const IStreamDataDecoder::DataInfo& dataInfo); - void LoadData(void** bufferAddress, u32 bufferBlockIndex, std::size_t startOffsetSamples, - std::size_t prefetchOffsetSamples, TaskProfileLogger& logger); + void LoadData(void** bufferAddress, u32 bufferBlockIndex, size_t startOffsetSamples, + size_t prefetchOffsetSamples, TaskProfileLogger& logger); bool LoadData1(DriverCommandStreamSoundLoadData* command, void** bufferAddress, - u32 bufferBlockIndex, std::size_t startOffsetSamples, - std::size_t prefetchOffsetSamples, TaskProfileLogger& logger); + u32 bufferBlockIndex, size_t startOffsetSamples, + size_t prefetchOffsetSamples, TaskProfileLogger& logger); bool LoadDataForOpus(DriverCommandStreamSoundLoadData* command, void** bufferAddress, - u32 bufferBlockIndex, std::size_t startOffsetSamples, - std::size_t prefetchOffsetSamples, TaskProfileLogger& logger); + u32 bufferBlockIndex, size_t startOffsetSamples, + size_t prefetchOffsetSamples, TaskProfileLogger& logger); bool ApplyStartOffset(s64, s32*); @@ -267,9 +267,9 @@ class StreamSoundLoader { position_t m_LoopEnd; char m_FilePath[SoundArchive::FilePathMax]; void* m_pExternalData; - std::size_t m_ExternalDataSize; + size_t m_ExternalDataSize; void* m_pCacheBuffer; - std::size_t m_CacheSize; + size_t m_CacheSize; u32 m_LoadingDataBlockIndex; u32 m_LastBlockIndex; u32 m_LoopStartBlockIndex; diff --git a/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h b/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h index 03740e9a..cd62d497 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h @@ -60,7 +60,7 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { struct WaveBufferInfo { position_t sampleBegin; - std::size_t sampleLength; + size_t sampleLength; s32 loopCount; }; static_assert(sizeof(WaveBufferInfo) == 0x18); @@ -78,7 +78,7 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { void* regionCallbackArg; char filePath[639]; void* pExternalData; - std::size_t externalDataSize; + size_t externalDataSize; FileStreamHookParam fileStreamHookParam; }; static_assert(sizeof(PrepareBaseArg) == 0x2d0); @@ -86,7 +86,7 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { struct PrepareArg { PrepareBaseArg baseArg; void* cacheBuffer; - std::size_t cacheSize; + size_t cacheSize; }; static_assert(sizeof(PrepareArg) == 0x2e0); @@ -131,7 +131,7 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { struct PrefetchLoadDataParam : LoadDataParam { u32 prefetchBlockIndex; - std::size_t prefetchBlockBytes; + size_t prefetchBlockBytes; }; static_assert(sizeof(PrefetchLoadDataParam) == 0xa8); @@ -206,7 +206,7 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { bool LoadStreamData(bool result, const LoadDataParam& loadDataParam, u16 assignNumber); bool LoadStreamData(bool result, const LoadDataParam& loadDataParam, u16 assignNumber, bool usePrefetchFlag, u32 currentPrefetchBlockIndex, - std::size_t currentPrefetchBlockBytes); + size_t currentPrefetchBlockBytes); bool IsStoppedByLoadingDelay() const; diff --git a/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h b/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h index eb5b81a3..9ec98c08 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h +++ b/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h @@ -13,35 +13,35 @@ class StreamSoundRuntime { ~StreamSoundRuntime(); bool Initialize(s32 soundCount, void** pOutAllocatedAddr, const void* endAddr, - void* streamInstanceBuffer, std::size_t streamInstanceBufferSize); + void* streamInstanceBuffer, size_t streamInstanceBufferSize); - static std::size_t GetRequiredStreamInstanceSize(s32 soundCount); + static size_t GetRequiredStreamInstanceSize(s32 soundCount); bool SetupStreamBuffer(const SoundArchive* pSoundArchive, void* strmBuffer, - std::size_t strmBufferSize); + size_t strmBufferSize); bool SetupStreamBuffer(const SoundArchive* pSoundArchive, void* strmBuffer, - std::size_t strmBufferSize, driver::StreamBufferPool* strmBufferPool); + size_t strmBufferSize, driver::StreamBufferPool* strmBufferPool); - std::size_t GetRequiredStreamBufferSize(const SoundArchive* soundArchive) const; + size_t GetRequiredStreamBufferSize(const SoundArchive* soundArchive) const; static u32 GetRequiredStreamBufferTimes(const SoundArchive* soundArchive); bool SetupStreamCacheBuffer(const SoundArchive* pSoundArchive, void* streamCacheBuffer, - std::size_t streamCacheSize); + size_t streamCacheSize); void Finalize(); - static std::size_t GetRequiredMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, + static size_t GetRequiredMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, s32 alignment); - static std::size_t GetRequiredStreamCacheSize(const SoundArchive* pSoundArchive, - std::size_t); + static size_t GetRequiredStreamCacheSize(const SoundArchive* pSoundArchive, + size_t); s32 GetActiveCount() const; s32 GetActiveChannelCount() const; s32 GetActiveTrackCount() const; s32 GetFreeCount() const; - void SetupUserParam(void** pOutAllocatedAddr, std::size_t adjustSize); + void SetupUserParam(void** pOutAllocatedAddr, size_t adjustSize); void Update(); #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) diff --git a/include/nn/atk/detail/thread/atk_DriverCommand.h b/include/nn/atk/detail/thread/atk_DriverCommand.h index 1f7c8ee4..848f686f 100644 --- a/include/nn/atk/detail/thread/atk_DriverCommand.h +++ b/include/nn/atk/detail/thread/atk_DriverCommand.h @@ -418,7 +418,7 @@ static_assert(sizeof(DriverCommandStreamSoundTrackMixParameter) == 0x48); struct DriverCommandInvalidateData : Command { void* mem; - std::size_t size; + size_t size; }; static_assert(sizeof(DriverCommandInvalidateData) == 0x28); @@ -431,7 +431,7 @@ struct DriverCommandEffect : Command { s32 bus; EffectBase* effect; void* effectBuffer; - std::size_t effectBufferSize; + size_t effectBufferSize; OutputMixer* pOutputMixer; }; static_assert(sizeof(DriverCommandEffect) == 0x40); @@ -440,7 +440,7 @@ struct DriverCommandEffectAux : Command { s32 bus; EffectAux* effect; void* effectBuffer; - std::size_t effectBufferSize; + size_t effectBufferSize; OutputMixer* pOutputMixer; }; static_assert(sizeof(DriverCommandEffectAux) == 0x40); diff --git a/include/nn/atk/detail/thread/atk_SoundThread.h b/include/nn/atk/detail/thread/atk_SoundThread.h index 4a0cb3f5..170a6269 100644 --- a/include/nn/atk/detail/thread/atk_SoundThread.h +++ b/include/nn/atk/detail/thread/atk_SoundThread.h @@ -67,12 +67,12 @@ class SoundThread : fnd::Thread::Handler { ~SoundThread() override; - bool CreateSoundThread(s32 threadPriority, void* stackBase, std::size_t stackSize, + bool CreateSoundThread(s32 threadPriority, void* stackBase, size_t stackSize, s32 idealCoreNumber, u32 affinityMask); - void Initialize(void* performanceFrameBuffer, std::size_t performanceFrameBufferSize, + void Initialize(void* performanceFrameBuffer, size_t performanceFrameBufferSize, bool isProfilingEnabled); - void Initialize(void* performanceFrameBuffer, std::size_t performanceFrameBufferSize, + void Initialize(void* performanceFrameBuffer, size_t performanceFrameBufferSize, bool isProfilingEnabled, bool isDetailSoundThreadProfilerEnabled, bool isUserThreadRenderingEnabled); @@ -142,7 +142,7 @@ class SoundThread : fnd::Thread::Handler { os::Tick m_LastPerformanceFrameBegin; os::Tick m_LastPerformanceFrameEnd; void* m_pPerformanceFrameUpdateBuffer[3]; - std::size_t m_PerformanceFrameUpdateBufferSize; + size_t m_PerformanceFrameUpdateBufferSize; s32 m_CurrentPerformanceFrameBufferIndex; bool m_IsProfilingEnabled; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) diff --git a/include/nn/atk/detail/thread/atk_ThreadInfoReader.h b/include/nn/atk/detail/thread/atk_ThreadInfoReader.h index 2f86cd0c..29202a5a 100644 --- a/include/nn/atk/detail/thread/atk_ThreadInfoReader.h +++ b/include/nn/atk/detail/thread/atk_ThreadInfoReader.h @@ -12,8 +12,8 @@ class ThreadInfoRecorder { private: void* m_Buffer; - std::size_t m_BufferSize; - std::size_t m_WritePosition; + size_t m_BufferSize; + size_t m_WritePosition; std::atomic_ulong m_ReadPosition; std::atomic_int m_RecordFrameCount; std::atomic_bool m_IsAllocationFailed; diff --git a/include/nn/atk/detail/util/atk_InstancePool.h b/include/nn/atk/detail/util/atk_InstancePool.h index 5478fb82..2126c0e5 100644 --- a/include/nn/atk/detail/util/atk_InstancePool.h +++ b/include/nn/atk/detail/util/atk_InstancePool.h @@ -5,9 +5,9 @@ namespace nn::atk::detail { class PoolImpl { public: - s32 CreateImpl(void* buffer, std::size_t size, std::size_t objSize); - s32 CreateImpl(void* buffer, std::size_t size, std::size_t objSize, - std::size_t alignment); + s32 CreateImpl(void* buffer, size_t size, size_t objSize); + s32 CreateImpl(void* buffer, size_t size, size_t objSize, + size_t alignment); void DestroyImpl(); @@ -20,7 +20,7 @@ class PoolImpl { private: PoolImpl* m_pNext; void* m_pBuffer; - std::size_t m_BufferSize; + size_t m_BufferSize; }; static_assert(sizeof(PoolImpl) == 0x18); diff --git a/include/nn/atk/detail/util/atk_WavOutFileStream.h b/include/nn/atk/detail/util/atk_WavOutFileStream.h index bc48d62f..b7306245 100644 --- a/include/nn/atk/detail/util/atk_WavOutFileStream.h +++ b/include/nn/atk/detail/util/atk_WavOutFileStream.h @@ -24,19 +24,19 @@ class WavOutFileStream { bool UpdateRiffChunkSize(); bool UpdateDataChunkSize(); - std::size_t Write(const void* buffer, std::size_t size); - std::size_t WriteDirect(const void* buf, std::size_t length, fnd::FndResult* result); + size_t Write(const void* buffer, size_t size); + size_t WriteDirect(const void* buf, size_t length, fnd::FndResult* result); bool Seek(position_t offset, fnd::Stream::SeekOrigin origin); - void SetCacheBuffer(char* cacheBuffer, std::size_t cacheBufferSize); + void SetCacheBuffer(char* cacheBuffer, size_t cacheBufferSize); private: fnd::FileStream* m_pFileStream; - std::size_t m_WaveDataSize; + size_t m_WaveDataSize; bool m_IsWaveDataSizeCalculating; char* m_Buffer; - std::size_t m_BufferLength; - std::size_t m_ValidBufferLength; + size_t m_BufferLength; + size_t m_ValidBufferLength; }; } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/voice/atk_ChannelManager.h b/include/nn/atk/detail/voice/atk_ChannelManager.h index ba66d783..20268b15 100644 --- a/include/nn/atk/detail/voice/atk_ChannelManager.h +++ b/include/nn/atk/detail/voice/atk_ChannelManager.h @@ -33,7 +33,7 @@ class ChannelManager { #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) InstancePool* m_pAdditionalParamPool; BufferPool* m_pAdditionalParamBufferPool; - std::size_t m_AdditionalParamBufferSizePerChannel; + size_t m_AdditionalParamBufferSizePerChannel; SoundInstanceConfig m_SoundInstanceConfig; #endif }; diff --git a/include/nn/atk/detail/voice/atk_LowLevelVoice.h b/include/nn/atk/detail/voice/atk_LowLevelVoice.h index 852d65f6..5b2cebc1 100644 --- a/include/nn/atk/detail/voice/atk_LowLevelVoice.h +++ b/include/nn/atk/detail/voice/atk_LowLevelVoice.h @@ -92,9 +92,9 @@ class LowLevelVoiceAllocator { LowLevelVoiceAllocator(); - std::size_t GetRequiredMemSize(s32 voiceCount); + size_t GetRequiredMemSize(s32 voiceCount); - void Initialize(s32 voiceCount, void* mem, std::size_t memSize); + void Initialize(s32 voiceCount, void* mem, size_t memSize); void Finalize(); void UpdateAllVoiceState(OutputMode outputMode); diff --git a/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h b/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h index 39999b6b..67f2660a 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h +++ b/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h @@ -12,13 +12,13 @@ class WaveSoundRuntime { bool Initialize(s32 soundCount, void** pOutAllocatedAddr, const void* endAddr); void Finalize(); - static std::size_t GetRequiredMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, - s32 alignment); + static size_t GetRequiredMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, + s32 alignment); s32 GetActiveCount() const; s32 GetFreeWaveSoundCount() const; - void SetupUserParam(void** startAddr, std::size_t adjustSize); + void SetupUserParam(void** startAddr, size_t adjustSize); void Update(); diff --git a/include/nn/atk/effect/atk_EffectAux.h b/include/nn/atk/effect/atk_EffectAux.h index e80d5b5c..eb99b032 100644 --- a/include/nn/atk/effect/atk_EffectAux.h +++ b/include/nn/atk/effect/atk_EffectAux.h @@ -44,7 +44,7 @@ class EffectAux { void ResetChannelIndex(); - std::size_t GetRequiredMemSize(const audio::AudioRendererParameter& parameter) const; + size_t GetRequiredMemSize(const audio::AudioRendererParameter& parameter) const; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) bool AddEffect(audio::AudioRendererConfig* pConfig, @@ -60,7 +60,7 @@ class EffectAux { #endif void SplitEffectBuffer(BufferSet* pBufferSet, void* effectBuffer, - std::size_t effectBufferSize); + size_t effectBufferSize); void SetEffectInputOutput(const s8* input, const s8* output, s32 inputCount, s32 outputCount); @@ -85,7 +85,7 @@ class EffectAux { bool IsEnabled() const; void SetEnabled(bool isEnabled); - void SetEffectBuffer(void* effectBuffer, std::size_t effectBufferSize); + void SetEffectBuffer(void* effectBuffer, size_t effectBufferSize); void Update(); @@ -100,7 +100,7 @@ class EffectAux { bool m_IsActive; bool m_IsEnabled; void* m_EffectBuffer; - std::size_t m_EffectBufferSize; + size_t m_EffectBufferSize; s32* m_AuxReadBuffer; ChannelIndex m_ChannelSetting[ChannelCountMax]; }; diff --git a/include/nn/atk/effect/atk_EffectBase.h b/include/nn/atk/effect/atk_EffectBase.h index 56b0763d..ae6444c9 100644 --- a/include/nn/atk/effect/atk_EffectBase.h +++ b/include/nn/atk/effect/atk_EffectBase.h @@ -37,11 +37,11 @@ class EffectBase { virtual void unk5() = 0; virtual void unk6() = 0; virtual void unk7() = 0; - virtual void UpdateBuffer(s32, void**, std::size_t, SampleFormat, s32, OutputMode); + virtual void UpdateBuffer(s32, void**, size_t, SampleFormat, s32, OutputMode); virtual void GetChannelIndex(ChannelIndex* pChannel, s32 channelCount) const; virtual s32 GetChannelSettingCountMax() const; virtual void OnChangeOutputMode(); - virtual void SetEffectBuffer(void* effectBuffer, std::size_t effectBufferSize); + virtual void SetEffectBuffer(void* effectBuffer, size_t effectBufferSize); #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) bool AddEffect(audio::AudioRendererConfig* pConfig, audio::FinalMixType* pFinalMixType); @@ -71,7 +71,7 @@ class EffectBase { bool m_IsActive; SampleRate m_SampleRate; void* m_EffectBuffer; - std::size_t m_EffectBufferSize; + size_t m_EffectBufferSize; }; static_assert(sizeof(EffectBase) == 0x30); } // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h b/include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h index 6c0d2eb0..79876280 100644 --- a/include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h +++ b/include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h @@ -6,7 +6,7 @@ namespace nn::atk::detail::fnd { class FileStreamProxy : FileStream { public: FileStreamProxy(const FileStream& fileStream, - position_t offset, std::size_t fileSize); + position_t offset, size_t fileSize); ~FileStreamProxy() override; @@ -20,15 +20,15 @@ class FileStreamProxy : FileStream { bool CanWrite() const override; bool CanSeek() const override; - std::size_t GetSize() const override; + size_t GetSize() const override; - std::size_t Read(void* buffer, std::size_t length, FndResult* result) override; - std::size_t Write(const void* buffer, std::size_t length, FndResult* result) override; + size_t Read(void* buffer, size_t length, FndResult* result) override; + size_t Write(const void* buffer, size_t length, FndResult* result) override; FndResult Seek(position_t offset, fnd::Stream::SeekOrigin origin) override; position_t GetCurrentPosition() const override; - void EnableCache(void* buffer, std::size_t length) override; + void EnableCache(void* buffer, size_t length) override; void DisableCache() override; bool IsCacheEnabled() const override; @@ -40,12 +40,12 @@ class FileStreamProxy : FileStream { position_t GetCachePosition() override; - std::size_t GetCachedLength() override; + size_t GetCachedLength() override; private: FileStream* m_pFileStream; position_t m_Offset; - std::size_t m_FileSize; + size_t m_FileSize; }; static_assert(sizeof(FileStreamProxy) == 0x20); } // namespace nn::atk::detail::fnd \ No newline at end of file diff --git a/include/nn/atk/fnd/io/atkfnd_Stream.h b/include/nn/atk/fnd/io/atkfnd_Stream.h index 179b375f..552c2f99 100644 --- a/include/nn/atk/fnd/io/atkfnd_Stream.h +++ b/include/nn/atk/fnd/io/atkfnd_Stream.h @@ -19,12 +19,12 @@ class Stream { virtual void Close() = 0; virtual bool IsOpened() const = 0; - virtual std::size_t Read(void* buf, std::size_t length, FndResult* result) = 0; - virtual std::size_t Write(const void* buf, std::size_t length, FndResult* result) = 0; + virtual size_t Read(void* buf, size_t length, FndResult* result) = 0; + virtual size_t Write(const void* buf, size_t length, FndResult* result) = 0; virtual FndResult Seek(position_t offset, SeekOrigin origin) = 0; virtual position_t GetCurrentPosition() const = 0; - virtual std::size_t GetSize() const = 0; + virtual size_t GetSize() const = 0; virtual bool CanRead() const = 0; virtual bool CanWrite() const = 0; diff --git a/include/nn/atk/fnd/io/atkfnd_StreamCache.h b/include/nn/atk/fnd/io/atkfnd_StreamCache.h index 67d44b8c..9a4c61fe 100644 --- a/include/nn/atk/fnd/io/atkfnd_StreamCache.h +++ b/include/nn/atk/fnd/io/atkfnd_StreamCache.h @@ -10,24 +10,24 @@ class StreamCache { constexpr static position_t InvalidPosition = -1; StreamCache(); - StreamCache(Stream* sourceStream, void* buffer, std::size_t length); + StreamCache(Stream* sourceStream, void* buffer, size_t length); - void Initialize(Stream* sourceStream, void* buffer, std::size_t length); + void Initialize(Stream* sourceStream, void* buffer, size_t length); void Finalize(); - std::size_t Read(void* buf, std::size_t length, FndResult* result, FsAccessLog* log, void* pFileStream); + size_t Read(void* buf, size_t length, FndResult* result, FsAccessLog* log, void* pFileStream); void FlushWriteCache(); - std::size_t GetReadCacheHitLength(std::size_t) const; + size_t GetReadCacheHitLength(size_t) const; FndResult SyncStreamCurrentPosition(position_t position); void ClearCache(); - std::size_t Write(const void* buf, std::size_t length, FndResult* result); + size_t Write(const void* buf, size_t length, FndResult* result); - std::size_t GetWritableCacheLength(std::size_t) const; + size_t GetWritableCacheLength(size_t) const; FndResult Seek(position_t offset, Stream::SeekOrigin origin); @@ -37,9 +37,9 @@ class StreamCache { Stream* m_Stream{}; position_t m_CurrentPosition{0}; void* m_CacheBuffer{}; - std::size_t m_CacheBufferLength{0}; + size_t m_CacheBufferLength{0}; position_t m_CachePosition{-1}; - std::size_t m_CachedLength{0}; + size_t m_CachedLength{0}; u8 m_CacheState{0}; u8 m_Padding[3]; }; diff --git a/include/nn/atk/fnd/os/atkfnd_CriticalSection.h b/include/nn/atk/fnd/os/atkfnd_CriticalSection.h index be2b3efd..5f6a7636 100644 --- a/include/nn/atk/fnd/os/atkfnd_CriticalSection.h +++ b/include/nn/atk/fnd/os/atkfnd_CriticalSection.h @@ -10,7 +10,7 @@ class CriticalSection { void unlock(); private: - nn::os::Mutex m_Mutex; + os::Mutex m_Mutex; }; static_assert(sizeof(CriticalSection) == 0x20); } // namespace nn::atk::detail::fnd \ No newline at end of file diff --git a/include/nn/atk/fnd/os/atkfnd_Thread.h b/include/nn/atk/fnd/os/atkfnd_Thread.h index d904ba2b..3c66da74 100644 --- a/include/nn/atk/fnd/os/atkfnd_Thread.h +++ b/include/nn/atk/fnd/os/atkfnd_Thread.h @@ -83,7 +83,7 @@ class Thread { char* name; void* stack; - std::size_t stackSize; + size_t stackSize; s32 idealCoreNumber; AffinityMask affinityMask; s32 priority; diff --git a/include/nn/atk/util/atk_ProfileReader.h b/include/nn/atk/util/atk_ProfileReader.h index 21a43e66..853e6f4f 100644 --- a/include/nn/atk/util/atk_ProfileReader.h +++ b/include/nn/atk/util/atk_ProfileReader.h @@ -54,7 +54,7 @@ class ProfileReader { public: ProfileReader(); - std::size_t Read(SoundProfile*, s32); + size_t Read(SoundProfile*, s32); void Record(const SoundProfile& src); diff --git a/include/nn/atk/util/atk_TaskProfileReader.h b/include/nn/atk/util/atk_TaskProfileReader.h index 411cd65b..0e7e6803 100644 --- a/include/nn/atk/util/atk_TaskProfileReader.h +++ b/include/nn/atk/util/atk_TaskProfileReader.h @@ -45,7 +45,7 @@ struct TaskProfile { u64 m_EndTick; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) position_t m_CacheStartPosition; - std::size_t m_CachedLength; + size_t m_CachedLength; position_t m_CacheCurrentPosition; detail::driver::StreamSoundPlayer* m_pPlayer; #endif @@ -69,7 +69,7 @@ struct TaskProfile { s32 GetDecodedSampleCount() const; TimeSpan GetFsAccessTime(); - std::size_t GetFsReadSize(); + size_t GetFsReadSize(); #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) detail::driver::StreamSoundPlayer* GetStreamSoundPlayer() const; @@ -89,12 +89,12 @@ struct TaskProfile { u64 m_EndTick; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) position_t m_CacheStartPosition; - std::size_t m_CachedLength; + size_t m_CachedLength; position_t m_CacheCurrentPosition; #endif u64 m_DecodeTick; u64 m_FsAccessTick; - std::size_t m_FsReadSize; + size_t m_FsReadSize; s32 m_DecodedSampleCount; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) detail::driver::StreamSoundPlayer* m_pPlayer; diff --git a/include/nn/audio/audio_AudioRendererTypes.h b/include/nn/audio/audio_AudioRendererTypes.h index 964c3a3b..099a425a 100644 --- a/include/nn/audio/audio_AudioRendererTypes.h +++ b/include/nn/audio/audio_AudioRendererTypes.h @@ -41,11 +41,11 @@ struct AudioRendererConfig { BehaviorManager* _pBehaviorManager; SplitterInfoManager* _pSplitterInfoManager; void* _pInParameter; - std::size_t _pInParameterSize; + size_t _pInParameterSize; void* _pOutStatus; - std::size_t _pOutStatusSize; + size_t _pOutStatusSize; void* _pConfigBuffer; - std::size_t _configBufferSize; + size_t _configBufferSize; }; static_assert(sizeof(AudioRendererConfig) == 0x70); diff --git a/include/nn/audio/audio_PerformanceMetrics.h b/include/nn/audio/audio_PerformanceMetrics.h index 272f3fbb..05053d68 100644 --- a/include/nn/audio/audio_PerformanceMetrics.h +++ b/include/nn/audio/audio_PerformanceMetrics.h @@ -10,7 +10,7 @@ class PerformanceInfo { PerformanceInfo(); ~PerformanceInfo(); - void SetBuffer(const void* buffer, std::size_t bufferSize); + void SetBuffer(const void* buffer, size_t bufferSize); void MoveToNextFrame(); PerformanceEntry* GetEntries(s32*); @@ -18,7 +18,7 @@ class PerformanceInfo { private: void* m_Buffer; - std::size_t m_BufferSize; + size_t m_BufferSize; PerformanceFrameHeader* m_Header; PerformanceEntry* m_Entries; PerformanceDetail* m_Details; From 965fb21d53e3cd4c8fd515186ab25b6fd332920e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 7 Aug 2026 14:13:48 -0400 Subject: [PATCH 181/785] atk: Match `SoundArchive` constructor --- CMakeLists.txt | 99 ++++++++++++----------- src/NintendoWare/atk/.gitkeep | 0 src/NintendoWare/atk/atk_SoundArchive.cpp | 8 ++ 3 files changed, 60 insertions(+), 47 deletions(-) delete mode 100644 src/NintendoWare/atk/.gitkeep create mode 100644 src/NintendoWare/atk/atk_SoundArchive.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 83e5dc80..96436755 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -245,6 +245,56 @@ add_library(NintendoSDK OBJECT include/nn/audio/audio_VoiceTypes.h include/nn/audio/audio_WaveBuffer.h + include/nvn/nvn_Cpp.h + include/nvn/nvn_CppFuncPtrBase.h + include/nvn/nvn_CppMethods.h + include/nvn/nvn_FuncPtrBase.h + include/nvn/nvn_FuncPtrInline.h + include/nvn/nvn.h + + include/vapours/results.hpp + include/vapours/results/sf_results.hpp + include/vapours/results/capsrv_results.hpp + include/vapours/results/pgl_results.hpp + include/vapours/results/lr_results.hpp + include/vapours/results/spl_results.hpp + include/vapours/results/pm_results.hpp + include/vapours/results/settings_results.hpp + include/vapours/results/debug_results.hpp + include/vapours/results/cal_results.hpp + include/vapours/results/i2c_results.hpp + include/vapours/results/results_common.hpp + include/vapours/results/time_results.hpp + include/vapours/results/vi_results.hpp + include/vapours/results/ns_results.hpp + include/vapours/results/fs_results.hpp + include/vapours/results/hipc_results.hpp + include/vapours/results/os_results.hpp + include/vapours/results/ro_results.hpp + include/vapours/results/loader_results.hpp + include/vapours/results/err_results.hpp + include/vapours/results/ncm_results.hpp + include/vapours/results/svc_results.hpp + include/vapours/results/nim_results.hpp + include/vapours/results/exosphere_results.hpp + include/vapours/results/creport_results.hpp + include/vapours/results/erpt_results.hpp + include/vapours/results/kvdb_results.hpp + include/vapours/results/dmnt_results.hpp + include/vapours/results/updater_results.hpp + include/vapours/results/fatal_results.hpp + include/vapours/results/sm_results.hpp + include/vapours/results/psc_results.hpp + include/vapours/results/nfp_results.hpp + include/nv.h + + src/NintendoSDK/nvn/nvn_CppFuncPtrImpl.h + src/NintendoSDK/nvn/nvn_FuncPtrImpl.h + src/NintendoSDK/nvn/nvn_Impl.cpp +) + +target_sources(NintendoSDK +PUBLIC include/nn/atk/atk_Adpcm.h include/nn/atk/atk_BiquadFilterCallback.h include/nn/atk/atk_FsSoundArchive.h @@ -388,53 +438,8 @@ add_library(NintendoSDK OBJECT include/nn/atk/fnd/io/atkfnd_StreamCache.h include/nn/atk/fnd/os/atkfnd_CriticalSection.h include/nn/atk/fnd/os/atkfnd_Thread.h - - include/nvn/nvn_Cpp.h - include/nvn/nvn_CppFuncPtrBase.h - include/nvn/nvn_CppMethods.h - include/nvn/nvn_FuncPtrBase.h - include/nvn/nvn_FuncPtrInline.h - include/nvn/nvn.h - - include/vapours/results.hpp - include/vapours/results/sf_results.hpp - include/vapours/results/capsrv_results.hpp - include/vapours/results/pgl_results.hpp - include/vapours/results/lr_results.hpp - include/vapours/results/spl_results.hpp - include/vapours/results/pm_results.hpp - include/vapours/results/settings_results.hpp - include/vapours/results/debug_results.hpp - include/vapours/results/cal_results.hpp - include/vapours/results/i2c_results.hpp - include/vapours/results/results_common.hpp - include/vapours/results/time_results.hpp - include/vapours/results/vi_results.hpp - include/vapours/results/ns_results.hpp - include/vapours/results/fs_results.hpp - include/vapours/results/hipc_results.hpp - include/vapours/results/os_results.hpp - include/vapours/results/ro_results.hpp - include/vapours/results/loader_results.hpp - include/vapours/results/err_results.hpp - include/vapours/results/ncm_results.hpp - include/vapours/results/svc_results.hpp - include/vapours/results/nim_results.hpp - include/vapours/results/exosphere_results.hpp - include/vapours/results/creport_results.hpp - include/vapours/results/erpt_results.hpp - include/vapours/results/kvdb_results.hpp - include/vapours/results/dmnt_results.hpp - include/vapours/results/updater_results.hpp - include/vapours/results/fatal_results.hpp - include/vapours/results/sm_results.hpp - include/vapours/results/psc_results.hpp - include/vapours/results/nfp_results.hpp - include/nv.h - - src/NintendoSDK/nvn/nvn_CppFuncPtrImpl.h - src/NintendoSDK/nvn/nvn_FuncPtrImpl.h - src/NintendoSDK/nvn/nvn_Impl.cpp +PRIVATE + src/NintendoWare/atk/atk_SoundArchive.cpp ) target_include_directories(NintendoSDK PUBLIC include/) diff --git a/src/NintendoWare/atk/.gitkeep b/src/NintendoWare/atk/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp new file mode 100644 index 00000000..7a2c34cc --- /dev/null +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -0,0 +1,8 @@ +#include + +namespace nn::atk { +SoundArchive::SoundArchive() { + m_ExtFileRoot[0] = '/'; + m_ExtFileRoot[1] = '\0'; +}; +} // namespace nn::atk \ No newline at end of file From b4c8ef5e4a07c2d9a03d7077124d57df6e68fcc6 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 7 Aug 2026 14:28:33 -0400 Subject: [PATCH 182/785] atk: Match `SoundArchive` destructor --- src/NintendoWare/atk/atk_SoundArchive.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 7a2c34cc..505852f2 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -5,4 +5,6 @@ SoundArchive::SoundArchive() { m_ExtFileRoot[0] = '/'; m_ExtFileRoot[1] = '\0'; }; + +SoundArchive::~SoundArchive() = default; } // namespace nn::atk \ No newline at end of file From 405415f46a6b8470838b93a85cd9b0ef97517d56 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 7 Aug 2026 14:30:47 -0400 Subject: [PATCH 183/785] atk: Match `SoundArchive::IsAvailable` --- src/NintendoWare/atk/atk_SoundArchive.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 505852f2..a435cfe3 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -7,4 +7,8 @@ SoundArchive::SoundArchive() { }; SoundArchive::~SoundArchive() = default; + +bool SoundArchive::IsAvailable() const { + return m_pFileReader != nullptr; +} } // namespace nn::atk \ No newline at end of file From 21025babb4add6775bb6285e64f0663dd248babe Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 7 Aug 2026 14:46:15 -0400 Subject: [PATCH 184/785] atk: Match `SoundArchive::Initialize` --- include/nn/atk/atk_SoundArchive.h | 2 +- include/nn/atk/detail/atk_SoundArchiveFileReader.h | 2 ++ src/NintendoWare/atk/atk_SoundArchive.cpp | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index 222d9386..e077a6cb 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -191,7 +191,7 @@ class SoundArchive { bool IsAvailable() const; - void Initialize(detail::SoundArchiveFileReader* reader); + void Initialize(detail::SoundArchiveFileReader* fileReader); void Finalize(); s32 GetSoundCount() const; diff --git a/include/nn/atk/detail/atk_SoundArchiveFileReader.h b/include/nn/atk/detail/atk_SoundArchiveFileReader.h index 4a326f82..988e3287 100644 --- a/include/nn/atk/detail/atk_SoundArchiveFileReader.h +++ b/include/nn/atk/detail/atk_SoundArchiveFileReader.h @@ -64,6 +64,8 @@ class SoundArchiveFileReader { void* GetAttachedGroupTable(u32) const; // unknown return type private: + friend SoundArchive; + SoundArchiveFile::FileHeader m_Header; SoundArchiveFile::StringBlockBody* m_pStringBlockBody; SoundArchiveFile::InfoBlockBody* m_pInfoBlockBody; diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index a435cfe3..cf6494d3 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -1,5 +1,7 @@ #include +#include + namespace nn::atk { SoundArchive::SoundArchive() { m_ExtFileRoot[0] = '/'; @@ -11,4 +13,9 @@ SoundArchive::~SoundArchive() = default; bool SoundArchive::IsAvailable() const { return m_pFileReader != nullptr; } + +void SoundArchive::Initialize(detail::SoundArchiveFileReader* fileReader) { + m_pFileReader = fileReader; + m_FileBlockOffset = fileReader->m_Header.GetFileBlockOffset(); +} } // namespace nn::atk \ No newline at end of file From 83f21dab5f3b6532f19ad60d468269b44e84f345 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 7 Aug 2026 14:47:42 -0400 Subject: [PATCH 185/785] atk: Match `SoundArchive::Finalize` --- src/NintendoWare/atk/atk_SoundArchive.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index cf6494d3..451b8b3f 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -18,4 +18,14 @@ void SoundArchive::Initialize(detail::SoundArchiveFileReader* fileReader) { m_pFileReader = fileReader; m_FileBlockOffset = fileReader->m_Header.GetFileBlockOffset(); } + +void SoundArchive::Finalize() { + if (m_pFileReader != nullptr) { + m_pFileReader->Finalize(); + m_pFileReader = nullptr; + } + + m_ExtFileRoot[0] = '/'; + m_ExtFileRoot[1] = '\0'; +} } // namespace nn::atk \ No newline at end of file From a97e39625fce83a70d5f795baff164c183d41265 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 7 Aug 2026 18:11:46 -0400 Subject: [PATCH 186/785] atk: Match `SoundArchive::GetPlayerCount` --- include/nn/atk/atk_SoundArchive.h | 12 +++++++----- include/nn/atk/detail/atk_SoundArchiveFileReader.h | 2 ++ src/NintendoWare/atk/atk_SoundArchive.cpp | 7 ++++++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index e077a6cb..f10f1b21 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -185,15 +185,14 @@ class SoundArchive { }; static_assert(sizeof(Sound3DInfo) == 0xc); +protected: SoundArchive(); +public: virtual ~SoundArchive(); bool IsAvailable() const; - void Initialize(detail::SoundArchiveFileReader* fileReader); - void Finalize(); - s32 GetSoundCount() const; s32 GetPlayerCount() const; s32 GetSoundGroupCount() const; @@ -237,8 +236,6 @@ class SoundArchive { bool detail_OpenFileStream(FileId id, void*, size_t, void*, size_t) const; - void OpenExtStreamImpl(void*, size_t, const char*, void*, size_t) const; - char* detail_GetExternalFileFullPath(const char*, char*, size_t) const; void SetExternalFileRoot(const char*); @@ -255,12 +252,17 @@ class SoundArchive { virtual bool IsAddon(); + void Initialize(detail::SoundArchiveFileReader* fileReader); + void Finalize(); + virtual detail::fnd::FileStream* OpenStream(void* buffer, size_t size, position_t begin, size_t length) const = 0; virtual detail::fnd::FileStream* OpenExtStream(void* buffer, size_t size, const char* extFilePath, void* cacheBuffer, size_t cacheSize) const = 0; + void OpenExtStreamImpl(void*, size_t, const char*, void*, size_t) const; + private: detail::SoundArchiveFileReader* m_pFileReader{}; detail::SoundArchiveParametersHook* m_pParametersHook{}; diff --git a/include/nn/atk/detail/atk_SoundArchiveFileReader.h b/include/nn/atk/detail/atk_SoundArchiveFileReader.h index 988e3287..a36b562a 100644 --- a/include/nn/atk/detail/atk_SoundArchiveFileReader.h +++ b/include/nn/atk/detail/atk_SoundArchiveFileReader.h @@ -63,6 +63,8 @@ class SoundArchiveFileReader { bool ReadSoundUserParam(u32*, u32, s32) const; void* GetAttachedGroupTable(u32) const; // unknown return type + int GetFileBlockOffset() const { return m_Header.GetFileBlockOffset(); } + private: friend SoundArchive; diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 451b8b3f..8b7dacaf 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -16,7 +16,7 @@ bool SoundArchive::IsAvailable() const { void SoundArchive::Initialize(detail::SoundArchiveFileReader* fileReader) { m_pFileReader = fileReader; - m_FileBlockOffset = fileReader->m_Header.GetFileBlockOffset(); + m_FileBlockOffset = fileReader->GetFileBlockOffset(); } void SoundArchive::Finalize() { @@ -28,4 +28,9 @@ void SoundArchive::Finalize() { m_ExtFileRoot[0] = '/'; m_ExtFileRoot[1] = '\0'; } + +s32 SoundArchive::GetPlayerCount() const { + return m_pFileReader->GetPlayerCount(); +} + } // namespace nn::atk \ No newline at end of file From 765ae472ae01add2078ab755c248d967410a4a48 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 7 Aug 2026 18:18:06 -0400 Subject: [PATCH 187/785] atk: Match `SoundArchive::GetWaveArchiveCount` Also added some inlined functions --- include/nn/atk/atk_SoundArchive.h | 5 +++-- src/NintendoWare/atk/atk_SoundArchive.cpp | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index f10f1b21..710b6318 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -194,9 +194,9 @@ class SoundArchive { bool IsAvailable() const; s32 GetSoundCount() const; + s32 GetGroupCount() const; s32 GetPlayerCount() const; s32 GetSoundGroupCount() const; - s32 GetGroupCount() const; s32 GetBankCount() const; s32 GetWaveArchiveCount() const; @@ -252,6 +252,7 @@ class SoundArchive { virtual bool IsAddon(); +protected: void Initialize(detail::SoundArchiveFileReader* fileReader); void Finalize(); @@ -261,7 +262,7 @@ class SoundArchive { virtual detail::fnd::FileStream* OpenExtStream(void* buffer, size_t size, const char* extFilePath, void* cacheBuffer, size_t cacheSize) const = 0; - void OpenExtStreamImpl(void*, size_t, const char*, void*, size_t) const; + detail::fnd::FileStream* OpenExtStreamImpl(void*, size_t, const char*, void*, size_t) const; private: detail::SoundArchiveFileReader* m_pFileReader{}; diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 8b7dacaf..0711225c 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -29,8 +29,27 @@ void SoundArchive::Finalize() { m_ExtFileRoot[1] = '\0'; } +s32 SoundArchive::GetSoundCount() const { + return m_pFileReader->GetSoundCount(); +} + +s32 SoundArchive::GetGroupCount() const { + return m_pFileReader->GetGroupCount(); +} + s32 SoundArchive::GetPlayerCount() const { return m_pFileReader->GetPlayerCount(); } +s32 SoundArchive::GetSoundGroupCount() const { + return m_pFileReader->GetSoundGroupCount(); +} + +s32 SoundArchive::GetBankCount() const { + return m_pFileReader->GetBankCount(); +} + +s32 SoundArchive::GetWaveArchiveCount() const { + return m_pFileReader->GetWaveArchiveCount(); +} } // namespace nn::atk \ No newline at end of file From 6784b7b53ee657ae8e7e035ae667e72864509bd9 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 7 Aug 2026 18:21:31 -0400 Subject: [PATCH 188/785] atk: Match `SoundArchive::detail_GetFileCount` --- include/nn/atk/atk_SoundArchive.h | 15 +++++++-------- .../nn/atk/detail/atk_SoundArchiveFileReader.h | 14 +++++++------- src/NintendoWare/atk/atk_SoundArchive.cpp | 16 ++++++++++------ 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index 710b6318..421f4385 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -193,14 +193,13 @@ class SoundArchive { bool IsAvailable() const; - s32 GetSoundCount() const; - s32 GetGroupCount() const; - s32 GetPlayerCount() const; - s32 GetSoundGroupCount() const; - s32 GetBankCount() const; - s32 GetWaveArchiveCount() const; - - s32 detail_GetFileCount() const; + u32 GetSoundCount() const; + u32 GetGroupCount() const; + u32 GetPlayerCount() const; + u32 GetSoundGroupCount() const; + u32 GetBankCount() const; + u32 GetWaveArchiveCount() const; + u32 detail_GetFileCount() const; char* GetItemLabel(ItemId id) const; FileId GetItemFileId(ItemId id) const; diff --git a/include/nn/atk/detail/atk_SoundArchiveFileReader.h b/include/nn/atk/detail/atk_SoundArchiveFileReader.h index a36b562a..c81a2133 100644 --- a/include/nn/atk/detail/atk_SoundArchiveFileReader.h +++ b/include/nn/atk/detail/atk_SoundArchiveFileReader.h @@ -33,13 +33,13 @@ class SoundArchiveFileReader { SoundArchive::FileId GetItemFileId(SoundArchive::ItemId id) const; SoundArchive::FileId GetItemPrefetchFileId(SoundArchive::ItemId id) const; - s32 GetSoundCount() const; - s32 GetBankCount() const; - s32 GetPlayerCount() const; - s32 GetSoundGroupCount() const; - s32 GetGroupCount() const; - s32 GetWaveArchiveCount() const; - s32 GetFileCount() const; + u32 GetSoundCount() const; + u32 GetBankCount() const; + u32 GetPlayerCount() const; + u32 GetSoundGroupCount() const; + u32 GetGroupCount() const; + u32 GetWaveArchiveCount() const; + u32 GetFileCount() const; bool ReadSoundInfo(SoundArchive::ItemId soundId, SoundArchive::SoundInfo* info) const; bool ReadBankInfo(SoundArchive::ItemId bankId, SoundArchive::BankInfo* info) const; diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 0711225c..2cfdd422 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -29,27 +29,31 @@ void SoundArchive::Finalize() { m_ExtFileRoot[1] = '\0'; } -s32 SoundArchive::GetSoundCount() const { +u32 SoundArchive::GetSoundCount() const { return m_pFileReader->GetSoundCount(); } -s32 SoundArchive::GetGroupCount() const { +u32 SoundArchive::GetGroupCount() const { return m_pFileReader->GetGroupCount(); } -s32 SoundArchive::GetPlayerCount() const { +u32 SoundArchive::GetPlayerCount() const { return m_pFileReader->GetPlayerCount(); } -s32 SoundArchive::GetSoundGroupCount() const { +u32 SoundArchive::GetSoundGroupCount() const { return m_pFileReader->GetSoundGroupCount(); } -s32 SoundArchive::GetBankCount() const { +u32 SoundArchive::GetBankCount() const { return m_pFileReader->GetBankCount(); } -s32 SoundArchive::GetWaveArchiveCount() const { +u32 SoundArchive::GetWaveArchiveCount() const { return m_pFileReader->GetWaveArchiveCount(); } + +u32 SoundArchive::detail_GetFileCount() const { + return m_pFileReader->GetFileCount(); +} } // namespace nn::atk \ No newline at end of file From 67098080e575f60a3297e2fd7219732b23542959 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 7 Aug 2026 21:19:19 -0400 Subject: [PATCH 189/785] atk: Move files around to match DWARF paths Paths were incorrect before, and the new paths also allow for better compatibility --- CMakeLists.txt | 205 +++++++++--------- include/nn/atk/atk_Adpcm.h | 3 +- .../atk_AudioRendererPerformanceReader.h | 10 +- include/nn/atk/{detail/seq => }/atk_Bank.h | 6 +- .../nn/atk/{detail/seq => }/atk_BankFile.h | 2 +- .../atk/{detail/seq => }/atk_BankFileReader.h | 2 +- include/nn/atk/{detail => }/atk_BasicSound.h | 10 +- .../atk/{detail => }/atk_BasicSoundPlayer.h | 6 +- .../{detail/util => }/atk_BinaryFileFormat.h | 0 .../dsp => }/atk_BiquadFilterPresets.h | 0 .../atk/{detail => }/atk_BusMixVolumePacket.h | 0 .../nn/atk/{detail/voice => }/atk_Channel.h | 12 +- .../{detail/voice => }/atk_ChannelManager.h | 4 +- .../atk/{submix => }/atk_ChannelMixVolume.h | 0 .../nn/atk/{detail/thread => }/atk_Command.h | 0 .../{detail/thread => }/atk_CommandManager.h | 2 +- include/nn/atk/{detail => }/atk_Config.h | 0 .../nn/atk/{detail/util => }/atk_CurveAdshr.h | 0 .../nn/atk/{detail/util => }/atk_CurveLfo.h | 0 include/nn/atk/{detail/debug => }/atk_Debug.h | 0 .../nn/atk/{util => }/atk_DeviceOutRecorder.h | 2 +- .../nn/atk/{detail => }/atk_DisposeCallback.h | 0 .../{detail => }/atk_DisposeCallbackManager.h | 2 +- .../{detail/thread => }/atk_DriverCommand.h | 12 +- .../atk/{detail/dsp => }/atk_DspadpcmReader.h | 0 include/nn/atk/{effect => }/atk_EffectAux.h | 0 include/nn/atk/{effect => }/atk_EffectBase.h | 0 include/nn/atk/{detail => }/atk_ElementType.h | 0 .../{detail => }/atk_ExternalSoundPlayer.h | 2 +- include/nn/atk/{submix => }/atk_FinalMix.h | 2 +- .../nn/atk/{detail/util => }/atk_FrameHeap.h | 0 include/nn/atk/atk_FsSoundArchive.h | 2 +- include/nn/atk/atk_Global.h | 2 +- include/nn/atk/{detail => }/atk_GroupFile.h | 2 +- .../nn/atk/{detail => }/atk_GroupFileReader.h | 2 +- .../{detail/dsp => }/atk_HardwareManager.h | 8 +- .../atk/{detail/util => }/atk_InstancePool.h | 0 include/nn/atk/{detail => }/atk_ItemType.h | 0 .../nn/atk/{detail => }/atk_LoaderManager.h | 2 +- .../{detail/voice => }/atk_LowLevelVoice.h | 4 +- .../nn/atk/{detail/seq => }/atk_MmlCommand.h | 0 .../nn/atk/{detail/seq => }/atk_MmlParser.h | 2 +- .../{detail/seq => }/atk_MmlSequenceTrack.h | 2 +- .../seq => }/atk_MmlSequenceTrackAllocator.h | 6 +- include/nn/atk/{detail => }/atk_MoveValue.h | 0 .../atk/{detail/voice => }/atk_MultiVoice.h | 4 +- .../voice => }/atk_MultiVoiceManager.h | 2 +- .../nn/atk/{detail => }/atk_NoteOnCallback.h | 2 +- .../{detail => }/atk_OutputAdditionalParam.h | 6 +- include/nn/atk/{submix => }/atk_OutputMixer.h | 6 +- .../nn/atk/{submix => }/atk_OutputReceiver.h | 0 include/nn/atk/{detail => }/atk_PlayerHeap.h | 0 .../{detail => }/atk_PlayerHeapDataManager.h | 4 +- include/nn/atk/{util => }/atk_ProfileReader.h | 0 .../atk/{detail/seq => }/atk_SequenceSound.h | 4 +- .../{detail/seq => }/atk_SequenceSoundFile.h | 2 +- .../seq => }/atk_SequenceSoundFileReader.h | 2 +- .../seq => }/atk_SequenceSoundPlayer.h | 16 +- .../seq => }/atk_SequenceSoundRuntime.h | 8 +- .../atk/{detail/seq => }/atk_SequenceTrack.h | 2 +- .../seq => }/atk_SequenceTrackAllocator.h | 2 +- include/nn/atk/atk_SoundActor.h | 2 +- include/nn/atk/atk_SoundArchive.h | 6 +- .../atk/{detail => }/atk_SoundArchiveFile.h | 4 +- .../{detail => }/atk_SoundArchiveFileReader.h | 2 +- include/nn/atk/atk_SoundArchiveFilesHook.h | 1 + .../atk/{detail => }/atk_SoundArchiveLoader.h | 0 .../nn/atk/atk_SoundArchiveParametersHook.h | 33 +++ include/nn/atk/atk_SoundArchivePlayer.h | 6 +- include/nn/atk/atk_SoundDataManager.h | 6 +- include/nn/atk/atk_SoundHandle.h | 2 +- include/nn/atk/atk_SoundHeap.h | 2 +- .../{detail => }/atk_SoundInstanceManager.h | 2 +- include/nn/atk/atk_SoundPlayer.h | 6 +- .../{detail => }/atk_SoundRuntimeUtility.h | 0 include/nn/atk/atk_SoundStartable.h | 4 +- include/nn/atk/atk_SoundSystem.h | 12 +- .../atk/{detail/thread => }/atk_SoundThread.h | 6 +- .../nn/atk/{detail => }/atk_StartInfoReader.h | 0 .../{detail/strm => }/atk_StreamBufferPool.h | 0 .../atk/{detail/strm => }/atk_StreamSound.h | 4 +- .../{detail/strm => }/atk_StreamSoundFile.h | 2 +- .../strm => }/atk_StreamSoundFileLoader.h | 2 +- .../strm => }/atk_StreamSoundFileReader.h | 2 +- .../{detail/strm => }/atk_StreamSoundLoader.h | 12 +- .../{detail/strm => }/atk_StreamSoundPlayer.h | 10 +- .../strm => }/atk_StreamSoundPrefetchFile.h | 4 +- .../atk_StreamSoundPrefetchFileReader.h | 2 +- .../strm => }/atk_StreamSoundRuntime.h | 4 +- .../atk/{detail/strm => }/atk_StreamTrack.h | 2 +- include/nn/atk/{submix => }/atk_SubMix.h | 4 +- include/nn/atk/{detail/thread => }/atk_Task.h | 2 +- .../atk/{detail/thread => }/atk_TaskManager.h | 2 +- .../nn/atk/{util => }/atk_TaskProfileReader.h | 4 +- .../atk/{detail/thread => }/atk_TaskThread.h | 0 .../thread => }/atk_ThreadInfoReader.h | 0 include/nn/atk/{detail/util => }/atk_Util.h | 2 +- include/nn/atk/{detail => }/atk_ValueArray.h | 0 include/nn/atk/{detail/voice => }/atk_Voice.h | 4 +- .../atk/{detail/voice => }/atk_VoiceCommand.h | 4 +- .../atk_VolumeThroughModePacket.h | 2 +- .../nn/atk/{detail/util => }/atk_WavBinary.h | 0 .../{detail/util => }/atk_WavOutFileStream.h | 2 +- .../nn/atk/{detail => }/atk_WaveArchiveFile.h | 2 +- .../{detail => }/atk_WaveArchiveFileReader.h | 2 +- include/nn/atk/{detail => }/atk_WaveFile.h | 2 +- .../nn/atk/{detail => }/atk_WaveFileReader.h | 4 +- .../nn/atk/{detail/wsd => }/atk_WaveSound.h | 6 +- .../atk/{detail/wsd => }/atk_WaveSoundFile.h | 2 +- .../wsd => }/atk_WaveSoundFileReader.h | 2 +- .../{detail/wsd => }/atk_WaveSoundLoader.h | 8 +- .../{detail/wsd => }/atk_WaveSoundPlayer.h | 8 +- .../{detail/wsd => }/atk_WaveSoundRuntime.h | 4 +- include/nn/atk/detail/atk_AdvancedWaveSound.h | 4 +- .../nn/atk/detail/atk_AdvancedWaveSoundFile.h | 2 +- .../atk/detail/atk_AdvancedWaveSoundPlayer.h | 8 +- .../atk/detail/atk_AdvancedWaveSoundRuntime.h | 4 +- .../atk/detail/{util => }/atk_BinaryTypes.h | 0 .../nn/atk/detail/atk_IRegionInfoReadable.h | 2 +- .../nn/atk/detail/atk_IStreamDataDecoder.h | 2 +- .../detail/{util => }/atk_MemoryFileStream.h | 2 +- include/nn/atk/detail/atk_RegionManager.h | 2 +- include/nn/atk/fnd/basis/atkfnd_Inlines.h | 1 + .../nn/atk/fnd/binary/atkfnd_PrimitiveTypes.h | 1 + .../atk/fnd/{basis => io}/atkfnd_ScopedLock.h | 0 include/nn/atk/fnd/string/atkfnd_String.h | 1 + src/NintendoWare/atk/atk_SoundArchive.cpp | 2 +- 127 files changed, 327 insertions(+), 282 deletions(-) rename include/nn/atk/{util => }/atk_AudioRendererPerformanceReader.h (70%) rename include/nn/atk/{detail/seq => }/atk_Bank.h (71%) rename include/nn/atk/{detail/seq => }/atk_BankFile.h (98%) rename include/nn/atk/{detail/seq => }/atk_BankFileReader.h (95%) rename include/nn/atk/{detail => }/atk_BasicSound.h (98%) rename include/nn/atk/{detail => }/atk_BasicSoundPlayer.h (90%) rename include/nn/atk/{detail/util => }/atk_BinaryFileFormat.h (100%) rename include/nn/atk/{detail/dsp => }/atk_BiquadFilterPresets.h (100%) rename include/nn/atk/{detail => }/atk_BusMixVolumePacket.h (100%) rename include/nn/atk/{detail/voice => }/atk_Channel.h (93%) rename include/nn/atk/{detail/voice => }/atk_ChannelManager.h (92%) rename include/nn/atk/{submix => }/atk_ChannelMixVolume.h (100%) rename include/nn/atk/{detail/thread => }/atk_Command.h (100%) rename include/nn/atk/{detail/thread => }/atk_CommandManager.h (98%) rename include/nn/atk/{detail => }/atk_Config.h (100%) rename include/nn/atk/{detail/util => }/atk_CurveAdshr.h (100%) rename include/nn/atk/{detail/util => }/atk_CurveLfo.h (100%) rename include/nn/atk/{detail/debug => }/atk_Debug.h (100%) rename include/nn/atk/{util => }/atk_DeviceOutRecorder.h (98%) rename include/nn/atk/{detail => }/atk_DisposeCallback.h (100%) rename include/nn/atk/{detail => }/atk_DisposeCallbackManager.h (93%) rename include/nn/atk/{detail/thread => }/atk_DriverCommand.h (98%) rename include/nn/atk/{detail/dsp => }/atk_DspadpcmReader.h (100%) rename include/nn/atk/{effect => }/atk_EffectAux.h (100%) rename include/nn/atk/{effect => }/atk_EffectBase.h (100%) rename include/nn/atk/{detail => }/atk_ElementType.h (100%) rename include/nn/atk/{detail => }/atk_ExternalSoundPlayer.h (95%) rename include/nn/atk/{submix => }/atk_FinalMix.h (96%) rename include/nn/atk/{detail/util => }/atk_FrameHeap.h (100%) rename include/nn/atk/{detail => }/atk_GroupFile.h (96%) rename include/nn/atk/{detail => }/atk_GroupFileReader.h (94%) rename include/nn/atk/{detail/dsp => }/atk_HardwareManager.h (98%) rename include/nn/atk/{detail/util => }/atk_InstancePool.h (100%) rename include/nn/atk/{detail => }/atk_ItemType.h (100%) rename include/nn/atk/{detail => }/atk_LoaderManager.h (91%) rename include/nn/atk/{detail/voice => }/atk_LowLevelVoice.h (97%) rename include/nn/atk/{detail/seq => }/atk_MmlCommand.h (100%) rename include/nn/atk/{detail/seq => }/atk_MmlParser.h (96%) rename include/nn/atk/{detail/seq => }/atk_MmlSequenceTrack.h (87%) rename include/nn/atk/{detail/seq => }/atk_MmlSequenceTrackAllocator.h (78%) rename include/nn/atk/{detail => }/atk_MoveValue.h (100%) rename include/nn/atk/{detail/voice => }/atk_MultiVoice.h (98%) rename include/nn/atk/{detail/voice => }/atk_MultiVoiceManager.h (96%) rename include/nn/atk/{detail => }/atk_NoteOnCallback.h (94%) rename include/nn/atk/{detail => }/atk_OutputAdditionalParam.h (93%) rename include/nn/atk/{submix => }/atk_OutputMixer.h (92%) rename include/nn/atk/{submix => }/atk_OutputReceiver.h (100%) rename include/nn/atk/{detail => }/atk_PlayerHeap.h (100%) rename include/nn/atk/{detail => }/atk_PlayerHeapDataManager.h (92%) rename include/nn/atk/{util => }/atk_ProfileReader.h (100%) rename include/nn/atk/{detail/seq => }/atk_SequenceSound.h (97%) rename include/nn/atk/{detail/seq => }/atk_SequenceSoundFile.h (96%) rename include/nn/atk/{detail/seq => }/atk_SequenceSoundFileReader.h (91%) rename include/nn/atk/{detail/seq => }/atk_SequenceSoundPlayer.h (95%) rename include/nn/atk/{detail/seq => }/atk_SequenceSoundRuntime.h (96%) rename include/nn/atk/{detail/seq => }/atk_SequenceTrack.h (98%) rename include/nn/atk/{detail/seq => }/atk_SequenceTrackAllocator.h (87%) rename include/nn/atk/{detail => }/atk_SoundArchiveFile.h (99%) rename include/nn/atk/{detail => }/atk_SoundArchiveFileReader.h (98%) create mode 100644 include/nn/atk/atk_SoundArchiveFilesHook.h rename include/nn/atk/{detail => }/atk_SoundArchiveLoader.h (100%) create mode 100644 include/nn/atk/atk_SoundArchiveParametersHook.h rename include/nn/atk/{detail => }/atk_SoundInstanceManager.h (95%) rename include/nn/atk/{detail => }/atk_SoundRuntimeUtility.h (100%) rename include/nn/atk/{detail/thread => }/atk_SoundThread.h (97%) rename include/nn/atk/{detail => }/atk_StartInfoReader.h (100%) rename include/nn/atk/{detail/strm => }/atk_StreamBufferPool.h (100%) rename include/nn/atk/{detail/strm => }/atk_StreamSound.h (96%) rename include/nn/atk/{detail/strm => }/atk_StreamSoundFile.h (98%) rename include/nn/atk/{detail/strm => }/atk_StreamSoundFileLoader.h (92%) rename include/nn/atk/{detail/strm => }/atk_StreamSoundFileReader.h (95%) rename include/nn/atk/{detail/strm => }/atk_StreamSoundLoader.h (96%) rename include/nn/atk/{detail/strm => }/atk_StreamSoundPlayer.h (97%) rename include/nn/atk/{detail/strm => }/atk_StreamSoundPrefetchFile.h (92%) rename include/nn/atk/{detail/strm => }/atk_StreamSoundPrefetchFileReader.h (96%) rename include/nn/atk/{detail/strm => }/atk_StreamSoundRuntime.h (97%) rename include/nn/atk/{detail/strm => }/atk_StreamTrack.h (94%) rename include/nn/atk/{submix => }/atk_SubMix.h (98%) rename include/nn/atk/{detail/thread => }/atk_Task.h (91%) rename include/nn/atk/{detail/thread => }/atk_TaskManager.h (97%) rename include/nn/atk/{util => }/atk_TaskProfileReader.h (98%) rename include/nn/atk/{detail/thread => }/atk_TaskThread.h (100%) rename include/nn/atk/{detail/thread => }/atk_ThreadInfoReader.h (100%) rename include/nn/atk/{detail/util => }/atk_Util.h (99%) rename include/nn/atk/{detail => }/atk_ValueArray.h (100%) rename include/nn/atk/{detail/voice => }/atk_Voice.h (96%) rename include/nn/atk/{detail/voice => }/atk_VoiceCommand.h (95%) rename include/nn/atk/{detail => }/atk_VolumeThroughModePacket.h (93%) rename include/nn/atk/{detail/util => }/atk_WavBinary.h (100%) rename include/nn/atk/{detail/util => }/atk_WavOutFileStream.h (96%) rename include/nn/atk/{detail => }/atk_WaveArchiveFile.h (96%) rename include/nn/atk/{detail => }/atk_WaveArchiveFileReader.h (95%) rename include/nn/atk/{detail => }/atk_WaveFile.h (97%) rename include/nn/atk/{detail => }/atk_WaveFileReader.h (88%) rename include/nn/atk/{detail/wsd => }/atk_WaveSound.h (92%) rename include/nn/atk/{detail/wsd => }/atk_WaveSoundFile.h (98%) rename include/nn/atk/{detail/wsd => }/atk_WaveSoundFileReader.h (95%) rename include/nn/atk/{detail/wsd => }/atk_WaveSoundLoader.h (91%) rename include/nn/atk/{detail/wsd => }/atk_WaveSoundPlayer.h (94%) rename include/nn/atk/{detail/wsd => }/atk_WaveSoundRuntime.h (95%) rename include/nn/atk/detail/{util => }/atk_BinaryTypes.h (100%) rename include/nn/atk/detail/{util => }/atk_MemoryFileStream.h (97%) create mode 100644 include/nn/atk/fnd/basis/atkfnd_Inlines.h create mode 100644 include/nn/atk/fnd/binary/atkfnd_PrimitiveTypes.h rename include/nn/atk/fnd/{basis => io}/atkfnd_ScopedLock.h (100%) create mode 100644 include/nn/atk/fnd/string/atkfnd_String.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 96436755..d1d1b328 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -296,148 +296,153 @@ add_library(NintendoSDK OBJECT target_sources(NintendoSDK PUBLIC include/nn/atk/atk_Adpcm.h + include/nn/atk/atk_AudioRendererPerformanceReader.h + include/nn/atk/atk_Bank.h + include/nn/atk/atk_BankFile.h + include/nn/atk/atk_BankFileReader.h + include/nn/atk/atk_BasicSound.h + include/nn/atk/atk_BasicSoundPlayer.h + include/nn/atk/atk_BinaryFileFormat.h include/nn/atk/atk_BiquadFilterCallback.h + include/nn/atk/atk_BiquadFilterPresets.h + include/nn/atk/atk_BusMixVolumePacket.h + include/nn/atk/atk_Channel.h + include/nn/atk/atk_ChannelManager.h + include/nn/atk/atk_ChannelMixVolume.h + include/nn/atk/atk_Command.h + include/nn/atk/atk_CommandManager.h + include/nn/atk/atk_Config.h + include/nn/atk/atk_CurveAdshr.h + include/nn/atk/atk_CurveLfo.h + include/nn/atk/atk_Debug.h + include/nn/atk/atk_DeviceOutRecorder.h + include/nn/atk/atk_DisposeCallback.h + include/nn/atk/atk_DisposeCallbackManager.h + include/nn/atk/atk_DriverCommand.h + include/nn/atk/atk_DspadpcmReader.h + include/nn/atk/atk_EffectAux.h + include/nn/atk/atk_EffectBase.h + include/nn/atk/atk_ElementType.h + include/nn/atk/atk_ExternalSoundPlayer.h + include/nn/atk/atk_FinalMix.h + include/nn/atk/atk_FrameHeap.h include/nn/atk/atk_FsSoundArchive.h include/nn/atk/atk_Global.h + include/nn/atk/atk_GroupFile.h + include/nn/atk/atk_GroupFileReader.h + include/nn/atk/atk_HardwareManager.h + include/nn/atk/atk_InstancePool.h + include/nn/atk/atk_ItemType.h + include/nn/atk/atk_LoaderManager.h + include/nn/atk/atk_LowLevelVoice.h + include/nn/atk/atk_MmlCommand.h + include/nn/atk/atk_MmlParser.h + include/nn/atk/atk_MmlSequenceTrack.h + include/nn/atk/atk_MmlSequenceTrackAllocator.h + include/nn/atk/atk_MoveValue.h + include/nn/atk/atk_MultiVoice.h + include/nn/atk/atk_MultiVoiceManager.h + include/nn/atk/atk_NoteOnCallback.h + include/nn/atk/atk_OutputAdditionalParam.h + include/nn/atk/atk_OutputMixer.h + include/nn/atk/atk_OutputReceiver.h + include/nn/atk/atk_PlayerHeap.h + include/nn/atk/atk_PlayerHeapDataManager.h + include/nn/atk/atk_ProfileReader.h + include/nn/atk/atk_SequenceSound.h + include/nn/atk/atk_SequenceSoundFile.h + include/nn/atk/atk_SequenceSoundFileReader.h include/nn/atk/atk_SequenceSoundHandle.h + include/nn/atk/atk_SequenceSoundPlayer.h + include/nn/atk/atk_SequenceSoundRuntime.h + include/nn/atk/atk_SequenceTrack.h + include/nn/atk/atk_SequenceTrackAllocator.h include/nn/atk/atk_SoundActor.h include/nn/atk/atk_SoundArchive.h + include/nn/atk/atk_SoundArchiveFile.h + include/nn/atk/atk_SoundArchiveFileReader.h + include/nn/atk/atk_SoundArchiveFilesHook.h + include/nn/atk/atk_SoundArchiveLoader.h + include/nn/atk/atk_SoundArchiveParametersHook.h include/nn/atk/atk_SoundArchivePlayer.h include/nn/atk/atk_SoundDataManager.h include/nn/atk/atk_SoundHandle.h include/nn/atk/atk_SoundHeap.h + include/nn/atk/atk_SoundInstanceManager.h include/nn/atk/atk_SoundMemoryAllocatable.h include/nn/atk/atk_SoundPlayer.h + include/nn/atk/atk_SoundRuntimeUtility.h include/nn/atk/atk_SoundStartable.h include/nn/atk/atk_SoundSystem.h + include/nn/atk/atk_SoundThread.h + include/nn/atk/atk_StartInfoReader.h + include/nn/atk/atk_StreamBufferPool.h + include/nn/atk/atk_StreamSound.h + include/nn/atk/atk_StreamSoundFile.h + include/nn/atk/atk_StreamSoundFileLoader.h + include/nn/atk/atk_StreamSoundFileReader.h include/nn/atk/atk_StreamSoundHandle.h + include/nn/atk/atk_StreamSoundLoader.h + include/nn/atk/atk_StreamSoundPlayer.h + include/nn/atk/atk_StreamSoundPrefetchFile.h + include/nn/atk/atk_StreamSoundPrefetchFileReader.h + include/nn/atk/atk_StreamSoundRuntime.h + include/nn/atk/atk_StreamTrack.h + include/nn/atk/atk_SubMix.h + include/nn/atk/atk_Task.h + include/nn/atk/atk_TaskManager.h + include/nn/atk/atk_TaskProfileReader.h + include/nn/atk/atk_TaskThread.h + include/nn/atk/atk_ThreadInfoReader.h + include/nn/atk/atk_Util.h + include/nn/atk/atk_ValueArray.h + include/nn/atk/atk_Voice.h + include/nn/atk/atk_VoiceCommand.h + include/nn/atk/atk_VolumeThroughModePacket.h + include/nn/atk/atk_WavBinary.h + include/nn/atk/atk_WaveArchiveFile.h + include/nn/atk/atk_WaveArchiveFileReader.h + include/nn/atk/atk_WaveFile.h + include/nn/atk/atk_WaveSound.h + include/nn/atk/atk_WaveSoundFile.h + include/nn/atk/atk_WaveSoundFileReader.h include/nn/atk/atk_WaveSoundHandle.h + include/nn/atk/atk_WaveSoundLoader.h + include/nn/atk/atk_WaveSoundPlayer.h + include/nn/atk/atk_WaveSoundRuntime.h + include/nn/atk/atk_WavOutFileStream.h + include/nn/atk/detail/atk_AddonSoundArchiveContainer.h include/nn/atk/detail/atk_AdvancedWaveSound.h include/nn/atk/detail/atk_AdvancedWaveSoundFile.h include/nn/atk/detail/atk_AdvancedWaveSoundFileReader.h include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h - include/nn/atk/detail/atk_BasicSound.h - include/nn/atk/detail/atk_BasicSoundPlayer.h - include/nn/atk/detail/atk_BusMixVolumePacket.h - include/nn/atk/detail/atk_Config.h - include/nn/atk/detail/atk_DisposeCallback.h - include/nn/atk/detail/atk_DisposeCallbackManager.h - include/nn/atk/detail/atk_ElementType.h - include/nn/atk/detail/atk_ExternalSoundPlayer.h - include/nn/atk/detail/atk_GroupFile.h - include/nn/atk/detail/atk_GroupFileReader.h + include/nn/atk/detail/atk_BinaryTypes.h include/nn/atk/detail/atk_IntrusiveList.h include/nn/atk/detail/atk_IRegionInfoReadable.h include/nn/atk/detail/atk_IStreamDataDecoder.h - include/nn/atk/detail/atk_ItemType.h - include/nn/atk/detail/atk_LoaderManager.h - include/nn/atk/detail/atk_MoveValue.h - include/nn/atk/detail/atk_NoteOnCallback.h - include/nn/atk/detail/atk_OutputAdditionalParam.h - include/nn/atk/detail/atk_PlayerHeap.h - include/nn/atk/detail/atk_PlayerHeapDataManager.h include/nn/atk/detail/atk_RegionManager.h - include/nn/atk/detail/atk_SoundArchiveFile.h - include/nn/atk/detail/atk_SoundArchiveFileReader.h - include/nn/atk/detail/atk_SoundArchiveLoader.h + include/nn/atk/detail/atk_MemoryFileStream.h include/nn/atk/detail/atk_SoundArchiveManager.h - include/nn/atk/detail/atk_SoundInstanceManager.h - include/nn/atk/detail/atk_SoundRuntimeUtility.h - include/nn/atk/detail/atk_StartInfoReader.h - include/nn/atk/detail/atk_ValueArray.h - include/nn/atk/detail/atk_VolumeThroughModePacket.h - include/nn/atk/detail/atk_WaveArchiveFile.h - include/nn/atk/detail/atk_WaveArchiveFileReader.h - include/nn/atk/detail/atk_WaveFile.h - include/nn/atk/detail/debug/atk_Debug.h - include/nn/atk/detail/dsp/atk_BiquadFilterPresets.h - include/nn/atk/detail/dsp/atk_DspadpcmReader.h - include/nn/atk/detail/dsp/atk_HardwareManager.h - include/nn/atk/detail/seq/atk_Bank.h - include/nn/atk/detail/seq/atk_BankFile.h - include/nn/atk/detail/seq/atk_BankFileReader.h - include/nn/atk/detail/seq/atk_MmlCommand.h - include/nn/atk/detail/seq/atk_MmlParser.h - include/nn/atk/detail/seq/atk_MmlSequenceTrack.h - include/nn/atk/detail/seq/atk_MmlSequenceTrackAllocator.h - include/nn/atk/detail/seq/atk_SequenceSound.h - include/nn/atk/detail/seq/atk_SequenceSoundFile.h - include/nn/atk/detail/seq/atk_SequenceSoundFileReader.h - include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h - include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h - include/nn/atk/detail/seq/atk_SequenceTrack.h - include/nn/atk/detail/seq/atk_SequenceTrackAllocator.h - include/nn/atk/detail/strm/atk_StreamBufferPool.h - include/nn/atk/detail/strm/atk_StreamSound.h - include/nn/atk/detail/strm/atk_StreamSoundFile.h - include/nn/atk/detail/strm/atk_StreamSoundFileLoader.h - include/nn/atk/detail/strm/atk_StreamSoundFileReader.h - include/nn/atk/detail/strm/atk_StreamSoundLoader.h - include/nn/atk/detail/strm/atk_StreamSoundPlayer.h - include/nn/atk/detail/strm/atk_StreamSoundPrefetchFile.h - include/nn/atk/detail/strm/atk_StreamSoundPrefetchFileReader.h - include/nn/atk/detail/strm/atk_StreamSoundRuntime.h - include/nn/atk/detail/strm/atk_StreamTrack.h - include/nn/atk/detail/thread/atk_Command.h - include/nn/atk/detail/thread/atk_CommandManager.h - include/nn/atk/detail/thread/atk_DriverCommand.h - include/nn/atk/detail/thread/atk_SoundThread.h - include/nn/atk/detail/thread/atk_Task.h - include/nn/atk/detail/thread/atk_TaskManager.h - include/nn/atk/detail/thread/atk_TaskThread.h - include/nn/atk/detail/thread/atk_ThreadInfoReader.h - include/nn/atk/detail/util/atk_CurveAdshr.h - include/nn/atk/detail/util/atk_BinaryFileFormat.h - include/nn/atk/detail/util/atk_BinaryTypes.h - include/nn/atk/detail/util/atk_CurveLfo.h - include/nn/atk/detail/util/atk_FrameHeap.h - include/nn/atk/detail/util/atk_InstancePool.h - include/nn/atk/detail/util/atk_MemoryFileStream.h - include/nn/atk/detail/util/atk_Util.h - include/nn/atk/detail/util/atk_WavBinary.h - include/nn/atk/detail/util/atk_WavOutFileStream.h - include/nn/atk/detail/voice/atk_Channel.h - include/nn/atk/detail/voice/atk_ChannelManager.h - include/nn/atk/detail/voice/atk_LowLevelVoice.h - include/nn/atk/detail/voice/atk_MultiVoice.h - include/nn/atk/detail/voice/atk_MultiVoiceManager.h - include/nn/atk/detail/voice/atk_Voice.h - include/nn/atk/detail/voice/atk_VoiceCommand.h - include/nn/atk/detail/wsd/atk_WaveSound.h - include/nn/atk/detail/wsd/atk_WaveSoundFile.h - include/nn/atk/detail/wsd/atk_WaveSoundFileReader.h - include/nn/atk/detail/wsd/atk_WaveSoundLoader.h - include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h - include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h - include/nn/atk/effect/atk_EffectAux.h - include/nn/atk/effect/atk_EffectBase.h - include/nn/atk/submix/atk_ChannelMixVolume.h - include/nn/atk/submix/atk_FinalMix.h - include/nn/atk/submix/atk_OutputMixer.h - include/nn/atk/submix/atk_OutputReceiver.h - include/nn/atk/submix/atk_SubMix.h - include/nn/atk/util/atk_AudioRendererPerformanceReader.h - include/nn/atk/util/atk_DeviceOutRecorder.h - include/nn/atk/util/atk_ProfileReader.h - include/nn/atk/util/atk_TaskProfileReader.h + include/nn/atk/fnd/basis/atkfnd_Config.h include/nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h include/nn/atk/fnd/basis/atkfnd_HeapBase.h include/nn/atk/fnd/basis/atkfnd_PrimitiveTypes.h include/nn/atk/fnd/basis/atkfnd_Result.h include/nn/atk/fnd/basis/atkfnd_RuntimeTypeInfo.h - include/nn/atk/fnd/basis/atkfnd_ScopedLock.h include/nn/atk/fnd/basis/atkfnd_Time.h include/nn/atk/fnd/basis/atkfnd_WorkBufferAllocator.h include/nn/atk/fnd/io/atkfnd_FileStream.h include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h + include/nn/atk/fnd/io/atkfnd_ScopedLock.h include/nn/atk/fnd/io/atkfnd_Stream.h include/nn/atk/fnd/io/atkfnd_StreamCache.h include/nn/atk/fnd/os/atkfnd_CriticalSection.h include/nn/atk/fnd/os/atkfnd_Thread.h + PRIVATE src/NintendoWare/atk/atk_SoundArchive.cpp ) diff --git a/include/nn/atk/atk_Adpcm.h b/include/nn/atk/atk_Adpcm.h index 720973b5..1e7b5515 100644 --- a/include/nn/atk/atk_Adpcm.h +++ b/include/nn/atk/atk_Adpcm.h @@ -2,7 +2,7 @@ #include -#include +#include namespace nn::atk { using AdpcmParam = audio::AdpcmParameter; @@ -18,6 +18,7 @@ struct AdpcmContextNotAligned { static_assert(sizeof(AdpcmContextNotAligned) == 0x6); namespace detail { +// TODO: Move to atk/detail/dsp/atk_DecodeAdpcm.cpp void DecodeDspAdpcm(position_t playPosition, AdpcmContext& context, const AdpcmParam& param, const void* adpcmData, size_t decodeSamples, s16* dest); diff --git a/include/nn/atk/util/atk_AudioRendererPerformanceReader.h b/include/nn/atk/atk_AudioRendererPerformanceReader.h similarity index 70% rename from include/nn/atk/util/atk_AudioRendererPerformanceReader.h rename to include/nn/atk/atk_AudioRendererPerformanceReader.h index 9f58ecce..18060007 100644 --- a/include/nn/atk/util/atk_AudioRendererPerformanceReader.h +++ b/include/nn/atk/atk_AudioRendererPerformanceReader.h @@ -7,7 +7,7 @@ namespace nn::atk { class AudioRendererPerformanceReader { public: - constexpr static u32 PerformanceInfoCountMin = 2; + static const int PerformanceInfoCountMin = 2; struct PerformanceInfo { void* performanceBuffer; @@ -17,10 +17,12 @@ class AudioRendererPerformanceReader { AudioRendererPerformanceReader(); - static size_t GetRequiredMemorySize(s32); + static size_t GetRequiredMemorySize(int performanceInfoCount); - void Initialize(s32, void*, size_t); - PerformanceInfo* ReadPerformanceInfo(); + void Initialize(int performanceInfoCount, void* buffer, size_t bufferSize); + const PerformanceInfo* ReadPerformanceInfo(); + + bool IsInitialized() const; void Record(const void* performanceFrameBuffer, size_t performanceFrameBufferSize, os::Tick tick); diff --git a/include/nn/atk/detail/seq/atk_Bank.h b/include/nn/atk/atk_Bank.h similarity index 71% rename from include/nn/atk/detail/seq/atk_Bank.h rename to include/nn/atk/atk_Bank.h index d8e5a274..bcbdc2d5 100644 --- a/include/nn/atk/detail/seq/atk_Bank.h +++ b/include/nn/atk/atk_Bank.h @@ -1,8 +1,8 @@ #pragma once -#include -#include -#include +#include +#include +#include namespace nn::atk::detail::driver { class Bank { diff --git a/include/nn/atk/detail/seq/atk_BankFile.h b/include/nn/atk/atk_BankFile.h similarity index 98% rename from include/nn/atk/detail/seq/atk_BankFile.h rename to include/nn/atk/atk_BankFile.h index 98dd8efb..71557aaf 100644 --- a/include/nn/atk/detail/seq/atk_BankFile.h +++ b/include/nn/atk/atk_BankFile.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { struct BankFile { diff --git a/include/nn/atk/detail/seq/atk_BankFileReader.h b/include/nn/atk/atk_BankFileReader.h similarity index 95% rename from include/nn/atk/detail/seq/atk_BankFileReader.h rename to include/nn/atk/atk_BankFileReader.h index 3aeff634..029c6dbc 100644 --- a/include/nn/atk/detail/seq/atk_BankFileReader.h +++ b/include/nn/atk/atk_BankFileReader.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { class BankFileReader { diff --git a/include/nn/atk/detail/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h similarity index 98% rename from include/nn/atk/detail/atk_BasicSound.h rename to include/nn/atk/atk_BasicSound.h index d234db41..f37a452f 100644 --- a/include/nn/atk/detail/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -4,11 +4,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace nn::atk { class SoundActor; diff --git a/include/nn/atk/detail/atk_BasicSoundPlayer.h b/include/nn/atk/atk_BasicSoundPlayer.h similarity index 90% rename from include/nn/atk/detail/atk_BasicSoundPlayer.h rename to include/nn/atk/atk_BasicSoundPlayer.h index 1c17d11c..71e4baf1 100644 --- a/include/nn/atk/detail/atk_BasicSoundPlayer.h +++ b/include/nn/atk/atk_BasicSoundPlayer.h @@ -2,9 +2,9 @@ #include -#include -#include -#include +#include +#include +#include namespace nn::atk::detail::driver { struct PlayerParamSet { diff --git a/include/nn/atk/detail/util/atk_BinaryFileFormat.h b/include/nn/atk/atk_BinaryFileFormat.h similarity index 100% rename from include/nn/atk/detail/util/atk_BinaryFileFormat.h rename to include/nn/atk/atk_BinaryFileFormat.h diff --git a/include/nn/atk/detail/dsp/atk_BiquadFilterPresets.h b/include/nn/atk/atk_BiquadFilterPresets.h similarity index 100% rename from include/nn/atk/detail/dsp/atk_BiquadFilterPresets.h rename to include/nn/atk/atk_BiquadFilterPresets.h diff --git a/include/nn/atk/detail/atk_BusMixVolumePacket.h b/include/nn/atk/atk_BusMixVolumePacket.h similarity index 100% rename from include/nn/atk/detail/atk_BusMixVolumePacket.h rename to include/nn/atk/atk_BusMixVolumePacket.h diff --git a/include/nn/atk/detail/voice/atk_Channel.h b/include/nn/atk/atk_Channel.h similarity index 93% rename from include/nn/atk/detail/voice/atk_Channel.h rename to include/nn/atk/atk_Channel.h index 69424c83..1213a045 100644 --- a/include/nn/atk/detail/voice/atk_Channel.h +++ b/include/nn/atk/atk_Channel.h @@ -1,11 +1,11 @@ #pragma once -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace nn::atk::detail::driver { class ChannelManager; diff --git a/include/nn/atk/detail/voice/atk_ChannelManager.h b/include/nn/atk/atk_ChannelManager.h similarity index 92% rename from include/nn/atk/detail/voice/atk_ChannelManager.h rename to include/nn/atk/atk_ChannelManager.h index 20268b15..2d4b41a0 100644 --- a/include/nn/atk/detail/voice/atk_ChannelManager.h +++ b/include/nn/atk/atk_ChannelManager.h @@ -1,7 +1,7 @@ #pragma once -#include -#include +#include +#include namespace nn::atk::detail::driver { class ChannelManager { diff --git a/include/nn/atk/submix/atk_ChannelMixVolume.h b/include/nn/atk/atk_ChannelMixVolume.h similarity index 100% rename from include/nn/atk/submix/atk_ChannelMixVolume.h rename to include/nn/atk/atk_ChannelMixVolume.h diff --git a/include/nn/atk/detail/thread/atk_Command.h b/include/nn/atk/atk_Command.h similarity index 100% rename from include/nn/atk/detail/thread/atk_Command.h rename to include/nn/atk/atk_Command.h diff --git a/include/nn/atk/detail/thread/atk_CommandManager.h b/include/nn/atk/atk_CommandManager.h similarity index 98% rename from include/nn/atk/detail/thread/atk_CommandManager.h rename to include/nn/atk/atk_CommandManager.h index c2c5a1ba..dd49a138 100644 --- a/include/nn/atk/detail/thread/atk_CommandManager.h +++ b/include/nn/atk/atk_CommandManager.h @@ -3,7 +3,7 @@ #include #include -#include +#include namespace nn::atk::detail { class CommandBuffer { diff --git a/include/nn/atk/detail/atk_Config.h b/include/nn/atk/atk_Config.h similarity index 100% rename from include/nn/atk/detail/atk_Config.h rename to include/nn/atk/atk_Config.h diff --git a/include/nn/atk/detail/util/atk_CurveAdshr.h b/include/nn/atk/atk_CurveAdshr.h similarity index 100% rename from include/nn/atk/detail/util/atk_CurveAdshr.h rename to include/nn/atk/atk_CurveAdshr.h diff --git a/include/nn/atk/detail/util/atk_CurveLfo.h b/include/nn/atk/atk_CurveLfo.h similarity index 100% rename from include/nn/atk/detail/util/atk_CurveLfo.h rename to include/nn/atk/atk_CurveLfo.h diff --git a/include/nn/atk/detail/debug/atk_Debug.h b/include/nn/atk/atk_Debug.h similarity index 100% rename from include/nn/atk/detail/debug/atk_Debug.h rename to include/nn/atk/atk_Debug.h diff --git a/include/nn/atk/util/atk_DeviceOutRecorder.h b/include/nn/atk/atk_DeviceOutRecorder.h similarity index 98% rename from include/nn/atk/util/atk_DeviceOutRecorder.h rename to include/nn/atk/atk_DeviceOutRecorder.h index 47cc76a0..f30e79ad 100644 --- a/include/nn/atk/util/atk_DeviceOutRecorder.h +++ b/include/nn/atk/atk_DeviceOutRecorder.h @@ -7,7 +7,7 @@ #include #include -#include +#include #include namespace nn::atk { diff --git a/include/nn/atk/detail/atk_DisposeCallback.h b/include/nn/atk/atk_DisposeCallback.h similarity index 100% rename from include/nn/atk/detail/atk_DisposeCallback.h rename to include/nn/atk/atk_DisposeCallback.h diff --git a/include/nn/atk/detail/atk_DisposeCallbackManager.h b/include/nn/atk/atk_DisposeCallbackManager.h similarity index 93% rename from include/nn/atk/detail/atk_DisposeCallbackManager.h rename to include/nn/atk/atk_DisposeCallbackManager.h index f615ad3f..0fa9e60c 100644 --- a/include/nn/atk/detail/atk_DisposeCallbackManager.h +++ b/include/nn/atk/atk_DisposeCallbackManager.h @@ -2,7 +2,7 @@ #include -#include +#include namespace nn::atk::detail::driver { class DisposeCallbackManager { diff --git a/include/nn/atk/detail/thread/atk_DriverCommand.h b/include/nn/atk/atk_DriverCommand.h similarity index 98% rename from include/nn/atk/detail/thread/atk_DriverCommand.h rename to include/nn/atk/atk_DriverCommand.h index 848f686f..1450a0a7 100644 --- a/include/nn/atk/detail/thread/atk_DriverCommand.h +++ b/include/nn/atk/atk_DriverCommand.h @@ -1,12 +1,12 @@ #pragma once #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace nn::atk::detail { enum DriverCommandId { diff --git a/include/nn/atk/detail/dsp/atk_DspadpcmReader.h b/include/nn/atk/atk_DspadpcmReader.h similarity index 100% rename from include/nn/atk/detail/dsp/atk_DspadpcmReader.h rename to include/nn/atk/atk_DspadpcmReader.h diff --git a/include/nn/atk/effect/atk_EffectAux.h b/include/nn/atk/atk_EffectAux.h similarity index 100% rename from include/nn/atk/effect/atk_EffectAux.h rename to include/nn/atk/atk_EffectAux.h diff --git a/include/nn/atk/effect/atk_EffectBase.h b/include/nn/atk/atk_EffectBase.h similarity index 100% rename from include/nn/atk/effect/atk_EffectBase.h rename to include/nn/atk/atk_EffectBase.h diff --git a/include/nn/atk/detail/atk_ElementType.h b/include/nn/atk/atk_ElementType.h similarity index 100% rename from include/nn/atk/detail/atk_ElementType.h rename to include/nn/atk/atk_ElementType.h diff --git a/include/nn/atk/detail/atk_ExternalSoundPlayer.h b/include/nn/atk/atk_ExternalSoundPlayer.h similarity index 95% rename from include/nn/atk/detail/atk_ExternalSoundPlayer.h rename to include/nn/atk/atk_ExternalSoundPlayer.h index c1220fc5..155f8508 100644 --- a/include/nn/atk/detail/atk_ExternalSoundPlayer.h +++ b/include/nn/atk/atk_ExternalSoundPlayer.h @@ -2,7 +2,7 @@ #include -#include +#include namespace nn::atk::detail { class ExternalSoundPlayer { diff --git a/include/nn/atk/submix/atk_FinalMix.h b/include/nn/atk/atk_FinalMix.h similarity index 96% rename from include/nn/atk/submix/atk_FinalMix.h rename to include/nn/atk/atk_FinalMix.h index 4de88fc1..17919c42 100644 --- a/include/nn/atk/submix/atk_FinalMix.h +++ b/include/nn/atk/atk_FinalMix.h @@ -4,7 +4,7 @@ #include #include -#include +#include namespace nn::atk { class FinalMix : OutputMixer { diff --git a/include/nn/atk/detail/util/atk_FrameHeap.h b/include/nn/atk/atk_FrameHeap.h similarity index 100% rename from include/nn/atk/detail/util/atk_FrameHeap.h rename to include/nn/atk/atk_FrameHeap.h diff --git a/include/nn/atk/atk_FsSoundArchive.h b/include/nn/atk/atk_FsSoundArchive.h index 2ef5a183..5722a110 100644 --- a/include/nn/atk/atk_FsSoundArchive.h +++ b/include/nn/atk/atk_FsSoundArchive.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h index 3231c668..8af2c404 100644 --- a/include/nn/atk/atk_Global.h +++ b/include/nn/atk/atk_Global.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include namespace nn::atk { enum WaveType { diff --git a/include/nn/atk/detail/atk_GroupFile.h b/include/nn/atk/atk_GroupFile.h similarity index 96% rename from include/nn/atk/detail/atk_GroupFile.h rename to include/nn/atk/atk_GroupFile.h index 9e5d70ed..1d2f5dea 100644 --- a/include/nn/atk/detail/atk_GroupFile.h +++ b/include/nn/atk/atk_GroupFile.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { struct GroupFile { diff --git a/include/nn/atk/detail/atk_GroupFileReader.h b/include/nn/atk/atk_GroupFileReader.h similarity index 94% rename from include/nn/atk/detail/atk_GroupFileReader.h rename to include/nn/atk/atk_GroupFileReader.h index 1f4eba2e..9d46b3ae 100644 --- a/include/nn/atk/detail/atk_GroupFileReader.h +++ b/include/nn/atk/atk_GroupFileReader.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { struct GroupItemLocationInfo { diff --git a/include/nn/atk/detail/dsp/atk_HardwareManager.h b/include/nn/atk/atk_HardwareManager.h similarity index 98% rename from include/nn/atk/detail/dsp/atk_HardwareManager.h rename to include/nn/atk/atk_HardwareManager.h index 73335467..2fc5a44e 100644 --- a/include/nn/atk/detail/dsp/atk_HardwareManager.h +++ b/include/nn/atk/atk_HardwareManager.h @@ -6,10 +6,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include namespace nn::atk::detail::driver { class HardwareManager { // inherits nn::atk::Util::Singleton diff --git a/include/nn/atk/detail/util/atk_InstancePool.h b/include/nn/atk/atk_InstancePool.h similarity index 100% rename from include/nn/atk/detail/util/atk_InstancePool.h rename to include/nn/atk/atk_InstancePool.h diff --git a/include/nn/atk/detail/atk_ItemType.h b/include/nn/atk/atk_ItemType.h similarity index 100% rename from include/nn/atk/detail/atk_ItemType.h rename to include/nn/atk/atk_ItemType.h diff --git a/include/nn/atk/detail/atk_LoaderManager.h b/include/nn/atk/atk_LoaderManager.h similarity index 91% rename from include/nn/atk/detail/atk_LoaderManager.h rename to include/nn/atk/atk_LoaderManager.h index 0d4cbbd1..98063445 100644 --- a/include/nn/atk/detail/atk_LoaderManager.h +++ b/include/nn/atk/atk_LoaderManager.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { template diff --git a/include/nn/atk/detail/voice/atk_LowLevelVoice.h b/include/nn/atk/atk_LowLevelVoice.h similarity index 97% rename from include/nn/atk/detail/voice/atk_LowLevelVoice.h rename to include/nn/atk/atk_LowLevelVoice.h index 5b2cebc1..b8873074 100644 --- a/include/nn/atk/detail/voice/atk_LowLevelVoice.h +++ b/include/nn/atk/atk_LowLevelVoice.h @@ -8,8 +8,8 @@ #include #include -#include -#include +#include +#include namespace nn::atk::detail { class Voice; diff --git a/include/nn/atk/detail/seq/atk_MmlCommand.h b/include/nn/atk/atk_MmlCommand.h similarity index 100% rename from include/nn/atk/detail/seq/atk_MmlCommand.h rename to include/nn/atk/atk_MmlCommand.h diff --git a/include/nn/atk/detail/seq/atk_MmlParser.h b/include/nn/atk/atk_MmlParser.h similarity index 96% rename from include/nn/atk/detail/seq/atk_MmlParser.h rename to include/nn/atk/atk_MmlParser.h index 62f369fd..8c91df9d 100644 --- a/include/nn/atk/detail/seq/atk_MmlParser.h +++ b/include/nn/atk/atk_MmlParser.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail::driver { class MmlParser { diff --git a/include/nn/atk/detail/seq/atk_MmlSequenceTrack.h b/include/nn/atk/atk_MmlSequenceTrack.h similarity index 87% rename from include/nn/atk/detail/seq/atk_MmlSequenceTrack.h rename to include/nn/atk/atk_MmlSequenceTrack.h index 5b1c66c0..88c2b270 100644 --- a/include/nn/atk/detail/seq/atk_MmlSequenceTrack.h +++ b/include/nn/atk/atk_MmlSequenceTrack.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail::driver { class MmlParser; diff --git a/include/nn/atk/detail/seq/atk_MmlSequenceTrackAllocator.h b/include/nn/atk/atk_MmlSequenceTrackAllocator.h similarity index 78% rename from include/nn/atk/detail/seq/atk_MmlSequenceTrackAllocator.h rename to include/nn/atk/atk_MmlSequenceTrackAllocator.h index 468ebda2..caf05f91 100644 --- a/include/nn/atk/detail/seq/atk_MmlSequenceTrackAllocator.h +++ b/include/nn/atk/atk_MmlSequenceTrackAllocator.h @@ -1,8 +1,8 @@ #pragma once -#include -#include -#include +#include +#include +#include namespace nn::atk::detail::driver { class MmlSequenceTrackAllocator : SequenceTrackAllocator { diff --git a/include/nn/atk/detail/atk_MoveValue.h b/include/nn/atk/atk_MoveValue.h similarity index 100% rename from include/nn/atk/detail/atk_MoveValue.h rename to include/nn/atk/atk_MoveValue.h diff --git a/include/nn/atk/detail/voice/atk_MultiVoice.h b/include/nn/atk/atk_MultiVoice.h similarity index 98% rename from include/nn/atk/detail/voice/atk_MultiVoice.h rename to include/nn/atk/atk_MultiVoice.h index 7c24b5e8..4e610381 100644 --- a/include/nn/atk/detail/voice/atk_MultiVoice.h +++ b/include/nn/atk/atk_MultiVoice.h @@ -2,8 +2,8 @@ #include -#include -#include +#include +#include namespace nn::atk::detail::driver { class MultiVoiceManager; diff --git a/include/nn/atk/detail/voice/atk_MultiVoiceManager.h b/include/nn/atk/atk_MultiVoiceManager.h similarity index 96% rename from include/nn/atk/detail/voice/atk_MultiVoiceManager.h rename to include/nn/atk/atk_MultiVoiceManager.h index dedc9004..2e08495d 100644 --- a/include/nn/atk/detail/voice/atk_MultiVoiceManager.h +++ b/include/nn/atk/atk_MultiVoiceManager.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail::driver { class MultiVoiceManager { diff --git a/include/nn/atk/detail/atk_NoteOnCallback.h b/include/nn/atk/atk_NoteOnCallback.h similarity index 94% rename from include/nn/atk/detail/atk_NoteOnCallback.h rename to include/nn/atk/atk_NoteOnCallback.h index 4f64e69e..24c1dda6 100644 --- a/include/nn/atk/detail/atk_NoteOnCallback.h +++ b/include/nn/atk/atk_NoteOnCallback.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail::driver { class SequenceSoundPlayer; diff --git a/include/nn/atk/detail/atk_OutputAdditionalParam.h b/include/nn/atk/atk_OutputAdditionalParam.h similarity index 93% rename from include/nn/atk/detail/atk_OutputAdditionalParam.h rename to include/nn/atk/atk_OutputAdditionalParam.h index bd4d02b9..e135a3e1 100644 --- a/include/nn/atk/detail/atk_OutputAdditionalParam.h +++ b/include/nn/atk/atk_OutputAdditionalParam.h @@ -2,9 +2,9 @@ #include -#include -#include -#include +#include +#include +#include namespace nn::atk::detail { using SendArray = ValueArray; diff --git a/include/nn/atk/submix/atk_OutputMixer.h b/include/nn/atk/atk_OutputMixer.h similarity index 92% rename from include/nn/atk/submix/atk_OutputMixer.h rename to include/nn/atk/atk_OutputMixer.h index c2128563..ebfb5729 100644 --- a/include/nn/atk/submix/atk_OutputMixer.h +++ b/include/nn/atk/atk_OutputMixer.h @@ -2,10 +2,10 @@ #include -#include -#include +#include +#include #include -#include +#include namespace nn::atk { class OutputMixer : protected OutputReceiver { diff --git a/include/nn/atk/submix/atk_OutputReceiver.h b/include/nn/atk/atk_OutputReceiver.h similarity index 100% rename from include/nn/atk/submix/atk_OutputReceiver.h rename to include/nn/atk/atk_OutputReceiver.h diff --git a/include/nn/atk/detail/atk_PlayerHeap.h b/include/nn/atk/atk_PlayerHeap.h similarity index 100% rename from include/nn/atk/detail/atk_PlayerHeap.h rename to include/nn/atk/atk_PlayerHeap.h diff --git a/include/nn/atk/detail/atk_PlayerHeapDataManager.h b/include/nn/atk/atk_PlayerHeapDataManager.h similarity index 92% rename from include/nn/atk/detail/atk_PlayerHeapDataManager.h rename to include/nn/atk/atk_PlayerHeapDataManager.h index 10118349..2f510b7b 100644 --- a/include/nn/atk/detail/atk_PlayerHeapDataManager.h +++ b/include/nn/atk/atk_PlayerHeapDataManager.h @@ -1,8 +1,8 @@ #pragma once #include -#include -#include +#include +#include namespace nn::atk::detail { class PlayerHeapDataManager : driver::DisposeCallback, SoundArchiveLoader { diff --git a/include/nn/atk/util/atk_ProfileReader.h b/include/nn/atk/atk_ProfileReader.h similarity index 100% rename from include/nn/atk/util/atk_ProfileReader.h rename to include/nn/atk/atk_ProfileReader.h diff --git a/include/nn/atk/detail/seq/atk_SequenceSound.h b/include/nn/atk/atk_SequenceSound.h similarity index 97% rename from include/nn/atk/detail/seq/atk_SequenceSound.h rename to include/nn/atk/atk_SequenceSound.h index 405cf9c9..771d266e 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSound.h +++ b/include/nn/atk/atk_SequenceSound.h @@ -1,8 +1,8 @@ #pragma once #include -#include -#include +#include +#include namespace nn::atk::detail { class SequenceSound; diff --git a/include/nn/atk/detail/seq/atk_SequenceSoundFile.h b/include/nn/atk/atk_SequenceSoundFile.h similarity index 96% rename from include/nn/atk/detail/seq/atk_SequenceSoundFile.h rename to include/nn/atk/atk_SequenceSoundFile.h index d93969f1..934ef485 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSoundFile.h +++ b/include/nn/atk/atk_SequenceSoundFile.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { struct SequenceSoundFile { diff --git a/include/nn/atk/detail/seq/atk_SequenceSoundFileReader.h b/include/nn/atk/atk_SequenceSoundFileReader.h similarity index 91% rename from include/nn/atk/detail/seq/atk_SequenceSoundFileReader.h rename to include/nn/atk/atk_SequenceSoundFileReader.h index 9a060697..50f65850 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSoundFileReader.h +++ b/include/nn/atk/atk_SequenceSoundFileReader.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { class SequenceSoundFileReader { diff --git a/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h b/include/nn/atk/atk_SequenceSoundPlayer.h similarity index 95% rename from include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h rename to include/nn/atk/atk_SequenceSoundPlayer.h index 51b72906..6b25c64f 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSoundPlayer.h +++ b/include/nn/atk/atk_SequenceSoundPlayer.h @@ -1,14 +1,14 @@ #pragma once #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include namespace nn::atk { struct SequenceUserProcCallbackParam { diff --git a/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h b/include/nn/atk/atk_SequenceSoundRuntime.h similarity index 96% rename from include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h rename to include/nn/atk/atk_SequenceSoundRuntime.h index a947befc..77b9991e 100644 --- a/include/nn/atk/detail/seq/atk_SequenceSoundRuntime.h +++ b/include/nn/atk/atk_SequenceSoundRuntime.h @@ -1,10 +1,10 @@ #pragma once #include -#include -#include -#include -#include +#include +#include +#include +#include namespace nn::atk::detail { class SequenceSoundRuntime { diff --git a/include/nn/atk/detail/seq/atk_SequenceTrack.h b/include/nn/atk/atk_SequenceTrack.h similarity index 98% rename from include/nn/atk/detail/seq/atk_SequenceTrack.h rename to include/nn/atk/atk_SequenceTrack.h index 230020c3..6be8d991 100644 --- a/include/nn/atk/detail/seq/atk_SequenceTrack.h +++ b/include/nn/atk/atk_SequenceTrack.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail::driver { class SequenceSoundPlayer; diff --git a/include/nn/atk/detail/seq/atk_SequenceTrackAllocator.h b/include/nn/atk/atk_SequenceTrackAllocator.h similarity index 87% rename from include/nn/atk/detail/seq/atk_SequenceTrackAllocator.h rename to include/nn/atk/atk_SequenceTrackAllocator.h index 91ad028a..e7d6ca48 100644 --- a/include/nn/atk/detail/seq/atk_SequenceTrackAllocator.h +++ b/include/nn/atk/atk_SequenceTrackAllocator.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail::driver { class SequenceSoundPlayer; diff --git a/include/nn/atk/atk_SoundActor.h b/include/nn/atk/atk_SoundActor.h index 8700089e..8d30f83a 100644 --- a/include/nn/atk/atk_SoundActor.h +++ b/include/nn/atk/atk_SoundActor.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk { class SoundActor { diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index 421f4385..a9b20911 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -1,13 +1,13 @@ #pragma once -#include -#include +#include +#include #include namespace nn::atk { namespace detail{ class SoundArchiveFileReader; -struct SoundArchiveParametersHook; +class SoundArchiveParametersHook; struct SoundArchiveFilesHook; } // namespace nn::atk::detail diff --git a/include/nn/atk/detail/atk_SoundArchiveFile.h b/include/nn/atk/atk_SoundArchiveFile.h similarity index 99% rename from include/nn/atk/detail/atk_SoundArchiveFile.h rename to include/nn/atk/atk_SoundArchiveFile.h index cb71738d..5a04ff2c 100644 --- a/include/nn/atk/detail/atk_SoundArchiveFile.h +++ b/include/nn/atk/atk_SoundArchiveFile.h @@ -1,10 +1,10 @@ #pragma once #include -#include +#include namespace nn::atk::detail { -struct SoundArchiveParametersHook; +class SoundArchiveParametersHook; class SoundArchiveFile { public: diff --git a/include/nn/atk/detail/atk_SoundArchiveFileReader.h b/include/nn/atk/atk_SoundArchiveFileReader.h similarity index 98% rename from include/nn/atk/detail/atk_SoundArchiveFileReader.h rename to include/nn/atk/atk_SoundArchiveFileReader.h index c81a2133..ff84c071 100644 --- a/include/nn/atk/detail/atk_SoundArchiveFileReader.h +++ b/include/nn/atk/atk_SoundArchiveFileReader.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include namespace nn::atk::detail { class SoundArchiveFileReader { diff --git a/include/nn/atk/atk_SoundArchiveFilesHook.h b/include/nn/atk/atk_SoundArchiveFilesHook.h new file mode 100644 index 00000000..7b9637ef --- /dev/null +++ b/include/nn/atk/atk_SoundArchiveFilesHook.h @@ -0,0 +1 @@ +#pragma once \ No newline at end of file diff --git a/include/nn/atk/detail/atk_SoundArchiveLoader.h b/include/nn/atk/atk_SoundArchiveLoader.h similarity index 100% rename from include/nn/atk/detail/atk_SoundArchiveLoader.h rename to include/nn/atk/atk_SoundArchiveLoader.h diff --git a/include/nn/atk/atk_SoundArchiveParametersHook.h b/include/nn/atk/atk_SoundArchiveParametersHook.h new file mode 100644 index 00000000..d604f667 --- /dev/null +++ b/include/nn/atk/atk_SoundArchiveParametersHook.h @@ -0,0 +1,33 @@ +#pragma once + +#include + +namespace nn::atk::detail { +class SoundArchiveParametersHook { +public: + bool SetIsEnable(bool value); + + const char* GetItemLabel(SoundArchive::ItemId id) const; + SoundArchive::ItemId GetItemId(const char* itemLabel) const; + + SoundArchive::SoundType GetSoundType(const char* itemLabel); + + bool ReadSoundInfo(SoundArchive::ItemId soundId, SoundArchive::SoundInfo* info) const; + bool ReadBankInfo(SoundArchive::ItemId bankId, SoundArchive::BankInfo* info) const; + bool ReadPlayerInfo(SoundArchive::ItemId playerId, SoundArchive::PlayerInfo* info) const; + bool ReadSoundGroupInfo(SoundArchive::ItemId soundGroupId, SoundArchive::SoundGroupInfo* info) const; + bool ReadGroupInfo(SoundArchive::ItemId groupId, SoundArchive::GroupInfo* info) const; + bool ReadFileInfo(SoundArchive::FileId id, SoundArchive::FileInfo* info, int index) const; + bool ReadSoundArchivePlayerInfo(SoundArchive::SoundArchivePlayerInfo* info) const; + bool ReadSound3DInfo(SoundArchive::ItemId soundId, SoundArchive::Sound3DInfo* info) const; + bool ReadWaveArchiveInfo(SoundArchive::ItemId warcId, SoundArchive::WaveArchiveInfo* info) const; + bool ReadSequenceSoundInfo(SoundArchive::ItemId soundId, SoundArchive::SequenceSoundInfo* info) const; + bool ReadStreamSoundInfo(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo* info) const; + bool ReadStreamSoundInfo2(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo2* info) const; + bool ReadWaveSoundInfo(SoundArchive::ItemId soundId, SoundArchive::WaveSoundInfo* info) const; + + bool ReadSoundUserParam(u32* pOutValue, SoundArchive::ItemId soundId, int index) const; + u32 GetSoundUserParam(SoundArchive::ItemId soundId, u32 userParam) const; +}; +} // namespace nn::atk::detail + diff --git a/include/nn/atk/atk_SoundArchivePlayer.h b/include/nn/atk/atk_SoundArchivePlayer.h index cfed52ae..b0623b5a 100644 --- a/include/nn/atk/atk_SoundArchivePlayer.h +++ b/include/nn/atk/atk_SoundArchivePlayer.h @@ -3,9 +3,9 @@ #include #include -#include -#include -#include +#include +#include +#include namespace nn::atk { class SoundArchivePlayer : SoundStartable { diff --git a/include/nn/atk/atk_SoundDataManager.h b/include/nn/atk/atk_SoundDataManager.h index 1a086af5..95355fe6 100644 --- a/include/nn/atk/atk_SoundDataManager.h +++ b/include/nn/atk/atk_SoundDataManager.h @@ -1,8 +1,8 @@ #pragma once -#include -#include -#include +#include +#include +#include namespace nn::atk { diff --git a/include/nn/atk/atk_SoundHandle.h b/include/nn/atk/atk_SoundHandle.h index 3aac003e..a10b329b 100644 --- a/include/nn/atk/atk_SoundHandle.h +++ b/include/nn/atk/atk_SoundHandle.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk { class SoundHandle { diff --git a/include/nn/atk/atk_SoundHeap.h b/include/nn/atk/atk_SoundHeap.h index 11c9858b..1375705b 100644 --- a/include/nn/atk/atk_SoundHeap.h +++ b/include/nn/atk/atk_SoundHeap.h @@ -4,7 +4,7 @@ #include #include -#include +#include #include namespace nn::atk::detail { diff --git a/include/nn/atk/detail/atk_SoundInstanceManager.h b/include/nn/atk/atk_SoundInstanceManager.h similarity index 95% rename from include/nn/atk/detail/atk_SoundInstanceManager.h rename to include/nn/atk/atk_SoundInstanceManager.h index aadf7d02..351432c7 100644 --- a/include/nn/atk/detail/atk_SoundInstanceManager.h +++ b/include/nn/atk/atk_SoundInstanceManager.h @@ -4,7 +4,7 @@ #include #include -#include +#include namespace nn::atk::detail { template diff --git a/include/nn/atk/atk_SoundPlayer.h b/include/nn/atk/atk_SoundPlayer.h index 113065ba..3bcf9c49 100644 --- a/include/nn/atk/atk_SoundPlayer.h +++ b/include/nn/atk/atk_SoundPlayer.h @@ -2,9 +2,9 @@ #include -#include -#include -#include +#include +#include +#include namespace nn::atk { class SoundPlayer { diff --git a/include/nn/atk/detail/atk_SoundRuntimeUtility.h b/include/nn/atk/atk_SoundRuntimeUtility.h similarity index 100% rename from include/nn/atk/detail/atk_SoundRuntimeUtility.h rename to include/nn/atk/atk_SoundRuntimeUtility.h diff --git a/include/nn/atk/atk_SoundStartable.h b/include/nn/atk/atk_SoundStartable.h index e9fa3616..f9d6730b 100644 --- a/include/nn/atk/atk_SoundStartable.h +++ b/include/nn/atk/atk_SoundStartable.h @@ -3,8 +3,8 @@ #include #include #include -#include -#include +#include +#include namespace nn::atk { class SoundStartable { diff --git a/include/nn/atk/atk_SoundSystem.h b/include/nn/atk/atk_SoundSystem.h index f86d0adc..40f7401b 100644 --- a/include/nn/atk/atk_SoundSystem.h +++ b/include/nn/atk/atk_SoundSystem.h @@ -6,12 +6,12 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace nn::atk { struct SoundSystem { diff --git a/include/nn/atk/detail/thread/atk_SoundThread.h b/include/nn/atk/atk_SoundThread.h similarity index 97% rename from include/nn/atk/detail/thread/atk_SoundThread.h rename to include/nn/atk/atk_SoundThread.h index 170a6269..5032b98c 100644 --- a/include/nn/atk/detail/thread/atk_SoundThread.h +++ b/include/nn/atk/atk_SoundThread.h @@ -6,11 +6,11 @@ #include #include -#include +#include #include #include -#include -#include +#include +#include namespace nn::atk::detail::driver { struct SoundThreadLock {}; diff --git a/include/nn/atk/detail/atk_StartInfoReader.h b/include/nn/atk/atk_StartInfoReader.h similarity index 100% rename from include/nn/atk/detail/atk_StartInfoReader.h rename to include/nn/atk/atk_StartInfoReader.h diff --git a/include/nn/atk/detail/strm/atk_StreamBufferPool.h b/include/nn/atk/atk_StreamBufferPool.h similarity index 100% rename from include/nn/atk/detail/strm/atk_StreamBufferPool.h rename to include/nn/atk/atk_StreamBufferPool.h diff --git a/include/nn/atk/detail/strm/atk_StreamSound.h b/include/nn/atk/atk_StreamSound.h similarity index 96% rename from include/nn/atk/detail/strm/atk_StreamSound.h rename to include/nn/atk/atk_StreamSound.h index ac15a7f6..e4a0fe0d 100644 --- a/include/nn/atk/detail/strm/atk_StreamSound.h +++ b/include/nn/atk/atk_StreamSound.h @@ -1,8 +1,8 @@ #pragma once #include -#include -#include +#include +#include namespace nn::atk::detail { class StreamSound; diff --git a/include/nn/atk/detail/strm/atk_StreamSoundFile.h b/include/nn/atk/atk_StreamSoundFile.h similarity index 98% rename from include/nn/atk/detail/strm/atk_StreamSoundFile.h rename to include/nn/atk/atk_StreamSoundFile.h index f43d87ae..3236c658 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundFile.h +++ b/include/nn/atk/atk_StreamSoundFile.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { class StreamSoundFile { diff --git a/include/nn/atk/detail/strm/atk_StreamSoundFileLoader.h b/include/nn/atk/atk_StreamSoundFileLoader.h similarity index 92% rename from include/nn/atk/detail/strm/atk_StreamSoundFileLoader.h rename to include/nn/atk/atk_StreamSoundFileLoader.h index e925912b..1513ac0e 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundFileLoader.h +++ b/include/nn/atk/atk_StreamSoundFileLoader.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include namespace nn::atk::detail { diff --git a/include/nn/atk/detail/strm/atk_StreamSoundFileReader.h b/include/nn/atk/atk_StreamSoundFileReader.h similarity index 95% rename from include/nn/atk/detail/strm/atk_StreamSoundFileReader.h rename to include/nn/atk/atk_StreamSoundFileReader.h index c38c8bc6..93284559 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundFileReader.h +++ b/include/nn/atk/atk_StreamSoundFileReader.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { class StreamSoundFileReader { diff --git a/include/nn/atk/detail/strm/atk_StreamSoundLoader.h b/include/nn/atk/atk_StreamSoundLoader.h similarity index 96% rename from include/nn/atk/detail/strm/atk_StreamSoundLoader.h rename to include/nn/atk/atk_StreamSoundLoader.h index 8338e962..6027d65a 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundLoader.h +++ b/include/nn/atk/atk_StreamSoundLoader.h @@ -2,14 +2,14 @@ #include #include -#include +#include #include -#include +#include #include -#include -#include -#include -#include +#include +#include +#include +#include namespace nn::atk::detail { struct IStreamDataDecoderManager; diff --git a/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h b/include/nn/atk/atk_StreamSoundPlayer.h similarity index 97% rename from include/nn/atk/detail/strm/atk_StreamSoundPlayer.h rename to include/nn/atk/atk_StreamSoundPlayer.h index cd62d497..7f243bd2 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundPlayer.h +++ b/include/nn/atk/atk_StreamSoundPlayer.h @@ -1,10 +1,10 @@ #pragma once -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace nn::atk::detail { struct StreamSoundDataInfo { diff --git a/include/nn/atk/detail/strm/atk_StreamSoundPrefetchFile.h b/include/nn/atk/atk_StreamSoundPrefetchFile.h similarity index 92% rename from include/nn/atk/detail/strm/atk_StreamSoundPrefetchFile.h rename to include/nn/atk/atk_StreamSoundPrefetchFile.h index 06f493d4..c66853a3 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundPrefetchFile.h +++ b/include/nn/atk/atk_StreamSoundPrefetchFile.h @@ -1,7 +1,7 @@ #pragma once -#include -#include +#include +#include namespace nn::atk::detail { class StreamSoundPrefetchFile { diff --git a/include/nn/atk/detail/strm/atk_StreamSoundPrefetchFileReader.h b/include/nn/atk/atk_StreamSoundPrefetchFileReader.h similarity index 96% rename from include/nn/atk/detail/strm/atk_StreamSoundPrefetchFileReader.h rename to include/nn/atk/atk_StreamSoundPrefetchFileReader.h index 4b59d803..488c6d2c 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundPrefetchFileReader.h +++ b/include/nn/atk/atk_StreamSoundPrefetchFileReader.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include namespace nn::atk::detail { class StreamSoundPrefetchFileReader : IRegionInfoReadable { diff --git a/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h b/include/nn/atk/atk_StreamSoundRuntime.h similarity index 97% rename from include/nn/atk/detail/strm/atk_StreamSoundRuntime.h rename to include/nn/atk/atk_StreamSoundRuntime.h index 9ec98c08..d37b55de 100644 --- a/include/nn/atk/detail/strm/atk_StreamSoundRuntime.h +++ b/include/nn/atk/atk_StreamSoundRuntime.h @@ -1,8 +1,8 @@ #pragma once #include -#include -#include +#include +#include namespace nn::atk::detail { class StreamSoundRuntime { diff --git a/include/nn/atk/detail/strm/atk_StreamTrack.h b/include/nn/atk/atk_StreamTrack.h similarity index 94% rename from include/nn/atk/detail/strm/atk_StreamTrack.h rename to include/nn/atk/atk_StreamTrack.h index b0c5c4d2..3f2eb87b 100644 --- a/include/nn/atk/detail/strm/atk_StreamTrack.h +++ b/include/nn/atk/atk_StreamTrack.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail::driver { class StreamChannel { diff --git a/include/nn/atk/submix/atk_SubMix.h b/include/nn/atk/atk_SubMix.h similarity index 98% rename from include/nn/atk/submix/atk_SubMix.h rename to include/nn/atk/atk_SubMix.h index fd1ce9f3..d5249e3c 100644 --- a/include/nn/atk/submix/atk_SubMix.h +++ b/include/nn/atk/atk_SubMix.h @@ -3,8 +3,8 @@ #include #include -#include -#include +#include +#include namespace nn::atk { namespace detail::driver { diff --git a/include/nn/atk/detail/thread/atk_Task.h b/include/nn/atk/atk_Task.h similarity index 91% rename from include/nn/atk/detail/thread/atk_Task.h rename to include/nn/atk/atk_Task.h index a89cf9b4..c49f90df 100644 --- a/include/nn/atk/detail/thread/atk_Task.h +++ b/include/nn/atk/atk_Task.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { class TaskManager; diff --git a/include/nn/atk/detail/thread/atk_TaskManager.h b/include/nn/atk/atk_TaskManager.h similarity index 97% rename from include/nn/atk/detail/thread/atk_TaskManager.h rename to include/nn/atk/atk_TaskManager.h index d962b5fe..24d3fe03 100644 --- a/include/nn/atk/detail/thread/atk_TaskManager.h +++ b/include/nn/atk/atk_TaskManager.h @@ -2,7 +2,7 @@ #include -#include +#include namespace nn::atk::detail { class TaskManager { diff --git a/include/nn/atk/util/atk_TaskProfileReader.h b/include/nn/atk/atk_TaskProfileReader.h similarity index 98% rename from include/nn/atk/util/atk_TaskProfileReader.h rename to include/nn/atk/atk_TaskProfileReader.h index 0e7e6803..0e59224d 100644 --- a/include/nn/atk/util/atk_TaskProfileReader.h +++ b/include/nn/atk/atk_TaskProfileReader.h @@ -3,10 +3,10 @@ #include #include -#include +#include #include #include -#include +#include namespace nn::atk { diff --git a/include/nn/atk/detail/thread/atk_TaskThread.h b/include/nn/atk/atk_TaskThread.h similarity index 100% rename from include/nn/atk/detail/thread/atk_TaskThread.h rename to include/nn/atk/atk_TaskThread.h diff --git a/include/nn/atk/detail/thread/atk_ThreadInfoReader.h b/include/nn/atk/atk_ThreadInfoReader.h similarity index 100% rename from include/nn/atk/detail/thread/atk_ThreadInfoReader.h rename to include/nn/atk/atk_ThreadInfoReader.h diff --git a/include/nn/atk/detail/util/atk_Util.h b/include/nn/atk/atk_Util.h similarity index 99% rename from include/nn/atk/detail/util/atk_Util.h rename to include/nn/atk/atk_Util.h index df860475..4e6e97bf 100644 --- a/include/nn/atk/detail/util/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -3,7 +3,7 @@ #include #include -#include +#include namespace nn::atk { class SoundArchive; diff --git a/include/nn/atk/detail/atk_ValueArray.h b/include/nn/atk/atk_ValueArray.h similarity index 100% rename from include/nn/atk/detail/atk_ValueArray.h rename to include/nn/atk/atk_ValueArray.h diff --git a/include/nn/atk/detail/voice/atk_Voice.h b/include/nn/atk/atk_Voice.h similarity index 96% rename from include/nn/atk/detail/voice/atk_Voice.h rename to include/nn/atk/atk_Voice.h index 1d02a0f4..d11d00ed 100644 --- a/include/nn/atk/detail/voice/atk_Voice.h +++ b/include/nn/atk/atk_Voice.h @@ -2,8 +2,8 @@ #include -#include -#include +#include +#include namespace nn::atk::detail { class Voice { diff --git a/include/nn/atk/detail/voice/atk_VoiceCommand.h b/include/nn/atk/atk_VoiceCommand.h similarity index 95% rename from include/nn/atk/detail/voice/atk_VoiceCommand.h rename to include/nn/atk/atk_VoiceCommand.h index 431426e6..e5b45530 100644 --- a/include/nn/atk/detail/voice/atk_VoiceCommand.h +++ b/include/nn/atk/atk_VoiceCommand.h @@ -2,8 +2,8 @@ #include -#include -#include +#include +#include namespace nn::atk::detail { struct VoiceCommandPlay : Command { diff --git a/include/nn/atk/detail/atk_VolumeThroughModePacket.h b/include/nn/atk/atk_VolumeThroughModePacket.h similarity index 93% rename from include/nn/atk/detail/atk_VolumeThroughModePacket.h rename to include/nn/atk/atk_VolumeThroughModePacket.h index 44641efc..5c700815 100644 --- a/include/nn/atk/detail/atk_VolumeThroughModePacket.h +++ b/include/nn/atk/atk_VolumeThroughModePacket.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { class VolumeThroughModePacket { diff --git a/include/nn/atk/detail/util/atk_WavBinary.h b/include/nn/atk/atk_WavBinary.h similarity index 100% rename from include/nn/atk/detail/util/atk_WavBinary.h rename to include/nn/atk/atk_WavBinary.h diff --git a/include/nn/atk/detail/util/atk_WavOutFileStream.h b/include/nn/atk/atk_WavOutFileStream.h similarity index 96% rename from include/nn/atk/detail/util/atk_WavOutFileStream.h rename to include/nn/atk/atk_WavOutFileStream.h index b7306245..d7152268 100644 --- a/include/nn/atk/detail/util/atk_WavOutFileStream.h +++ b/include/nn/atk/atk_WavOutFileStream.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include namespace nn::atk::detail { diff --git a/include/nn/atk/detail/atk_WaveArchiveFile.h b/include/nn/atk/atk_WaveArchiveFile.h similarity index 96% rename from include/nn/atk/detail/atk_WaveArchiveFile.h rename to include/nn/atk/atk_WaveArchiveFile.h index 8e0f684e..78c64626 100644 --- a/include/nn/atk/detail/atk_WaveArchiveFile.h +++ b/include/nn/atk/atk_WaveArchiveFile.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { struct WaveArchiveFile { diff --git a/include/nn/atk/detail/atk_WaveArchiveFileReader.h b/include/nn/atk/atk_WaveArchiveFileReader.h similarity index 95% rename from include/nn/atk/detail/atk_WaveArchiveFileReader.h rename to include/nn/atk/atk_WaveArchiveFileReader.h index e0ee9850..bc29536f 100644 --- a/include/nn/atk/detail/atk_WaveArchiveFileReader.h +++ b/include/nn/atk/atk_WaveArchiveFileReader.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { class WaveArchiveFileReader { diff --git a/include/nn/atk/detail/atk_WaveFile.h b/include/nn/atk/atk_WaveFile.h similarity index 97% rename from include/nn/atk/detail/atk_WaveFile.h rename to include/nn/atk/atk_WaveFile.h index 08dd6f49..766727b4 100644 --- a/include/nn/atk/detail/atk_WaveFile.h +++ b/include/nn/atk/atk_WaveFile.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { struct WaveFile { diff --git a/include/nn/atk/detail/atk_WaveFileReader.h b/include/nn/atk/atk_WaveFileReader.h similarity index 88% rename from include/nn/atk/detail/atk_WaveFileReader.h rename to include/nn/atk/atk_WaveFileReader.h index 1987dcf4..ebdb8023 100644 --- a/include/nn/atk/detail/atk_WaveFileReader.h +++ b/include/nn/atk/atk_WaveFileReader.h @@ -1,7 +1,7 @@ #pragma once -#include -#include +#include +#include namespace nn::atk::detail { class WaveFileReader { diff --git a/include/nn/atk/detail/wsd/atk_WaveSound.h b/include/nn/atk/atk_WaveSound.h similarity index 92% rename from include/nn/atk/detail/wsd/atk_WaveSound.h rename to include/nn/atk/atk_WaveSound.h index 7390f905..9b984fbc 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSound.h +++ b/include/nn/atk/atk_WaveSound.h @@ -1,9 +1,9 @@ #pragma once #include -#include -#include -#include +#include +#include +#include namespace nn::atk::detail { class WaveSound; diff --git a/include/nn/atk/detail/wsd/atk_WaveSoundFile.h b/include/nn/atk/atk_WaveSoundFile.h similarity index 98% rename from include/nn/atk/detail/wsd/atk_WaveSoundFile.h rename to include/nn/atk/atk_WaveSoundFile.h index 22769474..9c1b3cc5 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSoundFile.h +++ b/include/nn/atk/atk_WaveSoundFile.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { struct WaveSoundFile { diff --git a/include/nn/atk/detail/wsd/atk_WaveSoundFileReader.h b/include/nn/atk/atk_WaveSoundFileReader.h similarity index 95% rename from include/nn/atk/detail/wsd/atk_WaveSoundFileReader.h rename to include/nn/atk/atk_WaveSoundFileReader.h index 5416b723..18503913 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSoundFileReader.h +++ b/include/nn/atk/atk_WaveSoundFileReader.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { struct WaveSoundInfo { diff --git a/include/nn/atk/detail/wsd/atk_WaveSoundLoader.h b/include/nn/atk/atk_WaveSoundLoader.h similarity index 91% rename from include/nn/atk/detail/wsd/atk_WaveSoundLoader.h rename to include/nn/atk/atk_WaveSoundLoader.h index 581ffc1c..240511b1 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSoundLoader.h +++ b/include/nn/atk/atk_WaveSoundLoader.h @@ -1,10 +1,10 @@ #pragma once #include -#include -#include -#include -#include +#include +#include +#include +#include namespace nn::atk::detail::driver { class WaveSoundLoader; diff --git a/include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h b/include/nn/atk/atk_WaveSoundPlayer.h similarity index 94% rename from include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h rename to include/nn/atk/atk_WaveSoundPlayer.h index a62096ab..182d82a3 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSoundPlayer.h +++ b/include/nn/atk/atk_WaveSoundPlayer.h @@ -1,9 +1,9 @@ #pragma once -#include -#include -#include -#include +#include +#include +#include +#include namespace nn::atk::detail { struct WaveSoundDataInfo { diff --git a/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h b/include/nn/atk/atk_WaveSoundRuntime.h similarity index 95% rename from include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h rename to include/nn/atk/atk_WaveSoundRuntime.h index 67f2660a..3b025b34 100644 --- a/include/nn/atk/detail/wsd/atk_WaveSoundRuntime.h +++ b/include/nn/atk/atk_WaveSoundRuntime.h @@ -1,7 +1,7 @@ #pragma once -#include -#include +#include +#include namespace nn::atk::detail { class WaveSoundRuntime { diff --git a/include/nn/atk/detail/atk_AdvancedWaveSound.h b/include/nn/atk/detail/atk_AdvancedWaveSound.h index 52b02afd..ec1a6b9b 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSound.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSound.h @@ -1,7 +1,7 @@ #pragma once -#include -#include +#include +#include #include namespace nn::atk::detail { diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h b/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h index e5c7d875..1cc812ab 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h @@ -2,7 +2,7 @@ #include -#include +#include namespace nn::atk::detail { struct AdvancedWaveSoundFile { diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h b/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h index 368baf5d..05444888 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h @@ -1,10 +1,10 @@ #pragma once #include -#include -#include -#include -#include +#include +#include +#include +#include namespace nn::atk::detail::driver { class AdvancedWaveSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h b/include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h index dbc9ed44..a77b23ab 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h @@ -5,8 +5,8 @@ #include #include #include -#include -#include +#include +#include namespace nn::atk::detail { class AdvancedWaveSoundRuntime { diff --git a/include/nn/atk/detail/util/atk_BinaryTypes.h b/include/nn/atk/detail/atk_BinaryTypes.h similarity index 100% rename from include/nn/atk/detail/util/atk_BinaryTypes.h rename to include/nn/atk/detail/atk_BinaryTypes.h diff --git a/include/nn/atk/detail/atk_IRegionInfoReadable.h b/include/nn/atk/detail/atk_IRegionInfoReadable.h index 0352f6d4..676eb144 100644 --- a/include/nn/atk/detail/atk_IRegionInfoReadable.h +++ b/include/nn/atk/detail/atk_IRegionInfoReadable.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nn::atk::detail { class IRegionInfoReadable { diff --git a/include/nn/atk/detail/atk_IStreamDataDecoder.h b/include/nn/atk/detail/atk_IStreamDataDecoder.h index 98cff4d0..62c713b3 100644 --- a/include/nn/atk/detail/atk_IStreamDataDecoder.h +++ b/include/nn/atk/detail/atk_IStreamDataDecoder.h @@ -2,7 +2,7 @@ #include -#include +#include namespace nn::atk::detail { namespace driver { diff --git a/include/nn/atk/detail/util/atk_MemoryFileStream.h b/include/nn/atk/detail/atk_MemoryFileStream.h similarity index 97% rename from include/nn/atk/detail/util/atk_MemoryFileStream.h rename to include/nn/atk/detail/atk_MemoryFileStream.h index 8c1b69a4..933e2b0a 100644 --- a/include/nn/atk/detail/util/atk_MemoryFileStream.h +++ b/include/nn/atk/detail/atk_MemoryFileStream.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include namespace nn::atk::detail { diff --git a/include/nn/atk/detail/atk_RegionManager.h b/include/nn/atk/detail/atk_RegionManager.h index d6ecf2ef..f4410342 100644 --- a/include/nn/atk/detail/atk_RegionManager.h +++ b/include/nn/atk/detail/atk_RegionManager.h @@ -3,7 +3,7 @@ #include #include -#include +#include #include namespace nn::atk { diff --git a/include/nn/atk/fnd/basis/atkfnd_Inlines.h b/include/nn/atk/fnd/basis/atkfnd_Inlines.h new file mode 100644 index 00000000..7b9637ef --- /dev/null +++ b/include/nn/atk/fnd/basis/atkfnd_Inlines.h @@ -0,0 +1 @@ +#pragma once \ No newline at end of file diff --git a/include/nn/atk/fnd/binary/atkfnd_PrimitiveTypes.h b/include/nn/atk/fnd/binary/atkfnd_PrimitiveTypes.h new file mode 100644 index 00000000..7b9637ef --- /dev/null +++ b/include/nn/atk/fnd/binary/atkfnd_PrimitiveTypes.h @@ -0,0 +1 @@ +#pragma once \ No newline at end of file diff --git a/include/nn/atk/fnd/basis/atkfnd_ScopedLock.h b/include/nn/atk/fnd/io/atkfnd_ScopedLock.h similarity index 100% rename from include/nn/atk/fnd/basis/atkfnd_ScopedLock.h rename to include/nn/atk/fnd/io/atkfnd_ScopedLock.h diff --git a/include/nn/atk/fnd/string/atkfnd_String.h b/include/nn/atk/fnd/string/atkfnd_String.h new file mode 100644 index 00000000..7b9637ef --- /dev/null +++ b/include/nn/atk/fnd/string/atkfnd_String.h @@ -0,0 +1 @@ +#pragma once \ No newline at end of file diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 2cfdd422..d4114f3f 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -1,6 +1,6 @@ #include -#include +#include namespace nn::atk { SoundArchive::SoundArchive() { From 06efb3ec806e0020b187e4d0514417bc68d0f2fe Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 7 Aug 2026 22:05:14 -0400 Subject: [PATCH 190/785] audio: add more complete types --- include/nn/audio/audio_AudioRendererTypes.h | 20 +++++++++++----- include/nn/audio/audio_Common.h | 2 +- include/nn/audio/audio_EffectTypes.h | 2 ++ include/nn/audio/audio_FinalMixTypes.h | 3 +++ include/nn/audio/audio_MemoryPoolTypes.h | 5 ++++ include/nn/audio/audio_PerformanceMetrics.h | 16 +++++++++---- include/nn/audio/audio_SubMixTypes.h | 3 +++ include/nn/audio/audio_VoiceTypes.h | 26 +++++++++++++++------ include/nn/audio/audio_WaveBuffer.h | 4 ++-- 9 files changed, 60 insertions(+), 21 deletions(-) diff --git a/include/nn/audio/audio_AudioRendererTypes.h b/include/nn/audio/audio_AudioRendererTypes.h index 099a425a..963390ea 100644 --- a/include/nn/audio/audio_AudioRendererTypes.h +++ b/include/nn/audio/audio_AudioRendererTypes.h @@ -13,6 +13,12 @@ enum AudioRendererExecutionMode { AudioRendererExecutionMode_ManualExecution, }; +struct AudioRendererHandle { + void* _handle; + void* _context; +}; +static_assert(sizeof(AudioRendererHandle) == 0x10); + struct AudioRendererParameter { s32 sampleRate; s32 sampleCount; @@ -28,6 +34,14 @@ struct AudioRendererParameter { AudioRendererRenderingDevice renderingDevice; AudioRendererExecutionMode executionMode; u32 _magic; + + static const s32 MixBufferCountMax = 256; + static const s32 SubMixCountMax = 256; + static const s32 VoiceCountMax = 1024; + static const s32 SinkCountMax = 256; + static const s32 EffectCountMax = 256; + static const s32 PerformanceFrameCountMax = 4096; + static const s32 SplitterCountMax = 256; }; static_assert(sizeof(AudioRendererParameter) == 0x38); @@ -48,10 +62,4 @@ struct AudioRendererConfig { size_t _configBufferSize; }; static_assert(sizeof(AudioRendererConfig) == 0x70); - -struct AudioRendererHandle { - void* _handle; - void* _context; -}; -static_assert(sizeof(AudioRendererHandle) == 0x10); } // namespace nn::audio \ No newline at end of file diff --git a/include/nn/audio/audio_Common.h b/include/nn/audio/audio_Common.h index 7cc0ed32..8eb070a7 100644 --- a/include/nn/audio/audio_Common.h +++ b/include/nn/audio/audio_Common.h @@ -4,6 +4,7 @@ namespace nn::audio { using NodeId = uint32_t; +const int BufferAlignSize = 64; struct AudioDeviceName { char raw_name[0x100]; @@ -14,7 +15,6 @@ struct DelayType { u64* _0; }; -struct EffectInfo {}; struct MixInfo {}; class VoiceInfoManager {}; diff --git a/include/nn/audio/audio_EffectTypes.h b/include/nn/audio/audio_EffectTypes.h index 31d0c147..b648196d 100644 --- a/include/nn/audio/audio_EffectTypes.h +++ b/include/nn/audio/audio_EffectTypes.h @@ -3,6 +3,8 @@ #include namespace nn::audio { +struct EffectInfo {}; + struct AuxType { EffectInfo* _pEffectInfo; }; diff --git a/include/nn/audio/audio_FinalMixTypes.h b/include/nn/audio/audio_FinalMixTypes.h index 08434bee..80e097c9 100644 --- a/include/nn/audio/audio_FinalMixTypes.h +++ b/include/nn/audio/audio_FinalMixTypes.h @@ -5,5 +5,8 @@ namespace nn::audio { struct FinalMixType { MixInfo* _pMixInfo; + + static float GetVolumeMax(); + static float GetVolumeMin(); }; } // namespace nn::audio \ No newline at end of file diff --git a/include/nn/audio/audio_MemoryPoolTypes.h b/include/nn/audio/audio_MemoryPoolTypes.h index 7c976024..3165ea56 100644 --- a/include/nn/audio/audio_MemoryPoolTypes.h +++ b/include/nn/audio/audio_MemoryPoolTypes.h @@ -1,5 +1,7 @@ #pragma once +#include + namespace nn::audio { enum MemoryPoolState { MemoryPoolState_Invalid, @@ -21,6 +23,9 @@ struct MemoryPoolType { State_Detached, }; + static const size_t AddressAlignment {4096}; + static const size_t SizeGranularity {4096}; + MemoryPoolInfo* _pMemoryPoolInfo; }; static_assert(sizeof(MemoryPoolType) == 0x8); diff --git a/include/nn/audio/audio_PerformanceMetrics.h b/include/nn/audio/audio_PerformanceMetrics.h index 05053d68..98dad4e4 100644 --- a/include/nn/audio/audio_PerformanceMetrics.h +++ b/include/nn/audio/audio_PerformanceMetrics.h @@ -7,17 +7,23 @@ namespace nn::audio { class PerformanceInfo { public: + PerformanceInfo& operator=(const PerformanceInfo&); + PerformanceInfo& operator=(PerformanceInfo&&); + PerformanceInfo(); ~PerformanceInfo(); - void SetBuffer(const void* buffer, size_t bufferSize); - void MoveToNextFrame(); + bool SetBuffer(const void* buffer, size_t bufferSize); + + bool MoveToNextFrame(); - PerformanceEntry* GetEntries(s32*); - void GetTotalProcessingTime(); + s32 GetTotalProcessingTime(); + u32 GetFrameIndex(); + const PerformanceEntry* GetEntries(int*); + const PerformanceDetail* GetDetails(int*); private: - void* m_Buffer; + const void* m_Buffer; size_t m_BufferSize; PerformanceFrameHeader* m_Header; PerformanceEntry* m_Entries; diff --git a/include/nn/audio/audio_SubMixTypes.h b/include/nn/audio/audio_SubMixTypes.h index 69faf8ee..ee9ee2c4 100644 --- a/include/nn/audio/audio_SubMixTypes.h +++ b/include/nn/audio/audio_SubMixTypes.h @@ -5,5 +5,8 @@ namespace nn::audio { struct SubMixType { MixInfo* _pMixInfo; + + static float GetVolumeMin(); + static float GetVolumeMax(); }; } // namespace nn::audio \ No newline at end of file diff --git a/include/nn/audio/audio_VoiceTypes.h b/include/nn/audio/audio_VoiceTypes.h index e5337725..665d5be0 100644 --- a/include/nn/audio/audio_VoiceTypes.h +++ b/include/nn/audio/audio_VoiceTypes.h @@ -5,6 +5,13 @@ namespace nn::audio { struct VoiceInfo; +struct BiquadFilterParameter { + bool enable; + s16 numerator[3]; + s16 denominator[2]; +}; +static_assert(sizeof(BiquadFilterParameter) == 0xc); + struct VoiceType { enum PlayState { PlayState_Play, @@ -12,14 +19,19 @@ struct VoiceType { PlayState_Pause, }; + static const int PriorityHighest = 0; + static const int PriorityLowest = 255; + static const int WaveBufferCountMax = 4; + static const int ChannelCountMax = 6; + + static float GetPitchMax(); + static float GetPitchMin(); + static float GetVolumeMax(); + static float GetVolumeMin(); + + static const int BiquadFilterCountMax = 2; + VoiceInfo* _pVoiceInfo; }; static_assert(sizeof(VoiceType) == 0x8); - -struct BiquadFilterParameter { - bool enable; - s16 numerator[3]; - s16 denominator[2]; -}; -static_assert(sizeof(BiquadFilterParameter) == 0xc); } // namespace nn::audio \ No newline at end of file diff --git a/include/nn/audio/audio_WaveBuffer.h b/include/nn/audio/audio_WaveBuffer.h index 282ae5d7..aad32139 100644 --- a/include/nn/audio/audio_WaveBuffer.h +++ b/include/nn/audio/audio_WaveBuffer.h @@ -4,13 +4,13 @@ namespace nn::audio { struct WaveBuffer { - void* buffer; + const void* buffer; size_t size; s32 startSampleOffset; s32 endSampleOffset; bool loop; bool isEndOfStream; - void* pContext; + const void* pContext; size_t contextSize; }; static_assert(sizeof(WaveBuffer) == 0x30); From 66329a4e3db1582952dd0fdb885e4a003669f461 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 8 Aug 2026 15:19:09 -0400 Subject: [PATCH 191/785] atk: define more functions based on dwarf in `atk_BasicSound.h` --- include/nn/atk/atk_Bank.h | 3 +- include/nn/atk/atk_BasicSound.h | 566 +++++++++++++++++++------------- 2 files changed, 343 insertions(+), 226 deletions(-) diff --git a/include/nn/atk/atk_Bank.h b/include/nn/atk/atk_Bank.h index bcbdc2d5..8c051f11 100644 --- a/include/nn/atk/atk_Bank.h +++ b/include/nn/atk/atk_Bank.h @@ -14,6 +14,7 @@ class Bank { const WaveArchiveFileReader& warcReader, const NoteOnInfo& noteOnInfo) const; - static f32 CalcChannelVelocityVolume(u8 velocity); + static float CalcChannelVelocityVolume(u8 velocity); }; +static_assert(sizeof(Bank) == 0x1); } // namespace nn::atk::detail::driver \ No newline at end of file diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index f37a452f..ea5cc7f5 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -16,6 +16,23 @@ class SoundPlayer; class SoundHandle; class OutputAmbientParam { +public: + OutputAmbientParam(); + + void Initialize(); + + float GetVolume() const; + void SetVolume(float volume); + + float GetPan() const; + void SetPan(float pan); + + float GetSurroundPan() const; + void SetSurroundPan(float surroundPan); + + float GetEffectSend(int) const; + void SetEffectSend(int, float) const; + private: f32 m_Volume; f32 m_Pan; @@ -26,30 +43,92 @@ static_assert(sizeof(OutputAmbientParam) == 0x18); class SoundAmbientParam { public: - constexpr static u32 OutputLineFlagInherit = -1; + static const int OutputLineFlagInherit = -1; + SoundAmbientParam(); + + float GetVolume() const { return m_Volume; } + void SetVolume(float volume) { m_Volume = volume; } + + float GetPitch() const { return m_Pitch; } + void SetPitch(float pitch) { m_Pitch = pitch; } + + float GetLowPassFilter() const { return m_Lpf; } + void SetLowPassFilter(float lowPassFilter) { m_Lpf = lowPassFilter; } + + float GetBiquadFilterValue() const { return m_BiquadFilterValue; } + void SetBiquadFilterValue(float biquadFilterValue) { m_BiquadFilterValue = biquadFilterValue; } + + int GetBiquadFilterType() const { return m_BiquadFilterType; } + void SetBiquadFilterType(int biquadFilterType) { m_BiquadFilterType = biquadFilterType; } + + int GetPriority() const { return m_Priority; } + void SetPriority(int priority) { m_Priority = priority; } + + u32 GetUserData() const { return m_UserData; } + void SetUserData(u32 userData) { m_UserData = userData; } + + int GetOutputLineFlag() const { return m_OutputLineFlag; } + void SetOutputLineFlag(int outputLineFlag) { m_OutputLineFlag = outputLineFlag; } + + OutputAmbientParam& GetTvParam() { return m_TvParam; } + void SetTvParam(const OutputAmbientParam& tvParam) { m_TvParam = tvParam; } + private: - f32 m_Volume; - f32 m_Pitch; - f32 m_Lpf; - f32 m_BiquadFilterValue; - s32 m_BiquadFilterType; - s32 m_Priority; + float m_Volume; + float m_Pitch; + float m_Lpf; + float m_BiquadFilterValue; + int m_BiquadFilterType; + int m_Priority; u32 m_UserData; - s32 m_OutputLineFlag; + int m_OutputLineFlag; OutputAmbientParam m_TvParam; }; static_assert(sizeof(SoundAmbientParam) == 0x38); class SoundParam { +public: + SoundParam(); + + void Initialize(); + + float GetVolume() const { return m_Volume; } + void SetVolume(float volume) { m_Volume = volume; } + + float GetPitch() const { return m_Pitch; } + void SetPitch(float pitch) { m_Pitch = pitch; } + + float GetLpf() const { return m_Lpf; } + void SetLpf(float lpf) { m_Lpf = lpf; } + + float GetBiquadFilterValue() const { return m_BiquadFilterValue; } + void SetBiquadFilterValue(float biquadFilterValue) { m_BiquadFilterValue = biquadFilterValue; } + + int GetBiquadFilterType() const { return m_BiquadFilterType; } + void SetBiquadFilterType(int biquadFilterType) { m_BiquadFilterType = biquadFilterType; } + + int GetPriority() const { return m_Priority; } + void SetPriority(int priority) { m_Priority = priority; } + + int GetOutputLineFlag() const { return m_OutputLineFlag; } + void SetOutputLineFlag(int outputLineFlag) { m_OutputLineFlag = outputLineFlag; } + + u32 GetUserData() const { return m_UserData; } + void SetUserData(u32 userData) { m_UserData = userData; } + + OutputAmbientParam& GetTvParam() { return m_TvParam; } + const OutputAmbientParam& GetTvParam() const { return m_TvParam; } + void SetTvParam(const OutputAmbientParam& tvParam) { m_TvParam = tvParam; } + private: - f32 m_Volume; - f32 m_Pitch; - f32 m_Lpf; - f32 m_BiquadFilterValue; - s32 m_BiquadFilterType; - s32 m_Priority; - s32 m_OutputLineFlag; + float m_Volume; + float m_Pitch; + float m_Lpf; + float m_BiquadFilterValue; + int m_BiquadFilterType; + int m_Priority; + int m_OutputLineFlag; u32 m_UserData; OutputAmbientParam m_TvParam; }; @@ -62,75 +141,81 @@ struct SoundParamCalculationValues { static_assert(sizeof(SoundArchiveParam) == 0x4); struct SoundPlayerParam { - f32 volume; - f32 lpf; - s32 bqfType; - f32 bqfValue; - f32 outputVolume[1]; - f32 outputMainSend[1]; - f32 outputEffectSend[1][3]; + float volume; + float lpf; + int bqfType; + float bqfValue; + float outputVolume[1]; + float outputMainSend[1]; + float outputEffectSend[1][3]; }; + static_assert(sizeof(SoundPlayerParam) == 0x24); struct Sound3DParam { - f32 volume; - f32 pitch; - f32 lpf; - s32 bqfType; - f32 bqfValue; + float volume; + float pitch; + float lpf; + int bqfType; + float bqfValue; u32 outputLineFlag; - f32 outputVolume[1]; - f32 outputPan[1]; - f32 outputSurroundPan[1]; - f32 outputEffectSend[1][3]; - s32 playerPriority; + float outputVolume[1]; + float outputPan[1]; + float outputSurroundPan[1]; + float outputEffectSend[1][3]; + int playerPriority; }; + static_assert(sizeof(Sound3DParam) == 0x34); struct SoundActorParam { - f32 volume; - f32 pitch; - f32 lpf; - f32 outputVolume[1]; - f32 outputPan[1]; + float volume; + float pitch; + float lpf; + float outputVolume[1]; + float outputPan[1]; }; + static_assert(sizeof(SoundActorParam) == 0x14); struct SoundHandleParam { - f32 volume; - f32 pitch; - f32 lpf; - s32 bqfType; - s32 bqfValue; + float volume; + float pitch; + float lpf; + int bqfType; + int bqfValue; u32 outputLineFlag; - f32 outputVolume[1]; - f32 outputPan[1]; - f32 outputSurroundPan[1]; - f32 outputMainSend[1]; - f32 outputEffectSend[1][3]; + float outputVolume[1]; + float outputPan[1]; + float outputSurroundPan[1]; + float outputMainSend[1]; + float outputEffectSend[1][3]; MixParameter outputMixParameter[1][2]; MixMode mixMode; - f32 pan; - f32 surroundPan; - f32 mainSend; - f32 effectSend[3]; - s32 playerPriority; + float pan; + float surroundPan; + float mainSend; + float effectSend[3]; + int playerPriority; }; + static_assert(sizeof(SoundHandleParam) == 0x84); struct ResultParam { - f32 volume; - f32 pitch; - f32 lpf; - s32 bqfType; - f32 bqfValue; + float volume; + float pitch; + float lpf; + int bqfType; + float bqfValue; u32 outputLineFlag; detail::OutputParam outputParamResult[1]; - s32 playerPriority; + int playerPriority; }; + static_assert(sizeof(ResultParam) == 0x6c); struct FadeVolumeParam { - f32 stopFadeVolume; - f32 pauseFadeVolume; - f32 muteFadeVolume; + float stopFadeVolume; + float pauseFadeVolume; + float muteFadeVolume; bool isMuted; }; + static_assert(sizeof(FadeVolumeParam) == 0x10); SoundArchiveParam soundArchiveParam; SoundPlayerParam soundPlayerParam; @@ -140,21 +225,26 @@ struct SoundParamCalculationValues { ResultParam resultParam; FadeVolumeParam fadeVolumeParam; }; +static_assert(sizeof(SoundParamCalculationValues) == 0x170); namespace detail { class PlayerHeap; class ExternalSoundPlayer; struct SoundActorParam { - f32 volume; - f32 pitch; - f32 tvVolume; - f32 tvPan; - f32 lpf; + float volume; + float pitch; + float tvVolume; + float tvPan; + float lpf; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) - s32 biquadFilterType; - f32 biquadFilterValue; + int biquadFilterType; + float biquadFilterValue; #endif + + SoundActorParam(); + + void Reset(); }; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(SoundActorParam) == 0x14); @@ -163,28 +253,8 @@ static_assert(sizeof(SoundActorParam) == 0x1c); #endif class BasicSound { +// TODO: implement rtti in atk::fnd public: - enum State { - State_Constructed, - State_Initialized, - State_Finalized, - State_Destructed, - }; - - enum MuteState { - MuteState_Normal, - MuteState_Muting, - MuteState_Muted, - MuteState_Unmuting, - }; - - enum PauseState { - PauseState_Normal, - PauseState_Pausing, - PauseState_Paused, - PauseState_Unpausing, - }; - enum PlayerState { PlayerState_Init, PlayerState_Play, @@ -204,187 +274,211 @@ class BasicSound { }; static_assert(sizeof(AmbientInfo) == 0x28); - struct CommonParam { - MoveValue volume; - MixMode mixMode; - f32 pan; - f32 span; - f32 send[4]; - }; - static_assert(sizeof(CommonParam) == 0x2c); - BasicSound(); - virtual ~BasicSound(); + + void Update(); + void StartPrepared(); + + void Stop(int fadeFrames); + void ForceStop(); + + void Pause(bool flag, int fadeFrames); + void Pause(bool flag, int fadeFrames, PauseMode pauseMode); + void Mute(bool flag, int fadeFrames); + + void SetAutoStopCounter(int frames); + void FadeIn(int frames); + #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) virtual bool Initialize(); #else virtual bool Initialize(OutputReceiver* pOutputReceiver); #endif virtual void Finalize(); + virtual bool IsPrepared() const = 0; - virtual bool IsAttachedTempSpecialHandle() = 0; - virtual void DetachTempSpecialHandle() = 0; - virtual driver::BasicSoundPlayer* GetBasicSoundPlayerHandle() = 0; - virtual void OnUpdatePlayerPriority(); - virtual void UpdateMoveValue(); - virtual void OnUpdateParam(); + bool IsPause() const; + bool IsMute() const; + bool IsStarted() const; - void SetPriority(s32 priority, s32 ambientPriority); - void GetPriority(s32* pPlayerAvailable, s32* pPriority) const; + void SetPriority(int priority, int ambientPriority); + void GetPriority(int* priority, int* ambientPriority) const; - void ClearIsFinalizedForCannotAllocatedResourceFlag(); + void SetInitialVolume(float volume); + float GetInitialVolume() const; - void SetId(u32 id); + void SetVolume(float volume, int frames); + float GetVolume() const; - bool IsAttachedGeneralHandle(); - void DetachGeneralHandle(); + void SetPitch(float pitch); + float GetPitch() const; - bool IsAttachedTempGeneralHandle(); - void DetachTempGeneralHandle(); + void SetLpfFreq(float lpfFreq); + float GetLpfFreq() const; - void StartPrepared(); - void Stop(s32 fadeFrames); + void SetBiquadFilter(int type, float value); + void GetBiquadFilter(int* type, float* value) const; - void SetPlayerPriority(s32 priority); + void SetOutputLine(u32 lineFlag); + u32 GetOutputLine() const; + void ResetOutputLine(); - void ForceStop(); - void Pause(bool, s32); - void Pause(bool, s32, PauseMode pauseMode); - - void Mute(bool, s32); + void SetPlayerPriority(int priority); + void SetMixMode(MixMode mixMode); + MixMode GetMixMode(); - void SetAutoStopCounter(s32 autoStopCounter); + void SetPan(float pan); + float GetPan() const; - void FadeIn(s32); + void SetSurroundPan(float span); + float GetSurroundPan() const; - bool IsPause() const; - bool IsMute() const; + void SetMainSend(float send); + float GetMainSend() const; - void Update(); - void UpdateParam(); + void SetFxSend(AuxBus bus, float send); + float GetFxSend(AuxBus bus) const; - f32 CalculateVolume() const; - f32 CalculatePitch() const; - f32 CalculateLpfFrequency() const; - u32 CalculateOutLineFlag() const; - void CalculateBiquadFilter(s32* pBiquadFilterType, f32* pBiquadFilterValue) const; - void CalculateOutputParam(OutputParam*, OutputDevice) const; - void CalculateOutputBusMixVolume(OutputBusMixVolume*, OutputDevice) const; + void SetSend(int bus, float send); + float GetSend(int bus) const; + void SetVolumeThroughMode(int bus, u8 modeBitFlag); + u8 GetVolumeThroughMode(int bus); bool IsVolumeThroughModeUsed() const; - void ApplyCommonParam(OutputParam&) const; + int GetSendBusCount(); + int GetSendChannelCount(); + + void SetPanMode(PanMode mode); + void SetPanCurve(PanCurve curve); +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) + void SetOutputAdditionalParamAddr(OutputDevice device, OutputAdditionalParam* addr, + OutputAdditionalParam* addrForPlayer); +#endif + void SetOutputVolume(OutputDevice device, float volume); + void SetOutputPan(OutputDevice device, float pan); + void SetOutputSurroundPan(OutputDevice device, float span); + void SetOutputMainSend(OutputDevice device, float send); + void SetOutputFxSend(OutputDevice device, AuxBus bus, float send); + void SetOutputFxSend(OutputDevice device, float send); + void SetOutputAdditionalSend(OutputDevice device, int bus, float send); + void SetOutputBusMixVolumeEnabled(OutputDevice device, int subMixBus, bool isEnabled); + void SetOutputBusMixVolume(OutputDevice device, int srcChNo, int subMixBus, ChannelMixVolume param); + void SetOutputChannelMixParameter(OutputDevice device, u32 srcChNo, MixParameter param); + void SetOutputVolumeThroughMode(OutputDevice device, int bus, u8 modeBitFlag); + + float GetOutputVolume(OutputDevice device) const; + float GetOutputPan(OutputDevice device) const; + float GetOutputSurroundPan(OutputDevice device) const; + float GetOutputMainSend(OutputDevice device) const; + float GetOutputFxSend(OutputDevice device, AuxBus bus) const; + float GetOutputFxSend(OutputDevice device) const; + bool IsOutputBusMixVolumeEnabled(OutputDevice device, int subMixBus) const; + ChannelMixVolume GetOutputBusMixVolume(OutputDevice device, int srcChNo, int subMixBus) const; + float GetOutputAdditionalSend(OutputDevice device, int bus) const; + u8 GetOutputVolumeThroughMode(OutputDevice device, int bus) const; + MixParameter GetOutputChannelMixParameter(OutputDevice, u32 srcChNo) const; + int GetRemainingFadeFrames() const; + int GetRemainingPauseFadeFrames() const; + int GetRemainingMuteFadeFrames() const; + int GetPlayerPriority() const; + + void CalculateSoundParamCalculationValues(SoundParamCalculationValues* pOutValue) const; + + void SetId(u32 id); + u32 GetId() const; + u32 GetInstanceId() const; + u32 GetPlayFrameCount() const; + + void SetSetupTick(const os::Tick& tick); + os::Tick GetSetupTick() const; - void AttachPlayerHeap(PlayerHeap* heap); - void DetachPlayerHeap(PlayerHeap* heap); + int CalcCurrentPlayerPriority() const; + SoundPlayer* GetSoundPlayer(); + const SoundPlayer* GetSoundPlayer() const; void AttachSoundPlayer(SoundPlayer* player); void DetachSoundPlayer(SoundPlayer* player); + const SoundActor* GetSoundActor() const; void AttachSoundActor(SoundActor* actor); void DetachSoundActor(SoundActor* actor); void AttachExternalSoundPlayer(ExternalSoundPlayer* extPlayer); void DetachExternalSoundPlayer(ExternalSoundPlayer* extPlayer); - u32 GetRemainingFadeFrames() const; - u32 GetRemainingPauseFadeFrames() const; - u32 GetRemainingMuteFadeFrames() const; + void AttachPlayerHeap(PlayerHeap* pHeap); + void DetachPlayerHeap(PlayerHeap* pHeap); + PlayerHeap* GetPlayerHeap(); - void CalculateSoundParamCalculationValues(SoundParamCalculationValues* pParamCalcValues) const; + void SetAmbientInfo(const AmbientInfo& ambientArgInfo); + void ClearAmbientArgUpdateCallback(); + void ClearAmbientParamUpdateCallback(); + void ClearAmbientArgAllocatorCallback(); + const SoundParam& GetAmbientParam() const; + static int GetAmbientPriority(const AmbientInfo& ambientInfo, u32 soundId); - void SetInitialVolume(f32 volume); - f32 GetInitialVolume() const; - - void SetVolume(f32 volume, s32 frames); - s32 GetVolume() const; - - void SetPitch(f32 pitch); - f32 GetPitch() const; - - void SetLpfFreq(f32 lpf); - f32 GetLpfFreq() const; - - void SetBiquadFilter(s32 biquadFilterType, f32 biquadFilterValue); - void GetBiquadFilter(s32*, f32*) const; - - void SetOutputLine(u32 outputLine); - u32 GetOutputLine() const; - void ResetOutputLine(); - - void SetMixMode(MixMode mode); - MixMode GetMixMode() const; - - void SetPan(f32 pan); - f32 GetPan() const; - - void SetSurroundPan(f32 surroundPan); - f32 GetSurroundPan() const; + bool IsAttachedGeneralHandle(); + bool IsAttachedTempGeneralHandle(); + virtual bool IsAttachedTempSpecialHandle() = 0; - void SetMainSend(f32 mainSend); - f32 GetMainSend() const; + void DetachGeneralHandle(); + void DetachTempGeneralHandle(); + virtual void DetachTempSpecialHandle() = 0; - void SetFxSend(AuxBus auxBus, f32 fxSend); - f32 GetFxSend(AuxBus auxBus) const; + void SetUserParamBuffer(void* buffer, size_t size); + void* GetUserParam(); - void SetSend(s32, f32 send); - void SetOutputAdditionalSend(OutputDevice device, s32, f32 send); + void SetSoundStopCallback(const SoundStopCallback callback); + void SetSoundArchive(const SoundArchive* soundArchive); + const SoundArchive* GetSoundArchive() const; - f32 GetSend(s32) const; - void GetOutputAdditionalSend(OutputDevice device, s32) const; + enum PauseState { + PauseState_Normal, + PauseState_Pausing, + PauseState_Paused, + PauseState_Unpausing, + }; + PauseState GetPauseState() const; - void SetVolumeThroughMode(s32, u8); - void SetOutputVolumeThroughMode(OutputDevice device, s32, u8); + enum MuteState { + MuteState_Normal, + MuteState_Muting, + MuteState_Muted, + MuteState_Unmuting, + }; + MuteState GetMuteState() const; - void GetVolumeThroughMode(s32); - void GetOutputVolumeThroughMode(OutputDevice device, s32) const; +protected: + virtual driver::BasicSoundPlayer* GetBasicSoundPlayerHandle() = 0; + virtual void OnUpdatePlayerPriority(); + virtual void UpdateMoveValue(); + virtual void OnUpdateParam(); - s32 GetSendBusCount(); - s32 GetSendChannelCount(); + bool IsPlayerAvailable() const; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) - void SetOutputAdditionalParamAddr(OutputDevice device, OutputAdditionalParam* addr, - OutputAdditionalParam* addrForPlayer); -#endif +private: + void UpdateParam(); - void SetOutputVolume(OutputDevice device, f32 volume); - void SetOutputBusMixVolume(OutputDevice, u32, u32, ChannelMixVolume); - void SetOutputChannelMixParameter(OutputDevice, u32, MixParameter); - void SetOutputPan(OutputDevice device, f32 pan); - void SetOutputSurroundPan(OutputDevice device, f32 surroundPan); - void SetOutputMainSend(OutputDevice device, f32 mainSend); - void SetOutputFxSend(OutputDevice device, AuxBus auxBus, f32 fxSend); - void SetOutputFxSend(OutputDevice device, f32 fxSend); - void SetOutputBusMixVolumeEnabled(OutputDevice device, s32, bool); - - f32 GetOutputVolume(OutputDevice device) const; - MixParameter GetOutputChannelMixParameter(OutputDevice, u32) const; - f32 GetOutputPan(OutputDevice device) const; - f32 GetOutputSurroundPan(OutputDevice device) const; - f32 GetOutputMainSend(OutputDevice device) const; - f32 GetOutputFxSend(OutputDevice device, AuxBus auxBus) const; - f32 GetOutputFxSend(OutputDevice device) const; - - bool IsOutputBusMixVolumeEnabled(OutputDevice device, s32) const; - void GetOutputBusMixVolume(OutputDevice device, s32, s32) const; + void ClearIsFinalizedForCannotAllocatedResourceFlag(); - void SetPanMode(PanMode mode); - void SetPanCurve(PanCurve curve); - void SetAmbientInfo(AmbientInfo* ambientArgInfo); - - static s32 GetAmbientPriority(const AmbientInfo& ambientInfo, u32 soundId); + float CalculateVolume() const; + float CalculatePitch() const; + float CalculateLpfFrequency() const; + void CalculateBiquadFilter(int* pOutBiquadType, float* pOutBiquadValue) const; + u32 CalculateOutLineFlag() const; + void CalculateOutputParam(OutputParam* pOutParam, OutputDevice device) const; + void CalculateOutputBusMixVolume(OutputBusMixVolume* pOutParam, OutputDevice device) const; - void SetSetupTick(const os::Tick& tick); - void SetSoundArchive(const SoundArchive* soundArchive); - - PanMode GetPanMode() const; - PanCurve GetPanCurve() const; - AmbientInfo* GetAmbientInfo() const; + void ApplyCommonParam(OutputParam& param) const; -private: - friend SoundPlayer; - friend ExternalSoundPlayer; + enum State { + State_Constructed, + State_Initialized, + State_Finalized, + State_Destructed, + }; PlayerHeap* m_pPlayerHeap; SoundHandle* m_pGeneralHandle; @@ -396,9 +490,9 @@ class BasicSound { AmbientInfo m_AmbientInfo; SoundParam m_AmbientParam; SoundActorParam m_ActorParam; - MoveValue m_FadeVolume; - MoveValue m_PauseFadeVolume; - MoveValue m_MuteFadeVolume; + MoveValue m_FadeVolume; + MoveValue m_PauseFadeVolume; + MoveValue m_MuteFadeVolume; bool m_StartFlag; bool m_StartedFlag; bool m_AutoStopFlag; @@ -427,19 +521,41 @@ class BasicSound { #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) OutputReceiver* m_pOutputReceiver; #endif + + struct CommonParam { + MoveValue volume; + MixMode mixMode; + float pan; + float span; + float send[4]; + + void Initialize(); + void Update(); + + float GetVolume() const; + void SetVolume(float target, int frame); + + CommonParam(); + }; + static_assert(sizeof(CommonParam) == 0x2c); + CommonParam m_CommonParam; + OutputParam m_OutputParam[1]; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) - OutputAdditionalParam* m_pOutputAdditionalParam; + OutputAdditionalParam* m_pOutputAdditionalParam[1]; #endif void* m_pUserParam; size_t m_UserParamSize; SoundStopCallback m_SoundStopCallback; + + static u32 g_LastInstanceId; + +public: util::IntrusiveListNode m_SoundPlayerPlayLink; util::IntrusiveListNode m_SoundPlayerPriorityLink; util::IntrusiveListNode m_ExtSoundPlayerPlayLink; - static s32 g_LastInstanceId; }; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(BasicSound) == 0x1f0); From 6759a3e3c46831fb182c131169cce15bd01b8d4b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 8 Aug 2026 16:04:51 -0400 Subject: [PATCH 192/785] atk: define more functions based on dwarf in `atk_SoundArchive.h` --- include/nn/atk/atk_SoundArchive.h | 112 +++++++++++++++++------------- 1 file changed, 64 insertions(+), 48 deletions(-) diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index a9b20911..27f9da46 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -17,15 +17,13 @@ class SoundArchive { using FileId = ItemId; using StringId = ItemId; - constexpr static ItemId InvalidId = -1; + static const ItemId InvalidId = -1; - constexpr static u32 UserParamIndexMax = 3; - constexpr static u32 ResultInvalidSoundId = 0; - constexpr static u32 InvalidUserParam = -1; - constexpr static u32 SequenceBankMax = 4; - constexpr static u32 StreamTrackCount = 8; - - constexpr static s32 FilePathMax = 639; + static const int UserParamIndexMax = 3; + static const u32 ResultInvalidSoundId = 0; + static const u32 InvalidUserParam = -1; + static const u32 SequenceBankMax = 4; + static const u32 StreamTrackCount = 8; enum SoundType { SoundType_Invalid, @@ -81,12 +79,14 @@ class SoundArchive { static_assert(sizeof(GroupInfo) == 0x8); struct FileInfo { - constexpr static u32 InvalidOffset = -1; - constexpr static u32 InvalidSize = -1; + static const u32 InvalidOffset = 0xffffffff; + static const u32 InvalidSize = 0xffffffff; u32 fileSize; u32 offsetFromFileBlockHead; - char* externalFilePath; + const char* externalFilePath; + + FileInfo(); }; static_assert(sizeof(FileInfo) == 0x10); @@ -138,15 +138,15 @@ class SoundArchive { u8 biquadValue; u8 channelCount; s8 globalChannelIndex[2]; + + StreamTrackInfo(); }; static_assert(sizeof(StreamTrackInfo) == 0xe); struct StreamSoundInfo { - void Setup(); - u16 allocateTrackFlags; u16 allocateChannelCount; - f32 pitch; + float pitch; u8 mainSend; u8 fxSend[3]; StreamTrackInfo trackInfo[8]; @@ -154,6 +154,9 @@ class SoundArchive { DecodeMode decodeMode; FileId prefetchFileId; void* streamBufferPool; + + StreamSoundInfo(); + void Setup(); }; static_assert(sizeof(StreamSoundInfo) == 0x90); @@ -161,6 +164,8 @@ class SoundArchive { bool isLoop; u32 loopStartFrame; u32 loopEndFrame; + + StreamSoundInfo2(); }; static_assert(sizeof(StreamSoundInfo2) == 0xc); @@ -179,7 +184,7 @@ class SoundArchive { struct Sound3DInfo { u32 flags; - f32 decayRatio; + float decayRatio; u8 decayCurve; u8 dopplerFactor; }; @@ -201,55 +206,64 @@ class SoundArchive { u32 GetWaveArchiveCount() const; u32 detail_GetFileCount() const; - char* GetItemLabel(ItemId id) const; + const char* GetItemLabel(ItemId id) const; + ItemId GetItemId(const char* pStr) const; FileId GetItemFileId(ItemId id) const; FileId GetItemPrefetchFileId(ItemId id) const; - void* GetSoundUserParam(u32) const; - - bool ReadSoundUserParam(u32*, u32, s32) const; + static ItemId GetSoundIdFromIndex(u32); + static ItemId GetSoundGroupIdFromIndex(u32); + static ItemId GetBankIdFromIndex(u32); + static ItemId GetPlayerIdFromIndex(u32); + static ItemId GetWaveArchiveIdFromIndex(u32); + static ItemId GetGroupIdFromIndex(u32); - u32 GetSoundType(u32) const; + u32 GetSoundUserParam(ItemId soundId) const; + bool ReadSoundUserParam(u32* pOutValue, ItemId soundId, int index) const; - bool ReadSoundInfo(SoundInfo* info, u32) const; - bool ReadSequenceSoundInfo(SequenceSoundInfo* info, u32) const; - bool ReadStreamSoundInfo(StreamSoundInfo* info, u32) const; + SoundType GetSoundType(ItemId soundId) const; - bool detail_ReadStreamSoundInfo2(u32, StreamSoundInfo2*) const; - bool detail_ReadWaveSoundInfo(u32, WaveSoundInfo*) const; - bool detail_ReadAdvancedWaveSoundInfo(u32, AdvancedWaveSoundInfo*) const; + bool ReadSoundInfo(SoundInfo* pOutValue, ItemId soundId) const; + bool ReadSequenceSoundInfo(SequenceSoundInfo* pOutValue, ItemId soundId) const; + bool ReadBankInfo(BankInfo* pOutValue, ItemId bankId) const; + bool ReadPlayerInfo(PlayerInfo* pOutValue, ItemId playerId) const; + bool ReadSoundArchivePlayerInfo(SoundArchivePlayerInfo* pOutValue) const; + bool ReadStreamSoundInfo(StreamSoundInfo* pOutValue, ItemId soundId) const; - bool ReadPlayerInfo(PlayerInfo*, u32) const; - bool ReadSoundArchivePlayerInfo(SoundArchivePlayerInfo*) const; - bool ReadSound3DInfo(Sound3DInfo*, u32) const; - bool ReadBankInfo(BankInfo*, u32) const; - bool ReadWaveArchiveInfo(u32, WaveArchiveInfo*) const; + bool detail_ReadStreamSoundInfo2(ItemId soundId, StreamSoundInfo2* info) const; + bool detail_ReadWaveSoundInfo(ItemId soundId, WaveSoundInfo* info) const; + bool detail_ReadAdvancedWaveSoundInfo(ItemId soundId, AdvancedWaveSoundInfo* info) const; - bool detail_ReadSoundGroupInfo(u32, SoundGroupInfo*) const; + bool ReadSound3DInfo(Sound3DInfo* pOutValue, ItemId soundId) const; + bool ReadWaveArchiveInfo(ItemId warcId, WaveArchiveInfo* info) const; - bool ReadGroupInfo(GroupInfo*, u32) const; + bool detail_ReadSoundGroupInfo(ItemId soundGroupId, SoundGroupInfo* info) const; - bool detail_ReadFileInfo(u32, FileInfo*) const; + bool ReadGroupInfo(GroupInfo* pOutValue, ItemId groupId) const; - detail::Util::Table* detail_GetWaveArchiveIdTable(ItemId id); + bool detail_ReadFileInfo(FileId fileId, FileInfo* info) const; - bool detail_OpenFileStream(FileId id, void*, size_t, void*, size_t) const; - - char* detail_GetExternalFileFullPath(const char*, char*, size_t) const; - - void SetExternalFileRoot(const char*); + const detail::Util::Table* detail_GetWaveArchiveIdTable(ItemId id) const; + virtual const void* detail_GetFileAddress(FileId fileId) const = 0; + virtual size_t detail_GetRequiredStreamBufferSize() const = 0; - bool ReadStreamSoundFilePath(char*, size_t, u32); + detail::fnd::FileStream* detail_OpenFileStream(FileId fileId, void* buffer, size_t size, + void* cacheBuffer, size_t cacheSize) const; + const detail::Util::Table* detail_GetAttachedGroupTable(FileId fileId) const; + + detail::SoundArchiveParametersHook* detail_GetParametersHook() const; + void detail_SetParametersHook(detail::SoundArchiveParametersHook* parametersHook); - void* detail_GetAttachedGroupTable(u32) const; + void SetExternalFileRoot(const char* extFileRoot); + bool ReadStreamSoundFilePath(char* outFilePathBuffer, size_t filePathBufferSize, ItemId soundId) const; - virtual void* detail_GetFileAddress(ItemId itemId) = 0; - virtual size_t detail_GetRequiredStreamBufferSize() const = 0; - virtual void FileAccessBegin() const; virtual void FileAccessEnd() const; - virtual bool IsAddon(); + const char* detail_GetExternalFileFullPath(const char* externalFilePath, char* pathBuffer, + size_t bufSize) const; + + virtual bool IsAddon() const; protected: void Initialize(detail::SoundArchiveFileReader* fileReader); @@ -257,11 +271,13 @@ class SoundArchive { virtual detail::fnd::FileStream* OpenStream(void* buffer, size_t size, position_t begin, size_t length) const = 0; - virtual detail::fnd::FileStream* OpenExtStream(void* buffer, size_t size, const char* extFilePath, void* cacheBuffer, size_t cacheSize) const = 0; - detail::fnd::FileStream* OpenExtStreamImpl(void*, size_t, const char*, void*, size_t) const; + detail::fnd::FileStream* OpenExtStreamImpl(void* buffer, size_t size, const char* externalFilePath, + void* cacheBuffer, size_t cacheSize) const; + + static const s32 FilePathMax = 639; private: detail::SoundArchiveFileReader* m_pFileReader{}; From f50ae0f9541ec02788a554cf57759c5f4689a297 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 8 Aug 2026 16:21:34 -0400 Subject: [PATCH 193/785] atk: Add source files --- CMakeLists.txt | 104 ++++++++++++++++++ include/nn/atk/atk_Adpcm.h | 7 -- src/NintendoWare/atk/atk_FsSoundArchive.cpp | 0 .../atk/atk_SequenceSoundHandle.cpp | 0 .../atk/atk_SoundArchivePlayer.cpp | 0 src/NintendoWare/atk/atk_SoundDataManager.cpp | 0 src/NintendoWare/atk/atk_SoundHandle.cpp | 0 src/NintendoWare/atk/atk_SoundHeap.cpp | 0 src/NintendoWare/atk/atk_SoundPlayer.cpp | 0 src/NintendoWare/atk/atk_SoundStartable.cpp | 0 src/NintendoWare/atk/atk_SoundSystem.cpp | 0 .../atk/atk_StreamSoundHandle.cpp | 0 .../detail/atk_AddonSoundArchiveContainer.cpp | 0 .../atk/detail/atk_AdvancedWaveSound.cpp | 0 .../atk/detail/atk_AdvancedWaveSoundFile.cpp | 0 .../atk_AdvancedWaveSoundFileReader.cpp | 0 .../detail/atk_AdvancedWaveSoundPlayer.cpp | 0 .../detail/atk_AdvancedWaveSoundRuntime.cpp | 0 .../atk/detail/atk_BasicSound.cpp | 0 .../atk/detail/atk_BasicSoundPlayer.cpp | 0 .../atk/detail/atk_BusMixVolumePacket.cpp | 0 .../atk/detail/atk_DisposeCallbackManager.cpp | 0 .../atk/detail/atk_ExternalSoundPlayer.cpp | 0 src/NintendoWare/atk/detail/atk_GroupFile.cpp | 0 .../atk/detail/atk_GroupFileReader.cpp | 0 .../atk/detail/atk_OutputAdditionalParam.cpp | 0 .../atk/detail/atk_PlayerHeap.cpp | 0 .../atk/detail/atk_PlayerHeapDataManager.cpp | 0 .../atk/detail/atk_RegionManager.cpp | 0 .../atk/detail/atk_SoundArchiveFile.cpp | 0 .../atk/detail/atk_SoundArchiveFileReader.cpp | 0 .../atk/detail/atk_SoundArchiveLoader.cpp | 0 .../atk/detail/atk_SoundArchiveManager.cpp | 0 .../atk/detail/atk_StartInfoReader.cpp | 0 .../detail/atk_VolumeThroughModePacket.cpp | 0 .../atk/detail/atk_WaveArchiveFile.cpp | 0 .../atk/detail/atk_WaveArchiveFileReader.cpp | 0 src/NintendoWare/atk/detail/atk_WaveFile.cpp | 0 .../atk/detail/atk_WaveFileReader.cpp | 0 .../atk/detail/debug/atk_Debug.cpp | 0 .../detail/dsp/atk_BiquadFilterPresets.cpp | 0 .../atk/detail/dsp/atk_DecodeAdpcm.cpp | 7 ++ .../atk/detail/dsp/atk_DspadpcmReader.cpp | 0 .../atk/detail/dsp/atk_HardwareManager.cpp | 0 src/NintendoWare/atk/detail/seq/atk_Bank.cpp | 0 .../atk/detail/seq/atk_BankFile.cpp | 0 .../atk/detail/seq/atk_BankFileReader.cpp | 0 .../atk/detail/seq/atk_MmlParser.cpp | 0 .../atk/detail/seq/atk_MmlSequenceTrack.cpp | 0 .../seq/atk_MmlSequenceTrackAllocator.cpp | 0 .../atk/detail/seq/atk_SequenceSound.cpp | 0 .../atk/detail/seq/atk_SequenceSoundFile.cpp | 0 .../seq/atk_SequenceSoundFileReader.cpp | 0 .../detail/seq/atk_SequenceSoundPlayer.cpp | 0 .../detail/seq/atk_SequenceSoundRuntime.cpp | 0 .../atk/detail/seq/atk_SequenceTrack.cpp | 0 .../atk/detail/strm/atk_StreamBufferPool.cpp | 0 .../atk/detail/strm/atk_StreamSound.cpp | 0 .../atk/detail/strm/atk_StreamSoundFile.cpp | 0 .../detail/strm/atk_StreamSoundFileLoader.cpp | 0 .../detail/strm/atk_StreamSoundFileReader.cpp | 0 .../atk/detail/strm/atk_StreamSoundLoader.cpp | 0 .../atk/detail/strm/atk_StreamSoundPlayer.cpp | 0 .../strm/atk_StreamSoundPrefetchFile.cpp | 0 .../atk_StreamSoundPrefetchFileReader.cpp | 0 .../detail/strm/atk_StreamSoundRuntime.cpp | 0 .../atk/detail/strm/atk_StreamTrack.cpp | 0 .../atk/detail/thread/atk_CommandManager.cpp | 0 .../atk/detail/thread/atk_DriverCommand.cpp | 0 .../atk/detail/thread/atk_SoundThread.cpp | 0 .../atk/detail/thread/atk_Task.cpp | 0 .../atk/detail/thread/atk_TaskManager.cpp | 0 .../atk/detail/thread/atk_TaskThread.cpp | 0 .../atk/detail/util/atk_CurveAdshr.cpp | 0 .../atk/detail/util/atk_CurveLfo.cpp | 0 .../atk/detail/util/atk_FrameHeap.cpp | 0 .../atk/detail/util/atk_InstancePool.cpp | 0 .../atk/detail/util/atk_MemoryFileStream.cpp | 0 src/NintendoWare/atk/detail/util/atk_Util.cpp | 0 .../atk/detail/util/atk_WavOutFileStream.cpp | 0 .../atk/detail/voice/atk_Channel.cpp | 0 .../atk/detail/voice/atk_ChannelManager.cpp | 0 .../atk/detail/voice/atk_LowLevelVoice.cpp | 0 .../atk/detail/voice/atk_MultiVoice.cpp | 0 .../detail/voice/atk_MultiVoiceManager.cpp | 0 .../atk/detail/voice/atk_Voice.cpp | 0 .../atk/detail/voice/atk_VoiceCommand.cpp | 0 .../atk/detail/wsd/atk_WaveSound.cpp | 0 .../atk/detail/wsd/atk_WaveSoundFile.cpp | 0 .../detail/wsd/atk_WaveSoundFileReader.cpp | 0 .../atk/detail/wsd/atk_WaveSoundLoader.cpp | 0 .../atk/detail/wsd/atk_WaveSoundPlayer.cpp | 0 .../atk/detail/wsd/atk_WaveSoundRuntime.cpp | 0 src/NintendoWare/atk/effect/atk_EffectAux.cpp | 0 .../atk/effect/atk_EffectBase.cpp | 0 .../atk/submix/atk_ChannelMixVolume.cpp | 0 src/NintendoWare/atk/submix/atk_FinalMix.cpp | 0 .../atk/submix/atk_OutputMixer.cpp | 0 src/NintendoWare/atk/submix/atk_SubMix.cpp | 0 .../atk_AudioRendererPerformanceReader.cpp | 0 .../atk/util/atk_DeviceOutRecorder.cpp | 0 .../atk/util/atk_ProfileReader.cpp | 0 .../atk/util/atk_TaskProfileReader.cpp | 0 103 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 src/NintendoWare/atk/atk_FsSoundArchive.cpp create mode 100644 src/NintendoWare/atk/atk_SequenceSoundHandle.cpp create mode 100644 src/NintendoWare/atk/atk_SoundArchivePlayer.cpp create mode 100644 src/NintendoWare/atk/atk_SoundDataManager.cpp create mode 100644 src/NintendoWare/atk/atk_SoundHandle.cpp create mode 100644 src/NintendoWare/atk/atk_SoundHeap.cpp create mode 100644 src/NintendoWare/atk/atk_SoundPlayer.cpp create mode 100644 src/NintendoWare/atk/atk_SoundStartable.cpp create mode 100644 src/NintendoWare/atk/atk_SoundSystem.cpp create mode 100644 src/NintendoWare/atk/atk_StreamSoundHandle.cpp create mode 100644 src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp create mode 100644 src/NintendoWare/atk/detail/atk_AdvancedWaveSound.cpp create mode 100644 src/NintendoWare/atk/detail/atk_AdvancedWaveSoundFile.cpp create mode 100644 src/NintendoWare/atk/detail/atk_AdvancedWaveSoundFileReader.cpp create mode 100644 src/NintendoWare/atk/detail/atk_AdvancedWaveSoundPlayer.cpp create mode 100644 src/NintendoWare/atk/detail/atk_AdvancedWaveSoundRuntime.cpp create mode 100644 src/NintendoWare/atk/detail/atk_BasicSound.cpp create mode 100644 src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp create mode 100644 src/NintendoWare/atk/detail/atk_BusMixVolumePacket.cpp create mode 100644 src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp create mode 100644 src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp create mode 100644 src/NintendoWare/atk/detail/atk_GroupFile.cpp create mode 100644 src/NintendoWare/atk/detail/atk_GroupFileReader.cpp create mode 100644 src/NintendoWare/atk/detail/atk_OutputAdditionalParam.cpp create mode 100644 src/NintendoWare/atk/detail/atk_PlayerHeap.cpp create mode 100644 src/NintendoWare/atk/detail/atk_PlayerHeapDataManager.cpp create mode 100644 src/NintendoWare/atk/detail/atk_RegionManager.cpp create mode 100644 src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp create mode 100644 src/NintendoWare/atk/detail/atk_SoundArchiveFileReader.cpp create mode 100644 src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp create mode 100644 src/NintendoWare/atk/detail/atk_SoundArchiveManager.cpp create mode 100644 src/NintendoWare/atk/detail/atk_StartInfoReader.cpp create mode 100644 src/NintendoWare/atk/detail/atk_VolumeThroughModePacket.cpp create mode 100644 src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp create mode 100644 src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp create mode 100644 src/NintendoWare/atk/detail/atk_WaveFile.cpp create mode 100644 src/NintendoWare/atk/detail/atk_WaveFileReader.cpp create mode 100644 src/NintendoWare/atk/detail/debug/atk_Debug.cpp create mode 100644 src/NintendoWare/atk/detail/dsp/atk_BiquadFilterPresets.cpp create mode 100644 src/NintendoWare/atk/detail/dsp/atk_DecodeAdpcm.cpp create mode 100644 src/NintendoWare/atk/detail/dsp/atk_DspadpcmReader.cpp create mode 100644 src/NintendoWare/atk/detail/dsp/atk_HardwareManager.cpp create mode 100644 src/NintendoWare/atk/detail/seq/atk_Bank.cpp create mode 100644 src/NintendoWare/atk/detail/seq/atk_BankFile.cpp create mode 100644 src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp create mode 100644 src/NintendoWare/atk/detail/seq/atk_MmlParser.cpp create mode 100644 src/NintendoWare/atk/detail/seq/atk_MmlSequenceTrack.cpp create mode 100644 src/NintendoWare/atk/detail/seq/atk_MmlSequenceTrackAllocator.cpp create mode 100644 src/NintendoWare/atk/detail/seq/atk_SequenceSound.cpp create mode 100644 src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp create mode 100644 src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp create mode 100644 src/NintendoWare/atk/detail/seq/atk_SequenceSoundPlayer.cpp create mode 100644 src/NintendoWare/atk/detail/seq/atk_SequenceSoundRuntime.cpp create mode 100644 src/NintendoWare/atk/detail/seq/atk_SequenceTrack.cpp create mode 100644 src/NintendoWare/atk/detail/strm/atk_StreamBufferPool.cpp create mode 100644 src/NintendoWare/atk/detail/strm/atk_StreamSound.cpp create mode 100644 src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp create mode 100644 src/NintendoWare/atk/detail/strm/atk_StreamSoundFileLoader.cpp create mode 100644 src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp create mode 100644 src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp create mode 100644 src/NintendoWare/atk/detail/strm/atk_StreamSoundPlayer.cpp create mode 100644 src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp create mode 100644 src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp create mode 100644 src/NintendoWare/atk/detail/strm/atk_StreamSoundRuntime.cpp create mode 100644 src/NintendoWare/atk/detail/strm/atk_StreamTrack.cpp create mode 100644 src/NintendoWare/atk/detail/thread/atk_CommandManager.cpp create mode 100644 src/NintendoWare/atk/detail/thread/atk_DriverCommand.cpp create mode 100644 src/NintendoWare/atk/detail/thread/atk_SoundThread.cpp create mode 100644 src/NintendoWare/atk/detail/thread/atk_Task.cpp create mode 100644 src/NintendoWare/atk/detail/thread/atk_TaskManager.cpp create mode 100644 src/NintendoWare/atk/detail/thread/atk_TaskThread.cpp create mode 100644 src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp create mode 100644 src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp create mode 100644 src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp create mode 100644 src/NintendoWare/atk/detail/util/atk_InstancePool.cpp create mode 100644 src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp create mode 100644 src/NintendoWare/atk/detail/util/atk_Util.cpp create mode 100644 src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp create mode 100644 src/NintendoWare/atk/detail/voice/atk_Channel.cpp create mode 100644 src/NintendoWare/atk/detail/voice/atk_ChannelManager.cpp create mode 100644 src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp create mode 100644 src/NintendoWare/atk/detail/voice/atk_MultiVoice.cpp create mode 100644 src/NintendoWare/atk/detail/voice/atk_MultiVoiceManager.cpp create mode 100644 src/NintendoWare/atk/detail/voice/atk_Voice.cpp create mode 100644 src/NintendoWare/atk/detail/voice/atk_VoiceCommand.cpp create mode 100644 src/NintendoWare/atk/detail/wsd/atk_WaveSound.cpp create mode 100644 src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp create mode 100644 src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp create mode 100644 src/NintendoWare/atk/detail/wsd/atk_WaveSoundLoader.cpp create mode 100644 src/NintendoWare/atk/detail/wsd/atk_WaveSoundPlayer.cpp create mode 100644 src/NintendoWare/atk/detail/wsd/atk_WaveSoundRuntime.cpp create mode 100644 src/NintendoWare/atk/effect/atk_EffectAux.cpp create mode 100644 src/NintendoWare/atk/effect/atk_EffectBase.cpp create mode 100644 src/NintendoWare/atk/submix/atk_ChannelMixVolume.cpp create mode 100644 src/NintendoWare/atk/submix/atk_FinalMix.cpp create mode 100644 src/NintendoWare/atk/submix/atk_OutputMixer.cpp create mode 100644 src/NintendoWare/atk/submix/atk_SubMix.cpp create mode 100644 src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp create mode 100644 src/NintendoWare/atk/util/atk_DeviceOutRecorder.cpp create mode 100644 src/NintendoWare/atk/util/atk_ProfileReader.cpp create mode 100644 src/NintendoWare/atk/util/atk_TaskProfileReader.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d1d1b328..8286d6d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -293,6 +293,8 @@ add_library(NintendoSDK OBJECT src/NintendoSDK/nvn/nvn_Impl.cpp ) + +# Atk Sources target_sources(NintendoSDK PUBLIC include/nn/atk/atk_Adpcm.h @@ -445,6 +447,108 @@ PUBLIC PRIVATE src/NintendoWare/atk/atk_SoundArchive.cpp + src/NintendoWare/atk/atk_FsSoundArchive.cpp + src/NintendoWare/atk/atk_SequenceSoundHandle.cpp + src/NintendoWare/atk/atk_SoundArchive.cpp + src/NintendoWare/atk/atk_SoundArchivePlayer.cpp + src/NintendoWare/atk/atk_SoundDataManager.cpp + src/NintendoWare/atk/atk_SoundHandle.cpp + src/NintendoWare/atk/atk_SoundHeap.cpp + src/NintendoWare/atk/atk_SoundPlayer.cpp + src/NintendoWare/atk/atk_SoundStartable.cpp + src/NintendoWare/atk/atk_SoundSystem.cpp + src/NintendoWare/atk/atk_StreamSoundHandle.cpp + src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp + src/NintendoWare/atk/detail/atk_AdvancedWaveSound.cpp + src/NintendoWare/atk/detail/atk_AdvancedWaveSoundFile.cpp + src/NintendoWare/atk/detail/atk_AdvancedWaveSoundFileReader.cpp + src/NintendoWare/atk/detail/atk_AdvancedWaveSoundPlayer.cpp + src/NintendoWare/atk/detail/atk_AdvancedWaveSoundRuntime.cpp + src/NintendoWare/atk/detail/atk_BasicSound.cpp + src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp + src/NintendoWare/atk/detail/atk_BusMixVolumePacket.cpp + src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp + src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp + src/NintendoWare/atk/detail/atk_GroupFile.cpp + src/NintendoWare/atk/detail/atk_GroupFileReader.cpp + src/NintendoWare/atk/detail/atk_OutputAdditionalParam.cpp + src/NintendoWare/atk/detail/atk_PlayerHeap.cpp + src/NintendoWare/atk/detail/atk_PlayerHeapDataManager.cpp + src/NintendoWare/atk/detail/atk_RegionManager.cpp + src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp + src/NintendoWare/atk/detail/atk_SoundArchiveFileReader.cpp + src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp + src/NintendoWare/atk/detail/atk_SoundArchiveManager.cpp + src/NintendoWare/atk/detail/atk_StartInfoReader.cpp + src/NintendoWare/atk/detail/atk_VolumeThroughModePacket.cpp + src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp + src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp + src/NintendoWare/atk/detail/atk_WaveFile.cpp + src/NintendoWare/atk/detail/atk_WaveFileReader.cpp + src/NintendoWare/atk/detail/debug/atk_Debug.cpp + src/NintendoWare/atk/detail/dsp/atk_BiquadFilterPresets.cpp + src/NintendoWare/atk/detail/dsp/atk_DecodeAdpcm.cpp + src/NintendoWare/atk/detail/dsp/atk_DspadpcmReader.cpp + src/NintendoWare/atk/detail/dsp/atk_HardwareManager.cpp + src/NintendoWare/atk/detail/seq/atk_Bank.cpp + src/NintendoWare/atk/detail/seq/atk_BankFile.cpp + src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp + src/NintendoWare/atk/detail/seq/atk_MmlParser.cpp + src/NintendoWare/atk/detail/seq/atk_MmlSequenceTrack.cpp + src/NintendoWare/atk/detail/seq/atk_MmlSequenceTrackAllocator.cpp + src/NintendoWare/atk/detail/seq/atk_SequenceSound.cpp + src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp + src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp + src/NintendoWare/atk/detail/seq/atk_SequenceSoundPlayer.cpp + src/NintendoWare/atk/detail/seq/atk_SequenceSoundRuntime.cpp + src/NintendoWare/atk/detail/seq/atk_SequenceTrack.cpp + src/NintendoWare/atk/detail/strm/atk_StreamBufferPool.cpp + src/NintendoWare/atk/detail/strm/atk_StreamSound.cpp + src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp + src/NintendoWare/atk/detail/strm/atk_StreamSoundFileLoader.cpp + src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp + src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp + src/NintendoWare/atk/detail/strm/atk_StreamSoundPlayer.cpp + src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp + src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp + src/NintendoWare/atk/detail/strm/atk_StreamSoundRuntime.cpp + src/NintendoWare/atk/detail/strm/atk_StreamTrack.cpp + src/NintendoWare/atk/detail/thread/atk_CommandManager.cpp + src/NintendoWare/atk/detail/thread/atk_DriverCommand.cpp + src/NintendoWare/atk/detail/thread/atk_SoundThread.cpp + src/NintendoWare/atk/detail/thread/atk_Task.cpp + src/NintendoWare/atk/detail/thread/atk_TaskManager.cpp + src/NintendoWare/atk/detail/thread/atk_TaskThread.cpp + src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp + src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp + src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp + src/NintendoWare/atk/detail/util/atk_InstancePool.cpp + src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp + src/NintendoWare/atk/detail/util/atk_Util.cpp + src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp + src/NintendoWare/atk/detail/voice/atk_Channel.cpp + src/NintendoWare/atk/detail/voice/atk_ChannelManager.cpp + src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp + src/NintendoWare/atk/detail/voice/atk_MultiVoice.cpp + src/NintendoWare/atk/detail/voice/atk_MultiVoiceManager.cpp + src/NintendoWare/atk/detail/voice/atk_Voice.cpp + src/NintendoWare/atk/detail/voice/atk_VoiceCommand.cpp + src/NintendoWare/atk/detail/wsd/atk_WaveSound.cpp + src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp + src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp + src/NintendoWare/atk/detail/wsd/atk_WaveSoundLoader.cpp + src/NintendoWare/atk/detail/wsd/atk_WaveSoundPlayer.cpp + src/NintendoWare/atk/detail/wsd/atk_WaveSoundRuntime.cpp + src/NintendoWare/atk/effect/atk_EffectAux.cpp + src/NintendoWare/atk/effect/atk_EffectBase.cpp + src/NintendoWare/atk/submix/atk_ChannelMixVolume.cpp + src/NintendoWare/atk/submix/atk_FinalMix.cpp + src/NintendoWare/atk/submix/atk_OutputMixer.cpp + src/NintendoWare/atk/submix/atk_SubMix.cpp + src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp + src/NintendoWare/atk/util/atk_DeviceOutRecorder.cpp + src/NintendoWare/atk/util/atk_ProfileReader.cpp + src/NintendoWare/atk/util/atk_TaskProfileReader.cpp ) target_include_directories(NintendoSDK PUBLIC include/) diff --git a/include/nn/atk/atk_Adpcm.h b/include/nn/atk/atk_Adpcm.h index 1e7b5515..c0644ff3 100644 --- a/include/nn/atk/atk_Adpcm.h +++ b/include/nn/atk/atk_Adpcm.h @@ -16,11 +16,4 @@ struct AdpcmContextNotAligned { audio::AdpcmContext audioAdpcmContext; }; static_assert(sizeof(AdpcmContextNotAligned) == 0x6); - -namespace detail { -// TODO: Move to atk/detail/dsp/atk_DecodeAdpcm.cpp -void DecodeDspAdpcm(position_t playPosition, AdpcmContext& context, - const AdpcmParam& param, const void* adpcmData, - size_t decodeSamples, s16* dest); -}; } // namespace nn::atk \ No newline at end of file diff --git a/src/NintendoWare/atk/atk_FsSoundArchive.cpp b/src/NintendoWare/atk/atk_FsSoundArchive.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/atk_SequenceSoundHandle.cpp b/src/NintendoWare/atk/atk_SequenceSoundHandle.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/atk_SoundArchivePlayer.cpp b/src/NintendoWare/atk/atk_SoundArchivePlayer.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/atk_SoundDataManager.cpp b/src/NintendoWare/atk/atk_SoundDataManager.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/atk_SoundHandle.cpp b/src/NintendoWare/atk/atk_SoundHandle.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/atk_SoundHeap.cpp b/src/NintendoWare/atk/atk_SoundHeap.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/atk_SoundPlayer.cpp b/src/NintendoWare/atk/atk_SoundPlayer.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/atk_SoundStartable.cpp b/src/NintendoWare/atk/atk_SoundStartable.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/atk_SoundSystem.cpp b/src/NintendoWare/atk/atk_SoundSystem.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/atk_StreamSoundHandle.cpp b/src/NintendoWare/atk/atk_StreamSoundHandle.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp b/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_AdvancedWaveSound.cpp b/src/NintendoWare/atk/detail/atk_AdvancedWaveSound.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundFile.cpp b/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundFile.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundFileReader.cpp b/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundFileReader.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundPlayer.cpp b/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundPlayer.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundRuntime.cpp b/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundRuntime.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp b/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_BusMixVolumePacket.cpp b/src/NintendoWare/atk/detail/atk_BusMixVolumePacket.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp b/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_GroupFile.cpp b/src/NintendoWare/atk/detail/atk_GroupFile.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_GroupFileReader.cpp b/src/NintendoWare/atk/detail/atk_GroupFileReader.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_OutputAdditionalParam.cpp b/src/NintendoWare/atk/detail/atk_OutputAdditionalParam.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp b/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_PlayerHeapDataManager.cpp b/src/NintendoWare/atk/detail/atk_PlayerHeapDataManager.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_RegionManager.cpp b/src/NintendoWare/atk/detail/atk_RegionManager.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFileReader.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFileReader.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveManager.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveManager.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_StartInfoReader.cpp b/src/NintendoWare/atk/detail/atk_StartInfoReader.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_VolumeThroughModePacket.cpp b/src/NintendoWare/atk/detail/atk_VolumeThroughModePacket.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_WaveFile.cpp b/src/NintendoWare/atk/detail/atk_WaveFile.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp b/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/debug/atk_Debug.cpp b/src/NintendoWare/atk/detail/debug/atk_Debug.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/dsp/atk_BiquadFilterPresets.cpp b/src/NintendoWare/atk/detail/dsp/atk_BiquadFilterPresets.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/dsp/atk_DecodeAdpcm.cpp b/src/NintendoWare/atk/detail/dsp/atk_DecodeAdpcm.cpp new file mode 100644 index 00000000..d05bf409 --- /dev/null +++ b/src/NintendoWare/atk/detail/dsp/atk_DecodeAdpcm.cpp @@ -0,0 +1,7 @@ +#include + +namespace nn::atk::detail { +void DecodeDspAdpcm(position_t playPosition, AdpcmContext& context, + const AdpcmParam& param, const void* adpcmData, + size_t decodeSamples, s16* dest); +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/dsp/atk_DspadpcmReader.cpp b/src/NintendoWare/atk/detail/dsp/atk_DspadpcmReader.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/dsp/atk_HardwareManager.cpp b/src/NintendoWare/atk/detail/dsp/atk_HardwareManager.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/seq/atk_Bank.cpp b/src/NintendoWare/atk/detail/seq/atk_Bank.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/seq/atk_MmlParser.cpp b/src/NintendoWare/atk/detail/seq/atk_MmlParser.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/seq/atk_MmlSequenceTrack.cpp b/src/NintendoWare/atk/detail/seq/atk_MmlSequenceTrack.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/seq/atk_MmlSequenceTrackAllocator.cpp b/src/NintendoWare/atk/detail/seq/atk_MmlSequenceTrackAllocator.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceSound.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceSound.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundPlayer.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundPlayer.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundRuntime.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundRuntime.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceTrack.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceTrack.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamBufferPool.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamBufferPool.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSound.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSound.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileLoader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileLoader.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPlayer.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPlayer.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundRuntime.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundRuntime.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamTrack.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamTrack.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/thread/atk_CommandManager.cpp b/src/NintendoWare/atk/detail/thread/atk_CommandManager.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/thread/atk_DriverCommand.cpp b/src/NintendoWare/atk/detail/thread/atk_DriverCommand.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/thread/atk_SoundThread.cpp b/src/NintendoWare/atk/detail/thread/atk_SoundThread.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/thread/atk_Task.cpp b/src/NintendoWare/atk/detail/thread/atk_Task.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/thread/atk_TaskManager.cpp b/src/NintendoWare/atk/detail/thread/atk_TaskManager.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/thread/atk_TaskThread.cpp b/src/NintendoWare/atk/detail/thread/atk_TaskThread.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp b/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/util/atk_InstancePool.cpp b/src/NintendoWare/atk/detail/util/atk_InstancePool.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp b/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/util/atk_Util.cpp b/src/NintendoWare/atk/detail/util/atk_Util.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp b/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/voice/atk_ChannelManager.cpp b/src/NintendoWare/atk/detail/voice/atk_ChannelManager.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/voice/atk_MultiVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_MultiVoice.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/voice/atk_MultiVoiceManager.cpp b/src/NintendoWare/atk/detail/voice/atk_MultiVoiceManager.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/voice/atk_Voice.cpp b/src/NintendoWare/atk/detail/voice/atk_Voice.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/voice/atk_VoiceCommand.cpp b/src/NintendoWare/atk/detail/voice/atk_VoiceCommand.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSound.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSound.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundLoader.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundLoader.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundPlayer.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundPlayer.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundRuntime.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundRuntime.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/effect/atk_EffectAux.cpp b/src/NintendoWare/atk/effect/atk_EffectAux.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/effect/atk_EffectBase.cpp b/src/NintendoWare/atk/effect/atk_EffectBase.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/submix/atk_ChannelMixVolume.cpp b/src/NintendoWare/atk/submix/atk_ChannelMixVolume.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/submix/atk_FinalMix.cpp b/src/NintendoWare/atk/submix/atk_FinalMix.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/submix/atk_OutputMixer.cpp b/src/NintendoWare/atk/submix/atk_OutputMixer.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/submix/atk_SubMix.cpp b/src/NintendoWare/atk/submix/atk_SubMix.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp b/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/util/atk_DeviceOutRecorder.cpp b/src/NintendoWare/atk/util/atk_DeviceOutRecorder.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/util/atk_ProfileReader.cpp b/src/NintendoWare/atk/util/atk_ProfileReader.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/util/atk_TaskProfileReader.cpp b/src/NintendoWare/atk/util/atk_TaskProfileReader.cpp new file mode 100644 index 00000000..e69de29b From 089ba9079ca847db53e2d2abeab089f34f9006fc Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 8 Aug 2026 18:34:45 -0400 Subject: [PATCH 194/785] atk: Match `SoundArchive::GetItemLabel` --- include/nn/atk/atk_SoundArchiveFileReader.h | 15 +-------------- include/nn/atk/atk_SoundArchiveFilesHook.h | 17 ++++++++++++++++- .../nn/atk/atk_SoundArchiveParametersHook.h | 19 +++++++++++++++++-- src/NintendoWare/atk/atk_SoundArchive.cpp | 11 +++++++++++ 4 files changed, 45 insertions(+), 17 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveFileReader.h b/include/nn/atk/atk_SoundArchiveFileReader.h index ff84c071..7c747040 100644 --- a/include/nn/atk/atk_SoundArchiveFileReader.h +++ b/include/nn/atk/atk_SoundArchiveFileReader.h @@ -28,7 +28,7 @@ class SoundArchiveFileReader { void DumpTree() const; SoundArchive::ItemId GetItemId(const char* pStr); - char* GetItemLabel(SoundArchive::ItemId id) const; + const char* GetItemLabel(SoundArchive::ItemId id) const; SoundArchive::FileId GetItemFileId(SoundArchive::ItemId id) const; SoundArchive::FileId GetItemPrefetchFileId(SoundArchive::ItemId id) const; @@ -75,17 +75,4 @@ class SoundArchiveFileReader { SoundArchiveFile::FileBlock* m_pFileBlock; #endif }; - -struct SoundArchiveFilesHook { - constexpr static const char* ItemTypeStreamSound = "stm"; - constexpr static const char* ItemTypeWaveSound = "wsd"; - constexpr static const char* ItemTypeSequenceSound = "seq"; - - constexpr static const char* FileTypeStreamBinary = "bxstm"; - constexpr static const char* FileTypeWaveSoundBinary = "bxwsd"; - constexpr static const char* FileTypeSequenceBinary = "bxseq"; - constexpr static const char* FileTypeBankBinary = "bxbnk"; - constexpr static const char* FileTypeWaveArchiveBinary = "bxwar"; - constexpr static const char* FileTypeStreamPrefetchBinary = "bxstp"; -}; } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/atk_SoundArchiveFilesHook.h b/include/nn/atk/atk_SoundArchiveFilesHook.h index 7b9637ef..188bb9b2 100644 --- a/include/nn/atk/atk_SoundArchiveFilesHook.h +++ b/include/nn/atk/atk_SoundArchiveFilesHook.h @@ -1 +1,16 @@ -#pragma once \ No newline at end of file +#pragma once + +namespace nn::atk::detail { +struct SoundArchiveFilesHook { + constexpr static const char* ItemTypeStreamSound = "stm"; + constexpr static const char* ItemTypeWaveSound = "wsd"; + constexpr static const char* ItemTypeSequenceSound = "seq"; + + constexpr static const char* FileTypeStreamBinary = "bxstm"; + constexpr static const char* FileTypeWaveSoundBinary = "bxwsd"; + constexpr static const char* FileTypeSequenceBinary = "bxseq"; + constexpr static const char* FileTypeBankBinary = "bxbnk"; + constexpr static const char* FileTypeWaveArchiveBinary = "bxwar"; + constexpr static const char* FileTypeStreamPrefetchBinary = "bxstp"; +}; +} // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/atk_SoundArchiveParametersHook.h b/include/nn/atk/atk_SoundArchiveParametersHook.h index d604f667..69cb068e 100644 --- a/include/nn/atk/atk_SoundArchiveParametersHook.h +++ b/include/nn/atk/atk_SoundArchiveParametersHook.h @@ -5,9 +5,15 @@ namespace nn::atk::detail { class SoundArchiveParametersHook { public: - bool SetIsEnable(bool value); + bool GetIsEnable() const { return m_IsEnable; } + void SetIsEnable(bool value) { m_IsEnable = value; } + + const char* GetItemLabel(SoundArchive::ItemId id) const { + if (m_IsEnable) + return GetItemLabelImpl(id); + return nullptr; + } - const char* GetItemLabel(SoundArchive::ItemId id) const; SoundArchive::ItemId GetItemId(const char* itemLabel) const; SoundArchive::SoundType GetSoundType(const char* itemLabel); @@ -28,6 +34,15 @@ class SoundArchiveParametersHook { bool ReadSoundUserParam(u32* pOutValue, SoundArchive::ItemId soundId, int index) const; u32 GetSoundUserParam(SoundArchive::ItemId soundId, u32 userParam) const; + +protected: + virtual void Impl1(); + virtual void Impl2(); + virtual void Impl3(); + virtual const char* GetItemLabelImpl(SoundArchive::ItemId id) const; + +private: + bool m_IsEnable; }; } // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index d4114f3f..5332e96a 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -1,6 +1,7 @@ #include #include +#include namespace nn::atk { SoundArchive::SoundArchive() { @@ -56,4 +57,14 @@ u32 SoundArchive::GetWaveArchiveCount() const { u32 SoundArchive::detail_GetFileCount() const { return m_pFileReader->GetFileCount(); } + +const char* SoundArchive::GetItemLabel(ItemId id) const { + if (m_pParametersHook != nullptr) { + const char* result {m_pParametersHook->GetItemLabel(id)}; + if (result != nullptr) + return result; + } + + return m_pFileReader->GetItemLabel(id); +} } // namespace nn::atk \ No newline at end of file From 8803904042aaa68c0f3f6c5341e29362d2f85a1e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 8 Aug 2026 18:35:12 -0400 Subject: [PATCH 195/785] atk: Match `SoundArchive::GetItemId` --- include/nn/atk/atk_SoundArchiveParametersHook.h | 10 +++++++++- src/NintendoWare/atk/atk_SoundArchive.cpp | 10 ++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_SoundArchiveParametersHook.h b/include/nn/atk/atk_SoundArchiveParametersHook.h index 69cb068e..2e3ee998 100644 --- a/include/nn/atk/atk_SoundArchiveParametersHook.h +++ b/include/nn/atk/atk_SoundArchiveParametersHook.h @@ -11,10 +11,16 @@ class SoundArchiveParametersHook { const char* GetItemLabel(SoundArchive::ItemId id) const { if (m_IsEnable) return GetItemLabelImpl(id); + return nullptr; } - SoundArchive::ItemId GetItemId(const char* itemLabel) const; + SoundArchive::ItemId GetItemId(const char* itemLabel) const { + if (m_IsEnable) + return GetItemIdImpl(itemLabel); + + return SoundArchive::InvalidId; + } SoundArchive::SoundType GetSoundType(const char* itemLabel); @@ -40,6 +46,8 @@ class SoundArchiveParametersHook { virtual void Impl2(); virtual void Impl3(); virtual const char* GetItemLabelImpl(SoundArchive::ItemId id) const; + virtual SoundArchive::ItemId GetItemIdImpl(const char* itemLabel) const; + virtual SoundArchive::SoundType GetSoundTypeImpl(const char* itemLabel) const; private: bool m_IsEnable; diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 5332e96a..eb3b5130 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -67,4 +67,14 @@ const char* SoundArchive::GetItemLabel(ItemId id) const { return m_pFileReader->GetItemLabel(id); } + +SoundArchive::ItemId SoundArchive::GetItemId(const char* pStr) const { + if (m_pParametersHook != nullptr) { + ItemId result {m_pParametersHook->GetItemId(pStr)}; + if (result != InvalidId) + return result; + } + + return m_pFileReader->GetItemId(pStr); +} } // namespace nn::atk \ No newline at end of file From 1b06be65b5355e7d58106c0f9e8b4e5189081660 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 8 Aug 2026 18:35:48 -0400 Subject: [PATCH 196/785] atk: Match `SoundArchive::GetItemFileId` --- src/NintendoWare/atk/atk_SoundArchive.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index eb3b5130..e4dcc761 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -77,4 +77,8 @@ SoundArchive::ItemId SoundArchive::GetItemId(const char* pStr) const { return m_pFileReader->GetItemId(pStr); } + +SoundArchive::FileId SoundArchive::GetItemFileId(ItemId id) const { + return m_pFileReader->GetItemFileId(id); +} } // namespace nn::atk \ No newline at end of file From ca25204ac19fa98fbdb40c1e015aa2a8b28125f3 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 10 Aug 2026 10:43:58 -0400 Subject: [PATCH 197/785] atk: Add `fnd` cpp files --- CMakeLists.txt | 11 ++++ include/nn/atk/fnd/basis/atkfnd_HeapBase.h | 50 +++++++++++-------- .../atk/fnd/basis/atkfnd_FrameHeapImpl.cpp | 0 .../atk/fnd/basis/atkfnd_HeapBase.cpp | 0 .../atk/fnd/basis/atkfnd_Time.win32.cpp | 0 .../fnd/basis/atkfnd_WorkBufferAllocator.cpp | 0 .../atk/fnd/io/atkfnd_FileStreamImpl.cpp | 0 .../fnd/io/atkfnd_FileStreamImpl.win32.cpp | 0 .../atk/fnd/io/atkfnd_FileStreamProxy.cpp | 0 .../atk/fnd/io/atkfnd_StreamCache.cpp | 0 src/NintendoWare/atk/fnd/os/atkfnd_Thread.cpp | 0 .../atk/fnd/os/atkfnd_Thread.win32.cpp | 0 12 files changed, 40 insertions(+), 21 deletions(-) create mode 100644 src/NintendoWare/atk/fnd/basis/atkfnd_FrameHeapImpl.cpp create mode 100644 src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp create mode 100644 src/NintendoWare/atk/fnd/basis/atkfnd_Time.win32.cpp create mode 100644 src/NintendoWare/atk/fnd/basis/atkfnd_WorkBufferAllocator.cpp create mode 100644 src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp create mode 100644 src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp create mode 100644 src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp create mode 100644 src/NintendoWare/atk/fnd/io/atkfnd_StreamCache.cpp create mode 100644 src/NintendoWare/atk/fnd/os/atkfnd_Thread.cpp create mode 100644 src/NintendoWare/atk/fnd/os/atkfnd_Thread.win32.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 8286d6d8..c6f82c75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -549,6 +549,17 @@ PRIVATE src/NintendoWare/atk/util/atk_DeviceOutRecorder.cpp src/NintendoWare/atk/util/atk_ProfileReader.cpp src/NintendoWare/atk/util/atk_TaskProfileReader.cpp + + src/NintendoWare/atk/fnd/basis/atkfnd_FrameHeapImpl.cpp + src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp + src/NintendoWare/atk/fnd/basis/atkfnd_Time.win32.cpp + src/NintendoWare/atk/fnd/basis/atkfnd_WorkBufferAllocator.cpp + src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp + src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp + src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp + src/NintendoWare/atk/fnd/io/atkfnd_StreamCache.cpp + src/NintendoWare/atk/fnd/os/atkfnd_Thread.cpp + src/NintendoWare/atk/fnd/os/atkfnd_Thread.win32.cpp ) target_include_directories(NintendoSDK PUBLIC include/) diff --git a/include/nn/atk/fnd/basis/atkfnd_HeapBase.h b/include/nn/atk/fnd/basis/atkfnd_HeapBase.h index d0a83a33..7e8dd108 100644 --- a/include/nn/atk/fnd/basis/atkfnd_HeapBase.h +++ b/include/nn/atk/fnd/basis/atkfnd_HeapBase.h @@ -22,49 +22,57 @@ class HeapBase : util::IntrusiveListBaseNode { FillType_Max, }; - constexpr static u32 DefaultAlignment = 4; + static const int DefaultAlignment = 4; - constexpr static s32 ExpHeapSignature = 0x45585048; // HPXE - constexpr static s32 FrameHeapSignature = 0x46524D48; // HMRF - constexpr static s32 UnitHeapSignature = 0x554E5448; // HTNU + static const u32 ExpHeapSignature = 0x45585048; // HPXE + static const u32 FrameHeapSignature = 0x46524D48; // HMRF + static const u32 UnitHeapSignature = 0x554E5448; // HTNU - constexpr static u32 OptionZeroClear = 1; - constexpr static u32 OptionDebugFill = 1 << 1; - constexpr static u32 OptionThreadSafe = 1 << 2; + static const int OptionZeroClear = 1 << 0; + static const int OptionDebugFill = 1 << 1; + static const int OptionThreadSafe = 1 << 2; - constexpr static u32 ErrorPrint = 1; + static const int ErrorPrint = 1; - constexpr static u32 MIN_ALIGNMENT = 4; + constexpr static int MIN_ALIGNMENT = DefaultAlignment; - HeapList* FindListContainHeap(); - static HeapBase* FindContainHeap(HeapList* pList, const void* memBlock); static HeapBase* FindContainHeap(const void* memBlock); - static HeapBase* FindParentHeap(HeapBase* pChild); + static HeapBase* FindParentHeap(const HeapBase* pChild); + + void* GetHeapStartAddress(); + void* GetHeapEndAddress(); + + size_t GetTotalSize(); + size_t GetTotalUsableSize(); u32 SetFillValue(FillType type, u32 value); u32 GetFillValue(FillType type); HeapType GetHeapType(); +protected: void Initialize(u32 signature, void* heapStart, void* heapEnd, u16 optFlag); - - void SetOptionFlag(u16 optFlag); - - void FillNoUseMemory(void* address, size_t size); - void Finalize(); - + + u32 GetSignature() const; + void* GetHeapStart() const; + void* GetHeapEnd() const; + void LockHeap(); void UnlockHeap(); void FillFreeMemory(void* address, size_t size); - - u16 GetOptionFlag(); - + void FillNoUseMemory(void* address, size_t size); void FillAllocMemory(void* address, size_t size); private: + static HeapBase* FindContainHeap(HeapList* pList, const void* memBlock); + static HeapList* FindListContainHeap(HeapBase* pHeapBase); + + u16 GetOptionFlag(); + void SetOptionFlag(u16 optFlag); + void* mHeapStart; void* mHeapEnd; u32 m_Signature; diff --git a/src/NintendoWare/atk/fnd/basis/atkfnd_FrameHeapImpl.cpp b/src/NintendoWare/atk/fnd/basis/atkfnd_FrameHeapImpl.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp b/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/fnd/basis/atkfnd_Time.win32.cpp b/src/NintendoWare/atk/fnd/basis/atkfnd_Time.win32.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/fnd/basis/atkfnd_WorkBufferAllocator.cpp b/src/NintendoWare/atk/fnd/basis/atkfnd_WorkBufferAllocator.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_StreamCache.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_StreamCache.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/fnd/os/atkfnd_Thread.cpp b/src/NintendoWare/atk/fnd/os/atkfnd_Thread.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/NintendoWare/atk/fnd/os/atkfnd_Thread.win32.cpp b/src/NintendoWare/atk/fnd/os/atkfnd_Thread.win32.cpp new file mode 100644 index 00000000..e69de29b From 8e36f0047ba405fb9a70d160dc38dbb11eb15940 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 10 Aug 2026 11:52:25 -0400 Subject: [PATCH 198/785] atk: add definitions for `fnd` inlines --- include/nn/atk/fnd/basis/atkfnd_HeapBase.h | 6 +--- include/nn/atk/fnd/basis/atkfnd_Inlines.h | 33 ++++++++++++++++++- .../atk/fnd/basis/atkfnd_HeapBase.cpp | 9 +++++ 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/include/nn/atk/fnd/basis/atkfnd_HeapBase.h b/include/nn/atk/fnd/basis/atkfnd_HeapBase.h index 7e8dd108..b5b8708f 100644 --- a/include/nn/atk/fnd/basis/atkfnd_HeapBase.h +++ b/include/nn/atk/fnd/basis/atkfnd_HeapBase.h @@ -36,7 +36,6 @@ class HeapBase : util::IntrusiveListBaseNode { constexpr static int MIN_ALIGNMENT = DefaultAlignment; - static HeapBase* FindContainHeap(const void* memBlock); static HeapBase* FindParentHeap(const HeapBase* pChild); @@ -71,7 +70,7 @@ class HeapBase : util::IntrusiveListBaseNode { static HeapList* FindListContainHeap(HeapBase* pHeapBase); u16 GetOptionFlag(); - void SetOptionFlag(u16 optFlag); + void SetOptionFlag(u16 optFlag) { m_Attribute = optFlag & 0xff; }; void* mHeapStart; void* mHeapEnd; @@ -80,7 +79,4 @@ class HeapBase : util::IntrusiveListBaseNode { u32 m_Attribute; }; static_assert(sizeof(HeapBase) == 0x40); - -static u8 sFillVals[12]; -static HeapBase::HeapList sRootList {}; } // namespace nn::atk::detail::fnd \ No newline at end of file diff --git a/include/nn/atk/fnd/basis/atkfnd_Inlines.h b/include/nn/atk/fnd/basis/atkfnd_Inlines.h index 7b9637ef..a15e352d 100644 --- a/include/nn/atk/fnd/basis/atkfnd_Inlines.h +++ b/include/nn/atk/fnd/basis/atkfnd_Inlines.h @@ -1 +1,32 @@ -#pragma once \ No newline at end of file +#pragma once + +#include + +namespace nn::atk::detail::fnd { +template +inline T Clamp(T x, T low, T high); + +inline float FloatClamp(float value, float min, float max); + +template +inline ValueT RoundUp(ValueT x, int base); + +// TODO: figure out if this is correct for +// void* RoundUp(void* x, int base) +template +inline ValueT* RoundUp(ValueT* x, int base); + +template +inline ValueT RoundDown(ValueT x, int base); + +template +inline ValueT* RoundDown(ValueT* x, int base); + +template +inline TDiff GetOffsetFromPtr(const void* start, const void* end); + +inline ptrdiff_t GetOffsetFromPtr(const void* start, const void* end); + +template +inline void* AddOffsetToPtr(void* ptr, TOffset offset); +} // namespace nn::atk::detail::fnd \ No newline at end of file diff --git a/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp b/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp index e69de29b..5dc57404 100644 --- a/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp +++ b/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp @@ -0,0 +1,9 @@ +#include +#include + +namespace nn::atk::detail::fnd { +namespace { + HeapBase::HeapList* sRootList; + u32 sFillVals[HeapBase::FillType_Max] { 0xC3C3C3C3, 0xF3F3F3F3, 0xD3D3D3D3 }; +} +} // namespace nn::atk::detail::fnd \ No newline at end of file From f6148310be519c6012525877b6616018fcf00a43 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 10 Aug 2026 17:16:15 -0400 Subject: [PATCH 199/785] atk: Implement `HeapBase::Initialize` Implementation is still non-matching --- include/nn/atk/fnd/basis/atkfnd_HeapBase.h | 8 ++- include/nn/atk/fnd/basis/atkfnd_Inlines.h | 8 ++- .../atk/fnd/basis/atkfnd_HeapBase.cpp | 61 +++++++++++++++++-- 3 files changed, 69 insertions(+), 8 deletions(-) diff --git a/include/nn/atk/fnd/basis/atkfnd_HeapBase.h b/include/nn/atk/fnd/basis/atkfnd_HeapBase.h index b5b8708f..328046b7 100644 --- a/include/nn/atk/fnd/basis/atkfnd_HeapBase.h +++ b/include/nn/atk/fnd/basis/atkfnd_HeapBase.h @@ -4,7 +4,7 @@ #include namespace nn::atk::detail::fnd { -class HeapBase : util::IntrusiveListBaseNode { +class HeapBase : public util::IntrusiveListBaseNode { public: using HeapList = util::IntrusiveList>; @@ -70,7 +70,11 @@ class HeapBase : util::IntrusiveListBaseNode { static HeapList* FindListContainHeap(HeapBase* pHeapBase); u16 GetOptionFlag(); - void SetOptionFlag(u16 optFlag) { m_Attribute = optFlag & 0xff; }; + void SetOptionFlag(u16 optFlag) { + u32 maskBits {0xff}; + u16 newVal = optFlag & maskBits; + m_Attribute = newVal; + }; void* mHeapStart; void* mHeapEnd; diff --git a/include/nn/atk/fnd/basis/atkfnd_Inlines.h b/include/nn/atk/fnd/basis/atkfnd_Inlines.h index a15e352d..af14739c 100644 --- a/include/nn/atk/fnd/basis/atkfnd_Inlines.h +++ b/include/nn/atk/fnd/basis/atkfnd_Inlines.h @@ -23,9 +23,13 @@ template inline ValueT* RoundDown(ValueT* x, int base); template -inline TDiff GetOffsetFromPtr(const void* start, const void* end); +inline TDiff GetOffsetFromPtr(const void* start, const void* end) { + return reinterpret_cast(end) - reinterpret_cast(start); +} -inline ptrdiff_t GetOffsetFromPtr(const void* start, const void* end); +inline ptrdiff_t GetOffsetFromPtr(const void* start, const void* end) { + return reinterpret_cast(end) - reinterpret_cast(start); +} template inline void* AddOffsetToPtr(void* ptr, TOffset offset); diff --git a/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp b/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp index 5dc57404..889cb812 100644 --- a/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp +++ b/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp @@ -1,9 +1,62 @@ -#include +#include #include +#include "nn/atk/fnd/basis/atkfnd_Inlines.h" namespace nn::atk::detail::fnd { -namespace { - HeapBase::HeapList* sRootList; - u32 sFillVals[HeapBase::FillType_Max] { 0xC3C3C3C3, 0xF3F3F3F3, 0xD3D3D3D3 }; +static HeapBase::HeapList sRootList; +u32 sFillVals[HeapBase::FillType_Max] { 0xC3C3C3C3, 0xF3F3F3F3, 0xD3D3D3D3 }; + +// NON-MATCHING: unknown reason. Possibly something to do with global variables +void HeapBase::Initialize(u32 signature, void* heapStart, void* heapEnd, u16 optFlag) { + m_Signature = signature; + mHeapStart = heapStart; + mHeapEnd = heapEnd; + + SetOptionFlag(optFlag); + u32 diff = GetOffsetFromPtr(heapStart, heapEnd); + FillNoUseMemory(heapStart, diff); + + HeapList* pList {FindListContainHeap(this)}; + + pList->push_back(*this); +} + +// NON-MATCHING +void HeapBase::FillFreeMemory(void* address, size_t size) { + if ((m_Attribute >> 1 & 1) != 0) + memset(address, static_cast(GetFillValue(FillType_Free)), size); +} + +// NON-MATCHING +void HeapBase::FillAllocMemory(void* address, size_t size) { + if (m_Attribute & 1) { + memset(address, 0, size); + return; + } + + if ((m_Attribute >> 1 & 1) != 0) + memset(address, GetFillValue(FillType_Alloc), size); +} + +// NON-MATCHING +void HeapBase::FillNoUseMemory(void* address, size_t size) { + if ((m_Attribute >> 1 & 1) != 0) + memset(address, (int)GetFillValue(FillType_NoUse), size); +} + +// Inlined +u32 HeapBase::GetFillValue(FillType type) { + return sFillVals[type]; +} + +// Inlined +HeapBase::HeapList* HeapBase::FindListContainHeap(HeapBase* pHeapBase) { + HeapList* pList {&sRootList}; + HeapBase* pContainHeapBase {FindContainHeap(pList, pHeapBase)}; + + if (pContainHeapBase != nullptr) + pList = &pContainHeapBase->m_ChildList; + + return pList; } } // namespace nn::atk::detail::fnd \ No newline at end of file From 085f505ee2213b528fee8b2e320aba729b168f77 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 10 Aug 2026 18:03:11 -0400 Subject: [PATCH 200/785] atk: Match `StreamSoundFile::FileHeader::HasSeekBlock` Also matches `StreamSoundFile::FileHeader::GetReferenceBy` due to it being inlined --- include/nn/atk/atk_StreamSoundFile.h | 110 +++++++++++------- .../atk/detail/strm/atk_StreamSoundFile.cpp | 18 +++ 2 files changed, 83 insertions(+), 45 deletions(-) diff --git a/include/nn/atk/atk_StreamSoundFile.h b/include/nn/atk/atk_StreamSoundFile.h index 3236c658..988ac24d 100644 --- a/include/nn/atk/atk_StreamSoundFile.h +++ b/include/nn/atk/atk_StreamSoundFile.h @@ -3,17 +3,19 @@ #include namespace nn::atk::detail { -class StreamSoundFile { -public: - struct FileHeader : BinaryFileHeader { - - constexpr static u8 BlockCount = 4; +struct StreamSoundFile { + struct InfoBlock; - Util::Reference* GetReferenceBy(u16) const; + struct FileHeader : BinaryFileHeader { + private: + static const int BlockCount = 4; + + public: + Util::ReferenceWithSize toBlocks[BlockCount]; bool HasSeekBlock() const; bool HasRegionBlock() const; - + u32 GetInfoBlockSize() const; u32 GetSeekBlockSize() const; u32 GetDataBlockSize() const; @@ -24,10 +26,33 @@ class StreamSoundFile { u32 GetDataBlockOffset() const; u32 GetRegionBlockOffset() const; - Util::ReferenceWithSize toBlocks[BlockCount]; + const InfoBlock* GetInfoBlock() const; + + private: + const Util::ReferenceWithSize* GetReferenceBy(u16 typeId) const; }; static_assert(sizeof(FileHeader) == 0x44); + struct StreamSoundInfo; + struct TrackInfoTable; + struct ChannelInfoTable; + struct InfoBlockBody { + Util::Reference toStreamSoundInfo; + Util::Reference toTrackInfoTable; + Util::Reference toChannelInfoTable; + + const StreamSoundInfo* GetStreamSoundInfo() const; + const TrackInfoTable* GetTrackInfoTable() const; + const ChannelInfoTable* GetChannelInfoTable() const; + }; + static_assert(sizeof(InfoBlockBody) == 0x18); + + struct InfoBlock { + BinaryBlockHeader header; + InfoBlockBody body; + }; + static_assert(sizeof(InfoBlock) == 0x20); + struct StreamSoundInfo { u8 encodeMethod; bool isLoop; @@ -54,6 +79,15 @@ class StreamSoundFile { }; static_assert(sizeof(StreamSoundInfo) == 0x50); + struct TrackInfo; + struct TrackInfoTable { + Util::ReferenceTable table; + + const TrackInfo* GetTrackInfo(u32 index) const; + u32 GetTrackCount() const; + }; + + struct GlobalChannelIndexTable; struct TrackInfo { u8 volume; u8 pan; @@ -61,53 +95,43 @@ class StreamSoundFile { u8 flags; Util::Reference toGlobalChannelIndexTable; - }; - - struct TrackInfoTable { - TrackInfo* GetTrackInfo(u32 index) const; + u32 GetTrackChannelCount() const; + u8 GetGlobalChannelIndex(u32 index) const; - Util::ReferenceTable table; - }; - - struct DspAdpcmChannelInfo { - DspAdpcmParam param; - DspAdpcmLoopParam loopParam; + private: + const GlobalChannelIndexTable& GetGlobalChannelIndexTable() const; }; - static_assert(sizeof(DspAdpcmChannelInfo) == 0x2c); + static_assert(sizeof(TrackInfo) == 0xc); - struct ChannelInfo { - - DspAdpcmChannelInfo* GetDspAdpcmChannelInfo() const; + struct GlobalChannelIndexTable { + Util::Table table; - Util::Reference toDetailChannelInfo; + u32 GetCount() const; + u8 GetGlobalIndex(u32 index) const; }; - static_assert(sizeof(ChannelInfo) == 0x8); + struct ChannelInfo; struct ChannelInfoTable { - - ChannelInfo* GetChannelInfo(u32 index) const; - Util::ReferenceTable table; + + u32 GetChannelCount() const; + const ChannelInfo* GetChannelInfo(u32 index) const; }; - struct InfoBlockBody { - - StreamSoundInfo* GetStreamSoundInfo() const; - TrackInfoTable* GetTrackInfoTable() const; - ChannelInfoTable* GetChannelInfoTable() const; - - Util::Reference toStreamSoundInfo; - Util::Reference toTrackInfoTable; - Util::Reference toChannelInfoTable; + struct DspAdpcmChannelInfo; + struct ChannelInfo { + Util::Reference toDetailChannelInfo; + + const DspAdpcmChannelInfo* GetDspAdpcmChannelInfo() const; }; - static_assert(sizeof(InfoBlockBody) == 0x18); + static_assert(sizeof(ChannelInfo) == 0x8); - struct InfoBlock { - BinaryBlockHeader header; - InfoBlockBody body; + struct DspAdpcmChannelInfo { + DspAdpcmParam param; + DspAdpcmLoopParam loopParam; }; - static_assert(sizeof(InfoBlock) == 0x20); + static_assert(sizeof(DspAdpcmChannelInfo) == 0x2c); struct RegionInfo { u32 start; @@ -124,9 +148,5 @@ class StreamSoundFile { RegionInfo info; }; static_assert(sizeof(RegionBlock) == 0x108); - - struct GlobalChannelIndexTable { - Util::Table table; - }; }; } // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp index e69de29b..6bac07dc 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp @@ -0,0 +1,18 @@ +#include + +#include + +namespace nn::atk::detail { +bool StreamSoundFile::FileHeader::HasSeekBlock() const { + return GetReferenceBy(ElementType_StreamSoundFile_SeekBlock) != nullptr; +} + +const Util::ReferenceWithSize* StreamSoundFile::FileHeader::GetReferenceBy(u16 typeId) const { + for (int i {0}; i < dataBlocks; ++i) { + if (toBlocks[i].typeId == typeId) + return &toBlocks[i]; + } + + return nullptr; +} +} // namespace nn::atk::detail \ No newline at end of file From ccc97230888cf51708273fff44b965b302db8d90 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 10 Aug 2026 18:05:43 -0400 Subject: [PATCH 201/785] atk: Match `StreamSoundFile::FileHeader::HasRegionBlock` --- src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp index 6bac07dc..11b15320 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp @@ -7,6 +7,10 @@ bool StreamSoundFile::FileHeader::HasSeekBlock() const { return GetReferenceBy(ElementType_StreamSoundFile_SeekBlock) != nullptr; } +bool StreamSoundFile::FileHeader::HasRegionBlock() const { + return GetReferenceBy(ElementType_StreamSoundFile_RegionBlock) != nullptr; +} + const Util::ReferenceWithSize* StreamSoundFile::FileHeader::GetReferenceBy(u16 typeId) const { for (int i {0}; i < dataBlocks; ++i) { if (toBlocks[i].typeId == typeId) From 3aa1661c057c1488dd9e4765f3091005775b3cd4 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 10 Aug 2026 18:06:02 -0400 Subject: [PATCH 202/785] atk: Match `StreamSoundFile::FileHeader::GetInfoBlockSize` --- src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp index 11b15320..ce926b2e 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp @@ -11,6 +11,10 @@ bool StreamSoundFile::FileHeader::HasRegionBlock() const { return GetReferenceBy(ElementType_StreamSoundFile_RegionBlock) != nullptr; } +u32 StreamSoundFile::FileHeader::GetInfoBlockSize() const { + return GetReferenceBy(ElementType_StreamSoundFile_InfoBlock)->size; +} + const Util::ReferenceWithSize* StreamSoundFile::FileHeader::GetReferenceBy(u16 typeId) const { for (int i {0}; i < dataBlocks; ++i) { if (toBlocks[i].typeId == typeId) From 5c3ebd60e4faf3c6161086b9cc21eec7b212bbee Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 10 Aug 2026 19:14:53 -0400 Subject: [PATCH 203/785] atk: Match `StreamSoundFile::FileHeader::GetSeekBlockSize` --- src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp index ce926b2e..be7b20f4 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp @@ -15,6 +15,10 @@ u32 StreamSoundFile::FileHeader::GetInfoBlockSize() const { return GetReferenceBy(ElementType_StreamSoundFile_InfoBlock)->size; } +u32 StreamSoundFile::FileHeader::GetSeekBlockSize() const { + return GetReferenceBy(ElementType_StreamSoundFile_SeekBlock)->size; +} + const Util::ReferenceWithSize* StreamSoundFile::FileHeader::GetReferenceBy(u16 typeId) const { for (int i {0}; i < dataBlocks; ++i) { if (toBlocks[i].typeId == typeId) From 01ac4cf2f2f9a7422f768721577ac0e7310c544b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 10 Aug 2026 19:15:31 -0400 Subject: [PATCH 204/785] atk: Match `StreamSoundFile::FileHeader::GetDataBlockSize` --- src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp index be7b20f4..d7bda861 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp @@ -19,6 +19,10 @@ u32 StreamSoundFile::FileHeader::GetSeekBlockSize() const { return GetReferenceBy(ElementType_StreamSoundFile_SeekBlock)->size; } +u32 StreamSoundFile::FileHeader::GetDataBlockSize() const { + return GetReferenceBy(ElementType_StreamSoundFile_DataBlock)->size; +} + const Util::ReferenceWithSize* StreamSoundFile::FileHeader::GetReferenceBy(u16 typeId) const { for (int i {0}; i < dataBlocks; ++i) { if (toBlocks[i].typeId == typeId) From 972dcf1d47259a6cd991d3d029f0e825c4a326ff Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 10 Aug 2026 19:19:29 -0400 Subject: [PATCH 205/785] atk: Match `StreamSoundFile::FileHeader::GetRegionBlockSize` --- src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp index d7bda861..f9833715 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp @@ -23,6 +23,10 @@ u32 StreamSoundFile::FileHeader::GetDataBlockSize() const { return GetReferenceBy(ElementType_StreamSoundFile_DataBlock)->size; } +u32 StreamSoundFile::FileHeader::GetRegionBlockSize() const { + return GetReferenceBy(ElementType_StreamSoundFile_RegionBlock)->size; +} + const Util::ReferenceWithSize* StreamSoundFile::FileHeader::GetReferenceBy(u16 typeId) const { for (int i {0}; i < dataBlocks; ++i) { if (toBlocks[i].typeId == typeId) From 197bd7087bdc83f8544bd74c629590b4e85f76be Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 10 Aug 2026 19:26:30 -0400 Subject: [PATCH 206/785] atk: Match `StreamSoundFile::FileHeader::GetInfoBlockOffset` --- src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp index f9833715..d2e01b93 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp @@ -27,10 +27,15 @@ u32 StreamSoundFile::FileHeader::GetRegionBlockSize() const { return GetReferenceBy(ElementType_StreamSoundFile_RegionBlock)->size; } +u32 StreamSoundFile::FileHeader::GetInfoBlockOffset() const { + return GetReferenceBy(ElementType_StreamSoundFile_InfoBlock)->offset; +} + const Util::ReferenceWithSize* StreamSoundFile::FileHeader::GetReferenceBy(u16 typeId) const { for (int i {0}; i < dataBlocks; ++i) { - if (toBlocks[i].typeId == typeId) - return &toBlocks[i]; + const Util::ReferenceWithSize* p {&toBlocks[i]}; + if (p->typeId == typeId) + return p; } return nullptr; From 3c9fc6192048bcab20060b63eb1ea6004680e61d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 10 Aug 2026 19:26:57 -0400 Subject: [PATCH 207/785] atk: Match `StreamSoundFile::FileHeader::GetSeekBlockOffset` --- src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp index d2e01b93..e8080093 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp @@ -31,6 +31,10 @@ u32 StreamSoundFile::FileHeader::GetInfoBlockOffset() const { return GetReferenceBy(ElementType_StreamSoundFile_InfoBlock)->offset; } +u32 StreamSoundFile::FileHeader::GetSeekBlockOffset() const { + return GetReferenceBy(ElementType_StreamSoundFile_SeekBlock)->offset; +} + const Util::ReferenceWithSize* StreamSoundFile::FileHeader::GetReferenceBy(u16 typeId) const { for (int i {0}; i < dataBlocks; ++i) { const Util::ReferenceWithSize* p {&toBlocks[i]}; From 1ed9ae689e7baf53c21fd8052ffa32b00c648a57 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 10 Aug 2026 19:27:20 -0400 Subject: [PATCH 208/785] atk: Match `StreamSoundFile::FileHeader::GetDataBlockOffset` --- src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp index e8080093..96d8bc10 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp @@ -35,6 +35,10 @@ u32 StreamSoundFile::FileHeader::GetSeekBlockOffset() const { return GetReferenceBy(ElementType_StreamSoundFile_SeekBlock)->offset; } +u32 StreamSoundFile::FileHeader::GetDataBlockOffset() const { + return GetReferenceBy(ElementType_StreamSoundFile_DataBlock)->offset; +} + const Util::ReferenceWithSize* StreamSoundFile::FileHeader::GetReferenceBy(u16 typeId) const { for (int i {0}; i < dataBlocks; ++i) { const Util::ReferenceWithSize* p {&toBlocks[i]}; From ba0ddb2e3d207ffbf5a29f36f0d3d8bdb6843146 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 10 Aug 2026 19:27:56 -0400 Subject: [PATCH 209/785] atk: Match `StreamSoundFile::FileHeader::GetRegionBlockOffset` --- src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp index 96d8bc10..32007f3e 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp @@ -39,6 +39,10 @@ u32 StreamSoundFile::FileHeader::GetDataBlockOffset() const { return GetReferenceBy(ElementType_StreamSoundFile_DataBlock)->offset; } +u32 StreamSoundFile::FileHeader::GetRegionBlockOffset() const { + return GetReferenceBy(ElementType_StreamSoundFile_RegionBlock)->offset; +} + const Util::ReferenceWithSize* StreamSoundFile::FileHeader::GetReferenceBy(u16 typeId) const { for (int i {0}; i < dataBlocks; ++i) { const Util::ReferenceWithSize* p {&toBlocks[i]}; From 4155fdd7525d539cc09a6e94279765291f28e998 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 10 Aug 2026 19:45:10 -0400 Subject: [PATCH 210/785] atk: Match `StreamSoundFile::InfoBlockBody::GetStreamSoundInfo` --- src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp index 32007f3e..dec54451 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp @@ -1,6 +1,7 @@ #include #include +#include "nn/util/util_BytePtr.h" namespace nn::atk::detail { bool StreamSoundFile::FileHeader::HasSeekBlock() const { @@ -52,4 +53,11 @@ const Util::ReferenceWithSize* StreamSoundFile::FileHeader::GetReferenceBy(u16 t return nullptr; } + +const StreamSoundFile::StreamSoundInfo* StreamSoundFile::InfoBlockBody::GetStreamSoundInfo() const { + if (toStreamSoundInfo.typeId == ElementType_StreamSoundFile_StreamSoundInfo) + return util::ConstBytePtr(this).Advance(toStreamSoundInfo.offset).Get(); + + return nullptr; +} } // namespace nn::atk::detail \ No newline at end of file From 68cb4957133c696059db9f00077344777b5edd31 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 10 Aug 2026 19:46:40 -0400 Subject: [PATCH 211/785] atk: Match `StreamSoundFile::InfoBlockBody::GetTrackInfoTable` --- src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp index dec54451..32a53b0c 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp @@ -60,4 +60,11 @@ const StreamSoundFile::StreamSoundInfo* StreamSoundFile::InfoBlockBody::GetStrea return nullptr; } + +const StreamSoundFile::TrackInfoTable* StreamSoundFile::InfoBlockBody::GetTrackInfoTable() const { + if (toTrackInfoTable.typeId == ElementType_Table_ReferenceTable) + return util::ConstBytePtr(this).Advance(toTrackInfoTable.offset).Get(); + + return nullptr; +} } // namespace nn::atk::detail \ No newline at end of file From 0f6164b476393560e4ebdc6978386ade316efc89 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 10 Aug 2026 19:47:50 -0400 Subject: [PATCH 212/785] atk: Match `StreamSoundFile::InfoBlockBody::GetChannelInfoTable` --- src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp index 32a53b0c..c3eed987 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp @@ -67,4 +67,11 @@ const StreamSoundFile::TrackInfoTable* StreamSoundFile::InfoBlockBody::GetTrackI return nullptr; } + +const StreamSoundFile::ChannelInfoTable* StreamSoundFile::InfoBlockBody::GetChannelInfoTable() const { + if (toChannelInfoTable.typeId == ElementType_Table_ReferenceTable) + return util::ConstBytePtr(this).Advance(toChannelInfoTable.offset).Get(); + + return nullptr; +} } // namespace nn::atk::detail \ No newline at end of file From 2d7608433b38475f0cc290699be4ab399df56cb5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 10 Aug 2026 20:06:03 -0400 Subject: [PATCH 213/785] atk: Match `StreamSoundFile::TrackInfoTable::GetTrackInfo` Also added inline functions for `Util::ReferenceTable` --- include/nn/atk/atk_Util.h | 26 ++++++++++++++++--- .../atk/detail/strm/atk_StreamSoundFile.cpp | 4 +++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index 4e6e97bf..a196b250 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -70,13 +71,32 @@ struct Util { BlockReferenceTable blockReferenceTable; }; - template + template struct Table { CountType count; - T item[1]; + ItemType item[1]; }; - struct ReferenceTable : Table {}; + struct ReferenceTable : Table { + + const void* GetReferedItem(u32 index) const { + if (count > index) + return util::ConstBytePtr(this).Advance(item[index].offset).Get(); + + return nullptr; + } + + const void* GetReferedItem(u32 index, u16 typeId) const { + if (count > index && item[index].typeId == typeId) + return util::ConstBytePtr(this).Advance(item[index].offset).Get(); + + return nullptr; + } + + const void* FindReferedItemBy(u16 typeId) const; + + }; + struct ReferenceWithSizeTable : Table {}; struct BitFlag { diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp index c3eed987..2815c37e 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp @@ -74,4 +74,8 @@ const StreamSoundFile::ChannelInfoTable* StreamSoundFile::InfoBlockBody::GetChan return nullptr; } + +const StreamSoundFile::TrackInfo* StreamSoundFile::TrackInfoTable::GetTrackInfo(u32 index) const { + return static_cast(table.GetReferedItem(index, ElementType_StreamSoundFile_TrackInfo)); +} } // namespace nn::atk::detail \ No newline at end of file From b2d52e7a85068023029b3bf97dff577b9da7c5ca Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 10 Aug 2026 20:17:39 -0400 Subject: [PATCH 214/785] atk: Match `StreamSoundFile::ChannelInfoTable::GetChannelInfo` --- include/nn/atk/atk_StreamSoundFile.h | 2 +- include/nn/atk/atk_Util.h | 16 ++++++++++++++-- .../atk/detail/strm/atk_StreamSoundFile.cpp | 13 ++++++++++++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/include/nn/atk/atk_StreamSoundFile.h b/include/nn/atk/atk_StreamSoundFile.h index 988ac24d..0be1d5af 100644 --- a/include/nn/atk/atk_StreamSoundFile.h +++ b/include/nn/atk/atk_StreamSoundFile.h @@ -83,8 +83,8 @@ struct StreamSoundFile { struct TrackInfoTable { Util::ReferenceTable table; - const TrackInfo* GetTrackInfo(u32 index) const; u32 GetTrackCount() const; + const TrackInfo* GetTrackInfo(u32 index) const; }; struct GlobalChannelIndexTable; diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index a196b250..c59b7ea6 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -96,8 +96,20 @@ struct Util { const void* FindReferedItemBy(u16 typeId) const; }; - - struct ReferenceWithSizeTable : Table {}; + + struct ReferenceWithSizeTable : Table { + + const void* GetReferedItem(u32 index) const { + if (count > index) + return util::ConstBytePtr(this).Advance(item[index].offset).Get(); + + return nullptr; + } + + const void* GetReferedItemBy(u16 typeId) const; + u32 GetReferedItemSize(u32 index) const; + + }; struct BitFlag { constexpr static u32 BitNumberMax = 31; diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp index 2815c37e..e2aa5f10 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp @@ -1,7 +1,6 @@ #include #include -#include "nn/util/util_BytePtr.h" namespace nn::atk::detail { bool StreamSoundFile::FileHeader::HasSeekBlock() const { @@ -75,7 +74,19 @@ const StreamSoundFile::ChannelInfoTable* StreamSoundFile::InfoBlockBody::GetChan return nullptr; } +u32 StreamSoundFile::TrackInfoTable::GetTrackCount() const { + return table.count; +} + const StreamSoundFile::TrackInfo* StreamSoundFile::TrackInfoTable::GetTrackInfo(u32 index) const { return static_cast(table.GetReferedItem(index, ElementType_StreamSoundFile_TrackInfo)); } + +u32 StreamSoundFile::ChannelInfoTable::GetChannelCount() const { + return table.count; +} + +const StreamSoundFile::ChannelInfo* StreamSoundFile::ChannelInfoTable::GetChannelInfo(u32 index) const { + return static_cast(table.GetReferedItem(index, ElementType_StreamSoundFile_ChannelInfo)); +} } // namespace nn::atk::detail \ No newline at end of file From 19bcbd5a6b905954e766514d3172e627ce9f33b7 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 10 Aug 2026 20:34:04 -0400 Subject: [PATCH 215/785] atk: Match `StreamSoundFile::ChannelInfo::GetDspAdpcmChannelInfo` This matches all non-inlined functions in `StreamSoundFile` --- include/nn/atk/atk_Global.h | 8 ++++---- include/nn/atk/atk_Util.h | 15 +++++++++------ .../atk/detail/strm/atk_StreamSoundFile.cpp | 17 ++++++++++++----- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h index 8af2c404..081a712e 100644 --- a/include/nn/atk/atk_Global.h +++ b/include/nn/atk/atk_Global.h @@ -420,10 +420,10 @@ struct WaveInfo { }; static_assert(sizeof(WaveInfo) == 0xa0); -static const OutputMix DefaultTvMix{1.0, 1.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; +static const OutputMix DefaultTvMix{{1.0, 1.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}; } // namespace nn::atk::detail using SoundFrameUserCallback = void(*)(std::uintptr_t); diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index c59b7ea6..67cef5d2 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -48,7 +48,10 @@ struct Util { }; struct Reference { - constexpr static s32 InvalidOffset = -1; + static const int InvalidOffset = -1; + + bool IsValidTypeId(u16 validId) const { return typeId == validId; } + bool IsValidOffset() const { return offset != InvalidOffset; } // Id from ElementTypes enum u16 typeId; @@ -57,7 +60,7 @@ struct Util { }; static_assert(sizeof(Reference) == 0x8); - struct ReferenceWithSize : Reference { + struct ReferenceWithSize : public Reference { u32 size; }; static_assert(sizeof(ReferenceWithSize) == 0xc); @@ -81,14 +84,14 @@ struct Util { const void* GetReferedItem(u32 index) const { if (count > index) - return util::ConstBytePtr(this).Advance(item[index].offset).Get(); + return util::ConstBytePtr(this).Advance(item[index].offset).Get(); return nullptr; } const void* GetReferedItem(u32 index, u16 typeId) const { if (count > index && item[index].typeId == typeId) - return util::ConstBytePtr(this).Advance(item[index].offset).Get(); + return util::ConstBytePtr(this).Advance(item[index].offset).Get(); return nullptr; } @@ -101,14 +104,14 @@ struct Util { const void* GetReferedItem(u32 index) const { if (count > index) - return util::ConstBytePtr(this).Advance(item[index].offset).Get(); + return util::ConstBytePtr(this).Advance(item[index].offset).Get(); return nullptr; } const void* GetReferedItemBy(u16 typeId) const; u32 GetReferedItemSize(u32 index) const; - + }; struct BitFlag { diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp index e2aa5f10..269505c4 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp @@ -54,21 +54,21 @@ const Util::ReferenceWithSize* StreamSoundFile::FileHeader::GetReferenceBy(u16 t } const StreamSoundFile::StreamSoundInfo* StreamSoundFile::InfoBlockBody::GetStreamSoundInfo() const { - if (toStreamSoundInfo.typeId == ElementType_StreamSoundFile_StreamSoundInfo) + if (toStreamSoundInfo.IsValidTypeId(ElementType_StreamSoundFile_StreamSoundInfo)) return util::ConstBytePtr(this).Advance(toStreamSoundInfo.offset).Get(); return nullptr; } const StreamSoundFile::TrackInfoTable* StreamSoundFile::InfoBlockBody::GetTrackInfoTable() const { - if (toTrackInfoTable.typeId == ElementType_Table_ReferenceTable) + if (toTrackInfoTable.IsValidTypeId(ElementType_Table_ReferenceTable)) return util::ConstBytePtr(this).Advance(toTrackInfoTable.offset).Get(); return nullptr; } const StreamSoundFile::ChannelInfoTable* StreamSoundFile::InfoBlockBody::GetChannelInfoTable() const { - if (toChannelInfoTable.typeId == ElementType_Table_ReferenceTable) + if (toChannelInfoTable.IsValidTypeId(ElementType_Table_ReferenceTable)) return util::ConstBytePtr(this).Advance(toChannelInfoTable.offset).Get(); return nullptr; @@ -79,7 +79,7 @@ u32 StreamSoundFile::TrackInfoTable::GetTrackCount() const { } const StreamSoundFile::TrackInfo* StreamSoundFile::TrackInfoTable::GetTrackInfo(u32 index) const { - return static_cast(table.GetReferedItem(index, ElementType_StreamSoundFile_TrackInfo)); + return static_cast(table.GetReferedItem(index, ElementType_StreamSoundFile_TrackInfo)); } u32 StreamSoundFile::ChannelInfoTable::GetChannelCount() const { @@ -87,6 +87,13 @@ u32 StreamSoundFile::ChannelInfoTable::GetChannelCount() const { } const StreamSoundFile::ChannelInfo* StreamSoundFile::ChannelInfoTable::GetChannelInfo(u32 index) const { - return static_cast(table.GetReferedItem(index, ElementType_StreamSoundFile_ChannelInfo)); + return static_cast(table.GetReferedItem(index, ElementType_StreamSoundFile_ChannelInfo)); +} + +const StreamSoundFile::DspAdpcmChannelInfo* StreamSoundFile::ChannelInfo::GetDspAdpcmChannelInfo() const { + if (toDetailChannelInfo.IsValidTypeId(ElementType_Codec_DspAdpcmInfo)) + return util::ConstBytePtr(this).Advance(toDetailChannelInfo.offset).Get(); + + return nullptr; } } // namespace nn::atk::detail \ No newline at end of file From 2e7185e9aefdc8e25c1f718a12831041dbee6523 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 12 Aug 2026 13:25:32 -0400 Subject: [PATCH 216/785] atk: Match `StreamSoundFileLoader::LoadFileHeader` --- include/nn/atk/atk_StreamSoundFileLoader.h | 34 ++++++++++++++----- include/nn/atk/atk_StreamSoundFileReader.h | 22 ++++++++++++ include/nn/atk/fnd/io/atkfnd_FileStream.h | 2 +- .../atk/detail/strm/atk_StreamSoundLoader.cpp | 30 ++++++++++++++++ 4 files changed, 79 insertions(+), 9 deletions(-) diff --git a/include/nn/atk/atk_StreamSoundFileLoader.h b/include/nn/atk/atk_StreamSoundFileLoader.h index 1513ac0e..fb1f5082 100644 --- a/include/nn/atk/atk_StreamSoundFileLoader.h +++ b/include/nn/atk/atk_StreamSoundFileLoader.h @@ -5,21 +5,39 @@ #include namespace nn::atk::detail { -class StreamSoundFileLoader : IRegionInfoReadable { +class StreamSoundFileLoader : public IRegionInfoReadable { public: - StreamSoundFileLoader(); - ~StreamSoundFileLoader() override; + StreamSoundFileLoader() = default; + explicit StreamSoundFileLoader(fnd::FileStream* stream) { + Initialize(stream); + } + + void Initialize(fnd::FileStream* stream) { + m_pStream = stream; + m_SeekBlockOffset = 0; + m_RegionDataOffset = 0; + m_RegionInfoBytes = 0; + } + + void Finalize() { + m_pStream = nullptr; + m_SeekBlockOffset = 0; + m_RegionDataOffset = 0; + m_RegionInfoBytes = 0; + } bool LoadFileHeader(StreamSoundFileReader* reader, void* buffer, u64 size); - bool ReadSeekBlockData(u16* yn1, u16 yn2, s32 blockIndex, s32 channelCount); + bool ReadSeekBlockData(u16* yn1, u16* yn2, int blockIndex, int channelCount); bool ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo, u32 regionIndex) const override; + + ~StreamSoundFileLoader() override; private: - fnd::FileStream* m_pStream; - u32 m_SeekBlockOffset; - u32 m_RegionDataOffset; - u16 m_RegionInfoBytes; + fnd::FileStream* m_pStream {}; + u32 m_SeekBlockOffset {0}; + u32 m_RegionDataOffset {0}; + u16 m_RegionInfoBytes {0}; }; static_assert(sizeof(StreamSoundFileLoader) == 0x20); } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/atk_StreamSoundFileReader.h b/include/nn/atk/atk_StreamSoundFileReader.h index 93284559..7d36bc6c 100644 --- a/include/nn/atk/atk_StreamSoundFileReader.h +++ b/include/nn/atk/atk_StreamSoundFileReader.h @@ -26,6 +26,28 @@ class StreamSoundFileReader { bool ReadDspAdpcmChannelInfo(DspAdpcmParam* pParam, DspAdpcmLoopParam* pLoopParam, s32 channelIndex) const; + u32 GetSeekBlockOffset() const { + if (m_pHeader != nullptr && m_pHeader->HasSeekBlock()) + return m_pHeader->GetSeekBlockOffset(); + + return 0; + } + + u32 GetRegionDataOffset() const { + u32 result {0}; + if (m_pHeader != nullptr && m_pHeader->HasRegionBlock()) { + result = m_pHeader->GetRegionBlockOffset() + + m_pInfoBlockBody->GetStreamSoundInfo()->regionDataOffset.offset + + sizeof(BinaryBlockHeader); + } + + return result; + } + + u32 GetRegionInfoBytes() const { + return m_pInfoBlockBody->GetStreamSoundInfo()->regionInfoBytes; + } + private: StreamSoundFile::FileHeader* m_pHeader; StreamSoundFile::InfoBlockBody* m_pInfoBlockBody; diff --git a/include/nn/atk/fnd/io/atkfnd_FileStream.h b/include/nn/atk/fnd/io/atkfnd_FileStream.h index 967658ae..3dd14052 100644 --- a/include/nn/atk/fnd/io/atkfnd_FileStream.h +++ b/include/nn/atk/fnd/io/atkfnd_FileStream.h @@ -4,7 +4,7 @@ #include namespace nn::atk::detail::fnd { -class FileStream : Stream { +class FileStream : public Stream { public: enum AccessMode { AccessMode_None, diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp index e69de29b..6b3e4b63 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp @@ -0,0 +1,30 @@ +#include + +namespace nn::atk::detail { +bool StreamSoundFileLoader::LoadFileHeader(StreamSoundFileReader* reader, void* buffer, u64 size) { + const size_t HeaderSize = 0x60; + const size_t AlignSize = 0x40; + char buffer2[HeaderSize + AlignSize]; + + m_pStream->Seek(0, fnd::FileStream::SeekOrigin_Begin); + size_t readSize {m_pStream->Read(util::BytePtr(buffer2).AlignUp(AlignSize).Get(), HeaderSize, nullptr)}; + auto* header {util::BytePtr(buffer2).AlignUp(AlignSize).Get()}; + + if (readSize == HeaderSize && StreamSoundFileReader::IsValidFileHeader(header)) { + u32 loadSize {header->GetInfoBlockOffset() + header->GetInfoBlockSize()}; + if (loadSize <= size) { + m_pStream->Seek(0, fnd::FileStream::SeekOrigin_Begin); + readSize = m_pStream->Read(buffer, loadSize, nullptr); + if (readSize == (int)loadSize) { + reader->Initialize(buffer); + m_SeekBlockOffset = reader->GetSeekBlockOffset(); + m_RegionDataOffset = reader->GetRegionDataOffset(); + m_RegionInfoBytes = reader->GetRegionInfoBytes(); + return true; + } + } + } + + return false; +} +} // namespace nn::atk::detail \ No newline at end of file From 0fe7ba46ec4aa25a5b1d3ab8f658b7692f8c888a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 12 Aug 2026 15:52:18 -0400 Subject: [PATCH 217/785] atk: Match `StreamSoundFileLoader::ReadSeekBlockData` --- .../atk/detail/strm/atk_StreamSoundLoader.cpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp index 6b3e4b63..115e5bdb 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp @@ -27,4 +27,28 @@ bool StreamSoundFileLoader::LoadFileHeader(StreamSoundFileReader* reader, void* return false; } + +bool StreamSoundFileLoader::ReadSeekBlockData(u16* yn1, u16* yn2, int blockIndex, int channelCount) { + const size_t SeekInfoMaxSize = channelCount * 4L; + size_t readDataSize = SeekInfoMaxSize; + size_t readOffset = m_SeekBlockOffset + blockIndex * readDataSize + 8; + + m_pStream->Seek(readOffset, fnd::FileStream::SeekOrigin_Begin); + if (readDataSize <= 64) { + const int Align = 64; + u16 bufferBase[128]; + u16* buffer = util::BytePtr(bufferBase).AlignUp(Align).Get(); + size_t readSize {m_pStream->Read(buffer, readDataSize, nullptr)}; + + if (readSize == readDataSize) { + for (int i {0}; i < channelCount; ++i) { + yn1[i] = buffer[i * sizeof(u16)]; + yn2[i] = buffer[i * sizeof(u16) + 1]; + } + return true; + } + } + + return false; +} } // namespace nn::atk::detail \ No newline at end of file From f8ec43cb01d87967f7e09c5fd1fbadd262f8f695 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 12 Aug 2026 16:58:54 -0400 Subject: [PATCH 218/785] atk: Match `StreamSoundFileLoader::ReadRegionInfo` This matches all non-inlined functions in `StreamSoundFileLoader` --- .../atk/detail/strm/atk_StreamSoundLoader.cpp | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp index 115e5bdb..7c057d6b 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp @@ -2,8 +2,8 @@ namespace nn::atk::detail { bool StreamSoundFileLoader::LoadFileHeader(StreamSoundFileReader* reader, void* buffer, u64 size) { - const size_t HeaderSize = 0x60; - const size_t AlignSize = 0x40; + const size_t HeaderSize {0x60}; + const size_t AlignSize {64}; char buffer2[HeaderSize + AlignSize]; m_pStream->Seek(0, fnd::FileStream::SeekOrigin_Begin); @@ -29,15 +29,15 @@ bool StreamSoundFileLoader::LoadFileHeader(StreamSoundFileReader* reader, void* } bool StreamSoundFileLoader::ReadSeekBlockData(u16* yn1, u16* yn2, int blockIndex, int channelCount) { - const size_t SeekInfoMaxSize = channelCount * 4L; - size_t readDataSize = SeekInfoMaxSize; - size_t readOffset = m_SeekBlockOffset + blockIndex * readDataSize + 8; + const size_t SeekInfoMaxSize {channelCount * sizeof(u16) * 2}; + size_t readDataSize {SeekInfoMaxSize}; + size_t readOffset {m_SeekBlockOffset + sizeof(BinaryBlockHeader) + blockIndex * readDataSize}; m_pStream->Seek(readOffset, fnd::FileStream::SeekOrigin_Begin); if (readDataSize <= 64) { - const int Align = 64; + const int Align {64}; u16 bufferBase[128]; - u16* buffer = util::BytePtr(bufferBase).AlignUp(Align).Get(); + u16* buffer {util::BytePtr(bufferBase).AlignUp(Align).Get()}; size_t readSize {m_pStream->Read(buffer, readDataSize, nullptr)}; if (readSize == readDataSize) { @@ -51,4 +51,25 @@ bool StreamSoundFileLoader::ReadSeekBlockData(u16* yn1, u16* yn2, int blockIndex return false; } + +bool StreamSoundFileLoader::ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo, u32 regionIndex) const { + if (m_RegionDataOffset != 0 && m_RegionInfoBytes != 0) { + position_t offset {m_RegionDataOffset + static_cast(m_RegionInfoBytes) * regionIndex}; + m_pStream->Seek(offset, fnd::FileStream::SeekOrigin_Begin); + + const int Align {64}; + const size_t ReadSize {sizeof(StreamSoundFile::RegionInfo)}; + u8 bufferBase[ReadSize + Align]; + u8* buffer {util::BytePtr(bufferBase).AlignUp(Align).Get()}; + + size_t readSize {m_pStream->Read(buffer, ReadSize, nullptr)}; + if (readSize == ReadSize) { + *pInfo = *reinterpret_cast(buffer); + return true; + } + return false; + } + + return false; +} } // namespace nn::atk::detail \ No newline at end of file From a30c2734e417d7d0fc8b7811d9f341695e61cea2 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 12 Aug 2026 20:45:17 -0400 Subject: [PATCH 219/785] atk: Match `StreamSoundFileReader` constructor --- include/nn/atk/atk_StreamSoundFileReader.h | 24 +++++++++++-------- .../detail/strm/atk_StreamSoundFileReader.cpp | 5 ++++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/include/nn/atk/atk_StreamSoundFileReader.h b/include/nn/atk/atk_StreamSoundFileReader.h index 7d36bc6c..b19ddca1 100644 --- a/include/nn/atk/atk_StreamSoundFileReader.h +++ b/include/nn/atk/atk_StreamSoundFileReader.h @@ -8,23 +8,23 @@ class StreamSoundFileReader { StreamSoundFileReader(); void Initialize(const void* streamSoundFile); - - static bool IsValidFileHeader(const void* streamSoundFile); - void Finalize(); + bool IsAvailable() const; bool IsTrackInfoAvailable() const; bool IsOriginalLoopAvailable() const; - - static bool IsOriginalLoopAvailableImpl(const StreamSoundFile::FileHeader* header); - bool IsCrc32CheckAvailable() const; bool IsRegionIndexCheckAvailable() const; + static bool IsValidFileHeader(const void* streamSoundFile); + bool ReadStreamSoundInfo(StreamSoundFile::StreamSoundInfo* strmInfo) const; - bool ReadStreamTrackInfo(StreamSoundFile::TrackInfo* pTrackInfo, s32 trackIndex) const; + bool ReadStreamTrackInfo(StreamSoundFile::TrackInfo* pTrackInfo, int trackIndex) const; bool ReadDspAdpcmChannelInfo(DspAdpcmParam* pParam, DspAdpcmLoopParam* pLoopParam, - s32 channelIndex) const; + int channelIndex) const; + + u32 GetChannelCount() const; + u32 GetTrackCount() const; u32 GetSeekBlockOffset() const { if (m_pHeader != nullptr && m_pHeader->HasSeekBlock()) @@ -33,6 +33,8 @@ class StreamSoundFileReader { return 0; } + u32 GetSampleDataOffset() const; + u32 GetRegionDataOffset() const { u32 result {0}; if (m_pHeader != nullptr && m_pHeader->HasRegionBlock()) { @@ -48,9 +50,11 @@ class StreamSoundFileReader { return m_pInfoBlockBody->GetStreamSoundInfo()->regionInfoBytes; } + static bool IsOriginalLoopAvailableImpl(const StreamSoundFile::FileHeader* pHeader); + private: - StreamSoundFile::FileHeader* m_pHeader; - StreamSoundFile::InfoBlockBody* m_pInfoBlockBody; + StreamSoundFile::FileHeader* m_pHeader {}; + StreamSoundFile::InfoBlockBody* m_pInfoBlockBody {}; }; static_assert(sizeof(StreamSoundFileReader) == 0x10); } // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp index e69de29b..b2d4d03f 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp @@ -0,0 +1,5 @@ +#include + +namespace nn::atk::detail { +StreamSoundFileReader::StreamSoundFileReader() = default; +} // namespace nn::atk::detail \ No newline at end of file From ffb2b822705e8b8fc456c38fc9fc41e92d176419 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 13 Aug 2026 15:24:19 -0400 Subject: [PATCH 220/785] atk: Match `StreamSoundFileReader::IsValidFileHeader` --- include/nn/atk/atk_BinaryFileFormat.h | 2 ++ .../detail/strm/atk_StreamSoundFileReader.cpp | 26 +++++++++++++++++++ .../atk/detail/strm/atk_StreamSoundLoader.cpp | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_BinaryFileFormat.h b/include/nn/atk/atk_BinaryFileFormat.h index 2fa628ed..a1c38709 100644 --- a/include/nn/atk/atk_BinaryFileFormat.h +++ b/include/nn/atk/atk_BinaryFileFormat.h @@ -11,6 +11,8 @@ struct BinaryFileHeader { u32 fileSize; u16 dataBlocks; u16 reserved; + + static const u16 ValidByteOrderMark {0xFEFF}; }; static_assert(sizeof(BinaryFileHeader) == 0x14); diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp index b2d4d03f..47df65ab 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp @@ -1,5 +1,31 @@ #include namespace nn::atk::detail { +const u32 SignatureFileStm {0x4d545346}; // FSTM +const u32 SignatureInfoBlockStm {0x4f464e49}; // INFO + +const u32 SupportedFileVersionStm {0x10000}; +const u32 CurrentFileVersionStm {0x60200}; + +const u32 IncludeTrackinfoVersionStm {0x20000}; +const u32 IncludeOriginalloopVersionStm {0x40000}; +const u32 IncludeCrc32CheckVersionStm {0x50000}; +const u32 IncludeRegionIndexCheckVersionStm {0x60100}; + StreamSoundFileReader::StreamSoundFileReader() = default; + +void StreamSoundFileReader::Initialize(const void* streamSoundFile) { + +} + +bool StreamSoundFileReader::IsValidFileHeader(const void* streamSoundFile) { + const BinaryFileHeader& header {*util::ConstBytePtr(streamSoundFile).Get()}; + + bool isSupportedVersion {header.signature == SignatureFileStm + && header.byteOrder == BinaryFileHeader::ValidByteOrderMark + && header.version >= SupportedFileVersionStm + && header.version <= CurrentFileVersionStm}; + + return isSupportedVersion; +} } // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp index 7c057d6b..4f0896a8 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp @@ -10,7 +10,7 @@ bool StreamSoundFileLoader::LoadFileHeader(StreamSoundFileReader* reader, void* size_t readSize {m_pStream->Read(util::BytePtr(buffer2).AlignUp(AlignSize).Get(), HeaderSize, nullptr)}; auto* header {util::BytePtr(buffer2).AlignUp(AlignSize).Get()}; - if (readSize == HeaderSize && StreamSoundFileReader::IsValidFileHeader(header)) { + if (readSize == HeaderSize && reader->IsValidFileHeader(header)) { u32 loadSize {header->GetInfoBlockOffset() + header->GetInfoBlockSize()}; if (loadSize <= size) { m_pStream->Seek(0, fnd::FileStream::SeekOrigin_Begin); From 4f7997cb4a0e8796e996bf95ab2410321ae8488a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 13 Aug 2026 15:34:03 -0400 Subject: [PATCH 221/785] atk: Match `StreamSoundFileReader::Initialize` --- include/nn/atk/atk_StreamSoundFile.h | 4 +++- include/nn/atk/atk_StreamSoundFileReader.h | 4 ++-- .../atk/detail/strm/atk_StreamSoundFileReader.cpp | 7 ++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/nn/atk/atk_StreamSoundFile.h b/include/nn/atk/atk_StreamSoundFile.h index 0be1d5af..2cebadfe 100644 --- a/include/nn/atk/atk_StreamSoundFile.h +++ b/include/nn/atk/atk_StreamSoundFile.h @@ -26,7 +26,9 @@ struct StreamSoundFile { u32 GetDataBlockOffset() const; u32 GetRegionBlockOffset() const; - const InfoBlock* GetInfoBlock() const; + const InfoBlock* GetInfoBlock() const { + return util::ConstBytePtr(this).Advance(GetInfoBlockOffset()).Get(); + }; private: const Util::ReferenceWithSize* GetReferenceBy(u16 typeId) const; diff --git a/include/nn/atk/atk_StreamSoundFileReader.h b/include/nn/atk/atk_StreamSoundFileReader.h index b19ddca1..c2aab41c 100644 --- a/include/nn/atk/atk_StreamSoundFileReader.h +++ b/include/nn/atk/atk_StreamSoundFileReader.h @@ -53,8 +53,8 @@ class StreamSoundFileReader { static bool IsOriginalLoopAvailableImpl(const StreamSoundFile::FileHeader* pHeader); private: - StreamSoundFile::FileHeader* m_pHeader {}; - StreamSoundFile::InfoBlockBody* m_pInfoBlockBody {}; + const StreamSoundFile::FileHeader* m_pHeader {}; + const StreamSoundFile::InfoBlockBody* m_pInfoBlockBody {}; }; static_assert(sizeof(StreamSoundFileReader) == 0x10); } // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp index 47df65ab..d424a2c2 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp @@ -15,7 +15,12 @@ const u32 IncludeRegionIndexCheckVersionStm {0x60100}; StreamSoundFileReader::StreamSoundFileReader() = default; void StreamSoundFileReader::Initialize(const void* streamSoundFile) { - + if (IsValidFileHeader(streamSoundFile)) { + m_pHeader = util::ConstBytePtr(streamSoundFile).Get(); + const StreamSoundFile::InfoBlock* infoBlock {m_pHeader->GetInfoBlock()}; + if (infoBlock->header.kind == SignatureInfoBlockStm) + m_pInfoBlockBody = &infoBlock->body; + } } bool StreamSoundFileReader::IsValidFileHeader(const void* streamSoundFile) { From f305fc0255bfb583734ce7831260ebe003a11bc1 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 13 Aug 2026 15:35:11 -0400 Subject: [PATCH 222/785] atk: Move `StreamSoundFileLoader` to the correct cpp file --- .../detail/strm/atk_StreamSoundFileLoader.cpp | 75 +++++++++++++++++++ .../atk/detail/strm/atk_StreamSoundLoader.cpp | 75 ------------------- 2 files changed, 75 insertions(+), 75 deletions(-) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileLoader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileLoader.cpp index e69de29b..4f0896a8 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileLoader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileLoader.cpp @@ -0,0 +1,75 @@ +#include + +namespace nn::atk::detail { +bool StreamSoundFileLoader::LoadFileHeader(StreamSoundFileReader* reader, void* buffer, u64 size) { + const size_t HeaderSize {0x60}; + const size_t AlignSize {64}; + char buffer2[HeaderSize + AlignSize]; + + m_pStream->Seek(0, fnd::FileStream::SeekOrigin_Begin); + size_t readSize {m_pStream->Read(util::BytePtr(buffer2).AlignUp(AlignSize).Get(), HeaderSize, nullptr)}; + auto* header {util::BytePtr(buffer2).AlignUp(AlignSize).Get()}; + + if (readSize == HeaderSize && reader->IsValidFileHeader(header)) { + u32 loadSize {header->GetInfoBlockOffset() + header->GetInfoBlockSize()}; + if (loadSize <= size) { + m_pStream->Seek(0, fnd::FileStream::SeekOrigin_Begin); + readSize = m_pStream->Read(buffer, loadSize, nullptr); + if (readSize == (int)loadSize) { + reader->Initialize(buffer); + m_SeekBlockOffset = reader->GetSeekBlockOffset(); + m_RegionDataOffset = reader->GetRegionDataOffset(); + m_RegionInfoBytes = reader->GetRegionInfoBytes(); + return true; + } + } + } + + return false; +} + +bool StreamSoundFileLoader::ReadSeekBlockData(u16* yn1, u16* yn2, int blockIndex, int channelCount) { + const size_t SeekInfoMaxSize {channelCount * sizeof(u16) * 2}; + size_t readDataSize {SeekInfoMaxSize}; + size_t readOffset {m_SeekBlockOffset + sizeof(BinaryBlockHeader) + blockIndex * readDataSize}; + + m_pStream->Seek(readOffset, fnd::FileStream::SeekOrigin_Begin); + if (readDataSize <= 64) { + const int Align {64}; + u16 bufferBase[128]; + u16* buffer {util::BytePtr(bufferBase).AlignUp(Align).Get()}; + size_t readSize {m_pStream->Read(buffer, readDataSize, nullptr)}; + + if (readSize == readDataSize) { + for (int i {0}; i < channelCount; ++i) { + yn1[i] = buffer[i * sizeof(u16)]; + yn2[i] = buffer[i * sizeof(u16) + 1]; + } + return true; + } + } + + return false; +} + +bool StreamSoundFileLoader::ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo, u32 regionIndex) const { + if (m_RegionDataOffset != 0 && m_RegionInfoBytes != 0) { + position_t offset {m_RegionDataOffset + static_cast(m_RegionInfoBytes) * regionIndex}; + m_pStream->Seek(offset, fnd::FileStream::SeekOrigin_Begin); + + const int Align {64}; + const size_t ReadSize {sizeof(StreamSoundFile::RegionInfo)}; + u8 bufferBase[ReadSize + Align]; + u8* buffer {util::BytePtr(bufferBase).AlignUp(Align).Get()}; + + size_t readSize {m_pStream->Read(buffer, ReadSize, nullptr)}; + if (readSize == ReadSize) { + *pInfo = *reinterpret_cast(buffer); + return true; + } + return false; + } + + return false; +} +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp index 4f0896a8..e69de29b 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp @@ -1,75 +0,0 @@ -#include - -namespace nn::atk::detail { -bool StreamSoundFileLoader::LoadFileHeader(StreamSoundFileReader* reader, void* buffer, u64 size) { - const size_t HeaderSize {0x60}; - const size_t AlignSize {64}; - char buffer2[HeaderSize + AlignSize]; - - m_pStream->Seek(0, fnd::FileStream::SeekOrigin_Begin); - size_t readSize {m_pStream->Read(util::BytePtr(buffer2).AlignUp(AlignSize).Get(), HeaderSize, nullptr)}; - auto* header {util::BytePtr(buffer2).AlignUp(AlignSize).Get()}; - - if (readSize == HeaderSize && reader->IsValidFileHeader(header)) { - u32 loadSize {header->GetInfoBlockOffset() + header->GetInfoBlockSize()}; - if (loadSize <= size) { - m_pStream->Seek(0, fnd::FileStream::SeekOrigin_Begin); - readSize = m_pStream->Read(buffer, loadSize, nullptr); - if (readSize == (int)loadSize) { - reader->Initialize(buffer); - m_SeekBlockOffset = reader->GetSeekBlockOffset(); - m_RegionDataOffset = reader->GetRegionDataOffset(); - m_RegionInfoBytes = reader->GetRegionInfoBytes(); - return true; - } - } - } - - return false; -} - -bool StreamSoundFileLoader::ReadSeekBlockData(u16* yn1, u16* yn2, int blockIndex, int channelCount) { - const size_t SeekInfoMaxSize {channelCount * sizeof(u16) * 2}; - size_t readDataSize {SeekInfoMaxSize}; - size_t readOffset {m_SeekBlockOffset + sizeof(BinaryBlockHeader) + blockIndex * readDataSize}; - - m_pStream->Seek(readOffset, fnd::FileStream::SeekOrigin_Begin); - if (readDataSize <= 64) { - const int Align {64}; - u16 bufferBase[128]; - u16* buffer {util::BytePtr(bufferBase).AlignUp(Align).Get()}; - size_t readSize {m_pStream->Read(buffer, readDataSize, nullptr)}; - - if (readSize == readDataSize) { - for (int i {0}; i < channelCount; ++i) { - yn1[i] = buffer[i * sizeof(u16)]; - yn2[i] = buffer[i * sizeof(u16) + 1]; - } - return true; - } - } - - return false; -} - -bool StreamSoundFileLoader::ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo, u32 regionIndex) const { - if (m_RegionDataOffset != 0 && m_RegionInfoBytes != 0) { - position_t offset {m_RegionDataOffset + static_cast(m_RegionInfoBytes) * regionIndex}; - m_pStream->Seek(offset, fnd::FileStream::SeekOrigin_Begin); - - const int Align {64}; - const size_t ReadSize {sizeof(StreamSoundFile::RegionInfo)}; - u8 bufferBase[ReadSize + Align]; - u8* buffer {util::BytePtr(bufferBase).AlignUp(Align).Get()}; - - size_t readSize {m_pStream->Read(buffer, ReadSize, nullptr)}; - if (readSize == ReadSize) { - *pInfo = *reinterpret_cast(buffer); - return true; - } - return false; - } - - return false; -} -} // namespace nn::atk::detail \ No newline at end of file From 25ccb3300c65bd34adec2dcbeb817b7f0c5b0b14 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 13 Aug 2026 15:47:50 -0400 Subject: [PATCH 223/785] atk: Match `StreamSoundFileReader::IsTrackInfoAvailable` --- include/nn/atk/atk_StreamSoundFileReader.h | 5 ++++- .../atk/detail/strm/atk_StreamSoundFileReader.cpp | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_StreamSoundFileReader.h b/include/nn/atk/atk_StreamSoundFileReader.h index c2aab41c..ec6713b3 100644 --- a/include/nn/atk/atk_StreamSoundFileReader.h +++ b/include/nn/atk/atk_StreamSoundFileReader.h @@ -10,7 +10,10 @@ class StreamSoundFileReader { void Initialize(const void* streamSoundFile); void Finalize(); - bool IsAvailable() const; + bool IsAvailable() const { + return m_pHeader != nullptr; + } + bool IsTrackInfoAvailable() const; bool IsOriginalLoopAvailable() const; bool IsCrc32CheckAvailable() const; diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp index d424a2c2..2702d2a6 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp @@ -23,6 +23,17 @@ void StreamSoundFileReader::Initialize(const void* streamSoundFile) { } } +void StreamSoundFileReader::Finalize() { + m_pHeader = nullptr; + m_pInfoBlockBody = nullptr; +} + +bool StreamSoundFileReader::IsTrackInfoAvailable() const { + auto& header {*util::ConstBytePtr(m_pHeader).Get()}; + + return header.version <= IncludeTrackinfoVersionStm; +} + bool StreamSoundFileReader::IsValidFileHeader(const void* streamSoundFile) { const BinaryFileHeader& header {*util::ConstBytePtr(streamSoundFile).Get()}; From 105fc6b5990ee24854ea25132d64290a44a9b6b7 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 13 Aug 2026 15:50:56 -0400 Subject: [PATCH 224/785] atk: Match `StreamSoundFileReader::IsCrc32CheckAvailable` --- .../atk/detail/strm/atk_StreamSoundFileReader.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp index 2702d2a6..63045425 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp @@ -34,6 +34,12 @@ bool StreamSoundFileReader::IsTrackInfoAvailable() const { return header.version <= IncludeTrackinfoVersionStm; } +bool StreamSoundFileReader::IsCrc32CheckAvailable() const { + auto& header {*util::ConstBytePtr(m_pHeader).Get()}; + + return header.version >= IncludeCrc32CheckVersionStm; +} + bool StreamSoundFileReader::IsValidFileHeader(const void* streamSoundFile) { const BinaryFileHeader& header {*util::ConstBytePtr(streamSoundFile).Get()}; From fe3ecec93232df07b13304587de47cae5bab6b15 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 13 Aug 2026 15:57:12 -0400 Subject: [PATCH 225/785] atk: Match `StreamSoundFileReader::IsRegionIndexCheckAvailable` --- include/nn/atk/atk_StreamSoundFileReader.h | 12 ++++++++++-- .../atk/detail/strm/atk_StreamSoundFileReader.cpp | 12 ++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_StreamSoundFileReader.h b/include/nn/atk/atk_StreamSoundFileReader.h index ec6713b3..937e3b69 100644 --- a/include/nn/atk/atk_StreamSoundFileReader.h +++ b/include/nn/atk/atk_StreamSoundFileReader.h @@ -13,7 +13,7 @@ class StreamSoundFileReader { bool IsAvailable() const { return m_pHeader != nullptr; } - + bool IsTrackInfoAvailable() const; bool IsOriginalLoopAvailable() const; bool IsCrc32CheckAvailable() const; @@ -36,7 +36,15 @@ class StreamSoundFileReader { return 0; } - u32 GetSampleDataOffset() const; + u32 GetSampleDataOffset() const { + u32 result {0}; + if (m_pHeader != nullptr) + result = m_pHeader->GetDataBlockOffset() + + m_pInfoBlockBody->GetStreamSoundInfo()->sampleDataOffset.offset + + sizeof(BinaryBlockHeader); + + return result; + } u32 GetRegionDataOffset() const { u32 result {0}; diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp index 63045425..97f1d323 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp @@ -34,12 +34,24 @@ bool StreamSoundFileReader::IsTrackInfoAvailable() const { return header.version <= IncludeTrackinfoVersionStm; } +// bool StreamSoundFileReader::IsOriginalLoopAvailable() const { +// auto& header {*util::ConstBytePtr(m_pHeader).Get()}; + +// return header.version >= IncludeOriginalloopVersionStm; +// } + bool StreamSoundFileReader::IsCrc32CheckAvailable() const { auto& header {*util::ConstBytePtr(m_pHeader).Get()}; return header.version >= IncludeCrc32CheckVersionStm; } +bool StreamSoundFileReader::IsRegionIndexCheckAvailable() const { + auto& header {*util::ConstBytePtr(m_pHeader).Get()}; + + return header.version >= IncludeRegionIndexCheckVersionStm; +} + bool StreamSoundFileReader::IsValidFileHeader(const void* streamSoundFile) { const BinaryFileHeader& header {*util::ConstBytePtr(streamSoundFile).Get()}; From cc59324b18e5bcf1d870aa45dfa3f7a7a0b3a417 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 13 Aug 2026 16:08:09 -0400 Subject: [PATCH 226/785] atk: Match `StreamSoundFileReader::ReadStreamSoundInfo` --- .../detail/strm/atk_StreamSoundFileReader.cpp | 51 +++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp index 97f1d323..fe3bb38c 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp @@ -34,11 +34,13 @@ bool StreamSoundFileReader::IsTrackInfoAvailable() const { return header.version <= IncludeTrackinfoVersionStm; } -// bool StreamSoundFileReader::IsOriginalLoopAvailable() const { -// auto& header {*util::ConstBytePtr(m_pHeader).Get()}; +bool StreamSoundFileReader::IsOriginalLoopAvailable() const { + return IsOriginalLoopAvailableImpl(m_pHeader); +} -// return header.version >= IncludeOriginalloopVersionStm; -// } +bool StreamSoundFileReader::IsOriginalLoopAvailableImpl(const StreamSoundFile::FileHeader* pHeader) { + return pHeader->version >= IncludeOriginalloopVersionStm; +} bool StreamSoundFileReader::IsCrc32CheckAvailable() const { auto& header {*util::ConstBytePtr(m_pHeader).Get()}; @@ -62,4 +64,45 @@ bool StreamSoundFileReader::IsValidFileHeader(const void* streamSoundFile) { return isSupportedVersion; } + +bool StreamSoundFileReader::ReadStreamSoundInfo(StreamSoundFile::StreamSoundInfo* strmInfo) const { + auto* info {m_pInfoBlockBody->GetStreamSoundInfo()}; + + strmInfo->encodeMethod = info->encodeMethod; + strmInfo->isLoop = info->isLoop; + strmInfo->channelCount = info->channelCount; + strmInfo->regionCount = info->regionCount; + strmInfo->sampleRate = info->sampleRate; + strmInfo->loopStart = info->loopStart; + strmInfo->frameCount = info->frameCount; + strmInfo->blockCount = info->blockCount; + strmInfo->oneBlockBytes = info->oneBlockBytes; + strmInfo->oneBlockSamples = info->oneBlockSamples; + strmInfo->lastBlockBytes = info->lastBlockBytes; + strmInfo->lastBlockSamples = info->lastBlockSamples; + strmInfo->lastBlockPaddedBytes = info->lastBlockPaddedBytes; + strmInfo->sizeofSeekInfoAtom = info->sizeofSeekInfoAtom; + strmInfo->seekInfoIntervalSamples = info->seekInfoIntervalSamples; + strmInfo->sampleDataOffset = info->sampleDataOffset; + strmInfo->regionInfoBytes = info->regionInfoBytes; + strmInfo->regionDataOffset = info->regionDataOffset; + + if (IsOriginalLoopAvailable()) { + strmInfo->originalLoopStart = info->originalLoopStart; + strmInfo->originalLoopEnd = info->originalLoopEnd; + } + else { + strmInfo->originalLoopStart = info->loopStart; + strmInfo->originalLoopEnd = info->frameCount; + } + + if (IsCrc32CheckAvailable()) { + strmInfo->crc32Value = info->crc32Value; + } + else { + strmInfo->crc32Value = 0; + } + + return true; +} } // namespace nn::atk::detail \ No newline at end of file From 9c94771274300a9c3f398f35d502b0c342c28c81 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 13 Aug 2026 16:22:59 -0400 Subject: [PATCH 227/785] atk: Match `StreamSoundFileReader::ReadDspAdpcmChannelInfo` --- .../atk/detail/strm/atk_StreamSoundFileReader.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp index fe3bb38c..894819ea 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp @@ -105,4 +105,16 @@ bool StreamSoundFileReader::ReadStreamSoundInfo(StreamSoundFile::StreamSoundInfo return true; } + +bool StreamSoundFileReader::ReadDspAdpcmChannelInfo(DspAdpcmParam* pParam, DspAdpcmLoopParam* pLoopParam, + int channelIndex) const { + auto* src {m_pInfoBlockBody->GetChannelInfoTable()->GetChannelInfo(channelIndex)->GetDspAdpcmChannelInfo()}; + if (src != nullptr) { + *pParam = src->param; + *pLoopParam = src->loopParam; + return true; + } + + return false; +} } // namespace nn::atk::detail \ No newline at end of file From 48ca404752fd4ecd510ecb33020169ab9f36815a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 13 Aug 2026 17:33:51 -0400 Subject: [PATCH 228/785] atk: Match `StreamSoundFileReader::ReadStreamTrackInfo` This matches all non-inlined functions in `StreamSoundFileReader` --- include/nn/atk/atk_StreamSoundFile.h | 22 +++++++++++++----- include/nn/atk/atk_StreamSoundFileReader.h | 13 ++++++++++- .../atk/detail/strm/atk_StreamSoundFile.cpp | 4 ---- .../detail/strm/atk_StreamSoundFileReader.cpp | 23 +++++++++++++++++++ 4 files changed, 51 insertions(+), 11 deletions(-) diff --git a/include/nn/atk/atk_StreamSoundFile.h b/include/nn/atk/atk_StreamSoundFile.h index 2cebadfe..bf019d23 100644 --- a/include/nn/atk/atk_StreamSoundFile.h +++ b/include/nn/atk/atk_StreamSoundFile.h @@ -85,7 +85,8 @@ struct StreamSoundFile { struct TrackInfoTable { Util::ReferenceTable table; - u32 GetTrackCount() const; + u32 GetTrackCount() const { return table.count; } + const TrackInfo* GetTrackInfo(u32 index) const; }; @@ -98,19 +99,28 @@ struct StreamSoundFile { Util::Reference toGlobalChannelIndexTable; - u32 GetTrackChannelCount() const; - u8 GetGlobalChannelIndex(u32 index) const; + u32 GetTrackChannelCount() const { + return GetGlobalChannelIndexTable().GetCount(); + } + + u8 GetGlobalChannelIndex(u32 index) const { + return GetGlobalChannelIndexTable().GetGlobalIndex(index); + } private: - const GlobalChannelIndexTable& GetGlobalChannelIndexTable() const; + const GlobalChannelIndexTable& GetGlobalChannelIndexTable() const { + return *util::ConstBytePtr(this) + .Advance(toGlobalChannelIndexTable.offset) + .Get(); + } }; static_assert(sizeof(TrackInfo) == 0xc); struct GlobalChannelIndexTable { Util::Table table; - u32 GetCount() const; - u8 GetGlobalIndex(u32 index) const; + u32 GetCount() const { return table.count; } + u8 GetGlobalIndex(u32 index) const { return table.item[index]; } }; struct ChannelInfo; diff --git a/include/nn/atk/atk_StreamSoundFileReader.h b/include/nn/atk/atk_StreamSoundFileReader.h index 937e3b69..e7e82175 100644 --- a/include/nn/atk/atk_StreamSoundFileReader.h +++ b/include/nn/atk/atk_StreamSoundFileReader.h @@ -5,6 +5,17 @@ namespace nn::atk::detail { class StreamSoundFileReader { public: + struct TrackInfo { + u8 volume; + u8 pan; + u8 span; + u8 flags; + u8 channelCount; + u8 globalChannelIndex[2]; + + TrackInfo(); + }; + StreamSoundFileReader(); void Initialize(const void* streamSoundFile); @@ -22,7 +33,7 @@ class StreamSoundFileReader { static bool IsValidFileHeader(const void* streamSoundFile); bool ReadStreamSoundInfo(StreamSoundFile::StreamSoundInfo* strmInfo) const; - bool ReadStreamTrackInfo(StreamSoundFile::TrackInfo* pTrackInfo, int trackIndex) const; + bool ReadStreamTrackInfo(TrackInfo* pTrackInfo, int trackIndex) const; bool ReadDspAdpcmChannelInfo(DspAdpcmParam* pParam, DspAdpcmLoopParam* pLoopParam, int channelIndex) const; diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp index 269505c4..4170fd45 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp @@ -74,10 +74,6 @@ const StreamSoundFile::ChannelInfoTable* StreamSoundFile::InfoBlockBody::GetChan return nullptr; } -u32 StreamSoundFile::TrackInfoTable::GetTrackCount() const { - return table.count; -} - const StreamSoundFile::TrackInfo* StreamSoundFile::TrackInfoTable::GetTrackInfo(u32 index) const { return static_cast(table.GetReferedItem(index, ElementType_StreamSoundFile_TrackInfo)); } diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp index 894819ea..a07aa30d 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp @@ -106,6 +106,29 @@ bool StreamSoundFileReader::ReadStreamSoundInfo(StreamSoundFile::StreamSoundInfo return true; } +bool StreamSoundFileReader::ReadStreamTrackInfo(TrackInfo* pTrackInfo, int trackIndex) const { + auto* table {m_pInfoBlockBody->GetTrackInfoTable()}; + if (table != nullptr && trackIndex < static_cast(table->GetTrackCount())) { + auto* src {table->GetTrackInfo(trackIndex)}; + pTrackInfo->volume = src->volume; + pTrackInfo->pan = src->pan; + pTrackInfo->span = src->span; + pTrackInfo->flags = src->flags; + pTrackInfo->channelCount = src->GetTrackChannelCount(); + + u32 count {pTrackInfo->channelCount}; + if (count > 1) + count = 2; + + for (u32 i {0}; i < count; ++i) + pTrackInfo->globalChannelIndex[i] = src->GetGlobalChannelIndex(i); + + return true; + } + + return false; +} + bool StreamSoundFileReader::ReadDspAdpcmChannelInfo(DspAdpcmParam* pParam, DspAdpcmLoopParam* pLoopParam, int channelIndex) const { auto* src {m_pInfoBlockBody->GetChannelInfoTable()->GetChannelInfo(channelIndex)->GetDspAdpcmChannelInfo()}; From 5a63a0dc3944da3a14f3fddb9c6dd9fd30474ed5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 14 Aug 2026 19:52:02 -0400 Subject: [PATCH 229/785] atk: Match `StreamSoundPrefetchFile::FileHeader::GetInfoBlock` --- include/nn/atk/atk_StreamSoundPrefetchFile.h | 22 +++++------ include/nn/atk/atk_Util.h | 38 ++++++++++++++++--- .../strm/atk_StreamSoundPrefetchFile.cpp | 10 +++++ 3 files changed, 54 insertions(+), 16 deletions(-) diff --git a/include/nn/atk/atk_StreamSoundPrefetchFile.h b/include/nn/atk/atk_StreamSoundPrefetchFile.h index c66853a3..af1b9351 100644 --- a/include/nn/atk/atk_StreamSoundPrefetchFile.h +++ b/include/nn/atk/atk_StreamSoundPrefetchFile.h @@ -8,39 +8,39 @@ class StreamSoundPrefetchFile { public: struct PrefetchDataBlock; struct FileHeader : Util::SoundFileHeader { - - StreamSoundFile::InfoBlock* GetInfoBlock() const; - StreamSoundFile::RegionBlock* GetRegionBlock() const; - PrefetchDataBlock* GetPrefetchDataBlock() const; + + const StreamSoundFile::InfoBlock* GetInfoBlock() const; + const StreamSoundFile::RegionBlock* GetRegionBlock() const; + const PrefetchDataBlock* GetPrefetchDataBlock() const; u32 GetPrefetchDataBlockSize() const; bool HasRegionBlock() const; u32 GetRegionBlockSize() const; u32 GetRegionBlockOffset() const; - }; struct PrefetchSample { - - void* GetSampleAddress(); - u8 data[1]; + + const void* GetSampleAddress() const; }; struct PrefetchData { - - PrefetchSample* GetPrefetchSample(); - u32 startFrame; u32 prefetchSize; u32 reserved[1]; Util::Reference toPrefetchSample; + + const PrefetchSample* GetPrefetchSample() const; }; static_assert(sizeof(PrefetchData) == 0x14); struct PrefetchDataBlockBody { Util::Table prefetchDataTable; + + u32 GetPrefetchDataCount() const { return prefetchDataTable.count; } + const PrefetchData* GetPrefetchData(u32 index) const { return &prefetchDataTable.item[index]; } }; struct PrefetchDataBlock { diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index 67cef5d2..851533dc 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -53,7 +53,7 @@ struct Util { bool IsValidTypeId(u16 validId) const { return typeId == validId; } bool IsValidOffset() const { return offset != InvalidOffset; } - // Id from ElementTypes enum + // Id from ElementType enum u16 typeId; u8 padding[2]; s32 offset; @@ -67,11 +67,43 @@ struct Util { struct BlockReferenceTable { ReferenceWithSize item[1]; + + const void* GetReferedItemByIndex(const void* origin, int index, u16 count) const; + + const ReferenceWithSize* GetReference(u16 typeId, u16 count) const { + for (int i {0}; i < count; ++i) { + if (item[i].IsValidTypeId(typeId)) + return &item[i]; + } + + return nullptr; + } + + const void* GetReferedItem(const void* origin, u16 typeId, u16 count) const { + auto* ref {GetReference(typeId, count)}; + if (ref != nullptr && ref->offset != 0) + return util::ConstBytePtr(origin).Advance(ref->offset).Get(); + + return nullptr; + } + + u32 GetReferedItemSize(u16 typeId, u16 count) const; + u32 GetReferedItemOffset(u16 typeId, u16 count) const; }; struct SoundFileHeader { BinaryFileHeader header; BlockReferenceTable blockReferenceTable; + + int GetBlockCount() const { return header.dataBlocks; } + + protected: + const void* GetBlock(u16 typeId) const { + return blockReferenceTable.GetReferedItem(this, typeId, header.dataBlocks); + } + + u32 GetBlockSize(u16 typeId) const; + u32 GetBlockOffset(u16 typeId) const; }; template @@ -81,7 +113,6 @@ struct Util { }; struct ReferenceTable : Table { - const void* GetReferedItem(u32 index) const { if (count > index) return util::ConstBytePtr(this).Advance(item[index].offset).Get(); @@ -97,11 +128,9 @@ struct Util { } const void* FindReferedItemBy(u16 typeId) const; - }; struct ReferenceWithSizeTable : Table { - const void* GetReferedItem(u32 index) const { if (count > index) return util::ConstBytePtr(this).Advance(item[index].offset).Get(); @@ -111,7 +140,6 @@ struct Util { const void* GetReferedItemBy(u16 typeId) const; u32 GetReferedItemSize(u32 index) const; - }; struct BitFlag { diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp index e69de29b..8f17caaa 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp @@ -0,0 +1,10 @@ +#include + +#include + +namespace nn::atk::detail { +const StreamSoundFile::InfoBlock* StreamSoundPrefetchFile::FileHeader::GetInfoBlock() const { + return util::ConstBytePtr(GetBlock(ElementType_StreamSoundFile_InfoBlock)) + .Get(); +} +} // namespace nn::atk::detail \ No newline at end of file From b2ced9a7b0c949aa889ebf91f534c5fc0b95d082 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 14 Aug 2026 20:01:43 -0400 Subject: [PATCH 230/785] atk: Match `StreamSoundPrefetchFile::FileHeader::GetRegionBlock` --- .../atk/detail/strm/atk_StreamSoundPrefetchFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp index 8f17caaa..f15a6df3 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp @@ -7,4 +7,9 @@ const StreamSoundFile::InfoBlock* StreamSoundPrefetchFile::FileHeader::GetInfoBl return util::ConstBytePtr(GetBlock(ElementType_StreamSoundFile_InfoBlock)) .Get(); } + +const StreamSoundFile::RegionBlock* StreamSoundPrefetchFile::FileHeader::GetRegionBlock() const { + return util::ConstBytePtr(GetBlock(ElementType_StreamSoundFile_RegionBlock)) + .Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 3bbe1f594ef8d752f79b7d996220194a5956920b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 14 Aug 2026 20:05:05 -0400 Subject: [PATCH 231/785] atk: Match `StreamSoundPrefetchFile::FileHeader::GetPrefetchDataBlock` --- .../atk/detail/strm/atk_StreamSoundPrefetchFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp index f15a6df3..d62b8d47 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp @@ -12,4 +12,8 @@ const StreamSoundFile::RegionBlock* StreamSoundPrefetchFile::FileHeader::GetRegi return util::ConstBytePtr(GetBlock(ElementType_StreamSoundFile_RegionBlock)) .Get(); } + +const StreamSoundPrefetchFile::PrefetchDataBlock* StreamSoundPrefetchFile::FileHeader::GetPrefetchDataBlock() const { + return util::ConstBytePtr(GetBlock(ElementType_StreamSoundFile_PrefetchDataBlock)).Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 349647eac999c28283ae9455a572c22d11d218fb Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 14 Aug 2026 20:13:43 -0400 Subject: [PATCH 232/785] atk: Match `StreamSoundPrefetchFile::FileHeader::GetPrefetchDataBlockSize` --- include/nn/atk/atk_Util.h | 14 ++++++++++++-- .../detail/strm/atk_StreamSoundPrefetchFile.cpp | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index 851533dc..c6d016f6 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -87,7 +87,14 @@ struct Util { return nullptr; } - u32 GetReferedItemSize(u16 typeId, u16 count) const; + u32 GetReferedItemSize(u16 typeId, u16 count) const { + auto* ref {GetReference(typeId, count)}; + if (ref != nullptr) + return ref->size; + + return 0; + } + u32 GetReferedItemOffset(u16 typeId, u16 count) const; }; @@ -102,7 +109,10 @@ struct Util { return blockReferenceTable.GetReferedItem(this, typeId, header.dataBlocks); } - u32 GetBlockSize(u16 typeId) const; + u32 GetBlockSize(u16 typeId) const { + return blockReferenceTable.GetReferedItemSize(typeId, header.dataBlocks); + } + u32 GetBlockOffset(u16 typeId) const; }; diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp index d62b8d47..41365f1a 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp @@ -16,4 +16,8 @@ const StreamSoundFile::RegionBlock* StreamSoundPrefetchFile::FileHeader::GetRegi const StreamSoundPrefetchFile::PrefetchDataBlock* StreamSoundPrefetchFile::FileHeader::GetPrefetchDataBlock() const { return util::ConstBytePtr(GetBlock(ElementType_StreamSoundFile_PrefetchDataBlock)).Get(); } + +u32 StreamSoundPrefetchFile::FileHeader::GetPrefetchDataBlockSize() const { + return GetBlockSize(ElementType_StreamSoundFile_PrefetchDataBlock); +} } // namespace nn::atk::detail \ No newline at end of file From ba7e05f675f30d2373b539890eea5f315692d40d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 14 Aug 2026 20:15:14 -0400 Subject: [PATCH 233/785] atk: Match `StreamSoundPrefetchFile::FileHeader::HasRegionBlock` --- .../atk/detail/strm/atk_StreamSoundPrefetchFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp index 41365f1a..6d0d7369 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp @@ -20,4 +20,8 @@ const StreamSoundPrefetchFile::PrefetchDataBlock* StreamSoundPrefetchFile::FileH u32 StreamSoundPrefetchFile::FileHeader::GetPrefetchDataBlockSize() const { return GetBlockSize(ElementType_StreamSoundFile_PrefetchDataBlock); } + +bool StreamSoundPrefetchFile::FileHeader::HasRegionBlock() const { + return GetBlock(ElementType_StreamSoundFile_RegionBlock) != nullptr; +} } // namespace nn::atk::detail \ No newline at end of file From 26bbcb32414a9d1e2b3560f5ac88aab9018c15a4 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 14 Aug 2026 20:17:34 -0400 Subject: [PATCH 234/785] atk: Match `StreamSoundPrefetchFile::FileHeader::GetRegionBlockSize` --- .../atk/detail/strm/atk_StreamSoundPrefetchFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp index 6d0d7369..716fdcb7 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp @@ -24,4 +24,8 @@ u32 StreamSoundPrefetchFile::FileHeader::GetPrefetchDataBlockSize() const { bool StreamSoundPrefetchFile::FileHeader::HasRegionBlock() const { return GetBlock(ElementType_StreamSoundFile_RegionBlock) != nullptr; } + +u32 StreamSoundPrefetchFile::FileHeader::GetRegionBlockSize() const { + return GetBlockSize(ElementType_StreamSoundFile_RegionBlock); +} } // namespace nn::atk::detail \ No newline at end of file From 16f0b71221cad37b390e16a62aeddc18ca0e48eb Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 14 Aug 2026 20:25:08 -0400 Subject: [PATCH 235/785] atk: Match `StreamSoundPrefetchFile::FileHeader::GetRegionBlockOffset` --- include/nn/atk/atk_Util.h | 12 ++++++++++-- .../atk/detail/strm/atk_StreamSoundPrefetchFile.cpp | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index c6d016f6..4cb4f3bf 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -95,7 +95,13 @@ struct Util { return 0; } - u32 GetReferedItemOffset(u16 typeId, u16 count) const; + u32 GetReferedItemOffset(u16 typeId, u16 count) const { + auto* ref {GetReference(typeId, count)}; + if (ref != nullptr) + return ref->offset; + + return 0; + } }; struct SoundFileHeader { @@ -113,7 +119,9 @@ struct Util { return blockReferenceTable.GetReferedItemSize(typeId, header.dataBlocks); } - u32 GetBlockOffset(u16 typeId) const; + u32 GetBlockOffset(u16 typeId) const { + return blockReferenceTable.GetReferedItemOffset(typeId, header.dataBlocks); + } }; template diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp index 716fdcb7..0613707c 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp @@ -28,4 +28,8 @@ bool StreamSoundPrefetchFile::FileHeader::HasRegionBlock() const { u32 StreamSoundPrefetchFile::FileHeader::GetRegionBlockSize() const { return GetBlockSize(ElementType_StreamSoundFile_RegionBlock); } + +u32 StreamSoundPrefetchFile::FileHeader::GetRegionBlockOffset() const { + return GetBlockOffset(ElementType_StreamSoundFile_RegionBlock); +} } // namespace nn::atk::detail \ No newline at end of file From ac2c592158eb743eb3b0c52c916dc7b1b077459b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 14 Aug 2026 20:30:54 -0400 Subject: [PATCH 236/785] atk: Match `StreamSoundPrefetchFile::PrefetchData::GetPrefetchSample` --- include/nn/atk/atk_StreamSoundPrefetchFile.h | 13 +++++++------ .../atk/detail/strm/atk_StreamSoundPrefetchFile.cpp | 4 ++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/nn/atk/atk_StreamSoundPrefetchFile.h b/include/nn/atk/atk_StreamSoundPrefetchFile.h index af1b9351..7ea8d76b 100644 --- a/include/nn/atk/atk_StreamSoundPrefetchFile.h +++ b/include/nn/atk/atk_StreamSoundPrefetchFile.h @@ -20,12 +20,7 @@ class StreamSoundPrefetchFile { u32 GetRegionBlockOffset() const; }; - struct PrefetchSample { - u8 data[1]; - - const void* GetSampleAddress() const; - }; - + struct PrefetchSample; struct PrefetchData { u32 startFrame; u32 prefetchSize; @@ -47,5 +42,11 @@ class StreamSoundPrefetchFile { BinaryBlockHeader header; PrefetchDataBlockBody body; }; + + struct PrefetchSample { + u8 data[1]; + + const void* GetSampleAddress() const; + }; }; } // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp index 0613707c..4628841a 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp @@ -32,4 +32,8 @@ u32 StreamSoundPrefetchFile::FileHeader::GetRegionBlockSize() const { u32 StreamSoundPrefetchFile::FileHeader::GetRegionBlockOffset() const { return GetBlockOffset(ElementType_StreamSoundFile_RegionBlock); } + +const StreamSoundPrefetchFile::PrefetchSample* StreamSoundPrefetchFile::PrefetchData::GetPrefetchSample() const { + return util::ConstBytePtr(this).Advance(toPrefetchSample.offset).Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 74dbdc8f2ca492d4c0f84696f7cc15de8cb27fda Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 14 Aug 2026 20:33:30 -0400 Subject: [PATCH 237/785] atk: Match `StreamSoundPrefetchFile::PrefetchSample::GetSampleAddress` This matches all exported functions in `StreamSoundPrefetchFile` --- .../atk/detail/strm/atk_StreamSoundPrefetchFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp index 4628841a..4a875a06 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp @@ -1,6 +1,7 @@ #include #include +#include "nn/util/util_BytePtr.h" namespace nn::atk::detail { const StreamSoundFile::InfoBlock* StreamSoundPrefetchFile::FileHeader::GetInfoBlock() const { @@ -36,4 +37,8 @@ u32 StreamSoundPrefetchFile::FileHeader::GetRegionBlockOffset() const { const StreamSoundPrefetchFile::PrefetchSample* StreamSoundPrefetchFile::PrefetchData::GetPrefetchSample() const { return util::ConstBytePtr(this).Advance(toPrefetchSample.offset).Get(); } + +const void* StreamSoundPrefetchFile::PrefetchSample::GetSampleAddress() const { + return util::ConstBytePtr(data).Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 875e3c50f4e3ce76643f9b1886c7de463058f3fa Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 15 Aug 2026 14:06:39 -0400 Subject: [PATCH 238/785] atk: Match `StreamSoundPrefetchFileReader` constructor --- include/nn/atk/atk_StreamSoundPrefetchFile.h | 1 - .../atk/atk_StreamSoundPrefetchFileReader.h | 36 ++++++++++--------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/include/nn/atk/atk_StreamSoundPrefetchFile.h b/include/nn/atk/atk_StreamSoundPrefetchFile.h index 7ea8d76b..d880b0c4 100644 --- a/include/nn/atk/atk_StreamSoundPrefetchFile.h +++ b/include/nn/atk/atk_StreamSoundPrefetchFile.h @@ -8,7 +8,6 @@ class StreamSoundPrefetchFile { public: struct PrefetchDataBlock; struct FileHeader : Util::SoundFileHeader { - const StreamSoundFile::InfoBlock* GetInfoBlock() const; const StreamSoundFile::RegionBlock* GetRegionBlock() const; const PrefetchDataBlock* GetPrefetchDataBlock() const; diff --git a/include/nn/atk/atk_StreamSoundPrefetchFileReader.h b/include/nn/atk/atk_StreamSoundPrefetchFileReader.h index 488c6d2c..f03afe8f 100644 --- a/include/nn/atk/atk_StreamSoundPrefetchFileReader.h +++ b/include/nn/atk/atk_StreamSoundPrefetchFileReader.h @@ -4,12 +4,12 @@ #include namespace nn::atk::detail { -class StreamSoundPrefetchFileReader : IRegionInfoReadable { +class StreamSoundPrefetchFileReader : public IRegionInfoReadable { public: struct PrefetchDataInfo { u32 startFrame; u32 prefetchSize; - void* dataAddress; + const void* dataAddress; }; StreamSoundPrefetchFileReader(); @@ -18,28 +18,32 @@ class StreamSoundPrefetchFileReader : IRegionInfoReadable { void Initialize(const void* streamSoundPrefetchFile); void Finalize(); - bool IsValidFileHeader(const void* streamSoundPrefetchFile) const; - - s32 GetRegionDataOffset() const; - u16 GetRegionInfoBytes() const; + bool IsAvailable() const; bool IsIncludeRegionInfo() const; bool IsCrc32CheckAvailable() const; bool IsRegionIndexCheckAvailable() const; - + + bool IsValidFileHeader(const void* streamSoundPrefetchFile) const; + bool ReadStreamSoundInfo(StreamSoundFile::StreamSoundInfo* strmInfo) const; bool ReadDspAdpcmChannelInfo(DspAdpcmParam* pParam, DspAdpcmLoopParam* pLoopParam, - s32 channelIndex) const; - bool ReadPrefetchDataInfo(PrefetchDataInfo* pDataInfo, s32 prefetchIndex) const; - bool ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo, - u32 regionIndex) const override; + int channelIndex) const; + bool ReadPrefetchDataInfo(PrefetchDataInfo* pDataInfo, int prefetchIndex) const; + + bool ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo,u32 regionIndex) const override; + + u32 GetChannelCount() const; + u32 GetPrefetchDataCount() const; + u32 GetRegionDataOffset() const; + u16 GetRegionInfoBytes() const; private: - StreamSoundPrefetchFile::FileHeader* m_pHeader; - StreamSoundFile::InfoBlockBody* m_pInfoBlockBody; - StreamSoundPrefetchFile::PrefetchDataBlockBody* m_pPrefetchDataBlockBody; - u32 m_RegionDataOffset; - u16 m_RegionInfoBytes; + const StreamSoundPrefetchFile::FileHeader* m_pHeader {}; + const StreamSoundFile::InfoBlockBody* m_pInfoBlockBody {}; + const StreamSoundPrefetchFile::PrefetchDataBlockBody* m_pPrefetchDataBlockBody {}; + u32 m_RegionDataOffset {0}; + u16 m_RegionInfoBytes {0}; }; static_assert(sizeof(StreamSoundPrefetchFileReader) == 0x28); } // namespace nn::atk::detail \ No newline at end of file From 0135ac09de7a213c5368195305eea807487e8155 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 15 Aug 2026 14:08:57 -0400 Subject: [PATCH 239/785] atk: Match `StreamSoundPrefetchFileReader` destructor --- include/nn/atk/atk_StreamSoundPrefetchFileReader.h | 8 +++++++- .../detail/strm/atk_StreamSoundPrefetchFileReader.cpp | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_StreamSoundPrefetchFileReader.h b/include/nn/atk/atk_StreamSoundPrefetchFileReader.h index f03afe8f..bc178680 100644 --- a/include/nn/atk/atk_StreamSoundPrefetchFileReader.h +++ b/include/nn/atk/atk_StreamSoundPrefetchFileReader.h @@ -16,7 +16,13 @@ class StreamSoundPrefetchFileReader : public IRegionInfoReadable { ~StreamSoundPrefetchFileReader() override; void Initialize(const void* streamSoundPrefetchFile); - void Finalize(); + void Finalize() { + m_pHeader = nullptr; + m_pInfoBlockBody = nullptr; + m_pPrefetchDataBlockBody = nullptr; + m_RegionDataOffset = 0; + m_RegionInfoBytes = 0; + } bool IsAvailable() const; diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp index e69de29b..da282113 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp @@ -0,0 +1,9 @@ +#include + +namespace nn::atk::detail { +StreamSoundPrefetchFileReader::StreamSoundPrefetchFileReader() = default; + +StreamSoundPrefetchFileReader::~StreamSoundPrefetchFileReader() { + Finalize(); +} +} // namespace nn::atk::detail \ No newline at end of file From 89a74d1dbebddb8bcf9c35ce280b9cfb4e2deb8c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 15 Aug 2026 14:44:56 -0400 Subject: [PATCH 240/785] atk: Match `StreamSoundPrefetchFileReader::Initialize` --- .../atk/atk_StreamSoundPrefetchFileReader.h | 21 ++++++++-- .../detail/strm/atk_StreamSoundFileReader.cpp | 22 +++++----- .../atk_StreamSoundPrefetchFileReader.cpp | 40 +++++++++++++++++++ 3 files changed, 69 insertions(+), 14 deletions(-) diff --git a/include/nn/atk/atk_StreamSoundPrefetchFileReader.h b/include/nn/atk/atk_StreamSoundPrefetchFileReader.h index bc178680..359799a5 100644 --- a/include/nn/atk/atk_StreamSoundPrefetchFileReader.h +++ b/include/nn/atk/atk_StreamSoundPrefetchFileReader.h @@ -24,7 +24,9 @@ class StreamSoundPrefetchFileReader : public IRegionInfoReadable { m_RegionInfoBytes = 0; } - bool IsAvailable() const; + bool IsAvailable() const { + return m_pHeader != nullptr; + } bool IsIncludeRegionInfo() const; bool IsCrc32CheckAvailable() const; @@ -41,8 +43,21 @@ class StreamSoundPrefetchFileReader : public IRegionInfoReadable { u32 GetChannelCount() const; u32 GetPrefetchDataCount() const; - u32 GetRegionDataOffset() const; - u16 GetRegionInfoBytes() const; + + u32 GetRegionDataOffset() const { + u32 result {0}; + + if (IsAvailable() && m_pHeader->HasRegionBlock()) { + result = m_pHeader->GetRegionBlockOffset() + sizeof(BinaryBlockHeader) + + m_pInfoBlockBody->GetStreamSoundInfo()->regionDataOffset.offset; + } + + return result; + } + + u16 GetRegionInfoBytes() const { + return m_pInfoBlockBody->GetStreamSoundInfo()->regionInfoBytes; + } private: const StreamSoundPrefetchFile::FileHeader* m_pHeader {}; diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp index a07aa30d..15a08568 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp @@ -14,6 +14,17 @@ const u32 IncludeRegionIndexCheckVersionStm {0x60100}; StreamSoundFileReader::StreamSoundFileReader() = default; +bool StreamSoundFileReader::IsValidFileHeader(const void* streamSoundFile) { + const BinaryFileHeader& header {*util::ConstBytePtr(streamSoundFile).Get()}; + + bool isSupportedVersion {header.signature == SignatureFileStm + && header.byteOrder == BinaryFileHeader::ValidByteOrderMark + && header.version >= SupportedFileVersionStm + && header.version <= CurrentFileVersionStm}; + + return isSupportedVersion; +} + void StreamSoundFileReader::Initialize(const void* streamSoundFile) { if (IsValidFileHeader(streamSoundFile)) { m_pHeader = util::ConstBytePtr(streamSoundFile).Get(); @@ -54,17 +65,6 @@ bool StreamSoundFileReader::IsRegionIndexCheckAvailable() const { return header.version >= IncludeRegionIndexCheckVersionStm; } -bool StreamSoundFileReader::IsValidFileHeader(const void* streamSoundFile) { - const BinaryFileHeader& header {*util::ConstBytePtr(streamSoundFile).Get()}; - - bool isSupportedVersion {header.signature == SignatureFileStm - && header.byteOrder == BinaryFileHeader::ValidByteOrderMark - && header.version >= SupportedFileVersionStm - && header.version <= CurrentFileVersionStm}; - - return isSupportedVersion; -} - bool StreamSoundFileReader::ReadStreamSoundInfo(StreamSoundFile::StreamSoundInfo* strmInfo) const { auto* info {m_pInfoBlockBody->GetStreamSoundInfo()}; diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp index da282113..189c965f 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp @@ -1,9 +1,49 @@ #include namespace nn::atk::detail { +const u32 SignatureFileStp {0x50545346}; // FSTP +const u32 SignatureInfoBlockStp {0x4f464e49}; // INFO +const u32 SignaturePrefetchdataBlockStp {0x54414450}; // PDAT + +const int SupportedFileVersionStp {0x10000}; +const int CurrentFileVersionStp {0x50200}; + +const int IncludeRegionInfoVersionStp {0x30000}; +const int IncludeCrc32CheckVersionStp {0x40000}; +const int IncludeRegionIndexCheckVersionStp {0x50100}; + StreamSoundPrefetchFileReader::StreamSoundPrefetchFileReader() = default; StreamSoundPrefetchFileReader::~StreamSoundPrefetchFileReader() { Finalize(); } + +bool StreamSoundPrefetchFileReader::IsValidFileHeader(const void* streamSoundPrefetchFile) const { + const BinaryFileHeader& header {*util::ConstBytePtr(streamSoundPrefetchFile).Get()}; + + bool isSupportedVersion {header.signature == SignatureFileStp + && header.byteOrder == BinaryFileHeader::ValidByteOrderMark + && header.version >= SupportedFileVersionStp + && header.version <= CurrentFileVersionStp}; + + return isSupportedVersion; +} + +void StreamSoundPrefetchFileReader::Initialize(const void* streamSoundPrefetchFile) { + if (IsValidFileHeader(streamSoundPrefetchFile)) { + m_pHeader = util::ConstBytePtr(streamSoundPrefetchFile).Get(); + auto* infoBlock {m_pHeader->GetInfoBlock()}; + if (infoBlock->header.kind == SignatureInfoBlockStp) { + auto* dataBlock {m_pHeader->GetPrefetchDataBlock()}; + if (dataBlock->header.kind == SignaturePrefetchdataBlockStp) { + m_pInfoBlockBody = &infoBlock->body; + m_pPrefetchDataBlockBody = &dataBlock->body; + + m_RegionDataOffset = GetRegionDataOffset(); + m_RegionInfoBytes = GetRegionInfoBytes(); + } + } + } +} + } // namespace nn::atk::detail \ No newline at end of file From d7c85ef10e89e68972faa91bc6dd32fb342bf167 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 15 Aug 2026 14:46:13 -0400 Subject: [PATCH 241/785] atk: Match `StreamSoundPrefetchFileReader::IsIncludeRegionInfo` --- .../atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp index 189c965f..42ba8621 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp @@ -46,4 +46,8 @@ void StreamSoundPrefetchFileReader::Initialize(const void* streamSoundPrefetchFi } } +bool StreamSoundPrefetchFileReader::IsIncludeRegionInfo() const { + return m_pHeader->header.version >= IncludeRegionInfoVersionStp; +} + } // namespace nn::atk::detail \ No newline at end of file From 433a7866c7e50669409eba8694a9bda02c0baa12 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 15 Aug 2026 14:46:48 -0400 Subject: [PATCH 242/785] atk: Match `StreamSoundPrefetchFileReader::IsCrc32CheckAvailable` --- .../atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp index 42ba8621..38664b68 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp @@ -50,4 +50,8 @@ bool StreamSoundPrefetchFileReader::IsIncludeRegionInfo() const { return m_pHeader->header.version >= IncludeRegionInfoVersionStp; } +bool StreamSoundPrefetchFileReader::IsCrc32CheckAvailable() const { + return m_pHeader->header.version >= IncludeCrc32CheckVersionStp; +} + } // namespace nn::atk::detail \ No newline at end of file From f5778dead1d5a639a469125a2d2c9b6e0db2042e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 15 Aug 2026 14:47:22 -0400 Subject: [PATCH 243/785] atk: Match `StreamSoundPrefetchFileReader::IsRegionIndexCheckAvailable` --- .../atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp index 38664b68..272f34e0 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp @@ -54,4 +54,8 @@ bool StreamSoundPrefetchFileReader::IsCrc32CheckAvailable() const { return m_pHeader->header.version >= IncludeCrc32CheckVersionStp; } +bool StreamSoundPrefetchFileReader::IsRegionIndexCheckAvailable() const { + return m_pHeader->header.version >= IncludeRegionIndexCheckVersionStp; +} + } // namespace nn::atk::detail \ No newline at end of file From 1f04b19341199651eb8d8dec8bc6ec73a4f66ff4 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 15 Aug 2026 14:49:11 -0400 Subject: [PATCH 244/785] atk: Match `StreamSoundPrefetchFileReader::ReadStreamSoundInfo` --- .../atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp index 272f34e0..e6ebc457 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp @@ -58,4 +58,9 @@ bool StreamSoundPrefetchFileReader::IsRegionIndexCheckAvailable() const { return m_pHeader->header.version >= IncludeRegionIndexCheckVersionStp; } +bool StreamSoundPrefetchFileReader::ReadStreamSoundInfo(StreamSoundFile::StreamSoundInfo* strmInfo) const { + *strmInfo = *m_pInfoBlockBody->GetStreamSoundInfo(); + return true; +} + } // namespace nn::atk::detail \ No newline at end of file From 94e2248c2fdc255cb68d066121393b6b58596424 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 15 Aug 2026 14:50:41 -0400 Subject: [PATCH 245/785] atk: Match `StreamSoundPrefetchFileReader::ReadDspAdpcmChannelInfo` --- .../strm/atk_StreamSoundPrefetchFileReader.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp index e6ebc457..704d66b5 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp @@ -63,4 +63,17 @@ bool StreamSoundPrefetchFileReader::ReadStreamSoundInfo(StreamSoundFile::StreamS return true; } +bool StreamSoundPrefetchFileReader::ReadDspAdpcmChannelInfo(DspAdpcmParam* pParam, + DspAdpcmLoopParam* pLoopParam, + int channelIndex) const { + auto* src {m_pInfoBlockBody->GetChannelInfoTable()->GetChannelInfo(channelIndex)->GetDspAdpcmChannelInfo()}; + if (src != nullptr) { + *pParam = src->param; + *pLoopParam = src->loopParam; + return true; + } + + return false; +} + } // namespace nn::atk::detail \ No newline at end of file From 9be17ce3c8c568b3719126247d329d56e9ca914c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 15 Aug 2026 14:54:57 -0400 Subject: [PATCH 246/785] atk: Match `StreamSoundPrefetchFileReader::ReadPrefetchDataInfo` --- .../strm/atk_StreamSoundPrefetchFileReader.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp index 704d66b5..07e8eb0e 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp @@ -63,8 +63,7 @@ bool StreamSoundPrefetchFileReader::ReadStreamSoundInfo(StreamSoundFile::StreamS return true; } -bool StreamSoundPrefetchFileReader::ReadDspAdpcmChannelInfo(DspAdpcmParam* pParam, - DspAdpcmLoopParam* pLoopParam, +bool StreamSoundPrefetchFileReader::ReadDspAdpcmChannelInfo(DspAdpcmParam* pParam, DspAdpcmLoopParam* pLoopParam, int channelIndex) const { auto* src {m_pInfoBlockBody->GetChannelInfoTable()->GetChannelInfo(channelIndex)->GetDspAdpcmChannelInfo()}; if (src != nullptr) { @@ -76,4 +75,15 @@ bool StreamSoundPrefetchFileReader::ReadDspAdpcmChannelInfo(DspAdpcmParam* pPara return false; } +bool StreamSoundPrefetchFileReader::ReadPrefetchDataInfo(PrefetchDataInfo* pDataInfo, int prefetchIndex) const { + auto* data {m_pPrefetchDataBlockBody->GetPrefetchData(prefetchIndex)}; + pDataInfo->startFrame = data->startFrame; + pDataInfo->prefetchSize = data->prefetchSize; + + auto* sample {data->GetPrefetchSample()}; + pDataInfo->dataAddress = sample->GetSampleAddress(); + + return true; +} + } // namespace nn::atk::detail \ No newline at end of file From 4515f7b279d2c968acfd13b8b92df9eba06f21c3 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 15 Aug 2026 15:47:39 -0400 Subject: [PATCH 247/785] atk: Match `StreamSoundPrefetchFileReader::ReadRegionInfo` This matches all exported functions in `StreamSoundPrefetchFileReader` --- include/nn/atk/atk_StreamSoundPrefetchFileReader.h | 2 +- .../strm/atk_StreamSoundPrefetchFileReader.cpp | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_StreamSoundPrefetchFileReader.h b/include/nn/atk/atk_StreamSoundPrefetchFileReader.h index 359799a5..86c842bf 100644 --- a/include/nn/atk/atk_StreamSoundPrefetchFileReader.h +++ b/include/nn/atk/atk_StreamSoundPrefetchFileReader.h @@ -39,7 +39,7 @@ class StreamSoundPrefetchFileReader : public IRegionInfoReadable { int channelIndex) const; bool ReadPrefetchDataInfo(PrefetchDataInfo* pDataInfo, int prefetchIndex) const; - bool ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo,u32 regionIndex) const override; + bool ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo, u32 regionIndex) const override; u32 GetChannelCount() const; u32 GetPrefetchDataCount() const; diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp index 07e8eb0e..cfac34ba 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp @@ -82,8 +82,19 @@ bool StreamSoundPrefetchFileReader::ReadPrefetchDataInfo(PrefetchDataInfo* pData auto* sample {data->GetPrefetchSample()}; pDataInfo->dataAddress = sample->GetSampleAddress(); - + return true; } +bool StreamSoundPrefetchFileReader::ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo, u32 regionIndex) const { // 179 + if (m_RegionDataOffset != 0 && m_RegionInfoBytes != 0) { + position_t offset = m_RegionDataOffset + static_cast(m_RegionInfoBytes) * regionIndex; + auto bytePtr {util::ConstBytePtr(m_pHeader)}; + *pInfo = *bytePtr.Advance(offset).Get(); + return true; + } + + return false; +} + } // namespace nn::atk::detail \ No newline at end of file From ffca5a1a65afb5f65db60fc11be989e0cbd49e4e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 15 Aug 2026 16:03:50 -0400 Subject: [PATCH 248/785] atk: Match `WaveFile::FileHeader::GetInfoBlock` --- include/nn/atk/atk_WaveFile.h | 31 +++++++++---------- src/NintendoWare/atk/detail/atk_WaveFile.cpp | 10 ++++++ .../strm/atk_StreamSoundPrefetchFile.cpp | 1 - 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/include/nn/atk/atk_WaveFile.h b/include/nn/atk/atk_WaveFile.h index 766727b4..29fd7e98 100644 --- a/include/nn/atk/atk_WaveFile.h +++ b/include/nn/atk/atk_WaveFile.h @@ -7,25 +7,23 @@ struct WaveFile { struct InfoBlock; struct DataBlock; struct FileHeader : Util::SoundFileHeader { - - InfoBlock* GetInfoBlock() const; - DataBlock* GetDataBlock() const; - + const InfoBlock* GetInfoBlock() const; + const DataBlock* GetDataBlock() const; }; struct ChannelInfo; struct InfoBlockBody { - - ChannelInfo* GetChannelInfo(s32 channelIndex) const; - u8 encoding; u8 isLoop; - u8 padding; + u8 padding[2]; u32 sampleRate; u32 loopStartFrame; u32 loopEndFrame; u32 originalLoopStartFrame; Util::ReferenceTable channelInfoReferenceTable; + + int GetChannelCount() const; + const ChannelInfo& GetChannelInfo(int channelIndex) const; }; struct InfoBlock { @@ -33,22 +31,23 @@ struct WaveFile { InfoBlockBody body; }; - struct DspAdpcmInfo { - DspAdpcmParam adpcmParam; - DspAdpcmLoopParam adpcmLoopParam; - }; - static_assert(sizeof(DspAdpcmInfo) == 0x2C); - + struct DspAdpcmInfo; struct ChannelInfo { Util::Reference referToSamples; Util::Reference referToAdpcmInfo; u32 reserved; - void* GetSamplesAddress(const void* dataBlockBodyAddress) const; - DspAdpcmInfo* GetDspAdpcmInfo() const; + const void* GetSamplesAddress(const void* dataBlockBodyAddress) const; + const DspAdpcmInfo& GetDspAdpcmInfo() const; }; static_assert(sizeof(ChannelInfo) == 0x14); + struct DspAdpcmInfo { + DspAdpcmParam adpcmParam; + DspAdpcmLoopParam adpcmLoopParam; + }; + static_assert(sizeof(DspAdpcmInfo) == 0x2c); + struct DataBlock { BinaryBlockHeader header; union { diff --git a/src/NintendoWare/atk/detail/atk_WaveFile.cpp b/src/NintendoWare/atk/detail/atk_WaveFile.cpp index e69de29b..40a8b4cb 100644 --- a/src/NintendoWare/atk/detail/atk_WaveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveFile.cpp @@ -0,0 +1,10 @@ +#include + +#include + +namespace nn::atk::detail { +const WaveFile::InfoBlock* WaveFile::FileHeader::GetInfoBlock() const { + return util::ConstBytePtr(GetBlock(ElementType_WaveFile_InfoBlock)) + .Get(); +} +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp index 4a875a06..9c902916 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp @@ -1,7 +1,6 @@ #include #include -#include "nn/util/util_BytePtr.h" namespace nn::atk::detail { const StreamSoundFile::InfoBlock* StreamSoundPrefetchFile::FileHeader::GetInfoBlock() const { From 0960dfc006f929613f5098047819557ca2f785ca Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 15 Aug 2026 16:04:21 -0400 Subject: [PATCH 249/785] atk: Match `WaveFile::FileHeader::GetDataBlock` --- src/NintendoWare/atk/detail/atk_WaveFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_WaveFile.cpp b/src/NintendoWare/atk/detail/atk_WaveFile.cpp index 40a8b4cb..c0b99581 100644 --- a/src/NintendoWare/atk/detail/atk_WaveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveFile.cpp @@ -7,4 +7,9 @@ const WaveFile::InfoBlock* WaveFile::FileHeader::GetInfoBlock() const { return util::ConstBytePtr(GetBlock(ElementType_WaveFile_InfoBlock)) .Get(); } + +const WaveFile::DataBlock* WaveFile::FileHeader::GetDataBlock() const { + return util::ConstBytePtr(GetBlock(ElementType_WaveFile_DataBlock)) + .Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 24e7ea2a6f9846bdf503d753dcf45538fe48ffef Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 15 Aug 2026 16:07:34 -0400 Subject: [PATCH 250/785] atk: Match `WaveFile::InfoBlockBody::GetChannelInfo` --- include/nn/atk/atk_WaveFile.h | 2 +- src/NintendoWare/atk/detail/atk_WaveFile.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_WaveFile.h b/include/nn/atk/atk_WaveFile.h index 29fd7e98..01604e5a 100644 --- a/include/nn/atk/atk_WaveFile.h +++ b/include/nn/atk/atk_WaveFile.h @@ -22,7 +22,7 @@ struct WaveFile { u32 originalLoopStartFrame; Util::ReferenceTable channelInfoReferenceTable; - int GetChannelCount() const; + int GetChannelCount() const { return channelInfoReferenceTable.count; }; const ChannelInfo& GetChannelInfo(int channelIndex) const; }; diff --git a/src/NintendoWare/atk/detail/atk_WaveFile.cpp b/src/NintendoWare/atk/detail/atk_WaveFile.cpp index c0b99581..304622d2 100644 --- a/src/NintendoWare/atk/detail/atk_WaveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveFile.cpp @@ -1,6 +1,7 @@ #include #include +#include "nn/util/util_BytePtr.h" namespace nn::atk::detail { const WaveFile::InfoBlock* WaveFile::FileHeader::GetInfoBlock() const { @@ -12,4 +13,9 @@ const WaveFile::DataBlock* WaveFile::FileHeader::GetDataBlock() const { return util::ConstBytePtr(GetBlock(ElementType_WaveFile_DataBlock)) .Get(); } + +const WaveFile::ChannelInfo& WaveFile::InfoBlockBody::GetChannelInfo(int channelIndex) const { + return *util::ConstBytePtr(channelInfoReferenceTable.GetReferedItem(channelIndex)) + .Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 9dec90d3fbd5239c28231cd7acb1e3a5fdd4f581 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 15 Aug 2026 16:09:55 -0400 Subject: [PATCH 251/785] atk: Match `WaveFile::ChannelInfo::GetSamplesAddress` --- src/NintendoWare/atk/detail/atk_WaveFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_WaveFile.cpp b/src/NintendoWare/atk/detail/atk_WaveFile.cpp index 304622d2..873304b8 100644 --- a/src/NintendoWare/atk/detail/atk_WaveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveFile.cpp @@ -18,4 +18,8 @@ const WaveFile::ChannelInfo& WaveFile::InfoBlockBody::GetChannelInfo(int channel return *util::ConstBytePtr(channelInfoReferenceTable.GetReferedItem(channelIndex)) .Get(); } + +const void* WaveFile::ChannelInfo::GetSamplesAddress(const void* dataBlockBodyAddress) const { + return util::ConstBytePtr(dataBlockBodyAddress).Advance(referToSamples.offset).Get(); +} } // namespace nn::atk::detail \ No newline at end of file From eb5f91bd5b7430d9cbf7601fd448eef22b1473f5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 15 Aug 2026 16:11:11 -0400 Subject: [PATCH 252/785] atk: Match `WaveFile::ChannelInfo::GetDspAdpcmInfo` This matches all exported functions in `WaveFile` --- src/NintendoWare/atk/detail/atk_WaveFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_WaveFile.cpp b/src/NintendoWare/atk/detail/atk_WaveFile.cpp index 873304b8..650fe150 100644 --- a/src/NintendoWare/atk/detail/atk_WaveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveFile.cpp @@ -22,4 +22,9 @@ const WaveFile::ChannelInfo& WaveFile::InfoBlockBody::GetChannelInfo(int channel const void* WaveFile::ChannelInfo::GetSamplesAddress(const void* dataBlockBodyAddress) const { return util::ConstBytePtr(dataBlockBodyAddress).Advance(referToSamples.offset).Get(); } + +const WaveFile::DspAdpcmInfo& WaveFile::ChannelInfo::GetDspAdpcmInfo() const { + return *util::ConstBytePtr(this).Advance(referToAdpcmInfo.offset) + .Get(); +} } // namespace nn::atk::detail \ No newline at end of file From e006c6004edb93ed77a11daff2b4488719c49bd7 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 15 Aug 2026 18:09:12 -0400 Subject: [PATCH 253/785] atk: Match `WaveFileReader::GetSampleFormat` --- include/nn/atk/atk_WaveFileReader.h | 12 +++++++----- .../atk/detail/atk_WaveFileReader.cpp | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/include/nn/atk/atk_WaveFileReader.h b/include/nn/atk/atk_WaveFileReader.h index ebdb8023..46d30af0 100644 --- a/include/nn/atk/atk_WaveFileReader.h +++ b/include/nn/atk/atk_WaveFileReader.h @@ -6,22 +6,24 @@ namespace nn::atk::detail { class WaveFileReader { public: - constexpr static s32 SignatureFile = 0x56415746; // FWAV + static const int SignatureFile = 0x56415746; // FWAV static SampleFormat GetSampleFormat(u8 format); WaveFileReader(const void* waveFile, s8 waveType); + bool IsAvailable() const { return m_pHeader != nullptr; } + bool IsOriginalLoopAvailable() const; bool ReadWaveInfo(WaveInfo* info, const void* waveDataOffsetOrigin) const; - void* GetWaveDataAddress(const WaveFile::ChannelInfo* channelInfo, const void*) const; + const void* GetWaveDataAddress(const WaveFile::ChannelInfo* info, const void* waveDataOffsetOrigin) const; private: - WaveFile::FileHeader* m_pHeader; - WaveFile::InfoBlockBody* m_pInfoBlockBody; - void* m_pDataBlockBody; + const WaveFile::FileHeader* m_pHeader; + const WaveFile::InfoBlockBody* m_pInfoBlockBody; + const void* m_pDataBlockBody; DspadpcmReader m_DspadpcmReader; s8 m_WaveType; }; diff --git a/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp b/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp index e69de29b..338b645a 100644 --- a/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp @@ -0,0 +1,16 @@ +#include + +namespace nn::atk::detail { +SampleFormat WaveFileReader::GetSampleFormat(u8 format) { + switch (format) { + case 0: + return SampleFormat_PcmS8; + case 1: + return SampleFormat_PcmS16; + case 2: + return SampleFormat_DspAdpcm; + default: + return SampleFormat_DspAdpcm; + } +} +} // namespace nn::atk::detail \ No newline at end of file From 15e0c1d78b9dc07bbe725c230c8d09c66a6a7c6a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 15 Aug 2026 18:39:40 -0400 Subject: [PATCH 254/785] atk: Match `WaveFileReader` constructor --- include/nn/atk/atk_DspadpcmReader.h | 6 ++- include/nn/atk/atk_WaveFileReader.h | 6 +-- .../atk/detail/atk_WaveFileReader.cpp | 45 +++++++++++++++++++ 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/include/nn/atk/atk_DspadpcmReader.h b/include/nn/atk/atk_DspadpcmReader.h index 68bacadb..c7e546ca 100644 --- a/include/nn/atk/atk_DspadpcmReader.h +++ b/include/nn/atk/atk_DspadpcmReader.h @@ -7,9 +7,13 @@ class DspadpcmReader { public: DspadpcmReader(); + void Initialize(const void* dspadpcmData) { + m_pDspadpcmData = dspadpcmData; + } + bool ReadWaveInfo(WaveInfo* info) const; private: - void* m_pDspadpcmData; + const void* m_pDspadpcmData; }; } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/atk_WaveFileReader.h b/include/nn/atk/atk_WaveFileReader.h index 46d30af0..98496982 100644 --- a/include/nn/atk/atk_WaveFileReader.h +++ b/include/nn/atk/atk_WaveFileReader.h @@ -21,9 +21,9 @@ class WaveFileReader { const void* GetWaveDataAddress(const WaveFile::ChannelInfo* info, const void* waveDataOffsetOrigin) const; private: - const WaveFile::FileHeader* m_pHeader; - const WaveFile::InfoBlockBody* m_pInfoBlockBody; - const void* m_pDataBlockBody; + const WaveFile::FileHeader* m_pHeader {}; + const WaveFile::InfoBlockBody* m_pInfoBlockBody {}; + const void* m_pDataBlockBody {}; DspadpcmReader m_DspadpcmReader; s8 m_WaveType; }; diff --git a/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp b/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp index 338b645a..9019ca60 100644 --- a/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp @@ -1,6 +1,27 @@ #include namespace nn::atk::detail { +const u32 SignatureInfoBlockWav {0x4f464e49}; // INFO +const u32 SignatureDataBlockWav {0x41544144}; // DATA + +const u32 SupportedFileVersionWav {0x10000}; +const u32 CurrentFileVersionWav {0x10200}; + +const u32 IncludeOriginalLoopVersionWav {0x10200}; + +namespace { +bool IsValidFileHeaderWav(const void* waveFile) { + const BinaryFileHeader& header {*util::ConstBytePtr(waveFile).Get()}; + + bool isSupportedVersion {header.signature == WaveFileReader::SignatureFile + && header.byteOrder == BinaryFileHeader::ValidByteOrderMark + && header.version >= SupportedFileVersionWav + && header.version <= CurrentFileVersionWav}; + + return isSupportedVersion; +} +} + SampleFormat WaveFileReader::GetSampleFormat(u8 format) { switch (format) { case 0: @@ -13,4 +34,28 @@ SampleFormat WaveFileReader::GetSampleFormat(u8 format) { return SampleFormat_DspAdpcm; } } + +WaveFileReader::WaveFileReader(const void* waveFile, s8 waveType) { + m_WaveType = waveType; + switch (m_WaveType) { + case WaveType::WaveType_Nwwav: + if (IsValidFileHeaderWav(waveFile)) { + m_pHeader = util::ConstBytePtr(waveFile).Get(); + const WaveFile::InfoBlock* infoBlock {m_pHeader->GetInfoBlock()}; + const WaveFile::DataBlock* dataBlock {m_pHeader->GetDataBlock()}; + + if (infoBlock != nullptr && infoBlock->header.kind == SignatureInfoBlockWav + && dataBlock != nullptr && dataBlock->header.kind == SignatureDataBlockWav) { + m_pInfoBlockBody = &infoBlock->body; + m_pDataBlockBody = &dataBlock->byte; + } + } + break; + case WaveType::WaveType_Dspadpcm: + m_DspadpcmReader.Initialize(waveFile); + break; + case WaveType::WaveType_Invalid: + break; + } +} } // namespace nn::atk::detail \ No newline at end of file From 3d6097b197d81f5999644ee737e0b5e44508259e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 15 Aug 2026 18:43:02 -0400 Subject: [PATCH 255/785] atk: Match `WaveFileReader::IsOriginalLoopAvailable` --- src/NintendoWare/atk/detail/atk_WaveFileReader.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp b/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp index 9019ca60..b322520a 100644 --- a/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp @@ -58,4 +58,10 @@ WaveFileReader::WaveFileReader(const void* waveFile, s8 waveType) { break; } } + +bool WaveFileReader::IsOriginalLoopAvailable() const { + const BinaryFileHeader& header {*util::ConstBytePtr(m_pHeader).Get()}; + + return header.version >= IncludeOriginalLoopVersionWav; +} } // namespace nn::atk::detail \ No newline at end of file From 5d1a21fbe3c26701ac8923f7ea383681c36bf72b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 16 Aug 2026 10:58:59 -0400 Subject: [PATCH 256/785] atk: Match `WaveFileReader::GetWaveDataAddress` --- include/nn/atk/atk_Global.h | 8 ++++---- src/NintendoWare/atk/detail/atk_WaveFileReader.cpp | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h index 081a712e..e25b45bb 100644 --- a/include/nn/atk/atk_Global.h +++ b/include/nn/atk/atk_Global.h @@ -401,8 +401,8 @@ static_assert(sizeof(VoiceParam) == 0x78); struct WaveInfo { struct ChannelParam { - void* dataAddress; - s32 dataSize; + const void* dataAddress; + int dataSize; DspAdpcmParam adpcmParam; DspAdpcmLoopParam adpcmLoopParam; }; @@ -410,8 +410,8 @@ struct WaveInfo { SampleFormat sampleFormat; bool loopFlag; - s32 channelCount; - s32 sampleRate; + int channelCount; + int sampleRate; position_t loopStartFrame; position_t loopEndFrame; position_t originalLoopStartFrame; diff --git a/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp b/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp index b322520a..d9b1c69d 100644 --- a/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp @@ -64,4 +64,8 @@ bool WaveFileReader::IsOriginalLoopAvailable() const { return header.version >= IncludeOriginalLoopVersionWav; } + +const void* WaveFileReader::GetWaveDataAddress(const WaveFile::ChannelInfo* info, const void* waveDataOffsetOrigin) const { + return info->GetSamplesAddress(m_pDataBlockBody); +} } // namespace nn::atk::detail \ No newline at end of file From 1b93e16499b85431f89f0542051cf8382e7afc1f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 16 Aug 2026 11:00:30 -0400 Subject: [PATCH 257/785] atk: Match `WaveFileReader::ReadWaveInfo` This matches all exported functions in `WaveFileReader` --- .../atk/detail/atk_WaveFileReader.cpp | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp b/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp index d9b1c69d..109c49b9 100644 --- a/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp @@ -65,6 +65,56 @@ bool WaveFileReader::IsOriginalLoopAvailable() const { return header.version >= IncludeOriginalLoopVersionWav; } +bool WaveFileReader::ReadWaveInfo(WaveInfo* info, const void* waveDataOffsetOrigin) const { + switch (m_WaveType) { + case WaveType_Nwwav: { + const SampleFormat format {GetSampleFormat(m_pInfoBlockBody->encoding)}; + const int channelCount {m_pInfoBlockBody->GetChannelCount()}; + + info->sampleFormat = format; + info->channelCount = channelCount; + info->sampleRate = m_pInfoBlockBody->sampleRate; + info->loopFlag = m_pInfoBlockBody->isLoop == 1; + info->loopStartFrame = m_pInfoBlockBody->loopStartFrame; + info->loopEndFrame = m_pInfoBlockBody->loopEndFrame; + info->dataSize = m_pHeader->header.fileSize - sizeof(Util::SoundFileHeader); + + if (IsOriginalLoopAvailable()) + info->originalLoopStartFrame = m_pInfoBlockBody->originalLoopStartFrame; + else + info->originalLoopStartFrame = m_pInfoBlockBody->loopStartFrame; + + for (int i {0}; i < channelCount; ++i) { + if (i < 2) { + WaveInfo::ChannelParam& channelParam {info->channelParam[i]}; + const WaveFile::ChannelInfo& channelInfo {m_pInfoBlockBody->GetChannelInfo(i)}; + + if (channelInfo.referToAdpcmInfo.offset != 0) { + const WaveFile::DspAdpcmInfo& adpcmInfo {channelInfo.GetDspAdpcmInfo()}; + channelParam.adpcmParam = adpcmInfo.adpcmParam; + channelParam.adpcmLoopParam = adpcmInfo.adpcmLoopParam; + } + + channelParam.dataAddress = GetWaveDataAddress(&channelInfo, waveDataOffsetOrigin); + + const WaveFile::ChannelInfo& lastChannelInfo {m_pInfoBlockBody->GetChannelInfo(channelCount - 1)}; + channelParam.dataSize = m_pHeader->GetDataBlock()->header.size + - sizeof(BinaryBlockHeader) + - lastChannelInfo.referToSamples.offset; + } + } + break; + } + case WaveType_Dspadpcm: + m_DspadpcmReader.ReadWaveInfo(info); + break; + case WaveType_Invalid: + break; + } + + return true; +} + const void* WaveFileReader::GetWaveDataAddress(const WaveFile::ChannelInfo* info, const void* waveDataOffsetOrigin) const { return info->GetSamplesAddress(m_pDataBlockBody); } From 8581665c372277b5a06c7d3ce617085fc56af6ce Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 16 Aug 2026 11:11:52 -0400 Subject: [PATCH 258/785] atk: Match `AudioRendererPerformanceReader` constructor --- include/nn/atk/atk_AudioRendererPerformanceReader.h | 9 ++++----- .../atk/util/atk_AudioRendererPerformanceReader.cpp | 6 ++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/nn/atk/atk_AudioRendererPerformanceReader.h b/include/nn/atk/atk_AudioRendererPerformanceReader.h index 18060007..dd77478d 100644 --- a/include/nn/atk/atk_AudioRendererPerformanceReader.h +++ b/include/nn/atk/atk_AudioRendererPerformanceReader.h @@ -28,11 +28,10 @@ class AudioRendererPerformanceReader { private: PerformanceInfo* m_pPerformanceInfo{}; - s32 m_PerformanceInfoCount{0}; - std::atomic_int m_WriteIndex{0}; - std::atomic_int m_ReadIndex{0}; - bool m_IsInitialized{false}; + int m_PerformanceInfoCount {0}; + std::atomic_int m_WriteIndex {0}; + std::atomic_int m_ReadIndex {0}; + bool m_IsInitialized {false}; }; static_assert(sizeof(AudioRendererPerformanceReader) == 0x18); - } // namespace nn::atk \ No newline at end of file diff --git a/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp b/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp index e69de29b..dbc214be 100644 --- a/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp +++ b/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp @@ -0,0 +1,6 @@ +#include +#include + +namespace nn::atk { +AudioRendererPerformanceReader::AudioRendererPerformanceReader() = default; +} // namespace nn::atk \ No newline at end of file From 233e3caf280ef2cd66d44cf04d4bfd633f315a4c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 16 Aug 2026 11:48:18 -0400 Subject: [PATCH 259/785] atk: Match `AudioRendererPerformanceReader::GetRequiredMemorySize` --- .../atk/util/atk_AudioRendererPerformanceReader.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp b/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp index dbc214be..ea6d067b 100644 --- a/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp +++ b/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp @@ -3,4 +3,10 @@ namespace nn::atk { AudioRendererPerformanceReader::AudioRendererPerformanceReader() = default; + +size_t AudioRendererPerformanceReader::GetRequiredMemorySize(int performanceInfoCount) { + size_t size {performanceInfoCount * + (SoundSystem::GetPerformanceFrameBufferSize() + sizeof(PerformanceInfo))}; + return size; +} } // namespace nn::atk \ No newline at end of file From e68533a40f492e2a128528ef200f18a46541fee2 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 16 Aug 2026 19:26:14 -0400 Subject: [PATCH 260/785] atk: Match `AudioRendererPerformanceReader::Initialize` --- .../atk/atk_AudioRendererPerformanceReader.h | 2 +- .../atk_AudioRendererPerformanceReader.cpp | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_AudioRendererPerformanceReader.h b/include/nn/atk/atk_AudioRendererPerformanceReader.h index dd77478d..0ff20506 100644 --- a/include/nn/atk/atk_AudioRendererPerformanceReader.h +++ b/include/nn/atk/atk_AudioRendererPerformanceReader.h @@ -27,7 +27,7 @@ class AudioRendererPerformanceReader { void Record(const void* performanceFrameBuffer, size_t performanceFrameBufferSize, os::Tick tick); private: - PerformanceInfo* m_pPerformanceInfo{}; + PerformanceInfo* m_pPerformanceInfo {}; int m_PerformanceInfoCount {0}; std::atomic_int m_WriteIndex {0}; std::atomic_int m_ReadIndex {0}; diff --git a/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp b/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp index ea6d067b..2236ed19 100644 --- a/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp +++ b/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp @@ -9,4 +9,24 @@ size_t AudioRendererPerformanceReader::GetRequiredMemorySize(int performanceInfo (SoundSystem::GetPerformanceFrameBufferSize() + sizeof(PerformanceInfo))}; return size; } + +void AudioRendererPerformanceReader::Initialize(int performanceInfoCount, void* buffer, size_t bufferSize) { + m_PerformanceInfoCount = performanceInfoCount; + + auto ptr {util::BytePtr(buffer)}; + m_pPerformanceInfo = ptr.Get(); + + ptr += performanceInfoCount * sizeof(PerformanceInfo); + + const size_t performanceBufferSize {SoundSystem::GetPerformanceFrameBufferSize()}; + for (int i {0}; i < m_PerformanceInfoCount; ++i) { + m_pPerformanceInfo[i].performanceBuffer = ptr.Get(); + m_pPerformanceInfo[i].performanceBufferSize = performanceBufferSize; + ptr += performanceBufferSize; + } + + m_WriteIndex = 0; + m_ReadIndex = m_PerformanceInfoCount - 1; + m_IsInitialized = true; +} } // namespace nn::atk \ No newline at end of file From 9310c897c21487c207419dfe8a54295df0126736 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 16 Aug 2026 19:34:17 -0400 Subject: [PATCH 261/785] atk: Match `AudioRendererPerformanceReader::ReadPerformanceInfo` --- .../util/atk_AudioRendererPerformanceReader.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp b/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp index 2236ed19..6326ae5f 100644 --- a/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp +++ b/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp @@ -29,4 +29,19 @@ void AudioRendererPerformanceReader::Initialize(int performanceInfoCount, void* m_ReadIndex = m_PerformanceInfoCount - 1; m_IsInitialized = true; } + +const AudioRendererPerformanceReader::PerformanceInfo* AudioRendererPerformanceReader::ReadPerformanceInfo() { + int nextReadIndex {0}; + const int readIndex {m_ReadIndex}; + + if (readIndex + 1 < m_PerformanceInfoCount) + nextReadIndex = readIndex + 1; + + if (nextReadIndex != m_WriteIndex) { + m_ReadIndex = nextReadIndex; + return &m_pPerformanceInfo[nextReadIndex]; + } + + return nullptr; +} } // namespace nn::atk \ No newline at end of file From e597e6cb62b590a0e9e9655bcddd8039753259a7 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 16 Aug 2026 19:46:09 -0400 Subject: [PATCH 262/785] atk: Match `AudioRendererPerformanceReader::Record` This matches all exported functions in `AudioRendererPerformanceReader` --- .../nn/atk/atk_AudioRendererPerformanceReader.h | 2 +- .../util/atk_AudioRendererPerformanceReader.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_AudioRendererPerformanceReader.h b/include/nn/atk/atk_AudioRendererPerformanceReader.h index 0ff20506..188585ff 100644 --- a/include/nn/atk/atk_AudioRendererPerformanceReader.h +++ b/include/nn/atk/atk_AudioRendererPerformanceReader.h @@ -22,7 +22,7 @@ class AudioRendererPerformanceReader { void Initialize(int performanceInfoCount, void* buffer, size_t bufferSize); const PerformanceInfo* ReadPerformanceInfo(); - bool IsInitialized() const; + bool IsInitialized() const { return m_IsInitialized; }; void Record(const void* performanceFrameBuffer, size_t performanceFrameBufferSize, os::Tick tick); diff --git a/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp b/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp index 6326ae5f..f6e24831 100644 --- a/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp +++ b/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp @@ -1,4 +1,5 @@ #include + #include namespace nn::atk { @@ -44,4 +45,19 @@ const AudioRendererPerformanceReader::PerformanceInfo* AudioRendererPerformanceR return nullptr; } + +void AudioRendererPerformanceReader::Record(const void* performanceFrameBuffer, + size_t performanceFrameBufferSize, os::Tick tick) { + if (m_WriteIndex != m_ReadIndex) { + const int writeIndex {m_WriteIndex}; + m_pPerformanceInfo[writeIndex].tick = tick; + memcpy(m_pPerformanceInfo[writeIndex].performanceBuffer, performanceFrameBuffer, performanceFrameBufferSize); + + int nextWriteIndex {0}; + if (writeIndex + 1 < m_PerformanceInfoCount) + nextWriteIndex = writeIndex + 1; + + m_WriteIndex = nextWriteIndex; + } +} } // namespace nn::atk \ No newline at end of file From caad923221dfbc760c7210fb698ace817636bb5d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 17 Aug 2026 15:03:19 -0400 Subject: [PATCH 263/785] atk: Match `BankFile::FileHeader::GetInfoBlock` --- include/nn/atk/atk_Adpcm.h | 6 + include/nn/atk/atk_BankFile.h | 37 ++--- include/nn/atk/atk_DeviceOutRecorder.h | 142 ++++++++++++------ .../atk/detail/dsp/atk_DecodeAdpcm.cpp | 6 +- .../atk/detail/seq/atk_BankFile.cpp | 10 ++ 5 files changed, 137 insertions(+), 64 deletions(-) diff --git a/include/nn/atk/atk_Adpcm.h b/include/nn/atk/atk_Adpcm.h index c0644ff3..6949c8f6 100644 --- a/include/nn/atk/atk_Adpcm.h +++ b/include/nn/atk/atk_Adpcm.h @@ -16,4 +16,10 @@ struct AdpcmContextNotAligned { audio::AdpcmContext audioAdpcmContext; }; static_assert(sizeof(AdpcmContextNotAligned) == 0x6); + +namespace detail { +void DecodeDspAdpcm(position_t playPosition, AdpcmContext& context, + const AdpcmParam& param, const void* adpcmData, + size_t decodeSamples, s16* dest); +} } // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/atk_BankFile.h b/include/nn/atk/atk_BankFile.h index 71557aaf..bbd9ba3a 100644 --- a/include/nn/atk/atk_BankFile.h +++ b/include/nn/atk/atk_BankFile.h @@ -6,20 +6,22 @@ namespace nn::atk::detail { struct BankFile { struct InfoBlock; struct FileHeader : Util::SoundFileHeader { - - InfoBlock* GetInfoBlock() const; - + const InfoBlock* GetInfoBlock() const; }; struct Instrument; struct InfoBlockBody { - - Util::WaveIdTable* GetWaveIdTable() const; - Util::ReferenceTable GetInstrumentReferenceTable() const; - Instrument* GetInstrument(s32 programNo) const; - Util::Reference toWaveIdTable; Util::Reference toInstrumentReferenceTable; + + const Util::WaveIdTable& GetWaveIdTable() const; + const Util::ReferenceTable& GetInstrumentReferenceTable() const; + + u32 GetWaveIdCount() const; + s32 GetInstrumentCount() const; + + const Util::WaveId* GetWaveId(u32 index) const; + const Instrument* GetInstrument(int programNo) const; }; static_assert(sizeof(InfoBlockBody) == 0x10); @@ -31,37 +33,36 @@ struct BankFile { struct KeyRegion; struct Instrument { + Util::Reference toKeyRegionChunk; - KeyRegion* GetKeyRegion(u32 key) const; + const KeyRegion* GetKeyRegion(u32 key) const; - Util::Reference toKeyRegionChunk; }; static_assert(sizeof(Instrument) == 0x8); struct VelocityRegion; struct KeyRegion { + Util::Reference toVelocityRegionChunk; - VelocityRegion* GetVelocityRegion(u32 velocity) const; + const VelocityRegion* GetVelocityRegion(u32 velocity) const; - Util::Reference toVelocityRegionChunk; }; static_assert(sizeof(KeyRegion) == 0x8); struct RegionParameter; struct VelocityRegion { + u32 waveIdTableIndex; + Util::BitFlag optionParameter; u8 GetOriginalKey() const; u8 GetVolume() const; u8 GetPan() const; - f32 GetPitch() const ; + float GetPitch() const ; bool IsIgnoreNoteOff() const; u8 GetKeyGroup() const; u8 GetInterpolationType() const; - AdshrCurve* GetAdshrCurve() const; - RegionParameter* GetRegionParameter() const; - - u32 waveIdTableIndex; - Util::BitFlag optionParameter; + const AdshrCurve& GetAdshrCurve() const; + const RegionParameter* GetRegionParameter() const; }; static_assert(sizeof(VelocityRegion) == 0x8); diff --git a/include/nn/atk/atk_DeviceOutRecorder.h b/include/nn/atk/atk_DeviceOutRecorder.h index f30e79ad..2940b54b 100644 --- a/include/nn/atk/atk_DeviceOutRecorder.h +++ b/include/nn/atk/atk_DeviceOutRecorder.h @@ -11,8 +11,13 @@ #include namespace nn::atk { -class DeviceOutRecorder : detail::fnd::Thread::Handler { +class DeviceOutRecorder : public detail::fnd::Thread::Handler { + NN_NO_COPY(DeviceOutRecorder); public: + static const u32 RecordingBufferSize = 0x5a000; + static const u32 DefaultWriteBlockPerSamples = 0x10000; + static const u32 RequiredThreadStackSize = 0x10000; + enum State { State_NotInitialized, State_Initialized, @@ -27,11 +32,39 @@ class DeviceOutRecorder : detail::fnd::Thread::Handler { Message_Exit, }; - constexpr static u32 RecordingBufferSize = 0x5a000; - constexpr static u32 DefaultWriteBlockPerSamples = 0x10000; - constexpr static u32 RequiredThreadStackSize = 0x10000; + class InitializationOptions { + public: + InitializationOptions() = default; + + u32 GetPrioritiy() const { return m_Priority; } + void SetPriority(u32 value) { m_Priority = value; } + + int GetIdealCoreNumber() const { return m_IdealCoreNumber; } + void SetIdealCoreNumber(int value) { m_IdealCoreNumber = value; } + + private: + u32 m_Priority; + int m_IdealCoreNumber; + }; + static_assert(sizeof(InitializationOptions) == 0x8); + + class RecordingOptions { + public: + RecordingOptions() = default; + + u32 GetChannels() const { return m_Channels; } + void SetChannels(u32 value) { m_Channels = value; } + + bool IsLeadSilenceTrimmingEnabled() const { return m_IsLeadSilenceTrimmingEnabled; } + void SetLeadSilenceTrimmingEnabled(bool value) { m_IsLeadSilenceTrimmingEnabled = value; } - struct RecordingOptions { + u32 GetMaxFrames() const { return m_MaxFrames; } + void SetMaxFrames(u32 value) { m_MaxFrames = value; } + + u32 GetWriteBlockPerSamples() const { return m_WriteBlockPerSamples; } + void SetWriteBlockPerSamples(u32 value) { m_WriteBlockPerSamples = value; } + + private: u32 m_Channels; bool m_IsLeadSilenceTrimmingEnabled; u32 m_MaxFrames; @@ -39,12 +72,6 @@ class DeviceOutRecorder : detail::fnd::Thread::Handler { }; static_assert(sizeof(RecordingOptions) == 0x10); - struct InitializationOptions { - u32 m_Priority; - s32 m_IdealCoreNumber; - }; - static_assert(sizeof(InitializationOptions) == 0x8); - class RecorderBuffer { struct WriteState { u32 channelIndex; @@ -55,20 +82,27 @@ class DeviceOutRecorder : detail::fnd::Thread::Handler { explicit RecorderBuffer(const char* deviceName); void Initialize(s16* sampleBuffer, u32 maxSamples); - - void UpdateMaxSamples(); - - void Clear(); - void Finalize(); - + u32 Push(const s16* sampleBuffer, u32 samples); - u32 Pop(u32); - s64 Peek(); + u32 Pop(u32 samples); + s16* Peek(); - void SetReadBlockSamples(u32 readBlockSamples); + void SetReadBlockSamples(u32 value); + void Clear(); + + u32 GetReadableCount() const; + u32 GetWritableCount() const; + u32 GetContiguousReadableCount() const; + const char* GetDeviceName() const; + + void UpdateMaxSamples(); private: + void Skip(u32 samples); + void Write(const s16* sampleBuffer, u32 samples); + u32 IncrementPosition(u32 position, u32 length) const; + s16* m_SampleBuffer; u32 m_MaxBufferSamples; u32 m_MaxSamples; @@ -77,56 +111,74 @@ class DeviceOutRecorder : detail::fnd::Thread::Handler { u32 m_WritePosition; u32 m_ReadBlockSamples; WriteState m_WriteState; - char* m_DeviceName; + const char* m_DeviceName; }; static_assert(sizeof(RecorderBuffer) == 0x30); +protected: explicit DeviceOutRecorder(const char* deviceName); + +public: ~DeviceOutRecorder() override; - void Finalize(); + bool Initialize(void* recordingBuffer, size_t recordingBufferSize, + void* pThreadStack, size_t threadStackSize); + bool Initialize(void* recordingBuffer, size_t recordingBufferSize, + void* pThreadStack, size_t threadStackSize, const InitializationOptions& options); - bool Initialize(void*, size_t, void*, size_t); - bool Initialize(void*, size_t, void*, size_t, const InitializationOptions& options); + void Finalize(); - bool StartThread(u32, s32); + size_t GetRequiredMemorySizeForRecording(); - static size_t GetRequiredMemorySizeForRecording(); + bool Start(detail::fnd::FileStream& fileStream); + bool Start(detail::fnd::FileStream& fileStream, const RecordingOptions& options); - void Stop(bool); - void StopThread(); + void Stop(bool isBlocking); - bool Start(detail::fnd::FileStream&, const RecordingOptions& options); + bool IsInitialized() const; - s32 GetReadBlockSamples(u32) const; + State GetState() const; - s32 Prepare(); + bool IsLeadSilenceTrimming() const; - bool SendMessage(Message message); + u32 GetRecordingChannels() const; void RecordSamples(const s16* sampleBuffer, u32 samples); - bool PostMessage(Message message); +protected: + OutputMode GetOutputMode() const; - u32 Run(void* param) override; + virtual u32 GetMaxFrameLength() const = 0; + virtual u32 GetSamplesPerSec() const = 0; + virtual u32 GetValidChannels() const = 0; - s32 OnPrepare(); - bool OnWriteSamples(bool); - void OnRequestStop(); - void OnExit(); + virtual void OnStart(); + virtual void OnStop(); + virtual u32 OnProcessSamples(s16* sampleBuffer, u32 samples); - u64 GetLeadSilenceSamples(const s16* sampleBuffer, u32 sampleCount, u32) const; - u32 GetWritableSamples(u32) const; + s16 ResolveSampleEndian(s16 sample); + u32 Run(void* param) override; + +private: + s32 GetReadBlockSamples(u32 channels) const; + u32 GetLeadSilenceSamples(const s16* sampleBuffer, u32 samples, u32 channels) const; + u32 GetWritableSamples(u32 samples) const; bool IsNoMoreSamples() const; - void OnStart(); - void OnStop(); + bool StartThread(u32, s32); + void StopThread(); - u32 OnProcessSamples(s16* sampleBuffer, u32 samples); + s32 Prepare(); + bool SendMessage(Message message); + bool PostMessage(Message message); -private: - State m_State; + s32 OnPrepare(); + void OnRequestStop(); + void OnExit(); + bool OnWriteSamples(bool isForceWriteMode); + + volatile State m_State; u32 m_Channels; OutputMode m_OutputMode; bool m_IsLeadSilenceTrimming; diff --git a/src/NintendoWare/atk/detail/dsp/atk_DecodeAdpcm.cpp b/src/NintendoWare/atk/detail/dsp/atk_DecodeAdpcm.cpp index d05bf409..b7782589 100644 --- a/src/NintendoWare/atk/detail/dsp/atk_DecodeAdpcm.cpp +++ b/src/NintendoWare/atk/detail/dsp/atk_DecodeAdpcm.cpp @@ -3,5 +3,9 @@ namespace nn::atk::detail { void DecodeDspAdpcm(position_t playPosition, AdpcmContext& context, const AdpcmParam& param, const void* adpcmData, - size_t decodeSamples, s16* dest); + size_t decodeSamples, s16* dest) { + if (decodeSamples != 0) { + // TODO + } +} } // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp index e69de29b..ca964afa 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp @@ -0,0 +1,10 @@ +#include + +#include + +namespace nn::atk::detail { +const BankFile::InfoBlock* BankFile::FileHeader::GetInfoBlock() const { + return util::ConstBytePtr(GetBlock(ElementType_BankFile_InfoBlock)) + .Get(); +} +} // namespace nn::atk::detail \ No newline at end of file From 714e803d11f0fd22090424d866a7b5aef8089617 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 17 Aug 2026 15:05:25 -0400 Subject: [PATCH 264/785] atk: Match `BankFile::InfoBlockBody::GetWaveIdTable` --- src/NintendoWare/atk/detail/seq/atk_BankFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp index ca964afa..84604588 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp @@ -7,4 +7,9 @@ const BankFile::InfoBlock* BankFile::FileHeader::GetInfoBlock() const { return util::ConstBytePtr(GetBlock(ElementType_BankFile_InfoBlock)) .Get(); } + +const Util::WaveIdTable& BankFile::InfoBlockBody::GetWaveIdTable() const { + return *util::ConstBytePtr(this).Advance(toWaveIdTable.offset) + .Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 1fe40a06d5eca6a5a78fa59aeb71f3270d09944c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 17 Aug 2026 15:05:56 -0400 Subject: [PATCH 265/785] atk: Match `BankFile::InfoBlockBody::GetInstrumentReferenceTable` --- src/NintendoWare/atk/detail/seq/atk_BankFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp index 84604588..57a29321 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp @@ -12,4 +12,9 @@ const Util::WaveIdTable& BankFile::InfoBlockBody::GetWaveIdTable() const { return *util::ConstBytePtr(this).Advance(toWaveIdTable.offset) .Get(); } + +const Util::ReferenceTable& BankFile::InfoBlockBody::GetInstrumentReferenceTable() const { + return *util::ConstBytePtr(this).Advance(toInstrumentReferenceTable.offset) + .Get(); +} } // namespace nn::atk::detail \ No newline at end of file From bcbaf7ae312e0ac2a7cbafc50099d05ceab3efb3 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 17 Aug 2026 15:19:10 -0400 Subject: [PATCH 266/785] atk: Match `BankFile::InfoBlockBody::GetInstrument` --- include/nn/atk/atk_BankFile.h | 16 ++++++++++++---- include/nn/atk/atk_Util.h | 4 ++++ src/NintendoWare/atk/detail/seq/atk_BankFile.cpp | 10 ++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/include/nn/atk/atk_BankFile.h b/include/nn/atk/atk_BankFile.h index bbd9ba3a..2e11c87d 100644 --- a/include/nn/atk/atk_BankFile.h +++ b/include/nn/atk/atk_BankFile.h @@ -17,10 +17,18 @@ struct BankFile { const Util::WaveIdTable& GetWaveIdTable() const; const Util::ReferenceTable& GetInstrumentReferenceTable() const; - u32 GetWaveIdCount() const; - s32 GetInstrumentCount() const; - - const Util::WaveId* GetWaveId(u32 index) const; + u32 GetWaveIdCount() const { + return GetWaveIdTable().table.count; + } + + s32 GetInstrumentCount() const { + return GetInstrumentReferenceTable().count; + } + + const Util::WaveId* GetWaveId(u32 index) const { + return GetWaveIdTable().GetWaveId(index); + } + const Instrument* GetInstrument(int programNo) const; }; static_assert(sizeof(InfoBlockBody) == 0x10); diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index 4cb4f3bf..054636f6 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -197,6 +197,10 @@ struct Util { struct WaveIdTable { Table table; + + const WaveId* GetWaveId(u32 index) const { + return &table.item[index]; + } }; class WarningLogger { diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp index 57a29321..23142d1a 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp @@ -17,4 +17,14 @@ const Util::ReferenceTable& BankFile::InfoBlockBody::GetInstrumentReferenceTable return *util::ConstBytePtr(this).Advance(toInstrumentReferenceTable.offset) .Get(); } + +const BankFile::Instrument* BankFile::InfoBlockBody::GetInstrument(int programNo) const { + auto& table {GetInstrumentReferenceTable()}; + auto& ref {table.item[programNo]}; + + if (ref.IsValidTypeId(ElementType_BankFile_InstrumentInfo)) + return util::ConstBytePtr(table.GetReferedItem(programNo)).Get(); + + return nullptr; +} } // namespace nn::atk::detail \ No newline at end of file From 40c9da5b3b35e4b8c5c933357a2179a7d87e97eb Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 18 Aug 2026 14:53:37 -0400 Subject: [PATCH 267/785] atk: Match `BankFile::Instrument::GetKeyRegion` Shoutouts to https://github.com/stupidestmodder/TuneBloom, which is where the `GetRegion` logic was based from --- include/nn/atk/atk_BankFile.h | 4 +- include/nn/atk/atk_Global.h | 1 - include/nn/util/detail/util_TypeTraits.h | 5 + .../atk/detail/seq/atk_BankFile.cpp | 154 ++++++++++++++++++ 4 files changed, 160 insertions(+), 4 deletions(-) diff --git a/include/nn/atk/atk_BankFile.h b/include/nn/atk/atk_BankFile.h index 2e11c87d..f81e64fd 100644 --- a/include/nn/atk/atk_BankFile.h +++ b/include/nn/atk/atk_BankFile.h @@ -28,7 +28,7 @@ struct BankFile { const Util::WaveId* GetWaveId(u32 index) const { return GetWaveIdTable().GetWaveId(index); } - + const Instrument* GetInstrument(int programNo) const; }; static_assert(sizeof(InfoBlockBody) == 0x10); @@ -44,7 +44,6 @@ struct BankFile { Util::Reference toKeyRegionChunk; const KeyRegion* GetKeyRegion(u32 key) const; - }; static_assert(sizeof(Instrument) == 0x8); @@ -53,7 +52,6 @@ struct BankFile { Util::Reference toVelocityRegionChunk; const VelocityRegion* GetVelocityRegion(u32 velocity) const; - }; static_assert(sizeof(KeyRegion) == 0x8); diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h index e25b45bb..9ce136a8 100644 --- a/include/nn/atk/atk_Global.h +++ b/include/nn/atk/atk_Global.h @@ -156,7 +156,6 @@ struct AdshrCurve { }; static_assert(sizeof(AdshrCurve) == 0x5); -static const AdshrCurve DefaultAdshrCurve = {127, 127, 127, 127, 127}; static const AdshrCurve WsdDefaultAdshrCurve = {127, 127, 127, 127, 127}; struct BiquadFilterCoefficients { diff --git a/include/nn/util/detail/util_TypeTraits.h b/include/nn/util/detail/util_TypeTraits.h index cc0aff28..c8abc4f4 100644 --- a/include/nn/util/detail/util_TypeTraits.h +++ b/include/nn/util/detail/util_TypeTraits.h @@ -7,6 +7,11 @@ namespace nn::util::detail { template struct SizedInt; +template <> +struct SizedInt<4> { + typedef uint32_t Unsigned; +}; + template <> struct SizedInt<8> { typedef uint64_t Unsigned; diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp index 23142d1a..9f59cd74 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp @@ -3,6 +3,151 @@ #include namespace nn::atk::detail { +namespace { +const u8 DefaultOriginalKey {60}; +const u8 DefaultVolume {127}; +const u8 DefaultPan {64}; +const float DefaultPitch {1.0}; +const bool DefaultIgnoreNoteOff {false}; +const u8 DefaultKeyGroup {0}; +const u8 DefaultInterpolationType {0}; +const AdshrCurve DefaultAdshrCurve {127, 127, 127, 127, 127}; + +enum VelocityRegionBitFlag { + VelocityRegionBitFlag_Key = 0, + VelocityRegionBitFlag_Volume = 1, + VelocityRegionBitFlag_Pan = 2, + VelocityRegionBitFlag_Pitch = 3, + VelocityRegionBitFlag_InstrumentNoteParam = 4, + VelocityRegionBitFlag_Sends = 8, + VelocityRegionBitFlag_Envelope = 9, + VelocityRegionBitFlag_Randomizer = 10, + VelocityRegionBitFlag_Lfo = 11, + VelocityRegionBitFlag_BasicParamFlag = 0b01000011111 +}; + +struct DirectChunk { + Util::Reference toRegion; + + const void* GetRegion() const { + return util::ConstBytePtr(this, toRegion.offset).Get(); + } +}; +static_assert(sizeof(DirectChunk) == 0x8); + +struct RangeChunk { + Util::Table borderTable; + + const Util::Reference& GetRegionTableAddress(int index) const { + return *util::ConstBytePtr(this, sizeof(borderTable.count) + + util::align_up(borderTable.count, 4) + + sizeof(Util::Reference) * index).Get(); + } + + const void* GetRegion(u32 index) const { + bool isFoundRangeChunkIndex {false}; + u32 regionTableIndex {0}; + for (u32 i {0}; i < borderTable.count; ++i) { + if (index <= borderTable.item[i]) { + regionTableIndex = i; + isFoundRangeChunkIndex = true; + break; + } + } + + if (!isFoundRangeChunkIndex) + return nullptr; + + const Util::Reference& ref {GetRegionTableAddress(regionTableIndex)}; + return util::ConstBytePtr(this, ref.offset).Get(); + } +}; +static_assert(sizeof(RangeChunk) == 0x8); + +struct IndexChunk { + u8 min; + u8 max; + u8 reserved[2]; + Util::Reference toRegion[1]; + + const void* GetRegion(u32 index) const { + if (index >= min && index <= max) + return util::ConstBytePtr(this, toRegion[index - min].offset).Get(); + + return nullptr; + } +}; +static_assert(sizeof(IndexChunk) == 0xc); + +enum RegionType { + RegionType_Direct, + RegionType_Range, + RegionType_Index, + RegionType_Unknown +}; + +RegionType GetRegionType(u16 typeId) { + switch (typeId) { + case ElementType_BankFile_DirectReferenceTable: + return RegionType_Direct; + + case ElementType_BankFile_RangeReferenceTable: + return RegionType_Range; + + case ElementType_BankFile_IndexReferenceTable: + return RegionType_Index; + + default: + return RegionType_Unknown; + + } +} + +const void* GetDirectChunk(const void* regionChunk) { + const DirectChunk& directChunk {*reinterpret_cast(regionChunk)}; + + return directChunk.GetRegion(); +} + +const void* GetRangeChunk(const void* regionChunk, u32 index) { + const RangeChunk& rangeChunk {*reinterpret_cast(regionChunk)}; + + return rangeChunk.GetRegion(index); +} + +const void* GetIndexChunk(const void* regionChunk, u32 index) { + const IndexChunk& indexChunk {*reinterpret_cast(regionChunk)}; + + return indexChunk.GetRegion(index); +} + +const void* GetRegion(const void* startPtr, u16 typeId, u32 offset, u32 index) { + const void* regionChunk {util::ConstBytePtr(startPtr, offset).Get()}; + const void* region {nullptr}; + + switch (GetRegionType(typeId)) { + case RegionType_Direct: + region = GetDirectChunk(regionChunk); + break; + + case RegionType_Range: + region = GetRangeChunk(regionChunk, index); + break; + + case RegionType_Index: + region = GetIndexChunk(regionChunk, index); + break; + + case RegionType_Unknown: + default: + region = nullptr; + break; + } + + return region; +} +} // anonymous namespace + const BankFile::InfoBlock* BankFile::FileHeader::GetInfoBlock() const { return util::ConstBytePtr(GetBlock(ElementType_BankFile_InfoBlock)) .Get(); @@ -27,4 +172,13 @@ const BankFile::Instrument* BankFile::InfoBlockBody::GetInstrument(int programNo return nullptr; } + +const BankFile::KeyRegion* BankFile::Instrument::GetKeyRegion(u32 key) const { + return util::ConstBytePtr( + GetRegion(this, + toKeyRegionChunk.typeId, + toKeyRegionChunk.offset, + key) + ).Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 6179b45bb54289521308468a23bf56de2a194159 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 18 Aug 2026 14:54:14 -0400 Subject: [PATCH 268/785] atk: Match `BankFile::KeyRegion::GetVelocityRegion` --- src/NintendoWare/atk/detail/seq/atk_BankFile.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp index 9f59cd74..64b5ce00 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp @@ -181,4 +181,13 @@ const BankFile::KeyRegion* BankFile::Instrument::GetKeyRegion(u32 key) const { key) ).Get(); } + +const BankFile::VelocityRegion* BankFile::KeyRegion::GetVelocityRegion(u32 velocity) const { + return util::ConstBytePtr( + GetRegion(this, + toVelocityRegionChunk.typeId, + toVelocityRegionChunk.offset, + velocity) + ).Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 2a4063be694b7f78ca2e84f0b7b9b91bdb410a65 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 18 Aug 2026 16:20:46 -0400 Subject: [PATCH 269/785] atk: Match `BankFile::VelocityRegion::GetOriginalKey` `detail::Util::BitFlag` logic based on `nw::snd::internal::Util::BitFlag` from https://github.com/stupidestmodder/TuneBloom/blob/master/TuneBloom/include/snd/snd_Util.h --- include/nn/atk/atk_Util.h | 40 ++++++++++++++++++- .../atk/detail/seq/atk_BankFile.cpp | 9 +++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index 054636f6..a5fd7141 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -161,9 +161,45 @@ struct Util { }; struct BitFlag { - constexpr static u32 BitNumberMax = 31; - u32 bitFlag; + + bool GetValue(u32* value, u32 bitNumber) const { + u32 count {GetTrueCount(bitNumber)}; + if (count == 0) + return false; + + *value = (&bitFlag)[count]; + return true; + } + + bool GetValueF32(float* value, u32 bitNumber) const { + u32 count {GetTrueCount(bitNumber)}; + if (count == 0) + return false; + + *value = reinterpret_cast(&bitFlag)[count]; + return true; + } + + private: + static const int BitNumberMax = 31; + u32 GetTrueCount(u32 bitNumber) const { + int count {0}; + + bool ret {false}; + for (u32 i {0}; i <= bitNumber; ++i) { + if ((bitFlag & (1 << i)) != 0) { + ++count; + if (i == bitNumber) + ret = true; + } + } + + if (ret) + return count; + + return 0; + } }; static_assert(sizeof(BitFlag) == 0x4); diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp index 64b5ce00..58cfaab9 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp @@ -190,4 +190,13 @@ const BankFile::VelocityRegion* BankFile::KeyRegion::GetVelocityRegion(u32 veloc velocity) ).Get(); } + +u8 BankFile::VelocityRegion::GetOriginalKey() const { + u32 value; + bool result {optionParameter.GetValue(&value, VelocityRegionBitFlag_Key)}; + if (result) + return value; + + return DefaultOriginalKey; +} } // namespace nn::atk::detail \ No newline at end of file From ac1a3b7eb88a85d491586404f56ead9b41d467f5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 18 Aug 2026 16:21:20 -0400 Subject: [PATCH 270/785] atk: Match `BankFile::VelocityRegion::GetVolume` --- src/NintendoWare/atk/detail/seq/atk_BankFile.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp index 58cfaab9..8023759b 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp @@ -199,4 +199,13 @@ u8 BankFile::VelocityRegion::GetOriginalKey() const { return DefaultOriginalKey; } + +u8 BankFile::VelocityRegion::GetVolume() const { + u32 value; + bool result {optionParameter.GetValue(&value, VelocityRegionBitFlag_Volume)}; + if (result) + return value; + + return DefaultVolume; +} } // namespace nn::atk::detail \ No newline at end of file From af911abb0f4f46d2f8916a925704098e07bc9b34 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 18 Aug 2026 16:21:53 -0400 Subject: [PATCH 271/785] atk: Match `BankFile::VelocityRegion::GetPan` --- src/NintendoWare/atk/detail/seq/atk_BankFile.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp index 8023759b..317e7c66 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp @@ -208,4 +208,13 @@ u8 BankFile::VelocityRegion::GetVolume() const { return DefaultVolume; } + +u8 BankFile::VelocityRegion::GetPan() const { + u32 value; + bool result {optionParameter.GetValue(&value, VelocityRegionBitFlag_Pan)}; + if (result) + return value; + + return DefaultPan; +} } // namespace nn::atk::detail \ No newline at end of file From f80e60c20810d0f645a607297b95190a27640096 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 18 Aug 2026 16:22:45 -0400 Subject: [PATCH 272/785] atk: Match `BankFile::VelocityRegion::GetPitch` --- src/NintendoWare/atk/detail/seq/atk_BankFile.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp index 317e7c66..78b7d7a0 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp @@ -217,4 +217,13 @@ u8 BankFile::VelocityRegion::GetPan() const { return DefaultPan; } + +float BankFile::VelocityRegion::GetPitch() const { + float value; + bool result {optionParameter.GetValueF32(&value, VelocityRegionBitFlag_Pitch)}; + if (result) + return value; + + return DefaultPitch; +} } // namespace nn::atk::detail \ No newline at end of file From a6c2854cab415ae0b8a3e61835eb7d8547ccea7f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 18 Aug 2026 16:32:21 -0400 Subject: [PATCH 273/785] atk: Match `BankFile::VelocityRegion::IsIgnoreNoteOff` --- src/NintendoWare/atk/detail/seq/atk_BankFile.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp index 78b7d7a0..0eb50626 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp @@ -226,4 +226,13 @@ float BankFile::VelocityRegion::GetPitch() const { return DefaultPitch; } + +bool BankFile::VelocityRegion::IsIgnoreNoteOff() const { + u32 value; + bool result {optionParameter.GetValue(&value, VelocityRegionBitFlag_InstrumentNoteParam)}; + if (result) + return static_cast(value) != 0; + + return DefaultIgnoreNoteOff; +} } // namespace nn::atk::detail \ No newline at end of file From 1113cd45c956bd5432413ec8e36d389bef3d737d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 18 Aug 2026 16:46:58 -0400 Subject: [PATCH 274/785] atk: Match `BankFile::VelocityRegion::GetRegionParameter` --- .../atk/detail/seq/atk_BankFile.cpp | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp index 0eb50626..1e047948 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp @@ -1,6 +1,8 @@ #include #include +#include "nn/atk/atk_Global.h" +#include "nn/util/util_BytePtr.h" namespace nn::atk::detail { namespace { @@ -235,4 +237,29 @@ bool BankFile::VelocityRegion::IsIgnoreNoteOff() const { return DefaultIgnoreNoteOff; } + +u8 BankFile::VelocityRegion::GetKeyGroup() const { + u32 value; + bool result {optionParameter.GetValue(&value, VelocityRegionBitFlag_InstrumentNoteParam)}; + if (result) + return value >> 8; + + return DefaultKeyGroup; +} + +u8 BankFile::VelocityRegion::GetInterpolationType() const { + u32 value; + bool result {optionParameter.GetValue(&value, VelocityRegionBitFlag_InstrumentNoteParam)}; + if (result) + return value >> 16; + + return DefaultInterpolationType; +} + +const BankFile::RegionParameter* BankFile::VelocityRegion::GetRegionParameter() const { + if (optionParameter.bitFlag != VelocityRegionBitFlag_BasicParamFlag) + return nullptr; + + return util::ConstBytePtr(this, sizeof(VelocityRegion)).Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 897a64046f441fc867c6185313ab688e36348b25 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 18 Aug 2026 16:53:11 -0400 Subject: [PATCH 275/785] atk: Match `BankFile::VelocityRegion::GetAdshrCurve` This matches all exported functions in `BankFile` --- src/NintendoWare/atk/detail/seq/atk_BankFile.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp index 1e047948..6614d21c 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp @@ -256,6 +256,17 @@ u8 BankFile::VelocityRegion::GetInterpolationType() const { return DefaultInterpolationType; } +const AdshrCurve& BankFile::VelocityRegion::GetAdshrCurve() const { + u32 offsetToReference; + bool result {optionParameter.GetValue(&offsetToReference, VelocityRegionBitFlag_Envelope)}; + if (result) { + const auto& ref {*util::ConstBytePtr(this, offsetToReference).Get()}; + return *util::ConstBytePtr(&ref, ref.offset).Get(); + } + + return DefaultAdshrCurve; +} + const BankFile::RegionParameter* BankFile::VelocityRegion::GetRegionParameter() const { if (optionParameter.bitFlag != VelocityRegionBitFlag_BasicParamFlag) return nullptr; From 340203da5fe8a86fc7b5c68bfee93d6f2c4eb10d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 18 Aug 2026 17:15:51 -0400 Subject: [PATCH 276/785] atk: Match `SequenceSoundFile::FileHeader::GetDataBlock` --- include/nn/atk/atk_SequenceSoundFile.h | 43 ++++++++++--------- include/nn/atk/atk_Util.h | 8 ++-- .../atk/detail/seq/atk_BankFile.cpp | 2 - .../atk/detail/seq/atk_SequenceSoundFile.cpp | 10 +++++ 4 files changed, 37 insertions(+), 26 deletions(-) diff --git a/include/nn/atk/atk_SequenceSoundFile.h b/include/nn/atk/atk_SequenceSoundFile.h index 934ef485..468c6d2a 100644 --- a/include/nn/atk/atk_SequenceSoundFile.h +++ b/include/nn/atk/atk_SequenceSoundFile.h @@ -7,27 +7,32 @@ struct SequenceSoundFile { struct DataBlock; struct LabelBlock; struct FileHeader : Util::SoundFileHeader { + const DataBlock* GetDataBlock() const; + const LabelBlock* GetLabelBlock() const; + }; + + struct DataBlockBody { + u8 sequenceData[1]; - DataBlock* GetDataBlock() const; - LabelBlock* GetLabelBlock() const; + const void* GetSequenceData() const; }; - struct LabelInfo { - Util::Reference referToSequenceData; - u32 labelStringLength; - char label[1]; + struct DataBlock { + BinaryBlockHeader header; + DataBlockBody body; }; + struct LabelInfo; struct LabelBlockBody { + Util::ReferenceTable labelInfoReferenceTable; - LabelInfo* GetLabelInfo(s32 index) const; - char* GetLabel(s32 index) const; - char* GetLabelByOffest(s32 labelOffset) const; - - u32 GetOffset(s32 index, u32* offsetPtr) const; - bool GetOffsetByLabel(char* label, u32* offsetPtr) const; + int GetLabelCount() const { return labelInfoReferenceTable.count; }; + const LabelInfo* GetLabelInfo(int index) const; + const char* GetLabel(int index) const; + const char* GetLabelByOffset(u32 offset) const; - Util::ReferenceTable labelInfoReferenceTable; + bool GetOffset(int index, u32* offsetPtr) const; + bool GetOffsetByLabel(const char* label, u32* offsetPtr) const; }; struct LabelBlock { @@ -35,13 +40,11 @@ struct SequenceSoundFile { LabelBlockBody body; }; - struct DataBlockBody { - u8 sequenceData[1]; - }; - - struct DataBlock { - BinaryBlockHeader header; - DataBlockBody body; + struct LabelInfo { + Util::Reference referToSequenceData; + u32 labelStringLength; + char label[1]; }; + static_assert(sizeof(LabelInfo) == 0x10); }; } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index a5fd7141..c04cfbfd 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -82,7 +82,7 @@ struct Util { const void* GetReferedItem(const void* origin, u16 typeId, u16 count) const { auto* ref {GetReference(typeId, count)}; if (ref != nullptr && ref->offset != 0) - return util::ConstBytePtr(origin).Advance(ref->offset).Get(); + return util::ConstBytePtr(origin, ref->offset).Get(); return nullptr; } @@ -133,14 +133,14 @@ struct Util { struct ReferenceTable : Table { const void* GetReferedItem(u32 index) const { if (count > index) - return util::ConstBytePtr(this).Advance(item[index].offset).Get(); + return util::ConstBytePtr(this, item[index].offset).Get(); return nullptr; } const void* GetReferedItem(u32 index, u16 typeId) const { if (count > index && item[index].typeId == typeId) - return util::ConstBytePtr(this).Advance(item[index].offset).Get(); + return util::ConstBytePtr(this,item[index].offset).Get(); return nullptr; } @@ -151,7 +151,7 @@ struct Util { struct ReferenceWithSizeTable : Table { const void* GetReferedItem(u32 index) const { if (count > index) - return util::ConstBytePtr(this).Advance(item[index].offset).Get(); + return util::ConstBytePtr(this, item[index].offset).Get(); return nullptr; } diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp index 6614d21c..866c64a5 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp @@ -1,8 +1,6 @@ #include #include -#include "nn/atk/atk_Global.h" -#include "nn/util/util_BytePtr.h" namespace nn::atk::detail { namespace { diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp index e69de29b..e1a25d70 100644 --- a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp @@ -0,0 +1,10 @@ +#include + +#include + +namespace nn::atk::detail { +const SequenceSoundFile::DataBlock* SequenceSoundFile::FileHeader::GetDataBlock() const { + return util::ConstBytePtr(GetBlock(ElementType_SequenceSoundFile_DataBlock)) + .Get(); +} +} // namespace nn::atk::detail \ No newline at end of file From d1d599aab65b3e76d1b768941ac67d49b5b39548 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 18 Aug 2026 17:16:24 -0400 Subject: [PATCH 277/785] atk: Match `SequenceSoundFile::FileHeader::GetLabelBlock` --- src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp index e1a25d70..be47bdc9 100644 --- a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp @@ -7,4 +7,9 @@ const SequenceSoundFile::DataBlock* SequenceSoundFile::FileHeader::GetDataBlock( return util::ConstBytePtr(GetBlock(ElementType_SequenceSoundFile_DataBlock)) .Get(); } + +const SequenceSoundFile::LabelBlock* SequenceSoundFile::FileHeader::GetLabelBlock() const { + return util::ConstBytePtr(GetBlock(ElementType_SequenceSoundFile_LabelBlock)) + .Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 4e8303317e70c77c605defb4fd0d56508aebf93a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 18 Aug 2026 17:29:06 -0400 Subject: [PATCH 278/785] atk: Match `SequenceSoundFile::LabelBlockBody::GetLabelInfo` --- include/nn/atk/atk_SequenceSoundFile.h | 2 +- src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp | 4 ++++ .../atk/util/atk_AudioRendererPerformanceReader.cpp | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_SequenceSoundFile.h b/include/nn/atk/atk_SequenceSoundFile.h index 468c6d2a..7b45d622 100644 --- a/include/nn/atk/atk_SequenceSoundFile.h +++ b/include/nn/atk/atk_SequenceSoundFile.h @@ -14,7 +14,7 @@ struct SequenceSoundFile { struct DataBlockBody { u8 sequenceData[1]; - const void* GetSequenceData() const; + const void* GetSequenceData() const { return &sequenceData; }; }; struct DataBlock { diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp index be47bdc9..7a0d6a9c 100644 --- a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp @@ -12,4 +12,8 @@ const SequenceSoundFile::LabelBlock* SequenceSoundFile::FileHeader::GetLabelBloc return util::ConstBytePtr(GetBlock(ElementType_SequenceSoundFile_LabelBlock)) .Get(); } + +const SequenceSoundFile::LabelInfo* SequenceSoundFile::LabelBlockBody::GetLabelInfo(int index) const { + return util::ConstBytePtr(labelInfoReferenceTable.GetReferedItem(index)).Get(); +} } // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp b/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp index f6e24831..84bead06 100644 --- a/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp +++ b/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp @@ -1,5 +1,7 @@ #include +#include + #include namespace nn::atk { From 812c9c988f3beaed382500711cb09ba7c4479882 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 18 Aug 2026 17:34:12 -0400 Subject: [PATCH 279/785] atk: Match `SequenceSoundFile::LabelBlockBody::GetLabel` --- include/nn/atk/atk_SequenceSoundFile.h | 3 ++- src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_SequenceSoundFile.h b/include/nn/atk/atk_SequenceSoundFile.h index 7b45d622..a2e0612c 100644 --- a/include/nn/atk/atk_SequenceSoundFile.h +++ b/include/nn/atk/atk_SequenceSoundFile.h @@ -26,7 +26,8 @@ struct SequenceSoundFile { struct LabelBlockBody { Util::ReferenceTable labelInfoReferenceTable; - int GetLabelCount() const { return labelInfoReferenceTable.count; }; + int GetLabelCount() const { return labelInfoReferenceTable.count; } + const LabelInfo* GetLabelInfo(int index) const; const char* GetLabel(int index) const; const char* GetLabelByOffset(u32 offset) const; diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp index 7a0d6a9c..acc5cbb8 100644 --- a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp @@ -16,4 +16,9 @@ const SequenceSoundFile::LabelBlock* SequenceSoundFile::FileHeader::GetLabelBloc const SequenceSoundFile::LabelInfo* SequenceSoundFile::LabelBlockBody::GetLabelInfo(int index) const { return util::ConstBytePtr(labelInfoReferenceTable.GetReferedItem(index)).Get(); } + +const char* SequenceSoundFile::LabelBlockBody::GetLabel(int index) const { + const LabelInfo* labelInfo {GetLabelInfo(index)}; + return labelInfo->label; +} } // namespace nn::atk::detail \ No newline at end of file From 2bda1920b05bed48295bd04c3b8300f03325fb30 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 18 Aug 2026 17:38:23 -0400 Subject: [PATCH 280/785] atk: Match `SequenceSoundFile::LabelBlockBody::GetLabelByOffset` --- .../atk/detail/seq/atk_SequenceSoundFile.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp index acc5cbb8..a4b177d5 100644 --- a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp @@ -21,4 +21,14 @@ const char* SequenceSoundFile::LabelBlockBody::GetLabel(int index) const { const LabelInfo* labelInfo {GetLabelInfo(index)}; return labelInfo->label; } + +const char* SequenceSoundFile::LabelBlockBody::GetLabelByOffset(u32 offset) const { + for (int i {0}; i < GetLabelCount(); ++i) { + const LabelInfo* labelInfo {GetLabelInfo(i)}; + if (labelInfo->referToSequenceData.offset == offset) + return labelInfo->label; + } + + return nullptr; +} } // namespace nn::atk::detail \ No newline at end of file From d9dfa62c40b7cf862c4e6fc3a87c79a15e8a3ee5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 18 Aug 2026 17:40:54 -0400 Subject: [PATCH 281/785] atk: Match `SequenceSoundFile::LabelBlockBody::GetOffset` --- src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp index a4b177d5..88e9be33 100644 --- a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp @@ -31,4 +31,10 @@ const char* SequenceSoundFile::LabelBlockBody::GetLabelByOffset(u32 offset) cons return nullptr; } + +bool SequenceSoundFile::LabelBlockBody::GetOffset(int index, u32* offsetPtr) const { + const LabelInfo* labelInfo {GetLabelInfo(index)}; + *offsetPtr = labelInfo->referToSequenceData.offset; + return true; +} } // namespace nn::atk::detail \ No newline at end of file From 94698f032fe6c29072f40cc54c45006c3fde6ed3 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 18 Aug 2026 17:49:45 -0400 Subject: [PATCH 282/785] atk: Match `SequenceSoundFile::LabelBlockBody::GetOffsetByLabel` This matches all exported functions in `SequenceSoundFile` --- .../atk/detail/seq/atk_SequenceSoundFile.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp index 88e9be33..bf331b9d 100644 --- a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp @@ -1,5 +1,7 @@ #include +#include + #include namespace nn::atk::detail { @@ -37,4 +39,17 @@ bool SequenceSoundFile::LabelBlockBody::GetOffset(int index, u32* offsetPtr) con *offsetPtr = labelInfo->referToSequenceData.offset; return true; } + +bool SequenceSoundFile::LabelBlockBody::GetOffsetByLabel(const char* label, u32* offsetPtr) const { + const size_t labelLength {strlen(label)}; + for (int i {0}; i < GetLabelCount(); ++i) { + const LabelInfo* labelInfo {GetLabelInfo(i)}; + if (strncmp(label, labelInfo->label, labelLength) == 0) { + *offsetPtr = labelInfo->referToSequenceData.offset; + return true; + } + } + + return false; +} } // namespace nn::atk::detail \ No newline at end of file From 9e18a5b80f5a0b55a1e80602c6e6f589c37e7765 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 18 Aug 2026 18:03:17 -0400 Subject: [PATCH 283/785] atk: Match `AddonSoundArchiveContainer::Finalize` --- .../detail/atk_AddonSoundArchiveContainer.h | 37 ++++++++++++++----- .../detail/atk_AddonSoundArchiveContainer.cpp | 10 +++++ 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h b/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h index cf2453bc..69173b4c 100644 --- a/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h +++ b/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h @@ -12,30 +12,47 @@ class AddonSoundArchive; namespace detail { class AddonSoundArchiveContainer { public: - constexpr static s32 SoundArchiveNameCountMax = 64; - AddonSoundArchiveContainer(); ~AddonSoundArchiveContainer(); - bool Initialize(const char* name, - const AddonSoundArchive* pAddonSoundArchive, + bool Initialize(const char* soundArchiveName, + const AddonSoundArchive* pSoundArchive, const SoundDataManager* pSoundDataManager); void Finalize(); bool IsSameName(const char* name) const; - void SetAddTick(const os::Tick& addTick); + bool IsActive() const { + return m_IsActive; + } + + const SoundArchive* GetSoundArchive() const { + return m_pSoundArchive; + } + + const SoundDataManager* GetSoundDataManager() const { + return m_pSoundDataManager; + } + + const char* GetSoundArchiveName() const { + return m_SoundArchiveName; + } + + void SetAddTick(const os::Tick& tick); + + os::Tick GetAddTick() const { return m_AddTick; } + static const int SoundArchiveNameLengthMax = 64; util::IntrusiveListNode m_ElementLink; private: - bool m_IsActive; + bool m_IsActive {false}; u8 m_Padding[3]; - SoundArchive* m_pSoundArchive; - SoundDataManager* m_pSoundDataManager; - char m_SoundArchiveName[SoundArchiveNameCountMax]; - os::Tick m_AddTick; + const SoundArchive* m_pSoundArchive {}; + const SoundDataManager* m_pSoundDataManager {}; + char m_SoundArchiveName[SoundArchiveNameLengthMax]; + os::Tick m_AddTick {0}; }; static_assert(sizeof(AddonSoundArchiveContainer) == 0x70); } // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp b/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp index e69de29b..2a4ac7a0 100644 --- a/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp +++ b/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp @@ -0,0 +1,10 @@ +#include + +namespace nn::atk::detail { +void AddonSoundArchiveContainer::Finalize() { + m_IsActive = false; + m_SoundArchiveName[0] = '\0'; + m_pSoundArchive = nullptr; + m_pSoundDataManager = nullptr; +} +} // namespace nn::atk::detail \ No newline at end of file From 63e56cf112fa48abc93e6ddfe5614d9e39349160 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 18 Aug 2026 18:04:37 -0400 Subject: [PATCH 284/785] atk: Match `AddonSoundArchiveContainer` constructor --- src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp b/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp index 2a4ac7a0..0ca3b757 100644 --- a/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp +++ b/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp @@ -1,6 +1,8 @@ #include namespace nn::atk::detail { +AddonSoundArchiveContainer::AddonSoundArchiveContainer() = default; + void AddonSoundArchiveContainer::Finalize() { m_IsActive = false; m_SoundArchiveName[0] = '\0'; From ba4deee4abe56acfbe56ff7ad2c3226fcb21c1ef Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 18 Aug 2026 18:07:22 -0400 Subject: [PATCH 285/785] atk: Match `AddonSoundArchiveContainer` destructor --- .../atk/detail/atk_AddonSoundArchiveContainer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp b/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp index 0ca3b757..52699290 100644 --- a/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp +++ b/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp @@ -3,6 +3,12 @@ namespace nn::atk::detail { AddonSoundArchiveContainer::AddonSoundArchiveContainer() = default; +AddonSoundArchiveContainer::~AddonSoundArchiveContainer() { + m_IsActive = false; + m_pSoundArchive = nullptr; + m_pSoundDataManager = nullptr; +} + void AddonSoundArchiveContainer::Finalize() { m_IsActive = false; m_SoundArchiveName[0] = '\0'; From c7b3f9d1e779e50d7d1fc17e7b5e54f4e060709c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 11:26:15 -0400 Subject: [PATCH 286/785] atk: Match `detail::DecodeDspAdpcm` Implementation heavily based on [TuneBloom's](https://github.com/stupidestmodder/TuneBloom/blob/master/TuneBloom/src/snd-ply/DecodeAdpcm.cpp) --- include/nn/atk/atk_SoundArchive.h | 9 +++ include/nn/atk/atk_SoundArchiveFilesHook.h | 41 ++++++++---- .../detail/atk_AddonSoundArchiveContainer.h | 8 +-- .../atk/detail/dsp/atk_DecodeAdpcm.cpp | 66 +++++++++++++++++-- 4 files changed, 102 insertions(+), 22 deletions(-) diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index 27f9da46..1dc998cb 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -9,6 +9,11 @@ namespace detail{ class SoundArchiveFileReader; class SoundArchiveParametersHook; struct SoundArchiveFilesHook; + +namespace driver { +class StreamSoundLoader; +} + } // namespace nn::atk::detail class SoundArchive { @@ -280,10 +285,14 @@ class SoundArchive { static const s32 FilePathMax = 639; private: + friend detail::driver::StreamSoundLoader; + detail::SoundArchiveFileReader* m_pFileReader{}; detail::SoundArchiveParametersHook* m_pParametersHook{}; char m_ExtFileRoot[FilePathMax]; u32 m_FileBlockOffset; }; static_assert(sizeof(SoundArchive) == 0x2a0); + +class AddonSoundArchive : public SoundArchive {}; } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/atk_SoundArchiveFilesHook.h b/include/nn/atk/atk_SoundArchiveFilesHook.h index 188bb9b2..0c1d94ea 100644 --- a/include/nn/atk/atk_SoundArchiveFilesHook.h +++ b/include/nn/atk/atk_SoundArchiveFilesHook.h @@ -1,16 +1,35 @@ #pragma once +#include +#include + namespace nn::atk::detail { -struct SoundArchiveFilesHook { - constexpr static const char* ItemTypeStreamSound = "stm"; - constexpr static const char* ItemTypeWaveSound = "wsd"; - constexpr static const char* ItemTypeSequenceSound = "seq"; - - constexpr static const char* FileTypeStreamBinary = "bxstm"; - constexpr static const char* FileTypeWaveSoundBinary = "bxwsd"; - constexpr static const char* FileTypeSequenceBinary = "bxseq"; - constexpr static const char* FileTypeBankBinary = "bxbnk"; - constexpr static const char* FileTypeWaveArchiveBinary = "bxwar"; - constexpr static const char* FileTypeStreamPrefetchBinary = "bxstp"; +class SoundArchiveFilesHook { +public: + constexpr static const char ItemTypeWaveSound[] = "wsd"; + constexpr static const char ItemTypeStreamSound[] = "stm"; + constexpr static const char ItemTypeSequenceSound[] = "seq"; + + constexpr static const char FileTypeStreamBinary[] = "bxstm"; + constexpr static const char FileTypeWaveSoundBinary[] = "bxwsd"; + constexpr static const char FileTypeSequenceBinary[] = "bxseq"; + constexpr static const char FileTypeBankBinary[] = "bxbnk"; + constexpr static const char FileTypeWaveArchiveBinary[] = "bxwar"; + constexpr static const char FileTypeStreamPrefetchBinary[] = "bxstp"; + + bool GetIsEnable() const; + void SetIsEnable(bool value); + + bool IsTargetItem(const char* itemLabel); + + void Lock(); + void Unlock(); + + fnd::FileStream* OpenFile(void* buffer, size_t bufferLength, void* cacheBuffer, size_t cacheBufferLength, const char* itemLabel, const char* fileType); + + const void* GetFileAddress(const char* itemLabel, const char* itemType, const char* fileType, u32 fileIndex); + +private: + bool m_IsEnable; }; } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h b/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h index 69173b4c..44acf8e8 100644 --- a/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h +++ b/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h @@ -6,10 +6,7 @@ #include #include -namespace nn::atk { -class AddonSoundArchive; - -namespace detail { +namespace nn::atk::detail { class AddonSoundArchiveContainer { public: AddonSoundArchiveContainer(); @@ -55,5 +52,4 @@ class AddonSoundArchiveContainer { os::Tick m_AddTick {0}; }; static_assert(sizeof(AddonSoundArchiveContainer) == 0x70); -} // namespace nn::atk::detail -} // namespace nn::atk \ No newline at end of file +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/dsp/atk_DecodeAdpcm.cpp b/src/NintendoWare/atk/detail/dsp/atk_DecodeAdpcm.cpp index b7782589..fa33e6bb 100644 --- a/src/NintendoWare/atk/detail/dsp/atk_DecodeAdpcm.cpp +++ b/src/NintendoWare/atk/detail/dsp/atk_DecodeAdpcm.cpp @@ -1,11 +1,67 @@ #include namespace nn::atk::detail { -void DecodeDspAdpcm(position_t playPosition, AdpcmContext& context, - const AdpcmParam& param, const void* adpcmData, - size_t decodeSamples, s16* dest) { - if (decodeSamples != 0) { - // TODO +void DecodeDspAdpcm(position_t playPosition, + AdpcmContext& context, + const AdpcmParam& param, + const void* adpcmData, + size_t decodeSamples, + s16* dest) +{ + position_t frame = playPosition / 14; + position_t frameFrac = playPosition - frame * 14; + const u8* frameBegin = reinterpret_cast(adpcmData) + (frame * 8); + + s32 pred = context.audioAdpcmContext.predScale >> 4; + s32 scale = context.audioAdpcmContext.predScale & 0xF; + + for (u32 i {0}; i < decodeSamples; ++i) { + if (frameFrac == 0) { + const u8 pred_scale = *frameBegin; + context.audioAdpcmContext.predScale = pred_scale; + pred = pred_scale >> 4; + scale = pred_scale & 0xF; + } + + u8 code = frameBegin[frameFrac / 2 + 1]; + if (frameFrac & 1) + code &= 0xF; + else + code >>= 4; + + s16 nibble = code; + nibble <<= 12; + nibble >>= 1; + + s16 a1 = static_cast(param.coefficients[pred * 2 + 0]); + s16 a2 = static_cast(param.coefficients[pred * 2 + 1]); + s16 gain = static_cast(1 << scale); + + s32 val = a1 * context.audioAdpcmContext.history[0]; + val += a2 * context.audioAdpcmContext.history[1]; + val += gain * nibble; + val >>= 10; + val += 1; + val >>= 1; + + if (val > SHRT_MAX) + val = SHRT_MAX; + else if (val < SHRT_MIN) + val = SHRT_MIN; + + s16 smp = static_cast(val); + + context.audioAdpcmContext.history[1] = context.audioAdpcmContext.history[0]; + context.audioAdpcmContext.history[0] = smp; + + *dest = smp; + ++dest; + + ++frameFrac; + if (frameFrac == 14) { + frameBegin += 8; + frameFrac = 0; + } } } } // namespace nn::atk::detail \ No newline at end of file From 241d35f1ebcba5819cb8d2f89a1eac0dd82b35cb Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 11:37:36 -0400 Subject: [PATCH 287/785] atk: Move files to the correct paths --- CMakeLists.txt | 7 ++++--- include/nn/atk/fnd/basis/atkfnd_PrimitiveTypes.h | 8 -------- include/nn/atk/fnd/binary/atkfnd_PrimitiveTypes.h | 9 ++++++++- include/nn/atk/fnd/{io => os}/atkfnd_ScopedLock.h | 0 4 files changed, 12 insertions(+), 12 deletions(-) delete mode 100644 include/nn/atk/fnd/basis/atkfnd_PrimitiveTypes.h rename include/nn/atk/fnd/{io => os}/atkfnd_ScopedLock.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index c6f82c75..3bfa6a17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -293,7 +293,6 @@ add_library(NintendoSDK OBJECT src/NintendoSDK/nvn/nvn_Impl.cpp ) - # Atk Sources target_sources(NintendoSDK PUBLIC @@ -431,19 +430,21 @@ PUBLIC include/nn/atk/fnd/basis/atkfnd_Config.h include/nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h include/nn/atk/fnd/basis/atkfnd_HeapBase.h - include/nn/atk/fnd/basis/atkfnd_PrimitiveTypes.h + include/nn/atk/fnd/basis/atkfnd_Inlines.h include/nn/atk/fnd/basis/atkfnd_Result.h include/nn/atk/fnd/basis/atkfnd_RuntimeTypeInfo.h include/nn/atk/fnd/basis/atkfnd_Time.h include/nn/atk/fnd/basis/atkfnd_WorkBufferAllocator.h + include/nn/atk/fnd/binary/atkfnd_PrimitiveTypes.h include/nn/atk/fnd/io/atkfnd_FileStream.h include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h - include/nn/atk/fnd/io/atkfnd_ScopedLock.h include/nn/atk/fnd/io/atkfnd_Stream.h include/nn/atk/fnd/io/atkfnd_StreamCache.h include/nn/atk/fnd/os/atkfnd_CriticalSection.h + include/nn/atk/fnd/os/atkfnd_ScopedLock.h include/nn/atk/fnd/os/atkfnd_Thread.h + include/nn/atk/fnd/string/atkfnd_String.h PRIVATE src/NintendoWare/atk/atk_SoundArchive.cpp diff --git a/include/nn/atk/fnd/basis/atkfnd_PrimitiveTypes.h b/include/nn/atk/fnd/basis/atkfnd_PrimitiveTypes.h deleted file mode 100644 index ab767f25..00000000 --- a/include/nn/atk/fnd/basis/atkfnd_PrimitiveTypes.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include - -namespace nn::atk::detail::fnd { -using PcBinU16 = std::uint16_t; -using PcBinU32 = std::uint32_t; -} // namespace nn::atk::detail::fnd \ No newline at end of file diff --git a/include/nn/atk/fnd/binary/atkfnd_PrimitiveTypes.h b/include/nn/atk/fnd/binary/atkfnd_PrimitiveTypes.h index 7b9637ef..ab767f25 100644 --- a/include/nn/atk/fnd/binary/atkfnd_PrimitiveTypes.h +++ b/include/nn/atk/fnd/binary/atkfnd_PrimitiveTypes.h @@ -1 +1,8 @@ -#pragma once \ No newline at end of file +#pragma once + +#include + +namespace nn::atk::detail::fnd { +using PcBinU16 = std::uint16_t; +using PcBinU32 = std::uint32_t; +} // namespace nn::atk::detail::fnd \ No newline at end of file diff --git a/include/nn/atk/fnd/io/atkfnd_ScopedLock.h b/include/nn/atk/fnd/os/atkfnd_ScopedLock.h similarity index 100% rename from include/nn/atk/fnd/io/atkfnd_ScopedLock.h rename to include/nn/atk/fnd/os/atkfnd_ScopedLock.h From 9af3b6b4e99801ad2efe6df9bd20da5361bb4e77 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 11:41:20 -0400 Subject: [PATCH 288/785] atk: Match `SoundArchive::GetItemPrefetchFileId` --- src/NintendoWare/atk/atk_SoundArchive.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index e4dcc761..38bd3d7a 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -81,4 +81,8 @@ SoundArchive::ItemId SoundArchive::GetItemId(const char* pStr) const { SoundArchive::FileId SoundArchive::GetItemFileId(ItemId id) const { return m_pFileReader->GetItemFileId(id); } + +SoundArchive::FileId SoundArchive::GetItemPrefetchFileId(ItemId id) const { + return m_pFileReader->GetItemPrefetchFileId(id); +} } // namespace nn::atk \ No newline at end of file From d46699c2741aab199c3a7eb21034a6e3172124a3 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 12:10:22 -0400 Subject: [PATCH 289/785] atk: Match `SoundArchive::GetSoundUserParam` --- .../nn/atk/atk_SoundArchiveParametersHook.h | 23 +++++++++++++++++-- src/NintendoWare/atk/atk_SoundArchive.cpp | 9 ++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveParametersHook.h b/include/nn/atk/atk_SoundArchiveParametersHook.h index 2e3ee998..1b6dfb73 100644 --- a/include/nn/atk/atk_SoundArchiveParametersHook.h +++ b/include/nn/atk/atk_SoundArchiveParametersHook.h @@ -37,9 +37,14 @@ class SoundArchiveParametersHook { bool ReadStreamSoundInfo(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo* info) const; bool ReadStreamSoundInfo2(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo2* info) const; bool ReadWaveSoundInfo(SoundArchive::ItemId soundId, SoundArchive::WaveSoundInfo* info) const; - bool ReadSoundUserParam(u32* pOutValue, SoundArchive::ItemId soundId, int index) const; - u32 GetSoundUserParam(SoundArchive::ItemId soundId, u32 userParam) const; + + u32 GetSoundUserParam(SoundArchive::ItemId soundId, u32 userParam) const { + if (m_IsEnable) + return GetSoundUserParamImpl(soundId, userParam); + + return SoundArchive::InvalidUserParam; + } protected: virtual void Impl1(); @@ -48,6 +53,20 @@ class SoundArchiveParametersHook { virtual const char* GetItemLabelImpl(SoundArchive::ItemId id) const; virtual SoundArchive::ItemId GetItemIdImpl(const char* itemLabel) const; virtual SoundArchive::SoundType GetSoundTypeImpl(const char* itemLabel) const; + virtual void Impl7(); + virtual void Impl8(); + virtual void Impl9(); + virtual void Impl10(); + virtual void Impl11(); + virtual void Impl12(); + virtual void Impl13(); + virtual void Impl14(); + virtual void Impl15(); + virtual void Impl16(); + virtual void Impl17(); + virtual void Impl18(); + virtual void Impl19(); + virtual u32 GetSoundUserParamImpl(SoundArchive::ItemId soundId, u32 userParam) const; private: bool m_IsEnable; diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 38bd3d7a..f9130094 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -85,4 +85,13 @@ SoundArchive::FileId SoundArchive::GetItemFileId(ItemId id) const { SoundArchive::FileId SoundArchive::GetItemPrefetchFileId(ItemId id) const { return m_pFileReader->GetItemPrefetchFileId(id); } + +u32 SoundArchive::GetSoundUserParam(ItemId soundId) const { + u32 userParam {m_pFileReader->GetSoundUserParam(soundId)}; + + if (m_pParametersHook != nullptr && m_pParametersHook->GetIsEnable()) + userParam = m_pParametersHook->GetSoundUserParam(soundId, userParam); + + return userParam; +} } // namespace nn::atk \ No newline at end of file From 27c78afd3007b2cb1a595825e1648f35baecc258 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 13:33:10 -0400 Subject: [PATCH 290/785] atk: Match `SoundArchive::ReadSoundUserParam` Also reorganized `SoundArchive` a little --- include/nn/atk/atk_SoundArchive.h | 183 ++++++++++-------- .../nn/atk/atk_SoundArchiveParametersHook.h | 21 +- src/NintendoWare/atk/atk_SoundArchive.cpp | 9 + 3 files changed, 120 insertions(+), 93 deletions(-) diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index 1dc998cb..1a49edcc 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -19,16 +19,12 @@ class StreamSoundLoader; class SoundArchive { public: using ItemId = u32; - using FileId = ItemId; - using StringId = ItemId; - static const ItemId InvalidId = -1; + static const ItemId InvalidId = 0xffffffff; static const int UserParamIndexMax = 3; static const u32 ResultInvalidSoundId = 0; - static const u32 InvalidUserParam = -1; - static const u32 SequenceBankMax = 4; - static const u32 StreamTrackCount = 8; + static const u32 InvalidUserParam = 0xffffffff; enum SoundType { SoundType_Invalid, @@ -38,12 +34,21 @@ class SoundArchive { SoundType_AdvancedWave, }; + enum StreamFileType { + StreamFileType_Invalid = 0, + StreamFileType_NwStreamBinary = 1, + StreamFileType_Opus = 3, + }; + enum DecodeMode { DecodeMode_Default, DecodeMode_Cpu, DecodeMode_Accelerator, }; + using FileId = ItemId; + using StringId = ItemId; + struct SoundInfo { FileId fileId; ItemId playerId; @@ -59,78 +64,27 @@ class SoundArchive { }; static_assert(sizeof(SoundInfo) == 0x1c); - struct BankInfo { - FileId fileId; - }; - static_assert(sizeof(BankInfo) == 0x4); - - struct PlayerInfo { - s32 playableSoundMax; - u32 playerHeapSize; - }; - static_assert(sizeof(PlayerInfo) == 0x8); - - struct SoundGroupInfo { - ItemId startId; - ItemId endId; - detail::Util::Table fileIdTable; - }; - static_assert(sizeof(SoundGroupInfo) == 0x10); - - struct GroupInfo { - FileId fileId; - u32 groupFileSize; - }; - static_assert(sizeof(GroupInfo) == 0x8); - - struct FileInfo { - static const u32 InvalidOffset = 0xffffffff; - static const u32 InvalidSize = 0xffffffff; - - u32 fileSize; - u32 offsetFromFileBlockHead; - const char* externalFilePath; - - FileInfo(); - }; - static_assert(sizeof(FileInfo) == 0x10); - - struct WaveArchiveInfo { - u32 fileId; - u32 waveCount; - bool isLoadIndividual; - u8 padding[3]; - }; - static_assert(sizeof(WaveArchiveInfo) == 0xc); - - struct SoundArchivePlayerInfo { - s32 sequenceSoundCount; - s32 sequenceTrackCount; - s32 streamSoundCount; - s32 streamTrackCount; - s32 streamChannelCount; - s32 waveSoundCount; - s32 waveTrackCount; - s32 streamBufferTimes; - bool isAdvancedWaveSoundEnabled; + struct Sound3DInfo { + u32 flags; + float decayRatio; + u8 decayCurve; + u8 dopplerFactor; }; - static_assert(sizeof(SoundArchivePlayerInfo) == 0x24); + static_assert(sizeof(Sound3DInfo) == 0xc); + static const u32 SequenceBankMax = 4; struct SequenceSoundInfo { u32 startOffset; - u32 bankIds[4]; + u32 bankIds[SequenceBankMax]; u32 allocateTrackFlags; u8 channelPriority; bool isReleasePriorityFix; - }; - static_assert(sizeof(SequenceSoundInfo) == 0x1c); - enum StreamFileType { - StreamFileType_Invalid = 0, - StreamFileType_NwStreamBinary = 1, - StreamFileType_Opus = 3, + SequenceSoundInfo(); }; + static_assert(sizeof(SequenceSoundInfo) == 0x1c); + static const u32 StreamTrackCount = 8; struct StreamTrackInfo { u8 volume; u8 pan; @@ -154,7 +108,7 @@ class SoundArchive { float pitch; u8 mainSend; u8 fxSend[3]; - StreamTrackInfo trackInfo[8]; + StreamTrackInfo trackInfo[StreamTrackCount]; StreamFileType streamFileType; DecodeMode decodeMode; FileId prefetchFileId; @@ -179,6 +133,8 @@ class SoundArchive { u32 allocateTrackCount; u8 channelPriority; bool isReleasePriorityFix; + + WaveSoundInfo(); }; static_assert(sizeof(WaveSoundInfo) == 0xc); @@ -186,14 +142,73 @@ class SoundArchive { u32 waveArchiveId; }; static_assert(sizeof(AdvancedWaveSoundInfo) == 0x4); - - struct Sound3DInfo { - u32 flags; - float decayRatio; - u8 decayCurve; - u8 dopplerFactor; + + struct BankInfo { + FileId fileId; + + BankInfo(); }; - static_assert(sizeof(Sound3DInfo) == 0xc); + static_assert(sizeof(BankInfo) == 0x4); + + struct WaveArchiveInfo { + u32 fileId; + u32 waveCount; + bool isLoadIndividual; + u8 padding[3]; + + WaveArchiveInfo(); + }; + static_assert(sizeof(WaveArchiveInfo) == 0xc); + + struct PlayerInfo { + int playableSoundMax; + u32 playerHeapSize; + + PlayerInfo(); + }; + static_assert(sizeof(PlayerInfo) == 0x8); + + struct SoundGroupInfo { + ItemId startId; + ItemId endId; + detail::Util::Table fileIdTable; + + SoundGroupInfo(); + }; + static_assert(sizeof(SoundGroupInfo) == 0x10); + + struct GroupInfo { + FileId fileId; + u32 groupFileSize; + + GroupInfo(); + }; + static_assert(sizeof(GroupInfo) == 0x8); + + struct SoundArchivePlayerInfo { + s32 sequenceSoundCount; + s32 sequenceTrackCount; + s32 streamSoundCount; + s32 streamTrackCount; + s32 streamChannelCount; + s32 waveSoundCount; + s32 waveTrackCount; + s32 streamBufferTimes; + bool isAdvancedWaveSoundEnabled; + }; + static_assert(sizeof(SoundArchivePlayerInfo) == 0x24); + + struct FileInfo { + static const u32 InvalidOffset = 0xffffffff; + static const u32 InvalidSize = 0xffffffff; + + u32 fileSize; + u32 offsetFromFileBlockHead; + const char* externalFilePath; + + FileInfo(); + }; + static_assert(sizeof(FileInfo) == 0x10); protected: SoundArchive(); @@ -216,12 +231,12 @@ class SoundArchive { FileId GetItemFileId(ItemId id) const; FileId GetItemPrefetchFileId(ItemId id) const; - static ItemId GetSoundIdFromIndex(u32); - static ItemId GetSoundGroupIdFromIndex(u32); - static ItemId GetBankIdFromIndex(u32); - static ItemId GetPlayerIdFromIndex(u32); - static ItemId GetWaveArchiveIdFromIndex(u32); - static ItemId GetGroupIdFromIndex(u32); + static ItemId GetSoundIdFromIndex(u32 index); + static ItemId GetSoundGroupIdFromIndex(u32 index); + static ItemId GetBankIdFromIndex(u32 index); + static ItemId GetPlayerIdFromIndex(u32 index); + static ItemId GetWaveArchiveIdFromIndex(u32 index); + static ItemId GetGroupIdFromIndex(u32 index); u32 GetSoundUserParam(ItemId soundId) const; bool ReadSoundUserParam(u32* pOutValue, ItemId soundId, int index) const; @@ -287,8 +302,8 @@ class SoundArchive { private: friend detail::driver::StreamSoundLoader; - detail::SoundArchiveFileReader* m_pFileReader{}; - detail::SoundArchiveParametersHook* m_pParametersHook{}; + detail::SoundArchiveFileReader* m_pFileReader {}; + detail::SoundArchiveParametersHook* m_pParametersHook {}; char m_ExtFileRoot[FilePathMax]; u32 m_FileBlockOffset; }; diff --git a/include/nn/atk/atk_SoundArchiveParametersHook.h b/include/nn/atk/atk_SoundArchiveParametersHook.h index 1b6dfb73..f301d379 100644 --- a/include/nn/atk/atk_SoundArchiveParametersHook.h +++ b/include/nn/atk/atk_SoundArchiveParametersHook.h @@ -37,22 +37,26 @@ class SoundArchiveParametersHook { bool ReadStreamSoundInfo(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo* info) const; bool ReadStreamSoundInfo2(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo2* info) const; bool ReadWaveSoundInfo(SoundArchive::ItemId soundId, SoundArchive::WaveSoundInfo* info) const; - bool ReadSoundUserParam(u32* pOutValue, SoundArchive::ItemId soundId, int index) const; - - u32 GetSoundUserParam(SoundArchive::ItemId soundId, u32 userParam) const { + + bool ReadSoundUserParam(u32* pOutValue, SoundArchive::ItemId soundId, int index) const { if (m_IsEnable) - return GetSoundUserParamImpl(soundId, userParam); + return ReadSoundUserParamImpl(pOutValue, soundId, index); + + return false; + } - return SoundArchive::InvalidUserParam; + u32 GetSoundUserParam(SoundArchive::ItemId soundId, u32 userParam) const { + return GetSoundUserParamImpl(soundId, userParam); } protected: + virtual void Impl0(); virtual void Impl1(); virtual void Impl2(); - virtual void Impl3(); virtual const char* GetItemLabelImpl(SoundArchive::ItemId id) const; virtual SoundArchive::ItemId GetItemIdImpl(const char* itemLabel) const; virtual SoundArchive::SoundType GetSoundTypeImpl(const char* itemLabel) const; + virtual void Impl6(); virtual void Impl7(); virtual void Impl8(); virtual void Impl9(); @@ -65,11 +69,10 @@ class SoundArchiveParametersHook { virtual void Impl16(); virtual void Impl17(); virtual void Impl18(); - virtual void Impl19(); + virtual bool ReadSoundUserParamImpl(u32* pOutValue, SoundArchive::ItemId soundId, int index) const; virtual u32 GetSoundUserParamImpl(SoundArchive::ItemId soundId, u32 userParam) const; private: bool m_IsEnable; }; -} // namespace nn::atk::detail - +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index f9130094..20f060f4 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -94,4 +94,13 @@ u32 SoundArchive::GetSoundUserParam(ItemId soundId) const { return userParam; } + +bool SoundArchive::ReadSoundUserParam(u32* pOutValue, ItemId soundId, int index) const { + bool result {m_pFileReader->ReadSoundUserParam(pOutValue, soundId, index)}; + + if (m_pParametersHook != nullptr) + result |= m_pParametersHook->ReadSoundUserParam(pOutValue, soundId, index); + + return result; +} } // namespace nn::atk \ No newline at end of file From 1569d7e378d25a100e6847604f2108ef77f5f368 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 13:45:01 -0400 Subject: [PATCH 291/785] atk: Match `SoundArchive::GetSoundType` --- include/nn/atk/atk_SoundArchiveParametersHook.h | 7 ++++++- src/NintendoWare/atk/atk_SoundArchive.cpp | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_SoundArchiveParametersHook.h b/include/nn/atk/atk_SoundArchiveParametersHook.h index f301d379..6ec6a230 100644 --- a/include/nn/atk/atk_SoundArchiveParametersHook.h +++ b/include/nn/atk/atk_SoundArchiveParametersHook.h @@ -22,7 +22,12 @@ class SoundArchiveParametersHook { return SoundArchive::InvalidId; } - SoundArchive::SoundType GetSoundType(const char* itemLabel); + SoundArchive::SoundType GetSoundType(const char* itemLabel) { + if (m_IsEnable) + return GetSoundTypeImpl(itemLabel); + + return SoundArchive::SoundType_Invalid; + } bool ReadSoundInfo(SoundArchive::ItemId soundId, SoundArchive::SoundInfo* info) const; bool ReadBankInfo(SoundArchive::ItemId bankId, SoundArchive::BankInfo* info) const; diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 20f060f4..2f6f9364 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -103,4 +103,17 @@ bool SoundArchive::ReadSoundUserParam(u32* pOutValue, ItemId soundId, int index) return result; } + +SoundArchive::SoundType SoundArchive::GetSoundType(ItemId soundId) const { + if (m_pParametersHook != nullptr) { + const char* label {m_pParametersHook->GetItemLabel(soundId)}; + if (label != nullptr) { + SoundType type {m_pParametersHook->GetSoundType(label)}; + if (type != SoundType_Invalid) + return type; + } + } + + return m_pFileReader->GetSoundType(soundId); +} } // namespace nn::atk \ No newline at end of file From 998b6eeeac8365f2808174ce694f056f36bb21df Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 13:49:46 -0400 Subject: [PATCH 292/785] atk: Match `SoundArchive::ReadSoundInfo` --- include/nn/atk/atk_SoundArchiveParametersHook.h | 10 ++++++++-- src/NintendoWare/atk/atk_SoundArchive.cpp | 11 ++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveParametersHook.h b/include/nn/atk/atk_SoundArchiveParametersHook.h index 6ec6a230..6b6d9263 100644 --- a/include/nn/atk/atk_SoundArchiveParametersHook.h +++ b/include/nn/atk/atk_SoundArchiveParametersHook.h @@ -29,7 +29,13 @@ class SoundArchiveParametersHook { return SoundArchive::SoundType_Invalid; } - bool ReadSoundInfo(SoundArchive::ItemId soundId, SoundArchive::SoundInfo* info) const; + bool ReadSoundInfo(SoundArchive::ItemId soundId, SoundArchive::SoundInfo* info) const { + if (m_IsEnable) + return ReadSoundInfoImpl(soundId, info); + + return false; + } + bool ReadBankInfo(SoundArchive::ItemId bankId, SoundArchive::BankInfo* info) const; bool ReadPlayerInfo(SoundArchive::ItemId playerId, SoundArchive::PlayerInfo* info) const; bool ReadSoundGroupInfo(SoundArchive::ItemId soundGroupId, SoundArchive::SoundGroupInfo* info) const; @@ -61,7 +67,7 @@ class SoundArchiveParametersHook { virtual const char* GetItemLabelImpl(SoundArchive::ItemId id) const; virtual SoundArchive::ItemId GetItemIdImpl(const char* itemLabel) const; virtual SoundArchive::SoundType GetSoundTypeImpl(const char* itemLabel) const; - virtual void Impl6(); + virtual bool ReadSoundInfoImpl(SoundArchive::ItemId soundId, SoundArchive::SoundInfo* info) const; virtual void Impl7(); virtual void Impl8(); virtual void Impl9(); diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 2f6f9364..f2c82bb8 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -113,7 +113,16 @@ SoundArchive::SoundType SoundArchive::GetSoundType(ItemId soundId) const { return type; } } - + return m_pFileReader->GetSoundType(soundId); } + +bool SoundArchive::ReadSoundInfo(SoundInfo* pOutValue, ItemId soundId) const { + bool result {m_pFileReader->ReadSoundInfo(soundId, pOutValue)}; + + if (m_pParametersHook != nullptr) + result |= m_pParametersHook->ReadSoundInfo(soundId, pOutValue); + + return result; +} } // namespace nn::atk \ No newline at end of file From 2fb849d99a3adf2ab8dbdfd844b4cbb453b20113 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 13:57:07 -0400 Subject: [PATCH 293/785] atk: Match `SoundArchive::ReadSequenceSoundInfo` --- include/nn/atk/atk_SoundArchiveParametersHook.h | 11 +++++++++-- src/NintendoWare/atk/atk_SoundArchive.cpp | 12 +++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveParametersHook.h b/include/nn/atk/atk_SoundArchiveParametersHook.h index 6b6d9263..fdd9b74e 100644 --- a/include/nn/atk/atk_SoundArchiveParametersHook.h +++ b/include/nn/atk/atk_SoundArchiveParametersHook.h @@ -44,7 +44,14 @@ class SoundArchiveParametersHook { bool ReadSoundArchivePlayerInfo(SoundArchive::SoundArchivePlayerInfo* info) const; bool ReadSound3DInfo(SoundArchive::ItemId soundId, SoundArchive::Sound3DInfo* info) const; bool ReadWaveArchiveInfo(SoundArchive::ItemId warcId, SoundArchive::WaveArchiveInfo* info) const; - bool ReadSequenceSoundInfo(SoundArchive::ItemId soundId, SoundArchive::SequenceSoundInfo* info) const; + + bool ReadSequenceSoundInfo(SoundArchive::ItemId soundId, SoundArchive::SequenceSoundInfo* info) const { + if (m_IsEnable) + return ReadSequenceSoundInfoImpl(soundId, info); + + return false; + } + bool ReadStreamSoundInfo(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo* info) const; bool ReadStreamSoundInfo2(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo2* info) const; bool ReadWaveSoundInfo(SoundArchive::ItemId soundId, SoundArchive::WaveSoundInfo* info) const; @@ -76,7 +83,7 @@ class SoundArchiveParametersHook { virtual void Impl12(); virtual void Impl13(); virtual void Impl14(); - virtual void Impl15(); + virtual bool ReadSequenceSoundInfoImpl(SoundArchive::ItemId soundId, SoundArchive::SequenceSoundInfo* info) const; virtual void Impl16(); virtual void Impl17(); virtual void Impl18(); diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index f2c82bb8..c7b20bfb 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -105,6 +105,7 @@ bool SoundArchive::ReadSoundUserParam(u32* pOutValue, ItemId soundId, int index) } SoundArchive::SoundType SoundArchive::GetSoundType(ItemId soundId) const { +#if NN_SDK_VER > NN_MAKE_VER(1, 6, 0) if (m_pParametersHook != nullptr) { const char* label {m_pParametersHook->GetItemLabel(soundId)}; if (label != nullptr) { @@ -113,7 +114,7 @@ SoundArchive::SoundType SoundArchive::GetSoundType(ItemId soundId) const { return type; } } - +#endif return m_pFileReader->GetSoundType(soundId); } @@ -125,4 +126,13 @@ bool SoundArchive::ReadSoundInfo(SoundInfo* pOutValue, ItemId soundId) const { return result; } + +bool SoundArchive::ReadSequenceSoundInfo(SequenceSoundInfo* pOutValue, ItemId soundId) const { + bool result {m_pFileReader->ReadSequenceSoundInfo(soundId, pOutValue)}; + + if (m_pParametersHook != nullptr) + result |= m_pParametersHook->ReadSequenceSoundInfo(soundId, pOutValue); + + return result; +} } // namespace nn::atk \ No newline at end of file From a739e2a7c42ee14396ef52e925a48ce4b02eec52 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 14:00:53 -0400 Subject: [PATCH 294/785] atk: Match `SoundArchive::ReadBankInfo` --- include/nn/atk/atk_SoundArchiveParametersHook.h | 10 ++++++++-- src/NintendoWare/atk/atk_SoundArchive.cpp | 9 +++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveParametersHook.h b/include/nn/atk/atk_SoundArchiveParametersHook.h index fdd9b74e..8df1ae76 100644 --- a/include/nn/atk/atk_SoundArchiveParametersHook.h +++ b/include/nn/atk/atk_SoundArchiveParametersHook.h @@ -36,7 +36,13 @@ class SoundArchiveParametersHook { return false; } - bool ReadBankInfo(SoundArchive::ItemId bankId, SoundArchive::BankInfo* info) const; + bool ReadBankInfo(SoundArchive::ItemId bankId, SoundArchive::BankInfo* info) const { + if (m_IsEnable) + return ReadBankInfoImpl(bankId, info); + + return false; + } + bool ReadPlayerInfo(SoundArchive::ItemId playerId, SoundArchive::PlayerInfo* info) const; bool ReadSoundGroupInfo(SoundArchive::ItemId soundGroupId, SoundArchive::SoundGroupInfo* info) const; bool ReadGroupInfo(SoundArchive::ItemId groupId, SoundArchive::GroupInfo* info) const; @@ -75,7 +81,7 @@ class SoundArchiveParametersHook { virtual SoundArchive::ItemId GetItemIdImpl(const char* itemLabel) const; virtual SoundArchive::SoundType GetSoundTypeImpl(const char* itemLabel) const; virtual bool ReadSoundInfoImpl(SoundArchive::ItemId soundId, SoundArchive::SoundInfo* info) const; - virtual void Impl7(); + virtual bool ReadBankInfoImpl(SoundArchive::ItemId bankId, SoundArchive::BankInfo* info) const; virtual void Impl8(); virtual void Impl9(); virtual void Impl10(); diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index c7b20bfb..6de36cbf 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -135,4 +135,13 @@ bool SoundArchive::ReadSequenceSoundInfo(SequenceSoundInfo* pOutValue, ItemId so return result; } + +bool SoundArchive::ReadBankInfo(BankInfo* pOutValue, ItemId bankId) const { + bool result {m_pFileReader->ReadBankInfo(bankId, pOutValue)}; + + if (m_pParametersHook != nullptr) + result |= m_pParametersHook->ReadBankInfo(bankId, pOutValue); + + return result; +} } // namespace nn::atk \ No newline at end of file From 6619c4d63e509d74a7490df22148373f1e108440 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 14:03:01 -0400 Subject: [PATCH 295/785] atk: Match `SoundArchive::ReadPlayerInfo` --- include/nn/atk/atk_SoundArchiveParametersHook.h | 10 ++++++++-- src/NintendoWare/atk/atk_SoundArchive.cpp | 9 +++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveParametersHook.h b/include/nn/atk/atk_SoundArchiveParametersHook.h index 8df1ae76..fc8e9509 100644 --- a/include/nn/atk/atk_SoundArchiveParametersHook.h +++ b/include/nn/atk/atk_SoundArchiveParametersHook.h @@ -43,7 +43,13 @@ class SoundArchiveParametersHook { return false; } - bool ReadPlayerInfo(SoundArchive::ItemId playerId, SoundArchive::PlayerInfo* info) const; + bool ReadPlayerInfo(SoundArchive::ItemId playerId, SoundArchive::PlayerInfo* info) const { + if (m_IsEnable) + return ReadPlayerInfoImpl(playerId, info); + + return false; + } + bool ReadSoundGroupInfo(SoundArchive::ItemId soundGroupId, SoundArchive::SoundGroupInfo* info) const; bool ReadGroupInfo(SoundArchive::ItemId groupId, SoundArchive::GroupInfo* info) const; bool ReadFileInfo(SoundArchive::FileId id, SoundArchive::FileInfo* info, int index) const; @@ -82,7 +88,7 @@ class SoundArchiveParametersHook { virtual SoundArchive::SoundType GetSoundTypeImpl(const char* itemLabel) const; virtual bool ReadSoundInfoImpl(SoundArchive::ItemId soundId, SoundArchive::SoundInfo* info) const; virtual bool ReadBankInfoImpl(SoundArchive::ItemId bankId, SoundArchive::BankInfo* info) const; - virtual void Impl8(); + virtual bool ReadPlayerInfoImpl(SoundArchive::ItemId playerId, SoundArchive::PlayerInfo* info) const; virtual void Impl9(); virtual void Impl10(); virtual void Impl11(); diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 6de36cbf..637e7242 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -144,4 +144,13 @@ bool SoundArchive::ReadBankInfo(BankInfo* pOutValue, ItemId bankId) const { return result; } + +bool SoundArchive::ReadPlayerInfo(PlayerInfo* pOutValue, ItemId playerId) const { + bool result {m_pFileReader->ReadPlayerInfo(playerId, pOutValue)}; + + if (m_pParametersHook != nullptr) + result |= m_pParametersHook->ReadPlayerInfo(playerId, pOutValue); + + return result; +} } // namespace nn::atk \ No newline at end of file From 61e76b808e1edbd9131ac1adac7f3386687204c3 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 14:05:34 -0400 Subject: [PATCH 296/785] atk: Match `SoundArchive::ReadSoundArchivePlayerInfo` --- include/nn/atk/atk_SoundArchiveParametersHook.h | 11 +++++++++-- src/NintendoWare/atk/atk_SoundArchive.cpp | 9 +++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveParametersHook.h b/include/nn/atk/atk_SoundArchiveParametersHook.h index fc8e9509..d2f32a57 100644 --- a/include/nn/atk/atk_SoundArchiveParametersHook.h +++ b/include/nn/atk/atk_SoundArchiveParametersHook.h @@ -53,7 +53,14 @@ class SoundArchiveParametersHook { bool ReadSoundGroupInfo(SoundArchive::ItemId soundGroupId, SoundArchive::SoundGroupInfo* info) const; bool ReadGroupInfo(SoundArchive::ItemId groupId, SoundArchive::GroupInfo* info) const; bool ReadFileInfo(SoundArchive::FileId id, SoundArchive::FileInfo* info, int index) const; - bool ReadSoundArchivePlayerInfo(SoundArchive::SoundArchivePlayerInfo* info) const; + + bool ReadSoundArchivePlayerInfo(SoundArchive::SoundArchivePlayerInfo* info) const { + if (m_IsEnable) + return ReadSoundArchivePlayerInfoImpl(info); + + return false; + } + bool ReadSound3DInfo(SoundArchive::ItemId soundId, SoundArchive::Sound3DInfo* info) const; bool ReadWaveArchiveInfo(SoundArchive::ItemId warcId, SoundArchive::WaveArchiveInfo* info) const; @@ -93,7 +100,7 @@ class SoundArchiveParametersHook { virtual void Impl10(); virtual void Impl11(); virtual void Impl12(); - virtual void Impl13(); + virtual bool ReadSoundArchivePlayerInfoImpl(SoundArchive::SoundArchivePlayerInfo* info) const; virtual void Impl14(); virtual bool ReadSequenceSoundInfoImpl(SoundArchive::ItemId soundId, SoundArchive::SequenceSoundInfo* info) const; virtual void Impl16(); diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 637e7242..3ee65d9d 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -153,4 +153,13 @@ bool SoundArchive::ReadPlayerInfo(PlayerInfo* pOutValue, ItemId playerId) const return result; } + +bool SoundArchive::ReadSoundArchivePlayerInfo(SoundArchivePlayerInfo* pOutValue) const { + bool result {m_pFileReader->ReadSoundArchivePlayerInfo(pOutValue)}; + + if (m_pParametersHook != nullptr) + result |= m_pParametersHook->ReadSoundArchivePlayerInfo(pOutValue); + + return result; +} } // namespace nn::atk \ No newline at end of file From 804281d41ff97c415a4187608c08b797416b340c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 14:09:00 -0400 Subject: [PATCH 297/785] atk: Match `SoundArchive::ReadStreamSoundInfo` --- include/nn/atk/atk_SoundArchiveParametersHook.h | 10 ++++++++-- src/NintendoWare/atk/atk_SoundArchive.cpp | 9 +++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveParametersHook.h b/include/nn/atk/atk_SoundArchiveParametersHook.h index d2f32a57..dfc85b61 100644 --- a/include/nn/atk/atk_SoundArchiveParametersHook.h +++ b/include/nn/atk/atk_SoundArchiveParametersHook.h @@ -71,7 +71,13 @@ class SoundArchiveParametersHook { return false; } - bool ReadStreamSoundInfo(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo* info) const; + bool ReadStreamSoundInfo(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo* info) const { + if (m_IsEnable) + return ReadStreamSoundInfoImpl(soundId, info); + + return false; + } + bool ReadStreamSoundInfo2(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo2* info) const; bool ReadWaveSoundInfo(SoundArchive::ItemId soundId, SoundArchive::WaveSoundInfo* info) const; @@ -103,7 +109,7 @@ class SoundArchiveParametersHook { virtual bool ReadSoundArchivePlayerInfoImpl(SoundArchive::SoundArchivePlayerInfo* info) const; virtual void Impl14(); virtual bool ReadSequenceSoundInfoImpl(SoundArchive::ItemId soundId, SoundArchive::SequenceSoundInfo* info) const; - virtual void Impl16(); + virtual bool ReadStreamSoundInfoImpl(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo* info) const; virtual void Impl17(); virtual void Impl18(); virtual bool ReadSoundUserParamImpl(u32* pOutValue, SoundArchive::ItemId soundId, int index) const; diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 3ee65d9d..dcc00a97 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -162,4 +162,13 @@ bool SoundArchive::ReadSoundArchivePlayerInfo(SoundArchivePlayerInfo* pOutValue) return result; } + +bool SoundArchive::ReadStreamSoundInfo(StreamSoundInfo* pOutValue, ItemId soundId) const { + bool result {m_pFileReader->ReadStreamSoundInfo(soundId, pOutValue)}; + + if (m_pParametersHook != nullptr) + result |= m_pParametersHook->ReadStreamSoundInfo(soundId, pOutValue); + + return result; +} } // namespace nn::atk \ No newline at end of file From 3c2df057a57aadaf668db45df1f7cf7a4d083a7a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 14:12:20 -0400 Subject: [PATCH 298/785] atk: Match `SoundArchive::detail_ReadStreamSoundInfo2` --- include/nn/atk/atk_SoundArchiveParametersHook.h | 10 ++++++++-- src/NintendoWare/atk/atk_SoundArchive.cpp | 9 +++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveParametersHook.h b/include/nn/atk/atk_SoundArchiveParametersHook.h index dfc85b61..caa9c850 100644 --- a/include/nn/atk/atk_SoundArchiveParametersHook.h +++ b/include/nn/atk/atk_SoundArchiveParametersHook.h @@ -78,7 +78,13 @@ class SoundArchiveParametersHook { return false; } - bool ReadStreamSoundInfo2(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo2* info) const; + bool ReadStreamSoundInfo2(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo2* info) const { + if (m_IsEnable) + return ReadStreamSoundInfo2Impl(soundId, info); + + return false; + } + bool ReadWaveSoundInfo(SoundArchive::ItemId soundId, SoundArchive::WaveSoundInfo* info) const; bool ReadSoundUserParam(u32* pOutValue, SoundArchive::ItemId soundId, int index) const { @@ -110,7 +116,7 @@ class SoundArchiveParametersHook { virtual void Impl14(); virtual bool ReadSequenceSoundInfoImpl(SoundArchive::ItemId soundId, SoundArchive::SequenceSoundInfo* info) const; virtual bool ReadStreamSoundInfoImpl(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo* info) const; - virtual void Impl17(); + virtual bool ReadStreamSoundInfo2Impl(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo2* info) const; virtual void Impl18(); virtual bool ReadSoundUserParamImpl(u32* pOutValue, SoundArchive::ItemId soundId, int index) const; virtual u32 GetSoundUserParamImpl(SoundArchive::ItemId soundId, u32 userParam) const; diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index dcc00a97..33427245 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -171,4 +171,13 @@ bool SoundArchive::ReadStreamSoundInfo(StreamSoundInfo* pOutValue, ItemId soundI return result; } + +bool SoundArchive::detail_ReadStreamSoundInfo2(ItemId soundId, StreamSoundInfo2* info) const { + bool result {m_pFileReader->ReadStreamSoundInfo2(soundId, info)}; + + if (m_pParametersHook != nullptr) + result |= m_pParametersHook->ReadStreamSoundInfo2(soundId, info); + + return result; +} } // namespace nn::atk \ No newline at end of file From e9fd819fab47492d719bdcbbe2adaa977030ac1f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 14:14:10 -0400 Subject: [PATCH 299/785] atk: Match `SoundArchive::detail_ReadWaveSoundInfo` --- include/nn/atk/atk_SoundArchiveParametersHook.h | 11 ++++++++--- src/NintendoWare/atk/atk_SoundArchive.cpp | 9 +++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveParametersHook.h b/include/nn/atk/atk_SoundArchiveParametersHook.h index caa9c850..0395c36a 100644 --- a/include/nn/atk/atk_SoundArchiveParametersHook.h +++ b/include/nn/atk/atk_SoundArchiveParametersHook.h @@ -84,8 +84,13 @@ class SoundArchiveParametersHook { return false; } - - bool ReadWaveSoundInfo(SoundArchive::ItemId soundId, SoundArchive::WaveSoundInfo* info) const; + + bool ReadWaveSoundInfo(SoundArchive::ItemId soundId, SoundArchive::WaveSoundInfo* info) const { + if (m_IsEnable) + return ReadWaveSoundInfoImpl(soundId, info); + + return false; + } bool ReadSoundUserParam(u32* pOutValue, SoundArchive::ItemId soundId, int index) const { if (m_IsEnable) @@ -117,7 +122,7 @@ class SoundArchiveParametersHook { virtual bool ReadSequenceSoundInfoImpl(SoundArchive::ItemId soundId, SoundArchive::SequenceSoundInfo* info) const; virtual bool ReadStreamSoundInfoImpl(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo* info) const; virtual bool ReadStreamSoundInfo2Impl(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo2* info) const; - virtual void Impl18(); + virtual bool ReadWaveSoundInfoImpl(SoundArchive::ItemId soundId, SoundArchive::WaveSoundInfo* info) const; virtual bool ReadSoundUserParamImpl(u32* pOutValue, SoundArchive::ItemId soundId, int index) const; virtual u32 GetSoundUserParamImpl(SoundArchive::ItemId soundId, u32 userParam) const; diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 33427245..148c3e69 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -180,4 +180,13 @@ bool SoundArchive::detail_ReadStreamSoundInfo2(ItemId soundId, StreamSoundInfo2* return result; } + +bool SoundArchive::detail_ReadWaveSoundInfo(ItemId soundId, WaveSoundInfo* info) const { + bool result {m_pFileReader->ReadWaveSoundInfo(soundId, info)}; + + if (m_pParametersHook != nullptr) + result |= m_pParametersHook->ReadWaveSoundInfo(soundId, info); + + return result; +} } // namespace nn::atk \ No newline at end of file From af43e22047b7f8101086aca69b76d00cf29c4c87 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 14:15:05 -0400 Subject: [PATCH 300/785] atk: Match `SoundArchive::detail_ReadAdvancedWaveSoundInfo` --- src/NintendoWare/atk/atk_SoundArchive.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 148c3e69..707c20bd 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -189,4 +189,9 @@ bool SoundArchive::detail_ReadWaveSoundInfo(ItemId soundId, WaveSoundInfo* info) return result; } + +bool SoundArchive::detail_ReadAdvancedWaveSoundInfo(ItemId soundId, AdvancedWaveSoundInfo* info) const { + bool result {m_pFileReader->ReadAdvancedWaveSoundInfo(soundId, info)}; + return result; +} } // namespace nn::atk \ No newline at end of file From 6043110e4ceef2716a5583e5557fee22805e93de Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 14:18:23 -0400 Subject: [PATCH 301/785] atk: Match `SoundArchive::ReadSound3DInfo` --- include/nn/atk/atk_SoundArchiveParametersHook.h | 10 ++++++++-- src/NintendoWare/atk/atk_SoundArchive.cpp | 9 +++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveParametersHook.h b/include/nn/atk/atk_SoundArchiveParametersHook.h index 0395c36a..0e037060 100644 --- a/include/nn/atk/atk_SoundArchiveParametersHook.h +++ b/include/nn/atk/atk_SoundArchiveParametersHook.h @@ -61,7 +61,13 @@ class SoundArchiveParametersHook { return false; } - bool ReadSound3DInfo(SoundArchive::ItemId soundId, SoundArchive::Sound3DInfo* info) const; + bool ReadSound3DInfo(SoundArchive::ItemId soundId, SoundArchive::Sound3DInfo* info) const { + if (m_IsEnable) + return ReadSound3DInfoImpl(soundId, info); + + return false; + } + bool ReadWaveArchiveInfo(SoundArchive::ItemId warcId, SoundArchive::WaveArchiveInfo* info) const; bool ReadSequenceSoundInfo(SoundArchive::ItemId soundId, SoundArchive::SequenceSoundInfo* info) const { @@ -118,7 +124,7 @@ class SoundArchiveParametersHook { virtual void Impl11(); virtual void Impl12(); virtual bool ReadSoundArchivePlayerInfoImpl(SoundArchive::SoundArchivePlayerInfo* info) const; - virtual void Impl14(); + virtual bool ReadSound3DInfoImpl(SoundArchive::ItemId soundId, SoundArchive::Sound3DInfo* info) const; virtual bool ReadSequenceSoundInfoImpl(SoundArchive::ItemId soundId, SoundArchive::SequenceSoundInfo* info) const; virtual bool ReadStreamSoundInfoImpl(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo* info) const; virtual bool ReadStreamSoundInfo2Impl(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo2* info) const; diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 707c20bd..1889e71e 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -194,4 +194,13 @@ bool SoundArchive::detail_ReadAdvancedWaveSoundInfo(ItemId soundId, AdvancedWave bool result {m_pFileReader->ReadAdvancedWaveSoundInfo(soundId, info)}; return result; } + +bool SoundArchive::ReadSound3DInfo(Sound3DInfo* pOutValue, ItemId soundId) const { + bool result {m_pFileReader->ReadSound3DInfo(soundId, pOutValue)}; + + if (m_pParametersHook != nullptr) + result |= m_pParametersHook->ReadSound3DInfo(soundId, pOutValue); + + return result; +} } // namespace nn::atk \ No newline at end of file From eadf1ad2477ca248e2e1ce66cb15e55308a7a9b5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 14:21:55 -0400 Subject: [PATCH 302/785] atk: Match `SoundArchive::ReadWaveArchiveInfo` --- include/nn/atk/atk_SoundArchiveParametersHook.h | 9 +++++++-- src/NintendoWare/atk/atk_SoundArchive.cpp | 9 +++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveParametersHook.h b/include/nn/atk/atk_SoundArchiveParametersHook.h index 0e037060..ebcd9c61 100644 --- a/include/nn/atk/atk_SoundArchiveParametersHook.h +++ b/include/nn/atk/atk_SoundArchiveParametersHook.h @@ -68,7 +68,12 @@ class SoundArchiveParametersHook { return false; } - bool ReadWaveArchiveInfo(SoundArchive::ItemId warcId, SoundArchive::WaveArchiveInfo* info) const; + bool ReadWaveArchiveInfo(SoundArchive::ItemId warcId, SoundArchive::WaveArchiveInfo* info) const { + if (m_IsEnable) + return ReadWaveArchiveInfoImpl(warcId, info); + + return false; + } bool ReadSequenceSoundInfo(SoundArchive::ItemId soundId, SoundArchive::SequenceSoundInfo* info) const { if (m_IsEnable) @@ -121,7 +126,7 @@ class SoundArchiveParametersHook { virtual bool ReadPlayerInfoImpl(SoundArchive::ItemId playerId, SoundArchive::PlayerInfo* info) const; virtual void Impl9(); virtual void Impl10(); - virtual void Impl11(); + virtual bool ReadWaveArchiveInfoImpl(SoundArchive::ItemId warcId, SoundArchive::WaveArchiveInfo* info) const; virtual void Impl12(); virtual bool ReadSoundArchivePlayerInfoImpl(SoundArchive::SoundArchivePlayerInfo* info) const; virtual bool ReadSound3DInfoImpl(SoundArchive::ItemId soundId, SoundArchive::Sound3DInfo* info) const; diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 1889e71e..5a769ff4 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -203,4 +203,13 @@ bool SoundArchive::ReadSound3DInfo(Sound3DInfo* pOutValue, ItemId soundId) const return result; } + +bool SoundArchive::ReadWaveArchiveInfo(ItemId warcId, WaveArchiveInfo* info) const { + bool result {m_pFileReader->ReadWaveArchiveInfo(warcId, info)}; + + if (m_pParametersHook != nullptr) + result |= m_pParametersHook->ReadWaveArchiveInfo(warcId, info); + + return result; +} } // namespace nn::atk \ No newline at end of file From ef27bc0fbe71625471db307b1334fd2e2c14509a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 14:23:52 -0400 Subject: [PATCH 303/785] atk: Match `SoundArchive::detail_ReadSoundGroupInfo` --- include/nn/atk/atk_SoundArchiveParametersHook.h | 10 ++++++++-- src/NintendoWare/atk/atk_SoundArchive.cpp | 9 +++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveParametersHook.h b/include/nn/atk/atk_SoundArchiveParametersHook.h index ebcd9c61..7e353348 100644 --- a/include/nn/atk/atk_SoundArchiveParametersHook.h +++ b/include/nn/atk/atk_SoundArchiveParametersHook.h @@ -50,7 +50,13 @@ class SoundArchiveParametersHook { return false; } - bool ReadSoundGroupInfo(SoundArchive::ItemId soundGroupId, SoundArchive::SoundGroupInfo* info) const; + bool ReadSoundGroupInfo(SoundArchive::ItemId soundGroupId, SoundArchive::SoundGroupInfo* info) const { + if (m_IsEnable) + return ReadSoundGroupInfoImpl(soundGroupId, info); + + return false; + } + bool ReadGroupInfo(SoundArchive::ItemId groupId, SoundArchive::GroupInfo* info) const; bool ReadFileInfo(SoundArchive::FileId id, SoundArchive::FileInfo* info, int index) const; @@ -124,7 +130,7 @@ class SoundArchiveParametersHook { virtual bool ReadSoundInfoImpl(SoundArchive::ItemId soundId, SoundArchive::SoundInfo* info) const; virtual bool ReadBankInfoImpl(SoundArchive::ItemId bankId, SoundArchive::BankInfo* info) const; virtual bool ReadPlayerInfoImpl(SoundArchive::ItemId playerId, SoundArchive::PlayerInfo* info) const; - virtual void Impl9(); + virtual bool ReadSoundGroupInfoImpl(SoundArchive::ItemId soundGroupId, SoundArchive::SoundGroupInfo* info) const; virtual void Impl10(); virtual bool ReadWaveArchiveInfoImpl(SoundArchive::ItemId warcId, SoundArchive::WaveArchiveInfo* info) const; virtual void Impl12(); diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 5a769ff4..c8860cd4 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -212,4 +212,13 @@ bool SoundArchive::ReadWaveArchiveInfo(ItemId warcId, WaveArchiveInfo* info) con return result; } + +bool SoundArchive::detail_ReadSoundGroupInfo(ItemId soundGroupId, SoundGroupInfo* info) const { + bool result {m_pFileReader->ReadSoundGroupInfo(soundGroupId, info)}; + + if (m_pParametersHook != nullptr) + result |= m_pParametersHook->ReadSoundGroupInfo(soundGroupId, info); + + return result; +} } // namespace nn::atk \ No newline at end of file From b4fb3de1ba425ab8ecc319fdc88e4804fcda15d9 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 14:26:06 -0400 Subject: [PATCH 304/785] atk: Match `SoundArchive::ReadGroupInfo` --- include/nn/atk/atk_SoundArchiveParametersHook.h | 10 ++++++++-- src/NintendoWare/atk/atk_SoundArchive.cpp | 9 +++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveParametersHook.h b/include/nn/atk/atk_SoundArchiveParametersHook.h index 7e353348..e3831a55 100644 --- a/include/nn/atk/atk_SoundArchiveParametersHook.h +++ b/include/nn/atk/atk_SoundArchiveParametersHook.h @@ -57,7 +57,13 @@ class SoundArchiveParametersHook { return false; } - bool ReadGroupInfo(SoundArchive::ItemId groupId, SoundArchive::GroupInfo* info) const; + bool ReadGroupInfo(SoundArchive::ItemId groupId, SoundArchive::GroupInfo* info) const { + if (m_IsEnable) + return ReadGroupInfoImpl(groupId, info); + + return false; + } + bool ReadFileInfo(SoundArchive::FileId id, SoundArchive::FileInfo* info, int index) const; bool ReadSoundArchivePlayerInfo(SoundArchive::SoundArchivePlayerInfo* info) const { @@ -131,7 +137,7 @@ class SoundArchiveParametersHook { virtual bool ReadBankInfoImpl(SoundArchive::ItemId bankId, SoundArchive::BankInfo* info) const; virtual bool ReadPlayerInfoImpl(SoundArchive::ItemId playerId, SoundArchive::PlayerInfo* info) const; virtual bool ReadSoundGroupInfoImpl(SoundArchive::ItemId soundGroupId, SoundArchive::SoundGroupInfo* info) const; - virtual void Impl10(); + virtual bool ReadGroupInfoImpl(SoundArchive::ItemId groupId, SoundArchive::GroupInfo* info) const; virtual bool ReadWaveArchiveInfoImpl(SoundArchive::ItemId warcId, SoundArchive::WaveArchiveInfo* info) const; virtual void Impl12(); virtual bool ReadSoundArchivePlayerInfoImpl(SoundArchive::SoundArchivePlayerInfo* info) const; diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index c8860cd4..493f5155 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -221,4 +221,13 @@ bool SoundArchive::detail_ReadSoundGroupInfo(ItemId soundGroupId, SoundGroupInfo return result; } + +bool SoundArchive::ReadGroupInfo(GroupInfo* pOutValue, ItemId groupId) const { + bool result {m_pFileReader->ReadGroupInfo(groupId, pOutValue)}; + + if (m_pParametersHook != nullptr) + result |= m_pParametersHook->ReadGroupInfo(groupId, pOutValue); + + return result; +} } // namespace nn::atk \ No newline at end of file From 303d8183b548000dd2512f23f0f255e963fb77d7 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 14:33:59 -0400 Subject: [PATCH 305/785] atk: Match `SoundArchive::detail_ReadFileInfo` --- include/nn/atk/atk_SoundArchiveParametersHook.h | 9 +++++++-- src/NintendoWare/atk/atk_SoundArchive.cpp | 11 +++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveParametersHook.h b/include/nn/atk/atk_SoundArchiveParametersHook.h index e3831a55..4edbbc8d 100644 --- a/include/nn/atk/atk_SoundArchiveParametersHook.h +++ b/include/nn/atk/atk_SoundArchiveParametersHook.h @@ -64,7 +64,12 @@ class SoundArchiveParametersHook { return false; } - bool ReadFileInfo(SoundArchive::FileId id, SoundArchive::FileInfo* info, int index) const; + bool ReadFileInfo(SoundArchive::FileId id, SoundArchive::FileInfo* info, int index) const { + if (m_IsEnable) + return ReadFileInfoImpl(id, info, index); + + return false; + } bool ReadSoundArchivePlayerInfo(SoundArchive::SoundArchivePlayerInfo* info) const { if (m_IsEnable) @@ -139,7 +144,7 @@ class SoundArchiveParametersHook { virtual bool ReadSoundGroupInfoImpl(SoundArchive::ItemId soundGroupId, SoundArchive::SoundGroupInfo* info) const; virtual bool ReadGroupInfoImpl(SoundArchive::ItemId groupId, SoundArchive::GroupInfo* info) const; virtual bool ReadWaveArchiveInfoImpl(SoundArchive::ItemId warcId, SoundArchive::WaveArchiveInfo* info) const; - virtual void Impl12(); + virtual bool ReadFileInfoImpl(SoundArchive::FileId id, SoundArchive::FileInfo* info, int index) const; virtual bool ReadSoundArchivePlayerInfoImpl(SoundArchive::SoundArchivePlayerInfo* info) const; virtual bool ReadSound3DInfoImpl(SoundArchive::ItemId soundId, SoundArchive::Sound3DInfo* info) const; virtual bool ReadSequenceSoundInfoImpl(SoundArchive::ItemId soundId, SoundArchive::SequenceSoundInfo* info) const; diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 493f5155..a98f6014 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -230,4 +230,15 @@ bool SoundArchive::ReadGroupInfo(GroupInfo* pOutValue, ItemId groupId) const { return result; } + +bool SoundArchive::detail_ReadFileInfo(FileId fileId, FileInfo* info) const { + bool result {m_pFileReader->ReadFileInfo(fileId, info, 0)}; + + if (result && m_pParametersHook != nullptr) { + m_pParametersHook->ReadFileInfo(fileId, info, 0); + result = true; + } + + return result; +} } // namespace nn::atk \ No newline at end of file From 1312786594fd46c232a61631560befa97dd17a71 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 14:37:37 -0400 Subject: [PATCH 306/785] atk: Match `SoundArchive::detail_GetWaveArchiveIdTable` --- src/NintendoWare/atk/atk_SoundArchive.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index a98f6014..7328843b 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -241,4 +241,8 @@ bool SoundArchive::detail_ReadFileInfo(FileId fileId, FileInfo* info) const { return result; } + +const detail::Util::Table* SoundArchive::detail_GetWaveArchiveIdTable(ItemId id) const { + return m_pFileReader->GetWaveArchiveIdTable(id); +} } // namespace nn::atk \ No newline at end of file From d4095caec1a713a0ba739cd8cf07babdf36590d7 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 14:59:22 -0400 Subject: [PATCH 307/785] atk: Match `SoundArchive::detail_OpenFileStream` --- include/nn/atk/atk_SoundArchive.h | 8 ++++---- src/NintendoWare/atk/atk_SoundArchive.cpp | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index 1a49edcc..d6e27ef3 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -202,11 +202,11 @@ class SoundArchive { static const u32 InvalidOffset = 0xffffffff; static const u32 InvalidSize = 0xffffffff; - u32 fileSize; - u32 offsetFromFileBlockHead; - const char* externalFilePath; + u32 fileSize {InvalidSize}; + u32 offsetFromFileBlockHead {InvalidOffset}; + const char* externalFilePath {}; - FileInfo(); + FileInfo() = default; }; static_assert(sizeof(FileInfo) == 0x10); diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 7328843b..7afbecd5 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -245,4 +245,21 @@ bool SoundArchive::detail_ReadFileInfo(FileId fileId, FileInfo* info) const { const detail::Util::Table* SoundArchive::detail_GetWaveArchiveIdTable(ItemId id) const { return m_pFileReader->GetWaveArchiveIdTable(id); } + +detail::fnd::FileStream* SoundArchive::detail_OpenFileStream(FileId fileId, void* buffer, size_t size, + void* cacheBuffer, size_t cacheSize) const { + FileInfo fileInfo {}; + detail::fnd::FileStream* stream {}; + if (detail_ReadFileInfo(fileId, &fileInfo)) { + if (fileInfo.externalFilePath == nullptr) { + if (fileInfo.fileSize != FileInfo::InvalidSize && fileInfo.offsetFromFileBlockHead != FileInfo::InvalidOffset) + stream = OpenStream(buffer, size, m_FileBlockOffset + fileInfo.offsetFromFileBlockHead, fileInfo.fileSize); + } + else { + stream = OpenExtStreamImpl(buffer, size, fileInfo.externalFilePath, cacheBuffer, cacheSize); + } + } + + return stream; +} } // namespace nn::atk \ No newline at end of file From ac9f645363eb5fa5116b4806050e6fac2b6499f3 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 15:01:17 -0400 Subject: [PATCH 308/785] atk: Match `SoundArchive::detail_GetAttachedGroupTable` --- include/nn/atk/atk_SoundArchiveFileReader.h | 2 +- src/NintendoWare/atk/atk_SoundArchive.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_SoundArchiveFileReader.h b/include/nn/atk/atk_SoundArchiveFileReader.h index 7c747040..ff41f286 100644 --- a/include/nn/atk/atk_SoundArchiveFileReader.h +++ b/include/nn/atk/atk_SoundArchiveFileReader.h @@ -61,7 +61,7 @@ class SoundArchiveFileReader { u32 GetSoundUserParam(u32) const; bool ReadSoundUserParam(u32*, u32, s32) const; - void* GetAttachedGroupTable(u32) const; // unknown return type + const detail::Util::Table* GetAttachedGroupTable(u32) const; int GetFileBlockOffset() const { return m_Header.GetFileBlockOffset(); } diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 7afbecd5..942c4f54 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -262,4 +262,8 @@ detail::fnd::FileStream* SoundArchive::detail_OpenFileStream(FileId fileId, void return stream; } + +const detail::Util::Table* SoundArchive::detail_GetAttachedGroupTable(FileId fileId) const { + return m_pFileReader->GetAttachedGroupTable(fileId); +} } // namespace nn::atk \ No newline at end of file From 27c0da0af4df24226a4a32304e7995f83b5d256f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 16:31:52 -0400 Subject: [PATCH 309/785] atk: Reorganize `Util` to better match DWARF info --- include/nn/atk/atk_SoundArchive.h | 9 +- include/nn/atk/atk_Util.h | 255 +++++++++++++++--------------- 2 files changed, 136 insertions(+), 128 deletions(-) diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index d6e27ef3..5ce69c50 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -271,8 +271,13 @@ class SoundArchive { void* cacheBuffer, size_t cacheSize) const; const detail::Util::Table* detail_GetAttachedGroupTable(FileId fileId) const; - detail::SoundArchiveParametersHook* detail_GetParametersHook() const; - void detail_SetParametersHook(detail::SoundArchiveParametersHook* parametersHook); + detail::SoundArchiveParametersHook* detail_GetParametersHook() const { + return m_pParametersHook; + } + + void detail_SetParametersHook(detail::SoundArchiveParametersHook* parametersHook) { + m_pParametersHook = parametersHook; + } void SetExternalFileRoot(const char* extFileRoot); bool ReadStreamSoundFilePath(char* outFilePathBuffer, size_t filePathBufferSize, ItemId soundId) const; diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index c04cfbfd..2b9fa771 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -5,6 +5,7 @@ #include #include +#include namespace nn::atk { class SoundArchive; @@ -15,36 +16,54 @@ namespace detail { class PlayerHeapDataManager; class SoundArchiveLoader; struct LoadItemInfo; -struct Util { - NN_NO_COPY(Util); - NN_NO_MOVE(Util); +class Util { +public: + static const int VolumeDbMin {-904}; + static const int VolumeDbMax {60}; - constexpr static s32 VolumeDbMin = -904; - constexpr static s32 VolumeDbMax = 60; - - constexpr static s32 PitchDivisionBit = 0b1000; - constexpr static s32 PitchDivisionRange = 256; + static const int PitchDivisionBit {8}; + static const int PitchDivisionRange {256}; - constexpr static s32 CalcLpfFreqTableSize = 24; - constexpr static u32 CalcLpfFreqIntercept = 0x3E0ADE7F; - constexpr static u32 CalcLpfFreqThreshold = 0x3F666666; - - constexpr static u16 CalcLpfFreqTable[CalcLpfFreqTableSize] { - 80, 100, 128, 160, - 200, 256, 320, 400, - 500, 640, 800, 1000, - 1280, 1600, 2000, 2560, - 3200, 4000, 5120, 6400, - 8000, 10240, 12800, 16000 + enum PanCurve { + PanCurve_Sqrt, + PanCurve_Sincos, + PanCurve_Linear, + }; + + struct PanInfo { + PanCurve curve; + bool centerZeroFlag; + bool zeroClampFlag; + bool isEnableFrontBypass; }; + static_assert(sizeof(PanInfo) == 0x8); - constexpr static BiquadFilterCoefficients LowPassFilterCoefficientsTable32000[CalcLpfFreqTableSize] {}; - constexpr static BiquadFilterCoefficients LowPassFilterCoefficientsTable48000[CalcLpfFreqTableSize] {}; + static u16 CalcLpfFreq(float scale); + static BiquadFilterCoefficients CalcLowPassFilterCoefficients(int frequency, int sampleRate, bool isTableUsed); + static int FindLpfFreqTableIndex(int frequency); + static float CalcPanRatio(float pan, const PanInfo& info, OutputMode mode); + static float CalcSurroundPanRatio(float surroundPan, const PanInfo& info); - template - class Singleton { - public: - static Class* GetInstance(); + static float CalcPitchRatio(int pitch_); + static float CalcVolumeRatio(float dB); + static u16 CalcRandom(); + + static size_t GetSampleByByte(size_t byte, SampleFormat format); // 85 + static size_t GetByteBySample(size_t samples, SampleFormat format); + + static bool IsValidMemoryForDsp(const void* ptr, size_t size); + + static const int CalcLpfFreqTableSize {24}; // 92 + static const float CalcLpfFreqIntercept; // = 0x3E0ADE7F + static const float CalcLpfFreqThreshold;// = 0x3F666666; + static const u16 CalcLpfFreqTable[CalcLpfFreqTableSize]; + static const BiquadFilterCoefficients LowPassFilterCoefficientsTable32000[CalcLpfFreqTableSize]; + static const BiquadFilterCoefficients LowPassFilterCoefficientsTable48000[CalcLpfFreqTableSize]; + + template + struct Table { + CountType count; + ItemType item[1]; }; struct Reference { @@ -65,6 +84,36 @@ struct Util { }; static_assert(sizeof(ReferenceWithSize) == 0xc); + struct ReferenceTable : Table { + const void* GetReferedItem(u32 index) const { + if (count > index) + return util::ConstBytePtr(this, item[index].offset).Get(); + + return nullptr; + } + + const void* GetReferedItem(u32 index, u16 typeId) const { + if (count > index && item[index].typeId == typeId) + return util::ConstBytePtr(this,item[index].offset).Get(); + + return nullptr; + } + + const void* FindReferedItemBy(u16 typeId) const; + }; + + struct ReferenceWithSizeTable : Table { // 164 + const void* GetReferedItem(u32 index) const { + if (count > index) + return util::ConstBytePtr(this, item[index].offset).Get(); + + return nullptr; + } + + const void* GetReferedItemBy(u16 typeId) const; + u32 GetReferedItemSize(u32 index) const; + }; + struct BlockReferenceTable { ReferenceWithSize item[1]; @@ -104,7 +153,7 @@ struct Util { } }; - struct SoundFileHeader { + struct SoundFileHeader { // 239 BinaryFileHeader header; BlockReferenceTable blockReferenceTable; @@ -124,42 +173,6 @@ struct Util { } }; - template - struct Table { - CountType count; - ItemType item[1]; - }; - - struct ReferenceTable : Table { - const void* GetReferedItem(u32 index) const { - if (count > index) - return util::ConstBytePtr(this, item[index].offset).Get(); - - return nullptr; - } - - const void* GetReferedItem(u32 index, u16 typeId) const { - if (count > index && item[index].typeId == typeId) - return util::ConstBytePtr(this,item[index].offset).Get(); - - return nullptr; - } - - const void* FindReferedItemBy(u16 typeId) const; - }; - - struct ReferenceWithSizeTable : Table { - const void* GetReferedItem(u32 index) const { - if (count > index) - return util::ConstBytePtr(this, item[index].offset).Get(); - - return nullptr; - } - - const void* GetReferedItemBy(u16 typeId) const; - u32 GetReferedItemSize(u32 index) const; - }; - struct BitFlag { u32 bitFlag; @@ -203,19 +216,16 @@ struct Util { }; static_assert(sizeof(BitFlag) == 0x4); - enum PanCurve { - PanCurve_Sqrt, - PanCurve_Sincos, - PanCurve_Linear, - }; + static u8 DivideBy8bit(u32 value, int index) { // 334 - struct PanInfo { - PanCurve curve; - bool centerZeroFlag; - bool zeroClampFlag; - bool isEnableFrontBypass; - }; - static_assert(sizeof(PanInfo) == 0x8); + } + + static u8 DivideBy16bit(u32 value, int index) { + + } + + const void* GetWaveFile(u32 waveArchiveId, u32 waveIndex, const SoundArchive& arc, const SoundArchivePlayer& player); + const void* GetWaveFile(u32 waveArchiveId, u32 waveIndex, const SoundArchive& arc, const PlayerHeapDataManager* mgr); enum WaveArchiveLoadStatus { WaveArchiveLoadStatus_Error = -2, @@ -225,89 +235,82 @@ struct Util { WaveArchiveLoadStatus_Partly }; - struct WaveId { + static WaveArchiveLoadStatus GetWaveArchiveOfBank(LoadItemInfo& warcLoadInfo, bool& isLoadIndividual, const void* bankFile, const SoundArchive& arc, const SoundArchiveLoader& mgr); + + static const void* GetWaveFileOfWaveSound(const void* wsdFile, u32 index, const SoundArchive& arc, const SoundArchiveLoader& mgr); + + static ItemType GetItemType(u32 id); + static u32 GetItemIndex(u32 id); + static u32 GetMaskedItemId(u32 id, ItemType type); // 393 + + struct WaveId { // 398 u32 waveArchiveId; u32 waveIndex; }; static_assert(sizeof(WaveId) == 0x8); - struct WaveIdTable { + struct WaveIdTable { // 404 Table table; const WaveId* GetWaveId(u32 index) const { return &table.item[index]; } + + u32 GetCount() const { + return table.count; + } }; - class WarningLogger { + template + class Singleton { // 426 public: - enum LogId { - LogId_ChannelAllocationFailed, - LogId_SoundthreadFailedWakeup, - LogId_LogbufferFull, - LogId_Max, - }; + static CHILD& GetInstance(); + }; + + static int GetSubMixBusFromMainBus(); // 470 + static int GetSubMixBus(AuxBus bus); + static int GetSubMixBus(int bus); + static int GetOutputReceiverMixBufferIndex(const OutputReceiver* pOutputReceiver, int bus, int channel); + static int GetAdditionalSendIndex(int bus); + + class WarningLogger : public Singleton { // 578 + public: + WarningLogger(); + void Log(int logId, int arg0, int arg1); + void Print(); + void SwapBuffer(); + + private: struct LogBuffer { - constexpr static u32 LogCount = 64; + static const int LogCount = 64; struct Element { - - void Print(); + int logId; + int arg0; + int arg1; - s32 logId; - s32 arg0; - s32 arg1; + void Print(); }; static_assert(sizeof(Element) == 0xc); - void Log(s32 logId, s32 arg0, s32 arg1); - void Print(); Element element[LogCount]; - s32 counter; + int counter; + + LogBuffer(); + + void Log(int logId, int arg0, int arg1); + void Print(); + void Reset(); }; static_assert(sizeof(LogBuffer) == 0x304); - void Log(s32 logId, s32 arg0, s32 arg1); - void SwapBuffer(); - void Print(); - - private: LogBuffer m_Buffer0; LogBuffer m_Buffer1; LogBuffer* m_pCurrentBuffer; }; static_assert(sizeof(WarningLogger) == 0x610); - - static u16 CalcLpfFreq(f32 scale); - static BiquadFilterCoefficients CalcLowPassFilterCoefficients(s32 frequency, s32 sampleRate, - bool isTableUsed); - - static s32 FindLpfFreqTableIndex(s32); - - static f32 CalcPanRatio(f32 pan, PanInfo* info, OutputMode mode); - static f32 CalcSurroundPanRatio(f32 surroundPan, PanInfo* info); - static f32 CalcPitchRatio(f32 pitch_); - static f32 CalcVolumeRatio(f32 dB); - static f32 CalcRandom(); - - static void* GetWaveFile(u32, u32, const SoundArchive&, const SoundArchivePlayer&); - static void* GetWaveFile(u32, u32, const SoundArchive&, const PlayerHeapDataManager&); - - static WaveArchiveLoadStatus GetWaveArchiveOfBank(const LoadItemInfo& warcLoadInfo, - bool& isLoadIndividual, const void* bankFile, - const SoundArchive& arc, const SoundArchiveLoader& mgr); - - static void* GetWaveFileOfWaveSound(const void* wsdFile, u32 index, - const SoundArchive& arc, const SoundArchiveLoader& mgr); - - static s32 GetOutputReceiverMixBufferIndex(OutputReceiver*, s32, s32); - - static size_t GetSampleByByte(size_t samples, SampleFormat format); - static size_t GetByteBySample(size_t samples, SampleFormat format); - - static bool IsValidMemoryForDsp(const void* ptr, size_t size); }; static const f32 NoteTable[12] {}; From 1f7ade5e60ac14cb2f527d380bc56f1365240739 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 17:12:12 -0400 Subject: [PATCH 310/785] atk: Add some inline functions from `detail::Util` Implementations were pretty much taken from [TuneBloom](https://github.com/stupidestmodder/TuneBloom/), although I did try checking them on my own. --- include/nn/atk/atk_SoundArchive.h | 29 +++++++-- include/nn/atk/atk_Util.h | 59 ++++++++++++------- .../atk/detail/seq/atk_BankFile.cpp | 10 ++-- 3 files changed, 67 insertions(+), 31 deletions(-) diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index 5ce69c50..41ea5b31 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -231,12 +231,29 @@ class SoundArchive { FileId GetItemFileId(ItemId id) const; FileId GetItemPrefetchFileId(ItemId id) const; - static ItemId GetSoundIdFromIndex(u32 index); - static ItemId GetSoundGroupIdFromIndex(u32 index); - static ItemId GetBankIdFromIndex(u32 index); - static ItemId GetPlayerIdFromIndex(u32 index); - static ItemId GetWaveArchiveIdFromIndex(u32 index); - static ItemId GetGroupIdFromIndex(u32 index); + static ItemId GetSoundIdFromIndex(u32 index) { + return detail::Util::GetMaskedItemId(index, detail::ItemType_Sound); + } + + static ItemId GetSoundGroupIdFromIndex(u32 index) { + return detail::Util::GetMaskedItemId(index, detail::ItemType_SoundGroup); + } + + static ItemId GetBankIdFromIndex(u32 index) { + return detail::Util::GetMaskedItemId(index, detail::ItemType_Bank); + } + + static ItemId GetPlayerIdFromIndex(u32 index) { + return detail::Util::GetMaskedItemId(index, detail::ItemType_Player); + } + + static ItemId GetWaveArchiveIdFromIndex(u32 index) { + return detail::Util::GetMaskedItemId(index, detail::ItemType_WaveArchive); + } + + static ItemId GetGroupIdFromIndex(u32 index) { + return detail::Util::GetMaskedItemId(index, detail::ItemType_Group); + } u32 GetSoundUserParam(ItemId soundId) const; bool ReadSoundUserParam(u32* pOutValue, ItemId soundId, int index) const; diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index 2b9fa771..f7eb28e2 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -39,7 +39,9 @@ class Util { static_assert(sizeof(PanInfo) == 0x8); static u16 CalcLpfFreq(float scale); - static BiquadFilterCoefficients CalcLowPassFilterCoefficients(int frequency, int sampleRate, bool isTableUsed); + static BiquadFilterCoefficients CalcLowPassFilterCoefficients(int frequency, + int sampleRate, + bool isTableUsed); static int FindLpfFreqTableIndex(int frequency); static float CalcPanRatio(float pan, const PanInfo& info, OutputMode mode); static float CalcSurroundPanRatio(float surroundPan, const PanInfo& info); @@ -48,12 +50,12 @@ class Util { static float CalcVolumeRatio(float dB); static u16 CalcRandom(); - static size_t GetSampleByByte(size_t byte, SampleFormat format); // 85 + static size_t GetSampleByByte(size_t byte, SampleFormat format); static size_t GetByteBySample(size_t samples, SampleFormat format); static bool IsValidMemoryForDsp(const void* ptr, size_t size); - static const int CalcLpfFreqTableSize {24}; // 92 + static const int CalcLpfFreqTableSize {24}; static const float CalcLpfFreqIntercept; // = 0x3E0ADE7F static const float CalcLpfFreqThreshold;// = 0x3F666666; static const u16 CalcLpfFreqTable[CalcLpfFreqTableSize]; @@ -102,7 +104,7 @@ class Util { const void* FindReferedItemBy(u16 typeId) const; }; - struct ReferenceWithSizeTable : Table { // 164 + struct ReferenceWithSizeTable : Table { const void* GetReferedItem(u32 index) const { if (count > index) return util::ConstBytePtr(this, item[index].offset).Get(); @@ -153,7 +155,7 @@ class Util { } }; - struct SoundFileHeader { // 239 + struct SoundFileHeader { BinaryFileHeader header; BlockReferenceTable blockReferenceTable; @@ -216,16 +218,18 @@ class Util { }; static_assert(sizeof(BitFlag) == 0x4); - static u8 DivideBy8bit(u32 value, int index) { // 334 - + static u8 DivideBy8bit(u32 value, int index) { + return static_cast(value >> (8 * index)); } static u8 DivideBy16bit(u32 value, int index) { - + return static_cast(value >> (16 * index)); } - const void* GetWaveFile(u32 waveArchiveId, u32 waveIndex, const SoundArchive& arc, const SoundArchivePlayer& player); - const void* GetWaveFile(u32 waveArchiveId, u32 waveIndex, const SoundArchive& arc, const PlayerHeapDataManager* mgr); + const void* GetWaveFile(u32 waveArchiveId, u32 waveIndex, + const SoundArchive& arc, const SoundArchivePlayer& player); + const void* GetWaveFile(u32 waveArchiveId, u32 waveIndex, + const SoundArchive& arc, const PlayerHeapDataManager* mgr); enum WaveArchiveLoadStatus { WaveArchiveLoadStatus_Error = -2, @@ -235,21 +239,36 @@ class Util { WaveArchiveLoadStatus_Partly }; - static WaveArchiveLoadStatus GetWaveArchiveOfBank(LoadItemInfo& warcLoadInfo, bool& isLoadIndividual, const void* bankFile, const SoundArchive& arc, const SoundArchiveLoader& mgr); + static WaveArchiveLoadStatus GetWaveArchiveOfBank(LoadItemInfo& warcLoadInfo, + bool& isLoadIndividual, + const void* bankFile, + const SoundArchive& arc, + const SoundArchiveLoader& mgr); + + static const void* GetWaveFileOfWaveSound(const void* wsdFile, + u32 index, + const SoundArchive& arc, + const SoundArchiveLoader& mgr); + + static ItemType GetItemType(u32 id) { + return static_cast(id >> 24); + } - static const void* GetWaveFileOfWaveSound(const void* wsdFile, u32 index, const SoundArchive& arc, const SoundArchiveLoader& mgr); + static u32 GetItemIndex(u32 id) { + return id & 0x00FFFFFF; + } - static ItemType GetItemType(u32 id); - static u32 GetItemIndex(u32 id); - static u32 GetMaskedItemId(u32 id, ItemType type); // 393 + static u32 GetMaskedItemId(u32 id, ItemType type) { + return id | (type << 24); + } - struct WaveId { // 398 + struct WaveId { u32 waveArchiveId; u32 waveIndex; }; static_assert(sizeof(WaveId) == 0x8); - struct WaveIdTable { // 404 + struct WaveIdTable { Table table; const WaveId* GetWaveId(u32 index) const { @@ -262,18 +281,18 @@ class Util { }; template - class Singleton { // 426 + class Singleton { public: static CHILD& GetInstance(); }; - static int GetSubMixBusFromMainBus(); // 470 + static int GetSubMixBusFromMainBus(); static int GetSubMixBus(AuxBus bus); static int GetSubMixBus(int bus); static int GetOutputReceiverMixBufferIndex(const OutputReceiver* pOutputReceiver, int bus, int channel); static int GetAdditionalSendIndex(int bus); - class WarningLogger : public Singleton { // 578 + class WarningLogger : public Singleton { public: WarningLogger(); diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp index 866c64a5..3839c724 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp @@ -204,7 +204,7 @@ u8 BankFile::VelocityRegion::GetVolume() const { u32 value; bool result {optionParameter.GetValue(&value, VelocityRegionBitFlag_Volume)}; if (result) - return value; + return Util::DivideBy8bit(value, 0); return DefaultVolume; } @@ -213,7 +213,7 @@ u8 BankFile::VelocityRegion::GetPan() const { u32 value; bool result {optionParameter.GetValue(&value, VelocityRegionBitFlag_Pan)}; if (result) - return value; + return Util::DivideBy8bit(value, 0); return DefaultPan; } @@ -231,7 +231,7 @@ bool BankFile::VelocityRegion::IsIgnoreNoteOff() const { u32 value; bool result {optionParameter.GetValue(&value, VelocityRegionBitFlag_InstrumentNoteParam)}; if (result) - return static_cast(value) != 0; + return Util::DivideBy8bit(value, 0) != 0; return DefaultIgnoreNoteOff; } @@ -240,7 +240,7 @@ u8 BankFile::VelocityRegion::GetKeyGroup() const { u32 value; bool result {optionParameter.GetValue(&value, VelocityRegionBitFlag_InstrumentNoteParam)}; if (result) - return value >> 8; + return Util::DivideBy8bit(value, 1); return DefaultKeyGroup; } @@ -249,7 +249,7 @@ u8 BankFile::VelocityRegion::GetInterpolationType() const { u32 value; bool result {optionParameter.GetValue(&value, VelocityRegionBitFlag_InstrumentNoteParam)}; if (result) - return value >> 16; + return Util::DivideBy8bit(value, 2); return DefaultInterpolationType; } From 6d88253873f312bc8aa2ac35f2e88b3c823439bc Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 19 Aug 2026 17:20:07 -0400 Subject: [PATCH 311/785] atk: Match empty `SoundArchive` virtual functions --- src/NintendoWare/atk/atk_SoundArchive.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 942c4f54..f89c9c70 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -266,4 +266,12 @@ detail::fnd::FileStream* SoundArchive::detail_OpenFileStream(FileId fileId, void const detail::Util::Table* SoundArchive::detail_GetAttachedGroupTable(FileId fileId) const { return m_pFileReader->GetAttachedGroupTable(fileId); } + +void SoundArchive::FileAccessBegin() const {} + +void SoundArchive::FileAccessEnd() const {} + +bool SoundArchive::IsAddon() const { + return false; +} } // namespace nn::atk \ No newline at end of file From e8948483348cb901cb642d4dfa308e41990a0b32 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 20 Aug 2026 13:37:19 -0400 Subject: [PATCH 312/785] util: Add string utils Only `nn::util::Strlcpy` has been verified to match. All others are only placeholders for now. --- include/nn/util/util_StringUtil.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/nn/util/util_StringUtil.h b/include/nn/util/util_StringUtil.h index 54eb949c..cc73c5b5 100644 --- a/include/nn/util/util_StringUtil.h +++ b/include/nn/util/util_StringUtil.h @@ -48,4 +48,4 @@ inline s32 Strncmp(const T* pStr1, const T* pStr2, s32 count) { return c1 - c2; } -} // namespace nn::util \ No newline at end of file +} // namespace nn::util From d5ccf6f5efceeab556ac665c3f63eef2bef7b422 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 20 Aug 2026 14:44:14 -0400 Subject: [PATCH 313/785] atk: Match `SoundArchive::SetExternalFileRoot` --- src/NintendoWare/atk/atk_SoundArchive.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index f89c9c70..65f3f194 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -1,5 +1,10 @@ #include +#include +#include + +#include + #include #include @@ -267,6 +272,19 @@ const detail::Util::Table* SoundArchive::detail_GetAttachedGroupTable(FileI return m_pFileReader->GetAttachedGroupTable(fileId); } +void SoundArchive::SetExternalFileRoot(const char* extFileRoot) { + size_t len {std::strlen(extFileRoot)}; + size_t nullPos {len + 1}; + + util::Strlcpy(m_ExtFileRoot, extFileRoot, std::min(sizeof(m_ExtFileRoot), nullPos)); + + if (extFileRoot[len - 1] != '/') { + m_ExtFileRoot[len] = '/'; + ++len; + } + m_ExtFileRoot[len] = '\0'; +} + void SoundArchive::FileAccessBegin() const {} void SoundArchive::FileAccessEnd() const {} From ea37019f94ff2919f8e3587e1b8a5818447e65b0 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 20 Aug 2026 14:47:59 -0400 Subject: [PATCH 314/785] atk: Match `AddonSoundArchiveContainer::Initialize` --- .../atk/detail/atk_AddonSoundArchiveContainer.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp b/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp index 52699290..3df73066 100644 --- a/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp +++ b/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp @@ -1,5 +1,7 @@ #include +#include + namespace nn::atk::detail { AddonSoundArchiveContainer::AddonSoundArchiveContainer() = default; @@ -9,6 +11,17 @@ AddonSoundArchiveContainer::~AddonSoundArchiveContainer() { m_pSoundDataManager = nullptr; } +bool AddonSoundArchiveContainer::Initialize(const char* soundArchiveName, + const AddonSoundArchive* pSoundArchive, + const SoundDataManager* pSoundDataManager) { + util::Strlcpy(m_SoundArchiveName, soundArchiveName, sizeof(m_SoundArchiveName)); + m_IsActive = true; + m_pSoundArchive = pSoundArchive; + m_pSoundDataManager = pSoundDataManager; + + return true; +} + void AddonSoundArchiveContainer::Finalize() { m_IsActive = false; m_SoundArchiveName[0] = '\0'; From bf5315f7839a7ab1d7334def6c9ba79bde7345bc Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 22 Aug 2026 11:25:31 -0400 Subject: [PATCH 315/785] atk: Match `AddonSoundArchiveContainer::IsSameName` This also matches `nn::util::Strnlen` and `nn::util::Strncmp` --- .../atk/detail/atk_AddonSoundArchiveContainer.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp b/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp index 3df73066..936d5c93 100644 --- a/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp +++ b/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp @@ -28,4 +28,14 @@ void AddonSoundArchiveContainer::Finalize() { m_pSoundArchive = nullptr; m_pSoundDataManager = nullptr; } + +bool AddonSoundArchiveContainer::IsSameName(const char* name) const { + int nameLength {util::Strnlen(name, SoundArchiveNameLengthMax)}; + + if (nameLength == SoundArchiveNameLengthMax) + return false; + + int result {util::Strncmp(name, m_SoundArchiveName, SoundArchiveNameLengthMax)}; + return result == 0; +} } // namespace nn::atk::detail \ No newline at end of file From c441cad675b51c392aefae07f3c15412f05c16fb Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 22 Aug 2026 14:26:11 -0400 Subject: [PATCH 316/785] atk: Match `SoundArchive::ReadStreamSoundFilePath` --- include/nn/atk/atk_SoundArchive.h | 1 + src/NintendoWare/atk/atk_SoundArchive.cpp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index 41ea5b31..a98268dc 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -297,6 +297,7 @@ class SoundArchive { } void SetExternalFileRoot(const char* extFileRoot); + bool ReadStreamSoundFilePath(char* outFilePathBuffer, size_t filePathBufferSize, ItemId soundId) const; virtual void FileAccessBegin() const; diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 65f3f194..bfbf0a57 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -285,6 +285,26 @@ void SoundArchive::SetExternalFileRoot(const char* extFileRoot) { m_ExtFileRoot[len] = '\0'; } +bool SoundArchive::ReadStreamSoundFilePath(char* outFilePathBuffer, size_t filePathBufferSize, ItemId soundId) const { + if (GetSoundType(soundId) == SoundType_Stream) { + SoundInfo soundInfo; + if (!ReadSoundInfo(&soundInfo, soundId)) + return false; + + FileInfo fileInfo; + if (!detail_ReadFileInfo(soundInfo.fileId, &fileInfo)) + return false; + + const char* result {}; + if (fileInfo.externalFilePath != nullptr) + result = detail_GetExternalFileFullPath(fileInfo.externalFilePath, outFilePathBuffer, filePathBufferSize); + + return result != nullptr; + } + + return false; +} + void SoundArchive::FileAccessBegin() const {} void SoundArchive::FileAccessEnd() const {} From ef19f636f6e1254a4ec36f2c52beda16f6510168 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 23 Aug 2026 18:03:57 -0400 Subject: [PATCH 317/785] atk: Add draft implementation for `SoundArchive::detail_GetExternalFileFullPath` --- include/nn/atk/fnd/string/atkfnd_String.h | 20 ++++++++++++++++- src/NintendoWare/atk/atk_SoundArchive.cpp | 26 +++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/fnd/string/atkfnd_String.h b/include/nn/atk/fnd/string/atkfnd_String.h index 7b9637ef..50887c58 100644 --- a/include/nn/atk/fnd/string/atkfnd_String.h +++ b/include/nn/atk/fnd/string/atkfnd_String.h @@ -1 +1,19 @@ -#pragma once \ No newline at end of file +#pragma once + +#include + +#include + +namespace nn::atk::detail::fnd { +// UNSURE +inline size_t strncat(char* dst, size_t dstCount, const char* src, size_t srcCount) { + size_t length {strlen(src)}; + if (length + srcCount + 1 < dstCount) + length = srcCount + 1; + else + length = dstCount - 1 - length; + + std::strncat(dst, src, length); + return length; +} +} // namespace atk::detail::fnd \ No newline at end of file diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index bfbf0a57..e4e7a7e5 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -7,6 +7,7 @@ #include #include +#include "nn/atk/fnd/string/atkfnd_String.h" namespace nn::atk { SoundArchive::SoundArchive() { @@ -309,6 +310,31 @@ void SoundArchive::FileAccessBegin() const {} void SoundArchive::FileAccessEnd() const {} +// NON_MATCHING: still unsure on fnd::strncat's implementation, +// or the whole function really. Leaving as TODO +const char* SoundArchive::detail_GetExternalFileFullPath(const char* externalFilePath, + char* pathBuffer, + size_t bufSize) const { + if (*externalFilePath != '/') { + size_t dirLen {strlen(externalFilePath)}; + size_t fileLen {strlen(m_ExtFileRoot)}; + if (fileLen + dirLen < bufSize) { + if (bufSize > fileLen + 1) + bufSize += 1; + + util::Strlcpy(pathBuffer, externalFilePath, bufSize); + detail::fnd::strncat(pathBuffer, bufSize, m_ExtFileRoot, fileLen); + pathBuffer[bufSize - 1] = '\0'; + externalFilePath = pathBuffer; + } + else { + externalFilePath = nullptr; + } + } + + return externalFilePath; +} + bool SoundArchive::IsAddon() const { return false; } From 6a0301e1d0be5e626135d55998f4a06a8fd3d2f1 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 23 Aug 2026 18:50:36 -0400 Subject: [PATCH 318/785] atk: Match `BusMixVolumePacket::GetRequiredMemSize` --- include/nn/atk/atk_BusMixVolumePacket.h | 46 +++++++++++++++++-- .../atk/detail/atk_BusMixVolumePacket.cpp | 11 +++++ 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/include/nn/atk/atk_BusMixVolumePacket.h b/include/nn/atk/atk_BusMixVolumePacket.h index 7e786bda..f40aa7e7 100644 --- a/include/nn/atk/atk_BusMixVolumePacket.h +++ b/include/nn/atk/atk_BusMixVolumePacket.h @@ -3,20 +3,58 @@ #include namespace nn::atk::detail { -class BusMixVolumePacket { +struct BusMixVolumePacket { public: - static size_t GetRequiredMemSize(s32 busCount); + static size_t GetRequiredMemSize(int busCount); - bool Initialize(void* buffer, size_t size, s32 busCount); + BusMixVolumePacket(); + + bool Initialize(void* buffer, size_t size, int busCount); void Finalize(); void Reset(); + int GetBusCount() const { + return m_BusCount; + } + + float GetBusMixVolume(int waveChannel, int mixChannel) const { + return m_BusMixVolume.volume[waveChannel][mixChannel]; + } + + const OutputBusMixVolume& GetBusMixVolume() const { + return m_BusMixVolume; + } + + void SetBusMixVolume(int waveChannel, int mixChannel, float volume) { + m_BusMixVolume.volume[waveChannel][mixChannel] = volume; + } + + void SetBusMixVolume(const OutputBusMixVolume& busMixVolume) { + m_BusMixVolume = busMixVolume; + } + + bool IsUsed() const { + return m_IsUsed; + } + + void SetUsed(bool isUsed) { + m_IsUsed = isUsed; + } + + bool IsEnabled(int bus) const { + return m_pIsEnabledTable[bus]; + } + + void SetEnabled(int bus, bool isEnabled) { + m_pIsEnabledTable[bus] = isEnabled; + } + private: OutputBusMixVolume m_BusMixVolume; bool m_IsUsed; bool* m_pIsEnabledTable; - s32 m_BusCount; + int m_BusCount; }; static_assert(sizeof(BusMixVolumePacket) == 0xd8); } // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/atk_BusMixVolumePacket.cpp b/src/NintendoWare/atk/detail/atk_BusMixVolumePacket.cpp index e69de29b..b6d01310 100644 --- a/src/NintendoWare/atk/detail/atk_BusMixVolumePacket.cpp +++ b/src/NintendoWare/atk/detail/atk_BusMixVolumePacket.cpp @@ -0,0 +1,11 @@ +#include +#include + +namespace nn::atk::detail { +BusMixVolumePacket::BusMixVolumePacket() = default; + +size_t BusMixVolumePacket::GetRequiredMemSize(int busCount) { + size_t result {util::align_up(busCount, 8)}; + return result; +} +} // namespace nn::atk::detail \ No newline at end of file From e796606acd16fc84750e955d2b86e59ededb59ff Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 24 Aug 2026 11:28:26 -0400 Subject: [PATCH 319/785] atk: Match `DspadpcmReader::ReadWaveInfo` --- include/nn/atk/atk_DspadpcmReader.h | 2 +- .../atk/detail/dsp/atk_DspadpcmReader.cpp | 51 +++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_DspadpcmReader.h b/include/nn/atk/atk_DspadpcmReader.h index c7e546ca..2b46b74a 100644 --- a/include/nn/atk/atk_DspadpcmReader.h +++ b/include/nn/atk/atk_DspadpcmReader.h @@ -14,6 +14,6 @@ class DspadpcmReader { bool ReadWaveInfo(WaveInfo* info) const; private: - const void* m_pDspadpcmData; + const void* m_pDspadpcmData {}; }; } // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/dsp/atk_DspadpcmReader.cpp b/src/NintendoWare/atk/detail/dsp/atk_DspadpcmReader.cpp index e69de29b..5a419c2f 100644 --- a/src/NintendoWare/atk/detail/dsp/atk_DspadpcmReader.cpp +++ b/src/NintendoWare/atk/detail/dsp/atk_DspadpcmReader.cpp @@ -0,0 +1,51 @@ +#include + +#include + +#include + +namespace nn::atk::detail { +namespace { +struct InternalDSPADPCMInfo { + u32 sampleCount; + u32 adpcmNibbleCount; + u32 sampleRate; + u16 loopFlag; + u16 format; + u32 sa; + u32 ea; + u32 ca; + u16 coef[16]; + u16 gain; + u16 ps; + u16 yn1; + u16 yn2; + u16 lps; + u16 lyn1; + u16 lyn2; + u16 pad[11]; +}; +static_assert(sizeof(InternalDSPADPCMInfo) == 0x60); +} // anonymous namespace + +DspadpcmReader::DspadpcmReader() = default; + +bool DspadpcmReader::ReadWaveInfo(WaveInfo* info) const { + const InternalDSPADPCMInfo& data {*util::ConstBytePtr(m_pDspadpcmData).Get()}; + + info->sampleFormat = SampleFormat_DspAdpcm; + info->loopFlag = false; + info->channelCount = 1; + info->sampleRate = data.sampleRate; + info->loopStartFrame = 0; + info->loopEndFrame = data.sampleCount; + + info->channelParam[0].dataAddress = util::ConstBytePtr(m_pDspadpcmData, sizeof(InternalDSPADPCMInfo)).Get(); + std::memcpy(info->channelParam[0].adpcmParam.coef, data.coef, sizeof(data.coef)); + int yn1 = data.yn1; + info->channelParam[0].adpcmParam.predScale = data.ps; + info->channelParam[0].adpcmParam.yn1 = yn1; + info->channelParam[0].adpcmParam.yn2 = data.yn2; + return true; +} +} // namespace nn::atk::detail \ No newline at end of file From 1760eb459dfa083c839d480cbcdf201fe1ee6078 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 24 Aug 2026 17:33:28 -0400 Subject: [PATCH 320/785] atk: Add some header functions --- include/nn/atk/atk_MoveValue.h | 30 +++++++++++++++++++++++++----- include/nn/atk/atk_WavBinary.h | 31 ++++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/include/nn/atk/atk_MoveValue.h b/include/nn/atk/atk_MoveValue.h index 0a8ea461..5543f244 100644 --- a/include/nn/atk/atk_MoveValue.h +++ b/include/nn/atk/atk_MoveValue.h @@ -1,13 +1,33 @@ #pragma once namespace nn::atk::detail { -template +template class MoveValue { public: + MoveValue() = default; + + void InitValue(ValueType value) { + m_Origin = value; + m_Target = value; + m_Counter = 0; + m_Frame = 0; + } + + void SetTarget(ValueType targetValue, CountType frames); + + ValueType GetTarget() const; + ValueType GetValue() const; + + void Update(); + + bool IsFinished() const; + + CountType GetRemainingCount() const; + private: - T1 m_Origin; - T1 m_Target; - T2 m_Frame; - T2 m_Counter; + ValueType m_Origin {}; + ValueType m_Target {}; + CountType m_Frame {}; + CountType m_Counter {}; }; } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/atk_WavBinary.h b/include/nn/atk/atk_WavBinary.h index 0bea0947..02712dc6 100644 --- a/include/nn/atk/atk_WavBinary.h +++ b/include/nn/atk/atk_WavBinary.h @@ -2,22 +2,43 @@ #include -#include +#include +#include namespace nn::atk::detail { struct ChunkHeader { + ChunkHeader() = default; + + explicit ChunkHeader(u32 id); + ChunkHeader(u32 id, u32 size); + u32 id; fnd::PcBinU32 size; }; static_assert(sizeof(ChunkHeader) == 0x8); struct RiffChunk { + static const u32 ValidId {1179011410}; // "RIFF" + + RiffChunk() = default; + + bool IsValid(); + ChunkHeader header; u32 formatType; }; static_assert(sizeof(RiffChunk) == 0xc); struct FmtChunk { + static const u32 ValidId {0x20746d66}; // "fmt " + static const u16 FormatPcm {SampleFormat_PcmS16}; + + FmtChunk() = default; + + static u32 GetValidBodySize(); + + bool IsValid(); + ChunkHeader header; fnd::PcBinU16 formatTag; fnd::PcBinU16 channels; @@ -29,11 +50,19 @@ struct FmtChunk { static_assert(sizeof(FmtChunk) == 0x18); struct DataChunk { + static const u32 ValidId {0x61746164}; // "data" + + DataChunk() = default; + + bool IsValid(); + ChunkHeader header; }; static_assert(sizeof(DataChunk) == 0x8); struct WaveBinaryHeader { + WaveBinaryHeader() = default; + RiffChunk riffChunk; FmtChunk fmtChunk; DataChunk dataChunk; From c5dede77749a58e3f9303eb70c10d63967ac0a93 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 24 Aug 2026 17:50:41 -0400 Subject: [PATCH 321/785] atk: Matched a lot of `HeapBase` functions Functions matched: - `HeapBase::FindListContainHeap` - `HeapBase::FindContainHeap(const void*)` - `HeapBase::FindParentHeap` - `HeapBase::SetFillValue` - `HeapBase::GetFillValue` - `HeapBase::GetHeapType` - `HeapBase::Initialize` - `HeapBase::LockHeap` - `HeapBase::UnlockHeap` - `HeapBase::FillFreeMemory` - `HeapBase::FillNoUseMemory` - `HeapBase::FillAllocMemory` - `HeapBase::GetOptionFlag` --- CMakeLists.txt | 26 ++-- include/nn/atk/fnd/basis/atkfnd_HeapBase.h | 26 ++-- .../atk/fnd/basis/atkfnd_HeapBase.cpp | 143 ++++++++++++++---- 3 files changed, 143 insertions(+), 52 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3bfa6a17..d2e18179 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -426,7 +426,7 @@ PUBLIC include/nn/atk/detail/atk_RegionManager.h include/nn/atk/detail/atk_MemoryFileStream.h include/nn/atk/detail/atk_SoundArchiveManager.h - + include/nn/atk/fnd/basis/atkfnd_Config.h include/nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h include/nn/atk/fnd/basis/atkfnd_HeapBase.h @@ -445,8 +445,19 @@ PUBLIC include/nn/atk/fnd/os/atkfnd_ScopedLock.h include/nn/atk/fnd/os/atkfnd_Thread.h include/nn/atk/fnd/string/atkfnd_String.h - + PRIVATE + src/NintendoWare/atk/fnd/basis/atkfnd_FrameHeapImpl.cpp + src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp + src/NintendoWare/atk/fnd/basis/atkfnd_Time.win32.cpp + src/NintendoWare/atk/fnd/basis/atkfnd_WorkBufferAllocator.cpp + src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp + src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp + src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp + src/NintendoWare/atk/fnd/io/atkfnd_StreamCache.cpp + src/NintendoWare/atk/fnd/os/atkfnd_Thread.cpp + src/NintendoWare/atk/fnd/os/atkfnd_Thread.win32.cpp + src/NintendoWare/atk/atk_SoundArchive.cpp src/NintendoWare/atk/atk_FsSoundArchive.cpp src/NintendoWare/atk/atk_SequenceSoundHandle.cpp @@ -550,17 +561,6 @@ PRIVATE src/NintendoWare/atk/util/atk_DeviceOutRecorder.cpp src/NintendoWare/atk/util/atk_ProfileReader.cpp src/NintendoWare/atk/util/atk_TaskProfileReader.cpp - - src/NintendoWare/atk/fnd/basis/atkfnd_FrameHeapImpl.cpp - src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp - src/NintendoWare/atk/fnd/basis/atkfnd_Time.win32.cpp - src/NintendoWare/atk/fnd/basis/atkfnd_WorkBufferAllocator.cpp - src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp - src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp - src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp - src/NintendoWare/atk/fnd/io/atkfnd_StreamCache.cpp - src/NintendoWare/atk/fnd/os/atkfnd_Thread.cpp - src/NintendoWare/atk/fnd/os/atkfnd_Thread.win32.cpp ) target_include_directories(NintendoSDK PUBLIC include/) diff --git a/include/nn/atk/fnd/basis/atkfnd_HeapBase.h b/include/nn/atk/fnd/basis/atkfnd_HeapBase.h index 328046b7..4459adca 100644 --- a/include/nn/atk/fnd/basis/atkfnd_HeapBase.h +++ b/include/nn/atk/fnd/basis/atkfnd_HeapBase.h @@ -12,7 +12,7 @@ class HeapBase : public util::IntrusiveListBaseNode { HeapType_Exp, HeapType_Frame, HeapType_Unit, - HeapTyep_Unknown, + HeapType_Unknown, }; enum FillType { @@ -34,7 +34,7 @@ class HeapBase : public util::IntrusiveListBaseNode { static const int ErrorPrint = 1; - constexpr static int MIN_ALIGNMENT = DefaultAlignment; + static const int MIN_ALIGNMENT = DefaultAlignment; static HeapBase* FindContainHeap(const void* memBlock); static HeapBase* FindParentHeap(const HeapBase* pChild); @@ -45,7 +45,7 @@ class HeapBase : public util::IntrusiveListBaseNode { size_t GetTotalSize(); size_t GetTotalUsableSize(); - u32 SetFillValue(FillType type, u32 value); + u32 SetFillValue(FillType type, u32 val); u32 GetFillValue(FillType type); HeapType GetHeapType(); @@ -54,9 +54,17 @@ class HeapBase : public util::IntrusiveListBaseNode { void Initialize(u32 signature, void* heapStart, void* heapEnd, u16 optFlag); void Finalize(); - u32 GetSignature() const; - void* GetHeapStart() const; - void* GetHeapEnd() const; + u32 GetSignature() const { + return m_Signature; + } + + void* GetHeapStart() const { + return mHeapStart; + } + + void* GetHeapEnd() const { + return mHeapEnd; + } void LockHeap(); void UnlockHeap(); @@ -70,11 +78,7 @@ class HeapBase : public util::IntrusiveListBaseNode { static HeapList* FindListContainHeap(HeapBase* pHeapBase); u16 GetOptionFlag(); - void SetOptionFlag(u16 optFlag) { - u32 maskBits {0xff}; - u16 newVal = optFlag & maskBits; - m_Attribute = newVal; - }; + void SetOptionFlag(u16 optFlag); void* mHeapStart; void* mHeapEnd; diff --git a/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp b/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp index 889cb812..3833ec59 100644 --- a/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp +++ b/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp @@ -1,19 +1,97 @@ #include + #include -#include "nn/atk/fnd/basis/atkfnd_Inlines.h" +#include namespace nn::atk::detail::fnd { -static HeapBase::HeapList sRootList; -u32 sFillVals[HeapBase::FillType_Max] { 0xC3C3C3C3, 0xF3F3F3F3, 0xD3D3D3D3 }; +namespace { + HeapBase::HeapList sRootList; + u32 sFillVals[HeapBase::FillType_Max] { 0xC3C3C3C3, 0xF3F3F3F3, 0xD3D3D3D3 }; +} // anonymous namespace + +HeapBase::HeapList* HeapBase::FindListContainHeap(HeapBase* pHeapBase) { + HeapList* pList {&sRootList}; + HeapBase* pContainHeapBase {FindContainHeap(pList, pHeapBase)}; + + if (pContainHeapBase != nullptr) + pList = &pContainHeapBase->m_ChildList; + + return pList; +} + +// NON_MATCHING: commented because it needs to not be inlined for other functions to match +// HeapBase* HeapBase::FindContainHeap(HeapList* pList, const void* memBlock) { +// uintptr_t memBlockAddress {reinterpret_cast(memBlock)}; + +// for (auto itr {pList->begin()}; pList->end() != itr; ++itr) { +// auto curItr {++itr}; + +// if (&pList->front() == &*curItr) +// return nullptr; + +// if (reinterpret_cast(curItr->mHeapStart) <= memBlockAddress && memBlockAddress < reinterpret_cast(curItr->mHeapEnd)) { +// HeapBase* pChildHeapBase {FindContainHeap(&curItr->m_ChildList, &*curItr)}; + +// if (pChildHeapBase != nullptr) +// return pChildHeapBase; + +// } +// } + +// return nullptr; +// } + +HeapBase* HeapBase::FindContainHeap(const void* memBlock) { + return FindContainHeap(&sRootList, memBlock); +} + +HeapBase* HeapBase::FindParentHeap(const HeapBase* pChild) { + u64 heapAddress {reinterpret_cast(pChild)}; + + for (auto itr {sRootList.begin()}; itr != sRootList.end();) { + auto curItr {itr++}; + + if (reinterpret_cast(curItr->mHeapStart) <= heapAddress && reinterpret_cast(curItr->mHeapEnd) > heapAddress) + return FindContainHeap(&curItr->m_ChildList, &*curItr); + } + + return nullptr; +} + +u32 HeapBase::SetFillValue(FillType type, u32 val) { + u32 oldVal {sFillVals[type]}; + sFillVals[type] = val; + + return oldVal; +} + +u32 HeapBase::GetFillValue(FillType type) { + return sFillVals[type]; +} + +HeapBase::HeapType HeapBase::GetHeapType() { + switch (m_Signature) { + case ExpHeapSignature: + return HeapType::HeapType_Exp; + + case FrameHeapSignature: + return HeapType::HeapType_Frame; + + case UnitHeapSignature: + return HeapType::HeapType_Unit; + + default: + return HeapType::HeapType_Unknown; + } +} -// NON-MATCHING: unknown reason. Possibly something to do with global variables void HeapBase::Initialize(u32 signature, void* heapStart, void* heapEnd, u16 optFlag) { m_Signature = signature; mHeapStart = heapStart; mHeapEnd = heapEnd; SetOptionFlag(optFlag); - u32 diff = GetOffsetFromPtr(heapStart, heapEnd); + u32 diff = GetOffsetFromPtr(heapStart, heapEnd); FillNoUseMemory(heapStart, diff); HeapList* pList {FindListContainHeap(this)}; @@ -21,42 +99,51 @@ void HeapBase::Initialize(u32 signature, void* heapStart, void* heapEnd, u16 opt pList->push_back(*this); } -// NON-MATCHING +// NON_MATCHING +void HeapBase::Finalize() { + HeapList* pList {FindListContainHeap(this)}; + + if (pList != nullptr) + pList->erase(pList->begin()); + + m_Signature = 0; +} + +void HeapBase::LockHeap() {} + +void HeapBase::UnlockHeap() {} + void HeapBase::FillFreeMemory(void* address, size_t size) { - if ((m_Attribute >> 1 & 1) != 0) + if ((m_Attribute & OptionDebugFill) != 0) memset(address, static_cast(GetFillValue(FillType_Free)), size); } -// NON-MATCHING +void HeapBase::FillNoUseMemory(void* address, size_t size) { + if ((m_Attribute & OptionDebugFill) != 0) + memset(address, static_cast(GetFillValue(FillType_NoUse)), size); +} + void HeapBase::FillAllocMemory(void* address, size_t size) { - if (m_Attribute & 1) { + if (m_Attribute & OptionZeroClear) { memset(address, 0, size); return; } - if ((m_Attribute >> 1 & 1) != 0) - memset(address, GetFillValue(FillType_Alloc), size); + if ((m_Attribute & OptionDebugFill) != 0) + memset(address, static_cast(GetFillValue(FillType_Alloc)), size); } -// NON-MATCHING -void HeapBase::FillNoUseMemory(void* address, size_t size) { - if ((m_Attribute >> 1 & 1) != 0) - memset(address, (int)GetFillValue(FillType_NoUse), size); -} -// Inlined -u32 HeapBase::GetFillValue(FillType type) { - return sFillVals[type]; +u16 HeapBase::GetOptionFlag() { + return m_Attribute & 0xFF; } -// Inlined -HeapBase::HeapList* HeapBase::FindListContainHeap(HeapBase* pHeapBase) { - HeapList* pList {&sRootList}; - HeapBase* pContainHeapBase {FindContainHeap(pList, pHeapBase)}; - - if (pContainHeapBase != nullptr) - pList = &pContainHeapBase->m_ChildList; - - return pList; +// NON_MATCHING: matches inlined, but not standalone +void HeapBase::SetOptionFlag(u16 optFlag) { + if (optFlag >= 0) { + u32 maskBits {0xff}; + u32 newVal = optFlag & maskBits; + m_Attribute = newVal; + } } } // namespace nn::atk::detail::fnd \ No newline at end of file From f2a9f456db506161441fc85138869ac25a62e80d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 12:52:12 -0400 Subject: [PATCH 322/785] atk: Match `WaveSoundFile::FileHeader::GetInfoBlock` Also rearranged `WaveSoundFile` to better match DWARF --- CMakeLists.txt | 31 +++---- include/nn/atk/atk_WaveSoundFile.h | 85 ++++++++++++------- .../atk/detail/wsd/atk_WaveSoundFile.cpp | 10 +++ 3 files changed, 78 insertions(+), 48 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d2e18179..a41f222b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -401,9 +401,11 @@ PUBLIC include/nn/atk/atk_VoiceCommand.h include/nn/atk/atk_VolumeThroughModePacket.h include/nn/atk/atk_WavBinary.h + include/nn/atk/atk_WavOutFileStream.h include/nn/atk/atk_WaveArchiveFile.h include/nn/atk/atk_WaveArchiveFileReader.h include/nn/atk/atk_WaveFile.h + include/nn/atk/atk_WaveFileReader.h include/nn/atk/atk_WaveSound.h include/nn/atk/atk_WaveSoundFile.h include/nn/atk/atk_WaveSoundFileReader.h @@ -411,8 +413,6 @@ PUBLIC include/nn/atk/atk_WaveSoundLoader.h include/nn/atk/atk_WaveSoundPlayer.h include/nn/atk/atk_WaveSoundRuntime.h - include/nn/atk/atk_WavOutFileStream.h - include/nn/atk/detail/atk_AddonSoundArchiveContainer.h include/nn/atk/detail/atk_AdvancedWaveSound.h include/nn/atk/detail/atk_AdvancedWaveSoundFile.h @@ -420,13 +420,12 @@ PUBLIC include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h include/nn/atk/detail/atk_BinaryTypes.h - include/nn/atk/detail/atk_IntrusiveList.h include/nn/atk/detail/atk_IRegionInfoReadable.h include/nn/atk/detail/atk_IStreamDataDecoder.h - include/nn/atk/detail/atk_RegionManager.h + include/nn/atk/detail/atk_IntrusiveList.h include/nn/atk/detail/atk_MemoryFileStream.h + include/nn/atk/detail/atk_RegionManager.h include/nn/atk/detail/atk_SoundArchiveManager.h - include/nn/atk/fnd/basis/atkfnd_Config.h include/nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h include/nn/atk/fnd/basis/atkfnd_HeapBase.h @@ -447,18 +446,6 @@ PUBLIC include/nn/atk/fnd/string/atkfnd_String.h PRIVATE - src/NintendoWare/atk/fnd/basis/atkfnd_FrameHeapImpl.cpp - src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp - src/NintendoWare/atk/fnd/basis/atkfnd_Time.win32.cpp - src/NintendoWare/atk/fnd/basis/atkfnd_WorkBufferAllocator.cpp - src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp - src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp - src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp - src/NintendoWare/atk/fnd/io/atkfnd_StreamCache.cpp - src/NintendoWare/atk/fnd/os/atkfnd_Thread.cpp - src/NintendoWare/atk/fnd/os/atkfnd_Thread.win32.cpp - - src/NintendoWare/atk/atk_SoundArchive.cpp src/NintendoWare/atk/atk_FsSoundArchive.cpp src/NintendoWare/atk/atk_SequenceSoundHandle.cpp src/NintendoWare/atk/atk_SoundArchive.cpp @@ -553,6 +540,16 @@ PRIVATE src/NintendoWare/atk/detail/wsd/atk_WaveSoundRuntime.cpp src/NintendoWare/atk/effect/atk_EffectAux.cpp src/NintendoWare/atk/effect/atk_EffectBase.cpp + src/NintendoWare/atk/fnd/basis/atkfnd_FrameHeapImpl.cpp + src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp + src/NintendoWare/atk/fnd/basis/atkfnd_Time.win32.cpp + src/NintendoWare/atk/fnd/basis/atkfnd_WorkBufferAllocator.cpp + src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp + src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp + src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp + src/NintendoWare/atk/fnd/io/atkfnd_StreamCache.cpp + src/NintendoWare/atk/fnd/os/atkfnd_Thread.cpp + src/NintendoWare/atk/fnd/os/atkfnd_Thread.win32.cpp src/NintendoWare/atk/submix/atk_ChannelMixVolume.cpp src/NintendoWare/atk/submix/atk_FinalMix.cpp src/NintendoWare/atk/submix/atk_OutputMixer.cpp diff --git a/include/nn/atk/atk_WaveSoundFile.h b/include/nn/atk/atk_WaveSoundFile.h index 9c1b3cc5..518c0827 100644 --- a/include/nn/atk/atk_WaveSoundFile.h +++ b/include/nn/atk/atk_WaveSoundFile.h @@ -6,21 +6,30 @@ namespace nn::atk::detail { struct WaveSoundFile { struct InfoBlock; struct FileHeader : Util::SoundFileHeader { - - InfoBlock* GetInfoBlock() const; - + const InfoBlock* GetInfoBlock() const; }; struct WaveSoundData; struct InfoBlockBody { + Util::Reference toWaveIdTable; + Util::Reference toWaveSoundDataReferenceTable; - WaveSoundData* GetWaveSoundData(u32 index) const; - Util::ReferenceTable* GetWaveSoundDataReferenceTable() const; + const Util::WaveIdTable& GetWaveIdTable() const; + const Util::ReferenceTable& GetWaveSoundDataReferenceTable() const; + + u32 GetWaveIdCount() const { + return GetWaveIdTable().GetCount(); + } - Util::WaveIdTable* GetWaveIdTable() const; + u32 GetWaveSoundCount() const { + return GetWaveSoundDataReferenceTable().count; + } - Util::Reference toWaveIdTable; - Util::Reference toWaveSoundDataReferenceTable; + const Util::WaveId* GetWaveId(u32 index) const { + return GetWaveIdTable().GetWaveId(index); + } + + const WaveSoundData& GetWaveSoundData(u32 index) const; }; static_assert(sizeof(InfoBlockBody) == 0x10); @@ -34,58 +43,72 @@ struct WaveSoundFile { struct TrackInfo; struct NoteInfo; struct WaveSoundData { - - WaveSoundInfo* GetWaveSoundInfo() const; - - Util::ReferenceTable* GetTrackInfoReferenceTable() const; - Util::ReferenceTable* GetNoteInfoReferenceTable() const; - - TrackInfo* GetTrackInfo(u32 index) const; - NoteInfo* GetNoteInfo(u32 index) const; - Util::Reference toWaveSoundInfo; Util::Reference toTrackInfoReferenceTable; Util::Reference toNoteInfoReferenceTable; + + const WaveSoundInfo& GetWaveSoundInfo() const; + + const Util::ReferenceTable& GetTrackInfoReferenceTable() const; + const Util::ReferenceTable& GetNoteInfoReferenceTable() const; + + u32 GetTrackCount() const { + return GetTrackInfoReferenceTable().count; + } + + u32 GetNoteCount() const { + return GetNoteInfoReferenceTable().count; + } + + const TrackInfo& GetTrackInfo(u32 index) const; + const NoteInfo& GetNoteInfo(u32 index) const; }; static_assert(sizeof(WaveSoundData) == 0x18); struct WaveSoundInfo { + Util::BitFlag optionParameter; u8 GetPan() const; s8 GetSurroundPan() const; - f32 GetPitch() const; + float GetPitch() const; void GetSendValue(u8* mainSend, u8* fxSend, u8 fxSendCount) const; - AdshrCurve* GetAdshrCurve() const; + const AdshrCurve& GetAdshrCurve() const; u8 GetLpfFreq() const; u8 GetBiquadType() const; u8 GetBiquadValue() const; - - Util::BitFlag optionParameter; }; static_assert(sizeof(WaveSoundInfo) == 0x4); struct NoteEvent; struct TrackInfo { + Util::Reference toNoteEventReferenceTable; - Util::ReferenceTable* GetNoteEventReferenceTable() const; - NoteEvent* GetNoteEvent(u32 index) const; + const Util::ReferenceTable& GetNoteEventReferenceTable() const; - Util::Reference toNoteEventReferenceTable; + u32 GetNoteEventCount() const { + return GetNoteEventReferenceTable().count; + } + + const NoteEvent& GetNoteEvent(u32 index) const; }; static_assert(sizeof(TrackInfo) == 0x8); + struct NoteEvent { + u8 _0[8]; + }; + static_assert(sizeof(NoteEvent) == 0x8); + struct NoteInfo { - + u32 waveIdTableIndex; + Util::BitFlag optionParameter; + u8 GetOriginalKey() const; u8 GetVolume() const; u8 GetPan() const; u8 GetSurroundPan() const; - f32 GetPitch() const; - f32 GetSendValue(u8*, u8**, u8) const; - AdshrCurve* GetAdshrCurve() const; - - u32 waveIdTableIndex; - Util::BitFlag optionParameter; + float GetPitch() const; + void GetSendValue(u8* mainSend, u8** fxSend, u8 fxSendCount) const; + const AdshrCurve& GetAdshrCurve() const; }; static_assert(sizeof(NoteInfo) == 0x8); }; diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index e69de29b..cecb01bf 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -0,0 +1,10 @@ +#include + +#include + +namespace nn::atk::detail { +const WaveSoundFile::InfoBlock* WaveSoundFile::FileHeader::GetInfoBlock() const { + return util::ConstBytePtr(GetBlock(ElementType_WaveSoundFile_InfoBlock)) + .Get(); +} +} // namespace nn::atk::detail \ No newline at end of file From 0b0b3e0b4c3aad7aaa4835955c202ae8e3994618 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 12:54:56 -0400 Subject: [PATCH 323/785] atk: Match `WaveSoundFile::InfoBlockBody::GetWaveIdTable` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index cecb01bf..81f049fc 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -1,10 +1,15 @@ #include #include +#include "nn/util/util_BytePtr.h" namespace nn::atk::detail { const WaveSoundFile::InfoBlock* WaveSoundFile::FileHeader::GetInfoBlock() const { return util::ConstBytePtr(GetBlock(ElementType_WaveSoundFile_InfoBlock)) .Get(); } + +const Util::WaveIdTable& WaveSoundFile::InfoBlockBody::GetWaveIdTable() const { + return *util::ConstBytePtr(this, toWaveIdTable.offset).Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 188e84e1e4d01e5200375f1cb701d5950f10f6bd Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 13:02:55 -0400 Subject: [PATCH 324/785] atk: Match `WaveSoundFile::InfoBlockBody::GetWaveSoundDataReferenceTable` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index 81f049fc..c7c3524d 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -9,6 +9,11 @@ const WaveSoundFile::InfoBlock* WaveSoundFile::FileHeader::GetInfoBlock() const .Get(); } +const Util::ReferenceTable& WaveSoundFile::InfoBlockBody::GetWaveSoundDataReferenceTable() const { + return *util::ConstBytePtr(this, toWaveSoundDataReferenceTable.offset) + .Get(); +} + const Util::WaveIdTable& WaveSoundFile::InfoBlockBody::GetWaveIdTable() const { return *util::ConstBytePtr(this, toWaveIdTable.offset).Get(); } From 78bf21544e60074b4ff911120f0f00b0120284d9 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 13:22:07 -0400 Subject: [PATCH 325/785] atk: Match `WaveSoundFile::InfoBlockBody::GetWaveSoundData` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index c7c3524d..ccf04212 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -9,6 +9,13 @@ const WaveSoundFile::InfoBlock* WaveSoundFile::FileHeader::GetInfoBlock() const .Get(); } +const WaveSoundFile::WaveSoundData& WaveSoundFile::InfoBlockBody::GetWaveSoundData(u32 index) const { + return *util::ConstBytePtr( + GetWaveSoundDataReferenceTable() + .GetReferedItem(index, ElementType_WaveSoundFile_WaveSoundMetaData) + ).Get(); +} + const Util::ReferenceTable& WaveSoundFile::InfoBlockBody::GetWaveSoundDataReferenceTable() const { return *util::ConstBytePtr(this, toWaveSoundDataReferenceTable.offset) .Get(); From ba5396479eea363dbb5999f246fadb4319c4bda5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 13:24:31 -0400 Subject: [PATCH 326/785] atk: Match `WaveSoundFile::WaveSoundData::GetWaveSoundInfo` --- include/nn/atk/atk_WaveSoundFile.h | 1 - src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_WaveSoundFile.h b/include/nn/atk/atk_WaveSoundFile.h index 518c0827..6a1a75a1 100644 --- a/include/nn/atk/atk_WaveSoundFile.h +++ b/include/nn/atk/atk_WaveSoundFile.h @@ -48,7 +48,6 @@ struct WaveSoundFile { Util::Reference toNoteInfoReferenceTable; const WaveSoundInfo& GetWaveSoundInfo() const; - const Util::ReferenceTable& GetTrackInfoReferenceTable() const; const Util::ReferenceTable& GetNoteInfoReferenceTable() const; diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index ccf04212..34c673d5 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -24,4 +24,8 @@ const Util::ReferenceTable& WaveSoundFile::InfoBlockBody::GetWaveSoundDataRefere const Util::WaveIdTable& WaveSoundFile::InfoBlockBody::GetWaveIdTable() const { return *util::ConstBytePtr(this, toWaveIdTable.offset).Get(); } + +const WaveSoundFile::WaveSoundInfo& WaveSoundFile::WaveSoundData::GetWaveSoundInfo() const { + return *util::ConstBytePtr(this, toWaveSoundInfo.offset).Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 6d2b66bfb569be96718ee50de12ce1f4647e2006 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 13:27:01 -0400 Subject: [PATCH 327/785] atk: Match `WaveSoundFile::WaveSoundData::GetTrackInfoReferenceTable` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index 34c673d5..bfec9a78 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -28,4 +28,9 @@ const Util::WaveIdTable& WaveSoundFile::InfoBlockBody::GetWaveIdTable() const { const WaveSoundFile::WaveSoundInfo& WaveSoundFile::WaveSoundData::GetWaveSoundInfo() const { return *util::ConstBytePtr(this, toWaveSoundInfo.offset).Get(); } + +const Util::ReferenceTable& WaveSoundFile::WaveSoundData::GetTrackInfoReferenceTable() const { + return *util::ConstBytePtr(this, toTrackInfoReferenceTable.offset) + .Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 7f15bf37cb8c33480a8a5569b49d7911ec76032c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 13:28:08 -0400 Subject: [PATCH 328/785] atk: Match `WaveSoundFile::WaveSoundData::GetNoteInfoReferenceTable` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index bfec9a78..58981d72 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -33,4 +33,9 @@ const Util::ReferenceTable& WaveSoundFile::WaveSoundData::GetTrackInfoReferenceT return *util::ConstBytePtr(this, toTrackInfoReferenceTable.offset) .Get(); } + +const Util::ReferenceTable& WaveSoundFile::WaveSoundData::GetNoteInfoReferenceTable() const { + return *util::ConstBytePtr(this, toNoteInfoReferenceTable.offset) + .Get(); +} } // namespace nn::atk::detail \ No newline at end of file From c5383f744a581cbc8215fb653c0a12747d0bb83c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 13:33:07 -0400 Subject: [PATCH 329/785] atk: Match `WaveSoundFile::WaveSoundData::GetTrackInfo` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index 58981d72..6b4c5ffa 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -38,4 +38,11 @@ const Util::ReferenceTable& WaveSoundFile::WaveSoundData::GetNoteInfoReferenceTa return *util::ConstBytePtr(this, toNoteInfoReferenceTable.offset) .Get(); } + +const WaveSoundFile::TrackInfo& WaveSoundFile::WaveSoundData::GetTrackInfo(u32 index) const { + const void* pTrackInfo; + pTrackInfo = GetTrackInfoReferenceTable().GetReferedItem(index, ElementType_WaveSoundFile_TrackInfo); + + return *util::ConstBytePtr(pTrackInfo).Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 3928f7a3fb77d9399ea8d18c987b338d533a4751 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 13:34:16 -0400 Subject: [PATCH 330/785] atk: Match `WaveSoundFile::WaveSoundData::GetNoteInfo` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index 6b4c5ffa..dddb7478 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -45,4 +45,11 @@ const WaveSoundFile::TrackInfo& WaveSoundFile::WaveSoundData::GetTrackInfo(u32 i return *util::ConstBytePtr(pTrackInfo).Get(); } + +const WaveSoundFile::NoteInfo& WaveSoundFile::WaveSoundData::GetNoteInfo(u32 index) const { + const void* pNoteInfo; + pNoteInfo = GetNoteInfoReferenceTable().GetReferedItem(index, ElementType_WaveSoundFile_NoteInfo); + + return *util::ConstBytePtr(pNoteInfo).Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 1b74cf8ced22bf95dba7de4c49dead58263944d6 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 13:50:17 -0400 Subject: [PATCH 331/785] atk: Match `WaveSoundFile::WaveSoundInfo::GetPan` --- include/nn/atk/atk_Global.h | 2 - .../atk/detail/wsd/atk_WaveSoundFile.cpp | 55 ++++++++++++++++++- .../atk/fnd/basis/atkfnd_HeapBase.cpp | 4 +- 3 files changed, 56 insertions(+), 5 deletions(-) diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h index 9ce136a8..a03406a2 100644 --- a/include/nn/atk/atk_Global.h +++ b/include/nn/atk/atk_Global.h @@ -156,8 +156,6 @@ struct AdshrCurve { }; static_assert(sizeof(AdshrCurve) == 0x5); -static const AdshrCurve WsdDefaultAdshrCurve = {127, 127, 127, 127, 127}; - struct BiquadFilterCoefficients { s16 b0; s16 b1; diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index dddb7478..8911c45f 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -1,9 +1,53 @@ #include #include -#include "nn/util/util_BytePtr.h" namespace nn::atk::detail { +namespace { +const u8 WsdDefaultPan {64}; +const s8 WsdDefaultSurroundPan {0}; +const float WsdDefaultPitch {1.0}; +const u8 WsdDefaultMainSend {127}; +const u8 WsdDefaultFxSend {0}; +const AdshrCurve WsdDefaultAdshrCurve { + 127, + 127, + 127, + 127, + 127 +}; +const u8 WsdDefaultLpfFreq {64}; +const u8 WsdDefaultBiquadType {0}; +const u8 WsdDefaultBiquadValue {0}; +const u8 WsdDefaultKey {64}; +const u8 WsdDefaultVolume {96}; + +enum WaveSoundInfoBitFlagWsd { + WaveSoundInfoBitFlagWsd_Pan = 0, + WaveSoundInfoBitFlagWsd_Pitch = 1, + WaveSoundInfoBitFlagWsd_Filter = 2, + WaveSoundInfoBitFlagWsd_Send = 8, + WaveSoundInfoBitFlagWsd_Envelope = 9, + WaveSoundInfoBitFlagWsd_Randomizer = 10, +}; + +enum NoteInfoBitFlag { + NoteInfoBitFlag_Key = 0, + NoteInfoBitFlag_Volume = 1, + NoteInfoBitFlag_Pan = 2, + NoteInfoBitFlag_Pitch = 3, + NoteInfoBitFlag_Send = 8, + NoteInfoBitFlag_Envelope = 9, + NoteInfoBitFlag_Randomizer = 10, + NoteInfoBitFlag_Lfo = 11, +}; + +struct SendValueWsd { + u8 mainSend; + Util::Table fxSend; +}; +} // anonymous namespace + const WaveSoundFile::InfoBlock* WaveSoundFile::FileHeader::GetInfoBlock() const { return util::ConstBytePtr(GetBlock(ElementType_WaveSoundFile_InfoBlock)) .Get(); @@ -52,4 +96,13 @@ const WaveSoundFile::NoteInfo& WaveSoundFile::WaveSoundData::GetNoteInfo(u32 ind return *util::ConstBytePtr(pNoteInfo).Get(); } + +u8 WaveSoundFile::WaveSoundInfo::GetPan() const { + u32 value; + bool result {optionParameter.GetValue(&value, WaveSoundInfoBitFlagWsd_Pan)}; + if (result) + return Util::DivideBy8bit(value, 0); + + return WsdDefaultPan; +} } // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp b/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp index 3833ec59..5b23f8c0 100644 --- a/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp +++ b/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp @@ -5,8 +5,8 @@ namespace nn::atk::detail::fnd { namespace { - HeapBase::HeapList sRootList; - u32 sFillVals[HeapBase::FillType_Max] { 0xC3C3C3C3, 0xF3F3F3F3, 0xD3D3D3D3 }; +HeapBase::HeapList sRootList; +u32 sFillVals[HeapBase::FillType_Max] = { 0xC3C3C3C3, 0xF3F3F3F3, 0xD3D3D3D3 }; } // anonymous namespace HeapBase::HeapList* HeapBase::FindListContainHeap(HeapBase* pHeapBase) { From dd205a4267c1f1f3a451c8b4e0a2680338d6082c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 13:53:13 -0400 Subject: [PATCH 332/785] atk: Match `WaveSoundFile::WaveSoundInfo::GetSurroundPan` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index 8911c45f..2a9a7e2f 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -105,4 +105,13 @@ u8 WaveSoundFile::WaveSoundInfo::GetPan() const { return WsdDefaultPan; } + +s8 WaveSoundFile::WaveSoundInfo::GetSurroundPan() const { + u32 value; + bool result {optionParameter.GetValue(&value, WaveSoundInfoBitFlagWsd_Pan)}; + if (result) + return static_cast(Util::DivideBy8bit(value, 1)); + + return WsdDefaultSurroundPan; +} } // namespace nn::atk::detail \ No newline at end of file From cc9a8aa8757e212a00087f75003a7ffc169a0158 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 13:55:21 -0400 Subject: [PATCH 333/785] atk: Match `WaveSoundFile::WaveSoundInfo::GetPitch` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index 2a9a7e2f..ced7ed3b 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -114,4 +114,13 @@ s8 WaveSoundFile::WaveSoundInfo::GetSurroundPan() const { return WsdDefaultSurroundPan; } + +float WaveSoundFile::WaveSoundInfo::GetPitch() const { + float value; + bool result {optionParameter.GetValueF32(&value, WaveSoundInfoBitFlagWsd_Pitch)}; + if (result) + return value; + + return WsdDefaultPitch; +} } // namespace nn::atk::detail \ No newline at end of file From 0b3ca6a5dd3d68bfb9bb3c2e18c37d4f5d91557f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 14:04:57 -0400 Subject: [PATCH 334/785] atk: Match `WaveSoundFile::WaveSoundInfo::GetSendValue` Based on the implementation from [TuneBloom](https://github.com/stupidestmodder/TuneBloom/blob/master/TuneBloom/include/snd/snd_WaveSoundFile.h#L201) --- .../atk/detail/wsd/atk_WaveSoundFile.cpp | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index ced7ed3b..e4a1f58e 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -1,6 +1,8 @@ #include #include +#include "nn/atk/atk_Global.h" +#include "nn/util/util_BytePtr.h" namespace nn::atk::detail { namespace { @@ -123,4 +125,24 @@ float WaveSoundFile::WaveSoundInfo::GetPitch() const { return WsdDefaultPitch; } + +void WaveSoundFile::WaveSoundInfo::GetSendValue(u8* mainSend, u8* fxSend, u8 fxSendCount) const { + u32 value; + bool result {optionParameter.GetValue(&value, WaveSoundInfoBitFlagWsd_Send)}; + + if (result) { + const SendValueWsd& sendValue = *util::ConstBytePtr(this, value).Get(); + + *mainSend = sendValue.mainSend; + int countSize {sendValue.fxSend.count > AuxBus_Count ? AuxBus_Count : sendValue.fxSend.count}; + + for (int i {0}; i < countSize; ++i) + fxSend[i] = sendValue.fxSend.item[i]; + } + else { + *mainSend = WsdDefaultMainSend; + for (int i {0}; i < fxSendCount; ++i) + fxSend[i] = WsdDefaultFxSend; + } +} } // namespace nn::atk::detail \ No newline at end of file From 485380fc0f8783423fdafd5fe11b81a06e74c294 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 14:07:43 -0400 Subject: [PATCH 335/785] atk: Match `WaveSoundFile::WaveSoundInfo::GetAdshrCurve` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index e4a1f58e..86f4328a 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -145,4 +145,15 @@ void WaveSoundFile::WaveSoundInfo::GetSendValue(u8* mainSend, u8* fxSend, u8 fxS fxSend[i] = WsdDefaultFxSend; } } + +const AdshrCurve& WaveSoundFile::WaveSoundInfo::GetAdshrCurve() const { + u32 offsetToReference; + bool result {optionParameter.GetValue(&offsetToReference, WaveSoundInfoBitFlagWsd_Envelope)}; + if (result) { + const auto& ref {*util::ConstBytePtr(this, offsetToReference).Get()}; + return *util::ConstBytePtr(&ref, ref.offset).Get(); + } + + return WsdDefaultAdshrCurve; +} } // namespace nn::atk::detail \ No newline at end of file From f350a88fe913f31355f88f8934cc9d18ebe80772 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 14:10:09 -0400 Subject: [PATCH 336/785] atk: Match `WaveSoundFile::WaveSoundInfo::GetLpfFreq` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index 86f4328a..04c8647e 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -156,4 +156,13 @@ const AdshrCurve& WaveSoundFile::WaveSoundInfo::GetAdshrCurve() const { return WsdDefaultAdshrCurve; } + +u8 WaveSoundFile::WaveSoundInfo::GetLpfFreq() const { + u32 value; + bool result {optionParameter.GetValue(&value, WaveSoundInfoBitFlagWsd_Filter)}; + if (result) + return Util::DivideBy8bit(value, 0); + + return WsdDefaultLpfFreq; +} } // namespace nn::atk::detail \ No newline at end of file From 121e07ec24772c35db8de1a734a949ebf7bd0c76 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 14:10:54 -0400 Subject: [PATCH 337/785] atk: Match `WaveSoundFile::WaveSoundInfo::GetBiquadType` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index 04c8647e..7b5ab4c4 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -165,4 +165,13 @@ u8 WaveSoundFile::WaveSoundInfo::GetLpfFreq() const { return WsdDefaultLpfFreq; } + +u8 WaveSoundFile::WaveSoundInfo::GetBiquadType() const { + u32 value; + bool result {optionParameter.GetValue(&value, WaveSoundInfoBitFlagWsd_Filter)}; + if (result) + return Util::DivideBy8bit(value, 1); + + return WsdDefaultBiquadType; +} } // namespace nn::atk::detail \ No newline at end of file From 3f38f46e8b22b2401376516dd524d99d46ea7f1f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 14:11:26 -0400 Subject: [PATCH 338/785] atk: Match `WaveSoundFile::WaveSoundInfo::GetBiquadValue` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index 7b5ab4c4..e7ace39b 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -174,4 +174,13 @@ u8 WaveSoundFile::WaveSoundInfo::GetBiquadType() const { return WsdDefaultBiquadType; } + +u8 WaveSoundFile::WaveSoundInfo::GetBiquadValue() const { + u32 value; + bool result {optionParameter.GetValue(&value, WaveSoundInfoBitFlagWsd_Filter)}; + if (result) + return Util::DivideBy8bit(value, 2); + + return WsdDefaultBiquadValue; +} } // namespace nn::atk::detail \ No newline at end of file From 68f6c553fc8b6d56283af72ced1a7104af74a562 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 14:16:20 -0400 Subject: [PATCH 339/785] atk: Match `WaveSoundFile::TrackInfo::GetNoteEventReferenceTable` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index e7ace39b..9aecad29 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -1,8 +1,6 @@ #include #include -#include "nn/atk/atk_Global.h" -#include "nn/util/util_BytePtr.h" namespace nn::atk::detail { namespace { @@ -183,4 +181,9 @@ u8 WaveSoundFile::WaveSoundInfo::GetBiquadValue() const { return WsdDefaultBiquadValue; } + +const Util::ReferenceTable& WaveSoundFile::TrackInfo::GetNoteEventReferenceTable() const { + return *util::ConstBytePtr(this, toNoteEventReferenceTable.offset) + .Get(); +} } // namespace nn::atk::detail \ No newline at end of file From a1452171a7cd0cc0db1d4171d7137b835078feb2 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 14:20:12 -0400 Subject: [PATCH 340/785] atk: Match `WaveSoundFile::TrackInfo::GetNoteEvent` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index 9aecad29..48f1b9e6 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -186,4 +186,11 @@ const Util::ReferenceTable& WaveSoundFile::TrackInfo::GetNoteEventReferenceTable return *util::ConstBytePtr(this, toNoteEventReferenceTable.offset) .Get(); } + +const WaveSoundFile::NoteEvent& WaveSoundFile::TrackInfo::GetNoteEvent(u32 index) const { + const void* pNoteEvent; + pNoteEvent = GetNoteEventReferenceTable().GetReferedItem(index, ElementType_WaveSoundFile_NoteEvent); + + return *util::ConstBytePtr(pNoteEvent).Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 746aeb169044b8e546b510c871aa86d972d99e07 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 14:23:04 -0400 Subject: [PATCH 341/785] atk: Match `WaveSoundFile::NoteInfo::GetOriginalKey` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index 48f1b9e6..b4c87c64 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -193,4 +193,13 @@ const WaveSoundFile::NoteEvent& WaveSoundFile::TrackInfo::GetNoteEvent(u32 index return *util::ConstBytePtr(pNoteEvent).Get(); } + +u8 WaveSoundFile::NoteInfo::GetOriginalKey() const { + u32 value; + bool result {optionParameter.GetValue(&value, NoteInfoBitFlag_Key)}; + if (result) + return Util::DivideBy8bit(value, 0); + + return WsdDefaultKey; +} } // namespace nn::atk::detail \ No newline at end of file From 2ce92bd7039f33a996f3461f60847d2983f740fb Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 14:24:20 -0400 Subject: [PATCH 342/785] atk: Match `WaveSoundFile::NoteInfo::GetVolume` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index b4c87c64..737f2a29 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -202,4 +202,13 @@ u8 WaveSoundFile::NoteInfo::GetOriginalKey() const { return WsdDefaultKey; } + +u8 WaveSoundFile::NoteInfo::GetVolume() const { + u32 value; + bool result {optionParameter.GetValue(&value, NoteInfoBitFlag_Volume)}; + if (result) + return Util::DivideBy8bit(value, 0); + + return WsdDefaultVolume; +} } // namespace nn::atk::detail \ No newline at end of file From 4186b1629c9dcea36ee7eb0b3d10690f624273d2 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 14:25:41 -0400 Subject: [PATCH 343/785] atk: Match `WaveSoundFile::NoteInfo::GetPan` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index 737f2a29..f1210733 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -211,4 +211,13 @@ u8 WaveSoundFile::NoteInfo::GetVolume() const { return WsdDefaultVolume; } + +u8 WaveSoundFile::NoteInfo::GetPan() const { + u32 value; + bool result {optionParameter.GetValue(&value, NoteInfoBitFlag_Pan)}; + if (result) + return Util::DivideBy8bit(value, 0); + + return WsdDefaultPan; +} } // namespace nn::atk::detail \ No newline at end of file From ada103a714fe2006cb7456937c14fd9604978345 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 14:33:27 -0400 Subject: [PATCH 344/785] atk: Match `WaveSoundFile::NoteInfo::GetSurroundPan` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index f1210733..9251dd94 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -220,4 +220,13 @@ u8 WaveSoundFile::NoteInfo::GetPan() const { return WsdDefaultPan; } + +u8 WaveSoundFile::NoteInfo::GetSurroundPan() const { + u32 value; + bool result {optionParameter.GetValue(&value, NoteInfoBitFlag_Pan)}; + if (result) + return Util::DivideBy8bit(value, 1); + + return WsdDefaultSurroundPan; +} } // namespace nn::atk::detail \ No newline at end of file From 1cfb2b5728a09258c3e85722259f7af268897faf Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 14:34:14 -0400 Subject: [PATCH 345/785] atk: Match `WaveSoundFile::NoteInfo::GetPitch` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index 9251dd94..4a87e689 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -229,4 +229,13 @@ u8 WaveSoundFile::NoteInfo::GetSurroundPan() const { return WsdDefaultSurroundPan; } + +float WaveSoundFile::NoteInfo::GetPitch() const { + float value; + bool result {optionParameter.GetValueF32(&value, NoteInfoBitFlag_Pitch)}; + if (result) + return value; + + return WsdDefaultPitch; +} } // namespace nn::atk::detail \ No newline at end of file From 60742124e23efad8c8a3f29362592de34fdc25e8 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 15:09:29 -0400 Subject: [PATCH 346/785] atk: Match `WaveSoundFile::NoteInfo::GetAdshrCurve` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index 4a87e689..1d2520b2 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -238,4 +238,15 @@ float WaveSoundFile::NoteInfo::GetPitch() const { return WsdDefaultPitch; } + +const AdshrCurve& WaveSoundFile::NoteInfo::GetAdshrCurve() const { + u32 offsetToReference; + bool result {optionParameter.GetValue(&offsetToReference, NoteInfoBitFlag_Envelope)}; + if (result) { + const auto& ref {*util::ConstBytePtr(this, offsetToReference).Get()}; + return *util::ConstBytePtr(&ref, ref.offset).Get(); + } + + return WsdDefaultAdshrCurve; +} } // namespace nn::atk::detail \ No newline at end of file From d5b7bb81664d7e455f177ae093687afd2def949e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 25 Aug 2026 19:07:24 -0400 Subject: [PATCH 347/785] atk: Add implementation for `WaveSoundFile::NoteInfo::GetSendValue` Implementation does not match. Based on the one from [TuneBloom](https://github.com/stupidestmodder/TuneBloom/blob/master/TuneBloom/include/snd/snd_WaveSoundFile.h#L201) --- include/nn/atk/atk_WaveSoundFile.h | 7 +++++-- .../atk/detail/wsd/atk_WaveSoundFile.cpp | 21 +++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_WaveSoundFile.h b/include/nn/atk/atk_WaveSoundFile.h index 6a1a75a1..f7c9ccef 100644 --- a/include/nn/atk/atk_WaveSoundFile.h +++ b/include/nn/atk/atk_WaveSoundFile.h @@ -93,9 +93,12 @@ struct WaveSoundFile { static_assert(sizeof(TrackInfo) == 0x8); struct NoteEvent { - u8 _0[8]; + float position; + float length; + u32 noteIndex; + u32 reserved; }; - static_assert(sizeof(NoteEvent) == 0x8); + static_assert(sizeof(NoteEvent) == 0x10); struct NoteInfo { u32 waveIdTableIndex; diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index 1d2520b2..90ad80f2 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -239,6 +239,27 @@ float WaveSoundFile::NoteInfo::GetPitch() const { return WsdDefaultPitch; } +// NON_MATCHING +void WaveSoundFile::NoteInfo::GetSendValue(u8* mainSend, u8** fxSend, u8 fxSendCount) const { + u32 value; + bool result {optionParameter.GetValue(&value, NoteInfoBitFlag_Send)}; + + if (!result) { + *mainSend = WsdDefaultMainSend; + for (int i {0}; i < fxSendCount; ++i) + fxSend[i][0] = WsdDefaultFxSend; + } + else { + const SendValueWsd& sendValue = *util::ConstBytePtr(this, value).Get(); + + *mainSend = sendValue.mainSend; + int countSize {sendValue.fxSend.count > AuxBus_Count ? AuxBus_Count : sendValue.fxSend.count}; + + for (int i {0}; i < countSize; ++i) + fxSend[i][0] = sendValue.fxSend.item[i]; + } +} + const AdshrCurve& WaveSoundFile::NoteInfo::GetAdshrCurve() const { u32 offsetToReference; bool result {optionParameter.GetValue(&offsetToReference, NoteInfoBitFlag_Envelope)}; From 0b26968f6da444c0fd1eaf4b994f00f7d0bdbc57 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 27 Aug 2026 14:19:33 -0400 Subject: [PATCH 348/785] atk: Match `FileStreamImpl::Read` Also reorganized class to better match DWARF --- .../nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h | 42 ++++---- include/nn/atk/fnd/io/atkfnd_FileStream.h | 49 ++++++---- include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h | 98 ++++++++++++------- include/nn/atk/fnd/io/atkfnd_Stream.h | 27 +++-- .../atk/fnd/basis/atkfnd_FrameHeapImpl.cpp | 5 + .../atk/fnd/io/atkfnd_FileStreamImpl.cpp | 10 ++ 6 files changed, 153 insertions(+), 78 deletions(-) diff --git a/include/nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h b/include/nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h index a884dd4d..a621df9d 100644 --- a/include/nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h +++ b/include/nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h @@ -3,43 +3,47 @@ #include namespace nn::atk::detail::fnd { -class FrameHeapImpl : HeapBase { +class FrameHeapImpl : public HeapBase { public: - constexpr static s32 FreeHeadMode = 1; - constexpr static s32 FreeTailMode = 2; - constexpr static s32 FreeAllMode = 3; + static const int FreeHeadMode = 1; + static const int FreeTailMode = 2; + static const int FreeAllMode = 3; struct HeapState { u32 tagName; void* headAllocator; void* tailAllocator; - HeapState* pPrevState; + HeapState* pPrevState; + + HeapState(); }; static_assert(sizeof(HeapState) == 0x20); + FrameHeapImpl(); + static FrameHeapImpl* Create(void* startAddress, size_t size, u16 optFlag); - - void* Destroy(); - void* Alloc(size_t size, s32 alignment); - void* AllocFromHead(size_t size, s32 alignment); - void* AllocFromTail(size_t size, s32 alignment); + void* Destroy(); + void* Alloc(size_t size, int alignment); + size_t ResizeForMBlock(void* memBlock, size_t newSize); + size_t GetAllocatableSize(int alignment); - u64 ResizeForMBlock(void* memBlock, size_t size); + void Free(int mode); - size_t GetAllocatableSize(s32); + bool RecordState(u32 tagName); + bool FreeByState(u32 tagName); - void Free(s32 mode); - void FreeHead(); - void FreeTail(); + u32 Adjust(); - bool RecordState(u32); +private: + bool IsValid(); - bool FreeByState(u32); + void* AllocFromHead(size_t size, int alignment); + void* AllocFromTail(size_t size, int alignment); - s32 Adjust(); + void FreeHead(); + void FreeTail(); -private: void* m_pHeadAllocator; void* m_pTailAllocator; HeapState* m_pState; diff --git a/include/nn/atk/fnd/io/atkfnd_FileStream.h b/include/nn/atk/fnd/io/atkfnd_FileStream.h index 3dd14052..30ee5685 100644 --- a/include/nn/atk/fnd/io/atkfnd_FileStream.h +++ b/include/nn/atk/fnd/io/atkfnd_FileStream.h @@ -7,30 +7,45 @@ namespace nn::atk::detail::fnd { class FileStream : public Stream { public: enum AccessMode { - AccessMode_None, - AccessMode_Read, - AccessMode_Write, - AccessMode_ReadAndWrite, - AccessMode_AllowAppend, - AccessMode_AllowAppendAndWrite = 6, + AccessMode_None = 0, + AccessMode_Read = 1, + AccessMode_Write = 2, + AccessMode_AllowAppend = 4, + AccessMode_ReadAndWrite = AccessMode_Read | AccessMode_Write, + AccessMode_AllowAppendAndWrite = AccessMode_AllowAppend | AccessMode_Write, }; - virtual FndResult Open(const char* filePath, AccessMode openMode); - virtual void Flush(); + ~FileStream() override = default; + + virtual FndResult Open(const char* filePath, AccessMode openMode) = 0; + void Close() override = 0; + virtual void Flush() = 0; - virtual void EnableCache(void* buffer, size_t length); - virtual void DisableCache(); - virtual bool IsCacheEnabled() const; + bool IsOpened() const override = 0; + + bool CanRead() const override = 0; + bool CanWrite() const override = 0; + bool CanSeek() const override = 0; + + size_t GetSize() const override = 0; + + size_t Read(void* buf, size_t length, FndResult* result) override = 0; + size_t Write(const void* buf, size_t length, FndResult* result) override = 0; + FndResult Seek(position_t offset, SeekOrigin origin) override = 0; + + position_t GetCurrentPosition() const override = 0; - virtual s32 GetIoBufferAlignment() const; + virtual void EnableCache(void* buffer, size_t length) = 0; + virtual void DisableCache() = 0; + virtual bool IsCacheEnabled() const = 0; - virtual bool CanSetFsAccessLog() const; - virtual void* SetFsAccessLog(FsAccessLog* pFsAccessLog); + virtual int GetIoBufferAlignment() const = 0; - virtual position_t GetCachePosition(); - virtual size_t GetCachedLength(); + virtual bool CanSetFsAccessLog() const = 0; + virtual void* SetFsAccessLog(FsAccessLog* pFsAccessLog) = 0; - ~FileStream() override; + virtual position_t GetCachePosition() = 0; + virtual size_t GetCachedLength() = 0; }; static_assert(sizeof(FileStream) == 0x8); } // namespace nn::atk::detail::fnd \ No newline at end of file diff --git a/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h b/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h index a243f79c..4e983127 100644 --- a/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h +++ b/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h @@ -5,64 +5,90 @@ #include namespace nn::atk::detail::fnd { -class FileStreamImpl : FileStream { +class FileStreamImpl : public FileStream { + NN_NO_COPY(FileStreamImpl); public: - class DirectStream : fnd::Stream { + class DirectStream : public Stream { public: - ~DirectStream() override; + DirectStream() = default; - void Close() override; - bool IsOpened() const override; + void Initialize(FileStreamImpl& fileStream); - size_t Read(void* buf, size_t length, FndResult* result) override; - size_t Write(const void* buf, size_t length, FndResult* result) override; - FndResult Seek(position_t offset, SeekOrigin origin) override; + void Close() override {} + + bool IsOpened() const override { + return m_Owner->IsOpened(); + } - position_t GetCurrentPosition() const override; - size_t GetSize() const override; + bool CanRead() const override { + return m_Owner->CanRead(); + } + + bool CanWrite() const override { + return m_Owner->CanWrite(); + } + + bool CanSeek() const override { + return m_Owner->CanSeek(); + } + + size_t GetSize() const override { + return m_Owner->GetSize(); + } + + size_t Read(void* buf, size_t length, FndResult* result) override { + return m_Owner->ReadDirect(buf, length, result); + } + + size_t Write(const void* buf, size_t length, FndResult* result) override { + return m_Owner->WriteDirect(buf, length, result); + } + + FndResult Seek(position_t offset, SeekOrigin origin) override { + return m_Owner->SeekDirect(offset, origin); + } - bool CanRead() const override; - bool CanWrite() const override; - bool CanSeek() const override; - + position_t GetCurrentPosition() const override { + return m_Owner->GetCurrentPosition(); + } + + ~DirectStream() override; + private: FileStreamImpl* m_Owner; }; static_assert(sizeof(DirectStream) == 0x10); FileStreamImpl(); + explicit FileStreamImpl(void*); ~FileStreamImpl() override; - size_t Read(void* buf, size_t length, FndResult* result) override; - size_t Write(const void* buf, size_t length, FndResult* result) override; - FndResult Seek(position_t offset, fnd::Stream::SeekOrigin origin) override; - - bool CanRead() const override; - bool CanWrite() const override; - bool CanSeek() const override; - - void EnableCache(void* buffer, size_t length) override; - void DisableCache() override; - - void ValidateAlignment(void* buf); - FndResult Open(const char* filePath, AccessMode accessMode) override; void Close() override; void Flush() override; bool IsOpened() const override; + bool CanRead() const override; + bool CanWrite() const override; + bool CanSeek() const override; + size_t GetSize() const override; - s32 GetIoBufferAlignment() const override; - size_t ReadDirect(void* buf, size_t length, FndResult* result); - size_t WriteDirect(const void* buf, size_t length, FndResult* result); - FndResult SeekDirect(position_t offset, fnd::Stream::SeekOrigin origin); - - position_t GetCurrentPosition() const override; + size_t Read(void* buf, size_t length, FndResult* result) override; + size_t Write(const void* buf, size_t length, FndResult* result) override; + FndResult Seek(position_t offset, SeekOrigin origin) override; + position_t GetCurrentPosition() const override { + return m_CurrentPosition; + } + + void EnableCache(void* buffer, size_t length) override; + void DisableCache() override; bool IsCacheEnabled() const override; + int GetIoBufferAlignment() const override; + bool CanSetFsAccessLog() const override; void* SetFsAccessLog(FsAccessLog* pFsAccessLog) override; @@ -70,6 +96,12 @@ class FileStreamImpl : FileStream { size_t GetCachedLength() override; private: + size_t ReadDirect(void* buf, size_t length, FndResult* result); + size_t WriteDirect(const void* buf, size_t length, FndResult* result); + FndResult SeekDirect(position_t offset, SeekOrigin origin); + + void ValidateAlignment(void* buf) const; + fs::FileHandle m_FileHandle; bool m_IsOpened; u8 m_Padding[3]; diff --git a/include/nn/atk/fnd/io/atkfnd_Stream.h b/include/nn/atk/fnd/io/atkfnd_Stream.h index 552c2f99..f77bd394 100644 --- a/include/nn/atk/fnd/io/atkfnd_Stream.h +++ b/include/nn/atk/fnd/io/atkfnd_Stream.h @@ -1,13 +1,18 @@ #pragma once #include +#include #include #include namespace nn::atk::detail::fnd { class Stream { + NN_NO_COPY(Stream); public: + static const position_t InvalidPosition = 0xffffffff; + static const size_t InvalidSize = 0xffffffff; + enum SeekOrigin { SeekOrigin_Begin, SeekOrigin_End, @@ -15,20 +20,24 @@ class Stream { }; virtual ~Stream(); - + +protected: + Stream(); + +public: virtual void Close() = 0; virtual bool IsOpened() const = 0; - virtual size_t Read(void* buf, size_t length, FndResult* result) = 0; - virtual size_t Write(const void* buf, size_t length, FndResult* result) = 0; - virtual FndResult Seek(position_t offset, SeekOrigin origin) = 0; + virtual size_t Read(void* buf, size_t length, FndResult* result); + virtual size_t Write(const void* buf, size_t length, FndResult* result); + virtual FndResult Seek(position_t offset, SeekOrigin origin); - virtual position_t GetCurrentPosition() const = 0; - virtual size_t GetSize() const = 0; + virtual position_t GetCurrentPosition() const; + virtual size_t GetSize() const; - virtual bool CanRead() const = 0; - virtual bool CanWrite() const = 0; - virtual bool CanSeek() const = 0; + virtual bool CanRead() const; + virtual bool CanWrite() const; + virtual bool CanSeek() const; }; static_assert(sizeof(Stream) == 0x8); } // namespace nn::atk::detail::fnd \ No newline at end of file diff --git a/src/NintendoWare/atk/fnd/basis/atkfnd_FrameHeapImpl.cpp b/src/NintendoWare/atk/fnd/basis/atkfnd_FrameHeapImpl.cpp index e69de29b..29f297b7 100644 --- a/src/NintendoWare/atk/fnd/basis/atkfnd_FrameHeapImpl.cpp +++ b/src/NintendoWare/atk/fnd/basis/atkfnd_FrameHeapImpl.cpp @@ -0,0 +1,5 @@ +#include + +namespace nn::atk::detail::fnd { + +} // namespace nn::atk::detail::fnd \ No newline at end of file diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp index e69de29b..3bca5e16 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp @@ -0,0 +1,10 @@ +#include + +namespace nn::atk::detail::fnd { +size_t FileStreamImpl::Read(void* buf, size_t length, FndResult* result) { + if (IsCacheEnabled()) + return m_StreamCache.Read(buf, length, result, m_pAccessLog, this); + + return ReadDirect(buf, length, result); +} +} // namespace nn::atk::detail::fnd \ No newline at end of file From e032662afe6c4aad91c074d78ce1180c84432f15 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 27 Aug 2026 14:21:13 -0400 Subject: [PATCH 349/785] atk: Match `FileStreamImpl::Write` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp index 3bca5e16..92c9d3d4 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp @@ -7,4 +7,11 @@ size_t FileStreamImpl::Read(void* buf, size_t length, FndResult* result) { return ReadDirect(buf, length, result); } + +size_t FileStreamImpl::Write(const void* buf, size_t length, FndResult* result) { + if (IsCacheEnabled()) + return m_StreamCache.Write(buf, length, result); + + return WriteDirect(buf, length, result); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From ba2def67b46bff9bb433c43fba1797d7d4ce4dec Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 27 Aug 2026 14:22:03 -0400 Subject: [PATCH 350/785] atk: Match `FileStreamImpl::Seek` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp index 92c9d3d4..5bf5affb 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp @@ -14,4 +14,11 @@ size_t FileStreamImpl::Write(const void* buf, size_t length, FndResult* result) return WriteDirect(buf, length, result); } + +FndResult FileStreamImpl::Seek(position_t offset, SeekOrigin origin) { + if (IsCacheEnabled()) + return m_StreamCache.Seek(offset, origin); + + return SeekDirect(offset, origin); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From d9d39b490f6a5f8fc618fdba3d356f998f7484b9 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 27 Aug 2026 14:24:31 -0400 Subject: [PATCH 351/785] atk: Match `FileStreamImpl::CanRead` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp index 5bf5affb..6af480f1 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp @@ -21,4 +21,8 @@ FndResult FileStreamImpl::Seek(position_t offset, SeekOrigin origin) { return SeekDirect(offset, origin); } + +bool FileStreamImpl::CanRead() const { + return IsOpened(); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From d40efd65d3606d909ab08a472b6105afdbe8bd36 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 27 Aug 2026 14:25:27 -0400 Subject: [PATCH 352/785] atk: Match `FileStreamImpl::CanWrite` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp index 6af480f1..6107e21f 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp @@ -25,4 +25,8 @@ FndResult FileStreamImpl::Seek(position_t offset, SeekOrigin origin) { bool FileStreamImpl::CanRead() const { return IsOpened(); } + +bool FileStreamImpl::CanWrite() const { + return IsOpened(); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 5907aba315fa0a83f629023373ca258e5f7c1d17 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 27 Aug 2026 14:25:40 -0400 Subject: [PATCH 353/785] atk: Match `FileStreamImpl::CanSeek` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp index 6107e21f..a907adfe 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp @@ -29,4 +29,8 @@ bool FileStreamImpl::CanRead() const { bool FileStreamImpl::CanWrite() const { return IsOpened(); } + +bool FileStreamImpl::CanSeek() const { + return IsOpened(); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 15e83ac7de80700019ff7e7b4d0cc1586865e713 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 27 Aug 2026 14:44:03 -0400 Subject: [PATCH 354/785] atk: Match `FileStreamImpl::EnableCache` --- include/nn/atk/fnd/io/atkfnd_StreamCache.h | 6 +++++- .../atk/fnd/io/atkfnd_FileStreamImpl.cpp | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/fnd/io/atkfnd_StreamCache.h b/include/nn/atk/fnd/io/atkfnd_StreamCache.h index 9a4c61fe..9346b44c 100644 --- a/include/nn/atk/fnd/io/atkfnd_StreamCache.h +++ b/include/nn/atk/fnd/io/atkfnd_StreamCache.h @@ -7,11 +7,15 @@ struct FsAccessLog; class StreamCache { public: - constexpr static position_t InvalidPosition = -1; + static const position_t InvalidPosition = -1; StreamCache(); StreamCache(Stream* sourceStream, void* buffer, size_t length); + bool IsInitialized() const { + return m_Stream != nullptr && m_CacheBuffer != nullptr && m_CacheBufferLength != 0; + } + void Initialize(Stream* sourceStream, void* buffer, size_t length); void Finalize(); diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp index a907adfe..ef5b85b2 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp @@ -1,5 +1,9 @@ #include +#include + +#include + namespace nn::atk::detail::fnd { size_t FileStreamImpl::Read(void* buf, size_t length, FndResult* result) { if (IsCacheEnabled()) @@ -33,4 +37,17 @@ bool FileStreamImpl::CanWrite() const { bool FileStreamImpl::CanSeek() const { return IsOpened(); } + +void FileStreamImpl::EnableCache(void* buffer, size_t length) { + if (m_StreamCache.IsInitialized()) + m_StreamCache.Finalize(); + + void* alignedBuffer {util::BytePtr(buffer).AlignUp(GetIoBufferAlignment()).Get()}; + + m_StreamCache.Initialize( + &m_DirectStream, + alignedBuffer, + length + GetOffsetFromPtr(alignedBuffer, buffer) + ); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 34a43cf5defd0af66b779567b3cf0158c119bed0 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 27 Aug 2026 14:45:28 -0400 Subject: [PATCH 355/785] atk: Match `FileStreamImpl::DisableCache` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp index ef5b85b2..070b020a 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp @@ -50,4 +50,8 @@ void FileStreamImpl::EnableCache(void* buffer, size_t length) { length + GetOffsetFromPtr(alignedBuffer, buffer) ); } + +void FileStreamImpl::DisableCache() { + m_StreamCache.Finalize(); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From d0500e3d63050b9b28ef12bcbb6015d74badfe60 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 27 Aug 2026 14:49:18 -0400 Subject: [PATCH 356/785] atk: Match `FileStreamImpl::ValidateAlignment` --- include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h | 2 +- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h b/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h index 4e983127..2f165f94 100644 --- a/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h +++ b/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h @@ -100,7 +100,7 @@ class FileStreamImpl : public FileStream { size_t WriteDirect(const void* buf, size_t length, FndResult* result); FndResult SeekDirect(position_t offset, SeekOrigin origin); - void ValidateAlignment(void* buf) const; + void ValidateAlignment([[maybe_unused]] const void* buf) const; fs::FileHandle m_FileHandle; bool m_IsOpened; diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp index 070b020a..f4c2570a 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp @@ -54,4 +54,8 @@ void FileStreamImpl::EnableCache(void* buffer, size_t length) { void FileStreamImpl::DisableCache() { m_StreamCache.Finalize(); } + +void FileStreamImpl::ValidateAlignment([[maybe_unused]] const void* buf) const { + GetIoBufferAlignment(); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 648597f954f39fa7355a3b6b7658111a2759e6e0 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 27 Aug 2026 14:58:58 -0400 Subject: [PATCH 357/785] atk: Match `FileStreamImpl` constructor --- include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h | 10 ++++++---- include/nn/atk/fnd/io/atkfnd_Stream.h | 2 +- .../atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h b/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h index 2f165f94..755e4d16 100644 --- a/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h +++ b/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h @@ -55,6 +55,8 @@ class FileStreamImpl : public FileStream { ~DirectStream() override; private: + friend FileStreamImpl; + FileStreamImpl* m_Owner; }; static_assert(sizeof(DirectStream) == 0x10); @@ -102,14 +104,14 @@ class FileStreamImpl : public FileStream { void ValidateAlignment([[maybe_unused]] const void* buf) const; - fs::FileHandle m_FileHandle; - bool m_IsOpened; + fs::FileHandle m_FileHandle {0}; + bool m_IsOpened {false}; u8 m_Padding[3]; size_t m_FileSize; - position_t m_CurrentPosition; + position_t m_CurrentPosition {0}; StreamCache m_StreamCache; DirectStream m_DirectStream; - FsAccessLog* m_pAccessLog; + FsAccessLog* m_pAccessLog {nullptr}; }; static_assert(sizeof(FileStreamImpl) == 0x80); } // namespace nn::atk::detail::fnd \ No newline at end of file diff --git a/include/nn/atk/fnd/io/atkfnd_Stream.h b/include/nn/atk/fnd/io/atkfnd_Stream.h index f77bd394..9d003cb5 100644 --- a/include/nn/atk/fnd/io/atkfnd_Stream.h +++ b/include/nn/atk/fnd/io/atkfnd_Stream.h @@ -22,7 +22,7 @@ class Stream { virtual ~Stream(); protected: - Stream(); + Stream() = default; public: virtual void Close() = 0; diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp index e69de29b..9fed21a7 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp @@ -0,0 +1,18 @@ +#include + +namespace nn::atk::detail::fnd { +namespace { +fs::OpenMode ConvertAccessMode(FileStream::AccessMode accessMode) { + +} + +position_t GetSeekPosition(FileStreamImpl& target, position_t offset, Stream::SeekOrigin origin) { + position_t targetSizeEnd; + position_t result; +} +} // anonymous namespace + +FileStreamImpl::FileStreamImpl() { + m_DirectStream.m_Owner = this; +}; +} // namespace nn::atk::detail::fnd \ No newline at end of file From 321478e2cf8b8034f48247d9aea425219ad373b0 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 27 Aug 2026 15:27:39 -0400 Subject: [PATCH 358/785] atk: Match `FileStreamImpl::Close` --- include/nn/atk/fnd/io/atkfnd_FileStream.h | 6 +++--- .../atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/nn/atk/fnd/io/atkfnd_FileStream.h b/include/nn/atk/fnd/io/atkfnd_FileStream.h index 30ee5685..3d46a490 100644 --- a/include/nn/atk/fnd/io/atkfnd_FileStream.h +++ b/include/nn/atk/fnd/io/atkfnd_FileStream.h @@ -8,9 +8,9 @@ class FileStream : public Stream { public: enum AccessMode { AccessMode_None = 0, - AccessMode_Read = 1, - AccessMode_Write = 2, - AccessMode_AllowAppend = 4, + AccessMode_Read = 1 << 0, + AccessMode_Write = 1 << 1, + AccessMode_AllowAppend = 1 << 2, AccessMode_ReadAndWrite = AccessMode_Read | AccessMode_Write, AccessMode_AllowAppendAndWrite = AccessMode_AllowAppend | AccessMode_Write, }; diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp index 9fed21a7..3bf50593 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp @@ -1,5 +1,7 @@ #include +#include + namespace nn::atk::detail::fnd { namespace { fs::OpenMode ConvertAccessMode(FileStream::AccessMode accessMode) { @@ -15,4 +17,12 @@ position_t GetSeekPosition(FileStreamImpl& target, position_t offset, Stream::Se FileStreamImpl::FileStreamImpl() { m_DirectStream.m_Owner = this; }; + +void FileStreamImpl::Close() { + if (IsOpened()) { + m_CurrentPosition = 0; + m_IsOpened = false; + fs::CloseFile(m_FileHandle); + } +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 5591fc20a7e978b5f652a1005f5294519b6eea72 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 27 Aug 2026 15:29:32 -0400 Subject: [PATCH 359/785] atk: Match `FileStreamImpl::Flush` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp index 3bf50593..39d854fb 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp @@ -25,4 +25,9 @@ void FileStreamImpl::Close() { fs::CloseFile(m_FileHandle); } } + +void FileStreamImpl::Flush() { + if (IsOpened()) + fs::FlushFile(m_FileHandle); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 4e666522836a50bb92c1b4a21185ac2c6aa0ccd1 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 27 Aug 2026 15:30:28 -0400 Subject: [PATCH 360/785] atk: Match `FileStreamImpl::IsOpened` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp index 39d854fb..2ea9088f 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp @@ -30,4 +30,8 @@ void FileStreamImpl::Flush() { if (IsOpened()) fs::FlushFile(m_FileHandle); } + +bool FileStreamImpl::IsOpened() const { + return m_IsOpened; +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 4c153de368f6ba2ac1f77b6b9acd2afb28b2b880 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 27 Aug 2026 15:41:00 -0400 Subject: [PATCH 361/785] atk: Add implementation for `FileStreamImpl::GetSize` --- .../atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp index 2ea9088f..0c1ea126 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp @@ -34,4 +34,15 @@ void FileStreamImpl::Flush() { bool FileStreamImpl::IsOpened() const { return m_IsOpened; } + +// NON_MATCHING: needs symbol for nn::diag::detail::AbortImpl +size_t FileStreamImpl::GetSize() const { + s64 fileSize; + Result result {fs::GetFileSize(&fileSize, m_FileHandle)}; + + if (result.IsSuccess()) + return fileSize & 0xffffffff; + + // diag::detail::AbortImpl("", "", "", 0); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 30d705964972ea20d6f57c5b75e9468437f0fff9 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 27 Aug 2026 15:42:11 -0400 Subject: [PATCH 362/785] atk: Match `FileStreamImpl::GetIoBufferAlignment` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp index 0c1ea126..cccaa930 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp @@ -45,4 +45,8 @@ size_t FileStreamImpl::GetSize() const { // diag::detail::AbortImpl("", "", "", 0); } + +int FileStreamImpl::GetIoBufferAlignment() const { + return 1; +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 45d0b0bd9131d6c22b595a57ec959c953e2471ef Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 27 Aug 2026 16:52:19 -0400 Subject: [PATCH 363/785] atk: Match `FileStreamImpl::ReadDirect` --- include/nn/atk/fnd/basis/atkfnd_Result.h | 62 +++++++++++++++---- .../fnd/io/atkfnd_FileStreamImpl.win32.cpp | 22 +++++++ 2 files changed, 72 insertions(+), 12 deletions(-) diff --git a/include/nn/atk/fnd/basis/atkfnd_Result.h b/include/nn/atk/fnd/basis/atkfnd_Result.h index 74879b2a..81a06b05 100644 --- a/include/nn/atk/fnd/basis/atkfnd_Result.h +++ b/include/nn/atk/fnd/basis/atkfnd_Result.h @@ -4,17 +4,20 @@ namespace nn::atk::detail::fnd { enum FndResultType { + FndResultType_ErrorFlagMask = 1 << 31, + FndResultType_CategoryMask = 0b1111111 << 24, FndResultType_CodeMask = 0xffffff, - FndResultType_CategoryMask = 0x7f000000, - FndResultType_ErrorFlagMask = ~(FndResultType_CategoryMask | FndResultType_CodeMask), - - FndResultType_CategorySystem = 0x0, - FndResultType_CategoryBitOffset = 0x18, - FndResultType_CategoryIo = 0x1000000, + FndResultType_CategoryBitOffset = 24, FndResultType_ErrorFlag = FndResultType_ErrorFlagMask, + + FndResultType_CategorySystem = 0, + FndResultType_CategoryIo = 1 << FndResultType_CategoryBitOffset, - FndResultType_Failed = FndResultType_ErrorFlag, + FndResultType_True = FndResultType_CategorySystem, + FndResultType_False, + + FndResultType_Failed = FndResultType_ErrorFlag | FndResultType_CategorySystem, FndResultType_NotInitialized, FndResultType_NotSupported, FndResultType_NotOpened, @@ -22,17 +25,52 @@ enum FndResultType { FndResultType_InvalidArgument, FndResultType_InvalidStatus, - FndResultType_IoError = -0x7f000000, + FndResultType_IoError = FndResultType_ErrorFlag | FndResultType_CategoryIo, FndResultType_IoFileNotFound, FndResultType_IoInvalidAccess, FndResultType_IoTargetLocked, - - FndResultType_True = 0, - FndResultType_False, }; -struct FndResult { +class FndResult { +public: + FndResult() = default; + + explicit FndResult(u32 value) + : value{value} {}; + + explicit FndResult(FndResultType value) + : value(value) {}; + + bool IsSucceeded() const { + return !IsFailed(); + } + + bool IsTrue() const { + return value == FndResultType_True; + } + + bool IsFalse() const { + return value == FndResultType_False; + } + + bool IsFailed() const { + return value == FndResultType_Failed; + } + + const char* ToString(); + + void PrintResult(); + + explicit operator u32() const { + return value; + } + + explicit operator FndResultType() const { + return FndResultType(value); + } +private: u32 value; + }; static_assert(sizeof(FndResult) == 0x4); } // namespace nn::atk::detail::fnd \ No newline at end of file diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp index cccaa930..c7d2126e 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp @@ -49,4 +49,26 @@ size_t FileStreamImpl::GetSize() const { int FileStreamImpl::GetIoBufferAlignment() const { return 1; } + +size_t FileStreamImpl::ReadDirect(void* buf, size_t length, FndResult* result) { + ValidateAlignment(buf); + + size_t readFileLength {0}; + Result nnResult {fs::ReadFile(&readFileLength, m_FileHandle, m_CurrentPosition, buf, length)}; + + FndResult readResult; + + if (nnResult.IsSuccess()) { + readResult = FndResult{readFileLength != length}; + m_CurrentPosition += readFileLength; + } + else { + readResult = FndResult{FndResultType_IoError}; + } + + if (result != nullptr) + *result = readResult; + + return readFileLength; +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 6cc62a9cca9deba378562cd6c34d4812ca1d188c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 27 Aug 2026 16:52:32 -0400 Subject: [PATCH 364/785] atk: Match `FileStreamImpl::WriteDirect` --- .../fnd/io/atkfnd_FileStreamImpl.win32.cpp | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp index c7d2126e..45720370 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp @@ -71,4 +71,27 @@ size_t FileStreamImpl::ReadDirect(void* buf, size_t length, FndResult* result) { return readFileLength; } + +size_t FileStreamImpl::WriteDirect(const void* buf, size_t length, FndResult* result) { + ValidateAlignment(buf); + + FndResult writeResult; + + fs::WriteOption option; + Result nnResult {fs::WriteFile(m_FileHandle, m_CurrentPosition, buf, length, option)}; + + + if (nnResult.IsSuccess()) { + writeResult = FndResult{FndResultType_True}; + m_CurrentPosition += length; + } + else { + writeResult = FndResult{FndResultType_IoError}; + } + + if (result != nullptr) + *result = writeResult; + + return length; +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 4e7fbf52605089bb6e933ed275d6c41a4daf9636 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 28 Aug 2026 14:29:28 -0400 Subject: [PATCH 365/785] atk: Add non-matching implementation for `FileStreamImpl::SeekDirect` --- .../fnd/io/atkfnd_FileStreamImpl.win32.cpp | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp index 45720370..c4b2ef2e 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp @@ -8,9 +8,37 @@ fs::OpenMode ConvertAccessMode(FileStream::AccessMode accessMode) { } +// NON_MATCHING: still unsure of logic. position_t GetSeekPosition(FileStreamImpl& target, position_t offset, Stream::SeekOrigin origin) { - position_t targetSizeEnd; - position_t result; + position_t targetSizeEnd = target.GetSize(); + position_t result {0}; + + switch (origin) { + case Stream::SeekOrigin_Begin: + result = offset >= 0 ? offset : 0; + break; + case Stream::SeekOrigin_End: + result = targetSizeEnd - (offset < 0 ? offset : 0); + break; + case Stream::SeekOrigin_Current: + if (offset > 0) { + position_t position {target.GetCurrentPosition()}; + if (position + offset <= targetSizeEnd) + result = position + offset; + else + result = targetSizeEnd; + } + else if (offset < 0) { + if (0 < target.GetCurrentPosition() + offset) + result = target.GetCurrentPosition() + offset; + } + break; + default: + result = 0; + break; + } + + return result; } } // anonymous namespace @@ -94,4 +122,11 @@ size_t FileStreamImpl::WriteDirect(const void* buf, size_t length, FndResult* re return length; } + +// NON_MATCHING: needs GetSeekPosition +FndResult FileStreamImpl::SeekDirect(position_t offset, SeekOrigin origin) { + position_t seekPosition {GetSeekPosition(*this, offset, origin)}; + m_CurrentPosition = seekPosition; + return FndResult{FndResultType_True}; +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 9abe97624760f9d37ccaa2e1b686228e7f36ca3e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 28 Aug 2026 17:38:19 -0400 Subject: [PATCH 366/785] atk: Match `SoundArchiveFile::FileHeader::GetStringBlockSize` Also reorganized `SoundArchiveFile` to better match DWARF --- include/nn/atk/atk_SoundArchiveFile.h | 416 ++++++++++++------ .../atk/detail/atk_SoundArchiveFile.cpp | 16 + 2 files changed, 292 insertions(+), 140 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveFile.h b/include/nn/atk/atk_SoundArchiveFile.h index 5a04ff2c..b1bd630f 100644 --- a/include/nn/atk/atk_SoundArchiveFile.h +++ b/include/nn/atk/atk_SoundArchiveFile.h @@ -1,50 +1,67 @@ #pragma once +#include +#include #include -#include namespace nn::atk::detail { class SoundArchiveParametersHook; class SoundArchiveFile { public: - constexpr static u32 BlockCount = 3; + static const int BlockCount {3}; struct FileHeader : BinaryFileHeader { - - Util::ReferenceWithSize* GetReferenceBy(u16) const; + Util::ReferenceWithSize toBlocks[BlockCount]; u32 GetStringBlockSize() const; u32 GetInfoBlockSize() const; u32 GetFileBlockSize() const; - s32 GetStringBlockOffset() const; - s32 GetInfoBlockOffset() const; - s32 GetFileBlockOffset() const; + int GetStringBlockOffset() const; + int GetInfoBlockOffset() const; + int GetFileBlockOffset() const; - Util::ReferenceWithSize toBlocks[BlockCount]; + private: + const Util::ReferenceWithSize* GetReferenceBy(u16 typeId) const; }; static_assert(sizeof(FileHeader) == 0x38); + struct StringTable; + struct PatriciaTree; struct StringBlockBody { enum Sections { - Sections_StringTable, - Sections_PatriciaTree, - Sections_Max, + Sections_StringTable = 0, + Sections_PatriciaTree = 1, + Sections_Max = Sections_PatriciaTree, }; - void* GetSection(Sections section) const; - char* GetString(u32) const; - u32 GetItemIdImpl(Sections section, char* str) const; + Util::Reference toSection[1]; + + const char* GetString(SoundArchive::StringId stringId) const; + + u32 GetStringCount() const { + return GetStringTable()->GetCount(); + } + + u32 GetItemId(const char* str) const { + return GetItemIdImpl(Sections_PatriciaTree, str); + } void DumpTree() const; + + private: + const void* GetSection(Sections section) const; + + const StringTable* GetStringTable() const { + return util::ConstBytePtr(GetSection(Sections_StringTable)).Get(); + } - Util::Reference toSection[1]; - }; + const PatriciaTree* GetPatriciaTree(Sections section) const { + // TODO + } - struct StringBlock { - BinaryBlockHeader header; - StringBlockBody body; + u32 GetItemIdImpl(Sections section, const char* str) const; }; struct PatriciaTree { @@ -55,7 +72,7 @@ class SoundArchiveFile { static_assert(sizeof(NodeData) == 0x8); struct Node { - constexpr static u32 FlagLeaf = 1; + static const u16 FlagLeaf {1 << 0}; u16 flags; u16 bit; @@ -65,10 +82,46 @@ class SoundArchiveFile { }; static_assert(sizeof(Node) == 0x14); - void* GetNodeDataBy(const char*, u64); - u32 rootIdx; Util::Table nodeTable; + + const NodeData* GetNodeDataBy(const char* str, size_t len); + + void* operator[](int idx) const { + // TODO + } + + void* operator[](u32 idx) const { + // TODO + } + + void* operator[](const char* str) const { + // TODO + } + + void* operator()(const char* str, size_t len) const { + // TODO + } + + u32 GetDataCount() const; + u32 GetCount() const; + }; + + struct StringBlock { + BinaryBlockHeader header; + StringBlockBody body; + }; + + struct StringTable { + Util::ReferenceWithSizeTable table; + + const char* GetString(int stringId) const { + return util::ConstBytePtr(this, table.item[stringId].offset).Get(); + } + + u32 GetCount() const { + return table.count; + } }; struct SoundInfo; @@ -80,34 +133,6 @@ class SoundArchiveFile { struct FileInfo; struct SoundArchivePlayerInfo; struct InfoBlockBody { - - SoundInfo* GetSoundInfo(SoundArchive::ItemId itemId) const; - Util::ReferenceTable* GetSoundInfoReferenceTable() const; - - BankInfo* GetBankInfo(SoundArchive::ItemId itemId) const; - Util::ReferenceTable* GetBankInfoReferenceTable() const; - - PlayerInfo* GetPlayerInfo(SoundArchive::ItemId itemId) const; - Util::ReferenceTable* GetPlayerInfoReferenceTable() const; - - SoundGroupInfo* GetSoundGroupInfo(SoundArchive::ItemId itemId) const; - Util::ReferenceTable* GetSoundGroupInfoReferenceTable() const; - - GroupInfo* GetGroupInfo(SoundArchive::ItemId itemId) const; - Util::ReferenceTable* GetGroupInfoReferenceTable() const; - - WaveArchiveInfo* GetWaveArchiveInfo(SoundArchive::ItemId itemId) const; - Util::ReferenceTable* GetWaveArchiveInfoReferenceTable() const; - - FileInfo* GetFileInfo(SoundArchive::FileId itemId) const; - Util::ReferenceTable* GetFileInfoReferenceTable() const; - - SoundArchive::FileId GetItemFileId(SoundArchive::ItemId id) const; - SoundArchive::FileId GetItemPrefetchFileId(SoundArchive::ItemId id) const; - SoundArchive::StringId GetItemStringId(SoundArchive::ItemId id) const; - - SoundArchivePlayerInfo* GetSoundArchivePlayerInfo() const; - Util::Reference toSoundInfoReferenceTable; Util::Reference toSoundGroupInfoReferenceTable; Util::Reference toBankInfoReferenceTable; @@ -116,6 +141,37 @@ class SoundArchiveFile { Util::Reference toPlayerInfoReferenceTable; Util::Reference toFileInfoReferenceTable; Util::Reference toSoundArchivePlayerInfo; + + u32 GetSoundCount() const; + u32 GetBankCount() const; + u32 GetPlayerCount() const; + u32 GetSoundGroupCount() const; + u32 GetGroupCount() const; + u32 GetWaveArchiveCount() const; + u32 GetFileCount() const; + + const SoundInfo* GetSoundInfo(SoundArchive::ItemId itemId) const; + const BankInfo* GetBankInfo(SoundArchive::ItemId itemId) const; + const PlayerInfo* GetPlayerInfo(SoundArchive::ItemId itemId) const; + const SoundGroupInfo* GetSoundGroupInfo(SoundArchive::ItemId itemId) const; + const GroupInfo* GetGroupInfo(SoundArchive::ItemId itemId) const; + const WaveArchiveInfo* GetWaveArchiveInfo(SoundArchive::ItemId itemId) const; + const FileInfo* GetFileInfo(SoundArchive::FileId itemId) const; + + const SoundArchivePlayerInfo* GetSoundArchivePlayerInfo() const; + + SoundArchive::FileId GetItemFileId(SoundArchive::ItemId id) const; + SoundArchive::StringId GetItemStringId(SoundArchive::ItemId id) const; + SoundArchive::FileId GetItemPrefetchFileId(SoundArchive::ItemId id) const; + + private: + const Util::ReferenceTable& GetSoundInfoReferenceTable() const; + const Util::ReferenceTable& GetBankInfoReferenceTable() const; + const Util::ReferenceTable& GetPlayerInfoReferenceTable() const; + const Util::ReferenceTable& GetSoundGroupInfoReferenceTable() const; + const Util::ReferenceTable& GetWaveArchiveInfoReferenceTable() const; + const Util::ReferenceTable& GetGroupInfoReferenceTable() const; + const Util::ReferenceTable& GetFileInfoReferenceTable() const; }; static_assert(sizeof(InfoBlockBody) == 0x40); @@ -131,17 +187,22 @@ class SoundArchiveFile { struct SequenceSoundInfo; struct Sound3DInfo; struct SoundInfo { + u32 fileId; + u32 playerId; + u8 volume; + u8 remoteFilter; + u8 padding[2]; + Util::Reference toDetailSoundInfo; + Util::BitFlag optionParameter; SoundArchive::SoundType GetSoundType() const; - StreamSoundInfo* GetStreamSoundInfo() const; - - SoundArchive::StringId GetStringId() const; - - WaveSoundInfo* GetWaveSoundInfo() const; - AdvancedWaveSoundInfo* GetAdvancedWaveSoundInfo() const; - SequenceSoundInfo* GetSequenceSoundInfo() const; - Sound3DInfo* GetSound3DInfo() const; + const StreamSoundInfo& GetStreamSoundInfo() const; + const WaveSoundInfo& GetWaveSoundInfo() const; + const AdvancedWaveSoundInfo& GetAdvancedWaveSoundInfo() const; + const SequenceSoundInfo& GetSequenceSoundInfo() const; + const Sound3DInfo& GetSound3DInfo() const; + u32 GetStringId() const; PanMode GetPanMode() const; PanCurve GetPanCurve() const; SinglePlayType GetSinglePlayType() const; @@ -150,20 +211,32 @@ class SoundArchiveFile { u8 GetActorPlayerId() const; u32 GetUserParam() const; - bool ReadUserParam(u32*, s32) const; + bool ReadUserParam(u32* pOutValue, int index) const; bool IsFrontBypass() const; - - u32 fileId; - u32 playerId; - u8 volume; - u8 remoteFilter; - u8 padding[2]; - Util::Reference toDetailSoundInfo; - Util::BitFlag optionParameter; }; static_assert(sizeof(SoundInfo) == 0x18); + struct StreamTrackInfo; + struct StreamTrackInfoTable { + Util::ReferenceTable table; + + const StreamTrackInfo* GetTrackInfo(u32 index) { + return util::ConstBytePtr(table.GetReferedItem(ElementType_SoundArchiveFile_StreamSoundTrackInfo, index)) + .Get(); + } + + u32 GetTrackCount() const { + return table.count; + } + }; + + struct SendValue { + u8 mainSend; + u8 fxSend[3]; + }; + static_assert(sizeof(SendValue) == 0x4); + struct StreamTrackInfo { u8 volume; u8 pan; @@ -175,50 +248,84 @@ class SoundArchiveFile { u8 biquadType; u8 biquadValue; u8 padding[1]; - }; - static_assert(sizeof(StreamTrackInfo) == 0x18); - struct StreamTrackInfoTable { - Util::ReferenceTable table; + u32 GetTrackChannelCount() const { + return GetGlobalChannelIndexTable().GetCount(); + } + + u8 GetGlobalChannelIndex(u32 index) const { + return GetGlobalChannelIndexTable().GetGlobalIndex(index); + } + + const SendValue& GetSendValue() const { + return *util::ConstBytePtr(this, toSendValue.offset) + .Get(); + } + + const StreamSoundFile::GlobalChannelIndexTable& GetGlobalChannelIndexTable() const { + return *util::ConstBytePtr(this, toGlobalChannelIndexTable.offset) + .Get(); + } }; + static_assert(sizeof(StreamTrackInfo) == 0x18); struct StreamSoundExtension { u32 streamTypeInfo; u32 loopStartFrame; u32 loopEndFrame; - }; - static_assert(sizeof(StreamSoundExtension) == 0xc); - struct SendValue { - u8 mainSend; - u8 fxSend[3]; + SoundArchive::StreamFileType GetStreamFileType() const { + switch (Util::DivideBy8bit(streamTypeInfo, 0)) { + case 1: + return SoundArchive::StreamFileType_NwStreamBinary; + case 3: + return SoundArchive::StreamFileType_Opus; + default: + return SoundArchive::StreamFileType_Invalid; + } + } + + bool IsLoop() const { + return Util::DivideBy8bit(streamTypeInfo, 1) != 0; + } + + SoundArchive::DecodeMode GetDecodeMode() const { + switch (Util::DivideBy8bit(streamTypeInfo, 2)) { + case 1: + return SoundArchive::DecodeMode_Cpu; + case 2: + return SoundArchive::DecodeMode_Accelerator; + default: + return SoundArchive::DecodeMode_Default; + } + } }; - static_assert(sizeof(SendValue) == 0x4); + static_assert(sizeof(StreamSoundExtension) == 0xc); struct StreamSoundInfo { - - StreamTrackInfoTable* GetTrackInfoTable() const; - StreamSoundExtension* GetStreamSoundExtension() const; - SendValue* GetSendValue() const; - u16 allocateTrackFlags; u16 allocateChannelCount; Util::Reference toTrackInfoTable; - f32 pitch; + float pitch; Util::Reference toSendValue; Util::Reference toStreamSoundExtension; u32 prefetchFileId; + + const StreamTrackInfoTable* GetTrackInfoTable() const; + + float GetPitch() const { return pitch; } + const SendValue& GetSendValue() const; + const StreamSoundExtension* GetStreamSoundExtension() const; }; static_assert(sizeof(StreamSoundInfo) == 0x24); struct WaveSoundInfo { - - u8 GetChannelPriority() const; - u8 GetIsReleasePriorityFix() const; - u32 index; u32 allocateTrackCount; Util::BitFlag optionParameter; + + u8 GetChannelPriority() const; + u8 GetIsReleasePriorityFix() const; }; static_assert(sizeof(WaveSoundInfo) == 0xc); @@ -228,17 +335,16 @@ class SoundArchiveFile { static_assert(sizeof(AdvancedWaveSoundInfo) == 0x4); struct SequenceSoundInfo { - - Util::ReferenceTable* GetBankIdTable() const; + Util::Reference toBankIdTable; + u32 allocateTrackFlags; + Util::BitFlag optionParameter; + void GetBankIds(u32* bankIds) const; u32 GetStartOffset() const; u8 GetChannelPriority() const; - bool IsReleasePriorityFix() const; - Util::Reference toBankIdTable; - u32 allocateTrackFlags; - Util::BitFlag optionParameter; + const Util::Table& GetBankIdTable() const; }; static_assert(sizeof(SequenceSoundInfo) == 0x10); @@ -253,77 +359,79 @@ class SoundArchiveFile { static_assert(sizeof(Sound3DInfo) == 0x10); struct BankInfo { - - SoundArchive::StringId GetStringId() const; - u32 fileId; Util::Reference toWaveArchiveItemIdTable; Util::BitFlag optionParameter; + + u32 GetStringId() const; + + const Util::Table* GetWaveArchiveItemIdTable() const { + return util::ConstBytePtr(this, toWaveArchiveItemIdTable.offset) + .Get>(); + } }; static_assert(sizeof(BankInfo) == 0x10); struct PlayerInfo { - - SoundArchive::StringId GetStringId() const; - u32 GetPlayerHeapSize() const; - u32 playableSoundMax; Util::BitFlag optionParameter; + + u32 GetStringId() const; + u32 GetPlayerHeapSize() const; }; static_assert(sizeof(PlayerInfo) == 0x8); + struct WaveSoundGroupInfo; struct SoundGroupInfo { - - SoundArchive::StringId GetStringId() const; - u32 startId; u32 endId; Util::Reference toFileIdTable; Util::Reference toDetailSoundGroupInfo; Util::BitFlag optionParameter; + + u32 GetStringId() const; + + const Util::Table* GetFileIdTable() const { + return util::ConstBytePtr(this, toFileIdTable.offset) + .Get>(); + } + + const WaveSoundGroupInfo* GetWaveSoundGroupInfo() const { + return util::ConstBytePtr(this, toDetailSoundGroupInfo.offset) + .Get(); + } }; static_assert(sizeof(SoundGroupInfo) == 0x1c); - struct GroupInfo { + struct WaveSoundGroupInfo { + Util::Reference toWaveArchiveItemIdTable; + Util::BitFlag optionParameter; - SoundArchive::StringId GetStringId() const; + const Util::Table* GetWaveArchiveItemIdTable() const { + return util::ConstBytePtr(this, toWaveArchiveItemIdTable.offset) + .Get>(); + } + }; + static_assert(sizeof(WaveSoundGroupInfo) == 0xc); + struct GroupInfo { u32 fileId; Util::BitFlag optionParameter; + + u32 GetStringId() const; }; static_assert(sizeof(GroupInfo) == 0x8); struct WaveArchiveInfo { - - SoundArchive::StringId GetStringId() const; - u32 GetWaveCount() const; - u32 fileId; bool isLoadIndividual; u8 padding[3]; Util::BitFlag optionParameter; - }; - static_assert(sizeof(WaveArchiveInfo) == 0xc); - - struct SoundArchivePlayerInfo { - u16 sequenceSoundCount; - u16 sequenceTrackCount; - u16 streamSoundCount; - u16 streamTrackCount; - u16 streamChannelCount; - u16 waveSoundCount; - u16 waveTrackCount; - u8 streamBufferTimes; - u8 developFlags; - u32 options; - }; - static_assert(sizeof(SoundArchivePlayerInfo) == 0x14); - struct WaveSoundGroupInfo { - Util::Reference toWaveArchiveItemIdTable; - Util::BitFlag optionParameter; + u32 GetStringId() const; + u32 GetWaveCount() const; }; - static_assert(sizeof(WaveSoundGroupInfo) == 0xc); + static_assert(sizeof(WaveArchiveInfo) == 0xc); enum FileLocationType { FileLocationType_Internal, @@ -331,12 +439,37 @@ class SoundArchiveFile { FileLocationType_None, }; + struct InternalFileInfo; + struct ExternalFileInfo; + struct FileInfo { + Util::Reference toFileLocation; + Util::BitFlag optionParameter; + + FileLocationType GetFileLocationType() const; + const InternalFileInfo* GetInternalFileInfo() const; + const ExternalFileInfo* GetExternalFileInfo() const; + }; + static_assert(sizeof(FileInfo) == 0xc); + struct InternalFileInfo { - constexpr static s32 InvalidOffset = -1; - constexpr static s32 InvalidSize = -1; + static const u32 InvalidOffset {0xffffffff}; + static const u32 InvalidSize {0xffffffff}; Util::ReferenceWithSize toFileImageFromFileBlockBody; Util::Reference toAttachedGroupIdTable; + + u32 GetFileSize() const { + return toFileImageFromFileBlockBody.size; + } + + u32 GetOffsetFromFileBlockHead() const { + return toFileImageFromFileBlockBody.offset; + } + + const Util::Table* GetAttachedGroupTable() const { + return util::ConstBytePtr(this, toAttachedGroupIdTable.offset) + .Get>(); + } }; static_assert(sizeof(InternalFileInfo) == 0x14); @@ -344,16 +477,19 @@ class SoundArchiveFile { char filePath[1]; }; - struct FileInfo { - - FileLocationType GetFileLocationType() const; - InternalFileInfo* GetInternalFileInfo() const; - ExternalFileInfo* GetExternalFileInfo() const; - - Util::Reference toFileLocation; - Util::BitFlag optionParameter; + struct SoundArchivePlayerInfo { + u16 sequenceSoundCount; + u16 sequenceTrackCount; + u16 streamSoundCount; + u16 streamTrackCount; + u16 streamChannelCount; + u16 waveSoundCount; + u16 waveTrackCount; + u8 streamBufferTimes; + u8 developFlags; + u32 options; }; - static_assert(sizeof(FileInfo) == 0xc); + static_assert(sizeof(SoundArchivePlayerInfo) == 0x14); struct FileBlock {}; }; diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index e69de29b..c8d6e4b9 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -0,0 +1,16 @@ +#include + +namespace nn::atk::detail { +const Util::ReferenceWithSize* SoundArchiveFile::FileHeader::GetReferenceBy(u16 typeId) const { + for (int i {0}; i < BlockCount; ++i) { + if (toBlocks[i].typeId == typeId) + return &toBlocks[i]; + } + + return nullptr; +} + +u32 SoundArchiveFile::FileHeader::GetStringBlockSize() const { + return GetReferenceBy(ElementType_SoundArchiveFile_StringBlock)->size; +} +} // namespace nn::atk::detail \ No newline at end of file From f0f56b978dd96ec504a333ceae30990fb1eaa420 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 10:53:38 -0400 Subject: [PATCH 367/785] atk: Match `SoundArchiveFile::FileHeader::GetInfoBlockSize` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index c8d6e4b9..ae01a403 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -13,4 +13,8 @@ const Util::ReferenceWithSize* SoundArchiveFile::FileHeader::GetReferenceBy(u16 u32 SoundArchiveFile::FileHeader::GetStringBlockSize() const { return GetReferenceBy(ElementType_SoundArchiveFile_StringBlock)->size; } + +u32 SoundArchiveFile::FileHeader::GetInfoBlockSize() const { + return GetReferenceBy(ElementType_SoundArchiveFile_InfoBlock)->size; +} } // namespace nn::atk::detail \ No newline at end of file From 6a6748cbb27ce6ed66bba805949eaf884de718f2 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 10:54:53 -0400 Subject: [PATCH 368/785] atk: Match `SoundArchiveFile::FileHeader::GetFileBlockSize` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index ae01a403..3994e694 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -17,4 +17,8 @@ u32 SoundArchiveFile::FileHeader::GetStringBlockSize() const { u32 SoundArchiveFile::FileHeader::GetInfoBlockSize() const { return GetReferenceBy(ElementType_SoundArchiveFile_InfoBlock)->size; } + +u32 SoundArchiveFile::FileHeader::GetFileBlockSize() const { + return GetReferenceBy(ElementType_SoundArchiveFile_FileBlock)->size; +} } // namespace nn::atk::detail \ No newline at end of file From 0ebb0209f6a4072461ff4af0fde031e5b3c4aef3 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 10:55:41 -0400 Subject: [PATCH 369/785] atk: Match `SoundArchiveFile::FileHeader::GetStringBlockOffset` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 3994e694..7665edc1 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -21,4 +21,8 @@ u32 SoundArchiveFile::FileHeader::GetInfoBlockSize() const { u32 SoundArchiveFile::FileHeader::GetFileBlockSize() const { return GetReferenceBy(ElementType_SoundArchiveFile_FileBlock)->size; } + +int SoundArchiveFile::FileHeader::GetStringBlockOffset() const { + return GetReferenceBy(ElementType_SoundArchiveFile_StringBlock)->offset; +} } // namespace nn::atk::detail \ No newline at end of file From 2b96e3cd17b2c53df4c4fbb728d9656f46fa3c46 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 10:56:11 -0400 Subject: [PATCH 370/785] atk: Match `SoundArchiveFile::FileHeader::GetInfoBlockOffset` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 7665edc1..3038fbda 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -25,4 +25,8 @@ u32 SoundArchiveFile::FileHeader::GetFileBlockSize() const { int SoundArchiveFile::FileHeader::GetStringBlockOffset() const { return GetReferenceBy(ElementType_SoundArchiveFile_StringBlock)->offset; } + +int SoundArchiveFile::FileHeader::GetInfoBlockOffset() const { + return GetReferenceBy(ElementType_SoundArchiveFile_InfoBlock)->offset; +} } // namespace nn::atk::detail \ No newline at end of file From d87701fbf9c003f3da6c57e5a092f7e39867b771 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 10:56:32 -0400 Subject: [PATCH 371/785] atk: Match `SoundArchiveFile::FileHeader::GetFileBlockOffset` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 3038fbda..390a3bdc 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -29,4 +29,8 @@ int SoundArchiveFile::FileHeader::GetStringBlockOffset() const { int SoundArchiveFile::FileHeader::GetInfoBlockOffset() const { return GetReferenceBy(ElementType_SoundArchiveFile_InfoBlock)->offset; } + +int SoundArchiveFile::FileHeader::GetFileBlockOffset() const { + return GetReferenceBy(ElementType_SoundArchiveFile_FileBlock)->offset; +} } // namespace nn::atk::detail \ No newline at end of file From c31793e4fb457b2828cadbedfd5f282c48b2ad21 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 11:04:41 -0400 Subject: [PATCH 372/785] atk: Match `SoundArchiveFile::StringBlockBody::GetSection` --- include/nn/atk/atk_SoundArchiveFile.h | 2 +- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_SoundArchiveFile.h b/include/nn/atk/atk_SoundArchiveFile.h index b1bd630f..f2ed3ee1 100644 --- a/include/nn/atk/atk_SoundArchiveFile.h +++ b/include/nn/atk/atk_SoundArchiveFile.h @@ -33,7 +33,7 @@ class SoundArchiveFile { enum Sections { Sections_StringTable = 0, Sections_PatriciaTree = 1, - Sections_Max = Sections_PatriciaTree, + Sections_Max = 1, }; Util::Reference toSection[1]; diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 390a3bdc..dcc47e7f 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -33,4 +33,11 @@ int SoundArchiveFile::FileHeader::GetInfoBlockOffset() const { int SoundArchiveFile::FileHeader::GetFileBlockOffset() const { return GetReferenceBy(ElementType_SoundArchiveFile_FileBlock)->offset; } + +const void* SoundArchiveFile::StringBlockBody::GetSection(Sections section) const { + if (section > Sections_Max) + return nullptr; + + return util::ConstBytePtr(this, toSection[section].offset).Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 3974e9be33656eb497595a552323eaafb61d12d5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 11:09:54 -0400 Subject: [PATCH 373/785] atk: Match `SoundArchiveFile::StringBlockBody::GetString` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index dcc47e7f..ba1fedaf 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -40,4 +40,15 @@ const void* SoundArchiveFile::StringBlockBody::GetSection(Sections section) cons return util::ConstBytePtr(this, toSection[section].offset).Get(); } + +const char* SoundArchiveFile::StringBlockBody::GetString(SoundArchive::StringId stringId) const { + if (stringId == SoundArchive::InvalidId) + return nullptr; + + const StringTable* table {GetStringTable()}; + if (table == nullptr) + return nullptr; + + return table->GetString(stringId); +} } // namespace nn::atk::detail \ No newline at end of file From 147380a33b826a448130e29ea41c0d805170bf60 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 11:35:47 -0400 Subject: [PATCH 374/785] atk: Match `SoundArchiveFile::PatriciaTree::GetNodeDataBy` Using implementation from [TuneBloom](https://github.com/stupidestmodder/TuneBloom/blob/master/TuneBloom/include/snd/snd_SoundArchiveFile.h#L191) --- include/nn/atk/atk_SoundArchiveFile.h | 7 +++-- .../atk/detail/atk_SoundArchiveFile.cpp | 26 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveFile.h b/include/nn/atk/atk_SoundArchiveFile.h index f2ed3ee1..63ce83c3 100644 --- a/include/nn/atk/atk_SoundArchiveFile.h +++ b/include/nn/atk/atk_SoundArchiveFile.h @@ -58,7 +58,10 @@ class SoundArchiveFile { } const PatriciaTree* GetPatriciaTree(Sections section) const { - // TODO + if (section > Sections_Max) + return nullptr; + + return util::ConstBytePtr(GetSection(section)).Get(); } u32 GetItemIdImpl(Sections section, const char* str) const; @@ -85,7 +88,7 @@ class SoundArchiveFile { u32 rootIdx; Util::Table nodeTable; - const NodeData* GetNodeDataBy(const char* str, size_t len); + const NodeData* GetNodeDataBy(const char* str, size_t len) const; void* operator[](int idx) const { // TODO diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index ba1fedaf..2188d65d 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -1,5 +1,7 @@ #include +#include + namespace nn::atk::detail { const Util::ReferenceWithSize* SoundArchiveFile::FileHeader::GetReferenceBy(u16 typeId) const { for (int i {0}; i < BlockCount; ++i) { @@ -51,4 +53,28 @@ const char* SoundArchiveFile::StringBlockBody::GetString(SoundArchive::StringId return table->GetString(stringId); } + +const SoundArchiveFile::PatriciaTree::NodeData* SoundArchiveFile::PatriciaTree::GetNodeDataBy(const char* str, size_t len) const { + if (rootIdx >= nodeTable.count) + return nullptr; + + const Node* node = &nodeTable.item[rootIdx]; + if (len == 0) + len = strlen(str); + + while ((node->flags & Node::FlagLeaf) == 0) { + const int pos = node->bit >> 3; + const int bit = node->bit & 7; + u32 nodeIdx; + + if (pos < static_cast(len) && str[pos] & (1 << (7 - bit))) + nodeIdx = node->rightIdx; + else + nodeIdx = node->leftIdx; + + node = &nodeTable.item[nodeIdx]; + } + + return &node->nodeData; +} } // namespace nn::atk::detail \ No newline at end of file From 330edc4fc0e6dea3783d2cd783a37a9d22a8868b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 11:48:08 -0400 Subject: [PATCH 375/785] atk: Match `SoundArchiveFile::StringBlockBody::GetItemIdImpl` --- include/nn/atk/atk_SoundArchiveFile.h | 2 +- .../atk/detail/atk_SoundArchiveFile.cpp | 20 ++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveFile.h b/include/nn/atk/atk_SoundArchiveFile.h index 63ce83c3..57e087e1 100644 --- a/include/nn/atk/atk_SoundArchiveFile.h +++ b/include/nn/atk/atk_SoundArchiveFile.h @@ -88,7 +88,7 @@ class SoundArchiveFile { u32 rootIdx; Util::Table nodeTable; - const NodeData* GetNodeDataBy(const char* str, size_t len) const; + const NodeData* GetNodeDataBy(const char* str, size_t len = 0) const; void* operator[](int idx) const { // TODO diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 2188d65d..17861c3d 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -54,13 +54,31 @@ const char* SoundArchiveFile::StringBlockBody::GetString(SoundArchive::StringId return table->GetString(stringId); } +void SoundArchiveFile::StringBlockBody::DumpTree() const { + // TODO: Empty only in release builds +} + +u32 SoundArchiveFile::StringBlockBody::GetItemIdImpl(Sections section, const char* str) const { + const PatriciaTree* tree {GetPatriciaTree(section)}; + const PatriciaTree::NodeData* nodeData {tree->GetNodeDataBy(str)}; + + if (nodeData == nullptr) + return SoundArchive::InvalidId; + + const char* nodeDataStr {GetString(nodeData->stringId)}; + if (std::strcmp(str, nodeDataStr) != 0) + return SoundArchive::InvalidId; + + return nodeData->itemId; +} + const SoundArchiveFile::PatriciaTree::NodeData* SoundArchiveFile::PatriciaTree::GetNodeDataBy(const char* str, size_t len) const { if (rootIdx >= nodeTable.count) return nullptr; const Node* node = &nodeTable.item[rootIdx]; if (len == 0) - len = strlen(str); + len = std::strlen(str); while ((node->flags & Node::FlagLeaf) == 0) { const int pos = node->bit >> 3; From 9dfa7bc578365c5409c4bf69bd1716da55e40ad4 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 12:32:59 -0400 Subject: [PATCH 376/785] atk: Match `SoundArchiveFile::InfoBlockBody::GetSoundInfoReferenceTable` --- include/nn/atk/atk_SoundArchiveFile.h | 1 - src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_SoundArchiveFile.h b/include/nn/atk/atk_SoundArchiveFile.h index 57e087e1..20f705f9 100644 --- a/include/nn/atk/atk_SoundArchiveFile.h +++ b/include/nn/atk/atk_SoundArchiveFile.h @@ -160,7 +160,6 @@ class SoundArchiveFile { const GroupInfo* GetGroupInfo(SoundArchive::ItemId itemId) const; const WaveArchiveInfo* GetWaveArchiveInfo(SoundArchive::ItemId itemId) const; const FileInfo* GetFileInfo(SoundArchive::FileId itemId) const; - const SoundArchivePlayerInfo* GetSoundArchivePlayerInfo() const; SoundArchive::FileId GetItemFileId(SoundArchive::ItemId id) const; diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 17861c3d..e9545a66 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -95,4 +95,9 @@ const SoundArchiveFile::PatriciaTree::NodeData* SoundArchiveFile::PatriciaTree:: return &node->nodeData; } + +const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetSoundInfoReferenceTable() const { + return *util::ConstBytePtr(this, toSoundInfoReferenceTable.offset) + .Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 154b2b5252084290f7812af78aab6e6d32d82753 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 12:33:40 -0400 Subject: [PATCH 377/785] atk: Match `SoundArchiveFile::InfoBlockBody::GetBankInfoReferenceTable` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index e9545a66..1a6b45ad 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -100,4 +100,9 @@ const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetSoundInfoReferen return *util::ConstBytePtr(this, toSoundInfoReferenceTable.offset) .Get(); } + +const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetBankInfoReferenceTable() const { + return *util::ConstBytePtr(this, toBankInfoReferenceTable.offset) + .Get(); +} } // namespace nn::atk::detail \ No newline at end of file From dfd15e0e38ffff284005c5e52e3213f41c3c1a97 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 12:34:11 -0400 Subject: [PATCH 378/785] atk: Match `SoundArchiveFile::InfoBlockBody::GetPlayerInfoReferenceTable` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 1a6b45ad..1ddfb17c 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -105,4 +105,9 @@ const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetBankInfoReferenc return *util::ConstBytePtr(this, toBankInfoReferenceTable.offset) .Get(); } + +const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetPlayerInfoReferenceTable() const { + return *util::ConstBytePtr(this, toPlayerInfoReferenceTable.offset) + .Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 9d4dde39416cadd5719061613d7d9939c505a5e7 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 12:34:34 -0400 Subject: [PATCH 379/785] atk: Match `SoundArchiveFile::InfoBlockBody::GetSoundGroupInfoReferenceTable` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 1ddfb17c..6d751ec4 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -110,4 +110,9 @@ const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetPlayerInfoRefere return *util::ConstBytePtr(this, toPlayerInfoReferenceTable.offset) .Get(); } + +const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetSoundGroupInfoReferenceTable() const { + return *util::ConstBytePtr(this, toSoundGroupInfoReferenceTable.offset) + .Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 39672f28c3617943136072e8b261eb4f9b1a2f83 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 12:36:42 -0400 Subject: [PATCH 380/785] atk: Match `SoundArchiveFile::InfoBlockBody::GetWaveArchiveInfoReferenceTable` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 6d751ec4..2e3aea83 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -115,4 +115,9 @@ const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetSoundGroupInfoRe return *util::ConstBytePtr(this, toSoundGroupInfoReferenceTable.offset) .Get(); } + +const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetWaveArchiveInfoReferenceTable() const { + return *util::ConstBytePtr(this, toWaveArchiveInfoReferenceTable.offset) + .Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 0812defbe464f6e3644890e2ea3f1584c2d50b37 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 12:37:59 -0400 Subject: [PATCH 381/785] atk: Match `SoundArchiveFile::InfoBlockBody::GetGroupInfoReferenceTable` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 2e3aea83..85c3a570 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -120,4 +120,9 @@ const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetWaveArchiveInfoR return *util::ConstBytePtr(this, toWaveArchiveInfoReferenceTable.offset) .Get(); } + +const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetGroupInfoReferenceTable() const { + return *util::ConstBytePtr(this, toGroupInfoReferenceTable.offset) + .Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 0ba7c2bec706abf16f3f6b25217b2a36aea64ada Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 12:38:19 -0400 Subject: [PATCH 382/785] atk: Match `SoundArchiveFile::InfoBlockBody::GetFileInfoReferenceTable` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 85c3a570..2c066cfe 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -125,4 +125,9 @@ const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetGroupInfoReferen return *util::ConstBytePtr(this, toGroupInfoReferenceTable.offset) .Get(); } + +const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetFileInfoReferenceTable() const { + return *util::ConstBytePtr(this, toFileInfoReferenceTable.offset) + .Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 6317dc018f327a9858d8d5171bbf6e83b19a0a7f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 13:03:25 -0400 Subject: [PATCH 383/785] atk: Match `SoundArchiveFile::InfoBlockBody::GetSoundInfo` --- include/nn/atk/atk_SoundArchiveFile.h | 14 +++++++------- .../atk/detail/atk_SoundArchiveFile.cpp | 13 +++++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveFile.h b/include/nn/atk/atk_SoundArchiveFile.h index 20f705f9..a29e003b 100644 --- a/include/nn/atk/atk_SoundArchiveFile.h +++ b/include/nn/atk/atk_SoundArchiveFile.h @@ -145,13 +145,13 @@ class SoundArchiveFile { Util::Reference toFileInfoReferenceTable; Util::Reference toSoundArchivePlayerInfo; - u32 GetSoundCount() const; - u32 GetBankCount() const; - u32 GetPlayerCount() const; - u32 GetSoundGroupCount() const; - u32 GetGroupCount() const; - u32 GetWaveArchiveCount() const; - u32 GetFileCount() const; + u32 GetSoundCount() const { return GetSoundInfoReferenceTable().count; } + u32 GetBankCount() const { return GetBankInfoReferenceTable().count; } + u32 GetPlayerCount() const { return GetPlayerInfoReferenceTable().count; } + u32 GetSoundGroupCount() const { return GetSoundGroupInfoReferenceTable().count; } + u32 GetGroupCount() const { return GetGroupInfoReferenceTable().count; } + u32 GetWaveArchiveCount() const { return GetWaveArchiveInfoReferenceTable().count; } + u32 GetFileCount() const { return GetFileInfoReferenceTable().count; } const SoundInfo* GetSoundInfo(SoundArchive::ItemId itemId) const; const BankInfo* GetBankInfo(SoundArchive::ItemId itemId) const; diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 2c066cfe..53b1323d 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -96,6 +96,19 @@ const SoundArchiveFile::PatriciaTree::NodeData* SoundArchiveFile::PatriciaTree:: return &node->nodeData; } +const SoundArchiveFile::SoundInfo* SoundArchiveFile::InfoBlockBody::GetSoundInfo(SoundArchive::ItemId itemId) const { + if (Util::GetItemType(itemId) != ItemType_Sound) + return nullptr; + + u32 index {Util::GetItemIndex(itemId)}; + const Util::ReferenceTable& table {GetSoundInfoReferenceTable()}; + + if (index >= table.count) + return nullptr; + + return util::ConstBytePtr(table.GetReferedItem(index)).Get(); +} + const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetSoundInfoReferenceTable() const { return *util::ConstBytePtr(this, toSoundInfoReferenceTable.offset) .Get(); From f4281f7f6838ac9fd913cafea703a3a33bf2aead Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 13:04:56 -0400 Subject: [PATCH 384/785] atk: Match `SoundArchiveFile::InfoBlockBody::GetBankInfo` --- .../atk/detail/atk_SoundArchiveFile.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 53b1323d..67a4da47 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -109,6 +109,19 @@ const SoundArchiveFile::SoundInfo* SoundArchiveFile::InfoBlockBody::GetSoundInfo return util::ConstBytePtr(table.GetReferedItem(index)).Get(); } +const SoundArchiveFile::BankInfo* SoundArchiveFile::InfoBlockBody::GetBankInfo(SoundArchive::ItemId itemId) const { + if (Util::GetItemType(itemId) != ItemType_Bank) + return nullptr; + + u32 index {Util::GetItemIndex(itemId)}; + const Util::ReferenceTable& table {GetBankInfoReferenceTable()}; + + if (index >= table.count) + return nullptr; + + return util::ConstBytePtr(table.GetReferedItem(index)).Get(); +} + const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetSoundInfoReferenceTable() const { return *util::ConstBytePtr(this, toSoundInfoReferenceTable.offset) .Get(); From 94943dffd102ab4a863c511cc5ffbeeed0e955f5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 13:05:37 -0400 Subject: [PATCH 385/785] atk: Match `SoundArchiveFile::InfoBlockBody::GetPlayerInfo` --- .../atk/detail/atk_SoundArchiveFile.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 67a4da47..300738d4 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -122,6 +122,19 @@ const SoundArchiveFile::BankInfo* SoundArchiveFile::InfoBlockBody::GetBankInfo(S return util::ConstBytePtr(table.GetReferedItem(index)).Get(); } +const SoundArchiveFile::PlayerInfo* SoundArchiveFile::InfoBlockBody::GetPlayerInfo(SoundArchive::ItemId itemId) const { + if (Util::GetItemType(itemId) != ItemType_Player) + return nullptr; + + u32 index {Util::GetItemIndex(itemId)}; + const Util::ReferenceTable& table {GetPlayerInfoReferenceTable()}; + + if (index >= table.count) + return nullptr; + + return util::ConstBytePtr(table.GetReferedItem(index)).Get(); +} + const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetSoundInfoReferenceTable() const { return *util::ConstBytePtr(this, toSoundInfoReferenceTable.offset) .Get(); From 30ea1e91c566024a9ea31d74a99c7ce85c7b0cce Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 13:06:11 -0400 Subject: [PATCH 386/785] atk: Match `SoundArchiveFile::InfoBlockBody::GetSoundGroupInfo` --- .../atk/detail/atk_SoundArchiveFile.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 300738d4..c4bb29c6 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -1,6 +1,7 @@ #include #include +#include "nn/atk/atk_ItemType.h" namespace nn::atk::detail { const Util::ReferenceWithSize* SoundArchiveFile::FileHeader::GetReferenceBy(u16 typeId) const { @@ -135,6 +136,19 @@ const SoundArchiveFile::PlayerInfo* SoundArchiveFile::InfoBlockBody::GetPlayerIn return util::ConstBytePtr(table.GetReferedItem(index)).Get(); } +const SoundArchiveFile::SoundGroupInfo* SoundArchiveFile::InfoBlockBody::GetSoundGroupInfo(SoundArchive::ItemId itemId) const { + if (Util::GetItemType(itemId) != ItemType_SoundGroup) + return nullptr; + + u32 index {Util::GetItemIndex(itemId)}; + const Util::ReferenceTable& table {GetSoundGroupInfoReferenceTable()}; + + if (index >= table.count) + return nullptr; + + return util::ConstBytePtr(table.GetReferedItem(index)).Get(); +} + const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetSoundInfoReferenceTable() const { return *util::ConstBytePtr(this, toSoundInfoReferenceTable.offset) .Get(); From ec2c69ef6c5f960e356ec124099ed56c8c35198a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 13:08:55 -0400 Subject: [PATCH 387/785] atk: Match `SoundArchiveFile::InfoBlockBody::GetGroupInfo` --- include/nn/atk/atk_Util.h | 24 +++++++++---------- .../atk/detail/atk_SoundArchiveFile.cpp | 13 ++++++++++ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index f7eb28e2..028d07e5 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -88,17 +88,17 @@ class Util { struct ReferenceTable : Table { const void* GetReferedItem(u32 index) const { - if (count > index) - return util::ConstBytePtr(this, item[index].offset).Get(); - - return nullptr; + if (count <= index) + return nullptr; + + return util::ConstBytePtr(this, item[index].offset).Get(); } const void* GetReferedItem(u32 index, u16 typeId) const { - if (count > index && item[index].typeId == typeId) - return util::ConstBytePtr(this,item[index].offset).Get(); - - return nullptr; + if (count <= index || item[index].typeId != typeId) + return nullptr; + + return util::ConstBytePtr(this,item[index].offset).Get(); } const void* FindReferedItemBy(u16 typeId) const; @@ -106,10 +106,10 @@ class Util { struct ReferenceWithSizeTable : Table { const void* GetReferedItem(u32 index) const { - if (count > index) - return util::ConstBytePtr(this, item[index].offset).Get(); - - return nullptr; + if (count <= index) + return nullptr; + + return util::ConstBytePtr(this, item[index].offset).Get(); } const void* GetReferedItemBy(u16 typeId) const; diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index c4bb29c6..5a90d006 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -149,6 +149,19 @@ const SoundArchiveFile::SoundGroupInfo* SoundArchiveFile::InfoBlockBody::GetSoun return util::ConstBytePtr(table.GetReferedItem(index)).Get(); } +const SoundArchiveFile::GroupInfo* SoundArchiveFile::InfoBlockBody::GetGroupInfo(SoundArchive::ItemId itemId) const { + if (Util::GetItemType(itemId) != ItemType_Group) + return nullptr; + + u32 index {Util::GetItemIndex(itemId)}; + const Util::ReferenceTable& table {GetGroupInfoReferenceTable()}; + + if (index >= table.count) + return nullptr; + + return util::ConstBytePtr(table.GetReferedItem(index)).Get(); +} + const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetSoundInfoReferenceTable() const { return *util::ConstBytePtr(this, toSoundInfoReferenceTable.offset) .Get(); From e60030ad1958e5d086eaa3822f465f3924ff133f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 13:10:05 -0400 Subject: [PATCH 388/785] atk: Match `SoundArchiveFile::InfoBlockBody::GetWaveArchiveInfo` --- .../atk/detail/atk_SoundArchiveFile.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 5a90d006..1a838ca7 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -162,6 +162,19 @@ const SoundArchiveFile::GroupInfo* SoundArchiveFile::InfoBlockBody::GetGroupInfo return util::ConstBytePtr(table.GetReferedItem(index)).Get(); } +const SoundArchiveFile::WaveArchiveInfo* SoundArchiveFile::InfoBlockBody::GetWaveArchiveInfo(SoundArchive::ItemId itemId) const { + if (Util::GetItemType(itemId) != ItemType_WaveArchive) + return nullptr; + + u32 index {Util::GetItemIndex(itemId)}; + const Util::ReferenceTable& table {GetWaveArchiveInfoReferenceTable()}; + + if (index >= table.count) + return nullptr; + + return util::ConstBytePtr(table.GetReferedItem(index)).Get(); +} + const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetSoundInfoReferenceTable() const { return *util::ConstBytePtr(this, toSoundInfoReferenceTable.offset) .Get(); From 863f987a6097e02940619b1ddc464d580a2593d3 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 13:12:12 -0400 Subject: [PATCH 389/785] atk: Match `SoundArchiveFile::InfoBlockBody::GetFileInfo` --- include/nn/atk/atk_SoundArchiveFile.h | 1 + src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/include/nn/atk/atk_SoundArchiveFile.h b/include/nn/atk/atk_SoundArchiveFile.h index a29e003b..db687bf9 100644 --- a/include/nn/atk/atk_SoundArchiveFile.h +++ b/include/nn/atk/atk_SoundArchiveFile.h @@ -160,6 +160,7 @@ class SoundArchiveFile { const GroupInfo* GetGroupInfo(SoundArchive::ItemId itemId) const; const WaveArchiveInfo* GetWaveArchiveInfo(SoundArchive::ItemId itemId) const; const FileInfo* GetFileInfo(SoundArchive::FileId itemId) const; + const SoundArchivePlayerInfo* GetSoundArchivePlayerInfo() const; SoundArchive::FileId GetItemFileId(SoundArchive::ItemId id) const; diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 1a838ca7..916fb41e 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -175,6 +175,16 @@ const SoundArchiveFile::WaveArchiveInfo* SoundArchiveFile::InfoBlockBody::GetWav return util::ConstBytePtr(table.GetReferedItem(index)).Get(); } +const SoundArchiveFile::FileInfo* SoundArchiveFile::InfoBlockBody::GetFileInfo(SoundArchive::FileId itemId) const { + u32 index {Util::GetItemIndex(itemId)}; + const Util::ReferenceTable& table {GetFileInfoReferenceTable()}; + + if (index >= table.count) + return nullptr; + + return util::ConstBytePtr(table.GetReferedItem(index)).Get(); +} + const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetSoundInfoReferenceTable() const { return *util::ConstBytePtr(this, toSoundInfoReferenceTable.offset) .Get(); From db24aa861d66389a5d859109dc456cd15070d7ac Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 13:13:44 -0400 Subject: [PATCH 390/785] atk: Match `SoundArchiveFile::InfoBlockBody::GetSoundArchivePlayerInfo` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 916fb41e..7ac985a6 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -185,6 +185,11 @@ const SoundArchiveFile::FileInfo* SoundArchiveFile::InfoBlockBody::GetFileInfo(S return util::ConstBytePtr(table.GetReferedItem(index)).Get(); } +const SoundArchiveFile::SoundArchivePlayerInfo* SoundArchiveFile::InfoBlockBody::GetSoundArchivePlayerInfo() const { + return util::ConstBytePtr(this, toSoundArchivePlayerInfo.offset) + .Get(); +} + const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetSoundInfoReferenceTable() const { return *util::ConstBytePtr(this, toSoundInfoReferenceTable.offset) .Get(); From 5bafe83c8d2a6d1e7516fec3469194d148b470d6 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 13:31:08 -0400 Subject: [PATCH 391/785] atk: Match `SoundArchiveFile::InfoBlockBody::GetItemFileId` --- .../atk/detail/atk_SoundArchiveFile.cpp | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 7ac985a6..4a0954f6 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -190,6 +190,51 @@ const SoundArchiveFile::SoundArchivePlayerInfo* SoundArchiveFile::InfoBlockBody: .Get(); } +SoundArchive::FileId SoundArchiveFile::InfoBlockBody::GetItemFileId(SoundArchive::ItemId id) const { + SoundArchive::FileId fileId {SoundArchive::InvalidId}; + + switch (Util::GetItemType(id)) { + case ItemType_Sound: { + const SoundInfo* info {GetSoundInfo(id)}; + if (info != nullptr) + fileId = info->fileId; + break; + } + case ItemType_Bank: { + const BankInfo* info {GetBankInfo(id)}; + if (info != nullptr) + fileId = info->fileId; + break; + } + case ItemType_WaveArchive: { + const WaveArchiveInfo* info {GetWaveArchiveInfo(id)}; + if (info != nullptr) + fileId = info->fileId; + break; + } + case ItemType_Group: { + const GroupInfo* info {GetGroupInfo(id)}; + if (info != nullptr) + fileId = info->fileId; + break; + } + case ItemType_SoundGroup: { + const SoundGroupInfo* info {GetSoundGroupInfo(id)}; + if (info != nullptr) { + SoundArchive::ItemId soundId {info->startId}; + const SoundInfo* soundInfo {GetSoundInfo(soundId)}; + if (soundInfo != nullptr) + fileId = soundInfo->fileId; + } + break; + } + case ItemType_Player: + break; + } + + return fileId; +} + const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetSoundInfoReferenceTable() const { return *util::ConstBytePtr(this, toSoundInfoReferenceTable.offset) .Get(); From eeae77d3934a3d7ab6e674717b7f351ed521847d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 14:24:12 -0400 Subject: [PATCH 392/785] atk: Match `SoundArchiveFile::SoundInfo::GetSoundType` --- .../atk/detail/atk_SoundArchiveFile.cpp | 86 ++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 4a0954f6..67848015 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -1,9 +1,77 @@ #include #include -#include "nn/atk/atk_ItemType.h" namespace nn::atk::detail { +namespace { +const u32 DefaultStringId {0xffffffff}; // 26 +const PanMode DefaultPanMode {PanMode_Dual}; +const PanCurve DefaultPanCurve {PanCurve_Sqrt}; +const SinglePlayType DefaultSinglePlayType {SinglePlayType_None}; +const u16 DefaultSinglePlayEffectiveDuration {0xffff}; +const u8 DefaultPlayerPriority {64}; // 31 +const u8 DefaultChannelPriority {64}; +const u8 DefaultActorPlayerId {0}; // 33 +const u8 DefaultIsReleasePriorityFix {0}; +const bool DefaultIsFrontBypass {false}; +const u32 DefaultUserParam {0xffffffff}; // 36 +const u32 DefaultSeqStartOffset {0}; +const u32 DefaultWarcWaveCount {0}; +const u32 DefaultPlayerHeapSize {0}; // 39 + +enum SoundInfoBitFlag { // 44 + SoundInfoBitFlag_StringId = 0, + SoundInfoBitFlag_PanParam = 1, + SoundInfoBitFlag_PlayerParam = 2, + SoundInfoBitFlag_SinglePlayParam = 3, + + SoundInfoBitFlag_OffsetTo3dParam = 8, + SoundInfoBitFlag_OffsetToSendParam = 9, + SoundInfoBitFlag_OffsetToModParam = 10, + SoundInfoBitFlag_OffsetToRvlParam = 16, + SoundInfoBitFlag_OffsetToCtrParam = 17, + SoundInfoBitFlag_OffsetToCafeParam = 18, + + SoundInfoBitFlag_UserParam3 = 28, + SoundInfoBitFlag_UserParam2 = 29, + SoundInfoBitFlag_UserParam1 = 30, + SoundInfoBitFlag_UserParam = 31, +}; + +const int UserParamIndex[4] {}; // 65 + +enum WaveSoundInfoBitFlag { // 79 + WaveSoundInfoBitFlag_Priority = 0, +}; + +enum SequenceSoundInfoBitFlag { // 84 + SequenceSoundInfoBitFlag_StartOffset = 0, + SequenceSoundInfoBitFlag_Priority = 1, +}; + +enum BankInfoBitFlag { // 90 + BankInfoBitFlag_StringId = 0, +}; + +enum PlayerInfoBitFlag { // 95 + PlayerInfoBitFlag_StringId = 0, + PlayerInfoBitFlag_HeapSize = 1, +}; + +enum SoundGroupInfoBitFlag { // 101 + SoundGroupInfoBitFlag_StringId = 0, +}; + +enum GroupInfoBitFlag { // 106 + GroupInfoBitFlag_StringId = 0, +}; + +enum WaveArchiveInfoBitFlag { // 111 + WaveArchiveInfoBitFlag_StringId = 0, + WaveArchiveInfoBitFlag_WaveCount = 1, +}; +} // anonymous namespace + const Util::ReferenceWithSize* SoundArchiveFile::FileHeader::GetReferenceBy(u16 typeId) const { for (int i {0}; i < BlockCount; ++i) { if (toBlocks[i].typeId == typeId) @@ -269,4 +337,20 @@ const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetFileInfoReferenc return *util::ConstBytePtr(this, toFileInfoReferenceTable.offset) .Get(); } + +SoundArchive::SoundType SoundArchiveFile::SoundInfo::GetSoundType() const { + switch (toDetailSoundInfo.typeId) { + case ElementType_SoundArchiveFile_SequenceSoundInfo: + return SoundArchive::SoundType_Sequence; + + case ElementType_SoundArchiveFile_StreamSoundInfo: + return SoundArchive::SoundType_Stream; + + case ElementType_SoundArchiveFile_WaveSoundInfo: + return SoundArchive::SoundType_Wave; + + default: + return SoundArchive::SoundType_Invalid; + } +} } // namespace nn::atk::detail \ No newline at end of file From dd65e1682ce0015f29f1986429f071158d2fb3b8 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 14:26:43 -0400 Subject: [PATCH 393/785] atk: Match `SoundArchiveFile::SoundInfo::GetStreamSoundInfo` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 67848015..19593579 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -1,6 +1,7 @@ #include #include +#include "nn/util/util_BytePtr.h" namespace nn::atk::detail { namespace { @@ -353,4 +354,8 @@ SoundArchive::SoundType SoundArchiveFile::SoundInfo::GetSoundType() const { return SoundArchive::SoundType_Invalid; } } + +const SoundArchiveFile::StreamSoundInfo& SoundArchiveFile::SoundInfo::GetStreamSoundInfo() const { + return *util::ConstBytePtr(this, toDetailSoundInfo.offset).Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 7f3226f41166dc937aa613e421f2a655eeefbb5f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 14:35:51 -0400 Subject: [PATCH 394/785] atk: Match `SoundArchiveFile::InfoBlockBody::GetItemPrefetchFileId` --- .../atk/detail/atk_SoundArchiveFile.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 19593579..60186bc0 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -304,6 +304,19 @@ SoundArchive::FileId SoundArchiveFile::InfoBlockBody::GetItemFileId(SoundArchive return fileId; } +SoundArchive::FileId SoundArchiveFile::InfoBlockBody::GetItemPrefetchFileId(SoundArchive::ItemId id) const { + SoundArchive::FileId fileId {SoundArchive::InvalidId}; + + const SoundInfo* info {GetSoundInfo(id)}; + + if (info != nullptr && info->GetSoundType() == SoundArchive::SoundType_Stream) { + const SoundArchiveFile::StreamSoundInfo& streamSoundInfo {info->GetStreamSoundInfo()}; + fileId = streamSoundInfo.prefetchFileId; + } + + return fileId; +} + const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetSoundInfoReferenceTable() const { return *util::ConstBytePtr(this, toSoundInfoReferenceTable.offset) .Get(); From be2ae910f47121acc91b230cf99dcef642866fa0 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 14:43:29 -0400 Subject: [PATCH 395/785] atk: Match `SoundArchiveFile::SoundInfo::GetStringId` --- .../atk/detail/atk_SoundArchiveFile.cpp | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 60186bc0..c0ae3388 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -304,6 +304,51 @@ SoundArchive::FileId SoundArchiveFile::InfoBlockBody::GetItemFileId(SoundArchive return fileId; } +SoundArchive::StringId SoundArchiveFile::InfoBlockBody::GetItemStringId(SoundArchive::ItemId id) const { + SoundArchive::StringId stringId {SoundArchive::InvalidId}; + + switch (Util::GetItemType(id)) { + case ItemType_Sound: { + const SoundInfo* info {GetSoundInfo(id)}; + if (info != nullptr) + stringId = info->GetStringId(); + break; + } + case ItemType_Bank: { + const BankInfo* info {GetBankInfo(id)}; + if (info != nullptr) + stringId = info->GetStringId(); + break; + } + case ItemType_WaveArchive: { + const WaveArchiveInfo* info {GetWaveArchiveInfo(id)}; + if (info != nullptr) + stringId = info->GetStringId(); + break; + } + case ItemType_Group: { + const GroupInfo* info {GetGroupInfo(id)}; + if (info != nullptr) + stringId = info->GetStringId(); + break; + } + case ItemType_SoundGroup: { + const SoundGroupInfo* info {GetSoundGroupInfo(id)}; + if (info != nullptr) { + SoundArchive::ItemId soundId {info->startId}; + const SoundInfo* soundInfo {GetSoundInfo(soundId)}; + if (soundInfo != nullptr) + stringId = soundInfo->GetStringId(); + } + break; + } + case ItemType_Player: + break; + } + + return stringId; +} + SoundArchive::FileId SoundArchiveFile::InfoBlockBody::GetItemPrefetchFileId(SoundArchive::ItemId id) const { SoundArchive::FileId fileId {SoundArchive::InvalidId}; @@ -371,4 +416,14 @@ SoundArchive::SoundType SoundArchiveFile::SoundInfo::GetSoundType() const { const SoundArchiveFile::StreamSoundInfo& SoundArchiveFile::SoundInfo::GetStreamSoundInfo() const { return *util::ConstBytePtr(this, toDetailSoundInfo.offset).Get(); } + +u32 SoundArchiveFile::SoundInfo::GetStringId() const { + u32 value; + bool result {optionParameter.GetValue(&value, 0)}; + + if (!result) + return DefaultStringId; + + return value; +} } // namespace nn::atk::detail \ No newline at end of file From bb11505a1f289921fcacd6f94c8102d49de108b3 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 14:45:22 -0400 Subject: [PATCH 396/785] atk: Match `SoundArchiveFile::BankInfo::GetStringId` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index c0ae3388..2f99bc12 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -426,4 +426,14 @@ u32 SoundArchiveFile::SoundInfo::GetStringId() const { return value; } + +u32 SoundArchiveFile::BankInfo::GetStringId() const { + u32 value; + bool result {optionParameter.GetValue(&value, 0)}; + + if (!result) + return DefaultStringId; + + return value; +} } // namespace nn::atk::detail \ No newline at end of file From aa2e22688f2ab409e02f570e9373f87e45469413 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 14:46:15 -0400 Subject: [PATCH 397/785] atk: Match `SoundArchiveFile::PlayerInfo::GetStringId` --- .../atk/detail/atk_SoundArchiveFile.cpp | 55 ++++--------------- 1 file changed, 10 insertions(+), 45 deletions(-) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 2f99bc12..1d027ce6 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -304,51 +304,6 @@ SoundArchive::FileId SoundArchiveFile::InfoBlockBody::GetItemFileId(SoundArchive return fileId; } -SoundArchive::StringId SoundArchiveFile::InfoBlockBody::GetItemStringId(SoundArchive::ItemId id) const { - SoundArchive::StringId stringId {SoundArchive::InvalidId}; - - switch (Util::GetItemType(id)) { - case ItemType_Sound: { - const SoundInfo* info {GetSoundInfo(id)}; - if (info != nullptr) - stringId = info->GetStringId(); - break; - } - case ItemType_Bank: { - const BankInfo* info {GetBankInfo(id)}; - if (info != nullptr) - stringId = info->GetStringId(); - break; - } - case ItemType_WaveArchive: { - const WaveArchiveInfo* info {GetWaveArchiveInfo(id)}; - if (info != nullptr) - stringId = info->GetStringId(); - break; - } - case ItemType_Group: { - const GroupInfo* info {GetGroupInfo(id)}; - if (info != nullptr) - stringId = info->GetStringId(); - break; - } - case ItemType_SoundGroup: { - const SoundGroupInfo* info {GetSoundGroupInfo(id)}; - if (info != nullptr) { - SoundArchive::ItemId soundId {info->startId}; - const SoundInfo* soundInfo {GetSoundInfo(soundId)}; - if (soundInfo != nullptr) - stringId = soundInfo->GetStringId(); - } - break; - } - case ItemType_Player: - break; - } - - return stringId; -} - SoundArchive::FileId SoundArchiveFile::InfoBlockBody::GetItemPrefetchFileId(SoundArchive::ItemId id) const { SoundArchive::FileId fileId {SoundArchive::InvalidId}; @@ -436,4 +391,14 @@ u32 SoundArchiveFile::BankInfo::GetStringId() const { return value; } + +u32 SoundArchiveFile::PlayerInfo::GetStringId() const { + u32 value; + bool result {optionParameter.GetValue(&value, 0)}; + + if (!result) + return DefaultStringId; + + return value; +} } // namespace nn::atk::detail \ No newline at end of file From a3cfe429beb1aa43195347df9a8ca32ae2e6a55b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 14:47:38 -0400 Subject: [PATCH 398/785] atk: Match `SoundArchiveFile::SoundGroupInfo::GetStringId` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 1d027ce6..b2fdd745 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -401,4 +401,14 @@ u32 SoundArchiveFile::PlayerInfo::GetStringId() const { return value; } + +u32 SoundArchiveFile::SoundGroupInfo::GetStringId() const { + u32 value; + bool result {optionParameter.GetValue(&value, 0)}; + + if (!result) + return DefaultStringId; + + return value; +} } // namespace nn::atk::detail \ No newline at end of file From f127c24e2c55425b13fdbfdc04ccae92bbd2f0d0 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 14:48:17 -0400 Subject: [PATCH 399/785] atk: Match `SoundArchiveFile::GroupInfo::GetStringId` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index b2fdd745..95c49656 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -411,4 +411,14 @@ u32 SoundArchiveFile::SoundGroupInfo::GetStringId() const { return value; } + +u32 SoundArchiveFile::GroupInfo::GetStringId() const { + u32 value; + bool result {optionParameter.GetValue(&value, 0)}; + + if (!result) + return DefaultStringId; + + return value; +} } // namespace nn::atk::detail \ No newline at end of file From b04dbac0ddd72793c39a4b2ce50cf9f37df29cc6 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 14:48:47 -0400 Subject: [PATCH 400/785] atk: Match `SoundArchiveFile::WaveArchiveInfo::GetStringId` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 95c49656..8cbb6926 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -421,4 +421,14 @@ u32 SoundArchiveFile::GroupInfo::GetStringId() const { return value; } + +u32 SoundArchiveFile::WaveArchiveInfo::GetStringId() const { + u32 value; + bool result {optionParameter.GetValue(&value, 0)}; + + if (!result) + return DefaultStringId; + + return value; +} } // namespace nn::atk::detail \ No newline at end of file From b30c9b3ea1e6797f5ad90961e5dee6ccfb412667 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 14:53:28 -0400 Subject: [PATCH 401/785] atk: Match `SoundArchiveFile::InfoBlockBody::GetItemStringId` --- .../atk/detail/atk_SoundArchiveFile.cpp | 48 ++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 8cbb6926..b3b397bd 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -304,6 +304,50 @@ SoundArchive::FileId SoundArchiveFile::InfoBlockBody::GetItemFileId(SoundArchive return fileId; } +SoundArchive::StringId SoundArchiveFile::InfoBlockBody::GetItemStringId(SoundArchive::ItemId id) const { + SoundArchive::StringId stringId {SoundArchive::InvalidId}; + + switch (Util::GetItemType(id)) { + case ItemType_Sound: { + const SoundInfo* info {GetSoundInfo(id)}; + if (info != nullptr) + stringId = info->GetStringId(); + break; + } + case ItemType_Bank: { + const BankInfo* info {GetBankInfo(id)}; + if (info != nullptr) + stringId = info->GetStringId(); + break; + } + case ItemType_WaveArchive: { + const WaveArchiveInfo* info {GetWaveArchiveInfo(id)}; + if (info != nullptr) + stringId = info->GetStringId(); + break; + } + case ItemType_Group: { + const GroupInfo* info {GetGroupInfo(id)}; + if (info != nullptr) + stringId = info->GetStringId(); + break; + } + case ItemType_SoundGroup: { + const SoundGroupInfo* info {GetSoundGroupInfo(id)}; + if (info != nullptr) + stringId = info->GetStringId(); + break; + } + case ItemType_Player: + const PlayerInfo* info {GetPlayerInfo(id)}; + if (info != nullptr) + stringId = info->GetStringId(); + break; + } + + return stringId; +} + SoundArchive::FileId SoundArchiveFile::InfoBlockBody::GetItemPrefetchFileId(SoundArchive::ItemId id) const { SoundArchive::FileId fileId {SoundArchive::InvalidId}; @@ -392,7 +436,7 @@ u32 SoundArchiveFile::BankInfo::GetStringId() const { return value; } -u32 SoundArchiveFile::PlayerInfo::GetStringId() const { +u32 SoundArchiveFile::WaveArchiveInfo::GetStringId() const { u32 value; bool result {optionParameter.GetValue(&value, 0)}; @@ -422,7 +466,7 @@ u32 SoundArchiveFile::GroupInfo::GetStringId() const { return value; } -u32 SoundArchiveFile::WaveArchiveInfo::GetStringId() const { +u32 SoundArchiveFile::PlayerInfo::GetStringId() const { u32 value; bool result {optionParameter.GetValue(&value, 0)}; From bfa7e8d6c9022b7e695a87e582cea5c2461cd180 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 14:54:42 -0400 Subject: [PATCH 402/785] atk: Match `SoundArchiveFile::SoundInfo::GetWaveSoundInfo` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index b3b397bd..782e133c 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -416,6 +416,10 @@ const SoundArchiveFile::StreamSoundInfo& SoundArchiveFile::SoundInfo::GetStreamS return *util::ConstBytePtr(this, toDetailSoundInfo.offset).Get(); } +const SoundArchiveFile::WaveSoundInfo& SoundArchiveFile::SoundInfo::GetWaveSoundInfo() const { + return *util::ConstBytePtr(this, toDetailSoundInfo.offset).Get(); +} + u32 SoundArchiveFile::SoundInfo::GetStringId() const { u32 value; bool result {optionParameter.GetValue(&value, 0)}; From 453a800a6c6c0aba11c038f9c096424df2e87eb8 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 14:55:06 -0400 Subject: [PATCH 403/785] atk: Match `SoundArchiveFile::SoundInfo::GetAdvancedWaveSoundInfo` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 782e133c..f3721d5d 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -420,6 +420,10 @@ const SoundArchiveFile::WaveSoundInfo& SoundArchiveFile::SoundInfo::GetWaveSound return *util::ConstBytePtr(this, toDetailSoundInfo.offset).Get(); } +const SoundArchiveFile::AdvancedWaveSoundInfo& SoundArchiveFile::SoundInfo::GetAdvancedWaveSoundInfo() const { + return *util::ConstBytePtr(this, toDetailSoundInfo.offset).Get(); +} + u32 SoundArchiveFile::SoundInfo::GetStringId() const { u32 value; bool result {optionParameter.GetValue(&value, 0)}; From 9e49508239bc9e82aa2857f05bb7ffc73e49d278 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 14:55:27 -0400 Subject: [PATCH 404/785] atk: Match `SoundArchiveFile::SoundInfo::GetSequenceSoundInfo` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index f3721d5d..dcde64f6 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -424,6 +424,10 @@ const SoundArchiveFile::AdvancedWaveSoundInfo& SoundArchiveFile::SoundInfo::GetA return *util::ConstBytePtr(this, toDetailSoundInfo.offset).Get(); } +const SoundArchiveFile::SequenceSoundInfo& SoundArchiveFile::SoundInfo::GetSequenceSoundInfo() const { + return *util::ConstBytePtr(this, toDetailSoundInfo.offset).Get(); +} + u32 SoundArchiveFile::SoundInfo::GetStringId() const { u32 value; bool result {optionParameter.GetValue(&value, 0)}; From 29ddeb15981a2281ad6032216035e0cd5c16dc30 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 15:02:05 -0400 Subject: [PATCH 405/785] atk: Match `SoundArchiveFile::SoundInfo::GetSound3DInfo` --- include/nn/atk/atk_SoundArchiveFile.h | 2 +- .../atk/detail/atk_SoundArchiveFile.cpp | 22 ++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveFile.h b/include/nn/atk/atk_SoundArchiveFile.h index db687bf9..040bbe25 100644 --- a/include/nn/atk/atk_SoundArchiveFile.h +++ b/include/nn/atk/atk_SoundArchiveFile.h @@ -203,7 +203,7 @@ class SoundArchiveFile { const WaveSoundInfo& GetWaveSoundInfo() const; const AdvancedWaveSoundInfo& GetAdvancedWaveSoundInfo() const; const SequenceSoundInfo& GetSequenceSoundInfo() const; - const Sound3DInfo& GetSound3DInfo() const; + const Sound3DInfo* GetSound3DInfo() const; u32 GetStringId() const; PanMode GetPanMode() const; diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index dcde64f6..5a22de3a 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -428,9 +428,19 @@ const SoundArchiveFile::SequenceSoundInfo& SoundArchiveFile::SoundInfo::GetSeque return *util::ConstBytePtr(this, toDetailSoundInfo.offset).Get(); } +const SoundArchiveFile::Sound3DInfo* SoundArchiveFile::SoundInfo::GetSound3DInfo() const { + u32 offset; + bool result {optionParameter.GetValue(&offset, SoundInfoBitFlag_OffsetTo3dParam)}; + + if (!result) + return nullptr; + + return util::ConstBytePtr(this, offset).Get(); +} + u32 SoundArchiveFile::SoundInfo::GetStringId() const { u32 value; - bool result {optionParameter.GetValue(&value, 0)}; + bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; if (!result) return DefaultStringId; @@ -440,7 +450,7 @@ u32 SoundArchiveFile::SoundInfo::GetStringId() const { u32 SoundArchiveFile::BankInfo::GetStringId() const { u32 value; - bool result {optionParameter.GetValue(&value, 0)}; + bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; if (!result) return DefaultStringId; @@ -450,7 +460,7 @@ u32 SoundArchiveFile::BankInfo::GetStringId() const { u32 SoundArchiveFile::WaveArchiveInfo::GetStringId() const { u32 value; - bool result {optionParameter.GetValue(&value, 0)}; + bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; if (!result) return DefaultStringId; @@ -460,7 +470,7 @@ u32 SoundArchiveFile::WaveArchiveInfo::GetStringId() const { u32 SoundArchiveFile::SoundGroupInfo::GetStringId() const { u32 value; - bool result {optionParameter.GetValue(&value, 0)}; + bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; if (!result) return DefaultStringId; @@ -470,7 +480,7 @@ u32 SoundArchiveFile::SoundGroupInfo::GetStringId() const { u32 SoundArchiveFile::GroupInfo::GetStringId() const { u32 value; - bool result {optionParameter.GetValue(&value, 0)}; + bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; if (!result) return DefaultStringId; @@ -480,7 +490,7 @@ u32 SoundArchiveFile::GroupInfo::GetStringId() const { u32 SoundArchiveFile::PlayerInfo::GetStringId() const { u32 value; - bool result {optionParameter.GetValue(&value, 0)}; + bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; if (!result) return DefaultStringId; From 73871b18d82c52fc59f92f893c33c926b1930697 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 15:09:56 -0400 Subject: [PATCH 406/785] atk: Match `SoundArchiveFile::SoundInfo::GetPanMode` --- .../atk/detail/atk_SoundArchiveFile.cpp | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 5a22de3a..867c1656 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -1,26 +1,25 @@ #include #include -#include "nn/util/util_BytePtr.h" namespace nn::atk::detail { namespace { -const u32 DefaultStringId {0xffffffff}; // 26 +const u32 DefaultStringId {0xffffffff}; const PanMode DefaultPanMode {PanMode_Dual}; const PanCurve DefaultPanCurve {PanCurve_Sqrt}; const SinglePlayType DefaultSinglePlayType {SinglePlayType_None}; const u16 DefaultSinglePlayEffectiveDuration {0xffff}; -const u8 DefaultPlayerPriority {64}; // 31 +const u8 DefaultPlayerPriority {64}; const u8 DefaultChannelPriority {64}; -const u8 DefaultActorPlayerId {0}; // 33 +const u8 DefaultActorPlayerId {0}; const u8 DefaultIsReleasePriorityFix {0}; const bool DefaultIsFrontBypass {false}; -const u32 DefaultUserParam {0xffffffff}; // 36 +const u32 DefaultUserParam {0xffffffff}; const u32 DefaultSeqStartOffset {0}; const u32 DefaultWarcWaveCount {0}; -const u32 DefaultPlayerHeapSize {0}; // 39 +const u32 DefaultPlayerHeapSize {0}; -enum SoundInfoBitFlag { // 44 +enum SoundInfoBitFlag { SoundInfoBitFlag_StringId = 0, SoundInfoBitFlag_PanParam = 1, SoundInfoBitFlag_PlayerParam = 2, @@ -39,35 +38,35 @@ enum SoundInfoBitFlag { // 44 SoundInfoBitFlag_UserParam = 31, }; -const int UserParamIndex[4] {}; // 65 +const int UserParamIndex[4] {}; -enum WaveSoundInfoBitFlag { // 79 +enum WaveSoundInfoBitFlag { WaveSoundInfoBitFlag_Priority = 0, }; -enum SequenceSoundInfoBitFlag { // 84 +enum SequenceSoundInfoBitFlag { SequenceSoundInfoBitFlag_StartOffset = 0, SequenceSoundInfoBitFlag_Priority = 1, }; -enum BankInfoBitFlag { // 90 +enum BankInfoBitFlag { BankInfoBitFlag_StringId = 0, }; -enum PlayerInfoBitFlag { // 95 +enum PlayerInfoBitFlag { PlayerInfoBitFlag_StringId = 0, PlayerInfoBitFlag_HeapSize = 1, }; -enum SoundGroupInfoBitFlag { // 101 +enum SoundGroupInfoBitFlag { SoundGroupInfoBitFlag_StringId = 0, }; -enum GroupInfoBitFlag { // 106 +enum GroupInfoBitFlag { GroupInfoBitFlag_StringId = 0, }; -enum WaveArchiveInfoBitFlag { // 111 +enum WaveArchiveInfoBitFlag { WaveArchiveInfoBitFlag_StringId = 0, WaveArchiveInfoBitFlag_WaveCount = 1, }; @@ -448,9 +447,19 @@ u32 SoundArchiveFile::SoundInfo::GetStringId() const { return value; } +PanMode SoundArchiveFile::SoundInfo::GetPanMode() const { + u32 value; + bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_PanParam)}; + + if (!result) + return DefaultPanMode; + + return static_cast(Util::DivideBy8bit(value, 0)); +} + u32 SoundArchiveFile::BankInfo::GetStringId() const { u32 value; - bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; + bool result {optionParameter.GetValue(&value, BankInfoBitFlag_StringId)}; if (!result) return DefaultStringId; @@ -480,7 +489,7 @@ u32 SoundArchiveFile::SoundGroupInfo::GetStringId() const { u32 SoundArchiveFile::GroupInfo::GetStringId() const { u32 value; - bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; + bool result {optionParameter.GetValue(&value, GroupInfoBitFlag_StringId)}; if (!result) return DefaultStringId; @@ -490,7 +499,7 @@ u32 SoundArchiveFile::GroupInfo::GetStringId() const { u32 SoundArchiveFile::PlayerInfo::GetStringId() const { u32 value; - bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; + bool result {optionParameter.GetValue(&value, PlayerInfoBitFlag_StringId)}; if (!result) return DefaultStringId; From 496edc3ac2218cfd9804a1610943290a416f1ac5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 15:10:08 -0400 Subject: [PATCH 407/785] atk: Match `SoundArchiveFile::SoundInfo::GetPanCurve` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 867c1656..9b6eab66 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -457,6 +457,16 @@ PanMode SoundArchiveFile::SoundInfo::GetPanMode() const { return static_cast(Util::DivideBy8bit(value, 0)); } +PanCurve SoundArchiveFile::SoundInfo::GetPanCurve() const { + u32 value; + bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_PanParam)}; + + if (!result) + return DefaultPanCurve; + + return static_cast(Util::DivideBy8bit(value, 1)); +} + u32 SoundArchiveFile::BankInfo::GetStringId() const { u32 value; bool result {optionParameter.GetValue(&value, BankInfoBitFlag_StringId)}; From a60dc0bdc877254d71c6fe627b9e65d77b27a84a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 15:12:21 -0400 Subject: [PATCH 408/785] atk: Match `SoundArchiveFile::SoundInfo::GetSinglePlayType` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 9b6eab66..c3f0fcf0 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -1,6 +1,7 @@ #include #include +#include "nn/atk/atk_Global.h" namespace nn::atk::detail { namespace { @@ -467,6 +468,16 @@ PanCurve SoundArchiveFile::SoundInfo::GetPanCurve() const { return static_cast(Util::DivideBy8bit(value, 1)); } +SinglePlayType SoundArchiveFile::SoundInfo::GetSinglePlayType() const { + u32 value; + bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_SinglePlayParam)}; + + if (!result) + return DefaultSinglePlayType; + + return static_cast(Util::DivideBy8bit(value, 0)); +} + u32 SoundArchiveFile::BankInfo::GetStringId() const { u32 value; bool result {optionParameter.GetValue(&value, BankInfoBitFlag_StringId)}; From c4c9ea45db95c21fd3c63d6d8aaed6b0b130d610 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 15:15:11 -0400 Subject: [PATCH 409/785] atk: Match `SoundArchiveFile::SoundInfo::GetSinglePlayEffectiveDuration` --- include/nn/atk/atk_Util.h | 2 +- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index 028d07e5..a82079d7 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -222,7 +222,7 @@ class Util { return static_cast(value >> (8 * index)); } - static u8 DivideBy16bit(u32 value, int index) { + static u16 DivideBy16bit(u32 value, int index) { return static_cast(value >> (16 * index)); } diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index c3f0fcf0..7cb6b8e6 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -478,6 +478,16 @@ SinglePlayType SoundArchiveFile::SoundInfo::GetSinglePlayType() const { return static_cast(Util::DivideBy8bit(value, 0)); } +u16 SoundArchiveFile::SoundInfo::GetSinglePlayEffectiveDuration() const { + u32 value; + bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_SinglePlayParam)}; + + if (!result) + return DefaultSinglePlayEffectiveDuration; + + return Util::DivideBy16bit(value, 1); +} + u32 SoundArchiveFile::BankInfo::GetStringId() const { u32 value; bool result {optionParameter.GetValue(&value, BankInfoBitFlag_StringId)}; From eb54e4a57a64f86e12ef010834ca5c97ec4b0a7a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 15:16:26 -0400 Subject: [PATCH 410/785] atk: Match `SoundArchiveFile::SoundInfo::GetPlayerPriority` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 7cb6b8e6..72a6436e 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -488,6 +488,16 @@ u16 SoundArchiveFile::SoundInfo::GetSinglePlayEffectiveDuration() const { return Util::DivideBy16bit(value, 1); } +u8 SoundArchiveFile::SoundInfo::GetPlayerPriority() const { + u32 value; + bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_PlayerParam)}; + + if (!result) + return DefaultPlayerPriority; + + return Util::DivideBy8bit(value, 0); +} + u32 SoundArchiveFile::BankInfo::GetStringId() const { u32 value; bool result {optionParameter.GetValue(&value, BankInfoBitFlag_StringId)}; From 0194fbd79cf9e74238e7ecd60bdf120c9cc2de08 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 15:16:52 -0400 Subject: [PATCH 411/785] atk: Match `SoundArchiveFile::SoundInfo::GetActorPlayerId` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 72a6436e..8c29d51a 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -498,6 +498,16 @@ u8 SoundArchiveFile::SoundInfo::GetPlayerPriority() const { return Util::DivideBy8bit(value, 0); } +u8 SoundArchiveFile::SoundInfo::GetActorPlayerId() const { + u32 value; + bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_PlayerParam)}; + + if (!result) + return DefaultActorPlayerId; + + return Util::DivideBy8bit(value, 1); +} + u32 SoundArchiveFile::BankInfo::GetStringId() const { u32 value; bool result {optionParameter.GetValue(&value, BankInfoBitFlag_StringId)}; From 9ea02712aa0ce2e9ac78560e7ecb2b61032a51e4 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 15:31:09 -0400 Subject: [PATCH 412/785] atk: Match `SoundArchiveFile::SoundInfo::GetUserParam` --- include/nn/atk/atk_Util.h | 2 +- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index a82079d7..b246b688 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -199,9 +199,9 @@ class Util { private: static const int BitNumberMax = 31; u32 GetTrueCount(u32 bitNumber) const { + bool ret {false}; int count {0}; - bool ret {false}; for (u32 i {0}; i <= bitNumber; ++i) { if ((bitFlag & (1 << i)) != 0) { ++count; diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 8c29d51a..097c8072 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -508,6 +508,16 @@ u8 SoundArchiveFile::SoundInfo::GetActorPlayerId() const { return Util::DivideBy8bit(value, 1); } +u32 SoundArchiveFile::SoundInfo::GetUserParam() const { + u32 value; + bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_UserParam)}; + + if (!result) + return DefaultUserParam; + + return value; +} + u32 SoundArchiveFile::BankInfo::GetStringId() const { u32 value; bool result {optionParameter.GetValue(&value, BankInfoBitFlag_StringId)}; From 1ba6b59c03a1de728b10c5082dde26fd694fa9c5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 15:42:54 -0400 Subject: [PATCH 413/785] atk: Match `SoundArchiveFile::SoundInfo::ReadUserParam` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 097c8072..1553f73f 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -39,7 +39,12 @@ enum SoundInfoBitFlag { SoundInfoBitFlag_UserParam = 31, }; -const int UserParamIndex[4] {}; +const int UserParamIndex[4] { + SoundInfoBitFlag_UserParam, + SoundInfoBitFlag_UserParam1, + SoundInfoBitFlag_UserParam2, + SoundInfoBitFlag_UserParam3 +}; enum WaveSoundInfoBitFlag { WaveSoundInfoBitFlag_Priority = 0, @@ -518,6 +523,10 @@ u32 SoundArchiveFile::SoundInfo::GetUserParam() const { return value; } +bool SoundArchiveFile::SoundInfo::ReadUserParam(u32* pOutValue, int index) const { + return optionParameter.GetValue(pOutValue, UserParamIndex[index]); +} + u32 SoundArchiveFile::BankInfo::GetStringId() const { u32 value; bool result {optionParameter.GetValue(&value, BankInfoBitFlag_StringId)}; From 0279e470711ec6a3ddf4a80671995738cced1309 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 29 Aug 2026 15:47:10 -0400 Subject: [PATCH 414/785] atk: Match `SoundArchiveFile::SoundInfo::IsFrontBypass` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 1553f73f..fb70a12a 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -527,6 +527,16 @@ bool SoundArchiveFile::SoundInfo::ReadUserParam(u32* pOutValue, int index) const return optionParameter.GetValue(pOutValue, UserParamIndex[index]); } +bool SoundArchiveFile::SoundInfo::IsFrontBypass() const { + u32 value; + bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_OffsetToCtrParam)}; + + if (!result) + return DefaultIsFrontBypass; + + return value & 1; +} + u32 SoundArchiveFile::BankInfo::GetStringId() const { u32 value; bool result {optionParameter.GetValue(&value, BankInfoBitFlag_StringId)}; From 5a8ff95f24dc1d930d08c2ddddfef3a79288c6e8 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 30 Aug 2026 17:24:17 -0400 Subject: [PATCH 415/785] atk: Match `SoundArchiveFile::StreamSoundInfo::GetTrackInfoTable` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index fb70a12a..455fd76f 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -1,7 +1,9 @@ #include #include +#include "nn/atk/atk_ElementType.h" #include "nn/atk/atk_Global.h" +#include "nn/util/util_BytePtr.h" namespace nn::atk::detail { namespace { @@ -547,6 +549,13 @@ u32 SoundArchiveFile::BankInfo::GetStringId() const { return value; } +const SoundArchiveFile::StreamTrackInfoTable* SoundArchiveFile::StreamSoundInfo::GetTrackInfoTable() const { + if (!toTrackInfoTable.IsValidTypeId(ElementType_Table_ReferenceTable)) + return nullptr; + + return util::ConstBytePtr(this, toTrackInfoTable.offset).Get(); +} + u32 SoundArchiveFile::WaveArchiveInfo::GetStringId() const { u32 value; bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; From 8a7bc33786cd9f681453848955a4cd0ccf49346b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 30 Aug 2026 17:25:27 -0400 Subject: [PATCH 416/785] atk: Match `SoundArchiveFile::StreamSoundInfo::GetSendValue` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 455fd76f..8eba28ea 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -556,6 +556,10 @@ const SoundArchiveFile::StreamTrackInfoTable* SoundArchiveFile::StreamSoundInfo: return util::ConstBytePtr(this, toTrackInfoTable.offset).Get(); } +const SoundArchiveFile::SendValue& SoundArchiveFile::StreamSoundInfo::GetSendValue() const { + return *util::ConstBytePtr(this, toSendValue.offset).Get(); +} + u32 SoundArchiveFile::WaveArchiveInfo::GetStringId() const { u32 value; bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; From 550309a7899d86bbcb3177d01158e677ec643ca5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 30 Aug 2026 17:30:25 -0400 Subject: [PATCH 417/785] atk: Match `SoundArchiveFile::StreamSoundInfo::GetStreamSoundExtension` --- include/nn/atk/fnd/basis/atkfnd_Result.h | 2 +- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/nn/atk/fnd/basis/atkfnd_Result.h b/include/nn/atk/fnd/basis/atkfnd_Result.h index 81a06b05..a302dba0 100644 --- a/include/nn/atk/fnd/basis/atkfnd_Result.h +++ b/include/nn/atk/fnd/basis/atkfnd_Result.h @@ -54,7 +54,7 @@ class FndResult { } bool IsFailed() const { - return value == FndResultType_Failed; + return value == static_cast(FndResultType_Failed); } const char* ToString(); diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 8eba28ea..37ccd931 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -1,9 +1,6 @@ #include #include -#include "nn/atk/atk_ElementType.h" -#include "nn/atk/atk_Global.h" -#include "nn/util/util_BytePtr.h" namespace nn::atk::detail { namespace { @@ -556,6 +553,14 @@ const SoundArchiveFile::StreamTrackInfoTable* SoundArchiveFile::StreamSoundInfo: return util::ConstBytePtr(this, toTrackInfoTable.offset).Get(); } +const SoundArchiveFile::StreamSoundExtension* SoundArchiveFile::StreamSoundInfo::GetStreamSoundExtension() const { + if (!toStreamSoundExtension.IsValidOffset() || + !toStreamSoundExtension.IsValidTypeId(ElementType_SoundArchiveFile_StreamSoundExtensionInfo)) + return nullptr; + + return util::ConstBytePtr(this, toStreamSoundExtension.offset).Get(); +} + const SoundArchiveFile::SendValue& SoundArchiveFile::StreamSoundInfo::GetSendValue() const { return *util::ConstBytePtr(this, toSendValue.offset).Get(); } From 0cd38b49ebcb5942e80aff801df8a5d07c4662f8 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 30 Aug 2026 17:33:46 -0400 Subject: [PATCH 418/785] atk: Match `SoundArchiveFile::WaveSoundInfo::GetChannelPriority` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 37ccd931..ae54fc5b 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -565,6 +565,16 @@ const SoundArchiveFile::SendValue& SoundArchiveFile::StreamSoundInfo::GetSendVal return *util::ConstBytePtr(this, toSendValue.offset).Get(); } +u8 SoundArchiveFile::WaveSoundInfo::GetChannelPriority() const { + u32 value; + bool result {optionParameter.GetValue(&value, WaveSoundInfoBitFlag_Priority)}; + + if (!result) + return DefaultChannelPriority; + + return Util::DivideBy8bit(value, 0); +} + u32 SoundArchiveFile::WaveArchiveInfo::GetStringId() const { u32 value; bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; From f127917c65b3617f139e5d50b764e6cd08356ee7 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 30 Aug 2026 17:34:24 -0400 Subject: [PATCH 419/785] atk: Match `SoundArchiveFile::WaveSoundInfo::GetIsReleasePriorityFix` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index ae54fc5b..7140c50e 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -575,6 +575,16 @@ u8 SoundArchiveFile::WaveSoundInfo::GetChannelPriority() const { return Util::DivideBy8bit(value, 0); } +u8 SoundArchiveFile::WaveSoundInfo::GetIsReleasePriorityFix() const { + u32 value; + bool result {optionParameter.GetValue(&value, WaveSoundInfoBitFlag_Priority)}; + + if (!result) + return DefaultIsReleasePriorityFix; + + return Util::DivideBy8bit(value, 1); +} + u32 SoundArchiveFile::WaveArchiveInfo::GetStringId() const { u32 value; bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; From d6233e8e50c94177021e2f992c6f1a648b8679f9 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 30 Aug 2026 17:39:43 -0400 Subject: [PATCH 420/785] atk: Match `SoundArchiveFile::SequenceSoundInfo::GetBankIdTable` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 7140c50e..f69c7365 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -585,6 +585,10 @@ u8 SoundArchiveFile::WaveSoundInfo::GetIsReleasePriorityFix() const { return Util::DivideBy8bit(value, 1); } +const Util::Table& SoundArchiveFile::SequenceSoundInfo::GetBankIdTable() const { + return *util::ConstBytePtr(this, toBankIdTable.offset).Get>(); +} + u32 SoundArchiveFile::WaveArchiveInfo::GetStringId() const { u32 value; bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; From 1e8984802e02b6fe3d49c180847caf0a16e831d7 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 30 Aug 2026 17:53:28 -0400 Subject: [PATCH 421/785] atk: Match `SoundArchiveFile::SequenceSoundInfo::GetBankIds` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index f69c7365..55931610 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -589,6 +589,13 @@ const Util::Table& SoundArchiveFile::SequenceSoundInfo::GetBankIdTable() co return *util::ConstBytePtr(this, toBankIdTable.offset).Get>(); } +void SoundArchiveFile::SequenceSoundInfo::GetBankIds(u32* bankIds) const { + const Util::Table& table {GetBankIdTable()}; + + for (u32 i {0}; i < SoundArchive::SequenceBankMax; ++i) + bankIds[i] = i < table.count ? table.item[i] : SoundArchive::InvalidId; +} + u32 SoundArchiveFile::WaveArchiveInfo::GetStringId() const { u32 value; bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; From ec153dbd757abd2fc83e6735a42d1aeeaeae864c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 30 Aug 2026 17:55:03 -0400 Subject: [PATCH 422/785] atk: Match `SoundArchiveFile::SequenceSoundInfo::GetStartOffset` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 55931610..94e4eb5a 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -596,6 +596,16 @@ void SoundArchiveFile::SequenceSoundInfo::GetBankIds(u32* bankIds) const { bankIds[i] = i < table.count ? table.item[i] : SoundArchive::InvalidId; } +u32 SoundArchiveFile::SequenceSoundInfo::GetStartOffset() const { + u32 value; + bool result {optionParameter.GetValue(&value, SequenceSoundInfoBitFlag_StartOffset)}; + + if (!result) + return DefaultSeqStartOffset; + + return value; +} + u32 SoundArchiveFile::WaveArchiveInfo::GetStringId() const { u32 value; bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; From c6d9da1d97c82a85a7d966a00c83fa9ad91c8339 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 30 Aug 2026 17:56:00 -0400 Subject: [PATCH 423/785] atk: Match `SoundArchiveFile::SequenceSoundInfo::GetChannelPriority` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 94e4eb5a..50e446ad 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -606,6 +606,16 @@ u32 SoundArchiveFile::SequenceSoundInfo::GetStartOffset() const { return value; } +u8 SoundArchiveFile::SequenceSoundInfo::GetChannelPriority() const { + u32 value; + bool result {optionParameter.GetValue(&value, SequenceSoundInfoBitFlag_Priority)}; + + if (!result) + return DefaultChannelPriority; + + return Util::DivideBy8bit(value, 0); +} + u32 SoundArchiveFile::WaveArchiveInfo::GetStringId() const { u32 value; bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; From d979ebff03cd4da620e7d27ce3c4eabbfad0dee9 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 30 Aug 2026 18:00:21 -0400 Subject: [PATCH 424/785] atk: Match `SoundArchiveFile::SequenceSoundInfo::IsReleasePriorityFix` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 50e446ad..1430c67d 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -616,6 +616,16 @@ u8 SoundArchiveFile::SequenceSoundInfo::GetChannelPriority() const { return Util::DivideBy8bit(value, 0); } +bool SoundArchiveFile::SequenceSoundInfo::IsReleasePriorityFix() const { + u32 value; + bool result {optionParameter.GetValue(&value, SequenceSoundInfoBitFlag_Priority)}; + + if (!result) + return DefaultIsReleasePriorityFix == 0; + + return Util::DivideBy8bit(value, 1) != 0; +} + u32 SoundArchiveFile::WaveArchiveInfo::GetStringId() const { u32 value; bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; From 991ef9608cc84d441e35be96d789e45469981deb Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 30 Aug 2026 18:06:26 -0400 Subject: [PATCH 425/785] atk: Match `SoundArchiveFile::PlayerInfo::GetPlayerHeapSize` --- .../atk/detail/atk_SoundArchiveFile.cpp | 116 ++++++++++-------- 1 file changed, 63 insertions(+), 53 deletions(-) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 1430c67d..208f6306 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -258,6 +258,66 @@ const SoundArchiveFile::FileInfo* SoundArchiveFile::InfoBlockBody::GetFileInfo(S return util::ConstBytePtr(table.GetReferedItem(index)).Get(); } +u32 SoundArchiveFile::SoundInfo::GetStringId() const { + u32 value; + bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; + + if (!result) + return DefaultStringId; + + return value; +} + +u32 SoundArchiveFile::BankInfo::GetStringId() const { + u32 value; + bool result {optionParameter.GetValue(&value, BankInfoBitFlag_StringId)}; + + if (!result) + return DefaultStringId; + + return value; +} + +u32 SoundArchiveFile::WaveArchiveInfo::GetStringId() const { + u32 value; + bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; + + if (!result) + return DefaultStringId; + + return value; +} + +u32 SoundArchiveFile::SoundGroupInfo::GetStringId() const { + u32 value; + bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; + + if (!result) + return DefaultStringId; + + return value; +} + +u32 SoundArchiveFile::GroupInfo::GetStringId() const { + u32 value; + bool result {optionParameter.GetValue(&value, GroupInfoBitFlag_StringId)}; + + if (!result) + return DefaultStringId; + + return value; +} + +u32 SoundArchiveFile::PlayerInfo::GetStringId() const { + u32 value; + bool result {optionParameter.GetValue(&value, PlayerInfoBitFlag_StringId)}; + + if (!result) + return DefaultStringId; + + return value; +} + const SoundArchiveFile::SoundArchivePlayerInfo* SoundArchiveFile::InfoBlockBody::GetSoundArchivePlayerInfo() const { return util::ConstBytePtr(this, toSoundArchivePlayerInfo.offset) .Get(); @@ -442,16 +502,6 @@ const SoundArchiveFile::Sound3DInfo* SoundArchiveFile::SoundInfo::GetSound3DInfo return util::ConstBytePtr(this, offset).Get(); } -u32 SoundArchiveFile::SoundInfo::GetStringId() const { - u32 value; - bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; - - if (!result) - return DefaultStringId; - - return value; -} - PanMode SoundArchiveFile::SoundInfo::GetPanMode() const { u32 value; bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_PanParam)}; @@ -536,16 +586,6 @@ bool SoundArchiveFile::SoundInfo::IsFrontBypass() const { return value & 1; } -u32 SoundArchiveFile::BankInfo::GetStringId() const { - u32 value; - bool result {optionParameter.GetValue(&value, BankInfoBitFlag_StringId)}; - - if (!result) - return DefaultStringId; - - return value; -} - const SoundArchiveFile::StreamTrackInfoTable* SoundArchiveFile::StreamSoundInfo::GetTrackInfoTable() const { if (!toTrackInfoTable.IsValidTypeId(ElementType_Table_ReferenceTable)) return nullptr; @@ -626,42 +666,12 @@ bool SoundArchiveFile::SequenceSoundInfo::IsReleasePriorityFix() const { return Util::DivideBy8bit(value, 1) != 0; } -u32 SoundArchiveFile::WaveArchiveInfo::GetStringId() const { - u32 value; - bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; - - if (!result) - return DefaultStringId; - - return value; -} - -u32 SoundArchiveFile::SoundGroupInfo::GetStringId() const { - u32 value; - bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; - - if (!result) - return DefaultStringId; - - return value; -} - -u32 SoundArchiveFile::GroupInfo::GetStringId() const { - u32 value; - bool result {optionParameter.GetValue(&value, GroupInfoBitFlag_StringId)}; - - if (!result) - return DefaultStringId; - - return value; -} - -u32 SoundArchiveFile::PlayerInfo::GetStringId() const { +u32 SoundArchiveFile::PlayerInfo::GetPlayerHeapSize() const { u32 value; - bool result {optionParameter.GetValue(&value, PlayerInfoBitFlag_StringId)}; + bool result {optionParameter.GetValue(&value, PlayerInfoBitFlag_HeapSize)}; if (!result) - return DefaultStringId; + return DefaultPlayerHeapSize; return value; } From 186b16d0a7dd7ea373dbc716f6aa4ccf96f039c0 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 30 Aug 2026 18:07:49 -0400 Subject: [PATCH 426/785] atk: Match `SoundArchiveFile::WaveArchiveInfo::GetWaveCount` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 208f6306..5add9c74 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -675,4 +675,14 @@ u32 SoundArchiveFile::PlayerInfo::GetPlayerHeapSize() const { return value; } + +u32 SoundArchiveFile::WaveArchiveInfo::GetWaveCount() const { + u32 value; + bool result {optionParameter.GetValue(&value, WaveArchiveInfoBitFlag_WaveCount)}; + + if (!result) + return DefaultWarcWaveCount; + + return value; +} } // namespace nn::atk::detail \ No newline at end of file From 33cda1de5c9720017cd75dd55eb78c836920f133 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 30 Aug 2026 18:12:34 -0400 Subject: [PATCH 427/785] atk: Match `SoundArchiveFile::FileInfo::GetFileLocationType` --- .../atk/detail/atk_SoundArchiveFile.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 5add9c74..5b4ed928 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -1,6 +1,7 @@ #include #include +#include "nn/atk/atk_ElementType.h" namespace nn::atk::detail { namespace { @@ -685,4 +686,20 @@ u32 SoundArchiveFile::WaveArchiveInfo::GetWaveCount() const { return value; } + +SoundArchiveFile::FileLocationType SoundArchiveFile::FileInfo::GetFileLocationType() const { + switch (toFileLocation.typeId) { + case ElementType_SoundArchiveFile_InternalFileInfo: + return FileLocationType_Internal; + + case ElementType_SoundArchiveFile_ExternalFileInfo: + return FileLocationType_External; + + case 0: + return FileLocationType_None; + + default: + return FileLocationType_None; + } +} } // namespace nn::atk::detail \ No newline at end of file From 312fb2abefc5ec54bf4caba8ab50ea24223effac Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 30 Aug 2026 18:16:50 -0400 Subject: [PATCH 428/785] atk: Match `SoundArchiveFile::FileInfo::GetInternalFileInfo` --- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index 5b4ed928..a3453a19 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -1,7 +1,7 @@ #include #include -#include "nn/atk/atk_ElementType.h" +#include "nn/util/util_BytePtr.h" namespace nn::atk::detail { namespace { @@ -694,7 +694,7 @@ SoundArchiveFile::FileLocationType SoundArchiveFile::FileInfo::GetFileLocationTy case ElementType_SoundArchiveFile_ExternalFileInfo: return FileLocationType_External; - + case 0: return FileLocationType_None; @@ -702,4 +702,11 @@ SoundArchiveFile::FileLocationType SoundArchiveFile::FileInfo::GetFileLocationTy return FileLocationType_None; } } + +const SoundArchiveFile::InternalFileInfo* SoundArchiveFile::FileInfo::GetInternalFileInfo() const { + if (GetFileLocationType() != FileLocationType_Internal) + return nullptr; + + return util::ConstBytePtr(this, toFileLocation.offset).Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 1b990a37036169dc66f62ecc6868fb9bec4af21e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 30 Aug 2026 18:17:45 -0400 Subject: [PATCH 429/785] atk: Match `SoundArchiveFile::FileInfo::GetExternalFileInfo` This matches all exported functions in `SoundArchiveFile` --- include/nn/atk/atk_SoundArchiveFile.h | 12 ++++++++---- src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp | 8 +++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveFile.h b/include/nn/atk/atk_SoundArchiveFile.h index 040bbe25..abb4e05b 100644 --- a/include/nn/atk/atk_SoundArchiveFile.h +++ b/include/nn/atk/atk_SoundArchiveFile.h @@ -90,20 +90,24 @@ class SoundArchiveFile { const NodeData* GetNodeDataBy(const char* str, size_t len = 0) const; - void* operator[](int idx) const { + void* operator[]([[maybe_unused]] int idx) const { // TODO + return nullptr; } - void* operator[](u32 idx) const { + void* operator[]([[maybe_unused]] u32 idx) const { // TODO + return nullptr; } - void* operator[](const char* str) const { + void* operator[]([[maybe_unused]] const char* str) const { // TODO + return nullptr; } - void* operator()(const char* str, size_t len) const { + void* operator()([[maybe_unused]] const char* str, [[maybe_unused]] size_t len) const { // TODO + return nullptr; } u32 GetDataCount() const; diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index a3453a19..b0af246b 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -1,7 +1,6 @@ #include #include -#include "nn/util/util_BytePtr.h" namespace nn::atk::detail { namespace { @@ -709,4 +708,11 @@ const SoundArchiveFile::InternalFileInfo* SoundArchiveFile::FileInfo::GetInterna return util::ConstBytePtr(this, toFileLocation.offset).Get(); } + +const SoundArchiveFile::ExternalFileInfo* SoundArchiveFile::FileInfo::GetExternalFileInfo() const { + if (GetFileLocationType() != FileLocationType_External) + return nullptr; + + return util::ConstBytePtr(this, toFileLocation.offset).Get(); +} } // namespace nn::atk::detail \ No newline at end of file From ba9d0ff2e194276da4784483a8bc5385fb4e2abd Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 30 Aug 2026 19:12:21 -0400 Subject: [PATCH 430/785] atk: Match `detail::Debug_GetWarningFlag` --- include/nn/atk/atk_Debug.h | 8 +-- .../atk/detail/debug/atk_Debug.cpp | 64 +++++++++++++++++++ 2 files changed, 66 insertions(+), 6 deletions(-) diff --git a/include/nn/atk/atk_Debug.h b/include/nn/atk/atk_Debug.h index bd90d139..57010613 100644 --- a/include/nn/atk/atk_Debug.h +++ b/include/nn/atk/atk_Debug.h @@ -12,10 +12,8 @@ enum DebugWarningFlag { DebugWarningFlag_NotEnoughStrmchannel, }; -static u8 gWarningFlag = 0b11111; -static const u32 gWarningBitFlags[6] = {0b11111, 0b00001, 0b00010, 0b00100, 0b01000, 0b10000}; - -void Debug_SetWarningFlag(DebugWarningFlag warning, bool); +void Debug_SetWarningFlag(DebugWarningFlag warning, bool enable); +// extern u32 gWarningFlag; namespace detail { enum DebugSoundType { @@ -31,7 +29,5 @@ DebugWarningFlag Debug_GetDebugWarningFlagFromSoundType(DebugSoundType type); char* Debug_GetSoundTypeString(DebugSoundType type); using DebugLogFunc = void(*)(char*); - -static DebugLogFunc g_DebugLogHookFunc; } // namespace nn::atk::detail } // namespace nn::atk \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/debug/atk_Debug.cpp b/src/NintendoWare/atk/detail/debug/atk_Debug.cpp index e69de29b..7225a2f9 100644 --- a/src/NintendoWare/atk/detail/debug/atk_Debug.cpp +++ b/src/NintendoWare/atk/detail/debug/atk_Debug.cpp @@ -0,0 +1,64 @@ +#include + +namespace nn::atk { +namespace { +const u32 NotEnoughSeqSound {0b00001}; +const u32 NotEnoughStrmSound {0b00010}; +const u32 NotEnoughWaveSound {0b00100}; +const u32 NotEnoughSeqTrack {0b01000}; +const u32 NotEnoughStrmChannel {0b10000}; +const u32 NotEnoughInstance {0b11111}; + +u32 gWarningFlag = NotEnoughInstance; + +u32 GetWarningBitFlag(DebugWarningFlag warning) { + u32 bitFlag {0}; + + switch (warning) { + case DebugWarningFlag_NotEnoughInstance: + bitFlag = NotEnoughInstance; + break; + + case DebugWarningFlag_NotEnoughSeqsound: + bitFlag = NotEnoughSeqSound; + break; + + case DebugWarningFlag_NotEnoughStrmsound: + bitFlag = NotEnoughStrmSound; + break; + + case DebugWarningFlag_NotEnoughWavesound: + bitFlag = NotEnoughWaveSound; + break; + + case DebugWarningFlag_NotEnoughSeqtrack: + bitFlag = NotEnoughSeqTrack; + break; + + case DebugWarningFlag_NotEnoughStrmchannel: + bitFlag = NotEnoughStrmChannel; + break; + } + + return bitFlag; +} +} // anonymous namespace + +// NON_MATCHING +void Debug_SetWarningFlag(DebugWarningFlag warning, bool enable) { + u32 bitFlag {GetWarningBitFlag(warning)}; + + if (enable) + gWarningFlag = bitFlag | gWarningFlag; +} + +namespace detail { +DebugLogFunc g_DebugLogHookFunc; + +bool Debug_GetWarningFlag(DebugWarningFlag warning) { + u32 bitFlag {GetWarningBitFlag(warning)}; + + return (bitFlag & ~gWarningFlag) == 0; +} +} // namespace nn::atk::detail +} // namespace nn::atk \ No newline at end of file From c8a16c001e1d9b9610ba413eb32567c033ed4f93 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 30 Aug 2026 19:20:25 -0400 Subject: [PATCH 431/785] atk: Match `Debug_SetWarningFlag` --- src/NintendoWare/atk/detail/debug/atk_Debug.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/NintendoWare/atk/detail/debug/atk_Debug.cpp b/src/NintendoWare/atk/detail/debug/atk_Debug.cpp index 7225a2f9..9649f277 100644 --- a/src/NintendoWare/atk/detail/debug/atk_Debug.cpp +++ b/src/NintendoWare/atk/detail/debug/atk_Debug.cpp @@ -44,12 +44,13 @@ u32 GetWarningBitFlag(DebugWarningFlag warning) { } } // anonymous namespace -// NON_MATCHING void Debug_SetWarningFlag(DebugWarningFlag warning, bool enable) { u32 bitFlag {GetWarningBitFlag(warning)}; if (enable) - gWarningFlag = bitFlag | gWarningFlag; + gWarningFlag |= bitFlag; + else + gWarningFlag &= ~bitFlag; } namespace detail { From 603ee91ab53b294118865ed3ceba0883acebdd93 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 30 Aug 2026 19:35:22 -0400 Subject: [PATCH 432/785] atk: Match `detail::Debug_GetDebugWarningFlagFromSoundType` --- include/nn/atk/atk_Debug.h | 1 - src/NintendoWare/atk/detail/debug/atk_Debug.cpp | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_Debug.h b/include/nn/atk/atk_Debug.h index 57010613..091c3c69 100644 --- a/include/nn/atk/atk_Debug.h +++ b/include/nn/atk/atk_Debug.h @@ -13,7 +13,6 @@ enum DebugWarningFlag { }; void Debug_SetWarningFlag(DebugWarningFlag warning, bool enable); -// extern u32 gWarningFlag; namespace detail { enum DebugSoundType { diff --git a/src/NintendoWare/atk/detail/debug/atk_Debug.cpp b/src/NintendoWare/atk/detail/debug/atk_Debug.cpp index 9649f277..b5730438 100644 --- a/src/NintendoWare/atk/detail/debug/atk_Debug.cpp +++ b/src/NintendoWare/atk/detail/debug/atk_Debug.cpp @@ -61,5 +61,21 @@ bool Debug_GetWarningFlag(DebugWarningFlag warning) { return (bitFlag & ~gWarningFlag) == 0; } + +DebugWarningFlag Debug_GetDebugWarningFlagFromSoundType(DebugSoundType type) { + switch (type) { + case DebugSoundType_Seqsound: + return DebugWarningFlag_NotEnoughSeqsound; + + case DebugSoundType_Strmsound: + return DebugWarningFlag_NotEnoughStrmsound; + + case DebugSoundType_Wavesound: + return DebugWarningFlag_NotEnoughWavesound; + + default: + return DebugWarningFlag_NotEnoughSeqsound; + } +} } // namespace nn::atk::detail } // namespace nn::atk \ No newline at end of file From 9da512a9ef3b7b7adce1fc05f7a147b99c24368a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 30 Aug 2026 19:39:05 -0400 Subject: [PATCH 433/785] atk: Match `detail::Debug_GetSoundTypeString` --- include/nn/atk/atk_Debug.h | 4 +--- src/NintendoWare/atk/detail/atk_WaveFile.cpp | 1 - src/NintendoWare/atk/detail/debug/atk_Debug.cpp | 16 ++++++++++++++++ .../atk/fnd/basis/atkfnd_HeapBase.cpp | 3 ++- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/nn/atk/atk_Debug.h b/include/nn/atk/atk_Debug.h index 091c3c69..ea034b6b 100644 --- a/include/nn/atk/atk_Debug.h +++ b/include/nn/atk/atk_Debug.h @@ -21,11 +21,9 @@ enum DebugSoundType { DebugSoundType_Wavesound, }; -static const char* gSoundTypeStrings[3] = {"seq", "strm", "wave"}; - bool Debug_GetWarningFlag(DebugWarningFlag warning); DebugWarningFlag Debug_GetDebugWarningFlagFromSoundType(DebugSoundType type); -char* Debug_GetSoundTypeString(DebugSoundType type); +const char* Debug_GetSoundTypeString(DebugSoundType type); using DebugLogFunc = void(*)(char*); } // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/atk_WaveFile.cpp b/src/NintendoWare/atk/detail/atk_WaveFile.cpp index 650fe150..a852bbc0 100644 --- a/src/NintendoWare/atk/detail/atk_WaveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveFile.cpp @@ -1,7 +1,6 @@ #include #include -#include "nn/util/util_BytePtr.h" namespace nn::atk::detail { const WaveFile::InfoBlock* WaveFile::FileHeader::GetInfoBlock() const { diff --git a/src/NintendoWare/atk/detail/debug/atk_Debug.cpp b/src/NintendoWare/atk/detail/debug/atk_Debug.cpp index b5730438..3dd4cb29 100644 --- a/src/NintendoWare/atk/detail/debug/atk_Debug.cpp +++ b/src/NintendoWare/atk/detail/debug/atk_Debug.cpp @@ -77,5 +77,21 @@ DebugWarningFlag Debug_GetDebugWarningFlagFromSoundType(DebugSoundType type) { return DebugWarningFlag_NotEnoughSeqsound; } } + +const char* Debug_GetSoundTypeString(DebugSoundType type) { + switch (type) { + case DebugSoundType_Seqsound: + return "seq"; + + case DebugSoundType_Strmsound: + return "strm"; + + case DebugSoundType_Wavesound: + return "wave"; + + default: + return ""; + } +} } // namespace nn::atk::detail } // namespace nn::atk \ No newline at end of file diff --git a/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp b/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp index 5b23f8c0..ebdf4be4 100644 --- a/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp +++ b/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp @@ -19,7 +19,8 @@ HeapBase::HeapList* HeapBase::FindListContainHeap(HeapBase* pHeapBase) { return pList; } -// NON_MATCHING: commented because it needs to not be inlined for other functions to match +// NON_MATCHING +// Commented out because it needs to not be inlined for other functions to match // HeapBase* HeapBase::FindContainHeap(HeapList* pList, const void* memBlock) { // uintptr_t memBlockAddress {reinterpret_cast(memBlock)}; From 54c8ad7d96932902cab82df26611ce8b61b5b580 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 31 Aug 2026 14:25:15 -0400 Subject: [PATCH 434/785] atk: Match `WaveArchiveFile::FileHeader::GetReferenceBy` --- include/nn/atk/atk_WaveArchiveFile.h | 50 ++++++++++++------- include/nn/atk/atk_WaveFileReader.h | 3 +- src/NintendoWare/atk/atk_SoundArchive.cpp | 2 +- .../atk/detail/atk_WaveArchiveFile.cpp | 13 +++++ .../atk/detail/atk_WaveFileReader.cpp | 3 +- .../atk/detail/seq/atk_SequenceSoundFile.cpp | 2 +- 6 files changed, 50 insertions(+), 23 deletions(-) diff --git a/include/nn/atk/atk_WaveArchiveFile.h b/include/nn/atk/atk_WaveArchiveFile.h index 78c64626..0b31597c 100644 --- a/include/nn/atk/atk_WaveArchiveFile.h +++ b/include/nn/atk/atk_WaveArchiveFile.h @@ -4,43 +4,55 @@ namespace nn::atk::detail { struct WaveArchiveFile { - constexpr static s32 BlockCount = 2; + static const int BlockCount {2}; struct InfoBlock; struct FileBlock; struct FileHeader : BinaryFileHeader { + public: + Util::ReferenceWithSize toBlocks[BlockCount]; - InfoBlock* GetInfoBlock() const; - u32 GetInfoBlockOffset() const; + const InfoBlock* GetInfoBlock() const; + const FileBlock* GetFileBlock() const; + + u32 GetInfoBlockSize() const; + u32 GetFileBlockSize() const; - FileBlock* GetFileBlock() const; + u32 GetInfoBlockOffset() const; u32 GetFileBlockOffset() const; + + private: + const Util::ReferenceWithSize* GetReferenceBy(u16 typeId) const; + }; + static_assert(sizeof(FileHeader) == 0x2c); - u32 GetInfoBlockSize() const; + struct InfoBlockBody { + Util::Table table; - Util::Reference* GetReferenceBy(u16); + u32 GetWaveFileCount() const { return table.count; } - u32 GetFileBlockSize() const; + u32 GetSize(u32 index) const { + return table.item[index].size; + } - Util::ReferenceWithSize toBlocks[BlockCount]; + u32 GetOffsetFromFileBlockBody(u32 index) const { + return table.item[index].offset; + } + + static const u32 InvalidOffset = 0xffffffff; }; - static_assert(sizeof(FileHeader) == 0x2C); - struct FileBlockBody { /* unknown structure */ }; - struct FileBlock { + struct InfoBlock { BinaryBlockHeader header; - FileBlockBody body; + InfoBlockBody body; }; - struct InfoBlockBody { - constexpr static s32 InvalidOffset = -1; - - Util::ReferenceWithSizeTable table; - }; + struct FileBlockBody { }; - struct InfoBlock { + struct FileBlock { BinaryBlockHeader header; - InfoBlockBody body; + FileBlockBody body; }; + static_assert(sizeof(FileBlock) == 0xc); }; } // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/atk_WaveFileReader.h b/include/nn/atk/atk_WaveFileReader.h index 98496982..9b518a1a 100644 --- a/include/nn/atk/atk_WaveFileReader.h +++ b/include/nn/atk/atk_WaveFileReader.h @@ -18,7 +18,8 @@ class WaveFileReader { bool ReadWaveInfo(WaveInfo* info, const void* waveDataOffsetOrigin) const; - const void* GetWaveDataAddress(const WaveFile::ChannelInfo* info, const void* waveDataOffsetOrigin) const; + const void* GetWaveDataAddress(const WaveFile::ChannelInfo* info, + [[maybe_unused]] const void* waveDataOffsetOrigin) const; private: const WaveFile::FileHeader* m_pHeader {}; diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index e4e7a7e5..c8328b8a 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -7,7 +7,7 @@ #include #include -#include "nn/atk/fnd/string/atkfnd_String.h" +#include namespace nn::atk { SoundArchive::SoundArchive() { diff --git a/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp index e69de29b..f6add59e 100644 --- a/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp @@ -0,0 +1,13 @@ +#include + +namespace nn::atk::detail { +const Util::ReferenceWithSize* WaveArchiveFile::FileHeader::GetReferenceBy(u16 typeId) const { + for (int i {0}; i < BlockCount; ++i) { + if (toBlocks[i].IsValidTypeId(typeId)) { + return &toBlocks[i]; + } + } + + return nullptr; +} +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp b/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp index 109c49b9..8ec15ff0 100644 --- a/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp @@ -115,7 +115,8 @@ bool WaveFileReader::ReadWaveInfo(WaveInfo* info, const void* waveDataOffsetOrig return true; } -const void* WaveFileReader::GetWaveDataAddress(const WaveFile::ChannelInfo* info, const void* waveDataOffsetOrigin) const { +const void* WaveFileReader::GetWaveDataAddress(const WaveFile::ChannelInfo* info, + [[maybe_unused]] const void* waveDataOffsetOrigin) const { return info->GetSamplesAddress(m_pDataBlockBody); } } // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp index bf331b9d..7a8b630a 100644 --- a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp @@ -27,7 +27,7 @@ const char* SequenceSoundFile::LabelBlockBody::GetLabel(int index) const { const char* SequenceSoundFile::LabelBlockBody::GetLabelByOffset(u32 offset) const { for (int i {0}; i < GetLabelCount(); ++i) { const LabelInfo* labelInfo {GetLabelInfo(i)}; - if (labelInfo->referToSequenceData.offset == offset) + if (static_cast(labelInfo->referToSequenceData.offset) == offset) return labelInfo->label; } From b6216a8f86e0808c1b9a010cb3be75c51ff57682 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 31 Aug 2026 14:28:49 -0400 Subject: [PATCH 435/785] atk: Match `WaveArchiveFile::FileHeader::GetInfoBlockOffset` --- src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp index f6add59e..595c7929 100644 --- a/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp @@ -1,5 +1,7 @@ #include +#include + namespace nn::atk::detail { const Util::ReferenceWithSize* WaveArchiveFile::FileHeader::GetReferenceBy(u16 typeId) const { for (int i {0}; i < BlockCount; ++i) { @@ -10,4 +12,8 @@ const Util::ReferenceWithSize* WaveArchiveFile::FileHeader::GetReferenceBy(u16 t return nullptr; } + +u32 WaveArchiveFile::FileHeader::GetInfoBlockOffset() const { + return GetReferenceBy(ElementType_WaveArchiveFile_InfoBlock)->offset; +} } // namespace nn::atk::detail \ No newline at end of file From b9b90f4c60db2926c8314760519aa292c26425b3 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 31 Aug 2026 14:30:28 -0400 Subject: [PATCH 436/785] atk: Match `WaveArchiveFile::FileHeader::GetInfoBlock` --- src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp index 595c7929..0ec68bbf 100644 --- a/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp @@ -16,4 +16,8 @@ const Util::ReferenceWithSize* WaveArchiveFile::FileHeader::GetReferenceBy(u16 t u32 WaveArchiveFile::FileHeader::GetInfoBlockOffset() const { return GetReferenceBy(ElementType_WaveArchiveFile_InfoBlock)->offset; } + +const WaveArchiveFile::InfoBlock* WaveArchiveFile::FileHeader::GetInfoBlock() const { + return util::ConstBytePtr(this, GetInfoBlockOffset()).Get(); +} } // namespace nn::atk::detail \ No newline at end of file From ee5d817fae04550c00573aad8ad58c25bb15cb1b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 31 Aug 2026 14:31:32 -0400 Subject: [PATCH 437/785] atk: Match `WaveArchiveFile::FileHeader::GetFileBlockOffset` --- src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp index 0ec68bbf..3eb9a733 100644 --- a/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp @@ -13,11 +13,15 @@ const Util::ReferenceWithSize* WaveArchiveFile::FileHeader::GetReferenceBy(u16 t return nullptr; } +const WaveArchiveFile::InfoBlock* WaveArchiveFile::FileHeader::GetInfoBlock() const { + return util::ConstBytePtr(this, GetInfoBlockOffset()).Get(); +} + u32 WaveArchiveFile::FileHeader::GetInfoBlockOffset() const { return GetReferenceBy(ElementType_WaveArchiveFile_InfoBlock)->offset; } -const WaveArchiveFile::InfoBlock* WaveArchiveFile::FileHeader::GetInfoBlock() const { - return util::ConstBytePtr(this, GetInfoBlockOffset()).Get(); +u32 WaveArchiveFile::FileHeader::GetFileBlockOffset() const { + return GetReferenceBy(ElementType_WaveArchiveFile_FileBlock)->offset; } } // namespace nn::atk::detail \ No newline at end of file From a1a1d0a22ffc0731bdbc66904534843708674c01 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 31 Aug 2026 14:31:59 -0400 Subject: [PATCH 438/785] atk: Match `WaveArchiveFile::FileHeader::GetFileBlock` --- src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp index 3eb9a733..bcefa3c9 100644 --- a/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp @@ -21,6 +21,10 @@ u32 WaveArchiveFile::FileHeader::GetInfoBlockOffset() const { return GetReferenceBy(ElementType_WaveArchiveFile_InfoBlock)->offset; } +const WaveArchiveFile::FileBlock* WaveArchiveFile::FileHeader::GetFileBlock() const { + return util::ConstBytePtr(this, GetFileBlockOffset()).Get(); +} + u32 WaveArchiveFile::FileHeader::GetFileBlockOffset() const { return GetReferenceBy(ElementType_WaveArchiveFile_FileBlock)->offset; } From ddca4227b7c6c4c6296a8f30b46b14fb2023d77c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 31 Aug 2026 14:36:05 -0400 Subject: [PATCH 439/785] atk: Match `WaveArchiveFile::FileHeader::GetInfoBlockSize` --- src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp index bcefa3c9..f6db562d 100644 --- a/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp @@ -28,4 +28,8 @@ const WaveArchiveFile::FileBlock* WaveArchiveFile::FileHeader::GetFileBlock() co u32 WaveArchiveFile::FileHeader::GetFileBlockOffset() const { return GetReferenceBy(ElementType_WaveArchiveFile_FileBlock)->offset; } + +u32 WaveArchiveFile::FileHeader::GetInfoBlockSize() const { + return GetReferenceBy(ElementType_WaveArchiveFile_InfoBlock)->size; +} } // namespace nn::atk::detail \ No newline at end of file From d8f6a26cc3f9d7027f62703aa53ef02bb9d34866 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 31 Aug 2026 14:41:30 -0400 Subject: [PATCH 440/785] atk: Match `WaveArchiveFile::FileHeader::GetFileBlockSize` This matches all exported functions in `WaveArchiveFile` --- .../atk/detail/atk_WaveArchiveFile.cpp | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp index f6db562d..00b50b47 100644 --- a/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp @@ -3,33 +3,37 @@ #include namespace nn::atk::detail { -const Util::ReferenceWithSize* WaveArchiveFile::FileHeader::GetReferenceBy(u16 typeId) const { - for (int i {0}; i < BlockCount; ++i) { - if (toBlocks[i].IsValidTypeId(typeId)) { - return &toBlocks[i]; - } - } +const WaveArchiveFile::InfoBlock* WaveArchiveFile::FileHeader::GetInfoBlock() const { // 28 + return util::ConstBytePtr(this, GetInfoBlockOffset()).Get(); +} - return nullptr; +const WaveArchiveFile::FileBlock* WaveArchiveFile::FileHeader::GetFileBlock() const { // 34 + return util::ConstBytePtr(this, GetFileBlockOffset()).Get(); } -const WaveArchiveFile::InfoBlock* WaveArchiveFile::FileHeader::GetInfoBlock() const { - return util::ConstBytePtr(this, GetInfoBlockOffset()).Get(); +u32 WaveArchiveFile::FileHeader::GetInfoBlockSize() const { + return GetReferenceBy(ElementType_WaveArchiveFile_InfoBlock)->size; } -u32 WaveArchiveFile::FileHeader::GetInfoBlockOffset() const { - return GetReferenceBy(ElementType_WaveArchiveFile_InfoBlock)->offset; +u32 WaveArchiveFile::FileHeader::GetFileBlockSize() const { + return GetReferenceBy(ElementType_WaveArchiveFile_FileBlock)->size; } -const WaveArchiveFile::FileBlock* WaveArchiveFile::FileHeader::GetFileBlock() const { - return util::ConstBytePtr(this, GetFileBlockOffset()).Get(); +u32 WaveArchiveFile::FileHeader::GetInfoBlockOffset() const { + return GetReferenceBy(ElementType_WaveArchiveFile_InfoBlock)->offset; } u32 WaveArchiveFile::FileHeader::GetFileBlockOffset() const { return GetReferenceBy(ElementType_WaveArchiveFile_FileBlock)->offset; } -u32 WaveArchiveFile::FileHeader::GetInfoBlockSize() const { - return GetReferenceBy(ElementType_WaveArchiveFile_InfoBlock)->size; +const Util::ReferenceWithSize* WaveArchiveFile::FileHeader::GetReferenceBy(u16 typeId) const { + for (int i {0}; i < BlockCount; ++i) { + if (toBlocks[i].IsValidTypeId(typeId)) { + return &toBlocks[i]; + } + } + + return nullptr; } } // namespace nn::atk::detail \ No newline at end of file From 7cb5596dd8e9c6dda85f434613726983ee7a07cf Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 31 Aug 2026 15:06:50 -0400 Subject: [PATCH 441/785] atk: Match `GroupFile::FileHeader::GetInfoBlock` --- include/nn/atk/atk_GroupFile.h | 63 ++++++++++++++----- include/nn/atk/atk_WaveArchiveFile.h | 2 +- src/NintendoWare/atk/detail/atk_GroupFile.cpp | 10 +++ 3 files changed, 59 insertions(+), 16 deletions(-) diff --git a/include/nn/atk/atk_GroupFile.h b/include/nn/atk/atk_GroupFile.h index 1d2f5dea..8a7ecbd0 100644 --- a/include/nn/atk/atk_GroupFile.h +++ b/include/nn/atk/atk_GroupFile.h @@ -8,15 +8,26 @@ struct GroupFile { struct FileBlock; struct InfoExBlock; struct FileHeader : Util::SoundFileHeader { - - InfoBlock* GetInfoBlock() const; - FileBlock* GetFileBlock() const; - InfoExBlock* GetInfoExBlock() const; - + const InfoBlock* GetInfoBlock() const; + const FileBlock* GetFileBlock() const; + const InfoExBlock* GetInfoExBlock() const; }; + struct GroupItemInfo; struct InfoBlockBody { Util::ReferenceTable referenceTableOfGroupItemInfo; + + u32 GetGroupItemInfoCount() const { + return referenceTableOfGroupItemInfo.count; + } + + const GroupItemInfo* GetGroupItemInfo(u32 index) const { + if (GetGroupItemInfoCount() <= index) + return nullptr; + + return util::ConstBytePtr(this, referenceTableOfGroupItemInfo.item[index].offset) + .Get(); + } }; struct InfoBlock { @@ -24,15 +35,46 @@ struct GroupFile { InfoBlockBody body; }; - struct FileBlockBody {/* unknown structure */}; + struct FileBlockBody; + struct GroupItemInfo { + u32 fileId; + Util::ReferenceWithSize embeddedItemInfo; + + static const u32 OffsetForLink {0xffffffff}; + static const u32 SizeForLink {0xffffffff}; + + const void* GetFileLocation(const FileBlockBody* fileBlockBody) const { + // TODO: check if this is int or u32 comparison + if (static_cast(embeddedItemInfo.offset) == OffsetForLink) + return nullptr; + + return util::ConstBytePtr(fileBlockBody, embeddedItemInfo.offset).Get(); + } + }; + static_assert(sizeof(GroupItemInfo) == 0x10); + + struct FileBlockBody {/* empty structure */}; struct FileBlock { BinaryBlockHeader header; FileBlockBody body; }; + struct GroupItemInfoEx; struct InfoExBlockBody { Util::ReferenceTable referenceTableOfGroupItemInfoEx; + + u32 GetGroupItemInfoExCount() const { + return referenceTableOfGroupItemInfoEx.count; + } + + const GroupItemInfoEx* GetGroupItemInfoEx(u32 index) const { + if (GetGroupItemInfoExCount() <= index) + return nullptr; + + return util::ConstBytePtr(this, referenceTableOfGroupItemInfoEx.item[index].offset) + .Get(); + } }; struct InfoExBlock { @@ -40,15 +82,6 @@ struct GroupFile { InfoExBlockBody body; }; - struct GroupItemInfo { - constexpr static s32 OffsetForLink = -1; - constexpr static s32 SizeForLink = -1; - - u32 fileId; - Util::ReferenceWithSize embeddedItemInfo; - }; - static_assert(sizeof(GroupItemInfo) == 0x10); - struct GroupItemInfoEx { u32 itemId; u32 loadFlag; diff --git a/include/nn/atk/atk_WaveArchiveFile.h b/include/nn/atk/atk_WaveArchiveFile.h index 0b31597c..f4128df4 100644 --- a/include/nn/atk/atk_WaveArchiveFile.h +++ b/include/nn/atk/atk_WaveArchiveFile.h @@ -47,7 +47,7 @@ struct WaveArchiveFile { InfoBlockBody body; }; - struct FileBlockBody { }; + struct FileBlockBody {/* empty structure */}; struct FileBlock { BinaryBlockHeader header; diff --git a/src/NintendoWare/atk/detail/atk_GroupFile.cpp b/src/NintendoWare/atk/detail/atk_GroupFile.cpp index e69de29b..43a18312 100644 --- a/src/NintendoWare/atk/detail/atk_GroupFile.cpp +++ b/src/NintendoWare/atk/detail/atk_GroupFile.cpp @@ -0,0 +1,10 @@ +#include + +#include + +namespace nn::atk::detail { +const GroupFile::InfoBlock* GroupFile::FileHeader::GetInfoBlock() const { + return util::ConstBytePtr(GetBlock(ElementType_GroupFile_InfoBlock)) + .Get(); +} +} // namespace nn::atk::detail \ No newline at end of file From 96bb1c775ac45035575e3e7fc28a09401a9590a6 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 31 Aug 2026 15:07:30 -0400 Subject: [PATCH 442/785] atk: Match `GroupFile::FileHeader::GetFileBlock` --- src/NintendoWare/atk/detail/atk_GroupFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_GroupFile.cpp b/src/NintendoWare/atk/detail/atk_GroupFile.cpp index 43a18312..b47aaa89 100644 --- a/src/NintendoWare/atk/detail/atk_GroupFile.cpp +++ b/src/NintendoWare/atk/detail/atk_GroupFile.cpp @@ -7,4 +7,9 @@ const GroupFile::InfoBlock* GroupFile::FileHeader::GetInfoBlock() const { return util::ConstBytePtr(GetBlock(ElementType_GroupFile_InfoBlock)) .Get(); } + +const GroupFile::FileBlock* GroupFile::FileHeader::GetFileBlock() const { + return util::ConstBytePtr(GetBlock(ElementType_GroupFile_FileBlock)) + .Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 1927b8a0a78cbc9f6844ebcb938a49f42558d3bc Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 31 Aug 2026 15:08:01 -0400 Subject: [PATCH 443/785] atk: Match `GroupFile::FileHeader::GetInfoExBlock` This matches all exported functions in `GroupFile` --- src/NintendoWare/atk/detail/atk_GroupFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_GroupFile.cpp b/src/NintendoWare/atk/detail/atk_GroupFile.cpp index b47aaa89..92ff37cb 100644 --- a/src/NintendoWare/atk/detail/atk_GroupFile.cpp +++ b/src/NintendoWare/atk/detail/atk_GroupFile.cpp @@ -12,4 +12,9 @@ const GroupFile::FileBlock* GroupFile::FileHeader::GetFileBlock() const { return util::ConstBytePtr(GetBlock(ElementType_GroupFile_FileBlock)) .Get(); } + +const GroupFile::InfoExBlock* GroupFile::FileHeader::GetInfoExBlock() const { + return util::ConstBytePtr(GetBlock(ElementType_GroupFile_InfoExBlock)) + .Get(); +} } // namespace nn::atk::detail \ No newline at end of file From 2aad3639855b9375e7a567e35de1fecdf7480456 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 31 Aug 2026 17:19:18 -0400 Subject: [PATCH 444/785] atk: Match `StreamBufferPool::Initialize` --- include/nn/atk/atk_StreamBufferPool.h | 14 +++++++------ include/nn/util/util_BitUtil.h | 6 ++++++ .../atk/detail/strm/atk_StreamBufferPool.cpp | 20 +++++++++++++++++++ 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/include/nn/atk/atk_StreamBufferPool.h b/include/nn/atk/atk_StreamBufferPool.h index e22a8cbb..9e44fbbc 100644 --- a/include/nn/atk/atk_StreamBufferPool.h +++ b/include/nn/atk/atk_StreamBufferPool.h @@ -5,21 +5,23 @@ namespace nn::atk::detail::driver { class StreamBufferPool { public: - constexpr static u32 BlockMax = 32; - constexpr static u8 BitPerByte = 8; - - void Initialize(void* buffer, size_t size, s32 blockCount); + void Initialize(void* buffer, size_t size, int blockCount); void Finalize(); void* Alloc(); void Free(void* pPtr); + size_t GetBlockSize() const { return m_BlockSize; } + private: + static const int BlockMax {32}; + static const int BitPerByte {8}; + void* m_Buffer; size_t m_BufferSize; size_t m_BlockSize; - s32 m_BlockCount; - s32 m_AllocCount; + int m_BlockCount; + int m_AllocCount; u8 m_AllocFlags[BlockMax / BitPerByte]; }; static_assert(sizeof(StreamBufferPool) == 0x28); diff --git a/include/nn/util/util_BitUtil.h b/include/nn/util/util_BitUtil.h index 8fdf58c7..51dc2ed9 100644 --- a/include/nn/util/util_BitUtil.h +++ b/include/nn/util/util_BitUtil.h @@ -11,4 +11,10 @@ T align_up(T x, size_t align) { return (x + mask) & ~mask; } +template +T align_down(T x, size_t align) { + typedef typename detail::MakeUnsigned::Type UIntType; + UIntType mask = align - 1; + return x & ~mask; +} } // namespace nn::util \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamBufferPool.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamBufferPool.cpp index e69de29b..3974f68e 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamBufferPool.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamBufferPool.cpp @@ -0,0 +1,20 @@ +#include + +#include + +namespace nn::atk::detail::driver { +void StreamBufferPool::Initialize(void* buffer, size_t size, int blockCount) { + if (blockCount == 0) + return; + + Util::IsValidMemoryForDsp(buffer, size); + + m_Buffer = buffer; + m_BufferSize = size; + m_BlockCount = blockCount; + m_BlockSize = util::align_down(size / blockCount, 64); + m_AllocCount = 0; + for (int i {0}; i < BlockMax / BitPerByte; ++i) + m_AllocFlags[i] = 0; +} +} // namespace nn::atk::detail::driver \ No newline at end of file From a77a6ed0a07047c924d359749f74b7e155bb9714 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 31 Aug 2026 17:20:16 -0400 Subject: [PATCH 445/785] atk: Match `StreamBufferPool::Finalize` --- src/NintendoWare/atk/detail/strm/atk_StreamBufferPool.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamBufferPool.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamBufferPool.cpp index 3974f68e..3d7ac9cf 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamBufferPool.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamBufferPool.cpp @@ -17,4 +17,11 @@ void StreamBufferPool::Initialize(void* buffer, size_t size, int blockCount) { for (int i {0}; i < BlockMax / BitPerByte; ++i) m_AllocFlags[i] = 0; } + +void StreamBufferPool::Finalize() { + m_Buffer = nullptr; + m_BufferSize = 0; + m_BlockSize = 0; + m_BlockCount = 0; +} } // namespace nn::atk::detail::driver \ No newline at end of file From 1d5aa0a428d706b787439b367c56e47954eb21a9 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 31 Aug 2026 18:15:09 -0400 Subject: [PATCH 446/785] atk: Match `StreamBufferPool::Free` --- .../atk/detail/strm/atk_StreamBufferPool.cpp | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamBufferPool.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamBufferPool.cpp index 3d7ac9cf..fc01b1c8 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamBufferPool.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamBufferPool.cpp @@ -1,6 +1,7 @@ #include #include +#include "nn/types.h" namespace nn::atk::detail::driver { void StreamBufferPool::Initialize(void* buffer, size_t size, int blockCount) { @@ -24,4 +25,42 @@ void StreamBufferPool::Finalize() { m_BlockSize = 0; m_BlockCount = 0; } + +// WIP +void* StreamBufferPool::Alloc() { + if (m_AllocCount >= m_BlockCount) + return nullptr; + + const int availableByte {util::align_up(m_BlockCount, BitPerByte)}; + + for (int byteIndex {0}; byteIndex < availableByte / BitPerByte; ++byteIndex) { + if (m_AllocFlags[byteIndex] != 0xff) { + const u8 byte {m_AllocFlags[byteIndex]}; + + u8 mask {1 << 0}; + for (int bitIndex {0}; bitIndex < BitPerByte; ++bitIndex) { + if ((byte & mask) == 0) { + const int totalIndex {bitIndex}; + void* buffer {util::BytePtr(m_Buffer).Advance(m_BlockSize * (totalIndex | byte)).Get()}; + return buffer; + } + } + } + } + + return nullptr; +} + +void StreamBufferPool::Free(void* pPtr) { + ptrdiff_t offset {util::BytePtr(m_Buffer).Distance(pPtr)}; + + const u64 totalIndex {offset / m_BlockSize}; + + const int mask {1 << (totalIndex & 0b111)}; + const u64 byteIndex {totalIndex}; + const u64 bitIndex {byteIndex / BitPerByte}; + + m_AllocFlags[bitIndex] &= ~mask; + --m_AllocCount; +} } // namespace nn::atk::detail::driver \ No newline at end of file From 2c249f23639535bad047b59d2a46c1da647121be Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 31 Aug 2026 18:29:32 -0400 Subject: [PATCH 447/785] atk: Match `driver::StreamChannel::AppendWaveBuffer` --- include/nn/atk/atk_StreamTrack.h | 10 ++++++---- src/NintendoWare/atk/detail/strm/atk_StreamTrack.cpp | 8 ++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/nn/atk/atk_StreamTrack.h b/include/nn/atk/atk_StreamTrack.h index 3f2eb87b..6e132d69 100644 --- a/include/nn/atk/atk_StreamTrack.h +++ b/include/nn/atk/atk_StreamTrack.h @@ -1,13 +1,15 @@ #pragma once +#include + #include +#include namespace nn::atk::detail::driver { -class StreamChannel { -public: +struct StreamChannel { void AppendWaveBuffer(WaveBuffer* pBuffer, bool lastFlag); + os::Tick GetProcessTick(const SoundProfile& profile); -private: void* m_pBufferAddress; MultiVoice* m_pVoice; WaveBuffer m_WaveBuffer[32]; @@ -18,7 +20,7 @@ static_assert(sizeof(StreamChannel) == 0x1080); class StreamTrack { public: - StreamTrack(); + StreamTrack() = default; ~StreamTrack(); private: diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamTrack.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamTrack.cpp index e69de29b..65ef85c1 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamTrack.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamTrack.cpp @@ -0,0 +1,8 @@ +#include + +namespace nn::atk::detail::driver { +void StreamChannel::AppendWaveBuffer(WaveBuffer* pBuffer, bool lastFlag) { + if (m_pVoice != nullptr) + m_pVoice->AppendWaveBuffer(0, pBuffer, lastFlag); +} +} // namespace nn::atk::detail::driver \ No newline at end of file From 086af34a222b797f46aee1cfd3374b6564185f2f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 31 Aug 2026 19:15:51 -0400 Subject: [PATCH 448/785] atk: Match `FsSoundArchive` constructor --- include/nn/atk/atk_ChannelMixVolume.h | 22 ++++----- include/nn/atk/atk_DeviceOutRecorder.h | 26 +++++----- include/nn/atk/atk_FsSoundArchive.h | 49 ++++++++++++------- .../nn/atk/fnd/os/atkfnd_CriticalSection.h | 3 ++ src/NintendoWare/atk/atk_FsSoundArchive.cpp | 6 +++ .../atk/submix/atk_ChannelMixVolume.cpp | 1 + .../atk/util/atk_DeviceOutRecorder.cpp | 5 ++ .../atk/util/atk_ProfileReader.cpp | 5 ++ 8 files changed, 75 insertions(+), 42 deletions(-) diff --git a/include/nn/atk/atk_ChannelMixVolume.h b/include/nn/atk/atk_ChannelMixVolume.h index 17ad816d..d2b081e3 100644 --- a/include/nn/atk/atk_ChannelMixVolume.h +++ b/include/nn/atk/atk_ChannelMixVolume.h @@ -5,25 +5,25 @@ namespace nn::atk { class ChannelMixVolume { public: - constexpr static u8 ChannelCountMax = 24; + static const int ChannelCountMax = 24; ChannelMixVolume(); + explicit ChannelMixVolume(const MixVolume& mixVolume); + ChannelMixVolume(const float* pVolume, int volumeCount); - void InitializeChannelVolume(); + bool SetChannelCount(int channelCount); + int GetChannelCount() const; - explicit ChannelMixVolume(const MixVolume& mixVolume); - ChannelMixVolume(const f32* channelVolumes, s32 channelCount); + bool SetChannelVolume(int channelIndex, float volume); + float GetChannelVolume(int channelIndex) const; - bool SetChannelCount(s32 channelCount); - - bool SetChannelVolume(s32 channel, f32 volume); - f32 GetChannelVolume(s32 channel) const; + bool SetChannelVolume(int channelIndex, const float* pVolume, int volumeCount); - bool SetChannelVolume(s32 channel, const f32*, s32); + void InitializeChannelVolume(); private: - s32 m_ChannelCount; - f32 m_ChannelVolume[ChannelCountMax]; + int m_ChannelCount; + float m_ChannelVolume[ChannelCountMax]; }; static_assert(sizeof(ChannelMixVolume) == 0x64); } // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/atk_DeviceOutRecorder.h b/include/nn/atk/atk_DeviceOutRecorder.h index 2940b54b..485af6ec 100644 --- a/include/nn/atk/atk_DeviceOutRecorder.h +++ b/include/nn/atk/atk_DeviceOutRecorder.h @@ -103,13 +103,13 @@ class DeviceOutRecorder : public detail::fnd::Thread::Handler { void Write(const s16* sampleBuffer, u32 samples); u32 IncrementPosition(u32 position, u32 length) const; - s16* m_SampleBuffer; - u32 m_MaxBufferSamples; - u32 m_MaxSamples; - std::atomic_uint m_ValidSamples; - u32 m_ReadPosition; - u32 m_WritePosition; - u32 m_ReadBlockSamples; + s16* m_SampleBuffer {nullptr}; + u32 m_MaxBufferSamples {0}; + u32 m_MaxSamples {0}; + std::atomic_uint m_ValidSamples {0}; + u32 m_ReadPosition {0}; + u32 m_WritePosition {0}; + u32 m_ReadBlockSamples {1}; WriteState m_WriteState; const char* m_DeviceName; }; @@ -178,12 +178,12 @@ class DeviceOutRecorder : public detail::fnd::Thread::Handler { void OnExit(); bool OnWriteSamples(bool isForceWriteMode); - volatile State m_State; - u32 m_Channels; - OutputMode m_OutputMode; - bool m_IsLeadSilenceTrimming; - u32 m_MaxSamples; - u32 m_WrittenSamples; + volatile State m_State {State_NotInitialized}; + u32 m_Channels {0}; + OutputMode m_OutputMode {OutputMode_Stereo}; + bool m_IsLeadSilenceTrimming {false}; + u32 m_MaxSamples {0}; + u32 m_WrittenSamples {0}; detail::fnd::Thread m_Thread; void* m_ThreadStack; os::MessageQueue m_MessageQueue; diff --git a/include/nn/atk/atk_FsSoundArchive.h b/include/nn/atk/atk_FsSoundArchive.h index 5722a110..e515ed41 100644 --- a/include/nn/atk/atk_FsSoundArchive.h +++ b/include/nn/atk/atk_FsSoundArchive.h @@ -6,46 +6,59 @@ #include namespace nn::atk { -class FsSoundArchive : SoundArchive { +class FsSoundArchive : public SoundArchive { public: - enum FileAccessMode { - FileAccessMode_Always, - FileAccessMode_InFunction - }; + static const int BufferAlignSize {64}; - constexpr static u32 BufferAlignSize = 64; + struct OpenArg { + + }; FsSoundArchive(); ~FsSoundArchive() override; - void Close(); bool Open(const char* path); + bool Open(const char* path, const OpenArg* arg); + void Close(); - bool LoadFileHeader(); + size_t GetHeaderSize() const; - detail::fnd::FileStream* OpenStream(void* buffer, size_t size, - position_t begin, size_t length) const override; + bool LoadHeader(void* buffer, size_t size); - detail::fnd::FileStream* OpenExtStream(void* buffer, size_t size, const char* extFilePath, - void* cacheBuffer, size_t cacheSize) const override; + size_t GetLabelStringDataSize() const; + + bool LoadLabelStringData(void* buffer, size_t size); size_t detail_GetRequiredStreamBufferSize() const override; + const void* detail_GetFileAddress(ItemId itemId) const override; - bool LoadHeader(void* buffer, size_t size); - bool LoadLabelStringData(void* buffer, size_t size); + enum FileAccessMode { + FileAccessMode_Always, + FileAccessMode_InFunction + }; + + void SetFileAccessMode(FileAccessMode value); + FileAccessMode GetFileAccessMode() const; void FileAccessBegin() const override; void FileAccessEnd() const override; - void* detail_GetFileAddress(ItemId itemId) override; +protected: + detail::fnd::FileStream* OpenStream(void* buffer, size_t size, + position_t begin, size_t length) const override; + + detail::fnd::FileStream* OpenExtStream(void* buffer, size_t size, const char* extFilePath, + void* cacheBuffer, size_t cacheSize) const override; + + bool LoadFileHeader(); private: detail::SoundArchiveFileReader m_ArchiveReader; detail::fnd::FileStreamImpl m_FileStream; - bool m_IsOpened; - u8 m_FileAccessMode; + bool m_IsOpened {false}; + u8 m_FileAccessMode {FileAccessMode_Always}; u8 m_Padding[2]; - u32 m_FileAccessCount; + u32 m_FileAccessCount {0}; char m_SoundArchiveFullPath[SoundArchive::FilePathMax]; detail::fnd::CriticalSection m_FileOpenCloseLock; }; diff --git a/include/nn/atk/fnd/os/atkfnd_CriticalSection.h b/include/nn/atk/fnd/os/atkfnd_CriticalSection.h index 5f6a7636..efb60a44 100644 --- a/include/nn/atk/fnd/os/atkfnd_CriticalSection.h +++ b/include/nn/atk/fnd/os/atkfnd_CriticalSection.h @@ -5,6 +5,9 @@ namespace nn::atk::detail::fnd { class CriticalSection { public: + CriticalSection() + : m_Mutex(true) {} + void lock(); bool tryLock(); void unlock(); diff --git a/src/NintendoWare/atk/atk_FsSoundArchive.cpp b/src/NintendoWare/atk/atk_FsSoundArchive.cpp index e69de29b..eb722009 100644 --- a/src/NintendoWare/atk/atk_FsSoundArchive.cpp +++ b/src/NintendoWare/atk/atk_FsSoundArchive.cpp @@ -0,0 +1,6 @@ +#include + +namespace nn::atk { +FsSoundArchive::FsSoundArchive() = default; +} // namespace nn::atk + diff --git a/src/NintendoWare/atk/submix/atk_ChannelMixVolume.cpp b/src/NintendoWare/atk/submix/atk_ChannelMixVolume.cpp index e69de29b..d6785e88 100644 --- a/src/NintendoWare/atk/submix/atk_ChannelMixVolume.cpp +++ b/src/NintendoWare/atk/submix/atk_ChannelMixVolume.cpp @@ -0,0 +1 @@ +#include \ No newline at end of file diff --git a/src/NintendoWare/atk/util/atk_DeviceOutRecorder.cpp b/src/NintendoWare/atk/util/atk_DeviceOutRecorder.cpp index e69de29b..cc3866ed 100644 --- a/src/NintendoWare/atk/util/atk_DeviceOutRecorder.cpp +++ b/src/NintendoWare/atk/util/atk_DeviceOutRecorder.cpp @@ -0,0 +1,5 @@ +#include + +namespace nn::atk { + +} // namespace nn::atk \ No newline at end of file diff --git a/src/NintendoWare/atk/util/atk_ProfileReader.cpp b/src/NintendoWare/atk/util/atk_ProfileReader.cpp index e69de29b..37e72087 100644 --- a/src/NintendoWare/atk/util/atk_ProfileReader.cpp +++ b/src/NintendoWare/atk/util/atk_ProfileReader.cpp @@ -0,0 +1,5 @@ +#include + +namespace nn::atk { + +} // namespace nn::atk \ No newline at end of file From da848865ffbfe260f91638570d513cc20d00cac5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 31 Aug 2026 20:06:56 -0400 Subject: [PATCH 449/785] atk: Match `FsSoundArchive::Close` --- .../nn/atk/fnd/os/atkfnd_CriticalSection.h | 29 +++++++++++++++++-- include/nn/atk/fnd/os/atkfnd_ScopedLock.h | 20 +++++++++++-- src/NintendoWare/atk/atk_FsSoundArchive.cpp | 13 +++++++++ 3 files changed, 57 insertions(+), 5 deletions(-) diff --git a/include/nn/atk/fnd/os/atkfnd_CriticalSection.h b/include/nn/atk/fnd/os/atkfnd_CriticalSection.h index efb60a44..c1c76506 100644 --- a/include/nn/atk/fnd/os/atkfnd_CriticalSection.h +++ b/include/nn/atk/fnd/os/atkfnd_CriticalSection.h @@ -8,9 +8,32 @@ class CriticalSection { CriticalSection() : m_Mutex(true) {} - void lock(); - bool tryLock(); - void unlock(); + ~CriticalSection(); + + void Enter() { + // TODO + } + + bool TryEnter() { + // TODO + return true; + } + + void Leave() { + // TODO + } + + void Lock() { + m_Mutex.Lock(); + } + + bool TryLock() { + return m_Mutex.TryLock(); + } + + void Unlock() { + m_Mutex.Unlock(); + } private: os::Mutex m_Mutex; diff --git a/include/nn/atk/fnd/os/atkfnd_ScopedLock.h b/include/nn/atk/fnd/os/atkfnd_ScopedLock.h index 2f972fd2..4ac0e72a 100644 --- a/include/nn/atk/fnd/os/atkfnd_ScopedLock.h +++ b/include/nn/atk/fnd/os/atkfnd_ScopedLock.h @@ -1,9 +1,25 @@ #pragma once +#include + namespace nn::atk::detail::fnd { -template +template class ScopedLock { + NN_NO_COPY(ScopedLock); + public: - LockObj* m_LockObj; + explicit ScopedLock(TLockObject& lockObj) + : m_LockObj(lockObj) + { + m_LockObj.Lock(); + } + + ~ScopedLock() + { + m_LockObj.Unlock(); + } + +private: + TLockObject& m_LockObj; }; } // namespace nn::atk::detail::fnd \ No newline at end of file diff --git a/src/NintendoWare/atk/atk_FsSoundArchive.cpp b/src/NintendoWare/atk/atk_FsSoundArchive.cpp index eb722009..dbca85d9 100644 --- a/src/NintendoWare/atk/atk_FsSoundArchive.cpp +++ b/src/NintendoWare/atk/atk_FsSoundArchive.cpp @@ -1,6 +1,19 @@ #include +#include "nn/atk/fnd/io/atkfnd_FileStream.h" +#include "nn/atk/fnd/os/atkfnd_ScopedLock.h" namespace nn::atk { FsSoundArchive::FsSoundArchive() = default; + +void FsSoundArchive::Close() { + FileAccessBegin(); + + if (m_IsOpened) { + m_FileStream.Close(); + m_IsOpened = false; + } + + Finalize(); +} } // namespace nn::atk From 82a5bafe0db0ffa68e46707bc5e933746a026131 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 31 Aug 2026 20:57:44 -0400 Subject: [PATCH 450/785] atk: Match `FsSoundArchive::FileAccessBegin` --- src/NintendoWare/atk/atk_FsSoundArchive.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/atk_FsSoundArchive.cpp b/src/NintendoWare/atk/atk_FsSoundArchive.cpp index dbca85d9..ff368265 100644 --- a/src/NintendoWare/atk/atk_FsSoundArchive.cpp +++ b/src/NintendoWare/atk/atk_FsSoundArchive.cpp @@ -15,5 +15,15 @@ void FsSoundArchive::Close() { Finalize(); } + +void FsSoundArchive::FileAccessBegin() const { + if (m_FileAccessMode == FileAccessMode_InFunction) { + auto lock = detail::fnd::ScopedLock{const_cast(this)->m_FileOpenCloseLock}; + if (m_FileAccessCount == 0) + const_cast(this)->m_FileStream.Open(m_SoundArchiveFullPath, detail::fnd::FileStream::AccessMode_Read); + + const_cast(this)->m_FileAccessCount++; + } +} } // namespace nn::atk From 3c27f78e240d043d855df74de242ad24abf36aa8 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 31 Aug 2026 21:02:48 -0400 Subject: [PATCH 451/785] atk: Match `FsSoundArchive` destructor --- include/nn/atk/atk_FsSoundArchive.h | 6 +++--- include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h | 6 +++--- include/nn/atk/fnd/io/atkfnd_Stream.h | 2 +- include/nn/atk/fnd/io/atkfnd_StreamCache.h | 2 +- include/nn/atk/fnd/os/atkfnd_CriticalSection.h | 2 +- src/NintendoWare/atk/atk_FsSoundArchive.cpp | 14 +++++++++----- src/NintendoWare/atk/fnd/io/atkfnd_StreamCache.cpp | 5 +++++ 7 files changed, 23 insertions(+), 14 deletions(-) diff --git a/include/nn/atk/atk_FsSoundArchive.h b/include/nn/atk/atk_FsSoundArchive.h index e515ed41..b89173cf 100644 --- a/include/nn/atk/atk_FsSoundArchive.h +++ b/include/nn/atk/atk_FsSoundArchive.h @@ -54,13 +54,13 @@ class FsSoundArchive : public SoundArchive { private: detail::SoundArchiveFileReader m_ArchiveReader; - detail::fnd::FileStreamImpl m_FileStream; + mutable detail::fnd::FileStreamImpl m_FileStream; bool m_IsOpened {false}; u8 m_FileAccessMode {FileAccessMode_Always}; u8 m_Padding[2]; - u32 m_FileAccessCount {0}; + mutable u32 m_FileAccessCount {0}; char m_SoundArchiveFullPath[SoundArchive::FilePathMax]; - detail::fnd::CriticalSection m_FileOpenCloseLock; + mutable detail::fnd::CriticalSection m_FileOpenCloseLock; }; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(FsSoundArchive) == 0x618); diff --git a/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h b/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h index 755e4d16..a8a8970c 100644 --- a/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h +++ b/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h @@ -49,10 +49,10 @@ class FileStreamImpl : public FileStream { } position_t GetCurrentPosition() const override { - return m_Owner->GetCurrentPosition(); + return m_Owner->m_CurrentPosition; } - ~DirectStream() override; + ~DirectStream() override = default; private: friend FileStreamImpl; @@ -63,7 +63,7 @@ class FileStreamImpl : public FileStream { FileStreamImpl(); explicit FileStreamImpl(void*); - ~FileStreamImpl() override; + ~FileStreamImpl() override = default; FndResult Open(const char* filePath, AccessMode accessMode) override; void Close() override; diff --git a/include/nn/atk/fnd/io/atkfnd_Stream.h b/include/nn/atk/fnd/io/atkfnd_Stream.h index 9d003cb5..7d92f007 100644 --- a/include/nn/atk/fnd/io/atkfnd_Stream.h +++ b/include/nn/atk/fnd/io/atkfnd_Stream.h @@ -19,7 +19,7 @@ class Stream { SeekOrigin_Current, }; - virtual ~Stream(); + virtual ~Stream() = default; protected: Stream() = default; diff --git a/include/nn/atk/fnd/io/atkfnd_StreamCache.h b/include/nn/atk/fnd/io/atkfnd_StreamCache.h index 9346b44c..bae12330 100644 --- a/include/nn/atk/fnd/io/atkfnd_StreamCache.h +++ b/include/nn/atk/fnd/io/atkfnd_StreamCache.h @@ -35,7 +35,7 @@ class StreamCache { FndResult Seek(position_t offset, Stream::SeekOrigin origin); - virtual ~StreamCache(); + virtual ~StreamCache() = default; private: Stream* m_Stream{}; diff --git a/include/nn/atk/fnd/os/atkfnd_CriticalSection.h b/include/nn/atk/fnd/os/atkfnd_CriticalSection.h index c1c76506..90d98a71 100644 --- a/include/nn/atk/fnd/os/atkfnd_CriticalSection.h +++ b/include/nn/atk/fnd/os/atkfnd_CriticalSection.h @@ -8,7 +8,7 @@ class CriticalSection { CriticalSection() : m_Mutex(true) {} - ~CriticalSection(); + ~CriticalSection() = default; void Enter() { // TODO diff --git a/src/NintendoWare/atk/atk_FsSoundArchive.cpp b/src/NintendoWare/atk/atk_FsSoundArchive.cpp index ff368265..ce491b69 100644 --- a/src/NintendoWare/atk/atk_FsSoundArchive.cpp +++ b/src/NintendoWare/atk/atk_FsSoundArchive.cpp @@ -1,10 +1,14 @@ #include -#include "nn/atk/fnd/io/atkfnd_FileStream.h" -#include "nn/atk/fnd/os/atkfnd_ScopedLock.h" + +#include namespace nn::atk { FsSoundArchive::FsSoundArchive() = default; +FsSoundArchive::~FsSoundArchive() { + Close(); +} + void FsSoundArchive::Close() { FileAccessBegin(); @@ -18,11 +22,11 @@ void FsSoundArchive::Close() { void FsSoundArchive::FileAccessBegin() const { if (m_FileAccessMode == FileAccessMode_InFunction) { - auto lock = detail::fnd::ScopedLock{const_cast(this)->m_FileOpenCloseLock}; + auto lock = detail::fnd::ScopedLock{m_FileOpenCloseLock}; if (m_FileAccessCount == 0) - const_cast(this)->m_FileStream.Open(m_SoundArchiveFullPath, detail::fnd::FileStream::AccessMode_Read); + m_FileStream.Open(m_SoundArchiveFullPath, detail::fnd::FileStream::AccessMode_Read); - const_cast(this)->m_FileAccessCount++; + ++m_FileAccessCount; } } } // namespace nn::atk diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_StreamCache.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_StreamCache.cpp index e69de29b..ad3da737 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_StreamCache.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_StreamCache.cpp @@ -0,0 +1,5 @@ +#include + +namespace nn::atk::detail::fnd { + +} // namespace nn::atk::detail::fnd \ No newline at end of file From d124760a11af50de2d7e593fd26a528dd22eb7d5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 12:34:40 -0400 Subject: [PATCH 452/785] atk: Match `FsSoundArchive::LoadHeader` --- include/nn/atk/atk_SoundArchiveFileReader.h | 4 ++++ src/NintendoWare/atk/atk_FsSoundArchive.cpp | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/nn/atk/atk_SoundArchiveFileReader.h b/include/nn/atk/atk_SoundArchiveFileReader.h index ff41f286..f995197a 100644 --- a/include/nn/atk/atk_SoundArchiveFileReader.h +++ b/include/nn/atk/atk_SoundArchiveFileReader.h @@ -63,8 +63,12 @@ class SoundArchiveFileReader { bool ReadSoundUserParam(u32*, u32, s32) const; const detail::Util::Table* GetAttachedGroupTable(u32) const; + int GetInfoBlockOffset() const { return m_Header.GetInfoBlockOffset(); } int GetFileBlockOffset() const { return m_Header.GetFileBlockOffset(); } + u32 GetInfoBlockSize() const { return m_Header.GetInfoBlockSize(); } + u32 GetFileBlockSize() const { return m_Header.GetFileBlockSize(); } + private: friend SoundArchive; diff --git a/src/NintendoWare/atk/atk_FsSoundArchive.cpp b/src/NintendoWare/atk/atk_FsSoundArchive.cpp index ce491b69..bed6525c 100644 --- a/src/NintendoWare/atk/atk_FsSoundArchive.cpp +++ b/src/NintendoWare/atk/atk_FsSoundArchive.cpp @@ -20,6 +20,25 @@ void FsSoundArchive::Close() { Finalize(); } +bool FsSoundArchive::LoadHeader(void* buffer, size_t size) { + const s32 infoChunkOffset {m_ArchiveReader.GetInfoBlockOffset()}; + const u32 infoChunkSize {m_ArchiveReader.GetInfoBlockSize()}; + + if (size >= infoChunkSize) { + FileAccessBegin(); + m_FileStream.Seek(infoChunkOffset, detail::fnd::Stream::SeekOrigin_Begin); + size_t readSize {m_FileStream.Read(buffer, infoChunkSize, nullptr)}; + + if (readSize == infoChunkSize) { + FileAccessEnd(); + m_ArchiveReader.SetInfoBlock(buffer); + return true; + } + } + + return false; +} + void FsSoundArchive::FileAccessBegin() const { if (m_FileAccessMode == FileAccessMode_InFunction) { auto lock = detail::fnd::ScopedLock{m_FileOpenCloseLock}; From 828189a6751afa441d19ce76291302373bf2d0a6 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 12:57:11 -0400 Subject: [PATCH 453/785] atk: Match `FsSoundArchive::LoadLabelStringData` --- include/nn/atk/atk_SoundArchiveFileReader.h | 2 ++ src/NintendoWare/atk/atk_FsSoundArchive.cpp | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/nn/atk/atk_SoundArchiveFileReader.h b/include/nn/atk/atk_SoundArchiveFileReader.h index f995197a..404556e2 100644 --- a/include/nn/atk/atk_SoundArchiveFileReader.h +++ b/include/nn/atk/atk_SoundArchiveFileReader.h @@ -65,9 +65,11 @@ class SoundArchiveFileReader { int GetInfoBlockOffset() const { return m_Header.GetInfoBlockOffset(); } int GetFileBlockOffset() const { return m_Header.GetFileBlockOffset(); } + int GetStringBlockOffset() const { return m_Header.GetStringBlockOffset(); } u32 GetInfoBlockSize() const { return m_Header.GetInfoBlockSize(); } u32 GetFileBlockSize() const { return m_Header.GetFileBlockSize(); } + u32 GetStringBlockSize() const { return m_Header.GetStringBlockSize(); } private: friend SoundArchive; diff --git a/src/NintendoWare/atk/atk_FsSoundArchive.cpp b/src/NintendoWare/atk/atk_FsSoundArchive.cpp index bed6525c..f359980b 100644 --- a/src/NintendoWare/atk/atk_FsSoundArchive.cpp +++ b/src/NintendoWare/atk/atk_FsSoundArchive.cpp @@ -39,6 +39,25 @@ bool FsSoundArchive::LoadHeader(void* buffer, size_t size) { return false; } +bool FsSoundArchive::LoadLabelStringData(void* buffer, size_t size) { + const s32 stringBlockOffset {m_ArchiveReader.GetStringBlockOffset()}; + const u32 stringBlockSize {m_ArchiveReader.GetStringBlockSize()}; + + if (stringBlockOffset != detail::Util::Reference::InvalidOffset && size >= stringBlockSize) { + FileAccessBegin(); + m_FileStream.Seek(stringBlockOffset, detail::fnd::Stream::SeekOrigin_Begin); + size_t readSize {m_FileStream.Read(buffer, stringBlockSize, nullptr)}; + + if (readSize == stringBlockSize) { + FileAccessEnd(); + m_ArchiveReader.SetStringBlock(buffer); + return true; + } + } + + return false; +} + void FsSoundArchive::FileAccessBegin() const { if (m_FileAccessMode == FileAccessMode_InFunction) { auto lock = detail::fnd::ScopedLock{m_FileOpenCloseLock}; From bb8687df9ee4acd2faebaf671ec09b2554eb2462 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 13:01:26 -0400 Subject: [PATCH 454/785] atk: Match `FsSoundArchive::detail_GetRequiredStreamBufferSize` --- src/NintendoWare/atk/atk_FsSoundArchive.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/atk_FsSoundArchive.cpp b/src/NintendoWare/atk/atk_FsSoundArchive.cpp index f359980b..f791fec2 100644 --- a/src/NintendoWare/atk/atk_FsSoundArchive.cpp +++ b/src/NintendoWare/atk/atk_FsSoundArchive.cpp @@ -58,6 +58,10 @@ bool FsSoundArchive::LoadLabelStringData(void* buffer, size_t size) { return false; } +size_t FsSoundArchive::detail_GetRequiredStreamBufferSize() const { + return 8; +} + void FsSoundArchive::FileAccessBegin() const { if (m_FileAccessMode == FileAccessMode_InFunction) { auto lock = detail::fnd::ScopedLock{m_FileOpenCloseLock}; From c4a401c959f3cf798e95434fe6e588af91edd0e0 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 13:02:15 -0400 Subject: [PATCH 455/785] atk: Match `FsSoundArchive::detail_GetFileAddress` --- src/NintendoWare/atk/atk_FsSoundArchive.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/atk_FsSoundArchive.cpp b/src/NintendoWare/atk/atk_FsSoundArchive.cpp index f791fec2..ce0a4c53 100644 --- a/src/NintendoWare/atk/atk_FsSoundArchive.cpp +++ b/src/NintendoWare/atk/atk_FsSoundArchive.cpp @@ -62,6 +62,10 @@ size_t FsSoundArchive::detail_GetRequiredStreamBufferSize() const { return 8; } +const void* FsSoundArchive::detail_GetFileAddress([[maybe_unused]] ItemId itemId) const { + return nullptr; +} + void FsSoundArchive::FileAccessBegin() const { if (m_FileAccessMode == FileAccessMode_InFunction) { auto lock = detail::fnd::ScopedLock{m_FileOpenCloseLock}; From 0d28d42e6caa6792342bad79d9721435d3a55fad Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 13:04:51 -0400 Subject: [PATCH 456/785] atk: Match `FsSoundArchive::FileAccessEnd` --- src/NintendoWare/atk/atk_FsSoundArchive.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/NintendoWare/atk/atk_FsSoundArchive.cpp b/src/NintendoWare/atk/atk_FsSoundArchive.cpp index ce0a4c53..84d7f1bc 100644 --- a/src/NintendoWare/atk/atk_FsSoundArchive.cpp +++ b/src/NintendoWare/atk/atk_FsSoundArchive.cpp @@ -75,5 +75,16 @@ void FsSoundArchive::FileAccessBegin() const { ++m_FileAccessCount; } } + +void FsSoundArchive::FileAccessEnd() const { + if (m_FileAccessMode == FileAccessMode_InFunction) { + auto lock = detail::fnd::ScopedLock{m_FileOpenCloseLock}; + if (m_FileAccessCount == 1) + m_FileStream.Close(); + + if (m_FileAccessCount != 0) + --m_FileAccessCount; + } +} } // namespace nn::atk From 83095bdcb8d35ff43b1b16e4d54eb6e1618f2b69 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 13:18:03 -0400 Subject: [PATCH 457/785] atk: Match `FileStreamProxy` constructor --- include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h | 9 +++------ src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp | 6 ++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h b/include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h index 79876280..cfb7afb9 100644 --- a/include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h +++ b/include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h @@ -3,11 +3,9 @@ #include namespace nn::atk::detail::fnd { -class FileStreamProxy : FileStream { +class FileStreamProxy : public FileStream { public: - FileStreamProxy(const FileStream& fileStream, - position_t offset, size_t fileSize); - + FileStreamProxy(FileStream* fileStream, position_t offset, size_t fileSize); ~FileStreamProxy() override; FndResult Open(const char* filePath, AccessMode openMode) override; @@ -32,14 +30,13 @@ class FileStreamProxy : FileStream { void DisableCache() override; bool IsCacheEnabled() const override; - s32 GetIoBufferAlignment() const override; + int GetIoBufferAlignment() const override; bool CanSetFsAccessLog() const override; void* SetFsAccessLog(FsAccessLog* pFsAccessLog) override; position_t GetCachePosition() override; - size_t GetCachedLength() override; private: diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp index e69de29b..224cf618 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp @@ -0,0 +1,6 @@ +#include + +namespace nn::atk::detail::fnd { +FileStreamProxy::FileStreamProxy(FileStream* fileStream, position_t offset, size_t fileSize) + : m_pFileStream{fileStream}, m_Offset{offset}, m_FileSize{fileSize} {} +} // namespace nn::atk::detail::fnd \ No newline at end of file From df5c952ce9b64dd1dae66f2daf424a5800fd75a4 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 13:18:55 -0400 Subject: [PATCH 458/785] atk: Match `FileStreamProxy` destructor --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp index 224cf618..65a49b84 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp @@ -3,4 +3,10 @@ namespace nn::atk::detail::fnd { FileStreamProxy::FileStreamProxy(FileStream* fileStream, position_t offset, size_t fileSize) : m_pFileStream{fileStream}, m_Offset{offset}, m_FileSize{fileSize} {} + +FileStreamProxy::~FileStreamProxy() { + m_Offset = 0; + m_FileSize = 0; + m_pFileStream = nullptr; +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 0d57d437de38668e3e1bfca105c6b7ba58a6e0b4 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 13:20:19 -0400 Subject: [PATCH 459/785] atk: Match `FileStreamProxy::Open` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp index 65a49b84..0c5d001e 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp @@ -9,4 +9,8 @@ FileStreamProxy::~FileStreamProxy() { m_FileSize = 0; m_pFileStream = nullptr; } + +FndResult FileStreamProxy::Open(const char* filePath, AccessMode openMode) { + return m_pFileStream->Open(filePath, openMode); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 5ef91fdf459a15affc4d87ad83c5ed145ecc67d4 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 13:20:52 -0400 Subject: [PATCH 460/785] atk: Match `FileStreamProxy::Close` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp index 0c5d001e..cf093663 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp @@ -13,4 +13,8 @@ FileStreamProxy::~FileStreamProxy() { FndResult FileStreamProxy::Open(const char* filePath, AccessMode openMode) { return m_pFileStream->Open(filePath, openMode); } + +void FileStreamProxy::Close() { + m_pFileStream->Close(); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From bab50e8544757a9f79208000dbfcb6dcb92ef5d9 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 13:21:17 -0400 Subject: [PATCH 461/785] atk: Match `FileStreamProxy::Flush` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp index cf093663..fc737458 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp @@ -17,4 +17,8 @@ FndResult FileStreamProxy::Open(const char* filePath, AccessMode openMode) { void FileStreamProxy::Close() { m_pFileStream->Close(); } + +void FileStreamProxy::Flush() { + m_pFileStream->Flush(); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 0cca9bb4f2d13a8fb606d2ed946e83137780e032 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 13:21:43 -0400 Subject: [PATCH 462/785] atk: Match `FileStreamProxy::IsOpened` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp index fc737458..aae8e8f1 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp @@ -21,4 +21,8 @@ void FileStreamProxy::Close() { void FileStreamProxy::Flush() { m_pFileStream->Flush(); } + +bool FileStreamProxy::IsOpened() const { + return m_pFileStream->IsOpened(); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 0184c2845395d9b24da4ddc488d2f945bc7076bb Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 13:22:16 -0400 Subject: [PATCH 463/785] atk: Match `FileStreamProxy::CanRead` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp index aae8e8f1..eb113973 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp @@ -25,4 +25,8 @@ void FileStreamProxy::Flush() { bool FileStreamProxy::IsOpened() const { return m_pFileStream->IsOpened(); } + +bool FileStreamProxy::CanRead() const { + return m_pFileStream->CanRead(); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 084062bc73f4df69c389b311e7034f90b80368c4 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 13:22:35 -0400 Subject: [PATCH 464/785] atk: Match `FileStreamProxy::CanWrite` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp index eb113973..12c0b69b 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp @@ -29,4 +29,8 @@ bool FileStreamProxy::IsOpened() const { bool FileStreamProxy::CanRead() const { return m_pFileStream->CanRead(); } + +bool FileStreamProxy::CanWrite() const { + return m_pFileStream->CanWrite(); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From e5b752bac441061d66bbd6be787fbe0448ed6e37 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 13:22:56 -0400 Subject: [PATCH 465/785] atk: Match `FileStreamProxy::CanSeek` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp index 12c0b69b..2d5d98be 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp @@ -33,4 +33,8 @@ bool FileStreamProxy::CanRead() const { bool FileStreamProxy::CanWrite() const { return m_pFileStream->CanWrite(); } + +bool FileStreamProxy::CanSeek() const { + return m_pFileStream->CanSeek(); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From a290a156f165c4dd4528e2465b0873b677e303d5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 13:23:25 -0400 Subject: [PATCH 466/785] atk: Match `FileStreamProxy::GetSize` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp index 2d5d98be..51da242b 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp @@ -37,4 +37,8 @@ bool FileStreamProxy::CanWrite() const { bool FileStreamProxy::CanSeek() const { return m_pFileStream->CanSeek(); } + +size_t FileStreamProxy::GetSize() const { + return m_pFileStream->GetSize(); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From f79b080d899280a3600544c2c301b0d0483d0729 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 13:24:20 -0400 Subject: [PATCH 467/785] atk: Match `FileStreamProxy::Read` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp index 51da242b..b2fe81dc 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp @@ -41,4 +41,8 @@ bool FileStreamProxy::CanSeek() const { size_t FileStreamProxy::GetSize() const { return m_pFileStream->GetSize(); } + +size_t FileStreamProxy::Read(void* buffer, size_t length, FndResult* result) { + return m_pFileStream->Read(buffer, length, result); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 1be4973a50334a9445ef2a2e975ead1946ab63f8 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 13:24:39 -0400 Subject: [PATCH 468/785] atk: Match `FileStreamProxy::Write` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp index b2fe81dc..ea6e4fab 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp @@ -45,4 +45,8 @@ size_t FileStreamProxy::GetSize() const { size_t FileStreamProxy::Read(void* buffer, size_t length, FndResult* result) { return m_pFileStream->Read(buffer, length, result); } + +size_t FileStreamProxy::Write(const void* buffer, size_t length, FndResult* result) { + return m_pFileStream->Write(buffer, length, result); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 1856764ae022d3fe041c77ed2e0eb7e9a97ee126 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 15:20:22 -0400 Subject: [PATCH 469/785] atk: Match `FileStreamProxy::GetCurrentPosition` Also added non-matching implementation for `FileStreamProxy::Seek` --- include/nn/atk/fnd/basis/atkfnd_Result.h | 10 +++---- .../atk/fnd/io/atkfnd_FileStreamProxy.cpp | 30 +++++++++++++++++++ 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/include/nn/atk/fnd/basis/atkfnd_Result.h b/include/nn/atk/fnd/basis/atkfnd_Result.h index a302dba0..ec54833d 100644 --- a/include/nn/atk/fnd/basis/atkfnd_Result.h +++ b/include/nn/atk/fnd/basis/atkfnd_Result.h @@ -5,14 +5,14 @@ namespace nn::atk::detail::fnd { enum FndResultType { FndResultType_ErrorFlagMask = 1 << 31, - FndResultType_CategoryMask = 0b1111111 << 24, - FndResultType_CodeMask = 0xffffff, + FndResultType_CategoryMask = 0b1111111 << 24, + FndResultType_CodeMask = 0xffffff, FndResultType_CategoryBitOffset = 24, - FndResultType_ErrorFlag = FndResultType_ErrorFlagMask, + FndResultType_ErrorFlag = FndResultType_ErrorFlagMask, - FndResultType_CategorySystem = 0, - FndResultType_CategoryIo = 1 << FndResultType_CategoryBitOffset, + FndResultType_CategorySystem = 0, + FndResultType_CategoryIo = 1 << FndResultType_CategoryBitOffset, FndResultType_True = FndResultType_CategorySystem, FndResultType_False, diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp index ea6e4fab..3426eb31 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp @@ -1,5 +1,7 @@ #include +#include + namespace nn::atk::detail::fnd { FileStreamProxy::FileStreamProxy(FileStream* fileStream, position_t offset, size_t fileSize) : m_pFileStream{fileStream}, m_Offset{offset}, m_FileSize{fileSize} {} @@ -49,4 +51,32 @@ size_t FileStreamProxy::Read(void* buffer, size_t length, FndResult* result) { size_t FileStreamProxy::Write(const void* buffer, size_t length, FndResult* result) { return m_pFileStream->Write(buffer, length, result); } + +// NON_MATCHING: wrong csel cond and wrong use of registers +FndResult FileStreamProxy::Seek(position_t offset, fnd::Stream::SeekOrigin origin) { + position_t fileSizeEndPosition = m_FileSize; + + switch (origin) { + case SeekOrigin_Begin: + offset = m_Offset + offset; + break; + case SeekOrigin_End: + offset = m_Offset + (fileSizeEndPosition - offset); + break; + case SeekOrigin_Current: + offset = m_pFileStream->GetCurrentPosition() + offset; + break; + default: + return FndResult{FndResultType_Failed}; + } + + offset = std::min(m_Offset + fileSizeEndPosition, offset); + offset = std::min(m_Offset, offset); + + return m_pFileStream->Seek(offset, origin); +} + +position_t FileStreamProxy::GetCurrentPosition() const { + return m_pFileStream->GetCurrentPosition(); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 35552de47d4168f143923345317a7a98f69a7eaf Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 15:20:56 -0400 Subject: [PATCH 470/785] atk: Match `FileStreamProxy::EnableCache` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp index 3426eb31..c4dc7819 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp @@ -79,4 +79,8 @@ FndResult FileStreamProxy::Seek(position_t offset, fnd::Stream::SeekOrigin origi position_t FileStreamProxy::GetCurrentPosition() const { return m_pFileStream->GetCurrentPosition(); } + +void FileStreamProxy::EnableCache(void* buffer, size_t length) { + m_pFileStream->EnableCache(buffer, length); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 084db41f2836e4665c7974899154ba15c0ce21a2 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 15:21:20 -0400 Subject: [PATCH 471/785] atk: Match `FileStreamProxy::DisableCache` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp index c4dc7819..5ab7ee3a 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp @@ -83,4 +83,8 @@ position_t FileStreamProxy::GetCurrentPosition() const { void FileStreamProxy::EnableCache(void* buffer, size_t length) { m_pFileStream->EnableCache(buffer, length); } + +void FileStreamProxy::DisableCache() { + m_pFileStream->DisableCache(); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From bc410ed125bf4409ef2860b732275d539f386d12 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 15:21:46 -0400 Subject: [PATCH 472/785] atk: Match `FileStreamProxy::IsCacheEnabled` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp index 5ab7ee3a..6cf81c74 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp @@ -87,4 +87,8 @@ void FileStreamProxy::EnableCache(void* buffer, size_t length) { void FileStreamProxy::DisableCache() { m_pFileStream->DisableCache(); } + +bool FileStreamProxy::IsCacheEnabled() const { + return m_pFileStream->IsCacheEnabled(); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 8c553ca193efc3c7e6566a46efc8a5fda209d280 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 15:22:10 -0400 Subject: [PATCH 473/785] atk: Match `FileStreamProxy::GetIoBufferAlignment` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp index 6cf81c74..45f23515 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp @@ -91,4 +91,8 @@ void FileStreamProxy::DisableCache() { bool FileStreamProxy::IsCacheEnabled() const { return m_pFileStream->IsCacheEnabled(); } + +int FileStreamProxy::GetIoBufferAlignment() const { + return m_pFileStream->GetIoBufferAlignment(); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From efe3e1b6221463d5de7581c63f6b69ee22c53f1e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 15:22:37 -0400 Subject: [PATCH 474/785] atk: Match `FileStreamProxy::CanSetFsAccessLog` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp index 45f23515..ede2f517 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp @@ -95,4 +95,8 @@ bool FileStreamProxy::IsCacheEnabled() const { int FileStreamProxy::GetIoBufferAlignment() const { return m_pFileStream->GetIoBufferAlignment(); } + +bool FileStreamProxy::CanSetFsAccessLog() const { + return m_pFileStream->CanSetFsAccessLog(); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 59135d0ede0be9bee6fef0302e5caf09b0182271 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 15:23:18 -0400 Subject: [PATCH 475/785] atk: Match `FileStreamProxy::SetFsAccessLog` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp index ede2f517..6b8c514b 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp @@ -99,4 +99,8 @@ int FileStreamProxy::GetIoBufferAlignment() const { bool FileStreamProxy::CanSetFsAccessLog() const { return m_pFileStream->CanSetFsAccessLog(); } + +void* FileStreamProxy::SetFsAccessLog(FsAccessLog* pFsAccessLog) { + return m_pFileStream->SetFsAccessLog(pFsAccessLog); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 368a2d31c847eddd1b61b3a70289035efeb2a3d3 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 15:23:42 -0400 Subject: [PATCH 476/785] atk: Match `FileStreamProxy::GetCachePosition` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp index 6b8c514b..42687bef 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp @@ -1,6 +1,7 @@ #include #include +#include "nn/atk/fnd/basis/atkfnd_Config.h" namespace nn::atk::detail::fnd { FileStreamProxy::FileStreamProxy(FileStream* fileStream, position_t offset, size_t fileSize) @@ -103,4 +104,8 @@ bool FileStreamProxy::CanSetFsAccessLog() const { void* FileStreamProxy::SetFsAccessLog(FsAccessLog* pFsAccessLog) { return m_pFileStream->SetFsAccessLog(pFsAccessLog); } + +position_t FileStreamProxy::GetCachePosition() { + return m_pFileStream->GetCachePosition(); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 5a9cb69cde83c71353dda2d2a82180fee0dcfd33 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 15:24:03 -0400 Subject: [PATCH 477/785] atk: Match `FileStreamProxy::GetCachedLength` --- src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp index 42687bef..b24c8376 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp @@ -108,4 +108,8 @@ void* FileStreamProxy::SetFsAccessLog(FsAccessLog* pFsAccessLog) { position_t FileStreamProxy::GetCachePosition() { return m_pFileStream->GetCachePosition(); } + +size_t FileStreamProxy::GetCachedLength() { + return m_pFileStream->GetCachedLength(); +} } // namespace nn::atk::detail::fnd \ No newline at end of file From 1b2b4fb427df6864437cdfca783f53c49bb22d94 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 1 Sep 2026 18:21:05 -0400 Subject: [PATCH 478/785] atk: Match `FsSoundArchive::LoadFileHeader` Also added non-matching implementations for `FsSoundArchive::OpenStream` and `FsSoundArchive::OpenExtStream` --- src/NintendoWare/atk/atk_FsSoundArchive.cpp | 52 +++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/NintendoWare/atk/atk_FsSoundArchive.cpp b/src/NintendoWare/atk/atk_FsSoundArchive.cpp index 84d7f1bc..aa1b4108 100644 --- a/src/NintendoWare/atk/atk_FsSoundArchive.cpp +++ b/src/NintendoWare/atk/atk_FsSoundArchive.cpp @@ -1,6 +1,9 @@ #include +#include + #include +#include namespace nn::atk { FsSoundArchive::FsSoundArchive() = default; @@ -86,5 +89,54 @@ void FsSoundArchive::FileAccessEnd() const { --m_FileAccessCount; } } + +// NON_MATCHING +detail::fnd::FileStream* FsSoundArchive::OpenStream(void* buffer, size_t size, + position_t begin, size_t length) const { + detail::fnd::FileStream* stream {}; + if (sizeof(detail::fnd::FileStreamProxy) <= size && m_IsOpened) { + stream = new (buffer) detail::fnd::FileStreamProxy(&m_FileStream, begin, length); + } + + return stream; +} + +// NON_MATCHING +detail::fnd::FileStream* FsSoundArchive::OpenExtStream(void* buffer, size_t size, const char* extFilePath, + void* cacheBuffer, size_t cacheSize) const { + detail::fnd::FileStream* fileStream {}; + if (size >= sizeof(detail::fnd::FileStreamImpl) && m_IsOpened) { + fileStream = new (buffer) detail::fnd::FileStreamImpl(); + + fileStream->Open(extFilePath, detail::fnd::FileStreamImpl::AccessMode_Read); + + if (!fileStream->IsOpened()) { + fileStream = nullptr; + } + else { + if (cacheBuffer != nullptr && cacheSize != 0) + fileStream->EnableCache(cacheBuffer, cacheSize); + } + } + + return fileStream; +} + +bool FsSoundArchive::LoadFileHeader() { + const int Align = 256; + const size_t headerAlignSize = 256; + + char headerArea[sizeof(detail::SoundArchiveFile::FileHeader) + headerAlignSize + Align]; + void* file {util::BytePtr(headerArea).AlignUp(Align).Get()}; + + size_t readSize {m_FileStream.Read(file, headerAlignSize, nullptr)}; + + if (readSize != headerAlignSize) + return false; + + m_ArchiveReader.Initialize(file); + Initialize(&m_ArchiveReader); + return true; +} } // namespace nn::atk From 66238555c8eabf49af014592125392f3e9b424e1 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 2 Sep 2026 16:43:20 -0400 Subject: [PATCH 479/785] atk: Match `Task` constructor and destructor Also added some implementations for `os::Tick`, `os::Mutex` and `os::Event` --- include/nn/atk/atk_DeviceOutRecorder.h | 3 +- include/nn/atk/atk_Task.h | 14 +++++++ include/nn/os.h | 7 +--- include/nn/os/os_TickTypes.h | 40 +++++++++++++++++++ .../atk/detail/thread/atk_Task.cpp | 14 +++++++ 5 files changed, 71 insertions(+), 7 deletions(-) create mode 100644 include/nn/os/os_TickTypes.h diff --git a/include/nn/atk/atk_DeviceOutRecorder.h b/include/nn/atk/atk_DeviceOutRecorder.h index 485af6ec..f7414cec 100644 --- a/include/nn/atk/atk_DeviceOutRecorder.h +++ b/include/nn/atk/atk_DeviceOutRecorder.h @@ -2,7 +2,7 @@ #include -#include +#include #include #include @@ -13,6 +13,7 @@ namespace nn::atk { class DeviceOutRecorder : public detail::fnd::Thread::Handler { NN_NO_COPY(DeviceOutRecorder); + public: static const u32 RecordingBufferSize = 0x5a000; static const u32 DefaultWriteBlockPerSamples = 0x10000; diff --git a/include/nn/atk/atk_Task.h b/include/nn/atk/atk_Task.h index c49f90df..aa8148d2 100644 --- a/include/nn/atk/atk_Task.h +++ b/include/nn/atk/atk_Task.h @@ -1,5 +1,7 @@ #pragma once +#include + #include namespace nn::atk::detail { @@ -18,9 +20,21 @@ class Task { Task(); virtual ~Task(); + + void SetId(u32 id) { m_Id = id; } + Status GetStatus() const { return m_Status; }; + + void Wait() { m_Event.Wait(); } + bool TryWait() { return m_Event.TryWait(); } + +protected: virtual void Execute(TaskProfileLogger& logger) = 0; + void InitializeStatus() { m_Status = Status_Free; } + private: + NN_NO_COPY(Task); + friend TaskManager; util::IntrusiveListNode m_TaskLink; diff --git a/include/nn/os.h b/include/nn/os.h index 843d4f7a..d552b0a1 100644 --- a/include/nn/os.h +++ b/include/nn/os.h @@ -15,6 +15,7 @@ #include #include #include +#include namespace nn { namespace os { @@ -38,12 +39,6 @@ struct InterProcessEventType { }; } // namespace detail -struct Tick { - Tick(u64 val) : value(val) {} - - u64 value; -}; - struct LightEventType { std::aligned_storage_t<0xc, 4> storage; }; diff --git a/include/nn/os/os_TickTypes.h b/include/nn/os/os_TickTypes.h new file mode 100644 index 00000000..e4a3274f --- /dev/null +++ b/include/nn/os/os_TickTypes.h @@ -0,0 +1,40 @@ +#pragma once + +#include +#include + +namespace nn::os { + +class Tick; +s64 ConvertToTick(TimeSpan timeSpan); +TimeSpan ConvertToTimeSpan(Tick ticks); + +class Tick { +public: + Tick(s64 tick) : m_Tick(tick) {} + + Tick(TimeSpan timeSpan) : m_Tick(ConvertToTick(timeSpan)) {} + + s64 GetInt64Value() const { return m_Tick; } + + TimeSpan ToTimeSpan() const { return ConvertToTimeSpan(*this); } + + Tick& operator-=(Tick rhs) { + *this = *this - rhs; + return *this; + } + + Tick operator-(Tick rhs) const { return m_Tick - rhs.m_Tick; } + + Tick& operator+=(Tick rhs) { + *this = *this + rhs; + return *this; + } + + Tick operator+(Tick rhs) const { return m_Tick + rhs.m_Tick; } + +private: + s64 m_Tick; +}; + +} // namespace nn::os \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/thread/atk_Task.cpp b/src/NintendoWare/atk/detail/thread/atk_Task.cpp index e69de29b..8a620743 100644 --- a/src/NintendoWare/atk/detail/thread/atk_Task.cpp +++ b/src/NintendoWare/atk/detail/thread/atk_Task.cpp @@ -0,0 +1,14 @@ +#include + +namespace nn::atk::detail { +Task::Task() + : m_Event(os::EventClearMode_ManualClear) { + + InitializeStatus(); + SetId(0); + + m_Event.Signal(); +} + +Task::~Task() = default; +} // namespace nn::atk::detail \ No newline at end of file From 70ced7d93d8eeedf3c3c62be24d823329d9d107d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 3 Sep 2026 11:08:04 -0400 Subject: [PATCH 480/785] atk: Match `LowLevelVoice` constructor Also reorganized `LowLevelVoice` and `VolumeThroughModePacket` to better match DWARF --- include/nn/atk/atk_Global.h | 32 +++--- include/nn/atk/atk_LowLevelVoice.h | 98 +++++++++++-------- include/nn/atk/atk_ValueArray.h | 80 ++++++++++++++- include/nn/atk/atk_VolumeThroughModePacket.h | 12 ++- include/nn/audio/audio_Adpcm.h | 2 +- include/nn/audio/audio_VoiceTypes.h | 2 +- include/nn/os.h | 4 - include/nn/os/os_TickTypes.h | 24 +++-- src/NintendoWare/atk/atk_FsSoundArchive.cpp | 4 +- .../detail/atk_VolumeThroughModePacket.cpp | 7 ++ .../atk/detail/voice/atk_LowLevelVoice.cpp | 7 ++ 11 files changed, 194 insertions(+), 78 deletions(-) diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h index a03406a2..5fb8a655 100644 --- a/include/nn/atk/atk_Global.h +++ b/include/nn/atk/atk_Global.h @@ -157,11 +157,11 @@ struct AdshrCurve { static_assert(sizeof(AdshrCurve) == 0x5); struct BiquadFilterCoefficients { - s16 b0; - s16 b1; - s16 b2; - s16 a1; - s16 a2; + s16 b0 {0}; + s16 b1 {0}; + s16 b2 {0}; + s16 a1 {0}; + s16 a2 {0}; }; static_assert(sizeof(BiquadFilterCoefficients) == 0xa); @@ -249,7 +249,9 @@ enum OutputMode { }; struct OutputMix { - f32 channelGain[24]; + OutputMix() = default; + + f32 channelGain[24] = {0}; }; static_assert(sizeof(OutputMix) == 0x60); @@ -380,19 +382,19 @@ static_assert(sizeof(VoiceInfo) == 0x20); class VoiceParam { public: - VoiceParam(); + VoiceParam() = default; void Initialize(); private: - float m_Volume; - float m_Pitch; - OutputMix m_TvMix; - bool m_MonoFilterFlag; - bool m_BiquadFilterFlag; - BiquadFilterCoefficients m_BiquadFilterCoefficients; - u16 m_MonoFilterCutoff; - u8 m_InterpolationType; + float m_Volume {0}; + float m_Pitch {0}; + OutputMix m_TvMix {}; + bool m_MonoFilterFlag {false}; + bool m_BiquadFilterFlag {false}; + BiquadFilterCoefficients m_BiquadFilterCoefficients {}; + u16 m_MonoFilterCutoff {0}; + u8 m_InterpolationType {0}; }; static_assert(sizeof(VoiceParam) == 0x78); diff --git a/include/nn/atk/atk_LowLevelVoice.h b/include/nn/atk/atk_LowLevelVoice.h index b8873074..e29ba08c 100644 --- a/include/nn/atk/atk_LowLevelVoice.h +++ b/include/nn/atk/atk_LowLevelVoice.h @@ -2,87 +2,106 @@ #include -#include #include #include +#include #include -#include #include +#include #include namespace nn::atk::detail { + class Voice; -class alignas(256) LowLevelVoice { +class alignas(64) LowLevelVoice { public: LowLevelVoice(); - + void Initialize(); void Finalize(); - void FreeAllWaveBuffer(); - bool IsAvailable() const; void SetAvailable(bool isAvailable); bool IsVoiceDroppedFlagOn() const; void AppendWaveBuffer(WaveBuffer* waveBuffer); + void FreeAllWaveBuffer(); void UpdateState(OutputMode outputMode); - void UpdateStatePlay(bool isRun, OutputMode outputMode); - void UpdateStateStop(bool isRun); - void UpdateStatePause(bool isRun, OutputMode outputMode); + + void SetVoiceParam(const VoiceParam& voiceParam) { m_VoiceParam = voiceParam; } void SetPriority(s32 priority); + void SetState(VoiceState state); - bool AllocVoice(); + void SetSampleRate(s32 sampleRate) { m_SampleRate = sampleRate; } + void SetSampleFormat(SampleFormat sampleFormat) { m_SampleFormat = sampleFormat; } + void SetAdpcmParam(const AdpcmParam& adpcmParam) { m_AdpcmParam = adpcmParam; } - void SetState(VoiceState state); + position_t GetPlayPosition() const { return m_PlayPosition; } + + void SetVoice(Voice* pVoice) { m_pVoice = pVoice; } +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) + void SetOutputReceiver(OutputReceiver* pOutputReceiver) { m_pOutputReceiver = pOutputReceiver; } +#endif void UpdateVoiceInfo(VoiceInfo* voiceInfo) const; + + audio::NodeId GetNodeId() { return m_NodeId; } + +private: void UpdateVoiceParam(const VoiceParam& voiceParam, OutputMode outputMode); - void UpdateVolume(const VoiceParam& voiceParam); - void UpdatePitch(const VoiceParam& voiceParam); - void UpdateBiquadFilter(const VoiceParam& voiceParam); - void UpdateLowPassFilter(const VoiceParam& voiceParam); - void UpdateMixVolume(const OutputMix& outputMix, OutputMode outputMode); - void UpdateWaveBuffer(bool isRun, OutputMode outputMode); + bool AllocVoice(); + + void UpdateStatePlay(bool isRun, OutputMode outputMode); + void UpdateStateStop(bool isRun); + void UpdateStatePause(bool isRun, OutputMode outputMode); void UpdatePlayPosition(); + + void UpdateWaveBuffer(bool isRun, OutputMode outputMode); void UpdateWaveBufferOnPlayState(); void UpdateWaveBufferOnStopState(OutputMode outputMode); - bool AppendWaveBufferToVoice(WaveBuffer* waveBuffer); + void UpdateMixVolume(const OutputMix& outputMix, OutputMode outputMode); void UpdateMixVolumeOnSubMix(const OutputMix& outputMix, OutputMode outputMode); void UpdateMixVolumeOnFinalMix(const OutputMix& outputMix, OutputMode outputMode); - static f32 GetClampedVoiceVolume(f32 volume); + void UpdateVolume(const VoiceParam& voiceParam); + void UpdatePitch(const VoiceParam& voiceParam); + void UpdateBiquadFilter(const VoiceParam& voiceParam); + void UpdateLowPassFilter(const VoiceParam& voiceParam); - void SetVoiceMixVolume(f32 volume, s32 dstIndex); + void SetVoiceMixVolume(float mixVolume, int destinationIndex); -private: - AdpcmParam m_AdpcmParam; - audio::VoiceType m_Voice; - bool m_IsAvailable; - bool m_IsSetVoiceSlot; - VoiceParam m_VoiceParam; - s32 m_Priority; - VoiceState m_State; - u32 m_SampleRate; - SampleFormat m_SampleFormat; - position_t m_PlayPosition; + float GetClampedVoiceVolume(float volume); + + AdpcmParam m_AdpcmParam{}; + audio::VoiceType m_Voice{}; + bool m_IsAvailable{false}; + bool m_IsSetVoiceSlot{false}; + VoiceParam m_VoiceParam{}; + int32_t m_Priority{0}; + VoiceState m_State{VoiceState_Stop}; + u32 m_SampleRate{32000}; + SampleFormat m_SampleFormat{SampleFormat_PcmS16}; + position_t m_PlayPosition{0}; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) - void* _c0; // 0xc0 + u32 _c0{0}; // 0xc0 #else - OutputReceiver* m_pOutputReceiver; + OutputReceiver* m_pOutputReceiver{}; +#endif + WaveBuffer* m_WaveBufferListBegin{}; + WaveBuffer* m_WaveBufferListEnd{}; + WaveBuffer* m_LastAppendBuffer{}; + Voice* m_pVoice{}; + audio::NodeId m_NodeId{0}; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) + bool _ec{true}; //0xec #endif - WaveBuffer* m_WaveBufferListBegin; - WaveBuffer* m_WaveBufferListEnd; - WaveBuffer* m_LastAppendBuffer; - Voice* m_pVoice; - audio::NodeId nodeId; }; static_assert(sizeof(LowLevelVoice) == 0x100); @@ -114,4 +133,5 @@ class LowLevelVoiceAllocator { std::atomic m_DroppedVoiceCount{0}; }; static_assert(sizeof(LowLevelVoiceAllocator) == 0x28); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/atk_ValueArray.h b/include/nn/atk/atk_ValueArray.h index 4c20b6fc..666946c1 100644 --- a/include/nn/atk/atk_ValueArray.h +++ b/include/nn/atk/atk_ValueArray.h @@ -1,13 +1,87 @@ #pragma once +#include #include namespace nn::atk::detail { + template class ValueArray { public: + // UNCHECKED + static size_t GetRequiredMemSize(int count); + + // UNCHECKED + ValueArray() = default; + + // UNCHECKED + bool Initialize(void* buffer, [[maybe_unused]] size_t bufferSize, int count) { + m_pValue = reinterpret_cast(buffer); + m_Count = count; + Reset(); + return true; + } + + // UNCHECKED + bool IsInitialized() const { return m_pValue != nullptr && m_Count != 0; } + + // UNCHECKED + void* GetBufferAddr() { return m_pValue; } + + // UNCHECKED + void Finalize() { + m_pValue = nullptr; + m_Count = 0; + } + + // UNCHECKED + void Reset() { + for (int i{0}; i < m_Count; ++i) + m_pValue[i] = 0; + } + + // UNCHECKED + int GetCount() const { return m_Count; }; + + // UNCHECKED + void SetValue(int index, T value) { m_pValue[index] = value; } + + // UNCHECKED + T GetValue(int index) { return m_pValue[index]; } + + // UNCHECKED + bool TrySetValue(int index, T value) { + if (index >= m_Count) + return false; + + m_pValue[index] = value; + return true; + } + + // UNCHECKED + T TryGetValue(int index) { + if (index >= m_Count) + return 0; + + return m_pValue[index]; + } + + // UNCHECKED + ValueArray& operator=(const ValueArray& rhs) { + const int CopyCount{std::min(m_Count, rhs.m_Count)}; + + for (int i{0}; i < CopyCount; ++i) + this->SetValue(i, rhs.GetValue(i)); + + for (int i{rhs.m_Count}; i > 0; --i) + rhs.SetValue(i, 0); + + return *this; + } + private: - T* m_pValue; - s32 m_Count; + T* m_pValue{}; + int m_Count{0}; }; -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/atk_VolumeThroughModePacket.h b/include/nn/atk/atk_VolumeThroughModePacket.h index 5c700815..87e49449 100644 --- a/include/nn/atk/atk_VolumeThroughModePacket.h +++ b/include/nn/atk/atk_VolumeThroughModePacket.h @@ -7,20 +7,22 @@ class VolumeThroughModePacket { public: using VolumeThroughModeArray = ValueArray; - static size_t GetRequiredMemSize(s32 busCount); + VolumeThroughModePacket(); - bool Initialize(void* buffer, size_t size, s32 busCount); + static size_t GetRequiredMemSize(int busCount); + bool Initialize(void* buffer, size_t size, int busCount); void Finalize(); - void Reset(); + int GetBusCount() const { return m_VolumeThroughMode.GetCount(); } + VolumeThroughModePacket& operator=(const VolumeThroughModePacket& rhs); private: VolumeThroughModeArray m_VolumeThroughMode; bool m_IsVolumeThroughModeUsed; - f32 m_BinaryVolume; + float m_BinaryVolume; }; static_assert(sizeof(VolumeThroughModePacket) == 0x18); -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/audio/audio_Adpcm.h b/include/nn/audio/audio_Adpcm.h index 123e8abc..7597e060 100644 --- a/include/nn/audio/audio_Adpcm.h +++ b/include/nn/audio/audio_Adpcm.h @@ -10,7 +10,7 @@ struct AdpcmContext { static_assert(sizeof(AdpcmContext) == 0x6); struct AdpcmParameter { - u16 coefficients[16]; + u16 coefficients[16] = {0}; }; static_assert(sizeof(AdpcmParameter) == 0x20); } // namespace nn::audio \ No newline at end of file diff --git a/include/nn/audio/audio_VoiceTypes.h b/include/nn/audio/audio_VoiceTypes.h index 665d5be0..b3a9abed 100644 --- a/include/nn/audio/audio_VoiceTypes.h +++ b/include/nn/audio/audio_VoiceTypes.h @@ -31,7 +31,7 @@ struct VoiceType { static const int BiquadFilterCountMax = 2; - VoiceInfo* _pVoiceInfo; + VoiceInfo* _pVoiceInfo{}; }; static_assert(sizeof(VoiceType) == 0x8); } // namespace nn::audio \ No newline at end of file diff --git a/include/nn/os.h b/include/nn/os.h index d552b0a1..7664d812 100644 --- a/include/nn/os.h +++ b/include/nn/os.h @@ -140,8 +140,6 @@ void WaitLightEvent(LightEventType*); bool TimedWaitLightEvent(LightEventType*, nn::TimeSpan); void ClearLightEvent(LightEventType*); -TimeSpan ConvertToTimeSpan(Tick ticks); - // SEMAPHORES void InitializeSemaphore(SemaphoreType* semaphore, s32 initial_count, s32 max_count); void FinalizeSemaphore(SemaphoreType* semaphore); @@ -188,8 +186,6 @@ void SetUserExceptionHandler(void (*)(UserExceptionInfo*), void*, ulong, UserExc // OTHER void GenerateRandomBytes(void*, u64); -nn::os::Tick GetSystemTick(); -nn::os::Tick GetSystemTickFrequency(); u64 GetThreadAvailableCoreMask(); void SetMemoryHeapSize(u64 size); diff --git a/include/nn/os/os_TickTypes.h b/include/nn/os/os_TickTypes.h index e4a3274f..b035e915 100644 --- a/include/nn/os/os_TickTypes.h +++ b/include/nn/os/os_TickTypes.h @@ -6,16 +6,19 @@ namespace nn::os { class Tick; -s64 ConvertToTick(TimeSpan timeSpan); + +Tick GetSystemTick(); +Tick GetSystemTickFrequency(); +Tick ConvertToTick(TimeSpan timeSpan); TimeSpan ConvertToTimeSpan(Tick ticks); class Tick { public: - Tick(s64 tick) : m_Tick(tick) {} + Tick(s64 tick) : value(tick) {} - Tick(TimeSpan timeSpan) : m_Tick(ConvertToTick(timeSpan)) {} + Tick(TimeSpan timeSpan) : value(ConvertToTick(timeSpan).GetInt64Value()) {} - s64 GetInt64Value() const { return m_Tick; } + s64 GetInt64Value() const { return value; } TimeSpan ToTimeSpan() const { return ConvertToTimeSpan(*this); } @@ -24,17 +27,22 @@ class Tick { return *this; } - Tick operator-(Tick rhs) const { return m_Tick - rhs.m_Tick; } + Tick operator-(Tick rhs) const { return value - rhs.value; } Tick& operator+=(Tick rhs) { *this = *this + rhs; return *this; } - Tick operator+(Tick rhs) const { return m_Tick + rhs.m_Tick; } + Tick operator+(Tick rhs) const { return value + rhs.value; } + + s64 value; -private: - s64 m_Tick; +// TODO: DWARF shows value as private and named m_Tick. +// It's being kept as it was for now to keep sead +// from not compiling. Fix this before merging to master. +// private: +// s64 m_Tick; }; } // namespace nn::os \ No newline at end of file diff --git a/src/NintendoWare/atk/atk_FsSoundArchive.cpp b/src/NintendoWare/atk/atk_FsSoundArchive.cpp index aa1b4108..43d02d03 100644 --- a/src/NintendoWare/atk/atk_FsSoundArchive.cpp +++ b/src/NintendoWare/atk/atk_FsSoundArchive.cpp @@ -71,7 +71,7 @@ const void* FsSoundArchive::detail_GetFileAddress([[maybe_unused]] ItemId itemId void FsSoundArchive::FileAccessBegin() const { if (m_FileAccessMode == FileAccessMode_InFunction) { - auto lock = detail::fnd::ScopedLock{m_FileOpenCloseLock}; + detail::fnd::ScopedLock lock{m_FileOpenCloseLock}; if (m_FileAccessCount == 0) m_FileStream.Open(m_SoundArchiveFullPath, detail::fnd::FileStream::AccessMode_Read); @@ -81,7 +81,7 @@ void FsSoundArchive::FileAccessBegin() const { void FsSoundArchive::FileAccessEnd() const { if (m_FileAccessMode == FileAccessMode_InFunction) { - auto lock = detail::fnd::ScopedLock{m_FileOpenCloseLock}; + detail::fnd::ScopedLock lock{m_FileOpenCloseLock}; if (m_FileAccessCount == 1) m_FileStream.Close(); diff --git a/src/NintendoWare/atk/detail/atk_VolumeThroughModePacket.cpp b/src/NintendoWare/atk/detail/atk_VolumeThroughModePacket.cpp index e69de29b..22663deb 100644 --- a/src/NintendoWare/atk/detail/atk_VolumeThroughModePacket.cpp +++ b/src/NintendoWare/atk/detail/atk_VolumeThroughModePacket.cpp @@ -0,0 +1,7 @@ +#include + +namespace nn::atk::detail { + + + +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp index e69de29b..560a840a 100644 --- a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp @@ -0,0 +1,7 @@ +#include + +namespace nn::atk::detail { + +LowLevelVoice::LowLevelVoice() = default; + +} // namespace nn::atk::detail \ No newline at end of file From f53be4b34b969db5b94d5ade82b14a68b1072487 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 3 Sep 2026 12:10:16 -0400 Subject: [PATCH 481/785] atk: Match `LowLevelVoice::AppendWaveBuffer` --- .../atk/detail/voice/atk_LowLevelVoice.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp index 560a840a..33e2d294 100644 --- a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp @@ -4,4 +4,15 @@ namespace nn::atk::detail { LowLevelVoice::LowLevelVoice() = default; +void LowLevelVoice::AppendWaveBuffer(WaveBuffer* waveBuffer) { + waveBuffer->next = nullptr; + waveBuffer->status = WaveBuffer::Status_Wait; + if (m_WaveBufferListEnd == nullptr) + m_WaveBufferListBegin = waveBuffer; + else + m_WaveBufferListEnd->next = waveBuffer; + + m_WaveBufferListEnd = waveBuffer; +} + } // namespace nn::atk::detail \ No newline at end of file From c0c837dc5e5488eddf9195062d1ba7b80ecb197e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 3 Sep 2026 12:23:36 -0400 Subject: [PATCH 482/785] atk: Add functions for `ThreadInfoRecorder` --- include/nn/atk/atk_ThreadInfoReader.h | 31 +++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_ThreadInfoReader.h b/include/nn/atk/atk_ThreadInfoReader.h index 29202a5a..f9713e88 100644 --- a/include/nn/atk/atk_ThreadInfoReader.h +++ b/include/nn/atk/atk_ThreadInfoReader.h @@ -8,9 +8,36 @@ namespace nn::atk { namespace detail { class ThreadInfoRecorder { public: + static const size_t BufferMinimumSize {}; + + ThreadInfoRecorder(); + + void Initialize(void* buffer, size_t bufferSize) { + m_Buffer = buffer; + m_BufferSize = bufferSize; + } + + int GetRecordedFrameCount() const { return m_RecordFrameCount; } + + const void* GetRingBufferHeadAddress() const { + // TODO + return nullptr; + } + + void MoveToNextFrame() { + // TODO + } + + void RecordFooter() { + // TODO + } + util::IntrusiveListNode m_List; private: + void* AllocateInfoBuffer([[maybe_unused]] u32 count, [[maybe_unused]] size_t size) { return nullptr; } + void* AllocateBuffer([[maybe_unused]] u32 count, [[maybe_unused]] size_t size1, [[maybe_unused]]size_t size2) { return nullptr; } + void* m_Buffer; size_t m_BufferSize; size_t m_WritePosition; @@ -19,10 +46,10 @@ class ThreadInfoRecorder { std::atomic_bool m_IsAllocationFailed; }; static_assert(sizeof(ThreadInfoRecorder) == 0x38); -} // namespace nn::atk::detail +} // namespace detail using SoundThreadInfoRecorder = detail::ThreadInfoRecorder; using SoundThreadInfoRecorderList = util::IntrusiveList>; -} // namespace nn::atk \ No newline at end of file +} // namespace nn::atk \ No newline at end of file From d75b072241fe6a5d04aa8db6c159fb528a27864e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 3 Sep 2026 12:39:09 -0400 Subject: [PATCH 483/785] atk: Match `WavOutFileStream` constructor --- include/nn/atk/atk_WavOutFileStream.h | 45 +++++++++++-------- .../atk/detail/util/atk_WavOutFileStream.cpp | 7 +++ 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/include/nn/atk/atk_WavOutFileStream.h b/include/nn/atk/atk_WavOutFileStream.h index d7152268..b95c5e7d 100644 --- a/include/nn/atk/atk_WavOutFileStream.h +++ b/include/nn/atk/atk_WavOutFileStream.h @@ -4,39 +4,46 @@ #include namespace nn::atk::detail { + class WavOutFileStream { public: - constexpr static u8 FileIoBufferAlignment = 8; + static const int FileIoBufferAlignment = alignof(char); WavOutFileStream(); ~WavOutFileStream(); - bool Open(fnd::FileStream& stream, s32, u64); - - bool WriteHeader(s32, u64); - + bool Open(fnd::FileStream& stream, int channels, size_t samplesPerSec); void Close(); - bool FlushBuffer(); + size_t Write(const void* buf, size_t length); + bool Seek(position_t offset, fnd::FileStream::SeekOrigin origin); + + bool IsAvailable() const; + + size_t GetSize() const; + + position_t Tell() const; - u64 CalcRiffChunkSize(u64); + void SetCacheBuffer(char* buf, size_t length); + +private: + bool WriteHeader(int channels, size_t samplesPerSec); bool UpdateRiffChunkSize(); bool UpdateDataChunkSize(); + size_t CalcRiffChunkSize(size_t dataSize); - size_t Write(const void* buffer, size_t size); size_t WriteDirect(const void* buf, size_t length, fnd::FndResult* result); - bool Seek(position_t offset, fnd::Stream::SeekOrigin origin); - - void SetCacheBuffer(char* cacheBuffer, size_t cacheBufferSize); + size_t FlushBuffer(); -private: - fnd::FileStream* m_pFileStream; - size_t m_WaveDataSize; - bool m_IsWaveDataSizeCalculating; - char* m_Buffer; - size_t m_BufferLength; - size_t m_ValidBufferLength; + fnd::FileStream* m_pFileStream{}; + size_t m_WaveDataSize{0}; + bool m_IsWaveDataSizeCalculating{false}; + char* m_Buffer{}; + size_t m_BufferLength{0}; + size_t m_ValidBufferLength{0}; }; -} // namespace nn::atk::detail \ No newline at end of file +static_assert(sizeof(WavOutFileStream) == 0x30); + +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp b/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp index e69de29b..dce23552 100644 --- a/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp +++ b/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp @@ -0,0 +1,7 @@ +#include + +namespace nn::atk::detail { + +WavOutFileStream::WavOutFileStream() = default; + +} // namespace nn::atk::detail \ No newline at end of file From 924f84999dd73cdcada3f709b7a292cd5b5aab24 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 3 Sep 2026 12:41:19 -0400 Subject: [PATCH 484/785] atk: Match `WavOutFileStream` destructor --- src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp b/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp index dce23552..2a41593b 100644 --- a/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp +++ b/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp @@ -4,4 +4,6 @@ namespace nn::atk::detail { WavOutFileStream::WavOutFileStream() = default; +WavOutFileStream::~WavOutFileStream() = default; + } // namespace nn::atk::detail \ No newline at end of file From 2efbc3cee2fcaa56fd68f4afd6125bcb47952ff1 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 3 Sep 2026 12:59:16 -0400 Subject: [PATCH 485/785] atk: Add non-matching implementation for `WavOutFileStream::WriteHeader` --- include/nn/atk/atk_WavBinary.h | 19 +++++++------ .../atk/detail/util/atk_WavOutFileStream.cpp | 28 +++++++++++++++++++ 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/include/nn/atk/atk_WavBinary.h b/include/nn/atk/atk_WavBinary.h index 02712dc6..b79db808 100644 --- a/include/nn/atk/atk_WavBinary.h +++ b/include/nn/atk/atk_WavBinary.h @@ -6,11 +6,13 @@ #include namespace nn::atk::detail { + struct ChunkHeader { ChunkHeader() = default; - explicit ChunkHeader(u32 id); - ChunkHeader(u32 id, u32 size); + explicit ChunkHeader(u32 id) : id{id}, size{0} {}; + + ChunkHeader(u32 id, u32 size) : id{id}, size{size} {}; u32 id; fnd::PcBinU32 size; @@ -18,20 +20,20 @@ struct ChunkHeader { static_assert(sizeof(ChunkHeader) == 0x8); struct RiffChunk { - static const u32 ValidId {1179011410}; // "RIFF" + static const u32 ValidId {0x46464952}; // "RIFF" RiffChunk() = default; bool IsValid(); - ChunkHeader header; + ChunkHeader header{ValidId}; u32 formatType; }; static_assert(sizeof(RiffChunk) == 0xc); struct FmtChunk { - static const u32 ValidId {0x20746d66}; // "fmt " - static const u16 FormatPcm {SampleFormat_PcmS16}; + static const u32 ValidId{0x20746d66}; // "fmt " + static const u16 FormatPcm{SampleFormat_PcmS16}; FmtChunk() = default; @@ -39,7 +41,7 @@ struct FmtChunk { bool IsValid(); - ChunkHeader header; + ChunkHeader header{ValidId, sizeof(FmtChunk) - sizeof(ChunkHeader)}; fnd::PcBinU16 formatTag; fnd::PcBinU16 channels; fnd::PcBinU32 samplesPerSec; @@ -56,7 +58,7 @@ struct DataChunk { bool IsValid(); - ChunkHeader header; + ChunkHeader header{ValidId}; }; static_assert(sizeof(DataChunk) == 0x8); @@ -68,4 +70,5 @@ struct WaveBinaryHeader { DataChunk dataChunk; }; static_assert(sizeof(WaveBinaryHeader) == 0x2c); + } // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp b/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp index 2a41593b..d0d00079 100644 --- a/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp +++ b/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp @@ -1,9 +1,37 @@ #include +#include + +#include +#include + namespace nn::atk::detail { WavOutFileStream::WavOutFileStream() = default; WavOutFileStream::~WavOutFileStream() = default; +bool WavOutFileStream::Open(fnd::FileStream& stream, int channels, size_t samplesPerSec) { + +} + +// NON_MATCHING: reordering of instructions +bool WavOutFileStream::WriteHeader(int channels, size_t samplesPerSec) { + char buffer[sizeof(WaveBinaryHeader) + FileIoBufferAlignment]; + void* alignedBuffer {util::BytePtr(buffer).AlignUp(FileIoBufferAlignment).Get()}; + + WaveBinaryHeader* header {new (alignedBuffer) WaveBinaryHeader}; + + header->riffChunk.formatType = 0x45564157; // "WAVE" + header->riffChunk.header.size = sizeof(WaveBinaryHeader) - sizeof(ChunkHeader); + header->fmtChunk.bitsPerSample = 16; + header->fmtChunk.blockAlign = channels * 2; + header->fmtChunk.samplesPerSec = samplesPerSec; + header->fmtChunk.avgBytesPerSec = header->fmtChunk.blockAlign * header->fmtChunk.samplesPerSec; + header->fmtChunk.channels = channels; + header->fmtChunk.formatTag = FmtChunk::FormatPcm; + + size_t result {Write(header, sizeof(WaveBinaryHeader))}; + return result == sizeof(WaveBinaryHeader); +} } // namespace nn::atk::detail \ No newline at end of file From 5493e83531b591636f68ab70fc160c68574633e4 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 3 Sep 2026 14:29:54 -0400 Subject: [PATCH 486/785] atk: Add implementation for `WavOutFileStream::Open` --- .../atk/detail/util/atk_WavOutFileStream.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp b/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp index d0d00079..3796e36c 100644 --- a/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp +++ b/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp @@ -11,8 +11,17 @@ WavOutFileStream::WavOutFileStream() = default; WavOutFileStream::~WavOutFileStream() = default; +// NON_MATCHING: requires WavOutFileStream::WriteHeader bool WavOutFileStream::Open(fnd::FileStream& stream, int channels, size_t samplesPerSec) { + m_pFileStream = &stream; + if (WriteHeader(channels, samplesPerSec)) { + m_WaveDataSize = 0; + m_IsWaveDataSizeCalculating = true; + return true; + } + + return false; } // NON_MATCHING: reordering of instructions From 1607088928fc9da3c13079c1abebe0d35e45addf Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 3 Sep 2026 14:54:11 -0400 Subject: [PATCH 487/785] atk: Match `WavOutFileStream::SetCacheBuffer` --- include/nn/atk/atk_WavOutFileStream.h | 2 +- src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_WavOutFileStream.h b/include/nn/atk/atk_WavOutFileStream.h index b95c5e7d..b0367bd0 100644 --- a/include/nn/atk/atk_WavOutFileStream.h +++ b/include/nn/atk/atk_WavOutFileStream.h @@ -18,7 +18,7 @@ class WavOutFileStream { size_t Write(const void* buf, size_t length); bool Seek(position_t offset, fnd::FileStream::SeekOrigin origin); - bool IsAvailable() const; + bool IsAvailable() const { return m_pFileStream != nullptr && m_pFileStream->IsOpened(); } size_t GetSize() const; diff --git a/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp b/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp index 3796e36c..6c51c67d 100644 --- a/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp +++ b/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp @@ -24,6 +24,11 @@ bool WavOutFileStream::Open(fnd::FileStream& stream, int channels, size_t sample return false; } +void WavOutFileStream::SetCacheBuffer(char* buf, size_t length) { + m_Buffer = buf; + m_BufferLength = length; +} + // NON_MATCHING: reordering of instructions bool WavOutFileStream::WriteHeader(int channels, size_t samplesPerSec) { char buffer[sizeof(WaveBinaryHeader) + FileIoBufferAlignment]; @@ -43,4 +48,5 @@ bool WavOutFileStream::WriteHeader(int channels, size_t samplesPerSec) { size_t result {Write(header, sizeof(WaveBinaryHeader))}; return result == sizeof(WaveBinaryHeader); } + } // namespace nn::atk::detail \ No newline at end of file From afe3facaf14ae6dba049f53f6065965878534311 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 3 Sep 2026 15:03:30 -0400 Subject: [PATCH 488/785] atk: Match `AddonSoundArchiveContainer::SetAddTick` This matches all exported functions in `AddonSoundArchiveContainer` --- .../detail/atk_AddonSoundArchiveContainer.h | 33 +++++++------------ .../detail/atk_AddonSoundArchiveContainer.cpp | 16 ++++++--- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h b/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h index 44acf8e8..88e59c6b 100644 --- a/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h +++ b/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h @@ -12,29 +12,20 @@ class AddonSoundArchiveContainer { AddonSoundArchiveContainer(); ~AddonSoundArchiveContainer(); - bool Initialize(const char* soundArchiveName, - const AddonSoundArchive* pSoundArchive, + bool Initialize(const char* soundArchiveName, const AddonSoundArchive* pSoundArchive, const SoundDataManager* pSoundDataManager); - + void Finalize(); - + bool IsSameName(const char* name) const; - bool IsActive() const { - return m_IsActive; - } + bool IsActive() const { return m_IsActive; } - const SoundArchive* GetSoundArchive() const { - return m_pSoundArchive; - } + const SoundArchive* GetSoundArchive() const { return m_pSoundArchive; } - const SoundDataManager* GetSoundDataManager() const { - return m_pSoundDataManager; - } + const SoundDataManager* GetSoundDataManager() const { return m_pSoundDataManager; } - const char* GetSoundArchiveName() const { - return m_SoundArchiveName; - } + const char* GetSoundArchiveName() const { return m_SoundArchiveName; } void SetAddTick(const os::Tick& tick); @@ -44,12 +35,12 @@ class AddonSoundArchiveContainer { util::IntrusiveListNode m_ElementLink; private: - bool m_IsActive {false}; + bool m_IsActive{false}; u8 m_Padding[3]; - const SoundArchive* m_pSoundArchive {}; - const SoundDataManager* m_pSoundDataManager {}; + const SoundArchive* m_pSoundArchive{}; + const SoundDataManager* m_pSoundDataManager{}; char m_SoundArchiveName[SoundArchiveNameLengthMax]; - os::Tick m_AddTick {0}; + os::Tick m_AddTick{0}; }; static_assert(sizeof(AddonSoundArchiveContainer) == 0x70); -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp b/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp index 936d5c93..55e65764 100644 --- a/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp +++ b/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp @@ -3,6 +3,7 @@ #include namespace nn::atk::detail { + AddonSoundArchiveContainer::AddonSoundArchiveContainer() = default; AddonSoundArchiveContainer::~AddonSoundArchiveContainer() { @@ -11,8 +12,8 @@ AddonSoundArchiveContainer::~AddonSoundArchiveContainer() { m_pSoundDataManager = nullptr; } -bool AddonSoundArchiveContainer::Initialize(const char* soundArchiveName, - const AddonSoundArchive* pSoundArchive, +bool AddonSoundArchiveContainer::Initialize(const char* soundArchiveName, + const AddonSoundArchive* pSoundArchive, const SoundDataManager* pSoundDataManager) { util::Strlcpy(m_SoundArchiveName, soundArchiveName, sizeof(m_SoundArchiveName)); m_IsActive = true; @@ -30,12 +31,17 @@ void AddonSoundArchiveContainer::Finalize() { } bool AddonSoundArchiveContainer::IsSameName(const char* name) const { - int nameLength {util::Strnlen(name, SoundArchiveNameLengthMax)}; + int nameLength{util::Strnlen(name, SoundArchiveNameLengthMax)}; if (nameLength == SoundArchiveNameLengthMax) return false; - int result {util::Strncmp(name, m_SoundArchiveName, SoundArchiveNameLengthMax)}; + int result{util::Strncmp(name, m_SoundArchiveName, SoundArchiveNameLengthMax)}; return result == 0; } -} // namespace nn::atk::detail \ No newline at end of file + +void AddonSoundArchiveContainer::SetAddTick(const os::Tick& tick) { + m_AddTick = tick; +} + +} // namespace nn::atk::detail \ No newline at end of file From f6c79c04e6698ebc128b4d0d3b71a03da7e69ba8 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 3 Sep 2026 19:30:27 -0400 Subject: [PATCH 489/785] atk: Match `CurveAdshr::Reset` --- include/nn/atk/atk_CurveAdshr.h | 75 ++++++++----------- .../atk/detail/util/atk_CurveAdshr.cpp | 10 +++ 2 files changed, 40 insertions(+), 45 deletions(-) diff --git a/include/nn/atk/atk_CurveAdshr.h b/include/nn/atk/atk_CurveAdshr.h index 5f9101dd..61168619 100644 --- a/include/nn/atk/atk_CurveAdshr.h +++ b/include/nn/atk/atk_CurveAdshr.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail { + class CurveAdshr { public: enum Status { @@ -13,64 +14,48 @@ class CurveAdshr { Status_Release, }; - constexpr static f32 VolumeInit = -90.4; - constexpr static f32 AttackInit = 127; - constexpr static u32 HoldInit = 0; - constexpr static f32 DecayInit = 127; - constexpr static f32 SustainInit = 127; - constexpr static f32 ReleaseInit = 127; - - constexpr static u32 DecibelSquareTableSize = 128; - constexpr static u32 CalcDecibelScaleMax = 127; - - constexpr static u16 DecibelSquareTable[DecibelSquareTableSize] = { - 64813, 64814, 64815, 64885, 64935, 64974, 65006, 65033, - 65056, 65076, 65094, 65111, 65126, 65140, 65153, 65165, - 65176, 65187, 65197, 65206, 65215, 65223, 65231, 65239, - 65247, 65254, 65260, 65267, 65273, 65279, 65285, 65291, - 65297, 65302, 65307, 65312, 65317, 65322, 65326, 65331, - 65335, 65340, 65344, 65348, 65352, 65356, 65360, 65363, - 65367, 65371, 65374, 65378, 65381, 65384, 65387, 65391, - 65394, 65397, 65400, 65403, 65406, 65409, 65411, 65414, - 65417, 65420, 65422, 65425, 65427, 65430, 65433, 65435, - 65437, 65440, 65442, 65445, 65447, 65449, 65451, 65454, - 65456, 65458, 65460, 65462, 65464, 65466, 65468, 65470, - 65472, 65474, 65476, 65478, 65480, 65482, 65484, 65486, - 65487, 65489, 65491, 65493, 65494, 65496, 65498, 65500, - 65501, 65503, 65505, 65506, 65508, 65509, 65511, 65513, - 65514, 65516, 65517, 65519, 65520, 65522, 65523, 65525, - 65526, 65528, 65529, 65530, 65532, 65533, 65535, 0, - }; + static const float VolumeInit; + static const int AttackInit = 127; + static const int HoldInit = 0; + static const int DecayInit = 127; + static const int SustainInit = 127; + static const int ReleaseInit = 127; - CurveAdshr(); + static const int DecibelSquareTableSize = 128; + static const int CalcDecibelScaleMax = 127; - void Initialize(f32 initDecibel); + static const u16 DecibelSquareTable[DecibelSquareTableSize]; - void SetAttack(s32 attack); - void SetHold(s32 hold); - void SetDecay(s32 decay); - void SetSustain(s32 sustain); - void SetRelease(s32 release); + CurveAdshr(); - void Reset(f32 initDecibel); + void Initialize(float initDecibel); + void Reset(float initDecibel); + void Update(int msec); + float GetValue() const; - f32 GetValue() const; + Status GetStatus() const { return m_Status; } + void SetStatus(Status status) { m_Status = status; } - void Update(s32 msec); + void SetAttack(int attack); + void SetHold(int hold); + void SetDecay(int decay); + void SetSustain(int sustain); + void SetRelease(int release); - static u16 CalcDecibelSquare(s32); - static f32 CalcRelease(s32); + static float CalcRelease(int release); + static s16 CalcDecibelSquare(int scale); private: Status m_Status{Status_Attack}; - f32 m_Value{-904.0}; - f32 m_Decay{65535.0}; - f32 m_Release{65535.0}; - f32 m_Attack{0.0}; + float m_Value{-904.0}; + float m_Decay{65535.0}; + float m_Release{65535.0}; + float m_Attack{0.0}; u16 m_Hold{0}; u16 m_HoldCounter; u8 m_Sustain{127}; u8 m_Padding[3]; }; static_assert(sizeof(CurveAdshr) == 0x1c); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp index e69de29b..a5c27eca 100644 --- a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp +++ b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp @@ -0,0 +1,10 @@ +#include + +namespace nn::atk::detail { + +void CurveAdshr::Reset(float initDecibel) { + m_Value = initDecibel * 10; + m_Status = Status_Attack; +} + +} // namespace nn::atk::detail \ No newline at end of file From 7e5fc5975a23de4d03849ec8ff0a8a3cc71e1807 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 3 Sep 2026 20:20:37 -0400 Subject: [PATCH 490/785] atk: Match `CurveAdshr::CalcRelease` --- include/nn/atk/atk_CurveAdshr.h | 2 +- src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_CurveAdshr.h b/include/nn/atk/atk_CurveAdshr.h index 61168619..40310d0c 100644 --- a/include/nn/atk/atk_CurveAdshr.h +++ b/include/nn/atk/atk_CurveAdshr.h @@ -14,7 +14,7 @@ class CurveAdshr { Status_Release, }; - static const float VolumeInit; + static constexpr float VolumeInit = -90.4; static const int AttackInit = 127; static const int HoldInit = 0; static const int DecayInit = 127; diff --git a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp index a5c27eca..4f8f1675 100644 --- a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp +++ b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp @@ -7,4 +7,17 @@ void CurveAdshr::Reset(float initDecibel) { m_Status = Status_Attack; } +float CurveAdshr::CalcRelease(int release) { + if (release == ReleaseInit) + return 4.0f * 128 * 128 - 1; + + if (release == ReleaseInit - 1) + return 120 / 5.0f; + + if (release < 50) + return static_cast((release * 2) + 1) / 128.0f / 5.0f; + + return (60.0f / static_cast(126 - release)) / 5.0f; +} + } // namespace nn::atk::detail \ No newline at end of file From f45316a612be5e929a1c9d6db231ba70f2d7039c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 3 Sep 2026 20:20:56 -0400 Subject: [PATCH 491/785] atk: Match `CurveAdshr::SetDecay` --- src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp index 4f8f1675..b943f7b2 100644 --- a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp +++ b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp @@ -7,6 +7,10 @@ void CurveAdshr::Reset(float initDecibel) { m_Status = Status_Attack; } +void CurveAdshr::SetDecay(int decay) { + m_Decay = CalcRelease(decay); +} + float CurveAdshr::CalcRelease(int release) { if (release == ReleaseInit) return 4.0f * 128 * 128 - 1; From aaeab99c545ff68bc48927e1f8acbd16fbeae1a0 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 3 Sep 2026 20:22:00 -0400 Subject: [PATCH 492/785] atk: Match `CurveAdshr::SetRelease` --- src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp index b943f7b2..23cd037b 100644 --- a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp +++ b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp @@ -11,6 +11,10 @@ void CurveAdshr::SetDecay(int decay) { m_Decay = CalcRelease(decay); } +void CurveAdshr::SetRelease(int release) { + m_Release = CalcRelease(release); +} + float CurveAdshr::CalcRelease(int release) { if (release == ReleaseInit) return 4.0f * 128 * 128 - 1; From ed0f9551fd1bc0e513c36e7de1dff435b1d2e23e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 3 Sep 2026 20:24:30 -0400 Subject: [PATCH 493/785] atk: Match `CurveAdshr::SetSustain` --- src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp index 23cd037b..e32d5d25 100644 --- a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp +++ b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp @@ -11,15 +11,19 @@ void CurveAdshr::SetDecay(int decay) { m_Decay = CalcRelease(decay); } +void CurveAdshr::SetSustain(int sustain) { + m_Sustain = sustain; +} + void CurveAdshr::SetRelease(int release) { m_Release = CalcRelease(release); } float CurveAdshr::CalcRelease(int release) { - if (release == ReleaseInit) + if (release == 127) return 4.0f * 128 * 128 - 1; - if (release == ReleaseInit - 1) + if (release == 126) return 120 / 5.0f; if (release < 50) From b96acc33148739d89c176628269fa403486a0dc0 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 3 Sep 2026 20:43:53 -0400 Subject: [PATCH 494/785] atk: Match `CurveAdshr::SetAttack` --- .../atk/detail/util/atk_CurveAdshr.cpp | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp index e32d5d25..05b07011 100644 --- a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp +++ b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp @@ -7,6 +7,47 @@ void CurveAdshr::Reset(float initDecibel) { m_Status = Status_Attack; } +void CurveAdshr::SetAttack(int attack) { + // Table to optimize calculations + // More info here: https://github.com/stupidestmodder/TuneBloom/blob/master/TuneBloom/src/snd-ply/CurveAdshr.cpp#L127 + static const float attackTable[DecibelSquareTableSize] = { + 0.99921750, 0.99843258, 0.99764520, 0.99685530, + 0.99606287, 0.99526790, 0.99447040, 0.99367040, + 0.99286770, 0.99206250, 0.99125460, 0.99044410, + 0.98963088, 0.98881510, 0.98799650, 0.98717520, + 0.98635119, 0.98552440, 0.98469490, 0.98386250, + 0.98302728, 0.98218930, 0.98134828, 0.98050450, + 0.97965780, 0.97880810, 0.97795550, 0.97709990, + 0.97624129, 0.97537970, 0.97451500, 0.97364718, + 0.97277629, 0.97190230, 0.97102510, 0.97014480, + 0.96926120, 0.96837437, 0.96748440, 0.96659100, + 0.96569440, 0.96479440, 0.96389100, 0.96298420, + 0.96207398, 0.96116040, 0.96024328, 0.95932257, + 0.95839840, 0.95747060, 0.95653920, 0.95560420, + 0.95466548, 0.95372307, 0.95277690, 0.95182699, + 0.95087320, 0.94991570, 0.94895420, 0.94798880, + 0.94701950, 0.94604617, 0.94506890, 0.94408750, + 0.94310200, 0.94211239, 0.94111860, 0.94012058, + 0.93911839, 0.93811178, 0.93710089, 0.93608558, + 0.93506590, 0.93404168, 0.93301308, 0.93197978, + 0.93094200, 0.92989950, 0.92885230, 0.92780040, + 0.92674360, 0.92568210, 0.92461560, 0.92354420, + 0.92246780, 0.92138640, 0.92029980, 0.91920810, + 0.91811120, 0.91700910, 0.91590160, 0.91478870, + 0.91367030, 0.91254650, 0.91141710, 0.91028208, + 0.90914140, 0.90799490, 0.90684270, 0.90568447, + 0.90452039, 0.90335017, 0.90217400, 0.90099160, + 0.89980290, 0.89860800, 0.89740658, 0.89619880, + 0.89498440, 0.89005989, 0.88246220, 0.87592470, + 0.86918610, 0.86364060, 0.85357880, 0.84301889, + 0.82861350, 0.81490988, 0.80021720, 0.77806628, + 0.75547498, 0.72421250, 0.68282390, 0.63291690, + 0.55921350, 0.45514110, 0.32987699, 0.00000000 + }; + + m_Attack = attackTable[attack]; +} + void CurveAdshr::SetDecay(int decay) { m_Decay = CalcRelease(decay); } From 356d26af5602a6a469ab010e67b9886310cef3bd Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 3 Sep 2026 20:49:57 -0400 Subject: [PATCH 495/785] atk: Match `CurveAdshr::SetHold` --- src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp index 05b07011..0fafcf0e 100644 --- a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp +++ b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp @@ -48,6 +48,10 @@ void CurveAdshr::SetAttack(int attack) { m_Attack = attackTable[attack]; } +void CurveAdshr::SetHold(int hold) { + m_Hold = static_cast((hold + 1) * (hold + 1) / 4); +} + void CurveAdshr::SetDecay(int decay) { m_Decay = CalcRelease(decay); } From 49e8c91e00e30c504ddf4b945e06159ffb8fb314 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 3 Sep 2026 20:54:14 -0400 Subject: [PATCH 496/785] atk: Match `CurveAdshr::Initialize` --- src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp index 0fafcf0e..01052f87 100644 --- a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp +++ b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp @@ -2,6 +2,16 @@ namespace nn::atk::detail { +void CurveAdshr::Initialize(float initDecibel) { + SetAttack(AttackInit); + SetHold(HoldInit); + SetDecay(DecayInit); + SetSustain(SustainInit); + SetRelease(ReleaseInit); + + Reset(initDecibel); +} + void CurveAdshr::Reset(float initDecibel) { m_Value = initDecibel * 10; m_Status = Status_Attack; From 36bf8723ddea8152b8052dacdb625b2a90e17189 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 3 Sep 2026 21:02:38 -0400 Subject: [PATCH 497/785] atk: Match `CurveAdshr::GetValue` --- include/nn/atk/atk_CurveAdshr.h | 4 +-- .../atk/detail/util/atk_CurveAdshr.cpp | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_CurveAdshr.h b/include/nn/atk/atk_CurveAdshr.h index 40310d0c..42de1948 100644 --- a/include/nn/atk/atk_CurveAdshr.h +++ b/include/nn/atk/atk_CurveAdshr.h @@ -14,7 +14,7 @@ class CurveAdshr { Status_Release, }; - static constexpr float VolumeInit = -90.4; + static const float VolumeInit; static const int AttackInit = 127; static const int HoldInit = 0; static const int DecayInit = 127; @@ -24,7 +24,7 @@ class CurveAdshr { static const int DecibelSquareTableSize = 128; static const int CalcDecibelScaleMax = 127; - static const u16 DecibelSquareTable[DecibelSquareTableSize]; + static const s16 DecibelSquareTable[DecibelSquareTableSize]; CurveAdshr(); diff --git a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp index 01052f87..7b368a93 100644 --- a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp +++ b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp @@ -2,6 +2,27 @@ namespace nn::atk::detail { +const float CurveAdshr::VolumeInit {-90.4}; + +const s16 CurveAdshr::DecibelSquareTable[CurveAdshr::DecibelSquareTableSize] = { + -723, -722, -721, -651, -601, -562, -530, -503, + -480, -460, -442, -425, -410, -396, -383, -371, + -360, -349, -339, -330, -321, -313, -305, -297, + -289, -282, -276, -269, -263, -257, -251, -245, + -239, -234, -229, -224, -219, -214, -210, -205, + -201, -196, -192, -188, -184, -180, -176, -173, + -169, -165, -162, -158, -155, -152, -149, -145, + -142, -139, -136, -133, -130, -127, -125, -122, + -119, -116, -114, -111, -109, -106, -103, -101, + -99, -96, -94, -91, -89, -87, -85, -82, + -80, -78, -76, -74, -72, -70, -68, -66, + -64, -62, -60, -58, -56, -54, -52, -50, + -49, -47, -45, -43, -42, -40, -38, -36, + -35, -33, -31, -30, -28, -27, -25, -23, + -22, -20, -19, -17, -16, -14, -13, -11, + -10, -8, -7, -6, -4, -3, -1, 0 +}; + void CurveAdshr::Initialize(float initDecibel) { SetAttack(AttackInit); SetHold(HoldInit); @@ -17,6 +38,13 @@ void CurveAdshr::Reset(float initDecibel) { m_Status = Status_Attack; } +float CurveAdshr::GetValue() const { + if (m_Status == Status_Attack && m_Attack == 0) + return 0; + + return m_Value / 10.0f; +} + void CurveAdshr::SetAttack(int attack) { // Table to optimize calculations // More info here: https://github.com/stupidestmodder/TuneBloom/blob/master/TuneBloom/src/snd-ply/CurveAdshr.cpp#L127 From b150805ee577a786116f29c539d149a32c4bb1d1 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 4 Sep 2026 10:48:52 -0400 Subject: [PATCH 498/785] atk: Match `FileStreamImpl::SeekDirect` Co-authored-by: Narr the Reg <5944268+german77@users.noreply.github.com> --- include/nn/atk/atk_CurveAdshr.h | 14 ++--- include/nn/atk/fnd/basis/atkfnd_Inlines.h | 20 ++++++- include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h | 47 ++++++--------- .../fnd/io/atkfnd_FileStreamImpl.win32.cpp | 59 +++++++++---------- 4 files changed, 69 insertions(+), 71 deletions(-) diff --git a/include/nn/atk/atk_CurveAdshr.h b/include/nn/atk/atk_CurveAdshr.h index 42de1948..ac5c78a9 100644 --- a/include/nn/atk/atk_CurveAdshr.h +++ b/include/nn/atk/atk_CurveAdshr.h @@ -46,14 +46,14 @@ class CurveAdshr { static s16 CalcDecibelSquare(int scale); private: - Status m_Status{Status_Attack}; - float m_Value{-904.0}; - float m_Decay{65535.0}; - float m_Release{65535.0}; - float m_Attack{0.0}; - u16 m_Hold{0}; + Status m_Status; + float m_Value; + float m_Decay; + float m_Release; + float m_Attack; + u16 m_Hold; u16 m_HoldCounter; - u8 m_Sustain{127}; + u8 m_Sustain; u8 m_Padding[3]; }; static_assert(sizeof(CurveAdshr) == 0x1c); diff --git a/include/nn/atk/fnd/basis/atkfnd_Inlines.h b/include/nn/atk/fnd/basis/atkfnd_Inlines.h index af14739c..81eef1d9 100644 --- a/include/nn/atk/fnd/basis/atkfnd_Inlines.h +++ b/include/nn/atk/fnd/basis/atkfnd_Inlines.h @@ -3,15 +3,28 @@ #include namespace nn::atk::detail::fnd { + template -inline T Clamp(T x, T low, T high); +inline T ClampMin(T x, T low) { + return x < low ? low : x; +} + +template +inline T ClampMax(T x, T high) { + return x > high ? high : x; +} + +template +inline T Clamp(T x, T low, T high) { + return ClampMax(ClampMin(x, low), high); +} inline float FloatClamp(float value, float min, float max); template inline ValueT RoundUp(ValueT x, int base); -// TODO: figure out if this is correct for +// TODO: figure out if this is correct for // void* RoundUp(void* x, int base) template inline ValueT* RoundUp(ValueT* x, int base); @@ -33,4 +46,5 @@ inline ptrdiff_t GetOffsetFromPtr(const void* start, const void* end) { template inline void* AddOffsetToPtr(void* ptr, TOffset offset); -} // namespace nn::atk::detail::fnd \ No newline at end of file + +} // namespace nn::atk::detail::fnd \ No newline at end of file diff --git a/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h b/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h index a8a8970c..75cf5152 100644 --- a/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h +++ b/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h @@ -7,34 +7,25 @@ namespace nn::atk::detail::fnd { class FileStreamImpl : public FileStream { NN_NO_COPY(FileStreamImpl); + public: class DirectStream : public Stream { public: DirectStream() = default; void Initialize(FileStreamImpl& fileStream); - + void Close() override {} - bool IsOpened() const override { - return m_Owner->IsOpened(); - } - - bool CanRead() const override { - return m_Owner->CanRead(); - } + bool IsOpened() const override { return m_Owner->IsOpened(); } - bool CanWrite() const override { - return m_Owner->CanWrite(); - } + bool CanRead() const override { return m_Owner->CanRead(); } - bool CanSeek() const override { - return m_Owner->CanSeek(); - } + bool CanWrite() const override { return m_Owner->CanWrite(); } - size_t GetSize() const override { - return m_Owner->GetSize(); - } + bool CanSeek() const override { return m_Owner->CanSeek(); } + + size_t GetSize() const override { return m_Owner->GetSize(); } size_t Read(void* buf, size_t length, FndResult* result) override { return m_Owner->ReadDirect(buf, length, result); @@ -47,10 +38,8 @@ class FileStreamImpl : public FileStream { FndResult Seek(position_t offset, SeekOrigin origin) override { return m_Owner->SeekDirect(offset, origin); } - - position_t GetCurrentPosition() const override { - return m_Owner->m_CurrentPosition; - } + + position_t GetCurrentPosition() const override { return m_Owner->m_CurrentPosition; } ~DirectStream() override = default; @@ -80,10 +69,8 @@ class FileStreamImpl : public FileStream { size_t Read(void* buf, size_t length, FndResult* result) override; size_t Write(const void* buf, size_t length, FndResult* result) override; FndResult Seek(position_t offset, SeekOrigin origin) override; - - position_t GetCurrentPosition() const override { - return m_CurrentPosition; - } + + position_t GetCurrentPosition() const override { return m_CurrentPosition; } void EnableCache(void* buffer, size_t length) override; void DisableCache() override; @@ -104,14 +91,14 @@ class FileStreamImpl : public FileStream { void ValidateAlignment([[maybe_unused]] const void* buf) const; - fs::FileHandle m_FileHandle {0}; - bool m_IsOpened {false}; + fs::FileHandle m_FileHandle{0}; + bool m_IsOpened{false}; u8 m_Padding[3]; size_t m_FileSize; - position_t m_CurrentPosition {0}; + position_t m_CurrentPosition{0}; StreamCache m_StreamCache; DirectStream m_DirectStream; - FsAccessLog* m_pAccessLog {nullptr}; + FsAccessLog* m_pAccessLog{nullptr}; }; static_assert(sizeof(FileStreamImpl) == 0x80); -} // namespace nn::atk::detail::fnd \ No newline at end of file +} // namespace nn::atk::detail::fnd \ No newline at end of file diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp index c4b2ef2e..d0aa1900 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp @@ -1,37 +1,37 @@ #include +#include + #include +#include + namespace nn::atk::detail::fnd { -namespace { -fs::OpenMode ConvertAccessMode(FileStream::AccessMode accessMode) { -} +namespace { +fs::OpenMode ConvertAccessMode(FileStream::AccessMode accessMode) {} -// NON_MATCHING: still unsure of logic. position_t GetSeekPosition(FileStreamImpl& target, position_t offset, Stream::SeekOrigin origin) { position_t targetSizeEnd = target.GetSize(); - position_t result {0}; + position_t result{0}; switch (origin) { case Stream::SeekOrigin_Begin: - result = offset >= 0 ? offset : 0; + result = std::max(offset, 0L); break; case Stream::SeekOrigin_End: - result = targetSizeEnd - (offset < 0 ? offset : 0); + result = targetSizeEnd - std::min(offset, 0L); break; case Stream::SeekOrigin_Current: - if (offset > 0) { - position_t position {target.GetCurrentPosition()}; - if (position + offset <= targetSizeEnd) - result = position + offset; - else - result = targetSizeEnd; - } - else if (offset < 0) { - if (0 < target.GetCurrentPosition() + offset) - result = target.GetCurrentPosition() + offset; - } + if (offset > 0) + result = ClampMax(target.GetCurrentPosition() + offset, targetSizeEnd); + + else if (offset >= 0) + result = target.GetCurrentPosition(); + + else if (target.GetCurrentPosition() > -offset) + result = target.GetCurrentPosition() + offset; + break; default: result = 0; @@ -40,7 +40,7 @@ position_t GetSeekPosition(FileStreamImpl& target, position_t offset, Stream::Se return result; } -} // anonymous namespace +} // anonymous namespace FileStreamImpl::FileStreamImpl() { m_DirectStream.m_Owner = this; @@ -66,7 +66,7 @@ bool FileStreamImpl::IsOpened() const { // NON_MATCHING: needs symbol for nn::diag::detail::AbortImpl size_t FileStreamImpl::GetSize() const { s64 fileSize; - Result result {fs::GetFileSize(&fileSize, m_FileHandle)}; + Result result{fs::GetFileSize(&fileSize, m_FileHandle)}; if (result.IsSuccess()) return fileSize & 0xffffffff; @@ -81,16 +81,15 @@ int FileStreamImpl::GetIoBufferAlignment() const { size_t FileStreamImpl::ReadDirect(void* buf, size_t length, FndResult* result) { ValidateAlignment(buf); - size_t readFileLength {0}; - Result nnResult {fs::ReadFile(&readFileLength, m_FileHandle, m_CurrentPosition, buf, length)}; + size_t readFileLength{0}; + Result nnResult{fs::ReadFile(&readFileLength, m_FileHandle, m_CurrentPosition, buf, length)}; FndResult readResult; if (nnResult.IsSuccess()) { readResult = FndResult{readFileLength != length}; m_CurrentPosition += readFileLength; - } - else { + } else { readResult = FndResult{FndResultType_IoError}; } @@ -106,14 +105,12 @@ size_t FileStreamImpl::WriteDirect(const void* buf, size_t length, FndResult* re FndResult writeResult; fs::WriteOption option; - Result nnResult {fs::WriteFile(m_FileHandle, m_CurrentPosition, buf, length, option)}; - + Result nnResult{fs::WriteFile(m_FileHandle, m_CurrentPosition, buf, length, option)}; if (nnResult.IsSuccess()) { writeResult = FndResult{FndResultType_True}; m_CurrentPosition += length; - } - else { + } else { writeResult = FndResult{FndResultType_IoError}; } @@ -123,10 +120,10 @@ size_t FileStreamImpl::WriteDirect(const void* buf, size_t length, FndResult* re return length; } -// NON_MATCHING: needs GetSeekPosition FndResult FileStreamImpl::SeekDirect(position_t offset, SeekOrigin origin) { - position_t seekPosition {GetSeekPosition(*this, offset, origin)}; + position_t seekPosition{GetSeekPosition(*this, offset, origin)}; m_CurrentPosition = seekPosition; return FndResult{FndResultType_True}; } -} // namespace nn::atk::detail::fnd \ No newline at end of file + +} // namespace nn::atk::detail::fnd \ No newline at end of file From a7be62fc57428d2ae8d39585947650827a5df544 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 4 Sep 2026 12:18:49 -0400 Subject: [PATCH 499/785] atk: Match `CurveAdshr::Update` Using implementation from [TuneBloom](https://github.com/stupidestmodder/TuneBloom/blob/master/TuneBloom/src/snd-ply/CurveAdshr.cpp#L45) --- .../atk/detail/util/atk_CurveAdshr.cpp | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp index 7b368a93..655486ea 100644 --- a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp +++ b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp @@ -38,6 +38,55 @@ void CurveAdshr::Reset(float initDecibel) { m_Status = Status_Attack; } +void CurveAdshr::Update(int msec) { + switch (m_Status) { + case Status_Attack: + for (; msec > 0; --msec) { + m_Value *= m_Attack; + + if (m_Value > -1.0f / 32.0f) { + m_Value = 0.0f; + m_Status = Status_Hold; + m_HoldCounter = m_Hold; + break; + } + } + + break; + + case Status_Hold: + if (msec < m_HoldCounter) { + m_HoldCounter -= static_cast(msec); + } else { + msec -= m_HoldCounter; + m_HoldCounter = 0; + m_Status = Status_Decay; + } + + if (m_Status != Status_Decay) + break; + + case Status_Decay: { + const float sustainDecay = CurveAdshr::CalcDecibelSquare(m_Sustain); + + m_Value -= m_Decay * msec; + if (m_Value < sustainDecay) { + m_Value = sustainDecay; + m_Status = Status_Sustain; + } + + break; + } + + case Status_Sustain: + break; + + case Status_Release: + m_Value -= m_Release * msec; + break; + } +} + float CurveAdshr::GetValue() const { if (m_Status == Status_Attack && m_Attack == 0) return 0; @@ -115,4 +164,8 @@ float CurveAdshr::CalcRelease(int release) { return (60.0f / static_cast(126 - release)) / 5.0f; } +s16 CurveAdshr::CalcDecibelSquare(int scale) { + return DecibelSquareTable[scale]; +} + } // namespace nn::atk::detail \ No newline at end of file From 140c676b960b7d5c5416994533d118468735acec Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 4 Sep 2026 12:20:43 -0400 Subject: [PATCH 500/785] atk: Match `CurveAdshr::CurveAdshr` --- .../atk/detail/util/atk_CurveAdshr.cpp | 90 ++++++++----------- 1 file changed, 36 insertions(+), 54 deletions(-) diff --git a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp index 655486ea..abc5729a 100644 --- a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp +++ b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp @@ -2,26 +2,21 @@ namespace nn::atk::detail { -const float CurveAdshr::VolumeInit {-90.4}; +const float CurveAdshr::VolumeInit{-90.4}; const s16 CurveAdshr::DecibelSquareTable[CurveAdshr::DecibelSquareTableSize] = { - -723, -722, -721, -651, -601, -562, -530, -503, - -480, -460, -442, -425, -410, -396, -383, -371, - -360, -349, -339, -330, -321, -313, -305, -297, - -289, -282, -276, -269, -263, -257, -251, -245, - -239, -234, -229, -224, -219, -214, -210, -205, - -201, -196, -192, -188, -184, -180, -176, -173, - -169, -165, -162, -158, -155, -152, -149, -145, - -142, -139, -136, -133, -130, -127, -125, -122, - -119, -116, -114, -111, -109, -106, -103, -101, - -99, -96, -94, -91, -89, -87, -85, -82, - -80, -78, -76, -74, -72, -70, -68, -66, - -64, -62, -60, -58, -56, -54, -52, -50, - -49, -47, -45, -43, -42, -40, -38, -36, - -35, -33, -31, -30, -28, -27, -25, -23, - -22, -20, -19, -17, -16, -14, -13, -11, - -10, -8, -7, -6, -4, -3, -1, 0 -}; + -723, -722, -721, -651, -601, -562, -530, -503, -480, -460, -442, -425, -410, -396, -383, -371, + -360, -349, -339, -330, -321, -313, -305, -297, -289, -282, -276, -269, -263, -257, -251, -245, + -239, -234, -229, -224, -219, -214, -210, -205, -201, -196, -192, -188, -184, -180, -176, -173, + -169, -165, -162, -158, -155, -152, -149, -145, -142, -139, -136, -133, -130, -127, -125, -122, + -119, -116, -114, -111, -109, -106, -103, -101, -99, -96, -94, -91, -89, -87, -85, -82, + -80, -78, -76, -74, -72, -70, -68, -66, -64, -62, -60, -58, -56, -54, -52, -50, + -49, -47, -45, -43, -42, -40, -38, -36, -35, -33, -31, -30, -28, -27, -25, -23, + -22, -20, -19, -17, -16, -14, -13, -11, -10, -8, -7, -6, -4, -3, -1, 0}; + +CurveAdshr::CurveAdshr() { + Initialize(VolumeInit); +} void CurveAdshr::Initialize(float initDecibel) { SetAttack(AttackInit); @@ -69,7 +64,7 @@ void CurveAdshr::Update(int msec) { case Status_Decay: { const float sustainDecay = CurveAdshr::CalcDecibelSquare(m_Sustain); - m_Value -= m_Decay * msec; + m_Value -= m_Decay * static_cast(msec); if (m_Value < sustainDecay) { m_Value = sustainDecay; m_Status = Status_Sustain; @@ -82,7 +77,7 @@ void CurveAdshr::Update(int msec) { break; case Status_Release: - m_Value -= m_Release * msec; + m_Value -= m_Release * static_cast(msec); break; } } @@ -96,41 +91,28 @@ float CurveAdshr::GetValue() const { void CurveAdshr::SetAttack(int attack) { // Table to optimize calculations - // More info here: https://github.com/stupidestmodder/TuneBloom/blob/master/TuneBloom/src/snd-ply/CurveAdshr.cpp#L127 + // More info here: + // https://github.com/stupidestmodder/TuneBloom/blob/master/TuneBloom/src/snd-ply/CurveAdshr.cpp#L127 static const float attackTable[DecibelSquareTableSize] = { - 0.99921750, 0.99843258, 0.99764520, 0.99685530, - 0.99606287, 0.99526790, 0.99447040, 0.99367040, - 0.99286770, 0.99206250, 0.99125460, 0.99044410, - 0.98963088, 0.98881510, 0.98799650, 0.98717520, - 0.98635119, 0.98552440, 0.98469490, 0.98386250, - 0.98302728, 0.98218930, 0.98134828, 0.98050450, - 0.97965780, 0.97880810, 0.97795550, 0.97709990, - 0.97624129, 0.97537970, 0.97451500, 0.97364718, - 0.97277629, 0.97190230, 0.97102510, 0.97014480, - 0.96926120, 0.96837437, 0.96748440, 0.96659100, - 0.96569440, 0.96479440, 0.96389100, 0.96298420, - 0.96207398, 0.96116040, 0.96024328, 0.95932257, - 0.95839840, 0.95747060, 0.95653920, 0.95560420, - 0.95466548, 0.95372307, 0.95277690, 0.95182699, - 0.95087320, 0.94991570, 0.94895420, 0.94798880, - 0.94701950, 0.94604617, 0.94506890, 0.94408750, - 0.94310200, 0.94211239, 0.94111860, 0.94012058, - 0.93911839, 0.93811178, 0.93710089, 0.93608558, - 0.93506590, 0.93404168, 0.93301308, 0.93197978, - 0.93094200, 0.92989950, 0.92885230, 0.92780040, - 0.92674360, 0.92568210, 0.92461560, 0.92354420, - 0.92246780, 0.92138640, 0.92029980, 0.91920810, - 0.91811120, 0.91700910, 0.91590160, 0.91478870, - 0.91367030, 0.91254650, 0.91141710, 0.91028208, - 0.90914140, 0.90799490, 0.90684270, 0.90568447, - 0.90452039, 0.90335017, 0.90217400, 0.90099160, - 0.89980290, 0.89860800, 0.89740658, 0.89619880, - 0.89498440, 0.89005989, 0.88246220, 0.87592470, - 0.86918610, 0.86364060, 0.85357880, 0.84301889, - 0.82861350, 0.81490988, 0.80021720, 0.77806628, - 0.75547498, 0.72421250, 0.68282390, 0.63291690, - 0.55921350, 0.45514110, 0.32987699, 0.00000000 - }; + 0.99921750, 0.99843258, 0.99764520, 0.99685530, 0.99606287, 0.99526790, 0.99447040, + 0.99367040, 0.99286770, 0.99206250, 0.99125460, 0.99044410, 0.98963088, 0.98881510, + 0.98799650, 0.98717520, 0.98635119, 0.98552440, 0.98469490, 0.98386250, 0.98302728, + 0.98218930, 0.98134828, 0.98050450, 0.97965780, 0.97880810, 0.97795550, 0.97709990, + 0.97624129, 0.97537970, 0.97451500, 0.97364718, 0.97277629, 0.97190230, 0.97102510, + 0.97014480, 0.96926120, 0.96837437, 0.96748440, 0.96659100, 0.96569440, 0.96479440, + 0.96389100, 0.96298420, 0.96207398, 0.96116040, 0.96024328, 0.95932257, 0.95839840, + 0.95747060, 0.95653920, 0.95560420, 0.95466548, 0.95372307, 0.95277690, 0.95182699, + 0.95087320, 0.94991570, 0.94895420, 0.94798880, 0.94701950, 0.94604617, 0.94506890, + 0.94408750, 0.94310200, 0.94211239, 0.94111860, 0.94012058, 0.93911839, 0.93811178, + 0.93710089, 0.93608558, 0.93506590, 0.93404168, 0.93301308, 0.93197978, 0.93094200, + 0.92989950, 0.92885230, 0.92780040, 0.92674360, 0.92568210, 0.92461560, 0.92354420, + 0.92246780, 0.92138640, 0.92029980, 0.91920810, 0.91811120, 0.91700910, 0.91590160, + 0.91478870, 0.91367030, 0.91254650, 0.91141710, 0.91028208, 0.90914140, 0.90799490, + 0.90684270, 0.90568447, 0.90452039, 0.90335017, 0.90217400, 0.90099160, 0.89980290, + 0.89860800, 0.89740658, 0.89619880, 0.89498440, 0.89005989, 0.88246220, 0.87592470, + 0.86918610, 0.86364060, 0.85357880, 0.84301889, 0.82861350, 0.81490988, 0.80021720, + 0.77806628, 0.75547498, 0.72421250, 0.68282390, 0.63291690, 0.55921350, 0.45514110, + 0.32987699, 0.00000000}; m_Attack = attackTable[attack]; } From 1253c17ad6cf4b321c12fb3d0999ff3173b7bdbd Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 4 Sep 2026 13:11:47 -0400 Subject: [PATCH 501/785] atk: Match `CurveLfo::InitializeCurveTable` Also matches global curve lfo functions --- include/nn/atk/atk_CurveLfo.h | 7 --- .../atk/detail/util/atk_CurveLfo.cpp | 53 +++++++++++++++++++ 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/include/nn/atk/atk_CurveLfo.h b/include/nn/atk/atk_CurveLfo.h index ed90e6e2..bb4766b1 100644 --- a/include/nn/atk/atk_CurveLfo.h +++ b/include/nn/atk/atk_CurveLfo.h @@ -3,12 +3,6 @@ #include namespace nn::atk::detail { -f32 CurveSine(f32 arg); -f32 CurveTriangle(f32 arg); -f32 CurveSaw(f32 arg); -f32 CurveSquare(f32 arg); -f32 CurveRandom(f32 arg); - struct CurveLfoParam { enum CurveType { CurveType_Min, @@ -62,5 +56,4 @@ class CurveLfo { }; static_assert(sizeof(CurveLfo) == 0x20); -static CurveLfo::CurveFunc g_CurveFuncTable[5]; } // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp b/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp index e69de29b..6791931b 100644 --- a/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp +++ b/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp @@ -0,0 +1,53 @@ +#include + +#include + +#include + +#include + +namespace nn::atk::detail { + +namespace { + +float CurveSine(float arg) { + return util::SinTable(static_cast(arg * UINT_MAX)); +} + +float CurveSquare(float arg) { + return arg < 0.5f ? 0.0f : 1.0f; +} + +float CurveSaw(float arg) { + return arg; +} + +float CurveTriangle(float arg) { + static const float gradients[5]{4.0, -4.0, -4.0, 4.0, 4.0}; + static const float intercepts[5]{0.0, 2.0, 2.0, -4.0, 0.0}; + + u32 tmp{static_cast(arg * 4)}; + + return gradients[tmp] * arg + intercepts[tmp]; +} + +float CurveRandom(float arg) { + u16 rand{Util::CalcRandom()}; + float ret{rand / 65535.0f}; + + return ret; +} + +CurveLfo::CurveFunc g_CurveFuncTable[128]; + +} // anonymous namespace + +void CurveLfo::InitializeCurveTable() { + std::memset(static_cast(g_CurveFuncTable), 0, sizeof(g_CurveFuncTable)); + g_CurveFuncTable[0] = CurveSine; + g_CurveFuncTable[1] = CurveTriangle; + g_CurveFuncTable[2] = CurveRandom; + g_CurveFuncTable[3] = CurveSaw; + g_CurveFuncTable[4] = CurveSquare; +} +} // namespace nn::atk::detail \ No newline at end of file From 8c2c42f70f1d59cb827567fa1c2f00a0be65e144 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 4 Sep 2026 13:24:45 -0400 Subject: [PATCH 502/785] atk: Match `CurveLfo::Reset` --- include/nn/atk/atk_CurveLfo.h | 53 +++++++++++-------- .../atk/detail/util/atk_CurveLfo.cpp | 11 +++- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/include/nn/atk/atk_CurveLfo.h b/include/nn/atk/atk_CurveLfo.h index bb4766b1..4a61e76f 100644 --- a/include/nn/atk/atk_CurveLfo.h +++ b/include/nn/atk/atk_CurveLfo.h @@ -3,12 +3,18 @@ #include namespace nn::atk::detail { + struct CurveLfoParam { + float depth; + float speed; + u32 delay; + u8 range; + u8 curve; + u8 phase; + u8 padding[1]; + enum CurveType { CurveType_Min, - CurveType_UserMin = 0x40, - CurveType_Max = 0x7f, - CurveType_UserMax = CurveType_Max, CurveType_Sine = CurveType_Min, CurveType_Triangle, @@ -16,40 +22,45 @@ struct CurveLfoParam { CurveType_Square, CurveType_Random, - CurveType_Count = 0x80, + CurveType_UserMin = 64, + CurveType_Max = 127, + CurveType_UserMax = CurveType_Max, + + CurveType_Count, }; - void Initialize(); + CurveLfoParam(); - f32 depth; - f32 speed; - u32 delay; - u8 range; - u8 curve; - u8 phase; - u8 padding[1]; + void Initialize(); }; static_assert(sizeof(CurveLfoParam) == 0x10); class CurveLfo { public: - using CurveFunc = f32(*)(f32); - static void InitializeCurveTable(); + CurveLfo() = default; + + void Reset(); + void Update(int msec); - void RegisterUserCurve(CurveFunc curveFunc, u32); - void UnregisterUserCurve(u32); + float GetValue() const; - void Reset(); - void Update(s32 msec); + void SetParam(const CurveLfoParam& param) { m_Param = param; } + CurveLfoParam& GetParam() { return m_Param; } + const CurveLfoParam& GetParam() const { return m_Param; } + + static void InitializeCurveTable(); + + using CurveFunc = float(*)(float); - f32 GetValue() const; + void RegisterUserCurve(CurveFunc func, u32 index); + void UnregisterUserCurve(u32 index); private: CurveLfoParam m_Param; u32 m_DelayCounter; - f32 m_Counter; - f32 m_RandomValue; + float m_Counter; + float m_RandomValue; bool m_IsStart; bool m_IsNext; u8 m_Padding[2]; diff --git a/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp b/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp index 6791931b..1b763b68 100644 --- a/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp +++ b/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp @@ -31,7 +31,7 @@ float CurveTriangle(float arg) { return gradients[tmp] * arg + intercepts[tmp]; } -float CurveRandom(float arg) { +float CurveRandom([[maybe_unused]] float arg) { u16 rand{Util::CalcRandom()}; float ret{rand / 65535.0f}; @@ -42,6 +42,14 @@ CurveLfo::CurveFunc g_CurveFuncTable[128]; } // anonymous namespace +void CurveLfo::Reset() { + m_Counter = 0.0f; + m_RandomValue = 1.0f; + m_DelayCounter = 0; + m_IsStart = false; + m_IsNext = false; +} + void CurveLfo::InitializeCurveTable() { std::memset(static_cast(g_CurveFuncTable), 0, sizeof(g_CurveFuncTable)); g_CurveFuncTable[0] = CurveSine; @@ -50,4 +58,5 @@ void CurveLfo::InitializeCurveTable() { g_CurveFuncTable[3] = CurveSaw; g_CurveFuncTable[4] = CurveSquare; } + } // namespace nn::atk::detail \ No newline at end of file From 7068fb6cfa7a05fac8e31f85876689881859dcdb Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 4 Sep 2026 13:38:13 -0400 Subject: [PATCH 503/785] atk: Match `CurveLfo::Update` --- .../atk/detail/util/atk_CurveLfo.cpp | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp b/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp index 1b763b68..1ffb98b2 100644 --- a/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp +++ b/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp @@ -50,6 +50,29 @@ void CurveLfo::Reset() { m_IsNext = false; } +void CurveLfo::Update(int msec) { + if (m_DelayCounter < m_Param.delay && m_DelayCounter + msec <= m_Param.delay) { + m_DelayCounter += msec; + return; + } + + if (m_DelayCounter < m_Param.delay) { + msec -= m_Param.delay - m_DelayCounter; + m_DelayCounter = m_Param.delay; + } + + if (m_Param.speed > 0.0f) { + if (!m_IsStart) { + m_Counter = m_Param.phase / 127.0f; + m_IsStart = true; + } + + m_Counter += (m_Param.speed * msec) / 1000.0f; + m_IsNext = m_Counter >= 1.0f; + m_Counter -= static_cast(m_Counter); + } +} + void CurveLfo::InitializeCurveTable() { std::memset(static_cast(g_CurveFuncTable), 0, sizeof(g_CurveFuncTable)); g_CurveFuncTable[0] = CurveSine; From d29aceea5e4ecf028811911c27ca5d3557bb83fa Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 4 Sep 2026 13:52:55 -0400 Subject: [PATCH 504/785] atk: Match `CurveLfo::GetValue` --- include/nn/atk/atk_CurveLfo.h | 2 +- .../atk/detail/util/atk_CurveLfo.cpp | 44 ++++++++++++++++--- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/include/nn/atk/atk_CurveLfo.h b/include/nn/atk/atk_CurveLfo.h index 4a61e76f..f9f25599 100644 --- a/include/nn/atk/atk_CurveLfo.h +++ b/include/nn/atk/atk_CurveLfo.h @@ -60,7 +60,7 @@ class CurveLfo { CurveLfoParam m_Param; u32 m_DelayCounter; float m_Counter; - float m_RandomValue; + mutable float m_RandomValue; bool m_IsStart; bool m_IsNext; u8 m_Padding[2]; diff --git a/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp b/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp index 1ffb98b2..f94c98e7 100644 --- a/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp +++ b/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp @@ -42,6 +42,15 @@ CurveLfo::CurveFunc g_CurveFuncTable[128]; } // anonymous namespace +void CurveLfo::InitializeCurveTable() { + std::memset(static_cast(g_CurveFuncTable), 0, sizeof(g_CurveFuncTable)); + g_CurveFuncTable[0] = CurveSine; + g_CurveFuncTable[1] = CurveTriangle; + g_CurveFuncTable[2] = CurveRandom; + g_CurveFuncTable[3] = CurveSaw; + g_CurveFuncTable[4] = CurveSquare; +} + void CurveLfo::Reset() { m_Counter = 0.0f; m_RandomValue = 1.0f; @@ -73,13 +82,34 @@ void CurveLfo::Update(int msec) { } } -void CurveLfo::InitializeCurveTable() { - std::memset(static_cast(g_CurveFuncTable), 0, sizeof(g_CurveFuncTable)); - g_CurveFuncTable[0] = CurveSine; - g_CurveFuncTable[1] = CurveTriangle; - g_CurveFuncTable[2] = CurveRandom; - g_CurveFuncTable[3] = CurveSaw; - g_CurveFuncTable[4] = CurveSquare; +float CurveLfo::GetValue() const { + if (m_Param.depth == 0.0f) + return 0.0f; + + if (m_DelayCounter < m_Param.delay) + return 0.0f; + + CurveFunc func{g_CurveFuncTable[m_Param.curve]}; + + float value{0}; + + if (func != nullptr) { + if (m_Param.curve == CurveLfoParam::CurveType_Random) { + if (m_IsNext) + m_RandomValue = func(m_Counter); + + value = m_RandomValue; + } else { + value = func(m_Counter); + } + } else { + value = 1.0f; + } + + value *= m_Param.depth; + value *= static_cast(m_Param.range); + + return value; } } // namespace nn::atk::detail \ No newline at end of file From a016c434e2b3bc3be692d7bc5dd1da55e6d4f979 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 4 Sep 2026 14:04:55 -0400 Subject: [PATCH 505/785] atk: Match `CurveLfo::RegisterUserCurve` --- include/nn/atk/atk_CurveLfo.h | 4 ++-- src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_CurveLfo.h b/include/nn/atk/atk_CurveLfo.h index f9f25599..48b9d134 100644 --- a/include/nn/atk/atk_CurveLfo.h +++ b/include/nn/atk/atk_CurveLfo.h @@ -53,8 +53,8 @@ class CurveLfo { using CurveFunc = float(*)(float); - void RegisterUserCurve(CurveFunc func, u32 index); - void UnregisterUserCurve(u32 index); + static CurveFunc RegisterUserCurve(CurveFunc func, u32 index); + static CurveFunc UnregisterUserCurve(u32 index); private: CurveLfoParam m_Param; diff --git a/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp b/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp index f94c98e7..be235096 100644 --- a/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp +++ b/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp @@ -51,6 +51,15 @@ void CurveLfo::InitializeCurveTable() { g_CurveFuncTable[4] = CurveSquare; } +CurveLfo::CurveFunc CurveLfo::RegisterUserCurve(CurveFunc func, u32 index) { + s32 tableIndex = {static_cast(index + CurveLfoParam::CurveType_UserMin)}; + + CurveFunc tmp{g_CurveFuncTable[tableIndex]}; + g_CurveFuncTable[tableIndex] = func; + + return tmp; +} + void CurveLfo::Reset() { m_Counter = 0.0f; m_RandomValue = 1.0f; From fed31c3f95220d302c522b18fcd93988c2a2ef9b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 4 Sep 2026 14:05:51 -0400 Subject: [PATCH 506/785] atk: Match `CurveLfo::UnregisterUserCurve` --- src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp b/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp index be235096..d9f83285 100644 --- a/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp +++ b/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp @@ -60,6 +60,15 @@ CurveLfo::CurveFunc CurveLfo::RegisterUserCurve(CurveFunc func, u32 index) { return tmp; } +CurveLfo::CurveFunc CurveLfo::UnregisterUserCurve(u32 index) { + s32 tableIndex = {static_cast(index + CurveLfoParam::CurveType_UserMin)}; + + CurveFunc tmp{g_CurveFuncTable[tableIndex]}; + g_CurveFuncTable[tableIndex] = nullptr; + + return tmp; +} + void CurveLfo::Reset() { m_Counter = 0.0f; m_RandomValue = 1.0f; From fd5961b62839e57eeb45ab26280f5de40a9766a9 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 4 Sep 2026 14:10:21 -0400 Subject: [PATCH 507/785] atk: Match `CurveLfoParam::Initialize` This matches all exported functions in `CurveLfo` and `CurveLfoParam` --- include/nn/atk/atk_CurveLfo.h | 2 +- src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_CurveLfo.h b/include/nn/atk/atk_CurveLfo.h index 48b9d134..db947652 100644 --- a/include/nn/atk/atk_CurveLfo.h +++ b/include/nn/atk/atk_CurveLfo.h @@ -29,7 +29,7 @@ struct CurveLfoParam { CurveType_Count, }; - CurveLfoParam(); + CurveLfoParam() = default; void Initialize(); }; diff --git a/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp b/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp index d9f83285..d55d0b92 100644 --- a/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp +++ b/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp @@ -130,4 +130,13 @@ float CurveLfo::GetValue() const { return value; } +void CurveLfoParam::Initialize() { + depth = 0.0f; + speed = 6.25f; + delay = 0; + range = 1; + curve = CurveType_Sine; + phase = 0; +} + } // namespace nn::atk::detail \ No newline at end of file From 610e74fd28b42bc83e8f3b1323d0afd205d446d5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 4 Sep 2026 14:29:21 -0400 Subject: [PATCH 508/785] atk: Match `FrameHeap` constructor --- include/nn/atk/atk_FrameHeap.h | 84 ++++++++++++------- .../atk/detail/util/atk_FrameHeap.cpp | 7 ++ 2 files changed, 60 insertions(+), 31 deletions(-) diff --git a/include/nn/atk/atk_FrameHeap.h b/include/nn/atk/atk_FrameHeap.h index 0333dc9f..88d675a2 100644 --- a/include/nn/atk/atk_FrameHeap.h +++ b/include/nn/atk/atk_FrameHeap.h @@ -6,21 +6,34 @@ #include namespace nn::atk::detail { + class FrameHeap { public: - using DisposeCallback = void(*)(void*, size_t, void*); - using HeapCallback = void(*)(void*); + using DisposeCallback = void (*)(void*, size_t, void*); + using HeapCallback = void (*)(void*); - constexpr static s32 HeapAlign = 64; + static const int HeapAlign{64}; class Block { public: - Block(); + Block(void* buffer, size_t size, DisposeCallback callback, + void* callbackArg, HeapCallback heapCallback, void* heapCallbackArg) + : m_pBuffer{buffer}, m_Size{size}, + m_Callback{callback}, m_pCallbackArg{callbackArg}, + m_HeapCallback{heapCallback}, m_pHeapCallbackArg{heapCallbackArg} {} + + void* GetBufferAddr() { return m_pBuffer; } + const void* GetBufferAddr() const { return m_pBuffer; } + + size_t GetBufferSize() const { return m_Size; } + DisposeCallback GetDisposeCallback() const { return m_Callback; } + void* GetDisposeCallbackArg() const { return m_pCallbackArg; } + HeapCallback GetHeapCallback() const { return m_HeapCallback; } + void* GetHeapCallbackArg() const { return m_pHeapCallbackArg; } - private: - friend FrameHeap; - util::IntrusiveListNode m_Link; + + private: void* m_pBuffer; size_t m_Size; DisposeCallback m_Callback; @@ -29,59 +42,68 @@ class FrameHeap { void* m_pHeapCallbackArg; }; - using BlockList = util::IntrusiveList>; + using BlockList = + util::IntrusiveList>; class Section { public: Section(); ~Section(); - void* AppendBlock(Block* block); - - void Dump(const SoundDataManager&, const SoundArchive&) const; + void AppendBlock(Block* block); - private: - friend FrameHeap; + const BlockList& GetBlockList() const { return m_BlockList; } + BlockList& GetBlockList() { return m_BlockList; } + + void* GetAddr() { return this; } + + void SetUseCallback(bool use) { m_UseCallback = use; } + + void Dump(const SoundDataManager& mgr, const SoundArchive& arc) const; util::IntrusiveListNode m_Link; + + private: BlockList m_BlockList; bool m_UseCallback; }; - - using SectionList = util::IntrusiveList>; FrameHeap(); ~FrameHeap(); - void Destroy(); - bool Create(void* startAddress, size_t size); - - bool NewSection(); - void ClearSection(); - - void Clear(); + void Destroy(); void* Alloc(size_t size, DisposeCallback callback, void* callbackArg, HeapCallback heapCallback, void* heapCallbackArg); - s32 SaveState(); - - bool ProcessCallback(s32 level); + void Clear(); - void LoadState(s32 state); + int SaveState(); + void LoadState(int level); - s32 GetCurrentLevel() const; + int GetCurrentLevel() const; size_t GetSize() const; size_t GetFreeSize() const; - void Dump(const SoundDataManager&, const SoundArchive&) const; + bool IsValid() const; + + void Dump(const SoundDataManager& mgr, const SoundArchive& arc) const; + + bool ProcessCallback(int level); private: - fnd::FrameHeapImpl* m_pHeap; + bool NewSection(); + void ClearSection(); + + fnd::FrameHeapImpl* m_pHeap{}; SectionList m_SectionList; }; static_assert(sizeof(FrameHeap) == 0x18); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp index e69de29b..26e7a73d 100644 --- a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp +++ b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp @@ -0,0 +1,7 @@ +#include + +namespace nn::atk::detail { + +FrameHeap::FrameHeap() = default; + +} // namespace nn::atk::detail \ No newline at end of file From b2298784599467f8b237e4665644ab2f96c88056 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 4 Sep 2026 14:33:25 -0400 Subject: [PATCH 509/785] atk: Match `FrameHeap::Destroy` --- include/nn/atk/atk_FrameHeap.h | 2 +- src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_FrameHeap.h b/include/nn/atk/atk_FrameHeap.h index 88d675a2..bd6768da 100644 --- a/include/nn/atk/atk_FrameHeap.h +++ b/include/nn/atk/atk_FrameHeap.h @@ -91,7 +91,7 @@ class FrameHeap { size_t GetSize() const; size_t GetFreeSize() const; - bool IsValid() const; + bool IsValid() const { return m_pHeap != nullptr; } void Dump(const SoundDataManager& mgr, const SoundArchive& arc) const; diff --git a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp index 26e7a73d..387b77d0 100644 --- a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp +++ b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp @@ -4,4 +4,18 @@ namespace nn::atk::detail { FrameHeap::FrameHeap() = default; +bool FrameHeap::Create(void* startAddress, size_t size) { + Destroy(); + +} + +void FrameHeap::Destroy() { + if (IsValid()) { + ClearSection(); + m_pHeap->Free(fnd::FrameHeapImpl::FreeAllMode); + m_pHeap->Destroy(); + m_pHeap = nullptr; + } +} + } // namespace nn::atk::detail \ No newline at end of file From 34969ad0b57e702cf915495f65a5bd8aeb95d431 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 4 Sep 2026 15:19:55 -0400 Subject: [PATCH 510/785] atk: Match `FrameHeap` destructor Also added implementation for `FrameHeap::NewSection` --- include/nn/atk/atk_FrameHeap.h | 2 +- .../atk/detail/util/atk_FrameHeap.cpp | 29 ++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_FrameHeap.h b/include/nn/atk/atk_FrameHeap.h index bd6768da..c07ab508 100644 --- a/include/nn/atk/atk_FrameHeap.h +++ b/include/nn/atk/atk_FrameHeap.h @@ -65,7 +65,7 @@ class FrameHeap { private: BlockList m_BlockList; - bool m_UseCallback; + bool m_UseCallback{true}; }; static_assert(sizeof(Section) == 0x28); diff --git a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp index 387b77d0..de4bb00a 100644 --- a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp +++ b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp @@ -1,11 +1,24 @@ #include +#include + namespace nn::atk::detail { FrameHeap::FrameHeap() = default; -bool FrameHeap::Create(void* startAddress, size_t size) { +FrameHeap::Section::Section() = default; + +FrameHeap::~FrameHeap() { Destroy(); +} + +bool FrameHeap::Create(void* startAddress, size_t size) { + if (IsValid()) + Destroy(); + + void* endAddress{ + util::BytePtr(startAddress, size).AlignUp(HeapAlign / 16).Get() + }; } @@ -18,4 +31,18 @@ void FrameHeap::Destroy() { } } +// NON_MATCHING: missing initialization of padding bytes +bool FrameHeap::NewSection() { + void* buffer {m_pHeap->Alloc(sizeof(Section), HeapAlign / 16)}; + + if (buffer != nullptr) { + auto* section = new (buffer) Section; + m_SectionList.push_back(*section); + + return true; + } + + return false; +} + } // namespace nn::atk::detail \ No newline at end of file From d3c8b3bbdd6a51997a21114529b5eba74f220836 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 4 Sep 2026 17:30:04 -0400 Subject: [PATCH 511/785] atk: Match `PoolImpl::AllocImpl` --- include/nn/atk/atk_InstancePool.h | 60 +++++++++++++++++-- .../atk/detail/util/atk_InstancePool.cpp | 36 +++++++++++ 2 files changed, 90 insertions(+), 6 deletions(-) diff --git a/include/nn/atk/atk_InstancePool.h b/include/nn/atk/atk_InstancePool.h index 2126c0e5..702584bf 100644 --- a/include/nn/atk/atk_InstancePool.h +++ b/include/nn/atk/atk_InstancePool.h @@ -3,15 +3,20 @@ #include namespace nn::atk::detail { + class PoolImpl { public: - s32 CreateImpl(void* buffer, size_t size, size_t objSize); - s32 CreateImpl(void* buffer, size_t size, size_t objSize, - size_t alignment); + static const int DefaultAlignment{4}; + + PoolImpl() = default; + +protected: + int CreateImpl(void* buffer, size_t size, size_t objSize); + int CreateImpl(void* buffer, size_t size, size_t objSize, size_t alignment); void DestroyImpl(); - s32 CountImpl() const; + int CountImpl() const; void* AllocImpl(); @@ -24,8 +29,51 @@ class PoolImpl { }; static_assert(sizeof(PoolImpl) == 0x18); -class BufferPool : PoolImpl {}; +class BufferPool : PoolImpl { +public: + static const int DefaultAlignment{4}; + + BufferPool() = default; + + int Create(void* buffer, size_t size, size_t bufferSizePerAlloc); + int Create(void* buffer, size_t size, size_t bufferSizePerAlloc, size_t alignment); + + void Destroy() { DestroyImpl(); } + + int Count() const { return CountImpl(); } + + void* Alloc() { return AllocImpl(); } + + void Free(void* ptr) { FreeImpl(ptr); } + +}; template -class InstancePool : PoolImpl {}; +class InstancePool : PoolImpl { +public: + static const int DefaultAlignment{4}; + + InstancePool() = default; + + int Create(void* buffer, size_t size) { + size_t objSize{sizeof(T)}; + + return CreateImpl(buffer, size, objSize); + } + + int Create(void* buffer, size_t size, size_t alignment) { + size_t objSize{sizeof(T)}; + + return CreateImpl(buffer, size, objSize, alignment); + } + + void Destroy() { DestroyImpl(); } + + int Count() const { return Count(); } + + T* Alloc() { return reinterpret_cast(AllocImpl()); } + + void Free(T* obj) { FreeImpl(obj); } +}; + } // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/util/atk_InstancePool.cpp b/src/NintendoWare/atk/detail/util/atk_InstancePool.cpp index e69de29b..3e25fd80 100644 --- a/src/NintendoWare/atk/detail/util/atk_InstancePool.cpp +++ b/src/NintendoWare/atk/detail/util/atk_InstancePool.cpp @@ -0,0 +1,36 @@ +#include + +#include + +namespace nn::atk::detail { + +// NON_MATCHING: incomplete implementation +int PoolImpl::CreateImpl(void* buffer, size_t size, size_t objSize, size_t alignment) { + if (buffer == nullptr) + return 0; + + char* ptr {util::BytePtr(buffer).AlignUp(alignment).Get()}; + objSize = util::align_up(objSize, alignment); + int objectCount = (reinterpret_cast(buffer) + size - reinterpret_cast(ptr)) / objSize; + + for (int i{0}; i < objectCount; ++i) { + PoolImpl* head{m_pNext}; + } + + m_pBuffer = buffer; + m_BufferSize = size; + + return objectCount; +} + +void* PoolImpl::AllocImpl() { + PoolImpl* head{m_pNext}; + + if (head != nullptr) { + m_pNext = head->m_pNext; + } + + return head; +} + +} // namespace nn::atk::detail \ No newline at end of file From 5e8d5bd50da0b96d54e309627250e1ac41a7140e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 4 Sep 2026 21:27:53 -0400 Subject: [PATCH 512/785] atk: Match `FrameHeap::NewSection` Co-authored-by: dt-12345 --- src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp index de4bb00a..75124b32 100644 --- a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp +++ b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp @@ -31,12 +31,12 @@ void FrameHeap::Destroy() { } } -// NON_MATCHING: missing initialization of padding bytes bool FrameHeap::NewSection() { void* buffer {m_pHeap->Alloc(sizeof(Section), HeapAlign / 16)}; if (buffer != nullptr) { - auto* section = new (buffer) Section; + std::memset(buffer, 0, sizeof(Section)); + auto* section{new (buffer) Section}; m_SectionList.push_back(*section); return true; From 5458ea760003ab07f850f104cdab4987bee83a0d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 4 Sep 2026 21:50:36 -0400 Subject: [PATCH 513/785] atk: Match `FrameHeap::Create` --- .../atk/detail/util/atk_FrameHeap.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp index 75124b32..22bb5995 100644 --- a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp +++ b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp @@ -1,6 +1,9 @@ +#include #include #include +#include "nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h" +#include "nn/atk/fnd/basis/atkfnd_Inlines.h" namespace nn::atk::detail { @@ -16,10 +19,17 @@ bool FrameHeap::Create(void* startAddress, size_t size) { if (IsValid()) Destroy(); - void* endAddress{ - util::BytePtr(startAddress, size).AlignUp(HeapAlign / 16).Get() - }; + void* endAddress{util::BytePtr(startAddress, size).Get()}; + startAddress = util::BytePtr(startAddress).AlignUp(fnd::HeapBase::DefaultAlignment).Get(); + if (startAddress <= endAddress) { + m_pHeap = fnd::FrameHeapImpl::Create(startAddress, fnd::GetOffsetFromPtr(startAddress, endAddress), 0); + + if (m_pHeap != nullptr) + return NewSection(); + } + + return false; } void FrameHeap::Destroy() { @@ -32,7 +42,7 @@ void FrameHeap::Destroy() { } bool FrameHeap::NewSection() { - void* buffer {m_pHeap->Alloc(sizeof(Section), HeapAlign / 16)}; + void* buffer {m_pHeap->Alloc(sizeof(Section), fnd::HeapBase::DefaultAlignment)}; if (buffer != nullptr) { std::memset(buffer, 0, sizeof(Section)); From 87e51acb3a4c8b785060bbe73f2c01b40c0a0755 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 4 Sep 2026 21:55:48 -0400 Subject: [PATCH 514/785] atk: Match `FrameHeap::Clear` --- src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp index 22bb5995..e620cd20 100644 --- a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp +++ b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp @@ -1,9 +1,10 @@ -#include #include +#include + #include -#include "nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h" -#include "nn/atk/fnd/basis/atkfnd_Inlines.h" + +#include namespace nn::atk::detail { @@ -41,6 +42,12 @@ void FrameHeap::Destroy() { } } +void FrameHeap::Clear() { + ClearSection(); + m_pHeap->Free(fnd::FrameHeapImpl::FreeAllMode); + bool result = NewSection(); +} + bool FrameHeap::NewSection() { void* buffer {m_pHeap->Alloc(sizeof(Section), fnd::HeapBase::DefaultAlignment)}; From c138bb0f48f2314e0e421f52a19b06dcce7e3962 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 5 Sep 2026 11:56:40 -0400 Subject: [PATCH 515/785] atk: Match `FrameHeap::Section::AppendBlock` --- src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp index e620cd20..163a0b01 100644 --- a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp +++ b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp @@ -10,8 +10,6 @@ namespace nn::atk::detail { FrameHeap::FrameHeap() = default; -FrameHeap::Section::Section() = default; - FrameHeap::~FrameHeap() { Destroy(); } @@ -62,4 +60,10 @@ bool FrameHeap::NewSection() { return false; } +FrameHeap::Section::Section() = default; + +void FrameHeap::Section::AppendBlock(Block* block) { + m_BlockList.push_back(*block); +} + } // namespace nn::atk::detail \ No newline at end of file From 184c20051296c0980d05de75c10ded590ebf2586 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 5 Sep 2026 13:44:45 -0400 Subject: [PATCH 516/785] atk: Match `FrameHeap::Alloc` Some additional for `util::IntrusiveList` were added as they were required --- include/nn/atk/atk_FrameHeap.h | 1 + .../detail/atk_AddonSoundArchiveContainer.h | 2 +- include/nn/util/util_IntrusiveList.h | 24 ++++++++--------- .../atk/detail/util/atk_FrameHeap.cpp | 26 ++++++++++++++++--- .../atk_AudioRendererPerformanceReader.cpp | 6 ++--- 5 files changed, 40 insertions(+), 19 deletions(-) diff --git a/include/nn/atk/atk_FrameHeap.h b/include/nn/atk/atk_FrameHeap.h index c07ab508..5ad19e04 100644 --- a/include/nn/atk/atk_FrameHeap.h +++ b/include/nn/atk/atk_FrameHeap.h @@ -41,6 +41,7 @@ class FrameHeap { HeapCallback m_HeapCallback; void* m_pHeapCallbackArg; }; + static_assert(sizeof(Block) == 0x40); using BlockList = util::IntrusiveList>; diff --git a/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h b/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h index 88e59c6b..f63bcb38 100644 --- a/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h +++ b/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h @@ -36,7 +36,7 @@ class AddonSoundArchiveContainer { private: bool m_IsActive{false}; - u8 m_Padding[3]; + [[maybe_unused]] u8 m_Padding[3]; const SoundArchive* m_pSoundArchive{}; const SoundDataManager* m_pSoundDataManager{}; char m_SoundArchiveName[SoundArchiveNameLengthMax]; diff --git a/include/nn/util/util_IntrusiveList.h b/include/nn/util/util_IntrusiveList.h index 23868b7a..9aa929e0 100644 --- a/include/nn/util/util_IntrusiveList.h +++ b/include/nn/util/util_IntrusiveList.h @@ -135,10 +135,10 @@ class IntrusiveListImplementation { void pop_front() { m_Root.GetNext()->Unlink(); } - reference back(); - reference back() const; - reference front(); - reference front() const; + reference back() { return *m_Root.GetPrev(); } + const_reference back() const { return *m_Root.GetPrev(); } + reference front() { return *m_Root.GetNext(); } + const_reference front() const { return *m_Root.GetNext(); } iterator begin() { return m_Root.GetNext(); } const_iterator begin() const { return m_Root.GetNext(); } @@ -281,10 +281,11 @@ class IntrusiveList { void push_front(reference); void pop_back(); void pop_front(); - reference front(); - reference front() const; - reference back(); - reference back() const; + + reference front() { return ToReference(m_Implementation.front()); } + const_reference front() const { return ToReference(m_Implementation.front()); } + reference back() { return ToReference(m_Implementation.back()); } + const_reference back() const { return ToReference(m_Implementation.back()); } iterator begin() { return m_Implementation.begin(); } const_iterator begin() const { return m_Implementation.begin(); } @@ -330,10 +331,9 @@ class IntrusiveList { private: IntrusiveListNode& ToNode(reference ref) const { return NodeTraits::GetNode(ref); } - - const IntrusiveListNode& ToNode(const_reference) const; - reference ToReference(IntrusiveListNode&) const; - const_reference ToReference(const IntrusiveListNode&) const; + const IntrusiveListNode& ToNode(const_reference ref) const { return NodeTraits::GetNode(ref); } + reference ToReference(IntrusiveListNode& node) const { return NodeTraits::GetItem(node); } + const_reference ToReference(const IntrusiveListNode& node) const { return NodeTraits::GetItem(node); } detail::IntrusiveListImplementation m_Implementation; }; diff --git a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp index 163a0b01..1586f195 100644 --- a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp +++ b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp @@ -22,7 +22,8 @@ bool FrameHeap::Create(void* startAddress, size_t size) { startAddress = util::BytePtr(startAddress).AlignUp(fnd::HeapBase::DefaultAlignment).Get(); if (startAddress <= endAddress) { - m_pHeap = fnd::FrameHeapImpl::Create(startAddress, fnd::GetOffsetFromPtr(startAddress, endAddress), 0); + m_pHeap = fnd::FrameHeapImpl::Create(startAddress, + fnd::GetOffsetFromPtr(startAddress, endAddress), 0); if (m_pHeap != nullptr) return NewSection(); @@ -40,14 +41,33 @@ void FrameHeap::Destroy() { } } +void* FrameHeap::Alloc(size_t size, DisposeCallback callback, void* callbackArg, + HeapCallback heapCallback, void* heapCallbackArg) { + const size_t blockSize{sizeof(Block)}; + const size_t allocSize{(size + 127) & ~63}; + + void* mem{m_pHeap->Alloc(allocSize, blockSize)}; + + if (mem == nullptr) + return nullptr; + + void* buffer{util::BytePtr(mem, blockSize).Get()}; + + Block* block{new (mem) + Block(buffer, size, callback, callbackArg, heapCallback, heapCallbackArg)}; + m_SectionList.back().AppendBlock(block); + + return buffer; +} + void FrameHeap::Clear() { ClearSection(); m_pHeap->Free(fnd::FrameHeapImpl::FreeAllMode); - bool result = NewSection(); + [[maybe_unused]] bool result = NewSection(); } bool FrameHeap::NewSection() { - void* buffer {m_pHeap->Alloc(sizeof(Section), fnd::HeapBase::DefaultAlignment)}; + void* buffer{m_pHeap->Alloc(sizeof(Section), fnd::HeapBase::DefaultAlignment)}; if (buffer != nullptr) { std::memset(buffer, 0, sizeof(Section)); diff --git a/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp b/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp index 84bead06..709ae439 100644 --- a/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp +++ b/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp @@ -13,19 +13,19 @@ size_t AudioRendererPerformanceReader::GetRequiredMemorySize(int performanceInfo return size; } -void AudioRendererPerformanceReader::Initialize(int performanceInfoCount, void* buffer, size_t bufferSize) { +void AudioRendererPerformanceReader::Initialize(int performanceInfoCount, void* buffer, [[maybe_unused]] size_t bufferSize) { m_PerformanceInfoCount = performanceInfoCount; auto ptr {util::BytePtr(buffer)}; m_pPerformanceInfo = ptr.Get(); - ptr += performanceInfoCount * sizeof(PerformanceInfo); + ptr += static_cast(performanceInfoCount * sizeof(PerformanceInfo)); const size_t performanceBufferSize {SoundSystem::GetPerformanceFrameBufferSize()}; for (int i {0}; i < m_PerformanceInfoCount; ++i) { m_pPerformanceInfo[i].performanceBuffer = ptr.Get(); m_pPerformanceInfo[i].performanceBufferSize = performanceBufferSize; - ptr += performanceBufferSize; + ptr += static_cast(performanceBufferSize); } m_WriteIndex = 0; From 0c8fd6bb95ee1bb86bdde7392fd224727b74ac03 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 5 Sep 2026 15:43:11 -0400 Subject: [PATCH 517/785] atk: Add non-matching implementation for `FrameHeap::SaveState` --- include/nn/util/util_IntrusiveList.h | 21 ++++++++++++++----- .../atk/detail/util/atk_FrameHeap.cpp | 16 ++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/include/nn/util/util_IntrusiveList.h b/include/nn/util/util_IntrusiveList.h index 9aa929e0..64b3e8e1 100644 --- a/include/nn/util/util_IntrusiveList.h +++ b/include/nn/util/util_IntrusiveList.h @@ -79,8 +79,18 @@ class IntrusiveListImplementation { reference operator*() const { return *m_Node; } pointer operator->() const; - const_iterator& operator++(); - const_iterator operator++(int); + + const_iterator& operator++() { + m_Node = m_Node->GetNext(); + return *this; + } + + const_iterator operator++(int) { + const_iterator temporary(*this); + ++(*this); + return temporary; + } + const_iterator& operator--(); const_iterator operator--(int); bool operator==(const const_iterator&) const; @@ -149,7 +159,7 @@ class IntrusiveListImplementation { iterator iterator_to(reference value) { return iterator(&value); } const_iterator iterator_to(reference value) const { return iterator(&value); } - size_type size() const; + size_type size() const { return std::distance(begin(), end()); } bool empty() const { return !m_Root.IsLinked(); } @@ -308,8 +318,9 @@ class IntrusiveList { return m_Implementation.iterator_to(ToNode(value)); } - size_type size() const; - bool empty() const; + size_type size() const { return m_Implementation.size(); } + + bool empty() const { return m_Implementation.empty(); } iterator erase(const_iterator position) { detail::IntrusiveListImplementation::iterator result = diff --git a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp index 1586f195..1a8d67e8 100644 --- a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp +++ b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp @@ -66,6 +66,22 @@ void FrameHeap::Clear() { [[maybe_unused]] bool result = NewSection(); } +// NON_MATCHING: incorrect branching +int FrameHeap::SaveState() { + if (m_pHeap->RecordState(m_SectionList.size())) { + if (NewSection()) { + int result; + + result = m_SectionList.size() - 1; + return result; + } + + m_pHeap->FreeByState(0); + } + + return -1; +} + bool FrameHeap::NewSection() { void* buffer{m_pHeap->Alloc(sizeof(Section), fnd::HeapBase::DefaultAlignment)}; From 1fcc3e2588a7f3f3904444c486041cde4c707156 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 5 Sep 2026 16:44:33 -0400 Subject: [PATCH 518/785] atk: Match `PoolImpl::CountImpl` --- include/nn/atk/atk_FrameHeap.h | 3 +++ .../atk/detail/util/atk_FrameHeap.cpp | 23 +++++++++++++++++++ .../atk/detail/util/atk_InstancePool.cpp | 9 ++++++++ 3 files changed, 35 insertions(+) diff --git a/include/nn/atk/atk_FrameHeap.h b/include/nn/atk/atk_FrameHeap.h index 5ad19e04..b41ca69e 100644 --- a/include/nn/atk/atk_FrameHeap.h +++ b/include/nn/atk/atk_FrameHeap.h @@ -22,6 +22,8 @@ class FrameHeap { m_Callback{callback}, m_pCallbackArg{callbackArg}, m_HeapCallback{heapCallback}, m_pHeapCallbackArg{heapCallbackArg} {} + ~Block() = default; + void* GetBufferAddr() { return m_pBuffer; } const void* GetBufferAddr() const { return m_pBuffer; } @@ -58,6 +60,7 @@ class FrameHeap { void* GetAddr() { return this; } + bool GetUseCallback() const { return m_UseCallback; } void SetUseCallback(bool use) { m_UseCallback = use; } void Dump(const SoundDataManager& mgr, const SoundArchive& arc) const; diff --git a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp index 1a8d67e8..a41b8b99 100644 --- a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp +++ b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp @@ -96,8 +96,31 @@ bool FrameHeap::NewSection() { return false; } +// NON_MATCHING: bad implementation +// Commented out to prevent inlining in other functions +// void FrameHeap::ClearSection() { +// bool alreadyUseCallback{ProcessCallback(0)}; + +// if (!m_SectionList.empty()) { +// auto& section{m_SectionList.back()}; + +// if (alreadyUseCallback) +// section.SetUseCallback(false); + +// section.~Section(); +// for (auto it{m_SectionList.begin()}; it != m_SectionList.end(); ++it) { +// m_SectionList.erase(it); + +// } +// } +// } + FrameHeap::Section::Section() = default; +FrameHeap::Section::~Section() { + m_BlockList.clear(); +} + void FrameHeap::Section::AppendBlock(Block* block) { m_BlockList.push_back(*block); } diff --git a/src/NintendoWare/atk/detail/util/atk_InstancePool.cpp b/src/NintendoWare/atk/detail/util/atk_InstancePool.cpp index 3e25fd80..4750d2e2 100644 --- a/src/NintendoWare/atk/detail/util/atk_InstancePool.cpp +++ b/src/NintendoWare/atk/detail/util/atk_InstancePool.cpp @@ -33,4 +33,13 @@ void* PoolImpl::AllocImpl() { return head; } +int PoolImpl::CountImpl() const { + int count {0}; + + for (PoolImpl* ptr {m_pNext}; ptr != nullptr; ptr = ptr->m_pNext) + ++count; + + return count; +} + } // namespace nn::atk::detail \ No newline at end of file From e437c4d8c6e55a798cbe5a09eac379e8ab66153e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 5 Sep 2026 17:21:04 -0400 Subject: [PATCH 519/785] atk: Match `PoolImpl::DestroyImpl` --- .../atk/detail/util/atk_InstancePool.cpp | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/NintendoWare/atk/detail/util/atk_InstancePool.cpp b/src/NintendoWare/atk/detail/util/atk_InstancePool.cpp index 4750d2e2..c85357b5 100644 --- a/src/NintendoWare/atk/detail/util/atk_InstancePool.cpp +++ b/src/NintendoWare/atk/detail/util/atk_InstancePool.cpp @@ -23,20 +23,34 @@ int PoolImpl::CreateImpl(void* buffer, size_t size, size_t objSize, size_t align return objectCount; } +void PoolImpl::DestroyImpl() { + void* begin{util::BytePtr(m_pBuffer).Get()}; + void* end{util::BytePtr(m_pBuffer, m_BufferSize).Get()}; + + PoolImpl* ptr{m_pNext}; + PoolImpl* prev{this}; + + for (; ptr != nullptr; ptr = ptr->m_pNext) { + if (ptr >= begin && ptr < end) + prev->m_pNext = ptr->m_pNext; + else + prev = ptr; + } +} + void* PoolImpl::AllocImpl() { PoolImpl* head{m_pNext}; - if (head != nullptr) { + if (head != nullptr) m_pNext = head->m_pNext; - } return head; } int PoolImpl::CountImpl() const { int count {0}; - - for (PoolImpl* ptr {m_pNext}; ptr != nullptr; ptr = ptr->m_pNext) + + for (PoolImpl* ptr{m_pNext}; ptr != nullptr; ptr = ptr->m_pNext) ++count; return count; From 59b4027a98dfa070e9690055ea1e2c81bb93ed3f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 5 Sep 2026 17:33:10 -0400 Subject: [PATCH 520/785] atk: Match `PoolImpl::FreeImpl` --- .../atk/detail/util/atk_InstancePool.cpp | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/NintendoWare/atk/detail/util/atk_InstancePool.cpp b/src/NintendoWare/atk/detail/util/atk_InstancePool.cpp index c85357b5..89b546a7 100644 --- a/src/NintendoWare/atk/detail/util/atk_InstancePool.cpp +++ b/src/NintendoWare/atk/detail/util/atk_InstancePool.cpp @@ -9,12 +9,18 @@ int PoolImpl::CreateImpl(void* buffer, size_t size, size_t objSize, size_t align if (buffer == nullptr) return 0; - char* ptr {util::BytePtr(buffer).AlignUp(alignment).Get()}; + char* ptr{util::BytePtr(buffer).AlignUp(alignment).Get()}; objSize = util::align_up(objSize, alignment); - int objectCount = (reinterpret_cast(buffer) + size - reinterpret_cast(ptr)) / objSize; + int objectCount = + (reinterpret_cast(buffer) + size - reinterpret_cast(ptr)) / objSize; for (int i{0}; i < objectCount; ++i) { - PoolImpl* head{m_pNext}; + if (objectCount - 1 > 2) { + for (PoolImpl* head{m_pNext}; head != nullptr; head = head->m_pNext) { + reinterpret_cast(ptr)->m_pNext = head; + head = &reinterpret_cast(ptr)->m_pNext[i]; + } + } } m_pBuffer = buffer; @@ -26,7 +32,7 @@ int PoolImpl::CreateImpl(void* buffer, size_t size, size_t objSize, size_t align void PoolImpl::DestroyImpl() { void* begin{util::BytePtr(m_pBuffer).Get()}; void* end{util::BytePtr(m_pBuffer, m_BufferSize).Get()}; - + PoolImpl* ptr{m_pNext}; PoolImpl* prev{this}; @@ -38,6 +44,15 @@ void PoolImpl::DestroyImpl() { } } +int PoolImpl::CountImpl() const { + int count{0}; + + for (PoolImpl* ptr{m_pNext}; ptr != nullptr; ptr = ptr->m_pNext) + ++count; + + return count; +} + void* PoolImpl::AllocImpl() { PoolImpl* head{m_pNext}; @@ -47,13 +62,11 @@ void* PoolImpl::AllocImpl() { return head; } -int PoolImpl::CountImpl() const { - int count {0}; +void PoolImpl::FreeImpl(void* ptr) { + PoolImpl* head{reinterpret_cast(ptr)}; - for (PoolImpl* ptr{m_pNext}; ptr != nullptr; ptr = ptr->m_pNext) - ++count; - - return count; + head->m_pNext = m_pNext; + m_pNext = head; } } // namespace nn::atk::detail \ No newline at end of file From f9aeab669525af56869b4b293020dd53ca805b02 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 5 Sep 2026 17:54:36 -0400 Subject: [PATCH 521/785] atk: Match `MemoryFileStream` constructor --- include/nn/atk/detail/atk_MemoryFileStream.h | 34 +++++++++---------- .../atk/detail/util/atk_MemoryFileStream.cpp | 8 +++++ 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/include/nn/atk/detail/atk_MemoryFileStream.h b/include/nn/atk/detail/atk_MemoryFileStream.h index 933e2b0a..b6591a77 100644 --- a/include/nn/atk/detail/atk_MemoryFileStream.h +++ b/include/nn/atk/detail/atk_MemoryFileStream.h @@ -4,47 +4,47 @@ #include namespace nn::atk::detail { -class MemoryFileStream : fnd::FileStream { + +class MemoryFileStream : public fnd::FileStream { public: - MemoryFileStream(void* buffer, size_t size); + MemoryFileStream(const void* buffer, size_t size); ~MemoryFileStream() override; + fnd::FndResult Open(const char* filePath, AccessMode openMode) override; void Close() override; - - size_t Read(void* buf, size_t length, fnd::FndResult* result) override; - fnd::FndResult Seek(position_t offset, fnd::Stream::SeekOrigin origin) override; + void Flush() override; bool IsOpened() const override; - size_t Write(const void* buf, size_t length, fnd::FndResult* result) override; - - position_t GetCurrentPosition() const override; - - size_t GetSize() const override; - bool CanRead() const override; bool CanWrite() const override; bool CanSeek() const override; - fnd::FndResult Open(const char* filePath, AccessMode openMode) override; - void Flush() override; + size_t GetSize() const override; + + size_t Read(void* buf, size_t length, fnd::FndResult* result) override; + size_t Write(const void* buf, size_t length, fnd::FndResult* result) override; + fnd::FndResult Seek(position_t offset, fnd::Stream::SeekOrigin origin) override; + + position_t GetCurrentPosition() const override; void EnableCache(void* buffer, size_t length) override; void DisableCache() override; bool IsCacheEnabled() const override; - s32 GetIoBufferAlignment() const override; + int GetIoBufferAlignment() const override; bool CanSetFsAccessLog() const override; void* SetFsAccessLog(fnd::FsAccessLog* pFsAccessLog) override; - + position_t GetCachePosition() override; size_t GetCachedLength() override; private: - void* m_pBuffer; + const void* m_pBuffer; size_t m_Size; position_t m_Position; }; static_assert(sizeof(MemoryFileStream) == 0x20); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp b/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp index e69de29b..011eccf4 100644 --- a/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp +++ b/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp @@ -0,0 +1,8 @@ +#include + +namespace nn::atk::detail { + +MemoryFileStream::MemoryFileStream(const void* buffer, size_t size) + : m_pBuffer(buffer), m_Size(size), m_Position(0) {} + +} // namespace nn::atk::detail \ No newline at end of file From 55f392382a55603eea55874cce13c4fffefa8fdb Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 5 Sep 2026 17:57:26 -0400 Subject: [PATCH 522/785] atk: Match `MemoryFileStream::Open` --- include/nn/atk/detail/atk_MemoryFileStream.h | 2 +- src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/detail/atk_MemoryFileStream.h b/include/nn/atk/detail/atk_MemoryFileStream.h index b6591a77..4a319d99 100644 --- a/include/nn/atk/detail/atk_MemoryFileStream.h +++ b/include/nn/atk/detail/atk_MemoryFileStream.h @@ -8,7 +8,7 @@ namespace nn::atk::detail { class MemoryFileStream : public fnd::FileStream { public: MemoryFileStream(const void* buffer, size_t size); - ~MemoryFileStream() override; + ~MemoryFileStream() override = default; fnd::FndResult Open(const char* filePath, AccessMode openMode) override; void Close() override; diff --git a/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp b/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp index 011eccf4..49d26d50 100644 --- a/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp +++ b/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp @@ -5,4 +5,8 @@ namespace nn::atk::detail { MemoryFileStream::MemoryFileStream(const void* buffer, size_t size) : m_pBuffer(buffer), m_Size(size), m_Position(0) {} +fnd::FndResult MemoryFileStream::Open(const char* filePath, AccessMode openMode) { + return fnd::FndResult{fnd::FndResultType_Failed}; +} + } // namespace nn::atk::detail \ No newline at end of file From 1ee47293861663a615fe3c9d967feeaa558dccfa Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 5 Sep 2026 17:58:31 -0400 Subject: [PATCH 523/785] atk: Match `MemoryFileStream::Close` --- .../atk/detail/util/atk_MemoryFileStream.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp b/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp index 49d26d50..362a40d1 100644 --- a/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp +++ b/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp @@ -5,8 +5,15 @@ namespace nn::atk::detail { MemoryFileStream::MemoryFileStream(const void* buffer, size_t size) : m_pBuffer(buffer), m_Size(size), m_Position(0) {} -fnd::FndResult MemoryFileStream::Open(const char* filePath, AccessMode openMode) { +fnd::FndResult MemoryFileStream::Open([[maybe_unused]] const char* filePath, + [[maybe_unused]] AccessMode openMode) { return fnd::FndResult{fnd::FndResultType_Failed}; } +void MemoryFileStream::Close() { + m_pBuffer = nullptr; + m_Size = 0; + m_Position = 0; +} + } // namespace nn::atk::detail \ No newline at end of file From 2265429a33282ba5827d474c63f4869d1839b354 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 5 Sep 2026 17:58:51 -0400 Subject: [PATCH 524/785] atk: Match `MemoryFileStream::Flush` --- src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp b/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp index 362a40d1..49057afc 100644 --- a/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp +++ b/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp @@ -16,4 +16,6 @@ void MemoryFileStream::Close() { m_Position = 0; } +void MemoryFileStream::Flush() {} + } // namespace nn::atk::detail \ No newline at end of file From fd7df135a6423d5b0ff4be4edc058d1903d6d29b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 5 Sep 2026 18:04:24 -0400 Subject: [PATCH 525/785] atk: Match `MemoryFileStream::Read` and some header functions --- include/nn/atk/detail/atk_MemoryFileStream.h | 12 ++++++------ .../atk/detail/util/atk_MemoryFileStream.cpp | 12 +++++++++++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/include/nn/atk/detail/atk_MemoryFileStream.h b/include/nn/atk/detail/atk_MemoryFileStream.h index 4a319d99..f92ebd99 100644 --- a/include/nn/atk/detail/atk_MemoryFileStream.h +++ b/include/nn/atk/detail/atk_MemoryFileStream.h @@ -12,15 +12,15 @@ class MemoryFileStream : public fnd::FileStream { fnd::FndResult Open(const char* filePath, AccessMode openMode) override; void Close() override; - void Flush() override; + void Flush() override {} - bool IsOpened() const override; + bool IsOpened() const override { return m_pBuffer != nullptr; } - bool CanRead() const override; - bool CanWrite() const override; - bool CanSeek() const override; + bool CanRead() const override { return true; } + bool CanWrite() const override { return false; } + bool CanSeek() const override { return true; } - size_t GetSize() const override; + size_t GetSize() const override { return m_Size; } size_t Read(void* buf, size_t length, fnd::FndResult* result) override; size_t Write(const void* buf, size_t length, fnd::FndResult* result) override; diff --git a/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp b/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp index 49057afc..79c20807 100644 --- a/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp +++ b/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp @@ -1,5 +1,7 @@ #include +#include + namespace nn::atk::detail { MemoryFileStream::MemoryFileStream(const void* buffer, size_t size) @@ -16,6 +18,14 @@ void MemoryFileStream::Close() { m_Position = 0; } -void MemoryFileStream::Flush() {} +size_t MemoryFileStream::Read(void* buf, size_t length, fnd::FndResult* result) { + size_t readLen{std::min(length, m_Size - m_Position)}; + + std::memcpy(buf, reinterpret_cast(m_pBuffer) + m_Position, readLen); + + m_Position += readLen; + + return readLen; +} } // namespace nn::atk::detail \ No newline at end of file From 7e9bc41996afcd48208a13233809b6b10aeca967 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 5 Sep 2026 18:09:12 -0400 Subject: [PATCH 526/785] atk: Match `MemoryFileStream::Seek` --- include/nn/atk/detail/atk_MemoryFileStream.h | 7 +++++- .../atk/detail/util/atk_MemoryFileStream.cpp | 25 +++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/include/nn/atk/detail/atk_MemoryFileStream.h b/include/nn/atk/detail/atk_MemoryFileStream.h index f92ebd99..27a799b3 100644 --- a/include/nn/atk/detail/atk_MemoryFileStream.h +++ b/include/nn/atk/detail/atk_MemoryFileStream.h @@ -23,7 +23,12 @@ class MemoryFileStream : public fnd::FileStream { size_t GetSize() const override { return m_Size; } size_t Read(void* buf, size_t length, fnd::FndResult* result) override; - size_t Write(const void* buf, size_t length, fnd::FndResult* result) override; + + size_t Write([[maybe_unused]] const void* buf, [[maybe_unused]] size_t length, + [[maybe_unused]] fnd::FndResult* result) override { + return 0; + } + fnd::FndResult Seek(position_t offset, fnd::Stream::SeekOrigin origin) override; position_t GetCurrentPosition() const override; diff --git a/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp b/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp index 79c20807..41f7603d 100644 --- a/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp +++ b/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp @@ -18,14 +18,35 @@ void MemoryFileStream::Close() { m_Position = 0; } -size_t MemoryFileStream::Read(void* buf, size_t length, fnd::FndResult* result) { +size_t MemoryFileStream::Read(void* buf, size_t length, [[maybe_unused]] fnd::FndResult* result) { size_t readLen{std::min(length, m_Size - m_Position)}; std::memcpy(buf, reinterpret_cast(m_pBuffer) + m_Position, readLen); - m_Position += readLen; + m_Position += static_cast(readLen); return readLen; } +fnd::FndResult MemoryFileStream::Seek(position_t offset, fnd::Stream::SeekOrigin origin) { + switch (origin) { + case SeekOrigin_Begin: + m_Position = offset; + break; + + case SeekOrigin_End: + m_Position = static_cast(m_Size) - offset; + break; + + case SeekOrigin_Current: + m_Position += offset; + break; + + default: + return fnd::FndResult{fnd::FndResultType_Failed}; + } + + return fnd::FndResult{fnd::FndResultType_True}; +} + } // namespace nn::atk::detail \ No newline at end of file From b6625219b6cb230605df5605f882ce00a76331d3 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 5 Sep 2026 18:09:52 -0400 Subject: [PATCH 527/785] atk: Match `MemoryFileStream::GetCurrentPosition` --- include/nn/atk/detail/atk_MemoryFileStream.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/nn/atk/detail/atk_MemoryFileStream.h b/include/nn/atk/detail/atk_MemoryFileStream.h index 27a799b3..10ca9464 100644 --- a/include/nn/atk/detail/atk_MemoryFileStream.h +++ b/include/nn/atk/detail/atk_MemoryFileStream.h @@ -31,7 +31,7 @@ class MemoryFileStream : public fnd::FileStream { fnd::FndResult Seek(position_t offset, fnd::Stream::SeekOrigin origin) override; - position_t GetCurrentPosition() const override; + position_t GetCurrentPosition() const override { return m_Position; } void EnableCache(void* buffer, size_t length) override; void DisableCache() override; From 7762559dee61ad7a997d41929fec30a99091f94a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 5 Sep 2026 18:10:23 -0400 Subject: [PATCH 528/785] atk: Match `MemoryFileStream::EnableCache` --- include/nn/atk/detail/atk_MemoryFileStream.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/nn/atk/detail/atk_MemoryFileStream.h b/include/nn/atk/detail/atk_MemoryFileStream.h index 10ca9464..1de1cde9 100644 --- a/include/nn/atk/detail/atk_MemoryFileStream.h +++ b/include/nn/atk/detail/atk_MemoryFileStream.h @@ -33,7 +33,7 @@ class MemoryFileStream : public fnd::FileStream { position_t GetCurrentPosition() const override { return m_Position; } - void EnableCache(void* buffer, size_t length) override; + void EnableCache([[maybe_unused]] void* buffer, [[maybe_unused]] size_t length) override {} void DisableCache() override; bool IsCacheEnabled() const override; From 9783e68d6ea1bb38edc3ca1f6003724c06a0ecc3 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 5 Sep 2026 18:10:41 -0400 Subject: [PATCH 529/785] atk: Match `MemoryFileStream::DisableCache` --- include/nn/atk/detail/atk_MemoryFileStream.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/nn/atk/detail/atk_MemoryFileStream.h b/include/nn/atk/detail/atk_MemoryFileStream.h index 1de1cde9..bc17b642 100644 --- a/include/nn/atk/detail/atk_MemoryFileStream.h +++ b/include/nn/atk/detail/atk_MemoryFileStream.h @@ -34,7 +34,7 @@ class MemoryFileStream : public fnd::FileStream { position_t GetCurrentPosition() const override { return m_Position; } void EnableCache([[maybe_unused]] void* buffer, [[maybe_unused]] size_t length) override {} - void DisableCache() override; + void DisableCache() override {} bool IsCacheEnabled() const override; int GetIoBufferAlignment() const override; From 4017d468ea86697bfae4b4600a8763ea1a3b7229 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 5 Sep 2026 18:10:58 -0400 Subject: [PATCH 530/785] atk: Match `MemoryFileStream::IsCacheEnabled` --- include/nn/atk/detail/atk_MemoryFileStream.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/nn/atk/detail/atk_MemoryFileStream.h b/include/nn/atk/detail/atk_MemoryFileStream.h index bc17b642..f66a2867 100644 --- a/include/nn/atk/detail/atk_MemoryFileStream.h +++ b/include/nn/atk/detail/atk_MemoryFileStream.h @@ -35,7 +35,7 @@ class MemoryFileStream : public fnd::FileStream { void EnableCache([[maybe_unused]] void* buffer, [[maybe_unused]] size_t length) override {} void DisableCache() override {} - bool IsCacheEnabled() const override; + bool IsCacheEnabled() const override { return false; } int GetIoBufferAlignment() const override; From 0f24ae97c3a2de402824f4b428740af5bcfe71b0 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 5 Sep 2026 18:11:27 -0400 Subject: [PATCH 531/785] atk: Match `MemoryFileStream::GetIoBufferAlignment` --- include/nn/atk/detail/atk_MemoryFileStream.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/nn/atk/detail/atk_MemoryFileStream.h b/include/nn/atk/detail/atk_MemoryFileStream.h index f66a2867..f7bafd34 100644 --- a/include/nn/atk/detail/atk_MemoryFileStream.h +++ b/include/nn/atk/detail/atk_MemoryFileStream.h @@ -37,7 +37,7 @@ class MemoryFileStream : public fnd::FileStream { void DisableCache() override {} bool IsCacheEnabled() const override { return false; } - int GetIoBufferAlignment() const override; + int GetIoBufferAlignment() const override { return alignof(char); } bool CanSetFsAccessLog() const override; void* SetFsAccessLog(fnd::FsAccessLog* pFsAccessLog) override; From bf7d94f3907d50fbbf9d6234b53376bd7667ab83 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 5 Sep 2026 18:11:46 -0400 Subject: [PATCH 532/785] atk: Match `MemoryFileStream::CanSetFsAccessLog` --- include/nn/atk/detail/atk_MemoryFileStream.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/nn/atk/detail/atk_MemoryFileStream.h b/include/nn/atk/detail/atk_MemoryFileStream.h index f7bafd34..d710791f 100644 --- a/include/nn/atk/detail/atk_MemoryFileStream.h +++ b/include/nn/atk/detail/atk_MemoryFileStream.h @@ -39,7 +39,7 @@ class MemoryFileStream : public fnd::FileStream { int GetIoBufferAlignment() const override { return alignof(char); } - bool CanSetFsAccessLog() const override; + bool CanSetFsAccessLog() const override { return false; } void* SetFsAccessLog(fnd::FsAccessLog* pFsAccessLog) override; position_t GetCachePosition() override; From 45a11eeea45d7b1f3d0833ec75c56bba05e4160c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 5 Sep 2026 18:12:09 -0400 Subject: [PATCH 533/785] atk: Match `MemoryFileStream::SetFsAccessLog` --- include/nn/atk/detail/atk_MemoryFileStream.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/detail/atk_MemoryFileStream.h b/include/nn/atk/detail/atk_MemoryFileStream.h index d710791f..98028909 100644 --- a/include/nn/atk/detail/atk_MemoryFileStream.h +++ b/include/nn/atk/detail/atk_MemoryFileStream.h @@ -40,7 +40,9 @@ class MemoryFileStream : public fnd::FileStream { int GetIoBufferAlignment() const override { return alignof(char); } bool CanSetFsAccessLog() const override { return false; } - void* SetFsAccessLog(fnd::FsAccessLog* pFsAccessLog) override; + void* SetFsAccessLog([[maybe_unused]] fnd::FsAccessLog* pFsAccessLog) override { + return nullptr; + } position_t GetCachePosition() override; size_t GetCachedLength() override; From 9a58ba50009db1ec6e4a8e928b42ed07282b3826 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 5 Sep 2026 18:12:29 -0400 Subject: [PATCH 534/785] atk: Match `MemoryFileStream::GetCachePosition` --- include/nn/atk/detail/atk_MemoryFileStream.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/nn/atk/detail/atk_MemoryFileStream.h b/include/nn/atk/detail/atk_MemoryFileStream.h index 98028909..e8829e8b 100644 --- a/include/nn/atk/detail/atk_MemoryFileStream.h +++ b/include/nn/atk/detail/atk_MemoryFileStream.h @@ -44,7 +44,7 @@ class MemoryFileStream : public fnd::FileStream { return nullptr; } - position_t GetCachePosition() override; + position_t GetCachePosition() override { return 0; } size_t GetCachedLength() override; private: From 0b3af3669d91b54ba97b30415540bb16d8dfa26a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 5 Sep 2026 18:13:09 -0400 Subject: [PATCH 535/785] atk: Match `MemoryFileStream::GetCachedLength` --- include/nn/atk/detail/atk_MemoryFileStream.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/nn/atk/detail/atk_MemoryFileStream.h b/include/nn/atk/detail/atk_MemoryFileStream.h index e8829e8b..dda5b155 100644 --- a/include/nn/atk/detail/atk_MemoryFileStream.h +++ b/include/nn/atk/detail/atk_MemoryFileStream.h @@ -45,7 +45,7 @@ class MemoryFileStream : public fnd::FileStream { } position_t GetCachePosition() override { return 0; } - size_t GetCachedLength() override; + size_t GetCachedLength() override { return 0; } private: const void* m_pBuffer; From 6937dfefde017eea92cce41dafdaf0844191df5d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 6 Sep 2026 15:31:47 -0300 Subject: [PATCH 536/785] atk: Match `Util::CalcLpfFreq` Also added a bunch of static variables --- include/nn/atk/atk_Util.h | 123 ++-- include/nn/atk/fnd/basis/atkfnd_Inlines.h | 23 +- src/NintendoWare/atk/detail/util/atk_Util.cpp | 602 ++++++++++++++++++ .../fnd/io/atkfnd_FileStreamImpl.win32.cpp | 2 +- 4 files changed, 663 insertions(+), 87 deletions(-) diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index b246b688..1de3fd77 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -3,11 +3,12 @@ #include #include -#include #include +#include #include namespace nn::atk { + class SoundArchive; class SoundArchivePlayer; class OutputReceiver; @@ -18,12 +19,12 @@ class SoundArchiveLoader; struct LoadItemInfo; class Util { public: - static const int VolumeDbMin {-904}; - static const int VolumeDbMax {60}; + static const int VolumeDbMin{-904}; + static const int VolumeDbMax{60}; + + static const int PitchDivisionBit{8}; + static const int PitchDivisionRange{256}; - static const int PitchDivisionBit {8}; - static const int PitchDivisionRange {256}; - enum PanCurve { PanCurve_Sqrt, PanCurve_Sincos, @@ -39,8 +40,7 @@ class Util { static_assert(sizeof(PanInfo) == 0x8); static u16 CalcLpfFreq(float scale); - static BiquadFilterCoefficients CalcLowPassFilterCoefficients(int frequency, - int sampleRate, + static BiquadFilterCoefficients CalcLowPassFilterCoefficients(int frequency, int sampleRate, bool isTableUsed); static int FindLpfFreqTableIndex(int frequency); static float CalcPanRatio(float pan, const PanInfo& info, OutputMode mode); @@ -55,9 +55,9 @@ class Util { static bool IsValidMemoryForDsp(const void* ptr, size_t size); - static const int CalcLpfFreqTableSize {24}; - static const float CalcLpfFreqIntercept; // = 0x3E0ADE7F - static const float CalcLpfFreqThreshold;// = 0x3F666666; + static const int CalcLpfFreqTableSize{24}; + static const float CalcLpfFreqIntercept; + static const float CalcLpfFreqThreshold; static const u16 CalcLpfFreqTable[CalcLpfFreqTableSize]; static const BiquadFilterCoefficients LowPassFilterCoefficientsTable32000[CalcLpfFreqTableSize]; static const BiquadFilterCoefficients LowPassFilterCoefficientsTable48000[CalcLpfFreqTableSize]; @@ -90,15 +90,15 @@ class Util { const void* GetReferedItem(u32 index) const { if (count <= index) return nullptr; - + return util::ConstBytePtr(this, item[index].offset).Get(); } const void* GetReferedItem(u32 index, u16 typeId) const { if (count <= index || item[index].typeId != typeId) return nullptr; - - return util::ConstBytePtr(this,item[index].offset).Get(); + + return util::ConstBytePtr(this, item[index].offset).Get(); } const void* FindReferedItemBy(u16 typeId) const; @@ -108,7 +108,7 @@ class Util { const void* GetReferedItem(u32 index) const { if (count <= index) return nullptr; - + return util::ConstBytePtr(this, item[index].offset).Get(); } @@ -120,9 +120,9 @@ class Util { ReferenceWithSize item[1]; const void* GetReferedItemByIndex(const void* origin, int index, u16 count) const; - + const ReferenceWithSize* GetReference(u16 typeId, u16 count) const { - for (int i {0}; i < count; ++i) { + for (int i{0}; i < count; ++i) { if (item[i].IsValidTypeId(typeId)) return &item[i]; } @@ -131,7 +131,7 @@ class Util { } const void* GetReferedItem(const void* origin, u16 typeId, u16 count) const { - auto* ref {GetReference(typeId, count)}; + auto* ref{GetReference(typeId, count)}; if (ref != nullptr && ref->offset != 0) return util::ConstBytePtr(origin, ref->offset).Get(); @@ -139,15 +139,15 @@ class Util { } u32 GetReferedItemSize(u16 typeId, u16 count) const { - auto* ref {GetReference(typeId, count)}; + auto* ref{GetReference(typeId, count)}; if (ref != nullptr) return ref->size; return 0; } - + u32 GetReferedItemOffset(u16 typeId, u16 count) const { - auto* ref {GetReference(typeId, count)}; + auto* ref{GetReference(typeId, count)}; if (ref != nullptr) return ref->offset; @@ -179,7 +179,7 @@ class Util { u32 bitFlag; bool GetValue(u32* value, u32 bitNumber) const { - u32 count {GetTrueCount(bitNumber)}; + u32 count{GetTrueCount(bitNumber)}; if (count == 0) return false; @@ -188,7 +188,7 @@ class Util { } bool GetValueF32(float* value, u32 bitNumber) const { - u32 count {GetTrueCount(bitNumber)}; + u32 count{GetTrueCount(bitNumber)}; if (count == 0) return false; @@ -199,10 +199,10 @@ class Util { private: static const int BitNumberMax = 31; u32 GetTrueCount(u32 bitNumber) const { - bool ret {false}; - int count {0}; + bool ret{false}; + int count{0}; - for (u32 i {0}; i <= bitNumber; ++i) { + for (u32 i{0}; i <= bitNumber; ++i) { if ((bitFlag & (1 << i)) != 0) { ++count; if (i == bitNumber) @@ -218,18 +218,16 @@ class Util { }; static_assert(sizeof(BitFlag) == 0x4); - static u8 DivideBy8bit(u32 value, int index) { - return static_cast(value >> (8 * index)); - } + static u8 DivideBy8bit(u32 value, int index) { return static_cast(value >> (8 * index)); } static u16 DivideBy16bit(u32 value, int index) { return static_cast(value >> (16 * index)); } - const void* GetWaveFile(u32 waveArchiveId, u32 waveIndex, - const SoundArchive& arc, const SoundArchivePlayer& player); - const void* GetWaveFile(u32 waveArchiveId, u32 waveIndex, - const SoundArchive& arc, const PlayerHeapDataManager* mgr); + const void* GetWaveFile(u32 waveArchiveId, u32 waveIndex, const SoundArchive& arc, + const SoundArchivePlayer& player); + const void* GetWaveFile(u32 waveArchiveId, u32 waveIndex, const SoundArchive& arc, + const PlayerHeapDataManager* mgr); enum WaveArchiveLoadStatus { WaveArchiveLoadStatus_Error = -2, @@ -239,57 +237,46 @@ class Util { WaveArchiveLoadStatus_Partly }; - static WaveArchiveLoadStatus GetWaveArchiveOfBank(LoadItemInfo& warcLoadInfo, - bool& isLoadIndividual, - const void* bankFile, - const SoundArchive& arc, + static WaveArchiveLoadStatus GetWaveArchiveOfBank(LoadItemInfo& warcLoadInfo, + bool& isLoadIndividual, const void* bankFile, + const SoundArchive& arc, const SoundArchiveLoader& mgr); - static const void* GetWaveFileOfWaveSound(const void* wsdFile, - u32 index, - const SoundArchive& arc, + static const void* GetWaveFileOfWaveSound(const void* wsdFile, u32 index, + const SoundArchive& arc, const SoundArchiveLoader& mgr); - static ItemType GetItemType(u32 id) { - return static_cast(id >> 24); - } + static ItemType GetItemType(u32 id) { return static_cast(id >> 24); } - static u32 GetItemIndex(u32 id) { - return id & 0x00FFFFFF; - } + static u32 GetItemIndex(u32 id) { return id & 0x00FFFFFF; } + + static u32 GetMaskedItemId(u32 id, ItemType type) { return id | (type << 24); } - static u32 GetMaskedItemId(u32 id, ItemType type) { - return id | (type << 24); - } - struct WaveId { u32 waveArchiveId; u32 waveIndex; }; static_assert(sizeof(WaveId) == 0x8); - + struct WaveIdTable { Table table; - const WaveId* GetWaveId(u32 index) const { - return &table.item[index]; - } + const WaveId* GetWaveId(u32 index) const { return &table.item[index]; } - u32 GetCount() const { - return table.count; - } + u32 GetCount() const { return table.count; } }; template class Singleton { public: - static CHILD& GetInstance(); + static CHILD& GetInstance(); }; static int GetSubMixBusFromMainBus(); static int GetSubMixBus(AuxBus bus); static int GetSubMixBus(int bus); - static int GetOutputReceiverMixBufferIndex(const OutputReceiver* pOutputReceiver, int bus, int channel); + static int GetOutputReceiverMixBufferIndex(const OutputReceiver* pOutputReceiver, int bus, + int channel); static int GetAdditionalSendIndex(int bus); class WarningLogger : public Singleton { @@ -313,7 +300,6 @@ class Util { }; static_assert(sizeof(Element) == 0xc); - Element element[LogCount]; int counter; @@ -332,19 +318,6 @@ class Util { static_assert(sizeof(WarningLogger) == 0x610); }; -static const f32 NoteTable[12] {}; -static const f32 PitchTable[Util::PitchDivisionRange] {}; -static const f32 Decibel2RatioTable[965] {}; - -static const f32 Pan2RatioTableSqrtSurround[257] {}; -static const f32 Pan2RatioTableSinCosSurround[257] {}; -static const f32 Pan2RatioTableLinearSurround[257] {}; - -static const f32 Pan2RatioTableSqrt[257] {}; -static const f32 Pan2RatioTableSinCos[257] {}; -static const f32 Pan2RatioTableLinear[257] {}; +} // namespace detail -static const f32* PanTableTable[3] {Pan2RatioTableSqrt, Pan2RatioTableSinCos, Pan2RatioTableLinear}; -static const f32* PanTableTableForSurround[3] {Pan2RatioTableSqrtSurround, Pan2RatioTableSinCosSurround, Pan2RatioTableLinearSurround}; -} // namespace nn::atk::detail -} // namespace nn::atk \ No newline at end of file +} // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/fnd/basis/atkfnd_Inlines.h b/include/nn/atk/fnd/basis/atkfnd_Inlines.h index 81eef1d9..84f738fc 100644 --- a/include/nn/atk/fnd/basis/atkfnd_Inlines.h +++ b/include/nn/atk/fnd/basis/atkfnd_Inlines.h @@ -5,21 +5,22 @@ namespace nn::atk::detail::fnd { template -inline T ClampMin(T x, T low) { - return x < low ? low : x; -} +inline T Clamp(T x, T low, T high) { + if (x < low) + return low; -template -inline T ClampMax(T x, T high) { - return x > high ? high : x; -} + if (x > high) + return high; -template -inline T Clamp(T x, T low, T high) { - return ClampMax(ClampMin(x, low), high); + return x; } -inline float FloatClamp(float value, float min, float max); +inline float FloatClamp(float value, float min, float max) { + if (value >= min) + return value < max ? value : max; + + return min; +} template inline ValueT RoundUp(ValueT x, int base); diff --git a/src/NintendoWare/atk/detail/util/atk_Util.cpp b/src/NintendoWare/atk/detail/util/atk_Util.cpp index e69de29b..2ba89a0c 100644 --- a/src/NintendoWare/atk/detail/util/atk_Util.cpp +++ b/src/NintendoWare/atk/detail/util/atk_Util.cpp @@ -0,0 +1,602 @@ +#include + +#include + +namespace nn::atk::detail { + +namespace { +const float NoteTable[12]{ + 1.00000000000000f, 1.05946309435930f, 1.12246204830937f, 1.18920711500272f, + 1.25992104989487f, 1.33483985417003f, 1.41421356237310f, 1.49830707687668f, + 1.58740105196820f, 1.68179283050743f, 1.78179743628068f, 1.88774862536339f, +}; + +const float PitchTable[Util::PitchDivisionRange]{ + 1.00000000000000f, 1.00022565930507f, 1.00045136953226f, 1.00067713069307f, 1.00090294279898f, + 1.00112880586149f, 1.00135471989211f, 1.00158068490233f, 1.00180670090365f, 1.00203276790759f, + 1.00225888592566f, 1.00248505496936f, 1.00271127505020f, 1.00293754617972f, 1.00316386836942f, + 1.00339024163082f, 1.00361666597546f, 1.00384314141486f, 1.00406966796055f, 1.00429624562407f, + 1.00452287441694f, 1.00474955435071f, 1.00497628543691f, 1.00520306768709f, 1.00542990111280f, + 1.00565678572558f, 1.00588372153699f, 1.00611070855857f, 1.00633774680189f, 1.00656483627850f, + 1.00679197699996f, 1.00701916897784f, 1.00724641222370f, 1.00747370674912f, 1.00770105256566f, + 1.00792844968490f, 1.00815589811842f, 1.00838339787779f, 1.00861094897460f, 1.00883855142043f, + 1.00906620522687f, 1.00929391040551f, 1.00952166696794f, 1.00974947492577f, 1.00997733429057f, + 1.01020524507396f, 1.01043320728755f, 1.01066122094292f, 1.01088928605170f, 1.01111740262549f, + 1.01134557067591f, 1.01157379021458f, 1.01180206125310f, 1.01203038380312f, 1.01225875787623f, + 1.01248718348409f, 1.01271566063830f, 1.01294418935052f, 1.01317276963236f, 1.01340140149547f, + 1.01363008495149f, 1.01385882001206f, 1.01408760668882f, 1.01431644499343f, 1.01454533493752f, + 1.01477427653277f, 1.01500326979081f, 1.01523231472332f, 1.01546141134194f, 1.01569055965835f, + 1.01591975968421f, 1.01614901143119f, 1.01637831491095f, 1.01660767013518f, 1.01683707711556f, + 1.01706653586375f, 1.01729604639144f, 1.01752560871032f, 1.01775522283207f, 1.01798488876839f, + 1.01821460653096f, 1.01844437613148f, 1.01867419758165f, 1.01890407089317f, 1.01913399607774f, + 1.01936397314707f, 1.01959400211286f, 1.01982408298683f, 1.02005421578069f, 1.02028440050616f, + 1.02051463717495f, 1.02074492579879f, 1.02097526638940f, 1.02120565895850f, 1.02143610351784f, + 1.02166660007913f, 1.02189714865412f, 1.02212774925453f, 1.02235840189212f, 1.02258910657863f, + 1.02281986332579f, 1.02305067214536f, 1.02328153304909f, 1.02351244604873f, 1.02374341115603f, + 1.02397442838276f, 1.02420549774068f, 1.02443661924155f, 1.02466779289714f, 1.02489901871921f, + 1.02513029671954f, 1.02536162690990f, 1.02559300930208f, 1.02582444390784f, 1.02605593073898f, + 1.02628746980727f, 1.02651906112451f, 1.02675070470248f, 1.02698240055299f, 1.02721414868781f, + 1.02744594911876f, 1.02767780185764f, 1.02790970691624f, 1.02814166430638f, 1.02837367403986f, + 1.02860573612850f, 1.02883785058410f, 1.02907001741849f, 1.02930223664349f, 1.02953450827092f, + 1.02976683231260f, 1.02999920878037f, 1.03023163768604f, 1.03046411904146f, 1.03069665285846f, + 1.03092923914889f, 1.03116187792457f, 1.03139456919736f, 1.03162731297909f, 1.03186010928163f, + 1.03209295811682f, 1.03232585949652f, 1.03255881343258f, 1.03279181993686f, 1.03302487902123f, + 1.03325799069755f, 1.03349115497769f, 1.03372437187351f, 1.03395764139691f, 1.03419096355973f, + 1.03442433837388f, 1.03465776585123f, 1.03489124600365f, 1.03512477884305f, 1.03535836438130f, + 1.03559200263031f, 1.03582569360196f, 1.03605943730815f, 1.03629323376078f, 1.03652708297176f, + 1.03676098495299f, 1.03699493971638f, 1.03722894727384f, 1.03746300763728f, 1.03769712081862f, + 1.03793128682977f, 1.03816550568267f, 1.03839977738923f, 1.03863410196138f, 1.03886847941105f, + 1.03910290975017f, 1.03933739299068f, 1.03957192914452f, 1.03980651822362f, 1.04004116023993f, + 1.04027585520539f, 1.04051060313196f, 1.04074540403158f, 1.04098025791621f, 1.04121516479780f, + 1.04145012468832f, 1.04168513759972f, 1.04192020354397f, 1.04215532253304f, 1.04239049457890f, + 1.04262571969352f, 1.04286099788887f, 1.04309632917694f, 1.04333171356970f, 1.04356715107914f, + 1.04380264171725f, 1.04403818549601f, 1.04427378242741f, 1.04450943252346f, 1.04474513579614f, + 1.04498089225746f, 1.04521670191942f, 1.04545256479402f, 1.04568848089328f, 1.04592445022919f, + 1.04616047281379f, 1.04639654865907f, 1.04663267777707f, 1.04686886017980f, 1.04710509587929f, + 1.04734138488756f, 1.04757772721665f, 1.04781412287858f, 1.04805057188539f, 1.04828707424912f, + 1.04852362998181f, 1.04876023909550f, 1.04899690160224f, 1.04923361751407f, 1.04947038684306f, + 1.04970720960124f, 1.04994408580069f, 1.05018101545345f, 1.05041799857160f, 1.05065503516719f, + 1.05089212525229f, 1.05112926883898f, 1.05136646593932f, 1.05160371656540f, 1.05184102072929f, + 1.05207837844307f, 1.05231578971883f, 1.05255325456865f, 1.05279077300463f, 1.05302834503885f, + 1.05326597068341f, 1.05350364995040f, 1.05374138285194f, 1.05397916940012f, 1.05421700960704f, + 1.05445490348482f, 1.05469285104557f, 1.05493085230140f, 1.05516890726443f, 1.05540701594677f, + 1.05564517836056f, 1.05588339451791f, 1.05612166443095f, 1.05635998811181f, 1.05659836557263f, + 1.05683679682555f, 1.05707528188269f, 1.05731382075621f, 1.05755241345824f, 1.05779106000093f, + 1.05802976039644f, 1.05826851465692f, 1.05850732279451f, 1.05874618482139f, 1.05898510074970f, + 1.05922407059161f, +}; + +const float Decibel2RatioTable[Util::VolumeDbMax - Util::VolumeDbMin + 1]{ + 0.000000000f, 3.05492E-05f, 3.09030E-05f, 3.12608E-05f, // -90.4dB = -infinity + 3.16228E-05f, 3.19890E-05f, 3.23594E-05f, 3.27341E-05f, 3.31131E-05f, // -90.0 dB + 3.34965E-05f, 3.38844E-05f, 3.42768E-05f, 3.46737E-05f, 3.50752E-05f, + 3.54813E-05f, 3.58922E-05f, 3.63078E-05f, 3.67282E-05f, 3.71535E-05f, + 3.75837E-05f, 3.80189E-05f, 3.84592E-05f, 3.89045E-05f, 3.93550E-05f, + 3.98107E-05f, 4.02717E-05f, 4.07380E-05f, 4.12098E-05f, 4.16869E-05f, + 4.21697E-05f, 4.26580E-05f, 4.31519E-05f, 4.36516E-05f, 4.41570E-05f, + 4.46684E-05f, 4.51856E-05f, 4.57088E-05f, 4.62381E-05f, 4.67735E-05f, + 4.73151E-05f, 4.78630E-05f, 4.84172E-05f, 4.89779E-05f, 4.95450E-05f, + 5.01187E-05f, 5.06991E-05f, 5.12861E-05f, 5.18800E-05f, 5.24807E-05f, + 5.30884E-05f, 5.37032E-05f, 5.43250E-05f, 5.49541E-05f, 5.55904E-05f, + 5.62341E-05f, 5.68853E-05f, 5.75440E-05f, 5.82103E-05f, 5.88844E-05f, + 5.95662E-05f, 6.02560E-05f, 6.09537E-05f, 6.16595E-05f, 6.23735E-05f, + 6.30957E-05f, 6.38263E-05f, 6.45654E-05f, 6.53131E-05f, 6.60693E-05f, // -84.0 dB + 6.68344E-05f, 6.76083E-05f, 6.83912E-05f, 6.91831E-05f, 6.99842E-05f, + 7.07946E-05f, 7.16143E-05f, 7.24436E-05f, 7.32825E-05f, 7.41310E-05f, + 7.49894E-05f, 7.58578E-05f, 7.67361E-05f, 7.76247E-05f, 7.85236E-05f, + 7.94328E-05f, 8.03526E-05f, 8.12831E-05f, 8.22243E-05f, 8.31764E-05f, + 8.41395E-05f, 8.51138E-05f, 8.60994E-05f, 8.70964E-05f, 8.81049E-05f, + 8.91251E-05f, 9.01571E-05f, 9.12011E-05f, 9.22571E-05f, 9.33254E-05f, + 9.44061E-05f, 9.54993E-05f, 9.66051E-05f, 9.77237E-05f, 9.88553E-05f, + 0.000100000f, 0.000101158f, 0.000102329f, 0.000103514f, 0.000104713f, // -80.0 dB + 0.000105925f, 0.000107152f, 0.000108393f, 0.000109648f, 0.000110917f, + 0.000112202f, 0.000113501f, 0.000114815f, 0.000116145f, 0.000117490f, + 0.000118850f, 0.000120226f, 0.000121619f, 0.000123027f, 0.000124451f, + 0.000125893f, 0.000127350f, 0.000128825f, 0.000130317f, 0.000131826f, // -78.0 dB + 0.000133352f, 0.000134896f, 0.000136458f, 0.000138038f, 0.000139637f, + 0.000141254f, 0.000142889f, 0.000144544f, 0.000146218f, 0.000147911f, + 0.000149624f, 0.000151356f, 0.000153109f, 0.000154882f, 0.000156675f, + 0.000158489f, 0.000160325f, 0.000162181f, 0.000164059f, 0.000165959f, + 0.000167880f, 0.000169824f, 0.000171791f, 0.000173780f, 0.000175792f, + 0.000177828f, 0.000179887f, 0.000181970f, 0.000184077f, 0.000186209f, + 0.000188365f, 0.000190546f, 0.000192752f, 0.000194984f, 0.000197242f, + 0.000199526f, 0.000201837f, 0.000204174f, 0.000206538f, 0.000208930f, + 0.000211349f, 0.000213796f, 0.000216272f, 0.000218776f, 0.000221309f, + 0.000223872f, 0.000226464f, 0.000229087f, 0.000231739f, 0.000234423f, + 0.000237137f, 0.000239883f, 0.000242661f, 0.000245471f, 0.000248313f, + 0.000251189f, 0.000254097f, 0.000257040f, 0.000260016f, 0.000263027f, // -72.0 dB + 0.000266073f, 0.000269153f, 0.000272270f, 0.000275423f, 0.000278612f, + 0.000281838f, 0.000285102f, 0.000288403f, 0.000291743f, 0.000295121f, + 0.000298538f, 0.000301995f, 0.000305492f, 0.000309030f, 0.000312608f, + 0.000316228f, 0.000319890f, 0.000323594f, 0.000327341f, 0.000331131f, + 0.000334965f, 0.000338844f, 0.000342768f, 0.000346737f, 0.000350752f, + 0.000354813f, 0.000358922f, 0.000363078f, 0.000367282f, 0.000371535f, + 0.000375837f, 0.000380189f, 0.000384592f, 0.000389045f, 0.000393550f, + 0.000398107f, 0.000402717f, 0.000407380f, 0.000412098f, 0.000416869f, + 0.000421697f, 0.000426580f, 0.000431519f, 0.000436516f, 0.000441570f, + 0.000446684f, 0.000451856f, 0.000457088f, 0.000462381f, 0.000467735f, + 0.000473151f, 0.000478630f, 0.000484172f, 0.000489779f, 0.000495450f, + 0.000501187f, 0.000506991f, 0.000512861f, 0.000518800f, 0.000524807f, // -66.0 dB + 0.000530884f, 0.000537032f, 0.000543250f, 0.000549541f, 0.000555904f, + 0.000562341f, 0.000568853f, 0.000575440f, 0.000582103f, 0.000588844f, + 0.000595662f, 0.000602560f, 0.000609537f, 0.000616595f, 0.000623735f, + 0.000630957f, 0.000638263f, 0.000645654f, 0.000653131f, 0.000660693f, + 0.000668344f, 0.000676083f, 0.000683912f, 0.000691831f, 0.000699842f, + 0.000707946f, 0.000716143f, 0.000724436f, 0.000732825f, 0.000741310f, + 0.000749894f, 0.000758578f, 0.000767361f, 0.000776247f, 0.000785236f, + 0.000794328f, 0.000803526f, 0.000812831f, 0.000822243f, 0.000831764f, + 0.000841395f, 0.000851138f, 0.000860994f, 0.000870964f, 0.000881049f, + 0.000891251f, 0.000901571f, 0.000912011f, 0.000922571f, 0.000933254f, + 0.000944061f, 0.000954993f, 0.000966051f, 0.000977237f, 0.000988553f, + 0.001000000f, 0.001011579f, 0.001023293f, 0.001035142f, 0.001047129f, // -60.0.0dB ( 1/1000 ) + 0.001059254f, 0.001071519f, 0.001083927f, 0.001096478f, 0.001109175f, + 0.001122018f, 0.001135011f, 0.001148154f, 0.001161449f, 0.001174898f, + 0.001188502f, 0.001202264f, 0.001216186f, 0.001230269f, 0.001244515f, + 0.001258925f, 0.001273503f, 0.001288250f, 0.001303167f, 0.001318257f, + 0.001333521f, 0.001348963f, 0.001364583f, 0.001380384f, 0.001396368f, + 0.001412538f, 0.001428894f, 0.001445440f, 0.001462177f, 0.001479108f, + 0.001496236f, 0.001513561f, 0.001531087f, 0.001548817f, 0.001566751f, + 0.001584893f, 0.001603245f, 0.001621810f, 0.001640590f, 0.001659587f, + 0.001678804f, 0.001698244f, 0.001717908f, 0.001737801f, 0.001757924f, + 0.001778279f, 0.001798871f, 0.001819701f, 0.001840772f, 0.001862087f, + 0.001883649f, 0.001905461f, 0.001927525f, 0.001949845f, 0.001972423f, + 0.001995262f, 0.002018366f, 0.002041738f, 0.002065380f, 0.002089296f, // -54.0 dB + 0.002113489f, 0.002137962f, 0.002162719f, 0.002187762f, 0.002213095f, + 0.002238721f, 0.002264644f, 0.002290868f, 0.002317395f, 0.002344229f, + 0.002371374f, 0.002398833f, 0.002426610f, 0.002454709f, 0.002483133f, + 0.002511886f, 0.002540973f, 0.002570396f, 0.002600160f, 0.002630268f, + 0.002660725f, 0.002691535f, 0.002722701f, 0.002754229f, 0.002786121f, + 0.002818383f, 0.002851018f, 0.002884032f, 0.002917427f, 0.002951209f, + 0.002985383f, 0.003019952f, 0.003054921f, 0.003090295f, 0.003126079f, + 0.003162278f, 0.003198895f, 0.003235937f, 0.003273407f, 0.003311311f, + 0.003349654f, 0.003388442f, 0.003427678f, 0.003467369f, 0.003507519f, + 0.003548134f, 0.003589219f, 0.003630781f, 0.003672823f, 0.003715352f, + 0.003758374f, 0.003801894f, 0.003845918f, 0.003890451f, 0.003935501f, + 0.003981072f, 0.004027170f, 0.004073803f, 0.004120975f, 0.004168694f, // -48.0 dB + 0.004216965f, 0.004265795f, 0.004315191f, 0.004365158f, 0.004415704f, + 0.004466836f, 0.004518559f, 0.004570882f, 0.004623810f, 0.004677351f, + 0.004731513f, 0.004786301f, 0.004841724f, 0.004897788f, 0.004954502f, + 0.005011872f, 0.005069907f, 0.005128614f, 0.005188000f, 0.005248075f, + 0.005308844f, 0.005370318f, 0.005432503f, 0.005495409f, 0.005559043f, + 0.005623413f, 0.005688529f, 0.005754399f, 0.005821032f, 0.005888437f, + 0.005956621f, 0.006025596f, 0.006095369f, 0.006165950f, 0.006237348f, + 0.006309573f, 0.006382635f, 0.006456542f, 0.006531306f, 0.006606934f, + 0.006683439f, 0.006760830f, 0.006839116f, 0.006918310f, 0.006998420f, + 0.007079458f, 0.007161434f, 0.007244360f, 0.007328245f, 0.007413102f, + 0.007498942f, 0.007585776f, 0.007673615f, 0.007762471f, 0.007852356f, + 0.007943282f, 0.008035261f, 0.008128305f, 0.008222426f, 0.008317638f, // -42.0 dB + 0.008413951f, 0.008511380f, 0.008609938f, 0.008709636f, 0.008810489f, + 0.008912509f, 0.009015711f, 0.009120108f, 0.009225714f, 0.009332543f, + 0.009440609f, 0.009549926f, 0.009660509f, 0.009772372f, 0.009885531f, + 0.010000000f, 0.010115795f, 0.010232930f, 0.010351422f, 0.010471285f, // -40.0.0dB ( 1/100 ) + 0.010592537f, 0.010715193f, 0.010839269f, 0.010964782f, 0.011091748f, + 0.011220185f, 0.011350108f, 0.011481536f, 0.011614486f, 0.011748976f, + 0.011885022f, 0.012022644f, 0.012161860f, 0.012302688f, 0.012445146f, + 0.012589254f, 0.012735031f, 0.012882496f, 0.013031668f, 0.013182567f, + 0.013335214f, 0.013489629f, 0.013645831f, 0.013803843f, 0.013963684f, + 0.014125375f, 0.014288940f, 0.014454398f, 0.014621772f, 0.014791084f, + 0.014962357f, 0.015135612f, 0.015310875f, 0.015488166f, 0.015667511f, + 0.015848932f, 0.016032454f, 0.016218101f, 0.016405898f, 0.016595869f, // -36.0 dB + 0.016788040f, 0.016982437f, 0.017179084f, 0.017378008f, 0.017579236f, + 0.017782794f, 0.017988709f, 0.018197009f, 0.018407720f, 0.018620871f, + 0.018836491f, 0.019054607f, 0.019275249f, 0.019498446f, 0.019724227f, + 0.019952623f, 0.020183664f, 0.020417379f, 0.020653802f, 0.020892961f, + 0.021134890f, 0.021379621f, 0.021627185f, 0.021877616f, 0.022130947f, + 0.022387211f, 0.022646443f, 0.022908677f, 0.023173946f, 0.023442288f, + 0.023713737f, 0.023988329f, 0.024266101f, 0.024547089f, 0.024831331f, + 0.025118864f, 0.025409727f, 0.025703958f, 0.026001596f, 0.026302680f, + 0.026607251f, 0.026915348f, 0.027227013f, 0.027542287f, 0.027861212f, + 0.028183829f, 0.028510183f, 0.028840315f, 0.029174270f, 0.029512092f, + 0.029853826f, 0.030199517f, 0.030549211f, 0.030902954f, 0.031260794f, + 0.031622777f, 0.031988951f, 0.032359366f, 0.032734069f, 0.033113112f, // -30.0 dB + 0.033496544f, 0.033884416f, 0.034276779f, 0.034673685f, 0.035075187f, + 0.035481339f, 0.035892193f, 0.036307805f, 0.036728230f, 0.037153523f, + 0.037583740f, 0.038018940f, 0.038459178f, 0.038904514f, 0.039355008f, + 0.039810717f, 0.040271703f, 0.040738028f, 0.041209752f, 0.041686938f, + 0.042169650f, 0.042657952f, 0.043151908f, 0.043651583f, 0.044157045f, + 0.044668359f, 0.045185594f, 0.045708819f, 0.046238102f, 0.046773514f, + 0.047315126f, 0.047863009f, 0.048417237f, 0.048977882f, 0.049545019f, + 0.050118723f, 0.050699071f, 0.051286138f, 0.051880004f, 0.052480746f, + 0.053088444f, 0.053703180f, 0.054325033f, 0.054954087f, 0.055590426f, + 0.056234133f, 0.056885293f, 0.057543994f, 0.058210322f, 0.058884366f, + 0.059566214f, 0.060255959f, 0.060953690f, 0.061659500f, 0.062373484f, + 0.063095734f, 0.063826349f, 0.064565423f, 0.065313055f, 0.066069345f, // -24.0 dB + 0.066834392f, 0.067608298f, 0.068391165f, 0.069183097f, 0.069984200f, + 0.070794578f, 0.071614341f, 0.072443596f, 0.073282453f, 0.074131024f, + 0.074989421f, 0.075857758f, 0.076736149f, 0.077624712f, 0.078523563f, + 0.079432823f, 0.080352612f, 0.081283052f, 0.082224265f, 0.083176377f, + 0.084139514f, 0.085113804f, 0.086099375f, 0.087096359f, 0.088104887f, + 0.089125094f, 0.090157114f, 0.091201084f, 0.092257143f, 0.093325430f, + 0.094406088f, 0.095499259f, 0.096605088f, 0.097723722f, 0.098855309f, + 0.100000000f, 0.101157945f, 0.102329299f, 0.103514217f, 0.104712855f, // -20.0.0dB ( 1/10 ) + 0.105925373f, 0.107151931f, 0.108392691f, 0.109647820f, 0.110917482f, + 0.112201845f, 0.113501082f, 0.114815362f, 0.116144861f, 0.117489755f, + 0.118850223f, 0.120226443f, 0.121618600f, 0.123026877f, 0.124451461f, + 0.125892541f, 0.127350308f, 0.128824955f, 0.130316678f, 0.131825674f, // -18.0 dB + 0.133352143f, 0.134896288f, 0.136458314f, 0.138038426f, 0.139636836f, + 0.141253754f, 0.142889396f, 0.144543977f, 0.146217717f, 0.147910839f, + 0.149623566f, 0.151356125f, 0.153108746f, 0.154881662f, 0.156675107f, + 0.158489319f, 0.160324539f, 0.162181010f, 0.164058977f, 0.165958691f, + 0.167880402f, 0.169824365f, 0.171790839f, 0.173780083f, 0.175792361f, + 0.177827941f, 0.179887092f, 0.181970086f, 0.184077200f, 0.186208714f, + 0.188364909f, 0.190546072f, 0.192752491f, 0.194984460f, 0.197242274f, + 0.199526231f, 0.201836636f, 0.204173794f, 0.206538016f, 0.208929613f, + 0.211348904f, 0.213796209f, 0.216271852f, 0.218776162f, 0.221309471f, + 0.223872114f, 0.226464431f, 0.229086765f, 0.231739465f, 0.234422882f, + 0.237137371f, 0.239883292f, 0.242661010f, 0.245470892f, 0.248313311f, + 0.251188643f, 0.254097271f, 0.257039578f, 0.260015956f, 0.263026799f, // -12.0dB ( 1/4 ) + 0.266072506f, 0.269153480f, 0.272270131f, 0.275422870f, 0.278612117f, + 0.281838293f, 0.285101827f, 0.288403150f, 0.291742701f, 0.295120923f, + 0.298538262f, 0.301995172f, 0.305492111f, 0.309029543f, 0.312607937f, + 0.316227766f, 0.319889511f, 0.323593657f, 0.327340695f, 0.331131121f, + 0.334965439f, 0.338844156f, 0.342767787f, 0.346736850f, 0.350751874f, + 0.354813389f, 0.358921935f, 0.363078055f, 0.367282300f, 0.371535229f, + 0.375837404f, 0.380189396f, 0.384591782f, 0.389045145f, 0.393550075f, + 0.398107171f, 0.402717034f, 0.407380278f, 0.412097519f, 0.416869383f, + 0.421696503f, 0.426579519f, 0.431519077f, 0.436515832f, 0.441570447f, + 0.446683592f, 0.451855944f, 0.457088190f, 0.462381021f, 0.467735141f, + 0.473151259f, 0.478630092f, 0.484172368f, 0.489778819f, 0.495450191f, + 0.501187234f, 0.506990708f, 0.512861384f, 0.518800039f, 0.524807460f, // -6.0.0dB ( 1/2 ) + 0.530884444f, 0.537031796f, 0.543250331f, 0.549540874f, 0.555904257f, + 0.562341325f, 0.568852931f, 0.575439937f, 0.582103218f, 0.588843655f, + 0.595662144f, 0.602559586f, 0.609536897f, 0.616595002f, 0.623734835f, + 0.630957344f, 0.638263486f, 0.645654229f, 0.653130553f, 0.660693448f, + 0.668343918f, 0.676082975f, 0.683911647f, 0.691830971f, 0.699841996f, + 0.707945784f, 0.716143410f, 0.724435960f, 0.732824533f, 0.741310241f, + 0.749894209f, 0.758577575f, 0.767361489f, 0.776247117f, 0.785235635f, + 0.794328235f, 0.803526122f, 0.812830516f, 0.822242650f, 0.831763771f, // -2.0 dB + 0.841395142f, 0.851138038f, 0.860993752f, 0.870963590f, 0.881048873f, + 0.891250938f, 0.901571138f, 0.912010839f, 0.922571427f, 0.933254301f, // -1.0 dB + 0.944060876f, 0.954992586f, 0.966050879f, 0.977237221f, 0.988553095f, + 1.000000000f, 1.011579454f, 1.023292992f, 1.035142167f, 1.047128548f, // 0.0 dB + 1.059253725f, 1.071519305f, 1.083926914f, 1.096478196f, 1.109174815f, + 1.122018454f, 1.135010816f, 1.148153621f, 1.161448614f, 1.174897555f, // 1.0 dB + 1.188502227f, 1.202264435f, 1.216186001f, 1.230268771f, 1.244514612f, + 1.258925412f, 1.273503081f, 1.288249552f, 1.303166778f, 1.318256739f, // 2.0 dB + 1.333521432f, 1.348962883f, 1.364583137f, 1.380384265f, 1.396368361f, + 1.412537545f, 1.428893959f, 1.445439771f, 1.462177174f, 1.479108388f, + 1.496235656f, 1.513561248f, 1.531087462f, 1.548816619f, 1.566751070f, + 1.584893192f, 1.603245391f, 1.621810097f, 1.640589773f, 1.659586907f, + 1.678804018f, 1.698243652f, 1.717908387f, 1.737800829f, 1.757923614f, + 1.778279410f, 1.798870915f, 1.819700859f, 1.840772001f, 1.862087137f, + 1.883649089f, 1.905460718f, 1.927524913f, 1.949844600f, 1.972422736f, + 1.995262315f, // 6.0dB ( *2 ) +}; + +const int PanTableMax{256}; + +const int PanTableCenter{PanTableMax / 2}; + +const float Pan2RatioTableSqrt[PanTableMax + 1]{ + 1.000000000f, 0.998044964f, 0.996086091f, 0.994123358f, 0.992156742f, 0.990186220f, + 0.988211769f, 0.986233365f, 0.984250984f, 0.982264603f, 0.980274196f, 0.978279740f, + 0.976281209f, 0.974278579f, 0.972271824f, 0.970260919f, 0.968245837f, 0.966226552f, + 0.964203039f, 0.962175270f, 0.960143218f, 0.958106857f, 0.956066159f, 0.954021095f, + 0.951971638f, 0.949917760f, 0.947859431f, 0.945796622f, 0.943729304f, 0.941657448f, + 0.939581024f, 0.937500000f, 0.935414347f, 0.933324033f, 0.931229027f, 0.929129297f, + 0.927024811f, 0.924915537f, 0.922801441f, 0.920682491f, 0.918558654f, 0.916429894f, + 0.914296177f, 0.912157470f, 0.910013736f, 0.907864940f, 0.905711047f, 0.903552018f, + 0.901387819f, 0.899218411f, 0.897043756f, 0.894863816f, 0.892678554f, 0.890487928f, + 0.888291900f, 0.886090430f, 0.883883476f, 0.881670999f, 0.879452955f, 0.877229303f, + 0.875000000f, 0.872765003f, 0.870524267f, 0.868277749f, 0.866025404f, 0.863767185f, + 0.861503047f, 0.859232943f, 0.856956825f, 0.854674646f, 0.852386356f, 0.850091907f, + 0.847791248f, 0.845484329f, 0.843171098f, 0.840851503f, 0.838525492f, 0.836193010f, + 0.833854004f, 0.831508418f, 0.829156198f, 0.826797285f, 0.824431622f, 0.822059152f, + 0.819679816f, 0.817293552f, 0.814900301f, 0.812500000f, 0.810092587f, 0.807677999f, + 0.805256170f, 0.802827036f, 0.800390530f, 0.797946583f, 0.795495129f, 0.793036096f, + 0.790569415f, 0.788095013f, 0.785612818f, 0.783122755f, 0.780624750f, 0.778118725f, + 0.775604603f, 0.773082305f, 0.770551750f, 0.768012858f, 0.765465545f, 0.762909726f, + 0.760345316f, 0.757772228f, 0.755190373f, 0.752599661f, 0.750000000f, 0.747391296f, + 0.744773455f, 0.742146380f, 0.739509973f, 0.736864133f, 0.734208758f, 0.731543744f, + 0.728868987f, 0.726184377f, 0.723489806f, 0.720785162f, 0.718070331f, 0.715345196f, + 0.712609641f, 0.709863543f, 0.707106781f, 0.704339229f, 0.701560760f, 0.698771243f, + 0.695970545f, 0.693158532f, 0.690335064f, 0.687500000f, 0.684653197f, 0.681794507f, + 0.678923781f, 0.676040864f, 0.673145601f, 0.670237831f, 0.667317391f, 0.664384113f, + 0.661437828f, 0.658478360f, 0.655505530f, 0.652519157f, 0.649519053f, 0.646505027f, + 0.643476884f, 0.640434423f, 0.637377439f, 0.634305723f, 0.631219059f, 0.628117226f, + 0.625000000f, 0.621867148f, 0.618718434f, 0.615553613f, 0.612372436f, 0.609174647f, + 0.605959982f, 0.602728173f, 0.599478940f, 0.596212001f, 0.592927061f, 0.589623821f, + 0.586301970f, 0.582961191f, 0.579601156f, 0.576221529f, 0.572821962f, 0.569402099f, + 0.565961571f, 0.562500000f, 0.559016994f, 0.555512151f, 0.551985054f, 0.548435274f, + 0.544862368f, 0.541265877f, 0.537645329f, 0.534000234f, 0.530330086f, 0.526634361f, + 0.522912517f, 0.519163991f, 0.515388203f, 0.511584548f, 0.507752400f, 0.503891109f, + 0.500000000f, 0.496078371f, 0.492125492f, 0.488140605f, 0.484122918f, 0.480071609f, + 0.475985819f, 0.471864652f, 0.467707173f, 0.463512405f, 0.459279327f, 0.455006868f, + 0.450693909f, 0.446339277f, 0.441941738f, 0.437500000f, 0.433012702f, 0.428478413f, + 0.423895624f, 0.419262746f, 0.414578099f, 0.409839908f, 0.405046294f, 0.400195265f, + 0.395284708f, 0.390312375f, 0.385275875f, 0.380172658f, 0.375000000f, 0.369754986f, + 0.364434493f, 0.359035165f, 0.353553391f, 0.347985273f, 0.342326598f, 0.336572800f, + 0.330718914f, 0.324759526f, 0.318688720f, 0.312500000f, 0.306186218f, 0.299739470f, + 0.293150985f, 0.286410981f, 0.279508497f, 0.272431184f, 0.265165043f, 0.257694102f, + 0.250000000f, 0.242061459f, 0.233853587f, 0.225346955f, 0.216506351f, 0.207289049f, + 0.197642354f, 0.187500000f, 0.176776695f, 0.165359457f, 0.153093109f, 0.139754249f, + 0.125000000f, 0.108253175f, 0.088388348f, 0.062500000f, 0.000000000f, +}; + +const float Pan2RatioTableSqrtSurround[PanTableMax + 1]{ + 0.800000000f, 0.799274270f, 0.798548500f, 0.797822830f, 0.797097090f, 0.796371340f, + 0.795645650f, 0.794919900f, 0.794194160f, 0.793468480f, 0.792742700f, 0.792016980f, + 0.791291240f, 0.790565550f, 0.789839800f, 0.789114060f, 0.788388370f, 0.787662600f, + 0.786936880f, 0.786211190f, 0.785485450f, 0.784759700f, 0.784033950f, 0.783308270f, + 0.782582500f, 0.781856780f, 0.781131090f, 0.780405340f, 0.779679600f, 0.778953850f, + 0.778228160f, 0.777502400f, 0.776776670f, 0.776050980f, 0.775325240f, 0.774599490f, + 0.773873800f, 0.773148060f, 0.772422300f, 0.771696570f, 0.770970880f, 0.770245130f, + 0.769519390f, 0.768793700f, 0.768067960f, 0.767342200f, 0.766616500f, 0.765890780f, + 0.765165030f, 0.764439340f, 0.763713600f, 0.762987850f, 0.762262100f, 0.761536400f, + 0.760810670f, 0.760084900f, 0.759359240f, 0.758633490f, 0.757907750f, 0.757182060f, + 0.756456300f, 0.755730570f, 0.755004800f, 0.754279140f, 0.753553390f, 0.752827640f, + 0.752101960f, 0.751376200f, 0.750650470f, 0.749924700f, 0.749199030f, 0.748473290f, + 0.747747540f, 0.747021850f, 0.746296100f, 0.745570360f, 0.744844680f, 0.744118900f, + 0.743393180f, 0.742667440f, 0.741941750f, 0.741216000f, 0.740490260f, 0.739764570f, + 0.739038800f, 0.738313080f, 0.737587390f, 0.736861650f, 0.736135900f, 0.735410200f, + 0.734684470f, 0.733958700f, 0.733232980f, 0.732507290f, 0.731781540f, 0.731055800f, + 0.730330100f, 0.729604360f, 0.728878600f, 0.728152930f, 0.727427180f, 0.726701440f, + 0.725975690f, 0.725250000f, 0.724524260f, 0.723798500f, 0.723072800f, 0.722347080f, + 0.721621330f, 0.720895590f, 0.720169900f, 0.719444160f, 0.718718400f, 0.717992700f, + 0.717266980f, 0.716541230f, 0.715815540f, 0.715089800f, 0.714364050f, 0.713638300f, + 0.712912600f, 0.712186870f, 0.711461100f, 0.710735440f, 0.710009690f, 0.709283950f, + 0.708558260f, 0.707832500f, 0.707106770f, 0.704339200f, 0.701560740f, 0.698771240f, + 0.695970540f, 0.693158500f, 0.690335040f, 0.687500000f, 0.684653200f, 0.681794500f, + 0.678923790f, 0.676040890f, 0.673145590f, 0.670237840f, 0.667317390f, 0.664384100f, + 0.661437800f, 0.658478380f, 0.655505540f, 0.652519170f, 0.649519000f, 0.646505000f, + 0.643476900f, 0.640434440f, 0.637377440f, 0.634305700f, 0.631219000f, 0.628117200f, + 0.625000000f, 0.621867100f, 0.618718450f, 0.615553600f, 0.612372460f, 0.609174670f, + 0.605960000f, 0.602728190f, 0.599478960f, 0.596212000f, 0.592927040f, 0.589623800f, + 0.586301980f, 0.582961200f, 0.579601170f, 0.576221500f, 0.572821970f, 0.569402100f, + 0.565961600f, 0.562500000f, 0.559017000f, 0.555512130f, 0.551985000f, 0.548435270f, + 0.544862390f, 0.541265900f, 0.537645340f, 0.534000200f, 0.530330060f, 0.526634340f, + 0.522912500f, 0.519163970f, 0.515388190f, 0.511584500f, 0.507752400f, 0.503891100f, + 0.500000000f, 0.496078370f, 0.492125480f, 0.488140600f, 0.484122930f, 0.480071600f, + 0.475985830f, 0.471864640f, 0.467707190f, 0.463512390f, 0.459279330f, 0.455006870f, + 0.450693900f, 0.446339280f, 0.441941740f, 0.437500000f, 0.433012690f, 0.428478420f, + 0.423895630f, 0.419262740f, 0.414578100f, 0.409839900f, 0.405046280f, 0.400195270f, + 0.395284700f, 0.390312370f, 0.385275870f, 0.380172670f, 0.375000000f, 0.369755000f, + 0.364434480f, 0.359035160f, 0.353553380f, 0.347985270f, 0.342326600f, 0.336572800f, + 0.330718900f, 0.324759500f, 0.318688720f, 0.312500000f, 0.306186230f, 0.299739480f, + 0.293150990f, 0.286410990f, 0.279508500f, 0.272431190f, 0.265165030f, 0.257694100f, + 0.250000000f, 0.242061470f, 0.233853590f, 0.225346950f, 0.216506350f, 0.207289050f, + 0.197642360f, 0.187500000f, 0.176776690f, 0.165359450f, 0.153093110f, 0.139754250f, + 0.125000000f, 0.108253170f, 0.088388346f, 0.062500000f, 0.000000000f, +}; + +const float Pan2RatioTableSinCos[PanTableMax + 1]{ + 1.000000000f, 0.999981175f, 0.999924702f, 0.999830582f, 0.999698819f, 0.999529418f, + 0.999322385f, 0.999077728f, 0.998795456f, 0.998475581f, 0.998118113f, 0.997723067f, + 0.997290457f, 0.996820299f, 0.996312612f, 0.995767414f, 0.995184727f, 0.994564571f, + 0.993906970f, 0.993211949f, 0.992479535f, 0.991709754f, 0.990902635f, 0.990058210f, + 0.989176510f, 0.988257568f, 0.987301418f, 0.986308097f, 0.985277642f, 0.984210092f, + 0.983105487f, 0.981963869f, 0.980785280f, 0.979569766f, 0.978317371f, 0.977028143f, + 0.975702130f, 0.974339383f, 0.972939952f, 0.971503891f, 0.970031253f, 0.968522094f, + 0.966976471f, 0.965394442f, 0.963776066f, 0.962121404f, 0.960430519f, 0.958703475f, + 0.956940336f, 0.955141168f, 0.953306040f, 0.951435021f, 0.949528181f, 0.947585591f, + 0.945607325f, 0.943593458f, 0.941544065f, 0.939459224f, 0.937339012f, 0.935183510f, + 0.932992799f, 0.930766961f, 0.928506080f, 0.926210242f, 0.923879533f, 0.921514039f, + 0.919113852f, 0.916679060f, 0.914209756f, 0.911706032f, 0.909167983f, 0.906595705f, + 0.903989293f, 0.901348847f, 0.898674466f, 0.895966250f, 0.893224301f, 0.890448723f, + 0.887639620f, 0.884797098f, 0.881921264f, 0.879012226f, 0.876070094f, 0.873094978f, + 0.870086991f, 0.867046246f, 0.863972856f, 0.860866939f, 0.857728610f, 0.854557988f, + 0.851355193f, 0.848120345f, 0.844853565f, 0.841554977f, 0.838224706f, 0.834862875f, + 0.831469612f, 0.828045045f, 0.824589303f, 0.821102515f, 0.817584813f, 0.814036330f, + 0.810457198f, 0.806847554f, 0.803207531f, 0.799537269f, 0.795836905f, 0.792106577f, + 0.788346428f, 0.784556597f, 0.780737229f, 0.776888466f, 0.773010453f, 0.769103338f, + 0.765167266f, 0.761202385f, 0.757208847f, 0.753186799f, 0.749136395f, 0.745057785f, + 0.740951125f, 0.736816569f, 0.732654272f, 0.728464390f, 0.724247083f, 0.720002508f, + 0.715730825f, 0.711432196f, 0.707106781f, 0.702754744f, 0.698376249f, 0.693971461f, + 0.689540545f, 0.685083668f, 0.680600998f, 0.676092704f, 0.671558955f, 0.666999922f, + 0.662415778f, 0.657806693f, 0.653172843f, 0.648514401f, 0.643831543f, 0.639124445f, + 0.634393284f, 0.629638239f, 0.624859488f, 0.620057212f, 0.615231591f, 0.610382806f, + 0.605511041f, 0.600616479f, 0.595699304f, 0.590759702f, 0.585797857f, 0.580813958f, + 0.575808191f, 0.570780746f, 0.565731811f, 0.560661576f, 0.555570233f, 0.550457973f, + 0.545324988f, 0.540171473f, 0.534997620f, 0.529803625f, 0.524589683f, 0.519355990f, + 0.514102744f, 0.508830143f, 0.503538384f, 0.498227667f, 0.492898192f, 0.487550160f, + 0.482183772f, 0.476799230f, 0.471396737f, 0.465976496f, 0.460538711f, 0.455083587f, + 0.449611330f, 0.444122145f, 0.438616239f, 0.433093819f, 0.427555093f, 0.422000271f, + 0.416429560f, 0.410843171f, 0.405241314f, 0.399624200f, 0.393992040f, 0.388345047f, + 0.382683432f, 0.377007410f, 0.371317194f, 0.365612998f, 0.359895037f, 0.354163525f, + 0.348418680f, 0.342660717f, 0.336889853f, 0.331106306f, 0.325310292f, 0.319502031f, + 0.313681740f, 0.307849640f, 0.302005949f, 0.296150888f, 0.290284677f, 0.284407537f, + 0.278519689f, 0.272621355f, 0.266712757f, 0.260794118f, 0.254865660f, 0.248927606f, + 0.242980180f, 0.237023606f, 0.231058108f, 0.225083911f, 0.219101240f, 0.213110320f, + 0.207111376f, 0.201104635f, 0.195090322f, 0.189068664f, 0.183039888f, 0.177004220f, + 0.170961889f, 0.164913120f, 0.158858143f, 0.152797185f, 0.146730474f, 0.140658239f, + 0.134580709f, 0.128498111f, 0.122410675f, 0.116318631f, 0.110222207f, 0.104121634f, + 0.098017140f, 0.091908956f, 0.085797312f, 0.079682438f, 0.073564564f, 0.067443920f, + 0.061320736f, 0.055195244f, 0.049067674f, 0.042938257f, 0.036807223f, 0.030674803f, + 0.024541229f, 0.018406730f, 0.012271538f, 0.006135885f, 0.000000000f}; + +const float Pan2RatioTableSinCosSurround[PanTableMax + 1]{ + 0.800000000f, 0.799274270f, 0.798548500f, 0.797822830f, 0.797097090f, 0.796371340f, + 0.795645650f, 0.794919900f, 0.794194160f, 0.793468480f, 0.792742700f, 0.792016980f, + 0.791291240f, 0.790565550f, 0.789839800f, 0.789114060f, 0.788388370f, 0.787662600f, + 0.786936880f, 0.786211190f, 0.785485450f, 0.784759700f, 0.784033950f, 0.783308270f, + 0.782582500f, 0.781856780f, 0.781131090f, 0.780405340f, 0.779679600f, 0.778953850f, + 0.778228160f, 0.777502400f, 0.776776670f, 0.776050980f, 0.775325240f, 0.774599490f, + 0.773873800f, 0.773148060f, 0.772422300f, 0.771696570f, 0.770970880f, 0.770245130f, + 0.769519390f, 0.768793700f, 0.768067960f, 0.767342200f, 0.766616500f, 0.765890780f, + 0.765165030f, 0.764439340f, 0.763713600f, 0.762987850f, 0.762262100f, 0.761536400f, + 0.760810670f, 0.760084900f, 0.759359240f, 0.758633490f, 0.757907750f, 0.757182060f, + 0.756456300f, 0.755730570f, 0.755004800f, 0.754279140f, 0.753553390f, 0.752827640f, + 0.752101960f, 0.751376200f, 0.750650470f, 0.749924700f, 0.749199030f, 0.748473290f, + 0.747747540f, 0.747021850f, 0.746296100f, 0.745570360f, 0.744844680f, 0.744118900f, + 0.743393180f, 0.742667440f, 0.741941750f, 0.741216000f, 0.740490260f, 0.739764570f, + 0.739038800f, 0.738313080f, 0.737587390f, 0.736861650f, 0.736135900f, 0.735410200f, + 0.734684470f, 0.733958700f, 0.733232980f, 0.732507290f, 0.731781540f, 0.731055800f, + 0.730330100f, 0.729604360f, 0.728878600f, 0.728152930f, 0.727427180f, 0.726701440f, + 0.725975690f, 0.725250000f, 0.724524260f, 0.723798500f, 0.723072800f, 0.722347080f, + 0.721621330f, 0.720895590f, 0.720169900f, 0.719444160f, 0.718718400f, 0.717992700f, + 0.717266980f, 0.716541230f, 0.715815540f, 0.715089800f, 0.714364050f, 0.713638300f, + 0.712912600f, 0.712186870f, 0.711461100f, 0.710735440f, 0.710009690f, 0.709283950f, + 0.708558260f, 0.707832500f, 0.707106770f, 0.702754740f, 0.698376240f, 0.693971460f, + 0.689540570f, 0.685083690f, 0.680601000f, 0.676092680f, 0.671558980f, 0.666999940f, + 0.662415800f, 0.657806690f, 0.653172850f, 0.648514390f, 0.643831550f, 0.639124450f, + 0.634393270f, 0.629638250f, 0.624859500f, 0.620057200f, 0.615231570f, 0.610382800f, + 0.605511070f, 0.600616460f, 0.595699300f, 0.590759690f, 0.585797850f, 0.580813940f, + 0.575808170f, 0.570780750f, 0.565731800f, 0.560661550f, 0.555570240f, 0.550457950f, + 0.545324980f, 0.540171440f, 0.534997640f, 0.529803630f, 0.524589660f, 0.519356000f, + 0.514102760f, 0.508830130f, 0.503538370f, 0.498227660f, 0.492898200f, 0.487550170f, + 0.482183780f, 0.476799220f, 0.471396740f, 0.465976500f, 0.460538720f, 0.455083580f, + 0.449611340f, 0.444122140f, 0.438616250f, 0.433093820f, 0.427555080f, 0.422000260f, + 0.416429550f, 0.410843160f, 0.405241300f, 0.399624200f, 0.393992040f, 0.388345030f, + 0.382683430f, 0.377007420f, 0.371317200f, 0.365612980f, 0.359895050f, 0.354163530f, + 0.348418680f, 0.342660730f, 0.336889860f, 0.331106300f, 0.325310290f, 0.319502030f, + 0.313681750f, 0.307849650f, 0.302005950f, 0.296150890f, 0.290284660f, 0.284407530f, + 0.278519690f, 0.272621360f, 0.266712750f, 0.260794100f, 0.254865650f, 0.248927610f, + 0.242980180f, 0.237023600f, 0.231058100f, 0.225083920f, 0.219101240f, 0.213110310f, + 0.207111370f, 0.201104640f, 0.195090320f, 0.189068660f, 0.183039890f, 0.177004220f, + 0.170961890f, 0.164913120f, 0.158858150f, 0.152797190f, 0.146730470f, 0.140658240f, + 0.134580700f, 0.128498100f, 0.122410680f, 0.116318630f, 0.110222210f, 0.104121630f, + 0.098017140f, 0.091908954f, 0.085797310f, 0.079682440f, 0.073564567f, 0.067443920f, + 0.061320737f, 0.055195242f, 0.049067672f, 0.042938258f, 0.036807224f, 0.030674802f, + 0.024541229f, 0.018406730f, 0.012271538f, 0.006135885f, 0.000000000f, +}; + +const float Pan2RatioTableLinear[PanTableMax + 1]{ + 1.000000000f, 0.996093750f, 0.992187500f, 0.988281250f, 0.984375000f, 0.980468750f, + 0.976562500f, 0.972656250f, 0.968750000f, 0.964843750f, 0.960937500f, 0.957031250f, + 0.953125000f, 0.949218750f, 0.945312500f, 0.941406250f, 0.937500000f, 0.933593750f, + 0.929687500f, 0.925781250f, 0.921875000f, 0.917968750f, 0.914062500f, 0.910156250f, + 0.906250000f, 0.902343750f, 0.898437500f, 0.894531250f, 0.890625000f, 0.886718750f, + 0.882812500f, 0.878906250f, 0.875000000f, 0.871093750f, 0.867187500f, 0.863281250f, + 0.859375000f, 0.855468750f, 0.851562500f, 0.847656250f, 0.843750000f, 0.839843750f, + 0.835937500f, 0.832031250f, 0.828125000f, 0.824218750f, 0.820312500f, 0.816406250f, + 0.812500000f, 0.808593750f, 0.804687500f, 0.800781250f, 0.796875000f, 0.792968750f, + 0.789062500f, 0.785156250f, 0.781250000f, 0.777343750f, 0.773437500f, 0.769531250f, + 0.765625000f, 0.761718750f, 0.757812500f, 0.753906250f, 0.750000000f, 0.746093750f, + 0.742187500f, 0.738281250f, 0.734375000f, 0.730468750f, 0.726562500f, 0.722656250f, + 0.718750000f, 0.714843750f, 0.710937500f, 0.707031250f, 0.703125000f, 0.699218750f, + 0.695312500f, 0.691406250f, 0.687500000f, 0.683593750f, 0.679687500f, 0.675781250f, + 0.671875000f, 0.667968750f, 0.664062500f, 0.660156250f, 0.656250000f, 0.652343750f, + 0.648437500f, 0.644531250f, 0.640625000f, 0.636718750f, 0.632812500f, 0.628906250f, + 0.625000000f, 0.621093750f, 0.617187500f, 0.613281250f, 0.609375000f, 0.605468750f, + 0.601562500f, 0.597656250f, 0.593750000f, 0.589843750f, 0.585937500f, 0.582031250f, + 0.578125000f, 0.574218750f, 0.570312500f, 0.566406250f, 0.562500000f, 0.558593750f, + 0.554687500f, 0.550781250f, 0.546875000f, 0.542968750f, 0.539062500f, 0.535156250f, + 0.531250000f, 0.527343750f, 0.523437500f, 0.519531250f, 0.515625000f, 0.511718750f, + 0.507812500f, 0.503906250f, 0.500000000f, 0.496093750f, 0.492187500f, 0.488281250f, + 0.484375000f, 0.480468750f, 0.476562500f, 0.472656250f, 0.468750000f, 0.464843750f, + 0.460937500f, 0.457031250f, 0.453125000f, 0.449218750f, 0.445312500f, 0.441406250f, + 0.437500000f, 0.433593750f, 0.429687500f, 0.425781250f, 0.421875000f, 0.417968750f, + 0.414062500f, 0.410156250f, 0.406250000f, 0.402343750f, 0.398437500f, 0.394531250f, + 0.390625000f, 0.386718750f, 0.382812500f, 0.378906250f, 0.375000000f, 0.371093750f, + 0.367187500f, 0.363281250f, 0.359375000f, 0.355468750f, 0.351562500f, 0.347656250f, + 0.343750000f, 0.339843750f, 0.335937500f, 0.332031250f, 0.328125000f, 0.324218750f, + 0.320312500f, 0.316406250f, 0.312500000f, 0.308593750f, 0.304687500f, 0.300781250f, + 0.296875000f, 0.292968750f, 0.289062500f, 0.285156250f, 0.281250000f, 0.277343750f, + 0.273437500f, 0.269531250f, 0.265625000f, 0.261718750f, 0.257812500f, 0.253906250f, + 0.250000000f, 0.246093750f, 0.242187500f, 0.238281250f, 0.234375000f, 0.230468750f, + 0.226562500f, 0.222656250f, 0.218750000f, 0.214843750f, 0.210937500f, 0.207031250f, + 0.203125000f, 0.199218750f, 0.195312500f, 0.191406250f, 0.187500000f, 0.183593750f, + 0.179687500f, 0.175781250f, 0.171875000f, 0.167968750f, 0.164062500f, 0.160156250f, + 0.156250000f, 0.152343750f, 0.148437500f, 0.144531250f, 0.140625000f, 0.136718750f, + 0.132812500f, 0.128906250f, 0.125000000f, 0.121093750f, 0.117187500f, 0.113281250f, + 0.109375000f, 0.105468750f, 0.101562500f, 0.097656250f, 0.093750000f, 0.089843750f, + 0.085937500f, 0.082031250f, 0.078125000f, 0.074218750f, 0.070312500f, 0.066406250f, + 0.062500000f, 0.058593750f, 0.054687500f, 0.050781250f, 0.046875000f, 0.042968750f, + 0.039062500f, 0.035156250f, 0.031250000f, 0.027343750f, 0.023437500f, 0.019531250f, + 0.015625000f, 0.011718750f, 0.007812500f, 0.003906250f, 0.000000000f, +}; + +const float Pan2RatioTableLinearSurround[PanTableMax + 1]{ + 0.800000000f, 0.797656240f, 0.795312500f, 0.792968750f, 0.790624980f, 0.788281260f, + 0.785937490f, 0.783593770f, 0.781250000f, 0.778906200f, 0.776562500f, 0.774218740f, + 0.771875000f, 0.769531250f, 0.767187480f, 0.764843760f, 0.762499990f, 0.760156270f, + 0.757812500f, 0.755468700f, 0.753125000f, 0.750781240f, 0.748437500f, 0.746093750f, + 0.743749980f, 0.741406260f, 0.739062490f, 0.736718770f, 0.734375000f, 0.732031200f, + 0.729687500f, 0.727343740f, 0.725000000f, 0.722656250f, 0.720312480f, 0.717968760f, + 0.715624990f, 0.713281270f, 0.710937500f, 0.708593700f, 0.706250000f, 0.703906240f, + 0.701562500f, 0.699218750f, 0.696874980f, 0.694531260f, 0.692187490f, 0.689843770f, + 0.687500000f, 0.685156200f, 0.682812500f, 0.680468740f, 0.678125000f, 0.675781250f, + 0.673437480f, 0.671093760f, 0.668749990f, 0.666406270f, 0.664062500f, 0.661718700f, + 0.659375000f, 0.657031240f, 0.654687500f, 0.652343750f, 0.649999980f, 0.647656260f, + 0.645312490f, 0.642968770f, 0.640625000f, 0.638281200f, 0.635937500f, 0.633593740f, + 0.631250000f, 0.628906250f, 0.626562480f, 0.624218760f, 0.621874990f, 0.619531270f, + 0.617187500f, 0.614843700f, 0.612500000f, 0.610156240f, 0.607812500f, 0.605468750f, + 0.603124980f, 0.600781260f, 0.598437490f, 0.596093770f, 0.593750000f, 0.591406200f, + 0.589062500f, 0.586718740f, 0.584375000f, 0.582031250f, 0.579687480f, 0.577343760f, + 0.574999990f, 0.572656270f, 0.570312500f, 0.567968700f, 0.565625000f, 0.563281240f, + 0.560937500f, 0.558593750f, 0.556249980f, 0.553906260f, 0.551562490f, 0.549218770f, + 0.546875000f, 0.544531200f, 0.542187500f, 0.539843740f, 0.537500000f, 0.535156250f, + 0.532812480f, 0.530468760f, 0.528124990f, 0.525781270f, 0.523437500f, 0.521093700f, + 0.518750000f, 0.516406240f, 0.514062500f, 0.511718750f, 0.509374980f, 0.507031260f, + 0.504687490f, 0.502343770f, 0.500000000f, 0.496093750f, 0.492187500f, 0.488281250f, + 0.484375000f, 0.480468750f, 0.476562500f, 0.472656250f, 0.468750000f, 0.464843750f, + 0.460937500f, 0.457031250f, 0.453125000f, 0.449218750f, 0.445312500f, 0.441406250f, + 0.437500000f, 0.433593750f, 0.429687500f, 0.425781250f, 0.421875000f, 0.417968750f, + 0.414062500f, 0.410156250f, 0.406250000f, 0.402343750f, 0.398437500f, 0.394531250f, + 0.390625000f, 0.386718750f, 0.382812500f, 0.378906250f, 0.375000000f, 0.371093750f, + 0.367187500f, 0.363281250f, 0.359375000f, 0.355468750f, 0.351562500f, 0.347656250f, + 0.343750000f, 0.339843750f, 0.335937500f, 0.332031250f, 0.328125000f, 0.324218750f, + 0.320312500f, 0.316406250f, 0.312500000f, 0.308593750f, 0.304687500f, 0.300781250f, + 0.296875000f, 0.292968750f, 0.289062500f, 0.285156250f, 0.281250000f, 0.277343750f, + 0.273437500f, 0.269531250f, 0.265625000f, 0.261718750f, 0.257812500f, 0.253906250f, + 0.250000000f, 0.246093750f, 0.242187500f, 0.238281250f, 0.234375000f, 0.230468750f, + 0.226562500f, 0.222656250f, 0.218750000f, 0.214843750f, 0.210937500f, 0.207031250f, + 0.203125000f, 0.199218750f, 0.195312500f, 0.191406250f, 0.187500000f, 0.183593750f, + 0.179687500f, 0.175781250f, 0.171875000f, 0.167968750f, 0.164062500f, 0.160156250f, + 0.156250000f, 0.152343750f, 0.148437500f, 0.144531250f, 0.140625000f, 0.136718750f, + 0.132812500f, 0.128906250f, 0.125000000f, 0.121093750f, 0.117187500f, 0.113281250f, + 0.109375000f, 0.105468750f, 0.101562500f, 0.097656250f, 0.093750000f, 0.089843750f, + 0.085937500f, 0.082031250f, 0.078125000f, 0.074218750f, 0.070312500f, 0.066406250f, + 0.062500000f, 0.058593750f, 0.054687500f, 0.050781250f, 0.046875000f, 0.042968750f, + 0.039062500f, 0.035156250f, 0.031250000f, 0.027343750f, 0.023437500f, 0.019531250f, + 0.015625000f, 0.011718750f, 0.007812500f, 0.003906250f, 0.000000000f, +}; + +const float* PanTableTable[3]{Pan2RatioTableSqrt, Pan2RatioTableSinCos, Pan2RatioTableLinear}; + +const float* PanTableTableForSurround[3]{Pan2RatioTableSqrtSurround, Pan2RatioTableSinCosSurround, + Pan2RatioTableLinearSurround}; + +} // anonymous namespace + +const float Util::CalcLpfFreqIntercept{0.135614380f}; + +const float Util::CalcLpfFreqThreshold{0.9f}; + +const u16 Util::CalcLpfFreqTable[Util::CalcLpfFreqTableSize]{ + 80, 100, 128, 160, 200, 256, 320, 400, 500, 640, 800, 1000, + 1280, 1600, 2000, 2560, 3200, 4000, 5120, 6400, 8000, 10240, 12800, 16000, +}; + +const BiquadFilterCoefficients + Util::LowPassFilterCoefficientsTable32000[Util::CalcLpfFreqTableSize]{ + {299, 0, 0, 16085, 0}, {333, 0, 0, 16051, 0}, {387, 0, 0, 15997, 0}, + {519, 0, 0, 15865, 0}, {645, 0, 0, 15739, 0}, {796, 0, 0, 15588, 0}, + {1007, 0, 0, 15377, 0}, {1239, 0, 0, 15145, 0}, {1526, 0, 0, 14858, 0}, + {1932, 0, 0, 14452, 0}, {2381, 0, 0, 14003, 0}, {2910, 0, 0, 13474, 0}, + {3626, 0, 0, 12758, 0}, {4387, 0, 0, 11997, 0}, {5266, 0, 0, 11118, 0}, + {6372, 0, 0, 10012, 0}, {7470, 0, 0, 8914, 0}, {8628, 0, 0, 7756, 0}, + {9918, 0, 0, 6466, 0}, {11021, 0, 0, 5363, 0}, {11994, 0, 0, 4390, 0}, + {12850, 0, 0, 3534, 0}, {13369, 0, 0, 3015, 0}, {13573, 0, 0, 2811, 0}, + }; + +const BiquadFilterCoefficients + Util::LowPassFilterCoefficientsTable48000[Util::CalcLpfFreqTableSize]{ + {244, 0, 0, 16140, 0}, {273, 0, 0, 16111, 0}, {308, 0, 0, 16076, 0}, + {344, 0, 0, 16040, 0}, {412, 0, 0, 15972, 0}, {555, 0, 0, 15829, 0}, + {682, 0, 0, 15702, 0}, {835, 0, 0, 15549, 0}, {1045, 0, 0, 15339, 0}, + {1323, 0, 0, 15061, 0}, {1631, 0, 0, 14753, 0}, {2011, 0, 0, 14373, 0}, + {2523, 0, 0, 13861, 0}, {3089, 0, 0, 13295, 0}, {3757, 0, 0, 12627, 0}, + {4630, 0, 0, 11754, 0}, {5542, 0, 0, 10842, 0}, {6566, 0, 0, 9818, 0}, + {7801, 0, 0, 8583, 0}, {8968, 0, 0, 7416, 0}, {10126, 0, 0, 6258, 0}, + {11318, 0, 0, 5066, 0}, {12243, 0, 0, 4141, 0}, {12965, 0, 0, 3419, 0}, + }; + +u16 Util::CalcLpfFreq(float scale) { + scale = fnd::FloatClamp(scale, 0.0f, 1.0f); + + u16 freq{0}; + + if (scale < CalcLpfFreqIntercept) { + freq = CalcLpfFreqTable[0]; + } else if (scale >= CalcLpfFreqThreshold) { + freq = CalcLpfFreqTable[CalcLpfFreqTableSize - 1]; + } else { + int idx{static_cast((scale - CalcLpfFreqIntercept) / (0.1f / 3.0f))}; + freq = CalcLpfFreqTable[idx]; + } + + return freq; +} + +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp index d0aa1900..33241eb4 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp @@ -24,7 +24,7 @@ position_t GetSeekPosition(FileStreamImpl& target, position_t offset, Stream::Se break; case Stream::SeekOrigin_Current: if (offset > 0) - result = ClampMax(target.GetCurrentPosition() + offset, targetSizeEnd); + result = Clamp(target.GetCurrentPosition() + offset, LONG_MIN, targetSizeEnd); else if (offset >= 0) result = target.GetCurrentPosition(); From ff446fc8597f4f9fea853edb9dcfc8fe533e87de Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 6 Sep 2026 16:13:14 -0300 Subject: [PATCH 537/785] atk: Match `Util::FindLpfFreqTableIndex` --- src/NintendoWare/atk/detail/util/atk_Util.cpp | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/NintendoWare/atk/detail/util/atk_Util.cpp b/src/NintendoWare/atk/detail/util/atk_Util.cpp index 2ba89a0c..d5df5e92 100644 --- a/src/NintendoWare/atk/detail/util/atk_Util.cpp +++ b/src/NintendoWare/atk/detail/util/atk_Util.cpp @@ -599,4 +599,24 @@ u16 Util::CalcLpfFreq(float scale) { return freq; } +int Util::FindLpfFreqTableIndex(int frequency) { + int lowIndex{0}; + int highIndex{CalcLpfFreqTableSize - 1}; + + while (lowIndex <= highIndex) { + const int index{(lowIndex + highIndex) / 2}; + + if (CalcLpfFreqTable[index] < frequency) + lowIndex = index + 1; + + else if (CalcLpfFreqTable[index] > frequency) + highIndex = index - 1; + + else + return index; + } + + return -1; +} + } // namespace nn::atk::detail \ No newline at end of file From 641aeeed6655937592c1da5fbbac73407dc39e2a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 6 Sep 2026 17:34:23 -0300 Subject: [PATCH 538/785] atk: Match `Util::CalcPanRatio` Part of the implementation was taken from [TuneBloom](https://github.com/stupidestmodder/TuneBloom/blob/master/TuneBloom/src/snd-ply/Util.cpp#L472) --- include/nn/atk/fnd/basis/atkfnd_Inlines.h | 6 +- src/NintendoWare/atk/detail/util/atk_Util.cpp | 55 +++++++++++++++++++ 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/include/nn/atk/fnd/basis/atkfnd_Inlines.h b/include/nn/atk/fnd/basis/atkfnd_Inlines.h index 84f738fc..dc181e80 100644 --- a/include/nn/atk/fnd/basis/atkfnd_Inlines.h +++ b/include/nn/atk/fnd/basis/atkfnd_Inlines.h @@ -6,12 +6,12 @@ namespace nn::atk::detail::fnd { template inline T Clamp(T x, T low, T high) { - if (x < low) - return low; - if (x > high) return high; + if (x < low) + return low; + return x; } diff --git a/src/NintendoWare/atk/detail/util/atk_Util.cpp b/src/NintendoWare/atk/detail/util/atk_Util.cpp index d5df5e92..61cab103 100644 --- a/src/NintendoWare/atk/detail/util/atk_Util.cpp +++ b/src/NintendoWare/atk/detail/util/atk_Util.cpp @@ -1,6 +1,9 @@ #include +#include + #include +#include namespace nn::atk::detail { @@ -599,6 +602,36 @@ u16 Util::CalcLpfFreq(float scale) { return freq; } +// NON_MATCHING: wrong order of operations +BiquadFilterCoefficients Util::CalcLowPassFilterCoefficients(int frequency, int sampleRate, bool isTableUsed) { + if (isTableUsed) { + int index{FindLpfFreqTableIndex(frequency)}; + + if (sampleRate == 32000) + return LowPassFilterCoefficientsTable32000[index]; + + if (sampleRate == 48000) + return LowPassFilterCoefficientsTable48000[index]; + + NN_UNEXPECTED_DEFAULT; + } + else { + float coef; + float filterParam; + util::AngleIndex angle = (static_cast(frequency) << 32) / sampleRate; + coef = 2.0f - util::CosTable(angle); + filterParam = sqrt(coef * coef - 1.0f); + + BiquadFilterCoefficients parameter; + + parameter.b1 = filterParam; + parameter.b0 = (filterParam - coef) * -16384.0f; + parameter.b2 = coef; + + return parameter; + } +} + int Util::FindLpfFreqTableIndex(int frequency) { int lowIndex{0}; int highIndex{CalcLpfFreqTableSize - 1}; @@ -619,4 +652,26 @@ int Util::FindLpfFreqTableIndex(int frequency) { return -1; } +float Util::CalcPanRatio(float pan, const PanInfo& info, OutputMode mode) { + pan = (fnd::FloatClamp(pan, -1.0f, 1.0f) + 1.0f) / 2.0f; + + const float* table; + if (!info.isEnableFrontBypass && mode == OutputMode_Surround) + table = PanTableTableForSurround[info.curve]; + else + table = PanTableTable[info.curve]; + + float ratio{table[static_cast(pan * PanTableMax + 0.5f)]}; + + if (info.centerZeroFlag) + ratio /= table[PanTableCenter]; + + if (info.zeroClampFlag) + ratio = fnd::Clamp(ratio, 0.0f, 1.0f); + else + ratio = fnd::Clamp(ratio, 0.0f, 2.0f); + + return ratio; +} + } // namespace nn::atk::detail \ No newline at end of file From a37cc76a7c0090092e0c8db129bffeec285e387c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 6 Sep 2026 17:39:14 -0300 Subject: [PATCH 539/785] atk: Match `Util::CalcSurroundPanRatio` --- src/NintendoWare/atk/detail/util/atk_Util.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/NintendoWare/atk/detail/util/atk_Util.cpp b/src/NintendoWare/atk/detail/util/atk_Util.cpp index 61cab103..f2377d46 100644 --- a/src/NintendoWare/atk/detail/util/atk_Util.cpp +++ b/src/NintendoWare/atk/detail/util/atk_Util.cpp @@ -674,4 +674,16 @@ float Util::CalcPanRatio(float pan, const PanInfo& info, OutputMode mode) { return ratio; } +float Util::CalcSurroundPanRatio(float surroundPan, const PanInfo& info) { + surroundPan = fnd::FloatClamp(surroundPan, 0.0f, 2.0f) / 2.0f; + + const float* table{PanTableTableForSurround[info.curve]}; + + float ratio{table[static_cast(surroundPan * PanTableMax + 0.5f)]}; + + ratio = fnd::Clamp(ratio, 0.0f, 2.0f); + + return ratio; +} + } // namespace nn::atk::detail \ No newline at end of file From 89432acae89850d1751d5f75b960a173526c73c2 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 6 Sep 2026 17:54:53 -0300 Subject: [PATCH 540/785] atk: Match `Util::CalcVolumeRatio` --- src/NintendoWare/atk/detail/util/atk_Util.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/NintendoWare/atk/detail/util/atk_Util.cpp b/src/NintendoWare/atk/detail/util/atk_Util.cpp index f2377d46..5bd45ae8 100644 --- a/src/NintendoWare/atk/detail/util/atk_Util.cpp +++ b/src/NintendoWare/atk/detail/util/atk_Util.cpp @@ -686,4 +686,12 @@ float Util::CalcSurroundPanRatio(float surroundPan, const PanInfo& info) { return ratio; } +float Util::CalcVolumeRatio(float dB) { + dB = fnd::Clamp(dB, -90.4f, 6.0f); + + int index{static_cast(dB * 10.0f) - VolumeDbMin}; + + return Decibel2RatioTable[index]; +} + } // namespace nn::atk::detail \ No newline at end of file From 43fd0226a61388f8e31a6c41e0b54ce402817f80 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 6 Sep 2026 17:57:29 -0300 Subject: [PATCH 541/785] atk: Match `Util::CalcRandom` --- src/NintendoWare/atk/detail/util/atk_Util.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/NintendoWare/atk/detail/util/atk_Util.cpp b/src/NintendoWare/atk/detail/util/atk_Util.cpp index 5bd45ae8..dbfa737a 100644 --- a/src/NintendoWare/atk/detail/util/atk_Util.cpp +++ b/src/NintendoWare/atk/detail/util/atk_Util.cpp @@ -694,4 +694,12 @@ float Util::CalcVolumeRatio(float dB) { return Decibel2RatioTable[index]; } +u16 Util::CalcRandom() { + static u32 u; + + u *= 0x19660d; + u += 0x3c6ef35f; + return u >> 16; +} + } // namespace nn::atk::detail \ No newline at end of file From b657e88ece23eda97289cd52dab6b69ca855705b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 6 Sep 2026 18:12:59 -0300 Subject: [PATCH 542/785] atk: Match `Util::GetByteBySample` --- include/nn/atk/atk_Util.h | 2 +- src/NintendoWare/atk/detail/util/atk_Util.cpp | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index 1de3fd77..67d21735 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -50,7 +50,7 @@ class Util { static float CalcVolumeRatio(float dB); static u16 CalcRandom(); - static size_t GetSampleByByte(size_t byte, SampleFormat format); + static size_t GetSampleByByte(size_t samples, SampleFormat format); static size_t GetByteBySample(size_t samples, SampleFormat format); static bool IsValidMemoryForDsp(const void* ptr, size_t size); diff --git a/src/NintendoWare/atk/detail/util/atk_Util.cpp b/src/NintendoWare/atk/detail/util/atk_Util.cpp index dbfa737a..4c4831b8 100644 --- a/src/NintendoWare/atk/detail/util/atk_Util.cpp +++ b/src/NintendoWare/atk/detail/util/atk_Util.cpp @@ -702,4 +702,33 @@ u16 Util::CalcRandom() { return u >> 16; } +size_t Util::GetByteBySample(size_t samples, SampleFormat format) { + size_t byte {0}; + size_t frac; + + switch (format) { + case SampleFormat_DspAdpcm: + byte = (samples / 14) * 8; + frac = samples % 14; + + if (frac != 0) + byte += (frac + 1) / 2 + 1; + + break; + + case SampleFormat_PcmS8: + byte = samples; + break; + + case SampleFormat_PcmS16: + byte = samples << 1; + break; + + default: + break; + } + + return byte; +} + } // namespace nn::atk::detail \ No newline at end of file From e86e93722b86846eced4733196fa273ec8c3fc7a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 6 Sep 2026 18:17:50 -0300 Subject: [PATCH 543/785] atk: Match `Util::GetSampleByByte` --- include/nn/atk/atk_Util.h | 2 +- src/NintendoWare/atk/detail/util/atk_Util.cpp | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index 67d21735..1de3fd77 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -50,7 +50,7 @@ class Util { static float CalcVolumeRatio(float dB); static u16 CalcRandom(); - static size_t GetSampleByByte(size_t samples, SampleFormat format); + static size_t GetSampleByByte(size_t byte, SampleFormat format); static size_t GetByteBySample(size_t samples, SampleFormat format); static bool IsValidMemoryForDsp(const void* ptr, size_t size); diff --git a/src/NintendoWare/atk/detail/util/atk_Util.cpp b/src/NintendoWare/atk/detail/util/atk_Util.cpp index 4c4831b8..11204d5d 100644 --- a/src/NintendoWare/atk/detail/util/atk_Util.cpp +++ b/src/NintendoWare/atk/detail/util/atk_Util.cpp @@ -702,6 +702,35 @@ u16 Util::CalcRandom() { return u >> 16; } +size_t Util::GetSampleByByte(size_t byte, SampleFormat format) { + size_t samples {0}; + size_t frac; + + switch (format) { + case SampleFormat_DspAdpcm: + samples = (byte / 8) * 14; + frac = byte & 7; + + if (frac != 0) + samples += frac * 2 - 2; + + break; + + case SampleFormat_PcmS8: + samples = byte; + break; + + case SampleFormat_PcmS16: + samples = byte >> 1; + break; + + default: + break; + } + + return samples; +} + size_t Util::GetByteBySample(size_t samples, SampleFormat format) { size_t byte {0}; size_t frac; From c74ee143b56b203de0a56a4447ebdb05f875c2e2 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 6 Sep 2026 18:19:09 -0300 Subject: [PATCH 544/785] atk: Match `Util::IsValidMemoryForDsp` --- src/NintendoWare/atk/detail/util/atk_Util.cpp | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/NintendoWare/atk/detail/util/atk_Util.cpp b/src/NintendoWare/atk/detail/util/atk_Util.cpp index 11204d5d..e1ab2441 100644 --- a/src/NintendoWare/atk/detail/util/atk_Util.cpp +++ b/src/NintendoWare/atk/detail/util/atk_Util.cpp @@ -603,7 +603,8 @@ u16 Util::CalcLpfFreq(float scale) { } // NON_MATCHING: wrong order of operations -BiquadFilterCoefficients Util::CalcLowPassFilterCoefficients(int frequency, int sampleRate, bool isTableUsed) { +BiquadFilterCoefficients Util::CalcLowPassFilterCoefficients(int frequency, int sampleRate, + bool isTableUsed) { if (isTableUsed) { int index{FindLpfFreqTableIndex(frequency)}; @@ -612,10 +613,9 @@ BiquadFilterCoefficients Util::CalcLowPassFilterCoefficients(int frequency, int if (sampleRate == 48000) return LowPassFilterCoefficientsTable48000[index]; - + NN_UNEXPECTED_DEFAULT; - } - else { + } else { float coef; float filterParam; util::AngleIndex angle = (static_cast(frequency) << 32) / sampleRate; @@ -696,14 +696,14 @@ float Util::CalcVolumeRatio(float dB) { u16 Util::CalcRandom() { static u32 u; - + u *= 0x19660d; u += 0x3c6ef35f; return u >> 16; } size_t Util::GetSampleByByte(size_t byte, SampleFormat format) { - size_t samples {0}; + size_t samples{0}; size_t frac; switch (format) { @@ -723,7 +723,7 @@ size_t Util::GetSampleByByte(size_t byte, SampleFormat format) { case SampleFormat_PcmS16: samples = byte >> 1; break; - + default: break; } @@ -732,7 +732,7 @@ size_t Util::GetSampleByByte(size_t byte, SampleFormat format) { } size_t Util::GetByteBySample(size_t samples, SampleFormat format) { - size_t byte {0}; + size_t byte{0}; size_t frac; switch (format) { @@ -752,7 +752,7 @@ size_t Util::GetByteBySample(size_t samples, SampleFormat format) { case SampleFormat_PcmS16: byte = samples << 1; break; - + default: break; } @@ -760,4 +760,8 @@ size_t Util::GetByteBySample(size_t samples, SampleFormat format) { return byte; } +bool Util::IsValidMemoryForDsp([[maybe_unused]] const void* ptr, [[maybe_unused]] size_t size) { + return true; +} + } // namespace nn::atk::detail \ No newline at end of file From 915a6e3c47a2ed1ccebd2e575c667803502bbe02 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 6 Sep 2026 18:49:23 -0300 Subject: [PATCH 545/785] atk: Match `Util::GetWaveFile` --- include/nn/atk/atk_SoundArchive.h | 83 ++++++++++--------- include/nn/atk/atk_Util.h | 8 +- src/NintendoWare/atk/detail/util/atk_Util.cpp | 20 ++++- 3 files changed, 67 insertions(+), 44 deletions(-) diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index a98268dc..9bffa115 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -5,7 +5,8 @@ #include namespace nn::atk { -namespace detail{ + +namespace detail { class SoundArchiveFileReader; class SoundArchiveParametersHook; struct SoundArchiveFilesHook; @@ -14,17 +15,17 @@ namespace driver { class StreamSoundLoader; } -} // namespace nn::atk::detail +} // namespace detail class SoundArchive { public: using ItemId = u32; - static const ItemId InvalidId = 0xffffffff; + static const ItemId InvalidId{0xffffffff}; - static const int UserParamIndexMax = 3; - static const u32 ResultInvalidSoundId = 0; - static const u32 InvalidUserParam = 0xffffffff; + static const int UserParamIndexMax{3}; + static const u32 ResultInvalidSoundId{0}; + static const u32 InvalidUserParam{0xffffffff}; enum SoundType { SoundType_Invalid, @@ -72,7 +73,7 @@ class SoundArchive { }; static_assert(sizeof(Sound3DInfo) == 0xc); - static const u32 SequenceBankMax = 4; + static const u32 SequenceBankMax{4}; struct SequenceSoundInfo { u32 startOffset; u32 bankIds[SequenceBankMax]; @@ -84,7 +85,7 @@ class SoundArchive { }; static_assert(sizeof(SequenceSoundInfo) == 0x1c); - static const u32 StreamTrackCount = 8; + static const u32 StreamTrackCount{8}; struct StreamTrackInfo { u8 volume; u8 pan; @@ -151,12 +152,12 @@ class SoundArchive { static_assert(sizeof(BankInfo) == 0x4); struct WaveArchiveInfo { - u32 fileId; + u32 fileId{SoundArchive::InvalidId}; u32 waveCount; - bool isLoadIndividual; + bool isLoadIndividual{false}; u8 padding[3]; - WaveArchiveInfo(); + WaveArchiveInfo() = default; }; static_assert(sizeof(WaveArchiveInfo) == 0xc); @@ -199,12 +200,12 @@ class SoundArchive { static_assert(sizeof(SoundArchivePlayerInfo) == 0x24); struct FileInfo { - static const u32 InvalidOffset = 0xffffffff; - static const u32 InvalidSize = 0xffffffff; + static const u32 InvalidOffset{0xffffffff}; + static const u32 InvalidSize{0xffffffff}; - u32 fileSize {InvalidSize}; - u32 offsetFromFileBlockHead {InvalidOffset}; - const char* externalFilePath {}; + u32 fileSize{InvalidSize}; + u32 offsetFromFileBlockHead{InvalidOffset}; + const char* externalFilePath{}; FileInfo() = default; }; @@ -219,12 +220,12 @@ class SoundArchive { bool IsAvailable() const; u32 GetSoundCount() const; - u32 GetGroupCount() const; - u32 GetPlayerCount() const; - u32 GetSoundGroupCount() const; - u32 GetBankCount() const; - u32 GetWaveArchiveCount() const; - u32 detail_GetFileCount() const; + u32 GetGroupCount() const; + u32 GetPlayerCount() const; + u32 GetSoundGroupCount() const; + u32 GetBankCount() const; + u32 GetWaveArchiveCount() const; + u32 detail_GetFileCount() const; const char* GetItemLabel(ItemId id) const; ItemId GetItemId(const char* pStr) const; @@ -284,11 +285,11 @@ class SoundArchive { virtual const void* detail_GetFileAddress(FileId fileId) const = 0; virtual size_t detail_GetRequiredStreamBufferSize() const = 0; - detail::fnd::FileStream* detail_OpenFileStream(FileId fileId, void* buffer, size_t size, + detail::fnd::FileStream* detail_OpenFileStream(FileId fileId, void* buffer, size_t size, void* cacheBuffer, size_t cacheSize) const; const detail::Util::Table* detail_GetAttachedGroupTable(FileId fileId) const; - - detail::SoundArchiveParametersHook* detail_GetParametersHook() const { + + detail::SoundArchiveParametersHook* detail_GetParametersHook() const { return m_pParametersHook; } @@ -297,13 +298,14 @@ class SoundArchive { } void SetExternalFileRoot(const char* extFileRoot); - - bool ReadStreamSoundFilePath(char* outFilePathBuffer, size_t filePathBufferSize, ItemId soundId) const; + + bool ReadStreamSoundFilePath(char* outFilePathBuffer, size_t filePathBufferSize, + ItemId soundId) const; virtual void FileAccessBegin() const; virtual void FileAccessEnd() const; - const char* detail_GetExternalFileFullPath(const char* externalFilePath, char* pathBuffer, + const char* detail_GetExternalFileFullPath(const char* externalFilePath, char* pathBuffer, size_t bufSize) const; virtual bool IsAddon() const; @@ -312,25 +314,28 @@ class SoundArchive { void Initialize(detail::SoundArchiveFileReader* fileReader); void Finalize(); - virtual detail::fnd::FileStream* OpenStream(void* buffer, size_t size, - position_t begin, size_t length) const = 0; - virtual detail::fnd::FileStream* OpenExtStream(void* buffer, size_t size, const char* extFilePath, - void* cacheBuffer, size_t cacheSize) const = 0; + virtual detail::fnd::FileStream* OpenStream(void* buffer, size_t size, position_t begin, + size_t length) const = 0; + virtual detail::fnd::FileStream* OpenExtStream(void* buffer, size_t size, + const char* extFilePath, void* cacheBuffer, + size_t cacheSize) const = 0; - detail::fnd::FileStream* OpenExtStreamImpl(void* buffer, size_t size, const char* externalFilePath, - void* cacheBuffer, size_t cacheSize) const; - - static const s32 FilePathMax = 639; + detail::fnd::FileStream* OpenExtStreamImpl(void* buffer, size_t size, + const char* externalFilePath, void* cacheBuffer, + size_t cacheSize) const; + + static const s32 FilePathMax{639}; private: friend detail::driver::StreamSoundLoader; - detail::SoundArchiveFileReader* m_pFileReader {}; - detail::SoundArchiveParametersHook* m_pParametersHook {}; + detail::SoundArchiveFileReader* m_pFileReader{}; + detail::SoundArchiveParametersHook* m_pParametersHook{}; char m_ExtFileRoot[FilePathMax]; u32 m_FileBlockOffset; }; static_assert(sizeof(SoundArchive) == 0x2a0); class AddonSoundArchive : public SoundArchive {}; -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index 1de3fd77..4206d681 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -224,10 +224,10 @@ class Util { return static_cast(value >> (16 * index)); } - const void* GetWaveFile(u32 waveArchiveId, u32 waveIndex, const SoundArchive& arc, - const SoundArchivePlayer& player); - const void* GetWaveFile(u32 waveArchiveId, u32 waveIndex, const SoundArchive& arc, - const PlayerHeapDataManager* mgr); + static const void* GetWaveFile(u32 waveArchiveId, u32 waveIndex, const SoundArchive& arc, + const SoundArchivePlayer& player); + static const void* GetWaveFile(u32 waveArchiveId, u32 waveIndex, const SoundArchive& arc, + const PlayerHeapDataManager* mgr); enum WaveArchiveLoadStatus { WaveArchiveLoadStatus_Error = -2, diff --git a/src/NintendoWare/atk/detail/util/atk_Util.cpp b/src/NintendoWare/atk/detail/util/atk_Util.cpp index e1ab2441..83ddaa07 100644 --- a/src/NintendoWare/atk/detail/util/atk_Util.cpp +++ b/src/NintendoWare/atk/detail/util/atk_Util.cpp @@ -2,9 +2,11 @@ #include -#include #include +#include +#include + namespace nn::atk::detail { namespace { @@ -764,4 +766,20 @@ bool Util::IsValidMemoryForDsp([[maybe_unused]] const void* ptr, [[maybe_unused] return true; } +const void* Util::GetWaveFile(u32 waveArchiveId, u32 waveIndex, const SoundArchive& arc, + const SoundArchivePlayer& player) { + SoundArchive::WaveArchiveInfo info; + if (!arc.ReadWaveArchiveInfo(waveArchiveId, &info)) + return nullptr; + + const void* warcFile{player.detail_GetFileAddress(info.fileId)}; + if (warcFile == nullptr) + return nullptr; + + WaveArchiveFileReader reader{warcFile, info.isLoadIndividual}; + const void* waveFile{reader.GetWaveFile(waveIndex)}; + + return waveFile; +} + } // namespace nn::atk::detail \ No newline at end of file From a1a851e106d357334467fb0f4ff8932268127e12 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 6 Sep 2026 18:52:33 -0300 Subject: [PATCH 546/785] atk: Match overload for `Util::GetWaveFile` --- src/NintendoWare/atk/detail/util/atk_Util.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/NintendoWare/atk/detail/util/atk_Util.cpp b/src/NintendoWare/atk/detail/util/atk_Util.cpp index 83ddaa07..7eaef877 100644 --- a/src/NintendoWare/atk/detail/util/atk_Util.cpp +++ b/src/NintendoWare/atk/detail/util/atk_Util.cpp @@ -782,4 +782,20 @@ const void* Util::GetWaveFile(u32 waveArchiveId, u32 waveIndex, const SoundArchi return waveFile; } +const void* Util::GetWaveFile(u32 waveArchiveId, u32 waveIndex, const SoundArchive& arc, + const PlayerHeapDataManager* mgr) { + SoundArchive::WaveArchiveInfo info; + if (!arc.ReadWaveArchiveInfo(waveArchiveId, &info)) + return nullptr; + + const void* warcFile{mgr->GetFileAddress(info.fileId)}; + if (warcFile == nullptr) + return nullptr; + + WaveArchiveFileReader reader{warcFile, info.isLoadIndividual}; + const void* waveFile{reader.GetWaveFile(waveIndex)}; + + return waveFile; +} + } // namespace nn::atk::detail \ No newline at end of file From b12332a1aac721d5213ac078e8eada586f5f9da2 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 6 Sep 2026 19:23:02 -0300 Subject: [PATCH 547/785] atk: Match `Util::GetWaveArchiveOfBank` --- include/nn/atk/atk_SoundArchiveLoader.h | 2 +- include/nn/atk/atk_WaveArchiveFileReader.h | 2 + src/NintendoWare/atk/detail/util/atk_Util.cpp | 41 +++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_SoundArchiveLoader.h b/include/nn/atk/atk_SoundArchiveLoader.h index c2c2d970..8ae5b3a6 100644 --- a/include/nn/atk/atk_SoundArchiveLoader.h +++ b/include/nn/atk/atk_SoundArchiveLoader.h @@ -6,7 +6,7 @@ namespace nn::atk::detail { struct LoadItemInfo { SoundArchive::ItemId itemId; - void* address; + const void* address; }; static_assert(sizeof(LoadItemInfo) == 0x10); diff --git a/include/nn/atk/atk_WaveArchiveFileReader.h b/include/nn/atk/atk_WaveArchiveFileReader.h index bc29536f..3648bf98 100644 --- a/include/nn/atk/atk_WaveArchiveFileReader.h +++ b/include/nn/atk/atk_WaveArchiveFileReader.h @@ -30,6 +30,8 @@ class WaveArchiveFileReader { void* SetWaveFile(u32 waveIndex, const void* pWaveFile); + bool IsLoaded(u32 index) { return m_IsInitialized && GetWaveFile(index) != nullptr; } + private: WaveArchiveFile::FileHeader* m_pHeader; WaveArchiveFile::InfoBlockBody* m_pInfoBlockBody; diff --git a/src/NintendoWare/atk/detail/util/atk_Util.cpp b/src/NintendoWare/atk/detail/util/atk_Util.cpp index 7eaef877..d41ee54f 100644 --- a/src/NintendoWare/atk/detail/util/atk_Util.cpp +++ b/src/NintendoWare/atk/detail/util/atk_Util.cpp @@ -798,4 +798,45 @@ const void* Util::GetWaveFile(u32 waveArchiveId, u32 waveIndex, const SoundArchi return waveFile; } +Util::WaveArchiveLoadStatus Util::GetWaveArchiveOfBank(LoadItemInfo& warcLoadInfo, + bool& isLoadIndividual, const void* bankFile, + const SoundArchive& arc, + const SoundArchiveLoader& mgr) { + warcLoadInfo.itemId = SoundArchive::InvalidId; + warcLoadInfo.address = nullptr; + isLoadIndividual = false; + + BankFileReader reader{bankFile}; + const WaveIdTable* table{reader.GetWaveIdTable()}; + if (table == nullptr) + return WaveArchiveLoadStatus_Error; + + if (table->GetCount() == 0) + return WaveArchiveLoadStatus_Noneed; + + const WaveId* pWaveId{table->GetWaveId(0)}; + + const void* waveArchiveFile{mgr.detail_GetFileAddressByItemId(pWaveId->waveArchiveId)}; + if (waveArchiveFile == nullptr) + return WaveArchiveLoadStatus_NotYet; + + SoundArchive::WaveArchiveInfo warcInfo; + bool isReadWarcInfo{arc.ReadWaveArchiveInfo(pWaveId->waveArchiveId, &warcInfo)}; + + warcLoadInfo.itemId = pWaveId->waveArchiveId; + warcLoadInfo.address = waveArchiveFile; + + isLoadIndividual = warcInfo.isLoadIndividual; + + if (isLoadIndividual) { + WaveArchiveFileReader reader{waveArchiveFile, isLoadIndividual}; + for (u32 i{0}; i < table->GetCount(); ++i) { + if (!reader.IsLoaded(pWaveId->waveIndex)) + return WaveArchiveLoadStatus_Partly; + } + } + + return WaveArchiveLoadStatus_Ok; +} + } // namespace nn::atk::detail \ No newline at end of file From 2092915c38e47de4a014490be4fc1ee05cbf14a2 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 6 Sep 2026 19:49:32 -0300 Subject: [PATCH 548/785] atk: Match `Util::GetWaveFileOfWaveSound` --- include/nn/atk/atk_CurveLfo.h | 9 +++--- include/nn/atk/atk_Global.h | 27 +++++++++++++++++- include/nn/atk/atk_WaveSoundFileReader.h | 3 ++ .../detail/strm/atk_StreamSoundFileLoader.cpp | 4 +-- src/NintendoWare/atk/detail/util/atk_Util.cpp | 28 ++++++++++++++++++- 5 files changed, 62 insertions(+), 9 deletions(-) diff --git a/include/nn/atk/atk_CurveLfo.h b/include/nn/atk/atk_CurveLfo.h index db947652..42d26daf 100644 --- a/include/nn/atk/atk_CurveLfo.h +++ b/include/nn/atk/atk_CurveLfo.h @@ -37,9 +37,8 @@ static_assert(sizeof(CurveLfoParam) == 0x10); class CurveLfo { public: - CurveLfo() = default; - + void Reset(); void Update(int msec); @@ -51,7 +50,7 @@ class CurveLfo { static void InitializeCurveTable(); - using CurveFunc = float(*)(float); + using CurveFunc = float (*)(float); static CurveFunc RegisterUserCurve(CurveFunc func, u32 index); static CurveFunc UnregisterUserCurve(u32 index); @@ -63,8 +62,8 @@ class CurveLfo { mutable float m_RandomValue; bool m_IsStart; bool m_IsNext; - u8 m_Padding[2]; + [[maybe_unused]] u8 m_Padding[2]; }; static_assert(sizeof(CurveLfo) == 0x20); -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h index 5fb8a655..8d33ce33 100644 --- a/include/nn/atk/atk_Global.h +++ b/include/nn/atk/atk_Global.h @@ -147,7 +147,32 @@ enum FsPriority { FsPriority_Low, }; -struct AdshrCurve { +class AdshrCurve { +public: + AdshrCurve(u8 a, u8 d, u8 s, u8 h, u8 r) + : m_Attack{a}, m_Decay{d}, m_Sustain{s}, m_Hold{h}, m_Release{r} {} + + u8 GetAttack() const { return m_Attack; } + + void SetAttack(u8 attack) { m_Attack = attack; } + + u8 GetDecay() const { return m_Decay; } + + void SetDecay(u8 decay) { m_Decay = decay; } + + u8 GetSustain() const { return m_Sustain; } + + void SetSustain(u8 sustain) { m_Sustain = sustain; } + + u8 GetHold() const { return m_Hold; } + + void SetHold(u8 hold) { m_Hold = hold; } + + u8 GetRelease() const { return m_Release; } + + void SetRelease(u8 release) { m_Release = release; } + +private: u8 m_Attack; u8 m_Decay; u8 m_Sustain; diff --git a/include/nn/atk/atk_WaveSoundFileReader.h b/include/nn/atk/atk_WaveSoundFileReader.h index 18503913..10ead847 100644 --- a/include/nn/atk/atk_WaveSoundFileReader.h +++ b/include/nn/atk/atk_WaveSoundFileReader.h @@ -25,6 +25,9 @@ struct WaveSoundNoteInfo { u8 surroundPan; u8 volume; f32 pitch; + + WaveSoundNoteInfo() + : adshr(0, 0, 0, 0, 0) {}; }; static_assert(sizeof(WaveSoundNoteInfo) == 0x18); diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileLoader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileLoader.cpp index 4f0896a8..2c48c0d6 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileLoader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileLoader.cpp @@ -15,7 +15,7 @@ bool StreamSoundFileLoader::LoadFileHeader(StreamSoundFileReader* reader, void* if (loadSize <= size) { m_pStream->Seek(0, fnd::FileStream::SeekOrigin_Begin); readSize = m_pStream->Read(buffer, loadSize, nullptr); - if (readSize == (int)loadSize) { + if (static_cast(readSize) == static_cast(loadSize)) { reader->Initialize(buffer); m_SeekBlockOffset = reader->GetSeekBlockOffset(); m_RegionDataOffset = reader->GetRegionDataOffset(); @@ -33,7 +33,7 @@ bool StreamSoundFileLoader::ReadSeekBlockData(u16* yn1, u16* yn2, int blockIndex size_t readDataSize {SeekInfoMaxSize}; size_t readOffset {m_SeekBlockOffset + sizeof(BinaryBlockHeader) + blockIndex * readDataSize}; - m_pStream->Seek(readOffset, fnd::FileStream::SeekOrigin_Begin); + m_pStream->Seek(static_cast(readOffset), fnd::FileStream::SeekOrigin_Begin); if (readDataSize <= 64) { const int Align {64}; u16 bufferBase[128]; diff --git a/src/NintendoWare/atk/detail/util/atk_Util.cpp b/src/NintendoWare/atk/detail/util/atk_Util.cpp index d41ee54f..56729786 100644 --- a/src/NintendoWare/atk/detail/util/atk_Util.cpp +++ b/src/NintendoWare/atk/detail/util/atk_Util.cpp @@ -821,7 +821,7 @@ Util::WaveArchiveLoadStatus Util::GetWaveArchiveOfBank(LoadItemInfo& warcLoadInf return WaveArchiveLoadStatus_NotYet; SoundArchive::WaveArchiveInfo warcInfo; - bool isReadWarcInfo{arc.ReadWaveArchiveInfo(pWaveId->waveArchiveId, &warcInfo)}; + [[maybe_unused]] bool isReadWarcInfo{arc.ReadWaveArchiveInfo(pWaveId->waveArchiveId, &warcInfo)}; warcLoadInfo.itemId = pWaveId->waveArchiveId; warcLoadInfo.address = waveArchiveFile; @@ -839,4 +839,30 @@ Util::WaveArchiveLoadStatus Util::GetWaveArchiveOfBank(LoadItemInfo& warcLoadInf return WaveArchiveLoadStatus_Ok; } +const void* Util::GetWaveFileOfWaveSound(const void* wsdFile, u32 index, const SoundArchive& arc, + const SoundArchiveLoader& mgr) { + WaveSoundFileReader reader{wsdFile}; + WaveSoundNoteInfo noteInfo{}; + + [[maybe_unused]] bool isReadNoteInfo{reader.ReadNoteInfo(¬eInfo, index, 0)}; + // if (!isReadNoteInfo) + // return nullptr; + + const void* waveArchiveFile{mgr.detail_GetFileAddressByItemId(noteInfo.waveArchiveId)}; + if (waveArchiveFile == nullptr) + return nullptr; + + SoundArchive::WaveArchiveInfo warcInfo; + [[maybe_unused]] bool isReadWarcInfo{arc.ReadWaveArchiveInfo(noteInfo.waveArchiveId, &warcInfo)}; + // if (!isReadWarcInfo) + // return nullptr; + + WaveArchiveFileReader warcReader{waveArchiveFile, warcInfo.isLoadIndividual}; + const void* waveFile{warcReader.GetWaveFile(noteInfo.waveIndex)}; + if (waveFile == nullptr) + return nullptr; + + return waveFile; +} + } // namespace nn::atk::detail \ No newline at end of file From a26823ecbd8e733b4f1f99aafe784ba641ddeb5b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 11:15:35 -0300 Subject: [PATCH 549/785] atk: Match `BankFileReader` constructor --- include/nn/atk/atk_BankFileReader.h | 56 +++++++------ include/nn/atk/atk_Global.h | 56 ++++++------- include/nn/atk/atk_StreamSoundFileReader.h | 34 ++++---- .../atk/detail/seq/atk_BankFileReader.cpp | 7 ++ .../detail/strm/atk_StreamSoundFileReader.cpp | 79 ++++++++++--------- 5 files changed, 127 insertions(+), 105 deletions(-) diff --git a/include/nn/atk/atk_BankFileReader.h b/include/nn/atk/atk_BankFileReader.h index 029c6dbc..489dec65 100644 --- a/include/nn/atk/atk_BankFileReader.h +++ b/include/nn/atk/atk_BankFileReader.h @@ -3,23 +3,26 @@ #include namespace nn::atk::detail { +struct VelocityRegionInfo { + u32 waveArchiveId; + u32 waveIndex; + float pitch; + AdshrCurve adshrCurve; + u8 originalKey; + u8 volume; + u8 pan; + bool isIgnoreNoteOff; + u8 keyGroup; + u8 interpolationType; + + VelocityRegionInfo() + : adshrCurve(0, 0, 0, 0, 0) {}; +}; +static_assert(sizeof(VelocityRegionInfo) == 0x18); + class BankFileReader { public: - constexpr static s32 SignatureFile = 0x4b4e4246; // FBNK - - struct VelocityRegionInfo { - u32 waveArchiveId; - u32 waveIndex; - f32 pitch; - AdshrCurve adshrCurve; - u8 originalKey; - u8 volume; - u8 pan; - bool isIgnoreNoteOff; - u8 keyGroup; - u8 interpolationType; - }; - static_assert(sizeof(VelocityRegionInfo) == 0x18); + static const u32 SignatureFile{0x4b4e4246}; // FBNK BankFileReader(); explicit BankFileReader(const void* bankFile); @@ -27,15 +30,22 @@ class BankFileReader { void Initialize(const void* bankFile); void Finalize(); - bool ReadVelocityRegionInfo(VelocityRegionInfo* info, s32 programNo, - s32 key, s32 velocity) const; - - Util::WaveIdTable* GetWaveIdTable() const; + bool IsInitialized() const { return m_IsInitialized; } + + bool ReadVelocityRegionInfo(VelocityRegionInfo* info, int programNo, int key, + int velocity) const; + + const Util::WaveIdTable* GetWaveIdTable() const; + + const void* GetBankFileAddress() const { return m_pHeader; } + + int GetInstrumentCount() { return m_pInfoBlockBody->GetInstrumentCount(); } + private: - BankFile::FileHeader* m_pHeader; - BankFile::InfoBlockBody* m_pInfoBlockBody; - bool m_IsInitialized; + const BankFile::FileHeader* m_pHeader{}; + const BankFile::InfoBlockBody* m_pInfoBlockBody{}; + bool m_IsInitialized{false}; }; static_assert(sizeof(BankFileReader) == 0x18); -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h index 8d33ce33..47edb34a 100644 --- a/include/nn/atk/atk_Global.h +++ b/include/nn/atk/atk_Global.h @@ -4,6 +4,7 @@ #include namespace nn::atk { + enum WaveType { WaveType_Invalid = -1, WaveType_Nwwav, @@ -150,26 +151,26 @@ enum FsPriority { class AdshrCurve { public: AdshrCurve(u8 a, u8 d, u8 s, u8 h, u8 r) - : m_Attack{a}, m_Decay{d}, m_Sustain{s}, m_Hold{h}, m_Release{r} {} + : m_Attack{a}, m_Decay{d}, m_Sustain{s}, m_Hold{h}, m_Release{r} {} u8 GetAttack() const { return m_Attack; } void SetAttack(u8 attack) { m_Attack = attack; } u8 GetDecay() const { return m_Decay; } - + void SetDecay(u8 decay) { m_Decay = decay; } u8 GetSustain() const { return m_Sustain; } - + void SetSustain(u8 sustain) { m_Sustain = sustain; } u8 GetHold() const { return m_Hold; } - + void SetHold(u8 hold) { m_Hold = hold; } u8 GetRelease() const { return m_Release; } - + void SetRelease(u8 release) { m_Release = release; } private: @@ -182,11 +183,11 @@ class AdshrCurve { static_assert(sizeof(AdshrCurve) == 0x5); struct BiquadFilterCoefficients { - s16 b0 {0}; - s16 b1 {0}; - s16 b2 {0}; - s16 a1 {0}; - s16 a2 {0}; + s16 b0{0}; + s16 b1{0}; + s16 b2{0}; + s16 a1{0}; + s16 a2{0}; }; static_assert(sizeof(BiquadFilterCoefficients) == 0xa); @@ -331,7 +332,7 @@ enum SinglePlayType { SinglePlayType_PrioritizeOldest, SinglePlayType_PrioritizeOldestEffectiveDuration, SinglePlayType_PrioritizeOldestWithDuration = SinglePlayType_PrioritizeOldestEffectiveDuration, - + SinglePlayType_PrioritizeNewest, SinglePlayType_PrioritizeNewestEffectiveDuration, SinglePlayType_PrioritizeNewestWithDuration = SinglePlayType_PrioritizeNewestEffectiveDuration, @@ -412,14 +413,14 @@ class VoiceParam { void Initialize(); private: - float m_Volume {0}; - float m_Pitch {0}; - OutputMix m_TvMix {}; - bool m_MonoFilterFlag {false}; - bool m_BiquadFilterFlag {false}; - BiquadFilterCoefficients m_BiquadFilterCoefficients {}; - u16 m_MonoFilterCutoff {0}; - u8 m_InterpolationType {0}; + float m_Volume{0}; + float m_Pitch{0}; + OutputMix m_TvMix{}; + bool m_MonoFilterFlag{false}; + bool m_BiquadFilterFlag{false}; + BiquadFilterCoefficients m_BiquadFilterCoefficients{}; + u16 m_MonoFilterCutoff{0}; + u8 m_InterpolationType{0}; }; static_assert(sizeof(VoiceParam) == 0x78); @@ -444,13 +445,12 @@ struct WaveInfo { }; static_assert(sizeof(WaveInfo) == 0xa0); -static const OutputMix DefaultTvMix{{1.0, 1.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}; -} // namespace nn::atk::detail +static const OutputMix DefaultTvMix{{1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}; +} // namespace detail + +using SoundFrameUserCallback = void (*)(std::uintptr_t); +using SoundThreadUserCallback = void (*)(std::uintptr_t); +using SoundStopCallback = void (*)(); -using SoundFrameUserCallback = void(*)(std::uintptr_t); -using SoundThreadUserCallback = void(*)(std::uintptr_t); -using SoundStopCallback = void(*)(); -} // namespace nn::atk \ No newline at end of file +} // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/atk_StreamSoundFileReader.h b/include/nn/atk/atk_StreamSoundFileReader.h index e7e82175..f5f69ae2 100644 --- a/include/nn/atk/atk_StreamSoundFileReader.h +++ b/include/nn/atk/atk_StreamSoundFileReader.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail { + class StreamSoundFileReader { public: struct TrackInfo { @@ -21,9 +22,7 @@ class StreamSoundFileReader { void Initialize(const void* streamSoundFile); void Finalize(); - bool IsAvailable() const { - return m_pHeader != nullptr; - } + bool IsAvailable() const { return m_pHeader != nullptr; } bool IsTrackInfoAvailable() const; bool IsOriginalLoopAvailable() const; @@ -43,28 +42,30 @@ class StreamSoundFileReader { u32 GetSeekBlockOffset() const { if (m_pHeader != nullptr && m_pHeader->HasSeekBlock()) return m_pHeader->GetSeekBlockOffset(); - + return 0; } u32 GetSampleDataOffset() const { - u32 result {0}; + u32 result{0}; + if (m_pHeader != nullptr) - result = m_pHeader->GetDataBlockOffset() - + m_pInfoBlockBody->GetStreamSoundInfo()->sampleDataOffset.offset - + sizeof(BinaryBlockHeader); + result = m_pHeader->GetDataBlockOffset() + + m_pInfoBlockBody->GetStreamSoundInfo()->sampleDataOffset.offset + + sizeof(BinaryBlockHeader); return result; } u32 GetRegionDataOffset() const { - u32 result {0}; + u32 result{0}; + if (m_pHeader != nullptr && m_pHeader->HasRegionBlock()) { - result = m_pHeader->GetRegionBlockOffset() - + m_pInfoBlockBody->GetStreamSoundInfo()->regionDataOffset.offset - + sizeof(BinaryBlockHeader); + result = m_pHeader->GetRegionBlockOffset() + + m_pInfoBlockBody->GetStreamSoundInfo()->regionDataOffset.offset + + sizeof(BinaryBlockHeader); } - + return result; } @@ -75,8 +76,9 @@ class StreamSoundFileReader { static bool IsOriginalLoopAvailableImpl(const StreamSoundFile::FileHeader* pHeader); private: - const StreamSoundFile::FileHeader* m_pHeader {}; - const StreamSoundFile::InfoBlockBody* m_pInfoBlockBody {}; + const StreamSoundFile::FileHeader* m_pHeader{}; + const StreamSoundFile::InfoBlockBody* m_pInfoBlockBody{}; }; static_assert(sizeof(StreamSoundFileReader) == 0x10); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp index e69de29b..cbf800ff 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp @@ -0,0 +1,7 @@ +#include + +namespace nn::atk::detail { + +BankFileReader::BankFileReader() = default; + +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp index 15a08568..c48d7cca 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp @@ -1,26 +1,27 @@ #include namespace nn::atk::detail { -const u32 SignatureFileStm {0x4d545346}; // FSTM -const u32 SignatureInfoBlockStm {0x4f464e49}; // INFO -const u32 SupportedFileVersionStm {0x10000}; -const u32 CurrentFileVersionStm {0x60200}; +const u32 SignatureFileStm{0x4d545346}; // FSTM +const u32 SignatureInfoBlockStm{0x4f464e49}; // INFO -const u32 IncludeTrackinfoVersionStm {0x20000}; -const u32 IncludeOriginalloopVersionStm {0x40000}; -const u32 IncludeCrc32CheckVersionStm {0x50000}; -const u32 IncludeRegionIndexCheckVersionStm {0x60100}; +const u32 SupportedFileVersionStm{0x10000}; +const u32 CurrentFileVersionStm{0x60200}; + +const u32 IncludeTrackinfoVersionStm{0x20000}; +const u32 IncludeOriginalloopVersionStm{0x40000}; +const u32 IncludeCrc32CheckVersionStm{0x50000}; +const u32 IncludeRegionIndexCheckVersionStm{0x60100}; StreamSoundFileReader::StreamSoundFileReader() = default; bool StreamSoundFileReader::IsValidFileHeader(const void* streamSoundFile) { - const BinaryFileHeader& header {*util::ConstBytePtr(streamSoundFile).Get()}; - - bool isSupportedVersion {header.signature == SignatureFileStm - && header.byteOrder == BinaryFileHeader::ValidByteOrderMark - && header.version >= SupportedFileVersionStm - && header.version <= CurrentFileVersionStm}; + const BinaryFileHeader& header{*util::ConstBytePtr(streamSoundFile).Get()}; + + bool isSupportedVersion{header.signature == SignatureFileStm && + header.byteOrder == BinaryFileHeader::ValidByteOrderMark && + header.version >= SupportedFileVersionStm && + header.version <= CurrentFileVersionStm}; return isSupportedVersion; } @@ -28,19 +29,19 @@ bool StreamSoundFileReader::IsValidFileHeader(const void* streamSoundFile) { void StreamSoundFileReader::Initialize(const void* streamSoundFile) { if (IsValidFileHeader(streamSoundFile)) { m_pHeader = util::ConstBytePtr(streamSoundFile).Get(); - const StreamSoundFile::InfoBlock* infoBlock {m_pHeader->GetInfoBlock()}; + const StreamSoundFile::InfoBlock* infoBlock{m_pHeader->GetInfoBlock()}; if (infoBlock->header.kind == SignatureInfoBlockStm) m_pInfoBlockBody = &infoBlock->body; } } -void StreamSoundFileReader::Finalize() { +void StreamSoundFileReader::Finalize() { m_pHeader = nullptr; m_pInfoBlockBody = nullptr; } bool StreamSoundFileReader::IsTrackInfoAvailable() const { - auto& header {*util::ConstBytePtr(m_pHeader).Get()}; + auto& header{*util::ConstBytePtr(m_pHeader).Get()}; return header.version <= IncludeTrackinfoVersionStm; } @@ -49,24 +50,25 @@ bool StreamSoundFileReader::IsOriginalLoopAvailable() const { return IsOriginalLoopAvailableImpl(m_pHeader); } -bool StreamSoundFileReader::IsOriginalLoopAvailableImpl(const StreamSoundFile::FileHeader* pHeader) { +bool StreamSoundFileReader::IsOriginalLoopAvailableImpl( + const StreamSoundFile::FileHeader* pHeader) { return pHeader->version >= IncludeOriginalloopVersionStm; } bool StreamSoundFileReader::IsCrc32CheckAvailable() const { - auto& header {*util::ConstBytePtr(m_pHeader).Get()}; + auto& header{*util::ConstBytePtr(m_pHeader).Get()}; return header.version >= IncludeCrc32CheckVersionStm; } bool StreamSoundFileReader::IsRegionIndexCheckAvailable() const { - auto& header {*util::ConstBytePtr(m_pHeader).Get()}; + auto& header{*util::ConstBytePtr(m_pHeader).Get()}; return header.version >= IncludeRegionIndexCheckVersionStm; } bool StreamSoundFileReader::ReadStreamSoundInfo(StreamSoundFile::StreamSoundInfo* strmInfo) const { - auto* info {m_pInfoBlockBody->GetStreamSoundInfo()}; + auto* info{m_pInfoBlockBody->GetStreamSoundInfo()}; strmInfo->encodeMethod = info->encodeMethod; strmInfo->isLoop = info->isLoop; @@ -86,41 +88,38 @@ bool StreamSoundFileReader::ReadStreamSoundInfo(StreamSoundFile::StreamSoundInfo strmInfo->sampleDataOffset = info->sampleDataOffset; strmInfo->regionInfoBytes = info->regionInfoBytes; strmInfo->regionDataOffset = info->regionDataOffset; - + if (IsOriginalLoopAvailable()) { strmInfo->originalLoopStart = info->originalLoopStart; strmInfo->originalLoopEnd = info->originalLoopEnd; - } - else { + } else { strmInfo->originalLoopStart = info->loopStart; strmInfo->originalLoopEnd = info->frameCount; } - - if (IsCrc32CheckAvailable()) { + + if (IsCrc32CheckAvailable()) strmInfo->crc32Value = info->crc32Value; - } - else { + else strmInfo->crc32Value = 0; - } return true; } bool StreamSoundFileReader::ReadStreamTrackInfo(TrackInfo* pTrackInfo, int trackIndex) const { - auto* table {m_pInfoBlockBody->GetTrackInfoTable()}; + auto* table{m_pInfoBlockBody->GetTrackInfoTable()}; if (table != nullptr && trackIndex < static_cast(table->GetTrackCount())) { - auto* src {table->GetTrackInfo(trackIndex)}; + auto* src{table->GetTrackInfo(trackIndex)}; pTrackInfo->volume = src->volume; pTrackInfo->pan = src->pan; pTrackInfo->span = src->span; pTrackInfo->flags = src->flags; pTrackInfo->channelCount = src->GetTrackChannelCount(); - - u32 count {pTrackInfo->channelCount}; + + u32 count{pTrackInfo->channelCount}; if (count > 1) count = 2; - - for (u32 i {0}; i < count; ++i) + + for (u32 i{0}; i < count; ++i) pTrackInfo->globalChannelIndex[i] = src->GetGlobalChannelIndex(i); return true; @@ -129,9 +128,12 @@ bool StreamSoundFileReader::ReadStreamTrackInfo(TrackInfo* pTrackInfo, int track return false; } -bool StreamSoundFileReader::ReadDspAdpcmChannelInfo(DspAdpcmParam* pParam, DspAdpcmLoopParam* pLoopParam, +bool StreamSoundFileReader::ReadDspAdpcmChannelInfo(DspAdpcmParam* pParam, + DspAdpcmLoopParam* pLoopParam, int channelIndex) const { - auto* src {m_pInfoBlockBody->GetChannelInfoTable()->GetChannelInfo(channelIndex)->GetDspAdpcmChannelInfo()}; + auto* src{m_pInfoBlockBody->GetChannelInfoTable() + ->GetChannelInfo(channelIndex) + ->GetDspAdpcmChannelInfo()}; if (src != nullptr) { *pParam = src->param; *pLoopParam = src->loopParam; @@ -140,4 +142,5 @@ bool StreamSoundFileReader::ReadDspAdpcmChannelInfo(DspAdpcmParam* pParam, DspAd return false; } -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail \ No newline at end of file From 703bec42253243b42c9a8997c7a1b46a47c6765e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 11:25:35 -0300 Subject: [PATCH 550/785] atk: Match `BankFileReader::Initialize` --- .../atk/detail/seq/atk_BankFileReader.cpp | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp index cbf800ff..712eaee1 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp @@ -2,6 +2,38 @@ namespace nn::atk::detail { +namespace { +const u32 SignatureInfoBlockBank{0x4f464e49}; // INFO + +const u32 SupportedFileVersionBank{0x10000}; +const u32 CurrentFileVersionBank{0x10000}; + +bool IsValidFileHeaderBank(const void* bankFile) { + const BinaryFileHeader* header{util::ConstBytePtr(bankFile).Get()}; + + bool isSupportedVersion{header->signature == BankFileReader::SignatureFile && + header->byteOrder == BinaryFileHeader::ValidByteOrderMark && + header->version >= SupportedFileVersionBank && + header->version <= CurrentFileVersionBank}; + + return isSupportedVersion; +} +} // anonymous namespace + BankFileReader::BankFileReader() = default; +void BankFileReader::Initialize(const void* bankFile) { + if (bankFile == nullptr || !IsValidFileHeaderBank(bankFile)) + return; + + m_pHeader = reinterpret_cast(bankFile); + + const BankFile::InfoBlock* infoBlock{m_pHeader->GetInfoBlock()}; + + if (infoBlock->header.kind == SignatureInfoBlockBank) { + m_pInfoBlockBody = &infoBlock->body; + m_IsInitialized = true; + } +} + } // namespace nn::atk::detail \ No newline at end of file From e609f9541a3ea4ebd6c32f4ebcca36f5a1fbb4c2 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 11:26:16 -0300 Subject: [PATCH 551/785] atk: Match `BankFileReader` constructor 2 --- src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp index 712eaee1..33c8bc58 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp @@ -22,6 +22,10 @@ bool IsValidFileHeaderBank(const void* bankFile) { BankFileReader::BankFileReader() = default; +BankFileReader::BankFileReader(const void* bankFile) { + Initialize(bankFile); +} + void BankFileReader::Initialize(const void* bankFile) { if (bankFile == nullptr || !IsValidFileHeaderBank(bankFile)) return; From 546de36611594f4a0eea103797057e98928843b1 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 11:27:22 -0300 Subject: [PATCH 552/785] atk: Match `BankFileReader::Finalize` --- src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp index 33c8bc58..4310052c 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp @@ -40,4 +40,12 @@ void BankFileReader::Initialize(const void* bankFile) { } } +void BankFileReader::Finalize() { + if (m_IsInitialized) { + m_IsInitialized = false; + m_pHeader = nullptr; + m_pInfoBlockBody = nullptr; + } +} + } // namespace nn::atk::detail \ No newline at end of file From bd1438aeb494277123e7f16fcb460718e846535d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 11:45:26 -0300 Subject: [PATCH 553/785] atk: Match `BankFileReader::ReadVelocityRegionInfo` --- include/nn/atk/atk_BankFileReader.h | 2 +- include/nn/atk/atk_Util.h | 7 ++- .../atk/detail/seq/atk_BankFileReader.cpp | 49 +++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_BankFileReader.h b/include/nn/atk/atk_BankFileReader.h index 489dec65..e683085a 100644 --- a/include/nn/atk/atk_BankFileReader.h +++ b/include/nn/atk/atk_BankFileReader.h @@ -39,7 +39,7 @@ class BankFileReader { const void* GetBankFileAddress() const { return m_pHeader; } - int GetInstrumentCount() { return m_pInfoBlockBody->GetInstrumentCount(); } + int GetInstrumentCount() const { return m_pInfoBlockBody->GetInstrumentCount(); } private: diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index 4206d681..317e9121 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -261,7 +261,12 @@ class Util { struct WaveIdTable { Table table; - const WaveId* GetWaveId(u32 index) const { return &table.item[index]; } + const WaveId* GetWaveId(u32 index) const { + if (index < table.count) + return &table.item[index]; + + return nullptr; + } u32 GetCount() const { return table.count; } }; diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp index 4310052c..8f9a9398 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp @@ -48,4 +48,53 @@ void BankFileReader::Finalize() { } } +bool BankFileReader::ReadVelocityRegionInfo(VelocityRegionInfo* info, int programNo, int key, + int velocity) const { + if (!m_IsInitialized || programNo < 0 || programNo >= GetInstrumentCount()) + return false; + + const BankFile::Instrument* instrument{m_pInfoBlockBody->GetInstrument(programNo)}; + if (instrument == nullptr) + return false; + + const BankFile::KeyRegion* keyRegion{instrument->GetKeyRegion(key)}; + if (keyRegion == nullptr) + return false; + + const BankFile::VelocityRegion* velocityRegion{keyRegion->GetVelocityRegion(velocity)}; + if (velocityRegion == nullptr) + return false; + + const Util::WaveId* pWaveId{m_pInfoBlockBody->GetWaveId(velocityRegion->waveIdTableIndex)}; + if (pWaveId == nullptr || pWaveId->waveIndex == 0xffffffff) + return false; + + info->waveArchiveId = pWaveId->waveArchiveId; + info->waveIndex = pWaveId->waveIndex; + + const BankFile::RegionParameter* regionParameter{velocityRegion->GetRegionParameter()}; + if (regionParameter == nullptr) { + info->originalKey = velocityRegion->GetOriginalKey(); + info->volume = velocityRegion->GetVolume(); + info->pan = velocityRegion->GetPan(); + info->pitch = velocityRegion->GetPitch(); + info->isIgnoreNoteOff = velocityRegion->IsIgnoreNoteOff(); + info->keyGroup = velocityRegion->GetKeyGroup(); + info->interpolationType = velocityRegion->GetInterpolationType(); + info->adshrCurve = velocityRegion->GetAdshrCurve(); + } + else { + info->originalKey = regionParameter->originalKey; + info->volume = regionParameter->volume; + info->pan = regionParameter->pan; + info->pitch = regionParameter->pitch; + info->isIgnoreNoteOff = regionParameter->isIgnoreNoteOff; + info->keyGroup = regionParameter->keyGroup; + info->interpolationType = regionParameter->interpolationType; + info->adshrCurve = regionParameter->adshrCurve; + } + + return true; +} + } // namespace nn::atk::detail \ No newline at end of file From e7d1c243ccd7d70e8fa33b862831f99919a1223a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 11:56:32 -0300 Subject: [PATCH 554/785] atk: Match `BankFileReader::GetWaveIdTable` --- include/nn/atk/atk_BankFileReader.h | 6 +++--- .../atk/detail/seq/atk_BankFileReader.cpp | 14 ++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/nn/atk/atk_BankFileReader.h b/include/nn/atk/atk_BankFileReader.h index e683085a..309a28a9 100644 --- a/include/nn/atk/atk_BankFileReader.h +++ b/include/nn/atk/atk_BankFileReader.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail { + struct VelocityRegionInfo { u32 waveArchiveId; u32 waveIndex; @@ -15,8 +16,7 @@ struct VelocityRegionInfo { u8 keyGroup; u8 interpolationType; - VelocityRegionInfo() - : adshrCurve(0, 0, 0, 0, 0) {}; + VelocityRegionInfo() : adshrCurve(0, 0, 0, 0, 0) {}; }; static_assert(sizeof(VelocityRegionInfo) == 0x18); @@ -41,11 +41,11 @@ class BankFileReader { int GetInstrumentCount() const { return m_pInfoBlockBody->GetInstrumentCount(); } - private: const BankFile::FileHeader* m_pHeader{}; const BankFile::InfoBlockBody* m_pInfoBlockBody{}; bool m_IsInitialized{false}; }; static_assert(sizeof(BankFileReader) == 0x18); + } // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp index 8f9a9398..2032d4ea 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp @@ -52,7 +52,7 @@ bool BankFileReader::ReadVelocityRegionInfo(VelocityRegionInfo* info, int progra int velocity) const { if (!m_IsInitialized || programNo < 0 || programNo >= GetInstrumentCount()) return false; - + const BankFile::Instrument* instrument{m_pInfoBlockBody->GetInstrument(programNo)}; if (instrument == nullptr) return false; @@ -82,8 +82,7 @@ bool BankFileReader::ReadVelocityRegionInfo(VelocityRegionInfo* info, int progra info->keyGroup = velocityRegion->GetKeyGroup(); info->interpolationType = velocityRegion->GetInterpolationType(); info->adshrCurve = velocityRegion->GetAdshrCurve(); - } - else { + } else { info->originalKey = regionParameter->originalKey; info->volume = regionParameter->volume; info->pan = regionParameter->pan; @@ -93,8 +92,15 @@ bool BankFileReader::ReadVelocityRegionInfo(VelocityRegionInfo* info, int progra info->interpolationType = regionParameter->interpolationType; info->adshrCurve = regionParameter->adshrCurve; } - + return true; } +const Util::WaveIdTable* BankFileReader::GetWaveIdTable() const { + if (!m_IsInitialized) + return nullptr; + + return &m_pInfoBlockBody->GetWaveIdTable(); +} + } // namespace nn::atk::detail \ No newline at end of file From aec77ccc53f17f67775d7831746b1011a3118c6c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 12:18:17 -0300 Subject: [PATCH 555/785] atk: Match `SequenceSoundFileReader` constructor --- include/nn/atk/atk_SequenceSoundFileReader.h | 22 +++++++--- .../seq/atk_SequenceSoundFileReader.cpp | 44 +++++++++++++++++++ 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/include/nn/atk/atk_SequenceSoundFileReader.h b/include/nn/atk/atk_SequenceSoundFileReader.h index 50f65850..304583cd 100644 --- a/include/nn/atk/atk_SequenceSoundFileReader.h +++ b/include/nn/atk/atk_SequenceSoundFileReader.h @@ -3,21 +3,29 @@ #include namespace nn::atk::detail { + class SequenceSoundFileReader { public: - constexpr static s32 SignatureFile = 0x51455346; // FSEQ + static const u32 SignatureFile{0x51455346}; // FSEQ + + explicit SequenceSoundFileReader(const void* sequenceFile); - explicit SequenceSoundFileReader(void* sequenceFile); + bool IsAvailable() const { return m_pHeader != nullptr; } - void* GetSequenceData(); + const void* GetSequenceData(); bool GetOffsetByLabel(const char* label, u32* offsetPtr) const; bool GetLabelByOffset(u32 offset) const; + int GetLabelCount() const { return m_pLabelBlockBody->GetLabelCount(); } + + const char* GetLabel(int index) const { return m_pLabelBlockBody->GetLabel(index); } + private: - SequenceSoundFile::FileHeader* m_pHeader; - SequenceSoundFile::DataBlockBody* m_pDataBlockBody; - SequenceSoundFile::LabelBlockBody* m_pLabelBlockBody; + const SequenceSoundFile::FileHeader* m_pHeader{}; + const SequenceSoundFile::DataBlockBody* m_pDataBlockBody{}; + const SequenceSoundFile::LabelBlockBody* m_pLabelBlockBody{}; }; static_assert(sizeof(SequenceSoundFileReader) == 0x18); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp index e69de29b..4ecd82ca 100644 --- a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp @@ -0,0 +1,44 @@ +#include + +namespace nn::atk::detail { + +namespace { + +const u32 SignatureDataBlockSeq{0x41544144}; // DATA +const u32 SignatureLabelBlockSeq{0x4c42414c}; // LABL + +const u32 SupportedFileVersionSeq{0x10000}; +const u32 CurrentFileVersionSeq{0x20000}; + +bool IsValidFileHeaderSeq(const void* sequenceFile) { + const BinaryFileHeader* header{util::ConstBytePtr(sequenceFile).Get()}; + + bool isSupportedVersion{header->signature == SequenceSoundFileReader::SignatureFile && + header->byteOrder == BinaryFileHeader::ValidByteOrderMark && + header->version >= SupportedFileVersionSeq && + header->version <= CurrentFileVersionSeq}; + + return isSupportedVersion; +} + +} // anonymous namespace + +SequenceSoundFileReader::SequenceSoundFileReader(const void* sequenceFile) { + if (!IsValidFileHeaderSeq(sequenceFile)) + return; + + m_pHeader = reinterpret_cast(sequenceFile); + + const SequenceSoundFile::DataBlock* dataBlock{m_pHeader->GetDataBlock()}; + if (dataBlock->header.kind != SignatureDataBlockSeq) + return; + + const SequenceSoundFile::LabelBlock* labelBlock{m_pHeader->GetLabelBlock()}; + if (labelBlock->header.kind != SignatureLabelBlockSeq) + return; + + m_pDataBlockBody = &dataBlock->body; + m_pLabelBlockBody = &labelBlock->body; +} + +} // namespace nn::atk::detail \ No newline at end of file From e98acd51700e036534b7594199ecedff63e2f86e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 12:19:51 -0300 Subject: [PATCH 556/785] atk: Match `SequenceSoundFileReader::GetSequenceData` --- include/nn/atk/atk_SequenceSoundFileReader.h | 2 +- .../atk/detail/seq/atk_SequenceSoundFileReader.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_SequenceSoundFileReader.h b/include/nn/atk/atk_SequenceSoundFileReader.h index 304583cd..74edd3c7 100644 --- a/include/nn/atk/atk_SequenceSoundFileReader.h +++ b/include/nn/atk/atk_SequenceSoundFileReader.h @@ -12,7 +12,7 @@ class SequenceSoundFileReader { bool IsAvailable() const { return m_pHeader != nullptr; } - const void* GetSequenceData(); + const void* GetSequenceData() const; bool GetOffsetByLabel(const char* label, u32* offsetPtr) const; bool GetLabelByOffset(u32 offset) const; diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp index 4ecd82ca..fa115933 100644 --- a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp @@ -41,4 +41,8 @@ SequenceSoundFileReader::SequenceSoundFileReader(const void* sequenceFile) { m_pLabelBlockBody = &labelBlock->body; } +const void* SequenceSoundFileReader::GetSequenceData() const { + return m_pDataBlockBody; +} + } // namespace nn::atk::detail \ No newline at end of file From df06ae68bddfc638ccac63c267873232393457c7 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 12:21:09 -0300 Subject: [PATCH 557/785] atk: Match `SequenceSoundFileReader::GetOffsetByLabel` --- .../atk/detail/seq/atk_SequenceSoundFileReader.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp index fa115933..e53b4efa 100644 --- a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp @@ -45,4 +45,8 @@ const void* SequenceSoundFileReader::GetSequenceData() const { return m_pDataBlockBody; } +bool SequenceSoundFileReader::GetOffsetByLabel(const char* label, u32* offsetPtr) const { + return m_pLabelBlockBody->GetOffsetByLabel(label, offsetPtr); +} + } // namespace nn::atk::detail \ No newline at end of file From a63fb07ab9ce74c5bec8685bd5430211baabf98a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 12:25:58 -0300 Subject: [PATCH 558/785] atk: Match `SequenceSoundFileReader::GetLabelByOffset` --- include/nn/atk/atk_SequenceSoundFileReader.h | 2 +- .../atk/detail/seq/atk_SequenceSoundFileReader.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_SequenceSoundFileReader.h b/include/nn/atk/atk_SequenceSoundFileReader.h index 74edd3c7..57bc379a 100644 --- a/include/nn/atk/atk_SequenceSoundFileReader.h +++ b/include/nn/atk/atk_SequenceSoundFileReader.h @@ -15,7 +15,7 @@ class SequenceSoundFileReader { const void* GetSequenceData() const; bool GetOffsetByLabel(const char* label, u32* offsetPtr) const; - bool GetLabelByOffset(u32 offset) const; + const char* GetLabelByOffset(u32 offset) const; int GetLabelCount() const { return m_pLabelBlockBody->GetLabelCount(); } diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp index e53b4efa..ac68dec9 100644 --- a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp @@ -49,4 +49,8 @@ bool SequenceSoundFileReader::GetOffsetByLabel(const char* label, u32* offsetPtr return m_pLabelBlockBody->GetOffsetByLabel(label, offsetPtr); } +const char* SequenceSoundFileReader::GetLabelByOffset(u32 offset) const { + return m_pLabelBlockBody->GetLabelByOffset(offset); +} + } // namespace nn::atk::detail \ No newline at end of file From a5b9abf7c41c62cd0104622eb4eb73fb99fd7a6a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 15:27:45 -0300 Subject: [PATCH 559/785] atk: Match `SequenceTrack` constructor --- include/nn/atk/atk_CurveLfo.h | 2 +- include/nn/atk/atk_Global.h | 27 ++- include/nn/atk/atk_MoveValue.h | 12 +- include/nn/atk/atk_SequenceTrack.h | 167 +++++++++++------- .../atk/detail/seq/atk_BankFileReader.cpp | 2 + .../atk/detail/seq/atk_SequenceTrack.cpp | 10 ++ 6 files changed, 144 insertions(+), 76 deletions(-) diff --git a/include/nn/atk/atk_CurveLfo.h b/include/nn/atk/atk_CurveLfo.h index 42d26daf..96e652da 100644 --- a/include/nn/atk/atk_CurveLfo.h +++ b/include/nn/atk/atk_CurveLfo.h @@ -29,7 +29,7 @@ struct CurveLfoParam { CurveType_Count, }; - CurveLfoParam() = default; + CurveLfoParam() { Initialize(); }; void Initialize(); }; diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h index 47edb34a..572b4bf1 100644 --- a/include/nn/atk/atk_Global.h +++ b/include/nn/atk/atk_Global.h @@ -216,8 +216,14 @@ struct MixParameter { f32 fC; f32 lfe; }; - float ch[6]; + float ch[ChannelIndex_Count]; }; + + // why does this work + MixParameter() { fL = fR = rL = rR = fC = lfe = 1.0f; } + + MixParameter(float _fL, float _fR, float _rL, float _rR, float _fC, float _lfe) + : fL{_fL}, fR{_fR}, rL{_rL}, rR{_rR}, fC{_fC}, lfe{_lfe} {} }; static_assert(sizeof(MixParameter) == 0x18); @@ -231,7 +237,7 @@ struct MixVolume { f32 frontCenter; f32 lowFrequencyEffect; }; - float channel[6]; + float channel[ChannelIndex_Count]; }; }; static_assert(sizeof(MixVolume) == 0x18); @@ -277,7 +283,7 @@ enum OutputMode { struct OutputMix { OutputMix() = default; - f32 channelGain[24] = {0}; + f32 channelGain[24]{0}; }; static_assert(sizeof(OutputMix) == 0x60); @@ -350,6 +356,7 @@ enum VolumeThroughModeBitFlag { }; namespace detail { + enum DecodeMode { DecodeMode_Invalid = -1, DecodeMode_Default, @@ -375,7 +382,18 @@ struct OutputParam { MixParameter mixParameter[2]; float pan; float span; - float send[4]; + float send[AuxBus_Count + 1]; + + void Initialize() { + volume = 1.0f; + mixMode = MixMode_Pan; + pan = 0.0f; + span = 0.0f; + for (int i{0}; i < 4; ++i) + send[i] = 0.0f; + } + + OutputParam() = default; }; static_assert(sizeof(OutputParam) == 0x50); @@ -447,6 +465,7 @@ static_assert(sizeof(WaveInfo) == 0xa0); static const OutputMix DefaultTvMix{{1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}; + } // namespace detail using SoundFrameUserCallback = void (*)(std::uintptr_t); diff --git a/include/nn/atk/atk_MoveValue.h b/include/nn/atk/atk_MoveValue.h index 5543f244..7ded9061 100644 --- a/include/nn/atk/atk_MoveValue.h +++ b/include/nn/atk/atk_MoveValue.h @@ -1,6 +1,7 @@ #pragma once namespace nn::atk::detail { + template class MoveValue { public: @@ -25,9 +26,10 @@ class MoveValue { CountType GetRemainingCount() const; private: - ValueType m_Origin {}; - ValueType m_Target {}; - CountType m_Frame {}; - CountType m_Counter {}; + ValueType m_Origin{0}; + ValueType m_Target{0}; + CountType m_Frame{0}; + CountType m_Counter{0}; }; -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail \ No newline at end of file diff --git a/include/nn/atk/atk_SequenceTrack.h b/include/nn/atk/atk_SequenceTrack.h index 6be8d991..5bcd0f55 100644 --- a/include/nn/atk/atk_SequenceTrack.h +++ b/include/nn/atk/atk_SequenceTrack.h @@ -1,45 +1,28 @@ #pragma once #include +#include +#include namespace nn::atk::detail::driver { + class SequenceSoundPlayer; class SequenceTrack { public: - enum ParseResult { - ParseResult_Continue, - ParseResult_Finish, - }; - - constexpr static u32 CallStackDepth = 10; - - constexpr static u32 DefaultPriority = 64; - constexpr static u32 DefaultBendRange = 2; - constexpr static u32 DefaultPortaKey = 60; - - constexpr static s32 InvalidEnvelope = 255; - constexpr static s32 MaxEnvelopeValue = 127; - - constexpr static s32 ParserParamSize = 32; - - constexpr static s32 TrackVariableCount = 16; - - constexpr static s32 PauseReleaseValue = 16; - constexpr static s32 MuteReleaseValue = 127; - + static const int CallStackDepth{10}; struct ParserTrackParam { struct CallStack { u8 loopFlag; u8 loopCount; u8 padding[2]; - u8* address; + const u8* address; }; static_assert(sizeof(CallStack) == 0x10); - u8* baseAddr; - u8* currentAddr; + const u8* baseAddr; + const u8* currentAddr; bool cmpFlag; bool noteWaitFlag; bool tieFlag; @@ -54,15 +37,15 @@ class SequenceTrack { bool portaFlag; bool damperFlag; u8 bankIndex; - s32 prgNo; - f32 sweepPitch; + int prgNo; + float sweepPitch; MoveValue volume; MoveValue volume2; MoveValue pan; MoveValue surroundPan; MoveValue pitchBend; - CurveLfoParam lfoParam[4]; - u8 lfoTarget[4]; + CurveLfoParam lfoParam[Channel::ModCount]{}; + u8 lfoTarget[Channel::ModCount]; u8 velocityRange; u8 bendRange; s8 initPan; @@ -78,78 +61,130 @@ class SequenceTrack { s16 envHold; s8 biquadType; u8 mainSend; - u8 fxSend[3]; + u8 fxSend[AuxBus_Count]; u8 padding2[1]; - f32 lpfFreq; - f32 biquadValue; - s32 outputLine; + float lpfFreq; + float biquadValue; + s32 outputLine; + + ParserTrackParam() = default; }; - static_assert(sizeof(ParserTrackParam) == 0x150); + static_assert(sizeof(ParserTrackParam) == 0x150); - virtual ~SequenceTrack(); - virtual ParseResult Parse(bool doNoteOn) = 0; + enum ParseResult { + ParseResult_Continue, + ParseResult_Finish, + }; - SequenceTrack(); + static const int DefaultPriority{64}; + static const int DefaultBendRange{2}; + static const int DefaultPortaKey{60}; + static const int InvalidEnvelope{255}; + static const int MaxEnvelopeValue{127}; + static const int ParserParamSize{32}; + static const int TrackVariableCount{16}; - void SetPlayerTrackNo(s32 playerTrackNo); + static const int PauseReleaseValue{127}; + static const int MuteReleaseValue{127}; - void InitParam(); + static void ChannelCallbackFunc(Channel* dropChannel, Channel::ChannelCallbackStatus, + void* userData); - void Close(); + SequenceTrack(); + virtual ~SequenceTrack(); - void SetSeqData(const void* seqBase, s32 seqOffset); + void InitParam(); + + void SetSeqData(const void* seqBase, int seqOffset); void Open(); + void Close(); - void ReleaseAllChannel(s32 release); - void FreeAllChannel(); + bool IsOpened() const { return m_OpenFlag; } + + int ParseNextTick(bool doNoteOn); void UpdateChannelLength(); - void UpdateChannelRelease(Channel*); + void UpdateChannelParam(); - s32 ParseNextTick(bool doNoteOn); + Channel* NoteOn(int key, int velocity, int length, bool tieFlag); void StopAllChannel(); - void UpdateChannelParam(); + void ReleaseAllChannel(int release); + void FreeAllChannel(); void PauseAllChannel(bool flag); - - void AddChannel(Channel*); - s32 GetChannelCount() const; + int GetChannelCount() const; - static void ChannelCallbackFunc(Channel* dropChannel, - Channel::ChannelCallbackStatus callbackStatus, void* userData); + const ParserTrackParam& GetParserTrackParam() const { return m_ParserTrackParam; } + ParserTrackParam& GetParserTrackParam() { return m_ParserTrackParam; } void SetMute(SequenceMute mute); - void ForceMute(); + void SetSilence(bool silenceFlag, int fadeTimes); - void SetSilence(bool silenceFlag, s32 fadeTimes); - void SetBiquadFilter(s32 type, f32 value); - void SetBankIndex(s32 bankIndex); + void SetVolume(float volume) { m_ExtVolume = volume; } + void SetPitch(float pitch) { m_ExtPitch = pitch; } + void SetPanRange(float panRange) { m_PanRange = panRange; } + + void SetLpfFreq(float lpfFreq) { m_ParserTrackParam.lpfFreq = lpfFreq; }; + void SetBiquadFilter(int type, float value); + void SetBankIndex(int bankIndex); void SetTranspose(s8 transpose); void SetVelocityRange(u8 range); - void SetOutputLine(s32 outputLine); - void SetTvMixParameter(u32 srcChNo, s32 mixChNo, f32 param); - - s16 GetTrackVariable(s32 varNo) const; - void SetTrackVariable(s32 varNo, s16 var); + void SetOutputLine(int outputLine); + + void SetTvVolume(float volume) { m_TvParam.volume = volume; }; + void SetTvMixParameter(u32 srcChNo, int mixChNo, float param); + void SetTvPan(float pan) { m_TvParam.pan = pan; } + void SetTvSurroundPan(float span) { m_TvParam.span = span; } + void SetTvMainSend(float mainSend) { m_TvParam.send[0] = mainSend; } + void SetTvFxSend(AuxBus bus, float send) { m_TvParam.send[bus] = send; }; + + float GetVolume() const { return m_ExtVolume; } + float GetPitch() const { return m_ExtPitch; } + float GetPanRange() const { return m_PanRange; } - s16* GetVariablePtr(s32 varNo); + float GetLpfFreq() const { return m_ParserTrackParam.lpfFreq; } + int GetBiquadType() const { return m_ParserTrackParam.biquadType; } + float GetBiquadValue() const { return m_ParserTrackParam.biquadValue; } - Channel* NoteOn(s32 key, s32 velocity, s32 length, bool tieFlag); + s16 GetTrackVariable(int varNo) const; + void SetTrackVariable(int varNo, s16 var); + volatile s16* GetVariablePtr(int varNo); + + void SetSequenceSoundPlayer(SequenceSoundPlayer* player) { m_pSequenceSoundPlayer = player; } + const SequenceSoundPlayer* GetSequenceSoundPlayer() const { return m_pSequenceSoundPlayer; } + SequenceSoundPlayer* GetSequenceSoundPlayer() { return m_pSequenceSoundPlayer; } + + void SetPlayerTrackNo(int playerTrackNo); + u8 GetPlayerTrackNo() const { return m_PlayerTrackNo; } + + void UpdateChannelRelease(Channel* channel); + + os::Tick GetProcessTick(const SoundProfile& profile); + + void ForceMute(); + +protected: + virtual ParseResult Parse(bool doNoteOn) = 0; private: + Channel* GetLastChannel() const { return m_pChannelList; }; + + void AddChannel(Channel* channel); + u8 m_PlayerTrackNo; bool m_OpenFlag; bool m_ForceMute; - f32 m_ExtVolume; - f32 m_ExtPitch; - f32 m_PanRange; + float m_ExtVolume; + float m_ExtPitch; + float m_PanRange; OutputParam m_TvParam; ParserTrackParam m_ParserTrackParam; - s16 m_TrackVariable[TrackVariableCount]; + volatile s16 m_TrackVariable[TrackVariableCount]; SequenceSoundPlayer* m_pSequenceSoundPlayer; Channel* m_pChannelList; }; static_assert(sizeof(SequenceTrack) == 0x1e8); -} // namespace nn::atk::detail::driver \ No newline at end of file + +} // namespace nn::atk::detail::driver \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp index 2032d4ea..1c96eefe 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp @@ -3,6 +3,7 @@ namespace nn::atk::detail { namespace { + const u32 SignatureInfoBlockBank{0x4f464e49}; // INFO const u32 SupportedFileVersionBank{0x10000}; @@ -18,6 +19,7 @@ bool IsValidFileHeaderBank(const void* bankFile) { return isSupportedVersion; } + } // anonymous namespace BankFileReader::BankFileReader() = default; diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceTrack.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceTrack.cpp index e69de29b..92bcee0e 100644 --- a/src/NintendoWare/atk/detail/seq/atk_SequenceTrack.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_SequenceTrack.cpp @@ -0,0 +1,10 @@ +#include + +namespace nn::atk::detail::driver { + +SequenceTrack::SequenceTrack() + : m_OpenFlag{false}, m_pSequenceSoundPlayer{nullptr}, m_pChannelList{nullptr} { + InitParam(); +} + +} // namespace nn::atk::detail::driver \ No newline at end of file From 0acf4a04564efe9f530f26a76b8521ac59696428 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 17:24:50 -0300 Subject: [PATCH 560/785] atk: Reorganize `atk_Global.h` Moved stuff around to better match DWARF --- include/nn/atk/atk_Config.h | 7 + include/nn/atk/atk_Global.h | 527 +++++++++--------- include/nn/atk/atk_StreamSoundPlayer.h | 12 + .../atk/detail/voice/atk_Voice.cpp | 12 + 4 files changed, 310 insertions(+), 248 deletions(-) diff --git a/include/nn/atk/atk_Config.h b/include/nn/atk/atk_Config.h index 6c47205f..772570d7 100644 --- a/include/nn/atk/atk_Config.h +++ b/include/nn/atk/atk_Config.h @@ -7,4 +7,11 @@ namespace nn::atk { using position_t = detail::fnd::position_t; +const int StreamChannelCount{16}; +const u32 StreamTrackCount{8}; + +const int StreamDataLoadTaskMax{32}; + +static const size_t DataBlockSizeMarginSamples{0x480}; + } // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h index 572b4bf1..1cd57866 100644 --- a/include/nn/atk/atk_Global.h +++ b/include/nn/atk/atk_Global.h @@ -5,31 +5,54 @@ namespace nn::atk { -enum WaveType { - WaveType_Invalid = -1, - WaveType_Nwwav, - WaveType_Dspadpcm, +using SoundFrameUserCallback = void (*)(uintptr_t); +using SoundThreadUserCallback = void (*)(uintptr_t); +using SoundStopCallback = void (*)(); + +enum OutputMode { + OutputMode_Monaural, + OutputMode_Stereo, + OutputMode_Surround, + OutputMode_Dpl2, + OutputMode_Count, }; -struct WaveBuffer { - enum Status { - Status_Free, - Status_Wait, - Status_Play, - Status_Done, - }; +static const u32 InvalidSoundId{0xffffffff}; - void* bufferAddress; - size_t bufferSize; - size_t sampleLength; - position_t sampleOffset; - AdpcmContext* pAdpcmContext; - void* userParam; - bool loopFlag; - Status status; - WaveBuffer* next; +// DWARF shows this initialized as 18446744073709551615 +static const int InvalidStreamJumpRegionIndex{-1}; + +static const int RegionNameLengthMax{63}; + +static const int PlayerPriorityMin{0}; +static const int PlayerPriorityMax{127}; + +enum OutputDeviceIndex { + OutputDeviceIndex_Main, + OutputDeviceIndex_Count, +}; + +enum OutputLineIndex { + OutputLineIndex_Main = 0, + OutputLineIndex_ReservedMax = 1, + + OutputLineIndex_User0 = 16, + OutputLineIndex_User1 = 17, + OutputLineIndex_User2 = 18, + OutputLineIndex_User3 = 19, + + OutputLineIndex_Max = 32, +}; + +enum OutputLine { + OutputLine_Main = 1 << OutputLineIndex_Main, + OutputLine_ReservedMax = 1 << OutputLineIndex_ReservedMax, + + OutputLine_User0 = 1 << OutputLineIndex_User0, + OutputLine_User1 = 1 << OutputLineIndex_User1, + OutputLine_User2 = 1 << OutputLineIndex_User2, + OutputLine_User3 = 1 << OutputLineIndex_User3, }; -static_assert(sizeof(WaveBuffer) == 0x40); enum AuxBus { AuxBus_A, @@ -38,11 +61,120 @@ enum AuxBus { AuxBus_Count, }; +enum SampleFormat { + SampleFormat_PcmS8, + SampleFormat_PcmS16, + SampleFormat_DspAdpcm, + SampleFormat_PcmS32, +}; + +enum SequenceMute { + SequenceMute_Off, + SequenceMute_NoStop, + SequenceMute_Release, + SequenceMute_Stop, +}; + +enum OutputDevice { + OutputDevice_Main, + OutputDevice_Count, +}; + +enum ChannelIndex { + ChannelIndex_FrontLeft, + ChannelIndex_FrontRight, + ChannelIndex_RearLeft, + ChannelIndex_RearRight, + ChannelIndex_FrontCenter, + ChannelIndex_Lfe, + ChannelIndex_Count, +}; + +static const u32 WaveChannelMax{2}; + +static const u32 SeqBankMax{4}; + +enum PanMode { + PanMode_Dual, + PanMode_Balance, + PanMode_Invalid, +}; + +enum PanCurve { + PanCurve_Sqrt, + PanCurve_Sqrt0Db, + PanCurve_Sqrt0DbClamp, + PanCurve_Sincos, + PanCurve_Sincos0Db, + PanCurve_Sincos0DbClamp, + PanCurve_Linear, + PanCurve_Linear0Db, + PanCurve_Linear0DbClamp, + PanCurve_Invalid, +}; + +enum SinglePlayType { + SinglePlayType_None, + SinglePlayType_PrioritizeOldest, + SinglePlayType_PrioritizeOldestEffectiveDuration, + SinglePlayType_PrioritizeOldestWithDuration = SinglePlayType_PrioritizeOldestEffectiveDuration, + + SinglePlayType_PrioritizeNewest, + SinglePlayType_PrioritizeNewestEffectiveDuration, + SinglePlayType_PrioritizeNewestWithDuration = SinglePlayType_PrioritizeNewestEffectiveDuration, +}; + +enum WaveType { + WaveType_Invalid = -1, + WaveType_Nwwav, + WaveType_Dspadpcm, +}; + +struct DspAdpcmParam { + u16 coef[8][2]; + u16 predScale; + u16 yn1; + u16 yn2; +}; +static_assert(sizeof(DspAdpcmParam) == 0x26); + +class AdshrCurve { +public: + AdshrCurve(u8 a, u8 d, u8 s, u8 h, u8 r) + : m_Attack{a}, m_Decay{d}, m_Sustain{s}, m_Hold{h}, m_Release{r} {} + + u8 GetAttack() const { return m_Attack; } + + void SetAttack(u8 attack) { m_Attack = attack; } + + u8 GetDecay() const { return m_Decay; } + + void SetDecay(u8 decay) { m_Decay = decay; } + + u8 GetSustain() const { return m_Sustain; } + + void SetSustain(u8 sustain) { m_Sustain = sustain; } + + u8 GetHold() const { return m_Hold; } + + void SetHold(u8 hold) { m_Hold = hold; } + + u8 GetRelease() const { return m_Release; } + + void SetRelease(u8 release) { m_Release = release; } + +private: + u8 m_Attack; + u8 m_Decay; + u8 m_Sustain; + u8 m_Hold; + u8 m_Release; +}; +static_assert(sizeof(AdshrCurve) == 0x5); + enum BiquadFilterType { BiquadFilterType_Inherit = -1, - BiquadFilterType_Min = -1, - BiquadFilterType_DataMin = 0, - + BiquadFilterType_None = 0, BiquadFilterType_LowPassFilter, BiquadFilterType_HighPassFilter, @@ -55,7 +187,7 @@ enum BiquadFilterType { BiquadFilterType_BandPassFilter1024Nw4fCompatible48k, BiquadFilterType_BandPassFilter2048Nw4fCompatible48k, - BiquadFilterType_UserMin = 0x40, + BiquadFilterType_UserMin = 64, BiquadFilterType_User0 = BiquadFilterType_UserMin, BiquadFilterType_User1, @@ -122,65 +254,54 @@ enum BiquadFilterType { BiquadFilterType_User62, BiquadFilterType_User63, - BiquadFilterType_Max = 0x7f, - BiquadFilterType_UserMax = 0x7f, -}; + BiquadFilterType_UserMax = 127, -enum ChannelIndex { - ChannelIndex_FrontLeft, - ChannelIndex_FrontRight, - ChannelIndex_RearLeft, - ChannelIndex_RearRight, - ChannelIndex_FrontCenter, - ChannelIndex_Lfe, - ChannelIndex_Count, -}; + BiquadFilterType_DataMin = 0, + BiquadFilterType_Min = BiquadFilterType_Inherit, -enum CircularBufferSinkState { - CircularBufferSinkState_Invalid, - CircularBufferSinkState_Started, - CircularBufferSinkState_Stopped, + BiquadFilterType_Max = BiquadFilterType_UserMax, }; -enum FsPriority { - FsPriority_RealTime, - FsPriority_Normal, - FsPriority_Low, +enum SampleRateConverterType { + SampleRateConverterType_None, + SampleRateConverterType_Linear, + SampleRateConverterType_4Tap, }; -class AdshrCurve { -public: - AdshrCurve(u8 a, u8 d, u8 s, u8 h, u8 r) - : m_Attack{a}, m_Decay{d}, m_Sustain{s}, m_Hold{h}, m_Release{r} {} - - u8 GetAttack() const { return m_Attack; } - - void SetAttack(u8 attack) { m_Attack = attack; } - - u8 GetDecay() const { return m_Decay; } +struct OutputMix { + static const int ChannelCountMax{24}; - void SetDecay(u8 decay) { m_Decay = decay; } + float channelGain[ChannelCountMax]{}; - u8 GetSustain() const { return m_Sustain; } - - void SetSustain(u8 sustain) { m_Sustain = sustain; } + void Initialize(); +}; +static_assert(sizeof(OutputMix) == 0x60); - u8 GetHold() const { return m_Hold; } +struct WaveBuffer { + enum Status { + Status_Free, + Status_Wait, + Status_Play, + Status_Done, + }; - void SetHold(u8 hold) { m_Hold = hold; } + const void* bufferAddress; + size_t bufferSize; + position_t sampleLength; + position_t sampleOffset; + const AdpcmContext* pAdpcmContext; + void* userParam; + bool loopFlag; + Status status; + WaveBuffer* next; - u8 GetRelease() const { return m_Release; } + WaveBuffer() = default; + ~WaveBuffer(); - void SetRelease(u8 release) { m_Release = release; } - -private: - u8 m_Attack; - u8 m_Decay; - u8 m_Sustain; - u8 m_Hold; - u8 m_Release; + void Initialize(); + void Dump(); }; -static_assert(sizeof(AdshrCurve) == 0x5); +static_assert(sizeof(WaveBuffer) == 0x40); struct BiquadFilterCoefficients { s16 b0{0}; @@ -191,14 +312,6 @@ struct BiquadFilterCoefficients { }; static_assert(sizeof(BiquadFilterCoefficients) == 0xa); -struct DspAdpcmParam { - u16 coef[8][2]; - u16 predScale; - u16 yn1; - u16 yn2; -}; -static_assert(sizeof(DspAdpcmParam) == 0x26); - enum MixMode { MixMode_Pan = 0, MixMode_MixVolume = 1, @@ -206,104 +319,44 @@ enum MixMode { MixMode_Count = 2, }; -struct MixParameter { +struct MixVolume { union { struct { - f32 fL; - f32 fR; - f32 rL; - f32 rR; - f32 fC; - f32 lfe; + float frontLeft; + float frontRight; + float rearLeft; + float rearRight; + float frontCenter; + float lowFrequencyEffect; }; - float ch[ChannelIndex_Count]; + float channel[ChannelIndex_Count]; }; - - // why does this work - MixParameter() { fL = fR = rL = rR = fC = lfe = 1.0f; } - - MixParameter(float _fL, float _fR, float _rL, float _rR, float _fC, float _lfe) - : fL{_fL}, fR{_fR}, rL{_rL}, rR{_rR}, fC{_fC}, lfe{_lfe} {} }; -static_assert(sizeof(MixParameter) == 0x18); +static_assert(sizeof(MixVolume) == 0x18); -struct MixVolume { +struct MixParameter { union { struct { - f32 frontLeft; - f32 frontRight; - f32 rearLeft; - f32 rearRight; - f32 frontCenter; - f32 lowFrequencyEffect; + float fL; + float fR; + float rL; + float rR; + float fC; + float lfe; }; - float channel[ChannelIndex_Count]; + float ch[ChannelIndex_Count]; }; -}; -static_assert(sizeof(MixVolume) == 0x18); - -enum OutputDevice { - OutputDevice_Main, - OutputDevice_Count, -}; - -enum OutputDeviceIndex { - OutputDeviceIndex_Main, - OutputDeviceIndex_Count, -}; - -enum OutputLine { - OutputLine_Main = 1, - OutputLine_ReservedMax = 2, - - OutputLine_User0 = 0x10000, - OutputLine_User1 = 0x20000, - OutputLine_User2 = 0x40000, - OutputLine_User3 = 0x80000, -}; - -enum OutputLineIndex { - OutputLineIndex_Main = 1, - OutputLineIndex_ReservedMax = 2, - - OutputLineIndex_User0 = 0x10000, - OutputLineIndex_User1 = 0x20000, - OutputLineIndex_User2 = 0x40000, - OutputLineIndex_User3 = 0x80000, -}; -enum OutputMode { - OutputMode_Monaural, - OutputMode_Stereo, - OutputMode_Surround, - OutputMode_Dpl2, - OutputMode_Count, -}; - -struct OutputMix { - OutputMix() = default; - - f32 channelGain[24]{0}; -}; -static_assert(sizeof(OutputMix) == 0x60); + MixParameter() { fL = fR = rL = rR = fC = lfe = 1.0f; } -enum PanCurve { - PanCurve_Sqrt, - PanCurve_Sqrt0Db, - PanCurve_Sqrt0DbClamp, - PanCurve_Sincos, - PanCurve_Sincos0Db, - PanCurve_Sincos0DbClamp, - PanCurve_Linear, - PanCurve_Linear0Db, - PanCurve_Linear0DbClamp, - PanCurve_Invalid, + MixParameter(float _fL, float _fR, float _rL, float _rR, float _fC, float _lfe) + : fL{_fL}, fR{_fR}, rL{_rL}, rR{_rR}, fC{_fC}, lfe{_lfe} {} }; +static_assert(sizeof(MixParameter) == 0x18); -enum PanMode { - PanMode_Dual, - PanMode_Balance, - PanMode_Invalid, +enum UpdateType { + UpdateType_AudioFrame, + UpdateType_GameFrame, }; enum PauseMode { @@ -313,42 +366,16 @@ enum PauseMode { PauseMode_PauseImmediately, }; -enum SampleFormat { - SampleFormat_PcmS8, - SampleFormat_PcmS16, - SampleFormat_DspAdpcm, - SampleFormat_PcmS32, -}; - -enum SampleRateConverterType { - SampleRateConverterType_None, - SampleRateConverterType_Linear, - SampleRateConverterType_4Tap, -}; - -enum SequenceMute { - SequenceMute_Off, - SequenceMute_NoStop, - SequenceMute_Release, - SequenceMute_Stop, -}; - -enum SinglePlayType { - SinglePlayType_None, - SinglePlayType_PrioritizeOldest, - SinglePlayType_PrioritizeOldestEffectiveDuration, - SinglePlayType_PrioritizeOldestWithDuration = SinglePlayType_PrioritizeOldestEffectiveDuration, - - SinglePlayType_PrioritizeNewest, - SinglePlayType_PrioritizeNewestEffectiveDuration, - SinglePlayType_PrioritizeNewestWithDuration = SinglePlayType_PrioritizeNewestEffectiveDuration, +enum CircularBufferSinkState { + CircularBufferSinkState_Invalid, + CircularBufferSinkState_Started, + CircularBufferSinkState_Stopped, }; -struct StreamDataInfo {}; - -enum UpdateType { - UpdateType_AudioFrame, - UpdateType_GameFrame, +enum FsPriority { + FsPriority_RealTime, + FsPriority_Normal, + FsPriority_Low, }; enum VolumeThroughModeBitFlag { @@ -357,13 +384,6 @@ enum VolumeThroughModeBitFlag { namespace detail { -enum DecodeMode { - DecodeMode_Invalid = -1, - DecodeMode_Default, - DecodeMode_Cpu, - DecodeMode_Accelerator, -}; - struct DspAdpcmLoopParam { u16 loopPredScale; u16 loopYn1; @@ -371,38 +391,72 @@ struct DspAdpcmLoopParam { }; static_assert(sizeof(DspAdpcmLoopParam) == 0x6); -struct OutputBusMixVolume { - float volume[2][24]; +struct WaveInfo { + struct ChannelParam { + const void* dataAddress; + int dataSize; + DspAdpcmParam adpcmParam; + DspAdpcmLoopParam adpcmLoopParam; + }; + static_assert(sizeof(ChannelParam) == 0x38); + + SampleFormat sampleFormat; + bool loopFlag; + int channelCount; + int sampleRate; + position_t loopStartFrame; + position_t loopEndFrame; + position_t originalLoopStartFrame; + size_t dataSize; + ChannelParam channelParam[WaveChannelMax]; + + void Dump(); }; -static_assert(sizeof(OutputBusMixVolume) == 0xc0); +static_assert(sizeof(WaveInfo) == 0xa0); + +static const int DefaultBusCount{4}; struct OutputParam { float volume; u32 mixMode; - MixParameter mixParameter[2]; + MixParameter mixParameter[WaveChannelMax]; float pan; float span; - float send[AuxBus_Count + 1]; + float send[DefaultBusCount]; void Initialize() { volume = 1.0f; mixMode = MixMode_Pan; pan = 0.0f; span = 0.0f; - for (int i{0}; i < 4; ++i) + for (int i{0}; i < DefaultBusCount; ++i) send[i] = 0.0f; } - - OutputParam() = default; }; static_assert(sizeof(OutputParam) == 0x50); +struct OutputBusMixVolume { + float volume[WaveChannelMax][OutputMix::ChannelCountMax]; + + void Initialize(); +}; +static_assert(sizeof(OutputBusMixVolume) == 0xc0); + +enum DecodeMode { + DecodeMode_Invalid = -1, + DecodeMode_Default, + DecodeMode_Cpu, + DecodeMode_Accelerator, +}; + +static const int MaxPerformanceBufferCount{3}; + struct SoundInstanceConfig { bool isBusMixVolumeEnabled; bool isVolumeThroughModeEnabled; - s32 busCount; + int busCount; }; -static_assert(sizeof(SoundInstanceConfig) == 8); +static_assert(sizeof(SoundInstanceConfig) == 0x8); enum StreamFileType { StreamFileType_Bfstm, @@ -415,15 +469,6 @@ enum VoiceState { VoiceState_Pause, }; -struct VoiceInfo { - VoiceState voiceState; - WaveBuffer::Status waveBufferStatus; - void* waveBufferTag; - u32 playPosition; - void* userId; -}; -static_assert(sizeof(VoiceInfo) == 0x20); - class VoiceParam { public: VoiceParam() = default; @@ -442,34 +487,20 @@ class VoiceParam { }; static_assert(sizeof(VoiceParam) == 0x78); -struct WaveInfo { - struct ChannelParam { - const void* dataAddress; - int dataSize; - DspAdpcmParam adpcmParam; - DspAdpcmLoopParam adpcmLoopParam; - }; - static_assert(sizeof(ChannelParam) == 0x38); - - SampleFormat sampleFormat; - bool loopFlag; - int channelCount; - int sampleRate; - position_t loopStartFrame; - position_t loopEndFrame; - position_t originalLoopStartFrame; - size_t dataSize; - ChannelParam channelParam[2]; +struct VoiceInfo { + VoiceState voiceState; + WaveBuffer::Status waveBufferStatus; + void* waveBufferTag; + u32 playPosition; + void* userId; }; -static_assert(sizeof(WaveInfo) == 0xa0); +static_assert(sizeof(VoiceInfo) == 0x20); -static const OutputMix DefaultTvMix{{1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}; +static const int FilePathMax{639}; +static const int PpcIoBufferAlign{64}; -} // namespace detail +static const int StreamBlockCountMin{2}; -using SoundFrameUserCallback = void (*)(std::uintptr_t); -using SoundThreadUserCallback = void (*)(std::uintptr_t); -using SoundStopCallback = void (*)(); +} // namespace detail } // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/atk_StreamSoundPlayer.h b/include/nn/atk/atk_StreamSoundPlayer.h index 7f243bd2..9631a673 100644 --- a/include/nn/atk/atk_StreamSoundPlayer.h +++ b/include/nn/atk/atk_StreamSoundPlayer.h @@ -7,6 +7,17 @@ #include namespace nn::atk::detail { +struct StreamDataInfo { + bool loopFlag; + s32 sampleRate; + s64 loopStart; + s64 loopEnd; + s64 compatibleLoopStart; + s64 compatibleLoopEnd; + s32 channelCount; +}; +static_assert(sizeof(StreamDataInfo) == 0x30); + struct StreamSoundDataInfo { bool loopFlag; s32 sampleRate; @@ -189,6 +200,7 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { bool IsBufferEmpty() const; bool ReadStreamDataInfo(StreamDataInfo* strmDataInfo) const; + bool ReadStreamDataInfo(StreamSoundDataInfo* strmDataInfo) const; position_t GetPlaySamplePosition(bool) const; f32 GetFilledBufferPercentage() const; diff --git a/src/NintendoWare/atk/detail/voice/atk_Voice.cpp b/src/NintendoWare/atk/detail/voice/atk_Voice.cpp index e69de29b..8bd70285 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Voice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Voice.cpp @@ -0,0 +1,12 @@ +#include + +namespace nn::atk::detail { + +namespace { + +const OutputMix DefaultTvMix{{1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}; + +} + +} // namespace nn::atk::detail \ No newline at end of file From aeb6439abb11b54c4bf0977f962410457ee38c77 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 18:31:39 -0300 Subject: [PATCH 561/785] atk: Match `WaveSoundFileReader` constructor Also did some code cleanup --- include/nn/atk/atk_HardwareManager.h | 2 + include/nn/atk/atk_WaveSoundFileReader.h | 24 ++-- .../atk/detail/wsd/atk_WaveSoundFile.cpp | 123 +++++++++--------- .../detail/wsd/atk_WaveSoundFileReader.cpp | 37 ++++++ 4 files changed, 112 insertions(+), 74 deletions(-) diff --git a/include/nn/atk/atk_HardwareManager.h b/include/nn/atk/atk_HardwareManager.h index 2fc5a44e..df63b34e 100644 --- a/include/nn/atk/atk_HardwareManager.h +++ b/include/nn/atk/atk_HardwareManager.h @@ -2,6 +2,8 @@ #include +#include + #include #include diff --git a/include/nn/atk/atk_WaveSoundFileReader.h b/include/nn/atk/atk_WaveSoundFileReader.h index 10ead847..729f4f3b 100644 --- a/include/nn/atk/atk_WaveSoundFileReader.h +++ b/include/nn/atk/atk_WaveSoundFileReader.h @@ -4,12 +4,12 @@ namespace nn::atk::detail { struct WaveSoundInfo { - f32 pitch; + float pitch; AdshrCurve adshr; u8 pan; u8 surroundPan; u8 mainSend; - u8 fxSend[3]; + u8 fxSend[DefaultBusCount - 1]; u8 lpfFreq; u8 biquadType; u8 biquadValue; @@ -24,7 +24,7 @@ struct WaveSoundNoteInfo { u8 pan; u8 surroundPan; u8 volume; - f32 pitch; + float pitch; WaveSoundNoteInfo() : adshr(0, 0, 0, 0, 0) {}; @@ -33,23 +33,25 @@ static_assert(sizeof(WaveSoundNoteInfo) == 0x18); class WaveSoundFileReader { public: - constexpr static s32 SignatureFile = 0x44535746; // FWSD + static const u32 SignatureFile{0x44535746}; // FWSD explicit WaveSoundFileReader(const void* waveSoundFile); - s32 GetWaveSoundCount() const; - s32 GetNoteInfoCount(u32) const; - s32 GetTrackInfoCount(u32) const; + bool IsAvailable() const { return m_pHeader != nullptr; } - bool ReadWaveSoundInfo(WaveSoundInfo* dst, u32 index) const; + u32 GetWaveSoundCount() const; + u32 GetNoteInfoCount(u32 index) const; + u32 GetTrackInfoCount(u32 index) const; - bool IsFilterSupportedVersion() const; + bool ReadWaveSoundInfo(WaveSoundInfo* dst, u32 index) const; bool ReadNoteInfo(WaveSoundNoteInfo* dst, u32 index, u32 noteIndex) const; + + bool IsFilterSupportedVersion() const; private: - WaveSoundFile::FileHeader* m_pHeader; - WaveSoundFile::InfoBlockBody* m_pInfoBlockBody; + const WaveSoundFile::FileHeader* m_pHeader{}; + const WaveSoundFile::InfoBlockBody* m_pInfoBlockBody{}; }; static_assert(sizeof(WaveSoundFileReader) == 0x10); } // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index 90ad80f2..0992232f 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -4,23 +4,18 @@ namespace nn::atk::detail { namespace { -const u8 WsdDefaultPan {64}; -const s8 WsdDefaultSurroundPan {0}; -const float WsdDefaultPitch {1.0}; -const u8 WsdDefaultMainSend {127}; -const u8 WsdDefaultFxSend {0}; -const AdshrCurve WsdDefaultAdshrCurve { - 127, - 127, - 127, - 127, - 127 -}; -const u8 WsdDefaultLpfFreq {64}; -const u8 WsdDefaultBiquadType {0}; -const u8 WsdDefaultBiquadValue {0}; -const u8 WsdDefaultKey {64}; -const u8 WsdDefaultVolume {96}; + +const u8 WsdDefaultPan{64}; +const s8 WsdDefaultSurroundPan{0}; +const float WsdDefaultPitch{1.0}; +const u8 WsdDefaultMainSend{127}; +const u8 WsdDefaultFxSend{0}; +const AdshrCurve WsdDefaultAdshrCurve{127, 127, 127, 127, 127}; +const u8 WsdDefaultLpfFreq{64}; +const u8 WsdDefaultBiquadType{0}; +const u8 WsdDefaultBiquadValue{0}; +const u8 WsdDefaultKey{64}; +const u8 WsdDefaultVolume{96}; enum WaveSoundInfoBitFlagWsd { WaveSoundInfoBitFlagWsd_Pan = 0, @@ -46,23 +41,24 @@ struct SendValueWsd { u8 mainSend; Util::Table fxSend; }; -} // anonymous namespace + +} // anonymous namespace const WaveSoundFile::InfoBlock* WaveSoundFile::FileHeader::GetInfoBlock() const { return util::ConstBytePtr(GetBlock(ElementType_WaveSoundFile_InfoBlock)) - .Get(); + .Get(); } -const WaveSoundFile::WaveSoundData& WaveSoundFile::InfoBlockBody::GetWaveSoundData(u32 index) const { - return *util::ConstBytePtr( - GetWaveSoundDataReferenceTable() - .GetReferedItem(index, ElementType_WaveSoundFile_WaveSoundMetaData) - ).Get(); +const WaveSoundFile::WaveSoundData& +WaveSoundFile::InfoBlockBody::GetWaveSoundData(u32 index) const { + return *util::ConstBytePtr(GetWaveSoundDataReferenceTable().GetReferedItem( + index, ElementType_WaveSoundFile_WaveSoundMetaData)) + .Get(); } const Util::ReferenceTable& WaveSoundFile::InfoBlockBody::GetWaveSoundDataReferenceTable() const { return *util::ConstBytePtr(this, toWaveSoundDataReferenceTable.offset) - .Get(); + .Get(); } const Util::WaveIdTable& WaveSoundFile::InfoBlockBody::GetWaveIdTable() const { @@ -74,32 +70,32 @@ const WaveSoundFile::WaveSoundInfo& WaveSoundFile::WaveSoundData::GetWaveSoundIn } const Util::ReferenceTable& WaveSoundFile::WaveSoundData::GetTrackInfoReferenceTable() const { - return *util::ConstBytePtr(this, toTrackInfoReferenceTable.offset) - .Get(); + return *util::ConstBytePtr(this, toTrackInfoReferenceTable.offset).Get(); } const Util::ReferenceTable& WaveSoundFile::WaveSoundData::GetNoteInfoReferenceTable() const { - return *util::ConstBytePtr(this, toNoteInfoReferenceTable.offset) - .Get(); + return *util::ConstBytePtr(this, toNoteInfoReferenceTable.offset).Get(); } const WaveSoundFile::TrackInfo& WaveSoundFile::WaveSoundData::GetTrackInfo(u32 index) const { const void* pTrackInfo; - pTrackInfo = GetTrackInfoReferenceTable().GetReferedItem(index, ElementType_WaveSoundFile_TrackInfo); + pTrackInfo = + GetTrackInfoReferenceTable().GetReferedItem(index, ElementType_WaveSoundFile_TrackInfo); return *util::ConstBytePtr(pTrackInfo).Get(); } const WaveSoundFile::NoteInfo& WaveSoundFile::WaveSoundData::GetNoteInfo(u32 index) const { const void* pNoteInfo; - pNoteInfo = GetNoteInfoReferenceTable().GetReferedItem(index, ElementType_WaveSoundFile_NoteInfo); + pNoteInfo = + GetNoteInfoReferenceTable().GetReferedItem(index, ElementType_WaveSoundFile_NoteInfo); return *util::ConstBytePtr(pNoteInfo).Get(); } u8 WaveSoundFile::WaveSoundInfo::GetPan() const { u32 value; - bool result {optionParameter.GetValue(&value, WaveSoundInfoBitFlagWsd_Pan)}; + bool result{optionParameter.GetValue(&value, WaveSoundInfoBitFlagWsd_Pan)}; if (result) return Util::DivideBy8bit(value, 0); @@ -108,7 +104,7 @@ u8 WaveSoundFile::WaveSoundInfo::GetPan() const { s8 WaveSoundFile::WaveSoundInfo::GetSurroundPan() const { u32 value; - bool result {optionParameter.GetValue(&value, WaveSoundInfoBitFlagWsd_Pan)}; + bool result{optionParameter.GetValue(&value, WaveSoundInfoBitFlagWsd_Pan)}; if (result) return static_cast(Util::DivideBy8bit(value, 1)); @@ -117,7 +113,7 @@ s8 WaveSoundFile::WaveSoundInfo::GetSurroundPan() const { float WaveSoundFile::WaveSoundInfo::GetPitch() const { float value; - bool result {optionParameter.GetValueF32(&value, WaveSoundInfoBitFlagWsd_Pitch)}; + bool result{optionParameter.GetValueF32(&value, WaveSoundInfoBitFlagWsd_Pitch)}; if (result) return value; @@ -126,29 +122,29 @@ float WaveSoundFile::WaveSoundInfo::GetPitch() const { void WaveSoundFile::WaveSoundInfo::GetSendValue(u8* mainSend, u8* fxSend, u8 fxSendCount) const { u32 value; - bool result {optionParameter.GetValue(&value, WaveSoundInfoBitFlagWsd_Send)}; + bool result{optionParameter.GetValue(&value, WaveSoundInfoBitFlagWsd_Send)}; if (result) { const SendValueWsd& sendValue = *util::ConstBytePtr(this, value).Get(); *mainSend = sendValue.mainSend; - int countSize {sendValue.fxSend.count > AuxBus_Count ? AuxBus_Count : sendValue.fxSend.count}; + int countSize{sendValue.fxSend.count > AuxBus_Count ? AuxBus_Count : + sendValue.fxSend.count}; - for (int i {0}; i < countSize; ++i) + for (int i{0}; i < countSize; ++i) fxSend[i] = sendValue.fxSend.item[i]; - } - else { + } else { *mainSend = WsdDefaultMainSend; - for (int i {0}; i < fxSendCount; ++i) + for (int i{0}; i < fxSendCount; ++i) fxSend[i] = WsdDefaultFxSend; } } const AdshrCurve& WaveSoundFile::WaveSoundInfo::GetAdshrCurve() const { u32 offsetToReference; - bool result {optionParameter.GetValue(&offsetToReference, WaveSoundInfoBitFlagWsd_Envelope)}; + bool result{optionParameter.GetValue(&offsetToReference, WaveSoundInfoBitFlagWsd_Envelope)}; if (result) { - const auto& ref {*util::ConstBytePtr(this, offsetToReference).Get()}; + const auto& ref{*util::ConstBytePtr(this, offsetToReference).Get()}; return *util::ConstBytePtr(&ref, ref.offset).Get(); } @@ -157,7 +153,7 @@ const AdshrCurve& WaveSoundFile::WaveSoundInfo::GetAdshrCurve() const { u8 WaveSoundFile::WaveSoundInfo::GetLpfFreq() const { u32 value; - bool result {optionParameter.GetValue(&value, WaveSoundInfoBitFlagWsd_Filter)}; + bool result{optionParameter.GetValue(&value, WaveSoundInfoBitFlagWsd_Filter)}; if (result) return Util::DivideBy8bit(value, 0); @@ -166,7 +162,7 @@ u8 WaveSoundFile::WaveSoundInfo::GetLpfFreq() const { u8 WaveSoundFile::WaveSoundInfo::GetBiquadType() const { u32 value; - bool result {optionParameter.GetValue(&value, WaveSoundInfoBitFlagWsd_Filter)}; + bool result{optionParameter.GetValue(&value, WaveSoundInfoBitFlagWsd_Filter)}; if (result) return Util::DivideBy8bit(value, 1); @@ -175,7 +171,7 @@ u8 WaveSoundFile::WaveSoundInfo::GetBiquadType() const { u8 WaveSoundFile::WaveSoundInfo::GetBiquadValue() const { u32 value; - bool result {optionParameter.GetValue(&value, WaveSoundInfoBitFlagWsd_Filter)}; + bool result{optionParameter.GetValue(&value, WaveSoundInfoBitFlagWsd_Filter)}; if (result) return Util::DivideBy8bit(value, 2); @@ -183,20 +179,20 @@ u8 WaveSoundFile::WaveSoundInfo::GetBiquadValue() const { } const Util::ReferenceTable& WaveSoundFile::TrackInfo::GetNoteEventReferenceTable() const { - return *util::ConstBytePtr(this, toNoteEventReferenceTable.offset) - .Get(); + return *util::ConstBytePtr(this, toNoteEventReferenceTable.offset).Get(); } const WaveSoundFile::NoteEvent& WaveSoundFile::TrackInfo::GetNoteEvent(u32 index) const { const void* pNoteEvent; - pNoteEvent = GetNoteEventReferenceTable().GetReferedItem(index, ElementType_WaveSoundFile_NoteEvent); + pNoteEvent = + GetNoteEventReferenceTable().GetReferedItem(index, ElementType_WaveSoundFile_NoteEvent); return *util::ConstBytePtr(pNoteEvent).Get(); } u8 WaveSoundFile::NoteInfo::GetOriginalKey() const { u32 value; - bool result {optionParameter.GetValue(&value, NoteInfoBitFlag_Key)}; + bool result{optionParameter.GetValue(&value, NoteInfoBitFlag_Key)}; if (result) return Util::DivideBy8bit(value, 0); @@ -205,7 +201,7 @@ u8 WaveSoundFile::NoteInfo::GetOriginalKey() const { u8 WaveSoundFile::NoteInfo::GetVolume() const { u32 value; - bool result {optionParameter.GetValue(&value, NoteInfoBitFlag_Volume)}; + bool result{optionParameter.GetValue(&value, NoteInfoBitFlag_Volume)}; if (result) return Util::DivideBy8bit(value, 0); @@ -214,7 +210,7 @@ u8 WaveSoundFile::NoteInfo::GetVolume() const { u8 WaveSoundFile::NoteInfo::GetPan() const { u32 value; - bool result {optionParameter.GetValue(&value, NoteInfoBitFlag_Pan)}; + bool result{optionParameter.GetValue(&value, NoteInfoBitFlag_Pan)}; if (result) return Util::DivideBy8bit(value, 0); @@ -223,7 +219,7 @@ u8 WaveSoundFile::NoteInfo::GetPan() const { u8 WaveSoundFile::NoteInfo::GetSurroundPan() const { u32 value; - bool result {optionParameter.GetValue(&value, NoteInfoBitFlag_Pan)}; + bool result{optionParameter.GetValue(&value, NoteInfoBitFlag_Pan)}; if (result) return Util::DivideBy8bit(value, 1); @@ -232,7 +228,7 @@ u8 WaveSoundFile::NoteInfo::GetSurroundPan() const { float WaveSoundFile::NoteInfo::GetPitch() const { float value; - bool result {optionParameter.GetValueF32(&value, NoteInfoBitFlag_Pitch)}; + bool result{optionParameter.GetValueF32(&value, NoteInfoBitFlag_Pitch)}; if (result) return value; @@ -242,32 +238,33 @@ float WaveSoundFile::NoteInfo::GetPitch() const { // NON_MATCHING void WaveSoundFile::NoteInfo::GetSendValue(u8* mainSend, u8** fxSend, u8 fxSendCount) const { u32 value; - bool result {optionParameter.GetValue(&value, NoteInfoBitFlag_Send)}; + bool result{optionParameter.GetValue(&value, NoteInfoBitFlag_Send)}; if (!result) { *mainSend = WsdDefaultMainSend; - for (int i {0}; i < fxSendCount; ++i) + for (int i{0}; i < fxSendCount; ++i) fxSend[i][0] = WsdDefaultFxSend; - } - else { + } else { const SendValueWsd& sendValue = *util::ConstBytePtr(this, value).Get(); *mainSend = sendValue.mainSend; - int countSize {sendValue.fxSend.count > AuxBus_Count ? AuxBus_Count : sendValue.fxSend.count}; - - for (int i {0}; i < countSize; ++i) + int countSize{sendValue.fxSend.count > AuxBus_Count ? AuxBus_Count : + sendValue.fxSend.count}; + + for (int i{0}; i < countSize; ++i) fxSend[i][0] = sendValue.fxSend.item[i]; } } const AdshrCurve& WaveSoundFile::NoteInfo::GetAdshrCurve() const { u32 offsetToReference; - bool result {optionParameter.GetValue(&offsetToReference, NoteInfoBitFlag_Envelope)}; + bool result{optionParameter.GetValue(&offsetToReference, NoteInfoBitFlag_Envelope)}; if (result) { - const auto& ref {*util::ConstBytePtr(this, offsetToReference).Get()}; + const auto& ref{*util::ConstBytePtr(this, offsetToReference).Get()}; return *util::ConstBytePtr(&ref, ref.offset).Get(); } return WsdDefaultAdshrCurve; } -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp index e69de29b..1dcb875a 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp @@ -0,0 +1,37 @@ +#include + +namespace nn::atk::detail { + +namespace { + +const u32 SignatureInfoBlockWsd{0x4f464e49}; // INFO + +const u32 SupportedFileVersionWsd{0x10000}; +const u32 CurrentFileVersionWsd{0x10100}; +const u32 FilterSupportedVersionWsd{0x10100}; + +bool IsValidFileHeaderWsd(const void* waveSoundFile) { + const BinaryFileHeader* header{util::ConstBytePtr(waveSoundFile).Get()}; + + bool isSupportedVersion{header->signature == WaveSoundFileReader::SignatureFile && + header->byteOrder == BinaryFileHeader::ValidByteOrderMark && + header->version >= SupportedFileVersionWsd && + header->version <= CurrentFileVersionWsd}; + + return isSupportedVersion; +} + +} // anonymous namespace + +WaveSoundFileReader::WaveSoundFileReader(const void* waveSoundFile) { + if (IsValidFileHeaderWsd(waveSoundFile)) { + m_pHeader = reinterpret_cast(waveSoundFile); + + const WaveSoundFile::InfoBlock* infoBlock{m_pHeader->GetInfoBlock()}; + + if (infoBlock != nullptr && infoBlock->header.kind == SignatureInfoBlockWsd) + m_pInfoBlockBody = &infoBlock->body; + } +} + +} // namespace nn::atk::detail \ No newline at end of file From b14ed31f1172840f82567f3d7bfec142a652051d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 18:32:34 -0300 Subject: [PATCH 562/785] atk: Match `WaveSoundFileReader::GetWaveSoundCount` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp index 1dcb875a..6eb98888 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp @@ -34,4 +34,8 @@ WaveSoundFileReader::WaveSoundFileReader(const void* waveSoundFile) { } } +u32 WaveSoundFileReader::GetWaveSoundCount() const { + return m_pInfoBlockBody->GetWaveSoundCount(); +} + } // namespace nn::atk::detail \ No newline at end of file From 12c0863841bda10ec36b864bc7c03d94ae9b32f4 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 18:35:14 -0300 Subject: [PATCH 563/785] atk: Match `WaveSoundFileReader::GetNoteInfoCount` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp index 6eb98888..5ff0f866 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp @@ -38,4 +38,10 @@ u32 WaveSoundFileReader::GetWaveSoundCount() const { return m_pInfoBlockBody->GetWaveSoundCount(); } +u32 WaveSoundFileReader::GetNoteInfoCount(u32 index) const { + const WaveSoundFile::WaveSoundData& wsdData{m_pInfoBlockBody->GetWaveSoundData(index)}; + + return wsdData.GetNoteCount(); +} + } // namespace nn::atk::detail \ No newline at end of file From 6b092cbbe2bc49c920b03c82495ebee7fdb23f65 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 18:36:01 -0300 Subject: [PATCH 564/785] atk: Match `WaveSoundFileReader::GetTrackInfoCount` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp index 5ff0f866..48395f89 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp @@ -44,4 +44,10 @@ u32 WaveSoundFileReader::GetNoteInfoCount(u32 index) const { return wsdData.GetNoteCount(); } +u32 WaveSoundFileReader::GetTrackInfoCount(u32 index) const { + const WaveSoundFile::WaveSoundData& wsdData{m_pInfoBlockBody->GetWaveSoundData(index)}; + + return wsdData.GetTrackCount(); +} + } // namespace nn::atk::detail \ No newline at end of file From 30016bbf4813dc0c0f08873c04aa9ca811bd9e29 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 18:37:21 -0300 Subject: [PATCH 565/785] atk: Match `WaveSoundFileReader::IsFilterSupportedVersion` --- src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp index 48395f89..7db832f7 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp @@ -50,4 +50,8 @@ u32 WaveSoundFileReader::GetTrackInfoCount(u32 index) const { return wsdData.GetTrackCount(); } +bool WaveSoundFileReader::IsFilterSupportedVersion() const { + return m_pHeader->header.version >= FilterSupportedVersionWsd; +} + } // namespace nn::atk::detail \ No newline at end of file From 6d74bad4f083f126aacd7977ac37512e2df61589 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 18:51:01 -0300 Subject: [PATCH 566/785] atk: Match `WaveSoundFileReader::ReadWaveSoundInfo` --- include/nn/atk/atk_WaveSoundFileReader.h | 2 +- .../detail/wsd/atk_WaveSoundFileReader.cpp | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_WaveSoundFileReader.h b/include/nn/atk/atk_WaveSoundFileReader.h index 729f4f3b..cbc902c6 100644 --- a/include/nn/atk/atk_WaveSoundFileReader.h +++ b/include/nn/atk/atk_WaveSoundFileReader.h @@ -9,7 +9,7 @@ struct WaveSoundInfo { u8 pan; u8 surroundPan; u8 mainSend; - u8 fxSend[DefaultBusCount - 1]; + u8 fxSend[AuxBus_Count]; u8 lpfFreq; u8 biquadType; u8 biquadValue; diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp index 7db832f7..fe36322b 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp @@ -50,6 +50,29 @@ u32 WaveSoundFileReader::GetTrackInfoCount(u32 index) const { return wsdData.GetTrackCount(); } +bool WaveSoundFileReader::ReadWaveSoundInfo(WaveSoundInfo* dst, u32 index) const { + const WaveSoundFile::WaveSoundInfo& src{m_pInfoBlockBody->GetWaveSoundData(index).GetWaveSoundInfo()}; + + dst->pitch = src.GetPitch(); + dst->pan = src.GetPan(); + dst->surroundPan = src.GetSurroundPan(); + src.GetSendValue(&dst->mainSend, dst->fxSend, AuxBus_Count); + dst->adshr = src.GetAdshrCurve(); + + if (IsFilterSupportedVersion()) { + dst->lpfFreq = src.GetLpfFreq(); + dst->biquadType = src.GetBiquadType(); + dst->biquadValue = src.GetBiquadValue(); + } + else { + dst->lpfFreq = 64; // WsdDefaultLpfFreq + dst->biquadType = 0; // WsdDefaultBiquadType + dst->biquadValue = 0; // WsdDefaultBiquadValue + } + + return true; +} + bool WaveSoundFileReader::IsFilterSupportedVersion() const { return m_pHeader->header.version >= FilterSupportedVersionWsd; } From 59a1c8ba836de6c0e7695da007102d2ba31b85b6 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 19:10:41 -0300 Subject: [PATCH 567/785] atk: Match `WaveSoundFileReader::ReadNoteInfo` This matches all exported functions in `WaveSoundFileReader` --- include/nn/atk/atk_Util.h | 12 ++++--- .../detail/wsd/atk_WaveSoundFileReader.cpp | 32 +++++++++++++++---- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index 317e9121..e103c57c 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -262,10 +262,10 @@ class Util { Table table; const WaveId* GetWaveId(u32 index) const { - if (index < table.count) - return &table.item[index]; - - return nullptr; + if (index >= table.count) + return nullptr; + + return &table.item[index]; } u32 GetCount() const { return table.count; } @@ -273,8 +273,12 @@ class Util { template class Singleton { + Singleton() = default; + public: static CHILD& GetInstance(); + + friend CHILD; }; static int GetSubMixBusFromMainBus(); diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp index fe36322b..e3af220e 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp @@ -51,7 +51,8 @@ u32 WaveSoundFileReader::GetTrackInfoCount(u32 index) const { } bool WaveSoundFileReader::ReadWaveSoundInfo(WaveSoundInfo* dst, u32 index) const { - const WaveSoundFile::WaveSoundInfo& src{m_pInfoBlockBody->GetWaveSoundData(index).GetWaveSoundInfo()}; + const WaveSoundFile::WaveSoundInfo& src{ + m_pInfoBlockBody->GetWaveSoundData(index).GetWaveSoundInfo()}; dst->pitch = src.GetPitch(); dst->pan = src.GetPan(); @@ -63,12 +64,31 @@ bool WaveSoundFileReader::ReadWaveSoundInfo(WaveSoundInfo* dst, u32 index) const dst->lpfFreq = src.GetLpfFreq(); dst->biquadType = src.GetBiquadType(); dst->biquadValue = src.GetBiquadValue(); + } else { + dst->lpfFreq = 64; // WsdDefaultLpfFreq + dst->biquadType = 0; // WsdDefaultBiquadType + dst->biquadValue = 0; // WsdDefaultBiquadValue } - else { - dst->lpfFreq = 64; // WsdDefaultLpfFreq - dst->biquadType = 0; // WsdDefaultBiquadType - dst->biquadValue = 0; // WsdDefaultBiquadValue - } + + return true; +} + +bool WaveSoundFileReader::ReadNoteInfo(WaveSoundNoteInfo* dst, u32 index, u32 noteIndex) const { + const WaveSoundFile::NoteInfo& src{ + m_pInfoBlockBody->GetWaveSoundData(index).GetNoteInfo(noteIndex)}; + + const Util::WaveId* pWaveId{m_pInfoBlockBody->GetWaveIdTable().GetWaveId(src.waveIdTableIndex)}; + if (pWaveId == nullptr) + return false; + + dst->waveArchiveId = pWaveId->waveArchiveId; + dst->waveIndex = static_cast(pWaveId->waveIndex); + dst->pitch = src.GetPitch(); + dst->adshr = src.GetAdshrCurve(); + dst->originalKey = src.GetOriginalKey(); + dst->pan = src.GetPan(); + dst->surroundPan = src.GetSurroundPan(); + dst->volume = src.GetVolume(); return true; } From 251d33165209938937d575c80d8e56c43b253724 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 19:30:30 -0300 Subject: [PATCH 568/785] atk: Match `WaveArchiveFileReader` constructor --- include/nn/atk/atk_WaveArchiveFileReader.h | 45 ++++++++++++------- .../atk/detail/atk_WaveArchiveFileReader.cpp | 28 ++++++++++++ .../detail/wsd/atk_WaveSoundFileReader.cpp | 10 ++--- 3 files changed, 62 insertions(+), 21 deletions(-) diff --git a/include/nn/atk/atk_WaveArchiveFileReader.h b/include/nn/atk/atk_WaveArchiveFileReader.h index 3648bf98..59cad100 100644 --- a/include/nn/atk/atk_WaveArchiveFileReader.h +++ b/include/nn/atk/atk_WaveArchiveFileReader.h @@ -3,40 +3,53 @@ #include namespace nn::atk::detail { + class WaveArchiveFileReader { public: - constexpr static s32 SignatureFile = 0x52415746; // FWAR - constexpr static s32 SignatureWarcTable = 0x54415746; // FWAT - - struct IndividualLoadTable { - void* waveFile[1]; - }; + static const u32 SignatureFile = 0x52415746; // FWAR + static const u32 SignatureWarcTable = 0x54415746; // FWAT - WaveArchiveFileReader(); WaveArchiveFileReader(const void* pWaveArchiveFile, bool isIndividual); - - void Initialize(const void* pWaveArchiveFile, bool isIndividual); - - bool HasIndividualLoadTable() const; + WaveArchiveFileReader(); + void Initialize(const void* pWaveArchiveFile, bool isIndividual); void Finalize(); void InitializeFileTable(); + bool IsAvailable() const { return m_pHeader != nullptr; } + u32 GetWaveFileCount() const; - void* GetWaveFile(u32 waveIndex) const; u32 GetWaveFileSize(u32 waveIndex) const; u32 GetWaveFileOffsetFromFileHead(u32 waveIndex) const; + const void* GetWaveFile(u32 waveIndex) const; void* SetWaveFile(u32 waveIndex, const void* pWaveFile); - bool IsLoaded(u32 index) { return m_IsInitialized && GetWaveFile(index) != nullptr; } + bool IsLoaded(u32 waveIndex) { return m_IsInitialized && GetWaveFile(waveIndex) != nullptr; } + + bool HasIndividualLoadTable() const; + + struct IndividualLoadTable { + void* waveFile[1]; + }; private: - WaveArchiveFile::FileHeader* m_pHeader; - WaveArchiveFile::InfoBlockBody* m_pInfoBlockBody; + const void* GetWaveFileForWhole(u32 waveIndex) { + u32 offset{m_pInfoBlockBody->GetOffsetFromFileBlockBody(waveIndex)}; + + return util::ConstBytePtr(m_pHeader, offset).Get(); + } + + const void* GetWaveFileForIndividual(u32 waveIndex) { + return m_pLoadTable->waveFile[waveIndex]; + } + + const WaveArchiveFile::FileHeader* m_pHeader; + const WaveArchiveFile::InfoBlockBody* m_pInfoBlockBody; IndividualLoadTable* m_pLoadTable; bool m_IsInitialized; }; static_assert(sizeof(WaveArchiveFileReader) == 0x20); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp index e69de29b..88513520 100644 --- a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp @@ -0,0 +1,28 @@ +#include + +namespace nn::atk::detail { + +namespace { +const u32 SupportedFileVersionWar{0x10000}; +const u32 CurrentFileVersionWar{0x10000}; + +bool IsValidFileHeaderWar(const void* waveArchiveData) { + const BinaryFileHeader& header{*util::ConstBytePtr(waveArchiveData).Get()}; + + bool isSupportedVersion{header.signature == WaveArchiveFileReader::SignatureFile && + header.byteOrder == BinaryFileHeader::ValidByteOrderMark && + header.version >= SupportedFileVersionWar && + header.version <= CurrentFileVersionWar}; + + return isSupportedVersion; +} +} // anonymous namespace + +WaveArchiveFileReader::WaveArchiveFileReader() { + m_IsInitialized = false; + m_pInfoBlockBody = nullptr; + m_pLoadTable = nullptr; + m_pHeader = nullptr; +} + +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp index e3af220e..4ca208ec 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp @@ -11,12 +11,12 @@ const u32 CurrentFileVersionWsd{0x10100}; const u32 FilterSupportedVersionWsd{0x10100}; bool IsValidFileHeaderWsd(const void* waveSoundFile) { - const BinaryFileHeader* header{util::ConstBytePtr(waveSoundFile).Get()}; + const BinaryFileHeader& header{*util::ConstBytePtr(waveSoundFile).Get()}; - bool isSupportedVersion{header->signature == WaveSoundFileReader::SignatureFile && - header->byteOrder == BinaryFileHeader::ValidByteOrderMark && - header->version >= SupportedFileVersionWsd && - header->version <= CurrentFileVersionWsd}; + bool isSupportedVersion{header.signature == WaveSoundFileReader::SignatureFile && + header.byteOrder == BinaryFileHeader::ValidByteOrderMark && + header.version >= SupportedFileVersionWsd && + header.version <= CurrentFileVersionWsd}; return isSupportedVersion; } From 111d44525c4cb48ed6d0229ddaf47de0edbd7d63 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 19:39:08 -0300 Subject: [PATCH 569/785] atk: Match `WaveArchiveFileReader::HasIndividualLoadTable` --- .../atk/detail/atk_WaveArchiveFileReader.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp index 88513520..f24c65e8 100644 --- a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp @@ -3,6 +3,7 @@ namespace nn::atk::detail { namespace { + const u32 SupportedFileVersionWar{0x10000}; const u32 CurrentFileVersionWar{0x10000}; @@ -16,6 +17,7 @@ bool IsValidFileHeaderWar(const void* waveArchiveData) { return isSupportedVersion; } + } // anonymous namespace WaveArchiveFileReader::WaveArchiveFileReader() { @@ -25,4 +27,13 @@ WaveArchiveFileReader::WaveArchiveFileReader() { m_pHeader = nullptr; } +bool WaveArchiveFileReader::HasIndividualLoadTable() const { + if (!m_IsInitialized) + return false; + + const u32* signature{util::ConstBytePtr(m_pHeader, m_pHeader->GetFileBlockOffset()).Get()}; + + return *signature == SignatureWarcTable; +} + } // namespace nn::atk::detail \ No newline at end of file From 66e71adbae1866e906d7d8754e8d7026af31be46 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 19:47:05 -0300 Subject: [PATCH 570/785] atk: Match `WaveArchiveFileReader::Initialize` --- .../atk/detail/atk_WaveArchiveFileReader.cpp | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp index f24c65e8..053cdd0a 100644 --- a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp @@ -27,6 +27,26 @@ WaveArchiveFileReader::WaveArchiveFileReader() { m_pHeader = nullptr; } +void WaveArchiveFileReader::Initialize(const void* pWaveArchiveFile, bool isIndividual) { + if (pWaveArchiveFile == nullptr || !IsValidFileHeaderWar(pWaveArchiveFile)) + return; + + m_pHeader = reinterpret_cast(pWaveArchiveFile); + + m_pInfoBlockBody = &m_pHeader->GetInfoBlock()->body; + m_IsInitialized = true; + + m_pLoadTable = nullptr; + + if (!isIndividual || !HasIndividualLoadTable()) + return; + + m_pLoadTable = util::BytePtr(const_cast(pWaveArchiveFile)) + .Advance(m_pHeader->GetFileBlockOffset() + + sizeof(WaveArchiveFileReader::SignatureWarcTable)) + .Get(); +} + bool WaveArchiveFileReader::HasIndividualLoadTable() const { if (!m_IsInitialized) return false; From a7cef276cd43d87d0817a578d86bd33402358107 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 19:48:39 -0300 Subject: [PATCH 571/785] atk: Match `WaveArchiveFileReader` constructor 2 --- include/nn/atk/atk_WaveArchiveFileReader.h | 8 ++++---- .../atk/detail/atk_WaveArchiveFileReader.cpp | 9 ++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/nn/atk/atk_WaveArchiveFileReader.h b/include/nn/atk/atk_WaveArchiveFileReader.h index 59cad100..204fbe7e 100644 --- a/include/nn/atk/atk_WaveArchiveFileReader.h +++ b/include/nn/atk/atk_WaveArchiveFileReader.h @@ -45,10 +45,10 @@ class WaveArchiveFileReader { return m_pLoadTable->waveFile[waveIndex]; } - const WaveArchiveFile::FileHeader* m_pHeader; - const WaveArchiveFile::InfoBlockBody* m_pInfoBlockBody; - IndividualLoadTable* m_pLoadTable; - bool m_IsInitialized; + const WaveArchiveFile::FileHeader* m_pHeader{}; + const WaveArchiveFile::InfoBlockBody* m_pInfoBlockBody{}; + IndividualLoadTable* m_pLoadTable{}; + bool m_IsInitialized{false}; }; static_assert(sizeof(WaveArchiveFileReader) == 0x20); diff --git a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp index 053cdd0a..37fe2f43 100644 --- a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp @@ -20,11 +20,10 @@ bool IsValidFileHeaderWar(const void* waveArchiveData) { } // anonymous namespace -WaveArchiveFileReader::WaveArchiveFileReader() { - m_IsInitialized = false; - m_pInfoBlockBody = nullptr; - m_pLoadTable = nullptr; - m_pHeader = nullptr; +WaveArchiveFileReader::WaveArchiveFileReader() = default; + +WaveArchiveFileReader::WaveArchiveFileReader(const void* pWaveArchiveFile, bool isIndividual) { + Initialize(pWaveArchiveFile, isIndividual); } void WaveArchiveFileReader::Initialize(const void* pWaveArchiveFile, bool isIndividual) { From 4edb7b0714bc2078141114c2dd3b8d256b8d5be2 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 19:49:58 -0300 Subject: [PATCH 572/785] atk: Match `WaveArchiveFileReader::Finalize` --- .../atk/detail/atk_WaveArchiveFileReader.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp index 37fe2f43..a67bc4e5 100644 --- a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp @@ -46,6 +46,15 @@ void WaveArchiveFileReader::Initialize(const void* pWaveArchiveFile, bool isIndi .Get(); } +void WaveArchiveFileReader::Finalize() { + if (m_IsInitialized) { + m_pHeader = nullptr; + m_pInfoBlockBody = nullptr; + m_pLoadTable = nullptr; + m_IsInitialized = false; + } +} + bool WaveArchiveFileReader::HasIndividualLoadTable() const { if (!m_IsInitialized) return false; From e1a3b05d565f37975ed905ccf16ef02bb1e17488 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 19:51:32 -0300 Subject: [PATCH 573/785] atk: Match `WaveArchiveFileReader::GetWaveFileCount` --- src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp index a67bc4e5..024a73b4 100644 --- a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp @@ -55,6 +55,13 @@ void WaveArchiveFileReader::Finalize() { } } +u32 WaveArchiveFileReader::GetWaveFileCount() const { + if (!m_IsInitialized) + return 0; + + return m_pInfoBlockBody->table.count; +} + bool WaveArchiveFileReader::HasIndividualLoadTable() const { if (!m_IsInitialized) return false; From adb13c4adc4a95ba6f7d221b8942eb083c6994b1 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 19:54:12 -0300 Subject: [PATCH 574/785] atk: Match `WaveArchiveFileReader::InitializeFileTable` --- src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp index 024a73b4..bfd8525d 100644 --- a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp @@ -55,10 +55,15 @@ void WaveArchiveFileReader::Finalize() { } } +void WaveArchiveFileReader::InitializeFileTable() { + for (u32 i{0}; i < GetWaveFileCount(); ++i) + m_pLoadTable->waveFile[i] = nullptr; +} + u32 WaveArchiveFileReader::GetWaveFileCount() const { if (!m_IsInitialized) return 0; - + return m_pInfoBlockBody->table.count; } From 7a557dd89ceeb21a1071f03d19adb3bf4dec32e1 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 19:55:37 -0300 Subject: [PATCH 575/785] atk: Match `WaveArchiveFileReader::GetWaveFileSize` --- .../atk/detail/atk_WaveArchiveFileReader.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp index bfd8525d..6dd09d65 100644 --- a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp @@ -64,7 +64,14 @@ u32 WaveArchiveFileReader::GetWaveFileCount() const { if (!m_IsInitialized) return 0; - return m_pInfoBlockBody->table.count; + return m_pInfoBlockBody->GetWaveFileCount(); +} + +u32 WaveArchiveFileReader::GetWaveFileSize(u32 waveIndex) const { + if (!m_IsInitialized) + return 0; + + return m_pInfoBlockBody->GetSize(waveIndex); } bool WaveArchiveFileReader::HasIndividualLoadTable() const { From b04b19ea667de43ecc4fdb8ec3b7baff8886e82a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 20:03:21 -0300 Subject: [PATCH 576/785] atk: Match `WaveArchiveFileReader::GetWaveFileOffsetFromFileHead` --- include/nn/atk/atk_WaveArchiveFile.h | 21 ++++++++++--------- .../atk/detail/atk_WaveArchiveFileReader.cpp | 10 +++++++++ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/include/nn/atk/atk_WaveArchiveFile.h b/include/nn/atk/atk_WaveArchiveFile.h index f4128df4..42102996 100644 --- a/include/nn/atk/atk_WaveArchiveFile.h +++ b/include/nn/atk/atk_WaveArchiveFile.h @@ -3,24 +3,25 @@ #include namespace nn::atk::detail { + struct WaveArchiveFile { - static const int BlockCount {2}; + static const int BlockCount{2}; struct InfoBlock; struct FileBlock; struct FileHeader : BinaryFileHeader { public: Util::ReferenceWithSize toBlocks[BlockCount]; - + const InfoBlock* GetInfoBlock() const; const FileBlock* GetFileBlock() const; - + u32 GetInfoBlockSize() const; u32 GetFileBlockSize() const; u32 GetInfoBlockOffset() const; u32 GetFileBlockOffset() const; - + private: const Util::ReferenceWithSize* GetReferenceBy(u16 typeId) const; }; @@ -31,12 +32,10 @@ struct WaveArchiveFile { u32 GetWaveFileCount() const { return table.count; } - u32 GetSize(u32 index) const { - return table.item[index].size; - } + u32 GetSize(u32 index) const { return table.item[index].size; } u32 GetOffsetFromFileBlockBody(u32 index) const { - return table.item[index].offset; + return offsetof(WaveArchiveFile::FileBlock, body) + table.item[index].offset; } static const u32 InvalidOffset = 0xffffffff; @@ -47,7 +46,8 @@ struct WaveArchiveFile { InfoBlockBody body; }; - struct FileBlockBody {/* empty structure */}; + struct FileBlockBody { /* empty structure */ + }; struct FileBlock { BinaryBlockHeader header; @@ -55,4 +55,5 @@ struct WaveArchiveFile { }; static_assert(sizeof(FileBlock) == 0xc); }; -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp index 6dd09d65..4a91625b 100644 --- a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp @@ -74,6 +74,16 @@ u32 WaveArchiveFileReader::GetWaveFileSize(u32 waveIndex) const { return m_pInfoBlockBody->GetSize(waveIndex); } +u32 WaveArchiveFileReader::GetWaveFileOffsetFromFileHead(u32 waveIndex) const { + u32 result{0}; + + if (m_IsInitialized) + result = m_pHeader->GetFileBlockOffset() + + m_pInfoBlockBody->GetOffsetFromFileBlockBody(waveIndex); + + return result; +} + bool WaveArchiveFileReader::HasIndividualLoadTable() const { if (!m_IsInitialized) return false; From 500b4c04dcb2c508869d6091df11344bafe0cfa7 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 20:09:18 -0300 Subject: [PATCH 577/785] atk: Match `WaveArchiveFileReader::GetWaveFile` --- include/nn/atk/atk_WaveArchiveFile.h | 2 +- include/nn/atk/atk_WaveArchiveFileReader.h | 6 +++--- .../atk/detail/atk_WaveArchiveFileReader.cpp | 15 ++++++++++++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/include/nn/atk/atk_WaveArchiveFile.h b/include/nn/atk/atk_WaveArchiveFile.h index 42102996..337de902 100644 --- a/include/nn/atk/atk_WaveArchiveFile.h +++ b/include/nn/atk/atk_WaveArchiveFile.h @@ -35,7 +35,7 @@ struct WaveArchiveFile { u32 GetSize(u32 index) const { return table.item[index].size; } u32 GetOffsetFromFileBlockBody(u32 index) const { - return offsetof(WaveArchiveFile::FileBlock, body) + table.item[index].offset; + return table.item[index].offset; } static const u32 InvalidOffset = 0xffffffff; diff --git a/include/nn/atk/atk_WaveArchiveFileReader.h b/include/nn/atk/atk_WaveArchiveFileReader.h index 204fbe7e..8b781fd3 100644 --- a/include/nn/atk/atk_WaveArchiveFileReader.h +++ b/include/nn/atk/atk_WaveArchiveFileReader.h @@ -35,13 +35,13 @@ class WaveArchiveFileReader { }; private: - const void* GetWaveFileForWhole(u32 waveIndex) { + const void* GetWaveFileForWhole(u32 waveIndex) const { u32 offset{m_pInfoBlockBody->GetOffsetFromFileBlockBody(waveIndex)}; - return util::ConstBytePtr(m_pHeader, offset).Get(); + return util::ConstBytePtr(&m_pHeader->GetFileBlock()->body, offset).Get(); } - const void* GetWaveFileForIndividual(u32 waveIndex) { + const void* GetWaveFileForIndividual(u32 waveIndex) const { return m_pLoadTable->waveFile[waveIndex]; } diff --git a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp index 4a91625b..cec4a9a4 100644 --- a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp @@ -78,12 +78,25 @@ u32 WaveArchiveFileReader::GetWaveFileOffsetFromFileHead(u32 waveIndex) const { u32 result{0}; if (m_IsInitialized) - result = m_pHeader->GetFileBlockOffset() + + result = m_pHeader->GetFileBlockOffset() + offsetof(WaveArchiveFile::FileBlock, body) + m_pInfoBlockBody->GetOffsetFromFileBlockBody(waveIndex); return result; } +const void* WaveArchiveFileReader::GetWaveFile(u32 waveIndex) const { + if (!m_IsInitialized) + return nullptr; + + if (waveIndex >= m_pInfoBlockBody->GetWaveFileCount()) + return nullptr; + + if (m_pLoadTable != nullptr) + return GetWaveFileForIndividual(waveIndex); + + return GetWaveFileForWhole(waveIndex); +} + bool WaveArchiveFileReader::HasIndividualLoadTable() const { if (!m_IsInitialized) return false; From 48415c66a281095731706324865536015bdb75f6 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 7 Sep 2026 20:15:39 -0300 Subject: [PATCH 578/785] atk: Match `WaveArchiveFileReader::SetWaveFile` This matches all exported functions in `WaveArchiveFileReader` --- include/nn/atk/atk_WaveArchiveFileReader.h | 4 ++-- .../atk/detail/atk_WaveArchiveFileReader.cpp | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_WaveArchiveFileReader.h b/include/nn/atk/atk_WaveArchiveFileReader.h index 8b781fd3..611eca94 100644 --- a/include/nn/atk/atk_WaveArchiveFileReader.h +++ b/include/nn/atk/atk_WaveArchiveFileReader.h @@ -24,14 +24,14 @@ class WaveArchiveFileReader { u32 GetWaveFileOffsetFromFileHead(u32 waveIndex) const; const void* GetWaveFile(u32 waveIndex) const; - void* SetWaveFile(u32 waveIndex, const void* pWaveFile); + const void* SetWaveFile(u32 waveIndex, const void* pWaveFile); bool IsLoaded(u32 waveIndex) { return m_IsInitialized && GetWaveFile(waveIndex) != nullptr; } bool HasIndividualLoadTable() const; struct IndividualLoadTable { - void* waveFile[1]; + const void* waveFile[1]; }; private: diff --git a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp index cec4a9a4..71c1458b 100644 --- a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp @@ -97,6 +97,22 @@ const void* WaveArchiveFileReader::GetWaveFile(u32 waveIndex) const { return GetWaveFileForWhole(waveIndex); } +const void* WaveArchiveFileReader::SetWaveFile(u32 waveIndex, const void* pWaveFile) { + if (!m_IsInitialized) + return nullptr; + + if (m_pLoadTable == nullptr) + return nullptr; + + if (waveIndex >= m_pInfoBlockBody->GetWaveFileCount()) + return nullptr; + + const void* preAddress{GetWaveFileForIndividual(waveIndex)}; + m_pLoadTable->waveFile[waveIndex] = pWaveFile; + + return preAddress; +} + bool WaveArchiveFileReader::HasIndividualLoadTable() const { if (!m_IsInitialized) return false; From 8dce7c4023e93ce6ce465acfcae81549e48e598d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 12:41:39 -0300 Subject: [PATCH 579/785] atk: Match `GroupFileReader` constructor --- include/nn/atk/atk_GroupFileReader.h | 16 +- .../atk/detail/atk_GroupFileReader.cpp | 53 +++ .../atk/detail/atk_SoundArchiveFile.cpp | 301 +++++++++--------- .../atk/detail/atk_WaveFileReader.cpp | 78 ++--- 4 files changed, 261 insertions(+), 187 deletions(-) diff --git a/include/nn/atk/atk_GroupFileReader.h b/include/nn/atk/atk_GroupFileReader.h index 9d46b3ae..a84ba139 100644 --- a/include/nn/atk/atk_GroupFileReader.h +++ b/include/nn/atk/atk_GroupFileReader.h @@ -3,18 +3,21 @@ #include namespace nn::atk::detail { + struct GroupItemLocationInfo { u32 fileId; - void* address; + const void* address; }; static_assert(sizeof(GroupItemLocationInfo) == 0x10); class GroupFileReader { public: - constexpr static s64 SignatureFile = 0x50524746; // FGRP + static const u32 SignatureFile{0x50524746}; // FGRP explicit GroupFileReader(const void* groupFile); + u32 GetGroupItemCount() const { return m_pInfoBlockBody->GetGroupItemInfoCount(); } + bool ReadGroupItemLocationInfo(GroupItemLocationInfo* out, u32 index) const; u32 GetGroupItemExCount() const; @@ -22,9 +25,10 @@ class GroupFileReader { bool ReadGroupItemInfoEx(GroupFile::GroupItemInfoEx* out, u32 index) const; private: - GroupFile::InfoBlockBody* m_pInfoBlockBody; - GroupFile::FileBlockBody* m_pFileBlockBody; - GroupFile::InfoExBlockBody* m_pInfoExBlockBody; + const GroupFile::InfoBlockBody* m_pInfoBlockBody{}; + const GroupFile::FileBlockBody* m_pFileBlockBody{}; + const GroupFile::InfoExBlockBody* m_pInfoExBlockBody{}; }; static_assert(sizeof(GroupFileReader) == 0x18); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/atk_GroupFileReader.cpp b/src/NintendoWare/atk/detail/atk_GroupFileReader.cpp index e69de29b..2199408f 100644 --- a/src/NintendoWare/atk/detail/atk_GroupFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_GroupFileReader.cpp @@ -0,0 +1,53 @@ +#include + +namespace nn::atk::detail { + +namespace { + +const u32 SignatureInfoBlockGroup{1330007625}; // INFO +const u32 SignatureFileBlockGroup{1162627398}; // FILE +const u32 SignatureInfoexBlockGroup{1481002569}; // INFX + +const u32 SupportedFileVersionGroup{0x10000}; +const u32 CurrentFileVersionGroup{0x10000}; + +bool IsValidFileHeaderGroup(const void* groupFile) { + const BinaryFileHeader* header{util::ConstBytePtr(groupFile).Get()}; + + bool isSupportedVersion{header->signature == GroupFileReader::SignatureFile && + header->byteOrder == BinaryFileHeader::ValidByteOrderMark && + header->version >= SupportedFileVersionGroup && + header->version <= CurrentFileVersionGroup}; + + return isSupportedVersion; +} + +} // anonymous namespace + +GroupFileReader::GroupFileReader(const void* groupFile) { + if (IsValidFileHeaderGroup(groupFile)) { + auto* header{reinterpret_cast(groupFile)}; + + const GroupFile::InfoBlock* infoBlock{header->GetInfoBlock()}; + const GroupFile::FileBlock* fileBlock{header->GetFileBlock()}; + const GroupFile::InfoExBlock* infoExBlock{header->GetInfoExBlock()}; + + if (infoBlock != nullptr && fileBlock != nullptr) { + if (infoBlock->header.kind != SignatureInfoBlockGroup || + fileBlock->header.kind != SignatureFileBlockGroup) + return; + + if (infoExBlock != nullptr) { + if (infoExBlock->header.kind != SignatureInfoexBlockGroup) + return; + + m_pInfoExBlockBody = &infoExBlock->body; + } + + m_pInfoBlockBody = &infoBlock->body; + m_pFileBlockBody = &fileBlock->body; + } + } +} + +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index b0af246b..d99c77f8 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -4,54 +4,51 @@ namespace nn::atk::detail { namespace { -const u32 DefaultStringId {0xffffffff}; -const PanMode DefaultPanMode {PanMode_Dual}; -const PanCurve DefaultPanCurve {PanCurve_Sqrt}; -const SinglePlayType DefaultSinglePlayType {SinglePlayType_None}; -const u16 DefaultSinglePlayEffectiveDuration {0xffff}; -const u8 DefaultPlayerPriority {64}; -const u8 DefaultChannelPriority {64}; -const u8 DefaultActorPlayerId {0}; -const u8 DefaultIsReleasePriorityFix {0}; -const bool DefaultIsFrontBypass {false}; -const u32 DefaultUserParam {0xffffffff}; -const u32 DefaultSeqStartOffset {0}; -const u32 DefaultWarcWaveCount {0}; -const u32 DefaultPlayerHeapSize {0}; + +const u32 DefaultStringId{0xffffffff}; +const PanMode DefaultPanMode{PanMode_Dual}; +const PanCurve DefaultPanCurve{PanCurve_Sqrt}; +const SinglePlayType DefaultSinglePlayType{SinglePlayType_None}; +const u16 DefaultSinglePlayEffectiveDuration{0xffff}; +const u8 DefaultPlayerPriority{64}; +const u8 DefaultChannelPriority{64}; +const u8 DefaultActorPlayerId{0}; +const u8 DefaultIsReleasePriorityFix{0}; +const bool DefaultIsFrontBypass{false}; +const u32 DefaultUserParam{0xffffffff}; +const u32 DefaultSeqStartOffset{0}; +const u32 DefaultWarcWaveCount{0}; +const u32 DefaultPlayerHeapSize{0}; enum SoundInfoBitFlag { - SoundInfoBitFlag_StringId = 0, - SoundInfoBitFlag_PanParam = 1, - SoundInfoBitFlag_PlayerParam = 2, - SoundInfoBitFlag_SinglePlayParam = 3, - - SoundInfoBitFlag_OffsetTo3dParam = 8, - SoundInfoBitFlag_OffsetToSendParam = 9, - SoundInfoBitFlag_OffsetToModParam = 10, - SoundInfoBitFlag_OffsetToRvlParam = 16, - SoundInfoBitFlag_OffsetToCtrParam = 17, - SoundInfoBitFlag_OffsetToCafeParam = 18, - - SoundInfoBitFlag_UserParam3 = 28, - SoundInfoBitFlag_UserParam2 = 29, - SoundInfoBitFlag_UserParam1 = 30, - SoundInfoBitFlag_UserParam = 31, + SoundInfoBitFlag_StringId = 0, + SoundInfoBitFlag_PanParam = 1, + SoundInfoBitFlag_PlayerParam = 2, + SoundInfoBitFlag_SinglePlayParam = 3, + + SoundInfoBitFlag_OffsetTo3dParam = 8, + SoundInfoBitFlag_OffsetToSendParam = 9, + SoundInfoBitFlag_OffsetToModParam = 10, + SoundInfoBitFlag_OffsetToRvlParam = 16, + SoundInfoBitFlag_OffsetToCtrParam = 17, + SoundInfoBitFlag_OffsetToCafeParam = 18, + + SoundInfoBitFlag_UserParam3 = 28, + SoundInfoBitFlag_UserParam2 = 29, + SoundInfoBitFlag_UserParam1 = 30, + SoundInfoBitFlag_UserParam = 31, }; -const int UserParamIndex[4] { - SoundInfoBitFlag_UserParam, - SoundInfoBitFlag_UserParam1, - SoundInfoBitFlag_UserParam2, - SoundInfoBitFlag_UserParam3 -}; +const int UserParamIndex[4]{SoundInfoBitFlag_UserParam, SoundInfoBitFlag_UserParam1, + SoundInfoBitFlag_UserParam2, SoundInfoBitFlag_UserParam3}; enum WaveSoundInfoBitFlag { WaveSoundInfoBitFlag_Priority = 0, }; enum SequenceSoundInfoBitFlag { - SequenceSoundInfoBitFlag_StartOffset = 0, - SequenceSoundInfoBitFlag_Priority = 1, + SequenceSoundInfoBitFlag_StartOffset = 0, + SequenceSoundInfoBitFlag_Priority = 1, }; enum BankInfoBitFlag { @@ -59,8 +56,8 @@ enum BankInfoBitFlag { }; enum PlayerInfoBitFlag { - PlayerInfoBitFlag_StringId = 0, - PlayerInfoBitFlag_HeapSize = 1, + PlayerInfoBitFlag_StringId = 0, + PlayerInfoBitFlag_HeapSize = 1, }; enum SoundGroupInfoBitFlag { @@ -72,13 +69,14 @@ enum GroupInfoBitFlag { }; enum WaveArchiveInfoBitFlag { - WaveArchiveInfoBitFlag_StringId = 0, - WaveArchiveInfoBitFlag_WaveCount = 1, + WaveArchiveInfoBitFlag_StringId = 0, + WaveArchiveInfoBitFlag_WaveCount = 1, }; -} // anonymous namespace + +} // anonymous namespace const Util::ReferenceWithSize* SoundArchiveFile::FileHeader::GetReferenceBy(u16 typeId) const { - for (int i {0}; i < BlockCount; ++i) { + for (int i{0}; i < BlockCount; ++i) { if (toBlocks[i].typeId == typeId) return &toBlocks[i]; } @@ -121,10 +119,10 @@ const char* SoundArchiveFile::StringBlockBody::GetString(SoundArchive::StringId if (stringId == SoundArchive::InvalidId) return nullptr; - const StringTable* table {GetStringTable()}; + const StringTable* table{GetStringTable()}; if (table == nullptr) return nullptr; - + return table->GetString(stringId); } @@ -133,20 +131,21 @@ void SoundArchiveFile::StringBlockBody::DumpTree() const { } u32 SoundArchiveFile::StringBlockBody::GetItemIdImpl(Sections section, const char* str) const { - const PatriciaTree* tree {GetPatriciaTree(section)}; - const PatriciaTree::NodeData* nodeData {tree->GetNodeDataBy(str)}; + const PatriciaTree* tree{GetPatriciaTree(section)}; + const PatriciaTree::NodeData* nodeData{tree->GetNodeDataBy(str)}; if (nodeData == nullptr) return SoundArchive::InvalidId; - const char* nodeDataStr {GetString(nodeData->stringId)}; + const char* nodeDataStr{GetString(nodeData->stringId)}; if (std::strcmp(str, nodeDataStr) != 0) return SoundArchive::InvalidId; return nodeData->itemId; } -const SoundArchiveFile::PatriciaTree::NodeData* SoundArchiveFile::PatriciaTree::GetNodeDataBy(const char* str, size_t len) const { +const SoundArchiveFile::PatriciaTree::NodeData* +SoundArchiveFile::PatriciaTree::GetNodeDataBy(const char* str, size_t len) const { if (rootIdx >= nodeTable.count) return nullptr; @@ -170,12 +169,13 @@ const SoundArchiveFile::PatriciaTree::NodeData* SoundArchiveFile::PatriciaTree:: return &node->nodeData; } -const SoundArchiveFile::SoundInfo* SoundArchiveFile::InfoBlockBody::GetSoundInfo(SoundArchive::ItemId itemId) const { +const SoundArchiveFile::SoundInfo* +SoundArchiveFile::InfoBlockBody::GetSoundInfo(SoundArchive::ItemId itemId) const { if (Util::GetItemType(itemId) != ItemType_Sound) return nullptr; - u32 index {Util::GetItemIndex(itemId)}; - const Util::ReferenceTable& table {GetSoundInfoReferenceTable()}; + u32 index{Util::GetItemIndex(itemId)}; + const Util::ReferenceTable& table{GetSoundInfoReferenceTable()}; if (index >= table.count) return nullptr; @@ -183,12 +183,13 @@ const SoundArchiveFile::SoundInfo* SoundArchiveFile::InfoBlockBody::GetSoundInfo return util::ConstBytePtr(table.GetReferedItem(index)).Get(); } -const SoundArchiveFile::BankInfo* SoundArchiveFile::InfoBlockBody::GetBankInfo(SoundArchive::ItemId itemId) const { +const SoundArchiveFile::BankInfo* +SoundArchiveFile::InfoBlockBody::GetBankInfo(SoundArchive::ItemId itemId) const { if (Util::GetItemType(itemId) != ItemType_Bank) return nullptr; - u32 index {Util::GetItemIndex(itemId)}; - const Util::ReferenceTable& table {GetBankInfoReferenceTable()}; + u32 index{Util::GetItemIndex(itemId)}; + const Util::ReferenceTable& table{GetBankInfoReferenceTable()}; if (index >= table.count) return nullptr; @@ -196,12 +197,13 @@ const SoundArchiveFile::BankInfo* SoundArchiveFile::InfoBlockBody::GetBankInfo(S return util::ConstBytePtr(table.GetReferedItem(index)).Get(); } -const SoundArchiveFile::PlayerInfo* SoundArchiveFile::InfoBlockBody::GetPlayerInfo(SoundArchive::ItemId itemId) const { +const SoundArchiveFile::PlayerInfo* +SoundArchiveFile::InfoBlockBody::GetPlayerInfo(SoundArchive::ItemId itemId) const { if (Util::GetItemType(itemId) != ItemType_Player) return nullptr; - u32 index {Util::GetItemIndex(itemId)}; - const Util::ReferenceTable& table {GetPlayerInfoReferenceTable()}; + u32 index{Util::GetItemIndex(itemId)}; + const Util::ReferenceTable& table{GetPlayerInfoReferenceTable()}; if (index >= table.count) return nullptr; @@ -209,12 +211,13 @@ const SoundArchiveFile::PlayerInfo* SoundArchiveFile::InfoBlockBody::GetPlayerIn return util::ConstBytePtr(table.GetReferedItem(index)).Get(); } -const SoundArchiveFile::SoundGroupInfo* SoundArchiveFile::InfoBlockBody::GetSoundGroupInfo(SoundArchive::ItemId itemId) const { +const SoundArchiveFile::SoundGroupInfo* +SoundArchiveFile::InfoBlockBody::GetSoundGroupInfo(SoundArchive::ItemId itemId) const { if (Util::GetItemType(itemId) != ItemType_SoundGroup) return nullptr; - u32 index {Util::GetItemIndex(itemId)}; - const Util::ReferenceTable& table {GetSoundGroupInfoReferenceTable()}; + u32 index{Util::GetItemIndex(itemId)}; + const Util::ReferenceTable& table{GetSoundGroupInfoReferenceTable()}; if (index >= table.count) return nullptr; @@ -222,12 +225,13 @@ const SoundArchiveFile::SoundGroupInfo* SoundArchiveFile::InfoBlockBody::GetSoun return util::ConstBytePtr(table.GetReferedItem(index)).Get(); } -const SoundArchiveFile::GroupInfo* SoundArchiveFile::InfoBlockBody::GetGroupInfo(SoundArchive::ItemId itemId) const { +const SoundArchiveFile::GroupInfo* +SoundArchiveFile::InfoBlockBody::GetGroupInfo(SoundArchive::ItemId itemId) const { if (Util::GetItemType(itemId) != ItemType_Group) return nullptr; - u32 index {Util::GetItemIndex(itemId)}; - const Util::ReferenceTable& table {GetGroupInfoReferenceTable()}; + u32 index{Util::GetItemIndex(itemId)}; + const Util::ReferenceTable& table{GetGroupInfoReferenceTable()}; if (index >= table.count) return nullptr; @@ -235,12 +239,13 @@ const SoundArchiveFile::GroupInfo* SoundArchiveFile::InfoBlockBody::GetGroupInfo return util::ConstBytePtr(table.GetReferedItem(index)).Get(); } -const SoundArchiveFile::WaveArchiveInfo* SoundArchiveFile::InfoBlockBody::GetWaveArchiveInfo(SoundArchive::ItemId itemId) const { +const SoundArchiveFile::WaveArchiveInfo* +SoundArchiveFile::InfoBlockBody::GetWaveArchiveInfo(SoundArchive::ItemId itemId) const { if (Util::GetItemType(itemId) != ItemType_WaveArchive) return nullptr; - u32 index {Util::GetItemIndex(itemId)}; - const Util::ReferenceTable& table {GetWaveArchiveInfoReferenceTable()}; + u32 index{Util::GetItemIndex(itemId)}; + const Util::ReferenceTable& table{GetWaveArchiveInfoReferenceTable()}; if (index >= table.count) return nullptr; @@ -248,9 +253,10 @@ const SoundArchiveFile::WaveArchiveInfo* SoundArchiveFile::InfoBlockBody::GetWav return util::ConstBytePtr(table.GetReferedItem(index)).Get(); } -const SoundArchiveFile::FileInfo* SoundArchiveFile::InfoBlockBody::GetFileInfo(SoundArchive::FileId itemId) const { - u32 index {Util::GetItemIndex(itemId)}; - const Util::ReferenceTable& table {GetFileInfoReferenceTable()}; +const SoundArchiveFile::FileInfo* +SoundArchiveFile::InfoBlockBody::GetFileInfo(SoundArchive::FileId itemId) const { + u32 index{Util::GetItemIndex(itemId)}; + const Util::ReferenceTable& table{GetFileInfoReferenceTable()}; if (index >= table.count) return nullptr; @@ -260,7 +266,7 @@ const SoundArchiveFile::FileInfo* SoundArchiveFile::InfoBlockBody::GetFileInfo(S u32 SoundArchiveFile::SoundInfo::GetStringId() const { u32 value; - bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; + bool result{optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; if (!result) return DefaultStringId; @@ -270,7 +276,7 @@ u32 SoundArchiveFile::SoundInfo::GetStringId() const { u32 SoundArchiveFile::BankInfo::GetStringId() const { u32 value; - bool result {optionParameter.GetValue(&value, BankInfoBitFlag_StringId)}; + bool result{optionParameter.GetValue(&value, BankInfoBitFlag_StringId)}; if (!result) return DefaultStringId; @@ -280,7 +286,7 @@ u32 SoundArchiveFile::BankInfo::GetStringId() const { u32 SoundArchiveFile::WaveArchiveInfo::GetStringId() const { u32 value; - bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; + bool result{optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; if (!result) return DefaultStringId; @@ -290,7 +296,7 @@ u32 SoundArchiveFile::WaveArchiveInfo::GetStringId() const { u32 SoundArchiveFile::SoundGroupInfo::GetStringId() const { u32 value; - bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; + bool result{optionParameter.GetValue(&value, SoundInfoBitFlag_StringId)}; if (!result) return DefaultStringId; @@ -300,7 +306,7 @@ u32 SoundArchiveFile::SoundGroupInfo::GetStringId() const { u32 SoundArchiveFile::GroupInfo::GetStringId() const { u32 value; - bool result {optionParameter.GetValue(&value, GroupInfoBitFlag_StringId)}; + bool result{optionParameter.GetValue(&value, GroupInfoBitFlag_StringId)}; if (!result) return DefaultStringId; @@ -310,7 +316,7 @@ u32 SoundArchiveFile::GroupInfo::GetStringId() const { u32 SoundArchiveFile::PlayerInfo::GetStringId() const { u32 value; - bool result {optionParameter.GetValue(&value, PlayerInfoBitFlag_StringId)}; + bool result{optionParameter.GetValue(&value, PlayerInfoBitFlag_StringId)}; if (!result) return DefaultStringId; @@ -318,44 +324,44 @@ u32 SoundArchiveFile::PlayerInfo::GetStringId() const { return value; } -const SoundArchiveFile::SoundArchivePlayerInfo* SoundArchiveFile::InfoBlockBody::GetSoundArchivePlayerInfo() const { - return util::ConstBytePtr(this, toSoundArchivePlayerInfo.offset) - .Get(); +const SoundArchiveFile::SoundArchivePlayerInfo* +SoundArchiveFile::InfoBlockBody::GetSoundArchivePlayerInfo() const { + return util::ConstBytePtr(this, toSoundArchivePlayerInfo.offset).Get(); } SoundArchive::FileId SoundArchiveFile::InfoBlockBody::GetItemFileId(SoundArchive::ItemId id) const { - SoundArchive::FileId fileId {SoundArchive::InvalidId}; + SoundArchive::FileId fileId{SoundArchive::InvalidId}; switch (Util::GetItemType(id)) { case ItemType_Sound: { - const SoundInfo* info {GetSoundInfo(id)}; + const SoundInfo* info{GetSoundInfo(id)}; if (info != nullptr) fileId = info->fileId; break; } case ItemType_Bank: { - const BankInfo* info {GetBankInfo(id)}; + const BankInfo* info{GetBankInfo(id)}; if (info != nullptr) fileId = info->fileId; break; } case ItemType_WaveArchive: { - const WaveArchiveInfo* info {GetWaveArchiveInfo(id)}; + const WaveArchiveInfo* info{GetWaveArchiveInfo(id)}; if (info != nullptr) fileId = info->fileId; break; } case ItemType_Group: { - const GroupInfo* info {GetGroupInfo(id)}; + const GroupInfo* info{GetGroupInfo(id)}; if (info != nullptr) fileId = info->fileId; break; } case ItemType_SoundGroup: { - const SoundGroupInfo* info {GetSoundGroupInfo(id)}; + const SoundGroupInfo* info{GetSoundGroupInfo(id)}; if (info != nullptr) { - SoundArchive::ItemId soundId {info->startId}; - const SoundInfo* soundInfo {GetSoundInfo(soundId)}; + SoundArchive::ItemId soundId{info->startId}; + const SoundInfo* soundInfo{GetSoundInfo(soundId)}; if (soundInfo != nullptr) fileId = soundInfo->fileId; } @@ -368,42 +374,43 @@ SoundArchive::FileId SoundArchiveFile::InfoBlockBody::GetItemFileId(SoundArchive return fileId; } -SoundArchive::StringId SoundArchiveFile::InfoBlockBody::GetItemStringId(SoundArchive::ItemId id) const { - SoundArchive::StringId stringId {SoundArchive::InvalidId}; +SoundArchive::StringId +SoundArchiveFile::InfoBlockBody::GetItemStringId(SoundArchive::ItemId id) const { + SoundArchive::StringId stringId{SoundArchive::InvalidId}; switch (Util::GetItemType(id)) { case ItemType_Sound: { - const SoundInfo* info {GetSoundInfo(id)}; + const SoundInfo* info{GetSoundInfo(id)}; if (info != nullptr) stringId = info->GetStringId(); break; } case ItemType_Bank: { - const BankInfo* info {GetBankInfo(id)}; + const BankInfo* info{GetBankInfo(id)}; if (info != nullptr) stringId = info->GetStringId(); break; } case ItemType_WaveArchive: { - const WaveArchiveInfo* info {GetWaveArchiveInfo(id)}; + const WaveArchiveInfo* info{GetWaveArchiveInfo(id)}; if (info != nullptr) stringId = info->GetStringId(); break; } case ItemType_Group: { - const GroupInfo* info {GetGroupInfo(id)}; + const GroupInfo* info{GetGroupInfo(id)}; if (info != nullptr) stringId = info->GetStringId(); break; } case ItemType_SoundGroup: { - const SoundGroupInfo* info {GetSoundGroupInfo(id)}; + const SoundGroupInfo* info{GetSoundGroupInfo(id)}; if (info != nullptr) stringId = info->GetStringId(); break; } case ItemType_Player: - const PlayerInfo* info {GetPlayerInfo(id)}; + const PlayerInfo* info{GetPlayerInfo(id)}; if (info != nullptr) stringId = info->GetStringId(); break; @@ -412,13 +419,14 @@ SoundArchive::StringId SoundArchiveFile::InfoBlockBody::GetItemStringId(SoundArc return stringId; } -SoundArchive::FileId SoundArchiveFile::InfoBlockBody::GetItemPrefetchFileId(SoundArchive::ItemId id) const { - SoundArchive::FileId fileId {SoundArchive::InvalidId}; +SoundArchive::FileId +SoundArchiveFile::InfoBlockBody::GetItemPrefetchFileId(SoundArchive::ItemId id) const { + SoundArchive::FileId fileId{SoundArchive::InvalidId}; - const SoundInfo* info {GetSoundInfo(id)}; + const SoundInfo* info{GetSoundInfo(id)}; if (info != nullptr && info->GetSoundType() == SoundArchive::SoundType_Stream) { - const SoundArchiveFile::StreamSoundInfo& streamSoundInfo {info->GetStreamSoundInfo()}; + const SoundArchiveFile::StreamSoundInfo& streamSoundInfo{info->GetStreamSoundInfo()}; fileId = streamSoundInfo.prefetchFileId; } @@ -426,45 +434,42 @@ SoundArchive::FileId SoundArchiveFile::InfoBlockBody::GetItemPrefetchFileId(Soun } const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetSoundInfoReferenceTable() const { - return *util::ConstBytePtr(this, toSoundInfoReferenceTable.offset) - .Get(); + return *util::ConstBytePtr(this, toSoundInfoReferenceTable.offset).Get(); } const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetBankInfoReferenceTable() const { - return *util::ConstBytePtr(this, toBankInfoReferenceTable.offset) - .Get(); + return *util::ConstBytePtr(this, toBankInfoReferenceTable.offset).Get(); } const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetPlayerInfoReferenceTable() const { - return *util::ConstBytePtr(this, toPlayerInfoReferenceTable.offset) - .Get(); + return *util::ConstBytePtr(this, toPlayerInfoReferenceTable.offset).Get(); } -const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetSoundGroupInfoReferenceTable() const { +const Util::ReferenceTable& +SoundArchiveFile::InfoBlockBody::GetSoundGroupInfoReferenceTable() const { return *util::ConstBytePtr(this, toSoundGroupInfoReferenceTable.offset) - .Get(); + .Get(); } -const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetWaveArchiveInfoReferenceTable() const { +const Util::ReferenceTable& +SoundArchiveFile::InfoBlockBody::GetWaveArchiveInfoReferenceTable() const { return *util::ConstBytePtr(this, toWaveArchiveInfoReferenceTable.offset) - .Get(); + .Get(); } const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetGroupInfoReferenceTable() const { - return *util::ConstBytePtr(this, toGroupInfoReferenceTable.offset) - .Get(); + return *util::ConstBytePtr(this, toGroupInfoReferenceTable.offset).Get(); } const Util::ReferenceTable& SoundArchiveFile::InfoBlockBody::GetFileInfoReferenceTable() const { - return *util::ConstBytePtr(this, toFileInfoReferenceTable.offset) - .Get(); + return *util::ConstBytePtr(this, toFileInfoReferenceTable.offset).Get(); } SoundArchive::SoundType SoundArchiveFile::SoundInfo::GetSoundType() const { switch (toDetailSoundInfo.typeId) { case ElementType_SoundArchiveFile_SequenceSoundInfo: return SoundArchive::SoundType_Sequence; - + case ElementType_SoundArchiveFile_StreamSoundInfo: return SoundArchive::SoundType_Stream; @@ -484,27 +489,29 @@ const SoundArchiveFile::WaveSoundInfo& SoundArchiveFile::SoundInfo::GetWaveSound return *util::ConstBytePtr(this, toDetailSoundInfo.offset).Get(); } -const SoundArchiveFile::AdvancedWaveSoundInfo& SoundArchiveFile::SoundInfo::GetAdvancedWaveSoundInfo() const { +const SoundArchiveFile::AdvancedWaveSoundInfo& +SoundArchiveFile::SoundInfo::GetAdvancedWaveSoundInfo() const { return *util::ConstBytePtr(this, toDetailSoundInfo.offset).Get(); } -const SoundArchiveFile::SequenceSoundInfo& SoundArchiveFile::SoundInfo::GetSequenceSoundInfo() const { +const SoundArchiveFile::SequenceSoundInfo& +SoundArchiveFile::SoundInfo::GetSequenceSoundInfo() const { return *util::ConstBytePtr(this, toDetailSoundInfo.offset).Get(); } const SoundArchiveFile::Sound3DInfo* SoundArchiveFile::SoundInfo::GetSound3DInfo() const { u32 offset; - bool result {optionParameter.GetValue(&offset, SoundInfoBitFlag_OffsetTo3dParam)}; - + bool result{optionParameter.GetValue(&offset, SoundInfoBitFlag_OffsetTo3dParam)}; + if (!result) return nullptr; - + return util::ConstBytePtr(this, offset).Get(); } PanMode SoundArchiveFile::SoundInfo::GetPanMode() const { u32 value; - bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_PanParam)}; + bool result{optionParameter.GetValue(&value, SoundInfoBitFlag_PanParam)}; if (!result) return DefaultPanMode; @@ -514,7 +521,7 @@ PanMode SoundArchiveFile::SoundInfo::GetPanMode() const { PanCurve SoundArchiveFile::SoundInfo::GetPanCurve() const { u32 value; - bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_PanParam)}; + bool result{optionParameter.GetValue(&value, SoundInfoBitFlag_PanParam)}; if (!result) return DefaultPanCurve; @@ -524,7 +531,7 @@ PanCurve SoundArchiveFile::SoundInfo::GetPanCurve() const { SinglePlayType SoundArchiveFile::SoundInfo::GetSinglePlayType() const { u32 value; - bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_SinglePlayParam)}; + bool result{optionParameter.GetValue(&value, SoundInfoBitFlag_SinglePlayParam)}; if (!result) return DefaultSinglePlayType; @@ -534,7 +541,7 @@ SinglePlayType SoundArchiveFile::SoundInfo::GetSinglePlayType() const { u16 SoundArchiveFile::SoundInfo::GetSinglePlayEffectiveDuration() const { u32 value; - bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_SinglePlayParam)}; + bool result{optionParameter.GetValue(&value, SoundInfoBitFlag_SinglePlayParam)}; if (!result) return DefaultSinglePlayEffectiveDuration; @@ -544,7 +551,7 @@ u16 SoundArchiveFile::SoundInfo::GetSinglePlayEffectiveDuration() const { u8 SoundArchiveFile::SoundInfo::GetPlayerPriority() const { u32 value; - bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_PlayerParam)}; + bool result{optionParameter.GetValue(&value, SoundInfoBitFlag_PlayerParam)}; if (!result) return DefaultPlayerPriority; @@ -554,7 +561,7 @@ u8 SoundArchiveFile::SoundInfo::GetPlayerPriority() const { u8 SoundArchiveFile::SoundInfo::GetActorPlayerId() const { u32 value; - bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_PlayerParam)}; + bool result{optionParameter.GetValue(&value, SoundInfoBitFlag_PlayerParam)}; if (!result) return DefaultActorPlayerId; @@ -564,7 +571,7 @@ u8 SoundArchiveFile::SoundInfo::GetActorPlayerId() const { u32 SoundArchiveFile::SoundInfo::GetUserParam() const { u32 value; - bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_UserParam)}; + bool result{optionParameter.GetValue(&value, SoundInfoBitFlag_UserParam)}; if (!result) return DefaultUserParam; @@ -578,7 +585,7 @@ bool SoundArchiveFile::SoundInfo::ReadUserParam(u32* pOutValue, int index) const bool SoundArchiveFile::SoundInfo::IsFrontBypass() const { u32 value; - bool result {optionParameter.GetValue(&value, SoundInfoBitFlag_OffsetToCtrParam)}; + bool result{optionParameter.GetValue(&value, SoundInfoBitFlag_OffsetToCtrParam)}; if (!result) return DefaultIsFrontBypass; @@ -586,18 +593,21 @@ bool SoundArchiveFile::SoundInfo::IsFrontBypass() const { return value & 1; } -const SoundArchiveFile::StreamTrackInfoTable* SoundArchiveFile::StreamSoundInfo::GetTrackInfoTable() const { +const SoundArchiveFile::StreamTrackInfoTable* +SoundArchiveFile::StreamSoundInfo::GetTrackInfoTable() const { if (!toTrackInfoTable.IsValidTypeId(ElementType_Table_ReferenceTable)) return nullptr; - + return util::ConstBytePtr(this, toTrackInfoTable.offset).Get(); } -const SoundArchiveFile::StreamSoundExtension* SoundArchiveFile::StreamSoundInfo::GetStreamSoundExtension() const { - if (!toStreamSoundExtension.IsValidOffset() || - !toStreamSoundExtension.IsValidTypeId(ElementType_SoundArchiveFile_StreamSoundExtensionInfo)) +const SoundArchiveFile::StreamSoundExtension* +SoundArchiveFile::StreamSoundInfo::GetStreamSoundExtension() const { + if (!toStreamSoundExtension.IsValidOffset() || + !toStreamSoundExtension.IsValidTypeId( + ElementType_SoundArchiveFile_StreamSoundExtensionInfo)) return nullptr; - + return util::ConstBytePtr(this, toStreamSoundExtension.offset).Get(); } @@ -607,7 +617,7 @@ const SoundArchiveFile::SendValue& SoundArchiveFile::StreamSoundInfo::GetSendVal u8 SoundArchiveFile::WaveSoundInfo::GetChannelPriority() const { u32 value; - bool result {optionParameter.GetValue(&value, WaveSoundInfoBitFlag_Priority)}; + bool result{optionParameter.GetValue(&value, WaveSoundInfoBitFlag_Priority)}; if (!result) return DefaultChannelPriority; @@ -617,7 +627,7 @@ u8 SoundArchiveFile::WaveSoundInfo::GetChannelPriority() const { u8 SoundArchiveFile::WaveSoundInfo::GetIsReleasePriorityFix() const { u32 value; - bool result {optionParameter.GetValue(&value, WaveSoundInfoBitFlag_Priority)}; + bool result{optionParameter.GetValue(&value, WaveSoundInfoBitFlag_Priority)}; if (!result) return DefaultIsReleasePriorityFix; @@ -630,15 +640,15 @@ const Util::Table& SoundArchiveFile::SequenceSoundInfo::GetBankIdTable() co } void SoundArchiveFile::SequenceSoundInfo::GetBankIds(u32* bankIds) const { - const Util::Table& table {GetBankIdTable()}; + const Util::Table& table{GetBankIdTable()}; - for (u32 i {0}; i < SoundArchive::SequenceBankMax; ++i) + for (u32 i{0}; i < SoundArchive::SequenceBankMax; ++i) bankIds[i] = i < table.count ? table.item[i] : SoundArchive::InvalidId; } u32 SoundArchiveFile::SequenceSoundInfo::GetStartOffset() const { u32 value; - bool result {optionParameter.GetValue(&value, SequenceSoundInfoBitFlag_StartOffset)}; + bool result{optionParameter.GetValue(&value, SequenceSoundInfoBitFlag_StartOffset)}; if (!result) return DefaultSeqStartOffset; @@ -648,7 +658,7 @@ u32 SoundArchiveFile::SequenceSoundInfo::GetStartOffset() const { u8 SoundArchiveFile::SequenceSoundInfo::GetChannelPriority() const { u32 value; - bool result {optionParameter.GetValue(&value, SequenceSoundInfoBitFlag_Priority)}; + bool result{optionParameter.GetValue(&value, SequenceSoundInfoBitFlag_Priority)}; if (!result) return DefaultChannelPriority; @@ -658,7 +668,7 @@ u8 SoundArchiveFile::SequenceSoundInfo::GetChannelPriority() const { bool SoundArchiveFile::SequenceSoundInfo::IsReleasePriorityFix() const { u32 value; - bool result {optionParameter.GetValue(&value, SequenceSoundInfoBitFlag_Priority)}; + bool result{optionParameter.GetValue(&value, SequenceSoundInfoBitFlag_Priority)}; if (!result) return DefaultIsReleasePriorityFix == 0; @@ -668,7 +678,7 @@ bool SoundArchiveFile::SequenceSoundInfo::IsReleasePriorityFix() const { u32 SoundArchiveFile::PlayerInfo::GetPlayerHeapSize() const { u32 value; - bool result {optionParameter.GetValue(&value, PlayerInfoBitFlag_HeapSize)}; + bool result{optionParameter.GetValue(&value, PlayerInfoBitFlag_HeapSize)}; if (!result) return DefaultPlayerHeapSize; @@ -678,7 +688,7 @@ u32 SoundArchiveFile::PlayerInfo::GetPlayerHeapSize() const { u32 SoundArchiveFile::WaveArchiveInfo::GetWaveCount() const { u32 value; - bool result {optionParameter.GetValue(&value, WaveArchiveInfoBitFlag_WaveCount)}; + bool result{optionParameter.GetValue(&value, WaveArchiveInfoBitFlag_WaveCount)}; if (!result) return DefaultWarcWaveCount; @@ -693,7 +703,7 @@ SoundArchiveFile::FileLocationType SoundArchiveFile::FileInfo::GetFileLocationTy case ElementType_SoundArchiveFile_ExternalFileInfo: return FileLocationType_External; - + case 0: return FileLocationType_None; @@ -715,4 +725,5 @@ const SoundArchiveFile::ExternalFileInfo* SoundArchiveFile::FileInfo::GetExterna return util::ConstBytePtr(this, toFileLocation.offset).Get(); } -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp b/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp index 8ec15ff0..1e3c8edb 100644 --- a/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp @@ -1,26 +1,29 @@ #include namespace nn::atk::detail { -const u32 SignatureInfoBlockWav {0x4f464e49}; // INFO -const u32 SignatureDataBlockWav {0x41544144}; // DATA -const u32 SupportedFileVersionWav {0x10000}; -const u32 CurrentFileVersionWav {0x10200}; +const u32 SignatureInfoBlockWav{0x4f464e49}; // INFO +const u32 SignatureDataBlockWav{0x41544144}; // DATA -const u32 IncludeOriginalLoopVersionWav {0x10200}; +const u32 SupportedFileVersionWav{0x10000}; +const u32 CurrentFileVersionWav{0x10200}; + +const u32 IncludeOriginalLoopVersionWav{0x10200}; namespace { + bool IsValidFileHeaderWav(const void* waveFile) { - const BinaryFileHeader& header {*util::ConstBytePtr(waveFile).Get()}; - - bool isSupportedVersion {header.signature == WaveFileReader::SignatureFile - && header.byteOrder == BinaryFileHeader::ValidByteOrderMark - && header.version >= SupportedFileVersionWav - && header.version <= CurrentFileVersionWav}; + const BinaryFileHeader& header{*util::ConstBytePtr(waveFile).Get()}; + + bool isSupportedVersion{header.signature == WaveFileReader::SignatureFile && + header.byteOrder == BinaryFileHeader::ValidByteOrderMark && + header.version >= SupportedFileVersionWav && + header.version <= CurrentFileVersionWav}; return isSupportedVersion; } -} + +} // namespace SampleFormat WaveFileReader::GetSampleFormat(u8 format) { switch (format) { @@ -41,11 +44,11 @@ WaveFileReader::WaveFileReader(const void* waveFile, s8 waveType) { case WaveType::WaveType_Nwwav: if (IsValidFileHeaderWav(waveFile)) { m_pHeader = util::ConstBytePtr(waveFile).Get(); - const WaveFile::InfoBlock* infoBlock {m_pHeader->GetInfoBlock()}; - const WaveFile::DataBlock* dataBlock {m_pHeader->GetDataBlock()}; + const WaveFile::InfoBlock* infoBlock{m_pHeader->GetInfoBlock()}; + const WaveFile::DataBlock* dataBlock{m_pHeader->GetDataBlock()}; - if (infoBlock != nullptr && infoBlock->header.kind == SignatureInfoBlockWav - && dataBlock != nullptr && dataBlock->header.kind == SignatureDataBlockWav) { + if (infoBlock != nullptr && infoBlock->header.kind == SignatureInfoBlockWav && + dataBlock != nullptr && dataBlock->header.kind == SignatureDataBlockWav) { m_pInfoBlockBody = &infoBlock->body; m_pDataBlockBody = &dataBlock->byte; } @@ -54,22 +57,22 @@ WaveFileReader::WaveFileReader(const void* waveFile, s8 waveType) { case WaveType::WaveType_Dspadpcm: m_DspadpcmReader.Initialize(waveFile); break; - case WaveType::WaveType_Invalid: + case WaveType::WaveType_Invalid: break; } } bool WaveFileReader::IsOriginalLoopAvailable() const { - const BinaryFileHeader& header {*util::ConstBytePtr(m_pHeader).Get()}; - + const BinaryFileHeader& header{*util::ConstBytePtr(m_pHeader).Get()}; + return header.version >= IncludeOriginalLoopVersionWav; } bool WaveFileReader::ReadWaveInfo(WaveInfo* info, const void* waveDataOffsetOrigin) const { switch (m_WaveType) { case WaveType_Nwwav: { - const SampleFormat format {GetSampleFormat(m_pInfoBlockBody->encoding)}; - const int channelCount {m_pInfoBlockBody->GetChannelCount()}; + const SampleFormat format{GetSampleFormat(m_pInfoBlockBody->encoding)}; + const int channelCount{m_pInfoBlockBody->GetChannelCount()}; info->sampleFormat = format; info->channelCount = channelCount; @@ -79,28 +82,29 @@ bool WaveFileReader::ReadWaveInfo(WaveInfo* info, const void* waveDataOffsetOrig info->loopEndFrame = m_pInfoBlockBody->loopEndFrame; info->dataSize = m_pHeader->header.fileSize - sizeof(Util::SoundFileHeader); - if (IsOriginalLoopAvailable()) + if (IsOriginalLoopAvailable()) info->originalLoopStartFrame = m_pInfoBlockBody->originalLoopStartFrame; else info->originalLoopStartFrame = m_pInfoBlockBody->loopStartFrame; - for (int i {0}; i < channelCount; ++i) { + for (int i{0}; i < channelCount; ++i) { if (i < 2) { - WaveInfo::ChannelParam& channelParam {info->channelParam[i]}; - const WaveFile::ChannelInfo& channelInfo {m_pInfoBlockBody->GetChannelInfo(i)}; - + WaveInfo::ChannelParam& channelParam{info->channelParam[i]}; + const WaveFile::ChannelInfo& channelInfo{m_pInfoBlockBody->GetChannelInfo(i)}; + if (channelInfo.referToAdpcmInfo.offset != 0) { - const WaveFile::DspAdpcmInfo& adpcmInfo {channelInfo.GetDspAdpcmInfo()}; + const WaveFile::DspAdpcmInfo& adpcmInfo{channelInfo.GetDspAdpcmInfo()}; channelParam.adpcmParam = adpcmInfo.adpcmParam; channelParam.adpcmLoopParam = adpcmInfo.adpcmLoopParam; } - + channelParam.dataAddress = GetWaveDataAddress(&channelInfo, waveDataOffsetOrigin); - - const WaveFile::ChannelInfo& lastChannelInfo {m_pInfoBlockBody->GetChannelInfo(channelCount - 1)}; - channelParam.dataSize = m_pHeader->GetDataBlock()->header.size - - sizeof(BinaryBlockHeader) - - lastChannelInfo.referToSamples.offset; + + const WaveFile::ChannelInfo& lastChannelInfo{ + m_pInfoBlockBody->GetChannelInfo(channelCount - 1)}; + channelParam.dataSize = m_pHeader->GetDataBlock()->header.size - + sizeof(BinaryBlockHeader) - + lastChannelInfo.referToSamples.offset; } } break; @@ -115,8 +119,10 @@ bool WaveFileReader::ReadWaveInfo(WaveInfo* info, const void* waveDataOffsetOrig return true; } -const void* WaveFileReader::GetWaveDataAddress(const WaveFile::ChannelInfo* info, - [[maybe_unused]] const void* waveDataOffsetOrigin) const { +const void* +WaveFileReader::GetWaveDataAddress(const WaveFile::ChannelInfo* info, + [[maybe_unused]] const void* waveDataOffsetOrigin) const { return info->GetSamplesAddress(m_pDataBlockBody); } -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail \ No newline at end of file From f2f3f6c110ea2d3ea10e9f6a2195eb8574b7a539 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 12:47:03 -0300 Subject: [PATCH 580/785] atk: Match `GroupFileReader::ReadGroupItemLocationInfo` --- include/nn/atk/atk_GroupFile.h | 25 ++++++++----------- .../atk/detail/atk_GroupFileReader.cpp | 14 +++++++++++ 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/include/nn/atk/atk_GroupFile.h b/include/nn/atk/atk_GroupFile.h index 8a7ecbd0..edc1a2d3 100644 --- a/include/nn/atk/atk_GroupFile.h +++ b/include/nn/atk/atk_GroupFile.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail { + struct GroupFile { struct InfoBlock; struct FileBlock; @@ -17,16 +18,14 @@ struct GroupFile { struct InfoBlockBody { Util::ReferenceTable referenceTableOfGroupItemInfo; - u32 GetGroupItemInfoCount() const { - return referenceTableOfGroupItemInfo.count; - } + u32 GetGroupItemInfoCount() const { return referenceTableOfGroupItemInfo.count; } const GroupItemInfo* GetGroupItemInfo(u32 index) const { if (GetGroupItemInfoCount() <= index) return nullptr; return util::ConstBytePtr(this, referenceTableOfGroupItemInfo.item[index].offset) - .Get(); + .Get(); } }; @@ -40,11 +39,10 @@ struct GroupFile { u32 fileId; Util::ReferenceWithSize embeddedItemInfo; - static const u32 OffsetForLink {0xffffffff}; - static const u32 SizeForLink {0xffffffff}; + static const u32 OffsetForLink{0xffffffff}; + static const u32 SizeForLink{0xffffffff}; const void* GetFileLocation(const FileBlockBody* fileBlockBody) const { - // TODO: check if this is int or u32 comparison if (static_cast(embeddedItemInfo.offset) == OffsetForLink) return nullptr; @@ -53,7 +51,9 @@ struct GroupFile { }; static_assert(sizeof(GroupItemInfo) == 0x10); - struct FileBlockBody {/* empty structure */}; + struct FileBlockBody { + /* empty structure */ + }; struct FileBlock { BinaryBlockHeader header; @@ -64,16 +64,14 @@ struct GroupFile { struct InfoExBlockBody { Util::ReferenceTable referenceTableOfGroupItemInfoEx; - u32 GetGroupItemInfoExCount() const { - return referenceTableOfGroupItemInfoEx.count; - } + u32 GetGroupItemInfoExCount() const { return referenceTableOfGroupItemInfoEx.count; } const GroupItemInfoEx* GetGroupItemInfoEx(u32 index) const { if (GetGroupItemInfoExCount() <= index) return nullptr; return util::ConstBytePtr(this, referenceTableOfGroupItemInfoEx.item[index].offset) - .Get(); + .Get(); } }; @@ -87,7 +85,6 @@ struct GroupFile { u32 loadFlag; }; static_assert(sizeof(GroupItemInfoEx) == 0x8); - }; -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/atk_GroupFileReader.cpp b/src/NintendoWare/atk/detail/atk_GroupFileReader.cpp index 2199408f..8003983c 100644 --- a/src/NintendoWare/atk/detail/atk_GroupFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_GroupFileReader.cpp @@ -50,4 +50,18 @@ GroupFileReader::GroupFileReader(const void* groupFile) { } } +bool GroupFileReader::ReadGroupItemLocationInfo(GroupItemLocationInfo* out, u32 index) const { + if (m_pInfoBlockBody == nullptr) + return false; + + const GroupFile::GroupItemInfo* groupItemInfo{m_pInfoBlockBody->GetGroupItemInfo(index)}; + if (groupItemInfo == nullptr) + return false; + + out->fileId = groupItemInfo->fileId; + out->address = groupItemInfo->GetFileLocation(m_pFileBlockBody); + + return true; +} + } // namespace nn::atk::detail \ No newline at end of file From 1b8ec76692abb6f64278914aa6ede5abb6c902db Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 12:48:11 -0300 Subject: [PATCH 581/785] atk: Match `GroupFileReader::GetGroupItemExCount` --- src/NintendoWare/atk/detail/atk_GroupFileReader.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_GroupFileReader.cpp b/src/NintendoWare/atk/detail/atk_GroupFileReader.cpp index 8003983c..9a0f3b14 100644 --- a/src/NintendoWare/atk/detail/atk_GroupFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_GroupFileReader.cpp @@ -64,4 +64,11 @@ bool GroupFileReader::ReadGroupItemLocationInfo(GroupItemLocationInfo* out, u32 return true; } +u32 GroupFileReader::GetGroupItemExCount() const { + if (m_pInfoExBlockBody == nullptr) + return 0; + + return m_pInfoExBlockBody->GetGroupItemInfoExCount(); +} + } // namespace nn::atk::detail \ No newline at end of file From 5ce8143d1ebb6b97774ec871c870ee224ad4ea57 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 12:49:24 -0300 Subject: [PATCH 582/785] atk: Match `GroupFileReader::ReadGroupItemInfoEx` This matches all exported functions in `GroupFileReader` --- src/NintendoWare/atk/detail/atk_GroupFileReader.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_GroupFileReader.cpp b/src/NintendoWare/atk/detail/atk_GroupFileReader.cpp index 9a0f3b14..b667bd82 100644 --- a/src/NintendoWare/atk/detail/atk_GroupFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_GroupFileReader.cpp @@ -71,4 +71,17 @@ u32 GroupFileReader::GetGroupItemExCount() const { return m_pInfoExBlockBody->GetGroupItemInfoExCount(); } +bool GroupFileReader::ReadGroupItemInfoEx(GroupFile::GroupItemInfoEx* out, u32 index) const { + if (m_pInfoExBlockBody == nullptr) + return false; + + const GroupFile::GroupItemInfoEx* groupItemInfo{m_pInfoExBlockBody->GetGroupItemInfoEx(index)}; + if (groupItemInfo == nullptr) + return false; + + *out = *groupItemInfo; + + return true; +} + } // namespace nn::atk::detail \ No newline at end of file From f5b9ad9921d7e36aa530a7702ecc20d005f945ec Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 13:01:28 -0300 Subject: [PATCH 583/785] atk: Match `Util::CalcPitchRatio` Using implementation from [TuneBloom](https://github.com/stupidestmodder/TuneBloom/blob/master/TuneBloom/src/snd-ply/Util.cpp#L504) --- src/NintendoWare/atk/detail/util/atk_Util.cpp | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/NintendoWare/atk/detail/util/atk_Util.cpp b/src/NintendoWare/atk/detail/util/atk_Util.cpp index 56729786..c346d314 100644 --- a/src/NintendoWare/atk/detail/util/atk_Util.cpp +++ b/src/NintendoWare/atk/detail/util/atk_Util.cpp @@ -688,6 +688,47 @@ float Util::CalcSurroundPanRatio(float surroundPan, const PanInfo& info) { return ratio; } +float Util::CalcPitchRatio(int pitch_) { + const int Range{PitchDivisionRange*12}; + + int pitch{pitch_}; + + int octave{0}; + + while (pitch < 0) { + --octave; + pitch += Range; + } + + while (pitch >= Range) { + ++octave; + pitch -= Range; + } + + int note{pitch / PitchDivisionRange}; + pitch -= note * PitchDivisionRange; + + f32 ratio{1.0f}; + + while (octave > 0) { + ratio *= 2.0f; + --octave; + } + + while (octave < 0) { + ratio /= 2.0f; + ++octave; + } + + if (note != 0) + ratio *= NoteTable[note]; + + if (pitch != 0) + ratio *= PitchTable[pitch]; + + return ratio; +} + float Util::CalcVolumeRatio(float dB) { dB = fnd::Clamp(dB, -90.4f, 6.0f); From d1bfe0b95428e823010e4e53678b560b31a3cd89 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 15:22:11 -0300 Subject: [PATCH 584/785] atk: Match `Channel` constructor --- include/nn/atk/atk_Channel.h | 264 ++++++++++++------ include/nn/atk/atk_CurveLfo.h | 10 +- include/nn/atk/atk_DisposeCallback.h | 2 + include/nn/atk/atk_DisposeCallbackManager.h | 2 + include/nn/atk/atk_Global.h | 17 +- include/nn/atk/atk_MoveValue.h | 31 +- include/nn/atk/atk_MultiVoice.h | 8 +- .../atk/detail/voice/atk_Channel.cpp | 20 ++ 8 files changed, 257 insertions(+), 97 deletions(-) diff --git a/include/nn/atk/atk_Channel.h b/include/nn/atk/atk_Channel.h index 1213a045..95cf3bc4 100644 --- a/include/nn/atk/atk_Channel.h +++ b/include/nn/atk/atk_Channel.h @@ -1,17 +1,26 @@ #pragma once -#include -#include -#include #include #include +#include +#include #include +#include +#include namespace nn::atk::detail::driver { + class ChannelManager; class Channel { public: + enum LfoTarget { + LfoTarget_Pitch = 0, + LfoTarget_Volume = 1, + LfoTarget_Pan = 2, + LfoTarget_Invalid = 255, + }; + enum ChannelCallbackStatus { ChannelCallbackStatus_Stopped, ChannelCallbackStatus_Drop, @@ -19,139 +28,230 @@ class Channel { ChannelCallbackStatus_Cancel, }; - enum LfoTarget { - LfoTarget_Pitch, - LfoTarget_Volume, - LfoTarget_Pan, - LfoTarget_Invalid = 0xff, - }; - - using ChannelCallback = void(*)(Channel*,ChannelCallbackStatus,void*); + using ChannelCallback = void (*)(Channel*, ChannelCallbackStatus, void*); - constexpr static u32 ChannelCount = 97; - constexpr static u32 ChannelMin = 0; - constexpr static u32 ChannelMax = 96; + static const int ChannelCount{193}; + static const int ChannelMin{0}; + static const int ChannelMax{ChannelCount - 1}; - constexpr static u32 PriorityRelease = 1; - - constexpr static u32 KeyInit = 60; - constexpr static u32 OriginalKeyInit = KeyInit; - - constexpr static u8 SilenceVolumeMax = 255; - constexpr static u8 SilenceVolumeMin = 0; + static const int PriorityRelease{1}; - constexpr static u32 WaveBufferMax = 2; +private: + static const int KeyInit{60}; + static const int OriginalKeyInit{KeyInit}; - constexpr static u32 ModCount = 4; + static const u8 SilenceVolumeMax{255}; + static const u8 SilenceVolumeMin{0}; + static const float SilenceVolumeMaxR; // = 1.0 / SilenceVolumeMax; - constexpr static f32 SilenceVolumeMaxR = 1.0 / SilenceVolumeMax; +public: + static Channel* AllocChannel(int voiceChannelCount, int priority, ChannelCallback callback, + void* callbackData); - class Disposer : DisposeCallback { - public: - ~Disposer() override; + static void FreeChannel(Channel* channel); + static void DetachChannel(Channel* channel); - void InvalidateData(const void* start, const void* end) override; +private: + static void VoiceCallbackFunc(MultiVoice* voice, MultiVoice::VoiceCallbackStatus status, + void* arg); - private: - Channel* m_pChannel; - }; +public: + static const int WaveBufferMax{2}; Channel(); ~Channel(); - void InitParam(ChannelCallback callback, void* callbackData); - void Update(bool doPeriodicProc); - void Stop(); - s32 GetSweepValue() const; - void UpdateSweep(s32 count); + void CallChannelCallback(ChannelCallbackStatus status); - void Start(const WaveInfo& waveInfo, s32 length, position_t startOffsetSamples); - void Start(const WaveInfo& waveInfo, s32 length, position_t startOffsetSamples, + void Start(const WaveInfo& waveInfo, int length, position_t startOffsetSamples); + void Start(const WaveInfo& waveInfo, int length, position_t startOffsetSamples, bool isContextCalculationSkipMode); - void AppendWaveBuffer(const WaveInfo& waveInfo, position_t startOffsetSamples); - void AppendWaveBuffer(const WaveInfo& waveInfo, position_t startOffsetSamples, - bool isContextCalculationSkipMode); - + void Stop(); + void Pause(bool flag); + + void NoteOff(); void Release(); + + bool IsActive() const { return m_ActiveFlag != 0; } + bool IsPause() const { return m_PauseFlag != 0; } + + void SetKey(u8 key) { m_Key = key; } + + void SetKey(u8 key, u8 originalKey) { + m_Key = key; + m_OriginalKey = originalKey; + } + + void SetInitPan(float pan) { m_InitPan = pan; } + void SetInitSurroundPan(float span) { m_InitSurroundPan = span; } + void SetTune(float tune) { m_Tune = tune; } + + void SetAttack(int attack) { m_CurveAdshr.SetAttack(attack); } + void SetHold(int hold) { m_CurveAdshr.SetHold(hold); } + void SetDecay(int decay) { m_CurveAdshr.SetDecay(decay); } + void SetSustain(int sustain) { m_CurveAdshr.SetSustain(sustain); } + void SetRelease(int release) { m_CurveAdshr.SetRelease(release); } + + void SetSilence(bool silenceFlag, int fadeTimes) { + m_SilenceVolume.SetTarget(silenceFlag ? SilenceVolumeMin : SilenceVolumeMax, fadeTimes); + } + + int GetLength() const { return m_Length; } + void SetLength(s32 length) { m_Length = length; } + + bool IsRelease() const { return m_CurveAdshr.GetStatus() == CurveAdshr::Status_Release; } + + void SetUserVolume(float volume) { m_UserVolume = volume; } + void SetUserPitch(float pitch) { m_UserPitch = pitch; } + void SetUserPitchRatio(float pitchRatio) { m_UserPitchRatio = pitchRatio; } + void SetUserLpfFreq(float lpfFreq) { m_UserLpfFreq = lpfFreq; } + + void SetBiquadFilter(int type, float value); + + void SetLfoParam(const CurveLfoParam& param, int i) { m_Lfo[i].SetParam(param); } + void SetLfoTarget(LfoTarget type, int i) { m_LfoTarget[i] = type; } + + void SetPriority(int priority); - void NoteOff(); + void SetReleasePriorityFix(bool fix) { m_ReleasePriorityFixFlag = fix; } + void SetIsIgnoreNoteOff(bool flag) { m_IsIgnoreNoteOff = flag; } + + void SetSweepParam(float sweepPitch, int sweepTime, bool autoUpdate) { + m_SweepPitch = sweepPitch; + m_SweepLength = sweepTime; + m_AutoSweep = autoUpdate; + m_SweepCounter = 0; + } + + bool IsAutoUpdateSweep() const { return m_AutoSweep != 0; } + void UpdateSweep(int count); + + void SetPanMode(PanMode panMode) { m_PanMode = panMode; } + void SetPanCurve(PanCurve panCurve) { m_PanCurve = panCurve; } + + void SetOutputLine(u32 lineFlag) { m_OutputLineFlag = lineFlag; } + u32 GetOutputLine() const { return m_OutputLineFlag; } + + void SetTvParam(const OutputParam& param) { m_TvParam = param; } + const OutputParam& GetTvParam() const { return m_TvParam; } - void SetSweepParam(f32 sweepPitch, s32 sweepTime, bool autoUpdate); - void SetBiquadFilter(s32 type, f32 value); #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) - void SetTvAdditionalParam(OutputAdditionalParam* param); + void SetTvAdditionalParamAddr(OutputAdditionalParam* param) { m_pTvAdditionalParam = param; } + const OutputAdditionalParam* const GetTvAdditionalParamAddr() const { + return m_pTvAdditionalParam; + } + OutputAdditionalParam* GetTvAdditionalParamAddr() { return m_pTvAdditionalParam; } + void SetTvAdditionalParam(const OutputAdditionalParam& param); #endif + void SetMainSend(float mainSend); + void SetUserPan(float pan); - position_t GetCurrentPlayingSample(bool) const; + Channel* GetNextTrackChannel() const { return m_pNextLink; } + void SetNextTrackChannel(Channel* channel) { m_pNextLink = channel; } - static void VoiceCallbackFunc(MultiVoice* voice, - MultiVoice::VoiceCallbackStatus status, void* arg); + position_t GetCurrentPlayingSample(bool isOriginalSamplePosition) const; - void CallChannelCallback(ChannelCallbackStatus status); + void SetKeyGroupId(u8 id) { m_KeyGroupId = id; } + u8 GetKeyGroupId() const { return m_KeyGroupId; } + + void SetInterpolationType(u8 type) { m_InterpolationType = type; } + u8 GetInterpolationType() const { return m_InterpolationType; } + + void SetInstrumentVolume(float instrumentVolume) { m_InstrumentVolume = instrumentVolume; } + void SetVelocity(float velocity) { m_Velocity = velocity; } + + static const int ModCount{4}; - static Channel* AllocChannel(s32 voiceChannelCount, s32 priority, - ChannelCallback callback, void* callbackData); + void SetUpdateType(UpdateType updateType) { m_pVoice->SetUpdateType(updateType); } + UpdateType GetUpdateType() const { return m_pVoice->GetUpdateType(); } - void FreeChannel(); - void DetachChannel(); + void SetOutputReceiver(OutputReceiver* pOutputReceiver) { + m_pVoice->SetOutputReceiver(pOutputReceiver); + } + + os::Tick GetProcessTick(const SoundProfile& profile) { + return m_pVoice->GetProcessTick(profile); + } private: - friend ChannelManager; + class Disposer : public DisposeCallback { + public: + Disposer() = default; + + void Initialize(Channel* channel) { m_pChannel = channel; } + + ~Disposer() override; + + void InvalidateData(const void* start, const void* end) override; + + private: + Channel* m_pChannel{}; + }; + + int GetSweepValue() const; + void InitParam(ChannelCallback callback, void* callbackData); + + void AppendWaveBuffer(const WaveInfo& waveInfo, position_t startOffsetSamples); + void AppendWaveBuffer(const WaveInfo& waveInfo, position_t startOffsetSamples, + bool isContextCalculationSkipMode); Disposer m_Disposer; CurveAdshr m_CurveAdshr; - CurveLfo m_Lfo[4]; - u8 m_LfoTarget[4]; - u8 m_PauseFlag; - u8 m_ActiveFlag; - u8 m_AllocFlag; + CurveLfo m_Lfo[ModCount]; + u8 m_LfoTarget[ModCount]; + u8 m_PauseFlag{0}; + u8 m_ActiveFlag{0}; + u8 m_AllocFlag{0}; u8 m_AutoSweep; u8 m_ReleasePriorityFixFlag; u8 m_IsIgnoreNoteOff; u8 m_BiquadType; u8 m_Padding[1]; - f32 m_UserVolume; - f32 m_UserPitchRatio; - f32 m_UserLpfFreq; - f32 m_BiquadValue; + float m_UserVolume; + float m_UserPitchRatio; + float m_UserLpfFreq; + float m_BiquadValue; u32 m_OutputLineFlag; OutputParam m_TvParam; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) - detail::OutputAdditionalParam* m_pTvAdditionalParam; + detail::OutputAdditionalParam* m_pTvAdditionalParam{}; #endif - f32 m_UserPitch; - f32 m_SweepPitch; - s32 m_SweepCounter; - s32 m_SweepLength; - f32 m_InitPan; - f32 m_InitSurroundPan; - f32 m_Tune; + float m_UserPitch; + float m_SweepPitch; + int m_SweepCounter; + int m_SweepLength; + float m_InitPan; + float m_InitSurroundPan; + float m_Tune; MoveValue m_SilenceVolume; - f32 m_Cent; - f32 m_CentPitch; - s32 m_Length; + float m_Cent; + float m_CentPitch; + int m_Length; PanMode m_PanMode; PanCurve m_PanCurve; u8 m_Key; u8 m_OriginalKey; u8 m_KeyGroupId; u8 m_InterpolationType; - f32 m_InstrumentVolume; - f32 m_Velocity; + float m_InstrumentVolume; + float m_Velocity; ChannelCallback m_Callback; void* m_CallbackData; - MultiVoice* m_pVoice; + MultiVoice* m_pVoice{}; Channel* m_pNextLink; - WaveBuffer m_WaveBuffer[2][2]; - AdpcmContext m_AdpcmContext[2]; - AdpcmContext m_AdpcmLoopContext[2]; + WaveBuffer m_WaveBuffer[WaveBufferMax][WaveChannelMax]; + AdpcmContext m_AdpcmContext[WaveChannelMax]; + AdpcmContext m_AdpcmLoopContext[WaveChannelMax]; position_t m_LoopStartFrame; position_t m_OriginalLoopStartFrame; bool m_LoopFlag; + +public: util::IntrusiveListNode m_Link; }; static_assert(sizeof(Channel) == 0x400); -} // namespace nn::atk::detail::driver \ No newline at end of file + +} // namespace nn::atk::detail::driver \ No newline at end of file diff --git a/include/nn/atk/atk_CurveLfo.h b/include/nn/atk/atk_CurveLfo.h index 96e652da..7be5531b 100644 --- a/include/nn/atk/atk_CurveLfo.h +++ b/include/nn/atk/atk_CurveLfo.h @@ -57,11 +57,11 @@ class CurveLfo { private: CurveLfoParam m_Param; - u32 m_DelayCounter; - float m_Counter; - mutable float m_RandomValue; - bool m_IsStart; - bool m_IsNext; + u32 m_DelayCounter{0}; + float m_Counter{0.0f}; + mutable float m_RandomValue{1.0f}; + bool m_IsStart{false}; + bool m_IsNext{false}; [[maybe_unused]] u8 m_Padding[2]; }; static_assert(sizeof(CurveLfo) == 0x20); diff --git a/include/nn/atk/atk_DisposeCallback.h b/include/nn/atk/atk_DisposeCallback.h index a71f557a..c9496f92 100644 --- a/include/nn/atk/atk_DisposeCallback.h +++ b/include/nn/atk/atk_DisposeCallback.h @@ -5,6 +5,8 @@ namespace nn::atk::detail::driver { class DisposeCallback { public: + DisposeCallback() = default; + virtual ~DisposeCallback() = default; virtual void InvalidateData(const void* start, const void* end) = 0; diff --git a/include/nn/atk/atk_DisposeCallbackManager.h b/include/nn/atk/atk_DisposeCallbackManager.h index 0fa9e60c..937ee071 100644 --- a/include/nn/atk/atk_DisposeCallbackManager.h +++ b/include/nn/atk/atk_DisposeCallbackManager.h @@ -20,6 +20,8 @@ class DisposeCallbackManager { void Dispose(const void* mem, size_t size); + static DisposeCallbackManager* GetInstance(); + private: CallbackList m_CallbackList; }; diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h index 1cd57866..2676f915 100644 --- a/include/nn/atk/atk_Global.h +++ b/include/nn/atk/atk_Global.h @@ -174,7 +174,7 @@ static_assert(sizeof(AdshrCurve) == 0x5); enum BiquadFilterType { BiquadFilterType_Inherit = -1, - + BiquadFilterType_None = 0, BiquadFilterType_LowPassFilter, BiquadFilterType_HighPassFilter, @@ -295,10 +295,21 @@ struct WaveBuffer { Status status; WaveBuffer* next; - WaveBuffer() = default; + WaveBuffer() { Initialize(); }; ~WaveBuffer(); - void Initialize(); + void Initialize() { + bufferAddress = nullptr; + bufferSize = 0; + sampleLength = 0; + sampleOffset = 0; + pAdpcmContext = nullptr; + userParam = nullptr; + loopFlag = false; + status = Status_Free; + next = nullptr; + } + void Dump(); }; static_assert(sizeof(WaveBuffer) == 0x40); diff --git a/include/nn/atk/atk_MoveValue.h b/include/nn/atk/atk_MoveValue.h index 7ded9061..ab04406f 100644 --- a/include/nn/atk/atk_MoveValue.h +++ b/include/nn/atk/atk_MoveValue.h @@ -14,16 +14,35 @@ class MoveValue { m_Frame = 0; } - void SetTarget(ValueType targetValue, CountType frames); + void SetTarget(ValueType targetValue, CountType frames) { + m_Origin = GetValue(); + m_Target = targetValue; + m_Frame = frames; + m_Counter = 0; + } + + ValueType GetTarget() const { return m_Target; } + + ValueType GetValue() const { + if (IsFinished()) + return m_Target; - ValueType GetTarget() const; - ValueType GetValue() const; + return static_cast(m_Origin + (m_Target - m_Origin) * m_Counter / m_Frame); + } + + void Update() { + if (m_Counter < m_Frame) + ++m_Counter; + } - void Update(); + bool IsFinished() const { return m_Counter >= m_Frame; } - bool IsFinished() const; + CountType GetRemainingCount() const { + if (IsFinished()) + return 0; - CountType GetRemainingCount() const; + return m_Frame - m_Counter; + } private: ValueType m_Origin{0}; diff --git a/include/nn/atk/atk_MultiVoice.h b/include/nn/atk/atk_MultiVoice.h index 4e610381..75b6e217 100644 --- a/include/nn/atk/atk_MultiVoice.h +++ b/include/nn/atk/atk_MultiVoice.h @@ -4,6 +4,7 @@ #include #include +#include namespace nn::atk::detail::driver { class MultiVoiceManager; @@ -119,6 +120,9 @@ class MultiVoice { void SetOutputReceiver(OutputReceiver* pOutputReceiver); #endif void SetSubMixIndex(s32 subMixIndex); + + void SetUpdateType(UpdateType updateType) { m_UpdateType = updateType; } + UpdateType GetUpdateType() const { return m_UpdateType; } #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) void CalcPreMixVolume(PreMixVolume* mix, const OutputParam& param, @@ -152,7 +156,9 @@ class MultiVoice { static u64 FrameToByte(s64, SampleFormat); static void CalcOffsetAdpcmParam(AdpcmContext* context, const AdpcmParam& param, position_t offsetSamples, const void* dataAddress); - + + os::Tick GetProcessTick(const SoundProfile& profile); + private: friend MultiVoiceManager; diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index e69de29b..71fbb1c9 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -0,0 +1,20 @@ +#include +#include "nn/atk/atk_DisposeCallbackManager.h" + +namespace nn::atk::detail::driver { + +namespace { + +u8 GetNwInterpolationTypeFromHardwareManager() { + // TODO + u8 result; +} + +} // anonymous namespace + +Channel::Channel() { + m_Disposer.Initialize(this); + DisposeCallbackManager::GetInstance()->RegisterDisposeCallback(&m_Disposer); +} + +} // namespace nn::atk::detail::driver \ No newline at end of file From 3504e77ac1e78c0b59c313754377a6d0f45c9c3f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 15:26:06 -0300 Subject: [PATCH 585/785] atk: Match `Channel` destructor --- include/nn/atk/atk_Channel.h | 4 ++-- include/nn/atk/atk_Global.h | 2 +- src/NintendoWare/atk/detail/voice/atk_Channel.cpp | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/nn/atk/atk_Channel.h b/include/nn/atk/atk_Channel.h index 95cf3bc4..a8b527eb 100644 --- a/include/nn/atk/atk_Channel.h +++ b/include/nn/atk/atk_Channel.h @@ -115,7 +115,7 @@ class Channel { void SetLfoTarget(LfoTarget type, int i) { m_LfoTarget[i] = type; } void SetPriority(int priority); - + void SetReleasePriorityFix(bool fix) { m_ReleasePriorityFixFlag = fix; } void SetIsIgnoreNoteOff(bool flag) { m_IsIgnoreNoteOff = flag; } @@ -183,7 +183,7 @@ class Channel { void Initialize(Channel* channel) { m_pChannel = channel; } - ~Disposer() override; + ~Disposer() override = default; void InvalidateData(const void* start, const void* end) override; diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h index 2676f915..bddb27d8 100644 --- a/include/nn/atk/atk_Global.h +++ b/include/nn/atk/atk_Global.h @@ -296,7 +296,7 @@ struct WaveBuffer { WaveBuffer* next; WaveBuffer() { Initialize(); }; - ~WaveBuffer(); + ~WaveBuffer() = default; void Initialize() { bufferAddress = nullptr; diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index 71fbb1c9..a94d6a3d 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -1,5 +1,6 @@ #include -#include "nn/atk/atk_DisposeCallbackManager.h" + +#include namespace nn::atk::detail::driver { @@ -17,4 +18,8 @@ Channel::Channel() { DisposeCallbackManager::GetInstance()->RegisterDisposeCallback(&m_Disposer); } +Channel::~Channel() { + DisposeCallbackManager::GetInstance()->UnregisterDisposeCallback(&m_Disposer); +} + } // namespace nn::atk::detail::driver \ No newline at end of file From 679f080983463f3c0a73b628fbb13982cc50fb0b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 15:27:53 -0300 Subject: [PATCH 586/785] atk: Match `Channel::CallChannelCallback` --- src/NintendoWare/atk/detail/voice/atk_Channel.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index a94d6a3d..dc46946e 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -22,4 +22,13 @@ Channel::~Channel() { DisposeCallbackManager::GetInstance()->UnregisterDisposeCallback(&m_Disposer); } +void Channel::CallChannelCallback(ChannelCallbackStatus status) { + if (m_Callback == nullptr) + return; + + m_Callback(this, status, m_CallbackData); + m_Callback = nullptr; + m_CallbackData = nullptr; +} + } // namespace nn::atk::detail::driver \ No newline at end of file From 40c44601732421e17cab193575a24a754ec9b9ec Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 15:33:08 -0300 Subject: [PATCH 587/785] atk: Match `Channel::Start` --- include/nn/atk/atk_CurveAdshr.h | 2 +- .../atk/detail/voice/atk_Channel.cpp | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_CurveAdshr.h b/include/nn/atk/atk_CurveAdshr.h index ac5c78a9..a2fb775f 100644 --- a/include/nn/atk/atk_CurveAdshr.h +++ b/include/nn/atk/atk_CurveAdshr.h @@ -29,7 +29,7 @@ class CurveAdshr { CurveAdshr(); void Initialize(float initDecibel); - void Reset(float initDecibel); + void Reset(float initDecibel = VolumeInit); void Update(int msec); float GetValue() const; diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index dc46946e..6f1fa66a 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -31,4 +31,44 @@ void Channel::CallChannelCallback(ChannelCallbackStatus status) { m_CallbackData = nullptr; } +void Channel::Start(const WaveInfo& waveInfo, int length, position_t startOffsetSamples) { + m_Length = length; + + for (int i{0}; i < ModCount; ++i) + m_Lfo[i].Reset(); + + m_CurveAdshr.Reset(); + + m_SweepCounter = 0; + m_pVoice->SetSampleFormat(waveInfo.sampleFormat); + m_pVoice->SetSampleRate(waveInfo.sampleRate); + m_pVoice->SetInterpolationType(m_InterpolationType); + + AppendWaveBuffer(waveInfo, startOffsetSamples); + + m_pVoice->Start(); + + m_ActiveFlag = 1; +} + +void Channel::Start(const WaveInfo& waveInfo, int length, position_t startOffsetSamples, bool isContextCalculationSkipMode) { + m_Length = length; + + for (int i{0}; i < ModCount; ++i) + m_Lfo[i].Reset(); + + m_CurveAdshr.Reset(); + + m_SweepCounter = 0; + m_pVoice->SetSampleFormat(waveInfo.sampleFormat); + m_pVoice->SetSampleRate(waveInfo.sampleRate); + m_pVoice->SetInterpolationType(m_InterpolationType); + + AppendWaveBuffer(waveInfo, startOffsetSamples, isContextCalculationSkipMode); + + m_pVoice->Start(); + + m_ActiveFlag = 1; +} + } // namespace nn::atk::detail::driver \ No newline at end of file From 4f00909651924749ec1f83ff380c592425a59e56 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 15:34:25 -0300 Subject: [PATCH 588/785] atk: Match `Channel::Stop` --- src/NintendoWare/atk/detail/voice/atk_Channel.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index 6f1fa66a..2b831d75 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -71,4 +71,16 @@ void Channel::Start(const WaveInfo& waveInfo, int length, position_t startOffset m_ActiveFlag = 1; } +void Channel::Stop() { + if (m_pVoice == nullptr) + return; + + m_pVoice->Stop(); + m_pVoice->Free(); + + m_pVoice = nullptr; + m_PauseFlag = 0; + m_ActiveFlag = 0; +} + } // namespace nn::atk::detail::driver \ No newline at end of file From f67ab260e7298ca61b8a5aff90e32be6193a07a2 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 15:40:52 -0300 Subject: [PATCH 589/785] atk: Match `Channel::Release` --- include/nn/atk/atk_Channel.h | 6 +++++- .../atk/detail/voice/atk_Channel.cpp | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/include/nn/atk/atk_Channel.h b/include/nn/atk/atk_Channel.h index a8b527eb..54dae8d0 100644 --- a/include/nn/atk/atk_Channel.h +++ b/include/nn/atk/atk_Channel.h @@ -70,7 +70,11 @@ class Channel { bool isContextCalculationSkipMode); void Stop(); - void Pause(bool flag); + + void Pause(bool flag) { + m_PauseFlag = flag; + m_pVoice->Pause(m_PauseFlag); + } void NoteOff(); void Release(); diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index 2b831d75..c5395f53 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -47,11 +47,12 @@ void Channel::Start(const WaveInfo& waveInfo, int length, position_t startOffset AppendWaveBuffer(waveInfo, startOffsetSamples); m_pVoice->Start(); - + m_ActiveFlag = 1; } -void Channel::Start(const WaveInfo& waveInfo, int length, position_t startOffsetSamples, bool isContextCalculationSkipMode) { +void Channel::Start(const WaveInfo& waveInfo, int length, position_t startOffsetSamples, + bool isContextCalculationSkipMode) { m_Length = length; for (int i{0}; i < ModCount; ++i) @@ -83,4 +84,15 @@ void Channel::Stop() { m_ActiveFlag = 0; } +void Channel::Release() { + if (!IsRelease()) { + if (m_pVoice != nullptr && m_ReleasePriorityFixFlag == 0) + m_pVoice->SetPriority(PriorityRelease); + + m_CurveAdshr.SetStatus(CurveAdshr::Status_Release); + } + + m_PauseFlag = 0; +} + } // namespace nn::atk::detail::driver \ No newline at end of file From 9e83064338e6533a29ce182d00c295c5084e4b9f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 15:41:34 -0300 Subject: [PATCH 590/785] atk: Match `Channel::NoteOff` --- src/NintendoWare/atk/detail/voice/atk_Channel.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index c5395f53..65d8fd79 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -84,6 +84,13 @@ void Channel::Stop() { m_ActiveFlag = 0; } +void Channel::NoteOff() { + if (m_IsIgnoreNoteOff != 0) + return; + + Release(); +} + void Channel::Release() { if (!IsRelease()) { if (m_pVoice != nullptr && m_ReleasePriorityFixFlag == 0) From b7d67290a24d90c42f3ea997d0e78383d4d600a2 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 15:43:57 -0300 Subject: [PATCH 591/785] atk: Match `Channel::UpdateSweep` --- include/nn/atk/atk_Channel.h | 2 +- src/NintendoWare/atk/detail/voice/atk_Channel.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_Channel.h b/include/nn/atk/atk_Channel.h index 54dae8d0..c5ad48c6 100644 --- a/include/nn/atk/atk_Channel.h +++ b/include/nn/atk/atk_Channel.h @@ -118,7 +118,7 @@ class Channel { void SetLfoParam(const CurveLfoParam& param, int i) { m_Lfo[i].SetParam(param); } void SetLfoTarget(LfoTarget type, int i) { m_LfoTarget[i] = type; } - void SetPriority(int priority); + void SetPriority(int priority) { m_pVoice->SetPriority(priority); } void SetReleasePriorityFix(bool fix) { m_ReleasePriorityFixFlag = fix; } void SetIsIgnoreNoteOff(bool flag) { m_IsIgnoreNoteOff = flag; } diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index 65d8fd79..cdd53c48 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -102,4 +102,9 @@ void Channel::Release() { m_PauseFlag = 0; } +void Channel::UpdateSweep(int count) { + m_SweepCounter = + m_SweepCounter + count <= m_SweepLength ? m_SweepCounter + count : m_SweepLength; +} + } // namespace nn::atk::detail::driver \ No newline at end of file From fcf1596ba168d7adfd2656bb4b1a27f5c0495c3a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 15:45:53 -0300 Subject: [PATCH 592/785] atk: Match `Channel::SetTvAdditionalParam` --- src/NintendoWare/atk/detail/voice/atk_Channel.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index cdd53c48..108b7002 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -107,4 +107,12 @@ void Channel::UpdateSweep(int count) { m_SweepCounter + count <= m_SweepLength ? m_SweepCounter + count : m_SweepLength; } +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) +void Channel::SetTvAdditionalParam(const OutputAdditionalParam& param) { + if (m_pTvAdditionalParam != nullptr) + *m_pTvAdditionalParam = param; +} + +#endif + } // namespace nn::atk::detail::driver \ No newline at end of file From f972e562306c403a7c529eeb9759a5fd56b954b1 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 20:50:48 -0300 Subject: [PATCH 593/785] atk: Match `Channel::GetCurrentPlayingSample` --- include/nn/atk/atk_Channel.h | 6 +++++- .../atk/detail/voice/atk_Channel.cpp | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_Channel.h b/include/nn/atk/atk_Channel.h index c5ad48c6..e4def097 100644 --- a/include/nn/atk/atk_Channel.h +++ b/include/nn/atk/atk_Channel.h @@ -171,10 +171,11 @@ class Channel { void SetUpdateType(UpdateType updateType) { m_pVoice->SetUpdateType(updateType); } UpdateType GetUpdateType() const { return m_pVoice->GetUpdateType(); } - +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) void SetOutputReceiver(OutputReceiver* pOutputReceiver) { m_pVoice->SetOutputReceiver(pOutputReceiver); } +#endif os::Tick GetProcessTick(const SoundProfile& profile) { return m_pVoice->GetProcessTick(profile); @@ -249,6 +250,9 @@ class Channel { WaveBuffer m_WaveBuffer[WaveBufferMax][WaveChannelMax]; AdpcmContext m_AdpcmContext[WaveChannelMax]; AdpcmContext m_AdpcmLoopContext[WaveChannelMax]; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) + u32 m_StartOffsetSamples; +#endif position_t m_LoopStartFrame; position_t m_OriginalLoopStartFrame; bool m_LoopFlag; diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index 108b7002..13752e37 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -112,7 +112,24 @@ void Channel::SetTvAdditionalParam(const OutputAdditionalParam& param) { if (m_pTvAdditionalParam != nullptr) *m_pTvAdditionalParam = param; } - #endif +position_t Channel::GetCurrentPlayingSample(bool isOriginalSamplePosition) const { + if (m_ActiveFlag == 0) + return 0; + + position_t playSamplePosition{m_pVoice->GetCurrentPlayingSample()}; + + if (isOriginalSamplePosition && m_LoopFlag) { + position_t loopEnd{m_WaveBuffer[0][0].sampleLength + + (-m_LoopStartFrame + m_OriginalLoopStartFrame)}; + position_t originalLoopEnd{m_OriginalLoopStartFrame + playSamplePosition - loopEnd}; + + if (playSamplePosition > loopEnd) + playSamplePosition = originalLoopEnd; + } + + return playSamplePosition; +} + } // namespace nn::atk::detail::driver \ No newline at end of file From cf73085ffa1ceb8e336e0664c5e4595d7dd2a9e5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 20:52:59 -0300 Subject: [PATCH 594/785] atk: Match `Channel::SetBiquadFilter` --- src/NintendoWare/atk/detail/voice/atk_Channel.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index 13752e37..1cc08602 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -102,6 +102,11 @@ void Channel::Release() { m_PauseFlag = 0; } +void Channel::SetBiquadFilter(int type, float value) { + m_BiquadType = static_cast(type); + m_BiquadValue = value; +} + void Channel::UpdateSweep(int count) { m_SweepCounter = m_SweepCounter + count <= m_SweepLength ? m_SweepCounter + count : m_SweepLength; From 9c6e9e2ecd7e4336750ac0f063adb535f38eaf2a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 21:01:49 -0300 Subject: [PATCH 595/785] atk: Match `Channel::AllocChannel` --- include/nn/atk/atk_ChannelManager.h | 2 ++ include/nn/atk/atk_MultiVoiceManager.h | 2 ++ .../atk/detail/voice/atk_Channel.cpp | 27 +++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/include/nn/atk/atk_ChannelManager.h b/include/nn/atk/atk_ChannelManager.h index 2d4b41a0..4b8a2cfb 100644 --- a/include/nn/atk/atk_ChannelManager.h +++ b/include/nn/atk/atk_ChannelManager.h @@ -25,6 +25,8 @@ class ChannelManager { void UpdateAllChannel(); void UpdateAudioFrameChannel(); + static ChannelManager* GetInstance(); + private: ChannelPool m_Pool; ChannelList m_ChannelList; diff --git a/include/nn/atk/atk_MultiVoiceManager.h b/include/nn/atk/atk_MultiVoiceManager.h index 2e08495d..a9fc647f 100644 --- a/include/nn/atk/atk_MultiVoiceManager.h +++ b/include/nn/atk/atk_MultiVoiceManager.h @@ -44,6 +44,8 @@ class MultiVoiceManager { VoiceList* GetVoiceList() const; + static MultiVoiceManager* GetInstance(); + private: bool m_Initialized; VoiceList m_PrioVoiceList; diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index 1cc08602..21bcf65f 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -1,6 +1,8 @@ #include +#include #include +#include namespace nn::atk::detail::driver { @@ -13,6 +15,31 @@ u8 GetNwInterpolationTypeFromHardwareManager() { } // anonymous namespace +Channel* Channel::AllocChannel(int voiceChannelCount, int priority, ChannelCallback callback, + void* callbackData) { + Channel* channel{ChannelManager::GetInstance()->Alloc()}; + + if (channel == nullptr) { + Util::WarningLogger::GetInstance().Log(0, 0, 0); + return nullptr; + } + + channel->m_AllocFlag = 1; + + MultiVoice* voice{MultiVoiceManager::GetInstance()->AllocVoice(voiceChannelCount, priority, + VoiceCallbackFunc, channel)}; + + if (voice == nullptr) { + ChannelManager::GetInstance()->Free(channel); + return nullptr; + } + + channel->m_pVoice = voice; + channel->InitParam(callback, callbackData); + + return channel; +} + Channel::Channel() { m_Disposer.Initialize(this); DisposeCallbackManager::GetInstance()->RegisterDisposeCallback(&m_Disposer); From 492718462d2ca5f4f36c07cf0c504d1445237dfe Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 21:03:40 -0300 Subject: [PATCH 596/785] atk: Match `Channel::FreeChannel` --- src/NintendoWare/atk/detail/voice/atk_Channel.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index 21bcf65f..3aacb7b0 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -30,7 +30,7 @@ Channel* Channel::AllocChannel(int voiceChannelCount, int priority, ChannelCallb VoiceCallbackFunc, channel)}; if (voice == nullptr) { - ChannelManager::GetInstance()->Free(channel); + FreeChannel(channel); return nullptr; } @@ -40,6 +40,10 @@ Channel* Channel::AllocChannel(int voiceChannelCount, int priority, ChannelCallb return channel; } +void Channel::FreeChannel(Channel *channel) { + ChannelManager::GetInstance()->Free(channel); +} + Channel::Channel() { m_Disposer.Initialize(this); DisposeCallbackManager::GetInstance()->RegisterDisposeCallback(&m_Disposer); From 53efa0322aaffea4be91a694ae4dda367c3d6f56 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 21:04:42 -0300 Subject: [PATCH 597/785] atk: Match `Channel::DetachChannel` --- include/nn/atk/atk_Channel.h | 1 - src/NintendoWare/atk/detail/voice/atk_Channel.cpp | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_Channel.h b/include/nn/atk/atk_Channel.h index e4def097..56c3a157 100644 --- a/include/nn/atk/atk_Channel.h +++ b/include/nn/atk/atk_Channel.h @@ -47,7 +47,6 @@ class Channel { public: static Channel* AllocChannel(int voiceChannelCount, int priority, ChannelCallback callback, void* callbackData); - static void FreeChannel(Channel* channel); static void DetachChannel(Channel* channel); diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index 3aacb7b0..be9e0593 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -40,10 +40,15 @@ Channel* Channel::AllocChannel(int voiceChannelCount, int priority, ChannelCallb return channel; } -void Channel::FreeChannel(Channel *channel) { +void Channel::FreeChannel(Channel* channel) { ChannelManager::GetInstance()->Free(channel); } +void Channel::DetachChannel(Channel* channel) { + channel->m_Callback = nullptr; + channel->m_CallbackData = nullptr; +} + Channel::Channel() { m_Disposer.Initialize(this); DisposeCallbackManager::GetInstance()->RegisterDisposeCallback(&m_Disposer); From 560ce4cfedb694aeb5c3848f6f1634775c4f6c32 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 21:17:47 -0300 Subject: [PATCH 598/785] atk: Match `Channel::VoiceCallbackFunc` --- .../atk/detail/voice/atk_Channel.cpp | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index be9e0593..ba189471 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -49,6 +49,39 @@ void Channel::DetachChannel(Channel* channel) { channel->m_CallbackData = nullptr; } +void Channel::VoiceCallbackFunc(MultiVoice* voice, MultiVoice::VoiceCallbackStatus status, + void* arg) { + ChannelCallbackStatus chStatus{ChannelCallbackStatus_Finish}; + auto* channel{static_cast(arg)}; + + switch (status) { + case MultiVoice::VoiceCallbackStatus_FinishWave: + voice->Free(); + chStatus = ChannelCallbackStatus_Finish; + break; + + case MultiVoice::VoiceCallbackStatus_Cancel: + voice->Free(); + chStatus = ChannelCallbackStatus_Cancel; + break; + + case MultiVoice::VoiceCallbackStatus_DropVoice: + chStatus = ChannelCallbackStatus_Drop; + break; + + case MultiVoice::VoiceCallbackStatus_DropDsp: + chStatus = ChannelCallbackStatus_Drop; + break; + } + + channel->CallChannelCallback(chStatus); + + channel->m_pVoice = nullptr; + channel->m_PauseFlag = 0; + channel->m_ActiveFlag = 0; + channel->m_AllocFlag = 0; +} + Channel::Channel() { m_Disposer.Initialize(this); DisposeCallbackManager::GetInstance()->RegisterDisposeCallback(&m_Disposer); From 5b013863ddd053fe1346cf9ddf3d615e92a8772c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 21:22:21 -0300 Subject: [PATCH 599/785] atk: Match `Channel::SetSweepParam` --- include/nn/atk/atk_Channel.h | 7 +------ src/NintendoWare/atk/detail/voice/atk_Channel.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/nn/atk/atk_Channel.h b/include/nn/atk/atk_Channel.h index 56c3a157..78f1971b 100644 --- a/include/nn/atk/atk_Channel.h +++ b/include/nn/atk/atk_Channel.h @@ -122,12 +122,7 @@ class Channel { void SetReleasePriorityFix(bool fix) { m_ReleasePriorityFixFlag = fix; } void SetIsIgnoreNoteOff(bool flag) { m_IsIgnoreNoteOff = flag; } - void SetSweepParam(float sweepPitch, int sweepTime, bool autoUpdate) { - m_SweepPitch = sweepPitch; - m_SweepLength = sweepTime; - m_AutoSweep = autoUpdate; - m_SweepCounter = 0; - } + void SetSweepParam(float sweepPitch, int sweepTime, bool autoUpdate); bool IsAutoUpdateSweep() const { return m_AutoSweep != 0; } void UpdateSweep(int count); diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index ba189471..14afc2bf 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -176,6 +176,13 @@ void Channel::SetBiquadFilter(int type, float value) { m_BiquadValue = value; } +void Channel::SetSweepParam(float sweepPitch, int sweepTime, bool autoUpdate) { + m_SweepPitch = sweepPitch; + m_SweepLength = sweepTime; + m_AutoSweep = autoUpdate; + m_SweepCounter = 0; +} + void Channel::UpdateSweep(int count) { m_SweepCounter = m_SweepCounter + count <= m_SweepLength ? m_SweepCounter + count : m_SweepLength; From 271e6258b17447413b37bb618908ffb58b95e9c5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 21:43:55 -0300 Subject: [PATCH 600/785] atk: Match `Channel::GetSweepValue` --- include/nn/atk/atk_Channel.h | 2 +- src/NintendoWare/atk/detail/voice/atk_Channel.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_Channel.h b/include/nn/atk/atk_Channel.h index 78f1971b..4906bfc9 100644 --- a/include/nn/atk/atk_Channel.h +++ b/include/nn/atk/atk_Channel.h @@ -190,7 +190,7 @@ class Channel { Channel* m_pChannel{}; }; - int GetSweepValue() const; + float GetSweepValue() const; void InitParam(ChannelCallback callback, void* callbackData); void AppendWaveBuffer(const WaveInfo& waveInfo, position_t startOffsetSamples); diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index 14afc2bf..6d098258 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -213,4 +213,18 @@ position_t Channel::GetCurrentPlayingSample(bool isOriginalSamplePosition) const return playSamplePosition; } +float Channel::GetSweepValue() const { + if (m_SweepPitch == 0.0f) + return 0.0f; + + if (m_SweepCounter >= m_SweepLength) + return 0.0f; + + float sweep{m_SweepPitch}; + sweep *= static_cast(m_SweepLength - m_SweepCounter); + sweep /= static_cast(m_SweepLength); + + return sweep; +} + } // namespace nn::atk::detail::driver \ No newline at end of file From ae7e67c2bce1e58417ab77140acad7e060070c23 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 8 Sep 2026 22:08:13 -0300 Subject: [PATCH 601/785] atk: Match `Channel::InitParam` --- include/nn/atk/atk_CurveAdshr.h | 2 +- include/nn/atk/atk_HardwareManager.h | 13 ++- include/nn/atk/atk_MoveValue.h | 2 +- .../atk/detail/voice/atk_Channel.cpp | 91 ++++++++++++++++++- 4 files changed, 102 insertions(+), 6 deletions(-) diff --git a/include/nn/atk/atk_CurveAdshr.h b/include/nn/atk/atk_CurveAdshr.h index a2fb775f..4fa9c358 100644 --- a/include/nn/atk/atk_CurveAdshr.h +++ b/include/nn/atk/atk_CurveAdshr.h @@ -28,7 +28,7 @@ class CurveAdshr { CurveAdshr(); - void Initialize(float initDecibel); + void Initialize(float initDecibel = VolumeInit); void Reset(float initDecibel = VolumeInit); void Update(int msec); float GetValue() const; diff --git a/include/nn/atk/atk_HardwareManager.h b/include/nn/atk/atk_HardwareManager.h index df63b34e..2cf88f2b 100644 --- a/include/nn/atk/atk_HardwareManager.h +++ b/include/nn/atk/atk_HardwareManager.h @@ -12,9 +12,11 @@ #include #include #include +#include namespace nn::atk::detail::driver { -class HardwareManager { // inherits nn::atk::Util::Singleton + +class HardwareManager : public Util::Singleton { public: using SubMixList = util::IntrusiveList>; @@ -219,9 +221,15 @@ class HardwareManager { // inherits nn::atk::Util::Singleton static void FlushDataCache(void* address, size_t length); + SampleRateConverterType GetSrcType() const { return m_SrcType; } + private: bool m_IsInitialized; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) audio::AudioRendererHandle m_RendererHandle; +#else + audio::AudioRendererHandle* m_RendererHandle; +#endif audio::AudioRendererConfig m_Config; os::SystemEvent m_SystemEvent; s32 m_AudioRendererSuspendCount; @@ -274,5 +282,6 @@ class HardwareManager { // inherits nn::atk::Util::Singleton bool m_IsCompatibleBusVolumeEnabled; bool m_IsUserThreadRenderingEnabled; }; -static_assert(sizeof(HardwareManager) == 0xa58); +// static_assert(sizeof(HardwareManager) == 0xa58); + } // namespace nn::atk::detail::driver \ No newline at end of file diff --git a/include/nn/atk/atk_MoveValue.h b/include/nn/atk/atk_MoveValue.h index ab04406f..83bb576c 100644 --- a/include/nn/atk/atk_MoveValue.h +++ b/include/nn/atk/atk_MoveValue.h @@ -10,8 +10,8 @@ class MoveValue { void InitValue(ValueType value) { m_Origin = value; m_Target = value; - m_Counter = 0; m_Frame = 0; + m_Counter = 0; } void SetTarget(ValueType targetValue, CountType frames) { diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index 6d098258..f98455f6 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -2,6 +2,7 @@ #include #include +#include #include namespace nn::atk::detail::driver { @@ -9,8 +10,24 @@ namespace nn::atk::detail::driver { namespace { u8 GetNwInterpolationTypeFromHardwareManager() { - // TODO - u8 result; + u8 result{0}; + + switch (HardwareManager::GetInstance().GetSrcType()) { + case SampleRateConverterType_None: + result = 2; + break; + + case SampleRateConverterType_Linear: + result = 1; + break; + + case SampleRateConverterType_4Tap: + // result = 0; + break; + + } + + return result; } } // anonymous namespace @@ -227,4 +244,74 @@ float Channel::GetSweepValue() const { return sweep; } +void Channel::InitParam(ChannelCallback callback, void* callbackData) { + m_pNextLink = nullptr; + + m_Callback = callback; + m_CallbackData = callbackData; + + m_PauseFlag = 0; + m_AutoSweep = 1; + m_ReleasePriorityFixFlag = 0; + m_IsIgnoreNoteOff = 0; + + m_LoopFlag = false; + m_LoopStartFrame = 0; + m_OriginalLoopStartFrame = 0; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) + m_StartOffsetSamples = 0; +#endif + m_Length = 0; + + m_Key = KeyInit; + m_OriginalKey = OriginalKeyInit; + + m_InitPan = 0.0f; + m_InitSurroundPan = 0.0f; + + m_Tune = 1.0f; + + m_Cent = 0.0f; + m_CentPitch = 1.0f; + + m_UserVolume = 1.0f; + m_UserPitch = 0.0f; + m_UserPitchRatio = 1.0f; + m_UserLpfFreq = 0.0f; + + m_BiquadType = BiquadFilterType_None; + m_BiquadValue = 0.0f; + + m_OutputLineFlag = OutputLine_Main; + + m_TvParam.Initialize(); +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) + if (m_pTvAdditionalParam != nullptr) + m_pTvAdditionalParam->Reset(); +#endif + + m_SilenceVolume.InitValue(SilenceVolumeMax); + + m_SweepPitch = 0.0f; + m_SweepCounter = 0; + m_SweepLength = 0; + + m_CurveAdshr.Initialize(); + for (int i{0}; i < ModCount; ++i) { + m_Lfo[i].GetParam().Initialize(); + m_LfoTarget[i] = LfoTarget_Invalid; + } + + m_PanMode = PanMode_Dual; + m_PanCurve = PanCurve_Sqrt; + + m_KeyGroupId = 0; + + m_InterpolationType = GetNwInterpolationTypeFromHardwareManager(); + + m_InstrumentVolume = 1.0f; + + m_Velocity = 1.0f; +} + } // namespace nn::atk::detail::driver \ No newline at end of file From 7d6f80638284765e16f5c36bce3b50f4d148366e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 9 Sep 2026 16:40:19 -0300 Subject: [PATCH 602/785] atk: Match `Channel::Disposer::InvalidateData` --- include/nn/atk/atk_MultiVoice.h | 2 + .../atk/detail/voice/atk_Channel.cpp | 37 ++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_MultiVoice.h b/include/nn/atk/atk_MultiVoice.h index 75b6e217..8921a552 100644 --- a/include/nn/atk/atk_MultiVoice.h +++ b/include/nn/atk/atk_MultiVoice.h @@ -142,6 +142,8 @@ class MultiVoice { MultiVoice* detail_GetSdkVoice(s32) const; + int GetSdkVoiceCount() const { return m_ChannelCount; } + position_t GetCurrentPlayingSample() const; SampleFormat GetFormat() const; diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index f98455f6..629c49ac 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -20,11 +20,10 @@ u8 GetNwInterpolationTypeFromHardwareManager() { case SampleRateConverterType_Linear: result = 1; break; - + case SampleRateConverterType_4Tap: // result = 0; break; - } return result; @@ -230,6 +229,40 @@ position_t Channel::GetCurrentPlayingSample(bool isOriginalSamplePosition) const return playSamplePosition; } +void Channel::Disposer::InvalidateData(const void* start, const void* end) { + if (m_pChannel->m_pVoice == nullptr) + return; + + bool disposeFlag{false}; + int sdkVoiceCount{m_pChannel->m_pVoice->GetSdkVoiceCount()}; + + for (int channelIndex{0}; channelIndex < sdkVoiceCount; ++channelIndex) { + for (int waveBufferIndex{0}; waveBufferIndex < WaveBufferMax; ++waveBufferIndex) { + const WaveBuffer& waveBuffer{m_pChannel->m_WaveBuffer[channelIndex][waveBufferIndex]}; + + if (waveBuffer.status == WaveBuffer::Status_Done) + continue; + + const void* bufferEnd{ + util::ConstBytePtr(waveBuffer.bufferAddress, + Util::GetByteBySample(waveBuffer.sampleLength, + m_pChannel->m_pVoice->GetFormat())) + .Get()}; + + if (start <= bufferEnd && end >= waveBuffer.bufferAddress) { + disposeFlag = true; + break; + } + } + } + + if (disposeFlag) { + m_pChannel->CallChannelCallback(ChannelCallbackStatus_Cancel); + m_pChannel->Stop(); + Channel::FreeChannel(m_pChannel); + } +} + float Channel::GetSweepValue() const { if (m_SweepPitch == 0.0f) return 0.0f; From e34eab37cfed3645fa2d9814c655f3218f6e1e02 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 9 Sep 2026 17:48:25 -0300 Subject: [PATCH 603/785] atk: Match `Channel::AppendWaveBuffer` --- include/nn/atk/atk_Channel.h | 2 +- include/nn/audio/audio_Adpcm.h | 2 +- .../atk/detail/voice/atk_Channel.cpp | 94 +++++++++++++++++++ 3 files changed, 96 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_Channel.h b/include/nn/atk/atk_Channel.h index 4906bfc9..65e80e4d 100644 --- a/include/nn/atk/atk_Channel.h +++ b/include/nn/atk/atk_Channel.h @@ -245,7 +245,7 @@ class Channel { AdpcmContext m_AdpcmContext[WaveChannelMax]; AdpcmContext m_AdpcmLoopContext[WaveChannelMax]; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) - u32 m_StartOffsetSamples; + position_t m_StartOffsetSamples; #endif position_t m_LoopStartFrame; position_t m_OriginalLoopStartFrame; diff --git a/include/nn/audio/audio_Adpcm.h b/include/nn/audio/audio_Adpcm.h index 7597e060..123e8abc 100644 --- a/include/nn/audio/audio_Adpcm.h +++ b/include/nn/audio/audio_Adpcm.h @@ -10,7 +10,7 @@ struct AdpcmContext { static_assert(sizeof(AdpcmContext) == 0x6); struct AdpcmParameter { - u16 coefficients[16] = {0}; + u16 coefficients[16]; }; static_assert(sizeof(AdpcmParameter) == 0x20); } // namespace nn::audio \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index 629c49ac..2910f35c 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -347,4 +347,98 @@ void Channel::InitParam(ChannelCallback callback, void* callbackData) { m_Velocity = 1.0f; } +void Channel::AppendWaveBuffer(const WaveInfo& waveInfo, position_t startOffsetSamples, + bool isContextCalculationSkipMode) { + m_LoopFlag = waveInfo.loopFlag; + m_LoopStartFrame = waveInfo.loopStartFrame; + m_OriginalLoopStartFrame = waveInfo.originalLoopStartFrame; + + if (startOffsetSamples > 0 && waveInfo.sampleFormat == SampleFormat_DspAdpcm) + startOffsetSamples = startOffsetSamples / 14 * 14; + +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) + m_StartOffsetSamples = startOffsetSamples; +#endif + + const int sdkVoiceCount{m_pVoice->GetSdkVoiceCount()}; + + for (int ch{0}; ch < sdkVoiceCount; ++ch) { + const void* originalDataAddress{waveInfo.channelParam[ch].dataAddress}; + + AdpcmContext& adpcmContext{m_AdpcmContext[ch]}; + AdpcmContext& adpcmLoopContext{m_AdpcmLoopContext[ch]}; + + if (waveInfo.sampleFormat == SampleFormat_DspAdpcm) { + const DspAdpcmParam* pParam{&waveInfo.channelParam[ch].adpcmParam}; + + AdpcmParam param; + for (int i{0}; i < 8; ++i) { + for (int j{0}; j < 2; ++j) + param.coefficients[(i * sizeof(u16)) + j] = pParam->coef[i][j]; + } + + if (startOffsetSamples == 0) { + adpcmContext.audioAdpcmContext.predScale = pParam->predScale; + adpcmContext.audioAdpcmContext.history[0] = static_cast(pParam->yn1); + adpcmContext.audioAdpcmContext.history[1] = static_cast(pParam->yn2); + } else if (isContextCalculationSkipMode) { + adpcmContext.audioAdpcmContext.predScale = 0; + adpcmContext.audioAdpcmContext.history[0] = 0; + adpcmContext.audioAdpcmContext.history[1] = 0; + } else { + adpcmContext.audioAdpcmContext.predScale = pParam->predScale; + adpcmContext.audioAdpcmContext.history[0] = static_cast(pParam->yn1); + adpcmContext.audioAdpcmContext.history[1] = static_cast(pParam->yn2); + MultiVoice::CalcOffsetAdpcmParam(&adpcmContext, param, startOffsetSamples, + originalDataAddress); + } + + if (waveInfo.loopFlag) { + const DspAdpcmLoopParam* pLoopParam{&waveInfo.channelParam[ch].adpcmLoopParam}; + adpcmLoopContext.audioAdpcmContext.predScale = pLoopParam->loopPredScale; + adpcmLoopContext.audioAdpcmContext.history[0] = + static_cast(pLoopParam->loopYn1); + adpcmLoopContext.audioAdpcmContext.history[1] = + static_cast(pLoopParam->loopYn2); + } + + m_pVoice->SetAdpcmParam(ch, param); + } + + { + WaveBuffer* pBuffer0{&m_WaveBuffer[ch][0]}; + WaveBuffer* pBuffer1{&m_WaveBuffer[ch][1]}; + + pBuffer0->bufferAddress = originalDataAddress; + pBuffer0->bufferSize = waveInfo.channelParam[ch].dataSize; + pBuffer0->sampleOffset = startOffsetSamples; + pBuffer0->sampleLength = waveInfo.loopEndFrame; + pBuffer0->loopFlag = false; + + if (waveInfo.sampleFormat == SampleFormat_DspAdpcm) + pBuffer0->pAdpcmContext = &adpcmContext; + else + pBuffer0->pAdpcmContext = nullptr; + + if (waveInfo.loopFlag) { + pBuffer1->bufferAddress = originalDataAddress; + pBuffer1->bufferSize = waveInfo.channelParam[ch].dataSize; + pBuffer1->sampleOffset = m_LoopStartFrame; + pBuffer1->sampleLength = waveInfo.loopEndFrame; + pBuffer1->loopFlag = true; + + if (waveInfo.sampleFormat == SampleFormat_DspAdpcm) + pBuffer1->pAdpcmContext = &adpcmLoopContext; + else + pBuffer1->pAdpcmContext = nullptr; + + m_pVoice->AppendWaveBuffer(ch, pBuffer0, false); + m_pVoice->AppendWaveBuffer(ch, pBuffer1, true); + } else { + m_pVoice->AppendWaveBuffer(ch, pBuffer0, true); + } + } + } +} + } // namespace nn::atk::detail::driver \ No newline at end of file From e4d30aee15dc2bd3c4a1abde22b2112264002bba Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 9 Sep 2026 18:03:10 -0300 Subject: [PATCH 604/785] atk: Add version specific guards for `Channel` --- include/nn/atk/atk_Channel.h | 7 +++- .../atk/detail/voice/atk_Channel.cpp | 41 ++++++++----------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/include/nn/atk/atk_Channel.h b/include/nn/atk/atk_Channel.h index 65e80e4d..fafb63da 100644 --- a/include/nn/atk/atk_Channel.h +++ b/include/nn/atk/atk_Channel.h @@ -63,10 +63,12 @@ class Channel { void Update(bool doPeriodicProc); void CallChannelCallback(ChannelCallbackStatus status); - +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) void Start(const WaveInfo& waveInfo, int length, position_t startOffsetSamples); +#else void Start(const WaveInfo& waveInfo, int length, position_t startOffsetSamples, bool isContextCalculationSkipMode); +#endif void Stop(); @@ -193,9 +195,12 @@ class Channel { float GetSweepValue() const; void InitParam(ChannelCallback callback, void* callbackData); +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) void AppendWaveBuffer(const WaveInfo& waveInfo, position_t startOffsetSamples); +#else void AppendWaveBuffer(const WaveInfo& waveInfo, position_t startOffsetSamples, bool isContextCalculationSkipMode); +#endif Disposer m_Disposer; CurveAdshr m_CurveAdshr; diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index 2910f35c..364259b6 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -116,7 +116,12 @@ void Channel::CallChannelCallback(ChannelCallbackStatus status) { m_CallbackData = nullptr; } -void Channel::Start(const WaveInfo& waveInfo, int length, position_t startOffsetSamples) { +void Channel::Start(const WaveInfo& waveInfo, int length, position_t startOffsetSamples +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) + , + bool isContextCalculationSkipMode +#endif +) { m_Length = length; for (int i{0}; i < ModCount; ++i) @@ -129,28 +134,11 @@ void Channel::Start(const WaveInfo& waveInfo, int length, position_t startOffset m_pVoice->SetSampleRate(waveInfo.sampleRate); m_pVoice->SetInterpolationType(m_InterpolationType); +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) AppendWaveBuffer(waveInfo, startOffsetSamples); - - m_pVoice->Start(); - - m_ActiveFlag = 1; -} - -void Channel::Start(const WaveInfo& waveInfo, int length, position_t startOffsetSamples, - bool isContextCalculationSkipMode) { - m_Length = length; - - for (int i{0}; i < ModCount; ++i) - m_Lfo[i].Reset(); - - m_CurveAdshr.Reset(); - - m_SweepCounter = 0; - m_pVoice->SetSampleFormat(waveInfo.sampleFormat); - m_pVoice->SetSampleRate(waveInfo.sampleRate); - m_pVoice->SetInterpolationType(m_InterpolationType); - +#else AppendWaveBuffer(waveInfo, startOffsetSamples, isContextCalculationSkipMode); +#endif m_pVoice->Start(); @@ -347,8 +335,12 @@ void Channel::InitParam(ChannelCallback callback, void* callbackData) { m_Velocity = 1.0f; } -void Channel::AppendWaveBuffer(const WaveInfo& waveInfo, position_t startOffsetSamples, - bool isContextCalculationSkipMode) { +void Channel::AppendWaveBuffer(const WaveInfo& waveInfo, position_t startOffsetSamples +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) + , + bool isContextCalculationSkipMode +#endif +) { m_LoopFlag = waveInfo.loopFlag; m_LoopStartFrame = waveInfo.loopStartFrame; m_OriginalLoopStartFrame = waveInfo.originalLoopStartFrame; @@ -381,10 +373,13 @@ void Channel::AppendWaveBuffer(const WaveInfo& waveInfo, position_t startOffsetS adpcmContext.audioAdpcmContext.predScale = pParam->predScale; adpcmContext.audioAdpcmContext.history[0] = static_cast(pParam->yn1); adpcmContext.audioAdpcmContext.history[1] = static_cast(pParam->yn2); +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) } else if (isContextCalculationSkipMode) { adpcmContext.audioAdpcmContext.predScale = 0; adpcmContext.audioAdpcmContext.history[0] = 0; adpcmContext.audioAdpcmContext.history[1] = 0; + +#endif } else { adpcmContext.audioAdpcmContext.predScale = pParam->predScale; adpcmContext.audioAdpcmContext.history[0] = static_cast(pParam->yn1); From 8601811b2b550513da2cacad41d0339e0c159633 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 10 Sep 2026 21:09:27 -0300 Subject: [PATCH 605/785] atk: Match `LowLevelVoice::Initialize` --- include/nn/atk/atk_LowLevelVoice.h | 22 +++++++++---------- .../atk/detail/voice/atk_LowLevelVoice.cpp | 17 ++++++++++++++ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/include/nn/atk/atk_LowLevelVoice.h b/include/nn/atk/atk_LowLevelVoice.h index e29ba08c..e4b45599 100644 --- a/include/nn/atk/atk_LowLevelVoice.h +++ b/include/nn/atk/atk_LowLevelVoice.h @@ -78,7 +78,6 @@ class alignas(64) LowLevelVoice { void SetVoiceMixVolume(float mixVolume, int destinationIndex); float GetClampedVoiceVolume(float volume); - AdpcmParam m_AdpcmParam{}; audio::VoiceType m_Voice{}; bool m_IsAvailable{false}; @@ -100,37 +99,38 @@ class alignas(64) LowLevelVoice { Voice* m_pVoice{}; audio::NodeId m_NodeId{0}; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) - bool _ec{true}; //0xec + bool _ec{true}; // 0xec #endif }; static_assert(sizeof(LowLevelVoice) == 0x100); class LowLevelVoiceAllocator { public: - constexpr static u32 Unassigned = -1; + static const int Unassigned{-1}; LowLevelVoiceAllocator(); - size_t GetRequiredMemSize(s32 voiceCount); + size_t GetRequiredMemSize(int voiceCount); - void Initialize(s32 voiceCount, void* mem, size_t memSize); + void Initialize(int voiceCount, void* mem, size_t memSize); void Finalize(); void UpdateAllVoiceState(OutputMode outputMode); LowLevelVoice* AllocVoice(); - u64 GetVoiceArrayIndex(LowLevelVoice* pVoice); void FreeVoice(LowLevelVoice* pVoice); - s32* GetDroppedVoiceCount() const; + int GetDroppedVoiceCount() const; + + ptrdiff_t GetVoiceArrayIndex(LowLevelVoice* pVoice); private: void* m_pVoiceArray{}; LowLevelVoice** m_ppVoiceTable{}; - s32 m_UsingCount{0}; - s32* m_pAssignedTableIndex{}; - s32 m_VoiceCount{}; - std::atomic m_DroppedVoiceCount{0}; + int m_UsingCount{0}; + int* m_pAssignedTableIndex{}; + int m_VoiceCount{}; + std::atomic_int m_DroppedVoiceCount{0}; }; static_assert(sizeof(LowLevelVoiceAllocator) == 0x28); diff --git a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp index 33e2d294..ae2274ac 100644 --- a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp @@ -4,6 +4,23 @@ namespace nn::atk::detail { LowLevelVoice::LowLevelVoice() = default; +void LowLevelVoice::Initialize() { + m_Priority = 0; + m_IsAvailable = true; + m_SampleRate = 32000; + m_SampleFormat = SampleFormat_PcmS16; + m_PlayPosition = 0; +#if NN_WARE_VER < NN_MAKE_VER(4, 0, 0) + _c0 = 0; +#else + m_pOutputReceiver = nullptr; +#endif + m_NodeId = 0; +#if NN_WARE_VER < NN_MAKE_VER(4, 0, 0) + _ec = true; +#endif +} + void LowLevelVoice::AppendWaveBuffer(WaveBuffer* waveBuffer) { waveBuffer->next = nullptr; waveBuffer->status = WaveBuffer::Status_Wait; From 9c7f0622e434526bf5afb711e0b4ad154dfa85a1 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 10 Sep 2026 21:14:08 -0300 Subject: [PATCH 606/785] atk: Match `LowLevelVoice::FreeAllWaveBuffer` --- .../atk/detail/voice/atk_LowLevelVoice.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp index ae2274ac..159b1490 100644 --- a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp @@ -21,6 +21,16 @@ void LowLevelVoice::Initialize() { #endif } +void LowLevelVoice::FreeAllWaveBuffer() { + for (WaveBuffer* waveBuffer{m_WaveBufferListBegin}; waveBuffer != nullptr; + waveBuffer = waveBuffer->next) + waveBuffer->status = WaveBuffer::Status_Done; + + m_WaveBufferListBegin = nullptr; + m_WaveBufferListEnd = nullptr; + m_LastAppendBuffer = nullptr; +} + void LowLevelVoice::AppendWaveBuffer(WaveBuffer* waveBuffer) { waveBuffer->next = nullptr; waveBuffer->status = WaveBuffer::Status_Wait; From 8970db8ea934c0431f28d4ffd883fb67aa453bf1 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 10 Sep 2026 21:21:07 -0300 Subject: [PATCH 607/785] atk: Match `LowLevelVoice::Finalize` --- include/nn/atk/atk_HardwareManager.h | 2 ++ .../atk/detail/voice/atk_LowLevelVoice.cpp | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/nn/atk/atk_HardwareManager.h b/include/nn/atk/atk_HardwareManager.h index 2cf88f2b..b7742ef0 100644 --- a/include/nn/atk/atk_HardwareManager.h +++ b/include/nn/atk/atk_HardwareManager.h @@ -193,6 +193,8 @@ class HardwareManager : public Util::Singleton { bool IsResetReady() const; + audio::AudioRendererConfig& GetAudioRendererConfig() { return m_Config; } + void AddSubMix(SubMix* pSubMix); void RemoveSubMix(SubMix* pSubMix); diff --git a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp index 159b1490..13fa4549 100644 --- a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp @@ -1,5 +1,9 @@ #include +#include + +#include + namespace nn::atk::detail { LowLevelVoice::LowLevelVoice() = default; @@ -31,6 +35,20 @@ void LowLevelVoice::FreeAllWaveBuffer() { m_LastAppendBuffer = nullptr; } +void LowLevelVoice::Finalize() { + FreeAllWaveBuffer(); + + if (m_IsSetVoiceSlot) { + audio::ReleaseVoiceSlot(&driver::HardwareManager::GetInstance().GetAudioRendererConfig(), + &m_Voice); + m_IsSetVoiceSlot = false; + } + + m_pVoice = nullptr; + m_IsAvailable = false; + m_State = VoiceState_Stop; +} + void LowLevelVoice::AppendWaveBuffer(WaveBuffer* waveBuffer) { waveBuffer->next = nullptr; waveBuffer->status = WaveBuffer::Status_Wait; From eb4597533e47fc19e9a2459613b121a46bc79819 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 10 Sep 2026 21:25:34 -0300 Subject: [PATCH 608/785] atk: Match `LowLevelVoice::IsAvailable` --- .../atk/detail/voice/atk_LowLevelVoice.cpp | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp index 13fa4549..86872efc 100644 --- a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp @@ -25,16 +25,6 @@ void LowLevelVoice::Initialize() { #endif } -void LowLevelVoice::FreeAllWaveBuffer() { - for (WaveBuffer* waveBuffer{m_WaveBufferListBegin}; waveBuffer != nullptr; - waveBuffer = waveBuffer->next) - waveBuffer->status = WaveBuffer::Status_Done; - - m_WaveBufferListBegin = nullptr; - m_WaveBufferListEnd = nullptr; - m_LastAppendBuffer = nullptr; -} - void LowLevelVoice::Finalize() { FreeAllWaveBuffer(); @@ -49,6 +39,10 @@ void LowLevelVoice::Finalize() { m_State = VoiceState_Stop; } +bool LowLevelVoice::IsAvailable() const { + return m_IsAvailable; +} + void LowLevelVoice::AppendWaveBuffer(WaveBuffer* waveBuffer) { waveBuffer->next = nullptr; waveBuffer->status = WaveBuffer::Status_Wait; @@ -60,4 +54,14 @@ void LowLevelVoice::AppendWaveBuffer(WaveBuffer* waveBuffer) { m_WaveBufferListEnd = waveBuffer; } +void LowLevelVoice::FreeAllWaveBuffer() { + for (WaveBuffer* waveBuffer{m_WaveBufferListBegin}; waveBuffer != nullptr; + waveBuffer = waveBuffer->next) + waveBuffer->status = WaveBuffer::Status_Done; + + m_WaveBufferListBegin = nullptr; + m_WaveBufferListEnd = nullptr; + m_LastAppendBuffer = nullptr; +} + } // namespace nn::atk::detail \ No newline at end of file From fc634c0a04059307c5fecced40f82f7ba80ef2bb Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 10 Sep 2026 21:28:30 -0300 Subject: [PATCH 609/785] atk: Match `LowLevelVoice::SetAvailable` --- src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp index 86872efc..3c285b35 100644 --- a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp @@ -43,6 +43,10 @@ bool LowLevelVoice::IsAvailable() const { return m_IsAvailable; } +void LowLevelVoice::SetAvailable(bool isAvailable) { + m_IsAvailable = isAvailable; +} + void LowLevelVoice::AppendWaveBuffer(WaveBuffer* waveBuffer) { waveBuffer->next = nullptr; waveBuffer->status = WaveBuffer::Status_Wait; From 5d10e5d3017c6dfc79dfb2a3e46233f30fed170e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 10 Sep 2026 21:29:59 -0300 Subject: [PATCH 610/785] atk: Match `LowLevelVoice::IsVoiceDroppedFlagOn` --- src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp index 3c285b35..cd04401d 100644 --- a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp @@ -47,6 +47,13 @@ void LowLevelVoice::SetAvailable(bool isAvailable) { m_IsAvailable = isAvailable; } +bool LowLevelVoice::IsVoiceDroppedFlagOn() const { + if (audio::IsVoiceValid(&m_Voice)) + return audio::IsVoiceDroppedFlagOn(&m_Voice); + + return false; +} + void LowLevelVoice::AppendWaveBuffer(WaveBuffer* waveBuffer) { waveBuffer->next = nullptr; waveBuffer->status = WaveBuffer::Status_Wait; From 587a0cedf76f7927a87a0afbaac70496eb3a01f9 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 10 Sep 2026 21:33:49 -0300 Subject: [PATCH 611/785] atk: Match `LowLevelVoice::UpdateStateStop` --- src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp index cd04401d..c1e2cd0c 100644 --- a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp @@ -75,4 +75,9 @@ void LowLevelVoice::FreeAllWaveBuffer() { m_LastAppendBuffer = nullptr; } +void LowLevelVoice::UpdateStateStop(bool isRun) { + if (isRun) + audio::SetVoicePlayState(&m_Voice, audio::VoiceType::PlayState_Stop); +} + } // namespace nn::atk::detail \ No newline at end of file From cf4b756859c44205e5cb0ffd5f28955a42af418f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 10 Sep 2026 21:51:54 -0300 Subject: [PATCH 612/785] atk: Match `LowLevelVoice::UpdatePlayPosition` --- include/nn/audio.h | 2 +- .../atk/detail/voice/atk_LowLevelVoice.cpp | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/include/nn/audio.h b/include/nn/audio.h index ba115227..8695fc24 100644 --- a/include/nn/audio.h +++ b/include/nn/audio.h @@ -153,7 +153,7 @@ void SetVoiceMixVolume(nn::audio::VoiceType* voice, nn::audio::SubMixType* mix, int sourceIndex, int destinationIndex); nn::audio::VoiceType::PlayState GetVoicePlayState(nn::audio::VoiceType const* voice); s32 GetVoicePriority(nn::audio::VoiceType const* voice); -u64 GetVoicePlayedSampleCount(nn::audio::VoiceType const* voice); +s64 GetVoicePlayedSampleCount(nn::audio::VoiceType const* voice); u32 GetVoiceNodeId(nn::audio::VoiceType const* voice); bool AppendWaveBuffer(nn::audio::VoiceType* voice, nn::audio::WaveBuffer const* waveBuffer); nn::audio::WaveBuffer* GetReleasedWaveBuffer(nn::audio::VoiceType* voice); diff --git a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp index c1e2cd0c..3125ce88 100644 --- a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp @@ -75,9 +75,62 @@ void LowLevelVoice::FreeAllWaveBuffer() { m_LastAppendBuffer = nullptr; } +void LowLevelVoice::UpdateState(OutputMode outputMode) { + if (!audio::IsVoiceValid(&m_Voice)) + return; + + bool isRun = audio::GetVoicePlayState(&m_Voice) == audio::VoiceType::PlayState_Play; + + switch (m_State) { + case VoiceState_Play: + UpdateStatePlay(isRun, outputMode); + break; + case VoiceState_Stop: + UpdateStateStop(isRun); + break; + case VoiceState_Pause: + UpdateStatePause(isRun, outputMode); + break; + } +} + +void LowLevelVoice::UpdateStatePlay(bool isRun, OutputMode outputMode) { + UpdateWaveBuffer(isRun, outputMode); + UpdateVoiceParam(m_VoiceParam, outputMode); +} + void LowLevelVoice::UpdateStateStop(bool isRun) { if (isRun) audio::SetVoicePlayState(&m_Voice, audio::VoiceType::PlayState_Stop); } +void LowLevelVoice::UpdatePlayPosition() { + if (m_IsSetVoiceSlot) { + s64 playedSampleCount{audio::GetVoicePlayedSampleCount(&m_Voice)}; + s64 startOffset{0}; + + WaveBuffer* currentWaveBuffer{m_WaveBufferListBegin}; + + if (currentWaveBuffer != nullptr) { + startOffset = currentWaveBuffer->sampleOffset; + s64 loopSampleLength{currentWaveBuffer->sampleLength - startOffset}; + + if (currentWaveBuffer->loopFlag && playedSampleCount > loopSampleLength) + playedSampleCount = + playedSampleCount - (playedSampleCount / loopSampleLength) * loopSampleLength; + } + + m_PlayPosition = playedSampleCount + startOffset; + } +} + +void LowLevelVoice::UpdateWaveBuffer(bool isRun, OutputMode outputMode) { + if (isRun) { + UpdateWaveBufferOnPlayState(); + UpdatePlayPosition(); + } + + UpdateWaveBufferOnStopState(outputMode); +} + } // namespace nn::atk::detail \ No newline at end of file From bd2e3e367b7d3e74400a95bdea5744e2b807c2d7 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 10 Sep 2026 21:56:05 -0300 Subject: [PATCH 613/785] atk: Match `LowLevelVoice::UpdateWaveBuffer` Also match `LowLevelVoice::UpdateStatePlay` --- src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp index 3125ce88..42bdcd0e 100644 --- a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp @@ -128,9 +128,9 @@ void LowLevelVoice::UpdateWaveBuffer(bool isRun, OutputMode outputMode) { if (isRun) { UpdateWaveBufferOnPlayState(); UpdatePlayPosition(); + } else { + UpdateWaveBufferOnStopState(outputMode); } - - UpdateWaveBufferOnStopState(outputMode); } } // namespace nn::atk::detail \ No newline at end of file From 498296a957ba98f56bd3ecce0e01bb331dce1eba Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 10 Sep 2026 22:00:38 -0300 Subject: [PATCH 614/785] atk: Match `LowLevelVoice::UpdateStatePause` Also matches `LowLevelVoice::UpdateState` --- .../atk/detail/voice/atk_LowLevelVoice.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp index 42bdcd0e..976c90ad 100644 --- a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp @@ -100,8 +100,18 @@ void LowLevelVoice::UpdateStatePlay(bool isRun, OutputMode outputMode) { } void LowLevelVoice::UpdateStateStop(bool isRun) { - if (isRun) - audio::SetVoicePlayState(&m_Voice, audio::VoiceType::PlayState_Stop); + if (!isRun) + return; + + audio::SetVoicePlayState(&m_Voice, audio::VoiceType::PlayState_Stop); +} + +void LowLevelVoice::UpdateStatePause(bool isRun, OutputMode outputMode) { + if (!isRun) + return; + + UpdateVoiceParam(m_VoiceParam, outputMode); + audio::SetVoicePlayState(&m_Voice, audio::VoiceType::PlayState_Pause); } void LowLevelVoice::UpdatePlayPosition() { From 520821e4485bc5661414f4e6a6c3267378ee3eff Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 10 Sep 2026 22:14:03 -0300 Subject: [PATCH 615/785] atk: Match `LowLevelVoice::SetPriority` --- .../atk/detail/voice/atk_LowLevelVoice.cpp | 44 ++++++++++++++++--- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp index 976c90ad..fe5927e6 100644 --- a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp @@ -4,15 +4,38 @@ #include +namespace { + +const s32 LowLevelVoiceInitialPriority{0}; +const int LowLevelVoiceInitialSampleRate{32000}; +const nn::atk::SampleFormat LowLevelVoiceInitialSampleFormat{nn::atk::SampleFormat_PcmS16}; +const nn::atk::detail::VoiceState LowLevelVoiceInitialVoiceState{nn::atk::detail::VoiceState_Stop}; + +const size_t LowLevelVoiceAlignedSize{sizeof(nn::atk::detail::LowLevelVoice)}; + +int ConvertAtkPriorityToAudioPriority(s32 atkPriority) { + if (atkPriority == 255) + return 0; + + return 255 - atkPriority; +} + +int GetOutputReceiverMixBufferIndex(const nn::atk::OutputReceiver* pOutputReceiver, int channel, int bus) { + +} + +} // anonymous namespace + namespace nn::atk::detail { -LowLevelVoice::LowLevelVoice() = default; +LowLevelVoice::LowLevelVoice() + : m_State{LowLevelVoiceInitialVoiceState} {}; void LowLevelVoice::Initialize() { - m_Priority = 0; + m_Priority = LowLevelVoiceInitialPriority; m_IsAvailable = true; - m_SampleRate = 32000; - m_SampleFormat = SampleFormat_PcmS16; + m_SampleRate = LowLevelVoiceInitialSampleRate; + m_SampleFormat = LowLevelVoiceInitialSampleFormat; m_PlayPosition = 0; #if NN_WARE_VER < NN_MAKE_VER(4, 0, 0) _c0 = 0; @@ -94,6 +117,15 @@ void LowLevelVoice::UpdateState(OutputMode outputMode) { } } +void LowLevelVoice::SetPriority(s32 priority) { + m_Priority = priority; + + if (!audio::IsVoiceValid(&m_Voice)) + return; + + audio::SetVoicePriority(&m_Voice, ConvertAtkPriorityToAudioPriority(m_Priority)); +} + void LowLevelVoice::UpdateStatePlay(bool isRun, OutputMode outputMode) { UpdateWaveBuffer(isRun, outputMode); UpdateVoiceParam(m_VoiceParam, outputMode); @@ -107,9 +139,9 @@ void LowLevelVoice::UpdateStateStop(bool isRun) { } void LowLevelVoice::UpdateStatePause(bool isRun, OutputMode outputMode) { - if (!isRun) + if (!isRun) return; - + UpdateVoiceParam(m_VoiceParam, outputMode); audio::SetVoicePlayState(&m_Voice, audio::VoiceType::PlayState_Pause); } From f635cf2fa8d5cb20da1019bd8234c41fd55ca980 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 10 Sep 2026 22:27:34 -0300 Subject: [PATCH 616/785] atk: Match `LowLevelVoice::SetState` --- include/nn/atk/atk_LowLevelVoice.h | 10 ++--- .../atk/detail/voice/atk_LowLevelVoice.cpp | 37 ++++++++++++++++--- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/include/nn/atk/atk_LowLevelVoice.h b/include/nn/atk/atk_LowLevelVoice.h index e4b45599..5aed4ccb 100644 --- a/include/nn/atk/atk_LowLevelVoice.h +++ b/include/nn/atk/atk_LowLevelVoice.h @@ -79,14 +79,14 @@ class alignas(64) LowLevelVoice { float GetClampedVoiceVolume(float volume); AdpcmParam m_AdpcmParam{}; - audio::VoiceType m_Voice{}; + audio::VoiceType m_Voice; bool m_IsAvailable{false}; bool m_IsSetVoiceSlot{false}; VoiceParam m_VoiceParam{}; - int32_t m_Priority{0}; - VoiceState m_State{VoiceState_Stop}; - u32 m_SampleRate{32000}; - SampleFormat m_SampleFormat{SampleFormat_PcmS16}; + int32_t m_Priority; + VoiceState m_State; + u32 m_SampleRate; + SampleFormat m_SampleFormat; position_t m_PlayPosition{0}; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) u32 _c0{0}; // 0xc0 diff --git a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp index fe5927e6..79e57673 100644 --- a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp @@ -20,16 +20,17 @@ int ConvertAtkPriorityToAudioPriority(s32 atkPriority) { return 255 - atkPriority; } -int GetOutputReceiverMixBufferIndex(const nn::atk::OutputReceiver* pOutputReceiver, int channel, int bus) { - -} +int GetOutputReceiverMixBufferIndex(const nn::atk::OutputReceiver* pOutputReceiver, int channel, + int bus) {} } // anonymous namespace namespace nn::atk::detail { -LowLevelVoice::LowLevelVoice() - : m_State{LowLevelVoiceInitialVoiceState} {}; +LowLevelVoice::LowLevelVoice() + : m_Priority{LowLevelVoiceInitialPriority}, m_State{LowLevelVoiceInitialVoiceState}, + m_SampleRate{LowLevelVoiceInitialSampleRate}, + m_SampleFormat{LowLevelVoiceInitialSampleFormat} {} void LowLevelVoice::Initialize() { m_Priority = LowLevelVoiceInitialPriority; @@ -108,9 +109,11 @@ void LowLevelVoice::UpdateState(OutputMode outputMode) { case VoiceState_Play: UpdateStatePlay(isRun, outputMode); break; + case VoiceState_Stop: UpdateStateStop(isRun); break; + case VoiceState_Pause: UpdateStatePause(isRun, outputMode); break; @@ -126,6 +129,30 @@ void LowLevelVoice::SetPriority(s32 priority) { audio::SetVoicePriority(&m_Voice, ConvertAtkPriorityToAudioPriority(m_Priority)); } +void LowLevelVoice::SetState(VoiceState state) { + m_State = state; + + switch (state) { + case VoiceState_Play: + if (!m_IsSetVoiceSlot) { + AllocVoice(); + m_IsSetVoiceSlot = true; + } + break; + + case VoiceState_Stop: + if (m_IsSetVoiceSlot) { + audio::ReleaseVoiceSlot( + &driver::HardwareManager::GetInstance().GetAudioRendererConfig(), &m_Voice); + m_IsSetVoiceSlot = false; + } + break; + + case VoiceState_Pause: + break; + } +} + void LowLevelVoice::UpdateStatePlay(bool isRun, OutputMode outputMode) { UpdateWaveBuffer(isRun, outputMode); UpdateVoiceParam(m_VoiceParam, outputMode); From e98b04c40c7a36ccf7d014bb2fb0c52287c4161b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 10 Sep 2026 22:33:00 -0300 Subject: [PATCH 617/785] atk: Match `LowLevelVoice::UpdateVoiceInfo` --- .../atk/detail/voice/atk_LowLevelVoice.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp index 79e57673..c6e6a0a1 100644 --- a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp @@ -153,6 +153,23 @@ void LowLevelVoice::SetState(VoiceState state) { } } +void LowLevelVoice::UpdateVoiceInfo(VoiceInfo* voiceInfo) const { + voiceInfo->userId = m_pVoice; + voiceInfo->voiceState = m_State; + + volatile WaveBuffer* pListBegin{m_WaveBufferListBegin}; + + if (m_WaveBufferListBegin != nullptr) { + voiceInfo->waveBufferStatus = pListBegin->status; + voiceInfo->waveBufferTag = pListBegin->userParam; + } + else { + voiceInfo->waveBufferStatus = WaveBuffer::Status_Free; + } + + voiceInfo->playPosition = m_PlayPosition; +} + void LowLevelVoice::UpdateStatePlay(bool isRun, OutputMode outputMode) { UpdateWaveBuffer(isRun, outputMode); UpdateVoiceParam(m_VoiceParam, outputMode); From 2b3daf690b982f86c39890c97fa138967c76c259 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 10 Sep 2026 22:42:13 -0300 Subject: [PATCH 618/785] atk: Match `LowLevelVoice::GetClampedVoiceVolume` --- include/nn/atk/atk_LowLevelVoice.h | 3 ++- src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_LowLevelVoice.h b/include/nn/atk/atk_LowLevelVoice.h index 5aed4ccb..63973b57 100644 --- a/include/nn/atk/atk_LowLevelVoice.h +++ b/include/nn/atk/atk_LowLevelVoice.h @@ -78,6 +78,7 @@ class alignas(64) LowLevelVoice { void SetVoiceMixVolume(float mixVolume, int destinationIndex); float GetClampedVoiceVolume(float volume); + AdpcmParam m_AdpcmParam{}; audio::VoiceType m_Voice; bool m_IsAvailable{false}; @@ -99,7 +100,7 @@ class alignas(64) LowLevelVoice { Voice* m_pVoice{}; audio::NodeId m_NodeId{0}; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) - bool _ec{true}; // 0xec + bool m_IsRun{true}; #endif }; static_assert(sizeof(LowLevelVoice) == 0x100); diff --git a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp index c6e6a0a1..e6956482 100644 --- a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp @@ -3,6 +3,7 @@ #include #include +#include namespace { @@ -45,7 +46,7 @@ void LowLevelVoice::Initialize() { #endif m_NodeId = 0; #if NN_WARE_VER < NN_MAKE_VER(4, 0, 0) - _ec = true; + m_IsRun = true; #endif } @@ -219,4 +220,8 @@ void LowLevelVoice::UpdateWaveBuffer(bool isRun, OutputMode outputMode) { } } +float LowLevelVoice::GetClampedVoiceVolume(float volume) { + return fnd::FloatClamp(volume, 0.0f, 128.0f); +} + } // namespace nn::atk::detail \ No newline at end of file From ba96b7b8b6e516df195665d3bfee19bb3d6cce4f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 10 Sep 2026 22:44:56 -0300 Subject: [PATCH 619/785] atk: Match `LowLevelVoice::UpdateVolume` --- include/nn/atk/atk_Global.h | 12 +++++------- .../atk/detail/voice/atk_LowLevelVoice.cpp | 8 ++++++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h index bddb27d8..e2e58f83 100644 --- a/include/nn/atk/atk_Global.h +++ b/include/nn/atk/atk_Global.h @@ -480,13 +480,7 @@ enum VoiceState { VoiceState_Pause, }; -class VoiceParam { -public: - VoiceParam() = default; - - void Initialize(); - -private: +struct VoiceParam { float m_Volume{0}; float m_Pitch{0}; OutputMix m_TvMix{}; @@ -495,6 +489,10 @@ class VoiceParam { BiquadFilterCoefficients m_BiquadFilterCoefficients{}; u16 m_MonoFilterCutoff{0}; u8 m_InterpolationType{0}; + + VoiceParam() = default; + + void Initialize(); }; static_assert(sizeof(VoiceParam) == 0x78); diff --git a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp index e6956482..d443286a 100644 --- a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp @@ -163,8 +163,7 @@ void LowLevelVoice::UpdateVoiceInfo(VoiceInfo* voiceInfo) const { if (m_WaveBufferListBegin != nullptr) { voiceInfo->waveBufferStatus = pListBegin->status; voiceInfo->waveBufferTag = pListBegin->userParam; - } - else { + } else { voiceInfo->waveBufferStatus = WaveBuffer::Status_Free; } @@ -220,6 +219,11 @@ void LowLevelVoice::UpdateWaveBuffer(bool isRun, OutputMode outputMode) { } } +void LowLevelVoice::UpdateVolume(const VoiceParam& voiceParam) { + float volume{GetClampedVoiceVolume(voiceParam.m_Volume)}; + audio::SetVoiceVolume(&m_Voice, volume); +} + float LowLevelVoice::GetClampedVoiceVolume(float volume) { return fnd::FloatClamp(volume, 0.0f, 128.0f); } From ba1dadb125691b5bb9d724973cc900fc40a954ef Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 10 Sep 2026 22:55:47 -0300 Subject: [PATCH 620/785] atk: Match `LowLevelVoice::UpdatePitch` --- src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp index d443286a..12d4587c 100644 --- a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp @@ -224,6 +224,11 @@ void LowLevelVoice::UpdateVolume(const VoiceParam& voiceParam) { audio::SetVoiceVolume(&m_Voice, volume); } +void LowLevelVoice::UpdatePitch(const VoiceParam& voiceParam) { + float pitch{fnd::Clamp(voiceParam.m_Pitch, 0.0625f, 16.0f)}; + audio::SetVoicePitch(&m_Voice, pitch); +} + float LowLevelVoice::GetClampedVoiceVolume(float volume) { return fnd::FloatClamp(volume, 0.0f, 128.0f); } From b1e88b77a081a57359d34810f197f55b12ec2d39 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 10 Sep 2026 23:01:07 -0300 Subject: [PATCH 621/785] atk: Match `LowLevelVoice::UpdateBiquadFilter` --- .../atk/detail/voice/atk_LowLevelVoice.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp index 12d4587c..bad8fd09 100644 --- a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp @@ -229,6 +229,17 @@ void LowLevelVoice::UpdatePitch(const VoiceParam& voiceParam) { audio::SetVoicePitch(&m_Voice, pitch); } +void LowLevelVoice::UpdateBiquadFilter(const VoiceParam& voiceParam) { + audio::BiquadFilterParameter parameter; + parameter.denominator[0] = voiceParam.m_BiquadFilterCoefficients.a1; + parameter.denominator[1] = voiceParam.m_BiquadFilterCoefficients.a2; + parameter.numerator[0] = voiceParam.m_BiquadFilterCoefficients.b0; + parameter.numerator[1] = voiceParam.m_BiquadFilterCoefficients.b1; + parameter.numerator[2] = voiceParam.m_BiquadFilterCoefficients.b2; + parameter.enable = voiceParam.m_BiquadFilterFlag; + audio::SetVoiceBiquadFilterParameter(&m_Voice, 0, parameter); +} + float LowLevelVoice::GetClampedVoiceVolume(float volume) { return fnd::FloatClamp(volume, 0.0f, 128.0f); } From 5fa0bbd27196a91d399723df85d3d93d8e5e2ce3 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 10 Sep 2026 23:24:21 -0300 Subject: [PATCH 622/785] atk: Match `LowLevelVoice::UpdateMixVolume` --- include/nn/atk/atk_HardwareManager.h | 7 +++++++ include/nn/atk/atk_LowLevelVoice.h | 2 ++ .../atk/detail/voice/atk_LowLevelVoice.cpp | 13 +++++++++++++ 3 files changed, 22 insertions(+) diff --git a/include/nn/atk/atk_HardwareManager.h b/include/nn/atk/atk_HardwareManager.h index b7742ef0..6418d814 100644 --- a/include/nn/atk/atk_HardwareManager.h +++ b/include/nn/atk/atk_HardwareManager.h @@ -225,6 +225,9 @@ class HardwareManager : public Util::Singleton { SampleRateConverterType GetSrcType() const { return m_SrcType; } + bool IsEffectInitialized() const { return m_IsInitializedEffect; } + bool IsPresetSubMixEnabled() const { return m_IsPresetSubMixEnabled; } + private: bool m_IsInitialized; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) @@ -247,8 +250,12 @@ class HardwareManager : public Util::Singleton { u8 m_OutputDeviceFlag[32]; LowLevelVoiceAllocator m_LowLevelVoiceAllocator; FinalMix m_FinalMix; +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) + SubMix m_SubMix; +#else SubMix m_SubMix[SubMixCountMax]; SubMix m_AdditionalSubMix; +#endif SubMixList m_SubMixList; fnd::CriticalSection m_SubMixListLock; audio::AudioRendererParameter m_AudioRendererParameter; diff --git a/include/nn/atk/atk_LowLevelVoice.h b/include/nn/atk/atk_LowLevelVoice.h index 63973b57..05b67709 100644 --- a/include/nn/atk/atk_LowLevelVoice.h +++ b/include/nn/atk/atk_LowLevelVoice.h @@ -67,8 +67,10 @@ class alignas(64) LowLevelVoice { bool AppendWaveBufferToVoice(WaveBuffer* waveBuffer); void UpdateMixVolume(const OutputMix& outputMix, OutputMode outputMode); +#if NN_WARE_VER < NN_MAKE_VER(4, 0, 0) void UpdateMixVolumeOnSubMix(const OutputMix& outputMix, OutputMode outputMode); void UpdateMixVolumeOnFinalMix(const OutputMix& outputMix, OutputMode outputMode); +#endif void UpdateVolume(const VoiceParam& voiceParam); void UpdatePitch(const VoiceParam& voiceParam); diff --git a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp index bad8fd09..df4f089d 100644 --- a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp @@ -219,6 +219,19 @@ void LowLevelVoice::UpdateWaveBuffer(bool isRun, OutputMode outputMode) { } } +// Non-matching on versions over 4.0.0 +void LowLevelVoice::UpdateMixVolume(const OutputMix& outputMix, OutputMode outputMode) { +#if NN_WARE_VER < NN_MAKE_VER(4, 0, 0) + if (driver::HardwareManager::GetInstance().IsPresetSubMixEnabled()) { + UpdateMixVolumeOnSubMix(outputMix, outputMode); + } else { + UpdateMixVolumeOnFinalMix(outputMix, outputMode); + } +#else + +#endif +} + void LowLevelVoice::UpdateVolume(const VoiceParam& voiceParam) { float volume{GetClampedVoiceVolume(voiceParam.m_Volume)}; audio::SetVoiceVolume(&m_Voice, volume); From ca45ef1764ff5fa4016aa513db2089ba284fef07 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 11 Sep 2026 12:49:33 -0300 Subject: [PATCH 623/785] atk: Add RTTI functions and classes --- include/nn/atk/atk_BasicSound.h | 48 ++++++++----- include/nn/atk/atk_LoaderManager.h | 72 +++++++++++++++++-- include/nn/atk/atk_SoundActor.h | 7 ++ .../nn/atk/fnd/basis/atkfnd_RuntimeTypeInfo.h | 54 +++++++++++++- include/nn/util/util_IntrusiveList.h | 2 +- .../detail/strm/atk_StreamSoundFileLoader.cpp | 50 +++++++------ 6 files changed, 186 insertions(+), 47 deletions(-) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index ea5cc7f5..c542eaff 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -9,6 +9,7 @@ #include #include #include +#include namespace nn::atk { class SoundActor; @@ -253,7 +254,7 @@ static_assert(sizeof(SoundActorParam) == 0x1c); #endif class BasicSound { -// TODO: implement rtti in atk::fnd + NN_ATK_RTTI_BASE(BasicSound); public: enum PlayerState { PlayerState_Init, @@ -265,7 +266,7 @@ class BasicSound { struct AmbientArgUpdateCallback{}; struct AmbientArgAllocatorCallback{}; - struct AmbientInfo { + struct AmbientInfo { // 703 AmbientParamUpdateCallback* paramUpdateCallback; AmbientArgUpdateCallback* argUpdateCallback; AmbientArgAllocatorCallback* argAllocatorCallback; @@ -277,7 +278,7 @@ class BasicSound { BasicSound(); virtual ~BasicSound(); - void Update(); + void Update(); // 725 void StartPrepared(); void Stop(int fadeFrames); @@ -300,7 +301,7 @@ class BasicSound { virtual bool IsPrepared() const = 0; bool IsPause() const; bool IsMute() const; - bool IsStarted() const; + bool IsStarted() const { return m_StartedFlag; } void SetPriority(int priority, int ambientPriority); void GetPriority(int* priority, int* ambientPriority) const; @@ -480,7 +481,7 @@ class BasicSound { State_Destructed, }; - PlayerHeap* m_pPlayerHeap; + PlayerHeap* m_pPlayerHeap; // 934 SoundHandle* m_pGeneralHandle; SoundHandle* m_pTempGeneralHandle; SoundPlayer* m_pSoundPlayer; @@ -519,23 +520,38 @@ class BasicSound { f32 m_BiquadFilterValue; u32 m_OutputLineFlag; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) - OutputReceiver* m_pOutputReceiver; + OutputReceiver* m_pOutputReceiver; // 981 #endif - struct CommonParam { + struct CommonParam { // 984 MoveValue volume; MixMode mixMode; float pan; float span; - float send[4]; - - void Initialize(); - void Update(); - - float GetVolume() const; - void SetVolume(float target, int frame); - - CommonParam(); + float send[DefaultBusCount]; + + void Initialize() { + volume.InitValue(1.0f); + mixMode = MixMode_Pan; + pan = 0.0f; + span = 0.0f; + for (int i{0}; i < DefaultBusCount; ++i) + send[i] = 0.0f; + } + + void Update() { + volume.Update(); + } + + float GetVolume() const { + return volume.GetValue(); + } + + void SetVolume(float target, int frame) { + volume.SetTarget(target, frame); + } + + CommonParam() = default; }; static_assert(sizeof(CommonParam) == 0x2c); diff --git a/include/nn/atk/atk_LoaderManager.h b/include/nn/atk/atk_LoaderManager.h index 98063445..319eaf15 100644 --- a/include/nn/atk/atk_LoaderManager.h +++ b/include/nn/atk/atk_LoaderManager.h @@ -3,18 +3,78 @@ #include namespace nn::atk::detail { -template -class LoaderManager : driver::SoundThread::SoundFrameCallback { + +template +class LoaderManager : public driver::SoundThread::SoundFrameCallback { public: - using List = util::IntrusiveList>; + using List = util::IntrusiveList< + Instance, util::IntrusiveListMemberNodeTraits>; using Iterator = typename List::iterator; LoaderManager(); ~LoaderManager() override; - void OnBeginSoundFrame() override; + // UNCHECKED + size_t GetRequiredMemSize(int count) { return sizeof(Instance) * count; } + + // UNCHECKED + int Create(void* buffer, size_t size) { + char* ptr{reinterpret_cast(buffer)}; + const int objectCount{size / sizeof(Instance)}; + + for (int i{0}; i < objectCount; ++i) { + Instance* instance{new (ptr) Instance}; + m_FreeList.push_back(*instance); + + ptr += i * sizeof(Instance); + } + + m_pBuffer = buffer; + m_BufferSize = size; + } + + // UNCHECKED + void Destroy() { + char* ptr{reinterpret_cast(m_pBuffer)}; + const int objectCount{m_BufferSize / sizeof(Instance)}; + + if (m_FreeList.empty()) + return; + + for (int i{0}; i < objectCount; ++i) { + Instance* instance{reinterpret_cast(ptr)}; + m_FreeList.iterator_to(*instance)->Finalize(); + + ptr += i * sizeof(Instance); + } + + m_FreeList.clear(); + } + + Instance* Alloc() { + if (m_FreeList.empty()) + return nullptr; + + m_FreeList.pop_front(); + + Instance* instance{&m_FreeList.front()}; + + return instance; + } + + void Free(Instance* instance) { + // TODO + } + + void UpdateFreeReqList() { + // TODO + } + + int GetFreeCount() const { return m_FreeList.size(); } - void Destroy(); + void OnBeginSoundFrame() override { + // TODO + } private: void* m_pBuffer; @@ -23,4 +83,4 @@ class LoaderManager : driver::SoundThread::SoundFrameCallback { List m_FreeReqList; }; -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_SoundActor.h b/include/nn/atk/atk_SoundActor.h index 8d30f83a..e04c925f 100644 --- a/include/nn/atk/atk_SoundActor.h +++ b/include/nn/atk/atk_SoundActor.h @@ -6,5 +6,12 @@ namespace nn::atk { class SoundActor { public: using ActorPlayer = detail::ExternalSoundPlayer; + + ActorPlayer* detail_GetActorPlayer(int actorPlayerId); + +private: + u8 _0[0x90]; + ActorPlayer* m_ActorPlayerList; }; + } // namespace nn::atk \ No newline at end of file diff --git a/include/nn/atk/fnd/basis/atkfnd_RuntimeTypeInfo.h b/include/nn/atk/fnd/basis/atkfnd_RuntimeTypeInfo.h index 5e5c2061..bab4b32d 100644 --- a/include/nn/atk/fnd/basis/atkfnd_RuntimeTypeInfo.h +++ b/include/nn/atk/fnd/basis/atkfnd_RuntimeTypeInfo.h @@ -1,10 +1,60 @@ #pragma once namespace nn::atk::detail::fnd { + class RuntimeTypeInfo { public: + explicit RuntimeTypeInfo(const RuntimeTypeInfo* parent) : m_ParentTypeInfo{parent} {} + + // UNCHECKED + bool IsDerivedFrom(const RuntimeTypeInfo* s_TypeInfo) const { + const RuntimeTypeInfo* self{this}; + + if (self == s_TypeInfo) + return true; + + if (m_ParentTypeInfo == nullptr) + return false; + + return m_ParentTypeInfo->IsDerivedFrom(s_TypeInfo); + } + private: - RuntimeTypeInfo* m_ParentTypeInfo; + const RuntimeTypeInfo* m_ParentTypeInfo; }; static_assert(sizeof(RuntimeTypeInfo) == 0x8); -} // namespace nn::atk::detail::fnd \ No newline at end of file + +#define NN_ATK_RTTI_BASE(CLASS) \ +public: \ + static const nn::atk::detail::fnd::RuntimeTypeInfo* GetRuntimeTypeInfoStatic() { \ + static const nn::atk::detail::fnd::RuntimeTypeInfo s_TypeInfo{nullptr}; \ + return &s_TypeInfo; \ + } \ + \ + virtual const nn::atk::detail::fnd::RuntimeTypeInfo* GetRuntimeTypeInfo() const { \ + return CLASS::GetRuntimeTypeInfoStatic(); \ + } + +#define NN_ATK_RTTI_OVERRIDE(CLASS, BASE) \ +public: \ + static const nn::atk::detail::fnd::RuntimeTypeInfo* GetRuntimeTypeInfoStatic() { \ + static const nn::atk::detail::fnd::RuntimeTypeInfo s_TypeInfo{ \ + BASE::GetRuntimeTypeInfoStatic()}; \ + return &s_TypeInfo; \ + } \ + \ + const nn::atk::detail::fnd::RuntimeTypeInfo* GetRuntimeTypeInfo() const override { \ + return CLASS::GetRuntimeTypeInfoStatic(); \ + } + +template +inline TToPtr* DynamicCast(TFrom* obj) { + RuntimeTypeInfo* typeInfoU{TToPtr::GetRuntimeTypeInfoStatic()}; + + if (typeInfoU->IsDerivedFrom(obj->GetRuntimeTypeInfo())) + return static_cast(obj); + + return nullptr; +} + +} // namespace nn::atk::detail::fnd diff --git a/include/nn/util/util_IntrusiveList.h b/include/nn/util/util_IntrusiveList.h index 64b3e8e1..ae5d30e9 100644 --- a/include/nn/util/util_IntrusiveList.h +++ b/include/nn/util/util_IntrusiveList.h @@ -290,7 +290,7 @@ class IntrusiveList { void push_front(reference); void pop_back(); - void pop_front(); + void pop_front() { m_Implementation.pop_front(); } reference front() { return ToReference(m_Implementation.front()); } const_reference front() const { return ToReference(m_Implementation.front()); } diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileLoader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileLoader.cpp index 2c48c0d6..e559930d 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileLoader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileLoader.cpp @@ -1,17 +1,19 @@ #include namespace nn::atk::detail { + bool StreamSoundFileLoader::LoadFileHeader(StreamSoundFileReader* reader, void* buffer, u64 size) { - const size_t HeaderSize {0x60}; - const size_t AlignSize {64}; + const size_t HeaderSize{0x60}; + const size_t AlignSize{64}; char buffer2[HeaderSize + AlignSize]; m_pStream->Seek(0, fnd::FileStream::SeekOrigin_Begin); - size_t readSize {m_pStream->Read(util::BytePtr(buffer2).AlignUp(AlignSize).Get(), HeaderSize, nullptr)}; - auto* header {util::BytePtr(buffer2).AlignUp(AlignSize).Get()}; + size_t readSize{ + m_pStream->Read(util::BytePtr(buffer2).AlignUp(AlignSize).Get(), HeaderSize, nullptr)}; + auto* header{util::BytePtr(buffer2).AlignUp(AlignSize).Get()}; if (readSize == HeaderSize && reader->IsValidFileHeader(header)) { - u32 loadSize {header->GetInfoBlockOffset() + header->GetInfoBlockSize()}; + u32 loadSize{header->GetInfoBlockOffset() + header->GetInfoBlockSize()}; if (loadSize <= size) { m_pStream->Seek(0, fnd::FileStream::SeekOrigin_Begin); readSize = m_pStream->Read(buffer, loadSize, nullptr); @@ -28,20 +30,21 @@ bool StreamSoundFileLoader::LoadFileHeader(StreamSoundFileReader* reader, void* return false; } -bool StreamSoundFileLoader::ReadSeekBlockData(u16* yn1, u16* yn2, int blockIndex, int channelCount) { - const size_t SeekInfoMaxSize {channelCount * sizeof(u16) * 2}; - size_t readDataSize {SeekInfoMaxSize}; - size_t readOffset {m_SeekBlockOffset + sizeof(BinaryBlockHeader) + blockIndex * readDataSize}; +bool StreamSoundFileLoader::ReadSeekBlockData(u16* yn1, u16* yn2, int blockIndex, + int channelCount) { + const size_t SeekInfoMaxSize{channelCount * sizeof(u16) * 2}; + size_t readDataSize{SeekInfoMaxSize}; + size_t readOffset{m_SeekBlockOffset + sizeof(BinaryBlockHeader) + blockIndex * readDataSize}; m_pStream->Seek(static_cast(readOffset), fnd::FileStream::SeekOrigin_Begin); if (readDataSize <= 64) { - const int Align {64}; + const int Align{64}; u16 bufferBase[128]; - u16* buffer {util::BytePtr(bufferBase).AlignUp(Align).Get()}; - size_t readSize {m_pStream->Read(buffer, readDataSize, nullptr)}; + u16* buffer{util::BytePtr(bufferBase).AlignUp(Align).Get()}; + size_t readSize{m_pStream->Read(buffer, readDataSize, nullptr)}; if (readSize == readDataSize) { - for (int i {0}; i < channelCount; ++i) { + for (int i{0}; i < channelCount; ++i) { yn1[i] = buffer[i * sizeof(u16)]; yn2[i] = buffer[i * sizeof(u16) + 1]; } @@ -52,17 +55,19 @@ bool StreamSoundFileLoader::ReadSeekBlockData(u16* yn1, u16* yn2, int blockIndex return false; } -bool StreamSoundFileLoader::ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo, u32 regionIndex) const { +bool StreamSoundFileLoader::ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo, + u32 regionIndex) const { if (m_RegionDataOffset != 0 && m_RegionInfoBytes != 0) { - position_t offset {m_RegionDataOffset + static_cast(m_RegionInfoBytes) * regionIndex}; + position_t offset{m_RegionDataOffset + + static_cast(m_RegionInfoBytes) * regionIndex}; m_pStream->Seek(offset, fnd::FileStream::SeekOrigin_Begin); - - const int Align {64}; - const size_t ReadSize {sizeof(StreamSoundFile::RegionInfo)}; + + const int Align{64}; + const size_t ReadSize{sizeof(StreamSoundFile::RegionInfo)}; u8 bufferBase[ReadSize + Align]; - u8* buffer {util::BytePtr(bufferBase).AlignUp(Align).Get()}; - - size_t readSize {m_pStream->Read(buffer, ReadSize, nullptr)}; + u8* buffer{util::BytePtr(bufferBase).AlignUp(Align).Get()}; + + size_t readSize{m_pStream->Read(buffer, ReadSize, nullptr)}; if (readSize == ReadSize) { *pInfo = *reinterpret_cast(buffer); return true; @@ -72,4 +77,5 @@ bool StreamSoundFileLoader::ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo, u return false; } -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail From 901458858b181ffc61765cfcf9d26c8f8745bd94 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 11 Sep 2026 14:48:31 -0300 Subject: [PATCH 624/785] atk: Match `BasicSound` constructor --- include/nn/atk/atk_BasicSound.h | 218 +++++++++++------- .../atk/detail/atk_BasicSound.cpp | 7 + 2 files changed, 137 insertions(+), 88 deletions(-) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index c542eaff..8119b127 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -3,50 +3,58 @@ #include #include -#include #include -#include -#include #include -#include +#include +#include #include namespace nn::atk { + class SoundActor; class SoundPlayer; class SoundHandle; class OutputAmbientParam { public: - OutputAmbientParam(); + OutputAmbientParam() = default; - void Initialize(); + void Initialize() { + m_Volume = 1.0f; + m_Pan = 0.0f; + m_SurroundPan = 0.0f; - float GetVolume() const; - void SetVolume(float volume); + for (int i{0}; i < AuxBus_Count; ++i) + m_FxSend[i] = 0.0f; + } - float GetPan() const; - void SetPan(float pan); + float GetVolume() const { return m_Volume; } + void SetVolume(float volume) { m_Volume = volume; } - float GetSurroundPan() const; - void SetSurroundPan(float surroundPan); + float GetPan() const { return m_Pan; } + void SetPan(float pan) { m_Pan = pan; } + + float GetSurroundPan() const { return m_SurroundPan; } + void SetSurroundPan(float surroundPan) { m_SurroundPan = surroundPan; } - float GetEffectSend(int) const; - void SetEffectSend(int, float) const; + float GetEffectSend(int auxBusIndex) const { return m_FxSend[auxBusIndex]; } + void SetEffectSend(int auxBusIndex, float send) { m_FxSend[auxBusIndex] = send; } private: f32 m_Volume; f32 m_Pan; f32 m_SurroundPan; - f32 m_FxSend[3]; + f32 m_FxSend[AuxBus_Count]; }; static_assert(sizeof(OutputAmbientParam) == 0x18); class SoundAmbientParam { public: - static const int OutputLineFlagInherit = -1; - - SoundAmbientParam(); + static const int OutputLineFlagInherit{-1}; + + SoundAmbientParam() { + m_TvParam.Initialize(); + } float GetVolume() const { return m_Volume; } void SetVolume(float volume) { m_Volume = volume; } @@ -76,12 +84,12 @@ class SoundAmbientParam { void SetTvParam(const OutputAmbientParam& tvParam) { m_TvParam = tvParam; } private: - float m_Volume; - float m_Pitch; - float m_Lpf; - float m_BiquadFilterValue; - int m_BiquadFilterType; - int m_Priority; + float m_Volume{1.0f}; + float m_Pitch{1.0f}; + float m_Lpf{0.0f}; + float m_BiquadFilterValue{0.0f}; + int m_BiquadFilterType{BiquadFilterType_Inherit}; + int m_Priority{0}; u32 m_UserData; int m_OutputLineFlag; OutputAmbientParam m_TvParam; @@ -90,9 +98,21 @@ static_assert(sizeof(SoundAmbientParam) == 0x38); class SoundParam { public: - SoundParam(); - - void Initialize(); + SoundParam() { + Initialize(); + } + + void Initialize() { + m_Volume = 1.0f; + m_Pitch = 1.0f; + m_Lpf = 0.0f; + m_BiquadFilterType = BiquadFilterType_Inherit; + m_BiquadFilterValue = 0.0f; + m_Priority = 0; + m_OutputLineFlag = SoundAmbientParam::OutputLineFlagInherit; + m_UserData = 0; + m_TvParam.Initialize(); + } float GetVolume() const { return m_Volume; } void SetVolume(float volume) { m_Volume = volume; } @@ -137,7 +157,7 @@ static_assert(sizeof(SoundParam) == 0x38); struct SoundParamCalculationValues { struct SoundArchiveParam { - f32 volume; + float volume; }; static_assert(sizeof(SoundArchiveParam) == 0x4); @@ -148,10 +168,10 @@ struct SoundParamCalculationValues { float bqfValue; float outputVolume[1]; float outputMainSend[1]; - float outputEffectSend[1][3]; + float outputEffectSend[1][AuxBus_Count]; }; static_assert(sizeof(SoundPlayerParam) == 0x24); - + struct Sound3DParam { float volume; float pitch; @@ -162,7 +182,7 @@ struct SoundParamCalculationValues { float outputVolume[1]; float outputPan[1]; float outputSurroundPan[1]; - float outputEffectSend[1][3]; + float outputEffectSend[1][AuxBus_Count]; int playerPriority; }; static_assert(sizeof(Sound3DParam) == 0x34); @@ -187,13 +207,13 @@ struct SoundParamCalculationValues { float outputPan[1]; float outputSurroundPan[1]; float outputMainSend[1]; - float outputEffectSend[1][3]; + float outputEffectSend[1][AuxBus_Count]; MixParameter outputMixParameter[1][2]; MixMode mixMode; float pan; float surroundPan; float mainSend; - float effectSend[3]; + float effectSend[AuxBus_Count]; int playerPriority; }; static_assert(sizeof(SoundHandleParam) == 0x84); @@ -229,6 +249,7 @@ struct SoundParamCalculationValues { static_assert(sizeof(SoundParamCalculationValues) == 0x170); namespace detail { + class PlayerHeap; class ExternalSoundPlayer; @@ -243,9 +264,21 @@ struct SoundActorParam { float biquadFilterValue; #endif - SoundActorParam(); + SoundActorParam() { + Reset(); + } - void Reset(); + void Reset() { + volume = 1.0f; + pitch = 1.0f; + tvVolume = 1.0f; + tvPan = 0.0f; + lpf = 0.0f; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) + biquadFilterType = BiquadFilterType_Min; + biquadFilterValue = 0.0f; +#endif + } }; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(SoundActorParam) == 0x14); @@ -255,18 +288,13 @@ static_assert(sizeof(SoundActorParam) == 0x1c); class BasicSound { NN_ATK_RTTI_BASE(BasicSound); -public: - enum PlayerState { - PlayerState_Init, - PlayerState_Play, - PlayerState_Stop, - }; - struct AmbientParamUpdateCallback{}; - struct AmbientArgUpdateCallback{}; - struct AmbientArgAllocatorCallback{}; +public: + struct AmbientParamUpdateCallback {}; + struct AmbientArgUpdateCallback {}; + struct AmbientArgAllocatorCallback {}; - struct AmbientInfo { // 703 + struct AmbientInfo { AmbientParamUpdateCallback* paramUpdateCallback; AmbientArgUpdateCallback* argUpdateCallback; AmbientArgAllocatorCallback* argAllocatorCallback; @@ -275,10 +303,16 @@ class BasicSound { }; static_assert(sizeof(AmbientInfo) == 0x28); + enum PlayerState { + PlayerState_Init, + PlayerState_Play, + PlayerState_Stop, + }; + BasicSound(); virtual ~BasicSound(); - void Update(); // 725 + void Update(); void StartPrepared(); void Stop(int fadeFrames); @@ -354,7 +388,7 @@ class BasicSound { void SetPanMode(PanMode mode); void SetPanCurve(PanCurve curve); #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) - void SetOutputAdditionalParamAddr(OutputDevice device, OutputAdditionalParam* addr, + void SetOutputAdditionalParamAddr(OutputDevice device, OutputAdditionalParam* addr, OutputAdditionalParam* addrForPlayer); #endif void SetOutputVolume(OutputDevice device, float volume); @@ -365,7 +399,8 @@ class BasicSound { void SetOutputFxSend(OutputDevice device, float send); void SetOutputAdditionalSend(OutputDevice device, int bus, float send); void SetOutputBusMixVolumeEnabled(OutputDevice device, int subMixBus, bool isEnabled); - void SetOutputBusMixVolume(OutputDevice device, int srcChNo, int subMixBus, ChannelMixVolume param); + void SetOutputBusMixVolume(OutputDevice device, int srcChNo, int subMixBus, + ChannelMixVolume param); void SetOutputChannelMixParameter(OutputDevice device, u32 srcChNo, MixParameter param); void SetOutputVolumeThroughMode(OutputDevice device, int bus, u8 modeBitFlag); @@ -383,26 +418,30 @@ class BasicSound { int GetRemainingFadeFrames() const; int GetRemainingPauseFadeFrames() const; int GetRemainingMuteFadeFrames() const; - int GetPlayerPriority() const; + int GetPlayerPriority() const; // inlined? void CalculateSoundParamCalculationValues(SoundParamCalculationValues* pOutValue) const; void SetId(u32 id); - u32 GetId() const; + u32 GetId() const { return m_Id; } u32 GetInstanceId() const; - u32 GetPlayFrameCount() const; + u32 GetPlayFrameCount() const { return m_PlayingCounter; } void SetSetupTick(const os::Tick& tick); - os::Tick GetSetupTick() const; + os::Tick GetSetupTick() const { return m_SetupTick; } + + int CalcCurrentPlayerPriority() const { + return fnd::Clamp(m_AmbientParam.GetPriority(), 0, 127); + } - int CalcCurrentPlayerPriority() const; + SoundPlayer* GetSoundPlayer() { return m_pSoundPlayer; } + const SoundPlayer* GetSoundPlayer() const { return m_pSoundPlayer; } - SoundPlayer* GetSoundPlayer(); - const SoundPlayer* GetSoundPlayer() const; void AttachSoundPlayer(SoundPlayer* player); void DetachSoundPlayer(SoundPlayer* player); - const SoundActor* GetSoundActor() const; + const SoundActor* GetSoundActor() const { return m_pSoundActor; } + void AttachSoundActor(SoundActor* actor); void DetachSoundActor(SoundActor* actor); @@ -411,13 +450,17 @@ class BasicSound { void AttachPlayerHeap(PlayerHeap* pHeap); void DetachPlayerHeap(PlayerHeap* pHeap); - PlayerHeap* GetPlayerHeap(); + + PlayerHeap* GetPlayerHeap() { return m_pPlayerHeap; } void SetAmbientInfo(const AmbientInfo& ambientArgInfo); + void ClearAmbientArgUpdateCallback(); void ClearAmbientParamUpdateCallback(); void ClearAmbientArgAllocatorCallback(); - const SoundParam& GetAmbientParam() const; + + const SoundParam& GetAmbientParam() const { return m_AmbientParam; } + static int GetAmbientPriority(const AmbientInfo& ambientInfo, u32 soundId); bool IsAttachedGeneralHandle(); @@ -428,12 +471,17 @@ class BasicSound { void DetachTempGeneralHandle(); virtual void DetachTempSpecialHandle() = 0; - void SetUserParamBuffer(void* buffer, size_t size); - void* GetUserParam(); + void SetUserParamBuffer(void* buffer, size_t size) { + m_pUserParam = buffer; + m_UserParamSize = size; + } + + void* GetUserParam() { return m_pUserParam; } + + void SetSoundStopCallback(const SoundStopCallback callback) { m_SoundStopCallback = callback; } - void SetSoundStopCallback(const SoundStopCallback callback); void SetSoundArchive(const SoundArchive* soundArchive); - const SoundArchive* GetSoundArchive() const; + const SoundArchive* GetSoundArchive() const { return m_pSoundArchive; } enum PauseState { PauseState_Normal, @@ -441,7 +489,7 @@ class BasicSound { PauseState_Paused, PauseState_Unpausing, }; - PauseState GetPauseState() const; + PauseState GetPauseState() const { return static_cast(m_PauseState); } enum MuteState { MuteState_Normal, @@ -449,15 +497,15 @@ class BasicSound { MuteState_Muted, MuteState_Unmuting, }; - MuteState GetMuteState() const; + MuteState GetMuteState() const { return static_cast(m_MuteState); } protected: virtual driver::BasicSoundPlayer* GetBasicSoundPlayerHandle() = 0; - virtual void OnUpdatePlayerPriority(); + virtual void OnUpdatePlayerPriority() {} virtual void UpdateMoveValue(); - virtual void OnUpdateParam(); + virtual void OnUpdateParam() {} - bool IsPlayerAvailable() const; + bool IsPlayerAvailable() const { return m_PlayerAvailableFlag; } private: void UpdateParam(); @@ -471,7 +519,7 @@ class BasicSound { u32 CalculateOutLineFlag() const; void CalculateOutputParam(OutputParam* pOutParam, OutputDevice device) const; void CalculateOutputBusMixVolume(OutputBusMixVolume* pOutParam, OutputDevice device) const; - + void ApplyCommonParam(OutputParam& param) const; enum State { @@ -481,8 +529,8 @@ class BasicSound { State_Destructed, }; - PlayerHeap* m_pPlayerHeap; // 934 - SoundHandle* m_pGeneralHandle; + PlayerHeap* m_pPlayerHeap; + SoundHandle* m_pGeneralHandle; SoundHandle* m_pTempGeneralHandle; SoundPlayer* m_pSoundPlayer; SoundActor* m_pSoundActor; @@ -503,7 +551,7 @@ class BasicSound { PauseMode m_PauseMode; u8 m_Priority; s8 m_BiquadFilterType; - State m_State; + State m_State{State_Constructed}; u8 m_PlayerState; u8 m_PauseState; u8 m_MuteState; @@ -513,17 +561,17 @@ class BasicSound { u32 m_PlayingCounter; u32 m_Id; u32 m_InstanceId; - os::Tick m_SetupTick; + os::Tick m_SetupTick{0}; f32 m_InitVolume; f32 m_Pitch; f32 m_LpfFreq; f32 m_BiquadFilterValue; u32 m_OutputLineFlag; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) - OutputReceiver* m_pOutputReceiver; // 981 + OutputReceiver* m_pOutputReceiver; #endif - struct CommonParam { // 984 + struct CommonParam { MoveValue volume; MixMode mixMode; float pan; @@ -539,17 +587,11 @@ class BasicSound { send[i] = 0.0f; } - void Update() { - volume.Update(); - } + void Update() { volume.Update(); } - float GetVolume() const { - return volume.GetValue(); - } + float GetVolume() const { return volume.GetValue(); } - void SetVolume(float target, int frame) { - volume.SetTarget(target, frame); - } + void SetVolume(float target, int frame) { volume.SetTarget(target, frame); } CommonParam() = default; }; @@ -559,11 +601,11 @@ class BasicSound { OutputParam m_OutputParam[1]; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) - OutputAdditionalParam* m_pOutputAdditionalParam[1]; + OutputAdditionalParam* m_pOutputAdditionalParam[1]{}; #endif - void* m_pUserParam; - size_t m_UserParamSize; - SoundStopCallback m_SoundStopCallback; + void* m_pUserParam{}; + size_t m_UserParamSize{0}; + SoundStopCallback m_SoundStopCallback{}; static u32 g_LastInstanceId; @@ -571,12 +613,12 @@ class BasicSound { util::IntrusiveListNode m_SoundPlayerPlayLink; util::IntrusiveListNode m_SoundPlayerPriorityLink; util::IntrusiveListNode m_ExtSoundPlayerPlayLink; - }; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(BasicSound) == 0x1f0); #else static_assert(sizeof(BasicSound) == 0x210); #endif + } // namespace detail } // namespace nn::atk diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index e69de29b..167fcb94 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -0,0 +1,7 @@ +#include + +namespace nn::atk::detail { + +BasicSound::BasicSound() = default; + +} // namespace nn::atk::detail \ No newline at end of file From 0b61028aad76060e44ef9876f55539d4bee22c43 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 11 Sep 2026 15:09:16 -0300 Subject: [PATCH 625/785] atk: Match `BasicSound::StartPrepared` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 167fcb94..95ef649f 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -2,6 +2,11 @@ namespace nn::atk::detail { +// NON_MATCHING on versions lower than 4.0.0 BasicSound::BasicSound() = default; +void BasicSound::StartPrepared() { + m_StartFlag = true; +} + } // namespace nn::atk::detail \ No newline at end of file From 6127a716fc96361b888bdff410ffb78013bcce1f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 11 Sep 2026 15:13:01 -0300 Subject: [PATCH 626/785] atk: Match `BasicSound::SetPlayerPriority` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 95ef649f..701233b8 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -1,5 +1,7 @@ #include +#include + namespace nn::atk::detail { // NON_MATCHING on versions lower than 4.0.0 @@ -9,4 +11,12 @@ void BasicSound::StartPrepared() { m_StartFlag = true; } +void BasicSound::SetPlayerPriority(int priority) { + m_Priority = priority; + + if (m_pSoundPlayer != nullptr) + m_pSoundPlayer->detail_SortPriorityList(this); + + OnUpdatePlayerPriority(); +} } // namespace nn::atk::detail \ No newline at end of file From 1f30921ed698238c7ee439df4ccb820e32ab00e4 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 11 Sep 2026 15:28:53 -0300 Subject: [PATCH 627/785] atk: Match `BasicSound::Stop` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 701233b8..99d9d8ca 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -11,6 +11,24 @@ void BasicSound::StartPrepared() { m_StartFlag = true; } +void BasicSound::Stop(int fadeFrames) { + if ((fadeFrames <= 0 || m_PauseState == PauseState_Paused) || (!m_StartFlag && !m_StartedFlag)) { + Finalize(); + return; + } + + int frames{static_cast(fadeFrames * m_FadeVolume.GetValue())}; + m_FadeVolume.SetTarget(0.0f, frames); + SetPlayerPriority(0); + + m_AutoStopFlag = false; + m_PauseState = PauseState_Normal; + m_UnPauseFlag = false; + m_PauseMode = PauseMode_Default; + m_FadeOutFlag = true; + m_MuteState = MuteState_Normal; +} + void BasicSound::SetPlayerPriority(int priority) { m_Priority = priority; From 758c2439230a930ebfe2ae3efd850f880c3dce5c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 11 Sep 2026 15:34:55 -0300 Subject: [PATCH 628/785] atk: Match `BasicSound::ForceStop` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 99d9d8ca..2eee5c56 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -29,6 +29,12 @@ void BasicSound::Stop(int fadeFrames) { m_MuteState = MuteState_Normal; } +void BasicSound::ForceStop() { + m_FadeOutFlag = true; + + Finalize(); +} + void BasicSound::SetPlayerPriority(int priority) { m_Priority = priority; From 28eb71e50cdb6598e132df0368698df9829243bc Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 11 Sep 2026 16:02:59 -0300 Subject: [PATCH 629/785] atk: Match `BasicSound::Pause` --- include/nn/atk/atk_BasicSound.h | 2 +- .../atk/detail/atk_BasicSound.cpp | 51 +++++++++++++++++-- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index 8119b127..1225be27 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -418,7 +418,7 @@ class BasicSound { int GetRemainingFadeFrames() const; int GetRemainingPauseFadeFrames() const; int GetRemainingMuteFadeFrames() const; - int GetPlayerPriority() const; // inlined? + int GetPlayerPriority() const { return m_Priority; } void CalculateSoundParamCalculationValues(SoundParamCalculationValues* pOutValue) const; diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 2eee5c56..80ba7c4d 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -12,7 +12,8 @@ void BasicSound::StartPrepared() { } void BasicSound::Stop(int fadeFrames) { - if ((fadeFrames <= 0 || m_PauseState == PauseState_Paused) || (!m_StartFlag && !m_StartedFlag)) { + if ((fadeFrames <= 0 || m_PauseState == PauseState_Paused) || + (!m_StartFlag && !m_StartedFlag)) { Finalize(); return; } @@ -35,12 +36,54 @@ void BasicSound::ForceStop() { Finalize(); } +void BasicSound::Pause(bool flag, int fadeFrames) { + Pause(flag, fadeFrames, PauseMode_Default); +} + +void BasicSound::Pause(bool flag, int fadeFrames, PauseMode pauseMode) { + int frames; + if (flag) { + switch (m_PauseState) { + case PauseState_Normal: + case PauseState_Unpausing: + case PauseState_Pausing: + frames = static_cast(fadeFrames * m_PauseFadeVolume.GetValue()); + frames = frames > 0 ? frames : 1; + m_PauseFadeVolume.SetTarget(0.0f, frames); + m_PauseState = PauseState_Pausing; + m_UnPauseFlag = false; + break; + case PauseState_Paused: + default: + return; + } + } else { + switch (m_PauseState - 1) { + case PauseState_Normal: + case PauseState_Pausing: + case PauseState_Paused: + frames = static_cast(fadeFrames * (1.0f - m_PauseFadeVolume.GetValue())); + frames = frames > 0 ? frames : 1; + m_PauseFadeVolume.SetTarget(1.0f, frames); + m_PauseState = PauseState_Unpausing; + m_UnPauseFlag = true; + break; + case PauseState_Unpausing: + default: + return; + } + } + + m_PauseMode = pauseMode; +} + void BasicSound::SetPlayerPriority(int priority) { m_Priority = priority; - + if (m_pSoundPlayer != nullptr) m_pSoundPlayer->detail_SortPriorityList(this); - + OnUpdatePlayerPriority(); } -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail From a77b608b35120419a2ded813c5b7c175cd67e2fe Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 11 Sep 2026 16:22:13 -0300 Subject: [PATCH 630/785] atk: Match `BasicSound::Mute` --- include/nn/atk/atk_BasicSound.h | 1 + .../detail/atk_AddonSoundArchiveContainer.cpp | 2 +- .../atk/detail/atk_BasicSound.cpp | 35 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index 1225be27..7846cd6f 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -320,6 +320,7 @@ class BasicSound { void Pause(bool flag, int fadeFrames); void Pause(bool flag, int fadeFrames, PauseMode pauseMode); + void Mute(bool flag, int fadeFrames); void SetAutoStopCounter(int frames); diff --git a/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp b/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp index 55e65764..db71a9ce 100644 --- a/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp +++ b/src/NintendoWare/atk/detail/atk_AddonSoundArchiveContainer.cpp @@ -44,4 +44,4 @@ void AddonSoundArchiveContainer::SetAddTick(const os::Tick& tick) { m_AddTick = tick; } -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 80ba7c4d..85c656d4 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -42,6 +42,7 @@ void BasicSound::Pause(bool flag, int fadeFrames) { void BasicSound::Pause(bool flag, int fadeFrames, PauseMode pauseMode) { int frames; + if (flag) { switch (m_PauseState) { case PauseState_Normal: @@ -77,6 +78,40 @@ void BasicSound::Pause(bool flag, int fadeFrames, PauseMode pauseMode) { m_PauseMode = pauseMode; } +void BasicSound::Mute(bool flag, int fadeFrames) { + int frames; + + if (flag) { + switch (m_MuteState) { + case MuteState_Normal: + case MuteState_Muting: + case MuteState_Unmuting: + frames = static_cast(fadeFrames * m_MuteFadeVolume.GetValue()); + frames = frames > 0 ? frames : 1; + m_MuteFadeVolume.SetTarget(0.0f, frames); + m_MuteState = MuteState_Muting; + break; + case MuteState_Muted: + default: + return; + } + } else { + switch (m_MuteState - 1) { + case MuteState_Normal: + case MuteState_Muting: + case MuteState_Muted: + frames = static_cast(fadeFrames * (1.0f - m_MuteFadeVolume.GetValue())); + frames = frames > 0 ? frames : 1; + m_MuteFadeVolume.SetTarget(1.0f, frames); + m_MuteState = MuteState_Unmuting; + break; + case MuteState_Unmuting: + default: + return; + } + } +} + void BasicSound::SetPlayerPriority(int priority) { m_Priority = priority; From a0a06e6db37eae565930a04d6f67439358caab6c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 11 Sep 2026 16:24:14 -0300 Subject: [PATCH 631/785] atk: Match `BasicSound::SetAutoStopCounter` --- include/nn/atk/atk_BasicSound.h | 15 +++++---------- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 5 +++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index 7846cd6f..008f2040 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -52,9 +52,7 @@ class SoundAmbientParam { public: static const int OutputLineFlagInherit{-1}; - SoundAmbientParam() { - m_TvParam.Initialize(); - } + SoundAmbientParam() { m_TvParam.Initialize(); } float GetVolume() const { return m_Volume; } void SetVolume(float volume) { m_Volume = volume; } @@ -98,9 +96,7 @@ static_assert(sizeof(SoundAmbientParam) == 0x38); class SoundParam { public: - SoundParam() { - Initialize(); - } + SoundParam() { Initialize(); } void Initialize() { m_Volume = 1.0f; @@ -264,9 +260,7 @@ struct SoundActorParam { float biquadFilterValue; #endif - SoundActorParam() { - Reset(); - } + SoundActorParam() { Reset(); } void Reset() { volume = 1.0f; @@ -320,10 +314,11 @@ class BasicSound { void Pause(bool flag, int fadeFrames); void Pause(bool flag, int fadeFrames, PauseMode pauseMode); - + void Mute(bool flag, int fadeFrames); void SetAutoStopCounter(int frames); + void FadeIn(int frames); #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 85c656d4..5f6c9d45 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -112,6 +112,11 @@ void BasicSound::Mute(bool flag, int fadeFrames) { } } +void BasicSound::SetAutoStopCounter(int frames) { + m_AutoStopCounter = frames; + m_AutoStopFlag = frames > 0; +} + void BasicSound::SetPlayerPriority(int priority) { m_Priority = priority; From 29223a9d9c91a307f2d6ee72ad48ecb99d1cd0a0 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 11 Sep 2026 16:26:20 -0300 Subject: [PATCH 632/785] atk: Match `BasicSound::FadeIn` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 5f6c9d45..1f9718b6 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -115,7 +115,15 @@ void BasicSound::Mute(bool flag, int fadeFrames) { void BasicSound::SetAutoStopCounter(int frames) { m_AutoStopCounter = frames; m_AutoStopFlag = frames > 0; -} +} + +void BasicSound::FadeIn(int frames) { + if (m_FadeOutFlag || m_UpdateCounter > 0) + return; + + m_FadeVolume.InitValue(0.0f); + m_FadeVolume.SetTarget(1.0f, frames); +} void BasicSound::SetPlayerPriority(int priority) { m_Priority = priority; From 14321dbba1b23bf7392de9747ba01d3e00b2e588 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 11 Sep 2026 21:09:09 -0300 Subject: [PATCH 633/785] atk: Add non-matching implementation for `BasicSound::Initialize` --- include/nn/atk/atk_BasicSoundPlayer.h | 2 + include/nn/atk/atk_Command.h | 4 +- include/nn/atk/atk_CommandManager.h | 71 +++++++----- include/nn/atk/atk_DriverCommand.h | 5 +- .../atk/detail/atk_BasicSound.cpp | 102 ++++++++++++++++++ 5 files changed, 155 insertions(+), 29 deletions(-) diff --git a/include/nn/atk/atk_BasicSoundPlayer.h b/include/nn/atk/atk_BasicSoundPlayer.h index 71e4baf1..55c3eccb 100644 --- a/include/nn/atk/atk_BasicSoundPlayer.h +++ b/include/nn/atk/atk_BasicSoundPlayer.h @@ -39,6 +39,8 @@ class BasicSoundPlayer { BasicSoundPlayer(); void SetBiquadFilter(s32 type, f32 value); + void InitializeEvent() { m_Event.Clear(); } + private: os::Event m_Event; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) diff --git a/include/nn/atk/atk_Command.h b/include/nn/atk/atk_Command.h index 05134198..5eaf0108 100644 --- a/include/nn/atk/atk_Command.h +++ b/include/nn/atk/atk_Command.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail { + struct Command { Command* next; u32 id; @@ -10,4 +11,5 @@ struct Command { std::uintptr_t memory_next; }; static_assert(sizeof(Command) == 0x18); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_CommandManager.h b/include/nn/atk/atk_CommandManager.h index dd49a138..fafe0dde 100644 --- a/include/nn/atk/atk_CommandManager.h +++ b/include/nn/atk/atk_CommandManager.h @@ -6,18 +6,18 @@ #include namespace nn::atk::detail { + class CommandBuffer { public: CommandBuffer(); ~CommandBuffer(); + void Initialize(void* commandBuffer, size_t commandBufferSize); void Finalize(); - void Initialize(void* buffer, size_t bufferSize); - void* AllocMemory(size_t size); - void FreeMemory(Command* command); + void FreeMemory(Command* lastCommand); size_t GetCommandBufferSize() const; size_t GetAllocatableCommandSize() const; @@ -26,63 +26,79 @@ class CommandBuffer { private: u32* m_CommandMemoryArea; size_t m_CommandMemoryAreaSize; - std::uintptr_t m_CommandMemoryAreaBegin; - std::uintptr_t m_CommandMemoryAreaEnd; + uintptr_t m_CommandMemoryAreaBegin; + uintptr_t m_CommandMemoryAreaEnd; bool m_CommandMemoryAreaZeroFlag; }; static_assert(sizeof(CommandBuffer) == 0x28); class CommandManager { public: - using ProcessCommandListFunc = void(*)(Command*); - using RequestProcessCommandFunc = void(*)(); - - constexpr static s32 SendCommandQueueCount = 32; - constexpr static s32 RecvCommandQueueCount = 33; - constexpr static s32 InvalidCommand = -1; + using ProcessCommandListFunc = void (*)(Command*); + using RequestProcessCommandFunc = void (*)(); CommandManager(); ~CommandManager(); - void Finalize(); + bool IsAvailable() const { return m_Available; } + void Initialize(void* commandBuffer, size_t commandBufferSize, ProcessCommandListFunc func); + void Finalize(); - void* AllocMemory(size_t size, bool forceProcessCommandFlag); + void SetRequestProcessCommandFunc(RequestProcessCommandFunc func) { + m_pRequestProcessCommandFunc = func; + } - bool TryAllocMemory(size_t size); + template + CommandType* AllocCommand() { + return static_cast(AllocMemory(sizeof(CommandType), true)); + } - void RecvCommandReply(); + template + CommandType* AllocCommand(bool forceProcessCommandFlag) { + return static_cast(AllocMemory(sizeof(CommandType), forceProcessCommandFlag)); + } - u32 FlushCommand(bool forceFlag, bool forceProcessCommandFlag); + u32 PushCommand(Command* command); - void WaitCommandReply(u32 tag); + u32 FlushCommand(bool forceFlag); + u32 FlushCommand(bool forceFlag, bool forceProcessCommandFlag); + void RecvCommandReply(); void RecvCommandReplySync(); - u32 PushCommand(Command* command); - u32 FlushCommand(bool forceFlag); - - void FinalizeCommandList(Command* command); + void WaitCommandReply(u32 tag); - bool IsFinishCommand(u32) const; + bool IsFinishCommand(u32 tag) const; size_t GetCommandBufferSize() const; size_t GetAllocatableCommandSize() const; size_t GetAllocatedCommandBufferSize() const; - s32 GetAllocatedCommandCount() const; + int GetAllocatedCommandCount() const; + + u32 GetCommandListCount() const { return m_CommandListCount; } bool ProcessCommand(); private: + void* AllocMemory(size_t size, bool forceProcessCommandFlag); + bool TryAllocMemory(size_t size); + + void FinalizeCommandList(Command* command); + + static const int SendCommandQueueCount{32}; + static const int RecvCommandQueueCount{SendCommandQueueCount + 1}; + static const u32 InvalidCommand{0xffffffff}; + bool m_Available; ProcessCommandListFunc m_pProcessCommandListFunc; RequestProcessCommandFunc m_pRequestProcessCommandFunc; os::MessageQueueType m_SendCommandQueue; - std::uintptr_t m_SendCommandQueueBuffer[SendCommandQueueCount]; + uintptr_t m_SendCommandQueueBuffer[SendCommandQueueCount]; bool m_IsInitializedSendMessageQueue; os::MessageQueueType m_RecvCommandQueue; - std::uintptr_t m_RecvCommandQueueBuffer[RecvCommandQueueCount]; + uintptr_t m_RecvCommandQueueBuffer[RecvCommandQueueCount]; bool m_IsInitializedRecvMessageQueue; Command* m_CommandListBegin; Command* m_CommandListEnd; @@ -90,7 +106,8 @@ class CommandManager { u32 m_CommandTag; u32 m_FinishCommandTag; CommandBuffer m_CommandBuffer; - s32 m_AllocatedCommandCount; + int m_AllocatedCommandCount; }; static_assert(sizeof(CommandManager) == 0x310); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_DriverCommand.h b/include/nn/atk/atk_DriverCommand.h index 1450a0a7..d853a9a6 100644 --- a/include/nn/atk/atk_DriverCommand.h +++ b/include/nn/atk/atk_DriverCommand.h @@ -515,8 +515,10 @@ struct DriverCommandVoiceAdpcmParam : DriverCommandVoice { }; static_assert(sizeof(DriverCommandVoiceAdpcmParam) == 0x30); -class DriverCommand : CommandManager { +class DriverCommand : public CommandManager { public: + static DriverCommand* GetInstance(); + static void ProcessCommandList(Command* commandList); DriverCommand(); @@ -524,6 +526,7 @@ class DriverCommand : CommandManager { void Initialize(void* commandBuffer, size_t commandBufferSize); void RequestProcessCommand(); + }; static_assert(sizeof(DriverCommand) == 0x310); } // namespace nn::atk::detail \ No newline at end of file diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 1f9718b6..3a6e81cc 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -1,5 +1,8 @@ #include +#include + +#include #include namespace nn::atk::detail { @@ -7,6 +10,105 @@ namespace nn::atk::detail { // NON_MATCHING on versions lower than 4.0.0 BasicSound::BasicSound() = default; +// NON_MATCHING: bad order of instructions +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) +bool BasicSound::Initialize() +#else +bool BasicSound::Initialize(OutputReceiver* pOutputReceiver) +#endif +{ + m_InstanceId = g_LastInstanceId++; + // ++g_LastInstanceId; + + m_pPlayerHeap = nullptr; + m_pExtSoundPlayer = nullptr; + m_pSoundArchive = nullptr; + + m_PlayerState = PlayerState_Init; + m_PauseState = PauseState_Normal; + + m_pSoundPlayer = nullptr; + m_pSoundActor = nullptr; + m_MuteState = MuteState_Normal; + + m_pGeneralHandle = nullptr; + m_pTempGeneralHandle = nullptr; + + m_PauseMode = PauseMode_Default; + + m_BiquadFilterType = BiquadFilterType_Inherit; + + m_AutoStopCounter = 0; + m_UpdateCounter = 0; + m_PlayingCounter = 0; + m_Id = 0xffffffff; + + m_AmbientInfo.paramUpdateCallback = nullptr; + m_AmbientInfo.argUpdateCallback = nullptr; + m_AmbientInfo.argAllocatorCallback = nullptr; + m_AmbientInfo.arg = nullptr; + m_AmbientInfo.argSize = 0; + + m_StartFlag = false; + m_StartedFlag = false; + m_AutoStopFlag = false; + m_FadeOutFlag = false; + m_PlayerAvailableFlag = false; + m_UnPauseFlag = false; + + m_FadeVolume.InitValue(1.0f); + m_PauseFadeVolume.InitValue(1.0f); + m_MuteFadeVolume.InitValue(1.0f); + + m_InitVolume = 1.0f; + m_Pitch = 1.0f; + m_LpfFreq = 0.0f; + m_BiquadFilterValue = 0.0f; + m_OutputLineFlag = OutputLine_Main; + // m_Priority = 0; + + m_CommonParam.Initialize(); + + for (int i{0}; i < 1; ++i) { + m_OutputParam[i].Initialize(); +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) + if (m_pOutputAdditionalParam[i] != nullptr) + m_pOutputAdditionalParam[i]->Reset(); +#endif + } + + m_AmbientParam.Initialize(); + m_ActorParam.Reset(); + + if (m_UserParamSize != 0) + std::memset(m_pUserParam, 0, m_UserParamSize); + + { + driver::BasicSoundPlayer* basicPlayer{GetBasicSoundPlayerHandle()}; + + DriverCommand& cmdmgr{*DriverCommand::GetInstance()}; + + auto* command{cmdmgr.AllocCommand()}; + command->id = DriverCommandId_PlayerInit; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) + command->pOutputReceiver = pOutputReceiver; +#endif + command->availableFlagPtr = &m_PlayerAvailableFlag; + command->player = basicPlayer; + + cmdmgr.PushCommand(command); + + basicPlayer->InitializeEvent(); + } + +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) + pOutputReceiver->AddReferenceCount(1); + m_pOutputReceiver = pOutputReceiver; +#endif + m_State = State_Initialized; + return true; +} + void BasicSound::StartPrepared() { m_StartFlag = true; } From 38850f6a71d661941311831c1cb86b975056b7d6 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 11 Sep 2026 21:12:34 -0300 Subject: [PATCH 634/785] atk: Match `BasicSound::IsAttachedGeneralHandle` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 3a6e81cc..55163568 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -236,4 +236,8 @@ void BasicSound::SetPlayerPriority(int priority) { OnUpdatePlayerPriority(); } +bool BasicSound::IsAttachedGeneralHandle() { + return m_pGeneralHandle != nullptr; +} + } // namespace nn::atk::detail From a89ee595024408626e249ce6028bd5a206e6a264 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 11 Sep 2026 21:12:57 -0300 Subject: [PATCH 635/785] atk: Match `BasicSound::IsAttachedTempGeneralHandle` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 55163568..3ad0e9a6 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -240,4 +240,8 @@ bool BasicSound::IsAttachedGeneralHandle() { return m_pGeneralHandle != nullptr; } +bool BasicSound::IsAttachedTempGeneralHandle() { + return m_pTempGeneralHandle != nullptr; +} + } // namespace nn::atk::detail From 6db80694f6cd41217e3136d0bdd01f123c91dafd Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 11 Sep 2026 21:13:58 -0300 Subject: [PATCH 636/785] atk: Match `BasicSound::DetachGeneralHandle` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 3ad0e9a6..3bdd2503 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -4,6 +4,7 @@ #include #include +#include namespace nn::atk::detail { @@ -244,4 +245,8 @@ bool BasicSound::IsAttachedTempGeneralHandle() { return m_pTempGeneralHandle != nullptr; } +void BasicSound::DetachGeneralHandle() { + m_pGeneralHandle->DetachSound(); +} + } // namespace nn::atk::detail From 7b68cac294d8909e1bffe768dab8fdbf72ee1daa Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 11 Sep 2026 21:14:14 -0300 Subject: [PATCH 637/785] atk: Match `BasicSound::DetachTempGeneralHandle` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 3bdd2503..0a4a61ba 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -249,4 +249,8 @@ void BasicSound::DetachGeneralHandle() { m_pGeneralHandle->DetachSound(); } +void BasicSound::DetachTempGeneralHandle() { + m_pTempGeneralHandle->DetachSound(); +} + } // namespace nn::atk::detail From 172ed0cbc72b654f18fa256200c098b054cec1ac Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 11 Sep 2026 21:29:07 -0300 Subject: [PATCH 638/785] atk: Match `BasicSound::SetId` --- include/nn/atk/atk_BasicSound.h | 7 ++++++- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index 008f2040..98d6829e 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -286,7 +286,12 @@ class BasicSound { public: struct AmbientParamUpdateCallback {}; struct AmbientArgUpdateCallback {}; - struct AmbientArgAllocatorCallback {}; + struct AmbientArgAllocatorCallback { + virtual void Impl1(); + virtual void Impl2(); + virtual void Impl3(); + virtual void RemoveSoundImpl(void* arg, BasicSound* sound); + }; struct AmbientInfo { AmbientParamUpdateCallback* paramUpdateCallback; diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 0a4a61ba..994680af 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -237,6 +237,10 @@ void BasicSound::SetPlayerPriority(int priority) { OnUpdatePlayerPriority(); } +void BasicSound::SetId(u32 id) { + m_Id = id; +} + bool BasicSound::IsAttachedGeneralHandle() { return m_pGeneralHandle != nullptr; } From 828a006c3360b5af1304430cfcb796a7ab3ea01a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Fri, 11 Sep 2026 21:30:23 -0300 Subject: [PATCH 639/785] atk: Match `BasicSound::Finalize` --- .../atk/detail/atk_BasicSound.cpp | 67 ++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 994680af..21b73b36 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -3,8 +3,9 @@ #include #include -#include +#include #include +#include namespace nn::atk::detail { @@ -110,6 +111,70 @@ bool BasicSound::Initialize(OutputReceiver* pOutputReceiver) return true; } +void BasicSound::Finalize() { + if (m_State != State_Initialized) + return; + + SetId(0xffffffff); + + if (IsAttachedGeneralHandle()) + DetachGeneralHandle(); + + if (IsAttachedTempGeneralHandle()) + DetachTempGeneralHandle(); + + if (IsAttachedTempSpecialHandle()) + DetachTempSpecialHandle(); + + if (m_pSoundPlayer != nullptr) + m_pSoundPlayer->detail_RemoveSound(this); + + if (m_pExtSoundPlayer != nullptr) + m_pExtSoundPlayer->RemoveSound(this); + + if (m_AmbientInfo.argAllocatorCallback != nullptr) { + m_AmbientInfo.argAllocatorCallback->RemoveSoundImpl(m_AmbientInfo.arg, this); + m_AmbientInfo.arg = nullptr; + } + + { + if (m_StartedFlag) { + DriverCommand& cmdmgr{*DriverCommand::GetInstance()}; + + auto* command{cmdmgr.AllocCommand()}; + command->id = DriverCommandId_PlayerStop; + command->player = GetBasicSoundPlayerHandle(); + command->flag = m_FadeOutFlag; + + cmdmgr.PushCommand(command); + + m_StartedFlag = false; + } + + m_PlayerAvailableFlag = false; + m_PlayerState = PlayerState_Stop; + + DriverCommand& cmdmgr{*DriverCommand::GetInstance()}; + + auto* command{cmdmgr.AllocCommand()}; + command->id = DriverCommandId_PlayerFinalize; + command->player = GetBasicSoundPlayerHandle(); + + cmdmgr.PushCommand(command); + } + +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) + m_pOutputReceiver = nullptr; +#endif + + if (m_SoundStopCallback != nullptr) { + m_SoundStopCallback(); + m_SoundStopCallback = nullptr; + } + m_FadeOutFlag = false; + m_State = State_Finalized; +} + void BasicSound::StartPrepared() { m_StartFlag = true; } From c6c325b3ed02c32122ce60dbff740e4ef8bc0ca0 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 20:46:59 -0300 Subject: [PATCH 640/785] atk: Match `BasicSound::IsPause` --- include/nn/atk/atk_BasicSound.h | 8 ++++---- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 12 ++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index 98d6829e..571b6ff7 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -563,10 +563,10 @@ class BasicSound { u32 m_Id; u32 m_InstanceId; os::Tick m_SetupTick{0}; - f32 m_InitVolume; - f32 m_Pitch; - f32 m_LpfFreq; - f32 m_BiquadFilterValue; + float m_InitVolume; + float m_Pitch; + float m_LpfFreq; + float m_BiquadFilterValue; u32 m_OutputLineFlag; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) OutputReceiver* m_pOutputReceiver; diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 21b73b36..5dc2e23f 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -302,6 +302,18 @@ void BasicSound::SetPlayerPriority(int priority) { OnUpdatePlayerPriority(); } +bool BasicSound::IsPause() const { + switch (m_PauseState - 1) { + case PauseState_Normal: + case PauseState_Pausing: + return true; + case PauseState_Paused: + case PauseState_Unpausing: + default: + return false; + } +} + void BasicSound::SetId(u32 id) { m_Id = id; } From bbddfab4177043b17fda7d6f13df1b7420279ce7 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 20:47:54 -0300 Subject: [PATCH 641/785] atk: Match `BasicSound::IsMute` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 5dc2e23f..25cce8a3 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -314,6 +314,18 @@ bool BasicSound::IsPause() const { } } +bool BasicSound::IsMute() const { + switch (m_MuteState - 1) { + case MuteState_Normal: + case MuteState_Muting: + return true; + case MuteState_Muted: + case MuteState_Unmuting: + default: + return false; + } +} + void BasicSound::SetId(u32 id) { m_Id = id; } From a3bd3a8930a6134626910de052ede98a91aa9165 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 20:51:02 -0300 Subject: [PATCH 642/785] atk: Match `BasicSound::SetPriority` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 25cce8a3..86c86cd5 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -326,6 +326,11 @@ bool BasicSound::IsMute() const { } } +void BasicSound::SetPriority(int priority, int ambientPriority) { + m_Priority = priority; + m_AmbientParam.SetPriority(ambientPriority); +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 243c2349e28bb78f7da07b98032cb923b952e119 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 20:56:54 -0300 Subject: [PATCH 643/785] atk: Match `BasicSound::SetInitialVolume` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 86c86cd5..e5821885 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -1,7 +1,5 @@ #include -#include - #include #include #include @@ -331,6 +329,18 @@ void BasicSound::SetPriority(int priority, int ambientPriority) { m_AmbientParam.SetPriority(ambientPriority); } +void BasicSound::GetPriority(int* priority, int* ambientPriority) const { + if (priority != nullptr) + *priority = m_Priority; + + if (ambientPriority != nullptr) + *ambientPriority = m_AmbientParam.GetPriority(); +} + +void BasicSound::SetInitialVolume(float volume) { + m_InitVolume = volume < 0.0f ? 0.0f : volume; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 917907f2c8873b1034e991c447ea66618611dabc Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:00:01 -0300 Subject: [PATCH 644/785] atk: Match `BasicSound::GetInitialVolume` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index e5821885..2a90f398 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -341,6 +341,10 @@ void BasicSound::SetInitialVolume(float volume) { m_InitVolume = volume < 0.0f ? 0.0f : volume; } +float BasicSound::GetInitialVolume() const { + return m_InitVolume; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 18599720ededfde6284027364f64376763688395 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:01:54 -0300 Subject: [PATCH 645/785] atk: Match `BasicSound::SetVolume` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 2a90f398..52295205 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -345,6 +345,10 @@ float BasicSound::GetInitialVolume() const { return m_InitVolume; } +void BasicSound::SetVolume(float volume, int frames) { + m_CommonParam.SetVolume(volume < 0.0f ? 0.0f : volume, frames); +} + void BasicSound::SetId(u32 id) { m_Id = id; } From f231b048e6a60aa7154ac863f3c7191347f4dba5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:02:24 -0300 Subject: [PATCH 646/785] atk: Match `BasicSound::GetVolume` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 52295205..2c997c30 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -349,6 +349,10 @@ void BasicSound::SetVolume(float volume, int frames) { m_CommonParam.SetVolume(volume < 0.0f ? 0.0f : volume, frames); } +float BasicSound::GetVolume() const { + return m_CommonParam.GetVolume(); +} + void BasicSound::SetId(u32 id) { m_Id = id; } From d59876a6bfd611139beab3b0bcc38ca9b353cd88 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:03:58 -0300 Subject: [PATCH 647/785] atk: Match `BasicSound::SetPitch` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 2c997c30..eae721d3 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -353,6 +353,10 @@ float BasicSound::GetVolume() const { return m_CommonParam.GetVolume(); } +void BasicSound::SetPitch(float pitch) { + m_Pitch = pitch; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 6bcec2e4a89771caefac6846dff3cca1a67fe7ed Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:04:35 -0300 Subject: [PATCH 648/785] atk: Match `BasicSound::GetPitch` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index eae721d3..98e85d6d 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -357,6 +357,10 @@ void BasicSound::SetPitch(float pitch) { m_Pitch = pitch; } +float BasicSound::GetPitch() const { + return m_Pitch; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From a98e2ef7e04d9b5eb10a566cb7187e32f0bbf592 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:05:21 -0300 Subject: [PATCH 649/785] atk: Match `BasicSound::SetLpfFreq` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 98e85d6d..989c0d24 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -361,6 +361,10 @@ float BasicSound::GetPitch() const { return m_Pitch; } +void BasicSound::SetLpfFreq(float lpfFreq) { + m_LpfFreq = lpfFreq; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 0de270e0c3dc74807a2d6b7c7163820371dd4ec3 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:05:51 -0300 Subject: [PATCH 650/785] atk: Match `BasicSound::GetLpfFreq` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 989c0d24..4dc9b146 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -365,6 +365,10 @@ void BasicSound::SetLpfFreq(float lpfFreq) { m_LpfFreq = lpfFreq; } +float BasicSound::GetLpfFreq() const { + return m_LpfFreq; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From b69975bda84bd848e44fbccdf6743a9619ac4c6b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:07:14 -0300 Subject: [PATCH 651/785] atk: Match `BasicSound::SetBiquadFilter` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 4dc9b146..159bd5c3 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -369,6 +369,11 @@ float BasicSound::GetLpfFreq() const { return m_LpfFreq; } +void BasicSound::SetBiquadFilter(int type, float value) { + m_BiquadFilterType = static_cast(type); + m_BiquadFilterValue = value; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 64adf4cb8ed84c31f03d19f9b155c2ff0ddfb56f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:08:47 -0300 Subject: [PATCH 652/785] atk: Match `BasicSound::GetBiquadFilter` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 159bd5c3..b7ae248f 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -374,6 +374,14 @@ void BasicSound::SetBiquadFilter(int type, float value) { m_BiquadFilterValue = value; } +void BasicSound::GetBiquadFilter(int* type, float* value) const { + if (type != nullptr) + *type = static_cast(m_BiquadFilterType); + + if (value != nullptr) + *value = m_BiquadFilterValue; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 6f0def6fd7503495ce65e3b9843f1d2f940073a8 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:10:39 -0300 Subject: [PATCH 653/785] atk: Match `BasicSound::SetOutputLine` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index b7ae248f..a71b0265 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -382,6 +382,10 @@ void BasicSound::GetBiquadFilter(int* type, float* value) const { *value = m_BiquadFilterValue; } +void BasicSound::SetOutputLine(u32 lineFlag) { + m_OutputLineFlag = lineFlag; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From e276eceb5a71ecff9ce69221cc586f47cb1fa891 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:11:21 -0300 Subject: [PATCH 654/785] atk: Match `BasicSound::GetOutputLine` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index a71b0265..445ba7ec 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -386,6 +386,10 @@ void BasicSound::SetOutputLine(u32 lineFlag) { m_OutputLineFlag = lineFlag; } +u32 BasicSound::GetOutputLine() const { + return m_OutputLineFlag; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 3bd819c365f36d7903145fb5fff3e07d473341b5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:13:07 -0300 Subject: [PATCH 655/785] atk: Match `BasicSound::ResetOutputLine` --- include/nn/atk/atk_SoundPlayer.h | 2 ++ src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/include/nn/atk/atk_SoundPlayer.h b/include/nn/atk/atk_SoundPlayer.h index 3bcf9c49..febaf59e 100644 --- a/include/nn/atk/atk_SoundPlayer.h +++ b/include/nn/atk/atk_SoundPlayer.h @@ -46,6 +46,8 @@ class SoundPlayer { void SetVolume(f32 volume); void SetLowPassFilterFrequency(f32 lpfFreq); void SetBiquadFilter(s32 biquadFilterType, f32 biquadFilterValue); + + u32 GetDefaultOutputLine() const { return m_OutputLineFlag; } void SetDefaultOutputLine(u32 line); void SetMainSend(f32 send); diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 445ba7ec..41d381ce 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -390,6 +390,10 @@ u32 BasicSound::GetOutputLine() const { return m_OutputLineFlag; } +void BasicSound::ResetOutputLine() { + m_OutputLineFlag = m_pSoundPlayer->GetDefaultOutputLine(); +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 5ff25ca7bdda238285b69dea88e3535f46234a10 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:15:02 -0300 Subject: [PATCH 656/785] atk: Match `BasicSound::SetMixMode` --- include/nn/atk/atk_BasicSound.h | 1 + .../atk/detail/atk_BasicSound.cpp | 22 +++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index 571b6ff7..b973e222 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -361,6 +361,7 @@ class BasicSound { void ResetOutputLine(); void SetPlayerPriority(int priority); + void SetMixMode(MixMode mixMode); MixMode GetMixMode(); diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 41d381ce..773f3ef7 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -291,15 +291,6 @@ void BasicSound::FadeIn(int frames) { m_FadeVolume.SetTarget(1.0f, frames); } -void BasicSound::SetPlayerPriority(int priority) { - m_Priority = priority; - - if (m_pSoundPlayer != nullptr) - m_pSoundPlayer->detail_SortPriorityList(this); - - OnUpdatePlayerPriority(); -} - bool BasicSound::IsPause() const { switch (m_PauseState - 1) { case PauseState_Normal: @@ -394,6 +385,19 @@ void BasicSound::ResetOutputLine() { m_OutputLineFlag = m_pSoundPlayer->GetDefaultOutputLine(); } +void BasicSound::SetPlayerPriority(int priority) { + m_Priority = priority; + + if (m_pSoundPlayer != nullptr) + m_pSoundPlayer->detail_SortPriorityList(this); + + OnUpdatePlayerPriority(); +} + +void BasicSound::SetMixMode(MixMode mixMode) { + m_CommonParam.mixMode = mixMode; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From b6a36de2df6e3111df229f69978069311e41ba1e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:16:13 -0300 Subject: [PATCH 657/785] atk: Match `BasicSound::GetMixMode` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 773f3ef7..9f991cff 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -398,6 +398,10 @@ void BasicSound::SetMixMode(MixMode mixMode) { m_CommonParam.mixMode = mixMode; } +MixMode BasicSound::GetMixMode() { + return m_CommonParam.mixMode; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 9bfb1a2bae9ba35b05b005f6a19f9e92fe5b1972 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:17:08 -0300 Subject: [PATCH 658/785] atk: Match `BasicSound::SetPan` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 9f991cff..6a4cd7c1 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -402,6 +402,10 @@ MixMode BasicSound::GetMixMode() { return m_CommonParam.mixMode; } +void BasicSound::SetPan(float pan) { + m_CommonParam.pan = pan; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 7254b4ad49ba12d6a3a464cd0ecc007b7071e215 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:17:43 -0300 Subject: [PATCH 659/785] atk: Match `BasicSound::GetPan` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 6a4cd7c1..c71899a7 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -406,6 +406,10 @@ void BasicSound::SetPan(float pan) { m_CommonParam.pan = pan; } +float BasicSound::GetPan() const { + return m_CommonParam.pan; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 27008f695b1d1b7198273f8308ae1e530f730bbf Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:18:24 -0300 Subject: [PATCH 660/785] atk: Match `BasicSound::SetSurroundPan` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index c71899a7..1277b670 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -410,6 +410,10 @@ float BasicSound::GetPan() const { return m_CommonParam.pan; } +void BasicSound::SetSurroundPan(float span) { + m_CommonParam.span = span; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 01672254c3155022996474791de4014fc9b635c1 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:18:55 -0300 Subject: [PATCH 661/785] atk: Match `BasicSound::GetSurroundPan` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 1277b670..d2b1554c 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -414,6 +414,10 @@ void BasicSound::SetSurroundPan(float span) { m_CommonParam.span = span; } +float BasicSound::GetSurroundPan() const { + return m_CommonParam.span; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From f482fc4a6ba9183bbaf210ca46d4cb29f88bce1d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:20:04 -0300 Subject: [PATCH 662/785] atk: Match `BasicSound::SetMainSend` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index d2b1554c..bf8960c1 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -418,6 +418,10 @@ float BasicSound::GetSurroundPan() const { return m_CommonParam.span; } +void BasicSound::SetMainSend(float send) { + m_CommonParam.send[0] = send; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 45008d52114054a258d8aa64d68f8e8419671a9e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:20:49 -0300 Subject: [PATCH 663/785] atk: Match `BasicSound::GetMainSend` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index bf8960c1..718d4c9e 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -422,6 +422,10 @@ void BasicSound::SetMainSend(float send) { m_CommonParam.send[0] = send; } +float BasicSound::GetMainSend() const { + return m_CommonParam.send[0]; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From ecd73a6f199bd90bd61f0a470c6d166f9b4671c5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:21:59 -0300 Subject: [PATCH 664/785] atk: Match `BasicSound::SetFxSend` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 718d4c9e..0c6d02f3 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -426,6 +426,10 @@ float BasicSound::GetMainSend() const { return m_CommonParam.send[0]; } +void BasicSound::SetFxSend(AuxBus bus, float send) { + m_CommonParam.send[bus + 1L] = send; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 2df982e8df59ef3d806a1d007e46821f2d7c4388 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:26:41 -0300 Subject: [PATCH 665/785] atk: Match `BasicSound::GetFxSend` --- include/nn/atk/atk_LoaderManager.h | 1 + src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/nn/atk/atk_LoaderManager.h b/include/nn/atk/atk_LoaderManager.h index 319eaf15..c5921194 100644 --- a/include/nn/atk/atk_LoaderManager.h +++ b/include/nn/atk/atk_LoaderManager.h @@ -64,6 +64,7 @@ class LoaderManager : public driver::SoundThread::SoundFrameCallback { void Free(Instance* instance) { // TODO + m_FreeList.push_back(*instance); } void UpdateFreeReqList() { diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 0c6d02f3..fb02fd98 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -430,6 +430,10 @@ void BasicSound::SetFxSend(AuxBus bus, float send) { m_CommonParam.send[bus + 1L] = send; } +float BasicSound::GetFxSend(AuxBus bus) const { + return m_CommonParam.send[bus + 1L]; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From d1010675af1022e98ddf08d529dae13324838152 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:36:35 -0300 Subject: [PATCH 666/785] atk: Match `BasicSound::SetPanMode` --- include/nn/atk/atk_BasicSound.h | 5 ++++- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index b973e222..7b02a965 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -361,7 +361,7 @@ class BasicSound { void ResetOutputLine(); void SetPlayerPriority(int priority); - + void SetMixMode(MixMode mixMode); MixMode GetMixMode(); @@ -377,6 +377,7 @@ class BasicSound { void SetFxSend(AuxBus bus, float send); float GetFxSend(AuxBus bus) const; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) void SetSend(int bus, float send); float GetSend(int bus) const; @@ -386,9 +387,11 @@ class BasicSound { int GetSendBusCount(); int GetSendChannelCount(); +#endif void SetPanMode(PanMode mode); void SetPanCurve(PanCurve curve); + #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) void SetOutputAdditionalParamAddr(OutputDevice device, OutputAdditionalParam* addr, OutputAdditionalParam* addrForPlayer); diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index fb02fd98..2c67e5c1 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -434,6 +434,19 @@ float BasicSound::GetFxSend(AuxBus bus) const { return m_CommonParam.send[bus + 1L]; } +void BasicSound::SetPanMode(PanMode mode) { + { + DriverCommand& cmdmgr{*DriverCommand::GetInstance()}; + auto* command{cmdmgr.AllocCommand()}; + + command->id = DriverCommandId_PlayerPanmode; + command->player = GetBasicSoundPlayerHandle(); + command->panMode = mode; + + cmdmgr.PushCommand(command); + } +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 6f9fa97caedb87c6580ee388dc4c55bf7f9329cc Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:37:51 -0300 Subject: [PATCH 667/785] atk: Match `BasicSound::SetPanCurve` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 2c67e5c1..51a3ee1e 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -447,6 +447,19 @@ void BasicSound::SetPanMode(PanMode mode) { } } +void BasicSound::SetPanCurve(PanCurve curve) { + { + DriverCommand& cmdmgr{*DriverCommand::GetInstance()}; + auto* command{cmdmgr.AllocCommand()}; + + command->id = DriverCommandId_PlayerPancurve; + command->player = GetBasicSoundPlayerHandle(); + command->panCurve = curve; + + cmdmgr.PushCommand(command); + } +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 0a49819bcab021f1be3897626d4885d30078de94 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:41:18 -0300 Subject: [PATCH 668/785] atk: Match `BasicSound::SetOutputVolume` --- include/nn/atk/atk_BasicSound.h | 4 ++-- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index 7b02a965..541828d0 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -604,9 +604,9 @@ class BasicSound { CommonParam m_CommonParam; - OutputParam m_OutputParam[1]; + OutputParam m_OutputParam[OutputDevice_Count]; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) - OutputAdditionalParam* m_pOutputAdditionalParam[1]{}; + OutputAdditionalParam* m_pOutputAdditionalParam[OutputDevice_Count]{}; #endif void* m_pUserParam{}; size_t m_UserParamSize{0}; diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 51a3ee1e..7b5da612 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -69,7 +69,7 @@ bool BasicSound::Initialize(OutputReceiver* pOutputReceiver) m_CommonParam.Initialize(); - for (int i{0}; i < 1; ++i) { + for (int i{0}; i < OutputDevice_Count; ++i) { m_OutputParam[i].Initialize(); #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) if (m_pOutputAdditionalParam[i] != nullptr) @@ -460,6 +460,10 @@ void BasicSound::SetPanCurve(PanCurve curve) { } } +void BasicSound::SetOutputVolume(OutputDevice device, float volume) { + m_OutputParam[device].volume = volume; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From ddfbb4a35e011f4cce1aecd83445a466e8692680 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:51:31 -0300 Subject: [PATCH 669/785] atk: Match `BasicSound::SetOutputAdditionalParamAddr` --- include/nn/atk/atk_BasicSound.h | 2 +- include/nn/atk/atk_BasicSoundPlayer.h | 8 +++++--- include/nn/atk/atk_OutputAdditionalParam.h | 8 +++++--- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 8 ++++++++ 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index 541828d0..0f2818ff 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -394,7 +394,7 @@ class BasicSound { #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) void SetOutputAdditionalParamAddr(OutputDevice device, OutputAdditionalParam* addr, - OutputAdditionalParam* addrForPlayer); + OutputAdditionalParam* addrForPlayer = nullptr); #endif void SetOutputVolume(OutputDevice device, float volume); void SetOutputPan(OutputDevice device, float pan); diff --git a/include/nn/atk/atk_BasicSoundPlayer.h b/include/nn/atk/atk_BasicSoundPlayer.h index 55c3eccb..e161eb78 100644 --- a/include/nn/atk/atk_BasicSoundPlayer.h +++ b/include/nn/atk/atk_BasicSoundPlayer.h @@ -2,13 +2,12 @@ #include -#include #include #include namespace nn::atk::detail::driver { + struct PlayerParamSet { - void Initialize(); f32 volume; @@ -37,7 +36,9 @@ class BasicSoundPlayer { virtual void Pause(bool isPauseEnabled) = 0; BasicSoundPlayer(); + void SetBiquadFilter(s32 type, f32 value); + void SetTvAdditionalParamAddr(OutputAdditionalParam* pParam) { m_pTvAdditionalParam = pParam; } void InitializeEvent() { m_Event.Clear(); } @@ -62,4 +63,5 @@ static_assert(sizeof(BasicSoundPlayer) == 0xb0); #else static_assert(sizeof(BasicSoundPlayer) == 0xc0); #endif -} //namespace nn::atk::detail::driver \ No newline at end of file + +} // namespace nn::atk::detail::driver diff --git a/include/nn/atk/atk_OutputAdditionalParam.h b/include/nn/atk/atk_OutputAdditionalParam.h index e135a3e1..b00a96d2 100644 --- a/include/nn/atk/atk_OutputAdditionalParam.h +++ b/include/nn/atk/atk_OutputAdditionalParam.h @@ -2,11 +2,12 @@ #include -#include #include +#include #include namespace nn::atk::detail { + using SendArray = ValueArray; class OutputAdditionalParam { @@ -55,7 +56,7 @@ class OutputAdditionalParam { u8 TryGetVolumeThroughMode(s32 bus) const; void TrySetVolumeThroughMode(s32 bus, u8 volumeThroughMode); bool IsVolumeThroughModeEnabled() const; - + bool IsVolumeThroughModeUsed(); void SetVolumeThroughModeUsed(bool isUsed); @@ -67,4 +68,5 @@ class OutputAdditionalParam { VolumeThroughModePacket* VolumeThroughModePacket; }; static_assert(sizeof(OutputAdditionalParam) == 0x18); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 7b5da612..996f3340 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -460,6 +460,14 @@ void BasicSound::SetPanCurve(PanCurve curve) { } } +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) +void BasicSound::SetOutputAdditionalParamAddr(OutputDevice device, OutputAdditionalParam* addr, + OutputAdditionalParam* addrForPlayer) { + m_pOutputAdditionalParam[device] = addr; + GetBasicSoundPlayerHandle()->SetTvAdditionalParamAddr(addrForPlayer); +} +#endif + void BasicSound::SetOutputVolume(OutputDevice device, float volume) { m_OutputParam[device].volume = volume; } From 98fd1704594f00c810e9daa09b35991451993043 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:52:10 -0300 Subject: [PATCH 670/785] atk: Match `BasicSound::SetOutputPan` --- include/nn/atk/atk_BasicSoundPlayer.h | 3 +++ src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/include/nn/atk/atk_BasicSoundPlayer.h b/include/nn/atk/atk_BasicSoundPlayer.h index e161eb78..e357b731 100644 --- a/include/nn/atk/atk_BasicSoundPlayer.h +++ b/include/nn/atk/atk_BasicSoundPlayer.h @@ -38,7 +38,10 @@ class BasicSoundPlayer { BasicSoundPlayer(); void SetBiquadFilter(s32 type, f32 value); + +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) void SetTvAdditionalParamAddr(OutputAdditionalParam* pParam) { m_pTvAdditionalParam = pParam; } +#endif void InitializeEvent() { m_Event.Clear(); } diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 996f3340..77241cfc 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -472,6 +472,10 @@ void BasicSound::SetOutputVolume(OutputDevice device, float volume) { m_OutputParam[device].volume = volume; } +void BasicSound::SetOutputPan(OutputDevice device, float pan) { + m_OutputParam[device].pan = pan; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From fd4960a83c330020242703b5aa278f8a1eb6e3b5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:55:33 -0300 Subject: [PATCH 671/785] atk: Match `BasicSound::SetOutputSurroundPan` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 77241cfc..6e286cfb 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -476,6 +476,10 @@ void BasicSound::SetOutputPan(OutputDevice device, float pan) { m_OutputParam[device].pan = pan; } +void BasicSound::SetOutputSurroundPan(OutputDevice device, float span) { + m_OutputParam[device].span = span; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From de248b1350eef2b5a89ad4a62d37327acc90387d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:57:07 -0300 Subject: [PATCH 672/785] atk: Match `BasicSound::SetOutputMainSend` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 6e286cfb..f713c6be 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -480,6 +480,10 @@ void BasicSound::SetOutputSurroundPan(OutputDevice device, float span) { m_OutputParam[device].span = span; } +void BasicSound::SetOutputMainSend(OutputDevice device, float send) { + m_OutputParam[device].send[OutputDevice_Main] = send; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From baf2f5412ae4a60e52d0c3e417f0cd3f6d677183 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 22:05:23 -0300 Subject: [PATCH 673/785] atk: Match `BasicSound::SetOutputFxSend` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index f713c6be..565f12d1 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -427,11 +427,11 @@ float BasicSound::GetMainSend() const { } void BasicSound::SetFxSend(AuxBus bus, float send) { - m_CommonParam.send[bus + 1L] = send; + m_CommonParam.send[1L + bus] = send; } float BasicSound::GetFxSend(AuxBus bus) const { - return m_CommonParam.send[bus + 1L]; + return m_CommonParam.send[1L + bus]; } void BasicSound::SetPanMode(PanMode mode) { @@ -484,6 +484,10 @@ void BasicSound::SetOutputMainSend(OutputDevice device, float send) { m_OutputParam[device].send[OutputDevice_Main] = send; } +void BasicSound::SetOutputFxSend(OutputDevice device, AuxBus bus, float send) { + m_OutputParam[device].send[1L + bus] = send; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From e8c64bf1ee9f4be7f7481c0b6feff4932cc90ee5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 22:13:58 -0300 Subject: [PATCH 674/785] atk: Match `BasicSound::SetOutputChannelMixParameter` --- include/nn/atk/atk_BasicSound.h | 8 +++++++- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index 0f2818ff..f162a38c 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -401,13 +401,19 @@ class BasicSound { void SetOutputSurroundPan(OutputDevice device, float span); void SetOutputMainSend(OutputDevice device, float send); void SetOutputFxSend(OutputDevice device, AuxBus bus, float send); - void SetOutputFxSend(OutputDevice device, float send); + +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) void SetOutputAdditionalSend(OutputDevice device, int bus, float send); void SetOutputBusMixVolumeEnabled(OutputDevice device, int subMixBus, bool isEnabled); void SetOutputBusMixVolume(OutputDevice device, int srcChNo, int subMixBus, ChannelMixVolume param); +#endif + void SetOutputChannelMixParameter(OutputDevice device, u32 srcChNo, MixParameter param); + +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) void SetOutputVolumeThroughMode(OutputDevice device, int bus, u8 modeBitFlag); +#endif float GetOutputVolume(OutputDevice device) const; float GetOutputPan(OutputDevice device) const; diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 565f12d1..5dcb7010 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -488,6 +488,12 @@ void BasicSound::SetOutputFxSend(OutputDevice device, AuxBus bus, float send) { m_OutputParam[device].send[1L + bus] = send; } +void BasicSound::SetOutputChannelMixParameter(OutputDevice device, u32 srcChNo, + MixParameter param) { + for (int i{0}; i < ChannelIndex_Count; ++i) + m_OutputParam[device].mixParameter[srcChNo].ch[i] = param.ch[i]; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From c7e0f2a0486d208efef6dfaa2e81f1b868d6da7a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 22:15:12 -0300 Subject: [PATCH 675/785] atk: Match `BasicSound::GetOutputVolume` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 5dcb7010..06a9763a 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -494,6 +494,10 @@ void BasicSound::SetOutputChannelMixParameter(OutputDevice device, u32 srcChNo, m_OutputParam[device].mixParameter[srcChNo].ch[i] = param.ch[i]; } +float BasicSound::GetOutputVolume(OutputDevice device) const { + return m_OutputParam[device].volume; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 61972109d1c26916f45272c2547bd56ff7d9d810 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 22:16:02 -0300 Subject: [PATCH 676/785] atk: Match `BasicSound::GetOutputPan` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 06a9763a..6d7e907e 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -498,6 +498,10 @@ float BasicSound::GetOutputVolume(OutputDevice device) const { return m_OutputParam[device].volume; } +float BasicSound::GetOutputPan(OutputDevice device) const { + return m_OutputParam[device].pan; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 0cdfbda7f83fe678ef7ca0ab34353f4aa4982952 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 22:16:39 -0300 Subject: [PATCH 677/785] atk: Match `BasicSound::GetOutputSurroundPan` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 6d7e907e..2baa3a3a 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -502,6 +502,10 @@ float BasicSound::GetOutputPan(OutputDevice device) const { return m_OutputParam[device].pan; } +float BasicSound::GetOutputSurroundPan(OutputDevice device) const { + return m_OutputParam[device].span; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From b920617d18b6e2b9a98e9854df80d410bb87908c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 22:23:48 -0300 Subject: [PATCH 678/785] atk: Match `BasicSound::GetOutputMainSend` --- include/nn/atk/atk_Global.h | 2 +- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h index e2e58f83..14bbcf5e 100644 --- a/include/nn/atk/atk_Global.h +++ b/include/nn/atk/atk_Global.h @@ -512,4 +512,4 @@ static const int StreamBlockCountMin{2}; } // namespace detail -} // namespace nn::atk \ No newline at end of file +} // namespace nn::atk diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 2baa3a3a..ed8adf67 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -481,7 +481,7 @@ void BasicSound::SetOutputSurroundPan(OutputDevice device, float span) { } void BasicSound::SetOutputMainSend(OutputDevice device, float send) { - m_OutputParam[device].send[OutputDevice_Main] = send; + m_OutputParam[device].send[OutputDeviceIndex_Main] = send; } void BasicSound::SetOutputFxSend(OutputDevice device, AuxBus bus, float send) { @@ -506,6 +506,10 @@ float BasicSound::GetOutputSurroundPan(OutputDevice device) const { return m_OutputParam[device].span; } +float BasicSound::GetOutputMainSend(OutputDevice device) const { + return m_OutputParam[device].send[OutputDeviceIndex_Main]; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From bd0869f4f473e53e53bf7932727bb9e1bce14491 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 22:26:02 -0300 Subject: [PATCH 679/785] atk: Match `BasicSound::GetOutputFxSend` --- include/nn/atk/atk_BasicSound.h | 1 - src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index f162a38c..8623a6f3 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -420,7 +420,6 @@ class BasicSound { float GetOutputSurroundPan(OutputDevice device) const; float GetOutputMainSend(OutputDevice device) const; float GetOutputFxSend(OutputDevice device, AuxBus bus) const; - float GetOutputFxSend(OutputDevice device) const; bool IsOutputBusMixVolumeEnabled(OutputDevice device, int subMixBus) const; ChannelMixVolume GetOutputBusMixVolume(OutputDevice device, int srcChNo, int subMixBus) const; float GetOutputAdditionalSend(OutputDevice device, int bus) const; diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index ed8adf67..7951e584 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -510,6 +510,10 @@ float BasicSound::GetOutputMainSend(OutputDevice device) const { return m_OutputParam[device].send[OutputDeviceIndex_Main]; } +float BasicSound::GetOutputFxSend(OutputDevice device, AuxBus bus) const { + return m_OutputParam[device].send[1L + bus]; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 91f8ad2caceb5f55ba1453a7af5f11d0f70c7116 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 22:28:48 -0300 Subject: [PATCH 680/785] atk: Match `BasicSound::GetOutputChannelMixParameter` --- include/nn/atk/atk_BasicSound.h | 7 ++++++- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index 8623a6f3..7f32885c 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -420,11 +420,16 @@ class BasicSound { float GetOutputSurroundPan(OutputDevice device) const; float GetOutputMainSend(OutputDevice device) const; float GetOutputFxSend(OutputDevice device, AuxBus bus) const; + +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) bool IsOutputBusMixVolumeEnabled(OutputDevice device, int subMixBus) const; ChannelMixVolume GetOutputBusMixVolume(OutputDevice device, int srcChNo, int subMixBus) const; float GetOutputAdditionalSend(OutputDevice device, int bus) const; u8 GetOutputVolumeThroughMode(OutputDevice device, int bus) const; - MixParameter GetOutputChannelMixParameter(OutputDevice, u32 srcChNo) const; +#endif + + MixParameter GetOutputChannelMixParameter(OutputDevice device, u32 srcChNo) const; + int GetRemainingFadeFrames() const; int GetRemainingPauseFadeFrames() const; int GetRemainingMuteFadeFrames() const; diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 7951e584..b0750a00 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -514,6 +514,10 @@ float BasicSound::GetOutputFxSend(OutputDevice device, AuxBus bus) const { return m_OutputParam[device].send[1L + bus]; } +MixParameter BasicSound::GetOutputChannelMixParameter(OutputDevice device, u32 srcChNo) const { + return m_OutputParam[device].mixParameter[srcChNo]; +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 527d14a447782a0496c5777dbb0314900e8eb2a9 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 22:30:09 -0300 Subject: [PATCH 681/785] atk: Match `BasicSound::GetRemainingFadeFrames` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index b0750a00..b50ee9c0 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -518,6 +518,10 @@ MixParameter BasicSound::GetOutputChannelMixParameter(OutputDevice device, u32 s return m_OutputParam[device].mixParameter[srcChNo]; } +int BasicSound::GetRemainingFadeFrames() const { + return m_FadeVolume.GetRemainingCount(); +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 641b96222d8e28ae0d4b0ed514877cb7e915624a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 22:30:34 -0300 Subject: [PATCH 682/785] atk: Match `BasicSound::GetRemainingPauseFadeFrames` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index b50ee9c0..6aa1cf7c 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -522,6 +522,10 @@ int BasicSound::GetRemainingFadeFrames() const { return m_FadeVolume.GetRemainingCount(); } +int BasicSound::GetRemainingPauseFadeFrames() const { + return m_PauseFadeVolume.GetRemainingCount(); +} + void BasicSound::SetId(u32 id) { m_Id = id; } From f97b9aa881127952b5f83f4a13f0a33851fe010a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sat, 12 Sep 2026 22:31:47 -0300 Subject: [PATCH 683/785] atk: Match `BasicSound::GetRemainingMuteFadeFrames` --- include/nn/atk/atk_BasicSound.h | 2 ++ src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index 7f32885c..260fcd05 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -336,6 +336,7 @@ class BasicSound { virtual bool IsPrepared() const = 0; bool IsPause() const; bool IsMute() const; + bool IsStarted() const { return m_StartedFlag; } void SetPriority(int priority, int ambientPriority); @@ -433,6 +434,7 @@ class BasicSound { int GetRemainingFadeFrames() const; int GetRemainingPauseFadeFrames() const; int GetRemainingMuteFadeFrames() const; + int GetPlayerPriority() const { return m_Priority; } void CalculateSoundParamCalculationValues(SoundParamCalculationValues* pOutValue) const; diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 6aa1cf7c..c9e892fa 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -526,6 +526,10 @@ int BasicSound::GetRemainingPauseFadeFrames() const { return m_PauseFadeVolume.GetRemainingCount(); } +int BasicSound::GetRemainingMuteFadeFrames() const { + return m_MuteFadeVolume.GetRemainingCount(); +} + void BasicSound::SetId(u32 id) { m_Id = id; } From 7c37d4fdbab0cacc2f190163ea0c92a8c34a4632 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 10:52:32 -0300 Subject: [PATCH 684/785] atk: Run clang-format on all files --- include/nn/atk/atk_Adpcm.h | 10 +- .../atk/atk_AudioRendererPerformanceReader.h | 19 +- include/nn/atk/atk_Bank.h | 11 +- include/nn/atk/atk_BankFile.h | 18 +- include/nn/atk/atk_BankFileReader.h | 2 +- include/nn/atk/atk_BasicSound.h | 38 +- include/nn/atk/atk_BinaryFileFormat.h | 5 +- include/nn/atk/atk_BiquadFilterCallback.h | 4 +- include/nn/atk/atk_BiquadFilterPresets.h | 29 +- include/nn/atk/atk_BusMixVolumePacket.h | 34 +- include/nn/atk/atk_Channel.h | 2 +- include/nn/atk/atk_ChannelManager.h | 9 +- include/nn/atk/atk_ChannelMixVolume.h | 6 +- include/nn/atk/atk_Config.h | 3 +- include/nn/atk/atk_CurveAdshr.h | 2 +- include/nn/atk/atk_CurveLfo.h | 2 +- include/nn/atk/atk_Debug.h | 9 +- include/nn/atk/atk_DeviceOutRecorder.h | 44 ++- include/nn/atk/atk_DisposeCallback.h | 5 +- include/nn/atk/atk_DisposeCallbackManager.h | 10 +- include/nn/atk/atk_DriverCommand.h | 13 +- include/nn/atk/atk_DspadpcmReader.h | 10 +- include/nn/atk/atk_EffectAux.h | 24 +- include/nn/atk/atk_EffectBase.h | 5 +- include/nn/atk/atk_ElementType.h | 9 +- include/nn/atk/atk_ExternalSoundPlayer.h | 8 +- include/nn/atk/atk_FinalMix.h | 8 +- include/nn/atk/atk_FrameHeap.h | 15 +- include/nn/atk/atk_FsSoundArchive.h | 25 +- include/nn/atk/atk_GroupFile.h | 2 +- include/nn/atk/atk_GroupFileReader.h | 2 +- include/nn/atk/atk_HardwareManager.h | 45 ++- include/nn/atk/atk_InstancePool.h | 3 +- include/nn/atk/atk_ItemType.h | 4 +- include/nn/atk/atk_LowLevelVoice.h | 2 +- include/nn/atk/atk_MmlCommand.h | 8 +- include/nn/atk/atk_MmlParser.h | 11 +- include/nn/atk/atk_MmlSequenceTrack.h | 4 +- .../nn/atk/atk_MmlSequenceTrackAllocator.h | 8 +- include/nn/atk/atk_MoveValue.h | 2 +- include/nn/atk/atk_MultiVoice.h | 50 +-- include/nn/atk/atk_MultiVoiceManager.h | 14 +- include/nn/atk/atk_NoteOnCallback.h | 6 +- include/nn/atk/atk_OutputMixer.h | 19 +- include/nn/atk/atk_OutputReceiver.h | 4 +- include/nn/atk/atk_PlayerHeap.h | 14 +- include/nn/atk/atk_PlayerHeapDataManager.h | 6 +- include/nn/atk/atk_ProfileReader.h | 19 +- include/nn/atk/atk_SequenceSound.h | 15 +- include/nn/atk/atk_SequenceSoundFile.h | 10 +- include/nn/atk/atk_SequenceSoundFileReader.h | 2 +- include/nn/atk/atk_SequenceSoundHandle.h | 7 +- include/nn/atk/atk_SequenceSoundPlayer.h | 33 +- include/nn/atk/atk_SequenceSoundRuntime.h | 78 ++-- include/nn/atk/atk_SequenceTrack.h | 2 +- include/nn/atk/atk_SequenceTrackAllocator.h | 4 +- include/nn/atk/atk_SoundActor.h | 3 +- include/nn/atk/atk_SoundArchive.h | 5 +- include/nn/atk/atk_SoundArchiveFile.h | 79 ++-- include/nn/atk/atk_SoundArchiveFileReader.h | 24 +- include/nn/atk/atk_SoundArchiveFilesHook.h | 13 +- include/nn/atk/atk_SoundArchiveLoader.h | 67 ++-- .../nn/atk/atk_SoundArchiveParametersHook.h | 61 ++- include/nn/atk/atk_SoundArchivePlayer.h | 73 ++-- include/nn/atk/atk_SoundDataManager.h | 9 +- include/nn/atk/atk_SoundHandle.h | 4 +- include/nn/atk/atk_SoundHeap.h | 15 +- include/nn/atk/atk_SoundInstanceManager.h | 8 +- include/nn/atk/atk_SoundMemoryAllocatable.h | 6 +- include/nn/atk/atk_SoundPlayer.h | 125 +++--- include/nn/atk/atk_SoundRuntimeUtility.h | 4 +- include/nn/atk/atk_SoundStartable.h | 64 +-- include/nn/atk/atk_SoundSystem.h | 116 +++--- include/nn/atk/atk_SoundThread.h | 49 +-- include/nn/atk/atk_StartInfoReader.h | 4 +- include/nn/atk/atk_StreamBufferPool.h | 8 +- include/nn/atk/atk_StreamSound.h | 16 +- include/nn/atk/atk_StreamSoundFile.h | 20 +- include/nn/atk/atk_StreamSoundFileLoader.h | 22 +- include/nn/atk/atk_StreamSoundFileReader.h | 2 +- include/nn/atk/atk_StreamSoundHandle.h | 7 +- include/nn/atk/atk_StreamSoundLoader.h | 57 +-- include/nn/atk/atk_StreamSoundPlayer.h | 59 +-- include/nn/atk/atk_StreamSoundPrefetchFile.h | 10 +- .../atk/atk_StreamSoundPrefetchFileReader.h | 28 +- include/nn/atk/atk_StreamSoundRuntime.h | 36 +- include/nn/atk/atk_StreamTrack.h | 6 +- include/nn/atk/atk_SubMix.h | 60 +-- include/nn/atk/atk_Task.h | 6 +- include/nn/atk/atk_TaskManager.h | 9 +- include/nn/atk/atk_TaskProfileReader.h | 27 +- include/nn/atk/atk_TaskThread.h | 10 +- include/nn/atk/atk_ThreadInfoReader.h | 24 +- include/nn/atk/atk_Util.h | 7 +- include/nn/atk/atk_ValueArray.h | 2 +- include/nn/atk/atk_Voice.h | 12 +- include/nn/atk/atk_VoiceCommand.h | 5 +- include/nn/atk/atk_VolumeThroughModePacket.h | 4 +- include/nn/atk/atk_WavBinary.h | 12 +- include/nn/atk/atk_WavOutFileStream.h | 2 +- include/nn/atk/atk_WaveArchiveFile.h | 6 +- include/nn/atk/atk_WaveArchiveFileReader.h | 2 +- include/nn/atk/atk_WaveFile.h | 4 +- include/nn/atk/atk_WaveFileReader.h | 16 +- include/nn/atk/atk_WaveSound.h | 14 +- include/nn/atk/atk_WaveSoundFile.h | 30 +- include/nn/atk/atk_WaveSoundFileReader.h | 11 +- include/nn/atk/atk_WaveSoundHandle.h | 7 +- include/nn/atk/atk_WaveSoundLoader.h | 8 +- include/nn/atk/atk_WaveSoundPlayer.h | 17 +- include/nn/atk/atk_WaveSoundRuntime.h | 22 +- .../detail/atk_AddonSoundArchiveContainer.h | 4 +- include/nn/atk/detail/atk_AdvancedWaveSound.h | 6 +- .../nn/atk/detail/atk_AdvancedWaveSoundFile.h | 9 +- .../detail/atk_AdvancedWaveSoundFileReader.h | 4 +- .../atk/detail/atk_AdvancedWaveSoundPlayer.h | 16 +- .../atk/detail/atk_AdvancedWaveSoundRuntime.h | 30 +- include/nn/atk/detail/atk_BinaryTypes.h | 3 +- .../nn/atk/detail/atk_IRegionInfoReadable.h | 9 +- .../nn/atk/detail/atk_IStreamDataDecoder.h | 16 +- include/nn/atk/detail/atk_IntrusiveList.h | 7 +- include/nn/atk/detail/atk_MemoryFileStream.h | 2 +- include/nn/atk/detail/atk_RegionManager.h | 19 +- .../nn/atk/detail/atk_SoundArchiveManager.h | 4 +- include/nn/atk/fnd/basis/atkfnd_Config.h | 4 +- .../nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h | 6 +- include/nn/atk/fnd/basis/atkfnd_HeapBase.h | 36 +- include/nn/atk/fnd/basis/atkfnd_Inlines.h | 2 +- include/nn/atk/fnd/basis/atkfnd_Result.h | 50 +-- .../nn/atk/fnd/basis/atkfnd_RuntimeTypeInfo.h | 4 +- include/nn/atk/fnd/basis/atkfnd_Time.h | 6 +- .../fnd/basis/atkfnd_WorkBufferAllocator.h | 4 +- .../nn/atk/fnd/binary/atkfnd_PrimitiveTypes.h | 4 +- include/nn/atk/fnd/io/atkfnd_FileStream.h | 18 +- include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h | 4 +- .../nn/atk/fnd/io/atkfnd_FileStreamProxy.h | 6 +- include/nn/atk/fnd/io/atkfnd_Stream.h | 11 +- include/nn/atk/fnd/io/atkfnd_StreamCache.h | 8 +- .../nn/atk/fnd/os/atkfnd_CriticalSection.h | 23 +- include/nn/atk/fnd/os/atkfnd_ScopedLock.h | 15 +- include/nn/atk/fnd/os/atkfnd_Thread.h | 27 +- include/nn/atk/fnd/string/atkfnd_String.h | 8 +- include/nn/audio/audio_Adpcm.h | 4 +- include/nn/audio/audio_AudioRendererTypes.h | 4 +- include/nn/audio/audio_Common.h | 4 +- include/nn/audio/audio_EffectTypes.h | 4 +- include/nn/audio/audio_FinalMixTypes.h | 4 +- include/nn/audio/audio_MemoryPoolTypes.h | 8 +- include/nn/audio/audio_PerformanceMetrics.h | 4 +- .../nn/audio/audio_PerformanceMetricsTypes.h | 4 +- include/nn/audio/audio_SampleFormat.h | 4 +- include/nn/audio/audio_SinkTypes.h | 4 +- include/nn/audio/audio_SubMixTypes.h | 4 +- include/nn/audio/audio_VoiceTypes.h | 4 +- include/nn/audio/audio_WaveBuffer.h | 4 +- src/NintendoWare/atk/atk_FsSoundArchive.cpp | 49 +-- .../atk/atk_SequenceSoundHandle.cpp | 1 + src/NintendoWare/atk/atk_SoundArchive.cpp | 103 ++--- .../atk/atk_SoundArchivePlayer.cpp | 1 + src/NintendoWare/atk/atk_SoundDataManager.cpp | 1 + src/NintendoWare/atk/atk_SoundHandle.cpp | 1 + src/NintendoWare/atk/atk_SoundHeap.cpp | 1 + src/NintendoWare/atk/atk_SoundPlayer.cpp | 1 + src/NintendoWare/atk/atk_SoundStartable.cpp | 1 + src/NintendoWare/atk/atk_SoundSystem.cpp | 1 + .../atk/atk_StreamSoundHandle.cpp | 1 + .../atk/detail/atk_AdvancedWaveSound.cpp | 1 + .../atk/detail/atk_AdvancedWaveSoundFile.cpp | 1 + .../atk_AdvancedWaveSoundFileReader.cpp | 1 + .../detail/atk_AdvancedWaveSoundPlayer.cpp | 1 + .../detail/atk_AdvancedWaveSoundRuntime.cpp | 1 + .../atk/detail/atk_BasicSound.cpp | 106 +++++ .../atk/detail/atk_BasicSoundPlayer.cpp | 1 + .../atk/detail/atk_BusMixVolumePacket.cpp | 6 +- .../atk/detail/atk_DisposeCallbackManager.cpp | 1 + .../atk/detail/atk_ExternalSoundPlayer.cpp | 1 + src/NintendoWare/atk/detail/atk_GroupFile.cpp | 13 +- .../atk/detail/atk_GroupFileReader.cpp | 2 +- .../atk/detail/atk_OutputAdditionalParam.cpp | 1 + .../atk/detail/atk_PlayerHeap.cpp | 1 + .../atk/detail/atk_PlayerHeapDataManager.cpp | 1 + .../atk/detail/atk_RegionManager.cpp | 1 + .../atk/detail/atk_SoundArchiveFile.cpp | 2 +- .../atk/detail/atk_SoundArchiveFileReader.cpp | 1 + .../atk/detail/atk_SoundArchiveLoader.cpp | 1 + .../atk/detail/atk_SoundArchiveManager.cpp | 1 + .../atk/detail/atk_StartInfoReader.cpp | 1 + .../detail/atk_VolumeThroughModePacket.cpp | 6 +- .../atk/detail/atk_WaveArchiveFile.cpp | 10 +- .../atk/detail/atk_WaveArchiveFileReader.cpp | 2 +- src/NintendoWare/atk/detail/atk_WaveFile.cpp | 15 +- .../atk/detail/atk_WaveFileReader.cpp | 2 +- .../atk/detail/debug/atk_Debug.cpp | 30 +- .../detail/dsp/atk_BiquadFilterPresets.cpp | 1 + .../atk/detail/dsp/atk_DecodeAdpcm.cpp | 23 +- .../atk/detail/dsp/atk_DspadpcmReader.cpp | 15 +- .../atk/detail/dsp/atk_HardwareManager.cpp | 1 + src/NintendoWare/atk/detail/seq/atk_Bank.cpp | 1 + .../atk/detail/seq/atk_BankFile.cpp | 111 +++--- .../atk/detail/seq/atk_BankFileReader.cpp | 2 +- .../atk/detail/seq/atk_MmlParser.cpp | 1 + .../atk/detail/seq/atk_MmlSequenceTrack.cpp | 1 + .../seq/atk_MmlSequenceTrackAllocator.cpp | 1 + .../atk/detail/seq/atk_SequenceSound.cpp | 1 + .../atk/detail/seq/atk_SequenceSoundFile.cpp | 27 +- .../seq/atk_SequenceSoundFileReader.cpp | 2 +- .../detail/seq/atk_SequenceSoundPlayer.cpp | 1 + .../detail/seq/atk_SequenceSoundRuntime.cpp | 1 + .../atk/detail/seq/atk_SequenceTrack.cpp | 2 +- .../atk/detail/strm/atk_StreamBufferPool.cpp | 31 +- .../atk/detail/strm/atk_StreamSound.cpp | 1 + .../atk/detail/strm/atk_StreamSoundFile.cpp | 29 +- .../detail/strm/atk_StreamSoundFileReader.cpp | 2 +- .../atk/detail/strm/atk_StreamSoundLoader.cpp | 1 + .../atk/detail/strm/atk_StreamSoundPlayer.cpp | 1 + .../strm/atk_StreamSoundPrefetchFile.cpp | 17 +- .../atk_StreamSoundPrefetchFileReader.cpp | 61 +-- .../detail/strm/atk_StreamSoundRuntime.cpp | 1 + .../atk/detail/strm/atk_StreamTrack.cpp | 4 +- .../atk/detail/thread/atk_CommandManager.cpp | 1 + .../atk/detail/thread/atk_DriverCommand.cpp | 1 + .../atk/detail/thread/atk_SoundThread.cpp | 1 + .../atk/detail/thread/atk_Task.cpp | 8 +- .../atk/detail/thread/atk_TaskManager.cpp | 1 + .../atk/detail/thread/atk_TaskThread.cpp | 1 + .../atk/detail/util/atk_CurveAdshr.cpp | 2 +- .../atk/detail/util/atk_CurveLfo.cpp | 6 +- .../atk/detail/util/atk_FrameHeap.cpp | 4 +- .../atk/detail/util/atk_InstancePool.cpp | 2 +- .../atk/detail/util/atk_MemoryFileStream.cpp | 2 +- src/NintendoWare/atk/detail/util/atk_Util.cpp | 370 ++++++++---------- .../atk/detail/util/atk_WavOutFileStream.cpp | 10 +- .../atk/detail/voice/atk_Channel.cpp | 2 +- .../atk/detail/voice/atk_ChannelManager.cpp | 1 + .../atk/detail/voice/atk_LowLevelVoice.cpp | 2 +- .../atk/detail/voice/atk_MultiVoice.cpp | 1 + .../detail/voice/atk_MultiVoiceManager.cpp | 1 + .../atk/detail/voice/atk_Voice.cpp | 2 +- .../atk/detail/voice/atk_VoiceCommand.cpp | 1 + .../atk/detail/wsd/atk_WaveSound.cpp | 1 + .../atk/detail/wsd/atk_WaveSoundFile.cpp | 2 +- .../detail/wsd/atk_WaveSoundFileReader.cpp | 2 +- .../atk/detail/wsd/atk_WaveSoundLoader.cpp | 1 + .../atk/detail/wsd/atk_WaveSoundPlayer.cpp | 1 + .../atk/detail/wsd/atk_WaveSoundRuntime.cpp | 1 + src/NintendoWare/atk/effect/atk_EffectAux.cpp | 1 + .../atk/effect/atk_EffectBase.cpp | 1 + .../atk/fnd/basis/atkfnd_FrameHeapImpl.cpp | 4 +- .../atk/fnd/basis/atkfnd_HeapBase.cpp | 36 +- .../atk/fnd/basis/atkfnd_Time.win32.cpp | 1 + .../fnd/basis/atkfnd_WorkBufferAllocator.cpp | 1 + .../atk/fnd/io/atkfnd_FileStreamImpl.cpp | 13 +- .../fnd/io/atkfnd_FileStreamImpl.win32.cpp | 4 +- .../atk/fnd/io/atkfnd_FileStreamProxy.cpp | 6 +- .../atk/fnd/io/atkfnd_StreamCache.cpp | 4 +- src/NintendoWare/atk/fnd/os/atkfnd_Thread.cpp | 1 + .../atk/fnd/os/atkfnd_Thread.win32.cpp | 1 + .../atk/submix/atk_ChannelMixVolume.cpp | 2 +- src/NintendoWare/atk/submix/atk_FinalMix.cpp | 1 + .../atk/submix/atk_OutputMixer.cpp | 1 + src/NintendoWare/atk/submix/atk_SubMix.cpp | 1 + .../atk_AudioRendererPerformanceReader.cpp | 37 +- .../atk/util/atk_DeviceOutRecorder.cpp | 4 +- .../atk/util/atk_ProfileReader.cpp | 4 +- .../atk/util/atk_TaskProfileReader.cpp | 1 + 265 files changed, 2080 insertions(+), 1672 deletions(-) diff --git a/include/nn/atk/atk_Adpcm.h b/include/nn/atk/atk_Adpcm.h index 6949c8f6..c4043694 100644 --- a/include/nn/atk/atk_Adpcm.h +++ b/include/nn/atk/atk_Adpcm.h @@ -5,6 +5,7 @@ #include namespace nn::atk { + using AdpcmParam = audio::AdpcmParameter; struct alignas(64) AdpcmContext { @@ -18,8 +19,9 @@ struct AdpcmContextNotAligned { static_assert(sizeof(AdpcmContextNotAligned) == 0x6); namespace detail { -void DecodeDspAdpcm(position_t playPosition, AdpcmContext& context, - const AdpcmParam& param, const void* adpcmData, - size_t decodeSamples, s16* dest); + +void DecodeDspAdpcm(position_t playPosition, AdpcmContext& context, const AdpcmParam& param, + const void* adpcmData, size_t decodeSamples, s16* dest); + } -} // namespace nn::atk \ No newline at end of file +} // namespace nn::atk diff --git a/include/nn/atk/atk_AudioRendererPerformanceReader.h b/include/nn/atk/atk_AudioRendererPerformanceReader.h index 188585ff..65761f61 100644 --- a/include/nn/atk/atk_AudioRendererPerformanceReader.h +++ b/include/nn/atk/atk_AudioRendererPerformanceReader.h @@ -5,6 +5,7 @@ #include namespace nn::atk { + class AudioRendererPerformanceReader { public: static const int PerformanceInfoCountMin = 2; @@ -16,7 +17,7 @@ class AudioRendererPerformanceReader { }; AudioRendererPerformanceReader(); - + static size_t GetRequiredMemorySize(int performanceInfoCount); void Initialize(int performanceInfoCount, void* buffer, size_t bufferSize); @@ -24,14 +25,16 @@ class AudioRendererPerformanceReader { bool IsInitialized() const { return m_IsInitialized; }; - void Record(const void* performanceFrameBuffer, size_t performanceFrameBufferSize, os::Tick tick); + void Record(const void* performanceFrameBuffer, size_t performanceFrameBufferSize, + os::Tick tick); private: - PerformanceInfo* m_pPerformanceInfo {}; - int m_PerformanceInfoCount {0}; - std::atomic_int m_WriteIndex {0}; - std::atomic_int m_ReadIndex {0}; - bool m_IsInitialized {false}; + PerformanceInfo* m_pPerformanceInfo{}; + int m_PerformanceInfoCount{0}; + std::atomic_int m_WriteIndex{0}; + std::atomic_int m_ReadIndex{0}; + bool m_IsInitialized{false}; }; static_assert(sizeof(AudioRendererPerformanceReader) == 0x18); -} // namespace nn::atk \ No newline at end of file + +} // namespace nn::atk diff --git a/include/nn/atk/atk_Bank.h b/include/nn/atk/atk_Bank.h index 8c051f11..35c33b1c 100644 --- a/include/nn/atk/atk_Bank.h +++ b/include/nn/atk/atk_Bank.h @@ -1,20 +1,21 @@ #pragma once +#include #include #include -#include namespace nn::atk::detail::driver { + class Bank { public: Bank(); ~Bank(); - Channel* NoteOn(const BankFileReader& bankReader, - const WaveArchiveFileReader& warcReader, + Channel* NoteOn(const BankFileReader& bankReader, const WaveArchiveFileReader& warcReader, const NoteOnInfo& noteOnInfo) const; - + static float CalcChannelVelocityVolume(u8 velocity); }; static_assert(sizeof(Bank) == 0x1); -} // namespace nn::atk::detail::driver \ No newline at end of file + +} // namespace nn::atk::detail::driver diff --git a/include/nn/atk/atk_BankFile.h b/include/nn/atk/atk_BankFile.h index f81e64fd..86c7d564 100644 --- a/include/nn/atk/atk_BankFile.h +++ b/include/nn/atk/atk_BankFile.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail { + struct BankFile { struct InfoBlock; struct FileHeader : Util::SoundFileHeader { @@ -17,17 +18,11 @@ struct BankFile { const Util::WaveIdTable& GetWaveIdTable() const; const Util::ReferenceTable& GetInstrumentReferenceTable() const; - u32 GetWaveIdCount() const { - return GetWaveIdTable().table.count; - } + u32 GetWaveIdCount() const { return GetWaveIdTable().table.count; } - s32 GetInstrumentCount() const { - return GetInstrumentReferenceTable().count; - } + s32 GetInstrumentCount() const { return GetInstrumentReferenceTable().count; } - const Util::WaveId* GetWaveId(u32 index) const { - return GetWaveIdTable().GetWaveId(index); - } + const Util::WaveId* GetWaveId(u32 index) const { return GetWaveIdTable().GetWaveId(index); } const Instrument* GetInstrument(int programNo) const; }; @@ -63,7 +58,7 @@ struct BankFile { u8 GetOriginalKey() const; u8 GetVolume() const; u8 GetPan() const; - float GetPitch() const ; + float GetPitch() const; bool IsIgnoreNoteOff() const; u8 GetKeyGroup() const; u8 GetInterpolationType() const; @@ -91,4 +86,5 @@ struct BankFile { }; static_assert(sizeof(RegionParameter) == 0x28); }; -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_BankFileReader.h b/include/nn/atk/atk_BankFileReader.h index 309a28a9..a02041fe 100644 --- a/include/nn/atk/atk_BankFileReader.h +++ b/include/nn/atk/atk_BankFileReader.h @@ -48,4 +48,4 @@ class BankFileReader { }; static_assert(sizeof(BankFileReader) == 0x18); -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index 260fcd05..9050038b 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -162,9 +162,9 @@ struct SoundParamCalculationValues { float lpf; int bqfType; float bqfValue; - float outputVolume[1]; - float outputMainSend[1]; - float outputEffectSend[1][AuxBus_Count]; + float outputVolume[OutputDevice_Count]; + float outputMainSend[OutputDevice_Count]; + float outputEffectSend[OutputDevice_Count][AuxBus_Count]; }; static_assert(sizeof(SoundPlayerParam) == 0x24); @@ -175,10 +175,10 @@ struct SoundParamCalculationValues { int bqfType; float bqfValue; u32 outputLineFlag; - float outputVolume[1]; - float outputPan[1]; - float outputSurroundPan[1]; - float outputEffectSend[1][AuxBus_Count]; + float outputVolume[OutputDevice_Count]; + float outputPan[OutputDevice_Count]; + float outputSurroundPan[OutputDevice_Count]; + float outputEffectSend[OutputDevice_Count][AuxBus_Count]; int playerPriority; }; static_assert(sizeof(Sound3DParam) == 0x34); @@ -187,8 +187,8 @@ struct SoundParamCalculationValues { float volume; float pitch; float lpf; - float outputVolume[1]; - float outputPan[1]; + float outputVolume[OutputDevice_Count]; + float outputPan[OutputDevice_Count]; }; static_assert(sizeof(SoundActorParam) == 0x14); @@ -197,14 +197,14 @@ struct SoundParamCalculationValues { float pitch; float lpf; int bqfType; - int bqfValue; + float bqfValue; u32 outputLineFlag; - float outputVolume[1]; - float outputPan[1]; - float outputSurroundPan[1]; - float outputMainSend[1]; - float outputEffectSend[1][AuxBus_Count]; - MixParameter outputMixParameter[1][2]; + float outputVolume[OutputDevice_Count]; + float outputPan[OutputDevice_Count]; + float outputSurroundPan[OutputDevice_Count]; + float outputMainSend[OutputDevice_Count]; + float outputEffectSend[OutputDevice_Count][AuxBus_Count]; + MixParameter outputMixParameter[OutputDevice_Count][WaveChannelMax]; MixMode mixMode; float pan; float surroundPan; @@ -221,7 +221,7 @@ struct SoundParamCalculationValues { int bqfType; float bqfValue; u32 outputLineFlag; - detail::OutputParam outputParamResult[1]; + detail::OutputParam outputParamResult[OutputDevice_Count]; int playerPriority; }; static_assert(sizeof(ResultParam) == 0x6c); @@ -336,7 +336,7 @@ class BasicSound { virtual bool IsPrepared() const = 0; bool IsPause() const; bool IsMute() const; - + bool IsStarted() const { return m_StartedFlag; } void SetPriority(int priority, int ambientPriority); @@ -435,7 +435,7 @@ class BasicSound { int GetRemainingPauseFadeFrames() const; int GetRemainingMuteFadeFrames() const; - int GetPlayerPriority() const { return m_Priority; } + int GetPlayerPriority() const { return m_AmbientParam.GetPriority(); } void CalculateSoundParamCalculationValues(SoundParamCalculationValues* pOutValue) const; diff --git a/include/nn/atk/atk_BinaryFileFormat.h b/include/nn/atk/atk_BinaryFileFormat.h index a1c38709..fd9ab5c2 100644 --- a/include/nn/atk/atk_BinaryFileFormat.h +++ b/include/nn/atk/atk_BinaryFileFormat.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail { + struct BinaryFileHeader { s32 signature; u16 byteOrder; @@ -12,7 +13,7 @@ struct BinaryFileHeader { u16 dataBlocks; u16 reserved; - static const u16 ValidByteOrderMark {0xFEFF}; + static const u16 ValidByteOrderMark{0xFEFF}; }; static_assert(sizeof(BinaryFileHeader) == 0x14); @@ -23,4 +24,4 @@ struct BinaryBlockHeader { }; static_assert(sizeof(BinaryBlockHeader) == 0x8); -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_BiquadFilterCallback.h b/include/nn/atk/atk_BiquadFilterCallback.h index 1647e9ba..4b785250 100644 --- a/include/nn/atk/atk_BiquadFilterCallback.h +++ b/include/nn/atk/atk_BiquadFilterCallback.h @@ -3,6 +3,7 @@ #include namespace nn::atk { + class BiquadFilterCallback { public: using Coefficients = BiquadFilterCoefficients; @@ -12,4 +13,5 @@ class BiquadFilterCallback { virtual void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) = 0; }; static_assert(sizeof(BiquadFilterCallback) == 0x8); -} \ No newline at end of file + +} // namespace nn::atk diff --git a/include/nn/atk/atk_BiquadFilterPresets.h b/include/nn/atk/atk_BiquadFilterPresets.h index 7d0a67cf..2dbc0a0e 100644 --- a/include/nn/atk/atk_BiquadFilterPresets.h +++ b/include/nn/atk/atk_BiquadFilterPresets.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail { + class BiquadFilterLpf : BiquadFilterCallback { public: constexpr static u32 CoefficientsTableSize = 112; @@ -42,7 +43,7 @@ static_assert(sizeof(BiquadFilterBpf512) == 0x8); class BiquadFilterBpf1024 : BiquadFilterCallback { public: constexpr static u32 CoefficientsTableSize = 93; - + static Coefficients CoefficientsTable32000[CoefficientsTableSize]; ~BiquadFilterBpf1024() override; @@ -114,15 +115,17 @@ class BiquadFilterBpf2048Nw4fCompatible48k : BiquadFilterCallback { static_assert(sizeof(BiquadFilterBpf2048Nw4fCompatible48k) == 0x8); namespace driver { -static BiquadFilterLpf BiquadFilterInstanceLpf {}; -static BiquadFilterHpf BiquadFilterInstanceHpf {}; -static BiquadFilterBpf512 BiquadFilterInstanceBpf512 {}; -static BiquadFilterBpf1024 BiquadFilterInstanceBpf1024 {}; -static BiquadFilterBpf2048 BiquadFilterInstanceBpf2048 {}; -static BiquadFilterLpfNw4fCompatible48k BiquadFilterInstanceLpfNw4fCompatible48k {}; -static BiquadFilterHpfNw4fCompatible48k BiquadFilterInstanceHpfNw4fCompatible48k {}; -static BiquadFilterBpf512Nw4fCompatible48k BiquadFilterInstanceBpf512Nw4fCompatible48k {}; -static BiquadFilterBpf1024Nw4fCompatible48k BiquadFilterInstanceBpf1024Nw4fCompatible48k {}; -static BiquadFilterBpf2048Nw4fCompatible48k BiquadFilterInstanceBpf2048Nw4fCompatible48k {}; -}; -} // namespace nn::atk::detail \ No newline at end of file + +static BiquadFilterLpf BiquadFilterInstanceLpf{}; +static BiquadFilterHpf BiquadFilterInstanceHpf{}; +static BiquadFilterBpf512 BiquadFilterInstanceBpf512{}; +static BiquadFilterBpf1024 BiquadFilterInstanceBpf1024{}; +static BiquadFilterBpf2048 BiquadFilterInstanceBpf2048{}; +static BiquadFilterLpfNw4fCompatible48k BiquadFilterInstanceLpfNw4fCompatible48k{}; +static BiquadFilterHpfNw4fCompatible48k BiquadFilterInstanceHpfNw4fCompatible48k{}; +static BiquadFilterBpf512Nw4fCompatible48k BiquadFilterInstanceBpf512Nw4fCompatible48k{}; +static BiquadFilterBpf1024Nw4fCompatible48k BiquadFilterInstanceBpf1024Nw4fCompatible48k{}; +static BiquadFilterBpf2048Nw4fCompatible48k BiquadFilterInstanceBpf2048Nw4fCompatible48k{}; + +}; // namespace driver +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_BusMixVolumePacket.h b/include/nn/atk/atk_BusMixVolumePacket.h index f40aa7e7..3193f93f 100644 --- a/include/nn/atk/atk_BusMixVolumePacket.h +++ b/include/nn/atk/atk_BusMixVolumePacket.h @@ -3,52 +3,39 @@ #include namespace nn::atk::detail { + struct BusMixVolumePacket { public: static size_t GetRequiredMemSize(int busCount); BusMixVolumePacket(); - + bool Initialize(void* buffer, size_t size, int busCount); void Finalize(); void Reset(); - int GetBusCount() const { - return m_BusCount; - } + int GetBusCount() const { return m_BusCount; } float GetBusMixVolume(int waveChannel, int mixChannel) const { return m_BusMixVolume.volume[waveChannel][mixChannel]; } - const OutputBusMixVolume& GetBusMixVolume() const { - return m_BusMixVolume; - } + const OutputBusMixVolume& GetBusMixVolume() const { return m_BusMixVolume; } void SetBusMixVolume(int waveChannel, int mixChannel, float volume) { m_BusMixVolume.volume[waveChannel][mixChannel] = volume; } - void SetBusMixVolume(const OutputBusMixVolume& busMixVolume) { - m_BusMixVolume = busMixVolume; - } + void SetBusMixVolume(const OutputBusMixVolume& busMixVolume) { m_BusMixVolume = busMixVolume; } - bool IsUsed() const { - return m_IsUsed; - } + bool IsUsed() const { return m_IsUsed; } - void SetUsed(bool isUsed) { - m_IsUsed = isUsed; - } + void SetUsed(bool isUsed) { m_IsUsed = isUsed; } - bool IsEnabled(int bus) const { - return m_pIsEnabledTable[bus]; - } + bool IsEnabled(int bus) const { return m_pIsEnabledTable[bus]; } - void SetEnabled(int bus, bool isEnabled) { - m_pIsEnabledTable[bus] = isEnabled; - } + void SetEnabled(int bus, bool isEnabled) { m_pIsEnabledTable[bus] = isEnabled; } private: OutputBusMixVolume m_BusMixVolume; @@ -57,4 +44,5 @@ struct BusMixVolumePacket { int m_BusCount; }; static_assert(sizeof(BusMixVolumePacket) == 0xd8); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_Channel.h b/include/nn/atk/atk_Channel.h index fafb63da..f74ce0a2 100644 --- a/include/nn/atk/atk_Channel.h +++ b/include/nn/atk/atk_Channel.h @@ -261,4 +261,4 @@ class Channel { }; static_assert(sizeof(Channel) == 0x400); -} // namespace nn::atk::detail::driver \ No newline at end of file +} // namespace nn::atk::detail::driver diff --git a/include/nn/atk/atk_ChannelManager.h b/include/nn/atk/atk_ChannelManager.h index 4b8a2cfb..ffa7e0da 100644 --- a/include/nn/atk/atk_ChannelManager.h +++ b/include/nn/atk/atk_ChannelManager.h @@ -1,13 +1,15 @@ #pragma once -#include #include +#include namespace nn::atk::detail::driver { + class ChannelManager { public: using ChannelPool = InstancePool; - using ChannelList = util::IntrusiveList>; ChannelManager(); @@ -44,4 +46,5 @@ static_assert(sizeof(ChannelManager) == 0x30); #else static_assert(sizeof(ChannelManager) == 0x50); #endif -} // namespace nn::atk::detail::driver \ No newline at end of file + +} // namespace nn::atk::detail::driver diff --git a/include/nn/atk/atk_ChannelMixVolume.h b/include/nn/atk/atk_ChannelMixVolume.h index d2b081e3..fe61894b 100644 --- a/include/nn/atk/atk_ChannelMixVolume.h +++ b/include/nn/atk/atk_ChannelMixVolume.h @@ -3,6 +3,7 @@ #include namespace nn::atk { + class ChannelMixVolume { public: static const int ChannelCountMax = 24; @@ -10,7 +11,7 @@ class ChannelMixVolume { ChannelMixVolume(); explicit ChannelMixVolume(const MixVolume& mixVolume); ChannelMixVolume(const float* pVolume, int volumeCount); - + bool SetChannelCount(int channelCount); int GetChannelCount() const; @@ -26,4 +27,5 @@ class ChannelMixVolume { float m_ChannelVolume[ChannelCountMax]; }; static_assert(sizeof(ChannelMixVolume) == 0x64); -} // namespace nn::atk \ No newline at end of file + +} // namespace nn::atk diff --git a/include/nn/atk/atk_Config.h b/include/nn/atk/atk_Config.h index 772570d7..07c54fd3 100644 --- a/include/nn/atk/atk_Config.h +++ b/include/nn/atk/atk_Config.h @@ -5,6 +5,7 @@ #include namespace nn::atk { + using position_t = detail::fnd::position_t; const int StreamChannelCount{16}; @@ -14,4 +15,4 @@ const int StreamDataLoadTaskMax{32}; static const size_t DataBlockSizeMarginSamples{0x480}; -} // namespace nn::atk \ No newline at end of file +} // namespace nn::atk diff --git a/include/nn/atk/atk_CurveAdshr.h b/include/nn/atk/atk_CurveAdshr.h index 4fa9c358..859383f6 100644 --- a/include/nn/atk/atk_CurveAdshr.h +++ b/include/nn/atk/atk_CurveAdshr.h @@ -58,4 +58,4 @@ class CurveAdshr { }; static_assert(sizeof(CurveAdshr) == 0x1c); -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_CurveLfo.h b/include/nn/atk/atk_CurveLfo.h index 7be5531b..5e200184 100644 --- a/include/nn/atk/atk_CurveLfo.h +++ b/include/nn/atk/atk_CurveLfo.h @@ -66,4 +66,4 @@ class CurveLfo { }; static_assert(sizeof(CurveLfo) == 0x20); -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_Debug.h b/include/nn/atk/atk_Debug.h index ea034b6b..39c48d77 100644 --- a/include/nn/atk/atk_Debug.h +++ b/include/nn/atk/atk_Debug.h @@ -3,6 +3,7 @@ #include namespace nn::atk { + enum DebugWarningFlag { DebugWarningFlag_NotEnoughInstance, DebugWarningFlag_NotEnoughSeqsound, @@ -15,6 +16,7 @@ enum DebugWarningFlag { void Debug_SetWarningFlag(DebugWarningFlag warning, bool enable); namespace detail { + enum DebugSoundType { DebugSoundType_Seqsound, DebugSoundType_Strmsound, @@ -25,6 +27,7 @@ bool Debug_GetWarningFlag(DebugWarningFlag warning); DebugWarningFlag Debug_GetDebugWarningFlagFromSoundType(DebugSoundType type); const char* Debug_GetSoundTypeString(DebugSoundType type); -using DebugLogFunc = void(*)(char*); -} // namespace nn::atk::detail -} // namespace nn::atk \ No newline at end of file +using DebugLogFunc = void (*)(char*); + +} // namespace detail +} // namespace nn::atk diff --git a/include/nn/atk/atk_DeviceOutRecorder.h b/include/nn/atk/atk_DeviceOutRecorder.h index f7414cec..da38a428 100644 --- a/include/nn/atk/atk_DeviceOutRecorder.h +++ b/include/nn/atk/atk_DeviceOutRecorder.h @@ -11,9 +11,10 @@ #include namespace nn::atk { + class DeviceOutRecorder : public detail::fnd::Thread::Handler { NN_NO_COPY(DeviceOutRecorder); - + public: static const u32 RecordingBufferSize = 0x5a000; static const u32 DefaultWriteBlockPerSamples = 0x10000; @@ -84,7 +85,7 @@ class DeviceOutRecorder : public detail::fnd::Thread::Handler { void Initialize(s16* sampleBuffer, u32 maxSamples); void Finalize(); - + u32 Push(const s16* sampleBuffer, u32 samples); u32 Pop(u32 samples); s16* Peek(); @@ -96,7 +97,7 @@ class DeviceOutRecorder : public detail::fnd::Thread::Handler { u32 GetWritableCount() const; u32 GetContiguousReadableCount() const; const char* GetDeviceName() const; - + void UpdateMaxSamples(); private: @@ -104,13 +105,13 @@ class DeviceOutRecorder : public detail::fnd::Thread::Handler { void Write(const s16* sampleBuffer, u32 samples); u32 IncrementPosition(u32 position, u32 length) const; - s16* m_SampleBuffer {nullptr}; - u32 m_MaxBufferSamples {0}; - u32 m_MaxSamples {0}; - std::atomic_uint m_ValidSamples {0}; - u32 m_ReadPosition {0}; - u32 m_WritePosition {0}; - u32 m_ReadBlockSamples {1}; + s16* m_SampleBuffer{nullptr}; + u32 m_MaxBufferSamples{0}; + u32 m_MaxSamples{0}; + std::atomic_uint m_ValidSamples{0}; + u32 m_ReadPosition{0}; + u32 m_WritePosition{0}; + u32 m_ReadBlockSamples{1}; WriteState m_WriteState; const char* m_DeviceName; }; @@ -122,10 +123,10 @@ class DeviceOutRecorder : public detail::fnd::Thread::Handler { public: ~DeviceOutRecorder() override; - bool Initialize(void* recordingBuffer, size_t recordingBufferSize, - void* pThreadStack, size_t threadStackSize); - bool Initialize(void* recordingBuffer, size_t recordingBufferSize, - void* pThreadStack, size_t threadStackSize, const InitializationOptions& options); + bool Initialize(void* recordingBuffer, size_t recordingBufferSize, void* pThreadStack, + size_t threadStackSize); + bool Initialize(void* recordingBuffer, size_t recordingBufferSize, void* pThreadStack, + size_t threadStackSize, const InitializationOptions& options); void Finalize(); @@ -179,12 +180,12 @@ class DeviceOutRecorder : public detail::fnd::Thread::Handler { void OnExit(); bool OnWriteSamples(bool isForceWriteMode); - volatile State m_State {State_NotInitialized}; - u32 m_Channels {0}; - OutputMode m_OutputMode {OutputMode_Stereo}; - bool m_IsLeadSilenceTrimming {false}; - u32 m_MaxSamples {0}; - u32 m_WrittenSamples {0}; + volatile State m_State{State_NotInitialized}; + u32 m_Channels{0}; + OutputMode m_OutputMode{OutputMode_Stereo}; + bool m_IsLeadSilenceTrimming{false}; + u32 m_MaxSamples{0}; + u32 m_WrittenSamples{0}; detail::fnd::Thread m_Thread; void* m_ThreadStack; os::MessageQueue m_MessageQueue; @@ -198,4 +199,5 @@ class DeviceOutRecorder : public detail::fnd::Thread::Handler { u32 m_WriteBlockPerSamples; }; static_assert(sizeof(DeviceOutRecorder) == 0x310); -} // namespace nn::atk \ No newline at end of file + +} // namespace nn::atk diff --git a/include/nn/atk/atk_DisposeCallback.h b/include/nn/atk/atk_DisposeCallback.h index c9496f92..b9456e70 100644 --- a/include/nn/atk/atk_DisposeCallback.h +++ b/include/nn/atk/atk_DisposeCallback.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail::driver { + class DisposeCallback { public: DisposeCallback() = default; @@ -10,7 +11,7 @@ class DisposeCallback { virtual ~DisposeCallback() = default; virtual void InvalidateData(const void* start, const void* end) = 0; - + private: friend class DisposeCallbackManager; @@ -18,4 +19,4 @@ class DisposeCallback { }; static_assert(sizeof(DisposeCallback) == 0x18); -} // namespace nn::atk::detail::driver \ No newline at end of file +} // namespace nn::atk::detail::driver diff --git a/include/nn/atk/atk_DisposeCallbackManager.h b/include/nn/atk/atk_DisposeCallbackManager.h index 937ee071..0f7a4c54 100644 --- a/include/nn/atk/atk_DisposeCallbackManager.h +++ b/include/nn/atk/atk_DisposeCallbackManager.h @@ -5,11 +5,12 @@ #include namespace nn::atk::detail::driver { + class DisposeCallbackManager { public: - using CallbackList = util::IntrusiveList>; + using CallbackList = util::IntrusiveList< + DisposeCallback, + util::IntrusiveListMemberNodeTraits>; DisposeCallbackManager(); @@ -26,4 +27,5 @@ class DisposeCallbackManager { CallbackList m_CallbackList; }; static_assert(sizeof(DisposeCallbackManager) == 0x10); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail::driver diff --git a/include/nn/atk/atk_DriverCommand.h b/include/nn/atk/atk_DriverCommand.h index d853a9a6..36066eec 100644 --- a/include/nn/atk/atk_DriverCommand.h +++ b/include/nn/atk/atk_DriverCommand.h @@ -1,14 +1,15 @@ #pragma once -#include +#include #include #include #include #include -#include #include +#include namespace nn::atk::detail { + enum DriverCommandId { DriverCommandId_Dummy, DriverCommandId_Debug, @@ -387,7 +388,7 @@ struct DriverCommandStreamSoundLoadData : Command { static_assert(sizeof(DriverCommandStreamSoundLoadData) == 0xc0); struct DriverCommandStreamSoundForceFinish : Command { - driver::StreamSoundPlayer* player; + driver::StreamSoundPlayer* player; }; static_assert(sizeof(DriverCommandStreamSoundForceFinish) == 0x20); @@ -518,7 +519,7 @@ static_assert(sizeof(DriverCommandVoiceAdpcmParam) == 0x30); class DriverCommand : public CommandManager { public: static DriverCommand* GetInstance(); - + static void ProcessCommandList(Command* commandList); DriverCommand(); @@ -526,7 +527,7 @@ class DriverCommand : public CommandManager { void Initialize(void* commandBuffer, size_t commandBufferSize); void RequestProcessCommand(); - }; static_assert(sizeof(DriverCommand) == 0x310); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_DspadpcmReader.h b/include/nn/atk/atk_DspadpcmReader.h index 2b46b74a..72b69ea5 100644 --- a/include/nn/atk/atk_DspadpcmReader.h +++ b/include/nn/atk/atk_DspadpcmReader.h @@ -3,17 +3,17 @@ #include namespace nn::atk::detail { + class DspadpcmReader { public: DspadpcmReader(); - void Initialize(const void* dspadpcmData) { - m_pDspadpcmData = dspadpcmData; - } + void Initialize(const void* dspadpcmData) { m_pDspadpcmData = dspadpcmData; } bool ReadWaveInfo(WaveInfo* info) const; private: - const void* m_pDspadpcmData {}; + const void* m_pDspadpcmData{}; }; -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_EffectAux.h b/include/nn/atk/atk_EffectAux.h index eb99b032..55f107ad 100644 --- a/include/nn/atk/atk_EffectAux.h +++ b/include/nn/atk/atk_EffectAux.h @@ -3,15 +3,17 @@ #include #include +#include + #include #include #include #include -#include #include namespace nn::atk { + class OutputMixer; class EffectAux { @@ -47,20 +49,17 @@ class EffectAux { size_t GetRequiredMemSize(const audio::AudioRendererParameter& parameter) const; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) - bool AddEffect(audio::AudioRendererConfig* pConfig, - const audio::AudioRendererParameter& parameter, + bool AddEffect(audio::AudioRendererConfig* pConfig, + const audio::AudioRendererParameter& parameter, audio::FinalMixType* pFinalMixType); - bool AddEffect(audio::AudioRendererConfig* pConfig, - const audio::AudioRendererParameter& parameter, - audio::SubMixType* pSubMixType); + bool AddEffect(audio::AudioRendererConfig* pConfig, + const audio::AudioRendererParameter& parameter, audio::SubMixType* pSubMixType); #else - bool AddEffect(audio::AudioRendererConfig* pConfig, - const audio::AudioRendererParameter& parameter, - OutputMixer* pOutputMixer); + bool AddEffect(audio::AudioRendererConfig* pConfig, + const audio::AudioRendererParameter& parameter, OutputMixer* pOutputMixer); #endif - void SplitEffectBuffer(BufferSet* pBufferSet, void* effectBuffer, - size_t effectBufferSize); + void SplitEffectBuffer(BufferSet* pBufferSet, void* effectBuffer, size_t effectBufferSize); void SetEffectInputOutput(const s8* input, const s8* output, s32 inputCount, s32 outputCount); @@ -105,4 +104,5 @@ class EffectAux { ChannelIndex m_ChannelSetting[ChannelCountMax]; }; static_assert(sizeof(EffectAux) == 0x50 + sizeof(ChannelIndex) * EffectAux::ChannelCountMax); -} // namespace nn::atk \ No newline at end of file + +} // namespace nn::atk diff --git a/include/nn/atk/atk_EffectBase.h b/include/nn/atk/atk_EffectBase.h index ae6444c9..12d8f9ef 100644 --- a/include/nn/atk/atk_EffectBase.h +++ b/include/nn/atk/atk_EffectBase.h @@ -2,6 +2,7 @@ #include #include + #include #include #include @@ -9,6 +10,7 @@ #include namespace nn::atk { + class OutputMixer; class EffectBase { @@ -74,4 +76,5 @@ class EffectBase { size_t m_EffectBufferSize; }; static_assert(sizeof(EffectBase) == 0x30); -} // namespace nn::atk \ No newline at end of file + +} // namespace nn::atk diff --git a/include/nn/atk/atk_ElementType.h b/include/nn/atk/atk_ElementType.h index fcb4d186..f444c876 100644 --- a/include/nn/atk/atk_ElementType.h +++ b/include/nn/atk/atk_ElementType.h @@ -1,6 +1,7 @@ #pragma once namespace nn::atk::detail { + enum ElementType { ElementType_Category_Tables = 0x100, ElementType_Category_Parameters = 0x200, @@ -57,7 +58,8 @@ enum ElementType { ElementType_SoundArchiveFile_InfoBlock, ElementType_SoundArchiveFile_FileBlock, - ElementType_SoundArchiveFile_SoundInfoSection = ElementType_Category_SoundArchiveFile_InfoSections, + ElementType_SoundArchiveFile_SoundInfoSection = + ElementType_Category_SoundArchiveFile_InfoSections, ElementType_SoundArchiveFile_BankInfoSection, ElementType_SoundArchiveFile_PlayerInfoSection, ElementType_SoundArchiveFile_WaveArchiveInfoSection, @@ -82,7 +84,7 @@ enum ElementType { ElementType_SoundArchiveFile_StreamSoundTrackInfo, ElementType_SoundArchiveFile_SendInfo, ElementType_SoundArchiveFile_StreamSoundExtensionInfo, - + ElementType_SoundArchiveFile_StringTable = ElementType_Category_SoundArchiveFile_General, ElementType_SoundArchiveFile_PatriciaTree, @@ -139,4 +141,5 @@ enum ElementType { ElementType_AnimSoundFile_EventInfo = ElementType_Category_AnimSoundFile_Items }; -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_ExternalSoundPlayer.h b/include/nn/atk/atk_ExternalSoundPlayer.h index 155f8508..e17feb6b 100644 --- a/include/nn/atk/atk_ExternalSoundPlayer.h +++ b/include/nn/atk/atk_ExternalSoundPlayer.h @@ -5,11 +5,12 @@ #include namespace nn::atk::detail { + class ExternalSoundPlayer { public: using SoundList = util::IntrusiveList< - BasicSound, util::IntrusiveListMemberNodeTraits< - BasicSound, &BasicSound::m_ExtSoundPlayerPlayLink>>; + BasicSound, + util::IntrusiveListMemberNodeTraits>; virtual ~ExternalSoundPlayer(); virtual bool CanPlaySound(s32); @@ -36,4 +37,5 @@ class ExternalSoundPlayer { s32 m_PlayableCount; }; static_assert(sizeof(ExternalSoundPlayer) == 0x20); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_FinalMix.h b/include/nn/atk/atk_FinalMix.h index 17919c42..66a4f88e 100644 --- a/include/nn/atk/atk_FinalMix.h +++ b/include/nn/atk/atk_FinalMix.h @@ -7,12 +7,13 @@ #include namespace nn::atk { + class FinalMix : OutputMixer { public: static size_t GetRequiredMemorySize(bool isEffectEnabled); - bool Initialize(audio::AudioRendererConfig* pConfig, s32 channelCount, - bool isEffectEnabled, void* buffer, size_t bufferSize); + bool Initialize(audio::AudioRendererConfig* pConfig, s32 channelCount, bool isEffectEnabled, + void* buffer, size_t bufferSize); void Finalize(audio::AudioRendererConfig* pConfig); @@ -40,4 +41,5 @@ class FinalMix : OutputMixer { s32 m_ChannelCount; }; static_assert(sizeof(FinalMix) == 0x50); -} // namespace nn::atk \ No newline at end of file + +} // namespace nn::atk diff --git a/include/nn/atk/atk_FrameHeap.h b/include/nn/atk/atk_FrameHeap.h index b41ca69e..ff203564 100644 --- a/include/nn/atk/atk_FrameHeap.h +++ b/include/nn/atk/atk_FrameHeap.h @@ -16,11 +16,10 @@ class FrameHeap { class Block { public: - Block(void* buffer, size_t size, DisposeCallback callback, - void* callbackArg, HeapCallback heapCallback, void* heapCallbackArg) - : m_pBuffer{buffer}, m_Size{size}, - m_Callback{callback}, m_pCallbackArg{callbackArg}, - m_HeapCallback{heapCallback}, m_pHeapCallbackArg{heapCallbackArg} {} + Block(void* buffer, size_t size, DisposeCallback callback, void* callbackArg, + HeapCallback heapCallback, void* heapCallbackArg) + : m_pBuffer{buffer}, m_Size{size}, m_Callback{callback}, m_pCallbackArg{callbackArg}, + m_HeapCallback{heapCallback}, m_pHeapCallbackArg{heapCallbackArg} {} ~Block() = default; @@ -83,8 +82,8 @@ class FrameHeap { bool Create(void* startAddress, size_t size); void Destroy(); - void* Alloc(size_t size, DisposeCallback callback, void* callbackArg, - HeapCallback heapCallback, void* heapCallbackArg); + void* Alloc(size_t size, DisposeCallback callback, void* callbackArg, HeapCallback heapCallback, + void* heapCallbackArg); void Clear(); @@ -110,4 +109,4 @@ class FrameHeap { }; static_assert(sizeof(FrameHeap) == 0x18); -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_FsSoundArchive.h b/include/nn/atk/atk_FsSoundArchive.h index b89173cf..5e7fb921 100644 --- a/include/nn/atk/atk_FsSoundArchive.h +++ b/include/nn/atk/atk_FsSoundArchive.h @@ -6,13 +6,12 @@ #include namespace nn::atk { + class FsSoundArchive : public SoundArchive { public: - static const int BufferAlignSize {64}; - - struct OpenArg { + static const int BufferAlignSize{64}; - }; + struct OpenArg {}; FsSoundArchive(); ~FsSoundArchive() override; @@ -32,10 +31,7 @@ class FsSoundArchive : public SoundArchive { size_t detail_GetRequiredStreamBufferSize() const override; const void* detail_GetFileAddress(ItemId itemId) const override; - enum FileAccessMode { - FileAccessMode_Always, - FileAccessMode_InFunction - }; + enum FileAccessMode { FileAccessMode_Always, FileAccessMode_InFunction }; void SetFileAccessMode(FileAccessMode value); FileAccessMode GetFileAccessMode() const; @@ -44,8 +40,8 @@ class FsSoundArchive : public SoundArchive { void FileAccessEnd() const override; protected: - detail::fnd::FileStream* OpenStream(void* buffer, size_t size, - position_t begin, size_t length) const override; + detail::fnd::FileStream* OpenStream(void* buffer, size_t size, position_t begin, + size_t length) const override; detail::fnd::FileStream* OpenExtStream(void* buffer, size_t size, const char* extFilePath, void* cacheBuffer, size_t cacheSize) const override; @@ -55,10 +51,10 @@ class FsSoundArchive : public SoundArchive { private: detail::SoundArchiveFileReader m_ArchiveReader; mutable detail::fnd::FileStreamImpl m_FileStream; - bool m_IsOpened {false}; - u8 m_FileAccessMode {FileAccessMode_Always}; + bool m_IsOpened{false}; + u8 m_FileAccessMode{FileAccessMode_Always}; u8 m_Padding[2]; - mutable u32 m_FileAccessCount {0}; + mutable u32 m_FileAccessCount{0}; char m_SoundArchiveFullPath[SoundArchive::FilePathMax]; mutable detail::fnd::CriticalSection m_FileOpenCloseLock; }; @@ -67,4 +63,5 @@ static_assert(sizeof(FsSoundArchive) == 0x618); #else static_assert(sizeof(FsSoundArchive) == 0x610); #endif -} // namespace nn::atk \ No newline at end of file + +} // namespace nn::atk diff --git a/include/nn/atk/atk_GroupFile.h b/include/nn/atk/atk_GroupFile.h index edc1a2d3..25c4dc10 100644 --- a/include/nn/atk/atk_GroupFile.h +++ b/include/nn/atk/atk_GroupFile.h @@ -87,4 +87,4 @@ struct GroupFile { static_assert(sizeof(GroupItemInfoEx) == 0x8); }; -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_GroupFileReader.h b/include/nn/atk/atk_GroupFileReader.h index a84ba139..f78301c2 100644 --- a/include/nn/atk/atk_GroupFileReader.h +++ b/include/nn/atk/atk_GroupFileReader.h @@ -31,4 +31,4 @@ class GroupFileReader { }; static_assert(sizeof(GroupFileReader) == 0x18); -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_HardwareManager.h b/include/nn/atk/atk_HardwareManager.h index 6418d814..b3ad0004 100644 --- a/include/nn/atk/atk_HardwareManager.h +++ b/include/nn/atk/atk_HardwareManager.h @@ -8,17 +8,18 @@ #include #include -#include +#include #include +#include #include -#include #include namespace nn::atk::detail::driver { class HardwareManager : public Util::Singleton { public: - using SubMixList = util::IntrusiveList>; + using SubMixList = + util::IntrusiveList>; constexpr static u32 SoundFrameIntervalMsec = 5; constexpr static u32 SoundFrameIntervalUsec = 5000; @@ -90,9 +91,9 @@ class HardwareManager : public Util::Singleton { class HardwareManagerParameter { public: - void SetSubMixParameter(bool isStereoModeEnabled, bool isEffectEnabled, + void SetSubMixParameter(bool isStereoModeEnabled, bool isEffectEnabled, bool isSubMixEnabled, bool isAdditionalEffectBusEnabled, - bool isAdditionalSubMixEnabled, bool isCustomSubMixEnabled, + bool isAdditionalSubMixEnabled, bool isCustomSubMixEnabled, s32 customSubMixCount, s32 customMixTotalChannelCount); private: @@ -128,14 +129,18 @@ class HardwareManager : public Util::Singleton { audio::MemoryPoolState GetMemoryPoolState(audio::MemoryPoolType* pPool); - void SetupAudioRendererParameter(audio::AudioRendererParameter* audioRendererParameter, - const HardwareManagerParameter& hardwareManagerParameter) const; + void + SetupAudioRendererParameter(audio::AudioRendererParameter* audioRendererParameter, + const HardwareManagerParameter& hardwareManagerParameter) const; size_t GetRequiredMemSize(const HardwareManagerParameter& hardwareManagerParameter) const; size_t GetRequiredMemSizeForMemoryPool(s32 voiceCount) const; - size_t GetRequiredRecorderWorkBufferSize(const HardwareManagerParameter& hardwareManagerParameter) const; - size_t GetRequiredCircularBufferSinkWithMemoryPoolBufferSize(const HardwareManagerParameter& hardwareManagerParameter) const; - size_t GetRequiredCircularBufferSinkBufferSize(const HardwareManagerParameter& hardwareManagerParameter) const; + size_t GetRequiredRecorderWorkBufferSize( + const HardwareManagerParameter& hardwareManagerParameter) const; + size_t GetRequiredCircularBufferSinkWithMemoryPoolBufferSize( + const HardwareManagerParameter& hardwareManagerParameter) const; + size_t GetRequiredCircularBufferSinkBufferSize( + const HardwareManagerParameter& hardwareManagerParameter) const; s32 GetChannelCountMax() const; @@ -152,8 +157,8 @@ class HardwareManager : public Util::Singleton { void StartUserCircularBufferSink(bool isForceStartMode); u64 ReadUserCircularBufferSink(void* buffer, size_t bufferSize); - void AttachMemoryPool(audio::MemoryPoolType* pPool, void* buffer, - size_t bufferSize, bool isSoundThreadEnabled); + void AttachMemoryPool(audio::MemoryPoolType* pPool, void* buffer, size_t bufferSize, + bool isSoundThreadEnabled); Result RequestUpdateAudioRenderer(); @@ -165,14 +170,15 @@ class HardwareManager : public Util::Singleton { s32* GetDroppedLowLevelVoiceCount() const; - size_t GetRequiredPerformanceFramesBufferSize(HardwareManagerParameter* hardwareManagerParameter); + size_t + GetRequiredPerformanceFramesBufferSize(HardwareManagerParameter* hardwareManagerParameter); - Result Initialize(void* buffer, size_t bufferSize, void* memoryPoolBuffer, size_t memoryPoolBufferSize, - void* circularBufferSinkBuffer, size_t circularBufferSinkBufferSize, - HardwareManagerParameter* parameter); + Result Initialize(void* buffer, size_t bufferSize, void* memoryPoolBuffer, + size_t memoryPoolBufferSize, void* circularBufferSinkBuffer, + size_t circularBufferSinkBufferSize, HardwareManagerParameter* parameter); void SetBiquadFilterCallback(s32, const BiquadFilterCallback* callback); - void SetOutputMode(OutputMode mode,OutputDevice device); + void SetOutputMode(OutputMode mode, OutputDevice device); void UpdateEndUserOutputMode(); @@ -218,7 +224,8 @@ class HardwareManager : public Util::Singleton { void SetMainBusChannelVolumeForAdditionalEffect(f32 volume, s32 srcChannel, s32 dstChannel); f32 GetMainBusChannelVolumeForAdditionalEffect(s32 srcChannel, s32 dstChannel) const; - void SetAuxBusChannelVolumeForAdditionalEffect(AuxBus bus, f32 volume, s32 srcChannel, s32 dstChannel); + void SetAuxBusChannelVolumeForAdditionalEffect(AuxBus bus, f32 volume, s32 srcChannel, + s32 dstChannel); f32 GetAuxBusChannelVolumeForAdditionalEffect(AuxBus bus, s32 srcChannel, s32 dstChannel) const; static void FlushDataCache(void* address, size_t length); @@ -293,4 +300,4 @@ class HardwareManager : public Util::Singleton { }; // static_assert(sizeof(HardwareManager) == 0xa58); -} // namespace nn::atk::detail::driver \ No newline at end of file +} // namespace nn::atk::detail::driver diff --git a/include/nn/atk/atk_InstancePool.h b/include/nn/atk/atk_InstancePool.h index 702584bf..83649c6a 100644 --- a/include/nn/atk/atk_InstancePool.h +++ b/include/nn/atk/atk_InstancePool.h @@ -45,7 +45,6 @@ class BufferPool : PoolImpl { void* Alloc() { return AllocImpl(); } void Free(void* ptr) { FreeImpl(ptr); } - }; template @@ -76,4 +75,4 @@ class InstancePool : PoolImpl { void Free(T* obj) { FreeImpl(obj); } }; -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_ItemType.h b/include/nn/atk/atk_ItemType.h index 574f6ca7..47a4fc3b 100644 --- a/include/nn/atk/atk_ItemType.h +++ b/include/nn/atk/atk_ItemType.h @@ -1,6 +1,7 @@ #pragma once namespace nn::atk::detail { + enum ItemType { ItemType_Sound = 1, ItemType_SoundGroup, @@ -9,4 +10,5 @@ enum ItemType { ItemType_WaveArchive, ItemType_Group, }; -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_LowLevelVoice.h b/include/nn/atk/atk_LowLevelVoice.h index 05b67709..40a808a8 100644 --- a/include/nn/atk/atk_LowLevelVoice.h +++ b/include/nn/atk/atk_LowLevelVoice.h @@ -137,4 +137,4 @@ class LowLevelVoiceAllocator { }; static_assert(sizeof(LowLevelVoiceAllocator) == 0x28); -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_MmlCommand.h b/include/nn/atk/atk_MmlCommand.h index 6a9852cc..d27bdb79 100644 --- a/include/nn/atk/atk_MmlCommand.h +++ b/include/nn/atk/atk_MmlCommand.h @@ -1,6 +1,7 @@ #pragma once namespace nn::atk::detail::driver { + class MmlCommand { public: enum Mml { @@ -63,12 +64,12 @@ class MmlCommand { Mml_Damper, Mml_ModDelay, Mml_Tempo, - + Mml_SweepPitch = 0xe3, Mml_ModPeriod, Mml_ExCommand = 0xf0, - + Mml_EnvReset = 0xfb, Mml_LoopEnd, Mml_Ret, @@ -76,4 +77,5 @@ class MmlCommand { Mml_Fin, }; }; -} // namespace nn::atk::detail::driver \ No newline at end of file + +} // namespace nn::atk::detail::driver diff --git a/include/nn/atk/atk_MmlParser.h b/include/nn/atk/atk_MmlParser.h index 8c91df9d..1086e75f 100644 --- a/include/nn/atk/atk_MmlParser.h +++ b/include/nn/atk/atk_MmlParser.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail::driver { + class MmlParser { public: enum SeqArgType { @@ -25,9 +26,9 @@ class MmlParser { SequenceTrack::ParseResult Parse(MmlSequenceTrack* track, bool doNoteOn) const; - s32 ReadArg(const u8** ptr, SequenceSoundPlayer* player, SequenceTrack* track, + s32 ReadArg(const u8** ptr, SequenceSoundPlayer* player, SequenceTrack* track, SeqArgType argType) const; - + s32 Read24(const u8** ptr) const; s16 Read16(const u8** ptr) const; @@ -35,7 +36,8 @@ class MmlParser { s16* GetVariablePtr(SequenceSoundPlayer* player, SequenceTrack* track, s32 varNo) const; - void NoteOnCommandProc(MmlSequenceTrack* track, s32 key, s32 velocity, s32 length, bool tieFlag) const; + void NoteOnCommandProc(MmlSequenceTrack* track, s32 key, s32 velocity, s32 length, + bool tieFlag) const; s16 ReadVar(const u8** ptr) const; @@ -45,4 +47,5 @@ class MmlParser { static bool* mPrintVarEnabledFlag; }; static_assert(sizeof(MmlParser) == 0x8); -} // namespace nn::atk::detail::driver \ No newline at end of file + +} // namespace nn::atk::detail::driver diff --git a/include/nn/atk/atk_MmlSequenceTrack.h b/include/nn/atk/atk_MmlSequenceTrack.h index 88c2b270..47c74d66 100644 --- a/include/nn/atk/atk_MmlSequenceTrack.h +++ b/include/nn/atk/atk_MmlSequenceTrack.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail::driver { + class MmlParser; class MmlSequenceTrack : SequenceTrack { public: @@ -15,4 +16,5 @@ class MmlSequenceTrack : SequenceTrack { MmlParser* m_pParser; }; static_assert(sizeof(MmlSequenceTrack) == 0x1f0); -} // namespace nn::atk::detail::driver \ No newline at end of file + +} // namespace nn::atk::detail::driver diff --git a/include/nn/atk/atk_MmlSequenceTrackAllocator.h b/include/nn/atk/atk_MmlSequenceTrackAllocator.h index caf05f91..e9d0f44d 100644 --- a/include/nn/atk/atk_MmlSequenceTrackAllocator.h +++ b/include/nn/atk/atk_MmlSequenceTrackAllocator.h @@ -1,10 +1,11 @@ #pragma once -#include -#include #include +#include +#include namespace nn::atk::detail::driver { + class MmlSequenceTrackAllocator : SequenceTrackAllocator { public: using MmlSequenceTrackPool = InstancePool; @@ -24,4 +25,5 @@ class MmlSequenceTrackAllocator : SequenceTrackAllocator { MmlSequenceTrackPool m_TrackPool; }; static_assert(sizeof(MmlSequenceTrackAllocator) == 0x28); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail::driver diff --git a/include/nn/atk/atk_MoveValue.h b/include/nn/atk/atk_MoveValue.h index 83bb576c..0752f6ec 100644 --- a/include/nn/atk/atk_MoveValue.h +++ b/include/nn/atk/atk_MoveValue.h @@ -51,4 +51,4 @@ class MoveValue { CountType m_Counter{0}; }; -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_MultiVoice.h b/include/nn/atk/atk_MultiVoice.h index 8921a552..c2c51b7f 100644 --- a/include/nn/atk/atk_MultiVoice.h +++ b/include/nn/atk/atk_MultiVoice.h @@ -3,10 +3,11 @@ #include #include -#include #include +#include namespace nn::atk::detail::driver { + class MultiVoiceManager; class MultiVoice { @@ -23,15 +24,15 @@ class MultiVoice { VoiceCallbackStatus_DropDsp, }; - using VoiceCallback = void(*)(MultiVoice*,VoiceCallbackStatus,void*); + using VoiceCallback = void (*)(MultiVoice*, VoiceCallbackStatus, void*); - constexpr static u32 UpdateStart = 0b0000001; - constexpr static u32 UpdatePause = 0b0000010; - constexpr static u32 UpdateSrc = 0b0000100; - constexpr static u32 UpdateMix = 0b0001000; - constexpr static u32 UpdateLpf = 0b0010000; - constexpr static u32 UpdateBiquad = 0b0100000; - constexpr static u32 UpdateVe = 0b1000000; + constexpr static u32 UpdateStart = 0b0000001; + constexpr static u32 UpdatePause = 0b0000010; + constexpr static u32 UpdateSrc = 0b0000100; + constexpr static u32 UpdateMix = 0b0001000; + constexpr static u32 UpdateLpf = 0b0010000; + constexpr static u32 UpdateBiquad = 0b0100000; + constexpr static u32 UpdateVe = 0b1000000; constexpr static u32 PriorityNoDrop = 255; @@ -100,41 +101,41 @@ class MultiVoice { void SetOutputLine(u32 lineFlag); void SetOutputParamImpl(const OutputParam& in, const OutputParam& out); #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) - void SetOutputAdditionalParamImpl(const SendArray* pAdditionalSend, - const BusMixVolumePacket* pBusMixVolumePacket, - const OutputBusMixVolume* pBusMixVolume, + void SetOutputAdditionalParamImpl(const SendArray* pAdditionalSend, + const BusMixVolumePacket* pBusMixVolumePacket, + const OutputBusMixVolume* pBusMixVolume, const VolumeThroughModePacket* pVolumeThroughModePacket); #endif - void SetOutputBusMixVolumeImpl(const BusMixVolumePacket& in, + void SetOutputBusMixVolumeImpl(const BusMixVolumePacket& in, const OutputBusMixVolume& busMixVolume, const BusMixVolumePacket& out); - void SetOutputVolumeThroughModePacketImpl(const VolumeThroughModePacket&, + void SetOutputVolumeThroughModePacketImpl(const VolumeThroughModePacket&, const VolumeThroughModePacket&); void SetTvParam(const OutputParam& param); #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) void SetTvAdditionalParam(const OutputAdditionalParam& param); - void SetTvAdditionalParam(const SendArray* pAdditionalSend, + void SetTvAdditionalParam(const SendArray* pAdditionalSend, const BusMixVolumePacket* pBusMixVolumePacket, - const OutputBusMixVolume* pBusMixVolume, + const OutputBusMixVolume* pBusMixVolume, const VolumeThroughModePacket* pVolumeThroughModePacket); void SetOutputReceiver(OutputReceiver* pOutputReceiver); #endif void SetSubMixIndex(s32 subMixIndex); - + void SetUpdateType(UpdateType updateType) { m_UpdateType = updateType; } UpdateType GetUpdateType() const { return m_UpdateType; } #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) - void CalcPreMixVolume(PreMixVolume* mix, const OutputParam& param, - s32 channelIndex, OutputDevice device); + void CalcPreMixVolume(PreMixVolume* mix, const OutputParam& param, s32 channelIndex, + OutputDevice device); #else - void CalcPreMixVolume(PreMixVolume* mix, const OutputParam& param, + void CalcPreMixVolume(PreMixVolume* mix, const OutputParam& param, OutputAdditionalParam* pAdditionalParam, s32 channelIndex, OutputDevice device); #endif void CalcTvMix(OutputMix* mix, const PreMixVolume& pre); - void CalcMixImpl(OutputMix* mix, u32 outputDeviceIndex, - const OutputParam& param, const PreMixVolume& pre); + void CalcMixImpl(OutputMix* mix, u32 outputDeviceIndex, const OutputParam& param, + const PreMixVolume& pre); #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) void CalcMixImpl(OutputMix* mix, u32 outputDeviceIndex, const OutputParam& param, OutputAdditionalParam* pAdditionalParam, const PreMixVolume& pre); @@ -156,7 +157,7 @@ class MultiVoice { void SetAdpcmParam(s32 channelIndex, const AdpcmParam& param); static u64 FrameToByte(s64, SampleFormat); - static void CalcOffsetAdpcmParam(AdpcmContext* context, const AdpcmParam& param, + static void CalcOffsetAdpcmParam(AdpcmContext* context, const AdpcmParam& param, position_t offsetSamples, const void* dataAddress); os::Tick GetProcessTick(const SoundProfile& profile); @@ -203,4 +204,5 @@ static_assert(sizeof(MultiVoice) == 0x270); #else static_assert(sizeof(MultiVoice) == 0x298); #endif -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail::driver diff --git a/include/nn/atk/atk_MultiVoiceManager.h b/include/nn/atk/atk_MultiVoiceManager.h index a9fc647f..6c7e7275 100644 --- a/include/nn/atk/atk_MultiVoiceManager.h +++ b/include/nn/atk/atk_MultiVoiceManager.h @@ -3,23 +3,24 @@ #include namespace nn::atk::detail::driver { + class MultiVoiceManager { public: - using VoiceList = util::IntrusiveList>; + using VoiceList = util::IntrusiveList< + MultiVoice, util::IntrusiveListMemberNodeTraits>; MultiVoiceManager(); size_t GetObjectSize(const SoundInstanceConfig& config); size_t GetRequiredMemSize(s32 voiceCount, const SoundInstanceConfig& config); - + void Initialize(void* mem, size_t memSize, const SoundInstanceConfig& config); void Finalize(); void StopAllVoices(); - MultiVoice* AllocVoice(s32 voiceChannelCount, s32 priority, - MultiVoice::VoiceCallback callback, void* callbackData); + MultiVoice* AllocVoice(s32 voiceChannelCount, s32 priority, MultiVoice::VoiceCallback callback, + void* callbackData); bool DropLowestPriorityVoice(s32); @@ -52,4 +53,5 @@ class MultiVoiceManager { VoiceList m_FreeVoiceList; }; static_assert(sizeof(MultiVoiceManager) == 0x28); -} // namespace nn::atk::detail::driver \ No newline at end of file + +} // namespace nn::atk::detail::driver diff --git a/include/nn/atk/atk_NoteOnCallback.h b/include/nn/atk/atk_NoteOnCallback.h index 24c1dda6..4764f51d 100644 --- a/include/nn/atk/atk_NoteOnCallback.h +++ b/include/nn/atk/atk_NoteOnCallback.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail::driver { + class SequenceSoundPlayer; struct NoteOnInfo { @@ -28,8 +29,9 @@ static_assert(sizeof(NoteOnInfo) == 0x38); class NoteOnCallback { public: virtual ~NoteOnCallback(); - virtual Channel* NoteOn(SequenceSoundPlayer* seqPlayer, u8 bankIndex, + virtual Channel* NoteOn(SequenceSoundPlayer* seqPlayer, u8 bankIndex, const NoteOnInfo& noteOnInfo) = 0; }; static_assert(sizeof(NoteOnCallback) == 0x8); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail::driver diff --git a/include/nn/atk/atk_OutputMixer.h b/include/nn/atk/atk_OutputMixer.h index ebfb5729..9e23d67b 100644 --- a/include/nn/atk/atk_OutputMixer.h +++ b/include/nn/atk/atk_OutputMixer.h @@ -2,18 +2,20 @@ #include -#include #include -#include +#include #include +#include namespace nn::atk { + class OutputMixer : protected OutputReceiver { public: - using EffectList = util::IntrusiveList>; - using EffectAuxList = util::IntrusiveList>; + using EffectAuxList = util::IntrusiveList< + EffectAux, util::IntrusiveListMemberNodeTraits>; OutputMixer(); @@ -21,7 +23,7 @@ class OutputMixer : protected OutputReceiver { void Initialize(s32 bus, bool isEffectEnabled, void* buffer, size_t bufferSize); void Finalize(); - + bool HasEffect(s32 bus) const; bool AppendEffect(EffectBase* pEffect, s32 bus, void* buffer, size_t bufferSize); @@ -29,7 +31,7 @@ class OutputMixer : protected OutputReceiver { bool RemoveEffect(EffectBase* pEffect, s32 bus); bool RemoveEffect(EffectAux* pEffect, s32 bus); - + void ClearEffect(s32 bus); void UpdateEffectAux(); @@ -51,4 +53,5 @@ class OutputMixer : protected OutputReceiver { bool m_IsEffectEnabled; }; static_assert(sizeof(OutputMixer) == 0x40); -} // namespace nn::atk \ No newline at end of file + +} // namespace nn::atk diff --git a/include/nn/atk/atk_OutputReceiver.h b/include/nn/atk/atk_OutputReceiver.h index 1630a728..1c099918 100644 --- a/include/nn/atk/atk_OutputReceiver.h +++ b/include/nn/atk/atk_OutputReceiver.h @@ -3,6 +3,7 @@ #include namespace nn::atk { + class OutputReceiver { public: enum ReceiverType { @@ -17,4 +18,5 @@ class OutputReceiver { virtual bool IsSoundSendClampEnabled(s32 bus) const = 0; }; static_assert(sizeof(OutputReceiver) == 0x8); -} // namespace nn::atk \ No newline at end of file + +} // namespace nn::atk diff --git a/include/nn/atk/atk_PlayerHeap.h b/include/nn/atk/atk_PlayerHeap.h index b7f854b3..c2107292 100644 --- a/include/nn/atk/atk_PlayerHeap.h +++ b/include/nn/atk/atk_PlayerHeap.h @@ -5,9 +5,11 @@ #include namespace nn::atk { + class SoundPlayer; namespace detail { + class PlayerHeap; class CallbackNode { private: @@ -22,8 +24,7 @@ static_assert(sizeof(CallbackNode) == 0x20); class PlayerHeap : SoundMemoryAllocatable { public: using CallbackList = util::IntrusiveList< - CallbackNode, util::IntrusiveListMemberNodeTraits< - CallbackNode, &CallbackNode::m_Link>>; + CallbackNode, util::IntrusiveListMemberNodeTraits>; PlayerHeap(); ~PlayerHeap() override; @@ -31,11 +32,11 @@ class PlayerHeap : SoundMemoryAllocatable { void Destroy(); bool Create(void* startAddress, size_t size); - + void Clear(); void* Allocate(size_t size) override; - void* Allocate(size_t size, SoundMemoryAllocatable::DisposeCallback callback, + void* Allocate(size_t size, SoundMemoryAllocatable::DisposeCallback callback, void* callbackArg) override; size_t GetAllocateSize(size_t size, bool needMemoryPool) override; @@ -54,5 +55,6 @@ class PlayerHeap : SoundMemoryAllocatable { CallbackList m_CallbackList; }; static_assert(sizeof(PlayerHeap) == 0x50); -} // namespace nn::atk::detail -} // namespace nn::atk \ No newline at end of file + +} // namespace detail +} // namespace nn::atk diff --git a/include/nn/atk/atk_PlayerHeapDataManager.h b/include/nn/atk/atk_PlayerHeapDataManager.h index 2f510b7b..1f7f1f07 100644 --- a/include/nn/atk/atk_PlayerHeapDataManager.h +++ b/include/nn/atk/atk_PlayerHeapDataManager.h @@ -1,10 +1,11 @@ #pragma once -#include #include +#include #include namespace nn::atk::detail { + class PlayerHeapDataManager : driver::DisposeCallback, SoundArchiveLoader { public: constexpr static u8 FileAddressCount = 9; @@ -36,4 +37,5 @@ class PlayerHeapDataManager : driver::DisposeCallback, SoundArchiveLoader { bool m_IsFinalized; }; static_assert(sizeof(PlayerHeapDataManager) == 0x2c8); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_ProfileReader.h b/include/nn/atk/atk_ProfileReader.h index 853e6f4f..7c876d70 100644 --- a/include/nn/atk/atk_ProfileReader.h +++ b/include/nn/atk/atk_ProfileReader.h @@ -2,11 +2,12 @@ #include -#include #include +#include #include namespace nn::atk { + struct TimeRange { os::Tick begin; os::Tick end; @@ -71,9 +72,9 @@ static_assert(sizeof(ProfileReader) == 0x10318); static_assert(sizeof(ProfileReader) == 0x1f318); #endif -using ProfileReaderList = util::IntrusiveList>; +using ProfileReaderList = + util::IntrusiveList>; struct TaskProfile; @@ -92,7 +93,9 @@ class AtkProfileReader { }; using SoundThreadUpdateProfileReader = AtkProfileReader; -using SoundThreadUpdateProfileReaderList = util::IntrusiveList>; -} // namespace nn::atk \ No newline at end of file +using SoundThreadUpdateProfileReaderList = util::IntrusiveList< + SoundThreadUpdateProfileReader, + util::IntrusiveListMemberNodeTraits>; + +} // namespace nn::atk diff --git a/include/nn/atk/atk_SequenceSound.h b/include/nn/atk/atk_SequenceSound.h index 771d266e..78d2a1dc 100644 --- a/include/nn/atk/atk_SequenceSound.h +++ b/include/nn/atk/atk_SequenceSound.h @@ -1,10 +1,11 @@ #pragma once #include -#include #include +#include namespace nn::atk::detail { + class SequenceSound; using SequenceSoundInstanceManager = SoundInstanceManager; @@ -37,8 +38,8 @@ class SequenceSound : BasicSound { #endif void Finalize() override; - void Setup(driver::SequenceTrackAllocator* trackAllocator, u32 allocTracks, - driver::NoteOnCallback* noteOnCallback, s32 channelPriority, + void Setup(driver::SequenceTrackAllocator* trackAllocator, u32 allocTracks, + driver::NoteOnCallback* noteOnCallback, s32 channelPriority, bool isReleasePriorityFix, SequenceUserProcCallback userproc, void* userprocArg); void Prepare(const Resource& res, const driver::SequenceSoundPlayer::StartInfo& startInfo); @@ -46,7 +47,7 @@ class SequenceSound : BasicSound { void Skip(driver::SequenceSoundPlayer::StartOffsetType, s32); void SetTempoRatio(f32 tempoRatio); - + void SetChannelPriority(s32 priority); void OnUpdatePlayerPriority() override; @@ -83,7 +84,7 @@ class SequenceSound : BasicSound { bool IsAttachedTempSpecialHandle() override; void DetachTempSpecialHandle() override; - void RegisterDataLoadTask(const driver::SequenceSoundLoader::LoadInfo& loadInfo, + void RegisterDataLoadTask(const driver::SequenceSoundLoader::LoadInfo& loadInfo, const driver::SequenceSoundPlayer::StartInfo& startInfo); bool IsPrepared() const override; @@ -92,7 +93,6 @@ class SequenceSound : BasicSound { void OnUpdateParam() override; - private: friend SequenceSoundInstanceManager; @@ -110,4 +110,5 @@ static_assert(sizeof(SequenceSound) == 0x570); #else static_assert(sizeof(SequenceSound) == 0x5a0); #endif -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_SequenceSoundFile.h b/include/nn/atk/atk_SequenceSoundFile.h index a2e0612c..cc56e894 100644 --- a/include/nn/atk/atk_SequenceSoundFile.h +++ b/include/nn/atk/atk_SequenceSoundFile.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail { + struct SequenceSoundFile { struct DataBlock; struct LabelBlock; @@ -25,13 +26,13 @@ struct SequenceSoundFile { struct LabelInfo; struct LabelBlockBody { Util::ReferenceTable labelInfoReferenceTable; - + int GetLabelCount() const { return labelInfoReferenceTable.count; } - + const LabelInfo* GetLabelInfo(int index) const; const char* GetLabel(int index) const; const char* GetLabelByOffset(u32 offset) const; - + bool GetOffset(int index, u32* offsetPtr) const; bool GetOffsetByLabel(const char* label, u32* offsetPtr) const; }; @@ -48,4 +49,5 @@ struct SequenceSoundFile { }; static_assert(sizeof(LabelInfo) == 0x10); }; -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_SequenceSoundFileReader.h b/include/nn/atk/atk_SequenceSoundFileReader.h index 57bc379a..e1aa9295 100644 --- a/include/nn/atk/atk_SequenceSoundFileReader.h +++ b/include/nn/atk/atk_SequenceSoundFileReader.h @@ -28,4 +28,4 @@ class SequenceSoundFileReader { }; static_assert(sizeof(SequenceSoundFileReader) == 0x18); -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_SequenceSoundHandle.h b/include/nn/atk/atk_SequenceSoundHandle.h index bde9626e..3117edc4 100644 --- a/include/nn/atk/atk_SequenceSoundHandle.h +++ b/include/nn/atk/atk_SequenceSoundHandle.h @@ -6,8 +6,10 @@ namespace nn::atk { namespace detail { + class SequenceSound; -} // namespace nn::atk::detail + +} // namespace detail class SequenceSoundHandle { public: @@ -33,4 +35,5 @@ class SequenceSoundHandle { private: detail::SequenceSound* m_pSound; }; -} // namespace nn::atk \ No newline at end of file + +} // namespace nn::atk diff --git a/include/nn/atk/atk_SequenceSoundPlayer.h b/include/nn/atk/atk_SequenceSoundPlayer.h index 6b25c64f..264d81b1 100644 --- a/include/nn/atk/atk_SequenceSoundPlayer.h +++ b/include/nn/atk/atk_SequenceSoundPlayer.h @@ -1,16 +1,17 @@ #pragma once -#include +#include #include #include #include #include -#include -#include #include +#include #include +#include namespace nn::atk { + struct SequenceUserProcCallbackParam { s16* localVariable; s16* globalVariable; @@ -19,17 +20,18 @@ struct SequenceUserProcCallbackParam { }; static_assert(sizeof(SequenceUserProcCallbackParam) == 0x20); -using SequenceUserProcCallback = void(*)(u16,SequenceUserProcCallbackParam*,void*); +using SequenceUserProcCallback = void (*)(u16, SequenceUserProcCallbackParam*, void*); namespace detail::driver { + class SequenceSoundLoader; using SequenceSoundLoaderManager = LoaderManager; class SequenceSoundLoader { public: struct LoadInfo { - LoadInfo(const SoundArchive* arc, const SoundDataManager* mgr, - LoadItemInfo* seq, LoadItemInfo* banks, SoundPlayer* player); + LoadInfo(const SoundArchive* arc, const SoundDataManager* mgr, LoadItemInfo* seq, + LoadItemInfo* banks, SoundPlayer* player); SoundArchive* soundArchive; SoundDataManager* soundDataManager; @@ -129,11 +131,11 @@ class SequenceSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::Play constexpr static s32 PlayerVariableCount = 16; constexpr static s32 GlobalVariableCount = 16; constexpr static s32 TrackCountPerPlayer = 16; - + constexpr static u32 AllTrackBitFlag = 0x0000FFFF; constexpr static s32 VariableDefaultValue = -1; - + constexpr static s32 DefaultTimebase = 48; constexpr static s32 DefaultTempo = 120; constexpr static u32 DefaultSkipIntervalTick = 16 * DefaultTimebase; @@ -156,7 +158,7 @@ class SequenceSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::Play UpdateType updateType; }; static_assert(sizeof(StartInfo) == 0x18); - + struct PrepareArg { void* seqFile; void* bankFiles[4]; @@ -210,14 +212,14 @@ class SequenceSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::Play void SetChannelPriority(s32 priority); void SetReleasePriorityFix(bool fix); void SetSequenceUserprocCallback(SequenceUserProcCallback callback, void* arg); - + void CallSequenceUserprocCallback(u16 procId, SequenceTrack* track); s16* GetVariablePtr(s32 varNo); void GetLocalVariable(s32 varNo) const; static s16 GetGlobalVariable(s32 varNo); - + void SetLocalVariable(s32 varNo, s16 var); static void SetGlobalVariable(s32 varNo, s16 var); @@ -230,7 +232,7 @@ class SequenceSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::Play bool SetTrackBankIndex(u32 trackBitFlag, s32 bankIndex); void SetTrackTranspose(u32 trackBitFlag, s8 transpose); void SetTrackVelocityRange(u32 trackBitFlag, u8 range); - + void SetTrackOutputLine(u32 trackBitFlag, u32 outputLine); void ResetTrackOutputLine(u32 trackBitFlag); @@ -273,7 +275,7 @@ class SequenceSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::Play static s32 GetSkipIntervalTick(); void ChannelCallback(Channel* channel); - + void OnUpdateFrameSoundThread() override; void OnUpdateFrameSoundThreadWithAudioFrameFrequency() override; void OnShutdownSoundThread() override; @@ -314,5 +316,6 @@ static_assert(sizeof(SequenceSoundPlayer) == 0x358); #else static_assert(sizeof(SequenceSoundPlayer) == 0x368); #endif -} // namespace nn::atk::detail::driver -} // namespace nn::atk \ No newline at end of file + +} // namespace detail::driver +} // namespace nn::atk diff --git a/include/nn/atk/atk_SequenceSoundRuntime.h b/include/nn/atk/atk_SequenceSoundRuntime.h index 77b9991e..b0b8dc39 100644 --- a/include/nn/atk/atk_SequenceSoundRuntime.h +++ b/include/nn/atk/atk_SequenceSoundRuntime.h @@ -1,20 +1,22 @@ #pragma once -#include -#include #include #include #include +#include +#include namespace nn::atk::detail { + class SequenceSoundRuntime { public: class SequenceNoteOnCallback : driver::NoteOnCallback { public: ~SequenceNoteOnCallback() override; - driver::Channel* NoteOn(driver::SequenceSoundPlayer* seqPlayer, u8 bankIndex, + driver::Channel* NoteOn(driver::SequenceSoundPlayer* seqPlayer, u8 bankIndex, const driver::NoteOnInfo& noteOnInfo) override; + private: SequenceSoundRuntime* m_pSequenceSoundRuntime; }; @@ -42,11 +44,12 @@ class SequenceSoundRuntime { void SetupSequenceTrack(s32 trackCount, void** pOutAllocatedAddr, const void* endAddr); void SetupUserParam(void** pOutAllocatedAddr, size_t adjustSize); - static size_t GetRequiredMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, - s32 alignment); - static size_t GetRequiredSequenceTrackMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, - s32 alignment); - + static size_t + GetRequiredMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, + s32 alignment); + static size_t GetRequiredSequenceTrackMemorySize( + const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, s32 alignment); + bool IsSoundArchiveAvailable() const; s32 GetActiveCount() const; @@ -58,48 +61,44 @@ class SequenceSoundRuntime { void Update(); #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) - SequenceSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, + SequenceSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, BasicSound::AmbientInfo* ambientArgInfo); #else - SequenceSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, - BasicSound::AmbientInfo* ambientArgInfo, OutputReceiver* pOutputReceiver); + SequenceSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, + BasicSound::AmbientInfo* ambientArgInfo, + OutputReceiver* pOutputReceiver); #endif - SoundStartable::StartResult PrepareImpl(const SoundArchiveManager::SnapShot& snapShot, - SoundArchive::ItemId soundId, - SequenceSound* sound, - const SoundArchive::SoundInfo* commonInfo, + SoundStartable::StartResult PrepareImpl(const SoundArchiveManager::SnapShot& snapShot, + SoundArchive::ItemId soundId, SequenceSound* sound, + const SoundArchive::SoundInfo* commonInfo, const StartInfoReader& startInfoReader); - SoundStartable::StartResult SetupSequenceSoundInfo(SoundStartable::StartInfo::SequenceSoundInfo* sequenceSoundInfo, - SoundArchive::ItemId soundId, - const SoundArchive& soundArchive, - const SoundStartable::StartInfo::SequenceSoundInfo* pExternalSequenceSoundInfo); - - SoundStartable::StartResult SetupSequenceSoundFile(PrepareContext* pOutContext, - const SequenceSound& sound, - const SoundArchive& soundArchive, - const SoundDataManager& soundDataManager, - const SoundArchive::SoundInfo& commonInfo, - const SoundStartable::StartInfo::SequenceSoundInfo* pExternalSequenceSoundInfo); - - SoundStartable::StartResult SetupBankFileAndWaveArchiveFile(PrepareContext* pOutContext, - const SequenceSound& sound, - const SoundStartable::StartInfo::SequenceSoundInfo& sequenceSoundInfo, - const SoundArchiveManager::SnapShot& snapShot, - const SoundStartable::StartInfo::SequenceSoundInfo* pExternalSequenceSoundInfo); - - void SetupSequenceSoundPlayerStartInfo(SoundStartable::StartInfo* startInfo, - SoundArchive::ItemId soundId, + SoundStartable::StartResult SetupSequenceSoundInfo( + SoundStartable::StartInfo::SequenceSoundInfo* sequenceSoundInfo, + SoundArchive::ItemId soundId, const SoundArchive& soundArchive, + const SoundStartable::StartInfo::SequenceSoundInfo* pExternalSequenceSoundInfo); + + SoundStartable::StartResult SetupSequenceSoundFile( + PrepareContext* pOutContext, const SequenceSound& sound, const SoundArchive& soundArchive, + const SoundDataManager& soundDataManager, const SoundArchive::SoundInfo& commonInfo, + const SoundStartable::StartInfo::SequenceSoundInfo* pExternalSequenceSoundInfo); + + SoundStartable::StartResult SetupBankFileAndWaveArchiveFile( + PrepareContext* pOutContext, const SequenceSound& sound, + const SoundStartable::StartInfo::SequenceSoundInfo& sequenceSoundInfo, + const SoundArchiveManager::SnapShot& snapShot, + const SoundStartable::StartInfo::SequenceSoundInfo* pExternalSequenceSoundInfo); + + void SetupSequenceSoundPlayerStartInfo(SoundStartable::StartInfo* startInfo, + SoundArchive::ItemId soundId, const StartInfoReader& startInfoReader); void DumpMemory(const SoundArchive*) const; - void SetupBankFileAndWaveArchiveFileFromHook(PrepareContext* pOutContext, - SequenceSound* sound, + void SetupBankFileAndWaveArchiveFileFromHook(PrepareContext* pOutContext, SequenceSound* sound, SoundArchive* soundArchive); - private: SequenceSoundInstanceManager m_SequenceSoundInstanceManager; driver::SequenceSoundLoaderManager m_SequenceSoundLoaderManager; @@ -110,11 +109,12 @@ class SequenceSoundRuntime { SequenceUserProcCallback m_SequenceUserProcCallback; void* m_pSequenceUserProcCallbackArg; SoundArchiveManager* m_pSoundArchiveManager; - SoundArchiveFilesHook* m_pSoundArchiveFilesHook; + SoundArchiveFilesHook* m_pSoundArchiveFilesHook; }; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(SequenceSoundRuntime) == 0xe0); #else static_assert(sizeof(SequenceSoundRuntime) == 0xe8); #endif + } // namespace nn::atk::detail diff --git a/include/nn/atk/atk_SequenceTrack.h b/include/nn/atk/atk_SequenceTrack.h index 5bcd0f55..4720c477 100644 --- a/include/nn/atk/atk_SequenceTrack.h +++ b/include/nn/atk/atk_SequenceTrack.h @@ -187,4 +187,4 @@ class SequenceTrack { }; static_assert(sizeof(SequenceTrack) == 0x1e8); -} // namespace nn::atk::detail::driver \ No newline at end of file +} // namespace nn::atk::detail::driver diff --git a/include/nn/atk/atk_SequenceTrackAllocator.h b/include/nn/atk/atk_SequenceTrackAllocator.h index e7d6ca48..e8aa1055 100644 --- a/include/nn/atk/atk_SequenceTrackAllocator.h +++ b/include/nn/atk/atk_SequenceTrackAllocator.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail::driver { + class SequenceSoundPlayer; class SequenceTrackAllocator { @@ -11,4 +12,5 @@ class SequenceTrackAllocator { virtual SequenceTrack* AllocTrack(SequenceSoundPlayer* player) = 0; }; static_assert(sizeof(SequenceTrackAllocator) == 0x8); -} // namespace nn::atk::detail::driver \ No newline at end of file + +} // namespace nn::atk::detail::driver diff --git a/include/nn/atk/atk_SoundActor.h b/include/nn/atk/atk_SoundActor.h index e04c925f..574c995d 100644 --- a/include/nn/atk/atk_SoundActor.h +++ b/include/nn/atk/atk_SoundActor.h @@ -3,6 +3,7 @@ #include namespace nn::atk { + class SoundActor { public: using ActorPlayer = detail::ExternalSoundPlayer; @@ -14,4 +15,4 @@ class SoundActor { ActorPlayer* m_ActorPlayerList; }; -} // namespace nn::atk \ No newline at end of file +} // namespace nn::atk diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index 9bffa115..4eee67e2 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -7,12 +7,15 @@ namespace nn::atk { namespace detail { + class SoundArchiveFileReader; class SoundArchiveParametersHook; struct SoundArchiveFilesHook; namespace driver { + class StreamSoundLoader; + } } // namespace detail @@ -338,4 +341,4 @@ static_assert(sizeof(SoundArchive) == 0x2a0); class AddonSoundArchive : public SoundArchive {}; -} // namespace nn::atk \ No newline at end of file +} // namespace nn::atk diff --git a/include/nn/atk/atk_SoundArchiveFile.h b/include/nn/atk/atk_SoundArchiveFile.h index abb4e05b..ecf3aeae 100644 --- a/include/nn/atk/atk_SoundArchiveFile.h +++ b/include/nn/atk/atk_SoundArchiveFile.h @@ -1,15 +1,16 @@ #pragma once #include -#include #include +#include namespace nn::atk::detail { + class SoundArchiveParametersHook; class SoundArchiveFile { public: - static const int BlockCount {3}; + static const int BlockCount{3}; struct FileHeader : BinaryFileHeader { Util::ReferenceWithSize toBlocks[BlockCount]; @@ -39,20 +40,16 @@ class SoundArchiveFile { Util::Reference toSection[1]; const char* GetString(SoundArchive::StringId stringId) const; - - u32 GetStringCount() const { - return GetStringTable()->GetCount(); - } - u32 GetItemId(const char* str) const { - return GetItemIdImpl(Sections_PatriciaTree, str); - } + u32 GetStringCount() const { return GetStringTable()->GetCount(); } + + u32 GetItemId(const char* str) const { return GetItemIdImpl(Sections_PatriciaTree, str); } void DumpTree() const; - + private: const void* GetSection(Sections section) const; - + const StringTable* GetStringTable() const { return util::ConstBytePtr(GetSection(Sections_StringTable)).Get(); } @@ -75,7 +72,7 @@ class SoundArchiveFile { static_assert(sizeof(NodeData) == 0x8); struct Node { - static const u16 FlagLeaf {1 << 0}; + static const u16 FlagLeaf{1 << 0}; u16 flags; u16 bit; @@ -109,7 +106,7 @@ class SoundArchiveFile { // TODO return nullptr; } - + u32 GetDataCount() const; u32 GetCount() const; }; @@ -126,9 +123,7 @@ class SoundArchiveFile { return util::ConstBytePtr(this, table.item[stringId].offset).Get(); } - u32 GetCount() const { - return table.count; - } + u32 GetCount() const { return table.count; } }; struct SoundInfo; @@ -164,7 +159,7 @@ class SoundArchiveFile { const GroupInfo* GetGroupInfo(SoundArchive::ItemId itemId) const; const WaveArchiveInfo* GetWaveArchiveInfo(SoundArchive::ItemId itemId) const; const FileInfo* GetFileInfo(SoundArchive::FileId itemId) const; - + const SoundArchivePlayerInfo* GetSoundArchivePlayerInfo() const; SoundArchive::FileId GetItemFileId(SoundArchive::ItemId id) const; @@ -229,13 +224,12 @@ class SoundArchiveFile { Util::ReferenceTable table; const StreamTrackInfo* GetTrackInfo(u32 index) { - return util::ConstBytePtr(table.GetReferedItem(ElementType_SoundArchiveFile_StreamSoundTrackInfo, index)) - .Get(); - } - - u32 GetTrackCount() const { - return table.count; + return util::ConstBytePtr(table.GetReferedItem( + ElementType_SoundArchiveFile_StreamSoundTrackInfo, index)) + .Get(); } + + u32 GetTrackCount() const { return table.count; } }; struct SendValue { @@ -256,22 +250,19 @@ class SoundArchiveFile { u8 biquadValue; u8 padding[1]; - u32 GetTrackChannelCount() const { - return GetGlobalChannelIndexTable().GetCount(); - } + u32 GetTrackChannelCount() const { return GetGlobalChannelIndexTable().GetCount(); } u8 GetGlobalChannelIndex(u32 index) const { return GetGlobalChannelIndexTable().GetGlobalIndex(index); } const SendValue& GetSendValue() const { - return *util::ConstBytePtr(this, toSendValue.offset) - .Get(); + return *util::ConstBytePtr(this, toSendValue.offset).Get(); } const StreamSoundFile::GlobalChannelIndexTable& GetGlobalChannelIndexTable() const { return *util::ConstBytePtr(this, toGlobalChannelIndexTable.offset) - .Get(); + .Get(); } }; static_assert(sizeof(StreamTrackInfo) == 0x18); @@ -292,9 +283,7 @@ class SoundArchiveFile { } } - bool IsLoop() const { - return Util::DivideBy8bit(streamTypeInfo, 1) != 0; - } + bool IsLoop() const { return Util::DivideBy8bit(streamTypeInfo, 1) != 0; } SoundArchive::DecodeMode GetDecodeMode() const { switch (Util::DivideBy8bit(streamTypeInfo, 2)) { @@ -374,7 +363,7 @@ class SoundArchiveFile { const Util::Table* GetWaveArchiveItemIdTable() const { return util::ConstBytePtr(this, toWaveArchiveItemIdTable.offset) - .Get>(); + .Get>(); } }; static_assert(sizeof(BankInfo) == 0x10); @@ -400,12 +389,12 @@ class SoundArchiveFile { const Util::Table* GetFileIdTable() const { return util::ConstBytePtr(this, toFileIdTable.offset) - .Get>(); + .Get>(); } const WaveSoundGroupInfo* GetWaveSoundGroupInfo() const { return util::ConstBytePtr(this, toDetailSoundGroupInfo.offset) - .Get(); + .Get(); } }; static_assert(sizeof(SoundGroupInfo) == 0x1c); @@ -416,7 +405,7 @@ class SoundArchiveFile { const Util::Table* GetWaveArchiveItemIdTable() const { return util::ConstBytePtr(this, toWaveArchiveItemIdTable.offset) - .Get>(); + .Get>(); } }; static_assert(sizeof(WaveSoundGroupInfo) == 0xc); @@ -459,23 +448,18 @@ class SoundArchiveFile { static_assert(sizeof(FileInfo) == 0xc); struct InternalFileInfo { - static const u32 InvalidOffset {0xffffffff}; - static const u32 InvalidSize {0xffffffff}; + static const u32 InvalidOffset{0xffffffff}; + static const u32 InvalidSize{0xffffffff}; Util::ReferenceWithSize toFileImageFromFileBlockBody; Util::Reference toAttachedGroupIdTable; - u32 GetFileSize() const { - return toFileImageFromFileBlockBody.size; - } + u32 GetFileSize() const { return toFileImageFromFileBlockBody.size; } - u32 GetOffsetFromFileBlockHead() const { - return toFileImageFromFileBlockBody.offset; - } + u32 GetOffsetFromFileBlockHead() const { return toFileImageFromFileBlockBody.offset; } const Util::Table* GetAttachedGroupTable() const { - return util::ConstBytePtr(this, toAttachedGroupIdTable.offset) - .Get>(); + return util::ConstBytePtr(this, toAttachedGroupIdTable.offset).Get>(); } }; static_assert(sizeof(InternalFileInfo) == 0x14); @@ -500,4 +484,5 @@ class SoundArchiveFile { struct FileBlock {}; }; -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_SoundArchiveFileReader.h b/include/nn/atk/atk_SoundArchiveFileReader.h index 404556e2..586022de 100644 --- a/include/nn/atk/atk_SoundArchiveFileReader.h +++ b/include/nn/atk/atk_SoundArchiveFileReader.h @@ -4,9 +4,10 @@ #include namespace nn::atk::detail { + class SoundArchiveFileReader { public: - constexpr static s32 SignatureFile = 0x52415346; // FSAR + constexpr static s32 SignatureFile = 0x52415346; // FSAR constexpr static s32 InvalidOffset = -1; constexpr static s32 InvalidSize = -1; @@ -44,17 +45,23 @@ class SoundArchiveFileReader { bool ReadSoundInfo(SoundArchive::ItemId soundId, SoundArchive::SoundInfo* info) const; bool ReadBankInfo(SoundArchive::ItemId bankId, SoundArchive::BankInfo* info) const; bool ReadPlayerInfo(SoundArchive::ItemId playerId, SoundArchive::PlayerInfo* info) const; - bool ReadSoundGroupInfo(SoundArchive::ItemId soundGroupId, SoundArchive::SoundGroupInfo* info) const; + bool ReadSoundGroupInfo(SoundArchive::ItemId soundGroupId, + SoundArchive::SoundGroupInfo* info) const; bool ReadGroupInfo(SoundArchive::ItemId groupId, SoundArchive::GroupInfo* info) const; bool ReadFileInfo(SoundArchive::FileId id, SoundArchive::FileInfo* info, s32 index) const; - bool ReadWaveArchiveInfo(SoundArchive::ItemId warcId, SoundArchive::WaveArchiveInfo* info) const; + bool ReadWaveArchiveInfo(SoundArchive::ItemId warcId, + SoundArchive::WaveArchiveInfo* info) const; bool ReadSoundArchivePlayerInfo(SoundArchive::SoundArchivePlayerInfo* info) const; bool ReadSound3DInfo(SoundArchive::ItemId soundId, SoundArchive::Sound3DInfo* info) const; - bool ReadSequenceSoundInfo(SoundArchive::ItemId soundId, SoundArchive::SequenceSoundInfo* info) const; - bool ReadStreamSoundInfo(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo* info) const; - bool ReadStreamSoundInfo2(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo2* info) const; + bool ReadSequenceSoundInfo(SoundArchive::ItemId soundId, + SoundArchive::SequenceSoundInfo* info) const; + bool ReadStreamSoundInfo(SoundArchive::ItemId soundId, + SoundArchive::StreamSoundInfo* info) const; + bool ReadStreamSoundInfo2(SoundArchive::ItemId soundId, + SoundArchive::StreamSoundInfo2* info) const; bool ReadWaveSoundInfo(SoundArchive::ItemId soundId, SoundArchive::WaveSoundInfo* info) const; - bool ReadAdvancedWaveSoundInfo(SoundArchive::ItemId soundId, SoundArchive::AdvancedWaveSoundInfo* info) const; + bool ReadAdvancedWaveSoundInfo(SoundArchive::ItemId soundId, + SoundArchive::AdvancedWaveSoundInfo* info) const; Util::Table* GetWaveArchiveIdTable(SoundArchive::ItemId id) const; SoundArchive::SoundType GetSoundType(SoundArchive::ItemId soundId) const; @@ -81,4 +88,5 @@ class SoundArchiveFileReader { SoundArchiveFile::FileBlock* m_pFileBlock; #endif }; -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_SoundArchiveFilesHook.h b/include/nn/atk/atk_SoundArchiveFilesHook.h index 0c1d94ea..ba22c263 100644 --- a/include/nn/atk/atk_SoundArchiveFilesHook.h +++ b/include/nn/atk/atk_SoundArchiveFilesHook.h @@ -1,9 +1,10 @@ #pragma once -#include #include +#include namespace nn::atk::detail { + class SoundArchiveFilesHook { public: constexpr static const char ItemTypeWaveSound[] = "wsd"; @@ -25,11 +26,15 @@ class SoundArchiveFilesHook { void Lock(); void Unlock(); - fnd::FileStream* OpenFile(void* buffer, size_t bufferLength, void* cacheBuffer, size_t cacheBufferLength, const char* itemLabel, const char* fileType); + fnd::FileStream* OpenFile(void* buffer, size_t bufferLength, void* cacheBuffer, + size_t cacheBufferLength, const char* itemLabel, + const char* fileType); - const void* GetFileAddress(const char* itemLabel, const char* itemType, const char* fileType, u32 fileIndex); + const void* GetFileAddress(const char* itemLabel, const char* itemType, const char* fileType, + u32 fileIndex); private: bool m_IsEnable; }; -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_SoundArchiveLoader.h b/include/nn/atk/atk_SoundArchiveLoader.h index 8ae5b3a6..6af6a475 100644 --- a/include/nn/atk/atk_SoundArchiveLoader.h +++ b/include/nn/atk/atk_SoundArchiveLoader.h @@ -4,6 +4,7 @@ #include namespace nn::atk::detail { + struct LoadItemInfo { SoundArchive::ItemId itemId; const void* address; @@ -20,7 +21,7 @@ class SoundArchiveLoader { LoadFlag_Warc = 8, }; - constexpr static s32 SignatureIndividualWave = 0x56574946; // FWIV + constexpr static s32 SignatureIndividualWave = 0x56574946; // FWIV constexpr static u8 WaveBufferAlignSize = 64; struct IndividualWaveInfo { @@ -34,7 +35,7 @@ class SoundArchiveLoader { SoundArchiveLoader(); virtual ~SoundArchiveLoader(); - + virtual void* SetFileAddressToTable(SoundArchive::FileId fileId, const void* address) = 0; virtual void* GetFileAddressFromTable(SoundArchive::FileId fileId) const = 0; virtual void* GetFileAddressImpl(SoundArchive::FileId fileId) const = 0; @@ -43,52 +44,52 @@ class SoundArchiveLoader { bool IsAvailable() const; - bool LoadData(SoundArchive::ItemId itemId, SoundMemoryAllocatable* pAllocator, - u32 loadFlag, size_t loadBlockSize); - bool LoadSequenceSound(SoundArchive::ItemId soundId, SoundMemoryAllocatable* pAllocator, + bool LoadData(SoundArchive::ItemId itemId, SoundMemoryAllocatable* pAllocator, u32 loadFlag, + size_t loadBlockSize); + bool LoadSequenceSound(SoundArchive::ItemId soundId, SoundMemoryAllocatable* pAllocator, u32 loadFlag, size_t loadBlockSize); - bool LoadAdvancedWaveSound(SoundArchive::ItemId soundId, SoundMemoryAllocatable* pAllocator, + bool LoadAdvancedWaveSound(SoundArchive::ItemId soundId, SoundMemoryAllocatable* pAllocator, u32 loadFlag, size_t loadBlockSize); - bool LoadWaveSound(SoundArchive::ItemId soundId, SoundMemoryAllocatable* pAllocator, + bool LoadWaveSound(SoundArchive::ItemId soundId, SoundMemoryAllocatable* pAllocator, u32 loadFlag, size_t loadBlockSize, SoundArchive::ItemId waveSoundSetId); - bool LoadStreamSoundPrefetch(SoundArchive::ItemId soundId, SoundMemoryAllocatable* pAllocator, + bool LoadStreamSoundPrefetch(SoundArchive::ItemId soundId, SoundMemoryAllocatable* pAllocator, size_t loadBlockSize); - bool LoadBank(SoundArchive::ItemId bankId, SoundMemoryAllocatable* pAllocator, - u32 loadFlag, size_t loadBlockSize); - bool LoadWaveArchive(SoundArchive::ItemId bankId, SoundMemoryAllocatable* pAllocator, + bool LoadBank(SoundArchive::ItemId bankId, SoundMemoryAllocatable* pAllocator, u32 loadFlag, + size_t loadBlockSize); + bool LoadWaveArchive(SoundArchive::ItemId bankId, SoundMemoryAllocatable* pAllocator, u32 loadFlag, size_t loadBlockSize); - bool LoadGroup(SoundArchive::ItemId soundGroupId, SoundMemoryAllocatable* pAllocator, + bool LoadGroup(SoundArchive::ItemId soundGroupId, SoundMemoryAllocatable* pAllocator, size_t loadBlockSize); - bool LoadSoundGroup(SoundArchive::ItemId soundGroupId, SoundMemoryAllocatable* pAllocator, + bool LoadSoundGroup(SoundArchive::ItemId soundGroupId, SoundMemoryAllocatable* pAllocator, u32 loadFlag, size_t loadBlockSize); - bool LoadData(char* pItemName, SoundMemoryAllocatable* pAllocator, - u32 loadFlag, size_t loadBlockSize); - void* LoadImpl(SoundArchive::FileId fileId, SoundMemoryAllocatable* pAllocator, + bool LoadData(char* pItemName, SoundMemoryAllocatable* pAllocator, u32 loadFlag, + size_t loadBlockSize); + void* LoadImpl(SoundArchive::FileId fileId, SoundMemoryAllocatable* pAllocator, size_t loadBlockSize, bool needMemoryPool); - void* LoadFile(SoundArchive::FileId fileId, SoundMemoryAllocatable* pAllocator, + void* LoadFile(SoundArchive::FileId fileId, SoundMemoryAllocatable* pAllocator, size_t loadBlockSize, bool needMemoryPool); - void* LoadWaveArchiveImpl(SoundArchive::ItemId warcId, SoundMemoryAllocatable* pAllocator, + void* LoadWaveArchiveImpl(SoundArchive::ItemId warcId, SoundMemoryAllocatable* pAllocator, size_t loadBlockSize, bool needMemoryPool); - bool LoadIndividualWave(SoundArchive::ItemId warcId, u32 waveIndex, SoundMemoryAllocatable* pAllocator, - size_t loadBlockSize); - void* LoadWaveArchiveTable(SoundArchive::ItemId warcId, SoundMemoryAllocatable* pAllocator, + bool LoadIndividualWave(SoundArchive::ItemId warcId, u32 waveIndex, + SoundMemoryAllocatable* pAllocator, size_t loadBlockSize); + void* LoadWaveArchiveTable(SoundArchive::ItemId warcId, SoundMemoryAllocatable* pAllocator, size_t loadBlockSize); - size_t ReadFile(SoundArchive::FileId fileId, void* buffer, size_t size, s32 offset, + size_t ReadFile(SoundArchive::FileId fileId, void* buffer, size_t size, s32 offset, size_t loadBlockSize); bool PostProcessForLoadedGroupFile(void* pGroupFile, SoundMemoryAllocatable* pAllocator, size_t loadBlockSize); - void SetWaveArchiveTableWithSeqInEmbeddedGroup(SoundArchive::ItemId seqId, - SoundMemoryAllocatable* pAllocator); - void SetWaveArchiveTableWithBankInEmbeddedGroup(SoundArchive::ItemId bankId, + void SetWaveArchiveTableWithSeqInEmbeddedGroup(SoundArchive::ItemId seqId, SoundMemoryAllocatable* pAllocator); - void SetWaveArchiveTableWithWsdInEmbeddedGroup(SoundArchive::ItemId wsdId, + void SetWaveArchiveTableWithBankInEmbeddedGroup(SoundArchive::ItemId bankId, + SoundMemoryAllocatable* pAllocator); + void SetWaveArchiveTableWithWsdInEmbeddedGroup(SoundArchive::ItemId wsdId, SoundMemoryAllocatable* pAllocator); - void SetWaveArchiveTableInEmbeddedGroupImpl(SoundArchive::ItemId warcId, + void SetWaveArchiveTableInEmbeddedGroupImpl(SoundArchive::ItemId warcId, SoundMemoryAllocatable* pAllocator); bool IsDataLoaded(const char*, u32) const; @@ -102,12 +103,11 @@ class SoundArchiveLoader { bool IsSoundGroupDataLoaded(u32, u32) const; void* GetFileAddressFromSoundArchive(SoundArchive::FileId fileId) const; - + void* detail_GetFileAddressByItemId(SoundArchive::ItemId itemId) const; - - bool detail_LoadWaveArchiveByBankFile(void* bankFile, - SoundMemoryAllocatable* pAllocator); - bool detail_LoadWaveArchiveByWaveSoundFile(void* wsdFile, s32 wsdIndex, + + bool detail_LoadWaveArchiveByBankFile(void* bankFile, SoundMemoryAllocatable* pAllocator); + bool detail_LoadWaveArchiveByWaveSoundFile(void* wsdFile, s32 wsdIndex, SoundMemoryAllocatable* pAllocator); private: @@ -117,4 +117,5 @@ class SoundArchiveLoader { bool m_IsCancelLoading; }; static_assert(sizeof(SoundArchiveLoader) == 0x218); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_SoundArchiveParametersHook.h b/include/nn/atk/atk_SoundArchiveParametersHook.h index 4edbbc8d..c070cb1b 100644 --- a/include/nn/atk/atk_SoundArchiveParametersHook.h +++ b/include/nn/atk/atk_SoundArchiveParametersHook.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail { + class SoundArchiveParametersHook { public: bool GetIsEnable() const { return m_IsEnable; } @@ -50,7 +51,8 @@ class SoundArchiveParametersHook { return false; } - bool ReadSoundGroupInfo(SoundArchive::ItemId soundGroupId, SoundArchive::SoundGroupInfo* info) const { + bool ReadSoundGroupInfo(SoundArchive::ItemId soundGroupId, + SoundArchive::SoundGroupInfo* info) const { if (m_IsEnable) return ReadSoundGroupInfoImpl(soundGroupId, info); @@ -70,7 +72,7 @@ class SoundArchiveParametersHook { return false; } - + bool ReadSoundArchivePlayerInfo(SoundArchive::SoundArchivePlayerInfo* info) const { if (m_IsEnable) return ReadSoundArchivePlayerInfoImpl(info); @@ -85,28 +87,32 @@ class SoundArchiveParametersHook { return false; } - bool ReadWaveArchiveInfo(SoundArchive::ItemId warcId, SoundArchive::WaveArchiveInfo* info) const { + bool ReadWaveArchiveInfo(SoundArchive::ItemId warcId, + SoundArchive::WaveArchiveInfo* info) const { if (m_IsEnable) return ReadWaveArchiveInfoImpl(warcId, info); return false; } - - bool ReadSequenceSoundInfo(SoundArchive::ItemId soundId, SoundArchive::SequenceSoundInfo* info) const { + + bool ReadSequenceSoundInfo(SoundArchive::ItemId soundId, + SoundArchive::SequenceSoundInfo* info) const { if (m_IsEnable) return ReadSequenceSoundInfoImpl(soundId, info); return false; } - bool ReadStreamSoundInfo(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo* info) const { + bool ReadStreamSoundInfo(SoundArchive::ItemId soundId, + SoundArchive::StreamSoundInfo* info) const { if (m_IsEnable) return ReadStreamSoundInfoImpl(soundId, info); return false; } - bool ReadStreamSoundInfo2(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo2* info) const { + bool ReadStreamSoundInfo2(SoundArchive::ItemId soundId, + SoundArchive::StreamSoundInfo2* info) const { if (m_IsEnable) return ReadStreamSoundInfo2Impl(soundId, info); @@ -119,7 +125,7 @@ class SoundArchiveParametersHook { return false; } - + bool ReadSoundUserParam(u32* pOutValue, SoundArchive::ItemId soundId, int index) const { if (m_IsEnable) return ReadSoundUserParamImpl(pOutValue, soundId, index); @@ -138,23 +144,36 @@ class SoundArchiveParametersHook { virtual const char* GetItemLabelImpl(SoundArchive::ItemId id) const; virtual SoundArchive::ItemId GetItemIdImpl(const char* itemLabel) const; virtual SoundArchive::SoundType GetSoundTypeImpl(const char* itemLabel) const; - virtual bool ReadSoundInfoImpl(SoundArchive::ItemId soundId, SoundArchive::SoundInfo* info) const; + virtual bool ReadSoundInfoImpl(SoundArchive::ItemId soundId, + SoundArchive::SoundInfo* info) const; virtual bool ReadBankInfoImpl(SoundArchive::ItemId bankId, SoundArchive::BankInfo* info) const; - virtual bool ReadPlayerInfoImpl(SoundArchive::ItemId playerId, SoundArchive::PlayerInfo* info) const; - virtual bool ReadSoundGroupInfoImpl(SoundArchive::ItemId soundGroupId, SoundArchive::SoundGroupInfo* info) const; - virtual bool ReadGroupInfoImpl(SoundArchive::ItemId groupId, SoundArchive::GroupInfo* info) const; - virtual bool ReadWaveArchiveInfoImpl(SoundArchive::ItemId warcId, SoundArchive::WaveArchiveInfo* info) const; - virtual bool ReadFileInfoImpl(SoundArchive::FileId id, SoundArchive::FileInfo* info, int index) const; + virtual bool ReadPlayerInfoImpl(SoundArchive::ItemId playerId, + SoundArchive::PlayerInfo* info) const; + virtual bool ReadSoundGroupInfoImpl(SoundArchive::ItemId soundGroupId, + SoundArchive::SoundGroupInfo* info) const; + virtual bool ReadGroupInfoImpl(SoundArchive::ItemId groupId, + SoundArchive::GroupInfo* info) const; + virtual bool ReadWaveArchiveInfoImpl(SoundArchive::ItemId warcId, + SoundArchive::WaveArchiveInfo* info) const; + virtual bool ReadFileInfoImpl(SoundArchive::FileId id, SoundArchive::FileInfo* info, + int index) const; virtual bool ReadSoundArchivePlayerInfoImpl(SoundArchive::SoundArchivePlayerInfo* info) const; - virtual bool ReadSound3DInfoImpl(SoundArchive::ItemId soundId, SoundArchive::Sound3DInfo* info) const; - virtual bool ReadSequenceSoundInfoImpl(SoundArchive::ItemId soundId, SoundArchive::SequenceSoundInfo* info) const; - virtual bool ReadStreamSoundInfoImpl(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo* info) const; - virtual bool ReadStreamSoundInfo2Impl(SoundArchive::ItemId soundId, SoundArchive::StreamSoundInfo2* info) const; - virtual bool ReadWaveSoundInfoImpl(SoundArchive::ItemId soundId, SoundArchive::WaveSoundInfo* info) const; - virtual bool ReadSoundUserParamImpl(u32* pOutValue, SoundArchive::ItemId soundId, int index) const; + virtual bool ReadSound3DInfoImpl(SoundArchive::ItemId soundId, + SoundArchive::Sound3DInfo* info) const; + virtual bool ReadSequenceSoundInfoImpl(SoundArchive::ItemId soundId, + SoundArchive::SequenceSoundInfo* info) const; + virtual bool ReadStreamSoundInfoImpl(SoundArchive::ItemId soundId, + SoundArchive::StreamSoundInfo* info) const; + virtual bool ReadStreamSoundInfo2Impl(SoundArchive::ItemId soundId, + SoundArchive::StreamSoundInfo2* info) const; + virtual bool ReadWaveSoundInfoImpl(SoundArchive::ItemId soundId, + SoundArchive::WaveSoundInfo* info) const; + virtual bool ReadSoundUserParamImpl(u32* pOutValue, SoundArchive::ItemId soundId, + int index) const; virtual u32 GetSoundUserParamImpl(SoundArchive::ItemId soundId, u32 userParam) const; private: bool m_IsEnable; }; -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_SoundArchivePlayer.h b/include/nn/atk/atk_SoundArchivePlayer.h index b0623b5a..41ca66ed 100644 --- a/include/nn/atk/atk_SoundArchivePlayer.h +++ b/include/nn/atk/atk_SoundArchivePlayer.h @@ -2,12 +2,13 @@ #include -#include #include #include #include +#include namespace nn::atk { + class SoundArchivePlayer : SoundStartable { public: constexpr static u32 BufferAlignSize = 4096; @@ -43,8 +44,8 @@ class SoundArchivePlayer : SoundStartable { bool IsAvailable() const; - bool Initialize(const SoundArchive* arc, const SoundDataManager* manager, void* buffer, - size_t size, void* strmBuffer, size_t strmBufferSize, + bool Initialize(const SoundArchive* arc, const SoundDataManager* manager, void* buffer, + size_t size, void* strmBuffer, size_t strmBufferSize, size_t userParamSizePerSound); bool Initialize(const InitializeParam& param); @@ -55,8 +56,8 @@ class SoundArchivePlayer : SoundStartable { void DisposeInstances(); static size_t GetRequiredMemSize(const SoundArchive* arc); - static size_t GetRequiredMemSize(const SoundArchive* arc, size_t userParamSizePerSound, - s32 addonSoundArchiveCount); + static size_t GetRequiredMemSize(const SoundArchive* arc, size_t userParamSizePerSound, + s32 addonSoundArchiveCount); static size_t GetRequiredMemSize(const SoundArchive* arc, size_t userParamSizePerSound); static size_t GetRequiredMemSize(const InitializeParam& param); @@ -64,25 +65,25 @@ class SoundArchivePlayer : SoundStartable { size_t GetRequiredStreamBufferSize(const SoundArchive* arc) const; size_t GetRequiredStreamBufferTimes(const SoundArchive* arc) const; - - static size_t GetRequiredStreamCacheSize(const SoundArchive* arc, size_t); + static size_t GetRequiredStreamCacheSize(const SoundArchive* arc, size_t); - bool SetupMram(const SoundArchive* pArc, void* buffer, size_t size, - size_t userParamSizePerSound, s32 addonSoundArchiveCount, + bool SetupMram(const SoundArchive* pArc, void* buffer, size_t size, + size_t userParamSizePerSound, s32 addonSoundArchiveCount, void* streamSoundInstanceBuffer, size_t streamSoundInstanceBufferSize); bool SetupSoundPlayer(const SoundArchive* pArc, void** pOutAllocatedAddr, const void* endAddr); - bool SetupAddonSoundArchiveContainer(s32 containerCount, void** pOutAllocatedAddr, const void* endAddr); - bool SetupUserParamForBasicSound(const SoundArchive::SoundArchivePlayerInfo& playerInfo, + bool SetupAddonSoundArchiveContainer(s32 containerCount, void** pOutAllocatedAddr, + const void* endAddr); + bool SetupUserParamForBasicSound(const SoundArchive::SoundArchivePlayerInfo& playerInfo, void** pOutAllocatedAddr, const void* endAddr, size_t); detail::PlayerHeap* CreatePlayerHeap(void** pOutAllocatedAddr, const void* endAddr, size_t); void Update(); - + SoundPlayer* GetSoundPlayer(u32); - + SoundArchive* GetSoundArchive() const; AddonSoundArchive* GetAddonSoundArchive(const char*) const; AddonSoundArchive* GetAddonSoundArchive(s32) const; @@ -104,11 +105,12 @@ class SoundArchivePlayer : SoundStartable { #endif StartResult detail_SetupSound(SoundHandle* handle, u32 soundId, bool holdFlag, - const char* soundArchiveName, const StartInfo* startInfo) override; - StartResult detail_SetupSoundImpl(SoundHandle* handle, u32 soundId, + const char* soundArchiveName, + const StartInfo* startInfo) override; + StartResult detail_SetupSoundImpl(SoundHandle* handle, u32 soundId, detail::BasicSound::AmbientInfo* ambientArgInfo, - SoundActor* actor, bool holdFlag, const char* soundArchiveName, - const StartInfo* startInfo); + SoundActor* actor, bool holdFlag, + const char* soundArchiveName, const StartInfo* startInfo); bool IsSoundArchiveFileHooksEnabled() const; @@ -120,7 +122,7 @@ class SoundArchivePlayer : SoundStartable { void EnableHook(const SoundArchive*, bool); - StartResult PreprocessSinglePlay(const SoundArchive::SoundInfo& info, u32 soundId, + StartResult PreprocessSinglePlay(const SoundArchive::SoundInfo& info, u32 soundId, SoundPlayer& player); void SetCommonSoundParam(detail::BasicSound* pSound, const SoundArchive::SoundInfo* info); @@ -133,7 +135,7 @@ class SoundArchivePlayer : SoundStartable { static s32 GetSequenceSkipIntervalTick(); Result ReadWaveSoundDataInfo(detail::WaveSoundDataInfo*, u32, const SoundArchive*, - const SoundDataManager*) const; + const SoundDataManager*) const; Result ReadWaveSoundDataInfo(detail::WaveSoundDataInfo*, u32, const char*) const; Result ReadWaveSoundDataInfo(detail::WaveSoundDataInfo*, const char*, const char*) const; Result ReadWaveSoundDataInfo(detail::WaveSoundDataInfo*, u32) const; @@ -147,29 +149,27 @@ class SoundArchivePlayer : SoundStartable { static size_t GetRequiredWorkBufferSizeToReadStreamSoundHeader(); - Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, u32, - const char* const*, s32, const SoundArchive*, - void*, size_t) const; + Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, u32, + const char* const*, s32, const SoundArchive*, void*, + size_t) const; Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, u32, const char*, void*, size_t) const; - Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, u32, - const char* const*, s32, void*, size_t, - const char*) const; - Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, const char*, + Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, u32, + const char* const*, s32, void*, size_t, const char*) const; + Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, const char*, const char*, void*, size_t) const; - Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, const char*, - const char* const*, s32, void*, size_t, - const char*) const; - Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, u32, + Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, const char*, + const char* const*, s32, void*, size_t, const char*) const; + Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, u32, const char* const*, s32, void*, size_t) const; - Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, const char*, + Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, const char*, const char* const*, s32, void*, size_t) const; - Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, const char*, - const char*, void*, size_t, + Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, const char*, + const char*, void*, size_t, const char* soundArchiveName) const; - Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, u32, const char*, + Result ReadStreamSoundRegionDataInfo(detail::StreamSoundRegionDataInfo*, u32, const char*, void*, size_t, const char* soundArchiveName) const; - + void DumpMemory() const; bool ReadStreamSoundInstanceState(StreamSoundInstanceState*) const; @@ -179,7 +179,7 @@ class SoundArchivePlayer : SoundStartable { Result CheckStreamSoundFileExisting(char* streamSoundName) const; Result CheckStreamSoundFileExisting(const char*, const char*) const; Result CheckStreamSoundFileExisting(const SoundArchive*, u32) const; - + SoundArchive::ItemId detail_GetItemId(char* pString) override; SoundArchive::ItemId detail_GetItemId(char* pString, const char* soundArchiveName) override; @@ -213,4 +213,5 @@ static_assert(sizeof(SoundArchivePlayer) == 0x2e0); #else static_assert(sizeof(SoundArchivePlayer) == 0x310); #endif + } // namespace nn::atk diff --git a/include/nn/atk/atk_SoundDataManager.h b/include/nn/atk/atk_SoundDataManager.h index 95355fe6..087c7886 100644 --- a/include/nn/atk/atk_SoundDataManager.h +++ b/include/nn/atk/atk_SoundDataManager.h @@ -7,8 +7,10 @@ namespace nn::atk { namespace detail { + class SoundFileManager; -} // namespace nn::atk::detail + +} // namespace detail class SoundDataManager : detail::driver::DisposeCallback, detail::SoundArchiveLoader { public: @@ -26,9 +28,9 @@ class SoundDataManager : detail::driver::DisposeCallback, detail::SoundArchiveLo size_t GetRequiredMemSize(const SoundArchive* arc) const; bool Initialize(const SoundArchive* pArchive, void* buffer, size_t size); - + bool CreateTables(void**, const SoundArchive* pArchive, void*); - + void Finalize(); void InvalidateData(const void* start, const void* end) override; @@ -53,4 +55,5 @@ class SoundDataManager : detail::driver::DisposeCallback, detail::SoundArchiveLo detail::SoundFileManager* m_pFileManager; }; static_assert(sizeof(SoundDataManager) == 0x240); + } // namespace nn::atk diff --git a/include/nn/atk/atk_SoundHandle.h b/include/nn/atk/atk_SoundHandle.h index a10b329b..19b82b27 100644 --- a/include/nn/atk/atk_SoundHandle.h +++ b/include/nn/atk/atk_SoundHandle.h @@ -3,6 +3,7 @@ #include namespace nn::atk { + class SoundHandle { public: enum MuteState { @@ -36,4 +37,5 @@ class SoundHandle { detail::BasicSound* m_pSound; }; static_assert(sizeof(SoundHandle) == 0x8); -} // namespace nn::atk \ No newline at end of file + +} // namespace nn::atk diff --git a/include/nn/atk/atk_SoundHeap.h b/include/nn/atk/atk_SoundHeap.h index 1375705b..9e28fa3f 100644 --- a/include/nn/atk/atk_SoundHeap.h +++ b/include/nn/atk/atk_SoundHeap.h @@ -3,11 +3,12 @@ #include #include -#include #include +#include #include -namespace nn::atk::detail { +namespace nn::atk { + class SoundHeap : SoundMemoryAllocatable { public: SoundHeap(); @@ -24,8 +25,7 @@ class SoundHeap : SoundMemoryAllocatable { static void DisposeCallbackFunc(void* mem, size_t size, void* arg); - void* Allocate(size_t size, - SoundMemoryAllocatable::DisposeCallback heapCallback, + void* Allocate(size_t size, SoundMemoryAllocatable::DisposeCallback heapCallback, void* heapCallbackArg) override; size_t GetAllocateSize(size_t size, bool needMemoryPool) override; @@ -34,10 +34,11 @@ class SoundHeap : SoundMemoryAllocatable { void LoadState(s32 state); private: - fnd::CriticalSection m_CriticalSection; - FrameHeap m_FrameHeap; + detail::fnd::CriticalSection m_CriticalSection; + detail::FrameHeap m_FrameHeap; audio::MemoryPoolType m_MemoryPool; bool m_IsAutoMemoryPoolManagementEnabled; }; static_assert(sizeof(SoundHeap) == 0x50); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_SoundInstanceManager.h b/include/nn/atk/atk_SoundInstanceManager.h index 351432c7..27861253 100644 --- a/include/nn/atk/atk_SoundInstanceManager.h +++ b/include/nn/atk/atk_SoundInstanceManager.h @@ -7,11 +7,12 @@ #include namespace nn::atk::detail { + template class SoundInstanceManager { public: - using PriorityList = util::IntrusiveList>; + using PriorityList = + util::IntrusiveList>; using Iterator = typename PriorityList::iterator; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) @@ -32,4 +33,5 @@ class SoundInstanceManager { PriorityList m_PriorityList; PriorityList m_FreeList; }; -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_SoundMemoryAllocatable.h b/include/nn/atk/atk_SoundMemoryAllocatable.h index eb2a56d3..82cfcc67 100644 --- a/include/nn/atk/atk_SoundMemoryAllocatable.h +++ b/include/nn/atk/atk_SoundMemoryAllocatable.h @@ -3,13 +3,15 @@ #include namespace nn::atk { + class SoundMemoryAllocatable { public: - using DisposeCallback = void(*)(void*); + using DisposeCallback = void (*)(void*); virtual ~SoundMemoryAllocatable() = 0; virtual void* Allocate(size_t size) = 0; virtual void* Allocate(size_t size, DisposeCallback callback, void* callbackArg) = 0; virtual size_t GetAllocateSize(size_t size, bool needMemoryPool) = 0; }; -} // namespace nn::atk \ No newline at end of file + +} // namespace nn::atk diff --git a/include/nn/atk/atk_SoundPlayer.h b/include/nn/atk/atk_SoundPlayer.h index febaf59e..3f73e338 100644 --- a/include/nn/atk/atk_SoundPlayer.h +++ b/include/nn/atk/atk_SoundPlayer.h @@ -3,97 +3,127 @@ #include #include -#include #include +#include + +namespace nn::atk { -namespace nn::atk { class SoundPlayer { public: - using SoundList = util::IntrusiveList< - detail::BasicSound, util::IntrusiveListMemberNodeTraits< + using PlayerHeapList = util::IntrusiveList< + detail::PlayerHeap, + util::IntrusiveListMemberNodeTraits>; + + using SoundList = + util::IntrusiveList>; + using PriorityList = util::IntrusiveList< - detail::BasicSound, util::IntrusiveListMemberNodeTraits< - detail::BasicSound, &detail::BasicSound::m_SoundPlayerPriorityLink>>; - using PlayerHeapList = util::IntrusiveList< - detail::PlayerHeap, util::IntrusiveListMemberNodeTraits< - detail::PlayerHeap, &detail::PlayerHeap::m_Link>>; + detail::BasicSound, + util::IntrusiveListMemberNodeTraits>; + struct OutputParam { f32 volume; f32 mainSend; - f32 fxSend[3]; + f32 fxSend[AuxBus_Count]; + + void Initialize(); }; static_assert(sizeof(OutputParam) == 0x14); SoundPlayer(); + #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) explicit SoundPlayer(detail::OutputAdditionalParam* pParam); #endif - ~SoundPlayer(); - void StopAllSound(s32 fadeFrames); + ~SoundPlayer(); void Update(); - void DoFreePlayerHeap(); + void StopAllSound(int fadeFrames); - void detail_SortPriorityList(bool reverse); + void PauseAllSound(bool flag, int fadeFrames); + void PauseAllSound(bool flag, int fadeFrames, PauseMode pauseMode); - void PauseAllSound(s32, bool); - void PauseAllSound(bool, s32); - void PauseAllSound(bool, s32, PauseMode); - - void SetVolume(f32 volume); - void SetLowPassFilterFrequency(f32 lpfFreq); - void SetBiquadFilter(s32 biquadFilterType, f32 biquadFilterValue); + void SetVolume(float volume); + float GetVolume() const { return m_Volume; } - u32 GetDefaultOutputLine() const { return m_OutputLineFlag; } - void SetDefaultOutputLine(u32 line); + void SetLowPassFilterFrequency(float lpfFreq); + float GetLowPassFilterFrequency() const { return m_LpfFreq; } - void SetMainSend(f32 send); - f32 GetMainSend() const; + void SetBiquadFilter(int type, float value); + int GetBiquadFilterType() const { return m_BiquadType; } + float GetBiquadFilterValue() const { return m_BiquadValue; } - void SetEffectSend(AuxBus bus, f32 send); - void GetEffectSend(AuxBus bus) const; + void SetDefaultOutputLine(u32 outputLineFlag); + u32 GetDefaultOutputLine() const { return m_OutputLineFlag; } - void SetSend(s32 subMixBus, f32 send); - f32 GetSend(s32 subMixBus); + void SetMainSend(float send); + float GetMainSend() const; - void SetOutputVolume(OutputDevice device, f32 volume); + void SetEffectSend(AuxBus bus, float send); + float GetEffectSend(AuxBus bus) const; - void RemoveSoundList(detail::BasicSound* pSound); + void SetSend(int subMixBus, float send); + float GetSend(int subMixBus); - void InsertPriorityList(detail::BasicSound* pSound); - void RemovePriorityList(detail::BasicSound* pSound); + void SetOutputVolume(OutputDevice device, float volume); + float GetOutputVolume([[maybe_unused]] OutputDevice device) const { return m_TvParam.volume; } - void detail_SortPriorityList(detail::BasicSound* pSound); + void SetOutputMainSend([[maybe_unused]] OutputDevice device, float send) { + m_TvParam.mainSend = send; + } + float GetOutputMainSend([[maybe_unused]] OutputDevice device) const { + return m_TvParam.mainSend; + } - bool detail_AppendSound(detail::BasicSound* pSound); - bool detail_RemoveSound(detail::BasicSound* pSound); + void SetOutputFxSend([[maybe_unused]] OutputDevice device, AuxBus bus, float send) { + m_TvParam.fxSend[bus] = send; + } + float GetOutputFxSend([[maybe_unused]] OutputDevice device, AuxBus bus) const { + return m_TvParam.fxSend[bus]; + } - void SetPlayableSoundCount(s32 count); + int GetPlayingSoundCount() const { return m_SoundList.size(); } - void detail_SetPlayableSoundLimit(s32 limit); - - bool detail_CanPlaySound(s32 startPriority); - bool CanPlaySound(s32 startPriority); + void SetPlayableSoundCount(int count); + int GetPlayableSoundCount() const { return m_PlayableCount; } + void detail_SetPlayableSoundLimit(int limit); + void detail_RemoveSound(detail::BasicSound* pSound); + void detail_SortPriorityList(bool reverse); + void detail_SortPriorityList(detail::BasicSound* pSound); void detail_AppendPlayerHeap(detail::PlayerHeap* pHeap); + bool detail_CanUsePlayerHeap() const { return m_PlayerHeapCount != 0; } detail::PlayerHeap* detail_AllocPlayerHeap(); void detail_FreePlayerHeap(detail::PlayerHeap* pHeap); + bool IsFirstComeBased() { return m_IsFirstComeBased; } + void SetFirstComeBased(bool isFirstComeBased) { m_IsFirstComeBased = isFirstComeBased; } + private: + detail::BasicSound* GetLowestPrioritySound() { return &m_SoundList.front(); } + + void InsertPriorityList(detail::BasicSound* pSound); + void RemovePriorityList(detail::BasicSound* pSound); + void RemoveSoundList(detail::BasicSound* pSound); + + void DoFreePlayerHeap(); + SoundList m_SoundList; PriorityList m_PriorityList; PlayerHeapList m_PlayerHeapFreeList; PlayerHeapList m_PlayerHeapFreeReqList; - s32 m_PlayableCount; - s32 m_PlayableLimit; + int m_PlayableCount; + int m_PlayableLimit; u32 m_PlayerHeapCount; - f32 m_Volume; - f32 m_LpfFreq; - s32 m_BiquadType; - f32 m_BiquadValue; + float m_Volume; + float m_LpfFreq; + int m_BiquadType; + float m_BiquadValue; u32 m_OutputLineFlag; OutputParam m_TvParam; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) @@ -106,4 +136,5 @@ static_assert(sizeof(SoundPlayer) == 0x78); #else static_assert(sizeof(SoundPlayer) == 0x88); #endif + } // namespace nn::atk diff --git a/include/nn/atk/atk_SoundRuntimeUtility.h b/include/nn/atk/atk_SoundRuntimeUtility.h index 6f3504d2..5d2057fa 100644 --- a/include/nn/atk/atk_SoundRuntimeUtility.h +++ b/include/nn/atk/atk_SoundRuntimeUtility.h @@ -1,5 +1,7 @@ #pragma once namespace nn::atk::detail { + class SoundRuntimeUtility {}; -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_SoundStartable.h b/include/nn/atk/atk_SoundStartable.h index f9d6730b..7e586ffe 100644 --- a/include/nn/atk/atk_SoundStartable.h +++ b/include/nn/atk/atk_SoundStartable.h @@ -1,12 +1,13 @@ #pragma once +#include #include #include -#include #include -#include +#include namespace nn::atk { + class SoundStartable { public: struct StartInfo { @@ -17,23 +18,23 @@ class SoundStartable { }; enum EnableFlagBit { - EnableFlagBit_StartOffset = 1 << 0, - EnableFlagBit_PlayerId = 1 << 1, - EnableFlagBit_PlayerPriority = 1 << 2, - EnableFlagBit_ActorPlayerId = 1 << 3, - EnableFlagBit_SequenceSoundInfo = 1 << 4, - EnableFlagBit_StreamSoundInfo = 1 << 5, - EnableFlagBit_WaveSoundInfo = 1 << 6, - EnableFlagBit_VoiceRendererType = 1 << 7, - EnableFlagBit_FadeFrame = 1 << 8, - EnableFlagBit_SoundStopCallback = 1 << 9, - EnableFlagBit_StreamSoundMetaInfo = 1 << 10, - EnableFlagBit_StreamSoundMetaInfo2 = 1 << 11, - EnableFlagBit_DelayTime = 1 << 12, - EnableFlagBit_DelayCount = 1 << 13, - EnableFlagBit_UpdateType = 1 << 14, - EnableFlagBit_SubMixIndex = 1 << 15, - EnableFlagBit_OutputReceiver = 1 << 16, + EnableFlagBit_StartOffset = 1 << 0, + EnableFlagBit_PlayerId = 1 << 1, + EnableFlagBit_PlayerPriority = 1 << 2, + EnableFlagBit_ActorPlayerId = 1 << 3, + EnableFlagBit_SequenceSoundInfo = 1 << 4, + EnableFlagBit_StreamSoundInfo = 1 << 5, + EnableFlagBit_WaveSoundInfo = 1 << 6, + EnableFlagBit_VoiceRendererType = 1 << 7, + EnableFlagBit_FadeFrame = 1 << 8, + EnableFlagBit_SoundStopCallback = 1 << 9, + EnableFlagBit_StreamSoundMetaInfo = 1 << 10, + EnableFlagBit_StreamSoundMetaInfo2 = 1 << 11, + EnableFlagBit_DelayTime = 1 << 12, + EnableFlagBit_DelayCount = 1 << 13, + EnableFlagBit_UpdateType = 1 << 14, + EnableFlagBit_SubMixIndex = 1 << 15, + EnableFlagBit_OutputReceiver = 1 << 16, }; struct SequenceSoundInfo { @@ -89,7 +90,7 @@ class SoundStartable { UpdateType updateType; s32 subMixIndex; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) - OutputReceiver* pOutputReceiver; + OutputReceiver* pOutputReceiver; #endif }; @@ -128,18 +129,18 @@ class SoundStartable { virtual ~SoundStartable() = 0; - virtual StartResult detail_SetupSound(SoundHandle* handle, u32 soundId, - bool holdFlag, const char* soundArchiveName, + virtual StartResult detail_SetupSound(SoundHandle* handle, u32 soundId, bool holdFlag, + const char* soundArchiveName, const StartInfo* startInfo) = 0; - + virtual SoundArchive::ItemId detail_GetItemId(char* pString) = 0; virtual SoundArchive::ItemId detail_GetItemId(char* pString, const char* soundArchiveName) = 0; - StartResult StartSound(SoundHandle* handle, u32 soundId, - const char* soundArchiveName, const StartInfo* startInfo); + StartResult StartSound(SoundHandle* handle, u32 soundId, const char* soundArchiveName, + const StartInfo* startInfo); StartResult StartSound(SoundHandle* handle, u32 soundId, const StartInfo* startInfo); - StartResult StartSound(SoundHandle* handle, const char* pString, - const char* soundArchiveName, const StartInfo* startInfo); + StartResult StartSound(SoundHandle* handle, const char* pString, const char* soundArchiveName, + const StartInfo* startInfo); StartResult StartSound(SoundHandle* handle, const char* soundArchiveName, const StartInfo* startInfo); @@ -147,16 +148,17 @@ class SoundStartable { const StartInfo* startInfo); StartResult HoldSound(SoundHandle* handle, u32 soundId, const StartInfo* startInfo); StartResult HoldSound(SoundHandle* handle, const char* pString, const StartInfo* startInfo); - StartResult HoldSound(SoundHandle* handle, const char* pString, const char* soundArchiveName, + StartResult HoldSound(SoundHandle* handle, const char* pString, const char* soundArchiveName, const StartInfo* startInfo); StartResult PrepareSound(SoundHandle* handle, u32 soundId, const char* soundArchiveName, const StartInfo* startInfo); StartResult PrepareSound(SoundHandle* handle, u32 soundId, const StartInfo* startInfo); - StartResult PrepareSound(SoundHandle* handle, const char* pString, - const char* soundArchiveName, const StartInfo* startInfo); + StartResult PrepareSound(SoundHandle* handle, const char* pString, const char* soundArchiveName, + const StartInfo* startInfo); StartResult PrepareSound(SoundHandle* handle, const char* soundArchiveName, const StartInfo* startInfo); }; static_assert(sizeof(SoundStartable) == 0x8); -} // namespace nn::atk \ No newline at end of file + +} // namespace nn::atk diff --git a/include/nn/atk/atk_SoundSystem.h b/include/nn/atk/atk_SoundSystem.h index 40f7401b..5516fe6b 100644 --- a/include/nn/atk/atk_SoundSystem.h +++ b/include/nn/atk/atk_SoundSystem.h @@ -1,25 +1,26 @@ #pragma once +#include #include #include -#include #include -#include -#include -#include +#include #include #include -#include +#include +#include #include +#include namespace nn::atk { + struct SoundSystem { static bool g_IsInitialized; static bool g_IsStreamLoadWait; static bool g_IsEnterSleep; static bool g_IsInitializedDriverCommandManager; - + static uintptr_t g_LoadThreadStackPtr; static size_t g_LoadThreadStackSize; @@ -147,34 +148,40 @@ struct SoundSystem { static size_t GetRequiredMemSize(const SoundSystemParam& param); static size_t GetRequiredMemSizeForCircularBufferSink(const SoundSystemParam& param); static size_t GetRequiredMemSizeForMemoryPool(const SoundSystemParam& param); - - static void SetupHardwareManagerParameter(detail::driver::HardwareManager::HardwareManagerParameter* pOutValue, - SoundSystemParam* parameter); - static bool detail_InitializeSoundSystem(Result* pOutResult, const SoundSystemParam& param, const InitializeBufferSet& bufferSet); - static void detail_InitializeDriverCommandManager(const SoundSystemParam& param, u64, u64, u64, u64); - + static void SetupHardwareManagerParameter( + detail::driver::HardwareManager::HardwareManagerParameter* pOutValue, + SoundSystemParam* parameter); + + static bool detail_InitializeSoundSystem(Result* pOutResult, const SoundSystemParam& param, + const InitializeBufferSet& bufferSet); + static void detail_InitializeDriverCommandManager(const SoundSystemParam& param, u64, u64, u64, + u64); + static bool Initialize(SoundSystemParam* param, uintptr_t workMem, size_t workMemSize); - static bool Initialize(Result* pOutResult, const SoundSystemParam& param, - uintptr_t workMem, size_t workMemSize); - - static void SetupInitializeBufferSet(InitializeBufferSet* pOutValue, - SoundSystemParam* param, InitializeBufferSet* bufferSet); + static bool Initialize(Result* pOutResult, const SoundSystemParam& param, uintptr_t workMem, + size_t workMemSize); + + static void SetupInitializeBufferSet(InitializeBufferSet* pOutValue, SoundSystemParam* param, + InitializeBufferSet* bufferSet); - static bool Initialize(SoundSystemParam* param, uintptr_t workMem, size_t workMemSize, + static bool Initialize(SoundSystemParam* param, uintptr_t workMem, size_t workMemSize, uintptr_t memoryPoolMem, size_t memoryPoolMemSize); - static bool Initialize(Result* pOutResult, const SoundSystemParam& param, uintptr_t workMem, + static bool Initialize(Result* pOutResult, const SoundSystemParam& param, uintptr_t workMem, size_t workMemSize, uintptr_t memoryPoolMem, size_t memoryPoolMemSize); static bool Initialize(const SoundSystemParam& param, const InitializeBufferSet& bufferSet); - static bool Initialize(Result* pOutResult, const SoundSystemParam& param, const InitializeBufferSet& bufferSet); + static bool Initialize(Result* pOutResult, const SoundSystemParam& param, + const InitializeBufferSet& bufferSet); static void Finalize(); - static void SetSoundThreadBeginUserCallback(void(*threadBeginUserCallback)(u64), uintptr_t threadBeginUserCallbackArg); + static void SetSoundThreadBeginUserCallback(void (*threadBeginUserCallback)(u64), + uintptr_t threadBeginUserCallbackArg); static void ClearSoundThreadBeginUserCallback(); - static void SetSoundThreadEndUserCallback(void(*threadEndUserCallback)(u64), uintptr_t threadEndUserCallbackArg); + static void SetSoundThreadEndUserCallback(void (*threadEndUserCallback)(u64), + uintptr_t threadEndUserCallbackArg); static void ClearSoundThreadEndUserCallback(); static bool IsInitialized(); @@ -188,10 +195,11 @@ struct SoundSystem { static void DetachMemoryPool(audio::MemoryPoolType* pMemoryPool); static void DumpMemory(); - + static size_t GetAudioRendererBufferSize(); - static void SetupHardwareManagerParameterFromCurrentSetting(detail::driver::HardwareManager::HardwareManagerParameter* pHardwareManagerParameter); + static void SetupHardwareManagerParameterFromCurrentSetting( + detail::driver::HardwareManager::HardwareManagerParameter* pHardwareManagerParameter); static size_t GetRecorderBufferSize(); static size_t GetUserCircularBufferSinkBufferSize(); @@ -203,35 +211,36 @@ struct SoundSystem { static size_t GetAllocatedDriverCommandBufferSize(); static size_t GetAllocatedDriverCommandCount(); - static void RegisterAudioRendererPerformanceReader(AudioRendererPerformanceReader& audioRendererPerformanceReader); + static void RegisterAudioRendererPerformanceReader( + AudioRendererPerformanceReader& audioRendererPerformanceReader); - static bool AppendEffect(AuxBus auxBus, EffectBase* pEffectBase, - void* buffer, size_t bufferSize); - static bool AppendEffect(AuxBus auxBus, EffectBase* pEffectBase, - void* buffer, size_t bufferSize, OutputDevice device); - static bool AppendEffect(AuxBus auxBus, EffectBase* pEffectBase, - void* buffer, size_t bufferSize, OutputDevice device, s32 subMixNumber); + static bool AppendEffect(AuxBus auxBus, EffectBase* pEffectBase, void* buffer, + size_t bufferSize); + static bool AppendEffect(AuxBus auxBus, EffectBase* pEffectBase, void* buffer, + size_t bufferSize, OutputDevice device); + static bool AppendEffect(AuxBus auxBus, EffectBase* pEffectBase, void* buffer, + size_t bufferSize, OutputDevice device, s32 subMixNumber); - static bool AppendEffect(AuxBus auxBus, EffectAux* pEffectAux, - void* buffer, size_t bufferSize); - static bool AppendEffect(AuxBus auxBus, EffectAux* pEffectAux, - void* buffer, size_t bufferSize, OutputDevice device); - static bool AppendEffect(AuxBus auxBus, EffectAux* pEffectAux, - void* buffer, size_t bufferSize, OutputDevice device, s32 subMixNumber); + static bool AppendEffect(AuxBus auxBus, EffectAux* pEffectAux, void* buffer, size_t bufferSize); + static bool AppendEffect(AuxBus auxBus, EffectAux* pEffectAux, void* buffer, size_t bufferSize, + OutputDevice device); + static bool AppendEffect(AuxBus auxBus, EffectAux* pEffectAux, void* buffer, size_t bufferSize, + OutputDevice device, s32 subMixNumber); static bool AppendEffectToFinalMix(EffectAux* pEffectAux, void* buffer, size_t bufferSize); - static bool AppendEffectToAdditionalSubMix(EffectAux* pEffectAux, void* buffer, size_t bufferSize); + static bool AppendEffectToAdditionalSubMix(EffectAux* pEffectAux, void* buffer, + size_t bufferSize); static size_t GetRequiredEffectAuxBufferSize(const EffectAux* pEffectAux); static void RemoveEffect(AuxBus auxBus, EffectBase* pEffectBase); static void RemoveEffect(AuxBus auxBus, EffectBase* pEffectBase, OutputDevice outputDevice); - static void RemoveEffect(AuxBus auxBus, EffectBase* pEffectBase, OutputDevice outputDevice, + static void RemoveEffect(AuxBus auxBus, EffectBase* pEffectBase, OutputDevice outputDevice, s32 subMixNumber); static void RemoveEffect(AuxBus auxBus, EffectAux* pEffectAux); static void RemoveEffect(AuxBus auxBus, EffectAux* pEffectAux, OutputDevice outputDevice); - static void RemoveEffect(AuxBus auxBus, EffectAux* pEffectAux, OutputDevice outputDevice, + static void RemoveEffect(AuxBus auxBus, EffectAux* pEffectAux, OutputDevice outputDevice, s32 subMixNumber); static void RemoveEffectFromFinalMix(EffectAux* pEffectAux); @@ -240,7 +249,7 @@ struct SoundSystem { static void ClearEffect(AuxBus auxBus); static void ClearEffect(AuxBus auxBus, OutputDevice outputDevice); static void ClearEffect(AuxBus auxBus, OutputDevice outputDevice, s32 subMixNumber); - + static void ClearEffectFromFinalMix(); static void ClearEffectFromAdditionalSubMix(); @@ -257,26 +266,32 @@ struct SoundSystem { static f32 GetAuxBusVolume(AuxBus auxBus); static f32 GetAuxBusVolume(AuxBus auxBus, s32 subMixIndex); - static void SetMainBusChannelVolumeForAdditionalEffect(f32 volume, s32 srcChannel, s32 dstChannel); + static void SetMainBusChannelVolumeForAdditionalEffect(f32 volume, s32 srcChannel, + s32 dstChannel); static f32 GetMainBusChannelVolumeForAdditionalEffect(s32 srcChannel, s32 dstChannel); - static void SetAuxBusChannelVolumeForAdditionalEffect(AuxBus auxBus, f32 volume, s32 srcChannel, s32 dstChannel); - static f32 GetAuxBusChannelVolumeForAdditionalEffect(AuxBus auxBus, s32 srcChannel, s32 dstChannel); + static void SetAuxBusChannelVolumeForAdditionalEffect(AuxBus auxBus, f32 volume, s32 srcChannel, + s32 dstChannel); + static f32 GetAuxBusChannelVolumeForAdditionalEffect(AuxBus auxBus, s32 srcChannel, + s32 dstChannel); - static void SetAllAuxBusChannelVolumeForAdditionalEffect(f32 volume, s32 srcChannel, s32 dstChannel); - static void SetAllBusChannelVolumeForAdditionalEffect(f32 volume, s32 srcChannel, s32 dstChannel); + static void SetAllAuxBusChannelVolumeForAdditionalEffect(f32 volume, s32 srcChannel, + s32 dstChannel); + static void SetAllBusChannelVolumeForAdditionalEffect(f32 volume, s32 srcChannel, + s32 dstChannel); static void VoiceCommandProcess(UpdateType updateType, u32); static void VoiceCommandProcess(u32); - + static void VoiceCommandUpdate(); static size_t GetPerformanceFrameBufferSize(); static s32 GetDroppedLowLevelVoiceCount(); - + static void RegisterSoundThreadUpdateProfileReader(AtkProfileReader&); - static void UnregisterSoundThreadUpdateProfileReader(AtkProfileReader&); + static void + UnregisterSoundThreadUpdateProfileReader(AtkProfileReader&); static void RegisterSoundThreadInfoRecorder(detail::ThreadInfoRecorder&); static void UnregisterSoundThreadInfoRecorder(detail::ThreadInfoRecorder&); @@ -294,4 +309,5 @@ struct SoundSystem { static CircularBufferSinkState GetCircularBufferSinkState(); static detail::SoundInstanceConfig GetSoundInstanceConfig(); }; -} // namespace nn::atk \ No newline at end of file + +} // namespace nn::atk diff --git a/include/nn/atk/atk_SoundThread.h b/include/nn/atk/atk_SoundThread.h index 5032b98c..a8cfa631 100644 --- a/include/nn/atk/atk_SoundThread.h +++ b/include/nn/atk/atk_SoundThread.h @@ -1,30 +1,31 @@ #pragma once -#include #include +#include #include #include +#include #include +#include #include -#include #include -#include -#include +#include namespace nn::atk::detail::driver { + struct SoundThreadLock {}; struct AtkStateAndParameterUpdateLock {}; class SoundThread : fnd::Thread::Handler { public: enum Message { - Message_HwCallback = 0x10000000, - Message_Shutdown = 0x20000000, + Message_HwCallback = 0x10000000, + Message_Shutdown = 0x20000000, Message_ForceWakeup = 0x30000000, }; - using ProfileFunc = void(*)(os::Tick*); + using ProfileFunc = void (*)(os::Tick*); constexpr static u32 ThreadMessageBuffferSize = 32; @@ -43,9 +44,9 @@ class SoundThread : fnd::Thread::Handler { util::IntrusiveListNode m_Link; }; - using SoundFrameCallbackList = util::IntrusiveList>; + using SoundFrameCallbackList = util::IntrusiveList< + SoundFrameCallback, + util::IntrusiveListMemberNodeTraits>; class PlayerCallback { public: @@ -61,30 +62,31 @@ class SoundThread : fnd::Thread::Handler { util::IntrusiveListNode m_Link; }; - using PlayerCallbackList = util::IntrusiveList>; + using PlayerCallbackList = util::IntrusiveList< + PlayerCallback, + util::IntrusiveListMemberNodeTraits>; ~SoundThread() override; - - bool CreateSoundThread(s32 threadPriority, void* stackBase, size_t stackSize, + + bool CreateSoundThread(s32 threadPriority, void* stackBase, size_t stackSize, s32 idealCoreNumber, u32 affinityMask); - void Initialize(void* performanceFrameBuffer, size_t performanceFrameBufferSize, + void Initialize(void* performanceFrameBuffer, size_t performanceFrameBufferSize, bool isProfilingEnabled); - void Initialize(void* performanceFrameBuffer, size_t performanceFrameBufferSize, + void Initialize(void* performanceFrameBuffer, size_t performanceFrameBufferSize, bool isProfilingEnabled, bool isDetailSoundThreadProfilerEnabled, bool isUserThreadRenderingEnabled); void Destroy(); - + void Finalize(); void UpdateLowLevelVoices(); void ForceWakeup(); - void RegisterSoundFrameUserCallback(SoundFrameUserCallback callback, std::uintptr_t callbackArg); + void RegisterSoundFrameUserCallback(SoundFrameUserCallback callback, + std::uintptr_t callbackArg); void ClearSoundFrameUserCallback(); void RegisterThreadBeginUserCallback(SoundThreadUserCallback, std::uintptr_t callbackArg); @@ -103,7 +105,7 @@ class SoundThread : fnd::Thread::Handler { void UnlockAtkStateAndParameterUpdate(); void RegisterAudioRendererPerformanceReader(AudioRendererPerformanceReader& performanceReader); - + void RegisterSoundThreadUpdateProfileReader(SoundThreadUpdateProfileReader& profileReader); void UnregisterSoundThreadUpdateProfileReader(SoundThreadUpdateProfileReader& profileReader); @@ -112,8 +114,8 @@ class SoundThread : fnd::Thread::Handler { void FrameProcess(UpdateType updateType); - void RecordPerformanceInfo(audio::PerformanceInfo* src, os::Tick beginTick, - os::Tick endTick, u32 nwVoiceCount); + void RecordPerformanceInfo(audio::PerformanceInfo* src, os::Tick beginTick, os::Tick endTick, + u32 nwVoiceCount); void EffectFrameProcess(); @@ -165,4 +167,5 @@ static_assert(sizeof(SoundThread) == 0x4c8); #else static_assert(sizeof(SoundThread) == 0x508); #endif -} // namespace nn::atk::detail::driver \ No newline at end of file + +} // namespace nn::atk::detail::driver diff --git a/include/nn/atk/atk_StartInfoReader.h b/include/nn/atk/atk_StartInfoReader.h index c84db918..6821578d 100644 --- a/include/nn/atk/atk_StartInfoReader.h +++ b/include/nn/atk/atk_StartInfoReader.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail { + class StartInfoReader { public: explicit StartInfoReader(const SoundArchive::SoundInfo& soundInfo); @@ -33,4 +34,5 @@ static_assert(sizeof(StartInfoReader) == 0x50); #else static_assert(sizeof(StartInfoReader) == 0x58); #endif -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_StreamBufferPool.h b/include/nn/atk/atk_StreamBufferPool.h index 9e44fbbc..fc58e73a 100644 --- a/include/nn/atk/atk_StreamBufferPool.h +++ b/include/nn/atk/atk_StreamBufferPool.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail::driver { + class StreamBufferPool { public: void Initialize(void* buffer, size_t size, int blockCount); @@ -14,8 +15,8 @@ class StreamBufferPool { size_t GetBlockSize() const { return m_BlockSize; } private: - static const int BlockMax {32}; - static const int BitPerByte {8}; + static const int BlockMax{32}; + static const int BitPerByte{8}; void* m_Buffer; size_t m_BufferSize; @@ -25,4 +26,5 @@ class StreamBufferPool { u8 m_AllocFlags[BlockMax / BitPerByte]; }; static_assert(sizeof(StreamBufferPool) == 0x28); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail::driver diff --git a/include/nn/atk/atk_StreamSound.h b/include/nn/atk/atk_StreamSound.h index e4a0fe0d..724a0815 100644 --- a/include/nn/atk/atk_StreamSound.h +++ b/include/nn/atk/atk_StreamSound.h @@ -1,10 +1,11 @@ #pragma once -#include #include +#include #include namespace nn::atk::detail { + class StreamSound; using StreamSoundInstanceManager = SoundInstanceManager; @@ -22,11 +23,11 @@ class StreamSound : BasicSound { void Setup(const driver::StreamSoundPlayer::SetupArg& arg); void Prepare(const driver::StreamSoundPlayer::PrepareBaseArg& arg); - void PreparePrefetch(const void* strmPrefetchFile, + void PreparePrefetch(const void* strmPrefetchFile, const driver::StreamSoundPlayer::PrepareBaseArg& arg); void UpdateMoveValue() override; - + void OnUpdateParam() override; void SetTrackVolume(u32 trackBitFlag, f32 volume, s32); @@ -46,7 +47,7 @@ class StreamSound : BasicSound { bool IsAttachedTempSpecialHandle() override; void DetachTempSpecialHandle() override; - + bool ReadStreamDataInfo(StreamDataInfo*) const; s32 GetPlayLoopCount() const; @@ -59,11 +60,11 @@ class StreamSound : BasicSound { bool IsSuspendByLoadingDelay() const; bool IsLoadingDelayState() const; - driver::BasicSoundPlayer * GetBasicSoundPlayerHandle() override; + driver::BasicSoundPlayer* GetBasicSoundPlayerHandle() override; private: friend StreamSoundInstanceManager; - + util::IntrusiveListNode m_PriorityLink; StreamSoundHandle* m_pTempSpecialHandle; StreamSoundInstanceManager* m_Manager; @@ -81,4 +82,5 @@ static_assert(sizeof(StreamSound) == 0x11a00); #else static_assert(sizeof(StreamSound) == 0x11a40); #endif -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_StreamSoundFile.h b/include/nn/atk/atk_StreamSoundFile.h index bf019d23..1b480847 100644 --- a/include/nn/atk/atk_StreamSoundFile.h +++ b/include/nn/atk/atk_StreamSoundFile.h @@ -3,13 +3,14 @@ #include namespace nn::atk::detail { + struct StreamSoundFile { struct InfoBlock; struct FileHeader : BinaryFileHeader { private: static const int BlockCount = 4; - + public: Util::ReferenceWithSize toBlocks[BlockCount]; @@ -99,10 +100,8 @@ struct StreamSoundFile { Util::Reference toGlobalChannelIndexTable; - u32 GetTrackChannelCount() const { - return GetGlobalChannelIndexTable().GetCount(); - } - + u32 GetTrackChannelCount() const { return GetGlobalChannelIndexTable().GetCount(); } + u8 GetGlobalChannelIndex(u32 index) const { return GetGlobalChannelIndexTable().GetGlobalIndex(index); } @@ -110,8 +109,8 @@ struct StreamSoundFile { private: const GlobalChannelIndexTable& GetGlobalChannelIndexTable() const { return *util::ConstBytePtr(this) - .Advance(toGlobalChannelIndexTable.offset) - .Get(); + .Advance(toGlobalChannelIndexTable.offset) + .Get(); } }; static_assert(sizeof(TrackInfo) == 0xc); @@ -126,7 +125,7 @@ struct StreamSoundFile { struct ChannelInfo; struct ChannelInfoTable { Util::ReferenceTable table; - + u32 GetChannelCount() const; const ChannelInfo* GetChannelInfo(u32 index) const; }; @@ -134,7 +133,7 @@ struct StreamSoundFile { struct DspAdpcmChannelInfo; struct ChannelInfo { Util::Reference toDetailChannelInfo; - + const DspAdpcmChannelInfo* GetDspAdpcmChannelInfo() const; }; static_assert(sizeof(ChannelInfo) == 0x8); @@ -161,4 +160,5 @@ struct StreamSoundFile { }; static_assert(sizeof(RegionBlock) == 0x108); }; -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_StreamSoundFileLoader.h b/include/nn/atk/atk_StreamSoundFileLoader.h index fb1f5082..de080e00 100644 --- a/include/nn/atk/atk_StreamSoundFileLoader.h +++ b/include/nn/atk/atk_StreamSoundFileLoader.h @@ -1,17 +1,16 @@ #pragma once -#include #include +#include #include namespace nn::atk::detail { + class StreamSoundFileLoader : public IRegionInfoReadable { public: StreamSoundFileLoader() = default; - explicit StreamSoundFileLoader(fnd::FileStream* stream) { - Initialize(stream); - } - + explicit StreamSoundFileLoader(fnd::FileStream* stream) { Initialize(stream); } + void Initialize(fnd::FileStream* stream) { m_pStream = stream; m_SeekBlockOffset = 0; @@ -30,14 +29,15 @@ class StreamSoundFileLoader : public IRegionInfoReadable { bool ReadSeekBlockData(u16* yn1, u16* yn2, int blockIndex, int channelCount); bool ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo, u32 regionIndex) const override; - + ~StreamSoundFileLoader() override; private: - fnd::FileStream* m_pStream {}; - u32 m_SeekBlockOffset {0}; - u32 m_RegionDataOffset {0}; - u16 m_RegionInfoBytes {0}; + fnd::FileStream* m_pStream{}; + u32 m_SeekBlockOffset{0}; + u32 m_RegionDataOffset{0}; + u16 m_RegionInfoBytes{0}; }; static_assert(sizeof(StreamSoundFileLoader) == 0x20); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_StreamSoundFileReader.h b/include/nn/atk/atk_StreamSoundFileReader.h index f5f69ae2..18a22b7e 100644 --- a/include/nn/atk/atk_StreamSoundFileReader.h +++ b/include/nn/atk/atk_StreamSoundFileReader.h @@ -81,4 +81,4 @@ class StreamSoundFileReader { }; static_assert(sizeof(StreamSoundFileReader) == 0x10); -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_StreamSoundHandle.h b/include/nn/atk/atk_StreamSoundHandle.h index 6f7fe0a2..405d5fa9 100644 --- a/include/nn/atk/atk_StreamSoundHandle.h +++ b/include/nn/atk/atk_StreamSoundHandle.h @@ -6,8 +6,10 @@ namespace nn::atk { namespace detail { + class StreamSound; -} // namespace nn::atk::detail + +} // namespace detail class StreamSoundHandle { public: @@ -21,4 +23,5 @@ class StreamSoundHandle { private: detail::StreamSound* m_pSound; }; -} // namespace nn::atk \ No newline at end of file + +} // namespace nn::atk diff --git a/include/nn/atk/atk_StreamSoundLoader.h b/include/nn/atk/atk_StreamSoundLoader.h index 6027d65a..9352b11d 100644 --- a/include/nn/atk/atk_StreamSoundLoader.h +++ b/include/nn/atk/atk_StreamSoundLoader.h @@ -1,17 +1,18 @@ #pragma once #include -#include #include -#include +#include #include -#include +#include #include #include #include -#include +#include +#include namespace nn::atk::detail { + struct IStreamDataDecoderManager; struct DriverCommandStreamSoundLoadHeader; struct DriverCommandStreamSoundLoadData; @@ -81,6 +82,7 @@ struct FileStreamHookParam { static_assert(sizeof(FileStreamHookParam) == 0x10); namespace driver { + class StreamSoundPlayer; class StreamSoundLoader; @@ -139,9 +141,9 @@ class StreamSoundLoader { }; static_assert(sizeof(StreamDataLoadTask) == 0xf8); - using StreamDataLoadTaskList = util::IntrusiveList>; + using StreamDataLoadTaskList = util::IntrusiveList< + StreamDataLoadTask, + util::IntrusiveListMemberNodeTraits>; struct AdpcmInfo { AdpcmParam param; @@ -157,7 +159,6 @@ class StreamSoundLoader { size_t startOffsetSamplesAlign; size_t startOffsetByte; size_t copyByte; - }; static_assert(sizeof(BlockInfo) == 0x30); @@ -185,7 +186,7 @@ class StreamSoundLoader { void RequestLoadHeader(); void RequestLoadData(void** bufferAddress, u32 bufferBlockIndex, position_t startOffsetSamples, position_t prefetchOffsetSamples, s32 priority); - + void Update(); void ForceFinish(); @@ -197,9 +198,9 @@ class StreamSoundLoader { void LoadHeader(); bool LoadHeader1(DriverCommandStreamSoundLoadHeader* command); - bool LoadHeaderForOpus(DriverCommandStreamSoundLoadHeader* command, - StreamFileType type, DecodeMode decodeMode); - + bool LoadHeaderForOpus(DriverCommandStreamSoundLoadHeader* command, StreamFileType type, + DecodeMode decodeMode); + bool ReadTrackInfoFromStreamSoundFile(StreamSoundFileReader& reader); bool SetAdpcmInfo(StreamSoundFileReader& reader, s32 channelCount, AdpcmParam** adpcmParam); @@ -210,27 +211,26 @@ class StreamSoundLoader { void SetStreamSoundInfoForOpus(const IStreamDataDecoder::DataInfo& dataInfo); - void LoadData(void** bufferAddress, u32 bufferBlockIndex, size_t startOffsetSamples, + void LoadData(void** bufferAddress, u32 bufferBlockIndex, size_t startOffsetSamples, size_t prefetchOffsetSamples, TaskProfileLogger& logger); - bool LoadData1(DriverCommandStreamSoundLoadData* command, void** bufferAddress, - u32 bufferBlockIndex, size_t startOffsetSamples, - size_t prefetchOffsetSamples, TaskProfileLogger& logger); - bool LoadDataForOpus(DriverCommandStreamSoundLoadData* command, void** bufferAddress, - u32 bufferBlockIndex, size_t startOffsetSamples, + bool LoadData1(DriverCommandStreamSoundLoadData* command, void** bufferAddress, + u32 bufferBlockIndex, size_t startOffsetSamples, size_t prefetchOffsetSamples, + TaskProfileLogger& logger); + bool LoadDataForOpus(DriverCommandStreamSoundLoadData* command, void** bufferAddress, + u32 bufferBlockIndex, size_t startOffsetSamples, size_t prefetchOffsetSamples, TaskProfileLogger& logger); bool ApplyStartOffset(s64, s32*); - + void CalculateBlockInfo(BlockInfo&); bool LoadAdpcmContextForStartOffset(); - bool LoadOneBlockDataViaCache(void** bufferAddress, const BlockInfo& blockInfo, - position_t destAddressOffset, bool firstBlock, + bool LoadOneBlockDataViaCache(void** bufferAddress, const BlockInfo& blockInfo, + position_t destAddressOffset, bool firstBlock, bool updateAdpcmContext); - bool LoadOneBlockData(void** bufferAddress, const BlockInfo& blockInfo, - position_t destAddressOffset, bool firstBlock, - bool updateAdpcmContext); + bool LoadOneBlockData(void** bufferAddress, const BlockInfo& blockInfo, + position_t destAddressOffset, bool firstBlock, bool updateAdpcmContext); bool MoveNextRegion(s32*); @@ -251,7 +251,7 @@ class StreamSoundLoader { private: friend StreamSoundLoaderManager; - + StreamSoundFileLoader m_FileLoader; StreamSoundPlayer* m_PlayerHandle; fnd::FileStream* m_pFileStream; @@ -287,7 +287,7 @@ class StreamSoundLoader { SampleFormat m_SampleFormat; AdpcmInfo m_AdpcmInfo[16]; u32 m_FileStreamBuffer[128]; - IStreamDataDecoder* m_pStreamDataDecoder; + IStreamDataDecoder* m_pStreamDataDecoder; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static IStreamDataDecoderManager* g_pStreamDataDecoderManager; #else @@ -302,5 +302,6 @@ static_assert(sizeof(StreamSoundLoader) == 0x35c0); #else static_assert(sizeof(StreamSoundLoader) == 0x3640); #endif -} // namespace nn::atk::detail::driver -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace driver +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_StreamSoundPlayer.h b/include/nn/atk/atk_StreamSoundPlayer.h index 9631a673..08ee2407 100644 --- a/include/nn/atk/atk_StreamSoundPlayer.h +++ b/include/nn/atk/atk_StreamSoundPlayer.h @@ -7,6 +7,7 @@ #include namespace nn::atk::detail { + struct StreamDataInfo { bool loopFlag; s32 sampleRate; @@ -38,6 +39,7 @@ struct StreamSoundRegionDataInfo { static_assert(sizeof(StreamSoundRegionDataInfo) == 0x4c); namespace driver { + class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { public: enum StartOffsetType { @@ -64,7 +66,7 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { f32 span; f32 mainSend; f32 fxSend[3]; - + void Set(const StreamTrack* pStreamTrack); }; static_assert(sizeof(TrackData) == 0x28); @@ -82,7 +84,7 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { s32 delayTime; s32 delayCount; UpdateType updateType; -#if NN_SDK_VER < NN_MAKE_VER(4, 4 ,1) +#if NN_SDK_VER < NN_MAKE_VER(4, 4, 1) u32 subMixIndex; #endif StreamRegionCallback regionCallback; @@ -119,18 +121,17 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { f32 pitch; u8 mainSend; u8 fxSend[3]; -#if NN_SDK_VER >= NN_MAKE_VER(4, 4 ,1) +#if NN_SDK_VER >= NN_MAKE_VER(4, 4, 1) DecodeMode decodeMode; #endif }; -#if NN_SDK_VER < NN_MAKE_VER(4, 4 ,1) +#if NN_SDK_VER < NN_MAKE_VER(4, 4, 1) static_assert(sizeof(SetupArg) == 0x98); #else static_assert(sizeof(SetupArg) == 0xa0); #endif struct PrefetchIndexInfo { - void Initialize(const StreamDataInfoDetail& streamDataInfo); u32 lastBlockIndex; @@ -149,7 +150,6 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { StreamSoundPlayer(); ~StreamSoundPlayer() override; - #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) bool Initialize() override; #else @@ -170,13 +170,13 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { void SetupTrack(const SetupArg& arg); void Prepare(const PrepareArg& arg); - + void SetPrepareBaseArg(const PrepareBaseArg& arg); void RequestLoadHeader(const PrepareArg& arg); void PreparePrefetch(const PreparePrefetchArg& arg); - + bool ReadPrefetchFile(StreamSoundPrefetchFileReader& reader); bool ApplyStreamDataInfo(const StreamDataInfoDetail& streamDataInfo); @@ -216,14 +216,14 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { void UpdateLoadingBlockIndex(); bool LoadStreamData(bool result, const LoadDataParam& loadDataParam, u16 assignNumber); - bool LoadStreamData(bool result, const LoadDataParam& loadDataParam, u16 assignNumber, - bool usePrefetchFlag, u32 currentPrefetchBlockIndex, + bool LoadStreamData(bool result, const LoadDataParam& loadDataParam, u16 assignNumber, + bool usePrefetchFlag, u32 currentPrefetchBlockIndex, size_t currentPrefetchBlockBytes); bool IsStoppedByLoadingDelay() const; - static void VoiceCallbackFunc(MultiVoice* voice, - MultiVoice::VoiceCallbackStatus status, void* arg); + static void VoiceCallbackFunc(MultiVoice* voice, MultiVoice::VoiceCallbackStatus status, + void* arg); void Update(); void UpdateBuffer(); @@ -232,21 +232,21 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { bool CheckDiskDriveError(); void SetOutputParam(const OutputParam*, const OutputParam&, const TrackData&); - + #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) - void ApplyTvOutputParamForMultiChannel(OutputParam* outputParam, - MultiVoice* MultiVoice, s32 channelIndex, - MixMode mixMode); + void ApplyTvOutputParamForMultiChannel(OutputParam* outputParam, MultiVoice* MultiVoice, + s32 channelIndex, MixMode mixMode); #else - void ApplyTvOutputParamForMultiChannel(OutputParam* outputParam, - OutputAdditionalParam* pOutputAdditionalParam, - MultiVoice* MultiVoice, s32 channelIndex, + void ApplyTvOutputParamForMultiChannel(OutputParam* outputParam, + OutputAdditionalParam* pOutputAdditionalParam, + MultiVoice* MultiVoice, s32 channelIndex, MixMode mixMode); #endif - + void MixSettingForOutputParam(OutputParam* outputParam, s32 channelIndex, MixMode mixMode); - - position_t GetOriginalPlaySamplePosition(position_t, const StreamDataInfoDetail& streamDataInfo) const; + + position_t GetOriginalPlaySamplePosition(position_t, + const StreamDataInfoDetail& streamDataInfo) const; bool IsValidStartOffset(const StreamDataInfoDetail& streamDataInfo); @@ -258,13 +258,13 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { void PreparePrefetchOnLoopStartBlock(PrefetchLoadDataParam*, const PrefetchIndexInfo&, StreamSoundPrefetchFileReader& reader); void PreparePrefetchOnLoopBlock(PrefetchLoadDataParam*, const PrefetchIndexInfo&, u32); - bool PreparePrefetchOnNormalBlock(PrefetchLoadDataParam*, u32, + bool PreparePrefetchOnNormalBlock(PrefetchLoadDataParam*, u32, StreamSoundPrefetchFileReader* reader); - bool SetAdpcmLoopInfo(StreamSoundPrefetchFileReader& reader, + bool SetAdpcmLoopInfo(StreamSoundPrefetchFileReader& reader, const StreamDataInfoDetail& streamDataInfo, AdpcmParam* adpcmParam, AdpcmContextNotAligned* adpcmContext); - bool SetAdpcmInfo(StreamSoundPrefetchFileReader& reader, + bool SetAdpcmInfo(StreamSoundPrefetchFileReader& reader, const StreamDataInfoDetail& streamDataInfo, AdpcmParam* adpcmParam, AdpcmContextNotAligned* adpcmContext); @@ -318,7 +318,7 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { s32 m_DelayCount; u16 m_AssignNumber; u8 m_FileType; -#if NN_SDK_VER >= NN_MAKE_VER(4, 4 ,1) +#if NN_SDK_VER >= NN_MAKE_VER(4, 4, 1) DecodeMode m_DecodeMode; #endif bool m_LoopFlag; @@ -338,7 +338,7 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { StreamChannel m_Channels[16]; StreamTrack m_Tracks[8]; UpdateType m_UpdateType; -#if NN_SDK_VER < NN_MAKE_VER(4, 4 ,1) +#if NN_SDK_VER < NN_MAKE_VER(4, 4, 1) u32 m_SubMixIndex; #endif WaveBufferInfo m_WaveBufferInfo[32]; @@ -352,5 +352,6 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { static u16 g_AssignNumberCount; }; static_assert(sizeof(StreamSoundPlayer) == 0x11740); -} // namespace nn::atk::detail::driver -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace driver +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_StreamSoundPrefetchFile.h b/include/nn/atk/atk_StreamSoundPrefetchFile.h index d880b0c4..c91182eb 100644 --- a/include/nn/atk/atk_StreamSoundPrefetchFile.h +++ b/include/nn/atk/atk_StreamSoundPrefetchFile.h @@ -4,6 +4,7 @@ #include namespace nn::atk::detail { + class StreamSoundPrefetchFile { public: struct PrefetchDataBlock; @@ -13,7 +14,7 @@ class StreamSoundPrefetchFile { const PrefetchDataBlock* GetPrefetchDataBlock() const; u32 GetPrefetchDataBlockSize() const; - + bool HasRegionBlock() const; u32 GetRegionBlockSize() const; u32 GetRegionBlockOffset() const; @@ -34,7 +35,9 @@ class StreamSoundPrefetchFile { Util::Table prefetchDataTable; u32 GetPrefetchDataCount() const { return prefetchDataTable.count; } - const PrefetchData* GetPrefetchData(u32 index) const { return &prefetchDataTable.item[index]; } + const PrefetchData* GetPrefetchData(u32 index) const { + return &prefetchDataTable.item[index]; + } }; struct PrefetchDataBlock { @@ -48,4 +51,5 @@ class StreamSoundPrefetchFile { const void* GetSampleAddress() const; }; }; -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_StreamSoundPrefetchFileReader.h b/include/nn/atk/atk_StreamSoundPrefetchFileReader.h index 86c842bf..5b9225a1 100644 --- a/include/nn/atk/atk_StreamSoundPrefetchFileReader.h +++ b/include/nn/atk/atk_StreamSoundPrefetchFileReader.h @@ -1,9 +1,10 @@ #pragma once -#include #include +#include namespace nn::atk::detail { + class StreamSoundPrefetchFileReader : public IRegionInfoReadable { public: struct PrefetchDataInfo { @@ -24,9 +25,7 @@ class StreamSoundPrefetchFileReader : public IRegionInfoReadable { m_RegionInfoBytes = 0; } - bool IsAvailable() const { - return m_pHeader != nullptr; - } + bool IsAvailable() const { return m_pHeader != nullptr; } bool IsIncludeRegionInfo() const; bool IsCrc32CheckAvailable() const; @@ -38,18 +37,18 @@ class StreamSoundPrefetchFileReader : public IRegionInfoReadable { bool ReadDspAdpcmChannelInfo(DspAdpcmParam* pParam, DspAdpcmLoopParam* pLoopParam, int channelIndex) const; bool ReadPrefetchDataInfo(PrefetchDataInfo* pDataInfo, int prefetchIndex) const; - + bool ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo, u32 regionIndex) const override; u32 GetChannelCount() const; u32 GetPrefetchDataCount() const; u32 GetRegionDataOffset() const { - u32 result {0}; + u32 result{0}; if (IsAvailable() && m_pHeader->HasRegionBlock()) { - result = m_pHeader->GetRegionBlockOffset() + sizeof(BinaryBlockHeader) - + m_pInfoBlockBody->GetStreamSoundInfo()->regionDataOffset.offset; + result = m_pHeader->GetRegionBlockOffset() + sizeof(BinaryBlockHeader) + + m_pInfoBlockBody->GetStreamSoundInfo()->regionDataOffset.offset; } return result; @@ -60,11 +59,12 @@ class StreamSoundPrefetchFileReader : public IRegionInfoReadable { } private: - const StreamSoundPrefetchFile::FileHeader* m_pHeader {}; - const StreamSoundFile::InfoBlockBody* m_pInfoBlockBody {}; - const StreamSoundPrefetchFile::PrefetchDataBlockBody* m_pPrefetchDataBlockBody {}; - u32 m_RegionDataOffset {0}; - u16 m_RegionInfoBytes {0}; + const StreamSoundPrefetchFile::FileHeader* m_pHeader{}; + const StreamSoundFile::InfoBlockBody* m_pInfoBlockBody{}; + const StreamSoundPrefetchFile::PrefetchDataBlockBody* m_pPrefetchDataBlockBody{}; + u32 m_RegionDataOffset{0}; + u16 m_RegionInfoBytes{0}; }; static_assert(sizeof(StreamSoundPrefetchFileReader) == 0x28); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_StreamSoundRuntime.h b/include/nn/atk/atk_StreamSoundRuntime.h index d37b55de..ed947f3c 100644 --- a/include/nn/atk/atk_StreamSoundRuntime.h +++ b/include/nn/atk/atk_StreamSoundRuntime.h @@ -5,6 +5,7 @@ #include namespace nn::atk::detail { + class StreamSoundRuntime { public: constexpr static u32 DefaultStreamBlockCount = 5; @@ -12,29 +13,29 @@ class StreamSoundRuntime { StreamSoundRuntime(); ~StreamSoundRuntime(); - bool Initialize(s32 soundCount, void** pOutAllocatedAddr, const void* endAddr, + bool Initialize(s32 soundCount, void** pOutAllocatedAddr, const void* endAddr, void* streamInstanceBuffer, size_t streamInstanceBufferSize); - + static size_t GetRequiredStreamInstanceSize(s32 soundCount); - bool SetupStreamBuffer(const SoundArchive* pSoundArchive, void* strmBuffer, + bool SetupStreamBuffer(const SoundArchive* pSoundArchive, void* strmBuffer, size_t strmBufferSize); - bool SetupStreamBuffer(const SoundArchive* pSoundArchive, void* strmBuffer, + bool SetupStreamBuffer(const SoundArchive* pSoundArchive, void* strmBuffer, size_t strmBufferSize, driver::StreamBufferPool* strmBufferPool); size_t GetRequiredStreamBufferSize(const SoundArchive* soundArchive) const; static u32 GetRequiredStreamBufferTimes(const SoundArchive* soundArchive); - bool SetupStreamCacheBuffer(const SoundArchive* pSoundArchive, void* streamCacheBuffer, + bool SetupStreamCacheBuffer(const SoundArchive* pSoundArchive, void* streamCacheBuffer, size_t streamCacheSize); void Finalize(); - static size_t GetRequiredMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, - s32 alignment); + static size_t + GetRequiredMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, + s32 alignment); - static size_t GetRequiredStreamCacheSize(const SoundArchive* pSoundArchive, - size_t); + static size_t GetRequiredStreamCacheSize(const SoundArchive* pSoundArchive, size_t); s32 GetActiveCount() const; s32 GetActiveChannelCount() const; @@ -45,17 +46,17 @@ class StreamSoundRuntime { void Update(); #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) - StreamSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, + StreamSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, BasicSound::AmbientInfo* ambientArgInfo); #else - StreamSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, - BasicSound::AmbientInfo* ambientArgInfo, OutputReceiver* pOutputReceiver); + StreamSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, + BasicSound::AmbientInfo* ambientArgInfo, + OutputReceiver* pOutputReceiver); #endif - SoundStartable::StartResult PrepareImpl(const SoundArchive* pSoundArchive, - const SoundDataManager* pSoundDataManager, - SoundArchive::ItemId soundId, - StreamSound* sound, - const SoundArchive::SoundInfo* commonInfo, + SoundStartable::StartResult PrepareImpl(const SoundArchive* pSoundArchive, + const SoundDataManager* pSoundDataManager, + SoundArchive::ItemId soundId, StreamSound* sound, + const SoundArchive::SoundInfo* commonInfo, const StartInfoReader& startInfoReader); void DumpMemory(const SoundArchive* pSoundArchive) const; @@ -72,4 +73,5 @@ static_assert(sizeof(StreamSoundRuntime) == 0xb0); #else static_assert(sizeof(StreamSoundRuntime) == 0xb8); #endif + } // namespace nn::atk::detail diff --git a/include/nn/atk/atk_StreamTrack.h b/include/nn/atk/atk_StreamTrack.h index 6e132d69..7e6375c5 100644 --- a/include/nn/atk/atk_StreamTrack.h +++ b/include/nn/atk/atk_StreamTrack.h @@ -6,6 +6,7 @@ #include namespace nn::atk::detail::driver { + struct StreamChannel { void AppendWaveBuffer(WaveBuffer* pBuffer, bool lastFlag); os::Tick GetProcessTick(const SoundProfile& profile); @@ -22,7 +23,7 @@ class StreamTrack { public: StreamTrack() = default; ~StreamTrack(); - + private: bool m_ActiveFlag; StreamChannel* m_pChannels[2]; @@ -41,4 +42,5 @@ class StreamTrack { OutputParam m_TvParam; }; static_assert(sizeof(StreamTrack) == 0x80); -} // namespace nn::atk::detail::driver \ No newline at end of file + +} // namespace nn::atk::detail::driver diff --git a/include/nn/atk/atk_SubMix.h b/include/nn/atk/atk_SubMix.h index d5249e3c..14bbd48d 100644 --- a/include/nn/atk/atk_SubMix.h +++ b/include/nn/atk/atk_SubMix.h @@ -8,7 +8,9 @@ namespace nn::atk { namespace detail::driver { + class HardwareManager; + }; class SubMix : OutputMixer { @@ -48,7 +50,7 @@ class SubMix : OutputMixer { bool m_IsSoundSendClampEnabledArray[24]; }; static_assert(sizeof(SubMixParam) == 0x38); - + class VolumeData { public: VolumeData(); @@ -64,39 +66,36 @@ class SubMix : OutputMixer { static_assert(sizeof(VolumeData) == 0x14); SubMix(); - - static size_t GetRequiredMemorySize(s32 srcBusCount, s32 srcChannelCount, - s32 dstBusCount, s32 dstChannelCount); - static size_t GetRequiredMemorySize(s32 srcBusCount, s32 srcChannelCount, - s32 dstBusCount, s32 dstChannelCount, - bool isEffectEnabled); - static size_t GetRequiredMemorySize(s32 srcBusCount, s32 srcChannelCount, - s32 dstBusCount, s32 dstChannelCount, - bool isEffectEnabled, bool isInternalCall); - + + static size_t GetRequiredMemorySize(s32 srcBusCount, s32 srcChannelCount, s32 dstBusCount, + s32 dstChannelCount); + static size_t GetRequiredMemorySize(s32 srcBusCount, s32 srcChannelCount, s32 dstBusCount, + s32 dstChannelCount, bool isEffectEnabled); + static size_t GetRequiredMemorySize(s32 srcBusCount, s32 srcChannelCount, s32 dstBusCount, + s32 dstChannelCount, bool isEffectEnabled, + bool isInternalCall); + static size_t GetRequiredMemorySizeImpl(const SubMixParam& param); - static size_t GetRequiredMemorySize(s32 srcBusCount, s32 dstBusCount, - const OutputReceiver* pReceiver, - bool isEffectEnabled); + static size_t GetRequiredMemorySize(s32 srcBusCount, s32 dstBusCount, + const OutputReceiver* pReceiver, bool isEffectEnabled); static size_t GetRequiredMemorySize(const SubMixParam& param); - bool Initialize(s32 srcBusCount, s32 srcChannelCount, s32 dstBusCount, - s32 dstChannelCount, void* buffer, size_t bufferSize); - bool Initialize(s32 srcBusCount, s32 srcChannelCount, s32 dstBusCount, - s32 dstChannelCount, bool isEffectEnabled, void* buffer, - size_t bufferSize); - bool Initialize(s32 srcBusCount, s32 srcChannelCount, s32 dstBusCount, - s32 dstChannelCount, bool isEffectEnabled, bool isInternalCall, + bool Initialize(s32 srcBusCount, s32 srcChannelCount, s32 dstBusCount, s32 dstChannelCount, void* buffer, size_t bufferSize); - + bool Initialize(s32 srcBusCount, s32 srcChannelCount, s32 dstBusCount, s32 dstChannelCount, + bool isEffectEnabled, void* buffer, size_t bufferSize); + bool Initialize(s32 srcBusCount, s32 srcChannelCount, s32 dstBusCount, s32 dstChannelCount, + bool isEffectEnabled, bool isInternalCall, void* buffer, size_t bufferSize); + bool InitializeImpl(const SubMixParam& param, void* buffer, size_t bufferSize); - bool InitializeImpl(const SubMixParam& param, void* buffer, size_t bufferSize, bool isInternalCall); + bool InitializeImpl(const SubMixParam& param, void* buffer, size_t bufferSize, + bool isInternalCall); - bool Initialize(s32 srcBusCount, s32 dstBusCount, const OutputReceiver* pReceiver, - void* buffer, size_t bufferSize); - bool Initialize(s32 srcBusCount, s32 dstBusCount, const OutputReceiver* pReceiver, + bool Initialize(s32 srcBusCount, s32 dstBusCount, const OutputReceiver* pReceiver, void* buffer, + size_t bufferSize); + bool Initialize(s32 srcBusCount, s32 dstBusCount, const OutputReceiver* pReceiver, bool isEffectEnabled, void* buffer, size_t bufferSize); bool Initialize(const SubMixParam& param, void* buffer, size_t bufferSize); @@ -108,16 +107,16 @@ class SubMix : OutputMixer { void UpdateBusMixVolume(s32 bus); void UpdateChannelMixVolume(s32 bus); - void UpdateMixVolume(s32 srcBus, s32 srcChannel,s32 dstBus,s32 dstChannel); + void UpdateMixVolume(s32 srcBus, s32 srcChannel, s32 dstBus, s32 dstChannel); void SetDestination(OutputReceiver* pReceiver); void ApplyDestination(); f32 GetSend(s32 srcBus, s32 dstBus) const; - f32 GetSendImpl(s32 srcBus, s32 srcChannel,s32 dstBus,s32 dstChannel) const; + f32 GetSendImpl(s32 srcBus, s32 srcChannel, s32 dstBus, s32 dstChannel) const; void SetSend(s32 srcBus, s32 dstBus, f32 send); - void SetSendImpl(s32 srcBus, s32 srcChannel,s32 dstBus,s32 dstChannel, f32 send); + void SetSendImpl(s32 srcBus, s32 srcChannel, s32 dstBus, s32 dstChannel, f32 send); void SetBusVolume(s32 bus, f32 volume, s32 fadeFrame); f32 GetBusVolume(s32 bus) const; @@ -185,4 +184,5 @@ class SubMix : OutputMixer { bool m_IsAppliedOutputReceiver; }; static_assert(sizeof(SubMix) == 0xf8); -} // namespace nn::atk \ No newline at end of file + +} // namespace nn::atk diff --git a/include/nn/atk/atk_Task.h b/include/nn/atk/atk_Task.h index aa8148d2..3eedfd42 100644 --- a/include/nn/atk/atk_Task.h +++ b/include/nn/atk/atk_Task.h @@ -5,6 +5,7 @@ #include namespace nn::atk::detail { + class TaskManager; class Task { @@ -18,7 +19,7 @@ class Task { }; Task(); - + virtual ~Task(); void SetId(u32 id) { m_Id = id; } @@ -43,4 +44,5 @@ class Task { u32 m_Id; }; static_assert(sizeof(Task) == 0x48); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_TaskManager.h b/include/nn/atk/atk_TaskManager.h index 24d3fe03..c5e168c2 100644 --- a/include/nn/atk/atk_TaskManager.h +++ b/include/nn/atk/atk_TaskManager.h @@ -5,9 +5,11 @@ #include namespace nn::atk::detail { + class TaskManager { public: - using TaskList = util::IntrusiveList>; + using TaskList = + util::IntrusiveList>; enum Message { Message_Append, @@ -44,7 +46,7 @@ class TaskManager { void RemoveTaskById(u32 id); void CancelAllTask(); - + void WaitTask(); void CancelWaitTask(); @@ -64,4 +66,5 @@ static_assert(sizeof(TaskManager) == 0x1e0); #else static_assert(sizeof(TaskManager) == 0x1d8); #endif -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_TaskProfileReader.h b/include/nn/atk/atk_TaskProfileReader.h index 0e59224d..4fc72d4d 100644 --- a/include/nn/atk/atk_TaskProfileReader.h +++ b/include/nn/atk/atk_TaskProfileReader.h @@ -4,15 +4,17 @@ #include #include +#include #include #include -#include namespace nn::atk { namespace detail::driver { + class StreamSoundPlayer; -} // namespace nn::atk::detail::driver + +} // namespace detail::driver struct TaskProfile { enum TaskProfileType { @@ -36,7 +38,7 @@ struct TaskProfile { #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) void SetTick(const os::Tick& beginTick, const os::Tick& endTick); #else - void SetData(const os::Tick& beginTick, const os::Tick& endTick, + void SetData(const os::Tick& beginTick, const os::Tick& endTick, const detail::IStreamDataDecoder::CacheProfile& cacheProfile); #endif @@ -76,11 +78,11 @@ struct TaskProfile { #endif #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) - void SetData(const os::Tick& beginTick, const os::Tick& endTick, + void SetData(const os::Tick& beginTick, const os::Tick& endTick, detail::IStreamDataDecoder::DecodeProfile* decodeProfile); #else - void SetData(const os::Tick& beginTick, const os::Tick& endTick, - const detail::IStreamDataDecoder::DecodeProfile& decodeProfile, + void SetData(const os::Tick& beginTick, const os::Tick& endTick, + const detail::IStreamDataDecoder::DecodeProfile& decodeProfile, const detail::IStreamDataDecoder::CacheProfile& cacheProfile); #endif @@ -122,17 +124,17 @@ using TaskProfileReader = AtkProfileReader; class TaskProfileLogger { public: - using TaskProfileReaderList = util::IntrusiveList>; - + using TaskProfileReaderList = util::IntrusiveList< + TaskProfileReader, + util::IntrusiveListMemberNodeTraits>; + TaskProfileLogger(); void Record(const TaskProfile& profile); void RegisterReader(TaskProfileReader& profileReader); void UnregisterReader(const TaskProfileReader& profileReader); - + void SetProfilingEnabled(bool isEnabledProfiling); void Finalize(); @@ -143,4 +145,5 @@ class TaskProfileLogger { bool m_IsProfilingEnabled; }; static_assert(sizeof(TaskProfileLogger) == 0x38); -} // namespace nn::atk \ No newline at end of file + +} // namespace nn::atk diff --git a/include/nn/atk/atk_TaskThread.h b/include/nn/atk/atk_TaskThread.h index eae3d2b2..c79549e9 100644 --- a/include/nn/atk/atk_TaskThread.h +++ b/include/nn/atk/atk_TaskThread.h @@ -5,6 +5,7 @@ #include namespace nn::atk::detail { + class TaskThread : fnd::Thread::Handler { public: TaskThread(); @@ -12,9 +13,9 @@ class TaskThread : fnd::Thread::Handler { void Destroy(); - bool Create(s32 priority, void* stackBase, size_t stackSize, - s32 idealCoreNumber, u32 affinityMask, FsPriority fsPriority); - + bool Create(s32 priority, void* stackBase, size_t stackSize, s32 idealCoreNumber, + u32 affinityMask, FsPriority fsPriority); + u32 Run(void* param) override; private: @@ -25,4 +26,5 @@ class TaskThread : fnd::Thread::Handler { FsPriority m_FsPriority; }; static_assert(sizeof(TaskThread) == 0x220); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_ThreadInfoReader.h b/include/nn/atk/atk_ThreadInfoReader.h index f9713e88..655c943a 100644 --- a/include/nn/atk/atk_ThreadInfoReader.h +++ b/include/nn/atk/atk_ThreadInfoReader.h @@ -6,9 +6,10 @@ namespace nn::atk { namespace detail { + class ThreadInfoRecorder { public: - static const size_t BufferMinimumSize {}; + static const size_t BufferMinimumSize{}; ThreadInfoRecorder(); @@ -31,12 +32,17 @@ class ThreadInfoRecorder { void RecordFooter() { // TODO } - + util::IntrusiveListNode m_List; private: - void* AllocateInfoBuffer([[maybe_unused]] u32 count, [[maybe_unused]] size_t size) { return nullptr; } - void* AllocateBuffer([[maybe_unused]] u32 count, [[maybe_unused]] size_t size1, [[maybe_unused]]size_t size2) { return nullptr; } + void* AllocateInfoBuffer([[maybe_unused]] u32 count, [[maybe_unused]] size_t size) { + return nullptr; + } + void* AllocateBuffer([[maybe_unused]] u32 count, [[maybe_unused]] size_t size1, + [[maybe_unused]] size_t size2) { + return nullptr; + } void* m_Buffer; size_t m_BufferSize; @@ -46,10 +52,12 @@ class ThreadInfoRecorder { std::atomic_bool m_IsAllocationFailed; }; static_assert(sizeof(ThreadInfoRecorder) == 0x38); + } // namespace detail using SoundThreadInfoRecorder = detail::ThreadInfoRecorder; -using SoundThreadInfoRecorderList = util::IntrusiveList>; -} // namespace nn::atk \ No newline at end of file +using SoundThreadInfoRecorderList = util::IntrusiveList< + SoundThreadInfoRecorder, + util::IntrusiveListMemberNodeTraits>; + +} // namespace nn::atk diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index e103c57c..f88b2ca8 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -14,6 +14,7 @@ class SoundArchivePlayer; class OutputReceiver; namespace detail { + class PlayerHeapDataManager; class SoundArchiveLoader; struct LoadItemInfo; @@ -261,10 +262,10 @@ class Util { struct WaveIdTable { Table table; - const WaveId* GetWaveId(u32 index) const { + const WaveId* GetWaveId(u32 index) const { if (index >= table.count) return nullptr; - + return &table.item[index]; } @@ -329,4 +330,4 @@ class Util { } // namespace detail -} // namespace nn::atk \ No newline at end of file +} // namespace nn::atk diff --git a/include/nn/atk/atk_ValueArray.h b/include/nn/atk/atk_ValueArray.h index 666946c1..2d8cadea 100644 --- a/include/nn/atk/atk_ValueArray.h +++ b/include/nn/atk/atk_ValueArray.h @@ -84,4 +84,4 @@ class ValueArray { int m_Count{0}; }; -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_Voice.h b/include/nn/atk/atk_Voice.h index d11d00ed..b57563e5 100644 --- a/include/nn/atk/atk_Voice.h +++ b/include/nn/atk/atk_Voice.h @@ -6,6 +6,7 @@ #include namespace nn::atk::detail { + class Voice { public: constexpr static s32 PriorityMin = 0; @@ -34,7 +35,7 @@ class Voice { position_t GetPlayPosition() const; bool SetMonoFilter(bool enable, u16 cutoff); - void SetBiquadFilter(bool enable, const BiquadFilterCoefficients* coef); + void SetBiquadFilter(bool enable, const BiquadFilterCoefficients* coef); void UpdateVoiceStatus(); @@ -67,7 +68,7 @@ static_assert(sizeof(Voice) == 0xe0); class VirtualVoiceManager : Util::Singleton { public: constexpr static s32 InvalidVoiceId = -1; - + constexpr static u32 VirtualVoiceCount = 256; constexpr static u32 VirtualVoiceElementCount = 8; @@ -75,9 +76,9 @@ class VirtualVoiceManager : Util::Singleton { bool AllocVirtualVoice(); void FreeVirtualVoice(u32); - + void UpdateVoiceInfo(); - + s32 GetAllocatedVirtualVoiceCount() const; s32 GetUnreleasedLowLevelVoiceCount() const; @@ -89,4 +90,5 @@ class VirtualVoiceManager : Util::Singleton { util::BitFlagSet m_VoiceInfoDirtyTable[2]; }; static_assert(sizeof(VirtualVoiceManager) == 0x4868); -} // namespace nn::atk::voice \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_VoiceCommand.h b/include/nn/atk/atk_VoiceCommand.h index e5b45530..f947a204 100644 --- a/include/nn/atk/atk_VoiceCommand.h +++ b/include/nn/atk/atk_VoiceCommand.h @@ -6,6 +6,7 @@ #include namespace nn::atk::detail { + struct VoiceCommandPlay : Command { u32 voiceId; SampleFormat sampleFormat; @@ -66,7 +67,6 @@ static_assert(sizeof(VoiceCommandAppendWaveBuffer) == 0x100); class VoiceReplyCommand : CommandManager { public: static void ProcessCommandList(Command* commandList); - }; static_assert(sizeof(VoiceReplyCommand) == 0x310); @@ -93,4 +93,5 @@ class LowLevelVoiceCommand : CommandManager { s32 m_WaveBufferPacketCount; }; static_assert(sizeof(LowLevelVoiceCommand) == 0x320); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_VolumeThroughModePacket.h b/include/nn/atk/atk_VolumeThroughModePacket.h index 87e49449..21da302c 100644 --- a/include/nn/atk/atk_VolumeThroughModePacket.h +++ b/include/nn/atk/atk_VolumeThroughModePacket.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail { + class VolumeThroughModePacket { public: using VolumeThroughModeArray = ValueArray; @@ -25,4 +26,5 @@ class VolumeThroughModePacket { float m_BinaryVolume; }; static_assert(sizeof(VolumeThroughModePacket) == 0x18); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_WavBinary.h b/include/nn/atk/atk_WavBinary.h index b79db808..e77e0caf 100644 --- a/include/nn/atk/atk_WavBinary.h +++ b/include/nn/atk/atk_WavBinary.h @@ -20,7 +20,7 @@ struct ChunkHeader { static_assert(sizeof(ChunkHeader) == 0x8); struct RiffChunk { - static const u32 ValidId {0x46464952}; // "RIFF" + static const u32 ValidId{0x46464952}; // "RIFF" RiffChunk() = default; @@ -32,7 +32,7 @@ struct RiffChunk { static_assert(sizeof(RiffChunk) == 0xc); struct FmtChunk { - static const u32 ValidId{0x20746d66}; // "fmt " + static const u32 ValidId{0x20746d66}; // "fmt " static const u16 FormatPcm{SampleFormat_PcmS16}; FmtChunk() = default; @@ -52,8 +52,8 @@ struct FmtChunk { static_assert(sizeof(FmtChunk) == 0x18); struct DataChunk { - static const u32 ValidId {0x61746164}; // "data" - + static const u32 ValidId{0x61746164}; // "data" + DataChunk() = default; bool IsValid(); @@ -64,11 +64,11 @@ static_assert(sizeof(DataChunk) == 0x8); struct WaveBinaryHeader { WaveBinaryHeader() = default; - + RiffChunk riffChunk; FmtChunk fmtChunk; DataChunk dataChunk; }; static_assert(sizeof(WaveBinaryHeader) == 0x2c); -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_WavOutFileStream.h b/include/nn/atk/atk_WavOutFileStream.h index b0367bd0..88f595f0 100644 --- a/include/nn/atk/atk_WavOutFileStream.h +++ b/include/nn/atk/atk_WavOutFileStream.h @@ -46,4 +46,4 @@ class WavOutFileStream { }; static_assert(sizeof(WavOutFileStream) == 0x30); -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_WaveArchiveFile.h b/include/nn/atk/atk_WaveArchiveFile.h index 337de902..0c110058 100644 --- a/include/nn/atk/atk_WaveArchiveFile.h +++ b/include/nn/atk/atk_WaveArchiveFile.h @@ -34,9 +34,7 @@ struct WaveArchiveFile { u32 GetSize(u32 index) const { return table.item[index].size; } - u32 GetOffsetFromFileBlockBody(u32 index) const { - return table.item[index].offset; - } + u32 GetOffsetFromFileBlockBody(u32 index) const { return table.item[index].offset; } static const u32 InvalidOffset = 0xffffffff; }; @@ -56,4 +54,4 @@ struct WaveArchiveFile { static_assert(sizeof(FileBlock) == 0xc); }; -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_WaveArchiveFileReader.h b/include/nn/atk/atk_WaveArchiveFileReader.h index 611eca94..805ae50a 100644 --- a/include/nn/atk/atk_WaveArchiveFileReader.h +++ b/include/nn/atk/atk_WaveArchiveFileReader.h @@ -52,4 +52,4 @@ class WaveArchiveFileReader { }; static_assert(sizeof(WaveArchiveFileReader) == 0x20); -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_WaveFile.h b/include/nn/atk/atk_WaveFile.h index 01604e5a..9fefe503 100644 --- a/include/nn/atk/atk_WaveFile.h +++ b/include/nn/atk/atk_WaveFile.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail { + struct WaveFile { struct InfoBlock; struct DataBlock; @@ -57,4 +58,5 @@ struct WaveFile { }; }; }; -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_WaveFileReader.h b/include/nn/atk/atk_WaveFileReader.h index 9b518a1a..186721bf 100644 --- a/include/nn/atk/atk_WaveFileReader.h +++ b/include/nn/atk/atk_WaveFileReader.h @@ -1,12 +1,13 @@ #pragma once -#include #include +#include namespace nn::atk::detail { + class WaveFileReader { public: - static const int SignatureFile = 0x56415746; // FWAV + static const int SignatureFile = 0x56415746; // FWAV static SampleFormat GetSampleFormat(u8 format); @@ -18,15 +19,16 @@ class WaveFileReader { bool ReadWaveInfo(WaveInfo* info, const void* waveDataOffsetOrigin) const; - const void* GetWaveDataAddress(const WaveFile::ChannelInfo* info, + const void* GetWaveDataAddress(const WaveFile::ChannelInfo* info, [[maybe_unused]] const void* waveDataOffsetOrigin) const; private: - const WaveFile::FileHeader* m_pHeader {}; - const WaveFile::InfoBlockBody* m_pInfoBlockBody {}; - const void* m_pDataBlockBody {}; + const WaveFile::FileHeader* m_pHeader{}; + const WaveFile::InfoBlockBody* m_pInfoBlockBody{}; + const void* m_pDataBlockBody{}; DspadpcmReader m_DspadpcmReader; s8 m_WaveType; }; static_assert(sizeof(WaveFileReader) == 0x28); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_WaveSound.h b/include/nn/atk/atk_WaveSound.h index 9b984fbc..b5cb66c8 100644 --- a/include/nn/atk/atk_WaveSound.h +++ b/include/nn/atk/atk_WaveSound.h @@ -1,11 +1,12 @@ #pragma once -#include #include #include +#include #include -namespace nn::atk::detail { +namespace nn::atk::detail { + class WaveSound; using WaveSoundInstanceManager = SoundInstanceManager; @@ -21,10 +22,10 @@ class WaveSound : BasicSound { #endif void Finalize() override; - void Prepare(const void* wsdFile, const void* waveFile, + void Prepare(const void* wsdFile, const void* waveFile, const driver::WaveSoundPlayer::StartInfo& startInfo, s8 waveType); - void RegisterDataLoadTask(const driver::WaveSoundLoader::LoadInfo& loadInfo, + void RegisterDataLoadTask(const driver::WaveSoundLoader::LoadInfo& loadInfo, const driver::WaveSoundPlayer::StartInfo& startInfo); void SetChannelPriority(s32 priority); @@ -32,7 +33,7 @@ class WaveSound : BasicSound { void InitializeChannelParam(s32 priority, bool isReleasePriorityFix); void OnUpdatePlayerPriority() override; - + bool IsAttachedTempSpecialHandle() override; void DetachTempSpecialHandle() override; @@ -65,4 +66,5 @@ static_assert(sizeof(WaveSound) == 0x3b0); #else static_assert(sizeof(WaveSound) == 0x3e0); #endif -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_WaveSoundFile.h b/include/nn/atk/atk_WaveSoundFile.h index f7c9ccef..279b07ee 100644 --- a/include/nn/atk/atk_WaveSoundFile.h +++ b/include/nn/atk/atk_WaveSoundFile.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail { + struct WaveSoundFile { struct InfoBlock; struct FileHeader : Util::SoundFileHeader { @@ -16,18 +17,12 @@ struct WaveSoundFile { const Util::WaveIdTable& GetWaveIdTable() const; const Util::ReferenceTable& GetWaveSoundDataReferenceTable() const; - - u32 GetWaveIdCount() const { - return GetWaveIdTable().GetCount(); - } - u32 GetWaveSoundCount() const { - return GetWaveSoundDataReferenceTable().count; - } + u32 GetWaveIdCount() const { return GetWaveIdTable().GetCount(); } + + u32 GetWaveSoundCount() const { return GetWaveSoundDataReferenceTable().count; } - const Util::WaveId* GetWaveId(u32 index) const { - return GetWaveIdTable().GetWaveId(index); - } + const Util::WaveId* GetWaveId(u32 index) const { return GetWaveIdTable().GetWaveId(index); } const WaveSoundData& GetWaveSoundData(u32 index) const; }; @@ -51,13 +46,9 @@ struct WaveSoundFile { const Util::ReferenceTable& GetTrackInfoReferenceTable() const; const Util::ReferenceTable& GetNoteInfoReferenceTable() const; - u32 GetTrackCount() const { - return GetTrackInfoReferenceTable().count; - } + u32 GetTrackCount() const { return GetTrackInfoReferenceTable().count; } - u32 GetNoteCount() const { - return GetNoteInfoReferenceTable().count; - } + u32 GetNoteCount() const { return GetNoteInfoReferenceTable().count; } const TrackInfo& GetTrackInfo(u32 index) const; const NoteInfo& GetNoteInfo(u32 index) const; @@ -84,9 +75,7 @@ struct WaveSoundFile { const Util::ReferenceTable& GetNoteEventReferenceTable() const; - u32 GetNoteEventCount() const { - return GetNoteEventReferenceTable().count; - } + u32 GetNoteEventCount() const { return GetNoteEventReferenceTable().count; } const NoteEvent& GetNoteEvent(u32 index) const; }; @@ -114,4 +103,5 @@ struct WaveSoundFile { }; static_assert(sizeof(NoteInfo) == 0x8); }; -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_WaveSoundFileReader.h b/include/nn/atk/atk_WaveSoundFileReader.h index cbc902c6..c1f5ff93 100644 --- a/include/nn/atk/atk_WaveSoundFileReader.h +++ b/include/nn/atk/atk_WaveSoundFileReader.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail { + struct WaveSoundInfo { float pitch; AdshrCurve adshr; @@ -26,14 +27,13 @@ struct WaveSoundNoteInfo { u8 volume; float pitch; - WaveSoundNoteInfo() - : adshr(0, 0, 0, 0, 0) {}; + WaveSoundNoteInfo() : adshr(0, 0, 0, 0, 0) {}; }; static_assert(sizeof(WaveSoundNoteInfo) == 0x18); class WaveSoundFileReader { public: - static const u32 SignatureFile{0x44535746}; // FWSD + static const u32 SignatureFile{0x44535746}; // FWSD explicit WaveSoundFileReader(const void* waveSoundFile); @@ -46,7 +46,7 @@ class WaveSoundFileReader { bool ReadWaveSoundInfo(WaveSoundInfo* dst, u32 index) const; bool ReadNoteInfo(WaveSoundNoteInfo* dst, u32 index, u32 noteIndex) const; - + bool IsFilterSupportedVersion() const; private: @@ -54,4 +54,5 @@ class WaveSoundFileReader { const WaveSoundFile::InfoBlockBody* m_pInfoBlockBody{}; }; static_assert(sizeof(WaveSoundFileReader) == 0x10); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_WaveSoundHandle.h b/include/nn/atk/atk_WaveSoundHandle.h index 2d221b3b..fce5ec30 100644 --- a/include/nn/atk/atk_WaveSoundHandle.h +++ b/include/nn/atk/atk_WaveSoundHandle.h @@ -6,8 +6,10 @@ namespace nn::atk { namespace detail { + class WaveSound; -} // namespace nn::atk::detail + +} // namespace detail class WaveSoundHandle { public: @@ -24,4 +26,5 @@ class WaveSoundHandle { private: detail::WaveSound* m_pSound; }; -} // namespace nn::atk \ No newline at end of file + +} // namespace nn::atk diff --git a/include/nn/atk/atk_WaveSoundLoader.h b/include/nn/atk/atk_WaveSoundLoader.h index 240511b1..35210580 100644 --- a/include/nn/atk/atk_WaveSoundLoader.h +++ b/include/nn/atk/atk_WaveSoundLoader.h @@ -1,12 +1,13 @@ #pragma once -#include #include #include #include +#include #include namespace nn::atk::detail::driver { + class WaveSoundLoader; using WaveSoundLoaderManager = LoaderManager; @@ -38,7 +39,7 @@ class WaveSoundLoader { class DataLoadTask : Task { public: ~DataLoadTask() override; - + void Initialize(); bool TryAllocPlayerHeap(); @@ -87,4 +88,5 @@ class WaveSoundLoader { PlayerHeapDataManager m_PlayerHeapDataManager; util::IntrusiveListNode m_LinkForLoaderManager; }; -} // namespace nn::atk::detail::driver \ No newline at end of file + +} // namespace nn::atk::detail::driver diff --git a/include/nn/atk/atk_WaveSoundPlayer.h b/include/nn/atk/atk_WaveSoundPlayer.h index 182d82a3..fa7ef90e 100644 --- a/include/nn/atk/atk_WaveSoundPlayer.h +++ b/include/nn/atk/atk_WaveSoundPlayer.h @@ -6,6 +6,7 @@ #include namespace nn::atk::detail { + struct WaveSoundDataInfo { bool loopFlag; s32 sampleRate; @@ -17,7 +18,8 @@ struct WaveSoundDataInfo { }; static_assert(sizeof(WaveSoundDataInfo) == 0x30); -namespace driver { +namespace driver { + class WaveSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::PlayerCallback { public: enum StartOffsetType { @@ -32,8 +34,8 @@ class WaveSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::PlayerCa ResState_Assigned, }; - constexpr static s32 SignatureFile = 0x44535746; // FWSD - + constexpr static s32 SignatureFile = 0x44535746; // FWSD + constexpr static u32 PauseReleaseValue = 127; constexpr static u32 MuteReleaseValue = 127; constexpr static u32 DefaultPriority = 64; @@ -99,8 +101,8 @@ class WaveSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::PlayerCa bool StartChannel(); void UpdateChannel(); - static void ChannelCallbackFunc(Channel* dropChannel, - Channel::ChannelCallbackStatus status, void* userData); + static void ChannelCallbackFunc(Channel* dropChannel, Channel::ChannelCallbackStatus status, + void* userData); void OnUpdateFrameSoundThread() override; void OnUpdateFrameSoundThreadWithAudioFrameFrequency() override; @@ -143,5 +145,6 @@ static_assert(sizeof(WaveSoundPlayer) == 0x190); #else static_assert(sizeof(WaveSoundPlayer) == 0x1a0); #endif -} // namespace nn::atk::detail::driver -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace driver +} // namespace nn::atk::detail diff --git a/include/nn/atk/atk_WaveSoundRuntime.h b/include/nn/atk/atk_WaveSoundRuntime.h index 3b025b34..2a94713f 100644 --- a/include/nn/atk/atk_WaveSoundRuntime.h +++ b/include/nn/atk/atk_WaveSoundRuntime.h @@ -4,6 +4,7 @@ #include namespace nn::atk::detail { + class WaveSoundRuntime { public: WaveSoundRuntime(); @@ -12,8 +13,9 @@ class WaveSoundRuntime { bool Initialize(s32 soundCount, void** pOutAllocatedAddr, const void* endAddr); void Finalize(); - static size_t GetRequiredMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, - s32 alignment); + static size_t + GetRequiredMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, + s32 alignment); s32 GetActiveCount() const; s32 GetFreeWaveSoundCount() const; @@ -21,20 +23,19 @@ class WaveSoundRuntime { void SetupUserParam(void** startAddr, size_t adjustSize); void Update(); - + #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) - WaveSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, + WaveSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, BasicSound::AmbientInfo* ambientArgInfo); #else - WaveSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, + WaveSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, BasicSound::AmbientInfo* ambientArgInfo, OutputReceiver* pOutputReceiver); #endif - SoundStartable::StartResult PrepareImpl(const SoundArchive* pSoundArchive, - const SoundDataManager* pSoundDataManager, - SoundArchive::ItemId soundId, - WaveSound* sound, - const SoundArchive::SoundInfo* commonInfo, + SoundStartable::StartResult PrepareImpl(const SoundArchive* pSoundArchive, + const SoundDataManager* pSoundDataManager, + SoundArchive::ItemId soundId, WaveSound* sound, + const SoundArchive::SoundInfo* commonInfo, const StartInfoReader& startInfoReader); void DumpMemory(const SoundArchive*) const; @@ -49,4 +50,5 @@ static_assert(sizeof(WaveSoundRuntime) == 0x80); #else static_assert(sizeof(WaveSoundRuntime) == 0x88); #endif + } // namespace nn::atk::detail diff --git a/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h b/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h index f63bcb38..ce0e13b9 100644 --- a/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h +++ b/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h @@ -7,6 +7,7 @@ #include namespace nn::atk::detail { + class AddonSoundArchiveContainer { public: AddonSoundArchiveContainer(); @@ -43,4 +44,5 @@ class AddonSoundArchiveContainer { os::Tick m_AddTick{0}; }; static_assert(sizeof(AddonSoundArchiveContainer) == 0x70); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/detail/atk_AdvancedWaveSound.h b/include/nn/atk/detail/atk_AdvancedWaveSound.h index ec1a6b9b..edadd7ef 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSound.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSound.h @@ -5,6 +5,7 @@ #include namespace nn::atk::detail { + class AdvancedWaveSound; class AdvancedWaveSoundHandle; @@ -25,7 +26,7 @@ class AdvancedWaveSound : BasicSound { void Prepare(const driver::AdvancedWaveSoundPlayer::PrepareParameter& parameter); void OnUpdatePlayerPriority() override; - + bool IsAttachedTempSpecialHandle() override; void DetachTempSpecialHandle() override; @@ -48,4 +49,5 @@ static_assert(sizeof(AdvancedWaveSound) == 0x980); #else static_assert(sizeof(AdvancedWaveSound) == 0x9b0); #endif -} // namespace nn::atk::detail + +} // namespace nn::atk::detail diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h b/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h index 1cc812ab..7486351f 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h @@ -5,10 +5,10 @@ #include namespace nn::atk::detail { -struct AdvancedWaveSoundFile { + +struct AdvancedWaveSoundFile { struct WaveSoundTrack; struct InfoBlockBody { - BinaryTypes::ReferenceTable* GetTrackReferenceTable() const; WaveSoundTrack* GetWaveSoundTrack(s32 index) const; @@ -25,7 +25,6 @@ struct AdvancedWaveSoundFile { struct WaveSoundClip; struct WaveSoundTrack { - BinaryTypes::ReferenceTable* GetClipReferenceTable() const; WaveSoundClip* GetWaveSoundClip(s32 index) const; @@ -47,9 +46,9 @@ struct AdvancedWaveSoundFile { static_assert(sizeof(WaveSoundClip) == 0x18); InfoBlock* GetBlock() const; - + util::BinaryFileHeader fileHeader; }; static_assert(sizeof(AdvancedWaveSoundFile) == 0x20); -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundFileReader.h b/include/nn/atk/detail/atk_AdvancedWaveSoundFileReader.h index 2d546c55..8d647c76 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundFileReader.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundFileReader.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail { + struct AdvancedWaveSoundClipInfo { u32 waveIndex; u32 position; @@ -43,4 +44,5 @@ class AdvancedWaveSoundFileReader { AdvancedWaveSoundFile::InfoBlockBody* m_pInfoBlockBody; }; static_assert(sizeof(AdvancedWaveSoundFileReader) == 0x8); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h b/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h index 05444888..b3262710 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h @@ -1,12 +1,13 @@ #pragma once -#include #include -#include #include #include +#include +#include namespace nn::atk::detail::driver { + class AdvancedWaveSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { public: struct ClipParam { @@ -64,7 +65,7 @@ class AdvancedWaveSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { void Pause(bool isPauseEnabled) override; void Prepare(const PrepareParameter& parameter); - + void SetupPlayer(); bool SetupTracks(); @@ -73,10 +74,8 @@ class AdvancedWaveSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { void InitializeTrackParams(); - bool StartClip(ClipParam* pClipParam, - SoundArchive::AdvancedWaveSoundInfo* pWaveSoundClipInfo); - bool UpdateClip(ClipParam* pClipParam, - SoundArchive::AdvancedWaveSoundInfo* pWaveSoundClipInfo); + bool StartClip(ClipParam* pClipParam, SoundArchive::AdvancedWaveSoundInfo* pWaveSoundClipInfo); + bool UpdateClip(ClipParam* pClipParam, SoundArchive::AdvancedWaveSoundInfo* pWaveSoundClipInfo); void ReleaseClip(ClipParam* pClipParam); void StopClip(ClipParam* pClipParam); @@ -104,4 +103,5 @@ static_assert(sizeof(AdvancedWaveSoundPlayer) == 0x768); #else static_assert(sizeof(AdvancedWaveSoundPlayer) == 0x778); #endif -} // namespace nn::atk::detail::driver \ No newline at end of file + +} // namespace nn::atk::detail::driver diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h b/include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h index a77b23ab..3e6fe2b5 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h @@ -2,13 +2,14 @@ #include +#include #include #include -#include #include -#include +#include namespace nn::atk::detail { + class AdvancedWaveSoundRuntime { public: AdvancedWaveSoundRuntime(); @@ -17,30 +18,30 @@ class AdvancedWaveSoundRuntime { bool Initialize(s32 soundCount, void** pOutAllocatedAddr, const void* endAddr); void Finalize(); - static size_t GetRequiredMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, - size_t alignmentSize); + static size_t + GetRequiredMemorySize(const SoundArchive::SoundArchivePlayerInfo& soundArchivePlayerInfo, + size_t alignmentSize); s32 GetActiveCount() const; s32 GetFreeAdvancedWaveSoundCount() const; void SetupUserParam(void** startAddr, size_t adjustSize); - + void Update(); #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) - AdvancedWaveSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, - s32 ambientPriority, BasicSound::AmbientInfo* ambientArgInfo); + AdvancedWaveSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, + BasicSound::AmbientInfo* ambientArgInfo); #else - AdvancedWaveSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, - s32 ambientPriority, BasicSound::AmbientInfo* ambientArgInfo, + AdvancedWaveSound* AllocSound(SoundArchive::ItemId soundId, s32 priority, s32 ambientPriority, + BasicSound::AmbientInfo* ambientArgInfo, OutputReceiver* pOutputReceiver); #endif - SoundStartable::StartResult PrepareImpl(const SoundArchive* pSoundArchive, - const SoundDataManager* pSoundDataManager, - SoundArchive::ItemId soundId, - AdvancedWaveSound* sound, - const SoundArchive::SoundInfo* commonInfo, + SoundStartable::StartResult PrepareImpl(const SoundArchive* pSoundArchive, + const SoundDataManager* pSoundDataManager, + SoundArchive::ItemId soundId, AdvancedWaveSound* sound, + const SoundArchive::SoundInfo* commonInfo, const StartInfoReader& startInfoReader); void DumpMemory(const SoundArchive*) const; @@ -53,4 +54,5 @@ static_assert(sizeof(AdvancedWaveSoundRuntime) == 0x30); #else static_assert(sizeof(AdvancedWaveSoundRuntime) == 0x38); #endif + } // namespace nn::atk::detail diff --git a/include/nn/atk/detail/atk_BinaryTypes.h b/include/nn/atk/detail/atk_BinaryTypes.h index 5ce66cec..ec91e936 100644 --- a/include/nn/atk/detail/atk_BinaryTypes.h +++ b/include/nn/atk/detail/atk_BinaryTypes.h @@ -4,6 +4,7 @@ #include namespace nn::atk::detail { + struct BinaryTypes { NN_NO_COPY(BinaryTypes); NN_NO_MOVE(BinaryTypes); @@ -22,4 +23,4 @@ struct BinaryTypes { struct ReferenceTable : Table {}; }; -}; \ No newline at end of file +}; // namespace nn::atk::detail diff --git a/include/nn/atk/detail/atk_IRegionInfoReadable.h b/include/nn/atk/detail/atk_IRegionInfoReadable.h index 676eb144..7cb2fe46 100644 --- a/include/nn/atk/detail/atk_IRegionInfoReadable.h +++ b/include/nn/atk/detail/atk_IRegionInfoReadable.h @@ -3,12 +3,13 @@ #include namespace nn::atk::detail { + class IRegionInfoReadable { public: virtual ~IRegionInfoReadable() = default; - - virtual bool ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo, - u32 regionIndex) const = 0; + + virtual bool ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo, u32 regionIndex) const = 0; }; static_assert(sizeof(IRegionInfoReadable) == 0x8); -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/detail/atk_IStreamDataDecoder.h b/include/nn/atk/detail/atk_IStreamDataDecoder.h index 62c713b3..ba69ebb8 100644 --- a/include/nn/atk/detail/atk_IStreamDataDecoder.h +++ b/include/nn/atk/detail/atk_IStreamDataDecoder.h @@ -6,17 +6,14 @@ namespace nn::atk::detail { namespace driver { + class StreamSoundPlayer; -} // namespace nn::atk::detail::driver + +} // namespace driver class IStreamDataDecoder { public: - enum DecodeType { - DecodeType_Normal, - DecodeType_Loop, - DecodeType_Idling, - DecodeType_Count - }; + enum DecodeType { DecodeType_Normal, DecodeType_Loop, DecodeType_Idling, DecodeType_Count }; struct DataInfo { s32 channelCount; @@ -38,10 +35,11 @@ class IStreamDataDecoder { position_t cacheStartPosition; size_t cachedLength; position_t cacheCurrentPosition; - driver::StreamSoundPlayer* player; + driver::StreamSoundPlayer* player; }; static_assert(sizeof(CacheProfile) == 0x20); virtual ~IStreamDataDecoder(); }; -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/detail/atk_IntrusiveList.h b/include/nn/atk/detail/atk_IntrusiveList.h index def3e50e..4c8121ba 100644 --- a/include/nn/atk/detail/atk_IntrusiveList.h +++ b/include/nn/atk/detail/atk_IntrusiveList.h @@ -3,16 +3,19 @@ #include namespace nn::atk::detail { + using IntrusiveListNode = util::IntrusiveListNode; template class IntrusiveList { public: - using ElementList = util::IntrusiveList>; + using ElementList = + util::IntrusiveList>; using Iterator = typename ElementList::iterator; using ConstIterator = typename ElementList::const_iterator; private: ElementList m_ListImpl; }; -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/include/nn/atk/detail/atk_MemoryFileStream.h b/include/nn/atk/detail/atk_MemoryFileStream.h index dda5b155..459cfec2 100644 --- a/include/nn/atk/detail/atk_MemoryFileStream.h +++ b/include/nn/atk/detail/atk_MemoryFileStream.h @@ -54,4 +54,4 @@ class MemoryFileStream : public fnd::FileStream { }; static_assert(sizeof(MemoryFileStream) == 0x20); -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/include/nn/atk/detail/atk_RegionManager.h b/include/nn/atk/detail/atk_RegionManager.h index f4410342..9d161af5 100644 --- a/include/nn/atk/detail/atk_RegionManager.h +++ b/include/nn/atk/detail/atk_RegionManager.h @@ -7,6 +7,7 @@ #include namespace nn::atk { + enum StreamRegionCallbackResult { StreamRegionCallbackResult_Finish, StreamRegionCallbackResult_Continue, @@ -21,9 +22,10 @@ struct StreamRegionCallbackParam { }; static_assert(sizeof(StreamRegionCallbackParam) == 0x58); -using StreamRegionCallback = StreamRegionCallbackResult(*)(StreamRegionCallbackParam*,void*); +using StreamRegionCallback = StreamRegionCallbackResult (*)(StreamRegionCallbackParam*, void*); namespace detail { + struct StreamDataInfoDetail; class RegionManager { @@ -38,18 +40,18 @@ class RegionManager { }; void Initialize(); - bool InitializeRegion(IRegionInfoReadable* pRegionReader, + bool InitializeRegion(IRegionInfoReadable* pRegionReader, StreamDataInfoDetail* pStreamDataInfo); bool IsPreparedForRegionJump() const; - - bool ChangeRegion(s32 currentRegionNo, IRegionInfoReadable* pRegionReader, + + bool ChangeRegion(s32 currentRegionNo, IRegionInfoReadable* pRegionReader, StreamDataInfoDetail* pStreamDataInfo); - bool SetRegionInfo(const StreamSoundFile::RegionInfo* pRegionInfo, + bool SetRegionInfo(const StreamSoundFile::RegionInfo* pRegionInfo, const StreamDataInfoDetail* pStreamDataInfo); - bool TryMoveNextRegion(IRegionInfoReadable* pRegionReader, + bool TryMoveNextRegion(IRegionInfoReadable* pRegionReader, StreamDataInfoDetail* pStreamDataInfo); void SetPosition(position_t position); @@ -80,5 +82,6 @@ static_assert(sizeof(RegionManager) == 0x440); #else static_assert(sizeof(RegionManager) == 0x4c0); #endif -} // namespace nn::atk::detail -} // namespace nn::atk \ No newline at end of file + +} // namespace detail +} // namespace nn::atk diff --git a/include/nn/atk/detail/atk_SoundArchiveManager.h b/include/nn/atk/detail/atk_SoundArchiveManager.h index 58b31c38..b52d8087 100644 --- a/include/nn/atk/detail/atk_SoundArchiveManager.h +++ b/include/nn/atk/detail/atk_SoundArchiveManager.h @@ -6,6 +6,7 @@ #include namespace nn::atk::detail { + class SoundArchiveManager { public: using ContainerList = IntrusiveList; @@ -40,7 +41,7 @@ class SoundArchiveManager { void SetParametersHook(SoundArchiveParametersHook*); SoundArchiveParametersHook* GetParametersHook() const; - + private: SoundArchive* m_pMainSoundArchive; SoundDataManager* m_pMainSoundDataManager; @@ -50,4 +51,5 @@ class SoundArchiveManager { SoundArchiveParametersHook* m_pParametersHook; }; static_assert(sizeof(SoundArchiveManager) == 0x38); + } // namespace nn::atk::detail diff --git a/include/nn/atk/fnd/basis/atkfnd_Config.h b/include/nn/atk/fnd/basis/atkfnd_Config.h index f805308d..337cde0f 100644 --- a/include/nn/atk/fnd/basis/atkfnd_Config.h +++ b/include/nn/atk/fnd/basis/atkfnd_Config.h @@ -3,5 +3,7 @@ #include namespace nn::atk::detail::fnd { + using position_t = std::ptrdiff_t; -} // namespace nn::atk::detail::fnd \ No newline at end of file + +} // namespace nn::atk::detail::fnd diff --git a/include/nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h b/include/nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h index a621df9d..70b6e6c5 100644 --- a/include/nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h +++ b/include/nn/atk/fnd/basis/atkfnd_FrameHeapImpl.h @@ -3,11 +3,12 @@ #include namespace nn::atk::detail::fnd { + class FrameHeapImpl : public HeapBase { public: static const int FreeHeadMode = 1; static const int FreeTailMode = 2; - static const int FreeAllMode = 3; + static const int FreeAllMode = 3; struct HeapState { u32 tagName; @@ -49,4 +50,5 @@ class FrameHeapImpl : public HeapBase { HeapState* m_pState; }; static_assert(sizeof(FrameHeapImpl) == 0x58); -} // namespace nn::atk::detail::fnd \ No newline at end of file + +} // namespace nn::atk::detail::fnd diff --git a/include/nn/atk/fnd/basis/atkfnd_HeapBase.h b/include/nn/atk/fnd/basis/atkfnd_HeapBase.h index 4459adca..38031491 100644 --- a/include/nn/atk/fnd/basis/atkfnd_HeapBase.h +++ b/include/nn/atk/fnd/basis/atkfnd_HeapBase.h @@ -4,6 +4,7 @@ #include namespace nn::atk::detail::fnd { + class HeapBase : public util::IntrusiveListBaseNode { public: using HeapList = util::IntrusiveList>; @@ -24,12 +25,12 @@ class HeapBase : public util::IntrusiveListBaseNode { static const int DefaultAlignment = 4; - static const u32 ExpHeapSignature = 0x45585048; // HPXE - static const u32 FrameHeapSignature = 0x46524D48; // HMRF - static const u32 UnitHeapSignature = 0x554E5448; // HTNU + static const u32 ExpHeapSignature = 0x45585048; // HPXE + static const u32 FrameHeapSignature = 0x46524D48; // HMRF + static const u32 UnitHeapSignature = 0x554E5448; // HTNU - static const int OptionZeroClear = 1 << 0; - static const int OptionDebugFill = 1 << 1; + static const int OptionZeroClear = 1 << 0; + static const int OptionDebugFill = 1 << 1; static const int OptionThreadSafe = 1 << 2; static const int ErrorPrint = 1; @@ -38,7 +39,7 @@ class HeapBase : public util::IntrusiveListBaseNode { static HeapBase* FindContainHeap(const void* memBlock); static HeapBase* FindParentHeap(const HeapBase* pChild); - + void* GetHeapStartAddress(); void* GetHeapEndAddress(); @@ -53,19 +54,13 @@ class HeapBase : public util::IntrusiveListBaseNode { protected: void Initialize(u32 signature, void* heapStart, void* heapEnd, u16 optFlag); void Finalize(); - - u32 GetSignature() const { - return m_Signature; - } - - void* GetHeapStart() const { - return mHeapStart; - } - - void* GetHeapEnd() const { - return mHeapEnd; - } - + + u32 GetSignature() const { return m_Signature; } + + void* GetHeapStart() const { return mHeapStart; } + + void* GetHeapEnd() const { return mHeapEnd; } + void LockHeap(); void UnlockHeap(); @@ -87,4 +82,5 @@ class HeapBase : public util::IntrusiveListBaseNode { u32 m_Attribute; }; static_assert(sizeof(HeapBase) == 0x40); -} // namespace nn::atk::detail::fnd \ No newline at end of file + +} // namespace nn::atk::detail::fnd diff --git a/include/nn/atk/fnd/basis/atkfnd_Inlines.h b/include/nn/atk/fnd/basis/atkfnd_Inlines.h index dc181e80..e852b062 100644 --- a/include/nn/atk/fnd/basis/atkfnd_Inlines.h +++ b/include/nn/atk/fnd/basis/atkfnd_Inlines.h @@ -48,4 +48,4 @@ inline ptrdiff_t GetOffsetFromPtr(const void* start, const void* end) { template inline void* AddOffsetToPtr(void* ptr, TOffset offset); -} // namespace nn::atk::detail::fnd \ No newline at end of file +} // namespace nn::atk::detail::fnd diff --git a/include/nn/atk/fnd/basis/atkfnd_Result.h b/include/nn/atk/fnd/basis/atkfnd_Result.h index ec54833d..3e8cf415 100644 --- a/include/nn/atk/fnd/basis/atkfnd_Result.h +++ b/include/nn/atk/fnd/basis/atkfnd_Result.h @@ -3,17 +3,18 @@ #include namespace nn::atk::detail::fnd { + enum FndResultType { FndResultType_ErrorFlagMask = 1 << 31, - FndResultType_CategoryMask = 0b1111111 << 24, - FndResultType_CodeMask = 0xffffff, + FndResultType_CategoryMask = 0b1111111 << 24, + FndResultType_CodeMask = 0xffffff, FndResultType_CategoryBitOffset = 24, - FndResultType_ErrorFlag = FndResultType_ErrorFlagMask, + FndResultType_ErrorFlag = FndResultType_ErrorFlagMask, + + FndResultType_CategorySystem = 0, + FndResultType_CategoryIo = 1 << FndResultType_CategoryBitOffset, - FndResultType_CategorySystem = 0, - FndResultType_CategoryIo = 1 << FndResultType_CategoryBitOffset, - FndResultType_True = FndResultType_CategorySystem, FndResultType_False, @@ -34,43 +35,30 @@ enum FndResultType { class FndResult { public: FndResult() = default; - - explicit FndResult(u32 value) - : value{value} {}; - explicit FndResult(FndResultType value) - : value(value) {}; + explicit FndResult(u32 value) : value{value} {}; + + explicit FndResult(FndResultType value) : value(value) {}; - bool IsSucceeded() const { - return !IsFailed(); - } + bool IsSucceeded() const { return !IsFailed(); } - bool IsTrue() const { - return value == FndResultType_True; - } + bool IsTrue() const { return value == FndResultType_True; } - bool IsFalse() const { - return value == FndResultType_False; - } + bool IsFalse() const { return value == FndResultType_False; } - bool IsFailed() const { - return value == static_cast(FndResultType_Failed); - } + bool IsFailed() const { return value == static_cast(FndResultType_Failed); } const char* ToString(); void PrintResult(); - explicit operator u32() const { - return value; - } + explicit operator u32() const { return value; } + + explicit operator FndResultType() const { return FndResultType(value); } - explicit operator FndResultType() const { - return FndResultType(value); - } private: u32 value; - }; static_assert(sizeof(FndResult) == 0x4); -} // namespace nn::atk::detail::fnd \ No newline at end of file + +} // namespace nn::atk::detail::fnd diff --git a/include/nn/atk/fnd/basis/atkfnd_RuntimeTypeInfo.h b/include/nn/atk/fnd/basis/atkfnd_RuntimeTypeInfo.h index bab4b32d..9820ad98 100644 --- a/include/nn/atk/fnd/basis/atkfnd_RuntimeTypeInfo.h +++ b/include/nn/atk/fnd/basis/atkfnd_RuntimeTypeInfo.h @@ -28,7 +28,7 @@ static_assert(sizeof(RuntimeTypeInfo) == 0x8); public: \ static const nn::atk::detail::fnd::RuntimeTypeInfo* GetRuntimeTypeInfoStatic() { \ static const nn::atk::detail::fnd::RuntimeTypeInfo s_TypeInfo{nullptr}; \ - return &s_TypeInfo; \ + return &s_TypeInfo; \ } \ \ virtual const nn::atk::detail::fnd::RuntimeTypeInfo* GetRuntimeTypeInfo() const { \ @@ -40,7 +40,7 @@ public: static const nn::atk::detail::fnd::RuntimeTypeInfo* GetRuntimeTypeInfoStatic() { \ static const nn::atk::detail::fnd::RuntimeTypeInfo s_TypeInfo{ \ BASE::GetRuntimeTypeInfoStatic()}; \ - return &s_TypeInfo; \ + return &s_TypeInfo; \ } \ \ const nn::atk::detail::fnd::RuntimeTypeInfo* GetRuntimeTypeInfo() const override { \ diff --git a/include/nn/atk/fnd/basis/atkfnd_Time.h b/include/nn/atk/fnd/basis/atkfnd_Time.h index 7cc2bbcc..208e242c 100644 --- a/include/nn/atk/fnd/basis/atkfnd_Time.h +++ b/include/nn/atk/fnd/basis/atkfnd_Time.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail::fnd { + class Time { public: s64 Current(); @@ -15,7 +16,7 @@ class TimeSpan { static TimeSpan FromNanoSeconds(TickType); static TimeSpan FromMicroSeconds(TickType); static TimeSpan FromMilliSeconds(TickType); - + TickType ToNanoSeconds() const; TickType ToMicroSeconds() const; TickType ToMilliSeconds() const; @@ -24,4 +25,5 @@ class TimeSpan { TickType m_TickSpan; }; static_assert(sizeof(TimeSpan) == 0x8); -} // namespace nn::atk::detail::fnd \ No newline at end of file + +} // namespace nn::atk::detail::fnd diff --git a/include/nn/atk/fnd/basis/atkfnd_WorkBufferAllocator.h b/include/nn/atk/fnd/basis/atkfnd_WorkBufferAllocator.h index 49239c6a..3c3efbd2 100644 --- a/include/nn/atk/fnd/basis/atkfnd_WorkBufferAllocator.h +++ b/include/nn/atk/fnd/basis/atkfnd_WorkBufferAllocator.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail::fnd { + class WorkBufferAllocator { public: WorkBufferAllocator(void* buffer, size_t size); @@ -16,4 +17,5 @@ class WorkBufferAllocator { size_t m_Size; }; static_assert(sizeof(WorkBufferAllocator) == 0x18); -} // namespace nn::atk::detail::fnd \ No newline at end of file + +} // namespace nn::atk::detail::fnd diff --git a/include/nn/atk/fnd/binary/atkfnd_PrimitiveTypes.h b/include/nn/atk/fnd/binary/atkfnd_PrimitiveTypes.h index ab767f25..9d1f9784 100644 --- a/include/nn/atk/fnd/binary/atkfnd_PrimitiveTypes.h +++ b/include/nn/atk/fnd/binary/atkfnd_PrimitiveTypes.h @@ -3,6 +3,8 @@ #include namespace nn::atk::detail::fnd { + using PcBinU16 = std::uint16_t; using PcBinU32 = std::uint32_t; -} // namespace nn::atk::detail::fnd \ No newline at end of file + +} // namespace nn::atk::detail::fnd diff --git a/include/nn/atk/fnd/io/atkfnd_FileStream.h b/include/nn/atk/fnd/io/atkfnd_FileStream.h index 3d46a490..c96b3af2 100644 --- a/include/nn/atk/fnd/io/atkfnd_FileStream.h +++ b/include/nn/atk/fnd/io/atkfnd_FileStream.h @@ -4,15 +4,16 @@ #include namespace nn::atk::detail::fnd { + class FileStream : public Stream { public: enum AccessMode { - AccessMode_None = 0, - AccessMode_Read = 1 << 0, - AccessMode_Write = 1 << 1, - AccessMode_AllowAppend = 1 << 2, - AccessMode_ReadAndWrite = AccessMode_Read | AccessMode_Write, - AccessMode_AllowAppendAndWrite = AccessMode_AllowAppend | AccessMode_Write, + AccessMode_None = 0, + AccessMode_Read = 1 << 0, + AccessMode_Write = 1 << 1, + AccessMode_AllowAppend = 1 << 2, + AccessMode_ReadAndWrite = AccessMode_Read | AccessMode_Write, + AccessMode_AllowAppendAndWrite = AccessMode_AllowAppend | AccessMode_Write, }; ~FileStream() override = default; @@ -20,7 +21,7 @@ class FileStream : public Stream { virtual FndResult Open(const char* filePath, AccessMode openMode) = 0; void Close() override = 0; virtual void Flush() = 0; - + bool IsOpened() const override = 0; bool CanRead() const override = 0; @@ -48,4 +49,5 @@ class FileStream : public Stream { virtual size_t GetCachedLength() = 0; }; static_assert(sizeof(FileStream) == 0x8); -} // namespace nn::atk::detail::fnd \ No newline at end of file + +} // namespace nn::atk::detail::fnd diff --git a/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h b/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h index 75cf5152..66d79dab 100644 --- a/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h +++ b/include/nn/atk/fnd/io/atkfnd_FileStreamImpl.h @@ -5,6 +5,7 @@ #include namespace nn::atk::detail::fnd { + class FileStreamImpl : public FileStream { NN_NO_COPY(FileStreamImpl); @@ -101,4 +102,5 @@ class FileStreamImpl : public FileStream { FsAccessLog* m_pAccessLog{nullptr}; }; static_assert(sizeof(FileStreamImpl) == 0x80); -} // namespace nn::atk::detail::fnd \ No newline at end of file + +} // namespace nn::atk::detail::fnd diff --git a/include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h b/include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h index cfb7afb9..a282098c 100644 --- a/include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h +++ b/include/nn/atk/fnd/io/atkfnd_FileStreamProxy.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail::fnd { + class FileStreamProxy : public FileStream { public: FileStreamProxy(FileStream* fileStream, position_t offset, size_t fileSize); @@ -11,7 +12,7 @@ class FileStreamProxy : public FileStream { FndResult Open(const char* filePath, AccessMode openMode) override; void Close() override; void Flush() override; - + bool IsOpened() const override; bool CanRead() const override; @@ -45,4 +46,5 @@ class FileStreamProxy : public FileStream { size_t m_FileSize; }; static_assert(sizeof(FileStreamProxy) == 0x20); -} // namespace nn::atk::detail::fnd \ No newline at end of file + +} // namespace nn::atk::detail::fnd diff --git a/include/nn/atk/fnd/io/atkfnd_Stream.h b/include/nn/atk/fnd/io/atkfnd_Stream.h index 7d92f007..a8ddb0f1 100644 --- a/include/nn/atk/fnd/io/atkfnd_Stream.h +++ b/include/nn/atk/fnd/io/atkfnd_Stream.h @@ -7,8 +7,10 @@ #include namespace nn::atk::detail::fnd { + class Stream { NN_NO_COPY(Stream); + public: static const position_t InvalidPosition = 0xffffffff; static const size_t InvalidSize = 0xffffffff; @@ -27,17 +29,18 @@ class Stream { public: virtual void Close() = 0; virtual bool IsOpened() const = 0; - + virtual size_t Read(void* buf, size_t length, FndResult* result); virtual size_t Write(const void* buf, size_t length, FndResult* result); virtual FndResult Seek(position_t offset, SeekOrigin origin); - + virtual position_t GetCurrentPosition() const; virtual size_t GetSize() const; - + virtual bool CanRead() const; virtual bool CanWrite() const; virtual bool CanSeek() const; }; static_assert(sizeof(Stream) == 0x8); -} // namespace nn::atk::detail::fnd \ No newline at end of file + +} // namespace nn::atk::detail::fnd diff --git a/include/nn/atk/fnd/io/atkfnd_StreamCache.h b/include/nn/atk/fnd/io/atkfnd_StreamCache.h index bae12330..d9bf25fc 100644 --- a/include/nn/atk/fnd/io/atkfnd_StreamCache.h +++ b/include/nn/atk/fnd/io/atkfnd_StreamCache.h @@ -3,6 +3,7 @@ #include namespace nn::atk::detail::fnd { + struct FsAccessLog; class StreamCache { @@ -20,9 +21,9 @@ class StreamCache { void Finalize(); size_t Read(void* buf, size_t length, FndResult* result, FsAccessLog* log, void* pFileStream); - + void FlushWriteCache(); - + size_t GetReadCacheHitLength(size_t) const; FndResult SyncStreamCurrentPosition(position_t position); @@ -48,4 +49,5 @@ class StreamCache { u8 m_Padding[3]; }; static_assert(sizeof(StreamCache) == 0x40); -} // namespace nn::atk::detail::fnd \ No newline at end of file + +} // namespace nn::atk::detail::fnd diff --git a/include/nn/atk/fnd/os/atkfnd_CriticalSection.h b/include/nn/atk/fnd/os/atkfnd_CriticalSection.h index 90d98a71..fe0e822e 100644 --- a/include/nn/atk/fnd/os/atkfnd_CriticalSection.h +++ b/include/nn/atk/fnd/os/atkfnd_CriticalSection.h @@ -3,10 +3,10 @@ #include namespace nn::atk::detail::fnd { + class CriticalSection { public: - CriticalSection() - : m_Mutex(true) {} + CriticalSection() : m_Mutex(true) {} ~CriticalSection() = default; @@ -23,20 +23,15 @@ class CriticalSection { // TODO } - void Lock() { - m_Mutex.Lock(); - } + void Lock() { m_Mutex.Lock(); } + + bool TryLock() { return m_Mutex.TryLock(); } + + void Unlock() { m_Mutex.Unlock(); } - bool TryLock() { - return m_Mutex.TryLock(); - } - - void Unlock() { - m_Mutex.Unlock(); - } - private: os::Mutex m_Mutex; }; static_assert(sizeof(CriticalSection) == 0x20); -} // namespace nn::atk::detail::fnd \ No newline at end of file + +} // namespace nn::atk::detail::fnd diff --git a/include/nn/atk/fnd/os/atkfnd_ScopedLock.h b/include/nn/atk/fnd/os/atkfnd_ScopedLock.h index 4ac0e72a..100924a6 100644 --- a/include/nn/atk/fnd/os/atkfnd_ScopedLock.h +++ b/include/nn/atk/fnd/os/atkfnd_ScopedLock.h @@ -3,23 +3,18 @@ #include namespace nn::atk::detail::fnd { + template class ScopedLock { NN_NO_COPY(ScopedLock); public: - explicit ScopedLock(TLockObject& lockObj) - : m_LockObj(lockObj) - { - m_LockObj.Lock(); - } + explicit ScopedLock(TLockObject& lockObj) : m_LockObj(lockObj) { m_LockObj.Lock(); } - ~ScopedLock() - { - m_LockObj.Unlock(); - } + ~ScopedLock() { m_LockObj.Unlock(); } private: TLockObject& m_LockObj; }; -} // namespace nn::atk::detail::fnd \ No newline at end of file + +} // namespace nn::atk::detail::fnd diff --git a/include/nn/atk/fnd/os/atkfnd_Thread.h b/include/nn/atk/fnd/os/atkfnd_Thread.h index 3c66da74..38b8b65a 100644 --- a/include/nn/atk/fnd/os/atkfnd_Thread.h +++ b/include/nn/atk/fnd/os/atkfnd_Thread.h @@ -1,9 +1,10 @@ #pragma once -#include #include +#include namespace nn::atk::detail::fnd { + class TimeSpan; class Thread { @@ -11,16 +12,16 @@ class Thread { enum AffinityMask { AffinityMask_CoreAll = -1, AffinityMask_CoreDefault, - AffinityMask_Core0 = 1 << 0, - AffinityMask_Core1 = 1 << 1, - AffinityMask_Core2 = 1 << 2, - AffinityMask_Core3 = 1 << 3, - AffinityMask_Core4 = 1 << 4, - AffinityMask_Core5 = 1 << 5, - AffinityMask_Core6 = 1 << 6, - AffinityMask_Core7 = 1 << 7, - AffinityMask_Core8 = 1 << 8, - AffinityMask_Core9 = 1 << 9, + AffinityMask_Core0 = 1 << 0, + AffinityMask_Core1 = 1 << 1, + AffinityMask_Core2 = 1 << 2, + AffinityMask_Core3 = 1 << 3, + AffinityMask_Core4 = 1 << 4, + AffinityMask_Core5 = 1 << 5, + AffinityMask_Core6 = 1 << 6, + AffinityMask_Core7 = 1 << 7, + AffinityMask_Core8 = 1 << 8, + AffinityMask_Core9 = 1 << 9, AffinityMask_Core10 = 1 << 10, AffinityMask_Core11 = 1 << 11, AffinityMask_Core12 = 1 << 12, @@ -76,7 +77,6 @@ class Thread { static_assert(sizeof(Handler) == 0x8); struct RunArgs { - RunArgs(); bool IsValid() const; @@ -138,4 +138,5 @@ class Thread { bool m_IsTerminated; }; static_assert(sizeof(Thread) == 0x1f0); -} // nn::atk::detail::fnd \ No newline at end of file + +} // namespace nn::atk::detail::fnd diff --git a/include/nn/atk/fnd/string/atkfnd_String.h b/include/nn/atk/fnd/string/atkfnd_String.h index 50887c58..34b1b3bf 100644 --- a/include/nn/atk/fnd/string/atkfnd_String.h +++ b/include/nn/atk/fnd/string/atkfnd_String.h @@ -5,9 +5,10 @@ #include namespace nn::atk::detail::fnd { -// UNSURE + +// NON_MATCHING inline size_t strncat(char* dst, size_t dstCount, const char* src, size_t srcCount) { - size_t length {strlen(src)}; + size_t length{strlen(src)}; if (length + srcCount + 1 < dstCount) length = srcCount + 1; else @@ -16,4 +17,5 @@ inline size_t strncat(char* dst, size_t dstCount, const char* src, size_t srcCou std::strncat(dst, src, length); return length; } -} // namespace atk::detail::fnd \ No newline at end of file + +} // namespace nn::atk::detail::fnd diff --git a/include/nn/audio/audio_Adpcm.h b/include/nn/audio/audio_Adpcm.h index 123e8abc..642ae8d2 100644 --- a/include/nn/audio/audio_Adpcm.h +++ b/include/nn/audio/audio_Adpcm.h @@ -3,6 +3,7 @@ #include namespace nn::audio { + struct AdpcmContext { u16 predScale; s16 history[2]; @@ -13,4 +14,5 @@ struct AdpcmParameter { u16 coefficients[16]; }; static_assert(sizeof(AdpcmParameter) == 0x20); -} // namespace nn::audio \ No newline at end of file + +} // namespace nn::audio diff --git a/include/nn/audio/audio_AudioRendererTypes.h b/include/nn/audio/audio_AudioRendererTypes.h index 963390ea..9e8590d0 100644 --- a/include/nn/audio/audio_AudioRendererTypes.h +++ b/include/nn/audio/audio_AudioRendererTypes.h @@ -3,6 +3,7 @@ #include namespace nn::audio { + enum AudioRendererRenderingDevice { AudioRendererRenderingDevice_AudioCoprocessor, AudioRendererRenderingDevice_Cpu, @@ -62,4 +63,5 @@ struct AudioRendererConfig { size_t _configBufferSize; }; static_assert(sizeof(AudioRendererConfig) == 0x70); -} // namespace nn::audio \ No newline at end of file + +} // namespace nn::audio diff --git a/include/nn/audio/audio_Common.h b/include/nn/audio/audio_Common.h index 8eb070a7..b4c3dc22 100644 --- a/include/nn/audio/audio_Common.h +++ b/include/nn/audio/audio_Common.h @@ -3,6 +3,7 @@ #include namespace nn::audio { + using NodeId = uint32_t; const int BufferAlignSize = 64; @@ -25,4 +26,5 @@ class PerformanceBufferManager {}; class MemoryPoolManager {}; class BehaviorManager {}; class SplitterInfoManager {}; -} // namespace nn::audio \ No newline at end of file + +} // namespace nn::audio diff --git a/include/nn/audio/audio_EffectTypes.h b/include/nn/audio/audio_EffectTypes.h index b648196d..4ee8b0d7 100644 --- a/include/nn/audio/audio_EffectTypes.h +++ b/include/nn/audio/audio_EffectTypes.h @@ -3,9 +3,11 @@ #include namespace nn::audio { + struct EffectInfo {}; struct AuxType { EffectInfo* _pEffectInfo; }; -} // namespace nn::audio \ No newline at end of file + +} // namespace nn::audio diff --git a/include/nn/audio/audio_FinalMixTypes.h b/include/nn/audio/audio_FinalMixTypes.h index 80e097c9..7fcc7e45 100644 --- a/include/nn/audio/audio_FinalMixTypes.h +++ b/include/nn/audio/audio_FinalMixTypes.h @@ -3,10 +3,12 @@ #include namespace nn::audio { + struct FinalMixType { MixInfo* _pMixInfo; static float GetVolumeMax(); static float GetVolumeMin(); }; -} // namespace nn::audio \ No newline at end of file + +} // namespace nn::audio diff --git a/include/nn/audio/audio_MemoryPoolTypes.h b/include/nn/audio/audio_MemoryPoolTypes.h index 3165ea56..c055c3be 100644 --- a/include/nn/audio/audio_MemoryPoolTypes.h +++ b/include/nn/audio/audio_MemoryPoolTypes.h @@ -3,6 +3,7 @@ #include namespace nn::audio { + enum MemoryPoolState { MemoryPoolState_Invalid, MemoryPoolState_New, @@ -23,10 +24,11 @@ struct MemoryPoolType { State_Detached, }; - static const size_t AddressAlignment {4096}; - static const size_t SizeGranularity {4096}; + static const size_t AddressAlignment{4096}; + static const size_t SizeGranularity{4096}; MemoryPoolInfo* _pMemoryPoolInfo; }; static_assert(sizeof(MemoryPoolType) == 0x8); -} // namespace nn::audio + +} // namespace nn::audio diff --git a/include/nn/audio/audio_PerformanceMetrics.h b/include/nn/audio/audio_PerformanceMetrics.h index 98dad4e4..a0c1769d 100644 --- a/include/nn/audio/audio_PerformanceMetrics.h +++ b/include/nn/audio/audio_PerformanceMetrics.h @@ -5,6 +5,7 @@ #include namespace nn::audio { + class PerformanceInfo { public: PerformanceInfo& operator=(const PerformanceInfo&); @@ -30,4 +31,5 @@ class PerformanceInfo { PerformanceDetail* m_Details; }; static_assert(sizeof(PerformanceInfo) == 0x28); -} // namespace nn::audio \ No newline at end of file + +} // namespace nn::audio diff --git a/include/nn/audio/audio_PerformanceMetricsTypes.h b/include/nn/audio/audio_PerformanceMetricsTypes.h index 483a91f5..6f4ce401 100644 --- a/include/nn/audio/audio_PerformanceMetricsTypes.h +++ b/include/nn/audio/audio_PerformanceMetricsTypes.h @@ -3,6 +3,7 @@ #include namespace nn::audio { + enum PerformanceEntryType { PerformanceEntryType_Unknown, PerformanceEntryType_Voice, @@ -37,4 +38,5 @@ static_assert(sizeof(PerformanceEntry) == 0x10); struct PerformanceFrameHeader {}; struct PerformanceDetail {}; -} // namespace nn::audio \ No newline at end of file + +} // namespace nn::audio diff --git a/include/nn/audio/audio_SampleFormat.h b/include/nn/audio/audio_SampleFormat.h index 4380b223..b9ab5d2b 100644 --- a/include/nn/audio/audio_SampleFormat.h +++ b/include/nn/audio/audio_SampleFormat.h @@ -1,6 +1,7 @@ #pragma once namespace nn::audio { + enum SampleFormat { SampleFormat_Invalid, SampleFormat_PcmInt8, @@ -10,4 +11,5 @@ enum SampleFormat { SampleFormat_PcmFloat, SampleFormat_Adpcm, }; -} // namespace nn::audio \ No newline at end of file + +} // namespace nn::audio diff --git a/include/nn/audio/audio_SinkTypes.h b/include/nn/audio/audio_SinkTypes.h index d9775fff..63775f5e 100644 --- a/include/nn/audio/audio_SinkTypes.h +++ b/include/nn/audio/audio_SinkTypes.h @@ -1,6 +1,7 @@ #pragma once namespace nn::audio { + struct SinkInfo {}; struct DeviceSinkType { @@ -17,4 +18,5 @@ struct CircularBufferSinkType { SinkInfo* _handle; }; static_assert(sizeof(CircularBufferSinkType) == 0x8); -} // namespace nn::audio \ No newline at end of file + +} // namespace nn::audio diff --git a/include/nn/audio/audio_SubMixTypes.h b/include/nn/audio/audio_SubMixTypes.h index ee9ee2c4..74044e2f 100644 --- a/include/nn/audio/audio_SubMixTypes.h +++ b/include/nn/audio/audio_SubMixTypes.h @@ -3,10 +3,12 @@ #include namespace nn::audio { + struct SubMixType { MixInfo* _pMixInfo; static float GetVolumeMin(); static float GetVolumeMax(); }; -} // namespace nn::audio \ No newline at end of file + +} // namespace nn::audio diff --git a/include/nn/audio/audio_VoiceTypes.h b/include/nn/audio/audio_VoiceTypes.h index b3a9abed..20f49629 100644 --- a/include/nn/audio/audio_VoiceTypes.h +++ b/include/nn/audio/audio_VoiceTypes.h @@ -3,6 +3,7 @@ #include namespace nn::audio { + struct VoiceInfo; struct BiquadFilterParameter { @@ -34,4 +35,5 @@ struct VoiceType { VoiceInfo* _pVoiceInfo{}; }; static_assert(sizeof(VoiceType) == 0x8); -} // namespace nn::audio \ No newline at end of file + +} // namespace nn::audio diff --git a/include/nn/audio/audio_WaveBuffer.h b/include/nn/audio/audio_WaveBuffer.h index aad32139..f50e9479 100644 --- a/include/nn/audio/audio_WaveBuffer.h +++ b/include/nn/audio/audio_WaveBuffer.h @@ -3,6 +3,7 @@ #include namespace nn::audio { + struct WaveBuffer { const void* buffer; size_t size; @@ -14,4 +15,5 @@ struct WaveBuffer { size_t contextSize; }; static_assert(sizeof(WaveBuffer) == 0x30); -} // namespace nn::audio \ No newline at end of file + +} // namespace nn::audio diff --git a/src/NintendoWare/atk/atk_FsSoundArchive.cpp b/src/NintendoWare/atk/atk_FsSoundArchive.cpp index 43d02d03..59de09bb 100644 --- a/src/NintendoWare/atk/atk_FsSoundArchive.cpp +++ b/src/NintendoWare/atk/atk_FsSoundArchive.cpp @@ -2,10 +2,11 @@ #include -#include #include +#include namespace nn::atk { + FsSoundArchive::FsSoundArchive() = default; FsSoundArchive::~FsSoundArchive() { @@ -24,13 +25,13 @@ void FsSoundArchive::Close() { } bool FsSoundArchive::LoadHeader(void* buffer, size_t size) { - const s32 infoChunkOffset {m_ArchiveReader.GetInfoBlockOffset()}; - const u32 infoChunkSize {m_ArchiveReader.GetInfoBlockSize()}; + const s32 infoChunkOffset{m_ArchiveReader.GetInfoBlockOffset()}; + const u32 infoChunkSize{m_ArchiveReader.GetInfoBlockSize()}; if (size >= infoChunkSize) { FileAccessBegin(); m_FileStream.Seek(infoChunkOffset, detail::fnd::Stream::SeekOrigin_Begin); - size_t readSize {m_FileStream.Read(buffer, infoChunkSize, nullptr)}; + size_t readSize{m_FileStream.Read(buffer, infoChunkSize, nullptr)}; if (readSize == infoChunkSize) { FileAccessEnd(); @@ -43,13 +44,13 @@ bool FsSoundArchive::LoadHeader(void* buffer, size_t size) { } bool FsSoundArchive::LoadLabelStringData(void* buffer, size_t size) { - const s32 stringBlockOffset {m_ArchiveReader.GetStringBlockOffset()}; - const u32 stringBlockSize {m_ArchiveReader.GetStringBlockSize()}; + const s32 stringBlockOffset{m_ArchiveReader.GetStringBlockOffset()}; + const u32 stringBlockSize{m_ArchiveReader.GetStringBlockSize()}; if (stringBlockOffset != detail::Util::Reference::InvalidOffset && size >= stringBlockSize) { FileAccessBegin(); m_FileStream.Seek(stringBlockOffset, detail::fnd::Stream::SeekOrigin_Begin); - size_t readSize {m_FileStream.Read(buffer, stringBlockSize, nullptr)}; + size_t readSize{m_FileStream.Read(buffer, stringBlockSize, nullptr)}; if (readSize == stringBlockSize) { FileAccessEnd(); @@ -67,14 +68,14 @@ size_t FsSoundArchive::detail_GetRequiredStreamBufferSize() const { const void* FsSoundArchive::detail_GetFileAddress([[maybe_unused]] ItemId itemId) const { return nullptr; -} +} void FsSoundArchive::FileAccessBegin() const { if (m_FileAccessMode == FileAccessMode_InFunction) { detail::fnd::ScopedLock lock{m_FileOpenCloseLock}; if (m_FileAccessCount == 0) m_FileStream.Open(m_SoundArchiveFullPath, detail::fnd::FileStream::AccessMode_Read); - + ++m_FileAccessCount; } } @@ -84,16 +85,16 @@ void FsSoundArchive::FileAccessEnd() const { detail::fnd::ScopedLock lock{m_FileOpenCloseLock}; if (m_FileAccessCount == 1) m_FileStream.Close(); - + if (m_FileAccessCount != 0) --m_FileAccessCount; } } // NON_MATCHING -detail::fnd::FileStream* FsSoundArchive::OpenStream(void* buffer, size_t size, - position_t begin, size_t length) const { - detail::fnd::FileStream* stream {}; +detail::fnd::FileStream* FsSoundArchive::OpenStream(void* buffer, size_t size, position_t begin, + size_t length) const { + detail::fnd::FileStream* stream{}; if (sizeof(detail::fnd::FileStreamProxy) <= size && m_IsOpened) { stream = new (buffer) detail::fnd::FileStreamProxy(&m_FileStream, begin, length); } @@ -102,9 +103,10 @@ detail::fnd::FileStream* FsSoundArchive::OpenStream(void* buffer, size_t size, } // NON_MATCHING -detail::fnd::FileStream* FsSoundArchive::OpenExtStream(void* buffer, size_t size, const char* extFilePath, - void* cacheBuffer, size_t cacheSize) const { - detail::fnd::FileStream* fileStream {}; +detail::fnd::FileStream* FsSoundArchive::OpenExtStream(void* buffer, size_t size, + const char* extFilePath, void* cacheBuffer, + size_t cacheSize) const { + detail::fnd::FileStream* fileStream{}; if (size >= sizeof(detail::fnd::FileStreamImpl) && m_IsOpened) { fileStream = new (buffer) detail::fnd::FileStreamImpl(); @@ -112,8 +114,7 @@ detail::fnd::FileStream* FsSoundArchive::OpenExtStream(void* buffer, size_t size if (!fileStream->IsOpened()) { fileStream = nullptr; - } - else { + } else { if (cacheBuffer != nullptr && cacheSize != 0) fileStream->EnableCache(cacheBuffer, cacheSize); } @@ -127,16 +128,16 @@ bool FsSoundArchive::LoadFileHeader() { const size_t headerAlignSize = 256; char headerArea[sizeof(detail::SoundArchiveFile::FileHeader) + headerAlignSize + Align]; - void* file {util::BytePtr(headerArea).AlignUp(Align).Get()}; - - size_t readSize {m_FileStream.Read(file, headerAlignSize, nullptr)}; + void* file{util::BytePtr(headerArea).AlignUp(Align).Get()}; - if (readSize != headerAlignSize) + size_t readSize{m_FileStream.Read(file, headerAlignSize, nullptr)}; + + if (readSize != headerAlignSize) return false; - + m_ArchiveReader.Initialize(file); Initialize(&m_ArchiveReader); return true; } -} // namespace nn::atk +} // namespace nn::atk diff --git a/src/NintendoWare/atk/atk_SequenceSoundHandle.cpp b/src/NintendoWare/atk/atk_SequenceSoundHandle.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/atk_SequenceSoundHandle.cpp +++ b/src/NintendoWare/atk/atk_SequenceSoundHandle.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index c8328b8a..02824bd5 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -10,6 +10,7 @@ #include namespace nn::atk { + SoundArchive::SoundArchive() { m_ExtFileRoot[0] = '/'; m_ExtFileRoot[1] = '\0'; @@ -66,7 +67,7 @@ u32 SoundArchive::detail_GetFileCount() const { const char* SoundArchive::GetItemLabel(ItemId id) const { if (m_pParametersHook != nullptr) { - const char* result {m_pParametersHook->GetItemLabel(id)}; + const char* result{m_pParametersHook->GetItemLabel(id)}; if (result != nullptr) return result; } @@ -76,7 +77,7 @@ const char* SoundArchive::GetItemLabel(ItemId id) const { SoundArchive::ItemId SoundArchive::GetItemId(const char* pStr) const { if (m_pParametersHook != nullptr) { - ItemId result {m_pParametersHook->GetItemId(pStr)}; + ItemId result{m_pParametersHook->GetItemId(pStr)}; if (result != InvalidId) return result; } @@ -93,7 +94,7 @@ SoundArchive::FileId SoundArchive::GetItemPrefetchFileId(ItemId id) const { } u32 SoundArchive::GetSoundUserParam(ItemId soundId) const { - u32 userParam {m_pFileReader->GetSoundUserParam(soundId)}; + u32 userParam{m_pFileReader->GetSoundUserParam(soundId)}; if (m_pParametersHook != nullptr && m_pParametersHook->GetIsEnable()) userParam = m_pParametersHook->GetSoundUserParam(soundId, userParam); @@ -102,7 +103,7 @@ u32 SoundArchive::GetSoundUserParam(ItemId soundId) const { } bool SoundArchive::ReadSoundUserParam(u32* pOutValue, ItemId soundId, int index) const { - bool result {m_pFileReader->ReadSoundUserParam(pOutValue, soundId, index)}; + bool result{m_pFileReader->ReadSoundUserParam(pOutValue, soundId, index)}; if (m_pParametersHook != nullptr) result |= m_pParametersHook->ReadSoundUserParam(pOutValue, soundId, index); @@ -113,9 +114,9 @@ bool SoundArchive::ReadSoundUserParam(u32* pOutValue, ItemId soundId, int index) SoundArchive::SoundType SoundArchive::GetSoundType(ItemId soundId) const { #if NN_SDK_VER > NN_MAKE_VER(1, 6, 0) if (m_pParametersHook != nullptr) { - const char* label {m_pParametersHook->GetItemLabel(soundId)}; + const char* label{m_pParametersHook->GetItemLabel(soundId)}; if (label != nullptr) { - SoundType type {m_pParametersHook->GetSoundType(label)}; + SoundType type{m_pParametersHook->GetSoundType(label)}; if (type != SoundType_Invalid) return type; } @@ -125,7 +126,7 @@ SoundArchive::SoundType SoundArchive::GetSoundType(ItemId soundId) const { } bool SoundArchive::ReadSoundInfo(SoundInfo* pOutValue, ItemId soundId) const { - bool result {m_pFileReader->ReadSoundInfo(soundId, pOutValue)}; + bool result{m_pFileReader->ReadSoundInfo(soundId, pOutValue)}; if (m_pParametersHook != nullptr) result |= m_pParametersHook->ReadSoundInfo(soundId, pOutValue); @@ -134,7 +135,7 @@ bool SoundArchive::ReadSoundInfo(SoundInfo* pOutValue, ItemId soundId) const { } bool SoundArchive::ReadSequenceSoundInfo(SequenceSoundInfo* pOutValue, ItemId soundId) const { - bool result {m_pFileReader->ReadSequenceSoundInfo(soundId, pOutValue)}; + bool result{m_pFileReader->ReadSequenceSoundInfo(soundId, pOutValue)}; if (m_pParametersHook != nullptr) result |= m_pParametersHook->ReadSequenceSoundInfo(soundId, pOutValue); @@ -143,7 +144,7 @@ bool SoundArchive::ReadSequenceSoundInfo(SequenceSoundInfo* pOutValue, ItemId so } bool SoundArchive::ReadBankInfo(BankInfo* pOutValue, ItemId bankId) const { - bool result {m_pFileReader->ReadBankInfo(bankId, pOutValue)}; + bool result{m_pFileReader->ReadBankInfo(bankId, pOutValue)}; if (m_pParametersHook != nullptr) result |= m_pParametersHook->ReadBankInfo(bankId, pOutValue); @@ -152,7 +153,7 @@ bool SoundArchive::ReadBankInfo(BankInfo* pOutValue, ItemId bankId) const { } bool SoundArchive::ReadPlayerInfo(PlayerInfo* pOutValue, ItemId playerId) const { - bool result {m_pFileReader->ReadPlayerInfo(playerId, pOutValue)}; + bool result{m_pFileReader->ReadPlayerInfo(playerId, pOutValue)}; if (m_pParametersHook != nullptr) result |= m_pParametersHook->ReadPlayerInfo(playerId, pOutValue); @@ -161,7 +162,7 @@ bool SoundArchive::ReadPlayerInfo(PlayerInfo* pOutValue, ItemId playerId) const } bool SoundArchive::ReadSoundArchivePlayerInfo(SoundArchivePlayerInfo* pOutValue) const { - bool result {m_pFileReader->ReadSoundArchivePlayerInfo(pOutValue)}; + bool result{m_pFileReader->ReadSoundArchivePlayerInfo(pOutValue)}; if (m_pParametersHook != nullptr) result |= m_pParametersHook->ReadSoundArchivePlayerInfo(pOutValue); @@ -170,7 +171,7 @@ bool SoundArchive::ReadSoundArchivePlayerInfo(SoundArchivePlayerInfo* pOutValue) } bool SoundArchive::ReadStreamSoundInfo(StreamSoundInfo* pOutValue, ItemId soundId) const { - bool result {m_pFileReader->ReadStreamSoundInfo(soundId, pOutValue)}; + bool result{m_pFileReader->ReadStreamSoundInfo(soundId, pOutValue)}; if (m_pParametersHook != nullptr) result |= m_pParametersHook->ReadStreamSoundInfo(soundId, pOutValue); @@ -179,7 +180,7 @@ bool SoundArchive::ReadStreamSoundInfo(StreamSoundInfo* pOutValue, ItemId soundI } bool SoundArchive::detail_ReadStreamSoundInfo2(ItemId soundId, StreamSoundInfo2* info) const { - bool result {m_pFileReader->ReadStreamSoundInfo2(soundId, info)}; + bool result{m_pFileReader->ReadStreamSoundInfo2(soundId, info)}; if (m_pParametersHook != nullptr) result |= m_pParametersHook->ReadStreamSoundInfo2(soundId, info); @@ -188,7 +189,7 @@ bool SoundArchive::detail_ReadStreamSoundInfo2(ItemId soundId, StreamSoundInfo2* } bool SoundArchive::detail_ReadWaveSoundInfo(ItemId soundId, WaveSoundInfo* info) const { - bool result {m_pFileReader->ReadWaveSoundInfo(soundId, info)}; + bool result{m_pFileReader->ReadWaveSoundInfo(soundId, info)}; if (m_pParametersHook != nullptr) result |= m_pParametersHook->ReadWaveSoundInfo(soundId, info); @@ -196,13 +197,14 @@ bool SoundArchive::detail_ReadWaveSoundInfo(ItemId soundId, WaveSoundInfo* info) return result; } -bool SoundArchive::detail_ReadAdvancedWaveSoundInfo(ItemId soundId, AdvancedWaveSoundInfo* info) const { - bool result {m_pFileReader->ReadAdvancedWaveSoundInfo(soundId, info)}; +bool SoundArchive::detail_ReadAdvancedWaveSoundInfo(ItemId soundId, + AdvancedWaveSoundInfo* info) const { + bool result{m_pFileReader->ReadAdvancedWaveSoundInfo(soundId, info)}; return result; } bool SoundArchive::ReadSound3DInfo(Sound3DInfo* pOutValue, ItemId soundId) const { - bool result {m_pFileReader->ReadSound3DInfo(soundId, pOutValue)}; + bool result{m_pFileReader->ReadSound3DInfo(soundId, pOutValue)}; if (m_pParametersHook != nullptr) result |= m_pParametersHook->ReadSound3DInfo(soundId, pOutValue); @@ -211,7 +213,7 @@ bool SoundArchive::ReadSound3DInfo(Sound3DInfo* pOutValue, ItemId soundId) const } bool SoundArchive::ReadWaveArchiveInfo(ItemId warcId, WaveArchiveInfo* info) const { - bool result {m_pFileReader->ReadWaveArchiveInfo(warcId, info)}; + bool result{m_pFileReader->ReadWaveArchiveInfo(warcId, info)}; if (m_pParametersHook != nullptr) result |= m_pParametersHook->ReadWaveArchiveInfo(warcId, info); @@ -220,7 +222,7 @@ bool SoundArchive::ReadWaveArchiveInfo(ItemId warcId, WaveArchiveInfo* info) con } bool SoundArchive::detail_ReadSoundGroupInfo(ItemId soundGroupId, SoundGroupInfo* info) const { - bool result {m_pFileReader->ReadSoundGroupInfo(soundGroupId, info)}; + bool result{m_pFileReader->ReadSoundGroupInfo(soundGroupId, info)}; if (m_pParametersHook != nullptr) result |= m_pParametersHook->ReadSoundGroupInfo(soundGroupId, info); @@ -229,7 +231,7 @@ bool SoundArchive::detail_ReadSoundGroupInfo(ItemId soundGroupId, SoundGroupInfo } bool SoundArchive::ReadGroupInfo(GroupInfo* pOutValue, ItemId groupId) const { - bool result {m_pFileReader->ReadGroupInfo(groupId, pOutValue)}; + bool result{m_pFileReader->ReadGroupInfo(groupId, pOutValue)}; if (m_pParametersHook != nullptr) result |= m_pParametersHook->ReadGroupInfo(groupId, pOutValue); @@ -238,7 +240,7 @@ bool SoundArchive::ReadGroupInfo(GroupInfo* pOutValue, ItemId groupId) const { } bool SoundArchive::detail_ReadFileInfo(FileId fileId, FileInfo* info) const { - bool result {m_pFileReader->ReadFileInfo(fileId, info, 0)}; + bool result{m_pFileReader->ReadFileInfo(fileId, info, 0)}; if (result && m_pParametersHook != nullptr) { m_pParametersHook->ReadFileInfo(fileId, info, 0); @@ -252,17 +254,21 @@ const detail::Util::Table* SoundArchive::detail_GetWaveArchiveIdTable(ItemI return m_pFileReader->GetWaveArchiveIdTable(id); } -detail::fnd::FileStream* SoundArchive::detail_OpenFileStream(FileId fileId, void* buffer, size_t size, - void* cacheBuffer, size_t cacheSize) const { - FileInfo fileInfo {}; - detail::fnd::FileStream* stream {}; +detail::fnd::FileStream* SoundArchive::detail_OpenFileStream(FileId fileId, void* buffer, + size_t size, void* cacheBuffer, + size_t cacheSize) const { + FileInfo fileInfo{}; + detail::fnd::FileStream* stream{}; if (detail_ReadFileInfo(fileId, &fileInfo)) { if (fileInfo.externalFilePath == nullptr) { - if (fileInfo.fileSize != FileInfo::InvalidSize && fileInfo.offsetFromFileBlockHead != FileInfo::InvalidOffset) - stream = OpenStream(buffer, size, m_FileBlockOffset + fileInfo.offsetFromFileBlockHead, fileInfo.fileSize); - } - else { - stream = OpenExtStreamImpl(buffer, size, fileInfo.externalFilePath, cacheBuffer, cacheSize); + if (fileInfo.fileSize != FileInfo::InvalidSize && + fileInfo.offsetFromFileBlockHead != FileInfo::InvalidOffset) + stream = + OpenStream(buffer, size, m_FileBlockOffset + fileInfo.offsetFromFileBlockHead, + fileInfo.fileSize); + } else { + stream = + OpenExtStreamImpl(buffer, size, fileInfo.externalFilePath, cacheBuffer, cacheSize); } } @@ -274,11 +280,11 @@ const detail::Util::Table* SoundArchive::detail_GetAttachedGroupTable(FileI } void SoundArchive::SetExternalFileRoot(const char* extFileRoot) { - size_t len {std::strlen(extFileRoot)}; - size_t nullPos {len + 1}; + size_t len{std::strlen(extFileRoot)}; + size_t nullPos{len + 1}; util::Strlcpy(m_ExtFileRoot, extFileRoot, std::min(sizeof(m_ExtFileRoot), nullPos)); - + if (extFileRoot[len - 1] != '/') { m_ExtFileRoot[len] = '/'; ++len; @@ -286,7 +292,8 @@ void SoundArchive::SetExternalFileRoot(const char* extFileRoot) { m_ExtFileRoot[len] = '\0'; } -bool SoundArchive::ReadStreamSoundFilePath(char* outFilePathBuffer, size_t filePathBufferSize, ItemId soundId) const { +bool SoundArchive::ReadStreamSoundFilePath(char* outFilePathBuffer, size_t filePathBufferSize, + ItemId soundId) const { if (GetSoundType(soundId) == SoundType_Stream) { SoundInfo soundInfo; if (!ReadSoundInfo(&soundInfo, soundId)) @@ -296,10 +303,11 @@ bool SoundArchive::ReadStreamSoundFilePath(char* outFilePathBuffer, size_t fileP if (!detail_ReadFileInfo(soundInfo.fileId, &fileInfo)) return false; - const char* result {}; + const char* result{}; if (fileInfo.externalFilePath != nullptr) - result = detail_GetExternalFileFullPath(fileInfo.externalFilePath, outFilePathBuffer, filePathBufferSize); - + result = detail_GetExternalFileFullPath(fileInfo.externalFilePath, outFilePathBuffer, + filePathBufferSize); + return result != nullptr; } @@ -308,34 +316,33 @@ bool SoundArchive::ReadStreamSoundFilePath(char* outFilePathBuffer, size_t fileP void SoundArchive::FileAccessBegin() const {} -void SoundArchive::FileAccessEnd() const {} +void SoundArchive::FileAccessEnd() const {} // NON_MATCHING: still unsure on fnd::strncat's implementation, // or the whole function really. Leaving as TODO -const char* SoundArchive::detail_GetExternalFileFullPath(const char* externalFilePath, - char* pathBuffer, - size_t bufSize) const { +const char* SoundArchive::detail_GetExternalFileFullPath(const char* externalFilePath, + char* pathBuffer, size_t bufSize) const { if (*externalFilePath != '/') { - size_t dirLen {strlen(externalFilePath)}; - size_t fileLen {strlen(m_ExtFileRoot)}; + size_t dirLen{strlen(externalFilePath)}; + size_t fileLen{strlen(m_ExtFileRoot)}; if (fileLen + dirLen < bufSize) { if (bufSize > fileLen + 1) bufSize += 1; - + util::Strlcpy(pathBuffer, externalFilePath, bufSize); detail::fnd::strncat(pathBuffer, bufSize, m_ExtFileRoot, fileLen); pathBuffer[bufSize - 1] = '\0'; externalFilePath = pathBuffer; - } - else { + } else { externalFilePath = nullptr; } } - + return externalFilePath; } bool SoundArchive::IsAddon() const { return false; } -} // namespace nn::atk \ No newline at end of file + +} // namespace nn::atk diff --git a/src/NintendoWare/atk/atk_SoundArchivePlayer.cpp b/src/NintendoWare/atk/atk_SoundArchivePlayer.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/atk_SoundArchivePlayer.cpp +++ b/src/NintendoWare/atk/atk_SoundArchivePlayer.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/atk_SoundDataManager.cpp b/src/NintendoWare/atk/atk_SoundDataManager.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/atk_SoundDataManager.cpp +++ b/src/NintendoWare/atk/atk_SoundDataManager.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/atk_SoundHandle.cpp b/src/NintendoWare/atk/atk_SoundHandle.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/atk_SoundHandle.cpp +++ b/src/NintendoWare/atk/atk_SoundHandle.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/atk_SoundHeap.cpp b/src/NintendoWare/atk/atk_SoundHeap.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/atk_SoundHeap.cpp +++ b/src/NintendoWare/atk/atk_SoundHeap.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/atk_SoundPlayer.cpp b/src/NintendoWare/atk/atk_SoundPlayer.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/atk_SoundPlayer.cpp +++ b/src/NintendoWare/atk/atk_SoundPlayer.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/atk_SoundStartable.cpp b/src/NintendoWare/atk/atk_SoundStartable.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/atk_SoundStartable.cpp +++ b/src/NintendoWare/atk/atk_SoundStartable.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/atk_SoundSystem.cpp b/src/NintendoWare/atk/atk_SoundSystem.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/atk_SoundSystem.cpp +++ b/src/NintendoWare/atk/atk_SoundSystem.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/atk_StreamSoundHandle.cpp b/src/NintendoWare/atk/atk_StreamSoundHandle.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/atk_StreamSoundHandle.cpp +++ b/src/NintendoWare/atk/atk_StreamSoundHandle.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/atk_AdvancedWaveSound.cpp b/src/NintendoWare/atk/detail/atk_AdvancedWaveSound.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/atk_AdvancedWaveSound.cpp +++ b/src/NintendoWare/atk/detail/atk_AdvancedWaveSound.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundFile.cpp b/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundFile.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundFile.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundFileReader.cpp b/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundFileReader.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundFileReader.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundPlayer.cpp b/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundPlayer.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundPlayer.cpp +++ b/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundPlayer.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundRuntime.cpp b/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundRuntime.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundRuntime.cpp +++ b/src/NintendoWare/atk/detail/atk_AdvancedWaveSoundRuntime.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index c9e892fa..0d555210 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -7,6 +7,69 @@ namespace nn::atk::detail { +namespace { + +void SetSoundPlayerCalculationValues(SoundParamCalculationValues::SoundPlayerParam& param, + const SoundPlayer& player) { + param.volume = player.GetVolume(); + param.lpf = player.GetLowPassFilterFrequency(); + param.bqfType = player.GetBiquadFilterType(); + param.bqfValue = player.GetBiquadFilterValue(); + + for (int i{0}; i < OutputDevice_Count; ++i) { + const OutputDevice device{static_cast(i)}; + + param.outputVolume[device] = player.GetOutputVolume(device); + param.outputMainSend[device] = player.GetOutputMainSend(device); + + for (int k{0}; k < AuxBus_Count; ++k) { + const AuxBus bus{static_cast(k)}; + param.outputEffectSend[device][bus] = player.GetOutputFxSend(device, bus); + } + } +} + +void SetSound3DCalculationValues(SoundParamCalculationValues::Sound3DParam& param, + const SoundParam& ambientParam) { + param.volume = ambientParam.GetVolume(); + param.pitch = ambientParam.GetPitch(); + param.lpf = ambientParam.GetLpf(); + param.bqfType = ambientParam.GetBiquadFilterType(); + param.bqfValue = ambientParam.GetBiquadFilterValue(); + param.outputLineFlag = ambientParam.GetOutputLineFlag(); + param.playerPriority = ambientParam.GetPriority(); + + for (int i{0}; i < OutputDevice_Count; ++i) { + const OutputAmbientParam* pAmbientParam{&ambientParam.GetTvParam()}; + const OutputDevice device{static_cast(i)}; + + param.outputVolume[device] = pAmbientParam->GetVolume(); + param.outputPan[device] = pAmbientParam->GetPan(); + param.outputSurroundPan[device] = pAmbientParam->GetSurroundPan(); + + for (int k{0}; k < AuxBus_Count; ++k) { + const AuxBus bus{static_cast(k)}; + param.outputEffectSend[device][bus] = pAmbientParam->GetEffectSend(bus); + } + } +} + +void SetSoundActorCalculationValues(SoundParamCalculationValues::SoundActorParam& param, + const SoundActorParam& actorParam) { + param.volume = actorParam.volume; + param.pitch = actorParam.pitch; + param.lpf = actorParam.lpf; + + for (int i{0}; i < OutputDevice_Count; ++i) { + const OutputDevice device{static_cast(i)}; + + param.outputVolume[device] = actorParam.tvVolume; + param.outputPan[device] = actorParam.tvPan; + } +} + +} // anonymous namespace + // NON_MATCHING on versions lower than 4.0.0 BasicSound::BasicSound() = default; @@ -530,6 +593,49 @@ int BasicSound::GetRemainingMuteFadeFrames() const { return m_MuteFadeVolume.GetRemainingCount(); } +void BasicSound::CalculateSoundParamCalculationValues( + SoundParamCalculationValues* pOutValue) const { + pOutValue->soundArchiveParam.volume = m_InitVolume; + + SetSoundPlayerCalculationValues(pOutValue->soundPlayerParam, *m_pSoundPlayer); + SetSound3DCalculationValues(pOutValue->sound3DParam, m_AmbientParam); + SetSoundActorCalculationValues(pOutValue->soundActorParam, m_ActorParam); + + pOutValue->soundHandleParam.volume = m_CommonParam.GetVolume(); + pOutValue->soundHandleParam.pitch = m_Pitch; + pOutValue->soundHandleParam.lpf = m_LpfFreq; + pOutValue->soundHandleParam.bqfType = static_cast(m_BiquadFilterType); + pOutValue->soundHandleParam.bqfValue = m_BiquadFilterValue; + pOutValue->soundHandleParam.outputLineFlag = m_OutputLineFlag; + pOutValue->soundHandleParam.mixMode = m_CommonParam.mixMode; + pOutValue->soundHandleParam.pan = m_CommonParam.pan; + pOutValue->soundHandleParam.surroundPan = m_CommonParam.span; + pOutValue->soundHandleParam.mainSend = m_CommonParam.send[OutputDeviceIndex_Main]; + pOutValue->soundHandleParam.playerPriority = m_Priority; + + for (int i{0}; i < AuxBus_Count; ++i) + pOutValue->soundHandleParam.effectSend[i] = m_CommonParam.send[1L + i]; + + for (int i{0}; i < OutputDevice_Count; ++i) { + const OutputDevice device{static_cast(i)}; + + pOutValue->soundHandleParam.outputVolume[device] = m_OutputParam[device].volume; + pOutValue->soundHandleParam.outputPan[device] = m_OutputParam[device].pan; + pOutValue->soundHandleParam.outputSurroundPan[device] = m_OutputParam[device].span; + pOutValue->soundHandleParam.outputMainSend[device] = + m_OutputParam[device].send[OutputDeviceIndex_Main]; + + for (int k{0}; k < AuxBus_Count; ++k) + pOutValue->soundHandleParam.outputEffectSend[device][1L + k] = + m_OutputParam[device].send[1L + k]; + + pOutValue->soundHandleParam.outputMixParameter[device][0] = + m_OutputParam[device].mixParameter[0]; + pOutValue->soundHandleParam.outputMixParameter[device][1] = + m_OutputParam[device].mixParameter[1]; + } +} + void BasicSound::SetId(u32 id) { m_Id = id; } diff --git a/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp b/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/atk_BusMixVolumePacket.cpp b/src/NintendoWare/atk/detail/atk_BusMixVolumePacket.cpp index b6d01310..61e9287f 100644 --- a/src/NintendoWare/atk/detail/atk_BusMixVolumePacket.cpp +++ b/src/NintendoWare/atk/detail/atk_BusMixVolumePacket.cpp @@ -2,10 +2,12 @@ #include namespace nn::atk::detail { + BusMixVolumePacket::BusMixVolumePacket() = default; size_t BusMixVolumePacket::GetRequiredMemSize(int busCount) { - size_t result {util::align_up(busCount, 8)}; + size_t result{util::align_up(busCount, 8)}; return result; } -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp b/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp +++ b/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp +++ b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/atk_GroupFile.cpp b/src/NintendoWare/atk/detail/atk_GroupFile.cpp index 92ff37cb..73793c1e 100644 --- a/src/NintendoWare/atk/detail/atk_GroupFile.cpp +++ b/src/NintendoWare/atk/detail/atk_GroupFile.cpp @@ -3,18 +3,17 @@ #include namespace nn::atk::detail { + const GroupFile::InfoBlock* GroupFile::FileHeader::GetInfoBlock() const { - return util::ConstBytePtr(GetBlock(ElementType_GroupFile_InfoBlock)) - .Get(); + return util::ConstBytePtr(GetBlock(ElementType_GroupFile_InfoBlock)).Get(); } const GroupFile::FileBlock* GroupFile::FileHeader::GetFileBlock() const { - return util::ConstBytePtr(GetBlock(ElementType_GroupFile_FileBlock)) - .Get(); + return util::ConstBytePtr(GetBlock(ElementType_GroupFile_FileBlock)).Get(); } const GroupFile::InfoExBlock* GroupFile::FileHeader::GetInfoExBlock() const { - return util::ConstBytePtr(GetBlock(ElementType_GroupFile_InfoExBlock)) - .Get(); + return util::ConstBytePtr(GetBlock(ElementType_GroupFile_InfoExBlock)).Get(); } -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/atk_GroupFileReader.cpp b/src/NintendoWare/atk/detail/atk_GroupFileReader.cpp index b667bd82..f2c7000c 100644 --- a/src/NintendoWare/atk/detail/atk_GroupFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_GroupFileReader.cpp @@ -84,4 +84,4 @@ bool GroupFileReader::ReadGroupItemInfoEx(GroupFile::GroupItemInfoEx* out, u32 i return true; } -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/atk_OutputAdditionalParam.cpp b/src/NintendoWare/atk/detail/atk_OutputAdditionalParam.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/atk_OutputAdditionalParam.cpp +++ b/src/NintendoWare/atk/detail/atk_OutputAdditionalParam.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp b/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp +++ b/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/atk_PlayerHeapDataManager.cpp b/src/NintendoWare/atk/detail/atk_PlayerHeapDataManager.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/atk_PlayerHeapDataManager.cpp +++ b/src/NintendoWare/atk/detail/atk_PlayerHeapDataManager.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/atk_RegionManager.cpp b/src/NintendoWare/atk/detail/atk_RegionManager.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/atk_RegionManager.cpp +++ b/src/NintendoWare/atk/detail/atk_RegionManager.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp index d99c77f8..38de89e1 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFile.cpp @@ -726,4 +726,4 @@ const SoundArchiveFile::ExternalFileInfo* SoundArchiveFile::FileInfo::GetExterna return util::ConstBytePtr(this, toFileLocation.offset).Get(); } -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveFileReader.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveFileReader.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveFileReader.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveManager.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveManager.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveManager.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveManager.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/atk_StartInfoReader.cpp b/src/NintendoWare/atk/detail/atk_StartInfoReader.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/atk_StartInfoReader.cpp +++ b/src/NintendoWare/atk/detail/atk_StartInfoReader.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/atk_VolumeThroughModePacket.cpp b/src/NintendoWare/atk/detail/atk_VolumeThroughModePacket.cpp index 22663deb..e6aba22f 100644 --- a/src/NintendoWare/atk/detail/atk_VolumeThroughModePacket.cpp +++ b/src/NintendoWare/atk/detail/atk_VolumeThroughModePacket.cpp @@ -1,7 +1,3 @@ #include -namespace nn::atk::detail { - - - -} // namespace nn::atk::detail \ No newline at end of file +namespace nn::atk::detail {} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp b/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp index 00b50b47..2712ad09 100644 --- a/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveArchiveFile.cpp @@ -3,11 +3,12 @@ #include namespace nn::atk::detail { -const WaveArchiveFile::InfoBlock* WaveArchiveFile::FileHeader::GetInfoBlock() const { // 28 + +const WaveArchiveFile::InfoBlock* WaveArchiveFile::FileHeader::GetInfoBlock() const { // 28 return util::ConstBytePtr(this, GetInfoBlockOffset()).Get(); } -const WaveArchiveFile::FileBlock* WaveArchiveFile::FileHeader::GetFileBlock() const { // 34 +const WaveArchiveFile::FileBlock* WaveArchiveFile::FileHeader::GetFileBlock() const { // 34 return util::ConstBytePtr(this, GetFileBlockOffset()).Get(); } @@ -28,7 +29,7 @@ u32 WaveArchiveFile::FileHeader::GetFileBlockOffset() const { } const Util::ReferenceWithSize* WaveArchiveFile::FileHeader::GetReferenceBy(u16 typeId) const { - for (int i {0}; i < BlockCount; ++i) { + for (int i{0}; i < BlockCount; ++i) { if (toBlocks[i].IsValidTypeId(typeId)) { return &toBlocks[i]; } @@ -36,4 +37,5 @@ const Util::ReferenceWithSize* WaveArchiveFile::FileHeader::GetReferenceBy(u16 t return nullptr; } -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp index 71c1458b..0123b3a0 100644 --- a/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveArchiveFileReader.cpp @@ -122,4 +122,4 @@ bool WaveArchiveFileReader::HasIndividualLoadTable() const { return *signature == SignatureWarcTable; } -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/atk_WaveFile.cpp b/src/NintendoWare/atk/detail/atk_WaveFile.cpp index a852bbc0..5e58f9b6 100644 --- a/src/NintendoWare/atk/detail/atk_WaveFile.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveFile.cpp @@ -3,19 +3,18 @@ #include namespace nn::atk::detail { + const WaveFile::InfoBlock* WaveFile::FileHeader::GetInfoBlock() const { - return util::ConstBytePtr(GetBlock(ElementType_WaveFile_InfoBlock)) - .Get(); + return util::ConstBytePtr(GetBlock(ElementType_WaveFile_InfoBlock)).Get(); } const WaveFile::DataBlock* WaveFile::FileHeader::GetDataBlock() const { - return util::ConstBytePtr(GetBlock(ElementType_WaveFile_DataBlock)) - .Get(); + return util::ConstBytePtr(GetBlock(ElementType_WaveFile_DataBlock)).Get(); } const WaveFile::ChannelInfo& WaveFile::InfoBlockBody::GetChannelInfo(int channelIndex) const { return *util::ConstBytePtr(channelInfoReferenceTable.GetReferedItem(channelIndex)) - .Get(); + .Get(); } const void* WaveFile::ChannelInfo::GetSamplesAddress(const void* dataBlockBodyAddress) const { @@ -23,7 +22,7 @@ const void* WaveFile::ChannelInfo::GetSamplesAddress(const void* dataBlockBodyAd } const WaveFile::DspAdpcmInfo& WaveFile::ChannelInfo::GetDspAdpcmInfo() const { - return *util::ConstBytePtr(this).Advance(referToAdpcmInfo.offset) - .Get(); + return *util::ConstBytePtr(this).Advance(referToAdpcmInfo.offset).Get(); } -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp b/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp index 1e3c8edb..4a4d0d51 100644 --- a/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp +++ b/src/NintendoWare/atk/detail/atk_WaveFileReader.cpp @@ -125,4 +125,4 @@ WaveFileReader::GetWaveDataAddress(const WaveFile::ChannelInfo* info, return info->GetSamplesAddress(m_pDataBlockBody); } -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/debug/atk_Debug.cpp b/src/NintendoWare/atk/detail/debug/atk_Debug.cpp index 3dd4cb29..d077fa7d 100644 --- a/src/NintendoWare/atk/detail/debug/atk_Debug.cpp +++ b/src/NintendoWare/atk/detail/debug/atk_Debug.cpp @@ -2,17 +2,18 @@ namespace nn::atk { namespace { -const u32 NotEnoughSeqSound {0b00001}; -const u32 NotEnoughStrmSound {0b00010}; -const u32 NotEnoughWaveSound {0b00100}; -const u32 NotEnoughSeqTrack {0b01000}; -const u32 NotEnoughStrmChannel {0b10000}; -const u32 NotEnoughInstance {0b11111}; + +const u32 NotEnoughSeqSound{0b00001}; +const u32 NotEnoughStrmSound{0b00010}; +const u32 NotEnoughWaveSound{0b00100}; +const u32 NotEnoughSeqTrack{0b01000}; +const u32 NotEnoughStrmChannel{0b10000}; +const u32 NotEnoughInstance{0b11111}; u32 gWarningFlag = NotEnoughInstance; u32 GetWarningBitFlag(DebugWarningFlag warning) { - u32 bitFlag {0}; + u32 bitFlag{0}; switch (warning) { case DebugWarningFlag_NotEnoughInstance: @@ -30,7 +31,7 @@ u32 GetWarningBitFlag(DebugWarningFlag warning) { case DebugWarningFlag_NotEnoughWavesound: bitFlag = NotEnoughWaveSound; break; - + case DebugWarningFlag_NotEnoughSeqtrack: bitFlag = NotEnoughSeqTrack; break; @@ -42,10 +43,11 @@ u32 GetWarningBitFlag(DebugWarningFlag warning) { return bitFlag; } -} // anonymous namespace + +} // anonymous namespace void Debug_SetWarningFlag(DebugWarningFlag warning, bool enable) { - u32 bitFlag {GetWarningBitFlag(warning)}; + u32 bitFlag{GetWarningBitFlag(warning)}; if (enable) gWarningFlag |= bitFlag; @@ -54,10 +56,11 @@ void Debug_SetWarningFlag(DebugWarningFlag warning, bool enable) { } namespace detail { + DebugLogFunc g_DebugLogHookFunc; bool Debug_GetWarningFlag(DebugWarningFlag warning) { - u32 bitFlag {GetWarningBitFlag(warning)}; + u32 bitFlag{GetWarningBitFlag(warning)}; return (bitFlag & ~gWarningFlag) == 0; } @@ -93,5 +96,6 @@ const char* Debug_GetSoundTypeString(DebugSoundType type) { return ""; } } -} // namespace nn::atk::detail -} // namespace nn::atk \ No newline at end of file + +} // namespace detail +} // namespace nn::atk diff --git a/src/NintendoWare/atk/detail/dsp/atk_BiquadFilterPresets.cpp b/src/NintendoWare/atk/detail/dsp/atk_BiquadFilterPresets.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/dsp/atk_BiquadFilterPresets.cpp +++ b/src/NintendoWare/atk/detail/dsp/atk_BiquadFilterPresets.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/dsp/atk_DecodeAdpcm.cpp b/src/NintendoWare/atk/detail/dsp/atk_DecodeAdpcm.cpp index fa33e6bb..fa3b234f 100644 --- a/src/NintendoWare/atk/detail/dsp/atk_DecodeAdpcm.cpp +++ b/src/NintendoWare/atk/detail/dsp/atk_DecodeAdpcm.cpp @@ -1,21 +1,17 @@ #include namespace nn::atk::detail { -void DecodeDspAdpcm(position_t playPosition, - AdpcmContext& context, - const AdpcmParam& param, - const void* adpcmData, - size_t decodeSamples, - s16* dest) -{ + +void DecodeDspAdpcm(position_t playPosition, AdpcmContext& context, const AdpcmParam& param, + const void* adpcmData, size_t decodeSamples, s16* dest) { position_t frame = playPosition / 14; position_t frameFrac = playPosition - frame * 14; const u8* frameBegin = reinterpret_cast(adpcmData) + (frame * 8); - s32 pred = context.audioAdpcmContext.predScale >> 4; + s32 pred = context.audioAdpcmContext.predScale >> 4; s32 scale = context.audioAdpcmContext.predScale & 0xF; - for (u32 i {0}; i < decodeSamples; ++i) { + for (u32 i{0}; i < decodeSamples; ++i) { if (frameFrac == 0) { const u8 pred_scale = *frameBegin; context.audioAdpcmContext.predScale = pred_scale; @@ -38,10 +34,10 @@ void DecodeDspAdpcm(position_t playPosition, s16 gain = static_cast(1 << scale); s32 val = a1 * context.audioAdpcmContext.history[0]; - val += a2 * context.audioAdpcmContext.history[1]; - val += gain * nibble; + val += a2 * context.audioAdpcmContext.history[1]; + val += gain * nibble; val >>= 10; - val += 1; + val += 1; val >>= 1; if (val > SHRT_MAX) @@ -64,4 +60,5 @@ void DecodeDspAdpcm(position_t playPosition, } } } -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/dsp/atk_DspadpcmReader.cpp b/src/NintendoWare/atk/detail/dsp/atk_DspadpcmReader.cpp index 5a419c2f..7570d34a 100644 --- a/src/NintendoWare/atk/detail/dsp/atk_DspadpcmReader.cpp +++ b/src/NintendoWare/atk/detail/dsp/atk_DspadpcmReader.cpp @@ -6,6 +6,7 @@ namespace nn::atk::detail { namespace { + struct InternalDSPADPCMInfo { u32 sampleCount; u32 adpcmNibbleCount; @@ -26,12 +27,14 @@ struct InternalDSPADPCMInfo { u16 pad[11]; }; static_assert(sizeof(InternalDSPADPCMInfo) == 0x60); -} // anonymous namespace + +} // anonymous namespace DspadpcmReader::DspadpcmReader() = default; bool DspadpcmReader::ReadWaveInfo(WaveInfo* info) const { - const InternalDSPADPCMInfo& data {*util::ConstBytePtr(m_pDspadpcmData).Get()}; + const InternalDSPADPCMInfo& data{ + *util::ConstBytePtr(m_pDspadpcmData).Get()}; info->sampleFormat = SampleFormat_DspAdpcm; info->loopFlag = false; @@ -39,8 +42,9 @@ bool DspadpcmReader::ReadWaveInfo(WaveInfo* info) const { info->sampleRate = data.sampleRate; info->loopStartFrame = 0; info->loopEndFrame = data.sampleCount; - - info->channelParam[0].dataAddress = util::ConstBytePtr(m_pDspadpcmData, sizeof(InternalDSPADPCMInfo)).Get(); + + info->channelParam[0].dataAddress = + util::ConstBytePtr(m_pDspadpcmData, sizeof(InternalDSPADPCMInfo)).Get(); std::memcpy(info->channelParam[0].adpcmParam.coef, data.coef, sizeof(data.coef)); int yn1 = data.yn1; info->channelParam[0].adpcmParam.predScale = data.ps; @@ -48,4 +52,5 @@ bool DspadpcmReader::ReadWaveInfo(WaveInfo* info) const { info->channelParam[0].adpcmParam.yn2 = data.yn2; return true; } -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/dsp/atk_HardwareManager.cpp b/src/NintendoWare/atk/detail/dsp/atk_HardwareManager.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/dsp/atk_HardwareManager.cpp +++ b/src/NintendoWare/atk/detail/dsp/atk_HardwareManager.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/seq/atk_Bank.cpp b/src/NintendoWare/atk/detail/seq/atk_Bank.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/seq/atk_Bank.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_Bank.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp index 3839c724..83fb3915 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFile.cpp @@ -4,14 +4,15 @@ namespace nn::atk::detail { namespace { -const u8 DefaultOriginalKey {60}; -const u8 DefaultVolume {127}; -const u8 DefaultPan {64}; -const float DefaultPitch {1.0}; -const bool DefaultIgnoreNoteOff {false}; -const u8 DefaultKeyGroup {0}; -const u8 DefaultInterpolationType {0}; -const AdshrCurve DefaultAdshrCurve {127, 127, 127, 127, 127}; + +const u8 DefaultOriginalKey{60}; +const u8 DefaultVolume{127}; +const u8 DefaultPan{64}; +const float DefaultPitch{1.0}; +const bool DefaultIgnoreNoteOff{false}; +const u8 DefaultKeyGroup{0}; +const u8 DefaultInterpolationType{0}; +const AdshrCurve DefaultAdshrCurve{127, 127, 127, 127, 127}; enum VelocityRegionBitFlag { VelocityRegionBitFlag_Key = 0, @@ -29,9 +30,7 @@ enum VelocityRegionBitFlag { struct DirectChunk { Util::Reference toRegion; - const void* GetRegion() const { - return util::ConstBytePtr(this, toRegion.offset).Get(); - } + const void* GetRegion() const { return util::ConstBytePtr(this, toRegion.offset).Get(); } }; static_assert(sizeof(DirectChunk) == 0x8); @@ -39,15 +38,16 @@ struct RangeChunk { Util::Table borderTable; const Util::Reference& GetRegionTableAddress(int index) const { - return *util::ConstBytePtr(this, sizeof(borderTable.count) - + util::align_up(borderTable.count, 4) - + sizeof(Util::Reference) * index).Get(); + return *util::ConstBytePtr(this, sizeof(borderTable.count) + + util::align_up(borderTable.count, 4) + + sizeof(Util::Reference) * index) + .Get(); } const void* GetRegion(u32 index) const { - bool isFoundRangeChunkIndex {false}; - u32 regionTableIndex {0}; - for (u32 i {0}; i < borderTable.count; ++i) { + bool isFoundRangeChunkIndex{false}; + u32 regionTableIndex{0}; + for (u32 i{0}; i < borderTable.count; ++i) { if (index <= borderTable.item[i]) { regionTableIndex = i; isFoundRangeChunkIndex = true; @@ -58,7 +58,7 @@ struct RangeChunk { if (!isFoundRangeChunkIndex) return nullptr; - const Util::Reference& ref {GetRegionTableAddress(regionTableIndex)}; + const Util::Reference& ref{GetRegionTableAddress(regionTableIndex)}; return util::ConstBytePtr(this, ref.offset).Get(); } }; @@ -79,12 +79,7 @@ struct IndexChunk { }; static_assert(sizeof(IndexChunk) == 0xc); -enum RegionType { - RegionType_Direct, - RegionType_Range, - RegionType_Index, - RegionType_Unknown -}; +enum RegionType { RegionType_Direct, RegionType_Range, RegionType_Index, RegionType_Unknown }; RegionType GetRegionType(u16 typeId) { switch (typeId) { @@ -99,31 +94,30 @@ RegionType GetRegionType(u16 typeId) { default: return RegionType_Unknown; - } } const void* GetDirectChunk(const void* regionChunk) { - const DirectChunk& directChunk {*reinterpret_cast(regionChunk)}; + const DirectChunk& directChunk{*reinterpret_cast(regionChunk)}; return directChunk.GetRegion(); } const void* GetRangeChunk(const void* regionChunk, u32 index) { - const RangeChunk& rangeChunk {*reinterpret_cast(regionChunk)}; + const RangeChunk& rangeChunk{*reinterpret_cast(regionChunk)}; return rangeChunk.GetRegion(index); } const void* GetIndexChunk(const void* regionChunk, u32 index) { - const IndexChunk& indexChunk {*reinterpret_cast(regionChunk)}; - + const IndexChunk& indexChunk{*reinterpret_cast(regionChunk)}; + return indexChunk.GetRegion(index); } const void* GetRegion(const void* startPtr, u16 typeId, u32 offset, u32 index) { - const void* regionChunk {util::ConstBytePtr(startPtr, offset).Get()}; - const void* region {nullptr}; + const void* regionChunk{util::ConstBytePtr(startPtr, offset).Get()}; + const void* region{nullptr}; switch (GetRegionType(typeId)) { case RegionType_Direct: @@ -146,26 +140,26 @@ const void* GetRegion(const void* startPtr, u16 typeId, u32 offset, u32 index) { return region; } -} // anonymous namespace + +} // anonymous namespace const BankFile::InfoBlock* BankFile::FileHeader::GetInfoBlock() const { - return util::ConstBytePtr(GetBlock(ElementType_BankFile_InfoBlock)) - .Get(); + return util::ConstBytePtr(GetBlock(ElementType_BankFile_InfoBlock)).Get(); } const Util::WaveIdTable& BankFile::InfoBlockBody::GetWaveIdTable() const { - return *util::ConstBytePtr(this).Advance(toWaveIdTable.offset) - .Get(); + return *util::ConstBytePtr(this).Advance(toWaveIdTable.offset).Get(); } const Util::ReferenceTable& BankFile::InfoBlockBody::GetInstrumentReferenceTable() const { - return *util::ConstBytePtr(this).Advance(toInstrumentReferenceTable.offset) - .Get(); + return *util::ConstBytePtr(this) + .Advance(toInstrumentReferenceTable.offset) + .Get(); } const BankFile::Instrument* BankFile::InfoBlockBody::GetInstrument(int programNo) const { - auto& table {GetInstrumentReferenceTable()}; - auto& ref {table.item[programNo]}; + auto& table{GetInstrumentReferenceTable()}; + auto& ref{table.item[programNo]}; if (ref.IsValidTypeId(ElementType_BankFile_InstrumentInfo)) return util::ConstBytePtr(table.GetReferedItem(programNo)).Get(); @@ -175,25 +169,19 @@ const BankFile::Instrument* BankFile::InfoBlockBody::GetInstrument(int programNo const BankFile::KeyRegion* BankFile::Instrument::GetKeyRegion(u32 key) const { return util::ConstBytePtr( - GetRegion(this, - toKeyRegionChunk.typeId, - toKeyRegionChunk.offset, - key) - ).Get(); + GetRegion(this, toKeyRegionChunk.typeId, toKeyRegionChunk.offset, key)) + .Get(); } const BankFile::VelocityRegion* BankFile::KeyRegion::GetVelocityRegion(u32 velocity) const { - return util::ConstBytePtr( - GetRegion(this, - toVelocityRegionChunk.typeId, - toVelocityRegionChunk.offset, - velocity) - ).Get(); + return util::ConstBytePtr(GetRegion(this, toVelocityRegionChunk.typeId, + toVelocityRegionChunk.offset, velocity)) + .Get(); } u8 BankFile::VelocityRegion::GetOriginalKey() const { u32 value; - bool result {optionParameter.GetValue(&value, VelocityRegionBitFlag_Key)}; + bool result{optionParameter.GetValue(&value, VelocityRegionBitFlag_Key)}; if (result) return value; @@ -202,7 +190,7 @@ u8 BankFile::VelocityRegion::GetOriginalKey() const { u8 BankFile::VelocityRegion::GetVolume() const { u32 value; - bool result {optionParameter.GetValue(&value, VelocityRegionBitFlag_Volume)}; + bool result{optionParameter.GetValue(&value, VelocityRegionBitFlag_Volume)}; if (result) return Util::DivideBy8bit(value, 0); @@ -211,7 +199,7 @@ u8 BankFile::VelocityRegion::GetVolume() const { u8 BankFile::VelocityRegion::GetPan() const { u32 value; - bool result {optionParameter.GetValue(&value, VelocityRegionBitFlag_Pan)}; + bool result{optionParameter.GetValue(&value, VelocityRegionBitFlag_Pan)}; if (result) return Util::DivideBy8bit(value, 0); @@ -220,7 +208,7 @@ u8 BankFile::VelocityRegion::GetPan() const { float BankFile::VelocityRegion::GetPitch() const { float value; - bool result {optionParameter.GetValueF32(&value, VelocityRegionBitFlag_Pitch)}; + bool result{optionParameter.GetValueF32(&value, VelocityRegionBitFlag_Pitch)}; if (result) return value; @@ -229,7 +217,7 @@ float BankFile::VelocityRegion::GetPitch() const { bool BankFile::VelocityRegion::IsIgnoreNoteOff() const { u32 value; - bool result {optionParameter.GetValue(&value, VelocityRegionBitFlag_InstrumentNoteParam)}; + bool result{optionParameter.GetValue(&value, VelocityRegionBitFlag_InstrumentNoteParam)}; if (result) return Util::DivideBy8bit(value, 0) != 0; @@ -238,7 +226,7 @@ bool BankFile::VelocityRegion::IsIgnoreNoteOff() const { u8 BankFile::VelocityRegion::GetKeyGroup() const { u32 value; - bool result {optionParameter.GetValue(&value, VelocityRegionBitFlag_InstrumentNoteParam)}; + bool result{optionParameter.GetValue(&value, VelocityRegionBitFlag_InstrumentNoteParam)}; if (result) return Util::DivideBy8bit(value, 1); @@ -247,7 +235,7 @@ u8 BankFile::VelocityRegion::GetKeyGroup() const { u8 BankFile::VelocityRegion::GetInterpolationType() const { u32 value; - bool result {optionParameter.GetValue(&value, VelocityRegionBitFlag_InstrumentNoteParam)}; + bool result{optionParameter.GetValue(&value, VelocityRegionBitFlag_InstrumentNoteParam)}; if (result) return Util::DivideBy8bit(value, 2); @@ -256,9 +244,9 @@ u8 BankFile::VelocityRegion::GetInterpolationType() const { const AdshrCurve& BankFile::VelocityRegion::GetAdshrCurve() const { u32 offsetToReference; - bool result {optionParameter.GetValue(&offsetToReference, VelocityRegionBitFlag_Envelope)}; + bool result{optionParameter.GetValue(&offsetToReference, VelocityRegionBitFlag_Envelope)}; if (result) { - const auto& ref {*util::ConstBytePtr(this, offsetToReference).Get()}; + const auto& ref{*util::ConstBytePtr(this, offsetToReference).Get()}; return *util::ConstBytePtr(&ref, ref.offset).Get(); } @@ -271,4 +259,5 @@ const BankFile::RegionParameter* BankFile::VelocityRegion::GetRegionParameter() return util::ConstBytePtr(this, sizeof(VelocityRegion)).Get(); } -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp b/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp index 1c96eefe..5c586a70 100644 --- a/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_BankFileReader.cpp @@ -105,4 +105,4 @@ const Util::WaveIdTable* BankFileReader::GetWaveIdTable() const { return &m_pInfoBlockBody->GetWaveIdTable(); } -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/seq/atk_MmlParser.cpp b/src/NintendoWare/atk/detail/seq/atk_MmlParser.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/seq/atk_MmlParser.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_MmlParser.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/seq/atk_MmlSequenceTrack.cpp b/src/NintendoWare/atk/detail/seq/atk_MmlSequenceTrack.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/seq/atk_MmlSequenceTrack.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_MmlSequenceTrack.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/seq/atk_MmlSequenceTrackAllocator.cpp b/src/NintendoWare/atk/detail/seq/atk_MmlSequenceTrackAllocator.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/seq/atk_MmlSequenceTrackAllocator.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_MmlSequenceTrackAllocator.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceSound.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceSound.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/seq/atk_SequenceSound.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_SequenceSound.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp index 7a8b630a..43508c8d 100644 --- a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFile.cpp @@ -5,28 +5,28 @@ #include namespace nn::atk::detail { + const SequenceSoundFile::DataBlock* SequenceSoundFile::FileHeader::GetDataBlock() const { - return util::ConstBytePtr(GetBlock(ElementType_SequenceSoundFile_DataBlock)) - .Get(); + return util::ConstBytePtr(GetBlock(ElementType_SequenceSoundFile_DataBlock)).Get(); } const SequenceSoundFile::LabelBlock* SequenceSoundFile::FileHeader::GetLabelBlock() const { - return util::ConstBytePtr(GetBlock(ElementType_SequenceSoundFile_LabelBlock)) - .Get(); + return util::ConstBytePtr(GetBlock(ElementType_SequenceSoundFile_LabelBlock)).Get(); } -const SequenceSoundFile::LabelInfo* SequenceSoundFile::LabelBlockBody::GetLabelInfo(int index) const { +const SequenceSoundFile::LabelInfo* +SequenceSoundFile::LabelBlockBody::GetLabelInfo(int index) const { return util::ConstBytePtr(labelInfoReferenceTable.GetReferedItem(index)).Get(); } const char* SequenceSoundFile::LabelBlockBody::GetLabel(int index) const { - const LabelInfo* labelInfo {GetLabelInfo(index)}; + const LabelInfo* labelInfo{GetLabelInfo(index)}; return labelInfo->label; } const char* SequenceSoundFile::LabelBlockBody::GetLabelByOffset(u32 offset) const { - for (int i {0}; i < GetLabelCount(); ++i) { - const LabelInfo* labelInfo {GetLabelInfo(i)}; + for (int i{0}; i < GetLabelCount(); ++i) { + const LabelInfo* labelInfo{GetLabelInfo(i)}; if (static_cast(labelInfo->referToSequenceData.offset) == offset) return labelInfo->label; } @@ -35,15 +35,15 @@ const char* SequenceSoundFile::LabelBlockBody::GetLabelByOffset(u32 offset) cons } bool SequenceSoundFile::LabelBlockBody::GetOffset(int index, u32* offsetPtr) const { - const LabelInfo* labelInfo {GetLabelInfo(index)}; + const LabelInfo* labelInfo{GetLabelInfo(index)}; *offsetPtr = labelInfo->referToSequenceData.offset; return true; } bool SequenceSoundFile::LabelBlockBody::GetOffsetByLabel(const char* label, u32* offsetPtr) const { - const size_t labelLength {strlen(label)}; - for (int i {0}; i < GetLabelCount(); ++i) { - const LabelInfo* labelInfo {GetLabelInfo(i)}; + const size_t labelLength{strlen(label)}; + for (int i{0}; i < GetLabelCount(); ++i) { + const LabelInfo* labelInfo{GetLabelInfo(i)}; if (strncmp(label, labelInfo->label, labelLength) == 0) { *offsetPtr = labelInfo->referToSequenceData.offset; return true; @@ -52,4 +52,5 @@ bool SequenceSoundFile::LabelBlockBody::GetOffsetByLabel(const char* label, u32* return false; } -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp index ac68dec9..133d7aca 100644 --- a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundFileReader.cpp @@ -53,4 +53,4 @@ const char* SequenceSoundFileReader::GetLabelByOffset(u32 offset) const { return m_pLabelBlockBody->GetLabelByOffset(offset); } -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundPlayer.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundPlayer.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundPlayer.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundPlayer.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundRuntime.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundRuntime.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/seq/atk_SequenceSoundRuntime.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_SequenceSoundRuntime.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/seq/atk_SequenceTrack.cpp b/src/NintendoWare/atk/detail/seq/atk_SequenceTrack.cpp index 92bcee0e..a247effe 100644 --- a/src/NintendoWare/atk/detail/seq/atk_SequenceTrack.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_SequenceTrack.cpp @@ -7,4 +7,4 @@ SequenceTrack::SequenceTrack() InitParam(); } -} // namespace nn::atk::detail::driver \ No newline at end of file +} // namespace nn::atk::detail::driver diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamBufferPool.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamBufferPool.cpp index fc01b1c8..7b0d67ba 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamBufferPool.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamBufferPool.cpp @@ -4,6 +4,7 @@ #include "nn/types.h" namespace nn::atk::detail::driver { + void StreamBufferPool::Initialize(void* buffer, size_t size, int blockCount) { if (blockCount == 0) return; @@ -15,7 +16,7 @@ void StreamBufferPool::Initialize(void* buffer, size_t size, int blockCount) { m_BlockCount = blockCount; m_BlockSize = util::align_down(size / blockCount, 64); m_AllocCount = 0; - for (int i {0}; i < BlockMax / BitPerByte; ++i) + for (int i{0}; i < BlockMax / BitPerByte; ++i) m_AllocFlags[i] = 0; } @@ -31,17 +32,18 @@ void* StreamBufferPool::Alloc() { if (m_AllocCount >= m_BlockCount) return nullptr; - const int availableByte {util::align_up(m_BlockCount, BitPerByte)}; + const int availableByte{util::align_up(m_BlockCount, BitPerByte)}; - for (int byteIndex {0}; byteIndex < availableByte / BitPerByte; ++byteIndex) { + for (int byteIndex{0}; byteIndex < availableByte / BitPerByte; ++byteIndex) { if (m_AllocFlags[byteIndex] != 0xff) { - const u8 byte {m_AllocFlags[byteIndex]}; + const u8 byte{m_AllocFlags[byteIndex]}; - u8 mask {1 << 0}; - for (int bitIndex {0}; bitIndex < BitPerByte; ++bitIndex) { + u8 mask{1 << 0}; + for (int bitIndex{0}; bitIndex < BitPerByte; ++bitIndex) { if ((byte & mask) == 0) { - const int totalIndex {bitIndex}; - void* buffer {util::BytePtr(m_Buffer).Advance(m_BlockSize * (totalIndex | byte)).Get()}; + const int totalIndex{bitIndex}; + void* buffer{ + util::BytePtr(m_Buffer).Advance(m_BlockSize * (totalIndex | byte)).Get()}; return buffer; } } @@ -52,15 +54,16 @@ void* StreamBufferPool::Alloc() { } void StreamBufferPool::Free(void* pPtr) { - ptrdiff_t offset {util::BytePtr(m_Buffer).Distance(pPtr)}; + ptrdiff_t offset{util::BytePtr(m_Buffer).Distance(pPtr)}; - const u64 totalIndex {offset / m_BlockSize}; + const u64 totalIndex{offset / m_BlockSize}; - const int mask {1 << (totalIndex & 0b111)}; - const u64 byteIndex {totalIndex}; - const u64 bitIndex {byteIndex / BitPerByte}; + const int mask{1 << (totalIndex & 0b111)}; + const u64 byteIndex{totalIndex}; + const u64 bitIndex{byteIndex / BitPerByte}; m_AllocFlags[bitIndex] &= ~mask; --m_AllocCount; } -} // namespace nn::atk::detail::driver \ No newline at end of file + +} // namespace nn::atk::detail::driver diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSound.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSound.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSound.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSound.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp index 4170fd45..c605912f 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFile.cpp @@ -3,6 +3,7 @@ #include namespace nn::atk::detail { + bool StreamSoundFile::FileHeader::HasSeekBlock() const { return GetReferenceBy(ElementType_StreamSoundFile_SeekBlock) != nullptr; } @@ -44,8 +45,8 @@ u32 StreamSoundFile::FileHeader::GetRegionBlockOffset() const { } const Util::ReferenceWithSize* StreamSoundFile::FileHeader::GetReferenceBy(u16 typeId) const { - for (int i {0}; i < dataBlocks; ++i) { - const Util::ReferenceWithSize* p {&toBlocks[i]}; + for (int i{0}; i < dataBlocks; ++i) { + const Util::ReferenceWithSize* p{&toBlocks[i]}; if (p->typeId == typeId) return p; } @@ -67,7 +68,8 @@ const StreamSoundFile::TrackInfoTable* StreamSoundFile::InfoBlockBody::GetTrackI return nullptr; } -const StreamSoundFile::ChannelInfoTable* StreamSoundFile::InfoBlockBody::GetChannelInfoTable() const { +const StreamSoundFile::ChannelInfoTable* +StreamSoundFile::InfoBlockBody::GetChannelInfoTable() const { if (toChannelInfoTable.IsValidTypeId(ElementType_Table_ReferenceTable)) return util::ConstBytePtr(this).Advance(toChannelInfoTable.offset).Get(); @@ -75,21 +77,28 @@ const StreamSoundFile::ChannelInfoTable* StreamSoundFile::InfoBlockBody::GetChan } const StreamSoundFile::TrackInfo* StreamSoundFile::TrackInfoTable::GetTrackInfo(u32 index) const { - return static_cast(table.GetReferedItem(index, ElementType_StreamSoundFile_TrackInfo)); + return static_cast( + table.GetReferedItem(index, ElementType_StreamSoundFile_TrackInfo)); } u32 StreamSoundFile::ChannelInfoTable::GetChannelCount() const { return table.count; } -const StreamSoundFile::ChannelInfo* StreamSoundFile::ChannelInfoTable::GetChannelInfo(u32 index) const { - return static_cast(table.GetReferedItem(index, ElementType_StreamSoundFile_ChannelInfo)); +const StreamSoundFile::ChannelInfo* +StreamSoundFile::ChannelInfoTable::GetChannelInfo(u32 index) const { + return static_cast( + table.GetReferedItem(index, ElementType_StreamSoundFile_ChannelInfo)); } -const StreamSoundFile::DspAdpcmChannelInfo* StreamSoundFile::ChannelInfo::GetDspAdpcmChannelInfo() const { +const StreamSoundFile::DspAdpcmChannelInfo* +StreamSoundFile::ChannelInfo::GetDspAdpcmChannelInfo() const { if (toDetailChannelInfo.IsValidTypeId(ElementType_Codec_DspAdpcmInfo)) - return util::ConstBytePtr(this).Advance(toDetailChannelInfo.offset).Get(); - + return util::ConstBytePtr(this) + .Advance(toDetailChannelInfo.offset) + .Get(); + return nullptr; } -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp index c48d7cca..b80bc3e6 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundFileReader.cpp @@ -143,4 +143,4 @@ bool StreamSoundFileReader::ReadDspAdpcmChannelInfo(DspAdpcmParam* pParam, return false; } -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundLoader.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPlayer.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPlayer.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPlayer.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPlayer.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp index 9c902916..ceb5b0d8 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFile.cpp @@ -3,18 +3,21 @@ #include namespace nn::atk::detail { + const StreamSoundFile::InfoBlock* StreamSoundPrefetchFile::FileHeader::GetInfoBlock() const { return util::ConstBytePtr(GetBlock(ElementType_StreamSoundFile_InfoBlock)) - .Get(); + .Get(); } const StreamSoundFile::RegionBlock* StreamSoundPrefetchFile::FileHeader::GetRegionBlock() const { return util::ConstBytePtr(GetBlock(ElementType_StreamSoundFile_RegionBlock)) - .Get(); + .Get(); } -const StreamSoundPrefetchFile::PrefetchDataBlock* StreamSoundPrefetchFile::FileHeader::GetPrefetchDataBlock() const { - return util::ConstBytePtr(GetBlock(ElementType_StreamSoundFile_PrefetchDataBlock)).Get(); +const StreamSoundPrefetchFile::PrefetchDataBlock* +StreamSoundPrefetchFile::FileHeader::GetPrefetchDataBlock() const { + return util::ConstBytePtr(GetBlock(ElementType_StreamSoundFile_PrefetchDataBlock)) + .Get(); } u32 StreamSoundPrefetchFile::FileHeader::GetPrefetchDataBlockSize() const { @@ -33,11 +36,13 @@ u32 StreamSoundPrefetchFile::FileHeader::GetRegionBlockOffset() const { return GetBlockOffset(ElementType_StreamSoundFile_RegionBlock); } -const StreamSoundPrefetchFile::PrefetchSample* StreamSoundPrefetchFile::PrefetchData::GetPrefetchSample() const { +const StreamSoundPrefetchFile::PrefetchSample* +StreamSoundPrefetchFile::PrefetchData::GetPrefetchSample() const { return util::ConstBytePtr(this).Advance(toPrefetchSample.offset).Get(); } const void* StreamSoundPrefetchFile::PrefetchSample::GetSampleAddress() const { return util::ConstBytePtr(data).Get(); } -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp index cfac34ba..f408a9e8 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundPrefetchFileReader.cpp @@ -1,16 +1,17 @@ #include namespace nn::atk::detail { -const u32 SignatureFileStp {0x50545346}; // FSTP -const u32 SignatureInfoBlockStp {0x4f464e49}; // INFO -const u32 SignaturePrefetchdataBlockStp {0x54414450}; // PDAT -const int SupportedFileVersionStp {0x10000}; -const int CurrentFileVersionStp {0x50200}; +const u32 SignatureFileStp{0x50545346}; // FSTP +const u32 SignatureInfoBlockStp{0x4f464e49}; // INFO +const u32 SignaturePrefetchdataBlockStp{0x54414450}; // PDAT -const int IncludeRegionInfoVersionStp {0x30000}; -const int IncludeCrc32CheckVersionStp {0x40000}; -const int IncludeRegionIndexCheckVersionStp {0x50100}; +const int SupportedFileVersionStp{0x10000}; +const int CurrentFileVersionStp{0x50200}; + +const int IncludeRegionInfoVersionStp{0x30000}; +const int IncludeCrc32CheckVersionStp{0x40000}; +const int IncludeRegionIndexCheckVersionStp{0x50100}; StreamSoundPrefetchFileReader::StreamSoundPrefetchFileReader() = default; @@ -19,22 +20,24 @@ StreamSoundPrefetchFileReader::~StreamSoundPrefetchFileReader() { } bool StreamSoundPrefetchFileReader::IsValidFileHeader(const void* streamSoundPrefetchFile) const { - const BinaryFileHeader& header {*util::ConstBytePtr(streamSoundPrefetchFile).Get()}; - - bool isSupportedVersion {header.signature == SignatureFileStp - && header.byteOrder == BinaryFileHeader::ValidByteOrderMark - && header.version >= SupportedFileVersionStp - && header.version <= CurrentFileVersionStp}; + const BinaryFileHeader& header{ + *util::ConstBytePtr(streamSoundPrefetchFile).Get()}; + + bool isSupportedVersion{header.signature == SignatureFileStp && + header.byteOrder == BinaryFileHeader::ValidByteOrderMark && + header.version >= SupportedFileVersionStp && + header.version <= CurrentFileVersionStp}; return isSupportedVersion; } void StreamSoundPrefetchFileReader::Initialize(const void* streamSoundPrefetchFile) { if (IsValidFileHeader(streamSoundPrefetchFile)) { - m_pHeader = util::ConstBytePtr(streamSoundPrefetchFile).Get(); - auto* infoBlock {m_pHeader->GetInfoBlock()}; + m_pHeader = + util::ConstBytePtr(streamSoundPrefetchFile).Get(); + auto* infoBlock{m_pHeader->GetInfoBlock()}; if (infoBlock->header.kind == SignatureInfoBlockStp) { - auto* dataBlock {m_pHeader->GetPrefetchDataBlock()}; + auto* dataBlock{m_pHeader->GetPrefetchDataBlock()}; if (dataBlock->header.kind == SignaturePrefetchdataBlockStp) { m_pInfoBlockBody = &infoBlock->body; m_pPrefetchDataBlockBody = &dataBlock->body; @@ -58,14 +61,18 @@ bool StreamSoundPrefetchFileReader::IsRegionIndexCheckAvailable() const { return m_pHeader->header.version >= IncludeRegionIndexCheckVersionStp; } -bool StreamSoundPrefetchFileReader::ReadStreamSoundInfo(StreamSoundFile::StreamSoundInfo* strmInfo) const { +bool StreamSoundPrefetchFileReader::ReadStreamSoundInfo( + StreamSoundFile::StreamSoundInfo* strmInfo) const { *strmInfo = *m_pInfoBlockBody->GetStreamSoundInfo(); return true; } -bool StreamSoundPrefetchFileReader::ReadDspAdpcmChannelInfo(DspAdpcmParam* pParam, DspAdpcmLoopParam* pLoopParam, +bool StreamSoundPrefetchFileReader::ReadDspAdpcmChannelInfo(DspAdpcmParam* pParam, + DspAdpcmLoopParam* pLoopParam, int channelIndex) const { - auto* src {m_pInfoBlockBody->GetChannelInfoTable()->GetChannelInfo(channelIndex)->GetDspAdpcmChannelInfo()}; + auto* src{m_pInfoBlockBody->GetChannelInfoTable() + ->GetChannelInfo(channelIndex) + ->GetDspAdpcmChannelInfo()}; if (src != nullptr) { *pParam = src->param; *pLoopParam = src->loopParam; @@ -75,21 +82,23 @@ bool StreamSoundPrefetchFileReader::ReadDspAdpcmChannelInfo(DspAdpcmParam* pPara return false; } -bool StreamSoundPrefetchFileReader::ReadPrefetchDataInfo(PrefetchDataInfo* pDataInfo, int prefetchIndex) const { - auto* data {m_pPrefetchDataBlockBody->GetPrefetchData(prefetchIndex)}; +bool StreamSoundPrefetchFileReader::ReadPrefetchDataInfo(PrefetchDataInfo* pDataInfo, + int prefetchIndex) const { + auto* data{m_pPrefetchDataBlockBody->GetPrefetchData(prefetchIndex)}; pDataInfo->startFrame = data->startFrame; pDataInfo->prefetchSize = data->prefetchSize; - auto* sample {data->GetPrefetchSample()}; + auto* sample{data->GetPrefetchSample()}; pDataInfo->dataAddress = sample->GetSampleAddress(); return true; } -bool StreamSoundPrefetchFileReader::ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo, u32 regionIndex) const { // 179 +bool StreamSoundPrefetchFileReader::ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo, + u32 regionIndex) const { // 179 if (m_RegionDataOffset != 0 && m_RegionInfoBytes != 0) { position_t offset = m_RegionDataOffset + static_cast(m_RegionInfoBytes) * regionIndex; - auto bytePtr {util::ConstBytePtr(m_pHeader)}; + auto bytePtr{util::ConstBytePtr(m_pHeader)}; *pInfo = *bytePtr.Advance(offset).Get(); return true; } @@ -97,4 +106,4 @@ bool StreamSoundPrefetchFileReader::ReadRegionInfo(StreamSoundFile::RegionInfo* return false; } -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamSoundRuntime.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamSoundRuntime.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamSoundRuntime.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamSoundRuntime.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/strm/atk_StreamTrack.cpp b/src/NintendoWare/atk/detail/strm/atk_StreamTrack.cpp index 65ef85c1..79c32887 100644 --- a/src/NintendoWare/atk/detail/strm/atk_StreamTrack.cpp +++ b/src/NintendoWare/atk/detail/strm/atk_StreamTrack.cpp @@ -1,8 +1,10 @@ #include namespace nn::atk::detail::driver { + void StreamChannel::AppendWaveBuffer(WaveBuffer* pBuffer, bool lastFlag) { if (m_pVoice != nullptr) m_pVoice->AppendWaveBuffer(0, pBuffer, lastFlag); } -} // namespace nn::atk::detail::driver \ No newline at end of file + +} // namespace nn::atk::detail::driver diff --git a/src/NintendoWare/atk/detail/thread/atk_CommandManager.cpp b/src/NintendoWare/atk/detail/thread/atk_CommandManager.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/thread/atk_CommandManager.cpp +++ b/src/NintendoWare/atk/detail/thread/atk_CommandManager.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/thread/atk_DriverCommand.cpp b/src/NintendoWare/atk/detail/thread/atk_DriverCommand.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/thread/atk_DriverCommand.cpp +++ b/src/NintendoWare/atk/detail/thread/atk_DriverCommand.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/thread/atk_SoundThread.cpp b/src/NintendoWare/atk/detail/thread/atk_SoundThread.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/thread/atk_SoundThread.cpp +++ b/src/NintendoWare/atk/detail/thread/atk_SoundThread.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/thread/atk_Task.cpp b/src/NintendoWare/atk/detail/thread/atk_Task.cpp index 8a620743..e2a715d4 100644 --- a/src/NintendoWare/atk/detail/thread/atk_Task.cpp +++ b/src/NintendoWare/atk/detail/thread/atk_Task.cpp @@ -1,9 +1,8 @@ #include namespace nn::atk::detail { -Task::Task() - : m_Event(os::EventClearMode_ManualClear) { - + +Task::Task() : m_Event(os::EventClearMode_ManualClear) { InitializeStatus(); SetId(0); @@ -11,4 +10,5 @@ Task::Task() } Task::~Task() = default; -} // namespace nn::atk::detail \ No newline at end of file + +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/thread/atk_TaskManager.cpp b/src/NintendoWare/atk/detail/thread/atk_TaskManager.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/thread/atk_TaskManager.cpp +++ b/src/NintendoWare/atk/detail/thread/atk_TaskManager.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/thread/atk_TaskThread.cpp b/src/NintendoWare/atk/detail/thread/atk_TaskThread.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/thread/atk_TaskThread.cpp +++ b/src/NintendoWare/atk/detail/thread/atk_TaskThread.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp index abc5729a..c1ed12f2 100644 --- a/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp +++ b/src/NintendoWare/atk/detail/util/atk_CurveAdshr.cpp @@ -150,4 +150,4 @@ s16 CurveAdshr::CalcDecibelSquare(int scale) { return DecibelSquareTable[scale]; } -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp b/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp index d55d0b92..98c98a0a 100644 --- a/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp +++ b/src/NintendoWare/atk/detail/util/atk_CurveLfo.cpp @@ -53,7 +53,7 @@ void CurveLfo::InitializeCurveTable() { CurveLfo::CurveFunc CurveLfo::RegisterUserCurve(CurveFunc func, u32 index) { s32 tableIndex = {static_cast(index + CurveLfoParam::CurveType_UserMin)}; - + CurveFunc tmp{g_CurveFuncTable[tableIndex]}; g_CurveFuncTable[tableIndex] = func; @@ -62,7 +62,7 @@ CurveLfo::CurveFunc CurveLfo::RegisterUserCurve(CurveFunc func, u32 index) { CurveLfo::CurveFunc CurveLfo::UnregisterUserCurve(u32 index) { s32 tableIndex = {static_cast(index + CurveLfoParam::CurveType_UserMin)}; - + CurveFunc tmp{g_CurveFuncTable[tableIndex]}; g_CurveFuncTable[tableIndex] = nullptr; @@ -139,4 +139,4 @@ void CurveLfoParam::Initialize() { phase = 0; } -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp index a41b8b99..d981cb11 100644 --- a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp +++ b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp @@ -71,7 +71,7 @@ int FrameHeap::SaveState() { if (m_pHeap->RecordState(m_SectionList.size())) { if (NewSection()) { int result; - + result = m_SectionList.size() - 1; return result; } @@ -125,4 +125,4 @@ void FrameHeap::Section::AppendBlock(Block* block) { m_BlockList.push_back(*block); } -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/util/atk_InstancePool.cpp b/src/NintendoWare/atk/detail/util/atk_InstancePool.cpp index 89b546a7..970bc336 100644 --- a/src/NintendoWare/atk/detail/util/atk_InstancePool.cpp +++ b/src/NintendoWare/atk/detail/util/atk_InstancePool.cpp @@ -69,4 +69,4 @@ void PoolImpl::FreeImpl(void* ptr) { m_pNext = head; } -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp b/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp index 41f7603d..fa083ff7 100644 --- a/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp +++ b/src/NintendoWare/atk/detail/util/atk_MemoryFileStream.cpp @@ -49,4 +49,4 @@ fnd::FndResult MemoryFileStream::Seek(position_t offset, fnd::Stream::SeekOrigin return fnd::FndResult{fnd::FndResultType_True}; } -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/util/atk_Util.cpp b/src/NintendoWare/atk/detail/util/atk_Util.cpp index c346d314..baeac4b4 100644 --- a/src/NintendoWare/atk/detail/util/atk_Util.cpp +++ b/src/NintendoWare/atk/detail/util/atk_Util.cpp @@ -10,6 +10,7 @@ namespace nn::atk::detail { namespace { + const float NoteTable[12]{ 1.00000000000000f, 1.05946309435930f, 1.12246204830937f, 1.18920711500272f, 1.25992104989487f, 1.33483985417003f, 1.41421356237310f, 1.49830707687668f, @@ -72,200 +73,167 @@ const float PitchTable[Util::PitchDivisionRange]{ }; const float Decibel2RatioTable[Util::VolumeDbMax - Util::VolumeDbMin + 1]{ - 0.000000000f, 3.05492E-05f, 3.09030E-05f, 3.12608E-05f, // -90.4dB = -infinity - 3.16228E-05f, 3.19890E-05f, 3.23594E-05f, 3.27341E-05f, 3.31131E-05f, // -90.0 dB - 3.34965E-05f, 3.38844E-05f, 3.42768E-05f, 3.46737E-05f, 3.50752E-05f, - 3.54813E-05f, 3.58922E-05f, 3.63078E-05f, 3.67282E-05f, 3.71535E-05f, - 3.75837E-05f, 3.80189E-05f, 3.84592E-05f, 3.89045E-05f, 3.93550E-05f, - 3.98107E-05f, 4.02717E-05f, 4.07380E-05f, 4.12098E-05f, 4.16869E-05f, - 4.21697E-05f, 4.26580E-05f, 4.31519E-05f, 4.36516E-05f, 4.41570E-05f, - 4.46684E-05f, 4.51856E-05f, 4.57088E-05f, 4.62381E-05f, 4.67735E-05f, - 4.73151E-05f, 4.78630E-05f, 4.84172E-05f, 4.89779E-05f, 4.95450E-05f, - 5.01187E-05f, 5.06991E-05f, 5.12861E-05f, 5.18800E-05f, 5.24807E-05f, - 5.30884E-05f, 5.37032E-05f, 5.43250E-05f, 5.49541E-05f, 5.55904E-05f, - 5.62341E-05f, 5.68853E-05f, 5.75440E-05f, 5.82103E-05f, 5.88844E-05f, - 5.95662E-05f, 6.02560E-05f, 6.09537E-05f, 6.16595E-05f, 6.23735E-05f, - 6.30957E-05f, 6.38263E-05f, 6.45654E-05f, 6.53131E-05f, 6.60693E-05f, // -84.0 dB - 6.68344E-05f, 6.76083E-05f, 6.83912E-05f, 6.91831E-05f, 6.99842E-05f, - 7.07946E-05f, 7.16143E-05f, 7.24436E-05f, 7.32825E-05f, 7.41310E-05f, - 7.49894E-05f, 7.58578E-05f, 7.67361E-05f, 7.76247E-05f, 7.85236E-05f, - 7.94328E-05f, 8.03526E-05f, 8.12831E-05f, 8.22243E-05f, 8.31764E-05f, - 8.41395E-05f, 8.51138E-05f, 8.60994E-05f, 8.70964E-05f, 8.81049E-05f, - 8.91251E-05f, 9.01571E-05f, 9.12011E-05f, 9.22571E-05f, 9.33254E-05f, - 9.44061E-05f, 9.54993E-05f, 9.66051E-05f, 9.77237E-05f, 9.88553E-05f, - 0.000100000f, 0.000101158f, 0.000102329f, 0.000103514f, 0.000104713f, // -80.0 dB - 0.000105925f, 0.000107152f, 0.000108393f, 0.000109648f, 0.000110917f, - 0.000112202f, 0.000113501f, 0.000114815f, 0.000116145f, 0.000117490f, - 0.000118850f, 0.000120226f, 0.000121619f, 0.000123027f, 0.000124451f, - 0.000125893f, 0.000127350f, 0.000128825f, 0.000130317f, 0.000131826f, // -78.0 dB - 0.000133352f, 0.000134896f, 0.000136458f, 0.000138038f, 0.000139637f, - 0.000141254f, 0.000142889f, 0.000144544f, 0.000146218f, 0.000147911f, - 0.000149624f, 0.000151356f, 0.000153109f, 0.000154882f, 0.000156675f, - 0.000158489f, 0.000160325f, 0.000162181f, 0.000164059f, 0.000165959f, - 0.000167880f, 0.000169824f, 0.000171791f, 0.000173780f, 0.000175792f, - 0.000177828f, 0.000179887f, 0.000181970f, 0.000184077f, 0.000186209f, - 0.000188365f, 0.000190546f, 0.000192752f, 0.000194984f, 0.000197242f, - 0.000199526f, 0.000201837f, 0.000204174f, 0.000206538f, 0.000208930f, - 0.000211349f, 0.000213796f, 0.000216272f, 0.000218776f, 0.000221309f, - 0.000223872f, 0.000226464f, 0.000229087f, 0.000231739f, 0.000234423f, - 0.000237137f, 0.000239883f, 0.000242661f, 0.000245471f, 0.000248313f, - 0.000251189f, 0.000254097f, 0.000257040f, 0.000260016f, 0.000263027f, // -72.0 dB - 0.000266073f, 0.000269153f, 0.000272270f, 0.000275423f, 0.000278612f, - 0.000281838f, 0.000285102f, 0.000288403f, 0.000291743f, 0.000295121f, - 0.000298538f, 0.000301995f, 0.000305492f, 0.000309030f, 0.000312608f, - 0.000316228f, 0.000319890f, 0.000323594f, 0.000327341f, 0.000331131f, - 0.000334965f, 0.000338844f, 0.000342768f, 0.000346737f, 0.000350752f, - 0.000354813f, 0.000358922f, 0.000363078f, 0.000367282f, 0.000371535f, - 0.000375837f, 0.000380189f, 0.000384592f, 0.000389045f, 0.000393550f, - 0.000398107f, 0.000402717f, 0.000407380f, 0.000412098f, 0.000416869f, - 0.000421697f, 0.000426580f, 0.000431519f, 0.000436516f, 0.000441570f, - 0.000446684f, 0.000451856f, 0.000457088f, 0.000462381f, 0.000467735f, - 0.000473151f, 0.000478630f, 0.000484172f, 0.000489779f, 0.000495450f, - 0.000501187f, 0.000506991f, 0.000512861f, 0.000518800f, 0.000524807f, // -66.0 dB - 0.000530884f, 0.000537032f, 0.000543250f, 0.000549541f, 0.000555904f, - 0.000562341f, 0.000568853f, 0.000575440f, 0.000582103f, 0.000588844f, - 0.000595662f, 0.000602560f, 0.000609537f, 0.000616595f, 0.000623735f, - 0.000630957f, 0.000638263f, 0.000645654f, 0.000653131f, 0.000660693f, - 0.000668344f, 0.000676083f, 0.000683912f, 0.000691831f, 0.000699842f, - 0.000707946f, 0.000716143f, 0.000724436f, 0.000732825f, 0.000741310f, - 0.000749894f, 0.000758578f, 0.000767361f, 0.000776247f, 0.000785236f, - 0.000794328f, 0.000803526f, 0.000812831f, 0.000822243f, 0.000831764f, - 0.000841395f, 0.000851138f, 0.000860994f, 0.000870964f, 0.000881049f, - 0.000891251f, 0.000901571f, 0.000912011f, 0.000922571f, 0.000933254f, - 0.000944061f, 0.000954993f, 0.000966051f, 0.000977237f, 0.000988553f, - 0.001000000f, 0.001011579f, 0.001023293f, 0.001035142f, 0.001047129f, // -60.0.0dB ( 1/1000 ) - 0.001059254f, 0.001071519f, 0.001083927f, 0.001096478f, 0.001109175f, - 0.001122018f, 0.001135011f, 0.001148154f, 0.001161449f, 0.001174898f, - 0.001188502f, 0.001202264f, 0.001216186f, 0.001230269f, 0.001244515f, - 0.001258925f, 0.001273503f, 0.001288250f, 0.001303167f, 0.001318257f, - 0.001333521f, 0.001348963f, 0.001364583f, 0.001380384f, 0.001396368f, - 0.001412538f, 0.001428894f, 0.001445440f, 0.001462177f, 0.001479108f, - 0.001496236f, 0.001513561f, 0.001531087f, 0.001548817f, 0.001566751f, - 0.001584893f, 0.001603245f, 0.001621810f, 0.001640590f, 0.001659587f, - 0.001678804f, 0.001698244f, 0.001717908f, 0.001737801f, 0.001757924f, - 0.001778279f, 0.001798871f, 0.001819701f, 0.001840772f, 0.001862087f, - 0.001883649f, 0.001905461f, 0.001927525f, 0.001949845f, 0.001972423f, - 0.001995262f, 0.002018366f, 0.002041738f, 0.002065380f, 0.002089296f, // -54.0 dB - 0.002113489f, 0.002137962f, 0.002162719f, 0.002187762f, 0.002213095f, - 0.002238721f, 0.002264644f, 0.002290868f, 0.002317395f, 0.002344229f, - 0.002371374f, 0.002398833f, 0.002426610f, 0.002454709f, 0.002483133f, - 0.002511886f, 0.002540973f, 0.002570396f, 0.002600160f, 0.002630268f, - 0.002660725f, 0.002691535f, 0.002722701f, 0.002754229f, 0.002786121f, - 0.002818383f, 0.002851018f, 0.002884032f, 0.002917427f, 0.002951209f, - 0.002985383f, 0.003019952f, 0.003054921f, 0.003090295f, 0.003126079f, - 0.003162278f, 0.003198895f, 0.003235937f, 0.003273407f, 0.003311311f, - 0.003349654f, 0.003388442f, 0.003427678f, 0.003467369f, 0.003507519f, - 0.003548134f, 0.003589219f, 0.003630781f, 0.003672823f, 0.003715352f, - 0.003758374f, 0.003801894f, 0.003845918f, 0.003890451f, 0.003935501f, - 0.003981072f, 0.004027170f, 0.004073803f, 0.004120975f, 0.004168694f, // -48.0 dB - 0.004216965f, 0.004265795f, 0.004315191f, 0.004365158f, 0.004415704f, - 0.004466836f, 0.004518559f, 0.004570882f, 0.004623810f, 0.004677351f, - 0.004731513f, 0.004786301f, 0.004841724f, 0.004897788f, 0.004954502f, - 0.005011872f, 0.005069907f, 0.005128614f, 0.005188000f, 0.005248075f, - 0.005308844f, 0.005370318f, 0.005432503f, 0.005495409f, 0.005559043f, - 0.005623413f, 0.005688529f, 0.005754399f, 0.005821032f, 0.005888437f, - 0.005956621f, 0.006025596f, 0.006095369f, 0.006165950f, 0.006237348f, - 0.006309573f, 0.006382635f, 0.006456542f, 0.006531306f, 0.006606934f, - 0.006683439f, 0.006760830f, 0.006839116f, 0.006918310f, 0.006998420f, - 0.007079458f, 0.007161434f, 0.007244360f, 0.007328245f, 0.007413102f, - 0.007498942f, 0.007585776f, 0.007673615f, 0.007762471f, 0.007852356f, - 0.007943282f, 0.008035261f, 0.008128305f, 0.008222426f, 0.008317638f, // -42.0 dB - 0.008413951f, 0.008511380f, 0.008609938f, 0.008709636f, 0.008810489f, - 0.008912509f, 0.009015711f, 0.009120108f, 0.009225714f, 0.009332543f, - 0.009440609f, 0.009549926f, 0.009660509f, 0.009772372f, 0.009885531f, - 0.010000000f, 0.010115795f, 0.010232930f, 0.010351422f, 0.010471285f, // -40.0.0dB ( 1/100 ) - 0.010592537f, 0.010715193f, 0.010839269f, 0.010964782f, 0.011091748f, - 0.011220185f, 0.011350108f, 0.011481536f, 0.011614486f, 0.011748976f, - 0.011885022f, 0.012022644f, 0.012161860f, 0.012302688f, 0.012445146f, - 0.012589254f, 0.012735031f, 0.012882496f, 0.013031668f, 0.013182567f, - 0.013335214f, 0.013489629f, 0.013645831f, 0.013803843f, 0.013963684f, - 0.014125375f, 0.014288940f, 0.014454398f, 0.014621772f, 0.014791084f, - 0.014962357f, 0.015135612f, 0.015310875f, 0.015488166f, 0.015667511f, - 0.015848932f, 0.016032454f, 0.016218101f, 0.016405898f, 0.016595869f, // -36.0 dB - 0.016788040f, 0.016982437f, 0.017179084f, 0.017378008f, 0.017579236f, - 0.017782794f, 0.017988709f, 0.018197009f, 0.018407720f, 0.018620871f, - 0.018836491f, 0.019054607f, 0.019275249f, 0.019498446f, 0.019724227f, - 0.019952623f, 0.020183664f, 0.020417379f, 0.020653802f, 0.020892961f, - 0.021134890f, 0.021379621f, 0.021627185f, 0.021877616f, 0.022130947f, - 0.022387211f, 0.022646443f, 0.022908677f, 0.023173946f, 0.023442288f, - 0.023713737f, 0.023988329f, 0.024266101f, 0.024547089f, 0.024831331f, - 0.025118864f, 0.025409727f, 0.025703958f, 0.026001596f, 0.026302680f, - 0.026607251f, 0.026915348f, 0.027227013f, 0.027542287f, 0.027861212f, - 0.028183829f, 0.028510183f, 0.028840315f, 0.029174270f, 0.029512092f, - 0.029853826f, 0.030199517f, 0.030549211f, 0.030902954f, 0.031260794f, - 0.031622777f, 0.031988951f, 0.032359366f, 0.032734069f, 0.033113112f, // -30.0 dB - 0.033496544f, 0.033884416f, 0.034276779f, 0.034673685f, 0.035075187f, - 0.035481339f, 0.035892193f, 0.036307805f, 0.036728230f, 0.037153523f, - 0.037583740f, 0.038018940f, 0.038459178f, 0.038904514f, 0.039355008f, - 0.039810717f, 0.040271703f, 0.040738028f, 0.041209752f, 0.041686938f, - 0.042169650f, 0.042657952f, 0.043151908f, 0.043651583f, 0.044157045f, - 0.044668359f, 0.045185594f, 0.045708819f, 0.046238102f, 0.046773514f, - 0.047315126f, 0.047863009f, 0.048417237f, 0.048977882f, 0.049545019f, - 0.050118723f, 0.050699071f, 0.051286138f, 0.051880004f, 0.052480746f, - 0.053088444f, 0.053703180f, 0.054325033f, 0.054954087f, 0.055590426f, - 0.056234133f, 0.056885293f, 0.057543994f, 0.058210322f, 0.058884366f, - 0.059566214f, 0.060255959f, 0.060953690f, 0.061659500f, 0.062373484f, - 0.063095734f, 0.063826349f, 0.064565423f, 0.065313055f, 0.066069345f, // -24.0 dB - 0.066834392f, 0.067608298f, 0.068391165f, 0.069183097f, 0.069984200f, - 0.070794578f, 0.071614341f, 0.072443596f, 0.073282453f, 0.074131024f, - 0.074989421f, 0.075857758f, 0.076736149f, 0.077624712f, 0.078523563f, - 0.079432823f, 0.080352612f, 0.081283052f, 0.082224265f, 0.083176377f, - 0.084139514f, 0.085113804f, 0.086099375f, 0.087096359f, 0.088104887f, - 0.089125094f, 0.090157114f, 0.091201084f, 0.092257143f, 0.093325430f, - 0.094406088f, 0.095499259f, 0.096605088f, 0.097723722f, 0.098855309f, - 0.100000000f, 0.101157945f, 0.102329299f, 0.103514217f, 0.104712855f, // -20.0.0dB ( 1/10 ) - 0.105925373f, 0.107151931f, 0.108392691f, 0.109647820f, 0.110917482f, - 0.112201845f, 0.113501082f, 0.114815362f, 0.116144861f, 0.117489755f, - 0.118850223f, 0.120226443f, 0.121618600f, 0.123026877f, 0.124451461f, - 0.125892541f, 0.127350308f, 0.128824955f, 0.130316678f, 0.131825674f, // -18.0 dB - 0.133352143f, 0.134896288f, 0.136458314f, 0.138038426f, 0.139636836f, - 0.141253754f, 0.142889396f, 0.144543977f, 0.146217717f, 0.147910839f, - 0.149623566f, 0.151356125f, 0.153108746f, 0.154881662f, 0.156675107f, - 0.158489319f, 0.160324539f, 0.162181010f, 0.164058977f, 0.165958691f, - 0.167880402f, 0.169824365f, 0.171790839f, 0.173780083f, 0.175792361f, - 0.177827941f, 0.179887092f, 0.181970086f, 0.184077200f, 0.186208714f, - 0.188364909f, 0.190546072f, 0.192752491f, 0.194984460f, 0.197242274f, - 0.199526231f, 0.201836636f, 0.204173794f, 0.206538016f, 0.208929613f, - 0.211348904f, 0.213796209f, 0.216271852f, 0.218776162f, 0.221309471f, - 0.223872114f, 0.226464431f, 0.229086765f, 0.231739465f, 0.234422882f, - 0.237137371f, 0.239883292f, 0.242661010f, 0.245470892f, 0.248313311f, - 0.251188643f, 0.254097271f, 0.257039578f, 0.260015956f, 0.263026799f, // -12.0dB ( 1/4 ) - 0.266072506f, 0.269153480f, 0.272270131f, 0.275422870f, 0.278612117f, - 0.281838293f, 0.285101827f, 0.288403150f, 0.291742701f, 0.295120923f, - 0.298538262f, 0.301995172f, 0.305492111f, 0.309029543f, 0.312607937f, - 0.316227766f, 0.319889511f, 0.323593657f, 0.327340695f, 0.331131121f, - 0.334965439f, 0.338844156f, 0.342767787f, 0.346736850f, 0.350751874f, - 0.354813389f, 0.358921935f, 0.363078055f, 0.367282300f, 0.371535229f, - 0.375837404f, 0.380189396f, 0.384591782f, 0.389045145f, 0.393550075f, - 0.398107171f, 0.402717034f, 0.407380278f, 0.412097519f, 0.416869383f, - 0.421696503f, 0.426579519f, 0.431519077f, 0.436515832f, 0.441570447f, - 0.446683592f, 0.451855944f, 0.457088190f, 0.462381021f, 0.467735141f, - 0.473151259f, 0.478630092f, 0.484172368f, 0.489778819f, 0.495450191f, - 0.501187234f, 0.506990708f, 0.512861384f, 0.518800039f, 0.524807460f, // -6.0.0dB ( 1/2 ) - 0.530884444f, 0.537031796f, 0.543250331f, 0.549540874f, 0.555904257f, - 0.562341325f, 0.568852931f, 0.575439937f, 0.582103218f, 0.588843655f, - 0.595662144f, 0.602559586f, 0.609536897f, 0.616595002f, 0.623734835f, - 0.630957344f, 0.638263486f, 0.645654229f, 0.653130553f, 0.660693448f, - 0.668343918f, 0.676082975f, 0.683911647f, 0.691830971f, 0.699841996f, - 0.707945784f, 0.716143410f, 0.724435960f, 0.732824533f, 0.741310241f, - 0.749894209f, 0.758577575f, 0.767361489f, 0.776247117f, 0.785235635f, - 0.794328235f, 0.803526122f, 0.812830516f, 0.822242650f, 0.831763771f, // -2.0 dB - 0.841395142f, 0.851138038f, 0.860993752f, 0.870963590f, 0.881048873f, - 0.891250938f, 0.901571138f, 0.912010839f, 0.922571427f, 0.933254301f, // -1.0 dB - 0.944060876f, 0.954992586f, 0.966050879f, 0.977237221f, 0.988553095f, - 1.000000000f, 1.011579454f, 1.023292992f, 1.035142167f, 1.047128548f, // 0.0 dB - 1.059253725f, 1.071519305f, 1.083926914f, 1.096478196f, 1.109174815f, - 1.122018454f, 1.135010816f, 1.148153621f, 1.161448614f, 1.174897555f, // 1.0 dB - 1.188502227f, 1.202264435f, 1.216186001f, 1.230268771f, 1.244514612f, - 1.258925412f, 1.273503081f, 1.288249552f, 1.303166778f, 1.318256739f, // 2.0 dB - 1.333521432f, 1.348962883f, 1.364583137f, 1.380384265f, 1.396368361f, - 1.412537545f, 1.428893959f, 1.445439771f, 1.462177174f, 1.479108388f, - 1.496235656f, 1.513561248f, 1.531087462f, 1.548816619f, 1.566751070f, - 1.584893192f, 1.603245391f, 1.621810097f, 1.640589773f, 1.659586907f, - 1.678804018f, 1.698243652f, 1.717908387f, 1.737800829f, 1.757923614f, - 1.778279410f, 1.798870915f, 1.819700859f, 1.840772001f, 1.862087137f, - 1.883649089f, 1.905460718f, 1.927524913f, 1.949844600f, 1.972422736f, - 1.995262315f, // 6.0dB ( *2 ) + 0.000000000f, 3.05492E-05f, 3.09030E-05f, 3.12608E-05f, 3.16228E-05f, 3.19890E-05f, + 3.23594E-05f, 3.27341E-05f, 3.31131E-05f, 3.34965E-05f, 3.38844E-05f, 3.42768E-05f, + 3.46737E-05f, 3.50752E-05f, 3.54813E-05f, 3.58922E-05f, 3.63078E-05f, 3.67282E-05f, + 3.71535E-05f, 3.75837E-05f, 3.80189E-05f, 3.84592E-05f, 3.89045E-05f, 3.93550E-05f, + 3.98107E-05f, 4.02717E-05f, 4.07380E-05f, 4.12098E-05f, 4.16869E-05f, 4.21697E-05f, + 4.26580E-05f, 4.31519E-05f, 4.36516E-05f, 4.41570E-05f, 4.46684E-05f, 4.51856E-05f, + 4.57088E-05f, 4.62381E-05f, 4.67735E-05f, 4.73151E-05f, 4.78630E-05f, 4.84172E-05f, + 4.89779E-05f, 4.95450E-05f, 5.01187E-05f, 5.06991E-05f, 5.12861E-05f, 5.18800E-05f, + 5.24807E-05f, 5.30884E-05f, 5.37032E-05f, 5.43250E-05f, 5.49541E-05f, 5.55904E-05f, + 5.62341E-05f, 5.68853E-05f, 5.75440E-05f, 5.82103E-05f, 5.88844E-05f, 5.95662E-05f, + 6.02560E-05f, 6.09537E-05f, 6.16595E-05f, 6.23735E-05f, 6.30957E-05f, 6.38263E-05f, + 6.45654E-05f, 6.53131E-05f, 6.60693E-05f, 6.68344E-05f, 6.76083E-05f, 6.83912E-05f, + 6.91831E-05f, 6.99842E-05f, 7.07946E-05f, 7.16143E-05f, 7.24436E-05f, 7.32825E-05f, + 7.41310E-05f, 7.49894E-05f, 7.58578E-05f, 7.67361E-05f, 7.76247E-05f, 7.85236E-05f, + 7.94328E-05f, 8.03526E-05f, 8.12831E-05f, 8.22243E-05f, 8.31764E-05f, 8.41395E-05f, + 8.51138E-05f, 8.60994E-05f, 8.70964E-05f, 8.81049E-05f, 8.91251E-05f, 9.01571E-05f, + 9.12011E-05f, 9.22571E-05f, 9.33254E-05f, 9.44061E-05f, 9.54993E-05f, 9.66051E-05f, + 9.77237E-05f, 9.88553E-05f, 0.000100000f, 0.000101158f, 0.000102329f, 0.000103514f, + 0.000104713f, 0.000105925f, 0.000107152f, 0.000108393f, 0.000109648f, 0.000110917f, + 0.000112202f, 0.000113501f, 0.000114815f, 0.000116145f, 0.000117490f, 0.000118850f, + 0.000120226f, 0.000121619f, 0.000123027f, 0.000124451f, 0.000125893f, 0.000127350f, + 0.000128825f, 0.000130317f, 0.000131826f, 0.000133352f, 0.000134896f, 0.000136458f, + 0.000138038f, 0.000139637f, 0.000141254f, 0.000142889f, 0.000144544f, 0.000146218f, + 0.000147911f, 0.000149624f, 0.000151356f, 0.000153109f, 0.000154882f, 0.000156675f, + 0.000158489f, 0.000160325f, 0.000162181f, 0.000164059f, 0.000165959f, 0.000167880f, + 0.000169824f, 0.000171791f, 0.000173780f, 0.000175792f, 0.000177828f, 0.000179887f, + 0.000181970f, 0.000184077f, 0.000186209f, 0.000188365f, 0.000190546f, 0.000192752f, + 0.000194984f, 0.000197242f, 0.000199526f, 0.000201837f, 0.000204174f, 0.000206538f, + 0.000208930f, 0.000211349f, 0.000213796f, 0.000216272f, 0.000218776f, 0.000221309f, + 0.000223872f, 0.000226464f, 0.000229087f, 0.000231739f, 0.000234423f, 0.000237137f, + 0.000239883f, 0.000242661f, 0.000245471f, 0.000248313f, 0.000251189f, 0.000254097f, + 0.000257040f, 0.000260016f, 0.000263027f, 0.000266073f, 0.000269153f, 0.000272270f, + 0.000275423f, 0.000278612f, 0.000281838f, 0.000285102f, 0.000288403f, 0.000291743f, + 0.000295121f, 0.000298538f, 0.000301995f, 0.000305492f, 0.000309030f, 0.000312608f, + 0.000316228f, 0.000319890f, 0.000323594f, 0.000327341f, 0.000331131f, 0.000334965f, + 0.000338844f, 0.000342768f, 0.000346737f, 0.000350752f, 0.000354813f, 0.000358922f, + 0.000363078f, 0.000367282f, 0.000371535f, 0.000375837f, 0.000380189f, 0.000384592f, + 0.000389045f, 0.000393550f, 0.000398107f, 0.000402717f, 0.000407380f, 0.000412098f, + 0.000416869f, 0.000421697f, 0.000426580f, 0.000431519f, 0.000436516f, 0.000441570f, + 0.000446684f, 0.000451856f, 0.000457088f, 0.000462381f, 0.000467735f, 0.000473151f, + 0.000478630f, 0.000484172f, 0.000489779f, 0.000495450f, 0.000501187f, 0.000506991f, + 0.000512861f, 0.000518800f, 0.000524807f, 0.000530884f, 0.000537032f, 0.000543250f, + 0.000549541f, 0.000555904f, 0.000562341f, 0.000568853f, 0.000575440f, 0.000582103f, + 0.000588844f, 0.000595662f, 0.000602560f, 0.000609537f, 0.000616595f, 0.000623735f, + 0.000630957f, 0.000638263f, 0.000645654f, 0.000653131f, 0.000660693f, 0.000668344f, + 0.000676083f, 0.000683912f, 0.000691831f, 0.000699842f, 0.000707946f, 0.000716143f, + 0.000724436f, 0.000732825f, 0.000741310f, 0.000749894f, 0.000758578f, 0.000767361f, + 0.000776247f, 0.000785236f, 0.000794328f, 0.000803526f, 0.000812831f, 0.000822243f, + 0.000831764f, 0.000841395f, 0.000851138f, 0.000860994f, 0.000870964f, 0.000881049f, + 0.000891251f, 0.000901571f, 0.000912011f, 0.000922571f, 0.000933254f, 0.000944061f, + 0.000954993f, 0.000966051f, 0.000977237f, 0.000988553f, 0.001000000f, 0.001011579f, + 0.001023293f, 0.001035142f, 0.001047129f, 0.001059254f, 0.001071519f, 0.001083927f, + 0.001096478f, 0.001109175f, 0.001122018f, 0.001135011f, 0.001148154f, 0.001161449f, + 0.001174898f, 0.001188502f, 0.001202264f, 0.001216186f, 0.001230269f, 0.001244515f, + 0.001258925f, 0.001273503f, 0.001288250f, 0.001303167f, 0.001318257f, 0.001333521f, + 0.001348963f, 0.001364583f, 0.001380384f, 0.001396368f, 0.001412538f, 0.001428894f, + 0.001445440f, 0.001462177f, 0.001479108f, 0.001496236f, 0.001513561f, 0.001531087f, + 0.001548817f, 0.001566751f, 0.001584893f, 0.001603245f, 0.001621810f, 0.001640590f, + 0.001659587f, 0.001678804f, 0.001698244f, 0.001717908f, 0.001737801f, 0.001757924f, + 0.001778279f, 0.001798871f, 0.001819701f, 0.001840772f, 0.001862087f, 0.001883649f, + 0.001905461f, 0.001927525f, 0.001949845f, 0.001972423f, 0.001995262f, 0.002018366f, + 0.002041738f, 0.002065380f, 0.002089296f, 0.002113489f, 0.002137962f, 0.002162719f, + 0.002187762f, 0.002213095f, 0.002238721f, 0.002264644f, 0.002290868f, 0.002317395f, + 0.002344229f, 0.002371374f, 0.002398833f, 0.002426610f, 0.002454709f, 0.002483133f, + 0.002511886f, 0.002540973f, 0.002570396f, 0.002600160f, 0.002630268f, 0.002660725f, + 0.002691535f, 0.002722701f, 0.002754229f, 0.002786121f, 0.002818383f, 0.002851018f, + 0.002884032f, 0.002917427f, 0.002951209f, 0.002985383f, 0.003019952f, 0.003054921f, + 0.003090295f, 0.003126079f, 0.003162278f, 0.003198895f, 0.003235937f, 0.003273407f, + 0.003311311f, 0.003349654f, 0.003388442f, 0.003427678f, 0.003467369f, 0.003507519f, + 0.003548134f, 0.003589219f, 0.003630781f, 0.003672823f, 0.003715352f, 0.003758374f, + 0.003801894f, 0.003845918f, 0.003890451f, 0.003935501f, 0.003981072f, 0.004027170f, + 0.004073803f, 0.004120975f, 0.004168694f, 0.004216965f, 0.004265795f, 0.004315191f, + 0.004365158f, 0.004415704f, 0.004466836f, 0.004518559f, 0.004570882f, 0.004623810f, + 0.004677351f, 0.004731513f, 0.004786301f, 0.004841724f, 0.004897788f, 0.004954502f, + 0.005011872f, 0.005069907f, 0.005128614f, 0.005188000f, 0.005248075f, 0.005308844f, + 0.005370318f, 0.005432503f, 0.005495409f, 0.005559043f, 0.005623413f, 0.005688529f, + 0.005754399f, 0.005821032f, 0.005888437f, 0.005956621f, 0.006025596f, 0.006095369f, + 0.006165950f, 0.006237348f, 0.006309573f, 0.006382635f, 0.006456542f, 0.006531306f, + 0.006606934f, 0.006683439f, 0.006760830f, 0.006839116f, 0.006918310f, 0.006998420f, + 0.007079458f, 0.007161434f, 0.007244360f, 0.007328245f, 0.007413102f, 0.007498942f, + 0.007585776f, 0.007673615f, 0.007762471f, 0.007852356f, 0.007943282f, 0.008035261f, + 0.008128305f, 0.008222426f, 0.008317638f, 0.008413951f, 0.008511380f, 0.008609938f, + 0.008709636f, 0.008810489f, 0.008912509f, 0.009015711f, 0.009120108f, 0.009225714f, + 0.009332543f, 0.009440609f, 0.009549926f, 0.009660509f, 0.009772372f, 0.009885531f, + 0.010000000f, 0.010115795f, 0.010232930f, 0.010351422f, 0.010471285f, 0.010592537f, + 0.010715193f, 0.010839269f, 0.010964782f, 0.011091748f, 0.011220185f, 0.011350108f, + 0.011481536f, 0.011614486f, 0.011748976f, 0.011885022f, 0.012022644f, 0.012161860f, + 0.012302688f, 0.012445146f, 0.012589254f, 0.012735031f, 0.012882496f, 0.013031668f, + 0.013182567f, 0.013335214f, 0.013489629f, 0.013645831f, 0.013803843f, 0.013963684f, + 0.014125375f, 0.014288940f, 0.014454398f, 0.014621772f, 0.014791084f, 0.014962357f, + 0.015135612f, 0.015310875f, 0.015488166f, 0.015667511f, 0.015848932f, 0.016032454f, + 0.016218101f, 0.016405898f, 0.016595869f, 0.016788040f, 0.016982437f, 0.017179084f, + 0.017378008f, 0.017579236f, 0.017782794f, 0.017988709f, 0.018197009f, 0.018407720f, + 0.018620871f, 0.018836491f, 0.019054607f, 0.019275249f, 0.019498446f, 0.019724227f, + 0.019952623f, 0.020183664f, 0.020417379f, 0.020653802f, 0.020892961f, 0.021134890f, + 0.021379621f, 0.021627185f, 0.021877616f, 0.022130947f, 0.022387211f, 0.022646443f, + 0.022908677f, 0.023173946f, 0.023442288f, 0.023713737f, 0.023988329f, 0.024266101f, + 0.024547089f, 0.024831331f, 0.025118864f, 0.025409727f, 0.025703958f, 0.026001596f, + 0.026302680f, 0.026607251f, 0.026915348f, 0.027227013f, 0.027542287f, 0.027861212f, + 0.028183829f, 0.028510183f, 0.028840315f, 0.029174270f, 0.029512092f, 0.029853826f, + 0.030199517f, 0.030549211f, 0.030902954f, 0.031260794f, 0.031622777f, 0.031988951f, + 0.032359366f, 0.032734069f, 0.033113112f, 0.033496544f, 0.033884416f, 0.034276779f, + 0.034673685f, 0.035075187f, 0.035481339f, 0.035892193f, 0.036307805f, 0.036728230f, + 0.037153523f, 0.037583740f, 0.038018940f, 0.038459178f, 0.038904514f, 0.039355008f, + 0.039810717f, 0.040271703f, 0.040738028f, 0.041209752f, 0.041686938f, 0.042169650f, + 0.042657952f, 0.043151908f, 0.043651583f, 0.044157045f, 0.044668359f, 0.045185594f, + 0.045708819f, 0.046238102f, 0.046773514f, 0.047315126f, 0.047863009f, 0.048417237f, + 0.048977882f, 0.049545019f, 0.050118723f, 0.050699071f, 0.051286138f, 0.051880004f, + 0.052480746f, 0.053088444f, 0.053703180f, 0.054325033f, 0.054954087f, 0.055590426f, + 0.056234133f, 0.056885293f, 0.057543994f, 0.058210322f, 0.058884366f, 0.059566214f, + 0.060255959f, 0.060953690f, 0.061659500f, 0.062373484f, 0.063095734f, 0.063826349f, + 0.064565423f, 0.065313055f, 0.066069345f, 0.066834392f, 0.067608298f, 0.068391165f, + 0.069183097f, 0.069984200f, 0.070794578f, 0.071614341f, 0.072443596f, 0.073282453f, + 0.074131024f, 0.074989421f, 0.075857758f, 0.076736149f, 0.077624712f, 0.078523563f, + 0.079432823f, 0.080352612f, 0.081283052f, 0.082224265f, 0.083176377f, 0.084139514f, + 0.085113804f, 0.086099375f, 0.087096359f, 0.088104887f, 0.089125094f, 0.090157114f, + 0.091201084f, 0.092257143f, 0.093325430f, 0.094406088f, 0.095499259f, 0.096605088f, + 0.097723722f, 0.098855309f, 0.100000000f, 0.101157945f, 0.102329299f, 0.103514217f, + 0.104712855f, 0.105925373f, 0.107151931f, 0.108392691f, 0.109647820f, 0.110917482f, + 0.112201845f, 0.113501082f, 0.114815362f, 0.116144861f, 0.117489755f, 0.118850223f, + 0.120226443f, 0.121618600f, 0.123026877f, 0.124451461f, 0.125892541f, 0.127350308f, + 0.128824955f, 0.130316678f, 0.131825674f, 0.133352143f, 0.134896288f, 0.136458314f, + 0.138038426f, 0.139636836f, 0.141253754f, 0.142889396f, 0.144543977f, 0.146217717f, + 0.147910839f, 0.149623566f, 0.151356125f, 0.153108746f, 0.154881662f, 0.156675107f, + 0.158489319f, 0.160324539f, 0.162181010f, 0.164058977f, 0.165958691f, 0.167880402f, + 0.169824365f, 0.171790839f, 0.173780083f, 0.175792361f, 0.177827941f, 0.179887092f, + 0.181970086f, 0.184077200f, 0.186208714f, 0.188364909f, 0.190546072f, 0.192752491f, + 0.194984460f, 0.197242274f, 0.199526231f, 0.201836636f, 0.204173794f, 0.206538016f, + 0.208929613f, 0.211348904f, 0.213796209f, 0.216271852f, 0.218776162f, 0.221309471f, + 0.223872114f, 0.226464431f, 0.229086765f, 0.231739465f, 0.234422882f, 0.237137371f, + 0.239883292f, 0.242661010f, 0.245470892f, 0.248313311f, 0.251188643f, 0.254097271f, + 0.257039578f, 0.260015956f, 0.263026799f, 0.266072506f, 0.269153480f, 0.272270131f, + 0.275422870f, 0.278612117f, 0.281838293f, 0.285101827f, 0.288403150f, 0.291742701f, + 0.295120923f, 0.298538262f, 0.301995172f, 0.305492111f, 0.309029543f, 0.312607937f, + 0.316227766f, 0.319889511f, 0.323593657f, 0.327340695f, 0.331131121f, 0.334965439f, + 0.338844156f, 0.342767787f, 0.346736850f, 0.350751874f, 0.354813389f, 0.358921935f, + 0.363078055f, 0.367282300f, 0.371535229f, 0.375837404f, 0.380189396f, 0.384591782f, + 0.389045145f, 0.393550075f, 0.398107171f, 0.402717034f, 0.407380278f, 0.412097519f, + 0.416869383f, 0.421696503f, 0.426579519f, 0.431519077f, 0.436515832f, 0.441570447f, + 0.446683592f, 0.451855944f, 0.457088190f, 0.462381021f, 0.467735141f, 0.473151259f, + 0.478630092f, 0.484172368f, 0.489778819f, 0.495450191f, 0.501187234f, 0.506990708f, + 0.512861384f, 0.518800039f, 0.524807460f, 0.530884444f, 0.537031796f, 0.543250331f, + 0.549540874f, 0.555904257f, 0.562341325f, 0.568852931f, 0.575439937f, 0.582103218f, + 0.588843655f, 0.595662144f, 0.602559586f, 0.609536897f, 0.616595002f, 0.623734835f, + 0.630957344f, 0.638263486f, 0.645654229f, 0.653130553f, 0.660693448f, 0.668343918f, + 0.676082975f, 0.683911647f, 0.691830971f, 0.699841996f, 0.707945784f, 0.716143410f, + 0.724435960f, 0.732824533f, 0.741310241f, 0.749894209f, 0.758577575f, 0.767361489f, + 0.776247117f, 0.785235635f, 0.794328235f, 0.803526122f, 0.812830516f, 0.822242650f, + 0.831763771f, 0.841395142f, 0.851138038f, 0.860993752f, 0.870963590f, 0.881048873f, + 0.891250938f, 0.901571138f, 0.912010839f, 0.922571427f, 0.933254301f, 0.944060876f, + 0.954992586f, 0.966050879f, 0.977237221f, 0.988553095f, 1.000000000f, 1.011579454f, + 1.023292992f, 1.035142167f, 1.047128548f, 1.059253725f, 1.071519305f, 1.083926914f, + 1.096478196f, 1.109174815f, 1.122018454f, 1.135010816f, 1.148153621f, 1.161448614f, + 1.174897555f, 1.188502227f, 1.202264435f, 1.216186001f, 1.230268771f, 1.244514612f, + 1.258925412f, 1.273503081f, 1.288249552f, 1.303166778f, 1.318256739f, 1.333521432f, + 1.348962883f, 1.364583137f, 1.380384265f, 1.396368361f, 1.412537545f, 1.428893959f, + 1.445439771f, 1.462177174f, 1.479108388f, 1.496235656f, 1.513561248f, 1.531087462f, + 1.548816619f, 1.566751070f, 1.584893192f, 1.603245391f, 1.621810097f, 1.640589773f, + 1.659586907f, 1.678804018f, 1.698243652f, 1.717908387f, 1.737800829f, 1.757923614f, + 1.778279410f, 1.798870915f, 1.819700859f, 1.840772001f, 1.862087137f, 1.883649089f, + 1.905460718f, 1.927524913f, 1.949844600f, 1.972422736f, 1.995262315f, }; const int PanTableMax{256}; @@ -689,7 +657,7 @@ float Util::CalcSurroundPanRatio(float surroundPan, const PanInfo& info) { } float Util::CalcPitchRatio(int pitch_) { - const int Range{PitchDivisionRange*12}; + const int Range{PitchDivisionRange * 12}; int pitch{pitch_}; @@ -862,7 +830,8 @@ Util::WaveArchiveLoadStatus Util::GetWaveArchiveOfBank(LoadItemInfo& warcLoadInf return WaveArchiveLoadStatus_NotYet; SoundArchive::WaveArchiveInfo warcInfo; - [[maybe_unused]] bool isReadWarcInfo{arc.ReadWaveArchiveInfo(pWaveId->waveArchiveId, &warcInfo)}; + [[maybe_unused]] bool isReadWarcInfo{ + arc.ReadWaveArchiveInfo(pWaveId->waveArchiveId, &warcInfo)}; warcLoadInfo.itemId = pWaveId->waveArchiveId; warcLoadInfo.address = waveArchiveFile; @@ -884,17 +853,18 @@ const void* Util::GetWaveFileOfWaveSound(const void* wsdFile, u32 index, const S const SoundArchiveLoader& mgr) { WaveSoundFileReader reader{wsdFile}; WaveSoundNoteInfo noteInfo{}; - + [[maybe_unused]] bool isReadNoteInfo{reader.ReadNoteInfo(¬eInfo, index, 0)}; // if (!isReadNoteInfo) // return nullptr; const void* waveArchiveFile{mgr.detail_GetFileAddressByItemId(noteInfo.waveArchiveId)}; if (waveArchiveFile == nullptr) - return nullptr; + return nullptr; SoundArchive::WaveArchiveInfo warcInfo; - [[maybe_unused]] bool isReadWarcInfo{arc.ReadWaveArchiveInfo(noteInfo.waveArchiveId, &warcInfo)}; + [[maybe_unused]] bool isReadWarcInfo{ + arc.ReadWaveArchiveInfo(noteInfo.waveArchiveId, &warcInfo)}; // if (!isReadWarcInfo) // return nullptr; @@ -906,4 +876,4 @@ const void* Util::GetWaveFileOfWaveSound(const void* wsdFile, u32 index, const S return waveFile; } -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp b/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp index 6c51c67d..6a0e689b 100644 --- a/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp +++ b/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp @@ -32,11 +32,11 @@ void WavOutFileStream::SetCacheBuffer(char* buf, size_t length) { // NON_MATCHING: reordering of instructions bool WavOutFileStream::WriteHeader(int channels, size_t samplesPerSec) { char buffer[sizeof(WaveBinaryHeader) + FileIoBufferAlignment]; - void* alignedBuffer {util::BytePtr(buffer).AlignUp(FileIoBufferAlignment).Get()}; + void* alignedBuffer{util::BytePtr(buffer).AlignUp(FileIoBufferAlignment).Get()}; - WaveBinaryHeader* header {new (alignedBuffer) WaveBinaryHeader}; + WaveBinaryHeader* header{new (alignedBuffer) WaveBinaryHeader}; - header->riffChunk.formatType = 0x45564157; // "WAVE" + header->riffChunk.formatType = 0x45564157; // "WAVE" header->riffChunk.header.size = sizeof(WaveBinaryHeader) - sizeof(ChunkHeader); header->fmtChunk.bitsPerSample = 16; header->fmtChunk.blockAlign = channels * 2; @@ -45,8 +45,8 @@ bool WavOutFileStream::WriteHeader(int channels, size_t samplesPerSec) { header->fmtChunk.channels = channels; header->fmtChunk.formatTag = FmtChunk::FormatPcm; - size_t result {Write(header, sizeof(WaveBinaryHeader))}; + size_t result{Write(header, sizeof(WaveBinaryHeader))}; return result == sizeof(WaveBinaryHeader); } -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index 364259b6..950f4ade 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -436,4 +436,4 @@ void Channel::AppendWaveBuffer(const WaveInfo& waveInfo, position_t startOffsetS } } -} // namespace nn::atk::detail::driver \ No newline at end of file +} // namespace nn::atk::detail::driver diff --git a/src/NintendoWare/atk/detail/voice/atk_ChannelManager.cpp b/src/NintendoWare/atk/detail/voice/atk_ChannelManager.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/voice/atk_ChannelManager.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_ChannelManager.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp index df4f089d..10c4de48 100644 --- a/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_LowLevelVoice.cpp @@ -257,4 +257,4 @@ float LowLevelVoice::GetClampedVoiceVolume(float volume) { return fnd::FloatClamp(volume, 0.0f, 128.0f); } -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/voice/atk_MultiVoice.cpp b/src/NintendoWare/atk/detail/voice/atk_MultiVoice.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/voice/atk_MultiVoice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_MultiVoice.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/voice/atk_MultiVoiceManager.cpp b/src/NintendoWare/atk/detail/voice/atk_MultiVoiceManager.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/voice/atk_MultiVoiceManager.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_MultiVoiceManager.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/voice/atk_Voice.cpp b/src/NintendoWare/atk/detail/voice/atk_Voice.cpp index 8bd70285..0fabbf4d 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Voice.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Voice.cpp @@ -9,4 +9,4 @@ const OutputMix DefaultTvMix{{1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, } -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/voice/atk_VoiceCommand.cpp b/src/NintendoWare/atk/detail/voice/atk_VoiceCommand.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/voice/atk_VoiceCommand.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_VoiceCommand.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSound.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSound.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSound.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSound.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp index 0992232f..6c70263d 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFile.cpp @@ -267,4 +267,4 @@ const AdshrCurve& WaveSoundFile::NoteInfo::GetAdshrCurve() const { return WsdDefaultAdshrCurve; } -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp index 4ca208ec..938b3c25 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundFileReader.cpp @@ -97,4 +97,4 @@ bool WaveSoundFileReader::IsFilterSupportedVersion() const { return m_pHeader->header.version >= FilterSupportedVersionWsd; } -} // namespace nn::atk::detail \ No newline at end of file +} // namespace nn::atk::detail diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundLoader.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundLoader.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundLoader.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundLoader.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundPlayer.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundPlayer.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundPlayer.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundPlayer.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundRuntime.cpp b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundRuntime.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/detail/wsd/atk_WaveSoundRuntime.cpp +++ b/src/NintendoWare/atk/detail/wsd/atk_WaveSoundRuntime.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/effect/atk_EffectAux.cpp b/src/NintendoWare/atk/effect/atk_EffectAux.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/effect/atk_EffectAux.cpp +++ b/src/NintendoWare/atk/effect/atk_EffectAux.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/effect/atk_EffectBase.cpp b/src/NintendoWare/atk/effect/atk_EffectBase.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/effect/atk_EffectBase.cpp +++ b/src/NintendoWare/atk/effect/atk_EffectBase.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/fnd/basis/atkfnd_FrameHeapImpl.cpp b/src/NintendoWare/atk/fnd/basis/atkfnd_FrameHeapImpl.cpp index 29f297b7..ebff25b1 100644 --- a/src/NintendoWare/atk/fnd/basis/atkfnd_FrameHeapImpl.cpp +++ b/src/NintendoWare/atk/fnd/basis/atkfnd_FrameHeapImpl.cpp @@ -1,5 +1,3 @@ #include -namespace nn::atk::detail::fnd { - -} // namespace nn::atk::detail::fnd \ No newline at end of file +namespace nn::atk::detail::fnd {} // namespace nn::atk::detail::fnd diff --git a/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp b/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp index ebdf4be4..cea5f720 100644 --- a/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp +++ b/src/NintendoWare/atk/fnd/basis/atkfnd_HeapBase.cpp @@ -5,13 +5,15 @@ namespace nn::atk::detail::fnd { namespace { + HeapBase::HeapList sRootList; -u32 sFillVals[HeapBase::FillType_Max] = { 0xC3C3C3C3, 0xF3F3F3F3, 0xD3D3D3D3 }; -} // anonymous namespace +u32 sFillVals[HeapBase::FillType_Max] = {0xC3C3C3C3, 0xF3F3F3F3, 0xD3D3D3D3}; + +} // anonymous namespace HeapBase::HeapList* HeapBase::FindListContainHeap(HeapBase* pHeapBase) { - HeapList* pList {&sRootList}; - HeapBase* pContainHeapBase {FindContainHeap(pList, pHeapBase)}; + HeapList* pList{&sRootList}; + HeapBase* pContainHeapBase{FindContainHeap(pList, pHeapBase)}; if (pContainHeapBase != nullptr) pList = &pContainHeapBase->m_ChildList; @@ -30,7 +32,8 @@ HeapBase::HeapList* HeapBase::FindListContainHeap(HeapBase* pHeapBase) { // if (&pList->front() == &*curItr) // return nullptr; -// if (reinterpret_cast(curItr->mHeapStart) <= memBlockAddress && memBlockAddress < reinterpret_cast(curItr->mHeapEnd)) { +// if (reinterpret_cast(curItr->mHeapStart) <= memBlockAddress && memBlockAddress < +// reinterpret_cast(curItr->mHeapEnd)) { // HeapBase* pChildHeapBase {FindContainHeap(&curItr->m_ChildList, &*curItr)}; // if (pChildHeapBase != nullptr) @@ -47,12 +50,13 @@ HeapBase* HeapBase::FindContainHeap(const void* memBlock) { } HeapBase* HeapBase::FindParentHeap(const HeapBase* pChild) { - u64 heapAddress {reinterpret_cast(pChild)}; + u64 heapAddress{reinterpret_cast(pChild)}; - for (auto itr {sRootList.begin()}; itr != sRootList.end();) { - auto curItr {itr++}; + for (auto itr{sRootList.begin()}; itr != sRootList.end();) { + auto curItr{itr++}; - if (reinterpret_cast(curItr->mHeapStart) <= heapAddress && reinterpret_cast(curItr->mHeapEnd) > heapAddress) + if (reinterpret_cast(curItr->mHeapStart) <= heapAddress && + reinterpret_cast(curItr->mHeapEnd) > heapAddress) return FindContainHeap(&curItr->m_ChildList, &*curItr); } @@ -60,7 +64,7 @@ HeapBase* HeapBase::FindParentHeap(const HeapBase* pChild) { } u32 HeapBase::SetFillValue(FillType type, u32 val) { - u32 oldVal {sFillVals[type]}; + u32 oldVal{sFillVals[type]}; sFillVals[type] = val; return oldVal; @@ -95,15 +99,15 @@ void HeapBase::Initialize(u32 signature, void* heapStart, void* heapEnd, u16 opt u32 diff = GetOffsetFromPtr(heapStart, heapEnd); FillNoUseMemory(heapStart, diff); - HeapList* pList {FindListContainHeap(this)}; + HeapList* pList{FindListContainHeap(this)}; pList->push_back(*this); } // NON_MATCHING void HeapBase::Finalize() { - HeapList* pList {FindListContainHeap(this)}; - + HeapList* pList{FindListContainHeap(this)}; + if (pList != nullptr) pList->erase(pList->begin()); @@ -134,7 +138,6 @@ void HeapBase::FillAllocMemory(void* address, size_t size) { memset(address, static_cast(GetFillValue(FillType_Alloc)), size); } - u16 HeapBase::GetOptionFlag() { return m_Attribute & 0xFF; } @@ -142,9 +145,10 @@ u16 HeapBase::GetOptionFlag() { // NON_MATCHING: matches inlined, but not standalone void HeapBase::SetOptionFlag(u16 optFlag) { if (optFlag >= 0) { - u32 maskBits {0xff}; + u32 maskBits{0xff}; u32 newVal = optFlag & maskBits; m_Attribute = newVal; } } -} // namespace nn::atk::detail::fnd \ No newline at end of file + +} // namespace nn::atk::detail::fnd diff --git a/src/NintendoWare/atk/fnd/basis/atkfnd_Time.win32.cpp b/src/NintendoWare/atk/fnd/basis/atkfnd_Time.win32.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/fnd/basis/atkfnd_Time.win32.cpp +++ b/src/NintendoWare/atk/fnd/basis/atkfnd_Time.win32.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/fnd/basis/atkfnd_WorkBufferAllocator.cpp b/src/NintendoWare/atk/fnd/basis/atkfnd_WorkBufferAllocator.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/fnd/basis/atkfnd_WorkBufferAllocator.cpp +++ b/src/NintendoWare/atk/fnd/basis/atkfnd_WorkBufferAllocator.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp index f4c2570a..3fd5abf5 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.cpp @@ -5,6 +5,7 @@ #include namespace nn::atk::detail::fnd { + size_t FileStreamImpl::Read(void* buf, size_t length, FndResult* result) { if (IsCacheEnabled()) return m_StreamCache.Read(buf, length, result, m_pAccessLog, this); @@ -42,13 +43,10 @@ void FileStreamImpl::EnableCache(void* buffer, size_t length) { if (m_StreamCache.IsInitialized()) m_StreamCache.Finalize(); - void* alignedBuffer {util::BytePtr(buffer).AlignUp(GetIoBufferAlignment()).Get()}; + void* alignedBuffer{util::BytePtr(buffer).AlignUp(GetIoBufferAlignment()).Get()}; - m_StreamCache.Initialize( - &m_DirectStream, - alignedBuffer, - length + GetOffsetFromPtr(alignedBuffer, buffer) - ); + m_StreamCache.Initialize(&m_DirectStream, alignedBuffer, + length + GetOffsetFromPtr(alignedBuffer, buffer)); } void FileStreamImpl::DisableCache() { @@ -58,4 +56,5 @@ void FileStreamImpl::DisableCache() { void FileStreamImpl::ValidateAlignment([[maybe_unused]] const void* buf) const { GetIoBufferAlignment(); } -} // namespace nn::atk::detail::fnd \ No newline at end of file + +} // namespace nn::atk::detail::fnd diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp index 33241eb4..f5497eea 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamImpl.win32.cpp @@ -9,6 +9,7 @@ namespace nn::atk::detail::fnd { namespace { + fs::OpenMode ConvertAccessMode(FileStream::AccessMode accessMode) {} position_t GetSeekPosition(FileStreamImpl& target, position_t offset, Stream::SeekOrigin origin) { @@ -40,6 +41,7 @@ position_t GetSeekPosition(FileStreamImpl& target, position_t offset, Stream::Se return result; } + } // anonymous namespace FileStreamImpl::FileStreamImpl() { @@ -126,4 +128,4 @@ FndResult FileStreamImpl::SeekDirect(position_t offset, SeekOrigin origin) { return FndResult{FndResultType_True}; } -} // namespace nn::atk::detail::fnd \ No newline at end of file +} // namespace nn::atk::detail::fnd diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp index b24c8376..d02503a5 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_FileStreamProxy.cpp @@ -4,6 +4,7 @@ #include "nn/atk/fnd/basis/atkfnd_Config.h" namespace nn::atk::detail::fnd { + FileStreamProxy::FileStreamProxy(FileStream* fileStream, position_t offset, size_t fileSize) : m_pFileStream{fileStream}, m_Offset{offset}, m_FileSize{fileSize} {} @@ -66,7 +67,7 @@ FndResult FileStreamProxy::Seek(position_t offset, fnd::Stream::SeekOrigin origi break; case SeekOrigin_Current: offset = m_pFileStream->GetCurrentPosition() + offset; - break; + break; default: return FndResult{FndResultType_Failed}; } @@ -112,4 +113,5 @@ position_t FileStreamProxy::GetCachePosition() { size_t FileStreamProxy::GetCachedLength() { return m_pFileStream->GetCachedLength(); } -} // namespace nn::atk::detail::fnd \ No newline at end of file + +} // namespace nn::atk::detail::fnd diff --git a/src/NintendoWare/atk/fnd/io/atkfnd_StreamCache.cpp b/src/NintendoWare/atk/fnd/io/atkfnd_StreamCache.cpp index ad3da737..ebddc0d9 100644 --- a/src/NintendoWare/atk/fnd/io/atkfnd_StreamCache.cpp +++ b/src/NintendoWare/atk/fnd/io/atkfnd_StreamCache.cpp @@ -1,5 +1,3 @@ #include -namespace nn::atk::detail::fnd { - -} // namespace nn::atk::detail::fnd \ No newline at end of file +namespace nn::atk::detail::fnd {} // namespace nn::atk::detail::fnd diff --git a/src/NintendoWare/atk/fnd/os/atkfnd_Thread.cpp b/src/NintendoWare/atk/fnd/os/atkfnd_Thread.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/fnd/os/atkfnd_Thread.cpp +++ b/src/NintendoWare/atk/fnd/os/atkfnd_Thread.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/fnd/os/atkfnd_Thread.win32.cpp b/src/NintendoWare/atk/fnd/os/atkfnd_Thread.win32.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/fnd/os/atkfnd_Thread.win32.cpp +++ b/src/NintendoWare/atk/fnd/os/atkfnd_Thread.win32.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/submix/atk_ChannelMixVolume.cpp b/src/NintendoWare/atk/submix/atk_ChannelMixVolume.cpp index d6785e88..c66cfd87 100644 --- a/src/NintendoWare/atk/submix/atk_ChannelMixVolume.cpp +++ b/src/NintendoWare/atk/submix/atk_ChannelMixVolume.cpp @@ -1 +1 @@ -#include \ No newline at end of file +#include diff --git a/src/NintendoWare/atk/submix/atk_FinalMix.cpp b/src/NintendoWare/atk/submix/atk_FinalMix.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/submix/atk_FinalMix.cpp +++ b/src/NintendoWare/atk/submix/atk_FinalMix.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/submix/atk_OutputMixer.cpp b/src/NintendoWare/atk/submix/atk_OutputMixer.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/submix/atk_OutputMixer.cpp +++ b/src/NintendoWare/atk/submix/atk_OutputMixer.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/submix/atk_SubMix.cpp b/src/NintendoWare/atk/submix/atk_SubMix.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/submix/atk_SubMix.cpp +++ b/src/NintendoWare/atk/submix/atk_SubMix.cpp @@ -0,0 +1 @@ + diff --git a/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp b/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp index 709ae439..b2b82504 100644 --- a/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp +++ b/src/NintendoWare/atk/util/atk_AudioRendererPerformanceReader.cpp @@ -5,24 +5,26 @@ #include namespace nn::atk { + AudioRendererPerformanceReader::AudioRendererPerformanceReader() = default; size_t AudioRendererPerformanceReader::GetRequiredMemorySize(int performanceInfoCount) { - size_t size {performanceInfoCount * + size_t size{performanceInfoCount * (SoundSystem::GetPerformanceFrameBufferSize() + sizeof(PerformanceInfo))}; return size; } -void AudioRendererPerformanceReader::Initialize(int performanceInfoCount, void* buffer, [[maybe_unused]] size_t bufferSize) { +void AudioRendererPerformanceReader::Initialize(int performanceInfoCount, void* buffer, + [[maybe_unused]] size_t bufferSize) { m_PerformanceInfoCount = performanceInfoCount; - - auto ptr {util::BytePtr(buffer)}; + + auto ptr{util::BytePtr(buffer)}; m_pPerformanceInfo = ptr.Get(); ptr += static_cast(performanceInfoCount * sizeof(PerformanceInfo)); - - const size_t performanceBufferSize {SoundSystem::GetPerformanceFrameBufferSize()}; - for (int i {0}; i < m_PerformanceInfoCount; ++i) { + + const size_t performanceBufferSize{SoundSystem::GetPerformanceFrameBufferSize()}; + for (int i{0}; i < m_PerformanceInfoCount; ++i) { m_pPerformanceInfo[i].performanceBuffer = ptr.Get(); m_pPerformanceInfo[i].performanceBufferSize = performanceBufferSize; ptr += static_cast(performanceBufferSize); @@ -33,9 +35,10 @@ void AudioRendererPerformanceReader::Initialize(int performanceInfoCount, void* m_IsInitialized = true; } -const AudioRendererPerformanceReader::PerformanceInfo* AudioRendererPerformanceReader::ReadPerformanceInfo() { - int nextReadIndex {0}; - const int readIndex {m_ReadIndex}; +const AudioRendererPerformanceReader::PerformanceInfo* +AudioRendererPerformanceReader::ReadPerformanceInfo() { + int nextReadIndex{0}; + const int readIndex{m_ReadIndex}; if (readIndex + 1 < m_PerformanceInfoCount) nextReadIndex = readIndex + 1; @@ -48,18 +51,20 @@ const AudioRendererPerformanceReader::PerformanceInfo* AudioRendererPerformanceR return nullptr; } -void AudioRendererPerformanceReader::Record(const void* performanceFrameBuffer, +void AudioRendererPerformanceReader::Record(const void* performanceFrameBuffer, size_t performanceFrameBufferSize, os::Tick tick) { if (m_WriteIndex != m_ReadIndex) { - const int writeIndex {m_WriteIndex}; + const int writeIndex{m_WriteIndex}; m_pPerformanceInfo[writeIndex].tick = tick; - memcpy(m_pPerformanceInfo[writeIndex].performanceBuffer, performanceFrameBuffer, performanceFrameBufferSize); - - int nextWriteIndex {0}; + memcpy(m_pPerformanceInfo[writeIndex].performanceBuffer, performanceFrameBuffer, + performanceFrameBufferSize); + + int nextWriteIndex{0}; if (writeIndex + 1 < m_PerformanceInfoCount) nextWriteIndex = writeIndex + 1; m_WriteIndex = nextWriteIndex; } } -} // namespace nn::atk \ No newline at end of file + +} // namespace nn::atk diff --git a/src/NintendoWare/atk/util/atk_DeviceOutRecorder.cpp b/src/NintendoWare/atk/util/atk_DeviceOutRecorder.cpp index cc3866ed..cae67241 100644 --- a/src/NintendoWare/atk/util/atk_DeviceOutRecorder.cpp +++ b/src/NintendoWare/atk/util/atk_DeviceOutRecorder.cpp @@ -1,5 +1,3 @@ #include -namespace nn::atk { - -} // namespace nn::atk \ No newline at end of file +namespace nn::atk {} // namespace nn::atk diff --git a/src/NintendoWare/atk/util/atk_ProfileReader.cpp b/src/NintendoWare/atk/util/atk_ProfileReader.cpp index 37e72087..37707b17 100644 --- a/src/NintendoWare/atk/util/atk_ProfileReader.cpp +++ b/src/NintendoWare/atk/util/atk_ProfileReader.cpp @@ -1,5 +1,3 @@ #include -namespace nn::atk { - -} // namespace nn::atk \ No newline at end of file +namespace nn::atk {} // namespace nn::atk diff --git a/src/NintendoWare/atk/util/atk_TaskProfileReader.cpp b/src/NintendoWare/atk/util/atk_TaskProfileReader.cpp index e69de29b..8b137891 100644 --- a/src/NintendoWare/atk/util/atk_TaskProfileReader.cpp +++ b/src/NintendoWare/atk/util/atk_TaskProfileReader.cpp @@ -0,0 +1 @@ + From f0b77304bb2f322c513b8c41f0578bc400e4b076 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 10:52:46 -0300 Subject: [PATCH 685/785] atk: Match `BasicSound::CalculateVolume` --- .../atk/detail/atk_BasicSound.cpp | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 0d555210..4dbbf664 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -656,4 +656,26 @@ void BasicSound::DetachTempGeneralHandle() { m_pTempGeneralHandle->DetachSound(); } +float BasicSound::CalculateVolume() const { + float volume{1.0f}; + + if (m_MuteState == MuteState_Muted) + return 0.0f; + +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) + if (!IsVolumeThroughModeUsed()) +#endif + volume = m_InitVolume; + + volume *= m_pSoundPlayer->GetVolume(); + volume *= m_CommonParam.GetVolume(); + volume *= m_FadeVolume.GetValue(); + volume *= m_PauseFadeVolume.GetValue(); + volume *= m_MuteFadeVolume.GetValue(); + volume *= m_AmbientParam.GetVolume(); + volume *= m_ActorParam.volume; + + return volume; +} + } // namespace nn::atk::detail From ab5060d0dfce48492784bfe3ae4c81afd9a97348 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 11:04:42 -0300 Subject: [PATCH 686/785] atk: Match `BasicSound::CalculatePitch` --- include/nn/atk/atk_BasicSound.h | 2 +- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index 9050038b..64f3f64f 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -435,7 +435,7 @@ class BasicSound { int GetRemainingPauseFadeFrames() const; int GetRemainingMuteFadeFrames() const; - int GetPlayerPriority() const { return m_AmbientParam.GetPriority(); } + int GetPlayerPriority() const { return m_Priority + m_AmbientParam.GetPriority(); } void CalculateSoundParamCalculationValues(SoundParamCalculationValues* pOutValue) const; diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 4dbbf664..162dbdb4 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -634,6 +634,18 @@ void BasicSound::CalculateSoundParamCalculationValues( pOutValue->soundHandleParam.outputMixParameter[device][1] = m_OutputParam[device].mixParameter[1]; } + + pOutValue->resultParam.volume = CalculateVolume(); + pOutValue->resultParam.pitch = CalculatePitch(); + pOutValue->resultParam.lpf = CalculateLpfFrequency(); + pOutValue->resultParam.outputLineFlag = CalculateOutLineFlag(); + pOutValue->resultParam.playerPriority = fnd::Clamp(GetPlayerPriority(), 0, 127); + CalculateBiquadFilter(&pOutValue->resultParam.bqfType, &pOutValue->resultParam.bqfValue); + CalculateOutputParam(pOutValue->resultParam.outputParamResult, OutputDevice_Main); + + pOutValue->fadeVolumeParam.stopFadeVolume = m_FadeVolume.GetValue(); + pOutValue->fadeVolumeParam.pauseFadeVolume = m_PauseFadeVolume.GetValue(); + pOutValue->fadeVolumeParam.muteFadeVolume = m_MuteFadeVolume.GetValue(); } void BasicSound::SetId(u32 id) { @@ -678,4 +690,8 @@ float BasicSound::CalculateVolume() const { return volume; } +float BasicSound::CalculatePitch() const { + return m_Pitch * m_AmbientParam.GetPitch() * m_ActorParam.pitch; +} + } // namespace nn::atk::detail From 8f94b6ab5d647580bb666e3b5454bcedcc3cb2ad Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 11:06:52 -0300 Subject: [PATCH 687/785] atk: Match `BasicSound::CalculateLpfFrequency` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 162dbdb4..974cc731 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -694,4 +694,9 @@ float BasicSound::CalculatePitch() const { return m_Pitch * m_AmbientParam.GetPitch() * m_ActorParam.pitch; } +float BasicSound::CalculateLpfFrequency() const { + return m_LpfFreq + m_AmbientParam.GetLpf() + GetSoundPlayer()->GetLowPassFilterFrequency() + + m_ActorParam.lpf; +} + } // namespace nn::atk::detail From 9e228a0a8fd083a1a632f38cb2b33ffd999710dd Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 11:11:08 -0300 Subject: [PATCH 688/785] atk: Match `BasicSound::CalculateBiquadFilter` --- .../atk/detail/atk_BasicSound.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 974cc731..0a639261 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -4,6 +4,7 @@ #include #include #include +#include "nn/atk/atk_Global.h" namespace nn::atk::detail { @@ -699,4 +700,22 @@ float BasicSound::CalculateLpfFrequency() const { m_ActorParam.lpf; } +void BasicSound::CalculateBiquadFilter(int* pOutBiquadType, float* pOutBiquadValue) const { + int biquadFilterType{m_BiquadFilterType}; + float biquadFilterValue{m_BiquadFilterValue}; + + if (biquadFilterType == BiquadFilterType_Inherit) { + biquadFilterType = GetSoundPlayer()->GetBiquadFilterType(); + if (biquadFilterType == BiquadFilterType_Inherit) { + biquadFilterType = m_AmbientParam.GetBiquadFilterType(); + biquadFilterValue = m_AmbientParam.GetBiquadFilterValue(); + } else { + biquadFilterValue = GetSoundPlayer()->GetBiquadFilterValue(); + } + } + + *pOutBiquadType = biquadFilterType; + *pOutBiquadValue = biquadFilterValue; +} + } // namespace nn::atk::detail From e712b3d77238ebd3e879fc762caf2a506e2b7f9f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 11:13:25 -0300 Subject: [PATCH 689/785] atk: Match `BasicSound::CalculateOutLineFlag` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 0a639261..659abad0 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -718,4 +718,13 @@ void BasicSound::CalculateBiquadFilter(int* pOutBiquadType, float* pOutBiquadVal *pOutBiquadValue = biquadFilterValue; } +u32 BasicSound::CalculateOutLineFlag() const { + u32 outputLineFlag{m_OutputLineFlag}; + + if (m_AmbientParam.GetOutputLineFlag() != SoundAmbientParam::OutputLineFlagInherit) + outputLineFlag = m_AmbientParam.GetOutputLineFlag(); + + return outputLineFlag; +} + } // namespace nn::atk::detail From a00e1f824829a0ec96ed424e534590318285b954 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 11:23:07 -0300 Subject: [PATCH 690/785] atk: Match `BasicSound::ApplyCommonParam` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 659abad0..dc4d4303 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -4,7 +4,6 @@ #include #include #include -#include "nn/atk/atk_Global.h" namespace nn::atk::detail { @@ -727,4 +726,13 @@ u32 BasicSound::CalculateOutLineFlag() const { return outputLineFlag; } +void BasicSound::ApplyCommonParam(OutputParam& param) const { + param.mixMode = m_CommonParam.mixMode; + param.pan += m_CommonParam.pan; + param.span += m_CommonParam.span; + + for (int i{0}; i < DefaultBusCount; ++i) + param.send[i] += m_CommonParam.send[i]; +} + } // namespace nn::atk::detail From 8d18ebe1931af2e3d871a6132758ad9473f04958 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 11:44:16 -0300 Subject: [PATCH 691/785] atk: Match `BasicSound::CalculateOutputParam` --- .../atk/detail/atk_BasicSound.cpp | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index dc4d4303..3806ecd9 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -726,6 +726,37 @@ u32 BasicSound::CalculateOutLineFlag() const { return outputLineFlag; } +void BasicSound::CalculateOutputParam(OutputParam* pOutParam, OutputDevice device) const { + if (device != OutputDevice_Main) { + NN_UNEXPECTED_DEFAULT; + return; + } + + const OutputAmbientParam* pAmbientParam{&m_AmbientParam.GetTvParam()}; + float actorVolume{m_ActorParam.tvVolume}; + float actorPan{m_ActorParam.tvPan}; + + *pOutParam = m_OutputParam[device]; + + ApplyCommonParam(*pOutParam); + + const SoundPlayer* pSoundPlayer{m_pSoundPlayer}; + + pOutParam->volume *= + pSoundPlayer->GetOutputVolume(device) * pAmbientParam->GetVolume() * actorVolume; + pOutParam->pan += actorPan + pAmbientParam->GetPan(); + pOutParam->span += pAmbientParam->GetSurroundPan(); + + for (int i{0}; i < DefaultBusCount; ++i) { + if (i == OutputDeviceIndex_Main) + pOutParam->send[i] += pSoundPlayer->GetOutputMainSend(device); + else + pOutParam->send[i] += + pSoundPlayer->GetOutputFxSend(device, static_cast(i - 1)) + + pAmbientParam->GetEffectSend(i - 1); + } +} + void BasicSound::ApplyCommonParam(OutputParam& param) const { param.mixMode = m_CommonParam.mixMode; param.pan += m_CommonParam.pan; From cc6d61817b5fb53fd2d7f15ce8fa800b451a19ad Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 12:10:07 -0300 Subject: [PATCH 692/785] atk: Match `BasicSound::CalculateSoundParamCalculationValues` --- include/nn/atk/atk_BasicSound.h | 4 +- .../atk/detail/atk_BasicSound.cpp | 471 +++++++++--------- 2 files changed, 238 insertions(+), 237 deletions(-) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index 64f3f64f..4dfbb880 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -447,9 +447,7 @@ class BasicSound { void SetSetupTick(const os::Tick& tick); os::Tick GetSetupTick() const { return m_SetupTick; } - int CalcCurrentPlayerPriority() const { - return fnd::Clamp(m_AmbientParam.GetPriority(), 0, 127); - } + int CalcCurrentPlayerPriority() const { return fnd::Clamp(GetPlayerPriority(), 0, 127); } SoundPlayer* GetSoundPlayer() { return m_pSoundPlayer; } const SoundPlayer* GetSoundPlayer() const { return m_pSoundPlayer; } diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 3806ecd9..cdb97361 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -172,6 +172,19 @@ bool BasicSound::Initialize(OutputReceiver* pOutputReceiver) return true; } +void BasicSound::SetPriority(int priority, int ambientPriority) { + m_Priority = priority; + m_AmbientParam.SetPriority(ambientPriority); +} + +void BasicSound::GetPriority(int* priority, int* ambientPriority) const { + if (priority != nullptr) + *priority = m_Priority; + + if (ambientPriority != nullptr) + *ambientPriority = m_AmbientParam.GetPriority(); +} + void BasicSound::Finalize() { if (m_State != State_Initialized) return; @@ -236,6 +249,26 @@ void BasicSound::Finalize() { m_State = State_Finalized; } +void BasicSound::SetId(u32 id) { + m_Id = id; +} + +bool BasicSound::IsAttachedGeneralHandle() { + return m_pGeneralHandle != nullptr; +} + +void BasicSound::DetachGeneralHandle() { + m_pGeneralHandle->DetachSound(); +} + +bool BasicSound::IsAttachedTempGeneralHandle() { + return m_pTempGeneralHandle != nullptr; +} + +void BasicSound::DetachTempGeneralHandle() { + m_pTempGeneralHandle->DetachSound(); +} + void BasicSound::StartPrepared() { m_StartFlag = true; } @@ -259,6 +292,15 @@ void BasicSound::Stop(int fadeFrames) { m_MuteState = MuteState_Normal; } +void BasicSound::SetPlayerPriority(int priority) { + m_Priority = priority; + + if (m_pSoundPlayer != nullptr) + m_pSoundPlayer->detail_SortPriorityList(this); + + OnUpdatePlayerPriority(); +} + void BasicSound::ForceStop() { m_FadeOutFlag = true; @@ -378,17 +420,172 @@ bool BasicSound::IsMute() const { } } -void BasicSound::SetPriority(int priority, int ambientPriority) { - m_Priority = priority; - m_AmbientParam.SetPriority(ambientPriority); +float BasicSound::CalculateVolume() const { + float volume{1.0f}; + + if (m_MuteState == MuteState_Muted) + return 0.0f; + +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) + if (!IsVolumeThroughModeUsed()) +#endif + volume = m_InitVolume; + + volume *= m_pSoundPlayer->GetVolume(); + volume *= m_CommonParam.GetVolume(); + volume *= m_FadeVolume.GetValue(); + volume *= m_PauseFadeVolume.GetValue(); + volume *= m_MuteFadeVolume.GetValue(); + volume *= m_AmbientParam.GetVolume(); + volume *= m_ActorParam.volume; + + return volume; } -void BasicSound::GetPriority(int* priority, int* ambientPriority) const { - if (priority != nullptr) - *priority = m_Priority; +float BasicSound::CalculatePitch() const { + return m_Pitch * m_AmbientParam.GetPitch() * m_ActorParam.pitch; +} - if (ambientPriority != nullptr) - *ambientPriority = m_AmbientParam.GetPriority(); +float BasicSound::CalculateLpfFrequency() const { + return m_LpfFreq + m_AmbientParam.GetLpf() + GetSoundPlayer()->GetLowPassFilterFrequency() + + m_ActorParam.lpf; +} + +u32 BasicSound::CalculateOutLineFlag() const { + u32 outputLineFlag{m_OutputLineFlag}; + + if (m_AmbientParam.GetOutputLineFlag() != SoundAmbientParam::OutputLineFlagInherit) + outputLineFlag = m_AmbientParam.GetOutputLineFlag(); + + return outputLineFlag; +} + +void BasicSound::CalculateBiquadFilter(int* pOutBiquadType, float* pOutBiquadValue) const { + int biquadFilterType{m_BiquadFilterType}; + float biquadFilterValue{m_BiquadFilterValue}; + + if (biquadFilterType == BiquadFilterType_Inherit) { + biquadFilterType = GetSoundPlayer()->GetBiquadFilterType(); + if (biquadFilterType == BiquadFilterType_Inherit) { + biquadFilterType = m_AmbientParam.GetBiquadFilterType(); + biquadFilterValue = m_AmbientParam.GetBiquadFilterValue(); + } else { + biquadFilterValue = GetSoundPlayer()->GetBiquadFilterValue(); + } + } + + *pOutBiquadType = biquadFilterType; + *pOutBiquadValue = biquadFilterValue; +} + +void BasicSound::CalculateOutputParam(OutputParam* pOutParam, OutputDevice device) const { + if (device != OutputDevice_Main) { + NN_UNEXPECTED_DEFAULT; + return; + } + + const OutputAmbientParam* pAmbientParam{&m_AmbientParam.GetTvParam()}; + float actorVolume{m_ActorParam.tvVolume}; + float actorPan{m_ActorParam.tvPan}; + + *pOutParam = m_OutputParam[device]; + + ApplyCommonParam(*pOutParam); + + const SoundPlayer* pSoundPlayer{m_pSoundPlayer}; + + pOutParam->volume *= + pSoundPlayer->GetOutputVolume(device) * pAmbientParam->GetVolume() * actorVolume; + pOutParam->pan += actorPan + pAmbientParam->GetPan(); + pOutParam->span += pAmbientParam->GetSurroundPan(); + + for (int i{0}; i < DefaultBusCount; ++i) { + if (i == OutputDeviceIndex_Main) + pOutParam->send[i] += pSoundPlayer->GetOutputMainSend(device); + else + pOutParam->send[i] += + pSoundPlayer->GetOutputFxSend(device, static_cast(i - 1)) + + pAmbientParam->GetEffectSend(i - 1); + } +} + +void BasicSound::ApplyCommonParam(OutputParam& param) const { + param.mixMode = m_CommonParam.mixMode; + param.pan += m_CommonParam.pan; + param.span += m_CommonParam.span; + + for (int i{0}; i < DefaultBusCount; ++i) + param.send[i] += m_CommonParam.send[i]; +} + +int BasicSound::GetRemainingFadeFrames() const { + return m_FadeVolume.GetRemainingCount(); +} + +int BasicSound::GetRemainingPauseFadeFrames() const { + return m_PauseFadeVolume.GetRemainingCount(); +} + +int BasicSound::GetRemainingMuteFadeFrames() const { + return m_MuteFadeVolume.GetRemainingCount(); +} + +void BasicSound::CalculateSoundParamCalculationValues( + SoundParamCalculationValues* pOutValue) const { + pOutValue->soundArchiveParam.volume = m_InitVolume; + + SetSoundPlayerCalculationValues(pOutValue->soundPlayerParam, *m_pSoundPlayer); + SetSound3DCalculationValues(pOutValue->sound3DParam, m_AmbientParam); + SetSoundActorCalculationValues(pOutValue->soundActorParam, m_ActorParam); + + pOutValue->soundHandleParam.volume = m_CommonParam.GetVolume(); + pOutValue->soundHandleParam.pitch = m_Pitch; + pOutValue->soundHandleParam.lpf = m_LpfFreq; + pOutValue->soundHandleParam.bqfType = static_cast(m_BiquadFilterType); + pOutValue->soundHandleParam.bqfValue = m_BiquadFilterValue; + pOutValue->soundHandleParam.outputLineFlag = m_OutputLineFlag; + pOutValue->soundHandleParam.mixMode = m_CommonParam.mixMode; + pOutValue->soundHandleParam.pan = m_CommonParam.pan; + pOutValue->soundHandleParam.surroundPan = m_CommonParam.span; + pOutValue->soundHandleParam.mainSend = m_CommonParam.send[OutputDeviceIndex_Main]; + pOutValue->soundHandleParam.playerPriority = m_Priority; + + for (int i{0}; i < AuxBus_Count; ++i) + pOutValue->soundHandleParam.effectSend[i] = m_CommonParam.send[1L + i]; + + for (int i{0}; i < OutputDevice_Count; ++i) { + const OutputDevice device{static_cast(i)}; + + pOutValue->soundHandleParam.outputVolume[device] = m_OutputParam[device].volume; + pOutValue->soundHandleParam.outputPan[device] = m_OutputParam[device].pan; + pOutValue->soundHandleParam.outputSurroundPan[device] = m_OutputParam[device].span; + pOutValue->soundHandleParam.outputMainSend[device] = + m_OutputParam[device].send[OutputDeviceIndex_Main]; + + for (int k{0}; k < AuxBus_Count; ++k) + pOutValue->soundHandleParam.outputEffectSend[device][k] = + m_OutputParam[device].send[1 + k]; + + pOutValue->soundHandleParam.outputMixParameter[device][0] = + m_OutputParam[device].mixParameter[0]; + pOutValue->soundHandleParam.outputMixParameter[device][1] = + m_OutputParam[device].mixParameter[1]; + } + + pOutValue->resultParam.volume = CalculateVolume(); + pOutValue->resultParam.pitch = CalculatePitch(); + pOutValue->resultParam.lpf = CalculateLpfFrequency(); + pOutValue->resultParam.outputLineFlag = CalculateOutLineFlag(); + pOutValue->resultParam.playerPriority = CalcCurrentPlayerPriority(); + CalculateBiquadFilter(&pOutValue->resultParam.bqfType, &pOutValue->resultParam.bqfValue); + for (int i{0}; i < OutputDevice_Count; ++i) + CalculateOutputParam(&pOutValue->resultParam.outputParamResult[i], + static_cast(i)); + + pOutValue->fadeVolumeParam.stopFadeVolume = m_FadeVolume.GetValue(); + pOutValue->fadeVolumeParam.pauseFadeVolume = m_PauseFadeVolume.GetValue(); + pOutValue->fadeVolumeParam.muteFadeVolume = m_MuteFadeVolume.GetValue(); + pOutValue->fadeVolumeParam.isMuted = m_MuteState == MuteState_Muted; } void BasicSound::SetInitialVolume(float volume) { @@ -448,15 +645,6 @@ void BasicSound::ResetOutputLine() { m_OutputLineFlag = m_pSoundPlayer->GetDefaultOutputLine(); } -void BasicSound::SetPlayerPriority(int priority) { - m_Priority = priority; - - if (m_pSoundPlayer != nullptr) - m_pSoundPlayer->detail_SortPriorityList(this); - - OnUpdatePlayerPriority(); -} - void BasicSound::SetMixMode(MixMode mixMode) { m_CommonParam.mixMode = mixMode; } @@ -497,44 +685,16 @@ float BasicSound::GetFxSend(AuxBus bus) const { return m_CommonParam.send[1L + bus]; } -void BasicSound::SetPanMode(PanMode mode) { - { - DriverCommand& cmdmgr{*DriverCommand::GetInstance()}; - auto* command{cmdmgr.AllocCommand()}; - - command->id = DriverCommandId_PlayerPanmode; - command->player = GetBasicSoundPlayerHandle(); - command->panMode = mode; - - cmdmgr.PushCommand(command); - } -} - -void BasicSound::SetPanCurve(PanCurve curve) { - { - DriverCommand& cmdmgr{*DriverCommand::GetInstance()}; - auto* command{cmdmgr.AllocCommand()}; - - command->id = DriverCommandId_PlayerPancurve; - command->player = GetBasicSoundPlayerHandle(); - command->panCurve = curve; - - cmdmgr.PushCommand(command); - } -} - -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) -void BasicSound::SetOutputAdditionalParamAddr(OutputDevice device, OutputAdditionalParam* addr, - OutputAdditionalParam* addrForPlayer) { - m_pOutputAdditionalParam[device] = addr; - GetBasicSoundPlayerHandle()->SetTvAdditionalParamAddr(addrForPlayer); -} -#endif - void BasicSound::SetOutputVolume(OutputDevice device, float volume) { m_OutputParam[device].volume = volume; } +void BasicSound::SetOutputChannelMixParameter(OutputDevice device, u32 srcChNo, + MixParameter param) { + for (int i{0}; i < ChannelIndex_Count; ++i) + m_OutputParam[device].mixParameter[srcChNo].ch[i] = param.ch[i]; +} + void BasicSound::SetOutputPan(OutputDevice device, float pan) { m_OutputParam[device].pan = pan; } @@ -551,16 +711,14 @@ void BasicSound::SetOutputFxSend(OutputDevice device, AuxBus bus, float send) { m_OutputParam[device].send[1L + bus] = send; } -void BasicSound::SetOutputChannelMixParameter(OutputDevice device, u32 srcChNo, - MixParameter param) { - for (int i{0}; i < ChannelIndex_Count; ++i) - m_OutputParam[device].mixParameter[srcChNo].ch[i] = param.ch[i]; -} - float BasicSound::GetOutputVolume(OutputDevice device) const { return m_OutputParam[device].volume; } +MixParameter BasicSound::GetOutputChannelMixParameter(OutputDevice device, u32 srcChNo) const { + return m_OutputParam[device].mixParameter[srcChNo]; +} + float BasicSound::GetOutputPan(OutputDevice device) const { return m_OutputParam[device].pan; } @@ -577,193 +735,38 @@ float BasicSound::GetOutputFxSend(OutputDevice device, AuxBus bus) const { return m_OutputParam[device].send[1L + bus]; } -MixParameter BasicSound::GetOutputChannelMixParameter(OutputDevice device, u32 srcChNo) const { - return m_OutputParam[device].mixParameter[srcChNo]; -} - -int BasicSound::GetRemainingFadeFrames() const { - return m_FadeVolume.GetRemainingCount(); -} - -int BasicSound::GetRemainingPauseFadeFrames() const { - return m_PauseFadeVolume.GetRemainingCount(); -} - -int BasicSound::GetRemainingMuteFadeFrames() const { - return m_MuteFadeVolume.GetRemainingCount(); -} - -void BasicSound::CalculateSoundParamCalculationValues( - SoundParamCalculationValues* pOutValue) const { - pOutValue->soundArchiveParam.volume = m_InitVolume; - - SetSoundPlayerCalculationValues(pOutValue->soundPlayerParam, *m_pSoundPlayer); - SetSound3DCalculationValues(pOutValue->sound3DParam, m_AmbientParam); - SetSoundActorCalculationValues(pOutValue->soundActorParam, m_ActorParam); - - pOutValue->soundHandleParam.volume = m_CommonParam.GetVolume(); - pOutValue->soundHandleParam.pitch = m_Pitch; - pOutValue->soundHandleParam.lpf = m_LpfFreq; - pOutValue->soundHandleParam.bqfType = static_cast(m_BiquadFilterType); - pOutValue->soundHandleParam.bqfValue = m_BiquadFilterValue; - pOutValue->soundHandleParam.outputLineFlag = m_OutputLineFlag; - pOutValue->soundHandleParam.mixMode = m_CommonParam.mixMode; - pOutValue->soundHandleParam.pan = m_CommonParam.pan; - pOutValue->soundHandleParam.surroundPan = m_CommonParam.span; - pOutValue->soundHandleParam.mainSend = m_CommonParam.send[OutputDeviceIndex_Main]; - pOutValue->soundHandleParam.playerPriority = m_Priority; - - for (int i{0}; i < AuxBus_Count; ++i) - pOutValue->soundHandleParam.effectSend[i] = m_CommonParam.send[1L + i]; - - for (int i{0}; i < OutputDevice_Count; ++i) { - const OutputDevice device{static_cast(i)}; - - pOutValue->soundHandleParam.outputVolume[device] = m_OutputParam[device].volume; - pOutValue->soundHandleParam.outputPan[device] = m_OutputParam[device].pan; - pOutValue->soundHandleParam.outputSurroundPan[device] = m_OutputParam[device].span; - pOutValue->soundHandleParam.outputMainSend[device] = - m_OutputParam[device].send[OutputDeviceIndex_Main]; - - for (int k{0}; k < AuxBus_Count; ++k) - pOutValue->soundHandleParam.outputEffectSend[device][1L + k] = - m_OutputParam[device].send[1L + k]; - - pOutValue->soundHandleParam.outputMixParameter[device][0] = - m_OutputParam[device].mixParameter[0]; - pOutValue->soundHandleParam.outputMixParameter[device][1] = - m_OutputParam[device].mixParameter[1]; - } - - pOutValue->resultParam.volume = CalculateVolume(); - pOutValue->resultParam.pitch = CalculatePitch(); - pOutValue->resultParam.lpf = CalculateLpfFrequency(); - pOutValue->resultParam.outputLineFlag = CalculateOutLineFlag(); - pOutValue->resultParam.playerPriority = fnd::Clamp(GetPlayerPriority(), 0, 127); - CalculateBiquadFilter(&pOutValue->resultParam.bqfType, &pOutValue->resultParam.bqfValue); - CalculateOutputParam(pOutValue->resultParam.outputParamResult, OutputDevice_Main); - - pOutValue->fadeVolumeParam.stopFadeVolume = m_FadeVolume.GetValue(); - pOutValue->fadeVolumeParam.pauseFadeVolume = m_PauseFadeVolume.GetValue(); - pOutValue->fadeVolumeParam.muteFadeVolume = m_MuteFadeVolume.GetValue(); -} - -void BasicSound::SetId(u32 id) { - m_Id = id; -} - -bool BasicSound::IsAttachedGeneralHandle() { - return m_pGeneralHandle != nullptr; -} - -bool BasicSound::IsAttachedTempGeneralHandle() { - return m_pTempGeneralHandle != nullptr; -} - -void BasicSound::DetachGeneralHandle() { - m_pGeneralHandle->DetachSound(); -} - -void BasicSound::DetachTempGeneralHandle() { - m_pTempGeneralHandle->DetachSound(); -} - -float BasicSound::CalculateVolume() const { - float volume{1.0f}; - - if (m_MuteState == MuteState_Muted) - return 0.0f; - -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) - if (!IsVolumeThroughModeUsed()) -#endif - volume = m_InitVolume; - - volume *= m_pSoundPlayer->GetVolume(); - volume *= m_CommonParam.GetVolume(); - volume *= m_FadeVolume.GetValue(); - volume *= m_PauseFadeVolume.GetValue(); - volume *= m_MuteFadeVolume.GetValue(); - volume *= m_AmbientParam.GetVolume(); - volume *= m_ActorParam.volume; - - return volume; -} - -float BasicSound::CalculatePitch() const { - return m_Pitch * m_AmbientParam.GetPitch() * m_ActorParam.pitch; -} - -float BasicSound::CalculateLpfFrequency() const { - return m_LpfFreq + m_AmbientParam.GetLpf() + GetSoundPlayer()->GetLowPassFilterFrequency() + - m_ActorParam.lpf; -} +void BasicSound::SetPanMode(PanMode mode) { + { + DriverCommand& cmdmgr{*DriverCommand::GetInstance()}; + auto* command{cmdmgr.AllocCommand()}; -void BasicSound::CalculateBiquadFilter(int* pOutBiquadType, float* pOutBiquadValue) const { - int biquadFilterType{m_BiquadFilterType}; - float biquadFilterValue{m_BiquadFilterValue}; + command->id = DriverCommandId_PlayerPanmode; + command->player = GetBasicSoundPlayerHandle(); + command->panMode = mode; - if (biquadFilterType == BiquadFilterType_Inherit) { - biquadFilterType = GetSoundPlayer()->GetBiquadFilterType(); - if (biquadFilterType == BiquadFilterType_Inherit) { - biquadFilterType = m_AmbientParam.GetBiquadFilterType(); - biquadFilterValue = m_AmbientParam.GetBiquadFilterValue(); - } else { - biquadFilterValue = GetSoundPlayer()->GetBiquadFilterValue(); - } + cmdmgr.PushCommand(command); } - - *pOutBiquadType = biquadFilterType; - *pOutBiquadValue = biquadFilterValue; } -u32 BasicSound::CalculateOutLineFlag() const { - u32 outputLineFlag{m_OutputLineFlag}; - - if (m_AmbientParam.GetOutputLineFlag() != SoundAmbientParam::OutputLineFlagInherit) - outputLineFlag = m_AmbientParam.GetOutputLineFlag(); - - return outputLineFlag; -} - -void BasicSound::CalculateOutputParam(OutputParam* pOutParam, OutputDevice device) const { - if (device != OutputDevice_Main) { - NN_UNEXPECTED_DEFAULT; - return; - } - - const OutputAmbientParam* pAmbientParam{&m_AmbientParam.GetTvParam()}; - float actorVolume{m_ActorParam.tvVolume}; - float actorPan{m_ActorParam.tvPan}; - - *pOutParam = m_OutputParam[device]; - - ApplyCommonParam(*pOutParam); - - const SoundPlayer* pSoundPlayer{m_pSoundPlayer}; +void BasicSound::SetPanCurve(PanCurve curve) { + { + DriverCommand& cmdmgr{*DriverCommand::GetInstance()}; + auto* command{cmdmgr.AllocCommand()}; - pOutParam->volume *= - pSoundPlayer->GetOutputVolume(device) * pAmbientParam->GetVolume() * actorVolume; - pOutParam->pan += actorPan + pAmbientParam->GetPan(); - pOutParam->span += pAmbientParam->GetSurroundPan(); + command->id = DriverCommandId_PlayerPancurve; + command->player = GetBasicSoundPlayerHandle(); + command->panCurve = curve; - for (int i{0}; i < DefaultBusCount; ++i) { - if (i == OutputDeviceIndex_Main) - pOutParam->send[i] += pSoundPlayer->GetOutputMainSend(device); - else - pOutParam->send[i] += - pSoundPlayer->GetOutputFxSend(device, static_cast(i - 1)) + - pAmbientParam->GetEffectSend(i - 1); + cmdmgr.PushCommand(command); } } -void BasicSound::ApplyCommonParam(OutputParam& param) const { - param.mixMode = m_CommonParam.mixMode; - param.pan += m_CommonParam.pan; - param.span += m_CommonParam.span; - - for (int i{0}; i < DefaultBusCount; ++i) - param.send[i] += m_CommonParam.send[i]; +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) +void BasicSound::SetOutputAdditionalParamAddr(OutputDevice device, OutputAdditionalParam* addr, + OutputAdditionalParam* addrForPlayer) { + m_pOutputAdditionalParam[device] = addr; + GetBasicSoundPlayerHandle()->SetTvAdditionalParamAddr(addrForPlayer); } +#endif } // namespace nn::atk::detail From 6334ed90ef1bdbd855cfcf9664e9043f16d8c055 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 12:12:42 -0300 Subject: [PATCH 693/785] atk: Match `BasicSound::SetSetupTick` --- include/nn/atk/atk_BasicSound.h | 3 ++- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index 4dfbb880..b9546f8d 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -440,8 +440,9 @@ class BasicSound { void CalculateSoundParamCalculationValues(SoundParamCalculationValues* pOutValue) const; void SetId(u32 id); + u32 GetId() const { return m_Id; } - u32 GetInstanceId() const; + u32 GetInstanceId() const { return m_InstanceId; } u32 GetPlayFrameCount() const { return m_PlayingCounter; } void SetSetupTick(const os::Tick& tick); diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index cdb97361..b3a6a95e 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -769,4 +769,8 @@ void BasicSound::SetOutputAdditionalParamAddr(OutputDevice device, OutputAdditio } #endif +void BasicSound::SetSetupTick(const os::Tick& tick) { + m_SetupTick = tick; +} + } // namespace nn::atk::detail From e7813144908a3bfed6899a4b8f13a7a9b0f44d13 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 12:15:00 -0300 Subject: [PATCH 694/785] atk: Match `BasicSound::AttachSoundPlayer` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index b3a6a95e..153319de 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -773,4 +773,8 @@ void BasicSound::SetSetupTick(const os::Tick& tick) { m_SetupTick = tick; } +void BasicSound::AttachSoundPlayer(SoundPlayer* player) { + m_pSoundPlayer = player; +} + } // namespace nn::atk::detail From ad9b995c8607dcda2bf6d307c25e075b6ecf98a3 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 12:15:40 -0300 Subject: [PATCH 695/785] atk: Match `BasicSound::DetachSoundPlayer` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 153319de..a8a2cb56 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -777,4 +777,8 @@ void BasicSound::AttachSoundPlayer(SoundPlayer* player) { m_pSoundPlayer = player; } +void BasicSound::DetachSoundPlayer([[maybe_unused]] SoundPlayer* player) { + m_pSoundPlayer = nullptr; +} + } // namespace nn::atk::detail From 7e23184cb2e6639f30704080df59fbf0df61fd7f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 12:16:25 -0300 Subject: [PATCH 696/785] atk: Match `BasicSound::AttachSoundActor` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index a8a2cb56..0d283319 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -781,4 +781,8 @@ void BasicSound::DetachSoundPlayer([[maybe_unused]] SoundPlayer* player) { m_pSoundPlayer = nullptr; } +void BasicSound::AttachSoundActor(SoundActor* actor) { + m_pSoundActor = actor; +} + } // namespace nn::atk::detail From 96e915c5e27bec16529cf050aa156d9b592e54ec Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 12:17:13 -0300 Subject: [PATCH 697/785] atk: Match `BasicSound::DetachSoundActor` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 0d283319..01e5c59d 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -785,4 +785,8 @@ void BasicSound::AttachSoundActor(SoundActor* actor) { m_pSoundActor = actor; } +void BasicSound::DetachSoundActor([[maybe_unused]] SoundActor* actor) { + m_pSoundActor = nullptr; +} + } // namespace nn::atk::detail From 6ef2712254cfa20092dcb79f48b00c50788d3ff0 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 12:18:58 -0300 Subject: [PATCH 698/785] atk: Match `BasicSound::AttachExternalSoundPlayer` --- include/nn/atk/atk_Channel.h | 2 +- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_Channel.h b/include/nn/atk/atk_Channel.h index f74ce0a2..6922ca7b 100644 --- a/include/nn/atk/atk_Channel.h +++ b/include/nn/atk/atk_Channel.h @@ -140,7 +140,7 @@ class Channel { #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) void SetTvAdditionalParamAddr(OutputAdditionalParam* param) { m_pTvAdditionalParam = param; } - const OutputAdditionalParam* const GetTvAdditionalParamAddr() const { + const OutputAdditionalParam* GetTvAdditionalParamAddr() const { return m_pTvAdditionalParam; } OutputAdditionalParam* GetTvAdditionalParamAddr() { return m_pTvAdditionalParam; } diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 01e5c59d..fe486da9 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -789,4 +789,8 @@ void BasicSound::DetachSoundActor([[maybe_unused]] SoundActor* actor) { m_pSoundActor = nullptr; } +void BasicSound::AttachExternalSoundPlayer(ExternalSoundPlayer* extPlayer) { + m_pExtSoundPlayer = extPlayer; +} + } // namespace nn::atk::detail From fefd699f471933ba4867269ad0cd87f900a1f103 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 12:19:42 -0300 Subject: [PATCH 699/785] atk: Match `BasicSound::DetachExternalSoundPlayer` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index fe486da9..0e13ca41 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -793,4 +793,8 @@ void BasicSound::AttachExternalSoundPlayer(ExternalSoundPlayer* extPlayer) { m_pExtSoundPlayer = extPlayer; } +void BasicSound::DetachExternalSoundPlayer([[maybe_unused]] ExternalSoundPlayer* extPlayer) { + m_pExtSoundPlayer = nullptr; +} + } // namespace nn::atk::detail From 89fb43f9b22e6817bfa4d6a58244717e2ed0c369 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 12:20:46 -0300 Subject: [PATCH 700/785] atk: Match `BasicSound::AttachPlayerHeap` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 0e13ca41..9fa0f584 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -797,4 +797,8 @@ void BasicSound::DetachExternalSoundPlayer([[maybe_unused]] ExternalSoundPlayer* m_pExtSoundPlayer = nullptr; } +void BasicSound::AttachPlayerHeap(PlayerHeap* pHeap) { + m_pPlayerHeap = pHeap; +} + } // namespace nn::atk::detail From d207bec9100b212678b0f40effa29ad844c791ef Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 12:21:59 -0300 Subject: [PATCH 701/785] atk: Match `BasicSound::DetachPlayerHeap` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 9fa0f584..0736cfd3 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -801,4 +801,8 @@ void BasicSound::AttachPlayerHeap(PlayerHeap* pHeap) { m_pPlayerHeap = pHeap; } +void BasicSound::DetachPlayerHeap([[maybe_unused]] PlayerHeap* pHeap) { + m_pPlayerHeap = nullptr; +} + } // namespace nn::atk::detail From 4be8aea10accb4eb0eaaeb1a5e6d603ff9fe846a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 12:27:41 -0300 Subject: [PATCH 702/785] atk: Match `BasicSound::SetAmbientInfo` --- include/nn/atk/atk_BasicSound.h | 4 ++-- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index b9546f8d..f13b6594 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -289,7 +289,7 @@ class BasicSound { struct AmbientArgAllocatorCallback { virtual void Impl1(); virtual void Impl2(); - virtual void Impl3(); + virtual void* AllocateArgImpl(u64 argSize); virtual void RemoveSoundImpl(void* arg, BasicSound* sound); }; @@ -440,7 +440,7 @@ class BasicSound { void CalculateSoundParamCalculationValues(SoundParamCalculationValues* pOutValue) const; void SetId(u32 id); - + u32 GetId() const { return m_Id; } u32 GetInstanceId() const { return m_InstanceId; } u32 GetPlayFrameCount() const { return m_PlayingCounter; } diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 0736cfd3..9e0d3072 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -805,4 +805,14 @@ void BasicSound::DetachPlayerHeap([[maybe_unused]] PlayerHeap* pHeap) { m_pPlayerHeap = nullptr; } +void BasicSound::SetAmbientInfo(const AmbientInfo& ambientArgInfo) { + void* ambientArg{ambientArgInfo.argAllocatorCallback->AllocateArgImpl(ambientArgInfo.argSize)}; + + if (ambientArg != nullptr) { + std::memcpy(ambientArg, ambientArgInfo.arg, ambientArgInfo.argSize); + m_AmbientInfo = ambientArgInfo; + m_AmbientInfo.arg = ambientArg; + } +} + } // namespace nn::atk::detail From 41a32d16d9240d3578a26c112b7ca9eb1b7bca13 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 12:37:33 -0300 Subject: [PATCH 703/785] atk: Match `BasicSound::GetAmbientPriority` --- include/nn/atk/atk_BasicSound.h | 22 ++++++++++++++----- .../atk/detail/atk_BasicSound.cpp | 9 ++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index f13b6594..618eb641 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -284,8 +284,20 @@ class BasicSound { NN_ATK_RTTI_BASE(BasicSound); public: - struct AmbientParamUpdateCallback {}; - struct AmbientArgUpdateCallback {}; + struct AmbientParamUpdateCallback { + virtual void Impl1(); + virtual void Impl2(); + virtual void Impl3(); + virtual int GetPriority(void* arg, u32 soundId); + }; + + struct AmbientArgUpdateCallback { + virtual void Impl1(); + virtual void Impl2(); + virtual void Impl3(); + virtual void Impl4(); + }; + struct AmbientArgAllocatorCallback { virtual void Impl1(); virtual void Impl2(); @@ -471,9 +483,9 @@ class BasicSound { void SetAmbientInfo(const AmbientInfo& ambientArgInfo); - void ClearAmbientArgUpdateCallback(); - void ClearAmbientParamUpdateCallback(); - void ClearAmbientArgAllocatorCallback(); + void ClearAmbientArgUpdateCallback() { m_AmbientInfo.argUpdateCallback = nullptr; } + void ClearAmbientParamUpdateCallback() { m_AmbientInfo.paramUpdateCallback = nullptr; } + void ClearAmbientArgAllocatorCallback() { m_AmbientInfo.argAllocatorCallback = nullptr; } const SoundParam& GetAmbientParam() const { return m_AmbientParam; } diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 9e0d3072..1c1e56d2 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -815,4 +815,13 @@ void BasicSound::SetAmbientInfo(const AmbientInfo& ambientArgInfo) { } } +int BasicSound::GetAmbientPriority(const AmbientInfo& ambientInfo, u32 soundId) { + int priority{0}; + + if (ambientInfo.paramUpdateCallback != nullptr) + priority = ambientInfo.paramUpdateCallback->GetPriority(ambientInfo.arg, soundId); + + return priority; +} + } // namespace nn::atk::detail From 734433bbe53ba50b57ea4e0fe0839945e340ccfc Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 12:42:33 -0300 Subject: [PATCH 704/785] atk: Match `BasicSound::SetSoundArchive` --- include/nn/atk/atk_BasicSound.h | 2 +- .../atk/detail/atk_BasicSound.cpp | 76 ++++++++++--------- 2 files changed, 41 insertions(+), 37 deletions(-) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index 618eb641..342ab9a1 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -563,7 +563,7 @@ class BasicSound { SoundPlayer* m_pSoundPlayer; SoundActor* m_pSoundActor; ExternalSoundPlayer* m_pExtSoundPlayer; - SoundArchive* m_pSoundArchive; + const SoundArchive* m_pSoundArchive; AmbientInfo m_AmbientInfo; SoundParam m_AmbientParam; SoundActorParam m_ActorParam; diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 1c1e56d2..be7166bc 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -518,6 +518,38 @@ void BasicSound::ApplyCommonParam(OutputParam& param) const { param.send[i] += m_CommonParam.send[i]; } +void BasicSound::AttachPlayerHeap(PlayerHeap* pHeap) { + m_pPlayerHeap = pHeap; +} + +void BasicSound::DetachPlayerHeap([[maybe_unused]] PlayerHeap* pHeap) { + m_pPlayerHeap = nullptr; +} + +void BasicSound::AttachSoundPlayer(SoundPlayer* player) { + m_pSoundPlayer = player; +} + +void BasicSound::DetachSoundPlayer([[maybe_unused]] SoundPlayer* player) { + m_pSoundPlayer = nullptr; +} + +void BasicSound::AttachSoundActor(SoundActor* actor) { + m_pSoundActor = actor; +} + +void BasicSound::DetachSoundActor([[maybe_unused]] SoundActor* actor) { + m_pSoundActor = nullptr; +} + +void BasicSound::AttachExternalSoundPlayer(ExternalSoundPlayer* extPlayer) { + m_pExtSoundPlayer = extPlayer; +} + +void BasicSound::DetachExternalSoundPlayer([[maybe_unused]] ExternalSoundPlayer* extPlayer) { + m_pExtSoundPlayer = nullptr; +} + int BasicSound::GetRemainingFadeFrames() const { return m_FadeVolume.GetRemainingCount(); } @@ -769,42 +801,6 @@ void BasicSound::SetOutputAdditionalParamAddr(OutputDevice device, OutputAdditio } #endif -void BasicSound::SetSetupTick(const os::Tick& tick) { - m_SetupTick = tick; -} - -void BasicSound::AttachSoundPlayer(SoundPlayer* player) { - m_pSoundPlayer = player; -} - -void BasicSound::DetachSoundPlayer([[maybe_unused]] SoundPlayer* player) { - m_pSoundPlayer = nullptr; -} - -void BasicSound::AttachSoundActor(SoundActor* actor) { - m_pSoundActor = actor; -} - -void BasicSound::DetachSoundActor([[maybe_unused]] SoundActor* actor) { - m_pSoundActor = nullptr; -} - -void BasicSound::AttachExternalSoundPlayer(ExternalSoundPlayer* extPlayer) { - m_pExtSoundPlayer = extPlayer; -} - -void BasicSound::DetachExternalSoundPlayer([[maybe_unused]] ExternalSoundPlayer* extPlayer) { - m_pExtSoundPlayer = nullptr; -} - -void BasicSound::AttachPlayerHeap(PlayerHeap* pHeap) { - m_pPlayerHeap = pHeap; -} - -void BasicSound::DetachPlayerHeap([[maybe_unused]] PlayerHeap* pHeap) { - m_pPlayerHeap = nullptr; -} - void BasicSound::SetAmbientInfo(const AmbientInfo& ambientArgInfo) { void* ambientArg{ambientArgInfo.argAllocatorCallback->AllocateArgImpl(ambientArgInfo.argSize)}; @@ -824,4 +820,12 @@ int BasicSound::GetAmbientPriority(const AmbientInfo& ambientInfo, u32 soundId) return priority; } +void BasicSound::SetSetupTick(const os::Tick& tick) { + m_SetupTick = tick; +} + +void BasicSound::SetSoundArchive(const SoundArchive* soundArchive) { + m_pSoundArchive = soundArchive; +} + } // namespace nn::atk::detail From fc1e0e6fee321d8c00d72c89f38bf63d9900e19b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 12:47:13 -0300 Subject: [PATCH 705/785] atk: Match `BasicSound::UpdateMoveValue` --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index be7166bc..21fd6263 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -420,6 +420,12 @@ bool BasicSound::IsMute() const { } } +void BasicSound::UpdateMoveValue() { + m_FadeVolume.Update(); + m_MuteFadeVolume.Update(); + m_CommonParam.Update(); +} + float BasicSound::CalculateVolume() const { float volume{1.0f}; From 002a356846724730a5f10a62314aede9bb754338 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 13:09:01 -0300 Subject: [PATCH 706/785] atk: Match `BasicSound` destructor --- src/NintendoWare/atk/detail/atk_BasicSound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 21fd6263..fbdb7cd0 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -73,6 +73,10 @@ void SetSoundActorCalculationValues(SoundParamCalculationValues::SoundActorParam // NON_MATCHING on versions lower than 4.0.0 BasicSound::BasicSound() = default; +BasicSound::~BasicSound() { + m_State = State_Destructed; +} + // NON_MATCHING: bad order of instructions #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) bool BasicSound::Initialize() From 60c51517c312579c3a2b9f966286c188fa8c3996 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 13:16:19 -0300 Subject: [PATCH 707/785] atk: Match `BasicSound::ClearIsFinalizedForCannotAllocatedResourceFlag` --- include/nn/atk/atk_DriverCommand.h | 2 ++ .../atk/detail/atk_BasicSound.cpp | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/nn/atk/atk_DriverCommand.h b/include/nn/atk/atk_DriverCommand.h index 36066eec..0192eec5 100644 --- a/include/nn/atk/atk_DriverCommand.h +++ b/include/nn/atk/atk_DriverCommand.h @@ -22,6 +22,7 @@ enum DriverCommandId { DriverCommandId_PlayerStop, DriverCommandId_PlayerPause, DriverCommandId_PlayerParam, +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) DriverCommandId_PlayerAdditionalSend, DriverCommandId_PlayerBusMixVolumeUsed, DriverCommandId_PlayerBusMixVolume, @@ -29,6 +30,7 @@ enum DriverCommandId { DriverCommandId_PlayerBinaryVolume, DriverCommandId_PlayerVolumeThroughModeUsed, DriverCommandId_PlayerVolumeThroughMode, +#endif DriverCommandId_PlayerClearResourceFlag, DriverCommandId_SeqSetup, DriverCommandId_SeqLoad, diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index fbdb7cd0..ab8b1211 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -189,6 +189,18 @@ void BasicSound::GetPriority(int* priority, int* ambientPriority) const { *ambientPriority = m_AmbientParam.GetPriority(); } +void BasicSound::ClearIsFinalizedForCannotAllocatedResourceFlag() { + DriverCommand& cmdmgr{*DriverCommand::GetInstance()}; + + auto* command{cmdmgr.AllocCommand()}; + if (command == nullptr) + return; + + command->id = DriverCommandId_PlayerClearResourceFlag; + command->player = GetBasicSoundPlayerHandle(); + cmdmgr.PushCommand(command); +} + void BasicSound::Finalize() { if (m_State != State_Initialized) return; @@ -424,6 +436,14 @@ bool BasicSound::IsMute() const { } } +void BasicSound::Update() { + // TODO +} + +void BasicSound::UpdateParam() { + // TODO +} + void BasicSound::UpdateMoveValue() { m_FadeVolume.Update(); m_MuteFadeVolume.Update(); From c6af04c6106fe6e3be1bfc47177e1db636fb3a99 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 14:10:53 -0300 Subject: [PATCH 708/785] atk: Add inline functions for `BasicSoundPlayer` --- include/nn/atk/atk_BasicSoundPlayer.h | 98 ++++++++++++++++++++++++--- include/nn/atk/atk_StreamSound.h | 4 +- 2 files changed, 92 insertions(+), 10 deletions(-) diff --git a/include/nn/atk/atk_BasicSoundPlayer.h b/include/nn/atk/atk_BasicSoundPlayer.h index e357b731..79bfbc85 100644 --- a/include/nn/atk/atk_BasicSoundPlayer.h +++ b/include/nn/atk/atk_BasicSoundPlayer.h @@ -8,43 +8,123 @@ namespace nn::atk::detail::driver { struct PlayerParamSet { - void Initialize(); - - f32 volume; - f32 pitch; - f32 lpfFreq; - f32 biquadValue; + float volume; + float pitch; + float lpfFreq; + float biquadValue; s8 biquadType; PanMode panMode; PanCurve panCurve; u32 outputLineFlag; OutputParam tvParam; + + PlayerParamSet() { + Initialize(); + } + + void Initialize() { + tvParam.Initialize(); + } }; static_assert(sizeof(PlayerParamSet) == 0x70); class BasicSoundPlayer { public: + BasicSoundPlayer(); virtual ~BasicSoundPlayer(); + #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) virtual bool Initialize(); #else virtual bool Initialize(OutputReceiver* pOutputReceiver); #endif virtual void Finalize(); + virtual void Start() = 0; virtual void Stop() = 0; virtual void Pause(bool isPauseEnabled) = 0; - BasicSoundPlayer(); + bool IsActive() const { return m_ActiveFlag; } + bool IsStarted() const { return m_StartedFlag; } + bool IsPause() const { return m_PauseFlag; } + bool IsPlayFinished() const { return m_FinishFlag; } + bool IsFinalizedForCannotAllocateResource() const { + return m_IsFinalizedForCannotAllocateResource; + } + + void SetVolume(float volume) { m_PlayerParamSet.volume = volume; } + void SetPitch(float pitch) { m_PlayerParamSet.pitch = pitch; } + void SetLpfFreq(float lpfFreq) { m_PlayerParamSet.lpfFreq = lpfFreq; } + void SetBiquadFilter(int type, float value); + void SetPanMode(PanMode mode) { m_PlayerParamSet.panMode = mode; } + void SetPanCurve(PanCurve curve) { m_PlayerParamSet.panCurve = curve; } + + float GetVolume() const { return m_PlayerParamSet.volume; } + float GetPitch() const { return m_PlayerParamSet.pitch; } + float GetLpfFreq() const { return m_PlayerParamSet.lpfFreq; } + int GetBiquadFilterType() const { return m_PlayerParamSet.biquadType; } + float GetBiquadFilterValue() const { return m_PlayerParamSet.biquadValue; } + PanMode GetPanMode() const { return m_PlayerParamSet.panMode; } + PanCurve GetPanCurve() const { return m_PlayerParamSet.panCurve; } - void SetBiquadFilter(s32 type, f32 value); + void SetOutputLine(u32 outputLineFlag) { m_PlayerParamSet.outputLineFlag = outputLineFlag; } + u32 GetOutputLine() const { return m_PlayerParamSet.outputLineFlag; } + + void SetTvParam(const OutputParam& param) { m_PlayerParamSet.tvParam = param; } + const OutputParam& GetTvParam() const { return m_PlayerParamSet.tvParam; } #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) void SetTvAdditionalParamAddr(OutputAdditionalParam* pParam) { m_pTvAdditionalParam = pParam; } + + const OutputAdditionalParam* GetTvAdditionalParamAddr() const { + return m_pTvAdditionalParam; + }; + + void SetTvAdditionalSend(int bus, float send); + void SetTvBusMixVolumeUsed(bool isUsed); + void SetTvBusMixVolume(const OutputBusMixVolume& busMixVolume); + void SetTvBusMixVolumeEnabled(int bus, bool isEnabled); + void SetTvBinaryVolume(float volume); + void SetTvVolumeThroughModeUsed(bool isVolumeThroughModeEnabled); + void SetTvVolumeThroughMode(int bus, u8 volumeThroughMode); + void SetTvAdditionalParam(const OutputAdditionalParam& param) { + *m_pTvAdditionalParam = param; + }; #endif + bool TryWaitInstanceFree() { return m_Event.TryWait(); } + void WaitInstanceFree() { m_Event.Wait(); } + void InitializeEvent() { m_Event.Clear(); } + const PlayerHeapDataManager* GetPlayerHeapDataManager() const { + return m_pPlayerHeapDataManager; + } + + void ClearIsFinalizedForCannotAllocatedResourceFlag() { + m_IsFinalizedForCannotAllocateResource = false; + } + +protected: + void SetPlayerHeapDataManagerImpl(const PlayerHeapDataManager* mgr) { + m_pPlayerHeapDataManager = mgr; + } + + s32 ToDelayCount(s32 delayTimeMilliSec) { return delayTimeMilliSec / 5; }; + + void SetActiveFlag(bool isActive) { m_ActiveFlag = isActive; } + void SetStartedFlag(bool isStarted) { m_StartedFlag = isStarted; } + void SetPauseFlag(bool isPauseEnabled) { m_PauseFlag = isPauseEnabled; } + void SetFinishFlag(bool isPlayFinished) { m_FinishFlag = isPlayFinished; } + + void SetFinalizedForCannotAllocateResourceFlag(bool flag) { + m_IsFinalizedForCannotAllocateResource = flag; + } + +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) + OutputReceiver* GetOutputReceiver() { return m_pOutputReceiver; } +#endif + private: os::Event m_Event; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) @@ -59,7 +139,7 @@ class BasicSoundPlayer { #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) OutputAdditionalParam* m_pTvAdditionalParam; #endif - PlayerHeapDataManager* m_pPlayerHeapDataManager; + const PlayerHeapDataManager* m_pPlayerHeapDataManager; }; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) static_assert(sizeof(BasicSoundPlayer) == 0xb0); diff --git a/include/nn/atk/atk_StreamSound.h b/include/nn/atk/atk_StreamSound.h index 724a0815..0021c364 100644 --- a/include/nn/atk/atk_StreamSound.h +++ b/include/nn/atk/atk_StreamSound.h @@ -9,7 +9,9 @@ namespace nn::atk::detail { class StreamSound; using StreamSoundInstanceManager = SoundInstanceManager; -class StreamSound : BasicSound { +class StreamSound : public BasicSound { + NN_ATK_RTTI_OVERRIDE(StreamSound, BasicSound); + public: explicit StreamSound(const StreamSoundInstanceManager& manager); From 21b5fcb002a73571e951a99e7a40dfb572f61ccc Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 17:44:49 -0300 Subject: [PATCH 709/785] atk: Match `BasicSoundPlayer` constructor --- include/nn/atk/atk_BasicSoundPlayer.h | 22 +++++++++++++------ .../atk/detail/atk_BasicSound.cpp | 8 ------- .../atk/detail/atk_BasicSoundPlayer.cpp | 8 +++++++ 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/include/nn/atk/atk_BasicSoundPlayer.h b/include/nn/atk/atk_BasicSoundPlayer.h index 79bfbc85..1ad22787 100644 --- a/include/nn/atk/atk_BasicSoundPlayer.h +++ b/include/nn/atk/atk_BasicSoundPlayer.h @@ -23,6 +23,14 @@ struct PlayerParamSet { } void Initialize() { + volume = 1.0f; + pitch = 1.0f; + lpfFreq = 0.0f; + biquadValue = 0.0f; + biquadType = BiquadFilterType_Inherit; + panMode = PanMode_Dual; + panCurve = PanCurve_Sqrt; + outputLineFlag = 1; tvParam.Initialize(); } }; @@ -128,16 +136,16 @@ class BasicSoundPlayer { private: os::Event m_Event; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) - OutputReceiver* m_pOutputReceiver; + OutputReceiver* m_pOutputReceiver{}; #endif - bool m_ActiveFlag; - bool m_StartedFlag; - bool m_PauseFlag; - bool m_FinishFlag; - bool m_IsFinalizedForCannotAllocateResource; + bool m_ActiveFlag{false}; + bool m_StartedFlag{false}; + bool m_PauseFlag{false}; + bool m_FinishFlag{false}; + bool m_IsFinalizedForCannotAllocateResource{false}; PlayerParamSet m_PlayerParamSet; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) - OutputAdditionalParam* m_pTvAdditionalParam; + OutputAdditionalParam* m_pTvAdditionalParam{}; #endif const PlayerHeapDataManager* m_pPlayerHeapDataManager; }; diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index ab8b1211..885bd053 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -436,14 +436,6 @@ bool BasicSound::IsMute() const { } } -void BasicSound::Update() { - // TODO -} - -void BasicSound::UpdateParam() { - // TODO -} - void BasicSound::UpdateMoveValue() { m_FadeVolume.Update(); m_MuteFadeVolume.Update(); diff --git a/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp b/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp index 8b137891..168bcf36 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp @@ -1 +1,9 @@ +#include +namespace nn::atk::detail::driver { + +BasicSoundPlayer::BasicSoundPlayer() : m_Event(os::EventClearMode_ManualClear) { + m_Event.Signal(); +} + +} // namespace nn::atk::detail::driver From 456340229a101ebc6bfca6c7d5118fc91a566dd6 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 17:53:05 -0300 Subject: [PATCH 710/785] atk: Match `BasicSoundPlayer::Initialize` --- include/nn/atk/atk_BasicSoundPlayer.h | 4 ++-- include/nn/atk/atk_SequenceSoundPlayer.h | 4 ++-- include/nn/atk/atk_StreamSoundPlayer.h | 4 ++-- include/nn/atk/atk_WaveSoundPlayer.h | 4 ++-- .../atk/detail/atk_AdvancedWaveSoundPlayer.h | 4 ++-- .../atk/detail/atk_BasicSoundPlayer.cpp | 19 +++++++++++++++++++ 6 files changed, 29 insertions(+), 10 deletions(-) diff --git a/include/nn/atk/atk_BasicSoundPlayer.h b/include/nn/atk/atk_BasicSoundPlayer.h index 1ad22787..bc07a5a9 100644 --- a/include/nn/atk/atk_BasicSoundPlayer.h +++ b/include/nn/atk/atk_BasicSoundPlayer.h @@ -42,9 +42,9 @@ class BasicSoundPlayer { virtual ~BasicSoundPlayer(); #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) - virtual bool Initialize(); + virtual void Initialize(); #else - virtual bool Initialize(OutputReceiver* pOutputReceiver); + virtual void Initialize(OutputReceiver* pOutputReceiver); #endif virtual void Finalize(); diff --git a/include/nn/atk/atk_SequenceSoundPlayer.h b/include/nn/atk/atk_SequenceSoundPlayer.h index 264d81b1..ce785e32 100644 --- a/include/nn/atk/atk_SequenceSoundPlayer.h +++ b/include/nn/atk/atk_SequenceSoundPlayer.h @@ -184,9 +184,9 @@ class SequenceSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::Play ~SequenceSoundPlayer() override; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) - bool Initialize() override; + void Initialize() override; #else - bool Initialize(OutputReceiver* pOutputReceiver) override; + void Initialize(OutputReceiver* pOutputReceiver) override; #endif void Finalize() override; diff --git a/include/nn/atk/atk_StreamSoundPlayer.h b/include/nn/atk/atk_StreamSoundPlayer.h index 08ee2407..192c45d5 100644 --- a/include/nn/atk/atk_StreamSoundPlayer.h +++ b/include/nn/atk/atk_StreamSoundPlayer.h @@ -151,9 +151,9 @@ class StreamSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { ~StreamSoundPlayer() override; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) - bool Initialize() override; + void Initialize() override; #else - bool Initialize(OutputReceiver* pOutputReceiver) override; + void Initialize(OutputReceiver* pOutputReceiver) override; #endif bool TryAllocLoader(); diff --git a/include/nn/atk/atk_WaveSoundPlayer.h b/include/nn/atk/atk_WaveSoundPlayer.h index fa7ef90e..c2e7a01a 100644 --- a/include/nn/atk/atk_WaveSoundPlayer.h +++ b/include/nn/atk/atk_WaveSoundPlayer.h @@ -65,9 +65,9 @@ class WaveSoundPlayer : BasicSoundPlayer, DisposeCallback, SoundThread::PlayerCa ~WaveSoundPlayer() override; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) - bool Initialize() override; + void Initialize() override; #else - bool Initialize(OutputReceiver* pOutputReceiver) override; + void Initialize(OutputReceiver* pOutputReceiver) override; #endif void Finalize() override; diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h b/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h index b3262710..153786eb 100644 --- a/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h +++ b/include/nn/atk/detail/atk_AdvancedWaveSoundPlayer.h @@ -51,9 +51,9 @@ class AdvancedWaveSoundPlayer : BasicSoundPlayer, SoundThread::PlayerCallback { ~AdvancedWaveSoundPlayer() override; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) - bool Initialize() override; + void Initialize() override; #else - bool Initialize(OutputReceiver* pOutputReceiver) override; + void Initialize(OutputReceiver* pOutputReceiver) override; #endif void Finalize() override; diff --git a/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp b/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp index 168bcf36..ab919ac3 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp @@ -5,5 +5,24 @@ namespace nn::atk::detail::driver { BasicSoundPlayer::BasicSoundPlayer() : m_Event(os::EventClearMode_ManualClear) { m_Event.Signal(); } +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) +void BasicSoundPlayer::Initialize() +#else +void BasicSoundPlayer::Initialize(OutputReceiver* pOutputReceiver) +#endif +{ + m_ActiveFlag = false; + m_StartedFlag = false; + m_PauseFlag = false; + m_FinishFlag = false; + m_IsFinalizedForCannotAllocateResource = false; + +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) + m_pOutputReceiver = pOutputReceiver; +#endif + + m_PlayerParamSet.Initialize(); + m_pPlayerHeapDataManager = nullptr; +} } // namespace nn::atk::detail::driver From ee437b0bfb85ab5b889e5dd752799057ff2c6c2f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 17:55:47 -0300 Subject: [PATCH 711/785] atk: Match `BasicSoundPlayer::Finalize` --- .../atk/detail/atk_BasicSoundPlayer.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp b/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp index ab919ac3..c4df240a 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp @@ -1,5 +1,7 @@ #include +#include + namespace nn::atk::detail::driver { BasicSoundPlayer::BasicSoundPlayer() : m_Event(os::EventClearMode_ManualClear) { @@ -25,4 +27,15 @@ void BasicSoundPlayer::Initialize(OutputReceiver* pOutputReceiver) m_pPlayerHeapDataManager = nullptr; } +void BasicSoundPlayer::Finalize() { +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) + if (m_pOutputReceiver != nullptr) { + m_pOutputReceiver->AddReferenceCount(-1); + m_pOutputReceiver = nullptr; + } +#endif + + m_Event.Signal(); +} + } // namespace nn::atk::detail::driver From 27fed42a6c4a8fe6eca2daa3342133c0d0b50b41 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 17:58:10 -0300 Subject: [PATCH 712/785] atk: Match `BasicSoundPlayer::SetBiquadFilter` --- include/nn/atk/atk_BasicSoundPlayer.h | 1 + src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/nn/atk/atk_BasicSoundPlayer.h b/include/nn/atk/atk_BasicSoundPlayer.h index bc07a5a9..e994cc52 100644 --- a/include/nn/atk/atk_BasicSoundPlayer.h +++ b/include/nn/atk/atk_BasicSoundPlayer.h @@ -95,6 +95,7 @@ class BasicSoundPlayer { void SetTvBinaryVolume(float volume); void SetTvVolumeThroughModeUsed(bool isVolumeThroughModeEnabled); void SetTvVolumeThroughMode(int bus, u8 volumeThroughMode); + void SetTvAdditionalParam(const OutputAdditionalParam& param) { *m_pTvAdditionalParam = param; }; diff --git a/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp b/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp index c4df240a..136617e0 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp @@ -7,6 +7,7 @@ namespace nn::atk::detail::driver { BasicSoundPlayer::BasicSoundPlayer() : m_Event(os::EventClearMode_ManualClear) { m_Event.Signal(); } + #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) void BasicSoundPlayer::Initialize() #else @@ -38,4 +39,9 @@ void BasicSoundPlayer::Finalize() { m_Event.Signal(); } +void BasicSoundPlayer::SetBiquadFilter(int type, float value) { + m_PlayerParamSet.biquadType = type; + m_PlayerParamSet.biquadValue = value; +} + } // namespace nn::atk::detail::driver From a2ef4dc4946e3a9900d66160b30001fad3b2ac72 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 17:58:40 -0300 Subject: [PATCH 713/785] atk: Match `BasicSoundPlayer` destructor --- include/nn/atk/atk_BasicSoundPlayer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/nn/atk/atk_BasicSoundPlayer.h b/include/nn/atk/atk_BasicSoundPlayer.h index e994cc52..876ee14a 100644 --- a/include/nn/atk/atk_BasicSoundPlayer.h +++ b/include/nn/atk/atk_BasicSoundPlayer.h @@ -39,7 +39,7 @@ static_assert(sizeof(PlayerParamSet) == 0x70); class BasicSoundPlayer { public: BasicSoundPlayer(); - virtual ~BasicSoundPlayer(); + virtual ~BasicSoundPlayer() = default; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) virtual void Initialize(); From d741afc80b676e0fa847a46ddbb40feb90ce5221 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 18:06:37 -0300 Subject: [PATCH 714/785] atk: Match `DisposeCallbackManager::GetInstance` --- include/nn/atk/atk_DisposeCallbackManager.h | 8 ++++---- .../atk/detail/atk_DisposeCallbackManager.cpp | 11 +++++++++++ src/NintendoWare/atk/detail/voice/atk_Channel.cpp | 4 ++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/nn/atk/atk_DisposeCallbackManager.h b/include/nn/atk/atk_DisposeCallbackManager.h index 0f7a4c54..eb95b60b 100644 --- a/include/nn/atk/atk_DisposeCallbackManager.h +++ b/include/nn/atk/atk_DisposeCallbackManager.h @@ -12,17 +12,17 @@ class DisposeCallbackManager { DisposeCallback, util::IntrusiveListMemberNodeTraits>; + static DisposeCallbackManager& GetInstance(); + DisposeCallbackManager(); + void Dispose(const void* mem, size_t size); + void RegisterDisposeCallback(DisposeCallback* callback); void UnregisterDisposeCallback(DisposeCallback* callback); u64 GetCallbackCount() const; - void Dispose(const void* mem, size_t size); - - static DisposeCallbackManager* GetInstance(); - private: CallbackList m_CallbackList; }; diff --git a/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp b/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp index 8b137891..a64f5520 100644 --- a/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp +++ b/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp @@ -1 +1,12 @@ +#include +namespace nn::atk::detail::driver { + +DisposeCallbackManager& DisposeCallbackManager::GetInstance() { + static DisposeCallbackManager instance; + return instance; +} + +DisposeCallbackManager::DisposeCallbackManager() = default; + +} // namespace nn::atk::detail::driver diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index 950f4ade..dc6269b7 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -100,11 +100,11 @@ void Channel::VoiceCallbackFunc(MultiVoice* voice, MultiVoice::VoiceCallbackStat Channel::Channel() { m_Disposer.Initialize(this); - DisposeCallbackManager::GetInstance()->RegisterDisposeCallback(&m_Disposer); + DisposeCallbackManager::GetInstance().RegisterDisposeCallback(&m_Disposer); } Channel::~Channel() { - DisposeCallbackManager::GetInstance()->UnregisterDisposeCallback(&m_Disposer); + DisposeCallbackManager::GetInstance().UnregisterDisposeCallback(&m_Disposer); } void Channel::CallChannelCallback(ChannelCallbackStatus status) { From 509f7237318e2d5603affa12ca44afe0994a95c3 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 18:33:57 -0300 Subject: [PATCH 715/785] atk: Match `DisposeCallbackManager::RegisterDisposeCallback` --- include/nn/atk/atk_DisposeCallbackManager.h | 3 +- include/nn/util/util_IntrusiveList.h | 79 +++++++++++++++---- .../atk/detail/atk_DisposeCallbackManager.cpp | 16 ++++ 3 files changed, 81 insertions(+), 17 deletions(-) diff --git a/include/nn/atk/atk_DisposeCallbackManager.h b/include/nn/atk/atk_DisposeCallbackManager.h index eb95b60b..2f4ec094 100644 --- a/include/nn/atk/atk_DisposeCallbackManager.h +++ b/include/nn/atk/atk_DisposeCallbackManager.h @@ -14,7 +14,6 @@ class DisposeCallbackManager { static DisposeCallbackManager& GetInstance(); - DisposeCallbackManager(); void Dispose(const void* mem, size_t size); @@ -22,6 +21,8 @@ class DisposeCallbackManager { void UnregisterDisposeCallback(DisposeCallback* callback); u64 GetCallbackCount() const; + + DisposeCallbackManager(); private: CallbackList m_CallbackList; diff --git a/include/nn/util/util_IntrusiveList.h b/include/nn/util/util_IntrusiveList.h index ae5d30e9..e62a0eb2 100644 --- a/include/nn/util/util_IntrusiveList.h +++ b/include/nn/util/util_IntrusiveList.h @@ -78,7 +78,7 @@ class IntrusiveListImplementation { reference operator*() const { return *m_Node; } - pointer operator->() const; + pointer operator->() const { return m_Node; } const_iterator& operator++() { m_Node = m_Node->GetNext(); @@ -91,9 +91,19 @@ class IntrusiveListImplementation { return temporary; } - const_iterator& operator--(); - const_iterator operator--(int); - bool operator==(const const_iterator&) const; + const_iterator& operator--() { + m_Node = m_Node->GetPrev(); + return *this; + } + + const_iterator operator--(int) { + const_iterator temporary(*this); + --(*this); + return temporary; + } + + bool operator==(const const_iterator& ci) const { return m_Node == ci.m_Node; } + bool operator!=(const const_iterator& ci) const { return m_Node != ci.m_Node; } private: @@ -126,9 +136,18 @@ class IntrusiveListImplementation { return temporary; } - iterator& operator--(); - iterator operator--(int); - bool operator==(const iterator&) const; + iterator& operator--() { + m_Node = m_Node->GetPrev(); + return *this; + } + + iterator operator--(int) { + iterator temporary(*this); + --(*this); + return temporary; + } + + bool operator==(const iterator& i) const { return m_Node == i.m_Node; } bool operator!=(const iterator& i) const { return m_Node != i.m_Node; } @@ -222,12 +241,31 @@ class IntrusiveList { reference operator*() const; pointer operator->() const; - const_iterator& operator++(); - const_iterator operator++(int); - const_iterator& operator--(); - const_iterator operator--(int); - bool operator==(const const_iterator&) const; - bool operator!=(const const_iterator&) const; + + const_iterator& operator++() { + ++m_Iterator; + return *this; + } + + const_iterator operator++(int) { + iterator temporary(*this); + ++m_Iterator; + return temporary; + } + + const_iterator& operator--() { + --m_Iterator; + return *this; + } + + const_iterator operator--(int) { + iterator temporary(*this); + --m_Iterator; + return temporary; + } + + bool operator==(const const_iterator& ci) const { return m_Iterator == ci.m_Iterator; } + bool operator!=(const const_iterator& ci) const { return !(*this == ci); } private: friend class IntrusiveList; @@ -268,9 +306,18 @@ class IntrusiveList { return temporary; } - iterator& operator--(); - iterator operator--(int); - bool operator==(const iterator&) const; + iterator& operator--() { + --m_Iterator; + return *this; + } + + iterator operator--(int) { + iterator temporary(*this); + --m_Iterator; + return temporary; + } + + bool operator==(const iterator& i) const { return m_Iterator == i.m_Iterator; } bool operator!=(const iterator& i) const { return m_Iterator != i.m_Iterator; } diff --git a/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp b/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp index a64f5520..6c913776 100644 --- a/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp +++ b/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp @@ -9,4 +9,20 @@ DisposeCallbackManager& DisposeCallbackManager::GetInstance() { DisposeCallbackManager::DisposeCallbackManager() = default; +void DisposeCallbackManager::RegisterDisposeCallback(DisposeCallback* callback) { + m_CallbackList.push_back(*callback); +} + +// NON_MATCHING +void DisposeCallbackManager::Dispose(const void* mem, size_t size) { + const void* start{mem}; + const void* end{reinterpret_cast(reinterpret_cast(mem) + size)}; + + for (auto itr{GetInstance().m_CallbackList.begin()}; itr != GetInstance().m_CallbackList.end();) { + auto curItr{itr++}; + curItr->InvalidateData(start, end); + } +} + + } // namespace nn::atk::detail::driver From 4bc053db8dd7b372bff776ccd0ec8bd378ccffac Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 18:35:28 -0300 Subject: [PATCH 716/785] atk: Match `DisposeCallbackManager::UnregisterDisposeCallback` --- src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp b/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp index 6c913776..ba8d10f5 100644 --- a/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp +++ b/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp @@ -13,6 +13,10 @@ void DisposeCallbackManager::RegisterDisposeCallback(DisposeCallback* callback) m_CallbackList.push_back(*callback); } +void DisposeCallbackManager::UnregisterDisposeCallback(DisposeCallback* callback) { + m_CallbackList.erase(m_CallbackList.iterator_to(*callback)); +} + // NON_MATCHING void DisposeCallbackManager::Dispose(const void* mem, size_t size) { const void* start{mem}; From 9face133b9b13d30a51b4266f9bd25e6d95fe0b1 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 18:37:54 -0300 Subject: [PATCH 717/785] atk: Match `DisposeCallbackManager::GetCallbackCount` --- include/nn/atk/atk_DisposeCallbackManager.h | 3 +-- src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_DisposeCallbackManager.h b/include/nn/atk/atk_DisposeCallbackManager.h index 2f4ec094..f04a34ee 100644 --- a/include/nn/atk/atk_DisposeCallbackManager.h +++ b/include/nn/atk/atk_DisposeCallbackManager.h @@ -14,14 +14,13 @@ class DisposeCallbackManager { static DisposeCallbackManager& GetInstance(); - void Dispose(const void* mem, size_t size); void RegisterDisposeCallback(DisposeCallback* callback); void UnregisterDisposeCallback(DisposeCallback* callback); u64 GetCallbackCount() const; - + DisposeCallbackManager(); private: diff --git a/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp b/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp index ba8d10f5..87cdcc63 100644 --- a/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp +++ b/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp @@ -17,6 +17,10 @@ void DisposeCallbackManager::UnregisterDisposeCallback(DisposeCallback* callback m_CallbackList.erase(m_CallbackList.iterator_to(*callback)); } +u64 DisposeCallbackManager::GetCallbackCount() const { + return m_CallbackList.size(); +} + // NON_MATCHING void DisposeCallbackManager::Dispose(const void* mem, size_t size) { const void* start{mem}; From 165ee9a578901491b212e2aa793fa485e49f5b6d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 18:43:09 -0300 Subject: [PATCH 718/785] atk: Match `DisposeCallbackManager::Dispose` --- include/nn/atk/atk_DisposeCallbackManager.h | 4 +++- src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/nn/atk/atk_DisposeCallbackManager.h b/include/nn/atk/atk_DisposeCallbackManager.h index f04a34ee..cc7f353a 100644 --- a/include/nn/atk/atk_DisposeCallbackManager.h +++ b/include/nn/atk/atk_DisposeCallbackManager.h @@ -12,7 +12,9 @@ class DisposeCallbackManager { DisposeCallback, util::IntrusiveListMemberNodeTraits>; - static DisposeCallbackManager& GetInstance(); + // TODO: Maybe there's a better way to prevent inlining. Needed to match + // DisposeCallbackManager::Dispose + __attribute__((noinline)) static DisposeCallbackManager& GetInstance(); void Dispose(const void* mem, size_t size); diff --git a/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp b/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp index 87cdcc63..569f352f 100644 --- a/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp +++ b/src/NintendoWare/atk/detail/atk_DisposeCallbackManager.cpp @@ -21,16 +21,15 @@ u64 DisposeCallbackManager::GetCallbackCount() const { return m_CallbackList.size(); } -// NON_MATCHING void DisposeCallbackManager::Dispose(const void* mem, size_t size) { const void* start{mem}; const void* end{reinterpret_cast(reinterpret_cast(mem) + size)}; - for (auto itr{GetInstance().m_CallbackList.begin()}; itr != GetInstance().m_CallbackList.end();) { + for (auto itr{GetInstance().m_CallbackList.begin()}; + itr != GetInstance().m_CallbackList.end();) { auto curItr{itr++}; curItr->InvalidateData(start, end); } } - } // namespace nn::atk::detail::driver From dfa6205fcf6a6b47097217bd012d7546e2c8d9ba Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 18:53:21 -0300 Subject: [PATCH 719/785] atk: Match `ExternalSoundPlayer` constructor --- include/nn/atk/atk_ExternalSoundPlayer.h | 27 ++++++++++--------- .../atk/detail/atk_ExternalSoundPlayer.cpp | 6 +++++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/include/nn/atk/atk_ExternalSoundPlayer.h b/include/nn/atk/atk_ExternalSoundPlayer.h index e17feb6b..2b1c042a 100644 --- a/include/nn/atk/atk_ExternalSoundPlayer.h +++ b/include/nn/atk/atk_ExternalSoundPlayer.h @@ -12,29 +12,32 @@ class ExternalSoundPlayer { BasicSound, util::IntrusiveListMemberNodeTraits>; + ExternalSoundPlayer(); virtual ~ExternalSoundPlayer(); - virtual bool CanPlaySound(s32); - ExternalSoundPlayer(); + void StopAllSound(int fadeFrames); - void StopAllSound(s32 fadeFrames); - void PauseAllSound(bool, s32); - void PauseAllSound(bool, s32, PauseMode); + void PauseAllSound(bool flag, int fadeFrames); + void PauseAllSound(bool flag, int fadeFrames, PauseMode pauseMode); - void Finalize(SoundActor* actor); + int GetPlayingSoundCount() const { return m_SoundList.size(); } - void RemoveSound(BasicSound* sound); - bool AppendSound(BasicSound* sound); + void SetPlayableSoundCount(int count); + int GetPlayableSoundCount() const { return m_PlayableCount; } - BasicSound* GetLowestPrioritySound(); + virtual bool CanPlaySound(int startPriority); - void SetPlayableSoundCount(s32 count); + bool AppendSound(BasicSound* sound); + void RemoveSound(BasicSound* sound); - bool CanPlaySound(); + void Finalize(SoundActor* actor); + +protected: + BasicSound* GetLowestPrioritySound(); private: SoundList m_SoundList; - s32 m_PlayableCount; + int m_PlayableCount{1}; }; static_assert(sizeof(ExternalSoundPlayer) == 0x20); diff --git a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp index 8b137891..af2e96b8 100644 --- a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp +++ b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp @@ -1 +1,7 @@ +#include +namespace nn::atk::detail { + +ExternalSoundPlayer::ExternalSoundPlayer() = default; + +} // namespace nn::atk::detail From 0bada200f1bba0ef7b527e23cd83572ff3f8f62b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 19:00:39 -0300 Subject: [PATCH 720/785] atk: Match `ExternalSoundPlayer` destructor --- src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp index af2e96b8..1eae5bab 100644 --- a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp +++ b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp @@ -4,4 +4,11 @@ namespace nn::atk::detail { ExternalSoundPlayer::ExternalSoundPlayer() = default; +ExternalSoundPlayer::~ExternalSoundPlayer() { + for (auto itr{m_SoundList.begin()}; itr != m_SoundList.end();) { + auto curItr{itr++}; + curItr->DetachExternalSoundPlayer(this); + } +} + } // namespace nn::atk::detail From a3e6f66ea8f04dc8c97003423713ae54179ba790 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 19:02:11 -0300 Subject: [PATCH 721/785] atk: Match `ExternalSoundPlayer::StopAllSound` --- src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp index 1eae5bab..f6a14530 100644 --- a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp +++ b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp @@ -11,4 +11,11 @@ ExternalSoundPlayer::~ExternalSoundPlayer() { } } +void ExternalSoundPlayer::StopAllSound(int fadeFrames) { + for (auto itr{m_SoundList.begin()}; itr != m_SoundList.end();) { + auto curItr{itr++}; + curItr->Stop(fadeFrames); + } +} + } // namespace nn::atk::detail From 586cc23cb647c21a578e321a9eae98a5157eeae5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 19:02:57 -0300 Subject: [PATCH 722/785] atk: Match `ExternalSoundPlayer::PauseAllSound` --- .../atk/detail/atk_ExternalSoundPlayer.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp index f6a14530..5e8e289a 100644 --- a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp +++ b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp @@ -18,4 +18,18 @@ void ExternalSoundPlayer::StopAllSound(int fadeFrames) { } } +void ExternalSoundPlayer::PauseAllSound(bool flag, int fadeFrames) { + for (auto itr{m_SoundList.begin()}; itr != m_SoundList.end();) { + auto curItr{itr++}; + curItr->Pause(flag, fadeFrames); + } +} + +void ExternalSoundPlayer::PauseAllSound(bool flag, int fadeFrames, PauseMode pauseMode) { + for (auto itr{m_SoundList.begin()}; itr != m_SoundList.end();) { + auto curItr{itr++}; + curItr->Pause(flag, fadeFrames, pauseMode); + } +} + } // namespace nn::atk::detail From fff61a39448b6040f6462b2b749609b700a837d4 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 20:23:10 -0300 Subject: [PATCH 723/785] atk: Match `ExternalSoundPlayer::GetLowestPrioritySound` --- include/nn/atk/atk_BasicSound.h | 4 +++- .../atk/detail/atk_ExternalSoundPlayer.cpp | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index 342ab9a1..76ab1f89 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -460,7 +460,9 @@ class BasicSound { void SetSetupTick(const os::Tick& tick); os::Tick GetSetupTick() const { return m_SetupTick; } - int CalcCurrentPlayerPriority() const { return fnd::Clamp(GetPlayerPriority(), 0, 127); } + int CalcCurrentPlayerPriority() const { + return fnd::Clamp(GetPlayerPriority(), PlayerPriorityMin, PlayerPriorityMax); + } SoundPlayer* GetSoundPlayer() { return m_pSoundPlayer; } const SoundPlayer* GetSoundPlayer() const { return m_pSoundPlayer; } diff --git a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp index 5e8e289a..580732f4 100644 --- a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp +++ b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp @@ -32,4 +32,21 @@ void ExternalSoundPlayer::PauseAllSound(bool flag, int fadeFrames, PauseMode pau } } +BasicSound* ExternalSoundPlayer::GetLowestPrioritySound() { + if (m_SoundList.empty()) + return nullptr; + + int priority{PlayerPriorityMax + 1}; + BasicSound* sound{}; + + for (auto itr{m_SoundList.begin()}; itr != m_SoundList.end(); ++itr) { + int itrPriority{itr->CalcCurrentPlayerPriority()}; + + sound = priority > itrPriority ? &*itr : sound; + priority = priority > itrPriority ? itrPriority : priority; + } + + return sound; +} + } // namespace nn::atk::detail From 25be50af797e7a2cd58ad78ebdb183e1102f4207 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 20:52:47 -0300 Subject: [PATCH 724/785] atk: Match `ExternalSoundPlayer::SetPlayableSoundCount` --- src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp index 580732f4..f5d7c7f5 100644 --- a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp +++ b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp @@ -32,6 +32,15 @@ void ExternalSoundPlayer::PauseAllSound(bool flag, int fadeFrames, PauseMode pau } } +void ExternalSoundPlayer::SetPlayableSoundCount(int count) { + m_PlayableCount = count; + + while (GetPlayingSoundCount() > GetPlayableSoundCount()) { + BasicSound* dropSound{GetLowestPrioritySound()}; + dropSound->Finalize(); + } +} + BasicSound* ExternalSoundPlayer::GetLowestPrioritySound() { if (m_SoundList.empty()) return nullptr; From 2918d785468ebe69442aa3040b076c571caf10fe Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 21:01:08 -0300 Subject: [PATCH 725/785] atk: Match `ExternalSoundPlayer::CanPlaySound` --- .../atk/detail/atk_ExternalSoundPlayer.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp index f5d7c7f5..b618a016 100644 --- a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp +++ b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp @@ -41,6 +41,23 @@ void ExternalSoundPlayer::SetPlayableSoundCount(int count) { } } +bool ExternalSoundPlayer::CanPlaySound(int startPriority) { + if (GetPlayableSoundCount() == 0) + return false; + + if (GetPlayingSoundCount() >= GetPlayableSoundCount()) { + BasicSound* dropSound{GetLowestPrioritySound()}; + + if (dropSound == nullptr) + return false; + + if (startPriority < dropSound->CalcCurrentPlayerPriority()) + return false; + } + + return true; +} + BasicSound* ExternalSoundPlayer::GetLowestPrioritySound() { if (m_SoundList.empty()) return nullptr; From 7b8bc20ecc978368ed8c0cd0c2f33c4e1b5b5506 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 21:06:06 -0300 Subject: [PATCH 726/785] atk: Match `ExternalSoundPlayer::RemoveSound` --- src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp index b618a016..acc86ca4 100644 --- a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp +++ b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp @@ -58,6 +58,11 @@ bool ExternalSoundPlayer::CanPlaySound(int startPriority) { return true; } +void ExternalSoundPlayer::RemoveSound(BasicSound* sound) { + m_SoundList.erase(m_SoundList.iterator_to(*sound)); + sound->DetachExternalSoundPlayer(this); +} + BasicSound* ExternalSoundPlayer::GetLowestPrioritySound() { if (m_SoundList.empty()) return nullptr; From 5ad620c9e161029f5f69125d78c517fe50df5c97 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Sun, 13 Sep 2026 21:08:18 -0300 Subject: [PATCH 727/785] atk: Match `ExternalSoundPlayer::Finalize` --- .../atk/detail/atk_ExternalSoundPlayer.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp index acc86ca4..d27af916 100644 --- a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp +++ b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp @@ -63,6 +63,16 @@ void ExternalSoundPlayer::RemoveSound(BasicSound* sound) { sound->DetachExternalSoundPlayer(this); } +void ExternalSoundPlayer::Finalize(SoundActor* actor) { + for (auto itr{m_SoundList.begin()}; itr != m_SoundList.end();) { + auto curItr{itr++}; + [[maybe_unused]] const SoundActor* pActor{curItr->GetSoundActor()}; + + curItr->DetachSoundActor(actor); + RemoveSound(&*curItr); + } +} + BasicSound* ExternalSoundPlayer::GetLowestPrioritySound() { if (m_SoundList.empty()) return nullptr; From f77c58b5369903a85116c4ae49a7d6870b7452a6 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 08:46:14 -0300 Subject: [PATCH 728/785] atk: Match `ExternalSoundPlayer::AppendSound` This matches all exported functions in `ExternalSoundPlayer` --- .../atk/detail/atk_ExternalSoundPlayer.cpp | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp index d27af916..48124a18 100644 --- a/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp +++ b/src/NintendoWare/atk/detail/atk_ExternalSoundPlayer.cpp @@ -58,6 +58,29 @@ bool ExternalSoundPlayer::CanPlaySound(int startPriority) { return true; } +bool ExternalSoundPlayer::AppendSound(BasicSound* sound) { + int allocPriority{sound->CalcCurrentPlayerPriority()}; + + if (m_PlayableCount == 0) + return false; + + while (GetPlayingSoundCount() >= GetPlayableSoundCount()) { + BasicSound* dropSound{GetLowestPrioritySound()}; + + if (dropSound == nullptr) + return false; + + if (allocPriority < dropSound->CalcCurrentPlayerPriority()) + return false; + + dropSound->Finalize(); + } + + m_SoundList.push_back(*sound); + sound->AttachExternalSoundPlayer(this); + return true; +} + void ExternalSoundPlayer::RemoveSound(BasicSound* sound) { m_SoundList.erase(m_SoundList.iterator_to(*sound)); sound->DetachExternalSoundPlayer(this); From de6e394f0131b90b6ccae3948122a0b89381f8eb Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 09:06:01 -0300 Subject: [PATCH 729/785] atk: Match `PlayerHeap` constructor --- include/nn/atk/atk_PlayerHeap.h | 48 ++++++++++++------- .../atk/detail/atk_PlayerHeap.cpp | 6 +++ 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/include/nn/atk/atk_PlayerHeap.h b/include/nn/atk/atk_PlayerHeap.h index c2107292..fd51bdd3 100644 --- a/include/nn/atk/atk_PlayerHeap.h +++ b/include/nn/atk/atk_PlayerHeap.h @@ -12,45 +12,59 @@ namespace detail { class PlayerHeap; class CallbackNode { -private: - friend PlayerHeap; +public: + void SetCallback(SoundMemoryAllocatable::DisposeCallback callback) { m_Callback = callback; } + void SetCallbackArg(void* arg) { m_CallbackArg = arg; } + + SoundMemoryAllocatable::DisposeCallback GetCallback() { return m_Callback; } + void* GetCallbackArg() { return m_CallbackArg; } util::IntrusiveListNode m_Link; + +private: SoundMemoryAllocatable::DisposeCallback m_Callback; void* m_CallbackArg; }; static_assert(sizeof(CallbackNode) == 0x20); -class PlayerHeap : SoundMemoryAllocatable { +class PlayerHeap : public SoundMemoryAllocatable { public: - using CallbackList = util::IntrusiveList< - CallbackNode, util::IntrusiveListMemberNodeTraits>; - PlayerHeap(); ~PlayerHeap() override; - void Destroy(); + void AttachSoundPlayer(SoundPlayer* player) { m_pPlayer = player; } bool Create(void* startAddress, size_t size); - - void Clear(); + void Destroy(); void* Allocate(size_t size) override; - void* Allocate(size_t size, SoundMemoryAllocatable::DisposeCallback callback, - void* callbackArg) override; + void* Allocate(size_t size, DisposeCallback callback, void* callbackArg) override; size_t GetAllocateSize(size_t size, bool needMemoryPool) override; + + void Clear(); + + bool IsValid() const; + size_t GetFreeSize() const; + enum State { State_Constructed, State_TaskRegistered, State_TaskFinished, State_Destructed }; + + State GetState() const { return static_cast(m_State); } + void SetState(State state) { m_State = static_cast(state); } + private: - friend SoundPlayer; + using CallbackList = util::IntrusiveList< + CallbackNode, util::IntrusiveListMemberNodeTraits>; - SoundPlayer* m_pPlayer; - void* m_pStartAddress; - void* m_pEndAddress; - void* m_pAllocAddress; - u8 m_State; + SoundPlayer* m_pPlayer{}; + void* m_pStartAddress{}; + void* m_pEndAddress{}; + void* m_pAllocAddress{}; + u8 m_State{State_Constructed}; u8 m_Padding[3]; + +public: util::IntrusiveListNode m_Link; CallbackList m_CallbackList; }; diff --git a/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp b/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp index 8b137891..e0ea642e 100644 --- a/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp +++ b/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp @@ -1 +1,7 @@ +#include +namespace nn::atk::detail { + +PlayerHeap::PlayerHeap() = default; + +} // namespace nn::atk::detail From 24e331dc44ba8c8db96743a88a74fdcb1e570637 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 09:07:20 -0300 Subject: [PATCH 730/785] atk: Match `PlayerHeap::Destroy` --- src/NintendoWare/atk/detail/atk_PlayerHeap.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp b/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp index e0ea642e..5a92fa53 100644 --- a/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp +++ b/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp @@ -4,4 +4,9 @@ namespace nn::atk::detail { PlayerHeap::PlayerHeap() = default; +void PlayerHeap::Destroy() { + Clear(); + m_pAllocAddress = nullptr; +} + } // namespace nn::atk::detail From df893edddc326a7bd17e9ed0cb7c7e2a0c54c723 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 09:14:36 -0300 Subject: [PATCH 731/785] atk: Match `PlayerHeap` destructor --- include/nn/atk/atk_SoundMemoryAllocatable.h | 3 ++- src/NintendoWare/atk/detail/atk_PlayerHeap.cpp | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_SoundMemoryAllocatable.h b/include/nn/atk/atk_SoundMemoryAllocatable.h index 82cfcc67..ee789273 100644 --- a/include/nn/atk/atk_SoundMemoryAllocatable.h +++ b/include/nn/atk/atk_SoundMemoryAllocatable.h @@ -8,7 +8,8 @@ class SoundMemoryAllocatable { public: using DisposeCallback = void (*)(void*); - virtual ~SoundMemoryAllocatable() = 0; + virtual ~SoundMemoryAllocatable() = default; + virtual void* Allocate(size_t size) = 0; virtual void* Allocate(size_t size, DisposeCallback callback, void* callbackArg) = 0; virtual size_t GetAllocateSize(size_t size, bool needMemoryPool) = 0; diff --git a/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp b/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp index 5a92fa53..eb134ea4 100644 --- a/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp +++ b/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp @@ -4,6 +4,11 @@ namespace nn::atk::detail { PlayerHeap::PlayerHeap() = default; +PlayerHeap::~PlayerHeap() { + Destroy(); + m_State = 0; +} + void PlayerHeap::Destroy() { Clear(); m_pAllocAddress = nullptr; From d95709d0c69ba5c22f5104b038a66e6604fb6659 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 09:22:42 -0300 Subject: [PATCH 732/785] atk: Match `PlayerHeap::Create` --- .../atk/detail/atk_PlayerHeap.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp b/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp index eb134ea4..5e452762 100644 --- a/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp +++ b/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp @@ -1,5 +1,8 @@ #include +#include +#include + namespace nn::atk::detail { PlayerHeap::PlayerHeap() = default; @@ -14,4 +17,20 @@ void PlayerHeap::Destroy() { m_pAllocAddress = nullptr; } +bool PlayerHeap::Create(void* startAddress, size_t size) { + Util::IsValidMemoryForDsp(startAddress, size); + + void* endAddress{util::BytePtr(startAddress, static_cast(size)).Get()}; + startAddress = util::BytePtr(startAddress).AlignUp(fnd::Thread::StackAlignment).Get(); + + if (startAddress <= endAddress) { + m_pStartAddress = startAddress; + m_pEndAddress = endAddress; + m_pAllocAddress = startAddress; + return true; + } + + return false; +} + } // namespace nn::atk::detail From a1d405a4daa10ca33abf3122a392f6d26a1462cf Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 09:27:40 -0300 Subject: [PATCH 733/785] atk: Match `PlayerHeap::Allocate` --- .../atk/detail/atk_PlayerHeap.cpp | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp b/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp index 5e452762..d1191436 100644 --- a/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp +++ b/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp @@ -12,11 +12,6 @@ PlayerHeap::~PlayerHeap() { m_State = 0; } -void PlayerHeap::Destroy() { - Clear(); - m_pAllocAddress = nullptr; -} - bool PlayerHeap::Create(void* startAddress, size_t size) { Util::IsValidMemoryForDsp(startAddress, size); @@ -33,4 +28,21 @@ bool PlayerHeap::Create(void* startAddress, size_t size) { return false; } +void PlayerHeap::Destroy() { + Clear(); + m_pAllocAddress = nullptr; +} + +void* PlayerHeap::Allocate(size_t size) { + void* endp{util::BytePtr(m_pAllocAddress, size).Get()}; + + if (endp > m_pEndAddress) + return nullptr; + + void* allocAddress{m_pAllocAddress}; + m_pAllocAddress = util::BytePtr(endp).AlignUp(fnd::Thread::StackAlignment).Get(); + + return allocAddress; +} + } // namespace nn::atk::detail From 46e2646dd6d427b3e73ec83385c3ee65ec01f517 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 09:45:23 -0300 Subject: [PATCH 734/785] atk: Match `PlayerHeap::Allocate` overload --- include/nn/atk/atk_PlayerHeap.h | 2 +- .../atk/detail/atk_PlayerHeap.cpp | 20 ++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/include/nn/atk/atk_PlayerHeap.h b/include/nn/atk/atk_PlayerHeap.h index fd51bdd3..09c4ccfc 100644 --- a/include/nn/atk/atk_PlayerHeap.h +++ b/include/nn/atk/atk_PlayerHeap.h @@ -14,7 +14,7 @@ class PlayerHeap; class CallbackNode { public: void SetCallback(SoundMemoryAllocatable::DisposeCallback callback) { m_Callback = callback; } - void SetCallbackArg(void* arg) { m_CallbackArg = arg; } + void SetCallbackArg(void* callbackArg) { m_CallbackArg = callbackArg; } SoundMemoryAllocatable::DisposeCallback GetCallback() { return m_Callback; } void* GetCallbackArg() { return m_CallbackArg; } diff --git a/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp b/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp index d1191436..11deada7 100644 --- a/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp +++ b/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp @@ -34,7 +34,7 @@ void PlayerHeap::Destroy() { } void* PlayerHeap::Allocate(size_t size) { - void* endp{util::BytePtr(m_pAllocAddress, size).Get()}; + void* endp{util::BytePtr(m_pAllocAddress, static_cast(size)).Get()}; if (endp > m_pEndAddress) return nullptr; @@ -45,4 +45,22 @@ void* PlayerHeap::Allocate(size_t size) { return allocAddress; } +void* PlayerHeap::Allocate(size_t size, DisposeCallback callback, void* callbackArg) { + void* callbackNodeBuffer{util::BytePtr(m_pAllocAddress, static_cast(size)).Get()}; + void* endp{util::BytePtr(callbackNodeBuffer, sizeof(CallbackNode)).Get()}; + + if (endp > m_pEndAddress) + return nullptr; + + void* allocAddress{m_pAllocAddress}; + m_pAllocAddress = util::BytePtr(endp).AlignUp(fnd::Thread::StackAlignment).Get(); + + CallbackNode* node{new (callbackNodeBuffer) CallbackNode}; + node->SetCallback(callback); + node->SetCallbackArg(callbackArg); + m_CallbackList.push_back(*node); + + return allocAddress; +} + } // namespace nn::atk::detail From 61fde064280a2b044d58ebcab340498120d6d75a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 09:46:06 -0300 Subject: [PATCH 735/785] atk: Match `PlayerHeap::GetAllocateSize` --- src/NintendoWare/atk/detail/atk_PlayerHeap.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp b/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp index 11deada7..49bbe1a5 100644 --- a/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp +++ b/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp @@ -63,4 +63,8 @@ void* PlayerHeap::Allocate(size_t size, DisposeCallback callback, void* callback return allocAddress; } +size_t PlayerHeap::GetAllocateSize(size_t size, [[maybe_unused]] bool needMemoryPool) { + return size; +} + } // namespace nn::atk::detail From 1bab3be8f5738fc29f71c54145456de174be7ff4 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 10:02:17 -0300 Subject: [PATCH 736/785] atk: Match `PlayerHeap::Clear` --- include/nn/atk/atk_DriverCommand.h | 10 ++++----- .../atk/detail/atk_BasicSound.cpp | 12 +++++----- .../atk/detail/atk_PlayerHeap.cpp | 22 +++++++++++++++++++ 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/include/nn/atk/atk_DriverCommand.h b/include/nn/atk/atk_DriverCommand.h index 0192eec5..9ab0d240 100644 --- a/include/nn/atk/atk_DriverCommand.h +++ b/include/nn/atk/atk_DriverCommand.h @@ -520,15 +520,15 @@ static_assert(sizeof(DriverCommandVoiceAdpcmParam) == 0x30); class DriverCommand : public CommandManager { public: - static DriverCommand* GetInstance(); + static DriverCommand& GetInstance(); + static DriverCommand& GetInstanceForTaskThread(); - static void ProcessCommandList(Command* commandList); + void Initialize(void* commandBuffer, size_t commandBufferSize); DriverCommand(); - void Initialize(void* commandBuffer, size_t commandBufferSize); - - void RequestProcessCommand(); + static void ProcessCommandList(Command* commandList); + static void RequestProcessCommand(); }; static_assert(sizeof(DriverCommand) == 0x310); diff --git a/src/NintendoWare/atk/detail/atk_BasicSound.cpp b/src/NintendoWare/atk/detail/atk_BasicSound.cpp index 885bd053..db1a7c7e 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSound.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSound.cpp @@ -153,7 +153,7 @@ bool BasicSound::Initialize(OutputReceiver* pOutputReceiver) { driver::BasicSoundPlayer* basicPlayer{GetBasicSoundPlayerHandle()}; - DriverCommand& cmdmgr{*DriverCommand::GetInstance()}; + DriverCommand& cmdmgr{DriverCommand::GetInstance()}; auto* command{cmdmgr.AllocCommand()}; command->id = DriverCommandId_PlayerInit; @@ -190,7 +190,7 @@ void BasicSound::GetPriority(int* priority, int* ambientPriority) const { } void BasicSound::ClearIsFinalizedForCannotAllocatedResourceFlag() { - DriverCommand& cmdmgr{*DriverCommand::GetInstance()}; + DriverCommand& cmdmgr{DriverCommand::GetInstance()}; auto* command{cmdmgr.AllocCommand()}; if (command == nullptr) @@ -229,7 +229,7 @@ void BasicSound::Finalize() { { if (m_StartedFlag) { - DriverCommand& cmdmgr{*DriverCommand::GetInstance()}; + DriverCommand& cmdmgr{DriverCommand::GetInstance()}; auto* command{cmdmgr.AllocCommand()}; command->id = DriverCommandId_PlayerStop; @@ -244,7 +244,7 @@ void BasicSound::Finalize() { m_PlayerAvailableFlag = false; m_PlayerState = PlayerState_Stop; - DriverCommand& cmdmgr{*DriverCommand::GetInstance()}; + DriverCommand& cmdmgr{DriverCommand::GetInstance()}; auto* command{cmdmgr.AllocCommand()}; command->id = DriverCommandId_PlayerFinalize; @@ -791,7 +791,7 @@ float BasicSound::GetOutputFxSend(OutputDevice device, AuxBus bus) const { void BasicSound::SetPanMode(PanMode mode) { { - DriverCommand& cmdmgr{*DriverCommand::GetInstance()}; + DriverCommand& cmdmgr{DriverCommand::GetInstance()}; auto* command{cmdmgr.AllocCommand()}; command->id = DriverCommandId_PlayerPanmode; @@ -804,7 +804,7 @@ void BasicSound::SetPanMode(PanMode mode) { void BasicSound::SetPanCurve(PanCurve curve) { { - DriverCommand& cmdmgr{*DriverCommand::GetInstance()}; + DriverCommand& cmdmgr{DriverCommand::GetInstance()}; auto* command{cmdmgr.AllocCommand()}; command->id = DriverCommandId_PlayerPancurve; diff --git a/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp b/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp index 49bbe1a5..0d671f96 100644 --- a/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp +++ b/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp @@ -1,5 +1,6 @@ #include +#include #include #include @@ -67,4 +68,25 @@ size_t PlayerHeap::GetAllocateSize(size_t size, [[maybe_unused]] bool needMemory return size; } +void PlayerHeap::Clear() { + DriverCommand& cmdmgr{DriverCommand::GetInstanceForTaskThread()}; + + auto* command{cmdmgr.AllocCommand(false)}; + command->id = DriverCommandId_InvalidateData; + command->mem = m_pStartAddress; + command->size = util::BytePtr(m_pStartAddress).Distance(m_pAllocAddress); + + cmdmgr.PushCommand(command); + cmdmgr.FlushCommand(false, false); + + m_pAllocAddress = m_pStartAddress; + + for (auto& node : m_CallbackList) { + if (node.GetCallback() != nullptr) + node.GetCallback()(node.GetCallbackArg()); + } + + m_CallbackList.clear(); +} + } // namespace nn::atk::detail From a7317830f2f5dacb32ee6d81a7864dfb30277c53 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 10:03:39 -0300 Subject: [PATCH 737/785] atk: Match `PlayerHeap::GetFreeSize` --- include/nn/atk/atk_PlayerHeap.h | 2 +- src/NintendoWare/atk/detail/atk_PlayerHeap.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_PlayerHeap.h b/include/nn/atk/atk_PlayerHeap.h index 09c4ccfc..975d9b57 100644 --- a/include/nn/atk/atk_PlayerHeap.h +++ b/include/nn/atk/atk_PlayerHeap.h @@ -44,7 +44,7 @@ class PlayerHeap : public SoundMemoryAllocatable { void Clear(); - bool IsValid() const; + bool IsValid() const { return m_pPlayer != nullptr; } size_t GetFreeSize() const; diff --git a/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp b/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp index 0d671f96..0b544cf4 100644 --- a/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp +++ b/src/NintendoWare/atk/detail/atk_PlayerHeap.cpp @@ -89,4 +89,8 @@ void PlayerHeap::Clear() { m_CallbackList.clear(); } +size_t PlayerHeap::GetFreeSize() const { + return util::BytePtr(m_pAllocAddress).Distance(m_pEndAddress); +} + } // namespace nn::atk::detail From 36af3910cd7b1f5bd64fcc32479f6c26a473cf9b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 11:08:55 -0300 Subject: [PATCH 738/785] atk: Match all BiquadFilterPresets --- include/nn/atk/atk_BiquadFilterCallback.h | 4 +- include/nn/atk/atk_BiquadFilterPresets.h | 122 +++++++++++------- .../detail/dsp/atk_BiquadFilterPresets.cpp | 119 +++++++++++++++++ 3 files changed, 193 insertions(+), 52 deletions(-) diff --git a/include/nn/atk/atk_BiquadFilterCallback.h b/include/nn/atk/atk_BiquadFilterCallback.h index 4b785250..3098675f 100644 --- a/include/nn/atk/atk_BiquadFilterCallback.h +++ b/include/nn/atk/atk_BiquadFilterCallback.h @@ -8,9 +8,9 @@ class BiquadFilterCallback { public: using Coefficients = BiquadFilterCoefficients; - virtual ~BiquadFilterCallback(); + virtual ~BiquadFilterCallback() = default; - virtual void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) = 0; + virtual void GetCoefficients(Coefficients* pOutValue, int type, float value) const = 0; }; static_assert(sizeof(BiquadFilterCallback) == 0x8); diff --git a/include/nn/atk/atk_BiquadFilterPresets.h b/include/nn/atk/atk_BiquadFilterPresets.h index 2dbc0a0e..b86e386e 100644 --- a/include/nn/atk/atk_BiquadFilterPresets.h +++ b/include/nn/atk/atk_BiquadFilterPresets.h @@ -4,113 +4,135 @@ namespace nn::atk::detail { -class BiquadFilterLpf : BiquadFilterCallback { +class BiquadFilterLpf : public BiquadFilterCallback { public: - constexpr static u32 CoefficientsTableSize = 112; + BiquadFilterLpf() = default; + ~BiquadFilterLpf() override = default; - static Coefficients CoefficientsTable32000[CoefficientsTableSize]; + void GetCoefficients(Coefficients* pOutValue, int type, float value) const override; - ~BiquadFilterLpf() override; - - void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) override; +private: + static const int CoefficientsTableSize{112}; + static const Coefficients CoefficientsTable32000[CoefficientsTableSize]; }; static_assert(sizeof(BiquadFilterLpf) == 0x8); -class BiquadFilterHpf : BiquadFilterCallback { +class BiquadFilterHpf : public BiquadFilterCallback { public: - constexpr static u32 CoefficientsTableSize = 97; - - static Coefficients CoefficientsTable32000[CoefficientsTableSize]; + BiquadFilterHpf() = default; + ~BiquadFilterHpf() override = default; - ~BiquadFilterHpf() override; + void GetCoefficients(Coefficients* pOutValue, int type, float value) const override; - void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) override; +private: + static const int CoefficientsTableSize{97}; + static const Coefficients CoefficientsTable32000[CoefficientsTableSize]; }; static_assert(sizeof(BiquadFilterHpf) == 0x8); -class BiquadFilterBpf512 : BiquadFilterCallback { +class BiquadFilterBpf512 : public BiquadFilterCallback { public: - constexpr static u32 CoefficientsTableSize = 122; + BiquadFilterBpf512() = default; + ~BiquadFilterBpf512() override = default; - static Coefficients CoefficientsTable32000[CoefficientsTableSize]; + void GetCoefficients(Coefficients* pOutValue, int type, float value) const override; - ~BiquadFilterBpf512() override; - - void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) override; +private: + static const int CoefficientsTableSize{122}; + static const Coefficients CoefficientsTable32000[CoefficientsTableSize]; }; static_assert(sizeof(BiquadFilterBpf512) == 0x8); -class BiquadFilterBpf1024 : BiquadFilterCallback { +class BiquadFilterBpf1024 : public BiquadFilterCallback { public: - constexpr static u32 CoefficientsTableSize = 93; - - static Coefficients CoefficientsTable32000[CoefficientsTableSize]; + BiquadFilterBpf1024() = default; + ~BiquadFilterBpf1024() override = default; - ~BiquadFilterBpf1024() override; + void GetCoefficients(Coefficients* pOutValue, int type, float value) const override; - void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) override; +private: + static const int CoefficientsTableSize{93}; + static const Coefficients CoefficientsTable32000[CoefficientsTableSize]; }; static_assert(sizeof(BiquadFilterBpf1024) == 0x8); -class BiquadFilterBpf2048 : BiquadFilterCallback { +class BiquadFilterBpf2048 : public BiquadFilterCallback { public: - constexpr static u32 CoefficientsTableSize = 93; + BiquadFilterBpf2048() = default; + ~BiquadFilterBpf2048() override = default; - static Coefficients CoefficientsTable32000[CoefficientsTableSize]; + void GetCoefficients(Coefficients* pOutValue, int type, float value) const override; - ~BiquadFilterBpf2048() override; - - void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) override; +private: + static const int CoefficientsTableSize{93}; + static const Coefficients CoefficientsTable32000[CoefficientsTableSize]; }; static_assert(sizeof(BiquadFilterBpf2048) == 0x8); -class BiquadFilterLpfNw4fCompatible48k : BiquadFilterCallback { +class BiquadFilterLpfNw4fCompatible48k : public BiquadFilterCallback { public: - static Coefficients CoefficientsTable48000[BiquadFilterLpf::CoefficientsTableSize]; + BiquadFilterLpfNw4fCompatible48k() = default; + ~BiquadFilterLpfNw4fCompatible48k() override = default; - ~BiquadFilterLpfNw4fCompatible48k() override; + void GetCoefficients(Coefficients* pOutValue, int type, float value) const override; - void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) override; +private: + static const int CoefficientsTableSize{112}; + static const Coefficients CoefficientsTable48000[CoefficientsTableSize]; }; static_assert(sizeof(BiquadFilterLpfNw4fCompatible48k) == 0x8); -class BiquadFilterHpfNw4fCompatible48k : BiquadFilterCallback { +class BiquadFilterHpfNw4fCompatible48k : public BiquadFilterCallback { public: - static Coefficients CoefficientsTable48000[BiquadFilterHpf::CoefficientsTableSize]; + BiquadFilterHpfNw4fCompatible48k() = default; + ~BiquadFilterHpfNw4fCompatible48k() override = default; + + void GetCoefficients(Coefficients* pOutValue, int type, float value) const override; - ~BiquadFilterHpfNw4fCompatible48k() override; +private: + static const int CoefficientsTableSize{97}; + static const Coefficients CoefficientsTable48000[CoefficientsTableSize]; - void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) override; }; static_assert(sizeof(BiquadFilterHpfNw4fCompatible48k) == 0x8); -class BiquadFilterBpf512Nw4fCompatible48k : BiquadFilterCallback { +class BiquadFilterBpf512Nw4fCompatible48k : public BiquadFilterCallback { public: - static Coefficients CoefficientsTable48000[BiquadFilterBpf512::CoefficientsTableSize]; + BiquadFilterBpf512Nw4fCompatible48k() = default; + ~BiquadFilterBpf512Nw4fCompatible48k() override = default; - ~BiquadFilterBpf512Nw4fCompatible48k() override; + void GetCoefficients(Coefficients* pOutValue, int type, float value) const override; - void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) override; +private: + static const int CoefficientsTableSize{122}; + static const Coefficients CoefficientsTable48000[CoefficientsTableSize]; }; static_assert(sizeof(BiquadFilterBpf512Nw4fCompatible48k) == 0x8); -class BiquadFilterBpf1024Nw4fCompatible48k : BiquadFilterCallback { +class BiquadFilterBpf1024Nw4fCompatible48k : public BiquadFilterCallback { public: - static Coefficients CoefficientsTable48000[BiquadFilterBpf1024::CoefficientsTableSize]; + BiquadFilterBpf1024Nw4fCompatible48k() = default; + ~BiquadFilterBpf1024Nw4fCompatible48k() override = default; + + void GetCoefficients(Coefficients* pOutValue, int type, float value) const override; - ~BiquadFilterBpf1024Nw4fCompatible48k() override; +private: + static const int CoefficientsTableSize{93}; + static const Coefficients CoefficientsTable48000[CoefficientsTableSize]; - void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) override; }; static_assert(sizeof(BiquadFilterBpf1024Nw4fCompatible48k) == 0x8); -class BiquadFilterBpf2048Nw4fCompatible48k : BiquadFilterCallback { +class BiquadFilterBpf2048Nw4fCompatible48k : public BiquadFilterCallback { public: - static Coefficients CoefficientsTable48000[BiquadFilterBpf2048::CoefficientsTableSize]; + BiquadFilterBpf2048Nw4fCompatible48k() = default; + ~BiquadFilterBpf2048Nw4fCompatible48k() override = default; - ~BiquadFilterBpf2048Nw4fCompatible48k() override; + void GetCoefficients(Coefficients* pOutValue, int type, float value) const override; - void GetCoefficients(Coefficients* pOutValue, s32 type, f32 value) override; +private: + static const int CoefficientsTableSize{93}; + static const Coefficients CoefficientsTable48000[CoefficientsTableSize]; }; static_assert(sizeof(BiquadFilterBpf2048Nw4fCompatible48k) == 0x8); diff --git a/src/NintendoWare/atk/detail/dsp/atk_BiquadFilterPresets.cpp b/src/NintendoWare/atk/detail/dsp/atk_BiquadFilterPresets.cpp index 8b137891..b8190e63 100644 --- a/src/NintendoWare/atk/detail/dsp/atk_BiquadFilterPresets.cpp +++ b/src/NintendoWare/atk/detail/dsp/atk_BiquadFilterPresets.cpp @@ -1 +1,120 @@ +#include +#include + +namespace nn::atk::detail { + +const BiquadFilterLpf::Coefficients + BiquadFilterLpf::CoefficientsTable32000[BiquadFilterLpf::CoefficientsTableSize]{/*TODO*/}; +const BiquadFilterHpf::Coefficients + BiquadFilterHpf::CoefficientsTable32000[BiquadFilterHpf::CoefficientsTableSize]{/*TODO*/}; +const BiquadFilterBpf512::Coefficients + BiquadFilterBpf512::CoefficientsTable32000[BiquadFilterBpf512::CoefficientsTableSize]{/*TODO*/}; +const BiquadFilterBpf1024::Coefficients + BiquadFilterBpf1024::CoefficientsTable32000[BiquadFilterBpf1024::CoefficientsTableSize]{ + /*TODO*/}; +const BiquadFilterLpfNw4fCompatible48k::Coefficients BiquadFilterLpfNw4fCompatible48k:: + CoefficientsTable48000[BiquadFilterLpfNw4fCompatible48k::CoefficientsTableSize]{/*TODO*/}; +const BiquadFilterHpfNw4fCompatible48k::Coefficients BiquadFilterHpfNw4fCompatible48k:: + CoefficientsTable48000[BiquadFilterHpfNw4fCompatible48k::CoefficientsTableSize]{/*TODO*/}; +const BiquadFilterBpf512Nw4fCompatible48k::Coefficients BiquadFilterBpf512Nw4fCompatible48k:: + CoefficientsTable48000[BiquadFilterBpf512Nw4fCompatible48k::CoefficientsTableSize]{/*TODO*/}; +const BiquadFilterBpf1024Nw4fCompatible48k::Coefficients BiquadFilterBpf1024Nw4fCompatible48k:: + CoefficientsTable48000[BiquadFilterBpf1024Nw4fCompatible48k::CoefficientsTableSize]{/*TODO*/}; + +void BiquadFilterLpf::GetCoefficients(Coefficients* pOutValue, [[maybe_unused]] int type, + float value) const { + int coefSize{CoefficientsTableSize}; + int coefIndex{static_cast(value * static_cast(coefSize - 1))}; + + coefIndex = fnd::Clamp(coefIndex, 0, coefSize - 1); + *pOutValue = CoefficientsTable32000[coefIndex]; +} + +void BiquadFilterHpf::GetCoefficients(Coefficients* pOutValue, [[maybe_unused]] int type, + float value) const { + int coefSize{CoefficientsTableSize}; + int coefIndex{static_cast(value * static_cast(coefSize - 1))}; + + coefIndex = fnd::Clamp(coefIndex, 0, coefSize - 1); + *pOutValue = CoefficientsTable32000[coefIndex]; +} + +void BiquadFilterBpf512::GetCoefficients(Coefficients* pOutValue, [[maybe_unused]] int type, + float value) const { + int coefSize{CoefficientsTableSize}; + int coefIndex{static_cast(value * static_cast(coefSize - 1))}; + + coefIndex = fnd::Clamp(coefIndex, 0, coefSize - 1); + *pOutValue = CoefficientsTable32000[coefIndex]; +} + +void BiquadFilterBpf1024::GetCoefficients(Coefficients* pOutValue, [[maybe_unused]] int type, + float value) const { + int coefSize{CoefficientsTableSize}; + int coefIndex{static_cast((2.0f - value) * value * static_cast(coefSize - 1))}; + + coefIndex = fnd::Clamp(coefIndex, 0, coefSize - 1); + *pOutValue = CoefficientsTable32000[coefIndex]; +} + +void BiquadFilterBpf2048::GetCoefficients(Coefficients* pOutValue, [[maybe_unused]] int type, + float value) const { + int coefSize{CoefficientsTableSize}; + int coefIndex{static_cast((2.0f - value) * value * static_cast(coefSize - 1))}; + + coefIndex = fnd::Clamp(coefIndex, 0, coefSize - 1); + *pOutValue = CoefficientsTable32000[coefIndex]; +} + +void BiquadFilterLpfNw4fCompatible48k::GetCoefficients(Coefficients* pOutValue, + [[maybe_unused]] int type, + float value) const { + int coefSize{CoefficientsTableSize}; + int coefIndex{static_cast(value * static_cast(coefSize - 1))}; + + coefIndex = fnd::Clamp(coefIndex, 0, coefSize - 1); + *pOutValue = CoefficientsTable48000[coefIndex]; +} + +void BiquadFilterHpfNw4fCompatible48k::GetCoefficients(Coefficients* pOutValue, + [[maybe_unused]] int type, + float value) const { + int coefSize{CoefficientsTableSize}; + int coefIndex{static_cast(value * static_cast(coefSize - 1))}; + + coefIndex = fnd::Clamp(coefIndex, 0, coefSize - 1); + *pOutValue = CoefficientsTable48000[coefIndex]; +} + +void BiquadFilterBpf512Nw4fCompatible48k::GetCoefficients(Coefficients* pOutValue, + [[maybe_unused]] int type, + float value) const { + int coefSize{CoefficientsTableSize}; + int coefIndex{static_cast((2.0f - value) * value * static_cast(coefSize - 1))}; + + coefIndex = fnd::Clamp(coefIndex, 0, coefSize - 1); + *pOutValue = CoefficientsTable48000[coefIndex]; +} + +void BiquadFilterBpf1024Nw4fCompatible48k::GetCoefficients(Coefficients* pOutValue, + [[maybe_unused]] int type, + float value) const { + int coefSize{CoefficientsTableSize}; + int coefIndex{static_cast((2.0f - value) * value * static_cast(coefSize - 1))}; + + coefIndex = fnd::Clamp(coefIndex, 0, coefSize - 1); + *pOutValue = CoefficientsTable48000[coefIndex]; +} + +void BiquadFilterBpf2048Nw4fCompatible48k::GetCoefficients(Coefficients* pOutValue, + [[maybe_unused]] int type, + float value) const { + int coefSize{CoefficientsTableSize}; + int coefIndex{static_cast((2.0f - value) * value * static_cast(coefSize - 1))}; + + coefIndex = fnd::Clamp(coefIndex, 0, coefSize - 1); + *pOutValue = CoefficientsTable48000[coefIndex]; +} + +} // namespace nn::atk::detail From 83f498e90879b668926f2939247c456c0a701c09 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 11:55:36 -0300 Subject: [PATCH 739/785] atk: Match `FrameHeap::Section::Dump` --- src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp index d981cb11..448ea5c2 100644 --- a/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp +++ b/src/NintendoWare/atk/detail/util/atk_FrameHeap.cpp @@ -125,4 +125,7 @@ void FrameHeap::Section::AppendBlock(Block* block) { m_BlockList.push_back(*block); } +void FrameHeap::Section::Dump([[maybe_unused]] const SoundDataManager& mgr, + [[maybe_unused]] const SoundArchive& arc) const {} + } // namespace nn::atk::detail From 49617a9128b76a75dd9b4dbd018813e0ded3471c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 13:40:28 -0300 Subject: [PATCH 740/785] Just some code cleanup --- .../atk/atk_AudioRendererPerformanceReader.h | 2 +- include/nn/atk/atk_BankFile.h | 2 +- include/nn/atk/atk_Channel.h | 3 +- include/nn/atk/atk_ChannelMixVolume.h | 2 +- include/nn/atk/atk_DisposeCallback.h | 8 ++--- include/nn/atk/atk_MmlCommand.h | 16 ++++----- include/nn/atk/atk_NoteOnCallback.h | 15 ++++---- include/nn/atk/atk_SequenceSoundFile.h | 2 +- include/nn/atk/atk_SoundArchive.h | 18 +++++----- include/nn/atk/atk_SoundRuntimeUtility.h | 35 ++++++++++++++++++- include/nn/atk/atk_StreamSoundFileLoader.h | 2 +- include/nn/atk/atk_StreamSoundFileReader.h | 9 +++-- .../atk/atk_StreamSoundPrefetchFileReader.h | 7 ++-- include/nn/atk/atk_WaveFile.h | 2 +- .../nn/atk/fnd/os/atkfnd_CriticalSection.h | 16 ++++----- .../atk/detail/voice/atk_Channel.cpp | 12 +++---- 16 files changed, 94 insertions(+), 57 deletions(-) diff --git a/include/nn/atk/atk_AudioRendererPerformanceReader.h b/include/nn/atk/atk_AudioRendererPerformanceReader.h index 65761f61..168b9a40 100644 --- a/include/nn/atk/atk_AudioRendererPerformanceReader.h +++ b/include/nn/atk/atk_AudioRendererPerformanceReader.h @@ -8,7 +8,7 @@ namespace nn::atk { class AudioRendererPerformanceReader { public: - static const int PerformanceInfoCountMin = 2; + static const int PerformanceInfoCountMin{2}; struct PerformanceInfo { void* performanceBuffer; diff --git a/include/nn/atk/atk_BankFile.h b/include/nn/atk/atk_BankFile.h index 86c7d564..8855a5cf 100644 --- a/include/nn/atk/atk_BankFile.h +++ b/include/nn/atk/atk_BankFile.h @@ -20,7 +20,7 @@ struct BankFile { u32 GetWaveIdCount() const { return GetWaveIdTable().table.count; } - s32 GetInstrumentCount() const { return GetInstrumentReferenceTable().count; } + s32 GetInstrumentCount() const { return static_cast(GetInstrumentReferenceTable().count); } const Util::WaveId* GetWaveId(u32 index) const { return GetWaveIdTable().GetWaveId(index); } diff --git a/include/nn/atk/atk_Channel.h b/include/nn/atk/atk_Channel.h index 6922ca7b..ed60d966 100644 --- a/include/nn/atk/atk_Channel.h +++ b/include/nn/atk/atk_Channel.h @@ -42,7 +42,7 @@ class Channel { static const u8 SilenceVolumeMax{255}; static const u8 SilenceVolumeMin{0}; - static const float SilenceVolumeMaxR; // = 1.0 / SilenceVolumeMax; + constexpr static const float SilenceVolumeMaxR{1.0f / SilenceVolumeMax}; public: static Channel* AllocChannel(int voiceChannelCount, int priority, ChannelCallback callback, @@ -146,6 +146,7 @@ class Channel { OutputAdditionalParam* GetTvAdditionalParamAddr() { return m_pTvAdditionalParam; } void SetTvAdditionalParam(const OutputAdditionalParam& param); #endif + void SetMainSend(float mainSend); void SetUserPan(float pan); diff --git a/include/nn/atk/atk_ChannelMixVolume.h b/include/nn/atk/atk_ChannelMixVolume.h index fe61894b..80f6288b 100644 --- a/include/nn/atk/atk_ChannelMixVolume.h +++ b/include/nn/atk/atk_ChannelMixVolume.h @@ -6,7 +6,7 @@ namespace nn::atk { class ChannelMixVolume { public: - static const int ChannelCountMax = 24; + static const int ChannelCountMax{24}; ChannelMixVolume(); explicit ChannelMixVolume(const MixVolume& mixVolume); diff --git a/include/nn/atk/atk_DisposeCallback.h b/include/nn/atk/atk_DisposeCallback.h index b9456e70..be67f07b 100644 --- a/include/nn/atk/atk_DisposeCallback.h +++ b/include/nn/atk/atk_DisposeCallback.h @@ -6,16 +6,14 @@ namespace nn::atk::detail::driver { class DisposeCallback { public: + util::IntrusiveListNode m_DisposeLink; + DisposeCallback() = default; virtual ~DisposeCallback() = default; - + virtual void InvalidateData(const void* start, const void* end) = 0; -private: - friend class DisposeCallbackManager; - - util::IntrusiveListNode m_DisposeLink; }; static_assert(sizeof(DisposeCallback) == 0x18); diff --git a/include/nn/atk/atk_MmlCommand.h b/include/nn/atk/atk_MmlCommand.h index d27bdb79..f3d67ade 100644 --- a/include/nn/atk/atk_MmlCommand.h +++ b/include/nn/atk/atk_MmlCommand.h @@ -5,21 +5,21 @@ namespace nn::atk::detail::driver { class MmlCommand { public: enum Mml { - Mml_Wait = 0x80, + Mml_Wait = 128, Mml_Prg, - Mml_OpenTrack = 0x88, + Mml_OpenTrack = 136, Mml_Jump, Mml_Call, - Mml_Random = 0xa0, + Mml_Random = 160, Mml_Variable, Mml_If, Mml_Time, Mml_TimeRandom, Mml_TimeVariable, - Mml_Timebase = 0xb0, + Mml_Timebase = 176, Mml_EnvHold, Mml_Monophonic, Mml_VelocityRange, @@ -27,7 +27,7 @@ class MmlCommand { Mml_BiquadValue, Mml_BankSelect, - Mml_ModPhase = 0xbd, + Mml_ModPhase = 189, Mml_ModCurve, Mml_FrontBypass, Mml_Pan, @@ -65,12 +65,12 @@ class MmlCommand { Mml_ModDelay, Mml_Tempo, - Mml_SweepPitch = 0xe3, + Mml_SweepPitch = 227, Mml_ModPeriod, - Mml_ExCommand = 0xf0, + Mml_ExCommand = 240, - Mml_EnvReset = 0xfb, + Mml_EnvReset = 251, Mml_LoopEnd, Mml_Ret, Mml_AllocTrack, diff --git a/include/nn/atk/atk_NoteOnCallback.h b/include/nn/atk/atk_NoteOnCallback.h index 4764f51d..364ef195 100644 --- a/include/nn/atk/atk_NoteOnCallback.h +++ b/include/nn/atk/atk_NoteOnCallback.h @@ -7,12 +7,12 @@ namespace nn::atk::detail::driver { class SequenceSoundPlayer; struct NoteOnInfo { - s32 prgNo; - s32 key; - s32 velocity; - s32 length; - s32 initPan; - s32 priority; + int prgNo; + int key; + int velocity; + int length; + int initPan; + int priority; Channel::ChannelCallback channelCallback; void* channelCallbackData; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) @@ -28,7 +28,8 @@ static_assert(sizeof(NoteOnInfo) == 0x38); class NoteOnCallback { public: - virtual ~NoteOnCallback(); + virtual ~NoteOnCallback() = default; + virtual Channel* NoteOn(SequenceSoundPlayer* seqPlayer, u8 bankIndex, const NoteOnInfo& noteOnInfo) = 0; }; diff --git a/include/nn/atk/atk_SequenceSoundFile.h b/include/nn/atk/atk_SequenceSoundFile.h index cc56e894..64aa4615 100644 --- a/include/nn/atk/atk_SequenceSoundFile.h +++ b/include/nn/atk/atk_SequenceSoundFile.h @@ -27,7 +27,7 @@ struct SequenceSoundFile { struct LabelBlockBody { Util::ReferenceTable labelInfoReferenceTable; - int GetLabelCount() const { return labelInfoReferenceTable.count; } + int GetLabelCount() const { return static_cast(labelInfoReferenceTable.count); } const LabelInfo* GetLabelInfo(int index) const; const char* GetLabel(int index) const; diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index 4eee67e2..03f28a7b 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -84,7 +84,7 @@ class SoundArchive { u8 channelPriority; bool isReleasePriorityFix; - SequenceSoundInfo(); + SequenceSoundInfo() = default; }; static_assert(sizeof(SequenceSoundInfo) == 0x1c); @@ -102,7 +102,7 @@ class SoundArchive { u8 channelCount; s8 globalChannelIndex[2]; - StreamTrackInfo(); + StreamTrackInfo() = default; }; static_assert(sizeof(StreamTrackInfo) == 0xe); @@ -118,7 +118,7 @@ class SoundArchive { FileId prefetchFileId; void* streamBufferPool; - StreamSoundInfo(); + StreamSoundInfo() = default; void Setup(); }; static_assert(sizeof(StreamSoundInfo) == 0x90); @@ -128,7 +128,7 @@ class SoundArchive { u32 loopStartFrame; u32 loopEndFrame; - StreamSoundInfo2(); + StreamSoundInfo2() = default; }; static_assert(sizeof(StreamSoundInfo2) == 0xc); @@ -138,7 +138,7 @@ class SoundArchive { u8 channelPriority; bool isReleasePriorityFix; - WaveSoundInfo(); + WaveSoundInfo() = default; }; static_assert(sizeof(WaveSoundInfo) == 0xc); @@ -150,7 +150,7 @@ class SoundArchive { struct BankInfo { FileId fileId; - BankInfo(); + BankInfo() = default; }; static_assert(sizeof(BankInfo) == 0x4); @@ -168,7 +168,7 @@ class SoundArchive { int playableSoundMax; u32 playerHeapSize; - PlayerInfo(); + PlayerInfo() = default; }; static_assert(sizeof(PlayerInfo) == 0x8); @@ -177,7 +177,7 @@ class SoundArchive { ItemId endId; detail::Util::Table fileIdTable; - SoundGroupInfo(); + SoundGroupInfo() = default; }; static_assert(sizeof(SoundGroupInfo) == 0x10); @@ -185,7 +185,7 @@ class SoundArchive { FileId fileId; u32 groupFileSize; - GroupInfo(); + GroupInfo() = default; }; static_assert(sizeof(GroupInfo) == 0x8); diff --git a/include/nn/atk/atk_SoundRuntimeUtility.h b/include/nn/atk/atk_SoundRuntimeUtility.h index 5d2057fa..e7faa447 100644 --- a/include/nn/atk/atk_SoundRuntimeUtility.h +++ b/include/nn/atk/atk_SoundRuntimeUtility.h @@ -1,7 +1,40 @@ #pragma once +#include +#include +#include + namespace nn::atk::detail { -class SoundRuntimeUtility {}; +class SoundRuntimeUtility { +public: +#if NN_WARE_VER < NN_MAKE_VER(4, 0, 0) + Sound* AllocSound(SoundInstanceManager* manager, SoundArchive::ItemId soundId, + int playerPriority, int ambientPriority, + BasicSound::AmbientInfo* ambientArgInfo) +#else + template + Sound* AllocSound(SoundInstanceManager* manager, SoundArchive::ItemId soundId, + int playerPriority, int ambientPriority, + BasicSound::AmbientInfo* ambientArgInfo, OutputReceiver* pOutputReceiver) +#endif + { +#if NN_WARE_VER < NN_MAKE_VER(4, 0, 0) + Sound* sound{manager->Alloc(playerPriority, ambientPriority)}; +#else + Sound* sound{manager->Alloc(playerPriority, ambientPriority, pOutputReceiver)}; +#endif + + if (sound != nullptr) { + sound->SetId(soundId); + + if (ambientArgInfo != nullptr) + sound->SetAmbientInfo(*ambientArgInfo); + } + + return sound; + } +}; +static_assert(sizeof(SoundRuntimeUtility) == 0x1); } // namespace nn::atk::detail diff --git a/include/nn/atk/atk_StreamSoundFileLoader.h b/include/nn/atk/atk_StreamSoundFileLoader.h index de080e00..32f734e6 100644 --- a/include/nn/atk/atk_StreamSoundFileLoader.h +++ b/include/nn/atk/atk_StreamSoundFileLoader.h @@ -30,7 +30,7 @@ class StreamSoundFileLoader : public IRegionInfoReadable { bool ReadSeekBlockData(u16* yn1, u16* yn2, int blockIndex, int channelCount); bool ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo, u32 regionIndex) const override; - ~StreamSoundFileLoader() override; + ~StreamSoundFileLoader() override = default; private: fnd::FileStream* m_pStream{}; diff --git a/include/nn/atk/atk_StreamSoundFileReader.h b/include/nn/atk/atk_StreamSoundFileReader.h index 18a22b7e..5f739eac 100644 --- a/include/nn/atk/atk_StreamSoundFileReader.h +++ b/include/nn/atk/atk_StreamSoundFileReader.h @@ -36,8 +36,13 @@ class StreamSoundFileReader { bool ReadDspAdpcmChannelInfo(DspAdpcmParam* pParam, DspAdpcmLoopParam* pLoopParam, int channelIndex) const; - u32 GetChannelCount() const; - u32 GetTrackCount() const; + u32 GetChannelCount() const { + return m_pInfoBlockBody->GetChannelInfoTable()->GetChannelCount(); + } + + u32 GetTrackCount() const { + return m_pInfoBlockBody->GetTrackInfoTable()->GetTrackCount(); + } u32 GetSeekBlockOffset() const { if (m_pHeader != nullptr && m_pHeader->HasSeekBlock()) diff --git a/include/nn/atk/atk_StreamSoundPrefetchFileReader.h b/include/nn/atk/atk_StreamSoundPrefetchFileReader.h index 5b9225a1..b21e79d5 100644 --- a/include/nn/atk/atk_StreamSoundPrefetchFileReader.h +++ b/include/nn/atk/atk_StreamSoundPrefetchFileReader.h @@ -40,8 +40,11 @@ class StreamSoundPrefetchFileReader : public IRegionInfoReadable { bool ReadRegionInfo(StreamSoundFile::RegionInfo* pInfo, u32 regionIndex) const override; - u32 GetChannelCount() const; - u32 GetPrefetchDataCount() const; + u32 GetChannelCount() const { + return m_pInfoBlockBody->GetChannelInfoTable()->GetChannelCount(); + } + + u32 GetPrefetchDataCount() const { return m_pPrefetchDataBlockBody->GetPrefetchDataCount(); } u32 GetRegionDataOffset() const { u32 result{0}; diff --git a/include/nn/atk/atk_WaveFile.h b/include/nn/atk/atk_WaveFile.h index 9fefe503..52bb7960 100644 --- a/include/nn/atk/atk_WaveFile.h +++ b/include/nn/atk/atk_WaveFile.h @@ -23,7 +23,7 @@ struct WaveFile { u32 originalLoopStartFrame; Util::ReferenceTable channelInfoReferenceTable; - int GetChannelCount() const { return channelInfoReferenceTable.count; }; + int GetChannelCount() const { return static_cast(channelInfoReferenceTable.count); }; const ChannelInfo& GetChannelInfo(int channelIndex) const; }; diff --git a/include/nn/atk/fnd/os/atkfnd_CriticalSection.h b/include/nn/atk/fnd/os/atkfnd_CriticalSection.h index fe0e822e..f05f453f 100644 --- a/include/nn/atk/fnd/os/atkfnd_CriticalSection.h +++ b/include/nn/atk/fnd/os/atkfnd_CriticalSection.h @@ -10,18 +10,11 @@ class CriticalSection { ~CriticalSection() = default; - void Enter() { - // TODO - } + void Enter() { m_Mutex.Lock(); } - bool TryEnter() { - // TODO - return true; - } + bool TryEnter() { return m_Mutex.TryLock(); } - void Leave() { - // TODO - } + void Leave() { m_Mutex.Unlock(); } void Lock() { m_Mutex.Lock(); } @@ -30,6 +23,9 @@ class CriticalSection { void Unlock() { m_Mutex.Unlock(); } private: + static const u32 CriticalSectionSize{24}; + static const u32 CriticalSectionAlign{4}; + os::Mutex m_Mutex; }; static_assert(sizeof(CriticalSection) == 0x20); diff --git a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp index dc6269b7..69e10a24 100644 --- a/src/NintendoWare/atk/detail/voice/atk_Channel.cpp +++ b/src/NintendoWare/atk/detail/voice/atk_Channel.cpp @@ -334,13 +334,13 @@ void Channel::InitParam(ChannelCallback callback, void* callbackData) { m_Velocity = 1.0f; } - -void Channel::AppendWaveBuffer(const WaveInfo& waveInfo, position_t startOffsetSamples -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) - , - bool isContextCalculationSkipMode +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) +void Channel::AppendWaveBuffer(const WaveInfo& waveInfo, position_t startOffsetSamples) +#else +void Channel::AppendWaveBuffer(const WaveInfo& waveInfo, position_t startOffsetSamples, + bool isContextCalculationSkipMode) #endif -) { +{ m_LoopFlag = waveInfo.loopFlag; m_LoopStartFrame = waveInfo.loopStartFrame; m_OriginalLoopStartFrame = waveInfo.originalLoopStartFrame; From 49652ce516363457156192f5250a6efad282075c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 13:49:27 -0300 Subject: [PATCH 741/785] atk: Match `Util::WarningLogger::LogBuffer::Print` --- src/NintendoWare/atk/detail/util/atk_Util.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/util/atk_Util.cpp b/src/NintendoWare/atk/detail/util/atk_Util.cpp index baeac4b4..72f44b19 100644 --- a/src/NintendoWare/atk/detail/util/atk_Util.cpp +++ b/src/NintendoWare/atk/detail/util/atk_Util.cpp @@ -876,4 +876,8 @@ const void* Util::GetWaveFileOfWaveSound(const void* wsdFile, u32 index, const S return waveFile; } +void Util::WarningLogger::LogBuffer::Print() { + counter = 0; +} + } // namespace nn::atk::detail From e5ef89d82983954a7d7393e3adb3f242efe2dd80 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 13:59:51 -0300 Subject: [PATCH 742/785] atk: Match `Util::WarningLogger::SwapBuffer` --- include/nn/atk/atk_Util.h | 3 ++- src/NintendoWare/atk/detail/util/atk_Util.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index f88b2ca8..6ab8d734 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -317,7 +317,8 @@ class Util { void Log(int logId, int arg0, int arg1); void Print(); - void Reset(); + + void Reset() { counter = 0; } }; static_assert(sizeof(LogBuffer) == 0x304); diff --git a/src/NintendoWare/atk/detail/util/atk_Util.cpp b/src/NintendoWare/atk/detail/util/atk_Util.cpp index 72f44b19..d95a435b 100644 --- a/src/NintendoWare/atk/detail/util/atk_Util.cpp +++ b/src/NintendoWare/atk/detail/util/atk_Util.cpp @@ -876,6 +876,16 @@ const void* Util::GetWaveFileOfWaveSound(const void* wsdFile, u32 index, const S return waveFile; } +void Util::WarningLogger::SwapBuffer() { + if (m_pCurrentBuffer == &m_Buffer0) { + m_Buffer1.Reset(); + m_pCurrentBuffer = &m_Buffer1; + } else if (m_pCurrentBuffer == &m_Buffer1) { + m_Buffer0.Reset(); + m_pCurrentBuffer = &m_Buffer0; + } +} + void Util::WarningLogger::LogBuffer::Print() { counter = 0; } From 30d2354cc143fc595aa4ce39628dc1e51e5967e6 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 14:02:10 -0300 Subject: [PATCH 743/785] atk: Match `Util::WarningLogger::Print` --- src/NintendoWare/atk/detail/util/atk_Util.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/NintendoWare/atk/detail/util/atk_Util.cpp b/src/NintendoWare/atk/detail/util/atk_Util.cpp index d95a435b..b6a0d972 100644 --- a/src/NintendoWare/atk/detail/util/atk_Util.cpp +++ b/src/NintendoWare/atk/detail/util/atk_Util.cpp @@ -876,6 +876,13 @@ const void* Util::GetWaveFileOfWaveSound(const void* wsdFile, u32 index, const S return waveFile; } +void Util::WarningLogger::Print() { + if (m_pCurrentBuffer == &m_Buffer0) + m_Buffer1.Print(); + else if (m_pCurrentBuffer == &m_Buffer1) + m_Buffer0.Print(); +} + void Util::WarningLogger::SwapBuffer() { if (m_pCurrentBuffer == &m_Buffer0) { m_Buffer1.Reset(); From 1bcf23ec1a859a0514b582260bacf9a0533f2891 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 14:22:46 -0300 Subject: [PATCH 744/785] atk: Match `Util::WarningLogger::LogBuffer::Log` --- include/nn/atk/atk_Util.h | 7 +++++++ src/NintendoWare/atk/detail/util/atk_Util.cpp | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index 6ab8d734..479042bd 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -297,6 +297,13 @@ class Util { void Print(); void SwapBuffer(); + enum LogId { + LogId_ChannelAllocationFailed, + LogId_SoundthreadFailedWakeup, + LogId_LogbufferFull, + LogId_Max + }; + private: struct LogBuffer { static const int LogCount = 64; diff --git a/src/NintendoWare/atk/detail/util/atk_Util.cpp b/src/NintendoWare/atk/detail/util/atk_Util.cpp index b6a0d972..778cc419 100644 --- a/src/NintendoWare/atk/detail/util/atk_Util.cpp +++ b/src/NintendoWare/atk/detail/util/atk_Util.cpp @@ -893,8 +893,27 @@ void Util::WarningLogger::SwapBuffer() { } } +void Util::WarningLogger::LogBuffer::Log(int logId, int arg0, int arg1) { + while (counter < LogCount) { + Element* rLog{element + counter}; + rLog->logId = logId; + rLog->arg0 = arg0; + rLog->arg1 = arg1; + ++counter; + + if (counter != LogCount - 1) + return; + + logId = 2; + arg0 = -1; + arg1 = arg0; + } +} + void Util::WarningLogger::LogBuffer::Print() { counter = 0; } +void Util::WarningLogger::LogBuffer::Element::Print() {} + } // namespace nn::atk::detail From bce877d3f2a7e9d030d6550ce89934ba3c053a2b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 14:23:52 -0300 Subject: [PATCH 745/785] atk: Match `Util::WarningLogger::Log` --- src/NintendoWare/atk/detail/util/atk_Util.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/detail/util/atk_Util.cpp b/src/NintendoWare/atk/detail/util/atk_Util.cpp index 778cc419..4f1a27be 100644 --- a/src/NintendoWare/atk/detail/util/atk_Util.cpp +++ b/src/NintendoWare/atk/detail/util/atk_Util.cpp @@ -876,6 +876,11 @@ const void* Util::GetWaveFileOfWaveSound(const void* wsdFile, u32 index, const S return waveFile; } +void Util::WarningLogger::Log(int logId, int arg0, int arg1) { + if (m_pCurrentBuffer != nullptr) + m_pCurrentBuffer->Log(logId, arg0, arg1); +} + void Util::WarningLogger::Print() { if (m_pCurrentBuffer == &m_Buffer0) m_Buffer1.Print(); From 2aac5da730c1d55f5db94b6fc84b6ac7cd143c25 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 14:40:02 -0300 Subject: [PATCH 746/785] atk: Match `WavOutFileStream::WriteHeader` --- include/nn/atk/atk_Util.h | 15 +++++++++------ .../atk/detail/util/atk_WavOutFileStream.cpp | 7 +++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/nn/atk/atk_Util.h b/include/nn/atk/atk_Util.h index 479042bd..594c2c4b 100644 --- a/include/nn/atk/atk_Util.h +++ b/include/nn/atk/atk_Util.h @@ -277,7 +277,10 @@ class Util { Singleton() = default; public: - static CHILD& GetInstance(); + __attribute__((noinline)) static CHILD& GetInstance() { + static CHILD instance; + return instance; + } friend CHILD; }; @@ -291,7 +294,7 @@ class Util { class WarningLogger : public Singleton { public: - WarningLogger(); + WarningLogger() = default; void Log(int logId, int arg0, int arg1); void Print(); @@ -306,7 +309,7 @@ class Util { private: struct LogBuffer { - static const int LogCount = 64; + static const int LogCount{64}; struct Element { int logId; @@ -318,9 +321,9 @@ class Util { static_assert(sizeof(Element) == 0xc); Element element[LogCount]; - int counter; + int counter{0}; - LogBuffer(); + LogBuffer() = default; void Log(int logId, int arg0, int arg1); void Print(); @@ -331,7 +334,7 @@ class Util { LogBuffer m_Buffer0; LogBuffer m_Buffer1; - LogBuffer* m_pCurrentBuffer; + LogBuffer* m_pCurrentBuffer{&m_Buffer0}; }; static_assert(sizeof(WarningLogger) == 0x610); }; diff --git a/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp b/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp index 6a0e689b..b7e75129 100644 --- a/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp +++ b/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp @@ -21,7 +21,7 @@ bool WavOutFileStream::Open(fnd::FileStream& stream, int channels, size_t sample return true; } - return false; + // return false; } void WavOutFileStream::SetCacheBuffer(char* buf, size_t length) { @@ -29,7 +29,6 @@ void WavOutFileStream::SetCacheBuffer(char* buf, size_t length) { m_BufferLength = length; } -// NON_MATCHING: reordering of instructions bool WavOutFileStream::WriteHeader(int channels, size_t samplesPerSec) { char buffer[sizeof(WaveBinaryHeader) + FileIoBufferAlignment]; void* alignedBuffer{util::BytePtr(buffer).AlignUp(FileIoBufferAlignment).Get()}; @@ -41,9 +40,9 @@ bool WavOutFileStream::WriteHeader(int channels, size_t samplesPerSec) { header->fmtChunk.bitsPerSample = 16; header->fmtChunk.blockAlign = channels * 2; header->fmtChunk.samplesPerSec = samplesPerSec; - header->fmtChunk.avgBytesPerSec = header->fmtChunk.blockAlign * header->fmtChunk.samplesPerSec; - header->fmtChunk.channels = channels; header->fmtChunk.formatTag = FmtChunk::FormatPcm; + header->fmtChunk.channels = channels; + header->fmtChunk.avgBytesPerSec = header->fmtChunk.blockAlign * header->fmtChunk.samplesPerSec; size_t result{Write(header, sizeof(WaveBinaryHeader))}; return result == sizeof(WaveBinaryHeader); From e6d7b6c7fab28de2e5924acc15e4de58ae79df2d Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 14:40:41 -0300 Subject: [PATCH 747/785] atk: Match `WavOutFileStream::Open` --- src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp b/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp index b7e75129..6ca9edd4 100644 --- a/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp +++ b/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp @@ -11,7 +11,6 @@ WavOutFileStream::WavOutFileStream() = default; WavOutFileStream::~WavOutFileStream() = default; -// NON_MATCHING: requires WavOutFileStream::WriteHeader bool WavOutFileStream::Open(fnd::FileStream& stream, int channels, size_t samplesPerSec) { m_pFileStream = &stream; @@ -21,7 +20,7 @@ bool WavOutFileStream::Open(fnd::FileStream& stream, int channels, size_t sample return true; } - // return false; + return false; } void WavOutFileStream::SetCacheBuffer(char* buf, size_t length) { From acb8cf1a3962004007424cf72e1ccf0d54ccff53 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 15:25:22 -0300 Subject: [PATCH 748/785] atk: Match `WavOutFileStream::WriteDirect` --- include/nn/atk/atk_WavOutFileStream.h | 2 +- include/nn/atk/fnd/basis/atkfnd_Result.h | 2 +- include/nn/util/util_BytePtr.h | 8 ++++++- .../atk/detail/util/atk_WavOutFileStream.cpp | 22 +++++++++++++++++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/include/nn/atk/atk_WavOutFileStream.h b/include/nn/atk/atk_WavOutFileStream.h index 88f595f0..6e9f5c88 100644 --- a/include/nn/atk/atk_WavOutFileStream.h +++ b/include/nn/atk/atk_WavOutFileStream.h @@ -33,7 +33,7 @@ class WavOutFileStream { bool UpdateDataChunkSize(); size_t CalcRiffChunkSize(size_t dataSize); - size_t WriteDirect(const void* buf, size_t length, fnd::FndResult* result); + size_t WriteDirect(const void* buf, size_t length, fnd::FndResult* pResult); size_t FlushBuffer(); diff --git a/include/nn/atk/fnd/basis/atkfnd_Result.h b/include/nn/atk/fnd/basis/atkfnd_Result.h index 3e8cf415..95ed3015 100644 --- a/include/nn/atk/fnd/basis/atkfnd_Result.h +++ b/include/nn/atk/fnd/basis/atkfnd_Result.h @@ -46,7 +46,7 @@ class FndResult { bool IsFalse() const { return value == FndResultType_False; } - bool IsFailed() const { return value == static_cast(FndResultType_Failed); } + bool IsFailed() const { return static_cast(*this) < FndResultType_True; } const char* ToString(); diff --git a/include/nn/util/util_BytePtr.h b/include/nn/util/util_BytePtr.h index 500c598f..91aea2d6 100644 --- a/include/nn/util/util_BytePtr.h +++ b/include/nn/util/util_BytePtr.h @@ -80,7 +80,13 @@ class ConstBytePtr { } bool IsAligned(size_t) const; - ConstBytePtr& AlignUp(size_t); + + ConstBytePtr& AlignUp(size_t alignment) { + uintptr_t& ptr = reinterpret_cast(m_Ptr); + ptr = align_up(ptr, alignment); + return *this; + } + ConstBytePtr& AlignDown(size_t); ConstBytePtr& operator+=(ptrdiff_t); ConstBytePtr& operator-=(ptrdiff_t); diff --git a/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp b/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp index 6ca9edd4..25cc01bf 100644 --- a/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp +++ b/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp @@ -47,4 +47,26 @@ bool WavOutFileStream::WriteHeader(int channels, size_t samplesPerSec) { return result == sizeof(WaveBinaryHeader); } +size_t WavOutFileStream::WriteDirect(const void* buf, size_t length, fnd::FndResult* pResult) { + if (!IsAvailable()) + return 0; + + const void* alignedBuffer{util::ConstBytePtr(buf).AlignUp(FileIoBufferAlignment).Get()}; + + [[maybe_unused]] ptrdiff_t unAlignedLength{util::ConstBytePtr(buf, length).Distance(buf)}; + size_t alignedBufferLength{length}; + + size_t writtenBytes{m_pFileStream->Write(alignedBuffer, alignedBufferLength, pResult)}; + + if (pResult->IsFailed()) { + char bufferForAlignment[2]; + [[maybe_unused]] char* alignedBufferForAlignment{ + util::BytePtr(bufferForAlignment).AlignUp(FileIoBufferAlignment).Get()}; + + return 0; + } + + return writtenBytes; +} + } // namespace nn::atk::detail From 0941824012e76a85a29e66b31eeb62e384081aec Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 15:30:57 -0300 Subject: [PATCH 749/785] atk: Match `WavOutFileStream::FlushBuffer` --- include/nn/atk/fnd/basis/atkfnd_Result.h | 2 +- .../atk/detail/util/atk_WavOutFileStream.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/fnd/basis/atkfnd_Result.h b/include/nn/atk/fnd/basis/atkfnd_Result.h index 95ed3015..49e665c7 100644 --- a/include/nn/atk/fnd/basis/atkfnd_Result.h +++ b/include/nn/atk/fnd/basis/atkfnd_Result.h @@ -57,7 +57,7 @@ class FndResult { explicit operator FndResultType() const { return FndResultType(value); } private: - u32 value; + u32 value{0}; }; static_assert(sizeof(FndResult) == 0x4); diff --git a/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp b/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp index 25cc01bf..eaf124ab 100644 --- a/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp +++ b/src/NintendoWare/atk/detail/util/atk_WavOutFileStream.cpp @@ -69,4 +69,17 @@ size_t WavOutFileStream::WriteDirect(const void* buf, size_t length, fnd::FndRes return writtenBytes; } +size_t WavOutFileStream::FlushBuffer() { + size_t length{m_ValidBufferLength}; + m_ValidBufferLength = 0; + + if (length == 0) + return 0; + + fnd::FndResult result; + length = WriteDirect(m_Buffer, length, &result); + + return length; +} + } // namespace nn::atk::detail From dd790ea2fb1e7de42867d2a0e77a41c5f33ecbd3 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 15:44:10 -0300 Subject: [PATCH 750/785] atk: Match `Bank` constructor --- src/NintendoWare/atk/detail/seq/atk_Bank.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NintendoWare/atk/detail/seq/atk_Bank.cpp b/src/NintendoWare/atk/detail/seq/atk_Bank.cpp index 8b137891..6214f02d 100644 --- a/src/NintendoWare/atk/detail/seq/atk_Bank.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_Bank.cpp @@ -1 +1,7 @@ +#include +namespace nn::atk::detail::driver { + +Bank::Bank() = default; + +} // namespace nn::atk::detail::driver From 1e27f66950170734666a6469144ae7159eeb7054 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 15:44:29 -0300 Subject: [PATCH 751/785] atk: Match `Bank` destructor --- src/NintendoWare/atk/detail/seq/atk_Bank.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/NintendoWare/atk/detail/seq/atk_Bank.cpp b/src/NintendoWare/atk/detail/seq/atk_Bank.cpp index 6214f02d..4b7d5e37 100644 --- a/src/NintendoWare/atk/detail/seq/atk_Bank.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_Bank.cpp @@ -4,4 +4,6 @@ namespace nn::atk::detail::driver { Bank::Bank() = default; +Bank::~Bank() = default; + } // namespace nn::atk::detail::driver From 02c3b2ab59f0f416d2329524b4119f3b2264254a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 15:47:00 -0300 Subject: [PATCH 752/785] atk: Match `Bank::CalcChannelVelocityVolume` --- src/NintendoWare/atk/detail/seq/atk_Bank.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NintendoWare/atk/detail/seq/atk_Bank.cpp b/src/NintendoWare/atk/detail/seq/atk_Bank.cpp index 4b7d5e37..86ed324a 100644 --- a/src/NintendoWare/atk/detail/seq/atk_Bank.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_Bank.cpp @@ -1,9 +1,19 @@ #include +namespace { +const float VelocityMaxR{1.0f / 127.0f}; + +const float InstrumentVolumeCriterionR{1.0f / 127.0f}; +} + namespace nn::atk::detail::driver { Bank::Bank() = default; Bank::~Bank() = default; +float Bank::CalcChannelVelocityVolume(u8 velocity) { + return static_cast(velocity) * VelocityMaxR; +} + } // namespace nn::atk::detail::driver From c06ea902a13b4510406166155b8ce9435bd0cb1a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 14 Sep 2026 16:09:31 -0300 Subject: [PATCH 753/785] atk: Match `Bank::NoteOn` --- include/nn/atk/atk_BankFile.h | 4 +- include/nn/atk/atk_BankFileReader.h | 2 +- include/nn/atk/atk_BasicSoundPlayer.h | 11 ++-- include/nn/atk/atk_BiquadFilterPresets.h | 2 - include/nn/atk/atk_Channel.h | 4 +- include/nn/atk/atk_DisposeCallback.h | 3 +- include/nn/atk/atk_SoundHeap.h | 2 +- include/nn/atk/atk_SoundMemoryAllocatable.h | 2 +- include/nn/atk/atk_StreamSoundFileReader.h | 4 +- include/nn/atk/atk_WaveSoundFileReader.h | 2 +- include/nn/atk/fnd/basis/atkfnd_Result.h | 4 +- include/nn/os/os_MessageQueueTypes.h | 2 + include/nn/os/os_TickTypes.h | 12 ++-- include/nn/util/util_BytePtr.h | 2 +- include/nn/util/util_IntrusiveList.h | 20 +++--- .../atk/detail/atk_BasicSoundPlayer.cpp | 2 +- src/NintendoWare/atk/detail/seq/atk_Bank.cpp | 62 ++++++++++++++++++- 17 files changed, 100 insertions(+), 40 deletions(-) diff --git a/include/nn/atk/atk_BankFile.h b/include/nn/atk/atk_BankFile.h index 8855a5cf..1901eda2 100644 --- a/include/nn/atk/atk_BankFile.h +++ b/include/nn/atk/atk_BankFile.h @@ -20,7 +20,9 @@ struct BankFile { u32 GetWaveIdCount() const { return GetWaveIdTable().table.count; } - s32 GetInstrumentCount() const { return static_cast(GetInstrumentReferenceTable().count); } + s32 GetInstrumentCount() const { + return static_cast(GetInstrumentReferenceTable().count); + } const Util::WaveId* GetWaveId(u32 index) const { return GetWaveIdTable().GetWaveId(index); } diff --git a/include/nn/atk/atk_BankFileReader.h b/include/nn/atk/atk_BankFileReader.h index a02041fe..1713566b 100644 --- a/include/nn/atk/atk_BankFileReader.h +++ b/include/nn/atk/atk_BankFileReader.h @@ -16,7 +16,7 @@ struct VelocityRegionInfo { u8 keyGroup; u8 interpolationType; - VelocityRegionInfo() : adshrCurve(0, 0, 0, 0, 0) {}; + VelocityRegionInfo() : adshrCurve(0, 0, 0, 0, 0){}; }; static_assert(sizeof(VelocityRegionInfo) == 0x18); diff --git a/include/nn/atk/atk_BasicSoundPlayer.h b/include/nn/atk/atk_BasicSoundPlayer.h index 876ee14a..b8a1ca8e 100644 --- a/include/nn/atk/atk_BasicSoundPlayer.h +++ b/include/nn/atk/atk_BasicSoundPlayer.h @@ -18,9 +18,7 @@ struct PlayerParamSet { u32 outputLineFlag; OutputParam tvParam; - PlayerParamSet() { - Initialize(); - } + PlayerParamSet() { Initialize(); } void Initialize() { volume = 1.0f; @@ -56,6 +54,7 @@ class BasicSoundPlayer { bool IsStarted() const { return m_StartedFlag; } bool IsPause() const { return m_PauseFlag; } bool IsPlayFinished() const { return m_FinishFlag; } + bool IsFinalizedForCannotAllocateResource() const { return m_IsFinalizedForCannotAllocateResource; } @@ -84,9 +83,7 @@ class BasicSoundPlayer { #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) void SetTvAdditionalParamAddr(OutputAdditionalParam* pParam) { m_pTvAdditionalParam = pParam; } - const OutputAdditionalParam* GetTvAdditionalParamAddr() const { - return m_pTvAdditionalParam; - }; + const OutputAdditionalParam* GetTvAdditionalParamAddr() const { return m_pTvAdditionalParam; }; void SetTvAdditionalSend(int bus, float send); void SetTvBusMixVolumeUsed(bool isUsed); @@ -125,7 +122,7 @@ class BasicSoundPlayer { void SetStartedFlag(bool isStarted) { m_StartedFlag = isStarted; } void SetPauseFlag(bool isPauseEnabled) { m_PauseFlag = isPauseEnabled; } void SetFinishFlag(bool isPlayFinished) { m_FinishFlag = isPlayFinished; } - + void SetFinalizedForCannotAllocateResourceFlag(bool flag) { m_IsFinalizedForCannotAllocateResource = flag; } diff --git a/include/nn/atk/atk_BiquadFilterPresets.h b/include/nn/atk/atk_BiquadFilterPresets.h index b86e386e..74a64248 100644 --- a/include/nn/atk/atk_BiquadFilterPresets.h +++ b/include/nn/atk/atk_BiquadFilterPresets.h @@ -92,7 +92,6 @@ class BiquadFilterHpfNw4fCompatible48k : public BiquadFilterCallback { private: static const int CoefficientsTableSize{97}; static const Coefficients CoefficientsTable48000[CoefficientsTableSize]; - }; static_assert(sizeof(BiquadFilterHpfNw4fCompatible48k) == 0x8); @@ -119,7 +118,6 @@ class BiquadFilterBpf1024Nw4fCompatible48k : public BiquadFilterCallback { private: static const int CoefficientsTableSize{93}; static const Coefficients CoefficientsTable48000[CoefficientsTableSize]; - }; static_assert(sizeof(BiquadFilterBpf1024Nw4fCompatible48k) == 0x8); diff --git a/include/nn/atk/atk_Channel.h b/include/nn/atk/atk_Channel.h index ed60d966..12138ee4 100644 --- a/include/nn/atk/atk_Channel.h +++ b/include/nn/atk/atk_Channel.h @@ -140,9 +140,7 @@ class Channel { #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) void SetTvAdditionalParamAddr(OutputAdditionalParam* param) { m_pTvAdditionalParam = param; } - const OutputAdditionalParam* GetTvAdditionalParamAddr() const { - return m_pTvAdditionalParam; - } + const OutputAdditionalParam* GetTvAdditionalParamAddr() const { return m_pTvAdditionalParam; } OutputAdditionalParam* GetTvAdditionalParamAddr() { return m_pTvAdditionalParam; } void SetTvAdditionalParam(const OutputAdditionalParam& param); #endif diff --git a/include/nn/atk/atk_DisposeCallback.h b/include/nn/atk/atk_DisposeCallback.h index be67f07b..164194dd 100644 --- a/include/nn/atk/atk_DisposeCallback.h +++ b/include/nn/atk/atk_DisposeCallback.h @@ -11,9 +11,8 @@ class DisposeCallback { DisposeCallback() = default; virtual ~DisposeCallback() = default; - - virtual void InvalidateData(const void* start, const void* end) = 0; + virtual void InvalidateData(const void* start, const void* end) = 0; }; static_assert(sizeof(DisposeCallback) == 0x18); diff --git a/include/nn/atk/atk_SoundHeap.h b/include/nn/atk/atk_SoundHeap.h index 9e28fa3f..053f4d92 100644 --- a/include/nn/atk/atk_SoundHeap.h +++ b/include/nn/atk/atk_SoundHeap.h @@ -41,4 +41,4 @@ class SoundHeap : SoundMemoryAllocatable { }; static_assert(sizeof(SoundHeap) == 0x50); -} // namespace nn::atk::detail +} // namespace nn::atk diff --git a/include/nn/atk/atk_SoundMemoryAllocatable.h b/include/nn/atk/atk_SoundMemoryAllocatable.h index ee789273..9371cd55 100644 --- a/include/nn/atk/atk_SoundMemoryAllocatable.h +++ b/include/nn/atk/atk_SoundMemoryAllocatable.h @@ -9,7 +9,7 @@ class SoundMemoryAllocatable { using DisposeCallback = void (*)(void*); virtual ~SoundMemoryAllocatable() = default; - + virtual void* Allocate(size_t size) = 0; virtual void* Allocate(size_t size, DisposeCallback callback, void* callbackArg) = 0; virtual size_t GetAllocateSize(size_t size, bool needMemoryPool) = 0; diff --git a/include/nn/atk/atk_StreamSoundFileReader.h b/include/nn/atk/atk_StreamSoundFileReader.h index 5f739eac..ab8689ac 100644 --- a/include/nn/atk/atk_StreamSoundFileReader.h +++ b/include/nn/atk/atk_StreamSoundFileReader.h @@ -40,9 +40,7 @@ class StreamSoundFileReader { return m_pInfoBlockBody->GetChannelInfoTable()->GetChannelCount(); } - u32 GetTrackCount() const { - return m_pInfoBlockBody->GetTrackInfoTable()->GetTrackCount(); - } + u32 GetTrackCount() const { return m_pInfoBlockBody->GetTrackInfoTable()->GetTrackCount(); } u32 GetSeekBlockOffset() const { if (m_pHeader != nullptr && m_pHeader->HasSeekBlock()) diff --git a/include/nn/atk/atk_WaveSoundFileReader.h b/include/nn/atk/atk_WaveSoundFileReader.h index c1f5ff93..09f75faa 100644 --- a/include/nn/atk/atk_WaveSoundFileReader.h +++ b/include/nn/atk/atk_WaveSoundFileReader.h @@ -27,7 +27,7 @@ struct WaveSoundNoteInfo { u8 volume; float pitch; - WaveSoundNoteInfo() : adshr(0, 0, 0, 0, 0) {}; + WaveSoundNoteInfo() : adshr(0, 0, 0, 0, 0){}; }; static_assert(sizeof(WaveSoundNoteInfo) == 0x18); diff --git a/include/nn/atk/fnd/basis/atkfnd_Result.h b/include/nn/atk/fnd/basis/atkfnd_Result.h index 49e665c7..6fb02177 100644 --- a/include/nn/atk/fnd/basis/atkfnd_Result.h +++ b/include/nn/atk/fnd/basis/atkfnd_Result.h @@ -36,9 +36,9 @@ class FndResult { public: FndResult() = default; - explicit FndResult(u32 value) : value{value} {}; + explicit FndResult(u32 value) : value{value}{}; - explicit FndResult(FndResultType value) : value(value) {}; + explicit FndResult(FndResultType value) : value(value){}; bool IsSucceeded() const { return !IsFailed(); } diff --git a/include/nn/os/os_MessageQueueTypes.h b/include/nn/os/os_MessageQueueTypes.h index c97ef156..7a8dc18a 100644 --- a/include/nn/os/os_MessageQueueTypes.h +++ b/include/nn/os/os_MessageQueueTypes.h @@ -7,7 +7,9 @@ namespace nn::os { namespace detail { + class MultiWaitObjectList; + } struct MessageQueueType { diff --git a/include/nn/os/os_TickTypes.h b/include/nn/os/os_TickTypes.h index b035e915..066c75ab 100644 --- a/include/nn/os/os_TickTypes.h +++ b/include/nn/os/os_TickTypes.h @@ -38,11 +38,11 @@ class Tick { s64 value; -// TODO: DWARF shows value as private and named m_Tick. -// It's being kept as it was for now to keep sead -// from not compiling. Fix this before merging to master. -// private: -// s64 m_Tick; + // TODO: DWARF shows value as private and named m_Tick. + // It's being kept as it was for now to keep sead + // from not compiling. Fix this before merging to master. + // private: + // s64 m_Tick; }; -} // namespace nn::os \ No newline at end of file +} // namespace nn::os diff --git a/include/nn/util/util_BytePtr.h b/include/nn/util/util_BytePtr.h index 91aea2d6..6b9bfc12 100644 --- a/include/nn/util/util_BytePtr.h +++ b/include/nn/util/util_BytePtr.h @@ -86,7 +86,7 @@ class ConstBytePtr { ptr = align_up(ptr, alignment); return *this; } - + ConstBytePtr& AlignDown(size_t); ConstBytePtr& operator+=(ptrdiff_t); ConstBytePtr& operator-=(ptrdiff_t); diff --git a/include/nn/util/util_IntrusiveList.h b/include/nn/util/util_IntrusiveList.h index e62a0eb2..c7cef154 100644 --- a/include/nn/util/util_IntrusiveList.h +++ b/include/nn/util/util_IntrusiveList.h @@ -102,8 +102,8 @@ class IntrusiveListImplementation { return temporary; } - bool operator==(const const_iterator& ci) const { return m_Node == ci.m_Node; } - + bool operator==(const const_iterator& ci) const { return m_Node == ci.m_Node; } + bool operator!=(const const_iterator& ci) const { return m_Node != ci.m_Node; } private: @@ -241,7 +241,7 @@ class IntrusiveList { reference operator*() const; pointer operator->() const; - + const_iterator& operator++() { ++m_Iterator; return *this; @@ -252,7 +252,7 @@ class IntrusiveList { ++m_Iterator; return temporary; } - + const_iterator& operator--() { --m_Iterator; return *this; @@ -338,7 +338,7 @@ class IntrusiveList { void push_front(reference); void pop_back(); void pop_front() { m_Implementation.pop_front(); } - + reference front() { return ToReference(m_Implementation.front()); } const_reference front() const { return ToReference(m_Implementation.front()); } reference back() { return ToReference(m_Implementation.back()); } @@ -389,9 +389,14 @@ class IntrusiveList { private: IntrusiveListNode& ToNode(reference ref) const { return NodeTraits::GetNode(ref); } + const IntrusiveListNode& ToNode(const_reference ref) const { return NodeTraits::GetNode(ref); } + reference ToReference(IntrusiveListNode& node) const { return NodeTraits::GetItem(node); } - const_reference ToReference(const IntrusiveListNode& node) const { return NodeTraits::GetItem(node); } + + const_reference ToReference(const IntrusiveListNode& node) const { + return NodeTraits::GetItem(node); + } detail::IntrusiveListImplementation m_Implementation; }; @@ -416,7 +421,7 @@ class IntrusiveListBaseNodeTraits { static const T& GetItem(const IntrusiveListNode& node) { return static_cast(node); } }; -template +template class IntrusiveListMemberNodeTraits { friend class IntrusiveList; @@ -436,4 +441,5 @@ class IntrusiveListMemberNodeTraits { return reinterpret_cast(&(reinterpret_cast(0)->*Member)); } }; + } // namespace nn::util diff --git a/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp b/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp index 136617e0..71b9a3f9 100644 --- a/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp +++ b/src/NintendoWare/atk/detail/atk_BasicSoundPlayer.cpp @@ -35,7 +35,7 @@ void BasicSoundPlayer::Finalize() { m_pOutputReceiver = nullptr; } #endif - + m_Event.Signal(); } diff --git a/src/NintendoWare/atk/detail/seq/atk_Bank.cpp b/src/NintendoWare/atk/detail/seq/atk_Bank.cpp index 86ed324a..08e500d2 100644 --- a/src/NintendoWare/atk/detail/seq/atk_Bank.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_Bank.cpp @@ -1,10 +1,16 @@ #include +#include + +#include + namespace { + const float VelocityMaxR{1.0f / 127.0f}; const float InstrumentVolumeCriterionR{1.0f / 127.0f}; -} + +} // namespace namespace nn::atk::detail::driver { @@ -12,6 +18,60 @@ Bank::Bank() = default; Bank::~Bank() = default; +Channel* Bank::NoteOn(const BankFileReader& bankReader, const WaveArchiveFileReader& warcReader, + const NoteOnInfo& noteOnInfo) const { + VelocityRegionInfo regionInfo; + + if (!bankReader.ReadVelocityRegionInfo(®ionInfo, noteOnInfo.prgNo, noteOnInfo.key, + noteOnInfo.velocity)) + return nullptr; + + const void* waveFile{warcReader.GetWaveFile(regionInfo.waveIndex)}; + + WaveInfo waveInfo; + + { + WaveFileReader reader{waveFile, WaveType_Nwwav}; + + if (!reader.ReadWaveInfo(&waveInfo, nullptr)) + return nullptr; + } + + Channel* pChannel{Channel::AllocChannel(std::min(waveInfo.channelCount, 2), noteOnInfo.priority, + noteOnInfo.channelCallback, + noteOnInfo.channelCallbackData)}; + + if (pChannel == nullptr) + return nullptr; + + pChannel->SetKey(noteOnInfo.key, regionInfo.originalKey); + pChannel->SetVelocity(CalcChannelVelocityVolume(noteOnInfo.velocity)); + pChannel->SetInstrumentVolume(static_cast(regionInfo.volume) * + InstrumentVolumeCriterionR); + pChannel->SetTune(regionInfo.pitch); + pChannel->SetAttack(regionInfo.adshrCurve.GetAttack()); + pChannel->SetHold(regionInfo.adshrCurve.GetHold()); + pChannel->SetDecay(regionInfo.adshrCurve.GetDecay()); + pChannel->SetSustain(regionInfo.adshrCurve.GetSustain()); + pChannel->SetRelease(regionInfo.adshrCurve.GetRelease()); + + float initPan{static_cast(noteOnInfo.initPan + regionInfo.pan - 64) / 63.0f}; + pChannel->SetInitPan(initPan); + + pChannel->SetKeyGroupId(regionInfo.keyGroup); + pChannel->SetIsIgnoreNoteOff(regionInfo.isIgnoreNoteOff); + pChannel->SetInterpolationType(regionInfo.interpolationType); + pChannel->SetUpdateType(noteOnInfo.updateType); +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) + pChannel->Start(waveInfo, noteOnInfo.length, 0); +#else + pChannel->SetOutputReceiver(noteOnInfo.pOutputReceiver); + pChannel->Start(waveInfo, noteOnInfo.length, 0, false); +#endif + + return pChannel; +} + float Bank::CalcChannelVelocityVolume(u8 velocity) { return static_cast(velocity) * VelocityMaxR; } From 48c8cae68def8a64aeb8bb740d48a6c616c92e78 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 15 Sep 2026 12:12:08 -0300 Subject: [PATCH 754/785] atk: Reorganize a lot of structs based on DWARF --- include/nn/atk/atk_BankFileReader.h | 2 +- include/nn/atk/atk_BasicSoundPlayer.h | 2 +- include/nn/atk/atk_EffectBase.h | 49 ++--- .../nn/atk/atk_MmlSequenceTrackAllocator.h | 4 +- include/nn/atk/atk_MultiVoice.h | 2 +- include/nn/atk/atk_OutputReceiver.h | 12 +- include/nn/atk/atk_SequenceTrackAllocator.h | 3 + include/nn/atk/atk_SoundStartable.h | 176 ++++++++++-------- include/nn/atk/atk_WaveSoundFileReader.h | 2 +- include/nn/atk/detail/atk_BinaryTypes.h | 24 ++- include/nn/atk/detail/atk_IntrusiveList.h | 4 +- .../nn/atk/detail/atk_SoundArchiveManager.h | 25 ++- include/nn/atk/fnd/basis/atkfnd_Result.h | 4 +- src/NintendoWare/atk/atk_SoundHandle.cpp | 2 +- src/NintendoWare/atk/atk_SoundStartable.cpp | 14 ++ 15 files changed, 199 insertions(+), 126 deletions(-) diff --git a/include/nn/atk/atk_BankFileReader.h b/include/nn/atk/atk_BankFileReader.h index 1713566b..a02041fe 100644 --- a/include/nn/atk/atk_BankFileReader.h +++ b/include/nn/atk/atk_BankFileReader.h @@ -16,7 +16,7 @@ struct VelocityRegionInfo { u8 keyGroup; u8 interpolationType; - VelocityRegionInfo() : adshrCurve(0, 0, 0, 0, 0){}; + VelocityRegionInfo() : adshrCurve(0, 0, 0, 0, 0) {}; }; static_assert(sizeof(VelocityRegionInfo) == 0x18); diff --git a/include/nn/atk/atk_BasicSoundPlayer.h b/include/nn/atk/atk_BasicSoundPlayer.h index b8a1ca8e..909a845d 100644 --- a/include/nn/atk/atk_BasicSoundPlayer.h +++ b/include/nn/atk/atk_BasicSoundPlayer.h @@ -54,7 +54,7 @@ class BasicSoundPlayer { bool IsStarted() const { return m_StartedFlag; } bool IsPause() const { return m_PauseFlag; } bool IsPlayFinished() const { return m_FinishFlag; } - + bool IsFinalizedForCannotAllocateResource() const { return m_IsFinalizedForCannotAllocateResource; } diff --git a/include/nn/atk/atk_EffectBase.h b/include/nn/atk/atk_EffectBase.h index 12d8f9ef..c23d456a 100644 --- a/include/nn/atk/atk_EffectBase.h +++ b/include/nn/atk/atk_EffectBase.h @@ -32,41 +32,42 @@ class EffectBase { EffectBase(); virtual ~EffectBase(); - virtual void unk1() = 0; - virtual void unk2() = 0; - virtual void unk3() = 0; - virtual void unk4() = 0; - virtual void unk5() = 0; - virtual void unk6() = 0; - virtual void unk7() = 0; - virtual void UpdateBuffer(s32, void**, size_t, SampleFormat, s32, OutputMode); - virtual void GetChannelIndex(ChannelIndex* pChannel, s32 channelCount) const; - virtual s32 GetChannelSettingCountMax() const; - virtual void OnChangeOutputMode(); - virtual void SetEffectBuffer(void* effectBuffer, size_t effectBufferSize); - + virtual size_t GetRequiredMemSize() const = 0; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) - bool AddEffect(audio::AudioRendererConfig* pConfig, audio::FinalMixType* pFinalMixType); - bool AddEffect(audio::AudioRendererConfig* pConfig, audio::SubMixType* pFinalMixType); + virtual bool AddEffect(audio::AudioRendererConfig* pConfig, + audio::FinalMixType* pFinalMixType) = 0; + virtual bool AddEffect(audio::AudioRendererConfig* pConfig, + audio::SubMixType* pFinalMixType) = 0; #else - bool AddEffect(audio::AudioRendererConfig* pConfig, OutputMixer* pOutputMixer); + virtual bool AddEffect(audio::AudioRendererConfig* pConfig, OutputMixer* pOutputMixer) = 0; #endif - - void SetEffectInputOutput(const s8* input, const s8* output, s32 inputCount, s32 outputCount); - + virtual void SetEffectInputOutput(const s8* input, const s8* output, int inputCount, + int outputCount) = 0; #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) - void RemoveEffect(audio::AudioRendererConfig* pConfig, audio::FinalMixType* pFinalMixType); - void RemoveEffect(audio::AudioRendererConfig* pConfig, audio::SubMixType* pSubMixType); + virtual void RemoveEffect(audio::AudioRendererConfig* pConfig, + audio::FinalMixType* pFinalMixType) = 0; + virtual void RemoveEffect(audio::AudioRendererConfig* pConfig, + audio::SubMixType* pSubMixType) = 0; #else - void RemoveEffect(audio::AudioRendererConfig* pConfig, OutputMixer* pOutputMixer); + virtual void RemoveEffect(audio::AudioRendererConfig* pConfig, OutputMixer* pOutputMixer) = 0; #endif - - static s32 ConvertChannelModeToInt(ChannelMode channelMode); + virtual bool IsRemovable() const = 0; + virtual void UpdateBuffer(int, void**, size_t, SampleFormat, int, OutputMode); SampleRate GetSampleRate() const; bool SetSampleRate(SampleRate sampleRate); + virtual void GetChannelIndex(ChannelIndex* pChannel, int channelCount) const; + virtual int GetChannelSettingCountMax() const; + virtual void OnChangeOutputMode(); + virtual void SetEffectBuffer(void* effectBuffer, size_t effectBufferSize); + +protected: + static int ConvertChannelModeToInt(ChannelMode channelMode); + private: + NN_NO_COPY(EffectBase); + friend OutputMixer; util::IntrusiveListNode m_Link; diff --git a/include/nn/atk/atk_MmlSequenceTrackAllocator.h b/include/nn/atk/atk_MmlSequenceTrackAllocator.h index e9d0f44d..afa6f5cd 100644 --- a/include/nn/atk/atk_MmlSequenceTrackAllocator.h +++ b/include/nn/atk/atk_MmlSequenceTrackAllocator.h @@ -12,13 +12,13 @@ class MmlSequenceTrackAllocator : SequenceTrackAllocator { SequenceTrack* AllocTrack(SequenceSoundPlayer* player) override; - void FreeTrack(SequenceTrack* track); + void FreeTrack(SequenceTrack* track) override; s32 Create(void* buffer, size_t size); void Destroy(); - s32 GetAllocatableTrackCount(); + s32 GetAllocatableTrackCount() const override; private: MmlParser* m_pParser; diff --git a/include/nn/atk/atk_MultiVoice.h b/include/nn/atk/atk_MultiVoice.h index c2c51b7f..35ecfe97 100644 --- a/include/nn/atk/atk_MultiVoice.h +++ b/include/nn/atk/atk_MultiVoice.h @@ -57,7 +57,7 @@ class MultiVoice { constexpr static f32 SendMin = 0.0; constexpr static f32 SendMax = 1.0; - explicit MultiVoice(); + MultiVoice(); #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) explicit MultiVoice(OutputAdditionalParam* pAdditionalParam); #endif diff --git a/include/nn/atk/atk_OutputReceiver.h b/include/nn/atk/atk_OutputReceiver.h index 1c099918..d81573ce 100644 --- a/include/nn/atk/atk_OutputReceiver.h +++ b/include/nn/atk/atk_OutputReceiver.h @@ -6,16 +6,18 @@ namespace nn::atk { class OutputReceiver { public: - enum ReceiverType { + enum class ReceiverType : int { ReceiverType_SubMix, ReceiverType_FinalMix, }; + static const int BusCountMax{24}; + virtual ReceiverType GetReceiverType() const = 0; - virtual s32 GetChannelCount() const = 0; - virtual s32 GetBusCount() const = 0; - virtual void AddReferenceCount(s32 value) = 0; - virtual bool IsSoundSendClampEnabled(s32 bus) const = 0; + virtual int GetChannelCount() const = 0; + virtual int GetBusCount() const = 0; + virtual void AddReferenceCount(int value) = 0; + virtual bool IsSoundSendClampEnabled(int bus) const = 0; }; static_assert(sizeof(OutputReceiver) == 0x8); diff --git a/include/nn/atk/atk_SequenceTrackAllocator.h b/include/nn/atk/atk_SequenceTrackAllocator.h index e8aa1055..cd260c12 100644 --- a/include/nn/atk/atk_SequenceTrackAllocator.h +++ b/include/nn/atk/atk_SequenceTrackAllocator.h @@ -9,7 +9,10 @@ class SequenceSoundPlayer; class SequenceTrackAllocator { public: virtual ~SequenceTrackAllocator() = default; + virtual SequenceTrack* AllocTrack(SequenceSoundPlayer* player) = 0; + virtual void FreeTrack(SequenceTrack* track) = 0; + virtual int GetAllocatableTrackCount() const = 0; }; static_assert(sizeof(SequenceTrackAllocator) == 0x8); diff --git a/include/nn/atk/atk_SoundStartable.h b/include/nn/atk/atk_SoundStartable.h index 7e586ffe..3ab5756f 100644 --- a/include/nn/atk/atk_SoundStartable.h +++ b/include/nn/atk/atk_SoundStartable.h @@ -10,13 +10,50 @@ namespace nn::atk { class SoundStartable { public: - struct StartInfo { - enum StartOffsetType { - StartOffsetType_MilliSeconds, - StartOffsetType_Tick, - StartOffsetType_Sample, + class StartResult { + public: + enum ResultCode { + ResultCode_Success, + ResultCode_ErrorLowPriority, + ResultCode_ErrorInvalidLabelString, + ResultCode_ErrorInvalidSoundId, + ResultCode_CanceledBySinglePlay, + + ResultCode_ErrorCanceledForPrioritizingOldest = ResultCode_CanceledBySinglePlay, + ResultCode_ErrorNotDataLoaded, + ResultCode_ErrorNotSequenceLoaded, + ResultCode_ErrorNotBankLoaded, + ResultCode_ErrorNotWsdLoaded, + ResultCode_ErrorNotWarcLoaded, + ResultCode_ErrorNotEnoughPlayerHeap, + ResultCode_ErrorCannotOpenFile, + ResultCode_ErrorNotAvailable, + ResultCode_ErrorCannotAllocateTrack, + ResultCode_ErrorNotEnoughInstance, + ResultCode_ErrorInvalidParameter, + ResultCode_ErrorInvalidSequenceStartLocationLabel, + ResultCode_ErrorActorNotInitialized, + ResultCode_ErrorInvalidWarcId, + ResultCode_ErrorInvalidBankData, + ResultCode_ErrorInvalidStreamFileId, + ResultCode_ErrorInvalidStreamFilePath, + + ResultCode_ErrorUser = 128, + ResultCode_ErrorUnknown = 255, }; + StartResult() = default; + explicit StartResult(ResultCode code) : m_Code{code} {} + + bool IsSuccess() const { return m_Code == ResultCode_Success; } + + ResultCode GetCode() const { return m_Code; } + + private: + ResultCode m_Code; + }; + + struct StartInfo { enum EnableFlagBit { EnableFlagBit_StartOffset = 1 << 0, EnableFlagBit_PlayerId = 1 << 1, @@ -37,22 +74,32 @@ class SoundStartable { EnableFlagBit_OutputReceiver = 1 << 16, }; + enum StartOffsetType { + StartOffsetType_MilliSeconds, + StartOffsetType_Tick, + StartOffsetType_Sample, + }; + struct SequenceSoundInfo { - void* sequenceDataAddress; - char* startLocationLabel; + const void* sequenceDataAddress; + const char* startLocationLabel; SoundArchive::ItemId bankIds[4]; + + SequenceSoundInfo() = default; }; static_assert(sizeof(SequenceSoundInfo) == 0x20); struct StreamSoundInfo { - char* externalPath; - void* pExternalData; + const char* externalPath; + const void* pExternalData; size_t externalDataSize; StreamRegionCallback regionCallback; void* regionCallbackArg; - void* prefetchData; + const void* prefetchData; bool forcePlayPrefetchFlag; detail::driver::StreamBufferPool* pStreamBufferPool; + + StreamSoundInfo() = default; }; static_assert(sizeof(StreamSoundInfo) == 0x40); @@ -62,102 +109,85 @@ class SoundStartable { EnableParameterFlagBit_ContextCalculationSkipMode, }; - void* waveAddress; + const void* waveAddress; s8 waveType; u8 m_Padding[3]; - s32 enableParameterFlag; - s32 release; + int enableParameterFlag; + int release; bool isContextCalculationSkipMode; + + WaveSoundInfo() = default; }; static_assert(sizeof(WaveSoundInfo) == 0x18); u32 enableFlag; StartOffsetType startOffsetType; - s32 startOffset; + int startOffset; SoundArchive::ItemId playerId; - s32 playerPriority; - s32 actorPlayerId; + int playerPriority; + int actorPlayerId; SequenceSoundInfo sequenceSoundInfo; StreamSoundInfo streamSoundInfo; SoundArchive::StreamSoundInfo streamSoundMetaInfo; SoundArchive::StreamSoundInfo2 streamSoundMetaInfo2; WaveSoundInfo waveSoundInfo; u8 voiceRendererType; - s32 fadeFrame; + int fadeFrame; SoundStopCallback soundStopCallback; - s32 delayTime; - s32 delayCount; + int delayTime; + int delayCount; UpdateType updateType; - s32 subMixIndex; + int subMixIndex; #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) OutputReceiver* pOutputReceiver; #endif - }; - struct StartResult { - enum ResultCode { - ResultCode_Success, - ResultCode_ErrorLowPriority, - ResultCode_ErrorInvalidLabelString, - ResultCode_ErrorInvalidSoundId, - ResultCode_CanceledBySinglePlay, - ResultCode_ErrorCanceledForPrioritizingOldest = ResultCode_CanceledBySinglePlay, - ResultCode_ErrorNotDataLoaded, - ResultCode_ErrorNotSequenceLoaded, - ResultCode_ErrorNotBankLoaded, - ResultCode_ErrorNotWsdLoaded, - ResultCode_ErrorNotWarcLoaded, - ResultCode_ErrorNotEnoughPlayerHeap, - ResultCode_ErrorCannotOpenFile, - ResultCode_ErrorNotAvailable, - ResultCode_ErrorCannotAllocateTrack, - ResultCode_ErrorNotEnoughInstance, - ResultCode_ErrorInvalidParameter, - ResultCode_ErrorInvalidSequenceStartLocationLabel, - ResultCode_ErrorActorNotInitialized, - ResultCode_ErrorInvalidWarcId, - ResultCode_ErrorInvalidBankData, - ResultCode_ErrorInvalidStreamFileId, - ResultCode_ErrorInvalidStreamFilePath, - - ResultCode_ErrorUser = 0x80, - ResultCode_ErrorUnknown = 0xff, - }; - - ResultCode m_Code; + StartInfo() = default; }; - virtual ~SoundStartable() = 0; + virtual ~SoundStartable() = default; - virtual StartResult detail_SetupSound(SoundHandle* handle, u32 soundId, bool holdFlag, - const char* soundArchiveName, - const StartInfo* startInfo) = 0; + StartResult StartSound(SoundHandle* handle, SoundArchive::ItemId soundId, + const StartInfo* startInfo); - virtual SoundArchive::ItemId detail_GetItemId(char* pString) = 0; - virtual SoundArchive::ItemId detail_GetItemId(char* pString, const char* soundArchiveName) = 0; + StartResult StartSound(SoundHandle* handle, SoundArchive::ItemId soundId, + const char* soundArchiveName, const StartInfo* startInfo); - StartResult StartSound(SoundHandle* handle, u32 soundId, const char* soundArchiveName, - const StartInfo* startInfo); - StartResult StartSound(SoundHandle* handle, u32 soundId, const StartInfo* startInfo); - StartResult StartSound(SoundHandle* handle, const char* pString, const char* soundArchiveName, - const StartInfo* startInfo); - StartResult StartSound(SoundHandle* handle, const char* soundArchiveName, + StartResult StartSound(SoundHandle* handle, const char* soundName, const StartInfo* startInfo); + + StartResult StartSound(SoundHandle* handle, const char* soundName, const char* soundArchiveName, const StartInfo* startInfo); - StartResult HoldSound(SoundHandle* handle, u32 soundId, const char* soundArchiveName, + StartResult HoldSound(SoundHandle* handle, SoundArchive::ItemId soundId, const StartInfo* startInfo); - StartResult HoldSound(SoundHandle* handle, u32 soundId, const StartInfo* startInfo); - StartResult HoldSound(SoundHandle* handle, const char* pString, const StartInfo* startInfo); - StartResult HoldSound(SoundHandle* handle, const char* pString, const char* soundArchiveName, + + StartResult HoldSound(SoundHandle* handle, SoundArchive::ItemId soundId, + const char* soundArchiveName, const StartInfo* startInfo); + + StartResult HoldSound(SoundHandle* handle, const char* soundLabel, const StartInfo* startInfo); + + StartResult HoldSound(SoundHandle* handle, const char* soundLabel, const char* soundArchiveName, const StartInfo* startInfo); - StartResult PrepareSound(SoundHandle* handle, u32 soundId, const char* soundArchiveName, - const StartInfo* startInfo); - StartResult PrepareSound(SoundHandle* handle, u32 soundId, const StartInfo* startInfo); - StartResult PrepareSound(SoundHandle* handle, const char* pString, const char* soundArchiveName, + StartResult PrepareSound(SoundHandle* handle, SoundArchive::ItemId soundId, const StartInfo* startInfo); - StartResult PrepareSound(SoundHandle* handle, const char* soundArchiveName, + + StartResult PrepareSound(SoundHandle* handle, SoundArchive::ItemId soundId, + const char* soundArchiveName, const StartInfo* startInfo); + + StartResult PrepareSound(SoundHandle* handle, const char* soundName, const StartInfo* startInfo); + + StartResult PrepareSound(SoundHandle* handle, const char* soundName, + const char* soundArchiveName, const StartInfo* startInfo); + +protected: + virtual StartResult detail_SetupSound(SoundHandle* handle, u32 soundId, bool holdFlag, + const char* soundArchiveName, + const StartInfo* startInfo) = 0; + + virtual SoundArchive::ItemId detail_GetItemId(char* pString) = 0; + virtual SoundArchive::ItemId detail_GetItemId(char* pString, const char* soundArchiveName) = 0; }; static_assert(sizeof(SoundStartable) == 0x8); diff --git a/include/nn/atk/atk_WaveSoundFileReader.h b/include/nn/atk/atk_WaveSoundFileReader.h index 09f75faa..c1f5ff93 100644 --- a/include/nn/atk/atk_WaveSoundFileReader.h +++ b/include/nn/atk/atk_WaveSoundFileReader.h @@ -27,7 +27,7 @@ struct WaveSoundNoteInfo { u8 volume; float pitch; - WaveSoundNoteInfo() : adshr(0, 0, 0, 0, 0){}; + WaveSoundNoteInfo() : adshr(0, 0, 0, 0, 0) {}; }; static_assert(sizeof(WaveSoundNoteInfo) == 0x18); diff --git a/include/nn/atk/detail/atk_BinaryTypes.h b/include/nn/atk/detail/atk_BinaryTypes.h index ec91e936..3fb69fcd 100644 --- a/include/nn/atk/detail/atk_BinaryTypes.h +++ b/include/nn/atk/detail/atk_BinaryTypes.h @@ -6,21 +6,27 @@ namespace nn::atk::detail { struct BinaryTypes { - NN_NO_COPY(BinaryTypes); - NN_NO_MOVE(BinaryTypes); - - template - struct Table { - CountType count; - T item[1]; - }; + static const u32 InvalidOffset{0xffffffff}; + static const u32 InvalidSize{0xffffffff}; struct Reference { u32 offset; + + static const u32 InvalidOffset{BinaryTypes::InvalidOffset}; + + bool IsValidOffset() const { return offset != InvalidOffset; } }; static_assert(sizeof(Reference) == 0x4); - struct ReferenceTable : Table {}; + template + struct Table { + CountType count; + ItemType item[1]; + }; + + struct ReferenceTable : Table { + const void* GetReferedItem(int index) const; + }; }; }; // namespace nn::atk::detail diff --git a/include/nn/atk/detail/atk_IntrusiveList.h b/include/nn/atk/detail/atk_IntrusiveList.h index 4c8121ba..79387b41 100644 --- a/include/nn/atk/detail/atk_IntrusiveList.h +++ b/include/nn/atk/detail/atk_IntrusiveList.h @@ -6,11 +6,11 @@ namespace nn::atk::detail { using IntrusiveListNode = util::IntrusiveListNode; -template +template class IntrusiveList { public: using ElementList = - util::IntrusiveList>; + util::IntrusiveList>; using Iterator = typename ElementList::iterator; using ConstIterator = typename ElementList::const_iterator; diff --git a/include/nn/atk/detail/atk_SoundArchiveManager.h b/include/nn/atk/detail/atk_SoundArchiveManager.h index b52d8087..a92f0e82 100644 --- a/include/nn/atk/detail/atk_SoundArchiveManager.h +++ b/include/nn/atk/detail/atk_SoundArchiveManager.h @@ -13,11 +13,28 @@ class SoundArchiveManager { class SnapShot { public: + SnapShot(const SoundArchive& mainSoundArchive, const SoundDataManager& mainSoundDataManager, + const SoundArchive& currentSoundArchive, + const SoundDataManager& currentSoundDataManager) + : m_MainSoundArchive{mainSoundArchive}, m_MainSoundDataManager{mainSoundDataManager}, + m_CurrentSoundArchive{currentSoundArchive}, + m_CurrentSoundDataManager{currentSoundDataManager} {} + + const SoundArchive& GetMainSoundArchive() const { return m_MainSoundArchive; } + + const SoundDataManager& GetMainSoundDataManager() const { return m_MainSoundDataManager; } + + const SoundArchive& GetCurrentSoundArchive() const { return m_CurrentSoundArchive; } + + const SoundDataManager& GetCurrentSoundDataManager() const { + return m_CurrentSoundDataManager; + } + private: - SoundArchive* m_MainSoundArchive; - SoundDataManager* m_MainSoundDataManager; - SoundArchive* m_CurrentSoundArchive; - SoundDataManager* m_CurrentSoundDataManager; + const SoundArchive& m_MainSoundArchive; + const SoundDataManager& m_MainSoundDataManager; + const SoundArchive& m_CurrentSoundArchive; + const SoundDataManager& m_CurrentSoundDataManager; }; SoundArchiveManager(); diff --git a/include/nn/atk/fnd/basis/atkfnd_Result.h b/include/nn/atk/fnd/basis/atkfnd_Result.h index 6fb02177..49e665c7 100644 --- a/include/nn/atk/fnd/basis/atkfnd_Result.h +++ b/include/nn/atk/fnd/basis/atkfnd_Result.h @@ -36,9 +36,9 @@ class FndResult { public: FndResult() = default; - explicit FndResult(u32 value) : value{value}{}; + explicit FndResult(u32 value) : value{value} {}; - explicit FndResult(FndResultType value) : value(value){}; + explicit FndResult(FndResultType value) : value(value) {}; bool IsSucceeded() const { return !IsFailed(); } diff --git a/src/NintendoWare/atk/atk_SoundHandle.cpp b/src/NintendoWare/atk/atk_SoundHandle.cpp index 8b137891..f222e5bc 100644 --- a/src/NintendoWare/atk/atk_SoundHandle.cpp +++ b/src/NintendoWare/atk/atk_SoundHandle.cpp @@ -1 +1 @@ - +#include diff --git a/src/NintendoWare/atk/atk_SoundStartable.cpp b/src/NintendoWare/atk/atk_SoundStartable.cpp index 8b137891..9752a2fe 100644 --- a/src/NintendoWare/atk/atk_SoundStartable.cpp +++ b/src/NintendoWare/atk/atk_SoundStartable.cpp @@ -1 +1,15 @@ +#include +namespace nn::atk { + +SoundStartable::StartResult SoundStartable::StartSound(SoundHandle* handle, SoundArchive::ItemId soundId, const char* soundArchiveName, const StartInfo* startInfo) { + StartResult result{detail_SetupSound(handle, soundId, false, soundArchiveName, startInfo)}; + + if (!result.IsSuccess()) + return result; + + // StartResult result2{handle->StartPrepared()}; + // return result2; +} + +} // namespace nn::atk From 6a9af5ed99696aa029a092b1be589ae1e20996b0 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 15 Sep 2026 13:42:07 -0300 Subject: [PATCH 755/785] atk: Match `SoundHandle::DetachSound` --- include/nn/atk/atk_BasicSound.h | 2 + include/nn/atk/atk_SoundHandle.h | 302 ++++++++++++++++++++++- src/NintendoWare/atk/atk_SoundHandle.cpp | 27 ++ 3 files changed, 319 insertions(+), 12 deletions(-) diff --git a/include/nn/atk/atk_BasicSound.h b/include/nn/atk/atk_BasicSound.h index 76ab1f89..b897258f 100644 --- a/include/nn/atk/atk_BasicSound.h +++ b/include/nn/atk/atk_BasicSound.h @@ -538,6 +538,8 @@ class BasicSound { bool IsPlayerAvailable() const { return m_PlayerAvailableFlag; } private: + friend SoundHandle; + void UpdateParam(); void ClearIsFinalizedForCannotAllocatedResourceFlag(); diff --git a/include/nn/atk/atk_SoundHandle.h b/include/nn/atk/atk_SoundHandle.h index 19b82b27..50d571d3 100644 --- a/include/nn/atk/atk_SoundHandle.h +++ b/include/nn/atk/atk_SoundHandle.h @@ -6,6 +6,14 @@ namespace nn::atk { class SoundHandle { public: + enum PauseState { + PauseState_Normal, + PauseState_Pausing, + PauseState_Paused, + PauseState_Unpausing, + PauseState_Invalid, + }; + enum MuteState { MuteState_Normal, MuteState_Muting, @@ -14,27 +22,297 @@ class SoundHandle { MuteState_Invalid, }; - enum PauseState { - PauseState_Normal, - PauseState_Pausing, - PauseState_Paused, - PauseState_Unpausing, - PauseState_Invalid - }; - + SoundHandle() = default; ~SoundHandle() = default; - void detail_DuplicateHandle(SoundHandle* other); + void StartPrepared() { + if (IsAttachedSound()) + m_pSound->StartPrepared(); + } + + void Stop(int fadeFrames) { + if (IsAttachedSound()) + m_pSound->Stop(fadeFrames); + } + + void Pause(bool flag, int fadeFrames) { + if (IsAttachedSound()) + m_pSound->Pause(flag, fadeFrames); + } + + void Pause(bool flag, int fadeFrames, PauseMode pauseMode) { + if (IsAttachedSound()) + m_pSound->Pause(flag, fadeFrames, pauseMode); + } + + void Mute(bool flag, int fadeFrames) { + if (IsAttachedSound()) + m_pSound->Mute(flag, fadeFrames); + } + + bool IsPrepared() const { + if (!IsAttachedSound()) + return false; + + return m_pSound->IsPrepared(); + } + + bool IsPause() const { + if (!IsAttachedSound()) + return false; + + return m_pSound->IsPause(); + } + + bool IsMute() const { + if (!IsAttachedSound()) + return false; + + return m_pSound->IsMute(); + } + + PauseState GetPauseState() const { + if (!IsAttachedSound()) + return PauseState_Invalid; + + return static_cast(m_pSound->GetPauseState()); + } + + MuteState GetMuteState() const { + if (!IsAttachedSound()) + return MuteState_Invalid; + + return static_cast(m_pSound->GetMuteState()); + } + + void FadeIn(int frames) { + if (IsAttachedSound()) + m_pSound->FadeIn(frames); + } + + int GetRemainingFadeFrames() const { + if (!IsAttachedSound()) + return 0; + + return m_pSound->GetRemainingFadeFrames(); + } + + int GetRemainingPauseFadeFrames() const { + if (!IsAttachedSound()) + return 0; + + return m_pSound->GetRemainingPauseFadeFrames(); + } + + u32 GetPlayFrameCount() const { + if (!IsAttachedSound()) + return 0; + + return m_pSound->GetPlayFrameCount(); + } + + int GetRemainingMuteFadeFrames() const { + if (!IsAttachedSound()) + return 0; + + return m_pSound->GetRemainingMuteFadeFrames(); + } + + void SetVolume(float volume, int frames) { + if (IsAttachedSound()) + m_pSound->SetVolume(volume, frames); + } + +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) + void SetVolumeThroughMode(int bus, u8 modeBitFlag) { + if (IsAttachedSound()) + m_pSound->SetVolumeThroughMode(bus, modeBitFlag); + } +#endif + + void SetPan(float pan) { + if (IsAttachedSound()) + m_pSound->SetPan(pan); + } + + void SetSurroundPan(float span) { + if (IsAttachedSound()) + m_pSound->SetSurroundPan(span); + } + + void SetMixMode(MixMode mixMode) { + if (IsAttachedSound()) + m_pSound->SetMixMode(mixMode); + } + +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) + // UNCHECKED + void SetMixVolume(int subMixBus, const MixVolume& mixVolume) { + if (IsAttachedSound()) + m_pSound->SetOutputBusMixVolume(OutputDevice_Main, 0, subMixBus, + {mixVolume.channel, 6}); + } + + // UNCHECKED + void SetBusMixVolumeEnabled(int subMixBus, bool isEnabled) { + if (IsAttachedSound()) + m_pSound->SetOutputBusMixVolumeEnabled(OutputDevice_Main, subMixBus, isEnabled); + } + + // UNCHECKED + void SetBusMixVolume(int srcChNo, int subMixBus, const ChannelMixVolume& param) { + if (IsAttachedSound()) + m_pSound->SetOutputBusMixVolume(OutputDevice_Main, srcChNo, subMixBus, param); + } + + // UNCHECKED + void SetMixVolume(const MixVolume& mixVolume) { + if (IsAttachedSound()) + m_pSound->SetOutputBusMixVolume(OutputDevice_Main, 0, 0, {mixVolume.channel, 6}); + } + + // UNCHECKED + void SetBusMixVolume(int subMixBus, const ChannelMixVolume& param) { + if (IsAttachedSound()) + m_pSound->SetOutputBusMixVolume(OutputDevice_Main, 0, subMixBus, param); + } +#endif + + void SetMainSend(float send) { + if (IsAttachedSound()) + m_pSound->SetMainSend(send); + } + + void SetEffectSend(AuxBus bus, float send) { + if (IsAttachedSound()) + m_pSound->SetFxSend(bus, send); + } + +#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) + void SetSend(int bus, float send) { + if (IsAttachedSound()) + m_pSound->SetSend(bus, send); + } +#endif + + void SetPitch(float pitch) { + if (IsAttachedSound()) + m_pSound->SetPitch(pitch); + } + + void SetLowPassFilterFrequency(float lpfFreq) { + if (IsAttachedSound()) + m_pSound->SetLpfFreq(lpfFreq); + } + + void SetBiquadFilter(int type, float value) { + if (IsAttachedSound()) + m_pSound->SetBiquadFilter(type, value); + } + + void SetPlayerPriority(int priority) { + if (IsAttachedSound()) + m_pSound->SetPlayerPriority(priority); + } + + void SetOutputLine(u32 lineFlag) { + if (IsAttachedSound()) + m_pSound->SetOutputLine(lineFlag); + } + + void ResetOutputLine() { + if (IsAttachedSound()) + m_pSound->ResetOutputLine(); + } + + void SetOutputVolume(OutputDevice device, float volume) { + if (IsAttachedSound()) + m_pSound->SetOutputVolume(device, volume); + } + + void SetOutputPan(OutputDevice device, float pan) { + if (IsAttachedSound()) + m_pSound->SetOutputPan(device, pan); + } + + void SetOutputSurroundPan(OutputDevice device, float span) { + if (IsAttachedSound()) + m_pSound->SetOutputSurroundPan(device, span); + } + + void SetOutputMainSend(OutputDevice device, float send) { + if (IsAttachedSound()) + m_pSound->SetOutputMainSend(device, send); + } + + void SetOutputEffectSend(OutputDevice device, AuxBus bus, float send) { + if (IsAttachedSound()) + m_pSound->SetOutputFxSend(device, bus, send); + } + + bool IsAttachedSound() const { return m_pSound != nullptr; } void DetachSound(); - void detail_AttachSoundAsTempHandle(detail::BasicSound* sound); + u32 GetId() const { + if (IsAttachedSound()) + return m_pSound->GetId(); + + return InvalidSoundId; + } + + const SoundParam* GetAmbientParam() const { + if (IsAttachedSound()) + return &m_pSound->GetAmbientParam(); + + return nullptr; + } + + void* GetUserParam() const { + if (IsAttachedSound()) + return m_pSound->GetUserParam(); + + return nullptr; + } + + bool CalculateSoundParamCalculationValues(SoundParamCalculationValues* pOutValue) const; + + // UNCHECKED + void SetChannelMixParameter(u32 srcChNo, const MixParameter& param) { + if (IsAttachedSound()) + m_pSound->SetOutputChannelMixParameter(OutputDevice_Main, srcChNo, param); + } + + // UNCHECKED + void SetChannelMixParameter(const MixParameter& param) { + if (IsAttachedSound()) + m_pSound->SetOutputChannelMixParameter(OutputDevice_Main, 0, param); + } + + void SetOutputChannelMixParameter(OutputDevice device, u32 srcChNo, const MixParameter& param) { + if (IsAttachedSound()) + m_pSound->SetOutputChannelMixParameter(device, srcChNo, param); + } + + void SetOutputChannelMixParameter(OutputDevice device, const MixParameter& param) { + if (IsAttachedSound()) + m_pSound->SetOutputChannelMixParameter(device, 0, param); + } + void detail_AttachSound(detail::BasicSound* sound); - void CalculateSoundParamCalculationValues(SoundParamCalculationValues* calcValues) const; + void detail_AttachSoundAsTempHandle(detail::BasicSound* sound); + + detail::BasicSound* detail_GetAttachedSound() { return m_pSound; } + + const detail::BasicSound* detail_GetAttachedSound() const { return m_pSound; } + + void detail_DuplicateHandle(SoundHandle* handle); private: - detail::BasicSound* m_pSound; + NN_NO_COPY(SoundHandle); + + detail::BasicSound* m_pSound{}; }; static_assert(sizeof(SoundHandle) == 0x8); diff --git a/src/NintendoWare/atk/atk_SoundHandle.cpp b/src/NintendoWare/atk/atk_SoundHandle.cpp index f222e5bc..00982daa 100644 --- a/src/NintendoWare/atk/atk_SoundHandle.cpp +++ b/src/NintendoWare/atk/atk_SoundHandle.cpp @@ -1 +1,28 @@ #include + +namespace nn::atk { + +void SoundHandle::detail_DuplicateHandle(SoundHandle* handle) { + + detail::BasicSound* sound{m_pSound}; + + DetachSound(); + + // if (handle != nullptr) + // handle->detail_AttachSoundAsTempHandle(sound); +} + +void SoundHandle::DetachSound() { + if (IsAttachedSound()) { + if (m_pSound->m_pGeneralHandle == this) + m_pSound->m_pGeneralHandle = nullptr; + + if (m_pSound->m_pTempGeneralHandle == this) + m_pSound->m_pTempGeneralHandle = nullptr; + + if (m_pSound != nullptr) + m_pSound = nullptr; + } +} + +} // namespace nn::atk \ No newline at end of file From 17e359af6997298580f1386716f76f42f6059f81 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 15 Sep 2026 13:42:27 -0300 Subject: [PATCH 756/785] atk: Match `SoundHandle::detail_AttachSoundAsTempHandle` --- src/NintendoWare/atk/atk_SoundHandle.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/atk_SoundHandle.cpp b/src/NintendoWare/atk/atk_SoundHandle.cpp index 00982daa..062a4e94 100644 --- a/src/NintendoWare/atk/atk_SoundHandle.cpp +++ b/src/NintendoWare/atk/atk_SoundHandle.cpp @@ -12,6 +12,15 @@ void SoundHandle::detail_DuplicateHandle(SoundHandle* handle) { // handle->detail_AttachSoundAsTempHandle(sound); } +void SoundHandle::detail_AttachSoundAsTempHandle(detail::BasicSound* sound) { + m_pSound = sound; + + if (m_pSound->IsAttachedTempGeneralHandle()) + m_pSound->DetachTempGeneralHandle(); + + m_pSound->m_pTempGeneralHandle = this; +} + void SoundHandle::DetachSound() { if (IsAttachedSound()) { if (m_pSound->m_pGeneralHandle == this) From 1151eabb4605cba3f493c6d144f799cf1cfc486c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 15 Sep 2026 13:56:03 -0300 Subject: [PATCH 757/785] atk: Match `SoundHandle::detail_DuplicateHandle` --- src/NintendoWare/atk/atk_SoundHandle.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/NintendoWare/atk/atk_SoundHandle.cpp b/src/NintendoWare/atk/atk_SoundHandle.cpp index 062a4e94..d4227805 100644 --- a/src/NintendoWare/atk/atk_SoundHandle.cpp +++ b/src/NintendoWare/atk/atk_SoundHandle.cpp @@ -3,13 +3,15 @@ namespace nn::atk { void SoundHandle::detail_DuplicateHandle(SoundHandle* handle) { + DetachSound(); - detail::BasicSound* sound{m_pSound}; + if (handle == nullptr) + return; - DetachSound(); + detail::BasicSound* sound{handle->m_pSound}; - // if (handle != nullptr) - // handle->detail_AttachSoundAsTempHandle(sound); + if (handle->IsAttachedSound()) + detail_AttachSoundAsTempHandle(sound); } void SoundHandle::detail_AttachSoundAsTempHandle(detail::BasicSound* sound) { @@ -34,4 +36,4 @@ void SoundHandle::DetachSound() { } } -} // namespace nn::atk \ No newline at end of file +} // namespace nn::atk From f088cd05ca45b74f703020ec6177406629df087f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 15 Sep 2026 13:56:19 -0300 Subject: [PATCH 758/785] atk: Match `SoundHandle::detail_AttachSound` --- src/NintendoWare/atk/atk_SoundHandle.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/atk_SoundHandle.cpp b/src/NintendoWare/atk/atk_SoundHandle.cpp index d4227805..12562cb7 100644 --- a/src/NintendoWare/atk/atk_SoundHandle.cpp +++ b/src/NintendoWare/atk/atk_SoundHandle.cpp @@ -23,6 +23,15 @@ void SoundHandle::detail_AttachSoundAsTempHandle(detail::BasicSound* sound) { m_pSound->m_pTempGeneralHandle = this; } +void SoundHandle::detail_AttachSound(detail::BasicSound* sound) { + m_pSound = sound; + + if (m_pSound->IsAttachedGeneralHandle()) + m_pSound->DetachGeneralHandle(); + + m_pSound->m_pGeneralHandle = this; +} + void SoundHandle::DetachSound() { if (IsAttachedSound()) { if (m_pSound->m_pGeneralHandle == this) From 3201fa24c8fe74a8bc99ebd24a99c06bdb4c212f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 15 Sep 2026 13:57:46 -0300 Subject: [PATCH 759/785] atk: Match `SoundHandle::CalculateSoundParamCalculationValues` This matches all exported functions in `SoundHandle` --- src/NintendoWare/atk/atk_SoundHandle.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/atk_SoundHandle.cpp b/src/NintendoWare/atk/atk_SoundHandle.cpp index 12562cb7..23165664 100644 --- a/src/NintendoWare/atk/atk_SoundHandle.cpp +++ b/src/NintendoWare/atk/atk_SoundHandle.cpp @@ -45,4 +45,13 @@ void SoundHandle::DetachSound() { } } +bool SoundHandle::CalculateSoundParamCalculationValues( + SoundParamCalculationValues* pOutValue) const { + if (!IsAttachedSound()) + return false; + + m_pSound->CalculateSoundParamCalculationValues(pOutValue); + return true; +} + } // namespace nn::atk From 3bede4a70e0c0991ee70b98537a196d00617d04b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 15 Sep 2026 14:08:13 -0300 Subject: [PATCH 760/785] atk: Match `Bank::NoteOn` on versions lower than 4.0.0 --- include/nn/atk/atk_Channel.h | 3 +++ include/nn/atk/atk_NoteOnCallback.h | 12 ++++++------ include/nn/atk/atk_PlayerHeap.h | 2 +- src/NintendoWare/atk/detail/seq/atk_Bank.cpp | 1 + 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/nn/atk/atk_Channel.h b/include/nn/atk/atk_Channel.h index 12138ee4..3456aa72 100644 --- a/include/nn/atk/atk_Channel.h +++ b/include/nn/atk/atk_Channel.h @@ -166,6 +166,9 @@ class Channel { void SetUpdateType(UpdateType updateType) { m_pVoice->SetUpdateType(updateType); } UpdateType GetUpdateType() const { return m_pVoice->GetUpdateType(); } + + void SetSubMixIndex(int index) { m_pVoice->SetSubMixIndex(index); } + #if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) void SetOutputReceiver(OutputReceiver* pOutputReceiver) { m_pVoice->SetOutputReceiver(pOutputReceiver); diff --git a/include/nn/atk/atk_NoteOnCallback.h b/include/nn/atk/atk_NoteOnCallback.h index 364ef195..ef81be16 100644 --- a/include/nn/atk/atk_NoteOnCallback.h +++ b/include/nn/atk/atk_NoteOnCallback.h @@ -15,16 +15,16 @@ struct NoteOnInfo { int priority; Channel::ChannelCallback channelCallback; void* channelCallbackData; -#if NN_SDK_VER >= NN_MAKE_VER(4, 0, 0) +#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) + UpdateType updateType; + int subMixIndex; + int finalMixIndex; +#else OutputReceiver* pOutputReceiver; -#endif UpdateType updateType; +#endif }; -#if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) -static_assert(sizeof(NoteOnInfo) == 0x30); -#else static_assert(sizeof(NoteOnInfo) == 0x38); -#endif class NoteOnCallback { public: diff --git a/include/nn/atk/atk_PlayerHeap.h b/include/nn/atk/atk_PlayerHeap.h index 975d9b57..e6c07cca 100644 --- a/include/nn/atk/atk_PlayerHeap.h +++ b/include/nn/atk/atk_PlayerHeap.h @@ -62,7 +62,7 @@ class PlayerHeap : public SoundMemoryAllocatable { void* m_pEndAddress{}; void* m_pAllocAddress{}; u8 m_State{State_Constructed}; - u8 m_Padding[3]; + [[maybe_unused]] u8 m_Padding[3]; public: util::IntrusiveListNode m_Link; diff --git a/src/NintendoWare/atk/detail/seq/atk_Bank.cpp b/src/NintendoWare/atk/detail/seq/atk_Bank.cpp index 08e500d2..cd09ccd5 100644 --- a/src/NintendoWare/atk/detail/seq/atk_Bank.cpp +++ b/src/NintendoWare/atk/detail/seq/atk_Bank.cpp @@ -63,6 +63,7 @@ Channel* Bank::NoteOn(const BankFileReader& bankReader, const WaveArchiveFileRea pChannel->SetInterpolationType(regionInfo.interpolationType); pChannel->SetUpdateType(noteOnInfo.updateType); #if NN_SDK_VER < NN_MAKE_VER(4, 0, 0) + pChannel->SetSubMixIndex(noteOnInfo.subMixIndex); pChannel->Start(waveInfo, noteOnInfo.length, 0); #else pChannel->SetOutputReceiver(noteOnInfo.pOutputReceiver); From c58eaeee05e1c3bbb3e153a6a443a14ad98c5709 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 15 Sep 2026 14:32:30 -0300 Subject: [PATCH 761/785] atk: Match `SoundStartable::StartSound` (1) --- src/NintendoWare/atk/atk_SoundStartable.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/NintendoWare/atk/atk_SoundStartable.cpp b/src/NintendoWare/atk/atk_SoundStartable.cpp index 9752a2fe..65948358 100644 --- a/src/NintendoWare/atk/atk_SoundStartable.cpp +++ b/src/NintendoWare/atk/atk_SoundStartable.cpp @@ -2,14 +2,18 @@ namespace nn::atk { -SoundStartable::StartResult SoundStartable::StartSound(SoundHandle* handle, SoundArchive::ItemId soundId, const char* soundArchiveName, const StartInfo* startInfo) { +SoundStartable::StartResult SoundStartable::StartSound(SoundHandle* handle, + SoundArchive::ItemId soundId, + const char* soundArchiveName, + const StartInfo* startInfo) { StartResult result{detail_SetupSound(handle, soundId, false, soundArchiveName, startInfo)}; - - if (!result.IsSuccess()) + + if (!result.IsSuccess() || !handle->IsAttachedSound()) return result; - - // StartResult result2{handle->StartPrepared()}; - // return result2; + + handle->StartPrepared(); + StartResult result2{StartResult::ResultCode_Success}; + return result2; } } // namespace nn::atk From 8ebd52b2e3e31cacea9ea692e940997452679435 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 15 Sep 2026 14:34:26 -0300 Subject: [PATCH 762/785] atk: Match `SoundStartable::StartSound` (2) --- src/NintendoWare/atk/atk_SoundStartable.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/atk_SoundStartable.cpp b/src/NintendoWare/atk/atk_SoundStartable.cpp index 65948358..ff3a2822 100644 --- a/src/NintendoWare/atk/atk_SoundStartable.cpp +++ b/src/NintendoWare/atk/atk_SoundStartable.cpp @@ -16,4 +16,8 @@ SoundStartable::StartResult SoundStartable::StartSound(SoundHandle* handle, return result2; } +SoundStartable::StartResult SoundStartable::StartSound(SoundHandle* handle, SoundArchive::ItemId soundId, const StartInfo* startInfo) { + return StartSound(handle, soundId, nullptr, startInfo); +} + } // namespace nn::atk From be51df20748f7f302d12d49e2e4879cc71a85251 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 15 Sep 2026 14:53:57 -0300 Subject: [PATCH 763/785] atk: Match `SoundStartable::StartSound` (3) --- include/nn/atk/atk_SoundArchivePlayer.h | 4 ++-- include/nn/atk/atk_SoundStartable.h | 5 +++-- src/NintendoWare/atk/atk_SoundStartable.cpp | 16 +++++++++++++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/include/nn/atk/atk_SoundArchivePlayer.h b/include/nn/atk/atk_SoundArchivePlayer.h index 41ca66ed..55c78c19 100644 --- a/include/nn/atk/atk_SoundArchivePlayer.h +++ b/include/nn/atk/atk_SoundArchivePlayer.h @@ -180,8 +180,8 @@ class SoundArchivePlayer : SoundStartable { Result CheckStreamSoundFileExisting(const char*, const char*) const; Result CheckStreamSoundFileExisting(const SoundArchive*, u32) const; - SoundArchive::ItemId detail_GetItemId(char* pString) override; - SoundArchive::ItemId detail_GetItemId(char* pString, const char* soundArchiveName) override; + SoundArchive::ItemId detail_GetItemId(const char* pString) override; + SoundArchive::ItemId detail_GetItemId(const char* pString, const char* soundArchiveName) override; private: detail::SoundArchiveManager m_SoundArchiveManager; diff --git a/include/nn/atk/atk_SoundStartable.h b/include/nn/atk/atk_SoundStartable.h index 3ab5756f..413aa5eb 100644 --- a/include/nn/atk/atk_SoundStartable.h +++ b/include/nn/atk/atk_SoundStartable.h @@ -186,8 +186,9 @@ class SoundStartable { const char* soundArchiveName, const StartInfo* startInfo) = 0; - virtual SoundArchive::ItemId detail_GetItemId(char* pString) = 0; - virtual SoundArchive::ItemId detail_GetItemId(char* pString, const char* soundArchiveName) = 0; + virtual SoundArchive::ItemId detail_GetItemId(const char* soundName) = 0; + virtual SoundArchive::ItemId detail_GetItemId(const char* soundName, + const char* soundArchiveName) = 0; }; static_assert(sizeof(SoundStartable) == 0x8); diff --git a/src/NintendoWare/atk/atk_SoundStartable.cpp b/src/NintendoWare/atk/atk_SoundStartable.cpp index ff3a2822..4545c257 100644 --- a/src/NintendoWare/atk/atk_SoundStartable.cpp +++ b/src/NintendoWare/atk/atk_SoundStartable.cpp @@ -16,8 +16,22 @@ SoundStartable::StartResult SoundStartable::StartSound(SoundHandle* handle, return result2; } -SoundStartable::StartResult SoundStartable::StartSound(SoundHandle* handle, SoundArchive::ItemId soundId, const StartInfo* startInfo) { +SoundStartable::StartResult SoundStartable::StartSound(SoundHandle* handle, + SoundArchive::ItemId soundId, + const StartInfo* startInfo) { return StartSound(handle, soundId, nullptr, startInfo); } +SoundStartable::StartResult SoundStartable::StartSound(SoundHandle* handle, const char* soundName, + const char* soundArchiveName, + const StartInfo* startInfo) { + u32 soundId{detail_GetItemId(soundName, soundArchiveName)}; + + if (soundId == InvalidSoundId) + return StartResult{StartResult::ResultCode_ErrorInvalidLabelString}; + + StartResult result{StartSound(handle, soundId, soundArchiveName, startInfo)}; + return result; +} + } // namespace nn::atk From eb44186ec142629745220c5679440d41a5ed12c0 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 15 Sep 2026 14:55:04 -0300 Subject: [PATCH 764/785] atk: Match `SoundStartable::StartSound` (4) --- src/NintendoWare/atk/atk_SoundStartable.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/atk_SoundStartable.cpp b/src/NintendoWare/atk/atk_SoundStartable.cpp index 4545c257..02b754ed 100644 --- a/src/NintendoWare/atk/atk_SoundStartable.cpp +++ b/src/NintendoWare/atk/atk_SoundStartable.cpp @@ -34,4 +34,9 @@ SoundStartable::StartResult SoundStartable::StartSound(SoundHandle* handle, cons return result; } +SoundStartable::StartResult SoundStartable::StartSound(SoundHandle* handle, const char* soundName, + const StartInfo* startInfo) { + return StartSound(handle, soundName, nullptr, startInfo); +} + } // namespace nn::atk From a69e6ee44386a7497df8f17e424a6576a2017c36 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 15 Sep 2026 17:39:32 -0300 Subject: [PATCH 765/785] atk: Match `SoundStartable::HoldSound` (1) --- include/nn/atk/atk_SoundHandle.h | 8 +++--- src/NintendoWare/atk/atk_SoundStartable.cpp | 27 +++++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/include/nn/atk/atk_SoundHandle.h b/include/nn/atk/atk_SoundHandle.h index 50d571d3..d2bf5bd0 100644 --- a/include/nn/atk/atk_SoundHandle.h +++ b/include/nn/atk/atk_SoundHandle.h @@ -255,10 +255,10 @@ class SoundHandle { void DetachSound(); u32 GetId() const { - if (IsAttachedSound()) - return m_pSound->GetId(); - - return InvalidSoundId; + if (!IsAttachedSound()) + return InvalidSoundId; + + return m_pSound->GetId(); } const SoundParam* GetAmbientParam() const { diff --git a/src/NintendoWare/atk/atk_SoundStartable.cpp b/src/NintendoWare/atk/atk_SoundStartable.cpp index 02b754ed..22c3b600 100644 --- a/src/NintendoWare/atk/atk_SoundStartable.cpp +++ b/src/NintendoWare/atk/atk_SoundStartable.cpp @@ -39,4 +39,31 @@ SoundStartable::StartResult SoundStartable::StartSound(SoundHandle* handle, cons return StartSound(handle, soundName, nullptr, startInfo); } +SoundStartable::StartResult SoundStartable::HoldSound(SoundHandle* handle, + SoundArchive::ItemId soundId, + const char* soundArchiveName, + const StartInfo* startInfo) { + if (handle->IsAttachedSound() && handle->GetId() == soundId) { + handle->detail_GetAttachedSound()->SetAutoStopCounter(1); + } else { + StartResult result{detail_SetupSound(handle, soundId, true, soundArchiveName, startInfo)}; + + if (!result.IsSuccess()) + return result; + + handle->StartPrepared(); + handle->detail_GetAttachedSound()->SetAutoStopCounter(1); + } + + StartResult result{StartResult::ResultCode_Success}; + + if (startInfo != nullptr && (startInfo->enableFlag & StartInfo::EnableFlagBit_FadeFrame) != 0) { + handle->Stop(startInfo->fadeFrame); + StartResult result2{StartResult::ResultCode_Success}; + return result2; + } + + return result; +} + } // namespace nn::atk From 2b6f13ba5b3bec9ff275c378445a1653876b59cd Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 15 Sep 2026 17:52:24 -0300 Subject: [PATCH 766/785] atk: Match `SoundStartable::HoldSound` (2) --- src/NintendoWare/atk/atk_SoundStartable.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NintendoWare/atk/atk_SoundStartable.cpp b/src/NintendoWare/atk/atk_SoundStartable.cpp index 22c3b600..abd05391 100644 --- a/src/NintendoWare/atk/atk_SoundStartable.cpp +++ b/src/NintendoWare/atk/atk_SoundStartable.cpp @@ -66,4 +66,9 @@ SoundStartable::StartResult SoundStartable::HoldSound(SoundHandle* handle, return result; } +SoundStartable::StartResult SoundStartable::HoldSound(SoundHandle* handle, SoundArchive::ItemId soundId, const StartInfo* startInfo) { + StartResult result{HoldSound(handle, soundId, nullptr, startInfo)}; + return result; +} + } // namespace nn::atk From bf7ee0fcf3a69e462a5b81e269e81628601d6df6 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 15 Sep 2026 17:59:27 -0300 Subject: [PATCH 767/785] atk: Match `SoundStartable::HoldSound` (3) --- src/NintendoWare/atk/atk_SoundStartable.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NintendoWare/atk/atk_SoundStartable.cpp b/src/NintendoWare/atk/atk_SoundStartable.cpp index abd05391..c79bd50e 100644 --- a/src/NintendoWare/atk/atk_SoundStartable.cpp +++ b/src/NintendoWare/atk/atk_SoundStartable.cpp @@ -71,4 +71,13 @@ SoundStartable::StartResult SoundStartable::HoldSound(SoundHandle* handle, Sound return result; } +SoundStartable::StartResult SoundStartable::HoldSound(SoundHandle* handle, const char* soundLabel, const char* soundArchiveName, const StartInfo* startInfo) { + u32 soundId{detail_GetItemId(soundLabel, soundArchiveName)}; + + if (soundId == InvalidSoundId) + return StartResult{StartResult::ResultCode_ErrorInvalidLabelString}; + + return HoldSound(handle, soundId, soundArchiveName, startInfo); +} + } // namespace nn::atk From e824f311d76221ce74b2798db12c757253678b51 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 15 Sep 2026 17:59:58 -0300 Subject: [PATCH 768/785] atk: Match `SoundStartable::HoldSound` (4) --- src/NintendoWare/atk/atk_SoundStartable.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/NintendoWare/atk/atk_SoundStartable.cpp b/src/NintendoWare/atk/atk_SoundStartable.cpp index c79bd50e..123f1228 100644 --- a/src/NintendoWare/atk/atk_SoundStartable.cpp +++ b/src/NintendoWare/atk/atk_SoundStartable.cpp @@ -66,14 +66,23 @@ SoundStartable::StartResult SoundStartable::HoldSound(SoundHandle* handle, return result; } -SoundStartable::StartResult SoundStartable::HoldSound(SoundHandle* handle, SoundArchive::ItemId soundId, const StartInfo* startInfo) { +SoundStartable::StartResult SoundStartable::HoldSound(SoundHandle* handle, + SoundArchive::ItemId soundId, + const StartInfo* startInfo) { StartResult result{HoldSound(handle, soundId, nullptr, startInfo)}; return result; } -SoundStartable::StartResult SoundStartable::HoldSound(SoundHandle* handle, const char* soundLabel, const char* soundArchiveName, const StartInfo* startInfo) { +SoundStartable::StartResult SoundStartable::HoldSound(SoundHandle* handle, const char* soundLabel, + const StartInfo* startInfo) { + return HoldSound(handle, soundLabel, nullptr, startInfo); +} + +SoundStartable::StartResult SoundStartable::HoldSound(SoundHandle* handle, const char* soundLabel, + const char* soundArchiveName, + const StartInfo* startInfo) { u32 soundId{detail_GetItemId(soundLabel, soundArchiveName)}; - + if (soundId == InvalidSoundId) return StartResult{StartResult::ResultCode_ErrorInvalidLabelString}; From 425b0823da54097ceafda8a016174e8ea6e14495 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Tue, 15 Sep 2026 18:13:31 -0300 Subject: [PATCH 769/785] atk: Match `SoundStartable::PrepareSound` --- src/NintendoWare/atk/atk_SoundStartable.cpp | 29 +++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/NintendoWare/atk/atk_SoundStartable.cpp b/src/NintendoWare/atk/atk_SoundStartable.cpp index 123f1228..d5cd4929 100644 --- a/src/NintendoWare/atk/atk_SoundStartable.cpp +++ b/src/NintendoWare/atk/atk_SoundStartable.cpp @@ -89,4 +89,33 @@ SoundStartable::StartResult SoundStartable::HoldSound(SoundHandle* handle, const return HoldSound(handle, soundId, soundArchiveName, startInfo); } +SoundStartable::StartResult SoundStartable::PrepareSound(SoundHandle* handle, + SoundArchive::ItemId soundId, + const char* soundArchiveName, + const StartInfo* startInfo) { + return detail_SetupSound(handle, soundId, false, soundArchiveName, startInfo); +} + +SoundStartable::StartResult SoundStartable::PrepareSound(SoundHandle* handle, + SoundArchive::ItemId soundId, + const StartInfo* startInfo) { + return detail_SetupSound(handle, soundId, false, nullptr, startInfo); +} + +SoundStartable::StartResult SoundStartable::PrepareSound(SoundHandle* handle, const char* soundName, + const char* soundArchiveName, + const StartInfo* startInfo) { + u32 soundId{detail_GetItemId(soundName, soundArchiveName)}; + + if (soundId == InvalidSoundId) + return StartResult{StartResult::ResultCode_ErrorInvalidLabelString}; + + return PrepareSound(handle, soundId, soundArchiveName, startInfo); +} + +SoundStartable::StartResult SoundStartable::PrepareSound(SoundHandle* handle, const char* soundName, + const StartInfo* startInfo) { + return PrepareSound(handle, soundName, nullptr, startInfo); +} + } // namespace nn::atk From 260dad1946a84ca15245fda1599f730a30dcfb22 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 16 Sep 2026 08:28:53 -0300 Subject: [PATCH 770/785] atk: Match `SoundArchiveLoader` constructor --- include/nn/atk/atk_SoundArchiveLoader.h | 137 ++++++++++-------- include/nn/atk/atk_SoundDataManager.h | 10 +- .../atk/detail/atk_SoundArchiveLoader.cpp | 6 + 3 files changed, 91 insertions(+), 62 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveLoader.h b/include/nn/atk/atk_SoundArchiveLoader.h index 6af6a475..206c571f 100644 --- a/include/nn/atk/atk_SoundArchiveLoader.h +++ b/include/nn/atk/atk_SoundArchiveLoader.h @@ -8,81 +8,123 @@ namespace nn::atk::detail { struct LoadItemInfo { SoundArchive::ItemId itemId; const void* address; + + LoadItemInfo() = default; }; static_assert(sizeof(LoadItemInfo) == 0x10); class SoundArchiveLoader { public: - enum LoadFlag { - LoadFlag_All = -1, - LoadFlag_Seq = 1, - LoadFlag_Wsd = 2, - LoadFlag_Bank = 4, - LoadFlag_Warc = 8, - }; - - constexpr static s32 SignatureIndividualWave = 0x56574946; // FWIV - constexpr static u8 WaveBufferAlignSize = 64; + static const u32 SignatureIndividualWave{0x56574946}; // FWIV + static const int WaveBufferAlignSize{64}; struct IndividualWaveInfo { - u32 signature; + u32 signature{SignatureIndividualWave}; u32 fileId; u32 waveIndex; u32 padding[5]; u32 padding2[8]; + + IndividualWaveInfo(u32 _fileId, u32 _waveIndex) : fileId{_fileId}, waveIndex{_waveIndex} {}; }; static_assert(sizeof(IndividualWaveInfo) == 0x40); + enum LoadFlag { + LoadFlag_Seq = 1 << 0, + LoadFlag_Wsd = 1 << 1, + LoadFlag_Bank = 1 << 2, + LoadFlag_Warc = 1 << 3, + LoadFlag_All = -1, + }; + SoundArchiveLoader(); virtual ~SoundArchiveLoader(); - virtual void* SetFileAddressToTable(SoundArchive::FileId fileId, const void* address) = 0; - virtual void* GetFileAddressFromTable(SoundArchive::FileId fileId) const = 0; - virtual void* GetFileAddressImpl(SoundArchive::FileId fileId) const = 0; - - void SetSoundArchive(const SoundArchive* arc); - bool IsAvailable() const; bool LoadData(SoundArchive::ItemId itemId, SoundMemoryAllocatable* pAllocator, u32 loadFlag, size_t loadBlockSize); + + bool LoadData(const char* pItemName, SoundMemoryAllocatable* pAllocator, u32 loadFlag, + size_t loadBlockSize); + + bool IsDataLoaded(SoundArchive::ItemId itemId, u32 loadFlag) const; + + bool IsDataLoaded(const char* pItemName, u32 loadFlag) const; + + bool CancelLoading() { return m_IsCancelLoading; } + + const void* detail_GetFileAddressByItemId(SoundArchive::ItemId itemId) const; + + bool detail_LoadWaveArchiveByBankFile(const void* bankFile, SoundMemoryAllocatable* pAllocator); + + bool detail_LoadWaveArchiveByWaveSoundFile(const void* wsdFile, int wsdIndex, + SoundMemoryAllocatable* pAllocator); + +protected: + void SetSoundArchive(const SoundArchive* arc); + const SoundArchive* GetSoundArchive() const { return m_pSoundArchive; } + + const void* GetFileAddressFromSoundArchive(SoundArchive::FileId fileId) const; + + virtual const void* SetFileAddressToTable(SoundArchive::FileId fileId, const void* address) = 0; + virtual const void* GetFileAddressFromTable(SoundArchive::FileId fileId) const = 0; + virtual const void* GetFileAddressImpl(SoundArchive::FileId fileId) const = 0; + +private: bool LoadSequenceSound(SoundArchive::ItemId soundId, SoundMemoryAllocatable* pAllocator, u32 loadFlag, size_t loadBlockSize); - bool LoadAdvancedWaveSound(SoundArchive::ItemId soundId, SoundMemoryAllocatable* pAllocator, - u32 loadFlag, size_t loadBlockSize); + bool LoadWaveSound(SoundArchive::ItemId soundId, SoundMemoryAllocatable* pAllocator, u32 loadFlag, size_t loadBlockSize, SoundArchive::ItemId waveSoundSetId); + + bool LoadAdvancedWaveSound(SoundArchive::ItemId soundId, SoundMemoryAllocatable* pAllocator, + u32 loadFlag, size_t loadBlockSize); + bool LoadStreamSoundPrefetch(SoundArchive::ItemId soundId, SoundMemoryAllocatable* pAllocator, size_t loadBlockSize); + bool LoadBank(SoundArchive::ItemId bankId, SoundMemoryAllocatable* pAllocator, u32 loadFlag, size_t loadBlockSize); - bool LoadWaveArchive(SoundArchive::ItemId bankId, SoundMemoryAllocatable* pAllocator, + + bool LoadWaveArchive(SoundArchive::ItemId warcId, SoundMemoryAllocatable* pAllocator, u32 loadFlag, size_t loadBlockSize); - bool LoadGroup(SoundArchive::ItemId soundGroupId, SoundMemoryAllocatable* pAllocator, - size_t loadBlockSize); - bool LoadSoundGroup(SoundArchive::ItemId soundGroupId, SoundMemoryAllocatable* pAllocator, - u32 loadFlag, size_t loadBlockSize); - bool LoadData(char* pItemName, SoundMemoryAllocatable* pAllocator, u32 loadFlag, - size_t loadBlockSize); - void* LoadImpl(SoundArchive::FileId fileId, SoundMemoryAllocatable* pAllocator, - size_t loadBlockSize, bool needMemoryPool); - void* LoadFile(SoundArchive::FileId fileId, SoundMemoryAllocatable* pAllocator, - size_t loadBlockSize, bool needMemoryPool); + const void* LoadWaveArchiveTable(SoundArchive::ItemId warcId, + SoundMemoryAllocatable* pAllocator, size_t loadBlockSize); - void* LoadWaveArchiveImpl(SoundArchive::ItemId warcId, SoundMemoryAllocatable* pAllocator, - size_t loadBlockSize, bool needMemoryPool); bool LoadIndividualWave(SoundArchive::ItemId warcId, u32 waveIndex, SoundMemoryAllocatable* pAllocator, size_t loadBlockSize); - void* LoadWaveArchiveTable(SoundArchive::ItemId warcId, SoundMemoryAllocatable* pAllocator, - size_t loadBlockSize); - size_t ReadFile(SoundArchive::FileId fileId, void* buffer, size_t size, s32 offset, - size_t loadBlockSize); + bool LoadGroup(SoundArchive::ItemId groupId, SoundMemoryAllocatable* pAllocator, + size_t loadBlockSize); - bool PostProcessForLoadedGroupFile(void* pGroupFile, SoundMemoryAllocatable* pAllocator, + bool LoadSoundGroup(SoundArchive::ItemId soundGroupId, SoundMemoryAllocatable* pAllocator, + u32 loadFlag, size_t loadBlockSize); + + const void* LoadImpl(SoundArchive::FileId fileId, SoundMemoryAllocatable* pAllocator, + size_t loadBlockSize, bool needMemoryPool); + + void* LoadWaveArchiveImpl(SoundArchive::ItemId warcId, u32 waveIndex, + SoundMemoryAllocatable* pAllocator, u32 loadFlag, + size_t loadBlockSize); + + bool PostProcessForLoadedGroupFile(const void* pGroupFile, SoundMemoryAllocatable* pAllocator, size_t loadBlockSize); + bool IsSequenceSoundDataLoaded(SoundArchive::ItemId itemId, u32 loadFlag) const; + bool IsWaveSoundDataLoaded(SoundArchive::ItemId itemId, u32 loadFlag) const; + bool IsBankDataLoaded(SoundArchive::ItemId itemId, u32 loadFlag) const; + bool IsWaveArchiveDataLoaded(SoundArchive::ItemId itemId, u32 waveIndex) const; + bool IsGroupDataLoaded(SoundArchive::ItemId itemId) const; + bool IsSoundGroupDataLoaded(SoundArchive::ItemId itemId, u32 loadFlag) const; + + void* LoadFile(SoundArchive::FileId fileId, SoundMemoryAllocatable* allocator, + size_t loadBlockSize, bool needMemoryPool); + + size_t ReadFile(SoundArchive::FileId fileId, void* buffer, size_t size, int offset, + size_t loadBlockSize); + void SetWaveArchiveTableWithSeqInEmbeddedGroup(SoundArchive::ItemId seqId, SoundMemoryAllocatable* pAllocator); void SetWaveArchiveTableWithBankInEmbeddedGroup(SoundArchive::ItemId bankId, @@ -92,26 +134,7 @@ class SoundArchiveLoader { void SetWaveArchiveTableInEmbeddedGroupImpl(SoundArchive::ItemId warcId, SoundMemoryAllocatable* pAllocator); - bool IsDataLoaded(const char*, u32) const; - bool IsDataLoaded(u32, u32) const; - - bool IsSequenceSoundDataLoaded(u32, u32) const; - bool IsWaveSoundDataLoaded(u32, u32) const; - bool IsBankDataLoaded(u32, u32) const; - bool IsWaveArchiveDataLoaded(u32, u32) const; - bool IsGroupDataLoaded(u32) const; - bool IsSoundGroupDataLoaded(u32, u32) const; - - void* GetFileAddressFromSoundArchive(SoundArchive::FileId fileId) const; - - void* detail_GetFileAddressByItemId(SoundArchive::ItemId itemId) const; - - bool detail_LoadWaveArchiveByBankFile(void* bankFile, SoundMemoryAllocatable* pAllocator); - bool detail_LoadWaveArchiveByWaveSoundFile(void* wsdFile, s32 wsdIndex, - SoundMemoryAllocatable* pAllocator); - -private: - SoundArchive* m_pSoundArchive; + const SoundArchive* m_pSoundArchive{}; u32 m_StreamArea[128]; u16 m_LoadDataCallCount; bool m_IsCancelLoading; diff --git a/include/nn/atk/atk_SoundDataManager.h b/include/nn/atk/atk_SoundDataManager.h index 087c7886..207858e8 100644 --- a/include/nn/atk/atk_SoundDataManager.h +++ b/include/nn/atk/atk_SoundDataManager.h @@ -12,7 +12,7 @@ class SoundFileManager; } // namespace detail -class SoundDataManager : detail::driver::DisposeCallback, detail::SoundArchiveLoader { +class SoundDataManager : public detail::driver::DisposeCallback, public detail::SoundArchiveLoader { public: struct FileAddress { void* address; @@ -20,7 +20,7 @@ class SoundDataManager : detail::driver::DisposeCallback, detail::SoundArchiveLo using FileTable = detail::Util::Table; - constexpr static u32 BufferAlignSize = 8; + static const u32 BufferAlignSize{8}; SoundDataManager(); ~SoundDataManager() override; @@ -36,10 +36,10 @@ class SoundDataManager : detail::driver::DisposeCallback, detail::SoundArchiveLo void InvalidateData(const void* start, const void* end) override; void* detail_GetFileAddress(SoundArchive::FileId fileId) const; - void* GetFileAddressImpl(SoundArchive::FileId fileId) const override; + const void* GetFileAddressImpl(SoundArchive::FileId fileId) const override; - void* SetFileAddressToTable(SoundArchive::FileId fileId, const void* address) override; - void* GetFileAddressFromTable(SoundArchive::FileId fileId) const override; + const void* SetFileAddressToTable(SoundArchive::FileId fileId, const void* address) override; + const void* GetFileAddressFromTable(SoundArchive::FileId fileId) const override; void* SetFileAddress(SoundArchive::FileId fileId, const void* address); diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp index 8b137891..aad5176a 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp @@ -1 +1,7 @@ +#include +namespace nn::atk::detail { + +SoundArchiveLoader::SoundArchiveLoader() = default; + +} // namespace nn::atk::detail From 9392eb27fb4ebf0cdc3212c11503645ffe0c262b Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 16 Sep 2026 08:30:32 -0300 Subject: [PATCH 771/785] atk: Match `SoundArchiveLoader` destructor --- src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp index aad5176a..c07866b5 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp @@ -4,4 +4,8 @@ namespace nn::atk::detail { SoundArchiveLoader::SoundArchiveLoader() = default; +SoundArchiveLoader::~SoundArchiveLoader() { + m_pSoundArchive = nullptr; +}; + } // namespace nn::atk::detail From 33132864ed2dfd00782fd22d47d2932f2065dc8c Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 16 Sep 2026 08:31:33 -0300 Subject: [PATCH 772/785] atk: Match `SoundArchiveLoader::SetSoundArchive` --- src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp index c07866b5..271c45ce 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp @@ -8,4 +8,8 @@ SoundArchiveLoader::~SoundArchiveLoader() { m_pSoundArchive = nullptr; }; +void SoundArchiveLoader::SetSoundArchive(const SoundArchive* arc) { + m_pSoundArchive = arc; +} + } // namespace nn::atk::detail From 8418cdc59d356e1044e46fb151dac0f0ab74766a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 16 Sep 2026 08:33:15 -0300 Subject: [PATCH 773/785] atk: Match `SoundArchiveLoader::IsAvailable` --- src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp index 271c45ce..46a1d546 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp @@ -12,4 +12,11 @@ void SoundArchiveLoader::SetSoundArchive(const SoundArchive* arc) { m_pSoundArchive = arc; } +bool SoundArchiveLoader::IsAvailable() const { + if (m_pSoundArchive == nullptr) + return false; + + return m_pSoundArchive->IsAvailable(); +} + } // namespace nn::atk::detail From 1e2df7984084294f947b43555e98909b33ac6f97 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 16 Sep 2026 09:15:46 -0300 Subject: [PATCH 774/785] atk: Match `SoundArchiveLoader::LoadSequenceSound` --- include/nn/atk/atk_SoundArchive.h | 15 ++-- .../atk/detail/atk_SoundArchiveLoader.cpp | 90 +++++++++++++++++++ 2 files changed, 99 insertions(+), 6 deletions(-) diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index 03f28a7b..90561e19 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -78,13 +78,16 @@ class SoundArchive { static const u32 SequenceBankMax{4}; struct SequenceSoundInfo { - u32 startOffset; + u32 startOffset{0}; u32 bankIds[SequenceBankMax]; - u32 allocateTrackFlags; - u8 channelPriority; - bool isReleasePriorityFix; - - SequenceSoundInfo() = default; + u32 allocateTrackFlags{0}; + u8 channelPriority{0}; + bool isReleasePriorityFix{false}; + + SequenceSoundInfo() { + for (int i{0}; i < SequenceBankMax; ++i) + bankIds[i] = InvalidId; + }; }; static_assert(sizeof(SequenceSoundInfo) == 0x1c); diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp index 46a1d546..b50bf498 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp @@ -19,4 +19,94 @@ bool SoundArchiveLoader::IsAvailable() const { return m_pSoundArchive->IsAvailable(); } +bool SoundArchiveLoader::LoadData(SoundArchive::ItemId itemId, SoundMemoryAllocatable* pAllocator, + u32 loadFlag, size_t loadBlockSize) { + if (!IsAvailable()) + return false; + + if (itemId == SoundArchive::InvalidId) + return false; + + if (pAllocator == nullptr) + return false; + + m_pSoundArchive->FileAccessBegin(); + + SoundArchive::SoundArchivePlayerInfo soundArchivePlayerInfo; + if (!m_pSoundArchive->ReadSoundArchivePlayerInfo(&soundArchivePlayerInfo)) + return false; + + bool result; + switch (Util::GetItemType(itemId)) { + case ItemType_Sound: + switch (m_pSoundArchive->GetSoundType(itemId)) { + case SoundArchive::SoundType_Wave: + if (soundArchivePlayerInfo.isAdvancedWaveSoundEnabled) + result = LoadAdvancedWaveSound(itemId, pAllocator, loadFlag, loadBlockSize); + else + result = LoadWaveSound(itemId, pAllocator, loadFlag, loadBlockSize, + SoundArchive::InvalidId); + break; + case SoundArchive::SoundType_Stream: + result = LoadStreamSoundPrefetch(itemId, pAllocator, loadBlockSize); + break; + case SoundArchive::SoundType_Sequence: + result = LoadSequenceSound(itemId, pAllocator, loadFlag, loadBlockSize); + break; + default: + result = false; + break; + } + break; + case ItemType_SoundGroup: + result = LoadSoundGroup(itemId, pAllocator, loadFlag, loadBlockSize); + break; + case ItemType_Bank: + result = LoadBank(itemId, pAllocator, loadFlag, loadBlockSize); + break; + case ItemType_Player: + result = false; + break; + case ItemType_WaveArchive: + result = LoadWaveArchive(itemId, pAllocator, loadFlag, loadBlockSize); + break; + case ItemType_Group: + result = LoadGroup(itemId, pAllocator, loadBlockSize); + break; + default: + result = false; + break; + } + + return result; +} + +bool SoundArchiveLoader::LoadSequenceSound(SoundArchive::ItemId soundId, + SoundMemoryAllocatable* pAllocator, u32 loadFlag, + size_t loadBlockSize) { + if ((loadFlag & LoadFlag_Seq) != 0) { + u32 fileId{m_pSoundArchive->GetItemFileId(soundId)}; + + const void* pFile{LoadImpl(fileId, pAllocator, loadBlockSize, false)}; + + if (pFile == nullptr) + return false; + } + + if ((loadFlag & (LoadFlag_Bank | LoadFlag_Warc)) != 0) { + SoundArchive::SequenceSoundInfo info; + + if (!m_pSoundArchive->ReadSequenceSoundInfo(&info, soundId)) + return false; + + for (int i{0}; i < SoundArchive::SequenceBankMax; ++i) { + if (info.bankIds[i] != SoundArchive::InvalidId && + !LoadBank(info.bankIds[i], pAllocator, loadFlag, loadBlockSize)) + return false; + } + } + + return true; +} + } // namespace nn::atk::detail From e0be70399cccef485c4d3736d0434ceb9ca79e5a Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 16 Sep 2026 09:26:55 -0300 Subject: [PATCH 775/785] atk: Match `SoundArchiveLoader::LoadWaveArchive` --- .../atk/detail/atk_SoundArchiveLoader.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp index b50bf498..ffc9d81d 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp @@ -109,4 +109,18 @@ bool SoundArchiveLoader::LoadSequenceSound(SoundArchive::ItemId soundId, return true; } +bool SoundArchiveLoader::LoadWaveArchive(SoundArchive::ItemId warcId, + SoundMemoryAllocatable* pAllocator, u32 loadFlag, + size_t loadBlockSize) { + if ((loadFlag & LoadFlag_Warc) != 0) { + u32 fileId{m_pSoundArchive->GetItemFileId(warcId)}; + + const void* pFile{LoadImpl(fileId, pAllocator, loadBlockSize, true)}; + if (pFile == nullptr) + return false; + } + + return true; +} + } // namespace nn::atk::detail From cac5a0f6aafbf81fdb137f3e48a5ce53b8577738 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 16 Sep 2026 09:31:28 -0300 Subject: [PATCH 776/785] atk: Match `SoundArchiveLoader::LoadAdvancedWaveSound` --- include/nn/atk/atk_SoundArchive.h | 2 +- src/NintendoWare/atk/atk_SoundArchive.cpp | 5 ++-- .../atk/detail/atk_SoundArchiveLoader.cpp | 30 ++++++++++++++++++- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index 90561e19..e78f62f9 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -85,7 +85,7 @@ class SoundArchive { bool isReleasePriorityFix{false}; SequenceSoundInfo() { - for (int i{0}; i < SequenceBankMax; ++i) + for (int i{0}; i < static_cast(SequenceBankMax); ++i) bankIds[i] = InvalidId; }; }; diff --git a/src/NintendoWare/atk/atk_SoundArchive.cpp b/src/NintendoWare/atk/atk_SoundArchive.cpp index 02824bd5..b1a667be 100644 --- a/src/NintendoWare/atk/atk_SoundArchive.cpp +++ b/src/NintendoWare/atk/atk_SoundArchive.cpp @@ -283,7 +283,8 @@ void SoundArchive::SetExternalFileRoot(const char* extFileRoot) { size_t len{std::strlen(extFileRoot)}; size_t nullPos{len + 1}; - util::Strlcpy(m_ExtFileRoot, extFileRoot, std::min(sizeof(m_ExtFileRoot), nullPos)); + util::Strlcpy(m_ExtFileRoot, extFileRoot, + std::min(sizeof(m_ExtFileRoot), static_cast(nullPos))); if (extFileRoot[len - 1] != '/') { m_ExtFileRoot[len] = '/'; @@ -329,7 +330,7 @@ const char* SoundArchive::detail_GetExternalFileFullPath(const char* externalFil if (bufSize > fileLen + 1) bufSize += 1; - util::Strlcpy(pathBuffer, externalFilePath, bufSize); + util::Strlcpy(pathBuffer, externalFilePath, static_cast(bufSize)); detail::fnd::strncat(pathBuffer, bufSize, m_ExtFileRoot, fileLen); pathBuffer[bufSize - 1] = '\0'; externalFilePath = pathBuffer; diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp index ffc9d81d..524f93be 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp @@ -99,7 +99,7 @@ bool SoundArchiveLoader::LoadSequenceSound(SoundArchive::ItemId soundId, if (!m_pSoundArchive->ReadSequenceSoundInfo(&info, soundId)) return false; - for (int i{0}; i < SoundArchive::SequenceBankMax; ++i) { + for (int i{0}; i < static_cast(SoundArchive::SequenceBankMax); ++i) { if (info.bankIds[i] != SoundArchive::InvalidId && !LoadBank(info.bankIds[i], pAllocator, loadFlag, loadBlockSize)) return false; @@ -109,6 +109,34 @@ bool SoundArchiveLoader::LoadSequenceSound(SoundArchive::ItemId soundId, return true; } +bool SoundArchiveLoader::LoadAdvancedWaveSound(SoundArchive::ItemId soundId, + SoundMemoryAllocatable* pAllocator, u32 loadFlag, + size_t loadBlockSize) { + u32 awsdFileId{m_pSoundArchive->GetItemFileId(soundId)}; + + if ((loadFlag & LoadFlag_Wsd) != 0) { + const void* pFile{LoadImpl(awsdFileId, pAllocator, loadBlockSize, false)}; + + if (pFile == nullptr) + return false; + } + + if ((loadFlag & LoadFlag_Warc) != 0) { + const void* pAwsdFile{GetFileAddressImpl(awsdFileId)}; + if (pAwsdFile == nullptr) + return false; + + SoundArchive::AdvancedWaveSoundInfo info; + if (!m_pSoundArchive->detail_ReadAdvancedWaveSoundInfo(soundId, &info)) + return false; + + if (!LoadWaveArchive(info.waveArchiveId, pAllocator, loadFlag, loadBlockSize)) + return false; + } + + return true; +} + bool SoundArchiveLoader::LoadWaveArchive(SoundArchive::ItemId warcId, SoundMemoryAllocatable* pAllocator, u32 loadFlag, size_t loadBlockSize) { From a4f89164c59910e1359213178ed240ae08cdfa1e Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 16 Sep 2026 09:48:06 -0300 Subject: [PATCH 777/785] atk: Match `SoundArchiveLoader::LoadWaveArchiveImpl` --- include/nn/atk/atk_SoundArchiveLoader.h | 6 +++--- .../atk/detail/atk_SoundArchiveLoader.cpp | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/include/nn/atk/atk_SoundArchiveLoader.h b/include/nn/atk/atk_SoundArchiveLoader.h index 206c571f..600d7746 100644 --- a/include/nn/atk/atk_SoundArchiveLoader.h +++ b/include/nn/atk/atk_SoundArchiveLoader.h @@ -105,9 +105,9 @@ class SoundArchiveLoader { const void* LoadImpl(SoundArchive::FileId fileId, SoundMemoryAllocatable* pAllocator, size_t loadBlockSize, bool needMemoryPool); - void* LoadWaveArchiveImpl(SoundArchive::ItemId warcId, u32 waveIndex, - SoundMemoryAllocatable* pAllocator, u32 loadFlag, - size_t loadBlockSize); + bool LoadWaveArchiveImpl(SoundArchive::ItemId warcId, u32 waveIndex, + SoundMemoryAllocatable* pAllocator, u32 loadFlag, + size_t loadBlockSize); bool PostProcessForLoadedGroupFile(const void* pGroupFile, SoundMemoryAllocatable* pAllocator, size_t loadBlockSize); diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp index 524f93be..ca3702e0 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp @@ -151,4 +151,22 @@ bool SoundArchiveLoader::LoadWaveArchive(SoundArchive::ItemId warcId, return true; } +bool SoundArchiveLoader::LoadWaveArchiveImpl(SoundArchive::ItemId warcId, u32 waveIndex, + SoundMemoryAllocatable* pAllocator, u32 loadFlag, + size_t loadBlockSize) { + SoundArchive::WaveArchiveInfo info; + if (!m_pSoundArchive->ReadWaveArchiveInfo(warcId, &info)) + return false; + + if (info.isLoadIndividual) { + if (!LoadIndividualWave(warcId, waveIndex, pAllocator, loadBlockSize)) + return false; + } else { + if (!LoadWaveArchive(warcId, pAllocator, loadFlag, loadBlockSize)) + return false; + } + + return true; +} + } // namespace nn::atk::detail From 2148e68fd0caaefb8bdd70903a452f5143821ec7 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 16 Sep 2026 10:17:06 -0300 Subject: [PATCH 778/785] atk: Match `SoundArchiveLoader::LoadWaveSound` --- include/nn/atk/atk_SoundArchive.h | 6 +- .../atk/detail/atk_SoundArchiveLoader.cpp | 57 +++++++++++++++++++ 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index e78f62f9..fcb88275 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -137,9 +137,9 @@ class SoundArchive { struct WaveSoundInfo { u32 index; - u32 allocateTrackCount; - u8 channelPriority; - bool isReleasePriorityFix; + u32 allocateTrackCount{0}; + u8 channelPriority{0}; + bool isReleasePriorityFix{false}; WaveSoundInfo() = default; }; diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp index ca3702e0..bd0028ed 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp @@ -1,5 +1,7 @@ #include +#include + namespace nn::atk::detail { SoundArchiveLoader::SoundArchiveLoader() = default; @@ -137,6 +139,61 @@ bool SoundArchiveLoader::LoadAdvancedWaveSound(SoundArchive::ItemId soundId, return true; } +bool SoundArchiveLoader::LoadWaveSound(SoundArchive::ItemId soundId, + SoundMemoryAllocatable* pAllocator, u32 loadFlag, + size_t loadBlockSize, SoundArchive::ItemId waveSoundSetId) { + u32 wsdFileId{m_pSoundArchive->GetItemFileId(soundId)}; + + if ((loadFlag & LoadFlag_Wsd) != 0) { + const void* pFile{LoadImpl(wsdFileId, pAllocator, loadBlockSize, false)}; + + if (pFile == nullptr) + return false; + } + + if ((loadFlag & LoadFlag_Warc) != 0) { + const void* pWsdFile{GetFileAddressImpl(wsdFileId)}; + if (pWsdFile != nullptr) { + u32 index; + { + SoundArchive::WaveSoundInfo info; + if (!m_pSoundArchive->detail_ReadWaveSoundInfo(soundId, &info)) + return false; + index = info.index; + } + + u32 warcId{SoundArchive::InvalidId}; + u32 waveIndex; + { + WaveSoundFileReader reader{pWsdFile}; + WaveSoundNoteInfo info; + + if (!reader.ReadNoteInfo(&info, index, 0)) + return false; + + warcId = info.waveArchiveId; + waveIndex = info.waveIndex; + } + + if (!LoadWaveArchiveImpl(warcId, waveIndex, pAllocator, loadFlag, loadBlockSize)) + return false; + } else { + SoundArchive::ItemId itemId{waveSoundSetId != SoundArchive::InvalidId ? waveSoundSetId : + soundId}; + + const Util::Table* pWarcIdTable{ + m_pSoundArchive->detail_GetWaveArchiveIdTable(itemId)}; + + for (u32 i{0}; i < pWarcIdTable->count; ++i) { + if (!LoadWaveArchive(pWarcIdTable->item[i], pAllocator, loadFlag, loadBlockSize)) + return false; + } + } + } + + return true; +} + bool SoundArchiveLoader::LoadWaveArchive(SoundArchive::ItemId warcId, SoundMemoryAllocatable* pAllocator, u32 loadFlag, size_t loadBlockSize) { From 71b1031da55ba09ab5ffec1ca824d2cc1df182a8 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 16 Sep 2026 10:19:18 -0300 Subject: [PATCH 779/785] atk: Match `SoundArchiveLoader::LoadStreamSoundPrefetch` --- src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp index bd0028ed..c506068a 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp @@ -194,6 +194,12 @@ bool SoundArchiveLoader::LoadWaveSound(SoundArchive::ItemId soundId, return true; } +bool SoundArchiveLoader::LoadStreamSoundPrefetch(SoundArchive::ItemId soundId, SoundMemoryAllocatable* pAllocator, size_t loadBlockSize) { + u32 prefetchFileId{m_pSoundArchive->GetItemPrefetchFileId(soundId)}; + const void* pFile{LoadImpl(prefetchFileId, pAllocator, loadBlockSize, true)}; + return pFile != nullptr; +} + bool SoundArchiveLoader::LoadWaveArchive(SoundArchive::ItemId warcId, SoundMemoryAllocatable* pAllocator, u32 loadFlag, size_t loadBlockSize) { From de2f77e8d82f74b672efc31cd5a625362459b5c7 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 16 Sep 2026 10:38:24 -0300 Subject: [PATCH 780/785] atk: Match `SoundArchiveLoader::LoadBank` --- .../atk/detail/atk_SoundArchiveLoader.cpp | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp index c506068a..d1289a2d 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp @@ -1,5 +1,6 @@ #include +#include #include namespace nn::atk::detail { @@ -177,6 +178,7 @@ bool SoundArchiveLoader::LoadWaveSound(SoundArchive::ItemId soundId, if (!LoadWaveArchiveImpl(warcId, waveIndex, pAllocator, loadFlag, loadBlockSize)) return false; + } else { SoundArchive::ItemId itemId{waveSoundSetId != SoundArchive::InvalidId ? waveSoundSetId : soundId}; @@ -194,12 +196,58 @@ bool SoundArchiveLoader::LoadWaveSound(SoundArchive::ItemId soundId, return true; } -bool SoundArchiveLoader::LoadStreamSoundPrefetch(SoundArchive::ItemId soundId, SoundMemoryAllocatable* pAllocator, size_t loadBlockSize) { +bool SoundArchiveLoader::LoadStreamSoundPrefetch(SoundArchive::ItemId soundId, + SoundMemoryAllocatable* pAllocator, + size_t loadBlockSize) { u32 prefetchFileId{m_pSoundArchive->GetItemPrefetchFileId(soundId)}; const void* pFile{LoadImpl(prefetchFileId, pAllocator, loadBlockSize, true)}; return pFile != nullptr; } +bool SoundArchiveLoader::LoadBank(SoundArchive::ItemId bankId, SoundMemoryAllocatable* pAllocator, + u32 loadFlag, size_t loadBlockSize) { + u32 bankFileId{m_pSoundArchive->GetItemFileId(bankId)}; + + if ((loadFlag & LoadFlag_Bank) != 0) { + const void* pFile{LoadImpl(bankFileId, pAllocator, loadBlockSize, false)}; + + if (pFile == nullptr) + return false; + } + + if ((loadFlag & LoadFlag_Warc) != 0) { + const void* pFile{GetFileAddressImpl(bankFileId)}; + if (pFile != nullptr) { + BankFileReader reader{pFile}; + const Util::WaveIdTable* table{reader.GetWaveIdTable()}; + + if (table == nullptr) + return false; + + for (u32 i{0}; i < table->GetCount(); ++i) { + const Util::WaveId* pWaveId{table->GetWaveId(i)}; + if (pWaveId == nullptr) + return false; + + if (!LoadWaveArchiveImpl(pWaveId->waveArchiveId, pWaveId->waveIndex, pAllocator, + loadFlag, loadBlockSize)) + return false; + } + + } else { + const Util::Table* pWarcIdTable{ + m_pSoundArchive->detail_GetWaveArchiveIdTable(bankId)}; + + for (u32 i{0}; i < pWarcIdTable->count; ++i) { + if (!LoadWaveArchive(pWarcIdTable->item[i], pAllocator, loadFlag, loadBlockSize)) + return false; + } + } + } + + return true; +} + bool SoundArchiveLoader::LoadWaveArchive(SoundArchive::ItemId warcId, SoundMemoryAllocatable* pAllocator, u32 loadFlag, size_t loadBlockSize) { From da0d6859c41d83cb7eb09c2c55fd6b2fa94d3e21 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 16 Sep 2026 10:45:12 -0300 Subject: [PATCH 781/785] atk: Match `SoundArchiveLoader::LoadGroup` --- .../atk/detail/atk_SoundArchiveLoader.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp index d1289a2d..9213062c 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp @@ -262,6 +262,17 @@ bool SoundArchiveLoader::LoadWaveArchive(SoundArchive::ItemId warcId, return true; } +bool SoundArchiveLoader::LoadGroup(SoundArchive::ItemId groupId, SoundMemoryAllocatable* pAllocator, + size_t loadBlockSize) { + const void* pGroupFile{ + LoadImpl(m_pSoundArchive->GetItemFileId(groupId), pAllocator, loadBlockSize, true)}; + if (pGroupFile == nullptr) + return false; + + u32 fileId{PostProcessForLoadedGroupFile(pGroupFile, pAllocator, loadBlockSize)}; + return fileId; +} + bool SoundArchiveLoader::LoadWaveArchiveImpl(SoundArchive::ItemId warcId, u32 waveIndex, SoundMemoryAllocatable* pAllocator, u32 loadFlag, size_t loadBlockSize) { From 05d4bac493f4723fb00ecc8732842d17b8ae69a1 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 16 Sep 2026 10:57:00 -0300 Subject: [PATCH 782/785] atk: Match `SoundArchiveLoader::LoadSoundGroup` --- include/nn/atk/atk_SoundArchive.h | 6 ++-- .../atk/detail/atk_SoundArchiveLoader.cpp | 29 +++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h index fcb88275..ab9b6e0f 100644 --- a/include/nn/atk/atk_SoundArchive.h +++ b/include/nn/atk/atk_SoundArchive.h @@ -176,9 +176,9 @@ class SoundArchive { static_assert(sizeof(PlayerInfo) == 0x8); struct SoundGroupInfo { - ItemId startId; - ItemId endId; - detail::Util::Table fileIdTable; + ItemId startId{InvalidId}; + ItemId endId{InvalidId}; + detail::Util::Table* fileIdTable{}; SoundGroupInfo() = default; }; diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp index 9213062c..9c7ff6a9 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp @@ -273,6 +273,35 @@ bool SoundArchiveLoader::LoadGroup(SoundArchive::ItemId groupId, SoundMemoryAllo return fileId; } +bool SoundArchiveLoader::LoadSoundGroup(SoundArchive::ItemId soundGroupId, + SoundMemoryAllocatable* pAllocator, u32 loadFlag, + size_t loadBlockSize) { + SoundArchive::SoundGroupInfo info; + if (!m_pSoundArchive->detail_ReadSoundGroupInfo(soundGroupId, &info)) + return false; + + if (info.startId != SoundArchive::InvalidId) { + switch (m_pSoundArchive->GetSoundType(info.startId)) { + case SoundArchive::SoundType_Sequence: + for (u32 id{info.startId}; id <= info.endId; ++id) { + if (!LoadSequenceSound(id, pAllocator, loadFlag, loadBlockSize)) + return false; + } + break; + case SoundArchive::SoundType_Wave: { + for (u32 id{info.startId}; id <= info.endId; ++id) { + if (!LoadWaveSound(id, pAllocator, loadFlag, loadBlockSize, soundGroupId)) + return false; + } + } + default: + break; + } + } + + return true; +} + bool SoundArchiveLoader::LoadWaveArchiveImpl(SoundArchive::ItemId warcId, u32 waveIndex, SoundMemoryAllocatable* pAllocator, u32 loadFlag, size_t loadBlockSize) { From df548133219c135434839d09a1eb1bc2a14b639f Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 16 Sep 2026 11:07:50 -0300 Subject: [PATCH 783/785] atk: Match `SoundArchiveLoader::LoadData` --- .../atk/detail/atk_SoundArchiveLoader.cpp | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp index 9c7ff6a9..c1ba9759 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp @@ -43,6 +43,14 @@ bool SoundArchiveLoader::LoadData(SoundArchive::ItemId itemId, SoundMemoryAlloca switch (Util::GetItemType(itemId)) { case ItemType_Sound: switch (m_pSoundArchive->GetSoundType(itemId)) { + case SoundArchive::SoundType_Sequence: + result = LoadSequenceSound(itemId, pAllocator, loadFlag, loadBlockSize); + break; + + case SoundArchive::SoundType_Stream: + result = LoadStreamSoundPrefetch(itemId, pAllocator, loadBlockSize); + break; + case SoundArchive::SoundType_Wave: if (soundArchivePlayerInfo.isAdvancedWaveSoundEnabled) result = LoadAdvancedWaveSound(itemId, pAllocator, loadFlag, loadBlockSize); @@ -50,12 +58,7 @@ bool SoundArchiveLoader::LoadData(SoundArchive::ItemId itemId, SoundMemoryAlloca result = LoadWaveSound(itemId, pAllocator, loadFlag, loadBlockSize, SoundArchive::InvalidId); break; - case SoundArchive::SoundType_Stream: - result = LoadStreamSoundPrefetch(itemId, pAllocator, loadBlockSize); - break; - case SoundArchive::SoundType_Sequence: - result = LoadSequenceSound(itemId, pAllocator, loadFlag, loadBlockSize); - break; + default: result = false; break; @@ -81,6 +84,8 @@ bool SoundArchiveLoader::LoadData(SoundArchive::ItemId itemId, SoundMemoryAlloca break; } + m_pSoundArchive->FileAccessEnd(); + return result; } @@ -302,6 +307,12 @@ bool SoundArchiveLoader::LoadSoundGroup(SoundArchive::ItemId soundGroupId, return true; } +bool SoundArchiveLoader::LoadData(const char* pItemName, SoundMemoryAllocatable* pAllocator, + u32 loadFlag, size_t loadBlockSize) { + SoundArchive::ItemId itemId{m_pSoundArchive->GetItemId(pItemName)}; + return LoadData(itemId, pAllocator, loadFlag, loadBlockSize); +} + bool SoundArchiveLoader::LoadWaveArchiveImpl(SoundArchive::ItemId warcId, u32 waveIndex, SoundMemoryAllocatable* pAllocator, u32 loadFlag, size_t loadBlockSize) { From 680771aa48e06270e441c3ced90f8d0012f5f762 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 16 Sep 2026 12:11:29 -0300 Subject: [PATCH 784/785] atk: Match `SoundArchiveLoader::LoadFile` --- .../atk/detail/atk_SoundArchiveLoader.cpp | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp index c1ba9759..fcfd2d02 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp @@ -1,6 +1,7 @@ #include #include +#include #include namespace nn::atk::detail { @@ -313,6 +314,30 @@ bool SoundArchiveLoader::LoadData(const char* pItemName, SoundMemoryAllocatable* return LoadData(itemId, pAllocator, loadFlag, loadBlockSize); } +void* SoundArchiveLoader::LoadFile(SoundArchive::FileId fileId, SoundMemoryAllocatable* allocator, + size_t loadBlockSize, bool needMemoryPool) { + SoundArchive::FileInfo fileInfo; + if (!m_pSoundArchive->detail_ReadFileInfo(fileId, &fileInfo)) + return nullptr; + + u32 fileSize{fileInfo.fileSize}; + + if (fileSize + 1 <= 1) + return nullptr; + + void* buffer{allocator->Allocate(allocator->GetAllocateSize(fileSize, needMemoryPool))}; + + if (buffer == nullptr) + return nullptr; + + if (ReadFile(fileId, buffer, static_cast(fileSize), 0, loadBlockSize) != + static_cast(static_cast(fileSize))) + return nullptr; + + driver::HardwareManager::FlushDataCache(buffer, fileSize); + return buffer; +} + bool SoundArchiveLoader::LoadWaveArchiveImpl(SoundArchive::ItemId warcId, u32 waveIndex, SoundMemoryAllocatable* pAllocator, u32 loadFlag, size_t loadBlockSize) { From 564a890a7a66edc845143bae2300ab5909cfe703 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Wed, 16 Sep 2026 12:15:51 -0300 Subject: [PATCH 785/785] atk: Match `SoundArchiveLoader::LoadImpl` --- .../atk/detail/atk_SoundArchiveLoader.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp index fcfd2d02..64e1b10e 100644 --- a/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp +++ b/src/NintendoWare/atk/detail/atk_SoundArchiveLoader.cpp @@ -314,6 +314,20 @@ bool SoundArchiveLoader::LoadData(const char* pItemName, SoundMemoryAllocatable* return LoadData(itemId, pAllocator, loadFlag, loadBlockSize); } +const void* SoundArchiveLoader::LoadImpl(SoundArchive::FileId fileId, + SoundMemoryAllocatable* pAllocator, size_t loadBlockSize, + bool needMemoryPool) { + const void* fileAddress{GetFileAddressImpl(fileId)}; + + if (fileAddress == nullptr) { + fileAddress = LoadFile(fileId, pAllocator, loadBlockSize, needMemoryPool); + if (fileAddress != nullptr) + SetFileAddressToTable(fileId, fileAddress); + } + + return fileAddress; +} + void* SoundArchiveLoader::LoadFile(SoundArchive::FileId fileId, SoundMemoryAllocatable* allocator, size_t loadBlockSize, bool needMemoryPool) { SoundArchive::FileInfo fileInfo;