summaryrefslogtreecommitdiff
path: root/src/drumgizmo.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2021-04-10 18:36:47 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2021-07-04 11:27:14 +0200
commitfe1986214251bcd110837b81ed2159d75c58f8e2 (patch)
treec38a0bdb27b877b900227827b98ca5e39709ff09 /src/drumgizmo.cc
parenta638001e3249edf7264b5ee0f6d5280229aeb671 (diff)
Get rid of big stack allocation during resampler (re-)configuration.
Diffstat (limited to 'src/drumgizmo.cc')
-rw-r--r--src/drumgizmo.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc
index ca91c12..345e89d 100644
--- a/src/drumgizmo.cc
+++ b/src/drumgizmo.cc
@@ -463,10 +463,13 @@ void DrumGizmo::setSamplerate(float samplerate, float resampling_quality)
zita[c].set_inp_data(nullptr);
zita[c].set_inp_count(null_size);
- constexpr auto sz = 4096 * 16;
- sample_t s[sz];
- zita[c].set_out_data(s);
- zita[c].set_out_count(sz);
+ auto scratch_buffer_size = (null_size / ratio) + 1;
+ if(scratch_buffer.size() < scratch_buffer_size)
+ {
+ scratch_buffer.resize(scratch_buffer_size);
+ }
+ zita[c].set_out_data(scratch_buffer.data());
+ zita[c].set_out_count(scratch_buffer_size);
zita[c].process();
}