diff options
Diffstat (limited to 'src/audio_core/delay_line.cpp')
| -rw-r--r-- | src/audio_core/delay_line.cpp | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/src/audio_core/delay_line.cpp b/src/audio_core/delay_line.cpp deleted file mode 100644 index b1626a71b..000000000 --- a/src/audio_core/delay_line.cpp +++ /dev/null | |||
| @@ -1,107 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include <cstring> | ||
| 5 | #include "audio_core/delay_line.h" | ||
| 6 | |||
| 7 | namespace AudioCore { | ||
| 8 | DelayLineBase::DelayLineBase() = default; | ||
| 9 | DelayLineBase::~DelayLineBase() = default; | ||
| 10 | |||
| 11 | void DelayLineBase::Initialize(s32 max_delay_, float* src_buffer) { | ||
| 12 | buffer = src_buffer; | ||
| 13 | buffer_end = buffer + max_delay_; | ||
| 14 | max_delay = max_delay_; | ||
| 15 | output = buffer; | ||
| 16 | SetDelay(max_delay_); | ||
| 17 | Clear(); | ||
| 18 | } | ||
| 19 | |||
| 20 | void DelayLineBase::SetDelay(s32 new_delay) { | ||
| 21 | if (max_delay < new_delay) { | ||
| 22 | return; | ||
| 23 | } | ||
| 24 | delay = new_delay; | ||
| 25 | input = (buffer + ((output - buffer) + new_delay) % (max_delay + 1)); | ||
| 26 | } | ||
| 27 | |||
| 28 | s32 DelayLineBase::GetDelay() const { | ||
| 29 | return delay; | ||
| 30 | } | ||
| 31 | |||
| 32 | s32 DelayLineBase::GetMaxDelay() const { | ||
| 33 | return max_delay; | ||
| 34 | } | ||
| 35 | |||
| 36 | f32 DelayLineBase::TapOut(s32 last_sample) { | ||
| 37 | const float* ptr = input - (last_sample + 1); | ||
| 38 | if (ptr < buffer) { | ||
| 39 | ptr += (max_delay + 1); | ||
| 40 | } | ||
| 41 | |||
| 42 | return *ptr; | ||
| 43 | } | ||
| 44 | |||
| 45 | f32 DelayLineBase::Tick(f32 sample) { | ||
| 46 | *(input++) = sample; | ||
| 47 | const auto out_sample = *(output++); | ||
| 48 | |||
| 49 | if (buffer_end < input) { | ||
| 50 | input = buffer; | ||
| 51 | } | ||
| 52 | |||
| 53 | if (buffer_end < output) { | ||
| 54 | output = buffer; | ||
| 55 | } | ||
| 56 | |||
| 57 | return out_sample; | ||
| 58 | } | ||
| 59 | |||
| 60 | float* DelayLineBase::GetInput() { | ||
| 61 | return input; | ||
| 62 | } | ||
| 63 | |||
| 64 | const float* DelayLineBase::GetInput() const { | ||
| 65 | return input; | ||
| 66 | } | ||
| 67 | |||
| 68 | f32 DelayLineBase::GetOutputSample() const { | ||
| 69 | return *output; | ||
| 70 | } | ||
| 71 | |||
| 72 | void DelayLineBase::Clear() { | ||
| 73 | std::memset(buffer, 0, sizeof(float) * max_delay); | ||
| 74 | } | ||
| 75 | |||
| 76 | void DelayLineBase::Reset() { | ||
| 77 | buffer = nullptr; | ||
| 78 | buffer_end = nullptr; | ||
| 79 | max_delay = 0; | ||
| 80 | input = nullptr; | ||
| 81 | output = nullptr; | ||
| 82 | delay = 0; | ||
| 83 | } | ||
| 84 | |||
| 85 | DelayLineAllPass::DelayLineAllPass() = default; | ||
| 86 | DelayLineAllPass::~DelayLineAllPass() = default; | ||
| 87 | |||
| 88 | void DelayLineAllPass::Initialize(u32 delay_, float coeffcient_, f32* src_buffer) { | ||
| 89 | DelayLineBase::Initialize(delay_, src_buffer); | ||
| 90 | SetCoefficient(coeffcient_); | ||
| 91 | } | ||
| 92 | |||
| 93 | void DelayLineAllPass::SetCoefficient(float coeffcient_) { | ||
| 94 | coefficient = coeffcient_; | ||
| 95 | } | ||
| 96 | |||
| 97 | f32 DelayLineAllPass::Tick(f32 sample) { | ||
| 98 | const auto temp = sample - coefficient * *output; | ||
| 99 | return coefficient * temp + DelayLineBase::Tick(temp); | ||
| 100 | } | ||
| 101 | |||
| 102 | void DelayLineAllPass::Reset() { | ||
| 103 | coefficient = 0.0f; | ||
| 104 | DelayLineBase::Reset(); | ||
| 105 | } | ||
| 106 | |||
| 107 | } // namespace AudioCore | ||