diff options
-rw-r--r-- | plugin/drumgizmo_plugin.cc | 7 | ||||
-rw-r--r-- | plugingui/maintab.cc | 2 | ||||
-rw-r--r-- | plugingui/resamplingframecontent.cc | 35 | ||||
-rw-r--r-- | plugingui/resamplingframecontent.h | 13 | ||||
-rw-r--r-- | src/drumgizmo.cc | 19 | ||||
-rw-r--r-- | src/drumgizmo.h | 2 | ||||
-rw-r--r-- | src/settings.h | 5 |
7 files changed, 70 insertions, 13 deletions
diff --git a/plugin/drumgizmo_plugin.cc b/plugin/drumgizmo_plugin.cc index 87ce160..a91606b 100644 --- a/plugin/drumgizmo_plugin.cc +++ b/plugin/drumgizmo_plugin.cc @@ -612,6 +612,8 @@ std::string DrumGizmoPlugin::ConfigStringIO::get() float2str(settings.velocity_randomiser_weight.load()) + "</value>\n" " <value name=\"enable_resampling\">" + bool2str(settings.enable_resampling.load()) + "</value>\n" + " <value name=\"resampling_quality\">" + + float2str(settings.resampling_quality.load()) + "</value>\n" " <value name=\"disk_cache_upper_limit\">" + int2str(settings.disk_cache_upper_limit.load()) + "</value>\n" " <value name=\"disk_cache_chunk_size\">" + @@ -713,6 +715,11 @@ bool DrumGizmoPlugin::ConfigStringIO::set(std::string config_string) settings.enable_resampling.store(p.value("enable_resampling") == "true"); } + if(p.value("resampling_quality") != "") + { + settings.resampling_quality.store(str2float(p.value("resampling_quality"))); + } + if(p.value("disk_cache_upper_limit") != "") { settings.disk_cache_upper_limit.store(str2ll(p.value("disk_cache_upper_limit"))); diff --git a/plugingui/maintab.cc b/plugingui/maintab.cc index 9959f7e..771e0d2 100644 --- a/plugingui/maintab.cc +++ b/plugingui/maintab.cc @@ -105,7 +105,7 @@ MainTab::MainTab(Widget* parent, , humanizerframe_content{this, settings, settings_notifier} , diskstreamingframe_content{this, settings, settings_notifier} , bleedcontrolframe_content{this, settings, settings_notifier} - , resamplingframe_content{this, settings_notifier} + , resamplingframe_content{this, settings, settings_notifier} , timingframe_content{this, settings, settings_notifier} , sampleselectionframe_content{this, settings, settings_notifier} , visualizerframe_content{this, settings, settings_notifier} diff --git a/plugingui/resamplingframecontent.cc b/plugingui/resamplingframecontent.cc index 6026154..717df0f 100644 --- a/plugingui/resamplingframecontent.cc +++ b/plugingui/resamplingframecontent.cc @@ -31,9 +31,11 @@ namespace GUI { -ResamplingframeContent::ResamplingframeContent( - Widget* parent, SettingsNotifier& settings_notifier) - : Widget(parent) +ResamplingframeContent::ResamplingframeContent(Widget* parent, + Settings& settings, + SettingsNotifier& settings_notifier) + : Widget(parent) + , settings(settings) , settings_notifier(settings_notifier) { CONNECT(this, settings_notifier.drumkit_samplerate, @@ -42,10 +44,23 @@ ResamplingframeContent::ResamplingframeContent( this, &ResamplingframeContent::updateSessionSamplerate); CONNECT(this, settings_notifier.resampling_recommended, this, &ResamplingframeContent::updateResamplingRecommended); + CONNECT(this, settings_notifier.resampling_quality, + this, &ResamplingframeContent::updateResamplingQuality); text_field.move(0, 0); text_field.setReadOnly(true); + quality_knob.resize(30, 30); + quality_knob.setDefaultValue(0.7f); + quality_knob.showValue(false); + + quality_label.setText("Quality"); + quality_label.setAlignment(TextAlignment::center); + quality_label.resize(40, 16); + + CONNECT(&quality_knob, valueChangedNotifier, + this, &ResamplingframeContent::valueChangedNotifier); + updateContent(); text_field.show(); } @@ -53,7 +68,9 @@ ResamplingframeContent::ResamplingframeContent( void ResamplingframeContent::resize(std::size_t width, std::size_t height) { Widget::resize(width, height); - text_field.resize(width, height); + text_field.resize(width - 50, height); + quality_knob.move(width - 36, 20); + quality_label.move(width - 40, 0); } void ResamplingframeContent::updateContent() @@ -88,4 +105,14 @@ void ResamplingframeContent::updateResamplingRecommended(bool resampling_recomme updateContent(); } +void ResamplingframeContent::updateResamplingQuality(float resampling_quality) +{ + quality_knob.setValue(resampling_quality); +} + +void ResamplingframeContent::valueChangedNotifier(float value) +{ + settings.resampling_quality.store(value); +} + } // GUI:: diff --git a/plugingui/resamplingframecontent.h b/plugingui/resamplingframecontent.h index b5530c2..3efc62e 100644 --- a/plugingui/resamplingframecontent.h +++ b/plugingui/resamplingframecontent.h @@ -28,8 +28,11 @@ #include "widget.h" #include "textedit.h" +#include "knob.h" +#include "label.h" class SettingsNotifier; +struct Settings; namespace GUI { @@ -38,20 +41,28 @@ class ResamplingframeContent : public Widget { public: - ResamplingframeContent(Widget* parent, SettingsNotifier& settings_notifier); + ResamplingframeContent(Widget* parent, + Settings& settings, + SettingsNotifier& settings_notifier); // From Widget virtual void resize(std::size_t width, std::size_t height) override; +private: void updateContent(); void updateDrumkitSamplerate(std::size_t drumkit_samplerate); void updateSessionSamplerate(double samplerate); void updateResamplingRecommended(bool resampling_recommended); + void updateResamplingQuality(float resampling_quality); + void valueChangedNotifier(float value); private: TextEdit text_field{this}; + Knob quality_knob{this}; + Label quality_label{this}; + Settings& settings; SettingsNotifier& settings_notifier; std::string drumkit_samplerate; diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index fcc54ad..3af5cbc 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -53,7 +53,7 @@ DrumGizmo::DrumGizmo(Settings& settings, audio_cache.init(10000); // start thread events.reserve(1000); loader.init(); - setSamplerate(44100.0f); + setSamplerate(44100.0f, settings.resampling_quality.load()); settings_getter.audition_counter.hasChanged(); // Reset audition_counter } @@ -114,10 +114,15 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) enable_resampling = settings_getter.enable_resampling.getValue(); } - if(settings_getter.drumkit_samplerate.hasChanged()) { - settings_getter.drumkit_samplerate.getValue(); // stage new value - setSamplerate(settings.samplerate.load()); + auto sample_rate_changed = settings_getter.drumkit_samplerate.hasChanged(); + auto resampling_quality_changed = settings_getter.resampling_quality.hasChanged(); + if(sample_rate_changed || resampling_quality_changed) + { + settings_getter.drumkit_samplerate.getValue(); // stage new value + setSamplerate(settings.samplerate.load(), + settings_getter.resampling_quality.getValue()); + } } setFrameSize(nsamples); @@ -414,7 +419,7 @@ float DrumGizmo::samplerate() return settings.samplerate.load(); } -void DrumGizmo::setSamplerate(float samplerate) +void DrumGizmo::setSamplerate(float samplerate, float resampling_quality) { DEBUG(dgeditor, "%s samplerate: %f\n", __PRETTY_FUNCTION__, samplerate); settings.samplerate.store(samplerate); @@ -438,7 +443,9 @@ void DrumGizmo::setSamplerate(float samplerate) { zita[c].reset(); auto nchan = 1u; // mono - auto hlen = 72u; // 16 ≤ hlen ≤ 96 + // 16 ≤ hlen ≤ 96 - default is 72, q: 0.7f + resampling_quality = std::max(0.0f, std::min(1.0f, resampling_quality)); + std::size_t hlen = 16 + (96 - 16) * resampling_quality; zita[c].setup(input_fs, output_fs, nchan, hlen); // Prefill diff --git a/src/drumgizmo.h b/src/drumgizmo.h index 0aeab07..a075dd6 100644 --- a/src/drumgizmo.h +++ b/src/drumgizmo.h @@ -67,7 +67,7 @@ public: std::size_t getLatency() const; float samplerate(); - void setSamplerate(float samplerate); + void setSamplerate(float samplerate, float resample_quality = 0.7f); void setFrameSize(size_t framesize); diff --git a/src/settings.h b/src/settings.h index a3d21d0..7749adf 100644 --- a/src/settings.h +++ b/src/settings.h @@ -103,6 +103,7 @@ struct Settings Atomic<bool> enable_resampling{true}; Atomic<bool> resampling_recommended{false}; + Atomic<float> resampling_quality{0.7f}; // [0.0f; 1.0f] Atomic<std::size_t> number_of_files{0}; Atomic<std::size_t> number_of_files_loaded{0}; @@ -205,6 +206,7 @@ struct SettingsGetter SettingRef<bool> enable_resampling; SettingRef<bool> resampling_recommended; + SettingRef<float> resampling_quality; SettingRef<std::size_t> number_of_files; SettingRef<std::size_t> number_of_files_loaded; @@ -270,6 +272,7 @@ struct SettingsGetter , buffer_size(settings.buffer_size) , enable_resampling{settings.enable_resampling} , resampling_recommended{settings.resampling_recommended} + , resampling_quality{settings.resampling_quality} , number_of_files{settings.number_of_files} , number_of_files_loaded{settings.number_of_files_loaded} , current_file{settings.current_file} @@ -339,6 +342,7 @@ public: Notifier<bool> enable_resampling; Notifier<bool> resampling_recommended; + Notifier<float> resampling_quality; Notifier<std::size_t> number_of_files; Notifier<std::size_t> number_of_files_loaded; @@ -413,6 +417,7 @@ public: EVAL(enable_resampling); EVAL(resampling_recommended); + EVAL(resampling_quality); EVAL(number_of_files); EVAL(number_of_files_loaded); |