As part of the festive competition we’re hosting that asks you to build a seasonal snap on your RaspberryPi…we couldn’t help but try out another example of our own!
Didier from the dev team has created a Christmas music carousel snap! The snap allows you to play a Christmas music carousel from a selection of pre-selected music…with the option of having LED lights using a Raspberry PiGlow connected on the network.
Here are notes on how to do so!
Setting upOn a 16.04 Ubuntu desktop, you can install this as a snap:
snap install christmas-music-carousel --beta --devmode
Optionally, connect on your network a Raspberry PiGlow with Ubuntu Core installed on it with a PiGlow. Install the grpc-piglow snap on it:
snap install grpc-piglow --beta --devmode
Finally, run the carousel with default music selection (as root):
sudo christmas-music-carousel
Usage christmas-music-carousel [-options] [list OF MIDI FILES]
Play a music carousel and optionally sync up with lights on a Raspberry PiGlow connected on the network.
A list of midi files can be provided, and in that case, the carousel will play over them in random orders. If none is provided, a default christmas selection is chosen. If you have a PiGlow on the same network, ensure you have the grpc-piglow snap installed on it.
This programs need to be ran as root on your laptop to connect to alsa.
Available optionsbrightness (integer): adjust brightness (from 1 to 255) for light up PiGlow. Warning: any value above default (30) is dazzling
debug: Enable debug (developer) messages
Technical notes:This project is orchestrating multiple binaries:
TiMidity, a software synthesizer playing MIDI files
alsa utilities: aconnect, aplaymidi: to play midi files and connecting MIDI ports
music-grpc-events a python program in music-grpc-events/ directory receiving MIDI events and forwarding them to the PiGlow RPI board via gRPC
christmas-music-carousel, a golang program in *chrismas-music-carousel directory, which orchestrates all above tools, restarting them as needed, handling the notions of required and optional components. It’s using the bonjour/mDNS protocol to detect the RPI PiGlow on the network and forward those connexions info to music-grpc-events
Related projectsMore information on gRPC-PiGlow can be found here
Regenerating the gRPC protocol (python)
Ensure you are in your python virtualenv in music-grpc-events:
cd music-grpc-events
virtualenv venv
. venv/bin/active
pip install -r requirements.txt
Then, regenerate piglow_pb2.py from our protobuf protocole (the proto file is in github.com/didrocks/grpc-piglow):
pip install grpcio-toolspython -m grpc.tools.protoc -Ipath_to_grpc-piglow/proto/ --python_out=musicevents/ --grpc_python_out=musicevents/ path_to_grpc-piglow/proto/piglow.proto
Link to info on Github here.
источник[/list]