mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-20 10:26:51 +00:00
FS-4657 --resolve update libsndfile to its latest master
This commit is contained in:
parent
0c1f6ef2ed
commit
199a64bf6a
@ -1 +1 @@
|
||||
Wed Aug 28 03:22:32 CDT 2013
|
||||
Fri Feb 28 03:45:32 CDT 2014
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
EXTRA_DIST = add_cflags.m4 clip_mode.m4 endian.m4 extra_largefile.m4 \
|
||||
EXTRA_DIST = add_cflags.m4 clip_mode.m4 endian.m4 \
|
||||
flexible_array.m4 llrint.m4 lrint.m4 lrintf.m4 octave.m4 extra_pkg.m4
|
||||
|
||||
|
@ -1,17 +1,18 @@
|
||||
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"
|
||||
CFLAGS="$1"
|
||||
AC_TRY_LINK([
|
||||
#include <stdio.h>
|
||||
],
|
||||
[puts("Hello, World!"); return 0;],
|
||||
AC_MSG_RESULT([yes]),
|
||||
AC_MSG_RESULT([yes])
|
||||
CFLAGS="$ac_add_cflags__old_cflags $1",
|
||||
AC_MSG_RESULT([no])
|
||||
CFLAGS="$ac_add_cflags__old_cflags"
|
||||
CFLAGS="$ac_add_cflags__old_cflags"
|
||||
)
|
||||
])# AC_ADD_CFLAGS
|
||||
])# MN_ADD_CFLAGS
|
||||
|
@ -1,17 +1,19 @@
|
||||
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_LANG_ASSERT([C++])
|
||||
ac_add_cxxflags__old_cxxflags="$CXXFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS $1"
|
||||
CXXFLAGS="$1"
|
||||
AC_TRY_LINK([
|
||||
#include <cstdio>
|
||||
],
|
||||
[puts("Hello, World!"); return 0;],
|
||||
AC_MSG_RESULT([yes]),
|
||||
AC_MSG_RESULT([yes])
|
||||
CXXFLAGS="$ac_add_cxxflags__old_cxxflags $1",
|
||||
AC_MSG_RESULT([no])
|
||||
CXXFLAGS="$ac_add_cxxflags__old_cxxflags"
|
||||
CXXFLAGS="$ac_add_cxxflags__old_cxxflags"
|
||||
)
|
||||
])# AC_ADD_CXXFLAGS
|
||||
])# MN_ADD_CXXFLAGS
|
||||
|
31
libs/libsndfile/M4/clang.m4
Normal file
31
libs/libsndfile/M4/clang.m4
Normal file
@ -0,0 +1,31 @@
|
||||
dnl @synopsis MN_C_COMPILER_IS_CLANG
|
||||
dnl
|
||||
dnl Find out if a compiler claiming to be gcc really is gcc (fuck you clang).
|
||||
dnl @version 1.0 Oct 31 2013
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
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([MN_C_COMPILER_IS_CLANG],
|
||||
[AC_CACHE_CHECK(whether we are using the CLANG C compiler,
|
||||
mn_cv_c_compiler_clang,
|
||||
[ AC_LANG_ASSERT(C)
|
||||
AC_TRY_LINK([
|
||||
#include <stdio.h>
|
||||
],
|
||||
[
|
||||
#ifndef __clang__
|
||||
This is not clang!
|
||||
#endif
|
||||
],
|
||||
mn_cv_c_compiler_clang=yes,
|
||||
mn_cv_c_compiler_clang=no
|
||||
])
|
||||
)
|
||||
])
|
@ -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,
|
||||
|
||||
@ -92,13 +92,11 @@ if test $ac_cv_c_byte_order = unknown ; then
|
||||
[
|
||||
case "$target_cpu" in
|
||||
alpha* | i?86* | mipsel* | ia64*)
|
||||
ac_cv_c_big_endian=0
|
||||
ac_cv_c_little_endian=1
|
||||
ac_cv_c_byte_order=little
|
||||
;;
|
||||
|
||||
m68* | mips* | powerpc* | hppa* | sparc*)
|
||||
ac_cv_c_big_endian=1
|
||||
ac_cv_c_little_endian=0
|
||||
ac_cv_c_byte_order=big
|
||||
;;
|
||||
|
||||
esac
|
||||
@ -116,7 +114,6 @@ if test $ac_cv_c_byte_order = unknown ; then
|
||||
return (u.c [sizeof (long) - 1] == 1);
|
||||
}
|
||||
]], , ac_cv_c_byte_order=big,
|
||||
ac_cv_c_byte_order=unknown
|
||||
)
|
||||
|
||||
AC_TRY_RUN(
|
||||
@ -129,7 +126,6 @@ if test $ac_cv_c_byte_order = unknown ; then
|
||||
u.l = 1 ;
|
||||
return (u.c [0] == 1);
|
||||
}]], , ac_cv_c_byte_order=little,
|
||||
ac_cv_c_byte_order=unknown
|
||||
)
|
||||
fi
|
||||
fi
|
||||
@ -154,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,5 +1,6 @@
|
||||
# extra_pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
|
||||
#
|
||||
#
|
||||
# Copyright (c) 2008-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
# Copyright (c) 2004 Scott James Remnant <scott@netsplit.com>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
@ -40,6 +41,25 @@ AC_MSG_CHECKING([for $2 ])
|
||||
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
|
||||
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
|
||||
|
||||
pkg_link_saved_CFLAGS=$CFLAGS
|
||||
pkg_link_saved_LIBS=$LIBS
|
||||
|
||||
eval "pkg_CFLAGS=\${pkg_cv_[]$1[]_CFLAGS}"
|
||||
eval "pkg_LIBS=\${pkg_cv_[]$1[]_LIBS}"
|
||||
|
||||
CFLAGS="$CFLAGS $pkg_CFLAGS"
|
||||
LIBS="$LIBS $pkg_LIBS"
|
||||
|
||||
AC_TRY_LINK([], puts ("");, pkg_link=yes, pkg_link=no)
|
||||
|
||||
CFLAGS=$pkg_link_saved_CFLAGS
|
||||
LIBS=$pkg_link_saved_LIBS
|
||||
|
||||
if test $pkg_link = no ; then
|
||||
$as_echo_n "link failed ... "
|
||||
pkg_failed=yes
|
||||
fi
|
||||
|
||||
m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
|
||||
and $1[]_LIBS to avoid the need to call pkg-config.
|
||||
See the pkg-config man page for more details.])
|
||||
@ -48,7 +68,7 @@ if test $pkg_failed = yes; then
|
||||
_PKG_SHORT_ERRORS_SUPPORTED
|
||||
if test $_pkg_short_errors_supported = yes; then
|
||||
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
|
||||
else
|
||||
else
|
||||
$1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
|
||||
fi
|
||||
# Put the nasty error message in config.log where it belongs
|
||||
|
@ -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
|
||||
|
||||
@ -20,8 +20,8 @@ if test "x$ac_cv_c_compiler_gnu" = "xyes" ; then
|
||||
AC_MSG_RESULT($GCC_VERSION)
|
||||
|
||||
changequote(,)dnl
|
||||
GCC_MINOR_VERSION=`echo $GCC_VERSION | sed "s/^[0-9]\+\.//" | sed "s/\..*//"`
|
||||
GCC_MAJOR_VERSION=`echo $GCC_VERSION | sed "s/\..*//"`
|
||||
GCC_MINOR_VERSION=`echo $GCC_VERSION | sed "s/$GCC_MAJOR_VERSION\.//" | sed "s/\..*//"`
|
||||
changequote([,])dnl
|
||||
fi
|
||||
|
||||
@ -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
|
||||
|
||||
|
@ -18,10 +18,10 @@ dnl Find the version of Octave.
|
||||
dnl @version 1.0 Aug 23 2007
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
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 made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
dnl
|
||||
|
||||
@ -52,10 +52,10 @@ dnl Find the version of Octave.
|
||||
dnl @version 1.0 Aug 23 2007
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
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 made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
dnl
|
||||
|
||||
@ -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"
|
||||
@ -119,7 +119,7 @@ if test "x$prog_concat" = "xyesyesyes" ; then
|
||||
2.*)
|
||||
AC_MSG_WARN([Octave version 2.X is not supported.])
|
||||
;;
|
||||
3.0.*)
|
||||
3.*)
|
||||
OCTAVE_DEST_ODIR=`$OCTAVE_CONFIG --oct-site-dir | sed 's%^/usr%${prefix}%'`
|
||||
OCTAVE_DEST_MDIR=`$OCTAVE_CONFIG --m-site-dir | sed 's%^/usr%${prefix}%'`
|
||||
|
||||
|
33
libs/libsndfile/M4/really_gcc.m4
Normal file
33
libs/libsndfile/M4/really_gcc.m4
Normal file
@ -0,0 +1,33 @@
|
||||
dnl @synopsis MN_GCC_REALLY_IS_GCC
|
||||
dnl
|
||||
dnl Find out if a compiler claiming to be gcc really is gcc (fuck you clang).
|
||||
dnl @version 1.0 Oct 31 2013
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
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
|
||||
|
||||
# If the configure script has already detected GNU GCC, then make sure it
|
||||
# isn't CLANG masquerading as GCC.
|
||||
|
||||
AC_DEFUN([MN_GCC_REALLY_IS_GCC],
|
||||
[ AC_LANG_ASSERT(C)
|
||||
if test "x$ac_cv_c_compiler_gnu" = "xyes" ; then
|
||||
AC_TRY_LINK([
|
||||
#include <stdio.h>
|
||||
],
|
||||
[
|
||||
#ifdef __clang__
|
||||
This is clang!
|
||||
#endif
|
||||
],
|
||||
ac_cv_c_compiler_gnu=yes,
|
||||
ac_cv_c_compiler_gnu=no
|
||||
)
|
||||
fi
|
||||
|
||||
])
|
73
libs/libsndfile/M4/stack_protect.m4
Normal file
73
libs/libsndfile/M4/stack_protect.m4
Normal file
@ -0,0 +1,73 @@
|
||||
dnl Copyright (C) 2013 Xiph.org Foundation
|
||||
dnl
|
||||
dnl Redistribution and use in source and binary forms, with or without
|
||||
dnl modification, are permitted provided that the following conditions
|
||||
dnl are met:
|
||||
dnl
|
||||
dnl - Redistributions of source code must retain the above copyright
|
||||
dnl notice, this list of conditions and the following disclaimer.
|
||||
dnl
|
||||
dnl - Redistributions in binary form must reproduce the above copyright
|
||||
dnl notice, this list of conditions and the following disclaimer in the
|
||||
dnl documentation and/or other materials provided with the distribution.
|
||||
dnl
|
||||
dnl - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
dnl contributors may be used to endorse or promote products derived from
|
||||
dnl this software without specific prior written permission.
|
||||
dnl
|
||||
dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
dnl ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
dnl CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
dnl EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
dnl PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
dnl PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
dnl LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
dnl NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
dnl SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
dnl Want to know of GCC stack protector works, botfor the C and for the C++
|
||||
dnl compiler.
|
||||
dnl
|
||||
dnl Just checking if the compiler accepts the required CFLAGSs is not enough
|
||||
dnl because we have seen at least one instance where this check was
|
||||
dnl in-sufficient.
|
||||
dnl
|
||||
dnl Instead, try to compile and link a test program with the stack protector
|
||||
dnl flags. If that works, we use it.
|
||||
|
||||
AC_DEFUN([XIPH_GCC_STACK_PROTECTOR],
|
||||
[AC_LANG_ASSERT(C)
|
||||
AC_MSG_CHECKING([if $CC supports stack smash protection])
|
||||
xiph_stack_check_old_cflags="$CFLAGS"
|
||||
SSP_FLAGS="-fstack-protector --param ssp-buffer-size=4"
|
||||
CFLAGS=$SSP_FLAGS
|
||||
AC_TRY_LINK([
|
||||
#include <stdio.h>
|
||||
],
|
||||
[puts("Hello, World!"); return 0;],
|
||||
AC_MSG_RESULT([yes])
|
||||
CFLAGS="$xiph_stack_check_old_cflags $SSP_FLAGS",
|
||||
AC_MSG_RESULT([no])
|
||||
CFLAGS="$xiph_stack_check_old_cflags"
|
||||
)
|
||||
])# XIPH_GCC_STACK_PROTECTOR
|
||||
|
||||
AC_DEFUN([XIPH_GXX_STACK_PROTECTOR],
|
||||
[AC_LANG_PUSH([C++])
|
||||
AC_MSG_CHECKING([if $CXX supports stack smash protection])
|
||||
xiph_stack_check_old_cflags="$CFLAGS"
|
||||
SSP_FLAGS="-fstack-protector --param ssp-buffer-size=4"
|
||||
CFLAGS=$SSP_FLAGS
|
||||
AC_TRY_LINK([
|
||||
#include <cstdio>
|
||||
],
|
||||
[puts("Hello, World!"); return 0;],
|
||||
AC_MSG_RESULT([yes])
|
||||
CFLAGS="$xiph_stack_check_old_cflags $SSP_FLAGS",
|
||||
AC_MSG_RESULT([no])
|
||||
CFLAGS="$xiph_stack_check_old_cflags"
|
||||
)
|
||||
AC_LANG_POP([C++])
|
||||
])# XIPH_GXX_STACK_PROTECTOR
|
@ -1,29 +1,44 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
DISTCHECK_CONFIGURE_FLAGS = --enable-gcc-werror
|
||||
|
||||
if BUILD_OCTAVE_MOD
|
||||
octave_dir = Octave
|
||||
endif
|
||||
|
||||
SUBDIRS = M4 Win32 src $(octave_dir)
|
||||
#man doc examples regtest tests programs
|
||||
|
||||
DIST_SUBDIRS = M4 man doc Win32 src Octave examples regtest tests programs
|
||||
|
||||
EXTRA_DIST = libsndfile.spec.in sndfile.pc.in Mingw-make-dist.sh
|
||||
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = sndfile.pc
|
||||
|
||||
m4datadir = $(datadir)/aclocal
|
||||
|
||||
test: check-recursive
|
||||
|
||||
# Target to make autogenerated files.
|
||||
genfiles :
|
||||
(cd src ; make genfiles)
|
||||
(cd tests ; make genfiles)
|
||||
|
||||
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
ACLOCAL_AMFLAGS = -I M4
|
||||
|
||||
DISTCHECK_CONFIGURE_FLAGS = --enable-gcc-werror
|
||||
|
||||
if BUILD_OCTAVE_MOD
|
||||
octave_dir = Octave
|
||||
endif
|
||||
|
||||
SUBDIRS = M4 man doc Win32 src $(octave_dir) examples regtest tests programs
|
||||
DIST_SUBDIRS = M4 man doc Win32 src Octave examples regtest tests programs
|
||||
|
||||
EXTRA_DIST = libsndfile.spec.in sndfile.pc.in Scripts/android-configure.sh \
|
||||
Scripts/linux-to-win-cross-configure.sh Scripts/build-test-tarball.mk.in
|
||||
|
||||
CLEANFILES = *~
|
||||
|
||||
pkgconfig_DATA = sndfile.pc
|
||||
|
||||
m4datadir = $(datadir)/aclocal
|
||||
|
||||
#===============================================================================
|
||||
|
||||
test: check-recursive
|
||||
|
||||
# Target to make autogenerated files.
|
||||
genfiles :
|
||||
(cd src ; make genfiles)
|
||||
(cd tests ; make genfiles)
|
||||
|
||||
checkprograms :
|
||||
(cd src ; make libsndfile.la checkprograms)
|
||||
(cd tests ; make checkprograms)
|
||||
|
||||
testprogs :
|
||||
(cd src ; make testprogs)
|
||||
(cd tests ; make testprogs)
|
||||
|
||||
|
||||
test-tarball : Scripts/build-test-tarball.mk
|
||||
(cd src ; make all libsndfile.la checkprograms)
|
||||
(cd tests ; make all checkprograms)
|
||||
make -f Scripts/build-test-tarball.mk
|
||||
|
@ -1,3 +1,37 @@
|
||||
Version 1.0.25 (2011-07-13)
|
||||
* Fix for Secunia Advisory SA45125, heap overflow in PAF file handler.
|
||||
* Accept broken WAV files with blockalign == 0.
|
||||
* Minor bug fixes and improvements.
|
||||
|
||||
Version 1.0.24 (2011-03-23)
|
||||
* WAV files now have an 18 byte u-law and A-law fmt chunk.
|
||||
* Document virtual I/O functionality.
|
||||
* Two new methods rawHandle() and takeOwnership() in sndfile.hh.
|
||||
* AIFF fix for non-zero offset value in SSND chunk.
|
||||
* Minor bug fixes and improvements.
|
||||
|
||||
Version 1.0.23 (2010-10-10)
|
||||
* Add version metadata to Windows DLL.
|
||||
* Add a missing 'inline' to sndfile.hh.
|
||||
* Update docs.
|
||||
* Minor bug fixes and improvements.
|
||||
|
||||
Version 1.0.22 (2010-10-04)
|
||||
* Couple of fixes for SDS file writer.
|
||||
* Fixes arising from static analysis.
|
||||
* Handle FLAC files with ID3 meta data at start of file.
|
||||
* Handle FLAC files which report zero length.
|
||||
* Other minor bug fixes and improvements.
|
||||
|
||||
Version 1.0.21 (2009-12-13)
|
||||
* Add a couple of new binary programs to programs/ dir.
|
||||
* Remove sndfile-jackplay (now in sndfile-tools package).
|
||||
* Add windows only function sf_wchar_open().
|
||||
* Bunch of minor bug fixes.
|
||||
|
||||
Version 1.0.20 (2009-05-14)
|
||||
* Fix potential heap overflow in VOC file parser (Tobias Klein, http://www.trapkit.de/).
|
||||
|
||||
Version 1.0.19 (2009-03-02)
|
||||
* Fix for CVE-2009-0186 (Alin Rad Pop, Secunia Research).
|
||||
* Huge number of minor bug fixes as a result of static analysis.
|
||||
|
@ -21,7 +21,7 @@ OCT_LIB_DIR = @OCT_LIB_DIR@
|
||||
OCT_LIBS = @OCT_LIBS@
|
||||
|
||||
SNDFILEDIR = $(top_builddir)/src
|
||||
INCLUDES = -I$(SNDFILEDIR)
|
||||
AM_CPPFLAGS = -I$(SNDFILEDIR)
|
||||
|
||||
oct_module_srcs = sndfile.cc
|
||||
oct_module_files = sndfile.oct PKG_ADD
|
||||
@ -30,13 +30,19 @@ oct_module_files = sndfile.oct PKG_ADD
|
||||
noinst_DATA = $(oct_module_files)
|
||||
|
||||
|
||||
# Used by shave which cleans up automake generated Makefile output.
|
||||
V = @
|
||||
Q = $(V:1=)
|
||||
QUIET_GEN = $(Q:@=@echo ' GEN '$@;)
|
||||
|
||||
|
||||
# Use Octave's mkoctfile to do all the heavy lifting. Unfortunately, its
|
||||
# a little dumb so we need to guide it carefully.
|
||||
sndfile.oct : sndfile.o
|
||||
$(MKOCTFILE) -v $(INCLUDES) $(top_builddir)/Octave/$+ -L$(SNDFILEDIR)/.libs -L$(SNDFILEDIR) -lsndfile -o $(top_builddir)/Octave/$@
|
||||
$(QUIET_GEN) $(MKOCTFILE) -v $(INCLUDES) $(top_builddir)/Octave/$+ -L$(SNDFILEDIR)/.libs -L$(SNDFILEDIR) -lsndfile -o $(top_builddir)/Octave/$@ > /dev/null
|
||||
|
||||
sndfile.o : sndfile.cc
|
||||
$(MKOCTFILE) -v $(INCLUDES) -c $+ -o $(top_builddir)/Octave/$@
|
||||
$(QUIET_GEN) $(MKOCTFILE) -v $(INCLUDES) -c $+ -o $(top_builddir)/Octave/$@ > /dev/null
|
||||
|
||||
# Allow for the test being run in the build dir, but the test script
|
||||
# being located in the source dir.
|
||||
@ -70,3 +76,4 @@ uninstall-local :
|
||||
|
||||
clean-local :
|
||||
rm -f sndfile.o sndfile.oct
|
||||
@if test $(abs_builddir) != $(abs_srcdir) ; then rm -f PKG_ADD ; fi
|
||||
|
23
libs/libsndfile/Octave/Readme.txt
Normal file
23
libs/libsndfile/Octave/Readme.txt
Normal file
@ -0,0 +1,23 @@
|
||||
The libsndfile Modules for GNU Octave
|
||||
=====================================
|
||||
|
||||
These modules are currently known to work with version 3.0 of GNU Octave on
|
||||
Linux. They have not been tested elsewhere.
|
||||
|
||||
|
||||
Build Requirements
|
||||
------------------
|
||||
|
||||
In order to build these libsndfile related modules for GNU Octave on a Debian
|
||||
GNU/Linux (or Debian derived) system, you will need (on top of what is normally
|
||||
required to build libsndfile) the package:
|
||||
|
||||
octaveX.Y-headers
|
||||
|
||||
where X.Y matches the version number of your installation of GNU Octave.
|
||||
|
||||
The configure script in the top level libsndfile directory will detect the
|
||||
presence and correct versions of the Octave build tools. The building of these
|
||||
modules will only go ahead if everything is correct.
|
||||
|
||||
|
21
libs/libsndfile/Octave/format.h
Normal file
21
libs/libsndfile/Octave/format.h
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
** Copyright (C) 2007-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU Lesser General Public License as published by
|
||||
** the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU Lesser 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.
|
||||
*/
|
||||
|
||||
int format_of_str (const std::string & fmt) ;
|
||||
|
||||
void string_of_format (std::string & fmt, int format) ;
|
@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2007 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
# Copyright (C) 2007-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
@ -16,9 +16,7 @@
|
||||
|
||||
# These tests are nowhere near comprehensive.
|
||||
|
||||
printf ("\n\n\n\n\n\n\n") ;
|
||||
|
||||
printf (" Running Octave tests : ") ;
|
||||
printf (" Running Octave tests : ") ;
|
||||
fflush (stdout) ;
|
||||
|
||||
filename = "whatever" ;
|
||||
@ -51,6 +49,4 @@ if (err > 1e-7)
|
||||
|
||||
printf ("ok") ;
|
||||
|
||||
printf ("\n\n\n\n\n\n\n") ;
|
||||
|
||||
unlink (filename) ;
|
||||
|
@ -2,28 +2,34 @@
|
||||
|
||||
|
||||
# Check where we're being run from.
|
||||
if [ -d Octave ]; then
|
||||
if test -d Octave ; then
|
||||
cd Octave
|
||||
octave_src_dir=$(pwd)
|
||||
elif test -z "$octave_src_dir" ; then
|
||||
echo
|
||||
echo "Error : \$octave_src_dir is undefined."
|
||||
echo
|
||||
exit 1
|
||||
else
|
||||
octave_src_dir=$(cd $octave_src_dir && pwd)
|
||||
fi
|
||||
|
||||
# Find libsndfile shared object.
|
||||
libsndfile_lib_location=""
|
||||
|
||||
if [ -f "../src/.libs/libsndfile.so" ]; then
|
||||
if test -f "../src/.libs/libsndfile.so" ; then
|
||||
libsndfile_lib_location="../src/.libs/"
|
||||
elif [ -f "../src/libsndfile.so" ]; then
|
||||
elif test -f "../src/libsndfile.so" ; then
|
||||
libsndfile_lib_location="../src/"
|
||||
elif [ -f "../src/.libs/libsndfile.dylib" ]; then
|
||||
elif test -f "../src/.libs/libsndfile.dylib" ; then
|
||||
libsndfile_lib_location="../src/.libs/"
|
||||
elif [ -f "../src/libsndfile.dylib" ]; then
|
||||
elif test -f "../src/libsndfile.dylib" ; then
|
||||
libsndfile_lib_location="../src/"
|
||||
else
|
||||
echo
|
||||
echo
|
||||
echo "Not able to find the libsndfile shared lib we've just built."
|
||||
echo "This may cause the following test to fail."
|
||||
echo
|
||||
echo
|
||||
fi
|
||||
|
||||
libsndfile_lib_location=`(cd $libsndfile_lib_location && pwd)`
|
||||
@ -32,9 +38,9 @@ libsndfile_lib_location=`(cd $libsndfile_lib_location && pwd)`
|
||||
# Find sndfile.oct
|
||||
sndfile_oct_location=""
|
||||
|
||||
if [ -f .libs/sndfile.oct ]; then
|
||||
if test -f .libs/sndfile.oct ; then
|
||||
sndfile_oct_location=".libs"
|
||||
elif [ -f sndfile.oct ]; then
|
||||
elif test -f sndfile.oct ; then
|
||||
sndfile_oct_location="."
|
||||
else
|
||||
echo "Not able to find the sndfile.oct binaries we've just built."
|
||||
@ -49,7 +55,7 @@ case `file -b $sndfile_oct_location/sndfile.oct` in
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Not able to find the sndfile.oct binaries we've just built."
|
||||
echo "Not able to find the sndfile.oct binary we just built."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@ -57,16 +63,19 @@ case `file -b $sndfile_oct_location/sndfile.oct` in
|
||||
|
||||
# Make sure the TERM environment variable doesn't contain anything wrong.
|
||||
unset TERM
|
||||
|
||||
# echo "octave_src_dir : $octave_src_dir"
|
||||
# echo "libsndfile_lib_location : $libsndfile_lib_location"
|
||||
# echo "sndfile_oct_location : $sndfile_oct_location"
|
||||
|
||||
export LD_LIBRARY_PATH="$libsndfile_lib_location:$LD_LIBRARY_PATH"
|
||||
if test ! -f PKG_ADD ; then
|
||||
cp $octave_src_dir/PKG_ADD .
|
||||
fi
|
||||
|
||||
octave_src_dir=`(cd $octave_src_dir && pwd)`
|
||||
export LD_LIBRARY_PATH="$libsndfile_lib_location:$LD_LIBRARY_PATH"
|
||||
|
||||
octave_script="$octave_src_dir/octave_test.m"
|
||||
|
||||
(cd $sndfile_oct_location && octave -qH $octave_script)
|
||||
|
||||
|
||||
res=$?
|
||||
echo
|
||||
exit $res
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2007 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2007-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU Lesser General Public License as published by
|
||||
@ -367,7 +367,7 @@ string_of_minor_format (int format)
|
||||
case SF_FORMAT_G723_40 : return "g723_40" ;
|
||||
default : break ;
|
||||
} ;
|
||||
|
||||
|
||||
return "unknown" ;
|
||||
} /* string_of_minor_format */
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
## Copyright (C) 2002 Erik de Castro Lopo
|
||||
## Copyright (C) 2002-2011 Erik de Castro Lopo
|
||||
##
|
||||
## 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
|
||||
@ -33,7 +33,7 @@ samplingrate = -1 ;
|
||||
wavedata = -1 ;
|
||||
|
||||
|
||||
eval (sprintf ('load -f %s', filename)) ;
|
||||
eval (sprintf ('load -f %s', filename)) ;
|
||||
|
||||
if (samplerate > 0),
|
||||
fs = samplerate ;
|
||||
@ -42,7 +42,7 @@ elseif (samplingrate > 0),
|
||||
else
|
||||
error ("Not able to find sample rate.") ;
|
||||
endif
|
||||
|
||||
|
||||
if (max (size (wavedata)) > 1),
|
||||
data = wavedata ;
|
||||
else
|
||||
|
@ -1,4 +1,4 @@
|
||||
## Copyright (C) 2002 Erik de Castro Lopo
|
||||
## Copyright (C) 2002-2011 Erik de Castro Lopo
|
||||
##
|
||||
## 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
|
||||
|
@ -1,4 +1,4 @@
|
||||
## Copyright (C) 2002 Erik de Castro Lopo
|
||||
## Copyright (C) 2002-2011 Erik de Castro Lopo
|
||||
##
|
||||
## 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
|
||||
|
@ -1,4 +1,4 @@
|
||||
This is libsndfile, 1.0.19
|
||||
This is libsndfile, 1.0.25
|
||||
|
||||
libsndfile is a library of C routines for reading and writing
|
||||
files containing sampled audio data.
|
||||
@ -20,6 +20,9 @@ Bormann. Their original code can be found at :
|
||||
The src/G72x directory contains code written and released by Sun Microsystems
|
||||
under a suitably free license.
|
||||
|
||||
The src/ALAC directory contains code written and released by Apple Inc and
|
||||
released under the Apache license.
|
||||
|
||||
|
||||
LINUX
|
||||
-----
|
||||
|
79
libs/libsndfile/README.md
Normal file
79
libs/libsndfile/README.md
Normal file
@ -0,0 +1,79 @@
|
||||
# libsndfile
|
||||
|
||||
libsndfile is a C library for reading and writing files containing sampled audio
|
||||
data.
|
||||
|
||||
## Hacking
|
||||
|
||||
The canonical source code repository for libsndfile is at
|
||||
[https://github.com/erikd/libsndfile/][github].
|
||||
|
||||
You can grab the source code using:
|
||||
|
||||
$ git clone git://github.com/erikd/libsndfile.git
|
||||
|
||||
Building on Linux, OSX and Windows (Using GNU GCC) will require a number of GNU
|
||||
and other Free and Open Source Software tools including:
|
||||
|
||||
* [Autoconf][autoconf]
|
||||
* [Autogen][autogen]
|
||||
* [Automake][automake]
|
||||
* [Libtool][libtool]
|
||||
* [Pkgconfig][pkgconfig]
|
||||
* [Python][python]
|
||||
|
||||
If you are on Linux, its probably best to install these via your Linux
|
||||
distribution's package manager.
|
||||
|
||||
If you want to compile libsndfile with support for formats like FLAC and
|
||||
Ogg/Vorbis you will also need to install the following optional libraries:
|
||||
|
||||
* [FLAC][flac]
|
||||
* [libogg][libogg]
|
||||
* [libvorbis][libvorbis]
|
||||
|
||||
Support for these extra libraries is an all or nothing affair. Unless all of
|
||||
them are installed none of them will be supported.
|
||||
|
||||
$ ./autogen.sh
|
||||
|
||||
Running `autogen.sh` also installs a git pre-commit hook. The pre-commit hook
|
||||
is run each time a user tries to commit and checks code about to be committed
|
||||
against coding guidelines.
|
||||
|
||||
Nest step is to run configure, with the following configure options being
|
||||
recommended for anyone contemplating sending libsndfile patches:
|
||||
|
||||
$ ./configure --enable-gcc-werror
|
||||
|
||||
Finally libsndfile can be built and tested:
|
||||
|
||||
$ make
|
||||
$ make check
|
||||
|
||||
## Submitting Patches.
|
||||
|
||||
* Patches should pass all pre-commit hook tests.
|
||||
* Patches should always be submitted via a either Github "pull request" or a
|
||||
via emailed patches created using "git format-patch".
|
||||
* Patches for new features should include tests and documentation.
|
||||
* Patches to fix bugs should either pass all tests, or modify the tests in some
|
||||
sane way.
|
||||
* When a new feature is added for a particular file format and that feature
|
||||
makes sense for other formats, then it should also be implemented for one
|
||||
or two of the other formats.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[autoconf]: http://www.gnu.org/s/autoconf/
|
||||
[autogen]: http://www.gnu.org/s/autogen/
|
||||
[automake]: http://www.gnu.org/software/automake/
|
||||
[flac]: http://flac.sourceforge.net/
|
||||
[github]: https://github.com/erikd/libsndfile/
|
||||
[libogg]: http://xiph.org/ogg/
|
||||
[libtool]: http://www.gnu.org/software/libtool/
|
||||
[libvorbis]: http://www.vorbis.com/
|
||||
[pkgconfig]: http://www.freedesktop.org/wiki/Software/pkg-config
|
||||
[python]: http://www.python.org/
|
92
libs/libsndfile/Scripts/android-configure.sh
Normal file
92
libs/libsndfile/Scripts/android-configure.sh
Normal file
@ -0,0 +1,92 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
# Copyright (C) 2013 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.
|
||||
# * 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.
|
||||
|
||||
# Android NDK version number; eg r8e, r9 etc
|
||||
ANDROID_NDK_VER=r9
|
||||
|
||||
# Android NDK gcc version; eg 4.7, 4.9 etc.
|
||||
ANDROID_GCC_VER=4.8
|
||||
|
||||
# Android API version; eg 9 (Android 2.3), 14 (Android 4.0) etc.
|
||||
ANDROID_API_VER=9
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# No more user config beyond here.
|
||||
|
||||
BUILD_MACHINE=$(uname -s | tr 'A-Z' 'a-z')-$(uname -m)
|
||||
|
||||
function die_with {
|
||||
echo $1
|
||||
exit 1
|
||||
}
|
||||
|
||||
export CROSS_COMPILE=arm-linux-androideabi
|
||||
|
||||
# I put all my dev stuff in here
|
||||
export DEV_PREFIX=$HOME/Android
|
||||
test -d ${DEV_PREFIX} || die_with "Error : DEV_PREFIX '$DEV_PREFIX' does not exist."
|
||||
|
||||
# Don't forget to adjust this to your NDK path
|
||||
export ANDROID_NDK=${DEV_PREFIX}/android-ndk-${ANDROID_NDK_VER}
|
||||
test -d ${ANDROID_NDK} || die_with "Error : ANDROID_NDK '$ANDROID_NDK' does not exist."
|
||||
|
||||
export ANDROID_PREFIX=${ANDROID_NDK}/toolchains/arm-linux-androideabi-${ANDROID_GCC_VER}/prebuilt/${BUILD_MACHINE}
|
||||
test -d ${ANDROID_PREFIX} || die_with "Error : ANDROID_PREFIX '$ANDROID_PREFIX' does not exist."
|
||||
|
||||
export SYSROOT=${ANDROID_NDK}/platforms/android-${ANDROID_API_VER}/arch-arm
|
||||
test -d ${SYSROOT} || die_with "Error : SYSROOT '$SYSROOT' does not exist."
|
||||
|
||||
export CROSS_PREFIX=${ANDROID_PREFIX}/bin/${CROSS_COMPILE}
|
||||
test -f ${CROSS_PREFIX}-gcc || die_with "Error : CROSS_PREFIX compiler '${CROSS_PREFIX}-gcc' does not exist."
|
||||
|
||||
|
||||
# Non-exhaustive lists of compiler + binutils
|
||||
# Depending on what you compile, you might need more binutils than that
|
||||
export CPP=${CROSS_PREFIX}-cpp
|
||||
export AR=${CROSS_PREFIX}-ar
|
||||
export AS=${CROSS_PREFIX}-as
|
||||
export NM=${CROSS_PREFIX}-nm
|
||||
export CC=${CROSS_PREFIX}-gcc
|
||||
export CXX=${CROSS_PREFIX}-g++
|
||||
export LD=${CROSS_PREFIX}-ld
|
||||
export RANLIB=${CROSS_PREFIX}-ranlib
|
||||
|
||||
# Don't mix up .pc files from your host and build target
|
||||
export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
|
||||
|
||||
# Set up the needed FLAGS.
|
||||
export CFLAGS="${CFLAGS} -gstabs --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${ANDROID_PREFIX}/include"
|
||||
export CXXFLAGS="${CXXFLAGS} -gstabs -fno-exceptions --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${ANDROID_PREFIX}/include -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_GCC_VER}/include/ -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_GCC_VER}/libs/armeabi/include"
|
||||
|
||||
export CPPFLAGS="${CFLAGS}"
|
||||
export LDFLAGS="${LDFLAGS} -L${SYSROOT}/usr/lib -L${ANDROID_PREFIX}/lib"
|
||||
|
||||
# Create a symlink to the gdbclient.
|
||||
test -h gdbclient || ln -s ${ANDROID_PREFIX}/bin/arm-linux-androideabi-gdb gdbclient
|
||||
|
||||
./configure --host=${CROSS_COMPILE} --with-sysroot=${SYSROOT} "$@"
|
61
libs/libsndfile/Scripts/build-test-tarball.mk.in
Normal file
61
libs/libsndfile/Scripts/build-test-tarball.mk.in
Normal file
@ -0,0 +1,61 @@
|
||||
#!/usr/bin/make -f
|
||||
|
||||
# This is probably only going to work with GNU Make.
|
||||
# This in a separate file instead of in Makefile.am because Automake complains
|
||||
# about the GNU Make-isms.
|
||||
|
||||
EXEEXT = @EXEEXT@
|
||||
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
|
||||
HOST_TRIPLET = @HOST_TRIPLET@
|
||||
|
||||
SRC_BINDIR = @SRC_BINDIR@
|
||||
TEST_BINDIR = @TEST_BINDIR@
|
||||
|
||||
LIBRARY := $(SRC_BINDIR)libsndfile.so.$(LIB_VERSION)
|
||||
|
||||
LIB_VERSION := $(shell echo $(PACKAGE_VERSION) | sed -e 's/[a-z].*//')
|
||||
|
||||
TESTNAME = libsndfile-testsuite-$(HOST_TRIPLET)-$(PACKAGE_VERSION)
|
||||
|
||||
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@ 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)
|
||||
|
||||
libfiles := $(shell if test ! -z $(EXEEXT) ; then echo "src/libsndfile-1.def src/.libs/libsndfile-1.dll" ; elif test -f $(LIBRARY) ; then echo $(LIBRARY) ; fi ; fi)
|
||||
|
||||
testbins := $(addprefix $(TEST_BINDIR),$(subst @EXEEXT@,$(EXEEXT),$(testprogs))) $(libfiles) $(srcprogs)
|
||||
|
||||
|
||||
all : $(TARBALL)
|
||||
|
||||
clean :
|
||||
rm -rf $(TARBALL) $(TESTNAME)/
|
||||
|
||||
check : $(TESTNAME)/test_wrapper.sh
|
||||
(cd ./$(TESTNAME)/ && ./test_wrapper.sh)
|
||||
|
||||
$(TARBALL) : $(TESTNAME)/test_wrapper.sh
|
||||
tar zcf $@ $(TESTNAME)
|
||||
rm -rf $(TESTNAME)
|
||||
@echo
|
||||
@echo "Created : $(TARBALL)"
|
||||
@echo
|
||||
|
||||
$(TESTNAME)/test_wrapper.sh : $(testbins) tests/test_wrapper.sh tests/pedantic-header-test.sh
|
||||
rm -rf $(TESTNAME)
|
||||
mkdir -p $(TESTNAME)/tests/
|
||||
cp $(testbins) $(TESTNAME)/tests/
|
||||
cp tests/test_wrapper.sh $(TESTNAME)/
|
||||
cp tests/pedantic-header-test.sh $(TESTNAME)/tests/
|
||||
chmod u+x $@
|
||||
|
||||
tests/test_wrapper.sh : tests/test_wrapper.sh.in
|
||||
(cd tests/ ; make $@)
|
13
libs/libsndfile/Scripts/clang-sanitize.sh
Normal file
13
libs/libsndfile/Scripts/clang-sanitize.sh
Normal file
@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This is known to work with clang-3.4 from Debian testing/unstable.
|
||||
# 2013/07/14
|
||||
|
||||
export CC=clang
|
||||
export CXX=clang++
|
||||
export CFLAGS="-O3 -fsanitize=address,integer,undefined"
|
||||
export CXXFLAGS="-O3 -fsanitize=address,integer,undefined"
|
||||
|
||||
./configure --enable-gcc-werror
|
||||
|
||||
make clean all check
|
246
libs/libsndfile/Scripts/cstyle.py
Normal file
246
libs/libsndfile/Scripts/cstyle.py
Normal file
@ -0,0 +1,246 @@
|
||||
#!/usr/bin/python -tt
|
||||
#
|
||||
# Copyright (C) 2005-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
#
|
||||
# Released under the 2 clause BSD license.
|
||||
|
||||
"""
|
||||
This program checks C code for compliance to coding standards used in
|
||||
libsndfile and other projects I run.
|
||||
"""
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
class Preprocessor:
|
||||
"""
|
||||
Preprocess lines of C code to make it easier for the CStyleChecker class to
|
||||
test for correctness. Preprocessing works on a single line at a time but
|
||||
maintains state between consecutive lines so it can preprocessess multi-line
|
||||
comments.
|
||||
Preprocessing involves:
|
||||
- Strip C++ style comments from a line.
|
||||
- Strip C comments from a series of lines. When a C comment starts and
|
||||
ends on the same line it will be replaced with 'comment'.
|
||||
- Replace arbitrary C strings with the zero length string.
|
||||
- Replace '#define f(x)' with '#define f (c)' (The C #define requires that
|
||||
there be no space between defined macro name and the open paren of the
|
||||
argument list).
|
||||
Used by the CStyleChecker class.
|
||||
"""
|
||||
def __init__ (self):
|
||||
self.comment_nest = 0
|
||||
self.leading_space_re = re.compile ('^(\t+| )')
|
||||
self.trailing_space_re = re.compile ('(\t+| )$')
|
||||
self.define_hack_re = re.compile ("(#\s*define\s+[a-zA-Z0-9_]+)\(")
|
||||
|
||||
def comment_nesting (self):
|
||||
"""
|
||||
Return the currect comment nesting. At the start and end of the file,
|
||||
this value should be zero. Inside C comments it should be 1 or
|
||||
(possibly) more.
|
||||
"""
|
||||
return self.comment_nest
|
||||
|
||||
def __call__ (self, line):
|
||||
"""
|
||||
Strip the provided line of C and C++ comments. Stripping of multi-line
|
||||
C comments works as expected.
|
||||
"""
|
||||
|
||||
line = self.define_hack_re.sub (r'\1 (', line)
|
||||
|
||||
line = self.process_strings (line)
|
||||
|
||||
# Strip C++ style comments.
|
||||
if self.comment_nest == 0:
|
||||
line = re.sub ("( |\t*)//.*", '', line)
|
||||
|
||||
# Strip C style comments.
|
||||
open_comment = line.find ('/*')
|
||||
close_comment = line.find ('*/')
|
||||
|
||||
if self.comment_nest > 0 and close_comment < 0:
|
||||
# Inside a comment block that does not close on this line.
|
||||
return ""
|
||||
|
||||
if open_comment >= 0 and close_comment < 0:
|
||||
# A comment begins on this line but doesn't close on this line.
|
||||
self.comment_nest += 1
|
||||
return self.trailing_space_re.sub ('', line [:open_comment])
|
||||
|
||||
if open_comment < 0 and close_comment >= 0:
|
||||
# Currently open comment ends on this line.
|
||||
self.comment_nest -= 1
|
||||
return self.trailing_space_re.sub ('', line [close_comment + 2:])
|
||||
|
||||
if open_comment >= 0 and close_comment > 0 and self.comment_nest == 0:
|
||||
# Comment begins and ends on this line. Replace it with 'comment'
|
||||
# so we don't need to check whitespace before and after the comment
|
||||
# we're removing.
|
||||
newline = line [:open_comment] + "comment" + line [close_comment + 2:]
|
||||
return self.__call__ (newline)
|
||||
|
||||
return line
|
||||
|
||||
def process_strings (self, line):
|
||||
"""
|
||||
Given a line of C code, return a string where all literal C strings have
|
||||
been replaced with the empty string literal "".
|
||||
"""
|
||||
for k in range (0, len (line)):
|
||||
if line [k] == '"':
|
||||
start = k
|
||||
for k in range (start + 1, len (line)):
|
||||
if line [k] == '"' and line [k - 1] != '\\':
|
||||
return line [:start + 1] + '"' + self.process_strings (line [k + 1:])
|
||||
return line
|
||||
|
||||
|
||||
class CStyleChecker:
|
||||
"""
|
||||
A class for checking the whitespace and layout of a C code.
|
||||
"""
|
||||
def __init__ (self, debug):
|
||||
self.debug = debug
|
||||
self.filename = None
|
||||
self.error_count = 0
|
||||
self.line_num = 1
|
||||
self.orig_line = ''
|
||||
self.trailing_newline_re = re.compile ('[\r\n]+$')
|
||||
self.indent_re = re.compile ("^\s*")
|
||||
self.last_line_indent = ""
|
||||
self.last_line_indent_curly = False
|
||||
self.re_checks = \
|
||||
[ ( re.compile (" "), "multiple space instead of tab" )
|
||||
, ( re.compile ("\t "), "space after tab" )
|
||||
, ( re.compile ("[^ ];"), "missing space before semi-colon" )
|
||||
, ( re.compile ("{[^\s}]"), "missing space after open brace" )
|
||||
, ( re.compile ("[^{\s]}"), "missing space before close brace" )
|
||||
, ( re.compile ("[ \t]+$"), "contains trailing whitespace" )
|
||||
|
||||
, ( re.compile (",[^\s\n]"), "missing space after comma" )
|
||||
, ( re.compile (";[a-zA-Z0-9]"), "missing space after semi-colon" )
|
||||
, ( re.compile ("=[^\s\"'=]"), "missing space after assignment" )
|
||||
|
||||
# Open and close parenthesis.
|
||||
, ( re.compile ("[^\s\(\[\*&']\("), "missing space before open parenthesis" )
|
||||
, ( re.compile ("\)(-[^>]|[^,'\s\n\)\]-])"), "missing space after close parenthesis" )
|
||||
, ( re.compile ("\s(do|for|if|when)\s.*{$"), "trailing open parenthesis at end of line" )
|
||||
, ( re.compile ("\( [^;]"), "space after open parenthesis" )
|
||||
, ( re.compile ("[^;] \)"), "space before close parenthesis" )
|
||||
|
||||
# Open and close square brace.
|
||||
, ( re.compile ("[^\s\(\]]\["), "missing space before open square brace" )
|
||||
, ( re.compile ("\][^,\)\]\[\s\.-]"), "missing space after close square brace" )
|
||||
, ( re.compile ("\[ "), "space after open square brace" )
|
||||
, ( re.compile (" \]"), "space before close square brace" )
|
||||
|
||||
# Space around operators.
|
||||
, ( re.compile ("[^\s][\*/%+-][=][^\s]"), "missing space around opassign" )
|
||||
, ( re.compile ("[^\s][<>!=^/][=]{1,2}[^\s]"), "missing space around comparison" )
|
||||
|
||||
# Parens around single argument to return.
|
||||
, ( re.compile ("\s+return\s+\([a-zA-Z0-9_]+\)\s+;"), "parens around return value" )
|
||||
]
|
||||
|
||||
def get_error_count (self):
|
||||
"""
|
||||
Return the current error count for this CStyleChecker object.
|
||||
"""
|
||||
return self.error_count
|
||||
|
||||
def check_files (self, files):
|
||||
"""
|
||||
Run the style checker on all the specified files.
|
||||
"""
|
||||
for filename in files:
|
||||
self.check_file (filename)
|
||||
|
||||
def check_file (self, filename):
|
||||
"""
|
||||
Run the style checker on the specified file.
|
||||
"""
|
||||
self.filename = filename
|
||||
cfile = open (filename, "r")
|
||||
|
||||
self.line_num = 1
|
||||
|
||||
preprocess = Preprocessor ()
|
||||
while 1:
|
||||
line = cfile.readline ()
|
||||
if not line:
|
||||
break
|
||||
|
||||
line = self.trailing_newline_re.sub ('', line)
|
||||
self.orig_line = line
|
||||
|
||||
self.line_checks (preprocess (line))
|
||||
|
||||
self.line_num += 1
|
||||
|
||||
cfile.close ()
|
||||
self.filename = None
|
||||
|
||||
# Check for errors finding comments.
|
||||
if preprocess.comment_nesting () != 0:
|
||||
print ("Weird, comments nested incorrectly.")
|
||||
sys.exit (1)
|
||||
|
||||
return
|
||||
|
||||
def line_checks (self, line):
|
||||
"""
|
||||
Run the style checker on provided line of text, but within the context
|
||||
of how the line fits within the file.
|
||||
"""
|
||||
|
||||
indent = len (self.indent_re.search (line).group ())
|
||||
if re.search ("^\s+}", line):
|
||||
if not self.last_line_indent_curly and indent != self.last_line_indent:
|
||||
None # self.error ("bad indent on close curly brace")
|
||||
self.last_line_indent_curly = True
|
||||
else:
|
||||
self.last_line_indent_curly = False
|
||||
|
||||
# Now all the regex checks.
|
||||
for (check_re, msg) in self.re_checks:
|
||||
if check_re.search (line):
|
||||
self.error (msg)
|
||||
|
||||
if re.search ("[a-zA-Z0-9][<>!=^/&\|]{1,2}[a-zA-Z0-9]", line):
|
||||
if not re.search (".*#include.*[a-zA-Z0-9]/[a-zA-Z]", line):
|
||||
self.error ("missing space around operator")
|
||||
|
||||
self.last_line_indent = indent
|
||||
return
|
||||
|
||||
def error (self, msg):
|
||||
"""
|
||||
Print an error message and increment the error count.
|
||||
"""
|
||||
print ("%s (%d) : %s" % (self.filename, self.line_num, msg))
|
||||
if self.debug:
|
||||
print ("'" + self.orig_line + "'")
|
||||
self.error_count += 1
|
||||
|
||||
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||
|
||||
if len (sys.argv) < 1:
|
||||
print ("Usage : yada yada")
|
||||
sys.exit (1)
|
||||
|
||||
# Create a new CStyleChecker object
|
||||
if sys.argv [1] == '-d' or sys.argv [1] == '--debug':
|
||||
cstyle = CStyleChecker (True)
|
||||
cstyle.check_files (sys.argv [2:])
|
||||
else:
|
||||
cstyle = CStyleChecker (False)
|
||||
cstyle.check_files (sys.argv [1:])
|
||||
|
||||
|
||||
if cstyle.get_error_count ():
|
||||
sys.exit (1)
|
||||
|
||||
sys.exit (0)
|
79
libs/libsndfile/Scripts/git-pre-commit-hook
Normal file
79
libs/libsndfile/Scripts/git-pre-commit-hook
Normal file
@ -0,0 +1,79 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
|
||||
if git rev-parse --verify HEAD >/dev/null 2>&1 ; then
|
||||
against=HEAD
|
||||
else
|
||||
# Initial commit: diff against an empty tree object
|
||||
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
||||
fi
|
||||
|
||||
files=$(git diff-index --name-status --cached HEAD | grep -v ^D | sed -r "s/^[A-Z]+[A-Z0-9]*[ \t]+/ /")
|
||||
|
||||
# Redirect output to stderr.
|
||||
exec 1>&2
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check the copyright notice of all files to be commited.
|
||||
|
||||
user=`git config --global user.email`
|
||||
year=`date +"%Y"`
|
||||
|
||||
missing_copyright_year=""
|
||||
if test $user = "erikd@mega-nerd.com" ; then
|
||||
for f in $files ; do
|
||||
if test `head -5 $f | grep -c -i copyright` -gt 0 ; then
|
||||
user_copyright=`grep -i copyright $f | grep $user | grep -c $year`
|
||||
if test $user_copyright -lt 1 ; then
|
||||
missing_copyright_year="$missing_copyright_year $f"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if test -n "$missing_copyright_year" ; then
|
||||
echo "Missing current year in the copyright notice of the following files:"
|
||||
for f in $missing_copyright_year ; do
|
||||
echo " $f"
|
||||
done
|
||||
echo "Commit aborted."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check the formatting of all C files.
|
||||
|
||||
cfiles=""
|
||||
for f in $files ; do
|
||||
if test `dirname $f` = "src/ALAC" ; then
|
||||
echo "Skipping cstyle checking on $f"
|
||||
elif test `echo $f | grep -c "\.[ch]$"` -gt 0 ; then
|
||||
cfiles="$cfiles $f"
|
||||
fi
|
||||
done
|
||||
|
||||
if test -n "$cfiles" ; then
|
||||
Scripts/cstyle.py $cfiles
|
||||
if test $? -ne 0 ; then
|
||||
echo
|
||||
echo "Commit aborted. Fix the above error before trying again."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Prevent files with non-ascii filenames from being committed.
|
||||
|
||||
if test $(git diff --cached --name-only --diff-filter=A -z $against | LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 ; then
|
||||
echo "Error: Attempt to add a non-ascii file name."
|
||||
echo
|
||||
echo "This can cause problems if you want to work"
|
||||
echo "with people on other platforms."
|
||||
echo
|
||||
echo "To be portable it is advisable to rename the file ..."
|
||||
echo
|
||||
echo "Commit aborted."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
22
libs/libsndfile/Scripts/linux-to-win-cross-configure.sh
Normal file
22
libs/libsndfile/Scripts/linux-to-win-cross-configure.sh
Normal file
@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
case "$1" in
|
||||
w32)
|
||||
compiler_name=i686-w64-mingw32
|
||||
;;
|
||||
w64)
|
||||
compiler_name=x86_64-w64-mingw32
|
||||
;;
|
||||
*)
|
||||
echo "$0 (w32|w64) <other args>"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
shift
|
||||
|
||||
build_cpu=$(dpkg-architecture -qDEB_BUILD_GNU_CPU)
|
||||
build_host=$build_cpu-linux
|
||||
|
||||
./configure --host=$compiler_name --target=$compiler_name --build=$build_host \
|
||||
--program-prefix='' --disable-sqlite --disable-static $@
|
179
libs/libsndfile/autogen.sh
Normal file
179
libs/libsndfile/autogen.sh
Normal file
@ -0,0 +1,179 @@
|
||||
#!/bin/sh
|
||||
# Run this to set up the build system: configure, makefiles, etc.
|
||||
# (based on the version in enlightenment's cvs)
|
||||
|
||||
package="libsndfile"
|
||||
|
||||
ACLOCAL_FLAGS="-I M4"
|
||||
|
||||
olddir=`pwd`
|
||||
srcdir=`dirname $0`
|
||||
test -z "$srcdir" && srcdir=.
|
||||
|
||||
cd "$srcdir"
|
||||
DIE=0
|
||||
|
||||
printf "checking for autogen ... "
|
||||
result="yes"
|
||||
(autogen --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "You must have GNU autogen installed to compile $package."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
|
||||
result="no"
|
||||
DIE=1
|
||||
}
|
||||
echo $result
|
||||
|
||||
printf "checking for autoconf ... "
|
||||
result="yes"
|
||||
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "You must have autoconf installed to compile $package."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
|
||||
result="no"
|
||||
DIE=1
|
||||
}
|
||||
echo $result
|
||||
|
||||
VERSIONGREP="sed -e s/.*[^0-9\.]\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/"
|
||||
VERSIONMKMAJ="sed -e s/\([0-9][0-9]*\)[^0-9].*/\\1/"
|
||||
VERSIONMKMIN="sed -e s/.*[0-9][0-9]*\.//"
|
||||
|
||||
# do we need automake?
|
||||
if test -r Makefile.am; then
|
||||
AM_OPTIONS=`fgrep AUTOMAKE_OPTIONS Makefile.am`
|
||||
AM_NEEDED=`echo $AM_OPTIONS | $VERSIONGREP`
|
||||
if test x"$AM_NEEDED" = "x$AM_OPTIONS"; then
|
||||
AM_NEEDED=""
|
||||
fi
|
||||
if test -z $AM_NEEDED; then
|
||||
printf "checking for automake ... "
|
||||
AUTOMAKE=automake
|
||||
ACLOCAL=aclocal
|
||||
if ($AUTOMAKE --version < /dev/null > /dev/null 2>&1); then
|
||||
echo "yes"
|
||||
else
|
||||
echo "no"
|
||||
AUTOMAKE=
|
||||
fi
|
||||
else
|
||||
printf "checking for automake $AM_NEEDED or later ... "
|
||||
majneeded=`echo $AM_NEEDED | $VERSIONMKMAJ`
|
||||
minneeded=`echo $AM_NEEDED | $VERSIONMKMIN`
|
||||
for am in automake-$AM_NEEDED automake$AM_NEEDED \
|
||||
automake automake-1.7 automake-1.8 automake-1.9 automake-1.10; do
|
||||
($am --version < /dev/null > /dev/null 2>&1) || continue
|
||||
ver=`$am --version < /dev/null | head -n 1 | $VERSIONGREP`
|
||||
maj=`echo $ver | $VERSIONMKMAJ`
|
||||
min=`echo $ver | $VERSIONMKMIN`
|
||||
if test $maj -eq $majneeded -a $min -ge $minneeded; then
|
||||
AUTOMAKE=$am
|
||||
echo $AUTOMAKE
|
||||
break
|
||||
fi
|
||||
done
|
||||
test -z $AUTOMAKE && echo "no"
|
||||
printf "checking for aclocal $AM_NEEDED or later ... "
|
||||
for ac in aclocal-$AM_NEEDED aclocal$AM_NEEDED \
|
||||
aclocal aclocal-1.7 aclocal-1.8 aclocal-1.9 aclocal-1.10; do
|
||||
($ac --version < /dev/null > /dev/null 2>&1) || continue
|
||||
ver=`$ac --version < /dev/null | head -n 1 | $VERSIONGREP`
|
||||
maj=`echo $ver | $VERSIONMKMAJ`
|
||||
min=`echo $ver | $VERSIONMKMIN`
|
||||
if test $maj -eq $majneeded -a $min -ge $minneeded; then
|
||||
ACLOCAL=$ac
|
||||
echo $ACLOCAL
|
||||
break
|
||||
fi
|
||||
done
|
||||
test -z $ACLOCAL && echo "no"
|
||||
fi
|
||||
test -z $AUTOMAKE || test -z $ACLOCAL && {
|
||||
echo
|
||||
echo "You must have automake installed to compile $package."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
printf "checking for libtool ... "
|
||||
for LIBTOOLIZE in libtoolize glibtoolize nope; do
|
||||
($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 && break
|
||||
done
|
||||
if test x$LIBTOOLIZE = xnope; then
|
||||
echo "nope."
|
||||
LIBTOOLIZE=libtoolize
|
||||
else
|
||||
echo $LIBTOOLIZE
|
||||
fi
|
||||
($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "You must have libtool installed to compile $package."
|
||||
echo "Download the appropriate package for your system,"
|
||||
echo "or get the source from one of the GNU ftp sites"
|
||||
echo "listed in http://www.gnu.org/order/ftp.html"
|
||||
DIE=1
|
||||
}
|
||||
|
||||
printf "checking for pkg-config ... "
|
||||
result="yes"
|
||||
(pkg-config --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "You must have pkg-config installed to compile $package."
|
||||
echo "Download the appropriate package for your distribution."
|
||||
result="no"
|
||||
DIE=1
|
||||
}
|
||||
echo $result
|
||||
|
||||
|
||||
printf "checking for python ... "
|
||||
result="yes"
|
||||
(python --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "You must have Python installed to compile $package."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or get the source tarball at http://python.org/"
|
||||
result="no"
|
||||
DIE=1
|
||||
}
|
||||
echo $result
|
||||
|
||||
if test "$DIE" -eq 1; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test ! -d Cfg ; then
|
||||
echo "Creating 'Cfg' directory."
|
||||
mkdir Cfg
|
||||
fi
|
||||
|
||||
echo "Generating configuration files for $package, please wait ... "
|
||||
|
||||
echo " $ACLOCAL $ACLOCAL_FLAGS"
|
||||
$ACLOCAL $ACLOCAL_FLAGS || exit 1
|
||||
echo " $LIBTOOLIZE --automake --force"
|
||||
$LIBTOOLIZE --automake --force || exit 1
|
||||
echo " autoheader"
|
||||
autoheader || exit 1
|
||||
echo " $AUTOMAKE --add-missing $AUTOMAKE_FLAGS"
|
||||
$AUTOMAKE --add-missing $AUTOMAKE_FLAGS || exit 1
|
||||
echo " autoconf"
|
||||
autoconf || exit 1
|
||||
|
||||
cd $olddir
|
||||
|
||||
fprecommit=.git/hooks/pre-commit
|
||||
if test ! -f $fprecommit ; then
|
||||
echo
|
||||
echo "Installing git pre-commit hook for this project."
|
||||
cat > $fprecommit << 'foobar'
|
||||
#!/bin/sh
|
||||
exec Scripts/git-pre-commit-hook
|
||||
foobar
|
||||
chmod u+x $fprecommit
|
||||
echo
|
||||
fi
|
62
libs/libsndfile/binheader_readf_check.py
Normal file
62
libs/libsndfile/binheader_readf_check.py
Normal file
@ -0,0 +1,62 @@
|
||||
g#!/usr/bin/python
|
||||
|
||||
import re, string, sys
|
||||
|
||||
def trim_function_and_params (section):
|
||||
k = string.find (section, "(") + 1
|
||||
brackets = 1
|
||||
section_len = len (section)
|
||||
while k < section_len:
|
||||
if section [k] == '(':
|
||||
brackets += 1
|
||||
elif section [k] == ')':
|
||||
brackets -= 1
|
||||
if brackets < 1:
|
||||
return section [:k+1]
|
||||
k += 1
|
||||
print "Whoops!!!!"
|
||||
sys.exit (1)
|
||||
|
||||
def get_function_calls (filedata):
|
||||
filedata = string.split (filedata, "psf_binheader_readf")
|
||||
filedata = filedata [1:]
|
||||
|
||||
func_calls = []
|
||||
for section in filedata:
|
||||
section = "psf_binheader_readf" + section
|
||||
func_calls.append (trim_function_and_params (section))
|
||||
|
||||
return func_calls
|
||||
|
||||
def search_for_problems (filename):
|
||||
filedata = open (filename, "r").read ()
|
||||
|
||||
if len (filedata) < 1:
|
||||
print "Error : file '%s' contains no data." % filename
|
||||
sys.exit (1)
|
||||
|
||||
count = 0
|
||||
|
||||
calls = get_function_calls (filedata)
|
||||
for call in calls:
|
||||
if string.find (call, "sizeof") > 0:
|
||||
print "Found : ", call
|
||||
count += 1
|
||||
|
||||
if count == 0:
|
||||
print "%-20s : No problems found." % filename
|
||||
else:
|
||||
print "\n%-20s : Found %d errors." % (filename, count)
|
||||
sys.exit (1)
|
||||
return
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
if len (sys.argv) < 2:
|
||||
print "Usage : %s <file>" % sys.argv [0]
|
||||
sys.exit (1)
|
||||
|
||||
for file in sys.argv [1:]:
|
||||
search_for_problems (file)
|
||||
|
@ -1,30 +1,48 @@
|
||||
# Copyright (C) 1999-2008 Erik de Castro Lopo (erikd AT mega-nerd DOT com).
|
||||
# Copyright (C) 1999-2013 Erik de Castro Lopo <erikd@mega-nerd.com>.
|
||||
|
||||
dnl Require autoconf version
|
||||
AC_PREREQ(2.57)
|
||||
|
||||
AC_INIT([libsndfile],[1.0.19],[erikd@mega-nerd.com])
|
||||
AC_INIT([libsndfile],[1.0.26pre5],[sndfile@mega-nerd.com],
|
||||
[libsndfile],[http://www.mega-nerd.com/libsndfile/])
|
||||
|
||||
# Put config stuff in Cfg.
|
||||
AC_CONFIG_AUX_DIR(Cfg)
|
||||
|
||||
CFLAGS="$CFLAGS $CONFIGURE_CFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS"
|
||||
LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS"
|
||||
|
||||
AC_CONFIG_SRCDIR([src/sndfile.c])
|
||||
AC_CANONICAL_TARGET([])
|
||||
|
||||
AM_INIT_AUTOMAKE
|
||||
AC_CONFIG_MACRO_DIR([M4])
|
||||
|
||||
AC_CONFIG_HEADERS([src/config.h])
|
||||
|
||||
dnl Add parameters for aclocal
|
||||
AC_SUBST(ACLOCAL_AMFLAGS, "-I M4")
|
||||
AM_INIT_AUTOMAKE
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
|
||||
AC_LANG([C])
|
||||
|
||||
AC_PROG_CC_STDC
|
||||
AC_USE_SYSTEM_EXTENSIONS
|
||||
AM_PROG_CC_C_O
|
||||
AC_PROG_CXX
|
||||
|
||||
MN_C_COMPILER_IS_CLANG
|
||||
MN_GCC_REALLY_IS_GCC
|
||||
|
||||
AC_PROG_SED
|
||||
|
||||
# Do not check for F77.
|
||||
define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl
|
||||
|
||||
AM_PROG_LIBTOOL
|
||||
LT_PROG_RC
|
||||
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
|
||||
AC_CHECK_PROG(HAVE_AUTOGEN, autogen, yes, no)
|
||||
AC_CHECK_PROG(HAVE_WINE, wine, yes, no)
|
||||
AC_CHECK_PROG(HAVE_XCODE_SELECT, xcode-select, yes, no)
|
||||
|
||||
#------------------------------------------------------------------------------------
|
||||
# Rules for library version information:
|
||||
#
|
||||
@ -41,22 +59,12 @@ AC_LANG([C])
|
||||
# 6. If any interfaces have been removed since the last public release, then set age
|
||||
# to 0.
|
||||
|
||||
SHARED_VERSION_INFO="1:19:0"
|
||||
CLEAN_VERSION=`echo $PACKAGE_VERSION | $SED "s/p.*//"`
|
||||
VERSION_MINOR=`echo $CLEAN_VERSION | $SED "s/.*\.//"`
|
||||
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_C_O
|
||||
AC_PROG_CXX
|
||||
SHARED_VERSION_INFO="1:$VERSION_MINOR:0"
|
||||
|
||||
# Do not check for F77.
|
||||
define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl
|
||||
|
||||
AM_PROG_LIBTOOL
|
||||
|
||||
AC_CHECK_PROG(HAVE_AUTOGEN, autogen, yes, no)
|
||||
AC_CHECK_PROG(HAVE_WINE, wine, yes, no)
|
||||
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
#------------------------------------------------------------------------------------
|
||||
|
||||
AC_HEADER_STDC
|
||||
|
||||
@ -77,19 +85,6 @@ else
|
||||
AM_CONDITIONAL([LINUX_MINGW_CROSS_TEST],
|
||||
[test "$build_os:$target_os:$host_os:$HAVE_WINE" = "linux-gnu:mingw32msvc:mingw32msvc:yes"])
|
||||
|
||||
#====================================================================================
|
||||
# Check for support of the struct hack.
|
||||
|
||||
AC_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.])
|
||||
else
|
||||
AC_MSG_WARN([[*** This compiler does not support the 1999 ISO C Standard ***]])
|
||||
AC_MSG_WARN([[*** feature known as the flexible array struct member. ***]])
|
||||
AC_DEFINE([HAVE_FLEXIBLE_ARRAY],0)
|
||||
fi
|
||||
|
||||
#====================================================================================
|
||||
# Couple of initializations here. Fill in real values later.
|
||||
|
||||
@ -107,8 +102,11 @@ if test x$enable_experimental = xyes ; then
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([ENABLE_EXPERIMENTAL_CODE],${EXPERIMENTAL_CODE}, [Set to 1 to enable experimental code.])
|
||||
|
||||
AC_ARG_ENABLE(gcc-werror,
|
||||
AC_HELP_STRING([--enable-gcc-werror], [enable -Werror in all Makefiles]))
|
||||
AC_ARG_ENABLE(werror,
|
||||
AC_HELP_STRING([--enable-werror], [enable -Werror in all Makefiles]))
|
||||
|
||||
AC_ARG_ENABLE(stack-smash-protection,
|
||||
AC_HELP_STRING([--enable-stack-smash-protection], [Enable GNU GCC stack smash protection]))
|
||||
|
||||
AC_ARG_ENABLE(gcc-pipe,
|
||||
AC_HELP_STRING([--disable-gcc-pipe], [disable gcc -pipe option]))
|
||||
@ -129,7 +127,7 @@ AC_ARG_ENABLE(alsa,
|
||||
AC_HELP_STRING([--disable-alsa], [disable use of ALSA]))
|
||||
|
||||
AC_ARG_ENABLE(external-libs,
|
||||
AC_HELP_STRING([--disable-external-libs], [disable use of FLAC, Ogg and Vorbis]))
|
||||
AC_HELP_STRING([--disable-external-libs], [disable use of FLAC, Ogg and Vorbis [[default=no]]]))
|
||||
|
||||
AC_ARG_ENABLE(octave,
|
||||
AC_HELP_STRING([--enable-octave], [disable building of GNU Octave module]))
|
||||
@ -141,6 +139,7 @@ AM_CONDITIONAL([ENABLE_TEST_COVERAGE], [test "$enable_test_coverage" = yes])
|
||||
#====================================================================================
|
||||
# Check types and their sizes.
|
||||
|
||||
AC_CHECK_SIZEOF(wchar_t,4)
|
||||
AC_CHECK_SIZEOF(short,2)
|
||||
AC_CHECK_SIZEOF(int,4)
|
||||
AC_CHECK_SIZEOF(long,4)
|
||||
@ -157,43 +156,48 @@ AC_CHECK_SIZEOF(long long,8)
|
||||
# Unfortunately there is more than one way of ensuring this so need to do some
|
||||
# pretty rigourous testing here.
|
||||
|
||||
unset ac_cv_sizeof_off_t
|
||||
# Check for common 64 bit file offset types.
|
||||
AC_CHECK_SIZEOF(off_t,1)
|
||||
AC_CHECK_SIZEOF(loff_t,1)
|
||||
AC_CHECK_SIZEOF(off64_t,1)
|
||||
|
||||
if test "$enable_largefile:$ac_cv_sizeof_off_t" = "no:8" ; then
|
||||
echo
|
||||
echo "Error : Cannot disable large file support because sizeof (off_t) == 8."
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
AC_CHECK_SIZEOF(off_t,1) # Fake default value.
|
||||
|
||||
case "$host_os" in
|
||||
mingw*)
|
||||
mingw32msvc | mingw32)
|
||||
TYPEOF_SF_COUNT_T="__int64"
|
||||
SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
|
||||
SIZEOF_SF_COUNT_T=8
|
||||
AC_DEFINE([__USE_MINGW_ANSI_STDIO],1,[Set to 1 to use C99 printf/snprintf in MinGW.])
|
||||
;;
|
||||
*)
|
||||
SIZEOF_SF_COUNT_T=0
|
||||
if test "x$ac_cv_sizeof_off_t" = "x8" ; then
|
||||
# If sizeof (off_t) is 8, no further checking is needed.
|
||||
TYPEOF_SF_COUNT_T="off_t"
|
||||
TYPEOF_SF_COUNT_T="int64_t"
|
||||
SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
|
||||
SIZEOF_SF_COUNT_T=8
|
||||
elif test "x$ac_cv_sizeof_loff_t" = "x8" ; then
|
||||
TYPEOF_SF_COUNT_T="int64_t"
|
||||
SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
|
||||
SIZEOF_SF_COUNT_T=8
|
||||
elif test "x$ac_cv_sizeof_off64_t" = "x8" ; then
|
||||
TYPEOF_SF_COUNT_T="int64_t"
|
||||
SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
|
||||
SIZEOF_SF_COUNT_T=8
|
||||
else
|
||||
# Check for common 64 bit file offset types.
|
||||
AC_CHECK_SIZEOF(loff_t,1) # Fake default value.
|
||||
AC_CHECK_SIZEOF(off64_t,1) # Fake default value.
|
||||
|
||||
TYPEOF_SF_COUNT_T="unknown"
|
||||
if test "x$ac_cv_sizeof_loff_t" = "x8" ; then
|
||||
TYPEOF_SF_COUNT_T="loff_t"
|
||||
SIZEOF_SF_COUNT_T=8
|
||||
elif test "x$ac_cv_sizeof_off64_t" = "x8" ; then
|
||||
TYPEOF_SF_COUNT_T="off64_t"
|
||||
SIZEOF_SF_COUNT_T=8
|
||||
fi
|
||||
|
||||
# Save the old sizeof (off_t) value and then unset it to see if it
|
||||
# changes when Large File Support is enabled.
|
||||
|
||||
pre_largefile_sizeof_off_t=$ac_cv_sizeof_off_t
|
||||
unset ac_cv_sizeof_off_t
|
||||
|
||||
AC_SYS_EXTRA_LARGEFILE
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
if test "x$ac_cv_sys_largefile_CFLAGS" = "xno" ; then
|
||||
ac_cv_sys_largefile_CFLAGS=""
|
||||
@ -205,14 +209,11 @@ case "$host_os" in
|
||||
ac_cv_sys_largefile_LIBS=""
|
||||
fi
|
||||
|
||||
AC_CHECK_SIZEOF(off_t,1) # Fake default value.
|
||||
AC_CHECK_SIZEOF(off_t,1)
|
||||
|
||||
if test "x$ac_cv_sizeof_off_t" = "x8" ; then
|
||||
TYPEOF_SF_COUNT_T="int64_t"
|
||||
SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
|
||||
elif test "x$ac_cv_sizeof_off_t" = "x$pre_largefile_sizeof_off_t" ; then
|
||||
AC_MSG_WARN([[This machine does not seem to support 64 bit file offsets.]])
|
||||
TYPEOF_SF_COUNT_T="off_t"
|
||||
SIZEOF_SF_COUNT_T=$ac_cv_sizeof_off_t
|
||||
elif test "x$TYPEOF_SF_COUNT_T" = "xunknown" ; then
|
||||
echo
|
||||
echo "*** The configure process has determined that this system is capable"
|
||||
@ -245,7 +246,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.])
|
||||
@ -258,18 +259,19 @@ AC_DEFINE_UNQUOTED(WORDS_BIGENDIAN, ${ac_cv_c_big_endian},
|
||||
# Check for functions.
|
||||
|
||||
AC_CHECK_FUNCS(malloc calloc realloc free)
|
||||
AC_CHECK_FUNCS(open read write lseek pread pwrite)
|
||||
AC_CHECK_FUNCS(fstat ftruncate fsync)
|
||||
AC_CHECK_FUNCS(open read write lseek lseek64)
|
||||
AC_CHECK_FUNCS(fstat fstat64 ftruncate fsync)
|
||||
AC_CHECK_FUNCS(snprintf vsnprintf)
|
||||
AC_CHECK_FUNCS(gmtime gmtime_r localtime localtime_r gettimeofday)
|
||||
AC_CHECK_FUNCS(mmap getpagesize)
|
||||
AC_CHECK_FUNCS(setlocale)
|
||||
AC_CHECK_FUNCS(pipe waitpid)
|
||||
|
||||
AC_CHECK_LIB([m],floor)
|
||||
AC_CHECK_FUNCS(floor ceil fmod)
|
||||
AC_CHECK_FUNCS(floor ceil fmod lround)
|
||||
|
||||
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.
|
||||
@ -294,46 +296,62 @@ EXTERNAL_LIBS=""
|
||||
|
||||
# Check for pkg-config outside the if statement.
|
||||
PKG_PROG_PKG_CONFIG
|
||||
m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], AC_SUBST([pkgconfigdir], ${libdir}/pkgconfig))
|
||||
|
||||
#if test x$enable_external_libs = xno ; then
|
||||
AC_MSG_WARN([[*** External libs (FLAC, Ogg, Vorbis) disabled. ***]])
|
||||
#else
|
||||
# PKG_CHECK_MOD_VERSION(FLAC, flac >= 1.2.1, ac_cv_flac=yes, ac_cv_flac=no)
|
||||
# PKG_CHECK_MOD_VERSION(OGG, ogg >= 1.1.3, ac_cv_ogg=yes, ac_cv_ogg=no)
|
||||
if test -n "$PKG_CONFIG" ; then
|
||||
if test x$enable_external_libs = xno ; then
|
||||
AC_MSG_WARN([[*** External libs (FLAC, Ogg, Vorbis) disabled. ***]])
|
||||
else
|
||||
PKG_CHECK_MOD_VERSION(FLAC, flac >= 1.2.1, ac_cv_flac=yes, ac_cv_flac=no)
|
||||
|
||||
# Vorbis versions earlier than 1.2.1 are not const correct at the API level.
|
||||
# Vorbis 1.2.2 adds vorbis_version_string.
|
||||
# PKG_CHECK_MOD_VERSION(VORBIS, vorbis >= 1.2.0, ac_cv_vorbis=yes, ac_cv_vorbis=no)
|
||||
# PKG_CHECK_MOD_VERSION(VORBISENC, vorbisenc >= 1.2.0, ac_cv_vorbisenc=yes, ac_cv_vorbisenc=no)
|
||||
# fi
|
||||
# Make sure the FLAC_CFLAGS value is sane.
|
||||
FLAC_CFLAGS=`echo $FLAC_CFLAGS | $SED "s|include/FLAC|include|"`
|
||||
|
||||
HAVE_VORBIS_VERSION_STRING=0
|
||||
if test x$ac_cv_flac$ac_cv_ogg$ac_cv_vorbis$ac_cv_vorbisenc = "xyesyesyesyes" ; then
|
||||
PKG_CHECK_MOD_VERSION(OGG, ogg >= 1.1.3, ac_cv_ogg=yes, ac_cv_ogg=no)
|
||||
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$VORBIS_LIBS $LIBS"
|
||||
AC_CHECK_LIB(vorbis, vorbis_version_string, HAVE_VORBIS_VERSION_STRING=1)
|
||||
LIBS="$save_LIBS"
|
||||
if test x$enable_experimental = xyes ; then
|
||||
PKG_CHECK_MOD_VERSION(SPEEX, speex >= 1.2, ac_cv_speex=yes, ac_cv_speex=no)
|
||||
else
|
||||
SPEEX_CFLAGS=""
|
||||
SPEEX_LIBS=""
|
||||
fi
|
||||
|
||||
HAVE_EXTERNAL_LIBS=1
|
||||
enable_external_libs=yes
|
||||
# Vorbis versions earlier than 1.2.3 have bugs that cause the libsndfile
|
||||
# test suite to fail on MIPS, PowerPC and others.
|
||||
# See: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=549899
|
||||
PKG_CHECK_MOD_VERSION(VORBIS, vorbis >= 1.2.3, ac_cv_vorbis=yes, ac_cv_vorbis=no)
|
||||
PKG_CHECK_MOD_VERSION(VORBISENC, vorbisenc >= 1.2.3, ac_cv_vorbisenc=yes, ac_cv_vorbisenc=no)
|
||||
enable_external_libs=yes
|
||||
fi
|
||||
|
||||
EXTERNAL_CFLAGS="$FLAC_CFLAGS $OGG_CFLAGS $VORBISENC_CFLAGS"
|
||||
EXTERNAL_LIBS="$FLAC_LIBS $VORBISENC_LIBS"
|
||||
else
|
||||
enable_external_libs=no
|
||||
if test x$ac_cv_flac$ac_cv_ogg$ac_cv_vorbis$ac_cv_vorbisenc = "xyesyesyesyes" ; then
|
||||
HAVE_EXTERNAL_LIBS=1
|
||||
enable_external_libs=yes
|
||||
|
||||
EXTERNAL_CFLAGS="$FLAC_CFLAGS $OGG_CFLAGS $VORBIS_CFLAGS $VORBISENC_CFLAGS $SPEEX_CFLAGS"
|
||||
EXTERNAL_LIBS="$FLAC_LIBS $OGG_LIBS $VORBIS_LIBS $VORBISENC_LIBS $SPEEX_LIBS "
|
||||
else
|
||||
echo
|
||||
AC_MSG_WARN([[*** One or more of the external libraries (ie libflac, libogg and]])
|
||||
AC_MSG_WARN([[*** libvorbis) is either missing (possibly only the development]])
|
||||
AC_MSG_WARN([[*** headers) or is of an unsupported version.]])
|
||||
AC_MSG_WARN([[***]])
|
||||
AC_MSG_WARN([[*** Unfortunately, for ease of maintenance, the external libs]])
|
||||
AC_MSG_WARN([[*** are an all or nothing affair.]])
|
||||
echo
|
||||
enable_external_libs=no
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED([HAVE_EXTERNAL_LIBS], $HAVE_EXTERNAL_LIBS, [Will be set to 1 if flac, ogg and vorbis are available.])
|
||||
AC_DEFINE_UNQUOTED([HAVE_VORBIS_VERSION_STRING], $HAVE_VORBIS_VERSION_STRING, [Set to 1 if we have vorbis_version_string.])
|
||||
|
||||
#====================================================================================
|
||||
# Check for libsqlite3 (only used in regtest).
|
||||
|
||||
ac_cv_sqlite3=no
|
||||
#if test x$enable_sqlite != xno ; then
|
||||
# PKG_CHECK_MOD_VERSION(SQLITE3, sqlite3 >= 3.2, ac_cv_sqlite3=yes, ac_cv_sqlite3=no)
|
||||
# fi
|
||||
if test x$enable_sqlite != xno ; then
|
||||
PKG_CHECK_MOD_VERSION(SQLITE3, sqlite3 >= 3.2, ac_cv_sqlite3=yes, ac_cv_sqlite3=no)
|
||||
fi
|
||||
|
||||
if test x$ac_cv_sqlite3 = "xyes" ; then
|
||||
HAVE_SQLITE3=1
|
||||
@ -343,24 +361,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).
|
||||
|
||||
#PKG_CHECK_MOD_VERSION(JACK, jack >= 0.100, ac_cv_jack=yes, ac_cv_jack=no)
|
||||
|
||||
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
|
||||
@ -378,14 +383,19 @@ AC_DEFINE_UNQUOTED(CPU_CLIPS_NEGATIVE, ${ac_cv_c_clip_negative},
|
||||
OS_SPECIFIC_CFLAGS=""
|
||||
OS_SPECIFIC_LINKS=""
|
||||
os_is_win32=0
|
||||
os_is_macosx=0
|
||||
use_windows_api=0
|
||||
osx_darwin_version=0
|
||||
|
||||
case "$host_os" in
|
||||
darwin* | rhapsody*)
|
||||
os_is_macosx=1
|
||||
OS_SPECIFIC_CFLAGS="-fpascal-strings -I/Developer/Headers/FlatCarbon"
|
||||
OS_SPECIFIC_LINKS="-framework CoreAudio"
|
||||
osx_darwin_version=$(echo "$host_os" | sed 's/\..*//;s/darwin//g')
|
||||
if test x$HAVE_XCODE_SELECT = xyes ; then
|
||||
developer_path=`xcode-select --print-path`
|
||||
else
|
||||
developer_path="/Developer"
|
||||
fi
|
||||
OS_SPECIFIC_CFLAGS="-I${developer_path}/Headers/FlatCarbon"
|
||||
OS_SPECIFIC_LINKS="-framework CoreAudio -framework AudioToolbox -framework CoreFoundation"
|
||||
;;
|
||||
mingw*)
|
||||
os_is_win32=1
|
||||
@ -395,8 +405,9 @@ case "$host_os" in
|
||||
esac
|
||||
|
||||
AC_DEFINE_UNQUOTED(OS_IS_WIN32, ${os_is_win32}, [Set to 1 if compiling for Win32])
|
||||
AC_DEFINE_UNQUOTED(OS_IS_MACOSX, ${os_is_macosx}, [Set to 1 if compiling for MacOSX])
|
||||
AC_DEFINE_UNQUOTED(USE_WINDOWS_API, ${use_windows_api}, [Set to 1 to use the native windows API])
|
||||
AC_DEFINE_UNQUOTED(OSX_DARWIN_VERSION, ${osx_darwin_version}, [The darwin version, no-zero is valid])
|
||||
AM_CONDITIONAL(USE_WIN_VERSION_FILE, test ${use_windows_api} -eq 1)
|
||||
|
||||
#====================================================================================
|
||||
# Check for ALSA.
|
||||
@ -412,16 +423,17 @@ if test x$enable_alsa != xno ; then
|
||||
fi
|
||||
|
||||
#====================================================================================
|
||||
# Test for sanity when cross-compiling.
|
||||
# Check for OpenBSD's sndio.
|
||||
|
||||
if test x$cross_compiling = xyes ; then
|
||||
AC_MSG_WARN([[******************************************************************]])
|
||||
AC_MSG_WARN([[*** We are cross-compiling, so have to assume sizeof (short) == 2 ]])
|
||||
AC_MSG_WARN([[*** and sizeof (int) == 4. If this is not the case there is no ]])
|
||||
AC_MSG_WARN([[*** chance of this working. Please contact the mantainer. ]])
|
||||
AC_MSG_WARN([[******************************************************************]])
|
||||
SNDIO_LIBS=""
|
||||
AC_CHECK_HEADERS(sndio.h)
|
||||
if test x$ac_cv_header_sndio_h = xyes ; then
|
||||
SNDIO_LIBS="-lsndio"
|
||||
fi
|
||||
|
||||
#====================================================================================
|
||||
# Test for sanity when cross-compiling.
|
||||
|
||||
if test $ac_cv_sizeof_short != 2 ; then
|
||||
AC_MSG_WARN([[******************************************************************]])
|
||||
AC_MSG_WARN([[*** sizeof (short) != 2. ]])
|
||||
@ -454,14 +466,6 @@ if test x"$ac_cv_prog_HAVE_AUTOGEN" = "xno" ; then
|
||||
#====================================================================================
|
||||
# Settings for the HTML documentation.
|
||||
|
||||
htmldocdir=$prefix/share/doc/libsndfile1-dev/html
|
||||
|
||||
if test $prefix = "NONE" ; then
|
||||
htmldocdir=/usr/local/share/doc/libsndfile1-dev/html
|
||||
else
|
||||
htmldocdir=$prefix/share/doc/libsndfile1-dev/html
|
||||
fi
|
||||
|
||||
if test x$enable_bow_docs = "xyes" ; then
|
||||
HTML_BGCOLOUR="white"
|
||||
HTML_FGCOLOUR="black"
|
||||
@ -477,49 +481,51 @@ 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([****************************************************************])
|
||||
# AC_MSG_WARN([** GCC version 4.2 warns about the inline keyword for no good **])
|
||||
# AC_MSG_WARN([** reason but the maintainers do not see it as a bug. **])
|
||||
# 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])
|
||||
AC_MSG_WARN([****************************************************************])
|
||||
AC_MSG_WARN([** GCC version 4.2 warns about the inline keyword for no good **])
|
||||
AC_MSG_WARN([** reason but the maintainers do not see it as a bug. **])
|
||||
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([****************************************************************])
|
||||
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"
|
||||
CXXFLAGS="-Werror $CXXFLAGS"
|
||||
MN_ADD_CFLAGS([-D_FORTIFY_SOURCE=2])
|
||||
|
||||
if test x$enable_stack_smash_protection = "xyes" ; then
|
||||
XIPH_GCC_STACK_PROTECTOR
|
||||
XIPH_GXX_STACK_PROTECTOR
|
||||
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 "
|
||||
# -Wundef -Wmissing-declarations -Winline -Wconversion"
|
||||
CXXFLAGS="$CXXFLAGS -Wcast-align -Wcast-qual -Wshadow -Wwrite-strings -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wreorder -Wsign-promo "
|
||||
CFLAGS="$CFLAGS -Wcast-align -Wcast-qual -Wshadow -Wbad-function-cast -Wwrite-strings -Wundef -Wuninitialized -Winit-self -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Waggregate-return"
|
||||
# -Winline -Wconversion -Wunreachable-code"
|
||||
CXXFLAGS="$CXXFLAGS -Wcast-align -Wcast-qual -Wshadow -Wwrite-strings -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wreorder -Wsign-promo -Wundef -Wuninitialized -Winit-self"
|
||||
|
||||
if test "x$enable_gcc_opt" = "xno" ; then
|
||||
temp_CFLAGS=`echo $CFLAGS | sed "s/O2/O0/"`
|
||||
temp_CFLAGS=`echo $CFLAGS | $SED "s/O2/O0/"`
|
||||
CFLAGS=$temp_CFLAGS
|
||||
AC_MSG_WARN([[*** Compiler optimisations switched off. ***]])
|
||||
fi
|
||||
@ -529,24 +535,24 @@ if test x$ac_cv_c_compiler_gnu = xyes ; then
|
||||
darwin* | rhapsody*)
|
||||
# Disable -Wall, -pedantic and -Wshadow for Apple Darwin/Rhapsody.
|
||||
# System headers on these systems are broken.
|
||||
temp_CFLAGS=`echo $CFLAGS | sed "s/-Wall -pedantic//" | sed "s/-Wshadow//" | sed "s/-Waggregate-return//"`
|
||||
temp_CFLAGS=`echo $CFLAGS | $SED "s/-Wall -pedantic//" | $SED "s/-Wshadow//" | $SED "s/-Waggregate-return//"`
|
||||
CFLAGS=$temp_CFLAGS
|
||||
SHLIB_VERSION_ARG="-Wl,-exported_symbols_list -Wl,\$(srcdir)/Symbols.darwin"
|
||||
SHLIB_VERSION_ARG="-Wl,-exported_symbols_list -Wl,\$(builddir)/Symbols.darwin"
|
||||
;;
|
||||
linux*)
|
||||
SHLIB_VERSION_ARG="-Wl,--version-script=\$(srcdir)/Symbols.linux"
|
||||
linux*|kfreebsd*-gnu*|gnu*)
|
||||
SHLIB_VERSION_ARG="-Wl,--version-script=\$(builddir)/Symbols.gnu-binutils"
|
||||
;;
|
||||
mingw*)
|
||||
# Linker flag '-Wl,--out-implib' does not work with mingw cross compiler
|
||||
# so we don't use it here.
|
||||
SHLIB_VERSION_ARG="-Wl,\$(srcdir)/libsndfile-1.def"
|
||||
SHLIB_VERSION_ARG="-Wl,\$(builddir)/libsndfile-1.def"
|
||||
win32_target_dll=1
|
||||
if test x"$enable_shared" = xno ; then
|
||||
win32_target_dll=0
|
||||
fi
|
||||
;;
|
||||
os2*)
|
||||
SHLIB_VERSION_ARG="-Wl,-export-symbols \$(srcdir)/Symbols.os2"
|
||||
SHLIB_VERSION_ARG="-Wl,-export-symbols \$(builddir)/Symbols.os2"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
@ -558,36 +564,17 @@ if test x$ac_cv_c_compiler_gnu = xyes ; then
|
||||
COMPILER_IS_GCC=1
|
||||
fi
|
||||
|
||||
if test x$enable_werror = "xyes" ; then
|
||||
MN_ADD_CFLAGS([-Werror])
|
||||
|
||||
AC_LANG_PUSH([C++])
|
||||
MN_ADD_CXXFLAGS([-Werror])
|
||||
AC_LANG_POP([C++])
|
||||
fi
|
||||
|
||||
|
||||
AC_DEFINE_UNQUOTED([WIN32_TARGET_DLL], ${win32_target_dll}, [Set to 1 if windows DLL is being built.])
|
||||
AC_DEFINE_UNQUOTED([COMPILER_IS_GCC], ${COMPILER_IS_GCC}, [Set to 1 if the compile is GNU GCC.])
|
||||
AC_DEFUN([AX_COMPILER_VENDOR],
|
||||
[
|
||||
AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
|
||||
[ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown
|
||||
# note: don't check for gcc first since some other compilers define __GNUC__
|
||||
for ventest in intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI; do
|
||||
vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
|
||||
#if !($vencpp)
|
||||
thisisanerror;
|
||||
#endif
|
||||
])], [ax_cv_]_AC_LANG_ABBREV[_compiler_vendor=`echo $ventest | cut -d: -f1`; break])
|
||||
done
|
||||
])
|
||||
])
|
||||
|
||||
AX_COMPILER_VENDOR
|
||||
|
||||
# Enable 64 bit build
|
||||
AC_ARG_ENABLE(64,
|
||||
[AC_HELP_STRING([--enable-64],[build with 64 bit support])],[enable_64="$enable_64"],[enable_64="no"])
|
||||
|
||||
if test "x${ax_cv_c_compiler_vendor}" = "xsun" ; then
|
||||
if test "${enable_64}" = "yes"; then
|
||||
CFLAGS="$CFLAGS -m64"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
CFLAGS="$CFLAGS $OS_SPECIFIC_CFLAGS"
|
||||
|
||||
@ -596,43 +583,64 @@ if test x"$CFLAGS" = x ; then
|
||||
exit
|
||||
fi
|
||||
|
||||
HOST_TRIPLET="${host_cpu}-${host_vendor}-${host_os}"
|
||||
|
||||
AC_DEFINE_UNQUOTED([HOST_TRIPLET], "${HOST_TRIPLET}", [The host triplet of the compiled binary.])
|
||||
|
||||
if test "$HOST_TRIPLET" = "x86_64-w64-mingw32" ; then
|
||||
OS_SPECIFIC_LINKS=" -static-libgcc $OS_SPECIFIC_LINKS"
|
||||
fi
|
||||
|
||||
WIN_RC_VERSION=`echo $PACKAGE_VERSION | $SED -e "s/p.*//" -e "s/\./,/g"`
|
||||
|
||||
|
||||
if test "$enable_static" = no ; then
|
||||
SRC_BINDIR=src/.libs/
|
||||
TEST_BINDIR=tests/.libs/
|
||||
else
|
||||
SRC_BINDIR=src/
|
||||
TEST_BINDIR=tests/
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
AC_SUBST(htmldocdir)
|
||||
AC_SUBST(HOST_TRIPLET)
|
||||
|
||||
AC_SUBST(HTML_BGCOLOUR)
|
||||
AC_SUBST(HTML_FGCOLOUR)
|
||||
|
||||
AC_SUBST(SHLIB_VERSION_ARG)
|
||||
AC_SUBST(SHARED_VERSION_INFO)
|
||||
AC_SUBST(CLEAN_VERSION)
|
||||
AC_SUBST(WIN_RC_VERSION)
|
||||
|
||||
AC_SUBST(OS_SPECIFIC_CFLAGS)
|
||||
AC_SUBST(OS_SPECIFIC_LINKS)
|
||||
AC_SUBST(ALSA_LIBS)
|
||||
AC_SUBST(ENABLE_EXPERIMENTAL_CODE)
|
||||
AC_SUBST(SNDIO_LIBS)
|
||||
|
||||
AC_SUBST(EXTERNAL_CFLAGS)
|
||||
AC_SUBST(EXTERNAL_LIBS)
|
||||
|
||||
AC_SUBST(COMPILER_IS_GCC)
|
||||
AC_SUBST(GCC_MAJOR_VERSION)
|
||||
|
||||
AC_SUBST(HAVE_JACK)
|
||||
AC_SUBST(SRC_BINDIR)
|
||||
AC_SUBST(TEST_BINDIR)
|
||||
|
||||
dnl The following line causes the libtool distributed with the source
|
||||
dnl to be replaced if the build system has a more recent version.
|
||||
AC_SUBST(LIBTOOL_DEPS)
|
||||
|
||||
AC_CONFIG_FILES([ \
|
||||
src/sndfile.h src/Makefile src/GSM610/Makefile src/G72x/Makefile \
|
||||
man/Makefile examples/Makefile tests/Makefile regtest/Makefile \
|
||||
M4/Makefile doc/Makefile Win32/Makefile Octave/Makefile \
|
||||
programs/Makefile doc/libsndfile.css \
|
||||
Makefile libsndfile.spec sndfile.pc \
|
||||
tests/test_wrapper.sh \
|
||||
src/Makefile man/Makefile examples/Makefile tests/Makefile regtest/Makefile \
|
||||
M4/Makefile doc/Makefile Win32/Makefile Octave/Makefile programs/Makefile \
|
||||
Makefile \
|
||||
src/version-metadata.rc tests/test_wrapper.sh tests/pedantic-header-test.sh \
|
||||
doc/libsndfile.css Scripts/build-test-tarball.mk libsndfile.spec sndfile.pc \
|
||||
src/sndfile.h \
|
||||
echo-install-dirs
|
||||
])
|
||||
AC_OUTPUT
|
||||
|
||||
# Make it executable.
|
||||
chmod u+x tests/test_wrapper.sh
|
||||
# Make sure these are executable.
|
||||
chmod u+x tests/test_wrapper.sh build-test-tarball.mk echo-install-dirs
|
||||
|
||||
#====================================================================================
|
||||
|
||||
@ -641,46 +649,45 @@ AC_MSG_RESULT([
|
||||
|
||||
Configuration summary :
|
||||
|
||||
Version : ............................. ${VERSION}
|
||||
libsndfile version : .................. ${VERSION}
|
||||
|
||||
Host CPU : ............................ ${host_cpu}
|
||||
Host Vendor : ......................... ${host_vendor}
|
||||
Host OS : ............................. ${host_os}
|
||||
|
||||
Experimental code : ................... ${enable_experimental:-no}
|
||||
Using ALSA in example programs : ...... ${enable_alsa:-no}
|
||||
External FLAC/Ogg/Vorbis : ............ ${enable_external_libs:-no}
|
||||
|
||||
])
|
||||
|
||||
if test -z "$PKG_CONFIG" ; then
|
||||
echo " *****************************************************************"
|
||||
echo " *** The pkg-config program is missing. ***"
|
||||
echo " *** External FLAC/Ogg/Vorbis libs cannot be found without it. ***"
|
||||
echo " *** http://pkg-config.freedesktop.org/wiki/ ***"
|
||||
echo " *****************************************************************"
|
||||
echo
|
||||
fi
|
||||
|
||||
echo " Tools :"
|
||||
echo
|
||||
echo " Compiler is Clang : ................... ${mn_cv_c_compiler_clang}"
|
||||
echo " Compiler is GCC : ..................... ${ac_cv_c_compiler_gnu}"
|
||||
|
||||
if test x$ac_cv_c_compiler_gnu = xyes ; then
|
||||
echo -e " Tools :\n"
|
||||
echo " Compiler is GCC : ..................... ${ac_cv_c_compiler_gnu}"
|
||||
echo " GCC version : ......................... ${GCC_VERSION}"
|
||||
if test $GCC_MAJOR_VERSION -lt 3 ; then
|
||||
echo -e "\n ** This compiler version allows applications to write"
|
||||
echo "\n"
|
||||
echo " ** This compiler version allows applications to write"
|
||||
echo " ** to static strings within the library."
|
||||
echo " ** Compile with GCC version 3.X or above to avoid this problem."
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $libdir = "\${exec_prefix}/lib" ; then
|
||||
libdir="$prefix/lib"
|
||||
fi
|
||||
./echo-install-dirs
|
||||
|
||||
if test $bindir = "\${exec_prefix}/bin" ; then
|
||||
bindir="$prefix/bin"
|
||||
fi
|
||||
|
||||
AC_MSG_RESULT([[
|
||||
Installation directories :
|
||||
|
||||
Library directory : ................... $libdir
|
||||
Program directory : ................... $bindir
|
||||
Pkgconfig directory : ................. $libdir/pkgconfig
|
||||
HTML docs directory : ................. $htmldocdir
|
||||
]])
|
||||
|
||||
if test x$prefix != "x/usr" ; then
|
||||
echo "Compiling some other packages against libsndfile may require"
|
||||
echo -e "the addition of \"$libdir/pkgconfig\" to the"
|
||||
echo -e "PKG_CONFIG_PATH environment variable.\n"
|
||||
fi
|
||||
# Remove symlink created by Scripts/android-configure.sh.
|
||||
test -h gdbclient && rm -f gdbclient
|
||||
|
||||
(cd src && make genfiles)
|
||||
(cd tests && make genfiles)
|
||||
|
@ -8,65 +8,70 @@
|
||||
<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>
|
||||
|
||||
<H1><B>libsndfile : Frequently Asked Questions.</B></H1>
|
||||
<P>
|
||||
<A HREF="#Q001">Q1 : Do you plan to support XYZ codec in libsndfile?</A><BR>
|
||||
<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>
|
||||
but version 1 does not. 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
|
||||
presence of libsndfile?</A><BR>
|
||||
<A HREF="#Q008">Q8 : But I just want a simple Makefile! What do I do?</A><BR>
|
||||
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/MacOS X, what's the best way of detecting the
|
||||
presence of libsndfile?</A><BR/>
|
||||
<A HREF="#Q008">Q8 : I have libsndfile installed and now I want to use it. 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
|
||||
memory buffers?</A><BR>
|
||||
memory buffers?</A><BR/>
|
||||
<A HREF="#Q010">Q10 : Reading a 16 bit PCM file as normalised floats and then
|
||||
writing them back changes some sample values. Why?</A><BR>
|
||||
writing them back changes some sample values. Why?</A><BR/>
|
||||
<A HREF="#Q011">Q11 : I'm having problems with u-law encoded WAV files generated by
|
||||
libsndfile in Winamp. Why?</A><BR>
|
||||
<A HREF="#Q012">Q12 : I'm looking at sf_read*. What are items? What are frames?</A><BR>
|
||||
libsndfile in Winamp. Why?</A><BR/>
|
||||
<A HREF="#Q012">Q12 : I'm looking at sf_read*. What are items? What are frames?</A><BR/>
|
||||
<A HREF="#Q013">Q13 : Why can't libsndfile open this Sound Designer II (SD2)
|
||||
file?</A><BR>
|
||||
file?</A><BR/>
|
||||
<A HREF="#Q014">Q14 : I'd like to statically link libsndfile to my closed source
|
||||
application. Can I buy a license so that this is possible?</A><BR>
|
||||
application. Can I buy a license so that this is possible?</A><BR/>
|
||||
<A HREF="#Q015">Q15 : My program is crashing during a call to a function in libsndfile.
|
||||
Is this a bug in libsndfile?</A><BR>
|
||||
Is this a bug in libsndfile?</A><BR/>
|
||||
<A HREF="#Q016">Q16 : Will you accept a fix for compiling libsndfile with compiler X?
|
||||
</A><BR>
|
||||
</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><BR>
|
||||
</A><BR/>
|
||||
<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?
|
||||
</A><BR>
|
||||
</A><BR/>
|
||||
<A HREF="#Q020">Q20 : Why doesn't libsndfile support MP3? Lots of other Open Source
|
||||
projects support it!
|
||||
</A><BR>
|
||||
</A><BR/>
|
||||
<A HREF="#Q021">Q21 : How do I use libsndfile in a closed source or commercial program
|
||||
and comply with the license?
|
||||
</A><BR>
|
||||
</A><BR/>
|
||||
<A HREF="#Q022">Q22 : What versions of windows does libsndfile work on?
|
||||
</A><BR>
|
||||
</A><BR/>
|
||||
<A HREF="#Q023">Q23 : I'm cross compiling libsndfile for another platform. How can I
|
||||
run the test suite?
|
||||
</A><BR/>
|
||||
<HR>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q001"></A>
|
||||
<H2><BR><B>Q1 : Do you plan to support XYZ codec in libsnfile?</B></H2>
|
||||
<H2><BR/><B>Q1 : Do you plan to support XYZ codec in libsndfile?</B></H2>
|
||||
<P>
|
||||
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>
|
||||
@ -80,7 +85,7 @@ If you can't find either then the answer is no.
|
||||
</P>
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q002"></A>
|
||||
<H2><BR><B>Q2 : In version 0 the SF_INFO struct had a pcmbitwidth field
|
||||
<H2><BR/><B>Q2 : In version 0 the SF_INFO struct had a pcmbitwidth field
|
||||
but version 1 does not. Why?</B></H2>
|
||||
<P>
|
||||
This was dropped for a number of reasons:
|
||||
@ -91,50 +96,50 @@ If you can't find either then the answer is no.
|
||||
</UL>
|
||||
<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
|
||||
<A HREF="api.html#note1">here</A>
|
||||
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>
|
||||
To fix this I suggest that you install the GNU Bash shell, rename /bin/sh to
|
||||
/bin/sh.old and make a softlink from /bin/sh to the bash shell.
|
||||
/bin/sh.old and make a symlink from /bin/sh to the bash shell.
|
||||
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>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q004"></A>
|
||||
<H2><BR><B>Q4 : When trying to compile libsndfile on Solaris I get a "bad
|
||||
<H2><BR/><B>Q4 : When trying to compile libsndfile on Solaris I get a "bad
|
||||
substitution" error on linking. Why?</B></H2>
|
||||
<P>
|
||||
It seems that the Solaris Bourne shell disagrees with GNU libtool.
|
||||
</P>
|
||||
<P>
|
||||
To fix this I suggest that you install the GNU Bash shell, rename /bin/sh to
|
||||
/bin/sh.old and make a softlink from /bin/sh to the bash shell.
|
||||
/bin/sh.old and make a symlink from /bin/sh to the bash shell.
|
||||
Bash is designed to behave as a Bourne shell when is is called as /bin/sh.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q005"></A>
|
||||
<H2><BR><B>Q5 : Why doesn't libsndfile do interleaving/de-interleaving?</B></H2>
|
||||
<H2><BR/><B>Q5 : Why doesn't libsndfile do interleaving/de-interleaving?</B></H2>
|
||||
<P>
|
||||
This problem is bigger than it may seem at first.
|
||||
</P>
|
||||
@ -143,7 +148,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>
|
||||
@ -156,7 +161,7 @@ This means that this feature will not be added any time soon.
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q006"></A>
|
||||
<H2><BR><B>Q6 : What's the best format for storing temporary files?</B></H2>
|
||||
<H2><BR/><B>Q6 : What's the best format for storing temporary files?</B></H2>
|
||||
|
||||
<P>
|
||||
When you want to store temporary data there are a number of requirements;
|
||||
@ -184,7 +189,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>
|
||||
@ -242,7 +247,8 @@ libsndfile configure process. For instance on my system I get this:
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
<A NAME="Q008"></A>
|
||||
<H2><BR><B>Q8 : But I just want a simple Makefile! What do I do?</B></H2>
|
||||
<H2><BR/><B>Q8 : I have libsndfile installed and now I want to use it. I just want
|
||||
a simple Makefile! What do I do?</B></H2>
|
||||
|
||||
<P>
|
||||
The <B>pkg-config</B> program makes finding the correct compiler flag values and
|
||||
@ -277,7 +283,7 @@ the command would be:
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
<A NAME="Q009"></A>
|
||||
<H2><BR><B>Q9 : How about adding the ability to write/read sound files to/from
|
||||
<H2><BR/><B>Q9 : How about adding the ability to write/read sound files to/from
|
||||
memory buffers?</B></H2>
|
||||
|
||||
<P>
|
||||
@ -287,7 +293,7 @@ This has been added for version 1.0.13.
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
<A NAME="Q010"></A>
|
||||
<H2><BR><B>Q10 : Reading a 16 bit PCM file as normalised floats and then
|
||||
<H2><BR/><B>Q10 : Reading a 16 bit PCM file as normalised floats and then
|
||||
writing them back changes some sample values. Why?</B></H2>
|
||||
|
||||
<P>
|
||||
@ -335,7 +341,7 @@ other than normalized floats in the application.
|
||||
Alternatives to normalized floats are the <b>short</b> and <b>int</b> data
|
||||
types (ie using sf_read_short or sf_read_int) or using un-normalized floats
|
||||
(see
|
||||
<a href="http://www.mega-nerd.com/libsndfile/command.html#SFC_SET_NORM_FLOAT">
|
||||
<a href="command.html#SFC_SET_NORM_FLOAT">
|
||||
SFC_SET_NORM_FLOAT</a>).
|
||||
</P>
|
||||
<P>
|
||||
@ -352,7 +358,7 @@ storage format (and which is also supported by most common file types).
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
<A NAME="Q011"></A>
|
||||
<H2><BR><B>Q11 : I'm having problems with u-law encoded WAV files generated by
|
||||
<H2><BR/><B>Q11 : I'm having problems with u-law encoded WAV files generated by
|
||||
libsndfile in Winamp. Why?
|
||||
</B></H2>
|
||||
|
||||
@ -381,21 +387,48 @@ is the risk of breaking something that currently works.
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
<A NAME="Q012"></A>
|
||||
<H2><BR><B>Q12 : I'm looking at sf_read*. What are items? What are frames?
|
||||
<H2><BR/><B>Q12 : I'm looking at sf_read*. What are items? What are frames?
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
For a sound file with only one channel, a frame is the same as a item.
|
||||
An <tt>item</tt> is a single sample of the data type you are reading; ie a
|
||||
single <tt>short</tt> value for <tt>sf_read_short</tt> or a single <tt>float</tt>
|
||||
for <tt>sf_read_float</tt>.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
For multi channel sound files, a single frame contains a single item for
|
||||
each channel.
|
||||
For a sound file with only one channel, a frame is the same as a item (ie a
|
||||
single sample) while for multi channel sound files, a single frame contains a
|
||||
single item for each channel.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
Here are two simple, correct examples, both of which are assumed to be working
|
||||
on a stereo file, first using items:
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
#define CHANNELS 2
|
||||
short data [CHANNELS * 100] ;
|
||||
sf_count items_read = sf_read_short (file, data, 200) ;
|
||||
assert (items_read == 200) ;
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
and now readng the exact same amount of data using frames:
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
#define CHANNELS 2
|
||||
short data [CHANNELS * 100] ;
|
||||
sf_count frames_read = sf_readf_short (file, data, 100) ;
|
||||
assert (frames_read == 100) ;
|
||||
</PRE>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
<A NAME="Q013"></A>
|
||||
<H2><BR><B>Q13 : Why can't libsndfile open this Sound Designer II (SD2) file?
|
||||
<H2><BR/><B>Q13 : Why can't libsndfile open this Sound Designer II (SD2) file?
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
@ -407,7 +440,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>
|
||||
|
||||
@ -419,7 +452,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.
|
||||
@ -436,8 +469,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>
|
||||
@ -475,7 +508,7 @@ files are.
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q014"></A>
|
||||
<H2><BR><B>Q14 : I'd like to statically link libsndfile to my closed source
|
||||
<H2><BR/><B>Q14 : I'd like to statically link libsndfile to my closed source
|
||||
application. Can I buy a license so that this is possible?
|
||||
</B></H2>
|
||||
|
||||
@ -494,7 +527,7 @@ library is if your application is released under the GNU GPL or LGPL.
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q015"></A>
|
||||
<H2><BR><B>Q15 : My program is crashing during a call to a function in libsndfile.
|
||||
<H2><BR/><B>Q15 : My program is crashing during a call to a function in libsndfile.
|
||||
Is this a bug in libsndfile?
|
||||
</B></H2>
|
||||
|
||||
@ -527,7 +560,7 @@ following:
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q016"></A>
|
||||
<H2><BR><B>Q16 : Will you accept a fix for compiling libsndfile with compiler X?
|
||||
<H2><BR/><B>Q16 : Will you accept a fix for compiling libsndfile with compiler X?
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
@ -548,7 +581,7 @@ This can make compiling libsndfile with some older compilers difficult.
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q017"></A>
|
||||
<H2><BR><B>Q17 : Can libsndfile read/write files from/to UNIX pipes?
|
||||
<H2><BR/><B>Q17 : Can libsndfile read/write files from/to UNIX pipes?
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
@ -583,7 +616,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>
|
||||
@ -644,7 +677,7 @@ libsndfile is currently working on.
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q019"></A>
|
||||
<H2><BR><B>Q19 : I have project files for Visual Studio / XCode / Whatever. Why
|
||||
<H2><BR/><B>Q19 : I have project files for Visual Studio / XCode / Whatever. Why
|
||||
don't you distribute them with libsndfile?
|
||||
</B></H2>
|
||||
|
||||
@ -674,7 +707,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
|
||||
@ -696,7 +729,7 @@ Hence, I'm not willing to enter into an arrangement like that again.
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q020"></A>
|
||||
<H2><BR><B>Q20 : Why doesn't libsndfile support MP3? Lots of other Open Source
|
||||
<H2><BR/><B>Q20 : Why doesn't libsndfile support MP3? Lots of other Open Source
|
||||
projects support it!
|
||||
</B></H2>
|
||||
|
||||
@ -721,8 +754,7 @@ Some of those authors may be students and hence wouldn't be worth pursuing.
|
||||
However, libsndfile is released under the name of a company, Mega Nerd Pty Ltd;
|
||||
a company which has income from from libsamplerate licensing, libsndfile based
|
||||
consulting income and other unrelated consulting income.
|
||||
Adding MP3 support to libsndfile could place that income would be under legal
|
||||
threat.
|
||||
Adding MP3 support to libsndfile could place that income under legal threat.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@ -734,7 +766,7 @@ John ffitch of the Csound project) in version 1.0.18.
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q021"></A>
|
||||
<H2><BR><B>Q21 : How do I use libsndfile in a closed source or commercial program
|
||||
<H2><BR/><B>Q21 : How do I use libsndfile in a closed source or commercial program
|
||||
and comply with the license?
|
||||
</B></H2>
|
||||
|
||||
@ -746,7 +778,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.
|
||||
@ -762,28 +794,57 @@ 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 tested in Windows XP.
|
||||
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>
|
||||
libsndfile does not yet work on 64 bit versions of windows.
|
||||
Support for 64 bit versions of WinXP and Vista is likely to be working some
|
||||
time late in 2008.
|
||||
Since version 0.1.18 I have also been releasing precompiled binaries for Win64,
|
||||
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.
|
||||
</p>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q023"></A>
|
||||
<H2><BR/><B>Q23 : I'm cross compiling libsndfile for another platform. How can I
|
||||
run the test suite?
|
||||
</B></H2>
|
||||
|
||||
<p>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Since version 1.0.21 the top level Makefile has an extra make target,
|
||||
'test-tarball'.
|
||||
Building this target creates a tarball called called:
|
||||
</p>
|
||||
|
||||
<center><tt>
|
||||
libsndfile-testsuite-${host_triplet}-${version}.tar.gz
|
||||
</tt></center>
|
||||
|
||||
<p>
|
||||
in the top level directory.
|
||||
This tarball can then be copied to the target platform.
|
||||
Once untarred and test script <tt>test_wrapper.sh</tt> can be run from
|
||||
the top level of the extracted tarball.
|
||||
</p>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<HR>
|
||||
<P>
|
||||
The libsndfile home page is here :
|
||||
<A HREF="http://www.mega-nerd.com/libsndfile/">
|
||||
http://www.mega-nerd.com/libsndfile/</A>.
|
||||
<BR>
|
||||
Version : 1.0.19
|
||||
<BR/>
|
||||
Version : 1.0.25
|
||||
</P>
|
||||
|
||||
</BODY>
|
||||
|
@ -1,8 +1,7 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
htmldir = $(htmldocdir)
|
||||
html_DATA = index.html libsndfile.jpg libsndfile.css api.html command.html \
|
||||
bugs.html sndfile_info.html new_file_type.HOWTO pkgconfig.html \
|
||||
bugs.html sndfile_info.html new_file_type.HOWTO \
|
||||
win32.html FAQ.html lists.html embedded_files.html octave.html \
|
||||
dither.html tutorial.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,9 +35,15 @@
|
||||
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
|
||||
<A HREF="mailto:erikd@zip.com.au">
|
||||
Erik de Castro Lopo</a>.
|
||||
If any errors, omissions or ambiguities are found, please notify me (erikd)
|
||||
at mega-nerd dot com.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
To supplement this reference documentation, there are simple example programs
|
||||
included in the source code tarball.
|
||||
The test suite which is also part of the source code tarball is also a good
|
||||
place to look for the correct usage of the library functions.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
@ -46,7 +53,7 @@
|
||||
</B>
|
||||
</P>
|
||||
|
||||
<H2><B>SYNOPSIS</B></H2>
|
||||
<H2><B>Synopsis</B></H2>
|
||||
<P>
|
||||
The functions of libsndfile are defined as follows:
|
||||
</P>
|
||||
@ -57,7 +64,7 @@ The functions of libsndfile are defined as follows:
|
||||
|
||||
SNDFILE* <A HREF="#open">sf_open</A> (const char *path, int mode, SF_INFO *sfinfo) ;
|
||||
SNDFILE* <A HREF="#open_fd">sf_open_fd</A> (int fd, int mode, SF_INFO *sfinfo, int close_desc) ;
|
||||
|
||||
SNDFILE* <A HREF="#open_virtual">sf_open_virtual</A> (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) ;
|
||||
int <A HREF="#check">sf_format_check</A> (const SF_INFO *info) ;
|
||||
|
||||
sf_count_t <A HREF="#seek">sf_seek</A> (SNDFILE *sndfile, sf_count_t frames, int whence) ;
|
||||
@ -186,6 +193,10 @@ Not all combinations of endian-ness and major and minor file types are valid.
|
||||
SF_FORMAT_SD2 = 0x160000, /* Sound Designer 2 */
|
||||
SF_FORMAT_FLAC = 0x170000, /* FLAC lossless file format */
|
||||
SF_FORMAT_CAF = 0x180000, /* Core Audio File format */
|
||||
SF_FORMAT_WVE = 0x190000, /* Psion WVE format */
|
||||
SF_FORMAT_OGG = 0x200000, /* Xiph OGG container */
|
||||
SF_FORMAT_MPC2K = 0x210000, /* Akai MPC 2000 sampler */
|
||||
SF_FORMAT_RF64 = 0x220000, /* RF64 WAV file */
|
||||
|
||||
/* Subtypes from here on. */
|
||||
|
||||
@ -219,6 +230,8 @@ Not all combinations of endian-ness and major and minor file types are valid.
|
||||
SF_FORMAT_DPCM_8 = 0x0050, /* 8 bit differential PCM (XI only) */
|
||||
SF_FORMAT_DPCM_16 = 0x0051, /* 16 bit differential PCM (XI only) */
|
||||
|
||||
SF_FORMAT_VORBIS = 0x0060, /* Xiph Vorbis encoding. */
|
||||
|
||||
/* Endian-ness options. */
|
||||
|
||||
SF_ENDIAN_FILE = 0x00000000, /* Default file endian-ness. */
|
||||
@ -238,10 +251,12 @@ 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.
|
||||
An explanation of the error can obtained by passing NULL to
|
||||
<A HREF="#error">sf_strerror</A>.
|
||||
</P>
|
||||
|
||||
<A NAME="open_fd"></A>
|
||||
@ -251,6 +266,11 @@ On fail, the sf_open function returns a NULL pointer.
|
||||
SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ;
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
<b>Note:</b> On Microsoft Windows, this function does not work if the
|
||||
application and the libsndfile DLL are linked to different versions of the
|
||||
Microsoft C runtime DLL.
|
||||
</P>
|
||||
<P>
|
||||
The second open function takes a file descriptor of a file that has already been
|
||||
opened.
|
||||
@ -280,12 +300,92 @@ 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.
|
||||
</P>
|
||||
|
||||
<A NAME="open_virtual"></A>
|
||||
<h3><b>Virtual File Open Function</b></h3>
|
||||
<pre>
|
||||
SNDFILE* sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) ;
|
||||
</pre>
|
||||
<p>
|
||||
Opens a soundfile from a virtual file I/O context which is provided
|
||||
by the caller. This is usually used to interface libsndfile to a stream or buffer
|
||||
based system. Apart from the sfvirtual and the user_data parameters this function behaves
|
||||
like <a href="#open">sf_open</a>.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
typedef struct
|
||||
{ sf_vio_get_filelen get_filelen ;
|
||||
sf_vio_seek seek ;
|
||||
sf_vio_read read ;
|
||||
sf_vio_write write ;
|
||||
sf_vio_tell tell ;
|
||||
} SF_VIRTUAL_IO ;
|
||||
</pre>
|
||||
<p>
|
||||
Libsndfile calls the callbacks provided by the SF_VIRTUAL_IO structure when opening, reading
|
||||
and writing to the virtual file context. The user_data pointer is a user defined context which
|
||||
will be available in the callbacks.
|
||||
</p>
|
||||
<pre>
|
||||
typedef sf_count_t (*sf_vio_get_filelen) (void *user_data) ;
|
||||
typedef sf_count_t (*sf_vio_seek) (sf_count_t offset, int whence, void *user_data) ;
|
||||
typedef sf_count_t (*sf_vio_read) (void *ptr, sf_count_t count, void *user_data) ;
|
||||
typedef sf_count_t (*sf_vio_write) (const void *ptr, sf_count_t count, void *user_data) ;
|
||||
typedef sf_count_t (*sf_vio_tell) (void *user_data) ;
|
||||
</pre>
|
||||
<h4>sf_vio_get_filelen</h4>
|
||||
<pre>
|
||||
typedef sf_count_t (*sf_vio_get_filelen) (void *user_data) ;
|
||||
</pre>
|
||||
<p>
|
||||
The virtual file contex must return the length of the virtual file in bytes.<br>
|
||||
</p>
|
||||
<h4>sf_vio_seek</h4>
|
||||
<pre>
|
||||
typedef sf_count_t (*sf_vio_seek) (sf_count_t offset, int whence, void *user_data) ;
|
||||
</pre>
|
||||
<p>
|
||||
The virtual file context must seek to offset using the seek mode provided by whence which is one of<br>
|
||||
</p>
|
||||
<pre>
|
||||
SEEK_CUR
|
||||
SEEK_SET
|
||||
SEEK_END
|
||||
</pre>
|
||||
<p>
|
||||
The return value must contain the new offset in the file.
|
||||
</p>
|
||||
<h4>sf_vio_read</h4>
|
||||
<pre>
|
||||
typedef sf_count_t (*sf_vio_read) (void *ptr, sf_count_t count, void *user_data) ;
|
||||
</pre>
|
||||
<p>
|
||||
The virtual file context must copy ("read") "count" bytes into the
|
||||
buffer provided by ptr and return the count of actually copied bytes.
|
||||
</p>
|
||||
<h4>sf_vio_write</h4>
|
||||
<pre>
|
||||
typedef sf_count_t (*sf_vio_write) (const void *ptr, sf_count_t count, void *user_data) ;
|
||||
</pre>
|
||||
<p>
|
||||
The virtual file context must process "count" bytes stored in the
|
||||
buffer passed with ptr and return the count of actually processed bytes.<br>
|
||||
</p>
|
||||
<h4>sf_vio_tell</h4>
|
||||
<pre>
|
||||
typedef sf_count_t (*sf_vio_tell) (void *user_data) ;
|
||||
</pre>
|
||||
<p>
|
||||
Return the current position of the virtual file context.<br>
|
||||
</p>
|
||||
|
||||
|
||||
<A NAME="check"></A>
|
||||
<BR><H2><B>Format Check Function</B></H2>
|
||||
|
||||
@ -541,6 +641,12 @@ same as the frames parameter).
|
||||
sf_count_t sf_write_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ;
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
<b>Note:</b> Unless you are writing an external decoder/encode that uses
|
||||
libsndfile to handle the file headers, you should not be using these
|
||||
functions.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
The raw read and write functions read raw audio data from the audio file (not to be
|
||||
confused with reading RAW header-less PCM files). The number of bytes read or written
|
||||
@ -586,12 +692,16 @@ The <B>str_type</B> parameter can be any one of the following string types:
|
||||
SF_STR_SOFTWARE,
|
||||
SF_STR_ARTIST,
|
||||
SF_STR_COMMENT,
|
||||
SF_STR_DATE
|
||||
SF_STR_DATE,
|
||||
SF_STR_ALBUM,
|
||||
SF_STR_LICENSE,
|
||||
SF_STR_TRACKNUMBER,
|
||||
SF_STR_GENRE
|
||||
} ;
|
||||
</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
|
||||
@ -648,7 +758,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>
|
||||
@ -660,7 +770,7 @@ and a parameter of SF_TRUE to force correct scaling.
|
||||
<A HREF="http://www.mega-nerd.com/libsndfile/">here</A>.
|
||||
</P>
|
||||
<P>
|
||||
Version : 1.0.19
|
||||
Version : 1.0.25
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<!-- pepper -->
|
||||
|
@ -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
|
||||
@ -67,9 +68,8 @@
|
||||
problems.
|
||||
</P>
|
||||
<P>
|
||||
Once you have the above information you should email it to one of the
|
||||
<A HREF="lists.html">mailing lists</a>
|
||||
(posting to these lists is limited to the list subscribers).
|
||||
Once you have the above information you should submit a ticket on the libsnfile
|
||||
<A HREF="https://github.com/erikd/libsndfile/issues">github issue tracker</A>.
|
||||
|
||||
</P>
|
||||
</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>
|
||||
@ -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>
|
||||
@ -187,7 +188,12 @@
|
||||
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_SET_VBR_ENCODING_QUALITY">SFC_SET_VBR_ENCODING_QUALITY</A></TD>
|
||||
<TD>Set the the Variable Bit Rate encoding quality</TD>
|
||||
<TD>Set the Variable Bit Rate encoding quality</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_SET_COMPRESSION_LEVEL">SFC_SET_COMPRESSION_LEVEL</A></TD>
|
||||
<TD>Set the compression level.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
@ -205,6 +211,33 @@
|
||||
<TD>Set the Broadcast Chunk info</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_SET_CART_INFO">SFC_SET_CART_INFO</A></TD>
|
||||
<TD>Set the Cart Chunk info</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_GET_CART_INFO">SFC_GET_CART_INFO</A></TD>
|
||||
<TD>Retrieve the Cart Chunk info</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_GET_LOOP_INFO">SFC_GET_LOOP_INFO</A></TD>
|
||||
<TD>Get loop info</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_GET_INSTRUMENT">SFC_GET_INSTRUMENT</A></TD>
|
||||
<TD>Get instrument info</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_SET_INSTRUMENT">SFC_SET_INSTRUMENT</A></TD>
|
||||
<TD>Set instrument info</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
<TR>
|
||||
<TD><A HREF="#add-dither">add dither</A></TD>
|
||||
@ -891,7 +924,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 +942,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 ;
|
||||
@ -1242,7 +1275,7 @@ Parameters:
|
||||
</P>
|
||||
<DL>
|
||||
<DT>Return value: </DT>
|
||||
<DD>SF_AMBISONIC_NONE or SF_AMBISONIC_B_FORMAT or zero if the file format
|
||||
<DD>SF_AMBISONIC_NONE or SF_AMBISONIC_B_FORMAT or zero if the file format
|
||||
does not support ambisonic formats.
|
||||
</DL>
|
||||
|
||||
@ -1279,9 +1312,10 @@ This command is currently only supported for files with SF_FORMAT_WAVEX format.
|
||||
<A NAME="SFC_SET_VBR_ENCODING_QUALITY"></A>
|
||||
<H2><BR><B>SFC_SET_VBR_ENCODING_QUALITY</B></H2>
|
||||
<P>
|
||||
Set the the Variable Bit Rate encoding quality.
|
||||
Set the Variable Bit Rate encoding quality.
|
||||
The encoding quality value should be between 0.0 (lowest quality) and 1.0
|
||||
(highest quality).
|
||||
Currenly this command is only implemented for FLAC and Ogg/Vorbis files.
|
||||
</P>
|
||||
<P>
|
||||
Parameters:
|
||||
@ -1297,8 +1331,37 @@ The command must be sent before any audio data is written to the file.
|
||||
<P>
|
||||
</P>
|
||||
<DL>
|
||||
<DT>Return value: </DT>
|
||||
<DD>Zero on success, non-zero otherwise.
|
||||
<DT>Return value:</DT>
|
||||
<dd>SF_TRUE if VBR encoding quality was set.
|
||||
SF_FALSE otherwise.
|
||||
</DL>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="SFC_SET_COMPRESSION_LEVEL"></A>
|
||||
<H2><BR><B>SFC_SET_COMPRESSION_LEVEL</B></H2>
|
||||
<P>
|
||||
Set the compression level.
|
||||
The compression level should be between 0.0 (minimum compression level) and 1.0
|
||||
(highest compression level).
|
||||
Currenly this command is only implemented for FLAC and Ogg/Vorbis files.
|
||||
</P>
|
||||
<P>
|
||||
Parameters:
|
||||
<PRE>
|
||||
sndfile : A valid SNDFILE* pointer
|
||||
cmd : SFC_SET_COMPRESSION_LEVEL
|
||||
data : A pointer to a double value
|
||||
datasize : sizeof (double)
|
||||
</PRE>
|
||||
<P>
|
||||
The command must be sent before any audio data is written to the file.
|
||||
</P>
|
||||
<P>
|
||||
</P>
|
||||
<DL>
|
||||
<DT>Return value:</DT>
|
||||
<dd>SF_TRUE if compression level was set.
|
||||
SF_FALSE otherwise.
|
||||
</DL>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
@ -1334,7 +1397,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 +1430,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 +1438,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,9 +1452,225 @@ 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>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="SFC_GET_CART_INFO"></A>
|
||||
<H2><BR><B>SFC_GET_CART_INFO</B></H2>
|
||||
<P>Retrieve the Cart Chunk from WAV (and related) files. Based on AES46 standard for CartChunk (see <a href="http://www.cartchunk.org/">CartChunk.org</a> for more information.
|
||||
</P>
|
||||
<p>
|
||||
Parameters:
|
||||
</p>
|
||||
<PRE>
|
||||
sndfile : A valid SNDFILE* pointer
|
||||
cmd : SFC_GET_CART_INFO
|
||||
data : a pointer to an SF_CART_INFO struct
|
||||
datasize : sizeof (SF_CART_INFO)
|
||||
</PRE>
|
||||
<P>
|
||||
The SF_CART_INFO struct is defined in <sndfile.h> as:
|
||||
</P>
|
||||
<PRE>
|
||||
#define SF_CART_INFO_VAR(p_tag_text_size) \
|
||||
struct
|
||||
{ char version [4] ;
|
||||
char title [64] ;
|
||||
char artist [64] ;
|
||||
char cut_id [64] ;
|
||||
char client_id [64] ;
|
||||
char category [64] ;
|
||||
char classification [64] ;
|
||||
char out_cue [64] ;
|
||||
char start_date [10] ;
|
||||
char start_time [8] ;
|
||||
char end_date [10] ;
|
||||
char end_time [8] ;
|
||||
char producer_app_id [64] ;
|
||||
char producer_app_version [64] ;
|
||||
char user_def [64] ;
|
||||
long level_reference ;
|
||||
SF_CART_TIMER post_timers [8] ;
|
||||
char reserved [276] ;
|
||||
char url [1024] ;
|
||||
unsigned int tag_text_size ;
|
||||
char tag_text[p_tag_text_size] ;
|
||||
}
|
||||
</PRE>
|
||||
|
||||
<DL>
|
||||
<DT>Return value: </DT>
|
||||
<DD>SF_TRUE if the file contained a Cart chunk or SF_FALSE
|
||||
otherwise.
|
||||
</DL>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="SFC_SET_CART_INFO"></A>
|
||||
<H2><BR><B>SFC_SET_CART_INFO</B></H2>
|
||||
<P>
|
||||
Set the Cart Chunk for WAV (and related) files.
|
||||
</P>
|
||||
<p>
|
||||
Parameters:
|
||||
</p>
|
||||
<PRE>
|
||||
sndfile : A valid SNDFILE* pointer
|
||||
cmd : SFC_SET_CART_INFO
|
||||
data : a pointer to an SF_CART_INFO struct
|
||||
datasize : sizeof (SF_CART_INFO)
|
||||
</PRE>
|
||||
|
||||
<DL>
|
||||
<DT>Return value: </DT>
|
||||
<DD>SF_TRUE if setting the Cart chunk was successful and SF_FALSE
|
||||
otherwise.
|
||||
</DL>
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
<A NAME="SFC_GET_LOOP_INFO"></A>
|
||||
<H2><BR><B>SFC_GET_LOOP_INFO</B></H2>
|
||||
<P>
|
||||
Retrieve loop information for file including time signature, length in
|
||||
beats and original MIDI base note
|
||||
</P>
|
||||
<p>
|
||||
Parameters:
|
||||
</p>
|
||||
<PRE>
|
||||
sndfile : A valid SNDFILE* pointer
|
||||
cmd : SFC_GET_LOOP_INFO
|
||||
data : a pointer to an SF_LOOP_INFO struct
|
||||
datasize : sizeof (SF_LOOP_INFO)
|
||||
</PRE>
|
||||
<P>
|
||||
The SF_BROADCAST_INFO struct is defined in <sndfile.h> as:
|
||||
</P>
|
||||
<PRE>
|
||||
typedef struct
|
||||
{ short time_sig_num ; /* any positive integer > 0 */
|
||||
short time_sig_den ; /* any positive power of 2 > 0 */
|
||||
int loop_mode ; /* see SF_LOOP enum */
|
||||
|
||||
int num_beats ; /* this is NOT the amount of quarter notes !!!*/
|
||||
/* a full bar of 4/4 is 4 beats */
|
||||
/* a full bar of 7/8 is 7 beats */
|
||||
|
||||
float bpm ; /* suggestion, as it can be calculated using other fields:*/
|
||||
/* file's lenght, file's sampleRate and our time_sig_den*/
|
||||
/* -> bpms are always the amount of _quarter notes_ per minute */
|
||||
|
||||
int root_key ; /* MIDI note, or -1 for None */
|
||||
int future [6] ;
|
||||
} SF_LOOP_INFO ;
|
||||
</PRE>
|
||||
<P>
|
||||
Example:
|
||||
</P>
|
||||
<PRE>
|
||||
SF_LOOP_INFO loop;
|
||||
sf_command (sndfile, SFC_GET_LOOP_INFO, &loop, sizeof (loop)) ;
|
||||
</PRE>
|
||||
<DL>
|
||||
<DT>Return value:</DT>
|
||||
<DD>SF_TRUE if the file header contains loop information for the file.
|
||||
SF_FALSE otherwise.
|
||||
</DL>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
|
||||
<A NAME="SFC_GET_INSTRUMENT"></A>
|
||||
<H2><BR><B>SFC_GET_INSTRUMENT</B></H2>
|
||||
<P>
|
||||
Retrieve instrument information from file including MIDI base note,
|
||||
keyboard mapping and looping informations(start/stop and mode).
|
||||
</P>
|
||||
<p>
|
||||
Parameters:
|
||||
</p>
|
||||
<PRE>
|
||||
sndfile : A valid SNDFILE* pointer
|
||||
cmd : SFC_GET_INSTRUMENT
|
||||
data : a pointer to an SF_INSTRUMENT struct
|
||||
datasize : sizeof (SF_INSTRUMENT)
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The SF_INSTRUMENT struct is defined in <sndfile.h> as:
|
||||
</P>
|
||||
<PRE>
|
||||
enum
|
||||
{ /*
|
||||
** The loop mode field in SF_INSTRUMENT will be one of the following.
|
||||
*/
|
||||
SF_LOOP_NONE = 800,
|
||||
SF_LOOP_FORWARD,
|
||||
SF_LOOP_BACKWARD,
|
||||
SF_LOOP_ALTERNATING
|
||||
} ;
|
||||
|
||||
typedef struct
|
||||
{ int gain ;
|
||||
char basenote, detune ;
|
||||
char velocity_lo, velocity_hi ;
|
||||
char key_lo, key_hi ;
|
||||
int loop_count ;
|
||||
|
||||
struct
|
||||
{ int mode ;
|
||||
unsigned int start ;
|
||||
unsigned int end ;
|
||||
unsigned int count ;
|
||||
} loops [16] ; /* make variable in a sensible way */
|
||||
} SF_INSTRUMENT ;
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
Example:
|
||||
</P>
|
||||
<PRE>
|
||||
SF_INSTRUMENT inst ;
|
||||
sf_command (sndfile, SFC_GET_INSTRUMENT, &inst, sizeof (inst)) ;
|
||||
</PRE>
|
||||
<DL>
|
||||
<DT>Return value:</DT>
|
||||
<dd>SF_TRUE if the file header contains instrument information for the
|
||||
file. SF_FALSE otherwise.
|
||||
</DL>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
|
||||
<A NAME="SFC_SET_INSTRUMENT"></A>
|
||||
<H2><BR><B>SFC_SET_INSTRUMENT</B></H2>
|
||||
<P>
|
||||
Set the instrument information for the file.
|
||||
</P>
|
||||
<p>
|
||||
Parameters:
|
||||
</p>
|
||||
<PRE>
|
||||
sndfile : A valid SNDFILE* pointer
|
||||
cmd : SFC_GET_INSTRUMENT
|
||||
data : a pointer to an SF_INSTRUMENT struct
|
||||
datasize : sizeof (SF_INSTRUMENT)
|
||||
</PRE>
|
||||
<P>
|
||||
Example:
|
||||
</P>
|
||||
<PRE>
|
||||
SF_INSTRUMENT inst ;
|
||||
sf_command (sndfile, SFC_SET_INSTRUMENT, &inst, sizeof (inst)) ;
|
||||
</PRE>
|
||||
<DL>
|
||||
<DT>Return value:</DT>
|
||||
<dd>SF_TRUE if the file header contains instrument information for the
|
||||
file. SF_FALSE otherwise.
|
||||
</DL>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
|
||||
@ -1401,7 +1680,7 @@ Parameters:
|
||||
<A HREF="http://www.mega-nerd.com/libsndfile/">
|
||||
http://www.mega-nerd.com/libsndfile/</A>.
|
||||
<BR>
|
||||
Version : 1.0.19
|
||||
Version : 1.0.25
|
||||
</P>
|
||||
|
||||
</BODY>
|
||||
|
43
libs/libsndfile/doc/development.html
Normal file
43
libs/libsndfile/doc/development.html
Normal file
@ -0,0 +1,43 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<HTML>
|
||||
|
||||
<HEAD>
|
||||
<TITLE>
|
||||
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="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<!-- pepper -->
|
||||
<H1><BR>libsndfile Development</H1>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
libsndfile is being developed by a small but growing community of users
|
||||
and hackers led by Erik de Castro Lopo.
|
||||
People interested in helping should join the libsndfile-devel
|
||||
<A HREF="lists.html">mailing list</A>
|
||||
where most of the discussion about new features takes place.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
The main repository can be found on Github:
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<center>
|
||||
<A HREF="https://github.com/erikd/libsndfile/">
|
||||
https://github.com/erikd/libsndfile/</A>
|
||||
</center>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
and includes
|
||||
<a href="https://github.com/erikd/libsndfile/blob/master/README.md">
|
||||
instuctions</a>
|
||||
on how to build libsndfilefrom the Git repo.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
@ -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>
|
||||
@ -1009,7 +1010,7 @@ Example:
|
||||
<A HREF="http://www.mega-nerd.com/libsndfile/">
|
||||
http://www.mega-nerd.com/libsndfile/</A>.
|
||||
<BR>
|
||||
Version : 1.0.19
|
||||
Version : 1.0.25
|
||||
</P>
|
||||
|
||||
</BODY>
|
||||
|
112
libs/libsndfile/doc/donate.html
Normal file
112
libs/libsndfile/doc/donate.html
Normal file
@ -0,0 +1,112 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<HTML>
|
||||
|
||||
<HEAD>
|
||||
<TITLE>
|
||||
libsndfile : donate.
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<!-- 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="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
|
||||
<br/>
|
||||
<!-- pepper -->
|
||||
<center>
|
||||
<IMG SRC="libsndfile.jpg" HEIGHT=98 WIDTH=367 ALT="libsndfile.jpg">
|
||||
</center>
|
||||
<!-- pepper -->
|
||||
<br/>
|
||||
|
||||
<p>
|
||||
Dear libsndfile user,
|
||||
</p>
|
||||
<!-- pepper -->
|
||||
<p>
|
||||
This library was developed on Linux for Linux. I am not a Windows user and
|
||||
maintaining this library for Windows costs me significant amounts of time above
|
||||
and beyond the time taken to make it work on Linux and Unix-like systems.
|
||||
</p>
|
||||
<!-- pepper -->
|
||||
<p>
|
||||
I therefore ask Windows users of libsndfile to donate to ensure that libsndfile's
|
||||
support for Windows continues. As long as donations continue to flow in at a decent
|
||||
rate, I will continue to release precompiled Windows binaries in sync with the
|
||||
Linux/Unix version. If donations are poor, support for windows will fall behind.
|
||||
</p>
|
||||
<!-- pepper -->
|
||||
|
||||
<p>
|
||||
You are free to donate any amount you chose.
|
||||
As a guideline:
|
||||
</p>
|
||||
<!-- pepper -->
|
||||
<ul>
|
||||
<li>If you are simply a user of libsndfile that would like to ensure that
|
||||
the development of libsndfile continues, a donation of $10US would be more
|
||||
than adequate.
|
||||
</li>
|
||||
<li>If you are shareware author that distributes libsndfile with your app and
|
||||
makes more than $1000 a year from your shareware, a one off donation of $50
|
||||
would be appropriate.
|
||||
</li>
|
||||
<li>If your company is a commercial software house that distributes one or more
|
||||
products that ship with libsndfile, a donation of $100 every second or third
|
||||
year would be appropriate.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!-- pepper -->
|
||||
<p>
|
||||
Donations can be made in Bitcoin to the Bitcoin address
|
||||
<b>15hVWemFiH6DLJ22SBYPk9b4fgWtxBEvfQ</b>
|
||||
|
||||
which can be verified by checking the following GPG signature.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
-----BEGIN PGP SIGNED MESSAGE-----
|
||||
Hash: SHA256
|
||||
|
||||
libsndfile Bitcoin address : 15hVWemFiH6DLJ22SBYPk9b4fgWtxBEvfQ
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1.4.12 (GNU/Linux)
|
||||
|
||||
iQIcBAEBCAAGBQJSK7MUAAoJEEXYQ7zIiotIgXEP/R8hy65tlV7TiPw9bY9BklXS
|
||||
/Vl8FU2RhDkBt61ZmxbfDTybyQ5Vce/3wWph15L4RvpoX1OyeintQFmwwuPjOGiq
|
||||
eIz0nT9vDorG37Xdo5NZNBu9Tp1Od9MNtxFaAsRWFrDfvKEKljBHrcfM972cYrAp
|
||||
DaFd0Ik+bHKom9iQXFB7TFd0w2V4uszVMQDUGqb/vRNeRURZS7ypeMNwc8tZyTKR
|
||||
waEGMTa5sxxRjs7MqGRxSovnFT7JV3TNfdkBInUliIR/XvrudFR9J4Fiv+8Dk9P8
|
||||
WNjm6uFxvgIqiu1G9bjrwwr+DsBju93ljGNcZoayAKw5vwbX6KTcCbc31k9dP8Hf
|
||||
p6YdmPlZVKZmva+P3nLSJBTlxNu24Jm+ha+ZM/svDXTaPFWC8l5FP17kK0Bj8wCq
|
||||
N7pDz6RchEn10u+HdhfT1XiUjxj0zNXrr0GGj9apjl0RlT0O49eBttV0oXIdBRLi
|
||||
nTEaOWITpCgu7ggw1kWXHIWEncuiaSuJy/iH8PgNepWVj/6PxQRMrTqG4ux2Snk8
|
||||
Ua4vO8YHLMZX/XvSUS7eMtgfM7AO6YjJ/ac9bQif9bh6LsYEVVklysMUin6ZRS7Z
|
||||
Cms23FnqeQKtJOzdvqSJiV06lK6fP+tYdM4WSYn+AfL4IfYl2v48xXVU8XOOK9BH
|
||||
bJPKMDcz1ZvfYtX5mSW1
|
||||
=WXGB
|
||||
-----END PGP SIGNATURE-----
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Thanks and regards,
|
||||
<br/>
|
||||
Erik de Castro Lopo
|
||||
<br/>
|
||||
Main libsndfile author and maintainer
|
||||
</p>
|
||||
|
||||
<!-- pepper -->
|
||||
|
||||
<img src=
|
||||
"/cgi-bin/Count.cgi?ft=6|frgb=55;55;55|tr=0|trgb=0;0;0|wxh=15;20|md=6|dd=B|st=1|sh=1|df=libsndfile-donate.dat"
|
||||
HEIGHT=0 WIDTH=0 ALT="">
|
||||
|
||||
|
||||
</BODY>
|
||||
</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 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>
|
||||
|
@ -6,11 +6,12 @@
|
||||
libsndfile
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<META NAME="Version" CONTENT="libsndfile-1.0.19">
|
||||
<META NAME="Version" CONTENT="libsndfile-1.0.25">
|
||||
<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
|
||||
@ -67,18 +65,19 @@
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<UL>
|
||||
<LI>i586-pc-linux-gnu (Linux on PC hardware)
|
||||
<LI>powerpc-unknown-linux-gnu (Linux on Apple Mac hardware)
|
||||
<LI>powerpc-apple-darwin7.0 (Mac OS X 10.3)
|
||||
<LI>sparc-sun-solaris2.8 (using gcc)
|
||||
<LI>mips-sgi-irix5.3 (using gcc)
|
||||
<LI>QNX 6.0
|
||||
<LI>i386-unknown-openbsd2.9
|
||||
<LI>Every platform supported by Debian GNU/Linux including x86_64-linux-gnu,
|
||||
i486-linux-gnu, powerpc-linux-gnu, sparc-linux-gnu, alpha-linux-gnu,
|
||||
mips-linux-gnu and armel-linux-gnu.</LI>
|
||||
<LI>powerpc-apple-darwin7.0 (Mac OS X 10.3)</LI>
|
||||
<LI>sparc-sun-solaris2.8 (using gcc)</LI>
|
||||
<LI>mips-sgi-irix5.3 (using gcc)</LI>
|
||||
<LI>QNX 6.0</LI>
|
||||
<LI>i386-unknown-openbsd2.9</LI>
|
||||
</UL>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
At the moment, each new release is being tested on i386 Linux, PowerPC Linux,
|
||||
MacOSX on PowerPC and Win32.
|
||||
At the moment, each new release is being tested on i386 Linux, x86_64 Linux,
|
||||
PowerPC Linux, Win32 and Win64.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
|
||||
@ -293,7 +292,7 @@ and
|
||||
I have decided that I will not be adding support for MPEG Layer 3 (commonly
|
||||
known as MP3) due to the patent issues surrounding this file format.
|
||||
See
|
||||
<a href="http://www.mega-nerd.com/libsndfile/FAQ.html#Q020">
|
||||
<a href="FAQ.html#Q020">
|
||||
the FAQ</a>
|
||||
for more.
|
||||
</P>
|
||||
@ -343,7 +342,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.
|
||||
@ -360,8 +359,15 @@ and
|
||||
<LI>Version 1.0.17 (Aug 31 2006) Add C++ wrapper sndfile.hh. Minor bug fixes and cleanups.
|
||||
<LI>Version 1.0.18 (Feb 07 2009) Add Ogg/Vorbis suppport, remove captive libraries, many
|
||||
new features and bug fixes. Generate Win32 and Win64 pre-compiled binaries.
|
||||
<LI>Version 1.0.19 (Mar 02 2009) Fix for CVE-2009-0186. Huge number of minor fixes as a
|
||||
<LI>Version 1.0.19 (Mar 02 2009) Fix for CVE-2009-0186. Huge number of minor fixes as a
|
||||
result of static analysis.
|
||||
<LI>Version 1.0.20 (May 14 2009) Fix for potential heap overflow.
|
||||
<LI>Version 1.0.21 (December 13 2009) Bunch of minor bug fixes.
|
||||
<LI>Version 1.0.22 (October 04 2010) Bunch of minor bug fixes.
|
||||
<LI>Version 1.0.23 (October 10 2010) Minor bug fixes.
|
||||
<LI>Version 1.0.24 (March 23 2011) Minor bug fixes.
|
||||
<LI>Version 1.0.25 (July 13 2011) Fix for Secunia Advisory SA45125. Minor bug fixes and
|
||||
improvements.
|
||||
</UL>
|
||||
|
||||
<A NAME="Similar"></A>
|
||||
@ -389,7 +395,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>.
|
||||
@ -410,24 +416,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>
|
||||
@ -435,23 +429,22 @@ and
|
||||
</P>
|
||||
<UL>
|
||||
<LI>Source code as a .tar.gz :
|
||||
<A HREF="libsndfile-1.0.19.tar.gz">libsndfile-1.0.19.tar.gz</A>
|
||||
<A HREF="files/libsndfile-1.0.25.tar.gz">libsndfile-1.0.25.tar.gz</A>
|
||||
and
|
||||
<A HREF="libsndfile-1.0.19.tar.gz.asc">(GPG signature)</A>.
|
||||
<A HREF="files/libsndfile-1.0.25.tar.gz.asc">(GPG signature)</A>.
|
||||
<LI>Win32 installer:
|
||||
<A HREF="libsndfile-1.0.19-w32-setup.exe">
|
||||
libsndfile-1.0.19-w32-setup.exe</A> (thoroughly tested under
|
||||
<A HREF="files/libsndfile-1.0.25-w32-setup.exe">
|
||||
libsndfile-1.0.25-w32-setup.exe</A> (thoroughly tested under
|
||||
<a href="http://www.winehq.com/">Wine</a> and Windows XP).
|
||||
<LI>Win64 installer:
|
||||
<A HREF="libsndfile-1.0.19-w64-setup.exe">
|
||||
libsndfile-1.0.19-w64-setup.exe</A> (alpha quality release).
|
||||
<A HREF="files/libsndfile-1.0.25-w64-setup.exe">
|
||||
libsndfile-1.0.25-w64-setup.exe</A>
|
||||
(thoroughly tested on 64 bit Windows 7).
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
The Win32 installer was compiled for Windows XP but should also work on Windows
|
||||
2000 and Vista.
|
||||
It may even work on earlier versions of Windows.
|
||||
The Win64 is pretty much untested.
|
||||
2000, Vista and Windows 7.
|
||||
</p>
|
||||
|
||||
<P>
|
||||
|
@ -48,24 +48,32 @@ dl {
|
||||
margin-left : 3% ;
|
||||
margin-right : 3% ;
|
||||
}
|
||||
h1 {
|
||||
font-size : xx-large ;
|
||||
background : black ;
|
||||
color : #5050FF ;
|
||||
text-align : left ;
|
||||
margin-left : 3% ;
|
||||
margin-right : 3% ;
|
||||
}
|
||||
h2 {
|
||||
font-size : x-large ;
|
||||
h1 {
|
||||
font-size : xx-large ;
|
||||
background : black ;
|
||||
color : #5050FF ;
|
||||
text-align : left ;
|
||||
margin-left : 3% ;
|
||||
margin-right : 3% ;
|
||||
}
|
||||
h3 {
|
||||
font-size : large ;
|
||||
h2 {
|
||||
font-size : x-large ;
|
||||
background : black ;
|
||||
color : #5050FF ;
|
||||
text-align : left ;
|
||||
margin-left : 3% ;
|
||||
margin-right : 3% ;
|
||||
}
|
||||
h3 {
|
||||
font-size : large ;
|
||||
background : black ;
|
||||
color : #5050FF ;
|
||||
text-align : left ;
|
||||
margin-left : 3% ;
|
||||
margin-right : 3% ;
|
||||
}
|
||||
h4 {
|
||||
font-size : medium ;
|
||||
background : black ;
|
||||
color : #5050FF ;
|
||||
text-align : left ;
|
||||
|
@ -48,24 +48,32 @@ dl {
|
||||
margin-left : 3% ;
|
||||
margin-right : 3% ;
|
||||
}
|
||||
h1 {
|
||||
font-size : xx-large ;
|
||||
background : @HTML_BGCOLOUR@ ;
|
||||
color : #5050FF ;
|
||||
text-align : left ;
|
||||
margin-left : 3% ;
|
||||
margin-right : 3% ;
|
||||
}
|
||||
h2 {
|
||||
font-size : x-large ;
|
||||
h1 {
|
||||
font-size : xx-large ;
|
||||
background : @HTML_BGCOLOUR@ ;
|
||||
color : #5050FF ;
|
||||
text-align : left ;
|
||||
margin-left : 3% ;
|
||||
margin-right : 3% ;
|
||||
}
|
||||
h3 {
|
||||
font-size : large ;
|
||||
h2 {
|
||||
font-size : x-large ;
|
||||
background : @HTML_BGCOLOUR@ ;
|
||||
color : #5050FF ;
|
||||
text-align : left ;
|
||||
margin-left : 3% ;
|
||||
margin-right : 3% ;
|
||||
}
|
||||
h3 {
|
||||
font-size : large ;
|
||||
background : @HTML_BGCOLOUR@ ;
|
||||
color : #5050FF ;
|
||||
text-align : left ;
|
||||
margin-left : 3% ;
|
||||
margin-right : 3% ;
|
||||
}
|
||||
h4 {
|
||||
font-size : medium ;
|
||||
background : @HTML_BGCOLOUR@ ;
|
||||
color : #5050FF ;
|
||||
text-align : left ;
|
||||
@ -75,6 +83,8 @@ h3 {
|
||||
pre {
|
||||
font-family : courier, monospace ;
|
||||
font-size : medium ;
|
||||
margin-left : 6% ;
|
||||
margin-right : 6% ;
|
||||
}
|
||||
a:link { color : #9090FF ; }
|
||||
a:visited { color : #5050FF ; }
|
||||
|
434
libs/libsndfile/doc/linux_games_programming.txt
Normal file
434
libs/libsndfile/doc/linux_games_programming.txt
Normal file
@ -0,0 +1,434 @@
|
||||
# Here are some some emails I exchanged with a guy trying to use
|
||||
# libsndfile version 1 with code from the book "Linux Games Programming"
|
||||
# by John Hall. The email addresses have been changed to foil the spam
|
||||
# bots.
|
||||
|
||||
Date: Tue, 20 Jul 2004 22:49:21 +0100
|
||||
From: Paul <paul@fake-domain-name.co.uk>
|
||||
To: erikd@fake-domain-name.com
|
||||
Subject: Can you help with a problem?
|
||||
Date: Tue, 20 Jul 2004 22:49:21 +0100
|
||||
|
||||
Hi,
|
||||
|
||||
I'm trying to get the source examples in the "Programming Linux Games"
|
||||
(NoStarch, Loki Software + John R. Hall) which use sndfile.h/libsndfile.
|
||||
|
||||
While I can guess some of the newer versions of function calls and
|
||||
enumerations, there are some which I cannot guess.
|
||||
|
||||
Would you be able to translate them to the current version of
|
||||
enumeration and function calls so that I can update the source?
|
||||
|
||||
These are the three currently failing me:
|
||||
|
||||
sf_open_read(filename, SF_INFO *sfinfo) (guess: sf_open(filename,SFM_READ, &sfinfo))
|
||||
SF_FORMAT_PCM (guess: either SF_FORMAT_PCM_U8 or _RAW)
|
||||
SF_INFO.pcmbitwidth (guess: no idea!)
|
||||
|
||||
There are probably more. I'm happy to send you the source files for
|
||||
sound calls, scan the pages or anything else. Failing that, is there
|
||||
somewhere with the changes listed so I can try and fix the code for myself?
|
||||
|
||||
Thanks
|
||||
|
||||
TTFN
|
||||
|
||||
Paul
|
||||
|
||||
================================================================================
|
||||
|
||||
Date: Wed, 21 Jul 2004 17:38:08 +1000
|
||||
From: Erik de Castro Lopo <erikd@fake-domain-name.com>
|
||||
To: Paul <paul@fake-domain-name.co.uk>
|
||||
Subject: Re: Can you help with a problem?
|
||||
|
||||
On Tue, 20 Jul 2004 22:49:21 +0100
|
||||
Paul <paul@fake-domain-name.co.uk> wrote:
|
||||
|
||||
> Hi,
|
||||
>
|
||||
> I'm trying to get the source examples in the "Programming Linux Games"
|
||||
> (NoStarch, Loki Software + John R. Hall) which use sndfile.h/libsndfile.
|
||||
>
|
||||
> While I can guess some of the newer versions of function calls and
|
||||
> enumerations, there are some which I cannot guess.
|
||||
>
|
||||
> Would you be able to translate them to the current version of
|
||||
> enumeration and function calls so that I can update the source?
|
||||
>
|
||||
> These are the three currently failing me:
|
||||
>
|
||||
> sf_open_read(filename, SF_INFO *sfinfo) (guess: sf_open(filename,
|
||||
> SFM_READ, &sfinfo))
|
||||
|
||||
yes.
|
||||
|
||||
> SF_FORMAT_PCM (guess: either SF_FORMAT_PCM_U8 or _RAW)
|
||||
|
||||
Actually this list:
|
||||
|
||||
SF_FORMAT_PCM_U8
|
||||
SF_FORMAT_PCM_S8
|
||||
SF_FORMAT_PCM_16
|
||||
SF_FORMAT_PCM_24
|
||||
SF_FORMAT_PCM_32
|
||||
|
||||
> SF_INFO.pcmbitwidth (guess: no idea!)
|
||||
|
||||
WIth the above change, pcmbitwidth becomes redundant.
|
||||
|
||||
> There are probably more. I'm happy to send you the source files for
|
||||
> sound calls, scan the pages or anything else. Failing that, is there
|
||||
> somewhere with the changes listed so I can try and fix the code for
|
||||
> myself?
|
||||
|
||||
Version 1.0.0 came out some time ago, but I think this:
|
||||
|
||||
http://www.mega-nerd.com/libsndfile/version-1.html
|
||||
|
||||
lists most of the changes. You should also look at the API docs:
|
||||
|
||||
http://www.mega-nerd.com/libsndfile/api.html
|
||||
|
||||
HTH,
|
||||
Erik
|
||||
--
|
||||
+-----------------------------------------------------------+
|
||||
Erik de Castro Lopo nospam@fake-domain-name.com
|
||||
+-----------------------------------------------------------+
|
||||
"There is no reason why anyone would want a computer in their home"
|
||||
Ken Olson, DEC, 1977
|
||||
|
||||
================================================================================
|
||||
|
||||
From: PFJ <paul@fake-domain-name.co.uk>
|
||||
To: Erik de Castro Lopo <erikd@fake-domain-name.com>
|
||||
Subject: Re: Can you help with a problem?
|
||||
Date: Wed, 21 Jul 2004 09:07:39 +0100
|
||||
|
||||
|
||||
Hi Erik,
|
||||
|
||||
Thanks for getting back to me.
|
||||
|
||||
> > sf_open_read(filename, SF_INFO *sfinfo) (guess: sf_open(filename, SFM_READ, &sfinfo))
|
||||
>
|
||||
> yes.
|
||||
|
||||
Yay!
|
||||
|
||||
> > SF_FORMAT_PCM (guess: either SF_FORMAT_PCM_U8 or _RAW)
|
||||
>
|
||||
> Actually this list:
|
||||
>
|
||||
> SF_FORMAT_PCM_U8
|
||||
> SF_FORMAT_PCM_S8
|
||||
> SF_FORMAT_PCM_16
|
||||
> SF_FORMAT_PCM_24
|
||||
> SF_FORMAT_PCM_32
|
||||
|
||||
I know, but the source code explicitly has SF_FORMAT_PCM which given the
|
||||
code afterwards would equate to one of the above, but given that PCM
|
||||
files can have a varied bitwidth the author probably wanted to cover all
|
||||
bases.
|
||||
|
||||
> Version 1.0.0 came out some time ago, but I think this:
|
||||
>
|
||||
> http://www.mega-nerd.com/libsndfile/version-1.html
|
||||
>
|
||||
> lists most of the changes. You should also look at the API docs:
|
||||
>
|
||||
> http://www.mega-nerd.com/libsndfile/api.html
|
||||
|
||||
I'll download them and see what I can gleen.
|
||||
|
||||
Thanks again for getting back to me
|
||||
|
||||
TTFN
|
||||
|
||||
Paul
|
||||
|
||||
================================================================================
|
||||
|
||||
Date: Wed, 21 Jul 2004 18:20:29 +1000
|
||||
From: Erik de Castro Lopo <erikd@fake-domain-name.com>
|
||||
To: PFJ <paul@fake-domain-name.co.uk>
|
||||
Subject: Re: Can you help with a problem?
|
||||
|
||||
On Wed, 21 Jul 2004 09:07:39 +0100
|
||||
PFJ <paul@fake-domain-name.co.uk> wrote:
|
||||
|
||||
> I know, but the source code explicitly has SF_FORMAT_PCM which given the
|
||||
> code afterwards would equate to one of the above, but given that PCM
|
||||
> files can have a varied bitwidth the author probably wanted to cover all
|
||||
> bases.
|
||||
|
||||
But surely the existing code does something like:
|
||||
|
||||
sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM;
|
||||
sfinfo.pcmbitwidth = 16;
|
||||
|
||||
which can be directly translated to:
|
||||
|
||||
sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
|
||||
|
||||
and the same for pcmbitwitdhs of 24 and 32. For pcmbitwidth of 8
|
||||
you need to know that WAV files use SF_FORMAT_PCM_U8 and AIFF
|
||||
files use SF_FORMAT_PCM_S8. Thats all there is to it.
|
||||
|
||||
Erik
|
||||
--
|
||||
+-----------------------------------------------------------+
|
||||
Erik de Castro Lopo nospam@fake-domain-name.com
|
||||
+-----------------------------------------------------------+
|
||||
"Python addresses true pseudocode's two major failings: that it
|
||||
isn't standardized, and it isn't executable."
|
||||
- Grant R. Griffin in comp.dsp
|
||||
|
||||
================================================================================
|
||||
|
||||
Subject: Re: Can you help with a problem?
|
||||
From: PFJ <paul@fake-domain-name.co.uk>
|
||||
To: Erik de Castro Lopo <erikd@fake-domain-name.com>
|
||||
Date: Wed, 21 Jul 2004 09:50:55 +0100
|
||||
|
||||
Hi Erik,
|
||||
|
||||
> > I know, but the source code explicitly has SF_FORMAT_PCM which given the
|
||||
> > code afterwards would equate to one of the above, but given that PCM
|
||||
> > files can have a varied bitwidth the author probably wanted to cover all
|
||||
> > bases.
|
||||
>
|
||||
> But surely the existing code does something like:
|
||||
>
|
||||
> sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM;
|
||||
> sfinfo.pcmbitwidth = 16;
|
||||
|
||||
If only!
|
||||
|
||||
The actual code is this
|
||||
|
||||
int LoadSoundFile(char *filename, sound_p sound)
|
||||
{
|
||||
SNDFILE *file;
|
||||
SF_INFO file_info;
|
||||
short *buffer_short = NULL;
|
||||
u_int8_t *buffer_8 = NULL;
|
||||
int16_t *buffer_16 = NULL;
|
||||
unsigned int i;
|
||||
|
||||
/* Open the file and retrieve sample information. */
|
||||
file = sf_open_read(filename, &file_info);
|
||||
// I've sorted this one already - PFJ
|
||||
|
||||
/* Make sure the format is acceptable. */
|
||||
if ((file_info.format & 0x0F) != SF_FORMAT_PCM) {
|
||||
printf("'%s' is not a PCM-based audio file.\n", filename);
|
||||
sf_close(file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((file_info.pcmbitwidth == 8) && (file_info.channels == 1)) {
|
||||
sound->format = AL_FORMAT_MONO8;
|
||||
} else if ((file_info.pcmbitwidth == 8) && (file_info.channels == 2)) {
|
||||
sound->format = AL_FORMAT_STEREO8;
|
||||
} else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 1)) {
|
||||
sound->format = AL_FORMAT_MONO16;
|
||||
} else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 2)) {
|
||||
sound->format = AL_FORMAT_STEREO16;
|
||||
} else {
|
||||
printf("Unknown sample format in %s.\n", filename);
|
||||
sf_close(file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Allocate buffers. */
|
||||
buffer_short = (short *)malloc(file_info.samples * file_info.channels * sizeof (short));
|
||||
|
||||
buffer_8 = (u_int8_t *)malloc(file_info.samples * file_info.channels * file_info.pcmbitwidth / 8);
|
||||
|
||||
buffer_16 = (int16_t *)buffer_8;
|
||||
|
||||
if (buffer_short == NULL || buffer_8 == NULL) {
|
||||
printf("Unable to allocate enough memory for '%s'.\n", filename);
|
||||
goto error_cleanup;
|
||||
}
|
||||
|
||||
/* Read the entire sound file. */
|
||||
if (sf_readf_short(file,buffer_short,file_info.samples) == (size_t)-1) {
|
||||
printf("Error while reading samples from '%s'.\n", filename);
|
||||
goto error_cleanup;
|
||||
}
|
||||
|
||||
<minor snip>
|
||||
|
||||
/* Fill in the sound data structure. */
|
||||
sound->freq = file_info.samplerate;
|
||||
sound->size = file_info.samples * file_info.channels * file_info.pcmbitwidth / 8;
|
||||
|
||||
/* Give our sound data to OpenAL. */
|
||||
alGenBuffers(1, &sound->name);
|
||||
if (alGetError() != AL_NO_ERROR) {
|
||||
printf("Error creating an AL buffer name for %s.\n", filename);
|
||||
goto error_cleanup;
|
||||
}
|
||||
|
||||
alBufferData(sound->name, sound->format, buffer_8, sound->size,sound->freq);
|
||||
if (alGetError() != AL_NO_ERROR) {
|
||||
printf("Error sending buffer data to OpenAL for %s.\n", filename);
|
||||
goto error_cleanup;
|
||||
}
|
||||
|
||||
/* Close the file and return success. */
|
||||
sf_close(file);
|
||||
free(buffer_short);
|
||||
free(buffer_8);
|
||||
|
||||
return 0;
|
||||
|
||||
error_cleanup:
|
||||
if (file != NULL) fclose(file);
|
||||
free(buffer_short);
|
||||
free(buffer_8);
|
||||
return -1;
|
||||
}
|
||||
|
||||
As you can see, the PCM material in the listing will not currently
|
||||
compile and for the other sndfile material, it probably won't either.
|
||||
|
||||
Any help would be appreciated.
|
||||
|
||||
TTFN
|
||||
|
||||
Paul
|
||||
|
||||
================================================================================
|
||||
|
||||
From: Erik de Castro Lopo <erikd@fake-domain-name.com>
|
||||
To: PFJ <paul@fake-domain-name.co.uk>
|
||||
Subject: Re: Can you help with a problem?
|
||||
Date: Wed, 21 Jul 2004 19:36:46 +1000
|
||||
|
||||
On Wed, 21 Jul 2004 09:50:55 +0100
|
||||
PFJ <paul@fake-domain-name.co.uk> wrote:
|
||||
|
||||
> Hi Erik,
|
||||
>
|
||||
> > > I know, but the source code explicitly has SF_FORMAT_PCM which given the
|
||||
> > > code afterwards would equate to one of the above, but given that PCM
|
||||
> > > files can have a varied bitwidth the author probably wanted to cover all
|
||||
> > > bases.
|
||||
> >
|
||||
> > But surely the existing code does something like:
|
||||
> >
|
||||
> > sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM;
|
||||
> > sfinfo.pcmbitwidth = 16;
|
||||
>
|
||||
> If only!
|
||||
|
||||
No, really.
|
||||
|
||||
Drop this completely:
|
||||
|
||||
> /* Make sure the format is acceptable. */
|
||||
> if ((file_info.format & 0x0F) != SF_FORMAT_PCM) {
|
||||
> printf("'%s' is not a PCM-based audio file.\n", filename);
|
||||
> sf_close(file);
|
||||
> return -1;
|
||||
> }
|
||||
|
||||
Replace this block:
|
||||
|
||||
> if ((file_info.pcmbitwidth == 8) && (file_info.channels == 1)) {
|
||||
> sound->format = AL_FORMAT_MONO8;
|
||||
> } else if ((file_info.pcmbitwidth == 8) && (file_info.channels == 2)) {
|
||||
> sound->format = AL_FORMAT_STEREO8;
|
||||
> } else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 1)) {
|
||||
> sound->format = AL_FORMAT_MONO16;
|
||||
> } else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 2)) {
|
||||
> sound->format = AL_FORMAT_STEREO16;
|
||||
> } else {
|
||||
> printf("Unknown sample format in %s.\n", filename);
|
||||
> sf_close(file);
|
||||
> return -1;
|
||||
> }
|
||||
|
||||
with:
|
||||
|
||||
int pcmbitwidth = 0;
|
||||
|
||||
if (file_info.format & SF_FORMAT_SUBMASK != SF_FORMAT_PCM_16)
|
||||
{ printf("'%s' is not a PCM-based audio file.\n", filename);
|
||||
sf_close(file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (file_info.channels < 1 || file_info.channels > 2)
|
||||
{ printf("'%s' bad channel count.\n", filename);
|
||||
sf_close(file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (file_info.format & SF_FORMAT_SUBMASK + file_info.channels << 16)
|
||||
{ case (SF_FORMAT_PCM_U8 + 1 << 16):
|
||||
sound->format = AL_FORMAT_MONO8;
|
||||
pcmbitwidth = 8;
|
||||
break;
|
||||
case (SF_FORMAT_PCM_U8 + 2 << 16):
|
||||
sound->format = AL_FORMAT_STEREO8;
|
||||
pcmbitwidth = 8;
|
||||
break;
|
||||
case (SF_FORMAT_PCM_16 + 1 << 16):
|
||||
sound->format = AL_FORMAT_MONO16;
|
||||
pcmbitwidth = 16;
|
||||
break;
|
||||
case (SF_FORMAT_PCM_16 + 2 << 16):
|
||||
sound->format = AL_FORMAT_STEREO16;
|
||||
pcmbitwidth = 16;
|
||||
break;
|
||||
default:
|
||||
printf("Unknown sample format in %s.\n", filename);
|
||||
sf_close(file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
> /* Allocate buffers. */
|
||||
> buffer_short = (short *)malloc(file_info.samples *
|
||||
> file_info.channels *
|
||||
> sizeof (short));
|
||||
>
|
||||
> buffer_8 = (u_int8_t *)malloc(file_info.samples *
|
||||
> file_info.channels *
|
||||
> file_info.pcmbitwidth / 8);
|
||||
|
||||
Use pcmbitwidth as calculated above.
|
||||
|
||||
> buffer_16 = (int16_t *)buffer_8;
|
||||
>
|
||||
> if (buffer_short == NULL || buffer_8 == NULL) {
|
||||
> printf("Unable to allocate enough memory for '%s'.\n", filename);
|
||||
> goto error_cleanup;
|
||||
> }
|
||||
>
|
||||
> /* Read the entire sound file. */
|
||||
> if (sf_readf_short(file,buffer_short,file_info.samples) == (size_t)- 1) {
|
||||
|
||||
Replace "(size_t) - 1" with " < 0".
|
||||
|
||||
> As you can see, the PCM material in the listing will not currently
|
||||
> compile and for the other sndfile material, it probably won't either.
|
||||
|
||||
None of the changes above should have been very difficult to figure
|
||||
out.
|
||||
|
||||
Erik
|
||||
--
|
||||
+-----------------------------------------------------------+
|
||||
Erik de Castro Lopo nospam@fake-domain-name.com
|
||||
+-----------------------------------------------------------+
|
||||
Microsoft is finally bringing all of its Windows operating system families
|
||||
under one roof. It will combine all of the features of CE, stability and
|
||||
support of ME and the speed of NT.
|
||||
It will be called Windows CEMENT...
|
||||
|
@ -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>
|
||||
@ -14,21 +15,21 @@
|
||||
<BR>
|
||||
<H1><B>libsndfile and GNU Octave</B></H1>
|
||||
<P>
|
||||
<A HREF="http://www.octave.org/">GNU Octave</A> is a high-level interactive
|
||||
language for numerical computations.
|
||||
<A HREF="http://www.octave.org/">GNU Octave</A> is a high-level interactive
|
||||
language for numerical computations.
|
||||
There are currently two development streams, a stable 2.0.X series and a
|
||||
development 2.1.X series.
|
||||
Octave reads and writes data in binary formats that were originally developed
|
||||
for
|
||||
for
|
||||
<A HREF="http://www.mathworks.com/">MATLAB</A>.
|
||||
Version 2.0.X of Octave uses binary data files compatible with MATLAB
|
||||
version 4.2 while Octave 2.1.X uses binary data files compatible
|
||||
with MATLAB version 5.0 as well as being able to read the older MATLAB 4.2
|
||||
with MATLAB version 5.0 as well as being able to read the older MATLAB 4.2
|
||||
format.
|
||||
</P>
|
||||
<P>
|
||||
From version 1.0.1 of libsndfile onwards, libsndfile has the ability of reading
|
||||
and writing a small subset of the binary data files used by both versions
|
||||
From version 1.0.1 of libsndfile onwards, libsndfile has the ability of reading
|
||||
and writing a small subset of the binary data files used by both versions
|
||||
of GNU Octave.
|
||||
This gives people using GNU Octave for audio based work an easy method of
|
||||
moving audio data between GNU Octave and other programs which use libsndfile.
|
||||
@ -36,22 +37,22 @@
|
||||
<P>
|
||||
For instance it is now possible to do the following:
|
||||
</P>
|
||||
|
||||
|
||||
<UL>
|
||||
<LI> Load a WAV file into a sound file editor such as
|
||||
<LI> Load a WAV file into a sound file editor such as
|
||||
<A HREF="http://www.metadecks.org/software/sweep/">Sweep</A>.
|
||||
<LI> Save it as a MAT4 file.
|
||||
<LI> Load the data into Octave for manipulation.
|
||||
<LI> Save the modified data.
|
||||
<LI> Save the modified data.
|
||||
<LI> Reload it in Sweep.
|
||||
</UL>
|
||||
<P>
|
||||
Another example would be using the MAT4 or MAT5 file formats as a format which
|
||||
can be easily loaded into Octave for viewing/analyzing as well as a format
|
||||
can be easily loaded into Octave for viewing/analyzing as well as a format
|
||||
which can be played with command line players such as the one included with
|
||||
libsndfile.
|
||||
</P>
|
||||
|
||||
|
||||
<H2><B>Details</B></H2>
|
||||
<P>
|
||||
Octave, like most programming languages, uses variables to store data, and
|
||||
@ -69,7 +70,7 @@
|
||||
<PRE>
|
||||
octave:1 > samplerate = 44100 ;
|
||||
octave:2 > wavedata = sin ((0:1023)*2*pi/1024) ;
|
||||
octave:3 > save sine.mat samplerate wavedata
|
||||
octave:3 > save sine.mat samplerate wavedata
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
@ -83,9 +84,9 @@
|
||||
<P>
|
||||
In addition, libsndfile contains a command line program which which is able
|
||||
to play the correct types of Octave files.
|
||||
Using this command line player <B>sndfile-play</B> and a third Octave script
|
||||
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>
|
||||
@ -99,8 +100,8 @@
|
||||
</P>
|
||||
|
||||
<P>
|
||||
There are some other Octave scripts for audio to be found
|
||||
<A HREF="http://octave.sourceforge.net/index/audio.html">here</A>.
|
||||
There are some other Octave scripts for audio to be found
|
||||
<A HREF="http://octave.sourceforge.net/audio/index.html">here</A>.
|
||||
</P>
|
||||
|
||||
<BR>
|
||||
@ -108,7 +109,7 @@
|
||||
|
||||
<HR>
|
||||
<P>
|
||||
The libsndfile home page is here :
|
||||
The libsndfile home page is here :
|
||||
<A HREF="http://www.mega-nerd.com/libsndfile/">
|
||||
http://www.mega-nerd.com/libsndfile/</A>.
|
||||
</P>
|
||||
|
@ -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
libs/libsndfile/doc/print.css
Normal file
14
libs/libsndfile/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>
|
||||
|
25
libs/libsndfile/echo-install-dirs.in
Normal file
25
libs/libsndfile/echo-install-dirs.in
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
# @configure_input@
|
||||
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
bindir=@bindir@
|
||||
pkgconfigdir=@pkgconfigdir@
|
||||
datadir=@datadir@
|
||||
datarootdir=@datarootdir@
|
||||
docdir=@docdir@
|
||||
htmldir=@htmldir@
|
||||
|
||||
echo "
|
||||
Installation directories :
|
||||
|
||||
Library directory : ................... $libdir
|
||||
Program directory : ................... $bindir
|
||||
Pkgconfig directory : ................. $pkgconfigdir
|
||||
HTML docs directory : ................. $htmldir
|
||||
"
|
||||
echo "Compiling some other packages against libsndfile may require"
|
||||
echo "the addition of '$pkgconfigdir' to the"
|
||||
echo "PKG_CONFIG_PATH environment variable."
|
||||
echo
|
@ -2,7 +2,7 @@
|
||||
|
||||
noinst_PROGRAMS = make_sine sfprocess list_formats generate sndfilehandle sndfile-to-text
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/src
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/src
|
||||
|
||||
sndfile_to_text_SOURCES = sndfile-to-text.c
|
||||
sndfile_to_text_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
@ -22,3 +22,4 @@ generate_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
sndfilehandle_SOURCES = sndfilehandle.cc
|
||||
sndfilehandle_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
CLEANFILES = *~ *.exe
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2002-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
@ -98,6 +98,8 @@ encode_file (const char *infilename, const char *outfilename, int filetype)
|
||||
k = 16 - strlen (outfilename) ;
|
||||
PUT_DOTS (k) ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
if (! (infile = sf_open (infilename, SFM_READ, &sfinfo)))
|
||||
{ printf ("Error : could not open file : %s\n", infilename) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
@ -119,7 +121,7 @@ encode_file (const char *infilename, const char *outfilename, int filetype)
|
||||
} ;
|
||||
|
||||
while ((readcount = sf_read_float (infile, buffer, BUFFER_LEN)) > 0)
|
||||
sf_write_float (outfile, buffer, BUFFER_LEN) ;
|
||||
sf_write_float (outfile, buffer, readcount) ;
|
||||
|
||||
sf_close (infile) ;
|
||||
sf_close (outfile) ;
|
||||
|
250
libs/libsndfile/examples/generate.cs
Normal file
250
libs/libsndfile/examples/generate.cs
Normal file
@ -0,0 +1,250 @@
|
||||
/* (c) 2004 James Robson, http://www.arbingersys.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.
|
||||
**
|
||||
** ****************************
|
||||
**
|
||||
** How to use:
|
||||
** - libsndfile.dll must have already been compiled and be in this
|
||||
** application's search path
|
||||
**
|
||||
** - You must edit this file to point to the file you want to convert. Set
|
||||
** the following line of code (found in the Main() function further below)
|
||||
** to the name of a .WAV file that exists on your system.
|
||||
** 186: string sfn = "input.wav";
|
||||
**
|
||||
** - From a command prompt type
|
||||
** csc generate.cs
|
||||
**
|
||||
** - Run the resulting executable 'generate.exe'
|
||||
**
|
||||
**
|
||||
** Note: You will obviously need the csc compiler and the .NET runtime. I think
|
||||
** these are freely available for download from Microsoft's website
|
||||
** (part of the .NET SDK?).
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using sf_count_t = System.Int64; //alias; see SF_INFO struct
|
||||
|
||||
#if PLATFORM_64
|
||||
using size_t = System.UInt64;
|
||||
#else
|
||||
using size_t = System.UInt32;
|
||||
#endif
|
||||
|
||||
|
||||
class lsndf_example {
|
||||
|
||||
|
||||
//sound file formats
|
||||
public enum lsndf_frmts {
|
||||
SF_FORMAT_WAV = 0x010000, /* Microsoft WAV format (little endian). */
|
||||
SF_FORMAT_AIFF = 0x020000, /* Apple/SGI AIFF format (big endian). */
|
||||
SF_FORMAT_AU = 0x030000, /* Sun/NeXT AU format (big endian). */
|
||||
SF_FORMAT_RAW = 0x040000, /* RAW PCM data. */
|
||||
SF_FORMAT_PAF = 0x050000, /* Ensoniq PARIS file format. */
|
||||
SF_FORMAT_SVX = 0x060000, /* Amiga IFF / SVX8 / SV16 format. */
|
||||
SF_FORMAT_NIST = 0x070000, /* Sphere NIST format. */
|
||||
SF_FORMAT_VOC = 0x080000, /* VOC files. */
|
||||
SF_FORMAT_IRCAM = 0x0A0000, /* Berkeley/IRCAM/CARL */
|
||||
SF_FORMAT_W64 = 0x0B0000, /* Sonic Foundry's 64 bit RIFF/WAV */
|
||||
SF_FORMAT_MAT4 = 0x0C0000, /* Matlab (tm) V4.2 / GNU Octave 2.0 */
|
||||
SF_FORMAT_MAT5 = 0x0D0000, /* Matlab (tm) V5.0 / GNU Octave 2.1 */
|
||||
SF_FORMAT_PVF = 0x0E0000, /* Portable Voice Format */
|
||||
SF_FORMAT_XI = 0x0F0000, /* Fasttracker 2 Extended Instrument */
|
||||
SF_FORMAT_HTK = 0x100000, /* HMM Tool Kit format */
|
||||
SF_FORMAT_SDS = 0x110000, /* Midi Sample Dump Standard */
|
||||
|
||||
/* Subtypes from here on. */
|
||||
|
||||
SF_FORMAT_PCM_S8 = 0x0001, /* Signed 8 bit data */
|
||||
SF_FORMAT_PCM_16 = 0x0002, /* Signed 16 bit data */
|
||||
SF_FORMAT_PCM_24 = 0x0003, /* Signed 24 bit data */
|
||||
SF_FORMAT_PCM_32 = 0x0004, /* Signed 32 bit data */
|
||||
|
||||
SF_FORMAT_PCM_U8 = 0x0005, /* Unsigned 8 bit data (WAV and RAW only) */
|
||||
|
||||
SF_FORMAT_FLOAT = 0x0006, /* 32 bit float data */
|
||||
SF_FORMAT_DOUBLE = 0x0007, /* 64 bit float data */
|
||||
|
||||
SF_FORMAT_ULAW = 0x0010, /* U-Law encoded. */
|
||||
SF_FORMAT_ALAW = 0x0011, /* A-Law encoded. */
|
||||
SF_FORMAT_IMA_ADPCM = 0x0012, /* IMA ADPCM. */
|
||||
SF_FORMAT_MS_ADPCM = 0x0013, /* Microsoft ADPCM. */
|
||||
|
||||
SF_FORMAT_GSM610 = 0x0020, /* GSM 6.10 encoding. */
|
||||
SF_FORMAT_VOX_ADPCM = 0x0021, /* OKI / Dialogix ADPCM */
|
||||
|
||||
SF_FORMAT_G721_32 = 0x0030, /* 32kbs G721 ADPCM encoding. */
|
||||
SF_FORMAT_G723_24 = 0x0031, /* 24kbs G723 ADPCM encoding. */
|
||||
SF_FORMAT_G723_40 = 0x0032, /* 40kbs G723 ADPCM encoding. */
|
||||
|
||||
SF_FORMAT_DWVW_12 = 0x0040, /* 12 bit Delta Width Variable Word encoding. */
|
||||
SF_FORMAT_DWVW_16 = 0x0041, /* 16 bit Delta Width Variable Word encoding. */
|
||||
SF_FORMAT_DWVW_24 = 0x0042, /* 24 bit Delta Width Variable Word encoding. */
|
||||
SF_FORMAT_DWVW_N = 0x0043, /* N bit Delta Width Variable Word encoding. */
|
||||
|
||||
SF_FORMAT_DPCM_8 = 0x0050, /* 8 bit differential PCM (XI only) */
|
||||
SF_FORMAT_DPCM_16 = 0x0051, /* 16 bit differential PCM (XI only) */
|
||||
|
||||
|
||||
/* Endian-ness options. */
|
||||
|
||||
SF_ENDIAN_FILE = 0x00000000, /* Default file endian-ness. */
|
||||
SF_ENDIAN_LITTLE = 0x10000000, /* Force little endian-ness. */
|
||||
SF_ENDIAN_BIG = 0x20000000, /* Force big endian-ness. */
|
||||
SF_ENDIAN_CPU = 0x30000000, /* Force CPU endian-ness. */
|
||||
|
||||
SF_FORMAT_SUBMASK = 0x0000FFFF,
|
||||
SF_FORMAT_TYPEMASK = 0x0FFF0000,
|
||||
SF_FORMAT_ENDMASK = 0x30000000
|
||||
}
|
||||
|
||||
|
||||
//modes and other
|
||||
public enum lsndf_tf
|
||||
{ /* True and false */
|
||||
SF_FALSE = 0,
|
||||
SF_TRUE = 1,
|
||||
|
||||
/* Modes for opening files. */
|
||||
SFM_READ = 0x10,
|
||||
SFM_WRITE = 0x20,
|
||||
SFM_RDWR = 0x30
|
||||
}
|
||||
|
||||
|
||||
//important SF_INFO structure
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct SF_INFO
|
||||
{
|
||||
public sf_count_t frames ; // Used to be called samples. Changed to avoid confusion.
|
||||
public int samplerate ;
|
||||
public int channels ;
|
||||
public int format ;
|
||||
public int sections ;
|
||||
public int seekable ;
|
||||
};
|
||||
|
||||
|
||||
//function declarations
|
||||
//Note: Not all functions have been prototyped here. Only the ones necessary to
|
||||
// make this application work. The below code should give some clues as to
|
||||
// how to add the rest since they have a lot of parameter and return type
|
||||
// similarities.
|
||||
[DllImport("libsndfile.dll")]
|
||||
public static extern IntPtr sf_open ([MarshalAs(UnmanagedType.LPStr)] string path, int mode, ref SF_INFO sfinfo);
|
||||
|
||||
[DllImport("libsndfile.dll")]
|
||||
static extern int sf_error (IntPtr sndfile);
|
||||
|
||||
[DllImport("libsndfile.dll")]
|
||||
static extern IntPtr sf_strerror (IntPtr sndfile);
|
||||
|
||||
[DllImport("libsndfile.dll")]
|
||||
static extern int sf_format_check (ref SF_INFO info);
|
||||
|
||||
[DllImport("libsndfile.dll")]
|
||||
static extern sf_count_t sf_read_float (IntPtr sndfile, float[] ptr, sf_count_t items);
|
||||
|
||||
[DllImport("libsndfile.dll")]
|
||||
static extern sf_count_t sf_write_float (IntPtr sndfile, float[] ptr, sf_count_t items);
|
||||
|
||||
[DllImport("libsndfile.dll")]
|
||||
static extern int sf_close (IntPtr sndfile);
|
||||
|
||||
|
||||
public const sf_count_t BUFFER_LEN = 4096;
|
||||
|
||||
|
||||
//program entry
|
||||
static void Main( ) {
|
||||
|
||||
|
||||
//declarations
|
||||
SF_INFO sfinfo = new SF_INFO();
|
||||
float[] buffer = new float[BUFFER_LEN];
|
||||
sf_count_t rcnt;
|
||||
|
||||
//set the input file
|
||||
string sfn = "input.wav"; //set to a file on YOUR system
|
||||
//string sfn = "noexist.wav"; //test with non-existent file
|
||||
|
||||
//set the output file
|
||||
string ofn = "output.wav";
|
||||
|
||||
//read in sound file to convert
|
||||
IntPtr infile = sf_open (sfn, (int)lsndf_tf.SFM_READ, ref sfinfo);
|
||||
|
||||
//exit if error was thrown
|
||||
if ( (int)infile == 0 ) {
|
||||
Console.WriteLine("Error opening " + sfn);
|
||||
Console.WriteLine("Error #" + sf_error(infile));
|
||||
return;
|
||||
}
|
||||
|
||||
//set the file type for the output file
|
||||
//uncomment one and only one of the statements below to change the output
|
||||
//file encoding.
|
||||
//sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_WAV | lsndf_frmts.SF_FORMAT_PCM_U8);
|
||||
//sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_WAV | lsndf_frmts.SF_FORMAT_PCM_16);
|
||||
//sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_WAV | lsndf_frmts.SF_FORMAT_MS_ADPCM);
|
||||
sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_WAV | lsndf_frmts.SF_FORMAT_IMA_ADPCM);
|
||||
//sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_WAV | lsndf_frmts.SF_FORMAT_GSM610);
|
||||
/* Soundforge W64. */
|
||||
//sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_W64 | lsndf_frmts.SF_FORMAT_PCM_U8);
|
||||
//sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_W64 | lsndf_frmts.SF_FORMAT_PCM_16);
|
||||
//sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_W64 | lsndf_frmts.SF_FORMAT_MS_ADPCM);
|
||||
//sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_W64 | lsndf_frmts.SF_FORMAT_IMA_ADPCM);
|
||||
//sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_W64 | lsndf_frmts.SF_FORMAT_GSM610);
|
||||
|
||||
|
||||
//check that SF_INFO is valid
|
||||
if ( sf_format_check(ref sfinfo) == 0 ) {
|
||||
Console.WriteLine("sf_format_check failed. Invalid encoding");
|
||||
return;
|
||||
}
|
||||
|
||||
//open output file
|
||||
IntPtr outfile = sf_open (ofn, (int)lsndf_tf.SFM_WRITE, ref sfinfo);
|
||||
|
||||
//exit if error was thrown
|
||||
if ( (int)outfile == 0 ) {
|
||||
Console.WriteLine("Error opening " + ofn);
|
||||
Console.WriteLine("Error #" + sf_error(outfile));
|
||||
return;
|
||||
}
|
||||
|
||||
//infile -> outfile
|
||||
Console.Write(sfn + " -> " + ofn);
|
||||
while ( (rcnt = sf_read_float (infile, buffer, BUFFER_LEN)) > 0) {
|
||||
Console.Write(".");
|
||||
sf_write_float (outfile, buffer, BUFFER_LEN);
|
||||
}
|
||||
Console.WriteLine("done.");
|
||||
|
||||
//close up shop
|
||||
sf_close(infile);
|
||||
sf_close(outfile);
|
||||
|
||||
|
||||
} //main()
|
||||
|
||||
|
||||
} //class lsndf_example {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2001-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2001-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
@ -91,6 +91,6 @@ main (void)
|
||||
puts (sf_strerror (file)) ;
|
||||
|
||||
sf_close (file) ;
|
||||
return 0 ;
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2001-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2001-2013 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
@ -7,15 +7,15 @@
|
||||
** 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.
|
||||
** * 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
|
||||
@ -31,12 +31,13 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Include this header file to use functions from libsndfile. */
|
||||
#include <sndfile.h>
|
||||
|
||||
/* This will be the length of the buffer used to hold.frames while
|
||||
** we process them.
|
||||
/* This will be the length of the buffer used to hold.frames while
|
||||
** we process them.
|
||||
*/
|
||||
#define BUFFER_LEN 1024
|
||||
|
||||
@ -49,31 +50,35 @@ static void process_data (double *data, int count, int channels) ;
|
||||
|
||||
int
|
||||
main (void)
|
||||
{ /* This is a buffer of double precision floating point values
|
||||
** which will hold our data while we process it.
|
||||
*/
|
||||
static double data [BUFFER_LEN] ;
|
||||
{ /* This is a buffer of double precision floating point values
|
||||
** which will hold our data while we process it.
|
||||
*/
|
||||
static double data [BUFFER_LEN] ;
|
||||
|
||||
/* A SNDFILE is very much like a FILE in the Standard C library. The
|
||||
** sf_open function return an SNDFILE* pointer when they sucessfully
|
||||
/* A SNDFILE is very much like a FILE in the Standard C library. The
|
||||
** sf_open function return an SNDFILE* pointer when they sucessfully
|
||||
** open the specified file.
|
||||
*/
|
||||
SNDFILE *infile, *outfile ;
|
||||
*/
|
||||
SNDFILE *infile, *outfile ;
|
||||
|
||||
/* A pointer to an SF_INFO stutct is passed to sf_open.
|
||||
** On read, the library fills this struct with information about the file.
|
||||
** On write, the struct must be filled in before calling sf_open.
|
||||
*/
|
||||
SF_INFO sfinfo ;
|
||||
int readcount ;
|
||||
const char *infilename = "input.wav" ;
|
||||
const char *outfilename = "output.wav" ;
|
||||
/* A pointer to an SF_INFO struct is passed to sf_open.
|
||||
** On read, the library fills this struct with information about the file.
|
||||
** On write, the struct must be filled in before calling sf_open.
|
||||
*/
|
||||
SF_INFO sfinfo ;
|
||||
int readcount ;
|
||||
const char *infilename = "input.wav" ;
|
||||
const char *outfilename = "output.wav" ;
|
||||
|
||||
/* Here's where we open the input file. We pass sf_open the file name and
|
||||
** a pointer to an SF_INFO struct.
|
||||
** On successful open, sf_open returns a SNDFILE* pointer which is used
|
||||
** for all subsequent operations on that file.
|
||||
** If an error occurs during sf_open, the function returns a NULL pointer.
|
||||
/* The SF_INFO struct must be initialized before using it.
|
||||
*/
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
/* Here's where we open the input file. We pass sf_open the file name and
|
||||
** a pointer to an SF_INFO struct.
|
||||
** On successful open, sf_open returns a SNDFILE* pointer which is used
|
||||
** for all subsequent operations on that file.
|
||||
** If an error occurs during sf_open, the function returns a NULL pointer.
|
||||
**
|
||||
** If you are trying to open a raw headerless file you will need to set the
|
||||
** format and channels fields of sfinfo before calling sf_open(). For
|
||||
@ -82,56 +87,56 @@ main (void)
|
||||
**
|
||||
** sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16 ;
|
||||
** sfinfo.channels = 2 ;
|
||||
*/
|
||||
if (! (infile = sf_open (infilename, SFM_READ, &sfinfo)))
|
||||
{ /* Open failed so print an error message. */
|
||||
printf ("Not able to open input file %s.\n", infilename) ;
|
||||
/* Print the error message from libsndfile. */
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
*/
|
||||
if (! (infile = sf_open (infilename, SFM_READ, &sfinfo)))
|
||||
{ /* Open failed so print an error message. */
|
||||
printf ("Not able to open input file %s.\n", infilename) ;
|
||||
/* Print the error message from libsndfile. */
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if (sfinfo.channels > MAX_CHANNELS)
|
||||
{ printf ("Not able to process more than %d channels\n", MAX_CHANNELS) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
/* Open the output file. */
|
||||
if (! (outfile = sf_open (outfilename, SFM_WRITE, &sfinfo)))
|
||||
{ printf ("Not able to open output file %s.\n", outfilename) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
if (sfinfo.channels > MAX_CHANNELS)
|
||||
{ printf ("Not able to process more than %d channels\n", MAX_CHANNELS) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
/* Open the output file. */
|
||||
if (! (outfile = sf_open (outfilename, SFM_WRITE, &sfinfo)))
|
||||
{ printf ("Not able to open output file %s.\n", outfilename) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
/* While there are.frames in the input file, read them, process
|
||||
** them and write them to the output file.
|
||||
*/
|
||||
while ((readcount = sf_read_double (infile, data, BUFFER_LEN)))
|
||||
{ process_data (data, readcount, sfinfo.channels) ;
|
||||
sf_write_double (outfile, data, readcount) ;
|
||||
} ;
|
||||
/* While there are.frames in the input file, read them, process
|
||||
** them and write them to the output file.
|
||||
*/
|
||||
while ((readcount = sf_read_double (infile, data, BUFFER_LEN)))
|
||||
{ process_data (data, readcount, sfinfo.channels) ;
|
||||
sf_write_double (outfile, data, readcount) ;
|
||||
} ;
|
||||
|
||||
/* Close input and output files. */
|
||||
sf_close (infile) ;
|
||||
sf_close (outfile) ;
|
||||
/* Close input and output files. */
|
||||
sf_close (infile) ;
|
||||
sf_close (outfile) ;
|
||||
|
||||
return 0 ;
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
static void
|
||||
process_data (double *data, int count, int channels)
|
||||
{ double channel_gain [MAX_CHANNELS] = { 0.5, 0.8, 0.1, 0.4, 0.4, 0.9 } ;
|
||||
int k, chan ;
|
||||
int k, chan ;
|
||||
|
||||
/* Process the data here.
|
||||
** If the soundfile contains more then 1 channel you need to take care of
|
||||
** the data interleaving youself.
|
||||
** Current we just apply a channel dependant gain.
|
||||
*/
|
||||
/* Process the data here.
|
||||
** If the soundfile contains more then 1 channel you need to take care of
|
||||
** the data interleaving youself.
|
||||
** Current we just apply a channel dependant gain.
|
||||
*/
|
||||
|
||||
for (chan = 0 ; chan < channels ; chan ++)
|
||||
for (k = chan ; k < count ; k+= channels)
|
||||
data [k] *= channel_gain [chan] ;
|
||||
for (chan = 0 ; chan < channels ; chan ++)
|
||||
for (k = chan ; k < count ; k+= channels)
|
||||
data [k] *= channel_gain [chan] ;
|
||||
|
||||
return ;
|
||||
return ;
|
||||
} /* process_data */
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2008-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2008-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
@ -68,9 +68,9 @@ convert_to_text (SNDFILE * infile, FILE * outfile, int channels)
|
||||
int
|
||||
main (int argc, char * argv [])
|
||||
{ char *progname, *infilename, *outfilename ;
|
||||
SNDFILE *infile = NULL ;
|
||||
SNDFILE *infile = NULL ;
|
||||
FILE *outfile = NULL ;
|
||||
SF_INFO sfinfo ;
|
||||
SF_INFO sfinfo ;
|
||||
|
||||
progname = strrchr (argv [0], '/') ;
|
||||
progname = progname ? progname + 1 : argv [0] ;
|
||||
@ -101,6 +101,8 @@ main (int argc, char * argv [])
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
if ((infile = sf_open (infilename, SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("Not able to open input file %s.\n", infilename) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2007 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2007-2011 Erik de Castro Lopo <erikd@mega-nerd.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
|
||||
|
@ -10,7 +10,7 @@ Release: %{release}
|
||||
Copyright: LGPL
|
||||
Group: Libraries/Sound
|
||||
Source: http://www.mega-nerd.com/libsndfile/libsndfile-%{version}.tar.gz
|
||||
URL: http://www.mega-nerd.com/libsndfile/
|
||||
Url: http://www.mega-nerd.com/libsndfile/
|
||||
BuildRoot: /var/tmp/%{name}-%{version}
|
||||
|
||||
%description
|
||||
|
491
libs/libsndfile/make_lite.py
Normal file
491
libs/libsndfile/make_lite.py
Normal file
@ -0,0 +1,491 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import commands, os, re, string, sys, time
|
||||
|
||||
def count_enclosed_functions (source):
|
||||
func_count = 0
|
||||
open_brace = 0
|
||||
close_brace = 0
|
||||
for ch in source:
|
||||
if ch == '{':
|
||||
open_brace += 1
|
||||
elif ch == '}':
|
||||
close_brace += 1
|
||||
if open_brace == close_brace:
|
||||
func_count += 1
|
||||
if open_brace < close_brace:
|
||||
print "count_enclosed_functions : open_brace < close_brace"
|
||||
return -1
|
||||
return func_count
|
||||
|
||||
def find_function_prototype (source, proto_name):
|
||||
proto_re = "(^[a-zA-Z_ \t]+\s+%s[^a-zA-Z0-9_]\s*\([^\)]+\)\s+;\n)" % (proto_name)
|
||||
proto_result = re.search (proto_re, source, re.MULTILINE | re.DOTALL)
|
||||
if not proto_result:
|
||||
return None
|
||||
proto_text = proto_result.groups ()[0]
|
||||
return proto_text
|
||||
|
||||
def find_function_definition (source, func_name):
|
||||
func_re = "(\n[a-zA-Z_ \t]+\n%s[^a-zA-Z0-9_].* /\* %s \*/\n)" % (func_name, func_name)
|
||||
func_result = re.search (func_re, source, re.MULTILINE | re.DOTALL)
|
||||
if not func_result:
|
||||
sys.exit (1)
|
||||
return None
|
||||
func_text = func_result.groups ()[0]
|
||||
|
||||
# Now to check that we only have one enclosing function.
|
||||
func_count = count_enclosed_functions (func_text)
|
||||
if func_count != 1:
|
||||
return None
|
||||
return func_text
|
||||
|
||||
def find_include (source, inc_name):
|
||||
inc_re = "(^#include\s+[\<\"]%s[\"\>]\s*)" % inc_name
|
||||
inc_result = re.search (inc_re, source, re.MULTILINE | re.DOTALL)
|
||||
if not inc_result:
|
||||
return None
|
||||
inc_text = inc_result.groups ()[0]
|
||||
return inc_text
|
||||
|
||||
def find_assign_statement (source, var_name):
|
||||
var_re = "(^\s+%s\s*=[^;]+;)" % var_name
|
||||
var_result = re.search (var_re, source, re.MULTILINE | re.DOTALL)
|
||||
if not var_result:
|
||||
return None
|
||||
assign_text = var_result.groups ()[0]
|
||||
return assign_text
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
|
||||
def remove_include (source, inc_name):
|
||||
inc_text = find_include (source, inc_name)
|
||||
if not inc_text:
|
||||
print "remove_include : include '%s' not found. Exiting." % inc_name
|
||||
sys.exit (1)
|
||||
|
||||
source = string.replace (source, inc_text, "")
|
||||
return source
|
||||
|
||||
def remove_assign (source, assign_name):
|
||||
assign_text = find_assign (source, inc_name)
|
||||
if not inc_text:
|
||||
print "remove_include : include '%s' not found. Exiting." % inc_name
|
||||
sys.exit (1)
|
||||
|
||||
source = string.replace (source, inc_text, "")
|
||||
return source
|
||||
|
||||
def remove_prototype (source, proto_name):
|
||||
proto_text = find_function_prototype (source, proto_name)
|
||||
if not proto_text:
|
||||
print "remove_prototype : prototype '%s' not found. Exiting." % proto_name
|
||||
sys.exit (1)
|
||||
|
||||
source = string.replace (source, proto_text, "")
|
||||
return source
|
||||
|
||||
def remove_function (source, func_name):
|
||||
func_text = find_function_definition (source, func_name)
|
||||
if not func_text:
|
||||
print "remove_function : function '%s' not found. Exiting." % func_name
|
||||
sys.exit (1)
|
||||
|
||||
source = string.replace (source, func_text, "/* Function %s() removed here. */\n" % func_name)
|
||||
return source
|
||||
|
||||
def remove_all_assignments (source, var):
|
||||
count = 0
|
||||
while 1:
|
||||
assign_text = find_assign_statement (source, var)
|
||||
if not assign_text:
|
||||
if count != 0:
|
||||
break
|
||||
print "remove_all_assignments : variable '%s' not found. Exiting." % var
|
||||
sys.exit (1)
|
||||
|
||||
source = string.replace (source, assign_text, "")
|
||||
count += 1
|
||||
return source
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------
|
||||
|
||||
def remove_funcs_and_protos_from_file (filename, func_list):
|
||||
source_code = open (filename, 'r').read ()
|
||||
|
||||
for func in func_list:
|
||||
source_code = remove_prototype (source_code, func) ;
|
||||
source_code = remove_function (source_code, func) ;
|
||||
open (filename, 'w').write (source_code)
|
||||
|
||||
def remove_funcs_from_file (filename, func_list):
|
||||
source_code = open (filename, 'r').read ()
|
||||
|
||||
for func in func_list:
|
||||
source_code = remove_function (source_code, func) ;
|
||||
open (filename, 'w').write (source_code)
|
||||
|
||||
def remove_protos_from_file (filename, func_list):
|
||||
source_code = open (filename, 'r').read ()
|
||||
|
||||
for func in func_list:
|
||||
source_code = remove_prototype (source_code, func) ;
|
||||
open (filename, 'w').write (source_code)
|
||||
|
||||
def remove_includes_from_file (filename, inc_list):
|
||||
source_code = open (filename, 'r').read ()
|
||||
|
||||
for inc in inc_list:
|
||||
source_code = remove_include (source_code, inc) ;
|
||||
open (filename, 'w').write (source_code)
|
||||
|
||||
def remove_all_assignments_from_file (filename, var_list):
|
||||
source_code = open (filename, 'r').read ()
|
||||
|
||||
for var in var_list:
|
||||
source_code = remove_all_assignments (source_code, var) ;
|
||||
open (filename, 'w').write (source_code)
|
||||
|
||||
def remove_comment_start_end (filename, start_comment, end_comment):
|
||||
source_code = open (filename, 'r').read ()
|
||||
|
||||
while 1:
|
||||
start_index = string.find (source_code, start_comment)
|
||||
end_index = string.find (source_code, end_comment)
|
||||
if start_index < 0 or end_index < start_index:
|
||||
break
|
||||
end_index += len (end_comment)
|
||||
source_code = source_code [:start_index-1] + source_code [end_index:] ;
|
||||
|
||||
open (filename, 'w').write (source_code)
|
||||
|
||||
def remove_strings_from_file (filename, str_list):
|
||||
file_text = open (filename, 'r').read ()
|
||||
for current_str in str_list:
|
||||
file_text = string.replace (file_text, current_str, '')
|
||||
open (filename, 'w').write (file_text)
|
||||
|
||||
def string_replace_in_file (filename, from_str, to_str):
|
||||
file_text = open (filename, 'r').read ()
|
||||
file_text = string.replace (file_text, from_str, to_str)
|
||||
open (filename, 'w').write (file_text)
|
||||
|
||||
def remove_regex_from_file (filename, regex_list):
|
||||
file_text = open (filename, 'r').read ()
|
||||
for regex in regex_list:
|
||||
file_text = re.sub (regex, '', file_text, re.MULTILINE | re.DOTALL)
|
||||
open (filename, 'w').write (file_text)
|
||||
|
||||
#==========================================================================
|
||||
|
||||
def find_configure_version (filename):
|
||||
# AM_INIT_AUTOMAKE(libsndfile,0.0.21pre6)
|
||||
file = open (filename)
|
||||
while 1:
|
||||
line = file.readline ()
|
||||
if re.search ("AC_INIT", line):
|
||||
x = re.sub ("[^\(]+\(", "", line)
|
||||
x = re.sub ("\).*\n", "", x)
|
||||
x = string.split (x, ",")
|
||||
package = x [0]
|
||||
version = x [1]
|
||||
break
|
||||
file.close ()
|
||||
# version = re.escape (version)
|
||||
return package, version
|
||||
|
||||
def fix_configure_ac_file (filename):
|
||||
data = open (filename, 'r').read ()
|
||||
data = string.replace (data, "AM_INIT_AUTOMAKE(libsndfile,", "AM_INIT_AUTOMAKE(libsndfile_lite,", 1)
|
||||
|
||||
file = open (filename, 'w')
|
||||
file.write (data)
|
||||
file.close ()
|
||||
|
||||
|
||||
def make_dist_file (package, version):
|
||||
print "Making dist file."
|
||||
tar_gz_file = "%s-%s.tar.gz" % (package, version)
|
||||
if os.path.exists (tar_gz_file):
|
||||
return
|
||||
if os.system ("make dist"):
|
||||
sys.exit (1)
|
||||
return
|
||||
|
||||
def delete_files (file_list):
|
||||
for file_name in file_list:
|
||||
os.remove (file_name)
|
||||
|
||||
#=======================================================================
|
||||
|
||||
source_dir = os.getcwd ()
|
||||
|
||||
conf_package, conf_version = find_configure_version ('configure.ac')
|
||||
|
||||
package_version = "%s-%s" % (conf_package, conf_version)
|
||||
lite_version = "%s_lite-%s" % (conf_package, conf_version)
|
||||
|
||||
os.system ("rm -rf %s%s.tar.gz" % (source_dir, package_version))
|
||||
|
||||
os.system ("make dist")
|
||||
|
||||
make_dist_file (conf_package, conf_version)
|
||||
|
||||
os.chdir ("/tmp")
|
||||
|
||||
print "Uncompressing .tar.gz file."
|
||||
os.system ("rm -rf %s" % package_version)
|
||||
if os.system ("tar zxf %s/%s.tar.gz" % (source_dir, package_version)):
|
||||
sys.exit (1)
|
||||
|
||||
|
||||
print "Renaming to libsndfile_lite."
|
||||
os.system ("rm -rf %s" % lite_version)
|
||||
os.rename (package_version, lite_version)
|
||||
|
||||
print "Changing into libsndfile_lite directory."
|
||||
os.chdir (lite_version)
|
||||
|
||||
print "Removing un-neeed directories."
|
||||
delete_dirs = [ 'src/G72x' ]
|
||||
|
||||
for dir_name in delete_dirs:
|
||||
os.system ("rm -rf %s" % dir_name)
|
||||
|
||||
print "Removing un-needed files."
|
||||
delete_files ([ 'src/ircam.c', 'src/nist.c',
|
||||
'src/ima_adpcm.c', 'src/ms_adpcm.c', 'src/au_g72x.c',
|
||||
'src/mat4.c', 'src/mat5.c', 'src/dwvw.c', 'src/paf.c',
|
||||
'src/ogg.c', 'src/pvf.c', 'src/xi.c', 'src/htk.c',
|
||||
'src/sd2.c', 'src/rx2.c', 'src/txw.c', 'src/wve.c',
|
||||
'src/dwd.c', 'src/svx.c', 'src/voc.c', 'src/vox_adpcm.c',
|
||||
'src/sds.c'
|
||||
])
|
||||
|
||||
|
||||
print "Hacking 'configure.ac' and 'src/Makefile.am'."
|
||||
remove_strings_from_file ('configure.ac', [ 'src/G72x/Makefile' ])
|
||||
remove_strings_from_file ('src/Makefile.am', [ 'G72x/libg72x.la', 'G72x',
|
||||
'ircam.c', 'nist.c', 'ima_adpcm.c', 'ms_adpcm.c', 'au_g72x.c', 'mat4.c',
|
||||
'mat5.c', 'dwvw.c', 'paf.c', 'ogg.c', 'pvf.c', 'xi.c', 'htk.c',
|
||||
'sd2.c', 'rx2.c', 'txw.c', 'wve.c', 'dwd.c', 'svx.c', 'voc.c',
|
||||
'vox_adpcm.c', 'sds.c'
|
||||
])
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
print "Hacking header files."
|
||||
|
||||
remove_protos_from_file ('src/common.h', [ 'xi_open', 'sd2_open', 'ogg_open',
|
||||
'dwvw_init', 'paf_open', 'svx_open', 'nist_open', 'rx2_open', 'mat4_open',
|
||||
'voc_open', 'txw_open', 'dwd_open', 'htk_open', 'wve_open', 'mat5_open',
|
||||
'pvf_open', 'ircam_open', 'sds_open',
|
||||
'float32_init', 'double64_init', 'aiff_ima_init', 'vox_adpcm_init',
|
||||
'wav_w64_ima_init', 'wav_w64_msadpcm_init'
|
||||
])
|
||||
|
||||
remove_protos_from_file ('src/au.h',
|
||||
[ 'au_g72x_reader_init', 'au_g72x_writer_init' ])
|
||||
|
||||
remove_protos_from_file ('src/wav_w64.h', [ 'msadpcm_write_adapt_coeffs' ])
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
print "Hacking case statements."
|
||||
|
||||
remove_comment_start_end ('src/sndfile.c', '/* Lite remove start */' , '/* Lite remove end */')
|
||||
remove_comment_start_end ('src/aiff.c', '/* Lite remove start */' , '/* Lite remove end */')
|
||||
remove_comment_start_end ('src/au.c', '/* Lite remove start */' , '/* Lite remove end */')
|
||||
remove_comment_start_end ('src/raw.c', '/* Lite remove start */' , '/* Lite remove end */')
|
||||
remove_comment_start_end ('src/w64.c', '/* Lite remove start */' , '/* Lite remove end */')
|
||||
remove_comment_start_end ('src/wav.c', '/* Lite remove start */' , '/* Lite remove end */')
|
||||
remove_comment_start_end ('src/double64.c', '/* Lite remove start */' , '/* Lite remove end */')
|
||||
remove_comment_start_end ('src/float32.c', '/* Lite remove start */' , '/* Lite remove end */')
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
print "Hacking src/pcm.c."
|
||||
remove_funcs_from_file ('src/pcm.c', [
|
||||
'f2sc_array', 'f2sc_clip_array', 'f2uc_array', 'f2uc_clip_array',
|
||||
'f2bes_array', 'f2bes_clip_array', 'f2les_array', 'f2les_clip_array',
|
||||
'f2let_array', 'f2let_clip_array', 'f2bet_array', 'f2bet_clip_array',
|
||||
'f2bei_array', 'f2bei_clip_array', 'f2lei_array', 'f2lei_clip_array',
|
||||
'd2sc_array', 'd2sc_clip_array', 'd2uc_array', 'd2uc_clip_array',
|
||||
'd2bes_array', 'd2bes_clip_array', 'd2les_array', 'd2les_clip_array',
|
||||
'd2let_array', 'd2let_clip_array', 'd2bet_array', 'd2bet_clip_array',
|
||||
'd2bei_array', 'd2bei_clip_array', 'd2lei_array', 'd2lei_clip_array',
|
||||
])
|
||||
|
||||
remove_funcs_and_protos_from_file ('src/pcm.c', [
|
||||
'pcm_read_sc2f', 'pcm_read_uc2f', 'pcm_read_les2f', 'pcm_read_bes2f',
|
||||
'pcm_read_let2f', 'pcm_read_bet2f', 'pcm_read_lei2f', 'pcm_read_bei2f',
|
||||
'pcm_read_sc2d', 'pcm_read_uc2d', 'pcm_read_les2d', 'pcm_read_bes2d',
|
||||
'pcm_read_let2d', 'pcm_read_bet2d', 'pcm_read_lei2d', 'pcm_read_bei2d',
|
||||
'pcm_write_f2sc', 'pcm_write_f2uc', 'pcm_write_f2bes', 'pcm_write_f2les',
|
||||
'pcm_write_f2bet', 'pcm_write_f2let', 'pcm_write_f2bei', 'pcm_write_f2lei',
|
||||
'pcm_write_d2sc', 'pcm_write_d2uc', 'pcm_write_d2bes', 'pcm_write_d2les',
|
||||
'pcm_write_d2bet', 'pcm_write_d2let', 'pcm_write_d2bei', 'pcm_write_d2lei',
|
||||
|
||||
'sc2f_array', 'uc2f_array', 'bes2f_array', 'les2f_array',
|
||||
'bet2f_array', 'let2f_array', 'bei2f_array', 'lei2f_array',
|
||||
'sc2d_array', 'uc2d_array', 'bes2d_array', 'les2d_array',
|
||||
'bet2d_array', 'let2d_array', 'bei2d_array', 'lei2d_array'
|
||||
])
|
||||
|
||||
remove_includes_from_file ('src/pcm.c', [ 'float_cast.h' ])
|
||||
remove_all_assignments_from_file ('src/pcm.c', [
|
||||
'psf-\>write_float', 'psf\-\>write_double',
|
||||
'psf-\>read_float', 'psf\-\>read_double' ])
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
print "Hacking src/ulaw.c."
|
||||
remove_funcs_and_protos_from_file ('src/ulaw.c', [
|
||||
'ulaw_read_ulaw2f', 'ulaw_read_ulaw2d',
|
||||
'ulaw_write_f2ulaw', 'ulaw_write_d2ulaw',
|
||||
'ulaw2f_array', 'ulaw2d_array', 'f2ulaw_array', 'd2ulaw_array'
|
||||
])
|
||||
|
||||
remove_includes_from_file ('src/ulaw.c', [ 'float_cast.h' ])
|
||||
remove_all_assignments_from_file ('src/ulaw.c', [
|
||||
'psf-\>write_float', 'psf\-\>write_double',
|
||||
'psf-\>read_float', 'psf\-\>read_double' ])
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
print "Hacking src/alaw.c."
|
||||
remove_funcs_and_protos_from_file ('src/alaw.c', [
|
||||
'alaw_read_alaw2f', 'alaw_read_alaw2d',
|
||||
'alaw_write_f2alaw', 'alaw_write_d2alaw',
|
||||
'alaw2f_array', 'alaw2d_array', 'f2alaw_array', 'd2alaw_array'
|
||||
])
|
||||
|
||||
remove_includes_from_file ('src/alaw.c', [ 'float_cast.h' ])
|
||||
remove_all_assignments_from_file ('src/alaw.c', [
|
||||
'psf-\>write_float', 'psf\-\>write_double',
|
||||
'psf-\>read_float', 'psf\-\>read_double' ])
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
print "Hacking src/gsm610.c."
|
||||
remove_funcs_and_protos_from_file ('src/gsm610.c', [
|
||||
'gsm610_read_f', 'gsm610_read_d', 'gsm610_write_f', 'gsm610_write_d'
|
||||
])
|
||||
|
||||
remove_includes_from_file ('src/gsm610.c', [ 'float_cast.h' ])
|
||||
remove_all_assignments_from_file ('src/gsm610.c', [
|
||||
'psf-\>write_float', 'psf\-\>write_double',
|
||||
'psf-\>read_float', 'psf\-\>read_double' ])
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
print "Hacking src/float32.c."
|
||||
|
||||
# string_replace_in_file ('src/float32.c', '"float_cast.h"', '<math.h>')
|
||||
remove_funcs_from_file ('src/float32.c', [ 'float32_init' ])
|
||||
|
||||
remove_funcs_and_protos_from_file ('src/float32.c', [
|
||||
'host_read_f2s', 'host_read_f2i', 'host_read_f', 'host_read_f2d',
|
||||
'host_write_s2f', 'host_write_i2f', 'host_write_f', 'host_write_d2f',
|
||||
'f2s_array', 'f2i_array', 'f2d_array', 's2f_array', 'i2f_array', 'd2f_array',
|
||||
'float32_peak_update',
|
||||
'replace_read_f2s', 'replace_read_f2i', 'replace_read_f', 'replace_read_f2d',
|
||||
'replace_write_s2f', 'replace_write_i2f', 'replace_write_f', 'replace_write_d2f',
|
||||
'bf2f_array', 'f2bf_array',
|
||||
'float32_get_capability',
|
||||
])
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
print "Hacking src/double64.c."
|
||||
remove_funcs_from_file ('src/double64.c', [ 'double64_init' ])
|
||||
|
||||
remove_funcs_and_protos_from_file ('src/double64.c', [
|
||||
'host_read_d2s', 'host_read_d2i', 'host_read_d2f', 'host_read_d',
|
||||
'host_write_s2d', 'host_write_i2d', 'host_write_f2d', 'host_write_d',
|
||||
'd2s_array', 'd2i_array', 'd2f_array',
|
||||
's2d_array', 'i2d_array', 'f2d_array',
|
||||
'double64_peak_update', 'double64_get_capability',
|
||||
'replace_read_d2s', 'replace_read_d2i', 'replace_read_d2f', 'replace_read_d',
|
||||
'replace_write_s2d', 'replace_write_i2d', 'replace_write_f2d', 'replace_write_d',
|
||||
'd2bd_read', 'bd2d_write'
|
||||
])
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
print "Hacking test programs."
|
||||
delete_files ([ 'tests/dwvw_test.c', 'tests/floating_point_test.c',
|
||||
'tests/dft_cmp.c', 'tests/peak_chunk_test.c',
|
||||
'tests/scale_clip_test.tpl', 'tests/scale_clip_test.def'
|
||||
])
|
||||
|
||||
remove_comment_start_end ('tests/write_read_test.def', '/* Lite remove start */', '/* Lite remove end */')
|
||||
remove_comment_start_end ('tests/write_read_test.tpl', '/* Lite remove start */', '/* Lite remove end */')
|
||||
|
||||
remove_comment_start_end ('tests/Makefile.am', '# Lite remove start', '# Lite remove end')
|
||||
|
||||
remove_strings_from_file ('tests/Makefile.am', [
|
||||
'scale_clip_test.tpl', 'scale_clip_test.def',
|
||||
'\n\t./dwvw_test',
|
||||
'\n\t./floating_point_test', '\n\t./scale_clip_test',
|
||||
'\n\t./peak_chunk_test aiff', '\n\t./peak_chunk_test wav',
|
||||
'\n\t./command_test norm', '\n\t./command_test peak',
|
||||
'\n\t./lossy_comp_test wav_ima', '\n\t./lossy_comp_test wav_msadpcm',
|
||||
'\n\t./lossy_comp_test au_g721', '\n\t./lossy_comp_test au_g723',
|
||||
'\n\t./lossy_comp_test vox_adpcm',
|
||||
'\n\t./lossy_comp_test w64_ima', '\n\t./lossy_comp_test w64_msadpcm',
|
||||
'peak_chunk_test', 'dwvw_test', 'floating_point_test', 'scale_clip_test',
|
||||
|
||||
'paf-tests', 'svx-tests', 'nist-tests', 'ircam-tests', 'voc-tests',
|
||||
'mat4-tests', 'mat5-tests', 'pvf-tests', 'xi-tests', 'htk-tests',
|
||||
'sds-tests'
|
||||
])
|
||||
|
||||
remove_comment_start_end ('tests/pcm_test.c', '/* Lite remove start */', '/* Lite remove end */')
|
||||
remove_funcs_and_protos_from_file ('tests/pcm_test.c', [
|
||||
'pcm_test_float', 'pcm_test_double'
|
||||
])
|
||||
|
||||
remove_comment_start_end ('tests/lossy_comp_test.c', '/* Lite remove start */', '/* Lite remove end */')
|
||||
remove_funcs_and_protos_from_file ('tests/lossy_comp_test.c', [
|
||||
'lcomp_test_float', 'lcomp_test_double', 'sdlcomp_test_float', 'sdlcomp_test_double',
|
||||
'smoothed_diff_float', 'smoothed_diff_double'
|
||||
])
|
||||
|
||||
remove_comment_start_end ('tests/multi_file_test.c', '/* Lite remove start */', '/* Lite remove end */')
|
||||
|
||||
remove_strings_from_file ('tests/stdio_test.c', [
|
||||
'"paf",', '"svx",', '"nist",', '"ircam",', '"voc",', '"mat4",', '"mat5",', '"pvf",'
|
||||
])
|
||||
|
||||
remove_comment_start_end ('tests/pipe_test.c', '/* Lite remove start */', '/* Lite remove end */')
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
print "Fixing configure.ac file."
|
||||
fix_configure_ac_file ('configure.ac')
|
||||
|
||||
print "Building and testing source."
|
||||
# Try --disable-shared --disable-gcc-opt
|
||||
if os.system ("./reconfigure.mk && ./configure --disable-shared --disable-gcc-opt && make check"):
|
||||
os.system ('PS1="FIX > " bash --norc')
|
||||
sys.exit (1)
|
||||
|
||||
print "Making distcheck"
|
||||
if os.system ("make distcheck"):
|
||||
os.system ('PS1="FIX > " bash --norc')
|
||||
sys.exit (1)
|
||||
|
||||
print "Copying tarball"
|
||||
if os.system ("cp %s.tar.gz %s" % (lite_version, source_dir)):
|
||||
print "??? %s.tar.gz ???" % lite_version
|
||||
os.system ('PS1="FIX > " bash --norc')
|
||||
sys.exit (1)
|
||||
|
||||
os.chdir (source_dir)
|
||||
|
||||
os.system ("rm -rf /tmp/%s" % lite_version)
|
||||
|
||||
print "Done."
|
@ -1,6 +1,15 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
man_MANS = sndfile-info.1 sndfile-play.1 sndfile-convert.1
|
||||
man_MANS = sndfile-info.1 sndfile-play.1 sndfile-convert.1 sndfile-cmp.1 \
|
||||
sndfile-metadata-get.1 sndfile-metadata-set.1 sndfile-concat.1 \
|
||||
sndfile-interleave.1 sndfile-deinterleave.1
|
||||
|
||||
EXTRA_DIST = sndfile-info.1 sndfile-play.1 sndfile-convert.1
|
||||
EXTRA_DIST = sndfile-info.1 sndfile-play.1 sndfile-convert.1 sndfile-cmp.1 \
|
||||
sndfile-metadata-get.1 sndfile-concat.1 sndfile-interleave.1
|
||||
|
||||
# Same manpage for both programs.
|
||||
sndfile-metadata-set.1 : sndfile-metadata-get.1
|
||||
$(LN_S) $(srcdir)/sndfile-metadata-get.1 $@
|
||||
|
||||
sndfile-deinterleave.1 : sndfile-interleave.1
|
||||
$(LN_S) $(srcdir)/sndfile-interleave.1 $@
|
||||
|
16
libs/libsndfile/man/sndfile-cmp.1
Normal file
16
libs/libsndfile/man/sndfile-cmp.1
Normal file
@ -0,0 +1,16 @@
|
||||
.TH SNDFILE-CMP 1 "October 5, 2009"
|
||||
.SH NAME
|
||||
sndfile-cmp \- compares two audio files
|
||||
.SH SYNOPSIS
|
||||
.B sndfile-cmp
|
||||
.RI "file1 file2"
|
||||
.SH DESCRIPTION
|
||||
sndfile-cmp compares the audio data of two sound files. In particular most
|
||||
differences in the audio file header, particularly metadata like string info,
|
||||
are completely ignored.
|
||||
|
||||
sndfile-cmp 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>.
|
||||
|
16
libs/libsndfile/man/sndfile-concat.1
Normal file
16
libs/libsndfile/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>.
|
||||
|
@ -16,7 +16,7 @@ The format of the output file is determined by the filename extension
|
||||
of the output file.
|
||||
.LP
|
||||
The optional encoding parameter allows setting of the data encoding for
|
||||
the output file. Run "sndfile-convert --help" for more information.
|
||||
the output file. Run "sndfile\-convert \-\-help" for more information.
|
||||
.SH AUTHOR
|
||||
This manual page was written by Erik de Castro Lopo <erikd@mega-nerd.com>.
|
||||
|
||||
|
23
libs/libsndfile/man/sndfile-interleave.1
Normal file
23
libs/libsndfile/man/sndfile-interleave.1
Normal file
@ -0,0 +1,23 @@
|
||||
.TH SNDFILE-INTERLEAVE 1 "December 14, 2009"
|
||||
.SH NAME
|
||||
sndfile-interleave \- convert multiple single channel files into a multi-channel file
|
||||
.br
|
||||
sndfile-deinterleave \- split a multi-channel into multiple single channel files
|
||||
.SH SYNOPSIS
|
||||
.B sndfile-interleave
|
||||
.RI "<input 1> <input 2> ... -o <output file>"
|
||||
.br
|
||||
.B sndfile-deinterleave
|
||||
.RI "filename"
|
||||
|
||||
.SH DESCRIPTION
|
||||
sndfile-interleave and sndfile-deinterleave use libsndfile
|
||||
(http://www.mega-nerd.com/libsndfile/) to convert back and forth between multiple
|
||||
single channel files and a single multi-channel sound file.
|
||||
|
||||
Run "sndfile\-interleave \-\-help" or "sndfile\-deinterleave \-\-help" for
|
||||
more information
|
||||
|
||||
.SH AUTHOR
|
||||
This manual page was written by Erik de Castro Lopo <erikd@mega-nerd.com>.
|
||||
|
26
libs/libsndfile/man/sndfile-metadata-get.1
Normal file
26
libs/libsndfile/man/sndfile-metadata-get.1
Normal file
@ -0,0 +1,26 @@
|
||||
.TH SNDFILE-METADATA-GET 1 "October 6, 2009"
|
||||
.SH NAME
|
||||
sndfile-metadata-get \- retrieve metadata from a sound file
|
||||
.br
|
||||
sndfile-metadata-set \- set metadata in a sound file
|
||||
.SH SYNOPSIS
|
||||
.B sndfile-metadata-get
|
||||
.RI "[options] file"
|
||||
.br
|
||||
.B sndfile-metadata-set
|
||||
.RI "[options] file"
|
||||
.br
|
||||
.B sndfile-metadata-set
|
||||
.RI "[options] input-file output-file"
|
||||
|
||||
.SH DESCRIPTION
|
||||
sndfile-metadata-get and sndfile-metadata-set use libsndfile
|
||||
(http://www.mega-nerd.com/libsndfile/) to retrieve metadata from or set metadata
|
||||
in a sound file.
|
||||
|
||||
Run "sndfile\-metadata\-get \-\-help" or "sndfile\-metadata\-set \-\-help" for
|
||||
more information
|
||||
|
||||
.SH AUTHOR
|
||||
This manual page was written by Erik de Castro Lopo <erikd@mega-nerd.com>.
|
||||
|
@ -1,36 +1,47 @@
|
||||
## 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 sndfile-salvage
|
||||
|
||||
OS_SPECIFIC_CFLAGS = @OS_SPECIFIC_CFLAGS@
|
||||
OS_SPECIFIC_LINKS = @OS_SPECIFIC_LINKS@
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/src $(OS_SPECIFIC_CFLAGS)
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/src $(OS_SPECIFIC_CFLAGS)
|
||||
|
||||
CLEANFILES = *~ sndfile-*.exe
|
||||
|
||||
# This is the BeOS version of sndfile-play. It needs to be compiled with the C++
|
||||
# compiler.
|
||||
EXTRA_DIST = sndfile-play-beos.cpp test-sndfile-metadata-set.py
|
||||
|
||||
sndfile_info_SOURCES = sndfile-info.c
|
||||
sndfile_info_SOURCES = sndfile-info.c common.c common.h
|
||||
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_play_SOURCES = sndfile-play.c common.c common.h
|
||||
sndfile_play_LDADD = $(top_builddir)/src/libsndfile.la $(OS_SPECIFIC_LINKS) $(ALSA_LIBS) $(SNDIO_LIBS)
|
||||
|
||||
sndfile_convert_SOURCES = sndfile-convert.c common.c common.h
|
||||
sndfile_convert_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
sndfile_cmp_SOURCES = sndfile-cmp.c
|
||||
sndfile_cmp_SOURCES = sndfile-cmp.c common.c common.h
|
||||
sndfile_cmp_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
sndfile_metadata_set_SOURCES = sndfile-metadata-set.c common.c common.h
|
||||
sndfile_metadata_set_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
sndfile_metadata_get_SOURCES = sndfile-metadata-get.c
|
||||
sndfile_metadata_get_SOURCES = sndfile-metadata-get.c common.c common.h
|
||||
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 common.c common.h
|
||||
sndfile_deinterleave_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
sndfile_concat_SOURCES = sndfile-concat.c common.c common.h
|
||||
sndfile_concat_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
sndfile_salvage_SOURCES = sndfile-salvage.c common.c common.h
|
||||
sndfile_salvage_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2013 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2008 George Blood Audio
|
||||
**
|
||||
** All rights reserved.
|
||||
@ -35,17 +35,18 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define BUFFER_LEN 4096
|
||||
#define BUFFER_LEN 4096
|
||||
|
||||
#define MIN(x,y) ((x) < (y) ? (x) : (y))
|
||||
#define MIN(x, y) ((x) < (y) ? (x) : (y))
|
||||
|
||||
void
|
||||
sfe_copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels)
|
||||
sfe_copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels, int normalize)
|
||||
{ static double data [BUFFER_LEN], max ;
|
||||
int frames, readcount, k ;
|
||||
|
||||
@ -54,7 +55,7 @@ sfe_copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels)
|
||||
|
||||
sf_command (infile, SFC_CALC_SIGNAL_MAX, &max, sizeof (max)) ;
|
||||
|
||||
if (max < 1.0)
|
||||
if (!normalize && max < 1.0)
|
||||
{ while (readcount > 0)
|
||||
{ readcount = sf_readf_double (infile, data, frames) ;
|
||||
sf_writef_double (outfile, data, readcount) ;
|
||||
@ -146,6 +147,14 @@ merge_broadcast_info (SNDFILE * infile, SNDFILE * outfile, int format, const MET
|
||||
REPLACE_IF_NEW (origination_time) ;
|
||||
REPLACE_IF_NEW (umid) ;
|
||||
|
||||
/* Special case for Time Ref. */
|
||||
if (info->time_ref != NULL)
|
||||
{ uint64_t ts = atoll (info->time_ref) ;
|
||||
|
||||
binfo.time_reference_high = (ts >> 32) ;
|
||||
binfo.time_reference_low = (ts & 0xffffffff) ;
|
||||
} ;
|
||||
|
||||
/* Special case for coding_history because we may want to append. */
|
||||
if (info->coding_history != NULL)
|
||||
{ if (info->coding_hist_append)
|
||||
@ -180,22 +189,22 @@ update_strings (SNDFILE * outfile, const METADATA_INFO * info)
|
||||
sf_set_string (outfile, SF_STR_TITLE, info->title) ;
|
||||
|
||||
if (info->copyright != NULL)
|
||||
sf_set_string (outfile, SF_STR_TITLE, info->copyright) ;
|
||||
sf_set_string (outfile, SF_STR_COPYRIGHT, info->copyright) ;
|
||||
|
||||
if (info->artist != NULL)
|
||||
sf_set_string (outfile, SF_STR_ARTIST, info->artist) ;
|
||||
|
||||
if (info->comment != NULL)
|
||||
sf_set_string (outfile, SF_STR_TITLE, info->comment) ;
|
||||
sf_set_string (outfile, SF_STR_COMMENT, info->comment) ;
|
||||
|
||||
if (info->date != NULL)
|
||||
sf_set_string (outfile, SF_STR_DATE, info->date) ;
|
||||
|
||||
if (info->album != NULL)
|
||||
sf_set_string (outfile, SF_STR_TITLE, info->album) ;
|
||||
sf_set_string (outfile, SF_STR_ALBUM, info->album) ;
|
||||
|
||||
if (info->license != NULL)
|
||||
sf_set_string (outfile, SF_STR_TITLE, info->license) ;
|
||||
sf_set_string (outfile, SF_STR_LICENSE, info->license) ;
|
||||
|
||||
} /* update_strings */
|
||||
|
||||
@ -238,18 +247,18 @@ sfe_apply_metadata_changes (const char * filenames [2], const METADATA_INFO * in
|
||||
goto cleanup_exit ;
|
||||
} ;
|
||||
|
||||
update_strings (outfile, info) ;
|
||||
|
||||
if (infile != outfile)
|
||||
{ int infileminor = SF_FORMAT_SUBMASK & sfinfo.format ;
|
||||
|
||||
/* If the input file is not the same as the output file, copy the data. */
|
||||
if ((infileminor == SF_FORMAT_DOUBLE) || (infileminor == SF_FORMAT_FLOAT))
|
||||
sfe_copy_data_fp (outfile, infile, sfinfo.channels) ;
|
||||
sfe_copy_data_fp (outfile, infile, sfinfo.channels, SF_FALSE) ;
|
||||
else
|
||||
sfe_copy_data_int (outfile, infile, sfinfo.channels) ;
|
||||
} ;
|
||||
|
||||
update_strings (outfile, info) ;
|
||||
|
||||
cleanup_exit :
|
||||
|
||||
if (outfile != NULL && outfile != infile)
|
||||
@ -264,3 +273,194 @@ 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 },
|
||||
{ "ogg", 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 */
|
||||
|
||||
const char *
|
||||
program_name (const char * argv0)
|
||||
{ const char * tmp ;
|
||||
|
||||
tmp = strrchr (argv0, '/') ;
|
||||
argv0 = tmp ? tmp + 1 : argv0 ;
|
||||
|
||||
tmp = strrchr (argv0, '/') ;
|
||||
argv0 = tmp ? tmp + 1 : argv0 ;
|
||||
|
||||
/* Remove leading libtool name mangling. */
|
||||
if (strstr (argv0, "lt-") == argv0)
|
||||
return argv0 + 3 ;
|
||||
|
||||
return argv0 ;
|
||||
} /* program_name */
|
||||
|
||||
const char *
|
||||
sfe_endian_name (int format)
|
||||
{
|
||||
switch (format & SF_FORMAT_ENDMASK)
|
||||
{ case SF_ENDIAN_FILE : return "file" ;
|
||||
case SF_ENDIAN_LITTLE : return "little" ;
|
||||
case SF_ENDIAN_BIG : return "big" ;
|
||||
case SF_ENDIAN_CPU : return "cpu" ;
|
||||
default : break ;
|
||||
} ;
|
||||
|
||||
return "unknown" ;
|
||||
} /* sfe_endian_name */
|
||||
|
||||
const char *
|
||||
sfe_container_name (int format)
|
||||
{
|
||||
switch (format & SF_FORMAT_TYPEMASK)
|
||||
{ case SF_FORMAT_WAV : return "WAV" ;
|
||||
case SF_FORMAT_AIFF : return "AIFF" ;
|
||||
case SF_FORMAT_AU : return "AU" ;
|
||||
case SF_FORMAT_RAW : return "RAW" ;
|
||||
case SF_FORMAT_PAF : return "PAF" ;
|
||||
case SF_FORMAT_SVX : return "SVX" ;
|
||||
case SF_FORMAT_NIST : return "NIST" ;
|
||||
case SF_FORMAT_VOC : return "VOC" ;
|
||||
case SF_FORMAT_IRCAM : return "IRCAM" ;
|
||||
case SF_FORMAT_W64 : return "W64" ;
|
||||
case SF_FORMAT_MAT4 : return "MAT4" ;
|
||||
case SF_FORMAT_MAT5 : return "MAT5" ;
|
||||
case SF_FORMAT_PVF : return "PVF" ;
|
||||
case SF_FORMAT_XI : return "XI" ;
|
||||
case SF_FORMAT_HTK : return "HTK" ;
|
||||
case SF_FORMAT_SDS : return "SDS" ;
|
||||
case SF_FORMAT_AVR : return "AVR" ;
|
||||
case SF_FORMAT_WAVEX : return "WAVEX" ;
|
||||
case SF_FORMAT_SD2 : return "SD2" ;
|
||||
case SF_FORMAT_FLAC : return "FLAC" ;
|
||||
case SF_FORMAT_CAF : return "CAF" ;
|
||||
case SF_FORMAT_WVE : return "WVE" ;
|
||||
case SF_FORMAT_OGG : return "OGG" ;
|
||||
case SF_FORMAT_MPC2K : return "MPC2K" ;
|
||||
case SF_FORMAT_RF64 : return "RF64" ;
|
||||
default : break ;
|
||||
} ;
|
||||
|
||||
return "unknown" ;
|
||||
} /* sfe_container_name */
|
||||
|
||||
const char *
|
||||
sfe_codec_name (int format)
|
||||
{
|
||||
switch (format & SF_FORMAT_SUBMASK)
|
||||
{ case SF_FORMAT_PCM_S8 : return "signed 8 bit PCM" ;
|
||||
case SF_FORMAT_PCM_16 : return "16 bit PCM" ;
|
||||
case SF_FORMAT_PCM_24 : return "24 bit PCM" ;
|
||||
case SF_FORMAT_PCM_32 : return "32 bit PCM" ;
|
||||
case SF_FORMAT_PCM_U8 : return "unsigned 8 bit PCM" ;
|
||||
case SF_FORMAT_FLOAT : return "32 bit float" ;
|
||||
case SF_FORMAT_DOUBLE : return "64 bit double" ;
|
||||
case SF_FORMAT_ULAW : return "u-law" ;
|
||||
case SF_FORMAT_ALAW : return "a-law" ;
|
||||
case SF_FORMAT_IMA_ADPCM : return "IMA ADPCM" ;
|
||||
case SF_FORMAT_MS_ADPCM : return "MS ADPCM" ;
|
||||
case SF_FORMAT_GSM610 : return "gsm610" ;
|
||||
case SF_FORMAT_VOX_ADPCM : return "Vox ADPCM" ;
|
||||
case SF_FORMAT_G721_32 : return "g721 32kbps" ;
|
||||
case SF_FORMAT_G723_24 : return "g723 24kbps" ;
|
||||
case SF_FORMAT_G723_40 : return "g723 40kbps" ;
|
||||
case SF_FORMAT_DWVW_12 : return "12 bit DWVW" ;
|
||||
case SF_FORMAT_DWVW_16 : return "16 bit DWVW" ;
|
||||
case SF_FORMAT_DWVW_24 : return "14 bit DWVW" ;
|
||||
case SF_FORMAT_DWVW_N : return "DWVW" ;
|
||||
case SF_FORMAT_DPCM_8 : return "8 bit DPCM" ;
|
||||
case SF_FORMAT_DPCM_16 : return "16 bit DPCM" ;
|
||||
case SF_FORMAT_VORBIS : return "Vorbis" ;
|
||||
case SF_FORMAT_ALAC_16 : return "16 bit ALAC" ;
|
||||
case SF_FORMAT_ALAC_20 : return "20 bit ALAC" ;
|
||||
case SF_FORMAT_ALAC_24 : return "24 bit ALAC" ;
|
||||
case SF_FORMAT_ALAC_32 : return "32 bit ALAC" ;
|
||||
default : break ;
|
||||
} ;
|
||||
return "unknown" ;
|
||||
} /* sfe_codec_name */
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2013 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
@ -30,7 +30,9 @@
|
||||
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof (x [0])))
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
typedef struct
|
||||
{ const char * title ;
|
||||
@ -53,12 +55,24 @@ typedef struct
|
||||
const char * origination_time ;
|
||||
const char * umid ;
|
||||
const char * coding_history ;
|
||||
const char * time_ref ;
|
||||
} METADATA_INFO ;
|
||||
|
||||
typedef SF_BROADCAST_INFO_VAR (2048) SF_BROADCAST_INFO_2K ;
|
||||
|
||||
void sfe_apply_metadata_changes (const char * filenames [2], const METADATA_INFO * info) ;
|
||||
|
||||
void sfe_copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels) ;
|
||||
void sfe_copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels, int normalize) ;
|
||||
|
||||
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) ;
|
||||
|
||||
const char * program_name (const char * argv0) ;
|
||||
|
||||
const char * sfe_endian_name (int format) ;
|
||||
const char * sfe_container_name (int format) ;
|
||||
const char * sfe_codec_name (int format) ;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
** Copyright (C) 2008-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2008-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2008 Conrad Parker <conrad@metadecks.org>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
@ -30,27 +31,31 @@
|
||||
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* sndfile-cmp.c
|
||||
* Conrad Parker 2008
|
||||
*/
|
||||
|
||||
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/* Length of comparison data buffers in units of items */
|
||||
#define BUFLEN 65536
|
||||
|
||||
static char * progname ;
|
||||
static char * filename1, * filename2 ;
|
||||
static const char * progname = NULL ;
|
||||
static char * filename1 = NULL, * filename2 = NULL ;
|
||||
|
||||
static int
|
||||
comparison_error (const char * what)
|
||||
{ printf ("%s: %s of files %s and %s differ\n", progname, what, filename1, filename2) ;
|
||||
comparison_error (const char * what, sf_count_t frame_offset)
|
||||
{ char buffer [128] = "" ;
|
||||
|
||||
if (frame_offset >= 0)
|
||||
snprintf (buffer, sizeof (buffer), " (at frame offset %" PRId64 ")", frame_offset) ;
|
||||
|
||||
printf ("%s: %s of files %s and %s differ%s.\n", progname, what, filename1, filename2, buffer) ;
|
||||
return 1 ;
|
||||
} /* comparison_error */
|
||||
|
||||
@ -60,7 +65,7 @@ compare (void)
|
||||
double buf1 [BUFLEN], buf2 [BUFLEN] ;
|
||||
SF_INFO sfinfo1, sfinfo2 ;
|
||||
SNDFILE * sf1 = NULL, * sf2 = NULL ;
|
||||
sf_count_t len, i, nread1, nread2 ;
|
||||
sf_count_t items, i, nread1, nread2, offset = 0 ;
|
||||
int retval = 0 ;
|
||||
|
||||
memset (&sfinfo1, 0, sizeof (SF_INFO)) ;
|
||||
@ -80,34 +85,35 @@ compare (void)
|
||||
} ;
|
||||
|
||||
if (sfinfo1.samplerate != sfinfo2.samplerate)
|
||||
{ retval = comparison_error ("Samplerates") ;
|
||||
{ retval = comparison_error ("Samplerates", -1) ;
|
||||
goto out ;
|
||||
} ;
|
||||
|
||||
if (sfinfo1.channels != sfinfo2.channels)
|
||||
{ retval = comparison_error ("Number of channels") ;
|
||||
{ retval = comparison_error ("Number of channels", -1) ;
|
||||
goto out ;
|
||||
} ;
|
||||
|
||||
/* Calculate the framecount that will fit in our data buffers */
|
||||
len = BUFLEN / sfinfo1.channels ;
|
||||
items = BUFLEN / sfinfo1.channels ;
|
||||
|
||||
while ( (nread1 = sf_readf_double (sf1, buf1, len)) > 0)
|
||||
while ((nread1 = sf_readf_double (sf1, buf1, items)) > 0)
|
||||
{ nread2 = sf_readf_double (sf2, buf2, nread1) ;
|
||||
if (nread2 != nread1)
|
||||
{ retval = comparison_error ("PCM data lengths") ;
|
||||
{ retval = comparison_error ("PCM data lengths", -1) ;
|
||||
goto out ;
|
||||
} ;
|
||||
for (i = 0 ; i < nread1 ; i++)
|
||||
for (i = 0 ; i < nread1 * sfinfo1.channels ; i++)
|
||||
{ if (buf1 [i] != buf2 [i])
|
||||
{ retval = comparison_error ("PCM data") ;
|
||||
{ retval = comparison_error ("PCM data", offset + i / sfinfo1.channels) ;
|
||||
goto out ;
|
||||
} ;
|
||||
} ;
|
||||
offset += nread1 ;
|
||||
} ;
|
||||
|
||||
if ( (nread2 = sf_readf_double (sf2, buf2, nread1)) != 0)
|
||||
{ retval = comparison_error ("PCM data lengths") ;
|
||||
if ((nread2 = sf_readf_double (sf2, buf2, items)) != 0)
|
||||
{ retval = comparison_error ("PCM data lengths", -1) ;
|
||||
goto out ;
|
||||
} ;
|
||||
|
||||
@ -127,22 +133,22 @@ print_version (void)
|
||||
} /* print_version */
|
||||
|
||||
static void
|
||||
print_usage (void)
|
||||
usage_exit (void)
|
||||
{
|
||||
print_version () ;
|
||||
|
||||
printf ("Usage : %s <filename> <filename>\n", progname) ;
|
||||
printf (" Compare the PCM data of two sound files.\n\n") ;
|
||||
} /* print_usage */
|
||||
exit (0) ;
|
||||
} /* usage_exit */
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
progname = strrchr (argv [0], '/') ;
|
||||
progname = progname ? progname + 1 : argv [0] ;
|
||||
progname = program_name (argv [0]) ;
|
||||
|
||||
if (argc != 3)
|
||||
{ print_usage () ;
|
||||
{ usage_exit () ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
@ -151,7 +157,7 @@ main (int argc, char *argv [])
|
||||
|
||||
if (strcmp (filename1, filename2) == 0)
|
||||
{ printf ("Error : Input filenames are the same.\n\n") ;
|
||||
print_usage () ;
|
||||
usage_exit () ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
|
169
libs/libsndfile/programs/sndfile-concat.c
Normal file
169
libs/libsndfile/programs/sndfile-concat.c
Normal file
@ -0,0 +1,169 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the author nor the names of any contributors may be used
|
||||
** to endorse or promote products derived from this software without
|
||||
** specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#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 *progname)
|
||||
{
|
||||
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 *progname, *outfilename ;
|
||||
SNDFILE *outfile, **infiles ;
|
||||
SF_INFO sfinfo_out, sfinfo_in ;
|
||||
void (*func) (SNDFILE*, SNDFILE*, int) ;
|
||||
int k ;
|
||||
|
||||
progname = program_name (argv [0]) ;
|
||||
|
||||
if (argc < 4)
|
||||
usage_exit (progname) ;
|
||||
|
||||
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 */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2013 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
@ -45,93 +45,22 @@ 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) ;
|
||||
|
||||
static OUTPUT_FORMAT_MAP format_map [] =
|
||||
{
|
||||
{ "aif", 3, SF_FORMAT_AIFF },
|
||||
{ "wav", 0, SF_FORMAT_WAV },
|
||||
{ "au", 0, SF_FORMAT_AU },
|
||||
{ "caf", 0, SF_FORMAT_CAF },
|
||||
{ "flac", 0, SF_FORMAT_FLAC },
|
||||
{ "snd", 0, SF_FORMAT_AU },
|
||||
{ "svx", 0, SF_FORMAT_SVX },
|
||||
{ "paf", 0, SF_ENDIAN_BIG | SF_FORMAT_PAF },
|
||||
{ "fap", 0, SF_ENDIAN_LITTLE | SF_FORMAT_PAF },
|
||||
{ "gsm", 0, SF_FORMAT_RAW },
|
||||
{ "nist", 0, SF_FORMAT_NIST },
|
||||
{ "htk", 0, SF_FORMAT_HTK },
|
||||
{ "ircam", 0, SF_FORMAT_IRCAM },
|
||||
{ "sf", 0, SF_FORMAT_IRCAM },
|
||||
{ "voc", 0, SF_FORMAT_VOC },
|
||||
{ "w64", 0, SF_FORMAT_W64 },
|
||||
{ "raw", 0, SF_FORMAT_RAW },
|
||||
{ "mat4", 0, SF_FORMAT_MAT4 },
|
||||
{ "mat5", 0, SF_FORMAT_MAT5 },
|
||||
{ "mat", 0, SF_FORMAT_MAT4 },
|
||||
{ "pvf", 0, SF_FORMAT_PVF },
|
||||
{ "sds", 0, SF_FORMAT_SDS },
|
||||
{ "sd2", 0, SF_FORMAT_SD2 },
|
||||
{ "vox", 0, SF_FORMAT_RAW },
|
||||
{ "xi", 0, SF_FORMAT_XI },
|
||||
{ "wve", 0, SF_FORMAT_WVE },
|
||||
{ "oga", 0, SF_FORMAT_OGG },
|
||||
{ "mpc", 0, SF_FORMAT_MPC2K },
|
||||
{ "rf64", 0, SF_FORMAT_RF64 },
|
||||
} ; /* format_map */
|
||||
|
||||
static int
|
||||
guess_output_file_type (char *str, int format)
|
||||
{ char buffer [16], *cptr ;
|
||||
int k ;
|
||||
|
||||
format &= SF_FORMAT_SUBMASK ;
|
||||
|
||||
if ((cptr = strrchr (str, '.')) == NULL)
|
||||
return 0 ;
|
||||
|
||||
strncpy (buffer, cptr + 1, 15) ;
|
||||
buffer [15] = 0 ;
|
||||
|
||||
for (k = 0 ; buffer [k] ; k++)
|
||||
buffer [k] = tolower ((buffer [k])) ;
|
||||
|
||||
if (strcmp (buffer, "gsm") == 0)
|
||||
return SF_FORMAT_RAW | SF_FORMAT_GSM610 ;
|
||||
|
||||
if (strcmp (buffer, "vox") == 0)
|
||||
return SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM ;
|
||||
|
||||
for (k = 0 ; k < (int) (sizeof (format_map) / sizeof (format_map [0])) ; k++)
|
||||
{ if (format_map [k].len > 0 && strncmp (buffer, format_map [k].ext, format_map [k].len) == 0)
|
||||
return format_map [k].format | format ;
|
||||
else if (strcmp (buffer, format_map [k].ext) == 0)
|
||||
return format_map [k].format | format ;
|
||||
} ;
|
||||
|
||||
return 0 ;
|
||||
} /* guess_output_file_type */
|
||||
|
||||
static void copy_metadata (SNDFILE *outfile, SNDFILE *infile, int channels) ;
|
||||
|
||||
static void
|
||||
print_usage (char *progname)
|
||||
{ SF_FORMAT_INFO info ;
|
||||
|
||||
int k ;
|
||||
|
||||
usage_exit (const char *progname)
|
||||
{
|
||||
printf ("\nUsage : %s [options] [encoding] <input file> <output file>\n", progname) ;
|
||||
puts ("\n"
|
||||
" where [option] may be:\n\n"
|
||||
" -override-sample-rate=X : force sample rate of input to X\n\n"
|
||||
" -override-sample-rate=X : force sample rate of input to X\n"
|
||||
" -endian=little : force output file to little endian data\n"
|
||||
" -endian=big : force output file to big endian data\n"
|
||||
" -endian=cpu : force output file same endian-ness as the CPU\n"
|
||||
" -normalize : normalize the data in the output file\n"
|
||||
) ;
|
||||
|
||||
puts ("\n"
|
||||
puts (
|
||||
" where [encoding] may be one of the following:\n\n"
|
||||
" -pcms8 : force the output to signed 8 bit pcm\n"
|
||||
" -pcmu8 : force the output to unsigned 8 bit pcm\n"
|
||||
@ -143,6 +72,10 @@ print_usage (char *progname)
|
||||
puts (
|
||||
" -ulaw : force the output ULAW\n"
|
||||
" -alaw : force the output ALAW\n"
|
||||
" -alac16 : force the output 16 bit ALAC (CAF only)\n"
|
||||
" -alac20 : force the output 20 bit ALAC (CAF only)\n"
|
||||
" -alac24 : force the output 24 bit ALAC (CAF only)\n"
|
||||
" -alac32 : force the output 32 bit ALAC (CAF only)\n"
|
||||
" -ima-adpcm : force the output to IMA ADPCM (WAV only)\n"
|
||||
" -ms-adpcm : force the output to MS ADPCM (WAV only)\n"
|
||||
" -gsm610 : force the GSM6.10 (WAV only)\n"
|
||||
@ -152,33 +85,57 @@ print_usage (char *progname)
|
||||
" -vorbis : force the output to Vorbis (OGG only)\n"
|
||||
) ;
|
||||
|
||||
puts (
|
||||
" If no encoding is specified, the program will try to use the encoding\n"
|
||||
" of the input file in the output file. This will not always work as\n"
|
||||
" most container formats (eg WAV, AIFF etc) only support a small subset\n"
|
||||
" of codec formats (eg 16 bit PCM, a-law, Vorbis etc).\n"
|
||||
) ;
|
||||
|
||||
puts (
|
||||
" The format of the output file is determined by the file extension of the\n"
|
||||
" output file name. The following extensions are currently understood:\n"
|
||||
) ;
|
||||
|
||||
for (k = 0 ; k < (int) (sizeof (format_map) / sizeof (format_map [0])) ; k++)
|
||||
{ info.format = format_map [k].format ;
|
||||
sf_command (NULL, SFC_GET_FORMAT_INFO, &info, sizeof (info)) ;
|
||||
printf (" %-10s : %s\n", format_map [k].ext, info.name) ;
|
||||
} ;
|
||||
sfe_dump_format_map () ;
|
||||
|
||||
puts ("") ;
|
||||
} /* print_usage */
|
||||
exit (0) ;
|
||||
} /* usage_exit */
|
||||
|
||||
static void
|
||||
report_format_error_exit (const char * argv0, SF_INFO * sfinfo)
|
||||
{ int old_format = sfinfo->format ;
|
||||
int endian = sfinfo->format & SF_FORMAT_ENDMASK ;
|
||||
|
||||
sfinfo->format = old_format & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ;
|
||||
|
||||
if (endian && sf_format_check (sfinfo))
|
||||
{ printf ("Error : output file format does not support %s endian-ness.\n", sfe_endian_name (endian)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
printf ("\n"
|
||||
"Error : output file format is invalid.\n"
|
||||
"The '%s' container does not support '%s' codec data.\n"
|
||||
"Run '%s --help' for clues.\n\n",
|
||||
sfe_container_name (sfinfo->format), sfe_codec_name (sfinfo->format), program_name (argv0)) ;
|
||||
exit (1) ;
|
||||
} /* report_format_error_exit */
|
||||
|
||||
int
|
||||
main (int argc, char * argv [])
|
||||
{ char *progname, *infilename, *outfilename ;
|
||||
SNDFILE *infile = NULL, *outfile = NULL ;
|
||||
SF_INFO sfinfo ;
|
||||
{ const char *progname, *infilename, *outfilename ;
|
||||
SNDFILE *infile = NULL, *outfile = NULL ;
|
||||
SF_INFO sfinfo ;
|
||||
int k, outfilemajor, outfileminor = 0, infileminor ;
|
||||
int override_sample_rate = 0 ; /* assume no sample rate override. */
|
||||
int endian = SF_ENDIAN_FILE, normalize = SF_FALSE ;
|
||||
|
||||
progname = strrchr (argv [0], '/') ;
|
||||
progname = progname ? progname + 1 : argv [0] ;
|
||||
progname = program_name (argv [0]) ;
|
||||
|
||||
if (argc < 3 || argc > 5)
|
||||
{ print_usage (progname) ;
|
||||
{ usage_exit (progname) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
@ -187,19 +144,19 @@ main (int argc, char * argv [])
|
||||
|
||||
if (strcmp (infilename, outfilename) == 0)
|
||||
{ printf ("Error : Input and output filenames are the same.\n\n") ;
|
||||
print_usage (progname) ;
|
||||
usage_exit (progname) ;
|
||||
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) ;
|
||||
usage_exit (progname) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if (outfilename [0] == '-')
|
||||
{ printf ("Error : Output filename (%s) looks like an option.\n\n", outfilename) ;
|
||||
print_usage (progname) ;
|
||||
usage_exit (progname) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
@ -236,6 +193,22 @@ main (int argc, char * argv [])
|
||||
{ outfileminor = SF_FORMAT_ALAW ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-alac16"))
|
||||
{ outfileminor = SF_FORMAT_ALAC_16 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-alac20"))
|
||||
{ outfileminor = SF_FORMAT_ALAC_20 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-alac24"))
|
||||
{ outfileminor = SF_FORMAT_ALAC_24 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-alac32"))
|
||||
{ outfileminor = SF_FORMAT_ALAC_32 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-ima-adpcm"))
|
||||
{ outfileminor = SF_FORMAT_IMA_ADPCM ;
|
||||
continue ;
|
||||
@ -273,10 +246,37 @@ main (int argc, char * argv [])
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (! strcmp (argv [k], "-endian=little"))
|
||||
{ endian = SF_ENDIAN_LITTLE ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (! strcmp (argv [k], "-endian=big"))
|
||||
{ endian = SF_ENDIAN_BIG ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (! strcmp (argv [k], "-endian=cpu"))
|
||||
{ endian = SF_ENDIAN_CPU ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (! strcmp (argv [k], "-endian=file"))
|
||||
{ endian = SF_ENDIAN_FILE ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (! strcmp (argv [k], "-normalize"))
|
||||
{ normalize = SF_TRUE ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
printf ("Error : Not able to decode argunment '%s'.\n", argv [k]) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
if ((infile = sf_open (infilename, SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("Not able to open input file %s.\n", infilename) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
@ -289,7 +289,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 ;
|
||||
} ;
|
||||
@ -304,6 +304,8 @@ main (int argc, char * argv [])
|
||||
else
|
||||
sfinfo.format = outfilemajor | (sfinfo.format & SF_FORMAT_SUBMASK) ;
|
||||
|
||||
sfinfo.format |= endian ;
|
||||
|
||||
if ((sfinfo.format & SF_FORMAT_TYPEMASK) == SF_FORMAT_XI)
|
||||
switch (sfinfo.format & SF_FORMAT_SUBMASK)
|
||||
{ case SF_FORMAT_PCM_16 :
|
||||
@ -317,9 +319,7 @@ main (int argc, char * argv [])
|
||||
} ;
|
||||
|
||||
if (sf_format_check (&sfinfo) == 0)
|
||||
{ printf ("Error : output file format is invalid (0x%08X).\n", sfinfo.format) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
report_format_error_exit (argv [0], &sfinfo) ;
|
||||
|
||||
/* Open the output file. */
|
||||
if ((outfile = sf_open (outfilename, SFM_WRITE, &sfinfo)) == NULL)
|
||||
@ -328,12 +328,13 @@ main (int argc, char * argv [])
|
||||
} ;
|
||||
|
||||
/* Copy the metadata */
|
||||
copy_metadata (outfile, infile) ;
|
||||
copy_metadata (outfile, infile, sfinfo.channels) ;
|
||||
|
||||
if ((outfileminor == SF_FORMAT_DOUBLE) || (outfileminor == SF_FORMAT_FLOAT)
|
||||
if (normalize
|
||||
|| (outfileminor == SF_FORMAT_DOUBLE) || (outfileminor == SF_FORMAT_FLOAT)
|
||||
|| (infileminor == SF_FORMAT_DOUBLE) || (infileminor == SF_FORMAT_FLOAT)
|
||||
|| (infileminor == SF_FORMAT_VORBIS) || (outfileminor == SF_FORMAT_VORBIS))
|
||||
sfe_copy_data_fp (outfile, infile, sfinfo.channels) ;
|
||||
sfe_copy_data_fp (outfile, infile, sfinfo.channels, normalize) ;
|
||||
else
|
||||
sfe_copy_data_int (outfile, infile, sfinfo.channels) ;
|
||||
|
||||
@ -344,21 +345,28 @@ main (int argc, char * argv [])
|
||||
} /* main */
|
||||
|
||||
static void
|
||||
copy_metadata (SNDFILE *outfile, SNDFILE *infile)
|
||||
copy_metadata (SNDFILE *outfile, SNDFILE *infile, int channels)
|
||||
{ SF_INSTRUMENT inst ;
|
||||
SF_BROADCAST_INFO_2K binfo ;
|
||||
const char *str ;
|
||||
int k, err = 0 ;
|
||||
int k, chanmap [256] ;
|
||||
|
||||
for (k = SF_STR_FIRST ; k <= SF_STR_LAST ; k++)
|
||||
{ str = sf_get_string (infile, k) ;
|
||||
if (str != NULL)
|
||||
err = sf_set_string (outfile, k, str) ;
|
||||
sf_set_string (outfile, k, str) ;
|
||||
} ;
|
||||
|
||||
memset (&inst, 0, sizeof (inst)) ;
|
||||
memset (&binfo, 0, sizeof (binfo)) ;
|
||||
|
||||
if (channels < ARRAY_LEN (chanmap))
|
||||
{ size_t size = channels * sizeof (chanmap [0]) ;
|
||||
|
||||
if (sf_command (infile, SFC_GET_CHANNEL_MAP_INFO, chanmap, size) == SF_TRUE)
|
||||
sf_command (outfile, SFC_SET_CHANNEL_MAP_INFO, chanmap, size) ;
|
||||
} ;
|
||||
|
||||
if (sf_command (infile, SFC_GET_INSTRUMENT, &inst, sizeof (inst)) == SF_TRUE)
|
||||
sf_command (outfile, SFC_SET_INSTRUMENT, &inst, sizeof (inst)) ;
|
||||
|
||||
|
194
libs/libsndfile/programs/sndfile-deinterleave.c
Normal file
194
libs/libsndfile/programs/sndfile-deinterleave.c
Normal file
@ -0,0 +1,194 @@
|
||||
/*
|
||||
** Copyright (C) 2009-2011 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)
|
||||
{ if (argc != 1)
|
||||
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 mono files.\n"
|
||||
"\n"
|
||||
"If the input file is named 'a.wav', the output files will be named\n"
|
||||
"a_00.wav, a_01.wav and so on.\n"
|
||||
) ;
|
||||
printf ("Using %s.\n\n", sf_version_string ()) ;
|
||||
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 */
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2013 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
@ -45,15 +45,16 @@
|
||||
|
||||
#if (defined (WIN32) || defined (_WIN32))
|
||||
#include <windows.h>
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
static void print_version (void) ;
|
||||
static void print_usage (const char *progname) ;
|
||||
static void usage_exit (const char *progname) ;
|
||||
|
||||
static void info_dump (const char *filename) ;
|
||||
static int instrument_dump (const char *filename) ;
|
||||
static int broadcast_dump (const char *filename) ;
|
||||
static int chanmap_dump (const char *filename) ;
|
||||
static int cart_dump (const char *filename) ;
|
||||
static void total_dump (void) ;
|
||||
|
||||
static double total_seconds = 0.0 ;
|
||||
@ -65,16 +66,11 @@ main (int argc, char *argv [])
|
||||
print_version () ;
|
||||
|
||||
if (argc < 2 || strcmp (argv [1], "--help") == 0 || strcmp (argv [1], "-h") == 0)
|
||||
{ char *progname ;
|
||||
|
||||
progname = strrchr (argv [0], '/') ;
|
||||
progname = progname ? progname + 1 : argv [0] ;
|
||||
|
||||
print_usage (progname) ;
|
||||
{ usage_exit (program_name (argv [0])) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if (strcmp (argv [1], "-i") == 0)
|
||||
if (strcmp (argv [1], "--instrument") == 0)
|
||||
{ int error = 0 ;
|
||||
|
||||
for (k = 2 ; k < argc ; k++)
|
||||
@ -82,7 +78,7 @@ main (int argc, char *argv [])
|
||||
return error ;
|
||||
} ;
|
||||
|
||||
if (strcmp (argv [1], "-b") == 0)
|
||||
if (strcmp (argv [1], "--broadcast") == 0)
|
||||
{ int error = 0 ;
|
||||
|
||||
for (k = 2 ; k < argc ; k++)
|
||||
@ -90,6 +86,22 @@ main (int argc, char *argv [])
|
||||
return error ;
|
||||
} ;
|
||||
|
||||
if (strcmp (argv [1], "--channel-map") == 0)
|
||||
{ int error = 0 ;
|
||||
|
||||
for (k = 2 ; k < argc ; k++)
|
||||
error += chanmap_dump (argv [k]) ;
|
||||
return error ;
|
||||
} ;
|
||||
|
||||
if (strcmp (argv [1], "--cart") == 0)
|
||||
{ int error = 0 ;
|
||||
|
||||
for (k = 2 ; k < argc ; k++)
|
||||
error += cart_dump (argv [k]) ;
|
||||
return error ;
|
||||
} ;
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
info_dump (argv [k]) ;
|
||||
|
||||
@ -115,13 +127,17 @@ print_version (void)
|
||||
|
||||
|
||||
static void
|
||||
print_usage (const char *progname)
|
||||
usage_exit (const char *progname)
|
||||
{ printf ("Usage :\n %s <file> ...\n", progname) ;
|
||||
printf (" Prints out information about one or more sound files.\n\n") ;
|
||||
printf (" %s -i <file>\n", progname) ;
|
||||
printf (" %s --instrument <file>\n", progname) ;
|
||||
printf (" Prints out the instrument data for the given file.\n\n") ;
|
||||
printf (" %s -b <file>\n", progname) ;
|
||||
printf (" %s --broadcast <file>\n", progname) ;
|
||||
printf (" Prints out the broadcast WAV info for the given file.\n\n") ;
|
||||
printf (" %s --channel-map <file>\n", progname) ;
|
||||
printf (" Prints out the channel map for the given file.\n\n") ;
|
||||
printf (" %s --cart <file>\n", progname) ;
|
||||
printf (" Prints out the cart chunk WAV info for the given file.\n\n") ;
|
||||
#if (defined (_WIN32) || defined (WIN32))
|
||||
printf ("This is a Unix style command line application which\n"
|
||||
"should be run in a MSDOS box or Command Shell window.\n\n") ;
|
||||
@ -135,7 +151,8 @@ print_usage (const char *progname)
|
||||
*/
|
||||
Sleep (5 * 1000) ;
|
||||
#endif
|
||||
} /* print_usage */
|
||||
exit (0) ;
|
||||
} /* usage_exit */
|
||||
|
||||
/*==============================================================================
|
||||
** Dumping of sndfile info.
|
||||
@ -143,15 +160,6 @@ print_usage (const char *progname)
|
||||
|
||||
static double data [BUFFER_LEN] ;
|
||||
|
||||
static double
|
||||
get_signal_max (SNDFILE *file)
|
||||
{ double max ;
|
||||
|
||||
sf_command (file, SFC_CALC_SIGNAL_MAX, &max, sizeof (max)) ;
|
||||
|
||||
return max ;
|
||||
} /* get_signal_max */
|
||||
|
||||
static double
|
||||
calc_decibels (SF_INFO * sfinfo, double max)
|
||||
{ double decibels ;
|
||||
@ -226,8 +234,8 @@ generate_duration_str (SF_INFO *sfinfo)
|
||||
static void
|
||||
info_dump (const char *filename)
|
||||
{ static char strbuffer [BUFFER_LEN] ;
|
||||
SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
double signal_max, decibels ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
@ -248,7 +256,12 @@ info_dump (const char *filename)
|
||||
printf ("----------------------------------------\n") ;
|
||||
|
||||
printf ("Sample Rate : %d\n", sfinfo.samplerate) ;
|
||||
printf ("Frames : %" PRId64 "\n", sfinfo.frames) ;
|
||||
|
||||
if (sfinfo.frames == SF_COUNT_MAX)
|
||||
printf ("Frames : unknown\n") ;
|
||||
else
|
||||
printf ("Frames : %" PRId64 "\n", sfinfo.frames) ;
|
||||
|
||||
printf ("Channels : %d\n", sfinfo.channels) ;
|
||||
printf ("Format : 0x%08X\n", sfinfo.format) ;
|
||||
printf ("Sections : %d\n", sfinfo.sections) ;
|
||||
@ -257,7 +270,7 @@ info_dump (const char *filename)
|
||||
|
||||
if (sfinfo.frames < 100 * 1024 * 1024)
|
||||
{ /* Do not use sf_signal_max because it doesn't work for non-seekable files . */
|
||||
signal_max = get_signal_max (file) ;
|
||||
sf_command (file, SFC_CALC_SIGNAL_MAX, &signal_max, sizeof (signal_max)) ;
|
||||
decibels = calc_decibels (&sfinfo, signal_max) ;
|
||||
printf ("Signal Max : %g (%4.2f dB)\n", signal_max, decibels) ;
|
||||
} ;
|
||||
@ -286,8 +299,8 @@ str_of_type (int mode)
|
||||
|
||||
static int
|
||||
instrument_dump (const char *filename)
|
||||
{ SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
{ SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
SF_INSTRUMENT inst ;
|
||||
int got_inst, k ;
|
||||
|
||||
@ -325,8 +338,8 @@ instrument_dump (const char *filename)
|
||||
|
||||
static int
|
||||
broadcast_dump (const char *filename)
|
||||
{ SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
{ SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
SF_BROADCAST_INFO_2K bext ;
|
||||
double time_ref_sec ;
|
||||
int got_bext ;
|
||||
@ -379,6 +392,136 @@ broadcast_dump (const char *filename)
|
||||
return 0 ;
|
||||
} /* broadcast_dump */
|
||||
|
||||
static int
|
||||
chanmap_dump (const char *filename)
|
||||
{ SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
int * channel_map ;
|
||||
int got_chanmap, k ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("Error : Not able to open input file %s.\n", filename) ;
|
||||
fflush (stdout) ;
|
||||
memset (data, 0, sizeof (data)) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if ((channel_map = calloc (sfinfo.channels, sizeof (int))) == NULL)
|
||||
{ printf ("Error : malloc failed.\n\n") ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
got_chanmap = sf_command (file, SFC_GET_CHANNEL_MAP_INFO, channel_map, sfinfo.channels * sizeof (int)) ;
|
||||
sf_close (file) ;
|
||||
|
||||
if (got_chanmap == SF_FALSE)
|
||||
{ printf ("Error : File '%s' does not contain channel map information.\n\n", filename) ;
|
||||
free (channel_map) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
printf ("File : %s\n\n", filename) ;
|
||||
|
||||
puts (" Chan Position") ;
|
||||
for (k = 0 ; k < sfinfo.channels ; k ++)
|
||||
{ const char * name ;
|
||||
|
||||
#define CASE_NAME(x) case x : name = #x ; break ;
|
||||
switch (channel_map [k])
|
||||
{ CASE_NAME (SF_CHANNEL_MAP_INVALID) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_MONO) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_LEFT) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_RIGHT) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_CENTER) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_FRONT_LEFT) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_FRONT_RIGHT) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_FRONT_CENTER) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_REAR_CENTER) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_REAR_LEFT) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_REAR_RIGHT) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_LFE) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_SIDE_LEFT) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_SIDE_RIGHT) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_TOP_CENTER) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_TOP_FRONT_LEFT) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_TOP_FRONT_RIGHT) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_TOP_FRONT_CENTER) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_TOP_REAR_LEFT) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_TOP_REAR_RIGHT) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_TOP_REAR_CENTER) ;
|
||||
CASE_NAME (SF_CHANNEL_MAP_MAX) ;
|
||||
default : name = "default" ;
|
||||
break ;
|
||||
} ;
|
||||
|
||||
printf (" %3d %s\n", k, name) ;
|
||||
} ;
|
||||
|
||||
putchar ('\n') ;
|
||||
free (channel_map) ;
|
||||
|
||||
return 0 ;
|
||||
} /* chanmap_dump */
|
||||
|
||||
static int
|
||||
cart_dump (const char *filename)
|
||||
{ SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
SF_CART_INFO_VAR (1024) cart ;
|
||||
int got_cart, k ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
memset (&cart, 0, sizeof (cart)) ;
|
||||
|
||||
if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("Error : Not able to open input file %s.\n", filename) ;
|
||||
fflush (stdout) ;
|
||||
memset (data, 0, sizeof (data)) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
got_cart = sf_command (file, SFC_GET_CART_INFO, &cart, sizeof (cart)) ;
|
||||
sf_close (file) ;
|
||||
|
||||
if (got_cart == SF_FALSE)
|
||||
{ printf ("Error : File '%s' does not contain cart information.\n\n", filename) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
printf ("Version : %.*s\n", (int) sizeof (cart.version), cart.version) ;
|
||||
printf ("Title : %.*s\n", (int) sizeof (cart.title), cart.title) ;
|
||||
printf ("Artist : %.*s\n", (int) sizeof (cart.artist), cart.artist) ;
|
||||
printf ("Cut id : %.*s\n", (int) sizeof (cart.cut_id), cart.cut_id) ;
|
||||
printf ("Category : %.*s\n", (int) sizeof (cart.category), cart.category) ;
|
||||
printf ("Classification : %.*s\n", (int) sizeof (cart.classification), cart.classification) ;
|
||||
printf ("Out cue : %.*s\n", (int) sizeof (cart.out_cue), cart.out_cue) ;
|
||||
printf ("Start date : %.*s\n", (int) sizeof (cart.start_date), cart.start_date) ;
|
||||
printf ("Start time : %.*s\n", (int) sizeof (cart.start_time), cart.start_time) ;
|
||||
printf ("End date : %.*s\n", (int) sizeof (cart.end_date), cart.end_date) ;
|
||||
printf ("End time : %.*s\n", (int) sizeof (cart.end_time), cart.end_time) ;
|
||||
printf ("App id : %.*s\n", (int) sizeof (cart.producer_app_id), cart.producer_app_id) ;
|
||||
printf ("App version : %.*s\n", (int) sizeof (cart.producer_app_version), cart.producer_app_version) ;
|
||||
printf ("User defined : %.*s\n", (int) sizeof (cart.user_def), cart.user_def) ;
|
||||
printf ("Level ref. : %d\n", cart.level_reference) ;
|
||||
printf ("Post timers :\n") ;
|
||||
|
||||
for (k = 0 ; k < ARRAY_LEN (cart.post_timers) ; k++)
|
||||
if (cart.post_timers [k].usage [0])
|
||||
printf (" %d %.*s %d\n", k, (int) sizeof (cart.post_timers [k].usage), cart.post_timers [k].usage, cart.post_timers [k].value) ;
|
||||
|
||||
printf ("Reserved : %.*s\n", (int) sizeof (cart.reserved), cart.reserved) ;
|
||||
printf ("Url : %.*s\n", (int) sizeof (cart.url), cart.url) ;
|
||||
printf ("Tag text : %.*s\n", cart.tag_text_size, cart.tag_text) ;
|
||||
|
||||
return 0 ;
|
||||
} /* cart_dump */
|
||||
|
||||
static void
|
||||
total_dump (void)
|
||||
{ printf ("========================================\n") ;
|
||||
|
202
libs/libsndfile/programs/sndfile-interleave.c
Normal file
202
libs/libsndfile/programs/sndfile-interleave.c
Normal file
@ -0,0 +1,202 @@
|
||||
/*
|
||||
** Copyright (C) 2009-2011 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)
|
||||
{ if (argc > 1)
|
||||
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 - 3 > 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 or more mono files into a single multi-channel file.\n") ;
|
||||
printf ("Using %s.\n\n", sf_version_string ()) ;
|
||||
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,6 +1,6 @@
|
||||
/*
|
||||
** Copyright (C) 2008 George Blood Audio
|
||||
** Written by Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2008-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2008-2010 George Blood Audio
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
@ -58,8 +58,7 @@ main (int argc, char *argv [])
|
||||
int start ;
|
||||
|
||||
/* Store the program name. */
|
||||
progname = strrchr (argv [0], '/') ;
|
||||
progname = progname ? progname + 1 : argv [0] ;
|
||||
progname = program_name (argv [0]) ;
|
||||
|
||||
/* Check if we've been asked for help. */
|
||||
if (argc <= 2 || strcmp (argv [1], "--help") == 0 || strcmp (argv [1], "-h") == 0)
|
||||
@ -123,6 +122,7 @@ usage_exit (const char *progname, int exit_code)
|
||||
" --str-license Print the license metadata.\n"
|
||||
) ;
|
||||
|
||||
printf ("Using %s.\n\n", sf_version_string ()) ;
|
||||
exit (exit_code) ;
|
||||
} /* usage_exit */
|
||||
|
||||
@ -131,14 +131,14 @@ process_args (SNDFILE * file, const SF_BROADCAST_INFO_2K * binfo, int argc, char
|
||||
{ const char * str ;
|
||||
int k, do_all = 0 ;
|
||||
|
||||
#define HANDLE_BEXT_ARG(cmd,name,field) \
|
||||
#define HANDLE_BEXT_ARG(cmd, name, field) \
|
||||
if (do_all || strcmp (argv [k], cmd) == 0) \
|
||||
{ printf ("%-20s : %.*s\n", name, (int) sizeof (binfo->field), binfo->field) ; \
|
||||
if (! do_all) \
|
||||
continue ; \
|
||||
} ;
|
||||
|
||||
#define HANDLE_STR_ARG(cmd,name,id) \
|
||||
#define HANDLE_STR_ARG(cmd, name, id) \
|
||||
if (do_all || strcmp (argv [k], cmd) == 0) \
|
||||
{ str = sf_get_string (file, id) ; \
|
||||
printf ("%-20s : %s\n", name, str ? str : "") ; \
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Copyright (C) 2008 George Blood Audio
|
||||
** Written by Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2008-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2008-2010 George Blood Audio
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
@ -60,8 +60,7 @@ main (int argc, char *argv [])
|
||||
int k ;
|
||||
|
||||
/* Store the program name. */
|
||||
progname = strrchr (argv [0], '/') ;
|
||||
progname = progname ? progname + 1 : argv [0] ;
|
||||
progname = program_name (argv [0]) ;
|
||||
|
||||
/* Check if we've been asked for help. */
|
||||
if (argc < 3 || strcmp (argv [1], "--help") == 0 || strcmp (argv [1], "-h") == 0)
|
||||
@ -88,7 +87,7 @@ main (int argc, char *argv [])
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
#define HANDLE_BEXT_ARG(cmd,field) \
|
||||
#define HANDLE_BEXT_ARG(cmd, field) \
|
||||
if (strcmp (argv [k], cmd) == 0) \
|
||||
{ k ++ ; \
|
||||
if (k == argc) missing_param (argv [k - 1]) ; \
|
||||
@ -103,8 +102,9 @@ main (int argc, char *argv [])
|
||||
HANDLE_BEXT_ARG ("--bext-orig-date", origination_date) ;
|
||||
HANDLE_BEXT_ARG ("--bext-orig-time", origination_time) ;
|
||||
HANDLE_BEXT_ARG ("--bext-coding-hist", coding_history) ;
|
||||
HANDLE_BEXT_ARG ("--bext-time-ref", time_ref) ;
|
||||
|
||||
#define HANDLE_STR_ARG(cmd,field) \
|
||||
#define HANDLE_STR_ARG(cmd, field) \
|
||||
if (strcmp (argv [k], cmd) == 0) \
|
||||
{ k ++ ; \
|
||||
if (k == argc) missing_param (argv [k - 1]) ; \
|
||||
@ -112,6 +112,7 @@ main (int argc, char *argv [])
|
||||
continue ; \
|
||||
} ;
|
||||
|
||||
HANDLE_STR_ARG ("--str-comment", comment) ;
|
||||
HANDLE_STR_ARG ("--str-title", title) ;
|
||||
HANDLE_STR_ARG ("--str-copyright", copyright) ;
|
||||
HANDLE_STR_ARG ("--str-artist", artist) ;
|
||||
@ -206,8 +207,10 @@ usage_exit (const char *progname, int exit_code)
|
||||
" --bext-umid Set the 'bext' UMID.\n"
|
||||
" --bext-orig-date Set the 'bext' origination date.\n"
|
||||
" --bext-orig-time Set the 'bext' origination time.\n"
|
||||
" --bext-coding-hist Set the 'bext' coding history\n"
|
||||
" --bext-coding-hist Set the 'bext' coding history.\n"
|
||||
" --bext-time-raf Set the 'bext' Time ref.\n"
|
||||
"\n"
|
||||
" --str-comment Set the metadata comment.\n"
|
||||
" --str-title Set the metadata title.\n"
|
||||
" --str-copyright Set the metadata copyright.\n"
|
||||
" --str-artist Set the metadata artist.\n"
|
||||
@ -231,6 +234,7 @@ usage_exit (const char *progname, int exit_code)
|
||||
"exit with an appropriate error message.\n"
|
||||
) ;
|
||||
|
||||
printf ("Using %s.\n\n", sf_version_string ()) ;
|
||||
exit (exit_code) ;
|
||||
} /* usage_exit */
|
||||
|
||||
@ -250,7 +254,7 @@ has_bext_fields_set (const METADATA_INFO * info)
|
||||
if (info->description || info->originator || info->originator_reference)
|
||||
return 1 ;
|
||||
|
||||
if (info->origination_date || info->origination_time || info->umid || info->coding_history)
|
||||
if (info->origination_date || info->origination_time || info->umid || info->coding_history || info->time_ref)
|
||||
return 1 ;
|
||||
|
||||
return 0 ;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2013 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
@ -41,6 +41,10 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#if HAVE_ALSA_ASOUNDLIB_H
|
||||
#define ALSA_PCM_NEW_HW_PARAMS_API
|
||||
#define ALSA_PCM_NEW_SW_PARAMS_API
|
||||
@ -48,14 +52,28 @@
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#if defined (__linux__)
|
||||
#if defined (__ANDROID__)
|
||||
|
||||
#elif defined (__linux__) || defined (__FreeBSD_kernel__) || defined (__FreeBSD__)
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/soundcard.h>
|
||||
|
||||
#elif (defined (__MACH__) && defined (__APPLE__))
|
||||
#include <Carbon.h>
|
||||
#include <CoreAudio/AudioHardware.h>
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <Availability.h>
|
||||
|
||||
#if (OSX_DARWIN_VERSION > 11)
|
||||
/* Includes go here. */
|
||||
#elif (OSX_DARWIN_VERSION == 11)
|
||||
#include <AudioToolbox/AudioToolbox.h>
|
||||
#elif (OSX_DARWIN_VERSION > 0 && OSX_DARWIN_VERSION <= 10)
|
||||
#include <Carbon.h>
|
||||
#include <CoreAudio/AudioHardware.h>
|
||||
#endif
|
||||
|
||||
#elif defined (HAVE_SNDIO_H)
|
||||
#include <sndio.h>
|
||||
|
||||
#elif (defined (sun) && defined (unix))
|
||||
#include <fcntl.h>
|
||||
@ -68,8 +86,6 @@
|
||||
|
||||
#endif
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#define SIGNED_SIZEOF(x) ((int) sizeof (x))
|
||||
#define BUFFER_LEN (2048)
|
||||
|
||||
@ -348,12 +364,12 @@ alsa_write_float (snd_pcm_t *alsa_dev, float *data, int frames, int channels)
|
||||
** Linux/OSS functions for playing a sound.
|
||||
*/
|
||||
|
||||
#if defined (__linux__)
|
||||
#if !defined (__ANDROID__) && (defined (__linux__) || defined (__FreeBSD_kernel__) || defined (__FreeBSD__))
|
||||
|
||||
static int linux_open_dsp_device (int channels, int srate) ;
|
||||
static int opensoundsys_open_device (int channels, int srate) ;
|
||||
|
||||
static void
|
||||
linux_play (int argc, char *argv [])
|
||||
static int
|
||||
opensoundsys_play (int argc, char *argv [])
|
||||
{ static short buffer [BUFFER_LEN] ;
|
||||
SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
@ -373,7 +389,7 @@ linux_play (int argc, char *argv [])
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
audio_device = linux_open_dsp_device (sfinfo.channels, sfinfo.samplerate) ;
|
||||
audio_device = opensoundsys_open_device (sfinfo.channels, sfinfo.samplerate) ;
|
||||
|
||||
subformat = sfinfo.format & SF_FORMAT_SUBMASK ;
|
||||
|
||||
@ -410,54 +426,54 @@ linux_play (int argc, char *argv [])
|
||||
sf_close (sndfile) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* linux_play */
|
||||
return writecount ;
|
||||
} /* opensoundsys_play */
|
||||
|
||||
static int
|
||||
linux_open_dsp_device (int channels, int srate)
|
||||
opensoundsys_open_device (int channels, int srate)
|
||||
{ int fd, stereo, fmt ;
|
||||
|
||||
if ((fd = open ("/dev/dsp", O_WRONLY, 0)) == -1 &&
|
||||
(fd = open ("/dev/sound/dsp", O_WRONLY, 0)) == -1)
|
||||
{ perror ("linux_open_dsp_device : open ") ;
|
||||
{ perror ("opensoundsys_open_device : open ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
stereo = 0 ;
|
||||
if (ioctl (fd, SNDCTL_DSP_STEREO, &stereo) == -1)
|
||||
{ /* Fatal error */
|
||||
perror ("linux_open_dsp_device : stereo ") ;
|
||||
perror ("opensoundsys_open_device : stereo ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (ioctl (fd, SNDCTL_DSP_RESET, 0))
|
||||
{ perror ("linux_open_dsp_device : reset ") ;
|
||||
{ perror ("opensoundsys_open_device : reset ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
fmt = CPU_IS_BIG_ENDIAN ? AFMT_S16_BE : AFMT_S16_LE ;
|
||||
if (ioctl (fd, SNDCTL_DSP_SETFMT, &fmt) != 0)
|
||||
{ perror ("linux_open_dsp_device : set format ") ;
|
||||
{ perror ("opensoundsys_open_device : set format ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
} ;
|
||||
|
||||
if (ioctl (fd, SNDCTL_DSP_CHANNELS, &channels) != 0)
|
||||
{ perror ("linux_open_dsp_device : channels ") ;
|
||||
{ perror ("opensoundsys_open_device : channels ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (ioctl (fd, SNDCTL_DSP_SPEED, &srate) != 0)
|
||||
{ perror ("linux_open_dsp_device : sample rate ") ;
|
||||
{ perror ("opensoundsys_open_device : sample rate ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (ioctl (fd, SNDCTL_DSP_SYNC, 0) != 0)
|
||||
{ perror ("linux_open_dsp_device : sync ") ;
|
||||
{ perror ("opensoundsys_open_device : sync ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
return fd ;
|
||||
} /* linux_open_dsp_device */
|
||||
} /* opensoundsys_open_device */
|
||||
|
||||
#endif /* __linux__ */
|
||||
|
||||
@ -465,7 +481,174 @@ linux_open_dsp_device (int channels, int srate)
|
||||
** Mac OS X functions for playing a sound.
|
||||
*/
|
||||
|
||||
#if (defined (__MACH__) && defined (__APPLE__)) /* MacOSX */
|
||||
#if (OSX_DARWIN_VERSION > 11)
|
||||
/* MacOSX 10.8 use a new Audio API. Someone needs to write some code for it. */
|
||||
#endif /* OSX_DARWIN_VERSION > 11 */
|
||||
|
||||
#if (OSX_DARWIN_VERSION == 11)
|
||||
/* MacOSX 10.7 use AudioQueue API */
|
||||
|
||||
#define kBytesPerAudioBuffer (1024 * 8)
|
||||
#define kNumberOfAudioBuffers 4
|
||||
|
||||
typedef struct
|
||||
{ AudioStreamBasicDescription format ;
|
||||
|
||||
AudioQueueRef queue ;
|
||||
AudioQueueBufferRef queueBuffer [kNumberOfAudioBuffers] ;
|
||||
|
||||
UInt32 buf_size ;
|
||||
|
||||
SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
|
||||
int done_playing ;
|
||||
} MacOSXAudioData ;
|
||||
|
||||
|
||||
static void
|
||||
macosx_fill_buffer (MacOSXAudioData *audio_data, AudioQueueBufferRef audio_buffer)
|
||||
{ int size, sample_count, read_count ;
|
||||
short *buffer ;
|
||||
|
||||
size = audio_buffer->mAudioDataBytesCapacity ;
|
||||
sample_count = size / sizeof (short) ;
|
||||
|
||||
buffer = (short*) audio_buffer->mAudioData ;
|
||||
|
||||
read_count = sf_read_short (audio_data->sndfile, buffer, sample_count) ;
|
||||
|
||||
if (read_count > 0)
|
||||
{ audio_buffer->mAudioDataByteSize = read_count * sizeof (short) ;
|
||||
AudioQueueEnqueueBuffer (audio_data->queue, audio_buffer, 0, NULL) ;
|
||||
}
|
||||
else
|
||||
AudioQueueStop (audio_data->queue, false) ;
|
||||
|
||||
} /* macosx_fill_buffer */
|
||||
|
||||
|
||||
static void
|
||||
macosx_audio_out_callback (void *user_data, AudioQueueRef audio_queue, AudioQueueBufferRef audio_buffer)
|
||||
{ MacOSXAudioData *audio_data = (MacOSXAudioData *) user_data ;
|
||||
|
||||
if (audio_data->queue == audio_queue)
|
||||
macosx_fill_buffer (audio_data, audio_buffer) ;
|
||||
|
||||
} /* macosx_audio_out_callback */
|
||||
|
||||
|
||||
static void
|
||||
macosx_audio_out_property_callback (void *user_data, AudioQueueRef audio_queue, AudioQueuePropertyID prop)
|
||||
{ MacOSXAudioData *audio_data = (MacOSXAudioData *) user_data ;
|
||||
|
||||
if (prop == kAudioQueueProperty_IsRunning)
|
||||
{ UInt32 is_running = 0 ;
|
||||
UInt32 is_running_size = sizeof (is_running) ;
|
||||
|
||||
AudioQueueGetProperty (audio_queue, kAudioQueueProperty_IsRunning, &is_running, &is_running_size) ;
|
||||
|
||||
if (!is_running)
|
||||
{ audio_data->done_playing = SF_TRUE ;
|
||||
CFRunLoopStop (CFRunLoopGetCurrent ()) ;
|
||||
} ;
|
||||
} ;
|
||||
} /* macosx_audio_out_property_callback */
|
||||
|
||||
|
||||
|
||||
static void
|
||||
macosx_play (int argc, char *argv [])
|
||||
{ MacOSXAudioData audio_data ;
|
||||
OSStatus err ;
|
||||
int i ;
|
||||
int k ;
|
||||
|
||||
memset (&audio_data, 0x55, sizeof (audio_data)) ;
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
{ memset (&(audio_data.sfinfo), 0, sizeof (audio_data.sfinfo)) ;
|
||||
|
||||
printf ("Playing %s\n", argv [k]) ;
|
||||
if (! (audio_data.sndfile = sf_open (argv [k], SFM_READ, &(audio_data.sfinfo))))
|
||||
{ puts (sf_strerror (NULL)) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (audio_data.sfinfo.channels < 1 || audio_data.sfinfo.channels > 2)
|
||||
{ printf ("Error : channels = %d.\n", audio_data.sfinfo.channels) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
/* fill ASBD */
|
||||
audio_data.format.mSampleRate = audio_data.sfinfo.samplerate ;
|
||||
audio_data.format.mChannelsPerFrame = audio_data.sfinfo.channels ;
|
||||
audio_data.format.mFormatID = kAudioFormatLinearPCM ;
|
||||
audio_data.format.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked ;
|
||||
audio_data.format.mBytesPerPacket = audio_data.format.mChannelsPerFrame * 2 ;
|
||||
audio_data.format.mFramesPerPacket = 1 ;
|
||||
audio_data.format.mBytesPerFrame = audio_data.format.mBytesPerPacket ;
|
||||
audio_data.format.mBitsPerChannel = 16 ;
|
||||
audio_data.format.mReserved = 0 ;
|
||||
|
||||
/* create the queue */
|
||||
if ((err = AudioQueueNewOutput (&(audio_data.format), macosx_audio_out_callback, &audio_data,
|
||||
CFRunLoopGetCurrent (), kCFRunLoopCommonModes, 0, &(audio_data.queue))) != noErr)
|
||||
{ printf ("AudioQueueNewOutput failed\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
/* add property listener */
|
||||
if ((err = AudioQueueAddPropertyListener (audio_data.queue, kAudioQueueProperty_IsRunning, macosx_audio_out_property_callback, &audio_data)) != noErr)
|
||||
{ printf ("AudioQueueAddPropertyListener failed\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
/* create the buffers */
|
||||
for (i = 0 ; i < kNumberOfAudioBuffers ; i++)
|
||||
{ if ((err = AudioQueueAllocateBuffer (audio_data.queue, kBytesPerAudioBuffer, &audio_data.queueBuffer [i])) != noErr)
|
||||
{ printf ("AudioQueueAllocateBuffer failed\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
macosx_fill_buffer (&audio_data, audio_data.queueBuffer [i]) ;
|
||||
} ;
|
||||
|
||||
audio_data.done_playing = SF_FALSE ;
|
||||
|
||||
/* start queue */
|
||||
if ((err = AudioQueueStart (audio_data.queue, NULL)) != noErr)
|
||||
{ printf ("AudioQueueStart failed\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
while (audio_data.done_playing == SF_FALSE)
|
||||
CFRunLoopRun () ;
|
||||
|
||||
/* free the buffers */
|
||||
for (i = 0 ; i < kNumberOfAudioBuffers ; i++)
|
||||
{ if ((err = AudioQueueFreeBuffer (audio_data.queue, audio_data.queueBuffer [i])) != noErr)
|
||||
{ printf ("AudioQueueFreeBuffer failed\n") ;
|
||||
return ;
|
||||
} ;
|
||||
} ;
|
||||
|
||||
/* free the queue */
|
||||
if ((err = AudioQueueDispose (audio_data.queue, true)) != noErr)
|
||||
{ printf ("AudioQueueDispose failed\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
sf_close (audio_data.sndfile) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* macosx_play, AudioQueue implementation */
|
||||
|
||||
#endif /* OSX_DARWIN_VERSION == 11 */
|
||||
|
||||
#if (OSX_DARWIN_VERSION > 0 && OSX_DARWIN_VERSION <= 10)
|
||||
/* MacOSX 10.6 or earlier, use Carbon and AudioHardware API */
|
||||
|
||||
typedef struct
|
||||
{ AudioStreamBasicDescription format ;
|
||||
@ -564,7 +747,9 @@ macosx_play (int argc, char *argv [])
|
||||
|
||||
/* Base setup completed. Now play files. */
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
{ printf ("Playing %s\n", argv [k]) ;
|
||||
{ memset (&(audio_data.sfinfo), 0, sizeof (audio_data.sfinfo)) ;
|
||||
|
||||
printf ("Playing %s\n", argv [k]) ;
|
||||
if (! (audio_data.sndfile = sf_open (argv [k], SFM_READ, &(audio_data.sfinfo))))
|
||||
{ puts (sf_strerror (NULL)) ;
|
||||
continue ;
|
||||
@ -625,10 +810,9 @@ macosx_play (int argc, char *argv [])
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* macosx_play */
|
||||
|
||||
#endif /* MacOSX */
|
||||
} /* macosx_play, AudioHardware implementation */
|
||||
|
||||
#endif /* OSX_DARWIN_VERSION > 0 && OSX_DARWIN_VERSION <= 10 */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
** Win32 functions for playing a sound.
|
||||
@ -640,7 +824,7 @@ macosx_play (int argc, char *argv [])
|
||||
|
||||
#if (OS_IS_WIN32 == 1)
|
||||
|
||||
#define WIN32_BUFFER_LEN (1<<15)
|
||||
#define WIN32_BUFFER_LEN (1 << 15)
|
||||
|
||||
typedef struct
|
||||
{ HWAVEOUT hwave ;
|
||||
@ -696,8 +880,9 @@ win32_audio_out_callback (HWAVEOUT hwave, UINT msg, DWORD_PTR data, DWORD param1
|
||||
{ Win32_Audio_Data *audio_data ;
|
||||
|
||||
/* Prevent compiler warnings. */
|
||||
hwave = hwave ;
|
||||
param1 = param2 ;
|
||||
(void) hwave ;
|
||||
(void) param1 ;
|
||||
(void) param2 ;
|
||||
|
||||
if (data == 0)
|
||||
return ;
|
||||
@ -819,6 +1004,66 @@ win32_play (int argc, char *argv [])
|
||||
|
||||
#endif /* Win32 */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
** OpenBDS's sndio.
|
||||
*/
|
||||
|
||||
#if defined (HAVE_SNDIO_H)
|
||||
|
||||
static void
|
||||
sndio_play (int argc, char *argv [])
|
||||
{ struct sio_hdl *hdl ;
|
||||
struct sio_par par ;
|
||||
short buffer [BUFFER_LEN] ;
|
||||
SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
int k, readcount ;
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
{ printf ("Playing %s\n", argv [k]) ;
|
||||
if (! (sndfile = sf_open (argv [k], SFM_READ, &sfinfo)))
|
||||
{ puts (sf_strerror (NULL)) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (sfinfo.channels < 1 || sfinfo.channels > 2)
|
||||
{ printf ("Error : channels = %d.\n", sfinfo.channels) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if ((hdl = sio_open (NULL, SIO_PLAY, 0)) == NULL)
|
||||
{ fprintf (stderr, "open sndio device failed") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
sio_initpar (&par) ;
|
||||
par.rate = sfinfo.samplerate ;
|
||||
par.pchan = sfinfo.channels ;
|
||||
par.bits = 16 ;
|
||||
par.sig = 1 ;
|
||||
par.le = SIO_LE_NATIVE ;
|
||||
|
||||
if (! sio_setpar (hdl, &par) || ! sio_getpar (hdl, &par))
|
||||
{ fprintf (stderr, "set sndio params failed") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
if (! sio_start (hdl))
|
||||
{ fprintf (stderr, "sndio start failed") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
while ((readcount = sf_read_short (sndfile, buffer, BUFFER_LEN)))
|
||||
sio_write (hdl, buffer, readcount * sizeof (short)) ;
|
||||
|
||||
sio_close (hdl) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* sndio_play */
|
||||
|
||||
#endif /* sndio */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
** Solaris.
|
||||
*/
|
||||
@ -914,35 +1159,43 @@ main (int argc, char *argv [])
|
||||
{
|
||||
if (argc < 2)
|
||||
{
|
||||
printf ("\nUsage : %s <input sound file>\n\n", argv [0]) ;
|
||||
printf ("\nUsage : %s <input sound file>\n\n", program_name (argv [0])) ;
|
||||
printf (" Using %s.\n\n", sf_version_string ()) ;
|
||||
#if (OS_IS_WIN32 == 1)
|
||||
printf ("This is a Unix style command line application which\n"
|
||||
"should be run in a MSDOS box or Command Shell window.\n\n") ;
|
||||
printf ("Sleeping for 5 seconds before exiting.\n\n") ;
|
||||
|
||||
/* This is the officially blessed by microsoft way but I can't get
|
||||
** it to link.
|
||||
** Sleep (15) ;
|
||||
** Instead, use this:
|
||||
*/
|
||||
Sleep (5 * 1000) ;
|
||||
#endif
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
#if defined (__linux__)
|
||||
#if defined (__ANDROID__)
|
||||
puts ("*** Playing sound not yet supported on Android.") ;
|
||||
puts ("*** Please feel free to submit a patch.") ;
|
||||
return 1 ;
|
||||
#elif defined (__linux__)
|
||||
#if HAVE_ALSA_ASOUNDLIB_H
|
||||
if (access ("/proc/asound/cards", R_OK) == 0)
|
||||
alsa_play (argc, argv) ;
|
||||
else
|
||||
#endif
|
||||
linux_play (argc, argv) ;
|
||||
#elif (defined (__MACH__) && defined (__APPLE__))
|
||||
opensoundsys_play (argc, argv) ;
|
||||
#elif defined (__FreeBSD_kernel__) || defined (__FreeBSD__)
|
||||
opensoundsys_play (argc, argv) ;
|
||||
#elif (defined (__MACH__) && defined (__APPLE__) && OSX_DARWIN_VERSION <= 11)
|
||||
macosx_play (argc, argv) ;
|
||||
#elif defined HAVE_SNDIO_H
|
||||
sndio_play (argc, argv) ;
|
||||
#elif (defined (sun) && defined (unix))
|
||||
solaris_play (argc, argv) ;
|
||||
#elif (OS_IS_WIN32 == 1)
|
||||
win32_play (argc, argv) ;
|
||||
#elif (defined (__MACH__) && defined (__APPLE__) && OSX_DARWIN_VERSION > 11)
|
||||
printf ("OS X 10.8 and later have a new Audio API.\n") ;
|
||||
printf ("Someone needs to write code to use that API.\n") ;
|
||||
return 1 ;
|
||||
#elif defined (__BEOS__)
|
||||
printf ("This program cannot be compiled on BeOS.\n") ;
|
||||
printf ("Instead, compile the file sfplay_beos.cpp.\n") ;
|
||||
|
277
libs/libsndfile/programs/sndfile-salvage.c
Normal file
277
libs/libsndfile/programs/sndfile-salvage.c
Normal file
@ -0,0 +1,277 @@
|
||||
/*
|
||||
** Copyright (C) 2010-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the author nor the names of any contributors may be used
|
||||
** to endorse or promote products derived from this software without
|
||||
** specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define BUFFER_LEN (1 << 16)
|
||||
|
||||
#define NOT(x) (! (x))
|
||||
|
||||
|
||||
static void usage_exit (const char *progname) ;
|
||||
static void salvage_file (const char * broken_wav, const char * fixed_w64) ;
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
if (argc != 3)
|
||||
usage_exit (program_name (argv [0])) ;
|
||||
|
||||
salvage_file (argv [1], argv [2]) ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
/*==============================================================================
|
||||
*/
|
||||
|
||||
static void lseek_or_die (int fd, off_t offset, int whence) ;
|
||||
static sf_count_t get_file_length (int fd, const char * name) ;
|
||||
static sf_count_t find_data_offset (int fd, int format) ;
|
||||
static void copy_data (int fd, SNDFILE * sndfile, int readsize) ;
|
||||
|
||||
|
||||
static void
|
||||
usage_exit (const char *progname)
|
||||
{ printf ("Usage :\n\n %s <broken wav file> <fixed w64 file>\n\n", progname) ;
|
||||
puts ("Salvages the audio data from WAV files which are more than 4G in length.\n") ;
|
||||
printf ("Using %s.\n\n", sf_version_string ()) ;
|
||||
exit (0) ;
|
||||
} /* usage_exit */
|
||||
|
||||
static void
|
||||
salvage_file (const char * broken_wav, const char * fixed_w64)
|
||||
{ SNDFILE * sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
sf_count_t broken_len, data_offset ;
|
||||
int fd, read_size ;
|
||||
|
||||
if (strcmp (broken_wav, fixed_w64) == 0)
|
||||
{ printf ("Error : Input and output files must be different.\n\n") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if ((fd = open (broken_wav, O_RDONLY)) < 0)
|
||||
{ printf ("Error : Not able to open file '%s' : %s\n", broken_wav, strerror (errno)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
broken_len = get_file_length (fd, broken_wav) ;
|
||||
if (broken_len <= 0xffffffff)
|
||||
printf ("File is not greater than 4Gig but salvaging anyway.\n") ;
|
||||
|
||||
/* Grab the format info from the broken file. */
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
if ((sndfile = sf_open (broken_wav, SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("sf_open ('%s') failed : %s\n", broken_wav, sf_strerror (NULL)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
sf_close (sndfile) ;
|
||||
|
||||
data_offset = find_data_offset (fd, sfinfo.format & SF_FORMAT_TYPEMASK) ;
|
||||
|
||||
printf ("Offset to audio data : %" PRId64 "\n", data_offset) ;
|
||||
|
||||
switch (sfinfo.format & SF_FORMAT_TYPEMASK)
|
||||
{ case SF_FORMAT_WAV :
|
||||
case SF_FORMAT_WAVEX :
|
||||
sfinfo.format = SF_FORMAT_W64 | (sfinfo.format & SF_FORMAT_SUBMASK) ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
printf ("Don't currently support this file type.\n") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
switch (sfinfo.format & SF_FORMAT_SUBMASK)
|
||||
{ case SF_FORMAT_PCM_U8 :
|
||||
case SF_FORMAT_PCM_S8 :
|
||||
read_size = 1 ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_PCM_16 :
|
||||
read_size = 2 ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_PCM_24 :
|
||||
read_size = 3 ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_PCM_32 :
|
||||
case SF_FORMAT_FLOAT :
|
||||
read_size = 4 ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_DOUBLE :
|
||||
read_size = 8 ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
printf ("Sorry, don't currently support this file encoding type.\n") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
read_size *= sfinfo.channels ;
|
||||
|
||||
if ((sndfile = sf_open (fixed_w64, SFM_WRITE, &sfinfo)) == NULL)
|
||||
{ printf ("sf_open ('%s') failed : %s\n", broken_wav, sf_strerror (NULL)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
lseek_or_die (fd, data_offset, SEEK_SET) ;
|
||||
|
||||
copy_data (fd, sndfile, read_size) ;
|
||||
|
||||
sf_close (sndfile) ;
|
||||
|
||||
puts ("Done!") ;
|
||||
} /* salvage_file */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static void
|
||||
lseek_or_die (int fd, off_t offset, int whence)
|
||||
{
|
||||
if (lseek (fd, offset, whence) < 0)
|
||||
{ printf ("lseek failed : %s\n", strerror (errno)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* lseek_or_die */
|
||||
|
||||
|
||||
static sf_count_t
|
||||
get_file_length (int fd, const char * name)
|
||||
{ struct stat sbuf ;
|
||||
|
||||
if (sizeof (sbuf.st_size) != 8)
|
||||
{ puts ("Error : sizeof (sbuf.st_size) != 8. Was program compiled with\n"
|
||||
" 64 bit file offsets?\n") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (fstat (fd, &sbuf) != 0)
|
||||
{ printf ("Error : fstat ('%s') failed : %s\n", name, strerror (errno)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
return sbuf.st_size ;
|
||||
} /* get_file_length */
|
||||
|
||||
static sf_count_t
|
||||
find_data_offset (int fd, int format)
|
||||
{ char buffer [8192], *cptr ;
|
||||
const char * target = "XXXX" ;
|
||||
sf_count_t offset = -1, extra ;
|
||||
int rlen, slen ;
|
||||
|
||||
switch (format)
|
||||
{ case SF_FORMAT_WAV :
|
||||
case SF_FORMAT_WAVEX :
|
||||
target = "data" ;
|
||||
extra = 8 ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_AIFF :
|
||||
target = "SSND" ;
|
||||
extra = 16 ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
puts ("Error : Sorry, don't handle this input file format.\n") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
slen = strlen (target) ;
|
||||
|
||||
lseek_or_die (fd, 0, SEEK_SET) ;
|
||||
|
||||
printf ("Searching for '%s' maker.\n", target) ;
|
||||
|
||||
if ((rlen = read (fd, buffer, sizeof (buffer))) < 0)
|
||||
{ printf ("Error : failed read : %s\n", strerror (errno)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
cptr = memchr (buffer, target [0], rlen - slen) ;
|
||||
if (cptr && memcmp (cptr, target, slen) == 0)
|
||||
offset = cptr - buffer ;
|
||||
else
|
||||
{ printf ("Error : Could not find data offset.\n") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
return offset + extra ;
|
||||
} /* find_data_offset */
|
||||
|
||||
static void
|
||||
copy_data (int fd, SNDFILE * sndfile, int readsize)
|
||||
{ static char * buffer ;
|
||||
sf_count_t readlen, count ;
|
||||
int bufferlen, done = 0 ;
|
||||
|
||||
bufferlen = readsize * 1024 ;
|
||||
buffer = malloc (bufferlen) ;
|
||||
|
||||
while (NOT (done) && (readlen = read (fd, buffer, bufferlen)) >= 0)
|
||||
{ if (readlen < bufferlen)
|
||||
{ readlen -= readlen % readsize ;
|
||||
done = 1 ;
|
||||
} ;
|
||||
|
||||
if ((count = sf_write_raw (sndfile, buffer, readlen)) != readlen)
|
||||
{ printf ("Error : sf_write_raw returned %" PRId64 " : %s\n", count, sf_strerror (sndfile)) ;
|
||||
return ;
|
||||
} ;
|
||||
} ;
|
||||
|
||||
free (buffer) ;
|
||||
|
||||
return ;
|
||||
} /* copy_data */
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# Copyright (C) 2008 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
# Copyright (C) 2008-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
@ -176,7 +176,8 @@ test_post_mod (tests)
|
||||
|
||||
test_update ([ ("--str-artist", "Fox") ])
|
||||
|
||||
test_coding_history ()
|
||||
# This never worked.
|
||||
# test_coding_history ()
|
||||
|
||||
test_rewrite ()
|
||||
|
||||
|
@ -4,8 +4,9 @@ bin_PROGRAMS = sndfile-regtest
|
||||
|
||||
noinst_HEADERS = regtest.h
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/src $(SQLITE3_CFLAGS) $(OS_SPECIFIC_CFLAGS)
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/src $(SQLITE3_CFLAGS) $(OS_SPECIFIC_CFLAGS)
|
||||
|
||||
sndfile_regtest_SOURCES = sndfile-regtest.c database.c checksum.c
|
||||
sndfile_regtest_LDADD = $(top_builddir)/src/libsndfile.la $(SQLITE3_LIBS)
|
||||
|
||||
CLEANFILES = *~ *.exe
|
||||
|
108
libs/libsndfile/regtest/Readme.txt
Normal file
108
libs/libsndfile/regtest/Readme.txt
Normal file
@ -0,0 +1,108 @@
|
||||
sndfile-regtest
|
||||
===============
|
||||
|
||||
The 'sndfile-regtest' program is a regression test-suite for libsndile.
|
||||
|
||||
This program is intended to allow anyone who has an interest in the
|
||||
reliability and correctness of libsndfile to do their own regression
|
||||
testing. From the point of view of the libsndfile developers, this
|
||||
program now allows for distributed regression testing of libsndfile
|
||||
which will make libsndfile better.
|
||||
|
||||
|
||||
How Does it Work
|
||||
----------------
|
||||
Anyone who wishes to take part in the distributed regression testing of
|
||||
libsndfile can download the regression test program and install it.
|
||||
|
||||
Once installed the user can start collecting files and adding them to
|
||||
their own personal database. Then, as new versions of libsndfile come
|
||||
out, the user should test the new library version against their database
|
||||
of files (instructions below).
|
||||
|
||||
Any files which were successfully added to the database in the past but
|
||||
now fail the check with the new library version represent a regression.
|
||||
The user should then contact the libsndfile developers so that a copy
|
||||
of the test file can be made available to the developers.
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
The regression test program uses sqlite3 as the database engine. On
|
||||
Debian, the required packages are :
|
||||
|
||||
sqlite3
|
||||
libsqlite3-0
|
||||
libsqlite3-dev
|
||||
|
||||
but similar packages should be available on any other Linux style
|
||||
system.
|
||||
|
||||
The regression test currently only compiles under Unix-like systems.
|
||||
At some time in the future the regression test will distributed along
|
||||
with the libsndfile source code distribution.
|
||||
|
||||
|
||||
Organization of Files
|
||||
---------------------
|
||||
The regession test program keeps its database file in the directory it
|
||||
is run from. In addition, the database only contains information about
|
||||
the files, not the files themselves.
|
||||
|
||||
This means that database file should probably be kept in the same
|
||||
directory (or a directory above) the test files.
|
||||
|
||||
|
||||
Setting it Up for the First Time
|
||||
--------------------------------
|
||||
The sndfile-regtest program should be on your PATH. You can then cd into
|
||||
the directory where you intend to keep you test files and
|
||||
run the command:
|
||||
|
||||
sndfile-regtest --create-db
|
||||
|
||||
which creates a file named '.sndfile-regtest.db' in the current directory.
|
||||
|
||||
Files can then be added to the database using the command:
|
||||
|
||||
sndfile-regtest --add-file file1.wav
|
||||
|
||||
The --add-file option allows more than one file to be added at a time
|
||||
using:
|
||||
|
||||
sndfile-regtest --add-file file1.wav file2.aif .....
|
||||
|
||||
|
||||
Checking Files
|
||||
--------------
|
||||
One or more files that have already been added to the database can be
|
||||
checked using:
|
||||
|
||||
sndfile-regtest --check-file file1.wav file2.aif .....
|
||||
|
||||
It is also possible to check all files in the database using:
|
||||
|
||||
sndfile-regtest --check-all
|
||||
|
||||
|
||||
Running a Regression Test
|
||||
-------------------------
|
||||
Once you have a collection of files and a database it is possible to test
|
||||
new versions of libsndfile before you install them. If for instance you
|
||||
have just compiled a new version of libsndfile in the directory
|
||||
/usr/src/libsndfile-X.Y.Z, then you can use an existing sndfile-regtest
|
||||
binary with the new libsndfile using something like:
|
||||
|
||||
LD_PRELOAD=/usr/src/libsndfile-X.Y.Z/src/.libs/libsndfile.so.X.Y.Z \
|
||||
sndfile-regtest --check-all
|
||||
|
||||
|
||||
Reporting Regressions
|
||||
---------------------
|
||||
Any user who finds a file which was added to the regression database with
|
||||
an earlier version of libsndfile and then fails the check with a later
|
||||
version of the library should contact the author (erikd at mega dash nerd
|
||||
dot com). If possible place the file on a web server and email the author
|
||||
a link to it.
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2005-2009 Erik de Castro Lopo
|
||||
** Copyright (C) 2005-2011 Erik de Castro Lopo
|
||||
**
|
||||
** 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2005-2009 Erik de Castro Lopo
|
||||
** Copyright (C) 2005-2011 Erik de Castro Lopo
|
||||
**
|
||||
** 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
|
||||
@ -146,7 +146,7 @@ db_file_exists (REG_DB * db_handle, const char * filename)
|
||||
|
||||
db->count = 0 ;
|
||||
err = sqlite3_exec (db->sql, db->cmdbuf, (sqlite3_callback) count_callback, db, &errmsg) ;
|
||||
if (db->count == 1)
|
||||
if (err == 0 && db->count == 1)
|
||||
return 1 ;
|
||||
|
||||
return 0 ;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2005 Erik de Castro Lopo
|
||||
** Copyright (C) 2005-2011 Erik de Castro Lopo
|
||||
**
|
||||
** 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2005-2009 Erik de Castro Lopo
|
||||
** Copyright (C) 2005-2011 Erik de Castro Lopo
|
||||
**
|
||||
** 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
|
||||
|
@ -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}
|
||||
|
200
libs/libsndfile/src/ALAC/ALACAudioTypes.h
Normal file
200
libs/libsndfile/src/ALAC/ALACAudioTypes.h
Normal file
@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Copyright (c) 2011 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_START@
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
/*
|
||||
File: ALACAudioTypes.h
|
||||
*/
|
||||
|
||||
#ifndef ALACAUDIOTYPES_H
|
||||
#define ALACAUDIOTYPES_H
|
||||
|
||||
/* Force these Mac OS specific things to zero. */
|
||||
#define PRAGMA_STRUCT_ALIGN 0
|
||||
#define PRAGMA_STRUCT_PACKPUSH 0
|
||||
#define PRAGMA_STRUCT_PACK 0
|
||||
#define PRAGMA_ONCE 0
|
||||
#define PRAGMA_MARK 0
|
||||
|
||||
|
||||
#if PRAGMA_ONCE
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "sfendian.h"
|
||||
|
||||
#if CPU_IS_BIG_ENDIAN == 1
|
||||
#define TARGET_RT_BIG_ENDIAN 1
|
||||
#else
|
||||
#define TARGET_RT_BIG_ENDIAN 0
|
||||
#endif
|
||||
|
||||
#define kChannelAtomSize 12
|
||||
|
||||
enum
|
||||
{
|
||||
kALAC_UnimplementedError = -4,
|
||||
kALAC_FileNotFoundError = -43,
|
||||
kALAC_ParamError = -50,
|
||||
kALAC_MemFullError = -108,
|
||||
fALAC_FrameLengthError = -666,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
kALACFormatAppleLossless = MAKE_MARKER ('a', 'l', 'a', 'c'),
|
||||
kALACFormatLinearPCM = MAKE_MARKER ('l', 'p', 'c', 'm')
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
kALACMaxChannels = 8,
|
||||
kALACMaxEscapeHeaderBytes = 8,
|
||||
kALACMaxSearches = 16,
|
||||
kALACMaxCoefs = 16,
|
||||
kALACDefaultFramesPerPacket = 4096
|
||||
};
|
||||
|
||||
typedef uint32_t ALACChannelLayoutTag;
|
||||
|
||||
enum
|
||||
{
|
||||
kALACFormatFlagIsFloat = (1 << 0), // 0x1
|
||||
kALACFormatFlagIsBigEndian = (1 << 1), // 0x2
|
||||
kALACFormatFlagIsSignedInteger = (1 << 2), // 0x4
|
||||
kALACFormatFlagIsPacked = (1 << 3), // 0x8
|
||||
kALACFormatFlagIsAlignedHigh = (1 << 4), // 0x10
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
#if TARGET_RT_BIG_ENDIAN
|
||||
kALACFormatFlagsNativeEndian = kALACFormatFlagIsBigEndian
|
||||
#else
|
||||
kALACFormatFlagsNativeEndian = 0
|
||||
#endif
|
||||
};
|
||||
|
||||
// this is required to be an IEEE 64bit float
|
||||
typedef double alac_float64_t;
|
||||
|
||||
// These are the Channel Layout Tags used in the Channel Layout Info portion of the ALAC magic cookie
|
||||
enum
|
||||
{
|
||||
kALACChannelLayoutTag_Mono = (100<<16) | 1, // C
|
||||
kALACChannelLayoutTag_Stereo = (101<<16) | 2, // L R
|
||||
kALACChannelLayoutTag_MPEG_3_0_B = (113<<16) | 3, // C L R
|
||||
kALACChannelLayoutTag_MPEG_4_0_B = (116<<16) | 4, // C L R Cs
|
||||
kALACChannelLayoutTag_MPEG_5_0_D = (120<<16) | 5, // C L R Ls Rs
|
||||
kALACChannelLayoutTag_MPEG_5_1_D = (124<<16) | 6, // C L R Ls Rs LFE
|
||||
kALACChannelLayoutTag_AAC_6_1 = (142<<16) | 7, // C L R Ls Rs Cs LFE
|
||||
kALACChannelLayoutTag_MPEG_7_1_B = (127<<16) | 8 // C Lc Rc L R Ls Rs LFE (doc: IS-13818-7 MPEG2-AAC)
|
||||
};
|
||||
|
||||
// ALAC currently only utilizes these channels layouts. There is a one for one correspondance between a
|
||||
// given number of channels and one of these layout tags
|
||||
static const ALACChannelLayoutTag ALACChannelLayoutTags[kALACMaxChannels] =
|
||||
{
|
||||
kALACChannelLayoutTag_Mono, // C
|
||||
kALACChannelLayoutTag_Stereo, // L R
|
||||
kALACChannelLayoutTag_MPEG_3_0_B, // C L R
|
||||
kALACChannelLayoutTag_MPEG_4_0_B, // C L R Cs
|
||||
kALACChannelLayoutTag_MPEG_5_0_D, // C L R Ls Rs
|
||||
kALACChannelLayoutTag_MPEG_5_1_D, // C L R Ls Rs LFE
|
||||
kALACChannelLayoutTag_AAC_6_1, // C L R Ls Rs Cs LFE
|
||||
kALACChannelLayoutTag_MPEG_7_1_B // C Lc Rc L R Ls Rs LFE (doc: IS-13818-7 MPEG2-AAC)
|
||||
};
|
||||
|
||||
// AudioChannelLayout from CoreAudioTypes.h. We never need the AudioChannelDescription so we remove it
|
||||
struct ALACAudioChannelLayout
|
||||
{
|
||||
ALACChannelLayoutTag mChannelLayoutTag;
|
||||
uint32_t mChannelBitmap;
|
||||
uint32_t mNumberChannelDescriptions;
|
||||
};
|
||||
typedef struct ALACAudioChannelLayout ALACAudioChannelLayout;
|
||||
|
||||
struct AudioFormatDescription
|
||||
{
|
||||
alac_float64_t mSampleRate;
|
||||
uint32_t mFormatID;
|
||||
uint32_t mFormatFlags;
|
||||
uint32_t mBytesPerPacket;
|
||||
uint32_t mFramesPerPacket;
|
||||
uint32_t mBytesPerFrame;
|
||||
uint32_t mChannelsPerFrame;
|
||||
uint32_t mBitsPerChannel;
|
||||
uint32_t mReserved;
|
||||
};
|
||||
typedef struct AudioFormatDescription AudioFormatDescription;
|
||||
|
||||
/* Lossless Definitions */
|
||||
|
||||
enum
|
||||
{
|
||||
kALACCodecFormat = MAKE_MARKER ('a', 'l', 'a', 'c'),
|
||||
kALACVersion = 0,
|
||||
kALACCompatibleVersion = kALACVersion,
|
||||
kALACDefaultFrameSize = 4096
|
||||
};
|
||||
|
||||
// note: this struct is wrapped in an 'alac' atom in the sample description extension area
|
||||
// note: in QT movies, it will be further wrapped in a 'wave' atom surrounded by 'frma' and 'term' atoms
|
||||
typedef struct ALACSpecificConfig
|
||||
{
|
||||
uint32_t frameLength;
|
||||
uint8_t compatibleVersion;
|
||||
uint8_t bitDepth; // max 32
|
||||
uint8_t pb; // 0 <= pb <= 255
|
||||
uint8_t mb;
|
||||
uint8_t kb;
|
||||
uint8_t numChannels;
|
||||
uint16_t maxRun;
|
||||
uint32_t maxFrameBytes;
|
||||
uint32_t avgBitRate;
|
||||
uint32_t sampleRate;
|
||||
|
||||
} ALACSpecificConfig;
|
||||
|
||||
|
||||
// The AudioChannelLayout atom type is not exposed yet so define it here
|
||||
enum
|
||||
{
|
||||
AudioChannelLayoutAID = MAKE_MARKER ('c', 'h', 'a', 'n')
|
||||
};
|
||||
|
||||
#if PRAGMA_STRUCT_ALIGN
|
||||
#pragma options align=reset
|
||||
#elif PRAGMA_STRUCT_PACKPUSH
|
||||
#pragma pack(pop)
|
||||
#elif PRAGMA_STRUCT_PACK
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ALACAUDIOTYPES_H */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user