From 8cd333bba78515b40166ac1b41669bb8dd3c20a0 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 5 Sep 2014 02:24:07 +0200 Subject: [PATCH] =?UTF-8?q?Interpolation=20=C3=BCber=20drop-Outs=20mit=20e?= =?UTF-8?q?ingebaut.=20Nun=20erfolgreich?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sauSynKlick/SynKlick.cc | 72 +++++++++++++++++++++++++++++++++++----- sauSynKlick/SynKlick.txt | 12 ++++++- 2 files changed, 75 insertions(+), 9 deletions(-) diff --git a/sauSynKlick/SynKlick.cc b/sauSynKlick/SynKlick.cc index d9de76c..e1df326 100644 --- a/sauSynKlick/SynKlick.cc +++ b/sauSynKlick/SynKlick.cc @@ -153,6 +153,13 @@ class EventScore + +/** + * single sound channel with the ability to investigate itself. + * Internally holds a work buffer to be filled through libsndfile. + * The #visit function performs the decision logic to detect a defect + * at the "current" position, including the next neighbouring samples. + */ class Channel { SNDFILE *in_ = nullptr, @@ -267,6 +274,15 @@ class Channel event.recordNeutral(); } + /** if it ain't broken, don't fix it */ + bool + reallyNeedsFix() + { + float changeFactor = delta(workPos_) / (ema_ + EPSILON); + return changeFactor > 0.25 * TRIGGER_FACTOR; + } + + private: float sampleLevel() @@ -351,20 +367,44 @@ class Patch void reconstructMirroredSignal() { - for (uint i=0; i < LEN; ++i) + for (size_t i=0; i < LEN; ++i) workBuff[i] = rawBuff[LEN-1 - i]; } - - public: - Patch (Channel& c) - : rawBuff{c.accessCurrentContext()} + void + maybe_fix_Gap() { - reconstructMirroredSignal(); + const size_t CENTRE = CONTEXT; + size_t i = CENTRE-1; + while (i > 0 && 0.0f == workBuff[i]) --i; + if (i < CENTRE-1) + fix_Gap_by_Interpolation(i, CENTRE); + + i = CENTRE; + while (i < LEN-1 && 0.0f == workBuff[i]) ++i; + if (i > CENTRE) + fix_Gap_by_Interpolation(CENTRE-1, i); } void - apply() + fix_Gap_by_Interpolation(size_t s, size_t e) + { + assert (s+1 < e); + assert (0 <= s && s+1 < LEN); + assert (0 <= e && e < LEN); + + float before = workBuff[s]; + float after = workBuff[e]; + for (size_t i = s+1; i