From 6732ac4278bae1bf5bfeb9d4ca9e0fdfa1aaf369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Nusser?= Date: Sat, 13 Feb 2021 12:25:50 +0100 Subject: Small cleaning up and comment. --- src/sample_selection.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/sample_selection.cc') diff --git a/src/sample_selection.cc b/src/sample_selection.cc index 53417b8..eb023c5 100644 --- a/src/sample_selection.cc +++ b/src/sample_selection.cc @@ -141,8 +141,9 @@ const Sample* SampleSelection::get(level_t level, float position, std::size_t po auto random = rand.floatInRange(0.,1.); auto close = (samples[current_index].power - level)/power_range; auto diverse = 1./(1. + (float)(pos - last[current_index])/settings.samplerate); - auto closepos = (position - samples[current_index].sample->getPosition()); - auto value = f_close*pow2(close) + f_diverse*diverse + f_random*random + f_position*pow2(closepos); + auto closepos = samples[current_index].sample->getPosition() - position; + // note that the value below for close and closepos is actually the weighted squared l2 distance in 2d + auto value = f_close*pow2(close) + f_position*pow2(closepos) + f_diverse*diverse + f_random*random; if (value < value_opt) { -- cgit v1.2.3