2

I recently bought a cheap a USB Audio card and I have some issues with it.

It records audio so awful. Apparently the volume of the mic in is so loud and distorts. I figured out this in alsamixer. The input or output volumes assigned to this device cannot be changed.

My USB Audio card is listed by lsusb:

CODE: SELECT ALL
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 1130:f211 Tenx Technology, Inc. TP6911 Audio Headset

Another problem is that the recorded audio plays a little fast, maybe the sampling rate is also wrong.

2
  • I think the issue is probably that you bought a cheap audio card :(
    – Jivings
    Aug 28, 2013 at 7:44
  • I noticed that , but there must be a way to workaround this. I heard something about "softvolume". But I don't have a clue of how to use it properly. Aug 28, 2013 at 16:52

2 Answers 2

2

There is a good tutorial on the ALSA website. Basically it boils down to this:

  1. Add a soft volume device to your ~/.asoundrc:

    pcm.softvol {
        type            softvol
        slave {
            pcm         "<device name>"
        }
        control {
            name        "SoftMaster"
            card        0
        }
    }
    

    Instead of <device name>, you should put your PCM device there. You can list all devices by typing aplay -L. Then pick your headset as the slave device.

  2. Add the new device as your default device in ~/.asoundrc:

    pcm.!default {
        type             plug
        slave.pcm       "softvol"
    }
    

I haven't tried this, but I think these are the most important steps from the above tutorial. In your case, I would also use dmix as well, but that is described in the tutorial in more detail. Hopefully, the above lines will get you started.

5
  • I don' want to set it as default device (yet), how to apply the changes listed in .asoundrc? Aug 30, 2013 at 16:25
  • I figured out that speaker-test register your new controls Aug 30, 2013 at 16:56
  • It worked, but now, I have two controls with the same name. Apparently one controller is for outuput and another for capturing (mic in), but i don't know if they are the same because i change the volume of one and the other also changes. Aug 30, 2013 at 17:23
  • My actual configuration: pcm.softvol { type softvol slave { pcm "hw:1,0" } control { name "Volume out" card 1 } } pcm.!default { type plug slave.pcm "softvol" slave.channels 2 } Aug 30, 2013 at 17:24
  • My solution above only defines a Master volume, which applies to all sources of the device. You can define a recording source, and give it a softvol of its own. It is described in the more complex example of the link I gave you in my answer.
    – Arne
    Aug 31, 2013 at 15:12
2

Have you tried using your microphone with Pulseaudio? Alsa is very much a tool of the past ( although it is still needed at times, especially w/ some of the microphones that are on the market these days ). Pulseaudio often takes care of a lot of the quality issues that are associated with microphone devices, and offers a number of really awesome features.

Basic installation steps below ( See my link at the end of this answer for more specific notes if you're trying to obtain the same configuration that I have on my RaspberryPi):

Install pulse audio / development packages

sudo apt-get install gstreamer0.10-pulseaudio libao4 libasound2-plugins libgconfmm-2.6-1c2 libglademm-2.4-1c2a libpulse-dev libpulse-mainloop-glib0 libpulse-mainloop-glib0-dbg libpulse0 libpulse0-dbg libsox-fmt-pulse paman paprefs pavucontrol pavumeter pulseaudio pulseaudio-dbg pulseaudio-esound-compat pulseaudio-esound-compat-dbg pulseaudio-module-bluetooth pulseaudio-module-gconf pulseaudio-module-jack pulseaudio-module-lirc pulseaudio-module-lirc-dbg pulseaudio-module-x11 pulseaudio-module-zeroconf pulseaudio-module-zeroconf-dbg pulseaudio-utils oss-compat -y

Change alsa to use pulse:

sudo \cp -pf /etc/asound.conf /etc/asound.conf.ORIG 
echo 'pcm.pulse {
    type pulse
}

ctl.pulse {
    type pulse
}

pcm.!default {
    type pulse
}

ctl.!default {
    type pulse
}' | sudo tee /etc/asound.conf

Make sure your camera device loads on boot:

# Disallow module loading after startup. This is a security feature since it disallows additional module loading during runtime and on user request.
_DISALLOW_MODULE_LOADING=$(grep "DISALLOW_MODULE_LOADING=1" /etc/default/pulseaudio | wc -l)
if [[ "${_DISALLOW_MODULE_LOADING}" = "0" ]]; then

  sudo \cp -pf /etc/default/pulseaudio /etc/default/pulseaudio.ORIG
  sudo sed -i "s,DISALLOW_MODULE_LOADING=1,DISALLOW_MODULE_LOADING=0,g" /etc/default/pulseaudio

fi

Prevent PulseAudio from sending the audio hardware to sleep.

# This is the important part that prevents PulseAudio from sending the audio hardware to sleep. 
sudo sed -i 's,#load-module module-suspend-on-idle,load-module module-suspend-on-idle,g' /etc/pulse/default.pa

Optimize the pulse audio daemon config:

sudo \cp -fvp /etc/pulse/daemon.conf /etc/pulse/daemon.conf.${_DATE}

echo "
# ScarlettPi added this
high-priority = yes
nice-level = 5
exit-idle-time = -1
resample-method = src-sinc-medium-quality
default-sample-format = s16le
default-sample-rate = 48000
default-sample-channels = 2" | sudo tee -a /etc/pulse/daemon.conf

Add your user to the pulse-access group. In my case, my user is pi.

# add pi user to audio groups
sudo adduser pi pulse-access

Reboot:

sudo shutdown -r now

When the system is up and running, make sure pulse audio is started:

/usr/bin/pulseaudio --start --log-target=syslog --log-level=debug --system=false

Now see if everything works!

Hope this helps you. If you need any more help troubleshooting just comment on answer and @ me.

More reading here:

1
  • @Malcom-jones Mmmm... I'm not sure because I'm using ALSA in companion with JACK and MIDI devices. Aug 30, 2013 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.