From 087087e65c0ea0b19d21c4a8b44833bf0a951e86 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 12 Feb 2015 22:18:39 +0100 Subject: Add 'enable_resampling' config option for runtime disabling of the resampler. --- src/drumgizmo.cc | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'src/drumgizmo.cc') diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index 6b48cda..71043af 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -265,24 +265,26 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) // // Write audio // -#ifndef WITH_RESAMPLER - // No resampling needed - for(size_t c = 0; c < kit.channels.size(); c++) { - sample_t *buf = samples; - bool internal = false; - if(oe->getBuffer(c)) { - buf = oe->getBuffer(c); - internal = true; - } - if(buf) { - memset(buf, 0, nsamples * sizeof(sample_t)); - - getSamples(c, pos, buf, nsamples); +#ifdef WITH_RESAMPLER + if(Conf::enable_resampling == false) { // No resampling needed +#endif + for(size_t c = 0; c < kit.channels.size(); c++) { + sample_t *buf = samples; + bool internal = false; + if(oe->getBuffer(c)) { + buf = oe->getBuffer(c); + internal = true; + } + if(buf) { + memset(buf, 0, nsamples * sizeof(sample_t)); + + getSamples(c, pos, buf, nsamples); - if(!internal) oe->run(c, samples, nsamples); + if(!internal) oe->run(c, samples, nsamples); + } } - } -#else/*WITH_RESAMPLER*/ +#ifdef WITH_RESAMPLER + } else { // Resampling needed // @@ -320,6 +322,8 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) for(size_t c = 0; c < kit.channels.size(); c++) { oe->run(c, resampler_output_buffer[c], nsamples); } + + } #endif/*WITH_RESAMPLER*/ ie->post(); @@ -528,6 +532,11 @@ bool DrumGizmo::setConfigString(std::string cfg) str2float(p.value("velocity_randomiser_weight")); } + if(p.value("enable_resampling") != "") { + Conf::enable_resampling = + p.value("enable_resampling") == "true"; + } + std::string newkit = p.value("drumkitfile"); if(newkit != "" && kit.file() != newkit) { /* -- cgit v1.2.3