mirror of
https://git.eden-emu.dev/archive/citron
synced 2026-03-28 20:39:33 -04:00
fix(audio): biquad filter effect parameter version 2 handling
Fix ParameterVersion2 structure layout to match actual format: - Add padding and use f32 for coefficients (was incorrectly using s16) - Update state field offset from 0x17 to 0x25 Update command generation to: - Read from correct structure based on version - Convert float coefficients to fixed-point Q2.14 when using version 2 Signed-off-by: Zephyron <zephyron@citron-emu.org>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "audio_core/renderer/effect/biquad_filter.h"
|
||||
@@ -40,8 +41,28 @@ void BiquadFilterInfo::UpdateForCommandGeneration() {
|
||||
usage_state = UsageState::Disabled;
|
||||
}
|
||||
|
||||
auto params{reinterpret_cast<ParameterVersion1*>(parameter.data())};
|
||||
params->state = ParameterState::Updated;
|
||||
// Determine which version structure is being used
|
||||
// Version 1: state at offset 0x17, structure size ~24 bytes
|
||||
// Version 2: state at offset 0x25, structure size ~40 bytes
|
||||
auto params_v1{reinterpret_cast<ParameterVersion1*>(parameter.data())};
|
||||
auto params_v2{reinterpret_cast<ParameterVersion2*>(parameter.data())};
|
||||
|
||||
// Check which state location contains a valid ParameterState value (0-2)
|
||||
// Valid states: Initialized (0), Updating (1), Updated (2)
|
||||
const auto state_v1_raw = *reinterpret_cast<const u8*>(¶ms_v1->state);
|
||||
const auto state_v2_raw = *reinterpret_cast<const u8*>(¶ms_v2->state);
|
||||
|
||||
if (state_v1_raw <= 2) {
|
||||
// Version 1 location has valid state, update there
|
||||
params_v1->state = ParameterState::Updated;
|
||||
} else if (state_v2_raw <= 2) {
|
||||
// Version 2 location has valid state, update there
|
||||
params_v2->state = ParameterState::Updated;
|
||||
} else {
|
||||
// Neither looks valid, update both (one will be wrong but command generator handles it)
|
||||
params_v1->state = ParameterState::Updated;
|
||||
params_v2->state = ParameterState::Updated;
|
||||
}
|
||||
}
|
||||
|
||||
void BiquadFilterInfo::InitializeResultState(EffectResultState& result_state) {}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
@@ -27,10 +28,12 @@ public:
|
||||
struct ParameterVersion2 {
|
||||
/* 0x00 */ std::array<s8, MaxChannels> inputs;
|
||||
/* 0x06 */ std::array<s8, MaxChannels> outputs;
|
||||
/* 0x0C */ std::array<s16, 3> b;
|
||||
/* 0x12 */ std::array<s16, 2> a;
|
||||
/* 0x16 */ s8 channel_count;
|
||||
/* 0x17 */ ParameterState state;
|
||||
/* 0x0C */ u32 padding;
|
||||
/* 0x10 */ std::array<f32, 3> b;
|
||||
/* 0x1C */ std::array<f32, 2> a;
|
||||
/* 0x24 */ s8 channel_count;
|
||||
/* 0x25 */ ParameterState state;
|
||||
/* 0x26 */ u16 reserved;
|
||||
};
|
||||
static_assert(sizeof(ParameterVersion2) <= sizeof(EffectInfoBase::InParameterVersion2),
|
||||
"BiquadFilterInfo::ParameterVersion2 has the wrong size!");
|
||||
|
||||
Reference in New Issue
Block a user