Table of Contents

1. System Overview & Architecture

Radio Controller is a high-availability internet radio automation daemon built in Rust using Tokio asynchronous tasks. It acts as an autonomous audio director connecting local audio libraries, preemptive event triggers, and remote TeamTalk 5 live studios into an uninterrupted stream.

Zero-Dropout Continuous Streaming

Standard radio automation scripts typically terminate and restart their output stream on every song change or live input switch. This causes audio dropouts, socket disconnects, and listener buffering stalls. Radio Controller solves this by maintaining a persistent raw PCM audio pipeline piped into an internal FFmpeg transcoder and Icecast 2 mountpoint.

Bidirectional Smooth Crossfading

Song transitions feature smooth 3-second (configurable) crossfading. When switching between playlist music and the TeamTalk live studio (ttliveon and ttliveoff), the active source smoothly fades out while the incoming source softly enters without interrupting the audio stream.

Real-Time Wall-Clock Pacing

Audio chunk generation is actively synchronized against the server's monotonic wall clock. This prevents audio underruns or burst flooding of the Icecast listener queue.

2. Server Prerequisites & Ports

  • Operating System: Ubuntu 22.04 LTS (Jammy) or Ubuntu 24.04 LTS (Noble) 64-bit (x86_64). Also compatible with Debian 11/12.
  • Minimum Hardware: 1 vCPU, 512 MB RAM, 5 GB disk storage.
  • Recommended Hardware: 2 vCPU, 1–2 GB RAM, 20+ GB storage for music library.
  • Network Ports to Open:
    • 8000 TCP: Icecast 2 audio streaming port.
    • 10333 TCP & UDP: TeamTalk 5 server communication port.
    • 80 & 443 TCP: Public HTTP/HTTPS web traffic and Let's Encrypt SSL.

3. Step-by-Step Installation on Ubuntu

Follow these steps to deploy Radio Controller onto a fresh Ubuntu server:

# 1. Connect to your server as root
ssh root@YOUR_SERVER_IP

# 2. Create the target application directory
mkdir -p /home/radio/radio_controller
cd /home/radio/radio_controller

# 3. Extract the release archive into this directory
# (or transfer Radio_Controller_v1.0_Linux_x64.zip and unzip)
unzip Radio_Controller_v1.0_Linux_x64.zip

# 4. Make scripts and binaries executable
chmod +x scripts/*.sh bin/*

# 5. Run the automated dependency installer
# This installs FFmpeg, Icecast2, PulseAudio, sets up the 'radio' user,
# and enables lingering sessions (loginctl enable-linger radio)
sudo bash scripts/install-ubuntu-deps.sh

# 6. Set directory ownership
sudo chown -R radio:radio /home/radio/radio_controller
sudo chmod -R 755 /home/radio/radio_controller

4. Icecast 2 Server Configuration

Icecast 2 broadcasts the encoded audio stream to web listeners and audio players.

# 1. Back up existing configuration
sudo cp /etc/icecast2/icecast.xml /etc/icecast2/icecast.xml.bak

# 2. Copy the production template from the release package
sudo cp /home/radio/radio_controller/config/icecast.example.xml /etc/icecast2/icecast.xml

# 3. Edit /etc/icecast2/icecast.xml and set secure passwords:
sudo nano /etc/icecast2/icecast.xml

Configure the <authentication> block:

<authentication>
    <source-password>YOUR_SECURE_SOURCE_PASSWORD</source-password>
    <relay-password>YOUR_SECURE_RELAY_PASSWORD</relay-password>
    <admin-user>admin</admin-user>
    <admin-password>YOUR_SECURE_ADMIN_PASSWORD</admin-password>
</authentication>
# 4. Restart and enable Icecast
sudo systemctl restart icecast2
sudo systemctl enable icecast2

5. Master Configuration Reference (radio-controller.toml)

Copy the configuration template and customize your settings:

cp config/radio-controller.example.toml radio-controller.toml
nano radio-controller.toml
[station]
name = "My Radio Station"
description = "24/7 Automated Internet Radio"
genre = "Mixed"
url = "https://resonova.dev"

[icecast]
ffmpeg_path = "ffmpeg"
source_url = "icecast://source:YOUR_SOURCE_PASSWORD@127.0.0.1:8000/live.ogg"
admin_url = "http://127.0.0.1:8000/admin/metadata"
mount = "/live.ogg"
admin_username = "admin"
admin_password = "YOUR_ADMIN_PASSWORD"
codec = "ogg"
bitrate_kbps = 128
sample_rate = 48000
channels = 2

[playlist]
folders = ["./playlist"]
play_mode = "random"           # "random" or "sequential"
autostart = true
crossfade_seconds = 3
extensions = ["mp3", "ogg", "flac", "wav", "m4a", "aac"]

[teamtalk]
enabled = true
host = "127.0.0.1"
tcp_port = 10333
udp_port = 10333
encrypted = false
nickname = "RadioBot"
username = "radiobot"
password = "BOT_PASSWORD"
command_prefix = "!"
channel_name = "/Studio"
remember_last_channel = true
relay_sample_rate = 48000
relay_channels = 2
relay_include_mediafile_audio = true
relay_metadata = "TeamTalk Studio Live"

# Security & Access Control
admin_only = true              # Restricts bot commands to TeamTalk administrators
admin_users = []               # Optional additional authorized usernames

6. Systemd Service Setup (24/7 Autostart)

Install the systemd unit file to ensure the radio starts at boot and recovers from any unexpected errors:

# Copy unit file
sudo cp /home/radio/radio_controller/systemd/Radio.service /etc/systemd/system/Radio.service

# Reload systemd and start the service
sudo systemctl daemon-reload
sudo systemctl enable Radio.service
sudo systemctl start Radio.service

# Verify service health
sudo systemctl status Radio.service

7. Production SSL/HTTPS Reverse Proxy (Apache & Nginx)

Modern browsers block direct HTTP streams on HTTPS websites due to Mixed Content restrictions. Additionally, standard web proxy buffering can introduce lag and playback stalls. Use these reverse proxy snippets with instant packet flushing:

Apache 2 VirtualHost Configuration

# Enable proxy modules
sudo a2enmod proxy proxy_http ssl headers

# Add inside your <VirtualHost *:443> block:
ProxyPreserveHost Off
ProxyPass "/radio/" "http://127.0.0.1:8000/" flushpackets=on disablereuse=on
ProxyPassReverse "/radio/" "http://127.0.0.1:8000/"

Reload Apache: sudo systemctl reload apache2. Stream URL: https://your-domain.com/radio/live.ogg

Nginx Configuration

# Inside your server { listen 443 ssl; ... } block:
location /radio/ {
    proxy_pass http://127.0.0.1:8000/;
    proxy_set_header Host $host;
    proxy_buffering off;
    proxy_ignore_client_abort off;
    proxy_read_timeout 86400s;
    proxy_send_timeout 86400s;
}

Reload Nginx: sudo nginx -t && sudo systemctl reload nginx

8. TeamTalk 5 Studio Relay & Bot Commands

Authorized operators can manage playback, adjust volume, trigger events, or switch to live studio mode via TeamTalk text chat. Commands can be sent in channel (e.g. !play) or in private message without prefix.

Security Restriction

When admin_only = true is set, only users logged in as TeamTalk administrators (or listed in admin_users) can execute commands. Unauthorized commands are rejected and notify the sender via private message.

  • playStart or resume playlist playback
  • pausePause current audio source
  • xToggle pause and resume
  • stopStop all active audio playback
  • nSkip to next playlist track
  • bPrevious playlist track
  • v <0..100>Set player volume (e.g. v 80)
  • mr <0..100>Set TeamTalk studio master relay volume
  • ttliveonSwitch smoothly to TeamTalk live studio relay
  • ttliveoffLeave studio relay and return to playlist with soft crossfade
  • channelShow the current TeamTalk channel
  • join <name>Move the bot to a specified channel
  • rescanHot-rescan playlist folder without restarting the radio
  • neweventInteractive wizard to create a scheduled event
  • newstreamInteractive wizard to update Icecast stream parameters
  • statusDisplay engine uptime and stream status
  • helpSend complete command reference in chat

9. Media & Playlist Management

Upload audio files via SFTP or SCP into /home/radio/radio_controller/playlist/music/. Subfolders are indexed recursively (e.g. music/Pop, music/Rock, music/80s).

Hot Rescan: After copying new music tracks, you do NOT need to restart the radio service! Simply send the command rescan to the bot. The playlist updates immediately with zero interruption to current playback.

Supported Formats: MP3, OGG, FLAC, WAV, M4A, AAC.

10. Operations, Logs & Troubleshooting

Monitoring Live Service Logs

sudo journalctl -u Radio.service -f -n 100

Monitoring Icecast Logs

tail -f /var/log/icecast2/error.log
tail -f /var/log/icecast2/access.log

Common Issues & Solutions

  • Missing Library (libTeamTalk5.so): Verify that libTeamTalk5.so is present in /home/radio/radio_controller/lib/. You can also copy it system-wide: sudo cp lib/libTeamTalk5.so /usr/local/lib/ && sudo ldconfig.
  • Connection Refused (127.0.0.1:8000): Ensure Icecast 2 is running (sudo systemctl status icecast2) and the source password in radio-controller.toml matches <source-password> in /etc/icecast2/icecast.xml.
  • Audio Halts When SSH Disconnects: Ensure user lingering is enabled for the radio user: sudo loginctl enable-linger radio.