Skip to content

Instantly share code, notes, and snippets.

@Gadgetoid
Last active August 21, 2020 15:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gadgetoid/375f9dc0089f8518262dffb5179a56f7 to your computer and use it in GitHub Desktop.
Save Gadgetoid/375f9dc0089f8518262dffb5179a56f7 to your computer and use it in GitHub Desktop.
Working asound.conf for libphatmeter on Volumio. Very hacky and still needs tweaks to mpd.conf and /dev/i2c-1 owned by group "audio" =/

This is a horrible, hacky, proof of concept mess for Pi VU Meter on Volumio It details steps with the old phatmeter library, but should work with PiVuMeter too, simply change "ameter" to "pivumeter" and link the right lib accordingly

udev rules permissions

REQUIRED: Create /etc/udev/rules.d/60-i2c.rules with the contents:

KEREL=="i2c-1", GROUP="i2C", MODE="0777"

This allows MPD, which uses the mpd user and sound group, to gain access to the i2c bus.

mpd config

There must be a better way to do this/let MPD run with both audio/i2c groups?

mpd.conf just has "device "softvolume"" specified with other options commented out. Throws errors about missing PCM but vol works. /boot/config.txt must include: dtoverlay=i2s-mmap and dtoverlay=hifiberry-dac

alsa config

Contents of /etc/asound.conf as follows:

ctl.!default {
        type hw
        card 1
}

pcm.dmixer {
        type dmix
        ipc_key 1024
        ipc_perm 0666
        slave.pcm 'hw:1,0'
        slave {
                period_time 0
                period_size 1024
                buffer_size 8192
        }
        bindings {
                0 0
                1 1
        }
}

ctl.dmixer {
        type hw
        card 1
}

pcm.softvolume {
        type meter
        slave.pcm "softvol"
        scopes.0 ameter
}

pcm.softvol {
        type softvol
        slave.pcm "dmixer"
        control {
                name "SoftMaster"
                card 1
                device 0
        }
}

pcm_scope.ameter {
        type ameter
        decay_ms 500
        peak_ms 400
        brightness 128
}

pcm_scope_type.ameter {
        lib /usr/local/lib/libphatmeter.so
}

pcm.ameter {
        type meter
        slave.pcm 'hw:1,0' #can be hw or hw:0,1 etc...
        scopes.0 ameter
}

pcm.dsp0 ameter
@nicokaiser
Copy link

Are you sure output is routed through both ameter and dmix?

I had problems using both together (here with pivumeter): pimoroni/pivumeter#27

@elcuevero
Copy link

I'm interested in this to drive a blinkt, any progress?

@battez
Copy link

battez commented Aug 21, 2020

also interested to drive a blinkt @elcuevero did you have any luck ?

@Gadgetoid
Copy link
Author

There's a long abandoned PR against the PiVUMeter library that moves all the display code into Python.

Unfortunately it never got enough traction for me to get any help from people who know what they're doing 😆

It does however have a Blinkt! server.

You need to work from the devel branch- https://github.com/pimoroni/pivumeter/tree/devel

There are some minimal instructions to getting it up and running - https://github.com/pimoroni/pivumeter/blob/f0e333230fc6e83b992eda0d4df432998cd65fdc/python_server/README.md

Unfortunately I don't have time to go into any more depth.

@battez
Copy link

battez commented Aug 21, 2020

Hi @Gadgetoid thank you for that, appreciate you replying! I will take a look, when I tried pivumeter with volumio previously I could not get the asound to work at all so I will need to read up on that a bit first I think or I will likely trash my volumio install again.

@battez
Copy link

battez commented Aug 21, 2020

@Gadgetoid this was the issue I Was having https://community.volumio.org/t/help-with-pivumeter-alsa-asound-conf-and-pi-zero-w-with-a-blinkt-led/40676 am I rightin thinking if I attempt with your devel branch and blinkt server I will get around this? I find the Volumio install and what I can/cannot meddle with a bit tricky!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment