Subversion Repositories svnkaklik

Compare Revisions

Ignore whitespace Rev 410 → Rev 411

/programy/C/i86x/SID/src/Makefile.am
0,0 → 1,8
bin_PROGRAMS = sidd
sidd_SOURCES = sidd.c
 
# set the include path found by configure
INCLUDES= $(all_includes)
 
# the library search path.
sidd_LDFLAGS = $(all_libraries)
/programy/C/i86x/SID/src/Makefile.in
0,0 → 1,465
# Makefile.in generated by automake 1.10 from Makefile.am.
# @configure_input@
 
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
 
@SET_MAKE@
 
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
bin_PROGRAMS = sidd$(EXEEXT)
subdir = src
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS)
am_sidd_OBJECTS = sidd.$(OBJEXT)
sidd_OBJECTS = $(am_sidd_OBJECTS)
sidd_LDADD = $(LDADD)
sidd_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(sidd_LDFLAGS) \
$(LDFLAGS) -o $@
DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(sidd_SOURCES)
DIST_SOURCES = $(sidd_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
sidd_SOURCES = sidd.c
 
# set the include path found by configure
INCLUDES = $(all_includes)
 
# the library search path.
sidd_LDFLAGS = $(all_libraries)
all: all-am
 
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu src/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
 
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
@list='$(bin_PROGRAMS)'; for p in $$list; do \
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
if test -f $$p \
|| test -f $$p1 \
; then \
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
else :; fi; \
done
 
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
rm -f "$(DESTDIR)$(bindir)/$$f"; \
done
 
clean-binPROGRAMS:
@list='$(bin_PROGRAMS)'; for p in $$list; do \
f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
echo " rm -f $$p $$f"; \
rm -f $$p $$f ; \
done
sidd$(EXEEXT): $(sidd_OBJECTS) $(sidd_DEPENDENCIES)
@rm -f sidd$(EXEEXT)
$(sidd_LINK) $(sidd_OBJECTS) $(sidd_LDADD) $(LIBS)
 
mostlyclean-compile:
-rm -f *.$(OBJEXT)
 
distclean-compile:
-rm -f *.tab.c
 
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sidd.Po@am__quote@
 
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
 
.c.obj:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
 
.c.lo:
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
 
mostlyclean-libtool:
-rm -f *.lo
 
clean-libtool:
-rm -rf .libs _libs
 
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
 
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
 
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
 
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS)
installdirs:
for dir in "$(DESTDIR)$(bindir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
 
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
 
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
 
clean-generic:
 
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
 
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
 
clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
 
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
 
dvi: dvi-am
 
dvi-am:
 
html: html-am
 
info: info-am
 
info-am:
 
install-data-am:
 
install-dvi: install-dvi-am
 
install-exec-am: install-binPROGRAMS
 
install-html: install-html-am
 
install-info: install-info-am
 
install-man:
 
install-pdf: install-pdf-am
 
install-ps: install-ps-am
 
installcheck-am:
 
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
 
mostlyclean: mostlyclean-am
 
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
 
pdf: pdf-am
 
pdf-am:
 
ps: ps-am
 
ps-am:
 
uninstall-am: uninstall-binPROGRAMS
 
.MAKE: install-am install-strip
 
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
clean-generic clean-libtool ctags distclean distclean-compile \
distclean-generic distclean-libtool distclean-tags distdir dvi \
dvi-am html html-am info info-am install install-am \
install-binPROGRAMS install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
pdf pdf-am ps ps-am tags uninstall uninstall-am \
uninstall-binPROGRAMS
 
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
/programy/C/i86x/SID/src/sidd.c
0,0 → 1,969
//
// sidd.c: A VLF signal monitor.
//
// authors: Paul Nicholson (paul@abelian.demon.co.uk), Jakub kakona (kaklik@mlab.cz)
//
 
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/param.h>
#include <fcntl.h>
#include <errno.h>
#include <stdarg.h>
#include <ctype.h>
#include <string.h>
#include <signal.h>
#include <time.h>
#include <sched.h>
#include <linux/soundcard.h>
 
#include <fftw3.h>
 
///////////////////////////////////////////////////////////////////////////////
// Tuneable Settings //
///////////////////////////////////////////////////////////////////////////////
 
#define VERSION "0.94"
 
//
// Number of soundcard bytes to read at a time.
#define NREAD 2048
 
//
// Max number of bands which can be read from the config file.
#define MAXBANDS 20
 
//
// Name of the configuration file.
#define CONFIG_FILE "sidd.conf"
 
///////////////////////////////////////////////////////////////////////////////
// Globals and fixed definitions //
///////////////////////////////////////////////////////////////////////////////
//
// Default values here are over-ridden by the config file.
 
int mode = 1; // 1 = mono, 2 = stereo
int bits = 16; // Sample width, 8 or 16 bits
int BINS = 2048; // Number of frequency bins
#define FFTWID (2 * BINS) // Number of samples in FFT period
 
int background = 1; // Set zero if running in foreground
int fdi; // Input file handle
int fdm; // Mixer file handle
int VFLAG = 0; // Set non-zero by -v option
int MFLAG = 0; // Set non-zero by -m option
 
int spec_max = 100; // Issue a spectrum for every spec_max output records
int spec_cnt = 0;
int sample_rate = 100000; // Samples per second
 
int chans = 1;
int alert_on = 0;
 
int priority = 0; // Set to 1 if high scheduling priority
struct sigaction sa;
char mailaddr[100];
 
double los_thresh = 0; // Threshold for loss of signal, 0..1
int los_timeout = 0; // Number of seconds before loss of signal declared
 
double DF; // Frequency resolution of the FFT
int bailout_flag = 0; // To prevent bailout() looping
int grab_cnt = 0; // Count of samples into the FFT buffer
 
// Mixer gain settings requested by config file.
int req_lgain = -1; // Line gain
int req_mgain = -1; // Microphone gain
int req_igain = -1; // Input gain
int req_rgain = -1; // Record level
 
 
// Actual mixer values, read by open_mixer()
int mixer_recmask; // Recording device mask
int mixer_stereo; // Stereo device mask
int mixer_line; // Line input gain setting
int mixer_microphone; // Microphone input gain
int mixer_igain; // Overall input gain setting
int mixer_reclev; // Recording level setting
int mixer_recsrc; // Mask indicating which inputs are set to record
 
//
// Various filenames, contents set by config file.
//
char logfile[100] = "";
char device[100] = "/dev/dsp";
char mixer[100] = "/dev/mixer";
char spectrum_file[100] = "/tmp/sidspec";
char datadir[100] = ".";
 
//
// Table of frequency bands to monitor
//
 
struct BAND
{
char ident[50];
 
int start;
int end;
}
bands[MAXBANDS]; // Table of bands to be monitored
 
int nbands = 0;
 
//
// Independent state variables and buffers for left and right channels
//
struct CHAN
{
char *name;
double *signal_avg;
double *powspec;
double *fft_inbuf;
fftw_complex *fft_data;
fftw_plan ffp;
double peak;
double sum_sq;
int los_state;
time_t los_time;
FILE *fo;
char fname[100];
}
left = { "left" }, right = { "right" };
 
///////////////////////////////////////////////////////////////////////////////
// Various Utility Functions //
///////////////////////////////////////////////////////////////////////////////
 
//
// Issue a message to the log file, if the verbosity level is high enough...
//
 
void report( int level, char *format, ...)
{
va_list ap;
void bailout( char *format, ...);
char temp[ 200];
 
if( VFLAG < level) return;
 
va_start( ap, format);
vsprintf( temp, format, ap);
va_end( ap);
 
if( !logfile[0] || !background)
if( background != 2) fprintf( stderr, "%s\n", temp);
 
if( logfile[0])
{
time_t now = time( NULL);
struct tm *tm = gmtime( &now);
FILE *flog = NULL;
 
if( (flog = fopen( logfile, "a+")) == NULL)
bailout( "cannot open logfile [%s]: %s", logfile, strerror( errno));
 
fprintf( flog, "%04d/%02d/%02d %02d:%02d:%02d %s\n",
tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec, temp);
fclose( flog);
}
}
 
void alert( char *format, ...)
{
FILE *f;
va_list( ap);
char cmd[100], temp[100];
 
va_start( ap, format);
vsprintf( temp, format, ap);
va_end( ap);
report( -1, "%s", temp);
 
if( !alert_on || !mailaddr[0]) return;
 
sprintf( cmd, "mail -s 'sidd alert' '%s'", mailaddr);
if( (f=popen( cmd, "w")) == NULL)
{
report( 0, "cannot exec [%s]: %s", cmd, strerror( errno));
return;
}
 
fprintf( f, "sidd: %s\n", temp);
fclose( f);
}
 
//
// We try to exit the program through here, if possible.
//
 
void bailout( char *format, ...)
{
va_list ap;
char temp[ 200];
 
if( bailout_flag) exit( 1);
bailout_flag = 1;
va_start( ap, format);
vsprintf( temp, format, ap);
va_end( ap);
 
alert( "terminating: %s", temp);
exit( 1);
}
 
//
// Exit with a message if we get any signals.
//
 
void handle_sigs( int signum)
{
bailout( "got signal %d", signum);
}
 
///////////////////////////////////////////////////////////////////////////////
// Soundcard Setup //
///////////////////////////////////////////////////////////////////////////////
 
//
// Prepare the input stream, setting up the soundcard if the input
// is a character device.
//
 
void setup_input_stream( void)
{
struct stat st;
 
report( 1, "taking data from [%s]", device);
 
if( (fdi = open( device, O_RDONLY)) < 0)
bailout( "cannot open [%s]: %s", strerror( errno));
 
if( fstat( fdi, &st) < 0)
bailout( "cannot stat input stream: %s", strerror( errno));
 
if( S_ISCHR( st.st_mode))
{
int blksize;
int fragreq = 0x7fff000a;
unsigned int format;
unsigned int req_format = AFMT_S16_LE;
if( bits == 8) req_format = AFMT_U8;
 
if (ioctl( fdi, SNDCTL_DSP_SETFRAGMENT, &fragreq))
report( 01, "cannot set fragment size");
 
if( ioctl( fdi, SNDCTL_DSP_RESET, NULL) < 0)
bailout( "cannot reset input device");
 
chans = mode;
if( ioctl( fdi, SNDCTL_DSP_CHANNELS, &chans) < 0)
bailout( "cannot set channels on input device");
 
if( ioctl( fdi, SNDCTL_DSP_GETFMTS, &format) < 0)
bailout( "cannot get formats from input device");
 
report( 2, "formats available: %08X", format);
if( (format & req_format) == 0)
{
report( 0, "available dsp modes are %08X", format);
bailout( "unable to set %d bit dsp mode", bits);
}
 
format = req_format;
if( ioctl( fdi, SNDCTL_DSP_SETFMT, &format) < 0)
bailout( "cannot set dsp format on input device");
 
if( ioctl( fdi, SNDCTL_DSP_GETBLKSIZE, &blksize) < 0)
bailout( "cannot get block size from input device");
 
report( 2, "dsp block size: %d", blksize);
if( ioctl( fdi, SNDCTL_DSP_CHANNELS, &chans) < 0)
bailout( "cannot get channels from input device");
 
report( 1, "requesting rate %d", sample_rate);
if( ioctl( fdi, SNDCTL_DSP_SPEED, &sample_rate) < 0)
bailout( "cannot set sample rate of input device");
 
report( 1, "actual rate set: %d samples/sec", sample_rate);
report( 1, "soundcard channels: %d bits: %d", chans, bits);
}
}
 
///////////////////////////////////////////////////////////////////////////////
// Output Functions //
///////////////////////////////////////////////////////////////////////////////
 
void maybe_output_spectrum( void)
{
FILE *f;
int i;
 
if( ++spec_cnt < spec_max) return; // Wait for spec_max records
spec_cnt = 0;
 
if( !spectrum_file[0]) return; // Spectrum file not wanted.
 
if( (f=fopen( spectrum_file, "w+")) == NULL)
bailout( "cannot open spectrum file %s, %s", strerror( errno));
 
if( mode == 1){
fprintf( f, "Frequency PowerL \n");
for( i=0; i<BINS; i++) fprintf( f, "%.5e %.5e\n",
(i+0.5) * DF, left.signal_avg[i]/spec_max);}
else{
fprintf( f, "Frequncy PowerL PowerR \n");
for( i=0; i<BINS; i++) fprintf( f, "%.5e %.5e %.5e\n",
(i+0.5) * DF, left.signal_avg[i]/spec_max,
right.signal_avg[i]/spec_max);}
fclose( f);
 
for( i=0; i<BINS; i++) left.signal_avg[i] = 0;
if( mode == 2) for( i=0; i<BINS; i++) right.signal_avg[i] = 0;
}
 
void output_record( struct CHAN *c, char *prefix, double fsecs)
{
int i, j;
char test[100];
 
if( mode == 1)
sprintf( test, "%s.dat", prefix);
else
sprintf( test, "%s.%s.dat", prefix, c->name);
 
if( !c->fo || strcmp( test, c->fname))
{
if( c->fo) fclose( c->fo);
strcpy( c->fname, test);
report( 0, "using output file [%s]", c->fname);
if( (c->fo=fopen( c->fname, "a+")) == NULL)
bailout( "cannot open [%s], %s", c->fname, strerror( errno));
}
 
fprintf( c->fo, "%.3f %.3f %.3f", fsecs, c->peak, sqrt( c->sum_sq/FFTWID));
 
for( i=0; i<nbands; i++)
{
double e = 0;
int n1 = bands[i].start/DF;
int n2 = bands[i].end/DF;
for( j=n1; j<= n2; j++) e += c->powspec[j];
e /= n2 - n1 + 1;
fprintf( c->fo, " %.2e", e);
}
fprintf( c->fo, "\n");
fflush( c->fo);
 
c->peak = c->sum_sq = 0;
}
 
void output_records( void)
{
struct timeval tv;
struct tm *tm;
double fsecs;
time_t ud;
char prefix[100];
 
gettimeofday( &tv, NULL);
fsecs = tv.tv_sec + 1e-6 * tv.tv_usec;
ud = tv.tv_sec - tv.tv_sec % 86400;
tm = gmtime( &ud);
sprintf( prefix, "%s/%02d%02d%02d", datadir,
tm->tm_year - 100, tm->tm_mon+1, tm->tm_mday);
 
output_record( &left, prefix, fsecs);
if( mode == 2) output_record( &right, prefix, fsecs);
}
 
void check_los( struct CHAN *c)
{
if( !c->los_state)
{
if( !c->los_time && c->peak < los_thresh) time( &c->los_time);
if( c->los_time && c->peak > los_thresh) c->los_time = 0;
if( c->los_time && c->los_time + los_timeout < time( NULL))
{
c->los_state = 1;
c->los_time = 0;
if( mode == 1) alert( "loss of signal");
else alert( "loss of signal on %s", c->name);
}
}
else
{
if( !c->los_time && c->peak > los_thresh) time( &c->los_time);
if( c->los_time && c->peak < los_thresh) c->los_time = 0;
if( c->los_time && c->los_time + los_timeout < time( NULL))
{
c->los_state = 0;
c->los_time = 0;
if( mode == 1) alert( "signal restored");
else alert( "signal restored on %s", c->name);
}
}
}
 
///////////////////////////////////////////////////////////////////////////////
// Signal Processing //
///////////////////////////////////////////////////////////////////////////////
 
void process_fft( struct CHAN *c)
{
int i;
 
//
// Do the FFT. First time through, initialise the fft plan.
//
 
if( !c->ffp)
c->ffp = fftw_plan_dft_r2c_1d( FFTWID, c->fft_inbuf, c->fft_data,
FFTW_ESTIMATE | FFTW_DESTROY_INPUT);
 
fftw_execute( c->ffp);
 
//
// Obtain squared amplitude of each bin.
//
 
c->powspec[ 0] = 0.0; // Zero the DC component
for( i=1; i<BINS; i++)
{
double t1 = c->fft_data[ i][0];
double t2 = c->fft_data[ i][1];
c->powspec[ i] = t1*t1 + t2*t2;
}
 
//
// Accumulate average signal levels in each bin. signal_avg is used
// only for the spectrum file output.
//
 
for( i=0; i<BINS; i++) c->signal_avg[ i] += c->powspec[i];
check_los( c);
}
 
void insert_sample( struct CHAN *c, double f)
{
c->sum_sq += f * f;
if( f > c->peak) c->peak = f;
if( f < -c->peak) c->peak = -f;
 
c->fft_inbuf[ grab_cnt] = f * sin( grab_cnt/(double) FFTWID * M_PI);
}
 
void maybe_do_fft( void)
{
if( ++grab_cnt < FFTWID) return;
grab_cnt = 0;
 
process_fft( &left);
if( mode == 2) process_fft( &right);
 
output_records();
maybe_output_spectrum();
}
 
//
// Main signal processing loop. Never returns.
//
 
void process_signal( void)
{
unsigned char buff[ NREAD];
 
while( 1)
{
int i, q;
 
if( (q=read( fdi, buff, NREAD)) <= 0)
{
if( !q || errno == ENOENT || errno == 0)
{
sched_yield();
usleep( 50000);
continue;
}
 
report( 0, "input file: read error, count=%d errno=%d", q, errno);
exit( 1);
}
 
// Unpack the input buffer into signed 16 bit words.
// then scale to -1..+1 for further processing.
// We use 'chans' to decide if the soundcard is giving stereo or
// mono samples, rather than 'mode', because some cards will refuse
// to do mono.
if( bits == 16)
{
if( chans == 1)
{
for( i=0; i<q; i += 2)
{
int fh = *(short *)(buff + i);
insert_sample( &left, fh/32768.0);
maybe_do_fft();
}
}
else // chans must be 2
{
if( mode == 1)
for( i=0; i<q; i += 4)
{
int fh = *(short *)(buff + i);
insert_sample( &left, fh/32768.0);
maybe_do_fft();
}
else // mode == 2
for( i=0; i<q; i += 4)
{
int fh = *(short *)(buff + i);
insert_sample( &left, fh/32768.0);
fh = *(short *)(buff + i + 2);
insert_sample( &right, fh/32768.0);
maybe_do_fft();
}
}
}
else // bits must be 8
{
if( chans == 1)
{
for( i=0; i<q; i++)
{
int fh = ((short)buff[i] - 128)*256;
insert_sample( &left, fh/32768.0);
maybe_do_fft();
}
}
else // chans must be 2
{
if( mode == 1)
for( i=0; i<q; i += 2)
{
int fh = ((short)buff[i] - 128)*256;
insert_sample( &left, fh/32768.0);
maybe_do_fft();
}
else // mode == 2
for( i=0; i<q; i += 2)
{
int fh = ((short)buff[i] - 128)*256;
insert_sample( &left, fh/32768.0);
fh = ((short)buff[i+1] - 128)*256;
insert_sample( &right, fh/32768.0);
maybe_do_fft();
}
}
}
}
}
 
///////////////////////////////////////////////////////////////////////////////
// Configuration File Stuff //
///////////////////////////////////////////////////////////////////////////////
 
void config_band( char *ident, char *start, char *end)
{
struct BAND *b = bands + nbands++;
 
if( nbands == MAXBANDS) bailout( "too many bands specified in config file");
 
strcpy( b->ident, ident);
b->start = atoi( start);
b->end = atoi( end);
 
report( 1, "band %s %d %d", b->ident, b->start, b->end);
}
 
void load_config( void)
{
int lino = 0, nf;
FILE *f;
char buff[100], *p, *fields[20];
 
if( (f=fopen( CONFIG_FILE, "r")) == NULL)
bailout( "no config file found");
 
while( fgets( buff, 99, f))
{
lino++;
 
if( (p=strchr( buff, '\r')) != NULL) *p = 0;
if( (p=strchr( buff, '\n')) != NULL) *p = 0;
if( (p=strchr( buff, ';')) != NULL) *p = 0;
 
p = buff; nf = 0;
while( 1)
{
while( *p && isspace( *p)) p++;
if( !*p) break;
fields[nf++] = p;
while( *p && !isspace( *p)) p++;
if( *p) *p++ = 0;
}
if( !nf) continue;
 
if( nf == 4 && !strcasecmp( fields[0], "band"))
config_band( fields[1], fields[2], fields[3]);
else
if( nf == 2 && !strcasecmp( fields[0], "logfile"))
{
strcpy( logfile, fields[1]);
report( 1, "logfile %s", logfile);
}
else
if( nf == 3 && !strcasecmp( fields[0], "los"))
{
los_thresh = atof( fields[1]);
los_timeout = atoi( fields[2]);
report( 1, "los threshold %.3f, timeout %d seconds",
los_thresh, los_timeout);
}
else
if( nf == 2 && !strcasecmp( fields[0], "device"))
strcpy( device, fields[1]);
else
if( nf == 2 && !strcasecmp( fields[0], "mixer"))
strcpy( mixer, fields[1]);
else
if( nf == 2 && !strcasecmp( fields[0], "mode"))
{
if( !strcasecmp( fields[1], "mono")) mode = 1;
else
if( !strcasecmp( fields[1], "stereo")) mode = 2;
else
bailout( "error in config file, line %d", lino);
}
else
if( nf == 2 && !strcasecmp( fields[0], "bits"))
{
bits = atoi( fields[1]);
if( bits != 8 && bits != 16)
bailout( "can only do 8 or 16 bits, config file line %d", lino);
}
else
if( nf == 3 && !strcasecmp( fields[0], "spectrum"))
{
strcpy( spectrum_file, fields[1]);
spec_max = atoi( fields[2]);
}
else
if( nf == 2 && !strcasecmp( fields[0], "sched")
&& !strcasecmp( fields[1], "high"))
{
priority = 1;
}
else
if( nf == 4 && !strcasecmp( fields[0], "gain"))
{
int left = atoi( fields[2]);
int right = atoi( fields[3]);
int gain = (right << 8) | left;
 
if( !strcasecmp( fields[1], "line"))
{
req_lgain = gain;
mixer_recsrc = SOUND_MASK_LINE;
}
else
if( !strcasecmp( fields[1], "mic"))
{
req_mgain = gain;
mixer_recsrc = SOUND_MASK_MIC;
}
else
if( !strcasecmp( fields[1], "overall")) req_igain = gain;
else
if( !strcasecmp( fields[1], "record")) req_rgain = gain;
else
bailout( "unknown gain control [%s]", fields[1]);
}
else
if( nf == 2 && !strcasecmp( fields[0], "rate"))
sample_rate = atoi( fields[1]);
else
if( nf == 2 && !strcasecmp( fields[0], "bins"))
BINS = atoi( fields[1]);
else
if( nf == 2 && !strcasecmp( fields[0], "datadir"))
{
struct stat st;
strcpy( datadir, fields[1]);
if( stat( datadir, &st) < 0 || !S_ISDIR( st.st_mode))
bailout( "no data directory, %s", datadir);
}
else
bailout( "error in config file, line %d", lino);
}
 
fclose( f);
}
 
///////////////////////////////////////////////////////////////////////////////
// Mixer Stuff //
///////////////////////////////////////////////////////////////////////////////
 
void open_mixer( void)
{
if( (fdm = open( mixer, O_RDWR)) < 0)
bailout( "cannot open [%s]: %s", mixer, strerror( errno));
 
// Determine the available mixer recording gain controls.
// We must at least have a line input.
 
if( ioctl( fdm, SOUND_MIXER_READ_RECMASK, &mixer_recmask) < 0)
bailout( "cannot read mixer devmask");
 
if( (mixer_recmask & SOUND_MASK_LINE) == 0)
bailout( "mixer has no line device");
 
if( ioctl( fdm, SOUND_MIXER_READ_STEREODEVS, &mixer_stereo) < 0)
bailout( "cannot read mixer stereodevs");
 
if( ioctl( fdm, SOUND_MIXER_READ_RECSRC, &mixer_recsrc) < 0)
bailout( "cannot read mixer recsrc");
 
// Read the line input gain.
if( ioctl( fdm, SOUND_MIXER_READ_LINE, &mixer_line) < 0)
bailout( "cannot read mixer line");
 
// Read overall input gain? Optional.
if( (mixer_recmask & SOUND_MASK_IGAIN) &&
ioctl( fdm, SOUND_MIXER_READ_IGAIN, &mixer_igain) < 0)
bailout( "cannot read mixer igain");
 
// Read overall recording level? Optional.
if( (mixer_recmask & SOUND_MASK_RECLEV) &&
ioctl( fdm, SOUND_MIXER_READ_RECLEV, &mixer_reclev) < 0)
bailout( "cannot read mixer reclev");
}
 
void report_mixer_settings( void)
{
report( 1, "mixer: line input is %s",
mixer_stereo & SOUND_MASK_LINE ? "stereo" : "mono");
 
report( 1, "mixer: line input is %s",
mixer_recsrc & SOUND_MASK_LINE ? "on" : "off");
 
report( 1, "mixer: line input gain: left=%d right=%d",
mixer_line & 0xff, (mixer_line >> 8) & 0xff);
 
// Overall input gain? Optional.
if( mixer_recmask & SOUND_MASK_IGAIN)
{
report( 1, "mixer: igain: left=%d right=%d",
mixer_igain & 0xff, (mixer_igain >> 8) & 0xff);
}
else report( 1, "mixer: igain: n/a");
 
// Overall recording level? Optional.
if( mixer_recmask & SOUND_MASK_RECLEV)
{
report( 1, "mixer: reclev: left=%d right=%d",
mixer_reclev & 0xff, (mixer_reclev >> 8) & 0xff);
}
else report( 1, "mixer: reclev: n/a");
 
}
 
void setup_mixer( void)
{
if( req_lgain >= 0)
{
report( 1, "requesting line input gains left=%d right=%d",
req_lgain & 0xff, (req_lgain >> 8) & 0xff);
 
if( ioctl( fdm, SOUND_MIXER_WRITE_LINE, &req_lgain) < 0 ||
ioctl( fdm, SOUND_MIXER_READ_LINE, &mixer_line) < 0)
bailout( "error setting mixer line gain");
 
report( 1, "line input gains set to: left=%d right=%d",
mixer_line & 0xff, (mixer_line >> 8) & 0xff);
}
 
if( req_mgain >= 0)
{
report( 1, "requesting microphone input gains left=%d right=%d",
req_mgain & 0xff, (req_mgain >> 8) & 0xff);
 
if( ioctl( fdm, SOUND_MIXER_WRITE_MIC, &req_mgain) < 0 ||
ioctl( fdm, SOUND_MIXER_READ_MIC, &mixer_microphone) < 0)
bailout( "error setting mixer microphone gain");
 
report( 1, "Microphone input gains set to: left=%d right=%d",
mixer_microphone & 0xff, (mixer_microphone >> 8) & 0xff);
}
 
if( req_igain >= 0 &&
(mixer_recmask & SOUND_MASK_IGAIN))
{
report( 1, "requesting overall input gains left=%d right=%d",
req_igain & 0xff, (req_igain >> 8) & 0xff);
 
if( ioctl( fdm, SOUND_MIXER_WRITE_IGAIN, &req_igain) < 0 ||
ioctl( fdm, SOUND_MIXER_READ_IGAIN, &mixer_igain) < 0)
bailout( "error setting mixer overall input gain");
 
report( 1, "overall input gains set to: left=%d right=%d",
mixer_igain & 0xff, (mixer_igain >> 8) & 0xff);
}
 
if( req_rgain >= 0 &&
(mixer_recmask & SOUND_MASK_RECLEV))
{
report( 1, "requesting overall record levels left=%d right=%d",
req_rgain & 0xff, (req_rgain >> 8) & 0xff);
 
if( ioctl( fdm, SOUND_MIXER_WRITE_RECLEV, &req_rgain) < 0 ||
ioctl( fdm, SOUND_MIXER_READ_RECLEV, &mixer_reclev) < 0)
bailout( "error setting mixer record level");
 
report( 1, "mixer record levels set to: left=%d right=%d",
mixer_reclev & 0xff, (mixer_reclev >> 8) & 0xff);
}
 
//mixer_recsrc= SOUND_MASK_LINE;
mixer_recsrc= SOUND_MASK_MIC;
 
switch (mixer_recsrc)
{
case SOUND_MASK_MIC:
if( ioctl( fdm, SOUND_MIXER_WRITE_RECSRC, &mixer_recsrc) < 0)
bailout( "cannot set mixer recsrc to microphone");
else report(1, "Input device set to microphone");
break;
 
case SOUND_MASK_LINE:
if( ioctl( fdm, SOUND_MIXER_WRITE_RECSRC, &mixer_recsrc) < 0)
bailout( "cannot set mixer recsrc to line");
else report(1, "Input device set to line");
break;
}
}
 
///////////////////////////////////////////////////////////////////////////////
// Main //
///////////////////////////////////////////////////////////////////////////////
 
void make_daemon( void)
{
int childpid, fd;
 
if( (childpid = fork()) < 0)
bailout( "cannot fork: %s", strerror( errno));
else if( childpid > 0) exit( 0);
 
if( setpgrp() == -1) bailout( "cannot setpgrp");
 
if( (childpid = fork()) < 0)
bailout( "cannot fork: %s", strerror( errno));
else if( childpid > 0) exit( 0);
 
for( fd = 0; fd <NOFILE; fd++) if( fd != fdi) close( fd);
errno = 0;
background = 2;
}
 
void initialise_channel( struct CHAN *c)
{
int i;
 
c->fft_inbuf = (double *) malloc( BINS * 2 * sizeof( double));
c->fft_data = fftw_malloc( sizeof( fftw_complex) * FFTWID);
c->powspec = (double *) malloc( BINS * sizeof( double));
c->signal_avg = (double *) malloc( BINS * sizeof( double));
for( i=0; i<BINS; i++) c->signal_avg[i] = 0;
}
 
void setup_signal_handling( void)
{
sa.sa_handler = handle_sigs;
sigemptyset( &sa.sa_mask);
sa.sa_flags = 0;
sigaction( SIGINT, &sa, NULL);
sigaction( SIGTERM, &sa, NULL);
sigaction( SIGHUP, &sa, NULL);
sigaction( SIGQUIT, &sa, NULL);
sigaction( SIGFPE, &sa, NULL);
sigaction( SIGBUS, &sa, NULL);
sigaction( SIGSEGV, &sa, NULL);
}
 
// Set scheduling priority to the minimum SCHED_FIFO value.
void set_scheduling( void)
{
struct sched_param pa;
int min = sched_get_priority_min( SCHED_FIFO);
 
pa.sched_priority = min;
if( sched_setscheduler( 0, SCHED_FIFO, &pa) < 0)
report( -1, "cannot set scheduling priority: %s", strerror( errno));
else
report( 0, "using SCHED_FIFO priority %d", min);
}
 
int main( int argc, char *argv[])
{
while( 1)
{
int c = getopt( argc, argv, "vfm");
 
if( c == 'v') VFLAG++;
else
if( c == 'm') MFLAG++;
else
if( c == 'f') background = 0;
else if( c == -1) break;
else bailout( "unknown option [%c]", c);
}
 
setup_signal_handling();
load_config();
open_mixer();
 
if( MFLAG)
{
VFLAG = 1;
background = 0;
report_mixer_settings();
exit( 0);
}
 
setup_mixer();
if( background && !logfile[0])
report( -1, "warning: no logfile specified for daemon");
 
setup_input_stream();
DF = (double) sample_rate/(double) FFTWID;
 
report( 1, "resolution: bins=%d fftwid=%d df=%f", BINS, FFTWID, DF);
report( 1, "spectrum file: %s", spectrum_file);
 
initialise_channel( &left);
if( mode == 2) initialise_channel( &right);
 
if( background) make_daemon();
if( priority) set_scheduling();
 
report( 0, "sidd version %s: starting work", VERSION);
alert_on = 1;
process_signal();
return 0;
}
 
/programy/C/i86x/SID/src/sidd.conf
0,0 → 1,77
; Specify a file into which sidd will write messages.
logfile ./sidd.log
 
; The input device and mixer
device /dev/dsp
mixer /dev/mixer
 
; Specify the mode of operation - stereo or mono. In stereo mode,
; sidd will run two independent monitors, each with its own output file.
 
mode stereo
 
; The requested sample rate. The software will use the closest
; setting available from the soundcard.
rate 48000
 
; Sample size, 8 or 16 bits. 16 bits is strongly recommended, 8 bit is
; provided in case your soundcard or driver doesn't do 16.
 
bits 16
 
; Number of frequency bins to use. The FFT size is 2*bins and the program
; will issue an output record every (2*bins)/rate seconds.
bins 2048
 
; Line input gains, left and right. If using mono, set them both the same.
; Range is 0 to 100. The logfile will report the actual values set, which
; may differ a little.
;gain line 77 100
 
gain mic 100 100
 
; Overall input gains, comments as above.
;gain overall 86 100
 
; Overall record level, comments as above.
;gain record 100 100
 
; Specify a directory to contain daily data files. Use '.' for the
; current directory. Output files will be datadir/yymmdd.dat when running
; in mono, otherwise datadir/yymmdd.left.dat and datadir/yymmdd.right.dat
datadir .
 
; Enable real time scheduling of sidd. Recommended so that soundcard buffers
; are read promptly, which means minimum latency before each fft buffer is
; timestamped. You have to be running as root for this to work.
sched high
 
; Specify the email address of whoever is to get any bad news.
; mail someone@someplace
 
; The loss-of-signal warning threshold and time delay. If the input
; signal peak level (0-1.0) falls below the given threshold for more than
; the delay time, a warning will be issued. The threshold applies to both
; left and right in stereo mode, on the assumption that you've set the gains
; so that the signal levels are about the same anyway.
los 0.06 5
 
; Specify a file into which spectrum data will regularly be written.
; This file is overwritten with a fresh spectrum roughly every
; 100 * 2 * bins/rate seconds. The spectrum file contains three space
; separated columns: bin centre frequency (Hz) and the average power
; in the bin (relative), for the left and right channels. In mono mode,
; there are just two columns
spectrum /tmp/sidspec 100
 
; Specify the channels to monitor. The ident field is not actually used by
; sidd.
;
; ident from to
band 18k3HWU 18200 18400 ; Le Blanc, France
band 19k6GBZ 19480 19680 ; Anthorn, UK
band 22k1GBZ 22050 22150 ; Skelton, UK
band 20k3ICV 20190 20340 ; Tavolara, Italy
band B1 20800 21000 ; Background channel
band B2 22650 22850 ; Background channel
 
/programy/C/i86x/SID/src/sidd.log
0,0 → 1,5
2007/11/28 16:40:23 mixer: line input is stereo
2007/11/28 16:40:23 mixer: line input is off
2007/11/28 16:40:23 mixer: line input gain: left=0 right=0
2007/11/28 16:40:23 mixer: igain: n/a
2007/11/28 16:40:23 mixer: reclev: n/a