summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/drumgizmo.cc19
-rw-r--r--src/drumgizmo.h2
-rw-r--r--src/settings.h5
3 files changed, 19 insertions, 7 deletions
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);