Volume for Pirate Audio: Headphone Amp for Raspberry Pi

For the “Pirate Audio: Headphone Amp for Raspberry Pi”, how do you control volume from the command line or from mpd?

E.g., alsa mixer gives “This device has no controls”. There are various threads online with people trying to fix this, but no fixes I could follow.

The device works:

> aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 [HifiBerry DAC HiFi pcm5102a-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

But e.g.,

> sudo pactl list sinks
Connection failure: Connection refused
pa_context_connect() failed: Connection refused

For example,

mpc status

shows that the volume is not available for setting.

Any ideas?

Would love some input on this if anybody has any ideas!

Hi Björn (me again):

try this asound.conf:

pcm.!default  {
 type hw card 0
}
ctl.!default {
 type hw card 0
}
pcm.!default {
        type plug
        slave.pcm “softvol”
}
pcm.softvol {
        type softvol
        slave {
                pcm “dmix”
        }
        control {
                name “Amp”
                card 0
        }
        min_dB -5.0
        max_dB 20.0
        resolution 6
}

And skip pulse-audio (the pa-stuff). This is pure alsa-level (like aplay). This configuration creates a mixer device.

Hi - thank you, I will try this and report back!

Many thanks @bablokb - this worked!

Instructions written up here:

Pull request here: Added 'build your own' directory with help for getting started using the device without other software by bjohas · Pull Request #90 · pimoroni/pirate-audio · GitHub