summaryrefslogtreecommitdiff
path: root/src/audio_core/renderer/compressor.h
blob: 97f43dfae4a89a86fb10fce33734e92b8c390d1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <array>
#include "common/common_types.h"

namespace AudioCore::Renderer {

struct CompressorStatistics {
    float maximum_mean{};
    float minimum_gain{1.0f};
    std::array<float, 6> last_samples{}; // 6 channels max

    void Reset(u16 channel_count) {
        maximum_mean = 0.0f;
        minimum_gain = 1.0f;
        std::fill_n(last_samples.begin(), channel_count, 0.0f);
    }
};

struct CompressorParameter {
    u32 channel_count{};
    float input_gain{};
    float release_coefficient{};
    float attack_coefficient{};
    float ratio{};
    float threshold{};
    bool makeup_gain_enabled{};
    bool statistics_enabled{};
    bool statistics_reset{};

    bool IsChannelCountValid() const {
        return channel_count > 0 && channel_count <= 6;
    }
};

} // namespace AudioCore::Renderer