How kris-gupta/sonata works
Sonata is a command-line audio streamer: a user supplies a media URL, the program resolves an audio URL with yt-dlp, downloads byte ranges, decodes the audio, and plays samples through the system audio device. Its main implementation is concentrated in src/main.rs, with reader and buffer types in src/audio/reader.rs. A small terminal UI is also present, but the sampled entry point does not show it being connected to playback. The README is empty, and excerpts omit some orchestration details, so only supported runtime links are shown.
Main entry points: main.rs CLI orchestration · reader.rs Streaming buffers
Components 13
Entry and orchestration
- CLI orchestration
src/main.rs - yt-dlp resolver
Streaming and decode
- Range fetcher
src/main.rs - Chunk iterator
src/audio/reader.rs - Streaming buffers
src/audio/reader.rs - Audio decoder
src/main.rs - Media source reader
src/audio/reader.rs - Decoded sample buffers
src/audio/reader.rs
Playback and interface
- Audio playback
src/main.rs - Terminal UI
src/audio/tui.rs
Other components
- User
- Media host
- Audio output device
Connections 14
- User → CLI orchestration: provides URL
- CLI orchestration → yt-dlp resolver: resolves stream
- yt-dlp resolver → CLI orchestration: returns audio URL
- CLI orchestration → Range fetcher: starts thread
- CLI orchestration → Audio decoder: starts thread
- CLI orchestration → Audio playback: starts thread
- Range fetcher → Media host: requests byte ranges
- Range fetcher → Chunk iterator: iterates chunks
- Range fetcher → Streaming buffers: writes bytes
- Audio decoder → Streaming buffers: reads bytes
- Audio decoder → Media source reader: builds media source
- Audio decoder → Decoded sample buffers: writes samples
- Audio playback → Decoded sample buffers: reads samples
- Audio playback → Audio output device: outputs audio