summaryrefslogtreecommitdiff
path: root/src/audio_core/interpolate.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio_core/interpolate.h')
-rw-r--r--src/audio_core/interpolate.h31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/audio_core/interpolate.h b/src/audio_core/interpolate.h
index 19a7b66cb..8dff6111a 100644
--- a/src/audio_core/interpolate.h
+++ b/src/audio_core/interpolate.h
@@ -5,40 +5,45 @@
5#pragma once 5#pragma once
6 6
7#include <array> 7#include <array>
8#include <vector> 8#include <deque>
9#include "audio_core/hle/common.h"
9#include "common/common_types.h" 10#include "common/common_types.h"
10 11
11namespace AudioInterp { 12namespace AudioInterp {
12 13
13/// A variable length buffer of signed PCM16 stereo samples. 14/// A variable length buffer of signed PCM16 stereo samples.
14using StereoBuffer16 = std::vector<std::array<s16, 2>>; 15using StereoBuffer16 = std::deque<std::array<s16, 2>>;
15 16
16struct State { 17struct State {
17 // Two historical samples. 18 /// Two historical samples.
18 std::array<s16, 2> xn1 = {}; ///< x[n-1] 19 std::array<s16, 2> xn1 = {}; ///< x[n-1]
19 std::array<s16, 2> xn2 = {}; ///< x[n-2] 20 std::array<s16, 2> xn2 = {}; ///< x[n-2]
21 /// Current fractional position.
22 u64 fposition = 0;
20}; 23};
21 24
22/** 25/**
23 * No interpolation. This is equivalent to a zero-order hold. There is a two-sample predelay. 26 * No interpolation. This is equivalent to a zero-order hold. There is a two-sample predelay.
24 * @param state Interpolation state. 27 * @param state Interpolation state.
25 * @param input Input buffer. 28 * @param input Input buffer.
26 * @param rate_multiplier Stretch factor. Must be a positive non-zero value. 29 * @param rate Stretch factor. Must be a positive non-zero value.
27 * rate_multiplier > 1.0 performs decimation and rate_multipler < 1.0 30 * rate > 1.0 performs decimation and rate < 1.0 performs upsampling.
28 * performs upsampling. 31 * @param output The resampled audio buffer.
29 * @return The resampled audio buffer. 32 * @param outputi The index of output to start writing to.
30 */ 33 */
31StereoBuffer16 None(State& state, const StereoBuffer16& input, float rate_multiplier); 34void None(State& state, StereoBuffer16& input, float rate, DSP::HLE::StereoFrame16& output,
35 size_t& outputi);
32 36
33/** 37/**
34 * Linear interpolation. This is equivalent to a first-order hold. There is a two-sample predelay. 38 * Linear interpolation. This is equivalent to a first-order hold. There is a two-sample predelay.
35 * @param state Interpolation state. 39 * @param state Interpolation state.
36 * @param input Input buffer. 40 * @param input Input buffer.
37 * @param rate_multiplier Stretch factor. Must be a positive non-zero value. 41 * @param rate Stretch factor. Must be a positive non-zero value.
38 * rate_multiplier > 1.0 performs decimation and rate_multipler < 1.0 42 * rate > 1.0 performs decimation and rate < 1.0 performs upsampling.
39 * performs upsampling. 43 * @param output The resampled audio buffer.
40 * @return The resampled audio buffer. 44 * @param outputi The index of output to start writing to.
41 */ 45 */
42StereoBuffer16 Linear(State& state, const StereoBuffer16& input, float rate_multiplier); 46void Linear(State& state, StereoBuffer16& input, float rate, DSP::HLE::StereoFrame16& output,
47 size_t& outputi);
43 48
44} // namespace AudioInterp 49} // namespace AudioInterp