# christoskonstantas/anasa architecture

> Architecture diagram of the GitHub repository christoskonstantas/anasa, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/christoskonstantas/anasa
- Repository: https://github.com/christoskonstantas/anasa

## Overview

ANASA is an experimental C++ system for scheduling rendering ahead of simulated audio playback, not a DAW or audio host. Its main workflow is: control commands enter the Engine, the Scheduler classifies and orders timeline work, Executor workers render tiles, and completed audio is cached and published as ordered blocks for the simulated device callback to consume. Playback controls, edits, seeks, viewport preparation, FIFO/priority policies, synthetic and optional neural rendering, and WAV capture are distinct product capabilities. Links involving unsampled implementations rely on README statements; the graph omits uncertain internal calls.

Main entry points: [`src/scheduler/Scheduler.cpp`](https://github.com/christoskonstantas/anasa/blob/main/src/scheduler/Scheduler.cpp) (Scheduler), [`src/engine/Engine.cpp`](https://github.com/christoskonstantas/anasa/blob/main/src/engine/Engine.cpp) (Engine lifecycle), [`runtime-demo/RuntimeDemo.cpp`](https://github.com/christoskonstantas/anasa/blob/main/runtime-demo/RuntimeDemo.cpp) (Runtime demo), [`src/scheduler/TimelineAudioPublisher.cpp`](https://github.com/christoskonstantas/anasa/blob/main/src/scheduler/TimelineAudioPublisher.cpp) (Timeline publisher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_engine["Engine and control"]
  node_engine["Engine lifecycle<br/>[Engine.cpp]"]
  node_commands["Command queue<br/>[SpscQueue.hpp]"]
end

subgraph group_schedule["Scheduling and playback"]
  node_scheduler["Scheduler<br/>[Scheduler.cpp]"]
  node_playback["Playback controls"]
  node_gate["Background gate"]
  node_policies["Scheduling policies"]
  node_pending["Pending work<br/>[Scheduler.hpp]"]
  node_cache[("Render cache<br/>[RenderCache.cpp]")]
  node_versions[("Chunk versions<br/>[VersionTable.cpp]")]
  node_publisher["Timeline publisher"]
  node_shared["Playback shared state<br/>[PlaybackState.hpp]"]
end

subgraph group_render["Rendering backends"]
  node_executor["Worker pool<br/>[Executor.cpp]"]
  node_taskprocessor["Tile task processor"]
  node_synthetic["Synthetic renderer"]
  node_renderer["Tile renderer<br/>[Renderer.cpp]"]
  node_phraseadapter["Phrase tile adapter"]
  node_openvpi["OpenVPI renderer"]
  node_prepared["Prepared singing timeline"]
end

subgraph group_audio["Audio output"]
  node_ready["Ready audio queue<br/>[SpscQueue.hpp]"]
  node_processor["Audio block processor"]
  node_simulator["Audio simulator<br/>[AudioSimulator.cpp]"]
end

subgraph group_demo["Demo and capture"]
  node_demo["Runtime demo<br/>[RuntimeDemo.cpp]"]
  node_wav["WAV writer<br/>[WaveWriter.hpp]"]
end

node_control(("Control thread"))

node_control -->|"posts commands"| node_engine
node_engine -->|"owns pipeline"| node_scheduler
node_engine -->|"starts workers"| node_executor
node_engine -->|"starts simulator"| node_simulator
node_engine -->|"provides queue"| node_commands
node_scheduler -->|"reads commands"| node_commands
node_scheduler -->|"updates intent"| node_playback
node_scheduler -->|"gates dispatch"| node_gate
node_scheduler -->|"orders work"| node_policies
node_scheduler -->|"queues tiles"| node_pending
node_scheduler -->|"submits tiles"| node_executor
node_executor -->|"processes tasks"| node_taskprocessor
node_taskprocessor -->|"renders tiles"| node_renderer
node_renderer -->|"uses kernel"| node_synthetic
node_taskprocessor -->|"renders tiles"| node_phraseadapter
node_phraseadapter -->|"calls phrase renderer"| node_openvpi
node_demo -->|"prepares phrases"| node_prepared
node_demo -->|"runs scenarios"| node_engine
node_scheduler -->|"stores completed audio"| node_cache
node_scheduler -->|"publishes blocks"| node_publisher
node_publisher -->|"reads cached PCM"| node_cache
node_publisher -->|"copies ordered blocks"| node_ready
node_simulator -->|"calls callback processor"| node_processor
node_processor -->|"consumes blocks"| node_ready
node_scheduler -->|"invalidates chunks"| node_versions
node_scheduler -->|"publishes playback state"| node_shared
node_processor -->|"reports cursor"| node_shared
node_demo -->|"records WAV"| node_wav
node_engine -->|"owns version table"| node_versions

click node_engine "https://github.com/christoskonstantas/anasa/blob/main/src/engine/Engine.cpp"
click node_commands "https://github.com/christoskonstantas/anasa/blob/main/src/utils/queues/SpscQueue.hpp"
click node_scheduler "https://github.com/christoskonstantas/anasa/blob/main/src/scheduler/Scheduler.cpp"
click node_playback "https://github.com/christoskonstantas/anasa/blob/main/src/playback/PlaybackController.cpp"
click node_gate "https://github.com/christoskonstantas/anasa/blob/main/src/playback/BackgroundRenderGate.cpp"
click node_policies "https://github.com/christoskonstantas/anasa/tree/main/src/scheduler/policies"
click node_pending "https://github.com/christoskonstantas/anasa/blob/main/src/scheduler/Scheduler.hpp"
click node_executor "https://github.com/christoskonstantas/anasa/blob/main/src/execution/Executor.cpp"
click node_taskprocessor "https://github.com/christoskonstantas/anasa/blob/main/src/execution/RenderTaskProcessor.cpp"
click node_synthetic "https://github.com/christoskonstantas/anasa/blob/main/src/render/kernels/SyntheticRenderKernel.cpp"
click node_renderer "https://github.com/christoskonstantas/anasa/blob/main/src/render/Renderer.cpp"
click node_phraseadapter "https://github.com/christoskonstantas/anasa/blob/main/src/render/PhraseTileRenderer.cpp"
click node_openvpi "https://github.com/christoskonstantas/anasa/blob/main/src/render/openvpi/OpenVpiRenderer.cpp"
click node_prepared "https://github.com/christoskonstantas/anasa/blob/main/src/render/PreparedSingingTimeline.hpp"
click node_cache "https://github.com/christoskonstantas/anasa/blob/main/src/scheduler/RenderCache.cpp"
click node_versions "https://github.com/christoskonstantas/anasa/blob/main/src/render/VersionTable.cpp"
click node_publisher "https://github.com/christoskonstantas/anasa/blob/main/src/scheduler/TimelineAudioPublisher.cpp"
click node_ready "https://github.com/christoskonstantas/anasa/blob/main/src/utils/queues/SpscQueue.hpp"
click node_processor "https://github.com/christoskonstantas/anasa/blob/main/src/audio/AudioBlockProcessor.cpp"
click node_simulator "https://github.com/christoskonstantas/anasa/blob/main/src/audio/simulator/AudioSimulator.cpp"
click node_shared "https://github.com/christoskonstantas/anasa/blob/main/src/playback/PlaybackState.hpp"
click node_demo "https://github.com/christoskonstantas/anasa/blob/main/runtime-demo/RuntimeDemo.cpp"
click node_wav "https://github.com/christoskonstantas/anasa/blob/main/apps/WaveWriter.hpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_engine,node_commands toneBlue
class node_scheduler,node_playback,node_gate,node_policies,node_pending,node_cache,node_versions,node_publisher,node_shared toneAmber
class node_executor,node_taskprocessor,node_synthetic,node_renderer,node_phraseadapter,node_openvpi,node_prepared toneMint
class node_ready,node_processor,node_simulator toneRose
class node_demo,node_wav,node_control toneIndigo
```

## Components

### Engine and control

- [Engine lifecycle](https://github.com/christoskonstantas/anasa/blob/main/src/engine/Engine.cpp): `src/engine/Engine.cpp`
- [Command queue](https://github.com/christoskonstantas/anasa/blob/main/src/utils/queues/SpscQueue.hpp): `src/utils/queues/SpscQueue.hpp`

### Scheduling and playback

- [Scheduler](https://github.com/christoskonstantas/anasa/blob/main/src/scheduler/Scheduler.cpp): `src/scheduler/Scheduler.cpp`
- [Playback controls](https://github.com/christoskonstantas/anasa/blob/main/src/playback/PlaybackController.cpp): `src/playback/PlaybackController.cpp`
- [Background gate](https://github.com/christoskonstantas/anasa/blob/main/src/playback/BackgroundRenderGate.cpp): `src/playback/BackgroundRenderGate.cpp`
- [Scheduling policies](https://github.com/christoskonstantas/anasa/tree/main/src/scheduler/policies): `src/scheduler/policies`
- [Pending work](https://github.com/christoskonstantas/anasa/blob/main/src/scheduler/Scheduler.hpp): `src/scheduler/Scheduler.hpp`
- [Render cache](https://github.com/christoskonstantas/anasa/blob/main/src/scheduler/RenderCache.cpp): `src/scheduler/RenderCache.cpp`
- [Chunk versions](https://github.com/christoskonstantas/anasa/blob/main/src/render/VersionTable.cpp): `src/render/VersionTable.cpp`
- [Timeline publisher](https://github.com/christoskonstantas/anasa/blob/main/src/scheduler/TimelineAudioPublisher.cpp): `src/scheduler/TimelineAudioPublisher.cpp`
- [Playback shared state](https://github.com/christoskonstantas/anasa/blob/main/src/playback/PlaybackState.hpp): `src/playback/PlaybackState.hpp`

### Rendering backends

- [Worker pool](https://github.com/christoskonstantas/anasa/blob/main/src/execution/Executor.cpp): `src/execution/Executor.cpp`
- [Tile task processor](https://github.com/christoskonstantas/anasa/blob/main/src/execution/RenderTaskProcessor.cpp): `src/execution/RenderTaskProcessor.cpp`
- [Synthetic renderer](https://github.com/christoskonstantas/anasa/blob/main/src/render/kernels/SyntheticRenderKernel.cpp): `src/render/kernels/SyntheticRenderKernel.cpp`
- [Tile renderer](https://github.com/christoskonstantas/anasa/blob/main/src/render/Renderer.cpp): `src/render/Renderer.cpp`
- [Phrase tile adapter](https://github.com/christoskonstantas/anasa/blob/main/src/render/PhraseTileRenderer.cpp): `src/render/PhraseTileRenderer.cpp`
- [OpenVPI renderer](https://github.com/christoskonstantas/anasa/blob/main/src/render/openvpi/OpenVpiRenderer.cpp): `src/render/openvpi/OpenVpiRenderer.cpp`
- [Prepared singing timeline](https://github.com/christoskonstantas/anasa/blob/main/src/render/PreparedSingingTimeline.hpp): `src/render/PreparedSingingTimeline.hpp`

### Audio output

- [Ready audio queue](https://github.com/christoskonstantas/anasa/blob/main/src/utils/queues/SpscQueue.hpp): `src/utils/queues/SpscQueue.hpp`
- [Audio block processor](https://github.com/christoskonstantas/anasa/blob/main/src/audio/AudioBlockProcessor.cpp): `src/audio/AudioBlockProcessor.cpp`
- [Audio simulator](https://github.com/christoskonstantas/anasa/blob/main/src/audio/simulator/AudioSimulator.cpp): `src/audio/simulator/AudioSimulator.cpp`

### Demo and capture

- [Runtime demo](https://github.com/christoskonstantas/anasa/blob/main/runtime-demo/RuntimeDemo.cpp): `runtime-demo/RuntimeDemo.cpp`
- [WAV writer](https://github.com/christoskonstantas/anasa/blob/main/apps/WaveWriter.hpp): `apps/WaveWriter.hpp`

### Other components

- **Control thread**

## Connections

- Control thread → Engine lifecycle: posts commands (evidence: `src/engine/Engine.cpp`)
- Engine lifecycle → Scheduler: owns pipeline (evidence: `src/engine/Engine.cpp`)
- Engine lifecycle → Worker pool: starts workers (evidence: `src/engine/Engine.cpp`)
- Engine lifecycle → Audio simulator: starts simulator (evidence: `src/engine/Engine.cpp`)
- Engine lifecycle → Command queue: provides queue
- Scheduler → Command queue: reads commands
- Scheduler → Playback controls: updates intent
- Scheduler → Background gate: gates dispatch
- Scheduler → Scheduling policies: orders work (evidence: `src/scheduler/Scheduler.cpp`)
- Scheduler → Pending work: queues tiles (evidence: `src/scheduler/Scheduler.cpp`)
- Scheduler → Worker pool: submits tiles
- Worker pool → Tile task processor: processes tasks
- Tile task processor → Tile renderer: renders tiles
- Tile renderer → Synthetic renderer: uses kernel
- Tile task processor → Phrase tile adapter: renders tiles
- Phrase tile adapter → OpenVPI renderer: calls phrase renderer
- Runtime demo → Prepared singing timeline: prepares phrases
- Runtime demo → Engine lifecycle: runs scenarios
- Scheduler → Render cache: stores completed audio
- Scheduler → Timeline publisher: publishes blocks
- Timeline publisher → Render cache: reads cached PCM
- Timeline publisher → Ready audio queue: copies ordered blocks
- Audio simulator → Audio block processor: calls callback processor
- Audio block processor → Ready audio queue: consumes blocks
- Scheduler → Chunk versions: invalidates chunks
- Scheduler → Playback shared state: publishes playback state
- Audio block processor → Playback shared state: reports cursor
- Runtime demo → WAV writer: records WAV (evidence: `runtime-demo/RuntimeDemo.cpp`)
- Engine lifecycle → Chunk versions: owns version table
