How darkgraycat/bleeder works
Purpose and Entry Points
Bleeder is a Go-based live-coding/audio-generation system: it reads “bleed” source files, parses a music-oriented DSL, builds an intermediate representation, renders audio, and can play WAV output. The executable entry point is main.go; CLI construction and command context live in cmd/cmd.go, cmd/cfg.go, and cmd/ctx.go.
Example DSL inputs are stored under bleeds/, including bleeds/aelin.practice.toml and bleeds/just_playing.toml.
CLI and Execution Context
The command layer owns process-level configuration and dispatch into the core engine. cmd/cfg.go and root config.toml establish configuration boundaries, while cmd/ctx.go appears to carry shared execution context between CLI operations and runtime services.
The top-level control path is expected to be:
main.go → cmd/ command setup → core Bleeder orchestration → parse/render/play stages.
Core Bleeder Orchestration
internal/core/bleeder.go is the principal application coordinator. It works with bleed inputs and their context through internal/core/bleed.go and internal/core/bleedctx.go. This is the main boundary between user-authored source/configuration and the compiler-like audio pipeline.
The core package is where parsing results, runtime options, and downstream renderer/player dependencies should be assembled rather than embedded in CLI commands.
DSL Parsing and IR Boundary
The repository has two parser implementations, internal/core/parser.go and internal/core/parser2.go, suggesting an evolving syntax model. Both feed the canonical intermediate representation in internal/ir/ir.go.
This IR is the key architectural contract: parsers translate bleed syntax into structured musical/audio instructions; renderers should consume IR rather than depend on source syntax. DSL intent and planned behavior are documented in docs/aelin/dsl-design.md, docs/aelin/parser-design.md, and docs/aelin/syntax-model-v2.md.
Audio Synthesis and Rendering
Audio-domain primitives are concentrated in internal/audio/notes.go, internal/audio/waves.go, and internal/audio/wav.go. These likely provide note/frequency handling, waveform generation, and WAV encoding.
Rendering is abstracted by internal/renderer/renderer.go, with WAV-specific implementation in internal/renderer/wav_renderer.go. The rendering boundary converts IR/audio instructions into a material audio artifact, keeping file-format concerns separate from parsing and orchestration.
Playback and Runtime Output
Playback is separated from rendering in internal/player/player.go and internal/player/wav_player.go. This permits a generated WAV artifact to be consumed by a player implementation independently of how it was synthesized.
The system therefore has a clear output chain: IR → renderer → WAV/audio output → player. Audio-device behavior, buffering, and streaming concerns are architecturally relevant and discussed in docs/aelin/streaming-architecture.md and docs/aelin/buffer-drain-solution.md.
Live-Coding Integration
The extensions/bleeder-vscode/ package provides a VS Code integration, principally through extensions/bleeder-vscode/extension.js. It is an external editor-facing control surface rather than part of the Go runtime pipeline.
Supporting design documents, especially docs/aelin/live-coding-architecture.md and LIVE_CODING_PLAN.md, indicate that rapid source update, parse/rebuild, and audio-output lifecycle management are central future/runtime concerns.
Main entry points: bleeder.go Bleeder coordinator · cmd.go Command setup · wav_renderer.go WAV renderer · renderer.go Renderer abstraction
Components 19
CLI & configuration
- Executable entry
main.go - Command setup · Builds commands, configuration, and execution context.
cmd/cmd.go - CLI config
cmd/cfg.go - Command context
cmd/ctx.go - Root config
config.toml
Bleeder core
- Bleeder coordinator · Assembles parsing, rendering, and playback services.
internal/core/bleeder.go - Bleed source & context
internal/core/bleed.go - Bleed runtime context
internal/core/bleedctx.go - DSL parsers · Two evolving parser implementations translate bleed syntax.
internal/core/parser.go - Bleed examples
Audio pipeline
- Music IR · Canonical contract between DSL parsing and rendering.
internal/ir/ir.go - Renderer abstraction
internal/renderer/renderer.go - WAV renderer · Materializes rendered output as WAV.
internal/renderer/wav_renderer.go - Audio primitives · Notes, waveforms, and WAV encoding.
internal/audio/waves.go - WAV output
internal/audio/wav.go - Player abstraction
internal/player/player.go - WAV player
internal/player/wav_player.go
Live-coding surface
- VS Code extension · External editor-facing control surface for live coding.
extensions/bleeder-vscode/extension.js - Live-coding plan · Defines rapid update and audio lifecycle direction.
LIVE_CODING_PLAN.md
Connections 21
- Executable entry → Command setup: starts
- Command setup → CLI config: loads
- Command setup → Command context: creates
- CLI config → Root config: uses
- Command setup → Bleeder coordinator: dispatches to
- Bleed examples → Bleed source & context: provides
- Bleeder coordinator → Bleed source & context: reads
- Bleeder coordinator → Bleed runtime context: establishes
- Bleeder coordinator → DSL parsers: invokes
- DSL parsers → Music IR: produces
- Bleeder coordinator → Renderer abstraction: orchestrates
- Music IR → Renderer abstraction: renders
- Renderer abstraction → WAV renderer: implemented by
- WAV renderer → Audio primitives: synthesizes with
- Audio primitives → WAV output: encodes
- WAV renderer → WAV output: writes
- Bleeder coordinator → Player abstraction: orchestrates
- Player abstraction → WAV player: implemented by
- WAV output → WAV player: plays
- VS Code extension → Bleed source & context: edits
- Live-coding plan → VS Code extension: guides