qemu + pulseaudio and bad quality of sound
Asked Answered
G

1

12

I am using my gentoo as host os for kvm with vga passthrough for playing on windows, but I have problem with sound, it is not good quality, I hear something like crackles in sound. I am using pulseaudio (with --system mode) on host os, and tried different sample rates but didnt helped. My command for vm:

qemu-system-x86_64 \
   -vga none \
   -enable-kvm -m 10000 -cpu host -smp 8,cores=4,threads=2,sockets=1 \
   -device ioh3420,bus=pci.0,addr=1c.0,multifunction=on,port=1,chassis=1,id=root.1 \
   -device vfio-pci,host=01:00.0,bus=root.1,addr=00.0,multifunction=on,x-vga=on \
   -net nic,macaddr=50:E5:49:57:74:E3 -net bridge,vlan=0 \
   -soundhw hda \
   -boot d \
   -hda /dev/sdb \
   -usb -usbdevice host:09da:000a 

I tried setting PULSE_LATENCY_MSEC, QEMU_PA_SAMPLES, but didnt helped. I also checked with live cd on guest vm, to make sure if its not windows problem, but the result is the same. I also tried setting -soundhw ac97, but there is no official support for ac97 on windows 10 and I have some delays with sounds, but less interference.

my audio is:

00:1f.3 Audio device [0403]: Intel Corporation Sunrise Point-H HD Audio [8086:a170] (rev 31) (snd_hda_intel on msi z170a m7),

and versions of qemu and pulseaudio:

QEMU emulator version 2.3.0, Copyright (c) 2003-2008 Fabrice Bellard
pulseaudio 5.0

Could anyone help with this?

Gualterio answered 24/8, 2015 at 22:59 Comment(0)
I
21

I just saw your question after searching for pretty much this same problem myself and then found the solution on a you tube video about 5 mins later. Here is what I did and a link to the YouTube video is at the end. This little guide assumes Windows 10, you didn't specify so I have had to guess here:

First you need to switch Qemu to use AC97, for the soundhw option use ac97 i.e. -soundhw ac97 and also set QEMU_AUDIO_DRV to alsa (I also am setting the QEMU_PA_SAMPLES to 128 and not sure if that will affect things or not) QEMU_PA_SAMPLES=128 QEMU_AUDIO_DRV=alsa

Then start Windows and go to the Realtek website and download the AC97 Driver for Vista / Win7 Realtek AC97 download link, once downloaded extract this somewhere you will find it again.

Then for the next section you need to disable driver signature enforcement, I recommend watching the video for this part as it makes it a bit easier to see which option to click but it basically is:

Open Settings, go to Update & Security, Choose Recovery in the left pane, Choose Advanced Start-up, Choose Troubleshoot, Advanced Options, Choose Start Up Settings and then press the restart button.

Once restarted you need to choose option 7 which disables driver signature enforcement.

Once Windows comes back go into Device Manager, Right click the multimedia device and choose 'Update Driver Software' click browse on the next page and navigate to the realtek driver you downloaded earlier.

Let windows do its thing and hey presto crystal clear audio :) The Youtube video I followed

Incurve answered 14/3, 2016 at 21:31 Comment(9)
Works - absolutely perfect! I am using libvirt on Ubuntu 17.10. I did not touch the default QEMU variables.Daryldaryle
Indeed cracks are almost gone! Big big improvement! However I get one strange behavior: In adobe premiere, the sound is really bad, kinda out of order... making editing impossible. Pity...Multinuclear
I was struggling with this for a couple days too. Great answer, worked perfectly. What is the 128 for?Forswear
I do not know about the 128 I am afraid. Another user reported no issues when not using those variables so it may not matter.Incurve
@Multinuclear that is a shame, I wonder if the ac97 driver has problems with Premiere, It is quite an old driver.Incurve
Apologies to come back to this 4 years later, but I was having trouble with this problem with qemu (virsh) and audio crackling. I solved it by following the above method but with using QEMU_AUDIO_DRV=pa (I.e. pulseaudio instead of alsa)Goober
The PA_SAMPLE is for pulse audio, and will not have an effect when driver is set to Alsa. Edited answer for clarity.Lashoh
Worked for me too on Debian 10 buster! :) Nothing else I tried worked, including the MSI regedit stuff. I never had this issue on Debian 9 by the way. I upgraded to Debian 10 and the crackling sounds issue appeared, for both Windows 10 and Windows 8.1Loney
Noice! Solution from back in 2016 continues to work a treat on Windows 10 20H2 (OS Build 19042.685). Host is Ubuntu 20.04.1 LTS using qemu-kvm v4.2. However, the drivers from the link in the YouTube video caused my VM to BSOD. I used the 6305 drivers from realtek-download.com/download-ac97Mcwhirter

© 2022 - 2024 — McMap. All rights reserved.