mirror of
https://git.h3cjp.net/H3cJP/yuzu.git
synced 2024-11-14 13:42:56 +00:00
Merge pull request #1617 from FearlessTobi/fix-stretch-delay
time_stretch: Switch to values of Citra
This commit is contained in:
commit
f1cb425d92
|
@ -32,10 +32,10 @@ std::size_t TimeStretcher::Process(const s16* in, std::size_t num_in, s16* out,
|
||||||
// We were given actual_samples number of samples, and num_samples were requested from us.
|
// We were given actual_samples number of samples, and num_samples were requested from us.
|
||||||
double current_ratio = static_cast<double>(num_in) / static_cast<double>(num_out);
|
double current_ratio = static_cast<double>(num_in) / static_cast<double>(num_out);
|
||||||
|
|
||||||
const double max_latency = 1.0; // seconds
|
const double max_latency = 0.25; // seconds
|
||||||
const double max_backlog = m_sample_rate * max_latency;
|
const double max_backlog = m_sample_rate * max_latency;
|
||||||
const double backlog_fullness = m_sound_touch.numSamples() / max_backlog;
|
const double backlog_fullness = m_sound_touch.numSamples() / max_backlog;
|
||||||
if (backlog_fullness > 5.0) {
|
if (backlog_fullness > 4.0) {
|
||||||
// Too many samples in backlog: Don't push anymore on
|
// Too many samples in backlog: Don't push anymore on
|
||||||
num_in = 0;
|
num_in = 0;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ std::size_t TimeStretcher::Process(const s16* in, std::size_t num_in, s16* out,
|
||||||
|
|
||||||
// This low-pass filter smoothes out variance in the calculated stretch ratio.
|
// This low-pass filter smoothes out variance in the calculated stretch ratio.
|
||||||
// The time-scale determines how responsive this filter is.
|
// The time-scale determines how responsive this filter is.
|
||||||
constexpr double lpf_time_scale = 2.0; // seconds
|
constexpr double lpf_time_scale = 0.712; // seconds
|
||||||
const double lpf_gain = 1.0 - std::exp(-time_delta / lpf_time_scale);
|
const double lpf_gain = 1.0 - std::exp(-time_delta / lpf_time_scale);
|
||||||
m_stretch_ratio += lpf_gain * (current_ratio - m_stretch_ratio);
|
m_stretch_ratio += lpf_gain * (current_ratio - m_stretch_ratio);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue