Dejitter:
Filter:
Classes (extension) | Utilities

Dejitter : Object
ExtensionExtension

remove jitter from unstable control sources
Source: Dejitter.sc

Description

Dejitter is useful for calming controls with some jitter, e.g. a joystick that toggles between two adjacent values. It will reduce control traffic, because its function will only be run when the incoming value changes are outside the current jitter range. More precisely, jitter range is a moving window of [hi, lo] within which changes are handled as follows: when the incoming value is within the current range window nothing happens; when the incoming value goes above hi, value and hi are set to incoming, func runs, and lo is pulled up to (hi - width), i.e. the range window is dragged up. The same happens conversely when value goes below lo. This way, values leading in one direction drag the range window along with full sensitivity; after a change of direction, the window has to be traversed before changes are passed on and dragging sets in again. Therefore, one should keep the width just above the average jitter to avoid "dead" zones on every direction change.

Class Methods

Dejitter.new(width: 0.02, func, value)

create a new Dejitter

Arguments:

width

the width within which to filter jitter

func

the func to run when filtered value has changed

value

an initial value

Inherited class methods

Instance Methods

.value

the current value

.func

.func = value

the func to run when filtered value has changed

.width

.width = value

the width of the moving range window

.set(val)

the method to set a new (jittery) value

.lo

.hi

the current lo and hi values of the moving range window

Inherited instance methods