summaryrefslogtreecommitdiff
path: root/src/sample_selection.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/sample_selection.cc')
-rw-r--r--src/sample_selection.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/sample_selection.cc b/src/sample_selection.cc
index eb13e55..57ef4fe 100644
--- a/src/sample_selection.cc
+++ b/src/sample_selection.cc
@@ -56,7 +56,7 @@ void SampleSelection::finalise()
// FIXME: For the position, weird hacks via the powerlist are necessary. Refactor!
// FIXME: bad variable naming
-const Sample* SampleSelection::get(level_t level, float position, std::size_t pos)
+const Sample* SampleSelection::get(level_t level, float position, float openness, std::size_t pos)
{
const auto& samples = powerlist.getPowerListItems();
if(!samples.size())
@@ -67,6 +67,7 @@ const Sample* SampleSelection::get(level_t level, float position, std::size_t po
std::size_t index_opt = 0;
float power_opt{0.f};
float pos_opt{0.f};
+ float openness_opt{0.f};
float value_opt{std::numeric_limits<float>::max()};
// the following three values are mostly for debugging
float close_opt = 0.;
@@ -77,6 +78,7 @@ const Sample* SampleSelection::get(level_t level, float position, std::size_t po
// Note the magic values in front of the settings factors.
const float f_close = 4.*settings.sample_selection_f_close.load();
const float f_position = 1000.*settings.sample_selection_f_position.load(); // FIXME: huge factor for now
+ const float f_openness = 1000.*settings.sample_selection_f_openness.load(); // FIXME: huge factor for now
const float f_diverse = (1./2.)*settings.sample_selection_f_diverse.load();
const float f_random = (1./3.)*settings.sample_selection_f_random.load();
@@ -142,14 +144,21 @@ const Sample* SampleSelection::get(level_t level, float position, std::size_t po
auto close = (samples[current_index].power - level)/power_range;
auto diverse = 1./(1. + (float)(pos - last[current_index])/settings.samplerate);
auto closepos = samples[current_index].sample->getPosition() - position;
+ auto closeopenness = samples[current_index].sample->getOpenness() - openness;
// 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;
+ auto value =
+ f_close*pow2(close)
+ + f_position*pow2(closepos)
+ + f_openness*pow2(closeopenness)
+ + f_diverse*diverse
+ + f_random*random;
if (value < value_opt)
{
index_opt = current_index;
power_opt = samples[current_index].power;
pos_opt = samples[current_index].sample->getPosition();
+ openness_opt = samples[current_index].sample->getOpenness();
value_opt = value;
random_opt = random;
close_opt = close;
@@ -160,7 +169,7 @@ const Sample* SampleSelection::get(level_t level, float position, std::size_t po
}
while (up_value_lb <= value_opt || down_value_lb <= value_opt);
- DEBUG(rand, "Chose sample with index: %d, value: %f, power: %f, position: %f, random: %f, close: %f, diverse: %f, closepos: %f, count: %d", (int)index_opt, value_opt, power_opt, pos_opt, random_opt, close_opt, diverse_opt, closepos_opt, (int)count);
+ DEBUG(rand, "Chose sample with index: %d, value: %f, power: %f, position: %f, openness: %f, random: %f, close: %f, diverse: %f, closepos: %f, count: %d", (int)index_opt, value_opt, power_opt, pos_opt, openness_opt, random_opt, close_opt, diverse_opt, closepos_opt, (int)count);
last[index_opt] = pos;
return samples[index_opt].sample;