From e5efc3656090d39de1d8854aa495c8c16218c2f6 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 24 Jul 2016 10:06:27 +0200 Subject: Clear output buffers in LV2 and jack modes before each process iteration to eliminte noise when drumkit has not yet been loaded. --- drumgizmo/output/jackaudio.cc | 7 +++++++ plugin/drumgizmo_plugin.cc | 16 +++++++++------- src/drumgizmo.cc | 20 ++++++++------------ 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/drumgizmo/output/jackaudio.cc b/drumgizmo/output/jackaudio.cc index 2274bea..2620b84 100644 --- a/drumgizmo/output/jackaudio.cc +++ b/drumgizmo/output/jackaudio.cc @@ -26,6 +26,7 @@ */ #include #include +#include #include "jackaudio.h" @@ -83,6 +84,12 @@ void JackAudioOutputEngine::stop() void JackAudioOutputEngine::pre(size_t nsamples) { + // Clear all channels + for(auto& channel : channels) + { + assert(channel.samples.size() == nsamples); + std::memset(channel.samples.data(), 0, nsamples * sizeof(sample_t)); + } } void JackAudioOutputEngine::run(int ch, sample_t* samples, size_t nsamples) diff --git a/plugin/drumgizmo_plugin.cc b/plugin/drumgizmo_plugin.cc index 5e4ebeb..fa51575 100644 --- a/plugin/drumgizmo_plugin.cc +++ b/plugin/drumgizmo_plugin.cc @@ -26,13 +26,7 @@ */ #include "drumgizmo_plugin.h" -#include -#include -#include -#include -#include - -#include +#include #include @@ -292,6 +286,14 @@ void DrumGizmoPlugin::Output::stop() void DrumGizmoPlugin::Output::pre(size_t nsamples) { + // Clear all channels + for(auto& channel : *plugin.output_samples) + { + if(channel) + { + std::memset(channel, 0, nsamples * sizeof(sample_t)); + } + } } void DrumGizmoPlugin::Output::run(int ch, sample_t *samples, size_t nsamples) diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index fa601e6..18cbbb7 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -26,21 +26,16 @@ */ #include "drumgizmo.h" -#include -#include -#include +#include +#include +#include +#include #include #include - -#include - -#include - -#include #include -#include +#include #include "drumkitparser.h" #include "audioinputenginemidi.h" @@ -122,7 +117,8 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) setFreeWheel(ie.isFreewheeling() && oe.isFreewheeling()); ie.pre(); - oe.pre(nsamples); + oe.pre(nsamples); // Clears all output buffers + std::memset(samples, 0, nsamples * sizeof(sample_t)); // // Read new events @@ -161,7 +157,7 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) if(buf) { - memset(buf, 0, nsamples * sizeof(sample_t)); + std::memset(buf, 0, nsamples * sizeof(sample_t)); getSamples(c, pos, buf, nsamples); -- cgit v1.2.3