LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Distortion when PCM is at 100 (https://www.linuxquestions.org/questions/linux-desktop-74/distortion-when-pcm-is-at-100-a-840076/)

chrisinspace 10-23-2010 09:13 PM

Distortion when PCM is at 100
 
I am using Kubuntu 10.10 and having a sound issue. I fully installed PulseAudio so that I could properly enable the 5.1 sound on my system. At some volume levels it sounds great, while at others it has a terrible metallic-sounding distortion. I have worked with the various audio tools I have installed and narrowed down the problem.

Here is what I have installed to configure sound settings: kmix (KDE equivalent of gnome-volume-manager), pavucontrol, alsamixer.

I have found that when I adjust the master volume level through kmix (either with the GUI slider or the volume control keys on my keyboard), the levels in alsamixer all change, too, not just the Master level. When PCM maxes out at 100, I get the distortion, but if it is at 99 or lower, everything sounds perfect. The weird thing is that as I adjust the master volume level, the PCM level bounces between 98 and 100. Like this:

Master PCM

23.....100
35.....98
42.....100
52.....98
58.....98
61.....100
68.....98
74.....98
78+....100

Is there any way to lock the PCM level or cap it at 99? If I can keep the PCM from hitting 100, I can get rid of the distortion. I would greatly appreciate anyone's help.

jschiwal 10-24-2010 07:30 PM

I'm not an alsa expert. Looking in /etc/alsa.state, I found this segment:

Code:

...
        control.22 {
                comment.access 'read write user'
                comment.type INTEGER
                comment.count 2
                comment.range '0 - 255'
                comment.tlv '0000000100000008ffffec1400000014'
                comment.dbmin -5100
                comment.dbmax 0
                iface MIXER
                name 'PCM Playback Volume'
                value.0 255
                value.1 255
        }

I think that the alsa state file is read in when alsa starts. I think that comment.dbmax 0 is purely information.
But this segment of the "amixer" program output indicates that editing the "value" line will limit the lower and upper bounds of the alsa mixer:
Code:

Simple mixer control 'PCM',0
  Capabilities: pvolume penum
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 255

You may need to resort to the alsa documentation to see if there is an equivalent asound.conf setting.

Using pulse, you shouldn't need to touch kmix at all. I normally listen to podcasts on my laptop, piping the audio to my desktop. Selecting the optical output on my desktop (from the laptop padevchooser applet) selects my stereo for audio.

chrisinspace 10-25-2010 11:14 AM

I have been using Linux for a while, but I'm not a programmer and I've never had to hack ASLA before. So, to clarify, you think that by editing the 'value.0' and/or 'value.1' lines in the /etc/alsa.state file, I can set an upward limit? The range in the alsamixer is 0 to 100, so do you have any recommendations as to what value I should use to slightly decrease the cap? 255 looks like IP bit notation where 255 would equal 11111111 in binary.

Quote:

Originally Posted by jschiwal (Post 4138066)
Using pulse, you shouldn't need to touch kmix at all. I normally listen to podcasts on my laptop, piping the audio to my desktop. Selecting the optical output on my desktop (from the laptop padevchooser applet) selects my stereo for audio.

I'm using kmix with pulse because this is a HTPC and I control it from a multimedia keyboard. I really need the volume control keys to work and they are currently tied to the main volume channel of kmix.

jschiwal 10-26-2010 05:21 AM

Code:

                value.0 255
                value.1 255

I think changing the 255 to 250, for example, may change the max level. On my system, the alsa.state file is saved when alsa shuts down and I presume is reloaded then the device is detected:

I read through /etc/init.d/alsasound, where alsa is started, and the alsactl command to load the state file is commented out. I mentions that udev does it instead.

Code:

cat /etc/udev/rules.d/40-alsa.rules
SUBSYSTEM=="sound",            GROUP="audio"
SUBSYSTEM=="snd",              GROUP="audio"
KERNEL=="controlC[0-9]*",      NAME="snd/%k"
KERNEL=="hwC[D0-9]*",          NAME="snd/%k"
KERNEL=="pcmC[D0-9cp]*",        NAME="snd/%k"
KERNEL=="midiC[D0-9]*",        NAME="snd/%k"
KERNEL=="timer",                NAME="snd/%k"
KERNEL=="seq",                  NAME="snd/%k"
SUBSYSTEM=="sound", KERNEL=="controlC?", RUN+="/usr/sbin/alsa-init %n"

There may be a better place to set the maxDB variable in a configuration file, but I'm not certain on which file or syntax to use.

chrisinspace 10-29-2010 09:00 PM

I just checked and I don't have a /etc/alsa.state file, so I'm back to square one. I'm wondering if there is some way to maybe control which level kmix adjusts. Right now my only choice of channels is "Internal Audio Analog Surround 5.1". I can't choose "master", "PCM", etc.

jschiwal 10-31-2010 01:14 AM

You could use "sudo /usr/sbin/alsactl store 0" to store the settings for card 0. Looking at the kmix settings, I saw settings for the initial value, but not a way to set a max limit.

For pulse audio, you can run "pavucontrol", and change the settings in the Output tab.

chrisinspace 11-02-2010 09:49 PM

jschiwal, thank you for taking the time to look into this. I appreciate your help.

Well, in case anyone else is having this issue, I eventually found a work around on another forum (Thanks, Mandriva). If you kill kmix, then run the command

Code:

KMIX_PULSEAUDIO_DISABLE=1 kmix
you will be able to select the master channel. I selected PCM. That allows me to control the system volume with the PCM slider, preventing it from jumping to 100. I just never set the volume above 99. The change reverts if I reboot the machine, so the next step will be to set it that way at bootup, but I haven't gotten there yet. I'll update this when I figure that out, but it's not super-high on my priority list since I don't reboot this machine very often.

jschiwal 11-04-2010 06:01 PM

Thank you for the update.


All times are GMT -5. The time now is 06:59 AM.