• Stars
    star
    106
  • Rank 325,871 (Top 7 %)
  • Language
    C++
  • License
    GNU General Publi...
  • Created over 7 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Morrolinux's Pirate radio (PiFmRDS / PiFmAdv implementation with Bluetooth and mp3 support) - Stream music to your car's FM radio or use it as a Bluetooth speaker via headphone jack

mpradio

Morrolinux's Pirate radio (PiFmRDS implementation with Bluetooth and mp3 support) for all Raspberry Pi models. Exclusively tested on Minimal Raspbian (ARM).

Discontinued

mpradio has been redesigned and wrote from scratch in python. We moved here

Features

  • Resume track from its playback status hh:mm:ss across reboots (CD-like expirience)
  • Shuffle on/off
  • Customizable scrolling RDS to overcome 8-chars limitation
  • Skip to the next song by pressing a push-button (GPIO-connected on pin 18)
  • Safely shutdown by holding the push-button (GPIO-connected on pin 18)
  • Stream audio over FM or 3.5mm Jack (Bluetooth speaker via jack audio output)
  • Send mp3 files or zip/rar albums to the Pi via Bluetooth
  • Bluetooth OTA file management on the Pi with applications such as "Bluetooth Explorer Lite"
  • Read metadata from the mp3 files
  • Multiple file format support [mp3/wav/flac]
  • Read Only mode for saving sdcard from corruption when unplugging AC
  • PiFmAdv (optional)(experimental) implementation for better signal purity
  • Control pipe commands during playback (explained below)
  • Update just mpradio by sending mpradio-master.zip via Bluetooth (Update via App will be soon available)
  • Bluetooth companion app for android (Work in progress...)
  • Display Android notifications over RDS?
  • Automatically partition the sdcard for a dedicated mp3 storage space (instead of using a USB drive)

Known issues

  • Due to a design flaw in BCM43438 WIFI/BT chipset, you might need to disable WiFi if you experience BT audio stuttering on Pi Zero W and Pi 3: raspberrypi/linux#1402
  • Boot can take as long as 1m30s on the Pi 1 and 2 due to BT UART interface missing on the board. Reducing systemd timeout with echo "DefaultTimeoutStartSec=40s" >> /etc/systemd/system.conf should help

Installation

First make sure your Raspbian is up to date:

sudo apt-get update && sudo apt-get -y full-upgrade && sudo apt-get -y install git

git clone https://github.com/morrolinux/mpradio.git mpradio-master

cd mpradio-master/install && sudo ./install.sh

OR

You can just download and flash a full raspbian-mpradio.img image from here. Be aware even the "latest" image could be "not so latest", but certainly will work. Just wait for it to reboot twice on first use.

Configuration

By default, mpradio will always be running automatically after boot once installed. No additional configuration is needed. However, you can change the FM streaming frequency (which is otherwise defaulted to 107.0) by placing a file named pirateradio.config in the root of a USB key (which of course, will need to stay plugged for the settings to be permanent)

pirateradio.config example:

[PIRATERADIO]
frequency=107.0
btGain=1.7            		;gain setting for bluetooth streaming
storageGain=1         		;gain setting for stored files streaming
output=fm			;[fm/analog] for FM output or 3.5 mm jack output
btBoost=false		        ;Enhance Bluetooth audio. This might add a little latency
implementation=pi_fm_rds	;[pi_fm_rds/pi_fm_adv] - pi_fm_adv has a much cleaner sound

[PLAYLIST]
persistentPlaylist=true		;do not play tracks twice unless all of them have already been played
resumePlayback=true   		;(resume track from where it was upon reboot) require persistentPlaylist to be enabled
shuffle=true 
fileFormat=all          	;which file formats to search for. [mp3/flac/wav/all]

[RDS]
updateInterval=3      				;seconds between RDS refresh. lower values could result in RDS being ignored by your radio receiver
charsJump=6           				;how many characters should shift between updates [1-8]
rdsPattern=$ARTIST_NAME - $SONG_NAME		;Pattern which is passed to eval() to produce title EG: $SONG_YEAR - $ALBUM_NAME

Optional: Protect your SD card from corruption by setting Read-Only mode.

use utility/roswitch.sh as follows:

sudo bash roswitch.sh ro to enable read-ony (effective from next boot)

sudo bash roswitch.sh rw to disable read-only (effective immediately)

Usage

It (should) work out of the box. You need your mp3 files to be on a FAT32 USB stick (along with the pirateradio.config file if you want to override the default settings). You can safely shut down the Pi by holding the push button or via App, and waiting for about 5 seconds until the status LED stops blinking. If you enabled "persistentPlaylist" option, your Pi will never play the same song twice before consuming the full playlist. This means if you add new songs on the USB stick, with "persistentPlaylist" enabled they won't be played until the current playlist is consumed. You can "rebuild" the playlist (looking for new recently added files) if needed:

  • Via App

or

  • Boot your Pi with USB stick unplugged. (The current playlist will be erased.)
  • Safely shutdown your Pi
  • Power on your Pi once again, with the USB stick in it.
  • You're done! (mpradio will rebuild the playlist, indexing the new files as well)

Also, please remember that (though it would be probably illegal) you can test FM broadcasting by plugging a 20cm wire on the GPIO 4 of your Pi.

Control pipe

You can perform certain operations while mpradio.service is running by simply writing to /home/pi/mpradio_ctl

Example:

  • Play a song on demand: echo "PLAY /absolute/path/to/song.mp3" > mpradio_ctl
  • Skip the current song: echo "SKIP" > mpradio_ctl
  • Seek the track forward or backwards: echo "SEEK +10" > mpradio_ctl or echo "SEEK -10" > mpradio_ctl
  • Play all songs within a folder (via media scan): echo "SCAN /absolute/path/to/folder/" > mpradio_ctl

Bluetooth companion app

I'll post the source code once it's mature enough, but you can test an alpha (0.2) version here

NB: I haven't handled all corner conditions yet, so crashes may occour. (Make sure your Bluetooth is on and your Pi is paired, before even starting the app)

Screenshots:

UI UI UI

Updating

cd mpradio-master/install && sudo ./install.sh update

Or, if you prefer to be explicit:

cd mpradio-master && git fetch origin && git reset --hard origin/master && cd install && sudo ./install.sh

Uninstallation / Removal

In order to remove mpradio along with the packages that come with it:

cd mpradio-master/install && sudo ./install.sh remove

This has the effect of removing dependency packages whether or not you still want them. If you would like to keep the packages that mpradio depends on, run the following instead:

cd mpradio-master/install && sudo ./install.sh uninstall

Debugging / Troubleshooting

Services

mpradio is launched as a service (via systemd) upon each boot.

To check whether the service is running or not:

$ sudo systemctl status mpradio

To start or stop the service:

$ sudo systemctl [start/stop] mpradio

Bluetooth

Bluetooth connection logs are found at /var/log/bluetooth_dev.

If the Raspberry Pi is not showing up as a Bluetooth device, check whether the interface is UP, and that the bt-setup script is running:

$ hciconfig

$ sudo systemctl status bt-setup

If you are having issues with pairing Bluetooth for audio, please also check if simple-agent service is running:

$ sudo systemctl status simple-agent

If you are having issues with Bluetooth not connecting once it's paired, please check whether bluealsa is running or not:

$ sudo systemctl status bluealsa

A simple schematic of how things work together:

MPRadio schematic

Warning and Disclaimer

mpradio relies on PiFmRds for FM-Streaming feature. Please note that in most states, transmitting radio waves without a state-issued licence specific to the transmission modalities (frequency, power, bandwidth, etc.) is illegal. Always use a shield between your radio receiver and the Raspberry. Never use an antenna. See PiFmRds Waring and Disclamer for more information.

More Repositories

1

ChimeraDesk

Simple, fast and flexible DIY Remote Desktop software
Makefile
281
star
2

simple-ehm

A simple tool for a simple task: remove filler sounds ("ehm") from pre-recorded speeches. AI powered.
Jupyter Notebook
225
star
3

i3expo-ng

Exposè for i3 WM. Fork of https://gitlab.com/d.reis/i3expo to fix crashes and improve features/usability
Python
157
star
4

subito-it-searcher

searcher for subito.it
Python
95
star
5

LinuxRices

dotfiles and stuff
Shell
88
star
6

mpradio-py

Morrolinux's Pirate radio (PiFmAdv wrapper with Bluetooth and mp3 support) - Stream music to your car's FM radio or use it as a Bluetooth speaker via headphone jack
Python
71
star
7

olive-distributed

Export Olive video editor projects in a distributed manner
Python
38
star
8

KindleCalendar

Selenium automation to screenshot calendar and view it on kindle
Python
32
star
9

autodestroy

Simple bash script to program the "autodestroy button" on your PC. This will wipe the entire disk on demand!
Shell
29
star
10

SurfaceLinuxGoodies

Configs and utilities for Linux users on a Surface
Shell
21
star
11

kde-config-migrator

A tool for migrating settings that PlasmaConfigSaver is not taking care of
Shell
12
star
12

pIRemote

IR universal remote using a Raspberry Pi
Python
9
star
13

logseq-md-export

Utility to export logseq pages as standard markdown
Python
8
star
14

Thinkpad_X1_Yoga_1st_Gen

Specific configurations for Linux 2 in 1 Thinkpad X1 Yoga (1st Gen)
Shell
5
star
15

dots

ryals files
Shell
5
star
16

LazyBackupSupervisor

Simple backup failure notification system with heartbeat approach. Just a POC, nothing worth being published really.
Python
3
star
17

pixelArk

Arkanoid game with fortunes and grid/level editor (Built in SFML)
C++
3
star
18

fastBuyApp

Simple and dummy "e-commerce"-like Android App using RecyclerView, Fragments and stuff. - just for academic purposes
Java
2
star
19

mpradio-remote

Bluetooth remote app for mpradio-py via rfcomm.
Java
2
star