Add Reverbation DSP effect and fix FFTFilter include paths

This commit is contained in:
2026-03-21 12:16:19 +08:00
parent 2cc9d58edd
commit 00c2699542
4 changed files with 202 additions and 3 deletions

View File

@@ -0,0 +1,74 @@
#pragma once
#include "IAudioEffect.h"
#include <vector>
namespace XCEngine {
namespace Audio {
class Reverbation : public IAudioEffect {
public:
Reverbation();
~Reverbation() override;
void ProcessAudio(float* buffer, uint32 sampleCount, uint32 channels) override;
void SetRoomSize(float size);
float GetRoomSize() const { return m_roomSize; }
void SetDamping(float damping);
float GetDamping() const { return m_damping; }
void SetWetMix(float wetMix) override;
float GetWetMix() const override { return m_wetMix; }
void SetDryMix(float dryMix);
float GetDryMix() const { return m_dryMix; }
void SetWidth(float width);
float GetWidth() const { return m_width; }
void SetFreeze(bool freeze);
bool IsFreeze() const { return m_freeze; }
private:
void ProcessCombFilter(float* buffer, uint32 sampleCount, uint32 channel, uint32 combIndex);
void ProcessAllPassFilter(float* buffer, uint32 sampleCount, uint32 channel);
private:
float m_roomSize = 0.5f;
float m_damping = 0.5f;
float m_wetMix = 0.3f;
float m_dryMix = 0.7f;
float m_width = 1.0f;
bool m_freeze = false;
static constexpr uint32 CombCount = 8;
static constexpr uint32 AllPassCount = 4;
static constexpr uint32 MaxDelayLength = 2000;
struct CombFilter {
std::vector<float> buffer;
uint32 bufferSize = 0;
uint32 writeIndex = 0;
float feedback = 0.0f;
float damp1 = 0.0f;
float damp2 = 0.0f;
float filterStore = 0.0f;
};
struct AllPassFilter {
std::vector<float> buffer;
uint32 bufferSize = 0;
uint32 writeIndex = 0;
float feedback = 0.0f;
};
CombFilter m_combFilters[CombCount];
AllPassFilter m_allPassFilters[AllPassCount];
uint32 m_sampleRate = 48000;
};
} // namespace Audio
} // namespace XCEngine