add

wayland/running-median/add

Adds a new value to the sample buffer. If the buffer is already full the new value replaces the oldest element.
add
@/add
Adds a new value to the sample buffer. If the buffer is already full the new value replaces the oldest element.
Buffer@/sample-buffer
Sample buffer.
Newnumber
New value to be stored in buffer.
UPDpulse
Update. Push new value into sample buffer.
add
Buffer
New
UPD
Done
Donepulse
Pulses when a new value is stored in the sample buffer.
To use the node in your project you should have the wayland/running-median library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_UPD

node {
    void evaluate(Context ctx) {
        if (isInputDirty<input_UPD>(ctx)) {
            auto samples = getValue<input_Buffer>(ctx);
            float newValue = getValue<input_New>(ctx);
            samples -> add(newValue);
            emitValue<output_Done>(ctx, 1);
        }
    }
}