# Broadcaster Software (icecast and darkice)

## Summary

User: grace
Hostname: portal.local
Password: emergence
Running icecast (port 80) and darkice with Namecheap Dynamic DNS for external access. See icecast-darkice.md for setup instructions.

## Bill of Materials

- Raspberry pi 4b (1 gig ram) - https://www.sparkfun.com/raspberry-pi-4-model-b-1gb.html
- 3 x USB to XLR sound card cable - https://www.amazon.com/dp/B089WFYZ5R?ref=ppx_yo2ov_dt_b_fed_asin_title&th=1
- 3 x XLR microphones -
- Raspberry pi 4 Power supply - https://www.waveshare.com/pi-psu-us-w.htm
- ethernet cable - https://hosatech.com/products/data/network-cable/cat-500/
- micro hdmi to regular hdmi cable- https://www.waveshare.com/pi-official-micro-hdmi-cable-1m.htm

## Hardware setup

- Plug the mic into the the usb cable
- Plug the usb cable into the pi
- Plug the pi into the wall

## Pre work

1. install raspian lite 64 for raspi model 4b
2. configure user and wifi and turn on ssh services when you install
3. boot
4. find the ip address of the pi and ssh to it

## Setup instructions

### Creature comforts

1. sudo apt update && install git vim zsh
2. sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

### Icecast2 and Darkice installation

Loosely following this tutorial: https://dev.to/shilleh/stream-audio-from-raspberry-pi-to-local-computer-1a1c

#### Install icecast2

1. sudo apt install icecast2
2. It will ask you for three passwords. Set them all as emergence.

#### Install darkice

1. sudo apt install darkice
2. sudo vim /etc/darkice.cfg

```
[general]
duration = 0 # Stream indefinitely
bufferSecs = 5 # Buffer for the input, in seconds
reconnect = yes # Reconnect to the server if disconnected

[input]
device = plughw:1,0 # Your audio capture device
sampleRate = 44100
bitsPerSample = 16 # Bits per sample
channel = 1 # 2 = stereo, 1 = mono

[icecast2-0]
bitrateMode = cbr # Constant bit rate
format = mp3 # Audio format
bitrate = 128 # Bitrate in kbps
server = localhost # Server name or IP
port = 80 # Port number
password=emergence # Your Icecast password
mountPoint = portal # Mount point to stream to
name = Black Portal # Name of the stream
description = Black Portal Project # Description of the stream
url = http://blackportaldetroit.com # URL related to the stream
genre = politics # Genre of the stream
public = no # Do not list on public lists
```

#### Daemonize darkice

1. sudo vim /lib/systemd/system/darkice.service

```
[Unit]
Description=Darkice Service
[Service]
User=root
Type=simple
Restart=on-failure
RestartSec=5
WorkingDirectory=/home/grace
ExecStart=/usr/bin/darkice -c /etc/darkice.cfg
[Install]
WantedBy=multi-user.target
```

2. sudo systemctl daemon-reload
3. sudo systemctl enable icecast2
4. sudo systemctl enable darkice

### Dynamic DNS Configuration (Automated)

The install script automatically configures Namecheap Dynamic DNS to make the stream accessible at blackportaldetroit.com without requiring a static IP address.

#### What gets installed:

- **ddclient** - Updates your domain's IP address automatically
- **Configuration file** - Pre-configured for Namecheap at `/etc/ddclient.conf`
- **Systemd service** - Runs ddclient as a background service
- **Icecast on port 80** - Eliminates need for router port forwarding

#### Manual steps required after installation:

1. **In Namecheap account**: Enable Dynamic DNS for blackportaldetroit.com
2. **Add DNS record**: Create an "A + Dynamic DNS" record for "@" (root domain)
3. **Get password**: Note the Dynamic DNS password from Namecheap
4. **Update config**: Edit `/etc/ddclient.conf` and replace `REPLACE_WITH_NAMECHEAP_DDNS_PASSWORD`
5. **Start service**: Run `sudo systemctl start ddclient`
6. **No router setup needed** - icecast runs directly on port 80

#### Verify Dynamic DNS is working:

```bash
# Check ddclient status
sudo systemctl status ddclient

# View ddclient logs
sudo journalctl -u ddclient -f

# Test DNS resolution
nslookup blackportaldetroit.com
```
