# Curve

> A drawn breakpoint curve on a control lane: shape the input or Position through it, or loop it at a rate, mapped onto Min to Max.

Source: https://docs.tune.toys/nodes/ctl.curve/

Curve is a shape you draw: points joined by straight or bent segments, read as a control lane. It can bend another control signal through the shape, or play the shape on its own as a repeating sweep.

## What it does

The curve lives in the node's `points` data: 2 to 32 points, each an x and a y between 0 and 1, plus a curvature between −1 and 1 for the segment to its right. Before the first point and after the last the curve holds flat; two points at the same x make a step. A curvature of 0 is a straight line, positive values start slow and finish fast, and negative values start fast and finish slow, using the same bend as [Envelope](https://docs.tune.toys/nodes/std.envelope/). A node without points plays a straight line from (0, 0) to (1, 1).

In Shaper mode the curve is read at the control input, clamped to 0 to 1, or at Position when nothing is cabled. In Cycle mode it sweeps from 0 to 1 at Rate and starts again. Either way the curve's 0 to 1 is mapped onto Min to Max. Control runs once per audio block, so the curve is read once per block.

### Drawing the curve

On the node card, drag a point to move it; it stays between its neighbours. Double-click empty space to add a point on the curve without changing its shape. With a point focused, the arrow keys move it (Shift for fine steps), Tab moves to the next point, Backspace or Delete removes it (the first and last points stay), and the mouse wheel or Page Up and Page Down bend the segment to its right. Escape during a drag restores the curve. The change plays while you draw, and each drag or key press is one edit, so one Undo reverts it.

### Events

The `cycle` outlet is 1 for one block whenever a Cycle sweep starts again, and 0 otherwise, including in Shaper mode. The first block does not count. A sweep shorter than a block still reports one pulse per block, never more. Cable it into a trigger input, such as [Counter](https://docs.tune.toys/nodes/ctl.counter/), to count repeats.

## When to use it

Use it when a straight range is not enough: a filter that opens slowly and then quickly, a volume that holds and drops, a stepped pattern. Put it after a [Control LFO](https://docs.tune.toys/nodes/ctl.lfo/) or a sensor to reshape its motion, or use Cycle mode as a drawn LFO. For a plain range change with one bend, [Scale](https://docs.tune.toys/nodes/ctl.scale/) is simpler.

## Ports

<!-- ports:start -->

| Port      | Direction | Signal  | Lanes |
| --------- | --------- | ------- | ----- |
| `control` | Input     | Control | 1     |
| `control` | Output    | Control | 1     |
| `cycle`   | Output    | Control | 1     |

<!-- ports:end -->

## Parameters

<!-- parameters:start -->

| Parameter  | Label    | Range      | Default | Unit | Scale  | Notes                                                                                                                                                   |
| ---------- | -------- | ---------- | ------- | ---- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `mode`     | Mode     | 0 to 1     | 0       |      | linear | Shaper reads the curve at the input, or at Position when nothing is cabled; Cycle sweeps it from 0 to 1 at Rate, repeating. Choices: 0 Shaper, 1 Cycle. |
| `position` | Position | 0 to 1     | 0       |      | linear | Where Shaper mode reads the curve while the control input is not cabled. Shown when `mode` is 0.                                                        |
| `rate_hz`  | Rate     | 0.01 to 20 | 1       | Hz   | log    | Sweeps across the curve per second in Cycle mode. Shown when `mode` is 1.                                                                               |
| `min`      | Min      | -8 to 8    | 0       |      | linear | Output where the curve is at the bottom of its box.                                                                                                     |
| `max`      | Max      | -8 to 8    | 1       |      | linear | Output where the curve is at the top of its box. Below Min inverts the curve.                                                                           |

<!-- parameters:end -->

<!-- data:start -->

- `points`: floats.

<!-- data:end -->

### Mode (`mode`)

Shaper or Cycle. A discrete choice. Shaper reads the curve at its input; Cycle plays it as a repeating sweep and ignores the input.

### Position (`position`)

Where Shaper mode reads the curve, 0 to 1, while the control input is not cabled. Turn it by hand to scan the shape. Hidden in Cycle mode.

### Rate (`rate_hz`)

Sweeps per second in Cycle mode, 0.01 to 20 Hz on a logarithmic control. The sweep pauses where it is while the mode is Shaper. Hidden in Shaper mode.

### Min (`min`)

The output where the curve is at the bottom of its box, −8 to 8.

### Max (`max`)

The output where the curve is at the top of its box, −8 to 8. Set it below Min to turn the curve upside down.

## Tips

- Leave Min at 0 and Max at 1 when the curve drives a parameter cable: the cable maps 0 to 1 across the parameter's whole range.
- A falling curve in Cycle mode, from 1 down to 0, makes a drawn decay that repeats at Rate.
- Add a point in the middle of a bent segment before reshaping it: the curve does not move until you drag.

## See also

[Control LFO](https://docs.tune.toys/nodes/ctl.lfo/), [Scale](https://docs.tune.toys/nodes/ctl.scale/), [Envelope](https://docs.tune.toys/nodes/std.envelope/), [Cables](https://docs.tune.toys/concepts/cables/).
