Skip to content

bcm2835-codec sound distortions issue (clipping at volume level above 85%) #5587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
qrp73 opened this issue Aug 30, 2023 · 5 comments
Closed

Comments

@qrp73
Copy link

qrp73 commented Aug 30, 2023

Describe the bug

When sound volume is above 85% it leads to a sound distortion. Oscilloscope shows that there is amplitude clipping.

RPI4 output waveform at volume level 75%:
SDS00068

RPI4 output waveform at volume level 100%:
SDS00077

This clipping distortion is present for any load impedance (tested for open output, 57 kΩ and 32 Ω).

Steps to reproduce the behaviour

  1. Open audacity
  2. Select Generate->Tone
  3. Generate 200 Hz sine with amplitude 0.9999
  4. Play it
  5. Use OS Volume Control to change volume from 50% to 100% and notice that there is distortion appears at about 86%

Expected result: clean sine sound at 100% volume level.

Actual result: sound distortions happens when volume level is more than 85%

Device (s)

Raspberry Pi 4 Mod. B

System

$ cat /etc/rpi-issue
Raspberry Pi reference 2023-05-03
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 7c750947a959fb626a70c09fd17c65815df192ac, stage4

$ vcgencmd version
Mar 17 2023 10:50:39
Copyright (c) 2012 Broadcom
version 82f3750a65fadae9a38077e3c2e217ad158c8d54 (clean) (release) (start)

$ uname -a
Linux raspi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux

Logs

there is no error in the log related to this bug

Additional context

No response

@qrp73 qrp73 changed the title bcm2835-codec sound distortions issue bcm2835-codec sound distortions issue (clipping at volume level above 85%) Aug 30, 2023
@popcornmix
Copy link
Collaborator

The analogue audio on Pi boards is rather low level for headphones use which can result in too quiet audio for some headphones.

Because of this, we allow the audio to be overdriven by 4dB (see here).

When going above 0, you will clip a full range signal. But if you know signal is not full range, you may choose to get the higher volume level.

When using alsamixer to set volume, it shows red when above 0dB and clipping can occur. The recommendation is to not go above that if you may be using full range signals.

@qrp73
Copy link
Author

qrp73 commented Aug 30, 2023

how to disable this 4 dB overdrive? I don't need distorted gain. I want to set 100% volume and don't get clipping for max level signal.

@popcornmix
Copy link
Collaborator

From a linux point of view, you run aslamixer.
You choose (F6) sound card (bcm2835 Headphones).
When you adjust the volume you see on left "Item PCM [db gain: 4.00]" (when at max volume, in red).
Make sure that stays no higher than 0.00.

But I'm less familiar with pulseaudio, so I'm not sure how that interacts.
But looking at it, as I adjust volume in alsamixer, the volume bar in desktop panel (left-click speaker icon)
updates, so it looks like they interact okay.

@qrp73
Copy link
Author

qrp73 commented Aug 31, 2023

well is it possible to disable dB gain above 0 dB in the driver? So that 100% volume bar in the desktop panel can be equals to 0 dB gain for bcm2835 and alsamixer will be unable to set gain above 0 dB for bcm2835 and alsamixer Master volume 100% can be equals to 0 dB gain for bcm2835?

Can you provide some configurable option like "bcm2835codec_overdrive" which can enable or disable distorted gain above 0 dB for bcm2835?

@qrp73
Copy link
Author

qrp73 commented Nov 15, 2023

not relevant anymore

@qrp73 qrp73 closed this as completed Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants