From 458da8a94877677f086f06cdeecf959ec4283a33 Mon Sep 17 00:00:00 2001 From: Kelebek1 Date: Sat, 16 Jul 2022 23:48:45 +0100 Subject: Project Andio --- src/audio_core/renderer/voice/voice_state.h | 70 +++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/audio_core/renderer/voice/voice_state.h (limited to 'src/audio_core/renderer/voice/voice_state.h') diff --git a/src/audio_core/renderer/voice/voice_state.h b/src/audio_core/renderer/voice/voice_state.h new file mode 100644 index 000000000..d5497e2fb --- /dev/null +++ b/src/audio_core/renderer/voice/voice_state.h @@ -0,0 +1,70 @@ +// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include + +#include "audio_core/common/common.h" +#include "common/common_types.h" +#include "common/fixed_point.h" + +namespace AudioCore::AudioRenderer { +/** + * Holds a state for a voice. One is kept host-side, and one is used by the AudioRenderer, + * host-side is updated on the next iteration. + */ +struct VoiceState { + /** + * State of the voice's biquad filter. + */ + struct BiquadFilterState { + Common::FixedPoint<50, 14> s0; + Common::FixedPoint<50, 14> s1; + Common::FixedPoint<50, 14> s2; + Common::FixedPoint<50, 14> s3; + }; + + /** + * Context for ADPCM decoding. + */ + struct AdpcmContext { + u16 header; + s16 yn0; + s16 yn1; + }; + + /// Number of samples played + u64 played_sample_count; + /// Current offset from the starting offset + u32 offset; + /// Currently active wavebuffer index + u32 wave_buffer_index; + /// Array of which wavebuffers are currently valid + + std::array wave_buffer_valid; + /// Number of wavebuffers consumed, given back to the game + u32 wave_buffers_consumed; + /// History of samples, used for rate conversion + + std::array sample_history; + /// Current read fraction, used for resampling + Common::FixedPoint<49, 15> fraction; + /// Current adpcm context + AdpcmContext adpcm_context; + /// Current biquad states, used when filtering + + std::array, MaxBiquadFilters> biquad_states; + /// Previous samples + std::array previous_samples; + /// Unused + u32 external_context_size; + /// Unused + bool external_context_enabled; + /// Was this voice dropped? + bool voice_dropped; + /// Number of times the wavebuffer has looped + s32 loop_count; +}; + +} // namespace AudioCore::AudioRenderer -- cgit v1.2.3