From f3d79bd82bfd3a7baa5e83d4cd8236fd527dc339 Mon Sep 17 00:00:00 2001 From: Xiangfu Liu Date: Sat, 15 Oct 2011 10:14:50 +0800 Subject: [PATCH] new package: listener automatically records when sound is detected --- listener/Makefile | 47 +++++++++++++++++++ listener/files/listener.conf | 20 ++++++++ listener/patches/100-makefile.patch | 28 +++++++++++ .../200-fix-the-config-file-to-etc.patch | 28 +++++++++++ 4 files changed, 123 insertions(+) create mode 100644 listener/Makefile create mode 100644 listener/files/listener.conf create mode 100644 listener/patches/100-makefile.patch create mode 100644 listener/patches/200-fix-the-config-file-to-etc.patch diff --git a/listener/Makefile b/listener/Makefile new file mode 100644 index 0000000..d6dc03b --- /dev/null +++ b/listener/Makefile @@ -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)) diff --git a/listener/files/listener.conf b/listener/files/listener.conf new file mode 100644 index 0000000..6ce989b --- /dev/null +++ b/listener/files/listener.conf @@ -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 diff --git a/listener/patches/100-makefile.patch b/listener/patches/100-makefile.patch new file mode 100644 index 0000000..999b1b4 --- /dev/null +++ b/listener/patches/100-makefile.patch @@ -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 diff --git a/listener/patches/200-fix-the-config-file-to-etc.patch b/listener/patches/200-fix-the-config-file-to-etc.patch new file mode 100644 index 0000000..fbb2f3b --- /dev/null +++ b/listener/patches/200-fix-the-config-file-to-etc.patch @@ -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 + +