pimoroni / pivumeter

ALSA plugin for displaying VU meters on various Raspberry Pi add-ons - derived from ameter
GNU General Public License v3.0
59 stars 22 forks source link

How about support for the Unicorn pHat? #11

Closed SparkyXI closed 6 years ago

SparkyXI commented 7 years ago

See title, because how about? Would be a perfect VU meter for my audio/video conferencing test setup.

:)

Gadgetoid commented 7 years ago

It's something that will come after I've completed the shift to a Python-based front end. Unicorn HAT would be, at best, extremely tricky to get working with the current architecture because it requires root privileges, whereas ALSA + plugins run under the user context of the application that initialised them.

The Python/socket method will decouple the ALSA plugin (now the client) from whatever script (the server) displays the VU information on a HAT or pHAT.

This is still a work in progress though, here's the prototype server: https://github.com/pimoroni/pivumeter/blob/devel/python_server/socket_server.py

And the client plugin: https://github.com/pimoroni/pivumeter/blob/devel/src/devices/socket.c

Gadgetoid commented 7 years ago

I've got the build into a state where I can potentially test Unicorn HAT/pHAT blinkies now.

Unfortunately Unicorn HAT/pHAT are not compatible with any DAC add-on, because they have a pin clash. I'll have to fix my audio routing and disable the DAC before I can test it and rig a proof-of-concept.

SparkyXI commented 7 years ago

All fantastic things. Thanks for looking into it - very much appreciated!

Gadgetoid commented 7 years ago

Proof of concept: https://twitter.com/Gadgetoid/status/857175875183403009

And accompanying code: https://github.com/pimoroni/pivumeter/blob/devel/python_server/unicorn_server.py

I'm still having trouble with it conking out periodically, specifically in the gap between YouTube videos when playing continuously in Chrome. I'll need to narrow that down, 'cos it's super annoying!

SparkyXI commented 7 years ago

This is excellent. Thanks so much! Now, the question is... how exactly do I get this running? I have unicorn_server.py running in the background, but I get no blinky. Is there something else I should be running, or do I have to define the unicorn phat as the device somewhere?

Gadgetoid commented 7 years ago

You'll need to clone and install the development branch, like so:

git clone https://github.com/pimoroni/pivumeter -b devel
cd pivumeter
./setup.sh

Then modify the pcm_scope.pivumeter section in /etc/asound.conf, changing the line:

output_device default

Into:

output_device socket

Then fire up the server, play some audio, and cross your fingers!