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

Cracks on sound with flat parts #59

Closed
web-sto opened this issue May 7, 2016 · 8 comments
Closed

Cracks on sound with flat parts #59

web-sto opened this issue May 7, 2016 · 8 comments

Comments

@web-sto
Copy link

web-sto commented May 7, 2016

Hello,

I'm using snapcast and python-snapcast with a ubuntu-server and 2 x raspberry pi as clients.
Works very fine.
Hint: If you are using a raspberry pi as client, with phat dac and pam8403 as amp, don't power the amp using operating voltage from raspberry pi. I could hear the "heart beat" of the raspberry on the speaker. Only when I supply power to the amp from a serparate power supply, there was no noise anymore.

But here starts my question:
While having very good quality of sound listening to music, I recently noticed sometimes some sort of tiny cracks on the client. Some investigation made me discover it seem to appear only during news (meaning not music, rather somebody talking). I have the impression it is related to flat parts of the sound. I there is talking with background music there are no cracks to hear.

Any idea?

@ThYpHo0n
Copy link

ThYpHo0n commented May 7, 2016

I had the same with tracks where only bass was played. I've switched to USB soundcards in my 2 RasPis and the problem was gone.

@badaix
Copy link
Owner

badaix commented May 8, 2016

Is this Snapcast related or rather an issue of your DAC? Can you observe the same using e.g. aplay?
Sometimes even better DACs don't like non-native 44.1kHz and apply some poor re-sampling. Maybe you can try to play with different sample rates.

@web-sto
Copy link
Author

web-sto commented May 8, 2016

USB soundcards are not really an option at the moment as I bought 5 phat dacs for the project ...

So I did some further investigation whether the issue is related to hardware or snapcast.

  1. I recorded a news radiostream on another machine using VLC. This stream I converted from mp3 to flac, ogg, wav using audacity.
  2. On the raspberry pi I stopped snapclient
  3. I played all the file using VLC on the raspberry

result: with non of the files I could hear the cracks.

  1. Started snapclient, played the radiostream and I could hear the cracks

It seems it is related to snapcast, propably conversion, as the cracks occur when sound is flat, meaning e.g. between two word of somebody speaking. It seem a crack at the beginning of the flat part and at the end.

Could you tell me how to "play with different sample rates" ? I'm not that familiar with audio specific details.

Currently I'm still on default options. Snapclient on android shows "48000:16:2 - flac".

Thanks

@web-sto
Copy link
Author

web-sto commented May 9, 2016

Hello,

some further comment ...

Reducing the volume on the player (mpd) makes the cracks relatively louder. It seems the volume of the cracks is stable. Just at the moment when the volume on the player is reduced to minimum the cracks disappear.

And it is obvious that it occurs only while talking is played as sound or music with flat parts. On the same channel one can here it while news are played. As soon as this fades to music the cracks disappear.

I have taken a record with the a phone and attached it.

I have not idea if this is related to hardware or soundcast. I hope the expert can guide me to supply the right answers or test.

A nice day to all of you.

cracks.zip

@badaix
Copy link
Owner

badaix commented May 9, 2016

What is your exact configuration? What player are you using? MPD, Mopidy, ...
Maybe it's due to bad resampling before writing the audio signal into the fifo. Can you try to stop the Snapserver (sudo /etc/init.d/snapserver stop) and feed the fifo into aplay instead?
aplay /tmp/snapfifo -f dat

@web-sto
Copy link
Author

web-sto commented May 15, 2016

It took a while as I'm not an expert in this area ...

My configuration:

  1. Ubuntu Server in headless mode running Snapserver, MPD streaming only radio streams
  2. Configuration is mostly default, Android Snapclient shows 48000:16:2 flac
  3. Clients are 2 raspberry pi 2 with PhatDac and amplifier modul PAM8304 connected to speakers
  4. Using python-snapcast on clients to control some features (mute, volume, skip tracks, on/off, restart snapclient) using the hardware buttons of an old radio where I replaced PCB with RaspPi setup

Well finally I managed to test your last advise (sudo /etc/init.d/snapserver stop & aplay /tmp/snapfifo -f dat, struggling a while with message "resource occupied"). The signal I could hear was very weak but I could not recognize the mentioned cracks.

I did some other tests which should help to understand the issue. With a raspberry pi 3 set up from scratch with raspbian. Installed snapclient (meanwhile version 0.7.0).

  1. Test: using built in 3.5mm jack with ear phone
    As very known the sound quality of this set up is very bad, but I could not hear these cracks
  2. Test: adding Phat Dac on this RaspPi using its 3.5mm jack with ear phone
    sound much better now but I could not hear any cracks
  3. Live set up: just using additionally an amplifier modul PAM8304
    Well now one can here the cracks, as mentioned a couple of times, just when there are flat parts in the sound (like in news or talking) and this gets really disturbing. It is best to hear when MPD volume is reduced to almost 0, when it is set to 0 no cracks anymore to hear
  4. Test: Installing snapclient on an Intel NUC i3 machine running Kubuntu using Dell AC511 soundbar
    Again, works brilliant !!! Well, I could not here any cracks.

Summary:

  • Cracks to hear when signal is amplified using PAM8304.
  • To hear when sound has flat parts, disappears immediately when there is music or news with background music

Hello badaix:
Could you help me to test different formats per your advise on the 8th of Mai.
I was able to modify it on MPD (stream played faster then). But I could not figure out how to change the Snapserver/-client configuration to make it work.

Thanks for all the support.

@badaix
Copy link
Owner

badaix commented May 18, 2016

The audio signal is travelling this way:
MPD (audio source -> resampling -> snapfifo) -> snapserver -> FLAC encode -> network -> snapclient -> FLAC decode -> Alsa
Any of these steps is touching or modifying the signal and could potentially introduce the cracks.
What I suggested was to test this, to check if your MPD setup (especially resampling) is working properly:
MPD (audio source -> resampling -> snapfifo) -> aplay -> Alsa
What can be easily tested is:

  • change sample rate (from 48kHz to 44.1kHz)
  • remove FLAC encoding/decoding step: MPD (audio source -> resampling -> snapfifo) -> snapserver -> network -> snapclient -> Alsa
  • Use the file stream: wave file -> snapserver -> network -> snapclient -> Alsa

All configuration changes can be statically applied in etc/default/snapserver, as descibed here. For testing, I suggest to stop the snapserver (sudo /etc/init.d/snapserver stop) and to start it manually from command line. Supported command line parameters are described in the man page and listed by calling snapserver -h
change sample rate:
start snapserver with --sampleformat 44100:16:2
remove FLAC:
start snapserver with --codec pcm
Use the file stream:
Prepare some wave file "file.wav" (not mp3, but purely PCM encoded):
start snapserver with -s file:///path/to/your/file.wav

You can also try to use a different sound card setting in snapclient. By default the device with default in it's name is used. You can list all available devices with snapclient -l:

$ ./snapclient -l
0: default
Playback/recording through the PulseAudio sound server

1: null
Discard all samples (playback) or generate zero samples (capture)

2: pulse
PulseAudio Sound Server

3: sysdefault:CARD=Intel
HDA Intel, AD1984 Analog
Default Audio Device

4: front:CARD=Intel,DEV=0
HDA Intel, AD1984 Analog
Front speakers
...
18: hw:CARD=Intel,DEV=0
HDA Intel, AD1984 Analog
Direct hardware device without any conversions
...

You can configure a different device with snapclient -s <device idx>. In this case e.g. snapclient -s 18 to exclude PulseAudio, that seems to be involved in the default audio chain.

@badaix
Copy link
Owner

badaix commented Jul 29, 2016

Closing old, non reproducible issue. Please reopen if the problem still exists.

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