---
name: "load_sample"
section: "3alleg"
platform: "linux"
package: "liballegro-doc"
version: "2:4.2.2-2.2"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/load_sample"
---

# load\_sample(3alleg)

Loads a sample from a file. Allegro game programming library.

## NAME

load\_sample - Loads a sample from a file. Allegro game programming library.

## SYNOPSIS

**#include \<allegro.h\>**

**SAMPLE \*load\_sample(const char \*filename);**

## DESCRIPTION

Loads a sample from a file, supporting both mono and stereo WAV and mono VOC files, in 8 or 16-bit formats, as well as formats handled by functions registered using register\_sample\_file\_type(). Example:

```
   SAMPLE *sample = load_sample(user_input);
   if (!sample)
      abort_on_error("Couldn't load sample!");
```

## RETURN VALUE

Returns a pointer to the SAMPLE or NULL on error. Remember to free this sample later to avoid memory leaks.

## SEE ALSO

[**destroy\_sample**(3alleg)](/destroy_sample/3alleg.md), [**load\_voc**(3alleg)](/load_voc/3alleg.md), [**load\_wav**(3alleg)](/load_wav/3alleg.md), [**play\_sample**(3alleg)](/play_sample/3alleg.md), [**save\_sample**(3alleg)](/save_sample/3alleg.md), [**register\_sample\_file\_type**(3alleg)](/register_sample_file_type/3alleg.md), [**exsample**(3alleg)](/exsample/3alleg.md)
