diff options
author | bunnei <bunneidev@gmail.com> | 2016-04-29 16:43:20 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2016-04-29 16:43:20 +0200 |
commit | 4c235955cf09ad38ca4723f6c5861298f7e845cc (patch) | |
tree | b933a3f130e5e5f4e57ca90ce2ecdfa57e0ea1d8 /src/audio_core/interpolate.h | |
parent | Merge pull request #1730 from hrydgard/vertex-loader (diff) | |
parent | AudioCore: Implement interpolation (diff) | |
download | yuzu-4c235955cf09ad38ca4723f6c5861298f7e845cc.tar yuzu-4c235955cf09ad38ca4723f6c5861298f7e845cc.tar.gz yuzu-4c235955cf09ad38ca4723f6c5861298f7e845cc.tar.bz2 yuzu-4c235955cf09ad38ca4723f6c5861298f7e845cc.tar.lz yuzu-4c235955cf09ad38ca4723f6c5861298f7e845cc.tar.xz yuzu-4c235955cf09ad38ca4723f6c5861298f7e845cc.tar.zst yuzu-4c235955cf09ad38ca4723f6c5861298f7e845cc.zip |
Diffstat (limited to 'src/audio_core/interpolate.h')
-rw-r--r-- | src/audio_core/interpolate.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/audio_core/interpolate.h b/src/audio_core/interpolate.h new file mode 100644 index 000000000..a4c0a453d --- /dev/null +++ b/src/audio_core/interpolate.h @@ -0,0 +1,41 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <array> +#include <vector> + +#include "common/common_types.h" + +namespace AudioInterp { + +/// A variable length buffer of signed PCM16 stereo samples. +using StereoBuffer16 = std::vector<std::array<s16, 2>>; + +struct State { + // Two historical samples. + std::array<s16, 2> xn1 = {}; ///< x[n-1] + std::array<s16, 2> xn2 = {}; ///< x[n-2] +}; + +/** + * No interpolation. This is equivalent to a zero-order hold. There is a two-sample predelay. + * @param input Input buffer. + * @param rate_multiplier Stretch factor. Must be a positive non-zero value. + * rate_multiplier > 1.0 performs decimation and rate_multipler < 1.0 performs upsampling. + * @return The resampled audio buffer. + */ +StereoBuffer16 None(State& state, const StereoBuffer16& input, float rate_multiplier); + +/** + * Linear interpolation. This is equivalent to a first-order hold. There is a two-sample predelay. + * @param input Input buffer. + * @param rate_multiplier Stretch factor. Must be a positive non-zero value. + * rate_multiplier > 1.0 performs decimation and rate_multipler < 1.0 performs upsampling. + * @return The resampled audio buffer. + */ +StereoBuffer16 Linear(State& state, const StereoBuffer16& input, float rate_multiplier); + +} // namespace AudioInterp |