DECPS — Play Sound (`CSI Pv ; Pd ; Pn1 [; …] , ~`)
DEC VT520 musical-tone playback — `Pv` volume, `Pd` duration, then one or more `Pn` MIDI-style note numbers. Niche but implemented by xterm, WezTerm, Ghostty, mlterm; the only ANSI way to make the terminal beep at a specific pitch.
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\x1b[<Pv>;<Pd>;<Pn1>[;<Pn2>…],~\033[5;8;33,~\e[5;8;33,~ESC [ Pv ; Pd ; Pn1 [; …] , ~1b 5b ... 2c 7eDescription
DECPS — *Play Sound* — was added in the DEC VT520 to play one or more tones through the terminal's beeper. Xterm and several modern emulators (WezTerm, Ghostty, mlterm) implement it; for everyone else it's a silent no-op (which is usually the desired fallback — accessibility-conscious users disable terminal sound anyway). **Parameters**: - `Pv` — volume (0 = off, 1–3 = low, 4–7 = high). Most emulators map to a binary 'play / silent' since their underlying audio API has no volume control here. - `Pd` — duration in 1/32-of-a-second units; `8` = 0.25s. Range 0–255. - `Pn1; Pn2; …` — one or more MIDI-ish note numbers from 0 (silence) through 25 (`C7` in the DEC table). 0 = rest, 1 = `C5`, 2 = `C#5`, … 13 = `C6`, … 25 = `C7`. Multiple notes are played sequentially (not chord-style), each at the same `Pv`/`Pd`. **Common note codes** (DEC VT520 RM Appendix A): - `1`=C5 `2`=C#5 `3`=D5 `4`=D#5 `5`=E5 `6`=F5 `7`=F#5 `8`=G5 `9`=G#5 `10`=A5 `11`=A#5 `12`=B5 - `13`=C6 `14`=C#6 … `25`=C7 **'Ode to Joy' opener** as a sanity-check tune (E E F G G F E D C C D E E D D, all at `Pv=5 Pd=4`): `\x1b[5;4;5;5;6;8;8;6;5;3;1;1;3;5;5;3;3,~`. **Use cases**: long-build completion chime (CI tool plays a 2-note 'done' upon `make` exit), distinctive failure tone (red SGR + DECPS 3-note descending pattern), accessibility-friendly notification when OSC 9 desktop-notification would be too noisy. Don't use for every keystroke — it's blocking on most emulators (the terminal's audio thread serialises with the parser). **Coverage**: **xterm** = full (reference). **WezTerm** = full ≥ 20240127. **Ghostty** = full. **mlterm** = full. **Konsole** = partial (volume ignored, plays the system bell instead). **iTerm2** = partial (plays a single beep regardless of Pn). **Kitty** = no-op by default; opt-in via `enable_audio_bell`. **Alacritty** / **Linux console** / **macOS Terminal** / **Windows Terminal** / **cmd / ConPTY** / **gnome-terminal** = silent no-op. **Accessibility note**: respect `NO_COLOR`-style hints — many users have terminal sound permanently muted at the OS level. Don't lean on DECPS for *critical* signals; treat it as a polish nicety alongside a visible status indicator.
Spec citation: DEC VT520 RM Appendix A (DECPS) / xterm-ctlseqs (CSI Pv ; Pd ; Ps ; ... , ~)
Parameters
| Pv | Volume 0–7 (0 silent, 1–3 low, 4–7 high). Most emulators binary on/off. |
| Pd | Duration in 1/32-second units. 8 = 0.25s. Range 0–255. |
| Pn | Note number 0–25 (0 = rest, 1 = C5, … 25 = C7). Multiple Pn play sequentially. |
Examples
# Single quarter-second A5 'ding' at medium volume.\nprintf '\\033[5;8;10,~'import sys\n# Build-complete two-note chime: C6 then E6, half second each.\nsys.stdout.write('\\x1b[5;16;13;17,~')\nsys.stdout.flush()// Failure tone: descending three notes E5 -> C5 -> A4-equivalent rest.\nfmt.Print(\"\\x1b[6;6;5;3;1,~\")// 'Ode to Joy' opening line.\nprocess.stdout.write('\\x1b[5;4;5;5;6;8;8;6;5;3;1;1;3;5;5;3;3,~');/* Three quick high-pitched warning beeps. */\nprintf(\"\\x1b[7;2;25;25;25,~\");Terminal support
- xterm
- yes
- Linux console (fbcon)
- no
- macOS Terminal.app
- no
- iTerm2
- partial
- Windows Terminal
- no
- cmd.exe / ConPTY
- no
- kitty
- partial
- alacritty
- no
- WezTerm
- yes
- Ghostty
- yes
- GNOME Terminal
- no
- Konsole
- partial
- tmux
- no
- GNU screen
- no
| xterm | Linux console (fbcon) | macOS Terminal.app | iTerm2 | Windows Terminal | cmd.exe / ConPTY | kitty | alacritty | WezTerm | Ghostty | GNOME Terminal | Konsole | tmux | GNU screen |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| yes | no | no | partial | no | no | partial | no | yes | yes | no | partial | no | no |