mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-23 09:59:54 +00:00
Merge from -dev.
This commit is contained in:
commit
ea62c5083d
@ -57,7 +57,9 @@ mntest.sh
|
||||
programs/sndfile-cmp
|
||||
programs/sndfile-convert
|
||||
programs/sndfile-data-trim
|
||||
programs/sndfile-deinterleave
|
||||
programs/sndfile-info
|
||||
programs/sndfile-interleave
|
||||
programs/sndfile-jackplay
|
||||
programs/sndfile-metadata-get
|
||||
programs/sndfile-metadata-set
|
||||
@ -96,3 +98,4 @@ tests/test_wrapper.sh
|
||||
tests/utils.c
|
||||
tests/utils.h
|
||||
tests/write_read_test.c
|
||||
programs/sndfile-concat
|
||||
|
103
ChangeLog
103
ChangeLog
@ -1,3 +1,106 @@
|
||||
2009-12-09 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* programs/sndfile-jackplay.c man/sndfile-jackplay.1
|
||||
Remove these which will now be in found in the sndfile-tools package.
|
||||
|
||||
* programs/Makefile.am man/Makefile.am
|
||||
Remove build rules for sndfile-jackplay.
|
||||
|
||||
* configure.ac
|
||||
Remove detection of JACK Audio Connect Kit.
|
||||
|
||||
* programs/sndfile-concat.c man/sndfile-concat.1
|
||||
Add new program with man page.
|
||||
|
||||
* man/Makefile.am programs/Makefile.am
|
||||
Hook sndfile-concat into build system.
|
||||
|
||||
2009-12-08 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* tests/error_test.c
|
||||
Don't terminate when sf_close() returns zero in error_close_test().
|
||||
It seems that Windows 7 behaves differently from earlier versions of
|
||||
Windows.
|
||||
|
||||
2009-12-03 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* configure.ac M4/*.m4
|
||||
Rename all custom macros from AC_* to MN_*.
|
||||
|
||||
* programs/sndfile-interleave.c
|
||||
Make it actually work.
|
||||
|
||||
2009-12-02 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* doc/*.html configure.ac
|
||||
Corrections and clarifications courtesy of Robin Forder.
|
||||
|
||||
* programs/sndfile-convert.c programs/common.[ch]
|
||||
Move some code from convert to common for reuse.
|
||||
|
||||
* programs/sndfile-interleave.c programs/sndfile-interleave.c
|
||||
Add new programs sndfile-interleave and sndfile-deinterleave.
|
||||
|
||||
* programs/Makefile.am
|
||||
Hook new programs into build.
|
||||
|
||||
2009-12-01 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* src/create_symbols_file.py tests/stdio_test.c tests/win32_test.c
|
||||
Minor OS/2 tweaks as suggested by David Yeo.
|
||||
|
||||
* tests/multi_file_test.c
|
||||
Fix file creation flags on windows. Thanks to Bruce Sharpe.
|
||||
|
||||
* src/sf_unistd.h
|
||||
Set all group and other file create permssions to zero.
|
||||
|
||||
* tests/win32_test.c
|
||||
Add a new test.
|
||||
|
||||
2009-11-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* doc/print.css doc/*.html
|
||||
Add a print stylesheet and update all HTML documents to reference it.
|
||||
Thanks to Aditya Bhargava for suggesting this.
|
||||
|
||||
* doc/index.html
|
||||
Minor corrections.
|
||||
|
||||
2009-11-29 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* sndfile.pc.in
|
||||
Add a Libs.private entry to assist with static linking.
|
||||
|
||||
2009-11-28 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* src/make-static-lib-hidden-privates.sh src/Makefile.am
|
||||
Add a script to hide all non-public symbols in the libsndfile.a static
|
||||
library.
|
||||
|
||||
2009-11-22 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* tests/locale_test.c
|
||||
Correct usage of ENABLE_SNDFILE_WINDOWS_PROTOTYPES.
|
||||
|
||||
2009-11-20 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* src/windows.c
|
||||
Correct usage of ENABLE_SNDFILE_WINDOWS_PROTOTYPES.
|
||||
|
||||
2009-11-16 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* programs/sndfile-convert.c
|
||||
Allow the program to read from stdin by specifying '-' on the command line
|
||||
as the input file.
|
||||
|
||||
* src/sndfile.h.in
|
||||
Hash define ENABLE_SNDFILE_WINDOWS_PROTOTYPES to 1 for greater safety.
|
||||
|
||||
* tests/virtual_io_test.c
|
||||
Add a PAF/PCM_24 test and verify the file length is not negative
|
||||
immediately after openning the file for write.
|
||||
|
||||
2009-10-18 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* src/wav.c
|
||||
|
@ -1,8 +1,8 @@
|
||||
dnl @synopsis AC_ADD_CFLAGS
|
||||
dnl @synopsis MN_ADD_CFLAGS
|
||||
dnl
|
||||
dnl Add the given option to CFLAGS, if it doesn't break the compiler
|
||||
|
||||
AC_DEFUN([AC_ADD_CFLAGS],
|
||||
AC_DEFUN([MN_ADD_CFLAGS],
|
||||
[AC_MSG_CHECKING([if $CC accepts $1])
|
||||
ac_add_cflags__old_cflags="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $1"
|
||||
@ -14,4 +14,4 @@ AC_DEFUN([AC_ADD_CFLAGS],
|
||||
AC_MSG_RESULT([no])
|
||||
CFLAGS="$ac_add_cflags__old_cflags"
|
||||
)
|
||||
])# AC_ADD_CFLAGS
|
||||
])# MN_ADD_CFLAGS
|
||||
|
@ -1,8 +1,8 @@
|
||||
dnl @synopsis AC_ADD_CXXFLAGS
|
||||
dnl @synopsis MN_ADD_CXXFLAGS
|
||||
dnl
|
||||
dnl Add the given option to CXXFLAGS, if it doesn't break the compiler
|
||||
|
||||
AC_DEFUN([AC_ADD_CXXFLAGS],
|
||||
AC_DEFUN([MN_ADD_CXXFLAGS],
|
||||
[AC_MSG_CHECKING([if $CXX accepts $1])
|
||||
ac_add_cxxflags__old_cxxflags="$CXXFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS $1"
|
||||
@ -14,4 +14,4 @@ AC_DEFUN([AC_ADD_CXXFLAGS],
|
||||
AC_MSG_RESULT([no])
|
||||
CXXFLAGS="$ac_add_cxxflags__old_cxxflags"
|
||||
)
|
||||
])# AC_ADD_CXXFLAGS
|
||||
])# MN_ADD_CXXFLAGS
|
||||
|
@ -1,4 +1,4 @@
|
||||
dnl @synopsis AC_C_CLIP_MODE
|
||||
dnl @synopsis MN_C_CLIP_MODE
|
||||
dnl
|
||||
dnl Determine the clipping mode when converting float to int.
|
||||
dnl @version 1.0 May 17 2003
|
||||
@ -20,7 +20,7 @@ dnl Find the clipping mode in the following way:
|
||||
dnl 1) If we are not cross compiling test it.
|
||||
dnl 2) IF we are cross compiling, assume that clipping isn't done correctly.
|
||||
|
||||
AC_DEFUN([AC_C_CLIP_MODE],
|
||||
AC_DEFUN([MN_C_CLIP_MODE],
|
||||
[AC_CACHE_CHECK(processor clipping capabilities,
|
||||
ac_cv_c_clip_type,
|
||||
|
||||
@ -119,6 +119,6 @@ case "$ac_cv_c_clip_positive$ac_cv_c_clip_negative" in
|
||||
)
|
||||
]
|
||||
|
||||
)# AC_C_CLIP_MODE
|
||||
)# MN_C_CLIP_MODE
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
dnl @synopsis AC_C_FIND_ENDIAN
|
||||
dnl @synopsis MN_C_FIND_ENDIAN
|
||||
dnl
|
||||
dnl Determine endian-ness of target processor.
|
||||
dnl @version 1.1 Mar 03 2002
|
||||
@ -20,7 +20,7 @@ dnl 2) If 1) fails, look in <sys/types.h> and <sys/param.h>.
|
||||
dnl 3) If 1) and 2) fails and not cross compiling run a test program.
|
||||
dnl 4) If 1) and 2) fails and cross compiling then guess based on target.
|
||||
|
||||
AC_DEFUN([AC_C_FIND_ENDIAN],
|
||||
AC_DEFUN([MN_C_FIND_ENDIAN],
|
||||
[AC_CACHE_CHECK(processor byte ordering,
|
||||
ac_cv_c_byte_order,
|
||||
|
||||
@ -150,6 +150,6 @@ else
|
||||
fi
|
||||
|
||||
]
|
||||
)# AC_C_FIND_ENDIAN
|
||||
)# MN_C_FIND_ENDIAN
|
||||
|
||||
|
||||
|
@ -6,8 +6,8 @@ dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
|
||||
dnl Written by Paul Eggert <eggert@twinsun.com>.
|
||||
|
||||
dnl Internal subroutine of AC_SYS_EXTRA_LARGEFILE.
|
||||
dnl AC_SYS_EXTRA_LARGEFILE_FLAGS(FLAGSNAME)
|
||||
AC_DEFUN([AC_SYS_EXTRA_LARGEFILE_FLAGS],
|
||||
dnl MN_SYS_EXTRA_LARGEFILE_FLAGS(FLAGSNAME)
|
||||
AC_DEFUN([MN_SYS_EXTRA_LARGEFILE_FLAGS],
|
||||
[AC_CACHE_CHECK([for $1 value to request large file support],
|
||||
ac_cv_sys_largefile_$1,
|
||||
[ac_cv_sys_largefile_$1=`($GETCONF LFS_$1) 2>/dev/null` || {
|
||||
@ -67,9 +67,9 @@ AC_DEFUN([AC_SYS_EXTRA_LARGEFILE],
|
||||
[ --disable-largefile omit support for large files])
|
||||
if test "$enable_largefile" != no; then
|
||||
AC_CHECK_TOOL(GETCONF, getconf)
|
||||
AC_SYS_EXTRA_LARGEFILE_FLAGS(CFLAGS)
|
||||
AC_SYS_EXTRA_LARGEFILE_FLAGS(LDFLAGS)
|
||||
AC_SYS_EXTRA_LARGEFILE_FLAGS(LIBS)
|
||||
MN_SYS_EXTRA_LARGEFILE_FLAGS(CFLAGS)
|
||||
MN_SYS_EXTRA_LARGEFILE_FLAGS(LDFLAGS)
|
||||
MN_SYS_EXTRA_LARGEFILE_FLAGS(LIBS)
|
||||
|
||||
for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
|
||||
case "$ac_flag" in
|
||||
|
@ -1,4 +1,4 @@
|
||||
dnl @synopsis AC_C99_FLEXIBLE_ARRAY
|
||||
dnl @synopsis MN_C99_FLEXIBLE_ARRAY
|
||||
dnl
|
||||
dnl Dose the compiler support the 1999 ISO C Standard "stuct hack".
|
||||
dnl @version 1.1 Mar 15 2004
|
||||
@ -10,7 +10,7 @@ dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
|
||||
AC_DEFUN([AC_C99_FLEXIBLE_ARRAY],
|
||||
AC_DEFUN([MN_C99_FLEXIBLE_ARRAY],
|
||||
[AC_CACHE_CHECK(C99 struct flexible array support,
|
||||
ac_cv_c99_flexible_array,
|
||||
|
||||
@ -28,5 +28,5 @@ AC_TRY_LINK([[
|
||||
ac_cv_c99_flexible_array=yes,
|
||||
ac_cv_c99_flexible_array=no
|
||||
))]
|
||||
) # AC_C99_FLEXIBLE_ARRAY
|
||||
) # MN_C99_FLEXIBLE_ARRAY
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
dnl @synopsis AC_GCC_VERSION
|
||||
dnl @synopsis MN_GCC_VERSION
|
||||
dnl
|
||||
dnl Find the version of gcc.
|
||||
dnl @version 1.0 Nov 05 2007
|
||||
@ -11,7 +11,7 @@ dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
dnl
|
||||
|
||||
AC_DEFUN([AC_GCC_VERSION],
|
||||
AC_DEFUN([MN_GCC_VERSION],
|
||||
[
|
||||
if test "x$ac_cv_c_compiler_gnu" = "xyes" ; then
|
||||
|
||||
@ -29,5 +29,5 @@ AC_SUBST(GCC_VERSION)
|
||||
AC_SUBST(GCC_MAJOR_VERSION)
|
||||
AC_SUBST(GCC_MINOR_VERSION)
|
||||
|
||||
])# AC_GCC_VERSION
|
||||
])# MN_GCC_VERSION
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
dnl @synopsis AC_C99_FUNC_LLRINT
|
||||
dnl @synopsis MN_C99_FUNC_LLRINT
|
||||
dnl
|
||||
dnl Check whether C99's llrint function is available.
|
||||
dnl @version 1.1 Sep 30 2002
|
||||
@ -10,7 +10,7 @@ dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
dnl
|
||||
AC_DEFUN([AC_C99_FUNC_LLRINT],
|
||||
AC_DEFUN([MN_C99_FUNC_LLRINT],
|
||||
[AC_CACHE_CHECK(for llrint,
|
||||
ac_cv_c99_llrint,
|
||||
[
|
||||
@ -34,5 +34,5 @@ if test "$ac_cv_c99_llrint" = yes; then
|
||||
AC_DEFINE(HAVE_LLRINT, 1,
|
||||
[Define if you have C99's llrint function.])
|
||||
fi
|
||||
])# AC_C99_FUNC_LLRINT
|
||||
])# MN_C99_FUNC_LLRINT
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
dnl @synopsis AC_C99_FUNC_LRINT
|
||||
dnl @synopsis MN_C99_FUNC_LRINT
|
||||
dnl
|
||||
dnl Check whether C99's lrint function is available.
|
||||
dnl @version 1.3 Feb 12 2002
|
||||
@ -10,7 +10,7 @@ dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
dnl
|
||||
AC_DEFUN([AC_C99_FUNC_LRINT],
|
||||
AC_DEFUN([MN_C99_FUNC_LRINT],
|
||||
[AC_CACHE_CHECK(for lrint,
|
||||
ac_cv_c99_lrint,
|
||||
[
|
||||
@ -33,5 +33,5 @@ if test "$ac_cv_c99_lrint" = yes; then
|
||||
AC_DEFINE(HAVE_LRINT, 1,
|
||||
[Define if you have C99's lrint function.])
|
||||
fi
|
||||
])# AC_C99_FUNC_LRINT
|
||||
])# MN_C99_FUNC_LRINT
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
dnl @synopsis AC_C99_FUNC_LRINTF
|
||||
dnl @synopsis MN_C99_FUNC_LRINTF
|
||||
dnl
|
||||
dnl Check whether C99's lrintf function is available.
|
||||
dnl @version 1.3 Feb 12 2002
|
||||
@ -10,7 +10,7 @@ dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
dnl
|
||||
AC_DEFUN([AC_C99_FUNC_LRINTF],
|
||||
AC_DEFUN([MN_C99_FUNC_LRINTF],
|
||||
[AC_CACHE_CHECK(for lrintf,
|
||||
ac_cv_c99_lrintf,
|
||||
[
|
||||
@ -33,5 +33,5 @@ if test "$ac_cv_c99_lrintf" = yes; then
|
||||
AC_DEFINE(HAVE_LRINTF, 1,
|
||||
[Define if you have C99's lrintf function.])
|
||||
fi
|
||||
])# AC_C99_FUNC_LRINTF
|
||||
])# MN_C99_FUNC_LRINTF
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
dnl @synopsis AC_MKOCTFILE_VERSION
|
||||
dnl @synopsis OCTAVE_MKOCTFILE_VERSION
|
||||
dnl
|
||||
dnl Find the version of mkoctfile.
|
||||
dnl @version 1.0 Aug 23 2007
|
||||
@ -11,7 +11,7 @@ dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
dnl
|
||||
|
||||
AC_DEFUN([AC_MKOCTFILE_VERSION],
|
||||
AC_DEFUN([OCTAVE_MKOCTFILE_VERSION],
|
||||
[
|
||||
|
||||
|
||||
@ -34,5 +34,5 @@ if test "x$ac_cv_prog_HAVE_MKOCTFILE" = "xyes" ; then
|
||||
AC_SUBST(MKOCTFILE)
|
||||
AC_SUBST(MKOCTFILE_VERSION)
|
||||
|
||||
])# AC_MKOCTFILE_VERSION
|
||||
])# OCTAVE_MKOCTFILE_VERSION
|
||||
|
||||
|
@ -102,7 +102,7 @@ dnl Default to no.
|
||||
OCTAVE_BUILD=no
|
||||
|
||||
AC_OCTAVE_VERSION
|
||||
AC_MKOCTFILE_VERSION
|
||||
OCTAVE_MKOCTFILE_VERSION
|
||||
AC_OCTAVE_CONFIG_VERSION
|
||||
|
||||
prog_concat="$ac_cv_prog_HAVE_OCTAVE$ac_cv_prog_HAVE_OCTAVE_CONFIG$ac_cv_prog_HAVE_MKOCTFILE"
|
||||
|
@ -19,7 +19,7 @@ TARBALL = $(TESTNAME).tar.gz
|
||||
# Find the test programs by grepping the script for the programs it executes.
|
||||
testprogs := $(shell grep '^\./' tests/test_wrapper.sh | sed -e "s|./||" -e "s/ .*//" | sort | uniq)
|
||||
# Also add the programs not found by the above.
|
||||
testprogs += sfversion@EXEEXT@ stdin_test@EXEEXT@ stdout_test@EXEEXT@
|
||||
testprogs += sfversion@EXEEXT@ stdin_test@EXEEXT@ stdout_test@EXEEXT@ cpp_test@EXEEXT@ win32_test@EXEEXT@
|
||||
|
||||
# Find the single test program in src/ .
|
||||
srcprogs := $(shell if test -x src/.libs/test_main$(EXEEXT) ; then echo "src/.libs/test_main$(EXEEXT)" ; else echo "src/test_main$(EXEEXT)" ; fi)
|
||||
|
58
configure.ac
58
configure.ac
@ -3,7 +3,7 @@
|
||||
dnl Require autoconf version
|
||||
AC_PREREQ(2.57)
|
||||
|
||||
AC_INIT([libsndfile],[1.0.21pre1],[erikd@mega-nerd.com])
|
||||
AC_INIT([libsndfile],[1.0.21pre4],[erikd@mega-nerd.com])
|
||||
|
||||
# Put config stuff in Cfg.
|
||||
AC_CONFIG_AUX_DIR(Cfg)
|
||||
@ -76,7 +76,7 @@ AM_CONDITIONAL([LINUX_MINGW_CROSS_TEST],
|
||||
#====================================================================================
|
||||
# Check for support of the struct hack.
|
||||
|
||||
AC_C99_FLEXIBLE_ARRAY
|
||||
MN_C99_FLEXIBLE_ARRAY
|
||||
|
||||
if test x$ac_cv_c99_flexible_array = xyes ; then
|
||||
AC_DEFINE([HAVE_FLEXIBLE_ARRAY],1, [Set to 1 if the compile supports the struct hack.])
|
||||
@ -121,9 +121,6 @@ AC_ARG_ENABLE(bow-docs,
|
||||
AC_ARG_ENABLE(sqlite,
|
||||
AC_HELP_STRING([--disable-sqlite], [disable use of sqlite]))
|
||||
|
||||
AC_ARG_ENABLE(jack,
|
||||
AC_HELP_STRING([--disable-jack], [disable use of JACK]))
|
||||
|
||||
AC_ARG_ENABLE(alsa,
|
||||
AC_HELP_STRING([--disable-alsa], [disable use of ALSA]))
|
||||
|
||||
@ -246,7 +243,7 @@ AC_CHECK_SIZEOF(ssize_t,4)
|
||||
#====================================================================================
|
||||
# Determine endian-ness of target processor.
|
||||
|
||||
AC_C_FIND_ENDIAN
|
||||
MN_C_FIND_ENDIAN
|
||||
|
||||
AC_DEFINE_UNQUOTED(CPU_IS_BIG_ENDIAN, ${ac_cv_c_big_endian},
|
||||
[Target processor is big endian.])
|
||||
@ -269,8 +266,8 @@ AC_CHECK_FUNCS(setlocale)
|
||||
AC_CHECK_LIB([m],floor)
|
||||
AC_CHECK_FUNCS(floor ceil fmod)
|
||||
|
||||
AC_C99_FUNC_LRINT
|
||||
AC_C99_FUNC_LRINTF
|
||||
MN_C99_FUNC_LRINT
|
||||
MN_C99_FUNC_LRINTF
|
||||
|
||||
#====================================================================================
|
||||
# Check for requirements for building plugins for other languages/enviroments.
|
||||
@ -319,9 +316,9 @@ if test x$ac_cv_flac$ac_cv_ogg$ac_cv_vorbis$ac_cv_vorbisenc = "xyesyesyesyes" ;
|
||||
else
|
||||
AC_MSG_WARN([[
|
||||
|
||||
*** One or more of the external libraries (ie Flac, Ogg, Vorbis,
|
||||
*** etc), but one or more of those libs is either missing (possibly
|
||||
*** only the development headers) or is of an unsupported version.
|
||||
*** One or more of the external libraries (ie libflac, libogg and
|
||||
*** libvorbis) is either missing (possibly only the development
|
||||
*** headers) or is of an unsupported version.
|
||||
***
|
||||
*** Unfortunately, for ease of maintenance, the external libs
|
||||
*** are an all or nothing affair.
|
||||
@ -347,28 +344,11 @@ else
|
||||
|
||||
AC_DEFINE_UNQUOTED([HAVE_SQLITE3],$HAVE_SQLITE3,[Set to 1 if you have libsqlite3.])
|
||||
|
||||
#====================================================================================
|
||||
# Check for JACK (only used for examples/sndfile-jackplay).
|
||||
|
||||
ac_cv_jack=no
|
||||
if test x$enable_jack != xno ; then
|
||||
PKG_CHECK_MOD_VERSION(JACK, jack >= 0.100, ac_cv_jack=yes, ac_cv_jack=no)
|
||||
fi
|
||||
|
||||
|
||||
if test x$ac_cv_jack = "xyes" ; then
|
||||
HAVE_JACK=1
|
||||
else
|
||||
HAVE_JACK=0
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED([HAVE_JACK],$HAVE_JACK,[Set to 1 if you have JACK.])
|
||||
|
||||
#====================================================================================
|
||||
# Determine if the processor can do clipping on float to int conversions.
|
||||
|
||||
if test x$enable_cpu_clip != "xno" ; then
|
||||
AC_C_CLIP_MODE
|
||||
MN_C_CLIP_MODE
|
||||
else
|
||||
echo "checking processor clipping capabilities... disabled"
|
||||
ac_cv_c_clip_positive=0
|
||||
@ -485,9 +465,9 @@ win32_target_dll=0
|
||||
COMPILER_IS_GCC=0
|
||||
|
||||
if test x$ac_cv_c_compiler_gnu = xyes ; then
|
||||
AC_ADD_CFLAGS(-std=gnu99)
|
||||
MN_ADD_CFLAGS(-std=gnu99)
|
||||
|
||||
AC_GCC_VERSION
|
||||
MN_GCC_VERSION
|
||||
|
||||
if test "x$GCC_MAJOR_VERSION$GCC_MINOR_VERSION" = "x42" ; then
|
||||
AC_MSG_WARN([****************************************************************])
|
||||
@ -496,21 +476,21 @@ if test x$ac_cv_c_compiler_gnu = xyes ; then
|
||||
AC_MSG_WARN([** See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33995 **])
|
||||
AC_MSG_WARN([** Using -fgnu-inline to avoid this stupidity. **])
|
||||
AC_MSG_WARN([****************************************************************])
|
||||
AC_ADD_CFLAGS([-fgnu89-inline])
|
||||
MN_ADD_CFLAGS([-fgnu89-inline])
|
||||
fi
|
||||
|
||||
CFLAGS="$CFLAGS -Wall"
|
||||
CXXFLAGS="$CXXFLAGS -Wall"
|
||||
|
||||
AC_ADD_CFLAGS([-Wextra])
|
||||
MN_ADD_CFLAGS([-Wextra])
|
||||
|
||||
AC_LANG_PUSH([C++])
|
||||
AC_ADD_CXXFLAGS([-Wextra])
|
||||
MN_ADD_CXXFLAGS([-Wextra])
|
||||
AC_LANG_POP([C++])
|
||||
|
||||
AC_ADD_CFLAGS([-Wdeclaration-after-statement])
|
||||
AC_ADD_CFLAGS([-Wpointer-arith])
|
||||
AC_ADD_CFLAGS([-funsigned-char])
|
||||
MN_ADD_CFLAGS([-Wdeclaration-after-statement])
|
||||
MN_ADD_CFLAGS([-Wpointer-arith])
|
||||
MN_ADD_CFLAGS([-funsigned-char])
|
||||
|
||||
if test x$enable_gcc_werror = "xyes" ; then
|
||||
CFLAGS="-Werror $CFLAGS"
|
||||
@ -518,8 +498,8 @@ if test x$ac_cv_c_compiler_gnu = xyes ; then
|
||||
fi
|
||||
|
||||
if test x$enable_test_coverage = "xyes" ; then
|
||||
# AC_ADD_CFLAGS([-ftest-coverage])
|
||||
AC_ADD_CFLAGS([-coverage])
|
||||
# MN_ADD_CFLAGS([-ftest-coverage])
|
||||
MN_ADD_CFLAGS([-coverage])
|
||||
fi
|
||||
|
||||
CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return -Wcast-align -Wcast-qual -Wnested-externs -Wshadow -Wbad-function-cast -Wwrite-strings "
|
||||
|
47
doc/FAQ.html
47
doc/FAQ.html
@ -8,7 +8,8 @@
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<META NAME="Description" CONTENT="The libsndfile FAQ.">
|
||||
<META NAME="Keywords" CONTENT="WAV AIFF AU libsndfile sound audio dsp Linux">
|
||||
<LINK REL=StyleSheet HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
@ -18,12 +19,12 @@
|
||||
<A HREF="#Q001">Q1 : Do you plan to support XYZ codec in libsndfile?</A><BR>
|
||||
<A HREF="#Q002">Q2 : In version 0 the SF_INFO struct had a pcmbitwidth field
|
||||
but version 1 does not. Why?</A><BR>
|
||||
<A HREF="#Q003">Q3 : Compiling is really slow on MacOSX. Why?</A><BR>
|
||||
<A HREF="#Q003">Q3 : Compiling is really slow on MacOS X. Why?</A><BR>
|
||||
<A HREF="#Q004">Q4 : When trying to compile libsndfile on Solaris I get a "bad
|
||||
substitution" error during linking. What can I do to fix this?</A><BR>
|
||||
<A HREF="#Q005">Q5 : Why doesn't libsndfile do interleaving/de-interleaving?</A><BR>
|
||||
<A HREF="#Q006">Q6 : What's the best format for storing temporary files?</A><BR>
|
||||
<A HREF="#Q007">Q7 : On Linux/Unix/MacOSX, what's the best way of detecting the
|
||||
<A HREF="#Q007">Q7 : On Linux/Unix/MacOS X, what's the best way of detecting the
|
||||
presence of libsndfile?</A><BR>
|
||||
<A HREF="#Q008">Q8 : But I just want a simple Makefile! What do I do?</A><BR>
|
||||
<A HREF="#Q009">Q9 : How about adding the ability to write/read sound files to/from
|
||||
@ -43,7 +44,7 @@
|
||||
</A><BR>
|
||||
<A HREF="#Q017">Q17 : Can libsndfile read/write files from/to UNIX pipes?
|
||||
</A><BR>
|
||||
<A HREF="#Q018">Q18 : Is it possible to build a Universal Binary on Mac OSX?
|
||||
<A HREF="#Q018">Q18 : Is it possible to build a Universal Binary on Mac OS X?
|
||||
</A><BR>
|
||||
<A HREF="#Q019">Q19 : I have project files for Visual Studio / XCode / Whatever. Why
|
||||
don't you distribute them with libsndfile?
|
||||
@ -69,7 +70,7 @@ If source code for XYZ codec is available under a suitable license (LGPL, BSD,
|
||||
MIT etc) then yes, I'd like to add it.
|
||||
</P>
|
||||
<P>
|
||||
If suitable documentation is available on how to decode and enocde the format
|
||||
If suitable documentation is available on how to decode and encode the format
|
||||
then maybe, depending on how much work is involved.
|
||||
</P>
|
||||
<P>
|
||||
@ -95,21 +96,21 @@ If you can't find either then the answer is no.
|
||||
<P>
|
||||
As documented
|
||||
<A HREF="http://www.mega-nerd.com/libsndfile/api.html#note1">here</A>
|
||||
there is now a well defined behavior which ensures that no matter what the
|
||||
there is now a well defined behaviour which ensures that no matter what the
|
||||
bit width of the source file, the scaling always does something sensible.
|
||||
This makes it safe to read 8, 16, 24 and 32 bit PCM files using sf_read_short()
|
||||
and always have the optimal behavior.
|
||||
and always have the optimal behaviour.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q003"></A>
|
||||
<H2><BR><B>Q3 : Compiling is really slow on MacOSX. Why?</B></H2>
|
||||
<H2><BR><B>Q3 : Compiling is really slow on MacOS X. Why?</B></H2>
|
||||
<P>
|
||||
When you configure and compile libsndfile, it uses the /bin/sh shell for a number
|
||||
of tasks (ie configure script and libtool).
|
||||
Older versions of OSX (10.2?) shipped a a really crappy Bourne shell as /bin/sh
|
||||
Older versions of OS X (10.2?) shipped a really crappy Bourne shell as /bin/sh
|
||||
which resulted in <b>really</b> slow compiles.
|
||||
New version of OSX ship GNU Bash as /bin/sh and this answer doesn't apply in that
|
||||
Newer version of OS X ship GNU Bash as /bin/sh and this answer doesn't apply in that
|
||||
case.
|
||||
</P>
|
||||
<P>
|
||||
@ -118,7 +119,7 @@ To fix this I suggest that you install the GNU Bash shell, rename /bin/sh to
|
||||
Bash is designed to behave as a Bourne shell when is is called as /bin/sh.
|
||||
</P>
|
||||
<P>
|
||||
When I did this on my iBook running MacOSX, compile times dropped from 13 minutes
|
||||
When I did this on my iBook running MacOS X, compile times dropped from 13 minutes
|
||||
to 3 minutes.
|
||||
</P>
|
||||
|
||||
@ -146,7 +147,7 @@ For a stereo file, it is a pretty safe bet that a simple interleaving/de-interle
|
||||
could satisfy most users.
|
||||
However, for files with more than 2 channels this is unlikely to be the case.
|
||||
If the user has a 4 channel file and want to play that file on a stereo output
|
||||
sound card they either want the first two channels or they want some mixed combination
|
||||
sound card they either want the first 2 channels or they want some mixed combination
|
||||
of the 4 channels.
|
||||
</P>
|
||||
<P>
|
||||
@ -187,7 +188,7 @@ regardless of the host CPU.
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
<A NAME="Q007"></A>
|
||||
<H2><BR><B>Q7 : On Linux/Unix/MaxOSX, what's the best way of detecting the presence
|
||||
<H2><BR><B>Q7 : On Linux/Unix/MaxOS X, what's the best way of detecting the presence
|
||||
of libsndfile using autoconf?</B></H2>
|
||||
|
||||
<P>
|
||||
@ -410,7 +411,7 @@ First some background.
|
||||
SD2 files are native to the Apple Macintosh platform and use features of
|
||||
the Mac filesystem (file resource forks) to store the file's sample rate,
|
||||
number of channels, sample width and more.
|
||||
When you look at a file and its resource fork on Mac OSX it looks like
|
||||
When you look at a file and its resource fork on Mac OS X it looks like
|
||||
this:
|
||||
</P>
|
||||
|
||||
@ -422,7 +423,7 @@ this:
|
||||
<P>
|
||||
Notice how the file itself looks like a directory containing a single file
|
||||
named <B>rsrc</B>.
|
||||
When libsndfile is compiled for MacOSX, it should open (for write and read)
|
||||
When libsndfile is compiled for MacOS X, it should open (for write and read)
|
||||
SD2 file with resource forks like this without any problems.
|
||||
It will also handle files with the resource fork in a separate file as
|
||||
described below.
|
||||
@ -439,8 +440,8 @@ libsndfile to open the file.
|
||||
<P>
|
||||
However, it is possible to safely move an SD2 file to a Linux or Windows
|
||||
machine.
|
||||
For instance, when an SD2 file is copied from inside MacOSX to a windows
|
||||
shared directory or a Samba share (ie Linux), MacOSX is clever enough to
|
||||
For instance, when an SD2 file is copied from inside MacOS X to a windows
|
||||
shared directory or a Samba share (ie Linux), MacOS X is clever enough to
|
||||
store the resource fork of the file in a separate hidden file in the
|
||||
same directory like this:
|
||||
</P>
|
||||
@ -586,7 +587,7 @@ See also <A HREF="#Q006">FAQ Q6</A>.
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q018"></A>
|
||||
<H2><BR><B>Q18 : Is it possible to build a Universal Binary on Mac OSX?
|
||||
<H2><BR><B>Q18 : Is it possible to build a Universal Binary on Mac OS X?
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
@ -677,7 +678,7 @@ fixing or even testing it.
|
||||
|
||||
<P>
|
||||
I currently release sources that I personally test on Win32, Linux and
|
||||
MacOSX (PowerPC) using the compiler I trust (GNU GCC).
|
||||
MacOS X (PowerPC) using the compiler I trust (GNU GCC).
|
||||
Supporting one compiler on three (actually much more because GCC is available
|
||||
almost everywhere) platforms is doable without too much pain.
|
||||
I also release binaries for Win32 with instructions on how to use those
|
||||
@ -749,7 +750,7 @@ released under, the GNU Lesser General Public License (LGPL):
|
||||
|
||||
<ul>
|
||||
<li>Make sure you are linking to libsndfile as a shared library (Linux and Unix
|
||||
systems), Dynamic Link Library (Microsoft Windows) or dynlib (Mac OSX).
|
||||
systems), Dynamic Link Library (Microsoft Windows) or dynlib (Mac OS X).
|
||||
If you are using some other operating system that doesn't allow dynamically
|
||||
linked libraries, you will not be able to use libsndfile unless you release
|
||||
the source code to your program.
|
||||
@ -765,18 +766,18 @@ released under, the GNU Lesser General Public License (LGPL):
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q022"></A>
|
||||
<H2><BR><B>Q22 : What versions of windows does libsndfile work on?
|
||||
<H2><BR><B>Q22 : What versions of Windows does libsndfile work on?
|
||||
</B></H2>
|
||||
|
||||
<p>
|
||||
Currently the precompiled windows binaries are thoroughly tested on Windows XP.
|
||||
As such, they should also work on Win2k and Windows Vista.
|
||||
They may also work on earlier versions of windows.
|
||||
They may also work on earlier versions of Windows.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Since version 0.1.18 I have also been releasing precompiled binaries for Win64,
|
||||
the 64 bit version of windows.
|
||||
the 64 bit version of Windows.
|
||||
These binaries have received much less testing than the 32 bit versions, but
|
||||
should work as expected.
|
||||
I'd be very interested in receiving feedback on these binaries.
|
||||
|
17
doc/api.html
17
doc/api.html
@ -3,12 +3,13 @@
|
||||
|
||||
<HEAD>
|
||||
<TITLE>
|
||||
The libsndfile API.
|
||||
The libsndfile API
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<META NAME="Description" CONTENT="The libsndfile API.">
|
||||
<META NAME="Keywords" CONTENT="WAV AIFF AU libsndfile sound audio dsp Linux">
|
||||
<LINK REL=StyleSheet HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
@ -34,7 +35,7 @@
|
||||
unambiguous.
|
||||
However, since maintaining the documentation is the least fun part of working
|
||||
on libsndfile, these docs can and do fall behind the behaviour of library.
|
||||
If any errors omissions or ambiguities are found, please notify
|
||||
If any errors, omissions or ambiguities are found, please notify
|
||||
<A HREF="mailto:erikd@zip.com.au">
|
||||
Erik de Castro Lopo</a>.
|
||||
</P>
|
||||
@ -53,7 +54,7 @@
|
||||
</B>
|
||||
</P>
|
||||
|
||||
<H2><B>SYNOPSIS</B></H2>
|
||||
<H2><B>Synopsis</B></H2>
|
||||
<P>
|
||||
The functions of libsndfile are defined as follows:
|
||||
</P>
|
||||
@ -245,7 +246,7 @@ memory allocated during the call to sf_open().
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
On success, the sf_open function returns a non NULL pointer which should be
|
||||
On success, the sf_open function returns a non-NULL pointer which should be
|
||||
passed as the first parameter to all subsequent libsndfile calls dealing with
|
||||
that audio file.
|
||||
On fail, the sf_open function returns a NULL pointer.
|
||||
@ -287,7 +288,7 @@ parameter was TRUE when the sf_open_fd() function was called.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
On success, the sf_open_fd function returns a non NULL pointer which should be
|
||||
On success, the sf_open_fd function returns a non-NULL pointer which should be
|
||||
passed as the first parameter to all subsequent libsndfile calls dealing with
|
||||
that audio file.
|
||||
On fail, the sf_open_fd function returns a NULL pointer.
|
||||
@ -598,7 +599,7 @@ The <B>str_type</B> parameter can be any one of the following string types:
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The sf_get_string() function returns the specificed string if it exists and a
|
||||
The sf_get_string() function returns the specified string if it exists and a
|
||||
NULL pointer otherwise.
|
||||
In addition to the string ids above, SF_STR_FIRST (== SF_STR_TITLE) and
|
||||
SF_STR_LAST (always the same as the highest numbers string id) are also
|
||||
@ -655,7 +656,7 @@ would mean that all sample values read from the file will be zero.
|
||||
In order to read these files correctly using integer read methods, it is recommended
|
||||
that you use the
|
||||
<A HREF="command.html">sf_command</A>
|
||||
interface a command of
|
||||
interface, a command of
|
||||
<A HREF="command.html#SFC_SET_SCALE_FLOAT_INT_READ">SFC_SET_SCALE_FLOAT_INT_READ</A>
|
||||
and a parameter of SF_TRUE to force correct scaling.
|
||||
</P>
|
||||
|
@ -6,7 +6,8 @@
|
||||
Bug Reporting
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<LINK REL=StyleSheet HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
@ -45,7 +46,7 @@
|
||||
<LI> Whether you are using a package provided by your distribution or you
|
||||
compiled it youself.
|
||||
<LI> If you compiled it yourself, the compiler you are using. (Also make
|
||||
sure to run "make check".)
|
||||
sure to run 'make check'.)
|
||||
<LI> A description of the problem.
|
||||
<LI> Information generated by the sndfile-info program (see next paragraph).
|
||||
<LI> If you are having problems with sndfile-play and ALSA on Linux, I will
|
||||
|
@ -9,7 +9,8 @@
|
||||
<!-- Another version at the bottom of the page. -->
|
||||
<META NAME="Description" CONTENT="The libsndfile API.">
|
||||
<META NAME="Keywords" CONTENT="WAV AIFF AU libsndfile sound audio dsp Linux">
|
||||
<LINK REL=StyleSheet HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
@ -27,7 +28,7 @@
|
||||
Most of these operations are performed on a per-file basis.
|
||||
</P>
|
||||
<P>
|
||||
The cmd parameter is a integer identifier which is defined in <sndfile.h>.
|
||||
The cmd parameter is an integer identifier which is defined in <sndfile.h>.
|
||||
All of the valid command identifiers have names beginning with "SFC_".
|
||||
Data is passed to and returned from the library by use of a void pointer.
|
||||
The library will not read or write more than datasize bytes from the void pointer.
|
||||
@ -167,12 +168,12 @@
|
||||
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_GET_CLIPPING">SFC_GET_CLIPPING</A></TD>
|
||||
<TD>Retreive current clipping setting.</TD>
|
||||
<TD>Retrieve current clipping setting.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_GET_EMBED_FILE_INFO">SFC_GET_EMBED_FILE_INFO</A></TD>
|
||||
<TD>Retreive information about audio files embedded inside other files.</TD>
|
||||
<TD>Retrieve information about audio files embedded inside other files.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
@ -891,7 +892,7 @@ Example:
|
||||
<A NAME="SFC_GET_FORMAT_SUBTYPE"></A>
|
||||
<H2><BR><B>SFC_GET_FORMAT_SUBTYPE</B></H2>
|
||||
<P>
|
||||
Enumerate the subtypes (this function does not translate a sub type into
|
||||
Enumerate the subtypes (this function does not translate a subtype into
|
||||
a string describing that subtype).
|
||||
A typical use case might be retrieving a string description of all subtypes
|
||||
so that a dialog box can be filled in.
|
||||
@ -909,7 +910,7 @@ Parameters:
|
||||
datasize : sizeof (SF_FORMAT_INFO)
|
||||
</PRE>
|
||||
<P>
|
||||
Example 1: Retrieve all subytpes supported by the WAV format.
|
||||
Example 1: Retrieve all sybtypes supported by the WAV format.
|
||||
</P>
|
||||
<PRE>
|
||||
SF_FORMAT_INFO format_info ;
|
||||
@ -1334,7 +1335,7 @@ Parameters:
|
||||
<A NAME="SFC_GET_BROADCAST_INFO"></A>
|
||||
<H2><BR><B>SFC_GET_BROADCAST_INFO</B></H2>
|
||||
<P>
|
||||
Retrieve the Broadcast Extention Chunk from WAV (and related) files.
|
||||
Retrieve the Broadcast Extension Chunk from WAV (and related) files.
|
||||
</P>
|
||||
<p>
|
||||
Parameters:
|
||||
@ -1367,7 +1368,7 @@ The SF_BROADCAST_INFO struct is defined in <sndfile.h> as:
|
||||
|
||||
<DL>
|
||||
<DT>Return value: </DT>
|
||||
<DD>SF_TRUE if the file contained a Broadcast Extention chunk or SF_FALSE
|
||||
<DD>SF_TRUE if the file contained a Broadcast Extension chunk or SF_FALSE
|
||||
otherwise.
|
||||
</DL>
|
||||
|
||||
@ -1375,7 +1376,7 @@ The SF_BROADCAST_INFO struct is defined in <sndfile.h> as:
|
||||
<A NAME="SFC_SET_BROADCAST_INFO"></A>
|
||||
<H2><BR><B>SFC_SET_BROADCAST_INFO</B></H2>
|
||||
<P>
|
||||
Set the Broadcast Extention Chunk for WAV (and related) files.
|
||||
Set the Broadcast Extension Chunk for WAV (and related) files.
|
||||
</P>
|
||||
<p>
|
||||
Parameters:
|
||||
@ -1389,7 +1390,7 @@ Parameters:
|
||||
|
||||
<DL>
|
||||
<DT>Return value: </DT>
|
||||
<DD>SF_TRUE if setting the Broadcast Extention chunk was successful and SF_FALSE
|
||||
<DD>SF_TRUE if setting the Broadcast Extension chunk was successful and SF_FALSE
|
||||
otherwise.
|
||||
</DL>
|
||||
<!-- ========================================================================= -->
|
||||
|
@ -6,7 +6,8 @@
|
||||
libsndfile Development
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<LINK REL=StyleSheet HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
|
@ -9,7 +9,8 @@
|
||||
<!-- Another version at the bottom of the page. -->
|
||||
<META NAME="Description" CONTENT="The libsndfile API.">
|
||||
<META NAME="Keywords" CONTENT="WAV AIFF AU libsndfile sound audio dsp Linux">
|
||||
<LINK REL=StyleSheet HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
|
@ -9,7 +9,8 @@
|
||||
<!-- Another version at the bottom of the page. -->
|
||||
<META NAME="Description" CONTENT="The libsndfile API.">
|
||||
<META NAME="Keywords" CONTENT="WAV AIFF AU libsndfile sound audio dsp Linux">
|
||||
<LINK REL=StyleSheet HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
|
@ -8,7 +8,8 @@
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<META NAME="Description" CONTENT="The libsndfile API.">
|
||||
<META NAME="Keywords" CONTENT="WAV AIFF AU libsndfile sound audio dsp Linux">
|
||||
<LINK REL=StyleSheet HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
<!-- pepper -->
|
||||
<BODY>
|
||||
|
@ -10,7 +10,8 @@
|
||||
<META NAME="Description" CONTENT="The libsndfile Home Page">
|
||||
<META NAME="Keywords" CONTENT="WAV AIFF AU SVX PAF NIST W64 libsndfile sound audio dsp Linux">
|
||||
<META NAME="ROBOTS" CONTENT="NOFOLLOW">
|
||||
<LINK REL=StyleSheet HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
@ -47,11 +48,8 @@
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
The library was written to compile and run on a Linux system but should compile
|
||||
and run on just about any Unix (including MacOSX).
|
||||
It can also be compiled and run on Win32 systems using the Microsoft compiler and
|
||||
MacOS (OS9 and earlier) using the Metrowerks compiler.
|
||||
There are directions for compiling libsndfile on these platforms in the Win32 and
|
||||
MacOS directories of the source code distribution.
|
||||
and run on just about any Unix (including MacOS X).
|
||||
There are also pre-compiled binaries available for 32 and 64 bit windows.
|
||||
</P>
|
||||
<P>
|
||||
It was designed to handle both little-endian (such as WAV) and big-endian
|
||||
@ -78,7 +76,7 @@
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
At the moment, each new release is being tested on i386 Linux, PowerPC Linux,
|
||||
MacOSX on PowerPC and Win32.
|
||||
MacOS X on PowerPC and Win32.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
|
||||
@ -343,7 +341,7 @@ and
|
||||
<LI>Version 1.0.5 (May 03 2003) One new file format and new functionality.
|
||||
<LI>Version 1.0.6 (Feb 08 2004) Large file fix for Linux/Solaris, new functionality
|
||||
and Win32 improvements.
|
||||
<LI>Version 1.0.7 (Feb 24 2004) Fix build problems on MacOSX and fix ia64/MIPS etc
|
||||
<LI>Version 1.0.7 (Feb 24 2004) Fix build problems on MacOS X and fix ia64/MIPS etc
|
||||
clip mode detction.
|
||||
<LI>Version 1.0.8 (Mar 14 2004) Minor bug fixes.
|
||||
<LI>Version 1.0.9 (Mar 30 2004) Add AVR format. Improve handling of some WAV files.
|
||||
@ -390,7 +388,7 @@ and
|
||||
<a href="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">version 2.1</a>
|
||||
and
|
||||
<a href="http://www.gnu.org/copyleft/lesser.html">version 3</a>.
|
||||
To mamximise the compatibility of libsndfile, the user may choose to use libsndfile
|
||||
To maximise the compatibility of libsndfile, the user may choose to use libsndfile
|
||||
under either of the above two licenses.
|
||||
You can also read a simple explanation of the ideas behind the GPL and the LGPL
|
||||
<A HREF="http://www.gnu.org/copyleft/copyleft.html">here</A>.
|
||||
@ -411,24 +409,12 @@ and
|
||||
<A HREF="http://www.gnu.org/">Free Software</A>
|
||||
or
|
||||
<A HREF="http://www.opensource.org/">Open Source</A>.
|
||||
However, if you put in a great deal of effort building a huge application
|
||||
However, if you put in a great deal of effort building a significant application
|
||||
which simply uses libsndfile for file I/O, then I have no problem with you releasing
|
||||
that as closed source and charging as much money as you want for it as long as you
|
||||
abide by <A HREF="http://www.gnu.org/copyleft/lesser.html">the license</A>.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
What I don't like to see is things like Steve Dekorte's <b>SoundConverter</b>
|
||||
(no I won't link to his page) for Mac OSX.
|
||||
Mr Dekorte has grabbed a number of Free Software packages and wrapped them in a
|
||||
rather amateurish, buggy GUI and released the result as shareware.
|
||||
He charges US$10 for the full version when his contribution to the whole is, by
|
||||
his own
|
||||
<A HREF="http://groups.google.com/groups?selm=3F9B8F8B.7853300B@mega-nerd.com">
|
||||
admission</A>,
|
||||
less than 10%.
|
||||
</P>
|
||||
|
||||
<A NAME="Download"></A>
|
||||
<H1><B>Download</B></H1>
|
||||
<P>
|
||||
|
@ -6,7 +6,8 @@
|
||||
libsndfile Mailing Lists
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<LINK REL=StyleSheet HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
|
@ -6,7 +6,8 @@
|
||||
libsndfile and GNU Octave
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<LINK REL=StyleSheet HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
@ -85,7 +86,7 @@
|
||||
to play the correct types of Octave files.
|
||||
Using this command line player <B>sndfile-play</B> and a third Octave script
|
||||
file allows Octave data to be played from within Octave on any of the platforms
|
||||
which <B>sndfile-play</B> supports (at the moment: Linux, MacOSX, Solaris and
|
||||
which <B>sndfile-play</B> supports (at the moment: Linux, MacOS X, Solaris and
|
||||
Win32).
|
||||
</P>
|
||||
<PRE>
|
||||
|
@ -6,7 +6,8 @@
|
||||
libsndfile : pkg-config
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<LINK REL=StyleSheet HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
@ -18,7 +19,7 @@
|
||||
From version 1.0.0 libsndfile has had the ability to read and write files of
|
||||
greater than 2 Gig in size on most OSes even if sizeof (long) == 4.
|
||||
OSes which support this feature include Linux (2.4 kernel, glibc6) on x86, PPC and
|
||||
probably others, Win32, MacOSX, *BSD, Solaris and probably others.
|
||||
probably others, Win32, MacOS X, *BSD, Solaris and probably others.
|
||||
OSes on 64 bit processors where the default compile environment is LP64 (longs and
|
||||
pointers are 64 bit ie Linux on DEC/Compaq/HP Alpha processors) automatically
|
||||
support large file access.
|
||||
@ -30,7 +31,7 @@
|
||||
programs which link to the library.
|
||||
</P>
|
||||
<P>
|
||||
Note : People using Win32, MacOS (both OSX and pre-OSX) or *BSD can disregard the
|
||||
Note : People using Win32, MacOS (both OS X and pre-OS X) or *BSD can disregard the
|
||||
rest of this document as it does not apply to either of these OSes.
|
||||
</P>
|
||||
<P>
|
||||
|
14
doc/print.css
Normal file
14
doc/print.css
Normal file
@ -0,0 +1,14 @@
|
||||
body {
|
||||
background:white;
|
||||
color:black;
|
||||
}
|
||||
|
||||
h1{
|
||||
background:white;
|
||||
color:black;
|
||||
}
|
||||
|
||||
h2 {
|
||||
background:white;
|
||||
color:#666;
|
||||
}
|
@ -6,7 +6,8 @@
|
||||
sndfile-info
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<LINK REL=StyleSheet HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
|
@ -6,7 +6,8 @@
|
||||
libsndfile Tutorial
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<LINK REL=StyleSheet HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
|
@ -6,7 +6,8 @@
|
||||
Building libsndfile on Win32
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<LINK REL=StyleSheet HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
|
@ -1,10 +1,10 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
man_MANS = sndfile-info.1 sndfile-play.1 sndfile-convert.1 sndfile-cmp.1 \
|
||||
sndfile-jackplay.1 sndfile-metadata-get.1 sndfile-metadata-set.1
|
||||
sndfile-metadata-get.1 sndfile-metadata-set.1 sndfile-concat.1
|
||||
|
||||
EXTRA_DIST = sndfile-info.1 sndfile-play.1 sndfile-convert.1 sndfile-cmp.1 \
|
||||
sndfile-jackplay.1 sndfile-metadata-get.1
|
||||
sndfile-metadata-get.1 sndfile-concat.1
|
||||
|
||||
# Same manpage for both programs.
|
||||
sndfile-metadata-set.1 : sndfile-metadata-get.1
|
||||
|
16
man/sndfile-concat.1
Normal file
16
man/sndfile-concat.1
Normal file
@ -0,0 +1,16 @@
|
||||
.TH SNDFILE-CONCAT 1 "December 9, 2009"
|
||||
.SH NAME
|
||||
sndfile-concat \- concatenates two or more audio files
|
||||
.SH SYNOPSIS
|
||||
.B sndfile-concat
|
||||
.RI "infile1 infile2 .... outfile"
|
||||
.SH DESCRIPTION
|
||||
sndfile-concat generates a new output file by concatenating two or more input
|
||||
files. The format of the output file is the same as the format of the input
|
||||
file.
|
||||
|
||||
sndfile-concat does its work using libsndfile
|
||||
(http://www.mega-nerd.com/libsndfile/).
|
||||
.SH AUTHOR
|
||||
This manual page was written by Erik de Castro Lopo <erikd@mega-nerd.com>.
|
||||
|
@ -1,13 +0,0 @@
|
||||
.TH SNDFILE-PLAY 1 "October 5, 2009"
|
||||
.SH NAME
|
||||
sndfile-jackplay \- play a sound file via the JACK sound server
|
||||
.SH SYNOPSIS
|
||||
.B sndfile-jackplay
|
||||
.RI file
|
||||
.SH DESCRIPTION
|
||||
sndfile-jackplay plays the specified sound file via the JACK sound server.
|
||||
It uses libsndfile (http://www.mega-nerd.com/libsndfile/)
|
||||
to read the file.
|
||||
.SH AUTHOR
|
||||
This manual page was written by Erik de Castro Lopo <erikd@mega-nerd.com>.
|
||||
|
@ -1,7 +1,8 @@
|
||||
## 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
|
||||
bin_PROGRAMS = sndfile-info sndfile-play sndfile-convert sndfile-cmp \
|
||||
sndfile-metadata-set sndfile-metadata-get sndfile-interleave \
|
||||
sndfile-deinterleave sndfile-concat
|
||||
|
||||
OS_SPECIFIC_CFLAGS = @OS_SPECIFIC_CFLAGS@
|
||||
OS_SPECIFIC_LINKS = @OS_SPECIFIC_LINKS@
|
||||
@ -18,10 +19,6 @@ 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
|
||||
|
||||
@ -34,3 +31,12 @@ 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
|
||||
|
||||
sndfile_interleave_SOURCES = sndfile-interleave.c common.c common.h
|
||||
sndfile_interleave_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
sndfile_deinterleave_SOURCES = sndfile-deinterleave.c
|
||||
sndfile_deinterleave_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
sndfile_concat_SOURCES = sndfile-concat.c
|
||||
sndfile_concat_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
|
@ -264,3 +264,90 @@ cleanup_exit :
|
||||
return ;
|
||||
} /* sfe_apply_metadata_changes */
|
||||
|
||||
/*==============================================================================
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{ const char *ext ;
|
||||
int len ;
|
||||
int format ;
|
||||
} OUTPUT_FORMAT_MAP ;
|
||||
|
||||
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 */
|
||||
|
||||
int
|
||||
sfe_file_type_of_ext (const 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 ;
|
||||
} ;
|
||||
|
||||
/* Default if all the above fails. */
|
||||
return (SF_FORMAT_WAV | SF_FORMAT_PCM_24) ;
|
||||
} /* sfe_file_type_of_ext */
|
||||
|
||||
void
|
||||
sfe_dump_format_map (void)
|
||||
{ SF_FORMAT_INFO info ;
|
||||
int k ;
|
||||
|
||||
for (k = 0 ; k < ARRAY_LEN (format_map) ; 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 == NULL ? "????" : info.name) ;
|
||||
} ;
|
||||
|
||||
} /* sfe_dump_format_map */
|
||||
|
@ -30,9 +30,9 @@
|
||||
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0])))
|
||||
#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof (x [0])))
|
||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
typedef struct
|
||||
{ const char * title ;
|
||||
@ -64,3 +64,7 @@ void sfe_apply_metadata_changes (const char * filenames [2], const METADATA_INFO
|
||||
void sfe_copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels) ;
|
||||
|
||||
void sfe_copy_data_int (SNDFILE *outfile, SNDFILE *infile, int channels) ;
|
||||
|
||||
int sfe_file_type_of_ext (const char *filename, int format) ;
|
||||
|
||||
void sfe_dump_format_map (void) ;
|
||||
|
171
programs/sndfile-concat.c
Normal file
171
programs/sndfile-concat.c
Normal file
@ -0,0 +1,171 @@
|
||||
/*
|
||||
** 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>
|
||||
|
||||
#define BUFFER_LEN (1<<16)
|
||||
|
||||
|
||||
static void concat_data_fp (SNDFILE *wfile, SNDFILE *rofile, int channels) ;
|
||||
static void concat_data_int (SNDFILE *wfile, SNDFILE *rofile, int channels) ;
|
||||
|
||||
static void
|
||||
usage_exit (const char *argv0)
|
||||
{ const char *progname ;
|
||||
|
||||
progname = strrchr (argv0, '/') ;
|
||||
progname = progname ? progname + 1 : argv0 ;
|
||||
|
||||
printf ("\nUsage : %s <infile1> <infile2> ... <outfile>\n\n", progname) ;
|
||||
puts (
|
||||
" Create a new output file <outfile> containing the concatenated\n"
|
||||
" audio data from froms <infile1> <infile2> ....\n"
|
||||
"\n"
|
||||
" The joined file will be encoded in the same format as the data\n"
|
||||
" in infile1, with all the data in subsequent files automatically\n"
|
||||
" converted to the correct encoding.\n"
|
||||
"\n"
|
||||
" The only restriction is that the two files must have the same\n"
|
||||
" number of channels.\n"
|
||||
) ;
|
||||
|
||||
exit (0) ;
|
||||
} /* usage_exit */
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{ const char *argv0, *outfilename ;
|
||||
SNDFILE *outfile, **infiles ;
|
||||
SF_INFO sfinfo_out, sfinfo_in ;
|
||||
void (*func) (SNDFILE*, SNDFILE*, int) ;
|
||||
int k ;
|
||||
|
||||
argv0 = argv [0] ;
|
||||
|
||||
if (argc < 4)
|
||||
usage_exit (argv0) ;
|
||||
|
||||
argv ++ ;
|
||||
argc -- ;
|
||||
|
||||
argc -- ;
|
||||
outfilename = argv [argc] ;
|
||||
|
||||
if ((infiles = calloc (argc, sizeof (SNDFILE*))) == NULL)
|
||||
{ printf ("\nError : Malloc failed.\n\n") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
memset (&sfinfo_in, 0, sizeof (sfinfo_in)) ;
|
||||
|
||||
if ((infiles [0] = sf_open (argv [0], SFM_READ, &sfinfo_in)) == NULL)
|
||||
{ printf ("\nError : failed to open file '%s'.\n\n", argv [0]) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
sfinfo_out = sfinfo_in ;
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
{ if ((infiles [k] = sf_open (argv [k], SFM_READ, &sfinfo_in)) == NULL)
|
||||
{ printf ("\nError : failed to open file '%s'.\n\n", argv [k]) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (sfinfo_in.channels != sfinfo_out.channels)
|
||||
{ printf ("\nError : File '%s' has %d channels (should have %d).\n\n", argv [k], sfinfo_in.channels, sfinfo_out.channels) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
} ;
|
||||
|
||||
if ((outfile = sf_open (outfilename, SFM_WRITE, &sfinfo_out)) == NULL)
|
||||
{ printf ("\nError : Not able to open input file %s.\n", outfilename) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if ((sfinfo_out.format & SF_FORMAT_SUBMASK) == SF_FORMAT_DOUBLE ||
|
||||
(sfinfo_out.format & SF_FORMAT_SUBMASK) == SF_FORMAT_FLOAT)
|
||||
func = concat_data_fp ;
|
||||
else
|
||||
func = concat_data_int ;
|
||||
|
||||
for (k = 0 ; k < argc ; k++)
|
||||
{ func (outfile, infiles [k], sfinfo_out.channels) ;
|
||||
sf_close (infiles [k]) ;
|
||||
} ;
|
||||
|
||||
sf_close (outfile) ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
static void
|
||||
concat_data_fp (SNDFILE *wfile, SNDFILE *rofile, int channels)
|
||||
{ static double data [BUFFER_LEN] ;
|
||||
int frames, readcount ;
|
||||
|
||||
frames = BUFFER_LEN / channels ;
|
||||
readcount = frames ;
|
||||
|
||||
sf_seek (wfile, 0, SEEK_END) ;
|
||||
|
||||
while (readcount > 0)
|
||||
{ readcount = sf_readf_double (rofile, data, frames) ;
|
||||
sf_writef_double (wfile, data, readcount) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* concat_data_fp */
|
||||
|
||||
static void
|
||||
concat_data_int (SNDFILE *wfile, SNDFILE *rofile, int channels)
|
||||
{ static int data [BUFFER_LEN] ;
|
||||
int frames, readcount ;
|
||||
|
||||
frames = BUFFER_LEN / channels ;
|
||||
readcount = frames ;
|
||||
|
||||
sf_seek (wfile, 0, SEEK_END) ;
|
||||
|
||||
while (readcount > 0)
|
||||
{ readcount = sf_readf_int (rofile, data, frames) ;
|
||||
sf_writef_int (wfile, data, readcount) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* concat_data_int */
|
||||
|
@ -45,87 +45,11 @@ typedef struct
|
||||
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, int channels) ;
|
||||
|
||||
static OUTPUT_FORMAT_MAP format_map [] =
|
||||
{
|
||||
{ "aif", 3, SF_FORMAT_AIFF },
|
||||
{ "wav", 0, SF_FORMAT_WAV },
|
||||
{ "wavex", 0, SF_FORMAT_WAVEX },
|
||||
{ "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"
|
||||
@ -158,11 +82,7 @@ print_usage (char *progname)
|
||||
" 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 == NULL ? "????" : info.name) ;
|
||||
} ;
|
||||
sfe_dump_format_map () ;
|
||||
|
||||
puts ("") ;
|
||||
} /* print_usage */
|
||||
@ -192,7 +112,7 @@ main (int argc, char * argv [])
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if (infilename [0] == '-')
|
||||
if (strlen (infilename) > 1 && infilename [0] == '-')
|
||||
{ printf ("Error : Input filename (%s) looks like an option.\n\n", infilename) ;
|
||||
print_usage (progname) ;
|
||||
return 1 ;
|
||||
@ -290,7 +210,7 @@ main (int argc, char * argv [])
|
||||
|
||||
infileminor = sfinfo.format & SF_FORMAT_SUBMASK ;
|
||||
|
||||
if ((sfinfo.format = guess_output_file_type (outfilename, sfinfo.format)) == 0)
|
||||
if ((sfinfo.format = sfe_file_type_of_ext (outfilename, sfinfo.format)) == 0)
|
||||
{ printf ("Error : Not able to determine output file type for %s.\n", outfilename) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
187
programs/sndfile-deinterleave.c
Normal file
187
programs/sndfile-deinterleave.c
Normal file
@ -0,0 +1,187 @@
|
||||
/*
|
||||
** Copyright (C) 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 <sndfile.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define BUFFER_LEN 4096
|
||||
#define MAX_CHANNELS 16
|
||||
|
||||
|
||||
typedef struct
|
||||
{ SNDFILE * infile ;
|
||||
SNDFILE * outfile [MAX_CHANNELS] ;
|
||||
|
||||
union
|
||||
{ double d [MAX_CHANNELS * BUFFER_LEN] ;
|
||||
int i [MAX_CHANNELS * BUFFER_LEN] ;
|
||||
} din ;
|
||||
|
||||
union
|
||||
{ double d [BUFFER_LEN] ;
|
||||
int i [BUFFER_LEN] ;
|
||||
} dout ;
|
||||
|
||||
int channels ;
|
||||
} STATE ;
|
||||
|
||||
static void usage_exit (void) ;
|
||||
|
||||
static void deinterleave_int (STATE * state) ;
|
||||
static void deinterleave_double (STATE * state) ;
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{ STATE state ;
|
||||
SF_INFO sfinfo ;
|
||||
char pathname [512], ext [32], *cptr ;
|
||||
int ch, double_split ;
|
||||
|
||||
if (argc != 2)
|
||||
{ puts ("\nError : need a single input file.\n") ;
|
||||
usage_exit () ;
|
||||
} ;
|
||||
|
||||
memset (&state, 0, sizeof (state)) ;
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
if ((state.infile = sf_open (argv [1], SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("\nError : Not able to open input file '%s'\n%s\n", argv [1], sf_strerror (NULL)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (sfinfo.channels < 2)
|
||||
{ printf ("\nError : Input file '%s' only has one channel.\n", argv [1]) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
state.channels = sfinfo.channels ;
|
||||
sfinfo.channels = 1 ;
|
||||
|
||||
snprintf (pathname, sizeof (pathname), "%s", argv [1]) ;
|
||||
if ((cptr = strrchr (pathname, '.')) == NULL)
|
||||
ext [0] = 0 ;
|
||||
else
|
||||
{ snprintf (ext, sizeof (ext), "%s", cptr) ;
|
||||
cptr [0] = 0 ;
|
||||
} ;
|
||||
|
||||
printf ("Input file : %s\n", pathname) ;
|
||||
puts ("Output files :") ;
|
||||
|
||||
for (ch = 0 ; ch < state.channels ; ch++)
|
||||
{ char filename [520] ;
|
||||
|
||||
snprintf (filename, sizeof (filename), "%s_%02d%s", pathname, ch, ext) ;
|
||||
|
||||
if ((state.outfile [ch] = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL)
|
||||
{ printf ("Not able to open output file '%s'\n%s\n", filename, sf_strerror (NULL)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
printf (" %s\n", filename) ;
|
||||
} ;
|
||||
|
||||
switch (sfinfo.format & SF_FORMAT_SUBMASK)
|
||||
{ case SF_FORMAT_FLOAT :
|
||||
case SF_FORMAT_DOUBLE :
|
||||
case SF_FORMAT_VORBIS :
|
||||
double_split = 1 ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
double_split = 0 ;
|
||||
break ;
|
||||
} ;
|
||||
|
||||
if (double_split)
|
||||
deinterleave_double (&state) ;
|
||||
else
|
||||
deinterleave_int (&state) ;
|
||||
|
||||
sf_close (state.infile) ;
|
||||
for (ch = 0 ; ch < MAX_CHANNELS ; ch++)
|
||||
if (state.outfile [ch] != NULL)
|
||||
sf_close (state.outfile [ch]) ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static void
|
||||
usage_exit (void)
|
||||
{ puts ("\nUsage : sndfile-deinterleave <filename>\n") ;
|
||||
puts ("Split a mutli channel file into a set of mon files.\n") ;
|
||||
exit (0) ;
|
||||
} /* usage_exit */
|
||||
|
||||
static void
|
||||
deinterleave_int (STATE * state)
|
||||
{ int read_len ;
|
||||
int ch, k ;
|
||||
|
||||
do
|
||||
{ read_len = sf_readf_int (state->infile, state->din.i, BUFFER_LEN) ;
|
||||
|
||||
for (ch = 0 ; ch < state->channels ; ch ++)
|
||||
{ for (k = 0 ; k < read_len ; k++)
|
||||
state->dout.i [k] = state->din.i [k * state->channels + ch] ;
|
||||
sf_write_int (state->outfile [ch], state->dout.i, read_len) ;
|
||||
} ;
|
||||
}
|
||||
while (read_len > 0) ;
|
||||
|
||||
} /* deinterleave_int */
|
||||
|
||||
static void
|
||||
deinterleave_double (STATE * state)
|
||||
{ int read_len ;
|
||||
int ch, k ;
|
||||
|
||||
do
|
||||
{ read_len = sf_readf_double (state->infile, state->din.d, BUFFER_LEN) ;
|
||||
|
||||
for (ch = 0 ; ch < state->channels ; ch ++)
|
||||
{ for (k = 0 ; k < read_len ; k++)
|
||||
state->dout.d [k] = state->din.d [k * state->channels + ch] ;
|
||||
sf_write_double (state->outfile [ch], state->dout.d, read_len) ;
|
||||
} ;
|
||||
}
|
||||
while (read_len > 0) ;
|
||||
|
||||
} /* deinterleave_double */
|
200
programs/sndfile-interleave.c
Normal file
200
programs/sndfile-interleave.c
Normal file
@ -0,0 +1,200 @@
|
||||
/*
|
||||
** Copyright (C) 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 <sndfile.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define BUFFER_LEN 4096
|
||||
#define MAX_INPUTS 16
|
||||
|
||||
|
||||
typedef struct
|
||||
{ SNDFILE * infile [MAX_INPUTS] ;
|
||||
SNDFILE * outfile ;
|
||||
|
||||
union
|
||||
{ double d [BUFFER_LEN] ;
|
||||
int i [BUFFER_LEN] ;
|
||||
} din ;
|
||||
|
||||
union
|
||||
|
||||
{ double d [MAX_INPUTS * BUFFER_LEN] ;
|
||||
int i [MAX_INPUTS * BUFFER_LEN] ;
|
||||
} dout ;
|
||||
|
||||
int channels ;
|
||||
} STATE ;
|
||||
|
||||
|
||||
static void usage_exit (void) ;
|
||||
static void interleave_int (STATE * state) ;
|
||||
static void interleave_double (STATE * state) ;
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{ STATE state ;
|
||||
SF_INFO sfinfo ;
|
||||
int k, double_merge = 0 ;
|
||||
|
||||
if (argc < 5)
|
||||
{ puts ("\nError : need at least 2 input files.") ;
|
||||
usage_exit () ;
|
||||
} ;
|
||||
|
||||
if (strcmp (argv [argc - 2], "-o") != 0)
|
||||
{ puts ("\nError : second last command line parameter should be '-o'.\n") ;
|
||||
usage_exit () ;
|
||||
} ;
|
||||
|
||||
if (argc - 2 > MAX_INPUTS)
|
||||
{ printf ("\nError : Cannot handle more than %d input channels.\n\n", MAX_INPUTS) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
memset (&state, 0, sizeof (state)) ;
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
for (k = 1 ; k < argc - 2 ; k++)
|
||||
{
|
||||
if ((state.infile [k - 1] = sf_open (argv [k], SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("\nError : Not able to open input file '%s'\n%s\n", argv [k], sf_strerror (NULL)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (sfinfo.channels != 1)
|
||||
{ printf ("\bError : Input file '%s' should be mono (has %d channels).\n", argv [k], sfinfo.channels) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
switch (sfinfo.format & SF_FORMAT_SUBMASK)
|
||||
{ case SF_FORMAT_FLOAT :
|
||||
case SF_FORMAT_DOUBLE :
|
||||
case SF_FORMAT_VORBIS :
|
||||
double_merge = 1 ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
break ;
|
||||
} ;
|
||||
|
||||
state.channels ++ ;
|
||||
} ;
|
||||
|
||||
sfinfo.channels = state.channels ;
|
||||
sfinfo.format = sfe_file_type_of_ext (argv [argc - 1], sfinfo.format) ;
|
||||
|
||||
if ((state.outfile = sf_open (argv [argc - 1], SFM_WRITE, &sfinfo)) == NULL)
|
||||
{ printf ("Not able to open output file '%s'\n%s\n", argv [argc - 1], sf_strerror (NULL)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (double_merge)
|
||||
interleave_double (&state) ;
|
||||
else
|
||||
interleave_int (&state) ;
|
||||
|
||||
for (k = 0 ; k < MAX_INPUTS ; k++)
|
||||
if (state.infile [k] != NULL)
|
||||
sf_close (state.infile [k]) ;
|
||||
sf_close (state.outfile) ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
static void
|
||||
usage_exit (void)
|
||||
{ puts ("\nUsage : sndfile-interleave <input 1> <input 2> ... -o <output file>\n") ;
|
||||
puts ("Merge two mono files to one stereo file\n") ;
|
||||
exit (0) ;
|
||||
} /* usage_exit */
|
||||
|
||||
|
||||
static void
|
||||
interleave_int (STATE * state)
|
||||
{ int max_read_len, read_len ;
|
||||
int ch, k ;
|
||||
|
||||
do
|
||||
{ max_read_len = 0 ;
|
||||
|
||||
for (ch = 0 ; ch < state->channels ; ch ++)
|
||||
{ read_len = sf_read_int (state->infile [ch], state->din.i, BUFFER_LEN) ;
|
||||
if (read_len < BUFFER_LEN)
|
||||
memset (state->din.i + read_len, 0, sizeof (state->din.i [0]) * (BUFFER_LEN - read_len)) ;
|
||||
|
||||
for (k = 0 ; k < read_len ; k++)
|
||||
state->dout.i [k * state->channels + ch] = state->din.i [k] ;
|
||||
|
||||
max_read_len = MAX (max_read_len, read_len) ;
|
||||
} ;
|
||||
|
||||
sf_writef_int (state->outfile, state->dout.i, max_read_len) ;
|
||||
}
|
||||
while (max_read_len > 0) ;
|
||||
|
||||
} /* interleave_int */
|
||||
|
||||
|
||||
static void
|
||||
interleave_double (STATE * state)
|
||||
{ int max_read_len, read_len ;
|
||||
int ch, k ;
|
||||
|
||||
do
|
||||
{ max_read_len = 0 ;
|
||||
|
||||
for (ch = 0 ; ch < state->channels ; ch ++)
|
||||
{ read_len = sf_read_double (state->infile [ch], state->din.d, BUFFER_LEN) ;
|
||||
if (read_len < BUFFER_LEN)
|
||||
memset (state->din.d + read_len, 0, sizeof (state->din.d [0]) * (BUFFER_LEN - read_len)) ;
|
||||
|
||||
for (k = 0 ; k < read_len ; k++)
|
||||
state->dout.d [k * state->channels + ch] = state->din.d [k] ;
|
||||
|
||||
max_read_len = MAX (max_read_len, read_len) ;
|
||||
} ;
|
||||
|
||||
sf_writef_double (state->outfile, state->dout.d, max_read_len) ;
|
||||
}
|
||||
while (max_read_len > 0) ;
|
||||
|
||||
} /* interleave_double */
|
@ -1,277 +0,0 @@
|
||||
/*
|
||||
** Copyright (c) 2007-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** 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 <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
|
@ -8,4 +8,5 @@ Description: A library for reading and writing audio files
|
||||
Requires:
|
||||
Version: @VERSION@
|
||||
Libs: -L${libdir} -lsndfile
|
||||
Libs.private: @EXTERNAL_LIBS@
|
||||
Cflags: -I${includedir}
|
||||
|
@ -16,7 +16,8 @@ OS_SPECIFIC_LINKS = @OS_SPECIFIC_LINKS@
|
||||
SYMBOL_FILES = Symbols.linux Symbols.darwin libsndfile-1.def Symbols.os2 Symbols.static
|
||||
|
||||
EXTRA_DIST = sndfile.h.in config.h.in test_endswap.tpl test_endswap.def \
|
||||
$(SYMBOL_FILES) create_symbols_file.py binheader_writef_check.py
|
||||
$(SYMBOL_FILES) create_symbols_file.py binheader_writef_check.py \
|
||||
make-static-lib-hidden-privates.sh
|
||||
|
||||
noinst_HEADERS = common.h sfconfig.h sfendian.h wav_w64.h sf_unistd.h chanmap.h
|
||||
|
||||
|
@ -113,7 +113,7 @@ def win32_symbols (progname, version, name):
|
||||
|
||||
def os2_symbols (progname, version, name):
|
||||
print "; Auto-generated by %s\n" %progname
|
||||
print "LIBRARY %s%s.dll" % (name, re.sub ("\..*", "", version))
|
||||
print "LIBRARY %s%s" % (name, re.sub ("\..*", "", version))
|
||||
print "INITINSTANCE TERMINSTANCE"
|
||||
print "CODE PRELOAD MOVEABLE DISCARDABLE"
|
||||
print "DATA PRELOAD MOVEABLE MULTIPLE NONSHARED"
|
||||
|
14
src/make-static-lib-hidden-privates.sh
Executable file
14
src/make-static-lib-hidden-privates.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
# This script takes a static library and removes all non-public symbols.
|
||||
# Ie, it makes a static lib whose symbols are far less likely to clash with
|
||||
# the symbols of another shared or static library.
|
||||
|
||||
grep sf_ Symbols.linux | sed -e "s/[ ;]//g" > Symbols.static
|
||||
|
||||
ld -r --whole-archive .libs/libsndfile.a -o libsndfile_a.o
|
||||
|
||||
objcopy --keep-global-symbols=Symbols.static libsndfile_a.o libsndfile.o
|
||||
|
||||
rm -f libsndfile.a
|
||||
ar cru libsndfile.a libsndfile.o
|
@ -34,15 +34,17 @@
|
||||
#define S_IXUSR 0000100 /* execute/search permission, owner */
|
||||
#endif
|
||||
|
||||
#define S_IRWXG 0000070 /* rwx, group */
|
||||
#define S_IRGRP 0000040 /* read permission, group */
|
||||
#define S_IWGRP 0000020 /* write permission, grougroup */
|
||||
#define S_IXGRP 0000010 /* execute/search permission, group */
|
||||
/* Windows doesn't have group permissions so set all these to zero. */
|
||||
#define S_IRWXG 0 /* rwx, group */
|
||||
#define S_IRGRP 0 /* read permission, group */
|
||||
#define S_IWGRP 0 /* write permission, grougroup */
|
||||
#define S_IXGRP 0 /* execute/search permission, group */
|
||||
|
||||
#define S_IRWXO 0000007 /* rwx, other */
|
||||
#define S_IROTH 0000004 /* read permission, other */
|
||||
#define S_IWOTH 0000002 /* write permission, other */
|
||||
#define S_IXOTH 0000001 /* execute/search permission, other */
|
||||
/* Windows doesn't have others permissions so set all these to zero. */
|
||||
#define S_IRWXO 0 /* rwx, other */
|
||||
#define S_IROTH 0 /* read permission, other */
|
||||
#define S_IWOTH 0 /* write permission, other */
|
||||
#define S_IXOTH 0 /* execute/search permission, other */
|
||||
|
||||
#ifndef S_ISFIFO
|
||||
#define S_ISFIFO(mode) (((mode) & _S_IFMT) == _S_IFIFO)
|
||||
|
@ -317,7 +317,7 @@ typedef @TYPEOF_SF_COUNT_T@ sf_count_t ;
|
||||
#endif
|
||||
|
||||
|
||||
/* A pointer to a SF_INFO structure is passed to sf_open_read () and filled in.
|
||||
/* A pointer to a SF_INFO structure is passed to sf_open () and filled in.
|
||||
** On write, the SF_INFO structure is filled in by the user and passed into
|
||||
** sf_open ().
|
||||
*/
|
||||
@ -645,11 +645,11 @@ void sf_write_sync (SNDFILE *sndfile) ;
|
||||
** In order for this to work, you need to do the following:
|
||||
**
|
||||
** #include <windows.h>
|
||||
** #define ENABLE_SNDFILE_WINDOWS_PROTOTYPES
|
||||
** #define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1
|
||||
** #including <sndfile.h>
|
||||
*/
|
||||
|
||||
#ifdef ENABLE_SNDFILE_WINDOWS_PROTOTYPES
|
||||
#if ENABLE_SNDFILE_WINDOWS_PROTOTYPES
|
||||
SNDFILE* sf_wchar_open (LPCWSTR wpath, int mode, SF_INFO *sfinfo) ;
|
||||
#endif
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
#if OS_IS_WIN32
|
||||
#include <windows.h>
|
||||
|
||||
#define ENABLE_SNDFILE_WINDOWS_PROTOTYPES
|
||||
#define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1
|
||||
#include "sndfile.h"
|
||||
#include "common.h"
|
||||
|
||||
|
@ -26,6 +26,10 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if OS_IS_WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#include "utils.h"
|
||||
@ -203,8 +207,22 @@ error_close_test (void)
|
||||
fclose (file) ;
|
||||
|
||||
if (sf_close (sndfile) == 0)
|
||||
{ printf ("\n\nLine %d : sf_close should not have returned zero.\n", __LINE__) ;
|
||||
{
|
||||
#if OS_IS_WIN32
|
||||
OSVERSIONINFOEX osvi ;
|
||||
|
||||
memset (&osvi, 0, sizeof (OSVERSIONINFOEX)) ;
|
||||
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX) ;
|
||||
|
||||
if (GetVersionEx ((OSVERSIONINFO *) &osvi))
|
||||
{ printf ("\n\nLine %d : sf_close should not have returned zero.\n", __LINE__) ;
|
||||
printf ("\nHowever, this is a known bug in version %d.%d of windows so we'll ignore it.\n\n",
|
||||
(int) osvi.dwMajorVersion, (int) osvi.dwMinorVersion) ;
|
||||
} ;
|
||||
#else
|
||||
printf ("\n\nLine %d : sf_close should not have returned zero.\n", __LINE__) ;
|
||||
exit (1) ;
|
||||
#endif
|
||||
} ;
|
||||
|
||||
unlink (filename) ;
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
#if OS_IS_WIN32
|
||||
#include <windows.h>
|
||||
#define ENABLE_SNDFILE_WINDOWS_PROTOTYPES
|
||||
#define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1
|
||||
#endif
|
||||
|
||||
#include "sndfile.h"
|
||||
|
@ -131,15 +131,13 @@ multi_file_test (const char *filename, int *formats, int format_count)
|
||||
SF_INFO sfinfo ;
|
||||
SF_EMBED_FILE_INFO embed_info ;
|
||||
sf_count_t filelen ;
|
||||
int fd, k, file_count = 0, open_perm ;
|
||||
int fd, k, file_count = 0 ;
|
||||
|
||||
print_test_name ("multi_file_test", filename) ;
|
||||
|
||||
unlink (filename) ;
|
||||
|
||||
open_perm = OS_IS_WIN32 ? 0 : S_IRUSR | S_IWUSR | S_IRGRP ;
|
||||
|
||||
if ((fd = open (filename, O_RDWR | O_CREAT, open_perm)) < 0)
|
||||
if ((fd = open (filename, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR)) < 0)
|
||||
{ printf ("\n\nLine %d: open failed : %s\n", __LINE__, strerror (errno)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
@ -40,7 +40,8 @@
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#if (OS_IS_WIN32)
|
||||
/* EMX is OS/2. */
|
||||
#if (OS_IS_WIN32) || defined (__EMX__)
|
||||
|
||||
int
|
||||
main (void)
|
||||
|
@ -39,6 +39,7 @@ main (void)
|
||||
vio_test ("vio_pcm16.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ;
|
||||
vio_test ("vio_pcm24.aiff", SF_FORMAT_AIFF | SF_FORMAT_PCM_24) ;
|
||||
vio_test ("vio_float.au", SF_FORMAT_AU | SF_FORMAT_FLOAT) ;
|
||||
vio_test ("vio_pcm24.paf", SF_FORMAT_PAF | SF_FORMAT_PCM_24) ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
@ -189,6 +190,11 @@ vio_test (const char *fname, int format)
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (vfget_filelen (&vio_data) < 0)
|
||||
{ printf ("\n\nLine %d : vfget_filelen returned negative length.\n\n", __LINE__) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
gen_short_data (data, ARRAY_LEN (data), 0) ;
|
||||
sf_write_short (file, data, ARRAY_LEN (data)) ;
|
||||
|
||||
|
@ -38,7 +38,8 @@
|
||||
|
||||
#define SIGNED_SIZEOF(x) ((int) sizeof (x))
|
||||
|
||||
#if defined (__CYGWIN__)
|
||||
/* EMX is OS/2. */
|
||||
#if defined (__CYGWIN__) || defined (__EMX__)
|
||||
|
||||
#define LSEEK lseek
|
||||
#define FSTAT fstat
|
||||
@ -74,6 +75,7 @@
|
||||
static void show_fstat_error (void) ;
|
||||
static void show_lseek_error (void) ;
|
||||
static void show_stat_fstat_error (void) ;
|
||||
static void write_to_closed_file (void) ;
|
||||
|
||||
int
|
||||
main (void)
|
||||
@ -88,6 +90,7 @@ main (void)
|
||||
show_fstat_error () ;
|
||||
show_lseek_error () ;
|
||||
show_stat_fstat_error () ;
|
||||
write_to_closed_file () ;
|
||||
|
||||
puts ("\n\n") ;
|
||||
|
||||
@ -254,7 +257,7 @@ show_stat_fstat_error (void)
|
||||
} ;
|
||||
fstat_size = buf.st_size ;
|
||||
|
||||
printf ("3) Size returned by stat and fstat is %d and %d, ", stat_size, fstat_size) ;
|
||||
printf ("2) Size returned by stat and fstat is %d and %d, ", stat_size, fstat_size) ;
|
||||
|
||||
|
||||
if (stat_size == 0 || stat_size != fstat_size)
|
||||
@ -271,3 +274,44 @@ error_exit :
|
||||
} /* show_stat_fstat_error */
|
||||
|
||||
|
||||
static void
|
||||
write_to_closed_file (void)
|
||||
{ const char * filename = "closed_write_test.txt" ;
|
||||
struct stat buf ;
|
||||
FILE * file ;
|
||||
int fd, ignored ;
|
||||
|
||||
puts ("\nWrite to closed file test.\n--------------------------") ;
|
||||
|
||||
printf ("0) First we open file for write using fopen().\n") ;
|
||||
if ((file = fopen (filename, "w")) == NULL)
|
||||
{ printf ("\n\nLine %d: fopen() failed : %s\n\n", __LINE__, strerror (errno)) ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
printf ("1) Now we grab the file descriptor fileno().\n") ;
|
||||
fd = fileno (file) ;
|
||||
|
||||
printf ("2) Write some text via the file descriptor.\n") ;
|
||||
ignored = write (fd, "a\n", 2) ;
|
||||
|
||||
printf ("3) Now we close the file using fclose().\n") ;
|
||||
fclose (file) ;
|
||||
|
||||
stat (filename, &buf);
|
||||
printf (" File size is %d bytes.\n", (int) buf.st_size) ;
|
||||
|
||||
printf ("4) Now write more data to the file descriptor which should fail.\n") ;
|
||||
if (write (fd, "b\n", 2) < 0)
|
||||
printf ("5) Good, write returned an error code as it should have.\n") ;
|
||||
else
|
||||
{ printf ("5) Attempting to write to a closed file should have failed but didn't! *** WRONG ***\n") ;
|
||||
|
||||
stat (filename, &buf);
|
||||
printf (" File size is %d bytes.\n", (int) buf.st_size) ;
|
||||
} ;
|
||||
|
||||
unlink (filename) ;
|
||||
|
||||
return ;
|
||||
} /* write_to_closed_file */
|
||||
|
Loading…
Reference in New Issue
Block a user