diff options
| author | 2021-01-10 22:09:56 -0700 | |
|---|---|---|
| committer | 2021-01-10 22:09:56 -0700 | |
| commit | 7a3c884e39fccfbb498b855080bffabc9ce2e7f1 (patch) | |
| tree | 5056f9406dec188439cb0deb87603498243a9412 /src/audio_core/algorithm | |
| parent | More forgetting... duh (diff) | |
| parent | Merge pull request #5229 from Morph1984/fullscreen-opt (diff) | |
| download | yuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.tar.gz yuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.tar.xz yuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.zip | |
Merge remote-tracking branch 'upstream/master' into int-flags
Diffstat (limited to 'src/audio_core/algorithm')
| -rw-r--r-- | src/audio_core/algorithm/filter.cpp | 9 | ||||
| -rw-r--r-- | src/audio_core/algorithm/filter.h | 4 | ||||
| -rw-r--r-- | src/audio_core/algorithm/interpolate.cpp | 7 |
3 files changed, 11 insertions, 9 deletions
diff --git a/src/audio_core/algorithm/filter.cpp b/src/audio_core/algorithm/filter.cpp index f65bf64f7..01b8dff6b 100644 --- a/src/audio_core/algorithm/filter.cpp +++ b/src/audio_core/algorithm/filter.cpp | |||
| @@ -31,8 +31,8 @@ Filter Filter::LowPass(double cutoff, double Q) { | |||
| 31 | 31 | ||
| 32 | Filter::Filter() : Filter(1.0, 0.0, 0.0, 1.0, 0.0, 0.0) {} | 32 | Filter::Filter() : Filter(1.0, 0.0, 0.0, 1.0, 0.0, 0.0) {} |
| 33 | 33 | ||
| 34 | Filter::Filter(double a0, double a1, double a2, double b0, double b1, double b2) | 34 | Filter::Filter(double a0_, double a1_, double a2_, double b0_, double b1_, double b2_) |
| 35 | : a1(a1 / a0), a2(a2 / a0), b0(b0 / a0), b1(b1 / a0), b2(b2 / a0) {} | 35 | : a1(a1_ / a0_), a2(a2_ / a0_), b0(b0_ / a0_), b1(b1_ / a0_), b2(b2_ / a0_) {} |
| 36 | 36 | ||
| 37 | void Filter::Process(std::vector<s16>& signal) { | 37 | void Filter::Process(std::vector<s16>& signal) { |
| 38 | const std::size_t num_frames = signal.size() / 2; | 38 | const std::size_t num_frames = signal.size() / 2; |
| @@ -55,7 +55,8 @@ void Filter::Process(std::vector<s16>& signal) { | |||
| 55 | /// @param total_count The total number of biquads to be cascaded. | 55 | /// @param total_count The total number of biquads to be cascaded. |
| 56 | /// @param index 0-index of the biquad to calculate the Q value for. | 56 | /// @param index 0-index of the biquad to calculate the Q value for. |
| 57 | static double CascadingBiquadQ(std::size_t total_count, std::size_t index) { | 57 | static double CascadingBiquadQ(std::size_t total_count, std::size_t index) { |
| 58 | const double pole = M_PI * (2 * index + 1) / (4.0 * total_count); | 58 | const auto pole = |
| 59 | M_PI * static_cast<double>(2 * index + 1) / (4.0 * static_cast<double>(total_count)); | ||
| 59 | return 1.0 / (2.0 * std::cos(pole)); | 60 | return 1.0 / (2.0 * std::cos(pole)); |
| 60 | } | 61 | } |
| 61 | 62 | ||
| @@ -68,7 +69,7 @@ CascadingFilter CascadingFilter::LowPass(double cutoff, std::size_t cascade_size | |||
| 68 | } | 69 | } |
| 69 | 70 | ||
| 70 | CascadingFilter::CascadingFilter() = default; | 71 | CascadingFilter::CascadingFilter() = default; |
| 71 | CascadingFilter::CascadingFilter(std::vector<Filter> filters) : filters(std::move(filters)) {} | 72 | CascadingFilter::CascadingFilter(std::vector<Filter> filters_) : filters(std::move(filters_)) {} |
| 72 | 73 | ||
| 73 | void CascadingFilter::Process(std::vector<s16>& signal) { | 74 | void CascadingFilter::Process(std::vector<s16>& signal) { |
| 74 | for (auto& filter : filters) { | 75 | for (auto& filter : filters) { |
diff --git a/src/audio_core/algorithm/filter.h b/src/audio_core/algorithm/filter.h index 3546d149b..a291fe79b 100644 --- a/src/audio_core/algorithm/filter.h +++ b/src/audio_core/algorithm/filter.h | |||
| @@ -25,7 +25,7 @@ public: | |||
| 25 | /// Passthrough filter. | 25 | /// Passthrough filter. |
| 26 | Filter(); | 26 | Filter(); |
| 27 | 27 | ||
| 28 | Filter(double a0, double a1, double a2, double b0, double b1, double b2); | 28 | Filter(double a0_, double a1_, double a2_, double b0_, double b1_, double b2_); |
| 29 | 29 | ||
| 30 | void Process(std::vector<s16>& signal); | 30 | void Process(std::vector<s16>& signal); |
| 31 | 31 | ||
| @@ -51,7 +51,7 @@ public: | |||
| 51 | /// Passthrough. | 51 | /// Passthrough. |
| 52 | CascadingFilter(); | 52 | CascadingFilter(); |
| 53 | 53 | ||
| 54 | explicit CascadingFilter(std::vector<Filter> filters); | 54 | explicit CascadingFilter(std::vector<Filter> filters_); |
| 55 | 55 | ||
| 56 | void Process(std::vector<s16>& signal); | 56 | void Process(std::vector<s16>& signal); |
| 57 | 57 | ||
diff --git a/src/audio_core/algorithm/interpolate.cpp b/src/audio_core/algorithm/interpolate.cpp index 689a54508..3b4144e21 100644 --- a/src/audio_core/algorithm/interpolate.cpp +++ b/src/audio_core/algorithm/interpolate.cpp | |||
| @@ -146,7 +146,7 @@ std::vector<s16> Interpolate(InterpolationState& state, std::vector<s16> input, | |||
| 146 | return {}; | 146 | return {}; |
| 147 | 147 | ||
| 148 | if (ratio <= 0) { | 148 | if (ratio <= 0) { |
| 149 | LOG_CRITICAL(Audio, "Nonsensical interpolation ratio {}", ratio); | 149 | LOG_ERROR(Audio, "Nonsensical interpolation ratio {}", ratio); |
| 150 | return input; | 150 | return input; |
| 151 | } | 151 | } |
| 152 | 152 | ||
| @@ -164,7 +164,8 @@ std::vector<s16> Interpolate(InterpolationState& state, std::vector<s16> input, | |||
| 164 | const std::size_t num_frames{input.size() / 2}; | 164 | const std::size_t num_frames{input.size() / 2}; |
| 165 | 165 | ||
| 166 | std::vector<s16> output; | 166 | std::vector<s16> output; |
| 167 | output.reserve(static_cast<std::size_t>(input.size() / ratio + InterpolationState::taps)); | 167 | output.reserve(static_cast<std::size_t>(static_cast<double>(input.size()) / ratio + |
| 168 | InterpolationState::taps)); | ||
| 168 | 169 | ||
| 169 | for (std::size_t frame{}; frame < num_frames; ++frame) { | 170 | for (std::size_t frame{}; frame < num_frames; ++frame) { |
| 170 | const std::size_t lut_index{(state.fraction >> 8) * InterpolationState::taps}; | 171 | const std::size_t lut_index{(state.fraction >> 8) * InterpolationState::taps}; |
| @@ -217,7 +218,7 @@ void Resample(s32* output, const s32* input, s32 pitch, s32& fraction, std::size | |||
| 217 | const auto l2 = lut[lut_index + 2]; | 218 | const auto l2 = lut[lut_index + 2]; |
| 218 | const auto l3 = lut[lut_index + 3]; | 219 | const auto l3 = lut[lut_index + 3]; |
| 219 | 220 | ||
| 220 | const auto s0 = static_cast<s32>(input[index]); | 221 | const auto s0 = static_cast<s32>(input[index + 0]); |
| 221 | const auto s1 = static_cast<s32>(input[index + 1]); | 222 | const auto s1 = static_cast<s32>(input[index + 1]); |
| 222 | const auto s2 = static_cast<s32>(input[index + 2]); | 223 | const auto s2 = static_cast<s32>(input[index + 2]); |
| 223 | const auto s3 = static_cast<s32>(input[index + 3]); | 224 | const auto s3 = static_cast<s32>(input[index + 3]); |