cpiped captures an audio stream and outputs it to a pipe
cpiped was born to capture line-in audio from a sound card and send it to forked-daapd. On sound detection, it runs a simple script to start playing the associated pipe in forked-daapd.
- Buffering to handle clock mismatch
- Command execution on sound and silence detection
- User defined noise threshold
- Different sample rate handling
- Multiple instances running in parallel thanks to parametrized pid
cpiped relies on ALSA lib as only prerequisite
- Debian
sudo apt install -y libasound2-dev
- Clone the repository
git clone https://github.com/ale275/cpiped.git
- Make cpiped
cd cpiped make - Install cpiped
sudo install cpiped /usr/local/sbin/
cpiped is an application meant to be run from command line or demonized
cpiped [-s arg] [-e arg] [OPTIONS] FIFOFIFO: path to the named pipe where sound will be written
| Option | Description | Type | Default | Range | Required? |
|---|---|---|---|---|---|
-d |
ALSA capture device in hw:<card>,<device> format. | string |
'default' |
No | |
-f |
ALSA capture device sample rate in Hz. | integer |
44100 |
16000 - 192000 |
No |
-b |
Buffer size in seconds. | float |
.25 |
.1 - 5.0 |
No |
-s |
Command to run, in background, when sound is detected. | string |
Yes | ||
-e |
Command to run, in background, when silence is detected. | string |
Yes | ||
-t |
Silence threshold expressed as signal power. | integer |
100 |
1 - 32767 |
No |
-D |
Daemonize. | bool |
No | ||
-p |
Path to pidfile. | string |
'/var/run/cpiped.pid' |
No | |
-v |
Log verbosity. (-vv and -vvv for higher verbosity levels) |
bool |
No |
On start cpiped will set the following env variables
- CPIPED_SR audio capture sample rate in Hz
- CPIPED_SS audio capture sample size in bit(s)
- CPIPED_CC audio capture channel(s) count
Those variables are visible by the sound and silence detect commands
- Improve Makefile to create dedicated build folder
- Improve Makefile to add install directive
See the open issues for a full list of proposed features (and known issues).
- cpiped original code of cpiped by b-fitzpatrick
- NDpiped modified version writing the buffer only when sound was detected
- maweki cpiped fork for parametrized pid file