diff options
author | André Nusser <andre.nusser@googlemail.com> | 2019-05-11 21:02:27 +0200 |
---|---|---|
committer | André Nusser <andre.nusser@googlemail.com> | 2019-05-11 21:02:27 +0200 |
commit | 18650bf589c459e60c2435d9a547218a744cdb32 (patch) | |
tree | ab32e46ab7ac2e52e1cd16070647510952560867 | |
parent | eb362a5e4976d69509f35eb9e0c5771500041817 (diff) |
Some cleaning up of the sample selection.
-rw-r--r-- | plugin/drumgizmo_plugin.cc | 16 | ||||
-rw-r--r-- | plugingui/maintab.cc | 2 | ||||
-rw-r--r-- | plugingui/sampleselectionframecontent.cc | 62 | ||||
-rw-r--r-- | plugingui/sampleselectionframecontent.h | 22 | ||||
-rw-r--r-- | src/sample_selection.cc | 28 | ||||
-rw-r--r-- | src/settings.h | 24 |
6 files changed, 77 insertions, 77 deletions
diff --git a/plugin/drumgizmo_plugin.cc b/plugin/drumgizmo_plugin.cc index acbb5a9..1d03fd2 100644 --- a/plugin/drumgizmo_plugin.cc +++ b/plugin/drumgizmo_plugin.cc @@ -593,10 +593,10 @@ std::string DrumGizmoPlugin::ConfigStringIO::get() float2str(settings.velocity_modifier_weight.load()) + "</value>\n" " <value name=\"velocity_stddev\">" + float2str(settings.velocity_stddev.load()) + "</value>\n" - " <value name=\"sample_selection_f_distance\">" + - float2str(settings.sample_selection_f_distance.load()) + "</value>\n" - " <value name=\"sample_selection_f_recent\">" + - float2str(settings.sample_selection_f_recent.load()) + "</value>\n" + " <value name=\"sample_selection_f_close\">" + + float2str(settings.sample_selection_f_close.load()) + "</value>\n" + " <value name=\"sample_selection_f_diverse\">" + + float2str(settings.sample_selection_f_diverse.load()) + "</value>\n" " <value name=\"sample_selection_f_random\">" + float2str(settings.sample_selection_f_random.load()) + "</value>\n" " <value name=\"enable_velocity_randomiser\">" + @@ -660,14 +660,14 @@ bool DrumGizmoPlugin::ConfigStringIO::set(std::string config_string) settings.velocity_stddev.store(str2float(p.value("velocity_stddev"))); } - if(p.value("sample_selection_f_distance") != "") + if(p.value("sample_selection_f_close") != "") { - settings.sample_selection_f_distance.store(str2float(p.value("sample_selection_f_distance"))); + settings.sample_selection_f_close.store(str2float(p.value("sample_selection_f_close"))); } - if(p.value("sample_selection_f_recent") != "") + if(p.value("sample_selection_f_diverse") != "") { - settings.sample_selection_f_recent.store(str2float(p.value("sample_selection_f_recent"))); + settings.sample_selection_f_diverse.store(str2float(p.value("sample_selection_f_diverse"))); } if(p.value("sample_selection_f_random") != "") diff --git a/plugingui/maintab.cc b/plugingui/maintab.cc index 18fed6c..cdc0b05 100644 --- a/plugingui/maintab.cc +++ b/plugingui/maintab.cc @@ -51,7 +51,7 @@ MainTab::MainTab(Widget* parent, add("Drumkit", drumkit_frame, drumkitframe_content, 15, 0); add("Status", status_frame, statusframe_content, 24, 0); - add("Resampling", resampling_frame, resamplingframe_content, 10, 0); + add("Resampling", resampling_frame, resamplingframe_content, 20, 0); add("Velocity Humanizer", humanizer_frame, humanizerframe_content, 10, 1); humanizer_frame.setHelpText("Hello World\nThis is a nice World\n... I think"); diff --git a/plugingui/sampleselectionframecontent.cc b/plugingui/sampleselectionframecontent.cc index 534a0b9..d52ef93 100644 --- a/plugingui/sampleselectionframecontent.cc +++ b/plugingui/sampleselectionframecontent.cc @@ -42,19 +42,19 @@ SampleselectionframeContent::SampleselectionframeContent(Widget* parent, { layout.setResizeChildren(false); - f_distance.resize(80, 80); - f_distance_knob.resize(30, 30); - f_distance_knob.showValue(false); - f_distance_knob.setDefaultValue(Settings::sample_selection_f_distance_default/f_distance_factor); - f_distance.setControl(&f_distance_knob); - layout.addItem(&f_distance); - - f_recent.resize(80, 80); - f_recent_knob.resize(30, 30); - f_recent_knob.showValue(false); - f_recent_knob.setDefaultValue(Settings::sample_selection_f_recent_default/f_recent_factor); - f_recent.setControl(&f_recent_knob); - layout.addItem(&f_recent); + f_close.resize(80, 80); + f_close_knob.resize(30, 30); + f_close_knob.showValue(false); + f_close_knob.setDefaultValue(Settings::sample_selection_f_close_default/f_close_factor); + f_close.setControl(&f_close_knob); + layout.addItem(&f_close); + + f_diverse.resize(80, 80); + f_diverse_knob.resize(30, 30); + f_diverse_knob.showValue(false); + f_diverse_knob.setDefaultValue(Settings::sample_selection_f_diverse_default/f_diverse_factor); + f_diverse.setControl(&f_diverse_knob); + layout.addItem(&f_diverse); f_random.resize(80, 80); f_random_knob.resize(30, 30); @@ -63,33 +63,33 @@ SampleselectionframeContent::SampleselectionframeContent(Widget* parent, f_random.setControl(&f_random_knob); layout.addItem(&f_random); - layout.setPosition(&f_distance, GridLayout::GridRange{0, 1, 0, 1}); - layout.setPosition(&f_recent, GridLayout::GridRange{1, 2, 0, 1}); + layout.setPosition(&f_close, GridLayout::GridRange{0, 1, 0, 1}); + layout.setPosition(&f_diverse, GridLayout::GridRange{1, 2, 0, 1}); layout.setPosition(&f_random, GridLayout::GridRange{2, 3, 0, 1}); - CONNECT(this, settings_notifier.sample_selection_f_distance, - this, &SampleselectionframeContent::fDistanceSettingsValueChanged); - CONNECT(this, settings_notifier.sample_selection_f_recent, - this, &SampleselectionframeContent::fRecentSettingsValueChanged); + CONNECT(this, settings_notifier.sample_selection_f_close, + this, &SampleselectionframeContent::fCloseSettingsValueChanged); + CONNECT(this, settings_notifier.sample_selection_f_diverse, + this, &SampleselectionframeContent::fDiverseSettingsValueChanged); CONNECT(this, settings_notifier.sample_selection_f_random, this, &SampleselectionframeContent::fRandomSettingsValueChanged); - CONNECT(&f_distance_knob, valueChangedNotifier, - this, &SampleselectionframeContent::fDistanceKnobValueChanged); - CONNECT(&f_recent_knob, valueChangedNotifier, - this, &SampleselectionframeContent::fRecentKnobValueChanged); + CONNECT(&f_close_knob, valueChangedNotifier, + this, &SampleselectionframeContent::fCloseKnobValueChanged); + CONNECT(&f_diverse_knob, valueChangedNotifier, + this, &SampleselectionframeContent::fDiverseKnobValueChanged); CONNECT(&f_random_knob, valueChangedNotifier, this, &SampleselectionframeContent::fRandomKnobValueChanged); } -void SampleselectionframeContent::fDistanceKnobValueChanged(float value) +void SampleselectionframeContent::fCloseKnobValueChanged(float value) { - settings.sample_selection_f_distance.store(value*f_distance_factor); + settings.sample_selection_f_close.store(value*f_close_factor); } -void SampleselectionframeContent::fRecentKnobValueChanged(float value) +void SampleselectionframeContent::fDiverseKnobValueChanged(float value) { - settings.sample_selection_f_recent.store(value*f_recent_factor); + settings.sample_selection_f_diverse.store(value*f_diverse_factor); } void SampleselectionframeContent::fRandomKnobValueChanged(float value) @@ -97,14 +97,14 @@ void SampleselectionframeContent::fRandomKnobValueChanged(float value) settings.sample_selection_f_random.store(value*f_random_factor); } -void SampleselectionframeContent::fDistanceSettingsValueChanged(float value) +void SampleselectionframeContent::fCloseSettingsValueChanged(float value) { - f_distance_knob.setValue(value/f_distance_factor); + f_close_knob.setValue(value/f_close_factor); } -void SampleselectionframeContent::fRecentSettingsValueChanged(float value) +void SampleselectionframeContent::fDiverseSettingsValueChanged(float value) { - f_recent_knob.setValue(value/f_recent_factor); + f_diverse_knob.setValue(value/f_diverse_factor); } void SampleselectionframeContent::fRandomSettingsValueChanged(float value) diff --git a/plugingui/sampleselectionframecontent.h b/plugingui/sampleselectionframecontent.h index 097bc20..272d620 100644 --- a/plugingui/sampleselectionframecontent.h +++ b/plugingui/sampleselectionframecontent.h @@ -46,26 +46,26 @@ public: SettingsNotifier& settings_notifier); private: - static float constexpr f_distance_factor = 4.f; - static float constexpr f_recent_factor = 1.f; + static float constexpr f_close_factor = 4.f; + static float constexpr f_diverse_factor = 1.f; static float constexpr f_random_factor = .5f; - void fDistanceKnobValueChanged(float value); - void fRecentKnobValueChanged(float value); + void fCloseKnobValueChanged(float value); + void fDiverseKnobValueChanged(float value); void fRandomKnobValueChanged(float value); - void fDistanceSettingsValueChanged(float value); - void fRecentSettingsValueChanged(float value); + void fCloseSettingsValueChanged(float value); + void fDiverseSettingsValueChanged(float value); void fRandomSettingsValueChanged(float value); GridLayout layout{this, 3, 1}; - LabeledControl f_distance{this, "fDistance"}; - LabeledControl f_recent{this, "fRecent"}; - LabeledControl f_random{this, "fRandom"}; + LabeledControl f_close{this, "Close"}; + LabeledControl f_diverse{this, "Diverse"}; + LabeledControl f_random{this, "Random"}; - Knob f_distance_knob{&f_distance}; - Knob f_recent_knob{&f_recent}; + Knob f_close_knob{&f_close}; + Knob f_diverse_knob{&f_diverse}; Knob f_random_knob{&f_random}; Settings& settings; diff --git a/src/sample_selection.cc b/src/sample_selection.cc index 92c4efc..1c35c87 100644 --- a/src/sample_selection.cc +++ b/src/sample_selection.cc @@ -171,14 +171,14 @@ const Sample* SampleSelection::getObjective(level_t level, std::size_t pos) float value_opt{std::numeric_limits<float>::max()}; // the following three values are mostly for debugging float random_opt = 0.; - float distance_opt = 0.; - float recent_opt = 0.; + 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_distance = settings.sample_selection_f_distance.load(); - const float f_recent = settings.sample_selection_f_recent.load(); + 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 @@ -186,8 +186,8 @@ const Sample* SampleSelection::getObjective(level_t level, std::size_t pos) auto closest_it = std::lower_bound(samples.begin(), samples.end(), lvl); 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_distance*pow2(samples[up_index].power-lvl) : std::numeric_limits<float>::max()); - float down_value_lb = (up_index != 0 ? f_distance*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-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()); std::size_t count = 0; do @@ -199,7 +199,7 @@ const Sample* SampleSelection::getObjective(level_t level, std::size_t pos) if (up_index != samples.size()-1) { ++up_index; - up_value_lb = f_distance*pow2(samples[up_index].power-lvl); + up_value_lb = f_close*pow2(samples[up_index].power-lvl); } else { @@ -212,7 +212,7 @@ const Sample* SampleSelection::getObjective(level_t level, std::size_t pos) if (down_index != 0) { --down_index; - down_value_lb = f_distance*pow2(samples[down_index].power-lvl); + down_value_lb = f_close*pow2(samples[down_index].power-lvl); } else { @@ -221,9 +221,9 @@ const Sample* SampleSelection::getObjective(level_t level, std::size_t pos) } auto random = rand.floatInRange(0.,1.); - auto distance = samples[current_index].power - lvl; - auto recent = (float)settings.samplerate/std::max<std::size_t>(pos - last[current_index], 1); - auto value = f_distance*pow2(distance) + f_recent*pow2(recent) + f_random*random; + auto close = samples[current_index].power - lvl; + 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; if (value < value_opt) { @@ -231,14 +231,14 @@ const Sample* SampleSelection::getObjective(level_t level, std::size_t pos) power_opt = samples[current_index].power; value_opt = value; random_opt = random; - distance_opt = distance; - recent_opt = recent; + close_opt = close; + diverse_opt = diverse; } ++count; } while (up_value_lb <= value_opt || down_value_lb <= value_opt); - DEBUG(rand, "Chose sample with index: %d, value: %f, power %f, random: %f, distance: %f, recent: %f, count: %d", (int)index_opt, value_opt, power_opt, random_opt, distance_opt, recent_opt, (int)count); + DEBUG(rand, "Chose sample with index: %d, value: %f, power %f, random: %f, close: %f, diverse: %f, count: %d", (int)index_opt, value_opt, power_opt, random_opt, close_opt, diverse_opt, (int)count); last[index_opt] = pos; return samples[index_opt].sample; diff --git a/src/settings.h b/src/settings.h index 6abbc72..1974bcd 100644 --- a/src/settings.h +++ b/src/settings.h @@ -75,14 +75,14 @@ struct Settings static float constexpr velocity_modifier_falloff_default = 0.5f; static float constexpr velocity_modifier_weight_default = 0.25f; static float constexpr velocity_stddev_default = 1.0f; - static float constexpr sample_selection_f_distance_default = 2.f; - static float constexpr sample_selection_f_recent_default = .3f; + static float constexpr sample_selection_f_close_default = 2.f; + static float constexpr sample_selection_f_diverse_default = .3f; static float constexpr sample_selection_f_random_default = 0.05f; Atomic<float> velocity_modifier_falloff{velocity_modifier_falloff_default}; Atomic<float> velocity_modifier_weight{velocity_modifier_weight_default}; Atomic<float> velocity_stddev{velocity_stddev_default}; - Atomic<float> sample_selection_f_distance{sample_selection_f_distance_default}; - Atomic<float> sample_selection_f_recent{sample_selection_f_recent_default}; + Atomic<float> sample_selection_f_close{sample_selection_f_close_default}; + Atomic<float> sample_selection_f_diverse{sample_selection_f_diverse_default}; Atomic<float> sample_selection_f_random{sample_selection_f_random_default}; //! Control number of times to retry sample selection as long as the sample @@ -170,8 +170,8 @@ struct SettingsGetter SettingRef<float> velocity_modifier_falloff; SettingRef<float> velocity_modifier_weight; SettingRef<float> velocity_stddev; - SettingRef<float> sample_selection_f_distance; - SettingRef<float> sample_selection_f_recent; + SettingRef<float> sample_selection_f_close; + SettingRef<float> sample_selection_f_diverse; SettingRef<float> sample_selection_f_random; SettingRef<std::size_t> sample_selection_retry_count; @@ -224,8 +224,8 @@ struct SettingsGetter , velocity_modifier_falloff{settings.velocity_modifier_falloff} , velocity_modifier_weight{settings.velocity_modifier_weight} , velocity_stddev{settings.velocity_stddev} - , sample_selection_f_distance{settings.sample_selection_f_distance} - , sample_selection_f_recent{settings.sample_selection_f_recent} + , sample_selection_f_close{settings.sample_selection_f_close} + , sample_selection_f_diverse{settings.sample_selection_f_diverse} , sample_selection_f_random{settings.sample_selection_f_random} , sample_selection_retry_count(settings.sample_selection_retry_count) , velocity_modifier_current{settings.velocity_modifier_current} @@ -278,8 +278,8 @@ public: Notifier<float> velocity_modifier_falloff; Notifier<float> velocity_modifier_weight; Notifier<float> velocity_stddev; - Notifier<float> sample_selection_f_distance; - Notifier<float> sample_selection_f_recent; + Notifier<float> sample_selection_f_close; + Notifier<float> sample_selection_f_diverse; Notifier<float> sample_selection_f_random; Notifier<std::size_t> sample_selection_retry_count; Notifier<float> velocity_modifier_current; @@ -336,8 +336,8 @@ public: EVAL(velocity_modifier_falloff); EVAL(velocity_modifier_weight); EVAL(velocity_stddev); - EVAL(sample_selection_f_distance); - EVAL(sample_selection_f_recent); + EVAL(sample_selection_f_close); + EVAL(sample_selection_f_diverse); EVAL(sample_selection_f_random); EVAL(sample_selection_retry_count); EVAL(velocity_modifier_current); |