From e682b1a49395e380ceb5af2f456cfbdb5d40c0fc Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 19 Feb 2026 11:57:48 -0300 Subject: [PATCH 001/182] atk: Add `nn::atk` header files Filenames are based on DWARF info from the `.nss` inside Bloons TD5's romFS --- CMakeLists.txt | 136 ++++++++++++++++-- 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(+), 14 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 8821282..7643dd4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -202,15 +202,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/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 @@ -232,6 +223,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 0000000..e69de29 diff --git a/include/nn/atk/atk_AudioRendererPerformanceReader.h b/include/nn/atk/atk_AudioRendererPerformanceReader.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/atk_BiquadFilterCallback.h b/include/nn/atk/atk_BiquadFilterCallback.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/atk_ChannelMixVolume.h b/include/nn/atk/atk_ChannelMixVolume.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/atk_DeviceOutRecorder.h b/include/nn/atk/atk_DeviceOutRecorder.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/atk_EffectAux.h b/include/nn/atk/atk_EffectAux.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/atk_EffectBase.h b/include/nn/atk/atk_EffectBase.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/atk_FinalMix.h b/include/nn/atk/atk_FinalMix.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/atk_FsSoundArchive.h b/include/nn/atk/atk_FsSoundArchive.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/atk_Global.h b/include/nn/atk/atk_Global.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/atk_OutputMixer.h b/include/nn/atk/atk_OutputMixer.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/atk_OutputReceiver.h b/include/nn/atk/atk_OutputReceiver.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/atk_ProfileReader.h b/include/nn/atk/atk_ProfileReader.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/atk_SequenceSoundHandle.h b/include/nn/atk/atk_SequenceSoundHandle.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/atk_SoundActor.h b/include/nn/atk/atk_SoundActor.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/atk_SoundArchive.h b/include/nn/atk/atk_SoundArchive.h new file mode 100644 index 0000000..e69de29 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 c364664..616d3fe 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 0000000..e69de29 diff --git a/include/nn/atk/atk_SoundHeap.h b/include/nn/atk/atk_SoundHeap.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/atk_SoundMemoryAllocatable.h b/include/nn/atk/atk_SoundMemoryAllocatable.h new file mode 100644 index 0000000..e69de29 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 0000000..e69de29 diff --git a/include/nn/atk/atk_SoundSystem.h b/include/nn/atk/atk_SoundSystem.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/atk_StreamSoundHandle.h b/include/nn/atk/atk_StreamSoundHandle.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/atk_SubMix.h b/include/nn/atk/atk_SubMix.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/atk_TaskProfileReader.h b/include/nn/atk/atk_TaskProfileReader.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h b/include/nn/atk/detail/atk_AddonSoundArchiveContainer.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_AdvancedWaveSound.h b/include/nn/atk/detail/atk_AdvancedWaveSound.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h b/include/nn/atk/detail/atk_AdvancedWaveSoundFile.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_AdvancedWaveSoundFileReader.h b/include/nn/atk/detail/atk_AdvancedWaveSoundFileReader.h new file mode 100644 index 0000000..e69de29 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 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_BankFileReader.h b/include/nn/atk/detail/atk_BankFileReader.h new file mode 100644 index 0000000..e69de29 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 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_BinaryTypes.h b/include/nn/atk/detail/atk_BinaryTypes.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_BiquadFilterPresets.h b/include/nn/atk/detail/atk_BiquadFilterPresets.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_BusMixVolumePacket.h b/include/nn/atk/detail/atk_BusMixVolumePacket.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_Command.h b/include/nn/atk/detail/atk_Command.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_CommandManager.h b/include/nn/atk/detail/atk_CommandManager.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_Config.h b/include/nn/atk/detail/atk_Config.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_CurveAdshr.h b/include/nn/atk/detail/atk_CurveAdshr.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_CurveLfo.h b/include/nn/atk/detail/atk_CurveLfo.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_Debug.h b/include/nn/atk/detail/atk_Debug.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_DriverCommand.h b/include/nn/atk/detail/atk_DriverCommand.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_DspadpcmReader.h b/include/nn/atk/detail/atk_DspadpcmReader.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_ElementType.h b/include/nn/atk/detail/atk_ElementType.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_ExternalSoundPlayer.h b/include/nn/atk/detail/atk_ExternalSoundPlayer.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_FrameHeap.h b/include/nn/atk/detail/atk_FrameHeap.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_GroupFile.h b/include/nn/atk/detail/atk_GroupFile.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_GroupFileReader.h b/include/nn/atk/detail/atk_GroupFileReader.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_IRegionInfoReadable.h b/include/nn/atk/detail/atk_IRegionInfoReadable.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_IStreamDataDecoder.h b/include/nn/atk/detail/atk_IStreamDataDecoder.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_InstancePool.h b/include/nn/atk/detail/atk_InstancePool.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_IntrusiveList.h b/include/nn/atk/detail/atk_IntrusiveList.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_ItemType.h b/include/nn/atk/detail/atk_ItemType.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_LoaderManager.h b/include/nn/atk/detail/atk_LoaderManager.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_LowLevelVoice.h b/include/nn/atk/detail/atk_LowLevelVoice.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_MemoryFileStream.h b/include/nn/atk/detail/atk_MemoryFileStream.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_MoveValue.h b/include/nn/atk/detail/atk_MoveValue.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_OutputAdditionalParam.h b/include/nn/atk/detail/atk_OutputAdditionalParam.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_PlayerHeap.h b/include/nn/atk/detail/atk_PlayerHeap.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_PlayerHeapDataManager.h b/include/nn/atk/detail/atk_PlayerHeapDataManager.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_RegionManager.h b/include/nn/atk/detail/atk_RegionManager.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_SequenceSound.h b/include/nn/atk/detail/atk_SequenceSound.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_SequenceSoundFile.h b/include/nn/atk/detail/atk_SequenceSoundFile.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_SequenceSoundFileReader.h b/include/nn/atk/detail/atk_SequenceSoundFileReader.h new file mode 100644 index 0000000..e69de29 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 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_SoundArchiveFileReader.h b/include/nn/atk/detail/atk_SoundArchiveFileReader.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_SoundArchiveLoader.h b/include/nn/atk/detail/atk_SoundArchiveLoader.h new file mode 100644 index 0000000..e69de29 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 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_SoundRuntimeUtility.h b/include/nn/atk/detail/atk_SoundRuntimeUtility.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_StartInfoReader.h b/include/nn/atk/detail/atk_StartInfoReader.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_StreamSound.h b/include/nn/atk/detail/atk_StreamSound.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_StreamSoundFile.h b/include/nn/atk/detail/atk_StreamSoundFile.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_StreamSoundFileLoader.h b/include/nn/atk/detail/atk_StreamSoundFileLoader.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_StreamSoundFileReader.h b/include/nn/atk/detail/atk_StreamSoundFileReader.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_StreamSoundPrefetchFile.h b/include/nn/atk/detail/atk_StreamSoundPrefetchFile.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_StreamSoundPrefetchFileReader.h b/include/nn/atk/detail/atk_StreamSoundPrefetchFileReader.h new file mode 100644 index 0000000..e69de29 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 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_TaskManager.h b/include/nn/atk/detail/atk_TaskManager.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_TaskThread.h b/include/nn/atk/detail/atk_TaskThread.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_ThreadInfoReader.h b/include/nn/atk/detail/atk_ThreadInfoReader.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_Util.h b/include/nn/atk/detail/atk_Util.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_ValueArray.h b/include/nn/atk/detail/atk_ValueArray.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_Voice.h b/include/nn/atk/detail/atk_Voice.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_VoiceCommand.h b/include/nn/atk/detail/atk_VoiceCommand.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_VolumeThroughModePacket.h b/include/nn/atk/detail/atk_VolumeThroughModePacket.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_WavBinary.h b/include/nn/atk/detail/atk_WavBinary.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_WavOutFileStream.h b/include/nn/atk/detail/atk_WavOutFileStream.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_WaveArchiveFile.h b/include/nn/atk/detail/atk_WaveArchiveFile.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_WaveArchiveFileReader.h b/include/nn/atk/detail/atk_WaveArchiveFileReader.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_WaveFile.h b/include/nn/atk/detail/atk_WaveFile.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_WaveFileReader.h b/include/nn/atk/detail/atk_WaveFileReader.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_WaveSound.h b/include/nn/atk/detail/atk_WaveSound.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_WaveSoundFile.h b/include/nn/atk/detail/atk_WaveSoundFile.h new file mode 100644 index 0000000..e69de29 diff --git a/include/nn/atk/detail/atk_WaveSoundFileReader.h b/include/nn/atk/detail/atk_WaveSoundFileReader.h new file mode 100644 index 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 From b02f6aa006485bb70aec7b5eb8e72dd2fe04beb6 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/182] 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 e69de29..3a17174 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 b4857254528e39e417b6ca33c9285e89062d6baa 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/182] 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 e69de29..77ea43a 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 e69de29..7d4b99a 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 e69de29..8221326 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 bfaba6ea575f7f666d88a3b25e0f7deee013c8b3 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/182] 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 e69de29..9deb2c6 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 7d4b99a..83d57af 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 0fdf5d827d17284e131440ce91ee0d324c4885c2 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Thu, 19 Feb 2026 19:54:16 -0300 Subject: [PATCH 005/182] `nn::util`: Defined `IntrusiveListNode` --- include/nn/util/util_IntrusiveList.h | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 include/nn/util/util_IntrusiveList.h diff --git a/include/nn/util/util_IntrusiveList.h b/include/nn/util/util_IntrusiveList.h new file mode 100644 index 0000000..4e0e99d --- /dev/null +++ b/include/nn/util/util_IntrusiveList.h @@ -0,0 +1,8 @@ +#pragma once + +namespace nn::util { +struct IntrusiveListNode { + IntrusiveListNode* m_Prev; + IntrusiveListNode* m_Next; +}; +} // namespace nn::util \ No newline at end of file From 32e06ad9f5e893aac17f2cd1c95958e866f4bd5f 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 006/182] 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 e69de29..5d4198b 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 48e711e634f72bd4606fed29c0dbaab61c3ed405 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 007/182] 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 e69de29..aad67ef 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 448b29daed8fe4405f8a2ffd7b40fa950dc6a7fa 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 008/182] 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 e69de29..5ce66ce 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 cedbed18ee6c9c55f124b73a4d52b0786a7864a5 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 009/182] 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 e69de29..9ee0483 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 fe832d62acb4ace14f7c1b212161539c4ab90da5 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 010/182] 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 e69de29..2fa628e 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 29e62b5f572b4db3e7fd481e4f5cd89b12f8068d 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 011/182] 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 e69de29..ac41fb9 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 4671b808b0cfcda53652132f1a973f43651d6a3e 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 012/182] 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 e69de29..d84e0b4 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 646cb83f4003a1dc7ef120460218e3e942ece39b 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 013/182] 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 e69de29..5ee2cf1 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 ac41fb9..dd290a1 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 2aa128f64db0c2e4d2f13ead46f2a21da20d838c 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 014/182] 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 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 0000000..e69de29 From 7deb285b9b43f85f854383fe92da5f8a4aceffc6 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 015/182] 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 7643dd4..89a01d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -178,6 +178,7 @@ add_library(NintendoSDK OBJECT include/nn/util/util_BitPack.h include/nn/util/util_BytePtr.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 e69de29..53ed578 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 8221326..cfd0e1f 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 e69de29..f805308 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 e69de29..f7cf7da 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 e69de29..70db1dc 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 2c74b57d7260c5e38d7e3f53314cda946a219119 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 016/182] 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 53ed578..b8a148c 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 e69de29..bd391fe 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 e69de29..f904a18 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 dd290a1..028fac9 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 aef995a0f4b4b4361b381bf1fc8c249b096eb006 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 017/182] 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 e69de29..fcb4d18 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 7c006febf70f85faa195aeb79fbd6debf3efccb9 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 018/182] 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 e69de29..5337c82 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 63454dbc606a65e6c5bdd9ca49f3138f9b86db27 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 019/182] 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 e69de29..50b8334 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 8b5d806d12f384861c984b0a5e6a92e276e9682e 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 020/182] 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 e69de29..eb7ca6d 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 efe63d4ca5e99f8e99c1516fe0b13e45d0a48781 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 021/182] 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 e69de29..3e20155 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 c566f9bb8f432f151afbd2e375457faad841221a 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 022/182] 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 9ee0483..1039cf6 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 e69de29..53c24fa 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 f8d0e30954f65d841daac708c8dd9d593ac40997 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 023/182] 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 e69de29..6210120 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 eb7ca6d..929681b 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 9ee263bba45aa577124c40e6e9f1fe45d2a05385 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 024/182] 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 e69de29..3329eb7 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 ed1f96742b7e95e61ef451a0be3e30beae36b623 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 025/182] 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 89a01d4..01c6adc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -224,6 +224,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 77ea43a..09704a1 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 0000000..123e8ab --- /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 3f49f40494717583bb39ecf4ca2bcfd787f59e2a 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 026/182] 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 9deb2c6..76f30e8 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 e69de29..941d5a2 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 1b941b91db9fd0ecc3bda12836637892db308b39 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 027/182] 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 01c6adc..4c94d29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -227,18 +227,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 @@ -251,50 +243,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 @@ -302,56 +279,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 b8a148c..d1c22db 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 616d3fe..a42848b 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 3329eb7..a41fa5e 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 cfd0e1f..6c47205 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 6210120..24f01d1 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 bd391fe..cb170a3 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 929681b..a865a0f 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 5337c82..ccf7e2f 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 53c24fa..d91fcb3 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 3e20155..d001cb4 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 d84e0b4..dfebc38 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 5ee2cf1..c215feb 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 50b8334..62dd56e 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 593e9f139ae91d21f045e83b3e9e6569b194dddc 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 028/182] 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 f7cf7da..608aa27 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 70db1dc..17a58b6 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 940dbd7f1ec76412255d69e608d5eaad8da4ccf3 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 029/182] 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 e69de29..74879b2 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 8f2ed0619a006387c077b53565b561027148683f 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 030/182] 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 e69de29..4c7cf25 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 9bf018f52b7b3b9b97daf30d7133cdf20ace9f0d 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 031/182] 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 17a58b6..fb35700 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 5f756c79ffddb188b59604efc71f07f929b8ac42 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 032/182] 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 e69de29..b2f0d02 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 4c7cf25..3587882 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 06b6c43886f5168cc32c34e393906f1cb0ad3d40 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 033/182] 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 4c94d29..bc59305 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -353,7 +353,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 @@ -367,6 +366,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 e69de29..0000000 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 0000000..be2b3ef --- /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 ebfe0d9fde5e6e795c379ea69bf439562f25c7ac 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 034/182] 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 e69de29..dd3fcf7 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 d1c22db..9418043 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 30f5e22eb3be228ea1b1ed3aa313f80f4e8581de 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 035/182] 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 e69de29..0000000 diff --git a/include/nn/atk/submix/atk_OutputReceiver.h b/include/nn/atk/submix/atk_OutputReceiver.h new file mode 100644 index 0000000..cb9d1cd --- /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 8fd29d2c77843d313c7b8ca8423a8ad0a1b06e33 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 036/182] 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 aad67ef..0d4b1e1 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 e69de29..5f9101d 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 927caea71dadcb5b961749471187a55f0bc32aab 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 037/182] 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 e69de29..e81eaa1 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 734f8dc8761b107e2867439279317a830e0f7424 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 038/182] 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 e69de29..b8486f4 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 e9a349e9b962af9af6e5caae5678df06a823e704 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 039/182] 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 e69de29..4c20b6f 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 453cfa5dccd214aef42d638bd58fb573b239f293 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 040/182] 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 e69de29..e371f28 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 42440711c6293a848d5704b34ac97ddbefb481ed 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 041/182] 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 e69de29..9d5f9de 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 4c425e3fbf24688c4d7b0e4a14de106f113f4825 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 042/182] 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 e69de29..e995a92 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 ac23c8d5c87421cbafa591b1378e22bec55a6b98 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 043/182] 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 0000000..e533772 --- /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 2603b5bd6be8d5ee4ef7f1acd8fd248eabddbb52 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 044/182] 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 bc59305..df82d5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,12 +225,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 @@ -347,6 +348,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 0000000..dfcc501 --- /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 2c1e8ac1f05f6b54a27a8a168cec70c0cfc26498 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 045/182] 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 e69de29..6d3878c 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 e4414ca60f70ef7341dfbefd04a8895ec70fc45a 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 046/182] 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 e69de29..a4a1ca6 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 acee425c5d2f49a4165b7f5a9b9452df5c48391f 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 047/182] 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 83d57af..dc22a4a 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 9d5f9de..081d913 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 a4a1ca6..8e97043 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 5504f7d7cc51ac3ea2908885f32280bcaaca1057 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 048/182] 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 e69de29..d9920f5 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 7ff462e5201ec962b9fd1866df6d5884014a5d44 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 049/182] 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 028fac9..515b971 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 e69de29..6e105ec 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 8e97043..962c271 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 fe0445b2e3605223f9413edb04ac62c9d0ab131f 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 050/182] 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 e69de29..3aeff63 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 ede2eb42c35382884b372b13e9cb830774ae227a 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 051/182] 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 e69de29..0ab0a04 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 4249dce9f5a55d074a504b5961483a2787df78e4 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 052/182] 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 e69de29..e4d53eb 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 fd46ec32e1b8af4e542dd7aece5dcf9d2d167358 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 053/182] 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 e69de29..d8e5a27 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 02d5c6592be0f4f44bafe20d96acee362e8155a5 Mon Sep 17 00:00:00 2001 From: Nitr4m12 <67806925+Nitr4m12@users.noreply.github.com> Date: Mon, 23 Feb 2026 14:24:19 -0300 Subject: [PATCH 054/182] `nn::util`: Add more declarations for IntrusiveLists --- include/nn/util/util_IntrusiveList.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/nn/util/util_IntrusiveList.h b/include/nn/util/util_IntrusiveList.h index 4e0e99d..e08e08f 100644 --- a/include/nn/util/util_IntrusiveList.h +++ b/include/nn/util/util_IntrusiveList.h @@ -5,4 +5,26 @@ struct IntrusiveListNode { IntrusiveListNode* m_Prev; IntrusiveListNode* m_Next; }; + +namespace detail { +class IntrusiveListImplementation { +private: + IntrusiveListNode m_Root; +}; +} // namespace nn::util::detail + +template +class IntrusiveListBaseNode : IntrusiveListNode {}; + +template +class IntrusiveListBaseNodeTraits {}; + +template +class IntrusiveListMemberNodeTraits {}; + +template > +class IntrusiveList { +private: + detail::IntrusiveListImplementation m_Implementation; +}; } // namespace nn::util \ No newline at end of file From c9160824fc13c669332605a3cc7c98f6acbf2c24 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 055/182] 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 dc22a4a..d40f912 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 eb19647..5e50049 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 416dbb9991c5cce95907a8fa7421601b71d85b1e 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 056/182] atk: Define `detail::PlayerHeap` and `detail::CallbackNode` --- include/nn/atk/atk_SoundMemoryAllocatable.h | 2 +- include/nn/atk/detail/atk_PlayerHeap.h | 51 +++++++++++++++++++++ include/nn/util/util_IntrusiveList.h | 4 +- 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/include/nn/atk/atk_SoundMemoryAllocatable.h b/include/nn/atk/atk_SoundMemoryAllocatable.h index 0d4b1e1..8c1cde1 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 e69de29..079b57c 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 diff --git a/include/nn/util/util_IntrusiveList.h b/include/nn/util/util_IntrusiveList.h index e08e08f..6eb7762 100644 --- a/include/nn/util/util_IntrusiveList.h +++ b/include/nn/util/util_IntrusiveList.h @@ -19,10 +19,10 @@ class IntrusiveListBaseNode : IntrusiveListNode {}; template class IntrusiveListBaseNodeTraits {}; -template +template class IntrusiveListMemberNodeTraits {}; -template > +template class IntrusiveList { private: detail::IntrusiveListImplementation m_Implementation; From 00de83e9a0f470d239472921b3cdfb80608c16c8 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 057/182] 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 e69de29..de85296 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 753195018ec9ce445c0a88b104f9f3355dc71a3c 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 058/182] 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 3711c77..ad2c0d0 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 079b57c..dcea5c8 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 02d9d182025fa5cae24f485a55b2135ba16aea81 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 059/182] 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 e69de29..530c397 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 9e5f89607068c004c0d227e2b6389c32137bdae8 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 060/182] 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 e69de29..8700089 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 c7d26930b6388c6bb9f3181f83eae7679c17ba8b 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 061/182] 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 0000000..f1cf46f --- /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 f6ecc1c5ac0cd77b67b3d2541ca7e894154fdfac 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 062/182] 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 0000000..964c3a3 --- /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 dfcc501..aa9c002 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 f776a46d7b6e2f6b607107221627198cb983915a 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 063/182] audio: Add files to CMakeLists --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index df82d5c..8cac161 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,7 +225,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 ec3c4ebd8793cd17dbd2f8549762e40ae6b1b909 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 064/182] 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 8cac161..ee9cdd9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -228,6 +228,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 0000000..c09cc11 --- /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 59f46bc05a6146c8004c5305d0d932129c9d6329 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 065/182] 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 ee9cdd9..234bc59 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -229,6 +229,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 aa9c002..fcd8a96 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 f1cf46f..31d0c14 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 c09cc11..08434be 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 0000000..69faf8e --- /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 ecc7a7f43f7da3f3371b82e21ba70625c91be10c 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 066/182] 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 e69de29..e1fc7d2 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 8548c1ca15afa832b6163f9683d7e08a70cc48c8 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 067/182] 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 e69de29..d1b0539 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 780c54ff1dbf05e5c6861b8c73148109a8823486 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 068/182] 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 608aa27..7a91f27 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 b2f0d02..7a9502b 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 e69de29..6c0d2eb 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 fb35700..179b375 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 b585d07f508858a7af39147240b2d0b48cdce039 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 069/182] 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 e69de29..24fe6d5 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 873b0e11bded70735a4514e734d4ecf767986f91 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 070/182] 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 1039cf6..46bb16f 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 e69de29..850b69a 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 7d14f2dfbc3a02db85229b3548af02ca4dce12dc 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 071/182] 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 e69de29..bde9626 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 df2ad83acecd27e3aa48439589ee3273078834de 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 072/182] 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 e69de29..519448c 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 0d09bb3337f89aed9b9afab1a65156b7a125bb30 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 073/182] atk: Define `detail::SoundInstanceManager` Other changes: - util: Added type-aliases --- .../nn/atk/detail/atk_SoundInstanceManager.h | 30 ++++++++++ include/nn/util/util_IntrusiveList.h | 60 ++++++++++++++++++- 2 files changed, 89 insertions(+), 1 deletion(-) diff --git a/include/nn/atk/detail/atk_SoundInstanceManager.h b/include/nn/atk/detail/atk_SoundInstanceManager.h index e69de29..49fa6bb 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 diff --git a/include/nn/util/util_IntrusiveList.h b/include/nn/util/util_IntrusiveList.h index 6eb7762..fb163cb 100644 --- a/include/nn/util/util_IntrusiveList.h +++ b/include/nn/util/util_IntrusiveList.h @@ -1,5 +1,7 @@ #pragma once +#include + namespace nn::util { struct IntrusiveListNode { IntrusiveListNode* m_Prev; @@ -8,6 +10,32 @@ struct IntrusiveListNode { namespace detail { class IntrusiveListImplementation { +public: + using value_type = IntrusiveListNode; + using reference = value_type&; + using const_reference = const value_type&; + + class iterator { + public: + using value_type = value_type; + using pointer = value_type*; + using reference = value_type&; + + private: + pointer m_Node; + }; + + class const_iterator { + public: + using value_type = value_type; + using reference = value_type&; + using pointer = value_type*; + using difference_type = int; + + private: + pointer m_Node; + }; + private: IntrusiveListNode m_Root; }; @@ -17,13 +45,43 @@ template class IntrusiveListBaseNode : IntrusiveListNode {}; template -class IntrusiveListBaseNodeTraits {}; +class IntrusiveListBaseNodeTraits { +public: + using BaseNodeType = IntrusiveListBaseNode; +}; template class IntrusiveListMemberNodeTraits {}; template class IntrusiveList { +public: + using value_type = T; + using reference = T&; + using const_reference = const T&; + + class iterator { + public: + using value_type = value_type; + using reference = value_type&; + using pointer = value_type*; + + private: + detail::IntrusiveListImplementation::iterator m_Iterator; + }; + using reverse_iterator = std::reverse_iterator; + + class const_iterator { + public: + using value_type = value_type; + using reference = value_type&; + using pointer = value_type*; + + private: + detail::IntrusiveListImplementation::const_iterator m_Iterator; + }; + using const_reverse_iterator = std::reverse_iterator; + private: detail::IntrusiveListImplementation m_Implementation; }; From d993f390c42ff7e5f06ba90948cd33182c10fb1c 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 074/182] 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 e69de29..34dbe34 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 f1286e30e54c9e0414d00a77c514d517061b083d 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 075/182] 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 0000000..ebc3cc1 --- /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 db521b37044d026410499840684e2500c57f7bd7 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 076/182] 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 e69de29..5fb79e4 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 b80560c9b720e3d5a9e71346a10b0b23e00ddfc6 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 077/182] 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 e69de29..2f86cd0 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 b0e2fdcc42bc01522b533ce84b0833d93e4fdecd 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 078/182] 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 234bc59..2170ca4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -229,6 +229,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 0000000..7e11429 --- /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 ac1e082518bceeb7e63f7095aa92200ddba38ad2 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 079/182] 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 2170ca4..76d9c20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -229,6 +229,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 34dbe34..c8247a3 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 0000000..272f3fb --- /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 2ca714da25ddaf7d67e6e594b14b19849730c48e 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 080/182] 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 e69de29..0d478f4 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 442e712859240c61708ac2961f7e84443ca9ee72 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 081/182] 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 5d4198b..19fe670 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 e69de29..b28829e 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 519448c..bbb885d 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 8d6f1bd8a85056becf0c28c79b6788998652132a 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 082/182] 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 e69de29..ae4b38d 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 bc38e1008f504b694ea27e5141ccc5bfa48ff868 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 083/182] 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 e69de29..28d258c 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 ae4b38d..9696c2c 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 0d478f4..629f9b6 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 d7bb75a163b0a102b3436ec20bea45899682528a 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 084/182] 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 e69de29..1b9d0b3 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 6681340a4a6a3d0a0eaac3bcb51695cf2f890cd3 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 085/182] 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 f9366c6..8bb7e1e 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 19fe670..8a6d14c 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 b28829e..902e7db 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 bbb885d..4563bc2 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 6e105ec..1b52fdf 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 778765ee6a203e266241fcfd6b8503e5a5877201 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 086/182] 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 e69de29..8743fda 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 8452afd354fd27db0b7ec8438705e763f6f42267 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 087/182] 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 e69de29..e88d5d8 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 3d303b0d71fc7a0a8fd84abad800639719231030 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 088/182] 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 e69de29..f2f8a7b 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 823ef47c30c29b97cf3f0d6b3e082a1704a14499 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 089/182] 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 9418043..31131a3 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 e69de29..6ae7f6f 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 c8247a3..fc879c4 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 55f3735d608ff0f81dcdc1b74a298422b0434abc 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 090/182] 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 e69de29..a5e57d6 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 eb8b4f37b14c171aeebd2b69b75420b773cc4e14 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 091/182] 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 1b9d0b3..7f1776d 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 9807b84..99197a1 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 e46546713bd635c9db23f3feea8db923c5356ae3 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 092/182] 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 8a6d14c..a71f557 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 e69de29..ebcc475 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 b60032ecc6bc9ab82ab89ce2dbf125ad9ebed59f 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 093/182] 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 e69de29..a3d5cdc 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 51840075f470dbb804f596ccf0cd107c0eea94d1 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 094/182] 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 e69de29..def3e50 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 8468e2bd6cb65c5ed5645f6c1ea5ed715bdf8be3 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 095/182] 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 e69de29..7487f85 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 0396c4e0364825fd663c0e2fb76bc4b53df3efa1 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 096/182] 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 e69de29..574f6ca 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 3b2c06265eae0f98e41928eeb9d6a1339302253e 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 097/182] 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 e69de29..705da2d 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 e995a92..0a8ea46 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 629f9b6..f158558 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 db4f038d59af900e9648d2fd9b804fd6c37cb6da 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 098/182] 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 24fe6d5..51780d1 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 e96b93e..1be2e52 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 9f6158a6b41f885af840827b01ce7d88537c20e7 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 099/182] 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 e69de29..6f3504d 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 61f63f5b26012e447a3090da0c47fc65194ca5d3 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 100/182] 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 e69de29..0bea094 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 e69de29..ab767f2 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 e2fb4a42e8b2caf9e6ff45c5077ef304e9140352 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 101/182] 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 e69de29..5af0115 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 c157f28079ed5223dfff337932996e7b08c2ca27 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 102/182] 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 a3d5cdc..1f4eba2 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 e69de29..31c1bd0 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 5562247dec2a2a5671ef9940f59362894a18b471 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 103/182] 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 e69de29..bc48d62 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 04e882869ce9ccdf103c6975fcaca7ea64e115d7 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 104/182] 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 e69de29..6a9852c 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 b70066644f8bef686a93b1da8bf35adc111df42f 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 105/182] 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 e69de29..7119bb9 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 cf0d43b9f401dc65074d53fb5b7076b4ef724ad4 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 106/182] 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 8743fda..f0f5ca7 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 e69de29..e925912 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 fafdc747fd5da05164cebd3dbff4d423152ac65a 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 107/182] 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 5fb79e4..1d443b5 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 e69de29..91ffaff 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 eda7aff5549a4031adbba08fc66480a0dbd3f2d5 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 108/182] 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 e69de29..03c062f 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 b0c2d2fa1aa09089874464c4839e770f828be0bb 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 109/182] 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 e69de29..5478fb8 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 c848a1100d91da9edf3a7531fcd3dd404bca24f9 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 110/182] 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 e69de29..0513419 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 fa98052252e2236c12ccdeba3ff5741c831b4ae9 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 111/182] 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 e69de29..131b80d 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 f71c717ae03ce5674c10652ffc3ec2b391ac501a 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 112/182] 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 f0f5ca7..0352f6d 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 7119bb9..51b88e2 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 e69de29..f149d84 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 c61472aeed4f8243ff40e0708b7dd9179947e618 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 113/182] 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 e69de29..fdddd69 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 216fe2d3831e66d366a6794e5048b424951ad69f 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 114/182] 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 fdddd69..b0c5c4d 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 316f0ea628ec68bfdf5b9a467140a45651624df0 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 115/182] 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 d40f912..0b26ce6 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 e69de29..4708b38 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 751faa4770bf6e51736189e2365760e8350772f0 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 116/182] 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 e69de29..e18d20d 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 f6fd9ddd449c0fa3001d8393db2cf05c5fb66a53 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 117/182] 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 e69de29..9dd5ba5 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 fd442d74c474d66191f7b97bd2aa843c85821b7d 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 118/182] 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 e69de29..395b8c2 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 9fddbe60bc8eeab27d5b21eb777a872ce6b95d5d 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 119/182] 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 395b8c2..ab9d60e 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 4708b38..c5c6a2e 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 6e01ca58058ed4f4f51cf8ca5814b248ba40d432 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 120/182] 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 e69de29..5b1c66c 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 6895e2f0157b8c59c457680e06c77f7fd4121284 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 121/182] 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 e69de29..9f47f62 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 9dd5ba5..91ad028 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 ed6d9b66b769c0a1fbafa0d5121f80ccc08b0ef6 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 122/182] 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 e69de29..bb0a09e 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 13939e86376a9437e464437c560ab118def0bb08 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 123/182] 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 d001cb4..cb2077a 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 e69de29..5401ed3 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 0e493a0a34e67ac7a8075e7cdeba7a193ca036d0 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 124/182] 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 e69de29..f06cc73 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 ab9d60e..3bfd25d 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 54a9c879a83b152e929fef562b9d79cc54e20470 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 125/182] 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 7f1776d..1e5fe52 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 28d258c..a7a6a05 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 5e50049..ad2839c 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 9696c2c..df6c057 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 f06cc73..479a9fd 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 3bfd25d..5cca307 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 9b394063d2040f0628924aeab77ff84f191c835b 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 126/182] 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 e4d53eb..e3e65bf 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 1be2e52..d30ef9e 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 5cca307..8df451c 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 5401a5f..3efe1eb 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 c5c6a2e..9d7368e 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 f516b81a9225f55ba17ab08a91952529e95fc2b0 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 127/182] 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 e69de29..6f7fe0a 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 f1df8a5e2e83d6e9c671e78e9fdbf222b8e83745 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 128/182] 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 a41fa5e..653bdcb 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 1e5fe52..dbadae1 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 e69de29..76e0ed0 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 5f26a89203ba692e951a6f2c66c0585de10d0981 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 129/182] 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 e69de29..6a4aee8 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 e508f2f573abe6b88b36af5467a5dff2d84d01e0 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 130/182] 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 8df451c..db2544e 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 e69de29..581ffc1 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 b2f69c5a5994af9abd4381a957cce31fc1294fe5 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 131/182] 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 e69de29..c047307 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 680816bdd05eaa58f3b3a28d8d2926bf6bef51fa 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 132/182] 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 31131a3..392fb35 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 ad2839c..4ecd47f 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 479a9fd..3e29c36 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 3efe1eb..9d165a0 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 76e0ed0..a0eb498 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 131b80d..8e26655 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 e69de29..40978cd 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 dcd92bebbcdfc244b1d9a7732267016918889dec 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 133/182] 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 c956da8..096545a 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 8aaadfa8e0c26e10436718b423e6b70ccf874e86 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 134/182] 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 9d165a0..5e6a014 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 8e26655..d01c2e4 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 16863f4..60c47e9 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 096545a..2519b57 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 f67b334015c2f967aa1fd1f7d8decd5bceb4219f 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 135/182] 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 76d9c20..b542510 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -229,6 +229,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 0000000..a7a0c40 --- /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 041f4fce09c885eb1a7ce8dedd23dcd88bd34bbc 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 136/182] 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 a42848b..ef27d05 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 6ae7f6f..24a3e9d 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 dbadae1..1da59b2 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 a7a6a05..cc23ecd 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 4ecd47f..601c9c1 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 df6c057..911aa98 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 3e29c36..dd89367 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 db2544e..9a888e5 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 a0eb498..db17a27 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 9d7368e..ab3a2cd 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 60c47e9..b258887 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 40978cd..e71be46 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 c047307..58a8406 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 2519b57..2114fcd 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 d34e45d3d5dfaa0caf9c07da69be2f2f461e013b 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 137/182] 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 b542510..1250075 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,6 +232,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 0000000..4380b22 --- /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 eccb27623608aad15380026d185c7ad20c70c17c 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 138/182] 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 1250075..8794bc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -233,6 +233,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 0000000..d9775ff --- /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 39338641ecf5736120442cd310629c6db9be9ec7 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 139/182] 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 8794bc5..fed0f2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -236,6 +236,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 0000000..282ae5d --- /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 e3e69d78c34229dad6097f3e7c39f564d2ce4c70 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 140/182] 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 1b52fdf..a5b53cd 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 e69de29..2a0718a 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 bf71846011b85285c039a76110a8856d5a4d8f6f 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 141/182] 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 d9920f5..c4bb420 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 e69de29..dedc900 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 e9cd1a8ae6a149358f0ab6a6c1df671c89601cc4 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 142/182] 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 e69de29..c2c5a1b 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 f614685227d1dd7b60b761de5fd6d930a9aaf7b0 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 143/182] 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 e69de29..ff03e10 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 1c9c114821ee1d2c04278ddad434e3e85a2f94fd 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 144/182] 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 e69de29..1ebf113 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 8cbf4ae22a64e3d37e889aa1d4de9a6260b4156c 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 145/182] 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 1ebf113..67da636 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 e69de29..f0695ab 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 587a3727aaece81f65420a5bde76f56cae6e0776 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 146/182] 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 e1fc7d2..5c46ca7 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 d1b0539..42ae92b 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 e69de29..a769aa5 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 6ef5de683d5ce2d7b7c8fbc2eba3d6258f9adac2 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 147/182] 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 e69de29..4de88fc 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 a769aa5..c212856 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 cb9d1cd..1630a72 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 c4073f4367f0b75a448fa98bba66f774adda7fcc 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 148/182] 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 e69de29..245fb53 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 b4ed98d7c26b7642b9e226f4ae0f2573df90f40b 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 149/182] 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 941d5a2..49fdbe2 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 49765663c81b3001b3a43bc1a6b9161dd9c5ac87 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 150/182] 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 76f30e8..c97efed 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 e69de29..2fda28b 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 ffb288470c23eb957ce5217dbb5ab681a488a5e1 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 151/182] 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 e69de29..c7cde75 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 097024d20d63af86eab63056e3bedd315ef21b37 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 152/182] 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 e69de29..a884dd4 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 507ac748fc64c1e9a5fc40073c5a11a33abb8220 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 153/182] 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 e69de29..2f972fd 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 c3a4d99686df04145134353226a30a31ce9d74b9 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 154/182] 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 e69de29..a291f48 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 2be7fc2a01b04cb7710a98504c9ea671ddfec6f5 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 155/182] 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 a291f48..2710b3f 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 e69de29..49239c6 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 10d38433b1ebdab6108175caa11e5752d3a9ab60 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 156/182] 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 e69de29..5e5c206 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 9ecc633a3d25fcd6f69fdf48346760239051bcdc 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 157/182] 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 e69de29..cdfb98c 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 2fda28b..d452cfb 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 1c2ed8f43c95ec679047eeb67dac90343a1c3c99 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 158/182] 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 e69de29..a2862b6 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 3d42baecd5ebed7a8786d2e904c11198bc5b2905 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 159/182] 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 e69de29..8c1b69a 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 7a91f27..967658a 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 7a9502b..079fc87 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 ae3d687665b6f23396ca403f816208da78d14b91 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 160/182] 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 e69de29..11c9858 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 653bdcb..9e28ebf 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 608f6b33cda27ea4b47f7a2dd3a6660516a0b74c 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 161/182] 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 e69de29..eae3d2b 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 052a56e9c220e68677dbec88fc7d928a761c0f0d 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 162/182] 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 fed0f2c..6a2d954 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -334,6 +334,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 @@ -346,7 +347,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 38efe821562ef768b575ad7cd7aeb76753737358 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 163/182] 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 03c062f..a89cf9b 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 e69de29..e43ac07 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 ac3bea183e7e5f16a763505d60750ba0eb4e1e02 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 164/182] 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 e69de29..0c9e04b 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 6d3878c..8940e09 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 245fb53..b1c33c8 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 a7a0c40..7c97602 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 183e2bab41f0797700ec9ba5f0ab12aab8769da9 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 165/182] audio: Move types to their respective headers Also include all `nn::audio` headers in audio.h --- include/nn/audio.h | 211 ++---------------- include/nn/audio/audio_Common.h | 9 + .../nn/audio/audio_PerformanceMetricsTypes.h | 14 ++ 3 files changed, 37 insertions(+), 197 deletions(-) diff --git a/include/nn/audio.h b/include/nn/audio.h index bd8c86e..ba11522 100644 --- a/include/nn/audio.h +++ b/include/nn/audio.h @@ -6,150 +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 { - u64* _0; -}; - // Audio Renderer base APIs void InitializeAudioRendererParameter(nn::audio::AudioRendererParameter* inParameter); bool IsValidAudioRendererParameter(nn::audio::AudioRendererParameter const& inParameter); @@ -211,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 fcd8a96..7cc0ed3 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 7e11429..483a91f 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 d503abc87013ec585aa5451648a1d0491f5c562c 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 166/182] 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 0c9e04b..4a16daa 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 b962496fa096b53f23335fe8747c80d9dfff39a2 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 167/182] 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 09704a1..f7dd0a5 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 0b26ce6..3c04924 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 cdfb98c..bd90d13 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 8cd0125f133f356f6eb17011a66f99bfd58f36a0 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 168/182] 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 3c04924..c633a8c 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 ebc3cc1..22084b1 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 c9a41f2a9cc49a00648e5258909debd02ef5da0d 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 169/182] 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 dd3fcf7..862a02b 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 49fdbe2..436b239 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 3a17174..9105d93 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 f0695ab..9aad63b 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 1d443b5..1f869de 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 4f052c30db20e947a90acd5d1a69e6eb612108b8 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 170/182] 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 392fb35..b541edb 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 0942590da9731f594f146fecdac9f5ac04128393 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 171/182] 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 ef27d05..4138aa0 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 8bb7e1e..1a086af 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 de85296..3aac003 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 ad2c0d0..e2068ae 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 4a16daa..c5ce83d 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 8de92005e8ff3304c38b41798376e756276a9b6a 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 172/182] 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 9e28ebf..b200a51 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 8981e1d5fc19337958ba66e63b7d4074eb6876dd 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 173/182] 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 6a2d954..e47dc00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -238,10 +238,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 @@ -254,6 +251,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 @@ -298,6 +296,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 @@ -362,6 +362,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 b541edb..6538b3a 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 e2068ae..74dbc29 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 b200a51..c79032e 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 0000000..2d221b3 --- /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 99197a1..55129aa 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 601c9c1..7bbda1b 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 911aa98..ceca709 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 b8486f4..7c7e900 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 530c397..c1220fc 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 081d913..39cfefd 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 dcea5c8..61921eb 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 e88d5d8..eb0d9f6 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 49fa6bb..a13d2a8 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 c97efed..6575125 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 c5ce83d..4855ca1 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 d01c2e4..d50fbbd 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 f158558..bd50ed3 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 515b971..0c195a4 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 8940e09..87320cc 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 e71be46..151f6ce 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 5c46ca7..814b458 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 42ae92b..379b1a4 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 436b239..e588b46 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 9aad63b..daeed1b 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 c633a8c..2bd9db6 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 48993ac73e7994afe5ec3abc01f6f61bdab8da4f 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 174/182] 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 cb170a3..558ee2c 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 d06eaae6d9e08fb4fa591dae8f166b58122d498b 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 175/182] 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 e47dc00..d5eb9c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -238,7 +238,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 @@ -260,8 +263,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 @@ -290,14 +291,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 @@ -334,19 +331,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 @@ -362,7 +363,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 6575125..1647e9b 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 862a02b..8f54174 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 2bd9db6..3231c66 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 6538b3a..222d938 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 4138aa0..113644f 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 74dbc29..881a152 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 24a3e9d..28ec5c7 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 c79032e..f86d0ad 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 51780d1..8b125d4 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 1da59b2..77b578e 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 46bb16f..b7b2c9c 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 850b69a..2d546c5 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 cc23ecd..fdb1758 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 7bbda1b..21d6312 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 ceca709..afc24cc 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 7c7e900..c214a28 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 24f01d1..9e5d70e 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 e3e65bf..86e83c7 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 902e7db..1a37d53 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 eb0d9f6..9d203fe 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 558ee2c..10ae3d7 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 f904a18..fa39b15 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 4563bc2..c2c2d97 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 d30ef9e..58b31c3 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 a13d2a8..214f83e 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 a5e57d6..25db7d3 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 e371f28..a8e757b 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 a865a0f..660968c 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 0ab0a04..e0ee985 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 ccf7e2f..08dd6f4 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 31c1bd0..1987dcf 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 d452cfb..7d0a67c 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 5af0115..68bacad 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 4855ca1..7333546 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 d91fcb3..e888c78 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 9f47f62..62f369f 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 dd89367..292bbb0 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 cb2077a..d93969f 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 5401ed3..9a06069 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 9a888e5..8653ea8 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 5e6a014..e02c9e2 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 e18d20d..230020c 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 f2f8a7b..6209d14 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 db17a27..dd5f330 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 dfebc38..a417527 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 51b88e2..c38c8bc 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 d50fbbd..5f98db5 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 ab3a2cd..96ec48d 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 c215feb..06f493d 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 f149d84..4b59d80 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 b258887..3f9ad7e 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 67da636..bc7835f 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 bd50ed3..385555c 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 e43ac07..52c010f 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 e81eaa1..ed90e6e 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 a2862b6..0333dc9 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 0c195a4..df86047 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 a5b53cd..c795ee4 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 2a0718a..a80ca9a 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 87320cc..b7ec5dd 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 c4bb420..83580ce 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 962c271..ec8e430 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 ff03e10..456846d 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 151f6ce..a2630dc 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 62dd56e..2276947 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 6a4aee8..5416b72 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 58a8406..6872f52 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 2114fcd..f6730c5 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 814b458..e80d5b5 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 379b1a4..56b0763 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 c7cde75..d0a83a3 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 2710b3f..7cc2bbc 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 079fc87..a243f79 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 3587882..67d44b8 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 fc879c4..d904ba2 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 e588b46..17ad816 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 b1c33c8..fd1ce9f 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 9105d93..9f58ecc 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 daeed1b..47cc76a 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 91ffaff..3256505 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 03657e08b822b91d6b905fa52423b34151f3d8c2 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 176/182] util: Incorporate changes from master branch --- include/nn/util/util_IntrusiveList.h | 356 ++++++++++++++++++++++++--- 1 file changed, 315 insertions(+), 41 deletions(-) diff --git a/include/nn/util/util_IntrusiveList.h b/include/nn/util/util_IntrusiveList.h index fb163cb..cf0c316 100644 --- a/include/nn/util/util_IntrusiveList.h +++ b/include/nn/util/util_IntrusiveList.h @@ -1,88 +1,362 @@ #pragma once #include +#include namespace nn::util { -struct IntrusiveListNode { + +namespace detail { + +class IntrusiveListImplementation; + +} + +class IntrusiveListNode { + NN_NO_COPY(IntrusiveListNode); + +public: + IntrusiveListNode() : m_Prev(this), m_Next(this) {} + + bool IsLinked() const { return m_Next != this; } + +private: + friend class detail::IntrusiveListImplementation; + + IntrusiveListNode* GetPrev() { return m_Prev; } + const IntrusiveListNode* GetPrev() const { return m_Prev; } + IntrusiveListNode* GetNext() { return m_Next; } + const IntrusiveListNode* GetNext() const { return m_Next; } + + void LinkPrev(IntrusiveListNode* node) { LinkPrev(node, node); } + + void LinkPrev(IntrusiveListNode* first, IntrusiveListNode* last) { + IntrusiveListNode* node = last->m_Prev; + first->m_Prev = m_Prev; + node->m_Next = this; + m_Prev->m_Next = first; + m_Prev = node; + } + + void LinkNext(IntrusiveListNode*); + void LinkNext(IntrusiveListNode*, IntrusiveListNode*); + + void Unlink() { Unlink(m_Next); } + + void Unlink(IntrusiveListNode* last) { + IntrusiveListNode* node = last->m_Prev; + m_Prev->m_Next = last; + last->m_Prev = m_Prev; + node->m_Next = this; + m_Prev = node; + } + IntrusiveListNode* m_Prev; IntrusiveListNode* m_Next; }; namespace detail { + class IntrusiveListImplementation { + NN_NO_COPY(IntrusiveListImplementation); + public: - using value_type = IntrusiveListNode; - using reference = value_type&; - using const_reference = const value_type&; + typedef IntrusiveListNode value_type; + typedef int difference_type; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef int size_type; - class iterator { + class const_iterator { public: - using value_type = value_type; - using pointer = value_type*; - using reference = value_type&; + typedef const value_type value_type; + typedef difference_type difference_type; + typedef value_type* pointer; + typedef value_type& reference; + + const_iterator(pointer p) : m_Node(p) {} + + reference operator*() const { return *m_Node; } + + pointer operator->() const; + const_iterator& operator++(); + const_iterator operator++(int); + const_iterator& operator--(); + const_iterator operator--(int); + bool operator==(const const_iterator&) const; + bool operator!=(const const_iterator& ci) const { return m_Node != ci.m_Node; } private: pointer m_Node; }; - class const_iterator { + class iterator { public: - using value_type = value_type; - using reference = value_type&; - using pointer = value_type*; - using difference_type = int; + typedef value_type value_type; + typedef value_type* pointer; + typedef value_type& reference; + + iterator(pointer p) : m_Node(p) {} + + operator const_iterator() const { return m_Node; } + + reference operator*() const { return *m_Node; } + pointer operator->() const { return m_Node; } + + iterator& operator++() { + m_Node = m_Node->GetNext(); + return *this; + } + + iterator operator++(int) { + iterator temporary(*this); + ++(*this); + return temporary; + } + + iterator& operator--(); + iterator operator--(int); + bool operator==(const iterator&) const; + + bool operator!=(const iterator& i) const { return m_Node != i.m_Node; } private: pointer m_Node; }; + IntrusiveListImplementation() : m_Root() {} + + void push_back(reference node) { m_Root.LinkPrev(&node); } + + void push_front(reference); + void pop_back(); + + void pop_front() { m_Root.GetNext()->Unlink(); } + + reference back(); + reference back() const; + reference front(); + reference front() const; + + iterator begin() { return m_Root.GetNext(); } + const_iterator begin() const { return m_Root.GetNext(); } + + iterator end() { return &m_Root; } + const_iterator end() const { return &m_Root; } + + iterator iterator_to(reference value) { return iterator(&value); } + const_iterator iterator_to(reference value) const { return iterator(&value); } + + size_type size() const; + + bool empty() const { return !m_Root.IsLinked(); } + + iterator erase(const_iterator position) { + iterator temporary(ToMutable(position)); + if (temporary != end()) { + (temporary++)->Unlink(); + } + return temporary; + } + + void clear() { + while (!empty()) { + pop_front(); + } + } + + iterator insert(const_iterator position, reference node) { + ToMutable(position)->LinkPrev(&node); + return iterator(&node); + } + + void splice(const_iterator, IntrusiveListImplementation&); + void splice(const_iterator, IntrusiveListImplementation&, const_iterator); + void splice(const_iterator, IntrusiveListImplementation&, const_iterator, const_iterator); + private: - IntrusiveListNode m_Root; -}; -} // namespace nn::util::detail + void SpliceImplementation(const_iterator, const_iterator, const_iterator); -template -class IntrusiveListBaseNode : IntrusiveListNode {}; + iterator ToMutable(const_iterator i) const { return const_cast(&*i); } -template -class IntrusiveListBaseNodeTraits { -public: - using BaseNodeType = IntrusiveListBaseNode; + value_type m_Root; }; -template -class IntrusiveListMemberNodeTraits {}; +} // namespace detail -template +template class IntrusiveList { + NN_NO_COPY(IntrusiveList); + public: - using value_type = T; - using reference = T&; - using const_reference = const T&; + class iterator; + class const_iterator; - class iterator { + typedef T value_type; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + typedef int size_type; + + class const_iterator { public: - using value_type = value_type; - using reference = value_type&; - using pointer = value_type*; + typedef T value_type; + typedef value_type* pointer; + typedef value_type& reference; + + reference operator*() const; + pointer operator->() const; + const_iterator& operator++(); + const_iterator operator++(int); + const_iterator& operator--(); + const_iterator operator--(int); + bool operator==(const const_iterator&) const; + bool operator!=(const const_iterator&) const; private: - detail::IntrusiveListImplementation::iterator m_Iterator; + friend class IntrusiveList; + + const_iterator(detail::IntrusiveListImplementation::const_iterator ci) : m_Iterator(ci) {} + + detail::IntrusiveListImplementation::const_iterator GetImplementationIterator() const { + return m_Iterator; + } + + detail::IntrusiveListImplementation::const_iterator m_Iterator; }; - using reverse_iterator = std::reverse_iterator; - class const_iterator { + class iterator { public: - using value_type = value_type; - using reference = value_type&; - using pointer = value_type*; + typedef T value_type; + typedef value_type* pointer; + typedef value_type& reference; + + operator const_iterator() const { + return static_cast(m_Iterator); + } + + reference operator*() const { return NodeTraits::GetItem(*m_Iterator); } + + pointer operator->() const { return &NodeTraits::GetItem(*m_Iterator); } + + iterator& operator++() { + ++m_Iterator; + return *this; + } + + iterator operator++(int) { + iterator temporary(*this); + ++m_Iterator; + return temporary; + } + + iterator& operator--(); + iterator operator--(int); + bool operator==(const iterator&) const; + + bool operator!=(const iterator& i) const { return m_Iterator != i.m_Iterator; } private: - detail::IntrusiveListImplementation::const_iterator m_Iterator; + friend class IntrusiveList; + + iterator(detail::IntrusiveListImplementation::iterator iter) : m_Iterator(iter) {} + + detail::IntrusiveListImplementation::iterator GetImplementationIterator() const; + + detail::IntrusiveListImplementation::iterator m_Iterator; }; - using const_reverse_iterator = std::reverse_iterator; + + IntrusiveList() : m_Implementation() {} + + void push_back(reference value) { m_Implementation.push_back(ToNode(value)); } + + void push_front(reference); + void pop_back(); + void pop_front(); + reference front(); + reference front() const; + reference back(); + reference back() const; + + iterator begin() { return m_Implementation.begin(); } + const_iterator begin() const { return m_Implementation.begin(); } + + const_iterator cbegin() const; + + iterator end() { return m_Implementation.end(); } + const_iterator end() const { return m_Implementation.end(); } + + const_iterator cend() const; + reverse_iterator rbegin(); + const_reverse_iterator rbegin() const; + const_reverse_iterator crbegin() const; + reverse_iterator rend(); + const_reverse_iterator rend() const; + const_reverse_iterator crend() const; + + iterator iterator_to(reference value) { return m_Implementation.iterator_to(ToNode(value)); } + const_iterator iterator_to(const_reference value) const { + return m_Implementation.iterator_to(ToNode(value)); + } + + size_type size() const; + bool empty() const; + + iterator erase(const_iterator position) { + detail::IntrusiveListImplementation::iterator result = + m_Implementation.erase(position.GetImplementationIterator()); + return result; + } + + void clear() { m_Implementation.clear(); } + + iterator insert(const_iterator position, reference value) { + detail::IntrusiveListImplementation::iterator result = + m_Implementation.insert(position.GetImplementationIterator(), ToNode(value)); + return result; + } + + void splice(const_iterator, IntrusiveList&); + void splice(const_iterator, IntrusiveList&, const_iterator); + void splice(const_iterator, IntrusiveList&, const_iterator, const_iterator); private: + IntrusiveListNode& ToNode(reference ref) const { return NodeTraits::GetNode(ref); } + + const IntrusiveListNode& ToNode(const_reference) const; + reference ToReference(IntrusiveListNode&) const; + const_reference ToReference(const IntrusiveListNode&) const; + detail::IntrusiveListImplementation m_Implementation; }; -} // namespace nn::util \ No newline at end of file + +template +class IntrusiveListBaseNode : IntrusiveListNode {}; + +template +class IntrusiveListBaseNodeTraits { +public: + using BaseNodeType = IntrusiveListBaseNode; +}; + +template +class IntrusiveListMemberNodeTraits { + friend class IntrusiveList; + + static IntrusiveListNode& GetNode(T& ref) { return ref.*Member; } + + static const IntrusiveListNode& GetNode(const T& ref) { return ref.*Member; } + + static T& GetItem(IntrusiveListNode& node) { + return *reinterpret_cast(reinterpret_cast(&node) - GetOffset()); + } + + static const T& GetItem(const IntrusiveListNode& node) { + return *reinterpret_cast(reinterpret_cast(&node) - GetOffset()); + } + + static uintptr_t GetOffset() { + return reinterpret_cast(&(reinterpret_cast(0)->*Member)); + } +}; +} // namespace nn::util From 3470b20894859d21d293ee1c26777141cca05519 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 177/182] 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 77b578e..ef58a05 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 21d6312..7b3d9f3 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 292bbb0..54746d2 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 a2630dc..776a5c3 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 56532699bdd4fc2c5712d29908a9cd9459986dcc 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 178/182] 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 a954c4b..0000000 --- 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 5758229f5cfea6065f86476cb60b4a3dce588ffe 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 179/182] 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 f7dd0a5..720973b 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 8b125d4..cf2453b 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 305b6e5843933e05790f3364f12a10db68314d54 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 180/182] 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 e888c78..98dd8ef 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 a93ee772254215e9a5006b4fdeeb904efdb68c13 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 181/182] 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 8f54174..2ef5a18 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 113644f..8f08a12 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 881a152..113065b 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 ef58a05..52b02af 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 b7b2c9c..e5c7d87 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 fdb1758..368baf5 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 55129aa..dbc9ed4 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 7b3d9f3..96c18e5 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 afc24cc..1c17d11 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 86e83c7..232f0e4 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 1a37d53..1011834 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 9d203fe..d6ecf2e 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 10ae3d7..cb71738 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 fa39b15..6fb95c6 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 214f83e..8797c6d 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 25db7d3..c84db91 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 660968c..8e0f684 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 54746d2..405cf9c 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 8653ea8..51b7290 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 e02c9e2..a947bef 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 dd5f330..d152ea6 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 5f98db5..985bf63 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 96ec48d..03740e9 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 3f9ad7e..eb5b81a 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 bc7835f..1f7c8ee 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 385555c..4a0cb3f 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 52c010f..d962b5f 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 c795ee4..69424c8 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 a80ca9a..ba66d78 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 b7ec5dd..852d65f 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 83580ce..7c24b5e 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 ec8e430..1d02a0f 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 456846d..431426e 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 776a5c3..7390f90 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 6872f52..a62096a 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 f6730c5..39999b6 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 1f869de..21a43e6 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 cc807ffc9fab9696bf70b8e0f02d1dc298255b8f 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 182/182] 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 8f08a12..cfed52a 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 8c1cde1..eb2a56d 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 28ec5c7..e9fa361 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 96c18e5..d234db4 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 c214a28..7e786bd 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 ebcc475..f615ad3 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 7487f85..98cff4d 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 705da2d..0d4cbbd 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 232f0e4..4f64e69 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 39cfefd..bd4d02b 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 61921eb..b7f854b 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 6fb95c6..4a326f8 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 8797c6d..aadf7d0 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 a8e757b..44641ef 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 bb0a09e..468ebda 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 6209d14..e22a8cb 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 d152ea6..ac15a7f 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 a417527..f43d87a 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 985bf63..8338e96 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 03740e9..cd62d49 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 eb5b81a..9ec98c0 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 1f7c8ee..848f686 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 4a0cb3f..170a626 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 2f86cd0..29202a5 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 5478fb8..2126c0e 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 bc48d62..b730624 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 ba66d78..20268b1 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 852d65f..5b2cebc 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 39999b6..67f2660 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 e80d5b5..eb99b03 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 56b0763..ae6444c 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 6c0d2eb..7987628 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 179b375..552c2f9 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 67d44b8..9a4c61f 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 be2b3ef..5f6a763 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 d904ba2..3c66da7 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 21a43e6..853e6f4 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 411cd65..0e7e680 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 964c3a3..099a425 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 272f3fb..05053d6 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;