zondag 18 februari 2024

Lenovo V110 laptop met Ubuntu en Linux Mint

De Lenovo V110-laptop draait Ubuntu. Er is echter één probleem na de installatie en dat is de ingebouwde microfoon. Deze werkt niet out-of-the-box.

Ik heb een artikel gevonden op de arch linux wiki-website waarin wordt uitgelegd hoe je de microfoon kunt laten werken, ook al is het nog steeds een puinhoop met veel fouten.

https://wiki.archlinux.org/title/PulseAudio/Troubleshooting#Static_noise_in_microphone_recording

Na deze methode werkt de microfoon min of meer, maar de kwaliteit van de opnames is erg laag. Veel erger dan het gebruik ervan in MS Windows.

Voor gemakkelijke referentie (van wanneer de originele pagina is verwijderd), is hier een kopie:

Static noise in microphone recording

If we are getting static noise in Skype, gnome-sound-recorder, arecord, etc.’s recordings, then the sound card sample rate is incorrect. That is why there is static noise in Linux microphone recordings. To fix this, we need to set the sampling rate in /etc/pulse/daemon.conf for the sound hardware.

In addition to the guide below, since PulseAudio 11 it is possible to set avoid-resampling = yes in daemon.conf.

Determine sound cards in the system (1/5)

This requires alsa-utils and related packages to be installed: $ arecord –list-devices **** List of CAPTURE Hardware Devices **** card 0: Intel [HDA Intel], device 0: ALC888 Analog [ALC888 Analog] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: Intel [HDA Intel], device 2: ALC888 Analog [ALC888 Analog] Subdevices: 1/1 Subdevice #0: subdevice #0

The sound card is hw:x,y where x is the card number and y is the device number. In the above example, it is hw:0,0.

Determine sampling rate of the sound card (2/5)

We aim to find the highest sample rate supported by the hw:0,0 sound card using a trial-and-error procedure starting from a low value. When the top value is reached, we got a warning message: arecord -f dat -r 60000 -D hw:0,0 -d 5 test.wav “Recording WAVE ’test.wav’ : Signed 16 bit Little Endian, Rate 60000 Hz, Stereo Warning: rate is not accurate (requested = 60000Hz, got = 44100Hz) please, try the plug plugin

observe, the got = 44100Hz. This is the maximum sampling rate of our card.

Setting the sound card’s sampling rate into PulseAudio configuration (3/5)

The default sampling rate in PulseAudio: $ grep “default-sample-rate” /etc/pulse/daemon.conf ; default-sample-rate = 48000

48000 is disabled and needs to be changed to 44100: # sed ‘s/; default-sample-rate = 48000/default-sample-rate = 44100/g’ -i /etc/pulse/daemon.conf

Restart PulseAudio to apply the new settings (4/5)

$ pulseaudio -k $ pulseaudio –start

Finally check by recording and playing it back (5/5)

Let us record some voice using a microphone for, say, 10 seconds. Make sure the microphone is not muted and all $ arecord -f cd -d 10 test-mic.wav

After 10 seconds, let us play the recording… $ aplay test-mic.wav

Now hopefully, there is no static noise in microphone recording anymore.

Another Possible Cause

Another possible cause is that your mic has two channels but only one channel can provide a valid sound signal. Some information can be found here. The solution is to remap the stereo input to a mono input:

1. Find your source name from the following command; mine is alsa_input.pci-0000_00_1f.3.analog-stereo pacmd list-sources | grep ‘name:.*input’

2. Edit /etc/pulse/default.pa and add the following lines, where INPUT_NAME is name of the input source from above step: load-module module-remap-source source_name=record_mono master=INPUT_NAME master_channel_map=front-left channel_map=mono set-default-source record_mono

3. Restart PulseAudio: $ pulseaudio -k $ pulseaudio –start

Now arecord hopefully works. You may still need to change the RecordStream from setting to Remapped Built-in Audio Analog Stereo of a specific application in the Recording tab of pavucontrol.

If using a USB microphone

Try plugging it into a different port (eg: ports at the back rather than front).

No microphone on Steam or Skype with enable-remixing = no

When you set enable-remixing = no on /etc/pulse/daemon.conf you may find that your microphone has stopped working on certain applications like Skype or Steam. This happens because these applications capture the microphone as mono only and because remixing is disabled, Pulseaudio will no longer remix your stereo microphone to mono.

To fix this you need to tell Pulseaudio to do this for you:

1. Find the name of the source # pacmd list-sources

Example output edited for brevity, the name you need is in bold: index: 2 name: <alsa_input.pci-0000_00_14.2.analog-stereo> driver: <module-alsa-card.c> flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY

2. Add a remap rule to /etc/pulse/default.pa, use the name you found with the previous command, here we will use alsa_input.pci-0000_00_14.2.analog-stereo as an example: /etc/pulse/default.pa ### Remap microphone to mono load-module module-remap-source master=alsa_input.pci-0000_00_14.2.analog-stereo master_channel_map=front-left,front-right channels=2 channel_map=mono,mono

3. Restart Pulseaudio # pulseaudio -k

Note: Pulseaudio may fail to start if you do not exit a program that was using the microphone (e.g. if you tested on Steam before modifying the file), in which case you should exit the application and manually start Pulseaudio # pulseaudio –start

Microphone distorted due to automatic adjustment

If your microphone volume creeps up automatically and causes the sound to be distorted, you can fix it by disabling mic boost:

In all files /usr/share/alsa-card-profile/mixer/paths/analog-input*.conf,

  • Under [Element Capture] set volume to zero
  • Under [Element Internal Mic Boost] set volume to zero.
  • Under [Element Int Mic Boost] set volume to zero.
  • Under [Element Mic Boost] set volume to zero.

including all variations such as [Element Headphone Mic Boost] and [Element Mic Boost (+20dB)]

Then restart PulseAudio: # pulseaudio -k

Microphone crackling with Realtek ALC892

Sometimes ALC892 chips have crackling sound while recording using a microphone. Some Pulseaudio configuration changes may help: /etc/pulse/daemon.conf resample-method = src-sinc-best-quality default-sample-format = s16le default-sample-rate = 48000

and add the use_ucm option to /etc/pulse/default.pa load-module module-udev-detect use_ucm=0 tsched=0

then restart pulseaudio.

Microphone crackling with Azalia chipsets

Some Azalia based chips have popping/crackling noise and distortion while recording using a microphone with PulseAudio. This can be fixed by loading the snd-hda-intel module with position_fix set to an appropriate value. This tells the module to use various DMA pointer fixes. Use trial and error to determine which value works for you. (source)

Create a new modprobe.d config: /etc/modprobe.d/azalia-microphone.conf options snd-hda-intel position_fix=1

Valid values for position_fix are:

  • 0 = Auto
  • 1 = None
  • 2 = POSBUF
  • 3 = FIFO size

then reload your modules.

Echo test

If you are unsure about your microphone setup, you can hear the input from the microphone in real-time by enabling the loopback module (source): $ pactl load-module module-loopback

The module will show up in the Recording tab of the pavucontrol program, where the source and volume can be configured. While latency should be low, it should be sufficient to get a feeling of the sound quality as you will hear yourself speak in the microphone. To make the change permanent, add the following pulseaudio configuration: /etc/pulse/default.pa load-module module-loopback

Watch out for feedback! Be ready to lower all volumes in case the microphone picks up the output from the loudspeakers. Naturally, it is better to run such a test with headphones.

Audio quality

Troubleshooting buffer underruns (glitches, skips, crackling)

The newer implementation of the PulseAudio sound server uses timer-based audio scheduling instead of the traditional, interrupt-driven approach.

Timer-based scheduling may expose issues in some ALSA drivers. On the other hand, other drivers might have a tendency to experience buffer underruns without it on, so check to see what works on your system.

Note: Audio interfaces read from a small ring buffer of samples. This allows the interface to continuously play sound on its own while the kernel occasionally adds samples to the buffer. If the kernel doesn’t add samples fast enough and the buffer is exhausted, the interface will not have anything to play. At this point, the interface improvises audio, which will sound different between makes and models. This is called a “buffer underrun,” and is often labeled as “glitching,” “skipping,” “crackling,” or even “static” or “distortion.”

To turn timer-based scheduling off, add tsched=0 in /etc/pulse/default.pa: /etc/pulse/default.pa load-module module-udev-detect tsched=0

Then restart the PulseAudio server: $ pulseaudio -k $ pulseaudio –start

Do the reverse to enable timer-based scheduling, if not already enabled by default.

If you are using Intel’s IOMMU and experience buffer underruns, add intel_iommu=igfx_off to your kernel command line.

Some Intel audio cards using the snd-hda-intel module need the options vid=8086 pid=8ca0 snoop=0. In order to set them permanently, create/modify the following file including the line below. /etc/modprobe.d/sound.conf options snd-hda-intel vid=8086 pid=8ca0 snoop=0

Please report any such cards to PulseAudio Broken Sound Driver page

If you experience buffer underruns because of kernel page locking or late scheduling, see Gaming#Tweaking kernel parameters for response time consistency.

Static noise when using headphones

Time-based scheduling may be causing this, disable it as explained in #Troubleshooting buffer underruns (glitches, skips, crackling).

Another reason you are encountering static noise in your headphone jack could be ALSA’s loopback mixing.

Make sure you have alsa-utils installed, launch alsamixer, then select your audio device (pressing F6), navigate all the way left using the left arrow, and stop on Loopback, if Enabled disable it using the down arrow. This should not impact audio playback or microphone recording negatively, unless you require loopback mixing.

Some notebook models, like Dell XPS 13 9360, suffer from continuous hissing sound when a headphone is plugged in.

Yet another reason for this symptom could be the power-saving mode of your audio device.[3] If you followed Power management#Audio, revert the changes and check if it solves the problem.

Setting the default fragment number and buffer size in PulseAudio

This article or section needs language, wiki syntax or style improvements. See Help:Style for reference.

Reason: Copied from Linux mint topic with few additions (Discuss in Talk:PulseAudio/Troubleshooting)

Disabling timer-based scheduling

By default, PulseAudio uses timer-based scheduling. In this mode, fixed-size fragments are not used at all, and so the default-fragments and default-fragment-size-msec parameters are ignored. To turn timer-based scheduling off, add tsched=0 in /etc/pulse/default.pa: /etc/pulse/default.pa load-module module-udev-detect tsched=0

Decide on audio device parameters

Instructions below will cause PulseAudio to use a fixed size and number for audio fragments. These settings directly affect latency and power consumption. The latency is determined as default-fragments * default-fragment-size-msec, and the interrupt rate (i.e. how often the application is notified that some sound has indeed been played) is 1000 / default-fragment-size-msec. The considerations are:

  • The total number of fragments must be within the limits accepted by the hardware. Most sound cards are OK with two or more fragments, but some require three or more.
  • Giving the sound card more fragments than strictly necessary increases the latency, does not change power consumption, and does not remove the load from the scheduler. Therefore, it is advised only in the cases when the interrupts are not reliably delivered to the CPU, and one extra fragment beyond the minimum required should always be enough.
  • Giving the sound card bigger fragments increases latency and decreases power consumption.
  • Some applications (games and VoIP) request low latency and result in buffer underruns when PulseAudio cannot fulfill their request.
  • Setting the latency too low will put a lot of stress on the scheduler, also resulting in buffer underruns.

If one does not care about excessive power consumption, then 2 or 3 fragments, 5 ms each, are a reasonable choice.

Modify PulseAudio’s configuration file

/etc/pulse/daemon.conf default-fragments = 3 default-fragment-size-msec = 5

See if it helps

Restart the pulseaudio.service user unit.

Run your applications, listen to the sounds they produce, inspect the journal.

If the buffer underruns are occasional and mostly correlated to the system being highly loaded: this is a scheduler problem, the latency needs to be increased.

If there is metallic sound with the wrong speed from all applications: the most common reason is that you are trying to configure the fragment size which is way too small, like 1 ms. Do not do this.

If some, but not all, applications experience buffer underruns: this is an application that assumes a low-latency setup. So the fragment size must be decreased so that the application request becomes valid.

Choppy sound with analog surround sound setup

The low-frequency effects (LFE) or Subwoofer channel is not remixed per default. To enable it, the following needs to be set in /etc/pulse/daemon.conf : /etc/pulse/daemon.conf remixing-produce-lfe = yes remixing-consume-lfe = yes

You should also consider to set a proper crossover frequency for the LFE- channel. The crossover frequency is the frequency up to which the audio signal is rerouted to the LFE sink. The optimal crossover frequency in Hz depends on the size of all your speakers. /etc/pulse/daemon.conf lfe-crossover-freq = <40-200>

Laggy sound

This issue is due to incorrect buffer sizes. First verify that the variables default-fragments and default-fragment-size-msec are not being set to non default values in the file /etc/pulse/daemon.conf. If the issue is still present, try setting them to the following values: /etc/pulse/daemon.conf default-fragments = 5 default-fragment-size-msec = 2

Choppy/distorted sound

This can result from an incorrectly set sample rate. Try the following setting: /etc/pulse/daemon.conf avoid-resampling = yes #(Needs PA11 or higher) default-sample-rate = 48000

and restart the PulseAudio server.

If one experiences choppy sound in applications using OpenAL, change the sample rate in /etc/openal/alsoft.conf: /etc/openal/alsoft.conf frequency = 48000

Setting the PCM volume above 0 dB can cause clipping. Running alsamixer will allow you to see if this is the problem and if so fix it. Note that ALSA may not correctly export the dB information to PulseAudio. Try the following: /etc/pulse/default.pa load-module module-udev-detect ignore_dB=1

and restart the PulseAudio server. See also #No sound below a volume cutoff or Clipping on a particular output device.

Sound stuttering when streaming over network

When streaming over Wi-Fi using module-native-protocol-tcp, you can experience periodic sound stuttering with buffer underruns. As a workaround, you can try to use the rtp protocol. On the sender side, create an rtp sink: /etc/pulse/default.pa load-module module-null-sink sink_name=rtp load-module module-rtp-send source=rtp.monitor

and switch to it: /etc/pulse/default.pa set-default-sink rtp

On the receiver side, load the rtp module: /etc/pulse/default.pa load-module module-rtp-recv

Pops when starting and stopping playback

PulseAudio can suspend sinks after a period of inactivity. This can make an audible noise (like a crack/pop/scratch). Sometimes even when move the slider volume, or open and close windows (KDE4). This behavior is enabled in default configuration files: /etc/pulse/default.pa load-module module-suspend-on-idle /etc/pulse/system.pa load-module module-suspend-on-idle

Commenting that line in relevant file fixes that issue. A better solution is to add the following file: ~/.config/pulse/default.pa .include /etc/pulse/default.pa .nofail unload-module module-suspend-on-idle .fail

For some devices (eg. Bose Quietcomfort 35 II), setting high enough volume of the device (usually via physical buttons or a slider) eliminates the audible noise after stopping playback. 

Geen opmerkingen:

Een reactie posten

Opmerking: Alleen leden van deze blog kunnen een reactie posten.

Copy a website with Httrack

Met de applicatie httrack kunt u eenvoudig een gehele website naar uw harde schijf kopiëren. Hoewel httrack een terminalapplicatie is zonder...