diff options
| author | 2016-09-21 11:29:48 -0700 | |
|---|---|---|
| committer | 2016-09-21 11:29:48 -0700 | |
| commit | d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a (patch) | |
| tree | 8a22ca73ff838f3f0090b29a548ae81087fc90ed /src/audio_core/time_stretch.cpp | |
| parent | README: Specify master branch for Travis CI badge (diff) | |
| parent | Fix Travis clang-format check (diff) | |
| download | yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.tar.gz yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.tar.xz yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.zip | |
Merge pull request #2086 from linkmauve/clang-format
Add clang-format as part of our {commit,travis}-time checks
Diffstat (limited to 'src/audio_core/time_stretch.cpp')
| -rw-r--r-- | src/audio_core/time_stretch.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/audio_core/time_stretch.cpp b/src/audio_core/time_stretch.cpp index ea38f40d0..53cb64655 100644 --- a/src/audio_core/time_stretch.cpp +++ b/src/audio_core/time_stretch.cpp | |||
| @@ -5,12 +5,9 @@ | |||
| 5 | #include <chrono> | 5 | #include <chrono> |
| 6 | #include <cmath> | 6 | #include <cmath> |
| 7 | #include <vector> | 7 | #include <vector> |
| 8 | |||
| 9 | #include <SoundTouch.h> | 8 | #include <SoundTouch.h> |
| 10 | |||
| 11 | #include "audio_core/audio_core.h" | 9 | #include "audio_core/audio_core.h" |
| 12 | #include "audio_core/time_stretch.h" | 10 | #include "audio_core/time_stretch.h" |
| 13 | |||
| 14 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 15 | #include "common/logging/log.h" | 12 | #include "common/logging/log.h" |
| 16 | #include "common/math_util.h" | 13 | #include "common/math_util.h" |
| @@ -26,8 +23,8 @@ static double ClampRatio(double ratio) { | |||
| 26 | return MathUtil::Clamp(ratio, MIN_RATIO, MAX_RATIO); | 23 | return MathUtil::Clamp(ratio, MIN_RATIO, MAX_RATIO); |
| 27 | } | 24 | } |
| 28 | 25 | ||
| 29 | constexpr double MIN_DELAY_TIME = 0.05; // Units: seconds | 26 | constexpr double MIN_DELAY_TIME = 0.05; // Units: seconds |
| 30 | constexpr double MAX_DELAY_TIME = 0.25; // Units: seconds | 27 | constexpr double MAX_DELAY_TIME = 0.25; // Units: seconds |
| 31 | constexpr size_t DROP_FRAMES_SAMPLE_DELAY = 16000; // Units: samples | 28 | constexpr size_t DROP_FRAMES_SAMPLE_DELAY = 16000; // Units: samples |
| 32 | 29 | ||
| 33 | constexpr double SMOOTHING_FACTOR = 0.007; | 30 | constexpr double SMOOTHING_FACTOR = 0.007; |
| @@ -48,7 +45,8 @@ std::vector<s16> TimeStretcher::Process(size_t samples_in_queue) { | |||
| 48 | 45 | ||
| 49 | double ratio = CalculateCurrentRatio(); | 46 | double ratio = CalculateCurrentRatio(); |
| 50 | ratio = CorrectForUnderAndOverflow(ratio, samples_in_queue); | 47 | ratio = CorrectForUnderAndOverflow(ratio, samples_in_queue); |
| 51 | impl->smoothed_ratio = (1.0 - SMOOTHING_FACTOR) * impl->smoothed_ratio + SMOOTHING_FACTOR * ratio; | 48 | impl->smoothed_ratio = |
| 49 | (1.0 - SMOOTHING_FACTOR) * impl->smoothed_ratio + SMOOTHING_FACTOR * ratio; | ||
| 52 | impl->smoothed_ratio = ClampRatio(impl->smoothed_ratio); | 50 | impl->smoothed_ratio = ClampRatio(impl->smoothed_ratio); |
| 53 | 51 | ||
| 54 | // SoundTouch's tempo definition the inverse of our ratio definition. | 52 | // SoundTouch's tempo definition the inverse of our ratio definition. |
| @@ -100,7 +98,8 @@ double TimeStretcher::CalculateCurrentRatio() { | |||
| 100 | const steady_clock::time_point now = steady_clock::now(); | 98 | const steady_clock::time_point now = steady_clock::now(); |
| 101 | const std::chrono::duration<double> duration = now - impl->frame_timer; | 99 | const std::chrono::duration<double> duration = now - impl->frame_timer; |
| 102 | 100 | ||
| 103 | const double expected_time = static_cast<double>(impl->samples_queued) / static_cast<double>(native_sample_rate); | 101 | const double expected_time = |
| 102 | static_cast<double>(impl->samples_queued) / static_cast<double>(native_sample_rate); | ||
| 104 | const double actual_time = duration.count(); | 103 | const double actual_time = duration.count(); |
| 105 | 104 | ||
| 106 | double ratio; | 105 | double ratio; |