pimoroni / pivumeter Goto Github PK
View Code? Open in Web Editor NEWALSA plugin for displaying VU meters on various Raspberry Pi add-ons - derived from ameter
License: GNU General Public License v3.0
ALSA plugin for displaying VU meters on various Raspberry Pi add-ons - derived from ameter
License: GNU General Public License v3.0
I am looking for a way to use pivumeter with a pHAT DAC. This works fine, however only with one single sound source.
Since the pHAT DAC (just like the HiFiBerry) does not have a hardware mixer, I need to use the ALSA ´dmix` plugin, which also works fine per se.
Now when I try to combine both, I struggle. Since I cannot set a non-hardware device as slave for dmix I need to route the output through pivumeter first and the to dmixer:
pcm.!default {
type plug
slave.pcm "softvol_and_pivumeter"
}
ctl.!default {
type hw
card 0
}
pcm.pivumeter {
type meter
#slave.pcm "hw:0,0"
slave.pcm "dmixer"
scopes.0 pivumeter
}
pcm.softvol_and_pivumeter {
type softvol
slave.pcm "pivumeter"
control {
name "PCM"
card 0
}
}
pcm_scope.pivumeter {
type pivumeter
decay_ms 500
peak_ms 400
brightness 128
output_device phat-beat
}
pcm_scope_type.pivumeter {
lib /usr/local/lib/libpivumeter.so
}
pcm.dsp0 pivumeter
pcm.dmixer {
type dmix
ipc_key 1024
ipc_key_add_uid false
ipc_perm 0666
slave {
pcm "hw:0,0"
period_time 0
period_size 1024
buffer_size 8192
#rate 44100
#format S16_LE
}
bindings {
0 0
1 1
}
}
But with this config, there is no pivumeter output. Do you have an idea on how to solve this?
I used the airdac installer script from Pimoroni with a Pirate Radio kit and saw this during the installation:
wiringpi is required
Installing wiringpi...
E: Unable to locate package wiringpi
Apt failed to install wiringpi!
Falling back on pypi...
And later during the configuration of pivumeter:
checking for wiringPiSetup in -lwiringPi... no
configure: error: You need libwiringPi installed
Installing Pi VU Meter...
make: *** No rule to make target 'install'. Stop.
All done!
Seems like wiringPi needs to be replaced (or compiled separately).
While working on https://gist.github.com/roblan/1a373b5a3414a464b53a140f55dab058 I've notice that when I pause music there is very high CPU usage in this script.
Have I done something wrong or it's Pi VU Meter fault?
I plan to add support for both piglow (https://shop.pimoroni.com/products/piglow) and ws2812b based LED strips. For the piglow, I thought maybe almost nothing is needed, since the README.md (https://github.com/pimoroni/pivumeter/blob/8bddc3e94d996bf745d43a854793ca70b7bda12f/README.md#output_device) mentions:
default (18-segment VU driven by SN3218)
However, I don't find any such support (for example, https://github.com/pimoroni/pivumeter/blob/8bddc3e94d996bf745d43a854793ca70b7bda12f/src/pivumeter.c doesn't allow 'default' as a valid output device type, and grep for sn3218 finds nothing). I've looked through history to see if support was removed, but I don't find that happening.
Is the mention in the README.md a plan that didn't happen yet, or do I miss some option/flag?
Thank you!
When playing multiple (loud enough) streams e.g. through aplay
, some LEDs start blinking randomly. Maybe there is an overflow somewhere?
This is more of a request/inquiry, can this VU meter be used with the pHat DAC board?
That would make an awesome combo.
Hey guys,
It might well be my own fault, but I can't get it to work with my pi3 and scrollphat. I installed according to instructions and copy/pasted your example asound.conf but edited to add scrollphat as output. Nothing happening when playing different audio. Do I need to do something else to the asound.conf? I have no soundcard attached. Cheers.
Well, my problem looks identical to the issue in #16 but since I am already using the asound.conf file listed there (which removes dmix), I'm not sure how best to proceed.
I have a Pimoroni Pirate Radio, with Raspian Buster installed (Linux raspberrypi 5.10.63+ #1457). I'm running "pianobar" (version 2020.11.28) which lets me use it to stream Pandora radio. Pianobar segfaults after a couple of minutes. I got a core dump, and the backtrace looks identical to the one in issue #16:
(gdb) backtrace
#0 get_channel_level (channel=0, offset=<optimized out>, size1=53960, size2=1853429792,
max_decay=3496476, max_decay_temp=<optimized out>, level=<optimized out>,
level=<optimized out>) at src/pivumeter.c:116
#1 0xadd06494 in level_update (scope=<optimized out>) at src/pivumeter.c:171
#2 0xaf105efc in ?? () from /lib/arm-linux-gnueabihf/libasound.so.2
So I disabled pivumeter (just by renaming the asound.conf file, since I don't know the right way to disable it), and pianobar doesn't crash now. Any ideas on how to keep pivumeter from seg faulting?
is there a way to get the vu meter of the phatbeat to just match the dynamics of the song played and not the set volume? so that the leds are always lively even at low volumes?
When I try to use the phatbeat python library by setting some pixels (as documented here http://docs.pimoroni.com/phatbeat/) while playing music with pivumeter installed on my phatbeat, I can only see some random pixels (even when I set only 1 pixel) briefly flashing.
I can send the exact same command several times and witness how different random pixels flash briefly.
Even when using the VLC project. The play / pause button has the clear function used (https://github.com/pimoroni/phat-beat/blob/master/projects/vlc-radio/phatbeatd/usr/bin/phatbeatd). When I play pause I can see how the vumeter disappear and also a random flash of some random colours appear, at pause, and play.
I have to stop the pulseaudio.service
in order to shutdown pivumeter
before I can use the phatbeat python library as expected.
I would really like to keep the vumeter going and also at the same time insert some other user interfaces through the use of the LEDs with the python library.
Is that possible?
Can I use pivumter only on 1 LED channel and free the other channel of the phatbeat to use with the python library?
Thanks!
Following a brief discussion with sandy on discord...
Trying to get this to work with a blinkt playing music over spotify. Installed fine, but LEDs wont light up
running aplay -L
gives:
null
Discard all samples (playback) or generate zero samples (capture)
default
pivumeter
softvol_and_pivumeter
sysdefault:CARD=sndrpihifiberry
snd_rpi_hifiberry_dac,
Default Audio Device
dmix:CARD=sndrpihifiberry,DEV=0
snd_rpi_hifiberry_dac,
Direct sample mixing device
dsnoop:CARD=sndrpihifiberry,DEV=0
snd_rpi_hifiberry_dac,
Direct sample snooping device
hw:CARD=sndrpihifiberry,DEV=0
snd_rpi_hifiberry_dac,
Direct hardware device without any conversions
plughw:CARD=sndrpihifiberry,DEV=0
snd_rpi_hifiberry_dac,
Hardware device with all software conversions```
See title, because how about? Would be a perfect VU meter for my audio/video conferencing test setup.
:)
I'm trying to do something with server from devel branch, but all I get are 0 values for right and left.
Enviroment: raspbian jessie on Pi Zero W (no DAC or sound card)
What have I done:
cloned devel branch, run 'setup.sh socket'
created sample file in pivumeter/python_server/library/ (also - I don't know how to install pivumeter module to use it 'normally')
#!/usr/bin/env python
import pivumeter
import signal
class OutputBlinkt(pivumeter.OutputDevice):
def setup(self):
print 'setup'
def display_fft(self, bins):
pass
def display_vu(self, left, right):
print left, right
def cleanup(self):
print 'cleanup'
self.display_vu(0, 0)
pivumeter.run(OutputBlinkt)
signal.pause()
When I play something using shairport-sync
or run speaker-test
I get only 0 0
values in console
Question - what have I done wrong?
This issue seems either revealed by, or exacerbated by Raspbian Stretch and does not appear in Jessie either at all, or often enough to be reported widely.
VLC will play for 1-2 minutes before crashing with the below segfault, caused by Pi VU Meter.
Removing Pi VU Meter from the equation appears to fix the problem, although testing to confirm whether there is another issue is ongoing since VLC could be crashing and taking Pi VU Meter with it.
Relevant code:
Lines 96 to 135 in 8bddc3e
Thread 8 "vlc" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb363d380 (LWP 1202)]
get_channel_level (channel=channel@entry=0, offset=offset@entry=18816, size1=size1@entry=46720, size2=1063584424, size2@entry=3060062160, max_decay=max_decay@entry=3787718,
max_decay_temp=<optimized out>, level=<optimized out>, level=<optimized out>) at src/pivumeter.c:116
116 s = *ptr;
I have a couple of working theories for this:
Buffer size computation:
size = snd_pcm_meter_get_now(pcm) - level->old;
if (size < 0){
size += snd_pcm_meter_get_boundary(pcm);
}
offset = level->old % snd_pcm_meter_get_bufsize(pcm);
cont = snd_pcm_meter_get_bufsize(pcm) - offset;
size1 = size;
if (size1 > cont){
size1 = cont;
}
size2 = size - size1;
Relevant lines:
Lines 137 to 180 in 8bddc3e
I'm running the lastest Raspbian Jessie/PIXEL build with all updates on a Raspberry Pi 3 with a BLINKT! attached. I compiled pivumeter and ran setup.sh which seems to have installed properly. I'm running headless, so I've only tried pianobar and mpg123 so far. Both will occasionally light up one LED on the BLINKT!, however the audio stream freezes and I have to hard-kill the audio player apps. I've tried with HDMI attached and without, and with audio output manually set to HDMI and headphone port. In all cases, the results are the same.
Removing asound.conf allows audio to play just fine, however, the BLINKT! is obviously not doing anything at that point.
Welcome to pianobar (2014.06.08)! Press ? for a list of commands.
(i) Login... Ok.
(i) Get stations... Ok.
0) q 1200 Micrograms Radio
1) 80s Pop Radio
2) q Armin Van Buuren Radio
3) Binary Finary Radio
[ ... ]
[?] Select station: 2
|> Station "Armin Van Buuren Radio" (2034637540235068767)
(i) Receiving new playlist... Ok.
|> "Bright Morningstar" by "Tiesto" on "Elements Of Life"
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
Using device: blinkt
-08:19/08:19
And that's all I get. The timer doesn't move, and I get no audio.
C-specific modes for Pi VU Meter are considered EOL- there wont be any new device support built-in. However, the library is still transitioning to a socket
based method of communication where a Python script will be responsible for displaying VU data on the output device.
Currently the following output devices have been requested. I'm keen to see Python implementations of these submitted to this repository once #15 is merged, but I wont necessarily have the time to do these myself.
For the time being, if you have a request please post it below. Thank you!
hi, i really like your effort to give the pi a nice vumeter.
I currently wish display a simple vumeter on a lcd dispaly (16x2) about incoming (dsnoop) sound signal.
do you think you could support also the simple: 16x2 Character LCD - RGB Backlight 5V LC (https://shop.pimoroni.com/products/16x2-character-lcd-rgb-backlight-5v) from the coolest but expensive Display-O-Tron HAT ?
thanks
Federico
Hey, I have the great volumio system running on my pi Zero. But I can't get the alsa settings to work right.
The sound plays but the LED are not showing any reaction.
The original asound.conf looks like this:
pcm.softvolume {
type plug
slave.pcm "softvol"
}
pcm.softvol {
type softvol
slave {
pcm "plughw:1,0"
}
control {
name "SoftMaster"
card 1
device 0
}
max_dB 0.0
min_dB -50.0
resolution 100
}
How can I change this to use the LED's?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.