summaryrefslogtreecommitdiff
path: root/src/audio_core/time_stretch.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio_core/time_stretch.cpp')
-rw-r--r--src/audio_core/time_stretch.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/audio_core/time_stretch.cpp b/src/audio_core/time_stretch.cpp
index 17e128323..d2e3391c1 100644
--- a/src/audio_core/time_stretch.cpp
+++ b/src/audio_core/time_stretch.cpp
@@ -28,8 +28,8 @@ size_t TimeStretcher::Process(const s16* in, size_t num_in, s16* out, size_t num
28 // We were given actual_samples number of samples, and num_samples were requested from us. 28 // We were given actual_samples number of samples, and num_samples were requested from us.
29 double current_ratio = static_cast<double>(num_in) / static_cast<double>(num_out); 29 double current_ratio = static_cast<double>(num_in) / static_cast<double>(num_out);
30 30
31 const double max_latency = 0.3; // seconds 31 const double max_latency = 1.0; // seconds
32 const double max_backlog = m_sample_rate * max_latency / 1000.0 / m_stretch_ratio; 32 const double max_backlog = m_sample_rate * max_latency;
33 const double backlog_fullness = m_sound_touch.numSamples() / max_backlog; 33 const double backlog_fullness = m_sound_touch.numSamples() / max_backlog;
34 if (backlog_fullness > 5.0) { 34 if (backlog_fullness > 5.0) {
35 // Too many samples in backlog: Don't push anymore on 35 // Too many samples in backlog: Don't push anymore on
@@ -49,13 +49,13 @@ size_t TimeStretcher::Process(const s16* in, size_t num_in, s16* out, size_t num
49 const double lpf_gain = 1.0 - std::exp(-time_delta / lpf_time_scale); 49 const double lpf_gain = 1.0 - std::exp(-time_delta / lpf_time_scale);
50 m_stretch_ratio += lpf_gain * (current_ratio - m_stretch_ratio); 50 m_stretch_ratio += lpf_gain * (current_ratio - m_stretch_ratio);
51 51
52 // Place a lower limit of 10% speed. When a game boots up, there will be 52 // Place a lower limit of 5% speed. When a game boots up, there will be
53 // many silence samples. These do not need to be timestretched. 53 // many silence samples. These do not need to be timestretched.
54 m_stretch_ratio = std::max(m_stretch_ratio, 0.1); 54 m_stretch_ratio = std::max(m_stretch_ratio, 0.05);
55 m_sound_touch.setTempo(m_stretch_ratio); 55 m_sound_touch.setTempo(m_stretch_ratio);
56 56
57 LOG_DEBUG(Audio, "Audio Stretching: samples:{}/{} ratio:{} backlog:{} gain: {}", num_in, num_out, 57 LOG_DEBUG(Audio, "{:5}/{:5} ratio:{:0.6f} backlog:{:0.6f}", num_in, num_out, m_stretch_ratio,
58 m_stretch_ratio, backlog_fullness, lpf_gain); 58 backlog_fullness);
59 59
60 m_sound_touch.putSamples(in, num_in); 60 m_sound_touch.putSamples(in, num_in);
61 return m_sound_touch.receiveSamples(out, num_out); 61 return m_sound_touch.receiveSamples(out, num_out);