music.stepped

music.stepped(thresholds, otherwise=0.0)[source]

A bond that changes in steps rather than continuously.

Takes the value of the first threshold the frequency is below, which is how a register-dependent decision is usually written: one thing below middle C, another above it.

Parameters:
thresholdssequence of (scalar, scalar)

(below, value) pairs, tried in the order given.

otherwisescalar

The value for a frequency above every threshold.

Returns:
callable()

A function of one frequency, for Bonds.

Parameters:
Return type:

Callable[[float], float]

Examples

>>> register = stepped([(262, 3.0), (523, 6.0)], otherwise=12.0)
>>> register(220), register(440), register(880)
(3.0, 6.0, 12.0)