PeppyMeter

New version (Signac Edition) of the PeppyMeter was released today:
https://github.com/project-owner/PeppyMeter

New features include:
  • Refactored the algorithms for circular and linear meters
  • The changes allow to create vertical linear and circular meters
  • The circular meter range can be more than 180 degrees now
  • Fixed rendering issues for several default meters

Here are the new default meters which demo the new functionality:

meters-5.jpg
 
New version (Signac Edition) of the PeppyMeter was released today:
https://github.com/project-owner/PeppyMeter

New features include:
  • Refactored the algorithms for circular and linear meters
  • The changes allow to create vertical linear and circular meters
  • The circular meter range can be more than 180 degrees now
  • Fixed rendering issues for several default meters

Here are the new default meters which demo the new functionality:

View attachment 1100374
This is totally awesome. Thanks a lot. You are always a step in front. After creating my first PeppyMeter for my current project I wish one could make use of vertical linear one to simulate Magic Eye tubes.

Can I just clone the github code and integrate it into Peppy Player? In a first attempt it was not successful.

And just in this context, I have a feature request: Is it possible to integrate different indicators for left and right channel? This way one can simulate tubes like the EM83 tube.

Here is an impression of the horizontal implementation:
EM800 screenshot.png


And an idea, how the EM83 stereo tube could look like:
vertical_em83_bgr.png


Kind regards

Tobias
 
Thank you t0bit0bsen!

The code in the PeppyMeter and Peppy Player is slightly different. That doesn't allow direct replacement.
The new meters will be available in the Peppy Player in the next release.
Though you can get it right now here: https://github.com/project-owner/Peppy.doc/blob/master/files/peppymeter.zip
Please let me know if you will face any issue.

Different indicator per channel is doable. I'll add it to the wish list. Though I don't guarantee that it will be implemented soon.

Best regards
 
Thanks a lot for the fast reply. The version out of the zip works great:
snap001.png


You can see it in action in the video attached within the zip file.

I took photos of the tubes nearly at zero brightness. For the "bar" I cut the indicators at full brightness using a transparent background. For me the result is pretty nice, for the vertical as for the horizontal mode.

Best regards

Tobias
 

Attachments

I am hoping a Peppymeter maintainer or someone familiar can help me. I am trying to get level meter data from mpd with a config that includes:
Code:
audio_output {
        type            "alsa"
        name            "My ALSA Device"
        device          "hw:0,0"        # optional
        dop             "no"
        format          "44100:16:2"
        mixer_type      "software"      # optional
        mixer_device    "default"       # optional
        mixer_control   "PCM"           # optional
        mixer_index     "0"             # optional
}
as well as
Code:
audio_output {
        type            "alsa"
        name            "peppyalsa"
        device          "peppyalsa"
        dop             "yes"
}
and this plays music fine. After reading several posts about peppyalsa and installing it (I believe properly).. I have files located here:
Code:
root@raspberrypi:/usr/local/lib# ls -al
total 160
drwxr-xr-x  4 root root  4096 Jan  2 13:45 .
drwxr-xr-x 10 root root  4096 Sep 21 19:02 ..
-rw-r--r--  1 root root 70754 Jan  2 13:45 libpeppyalsa.a
-rwxr-xr-x  1 root root   988 Jan  2 13:45 libpeppyalsa.la
lrwxrwxrwx  1 root root    21 Jan  2 13:45 libpeppyalsa.so -> libpeppyalsa.so.0.0.0
lrwxrwxrwx  1 root root    21 Jan  2 13:45 libpeppyalsa.so.0 -> libpeppyalsa.so.0.0.0
-rwxr-xr-x  1 root root 66952 Jan  2 13:45 libpeppyalsa.so.0.0.0
drwxr-xr-x  3 root root  4096 Sep 21 19:13 pypy2.7
drwxr-xr-x  3 root root  4096 Sep 21 19:05 python3.9
and /etc/asound.conf
Code:
root@raspberrypi:/usr/local/lib# ls -al /etc/asound.conf
-rw-r--r-- 1 root root 713 Jan  4 18:11 /etc/asound.conf
which is almost identical to the example and looks like:
Code:
pcm.!default {
        type plug
        slave.pcm "softvol_and_peppyalsa"
}

ctl.!default {
        type hw
        card 0
}

pcm.peppyalsa {
        type meter
        slave.pcm "hw:0,0"
        scopes.0 peppyalsa
}

pcm.softvol_and_peppyalsa {
        type softvol
        slave.pcm "peppyalsa"
        control {
                name "PCM"
                card 0
        }
}

pcm_scope.peppyalsa {
        type peppyalsa
        decay_ms 400
        meter "/var/lib/mpd/myfifo"
        meter_max 100
        meter_show 0
        spectrum "/var/lib/mpd/myfifosa"
        spectrum_max 100
        spectrum_size 30
}

pcm_scope_type.peppyalsa {
        lib /usr/local/lib/libpeppyalsa.so
}

pcm.dsp0 peppyalsa

After restarting mpd I noticed that /var/lib/mpd/myfifo and /var/lib/mpd/myfifosa was created without me using mkfifo - and I took this as a very good sign:
Code:
root@raspberrypi:/var/lib/mpd# ls -al my*
prw-r--r-- 1 mpd audio 0 Jan  4 19:15 myfifo
prw-r--r-- 1 mpd audio 0 Jan  4 19:15 myfifosa

mpd runs as user mpd and yet - nothing comes from either /var/lib/mpd/myfifo or /var/lib/mpd/myfifosa.. this with mpd playing out of the speakers:
Code:
david@raspberrypi:~ $ sudo ./radio/peppyalsa/src/peppyalsa-client /var/lib/mpd/myfifo
Peppy ALSA Client. Goya Edition. 2018/09/08
Using provided pipe name /var/lib/mpd/myfifo
Code:
david@raspberrypi:~ $ sudo ./radio/peppyalsa/src/peppyalsa-client /var/lib/mpd/myfifosa
Peppy ALSA Client. Goya Edition. 2018/09/08
Using provided pipe name /var/lib/mpd/myfifosa

Or simply doing a cat on the pipe with the same mpd user:
Code:
mpd@raspberrypi:~$ ls -al myfifo*
prw-r--r-- 1 mpd audio 0 Jan  4 19:15 myfifo
prw-r--r-- 1 mpd audio 0 Jan  4 19:15 myfifosa
mpd@raspberrypi:~$ cat ./myfifo

Which catches me up to most posts where they get peppyalsa-client working through the pipe and then they move on..

I am now thinking what may(?) be related is that I am using a DAC Pro Hat on my Pi - which presents like this
Code:
david@raspberrypi:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Pro [RPi DAC Pro], device 0: Raspberry Pi DAC Pro HiFi pcm512x-hifi-0 [Raspberry Pi DAC Pro HiFi pcm512x-hifi-0]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
david@raspberrypi:~ $

Which I wouldn't expect to be a problem, and mpd plays fine through the DAC Pro. But I recall when configuring the DAC Pro that they recommended turning off all other Hardware playback devices to quickly/easily have it default to the DAC Pro, and that is making me think it could be related to my problems writing to the named pipe.

ANY help would be appreciated - pm
 
...


I am now thinking what may(?) be related is that I am using a DAC Pro Hat on my Pi - which presents like this
Code:
david@raspberrypi:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Pro [RPi DAC Pro], device 0: Raspberry Pi DAC Pro HiFi pcm512x-hifi-0 [Raspberry Pi DAC Pro HiFi pcm512x-hifi-0]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
david@raspberrypi:~ $

Which I wouldn't expect to be a problem, and mpd plays fine through the DAC Pro. But I recall when configuring the DAC Pro that they recommended turning off all other Hardware playback devices to quickly/easily have it default to the DAC Pro, and that is making me think it could be related to my problems writing to the named pipe.

ANY help would be appreciated - pm
Added Note **: It does seem to be related to the recommendation on how to activate the DAC Pro. In that, they specify to make a change in /boot/config.txt that results in:
Code:
# Enable audio (loads snd_bcm2835)
#dtparam=audio=on
dtoverlay=iqaudio-dacplus

Which does make the sound go through the DAC Hat. But I went back and uncommented the dtparam=audio=on line and now mpd is properly writing the music data to the named pipes (it seems). I can connect the peppyalsa-client to the named pipe and see the two meters moving properly.
But I don't get sound from the DAC Pro and my speakers 🙁. I will pursue getting sound to work on the DAC Pro while keeping the dtparam=audio=on setting in the /boot/config.txt.
 
Last edited:
Added Note **: It does seem to be related to the recommendation on how to activate the DAC Pro. In that, they specify to make a change in /boot/config.txt that results in:
Code:
# Enable audio (loads snd_bcm2835)
#dtparam=audio=on
dtoverlay=iqaudio-dacplus

Which does make the sound go through the DAC Hat. But I went back and uncommented the dtparam=audio=on line and now mpd is properly writing the music data to the named pipes (it seems). I can connect the peppyalsa-client to the named pipe and see the two meters moving properly.
But I don't get sound from the DAC Pro and my speakers 🙁. I will pursue getting sound to work on the DAC Pro while keeping the dtparam=audio=on setting in the /boot/config.txt.

It does work - keeping the dtparam=audio=on, it simply reset my hw for the DAC Pro. Using aplay -l:
Code:
david@raspberrypi:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
  Subdevices: 6/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 1: Pro [RPi DAC Pro], device 0: Raspberry Pi DAC Pro HiFi pcm512x-hifi-0 [Raspberry Pi DAC Pro HiFi pcm512x-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

I can see my DAC Pro is now card 1. So a simple change in my /etc/mpd.conf with:
Code:
audio_output {
        type            "alsa"
        name            "My ALSA Device"
        device          "hw:1,0"        # optional
        dop             "no"
        format          "44100:16:2"
        mixer_type      "software"      # optional
        mixer_device    "default"       # optional
        mixer_control   "PCM"           # optional
        mixer_index     "0"             # optional
}
setting the device to hw:1,0 on my audio_output for the speakers did the trick.

Seems to have it working both on the speakers and going to the named pipes.
 
Thanks, Sounds like a very good idea and I didn't know I could. Will do.

rpi - thank you for responding so quick all the same! I have a question for you (or anyone) about incorporating peppyalsa and possibly peppymeter into a very, very small screen area. I have a 320x240 screen on my little diy radio - but I only want the meters to be on the bottom say 1/3 of the screen. I am expecting that if I run peppymeter itself it will want to write directly to the screen, and use all of the screen.
Work in progress - but you can see here:
faceplate_tmp.jpg

So my current approach is simply get the values of the left/right channels and create custom bars in the code that I already have updating the screen with the station number/song title/artist/battery/etc. To that end I am currently trying to import peppymeters' DataSource... and get some minimal amount of code going to be able to fetch the left and right channel values. In my small brain it starts something like this:
Code:
# Load in the real meter values
from datasource import DataSource, SOURCE_NOISE, SOURCE_PIPE, SOURCE_HTTP
data_source = DataSource(util.meter_config)
data_source.start_data_source()
and then I can later fetch the values directly from data_source... (guessing)

Two questions:
1. Is there any existing howto or can you give me some pointers on a super minimal/simple python code base to fetch the current R/L channel values (I am expecting % I suppose) from the named pipe that the peppyalsa plugin is now properly writing to?
2. I am very open to a better way to do this over just my own custom code. For instance, if you told me a way to get peppymeter or even the spectrum analyzer (both look amazing, btw) going in such a way that I can output it to the smaller part of my screen then I am way open!
If so - the details are that I am currently writing out SPI using the ILI9341 with code that uses (this is very chopped up, but you likely get the idea):
Code:
from PIL import Image, ImageFont, ImageDraw # Drawing commands
from adafruit_rgb_display import ili9341 # Display commands

if not hasattr(PIL.Image, 'Resampling'):  # Pillow<9.0
    PIL.Image.Resampling = PIL.Image

# Configuration for CS and DC pins (these are PiTFT defaults):
cs_pin = digitalio.DigitalInOut(board.CE0)
dc_pin = digitalio.DigitalInOut(board.D25)
reset_pin = digitalio.DigitalInOut(board.D24)

# Config for display baudrate (default max is 24mhz):
BAUDRATE = 24000000

# Setup SPI bus using hardware SPI:
spi = board.SPI()

disp = ili9341.ILI9341(
    spi,
    rotation=270,  # 2.2", 2.4", 2.8", 3.2" ILI9341
    cs=cs_pin,
    dc=dc_pin,
    rst=reset_pin,
    baudrate=BAUDRATE,
)

and then in a loop I do draw rectangles and text before rendering...
Code:
   ...
    draw.text((width/10, 108), currentArtist, font=fontArtist, fill=white) # artist
    draw.text((width/10, 134), currentSong, font=fontSong, fill=white) # song

    # commit render
    disp.image(image)

Any advice - greatly appreciated! -pm
 
Hi, you can check how Volumio plugin does that, download and check the code:
https://community.volumio.org/t/pro...or-volumio-v2-9xx-and-3-0xx-buster/45862/1674
Here are the fresh examples:

f8bb10548b1d8bbab36efa7b4e235c1513a9a645.jpeg


There is a way to define the whole screen resolution in the file config.txt:
screen.width = 320
screen.height = 240
Then in the file meters.txt define the coordinates (top/left) of the meter. Assuming a meter will take the low third part of the screen:
meter.x = 0
meter.y = 160

Best regards
 
Hello,

I have an RPI4 with a DIYINHK XMOS DXIO 768K and before installing peppy meter resampling worked up to 768khz.
I noticed that the pappy meter causes the resampling to work only up to 192khz, even though the volumio3 settings are higher: 352.8, 384, 768khz. After disabling the peppy meter plugin in the settings, resampling works fine. Do you have that too?
Can it be fixed?
Best regards
 
Hi,

I'm not sure how PeppyMeter could affect resampling. PeppyMeter is using ALSA plugin called 'peppyalsa' which in turn is using another plugin 'meter'. That 'meter' plugin is a generic ALSA plugin. The 'peppyalsa' plugin just redirects the output from the 'meter' plugin to a named pipe and PeppyMeter grabs a signal from that named pipe.

You can try to exclude peppyalsa/PeppyMeter from the picture by disabling peppyalsa plugin in the ALSA configuration file. I'm not sure where is that file located in Volumio but usually it's either here /etc/asound.conf or here /home/pi/.asoundrc. The file should look similar to this one:
https://github.com/project-owner/peppyalsa.doc/wiki/Configuration
Just remove the line 'scopes.0 peppyalsa'. This should exclude peppyalsa plugin. If you will still face the same issue it means that the 'meter' plugin is the root cause. Unfortunately that generic ALSA plugin is out of my control.

Best regards
 
Hello,

I have an RPI4 with a DIYINHK XMOS DXIO 768K and before installing peppy meter resampling worked up to 768khz.
I noticed that the pappy meter causes the resampling to work only up to 192khz, even though the volumio3 settings are higher: 352.8, 384, 768khz. After disabling the peppy meter plugin in the settings, resampling works fine.
What slave device is in your meter asoundrc config?