# `TuningFork.Fx`
[🔗](https://github.com/jaman/tuning_fork/blob/v0.1.11/tuning_fork/lib/tuning_fork/fx.ex#L1)

Effects applied to a whole buffer of rendered audio.

    pcm
    |> Fx.echo(44_100, delay: 0.25, feedback: 0.45, mix: 0.3)
    |> Fx.reverb(44_100, room: 0.8, mix: 0.25)

# `apply`

```elixir
@spec apply(binary(), pos_integer(), keyword(), pos_integer()) :: binary()
```

Apply a list of effects in order.

`effects` is a keyword list of `{name, opts}`, where `name` is `:echo`, `:reverb` or
`:drive`, or any name `TuningFork.Fx.Live` runs — `:lowpass`, `:slicer`, `:compressor` and
the rest, with the options listed there; anything else raises `ArgumentError`. `channels`
is put into each effect's options where it did not name its own.

    Fx.apply(pcm, 44_100, [echo: [delay: 0.3], reverb: [room: 0.9]], 2)

# `drive`

```elixir
@spec drive(binary(), keyword()) :: binary()
```

Soft clipping through `tanh`, for weight rather than for distortion.

The result is the same length as `pcm`.

## Options

  * `:amount` — clamped to 0.0 to 1.0, default 0.3. Past about 0.5 it is audible as an
    effect rather than as the sound being louder

# `echo`

```elixir
@spec echo(binary(), pos_integer(), keyword()) :: binary()
```

Repeats, each quieter than the last.

The result is longer than `pcm` by however long the repeats take to fall below a hundredth
of full scale, up to 40 of them.

## Options

  * `:delay` — seconds between repeats, default 0.25
  * `:feedback` — how much of each repeat feeds the next, clamped to 0.0 to 0.95,
    default 0.4
  * `:mix` — how much of the result is echo, default 0.3
  * `:channels` — samples per frame, default 2

# `reverb`

```elixir
@spec reverb(binary(), pos_integer(), keyword()) :: binary()
```

A room around the sound.

Four comb filters at unrelated delays summed, then two allpass filters over the result —
the Schroeder arrangement. The result is longer than `pcm` by `0.5 + room * 2.0` seconds.

## Options

  * `:room` — how long it rings, clamped to 0.0 to 1.0, default 0.6
  * `:damp` — how much the repeats lose their top, clamped to 0.0 to 1.0, default 0.4
  * `:mix` — how much of the result is reverb, default 0.25
  * `:channels` — samples per frame, default 2

---

*Consult [api-reference.md](api-reference.md) for complete listing*
