Code Monkey home page Code Monkey logo

libsndfile's Introduction

libsndfile

C/C++ CI

libsndfile is a C library for reading and writing files containing sampled audio data.

Authors

The libsndfile project was originally developed and maintained by Erik de Castro Lopo [email protected] aka @erikd. The project was developed on Github at https://github.com/erikd/libsndfile.

After the release of version 1.0.30, @erikd transferred the project to the libsndfile team, see AUTHORS for details.

Hacking

The canonical source code repository for libsndfile is at https://github.com/libsndfile/libsndfile.

You can grab the source code using:

git clone https://github.com/libsndfile/libsndfile.git

For building for Android see BuildingForAndroid.

There are currently two build systems: the traditional GNU autotool based one and modern CMake based build system. Use of the CMake build system is documented below.

Setting up a build environment for libsndfile on Debian or Ubuntu is as simple as:

sudo apt install autoconf autogen automake build-essential libasound2-dev \
  libflac-dev libogg-dev libtool libvorbis-dev libopus-dev libmp3lame-dev \
  libmpg123-dev pkg-config python

For other Linux distributions or any of the *BSDs, the setup should be similar although the package install tools and package names may be slightly different.

Similarly on Mac OS X, assuming brew is already installed:

brew install autoconf autogen automake flac libogg libtool libvorbis opus mpg123 pkg-config

Once the build environment has been set up, building and testing libsndfile is as simple as:

autoreconf -vif
./configure --enable-werror
make
make check

The CMake build system

Although Autotools is the primary and recommended build toolchain, CMake meta build generator is also available. The build process with CMake takes place in two stages. First, standard build files are created from configuration scripts. Then the platform's native build tools are used for the actual building. CMake can produce Microsoft Visual Studio project and solution files, Unix Makefiles, Xcode projects and many more.

Some IDE support CMake natively or with plugins, check you IDE documentation for details.

Requirements

  1. C99-compliant compiler toolchain (tested with GCC, Clang and Visual Studio 2015)
  2. CMake 3.1.3 or newer

There are some recommended packages to enable all features of libsndfile:

  1. Ogg, Vorbis and FLAC libraries and headers to enable these formats support
  2. ALSA development package under Linux to build sndfile-play utility
  3. Sndio development package under BSD to build sndfile-play utility

Building from command line

CMake can handle out-of-place builds, enabling several builds from the same source tree, and cross-compilation. The ability to build a directory tree outside the source tree is a key feature, ensuring that if a build directory is removed, the source files remain unaffected.

mkdir CMakeBuild
cd CMakeBuild

Then run cmake command with directory where CMakeLists.txt script is located as argument (relative paths are supported):

cmake ..

This command will configure and write build script or solution to CMakeBuild directory. CMake is smart enough to create Unix makefiles under Linux or Visual Studio solution if you have Visual Studio installed, but you can configure generator with -G command line parameter:

cmake .. -G"Unix Makefiles"

The build procedure depends on the selected generator. With "Unix Makefiles" you can type:

make & make install

With "Visual Studio" and some other generators you can open solution or project from CMakeBuild directory and build using IDE.

Finally, you can use unified command:

cmake --build .

CMake also provides Qt-based cross platform GUI, cmake-gui. Using it is trivial and does not require detailed explanations.

Configuring CMake

You can pass additional options with /D<parameter>=<value> when you run cmake command. Some useful system options:

  • CMAKE_C_FLAGS - additional C compiler flags
  • CMAKE_BUILD_TYPE - configuration type, DEBUG, RELEASE, RELWITHDEBINFO or MINSIZEREL. DEBUG is default
  • CMAKE_INSTALL_PREFIX - build install location, the same as --prefix option of configure script

Useful libsndfile options:

  • BUILD_SHARED_LIBS - build shared library (DLL under Windows) when ON, build static library otherwise. This option is OFF by default.

  • BUILD_PROGRAMS - build libsndfile's utilities from programs/ directory, ON by default.

  • BUILD_EXAMPLES - build examples, ON by default.

  • BUILD_TESTING - build tests. Then you can run tests with ctest command, ON by default. Setting BUILD_SHARED_LIBS to ON disables this option.

  • ENABLE_EXTERNAL_LIBS - enable Ogg, Vorbis, FLAC and Opus support. This option is available and set to ON if all dependency libraries were found.

  • ENABLE_MPEG - MP3 support. This option is available and set to ON if all dependency libraries were found.

  • ENABLE_BOW_DOCS - enable black-on-white documentation theme, OFF by default.

  • ENABLE_EXPERIMENTAL - enable experimental code. Don't use it if you are not sure. This option is OFF by default.

  • ENABLE_CPACK - enable CPack support. This option is ON by default.

  • ENABLE_PACKAGE_CONFIG - generate and install package config file.

  • INSTALL_PKGCONFIG_MODULE - generate and install pkg-config module.

  • INSTALL_MANPAGES - install man pages for programs. This option is ON by default

  • ENABLE_STATIC_RUNTIME - enable static runtime on Windows platform (MSVC and MinGW), OFF by default.

    Note: For MSVC compiler this option is deprecated for CMake >= 3.15, see policy CMP0091. Use CMAKE_MSVC_RUNTIME_LIBRARY option instead.

    Note: For MinGW toolchain this option is experimental. If you enabled it and then disabled again, you need to clear CMake cache (delete CMakeCache.txt).

  • ENABLE_COMPATIBLE_LIBSNDFILE_NAME - set DLL name to libsndfile-1.dll (canonical name) on Windows platform, sndfile.dll otherwise, OFF by default. Library name can be different depending on platform. The well known DLL name on Windows platform is libsndfile-1.dll, because the only way to build Windows library before was MinGW toolchain with Autotools. This name is native for MinGW ecosystem, Autotools constructs it using MinGW platform rules from sndfile target. But when you build with CMake using native Windows compiler, the name is sndfile.dll. This is name for native Windows platform, because Windows has no library naming rules. It is preferred because you can search library using package manager or CMake's find_library command on any platform using the same sndfile name.

  • ENABLE_SSE2 - add compiler flag to enable SSE2 if required, ON by default.

    This option is for X86 and GCC compatible compilers configurations only.

    If you compile for other SIMD set, e.g. AVX2, you may want to set ENABLE_SSE2 to OFF.

    Note: This option is not active for X64 configuration, because SSE2 is always available in this mode and all optimizations are enabled by default.

Deprecated options:

  • DISABLE_EXTERNAL_LIBS - disable Ogg, Vorbis and FLAC support. Replaced by ENABLE_EXTERNAL_LIBS
  • BUILD_STATIC_LIBS - build static library. Use BUILD_SHARED_LIBS instead

Linking from CMake projects

First you need to add FindOgg.cmake, FindVorbis.cmake, FindFLAC.cmake and FindOpus.cmake files to some directory inside your CMake project (usually cmake) and add it to CMAKE_MODULE_PATH:

project(SomeApplication)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

Now you can search libsndfile library from your CMakeLists.txt with this command:

find_package(SndFile)

SndFile_FOUND is set to ON when library is found.

If libsndfile dependency is critical, you can add REQUIRED to find_package:

find_package(SndFile REQUIRED)

With with option find_package will terminate configuration process if libsndfile is not found.

You can also add version check:

find_package(SndFile 1.0.29)

find_package will report error, if libsndfile version is < 1.0.29.

You can combine REQUIRED and version if you need.

To link libsndfile library use:

target_link_libraries(my_application PRIVATE SndFile::sndfile)

Notes for Windows users

System CRT library

First advice about Visual Studio system CRT libraries, it is system code linked as static or dynamic library to every C application.

You can find related option in Visual Studio project properties:

C/C++ -> Code Generation -> Runtime Library

Dynamic version of system CRT library is default and it means that end user needs to have the same runtime library installed on his system. Most likely it is so, but if it is not, the user will see this error message using libsndfile DLL:

"The program can't start because <crt-dll-name>.dll is missing from your computer. Try reinstalling the program to fix this problem. "

To avoid this, you may want to enable static CRT library linking. In this case the size of your DLL will increase slightly the size will increase slightly, but you can redistribute the libsndfile DLL without having to install the correct version of the system CRT library.

CMake project will use dynamic system CRT libraries by default, just like Visual Studio does. But you can change it using ENABLE_STATIC_RUNTIME or CMAKE_MSVC_RUNTIME_LIBRARY options.

Note: You cannot use both options at the same time, it will lead to a configuration error.

If you have CMake >= 3.15 you should use CMAKE_MSVC_RUNTIME_LIBRARY option.

This will enable static linking:

cmake .. -D"MultiThreaded$<$<CONFIG:Debug>:Debug>"

You can use libsndfile ENABLE_STATIC_RUNTIME option to to control CRT library linking for CMake project: OFF or unset (default) for dynamic, and ON for static linking:

cmake .. -DENABLE_STATIC_RUNTIME=ON

Note: This option is deprecated and may be removed in far future because we have standard option CMAKE_MSVC_RUNTIME_LIBRARY now.

Using Vcpkg package manager

Second advice is about Ogg, Vorbis FLAC and Opus support. Searching external libraries under Windows is a little bit tricky. The best way is to use Vcpkg.

Install Vcpkg and then add this parameter to cmake command line:

-DCMAKE_TOOLCHAIN_FILE=<path-to-vcpkg>/scripts/buildsystems/vcpkg.cmake

You also need to set VCPKG_TARGET_TRIPLET if you want to use static libraries:

-DVCPKG_TARGET_TRIPLET=x64-windows-static

Then you need to install static libogg, libvorbis, libflac, libopus, mpg123 and mp3lame Vcpkg packages.

After 1.1.0beta2 you don't need to install dependencies manually. Libsndfile now supports Vcpkg manifest mode and all dependencies are installed automatically.

However, you can turn off the manifest mode and return to the classic mode using the VCPKG_MANIFEST_MODE parameter from the command line:

-DVCPKG_MANIFEST_MODE=OFF

In classic mode, you need to install the required libraries manually:

vcpkg install libvorbis:x64-windows-static libflac:x64-windows-static
opus:x64-windows-static mp3lame:x86-windows-static mpg123:x86-windows-static
libvorbis:x86-windows-static libflac:x86-windows-static
opus:x86-windows-static mp3lame:x86-windows-static mpg123:x86-windows-static

Note: Use must use the same CRT library for external libraries and the libsndfile library itself. For *-static triplets Vcpkg uses static CRT.

Submitting Patches

See CONTRIBUTING.md for details.

libsndfile's People

Contributors

amstewart avatar arthurt avatar bobsayshilol avatar ccawley2011 avatar chirlu avatar cmeister2 avatar erikd avatar evpobr avatar fabiangreffrath avatar foolswood avatar ftzpetruska avatar ghabry avatar gvanem avatar hzeller avatar janstary avatar jfriesne avatar kiilerix avatar luzpaz avatar madebr avatar manxorist avatar marcelwaldvogel avatar martindelille avatar mossheim avatar mtolly avatar smivan avatar soapgentoo avatar tmatth avatar umlaeute avatar uniontech-lilinjie avatar zodf0055980 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libsndfile's Issues

impossible use with wingw-w64

The simple following code

#include "sndfile.h"

int main() {
    SNDFILE* f;
    f=sf_open(NULL, 0, NULL);
    return 0;
}

cross-compiled with Mingw-w64 fails with

Assertion failed!

Program: Z:\home\eroux\softs\transcriber-ag\buuug\test-snd.exe
File: sndfile.c, Line 312

Expression: sizeof (sf_count_t) == 8

abnormal program termination

The cause seems to be that Mingw-w64 defines off_t as 32-bit, while the assertion clearly wants it 64 bit. I believe libsndfile should :

  • spot the fact that off_t is 32 bits at configure time (which it does anyway) and raise an error if it's the case (instead of compiling something that will never work)
  • fix compilation for mingw-w64

I've encountered the problem under mxe environment, which is really helpful if you want to test. I'll also report this bug to them.

Text strings encoding

API documentation does not states on how to deal with non-ascii text in metadata strings such as title, author...

While Vorbis Comments (ogg, speex, flac) are utf-8, ID3v1 is latin1 and ID3v2 might be latin1, utf8, ucs or utf16-LE depending on a flag. I have no idea on which encoding uses metadata in other formats such as WAV or AIFF.

Anyway libsndfile should provide either:

  • text strings in a common universal text encoding such as utf-8, or
  • means to know the text encoding to deal with.

Could we asume the former? Is there any means for the later?

g722 support

Does libsnd support reading g722 samples from a file ?
If no, then is there any plan to support or
any other open source library which can read g722 files?

New ALAC Support isn't exposed through command.c

VERSION

libsndfile-1.0.26pre2 (supplied by ErikD)

PLATFORM

32-bit libsndfile on Windows 7 x64

DESCRIPTION

The new subformats for 'alac' are not added to command.c and thus are not exposed through sf_command

REPRO STEPS

    std::int32_t subFmtCount = 0;
    sf_command(NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &subFmtCount, sizeof(std::int32_t));

RESULT

subFmtCount becomes 21.

EXPECTED

SFC_GET_FORMAT_SUBTYPE_COUNT to return the appropriate number for the new subtypes
All new SubTypes to have appropriate description strings filled out via SFC_GET_FORMAT_SUBTYPE

Libsndfile cannot decode CAF ALAC files with 6 audio channels

Platform: OSX 10.6.8
Compiled With: gcc i686-apple-darwin10-gcc-4.2.1
Tested Version: Github Commit: 85aaeef

Issue is broken-out from Libsndfile Issue #8:

The attached files (below) have 5.1 channelization (i.e. 6 audio channels) but cannot be decoded via libsndfile.

Test files:
http://dl.dropbox.com/u/24880982/SEGFAULT/SEGFAULT.zip

Result:
Calls to sf_read_float result in an error.

Decoded files via OSX afconvert command:
http://dl.dropbox.com/u/24880982/libsndfile_issue_10.zip

ld: symbol(s) not found for architecture x86_64

When I try to build on MacOS 10.8.4,it turns out this error message.

cc1plus: warning: command line option "-Wmissing-declarations" is valid for C/ObjC but not for C++
CXXLD sndfilehandle
ld: warning: ignoring file ../src/.libs/libsndfile.dylib, file was built for unsupported file format ( 0xce 0xfa 0xed 0xfe 0x c 0x 0 0x 0 0x 0 0x 9 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): ../src/.libs/libsndfile.dylib
Undefined symbols for architecture x86_64:
"_sf_close", referenced from:
_main in sndfilehandle.o
"_sf_open", referenced from:
_main in sndfilehandle.o
"_sf_read_short", referenced from:
_main in sndfilehandle.o
"_sf_write_short", referenced from:
_main in sndfilehandle.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[1]: *** [sndfilehandle] Error 1
make: *** [all-recursive] Error 1

Fix ALAC compiler warnings from gcc on ARM

Example warnings include:

ALAC/EndianPortable.c:49:5: warning: "TARGET_RT_LITTLE_ENDIAN" is not defined [-Wundef]

ALAC/alac_decoder.c:89:45: warning: cast increases required alignment of target type [-Wcast-align]

normalize support for sndfile-convert

would be great, if sndfile-convert had a flag to automatically normalize a file during the conversion. it is a basic feature, but i could not find any command-line application, which actually does it for all the formats supported by libsndfile ...

Possible to disable autogen dependency?

Hi,

The build system appears to depend on autogen, which is non-trivial to install on Mac OS (requiring Guile among other things).

Is there any way to bypass this dependency, for example via a flag to the configure script?

Jamie

Latest code fails to build on OS X because it thinks clang is GCC 4.2

The latest code in the repository fails to build on OS X. Here's the full log from MacPorts but some relevant portions are:

checking for version of /usr/bin/clang... 4.2.1
configure: WARNING: ****************************************************************
configure: WARNING: ** GCC version 4.2 warns about the inline keyword for no good **
configure: WARNING: ** reason but the maintainers do not see it as a bug.         **
configure: WARNING: ** See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33995      **
configure: WARNING: ** Using -fgnu-inline to avoid this stupidity.                **
configure: WARNING: ****************************************************************
checking if /usr/bin/clang accepts -fgnu89-inline... yes
  Tools :

    Compiler is GCC : ..................... yes
    GCC version : ......................... 4.2.1
ld: 1414 duplicate symbols for architecture x86_64

The problem seems to be that the configure script thinks the compiler is GCC, but it's actually clang (from Xcode 5.0.1's command line tools on OS X 10.9 Mavericks).

Because of this, the configure script then uses $CC -dumpversion to determine its version; with clang, this return "4.2.1" apparently regardless of the actual clang version. (The actual clang version is Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn).)

The configure script then decides that because this is "GCC 4.2" it should add the flag -fgnu89-inline to suppress a GCC warning, but this causes the build to fail with clang with duplicate symbol errors.

The latest released version of libsndfile, 1.0.25, builds successfully, because it has an additional bug: The GCC version detection code does not work correctly when sed is BSD sed, which it is on OS X.

In this case, two wrongs make a right: because the "GCC" version is incorrectly detected as being 4.4 instead of 4.2, -fgnu89-inline does not get added and the build succeeds. But the BSD sed compatibility problem was fixed in 7c893e4, thus exposing the other problem.

If I understand correctly, the only reason to add -fgnu89-inline is to suppress a warning, but I also tried to build the latest code on Mac OS X 10.5 which uses the Apple gcc 4.2.1 compiler. There were no additional warnings generated when removing -fgnu89-inline. Perhaps they only occur with FSF GCC and not with Apple's modified version.

Perhaps a simple way to solve the problem, since GCC 4.2 is so old now, would be to remove the code that checks for GCC 4.2 and adds -fgnu89-inline. Or if you want to keep it, then change the GCC detection to not consider clang to be GCC.

Loading a specific flac file causes sf_readf_float to return 0 too early.

This soundfile:

http://dl.dropbox.com/u/4814054/Kick06.flac

This program:

include <sndfile.h>

include <stdio.h>

include <string.h>

int main(int argc, char **argv){
SF_INFO sf_info; memset(&sf_info,0,sizeof(sf_info));

SNDFILE *sndfile = sf_open(argv[1],SFM_READ,&sf_info);

int frames_read = 0;
while(frames_read < sf_info.frames){
float samples[1024*sf_info.channels];

int read_now = sf_readf_float(sndfile, samples, 1024);
printf("read_now: %d. frames_read: %d. num_frames: %d.\n",read_now,frames_read,(int)sf_info.frames);

frames_read += read_now;

}

sf_close(sndfile);

return 0;
}

Unversioned lib for Android

Hi Erik,

on Android you can't easily handle versioned libraries. It would be great to either have a general configure option to build an unversioned libsndfile or to check for an Android target in configure and then set

libsndfile_la_LDFLAGS = -no-undefined -avoid-version

instead of the usual

libsndfile_la_LDFLAGS = -no-undefined -version-info @SHARED_VERSION_INFO@ @SHLIB_VERSION_ARG@

Kind regards,
Felix

make test-tarball fails

make test-tarball fails with this error message:

make[1]: *** No rule to make target tests/.libs/aiff_rw_test', needed bylibsndfile-testsuite-x86_64-unknown-linux-gnu-1.0.26pre5/test_wrapper.sh'. Stop.

Improve error reporting of sndfile-convert

The command:

sndfile-convert /tmp/a.ogg /tmp/a.wav
Error : output file format is invalid (0x00010060).

should provide a better error messages.

The problem is that the above command is trying to convert a file containing Vorbis data in an Ogg container into a file containing Vorbis data in a WAV container, but the WAV container doesn't support Vorbis data.

Typically what is needed is something like:

sndfile-convert -pcm16 /tmp/a.ogg /tmp/a.wav

to convert the audio data into a format that is accepted by the the WAV container.

Build process broken on Ubuntu

Since updating to Ubuntu 12.04, I am unable to run pulseaudio and several audio related applications. I am getting this strange error message:

pulseaudio: symbol lookup error: /usr/lib/x86_64-linux-gnu/libsndfile.so.1: undefined symbol: vorbis_version_string

I have seen this message pop up all over the net, but google could not yet find someone who actually solved it. I tried building libsndfile from the stable distribution:

CCLD make_sine
../src/.libs/libsndfile.so: undefined reference to `vorbis_version_string'
collect2: ld returned 1 exit status

[patch] remove C99 style variable declaration / variable length automatic array in ALAC source

Although libsndfile is already using pretty much of C99 standard functions / types, libsndfile has not been using these C99 specific syntactic features on other parts.
Unlike functions/types, syntax has no possible workaround on C89 compilers. Please avoid this if possible...
Patch attached.

diff --git a/src/ALAC/alac_decoder.c b/src/ALAC/alac_decoder.c
index 4a1dc91..1eb35c6 100644
--- a/src/ALAC/alac_decoder.c
+++ b/src/ALAC/alac_decoder.c
@@ -35,10 +35,12 @@
 #include "ALACBitUtilities.h"
 #include "EndianPortable.h"

+#ifndef __cplusplus
 typedef enum
 {  false = 0,
    true = 1
 } bool ;
+#endif

 // constants/data
 const uint32_t kMaxBitDepth = 32;          // max allowed bit depth is 32
@@ -637,7 +639,8 @@ static void Zero32( int32_t * buffer, uint32_t numItems, uint32_t stride )
    }
    else
    {
-       for ( uint32_t indx = 0; indx < (numItems * stride); indx += stride )
+       uint32_t indx;
+       for ( indx = 0; indx < (numItems * stride); indx += stride )
            buffer[indx] = 0;
    }
 }
diff --git a/src/ALAC/alac_encoder.c b/src/ALAC/alac_encoder.c
index 67e62da..a33b6cc 100644
--- a/src/ALAC/alac_encoder.c
+++ b/src/ALAC/alac_encoder.c
@@ -44,11 +44,13 @@
 #include "ALACAudioTypes.h"
 #include "EndianPortable.h"

+#ifndef __cplusplus
 typedef enum
 {
    false = 0,
    true = 1
 } bool ;
+#endif

 static void    GetConfig(ALAC_ENCODER *p, ALACSpecificConfig * config );

@@ -247,6 +249,8 @@ EncodeStereo(ALAC_ENCODER *p, struct BitBuffer * bitstream, int32_t * inputBuffe
    bool            doEscape;
    int32_t         status = ALAC_noErr;
    int32_t         bestRes;
+   uint32_t        numUV;
+   uint32_t        converge;

    // make sure we handle this bit-depth before we get going
    RequireAction( (p->mBitDepth == 16) || (p->mBitDepth == 20) || (p->mBitDepth == 24) || (p->mBitDepth == 32), return kALAC_ParamError; );
@@ -361,14 +365,14 @@ EncodeStereo(ALAC_ENCODER *p, struct BitBuffer * bitstream, int32_t * inputBuffe
    numU = numV = kMinUV;
    minBits1 = minBits2 = 1ul << 31;

-   for ( uint32_t numUV = kMinUV; numUV <= kMaxUV; numUV += 4 )
+   for ( numUV = kMinUV; numUV <= kMaxUV; numUV += 4 )
    {
        BitBufferInit( &workBits, p->mWorkBuffer, p->mMaxOutputBytes );

        dilate = 32;

        // run the predictor over the same data multiple times to help it converge
-       for ( uint32_t converge = 0; converge < 8; converge++ )
+       for ( converge = 0; converge < 8; converge++ )
        {
            pc_block( p->mMixBufferU, p->mPredictorU, numSamples/dilate, coefsU[numUV-1], numUV, chanBits, DENSHIFT_DEFAULT );
            pc_block( p->mMixBufferV, p->mPredictorV, numSamples/dilate, coefsV[numUV-1], numUV, chanBits, DENSHIFT_DEFAULT );
@@ -837,11 +841,12 @@ EncodeMono(ALAC_ENCODER *p, struct BitBuffer * bitstream, int32_t * inputBuffer,
    {
        BitBuffer       workBits;
        uint32_t        numBits;
+       uint32_t        converge;

        BitBufferInit( &workBits, p->mWorkBuffer, p->mMaxOutputBytes );

        dilate = 32;
-       for ( uint32_t converge = 0; converge < 7; converge++ )
+       for ( converge = 0; converge < 7; converge++ )
            pc_block( p->mMixBufferU, p->mPredictorU, numSamples/dilate, coefsU[numU-1], numU, chanBits, DENSHIFT_DEFAULT );

        dilate = 8;
@@ -1181,6 +1186,9 @@ int32_t
 alac_encoder_init (ALAC_ENCODER *p, uint32_t samplerate, uint32_t channels, uint32_t format_flags, uint32_t frameSize)
 {
    int32_t         status;
+   uint32_t        indx;
+   uint32_t        channel;
+   uint32_t        search;

    p->mFrameSize = (frameSize > 0 && frameSize <= ALAC_FRAME_LENGTH) ? frameSize : ALAC_FRAME_LENGTH ;

@@ -1206,7 +1214,7 @@ alac_encoder_init (ALAC_ENCODER *p, uint32_t samplerate, uint32_t channels, uint

    // set up default encoding parameters and state
    // - note: mFrameSize is set in the constructor or via alac_set_frame_size() which must be called before this routine
-   for ( uint32_t indx = 0; indx < kALACMaxChannels; indx++ )
+   for ( indx = 0; indx < kALACMaxChannels; indx++ )
        p->mLastMixRes[indx] = kDefaultMixRes;

    // the maximum output frame size can be no bigger than (samplesPerBlock * numChannels * ((10 + sampleSize)/8) + 1)
@@ -1217,9 +1225,9 @@ alac_encoder_init (ALAC_ENCODER *p, uint32_t samplerate, uint32_t channels, uint
    status = ALAC_noErr;

    // initialize coefs arrays once b/c retaining state across blocks actually improves the encode ratio
-   for ( int32_t channel = 0; channel < (int32_t) p->mNumChannels; channel++ )
+   for ( channel = 0; channel < (int32_t) p->mNumChannels; channel++ )
    {
-       for ( int32_t search = 0; search < kALACMaxSearches; search++ )
+       for ( search = 0; search < kALACMaxSearches; search++ )
        {
            init_coefs( p->mCoefsU[channel][search], DENSHIFT_DEFAULT, kALACMaxCoefs );
            init_coefs( p->mCoefsV[channel][search], DENSHIFT_DEFAULT, kALACMaxCoefs );
diff --git a/src/alac.c b/src/alac.c
index f4763fc..bef690c 100644
--- a/src/alac.c
+++ b/src/alac.c
@@ -167,9 +167,11 @@ alac_close (SF_PRIVATE *psf)
    {   ALAC_ENCODER *penc = &plac->encoder ;
        SF_CHUNK_INFO chunk_info ;
        sf_count_t readcount ;
-       uint8_t *kuki_data [plac->kuki_size] ;
+       uint8_t *kuki_data;
        uint32_t pakt_size = 0, saved_partial_block_frames ;

+       kuki_data = alloca(plac->kuki_size);
+
        plac->final_write_block = 1 ;
        saved_partial_block_frames = plac->partial_block_frames ;

Add Wavpack support

Obvious enough.

Unfortunately it is unlikely that I (Erik) will find sufficient time or motivation to do this, but I would be happy to accept patches.

ALAC encoder doesn't fill packet table header of pakt chunk

https://developer.apple.com/library/mac/#documentation/MusicAudio/Reference/CAFSpec/CAF_spec/CAF_spec.html#//apple_ref/doc/uid/TP40001862-CH210-BCGBDDAI

First 24 byte of pakt chunk is the packet table header, whose structure is:

struct CAFPacketTableHeader {
    SInt64  mNumberPackets;
    SInt64  mNumberValidFrames;
    SInt32  mPrimingFrames;
    SInt32  mRemainderFrames;
};

The Core Audio Format spec says:

The total number of packets of audio data described in the packet table. This value must always be valid.
For a CAF file with variable packet sizes, this value should reflect the actual number of packets in the Audio Data chunk. In a CAF file with constant packet size, and therefore no packet table, this field should be set to 0.

Access to Embedded WAV/AIFF Metadata Inside FLAC

I have lots of wav/aiff files with embedded sample playback informations
that I read using SFC_GET_LOOP_INFO and SFC_GET_INSTRUMENT.

I would like that once those file are reencoded in flac (using --keep-foreign-metadata)
still be able to retrieve those informations as well as getting custom chunk
using sf_get_chunk_size and sf_get_chunk_data

ima4 AIFF-C file of unknown origin decodes incorrectly in libsndfile

ima4 AIFF-C file of unknown origin decodes incorrectly in libsndfile

Happens on Mac OSX 10.6 as well as on Win 7 x64 with the .dlls found on the mega-nerd site. I don't know the origin of this file other than I downloaded it from the internet some time ago when testing the AIFF-C importer we wrote for Adobe Audition.

Here is the file that shows the issue in libsndfile: http://dl.dropbox.com/u/24880982/pawhistoriestrinity.aifc.zip (~240 MB)

Here is the file decoded to a PCM WAV by Apple's afconvert terminal command: http://dl.dropbox.com/u/24880982/pawhistoriestrinity.wav.zip (~890 MB)

The expectation is for libsndfile to be able to decode this file similar to how QuickTime and Apple's AudioToolbox framework can decode it.


output from sndfile-info


SoundStream:~ cvanwink$ sndfile-info /Users/cvanwink/Desktop/untitled\ folder/pawhistoriestrinity.aifc Version : libsndfile-1.0.24 File : /Users/cvanwink/Desktop/untitled folder/pawhistoriestrinity.aifc Length : 283401230 FORM : 283401222 AIFC FVER : 4 COMM : 30 Sample Rate : 44100 Frames : 4167664 Channels : 2 Sample Size : 16 Encoding : ima4 => unknown SSND : 283401160 Offset : 0 Block Size : 0 still need to check block count Sample Rate : 44100 Frames : 266730496 Channels : 2 Format : 0x00020012 Sections : 1 Seekable : TRUE Duration : 01:40:48.311

Output from OSX's terminal command afinfo


SoundStream:~ cvanwink$ afinfo /Users/cvanwink/Desktop/untitled\ folder/pawhistoriestrinity.aifc File: /Users/cvanwink/Desktop/untitled folder/pawhistoriestrinity.aifc File type ID: AIFC Data format: 2 ch, 44100 Hz, 'ima4' (0x00000000) 0 bits/channel, 68 bytes/packet, 64 frames/packet, 0 bytes/frame no channel layout. estimated duration: 6048.310567 sec audio bytes: 283401152 audio packets: 4167664 bit rate: 374850 bits per second packet size upper bound: 68 audio data file offset: 78 optimized

make: неверный ключ — «y»

...
CC sndfile-interleave.o
CCLD sndfile-interleave
CC sndfile-deinterleave.o
CCLD sndfile-deinterleave
CC sndfile-concat.o
CCLD sndfile-concat
CC sndfile-salvage.o
CCLD sndfile-salvage
make[1]: Выход из каталога /home/ss/pulseaudio/libsndfile/programs' make[1]: Вход в каталог/home/ss/pulseaudio/libsndfile'
make[1]: Цель all-am' не требует выполнения команд. make[1]: Выход из каталога/home/ss/pulseaudio/libsndfile'
make: неверный ключ — «y»

Data gets lost when opening and closing certain files in SFM_RDWR mode

While writing unit tests for PySoundFile, I witnessed very strange behavior:

After opening and closing (and nothing in between!) a certain WAV file in SFM_RDWR mode, the file was changed and a few samples were missing in the front.

The WAV file in question has 32-bit float format and was generated in Python using scipy.io.

This is the code that changes the file:

#include <sndfile.h>
int main() {
SF_INFO sfinfo;
SNDFILE* sf;
sf = sf_open("stereo.wav", SFM_RDWR, &sfinfo);
sf_close(sf);
}

The original WAV file has 4 frames, after running this program it has only 2 frames!

The first 3 samples (= one and a half frames) is missing, so maybe it has something to do with a wrong header size or something?

The WAV file itself and the code to generate it is available at https://gist.github.com/mgeier/7224433.

This seems to happen only with 32-bit and 64-bit float files, but I'm not sure.
Reading the file in SFM_READ mode works correctly.

Is the WAV file malformed?
If yes, shouldn't libsndfile return some kind of error?
If no, what's going on?

Investigate switching to a BSD or MIT license

I've sent an email to Erik about this and posted to the mailing list, but still haven't heard back from anyone, thus this seems to be the last place to ask.

If people don't want to read the mailing list post, here it is again:

Hi Everyone,

I've recently joined the developer team [1] of SFML a Simple and Fast
Multimedia Library [2]. Those that know SFML and have been following its
development know that we're using libsndfile and are currently pushing for
mobile support. There's already a semi-stable version for Android and iOS
merged into the master branch, but one of the major issues we're currently
facing is the license conflict with libsndfile on iOS.

As you may know (Erik at least knows [3]) iOS doesn't allow shared
libraries. In combination with libsndfile's LGPL license any iOS
application using libsndfile is, as far as I understand the licensing
stuff, required to release their application as LGPL or GPL. With SFML
using the zlib/libpng license static linkage is incompatible to begin
with.

Would it be possible to have a separate license or exception in the LGPL
license for iOS applications?

Just as prevention: Please don't make this into a "Why LGPL is great/bad"
discussion, I think we all know the pro/cons.

Up until now, the only "official" things I could find on this matter is
the StackOverflow topic [4] which basically says "no" and an email quote
of Erik [5] posted by Laurent, the author of SFML, that says "maybe". Thus
I came here to see if we could get an update on this matter.

Thanks,
Lukas

[1] http://en.sfml-dev.org/forums/index.php?topic=14997.0
[2] http://www.sfml-dev.org/
[3] https://stackoverflow.com/a/4733885/1034248#1034248
[4] https://stackoverflow.com/a/4939268/4940703#4940703
[5] http://en.sfml-dev.org/forums/index.php?topic=13716.msg107309#msg107309

Since this is kind of a blocking factor for SFML, feedback is urgent and highly appreciated.

sndfile-play.c referencing Carbon.h

I have installed the "Command Line Tools for Xcode" for OS X, which provides a minimal command-line build environment on OS X. They are available here:

http://developer.apple.com/downloads

If you only install these tools and attempt to compile libsndfile, compilation fails in sndfile-play.c as it references Carbon.h, which is not included with these tools.

Carbon.h is not required, and sndfile-play.c compiles fine if you remove it.

python scikits.audiolab Sndfile special chars in file name

Hi ,

Could you help me out on this , or guide me to some how can thanks
(python scikits.audiolab Sndfile special chars in file name)
I am trying to get a wav file information but Sndfile is unable to read file with special characters in path and file name(查找問題daw.wav) and i am unable to get information in any way , i tried passing file path to Sndfile with diferent encoding to but didnt work , but if i pass this 'C:\Users\Furqan\Desktop\test\DAW\1.wav' it works fine , Thanks is advance

My Code is
# -- coding: UTF-8 --
from scikits.audiolab import Sndfile
from os import walk, path, stat

track1 =  r'C:\Users\Furqan\Desktop\test\查找問題daw\查找問題d.wav'
#track2 = r'C:\Users\Furqan\Desktop\test\DAW\1.wav'

try:
    track_one_file_obj = Sndfile(track1, 'r')
except:
    print('Simple didnt work')
    pass

try:
    track_one_file_obj = Sndfile(track1.decode('cp1252'), 'r')
except:
    print('cp1252 didnt work')
    pass

try:
    track_one_file_obj = Sndfile(track1.encode('utf-8'), 'r')
    print(track_one_file_obj)
except:
    print('encode didnt work')
    pass


try:
    track_one_file_obj = Sndfile(track1.encode('utf8'), 'r')
    print(track_one_file_obj)
except:
    print('encode didnt work')
    pass

try:
    track_one_file_obj = Sndfile(track1.decode('utf-8'), 'r')
    print(track_one_file_obj)
except:
    print('decode didnt work')
    pass

CAF chunks after data chunk are read as garbage PCM

As is written in CAF spec, data is not necessarily the last chunk of CAF file:
https://developer.apple.com/library/mac/documentation/MusicAudio/Reference/CAFSpec/CAF_spec/CAF_spec.html#//apple_ref/doc/uid/TP40001862-CH210-BCGGEFGJ
(It is guaranteed to be placed at last only when size of data chunk is unknown, and mChunkSize field is set to -1 to indicate it. Usually it is the case for piping).

Since libsndfile always assumes data as the last chunk and completely ignore mChunkSize, all chunks after data are read as garbage PCM (in case of PCM codec is used).

Using sndfile-info on certain CAF ALAC files causes Segmentation Fault

OS: OSX 10.6.8 x86_64 (compiled with gcc: i686-apple-darwin10-gcc-4.2.1)
Tested with Libsndfile Version: commit db5ad49

Various files are in this .zip file: http://dl.dropbox.com/u/24880982/SEGFAULT/SEGFAULT.zip

There are many more on my system that I didn't include, so if there are multiple issues that need fixing I can post more, otherwise I assume they're all having problems from the same issue.

Apple's library do not have problems opening or playing these files. Below are afinfo logs from a few of the files:


nagra:~ cvanwink$ afinfo /Users/cvanwink/Desktop/ALAC\ Not\ Open/SEGFAULT/Door\ 17.caf 
File:           /Users/cvanwink/Desktop/ALAC Not Open/SEGFAULT/Door 17.caf
File type ID:   caff
Data format:     6 ch,  48000 Hz, 'alac' (0x00000003) from 24-bit source, 4096 frames/packet
Channel layout: 5.1 (L R C LFE Ls Rs)
estimated duration: 4.150125 sec
audio bytes: 1418183
audio packets: 49
audio 199206 valid frames + 0 priming + 1498 remainder = 200704
bit rate: 2713360 bits per second
packet size upper bound: 47554
audio data file offset: 4096
not optimized
source bit depth: I24
sound check:
    copyright                                Copyright (c) 2007 Apple Inc.  All Rights Reserved.
    approximate duration in seconds          4.15
    artist                                   Detroit Chop Shop

nagra:~ cvanwink$ afinfo /Users/cvanwink/Desktop/ALAC\ Not\ Open/SEGFAULT/Gun\ Hand\ Shot\ 4.caf 
File:           /Users/cvanwink/Desktop/ALAC Not Open/SEGFAULT/Gun Hand Shot 4.caf
File type ID:   caff
Data format:     6 ch,  48000 Hz, 'alac' (0x00000003) from 24-bit source, 4096 frames/packet
Channel layout: 5.1 (L R C LFE Ls Rs)
estimated duration: 10.150688 sec
audio bytes: 3209337
audio packets: 119
audio 487233 valid frames + 0 priming + 191 remainder = 487424
bit rate: 2528364 bits per second
packet size upper bound: 54938
audio data file offset: 4096
not optimized
source bit depth: I24
sound check:
    copyright                                Copyright (c) 2007 Apple Inc.  All Rights Reserved.
    approximate duration in seconds          10.151
    artist                                   Detroit Chop Shop

nagra:~ cvanwink$ afinfo /Users/cvanwink/Desktop/ALAC\ Not\ Open/SEGFAULT/Toilet\ Urinating\ Public\ Bathroom\ 01.caf 
File:           /Users/cvanwink/Desktop/ALAC Not Open/SEGFAULT/Toilet Urinating Public Bathroom 01.caf
File type ID:   caff
Data format:     6 ch,  48000 Hz, 'alac' (0x00000003) from 24-bit source, 4096 frames/packet
Channel layout: 5.1 (L R C LFE Ls Rs)
estimated duration: 20.365792 sec
audio bytes: 9513558
audio packets: 239
audio 977558 valid frames + 0 priming + 1386 remainder = 978944
bit rate: 3731782 bits per second
packet size upper bound: 46770
audio data file offset: 4096
not optimized
source bit depth: I24
sound check:
    copyright                                Copyright (c) 2007 Apple Inc.  All Rights Reserved.
    approximate duration in seconds          20.366
    artist                                   Detroit Chop Shop

Bug in psf_calc_signal_max() and psf_calc_max_all_channels()

Reported on the libsndfile-devel mailing list.

These functions don't return the calculated max for channel counts other than 1 or 2, 4 etc.

Problem is in

psf_calc_signal_max (SF_PRIVATE *psf, int normalize)
[..]
     data = psf->u.dbuf ;
     len = ARRAY_LEN (psf->u.dbuf) ;
[..]
readcount = sf_read_double ((SNDFILE*) psf, data, len)

sf_read_double will fail if len is not an integer multiple of the channel count.

sf_format_check() reports wrong endian capabilities for Ogg Vorbis

If you have an SF_INFO struct like the following:

SF_INFO myInfo;
myInfo.frames = 0xcccccccccccccccc // uninitialized
myInfo.samplerate = 0
myInfo.channels = 1
myInfo.format = 0x00200060 // Ogg Vorbis
myInfo.sections = 0xcccccccc // uninitialized
myInfo.seekable = 0xcccccccc // uninitialized

And you use sf_format_check(&myInfo) to check the validity of the format, it always returns SF_TRUE even when you also set either of the following

a) myInfo.format = myInfo.format | SF_ENDIAN_LITTLE;
b) myInfo.format = myInfo.format | SF_ENDIAN_BIG;

The problem is if you use sf_open() in write mode (0x00000020) with either the above SF_ENDIAN_LITTLE or SF_ENDIAN_BIG, that call will return NULL;

After that, sf_error() will indicate error code 29 ("Unspecified internal error.")

The request is to fix the sf_format_check() routine to properly report the capabilities of the Ogg Vorbis format combination.

(Adobe Bug #3093345)
[EDIT: Try to change c comments above to c++ comments to see if that makes the GitHub Markdown happier]

Is AIFF | FLOAT | BIG allowed?

I'm working on Python bindings for libsndfile, so I played around with a few combinations of major formats, subtypes and endians and found one combination that behaved strangely:

SF_FORMAT_AIFF | SF_FORMAT_FLOAT | SF_ENDIAN_BIG

If I use sf_format_check() on this, it claims that this is a valid format. However, if I try to open a file with that format, I get a Format not recognised error.

So which is it, valid or not valid?

Here's the code I tried (with libsndfile 1.0.25 on Debian Linux):

#include <sndfile.h>
int main() {
  SF_INFO sfinfo;
  sfinfo.channels = 2;
  sfinfo.samplerate = 44100;
  sfinfo.format = SF_FORMAT_AIFF | SF_FORMAT_FLOAT | SF_ENDIAN_BIG;

  printf("sf_format_check: ");
  if (sf_format_check(&sfinfo) == SF_FALSE) printf("not ");
  printf("valid\n");

  if (sf_open("delme.aifc", SFM_WRITE, &sfinfo) == NULL) {
    printf("Not able to open file: ");
    puts(sf_strerror(NULL));
  }
}

When I run this I get:

sf_format_check: valid
Not able to open file: Format not recognised.

All other combinations I tried (and I only tried a handful) behaved as expected: the file can be opened if and only if sf_format_check() returns SF_TRUE.

Add support for Xiph's Opus codec

I started this some time ago, but got busy on other things. If anyone has some spare cycles and would like to work on this, I can publish my work-in-progress branch for them to continue the effort.

I do hope to get back to this, but I have no idea when that will be.

Tests fail on Android

When cross compiling to Android and running the test suite tarball, the test fail with a segfault in the ALAC code.

Results:

float_scaled_test              : dpcm_16.xi ..............  -90.7dB SNR ... ok
float_scaled_test              : dpcm_8.xi ...............  -41.9dB SNR ... ok
float_scaled_test              : pcm_s8.sds ..............  -94.7dB SNR ... ok
float_scaled_test              : pcm_16.sds .............. -140.5dB SNR ... ok
float_scaled_test              : pcm_24.sds .............. -181.3dB SNR ... ok
float_scaled_test              : alac_16.caf ............. Segmentation fault

OSX 10.8.5 make error

interleave.c:291:7: error: explicitly assigning a variable of type 'SF_PRIVATE ' (aka 'struct sf_private_tag *') to itself [-Werror,-Wself-assign]
{ psf = psf ; mode = mode ;
~~~ ^ ~~~
interleave.c:291:20: error: explicitly assigning a variable of type 'int' to itself [-Werror,-Wself-assign]
{ psf = psf ; mode = mode ;
~~~~ ^ ~~~~
2 errors generated.
make[2]: *
* [interleave.lo] Error 1
make[1]: *** [all] Error 2
make: *** [all-recursive] Error 1

New ALAC support doesn't report proper file length for "Apple Loops"

VERSION:

libsndfile-1.0.26pre2 (supplied by ErikD)

PLATFORM:

32-bit libsndfile on Windows 7 x64

DESCRIPTION:

Apple ships many 'alac'-encoded CAF files with their video products for stock sound effects and stock loops. Many of the loops that came with Apple Soundtrack Pro and Apple Logic (possibly also Apple Garageband) are in what is called "Apple Loops" format. I'm unfamiliar with what the distinction is, but Apple QuickTime doesn't decode the file length properly (sample file attached), whereas the newer API, Apple AudioToolbox, does correctly report a file length that accomodates seemless looping. When decoded through libsndfile-1.0.26pre2, there is noise at the end of the file (probably repeated buffer), whereas QuickTime has silence where libsndfile has noise. AudioToolbox, doesn't have this extra space at the end.

REPRO STEPS:

  1. Download the sample files from here: http://dl.dropbox.com/u/24880982/Apple_Loop_Test.zip
  • Contents:
    • The original 'alac' CAF file
    • An AIFF showing the decode from libsndfile-1.0.26pre2
    • An AIFF showing the decode from QuickTime on OSX 10.6.8
    • An AIFF showing the decode from Apple AudioToolbox on OSX 10.6.8
      2) Decode the file through libsndfile

RESULT:

(see attached decode file)

SNDFILE-INFO DUMP:

C:\Users\cvanwink\Desktop\libsndfile-1.0.26pre2-w32\bin>sndfile-info.exe "C:\Users\cvanwink\Desktop\CAF\Acoustic Drum Kit Groove 23.caf"

Version : libsndfile-1.0.26pre2

File : C:\Users\cvanwink\Desktop\CAF\Acoustic Drum Kit Groove 23.caf
Length : 399277
caff
Version : 1
Flags : 0
desc : 32
Sample rate : 44100.000
Format id : alac
Format flags : 1
Bytes / packet : 0
Frames / packet : 4096
Channels / frame : 2
Bits / channel : 0
kuki : 56
pakt : 112
uuid : 209 (skipped)
uuid : 432 (skipped)
info : 80 (skipped)
free : 3067
data : 392409 (should be 392413)
edit : 1
End

Sample Rate : 44100
Frames : 180224
Channels : 2
Format : 0x00180070
Sections : 1
Seekable : TRUE
Duration : 00:00:04.087
Signal Max : 32768 (0.00 dB)

AFINFO DUMP (OSX terminal command that utilizes AudioToolbox):

nagra:Apple Loop Test cvanwink$ afinfo /Users/cvanwink/Desktop/Apple\ Loop\ Test/Acoustic\ Drum\ Kit\ Groove\ 23.caf
File: /Users/cvanwink/Desktop/Apple Loop Test/Acoustic Drum Kit Groove 23.caf
File type ID: caff
Data format: 2 ch, 44100 Hz, 'alac' (0x00000001) from 16-bit source, 4096 frames/packet
no channel layout.
estimated duration: 3.997755 sec
audio bytes: 392405
audio packets: 44
audio 176301 valid frames + 0 priming + 3923 remainder = 180224
bit rate: 768157 bits per second
packet size upper bound: 11667
audio data file offset: 4096
not optimized
source bit depth: I16
sound check:
approximate duration in seconds 3.998
copyright PowerFX Systems AB
comments SL00626
artist http://www.PowerFX.com

EXPECTED:

File length and decoding like Apple AudioToolbox for these types of files

libsndfile and sox: multiple definition of `gsm_create'

Hello everybody,
I try to integrate libsndfile in sox, but it don't work. First I have to use "--disable-external-libs", otherwise sox don't include libsndfile. And second when I build libsndfile without external libs sox include it, but I get errors like this:

D:/_System/mingw/local32/lib/libsndfile.a(gsm_create.o):gsm_create.c:(.text+0x0): multiple definition of `gsm_create'
D:/_System/mingw/local32/lib/libgsm.a(gsm_create.o):gsm_create.c:(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status

I try a way with remove all code what include gsm:
https://github.com/jb-alvarado/libsndfile

This works, but is a bad solution... Is there a more elegant way without remove gsm from libsndfile?

No tags in git for releases

It would be good to have tags for the release tarballs in git to allow tracking versions, git bisecting, maintaining personal branches, etc. easier.

sf_seek(handle, 0, SEEK_END) on a FLAC file returns -1 with error message "No Error"

CPU: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
Memory: 8 GB
OS: Lubuntu 12.10
Package: libsndfile-1.0.25-5 (from distribution)

The problem is described in the subject line.

Here's output from sndfile-info for one FLAC file that this occurs with:

Version : libsndfile-1.0.25

File : instrument1-layer1.flac
Length : 86188
FLAC Stream Metadata
Channels : 2
Sample rate : 48000
Frames : 20097
Bit width : 24
Vorbis Comment Metadata
End


Sample Rate : 48000
Frames : 20097
Channels : 2
Format : 0x00170003
Sections : 1
Seekable : TRUE
Duration : 00:00:00.419
Signal Max : 2.79467e+06 (-9.55 dB)

Note that the FLAC file referenced above was written using libsndfile.

I suspect the problem might be here:

https://github.com/erikd/libsndfile/blob/master/src/flac.c#L1346

... but I've done nothing to confirm it yet.

current package for centos

I'm having trouble to get a current package of libsndfile for centos: The newest version I found is 1.6.1 and ruby-audio depends on 1.7+ - is there a chef-cookbook somewhere to build current versions or is there any other out-of-the-box-way to build libsndfile?

thx for any help!
stefan

Four potentially malformed CAF ALAC files don't open in sndfile-info, but are okay in Apple's tools

OS: OSX 10.6.8 x86_64 (compiled with gcc: i686-apple-darwin10-gcc-4.2.1)
Tested with Libsndfile Version: commit db5ad49

Files: http://dl.dropbox.com/u/24880982/Malformed/Reported_As_Malformed.zip

I'll show the sndfile-info for one of the files as it seems representative of all four. I'll include afinfo for all four files:


Emery Background 01.caf

nagra:~ cvanwink$ sndfile-info /Users/cvanwink/Desktop/ALAC\ Not\ Open/Emery\ Background\ 01.caf 
Version : libsndfile-1.0.26pre2
Error : Not able to open input file /Users/cvanwink/Desktop/ALAC Not Open/Emery Background 01.caf.
File : /Users/cvanwink/Desktop/ALAC Not Open/Emery Background 01.caf
Length : 1077363
caff
  Version : 1
  Flags   : 0
desc : 32
  Sample rate  : 44100.000
  Format id    : alac
  Format flags : 1
  Bytes / packet   : 0
  Frames / packet  : 4096
  Channels / frame : 2
  Bits / channel   : 0
kuki : 56
pakt : 244
uuid : 213 (skipped)
uuid : 360 (skipped)
ovvw : 7200 (skipped)
info : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
 : -6860461075624624128 (skipped)
Supported file format but file is malformed.


nagra:~ cvanwink$ afinfo /Users/cvanwink/Desktop/ALAC\ Not\ Open/Emery\ Background\ 01.caf 
File:           /Users/cvanwink/Desktop/ALAC Not Open/Emery Background 01.caf
File type ID:   caff
Data format:     2 ch,  44100 Hz, 'alac' (0x00000001) from 16-bit source, 4096 frames/packet
                no channel layout.
estimated duration: 10.434785 sec
audio bytes: 1065075
audio packets: 113
audio 460174 valid frames + 0 priming + 2674 remainder = 462848
bit rate: 811839 bits per second
packet size upper bound: 12726
audio data file offset: 12288
optimized
source bit depth: I16
sound check:
    approximate duration in seconds          10.435

Euro Snare Roll 04.caf

nagra:~ cvanwink$ afinfo /Users/cvanwink/Desktop/ALAC\ Not\ Open/Euro\ Snare\ Roll\ 04.caf 
File:           /Users/cvanwink/Desktop/ALAC Not Open/Euro Snare Roll 04.caf
File type ID:   caff
Data format:     2 ch,  44100 Hz, 'alac' (0x00000001) from 16-bit source, 4096 frames/packet
                no channel layout.
estimated duration: 6.857143 sec
audio bytes: 621352
audio packets: 74
audio 302400 valid frames + 0 priming + 704 remainder = 303104
bit rate: 723226 bits per second
packet size upper bound: 11662
audio data file offset: 12288
optimized
source bit depth: I16
sound check:
    approximate duration in seconds          6.857
    copyright                                Apple Computer, Inc. 2004
    comments                                 Software Instrument Apple Loops
Creator: Logic Platinum
    artist                                   Apple

Pop Slip and Fall Beat.caf

nagra:~ cvanwink$ afinfo /Users/cvanwink/Desktop/ALAC\ Not\ Open/Pop\ Slip\ and\ Fall\ Beat.caf 
File:           /Users/cvanwink/Desktop/ALAC Not Open/Pop Slip and Fall Beat.caf
File type ID:   caff
Data format:     2 ch,  44100 Hz, 'alac' (0x00000001) from 16-bit source, 4096 frames/packet
                no channel layout.
estimated duration: 8.000000 sec
audio bytes: 699642
audio packets: 87
audio 352800 valid frames + 0 priming + 3552 remainder = 356352
bit rate: 692668 bits per second
packet size upper bound: 12423
audio data file offset: 12288
optimized
source bit depth: I16
sound check:
    approximate duration in seconds          8
    copyright                                Apple Computer, Inc. 2004
    comments                                 Software Instrument Apple Loops
Creator: Logic Platinum
    artist                                   Apple

Remix Layer Synth 01.caf

nagra:~ cvanwink$ afinfo /Users/cvanwink/Desktop/ALAC\ Not\ Open/Remix\ Layer\ Synth\ 01.caf 
File:           /Users/cvanwink/Desktop/ALAC Not Open/Remix Layer Synth 01.caf
File type ID:   caff
Data format:     2 ch,  44100 Hz, 'alac' (0x00000001) from 16-bit source, 4096 frames/packet
                no channel layout.
estimated duration: 7.384603 sec
audio bytes: 379721
audio packets: 80
audio 325661 valid frames + 0 priming + 2019 remainder = 327680
bit rate: 408830 bits per second
packet size upper bound: 6729
audio data file offset: 12288
optimized
source bit depth: I16
sound check:
    approximate duration in seconds          7.385
    copyright                                Apple Computer, Inc. 2004
    comments                                 Software Instrument Apple Loops
Creator: Logic Platinum
    artist                                   Apple

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.