# `ExCubecl.Audio`
[🔗](https://github.com/ohhi-vn/ex_cubecl/blob/v0.4.0/lib/ex_cubecl/audio.ex#L1)

Audio-specific GPU operations: mix, overlay, resample, channel conversion.

All operations run on GPU-resident sample buffers (f32 planar PCM).

## Examples

    result = ExCubecl.Audio.mix([track_a, track_b], gains: [0.7, 0.5])
    result = ExCubecl.Audio.overlay(bg, fg, duck_level: -12)
    resampled = ExCubecl.Audio.resample(samples, from: 44100, to: 48000)
    mono = ExCubecl.Audio.channels(samples, :stereo, :mono)

# `samples`

```elixir
@type samples() :: ExCubecl.AudioSamples.t()
```

# `channels`

```elixir
@spec channels(samples(), atom(), atom()) :: {:ok, samples()} | {:error, term()}
```

Converts between channel layouts (e.g. stereo → mono, mono → stereo).

## Examples

    mono = ExCubecl.Audio.channels(samples, :stereo, :mono)

# `mix`

```elixir
@spec mix(
  [samples()],
  keyword()
) :: {:ok, samples()} | {:error, term()}
```

Mixes multiple audio streams by summing with per-channel gain.

## Options

  * `:gains` — list of gain values (0.0–1.0+) corresponding to each track

# `overlay`

```elixir
@spec overlay(samples(), samples(), keyword()) :: {:ok, samples()} | {:error, term()}
```

Overlays foreground audio over background, optionally ducking the background.

## Options

  * `:duck_level` — dB reduction for background during foreground (default -12)

# `resample`

```elixir
@spec resample(
  samples(),
  keyword()
) :: {:ok, samples()} | {:error, term()}
```

Resamples audio to a different sample rate using GPU-accelerated linear interpolation.

## Options

  * `:from` — source sample rate (Hz)
  * `:to` — target sample rate (Hz)

---

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