---
title: Modulation and automation
order: 3
summary: Curves and LFOs that move a sound's volume, position, filter or pitch while it plays, and the volume and position of a track on a timeline.
---

<!-- Generated by tools/generate-docs.bxs from the BIF classes. Do not edit; change the Javadoc and run it again. -->

Curves and LFOs that move a sound's volume, position, filter or pitch while it plays, and the volume and position of a track on a timeline.

## audioLfo

Makes a low frequency oscillator: a value that swings between center - depth and center + depth, a number of times a second. On its own it is only a curve; give it to audioModulate() to make tremolo (the volume swings), auto pan, a wah (the filter cutoff swings) or vibrato (the pitch swings), or to audioAutomate() to move a track's volume or balance. audioCurveAt() reads its value at a time.

```js
audioLfo( shape="sine", rate=1, depth=1, center=0, phase=0, fadeIn=0, seed=0 )
```

| Argument | Type | Default | |
|---|---|---|---|
| `shape` | string | `"sine"` | sine, triangle, saw (a ramp up that jumps back), square or random (a new random value each cycle, held). Every shape starts at the center, and a square starts high. Defaults to sine. |
| `rate` | double | `1` | Cycles per second, above 0 and at most 1000. Defaults to 1. |
| `depth` | double | `1` | How far it swings from the center, in the unit of what it controls: dB for gainDb, -1 to 1 for pan, Hz for cutoff, semitones for pitch. Defaults to 1. |
| `center` | double | `0` | The value it swings around. Defaults to 0. |
| `phase` | double | `0` | Where in the cycle it starts, 0 to 1. Defaults to 0. |
| `fadeIn` | double | `0` | Seconds for the swing to grow from nothing to its full depth, as a player brings in vibrato. Defaults to 0, no fade. |
| `seed` | long | `0` | For the random shape: the same seed gives the same values. Defaults to 0. |

**Returns** A curve.

## audioCurve

Makes a value that moves from point to point over time: a fade of any shape, a filter sweep, a glide. Before the first point the curve has the first value and after the last it keeps the last. Give it to audioModulate() to change a sound, or to audioAutomate() to change a timeline track.

```js
audioCurve( points, interpolation="linear" )
```

| Argument | Type | Default | |
|---|---|---|---|
| `points` | array | required | An array of structs with at (seconds, 0 or more; time works too) and value, in any order, at different times. The unit of the value is that of what it controls: dB for gainDb, -1 to 1 for pan, Hz for cutoff, semitones for pitch. |
| `interpolation` | string | `"linear"` | How it moves between points: linear (straight lines), smooth (an eased curve) or step (holds each value until the next point). Defaults to linear. |

**Returns** A curve.

## audioCurveAt

Reads the value of a curve from audioCurve() or an LFO from audioLfo() at a time. It is how a script finds out what a modulation will do, to draw it, to check it, or to use the same movement for something else.

```js
audioCurveAt( curve, seconds )
```

| Argument | Type | Default | |
|---|---|---|---|
| `curve` | any | required | The curve or LFO. |
| `seconds` | double | required | The time, 0 or more. |

**Returns** The value at that time.

## audioModulate

Changes a sound while it plays. One parameter of the sound follows a curve from audioLfo() or audioCurve(), at the time of the sound (the curve at 2 seconds is what the sound does 2 seconds in). <ul> <li><b>gainDb</b>: the curve is the gain in dB. An LFO centered on -6 with a depth of 6 is tremolo, a line from -60 to 0 is a fade in.</li> <li><b>pan</b>: the curve is the position, -1 left to 1 right. An LFO is auto pan. A mono sound becomes stereo.</li> <li><b>cutoff</b>: the curve is the cutoff of a filter in Hz, a wah or a filter sweep. Choose the filter and its resonance.</li> <li><b>pitch</b>: the curve is the pitch in semitones, like a tape or a record, so a curve that swings around 0 is vibrato. A curve that is above 0 for a while makes the sound shorter, and below 0 longer.</li> </ul>

```js
audioModulate( audio, param, curve, filter="lowpass", q=0.7071 )
```

| Argument | Type | Default | |
|---|---|---|---|
| `audio` | any | required | The audio buffer. |
| `param` | string | required | gainDb, pan, cutoff or pitch. |
| `curve` | any | required | A curve from audioCurve() or an LFO from audioLfo(). |
| `filter` | string | `"lowpass"` | For cutoff: lowpass, highpass, bandpass or notch. Defaults to lowpass. |
| `q` | double | `0.7071` | For cutoff: the resonance. 0.7071 is flat, higher peaks at the cutoff. Defaults to 0.7071. |

**Returns** A new audio buffer.

## audioAutomate

Moves a track's volume or balance over the time of the timeline, as the fader of a mixing desk is moved during a mix: a swell, a fade out, a sound that travels from left to right. The movement is applied when the timeline is rendered, on top of the track gain and the ducks. A second call for the same parameter of the same track replaces the first.

```js
audioAutomate( timeline, track, param, curve )
```

| Argument | Type | Default | |
|---|---|---|---|
| `timeline` | any | required | The timeline from audioTimeline(). |
| `track` | string | required | The track. It is made when it does not exist yet. |
| `param` | string | required | gainDb (the curve is the gain in dB) or pan (the curve is the position, -1 left to 1 right, applied as a balance control on a stereo timeline). |
| `curve` | any | required | A curve from audioCurve() or an LFO from audioLfo(), in seconds of the timeline. |

**Returns** The same timeline, so calls can be chained.

