mocassino
Lightweight audio player based on MOC for Raspberry Pi Zero 2 devices with Pimoroni Pirate Audio hats
Overview
mocassino is a background service
turning a Raspberry Pi Zero 2 with a Pimoroni Pirate Audio hat
into a small standalone audio player.
The service handles the four buttons of the hat,
pilots its display, and delegates the playback to
MOC (music on console),
which it controls by running mocp commands.
Features
- Playback control with the buttons of the hat: play/pause, next track, previous track, seek backward and forward, volume up, volume down
- Playback information on the display of the hat: artist, title, and album of the current track, playback progress, volume, and the icons of the actions of the buttons
- Menu to browse the music root directory and play a directory or a single FLAC, MP3, OGG, or WAV file
- Menu showing the name and the IP address of the host, and shutting it down
- Menu to change the settings of the running service
- Settings stored in a YAML configuration file, including the action of each button
- Simulator window replacing the buttons and the display, to run the service on a PC without the hardware
Requirements
- Python 3.13 or later
- A package/virtual environment manager tool (e.g.,
micromamba,conda,uv, etc.) - A Raspberry Pi Zero 2 with a Pimoroni Pirate Audio hat, with MOC (music on console) installed
Installation
From PyPI (Recommended)
mocassino is published on PyPI as the same-name package
mocassino
, and this is the recommended way of installing it for most users.
Only the first time: create a virtual environment,
activate it, and install the latest release of mocassino
available on PyPI with pip:
$ micromamba create -n mocassino_env python=3.13
$ micromamba activate mocassino_env
(mocassino_env) $ pip install mocassino
You should be able to run the CLI tool mocassino:
(mocassino_env) $ mocassino --version
To update mocassino, use the -U / --upgrade option:
$ micromamba activate mocassino_env
(mocassino_env) $ pip install mocassino --upgrade
From Source
Clone this repository and install from source in a virtual environment:
$ git clone https://github.com/pettarin/mocassino
$ cd mocassino
$ micromamba create -n mocassino_env python=3.13
$ micromamba activate mocassino_env
(mocassino_env) $ pip install -e .
(mocassino_env) $ # or
(mocassino_env) $ make install-e-this
You should be able to run the CLI tool mocassino:
(mocassino_env) $ mocassino --version
Usage
Service Usage
Run the service with the mocassino run command.
By default it runs in background, detached from the terminal:
$ mocassino --library-directory-path /home/pi/music run
mocassino is running in background (PID 15875)
The MOC server is started automatically, if it is not already running.
The buttons of the hat are
A (top-left), B (bottom-left), X (top-right), and Y (bottom-right).
By default they perform the following actions:
| Button | Playback mode | Menu mode |
|---|---|---|
A |
Play/pause; hold: open the menu | Back, up one level |
B |
Next track; hold: previous track | Select |
X |
Volume up; hold: seek forward | Up; hold: select |
Y |
Volume down; hold: seek backward | Down; hold: select |
The permanent settings, including the action of each button,
can be stored in the ~/.config/mocassino/configuration.yaml file:
display:
font_file_path: /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf
library:
directory_path: /home/pi/music
To stop the service, send it the SIGTERM signal (e.g., kill 15875).
To try the service on a PC without the hardware, run it in foreground with the simulator window:
$ mocassino --simulator --library-directory-path ~/music run --foreground
CLI Usage
The
CLI Usage
guide describes all the commands, subcommands, and most of the options
of the CLI tool mocassino.
Some examples of the commands made available
by the CLI tool mocassino in the virtual enviroment
where it is installed:
$ # print the version
$ mocassino --version
$ # run the service in background (default)
$ mocassino run
$ # run the service in foreground, logging debug messages
$ mocassino --verbose run --foreground
$ # run the service with a given configuration file
$ mocassino --configuration-file-path /path/to/configuration.yaml run
$ # run the service on a PC, with the simulator window
$ mocassino --simulator --library-directory-path ~/music run --foreground
$ # run the service with the buttons of the hat, but without drawing on its display
$ mocassino --display-target none run
$ # print the effective configuration
$ mocassino configuration
Releases And Changelog
The list of releases and their changes is contained in the CHANGELOG document.
Development
Consult the DEVELOPMENT document to learn how to set up a development environment, run the tests, and browse the project structure.
The CONTRIBUTING document explains how to report issues and propose changes.
License
This project is licensed under the GNU General Public License v3.0 or later (GPLv3+).
See the LICENSE file for details.
Authors
- Alberto Pettarin (Web)
Metadata
Release files for mocassino 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mocassino-0.0.2.tar.gz | 75.1 kB | Without provenance | Details for mocassino-0.0.2.tar.gz |
Release files / mocassino-0.0.2.tar.gz
| Download URL | mocassino-0.0.2.tar.gz |
|---|---|
| Size | 75.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c703e8c4f1b94a09950fc8c10f7dc9b60122065db935c697c23e60f1179f9140
|
|
BLAKE2b-256 checksum How to use checksums |
a4683d880d11eded863b7af4e38931a7c727f18baa14e15fb1db2fc0bb3cb94b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.0
|
Security for mocassino 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.