[PR #13208] [MERGED] Add support for the DECPS (Play Sound) escape sequence #29423

Open
opened 2026-01-31 09:34:50 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/13208
Author: @j4james
Created: 5/31/2022
Status: Merged
Merged: 6/1/2022
Merged by: @undefined

Base: mainHead: feature-decps


📝 Commits (6)

  • d18013c Add dispatch framework for the DECPS escape sequence.
  • 13f7eb5 Add a shared MIDI library for playing musical notes.
  • 852401e Implement the conhost handler for the DECPS sequence.
  • 9405fc4 Implement the Terminal handler for the DECPS sequence.
  • 01cc6fb Add spell-check terms.
  • a293def Make MidiAudio::PlayNote noexcept.

📊 Changes

31 files changed (+556 additions, -39 deletions)

View changed files

📝 .github/actions/spelling/expect/expect.txt (+4 -0)
📝 OpenConsole.sln (+46 -0)
src/audio/midi/MidiAudio.cpp (+116 -0)
src/audio/midi/MidiAudio.hpp (+36 -0)
src/audio/midi/lib/midi.vcxproj (+26 -0)
src/audio/midi/precomp.cpp (+4 -0)
src/audio/midi/precomp.h (+30 -0)
📝 src/cascadia/TerminalControl/ControlCore.cpp (+76 -3)
📝 src/cascadia/TerminalControl/ControlCore.h (+9 -0)
📝 src/cascadia/TerminalControl/TerminalControlLib.vcxproj (+4 -0)
📝 src/cascadia/TerminalCore/Terminal.cpp (+18 -0)
📝 src/cascadia/TerminalCore/Terminal.hpp (+4 -0)
📝 src/cascadia/TerminalCore/TerminalApi.cpp (+5 -0)
📝 src/host/consoleInformation.cpp (+34 -0)
📝 src/host/host-common.vcxitems (+5 -0)
📝 src/host/output.cpp (+3 -1)
📝 src/host/outputStream.cpp (+29 -0)
📝 src/host/outputStream.hpp (+1 -0)
📝 src/host/server.h (+5 -0)
📝 src/terminal/adapter/ITermDispatch.hpp (+2 -0)

...and 11 more files

📄 Description

Summary of the Pull Request

The DECPS (Play Sound) escape sequence provides applications with a
way to play a basic sequence of musical notes. This emulates
functionality that was originally supported on the DEC VT520 and VT525
hardware terminals.

PR Checklist

Detailed Description of the Pull Request / Additional comments

When a DECPS control is executed, any further output is blocked until
all the notes have finished playing. So to prevent the UI from hanging
during this period, we have to temporarily release the console/terminal
lock, and then reacquire it before returning.

The problem we then have is how to deal with the terminal being closed
during that unlocked interval. The way I've dealt with that is with a
promise that is set to indicate a shutdown. This immediately aborts any
sound that is in progress, but also signals the thread that it needs to
exit as soon as possible.

The thread exit is achieved by throwing a custom exception which is
recognised by the state machine and rethrown instead of being logged.
This gets it all the way up to the root of the write operation, so it
won't attempt to process anything further output that might still be
buffered.

Validation Steps Performed

Thanks to the testing done by @jerch on a real VT525 terminal, we have a
good idea of how this sequence is supposed to work, and I'm fairly
confident that our implementation is reasonably compatible.

The only significant difference I'm aware of is that we support multiple
notes in a sequence. That was a feature that was documented in the
VT520/VT525 manual, but didn't appear to be supported on the actual
device.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/13208 **Author:** [@j4james](https://github.com/j4james) **Created:** 5/31/2022 **Status:** ✅ Merged **Merged:** 6/1/2022 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `feature-decps` --- ### 📝 Commits (6) - [`d18013c`](https://github.com/microsoft/terminal/commit/d18013c82e6f5f2db964e7544576e8370b0fef07) Add dispatch framework for the DECPS escape sequence. - [`13f7eb5`](https://github.com/microsoft/terminal/commit/13f7eb5c29cc11a58383dc441b6e0d314e5edd65) Add a shared MIDI library for playing musical notes. - [`852401e`](https://github.com/microsoft/terminal/commit/852401e8120083c39951b911f0dc7acc4ba676b2) Implement the conhost handler for the DECPS sequence. - [`9405fc4`](https://github.com/microsoft/terminal/commit/9405fc4e6082ce1fd463707f2b512899465fe11d) Implement the Terminal handler for the DECPS sequence. - [`01cc6fb`](https://github.com/microsoft/terminal/commit/01cc6fbedbbf1b04f766abb18ac83150f5062ce8) Add spell-check terms. - [`a293def`](https://github.com/microsoft/terminal/commit/a293def8c940490ba2ff9bdc99d38fc6c064dd45) Make MidiAudio::PlayNote noexcept. ### 📊 Changes **31 files changed** (+556 additions, -39 deletions) <details> <summary>View changed files</summary> 📝 `.github/actions/spelling/expect/expect.txt` (+4 -0) 📝 `OpenConsole.sln` (+46 -0) ➕ `src/audio/midi/MidiAudio.cpp` (+116 -0) ➕ `src/audio/midi/MidiAudio.hpp` (+36 -0) ➕ `src/audio/midi/lib/midi.vcxproj` (+26 -0) ➕ `src/audio/midi/precomp.cpp` (+4 -0) ➕ `src/audio/midi/precomp.h` (+30 -0) 📝 `src/cascadia/TerminalControl/ControlCore.cpp` (+76 -3) 📝 `src/cascadia/TerminalControl/ControlCore.h` (+9 -0) 📝 `src/cascadia/TerminalControl/TerminalControlLib.vcxproj` (+4 -0) 📝 `src/cascadia/TerminalCore/Terminal.cpp` (+18 -0) 📝 `src/cascadia/TerminalCore/Terminal.hpp` (+4 -0) 📝 `src/cascadia/TerminalCore/TerminalApi.cpp` (+5 -0) 📝 `src/host/consoleInformation.cpp` (+34 -0) 📝 `src/host/host-common.vcxitems` (+5 -0) 📝 `src/host/output.cpp` (+3 -1) 📝 `src/host/outputStream.cpp` (+29 -0) 📝 `src/host/outputStream.hpp` (+1 -0) 📝 `src/host/server.h` (+5 -0) 📝 `src/terminal/adapter/ITermDispatch.hpp` (+2 -0) _...and 11 more files_ </details> ### 📄 Description ## Summary of the Pull Request The `DECPS` (Play Sound) escape sequence provides applications with a way to play a basic sequence of musical notes. This emulates functionality that was originally supported on the DEC VT520 and VT525 hardware terminals. ## PR Checklist * [x] Closes #8687 * [x] CLA signed. * [ ] Tests added/passed * [ ] Documentation updated. * [ ] Schema updated. * [x] I've discussed this with core contributors already. Issue number where discussion took place: #8687 ## Detailed Description of the Pull Request / Additional comments When a `DECPS` control is executed, any further output is blocked until all the notes have finished playing. So to prevent the UI from hanging during this period, we have to temporarily release the console/terminal lock, and then reacquire it before returning. The problem we then have is how to deal with the terminal being closed during that unlocked interval. The way I've dealt with that is with a promise that is set to indicate a shutdown. This immediately aborts any sound that is in progress, but also signals the thread that it needs to exit as soon as possible. The thread exit is achieved by throwing a custom exception which is recognised by the state machine and rethrown instead of being logged. This gets it all the way up to the root of the write operation, so it won't attempt to process anything further output that might still be buffered. ## Validation Steps Performed Thanks to the testing done by @jerch on a real VT525 terminal, we have a good idea of how this sequence is supposed to work, and I'm fairly confident that our implementation is reasonably compatible. The only significant difference I'm aware of is that we support multiple notes in a sequence. That was a feature that was documented in the VT520/VT525 manual, but didn't appear to be supported on the actual device. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:34:50 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#29423