Giter Club home page Giter Club logo

cpiped's Introduction

cpiped captures an audio stream and outputs it to a pipe with a bit of buffering to handle clock mismatch. It also includes silence/sound detection and the ability to run a command on detection.

I'm using this to capture line-in audio from a sound card and send it to forked-daapd (https://github.com/ejurgensen/forked-daapd). On sound detection, it runs a simple script to start playing the associated pipe in forked-daapd.

cpiped's People

Contributors

b-fitzpatrick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cpiped's Issues

Support for single channel

I tried to get single channel input to work in my fork, but I could not get it to work.

abelmatser/cpiped

The mono audio input still sounds jittery. I heard this same jittery sound when capturing mono audio as stereo (arecord without -c 1 option) and forwarding this to snapcast.

What works:
sudo arecord -r 44100 -f S16_LE -D hw:1,0 > /tmp/snapfifo
What does not work:
sudo ./cpiped -c 1 -d hw:1,0 /tmp/snapfifo

constant buffering even with silence

This program is exactly what I need to get my whole house audio setup going. One catch I'm having is that even with silence the buffer keeps writing to my fifo file. Have tried setting the silence threshold to max and no different. This may not be an issue for others but I'm using forked-daapd to automatically play when a fifo starts and using cpiped and Shairport to feed it.

I've tried different sound cards and different paths in arecord, no help.

Hope someone can help!

Minor Skips when sending through forked-daapd

Thanks for this, found this in a raspberrypi forum, and successfully set it up with forked-daapd. However, the music tends to skip every 10 seconds or so, did you encounter this? And how did you fix it?

Also, I am unable to set the buffer above 0.5, only below down to about .095 works

Allow for parameters in silence and start commands

I wanted to start a custom script with a parameter when cpiped detects a sound but there is a check whether this is a valid file. But since I have a space with the parameters, that is not a valid file. Removing the check from the source code works.

I am not good at writing C or I would have sent a fix. Sorry

At the end I get

Invalid start command: /root/cpiped-snapcast-ctrl/playing.py chromecast

but actually executing it works fine.

Slowed down playback

Hello again - I am trying to debug this but figured I could ask for your help again after your assistance last week.

Looking further into my skipping issue, it turns out it was happening every so often because the output is slightly slower playback than the input, causing overruns from time to time. The slow playback is barely noticeable, but it's there. If I play a non-FIFO file through forked-daapd, the playback is correct so I'm thinking it must be something with the FIFO.

Any ideas on how to resolve this? I tried switching up the "val =" bitrate from 44100 to 48000, since the input through USB is coming in at 48kHz according to

`cat /proc/asound/card0/pcm0p/sub0/hw_params

No worries if not, just kind of stuck here. Really appreciate any help you can provide.

create release tag

We would like to package this for Alpine Linux. Would it be possible to create a release tag?

installation and set up with forked-daapd

Hi all,

I've found cpiped as a working solution to stream from a vinyl record player to a Homepod using a raspberry pi.

I've configured forked-daapd and wokrs great (streaming from spotify and other sources), but can't find a way to install cpiped and make it work.

My setup:

  1. Behringer UFO202 USB audio adapter (which connects the vinyl record player to te RPI)
  2. RPI 3 b+ with standard setup of forked-daapd

Can anyone give me a clue of how to set up cpiped, I'm newbie with RPI and Linux command line.

Thanks in advance!

ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave

Hello!

Thanks for making this :)

Can i have some help?

if i do
/usr/local/bin/cpiped -D /tmp/snapfifo
it works for a few hours, but if i use the init.d script, it just says

systemd[1]: Starting LSB: Captures sound card audio and outputs to a pipe...
cpiped[7706]: Starting up.
systemd[1]: Started LSB: Captures sound card audio and outputs to a pipe.
cpiped[7700]: ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave
cpiped[7707]: Unable to open pcm device: No such file or directory
cpiped[7707]: Stopping due to error.

this is the cpiped config file

PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Audio capture to a pipe" # Introduce a short description here
NAME=cpiped                    # Introduce the short server's name here
DAEMON=/usr/local/bin/cpiped   # Introduce the server's location here
DAEMON_ARGS="-D /tmp/snapfifo" # Edit this!
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

Sudden Extremely Loud Static from Cpiped

I have an unfortunate issue when using cpiped to capture music from an aux device and pipe it into snapcast to play on multiple stereos. Suddenly all of the stereos will start blasting an extremely loud static noise at an inhuman volume. Its quite terrifying! This happens about once a day, but seems to be occurring with more frequency. I believe the problem is linked to cpiped because the system returns to normal playback when I restart the cpiped daemon, but not if I restart the snapcast daemons. Cpiped is running on a raspberry pi with Raspbian Buster.

Anybody else experienced this behavior?

buffer issues

I got regular "Filling buffer" messages when reading from a usb audio device (Behringer UFO202 & RPI 3 model B), even with nothing reading from the named pipe.

FWIW, these seem to have disappeared since changing the sample rate from 44100 to 48000 in cpiped.c and recompiling (also setting matching minimum and maximum buffer limits).

Speech_recognition to access microphone to get many warnings like

In Python 3.7

ALSA lib pcm_dsnoop.c:638:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1075:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_a52.c:823:(_snd_pcm_a52_open) a52 is only for playback
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_dmix.c:1075:(snd_pcm_dmix_open) unable to open slave

How to solve this poroblem

buffer overrun

I'm getting distortion with Cpiped feeding into Owntone which I assume are buffering problems. If I use arecord I get overrun messages ("overrun!!! (at least 6935.229 ms long)") but it then works fine. So I assume that my buffer overrun may be too much for cpiped max buffer of 5s. Is it possible to extend the buffer size in Cpiped? I'm happy to try and rebuild it myself (if a new first for me) if you can point me to which part of the code needs to be altered.

with thanks

Use card via card number

Somehow on my setup I can't use the name of cards. When I want to use alsamixer I have to use alsamixer -c 1. None of the names that aplay -l gives me are "accepted" by cpiped.

I always get

Starting up.
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM Device
Unable to open pcm device: No such file or directory

If there was a way to use the card number that would be great.

Cannot compile in ubuntu 16.10 32 bits

Hello,

I'm trying to complie in my ubuntu box 32 bits but has this errors:

/tmp/ccnkWhD5.o: En la función myterm': /home/rafa/cpiped/cpiped.c:54: referencia a snd_pcm_drain' sin definir
/home/rafa/cpiped/cpiped.c:55: referencia a snd_pcm_close' sin definir /tmp/ccnkWhD5.o: En la función main':
/home/rafa/cpiped/cpiped.c:233: referencia a snd_pcm_open' sin definir /home/rafa/cpiped/cpiped.c:235: referencia a snd_strerror' sin definir
/home/rafa/cpiped/cpiped.c:238: referencia a snd_pcm_hw_params_sizeof' sin definir /home/rafa/cpiped/cpiped.c:238: referencia a snd_pcm_hw_params_sizeof' sin definir
/home/rafa/cpiped/cpiped.c:239: referencia a snd_pcm_hw_params_any' sin definir /home/rafa/cpiped/cpiped.c:240: referencia a snd_pcm_hw_params_set_access' sin definir
/home/rafa/cpiped/cpiped.c:241: referencia a snd_pcm_hw_params_set_format' sin definir /home/rafa/cpiped/cpiped.c:242: referencia a snd_pcm_hw_params_set_channels' sin definir
/home/rafa/cpiped/cpiped.c:243: referencia a snd_pcm_hw_params_set_rate_near' sin definir /home/rafa/cpiped/cpiped.c:247: referencia a snd_pcm_hw_params_set_period_size_near' sin definir
/home/rafa/cpiped/cpiped.c:250: referencia a snd_pcm_hw_params' sin definir /home/rafa/cpiped/cpiped.c:252: referencia a snd_strerror' sin definir
/home/rafa/cpiped/cpiped.c:257: referencia a snd_pcm_hw_params_get_period_time' sin definir /home/rafa/cpiped/cpiped.c:260: referencia a snd_pcm_hw_params_get_period_size' sin definir
/home/rafa/cpiped/cpiped.c:300: referencia a snd_pcm_readi' sin definir /home/rafa/cpiped/cpiped.c:316: referencia a sqrt' sin definir
/home/rafa/cpiped/cpiped.c:303: referencia a snd_pcm_prepare' sin definir /home/rafa/cpiped/cpiped.c:307: referencia a snd_strerror' sin definir

Sorry, it's in spanish. I have libasound2-dev installed, but I thing I'm missing any other package. Can you help me? Thanks in advance.

Sound skipping

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

Installation

Sorry for that dump question but how can i install cpiped?

i did a "git clone" and then "make", but "make install" did not work for me.
Maybe you can give me a short explanation.
Thank you in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.