kdoren / jambox-pi-gen

Start jamming online easily with a Raspberry Pi, an audio interface, and this free Jambox image file. Just download/burn/boot/jam. Choose from multiple jamming apps: Jamulus, SonoBus, JackTrip, JamTaba, JammerNetz or HpsJam. User interface is any web browser on same local network. Pre-built image file is available under "Releases".
BSD 3-Clause "New" or "Revised" License
75 stars 9 forks source link
hpsjam jacktrip jammernetz jamming jamtaba jamulus ninjam raspberry-pi sonobus

Jambox

A Raspberry Pi micro-SD card image for online jamming.
Pre-built image file is available under "Releases" to download and burn with balenaEtcher
Runs Jamulus (client-server), SonoBus (peer-to-peer), JamTaba (NINJAM), JackTrip, JammerNetz (client-server) or HpsJam (client-server) on Raspberry Pi.
Web Browser UI - use any laptop, tablet, desktop - even a smartphone.

Features



Easy to Setup

  1. Download image file from "Releases" (https://github.com/kdoren/jambox-pi-gen/releases). No need to unzip.
  2. Flash micro SD card using balenaEtcher.
  3. (optional) customize settings after burning by editing/adding files in /boot/payload directory.
  4. Works with most USB audio interfaces and audio HAT cards. Some interfaces may require changes to settings files.
  5. Connect wires: ethernet, USB audio interface, mic/instrument, headphones and power.
  6. Headphone amp may be needed (i.e. Rockville RHPA-4) depending on your audio interface.

Easy to Use

  1. Power on, boot up.
  2. Raspberry Pi will acquire a local IP address and register its access URL with urlrelay.com
  3. From any web browser on same local network (i.e. laptop or tablet), access Raspberry Pi UI via urlrelay.com/go
  4. Web browser will show Raspberry Pi desktop.
  5. Jamulus or SonoBus can be set to automatically launch at startup.
  6. If JAMULUS_SERVER is set, Jamulus will automatically connect (and shutdown after JAMULUS_TIMEOUT minutes)
  7. Double-click on a jamming app desktop icon:
    • "Jamulus Start" to launch Jamulus.
    • "SonoBus Start" to launch SonoBus.
    • "JamTaba Start" to launch JamTaba.
    • "JackTrip Start" to launch JackTrip.
    • "JammerNetz Start" to launch JammerNetz Client.
    • "HpsJam Start" to launch HpsJam Client
  8. Double-click on desktop icon "Off Switch" to shut down Raspberry Pi.

Simple hardware platform

Raspberry Pi + Audio Interface. 2GB Raspberry Pi is OK for jamming; 4GB model costs slightly more and allows flexibility for other purposes later. Can be attached to a board with velcro and pre-wired for easy setup.

Suggested Bill of Materials, prices in USD as of Nov 27, 2021:

Price (USD) Item URL
$ 46 Raspberry Pi 4-2GB https://vilros.com/products/raspberry-pi-4-2gb-ram
14 Vilros Self Cooling Heavy Duty Case https://vilros.com/products/vilros-raspberry-pi-4-compatible-self-cooling-heavy-duty-aluminum-case
11 Vilros Power Supply with Switch https://vilros.com/products/vilros-usb-c-5v-3a-power-supply-with-switch-designed-for-pi-4
8 SanDisk Ultra 16GB micro SD card https://www.amazon.com/gp/product/9966573445
45 Behringer UM2 USB Audio Interface https://www.americanmusical.com/behringer-u-phoria-um2-usb-audio-interface/p/BEH-UM2
18 Pyle PDMIC78 Microphone https://www.amazon.com/gp/product/B005BSOVRY
12 XLR Microphone Cable, 15 ft https://www.amazon.com/gp/product/B004UJHXUC
22 Microphone Stand w/clip https://www.amazon.com/gp/product/B00OZ9C9LK
? Over-ear Headphones Use decent ones (likely $40 or more)

Customizable Settings

Name Value Default File
urlrelay settings
NODE_ID id unique for your local network 1 /etc/urlrelay/urlrelay.conf
URL_ARGS url arguments sent to noVNC /?password=jambox /etc/urlrelay/urlrelay.conf
Jamulus Settings
JAMULUS_AUTOSTART set to 1 to launch on boot 0 /home/pi/.config/Jamulus/jamulus_start.conf
JAMULUS_SERVER DNS name or IP of Jamulus server /home/pi/.config/Jamulus/jamulus_start.conf
JAMULUS_TIMEOUT shutdown timer if auto-connecting 120m /home/pi/.config/Jamulus/jamulus_start.conf
AJ_SNAPSHOT filename of alsa-jack patch configuration ajs-jamulus-stereo.xml /home/pi/.config/Jamulus/jamulus_start.conf
MASTER_LEVEL master output level for audio interface 80% /home/pi/.config/Jamulus/jamulus_start.conf
CAPTURE_LEVEL capture level for audio interface 80% /home/pi/.config/Jamulus/jamulus_start.conf
SonoBus Settings
SONOBUS_AUTOSTART set to 1 to launch on boot 0 /home/pi/.config/sonobus_start.conf
AJ_SNAPSHOT filename of alsa-jack patch configuration ajs-sonobus-stereo.xml /home/pi/.config/sonobus_start.conf
MASTER_LEVEL master output level for audio interface 80% /home/pi/.config/sonobus_start.conf
CAPTURE_LEVEL capture level for audio interface 80% /home/pi/.config/sonobus_start.conf
Jack Settings
DEVICE alsa device ID of audio interface last capture device /etc/jackdrc.conf
PERIOD Jack Audio samples per period 64 [pi4] or 128 [pi3] /etc/jackdrc.conf
NPERIODS Jack Audio number of periods per buffer 3 [pi4] or 3 [pi3] /etc/jackdrc.conf
Jamulus Server Settings see file /home/pi/.config/Jamulus/jamulus-server.conf
JammerNetz Client Settings see file /home/pi/JammerNetz/jammernetz_start.conf
JammerNetz Server Settings see file /home/pi/JammerNetz/jammernetz-server.conf
HpsJam Client Settings see file /home/pi/.config/hpsjam_start.conf
HpsJam Server Settings see file /home/pi/.config/hpsjam-server.conf

Web Browser access to Raspberry Pi Desktop - How it works

urlrelay + noVNC = easy web browser access to Raspberry Pi desktop, without installing anything or knowing its IP address

urlrelay
  1. Raspberry PI on wired ethernet gets private IP address on local network assigned by router (DHCP), but we don't know what it is.
  2. urlrelay service running on Raspberry Pi registers its private IP access URL with urlrelay.com (web service in AWS)
  3. urlrelay.com stores this URL using source IP (public IP of router) as primary key
  4. urlrelay.com uses NODE_ID (default: "1") as secondary key
  5. If only a single device is registered for a local network (source IP), NODE_ID doesn't matter. From web browser on same local network (same source IP), urlrelay.com/go will redirect to Raspberry Pi.
  6. If >1 device exists on same local network, NODE_ID of each device should be different, then access via urlrelay.com/go?id=
  7. Recommended practice is to assign a different id to each micro SD card after flashing (in boot: /payload/etc/urlrelay/urlrelay.conf, i.e. NODE_ID=11), and place a label on each box with full URL "urlrelay.com/go?id=11"
  8. NODE_ID can be set after flashing (booting not required). In boot: partition, edit file /payload/etc/urlrelay/urlrelay.conf
  9. urlrelay.com deletes stale registrations after a set time (currently 30 days)
noVNC
  1. Web browser on same local network gets URL as a redirect from urlrelay.com
  2. noVNC is a VNC client written in Javascript which runs in web browser
  3. noVNC js code is served to browser from Raspberry Pi by a mini-http server on port 6080
  4. noVNC running in browser makes websocket connection to Rasbpberry Pi
  5. websockify (companion to noVNC) bridges websocket to VNC server
  6. Raspberry Pi runs VNC server presenting linux desktop

Original pi-gen README.md follows:

pi-gen

Tool used to create Raspberry Pi OS images. (Previously known as Raspbian).

Dependencies

pi-gen runs on Debian-based operating systems. Currently it is only supported on either Debian Buster or Ubuntu Xenial and is known to have issues building on earlier releases of these systems. On other Linux distributions it may be possible to use the Docker build described below.

To install the required dependencies for pi-gen you should run:

apt-get install coreutils quilt parted qemu-user-static debootstrap zerofree zip \
dosfstools bsdtar libcap2-bin grep rsync xz-utils file git curl bc

The file depends contains a list of tools needed. The format of this package is <tool>[:<debian-package>].

Config

Upon execution, build.sh will source the file config in the current working directory. This bash shell fragment is intended to set needed environment variables.

The following environment variables are supported:

A simple example for building Raspbian:

IMG_NAME='Raspbian'

The config file can also be specified on the command line as an argument the build.sh or build-docker.sh scripts.

./build.sh -c myconfig

This is parsed after config so can be used to override values set there.

How the build process works

The following process is followed to build images:

It is recommended to examine build.sh for finer details.

Docker Build

Docker can be used to perform the build inside a container. This partially isolates the build from the host system, and allows using the script on non-debian based systems (e.g. Fedora Linux). The isolate is not complete due to the need to use some kernel level services for arm emulation (binfmt) and loop devices (losetup).

To build:

vi config         # Edit your config file. See above.
./build-docker.sh

If everything goes well, your finished image will be in the deploy/ folder. You can then remove the build container with docker rm -v pigen_work

If something breaks along the line, you can edit the corresponding scripts, and continue:

CONTINUE=1 ./build-docker.sh

To examine the container after a failure you can enter a shell within it using:

sudo docker run -it --privileged --volumes-from=pigen_work pi-gen /bin/bash

After successful build, the build container is by default removed. This may be undesired when making incremental changes to a customized build. To prevent the build script from remove the container add

PRESERVE_CONTAINER=1 ./build-docker.sh

There is a possibility that even when running from a docker container, the installation of qemu-user-static will silently fail when building the image because binfmt-support must be enabled on the underlying kernel. An easy fix is to ensure binfmt-support is installed on the host machine before starting the ./build-docker.sh script (or using your own docker build solution).

Stage Anatomy

Raspbian Stage Overview

The build of Raspbian is divided up into several stages for logical clarity and modularity. This causes some initial complexity, but it simplifies maintenance and allows for more easy customization.

Stage specification

If you wish to build up to a specified stage (such as building up to stage 2 for a lite system), place an empty file named SKIP in each of the ./stage directories you wish not to include.

Then add an empty file named SKIP_IMAGES to ./stage4 and ./stage5 (if building up to stage 2) or to ./stage2 (if building a minimal system).

# Example for building a lite system
echo "IMG_NAME='Raspbian'" > config
touch ./stage3/SKIP ./stage4/SKIP ./stage5/SKIP
touch ./stage4/SKIP_IMAGES ./stage5/SKIP_IMAGES
sudo ./build.sh  # or ./build-docker.sh

If you wish to build further configurations upon (for example) the lite system, you can also delete the contents of ./stage3 and ./stage4 and replace with your own contents in the same format.

Skipping stages to speed up development

If you're working on a specific stage the recommended development process is as follows:

Troubleshooting

64 Bit Systems

Please note there is currently an issue when compiling with a 64 Bit OS. See https://github.com/RPi-Distro/pi-gen/issues/271

binfmt_misc

Linux is able execute binaries from other architectures, meaning that it should be possible to make use of pi-gen on an x86_64 system, even though it will be running ARM binaries. This requires support from the binfmt_misc kernel module.

You may see the following error:

update-binfmts: warning: Couldn't load the binfmt_misc module.

To resolve this, ensure that the following files are available (install them if necessary):

/lib/modules/$(uname -r)/kernel/fs/binfmt_misc.ko
/usr/bin/qemu-arm-static

You may also need to load the module by hand - run modprobe binfmt_misc.