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.cc24
1 files changed, 6 insertions, 18 deletions
diff --git a/src/sample_selection.cc b/src/sample_selection.cc
index ce50cfa..d4f78d7 100644
--- a/src/sample_selection.cc
+++ b/src/sample_selection.cc
@@ -62,15 +62,6 @@ const Sample* SampleSelection::get(level_t level, std::size_t pos)
return nullptr; // No samples to choose from.
}
- auto power_max = powerlist.getMaxPower();
- auto power_min = powerlist.getMinPower();
- float power_span = power_max - power_min;
-
- float mean = level - .5f/127.f; // XXX: this should actually be done when reading the events
- float stddev = settings.velocity_stddev.load();
- // the 20.0f we determined empirically
- float lvl = power_min + rand.normalDistribution(mean, stddev / 20.0f) * power_span;
-
std::size_t index_opt = 0;
float power_opt{0.f};
float value_opt{std::numeric_limits<float>::max()};
@@ -79,20 +70,17 @@ const Sample* SampleSelection::get(level_t level, std::size_t pos)
float close_opt = 0.;
float diverse_opt = 0.;
- DEBUG(rand, "level: %f, lvl: %f (mean: %.2f, stddev: %.2f,"
- "power_min: %f, power_max: %f)\n", level, lvl, mean, stddev, power_min, power_max);
-
const float f_close = settings.sample_selection_f_close.load();
const float f_diverse = settings.sample_selection_f_diverse.load();
const float f_random = settings.sample_selection_f_random.load();
// start with most promising power value and then stop when reaching far values
// which cannot become opt anymore
- auto closest_it = std::lower_bound(samples.begin(), samples.end(), lvl);
+ auto closest_it = std::lower_bound(samples.begin(), samples.end(), level);
std::size_t up_index = std::distance(samples.begin(), closest_it);
std::size_t down_index = (up_index == 0 ? 0 : up_index - 1);
- float up_value_lb = (up_index < samples.size() ? f_close*pow2(samples[up_index].power-lvl) : std::numeric_limits<float>::max());
- float down_value_lb = (up_index != 0 ? f_close*pow2(samples[down_index].power-lvl) : std::numeric_limits<float>::max());
+ float up_value_lb = (up_index < samples.size() ? f_close*pow2(samples[up_index].power-level) : std::numeric_limits<float>::max());
+ float down_value_lb = (up_index != 0 ? f_close*pow2(samples[down_index].power-level) : std::numeric_limits<float>::max());
std::size_t count = 0;
do
@@ -104,7 +92,7 @@ const Sample* SampleSelection::get(level_t level, std::size_t pos)
if (up_index != samples.size()-1)
{
++up_index;
- up_value_lb = f_close*pow2(samples[up_index].power-lvl);
+ up_value_lb = f_close*pow2(samples[up_index].power-level);
}
else
{
@@ -117,7 +105,7 @@ const Sample* SampleSelection::get(level_t level, std::size_t pos)
if (down_index != 0)
{
--down_index;
- down_value_lb = f_close*pow2(samples[down_index].power-lvl);
+ down_value_lb = f_close*pow2(samples[down_index].power-level);
}
else
{
@@ -126,7 +114,7 @@ const Sample* SampleSelection::get(level_t level, std::size_t pos)
}
auto random = rand.floatInRange(0.,1.);
- auto close = samples[current_index].power - lvl;
+ auto close = samples[current_index].power - level;
auto diverse = (float)settings.samplerate/std::max<std::size_t>(pos - last[current_index], 1);
auto value = f_close*pow2(close) + f_diverse*pow2(diverse) + f_random*random;