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

# midi\_seek(3alleg)

Seeks to the given midi\_pos in the current MIDI file. Allegro game programming library.

## NAME

midi\_seek - Seeks to the given midi\_pos in the current MIDI file. Allegro game programming library.

## SYNOPSIS

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

**int midi\_seek(int target);**

## DESCRIPTION

Seeks to the given midi\_pos in the current MIDI file. If the target is  earlier in the file than the current midi\_pos it seeks from the  beginning; otherwise it seeks from the current position.

## RETURN VALUE

Returns zero if it could successfully seek to the requested position. Otherwise, a return value of 1 means it stopped playing, and midi\_pos is set to the negative length of the MIDI file (so you can use this function to determine the length of a MIDI file). A return value of 2 means the MIDI file looped back to the start.

## SEE ALSO

[**play\_midi**(3alleg)](/play_midi/3alleg.md), [**midi\_pos**(3alleg)](/midi_pos/3alleg.md)
