---
name: "play_midi"
section: "3alleg4"
platform: "linux"
package: "allegro4-doc"
version: "2:4.4.3.1-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/play_midi/3alleg4"
---

# play\_midi(3alleg4)

Starts playing the specified MIDI file. Allegro game programming library.

## NAME

play\_midi - Starts playing the specified MIDI file. Allegro game programming library.

## SYNOPSIS

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

**int play\_midi(MIDI \*midi, int loop);**

## DESCRIPTION

Starts playing the specified MIDI file, first stopping whatever music was  previously playing. If the loop flag is set to non-zero, the data will be repeated until replaced with something else, otherwise it will stop at the end of the file. Passing a NULL pointer will stop whatever music is currently playing.

## RETURN VALUE

Returns non-zero if an error occurs (this may happen if a patch-caching wavetable driver is unable to load the required samples, or at least it might in the future when somebody writes some patch-caching wavetable drivers :-)

## SEE ALSO

**install\_sound**(3alleg4), **load\_midi**(3alleg4), **play\_looped\_midi**(3alleg4), **stop\_midi**(3alleg4), **midi\_pause**(3alleg4), **midi\_seek**(3alleg4), **midi\_pos**(3alleg4), **midi\_time**(3alleg4), **midi\_msg\_callback**(3alleg4), **exmidi**(3alleg4)
