5.7 KiB
5.7 KiB
Echoion Music Bot - System Overview
What is Echoion?
Echoion is a modern music bot for TeamSpeak 3 that plays music from YouTube and other sources directly into voice channels. It features high-quality audio, playlist management, and a unique hot-reload capability that allows updating the bot without disconnecting from the server.
System Architecture
graph TB
subgraph "User Interfaces"
TS[TeamSpeak Client]
DT[Desktop Client<br/>Qt6 Application]
end
subgraph "Echoion System"
PL[EchoionPlugin<br/>TeamSpeak Plugin]
CL[CoreLoader<br/>Dynamic Loader]
CO[EchoionCore<br/>Music Engine]
API[EchoionApi<br/>Shared Interfaces]
end
subgraph "External Services"
YT[YouTube<br/>via yt-dlp]
DB[(SQLite<br/>Database)]
end
TS <-->|TS3 SDK| PL
DT <-->|WebSocket RPC| CO
PL <-->|Hot Reload| CL
CL <-->|Load/Unload| CO
PL <-->|ICoreInterface| CO
CO <-->|IPluginInterface| PL
CO -->|Stream| YT
CO -->|Persist| DB
API -.->|Types/Interfaces| PL
API -.->|Types/Interfaces| CO
API -.->|Types/Interfaces| DT
Component Responsibilities
EchoionApi (The Contract)
Provides the shared language between all components:
- Data types (tracks, queues, playback state)
- Interfaces (how components talk to each other)
- Utilities (caching, events, database access)
EchoionCore (The Brain)
The main music engine that handles:
- Fetching music from YouTube
- Decoding audio with FFmpeg
- Managing the playback queue
- Processing user commands
- Serving the WebSocket API for desktop clients
Key feature: Can be updated while running (hot reload)
EchoionPlugin (The Bridge)
Connects EchoionCore to TeamSpeak:
- Receives chat messages from users
- Sends audio to TeamSpeak's voice system
- Manages server connections
- Handles user events (join/leave/move)
EchoionDesktop (The Remote)
A separate Qt6 application that:
- Connects to EchoionCore via WebSocket
- Provides a graphical control interface
- Shows playback status and queue
- Allows remote administration
How Components Communicate
Plugin ↔ Core Communication
The Plugin and Core talk through well-defined interfaces:
sequenceDiagram
participant User
participant TS as TeamSpeak
participant PL as Plugin
participant CO as Core
User->>TS: Type !play song
TS->>PL: onTextMessage
PL->>CO: onPluginEvent
CO->>CO: CommandManager
CO->>PL: sendTextMessage("Playing...")
PL->>TS: Display message
CO->>PL: sendAudioData (continuous)
PL->>TS: Voice transmission
TS->>User: Hear music
Desktop Client Communication
The Desktop app connects remotely:
sequenceDiagram
participant UI as Desktop UI
participant CC as CoreClient
participant RS as RpcServer
participant MM as MusicManager
UI->>CC: Click Play
CC->>RS: WebSocket: play
RS->>MM: Execute command
MM->>RS: Broadcast: playbackStarted
RS->>CC: Event notification
CC->>UI: Update display
Data Flow Overview
Playing a Song
flowchart LR
A[User Command] --> B[CommandManager]
B --> C{YouTube URL?}
C -->|Yes| D[Extract ID]
C -->|No| E[Search YouTube]
E --> F[Select Video]
D --> G[Get Stream URL]
F --> G
G --> H[Queue Track]
H --> I{Playing?}
I -->|No| J[Start Playback]
I -->|Yes| K[Wait in Queue]
J --> L[FFmpeg Decode]
L --> M[Apply Volume]
M --> N[Send to TS]
Audio Pipeline
flowchart TB
subgraph "Source"
YT[YouTube/URL]
end
subgraph "Processing"
NC[NetworkClient<br/>Download stream]
AD[AudioDecoder<br/>FFmpeg decode]
MM[MusicManager<br/>Volume/Queue]
end
subgraph "Output"
PI[PluginInterface]
TS[TeamSpeak Voice]
end
YT --> NC
NC --> AD
AD -->|Float PCM| MM
MM -->|Int16 PCM| PI
PI --> TS
Key Features
Hot Reload
Unlike traditional bots, Echoion can update its core logic without disconnecting:
sequenceDiagram
participant PL as Plugin
participant CL as CoreLoader
participant Old as Old Core
participant New as New Core
PL->>CL: Trigger reload
CL->>Old: Save state<br/>Queue, Position, Config
CL->>Old: Unload library
CL->>New: Load new library
CL->>New: Restore state
New->>PL: Resume playback
Multi-Client Support
Three ways to interact with the bot:
- TeamSpeak Chat - Type commands in channel
- Desktop App - Graphical interface via WebSocket
- Future: Web Interface - Same RPC protocol
High-Quality Audio
- Supports up to 48kHz stereo
- Hardware acceleration (CUDA, VAAPI, etc.)
- Efficient memory pooling
- Minimal audio latency
Technology Stack
| Purpose | Technology |
|---|---|
| Language | C++23 |
| Build | CMake 3.28+ |
| JSON | Glaze |
| Networking | Boost.Asio/Beast |
| Audio | FFmpeg |
| YouTube | yt-dlp |
| Database | SQLite3 |
| Desktop GUI | Qt6 |
| Plugin SDK | TeamSpeak 3 |
Directory Structure
Echoion/
├── EchoionApi/ # Shared interfaces & types
├── EchoionCore/ # Music engine (hot-reloadable)
├── EchoionPlugin/ # TeamSpeak plugin wrapper
├── EchoionDesktop/ # Qt6 control client
├── docs/ # This documentation
├── config.example.json # Example configuration
└── CMakeLists.txt # Build configuration
Next Steps
- Learn about the Shared API Layer
- Understand the Core Music Logic
- Explore TeamSpeak Integration
- See Data Flows in detail