b-fitzpatrick / cpiped

Captures an audio stream and outputs to a pipe with buffering and silence detection
GNU General Public License v3.0
71 stars 13 forks source link

Sound skipping #15

Closed tonysprenk closed 1 year ago

tonysprenk commented 2 years ago

I’ve successfully setup cpiped and owntone on a raspberry pi zero w to play audio from my record player (through behringer ufo202) to my HomePod. Everything is working fine except that the audio skips forward once every ten seconds or so. I have tried to set the buffer parameter (-b) to 4 or 5 but this doesn’t solve the issue, this is my execution script:

[Unit]
Description=cpiped
After=sound.target

[Service]
Type=forking
KillMode=none
User=pi
ExecStart=/home/pi/bin/cpiped -d "hw:1,0" -b 5 -s /home/pi/bin/soundDetect.sh -e /home/p>ExecStop=/usr/bin/killall -9 cpiped
WorkingDirectory=/home/pi

[Install]
WantedBy=multi-user.target
walkeret commented 1 year ago

I had the same issue. This comment from rccoe (adding/changing asound.conf) resolved it for me, by helping to set the correct sampling rate at 44.1: https://github.com/b-fitzpatrick/cpiped/issues/2

After the changes to /etc/asound.conf, don't forget to replace "hw:1,0" with "device" (no quotes) in the cpiped script. I did a 1.5 second buffer but I found buffer time didn't matter very much after making this change, since it seems to have been mainly about the sampling rate.

I'm streaming vinyl from a Behringer UFO202 and I noticed this also fixed the pitch, as play was also coming back slow before this fix. Hope this helps!

tonysprenk commented 1 year ago

Thank you so much for this suggestion. I want to try to see if it works for me. I have created the asound.conf file but I cannot remember where I can find the cpiped script to edit the "hw:1,0". It has been a while since I set this up. Any suggestions?

walkeret commented 1 year ago

Sure thing.

It should be at /lib/systemd/system/cpiped.service

Here's how I have mine configured:

[Unit]
Description=cpiped
After=sound.target

[Service]
Type=forking
KillMode=none
User=walkeret
ExecStart=/home/walkeret/bin/cpiped -d device  -b 1.5  -s /home/walkeret/bin/soundDetect.sh -e /home/walkeret/bin/soundAbsence.sh -t 100 -D /home/walkeret/.audioDetectPipe
ExecStop=/usr/bin/killall -9 cpiped
WorkingDirectory=/home/walkeret

[Install]
WantedBy=multi-user.target

Cheers.

tonysprenk commented 1 year ago

Thanks for this unfortunately I haven't got it working again, I remember when I set uitup a long time ago everything was working except for the audio skipping. Is there any way I can test wether chipped is receiving anything?

walkeret commented 1 year ago

You might want to check these:

sudo systemctl status owntone
sudo systemctl status cpiped
tonysprenk commented 1 year ago

for copied im getting the following error: Unable to open pcm device: No such file or directory

tonysprenk commented 1 year ago

ok I had to change hardware to "1" instead of "0" in asound.conf. Now copied is running but im not yet getting audio. Investigating.

walkeret commented 1 year ago

Had a feeling that was your issue and was about to recommend a double-check of settings in asound.conf (note also that the device number can sometimes change after a reboot unless you take extra measures). Good luck!

tonysprenk commented 1 year ago

The buffer is filling in cpiped. in owntone I can see that the pipe is playing normally but no audio from the homepod. Any troubleshooting suggestions?

tonysprenk commented 1 year ago

It's working! I had to press pause and then play in owntone. After that it starts and stops automatically. Audio is flawless too! thanks for your out of the blue suggestion. I am very happy I finally got this working. I had already given up on this. I will finally be able to close this issue. Thanks again!

chk86 commented 1 year ago

Just an update: this helped me out. I was experiencing similar issues with buffering and pitch using a Behringer UFO202 connected to a rasberry pi but was able to follow the comment linked above about adding a asound.conf to set the correct sampling rate at 44.1.