diff options
Diffstat (limited to 'alsa-utils/speaker-test')
-rw-r--r-- | alsa-utils/speaker-test/Makefile.am | 9 | ||||
-rw-r--r-- | alsa-utils/speaker-test/Makefile.in | 616 | ||||
-rw-r--r-- | alsa-utils/speaker-test/pink.c | 96 | ||||
-rw-r--r-- | alsa-utils/speaker-test/pink.h | 15 | ||||
-rw-r--r-- | alsa-utils/speaker-test/readme.txt | 12 | ||||
-rw-r--r-- | alsa-utils/speaker-test/samples/Makefile.am | 20 | ||||
-rw-r--r-- | alsa-utils/speaker-test/samples/Makefile.in | 396 | ||||
-rw-r--r-- | alsa-utils/speaker-test/samples/sample_map.csv | 2 | ||||
-rw-r--r-- | alsa-utils/speaker-test/speaker-test.1 | 125 | ||||
-rw-r--r-- | alsa-utils/speaker-test/speaker-test.c | 1031 |
10 files changed, 2322 insertions, 0 deletions
diff --git a/alsa-utils/speaker-test/Makefile.am b/alsa-utils/speaker-test/Makefile.am new file mode 100644 index 0000000..e3551bc --- /dev/null +++ b/alsa-utils/speaker-test/Makefile.am @@ -0,0 +1,9 @@ +INCLUDES = -I$(top_srcdir)/include +SUBDIRS= samples +LDADD = $(LIBINTL) -lm + +bin_PROGRAMS = speaker-test +speaker_test_SOURCES = speaker-test.c pink.c +man_MANS = speaker-test.1 +EXTRA_DIST = readme.txt speaker-test.1 pink.h + diff --git a/alsa-utils/speaker-test/Makefile.in b/alsa-utils/speaker-test/Makefile.in new file mode 100644 index 0000000..2ad0c75 --- /dev/null +++ b/alsa-utils/speaker-test/Makefile.in @@ -0,0 +1,616 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 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@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +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 = speaker-test$(EXEEXT) +subdir = speaker-test +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \ + $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ + $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \ + $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/aconfig.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_speaker_test_OBJECTS = speaker-test.$(OBJEXT) pink.$(OBJEXT) +speaker_test_OBJECTS = $(am_speaker_test_OBJECTS) +speaker_test_LDADD = $(LDADD) +am__DEPENDENCIES_1 = +speaker_test_DEPENDENCIES = $(am__DEPENDENCIES_1) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(speaker_test_SOURCES) +DIST_SOURCES = $(speaker_test_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-exec-recursive install-info-recursive \ + install-recursive installcheck-recursive installdirs-recursive \ + pdf-recursive ps-recursive uninstall-info-recursive \ + uninstall-recursive +man1dir = $(mandir)/man1 +NROFF = nroff +MANS = $(man_MANS) +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALSACONF_FALSE = @ALSACONF_FALSE@ +ALSACONF_TRUE = @ALSACONF_TRUE@ +ALSAMIXER_FALSE = @ALSAMIXER_FALSE@ +ALSAMIXER_TRUE = @ALSAMIXER_TRUE@ +ALSA_CFLAGS = @ALSA_CFLAGS@ +ALSA_LIBS = @ALSA_LIBS@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CURSESINC = @CURSESINC@ +CURSESLIB = @CURSESLIB@ +CURSES_CFLAGS = @CURSES_CFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +LDFLAGS = @LDFLAGS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +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@ +POSUB = @POSUB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SND_UTIL_MAJOR = @SND_UTIL_MAJOR@ +SND_UTIL_MINOR = @SND_UTIL_MINOR@ +SND_UTIL_SUBMINOR = @SND_UTIL_SUBMINOR@ +SND_UTIL_VERSION = @SND_UTIL_VERSION@ +STRIP = @STRIP@ +TESTSOUND = @TESTSOUND@ +USE_NLS = @USE_NLS@ +USE_XMLTO_FALSE = @USE_XMLTO_FALSE@ +USE_XMLTO_TRUE = @USE_XMLTO_TRUE@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +ac_ct_CC = @ac_ct_CC@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +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@ +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@ +ncurses5_config = @ncurses5_config@ +ncursesw5_config = @ncursesw5_config@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +xmlto = @xmlto@ +INCLUDES = -I$(top_srcdir)/include +SUBDIRS = samples +LDADD = $(LIBINTL) -lm +speaker_test_SOURCES = speaker-test.c pink.c +man_MANS = speaker-test.1 +EXTRA_DIST = readme.txt speaker-test.1 pink.h +all: all-recursive + +.SUFFIXES: +.SUFFIXES: .c .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) --foreign speaker-test/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign speaker-test/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 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(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: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +speaker-test$(EXEEXT): $(speaker_test_OBJECTS) $(speaker_test_DEPENDENCIES) + @rm -f speaker-test$(EXEEXT) + $(LINK) $(speaker_test_LDFLAGS) $(speaker_test_OBJECTS) $(speaker_test_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pink.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/speaker-test.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@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@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@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) '$<'` +uninstall-info-am: +install-man1: $(man1_MANS) $(man_MANS) + @$(NORMAL_INSTALL) + test -z "$(man1dir)" || $(mkdir_p) "$(DESTDIR)$(man1dir)" + @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ + else file=$$i; fi; \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + case "$$ext" in \ + 1*) ;; \ + *) ext='1' ;; \ + esac; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst"; \ + done +uninstall-man1: + @$(NORMAL_UNINSTALL) + @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + case "$$ext" in \ + 1*) ;; \ + *) ext='1' ;; \ + esac; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " rm -f '$(DESTDIR)$(man1dir)/$$inst'"; \ + rm -f "$(DESTDIR)$(man1dir)/$$inst"; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +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: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + 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: ctags-recursive $(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)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + 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 + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(mkdir_p) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(PROGRAMS) $(MANS) +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +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-recursive + +clean-am: clean-binPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: install-man + +install-exec-am: install-binPROGRAMS + +install-info: install-info-recursive + +install-man: install-man1 + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-info-am uninstall-man + +uninstall-info: uninstall-info-recursive + +uninstall-man: uninstall-man1 + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \ + clean clean-binPROGRAMS clean-generic clean-recursive ctags \ + ctags-recursive distclean distclean-compile distclean-generic \ + distclean-recursive distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man install-man1 \ + install-strip installcheck installcheck-am installdirs \ + installdirs-am maintainer-clean maintainer-clean-generic \ + maintainer-clean-recursive mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-recursive pdf pdf-am ps ps-am \ + tags tags-recursive uninstall uninstall-am \ + uninstall-binPROGRAMS uninstall-info-am uninstall-man \ + uninstall-man1 + +# 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: diff --git a/alsa-utils/speaker-test/pink.c b/alsa-utils/speaker-test/pink.c new file mode 100644 index 0000000..ef30755 --- /dev/null +++ b/alsa-utils/speaker-test/pink.c @@ -0,0 +1,96 @@ +/* + patest_pink.c + + generate Pink Noise using Gardner method. + Optimization suggested by James McCartney uses a tree + to select which random value to replace. + + x x x x x x x x x x x x x x x x + x x x x x x x x + x x x x + x x + x + + Tree is generated by counting trailing zeros in an increasing index. + When the index is zero, no random number is selected. + + This program uses the Portable Audio library which is under development. + For more information see: http://www.audiomulch.com/portaudio/ + + Author: Phil Burk, http://www.softsynth.com + + Revision History: + + Copyleft 1999 Phil Burk - No rights reserved. +*/ + +#include <stdio.h> +#include <math.h> +#include "pink.h" + +/************************************************************/ +/* Calculate pseudo-random 32 bit number based on linear congruential method. */ +static unsigned long generate_random_number( void ) +{ + static unsigned long rand_seed = 22222; /* Change this for different random sequences. */ + rand_seed = (rand_seed * 196314165) + 907633515; + return rand_seed; +} + +/* Setup PinkNoise structure for N rows of generators. */ +void initialize_pink_noise( pink_noise_t *pink, int num_rows ) +{ + int i; + long pmax; + pink->pink_index = 0; + pink->pink_index_mask = (1<<num_rows) - 1; +/* Calculate maximum possible signed random value. Extra 1 for white noise always added. */ + pmax = (num_rows + 1) * (1<<(PINK_RANDOM_BITS-1)); + pink->pink_scalar = 1.0f / pmax; +/* Initialize rows. */ + for( i=0; i<num_rows; i++ ) pink->pink_rows[i] = 0; + pink->pink_running_sum = 0; +} + +/* generate Pink noise values between -1.0 and +1.0 */ +float generate_pink_noise_sample( pink_noise_t *pink ) +{ + long new_random; + long sum; + float output; + +/* Increment and mask index. */ + pink->pink_index = (pink->pink_index + 1) & pink->pink_index_mask; + +/* If index is zero, don't update any random values. */ + if( pink->pink_index != 0 ) + { + /* Determine how many trailing zeros in PinkIndex. */ + /* This algorithm will hang if n==0 so test first. */ + int num_zeros = 0; + int n = pink->pink_index; + while( (n & 1) == 0 ) + { + n = n >> 1; + num_zeros++; + } + + /* Replace the indexed ROWS random value. + * Subtract and add back to Running_sum instead of adding all the random + * values together. Only one changes each time. + */ + pink->pink_running_sum -= pink->pink_rows[num_zeros]; + new_random = ((long)generate_random_number()) >> PINK_RANDOM_SHIFT; + pink->pink_running_sum += new_random; + pink->pink_rows[num_zeros] = new_random; + } + +/* Add extra white noise value. */ + new_random = ((long)generate_random_number()) >> PINK_RANDOM_SHIFT; + sum = pink->pink_running_sum + new_random; + +/* Scale to range of -1.0 to 0.9999. */ + output = pink->pink_scalar * sum; + + return output; +} diff --git a/alsa-utils/speaker-test/pink.h b/alsa-utils/speaker-test/pink.h new file mode 100644 index 0000000..0d17f7a --- /dev/null +++ b/alsa-utils/speaker-test/pink.h @@ -0,0 +1,15 @@ +#define PINK_MAX_RANDOM_ROWS (30) +#define PINK_RANDOM_BITS (24) +#define PINK_RANDOM_SHIFT ((sizeof(long)*8)-PINK_RANDOM_BITS) + +typedef struct +{ + long pink_rows[PINK_MAX_RANDOM_ROWS]; + long pink_running_sum; /* Used to optimize summing of generators. */ + int pink_index; /* Incremented each sample. */ + int pink_index_mask; /* Index wrapped by ANDing with this mask. */ + float pink_scalar; /* Used to scale within range of -1.0 to +1.0 */ +} pink_noise_t; + +void initialize_pink_noise( pink_noise_t *pink, int num_rows ); +float generate_pink_noise_sample( pink_noise_t *pink ); diff --git a/alsa-utils/speaker-test/readme.txt b/alsa-utils/speaker-test/readme.txt new file mode 100644 index 0000000..6774fe0 --- /dev/null +++ b/alsa-utils/speaker-test/readme.txt @@ -0,0 +1,12 @@ +To make or build just type + +make + +To test: - +1) Just stereo sound from one stereo jack: - +./speaker-test -Dplug:front -c2 +2) A 4 speaker setup from two stereo jacks: - +./speaker-test -Dplug:surround40 -c4 +3) A 5.1 speaker setup from three stereo jacks: - +./speaker-test -Dplug:surround51 -c6 + diff --git a/alsa-utils/speaker-test/samples/Makefile.am b/alsa-utils/speaker-test/samples/Makefile.am new file mode 100644 index 0000000..8cc3546 --- /dev/null +++ b/alsa-utils/speaker-test/samples/Makefile.am @@ -0,0 +1,20 @@ +sounddir = $(datadir)/sounds/alsa +wav_files = Front_Left.wav \ + Rear_Center.wav \ + Rear_Right.wav \ + Side_Right.wav \ + Front_Center.wav \ + Front_Right.wav \ + Noise.wav \ + Rear_Left.wav \ + Side_Left.wav +sound_DATA = $(wav_files) + +alsadir = $(datadir)/alsa/speaker-test +cfg_files = sample_map.csv + +alsa_DATA = $(cfg_files) + +EXTRA_DIST = \ + $(wav_files) \ + $(cfg_files) diff --git a/alsa-utils/speaker-test/samples/Makefile.in b/alsa-utils/speaker-test/samples/Makefile.in new file mode 100644 index 0000000..2240d2e --- /dev/null +++ b/alsa-utils/speaker-test/samples/Makefile.in @@ -0,0 +1,396 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 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@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +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@ +subdir = speaker-test/samples +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \ + $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ + $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \ + $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/aconfig.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(alsadir)" "$(DESTDIR)$(sounddir)" +alsaDATA_INSTALL = $(INSTALL_DATA) +soundDATA_INSTALL = $(INSTALL_DATA) +DATA = $(alsa_DATA) $(sound_DATA) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALSACONF_FALSE = @ALSACONF_FALSE@ +ALSACONF_TRUE = @ALSACONF_TRUE@ +ALSAMIXER_FALSE = @ALSAMIXER_FALSE@ +ALSAMIXER_TRUE = @ALSAMIXER_TRUE@ +ALSA_CFLAGS = @ALSA_CFLAGS@ +ALSA_LIBS = @ALSA_LIBS@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CURSESINC = @CURSESINC@ +CURSESLIB = @CURSESLIB@ +CURSES_CFLAGS = @CURSES_CFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +LDFLAGS = @LDFLAGS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +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@ +POSUB = @POSUB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SND_UTIL_MAJOR = @SND_UTIL_MAJOR@ +SND_UTIL_MINOR = @SND_UTIL_MINOR@ +SND_UTIL_SUBMINOR = @SND_UTIL_SUBMINOR@ +SND_UTIL_VERSION = @SND_UTIL_VERSION@ +STRIP = @STRIP@ +TESTSOUND = @TESTSOUND@ +USE_NLS = @USE_NLS@ +USE_XMLTO_FALSE = @USE_XMLTO_FALSE@ +USE_XMLTO_TRUE = @USE_XMLTO_TRUE@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +ac_ct_CC = @ac_ct_CC@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +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@ +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@ +ncurses5_config = @ncurses5_config@ +ncursesw5_config = @ncursesw5_config@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +xmlto = @xmlto@ +sounddir = $(datadir)/sounds/alsa +wav_files = Front_Left.wav \ + Rear_Center.wav \ + Rear_Right.wav \ + Side_Right.wav \ + Front_Center.wav \ + Front_Right.wav \ + Noise.wav \ + Rear_Left.wav \ + Side_Left.wav + +sound_DATA = $(wav_files) +alsadir = $(datadir)/alsa/speaker-test +cfg_files = sample_map.csv +alsa_DATA = $(cfg_files) +EXTRA_DIST = \ + $(wav_files) \ + $(cfg_files) + +all: all-am + +.SUFFIXES: +$(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) --foreign speaker-test/samples/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign speaker-test/samples/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 +uninstall-info-am: +install-alsaDATA: $(alsa_DATA) + @$(NORMAL_INSTALL) + test -z "$(alsadir)" || $(mkdir_p) "$(DESTDIR)$(alsadir)" + @list='$(alsa_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(alsaDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(alsadir)/$$f'"; \ + $(alsaDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(alsadir)/$$f"; \ + done + +uninstall-alsaDATA: + @$(NORMAL_UNINSTALL) + @list='$(alsa_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(alsadir)/$$f'"; \ + rm -f "$(DESTDIR)$(alsadir)/$$f"; \ + done +install-soundDATA: $(sound_DATA) + @$(NORMAL_INSTALL) + test -z "$(sounddir)" || $(mkdir_p) "$(DESTDIR)$(sounddir)" + @list='$(sound_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(soundDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(sounddir)/$$f'"; \ + $(soundDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(sounddir)/$$f"; \ + done + +uninstall-soundDATA: + @$(NORMAL_UNINSTALL) + @list='$(sound_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sounddir)/$$f'"; \ + rm -f "$(DESTDIR)$(sounddir)/$$f"; \ + done +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + 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 $(DATA) +installdirs: + for dir in "$(DESTDIR)$(alsadir)" "$(DESTDIR)$(sounddir)"; 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-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-alsaDATA install-soundDATA + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-alsaDATA uninstall-info-am uninstall-soundDATA + +.PHONY: all all-am check check-am clean clean-generic distclean \ + distclean-generic distdir dvi dvi-am html html-am info info-am \ + install install-alsaDATA install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-soundDATA install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ + pdf-am ps ps-am uninstall uninstall-alsaDATA uninstall-am \ + uninstall-info-am uninstall-soundDATA + +# 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: diff --git a/alsa-utils/speaker-test/samples/sample_map.csv b/alsa-utils/speaker-test/samples/sample_map.csv new file mode 100644 index 0000000..20d8ed2 --- /dev/null +++ b/alsa-utils/speaker-test/samples/sample_map.csv @@ -0,0 +1,2 @@ +0, "Front Left", "/usr/share/alsa/samples/Front_Left.wav" +1, "Front Right", "/usr/share/alsa/samples/Front_Right.wav" diff --git a/alsa-utils/speaker-test/speaker-test.1 b/alsa-utils/speaker-test/speaker-test.1 new file mode 100644 index 0000000..f0948a6 --- /dev/null +++ b/alsa-utils/speaker-test/speaker-test.1 @@ -0,0 +1,125 @@ +.\" -*- nroff -*- +.\" macros +.de EX \" Begin Example +. IP +. ft CW +. nf +. ne \\$1 +.. +.de EE \" End Example +. ft P +. fi +. PP +.. +.TH SPEAKER\-TEST 1 "20 September 2004" speaker-test +.SH NAME +speaker\-test \- command-line speaker test tone generator for ALSA +.SH SYNOPSIS +.B speaker\-test [\-options] + +.SH DESCRIPTION +\fBspeaker\-test\fP generates a tone that can be used to test the speakers of a computer. + +.SH OPTIONS + +.TP +\fB\-c\fP | \fB\-\-channels\fP \fINUM\fP +\fINUM\fP channels in stream + +.TP +\fB\-D\fP | \fB\-\-device\fP \fINAME\fP +PCM device name \fINAME\fP + +.TP +\fB\-f\fP | \fB\-\-frequency\fP \fIFREQ\fP +sine wave of \fIFREQ\fP Hz + +.TP +\fB\-\-help\fP +Print usage help + +.TP +\fB\-b\fP | \fB\-\-buffer\fP \fITIME\fP +Use buffer size of \fITIME\fP microseconds. +When 0 is given, use the maximal buffer size. +The default value is 0. + +.TP +\fB\-p\fP | \fB\-\-period\fP \fITIME\fP +Use period size of \fITIME\fP microseconds. +When 0 is given, the periods given by \fB\-P\fP option is used. +The default value is 0. + +.TP +\fB\-P\fP | \fB\-\-nperiods\fP \fPERIODS\fP +Use number of periods. The default value is 4. + +.TP +\fB\-r\fP | \fB\-\-rate\fP \fIRATE\fP +stream of \fIRATE\fP Hz + +.TP +\fB\-t\fP | \fB\-\-test\fP \fBpink\fP|\fBsine\fP|\fBwav\fP +\fB\-t pink\fP means use pink noise (default). + +Pink noise is perceptually uniform noise -- that is, it sounds like every frequency at once. If you can hear any tone it may indicate resonances in your speaker system or room. + +\fB\-t sine\fP means to use sine wave. + +\fB\-t wav\fP means to play WAV files, either pre-defined files or given via \fB\-w\fP option. + +You can pass the number from 1 to 3 as a backward compatibility. + +.TP +\fB\-l\fP | \fB\-\-nloops\fP \fBCOUNT\fP + +Specifies the number of loops. Zero means to run infinitely. + +When \fB\-s\fP option below with a valid channel is given, \fBspeaker\-test\fP will perform +always a single-shot without looping. + +.TP +\fB\-s\fP | \fB\-\-speaker\fP \fBCHANNEL\fP +Do a single-shot speaker test for the given channel. The channel number starts from 1. +The channel number corresponds to left, right, rear-left, rear-right, center, LFE, +side-left, side-right, and so on. + +For example, when 1 is passed, it tests the left channel only once rather than both channels +with looping. + +.TP +\fB\-w\fP | \fB\-\-wavfile\fP +Use the given WAV file for the playback instead of pre-defined WAV files. + +.TP +\fB\-W\fP | \fB\-\-wavdir\fP +Specify the directory containing WAV files for playback. +The default path is \fI/usr/share/sounds/alsa\fP. + + +.SH USAGE EXAMPLES + +Produce stereo sound from one stereo jack: +.EX + speaker-test -Dplug:front -c2 +.EE + +Produce 4 speaker sound from two stereo jacks: +.EX + speaker-test -Dplug:surround40 -c4 +.EE + +Produce 5.1 speaker sound from three stereo jacks: +.EX + speaker-test -Dplug:surround51 -c6 +.EE + +To send a nice low 75Hz tone to the Woofer and then exit without touching any other speakers: +.EX + speaker-test -Dplug:surround51 -c6 -s1 -f75 +.EE + +.SH AUTHOR +The speaker-test program was written by James Courtier-Dutton. +Pink noise support was added by Nathan Hurst. +Further extensions by Takashi Iwai. diff --git a/alsa-utils/speaker-test/speaker-test.c b/alsa-utils/speaker-test/speaker-test.c new file mode 100644 index 0000000..75a4bed --- /dev/null +++ b/alsa-utils/speaker-test/speaker-test.c @@ -0,0 +1,1031 @@ +/* + * Copyright (C) 2000-2004 James Courtier-Dutton + * Copyright (C) 2005 Nathan Hurst + * + * This file is part of the speaker-test tool. + * + * This small program sends a simple sinusoidal wave to your speakers. + * + * speaker-test is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * speaker-test is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * + * Main program by James Courtier-Dutton (including some source code fragments from the alsa project.) + * Some cleanup from Daniel Caujolle-Bert <segfault@club-internet.fr> + * Pink noise option added Nathan Hurst, + * based on generator by Phil Burk (pink.c) + * + * Changelog: + * 0.0.8 Added support for pink noise output. + * Changelog: + * 0.0.7 Added support for more than 6 channels. + * Changelog: + * 0.0.6 Added support for different sample formats. + * + * $Id: speaker_test.c,v 1.00 2003/11/26 19:43:38 jcdutton Exp $ + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sched.h> +#include <errno.h> +#include <getopt.h> +#include <inttypes.h> +#include <ctype.h> +#include <byteswap.h> + +#define ALSA_PCM_NEW_HW_PARAMS_API +#define ALSA_PCM_NEW_SW_PARAMS_API +#include <alsa/asoundlib.h> +#include <sys/time.h> +#include <math.h> +#include "pink.h" +#include "aconfig.h" +#include "gettext.h" +#include "version.h" + +#ifdef ENABLE_NLS +#include <locale.h> +#endif + +enum { + TEST_PINK_NOISE = 1, + TEST_SINE, + TEST_WAV +}; + +#define MAX_CHANNELS 16 + +static char *device = "default"; /* playback device */ +static snd_pcm_format_t format = SND_PCM_FORMAT_S16; /* sample format */ +static unsigned int rate = 48000; /* stream rate */ +static unsigned int channels = 1; /* count of channels */ +static unsigned int speaker = 0; /* count of channels */ +static unsigned int buffer_time = 0; /* ring buffer length in us */ +static unsigned int period_time = 0; /* period time in us */ +static unsigned int nperiods = 4; /* number of periods */ +static double freq = 440; /* sinusoidal wave frequency in Hz */ +static int test_type = TEST_PINK_NOISE; /* Test type. 1 = noise, 2 = sine wave */ +static pink_noise_t pink; +static snd_pcm_uframes_t buffer_size; +static snd_pcm_uframes_t period_size; +static const char *given_test_wav_file = NULL; +static char *wav_file_dir = SOUNDSDIR; + +static const char *const channel_name[MAX_CHANNELS] = { + N_("Front Left"), + N_("Front Right"), + N_("Rear Left"), + N_("Rear Right"), + N_("Center"), + N_("LFE"), + N_("Side Left"), + N_("Side Right"), + N_("Channel 9"), + N_("Channel 10"), + N_("Channel 11"), + N_("Channel 12"), + N_("Channel 13"), + N_("Channel 14"), + N_("Channel 15"), + N_("Channel 16") +}; + +static const int channels4[] = { + 0, + 1, + 3, + 2 +}; +static const int channels6[] = { + 0, + 4, + 1, + 3, + 2, + 5 +}; +static const int channels8[] = { + 0, + 4, + 1, + 7, + 3, + 2, + 6, + 5 +}; + +static void generate_sine(uint8_t *frames, int channel, int count, double *_phase) { + double phase = *_phase; + double max_phase = 1.0 / freq; + double step = 1.0 / (double)rate; + double res; + float fres; + int chn; + int32_t ires; + int8_t *samp8 = (int8_t*) frames; + int16_t *samp16 = (int16_t*) frames; + int32_t *samp32 = (int32_t*) frames; + float *samp_f = (float*) frames; + + while (count-- > 0) { + //res = sin((phase * 2 * M_PI) / max_phase - M_PI) * 32767; + //res = sin((phase * 2 * M_PI) / max_phase - M_PI) * 32767; + //res = (sin((phase * 2 * M_PI) / max_phase - M_PI)) * 0x03fffffff; /* Don't use MAX volume */ + //if (res > 0) res = 10000; + //if (res < 0) res = -10000; + + /* printf("%e\n",res); */ + //ires = res; + //ires = ((16 - (count & 0xf)) <<24); + //ires = 0; + + for(chn=0;chn<channels;chn++) { + switch (format) { + case SND_PCM_FORMAT_S8: + if (chn==channel) { + res = (sin((phase * 2 * M_PI) / max_phase - M_PI)) * 0x03fffffff; /* Don't use MAX volume */ + ires = res; + *samp8++ = ires >> 24; + } else { + *samp8++ = 0; + } + break; + case SND_PCM_FORMAT_S16_LE: + if (chn==channel) { + res = (sin((phase * 2 * M_PI) / max_phase - M_PI)) * 0x03fffffff; /* Don't use MAX volume */ + ires = res; +#if __BYTE_ORDER == __LITTLE_ENDIAN + *samp16++ = ires >> 16; +#elif __BYTE_ORDER == __BIG_ENDIAN + *samp16++ = bswap_16(ires >> 16); +#endif + } else { + *samp16++ = 0; + } + break; + case SND_PCM_FORMAT_S16_BE: + if (chn==channel) { + res = (sin((phase * 2 * M_PI) / max_phase - M_PI)) * 0x03fffffff; /* Don't use MAX volume */ + ires = res; +#if __BYTE_ORDER == __BIG_ENDIAN + *samp16++ = ires >> 16; +#elif __BYTE_ORDER == __LITTLE_ENDIAN + *samp16++ = bswap_16(ires >> 16); +#endif + } else { + *samp16++ = 0; + } + break; + case SND_PCM_FORMAT_FLOAT_LE: + if (chn==channel) { + res = (sin((phase * 2 * M_PI) / max_phase - M_PI)) * 0.75 ; /* Don't use MAX volume */ + fres = res; + *samp_f++ = fres; + //*samp32++ = 0xF2345678; + //printf("res=%lf, ires=%d 0x%x, samp32=0x%x\n",res,ires, ires, samp32[-1]); + } else { + //*samp32++ = ires+0x10000; + //*samp32++ = ires; + *samp_f++ = 0.0; + } + break; + case SND_PCM_FORMAT_S32_LE: + if (chn==channel) { + res = (sin((phase * 2 * M_PI) / max_phase - M_PI)) * 0x03fffffff; /* Don't use MAX volume */ + ires = res; +#if __BYTE_ORDER == __LITTLE_ENDIAN + *samp32++ = ires; +#elif __BYTE_ORDER == __BIG_ENDIAN + *samp32++ = bswap_32(ires); +#endif + } else { + *samp32++ = 0; + } + break; + case SND_PCM_FORMAT_S32_BE: + if (chn==channel) { + res = (sin((phase * 2 * M_PI) / max_phase - M_PI)) * 0x03fffffff; /* Don't use MAX volume */ + ires = res; +#if __BYTE_ORDER == __BIG_ENDIAN + *samp32++ = ires; +#elif __BYTE_ORDER == __LITTLE_ENDIAN + *samp32++ = bswap_32(ires); +#endif + } else { + *samp32++ = 0; + } + break; + default: + ; + } + } + + phase += step; + if (phase >= max_phase) + phase -= max_phase; + } + + *_phase = phase; +} + +/* Pink noise is a better test than sine wave because we can tell + * where pink noise is coming from more easily that a sine wave. + */ + + +static void generate_pink_noise( uint8_t *frames, int channel, int count) { + double res; + int chn; + int32_t ires; + int8_t *samp8 = (int8_t*) frames; + int16_t *samp16 = (int16_t*) frames; + int32_t *samp32 = (int32_t*) frames; + + while (count-- > 0) { + for(chn=0;chn<channels;chn++) { + switch (format) { + case SND_PCM_FORMAT_S8: + if (chn==channel) { + res = generate_pink_noise_sample(&pink) * 0x03fffffff; /* Don't use MAX volume */ + ires = res; + *samp8++ = ires >> 24; + } else { + *samp8++ = 0; + } + break; + case SND_PCM_FORMAT_S16_LE: + if (chn==channel) { + res = generate_pink_noise_sample(&pink) * 0x03fffffff; /* Don't use MAX volume */ + ires = res; +#if __BYTE_ORDER == __LITTLE_ENDIAN + *samp16++ = ires >> 16; +#elif __BYTE_ORDER == __BIG_ENDIAN + *samp16++ = bswap_16(ires >> 16); +#endif + } else { + *samp16++ = 0; + } + break; + case SND_PCM_FORMAT_S16_BE: + if (chn==channel) { + res = generate_pink_noise_sample(&pink) * 0x03fffffff; /* Don't use MAX volume */ + ires = res; +#if __BYTE_ORDER == __BIG_ENDIAN + *samp16++ = ires >> 16; +#elif __BYTE_ORDER == __LITTLE_ENDIAN + *samp16++ = bswap_16(ires >> 16); +#endif + } else { + *samp16++ = 0; + } + break; + case SND_PCM_FORMAT_S32_LE: + if (chn==channel) { + res = generate_pink_noise_sample(&pink) * 0x03fffffff; /* Don't use MAX volume */ + ires = res; +#if __BYTE_ORDER == __LITTLE_ENDIAN + *samp32++ = ires; +#elif __BYTE_ORDER == __BIG_ENDIAN + *samp32++ = bswap_32(ires); +#endif + } else { + *samp32++ = 0; + } + break; + case SND_PCM_FORMAT_S32_BE: + if (chn==channel) { + res = generate_pink_noise_sample(&pink) * 0x03fffffff; /* Don't use MAX volume */ + ires = res; +#if __BYTE_ORDER == __BIG_ENDIAN + *samp32++ = ires; +#elif __BYTE_ORDER == __LITTLE_ENDIAN + *samp32++ = bswap_32(ires); +#endif + } else { + *samp32++ = 0; + } + break; + default: + ; + } + } + } +} + +static int set_hwparams(snd_pcm_t *handle, snd_pcm_hw_params_t *params, snd_pcm_access_t access) { + unsigned int rrate; + int err; + snd_pcm_uframes_t period_size_min; + snd_pcm_uframes_t period_size_max; + snd_pcm_uframes_t buffer_size_min; + snd_pcm_uframes_t buffer_size_max; + + /* choose all parameters */ + err = snd_pcm_hw_params_any(handle, params); + if (err < 0) { + fprintf(stderr, _("Broken configuration for playback: no configurations available: %s\n"), snd_strerror(err)); + return err; + } + + /* set the interleaved read/write format */ + err = snd_pcm_hw_params_set_access(handle, params, access); + if (err < 0) { + fprintf(stderr, _("Access type not available for playback: %s\n"), snd_strerror(err)); + return err; + } + + /* set the sample format */ + err = snd_pcm_hw_params_set_format(handle, params, format); + if (err < 0) { + fprintf(stderr, _("Sample format not available for playback: %s\n"), snd_strerror(err)); + return err; + } + + /* set the count of channels */ + err = snd_pcm_hw_params_set_channels(handle, params, channels); + if (err < 0) { + fprintf(stderr, _("Channels count (%i) not available for playbacks: %s\n"), channels, snd_strerror(err)); + return err; + } + + /* set the stream rate */ + rrate = rate; + err = snd_pcm_hw_params_set_rate(handle, params, rate, 0); + if (err < 0) { + fprintf(stderr, _("Rate %iHz not available for playback: %s\n"), rate, snd_strerror(err)); + return err; + } + + if (rrate != rate) { + fprintf(stderr, _("Rate doesn't match (requested %iHz, get %iHz, err %d)\n"), rate, rrate, err); + return -EINVAL; + } + + printf(_("Rate set to %iHz (requested %iHz)\n"), rrate, rate); + /* set the buffer time */ + err = snd_pcm_hw_params_get_buffer_size_min(params, &buffer_size_min); + err = snd_pcm_hw_params_get_buffer_size_max(params, &buffer_size_max); + err = snd_pcm_hw_params_get_period_size_min(params, &period_size_min, NULL); + err = snd_pcm_hw_params_get_period_size_max(params, &period_size_max, NULL); + printf(_("Buffer size range from %lu to %lu\n"),buffer_size_min, buffer_size_max); + printf(_("Period size range from %lu to %lu\n"),period_size_min, period_size_max); + if (period_time > 0) { + printf(_("Requested period time %u us\n"), period_time); + err = snd_pcm_hw_params_set_period_time_near(handle, params, &period_time, NULL); + if (err < 0) { + fprintf(stderr, _("Unable to set period time %u us for playback: %s\n"), + period_time, snd_strerror(err)); + return err; + } + } + if (buffer_time > 0) { + printf(_("Requested buffer time %u us\n"), buffer_time); + err = snd_pcm_hw_params_set_buffer_time_near(handle, params, &buffer_time, NULL); + if (err < 0) { + fprintf(stderr, _("Unable to set buffer time %u us for playback: %s\n"), + buffer_time, snd_strerror(err)); + return err; + } + } + if (! buffer_time && ! period_time) { + buffer_size = buffer_size_max; + if (! period_time) + buffer_size = (buffer_size / nperiods) * nperiods; + printf(_("Using max buffer size %lu\n"), buffer_size); + err = snd_pcm_hw_params_set_buffer_size_near(handle, params, &buffer_size); + if (err < 0) { + fprintf(stderr, _("Unable to set buffer size %lu for playback: %s\n"), + buffer_size, snd_strerror(err)); + return err; + } + } + if (! buffer_time || ! period_time) { + printf(_("Periods = %u\n"), nperiods); + err = snd_pcm_hw_params_set_periods_near(handle, params, &nperiods, NULL); + if (err < 0) { + fprintf(stderr, _("Unable to set nperiods %u for playback: %s\n"), + nperiods, snd_strerror(err)); + return err; + } + } + + /* write the parameters to device */ + err = snd_pcm_hw_params(handle, params); + if (err < 0) { + fprintf(stderr, _("Unable to set hw params for playback: %s\n"), snd_strerror(err)); + return err; + } + + snd_pcm_hw_params_get_buffer_size(params, &buffer_size); + snd_pcm_hw_params_get_period_size(params, &period_size, NULL); + printf(_("was set period_size = %lu\n"),period_size); + printf(_("was set buffer_size = %lu\n"),buffer_size); + if (2*period_size > buffer_size) { + fprintf(stderr, _("buffer to small, could not use\n")); + return -EINVAL; + } + + return 0; +} + +static int set_swparams(snd_pcm_t *handle, snd_pcm_sw_params_t *swparams) { + int err; + + /* get the current swparams */ + err = snd_pcm_sw_params_current(handle, swparams); + if (err < 0) { + fprintf(stderr, _("Unable to determine current swparams for playback: %s\n"), snd_strerror(err)); + return err; + } + + /* start the transfer when a buffer is full */ + err = snd_pcm_sw_params_set_start_threshold(handle, swparams, buffer_size); + if (err < 0) { + fprintf(stderr, _("Unable to set start threshold mode for playback: %s\n"), snd_strerror(err)); + return err; + } + + /* allow the transfer when at least period_size frames can be processed */ + err = snd_pcm_sw_params_set_avail_min(handle, swparams, period_size); + if (err < 0) { + fprintf(stderr, _("Unable to set avail min for playback: %s\n"), snd_strerror(err)); + return err; + } + + /* write the parameters to the playback device */ + err = snd_pcm_sw_params(handle, swparams); + if (err < 0) { + fprintf(stderr, _("Unable to set sw params for playback: %s\n"), snd_strerror(err)); + return err; + } + + return 0; +} + +/* + * Underrun and suspend recovery + */ + +static int xrun_recovery(snd_pcm_t *handle, int err) { + if (err == -EPIPE) { /* under-run */ + err = snd_pcm_prepare(handle); + if (err < 0) + fprintf(stderr, _("Can't recovery from underrun, prepare failed: %s\n"), snd_strerror(err)); + return 0; + } + else if (err == -ESTRPIPE) { + + while ((err = snd_pcm_resume(handle)) == -EAGAIN) + sleep(1); /* wait until the suspend flag is released */ + + if (err < 0) { + err = snd_pcm_prepare(handle); + if (err < 0) + fprintf(stderr, _("Can't recovery from suspend, prepare failed: %s\n"), snd_strerror(err)); + } + + return 0; + } + + return err; +} + +/* + * Handle WAV files + */ + +static const char *wav_file[MAX_CHANNELS]; +static int wav_file_size[MAX_CHANNELS]; + +struct wave_header { + struct { + uint32_t magic; + uint32_t length; + uint32_t type; + } hdr; + struct { + uint32_t type; + uint32_t length; + } chunk1; + struct { + uint16_t format; + uint16_t channels; + uint32_t rate; + uint32_t bytes_per_sec; + uint16_t sample_size; + uint16_t sample_bits; + } body; + struct { + uint32_t type; + uint32_t length; + } chunk; +}; + +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define COMPOSE_ID(a,b,c,d) ((a) | ((b)<<8) | ((c)<<16) | ((d)<<24)) +#define LE_SHORT(v) (v) +#define LE_INT(v) (v) +#else +#define COMPOSE_ID(a,b,c,d) ((d) | ((c)<<8) | ((b)<<16) | ((a)<<24)) +#define LE_SHORT(v) bswap_16(v) +#define LE_INT(v) bswap_32(v) +#endif + +#define WAV_RIFF COMPOSE_ID('R','I','F','F') +#define WAV_WAVE COMPOSE_ID('W','A','V','E') +#define WAV_FMT COMPOSE_ID('f','m','t',' ') +#define WAV_DATA COMPOSE_ID('d','a','t','a') +#define WAV_PCM_CODE 1 + +static const char *search_for_file(const char *name) +{ + char *file; + if (*name == '/') + return strdup(name); + file = malloc(strlen(wav_file_dir) + strlen(name) + 2); + if (file) + sprintf(file, "%s/%s", wav_file_dir, name); + return file; +} + +static int check_wav_file(int channel, const char *name) +{ + struct wave_header header; + int fd; + + wav_file[channel] = search_for_file(name); + if (! wav_file[channel]) { + fprintf(stderr, _("No enough memory\n")); + return -ENOMEM; + } + + if ((fd = open(wav_file[channel], O_RDONLY)) < 0) { + fprintf(stderr, _("Cannot open WAV file %s\n"), wav_file[channel]); + return -EINVAL; + } + if (read(fd, &header, sizeof(header)) < (int)sizeof(header)) { + fprintf(stderr, _("Invalid WAV file %s\n"), wav_file[channel]); + goto error; + } + + if (header.hdr.magic != WAV_RIFF || header.hdr.type != WAV_WAVE) { + fprintf(stderr, _("Not a WAV file: %s\n"), wav_file[channel]); + goto error; + } + if (header.body.format != LE_SHORT(WAV_PCM_CODE)) { + fprintf(stderr, _("Unsupported WAV format %d for %s\n"), + LE_SHORT(header.body.format), wav_file[channel]); + goto error; + } + if (header.body.channels != LE_SHORT(1)) { + fprintf(stderr, _("%s is not a mono stream (%d channels)\n"), + wav_file[channel], LE_SHORT(header.body.channels)); + goto error; + } + if (header.body.rate != LE_INT(rate)) { + fprintf(stderr, _("Sample rate doesn't match (%d) for %s\n"), + LE_INT(header.body.rate), wav_file[channel]); + goto error; + } + if (header.body.sample_bits != LE_SHORT(16)) { + fprintf(stderr, _("Unsupported sample format bits %d for %s\n"), + LE_SHORT(header.body.sample_bits), wav_file[channel]); + goto error; + } + if (header.chunk.type != WAV_DATA) { + fprintf(stderr, _("Invalid WAV file %s\n"), wav_file[channel]); + goto error; + } + wav_file_size[channel] = LE_INT(header.chunk.length); + close(fd); + return 0; + + error: + close(fd); + return -EINVAL; +} + +static int setup_wav_file(int chn) +{ + static const char *const wavs[MAX_CHANNELS] = { + "Front_Left.wav", + "Front_Right.wav", + "Rear_Left.wav", + "Rear_Right.wav", + "Front_Center.wav", + "Rear_Center.wav", /* FIXME: should be "Bass" or so */ + "Side_Left.wav", + "Side_Right.wav", + "Channel_9.wav", + "Channel_10.wav", + "Channel_11.wav", + "Channel_12.wav", + "Channel_13.wav", + "Channel_14.wav", + "Channel_15.wav", + "Channel_16.wav" + }; + + if (given_test_wav_file) + return check_wav_file(chn, given_test_wav_file); + else + return check_wav_file(chn, wavs[chn]); +} + +static int read_wav(uint16_t *buf, int channel, int offset, int bufsize) +{ + static FILE *wavfp = NULL; + int size; + + if (! wav_file[channel]) { + fprintf(stderr, _("Undefined channel %d\n"), channel); + return -EINVAL; + } + + if (offset >= wav_file_size[channel]) + return 0; /* finished */ + + if (! offset) { + if (wavfp) + fclose(wavfp); + wavfp = fopen(wav_file[channel], "r"); + if (! wavfp) + return -errno; + if (fseek(wavfp, sizeof(struct wave_header), SEEK_SET) < 0) + return -errno; + } + if (offset + bufsize > wav_file_size[channel]) + bufsize = wav_file_size[channel] - offset; + bufsize /= channels; + for (size = 0; size < bufsize; size += 2) { + int chn; + for (chn = 0; chn < channels; chn++) { + if (chn == channel) { + if (fread(buf, 2, 1, wavfp) != 1) + return size; + } + else + *buf = 0; + buf++; + } + } + return size; +} + + +/* + * Transfer method - write only + */ + +static int write_buffer(snd_pcm_t *handle, uint8_t *ptr, int cptr) +{ + int err; + + while (cptr > 0) { + + err = snd_pcm_writei(handle, ptr, cptr); + + if (err == -EAGAIN) + continue; + + if (err < 0) { + fprintf(stderr, _("Write error: %d,%s\n"), err, snd_strerror(err)); + if (xrun_recovery(handle, err) < 0) { + fprintf(stderr, _("xrun_recovery failed: %d,%s\n"), err, snd_strerror(err)); + return -1; + } + break; /* skip one period */ + } + + ptr += snd_pcm_frames_to_bytes(handle, err); + cptr -= err; + } + return 0; +} + +static int write_loop(snd_pcm_t *handle, int channel, int periods, uint8_t *frames) +{ + double phase = 0; + int err, n; + + if (test_type == TEST_WAV) { + int bufsize = snd_pcm_frames_to_bytes(handle, period_size); + n = 0; + while ((err = read_wav((uint16_t *)frames, channel, n, bufsize)) > 0) { + n += err; + if ((err = write_buffer(handle, frames, + snd_pcm_bytes_to_frames(handle, err * channels))) < 0) + break; + } + if (buffer_size > n) { + snd_pcm_drain(handle); + snd_pcm_prepare(handle); + } + return err; + } + + + if (periods <= 0) + periods = 1; + + for(n = 0; n < periods; n++) { + if (test_type == TEST_PINK_NOISE) + generate_pink_noise(frames, channel, period_size); + else + generate_sine(frames, channel, period_size, &phase); + + if ((err = write_buffer(handle, frames, period_size)) < 0) + return err; + } + if (buffer_size > n * period_size) { + snd_pcm_drain(handle); + snd_pcm_prepare(handle); + } + return 0; +} + +static void help(void) +{ + int k; + + printf( + _("Usage: speaker-test [OPTION]... \n" + "-h,--help help\n" + "-D,--device playback device\n" + "-r,--rate stream rate in Hz\n" + "-c,--channels count of channels in stream\n" + "-f,--frequency sine wave frequency in Hz\n" + "-F,--format sample format\n" + "-b,--buffer ring buffer size in us\n" + "-p,--period period size in us\n" + "-P,--nperiods number of periods\n" + "-t,--test pink=use pink noise, sine=use sine wave, wav=WAV file\n" + "-l,--nloops specify number of loops to test, 0 = infinite\n" + "-s,--speaker single speaker test. Values 1=Left, 2=right, etc\n" + "-w,--wavfile Use the given WAV file as a test sound\n" + "-W,--wavdir Specify the directory containing WAV files\n" + "\n")); +#if 1 + printf(_("Recognized sample formats are:")); + for (k = 0; k < SND_PCM_FORMAT_LAST; ++k) { + const char *s = snd_pcm_format_name(k); + if (s) + printf(" %s", s); + } + + printf("\n\n"); +#endif + +} + +int main(int argc, char *argv[]) { + snd_pcm_t *handle; + int err, morehelp; + snd_pcm_hw_params_t *hwparams; + snd_pcm_sw_params_t *swparams; + uint8_t *frames; + int chn; + double time1,time2,time3; + unsigned int n, nloops; + struct timeval tv1,tv2; + + static const struct option long_option[] = { + {"help", 0, NULL, 'h'}, + {"device", 1, NULL, 'D'}, + {"rate", 1, NULL, 'r'}, + {"channels", 1, NULL, 'c'}, + {"frequency", 1, NULL, 'f'}, + {"format", 1, NULL, 'F'}, + {"buffer", 1, NULL, 'b'}, + {"period", 1, NULL, 'p'}, + {"nperiods", 1, NULL, 'P'}, + {"test", 1, NULL, 't'}, + {"nloops", 1, NULL, 'l'}, + {"speaker", 1, NULL, 's'}, + {"wavfile", 1, NULL, 'w'}, + {"wavdir", 1, NULL, 'W'}, + {NULL, 0, NULL, 0 }, + }; + +#ifdef ENABLE_NLS + setlocale(LC_ALL, ""); + textdomain(PACKAGE); +#endif + + snd_pcm_hw_params_alloca(&hwparams); + snd_pcm_sw_params_alloca(&swparams); + + nloops = 0; + morehelp = 0; + + printf("\nspeaker-test %s\n\n", SND_UTIL_VERSION_STR); + while (1) { + int c; + + if ((c = getopt_long(argc, argv, "hD:r:c:f:F:b:p:P:t:l:s:w:W:", long_option, NULL)) < 0) + break; + + switch (c) { + case 'h': + morehelp++; + break; + case 'D': + device = strdup(optarg); + break; + case 'F': + format = snd_pcm_format_value(optarg); + break; + case 'r': + rate = atoi(optarg); + rate = rate < 4000 ? 4000 : rate; + rate = rate > 196000 ? 196000 : rate; + break; + case 'c': + channels = atoi(optarg); + channels = channels < 1 ? 1 : channels; + channels = channels > 1024 ? 1024 : channels; + break; + case 'f': + freq = atoi(optarg); + freq = freq < 50 ? 50 : freq; + freq = freq > 5000 ? 5000 : freq; + break; + case 'b': + buffer_time = atoi(optarg); + buffer_time = buffer_time > 1000000 ? 1000000 : buffer_time; + break; + case 'p': + period_time = atoi(optarg); + period_time = period_time > 1000000 ? 1000000 : period_time; + break; + case 'P': + nperiods = atoi(optarg); + if (nperiods < 2 || nperiods > 1024) { + fprintf(stderr, _("Invalid number of periods %d\n"), nperiods); + exit(1); + } + break; + case 't': + if (*optarg == 'p') + test_type = TEST_PINK_NOISE; + else if (*optarg == 's') + test_type = TEST_SINE; + else if (*optarg == 'w') + test_type = TEST_WAV; + else if (isdigit(*optarg)) { + test_type = atoi(optarg); + if (test_type < TEST_PINK_NOISE || test_type > TEST_WAV) { + fprintf(stderr, _("Invalid test type %s\n"), optarg); + exit(1); + } + } else { + fprintf(stderr, _("Invalid test type %s\n"), optarg); + exit(1); + } + break; + case 'l': + nloops = atoi(optarg); + break; + case 's': + speaker = atoi(optarg); + speaker = speaker < 1 ? 0 : speaker; + speaker = speaker > channels ? 0 : speaker; + if (speaker==0) { + fprintf(stderr, _("Invalid parameter for -s option.\n")); + exit(EXIT_FAILURE); + } + break; + case 'w': + given_test_wav_file = optarg; + break; + case 'W': + wav_file_dir = optarg; + break; + default: + fprintf(stderr, _("Unknown option '%c'\n"), c); + exit(EXIT_FAILURE); + break; + } + } + + if (morehelp) { + help(); + exit(EXIT_SUCCESS); + } + + if (test_type == TEST_WAV) + format = SND_PCM_FORMAT_S16_LE; /* fixed format */ + + printf(_("Playback device is %s\n"), device); + printf(_("Stream parameters are %iHz, %s, %i channels\n"), rate, snd_pcm_format_name(format), channels); + switch (test_type) { + case TEST_PINK_NOISE: + printf(_("Using 16 octaves of pink noise\n")); + break; + case TEST_SINE: + printf(_("Sine wave rate is %.4fHz\n"), freq); + break; + case TEST_WAV: + printf(_("WAV file(s)\n")); + break; + + } + + while ((err = snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) { + printf(_("Playback open error: %d,%s\n"), err,snd_strerror(err)); + sleep(1); + } + + if ((err = set_hwparams(handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) { + printf(_("Setting of hwparams failed: %s\n"), snd_strerror(err)); + snd_pcm_close(handle); + exit(EXIT_FAILURE); + } + if ((err = set_swparams(handle, swparams)) < 0) { + printf(_("Setting of swparams failed: %s\n"), snd_strerror(err)); + snd_pcm_close(handle); + exit(EXIT_FAILURE); + } + + frames = malloc(snd_pcm_frames_to_bytes(handle, period_size)); + if (test_type == TEST_PINK_NOISE) + initialize_pink_noise(&pink, 16); + + if (frames == NULL) { + fprintf(stderr, _("No enough memory\n")); + exit(EXIT_FAILURE); + } + if (speaker==0) { + + if (test_type == TEST_WAV) { + for (chn = 0; chn < channels; chn++) { + if (setup_wav_file(chn) < 0) + exit(EXIT_FAILURE); + } + } + + for (n = 0; ! nloops || n < nloops; n++) { + + gettimeofday(&tv1, NULL); + for(chn = 0; chn < channels; chn++) { + int channel=chn; + if (channels == 4) { + channel=channels4[chn]; + } + if (channels == 6) { + channel=channels6[chn]; + } + if (channels == 8) { + channel=channels8[chn]; + } + printf(" %d - %s\n", channel, gettext(channel_name[channel])); + + err = write_loop(handle, channel, ((rate*3)/period_size), frames); + + if (err < 0) { + fprintf(stderr, _("Transfer failed: %s\n"), snd_strerror(err)); + free(frames); + snd_pcm_close(handle); + exit(EXIT_SUCCESS); + } + } + gettimeofday(&tv2, NULL); + time1 = (double)tv1.tv_sec + ((double)tv1.tv_usec / 1000000.0); + time2 = (double)tv2.tv_sec + ((double)tv2.tv_usec / 1000000.0); + time3 = time2 - time1; + printf(_("Time per period = %lf\n"), time3 ); + } + } else { + if (test_type == TEST_WAV) { + if (setup_wav_file(speaker - 1) < 0) + exit(EXIT_FAILURE); + } + + printf(" - %s\n", gettext(channel_name[speaker-1])); + err = write_loop(handle, speaker-1, ((rate*5)/period_size), frames); + + if (err < 0) { + fprintf(stderr, _("Transfer failed: %s\n"), snd_strerror(err)); + } + } + + + free(frames); + snd_pcm_close(handle); + + exit(EXIT_SUCCESS); +} |