Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ tecs/
│ ├── platform/ # Window, events, audio and gamepad backends
│ ├── physics/ # Rapier contract and binding
│ ├── input.nupp # Gameplay input over the platform event stream
│ ├── audio.nupp # Clips, voices, groups, limits, the Sound component
│ ├── audio/ # Clips, voices, groups, limits, the Sound component, General MIDI, Yamaha FM, music
│ ├── sequence.nupp # Sequencer, with the tween runtime inside it
│ ├── assets.nupp # Asset orchestration
│ ├── mcp.nupp # Debug server: transport, tools, sandbox
│ └── events.nupp, files.nupp, watch.nupp
├── native/rust/
│ ├── winit-host/ # The application loop, the wgpu renderer, the host ABI
│ ├── tecs-audio/ # cpal output and capture behind a batched contract
│ ├── tecs-audio/ # cpal output and capture behind a batched contract; General MIDI and Yamaha FM voices
│ ├── tecs-gamepad/ # gilrs enumeration and observations
│ ├── physics/ # Rapier storage and stepping
│ └── build-support/ # Native packaging and binary inspection
Expand Down
42 changes: 41 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ members = [
"native/rust/build-support",
"native/rust/physics",
"native/rust/tecs-audio",
"native/rust/tecs-audio-abi",
"native/rust/tecs-assets",
"native/rust/tecs-ui",
"native/rust/tecs-gamepad",
"native/rust/winit-host",
"tecs-gm",
"tecs-pcm",
"tecs-ymfm",
]
default-members = ["native/rust/winit-host"]
resolver = "2"
Expand Down Expand Up @@ -47,6 +51,7 @@ rayon = "1.12"
reqwest = { version = "0.13.4", default-features = false, features = ["deflate", "gzip", "rustls-no-provider", "socks", "stream"] }
resvg = { version = "0.47", default-features = false, features = ["text"] }
regex = "1.12"
rustysynth = "1.3.7"
rmcp = { version = "3.0.0", default-features = false, features = ["client", "server", "transport-io", "transport-streamable-http-client-reqwest", "transport-streamable-http-server"] }
rustls = { version = "0.23", default-features = false, features = ["ring", "std", "tls12"] }
serde = { version = "1", features = ["derive"] }
Expand All @@ -70,6 +75,7 @@ urlencoding = "2.1.3"
walkdir = "2.5"
wgpu = "30.0.1"
winit = "0.30.13"
ymfm-oxide = { git = "https://github.com/albanmgicquel/ymfm-oxide", rev = "4cc9e106c7dbf28c848a9a463bf3ef74709a5ed0" }
axum = { version = "0.8", default-features = false, features = ["http1", "tokio"] }

[profile.release]
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ test suite reach the same world without starting a graphics stack.
- Camera, layers with positioning modes, images, clips, sprite sheets with
animation, and distance-field text.
- Input across keyboard, pointer, gamepad and touch; audio playback, recording
and device enumeration; physics over Rapier; sequencing with tweening; asset
orchestration; file watching; and an MCP debug server.
and device enumeration; General MIDI from a SoundFont; emulated Yamaha FM
chips, from the OPL2 and OPL3 to the YM2612 and the OPL4; MIDI, VGM, VGZ and
DRO music played on them; physics over Rapier; sequencing with tweening;
asset orchestration; file watching; and an MCP debug server.

- [Tiled TMX maps and TSX tilesets](docs/tiled/index.md), animated tile and image
layers, object factories, runtime tile edits and authored collision outlines.
Expand Down
54 changes: 54 additions & 0 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,60 @@ Open Font License 1.1. The tests and retained UI example read it. Packages ship
`share/tecs/assets/fonts` with `JetBrainsMono-OFL.txt` and the versioned
`JetBrainsMono-NOTICE.md`.

## SoundFonts

Tecs ships no SoundFont. `tecs.audio.synth` reads one a game supplies, and a
General MIDI set is game content under its own licence, so a game that ships
one ships that licence beside it. FluidR3 GM, for example, is MIT.

## Linked BSD-licensed code

### ymfm-oxide

`tecs.audio.fm` emulates every chip it offers with ymfm-oxide
(<https://github.com/albanmgicquel/ymfm-oxide>), a pure-Rust port by Alban
Gicquel of ymfm, Aaron Giles's emulator of the Yamaha FM chips
(<https://github.com/aaronsgiles/ymfm>). It is a Cargo dependency pinned to one
commit, compiled into `tecsaudio`, so every package carries it and
`cargo-licenses.txt` records it as BSD-3-Clause. The licence asks for its
notice to travel with a binary, which is this one; Tecs keeps none of its
source. The OPLL family plays ymfm's own copyright-free stand-ins for the
instrument ROMs, made by David Viens and Hubert Lamontagne and carried in the
crate; no Yamaha ROM ships with Tecs.

```text
BSD 3-Clause License

Copyright (c) 2021, Aaron Giles
Copyright (c) 2026, Alban Gicquel
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
```

## Scope of the checks

The generated inventory and source manifest make shipped dependency names,
Expand Down
28 changes: 28 additions & 0 deletions docs/audio/agents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
description: "Inspect, record and drive the audio console from the MCP debug server"
order: 52
---

# Audio for agents

An agent cannot hear, so the debug server reports the console as data and
records what was played. A memory output, or a void one held by `clock_pause`,
makes all of it deterministic: the audio clock then moves only with the frames
`clock_step` grants, or with `audio_step`.

| Tool | What it does |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `audio` | Installed, available, failure, voice count, master gain, the Decoders registered |
| `audio_snapshot` | Buses and Tracks with their faders, sends, effects and meters; voices; Timelines; the clock, the output and the counters |
| `audio_events` | Starts, refusals, steals, stops and finishes, each with its clock time; pass `after` to read only what is new |
| `audio_listen` | Starts recording the next `seconds` of the mix |
| `audio_listening` | Summarizes the recording: peak, RMS, LUFS, clipped samples, silent spans and onset times; `save` writes a WAV |
| `audio_step` | Renders `seconds` of a memory or held void output |
| `audio_control` | Sets a Bus's or a Track's gain, mute, solo or pause |
| `audio_play` | Plays a Sound the mixer knows, by name, on a Bus or a Track, now or at a clock time |
| `audio_timeline` | Pauses, resumes, seeks or retempos a Timeline |
| `reload_sound` | Re-reads a Sound from where it came from, through its extension |

To check "did the door sound play when the door opened": `clock_pause`, open
the door, `clock_step`, then read `audio_events` for its start and
`audio_listening` for an onset near that time.
74 changes: 74 additions & 0 deletions docs/audio/extensions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
description: "Plug Decoders and Effects into the mixer through versioned C vtables, as tecs-pcm, tecs-gm and tecs-ymfm do"
order: 51
---

# Audio extensions

A kind of Sound is a Nupp module and a native Decoder registered together.
The Nupp half parses at control rate and can sequence; the native half renders
at audio rate, in the callback, where it must not allocate, lock or block.

## The three in the monorepo

- **`tecs-pcm`**: encoded audio files (symphonia). `tecs.pcm` loads a file, or
the bytes of one, as a Sound, resident and shared by every voice or streamed
from its file on one feeder thread, and gives the `PCM` and `PCM_STREAM`
asset kinds.

- **`tecs-gm`**: General MIDI from a SoundFont (`rustysynth`). `tecs.gm` loads
SoundFonts and plays a `Synth` as a voice; `tecs.gm.midi` loads Standard MIDI
Files as assets and plays them.
- **`tecs-ymfm`**: the 24 Yamaha FM chips `ymfm-oxide` emulates. `tecs.ymfm`
plays a chip as a voice; `tecs.ymfm.music` plays VGM, VGZ and DRO logs.

None is compiled in by default. Build their native libraries with
`nupp task extensions`, and run their tests with `nupp task test-pcm`,
`nupp task test-gm` and `nupp task test-ymfm`. Each is its own Nupp project
over the tecs sources, and finds its library the way tecs finds its own
services, or through `TECS_PCM_LIBRARY`, `TECS_GM_LIBRARY` and
`TECS_YMFM_LIBRARY`.

`tecs-gm` and `tecs-ymfm` drive their voices with Decoder events on the mixer's one clock, so a
note or a register write lines up with every clip by arithmetic.

## The Decoder ABI

`tecs-audio-abi` holds the types. A library exports a `DecoderVTable`:

| Entry | Thread | Purpose |
| ---------------------------------------- | ------- | ----------------------------------------------------------------------------------- |
| `abi_version`, `struct_size` | Load | Compatibility: the version must match and the size be at least what the mixer reads |
| `describe(params, bytes, rate) → format` | Control | Channels, rate, length, and whether it takes events |
| `open(params, bytes, rate) → instance` | Control | One instance per Playback, allocating everything here |
| `render(instance, out, frames) → frames` | Audio | Fewer frames than asked means the Playback has ended |
| `event(instance, frame, data)` | Audio | A timed event, delivered on its frame |
| `seek(instance, seconds)` | Control | Optional |
| `close(instance)` | Control | Never called on the audio thread |

`mixer:registerDecoder(vtable)` returns an id; `mixer:playDecoded(id, params,
bytes, options)` starts a Playback; `mixer:event(handle, data, at)` sends it an
event. An event's top bits, from bit 40, name an operation every sequenced
Decoder is asked for (notes off, reset); below them is the Decoder's own
payload.

A `tecs.audio.Sound` names its Decoder and carries what opens a Playback of
it, so `mixer:play(sound)` registers that Decoder on first use and needs
nothing else: this is how `tecs.pcm`'s Sounds play, and how a game's own kind
of Sound would.

## The Effect ABI

An `EffectVTable` has `describe` (latency and tail), `open` for a rate and
channel count, `process` in place on the audio thread, `param` (a target, on a
frame, ramped by the effect), `reset` and `close`. `mixer:registerEffect`
returns a kind that `tecs.audio.effects.custom` builds a spec for.

## Threads

The control side, the game thread today, only sends messages. The render side,
the device callback, the void output's supervisor, or the caller stepping a
memory output, applies them before it mixes, through a lock-free queue, and
hands back what it observed and what it finished with through another. Queries
read what the render side published. A Decoder or an Effect must not assume
which control thread calls it.
Loading
Loading