Skip to content
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

White noise at a base level while playing (at any volume) through HDMI, raspberry 3 [Resolved?] #601

Closed
adam-kral opened this issue Oct 16, 2017 · 15 comments

Comments

@adam-kral
Copy link

Hi, I have raspberry pi 3 connected via HDMI to a receiver/amplifier and I'm experiencing some white noise while the music is playing. When I pause the playback, it disappears. I haven't modified the settings, it worked with HDMI by default. The white noise is the same level disregarding sound level set on streaming device, so I can clearly hear it when the streaming volume is low. The noise becomes louder when amplifier volume is increased.

Thanks for replying

@mikebrady
Copy link
Owner

Thanks for the interesting post. Can I ask if you are using the hardware mixer — i.e. have you used the mixer_control_name setting in the alsa group within the settings file?

@adam-kral
Copy link
Author

adam-kral commented Oct 16, 2017

No, I left that commented out, too. Should I use some specific setting?

@mikebrady
Copy link
Owner

mikebrady commented Oct 16, 2017

Yes, you should use output device “hw:0”, and use the mixer control name “PCM” (use alsamixer to explore the device, see mixer names, etc.).

The reason it is better to use a hardware mixer is that Shairport Sync has full control of the volume range of the HDMI output and passes the audio signal directly to the output DAC, unaltered except for stuffing.

If you don’t use a hardware mixer, Shairport Sync uses a software mixer to control the output volume. Since the software mixer manipulates the signal, a two-bit dither has to be introduced. In a 16-bit range, this can be heard as a low level white noise. On 24-bit or 32-bit outputs, it’s inaudible.

Please let us know how it works out.

@adam-kral
Copy link
Author

adam-kral commented Oct 16, 2017

Thanks. So I added lines

output_device = "hw:0";
mixer_control_name = "PCM";

and restarted rpi 3. It still plays, but again with the white noise.

@mikebrady
Copy link
Owner

Yes, they are the correct settings. Unfortunately, this means that the source of white noise must lie elsewhere — for example, what is your source?

Another line of thinking is this: what if it isn’t white noise exactly, but is a low level somewhat irregular ticking hiss — i.e. not white noise as such? If there was a great deal of interpolation (i.e. “stuffing”) going on, it might be barely audible and might just account for this. So, to be clear, it wouldn’t account for true white noise but might account for a low level irregular clicking noise.

If you enable statistics in the configuration file and look in the log to see how much correction is going on, it might be instructive.

@adam-kral
Copy link
Author

It definitely plays louder and maybe better (but maybe just an illusion, questionable).

The noise is perceived like a continuous low vol level "ssssssss", I don't know what do you mean by irregular (on a human level?). The larger speaker from my speaker system emits lower frequency hiss, while the small ones emit higher positioned hiss.

My power source is a new ipad charger.

The statistics log:

Oct 16 17:40:35 raspberrypi shairport-sync[502]: -3.3,     490.2,     719.5,        1003,      0,     14,      0,      1,   5795,  176,  232
Oct 16 17:40:43 raspberrypi shairport-sync[502]: -0.1,     243.6,    1382.2,        2006,      0,     24,      0,      1,   5987,  221,  232
Oct 16 17:40:51 raspberrypi shairport-sync[502]: 0.2,      22.7,    1353.9,        3009,      0,     40,      0,      1,   5970,  215,  233
Oct 16 17:40:59 raspberrypi shairport-sync[502]: 0.4,     -82.1,    1345.4,        4012,      0,     74,      0,     12,   6011,  175,  232
Oct 16 17:41:07 raspberrypi shairport-sync[502]: 0.3,     -17.0,    1348.2,        5015,      0,    103,      0,     16,   6016,  172,  232
Oct 16 17:41:15 raspberrypi shairport-sync[502]: 0.2,      90.6,    1608.8,        6018,      0,    113,      0,     16,   5986,  175,  233
Oct 16 17:41:23 raspberrypi shairport-sync[502]: 0.3,      31.2,    1560.7,        7021,      0,    120,      0,     21,   6006,  215,  233
Oct 16 17:41:31 raspberrypi shairport-sync[502]: 0.5,     -56.6,    1580.5,        8024,      0,    130,      0,     21,   5978,  176,  233
Oct 16 17:41:40 raspberrypi shairport-sync[502]: -16.9,     351.2,     623.1,        9027,      0,    160,      0,     29,   4937,  174,  232
Oct 16 17:41:48 raspberrypi shairport-sync[502]: -10.8,    2506.7,    2625.6,       10030,      0,    179,      0,     36,   5065,  172,  231
Oct 16 17:41:56 raspberrypi shairport-sync[502]: -0.1,     203.9,    1512.5,       11033,      0,    202,      0,     37,   5984,  173,  231
Oct 16 17:42:04 raspberrypi shairport-sync[502]: 0.2,      59.5,    1266.1,       12036,      0,    203,      0,     37,   6013,  226,  231
Oct 16 17:42:12 raspberrypi shairport-sync[502]: 0.2,       0.0,    1183.9,       13039,      0,    213,      0,     37,   6000,  225,  231
Oct 16 17:42:20 raspberrypi shairport-sync[502]: 0.2,     -17.0,    1251.9,       14042,      0,    231,      0,     40,   6012,  216,  231
Oct 16 17:42:28 raspberrypi shairport-sync[502]: Playback Stopped. Total playing time 00:02:04.
Oct 16 17:44:26 raspberrypi shairport-sync[502]: sync error in milliseconds, net correction in ppm, corrections in ppm, total packets, missing packets, late packets, too late packets, resend requests, min DAC queue size, min b
Oct 16 17:44:37 raspberrypi shairport-sync[502]: 1.0,    -134.5,     437.7,        1003,      0,     16,      0,      3,   5983,  171,  230
Oct 16 17:44:45 raspberrypi shairport-sync[502]: -0.0,     -14.2,     994.2,        2006,      0,     31,      0,      3,   5975,  225,  230
Oct 16 17:44:53 raspberrypi shairport-sync[502]: -0.1,     -42.5,    1056.5,        3009,      0,     40,      0,      3,   6041,  225,  230
Oct 16 17:45:01 raspberrypi shairport-sync[502]: -0.1,      82.1,     977.2,        4012,      0,     47,      0,      3,   6030,  225,  230
Oct 16 17:45:09 raspberrypi shairport-sync[502]: -0.0,     -59.5,    1045.2,        5015,      0,     51,      0,      3,   5946,  224,  230
Oct 16 17:45:17 raspberrypi shairport-sync[502]: -0.2,      14.2,     977.2,        6018,      0,     59,      0,      3,   5946,  224,  231
Oct 16 17:45:25 raspberrypi shairport-sync[502]: -0.2,      31.2,    1073.5,        7021,      0,     75,      0,      5,   5968,  216,  230
Oct 16 17:45:33 raspberrypi shairport-sync[502]: -0.0,     -42.5,    1016.8,        8024,      0,     83,      0,      5,   5938,  223,  230
Oct 16 17:45:41 raspberrypi shairport-sync[502]: -0.1,     -34.0,     980.0,        9027,      0,     86,      0,      5,   5992,  224,  230
Oct 16 17:45:49 raspberrypi shairport-sync[502]: -0.1,     -31.2,     977.2,       10030,      0,     92,      0,      5,   5962,  224,  230
Oct 16 17:45:57 raspberrypi shairport-sync[502]: -0.1,      36.8,    1028.2,       11033,      0,     96,      0,      5,   5937,  224,  230
Oct 16 17:46:05 raspberrypi shairport-sync[502]: -0.0,     -85.0,     940.4,       12036,      0,     98,      0,      5,   5944,  225,  230
Oct 16 17:46:13 raspberrypi shairport-sync[502]: -0.2,      51.0,    1025.3,       13039,      0,    105,      0,      5,   5918,  224,  230
Oct 16 17:46:21 raspberrypi shairport-sync[502]: -0.2,      36.8,    1124.5,       14042,      0,    114,      0,      5,   6001,  216,  230
Oct 16 17:46:29 raspberrypi shairport-sync[502]: -0.1,       0.0,     980.0,       15045,      0,    120,      0,      5,   5979,  224,  230
Oct 16 17:46:37 raspberrypi shairport-sync[502]: -0.1,      -2.8,    1033.8,       16048,      0,    121,      0,      5,   5924,  224,  230
Oct 16 17:46:45 raspberrypi shairport-sync[502]: -0.2,      17.0,    1031.0,       17051,      0,    132,      0,      5,   5939,  224,  230
Oct 16 17:46:53 raspberrypi shairport-sync[502]: -0.1,      14.2,     960.2,       18054,      0,    138,      0,      5,   5989,  221,  230
Oct 16 17:47:01 raspberrypi shairport-sync[502]: 0.0,     -25.5,     982.8,       19057,      0,    143,      0,      5,   5949,  224,  230
Oct 16 17:47:09 raspberrypi shairport-sync[502]: -0.0,     -22.7,    1059.3,       20060,      0,    145,      0,      5,   5917,  223,  230
Oct 16 17:47:17 raspberrypi shairport-sync[502]: -0.2,       8.5,    1084.8,       21063,      0,    146,      0,      5,   5945,  224,  230
Oct 16 17:47:25 raspberrypi shairport-sync[502]: -0.1,      -5.7,    1285.9,       22066,      0,    152,      0,      7,   5911,  173,  230
Oct 16 17:47:33 raspberrypi shairport-sync[502]: -0.1,      28.3,    1053.7,       23069,      0,    156,      0,      7,   6022,  225,  230
Oct 16 17:47:41 raspberrypi shairport-sync[502]: -0.1,     -25.5,    1045.2,       24072,      0,    161,      0,      7,   5872,  225,  230
Oct 16 17:47:49 raspberrypi shairport-sync[502]: -0.1,     -36.8,    1209.4,       25075,      0,    181,      0,      7,   5964,  168,  230

@mikebrady
Copy link
Owner

Thanks. There is a great deal of overcorrection occurring. Take the third line, for example: – the difference between the second column (net corrections) [example 22.7] and the third (total corrections) [example 1353.9]. Much better to give Shairport Sync a wider drift tolerance – if you look in the README.md, in the section on the Raspberry Pi, a tolerance of 10 milliseconds is suggested. That will greatly reduce the amount of correction being done. Not sure it will fix the problem, but it'll help.

@adam-kral
Copy link
Author

adam-kral commented Oct 16, 2017

I'll try. But in the readme it seems to be associated with raspberry's DAC, which I thought I would completely circumvent using hdmi (= digital audio), no? I'm a noob, but I don't understand it.

@mikebrady
Copy link
Owner

mikebrady commented Oct 16, 2017

Meh, I don't know either. I thought the DAC and the HDMI were out of the same device. Worth trying...

@coreygreenberg
Copy link

FWIW I hear the same noise issue on my two RPi3 systems, both running Stretch and fitted with add-on Hifiberry DACs. With the playback system's volume turned up but nothing being Airplayed, there is no background noise or hum, but as soon as I start streaming music from iTunes to the RPi3, there is a persistent white noise in the background. It can be heard by itself if I keep the playback system turned up but lower the volume in the iTunes app running on my music server. As soon as the music is paused, the noise stops.

@mikebrady
Copy link
Owner

I’m using a Pimoroni PHAT, which uses the same overlay as the Hifiberry devices. It has no built-in hardware mixer, so Shairport Sync must use the software volume control and must introduce two bits of dither to avoid noticeable low-level artefacts. That’s where the white noise comes from on my setup, and I guess that’s where it is coming from on @coreygreenberg’s.

However, the Pimoroni PHAT, and I guess the Hifiberry devices, are all capable of 32-bit operation, so by setting the output to S32 (Signed 32-bit) in the configuration file, the dither is introduced as the lowest two bits of a 32-bit sample rather than the lowest two bits of a 16-bit sample and is, to my ears anyway, inaudible. @coreygreenberg, it’s worth trying 32-bit output.

@coreygreenberg
Copy link

coreygreenberg commented Oct 17, 2017

Thanks for the advice @mikebrady -- setting the output to S32 got rid of the noise.

For RPi3 users running Shairport-Sync with add-on DACs like the Hifiberry and PHAT:

  1. Launch Terminal and type "sudo leafpad" to open the text editor that has root privileges to edit the config file.

  2. In Leafpad, open the configuration file shairport-sync.conf.

  3. In the alsa section, uncomment "output_format" and change the default from S16 to S32:

alsa =
{
...
//  output_device = "default"; // the name of the alsa output device. Use "alsamixer" or "aplay" to find out the names of devices, mixers, etc.
//  mixer_control_name = "PCM"; // the name of the mixer to use to adjust output volume. If not specified, volume in adjusted in software.
//  mixer_device = "default"; // the mixer_device default is whatever the output_device is. Normally you wouldn't have to use this.
//  output_rate = 44100; // can be 44100, 88200, 176400 or 352800, but the device must have the capability.
  output_format = "S32"; // can be "U8", "S8", "S16", "S24", "S24_3LE", "S24_3BE" or "S32", but the device must have the capability. Except where stated using (*LE or *BE), endianness matches that of the processor.
...
};
  1. Save shairport-sync.conf, quit Leafpad, go back to Terminal and type "$ sudo reboot".

  2. Once the Pi boots up again, you should hear Airplay audio again minus the added dither noise @mikebrady mentioned earlier.

  3. Thanks Mike!

@mikebrady
Copy link
Owner

Fixed?

@mikebrady mikebrady changed the title White noise at a base level while playing (at any volume) through HDMI, raspberry 3 White noise at a base level while playing (at any volume) through HDMI, raspberry 3 [Resolved?] Nov 24, 2017
@coreygreenberg
Copy link

Sorry, I thought my previous reply explained that yes, the issue was fixed by your solution of changing S16 to S32 in the config file, as long as it's a DAC capable of 32-bit operation as your PHAT and my HifiBerry are. Since changing S16 to S32, the audible white noise overlay is gone (or at least inaudible even with ear pressed against tweeter). Thanks again Mike!

@mikebrady
Copy link
Owner

Cool, thanks!

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

3 participants