From 8fac5fb3ac631f430e8181f7fb471faf7ebbb76a Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 8 Aug 2018 17:52:46 +0200 Subject: Remove old CHReampler class. --- src/drumgizmo.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/drumgizmo.cc') diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index e7ebe5a..5048e35 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -201,10 +201,9 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) zita[c].process(); } - std::memset(_resampler_input_buffer[c], 0, - sizeof(_resampler_input_buffer[c])); + std::memset(resampler_input_buffer[c].get(), 0, MAX_RESAMPLER_BUFFER_SIZE); - zita[c].inp_data = _resampler_input_buffer[c]; + zita[c].inp_data = resampler_input_buffer[c].get(); std::size_t sample_count = std::ceil((nsamples - (nsamples - zita[c].out_count)) * ratio); getSamples(c, kitpos, zita[c].inp_data, sample_count); @@ -409,11 +408,18 @@ void DrumGizmo::setSamplerate(float samplerate) // Notify input engine of the samplerate change. ie.setSampleRate(samplerate); - auto input_fs = kit.getSamplerate(); + auto input_fs = settings.drumkit_samplerate.load(); auto output_fs = samplerate; ratio = input_fs / output_fs; settings.resamplig_recommended.store(ratio != 1.0); + // TODO: Only reallocate the actual amount of samples needed based on the + // ratio and the framesize. + for(auto& buf : resampler_input_buffer) + { + buf.reset(new sample_t[MAX_RESAMPLER_BUFFER_SIZE]); + } + for(int c = 0; c < MAX_NUM_CHANNELS; ++c) { zita[c].reset(); -- cgit v1.2.3