---
name: "SDL_ConvertAudioSamples"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_ConvertAudioSamples"
---

# SDL\_ConvertAudioSamples(3)

Convert some audio data of one format to another format.

## NAME

SDL\_ConvertAudioSamples - Convert some audio data of one format to another format.

## HEADER FILE

Defined in SDL3/SDL\_audio.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**bool SDL\_ConvertAudioSamples(const SDL\_AudioSpec \*src\_spec, const Uint8 \*src\_data, int src\_len, const SDL\_AudioSpec \*dst\_spec, Uint8 \*\*dst\_data, int \*dst\_len);**

## DESCRIPTION

Please note that this function is for convenience, but should not be used to resample audio in blocks, as it will introduce audio artifacts on the boundaries. You should only use this function if you are converting audio data in its entirety in one call. If you want to convert audio in smaller chunks, use an  **SDL\_AudioStream** , which is designed for this situation.

Internally, this function creates and destroys an

**SDL\_AudioStream**\
  on each use, so it's also less efficient than using one directly, if you need to convert multiple times.

## FUNCTION PARAMETERS

- *src\_spec*

  the format details of the input audio.

- *src\_data*

  the audio data to be converted.

- *src\_len*

  the len of src\_data.

- *dst\_spec*

  the format details of the output audio.

- *dst\_data*

  will be filled with a pointer to converted audio data, which should be freed with  **SDL\_free** (). On error, it will be NULL.

- *dst\_len*

  will be filled with the len of dst\_data.

## RETURN VALUE

Returns true on success or false on failure; call

**SDL\_GetError** () for more information.

## THREAD SAFETY

It is safe to call this function from any thread.

## AVAILABILITY

This function is available since SDL 3.2.0.
