Skip to content
/ cpiped Public
forked from b-fitzpatrick/cpiped

Captures an audio stream and outputs to a pipe with buffering and silence detection

License

Notifications You must be signed in to change notification settings

ale275/cpiped

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cpiped

Release GitHub commit activity Issues Contributors project_license Stargazers Forks Build flow

c

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.

Contents

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 as only prerequisite

  • Debian
    sudo apt install -y libasound2-dev

Installation

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

Usage

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

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 for a full list of proposed features (and known issues).

Acknowledgments

Top contributors:

contrib.rocks image

About

Captures an audio stream and outputs to a pipe with buffering and silence detection

Topics

Resources

License

Stars

Watchers

Forks

Languages

  • C 79.6%
  • Shell 19.7%
  • Makefile 0.7%