diff options
author | David Marcec <dmarcecguzman@gmail.com> | 2020-07-12 13:59:14 +0200 |
---|---|---|
committer | David Marcec <dmarcecguzman@gmail.com> | 2020-07-25 04:39:34 +0200 |
commit | 380658c21d39cf05ac765a9284da246388cca2a4 (patch) | |
tree | 1416cd7e9aee96ec40675078d16a8240d410d04b /src/audio_core/command_generator.h | |
parent | Merge pull request #4377 from Morph1984/dark-themes (diff) | |
download | yuzu-380658c21d39cf05ac765a9284da246388cca2a4.tar yuzu-380658c21d39cf05ac765a9284da246388cca2a4.tar.gz yuzu-380658c21d39cf05ac765a9284da246388cca2a4.tar.bz2 yuzu-380658c21d39cf05ac765a9284da246388cca2a4.tar.lz yuzu-380658c21d39cf05ac765a9284da246388cca2a4.tar.xz yuzu-380658c21d39cf05ac765a9284da246388cca2a4.tar.zst yuzu-380658c21d39cf05ac765a9284da246388cca2a4.zip |
Diffstat (limited to 'src/audio_core/command_generator.h')
-rw-r--r-- | src/audio_core/command_generator.h | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/src/audio_core/command_generator.h b/src/audio_core/command_generator.h new file mode 100644 index 000000000..e0d7510fc --- /dev/null +++ b/src/audio_core/command_generator.h @@ -0,0 +1,83 @@ +// Copyright 2020 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <array> +#include "audio_core/common.h" +#include "audio_core/voice_context.h" +#include "common/common_funcs.h" +#include "common/common_types.h" + +namespace Core::Memory { +class Memory; +} + +namespace AudioCore { +class MixContext; +class SplitterContext; +class ServerSplitterDestinationData; +class ServerMixInfo; +using MixVolumeBuffer = std::array<float, AudioCommon::MAX_MIX_BUFFERS>; +class CommandGenerator { +public: + explicit CommandGenerator(AudioCommon::AudioRendererParameter& worker_params, + VoiceContext& voice_context, MixContext& mix_context, + SplitterContext& splitter_context, Core::Memory::Memory& memory); + ~CommandGenerator(); + + void ClearMixBuffers(); + void GenerateVoiceCommands(); + void GenerateVoiceCommand(ServerVoiceInfo& voice_info); + void GenerateSubMixCommands(); + void GenerateFinalMixCommands(); + void PreCommand(); + void PostCommand(); + + s32* GetChannelMixBuffer(s32 channel); + const s32* GetChannelMixBuffer(s32 channel) const; + s32* GetMixBuffer(std::size_t index); + const s32* GetMixBuffer(std::size_t index) const; + std::size_t GetMixChannelBufferOffset(s32 channel) const; + +private: + void GenerateDataSourceCommand(ServerVoiceInfo& voice_info, VoiceState& dsp_state, s32 channel); + void GenerateBiquadFilterCommandForVoice(ServerVoiceInfo& voice_info, VoiceState& dsp_state, + s32 mix_buffer_count, s32 channel); + void GenerateVolumeRampCommand(float last_volume, float current_volume, s32 channel, + s32 node_id); + void GenerateVoiceMixCommand(const MixVolumeBuffer& mix_volumes, + const MixVolumeBuffer& last_mix_volumes, VoiceState& dsp_state, + s32 mix_buffer_offset, s32 mix_buffer_count, s32 voice_index, + s32 node_id); + void GenerateSubMixCommand(ServerMixInfo& mix_info); + void GenerateMixCommands(ServerMixInfo& mix_info); + void GenerateMixCommand(std::size_t output_offset, std::size_t input_offset, float volume, + s32 node_id); + void GenerateFinalMixCommand(); + void GenerateBiquadFilterCommand(s32 mix_buffer, const BiquadFilterParameter& params, + std::array<s64, 2>& state, std::size_t input_offset, + std::size_t output_offset, s32 sample_count, s32 node_id); + void GenerateDepopPrepareCommand(VoiceState& dsp_state); + ServerSplitterDestinationData* GetDestinationData(s32 splitter_id, s32 index); + + // DSP Code + s32 DecodePcm16(ServerVoiceInfo& voice_info, VoiceState& dsp_state, s32 sample_count, + s32 channel, std::size_t mix_offset); + s32 DecodeAdpcm(ServerVoiceInfo& voice_info, VoiceState& dsp_state, s32 sample_count, + s32 channel, std::size_t mix_offset); + void DecodeFromWaveBuffers(ServerVoiceInfo& voice_info, s32* output, VoiceState& dsp_state, + s32 channel, s32 target_sample_rate, s32 sample_count, s32 node_id); + void Resample(s32* output, s32* input, s32 pitch, s32& fraction, s32 sample_count); + + AudioCommon::AudioRendererParameter& worker_params; + VoiceContext& voice_context; + MixContext& mix_context; + SplitterContext& splitter_context; + Core::Memory::Memory& memory; + std::vector<s32> mix_buffer{}; + std::vector<s32> sample_buffer{}; + bool dumping_frame{false}; +}; +} // namespace AudioCore |