mirror of
https://github.com/cookiengineer/audacity
synced 2026-04-24 23:13:42 +02:00
Move library tree where it belongs
This commit is contained in:
36
lib-src/libsndfile/programs/Makefile.am
Normal file
36
lib-src/libsndfile/programs/Makefile.am
Normal file
@@ -0,0 +1,36 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
bin_PROGRAMS = sndfile-info sndfile-play sndfile-convert sndfile-jackplay sndfile-cmp \
|
||||
sndfile-metadata-set sndfile-metadata-get
|
||||
|
||||
OS_SPECIFIC_CFLAGS = @OS_SPECIFIC_CFLAGS@
|
||||
OS_SPECIFIC_LINKS = @OS_SPECIFIC_LINKS@
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/src $(OS_SPECIFIC_CFLAGS)
|
||||
|
||||
# This is the BeOS version of sndfile-play. It needs to be compiled with the C++
|
||||
# compiler.
|
||||
EXTRA_DIST = sndfile-play-beos.cpp test-sndfile-metadata-set.py
|
||||
|
||||
sndfile_info_SOURCES = sndfile-info.c
|
||||
sndfile_info_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
sndfile_play_SOURCES = sndfile-play.c
|
||||
sndfile_play_LDADD = $(top_builddir)/src/libsndfile.la $(OS_SPECIFIC_LINKS) $(ALSA_LIBS)
|
||||
|
||||
sndfile_jackplay_SOURCES = sndfile-jackplay.c
|
||||
sndfile_jackplay_CFLAGS = $(JACK_CFLAGS)
|
||||
sndfile_jackplay_LDADD = $(top_builddir)/src/libsndfile.la $(JACK_LIBS)
|
||||
|
||||
sndfile_convert_SOURCES = sndfile-convert.c common.c common.h
|
||||
sndfile_convert_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
sndfile_cmp_SOURCES = sndfile-cmp.c
|
||||
sndfile_cmp_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
sndfile_metadata_set_SOURCES = sndfile-metadata-set.c common.c common.h
|
||||
sndfile_metadata_set_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
sndfile_metadata_get_SOURCES = sndfile-metadata-get.c
|
||||
sndfile_metadata_get_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
623
lib-src/libsndfile/programs/Makefile.in
Normal file
623
lib-src/libsndfile/programs/Makefile.in
Normal file
@@ -0,0 +1,623 @@
|
||||
# Makefile.in generated by automake 1.10.2 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008 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@
|
||||
target_triplet = @target@
|
||||
bin_PROGRAMS = sndfile-info$(EXEEXT) sndfile-play$(EXEEXT) \
|
||||
sndfile-convert$(EXEEXT) sndfile-jackplay$(EXEEXT) \
|
||||
sndfile-cmp$(EXEEXT) sndfile-metadata-set$(EXEEXT) \
|
||||
sndfile-metadata-get$(EXEEXT)
|
||||
subdir = programs
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/M4/add_cflags.m4 \
|
||||
$(top_srcdir)/M4/add_cxxflags.m4 $(top_srcdir)/M4/clip_mode.m4 \
|
||||
$(top_srcdir)/M4/endian.m4 $(top_srcdir)/M4/extra_largefile.m4 \
|
||||
$(top_srcdir)/M4/extra_pkg.m4 \
|
||||
$(top_srcdir)/M4/flexible_array.m4 \
|
||||
$(top_srcdir)/M4/gcc_version.m4 $(top_srcdir)/M4/libtool.m4 \
|
||||
$(top_srcdir)/M4/lrint.m4 $(top_srcdir)/M4/lrintf.m4 \
|
||||
$(top_srcdir)/M4/ltoptions.m4 $(top_srcdir)/M4/ltsugar.m4 \
|
||||
$(top_srcdir)/M4/ltversion.m4 $(top_srcdir)/M4/lt~obsolete.m4 \
|
||||
$(top_srcdir)/M4/mkoctfile_version.m4 \
|
||||
$(top_srcdir)/M4/octave.m4 $(top_srcdir)/M4/pkg.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/src/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
am__installdirs = "$(DESTDIR)$(bindir)"
|
||||
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
|
||||
PROGRAMS = $(bin_PROGRAMS)
|
||||
am_sndfile_cmp_OBJECTS = sndfile-cmp.$(OBJEXT)
|
||||
sndfile_cmp_OBJECTS = $(am_sndfile_cmp_OBJECTS)
|
||||
sndfile_cmp_DEPENDENCIES = $(top_builddir)/src/libsndfile.la
|
||||
am_sndfile_convert_OBJECTS = sndfile-convert.$(OBJEXT) \
|
||||
common.$(OBJEXT)
|
||||
sndfile_convert_OBJECTS = $(am_sndfile_convert_OBJECTS)
|
||||
sndfile_convert_DEPENDENCIES = $(top_builddir)/src/libsndfile.la
|
||||
am_sndfile_info_OBJECTS = sndfile-info.$(OBJEXT)
|
||||
sndfile_info_OBJECTS = $(am_sndfile_info_OBJECTS)
|
||||
sndfile_info_DEPENDENCIES = $(top_builddir)/src/libsndfile.la
|
||||
am_sndfile_jackplay_OBJECTS = \
|
||||
sndfile_jackplay-sndfile-jackplay.$(OBJEXT)
|
||||
sndfile_jackplay_OBJECTS = $(am_sndfile_jackplay_OBJECTS)
|
||||
am__DEPENDENCIES_1 =
|
||||
sndfile_jackplay_DEPENDENCIES = $(top_builddir)/src/libsndfile.la \
|
||||
$(am__DEPENDENCIES_1)
|
||||
sndfile_jackplay_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(sndfile_jackplay_CFLAGS) \
|
||||
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
am_sndfile_metadata_get_OBJECTS = sndfile-metadata-get.$(OBJEXT)
|
||||
sndfile_metadata_get_OBJECTS = $(am_sndfile_metadata_get_OBJECTS)
|
||||
sndfile_metadata_get_DEPENDENCIES = $(top_builddir)/src/libsndfile.la
|
||||
am_sndfile_metadata_set_OBJECTS = sndfile-metadata-set.$(OBJEXT) \
|
||||
common.$(OBJEXT)
|
||||
sndfile_metadata_set_OBJECTS = $(am_sndfile_metadata_set_OBJECTS)
|
||||
sndfile_metadata_set_DEPENDENCIES = $(top_builddir)/src/libsndfile.la
|
||||
am_sndfile_play_OBJECTS = sndfile-play.$(OBJEXT)
|
||||
sndfile_play_OBJECTS = $(am_sndfile_play_OBJECTS)
|
||||
sndfile_play_DEPENDENCIES = $(top_builddir)/src/libsndfile.la \
|
||||
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
|
||||
depcomp = $(SHELL) $(top_srcdir)/Cfg/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 = $(sndfile_cmp_SOURCES) $(sndfile_convert_SOURCES) \
|
||||
$(sndfile_info_SOURCES) $(sndfile_jackplay_SOURCES) \
|
||||
$(sndfile_metadata_get_SOURCES) \
|
||||
$(sndfile_metadata_set_SOURCES) $(sndfile_play_SOURCES)
|
||||
DIST_SOURCES = $(sndfile_cmp_SOURCES) $(sndfile_convert_SOURCES) \
|
||||
$(sndfile_info_SOURCES) $(sndfile_jackplay_SOURCES) \
|
||||
$(sndfile_metadata_get_SOURCES) \
|
||||
$(sndfile_metadata_set_SOURCES) $(sndfile_play_SOURCES)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
|
||||
ALSA_LIBS = @ALSA_LIBS@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
COMPILER_IS_GCC = @COMPILER_IS_GCC@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
ENABLE_EXPERIMENTAL_CODE = @ENABLE_EXPERIMENTAL_CODE@
|
||||
EXEEXT = @EXEEXT@
|
||||
EXTERNAL_CFLAGS = @EXTERNAL_CFLAGS@
|
||||
EXTERNAL_LIBS = @EXTERNAL_LIBS@
|
||||
FGREP = @FGREP@
|
||||
FLAC_CFLAGS = @FLAC_CFLAGS@
|
||||
FLAC_LIBS = @FLAC_LIBS@
|
||||
GCC_MAJOR_VERSION = @GCC_MAJOR_VERSION@
|
||||
GCC_MINOR_VERSION = @GCC_MINOR_VERSION@
|
||||
GCC_VERSION = @GCC_VERSION@
|
||||
GETCONF = @GETCONF@
|
||||
GREP = @GREP@
|
||||
HAVE_AUTOGEN = @HAVE_AUTOGEN@
|
||||
HAVE_JACK = @HAVE_JACK@
|
||||
HAVE_MKOCTFILE = @HAVE_MKOCTFILE@
|
||||
HAVE_OCTAVE = @HAVE_OCTAVE@
|
||||
HAVE_OCTAVE_CONFIG = @HAVE_OCTAVE_CONFIG@
|
||||
HAVE_WINE = @HAVE_WINE@
|
||||
HTML_BGCOLOUR = @HTML_BGCOLOUR@
|
||||
HTML_FGCOLOUR = @HTML_FGCOLOUR@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
JACK_CFLAGS = @JACK_CFLAGS@
|
||||
JACK_LIBS = @JACK_LIBS@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIBTOOL_DEPS = @LIBTOOL_DEPS@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
MKOCTFILE = @MKOCTFILE@
|
||||
MKOCTFILE_VERSION = @MKOCTFILE_VERSION@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OCTAVE = @OCTAVE@
|
||||
OCTAVE_CONFIG = @OCTAVE_CONFIG@
|
||||
OCTAVE_CONFIG_VERSION = @OCTAVE_CONFIG_VERSION@
|
||||
OCTAVE_DEST_MDIR = @OCTAVE_DEST_MDIR@
|
||||
OCTAVE_DEST_ODIR = @OCTAVE_DEST_ODIR@
|
||||
OCTAVE_VERSION = @OCTAVE_VERSION@
|
||||
OGG_CFLAGS = @OGG_CFLAGS@
|
||||
OGG_LIBS = @OGG_LIBS@
|
||||
OS_SPECIFIC_CFLAGS = @OS_SPECIFIC_CFLAGS@
|
||||
OS_SPECIFIC_LINKS = @OS_SPECIFIC_LINKS@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
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@
|
||||
PKG_CONFIG = @PKG_CONFIG@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SF_COUNT_MAX = @SF_COUNT_MAX@
|
||||
SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
|
||||
SHELL = @SHELL@
|
||||
SHLIB_VERSION_ARG = @SHLIB_VERSION_ARG@
|
||||
SIZEOF_SF_COUNT_T = @SIZEOF_SF_COUNT_T@
|
||||
SQLITE3_CFLAGS = @SQLITE3_CFLAGS@
|
||||
SQLITE3_LIBS = @SQLITE3_LIBS@
|
||||
STRIP = @STRIP@
|
||||
TYPEOF_SF_COUNT_T = @TYPEOF_SF_COUNT_T@
|
||||
VERSION = @VERSION@
|
||||
VORBISENC_CFLAGS = @VORBISENC_CFLAGS@
|
||||
VORBISENC_LIBS = @VORBISENC_LIBS@
|
||||
VORBIS_CFLAGS = @VORBIS_CFLAGS@
|
||||
VORBIS_LIBS = @VORBIS_LIBS@
|
||||
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_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
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@
|
||||
htmldocdir = @htmldocdir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
lt_ECHO = @lt_ECHO@
|
||||
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 = @target@
|
||||
target_alias = @target_alias@
|
||||
target_cpu = @target_cpu@
|
||||
target_os = @target_os@
|
||||
target_vendor = @target_vendor@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
INCLUDES = -I$(top_srcdir)/src $(OS_SPECIFIC_CFLAGS)
|
||||
|
||||
# This is the BeOS version of sndfile-play. It needs to be compiled with the C++
|
||||
# compiler.
|
||||
EXTRA_DIST = sndfile-play-beos.cpp test-sndfile-metadata-set.py
|
||||
sndfile_info_SOURCES = sndfile-info.c
|
||||
sndfile_info_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
sndfile_play_SOURCES = sndfile-play.c
|
||||
sndfile_play_LDADD = $(top_builddir)/src/libsndfile.la $(OS_SPECIFIC_LINKS) $(ALSA_LIBS)
|
||||
sndfile_jackplay_SOURCES = sndfile-jackplay.c
|
||||
sndfile_jackplay_CFLAGS = $(JACK_CFLAGS)
|
||||
sndfile_jackplay_LDADD = $(top_builddir)/src/libsndfile.la $(JACK_LIBS)
|
||||
sndfile_convert_SOURCES = sndfile-convert.c common.c common.h
|
||||
sndfile_convert_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
sndfile_cmp_SOURCES = sndfile-cmp.c
|
||||
sndfile_cmp_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
sndfile_metadata_set_SOURCES = sndfile-metadata-set.c common.c common.h
|
||||
sndfile_metadata_set_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
sndfile_metadata_get_SOURCES = sndfile-metadata-get.c
|
||||
sndfile_metadata_get_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .lo .o .obj
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
|
||||
&& { if test -f $@; then exit 0; else break; fi; }; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu programs/Makefile'; \
|
||||
cd $(top_srcdir) && \
|
||||
$(AUTOMAKE) --gnu programs/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: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(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) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
|
||||
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --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
|
||||
sndfile-cmp$(EXEEXT): $(sndfile_cmp_OBJECTS) $(sndfile_cmp_DEPENDENCIES)
|
||||
@rm -f sndfile-cmp$(EXEEXT)
|
||||
$(LINK) $(sndfile_cmp_OBJECTS) $(sndfile_cmp_LDADD) $(LIBS)
|
||||
sndfile-convert$(EXEEXT): $(sndfile_convert_OBJECTS) $(sndfile_convert_DEPENDENCIES)
|
||||
@rm -f sndfile-convert$(EXEEXT)
|
||||
$(LINK) $(sndfile_convert_OBJECTS) $(sndfile_convert_LDADD) $(LIBS)
|
||||
sndfile-info$(EXEEXT): $(sndfile_info_OBJECTS) $(sndfile_info_DEPENDENCIES)
|
||||
@rm -f sndfile-info$(EXEEXT)
|
||||
$(LINK) $(sndfile_info_OBJECTS) $(sndfile_info_LDADD) $(LIBS)
|
||||
sndfile-jackplay$(EXEEXT): $(sndfile_jackplay_OBJECTS) $(sndfile_jackplay_DEPENDENCIES)
|
||||
@rm -f sndfile-jackplay$(EXEEXT)
|
||||
$(sndfile_jackplay_LINK) $(sndfile_jackplay_OBJECTS) $(sndfile_jackplay_LDADD) $(LIBS)
|
||||
sndfile-metadata-get$(EXEEXT): $(sndfile_metadata_get_OBJECTS) $(sndfile_metadata_get_DEPENDENCIES)
|
||||
@rm -f sndfile-metadata-get$(EXEEXT)
|
||||
$(LINK) $(sndfile_metadata_get_OBJECTS) $(sndfile_metadata_get_LDADD) $(LIBS)
|
||||
sndfile-metadata-set$(EXEEXT): $(sndfile_metadata_set_OBJECTS) $(sndfile_metadata_set_DEPENDENCIES)
|
||||
@rm -f sndfile-metadata-set$(EXEEXT)
|
||||
$(LINK) $(sndfile_metadata_set_OBJECTS) $(sndfile_metadata_set_LDADD) $(LIBS)
|
||||
sndfile-play$(EXEEXT): $(sndfile_play_OBJECTS) $(sndfile_play_DEPENDENCIES)
|
||||
@rm -f sndfile-play$(EXEEXT)
|
||||
$(LINK) $(sndfile_play_OBJECTS) $(sndfile_play_LDADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/common.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sndfile-cmp.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sndfile-convert.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sndfile-info.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sndfile-metadata-get.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sndfile-metadata-set.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sndfile-play.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sndfile_jackplay-sndfile-jackplay.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 $@ $<
|
||||
|
||||
sndfile_jackplay-sndfile-jackplay.o: sndfile-jackplay.c
|
||||
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sndfile_jackplay_CFLAGS) $(CFLAGS) -MT sndfile_jackplay-sndfile-jackplay.o -MD -MP -MF $(DEPDIR)/sndfile_jackplay-sndfile-jackplay.Tpo -c -o sndfile_jackplay-sndfile-jackplay.o `test -f 'sndfile-jackplay.c' || echo '$(srcdir)/'`sndfile-jackplay.c
|
||||
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/sndfile_jackplay-sndfile-jackplay.Tpo $(DEPDIR)/sndfile_jackplay-sndfile-jackplay.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sndfile-jackplay.c' object='sndfile_jackplay-sndfile-jackplay.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sndfile_jackplay_CFLAGS) $(CFLAGS) -c -o sndfile_jackplay-sndfile-jackplay.o `test -f 'sndfile-jackplay.c' || echo '$(srcdir)/'`sndfile-jackplay.c
|
||||
|
||||
sndfile_jackplay-sndfile-jackplay.obj: sndfile-jackplay.c
|
||||
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sndfile_jackplay_CFLAGS) $(CFLAGS) -MT sndfile_jackplay-sndfile-jackplay.obj -MD -MP -MF $(DEPDIR)/sndfile_jackplay-sndfile-jackplay.Tpo -c -o sndfile_jackplay-sndfile-jackplay.obj `if test -f 'sndfile-jackplay.c'; then $(CYGPATH_W) 'sndfile-jackplay.c'; else $(CYGPATH_W) '$(srcdir)/sndfile-jackplay.c'; fi`
|
||||
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/sndfile_jackplay-sndfile-jackplay.Tpo $(DEPDIR)/sndfile_jackplay-sndfile-jackplay.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sndfile-jackplay.c' object='sndfile_jackplay-sndfile-jackplay.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sndfile_jackplay_CFLAGS) $(CFLAGS) -c -o sndfile_jackplay-sndfile-jackplay.obj `if test -f 'sndfile-jackplay.c'; then $(CYGPATH_W) 'sndfile-jackplay.c'; else $(CYGPATH_W) '$(srcdir)/sndfile-jackplay.c'; fi`
|
||||
|
||||
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; nonempty = 1; } \
|
||||
END { if (nonempty) { 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; nonempty = 1; } \
|
||||
END { if (nonempty) { 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=; \
|
||||
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; nonempty = 1; } \
|
||||
END { if (nonempty) { 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:
|
||||
266
lib-src/libsndfile/programs/common.c
Normal file
266
lib-src/libsndfile/programs/common.c
Normal file
@@ -0,0 +1,266 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2008 George Blood Audio
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the author nor the names of any contributors may be used
|
||||
** to endorse or promote products derived from this software without
|
||||
** specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define BUFFER_LEN 4096
|
||||
|
||||
#define MIN(x,y) ((x) < (y) ? (x) : (y))
|
||||
|
||||
void
|
||||
sfe_copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels)
|
||||
{ static double data [BUFFER_LEN], max ;
|
||||
int frames, readcount, k ;
|
||||
|
||||
frames = BUFFER_LEN / channels ;
|
||||
readcount = frames ;
|
||||
|
||||
sf_command (infile, SFC_CALC_SIGNAL_MAX, &max, sizeof (max)) ;
|
||||
|
||||
if (max < 1.0)
|
||||
{ while (readcount > 0)
|
||||
{ readcount = sf_readf_double (infile, data, frames) ;
|
||||
sf_writef_double (outfile, data, readcount) ;
|
||||
} ;
|
||||
}
|
||||
else
|
||||
{ sf_command (infile, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE) ;
|
||||
|
||||
while (readcount > 0)
|
||||
{ readcount = sf_readf_double (infile, data, frames) ;
|
||||
for (k = 0 ; k < readcount * channels ; k++)
|
||||
data [k] /= max ;
|
||||
sf_writef_double (outfile, data, readcount) ;
|
||||
} ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* sfe_copy_data_fp */
|
||||
|
||||
void
|
||||
sfe_copy_data_int (SNDFILE *outfile, SNDFILE *infile, int channels)
|
||||
{ static int data [BUFFER_LEN] ;
|
||||
int frames, readcount ;
|
||||
|
||||
frames = BUFFER_LEN / channels ;
|
||||
readcount = frames ;
|
||||
|
||||
while (readcount > 0)
|
||||
{ readcount = sf_readf_int (infile, data, frames) ;
|
||||
sf_writef_int (outfile, data, readcount) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* sfe_copy_data_int */
|
||||
|
||||
/*==============================================================================
|
||||
*/
|
||||
|
||||
static int
|
||||
merge_broadcast_info (SNDFILE * infile, SNDFILE * outfile, int format, const METADATA_INFO * info)
|
||||
{ SF_BROADCAST_INFO_2K binfo ;
|
||||
int infileminor ;
|
||||
|
||||
memset (&binfo, 0, sizeof (binfo)) ;
|
||||
|
||||
if ((SF_FORMAT_TYPEMASK & format) != SF_FORMAT_WAV)
|
||||
{ printf ("Error : This is not a WAV file and hence broadcast info cannot be added to it.\n\n") ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
infileminor = SF_FORMAT_SUBMASK & format ;
|
||||
|
||||
switch (infileminor)
|
||||
{ case SF_FORMAT_PCM_16 :
|
||||
case SF_FORMAT_PCM_24 :
|
||||
case SF_FORMAT_PCM_32 :
|
||||
break ;
|
||||
|
||||
default :
|
||||
printf (
|
||||
"Warning : The EBU Technical Recommendation R68-2000 states that the only\n"
|
||||
" allowed encodings are Linear PCM and MPEG3. This file is not in\n"
|
||||
" the right format.\n\n"
|
||||
) ;
|
||||
break ;
|
||||
} ;
|
||||
|
||||
if (sf_command (infile, SFC_GET_BROADCAST_INFO, &binfo, sizeof (binfo)) == 0)
|
||||
{ if (infile == outfile)
|
||||
{ printf (
|
||||
"Error : Attempting in-place broadcast info update, but file does not\n"
|
||||
" have a 'bext' chunk to modify. The solution is to specify both\n"
|
||||
" input and output files on the command line.\n\n"
|
||||
) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
} ;
|
||||
|
||||
#define REPLACE_IF_NEW(x) \
|
||||
if (info->x != NULL) \
|
||||
{ memset (binfo.x, 0, sizeof (binfo.x)) ; \
|
||||
memcpy (binfo.x, info->x, MIN (strlen (info->x), sizeof (binfo.x))) ; \
|
||||
} ;
|
||||
|
||||
REPLACE_IF_NEW (description) ;
|
||||
REPLACE_IF_NEW (originator) ;
|
||||
REPLACE_IF_NEW (originator_reference) ;
|
||||
REPLACE_IF_NEW (origination_date) ;
|
||||
REPLACE_IF_NEW (origination_time) ;
|
||||
REPLACE_IF_NEW (umid) ;
|
||||
|
||||
/* Special case for coding_history because we may want to append. */
|
||||
if (info->coding_history != NULL)
|
||||
{ if (info->coding_hist_append)
|
||||
{ int slen = strlen (binfo.coding_history) ;
|
||||
|
||||
while (slen > 1 && isspace (binfo.coding_history [slen - 1]))
|
||||
slen -- ;
|
||||
|
||||
memcpy (binfo.coding_history + slen, info->coding_history, sizeof (binfo.coding_history) - slen) ;
|
||||
}
|
||||
else
|
||||
{ size_t slen = MIN (strlen (info->coding_history), sizeof (binfo.coding_history)) ;
|
||||
|
||||
memset (binfo.coding_history, 0, sizeof (binfo.coding_history)) ;
|
||||
memcpy (binfo.coding_history, info->coding_history, slen) ;
|
||||
binfo.coding_history_size = slen ;
|
||||
} ;
|
||||
} ;
|
||||
|
||||
if (sf_command (outfile, SFC_SET_BROADCAST_INFO, &binfo, sizeof (binfo)) == 0)
|
||||
{ printf ("Error : Setting of broadcast info chunks failed.\n\n") ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
return 0 ;
|
||||
} /* merge_broadcast_info*/
|
||||
|
||||
static void
|
||||
update_strings (SNDFILE * outfile, const METADATA_INFO * info)
|
||||
{
|
||||
if (info->title != NULL)
|
||||
sf_set_string (outfile, SF_STR_TITLE, info->title) ;
|
||||
|
||||
if (info->copyright != NULL)
|
||||
sf_set_string (outfile, SF_STR_TITLE, info->copyright) ;
|
||||
|
||||
if (info->artist != NULL)
|
||||
sf_set_string (outfile, SF_STR_ARTIST, info->artist) ;
|
||||
|
||||
if (info->comment != NULL)
|
||||
sf_set_string (outfile, SF_STR_TITLE, info->comment) ;
|
||||
|
||||
if (info->date != NULL)
|
||||
sf_set_string (outfile, SF_STR_DATE, info->date) ;
|
||||
|
||||
if (info->album != NULL)
|
||||
sf_set_string (outfile, SF_STR_TITLE, info->album) ;
|
||||
|
||||
if (info->license != NULL)
|
||||
sf_set_string (outfile, SF_STR_TITLE, info->license) ;
|
||||
|
||||
} /* update_strings */
|
||||
|
||||
|
||||
|
||||
void
|
||||
sfe_apply_metadata_changes (const char * filenames [2], const METADATA_INFO * info)
|
||||
{ SNDFILE *infile = NULL, *outfile = NULL ;
|
||||
SF_INFO sfinfo ;
|
||||
METADATA_INFO tmpinfo ;
|
||||
int error_code = 0 ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
memset (&tmpinfo, 0, sizeof (tmpinfo)) ;
|
||||
|
||||
if (filenames [1] == NULL)
|
||||
infile = outfile = sf_open (filenames [0], SFM_RDWR, &sfinfo) ;
|
||||
else
|
||||
{ infile = sf_open (filenames [0], SFM_READ, &sfinfo) ;
|
||||
|
||||
/* Output must be WAV. */
|
||||
sfinfo.format = SF_FORMAT_WAV | (SF_FORMAT_SUBMASK & sfinfo.format) ;
|
||||
outfile = sf_open (filenames [1], SFM_WRITE, &sfinfo) ;
|
||||
} ;
|
||||
|
||||
if (infile == NULL)
|
||||
{ printf ("Error : Not able to open input file '%s' : %s\n", filenames [0], sf_strerror (infile)) ;
|
||||
error_code = 1 ;
|
||||
goto cleanup_exit ;
|
||||
} ;
|
||||
|
||||
if (outfile == NULL)
|
||||
{ printf ("Error : Not able to open output file '%s' : %s\n", filenames [1], sf_strerror (outfile)) ;
|
||||
error_code = 1 ;
|
||||
goto cleanup_exit ;
|
||||
} ;
|
||||
|
||||
if (info->has_bext_fields && merge_broadcast_info (infile, outfile, sfinfo.format, info))
|
||||
{ error_code = 1 ;
|
||||
goto cleanup_exit ;
|
||||
} ;
|
||||
|
||||
update_strings (outfile, info) ;
|
||||
|
||||
if (infile != outfile)
|
||||
{ int infileminor = SF_FORMAT_SUBMASK & sfinfo.format ;
|
||||
|
||||
/* If the input file is not the same as the output file, copy the data. */
|
||||
if ((infileminor == SF_FORMAT_DOUBLE) || (infileminor == SF_FORMAT_FLOAT))
|
||||
sfe_copy_data_fp (outfile, infile, sfinfo.channels) ;
|
||||
else
|
||||
sfe_copy_data_int (outfile, infile, sfinfo.channels) ;
|
||||
} ;
|
||||
|
||||
cleanup_exit :
|
||||
|
||||
if (outfile != NULL && outfile != infile)
|
||||
sf_close (outfile) ;
|
||||
|
||||
if (infile != NULL)
|
||||
sf_close (infile) ;
|
||||
|
||||
if (error_code)
|
||||
exit (error_code) ;
|
||||
|
||||
return ;
|
||||
} /* sfe_apply_metadata_changes */
|
||||
|
||||
64
lib-src/libsndfile/programs/common.h
Normal file
64
lib-src/libsndfile/programs/common.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the author nor the names of any contributors may be used
|
||||
** to endorse or promote products derived from this software without
|
||||
** specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
typedef struct
|
||||
{ const char * title ;
|
||||
const char * copyright ;
|
||||
const char * artist ;
|
||||
const char * comment ;
|
||||
const char * date ;
|
||||
const char * album ;
|
||||
const char * license ;
|
||||
|
||||
|
||||
/* Stuff to go in the 'bext' chunk of WAV files. */
|
||||
int has_bext_fields ;
|
||||
int coding_hist_append ;
|
||||
|
||||
const char * description ;
|
||||
const char * originator ;
|
||||
const char * originator_reference ;
|
||||
const char * origination_date ;
|
||||
const char * origination_time ;
|
||||
const char * umid ;
|
||||
const char * coding_history ;
|
||||
} METADATA_INFO ;
|
||||
|
||||
typedef SF_BROADCAST_INFO_VAR (2048) SF_BROADCAST_INFO_2K ;
|
||||
|
||||
void sfe_apply_metadata_changes (const char * filenames [2], const METADATA_INFO * info) ;
|
||||
|
||||
void sfe_copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels) ;
|
||||
|
||||
void sfe_copy_data_int (SNDFILE *outfile, SNDFILE *infile, int channels) ;
|
||||
159
lib-src/libsndfile/programs/sndfile-cmp.c
Normal file
159
lib-src/libsndfile/programs/sndfile-cmp.c
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
** Copyright (C) 2008-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the author nor the names of any contributors may be used
|
||||
** to endorse or promote products derived from this software without
|
||||
** specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* sndfile-cmp.c
|
||||
* Conrad Parker 2008
|
||||
*/
|
||||
|
||||
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
/* Length of comparison data buffers in units of items */
|
||||
#define BUFLEN 65536
|
||||
|
||||
static char * progname ;
|
||||
static char * filename1, * filename2 ;
|
||||
|
||||
static int
|
||||
comparison_error (const char * what)
|
||||
{ printf ("%s: %s of files %s and %s differ\n", progname, what, filename1, filename2) ;
|
||||
return 1 ;
|
||||
} /* comparison_error */
|
||||
|
||||
static int
|
||||
compare (void)
|
||||
{
|
||||
double buf1 [BUFLEN], buf2 [BUFLEN] ;
|
||||
SF_INFO sfinfo1, sfinfo2 ;
|
||||
SNDFILE * sf1 = NULL, * sf2 = NULL ;
|
||||
sf_count_t len, i, nread1, nread2 ;
|
||||
int retval = 0 ;
|
||||
|
||||
memset (&sfinfo1, 0, sizeof (SF_INFO)) ;
|
||||
sf1 = sf_open (filename1, SFM_READ, &sfinfo1) ;
|
||||
if (sf1 == NULL)
|
||||
{ printf ("Error opening %s.\n", filename1) ;
|
||||
retval = 1 ;
|
||||
goto out ;
|
||||
} ;
|
||||
|
||||
memset (&sfinfo2, 0, sizeof (SF_INFO)) ;
|
||||
sf2 = sf_open (filename2, SFM_READ, &sfinfo2) ;
|
||||
if (sf2 == NULL)
|
||||
{ printf ("Error opening %s.\n", filename2) ;
|
||||
retval = 1 ;
|
||||
goto out ;
|
||||
} ;
|
||||
|
||||
if (sfinfo1.samplerate != sfinfo2.samplerate)
|
||||
{ retval = comparison_error ("Samplerates") ;
|
||||
goto out ;
|
||||
} ;
|
||||
|
||||
if (sfinfo1.channels != sfinfo2.channels)
|
||||
{ retval = comparison_error ("Number of channels") ;
|
||||
goto out ;
|
||||
} ;
|
||||
|
||||
/* Calculate the framecount that will fit in our data buffers */
|
||||
len = BUFLEN / sfinfo1.channels ;
|
||||
|
||||
while ( (nread1 = sf_readf_double (sf1, buf1, len)) > 0)
|
||||
{ nread2 = sf_readf_double (sf2, buf2, nread1) ;
|
||||
if (nread2 != nread1)
|
||||
{ retval = comparison_error ("PCM data lengths") ;
|
||||
goto out ;
|
||||
} ;
|
||||
for (i = 0 ; i < nread1 ; i++)
|
||||
{ if (buf1 [i] != buf2 [i])
|
||||
{ retval = comparison_error ("PCM data") ;
|
||||
goto out ;
|
||||
} ;
|
||||
} ;
|
||||
} ;
|
||||
|
||||
if ( (nread2 = sf_readf_double (sf2, buf2, nread1)) != 0)
|
||||
{ retval = comparison_error ("PCM data lengths") ;
|
||||
goto out ;
|
||||
} ;
|
||||
|
||||
out :
|
||||
sf_close (sf1) ;
|
||||
sf_close (sf2) ;
|
||||
|
||||
return retval ;
|
||||
} /* compare */
|
||||
|
||||
static void
|
||||
print_version (void)
|
||||
{ char buffer [256] ;
|
||||
|
||||
sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer)) ;
|
||||
printf ("\nVersion : %s\n\n", buffer) ;
|
||||
} /* print_version */
|
||||
|
||||
static void
|
||||
print_usage (void)
|
||||
{
|
||||
print_version () ;
|
||||
|
||||
printf ("Usage : %s <filename> <filename>\n", progname) ;
|
||||
printf (" Compare the PCM data of two sound files.\n\n") ;
|
||||
} /* print_usage */
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
progname = strrchr (argv [0], '/') ;
|
||||
progname = progname ? progname + 1 : argv [0] ;
|
||||
|
||||
if (argc != 3)
|
||||
{ print_usage () ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
filename1 = argv [argc - 2] ;
|
||||
filename2 = argv [argc - 1] ;
|
||||
|
||||
if (strcmp (filename1, filename2) == 0)
|
||||
{ printf ("Error : Input filenames are the same.\n\n") ;
|
||||
print_usage () ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
return compare () ;
|
||||
} /* main */
|
||||
369
lib-src/libsndfile/programs/sndfile-convert.c
Normal file
369
lib-src/libsndfile/programs/sndfile-convert.c
Normal file
@@ -0,0 +1,369 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the author nor the names of any contributors may be used
|
||||
** to endorse or promote products derived from this software without
|
||||
** specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
|
||||
typedef struct
|
||||
{ char *infilename, *outfilename ;
|
||||
SF_INFO infileinfo, outfileinfo ;
|
||||
} OptionData ;
|
||||
|
||||
typedef struct
|
||||
{ const char *ext ;
|
||||
int len ;
|
||||
int format ;
|
||||
} OUTPUT_FORMAT_MAP ;
|
||||
|
||||
static void copy_metadata (SNDFILE *outfile, SNDFILE *infile) ;
|
||||
|
||||
static OUTPUT_FORMAT_MAP format_map [] =
|
||||
{
|
||||
{ "aif", 3, SF_FORMAT_AIFF },
|
||||
{ "wav", 0, SF_FORMAT_WAV },
|
||||
{ "au", 0, SF_FORMAT_AU },
|
||||
{ "caf", 0, SF_FORMAT_CAF },
|
||||
{ "flac", 0, SF_FORMAT_FLAC },
|
||||
{ "snd", 0, SF_FORMAT_AU },
|
||||
{ "svx", 0, SF_FORMAT_SVX },
|
||||
{ "paf", 0, SF_ENDIAN_BIG | SF_FORMAT_PAF },
|
||||
{ "fap", 0, SF_ENDIAN_LITTLE | SF_FORMAT_PAF },
|
||||
{ "gsm", 0, SF_FORMAT_RAW },
|
||||
{ "nist", 0, SF_FORMAT_NIST },
|
||||
{ "htk", 0, SF_FORMAT_HTK },
|
||||
{ "ircam", 0, SF_FORMAT_IRCAM },
|
||||
{ "sf", 0, SF_FORMAT_IRCAM },
|
||||
{ "voc", 0, SF_FORMAT_VOC },
|
||||
{ "w64", 0, SF_FORMAT_W64 },
|
||||
{ "raw", 0, SF_FORMAT_RAW },
|
||||
{ "mat4", 0, SF_FORMAT_MAT4 },
|
||||
{ "mat5", 0, SF_FORMAT_MAT5 },
|
||||
{ "mat", 0, SF_FORMAT_MAT4 },
|
||||
{ "pvf", 0, SF_FORMAT_PVF },
|
||||
{ "sds", 0, SF_FORMAT_SDS },
|
||||
{ "sd2", 0, SF_FORMAT_SD2 },
|
||||
{ "vox", 0, SF_FORMAT_RAW },
|
||||
{ "xi", 0, SF_FORMAT_XI },
|
||||
{ "wve", 0, SF_FORMAT_WVE },
|
||||
{ "oga", 0, SF_FORMAT_OGG },
|
||||
{ "mpc", 0, SF_FORMAT_MPC2K },
|
||||
{ "rf64", 0, SF_FORMAT_RF64 },
|
||||
} ; /* format_map */
|
||||
|
||||
static int
|
||||
guess_output_file_type (char *str, int format)
|
||||
{ char buffer [16], *cptr ;
|
||||
int k ;
|
||||
|
||||
format &= SF_FORMAT_SUBMASK ;
|
||||
|
||||
if ((cptr = strrchr (str, '.')) == NULL)
|
||||
return 0 ;
|
||||
|
||||
strncpy (buffer, cptr + 1, 15) ;
|
||||
buffer [15] = 0 ;
|
||||
|
||||
for (k = 0 ; buffer [k] ; k++)
|
||||
buffer [k] = tolower ((buffer [k])) ;
|
||||
|
||||
if (strcmp (buffer, "gsm") == 0)
|
||||
return SF_FORMAT_RAW | SF_FORMAT_GSM610 ;
|
||||
|
||||
if (strcmp (buffer, "vox") == 0)
|
||||
return SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM ;
|
||||
|
||||
for (k = 0 ; k < (int) (sizeof (format_map) / sizeof (format_map [0])) ; k++)
|
||||
{ if (format_map [k].len > 0 && strncmp (buffer, format_map [k].ext, format_map [k].len) == 0)
|
||||
return format_map [k].format | format ;
|
||||
else if (strcmp (buffer, format_map [k].ext) == 0)
|
||||
return format_map [k].format | format ;
|
||||
} ;
|
||||
|
||||
return 0 ;
|
||||
} /* guess_output_file_type */
|
||||
|
||||
|
||||
static void
|
||||
print_usage (char *progname)
|
||||
{ SF_FORMAT_INFO info ;
|
||||
|
||||
int k ;
|
||||
|
||||
printf ("\nUsage : %s [options] [encoding] <input file> <output file>\n", progname) ;
|
||||
puts ("\n"
|
||||
" where [option] may be:\n\n"
|
||||
" -override-sample-rate=X : force sample rate of input to X\n\n"
|
||||
) ;
|
||||
|
||||
puts ("\n"
|
||||
" where [encoding] may be one of the following:\n\n"
|
||||
" -pcms8 : force the output to signed 8 bit pcm\n"
|
||||
" -pcmu8 : force the output to unsigned 8 bit pcm\n"
|
||||
" -pcm16 : force the output to 16 bit pcm\n"
|
||||
" -pcm24 : force the output to 24 bit pcm\n"
|
||||
" -pcm32 : force the output to 32 bit pcm\n"
|
||||
" -float32 : force the output to 32 bit floating point"
|
||||
) ;
|
||||
puts (
|
||||
" -ulaw : force the output ULAW\n"
|
||||
" -alaw : force the output ALAW\n"
|
||||
" -ima-adpcm : force the output to IMA ADPCM (WAV only)\n"
|
||||
" -ms-adpcm : force the output to MS ADPCM (WAV only)\n"
|
||||
" -gsm610 : force the GSM6.10 (WAV only)\n"
|
||||
" -dwvw12 : force the output to 12 bit DWVW (AIFF only)\n"
|
||||
" -dwvw16 : force the output to 16 bit DWVW (AIFF only)\n"
|
||||
" -dwvw24 : force the output to 24 bit DWVW (AIFF only)\n"
|
||||
" -vorbis : force the output to Vorbis (OGG only)\n"
|
||||
) ;
|
||||
|
||||
puts (
|
||||
" The format of the output file is determined by the file extension of the\n"
|
||||
" output file name. The following extensions are currently understood:\n"
|
||||
) ;
|
||||
|
||||
for (k = 0 ; k < (int) (sizeof (format_map) / sizeof (format_map [0])) ; k++)
|
||||
{ info.format = format_map [k].format ;
|
||||
sf_command (NULL, SFC_GET_FORMAT_INFO, &info, sizeof (info)) ;
|
||||
printf (" %-10s : %s\n", format_map [k].ext, info.name) ;
|
||||
} ;
|
||||
|
||||
puts ("") ;
|
||||
} /* print_usage */
|
||||
|
||||
int
|
||||
main (int argc, char * argv [])
|
||||
{ char *progname, *infilename, *outfilename ;
|
||||
SNDFILE *infile = NULL, *outfile = NULL ;
|
||||
SF_INFO sfinfo ;
|
||||
int k, outfilemajor, outfileminor = 0, infileminor ;
|
||||
int override_sample_rate = 0 ; /* assume no sample rate override. */
|
||||
|
||||
progname = strrchr (argv [0], '/') ;
|
||||
progname = progname ? progname + 1 : argv [0] ;
|
||||
|
||||
if (argc < 3 || argc > 5)
|
||||
{ print_usage (progname) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
infilename = argv [argc-2] ;
|
||||
outfilename = argv [argc-1] ;
|
||||
|
||||
if (strcmp (infilename, outfilename) == 0)
|
||||
{ printf ("Error : Input and output filenames are the same.\n\n") ;
|
||||
print_usage (progname) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if (infilename [0] == '-')
|
||||
{ printf ("Error : Input filename (%s) looks like an option.\n\n", infilename) ;
|
||||
print_usage (progname) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if (outfilename [0] == '-')
|
||||
{ printf ("Error : Output filename (%s) looks like an option.\n\n", outfilename) ;
|
||||
print_usage (progname) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
for (k = 1 ; k < argc - 2 ; k++)
|
||||
{ if (! strcmp (argv [k], "-pcms8"))
|
||||
{ outfileminor = SF_FORMAT_PCM_S8 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-pcmu8"))
|
||||
{ outfileminor = SF_FORMAT_PCM_U8 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-pcm16"))
|
||||
{ outfileminor = SF_FORMAT_PCM_16 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-pcm24"))
|
||||
{ outfileminor = SF_FORMAT_PCM_24 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-pcm32"))
|
||||
{ outfileminor = SF_FORMAT_PCM_32 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-float32"))
|
||||
{ outfileminor = SF_FORMAT_FLOAT ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-ulaw"))
|
||||
{ outfileminor = SF_FORMAT_ULAW ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-alaw"))
|
||||
{ outfileminor = SF_FORMAT_ALAW ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-ima-adpcm"))
|
||||
{ outfileminor = SF_FORMAT_IMA_ADPCM ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-ms-adpcm"))
|
||||
{ outfileminor = SF_FORMAT_MS_ADPCM ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-gsm610"))
|
||||
{ outfileminor = SF_FORMAT_GSM610 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-dwvw12"))
|
||||
{ outfileminor = SF_FORMAT_DWVW_12 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-dwvw16"))
|
||||
{ outfileminor = SF_FORMAT_DWVW_16 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-dwvw24"))
|
||||
{ outfileminor = SF_FORMAT_DWVW_24 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-vorbis"))
|
||||
{ outfileminor = SF_FORMAT_VORBIS ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (strstr (argv [k], "-override-sample-rate=") == argv [k])
|
||||
{ const char *ptr ;
|
||||
|
||||
ptr = argv [k] + strlen ("-override-sample-rate=") ;
|
||||
override_sample_rate = atoi (ptr) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
printf ("Error : Not able to decode argunment '%s'.\n", argv [k]) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if ((infile = sf_open (infilename, SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("Not able to open input file %s.\n", infilename) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
/* Update sample rate if forced to something else. */
|
||||
if (override_sample_rate)
|
||||
sfinfo.samplerate = override_sample_rate ;
|
||||
|
||||
infileminor = sfinfo.format & SF_FORMAT_SUBMASK ;
|
||||
|
||||
if ((sfinfo.format = guess_output_file_type (outfilename, sfinfo.format)) == 0)
|
||||
{ printf ("Error : Not able to determine output file type for %s.\n", outfilename) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
outfilemajor = sfinfo.format & (SF_FORMAT_TYPEMASK | SF_FORMAT_ENDMASK) ;
|
||||
|
||||
if (outfileminor == 0)
|
||||
outfileminor = sfinfo.format & SF_FORMAT_SUBMASK ;
|
||||
|
||||
if (outfileminor != 0)
|
||||
sfinfo.format = outfilemajor | outfileminor ;
|
||||
else
|
||||
sfinfo.format = outfilemajor | (sfinfo.format & SF_FORMAT_SUBMASK) ;
|
||||
|
||||
if ((sfinfo.format & SF_FORMAT_TYPEMASK) == SF_FORMAT_XI)
|
||||
switch (sfinfo.format & SF_FORMAT_SUBMASK)
|
||||
{ case SF_FORMAT_PCM_16 :
|
||||
sfinfo.format = outfilemajor | SF_FORMAT_DPCM_16 ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_PCM_S8 :
|
||||
case SF_FORMAT_PCM_U8 :
|
||||
sfinfo.format = outfilemajor | SF_FORMAT_DPCM_8 ;
|
||||
break ;
|
||||
} ;
|
||||
|
||||
if (sf_format_check (&sfinfo) == 0)
|
||||
{ printf ("Error : output file format is invalid (0x%08X).\n", sfinfo.format) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
/* Open the output file. */
|
||||
if ((outfile = sf_open (outfilename, SFM_WRITE, &sfinfo)) == NULL)
|
||||
{ printf ("Not able to open output file %s : %s\n", outfilename, sf_strerror (NULL)) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
/* Copy the metadata */
|
||||
copy_metadata (outfile, infile) ;
|
||||
|
||||
if ((outfileminor == SF_FORMAT_DOUBLE) || (outfileminor == SF_FORMAT_FLOAT)
|
||||
|| (infileminor == SF_FORMAT_DOUBLE) || (infileminor == SF_FORMAT_FLOAT)
|
||||
|| (infileminor == SF_FORMAT_VORBIS) || (outfileminor == SF_FORMAT_VORBIS))
|
||||
sfe_copy_data_fp (outfile, infile, sfinfo.channels) ;
|
||||
else
|
||||
sfe_copy_data_int (outfile, infile, sfinfo.channels) ;
|
||||
|
||||
sf_close (infile) ;
|
||||
sf_close (outfile) ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
static void
|
||||
copy_metadata (SNDFILE *outfile, SNDFILE *infile)
|
||||
{ SF_INSTRUMENT inst ;
|
||||
SF_BROADCAST_INFO_2K binfo ;
|
||||
const char *str ;
|
||||
int k, err = 0 ;
|
||||
|
||||
for (k = SF_STR_FIRST ; k <= SF_STR_LAST ; k++)
|
||||
{ str = sf_get_string (infile, k) ;
|
||||
if (str != NULL)
|
||||
err = sf_set_string (outfile, k, str) ;
|
||||
} ;
|
||||
|
||||
memset (&inst, 0, sizeof (inst)) ;
|
||||
memset (&binfo, 0, sizeof (binfo)) ;
|
||||
|
||||
if (sf_command (infile, SFC_GET_INSTRUMENT, &inst, sizeof (inst)) == SF_TRUE)
|
||||
sf_command (outfile, SFC_SET_INSTRUMENT, &inst, sizeof (inst)) ;
|
||||
|
||||
if (sf_command (infile, SFC_GET_BROADCAST_INFO, &binfo, sizeof (binfo)) == SF_TRUE)
|
||||
sf_command (outfile, SFC_SET_BROADCAST_INFO, &binfo, sizeof (binfo)) ;
|
||||
|
||||
} /* copy_metadata */
|
||||
|
||||
394
lib-src/libsndfile/programs/sndfile-info.c
Normal file
394
lib-src/libsndfile/programs/sndfile-info.c
Normal file
@@ -0,0 +1,394 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the author nor the names of any contributors may be used
|
||||
** to endorse or promote products derived from this software without
|
||||
** specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define BUFFER_LEN (1 << 16)
|
||||
|
||||
#if (defined (WIN32) || defined (_WIN32))
|
||||
#include <windows.h>
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
static void print_version (void) ;
|
||||
static void print_usage (const char *progname) ;
|
||||
|
||||
static void info_dump (const char *filename) ;
|
||||
static int instrument_dump (const char *filename) ;
|
||||
static int broadcast_dump (const char *filename) ;
|
||||
static void total_dump (void) ;
|
||||
|
||||
static double total_seconds = 0.0 ;
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{ int k ;
|
||||
|
||||
print_version () ;
|
||||
|
||||
if (argc < 2 || strcmp (argv [1], "--help") == 0 || strcmp (argv [1], "-h") == 0)
|
||||
{ char *progname ;
|
||||
|
||||
progname = strrchr (argv [0], '/') ;
|
||||
progname = progname ? progname + 1 : argv [0] ;
|
||||
|
||||
print_usage (progname) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if (strcmp (argv [1], "-i") == 0)
|
||||
{ int error = 0 ;
|
||||
|
||||
for (k = 2 ; k < argc ; k++)
|
||||
error += instrument_dump (argv [k]) ;
|
||||
return error ;
|
||||
} ;
|
||||
|
||||
if (strcmp (argv [1], "-b") == 0)
|
||||
{ int error = 0 ;
|
||||
|
||||
for (k = 2 ; k < argc ; k++)
|
||||
error += broadcast_dump (argv [k]) ;
|
||||
return error ;
|
||||
} ;
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
info_dump (argv [k]) ;
|
||||
|
||||
if (argc > 2)
|
||||
total_dump () ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
/*==============================================================================
|
||||
** Print version and usage.
|
||||
*/
|
||||
|
||||
static double data [BUFFER_LEN] ;
|
||||
|
||||
static void
|
||||
print_version (void)
|
||||
{ char buffer [256] ;
|
||||
|
||||
sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer)) ;
|
||||
printf ("\nVersion : %s\n\n", buffer) ;
|
||||
} /* print_version */
|
||||
|
||||
|
||||
static void
|
||||
print_usage (const char *progname)
|
||||
{ printf ("Usage :\n %s <file> ...\n", progname) ;
|
||||
printf (" Prints out information about one or more sound files.\n\n") ;
|
||||
printf (" %s -i <file>\n", progname) ;
|
||||
printf (" Prints out the instrument data for the given file.\n\n") ;
|
||||
printf (" %s -b <file>\n", progname) ;
|
||||
printf (" Prints out the broadcast WAV info for the given file.\n\n") ;
|
||||
#if (defined (_WIN32) || defined (WIN32))
|
||||
printf ("This is a Unix style command line application which\n"
|
||||
"should be run in a MSDOS box or Command Shell window.\n\n") ;
|
||||
printf ("Sleeping for 5 seconds before exiting.\n\n") ;
|
||||
fflush (stdout) ;
|
||||
|
||||
/* This is the officially blessed by microsoft way but I can't get
|
||||
** it to link.
|
||||
** Sleep (15) ;
|
||||
** Instead, use this:
|
||||
*/
|
||||
Sleep (5 * 1000) ;
|
||||
#endif
|
||||
} /* print_usage */
|
||||
|
||||
/*==============================================================================
|
||||
** Dumping of sndfile info.
|
||||
*/
|
||||
|
||||
static double data [BUFFER_LEN] ;
|
||||
|
||||
static double
|
||||
get_signal_max (SNDFILE *file)
|
||||
{ double max ;
|
||||
|
||||
sf_command (file, SFC_CALC_SIGNAL_MAX, &max, sizeof (max)) ;
|
||||
|
||||
return max ;
|
||||
} /* get_signal_max */
|
||||
|
||||
static double
|
||||
calc_decibels (SF_INFO * sfinfo, double max)
|
||||
{ double decibels ;
|
||||
|
||||
switch (sfinfo->format & SF_FORMAT_SUBMASK)
|
||||
{ case SF_FORMAT_PCM_U8 :
|
||||
case SF_FORMAT_PCM_S8 :
|
||||
decibels = max / 0x80 ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_PCM_16 :
|
||||
decibels = max / 0x8000 ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_PCM_24 :
|
||||
decibels = max / 0x800000 ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_PCM_32 :
|
||||
decibels = max / 0x80000000 ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_FLOAT :
|
||||
case SF_FORMAT_DOUBLE :
|
||||
decibels = max / 1.0 ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
decibels = max / 0x8000 ;
|
||||
break ;
|
||||
} ;
|
||||
|
||||
return 20.0 * log10 (decibels) ;
|
||||
} /* calc_decibels */
|
||||
|
||||
static const char *
|
||||
format_duration_str (double seconds)
|
||||
{ static char str [128] ;
|
||||
int hrs, min ;
|
||||
double sec ;
|
||||
|
||||
memset (str, 0, sizeof (str)) ;
|
||||
|
||||
hrs = (int) (seconds / 3600.0) ;
|
||||
min = (int) ((seconds - (hrs * 3600.0)) / 60.0) ;
|
||||
sec = seconds - (hrs * 3600.0) - (min * 60.0) ;
|
||||
|
||||
snprintf (str, sizeof (str) - 1, "%02d:%02d:%06.3f", hrs, min, sec) ;
|
||||
|
||||
return str ;
|
||||
} /* format_duration_str */
|
||||
|
||||
static const char *
|
||||
generate_duration_str (SF_INFO *sfinfo)
|
||||
{
|
||||
double seconds ;
|
||||
|
||||
if (sfinfo->samplerate < 1)
|
||||
return NULL ;
|
||||
|
||||
if (sfinfo->frames / sfinfo->samplerate > 0x7FFFFFFF)
|
||||
return "unknown" ;
|
||||
|
||||
seconds = (1.0 * sfinfo->frames) / sfinfo->samplerate ;
|
||||
|
||||
/* Accumulate the total of all known file durations */
|
||||
total_seconds += seconds ;
|
||||
|
||||
return format_duration_str (seconds) ;
|
||||
} /* generate_duration_str */
|
||||
|
||||
static void
|
||||
info_dump (const char *filename)
|
||||
{ static char strbuffer [BUFFER_LEN] ;
|
||||
SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
double signal_max, decibels ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("Error : Not able to open input file %s.\n", filename) ;
|
||||
fflush (stdout) ;
|
||||
memset (data, 0, sizeof (data)) ;
|
||||
sf_command (file, SFC_GET_LOG_INFO, strbuffer, BUFFER_LEN) ;
|
||||
puts (strbuffer) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
printf ("========================================\n") ;
|
||||
sf_command (file, SFC_GET_LOG_INFO, strbuffer, BUFFER_LEN) ;
|
||||
puts (strbuffer) ;
|
||||
printf ("----------------------------------------\n") ;
|
||||
|
||||
if (file == NULL)
|
||||
{ printf ("Error : Not able to open input file %s.\n", filename) ;
|
||||
fflush (stdout) ;
|
||||
memset (data, 0, sizeof (data)) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
}
|
||||
else
|
||||
{ printf ("Sample Rate : %d\n", sfinfo.samplerate) ;
|
||||
printf ("Frames : %" PRId64 "\n", sfinfo.frames) ;
|
||||
printf ("Channels : %d\n", sfinfo.channels) ;
|
||||
printf ("Format : 0x%08X\n", sfinfo.format) ;
|
||||
printf ("Sections : %d\n", sfinfo.sections) ;
|
||||
printf ("Seekable : %s\n", (sfinfo.seekable ? "TRUE" : "FALSE")) ;
|
||||
printf ("Duration : %s\n", generate_duration_str (&sfinfo)) ;
|
||||
|
||||
if (sfinfo.frames < 100 * 1024 * 1024)
|
||||
{ /* Do not use sf_signal_max because it doesn't work for non-seekable files . */
|
||||
signal_max = get_signal_max (file) ;
|
||||
decibels = calc_decibels (&sfinfo, signal_max) ;
|
||||
printf ("Signal Max : %g (%4.2f dB)\n", signal_max, decibels) ;
|
||||
} ;
|
||||
putchar ('\n') ;
|
||||
} ;
|
||||
|
||||
sf_close (file) ;
|
||||
|
||||
} /* info_dump */
|
||||
|
||||
/*==============================================================================
|
||||
** Dumping of SF_INSTRUMENT data.
|
||||
*/
|
||||
|
||||
static const char *
|
||||
str_of_type (int mode)
|
||||
{ switch (mode)
|
||||
{ case SF_LOOP_NONE : return "none" ;
|
||||
case SF_LOOP_FORWARD : return "fwd " ;
|
||||
case SF_LOOP_BACKWARD : return "back" ;
|
||||
case SF_LOOP_ALTERNATING : return "alt " ;
|
||||
default : break ;
|
||||
} ;
|
||||
|
||||
return "????" ;
|
||||
} /* str_of_mode */
|
||||
|
||||
static int
|
||||
instrument_dump (const char *filename)
|
||||
{ SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
SF_INSTRUMENT inst ;
|
||||
int got_inst, k ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("Error : Not able to open input file %s.\n", filename) ;
|
||||
fflush (stdout) ;
|
||||
memset (data, 0, sizeof (data)) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
got_inst = sf_command (file, SFC_GET_INSTRUMENT, &inst, sizeof (inst)) ;
|
||||
sf_close (file) ;
|
||||
|
||||
if (got_inst == SF_FALSE)
|
||||
{ printf ("Error : File '%s' does not contain instrument data.\n\n", filename) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
printf ("Instrument : %s\n\n", filename) ;
|
||||
printf (" Gain : %d\n", inst.gain) ;
|
||||
printf (" Base note : %d\n", inst.basenote) ;
|
||||
printf (" Velocity : %d - %d\n", (int) inst.velocity_lo, (int) inst.velocity_hi) ;
|
||||
printf (" Key : %d - %d\n", (int) inst.key_lo, (int) inst.key_hi) ;
|
||||
printf (" Loop points : %d\n", inst.loop_count) ;
|
||||
|
||||
for (k = 0 ; k < inst.loop_count ; k++)
|
||||
printf (" %-2d Mode : %s Start : %6d End : %6d Count : %6d\n", k, str_of_type (inst.loops [k].mode), inst.loops [k].start, inst.loops [k].end, inst.loops [k].count) ;
|
||||
|
||||
putchar ('\n') ;
|
||||
return 0 ;
|
||||
} /* instrument_dump */
|
||||
|
||||
static int
|
||||
broadcast_dump (const char *filename)
|
||||
{ SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
SF_BROADCAST_INFO_2K bext ;
|
||||
double time_ref_sec ;
|
||||
int got_bext ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("Error : Not able to open input file %s.\n", filename) ;
|
||||
fflush (stdout) ;
|
||||
memset (data, 0, sizeof (data)) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
memset (&bext, 0, sizeof (SF_BROADCAST_INFO_2K)) ;
|
||||
|
||||
got_bext = sf_command (file, SFC_GET_BROADCAST_INFO, &bext, sizeof (bext)) ;
|
||||
sf_close (file) ;
|
||||
|
||||
if (got_bext == SF_FALSE)
|
||||
{ printf ("Error : File '%s' does not contain broadcast information.\n\n", filename) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
/*
|
||||
** From : http://www.ebu.ch/en/technical/publications/userguides/bwf_user_guide.php
|
||||
**
|
||||
** Time Reference:
|
||||
** This field is a count from midnight in samples to the first sample
|
||||
** of the audio sequence.
|
||||
*/
|
||||
|
||||
time_ref_sec = ((pow (2.0, 32) * bext.time_reference_high) + (1.0 * bext.time_reference_low)) / sfinfo.samplerate ;
|
||||
|
||||
printf ("Description : %.*s\n", (int) sizeof (bext.description), bext.description) ;
|
||||
printf ("Originator : %.*s\n", (int) sizeof (bext.originator), bext.originator) ;
|
||||
printf ("Origination ref : %.*s\n", (int) sizeof (bext.originator_reference), bext.originator_reference) ;
|
||||
printf ("Origination date : %.*s\n", (int) sizeof (bext.origination_date), bext.origination_date) ;
|
||||
printf ("Origination time : %.*s\n", (int) sizeof (bext.origination_time), bext.origination_time) ;
|
||||
|
||||
if (bext.time_reference_high == 0 && bext.time_reference_low == 0)
|
||||
printf ("Time ref : 0\n") ;
|
||||
else
|
||||
printf ("Time ref : 0x%x%08x (%.6f seconds)\n", bext.time_reference_high, bext.time_reference_low, time_ref_sec) ;
|
||||
|
||||
printf ("BWF version : %d\n", bext.version) ;
|
||||
printf ("UMID : %.*s\n", (int) sizeof (bext.umid), bext.umid) ;
|
||||
printf ("Coding history : %.*s\n", bext.coding_history_size, bext.coding_history) ;
|
||||
|
||||
return 0 ;
|
||||
} /* broadcast_dump */
|
||||
|
||||
static void
|
||||
total_dump (void)
|
||||
{ printf ("========================================\n") ;
|
||||
printf ("Total Duration : %s\n", format_duration_str (total_seconds)) ;
|
||||
} /* total_dump */
|
||||
277
lib-src/libsndfile/programs/sndfile-jackplay.c
Normal file
277
lib-src/libsndfile/programs/sndfile-jackplay.c
Normal file
@@ -0,0 +1,277 @@
|
||||
/*
|
||||
** Copyright (C) 2007 Jonatan Liljedahl <lijon@kymatica.com>
|
||||
**
|
||||
** This program 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.
|
||||
**
|
||||
** This program 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.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if HAVE_JACK
|
||||
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include <jack/jack.h>
|
||||
#include <jack/ringbuffer.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#define RB_SIZE (1 << 16)
|
||||
|
||||
typedef struct _thread_info
|
||||
{ pthread_t thread_id ;
|
||||
SNDFILE *sndfile ;
|
||||
jack_nframes_t pos ;
|
||||
jack_client_t *client ;
|
||||
unsigned int channels ;
|
||||
volatile int can_process ;
|
||||
volatile int read_done ;
|
||||
volatile int play_done ;
|
||||
} thread_info_t ;
|
||||
|
||||
pthread_mutex_t disk_thread_lock = PTHREAD_MUTEX_INITIALIZER ;
|
||||
pthread_cond_t data_ready = PTHREAD_COND_INITIALIZER ;
|
||||
|
||||
static jack_ringbuffer_t *ringbuf ;
|
||||
static jack_port_t **output_port ;
|
||||
static jack_default_audio_sample_t ** outs ;
|
||||
const size_t sample_size = sizeof (jack_default_audio_sample_t) ;
|
||||
|
||||
static int
|
||||
process (jack_nframes_t nframes, void * arg)
|
||||
{
|
||||
thread_info_t *info = (thread_info_t *) arg ;
|
||||
jack_default_audio_sample_t buf [info->channels] ;
|
||||
unsigned i, n ;
|
||||
|
||||
if (! info->can_process)
|
||||
return 0 ;
|
||||
|
||||
for (n = 0 ; n < info->channels ; n++)
|
||||
outs [n] = jack_port_get_buffer (output_port [n], nframes) ;
|
||||
|
||||
for (i = 0 ; i < nframes ; i++)
|
||||
{ size_t read_cnt ;
|
||||
|
||||
/* Read one frame of audio. */
|
||||
read_cnt = jack_ringbuffer_read (ringbuf, (void*) buf, sample_size*info->channels) ;
|
||||
if (read_cnt == 0 && info->read_done)
|
||||
{ /* File is done, so stop the main loop. */
|
||||
info->play_done = 1 ;
|
||||
return 0 ;
|
||||
} ;
|
||||
|
||||
/* Update play-position counter. */
|
||||
info->pos += read_cnt / (sample_size*info->channels) ;
|
||||
|
||||
/* Output each channel of the frame. */
|
||||
for (n = 0 ; n < info->channels ; n++)
|
||||
outs [n][i] = buf [n] ;
|
||||
} ;
|
||||
|
||||
/* Wake up the disk thread to read more data. */
|
||||
if (pthread_mutex_trylock (&disk_thread_lock) == 0)
|
||||
{ pthread_cond_signal (&data_ready) ;
|
||||
pthread_mutex_unlock (&disk_thread_lock) ;
|
||||
} ;
|
||||
|
||||
return 0 ;
|
||||
} /* process */
|
||||
|
||||
static void *
|
||||
disk_thread (void *arg)
|
||||
{ thread_info_t *info = (thread_info_t *) arg ;
|
||||
sf_count_t buf_avail, read_frames ;
|
||||
jack_ringbuffer_data_t vec [2] ;
|
||||
size_t bytes_per_frame = sample_size*info->channels ;
|
||||
|
||||
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL) ;
|
||||
pthread_mutex_lock (&disk_thread_lock) ;
|
||||
|
||||
while (1)
|
||||
{ jack_ringbuffer_get_write_vector (ringbuf, vec) ;
|
||||
|
||||
read_frames = 0 ;
|
||||
|
||||
if (vec [0].len)
|
||||
{ /* Fill the first part of the ringbuffer. */
|
||||
buf_avail = vec [0].len / bytes_per_frame ;
|
||||
read_frames = sf_readf_float (info->sndfile, (float *) vec [0].buf, buf_avail) ;
|
||||
if (vec [1].len)
|
||||
{ /* Fill the second part of the ringbuffer? */
|
||||
buf_avail = vec [1].len / bytes_per_frame ;
|
||||
read_frames += sf_readf_float (info->sndfile, (float *) vec [1].buf, buf_avail) ;
|
||||
} ;
|
||||
} ;
|
||||
|
||||
if (read_frames == 0)
|
||||
break ; /* end of file? */
|
||||
|
||||
jack_ringbuffer_write_advance (ringbuf, read_frames * bytes_per_frame) ;
|
||||
|
||||
/* Tell process that we've filled the ringbuffer. */
|
||||
info->can_process = 1 ;
|
||||
|
||||
/* Wait for the process thread to wake us up. */
|
||||
pthread_cond_wait (&data_ready, &disk_thread_lock) ;
|
||||
} ;
|
||||
|
||||
/* Tell that we're done reading the file. */
|
||||
info->read_done = 1 ;
|
||||
pthread_mutex_unlock (&disk_thread_lock) ;
|
||||
|
||||
return 0 ;
|
||||
} /* disk_thread */
|
||||
|
||||
static void
|
||||
jack_shutdown (void *arg)
|
||||
{ (void) arg ;
|
||||
exit (1) ;
|
||||
} /* jack_shutdown */
|
||||
|
||||
static void
|
||||
print_time (jack_nframes_t pos, int jack_sr)
|
||||
{ float sec = pos / (1.0 * jack_sr) ;
|
||||
int min = sec / 60.0 ;
|
||||
fprintf (stderr, "%02d:%05.2f", min, fmod (sec, 60.0)) ;
|
||||
} /* print_time */
|
||||
|
||||
int
|
||||
main (int narg, char * args [])
|
||||
{
|
||||
SNDFILE *sndfile ;
|
||||
SF_INFO sndfileinfo ;
|
||||
jack_client_t *client ;
|
||||
thread_info_t info ;
|
||||
int i, jack_sr ;
|
||||
|
||||
if (narg < 2)
|
||||
{ fprintf (stderr, "no soundfile given\n") ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
// create jack client
|
||||
if ((client = jack_client_new ("jackplay")) == 0)
|
||||
{
|
||||
fprintf (stderr, "Jack server not running?\n") ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
jack_sr = jack_get_sample_rate (client) ;
|
||||
|
||||
/* Open the soundfile. */
|
||||
sndfileinfo.format = 0 ;
|
||||
sndfile = sf_open (args [1], SFM_READ, &sndfileinfo) ;
|
||||
if (sndfile == NULL)
|
||||
{ fprintf (stderr, "Could not open soundfile '%s'\n", args [1]) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
fprintf (stderr, "Channels : %d\nSample rate : %d Hz\nDuration : ", sndfileinfo.channels, sndfileinfo.samplerate) ;
|
||||
|
||||
print_time (sndfileinfo.frames, sndfileinfo.samplerate) ;
|
||||
fprintf (stderr, "\n") ;
|
||||
|
||||
if (sndfileinfo.samplerate != jack_sr)
|
||||
fprintf (stderr, "Warning: samplerate of soundfile (%d Hz) does not match jack server (%d Hz).\n", sndfileinfo.samplerate, jack_sr) ;
|
||||
|
||||
/* Init the thread info struct. */
|
||||
memset (&info, 0, sizeof (info)) ;
|
||||
info.can_process = 0 ;
|
||||
info.read_done = 0 ;
|
||||
info.play_done = 0 ;
|
||||
info.sndfile = sndfile ;
|
||||
info.channels = sndfileinfo.channels ;
|
||||
info.client = client ;
|
||||
info.pos = 0 ;
|
||||
|
||||
/* Set up callbacks. */
|
||||
jack_set_process_callback (client, process, &info) ;
|
||||
jack_on_shutdown (client, jack_shutdown, 0) ;
|
||||
|
||||
/* Allocate output ports. */
|
||||
output_port = calloc (sndfileinfo.channels, sizeof (jack_port_t *)) ;
|
||||
outs = calloc (sndfileinfo.channels, sizeof (jack_default_audio_sample_t *)) ;
|
||||
for (i = 0 ; i < sndfileinfo.channels ; i++)
|
||||
{ char name [16] ;
|
||||
|
||||
snprintf (name, sizeof (name), "out_%d", i + 1) ;
|
||||
output_port [i] = jack_port_register (client, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0) ;
|
||||
} ;
|
||||
|
||||
/* Allocate and clear ringbuffer. */
|
||||
ringbuf = jack_ringbuffer_create (sizeof (jack_default_audio_sample_t) * RB_SIZE) ;
|
||||
memset (ringbuf->buf, 0, ringbuf->size) ;
|
||||
|
||||
/* Activate client. */
|
||||
if (jack_activate (client))
|
||||
{ fprintf (stderr, "Cannot activate client.\n") ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
/* Auto connect all channels. */
|
||||
for (i = 0 ; i < sndfileinfo.channels ; i++)
|
||||
{ char name [64] ;
|
||||
|
||||
snprintf (name, sizeof (name), "alsa_pcm:playback_%d", i + 1) ;
|
||||
|
||||
if (jack_connect (client, jack_port_name (output_port [i]), name))
|
||||
fprintf (stderr, "Cannot connect output port %d (%s).\n", i, name) ;
|
||||
} ;
|
||||
|
||||
/* Start the disk thread. */
|
||||
pthread_create (&info.thread_id, NULL, disk_thread, &info) ;
|
||||
|
||||
/* Sit in a loop, displaying the current play position. */
|
||||
while (! info.play_done)
|
||||
{ fprintf (stderr, "\r-> ") ;
|
||||
print_time (info.pos, jack_sr) ;
|
||||
fflush (stdout) ;
|
||||
usleep (50000) ;
|
||||
} ;
|
||||
|
||||
/* Clean up. */
|
||||
jack_client_close (client) ;
|
||||
jack_ringbuffer_free (ringbuf) ;
|
||||
sf_close (sndfile) ;
|
||||
free (outs) ;
|
||||
free (output_port) ;
|
||||
|
||||
puts ("") ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
#else
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
puts (
|
||||
"Sorry this program was compiled without libjack (which probably\n"
|
||||
"only exists on Linux and Mac OSX) and hence doesn't work."
|
||||
) ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
#endif
|
||||
177
lib-src/libsndfile/programs/sndfile-metadata-get.c
Normal file
177
lib-src/libsndfile/programs/sndfile-metadata-get.c
Normal file
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
** Copyright (C) 2008 George Blood Audio
|
||||
** Written by Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the author nor the names of any contributors may be used
|
||||
** to endorse or promote products derived from this software without
|
||||
** specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define BUFFER_LEN (1 << 16)
|
||||
|
||||
static void usage_exit (const char *progname, int exit_code) ;
|
||||
static void process_args (SNDFILE * file, const SF_BROADCAST_INFO_2K * binfo, int argc, char * argv []) ;
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{ SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
SF_BROADCAST_INFO_2K binfo ;
|
||||
const char *progname ;
|
||||
const char * filename = NULL ;
|
||||
int start ;
|
||||
|
||||
/* Store the program name. */
|
||||
progname = strrchr (argv [0], '/') ;
|
||||
progname = progname ? progname + 1 : argv [0] ;
|
||||
|
||||
/* Check if we've been asked for help. */
|
||||
if (argc <= 2 || strcmp (argv [1], "--help") == 0 || strcmp (argv [1], "-h") == 0)
|
||||
usage_exit (progname, 0) ;
|
||||
|
||||
if (argv [argc - 1][0] != '-')
|
||||
{ filename = argv [argc - 1] ;
|
||||
start = 1 ;
|
||||
}
|
||||
else if (argv [1][0] != '-')
|
||||
{ filename = argv [1] ;
|
||||
start = 2 ;
|
||||
}
|
||||
else
|
||||
{ printf ("Error : Either the first or the last command line parameter should be a filename.\n\n") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
/* Get the time in case we need it later. */
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("Error : Open of file '%s' failed : %s\n\n", filename, sf_strerror (file)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
memset (&binfo, 0, sizeof (binfo)) ;
|
||||
if (sf_command (file, SFC_GET_BROADCAST_INFO, &binfo, sizeof (binfo)) == 0)
|
||||
memset (&binfo, 0, sizeof (binfo)) ;
|
||||
|
||||
process_args (file, &binfo, argc - 2, argv + start) ;
|
||||
|
||||
sf_close (file) ;
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
/*==============================================================================
|
||||
** Print version and usage.
|
||||
*/
|
||||
|
||||
static void
|
||||
usage_exit (const char *progname, int exit_code)
|
||||
{ printf ("\nUsage :\n %s [options] <file>\n\nOptions:\n", progname) ;
|
||||
|
||||
puts (
|
||||
" --bext-description Print the 'bext' description.\n"
|
||||
" --bext-originator Print the 'bext; originator info.\n"
|
||||
" --bext-orig-ref Print the 'bext' origination reference.\n"
|
||||
" --bext-umid Print the 'bext' UMID.\n"
|
||||
" --bext-orig-date Print the 'bext' origination date.\n"
|
||||
" --bext-orig-time Print the 'bext' origination time.\n"
|
||||
" --bext-coding-hist Print the 'bext' coding history.\n"
|
||||
) ;
|
||||
|
||||
puts (
|
||||
" --str-title Print the title metadata.\n"
|
||||
" --str-copyright Print the copyright metadata.\n"
|
||||
" --str-artist Print the artist metadata.\n"
|
||||
" --str-comment Print the comment metadata.\n"
|
||||
" --str-date Print the creation date metadata.\n"
|
||||
" --str-album Print the album metadata.\n"
|
||||
" --str-license Print the license metadata.\n"
|
||||
) ;
|
||||
|
||||
exit (exit_code) ;
|
||||
} /* usage_exit */
|
||||
|
||||
static void
|
||||
process_args (SNDFILE * file, const SF_BROADCAST_INFO_2K * binfo, int argc, char * argv [])
|
||||
{ const char * str ;
|
||||
int k, do_all = 0 ;
|
||||
|
||||
#define HANDLE_BEXT_ARG(cmd,name,field) \
|
||||
if (do_all || strcmp (argv [k], cmd) == 0) \
|
||||
{ printf ("%-20s : %.*s\n", name, (int) sizeof (binfo->field), binfo->field) ; \
|
||||
if (! do_all) \
|
||||
continue ; \
|
||||
} ;
|
||||
|
||||
#define HANDLE_STR_ARG(cmd,name,id) \
|
||||
if (do_all || strcmp (argv [k], cmd) == 0) \
|
||||
{ str = sf_get_string (file, id) ; \
|
||||
printf ("%-20s : %s\n", name, str ? str : "") ; \
|
||||
if (! do_all) continue ; \
|
||||
} ;
|
||||
|
||||
for (k = 0 ; k < argc ; k++)
|
||||
{ if (do_all || strcmp (argv [k], "--all") == 0)
|
||||
do_all = 1 ;
|
||||
|
||||
HANDLE_BEXT_ARG ("--bext-description", "Description", description) ;
|
||||
HANDLE_BEXT_ARG ("--bext-originator", "Originator", originator) ;
|
||||
HANDLE_BEXT_ARG ("--bext-orig-ref", "Origination ref", originator_reference) ;
|
||||
HANDLE_BEXT_ARG ("--bext-umid", "UMID", umid) ;
|
||||
HANDLE_BEXT_ARG ("--bext-orig-date", "Origination date", origination_date) ;
|
||||
HANDLE_BEXT_ARG ("--bext-orig-time", "Origination time", origination_time) ;
|
||||
HANDLE_BEXT_ARG ("--bext-coding-hist", "Coding history", coding_history) ;
|
||||
|
||||
HANDLE_STR_ARG ("--str-title", "Name", SF_STR_TITLE) ;
|
||||
HANDLE_STR_ARG ("--str-copyright", "Copyright", SF_STR_COPYRIGHT) ;
|
||||
HANDLE_STR_ARG ("--str-artist", "Artist", SF_STR_ARTIST) ;
|
||||
HANDLE_STR_ARG ("--str-comment", "Comment", SF_STR_COMMENT) ;
|
||||
HANDLE_STR_ARG ("--str-date", "Create date", SF_STR_DATE) ;
|
||||
HANDLE_STR_ARG ("--str-album", "Album", SF_STR_ALBUM) ;
|
||||
HANDLE_STR_ARG ("--str-license", "License", SF_STR_LICENSE) ;
|
||||
|
||||
if (! do_all)
|
||||
{ printf ("Error : Don't know what to do with command line arg '%s'.\n\n", argv [k]) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
break ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* process_args */
|
||||
279
lib-src/libsndfile/programs/sndfile-metadata-set.c
Normal file
279
lib-src/libsndfile/programs/sndfile-metadata-set.c
Normal file
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
** Copyright (C) 2008 George Blood Audio
|
||||
** Written by Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the author nor the names of any contributors may be used
|
||||
** to endorse or promote products derived from this software without
|
||||
** specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define BUFFER_LEN (1 << 16)
|
||||
|
||||
|
||||
static void usage_exit (const char *progname, int exit_code) ;
|
||||
static void missing_param (const char * option) ;
|
||||
static void read_localtime (struct tm * timedata) ;
|
||||
static int has_bext_fields_set (const METADATA_INFO * info) ;
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{ METADATA_INFO info ;
|
||||
struct tm timedata ;
|
||||
const char *progname ;
|
||||
const char * filenames [2] = { NULL, NULL } ;
|
||||
int k ;
|
||||
|
||||
/* Store the program name. */
|
||||
progname = strrchr (argv [0], '/') ;
|
||||
progname = progname ? progname + 1 : argv [0] ;
|
||||
|
||||
/* Check if we've been asked for help. */
|
||||
if (argc < 3 || strcmp (argv [1], "--help") == 0 || strcmp (argv [1], "-h") == 0)
|
||||
usage_exit (progname, 0) ;
|
||||
|
||||
/* Clear set all fields of the struct to zero bytes. */
|
||||
memset (&info, 0, sizeof (info)) ;
|
||||
|
||||
/* Get the time in case we need it later. */
|
||||
read_localtime (&timedata) ;
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
{ char tmp [20] ;
|
||||
|
||||
if (argv [k][0] != '-')
|
||||
{ if (filenames [0] == NULL)
|
||||
filenames [0] = argv [k] ;
|
||||
else if (filenames [1] == NULL)
|
||||
filenames [1] = argv [k] ;
|
||||
else
|
||||
{ printf ("Error : Already have two file names on the command line and then found '%s'.\n\n", argv [k]) ;
|
||||
usage_exit (progname, 1) ;
|
||||
} ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
#define HANDLE_BEXT_ARG(cmd,field) \
|
||||
if (strcmp (argv [k], cmd) == 0) \
|
||||
{ k ++ ; \
|
||||
if (k == argc) missing_param (argv [k - 1]) ; \
|
||||
info.field = argv [k] ; \
|
||||
continue ; \
|
||||
} ;
|
||||
|
||||
HANDLE_BEXT_ARG ("--bext-description", description) ;
|
||||
HANDLE_BEXT_ARG ("--bext-originator", originator) ;
|
||||
HANDLE_BEXT_ARG ("--bext-orig-ref", originator_reference) ;
|
||||
HANDLE_BEXT_ARG ("--bext-umid", umid) ;
|
||||
HANDLE_BEXT_ARG ("--bext-orig-date", origination_date) ;
|
||||
HANDLE_BEXT_ARG ("--bext-orig-time", origination_time) ;
|
||||
HANDLE_BEXT_ARG ("--bext-coding-hist", coding_history) ;
|
||||
|
||||
#define HANDLE_STR_ARG(cmd,field) \
|
||||
if (strcmp (argv [k], cmd) == 0) \
|
||||
{ k ++ ; \
|
||||
if (k == argc) missing_param (argv [k - 1]) ; \
|
||||
info.field = argv [k] ; \
|
||||
continue ; \
|
||||
} ;
|
||||
|
||||
HANDLE_STR_ARG ("--str-title", title) ;
|
||||
HANDLE_STR_ARG ("--str-copyright", copyright) ;
|
||||
HANDLE_STR_ARG ("--str-artist", artist) ;
|
||||
HANDLE_STR_ARG ("--str-date", date) ;
|
||||
HANDLE_STR_ARG ("--str-album", album) ;
|
||||
HANDLE_STR_ARG ("--str-license", license) ;
|
||||
|
||||
/* Following options do not take an argument. */
|
||||
if (strcmp (argv [k], "--bext-auto-time-date") == 0)
|
||||
{ snprintf (tmp, sizeof (tmp), "%02d:%02d:%02d", timedata.tm_hour, timedata.tm_min, timedata.tm_sec) ;
|
||||
info.origination_time = strdup (tmp) ;
|
||||
|
||||
snprintf (tmp, sizeof (tmp), "%04d-%02d-%02d", timedata.tm_year + 1900, timedata.tm_mon + 1, timedata.tm_mday) ;
|
||||
info.origination_date = strdup (tmp) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (strcmp (argv [k], "--bext-auto-time") == 0)
|
||||
{ snprintf (tmp, sizeof (tmp), "%02d:%02d:%02d", timedata.tm_hour, timedata.tm_min, timedata.tm_sec) ;
|
||||
info.origination_time = strdup (tmp) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (strcmp (argv [k], "--bext-auto-date") == 0)
|
||||
{ snprintf (tmp, sizeof (tmp), "%04d-%02d-%02d", timedata.tm_year + 1900, timedata.tm_mon + 1, timedata.tm_mday) ;
|
||||
info.origination_date = strdup (tmp) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (strcmp (argv [k], "--str-auto-date") == 0)
|
||||
{ snprintf (tmp, sizeof (tmp), "%04d-%02d-%02d", timedata.tm_year + 1900, timedata.tm_mon + 1, timedata.tm_mday) ;
|
||||
|
||||
info.date = strdup (tmp) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
printf ("Error : Don't know what to do with command line arg '%s'.\n\n", argv [k]) ;
|
||||
usage_exit (progname, 1) ;
|
||||
} ;
|
||||
|
||||
/* Find out if any of the 'bext' fields are set. */
|
||||
info.has_bext_fields = has_bext_fields_set (&info) ;
|
||||
|
||||
if (filenames [0] == NULL)
|
||||
{ printf ("Error : No input file specificed.\n\n") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (filenames [1] != NULL && strcmp (filenames [0], filenames [1]) == 0)
|
||||
{ printf ("Error : Input and output files are the same.\n\n") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (info.coding_history != NULL && filenames [1] == NULL)
|
||||
{ printf ("\n"
|
||||
"Error : Trying to update coding history of an existing file which unfortunately\n"
|
||||
" is not supported. Instead, create a new file using :\n"
|
||||
"\n"
|
||||
" %s --bext-coding-hist \"Coding history\" old_file.wav new_file.wav\n"
|
||||
"\n",
|
||||
progname) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
sfe_apply_metadata_changes (filenames, &info) ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
/*==============================================================================
|
||||
** Print version and usage.
|
||||
*/
|
||||
|
||||
static void
|
||||
usage_exit (const char *progname, int exit_code)
|
||||
{ printf ("\nUsage :\n\n"
|
||||
" %s [options] <file>\n"
|
||||
" %s [options] <input file> <output file>\n"
|
||||
"\n",
|
||||
progname, progname) ;
|
||||
|
||||
puts (
|
||||
"Where an option is made up of a pair of a field to set (one of\n"
|
||||
"the 'bext' or metadata fields below) and a string. Fields are\n"
|
||||
"as follows :\n"
|
||||
) ;
|
||||
|
||||
puts (
|
||||
" --bext-description Set the 'bext' description.\n"
|
||||
" --bext-originator Set the 'bext' originator.\n"
|
||||
" --bext-orig-ref Set the 'bext' originator reference.\n"
|
||||
" --bext-umid Set the 'bext' UMID.\n"
|
||||
" --bext-orig-date Set the 'bext' origination date.\n"
|
||||
" --bext-orig-time Set the 'bext' origination time.\n"
|
||||
" --bext-coding-hist Set the 'bext' coding history\n"
|
||||
"\n"
|
||||
" --str-title Set the metadata title.\n"
|
||||
" --str-copyright Set the metadata copyright.\n"
|
||||
" --str-artist Set the metadata artist.\n"
|
||||
" --str-date Set the metadata date.\n"
|
||||
" --str-album Set the metadata album.\n"
|
||||
" --str-license Set the metadata license.\n"
|
||||
) ;
|
||||
|
||||
puts (
|
||||
"There are also the following arguments which do not take a\n"
|
||||
"parameter :\n\n"
|
||||
" --bext-auto-time-date Set the 'bext' time and date to current time/date.\n"
|
||||
" --bext-auto-time Set the 'bext' time to current time.\n"
|
||||
" --bext-auto-date Set the 'bext' date to current date.\n"
|
||||
" --str-auto-date Set the metadata date to current date.\n"
|
||||
) ;
|
||||
|
||||
puts (
|
||||
"Most of the above operations can be done in-place on an existing\n"
|
||||
"file. If any operation cannot be performed, the application will\n"
|
||||
"exit with an appropriate error message.\n"
|
||||
) ;
|
||||
|
||||
exit (exit_code) ;
|
||||
} /* usage_exit */
|
||||
|
||||
static void
|
||||
missing_param (const char * option)
|
||||
{
|
||||
printf ("Error : Option '%s' needs a parameter but doesn't seem to have one.\n\n", option) ;
|
||||
exit (1) ;
|
||||
} /* missing_param */
|
||||
|
||||
/*==============================================================================
|
||||
*/
|
||||
|
||||
static int
|
||||
has_bext_fields_set (const METADATA_INFO * info)
|
||||
{
|
||||
if (info->description || info->originator || info->originator_reference)
|
||||
return 1 ;
|
||||
|
||||
if (info->origination_date || info->origination_time || info->umid || info->coding_history)
|
||||
return 1 ;
|
||||
|
||||
return 0 ;
|
||||
} /* has_bext_fields_set */
|
||||
|
||||
static void
|
||||
read_localtime (struct tm * timedata)
|
||||
{ time_t current ;
|
||||
struct tm *tmptr ;
|
||||
|
||||
time (¤t) ;
|
||||
memset (timedata, 0, sizeof (struct tm)) ;
|
||||
|
||||
#if defined (HAVE_LOCALTIME_R)
|
||||
/* If the re-entrant version is available, use it. */
|
||||
tmptr = localtime_r (¤t, timedata) ;
|
||||
#elif defined (HAVE_LOCALTIME)
|
||||
/* Otherwise use the standard one and copy the data to local storage. */
|
||||
tmptr = localtime (¤t) ;
|
||||
memcpy (timedata, tmptr, sizeof (struct tm)) ;
|
||||
#endif
|
||||
|
||||
return ;
|
||||
} /* read_localtime */
|
||||
|
||||
144
lib-src/libsndfile/programs/sndfile-play-beos.cpp
Normal file
144
lib-src/libsndfile/programs/sndfile-play-beos.cpp
Normal file
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
** Copyright (C) 2001 Marcus Overhagen <marcus@overhagen.de>
|
||||
**
|
||||
** This program 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.
|
||||
**
|
||||
** This program 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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Application.h>
|
||||
#include <SoundPlayer.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#define BUFFER_LEN 1024
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
** BeOS functions for playing a sound.
|
||||
*/
|
||||
|
||||
#if defined (__BEOS__)
|
||||
|
||||
struct shared_data
|
||||
{
|
||||
BSoundPlayer *player;
|
||||
SNDFILE *sndfile;
|
||||
SF_INFO sfinfo;
|
||||
sem_id finished;
|
||||
};
|
||||
|
||||
static void
|
||||
buffer_callback(void *theCookie, void *buf, size_t size, const media_raw_audio_format &format)
|
||||
{
|
||||
shared_data *data = (shared_data *)theCookie;
|
||||
short *buffer = (short *)buf;
|
||||
int count = size / sizeof(short);
|
||||
int m, readcount;
|
||||
|
||||
if (!data->player->HasData())
|
||||
return;
|
||||
|
||||
readcount = sf_read_short(data->sndfile, buffer, count);
|
||||
if (readcount == 0)
|
||||
{ data->player->SetHasData(false);
|
||||
release_sem(data->finished);
|
||||
}
|
||||
if (readcount < count)
|
||||
{ for (m = readcount ; m < count ; m++)
|
||||
buffer [m] = 0 ;
|
||||
}
|
||||
if (data->sfinfo.pcmbitwidth < 16)
|
||||
{ for (m = 0 ; m < count ; m++)
|
||||
buffer [m] *= 256 ;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
beos_play (int argc, char *argv [])
|
||||
{
|
||||
shared_data data;
|
||||
status_t status;
|
||||
int k;
|
||||
|
||||
/* BSoundPlayer requires a BApplication object */
|
||||
BApplication app("application/x-vnd.MarcusOverhagen-sfplay");
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
{ printf ("Playing %s\n", argv [k]) ;
|
||||
if (! (data.sndfile = sf_open_read (argv [k], &data.sfinfo)))
|
||||
{ sf_perror (NULL) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (data.sfinfo.channels < 1 || data.sfinfo.channels > 2)
|
||||
{ printf ("Error : channels = %d.\n", data.sfinfo.channels) ;
|
||||
sf_close (data.sndfile) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
data.finished = create_sem(0,"finished");
|
||||
|
||||
media_raw_audio_format format =
|
||||
{ data.sfinfo.samplerate,
|
||||
data.sfinfo.channels,
|
||||
media_raw_audio_format::B_AUDIO_SHORT,
|
||||
B_HOST_IS_LENDIAN ? B_MEDIA_LITTLE_ENDIAN : B_MEDIA_BIG_ENDIAN,
|
||||
BUFFER_LEN * sizeof(short)
|
||||
};
|
||||
|
||||
BSoundPlayer player(&format,"player",buffer_callback,NULL,&data);
|
||||
data.player = &player;
|
||||
|
||||
if ((status = player.InitCheck()) != B_OK)
|
||||
{
|
||||
printf ("Error : BSoundPlayer init failed, %s.\n", strerror(status)) ;
|
||||
delete_sem(data.finished);
|
||||
sf_close (data.sndfile) ;
|
||||
continue ;
|
||||
}
|
||||
|
||||
player.SetVolume(1.0);
|
||||
player.Start();
|
||||
player.SetHasData(true);
|
||||
acquire_sem(data.finished);
|
||||
player.Stop();
|
||||
delete_sem(data.finished);
|
||||
|
||||
sf_close (data.sndfile) ;
|
||||
|
||||
} ;
|
||||
|
||||
} /* beos_play */
|
||||
|
||||
#endif
|
||||
|
||||
/*==============================================================================
|
||||
** Main function.
|
||||
*/
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
if (argc < 2)
|
||||
{ printf ("Usage : %s <input sound file>\n\n", argv [0]) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
beos_play (argc, argv) ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
958
lib-src/libsndfile/programs/sndfile-play.c
Normal file
958
lib-src/libsndfile/programs/sndfile-play.c
Normal file
@@ -0,0 +1,958 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the author nor the names of any contributors may be used
|
||||
** to endorse or promote products derived from this software without
|
||||
** specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_ALSA_ASOUNDLIB_H
|
||||
#define ALSA_PCM_NEW_HW_PARAMS_API
|
||||
#define ALSA_PCM_NEW_SW_PARAMS_API
|
||||
#include <alsa/asoundlib.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#if defined (__linux__)
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/soundcard.h>
|
||||
|
||||
#elif (defined (__MACH__) && defined (__APPLE__))
|
||||
#include <Carbon.h>
|
||||
#include <CoreAudio/AudioHardware.h>
|
||||
|
||||
#elif (defined (sun) && defined (unix))
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/audioio.h>
|
||||
|
||||
#elif (OS_IS_WIN32 == 1)
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
|
||||
#endif
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#define SIGNED_SIZEOF(x) ((int) sizeof (x))
|
||||
#define BUFFER_LEN (2048)
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
** Linux/OSS functions for playing a sound.
|
||||
*/
|
||||
|
||||
#if HAVE_ALSA_ASOUNDLIB_H
|
||||
|
||||
static snd_pcm_t * alsa_open (int channels, unsigned srate, int realtime) ;
|
||||
static int alsa_write_float (snd_pcm_t *alsa_dev, float *data, int frames, int channels) ;
|
||||
|
||||
static void
|
||||
alsa_play (int argc, char *argv [])
|
||||
{ static float buffer [BUFFER_LEN] ;
|
||||
SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
snd_pcm_t * alsa_dev ;
|
||||
int k, readcount, subformat ;
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
{ memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
printf ("Playing %s\n", argv [k]) ;
|
||||
if (! (sndfile = sf_open (argv [k], SFM_READ, &sfinfo)))
|
||||
{ puts (sf_strerror (NULL)) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (sfinfo.channels < 1 || sfinfo.channels > 2)
|
||||
{ printf ("Error : channels = %d.\n", sfinfo.channels) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if ((alsa_dev = alsa_open (sfinfo.channels, (unsigned) sfinfo.samplerate, SF_FALSE)) == NULL)
|
||||
continue ;
|
||||
|
||||
subformat = sfinfo.format & SF_FORMAT_SUBMASK ;
|
||||
|
||||
if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE)
|
||||
{ double scale ;
|
||||
int m ;
|
||||
|
||||
sf_command (sndfile, SFC_CALC_SIGNAL_MAX, &scale, sizeof (scale)) ;
|
||||
if (scale < 1e-10)
|
||||
scale = 1.0 ;
|
||||
else
|
||||
scale = 32700.0 / scale ;
|
||||
|
||||
while ((readcount = sf_read_float (sndfile, buffer, BUFFER_LEN)))
|
||||
{ for (m = 0 ; m < readcount ; m++)
|
||||
buffer [m] *= scale ;
|
||||
alsa_write_float (alsa_dev, buffer, BUFFER_LEN / sfinfo.channels, sfinfo.channels) ;
|
||||
} ;
|
||||
}
|
||||
else
|
||||
{ while ((readcount = sf_read_float (sndfile, buffer, BUFFER_LEN)))
|
||||
alsa_write_float (alsa_dev, buffer, BUFFER_LEN / sfinfo.channels, sfinfo.channels) ;
|
||||
} ;
|
||||
|
||||
snd_pcm_drain (alsa_dev) ;
|
||||
snd_pcm_close (alsa_dev) ;
|
||||
|
||||
sf_close (sndfile) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* alsa_play */
|
||||
|
||||
static snd_pcm_t *
|
||||
alsa_open (int channels, unsigned samplerate, int realtime)
|
||||
{ const char * device = "default" ;
|
||||
snd_pcm_t *alsa_dev = NULL ;
|
||||
snd_pcm_hw_params_t *hw_params ;
|
||||
snd_pcm_uframes_t buffer_size ;
|
||||
snd_pcm_uframes_t alsa_period_size, alsa_buffer_frames ;
|
||||
snd_pcm_sw_params_t *sw_params ;
|
||||
|
||||
int err ;
|
||||
|
||||
if (realtime)
|
||||
{ alsa_period_size = 256 ;
|
||||
alsa_buffer_frames = 3 * alsa_period_size ;
|
||||
}
|
||||
else
|
||||
{ alsa_period_size = 1024 ;
|
||||
alsa_buffer_frames = 4 * alsa_period_size ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_open (&alsa_dev, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0)
|
||||
{ fprintf (stderr, "cannot open audio device \"%s\" (%s)\n", device, snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
snd_pcm_nonblock (alsa_dev, 0) ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_malloc (&hw_params)) < 0)
|
||||
{ fprintf (stderr, "cannot allocate hardware parameter structure (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_any (alsa_dev, hw_params)) < 0)
|
||||
{ fprintf (stderr, "cannot initialize hardware parameter structure (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_access (alsa_dev, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0)
|
||||
{ fprintf (stderr, "cannot set access type (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_format (alsa_dev, hw_params, SND_PCM_FORMAT_FLOAT)) < 0)
|
||||
{ fprintf (stderr, "cannot set sample format (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_rate_near (alsa_dev, hw_params, &samplerate, 0)) < 0)
|
||||
{ fprintf (stderr, "cannot set sample rate (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_channels (alsa_dev, hw_params, channels)) < 0)
|
||||
{ fprintf (stderr, "cannot set channel count (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_buffer_size_near (alsa_dev, hw_params, &alsa_buffer_frames)) < 0)
|
||||
{ fprintf (stderr, "cannot set buffer size (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_period_size_near (alsa_dev, hw_params, &alsa_period_size, 0)) < 0)
|
||||
{ fprintf (stderr, "cannot set period size (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params (alsa_dev, hw_params)) < 0)
|
||||
{ fprintf (stderr, "cannot set parameters (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
/* extra check: if we have only one period, this code won't work */
|
||||
snd_pcm_hw_params_get_period_size (hw_params, &alsa_period_size, 0) ;
|
||||
snd_pcm_hw_params_get_buffer_size (hw_params, &buffer_size) ;
|
||||
if (alsa_period_size == buffer_size)
|
||||
{ fprintf (stderr, "Can't use period equal to buffer size (%lu == %lu)", alsa_period_size, buffer_size) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
snd_pcm_hw_params_free (hw_params) ;
|
||||
|
||||
if ((err = snd_pcm_sw_params_malloc (&sw_params)) != 0)
|
||||
{ fprintf (stderr, "%s: snd_pcm_sw_params_malloc: %s", __func__, snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_sw_params_current (alsa_dev, sw_params)) != 0)
|
||||
{ fprintf (stderr, "%s: snd_pcm_sw_params_current: %s", __func__, snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
/* note: set start threshold to delay start until the ring buffer is full */
|
||||
snd_pcm_sw_params_current (alsa_dev, sw_params) ;
|
||||
|
||||
if ((err = snd_pcm_sw_params_set_start_threshold (alsa_dev, sw_params, buffer_size)) < 0)
|
||||
{ fprintf (stderr, "cannot set start threshold (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_sw_params (alsa_dev, sw_params)) != 0)
|
||||
{ fprintf (stderr, "%s: snd_pcm_sw_params: %s", __func__, snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
snd_pcm_sw_params_free (sw_params) ;
|
||||
|
||||
snd_pcm_reset (alsa_dev) ;
|
||||
|
||||
catch_error :
|
||||
|
||||
if (err < 0 && alsa_dev != NULL)
|
||||
{ snd_pcm_close (alsa_dev) ;
|
||||
return NULL ;
|
||||
} ;
|
||||
|
||||
return alsa_dev ;
|
||||
} /* alsa_open */
|
||||
|
||||
static int
|
||||
alsa_write_float (snd_pcm_t *alsa_dev, float *data, int frames, int channels)
|
||||
{ static int epipe_count = 0 ;
|
||||
|
||||
int total = 0 ;
|
||||
int retval ;
|
||||
|
||||
if (epipe_count > 0)
|
||||
epipe_count -- ;
|
||||
|
||||
while (total < frames)
|
||||
{ retval = snd_pcm_writei (alsa_dev, data + total * channels, frames - total) ;
|
||||
|
||||
if (retval >= 0)
|
||||
{ total += retval ;
|
||||
if (total == frames)
|
||||
return total ;
|
||||
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
switch (retval)
|
||||
{ case -EAGAIN :
|
||||
puts ("alsa_write_float: EAGAIN") ;
|
||||
continue ;
|
||||
break ;
|
||||
|
||||
case -EPIPE :
|
||||
if (epipe_count > 0)
|
||||
{ printf ("alsa_write_float: EPIPE %d\n", epipe_count) ;
|
||||
if (epipe_count > 140)
|
||||
return retval ;
|
||||
} ;
|
||||
epipe_count += 100 ;
|
||||
|
||||
#if 0
|
||||
if (0)
|
||||
{ snd_pcm_status_t *status ;
|
||||
|
||||
snd_pcm_status_alloca (&status) ;
|
||||
if ((retval = snd_pcm_status (alsa_dev, status)) < 0)
|
||||
fprintf (stderr, "alsa_out: xrun. can't determine length\n") ;
|
||||
else if (snd_pcm_status_get_state (status) == SND_PCM_STATE_XRUN)
|
||||
{ struct timeval now, diff, tstamp ;
|
||||
|
||||
gettimeofday (&now, 0) ;
|
||||
snd_pcm_status_get_trigger_tstamp (status, &tstamp) ;
|
||||
timersub (&now, &tstamp, &diff) ;
|
||||
|
||||
fprintf (stderr, "alsa_write_float xrun: of at least %.3f msecs. resetting stream\n",
|
||||
diff.tv_sec * 1000 + diff.tv_usec / 1000.0) ;
|
||||
}
|
||||
else
|
||||
fprintf (stderr, "alsa_write_float: xrun. can't determine length\n") ;
|
||||
} ;
|
||||
#endif
|
||||
|
||||
snd_pcm_prepare (alsa_dev) ;
|
||||
break ;
|
||||
|
||||
case -EBADFD :
|
||||
fprintf (stderr, "alsa_write_float: Bad PCM state.n") ;
|
||||
return 0 ;
|
||||
break ;
|
||||
|
||||
case -ESTRPIPE :
|
||||
fprintf (stderr, "alsa_write_float: Suspend event.n") ;
|
||||
return 0 ;
|
||||
break ;
|
||||
|
||||
case -EIO :
|
||||
puts ("alsa_write_float: EIO") ;
|
||||
return 0 ;
|
||||
|
||||
default :
|
||||
fprintf (stderr, "alsa_write_float: retval = %d\n", retval) ;
|
||||
return 0 ;
|
||||
break ;
|
||||
} ; /* switch */
|
||||
} ; /* while */
|
||||
|
||||
return total ;
|
||||
} /* alsa_write_float */
|
||||
|
||||
#endif /* HAVE_ALSA_ASOUNDLIB_H */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
** Linux/OSS functions for playing a sound.
|
||||
*/
|
||||
|
||||
#if defined (__linux__)
|
||||
|
||||
static int linux_open_dsp_device (int channels, int srate) ;
|
||||
|
||||
static void
|
||||
linux_play (int argc, char *argv [])
|
||||
{ static short buffer [BUFFER_LEN] ;
|
||||
SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
int k, audio_device, readcount, writecount, subformat ;
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
{ memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
printf ("Playing %s\n", argv [k]) ;
|
||||
if (! (sndfile = sf_open (argv [k], SFM_READ, &sfinfo)))
|
||||
{ puts (sf_strerror (NULL)) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (sfinfo.channels < 1 || sfinfo.channels > 2)
|
||||
{ printf ("Error : channels = %d.\n", sfinfo.channels) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
audio_device = linux_open_dsp_device (sfinfo.channels, sfinfo.samplerate) ;
|
||||
|
||||
subformat = sfinfo.format & SF_FORMAT_SUBMASK ;
|
||||
|
||||
if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE)
|
||||
{ static float float_buffer [BUFFER_LEN] ;
|
||||
double scale ;
|
||||
int m ;
|
||||
|
||||
sf_command (sndfile, SFC_CALC_SIGNAL_MAX, &scale, sizeof (scale)) ;
|
||||
if (scale < 1e-10)
|
||||
scale = 1.0 ;
|
||||
else
|
||||
scale = 32700.0 / scale ;
|
||||
|
||||
while ((readcount = sf_read_float (sndfile, float_buffer, BUFFER_LEN)))
|
||||
{ for (m = 0 ; m < readcount ; m++)
|
||||
buffer [m] = scale * float_buffer [m] ;
|
||||
writecount = write (audio_device, buffer, readcount * sizeof (short)) ;
|
||||
} ;
|
||||
}
|
||||
else
|
||||
{ while ((readcount = sf_read_short (sndfile, buffer, BUFFER_LEN)))
|
||||
writecount = write (audio_device, buffer, readcount * sizeof (short)) ;
|
||||
} ;
|
||||
|
||||
if (ioctl (audio_device, SNDCTL_DSP_POST, 0) == -1)
|
||||
perror ("ioctl (SNDCTL_DSP_POST) ") ;
|
||||
|
||||
if (ioctl (audio_device, SNDCTL_DSP_SYNC, 0) == -1)
|
||||
perror ("ioctl (SNDCTL_DSP_SYNC) ") ;
|
||||
|
||||
close (audio_device) ;
|
||||
|
||||
sf_close (sndfile) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* linux_play */
|
||||
|
||||
static int
|
||||
linux_open_dsp_device (int channels, int srate)
|
||||
{ int fd, stereo, fmt ;
|
||||
|
||||
if ((fd = open ("/dev/dsp", O_WRONLY, 0)) == -1 &&
|
||||
(fd = open ("/dev/sound/dsp", O_WRONLY, 0)) == -1)
|
||||
{ perror ("linux_open_dsp_device : open ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
stereo = 0 ;
|
||||
if (ioctl (fd, SNDCTL_DSP_STEREO, &stereo) == -1)
|
||||
{ /* Fatal error */
|
||||
perror ("linux_open_dsp_device : stereo ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (ioctl (fd, SNDCTL_DSP_RESET, 0))
|
||||
{ perror ("linux_open_dsp_device : reset ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
fmt = CPU_IS_BIG_ENDIAN ? AFMT_S16_BE : AFMT_S16_LE ;
|
||||
if (ioctl (fd, SNDCTL_DSP_SETFMT, &fmt) != 0)
|
||||
{ perror ("linux_open_dsp_device : set format ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (ioctl (fd, SNDCTL_DSP_CHANNELS, &channels) != 0)
|
||||
{ perror ("linux_open_dsp_device : channels ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (ioctl (fd, SNDCTL_DSP_SPEED, &srate) != 0)
|
||||
{ perror ("linux_open_dsp_device : sample rate ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (ioctl (fd, SNDCTL_DSP_SYNC, 0) != 0)
|
||||
{ perror ("linux_open_dsp_device : sync ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
return fd ;
|
||||
} /* linux_open_dsp_device */
|
||||
|
||||
#endif /* __linux__ */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
** Mac OS X functions for playing a sound.
|
||||
*/
|
||||
|
||||
#if (defined (__MACH__) && defined (__APPLE__)) /* MacOSX */
|
||||
|
||||
typedef struct
|
||||
{ AudioStreamBasicDescription format ;
|
||||
|
||||
UInt32 buf_size ;
|
||||
AudioDeviceID device ;
|
||||
|
||||
SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
|
||||
int fake_stereo ;
|
||||
int done_playing ;
|
||||
} MacOSXAudioData ;
|
||||
|
||||
#include <math.h>
|
||||
|
||||
static OSStatus
|
||||
macosx_audio_out_callback (AudioDeviceID device, const AudioTimeStamp* current_time,
|
||||
const AudioBufferList* data_in, const AudioTimeStamp* time_in,
|
||||
AudioBufferList* data_out, const AudioTimeStamp* time_out,
|
||||
void* client_data)
|
||||
{ MacOSXAudioData *audio_data ;
|
||||
int size, sample_count, read_count, k ;
|
||||
float *buffer ;
|
||||
|
||||
/* Prevent compiler warnings. */
|
||||
device = device ;
|
||||
current_time = current_time ;
|
||||
data_in = data_in ;
|
||||
time_in = time_in ;
|
||||
time_out = time_out ;
|
||||
|
||||
audio_data = (MacOSXAudioData*) client_data ;
|
||||
|
||||
size = data_out->mBuffers [0].mDataByteSize ;
|
||||
sample_count = size / sizeof (float) ;
|
||||
|
||||
buffer = (float*) data_out->mBuffers [0].mData ;
|
||||
|
||||
if (audio_data->fake_stereo != 0)
|
||||
{ read_count = sf_read_float (audio_data->sndfile, buffer, sample_count / 2) ;
|
||||
|
||||
for (k = read_count - 1 ; k >= 0 ; k--)
|
||||
{ buffer [2 * k ] = buffer [k] ;
|
||||
buffer [2 * k + 1] = buffer [k] ;
|
||||
} ;
|
||||
read_count *= 2 ;
|
||||
}
|
||||
else
|
||||
read_count = sf_read_float (audio_data->sndfile, buffer, sample_count) ;
|
||||
|
||||
/* Fill the remainder with zeroes. */
|
||||
if (read_count < sample_count)
|
||||
{ if (audio_data->fake_stereo == 0)
|
||||
memset (&(buffer [read_count]), 0, (sample_count - read_count) * sizeof (float)) ;
|
||||
/* Tell the main application to terminate. */
|
||||
audio_data->done_playing = SF_TRUE ;
|
||||
} ;
|
||||
|
||||
return noErr ;
|
||||
} /* macosx_audio_out_callback */
|
||||
|
||||
static void
|
||||
macosx_play (int argc, char *argv [])
|
||||
{ MacOSXAudioData audio_data ;
|
||||
OSStatus err ;
|
||||
UInt32 count, buffer_size ;
|
||||
int k ;
|
||||
|
||||
audio_data.fake_stereo = 0 ;
|
||||
audio_data.device = kAudioDeviceUnknown ;
|
||||
|
||||
/* get the default output device for the HAL */
|
||||
count = sizeof (AudioDeviceID) ;
|
||||
if ((err = AudioHardwareGetProperty (kAudioHardwarePropertyDefaultOutputDevice,
|
||||
&count, (void *) &(audio_data.device))) != noErr)
|
||||
{ printf ("AudioHardwareGetProperty (kAudioDevicePropertyDefaultOutputDevice) failed.\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
/* get the buffersize that the default device uses for IO */
|
||||
count = sizeof (UInt32) ;
|
||||
if ((err = AudioDeviceGetProperty (audio_data.device, 0, false, kAudioDevicePropertyBufferSize,
|
||||
&count, &buffer_size)) != noErr)
|
||||
{ printf ("AudioDeviceGetProperty (kAudioDevicePropertyBufferSize) failed.\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
/* get a description of the data format used by the default device */
|
||||
count = sizeof (AudioStreamBasicDescription) ;
|
||||
if ((err = AudioDeviceGetProperty (audio_data.device, 0, false, kAudioDevicePropertyStreamFormat,
|
||||
&count, &(audio_data.format))) != noErr)
|
||||
{ printf ("AudioDeviceGetProperty (kAudioDevicePropertyStreamFormat) failed.\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
/* Base setup completed. Now play files. */
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
{ printf ("Playing %s\n", argv [k]) ;
|
||||
if (! (audio_data.sndfile = sf_open (argv [k], SFM_READ, &(audio_data.sfinfo))))
|
||||
{ puts (sf_strerror (NULL)) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (audio_data.sfinfo.channels < 1 || audio_data.sfinfo.channels > 2)
|
||||
{ printf ("Error : channels = %d.\n", audio_data.sfinfo.channels) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
audio_data.format.mSampleRate = audio_data.sfinfo.samplerate ;
|
||||
|
||||
if (audio_data.sfinfo.channels == 1)
|
||||
{ audio_data.format.mChannelsPerFrame = 2 ;
|
||||
audio_data.fake_stereo = 1 ;
|
||||
}
|
||||
else
|
||||
audio_data.format.mChannelsPerFrame = audio_data.sfinfo.channels ;
|
||||
|
||||
if ((err = AudioDeviceSetProperty (audio_data.device, NULL, 0, false, kAudioDevicePropertyStreamFormat,
|
||||
sizeof (AudioStreamBasicDescription), &(audio_data.format))) != noErr)
|
||||
{ printf ("AudioDeviceSetProperty (kAudioDevicePropertyStreamFormat) failed.\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
/* we want linear pcm */
|
||||
if (audio_data.format.mFormatID != kAudioFormatLinearPCM)
|
||||
return ;
|
||||
|
||||
/* Fire off the device. */
|
||||
if ((err = AudioDeviceAddIOProc (audio_data.device, macosx_audio_out_callback,
|
||||
(void *) &audio_data)) != noErr)
|
||||
{ printf ("AudioDeviceAddIOProc failed.\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
err = AudioDeviceStart (audio_data.device, macosx_audio_out_callback) ;
|
||||
if (err != noErr)
|
||||
return ;
|
||||
|
||||
audio_data.done_playing = SF_FALSE ;
|
||||
|
||||
while (audio_data.done_playing == SF_FALSE)
|
||||
usleep (10 * 1000) ; /* 10 000 milliseconds. */
|
||||
|
||||
if ((err = AudioDeviceStop (audio_data.device, macosx_audio_out_callback)) != noErr)
|
||||
{ printf ("AudioDeviceStop failed.\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
err = AudioDeviceRemoveIOProc (audio_data.device, macosx_audio_out_callback) ;
|
||||
if (err != noErr)
|
||||
{ printf ("AudioDeviceRemoveIOProc failed.\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
sf_close (audio_data.sndfile) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* macosx_play */
|
||||
|
||||
#endif /* MacOSX */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
** Win32 functions for playing a sound.
|
||||
**
|
||||
** This API sucks. Its needlessly complicated and is *WAY* too loose with
|
||||
** passing pointers arounf in integers and and using char* pointers to
|
||||
** point to data instead of short*. It plain sucks!
|
||||
*/
|
||||
|
||||
#if (OS_IS_WIN32 == 1)
|
||||
|
||||
#define WIN32_BUFFER_LEN (1<<15)
|
||||
|
||||
typedef struct
|
||||
{ HWAVEOUT hwave ;
|
||||
WAVEHDR whdr [2] ;
|
||||
|
||||
CRITICAL_SECTION mutex ; /* to control access to BuffersInUSe */
|
||||
HANDLE Event ; /* signal that a buffer is free */
|
||||
|
||||
short buffer [WIN32_BUFFER_LEN / sizeof (short)] ;
|
||||
int current, bufferlen ;
|
||||
int BuffersInUse ;
|
||||
|
||||
SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
|
||||
sf_count_t remaining ;
|
||||
} Win32_Audio_Data ;
|
||||
|
||||
|
||||
static void
|
||||
win32_play_data (Win32_Audio_Data *audio_data)
|
||||
{ int thisread, readcount ;
|
||||
|
||||
/* fill a buffer if there is more data and we can read it sucessfully */
|
||||
readcount = (audio_data->remaining > audio_data->bufferlen) ? audio_data->bufferlen : (int) audio_data->remaining ;
|
||||
|
||||
thisread = (int) sf_read_short (audio_data->sndfile, (short *) (audio_data->whdr [audio_data->current].lpData), readcount) ;
|
||||
|
||||
audio_data->remaining -= thisread ;
|
||||
|
||||
if (thisread > 0)
|
||||
{ /* Fix buffer length if this is only a partial block. */
|
||||
if (thisread < audio_data->bufferlen)
|
||||
audio_data->whdr [audio_data->current].dwBufferLength = thisread * sizeof (short) ;
|
||||
|
||||
/* Queue the WAVEHDR */
|
||||
waveOutWrite (audio_data->hwave, (LPWAVEHDR) &(audio_data->whdr [audio_data->current]), sizeof (WAVEHDR)) ;
|
||||
|
||||
/* count another buffer in use */
|
||||
EnterCriticalSection (&audio_data->mutex) ;
|
||||
audio_data->BuffersInUse ++ ;
|
||||
LeaveCriticalSection (&audio_data->mutex) ;
|
||||
|
||||
/* use the other buffer next time */
|
||||
audio_data->current = (audio_data->current + 1) % 2 ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* win32_play_data */
|
||||
|
||||
static void CALLBACK
|
||||
win32_audio_out_callback (HWAVEOUT hwave, UINT msg, DWORD_PTR data, DWORD param1, DWORD param2)
|
||||
{ Win32_Audio_Data *audio_data ;
|
||||
|
||||
/* Prevent compiler warnings. */
|
||||
hwave = hwave ;
|
||||
param1 = param2 ;
|
||||
|
||||
if (data == 0)
|
||||
return ;
|
||||
|
||||
/*
|
||||
** I consider this technique of passing a pointer via an integer as
|
||||
** fundamentally broken but thats the way microsoft has defined the
|
||||
** interface.
|
||||
*/
|
||||
audio_data = (Win32_Audio_Data*) data ;
|
||||
|
||||
/* let main loop know a buffer is free */
|
||||
if (msg == MM_WOM_DONE)
|
||||
{ EnterCriticalSection (&audio_data->mutex) ;
|
||||
audio_data->BuffersInUse -- ;
|
||||
LeaveCriticalSection (&audio_data->mutex) ;
|
||||
SetEvent (audio_data->Event) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* win32_audio_out_callback */
|
||||
|
||||
static void
|
||||
win32_play (int argc, char *argv [])
|
||||
{ Win32_Audio_Data audio_data ;
|
||||
|
||||
WAVEFORMATEX wf ;
|
||||
int k, error ;
|
||||
|
||||
audio_data.sndfile = NULL ;
|
||||
audio_data.hwave = 0 ;
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
{ printf ("Playing %s\n", argv [k]) ;
|
||||
|
||||
if (! (audio_data.sndfile = sf_open (argv [k], SFM_READ, &(audio_data.sfinfo))))
|
||||
{ puts (sf_strerror (NULL)) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
audio_data.remaining = audio_data.sfinfo.frames * audio_data.sfinfo.channels ;
|
||||
audio_data.current = 0 ;
|
||||
|
||||
InitializeCriticalSection (&audio_data.mutex) ;
|
||||
audio_data.Event = CreateEvent (0, FALSE, FALSE, 0) ;
|
||||
|
||||
wf.nChannels = audio_data.sfinfo.channels ;
|
||||
wf.wFormatTag = WAVE_FORMAT_PCM ;
|
||||
wf.cbSize = 0 ;
|
||||
wf.wBitsPerSample = 16 ;
|
||||
|
||||
wf.nSamplesPerSec = audio_data.sfinfo.samplerate ;
|
||||
|
||||
wf.nBlockAlign = audio_data.sfinfo.channels * sizeof (short) ;
|
||||
|
||||
wf.nAvgBytesPerSec = wf.nBlockAlign * wf.nSamplesPerSec ;
|
||||
|
||||
error = waveOutOpen (&(audio_data.hwave), WAVE_MAPPER, &wf, (DWORD_PTR) win32_audio_out_callback,
|
||||
(DWORD_PTR) &audio_data, CALLBACK_FUNCTION) ;
|
||||
if (error)
|
||||
{ puts ("waveOutOpen failed.") ;
|
||||
audio_data.hwave = 0 ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
audio_data.whdr [0].lpData = (char*) audio_data.buffer ;
|
||||
audio_data.whdr [1].lpData = ((char*) audio_data.buffer) + sizeof (audio_data.buffer) / 2 ;
|
||||
|
||||
audio_data.whdr [0].dwBufferLength = sizeof (audio_data.buffer) / 2 ;
|
||||
audio_data.whdr [1].dwBufferLength = sizeof (audio_data.buffer) / 2 ;
|
||||
|
||||
audio_data.whdr [0].dwFlags = 0 ;
|
||||
audio_data.whdr [1].dwFlags = 0 ;
|
||||
|
||||
/* length of each audio buffer in samples */
|
||||
audio_data.bufferlen = sizeof (audio_data.buffer) / 2 / sizeof (short) ;
|
||||
|
||||
/* Prepare the WAVEHDRs */
|
||||
if ((error = waveOutPrepareHeader (audio_data.hwave, &(audio_data.whdr [0]), sizeof (WAVEHDR))))
|
||||
{ printf ("waveOutPrepareHeader [0] failed : %08X\n", error) ;
|
||||
waveOutClose (audio_data.hwave) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if ((error = waveOutPrepareHeader (audio_data.hwave, &(audio_data.whdr [1]), sizeof (WAVEHDR))))
|
||||
{ printf ("waveOutPrepareHeader [1] failed : %08X\n", error) ;
|
||||
waveOutUnprepareHeader (audio_data.hwave, &(audio_data.whdr [0]), sizeof (WAVEHDR)) ;
|
||||
waveOutClose (audio_data.hwave) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
/* Fill up both buffers with audio data */
|
||||
audio_data.BuffersInUse = 0 ;
|
||||
win32_play_data (&audio_data) ;
|
||||
win32_play_data (&audio_data) ;
|
||||
|
||||
/* loop until both buffers are released */
|
||||
while (audio_data.BuffersInUse > 0)
|
||||
{
|
||||
/* wait for buffer to be released */
|
||||
WaitForSingleObject (audio_data.Event, INFINITE) ;
|
||||
|
||||
/* refill the buffer if there is more data to play */
|
||||
win32_play_data (&audio_data) ;
|
||||
} ;
|
||||
|
||||
waveOutUnprepareHeader (audio_data.hwave, &(audio_data.whdr [0]), sizeof (WAVEHDR)) ;
|
||||
waveOutUnprepareHeader (audio_data.hwave, &(audio_data.whdr [1]), sizeof (WAVEHDR)) ;
|
||||
|
||||
waveOutClose (audio_data.hwave) ;
|
||||
audio_data.hwave = 0 ;
|
||||
|
||||
DeleteCriticalSection (&audio_data.mutex) ;
|
||||
|
||||
sf_close (audio_data.sndfile) ;
|
||||
} ;
|
||||
|
||||
} /* win32_play */
|
||||
|
||||
#endif /* Win32 */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
** Solaris.
|
||||
*/
|
||||
|
||||
#if (defined (sun) && defined (unix)) /* ie Solaris */
|
||||
|
||||
static void
|
||||
solaris_play (int argc, char *argv [])
|
||||
{ static short buffer [BUFFER_LEN] ;
|
||||
audio_info_t audio_info ;
|
||||
SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
unsigned long delay_time ;
|
||||
long k, start_count, output_count, write_count, read_count ;
|
||||
int audio_fd, error, done ;
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
{ printf ("Playing %s\n", argv [k]) ;
|
||||
if (! (sndfile = sf_open (argv [k], SFM_READ, &sfinfo)))
|
||||
{ puts (sf_strerror (NULL)) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (sfinfo.channels < 1 || sfinfo.channels > 2)
|
||||
{ printf ("Error : channels = %d.\n", sfinfo.channels) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
/* open the audio device - write only, non-blocking */
|
||||
if ((audio_fd = open ("/dev/audio", O_WRONLY | O_NONBLOCK)) < 0)
|
||||
{ perror ("open (/dev/audio) failed") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
/* Retrive standard values. */
|
||||
AUDIO_INITINFO (&audio_info) ;
|
||||
|
||||
audio_info.play.sample_rate = sfinfo.samplerate ;
|
||||
audio_info.play.channels = sfinfo.channels ;
|
||||
audio_info.play.precision = 16 ;
|
||||
audio_info.play.encoding = AUDIO_ENCODING_LINEAR ;
|
||||
audio_info.play.gain = AUDIO_MAX_GAIN ;
|
||||
audio_info.play.balance = AUDIO_MID_BALANCE ;
|
||||
|
||||
if ((error = ioctl (audio_fd, AUDIO_SETINFO, &audio_info)))
|
||||
{ perror ("ioctl (AUDIO_SETINFO) failed") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
/* Delay time equal to 1/4 of a buffer in microseconds. */
|
||||
delay_time = (BUFFER_LEN * 1000000) / (audio_info.play.sample_rate * 4) ;
|
||||
|
||||
done = 0 ;
|
||||
while (! done)
|
||||
{ read_count = sf_read_short (sndfile, buffer, BUFFER_LEN) ;
|
||||
if (read_count < BUFFER_LEN)
|
||||
{ memset (&(buffer [read_count]), 0, (BUFFER_LEN - read_count) * sizeof (short)) ;
|
||||
/* Tell the main application to terminate. */
|
||||
done = SF_TRUE ;
|
||||
} ;
|
||||
|
||||
start_count = 0 ;
|
||||
output_count = BUFFER_LEN * sizeof (short) ;
|
||||
|
||||
while (output_count > 0)
|
||||
{ /* write as much data as possible */
|
||||
write_count = write (audio_fd, &(buffer [start_count]), output_count) ;
|
||||
if (write_count > 0)
|
||||
{ output_count -= write_count ;
|
||||
start_count += write_count ;
|
||||
}
|
||||
else
|
||||
{ /* Give the audio output time to catch up. */
|
||||
usleep (delay_time) ;
|
||||
} ;
|
||||
} ; /* while (outpur_count > 0) */
|
||||
} ; /* while (! done) */
|
||||
|
||||
close (audio_fd) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* solaris_play */
|
||||
|
||||
#endif /* Solaris */
|
||||
|
||||
/*==============================================================================
|
||||
** Main function.
|
||||
*/
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
if (argc < 2)
|
||||
{
|
||||
printf ("\nUsage : %s <input sound file>\n\n", argv [0]) ;
|
||||
#if (OS_IS_WIN32 == 1)
|
||||
printf ("This is a Unix style command line application which\n"
|
||||
"should be run in a MSDOS box or Command Shell window.\n\n") ;
|
||||
printf ("Sleeping for 5 seconds before exiting.\n\n") ;
|
||||
|
||||
/* This is the officially blessed by microsoft way but I can't get
|
||||
** it to link.
|
||||
** Sleep (15) ;
|
||||
** Instead, use this:
|
||||
*/
|
||||
Sleep (5 * 1000) ;
|
||||
#endif
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
#if defined (__linux__)
|
||||
#if HAVE_ALSA_ASOUNDLIB_H
|
||||
if (access ("/proc/asound/cards", R_OK) == 0)
|
||||
alsa_play (argc, argv) ;
|
||||
else
|
||||
#endif
|
||||
linux_play (argc, argv) ;
|
||||
#elif (defined (__MACH__) && defined (__APPLE__))
|
||||
macosx_play (argc, argv) ;
|
||||
#elif (defined (sun) && defined (unix))
|
||||
solaris_play (argc, argv) ;
|
||||
#elif (OS_IS_WIN32 == 1)
|
||||
win32_play (argc, argv) ;
|
||||
#elif defined (__BEOS__)
|
||||
printf ("This program cannot be compiled on BeOS.\n") ;
|
||||
printf ("Instead, compile the file sfplay_beos.cpp.\n") ;
|
||||
return 1 ;
|
||||
#else
|
||||
puts ("*** Playing sound not yet supported on this platform.") ;
|
||||
puts ("*** Please feel free to submit a patch.") ;
|
||||
return 1 ;
|
||||
#endif
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
187
lib-src/libsndfile/programs/test-sndfile-metadata-set.py
Executable file
187
lib-src/libsndfile/programs/test-sndfile-metadata-set.py
Executable file
@@ -0,0 +1,187 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# Copyright (C) 2008 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# * Neither the author nor the names of any contributors may be used
|
||||
# to endorse or promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# Simple test script for the sndfile-metadata-set program.
|
||||
|
||||
import commands, os, sys
|
||||
import time, datetime
|
||||
|
||||
def print_test_name (name):
|
||||
print " %-30s :" % name,
|
||||
|
||||
def assert_info (filename, arg, value):
|
||||
cmd = "./sndfile-metadata-get %s %s" % (arg, filename)
|
||||
status, output = commands.getstatusoutput (cmd)
|
||||
if status:
|
||||
print "\n\nError : command '%s' should not have failed." % cmd
|
||||
sys.exit (1)
|
||||
if output.find (value) < 0:
|
||||
print "\n\nError : not able to find '%s'." % value
|
||||
print output
|
||||
sys.exit (1)
|
||||
return
|
||||
|
||||
|
||||
def check_executable (name):
|
||||
if not (os.path.isfile (name)):
|
||||
print "\n\nError : Can't find executable '%s'. Have you run make?" % name
|
||||
sys.exit (1)
|
||||
|
||||
def test_empty_fail ():
|
||||
print_test_name ("Empty fail test")
|
||||
cmd = "./sndfile-metadata-set --bext-description Alpha sine.wav"
|
||||
status, output = commands.getstatusoutput (cmd)
|
||||
if not status:
|
||||
print "\n\nError : command '%s' should have failed." % cmd
|
||||
sys.exit (1)
|
||||
print "ok"
|
||||
|
||||
def test_copy ():
|
||||
print_test_name ("Copy test")
|
||||
cmd = "./sndfile-metadata-set --bext-description \"First Try\" sine.wav output.wav"
|
||||
status, output = commands.getstatusoutput (cmd)
|
||||
if status:
|
||||
print "\n\nError : command '%s' should not have failed." % cmd
|
||||
sys.exit (1)
|
||||
assert_info ("output.wav", "--bext-description", "First Try")
|
||||
print "ok"
|
||||
|
||||
def test_update (tests):
|
||||
print_test_name ("Update test")
|
||||
for arg, value in tests:
|
||||
cmd = "./sndfile-metadata-set %s \"%s\" output.wav" % (arg, value)
|
||||
status, output = commands.getstatusoutput (cmd)
|
||||
if status:
|
||||
print "\n\nError : command '%s' should not have failed." % cmd
|
||||
sys.exit (1)
|
||||
assert_info ("output.wav", arg, value)
|
||||
print "ok"
|
||||
|
||||
def test_post_mod (tests):
|
||||
print_test_name ("Post mod test")
|
||||
for arg, value in tests:
|
||||
assert_info ("output.wav", arg, value)
|
||||
print "ok"
|
||||
|
||||
def test_auto_date ():
|
||||
print_test_name ("Auto date test")
|
||||
cmd = "./sndfile-metadata-set --bext-auto-time-date sine.wav date-time.wav"
|
||||
status, output = commands.getstatusoutput (cmd)
|
||||
if status:
|
||||
print "\n\nError : command '%s' should not have failed." % cmd
|
||||
sys.exit (1)
|
||||
target = datetime.date.today ().__str__ ()
|
||||
assert_info ("date-time.wav", "--bext-orig-date", target)
|
||||
print "ok"
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
def test_coding_history ():
|
||||
print_test_name ("Coding history test")
|
||||
cmd = "./sndfile-metadata-set --bext-coding-hist \"alpha beta\" output.wav"
|
||||
status, output = commands.getstatusoutput (cmd)
|
||||
if status:
|
||||
print "\n\nError : command '%s' should not have failed." % cmd
|
||||
sys.exit (1)
|
||||
cmd = "./sndfile-metadata-get --bext-coding-hist output.wav"
|
||||
status, output = commands.getstatusoutput (cmd)
|
||||
if status:
|
||||
print "\n\nError : command '%s' should not have failed." % cmd
|
||||
sys.exit (1)
|
||||
print "ok"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
def test_rewrite ():
|
||||
print_test_name ("Rewrite test")
|
||||
cmd = "./sndfile-metadata-set --bext-originator \"Really, really long string\" output.wav"
|
||||
status, output = commands.getstatusoutput (cmd)
|
||||
if status:
|
||||
print "\n\nError : command '%s' should not have failed." % cmd
|
||||
sys.exit (1)
|
||||
cmd = "./sndfile-metadata-set --bext-originator \"Short\" output.wav"
|
||||
status, output = commands.getstatusoutput (cmd)
|
||||
if status:
|
||||
print "\n\nError : command '%s' should not have failed." % cmd
|
||||
sys.exit (1)
|
||||
cmd = "./sndfile-metadata-get --bext-originator output.wav"
|
||||
status, output = commands.getstatusoutput (cmd)
|
||||
if status:
|
||||
print "\n\nError : command '%s' should not have failed." % cmd
|
||||
sys.exit (1)
|
||||
if output.find ("really long") > 0:
|
||||
print "\n\nError : output '%s' should not contain 'really long'." % output
|
||||
sys.exit (1)
|
||||
print "ok"
|
||||
|
||||
#===============================================================================
|
||||
|
||||
test_dir = "programs"
|
||||
|
||||
if os.path.isdir (test_dir):
|
||||
os.chdir (test_dir)
|
||||
|
||||
for f in [ "sndfile-metadata-set", "sndfile-metadata-get", "../examples/make_sine" ]:
|
||||
check_executable (f)
|
||||
|
||||
os.system ("../examples/make_sine")
|
||||
if not os.path.isfile ("sine.wav"):
|
||||
print "\n\nError : Can't file file 'sine.wav'."
|
||||
sys.exit (1)
|
||||
|
||||
print ""
|
||||
|
||||
test_empty_fail ()
|
||||
test_copy ()
|
||||
|
||||
tests = [
|
||||
("--bext-description", "Alpha"), ("--bext-originator", "Beta"), ("--bext-orig-ref", "Charlie"),
|
||||
("--bext-umid", "Delta"), ("--bext-orig-date", "2001-10-01"), ("--bext-orig-time", "01:02:03"),
|
||||
("--str-title", "Echo"), ("--str-artist", "Fox trot")
|
||||
]
|
||||
|
||||
test_auto_date ()
|
||||
test_update (tests)
|
||||
test_post_mod (tests)
|
||||
|
||||
test_update ([ ("--str-artist", "Fox") ])
|
||||
|
||||
test_coding_history ()
|
||||
|
||||
test_rewrite ()
|
||||
|
||||
|
||||
print ""
|
||||
|
||||
sys.exit (0)
|
||||
|
||||
Reference in New Issue
Block a user