From b5f090483a5cfc4394c97ef5f78681fa79bbd7f1 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/511] 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 77d547e4..ce9a2155 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -205,16 +205,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 @@ -236,6 +226,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 5a36be4e853afe0c3b7ff09a6d1397c8fbab4b68 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/511] 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 557438c06b331435d019a963ad9d38e5f2a71f5e 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/511] 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 a413f45b1d5e75fdac12399284841c9f5729fe0a 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/511] 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 f9d6bfba016497ca0f55d6e190395a31ea7a5fa4 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/511] 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 8cad8c8a23927c65b35f05e55bf8f489e6824dfc 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/511] 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 6f17513efc557b79fde468dfdc84cc65e6372e64 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/511] 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 8549e2a199ee2001af6866757962e469c499ff1b 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/511] 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 8151cdcad90aa0ef89afcfa54ba3fae0662fe977 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/511] 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 fd9e0268a5b3aa6f8155dc7e493b65b7908eb613 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/511] 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 7bab0a1d7a8c1d31bdf6a69cc6dabc966731c50a 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/511] 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 45d485b7699b1c56dd322a47b592b0e3f412b28b 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/511] 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 fb3a30b544daa346f8c947425a34a7f32b75a64b 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/511] 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 0afcdfd7788ed0209c5b62698cf0f1f029ccd734 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/511] 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 ce9a2155..17d3d50e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -179,6 +179,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_StringView.h include/nn/ui2d/detail/TexCoordArray.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 2148fd7a36046bcd98ef1264ebfcb065af5520bc 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/511] 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 8f28f316b346a8c5f59d3a8e5278f596a68538aa 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/511] 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 ccf5333494fc6a2016c35ba3fe557b5c9734e615 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/511] 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 39884027cffbcb0c1b65ecd05e350c8028ff3c2b 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/511] 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 b7eafa598809672e03f56977a807d46b5d6cea90 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/511] 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 6f605ceba43271bbcf72728f92666ef4495dd52b 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/511] 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 75ecf5d5000f7db4ea5d5a69388390eb92d78c74 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/511] 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 5e00697766f82385a07b84a32a1e2ed1f0577545 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/511] 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 c16fb01ac5ebc8dd310dd00cfb0c79ff556315dc 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/511] 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 62f9210c030049d7d470ebe5eeffe5028376ad32 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/511] 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 17d3d50e..b31eb998 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -227,6 +227,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 eae9a35b3834675cc810642cc16fc67d0cd73522 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/511] 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 2bb7a4e0b51634a8b57ff819695bd7cbeb128fe0 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/511] 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 b31eb998..5e0b557f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -230,18 +230,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 @@ -254,50 +246,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 @@ -305,56 +282,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 a0bf75c308194f513bf5895917e7e1a867244e46 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/511] 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 d97c125240c15c4c4703f60ef04dd8d36e43c6ad 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/511] 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 eb41284453c3a5ab0d9a032265729d30bb42c020 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/511] 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 b4a8c2592cc02970fbb88af70d19800dd525f4d7 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/511] 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 f035dd343c76c62be8c461819e1e9f399cf12678 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/511] 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 21ed5b3b4cab5c79568a68593f6df1f4d11e995f 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/511] 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 5e0b557f..904696f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -356,7 +356,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 @@ -370,6 +369,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 21b005d6aefb4443036aae7edaf1b9914d6880f5 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/511] 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 b586cb24d023db16de5e4ddbfd603c8c11db91db 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/511] 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 9b26e18f1adb3748a4812926ee1610151c14871e 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/511] 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 0e9bd5ecf39060cd9adcc741abdf1cb025c466c6 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/511] 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 526c93f6578076b6c50ef91cfad8a5186f3a149a 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/511] 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 4b5bc99afd54d59a24891749363e6995565e851d 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/511] 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 4ec6c7bba9183ce3b589891eed0c994c5b971b88 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/511] 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 1972ec87582ca23e2e52184872f2a08784b9aa3e 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/511] 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 fd3437cfb09ef0ba13f9bdb10f226b62f0918f3d 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/511] 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 a4c354ee66d1c711732e99239f681c149b5b9c07 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/511] 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 6a43bf668a37cd93c44556d1875c2b51dfe62aae 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/511] 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 904696f3..2f7126a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -228,12 +228,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 @@ -350,6 +351,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 8ba442b27749dc8f365076106abb404e91b6ceca 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/511] 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 167f528351fd3f5a5c1fd8c19322c9441cda053d 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/511] 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 3fa185cced7d16de9093f0d3493ff58dad6a16ca 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/511] 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 12c5f97d2d1643392566b79143d354cc4580ce15 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/511] 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 aabecf8a33ad5828424cb8353a07a530115d8440 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/511] 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 3cb5004f84792076cb6ea47dce8762329e4e1f57 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/511] 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 24617a487bcb46ea1d9a3a4fa8aad615bec5e5e0 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/511] 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 bf17703b0188cd80fa39799b140de2b714fbb55c 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/511] 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 b838429e3c5fcd03f2a7d64c488a0bdad4388ae6 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/511] 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 74e97568c720d75756eab6d9a3aa8bf5103a3ed9 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/511] 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 a22bff7ce5f335bc2ec3b179876c8f146f37a566 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/511] 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 098c41860c2792f802c26e5a09fbc46221b5a865 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/511] 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 177fe2e0f2c8278b6118586a018860cfd54b8c0d 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/511] 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 597bf1bbc784ddf78400560dc2b1d5d022a934fa 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/511] 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 112a29e595723ebbdd032027951d18f495b24db2 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/511] 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 b40c3258a9ad7ec91de27661b4b4397320599b33 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/511] 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 a2f57d77324a1bda84c42d3c31aacd67fa1243ce 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/511] 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 2600f1e543728fbb31d5b4731c3b99b1fd366f64 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/511] audio: Add files to CMakeLists --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f7126a7..4e6adab6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -228,7 +228,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 ee116ee9cb504893ae43a3dfc34693fd9c9bca16 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/511] 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 4e6adab6..57e1372b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,6 +231,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 39108e095ab61a6a10d599e62ade697c5e4a4a6e 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/511] 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 57e1372b..de9b9250 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,6 +232,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 c3a9ca8d2da127cf524585ad41527c641df2aed8 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/511] 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 2581823cecb9639ec9a888e68609cb075d8cdd0d 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/511] 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 c010263b9ef4b30c7e0716921e129d33a4fe7a70 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/511] 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 5cdc555a8741b74c1da930dad446f4a225c44429 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/511] 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 7d433aa39dc61d39c5b5876c703f14d73fd90e0c 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/511] 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 72484c1bb2bacdd5a031d46578ec2404ebdef934 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/511] 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 011d67340fcff3799525339103b9e43a9b4fa1dd 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/511] 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 0982108f2ed206edddd3110600099eef3ab1c9aa 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/511] 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 1f813eb1bb016993c7571fabaf175be9b9cc2b71 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/511] 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 d6292ba0db5af05e760824e0e5c95ece4ba83c5d 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/511] 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 cddca0e145aa68143d2d71944d85cbc06a9ea27e 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/511] 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 cbd3fdd40908b2ffee12b1d8fa5ef232ee59f297 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/511] 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 a75c6a20142b5ec705fa7664e7497ab66d9bcebd 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/511] 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 de9b9250..c168d579 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,6 +232,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 259b4461d9e90feaf438a21195cad3048a953163 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/511] 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 c168d579..40ee08a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,6 +232,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 8d1f0070aca7335406d42185475a8a07592b9125 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/511] 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 194e5489c9217ede721c6bdeea8bc0c596cad797 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/511] 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 7ef76f9271b20beda76dbf46748cbbf899199d05 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/511] 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 0af4084873013303da328dd3c8092d5c02166c71 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/511] 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 ca45da267139cac9ec320be49e054e9b375a08b7 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/511] 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 a49ec7609bbd0791767ebc3f3ab695785be0e72c 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/511] 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 51db4ab0be3900164462c7a6613bf3e9a223172f 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/511] 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 10433bfe005af9217cfd3a40c4929774e5aa4e3c 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/511] 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 073407e1c0fba71142fdded53430d89c07c81f4c 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/511] 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 56cfce2d08e90a9385566796f2aa859fe4f0e511 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/511] 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 98c832c06eb08e7d89b7f853b1f50b0fee5307b6 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/511] 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 28d614fa70f3c40bb2649871db49af16720c2b21 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/511] 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 5caabdf8dd33491b21ad4ac43c1170295d505fe3 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/511] 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 765c65a4830926e341a07c204fcee3cc1b17e7d6 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/511] 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 273bada375508dc4295f17a059a54be549411cd3 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/511] 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 e33e1c4e3d78453ac049c2f17d351a09536429ba 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/511] 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 3228c50eb629a50fc11009cf9e8c881047edf715 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/511] 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 e7321c80ab5906917ae677e1e60bd4d1226a63cb 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/511] 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 e77325d2ec654b7e2be99cd364e4b33dcbe00804 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/511] 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 aa214aaa0d1420bc2762db25db34386baedee548 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/511] 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 f08a1a262d1d14552ba2aa10b36200378a430561 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/511] 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 eef0b7e83167fa9282afcbf29b293fe6baa934ea 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/511] 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 7cff8599a09e886db79466d28269c38a02928723 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/511] 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 37d546ca2a0add5392a12456df35b06b65b1a07b 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/511] 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 ee745ec46689054e9e3f5bc3ef7200fc9d48c262 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/511] 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 3bb656b64e35073dce8b8bc64481d30801300c7b 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/511] 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 f5ae61b8a5ce01218056672f12d6aae36cf129d8 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/511] 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 84b59e658e0f387feca945cedef76e257c137b59 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/511] 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 7d744eb9bab75c42fa8b4b6b5f415cc1f42d2c2d 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/511] 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 a5dd042848d5f54a7adb4e91be955abc853d1fdd 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/511] 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 e8fb1471430f1288d3ca4ebf66c25b09e25ec023 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/511] 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 f69ba11fab1a9cb61c3b0ea13819a6d3f76210a8 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/511] 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 ee316e425cac160014498c70f8d5273eb68dd0cc 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/511] 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 2f94d2bc4135e92b03d37d26d47390aa6aa19176 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/511] 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 145ef46720b6894df986e60a57c59a2b7b037976 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/511] 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 1fedbfe299b19cdc9293228c2da7620152d161d1 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/511] 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 3f40b4f66171f323e50b5d2638ef670cd30e4ffe 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/511] 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 4b60ec28e6ec8659e790ca48bf54e65a5203ce11 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/511] 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 65a037c40aeb7eda196f68acd0fbd5cd2c1f7a7f 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/511] 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 9f1e8fbe37efe7705a855b4aec20dd23ee729ebf 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/511] 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 241d0deddcce505fd0ae3d99a2b82a19518646fe 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/511] 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 0b703f5987540129e0bb28d0d41c483a9ee0126b 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/511] 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 7cc6993e01fa99e1057ef02d5bd6e49d654d4fc6 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/511] 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 bfc480acdd2feea70c76b5b70947ba54533e7ce1 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/511] 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 4080d1beca0afd5873d52cf7953d6b3c7b35d269 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/511] 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 dff49b8eef433e7ac9f25b4a32807cbc607c07e4 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/511] 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 8a6d84ad9907adc30ee304387bcb72b827443b3a 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/511] 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 532c03a10f2b50e5d439cc4336d2adb321f9b602 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/511] 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 9920231e574fabbd4c476907e2f2400e43f58f5d 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/511] 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 94a01e41d2db8e15f92eb32393f666bdde246b77 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/511] 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 1a0c03459f86aa89ffb3d7a3665bcc4ca8c90052 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/511] 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 83bcaa53f23bd7dafda6f9b451a18b7ea974c311 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/511] 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 d7e749c4da3e95fe1f43d027214fa11628fd9bd0 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/511] 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 e7be92f0f2e6d9425cd6722d67023d226eaceac3 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/511] 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 26528948b16c331be45638b8b94b2bb6721762a0 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/511] 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 dc0956d4b3c757f596bcc8ec365e30ca9f57b558 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/511] 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 40ee08a8..d7c87e38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,6 +232,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 183e105d7cd13016fa5070d596818c14a524a6d6 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/511] 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 454c77732a9609d024461a4c594ceaa66a1b5a95 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/511] 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 d7c87e38..35a46792 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -235,6 +235,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 eaeb709a01db49db6f8b6928fa74722917d04fbb 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/511] 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 35a46792..4ea0f771 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -236,6 +236,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 f56998eddd0e9d06c42bce9edac8045cd8845f1a 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/511] 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 4ea0f771..b39a58fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -239,6 +239,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 94fff1aa7ca19c21111b60a5b8f37da4f34aa5cc 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/511] 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 67a85bb4208af4ebd6b95d4ef62a190ab545889c 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/511] 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 6452577cbace4819bc2d398b7adc1cedb7012a95 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/511] 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 f19775169d9020263cfd1bb13bfce2a9d060509d 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/511] 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 3b1d929ccd04b0fcbeead4effcb4241c6b1fb6a6 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/511] 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 8997d9d1c12c1f5805f0dce0f9b337214f41cf03 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/511] 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 4ce325592ee7f1485922432602616a26caf9fab7 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/511] 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 cf934016c19e2bafe036e87aaca6a56c985c94eb 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/511] 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 61bad6240141caa96b1da6c73af310c2f0a73712 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/511] 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 f41736fc8ffa967b0b4ee4683e58eef6b8f12897 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/511] 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 3d16f6319db0acdc33dfa63f97621b787b75cf79 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/511] 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 47d8d5b35c7564dbfcf5cacd4a9ce35d0dac0a4c 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/511] 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 610b0e0715c6271a09557d644bd1e6d0d842da6e 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/511] 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 5a240e575eedddfd22488b41a204e174fc6e1ae8 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/511] 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 1a194c9946bc21e00af21ec6fba40c61ce1c1e50 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/511] 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 8abafd8c879b74895bbaa4d3a659dcb003efdc4d 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/511] 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 ca9a4f29f9b07942e05f1e246b144d4e852b9e0f 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/511] 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 7fc14927f6955080a7b88d45dce18662754090dc 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/511] 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 674d916e7fe12fae7aaa1244cc1b1917bd69b717 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/511] 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 1e5cfeb90d644442cfbe424430f182f649e10f6b 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/511] 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 3b6432351d56535785fb10d90ff08d489b5e3366 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/511] 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 76e9977955fc7462fd51e2b0fb73dbaf9958bd7d 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/511] 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 d8e69e3f51f3d2159053710eb30c81d964df62c7 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/511] 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 b39a58fc..5546dd66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -337,6 +337,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 @@ -349,7 +350,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 8ae289173479d3fe4638e642a73dd155d17a4678 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/511] 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 c7e7d83ec18595db6b2f133aa0851f32dd64e7ae 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/511] 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 485083cfbb82723872f0aa3f5940d8b51e51f315 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/511] 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 24365688c7a77551f92e19c7db0fd9385738f5e8 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/511] 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 0b0b6f39327595bee2dcc6acd0457d74d1fb5511 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/511] 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 0d649879b89c356fd18d72ac0c98c56bb0e09c48 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/511] 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 e9135cb02330f71fe087413dfcd4a3aca4b19cf5 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/511] 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 210064e02f7def8d0dfd12cf81ea9fd1ba1f0d71 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/511] 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 a49ef3b7ccb4e865b231975756ccb7da0e431b2c 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/511] 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 847a7181bd794c60db0bcc8ab18a67ab9b7ce17c 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/511] 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 a88a34488dd963325c3e0e81a2aa040e6c684327 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/511] 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 5546dd66..5c102d2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -241,10 +241,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 @@ -257,6 +254,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 @@ -301,6 +299,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 @@ -365,6 +365,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 673403a144c1fe3e8a46c45f2fa1c48b89342e81 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/511] 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 ea61a7ca825a4e2de578099acb5041b3b6dbc9ca 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/511] 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 5c102d2b..95214954 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -241,7 +241,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 @@ -263,8 +266,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 @@ -293,14 +294,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 @@ -337,19 +334,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 @@ -365,7 +366,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 18bc6efe68193bfd28e5f872c14abeb907488f83 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/511] util: Incorporate changes from master branch --- include/nn/util/util_IntrusiveList.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/nn/util/util_IntrusiveList.h b/include/nn/util/util_IntrusiveList.h index 319f43a8..52b8caaf 100644 --- a/include/nn/util/util_IntrusiveList.h +++ b/include/nn/util/util_IntrusiveList.h @@ -338,6 +338,15 @@ class IntrusiveList { detail::IntrusiveListImplementation m_Implementation; }; +template +class IntrusiveListBaseNode : IntrusiveListNode {}; + +template +class IntrusiveListBaseNodeTraits { +public: + using BaseNodeType = IntrusiveListBaseNode; +}; + template class IntrusiveListMemberNodeTraits { friend class IntrusiveList; @@ -358,5 +367,4 @@ class IntrusiveListMemberNodeTraits { return reinterpret_cast(&(reinterpret_cast(0)->*Member)); } }; - } // namespace nn::util From 81186bbfeb611a1800499813c30007417c9677aa 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/511] 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 1260f6ed01b831311e07e3f724f6dc18171fd9b4 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/511] 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 f6c2c9738881725381a481b7cb1421a6ef95c601 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/511] 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 cc535e686dd5a3da235941756cd046af99eb0067 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/511] 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 25d265a215f872759a5925923d25777084f5a46d 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/511] 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 f6449662a6f15168815c9de875bac46aa53d0c41 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/511] 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 46a58a58ad63070334f0bb99427546afc52c7872 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/511] 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 95214954..20b5f177 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -241,6 +241,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 @@ -384,53 +434,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 26fc849d9f5bbca5d91b750f73877e191d467774 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/511] 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 5a516ddc5df71b46e29ab92d8b2743e7c63ee819 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/511] 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 7ebe2143a91b827ad89f3813c08a5b22306e5e22 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/511] 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 bddd6ccbc98ed64ad3d20e0ab29bca9ac8ba7d0b 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/511] 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 57a85aa800d664d37620d87ffb60faa18238cd70 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/511] 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 6cda6a496842fd2281a72dc98b1b69ce8c049f7a 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/511] 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 8ee1383f83754e17181b2fa8a9065494c035285b 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/511] 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 d9ac0468eafb00b7b504a2837357ae39f9f5ce28 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/511] 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 20b5f177..f3210eef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -292,148 +292,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 ef49c3a48f17d3780d9de96998596bc8dfb46be3 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/511] 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 6d007635a65a8837f39f495c68a6b647ab139f60 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/511] 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 48b89fe559f9d6fca802a3bcc782e9445b8e9181 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/511] 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 8e36afa050f040c37142e22eeeccc2340a4738cd 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/511] 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 f3210eef..a6f9692e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -289,6 +289,8 @@ add_library(NintendoSDK OBJECT src/NintendoSDK/nvn/nvn_Impl.cpp ) + +# Atk Sources target_sources(NintendoSDK PUBLIC include/nn/atk/atk_Adpcm.h @@ -441,6 +443,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 2d1a250d5aaecc82128e43d6e8b8ff81eadff354 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/511] 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 57318c619d6d576ccfe98632faa7c922cbdbf56c 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/511] 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 a317183441cb5c3ba18792e69fbb4effdc72c1b9 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/511] 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 b905334c8cde551491a8171ade9dd9e4ece9bb84 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/511] 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 a6f9692e..5ce88eee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -545,6 +545,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 5246d5cb6fb7264c6a145bd024997ab26214efd1 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/511] 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 7e8f94112d0be8f31602fc595eca276cdf78a6fc 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/511] 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 ++- include/nn/util/util_IntrusiveList.h | 23 +++++-- .../atk/fnd/basis/atkfnd_HeapBase.cpp | 61 +++++++++++++++++-- 4 files changed, 88 insertions(+), 12 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/include/nn/util/util_IntrusiveList.h b/include/nn/util/util_IntrusiveList.h index 52b8caaf..88dafd62 100644 --- a/include/nn/util/util_IntrusiveList.h +++ b/include/nn/util/util_IntrusiveList.h @@ -338,13 +338,28 @@ class IntrusiveList { detail::IntrusiveListImplementation m_Implementation; }; -template -class IntrusiveListBaseNode : IntrusiveListNode {}; +template +class IntrusiveListBaseNode : public IntrusiveListNode { +public: + IntrusiveListBaseNode(); +}; -template +template class IntrusiveListBaseNodeTraits { public: - using BaseNodeType = IntrusiveListBaseNode; + using BaseNodeType = IntrusiveListBaseNode; + + static IntrusiveListNode& GetNode(T& ref) { return ref; } + + static const IntrusiveListNode& GetNode(const T& ref) { return ref; } + + static T& GetItem(IntrusiveListNode& node) { + return *reinterpret_cast(node); + } + + static const T& GetItem(const IntrusiveListNode& node) { + return *reinterpret_cast(node); + } }; template 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 189f48708b61992f10b785420c923a18e85ad10f 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/511] 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 ac925244cb5238d8fabea28e78073f6dfddbdb72 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/511] 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 5878998400c9c4d89a06282e481131a870fa1b5d 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/511] 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 195b6249fa7e21227d7e488e02d7e65b3ce776be 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/511] 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 7e8b23ddd30cc125e6fccc3b51372c0d04c7aac2 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/511] 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 5c6ce2cb7ea0259f8e4f9f8af34283ed44127c41 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/511] 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 37466d68f35da009d982ca65719a5cc41249c953 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/511] 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 028bc91525f754de30b081a9e3e81ae5d084ba8b 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/511] 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 f2c4a9be5383308864e178ddc015c4d0090b936d 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/511] 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 8fb5123d066e8def2e0ef835ab74370ebe7bc87d 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/511] 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 bf8bd345ca99f6685a2bcefaefafb4e97d1991bf 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/511] 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 3f3e334b4b70efa9bee1d6b6dd4f8a003eafccd6 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/511] 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 fda040f828acea793a4498ff50373ecd1e043121 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/511] 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 93bf17c508ec600ef9de035c6d1d728d9ef136c9 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/511] 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 9c5248f1d46288a9eb532cf1c7076fd6e079040b 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/511] 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 c7c06e96f8f6a1f6202a0601633f2a90bf3bb6f9 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/511] 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 8316d58119e7c55fd4fbf94f3efe4289d7c98902 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/511] 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 8082fa093a09472aaa6f959d575ff9f00b4c714f 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/511] 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 913c0306808f99444f445716040be5328415750f 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/511] 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 10e657a17bf8ff7212a11f792df26fe351a874f4 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/511] 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 4df8c2f64e7fe8b6f5438463d6260c649e58058c 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/511] 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 b05ac0d106b656e59ba280df9cf26ecfa58ae97a 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/511] 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 b50bf4e68923e6354c29fed800827c00870427dd 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/511] 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 f06bb0ff51a71d051def37e0e481c94e30c0d12c 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/511] 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 cbb5ab02b598e5ef7e555f4068bd5a0f634f75bf 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/511] 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 60f88c739b0cda5a0f4e9568d8f0d88cc3cdad68 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/511] 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 89ba1fc9e5703ffed71201828389d62f0952db97 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/511] 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 fc40cd4870c565c200ae4845068de7cc112510b5 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/511] 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 269cba8c9032357a6c39afc785440edb51c73abc 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/511] 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 6b8288c8d5b36bb91fd982ee1292dc3d95458be7 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/511] 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 68dac10c49e5e00f50bab84bf017e1c0961da1bb 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/511] 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 c6560db945f89a0ded1cb15b094e081994957c60 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/511] 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 330bf2df35d5646d02ecb58ae1cc2e9fdb14bac6 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/511] 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 07d8d7f8966180e926949f550765582b23bbfa8d 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/511] 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 5b1c806a6babc25db5c033686ad10ea44879ae21 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/511] 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 0e78293c21221385736a3599ff922d3e8ccd293e 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/511] 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 1484c34cd18a98a3bb5a06f1f54deab251ba7f2e 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/511] 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 e689b58f1bdf10f4269544dcbed9417d963091d8 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/511] 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 1ec20c048a725cd01eada160f7146407b41e56cc 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/511] 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 6a52becb83beac0c137927fa09ad0fddbe29665f 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/511] 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 d19c6cc1c92addb35f04667b9ac62634dcd8cbb7 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/511] 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 a591a4136c6a4c3d63bc5833f617f8747ef24c26 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/511] 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 cfd6388e34562ac3a47e78ac507e4d5c312124f1 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/511] 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 85002389c1d100a925da88a474afcc3299c39f6c 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/511] 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 749e3d272680d4fe94db09d47921a79abdcdab65 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/511] 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 3e865e396101e402e8fd247acaa9942df7d925eb 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/511] 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 91f06aa3fb2c1c49bfb62c862382f107e96ea031 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/511] 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 1955e4372edf15117ece6036a3bd1b7a6ba84859 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/511] 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 cd87c15daef8ac1b8c8cacc5ce7083ed91cdb573 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/511] 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 61a62cc735a7245b5e628594c338268913a2400c 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/511] 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 49889060b8d8de9e700cac7472ff24ffe2b291ae 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/511] 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 85c947f175a44898a6c937ee39f8a81d4d8ac4be 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/511] 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 03c82c9932c814db3d4763ebceee09feabd4068d 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/511] 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 7da2e814f175ce4283397ff26717e17dd0b776fd 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/511] 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 fcd9b5bd3a059d7a387041c6900af438300dc1ff 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/511] 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 cf019a99a56f6fbea880561c74f57dad8cb5be21 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/511] 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 54353abf87cea8fe2668dcc91bff7dfd8d1d548d 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/511] 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 8f3c40d3f8c44a37be54910ba0a8d9032ebb2017 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/511] 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 7fb6345c550e87e65e67ca4aaf2179fc7689ad78 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/511] 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 606be947630a5f2bcf70399b64fb2d82e1a0a10f 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/511] 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 2794093bd0454d57627bae46410f63db834ac71d 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/511] 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 23e486f7ad58f98d6ef9883c2394144573da7e2b 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/511] 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 26cb185a6353441fd8af28a95059c55e218549f5 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/511] 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 61fa89dc2afc889db26bb3ae62eadafda37453c8 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/511] 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 9dbececce99df82151ff3b767d0fcee40fbe64ab 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/511] 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 2e328a8a3ddea7952e859c16265fa30125a25ae1 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/511] 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 4bcad57ef824ae649b767511d8156a3565bda4f7 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/511] 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 8f6984bb961fc894ee130d946a7729dd111e1c50 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/511] 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 82d8c9ccf92fa92f3e6fbe7ab5b1095e7984bb32 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/511] 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 7a60e99ca78a3083a3f82a907efcb6726d234208 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/511] 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 fb1a8319c5c46a54dd32b49adfe7744a8308e0ca 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/511] 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 31d85709dac21988f1d17f37e410611f444aa602 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/511] 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 0904aac8afb3763b3a0001e1e7e10b45048eef96 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/511] 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 5a833d5f6d99c8e0da836ab92ffb7316f80f4797 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/511] 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 15c7f4734a9aa319a0a376ad226911fd9f69b50c 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/511] 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 a5d7fedb95218e25fdebb74ff5f85e059d7521d8 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/511] 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 4eb79f0561b3ff35cc8f0c5895e12fb6fc90eba4 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/511] 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 9fbc776a8b530129f601f5879f61855ca052f5ac 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/511] 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 e121aaa683f27d12ad464c00168338fbfeb50db1 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/511] 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 17c185c43f3ee78c223d4fecfe558582feb35057 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/511] 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 76f81527ec4f24585880b85f4b58c7e03471863e 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/511] 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 019a34338fc15f267d7ab13f3a1d79f18bae26fb 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/511] 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 945d071f065f3d3226241a496d5daa39e0e2cfd9 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/511] 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 6dd769da9e70dbc9a7356cedc32db1722b53ac22 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/511] 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 a385720786bd59cf9492eb93cc671313aae95a88 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/511] 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 a33feabf3ad363c0be48407e58462f8a93537eee 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/511] 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 7cf351e02e73fc4ae5a40a8181c62537691b7803 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/511] 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 ca0933212540fcfd46d85405cd87456ee121935c 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/511] 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 5ce88eee..aaeaeb43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -289,7 +289,6 @@ add_library(NintendoSDK OBJECT src/NintendoSDK/nvn/nvn_Impl.cpp ) - # Atk Sources target_sources(NintendoSDK PUBLIC @@ -427,19 +426,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 a26d3990fccd7c11054357552002cd8c8b0f493e 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/511] 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 e56ca4930d50f12a0421b0636d87e9752ba5761f 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/511] 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 1be52489c04209d33103e18637ec321cd3e3b7f1 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/511] 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 7215b612150a39f4c26d6a71edab3842dbbd9d35 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/511] 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 e856dfd8ce8b3e150f8bc95fe3b7eb8d0ede559e 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/511] 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 fd3e776ccd130716a87819475124dd15a4c0015e 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/511] 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 6219e622d760d4ba43e053ba1a3c86b2cefd88d3 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/511] 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 9df4c0afa642012693e2fe99fd9c2be7c9e0a8af 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/511] 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 d5d9e6541a10b8e94786c9762e469a61444d3a67 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/511] 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 94803382f817b5a18aba0ce771d25dc13f4fb890 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/511] 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 3cb24df48c6ac163102540ef4374920501c3f980 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/511] 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 762ed097f8f4ec72a2d938cb926f20dbe81a3158 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/511] 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 e39f4f907e7cd9a0ed65bbe6f51984dc63d3e555 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/511] 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 8ae8ff579c9b34c4fb73d4642bdfaaecac7df163 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/511] 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 37100bcc5d2228115ea1875d0fc3d87055972196 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/511] 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 5fde28ebce76e8c90575d66473756b93abc7dd94 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/511] 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 215bf8dc84c2ff1d25a3bb59839a094d3ea50e3d 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/511] 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 7adff84e0de1dc12aa30fb48d41280f23a49f7f9 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/511] 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 3b673e3831ddfd7b75742464bed81e44c53931b3 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/511] 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 59f065bc6a268613a502019c292d979120a7bb3c 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/511] 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 f0c9a5b439da3fa1c23a6daecb5c0549df2fabb4 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/511] 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 2ef1f27b9a3f0f4aa46c7bae784c637241a40277 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/511] 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 dcd6a5b418b12e80327b44c9ecf55496f8475011 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/511] 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 c62846592289ad5e0e7e33c8bb1face12e184c2c 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/511] 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 abc98b820cb6706b86d215907352ec1dc9405010 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/511] util: Add string utils Only `nn::util::Strlcpy` has been verified to match. All others are only placeholders for now. --- CMakeLists.txt | 1 + include/nn/util/util_StringUtil.h | 33 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 include/nn/util/util_StringUtil.h diff --git a/CMakeLists.txt b/CMakeLists.txt index aaeaeb43..c69733b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -181,6 +181,7 @@ add_library(NintendoSDK OBJECT 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 include/nn/ui2d/detail/TexCoordArray.h include/nn/ui2d/Layout.h diff --git a/include/nn/util/util_StringUtil.h b/include/nn/util/util_StringUtil.h new file mode 100644 index 00000000..1b292c8c --- /dev/null +++ b/include/nn/util/util_StringUtil.h @@ -0,0 +1,33 @@ +namespace nn::util { +template +inline int Strlcpy(T* pOutDst, const T* pSrc, int count) { + int length = 0; + + if (count > 0) { + while (--count && *pSrc) { + *pOutDst++ = *pSrc++; + ++length; + } + *pOutDst++ = '\0'; + } + + while (*pSrc++) + ++length; + + return length; +} + +template +inline int Strnlen(const T* pStr, int count) { + int length = 0; + + while (--count && *pStr++) { + ++length; + } + + return length; +} + +template +inline int Strncmp(const T* pStr1, const T* pStr2, int count); +} \ No newline at end of file From 333b60f72f233f78dbfd44d27d9b125fba99ff01 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/511] 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 148dd67b49ccdb3d681747dfb75ed49b0584ce99 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/511] 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 db71987e85c45fa743932b396a51b3e56cf5fa0a 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/511] atk: Match `AddonSoundArchiveContainer::IsSameName` This also matches `nn::util::Strnlen` and `nn::util::Strncmp` --- include/nn/util/util_StringUtil.h | 30 ++++++++++++++----- .../detail/atk_AddonSoundArchiveContainer.cpp | 10 +++++++ 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/include/nn/util/util_StringUtil.h b/include/nn/util/util_StringUtil.h index 1b292c8c..e3051c2e 100644 --- a/include/nn/util/util_StringUtil.h +++ b/include/nn/util/util_StringUtil.h @@ -1,5 +1,5 @@ namespace nn::util { -template +template inline int Strlcpy(T* pOutDst, const T* pSrc, int count) { int length = 0; @@ -17,17 +17,33 @@ inline int Strlcpy(T* pOutDst, const T* pSrc, int count) { return length; } -template +template inline int Strnlen(const T* pStr, int count) { int length = 0; - while (--count && *pStr++) { - ++length; + if (count > 0) { + while (count && *pStr) { + ++pStr; + ++length; + --count; + } } return length; } -template -inline int Strncmp(const T* pStr1, const T* pStr2, int count); -} \ No newline at end of file +template +inline int Strncmp(const T* pStr1, const T* pStr2, int count) { + if (count == 0) + return 0; + + T c1, c2; + + do { + c1 = *pStr1++; + c2 = *pStr2++; + } while (c1 && c1 == c2 && --count); + + return c1 - c2; +} +} // namespace nn::util \ 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 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 dc1df1c372eb9dbf59ece49f77b7aa89b9c2c771 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/511] 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 be6dd59fca48df1a7e9ba2a50ae469006eede6ba 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/511] 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 716360b77c0f4ee1b5e11bd13b33fbccccbdf2a3 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/511] 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 1e0f8bee2ad43d94128812cda363918324f65040 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/511] 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 a436777673abc71ff16e16c8aca127b2c7e7e06a 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/511] 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 4fdd351ecab6368ff8d9744de801225f7b9a64ec 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/511] 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 ++-- include/nn/util/util_IntrusiveList.h | 4 +- .../atk/fnd/basis/atkfnd_HeapBase.cpp | 143 ++++++++++++++---- 4 files changed, 145 insertions(+), 54 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c69733b4..b6d0ed8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -423,7 +423,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 @@ -442,8 +442,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 @@ -547,17 +558,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/include/nn/util/util_IntrusiveList.h b/include/nn/util/util_IntrusiveList.h index 88dafd62..0cd5475b 100644 --- a/include/nn/util/util_IntrusiveList.h +++ b/include/nn/util/util_IntrusiveList.h @@ -354,11 +354,11 @@ class IntrusiveListBaseNodeTraits { static const IntrusiveListNode& GetNode(const T& ref) { return ref; } static T& GetItem(IntrusiveListNode& node) { - return *reinterpret_cast(node); + return reinterpret_cast(node); } static const T& GetItem(const IntrusiveListNode& node) { - return *reinterpret_cast(node); + return reinterpret_cast(node); } }; 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 f4c2cade0f2e1f9b02d0b4ef64d4d2d87d9e8773 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/511] 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 b6d0ed8e..b3266d2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -398,9 +398,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 @@ -408,8 +410,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 @@ -417,13 +417,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 @@ -444,18 +443,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 @@ -550,6 +537,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 4d1fc0c4a5b1af8a70b7700edf7339867c939af7 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/511] 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 1d33106390e44fa97f70db113d1fa42ca75a9574 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/511] 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 32979d31b3e5cf5c47539645944c64fc338e4a21 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/511] 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 a464744250350b03caafcca46d57170870dbe97d 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/511] 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 262db6e4e60bf5b08d1fd70307e66b08a0a570bb 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/511] 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 0715a16e36b3d27bf514fb1e3161b0e81c53fc99 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/511] 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 0258d5e9b101cf5e4663f3ff4406388a2640aad7 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/511] 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 ce40936966f622519d624d0fcb0519c3370044b0 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/511] 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 8b0df154cdb65ca9b005ef5ce3627600f90ba7e5 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/511] 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 a68f8f977f9bc915dfe7c108cc232c097264fd68 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/511] 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 a5a84e9058e028f6f5b05efc6801223c73086685 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/511] 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 13d183296b8d1b1133ea064875d39721a9488ffe 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/511] 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 38b2b8ba018434fabe85cb35a3c08156819d5c64 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/511] 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 e95da05a643004e60eee73e72fce647296ba17ea 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/511] 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 fceae0d7c93593c0233077461162809292d72428 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/511] 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 6119a222bfe2a4c0eeeffa6c6e84fe82bb388977 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/511] 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 a8a53458545bba3d33ca0c5c7bab2556ef16f6da 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/511] 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 7a4aa617208df8d23e2f7a880c3ca9a93cabdceb 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/511] 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 9de200ae261926bc001d3d7c1d6388d136bf73c0 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/511] 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 d3cfc457efca9022b6096542434a2cb3711089a8 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/511] 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 35212deb29fd82b5e8ec2e13208eebece2aa9049 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/511] 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 db19178e3d8e2ff0bc726ddaa60c415847c540db 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/511] 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 b1b202e5c4eba77ba4caa2fc5e77cb2c9507ec76 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/511] 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 53d25cc33a690145ad66ce071b1d506daa03b7d7 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/511] 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 a283d1d34629a8bc603082c6b4c13000ff0dca4d 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/511] 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 2e86c7882b39ad69c7c9438c99e2f36fb2fb2f1a 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/511] 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 1048b3ffe4a2a4266f75a9425b17c58ae23603f5 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/511] 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 51eabb8c5cd650298a30ffb1744313c69a338000 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/511] 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 70cd3f560e486591b198624f9030318e07de755e 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/511] 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 eafd40c00a89b367c5afeded657e67f2ad8c8ed2 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/511] 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 66238c06ca0c3c869eb7c20c60f7e3fda0bb5956 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/511] 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 e51cdbedde4171eaecd4e237b63df3579670067a 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/511] 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 30d7470d43e3f0eedc384d5b8caca7e4aee86b5d 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/511] 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 71e690a154a453a05837da30648b6d4969b11b9f 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/511] 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 df683efafede22fe689943d60cb7533813980c5c 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/511] 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 1eb081906233ffaf0f109541d1947c7c1b351e38 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/511] 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 383265d6a58b89f718c7410a1f112a47dc8ac6e8 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/511] 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 78111f904e58d9716278548f57f50e619128f9f4 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/511] 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 eded8075099b338d6023f13ed2b8af0e81d181e1 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/511] 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 1b4631b6e61faf963ec7d5f08ee52377795ad4a7 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/511] 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 d29f6cc117a59703b0204ae6600f5c76e4d390a1 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/511] 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 665c4a2f1c36972684aa5d5c5bcf089c89751fa1 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/511] 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 f43718751c15b8290211bff2f3aa45df99b958a7 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/511] 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 f6e7886fecdf2c0d7f37c7097a5b870cc69ccb54 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/511] 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 ebbdc6042bc6c80c97339fd9853da26e0ed05f6b 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/511] 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 2047042d5718f4fe646b56e7f14f160a5e301a12 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/511] 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 d8a21fdff726438e390e17c3377bc447fe1533cf 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/511] 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 3f8c1b3e2d6c1f4fc7ca96abcb24ab00f86706e4 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/511] 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 515c3b3a3018eac12993b950d1b88a7de39a6383 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/511] 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 6da16228437ef76fdcb7281b429e664b1c128921 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/511] 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 3538aabf3bece1f283531564fd55edb339382271 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/511] 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 0d038ebcc23b763f8a8523e22631b6ebb9c7158f 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/511] 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 9d45a2b1b4f5da9c5bdf1d42cd75f6011aac773d 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/511] 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 26bdf37bab5c64d7a53b4e14acd7ecf616acd5a6 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/511] 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 660746947139d7bf2ed4fd5affbc54c28f1ffbaa 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/511] 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 fbced9e5e9fb40f83b4b2608764a402c886047f5 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/511] 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 942e288f9d4f521f75e6f9fa6acbe8ecc7c49c82 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/511] 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 c8bcc51978792dcf3445e587b0489624f7ebe721 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/511] 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 a86b9d3373b9fcd0ea0b52618dae3b120d16daa2 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/511] 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 b509cb5d2746cca2fe7a7d22f2b8f7fd830f61ea 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/511] 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 4ead5f5f3953c1a318bda39b46159f72297d470a 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/511] 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 d470962c481811b820cb7f2da4565534d7adda1b 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/511] 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 c9764857a84479cce7fefed8de0b21ea87743fef 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/511] 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 d04bd3c4eb70d879b5bf904aae38d5378d3224a5 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/511] 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 8c79a238c2a48b0b09ab708c1dbeb849e3402df8 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/511] 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 2b79498bfbaea05016890c5c85840ba769ab4e26 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/511] 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 ebbc98b31de34a26f7432434129d741f9877bfa8 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/511] 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 6112deaa0cc97d36566f2a8555ea5a91cefee46e 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/511] 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 9830be74a3b397fcadcc2fcc596009befc1f059d 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/511] 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 9e2d6ad3be2a679f26a73976405b96c8eec3af80 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/511] 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 385c4e8971e63163a81e505839d32a8562ddcb92 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/511] 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 231f683fae709f9f7ceace7b53001258495d6cb3 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/511] 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 f2d7101b304c5dd45d22c1e18672aa56b9fe5825 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/511] 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 46acfc83dd886539ba98cce489d2beab5777baf0 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/511] 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 2019987c30c44d1dae5df4a89650f1f72d51d36b 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/511] 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 ce7a34c1f4e1eb48ad22299b7a9652acaa8173b0 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/511] 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 c0bad4a5dbeb093360858140b7d17c8065442b22 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/511] 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 ed1c5045019afb6f1abcb3dab10b1e72d29c0735 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/511] 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 62805b033e966f94bc90ded59c111b12a9eec056 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/511] 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 5dd5c20be65d89f378c29322dab337ef189296d6 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/511] 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 75b1c0e3c0d56424a66905a842228a96271f3b46 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/511] 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 b331da31917d50bb14dd9388d86dd5a6d3fc353c 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/511] 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 e447dedd5faa4cabe75b775adfd4a483a8528d2b 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/511] 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 3546fd5558a5d16026572d92ec16560d05ce92fc 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/511] 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 ce7ca873a43851652683ec79ee39fc20f9661e88 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/511] 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 127e2f8cb6df6f70d6fef9ea6dba39fc2814182f 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/511] 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 485ef913bd1f79264656843d03d2aa387e2e00a1 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/511] 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 4b16a0aa39a849af2d24d244cd113f8ff980eaf4 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/511] 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 4f94c9d98f13383c39a3e8d6a6809d33ee23abfb 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/511] 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 42d876641209203eea855aa2cd0eb634d9e31b41 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/511] 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 07e7e220f48b3044d894ad083396413a5b2a93f3 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/511] 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 61d9d1c29d431117b52931e8e07563eaaad3287e 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/511] 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 1deeb55dd10a01db21d3ef2bbd57ed044ea24ddd 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/511] 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 d405355d62380bcb030a877da3623fb261d8ab58 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/511] 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 4816a2016e4812b8a6a8652aec20a572ce3e2fc3 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/511] 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 9917c372520e8db8a9850b141bcffa791357eaad 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/511] 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 e27a2cc5c0ad2238b805e41eb1b38a97e7ed8ab0 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/511] 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 e6f3ddda74875e22dfa6be45e3f37d51bc9cb32e 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/511] 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 619677745b647dfd5e47694a1d737d4d1e8d6070 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/511] 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 93a1bb2b4b4beccf4faafd5b9c1ea56461d4019d 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/511] 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 65c7563affeafbb01a514ca2e5446fd2d4c7f89a 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/511] 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 f8f59fc38dd093f25ba0307ff69bc6f0d545d2e5 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/511] 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 977439f51929b379a704f386a771ea5a88426eea 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/511] 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 c0ef44ba38b8aad4f2707f38025dbfd2893cdf10 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/511] 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 26451844e6c15f652e0357f9ef31951114b0cffa 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/511] 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 804abe832ecda7dec54eb759570b4ae242e307d1 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/511] 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 32b1a6cfd10fd6d7c83542c9889718e1a892cf3b 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/511] 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 d4c7e255aa27b9ee627683cba3f482f2550c3e37 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/511] 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 9d45521a96cbad2d61b6b0b28d7d4263beec34a6 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/511] 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 ea2f2cde96dccf7997bb996b01004f1b58fefff8 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/511] 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 b697e079efc1baf3abb064ea6956e15641c62288 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/511] 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 2bf1d7242d6ad17d47fd63abada89786dd30d7ed 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/511] 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 50a4cb890d09b832d52929c441f517cf082044b6 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/511] 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 4989e784d75923e67db6013dbf07c894fd06abea 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/511] 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 745d9ee459da11bfaa7a2fde7f926c2c29a903c6 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/511] 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 ddaf9e6caa85d753155d6e6818e7aba64c10d3ec 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/511] 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 a88fae643d09ec3b1bb25136f7e7028e7cae556b 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/511] 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 8ac47c83ee9f95c2f592fa5c7d34139323d9ccdf 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/511] 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 579f997def29246fd9dd0a70422404087c900fcd 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/511] 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 d424c2d9d4531b12069862766486cdf7c44004c7 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/511] 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 a8da590f0f896cc2885f95f8aae1f806914e699f 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/511] 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 bdccedc4848013a8b11591bfc1a9a7a13684799a 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/511] 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 91360a080d08e4ca1d24759d75d6835104ff706e 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/511] 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 eb866bd65f54c6e15b1a222da9abf87d5caa9e9c 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/511] 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 b749c0c3dcc1da6e94d1129aad3275b86ea27145 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/511] 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 c43ac5c3ae8e5d8925580efa374a0b596c4a2875 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/511] 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 7a2e714c7bc0f4e67ce9fba0cab9a31ca73ee1db 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/511] atk: Match `FsSoundArchive::Close` --- .../nn/atk/fnd/os/atkfnd_CriticalSection.h | 29 +++++++++++++++++-- include/nn/atk/fnd/os/atkfnd_ScopedLock.h | 20 +++++++++++-- include/nn/os/os_Mutex.h | 3 +- src/NintendoWare/atk/atk_FsSoundArchive.cpp | 13 +++++++++ 4 files changed, 59 insertions(+), 6 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/include/nn/os/os_Mutex.h b/include/nn/os/os_Mutex.h index 6656ce46..77e00446 100644 --- a/include/nn/os/os_Mutex.h +++ b/include/nn/os/os_Mutex.h @@ -21,7 +21,8 @@ class Mutex { explicit Mutex(bool recursive) { InitializeMutex(&m_Mutex, recursive, 0); } Mutex(bool, int); - ~Mutex(); + + ~Mutex() { FinalizeMutex(&m_Mutex); } void Lock() { LockMutex(&m_Mutex); } 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 9f37021f7cd5fc937fbdc7278ff69de8450d8a8d 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/511] 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 c0273b60dfac609cf9489dfbf3111f8c2ce227e2 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/511] 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 14ba2b89f54b32aad2e3f0dc806c6fc3a2425c7f 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/511] 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 06dcd6ecbd2ee32ed3cf35477e00b3bced173398 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/511] 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 ed884e3d04b858aecb81f12bad2f74516911d27c 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/511] 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 8eff7d3281ca0e08c221192f18d60c6dab5f51c2 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/511] 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 d32463a8344cfa4c1ee8737e81893cda5abfbe5d 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/511] 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 98b014d18276218374ad6810a9a76f4837a7852f 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/511] 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 8d60e93f59789e3a4dcf4a696086928a8a1d5bea 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/511] 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 df43e38a9974fee672eac355324c8e085b8d4678 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/511] 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 3db76506cf6cb9cd43dba7995e8d10f015a9fc92 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/511] 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 b6dfcf305dd79f5fc33f308702faa00969fef389 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/511] 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 9e6749edf234bd5e8121e5dcc9331d8162cec82c 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/511] 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 2114efe44087866d3bad4016f082d7bb54ced6d7 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/511] 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 3ae8f37bbb4d3b2a50f39d84d70e5d17dd7062a2 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/511] 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 0049a9f1175cbabcde93cca37b1988777d389f52 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/511] 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 8c4f2615e9dfc47eb387091cbf8b35483418e71d 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/511] 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 49c293a6feaee9b0f5ac91745c4551f27128fbb9 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/511] 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 eaa63962a51099fa26c0d3b64811a87fe5c74a9b 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/511] 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 3d9a7990d5370ec6d88131cadcd31dc42e365cc1 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/511] 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 ff666e7c81055877c1aabf85f7ea30dda69d22c8 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/511] 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 73cbdfd43f451dc5d79dab2b2593861e395d07b7 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/511] 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 1e388b781b9d7fbe0942a93d4f5a443525263684 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/511] 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 305263990484932afbd1fd2c1c2665942579404e 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/511] 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 6c895274e0eff595e0956a59415abf08b73f7323 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/511] 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 e34804fe12af86398b15eb646aa7c270cf7cb756 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/511] 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 72db43cc3c50a41c804cd9fb96e21b36fa6e4829 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/511] 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 35cebcd639d3ea923a23d78b639026e0a35e24c1 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/511] 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 3a4ccdc4edebfae8a530d7625a8b2d4696bee83c 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/511] 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 1b64a1b145b34acd5c7438925cead5d09bba7f01 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/511] 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 | 34 +------------ include/nn/os/os_Event.h | 48 +++++++++++++++++++ include/nn/os/os_EventCommon.h | 5 ++ include/nn/os/os_EventTypes.h | 26 ++++++++++ include/nn/os/os_Mutex.h | 30 +++++++----- include/nn/os/os_TickTypes.h | 40 ++++++++++++++++ .../atk/detail/thread/atk_Task.cpp | 14 ++++++ 9 files changed, 170 insertions(+), 44 deletions(-) create mode 100644 include/nn/os/os_Event.h create mode 100644 include/nn/os/os_EventCommon.h create mode 100644 include/nn/os/os_EventTypes.h 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 6f27d49f..beeb0df5 100644 --- a/include/nn/os.h +++ b/include/nn/os.h @@ -11,17 +11,17 @@ #include #include +#include #include #include -#include #include +#include namespace nn { namespace os { namespace detail { -class MultiWaitObjectList; struct InterProcessEventType { enum State { State_NotInitialized = 0, @@ -39,31 +39,10 @@ struct InterProcessEventType { }; } // namespace detail -struct Tick { - Tick(u64 val) : value(val) {} - - u64 value; -}; - struct LightEventType { std::aligned_storage_t<0xc, 4> storage; }; -struct EventType { - util::TypedStorage _multiWaitObjectList; - bool _signalState; - bool _initiallySignaled; - uint8_t _clearMode; - uint8_t _state; - uint32_t _broadcastCounterLower; - uint32_t _broadcastCounterUpper; - detail::InternalCriticalSectionStorage _csEvent; - detail::InternalConditionVariableStorage _cvSignaled; -}; -static_assert(std::is_trivial::value, "EventType non trivial"); -typedef EventType Event; - -enum EventClearMode { EventClearMode_ManualClear, EventClearMode_AutoClear }; struct ConditionVariableType {}; @@ -154,15 +133,6 @@ void SleepThread(nn::TimeSpan); void WaitThread(nn::os::ThreadType*); void SetThreadCoreMask(nn::os::ThreadType*, int, u64 mask); -// EVENTS -void InitializeEvent(EventType*, bool initiallySignaled, EventClearMode eventClearMode); -void FinalizeEvent(EventType*); -void SignalEvent(EventType*); -void WaitEvent(EventType*); -bool TryWaitEvent(EventType*); -bool TimedWaitEvent(EventType*, nn::TimeSpan); -void ClearEvent(EventType*); - // LIGHT EVENTS void InitializeLightEvent(LightEventType*, bool initiallySignaled, EventClearMode eventClearMode); void FinalizeLightEvent(LightEventType*); diff --git a/include/nn/os/os_Event.h b/include/nn/os/os_Event.h new file mode 100644 index 00000000..b606dbee --- /dev/null +++ b/include/nn/os/os_Event.h @@ -0,0 +1,48 @@ +#pragma once + +#include +#include +#include +#include + +namespace nn::os { + +// todo: figure out where these go +void InitializeEvent(EventType*, bool initiallySignaled, EventClearMode eventClearMode); +void FinalizeEvent(EventType*); +void SignalEvent(EventType*); +void WaitEvent(EventType*); +bool TryWaitEvent(EventType*); +bool TimedWaitEvent(EventType*, nn::TimeSpan); +void ClearEvent(EventType*); + +class Event { + NN_NO_COPY(Event); + NN_NO_MOVE(Event); + +public: + explicit Event(EventClearMode clearMode) { InitializeEvent(&m_Event, false, clearMode); } + + ~Event() { FinalizeEvent(&m_Event); } + + void Wait() { WaitEvent(&m_Event); } + + bool TryWait() { return TryWaitEvent(&m_Event); } + + bool TimedWait(TimeSpan timeSpan) { return TimedWaitEvent(&m_Event, timeSpan); } + + void Signal() { SignalEvent(&m_Event); } + + void Clear() { ClearEvent(&m_Event); } + + operator EventType&() { return m_Event; } + + operator const EventType&() const { return m_Event; } + + EventType* GetBase() { return &m_Event; } + +private: + EventType m_Event; +}; + +} // namespace nn::os \ No newline at end of file diff --git a/include/nn/os/os_EventCommon.h b/include/nn/os/os_EventCommon.h new file mode 100644 index 00000000..1c75a20e --- /dev/null +++ b/include/nn/os/os_EventCommon.h @@ -0,0 +1,5 @@ +#pragma once + +namespace nn::os { +enum EventClearMode { EventClearMode_ManualClear, EventClearMode_AutoClear }; +} // namespace nn::os \ No newline at end of file diff --git a/include/nn/os/os_EventTypes.h b/include/nn/os/os_EventTypes.h new file mode 100644 index 00000000..497ded56 --- /dev/null +++ b/include/nn/os/os_EventTypes.h @@ -0,0 +1,26 @@ +#pragma once + +#include +#include +#include + +namespace nn::os { + +namespace detail { +class MultiWaitObjectList; +} // namespace detail + +struct EventType { + util::TypedStorage _multiWaitObjectList; + bool _signalState; + bool _initiallySignaled; + uint8_t _clearMode; + uint8_t _state; + uint32_t _broadcastCounterLower; + uint32_t _broadcastCounterUpper; + detail::InternalCriticalSectionStorage _csEvent; + detail::InternalConditionVariableStorage _cvSignaled; +}; +static_assert(std::is_trivial::value, "EventType non trivial"); + +} // namespace nn::os \ No newline at end of file diff --git a/include/nn/os/os_Mutex.h b/include/nn/os/os_Mutex.h index 77e00446..d091ca66 100644 --- a/include/nn/os/os_Mutex.h +++ b/include/nn/os/os_Mutex.h @@ -6,7 +6,7 @@ namespace nn::os { // todo: figure out where these go -void InitializeMutex(MutexType*, bool, s32); +void InitializeMutex(MutexType*, bool recursive, s32 lockLevel); void FinalizeMutex(MutexType*); void LockMutex(MutexType*); bool TryLockMutex(MutexType*); @@ -20,21 +20,29 @@ class Mutex { public: explicit Mutex(bool recursive) { InitializeMutex(&m_Mutex, recursive, 0); } - Mutex(bool, int); - + Mutex(bool recursive, s32 lockLevel) { InitializeMutex(&m_Mutex, recursive, lockLevel); }; + ~Mutex() { FinalizeMutex(&m_Mutex); } void Lock() { LockMutex(&m_Mutex); } - bool TryLock(); + bool TryLock() { return TryLockMutex(&m_Mutex); } + void Unlock() { UnlockMutex(&m_Mutex); } - bool IsLockedByCurrentThread() const; - void lock(); - bool try_lock(); - void unlock(); - operator MutexType&(); - operator const MutexType&() const; - MutexType* GetBase(); + + bool IsLockedByCurrentThread() const { return IsMutexLockedByCurrentThread(&m_Mutex); }; + + void lock() { Lock(); } + + bool try_lock() { return TryLock(); } + + void unlock() { Unlock(); } + + operator MutexType&() { return m_Mutex; } + + operator const MutexType&() const { return m_Mutex; } + + MutexType* GetBase() { return &m_Mutex; } private: MutexType m_Mutex; 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 bc0b08958565ed2606486441c2621047f7da4fe8 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/511] 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 beeb0df5..0a7056e8 100644 --- a/include/nn/os.h +++ b/include/nn/os.h @@ -141,8 +141,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); @@ -189,8 +187,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 3c6e05525080ea188cee7b13f2c5a36230921c0a 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/511] 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 c04fb575ec21db8457f21f158c3f60a9d51fb579 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/511] 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 dde73233a55c763c5875574b8ba5bb2e4a664460 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/511] 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 f614056bf264efe17ea3c3ab784dfc2ba50e5088 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/511] 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 c5327129189f432be4b77be6d6cb2bfb6f884a37 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/511] 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 8529ad2a840ffedd2f22b864ca52d0ad92e2c413 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/511] 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 8a4e5a04d1ca602dd7f550a2f85e569127ccd13d 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/511] 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 4aa45ac38e83e48fdc2dedb76f8f6a8c80626d68 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/511] 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 233e11a570ece83609a2e254e23ce411297a8866 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/511] 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 aada3bf382410c93e85672c7f22d2af9cb8ecbb4 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/511] 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 5e22880477fc5cf1f4df44db7e49d6cd51a8f8f7 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/511] 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 ccbb3c62f40d1ab25ee8a6c27ee8ba8aa78311b5 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/511] 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 6286ff1be22321ce2afc8dc365457424fdbcfc36 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/511] 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 916af453243ee87883d7600975474b5939a83f73 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/511] 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 320af07c6696a38ffd2e537097fe5a198d53c7be 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/511] 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 d29d398bda055227d57d7685a62b0ecb1513092c 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/511] 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 c6418cfa9a8ecedcad7c3fb7f4d449186fd0988b 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/511] 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 092bc78d932991392f1baafe2423eb62c5c984c5 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/511] 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 e455c021ba63690b128e4a720011d68067161356 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/511] 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 0b3e6a54ee7d22b517f674a078fa3d6ce6eca3c8 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/511] 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 545864bb5ed84809442e070806cb500cf5a5db23 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/511] 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 e00662dc11a64171c64d2260dff0533ea9c801e6 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/511] 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 a60b353ae1ed9dbd8172f2f6ea88f03dcd1b75b4 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/511] 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 e471e3afe2314a46c795880bb84d7a887c73b0a9 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/511] 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 753d657cbefade91af9960d4f323b61d19ce5d2c 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/511] 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 a53c8b6dc343413643c8b5a379441a7e1d3e3112 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/511] 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 e6b50874ddf474295fe595f274d2266d77d5ad6c 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/511] 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 e4b3e2d0b79fd0c1750cc44742c42f51f4530e3d 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/511] 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 250e63543ccfe10a64a6c2501ebc75af26d4e54d 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/511] 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 80a03e0d51848d8c42547c811d60e8526b245ed9 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/511] 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 c87cb113618567e098c2402d240cd01930caf5e2 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/511] 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