summaryrefslogtreecommitdiffstats
path: root/src/audio_core/interpolate.cpp
diff options
context:
space:
mode:
authorJames Rowe <jroweboy@gmail.com>2018-01-12 03:21:20 +0100
committerJames Rowe <jroweboy@gmail.com>2018-01-13 03:11:03 +0100
commitebf9a784a9f7f4148a669dbb39e7cd50df779a14 (patch)
treed585685a1c0a34b903af1d086d62560bf56bb29f /src/audio_core/interpolate.cpp
parentconfig: Default CPU core to Unicorn. (diff)
downloadyuzu-ebf9a784a9f7f4148a669dbb39e7cd50df779a14.tar
yuzu-ebf9a784a9f7f4148a669dbb39e7cd50df779a14.tar.gz
yuzu-ebf9a784a9f7f4148a669dbb39e7cd50df779a14.tar.bz2
yuzu-ebf9a784a9f7f4148a669dbb39e7cd50df779a14.tar.lz
yuzu-ebf9a784a9f7f4148a669dbb39e7cd50df779a14.tar.xz
yuzu-ebf9a784a9f7f4148a669dbb39e7cd50df779a14.tar.zst
yuzu-ebf9a784a9f7f4148a669dbb39e7cd50df779a14.zip
Diffstat (limited to '')
-rw-r--r--src/audio_core/interpolate.cpp76
1 files changed, 0 insertions, 76 deletions
diff --git a/src/audio_core/interpolate.cpp b/src/audio_core/interpolate.cpp
deleted file mode 100644
index 83573d772..000000000
--- a/src/audio_core/interpolate.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
-
-#include "audio_core/interpolate.h"
-#include "common/assert.h"
-#include "common/math_util.h"
-
-namespace AudioInterp {
-
-// Calculations are done in fixed point with 24 fractional bits.
-// (This is not verified. This was chosen for minimal error.)
-constexpr u64 scale_factor = 1 << 24;
-constexpr u64 scale_mask = scale_factor - 1;
-
-/// Here we step over the input in steps of rate, until we consume all of the input.
-/// Three adjacent samples are passed to fn each step.
-template <typename Function>
-static void StepOverSamples(State& state, StereoBuffer16& input, float rate,
- DSP::HLE::StereoFrame16& output, size_t& outputi, Function fn) {
- ASSERT(rate > 0);
-
- if (input.empty())
- return;
-
- input.insert(input.begin(), {state.xn2, state.xn1});
-
- const u64 step_size = static_cast<u64>(rate * scale_factor);
- u64 fposition = state.fposition;
- size_t inputi = 0;
-
- while (outputi < output.size()) {
- inputi = static_cast<size_t>(fposition / scale_factor);
-
- if (inputi + 2 >= input.size()) {
- inputi = input.size() - 2;
- break;
- }
-
- u64 fraction = fposition & scale_mask;
- output[outputi++] = fn(fraction, input[inputi], input[inputi + 1], input[inputi + 2]);
-
- fposition += step_size;
- }
-
- state.xn2 = input[inputi];
- state.xn1 = input[inputi + 1];
- state.fposition = fposition - inputi * scale_factor;
-
- input.erase(input.begin(), std::next(input.begin(), inputi + 2));
-}
-
-void None(State& state, StereoBuffer16& input, float rate, DSP::HLE::StereoFrame16& output,
- size_t& outputi) {
- StepOverSamples(
- state, input, rate, output, outputi,
- [](u64 fraction, const auto& x0, const auto& x1, const auto& x2) { return x0; });
-}
-
-void Linear(State& state, StereoBuffer16& input, float rate, DSP::HLE::StereoFrame16& output,
- size_t& outputi) {
- // Note on accuracy: Some values that this produces are +/- 1 from the actual firmware.
- StepOverSamples(state, input, rate, output, outputi,
- [](u64 fraction, const auto& x0, const auto& x1, const auto& x2) {
- // This is a saturated subtraction. (Verified by black-box fuzzing.)
- s64 delta0 = MathUtil::Clamp<s64>(x1[0] - x0[0], -32768, 32767);
- s64 delta1 = MathUtil::Clamp<s64>(x1[1] - x0[1], -32768, 32767);
-
- return std::array<s16, 2>{
- static_cast<s16>(x0[0] + fraction * delta0 / scale_factor),
- static_cast<s16>(x0[1] + fraction * delta1 / scale_factor),
- };
- });
-}
-
-} // namespace AudioInterp