summaryrefslogtreecommitdiffstats
path: root/src/audio_core/delay_line.h
blob: b6a6e0b1241a83ad6619f48bda8c8b3a8d7a5203 (plain) (blame)
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
40
41
42
43
44
45
46
#pragma once

#include "common/common_types.h"

namespace AudioCore {

class DelayLineBase {
public:
    DelayLineBase();
    ~DelayLineBase();

    void Initialize(s32 _max_delay, float* src_buffer);
    void SetDelay(s32 new_delay);
    s32 GetDelay() const;
    s32 GetMaxDelay() const;
    f32 TapOut(s32 last_sample);
    f32 Tick(f32 sample);
    float* GetInput();
    const float* GetInput() const;
    f32 GetOutputSample() const;
    void Clear();
    void Reset();

protected:
    float* buffer{nullptr};
    float* buffer_end{nullptr};
    s32 max_delay{};
    float* input{nullptr};
    float* output{nullptr};
    s32 delay{};
};

class DelayLineAllPass final : public DelayLineBase {
public:
    DelayLineAllPass();
    ~DelayLineAllPass();

    void Initialize(u32 delay, float _coeffcient, f32* src_buffer);
    void SetCoefficient(float _coeffcient);
    f32 Tick(f32 sample);
    void Reset();

private:
    float coefficient{};
};
} // namespace AudioCore