diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index 67a442dd..fae26124 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -45,6 +45,7 @@ *** xref:reference/misc/onset_gate.adoc[Onset Gate] *** xref:reference/misc/one_pole_lowpass.adoc[One Pole Low Pass] *** xref:reference/misc/dc_block.adoc[DC Block] +*** xref:reference/misc/dynamic_smoother.adoc[Dynamic Smoother] ** xref:reference/synth.adoc[Synthesizers] *** xref:reference/synth/sin_osc.adoc[Sine Wave Oscillator] diff --git a/docs/modules/ROOT/pages/reference/misc/dynamic_smoother.adoc b/docs/modules/ROOT/pages/reference/misc/dynamic_smoother.adoc new file mode 100644 index 00000000..23e4fa9a --- /dev/null +++ b/docs/modules/ROOT/pages/reference/misc/dynamic_smoother.adoc @@ -0,0 +1,83 @@ += Dynamic Smoother + +include::../../common.adoc[] + +== Overview + +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. + +in preparation for analysis. + +== Include + +```c++ +#include +``` + +== Declaration + +```c++ + struct dynamic_smoother + { + dynamic_smoother( + frequency base + , float sps + ); + + dynamic_smoother( + frequency base + , float sensitivity + , float sps + ); + + float operator()(float s); + void base_frequency(frequency base, float sps); + }; +``` + +== Expressions + +=== Notation + +`ds`, `a`, `b` :: Objects of type `dynamic_smoother`. +`f` :: Object of type `frequency` representing the base cutoff frequency. +`sps` :: Floating point value representing samples per second. +`sens` :: Floating point value representing sensitivity. +`s` :: Input sample. + +=== Constructors and Assignment + +[cols="1,1"] +|=== +| Expression | Semantics + +| `dynamic_smoother(f, sens, sps)` | Construct a `dynamic_smoother` with specified base + cutoff frequency, `f`, sensitivity, `sens`, and + samples per second, `sps`. +| `dynamic_smoother(f, sps)` | Construct a `dynamic_smoother` with specified base + cutoff frequency, `f`, and samples per second, `sps`. + In this case, the sensitivity is set to 0.5. +| `dynamic_smoother(b)` | Copy construct a `dynamic_smoother` from `b`. +| `a = b` | Assign `b` to `a`. +|=== + +NOTE: C++ brace initialization may also be used. + +[cols="1,1,1"] +|=== +| Expression | Semantics | Return Type + +| `ds(s)` | Process the input sample, `s`. | `float` +|=== + +=== Mutators + +[cols="1,1,1"] +|=== +| Expression | Semantics | Return Type + +| `ds.base_frequency(f, sps)` | Set the base cutoff frequency given + `frequency f`, and samples per second + `sps`. | `void` +|=== + diff --git a/docs/modules/ROOT/pages/reference/misc/one_pole_lowpass.adoc b/docs/modules/ROOT/pages/reference/misc/one_pole_lowpass.adoc index 266307db..91317285 100644 --- a/docs/modules/ROOT/pages/reference/misc/one_pole_lowpass.adoc +++ b/docs/modules/ROOT/pages/reference/misc/one_pole_lowpass.adoc @@ -42,7 +42,7 @@ struct one_pole_lowpass | Expression | Semantics | `one_pole_lowpass(f, sps)` | Construct a `one_pole_lowpass` with specified - cutoff frequency, `f`, and samples per second `sps`. + cutoff frequency, `f`, and samples per second, `sps`. | `one_pole_lowpass(b)` | Copy construct a `one_pole_lowpass` from `b`. | `a = b` | Assign `b` to `a`. | `a = s` | Set the latest result to `s`. @@ -55,7 +55,7 @@ NOTE: C++ brace initialization may also be used. | Expression | Semantics | Return Type | `lp()` | Return the latest result. | `float` -| `lp(s)` | process the input sample, `s`. | `float` +| `lp(s)` | Process the input sample, `s`. | `float` |=== === Mutators diff --git a/q_lib/include/q/fx/lowpass.hpp b/q_lib/include/q/fx/lowpass.hpp index 06d6269a..56549425 100755 --- a/q_lib/include/q/fx/lowpass.hpp +++ b/q_lib/include/q/fx/lowpass.hpp @@ -204,18 +204,17 @@ namespace cycfi::q //////////////////////////////////////////////////////////////////////////// // dynamic_smoother based on Dynamic Smoothing Using Self Modulating Filter - // by Andrew Simper, Cytomic, 2014, andy@cytomic.com + // by Andrew Simper, Cytomic, 2016, andy@cytomic.com // // https://cytomic.com/files/dsp/DynamicSmoothing.pdf // // 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 is a meaure of how much the signal is - // "changing" so is useful to increase the cutoff frequency dynamically - // and allow for faster tracking when the input signal is changing more. - // The absolute value of the bandpass signal is used since either a change - // upwards or downwards should increase the cutoff. - // + // bandpass output of a 2-pole multimode filter to modulate its own cutoff + // frequency. The bandpass signal measures how much the signal is + // "changing," making it useful for dynamically increasing the cutoff + // frequency and allowing for faster tracking when the input signal + // changes more. The absolute value of the bandpass signal is used since + // either an upward or downward change should increase the cutoff. //////////////////////////////////////////////////////////////////////////// struct dynamic_smoother {