> ## 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.

# Settings

> set and with, and the settings every line shares: time, tempo and swing.

A setting is `set`, then the setting and its value: `set tempo 90`. It applies from its line to the end of the cell, and carries into later cells. `set` goes only at the top of a cell, outside every block. Inside a block, settings go on a [`with`](#with), which gives them to its own block and nothing else.

| Setting | Value | Default | Sets |
| - | - | - | - |
| `time` | `<count> over <unit>` | `4 over 4` | The time signature. |
| `tempo` | 20 to 400 | `120` | Quarter notes per minute. |
| `swing` | `on` or `off` | `off` | Whether the eighths swing. |

These three apply to every line. The drums and the pitched instruments each have settings of their own, set the same way: [`kit`](https://pkhambat.mintlify.site/drums/kit#kit) for the drums, and [`key` and `mode`](https://pkhambat.mintlify.site/pitched/key), [`octave`](https://pkhambat.mintlify.site/pitched/instruments#octave), [`transpose`](https://pkhambat.mintlify.site/pitched/instruments#transpose) and [an instrument's sound](https://pkhambat.mintlify.site/pitched/instruments.md#sound) for the pitched instruments.

## time

The unit is the note value counted: 1, 2, 4, 8 or 16. The count can be a sum, as in `set time 3+4 over 8`, which groups the grid without changing the bar. `over` is required because `/` is division: `7/8` is the number 0.875.

## swing

`set swing on` swings the eighths, as a part marked *Swing* is played: the off-beat eighth falls two thirds of the way through the beat, where a triplet's third note would, and sixteenths move with the eighth they belong to. It is off unless it's set, and `set swing off` turns it off again. Only the sound moves: the grid stays as written, and the sheet says *Swing* above the first staff.

```composer-nb theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/composer-nb.json"]}}
set swing on
set tempo 100

play {
  ride: 1 bars x-
  hat.pedal: 2 4
  kick: 1 3
}
```

## with

`with`, then settings with commas between them, then a block: `with key E, mode minor { ... }`. The settings apply to the block only, and what was set before comes back at its `}`. A `with` takes any setting `set` takes, each once, and at least one. Names declared inside a `with` stay inside it, as names in any block do, and nothing in it carries into later cells.

A `with`'s block holds what could stand where the `with` is:

| Where | The block holds | Plays |
| - | - | - |
| At the top of a cell | Statements: declarations, `play` and other `with`s. | Each `play` in it, with the settings. |
| In a `play`, a pattern, `bar` or `every` | Lines, groups, `bar`, `every` and other `with`s. | As a block on a line of its own: together with the other lines, repeating until what it's in ends. |
| In a [group](https://pkhambat.mintlify.site/language/patterns.md#groups) | The same. | As one part in order. |

An instrument's block of layers and a named value hold values, not lines, so a `with` goes around the line instead: `with octave 5 { piano: { ... } }`.

```composer-nb theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/composer-nb.json"]}}
set tempo 96
chords walk = i ii|iii iv|v vi|vii i

with key E, mode minor {
  play {
    piano: chords walk
    with octave 2 { bass: notes i---v--- }
  }
}

chords prog = i vi|iv v
play (
  with key E { piano: chords prog }
  with key G { piano: chords prog }
)
```

The chart walks through every chord of E minor, and the bass plays an octave below it, its figure repeating under each chord. A pattern is evaluated where it is played, so `prog` plays in E and then in G.

`time`, `tempo` and `swing` go on a `with` around a whole play, or on a part that plays in order. Lines that sound together share one moment, and so one tempo: a `with tempo` beside other lines in a play or a pattern is an error, and so is a pattern that changes the tempo played with other lines. A `with` that holds everything a pattern plays can set its tempo, and the pattern then plays at it wherever it plays in order: `pattern tag = with time 6 over 4 { ... }`.

```composer-nb theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/composer-nb.json"]}}
pattern beat = {
  hat: x-
  kick: 1 3
  snare: 2 4
}

play (
  with tempo 90 { 2 bars beat }
  with tempo 120 { 2 bars beat }
)
```


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