summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2024-07-27 11:42:03 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2024-07-28 21:34:08 +0200
commitaf48a660a3410c3a63cab324fd8a345b648f821d (patch)
tree0c3a9cb6f073ae6884866d4af7e1965777384982
parent6f0518b9a5999442d063369d9818c41fb9ac2ed6 (diff)
WIP
-rw-r--r--.clang-tidy35
-rw-r--r--src/sample_selection.cc25
-rw-r--r--src/settings.h2
3 files changed, 61 insertions, 1 deletions
diff --git a/.clang-tidy b/.clang-tidy
new file mode 100644
index 0000000..d3437d7
--- /dev/null
+++ b/.clang-tidy
@@ -0,0 +1,35 @@
+---
+Checks: "*,
+ -abseil-*,
+ -altera-*,
+ -android-*,
+ -fuchsia-*,
+ -google-*,
+ -llvm*,
+ -modernize-use-trailing-return-type,
+ -zircon-*,
+ -readability-else-after-return,
+ -readability-static-accessed-through-instance,
+ -readability-avoid-const-params-in-decls,
+ -cppcoreguidelines-non-private-member-variables-in-classes,
+ -misc-non-private-member-variables-in-classes,
+ -misc-include-cleaner,
+ -cppcoreguidelines-avoid-do-while,
+ -bugprone-easily-swappable-parameters,
+ -hicpp-uppercase-literal-suffix,
+ -readability-uppercase-literal-suffix,
+"
+WarningsAsErrors: ''
+HeaderFilterRegex: ''
+FormatStyle: none
+
+CheckOptions:
+ - key: readability-identifier-length.IgnoredVariableNames
+ value: 'x|y|z'
+ - key: readability-identifier-length.IgnoredParameterNames
+ value: 'x|y|z'
+
+
+
+
+
diff --git a/src/sample_selection.cc b/src/sample_selection.cc
index b7b6bcd..4bd1979 100644
--- a/src/sample_selection.cc
+++ b/src/sample_selection.cc
@@ -89,6 +89,7 @@ const Sample* SampleSelection::get(float power, float instrument_power_span, flo
instrument_power_span = 1.0;
}
+#if 0
// 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(), power);
@@ -165,6 +166,30 @@ const Sample* SampleSelection::get(float power, float instrument_power_span, flo
++count;
}
while (up_value_lb <= value_opt || down_value_lb <= value_opt);
+#else
+ for(std::size_t current_index = 0; current_index < samples.size(); ++current_index)
+ {
+ auto random = rand.floatInRange(0.,1.);
+ auto close = (samples[current_index].power - power)/instrument_power_span;
+ auto diverse = 1./(1. + (float)(pos - last[current_index])/settings.samplerate);
+ 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)
+ {
+ index_opt = current_index;
+ power_opt = samples[current_index].power;
+ pos_opt = samples[current_index].sample->getPosition();
+ value_opt = value;
+ random_opt = random;
+ close_opt = close;
+ diverse_opt = diverse;
+ closepos_opt = closepos;
+ }
+ }
+ int count{}; // not used
+#endif
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);
diff --git a/src/settings.h b/src/settings.h
index 58b17f3..074c7bc 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -78,7 +78,7 @@ struct Settings
static float constexpr velocity_stddev_default = .45f;
static float constexpr position_stddev_default = .45f;
static float constexpr sample_selection_f_close_default = .85f;
- static float constexpr sample_selection_f_position_default = .016f;
+ static float constexpr sample_selection_f_position_default = .85f;
static float constexpr sample_selection_f_diverse_default = .16f;
static float constexpr sample_selection_f_random_default = .07f;
Atomic<float> velocity_modifier_falloff{velocity_modifier_falloff_default};