Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
725b06e
added binary build to .gitignore
ale275 Oct 12, 2025
6b262c0
fixed mylog code aesthetic
ale275 Oct 12, 2025
bea1ce2
introduced log verbosity control functionality
ale275 Oct 12, 2025
a7c6893
moved some LOG_INFO message under verbosity control
ale275 Oct 12, 2025
152d7d5
Add files via upload
natedreger Apr 27, 2020
f1f8c1c
Update README.md
natedreger Apr 27, 2020
d723010
Update README.md
natedreger Apr 27, 2020
6ec44c5
aligned NDpiped and cpiped
ale275 Oct 12, 2025
4da6f1b
parameterize pid
maweki Jan 7, 2020
b8e4422
README update
ale275 Oct 12, 2025
b11c922
README update with ToDo list
ale275 Oct 12, 2025
3f7027b
introduced variables for sample size and channel count
ale275 Oct 25, 2025
dab9dcb
made bufsize truly reliant on buffer duration, sample rate and captur…
ale275 Oct 25, 2025
6ea4e4b
linked size of readbuffer to sample size and captured channels
ale275 Oct 25, 2025
1bcc480
added -vv and -vvv options for higher verbosity levels
ale275 Oct 25, 2025
0944a93
cleaned up pid file code
ale275 Nov 2, 2025
abe9841
added -f command line parameter to set sample frequency
ale275 Nov 2, 2025
608e5c0
added settings logging for log verbosity level 1
ale275 Nov 2, 2025
c803b27
modified bufsize calculation
ale275 Nov 2, 2025
3db6206
added export as env variables for sample size, rate and capture chann…
ale275 Nov 2, 2025
ee3b52c
added comments in the signal processing section
ale275 Nov 2, 2025
8594b2d
fixed default sample rate
ale275 Dec 14, 2025
cb31ba1
Create build workflow
ale275 Dec 28, 2025
373c001
README overhaul
ale275 Dec 28, 2025
9d85652
added check to revert to default sample rate if no value is specified…
ale275 Jan 26, 2026
c349cdc
README updated to add "made with C" shield
ale275 Jan 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/cpiped-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: cpiped build

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: install alsasound
run: sudo apt install -y libasound2-dev
- uses: actions/checkout@v4
- name: make
run: make
- name: check executable
run: bash -c "[[ -x cpiped ]]"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cpiped
132 changes: 126 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,127 @@
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.
<h1>cpiped</h1>

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.
[![Release][release-shield]][release-url]
![GitHub commit activity][commit-shield]
[![Issues][issues-shield]][issues-url]
[![Contributors][contributors-shield]][contributors-url]
[![project_license][license-shield]][license-url]
[![Stargazers][stars-shield]][stars-url]
[![Forks][forks-shield]][forks-url]
![Build flow][build-shield]

![c][c-shield]

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](https://github.com/ejurgensen/forked-daapd). On sound detection, it runs a simple script to start playing the associated pipe in forked-daapd.

## Contents
- [Contents](#contents)
- [Features](#features)
- [Getting Started](#getting-started)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Usage](#usage)
- [Options](#options)
- [Env variables](#env-variables)
- [ToDo(s)](#todos)
- [Acknowledgments](#acknowledgments)
- [Top contributors:](#top-contributors)

## Features
- 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

## Getting Started

### Prerequisites
`cpiped` relies on [ALSA lib](http://www.alsa-project.org) as only prerequisite

- Debian
```sh
sudo apt install -y libasound2-dev
```

### Installation
1. Clone the repository
```sh
git clone https://github.com/ale275/cpiped.git
```
2. Make cpiped
```sh
cd cpiped
make
```
4. Install cpiped
```sh
sudo install cpiped /usr/local/sbin/
```

## Usage

`cpiped` is an application meant to be run from command line or demonized

```sh
cpiped [-s arg] [-e arg] [OPTIONS] FIFO
```
FIFO: path to the named pipe where sound will be written

### Options

| 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 |

### Env variables
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

## ToDo(s)
- [ ] Improve Makefile to create dedicated build folder
- [ ] Improve Makefile to add install directive

See the [open issues](https://github.com/ale275/cpiped/issues) for a full list of proposed features (and known issues).

## Acknowledgments

* [cpiped](https://github.com/b-fitzpatrick/cpiped) original code of cpiped by [b-fitzpatrick](https://github.com/b-fitzpatrick)
* [NDpiped](https://github.com/natedreger/NDpiped) modified version writing the buffer only when sound was detected
* [maweki cpiped fork](https://github.com/maweki/cpiped) for parametrized pid file

### Top contributors:

<a href="https://github.com/ale275/cpiped/graphs/contributors">
<img src="https://contrib.rocks/image?repo=ale275/cpiped" alt="contrib.rocks image" />
</a>

<!-- variables -->
[build-shield]: https://github.com/ale275/cpiped/actions/workflows/cpiped-build.yml/badge.svg
[commit-shield]: https://img.shields.io/github/commit-activity/t/ale275/cpiped?style=flat
[release-shield]: https://img.shields.io/github/release/ale275/cpiped.svg?colorB=58839b
[release-url]: https://github.com/ale275/cpiped/releases/latest
[contributors-shield]: https://img.shields.io/github/contributors/ale275/cpiped.svg
[contributors-url]: https://github.com/ale275/cpiped/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/ale275/cpiped.svg?style=flat
[forks-url]: https://github.com/ale275/cpiped/network/members
[stars-shield]: https://img.shields.io/github/stars/ale275/cpiped.svg?style=flat
[stars-url]: https://github.com/ale275/cpiped/stargazers
[issues-shield]: https://img.shields.io/github/issues/ale275/cpiped.svg
[issues-url]: https://github.com/ale275/cpiped/issues
[license-shield]: https://img.shields.io/github/license/ale275/cpiped.svg
[license-url]: https://github.com/ale275/cpiped/blob/master/LICENSE
[c-shield]: https://img.shields.io/badge/made%20with%20C-1f425f?style=flat&logo=c&logoColor=white
Loading