Is it possible to change the volume scale?


#1

The volume is really loud and distorted in my setup. I have to turn the software volume down to almost off. I can’t get it to a point where I can make it quieter with out it muting the volume.

Say the volume scale is 0-100 on the bar is it possible to change it to 0-30 so the bar is all the way to to right on the volume and only playing at 30.

Is this possible?

I tried changing from the default audio mixer in pimusicbox to the Alsa mixer but this stops the web gui from loading.

I also use airplay and it works fine with volume about 50% on my iPhone.

My setup is pi Zero, phat dac, stereo amp running rc4.


#2

default software mixer uses linear volume scale which unfortunetly is not what we humans perceive. Humans percive the sound volume in logarithmic scale this is why the usefull range of the mixer is between 0 and 30%. You can use mopidy-alsamixer plugin which has configurable volume scales (cubic, log) which are more human and min max values.


#3

The phatDac is not great as it does not have a hardware mixer which means you cannot use mopidy-alsamixer. I bought this card exactly because it is a frustrating edge case to test with!

If I remember correctly, musicbox sets the system volume really high when booting. if you log into the console and run alsamixer you should be able to reduce this back down to a more sensible level. If you want to make that a permanent change then adjust the values at the bottom of /opt/musicbox/setsound.sh


#4

like this?

do
# Set initial hardware volume
amixer set -c $CARD “$CTL” 30% unmute > /dev/null 2>&1 || true
#amixer set -c $CARD “$CTL” ${VOLUME}% unmute > /dev/null 2>&1 || true
done

Set PCM of Pi higher, because it’s really quiet otherwise (hardware thing)

amixer -c 0 set PCM playback 30% > /dev/null 2>&1 || true &


#5

If I done that correctly, it hasnt made any difference.


#6

Did you try adjusting it in alsamixer as I also suggested? if you cannot adjust it in alsamixer then you cannot adjust it and you have to rely entirely on Mopidy’s software volume mixing. I don’t have the phatdac on me right now to test this.


#7

When I load the alsamixer all it says is

This sound device does not have any controls.

There must be something that can be done to reduce the volume.


#8

as You said phatDac does not have hardware mixer so how alsamixer would reduce the volume ? :slight_smile:


#9

I thought alsamixer still gave you software mixing control by default when there’s no hardware mixing available (there’s no reason why it couldn’t) but I don’t remember, it’s been a while. You might have to define the softvol plugin yourself manually. See
http://alsa.opensrc.org/Softvol


#10

Link doesnt seem to work,

Im now wondering about adding physical volume buttons to my speaker using an addon like
https://github.com/9and3r/mopidy-ttsgpio, do you think something like this would work?

edit
I cant install festival all i get is

E: Unable to locate package festival

Am I right in thinking updating the raspberry pi breaks pimusicbox?


#11

If you want 0dB then use the command:

amixer sset PCM,0 0dB

This will set ALSA to value 86 for PCM out. Some reason 100% is the default which is +6dB above full scale, why it is distorted.


#12

Thanks I will try that when I get home


#13

It didnt work, thanks tho

root@MusicBox:~# amixer sset PCM,0 0dB
amixer: Unable to find simple control ‘PCM’,0


#14

Did you ever find a solution to this? I have the same issue - I’m using the PhatDac and 5% volume is about the max that I would want. Very difficult to control with 5% to work with. Thanks


#15

No I never did, I pritty much use between 1 to 5%.

The only way I think is add a volume wheel to the amp. My amp doesn’t support volume wheels annoyingly.


#16

In my mopidy branch (https://github.com/mczerski/mopidy/commits/feature/output_volume) I have added the cubic volume scale to software mixer, this should increase the usable volume range. But I must warn that this is mopidy version 2.1 and it is work in progress. But I’m using it and it is working


#17

I got it working using the alsa config from here: http://forums.pimoroni.com/t/howto-get-phat-dac-to-play-all-system-sound-software-volume-control/2361 and using the alsamixer plugin. FYI I’m using Mopidy but I think that the mopidy.conf is the same as MusicBox.

This is my /etc/asound.conf

# the sound card
pcm.real {
  type hw
  card 0
  device 0
}

#support  the ipc stuff is needed for permissions, etc.
pcm.dmixer {
  type dmix
  ipc_key 1024
  ipc_perm 0666
  slave.pcm "real"
  slave {
    period_time 0
    period_size 1024
    buffer_size 8192
    rate 44100
  }
  bindings {
    0 0
    1 1
  }
}

ctl.dmixer {
  type hw
  card 0
  }

# software volume
pcm.softvol {
  type softvol
  slave.pcm "dmixer"
  control {
    name "Software"
    card 0
  }
}
# mpd volume control
pcm.mpdvol {
  type softvol
  slave.pcm "dmixer"
  control {
    name "MPD"
    card 0
  }
}
# ctrl for mpd volume
ctl.mpdvol {
  type hw
  card 0
}

# input
pcm.input {
        type dsnoop
        ipc_key 3129398
        ipc_key_add_uid false
        ipc_perm 0660
        slave.pcm "810"
}
# duplex device
pcm.duplex {
        type asym
        playback.pcm "softvol"
        capture.pcm "input"
}

# default devices
pcm.!default {
  type plug
  slave.pcm "duplex"
}

# for oss devices
pcm.dsp0 {
  type plug
  slave.pcm "duplex"
}

and this is what I have in my /etc/mopidy/mopidy.conf

[alsamixer]
enabled = True
card = 0
control = Software
min_volume = 0
max_volume = 30

[audio]
mixer = alsamixer
mixer_volume = 40
output = alsasink
buffer_time = ""

Just got this working, it is almost 12am so I haven’t tested it out too much but I didn’t wake the whole house up for a change. Hope this helps

mczerski - thanks for your work, I’ll have to give it a try.


#18

This seems to be working perfectly. I’m also running shairport sync on the same Pi and this puts both into a similar volume range. Now I just need to get alsa equal working and it will be totally perfect.


#19

I am running PiMusicBox with an IQAudioDAC+ and I have the same issue, usable volume range is within the 0-10% range, so almost impossible to dial in the right volume level.

Can I use the code above for my situation also?

Thanks!