Updated: November 3, 2010

This is is a question often asked. Not only that, I have received a formal request from one of my readers to write a tutorial on this topic. Studying the internals of the problem into some depth, I really did discover that most people are having a hard time playing with USB devices in VirtualBox. Therefore, I decided to make the world a better place and write this howto.

4 Channel Low Profile PCI Sound Card with AC97 3D Audio Effects CMI8738 Works r76032: Driver is provided on the CD packaged with the sound card. I extracted drivers from the Setup.exe. This is a simple NSIS self-extracting installer. I decompressed it using 7z. I added installation files to my bootcd.iso for ReactOS.

Using USB devices of any kind, like thumb drives, Web camera and others, in your virtual machine can improve the quality of your virtual experience. It makes the virtual machine more usable. You can enjoy the virtual machine as more than just a test bed or a dire necessity because one of your programs may not work in the host operating system. It can become a second reality, where you use your system resources to the max, including all kinds of cool peripherals. Convinced? Surely. Now, let's examine the functionality, up close.

Test

4) While audio is playing on the host, attempt to play audio from the guest. The audio from the guest should start playing as well. At this point, you can stop the audio from the host which is no longer necessary. This seems to fix the issue until VirtualBox is shut down. You can even reboot or shutdown your guests. Device drivers improve sound, graphics, networking, and storage performance. If you perform a custom VMware Tools installation or reinstallation, you can choose which drivers to install. The set of drivers that are installed when you install VMware Tools depends on. This driver is for Windows 98 only and requires a computer with a CMI8738-based audio card. C-Media does not provide end user support for drivers, so please contact your hardware manufacturer if. Solution 4: Using High Definition Audio Driver. For some users, the Nvidia High Definition Audio Driver doesn’t work so in this step, we will be changing the installation of this driver to just “High Definition Audio Driver”. It sounds weird but this fixes this issue for some people so it is good to give it a go. In order to do so.

We will examine the problem in Linux. In Windows, the issue is far more trivial, but still, you might want to read anyway. The choice of the guest operating system is not important, the only difference in the setup concerns the host operating system.

Important note: You will need VirtualBox PUEL edition. The OSE edition does not offer USB support. Make sure you download the right version, otherwise you may hit an insurmountable obstacle.

Step 1: Install virtual machine

You know all about this. I've written tons of tutorials on how to do this, including some fairly elaborate multi-boot setup. Windows, Linux, take your pick.

Step 2: Configure USB support in virtual machine settings

Click on Settings for your virtual machine, go to USB tab. Check the two boxes, since you do want USB 2.0 support. In theory, this is all, but there's one step we will need to do afterwards to get this really working. True for Windows, Linux needs a bit more sweat. We will address that soon.

USB filter

USB filter is a nice feature that allows you to automatically connect USB devices to your virtual machine. Any device listed in the filter box will be plugged in when you power the guest operating system. Other devices will require that you manually connect them.

Step 3: Install Virtual Guest Additions

This is required to have the USB support enabled. Much like VMware Tools for VMware products, the Guest Additions expose additional functionality in the virtual machine, boost performance, enhance sharing, and more. We've had a long tutorial, which explains how to achieve this in both Windows and Linux virtual machines.

Step 4: Test and fail

We will try to connect a 16GB Kingston DataTraveler G2 USB thumb drive, which has a single JPG image on it, just for fun. Testbed: Ubuntu Lucid with VirtualBox 3.2, running a Windows XP virtual machine.

Boot your virtual machine. Now try to connect a USB device. Go to Devices > USB Devices and choose the one you need. Oops, the options will all be grayed out.

So what do you do?

Step 5: Fix the group permissions

Yes, this geeky step is part of the setup. You will need to add your user to the VirtualBox group to be able to share USB resources. You can do this from the command line or try the GUI menus.

All right, so we're running Ubuntu with Gnome desktop. Therefore, go to System > Administration > Users and Groups. In the menu that opens, click on Manage Groups. Scroll and look for the vboxusers group.

Click on the Properties button. Make sure your user is listed and checked in the Group Members field.

You will need to logout and login back into the session for the effects to take change. Now, power on the virtual machine once more and see what happens.

Step 6: Test again and succeed

This time, it will work properly. If you've used filters, the device will be automounted. You will have the USB device ready for use in your virtual machine. It can be a storage device or some other cool gadget. You may even use iPhone, iPod or similar, in case the host operating system does not support the device sync or whatnot.

In the past, you would have to change all kinds of other permissions manually, so there's hope and progress after all, but an automation of this step would make it so much easier for the average user. But we're done, everything works!

More reading

For a whole library full of tutorials, guides, howtos, tips and tricks on virtualization, feel free to click on any of the links below, preferably all.

Conclusion

Setting up the USB sharing in VirtualBox is not the easiest or the most intuitive step, but it can be done without donating a kidney. You do not need to dabble in code. You will have to pay attention to some of the steps, though, and you should be up and running in minutes, once your virtual machines is installed and fully set up.

Anyhow, that would be all. Another mystery unraveled, another tutorial made easy. I hope you enjoyed this; expect more good things to come. Thank you Carl for the idea!

P.S. I have written this tutorial for Ubuntu, Gnome. If you need tutorials for other Gnome desktops or for KDE desktops, feel free to ping me and I'll bake a sequel. In general, it's pretty much the same. Add your user to the vboxusers group. Log out, log in. C'est tout.

P.S.S. If you find this article useful, please support Dedoimedo.

Cheers.

< Advanced Linux Sound Architecture

Volume

No output

If speaker-test produces sound but some other program does not, determine whether PulseAudio is being used:

If it is, try using apulseAUR, as described in Advanced Linux Sound Architecture#PulseAudio compatibility. Alternatively, killing the PulseAudio process may cause sound to start working in the desired process.

Output is muted after reboot

Run the following command:

If the problem persists, verify that the Auto-Mute option in alsamixer is set to Disabled.

Volume is too low

Run alsamixer and try to increase the value of the sliders, unmuting channels if necessary. Note that if you have many sliders, you may have to scroll to the right to see any missing sliders.

If all the sliders are maxed out, and the volume is still too low, you can try running the following script[dead link 2020-03-28 ⓘ] to reset your codec settings:

The script assumes that /usr/bin/python refers to Python 2, which is incorrect on Arch by default. To avoid this issue run the following command:

Close the analyzer, and when prompted as to whether you want to reset the codecs, say 'yes'.

If the volume is still too low, run alsamixer again: resetting the codecs may have caused new sliders to become enabled and some of them may be set to a low value.

Low Sound Volume

If you are facing low sound even after maxing out your speakers/headphones, you can give the softvol plugin a try. Add the following to /etc/asound.conf.

Note: You will probably have to restart the computer, as restarting the alsa daemon did not load the new configuration for me. Also, if the configuration does not work even after restarting, try changing plug with hw in the above configuration.

After the changes are loaded successfully, you will see a Pre-Amp section in alsamixer. You can adjust the levels there.

Note:
  • Setting a high value for Pre-Amp can cause sound distortion, so adjust it according to the level that suits you.
  • Some audio codecs may need to have settings adjusted in the HDA Analyzer (see #Volume is too low) in order to achieve proper volume without distortion. Checking the HP option under widget control in the Playback Switch (Node[0x14] PIN in the ALC892 codec, for instance) can sometimes improve audio quality and volume significantly.

Random lack of sound on startup

You can quickly test sound by running speaker-test. If there is no sound, the error message might look something like

If you have no sound on startup, this may be because your system has multiple sound cards, and their order may sometimes change on startup. If this is the case, try setting the default sound card.

If you use mpd and the configuration tips above do not work for you, try reading this instead.

Microphone

No microphone input

In alsamixer, make sure that all the volume levels are up under recording, and that CAPTURE is toggled active on the microphone (e.g. Mic, Internal Mic) and/or on Capture (in alsamixer, select these items and press space). Try making positive Mic Boost and raising Capture and Digital levels higher; this may make static or distortion, but then you can adjust them back down once you are hearing something when you record

As the pulseaudio wrapper is shown as 'default' in alsamixer, you may have to press F6 to select your actual soundcard first. You may also need to enable and increase the volume of Line-in in the Playback section.

To test the microphone, run these commands (see arecord's man page for further information):

Devices

Alternatively, you can run this command:

alongside alsamixer to easily identify channel which you should select and unmute.

To test a particular device, use the --device parameter followed by the hardware PCM name in the form hw:C,D for card C device D, or plughw:C,D for plugged hardware. For instance:

If all fails, you may want to eliminate hardware failure by testing the microphone with a different device.

For at least some computers, muting a microphone (MM) simply means its input does not go immediately to the speakers. It still receives input.

Drivers vbox communication sound cards & media devices online

Many Dell laptops need '-dmic' to be appended to the model name in /etc/modprobe.d/modprobe.conf:

Some programs use try to use OSS as the main input software. If you have enabled the snd_pcm_oss, snd_mixer_oss or snd_seq_osskernel modules previously (they are not loaded by default), try unloading them.

See also:

Setting the default microphone/capture device

Some applications (Pidgin, Adobe Flash) do not provide an option to change the capture device. It becomes a problem if your microphone is on a separate device (e.g. USB webcam or microphone) than your internal sound card. To change only the default capture device, leaving the default playback device as is, you can modify your ~/.asoundrc file to include the following:

Replace 'U0x46d0x81d' with your capture device's card name in ALSA. You can use arecord -L to list all the capture devices detected by ALSA.

Internal microphone not working

First make sure the volume is enabled under the Capture view in alsamixer. In some case, the 'Internal Microphone' is not displayed in the capture list available when pressing F4. If so, specifying the card number given by aplay -l to start alsamixer (for example alsamixer -c 0 ) can make it appear.


Then add the following to /etc/modprobe.d/snd-hda-intel.conf:

Then reload the module:

Now there should be an additional input under the previously mentioned Capture view.

Crackling microphone

If you are getting a crackling or popping from your microphone that cannot be resolved with ALSA settings or cleaning your microphone jack, try adding the following line to /etc/modprobe.d/modprobe.conf:

This option will fix crackling on pure ALSA, but will cause issues to pulseaudio. To let Pulse use these settings effectively, edit /etc/pulse/default.pa and find this line:

And change it to this:

See the DMA-Position Problem in the kernel docs.

Audio Quality

Crackling sound through mini-jack (headphones connector)

Whether you followed simultaneous output tip or managed to get it done on your own, you might get crackling sound through headphones or external speakers. This can be fixed by muting or setting volume to 0% on item Mic. Use alsamixer or amixer:

Popping sound after resuming from suspension

You might hear a popping sound after resuming the computer from suspension. This can be fixed by editing /etc/pm/sleep.d/90alsa and removing the line that says aplay -d 1 /dev/zero

Sound skipping during playback

Run alsamixer, and if channels exist for nonexistent output devices then disable them (e.g. alsamixer showing a center speaker but you not having one).

Poor sound quality or clipping

If you experience poor sound quality, try setting the PCM volume (in alsamixer) to a level such that gain is 0.

If snd-usb-audio driver has been loaded, you could try to enable softvol in /etc/asound.conf file. Example configuration for the first audio device:

Pops when starting and stopping playback

Some modules (e.g. snd_ac97_codec and snd_hda_intel) can power off your sound card when it is not used. This can make an audible noise (like a crack/pop/scratch) when turning on/off your sound card. Sometimes even when moving the volume slider or opening and closing windows (KDE4). If you find this annoying, try modinfo your_module and look for a module option that adjusts or disables this feature.

For example, to disable the power saving mode for the snd_hda_intel module, add to /etc/modprobe.d/modprobe.conf:

You may also need to disable power saving for the audio card controller:

Alternatively you can set parameters for kernel modules with modprobe snd_hda_intel power_save=0 etc.

You may also have to unmute the 'Line' ALSA channel for this to work. Any value will do (other than '0' or something too high). For example, on an onboard VIA VT1708S (using the snd_hda_intel module) these cracks occurred even when power_save was set to 0. Unmuting the 'Line' channel and setting a value of '1' solved the problem.

Source: https://www.kernel.org/doc/Documentation/sound/alsa/powersave.txt[dead link 2020-03-28 ⓘ]

Sound skipping while using dynamic CPU frequency scaling

Some combinations of ALSA drivers and chipsets may cause audio from all sources to skip when used in combination with a dynamic frequency scaling governor such as ondemand or conservative. Currently, the solution is to switch back to the performance governor.

Refer to the CPU frequency scaling for more information.

Hardware and Cards

Verifying output parameters

Drivers Vbox Communication Sound Cards & Media Devices Using

Check the contents of /proc/asound/cardX/pcmYp/subZ/hw_params, where X, Y, and Z are system dependent.In order to find this file, execute the following command while outputting anything via ALSA:

If nothing is playing there should be no results.

Here is an example output for audio with a bit depth of 24 bits and a sampling frequency of 44.1 kilohertz:

More info is available in the ALSA documentation.

Error 'Unknown hardware' appears after kernel update

The following messages may be displayed during ALSA's initialization:

or:

Simply store ALSA mixer settings again:

It may be necessary configure ALSA again with alsamixer

Fix wrong audio pin mapping

If the mappings to your audio pins(plugs) do not correspond but ALSA works fine, you could try HDA Analyzer -- a pyGTK2 GUI for HD-audio control can be found at the ALSA wiki.Try tweaking the Widget Control section of the PIN nodes, to make microphones IN and headphone jacks OUT. Referring to the Config Defaults heading is a good idea.

Note: The script is incompatible with Python 3, which is the default Python implementation on Arch Linux. In order to use the script, replace all occurrences of python in the run.py file with python2 to point the script to the Python 2 version. Then make the script executable and run it.

S/PDIF output does not work

If the optical/coaxial digital output of your motherboard/sound card is not working or stopped working, and have already enabled and unmuted it in alsamixer, try running the following:

You can also put this command in an enabled systemd service as it sometimes it may stop working after a reboot.

Conflicting PC speaker

If you are sure nothing is muted, that your drivers are installed correctly, and that your volume is right, but you still do not hear anything, then try adding the following line to /etc/modprobe.d/modprobe.conf:

The above fix has been observed to work with via82xx

The above fix has been reported to work with snd-intel8x0

HP TX2500

Add these 2 lines into /etc/modprobe.d/modprobe.conf:

No sound when S/PDIF video card is installed

Discover available modules and their order:

Disable the undesired video card audio codec in /etc/modprobe.d/modprobe.conf:

If both devices use the same module then we can use the enable parameter from snd_hda_intel module; it is an array of booleans that can enable/disable the desired sound card.

Wrong sound card model type

Although ALSA detects your soundcard through the BIOS, at times ALSA may not be able to recognize your model type. The soundcard chip can be found in alsamixer (e.g. ALC662) and the model can be set in /etc/modprobe.d/modprobe.conf or /etc/modprobe.d/sound.conf. For example:

There are other model settings too. For most cases ALSA defaults will do. If you want to look at more specific settings for your soundcard take a look at the ALSA Soundcard List find your model, then Details, then look at the 'Setting up modprobe...' section. Enter these values in /etc/modprobe.d/modprobe.conf. For example, for an Intel AC97 audio:

Intel onboard sound

No sound with onboard Intel sound card

There may be a problem with two conflicting modules loaded, namely snd-intel8x0 and snd-intel8x0m. In this case, blacklist snd-intel8x0m:

Muting the 'External Amplifier' in alsamixer or amixer may also help. See the ALSA wiki.

Unmuting the 'Mix' setting in the mixer might help, also.

No headphone sound with onboard intel sound card

With Intel Corporation 82801 I (ICH9 Family) HD Audio Controller on laptop, you may need to add this line to modprobe or sound.conf:

Where model is any one of the following:

  • dell-m6
  • dell-vostro
  • generic
  • laptop
  • laptop-hpsense
  • olpc-xo-1_5
Note: It may be necessary to put this 'options' line below (after) any 'alias' lines about your card.

You can see all the available models in the kernel documentation. For example https://www.kernel.org/doc/html/latest/sound/hd-audio/models.html, but check that it is the correct version of that document for your kernel version.

A list of available models is also available here. To know your chip name type the following command (with * being corrected to match your files). Note that some chips could have been renamed and do not directly match the available ones in the file.

Note that there is a high chance none of the input devices (all internal and external mics) will work if you choose to do this, so it is either your headphones or your mic. Please report to ALSA if you are affected by this bug.

And also, if you have problems getting beeps to work (pcspkr):

HDMI

HDMI Output does not work

The procedure described below can be used to test HDMI audio. Before proceeding, make sure you have enabled and unmuted the output with alsamixer.

Note: If you are using an AMD card a necessary kernel module is disabled by default. See ATI#HDMI audio.
Drivers Vbox Communication Sound Cards & Media Devices

Connect your PC to the Display via HDMI cable and enable the display with xrandr.

Use aplay -l to discover the card and device number. For example:

Send sound to the device. Following the example in the previous step, you would send sound to card 1, device 3:

If aplay does not output any errors, but still no sound is heard, 'reboot' the receiver, monitor or tv set. Since the HDMI interface executes a handshake on connection, it might have noticed before that there was no audio stream embedded, and disabled audio decoding. If you are using a standalone window manager, you may need to have sound playing while plugging in the HDMI cable.

mplay and other application could be configured to use special HDMI device as audio output. But flashplugin could only use default device. The following method is used to override default device. But you need to change it back when your TV is disconnected from HDMI port.

If the test is successful, create or edit your ~/.asoundrc file to set HDMI as the default audio device.

Or if the above configuration does not work try:

Drivers Vbox Communication Sound Cards & Media Devices Online

Or if you alternatively succeed with

for your HDMI or DisplayPort port the following configuration will work (successfully tested on Lenovo ThinkPad T430s):

PCM through HDMI does not work (Intel Gfx)

As of Linux 3.1 multi-channel PCM output through HDMI with a Intel card (Intel Eaglelake, IbexPeak/Ironlake,SandyBridge/CougarPoint and IvyBridge/PantherPoint) is not yet supported. Support for it has been recently added and expected to be available in Linux 3.2. To make it work in Linux 3.1 you need to apply the following patches:

HDMI 5.1 sound goes to wrong speakers

Sound can be redirected to the intended speakers using ALSA's remap function. To do so, add the following to /etc/asound.conf:

Applications

SDL: No sound with SDL applications

If you get no sound using SDL based applications, try setting the environment variableSDL_AUDIODRIVER to alsa.

OpenAL: No sound in applications that use OpenAL

Openal defaults to pulseaudio, to change the order, add the following configuration to /etc/openal/alsoft.conf:

VirtualBox: Virtual machine has no sound

If you experience problems with VirtualBox, the following command might be helpful:

You might need to activate the ALSA output in your audio software as well. You might also try selecting different sound devices in your virtual machine settings to find one that works.

Others: Generic application problems

For other applications who insist on their own audio setup, e.g., XMMS or MPlayer, you would need to set their specific options.

For MPlayer or mpv, add the following line to the respective configuration file:

Eg. for XMMS2, go into their options and make sure the sound driver is set to ALSA, not oss.

To do this in XMMS:

  • Open XMMS
    • Options > Preferences.
    • Choose the ALSA output plugin.

For applications which do not provide a ALSA output, you can use aoss from the alsa-oss package. To use aoss, when you run the program, prefix it with aoss, e.g.:

pcm.!default{ ... } doesnt work for me anymore. but this does:

Drivers Vbox Communication Sound Cards & Media Devices

Other Issues

Simultaneous playback problems

If you are having problems with simultaneous playback, and if PulseAudio is installed, its default configuration is set to 'hijack' the soundcard. Some users of ALSA may not want to use PulseAudio and are quite content with their current ALSA settings. One fix is to edit /etc/asound.conf and comment out the following lines:

Commenting the following out also may help:

This may be a much simpler solution than completely uninstalling PulseAudio.

Effectively, here is an example of a working /etc/asound.conf:

Note: This /etc/asound.conf file was intended for and used successfully with a global MPD configuration. See #Problems with availability to only one user at a time.
Note: Alternatively, if you do not have PulseAudio installed, and just want to get dmix to work with vanilla ALSA, see the upstream documentation. In particular, you probably want to replace dsp in the above config with !default. Also, if you notice this causes certain applications to skip while playing (i.e. sound 'glitchy'), and complain about underrun occurring, you may want to tweak the slave.buffer_size inside pcm.dmixer.

Removing old ALSA state file (asound.state)

The alsa-utils package provides alsa-store.service which automatically stores the current ALSA state to /var/lib/alsa/asound.state upon system shutdown. This can be problematic for users who are trying to reset their current ALSA state as the asound.state file will be recreated with the current state upon every shutdown (e.g., attempting to remove user-defined channels from the mixer). The alsa-store.service service may be temporarily disabled by creating the following empty file:

The presence of state-daemon.conf prevents alsa-store.service from saving asound.state during shutdown. After disabling this service, the asound.state file may be removed as such:

After rebooting, the previous ALSA state should be lost and the current state should be reset to defaults. Re-enable alsa-store.service by deleting the condition file we created:

On the next shutdown, the asound.state file should be recreated with ALSA defaults. The file may also be generated immediately using:

If you want to clean ALSA state without rebooting, you can use rmmod to remove the sound driver module, then manually delete the unwanted entries in asound.state, and then use modprobe to reinstall the sound driver module.

Problems with availability to only one user at a time

You might find that only one user can use the dmixer at a time. This is probably ok for most, but for those who run mpd as a separate user this poses a problem. When mpd is playing a normal user cannot play sounds though the dmixer. While it is quite possible to just run mpd under a user's login account, another solution has been found. Adding the line ipc_key_add_uid 0 to the pcm.dmixer block disables this locking. The following is a snippet from asound.conf, the rest is the same as above.

Crackling/popping on Dell laptops

Check if you have i8kutilsAUR installed and if anything (e.g. i8kmon.service) is reading or writing to the interface exposed by the module, as i8kutils BIOS system calls block the kernel for a moment on some systems. See warning in Fan speed control#Dell laptops for more details.

Retrieved from 'https://wiki.archlinux.org/index.php?title=Advanced_Linux_Sound_Architecture/Troubleshooting&oldid=651575'