# Broadcaster Software (icecast and darkice)
## Summary
User: grace
Hostname: portal.local
Password: emergence
Running icecast and darkice. 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
sudo apt update && install git vim zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

### Icecast2 and Darkice installation
Follow this tutorial: https://dev.to/shilleh/stream-audio-from-raspberry-pi-to-local-computer-1a1c


#### Install icecast2
sudo apt install icecast2 

It will ask you for three passwords. Set them all as emergence.


#### Install darkice
sudo apt install darkice

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 = 8000 # 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

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
```

sudo systemctl daemon-reload

sudo systemctl enable icecast2

sudo systemctl enable darkice

