---
name: "allocate_voice"
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/allocate_voice"
---

# allocate\_voice(3alleg)

Allocates a sound card voice for a sample. Allegro game programming library.

## NAME

allocate\_voice - Allocates a sound card voice for a sample. Allegro game programming library.

## SYNOPSIS

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

**int allocate\_voice(const SAMPLE \*spl);**

## DESCRIPTION

Allocates a sound card voice and prepares it for playing the specified  sample, setting up sensible default parameters (maximum volume, centre  pan, no change of pitch, no looping). When you are finished with the  voice you must free it by calling deallocate\_voice() or release\_voice(). Allegro can manage up to 256 simultaneous voices, but that limit may be lower due to hardware reasons.

## RETURN VALUE

Returns the voice number, or -1 if no voices are available.

## SEE ALSO

[**deallocate\_voice**(3alleg)](/deallocate_voice/3alleg.md), [**reallocate\_voice**(3alleg)](/reallocate_voice/3alleg.md), [**release\_voice**(3alleg)](/release_voice/3alleg.md), [**load\_sample**(3alleg)](/load_sample/3alleg.md)
