New here? End-user setup: docs/install.md · this file is for contributors and automation. Flow (planning lifecycle): flow/README.md.
trem is a mathematical music engine in Rust. The repo root is a virtual
workspace (Cargo.toml only): all crates live under crates/, including
the trem-bin application (cargo run targets it via default-members).
crates/trem/-- Core library (no codec I/O). Rational arithmetic, pitch/scale systems, temporal trees, audio processing graphs, Euclidean rhythms, node registry, offline rendering, and typed PCM units (trem::signal). Optionalrung/midi: Rung clip JSON (trem::rung) and SMF import.crates/trem-mio/-- Media I/O (not the Tokiomiocrate): planar WAV/FLAC today (trem_mio::audio,trem_mio::wav); room for images later. Featureaudio(default on). Onwasm32without WASI use in-memory APIs (from_bytes,write_planar_to_vec,open_memory/done_into_vec).crates/trem-dsp/-- Built-in graph nodes (standardmodule), registry wiring (register_standard,standard_registry), andinterfacesre-exports for customNodeimplementations (seedocs/graph-architecture.md).crates/trem-rta/-- Real-time playback host (cpal + rtrb). Featurecli:cli_output(StereoOutputCli,AudioPlayer). File output usestrem_mio::audio(cratetrem-mio).crates/trem-tui/-- Terminal UI using ratatui + crossterm.
The trem-bin package (crates/trem-bin/) wires libraries into the TUI DAW.
The default patch and pattern live under crates/trem-bin/src/demo/ (levels.rs =
mix constants, graph.rs = routing, pattern.rs = starter grid).
cargo check --workspace # type-check everything
cargo test --workspace # run all unit + integration tests (mirrors GitHub Actions CI)
cargo test -p trem --features rung,midi # Rung + MIDI import tests (also run in CI)
cargo test -p trem-mio # WAV/FLAC I/O tests
cargo test --workspace --doc # run doc-test examples
cargo bench -p trem -- --test # compile-check trem benchmarks
cargo bench -p trem-dsp -- --test # compile-check trem-dsp benchmarks
cargo doc --workspace --no-deps # build documentation
cargo run # launch the TUI demo (workspace default-member `crates/trem-bin`; same as `trem tui`)
cargo run -p trem-bin # explicit package (equivalent)
cargo run -- rung import file.mid # MIDI → Rung JSON (`clip` is a visible alias for `rung`)
cargo run -- rung import tune.mid -o - # write JSON to stdout
cargo run -- rung edit clip.rung.json # Rung piano-roll editor (TTY)
cargo check -p trem-mio --examples # all `trem-mio` I/O examples (WAV/FLAC)
cargo run -p trem-mio --example save_planar_wav # planar WAV write (feature `audio` default on `trem-mio`)
cargo run -p trem-dsp --example <name> # graph + stock DSP examples
cargo check -p trem-rta --features cli # `StereoOutputCli` onlyWork items use the flow/ directory (same model as the ezc repo). Full rules:
flow/README.md.
flow/prop/ -> flow/todo/ -> flow/plan/ -> flow/work/ -> flow/done/
flow/prop/— Draft proposals (what / why).flow/todo/— Accepted; committed to doing.flow/plan/— Detailed implementation plan (use for non-trivial work).flow/work/— In progress (one item per agent when possible).flow/done/— Complete; add Lessons learned. This is the decision log for shipped work items.
Top-level docs/ is not a flow stage — it holds ongoing user and architecture
docs (install.md, graph-architecture.md, modes/, …).
- License: MIT.
- Tests: Run
cargo test --workspacebefore marking anything done. All tests must pass. - Doc comments: Every public type, function, and module should have a doc
comment. Key types should have
# Exampleswith tested code blocks. - No narration comments: Do not add comments that just describe what the code does. Comments should only explain non-obvious intent or trade-offs.
- Formatting: Use
cargo fmtconventions. No manual formatting overrides. - Dependencies: Prefer well-maintained Rust crates over reinventing. Use the package manager to add dependencies (don't make up versions).
- Design velocity: This project is young and changes fast. Prefer one clear design and break + rewrite when something better appears — not long-lived parallel APIs, compatibility shims, or “legacy until migrated” layers unless there is an explicit, time-bounded reason.
demos/-- Placeholder for future demos (seedemos/README.md).crates/trem-bin/src/demo/-- Default patch for the binary:levels.rs(mix),graph.rs(routing),pattern.rs(grid). Seecrates/trem-bin/src/demo/README.md.crates/trem/src/graph.rs-- The coreGraphandNodetrait (PrepareEnv/Node::prepare, pooled input mix).GraphimplementsNode, enabling recursive nesting. See docs/graph-architecture.md. Seedocs/graph-architecture.mdfor prepare/block sizing behavior.crates/trem-mio/-- Media codecs and file helpers (audio,wav); depends ontremforsignaltypes only.crates/trem-dsp/src/standard/-- Stock nodes (oscillators, filters, dynamics, effects, drum synths, etc.).crates/trem/src/registry.rs-- Runtime node factory mapping tags to constructors (populate viatrem_dsp::register_standard).crates/trem/src/tree.rs-- Recursive temporal trees for rhythm.crates/trem/src/pitch.rs-- Xenharmonic pitch and tuning systems.crates/trem-rta/src/driver.rs-- Audio thread loop.crates/trem-tui/src/app.rs-- TUI application state and render loop.crates/trem-tui/src/view/-- Widget implementations for each TUI pane.docs/tui-testing.md-- TUI testing:tests/keyboard_flows.rs,tests/widget_labels.rs,cargo test -p trem-tui, optionalexpect scripts/tui-smoke.expecton a real terminal.docs/modes/-- User stories and input specs for fullscreen editing modes (pattern roll first);docs/modes/principles.mdis the shared contract for future modes.crates/trem/src/rung/-- Rung interchange (RungFile,Clip; MIDI import behind crate featuresrung+midi).crates/trem-bin/src/main.rs-- CLI + demo graph/pattern + TUI launch.
Before completing any work item:
cargo check --workspace-- no errorscargo test --workspace-- all tests passcargo test --workspace --doc-- doc examples pass- If DSP or graph changes:
cargo bench -p trem -- --testandcargo bench -p trem-dsp -- --test-- benchmarks compile