TuningFork.Curve (TuningFork v0.1.11)

Copy Markdown View Source

A multiplier that moves over the length of a note, as {progress, value} breakpoints.

Curve.new([{0.0, 1.0}, {0.5, 1.5}, {1.0, 1.0}])

Summary

Functions

The value at progress, 0.0 at the start of a note and 1.0 at its end.

Whether a curve holds one value throughout. True of nil and of a single-point curve.

A curve that stays at value throughout. flat?/1 is true of it.

A curve going straight from from at progress 0.0 to to at progress 1.0.

A curve from {progress, value} pairs, sorted by progress.

Thin a curve down to at most count breakpoints, keeping its shape.

Types

point()

@type point() :: {float(), float()}

t()

@type t() :: [point()]

Functions

at(points, progress)

@spec at(t(), float()) :: float()

The value at progress, 0.0 at the start of a note and 1.0 at its end.

Interpolated in a straight line between breakpoints; before the first breakpoint and after the last it is that breakpoint's value.

flat?(arg1)

@spec flat?(t() | nil) :: boolean()

Whether a curve holds one value throughout. True of nil and of a single-point curve.

hold(value)

@spec hold(number()) :: t()

A curve that stays at value throughout. flat?/1 is true of it.

linear(from, to)

@spec linear(number(), number()) :: t()

A curve going straight from from at progress 0.0 to to at progress 1.0.

new(points)

@spec new([{number(), number()}]) :: t()

A curve from {progress, value} pairs, sorted by progress.

Progress runs 0.0 at the start of a note to 1.0 at its end; value is a multiplier over the field the curve is attached to. Both members of each pair are converted to floats. Raises ArgumentError on an empty list. Points outside 0.0 to 1.0 are kept rather than dropped or clamped.

simplify(points, count)

@spec simplify(t(), pos_integer()) :: t()

Thin a curve down to at most count breakpoints, keeping its shape.

The first and last points are always kept. A curve already at or under count points is returned unchanged. Raises ArgumentError when count is under 2.