---
title: "Add Audio Tracks to Video | Rendley SDK Docs"
description: "Add audio clips to the timeline with trimming, playback speed, pitch preservation and volume fades. Mix background music, voiceovers and sound effects."
url: https://docs.rendley.com/sdk/getting-started/clips/audio/
---

# Audio clips

The [AudioClip](https://docs.rendley.com/sdk/api-reference/classes/AudioClip.html) plays an audio file on the timeline. It supports trimming, playback speed, pitch preservation, and volume fades.

## Create an audio clip

The duration is inferred from the media data.

```
const mediaId = await Engine.getInstance()
  .getLibrary()
  .addMedia("https://example.com/voiceover.mp3");

await layer.addClip({
  mediaDataId: mediaId,
  startTime: 0,
});
```

List of Supported Formats

| Format | Support |
| --- | --- |
| MP3 | ✅ |
| M4A | ✅ |
| OGG | ✅ |
| WAV | ✅ |
| AAC | ✅ |

## Volume and mute

```
audioClip.setVolume(0.5);
audioClip.setMuted(true);
```

## Adding background music

Background music is just an audio clip on its own layer, trimmed to the composition length and faded in / out so it doesn’t start or end abruptly. A typical setup:

```
const musicMediaId = await Engine.getInstance()
  .getLibrary()
  .addMedia("https://example.com/song.mp3");

const musicLayer = Engine.getInstance().getTimeline().createLayer();
const music = await musicLayer.addClip({
  mediaDataId: musicMediaId,
  startTime: 0,
});

// Trim the music to the composition length.
const duration = Engine.getInstance().getTimeline().getFitDuration();
music.setRightTrim(Math.max(0, music.getDuration() - duration));

// Keep the music quieter than dialogue.
music.setVolume(0.3);

// Smooth fade-in and fade-out at the boundaries.
music.setVolumeFadeInDuration(1.0);
music.setVolumeFadeOutDuration(2.0);
```

If the music is longer than the composition, `setRightTrim` cuts the tail. If it’s shorter, duplicate the clip on the same layer to extend playback, or use a single long track.

## Playback speed and fades

Speed, pitch, and fade in/out are covered on the [Playback Speed & Fades](https://docs.rendley.com/sdk/getting-started/playback-speed/) page.

## Waveform samples

If you enable [`clipAudioStoreSamples`](https://docs.rendley.com/sdk/getting-started/settings/#audio-samples) in the Settings before adding the media, the SDK extracts normalized `Float32Array` samples you can use to draw a waveform or drive custom clips.

```
const samples = audioClip.getAudioSamples(0); // start at 0, full duration
```

See [Filmstrip & Waveforms](https://docs.rendley.com/sdk/getting-started/filmstrip/) for the full workflow.

## What to read next

- **[Video clips](https://docs.rendley.com/sdk/getting-started/clips/video/)** trim, split and place footage on a layer.
- **[Playback speed](https://docs.rendley.com/sdk/getting-started/playback-speed/)** retimes a clip and fades its audio.
- **[Filmstrips and waveforms](https://docs.rendley.com/sdk/getting-started/filmstrip/)** draws thumbnails and audio peaks for a timeline UI.
- API reference: [`AudioClip`](https://docs.rendley.com/sdk/api-reference/classes/AudioClip.html).

[Previous pageVideo clips](https://docs.rendley.com/sdk/getting-started/clips/video/) [Next pageImage clips](https://docs.rendley.com/sdk/getting-started/clips/image/)
