Raspberry Pi Setup

mtrack is designed to run on small devices like the Raspberry Pi, making it perfect for portable live performance setups.

Hardware Requirements

  • Raspberry Pi 4 (2GB+ RAM) - Recommended for best performance
  • Raspberry Pi 3B+ - Works but may have limitations with many tracks
  • Raspberry Pi Zero 2 W - Minimal setup, fewer tracks

Audio Interface

Use a class compliant USB audio interface:

  • MOTU UltraLite-mk5 (tested)
  • Behringer interfaces (tested)
  • Any class compliant USB audio device

Storage

  • SD Card: Use a high-quality, fast SD card (Class 10, UHS-I or better)
  • USB Storage: For large song libraries, consider USB 3.0 external storage

Installation

Install Rust

1
2
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env

Install mtrack

1
2
cargo install mtrack --locked
sudo cp ~/.cargo/bin/mtrack /usr/local/bin/mtrack

Install Dependencies

1
2
3
4
5
6
7
8
9
# Audio dependencies
sudo apt-get update
sudo apt-get install -y \
    libasound2-dev \
    pkg-config \
    build-essential

# OLA for DMX (if using lighting)
sudo apt-get install -y ola ola-python

Performance Optimization

CPU Governor

Set CPU to performance mode:

1
sudo cpufreq-set -g performance

Make it permanent:

1
echo 'GOVERNOR="performance"' | sudo tee /etc/default/cpufrequtils

Audio Buffer Settings

Adjust buffer settings in your configuration for lower latency:

1
2
3
audio:
  buffer_size: 512      # Smaller buffer for lower latency
  buffer_threshold: 128 # Lower threshold

Note: Smaller buffers may cause dropouts on slower hardware. Test and adjust.

Disable Unnecessary Services

Disable services you don’t need:

1
2
sudo systemctl disable bluetooth
sudo systemctl disable wifi-powersave

Storage Optimization

Use Fast Storage

  • Use a fast SD card or USB 3.0 storage
  • Consider mounting song repository on USB storage for better performance

Optimize Audio Files

  • Use WAV format (no decoding overhead)
  • Use 44.1kHz sample rate (standard, lower CPU usage)
  • Avoid unnecessarily high bit depths if not needed

Network Setup

Set a static IP for reliable remote control:

1
sudo nano /etc/dhcpcd.conf

Add:

interface eth0
static ip_address=192.168.1.100/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1

WiFi Setup

If using WiFi, ensure stable connection:

1
2
# Disable power saving
sudo iwconfig wlan0 power off

Systemd Service

Set up mtrack to run as a service:

1
2
sudo mtrack systemd > /etc/systemd/system/mtrack.service
sudo nano /etc/default/mtrack

Add:

MTRACK_CONFIG=/path/to/mtrack.yaml

Enable and start:

1
2
sudo systemctl enable mtrack
sudo systemctl start mtrack

Power Management

Disable Screen Blanking

If using a display:

1
sudo nano /etc/lightdm/lightdm.conf

Add:

[Seat:*]
xserver-command=X -s 0 -dpms

USB Power

Ensure adequate power supply (especially with USB audio interfaces):

  • Use official Raspberry Pi power supply or equivalent
  • Consider powered USB hub for multiple devices

Troubleshooting

Audio Dropouts

  • Increase buffer sizes
  • Check CPU usage: htop
  • Disable unnecessary services
  • Use performance CPU governor

Slow Startup

  • Check SD card speed: sudo hdparm -tT /dev/mmcblk0
  • Consider faster storage
  • Reduce song repository size

Device Not Found

  • Check USB power supply
  • Try different USB port
  • Check dmesg for USB errors
  • Verify device is class compliant

Example Configuration

Optimized configuration for Raspberry Pi:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
songs: /mnt/usb/songs
playlist: /mnt/usb/playlist.yaml

audio:
  device: bcm2835 Headphones  # Or your USB interface
  buffer_size: 1024
  buffer_threshold: 256
  sample_rate: 44100
  sample_format: int
  bits_per_sample: 32

midi:
  device: YourMIDIDevice

track_mappings:
  click: [1]
  cue: [2]
  # ... your tracks