diff --git a/docs/modules/ROOT/images/dynamic_smoother.svg b/docs/modules/ROOT/images/dynamic_smoother.svg new file mode 100644 index 00000000..dffedb8a --- /dev/null +++ b/docs/modules/ROOT/images/dynamic_smoother.svg @@ -0,0 +1,1374 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/modules/ROOT/images/dynamic_smoother_input.svg b/docs/modules/ROOT/images/dynamic_smoother_input.svg new file mode 100644 index 00000000..302bb43f --- /dev/null +++ b/docs/modules/ROOT/images/dynamic_smoother_input.svg @@ -0,0 +1,303 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/modules/ROOT/pages/reference/misc/dynamic_smoother.adoc b/docs/modules/ROOT/pages/reference/misc/dynamic_smoother.adoc index 638d4b99..9bb57f32 100644 --- a/docs/modules/ROOT/pages/reference/misc/dynamic_smoother.adoc +++ b/docs/modules/ROOT/pages/reference/misc/dynamic_smoother.adoc @@ -6,6 +6,16 @@ include::../../common.adoc[] The `dynamic_smoother` class is based on link:https://cytomic.com/files/dsp/DynamicSmoothing.pdf[Dynamic Smoothing Using Self Modulating Filter] (© Andrew Simper, Cytomic, 2014, andy@cytomic.com), a robust and inexpensive dynamic smoothing algorithm based on using the bandpass output of a 2-pole multimode filter to modulate its own cutoff frequency. The bandpass signal dynamically adjusts the cutoff frequency to provide faster tracking when the input signal changes significantly. It is ideal for de-noising and smoothing operations, such as for analog potentiometers or MIDI controllers, but is also useful in cleaning up audio signals for analytical processes such as pitch detection. +== Response + +image::dynamic_smoother_input.svg[alt="Dynamic Smooother Input", title="Dynamic smooother input", width="750px" align=center, link={imagesdir}/dynamic_smoother_input.svg] + +image::dynamic_smoother.svg[alt="Dynamic Smooother", title="Dynamic smooother response", width="750px" align=center, link={imagesdir}/dynamic_smoother.svg] + +The blue trace (Figure 1) is the original signal, the orange trace (Figure 2) is the signal processed by the dynamic smoother with a base cutoff freqeuency at twice the fundamental frequency of the signal, and for comparison, the green trace (Figure 2) is the signal processed by a one-pole lowpass filter using the same cutoff frequency. + +Notice that, compared to the one-pole lowpass filter, the dynamic smoother responds more quickly to rapid changes in the input signal, such as sharp peaks. But for slower changes, such as the signal near the center, the dynamic smoother and the one-pole lowpass filter have similar outputs. + == Include ```c++ diff --git a/test/dynamic_smoother.cpp b/test/dynamic_smoother.cpp index e889682d..9c3bf619 100755 --- a/test/dynamic_smoother.cpp +++ b/test/dynamic_smoother.cpp @@ -18,21 +18,24 @@ void process( std::string name, std::vector const& in , float sps, q::frequency f) { - constexpr auto n_channels = 2; + constexpr auto n_channels = 3; std::vector out(in.size() * n_channels); - auto ds = q::dynamic_smoother{f*2, 0.1, sps}; + auto ds = q::dynamic_smoother{f*4, 0.9, sps}; + auto lp = q::one_pole_lowpass{f*4, sps}; for (auto i = 0; i != in.size(); ++i) { auto pos = i * n_channels; auto ch1 = pos; auto ch2 = pos+1; + auto ch3 = pos+2; auto s = in[i]; out[ch1] = s; out[ch2] = ds(s); + out[ch3] = lp(s); } ////////////////////////////////////////////////////////////////////////////