new package: listener automatically records when sound is detected

This commit is contained in:
Xiangfu Liu 2011-10-15 10:14:50 +08:00
parent ecb69c77e3
commit f3d79bd82b
4 changed files with 123 additions and 0 deletions

47
listener/Makefile Normal file
View File

@ -0,0 +1,47 @@
#
# Copyright (C) 2006-2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=listener
PKG_VERSION:=1.7.2
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tgz
PKG_SOURCE_URL:=http://www.vanheusden.com/listener/
PKG_MD5SUM:=8ad9c24c45c7d28aed606304a2bf80bf
include $(INCLUDE_DIR)/package.mk
define Package/listener
SECTION:=sound
CATEGORY:=Sound
DEPENDS:=+libncurses +libsndfile
TITLE:=Listener automatically records when sound is detected
URL:=http://www.vanheusden.com/listener/
endef
define Package/listener/description
This program listens for sound. If it detects any, it starts recording
automatically and also automatically stops when things become silent
again.
endef
TARGET_CFLAGS+= -DCONFIGFILE=\\\"/etc/listener.conf\\\"
define Package/listener/install
$(INSTALL_DIR) $(1)/usr/bin
$(CP) $(PKG_BUILD_DIR)/{listener,listenersoundpipe,setlistener} $(1)/usr/bin/
$(INSTALL_DIR) $(1)/etc
$(CP) $(FILES_DIR)/listener.conf $(1)/etc/
$(INSTALL_DIR) $(1)/usr/share/listener
$(CP) $(PKG_BUILD_DIR)/manual.html $(1)/usr/share/listener/
endef
$(eval $(call BuildPackage,listener))

View File

@ -0,0 +1,20 @@
wav_path = /usr/share/listener/
fname_template = listener-%h-%y%m%d-%H%M%S.wav
devname = /dev/dsp
detect_level = 1
min_duration = 10
rec_silence = 5
max_duration = 60
min_triggers = 2
sample_rate = 8000
channels = 1
format=wav
amplify = off
start_amplify = 1.5
max_amplify = 10.0
fixed_amplify = no
safe_after_filter = no
one_shot = no
#compression = a-law
#filter = ./my_filter2.so.0.1 0 3000.0 1.0

View File

@ -0,0 +1,28 @@
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ VERSION=1.7.2
INSTALL_PREFIX=/usr/local
-CFLAGS+=-g -O2 -Wall -DVERSION=\"$(VERSION)\"
+CFLAGS+=-DVERSION=\"$(VERSION)\"
OBJSsl=sl.o snd_dev.o error.o utils.o
OBJSli=listener.o snd_dev.o error.o utils.o lib.o
@@ -11,13 +11,13 @@ OBJSsp=snd_dev.o lsp.o error.o utils.o
all: setlistener listener listenersoundpipe
setlistener: $(OBJSsl)
- $(CC) -g -Wall -W $(OBJSsl) -ldl -lncurses -o setlistener
+ $(CC) $(CFLAGS) $(OBJSsl) $(LDFLAGS) -ldl -lncurses -o setlistener
listener: $(OBJSli)
- $(CC) -g -Wall -W $(OBJSli) -ldl -lm -lsndfile -o listener -DCONFIGFILE=$(INSTALL_PREFIX)/etc/listener.conf
+ $(CC) $(CFLAGS) $(OBJSli) $(LDFLAGS) -ldl -lm -lsndfile -o listener -DCONFIGFILE=$(INSTALL_PREFIX)/etc/listener.conf
listenersoundpipe: $(OBJSsp)
- $(CC) -g -Wall -W $(OBJSsp) -o listenersoundpipe
+ $(CC) $(CFLAGS) $(OBJSsp) -o listenersoundpipe
install: setlistener listener listenersoundpipe
cp setlistener $(INSTALL_PREFIX)/bin

View File

@ -0,0 +1,28 @@
diff --git a/Makefile b/Makefile
index 4b25e62..48f4caa 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ setlistener: $(OBJSsl)
$(CC) $(CFLAGS) $(OBJSsl) $(LDFLAGS) -ldl -lncurses -o setlistener
listener: $(OBJSli)
- $(CC) $(CFLAGS) $(OBJSli) $(LDFLAGS) -ldl -lm -lsndfile -o listener -DCONFIGFILE=$(INSTALL_PREFIX)/etc/listener.conf
+ $(CC) $(CFLAGS) $(OBJSli) $(LDFLAGS) -ldl -lm -lsndfile -o listener
listenersoundpipe: $(OBJSsp)
$(CC) $(CFLAGS) $(OBJSsp) -o listenersoundpipe
diff --git a/listener.h b/listener.h
index 5cdf088..88b93ee 100644
--- a/listener.h
+++ b/listener.h
@@ -1,7 +1,9 @@
#define SAMPLE_RATE 44100
#define WAV_PATH "listen_wav_out"
#define DSP_PATH "/dev/dsp"
-#define CONFIGFILE "/usr/local/etc/listener.conf"
+#ifndef CONFIGFILE
+ #define CONFIGFILE "/usr/local/etc/listener.conf"
+#endif
#define MAX_N_LIBRARIES 16