diff options
| author | 2017-08-03 12:22:51 +0100 | |
|---|---|---|
| committer | 2017-08-28 10:54:41 +0100 | |
| commit | 933508e2a2f7923cebc15d679b78933df8fb9ee5 (patch) | |
| tree | e49faeb30929c03c5490d8ae507ec907060c1068 /src/audio_core/interpolate.h | |
| parent | Merge pull request #2850 from j-selby/fix_invalid_paths (diff) | |
| download | yuzu-933508e2a2f7923cebc15d679b78933df8fb9ee5.tar.gz yuzu-933508e2a2f7923cebc15d679b78933df8fb9ee5.tar.xz yuzu-933508e2a2f7923cebc15d679b78933df8fb9ee5.zip | |
interpolate: Interpolate on a frame-by-frame basis
Diffstat (limited to 'src/audio_core/interpolate.h')
| -rw-r--r-- | src/audio_core/interpolate.h | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/audio_core/interpolate.h b/src/audio_core/interpolate.h index 19a7b66cb..59f59bc14 100644 --- a/src/audio_core/interpolate.h +++ b/src/audio_core/interpolate.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <vector> | 8 | #include <vector> |
| 9 | #include "audio_core/hle/common.h" | ||
| 9 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 10 | 11 | ||
| 11 | namespace AudioInterp { | 12 | namespace AudioInterp { |
| @@ -14,31 +15,35 @@ namespace AudioInterp { | |||
| 14 | using StereoBuffer16 = std::vector<std::array<s16, 2>>; | 15 | using StereoBuffer16 = std::vector<std::array<s16, 2>>; |
| 15 | 16 | ||
| 16 | struct State { | 17 | struct 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 | */ |
| 31 | StereoBuffer16 None(State& state, const StereoBuffer16& input, float rate_multiplier); | 34 | void 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 | */ |
| 42 | StereoBuffer16 Linear(State& state, const StereoBuffer16& input, float rate_multiplier); | 46 | void Linear(State& state, StereoBuffer16& input, float rate, DSP::HLE::StereoFrame16& output, |
| 47 | size_t& outputi); | ||
| 43 | 48 | ||
| 44 | } // namespace AudioInterp | 49 | } // namespace AudioInterp |