> ## Documentation Index
> Fetch the complete documentation index at: https://pkhambat.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# play

> The statement that renders a value to audio.

`play` evaluates what follows it and renders one output. It is the only statement that makes sound, and it goes at the top level of a cell.

```text theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/composer-nb.json"]}}
play <pattern, group, block or line> [for <number> bars]
```

```composer-nb theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/composer-nb.json"]}}
pattern groove = {
  kick: x---
  snare: ----x---
}

play groove
play piano: chords Am F for 2 bars
play {
  crash: 1
  groove
} for 4 bars
```

This cell renders three outputs.

## What repeats

A play is a timeline, and its statements start together.

| In a play | Plays |
| - | - |
| A line | Once. |
| A named block | Once, with silence after it if the play runs longer. |
| A pattern, or a group in brackets | Repeated until the play ends. A group plays what's in it in order. |
| `every` | Repeated until the play ends. |
| `bar <n>` | In bar `n`. |

## Duration

Write `play groove for 2 bars` to set the whole output’s duration. The duration follows the music; `play 2 bars groove` is rejected.

Without a duration, a play lasts as long as its longest statement, and what repeats must fit that a whole number of times. With a length, it lasts exactly that long: whatever is repeating stops at the end, and silence fills any time left over. A play can't run past 10 minutes.

## Output

* A header with the time, tempo, key, number of bars and the instruments that play.
* Audio, with a waveform to follow and seek.
* A grid of every hit and note, bar by bar. The playground can draw it as sheet music instead: the kit on a percussion staff with hands up and feet down, each instrument on a staff of its own (a guitar with its tab) in the signature of the [`key`](https://pkhambat.mintlify.site/pitched/key), and the sheet prints.
* The chords played. The playground draws a diagram for each.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.