mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-23 01:49:53 +00:00
initial import
(automatically generated log message)
This commit is contained in:
parent
cb979e10a7
commit
a1e9265cad
2
AUTHORS
2
AUTHORS
@ -1,4 +1,4 @@
|
||||
The main author of libsndfile is Erik de Castro Lopo <erikd@mega-nerd.com>.
|
||||
The main author of libsndfile is Erik de Castro Lopo <erikd@zip.com.au>.
|
||||
|
||||
The code in the src/GSM610 directory was written by Jutta Degener
|
||||
<jutta@cs.tu-berlin.de> and Carsten Bormann <cabo@cs.tu-berlin.de>.
|
||||
|
73
MacOS9/MacOS9-readme.txt
Normal file
73
MacOS9/MacOS9-readme.txt
Normal file
@ -0,0 +1,73 @@
|
||||
|
||||
***************************************************************************
|
||||
Mac OS X is UNIX so use the INSTALL instructions in the dirctory
|
||||
above. These instructions are for OS9.
|
||||
***************************************************************************
|
||||
|
||||
|
||||
BUILDING LIBSNDFILE FOR MACINTOSH (Pre Mac OSX)
|
||||
-----------------------------------------------
|
||||
|
||||
These instructions are current as of libsndfile 0.0.16, and assume the
|
||||
following development environment:
|
||||
|
||||
- MacOS 8.6
|
||||
- Metrowerks CodeWarrior Pro4 (IDE3.3, and all publicly available
|
||||
compiler updates as of June, 1999)
|
||||
- Apple Universal Libraries 3.2
|
||||
|
||||
The following procedure is recommended for building a libsndfile library
|
||||
suitable for inclusion in other MacOS projects:
|
||||
|
||||
1. using CodeWarrior, create a new "Empty Project"
|
||||
|
||||
2. obtain the libsndfile source distribution (see homepage URL below);
|
||||
add all ".c" files found in the top level of the "src", "src/GSM610" and
|
||||
"src/G72x" folders to the project
|
||||
|
||||
3. starting from the factory defaults, adjust the following project
|
||||
settings:
|
||||
- Target Settings panel:
|
||||
linker = "MacOS PPC Linker"
|
||||
- PPC Target panel:
|
||||
project type = "Library"
|
||||
file name = "libsndfile"
|
||||
|
||||
4. grab the "config.h" file from the MacOS directory and replace the default
|
||||
config.h file in the "src" directory
|
||||
|
||||
5. Make the project
|
||||
|
||||
|
||||
CROSSPLATFORM (x86) BUILDS?
|
||||
--------------------------
|
||||
|
||||
For situations in which CodeWarrior is being used to develop a project
|
||||
for dual-platform operation, it is possible to build an x86 version of
|
||||
libsndfile on the mac as well. Use the procedure above to set up the
|
||||
PPC target, then perform the following steps:
|
||||
|
||||
6. create a new target, by cloning the existing ppc target (created
|
||||
above)
|
||||
|
||||
7. adjust the following project settings:
|
||||
- Target Settings panel:
|
||||
linker = "Win32 x86 Linker"
|
||||
- x86 Settings panel:
|
||||
project type = "Library (LIB)"
|
||||
file name = "libsndfile.x32.lib"
|
||||
- Access Paths panel:
|
||||
add this compiler-relative path at the TOP of "System Paths"
|
||||
(note: this must be at the TOP of the path list):
|
||||
"{Compiler}:Win32-x86 Support:Headers:Win32 SDK:sys:"
|
||||
|
||||
8. Make the x86 target
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
|
||||
The file "README" in the libsndfile distribution, for general
|
||||
information about libsndfile.
|
||||
|
||||
|
12
MacOS9/Makefile.am
Normal file
12
MacOS9/Makefile.am
Normal file
@ -0,0 +1,12 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
EXTRA_DIST = config.h sndfile.h MacOS9-readme.txt
|
||||
|
||||
DISTCLEANFILES = Makefile
|
||||
|
||||
## Do not edit or modify anything in this comment block.
|
||||
## The arch-tag line is a file identity tag for the GNU Arch
|
||||
## revision control system.
|
||||
##
|
||||
## arch-tag: ced95aad-be1c-4ae5-a97b-897a15aaebd5
|
||||
|
218
MacOS9/config.h
Normal file
218
MacOS9/config.h
Normal file
@ -0,0 +1,218 @@
|
||||
/* src/config.h. Generated by configure. */
|
||||
/* src/config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Set to 1 if the compile is GNU GCC. */
|
||||
/* #undef COMPILER_IS_GCC */
|
||||
|
||||
/* Target processor clips on negative float to int conversion. */
|
||||
#define CPU_CLIPS_NEGATIVE 1
|
||||
|
||||
/* Target processor clips on positive float to int conversion. */
|
||||
#define CPU_CLIPS_POSITIVE 1
|
||||
|
||||
/* Target processor is big endian. */
|
||||
#define CPU_IS_BIG_ENDIAN 1
|
||||
|
||||
/* Target processor is little endian. */
|
||||
#define CPU_IS_LITTLE_ENDIAN 0
|
||||
|
||||
/* Set to 1 to enable experimental code. */
|
||||
#define ENABLE_EXPERIMENTAL_CODE 0
|
||||
|
||||
/* Major version of GCC or 3 otherwise. */
|
||||
/* #undef GCC_MAJOR_VERSION */
|
||||
|
||||
/* Define to 1 if you have the `calloc' function. */
|
||||
#define HAVE_CALLOC 1
|
||||
|
||||
/* Define to 1 if you have the `ceil' function. */
|
||||
#define HAVE_CEIL 1
|
||||
|
||||
/* Set to 1 if S_IRGRP is defined. */
|
||||
#define HAVE_DECL_S_IRGRP 1
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the <endian.h> header file. */
|
||||
#define HAVE_ENDIAN_H 1
|
||||
|
||||
/* Define to 1 if you have the `fdatasync' function. */
|
||||
#define HAVE_FDATASYNC 1
|
||||
|
||||
/* Define to 1 if you have the `floor' function. */
|
||||
#define HAVE_FLOOR 1
|
||||
|
||||
/* Define to 1 if you have the `fmod' function. */
|
||||
#define HAVE_FMOD 1
|
||||
|
||||
/* Define to 1 if you have the `free' function. */
|
||||
#define HAVE_FREE 1
|
||||
|
||||
/* Define to 1 if you have the `fstat' function. */
|
||||
#define HAVE_FSTAT 1
|
||||
|
||||
/* Define to 1 if you have the `fsync' function. */
|
||||
#define HAVE_FSYNC 1
|
||||
|
||||
/* Define to 1 if you have the `ftruncate' function. */
|
||||
#define HAVE_FTRUNCATE 1
|
||||
|
||||
/* Define to 1 if you have the `gmtime' function. */
|
||||
#define HAVE_GMTIME 1
|
||||
|
||||
/* Define to 1 if you have the `gmtime_r' function. */
|
||||
/* #undef HAVE_GMTIME_R */
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the `m' library (-lm). */
|
||||
#define HAVE_LIBM 1
|
||||
|
||||
/* Define if you have C99's lrint function. */
|
||||
#define HAVE_LRINT 0
|
||||
|
||||
/* Define if you have C99's lrintf function. */
|
||||
#define HAVE_LRINTF 0
|
||||
|
||||
/* Define to 1 if you have the `lseek' function. */
|
||||
#define HAVE_LSEEK 1
|
||||
|
||||
/* Define to 1 if you have the `malloc' function. */
|
||||
#define HAVE_MALLOC 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the <mmreg.h> header file. */
|
||||
/* #undef HAVE_MMREG_H */
|
||||
|
||||
/* Define to 1 if you have the `open' function. */
|
||||
#define HAVE_OPEN 1
|
||||
|
||||
/* Define to 1 if you have the `pread' function. */
|
||||
#define HAVE_PREAD 1
|
||||
|
||||
/* Define to 1 if you have the `pwrite' function. */
|
||||
#define HAVE_PWRITE 1
|
||||
|
||||
/* Define to 1 if you have the `read' function. */
|
||||
#define HAVE_READ 1
|
||||
|
||||
/* Define to 1 if you have the `realloc' function. */
|
||||
#define HAVE_REALLOC 1
|
||||
|
||||
/* Define to 1 if you have the `snprintf' function. */
|
||||
#define HAVE_SNPRINTF 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
|
||||
#define HAVE_SYS_WAIT_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if you have the `vsnprintf' function. */
|
||||
#define HAVE_VSNPRINTF 1
|
||||
|
||||
/* Define to 1 if you have the <wintypes.h> header file. */
|
||||
/* #undef HAVE_WINTYPES_H */
|
||||
|
||||
/* Define to 1 if you have the `write' function. */
|
||||
#define HAVE_WRITE 1
|
||||
|
||||
/* Set to 1 if compiling for Win32 */
|
||||
#define OS_IS_WIN32 0
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "libsndfile"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "<erikd@zip.com.au>"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "libsndfile"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "libsndfile 1.1.0pre1"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "libsndfile"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "1.1.0pre1"
|
||||
|
||||
/* Set to maximum allowed value of sf_count_t type. */
|
||||
#define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFFLL
|
||||
|
||||
/* The size of a `double', as computed by sizeof. */
|
||||
#define SIZEOF_DOUBLE 8
|
||||
|
||||
/* The size of a `float', as computed by sizeof. */
|
||||
#define SIZEOF_FLOAT 4
|
||||
|
||||
/* The size of a `int', as computed by sizeof. */
|
||||
#define SIZEOF_INT 4
|
||||
|
||||
/* The size of a `loff_t', as computed by sizeof. */
|
||||
#define SIZEOF_LOFF_T 0
|
||||
|
||||
/* The size of a `long', as computed by sizeof. */
|
||||
#define SIZEOF_LONG 4
|
||||
|
||||
/* The size of a `off64_t', as computed by sizeof. */
|
||||
#define SIZEOF_OFF64_T 0
|
||||
|
||||
/* The size of a `off_t', as computed by sizeof. */
|
||||
#define SIZEOF_OFF_T 4
|
||||
|
||||
/* Set to sizeof (long) if unknown. */
|
||||
#define SIZEOF_SF_COUNT_T 4
|
||||
|
||||
/* The size of a `short', as computed by sizeof. */
|
||||
#define SIZEOF_SHORT 2
|
||||
|
||||
/* The size of a `size_t', as computed by sizeof. */
|
||||
#define SIZEOF_SIZE_T 4
|
||||
|
||||
/* The size of a `ssize_t', as computed by sizeof. */
|
||||
#define SIZEOF_SSIZE_T 4
|
||||
|
||||
/* The size of a `void*', as computed by sizeof. */
|
||||
#define SIZEOF_VOIDP 4
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Set to long if unknown. */
|
||||
#define TYPEOF_SF_COUNT_T off_t
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "1.0.6pre14"
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: d0eaac82-82be-4d81-984e-a86744f18100
|
||||
*/
|
||||
|
447
MacOS9/sndfile.h
Normal file
447
MacOS9/sndfile.h
Normal file
@ -0,0 +1,447 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
** sndfile.h -- system-wide definitions
|
||||
**
|
||||
** API documentation is in the doc/ directory of the source code tarball
|
||||
** and at http://www.zip.com.au/~erikd/libsndfile/api.html.
|
||||
*/
|
||||
|
||||
#ifndef SNDFILE_H
|
||||
#define SNDFILE_H
|
||||
|
||||
/* This is the version 1.0.X header file. */
|
||||
#define SNDFILE_1
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* For the Metrowerks CodeWarrior Pro Compiler (mainly MacOS) */
|
||||
|
||||
#if (defined (__MWERKS__))
|
||||
#include <unix.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* The following file types can be read and written.
|
||||
** A file type would consist of a major type (ie SF_FORMAT_WAV) bitwise
|
||||
** ORed with a minor type (ie SF_FORMAT_PCM). SF_FORMAT_TYPEMASK and
|
||||
** SF_FORMAT_SUBMASK can be used to separate the major and minor file
|
||||
** types.
|
||||
*/
|
||||
|
||||
enum
|
||||
{ /* Major formats. */
|
||||
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
|
||||
} ;
|
||||
|
||||
/*
|
||||
** The following are the valid command numbers for the sf_command()
|
||||
** interface. The use of these commands is documented in the file
|
||||
** command.html in the doc directory of the source code distribution.
|
||||
*/
|
||||
|
||||
enum
|
||||
{ SFC_GET_LIB_VERSION = 0x1000,
|
||||
SFC_GET_LOG_INFO = 0x1001,
|
||||
|
||||
SFC_GET_NORM_DOUBLE = 0x1010,
|
||||
SFC_GET_NORM_FLOAT = 0x1011,
|
||||
SFC_SET_NORM_DOUBLE = 0x1012,
|
||||
SFC_SET_NORM_FLOAT = 0x1013,
|
||||
|
||||
SFC_GET_SIMPLE_FORMAT_COUNT = 0x1020,
|
||||
SFC_GET_SIMPLE_FORMAT = 0x1021,
|
||||
|
||||
SFC_GET_FORMAT_INFO = 0x1028,
|
||||
|
||||
SFC_GET_FORMAT_MAJOR_COUNT = 0x1030,
|
||||
SFC_GET_FORMAT_MAJOR = 0x1031,
|
||||
SFC_GET_FORMAT_SUBTYPE_COUNT = 0x1032,
|
||||
SFC_GET_FORMAT_SUBTYPE = 0x1033,
|
||||
|
||||
SFC_CALC_SIGNAL_MAX = 0x1040,
|
||||
SFC_CALC_NORM_SIGNAL_MAX = 0x1041,
|
||||
SFC_CALC_MAX_ALL_CHANNELS = 0x1042,
|
||||
SFC_CALC_NORM_MAX_ALL_CHANNELS = 0x1043,
|
||||
|
||||
SFC_SET_ADD_PEAK_CHUNK = 0x1050,
|
||||
|
||||
SFC_UPDATE_HEADER_NOW = 0x1060,
|
||||
SFC_SET_UPDATE_HEADER_AUTO = 0x1061,
|
||||
|
||||
SFC_FILE_TRUNCATE = 0x1080,
|
||||
|
||||
SFC_SET_RAW_START_OFFSET = 0x1090,
|
||||
|
||||
SFC_SET_DITHER_ON_WRITE = 0x10A0,
|
||||
SFC_SET_DITHER_ON_READ = 0x10A1,
|
||||
|
||||
SFC_GET_DITHER_INFO_COUNT = 0x10A2,
|
||||
SFC_GET_DITHER_INFO = 0x10A3,
|
||||
|
||||
SFC_GET_EMBED_FILE_INFO = 0x10B0,
|
||||
|
||||
SFC_SET_CLIPPING = 0x10C0,
|
||||
SFC_GET_CLIPPING = 0x10C1,
|
||||
|
||||
/* Following commands for testing only. */
|
||||
SFC_TEST_IEEE_FLOAT_REPLACE = 0x6001,
|
||||
|
||||
/*
|
||||
** SFC_SET_ADD_* values are deprecated and will disappear at some
|
||||
** time in the future. They are guaranteed to be here up to and
|
||||
** including version 1.0.8 to avoid breakage of existng software.
|
||||
** They currently do nothing and will continue to do nothing.
|
||||
*/
|
||||
SFC_SET_ADD_DITHER_ON_WRITE = 0x1070,
|
||||
SFC_SET_ADD_DITHER_ON_READ = 0x1071
|
||||
} ;
|
||||
|
||||
|
||||
/*
|
||||
** String types that can be set and read from files. Not all file types
|
||||
** support this and even the file types which support one, may not support
|
||||
** all string types.
|
||||
*/
|
||||
|
||||
enum
|
||||
{ SF_STR_TITLE = 0x01,
|
||||
SF_STR_COPYRIGHT = 0x02,
|
||||
SF_STR_SOFTWARE = 0x03,
|
||||
SF_STR_ARTIST = 0x04,
|
||||
SF_STR_COMMENT = 0x05,
|
||||
SF_STR_DATE = 0x06
|
||||
} ;
|
||||
|
||||
enum
|
||||
{ /* True and false */
|
||||
SF_FALSE = 0,
|
||||
SF_TRUE = 1,
|
||||
|
||||
/* Modes for opening files. */
|
||||
SFM_READ = 0x10,
|
||||
SFM_WRITE = 0x20,
|
||||
SFM_RDWR = 0x30
|
||||
} ;
|
||||
|
||||
/* Pubic error values. These are guaranteed to remain unchanged for the duration
|
||||
** of the library major version number.
|
||||
** There are also a large number of private error numbers which are internal to
|
||||
** the library which can change at any time.
|
||||
*/
|
||||
|
||||
enum
|
||||
{ SF_ERR_NO_ERROR = 0,
|
||||
SF_ERR_UNRECOGNISED_FORMAT = 1,
|
||||
SF_ERR_SYSTEM = 2
|
||||
} ;
|
||||
|
||||
/* A SNDFILE* pointer can be passed around much like stdio.h's FILE* pointer. */
|
||||
|
||||
typedef void SNDFILE ;
|
||||
|
||||
<<<<<<< diff from left file
|
||||
typedef off_t sf_count_t ;
|
||||
========
|
||||
/* The following typedef is system specific and is defined when libsndfile is.
|
||||
** compiled. sf_count_t can be one of loff_t (Linux), off_t (*BSD),
|
||||
** off64_t (Solaris), __int64_t (Win32) etc.
|
||||
*/
|
||||
|
||||
typedef loff_t sf_count_t ;
|
||||
|
||||
#define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFFLL
|
||||
>>>>>>> diff from right file
|
||||
|
||||
/* A pointer to a SF_INFO structure is passed to sf_open_read () and filled in.
|
||||
** On write, the SF_INFO structure is filled in by the user and passed into
|
||||
** sf_open_write ().
|
||||
*/
|
||||
|
||||
struct SF_INFO
|
||||
{ sf_count_t frames ; /* Used to be called samples. Changed to avoid confusion. */
|
||||
int samplerate ;
|
||||
int channels ;
|
||||
int format ;
|
||||
int sections ;
|
||||
int seekable ;
|
||||
} ;
|
||||
|
||||
typedef struct SF_INFO SF_INFO ;
|
||||
|
||||
/* The SF_FORMAT_INFO struct is used to retrieve information about the sound
|
||||
** file formats libsndfile supports using the sf_command () interface.
|
||||
**
|
||||
** Using this interface will allow applications to support new file formats
|
||||
** and encoding types when libsndfile is upgraded, without requiring
|
||||
** re-compilation of the application.
|
||||
**
|
||||
** Please consult the libsndfile documentation (particularly the information
|
||||
** on the sf_command () interface) for examples of its use.
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{ int format ;
|
||||
const char *name ;
|
||||
const char *extension ;
|
||||
} SF_FORMAT_INFO ;
|
||||
|
||||
/*
|
||||
** Enums and typedefs for adding dither on read and write.
|
||||
** See the html documentation for sf_command(), SFC_SET_DITHER_ON_WRITE
|
||||
** and SFC_SET_DITHER_ON_READ.
|
||||
*/
|
||||
|
||||
enum
|
||||
{ SFD_DEFAULT_LEVEL = 0,
|
||||
SFD_CUSTOM_LEVEL = 0x40000000,
|
||||
|
||||
SFD_NO_DITHER = 500,
|
||||
SFD_WHITE = 501,
|
||||
SFD_TRIANGULAR_PDF = 502
|
||||
} ;
|
||||
|
||||
typedef struct
|
||||
{ int type ;
|
||||
double level ;
|
||||
const char *name ;
|
||||
} SF_DITHER_INFO ;
|
||||
|
||||
/* Struct used to retrieve information about a file embedded within a
|
||||
** larger file. See SFC_GET_EMBED_FILE_INFO.
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{ sf_count_t offset ;
|
||||
sf_count_t length ;
|
||||
} SF_EMBED_FILE_INFO ;
|
||||
|
||||
|
||||
/* Open the specified file for read, write or both. On error, this will
|
||||
** return a NULL pointer. To find the error number, pass a NULL SNDFILE
|
||||
** to sf_perror () or sf_error_str ().
|
||||
** All calls to sf_open() should be matched with a call to sf_close().
|
||||
*/
|
||||
|
||||
SNDFILE* sf_open (const char *path, int mode, SF_INFO *sfinfo) ;
|
||||
|
||||
/* Use the existing file descriptor to create a SNDFILE object. If close_desc
|
||||
** is TRUE, the file descriptor will be closed when sf_close() is called. If
|
||||
** it is FALSE, the descritor will not be closed.
|
||||
** When passed a descriptor like this, the library will assume that the start
|
||||
** of file header is at the current file offset. This allows sound files within
|
||||
** larger container files to be read and/or written.
|
||||
** On error, this will return a NULL pointer. To find the error number, pass a
|
||||
** NULL SNDFILE to sf_perror () or sf_error_str ().
|
||||
** All calls to sf_open_fd() should be matched with a call to sf_close().
|
||||
|
||||
*/
|
||||
|
||||
SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ;
|
||||
|
||||
/* sf_error () returns a error number which can be translated to a text
|
||||
** string using sf_error_number().
|
||||
*/
|
||||
|
||||
int sf_error (SNDFILE *sndfile) ;
|
||||
|
||||
/* sf_strerror () returns to the caller a pointer to the current error message for
|
||||
** the given SNDFILE.
|
||||
*/
|
||||
|
||||
const char* sf_strerror (SNDFILE *sndfile) ;
|
||||
|
||||
/* sf_error_number () allows the retrieval of the error string for each internal
|
||||
** error number.
|
||||
*/
|
||||
|
||||
const char* sf_error_number (int errnum) ;
|
||||
|
||||
/* The following three error functions are deprecated but they will remain in the
|
||||
** library for the forseeable future. The function sf_strerror() should be used
|
||||
** in their place.
|
||||
*/
|
||||
|
||||
int sf_perror (SNDFILE *sndfile) ;
|
||||
int sf_error_str (SNDFILE *sndfile, char* str, size_t len) ;
|
||||
|
||||
|
||||
/* Return TRUE if fields of the SF_INFO struct are a valid combination of values. */
|
||||
|
||||
int sf_command (SNDFILE *sndfile, int command, void *data, int datasize) ;
|
||||
|
||||
/* Return TRUE if fields of the SF_INFO struct are a valid combination of values. */
|
||||
|
||||
int sf_format_check (const SF_INFO *info) ;
|
||||
|
||||
/* Seek within the waveform data chunk of the SNDFILE. sf_seek () uses
|
||||
** the same values for whence (SEEK_SET, SEEK_CUR and SEEK_END) as
|
||||
** stdio.h function fseek ().
|
||||
** An offset of zero with whence set to SEEK_SET will position the
|
||||
** read / write pointer to the first data sample.
|
||||
** On success sf_seek returns the current position in (multi-channel)
|
||||
** samples from the start of the file.
|
||||
** Please see the libsndfile documentation for moving the read pointer
|
||||
** separately from the write pointer on files open in mode SFM_RDWR.
|
||||
** On error all of these functions return -1.
|
||||
*/
|
||||
|
||||
sf_count_t sf_seek (SNDFILE *sndfile, sf_count_t frames, int whence) ;
|
||||
|
||||
/* Functions for retrieving and setting string data within sound files.
|
||||
** Not all file types support this features; AIFF and WAV do. For both
|
||||
** functions, the str_type parameter must be one of the SF_STR_* values
|
||||
** defined above.
|
||||
** On error, sf_set_string() returns non-zero while sf_get_string()
|
||||
** returns NULL.
|
||||
*/
|
||||
|
||||
int sf_set_string (SNDFILE *sndfile, int str_type, const char* str) ;
|
||||
|
||||
const char* sf_get_string (SNDFILE *sndfile, int str_type) ;
|
||||
|
||||
/* Functions for reading/writing the waveform data of a sound file.
|
||||
*/
|
||||
|
||||
sf_count_t sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ;
|
||||
sf_count_t sf_write_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ;
|
||||
|
||||
/* Functions for reading and writing the data chunk in terms of frames.
|
||||
** The number of items actually read/written = frames * number of channels.
|
||||
** sf_xxxx_raw read/writes the raw data bytes from/to the file
|
||||
** sf_xxxx_short passes data in the native short format
|
||||
** sf_xxxx_int passes data in the native int format
|
||||
** sf_xxxx_float passes data in the native float format
|
||||
** sf_xxxx_double passes data in the native double format
|
||||
** All of these read/write function return number of frames read/written.
|
||||
*/
|
||||
|
||||
sf_count_t sf_readf_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ;
|
||||
sf_count_t sf_writef_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ;
|
||||
|
||||
sf_count_t sf_readf_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ;
|
||||
sf_count_t sf_writef_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ;
|
||||
|
||||
sf_count_t sf_readf_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ;
|
||||
sf_count_t sf_writef_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ;
|
||||
|
||||
sf_count_t sf_readf_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ;
|
||||
sf_count_t sf_writef_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ;
|
||||
|
||||
/* Functions for reading and writing the data chunk in terms of items.
|
||||
** Otherwise similar to above.
|
||||
** All of these read/write function return number of items read/written.
|
||||
*/
|
||||
|
||||
sf_count_t sf_read_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ;
|
||||
sf_count_t sf_write_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ;
|
||||
|
||||
sf_count_t sf_read_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ;
|
||||
sf_count_t sf_write_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ;
|
||||
|
||||
sf_count_t sf_read_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ;
|
||||
sf_count_t sf_write_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ;
|
||||
|
||||
sf_count_t sf_read_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ;
|
||||
sf_count_t sf_write_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ;
|
||||
|
||||
/* Close the SNDFILE and clean up all memory allocations associated with this
|
||||
** file.
|
||||
** Returns 0 on success, or an error number.
|
||||
*/
|
||||
|
||||
int sf_close (SNDFILE *sndfile) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* SNDFILE_H */
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 7f113dbf-af15-4e35-8621-f60a188be6a5
|
||||
*/
|
||||
|
9
Make.bat
9
Make.bat
@ -1,7 +1,6 @@
|
||||
@echo off
|
||||
|
||||
if "%1"=="check" GOTO CHECK
|
||||
if "%1"=="clean" GOTO CLEAN
|
||||
|
||||
copy /y Win32\sndfile.h src\sndfile.h
|
||||
copy /y Win32\config.h src\config.h
|
||||
@ -14,14 +13,8 @@ goto END
|
||||
nmake -f Win32\Makefile.msvc check
|
||||
goto END
|
||||
|
||||
:CLEAN
|
||||
nmake -f Win32\Makefile.msvc clean
|
||||
goto END
|
||||
|
||||
|
||||
:END
|
||||
|
||||
|
||||
goto skipArchTag
|
||||
|
||||
Do not edit or modify anything in this comment block.
|
||||
@ -30,4 +23,4 @@ goto skipArchTag
|
||||
|
||||
arch-tag: 8700080b-8d9a-4852-ad8a-8ecd027f1f61
|
||||
|
||||
:skipArchTag
|
||||
skipArchTag
|
||||
|
10
Makefile.am
10
Makefile.am
@ -1,9 +1,9 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
SUBDIRS = man doc Win32 Octave src examples regtest tests
|
||||
SUBDIRS = man doc Win32 MacOS9 Octave src examples tests
|
||||
DIST_SUBDIRS = $(SUBDIRS)
|
||||
EXTRA_DIST = reconfigure.mk acinclude.m4 libsndfile.spec.in \
|
||||
sndfile.pc.in Mingw-make-dist.sh
|
||||
EXTRA_DIST = reconf acinclude.m4 libsndfile.spec.in sndfile.pc.in \
|
||||
check_libsndfile.py libsndfile_version_convert.py Make.bat
|
||||
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
@ -13,10 +13,6 @@ m4datadir = $(datadir)/aclocal
|
||||
|
||||
test: check-recursive
|
||||
|
||||
# Target to make autogenerated files.
|
||||
genfiles :
|
||||
(cd src ; make genfiles)
|
||||
(cd tests ; make genfiles)
|
||||
|
||||
|
||||
## Do not edit or modify anything in this comment block.
|
||||
|
76
NEWS
76
NEWS
@ -1,75 +1,15 @@
|
||||
Version 1.0.17 (2006-08-31)
|
||||
* Add sndfile.hh C++ wrapper.
|
||||
* Update Win32 MinGW build instructions.
|
||||
* Minor bug fixes and cleanups.
|
||||
|
||||
Version 1.0.16 (2006-04-30)
|
||||
* Add support for Broadcast (BEXT) chunks in WAV files.
|
||||
* Implement new commands SFC_GET_SIGNAL_MAX and SFC_GET_MAX_ALL_CHANNELS.
|
||||
* Add support for RIFX (big endian WAV variant).
|
||||
* Fix configure script bugs.
|
||||
* Fix bug in INST and MARK chunk writing for AIFF files.
|
||||
|
||||
Version 1.0.15 (2006-03-16)
|
||||
* Fix some ia64 issues.
|
||||
* Fix precompiled DLL.
|
||||
* Minor bug fixes.
|
||||
|
||||
Version 1.0.14 (2006-02-19)
|
||||
* Really fix MinGW compile problems.
|
||||
* Minor bug fixes.
|
||||
|
||||
Version 1.0.13 (2006-01-21)
|
||||
* Fix for MinGW compiler problems.
|
||||
* Allow readin/write of instrument chunks from WAV and AIFF files.
|
||||
* Compile problem fix for Solaris compiler.
|
||||
* Minor cleanups and bug fixes.
|
||||
|
||||
Version 1.0.12 (2005-09-30)
|
||||
* Add support for FLAC and Apple's Core Audio Format (CAF).
|
||||
* Add virtual I/O interface (still needs docs).
|
||||
* Cygwin and other Win32 fixes.
|
||||
* Minor bug fixes and cleanups.
|
||||
|
||||
Version 1.0.11 (2004-11-15)
|
||||
* Add support for SD2 files.
|
||||
* Add read support for loop info in WAV and AIFF files.
|
||||
* Add more tests.
|
||||
* Improve type safety.
|
||||
* Minor optimisations and bug fixes.
|
||||
|
||||
Version 1.0.10 (2004-06-15)
|
||||
* Fix AIFF read/write mode bugs.
|
||||
* Add support for compiling Win32 DLLS using MinGW.
|
||||
* Fix problems resulting in failed compiles with gcc-2.95.
|
||||
* Improve test suite.
|
||||
* Minor bug fixes.
|
||||
|
||||
Version 1.0.9 (2004-03-30)
|
||||
* Add handling of AVR (Audio Visual Research) files.
|
||||
* Improve handling of WAVEFORMATEXTENSIBLE WAV files.
|
||||
* Fix for using pipes on Win32.
|
||||
|
||||
Version 1.0.8 (2004-03-14)
|
||||
* Correct peak chunk handing for files with > 16 tracks.
|
||||
* Fix for WAV files with huge number of CUE chunks.
|
||||
|
||||
Version 1.0.7 (2004-02-25)
|
||||
* Fix clip mode detection on ia64, MIPS and other CPUs.
|
||||
* Fix two MacOSX build problems.
|
||||
|
||||
Version 1.0.6 (2004-02-08)
|
||||
Version 1.0.6 (2003-11-05)
|
||||
* Added support for native Win32 file access API (Ross Bencina).
|
||||
* New mode to add clippling then a converting from float/double to integer
|
||||
would otherwise wrap around.
|
||||
* Fixed a bug in reading/writing files > 2Gig on Linux, Solaris and others.
|
||||
* New mode to add clippling then a converstion from float/double to
|
||||
integer would otherwise wrap around.
|
||||
* Add reading of IMA ADPCM encoded AIFF files.
|
||||
* Many minor bug fixes.
|
||||
* Other random fixes for Win32.
|
||||
|
||||
* Other fixes for Win32.
|
||||
|
||||
Version 1.0.5 (2003-05-03)
|
||||
* Added support for HTK files.
|
||||
* Added new function sf_open_fd() to allow for secure opening of temporary
|
||||
files as well as reading/writing sound files embedded within larger
|
||||
files as well as reading/writing sound files embedded within larger
|
||||
container files.
|
||||
* Added string support for AIFF files.
|
||||
* Minor bug fixes and code cleanups.
|
||||
@ -101,7 +41,7 @@ Version 1.0.0rc6 (2002-08-14)
|
||||
|
||||
Version 1.0.0rc5 (2002-08-10)
|
||||
* Release candidate 5 for the 1.0.0 series.
|
||||
* Changed the definition of sf_count_t which was causing problems when
|
||||
* Changed the definition of sf_count_t which was causing problems when
|
||||
libsndfile was compiled with other libraries (ie WxWindows).
|
||||
* Minor bug fixes.
|
||||
* Documentation cleanup.
|
||||
|
@ -19,7 +19,7 @@
|
||||
## Load data from the file given by @var{filename}.
|
||||
## @end deftypefn
|
||||
|
||||
## Author: Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
## Author: Erik de Castro Lopo <erikd@zip.com.au>
|
||||
## Description: Load the sound data from the given file name
|
||||
|
||||
function [data fs] = sndfile_load (filename)
|
||||
|
@ -20,7 +20,7 @@
|
||||
## program.
|
||||
## @end deftypefn
|
||||
|
||||
## Author: Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
## Author: Erik de Castro Lopo <erikd@zip.com.au>
|
||||
## Description: Play the given data as a sound file
|
||||
|
||||
function sndfile_play (data, fs)
|
||||
|
@ -20,7 +20,7 @@
|
||||
## the sample rate to @var{fs}.
|
||||
## @end deftypefn
|
||||
|
||||
## Author: Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
## Author: Erik de Castro Lopo <erikd@zip.com.au>
|
||||
## Description: Save data as a sound file
|
||||
|
||||
function sndfile_save (filename, data, fs)
|
||||
|
9
README
9
README
@ -1,4 +1,4 @@
|
||||
This is libsndfile, 1.0.17
|
||||
This is libsndfile, 1.0.6
|
||||
|
||||
libsndfile is a library of C routines for reading and writing
|
||||
files containing sampled audio data.
|
||||
@ -22,6 +22,9 @@ and test its functionality.
|
||||
The Win32/ directory contains files and documentation to allow libsndfile
|
||||
to compile under Win32 with the Microsoft Visual C++ compiler.
|
||||
|
||||
The MacOS/ directory contains files and documentation to allow libsndfile
|
||||
to compile under MacOS with the Metrowerks compiler.
|
||||
|
||||
The src/GSM610 directory contains code written by Jutta Degener and Carsten
|
||||
Bormann. Their original code can be found at :
|
||||
http://kbs.cs.tu-berlin.de/~jutta/toast.html
|
||||
@ -64,8 +67,8 @@ values for the following #defines (this would work for AmigaOS) :
|
||||
CONTACTS
|
||||
--------
|
||||
|
||||
libsndfile was written by Erik de Castro Lopo (erikd AT mega-nerd DOT com).
|
||||
libsndfile was written by Erik de Castro Lopo (erikd AT zipworld DOT com DOT au).
|
||||
The libsndfile home page is at :
|
||||
|
||||
http://www.mega-nerd.com/libsndfile/
|
||||
http://www.zip.com.au/~erikd/libsndfile/
|
||||
|
||||
|
31
ROtest/Makefile
Normal file
31
ROtest/Makefile
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
|
||||
TARGETS = ro_test
|
||||
|
||||
SNDFILE_LIB = ../src/.libs/libsndfile.a
|
||||
SNDFILE_INC = ../src
|
||||
SNDFILE_HEADER = $(SNDFILE_INC)/sndfile.h
|
||||
|
||||
all : $(TARGETS)
|
||||
|
||||
|
||||
libsndfile.a : $(SNDFILE_LIB)
|
||||
cp -f $(SNDFILE_LIB) .
|
||||
|
||||
sndfile.h : $(SNDFILE_HEADER)
|
||||
cp -f $(SNDFILE_HEADER) .
|
||||
|
||||
ro_test: ro_test.c libsndfile.a sndfile.h
|
||||
gcc -Wall ro_test.c -static libsndfile.a -o ro_test
|
||||
|
||||
clean:
|
||||
rm -f $(TARGETS)
|
||||
|
||||
check: $(TARGETS) ro.data
|
||||
./ro_test ro.data
|
||||
|
||||
# Do not edit or modify anything in this comment block.
|
||||
# The arch-tag line is a file identity tag for the GNU Arch
|
||||
# revision control system.
|
||||
#
|
||||
# arch-tag: baac643d-a847-486d-aa90-444bcb2d433d
|
12
ROtest/ro.dat
Normal file
12
ROtest/ro.dat
Normal file
@ -0,0 +1,12 @@
|
||||
# Read Only data.
|
||||
|
||||
@ filename, ro_type, channels, frames, data_hash
|
||||
|
||||
|
||||
"/home/erikd/Sound/SDS/mono24.sds", "Midi Sample Dump Standard", 1, 43879
|
||||
|
||||
# Do not edit or modify anything in this comment block.
|
||||
# The arch-tag line is a file identity tag for the GNU Arch
|
||||
# revision control system.
|
||||
#
|
||||
# arch-tag: eb2d25b6-c26a-4183-8b05-e1c212e14b7e
|
36
ROtest/ro_test.c
Normal file
36
ROtest/ro_test.c
Normal file
@ -0,0 +1,36 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "sndfile.h"
|
||||
|
||||
|
||||
typedef struct
|
||||
{ char filename [1024] ;
|
||||
char filetype [1024] ;
|
||||
|
||||
sf_count_t frames ;
|
||||
int channels ;
|
||||
|
||||
int data_hash ;
|
||||
|
||||
} RO_TEST_DATA ;
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
if (argc != 2)
|
||||
{ puts ("Error : expect a filename argument.") ;
|
||||
exit (1) ;
|
||||
}
|
||||
puts ("\nRead Only Test.\n---------------\n") ;
|
||||
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 1a24e55b-bbce-47dc-b895-26ef12ffe4dc
|
||||
*/
|
||||
|
@ -1,6 +1,8 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
EXTRA_DIST = README-precompiled-dll.txt testprog.c
|
||||
EXTRA_DIST = sndfile.h config.h libsndfile.def Makefile.msvc
|
||||
|
||||
|
||||
|
||||
## Do not edit or modify anything in this comment block.
|
||||
## The arch-tag line is a file identity tag for the GNU Arch
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
# Set the value of $(MSVCDir) for your installation.
|
||||
# Please note that none of the directory names are allowed to have spaces
|
||||
# in them. You must use the short name.
|
||||
# in them. You must use the short name
|
||||
#
|
||||
# "C:\Program Files\Microsoft Visual Studio\VC98" will not work.
|
||||
# "C:\Progra~1\Micros~1\VC98" will work.
|
||||
@ -13,14 +13,13 @@ LINK32=link.exe
|
||||
DLL_LINK_FLAGS=/nologo /dll /incremental:no /libpath:"$(MSVCDir)\Lib" /pdb:"libsndfile.pdb" /implib:".\libsndfile.lib" /machine:I386 /out:"libsndfile.dll"
|
||||
PROG_LINK_FLAGS=/nologo /incremental:no /libpath:"$(MSVCDir)\Lib" /pdb:"libsndfile.pdb" /machine:I386 /exetype:dynamic
|
||||
|
||||
CFLAGS=/nologo /MD /W1 /GX /O2 /I "$(MSVCDir)\Include" /I "src" /D "WIN32" /D "_USRDLL" /D "inline=__inline" /YX /FD
|
||||
CFLAGS=/nologo /MD /W1 /GX /O2 /I "$(MSVCDir)\Include" /I "src" /D "WIN32" /D "_USRDLL" /YX /FD
|
||||
|
||||
#====================================================================
|
||||
# Targets
|
||||
|
||||
ALL : libsndfile.dll \
|
||||
"sndfile-info.exe" \
|
||||
"sndfile-convert.exe" \
|
||||
"sndfile-play.exe" \
|
||||
"generate.exe"
|
||||
|
||||
@ -28,7 +27,6 @@ CLEAN :
|
||||
-@erase "src\*.obj"
|
||||
-@erase "src\G72x\*.obj"
|
||||
-@erase "src\GSM610\*.obj"
|
||||
-@erase "tests\*.obj"
|
||||
-@erase "tests\*.exe"
|
||||
|
||||
#====================================================================
|
||||
@ -56,8 +54,7 @@ LINK32_OBJS= \
|
||||
".\src\aiff.obj" \
|
||||
".\src\alaw.obj" \
|
||||
".\src\au.obj" \
|
||||
".\src\g72x.obj" \
|
||||
".\src\avr.obj" \
|
||||
".\src\au_g72x.obj" \
|
||||
".\src\common.obj" \
|
||||
".\src\double64.obj" \
|
||||
".\src\dwvw.obj" \
|
||||
@ -75,6 +72,7 @@ LINK32_OBJS= \
|
||||
".\src\raw.obj" \
|
||||
".\src\rx2.obj" \
|
||||
".\src\sd2.obj" \
|
||||
".\src\sfendian.obj" \
|
||||
".\src\sndfile.obj" \
|
||||
".\src\svx.obj" \
|
||||
".\src\txw.obj" \
|
||||
@ -93,21 +91,14 @@ LINK32_OBJS= \
|
||||
".\src\ogg.obj" \
|
||||
".\src\pvf.obj" \
|
||||
".\src\xi.obj" \
|
||||
".\src\htk.obj" \
|
||||
".\src\flac.obj" \
|
||||
".\src\caf.obj"
|
||||
".\src\htk.obj"
|
||||
|
||||
libsndfile.dll : $(LINK32_OBJS) ".\src\libsndfile.def"
|
||||
$(LINK32) $(DLL_LINK_FLAGS) /def:".\src\libsndfile.def" $(LINK32_OBJS)
|
||||
libsndfile.dll : $(LINK32_OBJS) ".\Win32\libsndfile.def"
|
||||
$(LINK32) $(DLL_LINK_FLAGS) /def:".\Win32\libsndfile.def" $(LINK32_OBJS)
|
||||
|
||||
"sndfile-info.exe" : ".\examples\sndfile-info.c"
|
||||
$(CPP) $(CFLAGS) /Fo".\examples\sndfile-info.obj" /c ".\examples\sndfile-info.c"
|
||||
$(LINK32) $(PROG_LINK_FLAGS) /out:"sndfile-info.exe" ".\examples\sndfile-info.obj" libsndfile.lib
|
||||
|
||||
"sndfile-convert.exe" : ".\examples\sndfile-convert.c"
|
||||
$(CPP) $(CFLAGS) /Fo".\examples\sndfile-convert.obj" /c ".\examples\sndfile-convert.c"
|
||||
$(LINK32) $(PROG_LINK_FLAGS) /out:"sndfile-convert.exe" ".\examples\sndfile-convert.obj" libsndfile.lib
|
||||
|
||||
"sndfile-play.exe" : ".\examples\sndfile-play.c"
|
||||
$(CPP) $(CFLAGS) /Fo".\examples\sndfile-play.obj" /c ".\examples\sndfile-play.c"
|
||||
$(LINK32) $(PROG_LINK_FLAGS) /out:"sndfile-play.exe" ".\examples\sndfile-play.obj" libsndfile.lib winmm.lib
|
||||
@ -133,8 +124,6 @@ TEST_PROGS= \
|
||||
".\tests\misc_test.exe" \
|
||||
".\tests\string_test.exe" \
|
||||
".\tests\win32_test.exe" \
|
||||
".\tests\stdio_test.exe" \
|
||||
".\tests\pipe_test.exe" \
|
||||
".\tests\benchmark.exe"
|
||||
|
||||
CHECK: $(TEST_PROGS)
|
||||
@ -184,13 +173,6 @@ CHECK: $(TEST_PROGS)
|
||||
-@echo ----------------------------------------------------------------------
|
||||
-@".\tests\sfversion.exe"
|
||||
-@echo " passed tests on AU files."
|
||||
-@echo ----------------------------------------------------------------------
|
||||
".\tests\write_read_test" caf
|
||||
".\tests\lossy_comp_test" caf_ulaw
|
||||
".\tests\lossy_comp_test" caf_alaw
|
||||
".\tests\misc_test" caf
|
||||
-@echo ----------------------------------------------------------------------
|
||||
-@echo `./sfversion` passed tests on CAF files."
|
||||
-@echo ----------------------------------------------------------------------
|
||||
".\tests\write_read_test" raw
|
||||
".\tests\lossy_comp_test" raw_ulaw
|
||||
@ -256,24 +238,6 @@ CHECK: $(TEST_PROGS)
|
||||
-@".\tests\sfversion.exe"
|
||||
-@echo " passed tests on MAT5 files."
|
||||
-@echo ----------------------------------------------------------------------
|
||||
".\tests\write_read_test" htk
|
||||
".\tests\misc_test" htk
|
||||
-@echo ----------------------------------------------------------------------
|
||||
-@".\tests\sfversion.exe"
|
||||
-@echo " passed tests on HTK files."
|
||||
-@echo ----------------------------------------------------------------------
|
||||
".\tests\write_read_test" avr
|
||||
".\tests\misc_test" avr
|
||||
-@echo ----------------------------------------------------------------------
|
||||
-@".\tests\sfversion.exe"
|
||||
-@echo " passed tests on AVR files."
|
||||
-@echo ----------------------------------------------------------------------
|
||||
-@".\tests\stdio_test.exe"
|
||||
-@".\tests\pipe_test.exe"
|
||||
-@echo ----------------------------------------------------------------------
|
||||
-@".\tests\sfversion.exe"
|
||||
-@echo " passed all tests."
|
||||
-@echo ----------------------------------------------------------------------
|
||||
|
||||
#====================================================================
|
||||
# C files in src\GSM610.
|
||||
@ -350,11 +314,8 @@ CHECK: $(TEST_PROGS)
|
||||
".\src\au.obj" : ".\src\au.c"
|
||||
$(CPP) $(CFLAGS) /Fo".\src\au.obj" /c ".\src\au.c"
|
||||
|
||||
".\src\g72x.obj" : ".\src\g72x.c"
|
||||
$(CPP) $(CFLAGS) /Fo".\src\g72x.obj" /c ".\src\g72x.c"
|
||||
|
||||
".\src\avr.obj" : ".\src\avr.c"
|
||||
$(CPP) $(CFLAGS) /Fo".\src\avr.obj" /c ".\src\avr.c"
|
||||
".\src\au_g72x.obj" : ".\src\au_g72x.c"
|
||||
$(CPP) $(CFLAGS) /Fo".\src\au_g72x.obj" /c ".\src\au_g72x.c"
|
||||
|
||||
".\src\common.obj" : ".\src\common.c"
|
||||
$(CPP) $(CFLAGS) /Fo".\src\common.obj" /c ".\src\common.c"
|
||||
@ -407,6 +368,9 @@ CHECK: $(TEST_PROGS)
|
||||
".\src\sd2.obj" : ".\src\sd2.c"
|
||||
$(CPP) $(CFLAGS) /Fo".\src\sd2.obj" /c ".\src\sd2.c"
|
||||
|
||||
".\src\sfendian.obj" : ".\src\sfendian.c"
|
||||
$(CPP) $(CFLAGS) /Fo".\src\sfendian.obj" /c ".\src\sfendian.c"
|
||||
|
||||
".\src\sndfile.obj" : ".\src\sndfile.c"
|
||||
$(CPP) $(CFLAGS) /Fo".\src\sndfile.obj" /c ".\src\sndfile.c"
|
||||
|
||||
@ -464,12 +428,6 @@ CHECK: $(TEST_PROGS)
|
||||
".\src\htk.obj" : ".\src\htk.c"
|
||||
$(CPP) $(CFLAGS) /Fo".\src\htk.obj" /c ".\src\htk.c"
|
||||
|
||||
".\src\flac.obj" : ".\src\flac.c"
|
||||
$(CPP) $(CFLAGS) /Fo".\src\flac.obj" /c ".\src\flac.c"
|
||||
|
||||
".\src\caf.obj" : ".\src\caf.c"
|
||||
$(CPP) $(CFLAGS) /Fo".\src\caf.obj" /c ".\src\caf.c"
|
||||
|
||||
#====================================================================
|
||||
# Object files for test programs.
|
||||
|
||||
@ -546,22 +504,6 @@ CHECK: $(TEST_PROGS)
|
||||
$(CPP) $(CFLAGS) /Fo".\tests\win32_test.obj" /c ".\tests\win32_test.c"
|
||||
$(LINK32) $(PROG_LINK_FLAGS) /out:".\tests\win32_test.exe" ".\tests\win32_test.obj"
|
||||
|
||||
".\tests\stdio_test.exe" : ".\tests\stdio_test.c" ".\tests\utils.obj"
|
||||
$(CPP) $(CFLAGS) /Fo".\tests\stdio_test.obj" /c ".\tests\stdio_test.c"
|
||||
$(LINK32) $(PROG_LINK_FLAGS) /out:".\tests\stdio_test.exe" ".\tests\stdio_test.obj" ".\tests\utils.obj" libsndfile.lib
|
||||
|
||||
".\tests\pipe_test.exe" : ".\tests\pipe_test.c" ".\tests\utils.obj"
|
||||
$(CPP) $(CFLAGS) /Fo".\tests\pipe_test.obj" /c ".\tests\pipe_test.c"
|
||||
$(LINK32) $(PROG_LINK_FLAGS) /out:".\tests\pipe_test.exe" ".\tests\pipe_test.obj" ".\tests\utils.obj" libsndfile.lib
|
||||
|
||||
# ".\tests\stdin_test.exe" : ".\tests\stdin_test.c" ".\tests\utils.obj"
|
||||
# $(CPP) $(CFLAGS) /Fo".\tests\stdin_test.obj" /c ".\tests\stdin_test.c"
|
||||
# $(LINK32) $(PROG_LINK_FLAGS) /out:".\tests\stdin_test.exe" ".\tests\stdin_test.obj" ".\tests\utils.obj" libsndfile.lib
|
||||
#
|
||||
# ".\tests\stdout_test.exe" : ".\tests\stdout_test.c" ".\tests\utils.obj"
|
||||
# $(CPP) $(CFLAGS) /Fo".\tests\stdout_test.obj" /c ".\tests\stdout_test.c"
|
||||
# $(LINK32) $(PROG_LINK_FLAGS) /out:".\tests\stdout_test.exe" ".\tests\stdout_test.obj" ".\tests\utils.obj" libsndfile.lib
|
||||
|
||||
".\tests\benchmark.exe" : ".\tests\benchmark.c"
|
||||
$(CPP) $(CFLAGS) /Fo".\tests\benchmark.obj" /c ".\tests\benchmark.c"
|
||||
$(LINK32) $(PROG_LINK_FLAGS) /out:".\tests\benchmark.exe" ".\tests\benchmark.obj" ".\tests\utils.obj" libsndfile.lib
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2002,2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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
|
||||
@ -45,12 +45,6 @@
|
||||
/* Major version of GCC or 3 otherwise. */
|
||||
/* #undef GCC_MAJOR_VERSION */
|
||||
|
||||
/* Define to 1 if you have the <alsa/asoundlib.h> header file. */
|
||||
/* #undef HAVE_ALSA_ASOUNDLIB_H */
|
||||
|
||||
/* Define to 1 if you have the <byteswap.h> header file. */
|
||||
/* #undef HAVE_BYTESWAP_H */
|
||||
|
||||
/* Define to 1 if you have the `calloc' function. */
|
||||
#define HAVE_CALLOC 1
|
||||
|
||||
@ -61,23 +55,13 @@
|
||||
#define HAVE_DECL_S_IRGRP 0
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
/* #undef HAVE_DLFCN_H */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the <endian.h> header file. */
|
||||
/* #undef HAVE_ENDIAN_H */
|
||||
#define HAVE_ENDIAN_H 1
|
||||
|
||||
/* Define to 1 if you have the `fdatasync' function. */
|
||||
|
||||
/* #undef HAVE_FDATASYNC */
|
||||
|
||||
/* Define to 1 if you have libflac 1.1.1 */
|
||||
/* #undef HAVE_FLAC_1_1_1 1 */
|
||||
|
||||
/* Define to 1 if you have the <FLAC/all.h> header file. */
|
||||
/* #undef HAVE_FLAC_ALL_H 1 */
|
||||
|
||||
/* Set to 1 if the compile supports the struct hack. */
|
||||
#define HAVE_FLEXIBLE_ARRAY 1
|
||||
#define HAVE_FDATASYNC 1
|
||||
|
||||
/* Define to 1 if you have the `floor' function. */
|
||||
#define HAVE_FLOOR 1
|
||||
@ -92,29 +76,23 @@
|
||||
#define HAVE_FSTAT 1
|
||||
|
||||
/* Define to 1 if you have the `fsync' function. */
|
||||
/* #undef HAVE_FSYNC */
|
||||
#define HAVE_FSYNC 1
|
||||
|
||||
/* Define to 1 if you have the `ftruncate' function. */
|
||||
/* #undef HAVE_FTRUNCATE */
|
||||
|
||||
/* Define to 1 if you have the `getpagesize' function. */
|
||||
#define HAVE_GETPAGESIZE 1
|
||||
#define HAVE_FTRUNCATE 1
|
||||
|
||||
/* Define to 1 if you have the `gmtime' function. */
|
||||
#define HAVE_GMTIME 1
|
||||
|
||||
/* Define to 1 if you have the `gmtime_r' function. */
|
||||
/* #undef HAVE_GMTIME_R */
|
||||
/* #undefine HAVE_GMTIME_R */
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
/* #undef HAVE_INTTYPES_H */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the `m' library (-lm). */
|
||||
#define HAVE_LIBM 1
|
||||
|
||||
/* Define to 1 if you have the <locale.h> header file. */
|
||||
/* #undef HAVE_LOCALE_H */
|
||||
|
||||
/* Define if you have C99's lrint function. */
|
||||
/* #undef HAVE_LRINT */
|
||||
|
||||
@ -130,17 +108,17 @@
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the `mmap' function. */
|
||||
/* #undef HAVE_MMAP */
|
||||
/* Define to 1 if you have the <mmreg.h> header file. */
|
||||
/* #undef HAVE_MMREG_H */
|
||||
|
||||
/* Define to 1 if you have the `open' function. */
|
||||
#define HAVE_OPEN 1
|
||||
|
||||
/* Define to 1 if you have the `pread' function. */
|
||||
/* #undef HAVE_PREAD */
|
||||
#define HAVE_PREAD 1
|
||||
|
||||
/* Define to 1 if you have the `pwrite' function. */
|
||||
/* #undef HAVE_PWRITE */
|
||||
#define HAVE_PWRITE 1
|
||||
|
||||
/* Define to 1 if you have the `read' function. */
|
||||
#define HAVE_READ 1
|
||||
@ -148,20 +126,11 @@
|
||||
/* Define to 1 if you have the `realloc' function. */
|
||||
#define HAVE_REALLOC 1
|
||||
|
||||
/* Define to 1 if you have the `setlocale' function. */
|
||||
/* #undef HAVE_SETLOCALE */
|
||||
|
||||
/* Define to 1 if you have the `snprintf' function. */
|
||||
#define HAVE_SNPRINTF 1
|
||||
|
||||
/* Set to 1 if you have libsqlite3. */
|
||||
/* #undef HAVE_SQLITE3 */
|
||||
|
||||
/* Define to 1 if the system has the type `ssize_t'. */
|
||||
/* #undef HAVE_SSIZE_T */
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
/* #undef HAVE_STDINT_H */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
@ -179,7 +148,7 @@
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
|
||||
/* #undef HAVE_SYS_WAIT_H */
|
||||
#define HAVE_SYS_WAIT_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
/* #undef HAVE_UNISTD_H */
|
||||
@ -187,12 +156,12 @@
|
||||
/* Define to 1 if you have the `vsnprintf' function. */
|
||||
#define HAVE_VSNPRINTF 1
|
||||
|
||||
/* Define to 1 if you have the <wintypes.h> header file. */
|
||||
/* #undef HAVE_WINTYPES_H */
|
||||
|
||||
/* Define to 1 if you have the `write' function. */
|
||||
#define HAVE_WRITE 1
|
||||
|
||||
/* Set to 1 if compiling for MacOSX */
|
||||
#define OS_IS_MACOSX 0
|
||||
|
||||
/* Set to 1 if compiling for Win32 */
|
||||
#define OS_IS_WIN32 1
|
||||
|
||||
@ -200,22 +169,26 @@
|
||||
#define PACKAGE "libsndfile"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "erikd@mega-nerd.com"
|
||||
#define PACKAGE_BUGREPORT "<erikd@zip.com.au>"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "libsndfile"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "libsndfile 1.0.13"
|
||||
#define PACKAGE_STRING "libsndfile 1.1.0pre1"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "libsndfile"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "1.0.13"
|
||||
<<<<<<< diff from left file
|
||||
#define PACKAGE_VERSION ""
|
||||
========
|
||||
#define PACKAGE_VERSION "1.1.0pre1"
|
||||
|
||||
/* Set to maximum allowed value of sf_count_t type. */
|
||||
#define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFFi64
|
||||
#define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFFLL
|
||||
>>>>>>> diff from right file
|
||||
|
||||
/* The size of a `double', as computed by sizeof. */
|
||||
#define SIZEOF_DOUBLE 8
|
||||
@ -226,20 +199,14 @@
|
||||
/* The size of a `int', as computed by sizeof. */
|
||||
#define SIZEOF_INT 4
|
||||
|
||||
/* The size of a `int64_t', as computed by sizeof. */
|
||||
#define SIZEOF_INT64_T 0
|
||||
|
||||
/* The size of a `loff_t', as computed by sizeof. */
|
||||
#define SIZEOF_LOFF_T 0
|
||||
|
||||
/* The size of a `long', as computed by sizeof. */
|
||||
#define SIZEOF_LONG 4
|
||||
|
||||
/* The size of a `long long', as computed by sizeof. */
|
||||
#define SIZEOF_LONG_LONG 0
|
||||
|
||||
/* The size of a `off64_t', as computed by sizeof. */
|
||||
/* #undef SIZEOF_OFF64_T */
|
||||
#define SIZEOF_OFF64_T 0
|
||||
|
||||
/* The size of a `off_t', as computed by sizeof. */
|
||||
#define SIZEOF_OFF_T 4
|
||||
@ -263,23 +230,21 @@
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Set to long if unknown. */
|
||||
#define TYPEOF_SF_COUNT_T loff_t
|
||||
|
||||
/* Set to 1 to use the native windows API */
|
||||
#define USE_WINDOWS_API 1
|
||||
#define TYPEOF_SF_COUNT_T __int64_t
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "1.0.13"
|
||||
#define VERSION "1.1.0pre1"
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
/* #undef _FILE_OFFSET_BITS */
|
||||
/*
|
||||
[Number], [of], [bits], [in], [a], [file], [offset,], [on], [hosts], [where], [this], [is], [settable.]
|
||||
*/
|
||||
/* #undef _FILE_OFFSET_BITS 64 */
|
||||
|
||||
/* Define to make fseeko etc. visible, on some hosts. */
|
||||
/* #undef _LARGEFILE_SOURCE */
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
/* #undef _LARGE_FILES */
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
|
81
Win32/libsndfile.def
Normal file
81
Win32/libsndfile.def
Normal file
@ -0,0 +1,81 @@
|
||||
LIBRARY libsndfile.dll
|
||||
EXPORTS
|
||||
|
||||
;
|
||||
; open, close, command
|
||||
;
|
||||
sf_command @1
|
||||
sf_open @2
|
||||
sf_close @3
|
||||
|
||||
;
|
||||
; seeking
|
||||
;
|
||||
sf_seek @4
|
||||
|
||||
;
|
||||
; error functions
|
||||
;
|
||||
sf_error @7
|
||||
sf_perror @8
|
||||
sf_error_str @9
|
||||
sf_error_number @10
|
||||
|
||||
;
|
||||
; misc stuff
|
||||
;
|
||||
sf_format_check @11
|
||||
|
||||
;
|
||||
; reading
|
||||
;
|
||||
sf_read_raw @16
|
||||
|
||||
sf_readf_short @17
|
||||
sf_readf_int @18
|
||||
sf_readf_float @19
|
||||
sf_readf_double @20
|
||||
|
||||
sf_read_short @21
|
||||
sf_read_int @22
|
||||
sf_read_float @23
|
||||
sf_read_double @24
|
||||
|
||||
;
|
||||
; writing
|
||||
;
|
||||
sf_write_raw @32
|
||||
|
||||
sf_writef_short @33
|
||||
sf_writef_int @34
|
||||
sf_writef_float @35
|
||||
sf_writef_double @36
|
||||
|
||||
sf_write_short @37
|
||||
sf_write_int @38
|
||||
sf_write_float @39
|
||||
sf_write_double @40
|
||||
|
||||
|
||||
;
|
||||
; Added more recently
|
||||
;
|
||||
sf_strerror @50
|
||||
|
||||
sf_get_string @60
|
||||
sf_set_string @61
|
||||
|
||||
sf_open_fd @70
|
||||
|
||||
; Maybe one day. Maybe.
|
||||
; sf_dither_short @70
|
||||
; sf_dither_int @71
|
||||
; sf_dither_float @72
|
||||
; sf_dither_double @73
|
||||
|
||||
; Do not edit or modify anything in this comment block.
|
||||
; The arch-tag line is a file identity tag for the GNU Arch
|
||||
; revision control system.
|
||||
;
|
||||
; arch-tag: ba9144f1-6018-4751-a642-e531257f2296
|
||||
|
134
Win32/sndfile.h
134
Win32/sndfile.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2006 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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
|
||||
@ -20,7 +20,7 @@
|
||||
** sndfile.h -- system-wide definitions
|
||||
**
|
||||
** API documentation is in the doc/ directory of the source code tarball
|
||||
** and at http://www.mega-nerd.com/libsndfile/api.html.
|
||||
** and at http://www.zip.com.au/~erikd/libsndfile/api.html.
|
||||
*/
|
||||
|
||||
#ifndef SNDFILE_H
|
||||
@ -68,11 +68,6 @@ enum
|
||||
SF_FORMAT_XI = 0x0F0000, /* Fasttracker 2 Extended Instrument */
|
||||
SF_FORMAT_HTK = 0x100000, /* HMM Tool Kit format */
|
||||
SF_FORMAT_SDS = 0x110000, /* Midi Sample Dump Standard */
|
||||
SF_FORMAT_AVR = 0x120000, /* Audio Visual Research */
|
||||
SF_FORMAT_WAVEX = 0x130000, /* MS WAVE with WAVEFORMATEX */
|
||||
SF_FORMAT_SD2 = 0x160000, /* Sound Designer 2 */
|
||||
SF_FORMAT_FLAC = 0x170000, /* FLAC lossless file format */
|
||||
SF_FORMAT_CAF = 0x180000, /* Core Audio File format */
|
||||
|
||||
/* Subtypes from here on. */
|
||||
|
||||
@ -106,6 +101,7 @@ enum
|
||||
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. */
|
||||
@ -132,7 +128,6 @@ enum
|
||||
SFC_GET_NORM_FLOAT = 0x1011,
|
||||
SFC_SET_NORM_DOUBLE = 0x1012,
|
||||
SFC_SET_NORM_FLOAT = 0x1013,
|
||||
SFC_SET_SCALE_FLOAT_INT_READ = 0x1014,
|
||||
|
||||
SFC_GET_SIMPLE_FORMAT_COUNT = 0x1020,
|
||||
SFC_GET_SIMPLE_FORMAT = 0x1021,
|
||||
@ -169,11 +164,6 @@ enum
|
||||
SFC_SET_CLIPPING = 0x10C0,
|
||||
SFC_GET_CLIPPING = 0x10C1,
|
||||
|
||||
SFC_GET_INSTRUMENT = 0x10D0,
|
||||
SFC_SET_INSTRUMENT = 0x10D1,
|
||||
|
||||
SFC_GET_LOOP_INFO = 0x10E0,
|
||||
|
||||
/* Following commands for testing only. */
|
||||
SFC_TEST_IEEE_FLOAT_REPLACE = 0x6001,
|
||||
|
||||
@ -203,14 +193,6 @@ enum
|
||||
SF_STR_DATE = 0x06
|
||||
} ;
|
||||
|
||||
/*
|
||||
** Use the following as the start and end index when doing metadata
|
||||
** transcoding.
|
||||
*/
|
||||
|
||||
#define SF_STR_FIRST SF_STR_TITLE
|
||||
#define SF_STR_LAST SF_STR_DATE
|
||||
|
||||
enum
|
||||
{ /* True and false */
|
||||
SF_FALSE = 0,
|
||||
@ -222,7 +204,7 @@ enum
|
||||
SFM_RDWR = 0x30
|
||||
} ;
|
||||
|
||||
/* Public error values. These are guaranteed to remain unchanged for the duration
|
||||
/* Pubic error values. These are guaranteed to remain unchanged for the duration
|
||||
** of the library major version number.
|
||||
** There are also a large number of private error numbers which are internal to
|
||||
** the library which can change at any time.
|
||||
@ -231,17 +213,16 @@ enum
|
||||
enum
|
||||
{ SF_ERR_NO_ERROR = 0,
|
||||
SF_ERR_UNRECOGNISED_FORMAT = 1,
|
||||
SF_ERR_SYSTEM = 2,
|
||||
SF_ERR_MALFORMED_FILE = 3,
|
||||
SF_ERR_UNSUPPORTED_ENCODING = 4
|
||||
SF_ERR_SYSTEM = 2
|
||||
} ;
|
||||
|
||||
/* A SNDFILE* pointer can be passed around much like stdio.h's FILE* pointer. */
|
||||
|
||||
typedef struct SNDFILE_tag SNDFILE ;
|
||||
typedef void SNDFILE ;
|
||||
|
||||
|
||||
/* The following typedef is system specific and is defined when libsndfile is.
|
||||
** compiled. sf_count_t can be one of loff_t (Linux), off_t (*BSD),
|
||||
** compiled. sf_count_t can be one of loff_t (Linux), off_t (*BSD),
|
||||
** off64_t (Solaris), __int64_t (Win32) etc.
|
||||
*/
|
||||
|
||||
@ -278,8 +259,8 @@ typedef struct SF_INFO SF_INFO ;
|
||||
|
||||
typedef struct
|
||||
{ int format ;
|
||||
const char *name ;
|
||||
const char *extension ;
|
||||
const char *name ;
|
||||
const char *extension ;
|
||||
} SF_FORMAT_INFO ;
|
||||
|
||||
/*
|
||||
@ -312,71 +293,6 @@ typedef struct
|
||||
sf_count_t length ;
|
||||
} SF_EMBED_FILE_INFO ;
|
||||
|
||||
/*
|
||||
** Structs used to retrieve music sample information from a file.
|
||||
*/
|
||||
|
||||
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 ;
|
||||
|
||||
|
||||
|
||||
/* Struct used to retrieve loop information from a file.*/
|
||||
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 ;
|
||||
|
||||
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) ;
|
||||
|
||||
struct SF_VIRTUAL_IO
|
||||
{ sf_vio_get_filelen get_filelen ;
|
||||
sf_vio_seek seek ;
|
||||
sf_vio_read read ;
|
||||
sf_vio_write write ;
|
||||
sf_vio_tell tell ;
|
||||
} ;
|
||||
|
||||
typedef struct SF_VIRTUAL_IO SF_VIRTUAL_IO ;
|
||||
|
||||
/* Open the specified file for read, write or both. On error, this will
|
||||
** return a NULL pointer. To find the error number, pass a NULL SNDFILE
|
||||
@ -400,8 +316,6 @@ SNDFILE* sf_open (const char *path, int mode, SF_INFO *sfinfo) ;
|
||||
|
||||
SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ;
|
||||
|
||||
SNDFILE* sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) ;
|
||||
|
||||
/* sf_error () returns a error number which can be translated to a text
|
||||
** string using sf_error_number().
|
||||
*/
|
||||
@ -416,7 +330,6 @@ const char* sf_strerror (SNDFILE *sndfile) ;
|
||||
|
||||
/* sf_error_number () allows the retrieval of the error string for each internal
|
||||
** error number.
|
||||
**
|
||||
*/
|
||||
|
||||
const char* sf_error_number (int errnum) ;
|
||||
@ -468,7 +381,7 @@ const char* sf_get_string (SNDFILE *sndfile, int str_type) ;
|
||||
*/
|
||||
|
||||
sf_count_t sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ;
|
||||
sf_count_t sf_write_raw (SNDFILE *sndfile, const void *ptr, sf_count_t bytes) ;
|
||||
sf_count_t sf_write_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ;
|
||||
|
||||
/* Functions for reading and writing the data chunk in terms of frames.
|
||||
** The number of items actually read/written = frames * number of channels.
|
||||
@ -481,16 +394,16 @@ sf_count_t sf_write_raw (SNDFILE *sndfile, const void *ptr, sf_count_t bytes) ;
|
||||
*/
|
||||
|
||||
sf_count_t sf_readf_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ;
|
||||
sf_count_t sf_writef_short (SNDFILE *sndfile, const short *ptr, sf_count_t frames) ;
|
||||
sf_count_t sf_writef_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ;
|
||||
|
||||
sf_count_t sf_readf_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ;
|
||||
sf_count_t sf_writef_int (SNDFILE *sndfile, const int *ptr, sf_count_t frames) ;
|
||||
sf_count_t sf_writef_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ;
|
||||
|
||||
sf_count_t sf_readf_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ;
|
||||
sf_count_t sf_writef_float (SNDFILE *sndfile, const float *ptr, sf_count_t frames) ;
|
||||
sf_count_t sf_writef_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ;
|
||||
|
||||
sf_count_t sf_readf_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ;
|
||||
sf_count_t sf_writef_double (SNDFILE *sndfile, const double *ptr, sf_count_t frames) ;
|
||||
sf_count_t sf_writef_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ;
|
||||
|
||||
/* Functions for reading and writing the data chunk in terms of items.
|
||||
** Otherwise similar to above.
|
||||
@ -498,16 +411,16 @@ sf_count_t sf_writef_double (SNDFILE *sndfile, const double *ptr, sf_count_t fra
|
||||
*/
|
||||
|
||||
sf_count_t sf_read_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ;
|
||||
sf_count_t sf_write_short (SNDFILE *sndfile, const short *ptr, sf_count_t items) ;
|
||||
sf_count_t sf_write_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ;
|
||||
|
||||
sf_count_t sf_read_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ;
|
||||
sf_count_t sf_write_int (SNDFILE *sndfile, const int *ptr, sf_count_t items) ;
|
||||
sf_count_t sf_write_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ;
|
||||
|
||||
sf_count_t sf_read_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ;
|
||||
sf_count_t sf_write_float (SNDFILE *sndfile, const float *ptr, sf_count_t items) ;
|
||||
sf_count_t sf_write_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ;
|
||||
|
||||
sf_count_t sf_read_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ;
|
||||
sf_count_t sf_write_double (SNDFILE *sndfile, const double *ptr, sf_count_t items) ;
|
||||
sf_count_t sf_write_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ;
|
||||
|
||||
/* Close the SNDFILE and clean up all memory allocations associated with this
|
||||
** file.
|
||||
@ -516,13 +429,6 @@ sf_count_t sf_write_double (SNDFILE *sndfile, const double *ptr, sf_count_t item
|
||||
|
||||
int sf_close (SNDFILE *sndfile) ;
|
||||
|
||||
/* If the file is opened SFM_WRITE or SFM_RDWR, call fsync() on the file
|
||||
** to force the writing of data to disk. If the file is opened SFM_READ
|
||||
** no action is taken.
|
||||
*/
|
||||
|
||||
void sf_write_sync (SNDFILE *sndfile) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif /* __cplusplus */
|
||||
@ -531,7 +437,7 @@ void sf_write_sync (SNDFILE *sndfile) ;
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 906bb197-18f2-4f66-a395-b4722bab5114
|
||||
|
150
acinclude.m4
150
acinclude.m4
@ -7,7 +7,7 @@ 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],
|
||||
AC_DEFUN(AC_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` || {
|
||||
@ -30,7 +30,7 @@ changequote([, ])dnl
|
||||
|
||||
dnl Internal subroutine of AC_SYS_EXTRA_LARGEFILE.
|
||||
dnl AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(VAR, VAL)
|
||||
AC_DEFUN([AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND],
|
||||
AC_DEFUN(AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND,
|
||||
[case $2 in
|
||||
no) ;;
|
||||
?*)
|
||||
@ -42,7 +42,7 @@ AC_DEFUN([AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND],
|
||||
|
||||
dnl Internal subroutine of AC_SYS_EXTRA_LARGEFILE.
|
||||
dnl AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE(C-MACRO, CACHE-VAR, COMMENT, CODE-TO-SET-DEFAULT)
|
||||
AC_DEFUN([AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE],
|
||||
AC_DEFUN(AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE,
|
||||
[AC_CACHE_CHECK([for $1], $2,
|
||||
[$2=no
|
||||
changequote(, )dnl
|
||||
@ -61,7 +61,7 @@ changequote([, ])dnl
|
||||
AC_DEFINE_UNQUOTED([$1], [$]$2, [$3])
|
||||
fi])
|
||||
|
||||
AC_DEFUN([AC_SYS_EXTRA_LARGEFILE],
|
||||
AC_DEFUN(AC_SYS_EXTRA_LARGEFILE,
|
||||
[AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_ARG_ENABLE(largefile,
|
||||
[ --disable-largefile omit support for large files])
|
||||
@ -70,7 +70,7 @@ AC_DEFUN([AC_SYS_EXTRA_LARGEFILE],
|
||||
AC_SYS_EXTRA_LARGEFILE_FLAGS(CFLAGS)
|
||||
AC_SYS_EXTRA_LARGEFILE_FLAGS(LDFLAGS)
|
||||
AC_SYS_EXTRA_LARGEFILE_FLAGS(LIBS)
|
||||
|
||||
|
||||
for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
|
||||
case "$ac_flag" in
|
||||
no) ;;
|
||||
@ -111,12 +111,6 @@ AC_DEFUN([AC_SYS_EXTRA_LARGEFILE],
|
||||
esac])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
dnl @synopsis AC_C_FIND_ENDIAN
|
||||
dnl
|
||||
dnl Determine endian-ness of target processor.
|
||||
@ -275,46 +269,6 @@ else
|
||||
|
||||
)# AC_C_FIND_ENDIAN
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
dnl @synopsis AC_C99_FLEXIBLE_ARRAY
|
||||
dnl
|
||||
dnl Dose the compiler support the 1999 ISO C Standard "stuct hack".
|
||||
dnl @version 1.1 Mar 15 2004
|
||||
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.
|
||||
|
||||
AC_DEFUN([AC_C99_FLEXIBLE_ARRAY],
|
||||
[AC_CACHE_CHECK(C99 struct flexible array support,
|
||||
ac_cv_c99_flexible_array,
|
||||
|
||||
# Initialize to unknown
|
||||
ac_cv_c99_flexible_array=no
|
||||
|
||||
AC_TRY_LINK([[
|
||||
#include <stdlib.h>
|
||||
typedef struct {
|
||||
int k;
|
||||
char buffer [] ;
|
||||
} MY_STRUCT ;
|
||||
]],
|
||||
[ MY_STRUCT *p = calloc (1, sizeof (MY_STRUCT) + 42); ],
|
||||
ac_cv_c99_flexible_array=yes,
|
||||
ac_cv_c99_flexible_array=no
|
||||
))]
|
||||
) # AC_C99_FLEXIBLE_ARRAY
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
dnl @synopsis AC_C99_FUNC_LRINT
|
||||
dnl
|
||||
dnl Check whether C99's lrint function is available.
|
||||
@ -332,7 +286,7 @@ AC_DEFUN([AC_C99_FUNC_LRINT],
|
||||
ac_cv_c99_lrint,
|
||||
[
|
||||
lrint_save_CFLAGS=$CFLAGS
|
||||
CFLAGS="-lm"
|
||||
CFLAGS="-O2 -lm"
|
||||
AC_TRY_LINK([
|
||||
#define _ISOC9X_SOURCE 1
|
||||
#define _ISOC99_SOURCE 1
|
||||
@ -367,6 +321,8 @@ AC_DEFUN([AC_C99_FUNC_LRINTF],
|
||||
[AC_CACHE_CHECK(for lrintf,
|
||||
ac_cv_c99_lrintf,
|
||||
[
|
||||
lrintf_save_CFLAGS=$CFLAGS
|
||||
CFLAGS="-O2 -lm"
|
||||
AC_TRY_LINK([
|
||||
#define _ISOC9X_SOURCE 1
|
||||
#define _ISOC99_SOURCE 1
|
||||
@ -375,6 +331,9 @@ AC_TRY_LINK([
|
||||
|
||||
#include <math.h>
|
||||
], if (!lrintf(3.14159)) lrintf(2.7183);, ac_cv_c99_lrintf=yes, ac_cv_c99_lrintf=no)
|
||||
|
||||
CFLAGS=$lrintf_save_CFLAGS
|
||||
|
||||
])
|
||||
|
||||
if test "$ac_cv_c99_lrintf" = yes; then
|
||||
@ -382,10 +341,6 @@ if test "$ac_cv_c99_lrintf" = yes; then
|
||||
[Define if you have C99's lrintf function.])
|
||||
fi
|
||||
])# AC_C99_FUNC_LRINTF
|
||||
|
||||
|
||||
|
||||
|
||||
dnl @synopsis AC_C99_FUNC_LLRINT
|
||||
dnl
|
||||
dnl Check whether C99's llrint function is available.
|
||||
@ -402,6 +357,8 @@ AC_DEFUN([AC_C99_FUNC_LLRINT],
|
||||
[AC_CACHE_CHECK(for llrint,
|
||||
ac_cv_c99_llrint,
|
||||
[
|
||||
llrint_save_CFLAGS=$CFLAGS
|
||||
CFLAGS="-O2 -lm"
|
||||
AC_TRY_LINK([
|
||||
#define _ISOC9X_SOURCE 1
|
||||
#define _ISOC99_SOURCE 1
|
||||
@ -411,6 +368,9 @@ AC_TRY_LINK([
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
], int64_t x ; x = llrint(3.14159) ;, ac_cv_c99_llrint=yes, ac_cv_c99_llrint=no)
|
||||
|
||||
CFLAGS=$llrint_save_CFLAGS
|
||||
|
||||
])
|
||||
|
||||
if test "$ac_cv_c99_llrint" = yes; then
|
||||
@ -418,9 +378,6 @@ if test "$ac_cv_c99_llrint" = yes; then
|
||||
[Define if you have C99's llrint function.])
|
||||
fi
|
||||
])# AC_C99_FUNC_LLRINT
|
||||
|
||||
|
||||
|
||||
dnl @synopsis AC_C_CLIP_MODE
|
||||
dnl
|
||||
dnl Determine the clipping mode when converting float to int.
|
||||
@ -435,6 +392,10 @@ dnl provided "as is" without express or implied warranty.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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.
|
||||
@ -447,6 +408,7 @@ AC_DEFUN([AC_C_CLIP_MODE],
|
||||
ac_cv_c_clip_positive=unknown
|
||||
ac_cv_c_clip_negative=unknown
|
||||
|
||||
|
||||
if test $ac_cv_c_clip_positive = unknown ; then
|
||||
AC_TRY_RUN(
|
||||
[[
|
||||
@ -456,26 +418,24 @@ if test $ac_cv_c_clip_positive = unknown ; then
|
||||
#define __USE_ISOC9X 1
|
||||
#include <math.h>
|
||||
int main (void)
|
||||
{ double fval ;
|
||||
int k, ival ;
|
||||
{ double fval [] = { 1.0 * 0x7FFFFFFF, 1.1 * 0x7FFFFFFF, 1.2 * 0x7FFFFFFF } ;
|
||||
|
||||
fval = 1.0 * 0x7FFFFFFF ;
|
||||
for (k = 0 ; k < 100 ; k++)
|
||||
{ ival = (lrint (fval)) >> 24 ;
|
||||
if (ival != 127)
|
||||
return 1 ;
|
||||
|
||||
fval *= 1.2499999 ;
|
||||
} ;
|
||||
|
||||
if (lrint (fval [0]) < 0)
|
||||
return 0 ;
|
||||
|
||||
if (lrint (fval [1]) < 0)
|
||||
return 0 ;
|
||||
|
||||
if (lrint (fval [2]) < 0)
|
||||
return 0 ;
|
||||
|
||||
return 1 ;
|
||||
}
|
||||
]],
|
||||
ac_cv_c_clip_positive=yes,
|
||||
ac_cv_c_clip_positive=no,
|
||||
]], , ac_cv_c_clip_positive=yes,
|
||||
ac_cv_c_clip_positive=unknown
|
||||
)
|
||||
|
||||
|
||||
AC_TRY_RUN(
|
||||
[[
|
||||
#define _ISOC9X_SOURCE 1
|
||||
@ -484,25 +444,23 @@ if test $ac_cv_c_clip_positive = unknown ; then
|
||||
#define __USE_ISOC9X 1
|
||||
#include <math.h>
|
||||
int main (void)
|
||||
{ double fval ;
|
||||
int k, ival ;
|
||||
{ double fval [] = { -8.0 * 0x10000000, -8.8 * 0x10000000, -9.6 * 0x10000000 } ;
|
||||
|
||||
fval = -8.0 * 0x10000000 ;
|
||||
for (k = 0 ; k < 100 ; k++)
|
||||
{ ival = (lrint (fval)) >> 24 ;
|
||||
if (ival != -128)
|
||||
return 1 ;
|
||||
|
||||
fval *= 1.2499999 ;
|
||||
} ;
|
||||
|
||||
if (lrint (fval [0]) > 0)
|
||||
return 0 ;
|
||||
|
||||
if (lrint (fval [1]) > 0)
|
||||
return 0 ;
|
||||
|
||||
if (lrint (fval [2]) > 0)
|
||||
return 0 ;
|
||||
|
||||
return 1 ;
|
||||
}
|
||||
]],
|
||||
ac_cv_c_clip_negative=yes,
|
||||
ac_cv_c_clip_negative=no,
|
||||
]], , ac_cv_c_clip_negative=yes,
|
||||
ac_cv_c_clip_negative=unknown
|
||||
)
|
||||
|
||||
fi
|
||||
|
||||
if test $ac_cv_c_clip_positive = yes ; then
|
||||
@ -540,24 +498,6 @@ case "$ac_cv_c_clip_positive$ac_cv_c_clip_negative" in
|
||||
)# AC_C_CLIP_MODE
|
||||
|
||||
|
||||
dnl @synopsis AC_ADD_CFLAGS
|
||||
dnl
|
||||
dnl Add the given option to CFLAGS, if it doesn't break the compiler
|
||||
|
||||
AC_DEFUN([AC_ADD_CFLAGS],
|
||||
[AC_MSG_CHECKING([if $CC accepts $1])
|
||||
ac_add_cflags__old_cflags="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $1"
|
||||
AC_TRY_LINK([#include <stdio.h>],
|
||||
[printf("Hello, World!\n"); return 0;],
|
||||
AC_MSG_RESULT([yes]),
|
||||
AC_MSG_RESULT([no])
|
||||
CFLAGS="$ac_add_cflags__old_cflags")
|
||||
])
|
||||
|
||||
|
||||
|
||||
|
||||
ifelse(dnl
|
||||
|
||||
Do not edit or modify anything in this comment block.
|
||||
|
597
configure.ac
597
configure.ac
@ -1,16 +1,13 @@
|
||||
# Copyright (C) 1999-2006 Erik de Castro Lopo (erikd AT mega-nerd DOT com).
|
||||
# Copyright (C) 1999-2003 Erik de Castro Lopo (erikd AT zip DOT com DOT au).
|
||||
|
||||
dnl Require autoconf version
|
||||
AC_PREREQ(2.57)
|
||||
AC_PREREQ(2.54)
|
||||
|
||||
AC_INIT([libsndfile],[1.0.18pre9],[erikd@mega-nerd.com])
|
||||
AC_INIT(libsndfile,1.0.6pre15,<erikd@zip.com.au>)
|
||||
AC_CONFIG_SRCDIR([src/sndfile.c])
|
||||
AC_CANONICAL_TARGET([])
|
||||
|
||||
AM_INIT_AUTOMAKE($PACKAGE_NAME,$PACKAGE_VERSION)
|
||||
AC_CONFIG_HEADERS([src/config.h])
|
||||
|
||||
AC_LANG([C])
|
||||
AC_CONFIG_HEADERS(src/config.h)
|
||||
|
||||
#------------------------------------------------------------------------------------
|
||||
# Rules for library version information:
|
||||
@ -28,44 +25,24 @@ AC_LANG([C])
|
||||
# 6. If any interfaces have been removed since the last public release, then set age
|
||||
# to 0.
|
||||
|
||||
SHARED_VERSION_INFO="1:18:0"
|
||||
|
||||
AC_PROG_CC
|
||||
AM_PROG_LIBTOOL
|
||||
SHARED_VERSION_INFO="1:6:0"
|
||||
|
||||
AC_CHECK_PROG(autogen, autogen, yes, no)
|
||||
|
||||
AC_PROG_CC
|
||||
AC_PROG_INSTALL
|
||||
|
||||
AC_PROG_MAKE_SET
|
||||
AC_PROG_LN_S
|
||||
AM_PROG_LIBTOOL
|
||||
|
||||
AC_HEADER_STDC
|
||||
|
||||
AC_CHECK_HEADERS(endian.h)
|
||||
AC_CHECK_HEADERS(byteswap.h)
|
||||
AC_CHECK_HEADERS(locale.h)
|
||||
AC_CHECK_HEADERS(inttypes.h)
|
||||
|
||||
AC_HEADER_SYS_WAIT
|
||||
|
||||
AC_CHECK_DECLS(S_IRGRP)
|
||||
if test x$ac_cv_have_decl_S_IRGRP = xyes ; then
|
||||
AC_DEFINE_UNQUOTED([HAVE_DECL_S_IRGRP],1,[Set to 1 if S_IRGRP is defined.])
|
||||
else
|
||||
AC_DEFINE_UNQUOTED([HAVE_DECL_S_IRGRP],0)
|
||||
fi
|
||||
|
||||
#====================================================================================
|
||||
# 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
|
||||
AC_DEFINE_UNQUOTED([HAVE_DECL_S_IRGRP],${HAVE_DECL_S_IRGRP}, [Set to 1 if S_IRGRP is defined.])
|
||||
|
||||
#====================================================================================
|
||||
# Couple of initializations here. Fill in real values later.
|
||||
@ -76,41 +53,59 @@ SHLIB_VERSION_ARG=""
|
||||
# Finished checking, handle options.
|
||||
|
||||
AC_ARG_ENABLE(experimental,
|
||||
AC_HELP_STRING([--enable-experimental], [enable experimental code]))
|
||||
[ --enable-experimental enable experimental code],
|
||||
ac_arg_experimental=yes, ac_arg_experimental=no)
|
||||
|
||||
EXPERIMENTAL_CODE=0
|
||||
if test x$enable_experimental = xyes ; then
|
||||
if test x$ac_arg_experimental = xyes ; then
|
||||
EXPERIMENTAL_CODE=1
|
||||
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(gcc-pipe,
|
||||
[ --disable-gcc-pipe disable gcc -pipe option],
|
||||
ac_arg_gcc_pipe="N", ac_arg_gcc_pipe="Y")
|
||||
|
||||
AC_ARG_ENABLE(gcc-pipe,
|
||||
AC_HELP_STRING([--disable-gcc-pipe], [disable gcc -pipe option]))
|
||||
AC_ARG_ENABLE(gcc-opt,
|
||||
[ --disable-gcc-opt disable gcc optimisations],
|
||||
ac_arg_gcc_opt="N", ac_arg_gcc_opt="Y")
|
||||
|
||||
AC_ARG_ENABLE(gcc-opt,
|
||||
AC_HELP_STRING([--disable-gcc-opt], [disable gcc optimisations]))
|
||||
AC_ARG_ENABLE(cpu-clip,
|
||||
[ --disable-cpu-clip disable tricky cpu specific clipper],
|
||||
ac_arg_cpu_clip="N", ac_arg_cpu_clip="Y")
|
||||
|
||||
AC_ARG_ENABLE(cpu-clip,
|
||||
AC_HELP_STRING([--disable-cpu-clip], [disable tricky cpu specific clipper]))
|
||||
if test x$ac_cv_c_compiler_gnu = xyes ; then
|
||||
CFLAGS="$CFLAGS -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return -Wcast-align -Wcast-qual -Wnested-externs -Wshadow -Wbad-function-cast -Wwrite-strings"
|
||||
# -Wpointer-arith -Wundef -Wmissing-declarations -Winline -Wconversion"
|
||||
if test "$ac_arg_gcc_opt" = "N" ; then
|
||||
temp_CFLAGS=`echo $CFLAGS | sed "s/O2/O0/"`
|
||||
CFLAGS=$temp_CFLAGS
|
||||
AC_MSG_WARN([[*** Compiler optimisations switched off. ***]])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(bow-docs,
|
||||
AC_HELP_STRING([--enable-bow-docs], [enable black-on-white html docs]))
|
||||
# OS specific tweaks.
|
||||
case "$target_os" in
|
||||
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//"`
|
||||
SHLIB_VERSION_ARG="-Wl,-exported_symbols_list -Wl,Symbols"
|
||||
CFLAGS=$temp_CFLAGS
|
||||
;;
|
||||
linux*)
|
||||
SHLIB_VERSION_ARG="-Wl,--version-script=Symbols"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
if test x$ac_arg_gcc_pipe != "xN" ; then
|
||||
CFLAGS="$CFLAGS -pipe"
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(sqlite,
|
||||
AC_HELP_STRING([--disable-sqlite], [disable use of sqlite]))
|
||||
|
||||
AC_ARG_ENABLE(flac,
|
||||
AC_HELP_STRING([--disable-flac], [disable use of FLAC]))
|
||||
|
||||
AC_ARG_ENABLE(alsa,
|
||||
AC_HELP_STRING([--disable-alsa], [disable use of ALSA]))
|
||||
|
||||
AC_ARG_ENABLE(test-coverage,
|
||||
AC_HELP_STRING([--enable-test-coverage], [enable test coverage]))
|
||||
AM_CONDITIONAL([ENABLE_TEST_COVERAGE], [test "$enable_test_coverage" = yes])
|
||||
AC_DEFINE([COMPILER_IS_GCC],1, [Set to 1 if the compile is GNU GCC.])
|
||||
GCC_MAJOR_VERSION=`$CC -dumpversion | sed "s/\..*//"`
|
||||
AC_DEFINE_UNQUOTED([GCC_MAJOR_VERSION],${GCC_MAJOR_VERSION}, [Major version of GCC or 3 otherwise.])
|
||||
fi
|
||||
|
||||
#====================================================================================
|
||||
# Check types and their sizes.
|
||||
@ -122,8 +117,6 @@ AC_CHECK_SIZEOF(float,4)
|
||||
AC_CHECK_SIZEOF(double,4)
|
||||
AC_CHECK_SIZEOF(void*,8)
|
||||
AC_CHECK_SIZEOF(size_t,4)
|
||||
AC_CHECK_SIZEOF(int64_t,8)
|
||||
AC_CHECK_SIZEOF(long long,8)
|
||||
|
||||
#====================================================================================
|
||||
# Find an appropriate type for sf_count_t.
|
||||
@ -135,72 +128,62 @@ unset ac_cv_sizeof_off_t
|
||||
|
||||
AC_CHECK_SIZEOF(off_t,1) # Fake default value.
|
||||
|
||||
case "$host_os" in
|
||||
mingw*)
|
||||
TYPEOF_SF_COUNT_T="__int64"
|
||||
SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
|
||||
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"
|
||||
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
|
||||
;;
|
||||
*)
|
||||
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"
|
||||
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.
|
||||
elif test "x$ac_cv_sizeof_off64_t" = "x8" ; then
|
||||
TYPEOF_SF_COUNT_T="off64_t"
|
||||
SIZEOF_SF_COUNT_T=8
|
||||
fi
|
||||
|
||||
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.
|
||||
|
||||
# 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
|
||||
|
||||
pre_largefile_sizeof_off_t=$ac_cv_sizeof_off_t
|
||||
unset ac_cv_sizeof_off_t
|
||||
AC_SYS_EXTRA_LARGEFILE
|
||||
|
||||
AC_SYS_EXTRA_LARGEFILE
|
||||
if test "x$ac_cv_sys_largefile_CFLAGS" = "xno" ; then
|
||||
ac_cv_sys_largefile_CFLAGS=""
|
||||
fi
|
||||
if test "x$ac_cv_sys_largefile_LDFLAGS" = "xno" ; then
|
||||
ac_cv_sys_largefile_LDFLAGS=""
|
||||
fi
|
||||
if test "x$ac_cv_sys_largefile_LIBS" = "xno" ; then
|
||||
ac_cv_sys_largefile_LIBS=""
|
||||
fi
|
||||
|
||||
if test "x$ac_cv_sys_largefile_CFLAGS" = "xno" ; then
|
||||
ac_cv_sys_largefile_CFLAGS=""
|
||||
fi
|
||||
if test "x$ac_cv_sys_largefile_LDFLAGS" = "xno" ; then
|
||||
ac_cv_sys_largefile_LDFLAGS=""
|
||||
fi
|
||||
if test "x$ac_cv_sys_largefile_LIBS" = "xno" ; then
|
||||
ac_cv_sys_largefile_LIBS=""
|
||||
fi
|
||||
AC_CHECK_SIZEOF(off_t,1) # Fake default value.
|
||||
|
||||
AC_CHECK_SIZEOF(off_t,1) # Fake default value.
|
||||
if 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"
|
||||
echo "*** of Large File Support but has not been able to find a type which"
|
||||
echo "*** is an unambiguous 64 bit file offset."
|
||||
echo "*** Please contact the author to help resolve this problem."
|
||||
echo
|
||||
AC_MSG_ERROR([[Bad file offset type.]])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$ac_cv_sizeof_off_t" = "x8" ; then
|
||||
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"
|
||||
echo "*** of Large File Support but has not been able to find a type which"
|
||||
echo "*** is an unambiguous 64 bit file offset."
|
||||
echo "*** Please contact the author to help resolve this problem."
|
||||
echo
|
||||
AC_MSG_ERROR([[Bad file offset type.]])
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if test $SIZEOF_SF_COUNT_T = 4 ; then
|
||||
if test $SIZEOF_SF_COUNT_T = 8 ; then
|
||||
SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
|
||||
elif test $SIZEOF_SF_COUNT_T = 4 ; then
|
||||
SF_COUNT_MAX="0x7FFFFFFF"
|
||||
fi
|
||||
|
||||
@ -213,7 +196,6 @@ AC_SUBST(SIZEOF_SF_COUNT_T)
|
||||
AC_DEFINE_UNQUOTED([SF_COUNT_MAX],${SF_COUNT_MAX}, [Set to maximum allowed value of sf_count_t type.])
|
||||
AC_SUBST(SF_COUNT_MAX)
|
||||
|
||||
AC_CHECK_TYPES(ssize_t)
|
||||
AC_CHECK_SIZEOF(ssize_t,4)
|
||||
|
||||
#====================================================================================
|
||||
@ -225,60 +207,11 @@ AC_DEFINE_UNQUOTED(CPU_IS_BIG_ENDIAN, ${ac_cv_c_big_endian},
|
||||
[Target processor is big endian.])
|
||||
AC_DEFINE_UNQUOTED(CPU_IS_LITTLE_ENDIAN, ${ac_cv_c_little_endian},
|
||||
[Target processor is little endian.])
|
||||
AC_DEFINE_UNQUOTED(WORDS_BIGENDIAN, ${ac_cv_c_big_endian},
|
||||
[Target processor is 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(snprintf vsnprintf)
|
||||
AC_CHECK_FUNCS(gmtime gmtime_r)
|
||||
AC_CHECK_FUNCS(mmap getpagesize)
|
||||
AC_CHECK_FUNCS(setlocale)
|
||||
|
||||
AC_CHECK_LIB([m],floor)
|
||||
AC_CHECK_FUNCS(floor ceil fmod)
|
||||
|
||||
case "$host_os" in
|
||||
cygwin*)
|
||||
AC_MSG_WARN([[Not using built-in lrint() and lrintf() because they are broken on Cygwin.]])
|
||||
;;
|
||||
*)
|
||||
AC_C99_FUNC_LRINT
|
||||
AC_C99_FUNC_LRINTF
|
||||
|
||||
if test "x$ac_cv_c99_lrint" = "xno" ; then
|
||||
if test "x$ac_cv_c99_lrintf" = "xno" ; then
|
||||
AC_MSG_WARN([[*** Missing C99 standard functions lrint() and lrintf().]])
|
||||
AC_MSG_WARN([[*** This may cause benign compiler warnings on some systems (ie Solaris).]])
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
#====================================================================================
|
||||
# Check for libsqlite3 (only used in regtest).
|
||||
|
||||
ac_cv_sqlite3=no
|
||||
if test x$enable_sqlite != xno ; then
|
||||
PKG_CHECK_MODULES(SQLITE3, sqlite3 >= 3.2, ac_cv_sqlite3=yes, ac_cv_sqlite3=no)
|
||||
fi
|
||||
|
||||
if test x$ac_cv_sqlite3 = "xyes" ; then
|
||||
HAVE_SQLITE3=1
|
||||
else
|
||||
HAVE_SQLITE3=0
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED([HAVE_SQLITE3],$HAVE_SQLITE3,[Set to 1 if you have libsqlite3.])
|
||||
|
||||
#====================================================================================
|
||||
# Determine if the processor can do clipping on float to int conversions.
|
||||
|
||||
if test x$enable_cpu_clip != "xno" ; then
|
||||
if test x$ac_arg_cpu_clip = "xY" ; then
|
||||
AC_C_CLIP_MODE
|
||||
else
|
||||
echo "checking processor clipping capabilities... disabled"
|
||||
@ -291,138 +224,66 @@ AC_DEFINE_UNQUOTED(CPU_CLIPS_POSITIVE, ${ac_cv_c_clip_positive},
|
||||
AC_DEFINE_UNQUOTED(CPU_CLIPS_NEGATIVE, ${ac_cv_c_clip_negative},
|
||||
[Target processor clips on negative float to int conversion.])
|
||||
|
||||
|
||||
#====================================================================================
|
||||
# FLAC defines.
|
||||
# Check for functions.
|
||||
|
||||
AC_DEFINE(FLAC__HAS_OGG, 1, [This is always true.])
|
||||
AC_CHECK_FUNCS(malloc calloc realloc free)
|
||||
AC_CHECK_FUNCS(open read write lseek pread pwrite)
|
||||
AC_CHECK_FUNCS(fstat ftruncate fsync fdatasync)
|
||||
AC_CHECK_FUNCS(snprintf vsnprintf)
|
||||
AC_CHECK_FUNCS(gmtime gmtime_r)
|
||||
AC_CHECK_FUNCS(mmap getpagesize)
|
||||
|
||||
case "$host_cpu" in
|
||||
i*86)
|
||||
cpu_ia32=true
|
||||
AC_DEFINE(FLAC__CPU_IA32)
|
||||
AH_TEMPLATE(FLAC__CPU_IA32, [define if building for ia32/i386])
|
||||
AC_CHECK_LIB([m],floor)
|
||||
AC_CHECK_FUNCS(floor ceil fmod)
|
||||
|
||||
case "$target_os" in
|
||||
darwin* | rhapsody*)
|
||||
AC_MSG_WARN([[Not using native lrint() and lrintf() because they are missing on 10.1.]])
|
||||
;;
|
||||
powerpc)
|
||||
cpu_ppc=true
|
||||
AC_DEFINE(FLAC__CPU_PPC)
|
||||
AH_TEMPLATE(FLAC__CPU_PPC, [define if building for PowerPC])
|
||||
;;
|
||||
sparc)
|
||||
cpu_sparc=true
|
||||
AC_DEFINE(FLAC__CPU_SPARC)
|
||||
AH_TEMPLATE(FLAC__CPU_SPARC, [define if building for SPARC])
|
||||
*)
|
||||
AC_C99_FUNC_LRINT
|
||||
AC_C99_FUNC_LRINTF
|
||||
|
||||
if test x$ac_cv_c99_lrint = xno || test x$ac_cv_c99_lrintf = xno ; then
|
||||
AC_MSG_WARN([[*** Missing C99 standard functions lrint() and lrintf().]])
|
||||
AC_MSG_WARN([[*** This may cause benign compiler warnings on some systems (ie Solaris).]])
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
AM_CONDITIONAL(FLaC__CPU_IA32, test "x$cpu_ia32" = xtrue)
|
||||
AM_CONDITIONAL(FLaC__CPU_PPC, test "x$cpu_ppc" = xtrue)
|
||||
AM_CONDITIONAL(FLaC__CPU_SPARC, test "x$cpu_sparc" = xtrue)
|
||||
|
||||
case "$host" in
|
||||
*-pc-linux-gnu)
|
||||
sys_linux=true
|
||||
AC_DEFINE(FLAC__SYS_LINUX)
|
||||
AH_TEMPLATE(FLAC__SYS_LINUX, [define if building for Linux])
|
||||
;;
|
||||
*-*-darwin*)
|
||||
sys_darwin=true
|
||||
AC_DEFINE(FLAC__SYS_DARWIN)
|
||||
AH_TEMPLATE(FLAC__SYS_DARWIN, [define if building for Darwin / MacOS X])
|
||||
;;
|
||||
esac
|
||||
|
||||
AM_CONDITIONAL(FLaC__SYS_DARWIN, test "x$sys_darwin" = xtrue)
|
||||
AM_CONDITIONAL(FLaC__SYS_LINUX, test "x$sys_linux" = xtrue)
|
||||
|
||||
AC_ARG_ENABLE(asm-optimizations, AC_HELP_STRING([--disable-asm-optimizations], [Don't use any assembly optimization routines]), asm_opt=no, asm_opt=yes)
|
||||
AM_CONDITIONAL(FLaC__NO_ASM, test "x$asm_opt" = xno)
|
||||
|
||||
if test "x$asm_opt" = xno ; then
|
||||
AC_DEFINE(FLAC__NO_ASM)
|
||||
AH_TEMPLATE(FLAC__NO_ASM, [define to disable use of assembly code])
|
||||
fi
|
||||
|
||||
AC_CHECK_PROGS(NASM, nasm)
|
||||
AM_CONDITIONAL(FLaC__HAS_NASM, test -n "$NASM")
|
||||
|
||||
if test -n "$NASM" ; then
|
||||
AC_DEFINE(FLAC__HAS_NASM)
|
||||
AH_TEMPLATE(FLAC__HAS_NASM, [define if you are compiling for x86 and have the NASM assembler])
|
||||
fi
|
||||
|
||||
# Only matters for PowerPC
|
||||
AC_CHECK_PROGS(AS, as, as)
|
||||
AC_CHECK_PROGS(GAS, gas, gas)
|
||||
|
||||
AM_CONDITIONAL(FLaC__HAS_AS, test "$AS" = "as")
|
||||
AM_CONDITIONAL(FLaC__HAS_GAS, test "$AS" = "gas")
|
||||
|
||||
if test "$AS" = "as" ; then
|
||||
AC_DEFINE(FLAC__HAS_AS)
|
||||
AH_TEMPLATE(FLAC__HAS_AS, [define if you are compiling for PowerPC and have the 'as' assembler])
|
||||
fi
|
||||
|
||||
if test "$AS" = "gas" ; then
|
||||
# funniest. macro. ever.
|
||||
AC_DEFINE(FLAC__HAS_GAS)
|
||||
AH_TEMPLATE(FLAC__HAS_GAS, [define if you are compiling for PowerPC and have the 'gas' assembler])
|
||||
fi
|
||||
|
||||
case "$host" in
|
||||
i386-*-openbsd3.[[0-3]]) OBJ_FORMAT=aoutb ;;
|
||||
*-*-cygwin|*mingw*) OBJ_FORMAT=win32 ;;
|
||||
*) OBJ_FORMAT=elf ;;
|
||||
esac
|
||||
|
||||
AC_SUBST(OBJ_FORMAT)
|
||||
|
||||
#====================================================================================
|
||||
# Target OS specific stuff.
|
||||
|
||||
OS_SPECIFIC_CFLAGS=""
|
||||
OS_SPECIFIC_LINKS=""
|
||||
OS_SPECIFIC_INCLUDES=""
|
||||
os_is_win32=0
|
||||
os_is_macosx=0
|
||||
use_windows_api=0
|
||||
|
||||
case "$host_os" in
|
||||
case "$target_os" in
|
||||
darwin* | rhapsody*)
|
||||
os_is_macosx=1
|
||||
OS_SPECIFIC_CFLAGS="-fpascal-strings -I/Developer/Headers/FlatCarbon"
|
||||
OS_SPECIFIC_INCLUDES="-fpascal-strings -I/Developer/Headers/FlatCarbon"
|
||||
OS_SPECIFIC_LINKS="-framework CoreAudio"
|
||||
;;
|
||||
mingw*)
|
||||
mingw32msvc)
|
||||
os_is_win32=1
|
||||
use_windows_api=1
|
||||
OS_SPECIFIC_LINKS="-lwinmm"
|
||||
AC_CHECK_HEADERS(wintypes.h mmreg.h)
|
||||
OS_SPECIFIC_INCLUDES=""
|
||||
OS_SPECIFIC_LINKS=""
|
||||
;;
|
||||
cygwin*)
|
||||
os_is_win32=1
|
||||
OS_SPECIFIC_LINKS="-lwinmm"
|
||||
*)
|
||||
OS_SPECIFIC_INCLUDES=""
|
||||
OS_SPECIFIC_LINKS=""
|
||||
;;
|
||||
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])
|
||||
|
||||
#====================================================================================
|
||||
# Check for ALSA.
|
||||
|
||||
ALSA_LIBS=""
|
||||
|
||||
if test x$enable_alsa != xno ; then
|
||||
AC_CHECK_HEADERS(alsa/asoundlib.h)
|
||||
if test x$ac_cv_header_alsa_asoundlib_h = xyes ; then
|
||||
ALSA_LIBS="-lasound"
|
||||
fi
|
||||
fi
|
||||
|
||||
#====================================================================================
|
||||
# Test for sanity when cross-compiling.
|
||||
|
||||
if test x$cross_compiling = xyes ; then
|
||||
if test $cross_compiling = yes ; 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 ]])
|
||||
@ -456,161 +317,35 @@ if test $ac_cv_sizeof_double != 8 ; then
|
||||
|
||||
if test x"$ac_cv_prog_autogen" = "xno" ; then
|
||||
AC_MSG_WARN([[Touching files in directory tests/.]])
|
||||
touch tests/*.c tests/*.h
|
||||
fi
|
||||
|
||||
#====================================================================================
|
||||
# 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"
|
||||
else
|
||||
HTML_BGCOLOUR="black"
|
||||
HTML_FGCOLOUR="white"
|
||||
touch tests/*.c tests/*.h
|
||||
fi
|
||||
|
||||
#====================================================================================
|
||||
# Now use the information from the checking stage.
|
||||
|
||||
win32_target_dll=0
|
||||
|
||||
if test x$ac_cv_c_compiler_gnu = xyes ; then
|
||||
AC_ADD_CFLAGS(-std=gnu99)
|
||||
|
||||
CFLAGS="$CFLAGS -W -Wall"
|
||||
CXXFLAGS="$CXXFLAGS -W -Wall"
|
||||
|
||||
AC_ADD_CFLAGS([-Wdeclaration-after-statement])
|
||||
AC_ADD_CFLAGS([-Wpointer-arith])
|
||||
|
||||
if test x$enable_gcc_werror = "xyes" ; then
|
||||
CFLAGS="-Werror $CFLAGS"
|
||||
CXXFLAGS="-Werror $CXXFLAGS"
|
||||
fi
|
||||
|
||||
if test x$enable_test_coverage = "xyes" ; then
|
||||
# AC_ADD_CFLAGS([-ftest-coverage])
|
||||
AC_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 "
|
||||
|
||||
if test "x$enable_gcc_opt" = "xno" ; then
|
||||
temp_CFLAGS=`echo $CFLAGS | sed "s/O2/O0/"`
|
||||
CFLAGS=$temp_CFLAGS
|
||||
AC_MSG_WARN([[*** Compiler optimisations switched off. ***]])
|
||||
fi
|
||||
|
||||
# OS specific tweaks.
|
||||
case "$host_os" in
|
||||
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//"`
|
||||
CFLAGS=$temp_CFLAGS
|
||||
SHLIB_VERSION_ARG="-Wl,-exported_symbols_list -Wl,\$(srcdir)/Symbols.darwin"
|
||||
;;
|
||||
linux*)
|
||||
SHLIB_VERSION_ARG="-Wl,--version-script=\$(srcdir)/Symbols.linux"
|
||||
;;
|
||||
mingw*)
|
||||
SHLIB_VERSION_ARG="-Wl,\$(srcdir)/libsndfile.def"
|
||||
win32_target_dll=1
|
||||
if test x"$enable_shared" = xno ; then
|
||||
win32_target_dll=0
|
||||
fi
|
||||
;;
|
||||
cygwin*)
|
||||
SHLIB_VERSION_ARG="-Wl,\$(srcdir)/cygsndfile.def"
|
||||
win32_target_dll=1
|
||||
if test x"$enable_shared" = xno ; then
|
||||
win32_target_dll=0
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
if test x$enable_gcc_pipe != "xno" ; then
|
||||
CFLAGS="$CFLAGS -pipe"
|
||||
fi
|
||||
|
||||
AC_DEFINE([COMPILER_IS_GCC],1, [Set to 1 if the compile is GNU GCC.])
|
||||
GCC_MAJOR_VERSION=`$CC -dumpversion | sed "s/\..*//"`
|
||||
AC_DEFINE_UNQUOTED([GCC_MAJOR_VERSION],${GCC_MAJOR_VERSION}, [Major version of GCC or 3 otherwise.])
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED(WIN32_TARGET_DLL, ${win32_target_dll}, [Set to 1 if windows DLL is being built.])
|
||||
|
||||
CFLAGS="$CFLAGS $OS_SPECIFIC_CFLAGS"
|
||||
|
||||
if test x"$CFLAGS" = x ; then
|
||||
echo "Error in configure script. CFLAGS has been screwed up."
|
||||
exit
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
AC_SUBST(htmldocdir)
|
||||
AC_SUBST(HTML_BGCOLOUR)
|
||||
AC_SUBST(HTML_FGCOLOUR)
|
||||
# if test x$ac_cv_c_compiler_gnu = xyes ; then
|
||||
# CFLAGS="$CFLAGS -Werror"
|
||||
# fi
|
||||
|
||||
AC_SUBST(SHLIB_VERSION_ARG)
|
||||
AC_SUBST(SHARED_VERSION_INFO)
|
||||
AC_SUBST(OS_SPECIFIC_CFLAGS)
|
||||
AC_SUBST(OS_SPECIFIC_INCLUDES)
|
||||
AC_SUBST(OS_SPECIFIC_LINKS)
|
||||
AC_SUBST(ALSA_LIBS)
|
||||
AC_SUBST(ENABLE_EXPERIMENTAL_CODE)
|
||||
|
||||
AC_SUBST(COMPILER_IS_GCC)
|
||||
AC_SUBST(GCC_MAJOR_VERSION)
|
||||
|
||||
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 \
|
||||
\
|
||||
src/FLAC/Makefile src/FLAC/include/FLAC/Makefile src/FLAC/include/Makefile \
|
||||
src/FLAC/include/share/grabbag/Makefile src/FLAC/include/share/Makefile \
|
||||
src/FLAC/include/test_libs_common/Makefile src/FLAC/src/Makefile \
|
||||
src/FLAC/src/libFLAC/ia32/Makefile src/FLAC/src/libFLAC/Makefile \
|
||||
src/FLAC/src/libFLAC/include/private/Makefile \
|
||||
src/FLAC/src/libFLAC/include/Makefile \
|
||||
src/FLAC/src/libFLAC/include/protected/Makefile \
|
||||
src/FLAC/src/libFLAC/ppc/as/Makefile src/FLAC/src/libFLAC/ppc/Makefile \
|
||||
src/FLAC/src/libFLAC/ppc/gas/Makefile src/FLAC/src/share/Makefile \
|
||||
src/FLAC/src/share/getopt/Makefile src/FLAC/src/share/grabbag/Makefile \
|
||||
src/FLAC/src/share/replaygain_anal/Makefile \
|
||||
src/FLAC/src/share/replaygain_syn/include/private/Makefile \
|
||||
src/FLAC/src/share/replaygain_syn/include/Makefile \
|
||||
src/FLAC/src/share/replaygain_syn/Makefile \
|
||||
src/FLAC/src/share/utf8/Makefile src/FLAC/src/test_libFLAC/Makefile \
|
||||
src/FLAC/src/test_libs_common/Makefile src/FLAC/src/test_seeking/Makefile \
|
||||
src/FLAC/src/test_streams/Makefile src/FLAC/test/Makefile \
|
||||
src/FLAC/src/monkeys_audio_utilities/Makefile \
|
||||
src/FLAC/src/monkeys_audio_utilities/flac_mac/Makefile \
|
||||
src/FLAC/src/monkeys_audio_utilities/flac_ren/Makefile \
|
||||
src/FLAC/src/test_grabbag/Makefile src/FLAC/src/test_grabbag/cuesheet/Makefile \
|
||||
src/FLAC/src/test_grabbag/picture/Makefile \
|
||||
\
|
||||
src/OGG/include/ogg/Makefile src/OGG/include/Makefile src/OGG/Makefile \
|
||||
man/Makefile examples/Makefile tests/Makefile regtest/Makefile \
|
||||
doc/Makefile doc/libsndfile.css \
|
||||
Win32/Makefile Octave/Makefile \
|
||||
Makefile libsndfile.spec sndfile.pc \
|
||||
])
|
||||
AC_CONFIG_FILES([Makefile src/sndfile.h \
|
||||
src/Makefile src/GSM610/Makefile src/G72x/Makefile \
|
||||
man/Makefile examples/Makefile tests/Makefile doc/Makefile \
|
||||
Win32/Makefile MacOS9/Makefile Octave/Makefile \
|
||||
libsndfile.spec sndfile.pc])
|
||||
AC_OUTPUT
|
||||
|
||||
#====================================================================================
|
||||
@ -621,7 +356,7 @@ AC_MSG_RESULT([
|
||||
Configuration summary :
|
||||
|
||||
Version : ..................... ${VERSION}
|
||||
Experimental code : ........... ${enable_experimental:-no}
|
||||
Experimental code : ........... ${ac_arg_experimental}
|
||||
])
|
||||
|
||||
if test x$ac_cv_c_compiler_gnu = xyes ; then
|
||||
@ -629,45 +364,33 @@ if test x$ac_cv_c_compiler_gnu = xyes ; then
|
||||
echo " Compiler is GCC : ............. ${ac_cv_c_compiler_gnu}"
|
||||
echo " GCC major version : ........... ${GCC_MAJOR_VERSION}"
|
||||
if test $GCC_MAJOR_VERSION -lt 3 ; then
|
||||
echo -e "\n ** This compiler version allows applications to write"
|
||||
echo -e "\n ** This compiler version allows applications to write "
|
||||
echo " ** to static strings within the library."
|
||||
echo " ** Compile with GCC version 3.X to avoid this problem."
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $libdir = "\${exec_prefix}/lib" ; then
|
||||
libdir="$prefix/lib"
|
||||
fi
|
||||
|
||||
if test $bindir = "\${exec_prefix}/bin" ; then
|
||||
bindir="$prefix/bin"
|
||||
fi
|
||||
|
||||
AC_MSG_RESULT([[
|
||||
AC_MSG_RESULT([
|
||||
Installation directories :
|
||||
|
||||
Library directory : ........... $libdir
|
||||
Program directory : ........... $bindir
|
||||
Pkgconfig directory : ......... $libdir/pkgconfig
|
||||
HTML docs directory : ......... $htmldocdir
|
||||
]])
|
||||
Library directory : ........... ${prefix}/lib
|
||||
Program directory : ........... ${prefix}/bin
|
||||
Pkgconfig directory : ......... ${prefix}/lib/pkgconfig
|
||||
])
|
||||
|
||||
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 "Compiling some other packages against libsndfile may require "
|
||||
echo -e "the addition of \"${prefix}/lib/pkgconfig\" to the "
|
||||
echo -e "PKG_CONFIG_PATH environment variable.\n"
|
||||
fi
|
||||
|
||||
#==================================================================================
|
||||
# Ugly hack to remove -Werror from some Makefiles.
|
||||
|
||||
TMPFILE=/tmp/strchange$$
|
||||
ifelse(dnl
|
||||
|
||||
for f in "src/FLAC/src/libFLAC/Makefile" ; do
|
||||
tmp=`grep -l "\-Werror" "$f"`
|
||||
if test -n "$tmp" ; then
|
||||
if sed -e "s!\-Werror!!g" "$f" > $TMPFILE ; then
|
||||
cp -f $TMPFILE "$f"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
Do not edit or modify anything in this comment block.
|
||||
The arch-tag line is a file identity tag for the GNU Arch
|
||||
revision control system.
|
||||
|
||||
arch-tag: 6391b316-6cfc-43c2-a18a-8defdc4ee359
|
||||
|
||||
)dnl
|
||||
|
539
doc/FAQ.html
539
doc/FAQ.html
@ -5,17 +5,19 @@
|
||||
<TITLE>
|
||||
libsndfile : Frequently Asked Questions.
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT zip DOT com DOT au)">
|
||||
<META NAME="Version" CONTENT="Version 1.0.6">
|
||||
<!-- Another version at the bottom of the page. -->
|
||||
<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">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#5050FF" VLINK="#5050FF" ALINK="#FF00FF">
|
||||
|
||||
<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 : On Linux, sf_open returns weird info about files. Why?</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>
|
||||
@ -23,56 +25,54 @@
|
||||
substitution" error during linking. What can I do to fix this?</A><BR>
|
||||
<A HREF="#Q005">Q5 : Why doesn't libsndfile do interleaving/de-interleaving?</A><BR>
|
||||
<A HREF="#Q006">Q6 : What's the best format for storing temporary files?</A><BR>
|
||||
<A HREF="#Q007">Q7 : On Linux/Unix/MacOSX, what's the best way of detecting the
|
||||
<A HREF="#Q007">Q7 : On Linux/Unix/MaxOSX, what's the best way of detecting the
|
||||
presence of libsndfile?</A><BR>
|
||||
<A HREF="#Q008">Q8 : But I just want a simple Makefile! What do I do?</A><BR>
|
||||
<A HREF="#Q009">Q9 : How about adding the ability to write/read sound files to/from
|
||||
<A HREF="#Q008">Q8 : How about adding the ability to write/read sound files to/from
|
||||
memory buffers?</A><BR>
|
||||
<A HREF="#Q010">Q10 : Reading a 16 bit PCM file as normalised floats and then
|
||||
<A HREF="#Q009">Q9 : Reading a 16 bit PCM file as normalised floats and then
|
||||
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
|
||||
<A HREF="#Q010">Q10 : 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>
|
||||
<A HREF="#Q013">Q13 : Why can't libsndfile open this Sound Designer II (SD2)
|
||||
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>
|
||||
<A HREF="#Q015">Q15 : My program is crashing during a call to a function in libsndfile.
|
||||
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 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 HREF="#Q019">Q19 : I have project files for Visual Studio / XCode / Whatever. Why
|
||||
don't you distribute them with libsndfile?
|
||||
</A><BR>
|
||||
<A HREF="#Q020">Q20 : Why doesn't libsndfile support MP3? Lots of other Open Source
|
||||
projects support it!
|
||||
</A><BR>
|
||||
<A HREF="#Q011">Q11 : What are samples? What are frames?</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 : On Linux, sf_open returns weird info about files. Why?</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.
|
||||
This simple call to sf_open :
|
||||
</P>
|
||||
<PRE>
|
||||
file = sf_open (filename, SFM_READ, &sfinfo) ;
|
||||
|
||||
printf ("srate : %d\n", sfinfo.samplerate) ;
|
||||
printf ("frames : %d\n", sfinfo.frames) ;
|
||||
printf ("channels : %d\n", sfinfo.channels) ;
|
||||
printf ("format : %d\n", sfinfo.format) ;
|
||||
printf ("sections : %d\n", sfinfo.sections);
|
||||
printf ("seekable : %d\n", sfinfo.seekable) ;
|
||||
</PRE>
|
||||
<P>
|
||||
If suitable documentation is available on how to decode and enocde the format
|
||||
then maybe, depending on how much work is involved.
|
||||
returns this weird info:
|
||||
</P>
|
||||
<PRE>
|
||||
srate : 0
|
||||
frames : 1445760
|
||||
channels : 44100
|
||||
format : 2
|
||||
sections : 65538
|
||||
seekable : 1
|
||||
|
||||
</PRE>
|
||||
<H2><B>Answer</B></H2>
|
||||
<P>
|
||||
If XYZ is some proprietary codec where no source code or documentation is
|
||||
available then no.
|
||||
</P>
|
||||
<P>
|
||||
So if you want support for XYZ codec, first find existing source code or
|
||||
documentation.
|
||||
If you can't find either then the answer is no.
|
||||
This is only a problem on Linux and other 32 bit OSes (possibly 32 bit Solaris)
|
||||
which require special compiler command line options to allow access to files
|
||||
greater than 2 Gig in size.
|
||||
<A HREF="pkgconfig.html">These instructions</A> should show you a way around this
|
||||
problem.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q002"></A>
|
||||
<H2><BR><B>Q2 : In version 0 the SF_INFO struct had a pcmbitwidth field
|
||||
@ -86,7 +86,7 @@ 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>
|
||||
<A HREF="http://www.zip.com.au/~erikd/libsndfile/api.html#note1">here</A>
|
||||
there is now a well defined behavior 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()
|
||||
@ -97,12 +97,9 @@ and always have the optimal behavior.
|
||||
<A NAME="Q003"></A>
|
||||
<H2><BR><B>Q3 : Compiling is really slow on MacOSX. Why?</B></H2>
|
||||
<P>
|
||||
When you configure and compile libsndfile, it uses the /bin/sh shell for a number
|
||||
When you configure and compile libsndfile, it uses the Bourne 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
|
||||
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
|
||||
case.
|
||||
However, Apple has decided to ship their system with a really crappy Bourne shell.
|
||||
</P>
|
||||
<P>
|
||||
To fix this I suggest that you install the GNU Bash shell, rename /bin/sh to
|
||||
@ -110,7 +107,7 @@ To fix this I suggest that you install the GNU Bash shell, rename /bin/sh to
|
||||
Bash is designed to behave as a Bourne shell when is is called as /bin/sh.
|
||||
</P>
|
||||
<P>
|
||||
When I did this on my iBook running MacOSX, compile times dropped from 13 minutes
|
||||
When I did this on my iBook running MacOSX, compile times dropped from 13 minutes
|
||||
to 3 minutes.
|
||||
</P>
|
||||
|
||||
@ -134,11 +131,11 @@ Bash is designed to behave as a Bourne shell when is is called as /bin/sh.
|
||||
This problem is bigger than it may seem at first.
|
||||
</P>
|
||||
<P>
|
||||
For a stereo file, it is a pretty safe bet that a simple interleaving/de-interleaving
|
||||
For a stereo file, it a pretty safe bet that a simple interleaving/de-interleaving
|
||||
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
|
||||
However, for file 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
|
||||
of the 4 channels.
|
||||
</P>
|
||||
<P>
|
||||
@ -164,13 +161,13 @@ When you want to store temporary data there are a number of requirements;
|
||||
<LI> Able to store data in either endian-ness.
|
||||
</UL>
|
||||
<P>
|
||||
The format which best meets these requirements is AU, which allows data to be
|
||||
stored in any one of short, int, float and double (among others) formats.
|
||||
The format which best means these requirements is AU, which allows data to be
|
||||
stored in any one of short, int, float and double (among others).
|
||||
</P>
|
||||
<P>
|
||||
For instance, if an application uses float data internally, its temporary files
|
||||
For instance, if an application uses float data internally, it temporary files
|
||||
should use a format of (SF_ENDIAN_CPU | SF_FORMAT_AU | SF_FORMAT_FLOAT) which
|
||||
will store big endian float data in big endian CPUs and little endian float data
|
||||
will store big endian float data in big endian CPUs and little float endian data
|
||||
on little endian CPUs.
|
||||
Reading and writing this format will not require any conversions or byte swapping
|
||||
regardless of the host CPU.
|
||||
@ -207,7 +204,7 @@ variables which can be used in Makefile.am like this:
|
||||
</PRE>
|
||||
<P>
|
||||
If you install libsndfile from source, you will probably need to set the
|
||||
<B>PKG_CONFIG_PATH</B> environment variable as suggested at the end of the
|
||||
<B>PKG_CONFIG_PATH</B> environment variable's suggested at the end of the
|
||||
libsndfile configure process. For instance on my system I get this:
|
||||
</P>
|
||||
<PRE>
|
||||
@ -237,85 +234,58 @@ 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 : How about adding the ability to write/read sound files to/from
|
||||
memory buffers?</B></H2>
|
||||
|
||||
<P>
|
||||
The <B>pkg-config</B> program makes finding the correct compiler flag values and
|
||||
library location far easier.
|
||||
During the installation of libsndfile, a file named <B>sndfile.pc</B> is installed
|
||||
in the directory <B>${libdir}/pkgconfig</B> (ie if libsndfile is installed in
|
||||
<B>/usr/local/lib</B>, <B>sndfile.pc</B> will be installed in
|
||||
<B>/usr/local/lib/pkgconfig/</B>).
|
||||
I have a had a number of requests like this over the last 18 months.
|
||||
As yet, no-one has been able to justify why this is a good idea and why this
|
||||
cannot be done a different way.
|
||||
</P>
|
||||
<P>
|
||||
In order for pkg-config to find sndfile.pc it may be necessary to point the
|
||||
environment variable <B>PKG_CONFIG_PATH</B> in the right direction.
|
||||
One example of different way is temporary files stored on a temporary file
|
||||
systems (ie tmpfs on both Linux and Solaris).
|
||||
These require no changes to libsndfile, no extra code in libsndfile, achieve
|
||||
exactly what is required and work now.
|
||||
</P>
|
||||
<PRE>
|
||||
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
Then, to compile a C file into an object file, the command would be:
|
||||
</P>
|
||||
<PRE>
|
||||
gcc `pkg-config --cflags sndfile` -c somefile.c
|
||||
</PRE>
|
||||
<P>
|
||||
and to link a number of objects into an executable that links against libsndfile,
|
||||
the command would be:
|
||||
</P>
|
||||
<PRE>
|
||||
gcc `pkg-config --libs sndfile` obj1.o obj2.o -o program
|
||||
</PRE>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
<A NAME="Q009"></A>
|
||||
<H2><BR><B>Q9 : How about adding the ability to write/read sound files to/from
|
||||
memory buffers?</B></H2>
|
||||
|
||||
<P>
|
||||
This has been added for version 1.0.13.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
<A NAME="Q010"></A>
|
||||
<H2><BR><B>Q10 : Reading a 16 bit PCM file as normalised floats and then
|
||||
<H2><BR><B>Q9 : Reading a 16 bit PCM file as normalised floats and then
|
||||
writing them back changes some sample values. Why?</B></H2>
|
||||
|
||||
<P>
|
||||
This is caused by the fact that the conversion from 16 bit short to float is
|
||||
done by dividing by 32768 (0x8000 in hexadecimal) while the conversion from
|
||||
float to 16 bit short is done by multiplying by 32767 (0x7FFF in hex).
|
||||
So for instance, a value in a 16 bit PCM file of 20000 gets read as a floating
|
||||
point number of 0.6103515625 (20000.0 / 0x8000).
|
||||
So for instance, a value in a 16 bit PCM file of 20000, gets read as a floating
|
||||
point number of 0.6103515625 (20000.0 / 0x8000).
|
||||
Converting that back to a 16 bit short results in a value of 19999.3896484375
|
||||
(0.6103515625 * 0x7FFF) which then gets rounded down to 19999.
|
||||
</P>
|
||||
<P>
|
||||
You will notice that for this particular case, the error is 1 in 20000 or
|
||||
You will notice that for this particular case, the error is 1 in 20000 or
|
||||
0.005%.
|
||||
Interestingly, for values of less than 16369, dividing by 0x8000 followed
|
||||
by multiplying by 0x7FFF and then rounding the result, gives back the
|
||||
original value.
|
||||
It turns out that as long as the host operating system supplies the 1999 ISO
|
||||
C Standard functions <B>lrintf</B> and <B>lrint</B> (or a replacement has
|
||||
C Standard functions <B>lrintf</B> and <B>lrint</B> (or a replacement has
|
||||
been supplied) then the maximum possible error is 1 in 16369 or about 0.006%.
|
||||
</P>
|
||||
<P>
|
||||
Regardless of the size of the error, the reason why this is done is rather
|
||||
Regardless of the size of the error, the reason why this is done is rather
|
||||
subtle.
|
||||
</P>
|
||||
<P>
|
||||
In a file containing 16 bit PCM samples, the values are restricted to the range
|
||||
[-32768, 32767] while we want floating point values in the range [-1.0, 1.0].
|
||||
The only way to do this conversion is to do a floating point division by a value
|
||||
of 0x8000.
|
||||
The only way to do this conversion is to do a floating point divide by a value
|
||||
0x8000.
|
||||
Converting the other way, the only way to ensure that floating point values in
|
||||
the range [-1.0, 1.0] are within the valid range allowed by a 16 bit short is
|
||||
to multiply by 0x7FFF.
|
||||
to multiply 0x7FFF.
|
||||
</P>
|
||||
<P>
|
||||
Some people would say that this is a severe short-coming of libsndfile.
|
||||
@ -326,8 +296,8 @@ in audio quality that they should also be concerned about.
|
||||
<P>
|
||||
The correct way to deal with this problem is to consider 16 bit short data as
|
||||
a final destination format only, not as an intermediate storage format.
|
||||
All intermediate data (ie which is going to be processed further) should be
|
||||
stored in floating point format which is supported by all of the most common
|
||||
All intermediate data (ie which is going to be processed further) should be
|
||||
stored in floating point format which is supported by all of the most common
|
||||
file formats.
|
||||
If floating point files are considered too large (2 times the size of a 16 bit
|
||||
PCM file), it would also be possible to use 24 bit PCM as an intermediate
|
||||
@ -336,8 +306,8 @@ 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
|
||||
<A NAME="Q010"></A>
|
||||
<H2><BR><B>Q10 : I'm having problems with u-law encoded WAV files generated by
|
||||
libsndfile in Winamp. Why?
|
||||
</B></H2>
|
||||
|
||||
@ -345,376 +315,55 @@ storage format (and which is also supported by most common file types).
|
||||
This is actually a Winamp problem.
|
||||
The official Microsoft spec suggests that the 'fmt ' chunk should be 18 bytes.
|
||||
Unfortunately at least one of Microsoft's own applications (Sound Recorder on
|
||||
Win98 I believe) did not accept 18 bytes 'fmt ' chunks.
|
||||
Win98 I believe), did not accept 18 bytes 'fmt ' chunks.
|
||||
</P>
|
||||
<P>
|
||||
Michael Lee did some experimenting and found that:
|
||||
</P>
|
||||
<PRE>
|
||||
I have checked that Windows Media Player 9, QuickTime Player 6.4,
|
||||
I have checked that Windows Media Player 9, QuickTime Player 6.4,
|
||||
RealOne Player 2.0 and GoldWave 5.06 can all play u-law files with
|
||||
16-byte or 18-byte 'fmt ' chunk. Only Winamp (2.91) and foobar2000
|
||||
16-byte or 18-byte 'fmt ' chunk. Only Winamp (2.91) and foobar2000
|
||||
are unable to play u-law files with 16-byte 'fmt ' chunk.
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
Even this is a very small sampling of all the players out there.
|
||||
For that reason it is probably not a good idea to change this now because there
|
||||
Even this is s very small sampling of all the players out there.
|
||||
For that reason its probably not a good idea to change this now because there
|
||||
is the risk of breaking something that currently works.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
<A NAME="Q012"></A>
|
||||
<H2><BR><B>Q12 : I'm looking at sf_read*. What are items? What are frames?
|
||||
<A NAME="Q011"></A>
|
||||
<H2><BR><B>Q11 : What are samples? What are frames?
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
For a sound file with only one channel, a frame is the same as a item.
|
||||
For a sound file with only one channel, a frame is the same as a sample.
|
||||
</P>
|
||||
<P>
|
||||
For multi channel sound files, a single frame contains a single item for
|
||||
For multi channel sound files, a single frame contains a single sample for
|
||||
each channel.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
<A NAME="Q013"></A>
|
||||
<H2><BR><B>Q13 : Why can't libsndfile open this Sound Designer II (SD2) file?
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
This is somewhat complicated.
|
||||
First some background.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
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
|
||||
this:
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
-rw-r--r-- 1 erikd erikd 46512 Oct 18 22:57 file.sd2
|
||||
-rw-r--r-- 1 erikd erikd 538 Oct 18 22:57 file.sd2/rsrc
|
||||
</PRE>
|
||||
|
||||
<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)
|
||||
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.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
When SD2 files are moved to other platforms, the resource fork of the file
|
||||
can sometimes be dropped altogether.
|
||||
All that remains is the raw audio data and no information about the number
|
||||
of channels, sample rate or bit width which makes it a little difficult for
|
||||
libsndfile to open the file.
|
||||
</P>
|
||||
|
||||
<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
|
||||
store the resource fork of the file in a separate hidden file in the
|
||||
same directory like this:
|
||||
</P>
|
||||
<PRE>
|
||||
-rw-r--r-- 1 erikd erikd 538 Oct 18 22:57 ._file.sd2
|
||||
-rw-r--r-- 1 erikd erikd 46512 Oct 18 22:57 file.sd2
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
Regardless of what platform it is running on, when libsndfile is asked to
|
||||
open a file named <B>"foo"</B> and it can't recognize the file type from
|
||||
the data in the file, it will attempt to open the resource fork and if
|
||||
that fails, it then tries to open a file named <B>"._foo"</B> to see if
|
||||
the file has a valid resource fork.
|
||||
This is the same regardless of whether the file is being opened for read
|
||||
or write.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
In short, libsndfile should open SD2 files with a valid resource fork on
|
||||
all of the platforms that libsndfile supports.
|
||||
If a file has lost its resource fork, the only option is the open the file
|
||||
using the SF_FORMAT_RAW option and guessing its sample rate, channel count
|
||||
and bit width.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
Occasionally, when SD2 files are moved to other systems, the file is
|
||||
<A HREF="http://www.macdisk.com/binhexen.php3">BinHexed</A>
|
||||
which wraps the resource fork and the data fork together.
|
||||
For these files, it would be possible to write a BinHex parser but
|
||||
there is not a lot to gain considering how rare these BinHexed SD2
|
||||
files are.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q014"></A>
|
||||
<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>
|
||||
|
||||
<P>
|
||||
Unfortunately no.
|
||||
libsndfile contains code written by other people who have agreed that their
|
||||
code be used under the GNU LGPL but no more.
|
||||
Even if they were to agree, there would be significant difficulties in
|
||||
dividing up the payments fairly.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
The <B>only</B> way you can legally use libsndfile as a statically linked
|
||||
library is if your application is released under the GNU GPL or LGPL.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q015"></A>
|
||||
<H2><BR><B>Q15 : My program is crashing during a call to a function in libsndfile.
|
||||
Is this a bug in libsndfile?
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
libsndfile is being used by large numbers of people all over the world
|
||||
without any problems like this. That means that it is much more likely
|
||||
that your code has a bug than libsndfile. However, it is still possible
|
||||
that there is a bug in libsndfile.
|
||||
</P>
|
||||
<P>
|
||||
To figure out whether it is your code or libsndfile you should do the
|
||||
following:
|
||||
</P>
|
||||
<UL>
|
||||
<LI>Make sure you are compiling your code with warnings switched on and
|
||||
that you fix as many warnings as possible.
|
||||
With the GNU compiler (gcc) I would recommend at least
|
||||
<B>-W -Wall -Werror</B> which will force you to fix all warnings
|
||||
before you can run the code.
|
||||
<LI>Try using a memory debugger.
|
||||
<A HREF="http://valgrind.kde.org/">Valgrind</A> on x86 Linux is excellent.
|
||||
<A HREF="http://www.ibm.com/software/awdtools/purify/">Purify</A> also
|
||||
has a good reputation.
|
||||
<LI>If the code is clean after the above two steps and you still get
|
||||
a crash in libsndfile, then send me a small snippet of code (no
|
||||
more than 30-40 lines) which includes the call to sf_open() and
|
||||
also shows how all variables passed to/returned from sf_open()
|
||||
are defined.
|
||||
</UL>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q016"></A>
|
||||
<H2><BR><B>Q16 : Will you accept a fix for compiling libsndfile with compiler X?
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
If compiler X is a C++ compiler then no.
|
||||
C and C++ are different enough to make writing code that compiles as valid C
|
||||
and valid C++ too difficult.
|
||||
I would rather spend my time fixing bugs and adding features.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
If compiler X is a C compiler then I will do what I can as long as that does
|
||||
not hamper the correctness, portability and maintainability of the existing
|
||||
code.
|
||||
It should be noted however that libsndfile uses features specified by the 1999
|
||||
ISO C Standard.
|
||||
This can make compiling libsndfile with some older compilers difficult.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q017"></A>
|
||||
<H2><BR><B>Q17 : Can libsndfile read/write files from/to UNIX pipes?
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
Yes, libsndfile can read files from pipes.
|
||||
Unfortunately, the write case is much more complicated.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
File formats like AIFF and WAV have information at the start of the file (the
|
||||
file header) which states the length of the file, the number of sample frames
|
||||
etc.
|
||||
This information must be filled in correctly when the file header is written,
|
||||
but this information is not reliably known until the file is closed.
|
||||
This means that libsndfile cannot write AIFF, WAV and many other file types
|
||||
to a pipe.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
However, there is at least one file format (AU) which is specifically designed
|
||||
to be written to a pipe.
|
||||
Like AIFF and WAV, AU has a header with a sample frames field, but it is
|
||||
specifically allowable to set that frames field to 0x7FFFFFFF if the file
|
||||
length is not known when the header is written.
|
||||
The AU file format can also hold data in many of the standard formats (ie
|
||||
SF_FORMAT_PCM_16, SF_FORMAT_PCM_24, SF_FORMAT_FLOAT etc) as well as allowing
|
||||
data in both big and little endian format.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
See also <A HREF="#Q006">FAQ Q6</A>.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q018"></A>
|
||||
<H2><BR><B>Q18 : Is it possible to build a Universal Binary on Mac OSX?
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
Yes, but you must do two separate configure/build/test runs; one on PowerPC
|
||||
and one on Intel.
|
||||
It is then possible to merge the binaries into a single universal binary using
|
||||
one of the programs in the Apple tool chain.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
It is <b>not</b> possible to build a working universal binary via a single
|
||||
compile/build run on a single CPU.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
The problem is that the libsndfile build process detects features of the CPU its
|
||||
being built for during the configure process and when building a universal binary,
|
||||
configure is only run once and that data is then used for both CPUs.
|
||||
That configure data will be wrong for one of those CPUs.
|
||||
You will still be able to compile libsndfile, and the test suite will pass on
|
||||
the machine you compiled it on.
|
||||
However, if you take the universal binary test suite programs compiled on one
|
||||
CPU and run them on the other, the test suite will fail.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
Part of the problem is the the CPU endian-ness is detected at configure time.
|
||||
Yes, I know the Apple compiler defines one of the macros __LITTLE_ENDIAN__
|
||||
and __BIG_ENDIAN__, but those macros are not part of the 1999 ISO C Standard
|
||||
and they are not portable.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
In addition, endian issues are not the only reason why the cross compiled
|
||||
binary will fail.
|
||||
The configure script also detects other CPU specific idiosyncrasies to provide
|
||||
more optimized code.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
Now, if you have read this far you're probably thinking there must be a way
|
||||
to fix this and there probably is.
|
||||
The problem is that its a hell of a lot of work and would require significant
|
||||
changes to the configure process, the internal code and the test suite.
|
||||
In addition, these changes must not break compilation on any of the platforms
|
||||
libsndfile is currently working on.
|
||||
</p>
|
||||
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q019"></A>
|
||||
<H2><BR><B>Q19 : I have project files for Visual Studio / XCode / Whatever. Why
|
||||
don't you distribute them with libsndfile?
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
There's a very good reason for this.
|
||||
I will only distribute things that I actually have an ability to test and
|
||||
maintain.
|
||||
Project files for a bunch of different compilers and Integrated Development
|
||||
Environments are simply too difficult to maintain.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
The problem is that every time I add a new file to libsndfile or rename an
|
||||
existing file I would have to modify all the project files and then test that
|
||||
libsndfile still built with all the different compilers.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
Maintaining these project files is also rather difficult if I don't have access
|
||||
to the required compiler/IDE.
|
||||
If I just edit the project files without testing them I will almost certainly
|
||||
get it wrong.
|
||||
If I release a version of libsndfile with broken project files, I'll get a bunch
|
||||
of emails from people complaining about it not building and have no way of
|
||||
fixing or even testing it.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
I currently release sources that I personally test on Win32, Linux and
|
||||
MacOSX (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
|
||||
binaries with Visual Studio.
|
||||
As a guy who is mainly interested in Linux, I'm not to keen to jump through
|
||||
a bunch of hoops to support compilers and operating systems I don't use.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
So, I hear you want to volunteer to maintain the project files for Some Crappy
|
||||
Compiler 2007?
|
||||
Well sorry, that won't work either.
|
||||
I have had numerous people over the years offer to maintaining the project
|
||||
files for Microsoft's Visual Studio.
|
||||
Every single time that happened, they maintained it for a release or two and
|
||||
then disappeared off the face of the earth.
|
||||
Hence, I'm not willing to enter into an arrangement like that again.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q020"></A>
|
||||
<H2><BR><B>Q20 : Why doesn't libsndfile support MP3? Lots of other Open Source
|
||||
projects support it!
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
MP3 is not supported for one very good reason; doing so requires the payment
|
||||
of licensing fees.
|
||||
As can be seen from
|
||||
<a href="http://www.mp3licensing.com/royalty/software.html">
|
||||
mp3licensing.com</a>
|
||||
the required royalty payments are not cheap.
|
||||
</P>
|
||||
|
||||
<p>
|
||||
Yes, I know other libraries ignore the licensing requirements, but their legal
|
||||
status is extremely dubious.
|
||||
At any time, the body selling the licenses could go after the authors of those
|
||||
libraries.
|
||||
Some of those authors may be students and hence wouldn't be worth pursuing.
|
||||
</P>
|
||||
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Fortunately, Ogg Vorbis exists as an alternative to MP3.
|
||||
Support for Ogg Vorbis in libsndfile is currently been worked on.
|
||||
</p>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<HR>
|
||||
<P>
|
||||
The libsndfile home page is here :
|
||||
<A HREF="http://www.mega-nerd.com/libsndfile/">
|
||||
http://www.mega-nerd.com/libsndfile/</A>.
|
||||
<A HREF="http://www.zip.com.au/~erikd/libsndfile/">
|
||||
http://www.zip.com.au/~erikd/libsndfile/</A>.
|
||||
<BR>
|
||||
Version : 1.0.17
|
||||
Version : 1.0.6
|
||||
</P>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
<!--
|
||||
Do not edit or modify anything in this comment block.
|
||||
The arch-tag line is a file identity tag for the GNU Arch
|
||||
revision control system.
|
||||
|
||||
arch-tag: 508f827d-b9a7-4a86-8c2f-d82321df91f7
|
||||
-->
|
||||
|
@ -1,12 +1,10 @@
|
||||
## 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 \
|
||||
win32.html FAQ.html lists.html embedded_files.html octave.html \
|
||||
dither.html
|
||||
EXTRA_DIST = index.html libsndfile.jpg libsndfile.css api.html command.html \
|
||||
bugs.html sndfile_info.html new_file_type.HOWTO pkgconfig.html \
|
||||
win32.html FAQ.html lists.html embedded_files.html octave.html \
|
||||
dither.html
|
||||
|
||||
EXTRA_DIST = $(html_DATA)
|
||||
|
||||
## Do not edit or modify anything in this comment block.
|
||||
## The arch-tag line is a file identity tag for the GNU Arch
|
||||
|
289
doc/api.html
289
doc/api.html
@ -5,34 +5,36 @@
|
||||
<TITLE>
|
||||
The libsndfile API.
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT zip DOT com DOT au)">
|
||||
<META NAME="Version" CONTENT="Version 1.0.6">
|
||||
<!-- Another date at bottom of 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">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#9090FF" VLINK="#5050FF" ALINK="#FF00FF">
|
||||
|
||||
<BR>
|
||||
<H1><B>libsndfile</B></H1>
|
||||
<P>
|
||||
Libsndfile is a library designed to allow the reading and writing of many
|
||||
different sampled sound file formats (such as MS Windows WAV and the Apple/SGI
|
||||
AIFF format) through one standard library interface.
|
||||
Libsndfile is a library designed to allow the reading and writing of many
|
||||
different sampled sound file formats (such as MS Windows WAV and the Apple/SGI
|
||||
AIFF format) through one standard library interface.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
During read and write operations, formats are seamlessly converted between the
|
||||
During read and write operations, formats are seamless converted between the
|
||||
format the application program has requested or supplied and the file's data
|
||||
format. The application programmer can remain blissfully unaware of issues
|
||||
such as file endian-ness and data format. See <A HREF="#note1">Note 1</A> and
|
||||
<A HREF="#note2">Note 2</A>.
|
||||
<A HREF="#note1">Note 2</A>.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
Every effort is made to keep these documents up-to-date, error free and
|
||||
unambiguous.
|
||||
However, since maintaining the documentation is the least fun part of working
|
||||
Every effort is made to keep these documents up-to-date, error free and
|
||||
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">
|
||||
@ -41,23 +43,23 @@
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
<B> Finally, if you think there is some feature missing from libsndfile, check that
|
||||
it isn't already implemented (and documented)
|
||||
it isn't already implemented (and documented)
|
||||
<A HREF="command.html">here</A>.
|
||||
</B>
|
||||
</P>
|
||||
|
||||
<H2><B>SYNOPSIS</B></H2>
|
||||
<P>
|
||||
The functions of libsndfile are defined as follows:
|
||||
The functions of linbsndfile are defined as follows:
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<PRE>
|
||||
#include <stdio.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
|
||||
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) ;
|
||||
|
||||
|
||||
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) ;
|
||||
@ -72,8 +74,7 @@ The functions of libsndfile are defined as follows:
|
||||
int <A HREF="#error">sf_error_str</A> (SNDFILE *sndfile, char* str, size_t len) ;
|
||||
|
||||
int <A HREF="#close">sf_close</A> (SNDFILE *sndfile) ;
|
||||
void <A HREF="#write_sync">sf_write_sync</A> (SNDFILE *sndfile) ;
|
||||
|
||||
|
||||
sf_count_t <A HREF="#read">sf_read_short</A> (SNDFILE *sndfile, short *ptr, sf_count_t items) ;
|
||||
sf_count_t <A HREF="#read">sf_read_int</A> (SNDFILE *sndfile, int *ptr, sf_count_t items) ;
|
||||
sf_count_t <A HREF="#read">sf_read_float</A> (SNDFILE *sndfile, float *ptr, sf_count_t items) ;
|
||||
@ -116,7 +117,7 @@ SNDFILE* is an anonymous pointer to data which is private to the library.
|
||||
|
||||
<P>
|
||||
The SF_INFO structure is for passing data between the calling function and the library
|
||||
when opening a file for reading or writing. It is defined in sndfile.h as follows:
|
||||
when opening a file for read or writing. It is defined in sndfile.h as follows:
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<PRE>
|
||||
@ -143,23 +144,23 @@ The mode parameter for this function can be any one of the following three value
|
||||
<P>
|
||||
When opening a file for read, the <b>format</B> field should be set to zero before
|
||||
calling sf_open().
|
||||
The only exception to this is the case of RAW files where the caller has to set
|
||||
the samplerate, channels and format fields to valid values.
|
||||
The only exception to this is the case of RAW files where the caller has to set in
|
||||
the channels and format fields to valid values.
|
||||
All other fields of the structure are filled in by the library.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
When opening a file for write, the caller must fill in structure members samplerate,
|
||||
channels, and format.
|
||||
channels, and format.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
The format field in the above SF_INFO structure is made up of the bit-wise OR of a
|
||||
major format type (values between 0x10000 and 0x08000000), a minor format type
|
||||
(with values less than 0x10000) and an optional endian-ness value.
|
||||
The currently understood formats are listed in sndfile.h as follows and also include
|
||||
The format field in the above SF_INFO structure is made up of the bit-wise OR of a
|
||||
major format type (values between 0x10000 and 0x08000000), a minor format type
|
||||
with (values less than 0x10000) and an optional endian-ness value.
|
||||
The currently understood formats are listed in sndfile.h as follows and also includes
|
||||
bitmasks for separating major and minor file types.
|
||||
Not all combinations of endian-ness and major and minor file types are valid.
|
||||
Not all combinations of endian-ness and major and minor file types are valid.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<PRE>
|
||||
@ -177,28 +178,19 @@ Not all combinations of endian-ness and major and minor file types are valid.
|
||||
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 */
|
||||
SF_FORMAT_AVR = 0x120000, /* Audio Visual Research */
|
||||
SF_FORMAT_WAVEX = 0x130000, /* MS WAVE with WAVEFORMATEX */
|
||||
SF_FORMAT_SD2 = 0x160000, /* Sound Designer 2 */
|
||||
SF_FORMAT_FLAC = 0x170000, /* FLAC lossless file format */
|
||||
SF_FORMAT_CAF = 0x180000, /* Core Audio File format */
|
||||
|
||||
|
||||
/* 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. */
|
||||
@ -206,26 +198,23 @@ Not all combinations of endian-ness and major and minor file types are valid.
|
||||
|
||||
SF_FORMAT_GSM610 = 0x0020, /* GSM 6.10 encoding. */
|
||||
SF_FORMAT_VOX_ADPCM = 0x0021, /* Oki Dialogic ADPCM encoding. */
|
||||
|
||||
|
||||
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
|
||||
@ -234,14 +223,14 @@ Not all combinations of endian-ness and major and minor file types are valid.
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
Every call to sf_open() should be matched with a call to sf_close() to free up
|
||||
memory allocated during the call to sf_open().
|
||||
memory allocated by during the call to sf_open().
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
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
|
||||
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.
|
||||
On fail, the sf_open functions return a NULL pointer.
|
||||
</P>
|
||||
|
||||
<A NAME="open_fd"></A>
|
||||
@ -252,9 +241,9 @@ On fail, the sf_open function returns a NULL pointer.
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The second open function takes a file descriptor of a file that has already been
|
||||
opened.
|
||||
Care should be taken to ensure that the mode of the file represented by the
|
||||
The second open function takes a file descriptor of a file that has already been
|
||||
opened.
|
||||
Care should be taken to ensure that the mode of the file represented by the
|
||||
descriptor matches the mode argument.
|
||||
This function is useful in the following circumstances:
|
||||
</P>
|
||||
@ -265,25 +254,22 @@ This function is useful in the following circumstances:
|
||||
which is then passed to libsndfile).
|
||||
<LI>Opening files with file names using OS specific character encodings
|
||||
and then passing the file descriptor to sf_open_fd().
|
||||
<LI>Opening sound files embedded within larger files.
|
||||
<LI>Opening sound files embedded within larger files.
|
||||
<A HREF="embedded_files.html">More info</A>.
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
Every call to sf_open_fd() should be matched with a call to sf_close() to free up
|
||||
memory allocated during the call to sf_open().
|
||||
memory allocated by during the call to sf_open().
|
||||
The file descriptor is only closed if the close_desc parameter was TRUE when the
|
||||
sf_open_fd() function was called.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
When sf_close() is called, the file descriptor is only closed if the <B>close_desc</B>
|
||||
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
|
||||
passed as the first parameter to all subsequent libsndfile calls dealing with
|
||||
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.
|
||||
On fail, the sf_open_fd functions return a NULL pointer.
|
||||
</P>
|
||||
|
||||
<A NAME="check"></A>
|
||||
@ -310,10 +296,10 @@ sf_format_check returns TRUE if the parameters are valid and FALSE otherwise.
|
||||
|
||||
<P>
|
||||
The file seek functions work much like lseek in unistd.h with the exception that
|
||||
the non-audio data is ignored and the seek only moves within the audio data section of
|
||||
the file.
|
||||
the non-audio data is ignored and the seek only moves within the audio data section of
|
||||
the file.
|
||||
In addition, seeks are defined in number of (multichannel) frames.
|
||||
Therefore, a seek in a stereo file from the current position forward with an offset
|
||||
Therefore, for a seek in a stereo file from the current position forward with an offset
|
||||
of 1 would skip forward by one sample of both channels.
|
||||
</P>
|
||||
|
||||
@ -328,22 +314,22 @@ like lseek(), the whence parameter can be any one of the following three values:
|
||||
</PRE>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
Internally, libsndfile keeps track of the read and write locations using separate
|
||||
read and write pointers.
|
||||
If a file has been opened with a mode of SFM_RDWR, bitwise OR-ing the standard whence
|
||||
values above with either SFM_READ or SFM_WRITE allows the read and write pointers to
|
||||
Internally, libsndfile keeps track of the read and write locations using separate
|
||||
read and write pointers.
|
||||
If a file has been opened with a mode of SFM_RDWR, bitwise OR-ing the standard whence
|
||||
values above with either SFM_READ or SFM_WRITE allows the read and write pointers to
|
||||
be modified separately.
|
||||
If the SEEK_* values are used on their own, the read and write pointers are
|
||||
both modified.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
Note that the frames offset can be negative and in fact should be when SEEK_END is used for the
|
||||
whence parameter.
|
||||
Note that frames offset can be negative and in fact should be when SEEK_END is used for the
|
||||
whence parameter.
|
||||
</P>
|
||||
<P>
|
||||
sf_seek will return the offset in (multichannel) frames from the start of the audio data
|
||||
or -1 if an error occured (ie an attempt is made to seek beyond the start or end of the file).
|
||||
or -1 if an error occurs (ie an attempt is made to seek beyond the start or end of the file).
|
||||
</P>
|
||||
|
||||
<A NAME="command"></A>
|
||||
@ -354,8 +340,8 @@ or -1 if an error occured (ie an attempt is made to seek beyond the start or end
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
This function allows the caller to retrieve information from or change aspects of the
|
||||
library behaviour on a per file basis. Examples include reading or writing text descriptions
|
||||
This function allows the caller to retrieve information from or change aspects of the
|
||||
library behaviour on a per file basis. Examples include reading or writing text descriptions
|
||||
to a file or changing the scaling applied to sample data during read and write.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
@ -367,7 +353,7 @@ pointer. For some calls no data is required in which case data should be NULL an
|
||||
datasize may be used for some other purpose.
|
||||
</P>
|
||||
<P>
|
||||
The return value of sf_command () depends on the value of the cmd parameter, but it is
|
||||
The return value of sf_command () depends on the value of the cmd parameter, but it is
|
||||
usually non-zero for success and zero on error.
|
||||
</P>
|
||||
<P>
|
||||
@ -388,17 +374,14 @@ The error number may be one of the following:
|
||||
<PRE>
|
||||
enum
|
||||
{ SF_ERR_NO_ERROR = 0,
|
||||
SF_ERR_UNRECOGNISED_FORMAT = 1,
|
||||
SF_ERR_SYSTEM = 2,
|
||||
SF_ERR_MALFORMED_FILE = 3,
|
||||
SF_ERR_UNSUPPORTED_ENCODING = 4
|
||||
SF_ERR_UNRECOGNISED_FORMAT = 1
|
||||
} ;
|
||||
</PRE>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
or any one of many other internal error values.
|
||||
Applications should only test the return value against error values defined in
|
||||
<sndfile.h> as the internal error values are subject to change at any
|
||||
<sndfile.h> as the internal error values are subject to change at any
|
||||
time.
|
||||
For errors not in the above list, the function sf_error_number() can be used to
|
||||
convert it to an error string.
|
||||
@ -410,8 +393,8 @@ convert it to an error string.
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The error functions sf_strerror() and sf_error_number() convert the library's internal
|
||||
error enumerations into text strings.
|
||||
The error functions sf_strerror() and sf_error_number() convert the library's internal
|
||||
error enumerations into text strings.
|
||||
</P>
|
||||
<PRE>
|
||||
int sf_perror (SNDFILE *sndfile) ;
|
||||
@ -419,7 +402,7 @@ error enumerations into text strings.
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The functions sf_perror() and sf_error_str() are deprecated and will be dropped
|
||||
The functions sf_perror() and sf_error_str() are depricated and will be dropped
|
||||
from the library at some later date.
|
||||
</P>
|
||||
|
||||
@ -431,25 +414,10 @@ from the library at some later date.
|
||||
</PRE>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
The close function closes the file, deallocates its internal buffers and returns
|
||||
0 on success or an error value otherwise.
|
||||
The close function closes the file, deallocates it's internal buffers and returns
|
||||
0 on success or an error value.
|
||||
</P>
|
||||
<BR>
|
||||
|
||||
<A NAME="write_sync"></A>
|
||||
<H2><BR><B>Write Sync Function</B></H2>
|
||||
|
||||
<PRE>
|
||||
void sf_write_sync (SNDFILE *sndfile) ;
|
||||
</PRE>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
If the file is opened SFM_WRITE or SFM_RDWR, call the operating system's function
|
||||
to force the writing of all file cache buffers to disk. If the file is opened
|
||||
SFM_READ no action is taken.
|
||||
</P>
|
||||
<BR>
|
||||
|
||||
<BR><BR>
|
||||
|
||||
<A NAME="read"></A>
|
||||
<H2><BR><B>File Read Functions (Items)</B></H2>
|
||||
@ -463,27 +431,27 @@ SFM_READ no action is taken.
|
||||
|
||||
<P>
|
||||
The file read items functions fill the array pointed to by ptr with the requested
|
||||
number of items. The items parameter must be an integer product of the number
|
||||
of channels or an error will occur.
|
||||
number of items. The items parameter must be an integer product of the number
|
||||
of channels or an error will occur.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
It is important to note that the data type used by the calling program and the data
|
||||
It is important to note that the data type used by the calling progarm and the data
|
||||
format of the file do not need to be the same. For instance, it is possible to open
|
||||
a 16 bit PCM encoded WAV file and read the data using sf_read_float(). The library
|
||||
seamlessly converts between the two formats on-the-fly. See
|
||||
seamleassly converts between the two formats on-the-fly. See
|
||||
<A HREF="#note1">Note 1</A>.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
The sf_read_XXXX functions return the number of items read.
|
||||
Unless the end of the file was reached during the read, the return value should
|
||||
equal the number of items requested.
|
||||
Attempts to read beyond the end of the file will not result in an error but will
|
||||
cause the sf_read_XXXX functions to return less than the number of items requested
|
||||
or 0 if already at the end of the file.
|
||||
The sf_read_XXXX functions return the number of items read.
|
||||
Unless the end of the file was reached during the read, the return value should
|
||||
equal the number of items requested.
|
||||
Attempts to read beyond the end of the file will not result in an error but will
|
||||
cause the sf_read_XXXX functions to return less than the number of items requested
|
||||
or 0 if already at the end of the file.
|
||||
</P>
|
||||
|
||||
|
||||
<A NAME="readf"></A>
|
||||
<H2><BR><B>File Read Functions (Frames)</B></H2>
|
||||
|
||||
@ -501,19 +469,19 @@ frames and the number of channels.
|
||||
</P>
|
||||
|
||||
<P><B>
|
||||
Care must be taken to ensure that there is enough space in the array pointed to by
|
||||
Care must be taken insure that there is enough space in the array pointed to by
|
||||
ptr, to take (frames * channels) number of items (shorts, ints, floats or doubles).
|
||||
</B></P>
|
||||
|
||||
<P>
|
||||
The sf_readf_XXXX functions return the number of frames read.
|
||||
Unless the end of the file was reached during the read, the return value should equal
|
||||
the number of frames requested.
|
||||
Attempts to read beyond the end of the file will not result in an error but will cause
|
||||
the sf_readf_XXXX functions to return less than the number of frames requested or 0 if
|
||||
already at the end of the file.
|
||||
The sf_readf_XXXX functions return the number of frames read.
|
||||
Unless the end of the file was reached during the read, the return value should equal
|
||||
the number of frames requested.
|
||||
Attempts to read beyond the end of the file will not result in an error but will cause
|
||||
the sf_readf_XXXX functions to return less than the number of frames requested or 0 if
|
||||
already at the end of the file.
|
||||
</P>
|
||||
|
||||
|
||||
<A NAME="write"></A>
|
||||
<H2><BR><B>File Write Functions (Items)</B></H2>
|
||||
|
||||
@ -526,22 +494,22 @@ already at the end of the file.
|
||||
|
||||
<P>
|
||||
The file write items functions write the data in the array pointed to by ptr to the file.
|
||||
The items parameter must be an integer product of the number of channels or an error
|
||||
The items parameter must be an integer product of the number of channels or an error
|
||||
will occur.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
It is important to note that the data type used by the calling program and the data
|
||||
It is important to note that the data type used by the calling progarm and the data
|
||||
format of the file do not need to be the same. For instance, it is possible to open
|
||||
a 16 bit PCM encoded WAV file and write the data using sf_write_float(). The library
|
||||
seamlessly converts between the two formats on-the-fly. See
|
||||
seamleassly converts between the two formats on-the-fly. See
|
||||
<A HREF="#note1">Note 1</A>.
|
||||
</P>
|
||||
<P>
|
||||
The sf_write_XXXX functions return the number of items written (which should be the
|
||||
same as the items parameter).
|
||||
</P>
|
||||
|
||||
|
||||
<A NAME="writef"></A>
|
||||
<H2><BR><B>File Write Functions (Frames)</B></H2>
|
||||
|
||||
@ -558,9 +526,9 @@ The array must be large enough to hold the product of frames and the number of c
|
||||
</P>
|
||||
<P>
|
||||
The sf_writef_XXXX functions return the number of frames written (which should be the
|
||||
same as the frames parameter).
|
||||
same as the frames parameter).
|
||||
</P>
|
||||
|
||||
|
||||
<A NAME="raw"></A>
|
||||
<H2><BR><B>Raw File Read and Write Functions</B></H2>
|
||||
<!-- pepper -->
|
||||
@ -570,20 +538,20 @@ same as the frames parameter).
|
||||
</PRE>
|
||||
|
||||
<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
|
||||
must always be an integer multiple of the number of channels multiplied by the number
|
||||
The raw write 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
|
||||
must always be an integer multiple of the number of channels multiplied by the number
|
||||
of bytes required to represent one sample from one channel.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
The raw read and write functions return the number of bytes read or written (which
|
||||
should be the same as the bytes parameter).
|
||||
The raw read and write functions return the number of bytes read or written (which
|
||||
should be the same as the bytes parameter).
|
||||
</P>
|
||||
|
||||
<P>
|
||||
<B>
|
||||
Note : The result of using of both regular reads/writes and raw reads/writes on
|
||||
Note : The result of using of both regular reads/writes and raw reads/wites on
|
||||
compressed file formats other than SF_FORMAT_ALAW and SF_FORMAT_ULAW is undefined.
|
||||
</B>
|
||||
</P>
|
||||
@ -598,8 +566,8 @@ compressed file formats other than SF_FORMAT_ALAW and SF_FORMAT_ULAW is undefine
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
These functions allow strings to be set on files opened for write and to be
|
||||
retrieved from files opened for read where supported by the given file type.
|
||||
These functions allow strings to be set on files open for write and to be
|
||||
retrieved from files open for read where supported by the given file type.
|
||||
The <B>str_type</B> parameter can be any one of the following string types:
|
||||
</P>
|
||||
|
||||
@ -615,16 +583,13 @@ The <B>str_type</B> parameter can be any one of the following string types:
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The sf_get_string() function returns the specificed string if it exists and a
|
||||
The sf_get_string() function returns the specificed 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
|
||||
available to allow iteration over all the available string ids.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
The sf_set_string() function sets the string data.
|
||||
It returns zero on success and non-zero on error.
|
||||
It returns zero on success and non-zero on error.
|
||||
The error code can be converted to a string using sf_error_number().
|
||||
</P>
|
||||
|
||||
@ -639,21 +604,21 @@ The error code can be converted to a string using sf_error_number().
|
||||
<H2><BR><B>Note 1</B></H2>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
When converting between integer PCM formats of differing size (ie using sf_read_int()
|
||||
to read a 16 bit PCM encoded WAV file) libsndfile obeys one simple rule:
|
||||
When converting between integer PCM formats of differing size (ie using sf_read_int()
|
||||
to read a 16 bit PCM encoded WAV file) libsndfile obeys one simple rule:
|
||||
</P>
|
||||
|
||||
<P CLASS=indent_block>
|
||||
Whenever integer data is moved from one sized container to another sized container,
|
||||
the most significant bit in the source container will become the most significant bit
|
||||
in the destination container.
|
||||
Whenever integer data is moved from one sized container to another sized container,
|
||||
the most significant bit in the source container will become the most significant bit
|
||||
in the destination container.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
When converting between integer data and floating point data, different rules apply.
|
||||
The default behaviour when reading floating point data (sf_read_float() or
|
||||
sf_read_double ()) from a file with integer data is normalisation. Regardless of
|
||||
whether data in the file is 8, 16, 24 or 32 bit wide, the data will be read as
|
||||
The default behaviour when reading floating point data (sf_read_float() or
|
||||
sf_read_double ()) from a file with integer data is normalisation. Regardless of
|
||||
whether data in the file is 8, 16, 24 or 32 bit wide, the data will be read as
|
||||
floating point data in the range [-1.0, 1.0]. Similarly, data in the range [-1.0, 1.0]
|
||||
will be written to an integer PCM file so that a data value of 1.0 will be the largest
|
||||
allowable integer for the given bit width. This normalisation can be turned on or off
|
||||
@ -664,27 +629,21 @@ using the <A HREF="command.html">sf_command</A> interface.
|
||||
<H2><BR><B>Note 2</B></H2>
|
||||
|
||||
<P>
|
||||
Reading a file containg floating point data (allowable with WAV, AIFF, AU and other
|
||||
file formats) using integer read methods (sf_read_short() or sf_read_int()) can
|
||||
produce unexpected results.
|
||||
For instance the data in the file may have a maximum absolute value < 1.0 which
|
||||
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
|
||||
<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.
|
||||
Reading a file containg floating point data (allowable with WAV, AIFF, AU and other
|
||||
file formats) using integer read methods (sf_read_short() or sf_read_int()) is
|
||||
discouraged as the library cannot guarantee sensible results. For instance the data
|
||||
in the file may have a maximum absolute value < 1.0 which would mean that all samples
|
||||
values read from the file will be zero.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<HR>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
The libsndfile home page is
|
||||
<A HREF="http://www.mega-nerd.com/libsndfile/">here</A>.
|
||||
The libsndfile home page is
|
||||
<A HREF="http://www.zip.com.au/~erikd/libsndfile/">here</A>.
|
||||
</P>
|
||||
<P>
|
||||
Version : 1.0.17
|
||||
Version : 1.0.6
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<!-- pepper -->
|
||||
@ -696,8 +655,8 @@ Version : 1.0.17
|
||||
|
||||
<!--
|
||||
Do not edit or modify anything in this comment block.
|
||||
The arch-tag line is a file identity tag for the GNU Arch
|
||||
The arch-tag line is a file identity tag for the GNU Arch
|
||||
revision control system.
|
||||
|
||||
|
||||
arch-tag: f6d3aa8f-983a-4ad3-9681-346e122d815e
|
||||
-->
|
||||
|
@ -5,59 +5,49 @@
|
||||
<TITLE>
|
||||
Bug Reporting
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT zip DOT com DOT au)">
|
||||
<LINK REL=StyleSheet HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#9090FF" VLINK="#5050FF" ALINK="#FF00FF">
|
||||
|
||||
<CENTER>
|
||||
<H1><B>Reporting Bugs in libsndfile</B></H1>
|
||||
</CENTER>
|
||||
<P>
|
||||
Before even attempting to report a bug in libsndfile please make sure you have
|
||||
read the
|
||||
<A HREF="FAQ.html">Frequently Asked Questions</A>.
|
||||
If you are having a problem writing code using libsndfile make sure you read
|
||||
the
|
||||
<A HREF="api.html">Application Programming Interface</A>
|
||||
documentation.
|
||||
read all the documentation, especially the
|
||||
<A HREF="api.html">Application Programming Interface</A>
|
||||
docs and the
|
||||
<A HREF="FAQ.html">Frequently Asked Questions</A>.
|
||||
</P>
|
||||
<P>
|
||||
That said, I am interested in finding and fixing all genuine bugs in libsndfile.
|
||||
That said, I am interested in finding and fixing all genuine bugs in libsndfile.
|
||||
Bugs I want to fix include any of the following problems (and probably others) :
|
||||
</P>
|
||||
<UL>
|
||||
<LI> Compilation problems on new platforms.
|
||||
<LI> Errors being detected during the `make check' process.
|
||||
<LI> Segmentation faults occuring inside libsndfile.
|
||||
<LI> libsndfile hanging when opening a file.
|
||||
<LI> Supported sound file types being incorrectly read or written.
|
||||
<LI> Omissions, errors or spelling mistakes in the documentation.
|
||||
<LI> compilation problems on new platforms
|
||||
<LI> errors being detected during the `make check' process
|
||||
<LI> segmentation faults occuring inside libsndfile
|
||||
<LI> libsndfile hanging when opening a file
|
||||
<LI> supported sound file types being incorrectly read or written
|
||||
<LI> ommissions, errors or spelling mistakes in the documentation
|
||||
</UL>
|
||||
|
||||
|
||||
<P>
|
||||
When submitting a bug report you must include :
|
||||
</P>
|
||||
<UL>
|
||||
<LI> Your system (CPU and memory size should be enough).
|
||||
<LI> The operating system you are using.
|
||||
<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".)
|
||||
<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
|
||||
need information about your kernel, ALSA version, compiler version,
|
||||
whether you compiled the kernel/ALSA your self or installed from a
|
||||
package etc.
|
||||
<LI> the operating system you are using
|
||||
<LI> the compiler you are using
|
||||
<LI> a description of the problem
|
||||
<LI> information generated by the sndfile-info program (see next paragraph)
|
||||
</UL>
|
||||
|
||||
|
||||
<P>
|
||||
If libsndfile compiles and installs correctly but has difficulty reading a particular
|
||||
file or type of file you should run the <B>sndfile-info</B> program (from the examples
|
||||
directory of the libsndfile distribution) on the file. See
|
||||
If libsndfile compiles and installs correctly but has difficulty reading a particular
|
||||
file or type of file you should run the <B>sndfile-info</B> program (from the examples
|
||||
directory of the libsndfile distribution) on the file. See
|
||||
<A HREF="sndfile_info.html">here</A>
|
||||
for an example of the use of the <B>sndfile-info</B> program.
|
||||
</P>
|
||||
@ -67,18 +57,18 @@
|
||||
problems.
|
||||
</P>
|
||||
<P>
|
||||
Once you have the above information you should email it to one of the
|
||||
Once you have the above information should email it to one of the
|
||||
<A HREF="lists.html">mailing lists</a>
|
||||
(posting to these lists is limited to the list subscribers).
|
||||
|
||||
|
||||
</P>
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
<!--
|
||||
Do not edit or modify anything in this comment block.
|
||||
The arch-tag line is a file identity tag for the GNU Arch
|
||||
The arch-tag line is a file identity tag for the GNU Arch
|
||||
revision control system.
|
||||
|
||||
|
||||
arch-tag: 1533a2ca-489c-4190-b602-ecae1cc992e4
|
||||
-->
|
||||
|
421
doc/command.html
421
doc/command.html
@ -5,14 +5,15 @@
|
||||
<TITLE>
|
||||
libsndfile : the sf_command function.
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT zip DOT com DOT au)">
|
||||
<META NAME="Version" CONTENT="Version 1.0.6">
|
||||
<!-- 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">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#5050FF" VLINK="#5050FF" ALINK="#FF00FF">
|
||||
|
||||
<H1><B>sf_command</B></H1>
|
||||
<PRE>
|
||||
@ -20,18 +21,18 @@
|
||||
int sf_command (SNDFILE *sndfile, int cmd, void *data, int datasize) ;
|
||||
</PRE>
|
||||
<P>
|
||||
This function allows the caller to retrieve information from or change aspects of the
|
||||
library behaviour.
|
||||
Examples include retrieving a string containing the library version or changing the
|
||||
This function allows the caller to retrieve information from or change aspects of the
|
||||
library behaviour.
|
||||
Examples include retrieving a string containing the library version or changing the
|
||||
scaling applied to floating point sample data during read and write.
|
||||
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>.
|
||||
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.
|
||||
For some calls no data is required in which case data should be NULL and datasize
|
||||
All of the valid command identifiers have names begining 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.
|
||||
For some calls no data is required in which case data should be NULL and datasize
|
||||
may be used for some other purpose.
|
||||
</P>
|
||||
<P>
|
||||
@ -50,35 +51,26 @@
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_CALC_SIGNAL_MAX">SFC_CALC_SIGNAL_MAX</A></TD>
|
||||
<TD>Calculate the measured maximum signal value.</TD>
|
||||
<TD>Retrieve the measured maximum signal value.</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_CALC_NORM_SIGNAL_MAX">SFC_CALC_NORM_SIGNAL_MAX</A></TD>
|
||||
<TD>Calculate the measured normalised maximum signal value.</TD>
|
||||
<TD>Retrieve the measured normalised maximum signal value.</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_CALC_MAX_ALL_CHANNELS">SFC_CALC_MAX_ALL_CHANNELS</A></TD>
|
||||
<TD>Calculate the peak value for each channel.</TD>
|
||||
<TD>Calculate peaks for all channels.</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_CALC_NORM_MAX_ALL_CHANNELS">SFC_CALC_NORM_MAX_ALL_CHANNELS</A></TD>
|
||||
<TD>Calculate the normalised peak for each channel.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_GET_SIGNAL_MAX">SFC_GET_SIGNAL_MAX</A></TD>
|
||||
<TD>Retrieve the peak value for the file (as stored in the file header).</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_GET_MAX_ALL_CHANNELS">SFC_GET_MAX_ALL_CHANNELS</A></TD>
|
||||
<TD>Retrieve the peak value for each channel (as stored in the file header).</TD>
|
||||
<TD>Calculate normalised peaks for all channels.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_SET_NORM_FLOAT">SFC_SET_NORM_FLOAT</A></TD>
|
||||
<TD>Modify the normalisation behaviour of the floating point reading and writing functions.</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_SET_NORM_DOUBLE">SFC_SET_NORM_DOUBLE</A></TD>
|
||||
<TD>Modify the normalisation behaviour of the double precision floating point reading and writing functions.</TD>
|
||||
</TR>
|
||||
@ -86,15 +78,10 @@
|
||||
<TD><A HREF="#SFC_GET_NORM_FLOAT">SFC_GET_NORM_FLOAT</A></TD>
|
||||
<TD>Retrieve the current normalisation behaviour of the floating point reading and writing functions.</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_GET_NORM_DOUBLE">SFC_GET_NORM_DOUBLE</A></TD>
|
||||
<TD>Retrieve the current normalisation behaviour of the double precision floating point reading and writing functions.</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_SET_SCALE_FLOAT_INT_READ">SFC_SET_SCALE_FLOAT_INT_READ</A></TD>
|
||||
<TD>Set/clear the scale factor when integer (short/int) data is read from a file
|
||||
containing floating point data.</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_GET_SIMPLE_FORMAT_COUNT">SFC_GET_SIMPLE_FORMAT_COUNT</A></TD>
|
||||
<TD>Retrieve the number of simple formats supported by libsndfile.</TD>
|
||||
@ -152,31 +139,7 @@
|
||||
<TD>Change the data start offset for files opened up as SF_FORMAT_RAW.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_SET_CLIPPING">SFC_SET_CLIPPING</A></TD>
|
||||
<TD>Turn on/off automatic clipping when doing floating point to integer
|
||||
conversion.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_GET_CLIPPING">SFC_GET_CLIPPING</A></TD>
|
||||
<TD>Retreive 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>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_WAVEX_GET_AMBISONIC">SFC_GET_AMBISONIC</A></TD>
|
||||
<TD>Test a WAVEX file for Ambisonic format</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><A HREF="#SFC_WAVEX_SET_AMBISONIC">SFC_SET_AMBISONIC</A></TD>
|
||||
<TD>Modify a WAVEX header for Ambisonic format</TD>
|
||||
</TR>
|
||||
|
||||
<!--
|
||||
<TR>
|
||||
@ -184,7 +147,7 @@
|
||||
<TD>Add dither to output on write.</TD>
|
||||
</TR>
|
||||
-->
|
||||
</TABLE>
|
||||
</TABLE>
|
||||
</CENTER>
|
||||
|
||||
<BR><BR>
|
||||
@ -291,7 +254,7 @@ Example:
|
||||
<A NAME="SFC_CALC_NORM_SIGNAL_MAX"></A>
|
||||
<H2><BR><B>SFC_CALC_NORM_SIGNAL_MAX</B></H2>
|
||||
<P>
|
||||
Retrieve the measured normalised maximum signal value. This involves reading
|
||||
Retrieve the measured normailised maximum signal value. This involves reading
|
||||
through the whole file which can be slow on large files.
|
||||
</P>
|
||||
<P>
|
||||
@ -319,8 +282,8 @@ Example:
|
||||
<A NAME="SFC_CALC_MAX_ALL_CHANNELS"></A>
|
||||
<H2><BR><B>SFC_CALC_MAX_ALL_CHANNELS</B></H2>
|
||||
<P>
|
||||
Calculate the peak value (ie a single number) for each channel.
|
||||
This involves reading through the whole file which can be slow on large files.
|
||||
Calculate peaks for all channels. This involves reading through
|
||||
the whole file which can be slow on large files.
|
||||
</P>
|
||||
<P>
|
||||
Parameters:
|
||||
@ -347,8 +310,8 @@ Example:
|
||||
<A NAME="SFC_CALC_NORM_MAX_ALL_CHANNELS"></A>
|
||||
<H2><BR><B>SFC_CALC_NORM_MAX_ALL_CHANNELS</B></H2>
|
||||
<P>
|
||||
Calculate the normalised peak for each channel.
|
||||
This involves reading through the whole file which can be slow on large files.
|
||||
Calculate normalised peaks for all channels. This involves reading through
|
||||
the whole file which can be slow on large files.
|
||||
</P>
|
||||
<P>
|
||||
Parameters:
|
||||
@ -373,59 +336,6 @@ Example:
|
||||
|
||||
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="SFC_GET_SIGNAL_MAX"></A>
|
||||
<H2><BR><B>SFC_GET_SIGNAL_MAX</B></H2>
|
||||
<P>
|
||||
Retrieve the peak value for the file as stored in the file header.
|
||||
</P>
|
||||
<P>
|
||||
Parameters:
|
||||
<PRE>
|
||||
sndfile : A valid SNDFILE* pointer
|
||||
cmd : SFC_GET_SIGNAL_MAX
|
||||
data : A pointer to a double
|
||||
datasize : sizeof (double)
|
||||
</PRE>
|
||||
<P>
|
||||
Example:
|
||||
</P>
|
||||
<PRE>
|
||||
double max_peak ;
|
||||
sf_command (sndfile, SFC_GET_SIGNAL_MAX, &max_peak, sizeof (max_peak)) ;
|
||||
</PRE>
|
||||
<DL>
|
||||
<DT>Return value:</DT>
|
||||
<DD>SF_TRUE if the file header contained the peak value. SF_FALSE otherwise.
|
||||
</DL>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="SFC_GET_MAX_ALL_CHANNELS"></A>
|
||||
<H2><BR><B>SFC_GET_MAX_ALL_CHANNELS</B></H2>
|
||||
<P>
|
||||
Retrieve the peak value for the file as stored in the file header.
|
||||
</P>
|
||||
<P>
|
||||
Parameters:
|
||||
<PRE>
|
||||
sndfile : A valid SNDFILE* pointer
|
||||
cmd : SFC_GET_SIGNAL_MAX
|
||||
data : A pointer to an array of doubles
|
||||
datasize : sizeof (double) * number_of_channels
|
||||
</PRE>
|
||||
<P>
|
||||
Example:
|
||||
</P>
|
||||
<PRE>
|
||||
double peaks [number_of_channels] ;
|
||||
sf_command (sndfile, SFC_GET_MAX_ALL_CHANNELS, peaks, sizeof (peaks)) ;
|
||||
</PRE>
|
||||
<DL>
|
||||
<DT>Return value:</DT>
|
||||
<DD>SF_TRUE if the file header contains per channel peak values for the file.
|
||||
SF_FALSE otherwise.
|
||||
</DL>
|
||||
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="SFC_SET_NORM_FLOAT"></A>
|
||||
@ -450,7 +360,7 @@ Parameters:
|
||||
datasize : SF_TRUE or SF_FALSE
|
||||
</PRE>
|
||||
<P>
|
||||
For read operations setting normalisation to SF_TRUE means that the data from all
|
||||
For read operations setting normalisation to SF_TRUE means that the data from all
|
||||
subsequent reads will be be normalised to the range [-1.0, 1.0].
|
||||
</P>
|
||||
<P>
|
||||
@ -471,14 +381,14 @@ Example:
|
||||
</PRE>
|
||||
<DL>
|
||||
<DT>Return value: </DT>
|
||||
<DD>Returns the previous float normalisation mode.
|
||||
<DD>Returns 1 on success or 0 for failure.
|
||||
</DL>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="SFC_SET_NORM_DOUBLE"></A>
|
||||
<H2><BR><B>SFC_SET_NORM_DOUBLE</B></H2>
|
||||
<P>
|
||||
This command only affects data read from or written to using the double precision
|
||||
This command only affects data read from or written to using the double precision
|
||||
floating point functions:
|
||||
</P>
|
||||
<PRE>
|
||||
@ -498,7 +408,7 @@ Parameters:
|
||||
datasize : SF_TRUE or SF_FALSE
|
||||
</PRE>
|
||||
<P>
|
||||
For read operations setting normalisation to SF_TRUE means that the data
|
||||
For read operations setting normalisation to SF_TRUE means that the data
|
||||
from all subsequent reads will be be normalised to the range [-1.0, 1.0].
|
||||
</P>
|
||||
<P>
|
||||
@ -519,7 +429,7 @@ Example:
|
||||
</PRE>
|
||||
<DL>
|
||||
<DT>Return value: </DT>
|
||||
<DD>Returns the previous double normalisation mode.
|
||||
<DD>Returns 1 on success or 0 for failure.
|
||||
</DL>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
@ -545,7 +455,7 @@ Example:
|
||||
</PRE>
|
||||
<DL>
|
||||
<DT>Return value: </DT>
|
||||
<DD>Returns TRUE if normalisation is on and FALSE otherwise.
|
||||
<DD>Returns TRUE if normaisation is on and FALSE otherwise.
|
||||
</DL>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
@ -574,35 +484,6 @@ Example:
|
||||
<DD>Returns TRUE if normalisation is on and FALSE otherwise.
|
||||
</DL>
|
||||
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="SFC_SET_SCALE_FLOAT_INT_READ"></A>
|
||||
<H2><BR><B>SFC_SET_SCALE_FLOAT_INT_READ</B></H2>
|
||||
<P>
|
||||
Set/clear the scale factor when integer (short/int) data is read from a file
|
||||
containing floating point data.
|
||||
</P>
|
||||
<P>
|
||||
Parameters:
|
||||
</P>
|
||||
<PRE>
|
||||
sndfile : A valid SNDFILE* pointer
|
||||
cmd : SFC_SET_SCALE_FLOAT_INT_READ
|
||||
data : NULL
|
||||
datasize : TRUE or FALSE
|
||||
</PRE>
|
||||
<P>
|
||||
Example:
|
||||
</P>
|
||||
<PRE>
|
||||
sf_command (sndfile, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;
|
||||
</PRE>
|
||||
<DL>
|
||||
<DT>Return value: </DT>
|
||||
<DD>Returns the previous SFC_SET_SCALE_FLOAT_INT_READ setting for this file.
|
||||
</DL>
|
||||
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="SFC_GET_SIMPLE_FORMAT_COUNT"></A>
|
||||
<H2><BR><B>SFC_GET_SIMPLE_FORMAT_COUNT</B></H2>
|
||||
@ -656,8 +537,8 @@ The SF_FORMAT_INFO struct is defined in <sndfile.h> as:
|
||||
} SF_FORMAT_INFO ;
|
||||
</PRE>
|
||||
<P>
|
||||
When sf_command() is called with SF_GET_SIMPLE_FORMAT, the value of the format
|
||||
field should be the format number (ie 0 <= format <= count value obtained using
|
||||
When sf_command() is called with SF_GET_SIMPLE_FORMAT, the value of the format
|
||||
field should be the format number (ie 0 <= format <= count value obtained using
|
||||
SF_GET_SIMPLE_FORMAT_COUNT).
|
||||
</P>
|
||||
<P>
|
||||
@ -669,7 +550,7 @@ Example:
|
||||
|
||||
sf_command (sndfile, SFC_GET_SIMPLE_FORMAT_COUNT, &count, sizeof (int)) ;
|
||||
|
||||
for (k = 0 ; k < count ; k++)
|
||||
for (k = 0 ; k < count ; k++)
|
||||
{ format_info.format = k ;
|
||||
sf_command (sndfile, SFC_GET_SIMPLE_FORMAT, &format_info, sizeof (format_info)) ;
|
||||
printf ("%08x %s %s\n", format_info.format, format_info.name, format_info.extension) ;
|
||||
@ -678,11 +559,11 @@ Example:
|
||||
<DL>
|
||||
<DT>Return value: </DT>
|
||||
<DD>0 on success and non-zero otherwise.
|
||||
<DD>The value of the format field of the SF_FORMAT_INFO struct will be a value which
|
||||
can be placed in the format field of an SF_INFO struct when a file is to be opened
|
||||
<DD>The value of the format field of the SF_FORMAT_INFO struct will be an value which
|
||||
can be placed in the format field of an SF_INFO struct when a file is to be opened
|
||||
for write.
|
||||
<DD>The name field will contain a char* pointer to the name of the string, eg. "WAV (Microsoft 16 bit PCM)".
|
||||
<DD>The extension field will contain the most commonly used file extension for that file type.
|
||||
<DD>The name field will contain a char* pointer to the name of the string ie "WAV (Microsoft 16 bit PCM)".
|
||||
<DD>The extention field will contain the most commonly used file extension for that file type.
|
||||
</DL>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
@ -711,11 +592,11 @@ The SF_FORMAT_INFO struct is defined in <sndfile.h> as:
|
||||
} SF_FORMAT_INFO ;
|
||||
</PRE>
|
||||
<P>
|
||||
When sf_command() is called with SF_GET_FORMAT_INFO, the format field is
|
||||
examined and if (format & SF_FORMAT_TYPEMASK) is a valid format then the struct
|
||||
When sf_command() is called with SF_GET_FORMAT_INFO, the format field is
|
||||
examined and if (format & SF_FORMAT_TYPEMASK) is a valid format then the struct
|
||||
is filled in with information about the given major type.
|
||||
If (format & SF_FORMAT_TYPEMASK) is FALSE and (format & SF_FORMAT_SUBMASK) is a
|
||||
valid subtype format then the struct is filled in with information about the given
|
||||
If (format & SF_FORMAT_TYPEMASK) is FALSE and (format & SF_FORMAT_SUBMASK) is a
|
||||
valid subtype format then the struct is filled in with information about the given
|
||||
subtype.
|
||||
</P>
|
||||
<P>
|
||||
@ -787,7 +668,7 @@ Example:
|
||||
|
||||
sf_command (sndfile, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof (int)) ;
|
||||
|
||||
for (k = 0 ; k < count ; k++)
|
||||
for (k = 0 ; k < count ; k++)
|
||||
{ format_info.format = k ;
|
||||
sf_command (sndfile, SFC_GET_FORMAT_MAJOR, &format_info, sizeof (format_info)) ;
|
||||
printf ("%08x %s %s\n", format_info.format, format_info.name, format_info.extension) ;
|
||||
@ -800,10 +681,10 @@ directory of the libsndfile source code distribution.
|
||||
<DL>
|
||||
<DT>Return value: </DT>
|
||||
<DD>0 on success and non-zero otherwise.
|
||||
<DD>The value of the format field will be one of the major format identifiers such as
|
||||
SF_FORMAT_WAV or SF_FORMAT_AIFF.
|
||||
<DD>The name field will contain a char* pointer to the name of the string, eg. "WAV (Microsoft)".
|
||||
<DD>The extension field will contain the most commonly used file extension for that file type.
|
||||
<DD>The value of the format field will one of the major format identifiers suc as SF_FORMAT_WAV
|
||||
SF_FORMAT_AIFF.
|
||||
<DD>The name field will contain a char* pointer to the name of the string ie "WAV (Microsoft)".
|
||||
<DD>The extention field will contain the most commonly used file extension for that file type.
|
||||
</DL>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
@ -837,13 +718,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
|
||||
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.
|
||||
</P>
|
||||
<P>
|
||||
|
||||
Retrieve information about a subformat.
|
||||
</P>
|
||||
<P>
|
||||
Parameters:
|
||||
@ -855,7 +730,7 @@ Parameters:
|
||||
datasize : sizeof (SF_FORMAT_INFO)
|
||||
</PRE>
|
||||
<P>
|
||||
Example 1: Retrieve all subytpes supported by the WAV format.
|
||||
Example:
|
||||
</P>
|
||||
<PRE>
|
||||
SF_FORMAT_INFO format_info ;
|
||||
@ -863,51 +738,34 @@ Example 1: Retrieve all subytpes supported by the WAV format.
|
||||
|
||||
sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE_COUNT, &count, sizeof (int)) ;
|
||||
|
||||
for (k = 0 ; k < count ; k++)
|
||||
/* Retrieve all the subtypes supported by the WAV format. */
|
||||
for (k = 0 ; k < count ; k++)
|
||||
{ format_info.format = k ;
|
||||
sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE, &format_info, sizeof (format_info)) ;
|
||||
if (! sf_format_check (format_info.format | SF_FORMAT_WAV))
|
||||
if (! sf_format_check (format.info | SF_FORMAT_WAV))
|
||||
continue ;
|
||||
printf ("%08x %s\n", format_info.format, format_info.name) ;
|
||||
} ;
|
||||
</PRE>
|
||||
<P>
|
||||
Example 2: Print a string describing the SF_FORMAT_PCM_16 subtype.
|
||||
</P>
|
||||
<PRE>
|
||||
SF_FORMAT_INFO format_info ;
|
||||
int k, count ;
|
||||
|
||||
sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE_COUNT, &count, sizeof (int)) ;
|
||||
|
||||
for (k = 0 ; k < count ; k++)
|
||||
{ format_info.format = k ;
|
||||
sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE, &format_info, sizeof (format_info)) ;
|
||||
if (format_info.format == SF_FORMAT_PCM_16)
|
||||
{ printf ("%08x %s\n", format_info.format, format_info.name) ;
|
||||
break ;
|
||||
} ;
|
||||
} ;
|
||||
</PRE>
|
||||
<P>
|
||||
For a more comprehensive example, see the program list_formats.c in the examples/
|
||||
directory of the libsndfile source code distribution.
|
||||
</P>
|
||||
<DL>
|
||||
<DT>Return value: </DT>
|
||||
<DD>0 on success and non-zero otherwise.
|
||||
<DD>The value of the format field will be one of the major format identifiers such as
|
||||
SF_FORMAT_WAV or SF_FORMAT_AIFF.
|
||||
<DD>The name field will contain a char* pointer to the name of the string; for instance
|
||||
<DD>The value of the format field will one of the major format identifiers such as SF_FORMAT_WAV
|
||||
SF_FORMAT_AIFF.
|
||||
<DD>The name field will contain a char* pointer to the name of the string; for instance
|
||||
"WAV (Microsoft)" or "AIFF (Apple/SGI)".
|
||||
<DD>The extension field will be a NULL pointer.
|
||||
<DD>The extention field will be a NULL pointer.
|
||||
</DL>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="SFC_SET_ADD_PEAK_CHUNK"></A>
|
||||
<H2><BR><B>SFC_SET_ADD_PEAK_CHUNK</B></H2>
|
||||
<P>
|
||||
By default, WAV and AIFF files which contain floating point data (subtype SF_FORMAT_FLOAT
|
||||
By default, WAV and AIFF files which contain floating point data (subtype SF_FORMAT_FLOAT
|
||||
or SF_FORMAT_DOUBLE) have a PEAK chunk.
|
||||
By using this command, the addition of a PEAK chunk can be turned on or off.
|
||||
</P>
|
||||
@ -948,9 +806,9 @@ closed using <B>sf_close()</B>.
|
||||
<P>
|
||||
There are however situations where large files are being generated and it would
|
||||
be nice to have valid data in the header before the file is complete.
|
||||
Using this command will update the file header to reflect the amount of data written
|
||||
Using this command will update the file header to reflect the amount of data written
|
||||
to the file so far.
|
||||
Other programs opening the file for read (before any more data is written) will
|
||||
Other programs opening the file for read (before any more data is written) will
|
||||
then read a valid sound file header.
|
||||
</P>
|
||||
<P>
|
||||
@ -1007,7 +865,7 @@ Example:
|
||||
<A NAME="SFC_FILE_TRUNCATE"></A>
|
||||
<H2><BR><B>SFC_FILE_TRUNCATE</B></H2>
|
||||
<P>
|
||||
Truncate a file that was opened for write or read/write.
|
||||
Truncate a file open for write or for read/write.
|
||||
</P>
|
||||
<P>
|
||||
Parameters:
|
||||
@ -1023,7 +881,7 @@ Truncate the file to the number of frames specified by the sf_count_t pointed
|
||||
to by data.
|
||||
After this command, both the read and the write pointer will be
|
||||
at the new end of the file.
|
||||
This command will fail (returning non-zero) if the requested truncate position
|
||||
This command will fail (returning non-zero) if the requested truncate position
|
||||
is beyond the end of the file.
|
||||
</P>
|
||||
<P>
|
||||
@ -1072,165 +930,14 @@ Example:
|
||||
</DL>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="SFC_SET_CLIPPING"></A>
|
||||
<H2><BR><B>SFC_SET_CLIPPING</B></H2>
|
||||
<P>
|
||||
Turn on/off automatic clipping when doing floating point to integer conversion.
|
||||
</P>
|
||||
<P>
|
||||
Parameters:
|
||||
<PRE>
|
||||
sndfile : A valid SNDFILE* pointer
|
||||
cmd : SFC_SET_CLIPPING
|
||||
data : NULL
|
||||
datasize : SF_TRUE or SF_FALSE.
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
Turn on (datasize == SF_TRUE) or off (datasize == SF_FALSE) clipping.
|
||||
</P>
|
||||
<P>
|
||||
Example:
|
||||
</P>
|
||||
<PRE>
|
||||
sf_command (sndfile, SFC_SET_CLIPPING, NULL, SF_TRUE) ;
|
||||
</PRE>
|
||||
<DL>
|
||||
<DT>Return value:</DT>
|
||||
<DD>Clipping mode (SF_TRUE or SF_FALSE).
|
||||
</DL>
|
||||
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="SFC_GET_CLIPPING"></A>
|
||||
<H2><BR><B>SFC_GET_CLIPPING</B></H2>
|
||||
<P>
|
||||
Turn on/off automatic clipping when doing floating point to integer conversion.
|
||||
</P>
|
||||
<P>
|
||||
Parameters:
|
||||
<PRE>
|
||||
sndfile : A valid SNDFILE* pointer
|
||||
cmd : SFC_GET_CLIPPING
|
||||
data : NULL
|
||||
datasize : 0
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
Retrieve the current cliiping setting.
|
||||
</P>
|
||||
<P>
|
||||
Example:
|
||||
</P>
|
||||
<PRE>
|
||||
sf_command (sndfile, SFC_GET_CLIPPING, NULL, 0) ;
|
||||
</PRE>
|
||||
<DL>
|
||||
<DT>Return value:</DT>
|
||||
<DD>Clipping mode (SF_TRUE or SF_FALSE).
|
||||
</DL>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="SFC_GET_EMBED_FILE_INFO"></A>
|
||||
<H2><BR><B>SFC_GET_EMBED_FILE_INFO</B></H2>
|
||||
<P>
|
||||
Get the file offset and file length of a file enbedded within another
|
||||
larger file.
|
||||
</P>
|
||||
<P>
|
||||
Parameters:
|
||||
<PRE>
|
||||
sndfile : A valid SNDFILE* pointer
|
||||
cmd : SFC_GET_CLIPPING
|
||||
data : a pointer to an SF_EMBED_FILE_INFO struct
|
||||
datasize : sizeof (SF_EMBED_FILE_INFO)
|
||||
</PRE>
|
||||
<P>
|
||||
The SF_FORMAT_INFO struct is defined in <sndfile.h> as:
|
||||
</P>
|
||||
<PRE>
|
||||
typedef struct
|
||||
{ sf_count_t offset ;
|
||||
sf_count_t length ;
|
||||
} SF_EMBED_FILE_INFO ;
|
||||
</PRE>
|
||||
<DL>
|
||||
<DT>Return value: </DT>
|
||||
<DD>0 on success and non-zero otherwise.
|
||||
<DD>The value of the offset field of the SF_EMBED_FILE_INFO struct will be
|
||||
the offsets in bytes from the start of the outer file to the start of
|
||||
the audio file.
|
||||
<DD>The value of the offset field of the SF_EMBED_FILE_INFO struct will be
|
||||
the length in bytes of the embedded file.
|
||||
</DL>
|
||||
|
||||
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="SFC_WAVEX_GET_AMBISONIC"></A>
|
||||
<H2><BR><B>SFC_WAVEX_GET_AMBISONIC</B></H2>
|
||||
<P>
|
||||
Test if the current file has the GUID of a WAVEX file for any of the Ambisonic
|
||||
formats.
|
||||
</P>
|
||||
<P>
|
||||
Parameters:
|
||||
<PRE>
|
||||
sndfile : A valid SNDFILE* pointer
|
||||
cmd : SFC_WAVEX_GET_AMBISONIC
|
||||
data : NULL
|
||||
datasize : 0
|
||||
</PRE>
|
||||
<P>
|
||||
The Ambisonic WAVEX formats are defined here :
|
||||
<A HREF="http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html">
|
||||
http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html</A>.
|
||||
</P>
|
||||
<DL>
|
||||
<DT>Return value: </DT>
|
||||
<DD>SF_AMBISONIC_NONE or SF_AMBISONIC_B_FORMAT or zero if the file format
|
||||
does not support ambisonic formats.
|
||||
</DL>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="SFC_WAVEX_SET_AMBISONIC"></A>
|
||||
<H2><BR><B>SFC_WAVEX_SET_AMBISONIC</B></H2>
|
||||
<P>
|
||||
Set the GUID of a new WAVEX file to indicate an Ambisonics format.
|
||||
</P>
|
||||
<P>
|
||||
Parameters:
|
||||
<PRE>
|
||||
sndfile : A valid SNDFILE* pointer
|
||||
cmd : SFC_WAVEX_SET_AMBISONIC
|
||||
data : NULL
|
||||
datasize : SF_AMBISONIC_NONE or SF_AMBISONIC_B_FORMAT
|
||||
</PRE>
|
||||
<P>
|
||||
Turn on (SF_AMBISONIC_B_FORMAT) or off (SF_AMBISONIC_NONE) encoding.
|
||||
This command is currently only supported for files with SF_FORMAT_WAVEX format.
|
||||
</P>
|
||||
<P>
|
||||
The Ambisonic WAVEX formats are defined here :
|
||||
<A HREF="http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html">
|
||||
http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html</A>.
|
||||
</P>
|
||||
<DL>
|
||||
<DT>Return value: </DT>
|
||||
<DD>Return the ambisonic value that has just been set or zero if the file
|
||||
format does not support ambisonic encoding.
|
||||
</DL>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
|
||||
<HR>
|
||||
<P>
|
||||
The libsndfile home page is here :
|
||||
<A HREF="http://www.mega-nerd.com/libsndfile/">
|
||||
http://www.mega-nerd.com/libsndfile/</A>.
|
||||
The libsndfile home page is here :
|
||||
<A HREF="http://www.zip.com.au/~erikd/libsndfile/">
|
||||
http://www.zip.com.au/~erikd/libsndfile/</A>.
|
||||
<BR>
|
||||
Version : 1.0.17
|
||||
Version : 1.0.6
|
||||
</P>
|
||||
|
||||
</BODY>
|
||||
@ -1238,8 +945,8 @@ Version : 1.0.17
|
||||
|
||||
<!--
|
||||
Do not edit or modify anything in this comment block.
|
||||
The arch-tag line is a file identity tag for the GNU Arch
|
||||
The arch-tag line is a file identity tag for the GNU Arch
|
||||
revision control system.
|
||||
|
||||
|
||||
arch-tag: 6ee72f74-0fb3-42b6-a85c-d3331d7145b5
|
||||
-->
|
||||
|
@ -5,14 +5,15 @@
|
||||
<TITLE>
|
||||
libsndfile : the sf_command function.
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT zip DOT com DOT au)">
|
||||
<META NAME="Version" CONTENT="Version 1.0.6">
|
||||
<!-- 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">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#5050FF" VLINK="#5050FF" ALINK="#FF00FF">
|
||||
|
||||
<H1><B>sf_command</B></H1>
|
||||
<PRE>
|
||||
@ -1006,10 +1007,10 @@ Example:
|
||||
<HR>
|
||||
<P>
|
||||
The libsndfile home page is here :
|
||||
<A HREF="http://www.mega-nerd.com/libsndfile/">
|
||||
http://www.mega-nerd.com/libsndfile/</A>.
|
||||
<A HREF="http://www.zip.com.au/~erikd/libsndfile/">
|
||||
http://www.zip.com.au/~erikd/libsndfile/</A>.
|
||||
<BR>
|
||||
Version : 1.0.17
|
||||
Version : 1.0.6
|
||||
</P>
|
||||
|
||||
</BODY>
|
||||
|
@ -5,13 +5,14 @@
|
||||
<TITLE>
|
||||
libsndfile : Embedded Sound Files.
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT zip DOT com DOT au)">
|
||||
<META NAME="Version" CONTENT="Version 1.0.6">
|
||||
<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">
|
||||
</HEAD>
|
||||
<!-- pepper -->
|
||||
<BODY>
|
||||
<BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#5050FF" VLINK="#5050FF" ALINK="#FF00FF">
|
||||
<!-- pepper -->
|
||||
<H1><B>Embedded Sound Files.</B></H1>
|
||||
|
||||
@ -37,7 +38,7 @@ There are however a couple of caveats:
|
||||
</UL>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
The test program <B>multi_file_test.c</B> in the <B>tests/</B> directory of the
|
||||
The test program <B>multi_file.c</B> in the <B>tests/</B> directory of the
|
||||
source code tarball shows how this functionality is used to read and write
|
||||
embedded files.
|
||||
</P>
|
||||
|
274
doc/index.html
274
doc/index.html
@ -5,59 +5,58 @@
|
||||
<TITLE>
|
||||
libsndfile
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<META NAME="Version" CONTENT="libsndfile-1.0.17">
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT zip DOT com DOT au)">
|
||||
<META NAME="Version" CONTENT="libsndfile-1.1.0pre1">
|
||||
<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">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#9090FF" VLINK="#5050FF" ALINK="#FF00FF">
|
||||
<!-- pepper -->
|
||||
<CENTER>
|
||||
<IMG SRC="libsndfile.jpg" HEIGHT=98 WIDTH=367 ALT="libsndfile.jpg">
|
||||
</CENTER>
|
||||
<!-- pepper -->
|
||||
<CENTER>
|
||||
<A HREF="#History">History</A> -+-
|
||||
<A HREF="#Features">Features</A> -+-
|
||||
<A HREF="#Similar">Similar or Related Projects</A> -+-
|
||||
<A HREF="#History">History</A> -+-
|
||||
<A HREF="#Features">Features</A> -+-
|
||||
<A HREF="#Similar">Similar or Related Projects</A>
|
||||
<BR>
|
||||
<A HREF="api.html">Programming Interface</A> -+-
|
||||
<A HREF="bugs.html">Bug Reporting</A> -+-
|
||||
<A HREF="#Download">Download</A> -+-
|
||||
<A HREF="NEWS">News</A>
|
||||
<BR>
|
||||
<A HREF="development.html">Development</A> -+-
|
||||
<A HREF="api.html">Programming Interface</A> -+-
|
||||
<A HREF="bugs.html">Bug Reporting</A> -+-
|
||||
<A HREF="#Download">Download</A>
|
||||
<BR>
|
||||
<A HREF="FAQ.html">FAQ</A> -+-
|
||||
<A HREF="lists.html">Mailing Lists</A> -+-
|
||||
<A HREF="ChangeLog">Change Log</A> -+-
|
||||
<BR>
|
||||
<A HREF="FAQ.html">FAQ</A> -+-
|
||||
<A HREF="lists.html">Mailing Lists</A> -+-
|
||||
<A HREF="ChangeLog">Change Log</A> -+-
|
||||
<A HREF="#Licensing">Licensing Information</A>
|
||||
</CENTER>
|
||||
|
||||
<BR><BR>
|
||||
<P>
|
||||
Libsndfile is a C library for reading and writing files containing sampled sound
|
||||
(such as MS Windows WAV and the Apple/SGI AIFF format) through one standard
|
||||
library interface. It is released in source code format under the
|
||||
Libsndfile is a C library for reading and writing files containing sampled sound
|
||||
(such as MS Windows WAV and the Apple/SGI AIFF format) through one standard
|
||||
library interface. It is released in source code format under the
|
||||
<A HREF="http://www.gnu.org/copyleft/lesser.html">Gnu Lesser General Public License</A>.
|
||||
</P>
|
||||
<!-- 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
|
||||
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.
|
||||
</P>
|
||||
<P>
|
||||
It was designed to handle both little-endian (such as WAV) and big-endian
|
||||
(such as AIFF) data, and to compile and run correctly on little-endian (such as Intel
|
||||
and DEC/Compaq Alpha) processor systems as well as big-endian processor systems such
|
||||
as Motorola 68k, Power PC, MIPS and Sparc.
|
||||
Hopefully the design of the library will also make it easy to extend for reading and
|
||||
It was designed to handle both little-endian (such as WAV) and big-endian
|
||||
(such as AIFF) data, and to compile and run correctly on little-endian (such as Intel
|
||||
and DEC/Compaq Alpha) processor systems as well as big-endian processor systems such
|
||||
as Motorola 68k, Power PC, MIPS and Sparc.
|
||||
Hopefully the design of the library will also make it easy to extend for reading and
|
||||
writing new sound file formats.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
@ -66,15 +65,20 @@
|
||||
</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>i586-pc-linux-gnu (Redhat 5.2 glibc)
|
||||
<LI>powerpc-unknown-linux-gnu (Linux PPC)
|
||||
<LI>powerpc-apple-darwin6.0 (Mac OS X 10.2)
|
||||
<LI>sparc-sun-solaris2.8 (gcc)
|
||||
<LI>mips-sgi-irix5.3 (Native IRIX toolset)
|
||||
<LI>sparc-sun-solaris2.5.1 (gcc)
|
||||
<LI>mips-sgi-irix5.3 (gcc)
|
||||
<LI>mips-sgi-irix6.3 (cc - native compiler)
|
||||
<LI>QNX 6.0 (gcc 2.96.2 19991024)
|
||||
<LI>i386-unknown-openbsd2.9 (gcc 2.95.3 20010125)
|
||||
<LI>i686-pc-cygwin (Cygwin on Win98)
|
||||
<BR>
|
||||
<LI>Win32 (Microsoft Visual C++)
|
||||
<LI>MacOS 8.6 (Metrowerks Codewarrior Pro4)
|
||||
</UL>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
@ -93,20 +97,20 @@
|
||||
<lI> Ability to read and write a large number of file formats.
|
||||
<LI> A simple, elegant and easy to use Applications Programming Interface.
|
||||
<LI> Usable on Unix, Win32, MacOS and others.
|
||||
<LI> On the fly format conversion, including endian-ness swapping, type conversion
|
||||
<LI> On the fly format conversion, including endian swapping, type conversion
|
||||
and bitwidth scaling.
|
||||
<LI> Optional normalisation when reading floating point data from files containing
|
||||
integer data.
|
||||
<LI> Ability to open files in read/write mode.
|
||||
<LI> The ability to write the file header without closing the file (only on files
|
||||
<LI> The ability to write the file header without closing the file (only on files
|
||||
open for write or read/write).
|
||||
<LI> Ability to query the library about all supported formats and retrieve text
|
||||
<LI> Ability to query the library about all supported formats and retrieve text
|
||||
strings describing each format.
|
||||
</UL>
|
||||
<P>
|
||||
libsndfile has a comprehensive test suite so that each release is as bug free
|
||||
as possible.
|
||||
When new bugs are found, new tests are added to the test suite to ensure that
|
||||
libsndfile has a comprehensive test suite so that each release is as bug free
|
||||
as possible.
|
||||
When new bugs are found, new tests are added to the test suite to ensure that
|
||||
these bugs don't creep back into the code.
|
||||
When new features are added, tests are added to the test suite to make sure that
|
||||
these features continue to work correctly even when they are old features.
|
||||
@ -114,7 +118,7 @@
|
||||
<P>
|
||||
The following table lists the file formats and encodings that libsndfile can read
|
||||
and write.
|
||||
The file formats are arranged across the top and encodings along the left
|
||||
The file formats formats are arranged across the top and encodings along the left
|
||||
edge.
|
||||
</P>
|
||||
<BR>
|
||||
@ -136,138 +140,135 @@
|
||||
<TD ALIGN="center">Portable Voice Format<BR>PVF</TD>
|
||||
<TD ALIGN="center">Fasttracker 2<BR>XI</TD>
|
||||
<TD ALIGN="center">HMM Tool Kit<BR>HTK</TD>
|
||||
<TD ALIGN="center">Apple<BR>CAF</TD>
|
||||
<!-- TD ALIGN="center">Sound<BR>Designer II<BR>SD2</TD -->
|
||||
</TR>
|
||||
<TR><TD>Unsigned 8 bit PCM</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>Signed 8 bit PCM</TD>
|
||||
<TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD> </TD><TD>R/W</TD>
|
||||
<TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>Signed 16 bit PCM</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>Signed 24 bit PCM</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>Signed 32 bit PCM</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD> </TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>32 bit float</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>64 bit double</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>u-law encoding</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD ALIGN="center">R/W</TD>
|
||||
</TR>
|
||||
<TR><TD>A-law encoding</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD ALIGN="center">R/W</TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>IMA ADPCM</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>MS ADPCM</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>GSM 6.10</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>G721 ADPCM 32kbps</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>G723 ADPCM 24kbps</TD>
|
||||
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>G723 ADPCM 40kbps</TD>
|
||||
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>12 bit DWVW</TD>
|
||||
<TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>16 bit DWVW</TD>
|
||||
<TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>24 bit DWVW</TD>
|
||||
<TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
<TR><TD>Ok Dialogic ADPCM</TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
<TR><TD>8 bit DPCM</TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD>
|
||||
</TR>
|
||||
<TR><TD>16 bit DPCM</TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<!-- pepper -->
|
||||
@ -276,9 +277,10 @@
|
||||
Some of the file formats I am also interested in adding are:
|
||||
</P>
|
||||
<UL>
|
||||
<LI> Soundfont II.
|
||||
<LI> Gravis Ultrasound patch files.
|
||||
<LI> Kurzweil K2000 sampler files.
|
||||
<LI> Ogg Vorbis.
|
||||
<LI> Ogg Speex.
|
||||
<LI> FLAC.
|
||||
</UL>
|
||||
<P>
|
||||
@ -295,24 +297,24 @@
|
||||
<H1><B>History</B></H1>
|
||||
<P>
|
||||
My first attempt at reading and writing WAV files was in 1990 or so under Windows
|
||||
3.1.
|
||||
I started using Linux in early 1995 and contributed some code to the
|
||||
3.1.
|
||||
I started using Linux in early 1995 and contributed some code to the
|
||||
<A HREF="http://www.vaxxine.com/ve3wwg/gnuwave.html">wavplay</A>
|
||||
program.
|
||||
That contributed code would eventually mutate into this library.
|
||||
As one of my interests is Digital Signal Processing (DSP) I decided that as well as
|
||||
reading data from an audio file in the native format (typically 16 bit short integers)
|
||||
it would also be useful to be able to have the library do the conversion to floating
|
||||
point numbers for DSP applications.
|
||||
It then dawned on me that whatever file format (anything from 8 bit unsigned chars,
|
||||
to 32 bit floating point numbers) the library should be able to convert the data to
|
||||
whatever format the library user wishes to use it in.
|
||||
For example, in a sound playback program, the library caller typically wants the sound
|
||||
program.
|
||||
That contributed code would eventually mutate into this library.
|
||||
As one of my interests is Digital Signal Processing (DSP) I decided that as well as
|
||||
reading data from an audio file in the native format (typically 16 bit short integers)
|
||||
it would also be useful to be able to have the library do the conversion to floating
|
||||
point numbers for DSP applications.
|
||||
It then dawned on me that whatever file format (anything from 8 bit unsigned chars,
|
||||
to 32 bit floating point numbers) the library should be able to convert the data to
|
||||
whatever format the library user wishes to use it in.
|
||||
For example, in a sound playback program, the library caller typically wants the sound
|
||||
data in 16 bit short integers to dump into a sound card even though the data in the
|
||||
file may be 32 bit floating point numbers (ie Microsoft's WAVE_FORMAT_IEEE_FLOAT
|
||||
format).
|
||||
Another example would be someone doing speech recognition research who has recorded
|
||||
some speech as a 16 bit WAV file but wants to process it as double precision floating
|
||||
file may be 32 bit floating point numbers (ie Microsoft's WAVE_FORMAT_IEEE_FLOAT
|
||||
format).
|
||||
Another example would be someone doing speech recognition research who has recorded
|
||||
some speech as a 16 bit WAV file but wants to process it as double precision floating
|
||||
point numbers.
|
||||
</P>
|
||||
<P>
|
||||
@ -329,138 +331,106 @@
|
||||
<LI>Version 1.0.3 (Dec 09 2002) Fixes for Linux on ia64 CPUs.
|
||||
<LI>Version 1.0.4 (Feb 02 2003) New file formats and functionality.
|
||||
<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
|
||||
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.
|
||||
<LI>Version 1.0.10 (Jun 15 2004) Minor bug fixes. Fix support for Win32 MinGW compiler.
|
||||
<LI>Version 1.0.11 (Nov 15 2004) Add SD2 file support, reading of loop data in WAV and AIFF.
|
||||
Minor bug fixes.
|
||||
<LI>Version 1.0.12 (Sep 30 2005) Add FLAC and CAF file support, virtual I/O interface.
|
||||
Minor bug fixes and cleanups.
|
||||
<LI>Version 1.0.13 (Jan 21 2006) Add read/write of instrument chunks. Minor bug fixes.
|
||||
<LI>Version 1.0.14 (Feb 19 2006) Minor bug fixes. Start shipping windows binary/source ZIP.
|
||||
<LI>Version 1.0.15 (Mar 16 2006) Minor bug fixes.
|
||||
<LI>Version 1.0.16 (Apr 30 2006) Add support for RIFX. Other minor feature enhancements and
|
||||
bug fixes.
|
||||
<LI>Version 1.0.17 (Aug 31 2006) Add C++ wrapper sndfile.hh. Minor bug fixes and cleanups.
|
||||
<LI>Version 1.0.6 (Nov 03 2003) New functionality and Win32 improvements.
|
||||
</UL>
|
||||
|
||||
|
||||
<A NAME="Similar"></A>
|
||||
<H1><B>Similar or Related Projects</B></H1>
|
||||
|
||||
<UL>
|
||||
<LI><A HREF="http://home.sprynet.com/~cbagwell/sox.html">SoX</A> is a program for
|
||||
<LI><A HREF="http://home.sprynet.com/~cbagwell/sox.html">SoX</A> is a program for
|
||||
converting between sound file formats.
|
||||
<LI><A HREF="http://members.home.com/ve3wwg/gnuwave.html">Wavplay</A> started out
|
||||
as a minimal WAV file player under Linux and has mutated into Gnuwave, a client/server
|
||||
<LI><A HREF="http://members.home.com/ve3wwg/gnuwave.html">Wavplay</A> started out
|
||||
as a minimal WAV file player under Linux and has mutated into Gnuwave a client/server
|
||||
application for more general multimedia and games sound playback.
|
||||
<LI><A HREF="http://www.68k.org/~michael/audiofile/">Audiofile</A> (libaudiofile) is
|
||||
a library similar to libsndfile but with a different programming interface. The
|
||||
author Michael Pruett has set out to clone (and fix some bugs in) the libaudiofile
|
||||
<LI><A HREF="http://www.68k.org/~michael/audiofile/">Audiofile</A> (libaudiofile) is
|
||||
a library similar to libsndfile but with a different programming interface. The
|
||||
author Michael Pruett has set out to clone (and fix some bugs) the libaudiofile
|
||||
library which ships with SGI's IRIX OS.
|
||||
<LI><A HREF="ftp://ccrma-ftp.stanford.edu/pub/Lisp/sndlib.tar.gz">sndlib.tar.gz</A> is
|
||||
<LI><A HREF="ftp://ccrma-ftp.stanford.edu/pub/Lisp/sndlib.tar.gz">sndlib.tar.gz</A> is
|
||||
another library written by Bill Schottstaedt of CCRMA.
|
||||
</UL>
|
||||
|
||||
<A NAME="Licensing"></A>
|
||||
<H1><B>Licensing</B></H1>
|
||||
<P>
|
||||
libsndfile is released under the terms of the GNU Lesser General Public License. You may
|
||||
read the license
|
||||
<A HREF="http://www.gnu.org/copyleft/lesser.html">here</A>
|
||||
or read a simple explanation of the ideas behind the GPL and the LGPL
|
||||
libsndfile is released under the terms of the GNU Lesser General Public License. You may
|
||||
read the license
|
||||
<A HREF="http://www.gnu.org/copyleft/lesser.html">here</A>
|
||||
or read a simple explanation of the ideas behind the GPL and the LGPL
|
||||
<A HREF="http://www.gnu.org/copyleft/copyleft.html">here</A>.
|
||||
</P>
|
||||
<P>
|
||||
You can use libsndfile with
|
||||
<A HREF="http://www.gnu.org/">Free Software</A>,
|
||||
You can use libsndfile with
|
||||
<A HREF="http://www.gnu.org/">Free Software</A>,
|
||||
<A HREF="http://www.opensource.org/">Open Source</A>,
|
||||
proprietary, shareware or other closed source applications as long as libsndfile
|
||||
is used as a dynamically loaded library and you abide by a small number of other
|
||||
conditions (read the LGPL for more info).
|
||||
With applications released under the GNU GPL you can also use libsndfile statically
|
||||
proprietary, shareware or other closed source applications as long as libsndfile
|
||||
is used as a dynamically loaded library.
|
||||
With applications released under the GNU GPL you can also use libsndfile statically
|
||||
linked to your application.
|
||||
</P>
|
||||
<P>
|
||||
I would like to see libsndfile used as widely as possible but I would prefer it
|
||||
if you released software that uses libsndfile as
|
||||
I would like to see libsndfile used as widely as possible but I would prefer it
|
||||
if you released software that uses libsndfile as
|
||||
<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
|
||||
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>.
|
||||
which simply uses libsnfile 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.
|
||||
</P>
|
||||
<A NAME="Download"></A>
|
||||
<P>
|
||||
What I don't like to see is things like Steve Dekorte's
|
||||
What I don't like to see is things like Steve Dekorte's
|
||||
<A HREF="http://www.dekorte.com/Software/OSX/SoundConverter/">SoundConverter</A>
|
||||
for Mac OSX.
|
||||
Mr Dekorte has grabbed a number of Free Software packages and wrapped them in a
|
||||
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
|
||||
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>,
|
||||
addmission</A>,
|
||||
less than 10%.
|
||||
</P>
|
||||
|
||||
<H1><B>Download</B></H1>
|
||||
<P>
|
||||
Here is the latest version. It is available in the following formats (I am no longer
|
||||
distributing RPMs).
|
||||
distributing RPMs).
|
||||
</P>
|
||||
<UL>
|
||||
<LI>Source code as a .tar.gz :
|
||||
<A HREF="libsndfile-1.0.17.tar.gz">libsndfile-1.0.17.tar.gz</A>
|
||||
and
|
||||
<A HREF="libsndfile-1.0.17.tar.gz.asc">(GPG signature)</A>.
|
||||
<LI>Windows .zip file including precompiled binaries and all source code :
|
||||
<A HREF="libsndfile-1_0_17.zip">libsndfile-1_0_17.zip</A>
|
||||
and
|
||||
<A HREF="libsndfile-1_0_17.zip.asc">(GPG signature)</A>.
|
||||
<LI>Source code as a .tar.gz :
|
||||
<A HREF="libsndfile-1.1.0pre1.tar.gz">libsndfile-1.1.0pre1.tar.gz</A>
|
||||
</UL>
|
||||
<P>
|
||||
Compiling libsndfile is relatively easy. The INSTALL file in the top level directory
|
||||
gives instructions on compiling and installing libsndfile on Unix-like systems
|
||||
gives instructions on compiling and installing libsndfile on Unix-like systems
|
||||
(including MacOSX). For Win32 there are instructions in the doc/ directory of the
|
||||
tarball. These instructions are mirrored
|
||||
tarball. These instructions are mirrored
|
||||
<A HREF="win32.html">here</A>.
|
||||
</P>
|
||||
<P>
|
||||
Pre-release versions of libsndfile are available
|
||||
<A HREF="http://www.mega-nerd.com/tmp/">here</A>
|
||||
and are announced on the
|
||||
<A HREF="lists.html">libsndfile-devel</A>
|
||||
mailing list.
|
||||
</P>
|
||||
<BR><BR>
|
||||
|
||||
<HR>
|
||||
|
||||
<P>
|
||||
The latest version of this document can be found
|
||||
<A HREF="http://www.mega-nerd.com/libsndfile/">here</A>.
|
||||
<A HREF="http://www.zip.com.au/~erikd/libsndfile/">here</A>.
|
||||
</P>
|
||||
<P>
|
||||
Author :
|
||||
<A HREF="mailto:erikd@mega-nerd.com">
|
||||
Erik de Castro Lopo</a>
|
||||
Author :
|
||||
<A HREF="mailto:erikd@zip.com.au">Erik de Castro Lopo</a>
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
This page has been accessed
|
||||
<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.dat"
|
||||
"/cgi-bin/counter?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.dat"
|
||||
HEIGHT=30 WIDTH=100 ALT="counter.gif">
|
||||
times.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<!-- pepper -->
|
||||
<!-- <A HREF="mailto:lsf0305@mega-nerd.com">For the bots</A> -->
|
||||
<!-- pepper -->
|
||||
|
||||
<BR><BR>
|
||||
@ -469,8 +439,8 @@ times.
|
||||
|
||||
<!--
|
||||
Do not edit or modify anything in this comment block.
|
||||
The arch-tag line is a file identity tag for the GNU Arch
|
||||
The arch-tag line is a file identity tag for the GNU Arch
|
||||
revision control system.
|
||||
|
||||
|
||||
arch-tag: a96adffb-3017-46e2-82a0-6d77832b14d5
|
||||
-->
|
||||
|
85
doc/libsndfile.css
Normal file
85
doc/libsndfile.css
Normal file
@ -0,0 +1,85 @@
|
||||
body {
|
||||
background : black ;
|
||||
color : white ;
|
||||
font-family : arial, helvetica, sans-serif ;
|
||||
}
|
||||
td {
|
||||
font-family : arial, helvetica, sans-serif ;
|
||||
background : black ;
|
||||
color : white ;
|
||||
}
|
||||
center {
|
||||
font-family : arial, helvetica, sans-serif ;
|
||||
}
|
||||
p {
|
||||
font-family : arial, helvetica, sans-serif ;
|
||||
text-align : left ;
|
||||
margin-left : 3% ;
|
||||
margin-right : 3% ;
|
||||
}
|
||||
.indent_block {
|
||||
font-family : arial, helvetica, sans-serif ;
|
||||
text-align : left ;
|
||||
margin-left : 10% ;
|
||||
margin-right : 10% ;
|
||||
}
|
||||
br {
|
||||
font-family : arial, helvetica, sans-serif ;
|
||||
}
|
||||
form {
|
||||
font-family : arial, helvetica, sans-serif ;
|
||||
}
|
||||
ul {
|
||||
font-family : arial, helvetica, sans-serif ;
|
||||
text-align : left ;
|
||||
margin-left : 3% ;
|
||||
margin-right : 6% ;
|
||||
}
|
||||
ol {
|
||||
font-family : arial, helvetica, sans-serif ;
|
||||
text-align : left ;
|
||||
margin-left : 3% ;
|
||||
margin-right : 6% ;
|
||||
}
|
||||
dl {
|
||||
font-family : arial, helvetica, sans-serif ;
|
||||
text-align : left ;
|
||||
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 ;
|
||||
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% ;
|
||||
}
|
||||
pre {
|
||||
font-family : courier, monospace ;
|
||||
font-size : medium ;
|
||||
}
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 08f03cbe-38c2-457b-95ff-44daea275294
|
||||
*/
|
@ -5,11 +5,11 @@
|
||||
<TITLE>
|
||||
libsndfile Mailing Lists
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT zip DOT com DOT au)">
|
||||
<LINK REL=StyleSheet HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#9090FF" VLINK="#5050FF" ALINK="#FF00FF">
|
||||
<!-- pepper -->
|
||||
<H1><BR>libsndfile Mailing Lists</H1>
|
||||
<!-- pepper -->
|
||||
@ -18,21 +18,21 @@ There are three mailing lists for libsndfile:
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<UL>
|
||||
<LI> <B>libsndfile-announce@mega-nerd.com</B> <!-- pepper -->
|
||||
<LI> <B>libsndfile-announce@mega-nerd.com</B> <!-- pepper -->
|
||||
<A HREF="mailto:libsndfile-announce-request@mega-nerd.com?subject=subscribe">Subscribe</A>
|
||||
<BR>
|
||||
A list which will announce each new release of libsndfile.
|
||||
Noone can post to this list except the author.
|
||||
<BR><BR>
|
||||
|
||||
<LI> <B>libsndfile-devel@mega-nerd.com</B> <!-- pepper -->
|
||||
<LI> <B>libsndfile-devel@mega-nerd.com</B> <!-- pepper -->
|
||||
<A HREF="mailto:libsndfile-devel-request@mega-nerd.com?subject=subscribe">Subscribe</A>
|
||||
<BR>
|
||||
A list for discussing bugs, porting issues and feature requests.
|
||||
Posting is restricted to subscribers.
|
||||
<BR><BR>
|
||||
|
||||
<LI> <B>libsndfile-users@mega-nerd.com</B> <!-- pepper -->
|
||||
<LI> <B>libsndfile-users@mega-nerd.com</B> <!-- pepper -->
|
||||
<A HREF="mailto:libsndfile-users-request@mega-nerd.com?subject=subscribe">Subscribe</A>
|
||||
<BR>
|
||||
A list for discussing the use of libsndfile in other programs.
|
||||
|
@ -18,9 +18,9 @@ have all required tools including :
|
||||
- automake
|
||||
- libtool
|
||||
|
||||
These should all be available on the GNU ftp site: ftp://ftp.gnu.org/pub/gnu/.
|
||||
These will all be available on the GNU ftp site: ftp://ftp.gnu.org/pub/gnu/.
|
||||
|
||||
To help make these steps clearer let's suppose we are adding support for the
|
||||
To help make these steps clearer lets suppose we are adding support for the
|
||||
Whacky file format whose files contain 'W','A','C' and 'K' as the first four
|
||||
bytes of the file format. Lets also assume that Whacky files contain PCM encoded
|
||||
data.
|
||||
@ -44,13 +44,13 @@ FILESPECIFIC = aiff.c au.c au_g72x.c nist.c paf.c raw.c samplitude.c \
|
||||
wav_ms_adpcm.c
|
||||
|
||||
Then, run the script named 'reconf' in the libsndfile top level directory,
|
||||
which will run autoconf and other associated tools. Finally run "./configure"
|
||||
which will run autoconf and other ascocisated tools. Finally run "./configure"
|
||||
in the top level directory. You may want to use the "--disable-gcc-opt" option
|
||||
to disable gcc optimisations and make debugging with gdb/ddd easier.
|
||||
|
||||
Step 3
|
||||
------
|
||||
Add a unique identifier for the new file type.
|
||||
Add a unique identifier to for the new file type.
|
||||
|
||||
Edit src/sndfile.h.in and find the enum containing the SF_FORMAT_XXX identifiers.
|
||||
Since you will be adding a major file type you should add your identifier to the
|
||||
@ -76,32 +76,32 @@ top of file should you need to have a look at it.
|
||||
|
||||
Step 5
|
||||
------
|
||||
Add a call to your open function from psf_open_file ().
|
||||
Add a call to your open read function from sf_open_read ().
|
||||
|
||||
Edit src/sndfile.c and find the switch statement in psf_open_file (). It starts
|
||||
Edit src/sndfile.c and find the switch statement in sf_open_read (). It starts
|
||||
like this:
|
||||
|
||||
switch (filetype)
|
||||
{ case SF_FORMAT_WAV :
|
||||
error = wav_open (psf) ;
|
||||
sf_errno = wav_open_read (psf) ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_AIFF :
|
||||
error = aiff_open (psf) ;
|
||||
sf_errno = aiff_open_read (psf) ;
|
||||
break ;
|
||||
|
||||
Towards the bottom of this switch statement your should add one for the new file
|
||||
type. Something like:
|
||||
type. Soemthing like:
|
||||
|
||||
case SF_FORMAT_WACK :
|
||||
sf_errno = whacky_open (psf) ;
|
||||
sf_errno = whacky_open_read (psf)
|
||||
break ;
|
||||
|
||||
Setp 6
|
||||
------
|
||||
Add prototypes for new open read and open write functions.
|
||||
Add prototyes for new open read and open write functions.
|
||||
|
||||
Edit src/common.h, go to the bottom of the file and add something like
|
||||
Edit src/commonn.h, go to the bottom of the file and add something like
|
||||
|
||||
int whacky_open (SF_PRIVATE *psf) ;
|
||||
|
||||
@ -112,20 +112,20 @@ Implement your open read function. The best way to do this is by coding
|
||||
something much like one of the other file formats. The file src/au.c might be
|
||||
a good place to start.
|
||||
|
||||
In src/whacky.c you should now implement the function whacky_open() which
|
||||
In src/whacky.c you should now implement the function whacky_open_read() which
|
||||
was prototyped in src/common.h. This function should return 0 on success and
|
||||
a non-zero number on error.
|
||||
a negative number on error.
|
||||
|
||||
Error values are defined in src/common.h in a enum which starts at SFE_NO_ERROR.
|
||||
When adding a new error value, you also need to add an error string to the
|
||||
SndfileErrors array in src/sndfile.c.
|
||||
SndfileErrors array in src/sndfile.c
|
||||
|
||||
To parse the header of your new file type you should avoid using standard read/
|
||||
write/seek functions (and the fread/fwrite/fseek etc) and instead use
|
||||
psf_binheader_readf () which is implemented and documented in src/common.h.
|
||||
|
||||
During the parsing process, you should also print logging information to
|
||||
libsndfile's internal log buffer using the psf_log_printf() function.
|
||||
libsndfile's internal log bufer using the psf_log_printf() function.
|
||||
|
||||
At the end of the open read process, you should have set a number of fields in the
|
||||
SF_PRIVATE structure pointed to by psf.
|
||||
|
@ -5,11 +5,11 @@
|
||||
<TITLE>
|
||||
libsndfile and GNU Octave
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT zip DOT com DOT au)">
|
||||
<LINK REL=StyleSheet HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#5050FF" VLINK="#5050FF" ALINK="#FF00FF">
|
||||
|
||||
<BR>
|
||||
<H1><B>libsndfile and GNU Octave</B></H1>
|
||||
@ -56,14 +56,14 @@
|
||||
<P>
|
||||
Octave, like most programming languages, uses variables to store data, and
|
||||
Octave variables can contain both arrays and matrices.
|
||||
It is also able to store one or more of these variables in a file.
|
||||
It is also able to store one or more or these variables in a file.
|
||||
When reading Octave files, libsndfile expects a file to contain two
|
||||
variables and their associated data.
|
||||
The first variable should contain a variable holding the file sample rate
|
||||
while the second variable contains the audio data.
|
||||
</P>
|
||||
<P>
|
||||
For example, to generate a sine wave and store it as a binary file which
|
||||
For example, to generate a sine wave and store it as an binary file which
|
||||
is compatible with libsndfile, do the following:
|
||||
</P>
|
||||
<PRE>
|
||||
@ -84,7 +84,7 @@
|
||||
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
|
||||
file allows Octave data to be played from within Octave on any of the platforms
|
||||
file allows Octave data to played from within Octave on any of the platforms
|
||||
which <B>sndfile-play</B> supports (at the moment: Linux, MacOSX, Solaris and
|
||||
Win32).
|
||||
</P>
|
||||
@ -99,7 +99,7 @@
|
||||
</P>
|
||||
|
||||
<P>
|
||||
There are some other Octave scripts for audio to be found
|
||||
There are some other Otave scripts for audio to be found
|
||||
<A HREF="http://octave.sourceforge.net/index/audio.html">here</A>.
|
||||
</P>
|
||||
|
||||
@ -109,8 +109,8 @@
|
||||
<HR>
|
||||
<P>
|
||||
The libsndfile home page is here :
|
||||
<A HREF="http://www.mega-nerd.com/libsndfile/">
|
||||
http://www.mega-nerd.com/libsndfile/</A>.
|
||||
<A HREF="http://www.zip.com.au/~erikd/libsndfile/">
|
||||
http://www.zip.com.au/~erikd/libsndfile/</A>.
|
||||
</P>
|
||||
|
||||
</BODY>
|
||||
|
@ -5,11 +5,11 @@
|
||||
<TITLE>
|
||||
libsndfile : pkg-config
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT zip DOT com DOT au)">
|
||||
<LINK REL=StyleSheet HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#9090FF" VLINK="#5050FF" ALINK="#FF00FF">
|
||||
|
||||
<BR>
|
||||
<H1>libsndfile and pkg-config</H1>
|
||||
@ -39,7 +39,7 @@
|
||||
During the installation of libsndfile, a file named <B>sndfile.pc</B> is installed
|
||||
in the directory <B>${libdir}/pkgconfig</B> (ie if libsndfile is installed in
|
||||
<B>/usr/local/lib</B>, <B>sndfile.pc</B> will be installed in
|
||||
<B>/usr/local/lib/pkgconfig/</B>).
|
||||
<B>/usr/local/lib/pkgconfig/</B>.
|
||||
</P>
|
||||
<P>
|
||||
In order for pkg-config to find sndfile.pc it may be necessary to point the
|
||||
|
@ -5,11 +5,11 @@
|
||||
<TITLE>
|
||||
sndfile-info
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT zip DOT com DOT au)">
|
||||
<LINK REL=StyleSheet HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#9090FF" VLINK="#5050FF" ALINK="#FF00FF">
|
||||
|
||||
<P>
|
||||
Here is an example of the output from the <B>sndfile-info</B> program distributed with
|
||||
|
150
doc/win32.html
150
doc/win32.html
@ -5,119 +5,66 @@
|
||||
<TITLE>
|
||||
Building libsndfile on Win32
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT zip DOT com DOT au)">
|
||||
<LINK REL=StyleSheet HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#9090FF" VLINK="#5050FF" ALINK="#FF00FF">
|
||||
<!-- pepper -->
|
||||
<H1><BR>Building libsndfile on Win32</H1>
|
||||
|
||||
<P><B>
|
||||
Note : For pre-compiled binaries for windows, see the main web page.
|
||||
</B></P>
|
||||
|
||||
<P>
|
||||
There are currently two ways of building libsndfile under Win32:
|
||||
For Win32 there is a Microsoft Visual C++ compatible makefile in the <B>Win32\</B>
|
||||
directory of the distribution. Making the libsndfile DLL on Win32 involves
|
||||
the following:
|
||||
</P>
|
||||
<UL>
|
||||
<LI> Using the free <A HREF="#MinGW">MinGW</A> tools.
|
||||
<LI> Using Cygwin (this is the full Cygwin without the -mno-cygwin option).
|
||||
</UL>
|
||||
|
||||
<P><B>
|
||||
Building libsndfile using the microsoft compiler does not currently work.
|
||||
Microsoft's compiler is a C++ compiler and does not compile a number of ISO
|
||||
C99 Standard constructs.
|
||||
If you insist on compiling libsndfile with the microsoft compiler you are
|
||||
on your own.
|
||||
</B></P>
|
||||
<P><B>
|
||||
However, even though the libsndfile source code cannot be compiled with
|
||||
the microsoft compiler, the pre-compiled windows DLL distributed on the
|
||||
main web page can be used with C++ projects compiled with the microsoft
|
||||
compiler.
|
||||
</B></P>
|
||||
|
||||
<!-- pepper -->
|
||||
<OL>
|
||||
<LI> Using WinZip in the GUI, open the libsndfile-1.X.Y.tar.gz file and
|
||||
extract the files into a directory. The following example assumes
|
||||
<B>C:\</B>.
|
||||
<LI> In the directory containing the extracted files, find the file
|
||||
<B>Win32\Makefile.msvc</B> and open it in a text editor (ie Notepad or
|
||||
similar).
|
||||
<LI> Find the line which starts with <B>MSVCDir</B> and modify the directory
|
||||
path to point to the location of MSVC++ on your machine. This allows the
|
||||
makefile to inform the compiler of the location of the standard header
|
||||
files. Note that none of the directory names are allowed to have spaces
|
||||
in them.
|
||||
<LI> Copy the file named <B>sndfile.h</B> from the <B>Win32\</B> directory to the
|
||||
<B>src\</B> directory replacing the one that was originally there.
|
||||
<LI> Copy the file named <B>config.h</B> from the <B>Win32\</B> directory to the
|
||||
<B>src\</B> directory replacing the one that was originally there.
|
||||
<LI> Open a DOS window and cd into the libsndfile-1.X.Y directory.
|
||||
<LI> Make sure that the program <B>nmake</B> (which is part of the MSCV++
|
||||
package) is in a directory which is part of your <B>PATH</B> variable.
|
||||
<LI> Type in the command
|
||||
<CENTER><PRE>C:\libsndfile-1.X.Y> nmake -f Win32\Makefile.msvc
|
||||
</PRE></CENTER>
|
||||
and press <return>. You should now see a a large number of compile
|
||||
commands as libsndfile.dll is built.
|
||||
<LI> To check that the built DLL has been compiled correctly type in and run the
|
||||
command
|
||||
<CENTER><PRE>C:\libsndfile-1.X.Y> nmake -f Win32\Makefile.msvc check
|
||||
</PRE></CENTER>
|
||||
which will compile a set of test programs and run them. If any of the
|
||||
programs fail the error message will be help in debugging the problem.
|
||||
</OL>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
The free MinGW tools are the preferred option because they are a free (as in
|
||||
beer and speech), easily obtainable and much closer to the Linux/GCC
|
||||
environment on which libsndfile is developed.
|
||||
At the end of the above procedure, you will find the DLL, <B>libsndfile.dll</B>, a
|
||||
LIB file <B>libsndfile.lib</B> in the current directory. These two files, along
|
||||
with the header file <B>sndfile.h</B> (in the <B>Win32\</B> directory) are all that
|
||||
you need to copy to your project in order to use libsndfile.
|
||||
</P>
|
||||
|
||||
<A NAME="MinGW"></A>
|
||||
<H2><BR>Building libsndfile using MinGW.</H2>
|
||||
<P>
|
||||
The MinGW tools are available from <A HREF="http://www.mingw.org/">
|
||||
http://www.mingw.org/</A>.
|
||||
The files you will need will be named something like:
|
||||
</P>
|
||||
<UL>
|
||||
<LI> msysDTK-1.0.1.exe
|
||||
<LI> MSYS-1.0.10.exe
|
||||
<LI> gcc-core-3.4.2-20040916-1.tar.gz
|
||||
<LI> gcc-g++-3.4.2-20040916-1.tar.gz
|
||||
<LI> binutils-2.15.91-20040901-1.tar.gz
|
||||
<LI> mingw-runtime-3.9.tar.gz
|
||||
<LI> w32api-3.6.tar.gz
|
||||
<LI> mingw-utils-0.3.tar.gz
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
They should be installed using the directions on the MinGW site.
|
||||
I know the instructions aren't great, but I don't have the time or expertise
|
||||
to write better ones.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
Once you have the tools installed you will get an icon named <B>MSYS</B> on
|
||||
your desktop.
|
||||
Clicking on that icon will bring up something that looks a little like an
|
||||
xterm.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
Assuming that you have downloaded the <B>.tar.gz</B> file into the
|
||||
<B>C:\temp\</B> directory you should now be able to execute the following
|
||||
commands:
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
tar zxf /c/temp/libsndfile.X.Y.Z.tar.gz
|
||||
cd libsndfile-X.Y.Z
|
||||
./configure
|
||||
make
|
||||
make check
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
If there is a failure during compiling or the "make check" stage, you should
|
||||
check that you are using the current stable version of the MinGW tools, and
|
||||
the latest version of libsndfile before sending the author a bug report.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
Once this is done, anyone interested in using libsndfile in other projects
|
||||
will be interested in the following files:
|
||||
</P>
|
||||
<UL>
|
||||
<LI> libsndfile.dll
|
||||
<LI> libsndfile.lib
|
||||
<LI> libsndfile.def
|
||||
<LI> src/sndfile.h
|
||||
<LI> doc/*.html
|
||||
</UL>
|
||||
|
||||
<!--===========================================================================-->
|
||||
|
||||
<!-- pepper -->
|
||||
<H2><BR>Compile Problems</H2>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
Compile problems using the above method of building the libsndfile DLL on Win32 should
|
||||
be emailed to
|
||||
<A HREF="mailto:erikd@mega-nerd.com">
|
||||
Erik de Castro Lopo</a>.
|
||||
Compile problems using the above method of building the libsndfile DLL on Win32 should
|
||||
be emailed to
|
||||
<A HREF="mailto:erikd@zip.com.au">Erik de Castro Lopo</a>.
|
||||
This includes error messages generated during step 7 above.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
@ -128,14 +75,13 @@ If you are using some other method to compile the libsndfile DLL you are on your
|
||||
<!-- pepper -->
|
||||
<!-- pepper -->
|
||||
<!-- pepper -->
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
<!--
|
||||
Do not edit or modify anything in this comment block.
|
||||
The arch-tag line is a file identity tag for the GNU Arch
|
||||
The arch-tag line is a file identity tag for the GNU Arch
|
||||
revision control system.
|
||||
|
||||
|
||||
arch-tag: b32ddb11-eb51-425f-9d39-b8b66284f129
|
||||
-->
|
||||
|
@ -2,30 +2,27 @@
|
||||
|
||||
bin_PROGRAMS = sndfile-info sndfile-play sndfile-convert
|
||||
|
||||
noinst_PROGRAMS = sndfile-data-trim make_sine sfprocess list_formats generate
|
||||
noinst_PROGRAMS = make_sine sfprocess list_formats cooledit-fixer generate
|
||||
|
||||
# This is the BeOS version of sndfile-play. It needs to be compiled with the C++
|
||||
# compiler.
|
||||
EXTRA_DIST = sndfile-play-beos.cpp
|
||||
|
||||
OS_SPECIFIC_CFLAGS = @OS_SPECIFIC_CFLAGS@
|
||||
OS_SPECIFIC_INCLUDES = @OS_SPECIFIC_INCLUDES@
|
||||
OS_SPECIFIC_LINKS = @OS_SPECIFIC_LINKS@
|
||||
|
||||
SNDFILEDIR =../src
|
||||
INCLUDES = -I$(srcdir)/$(SNDFILEDIR) $(OS_SPECIFIC_CFLAGS)
|
||||
INCLUDES = -I$(srcdir)/$(SNDFILEDIR) $(OS_SPECIFIC_INCLUDES)
|
||||
|
||||
sndfile_info_SOURCES = sndfile-info.c
|
||||
sndfile_info_LDADD = $(SNDFILEDIR)/libsndfile.la
|
||||
|
||||
sndfile_play_SOURCES = sndfile-play.c
|
||||
sndfile_play_LDADD = $(SNDFILEDIR)/libsndfile.la $(OS_SPECIFIC_LINKS) $(ALSA_LIBS)
|
||||
sndfile_play_LDADD = $(SNDFILEDIR)/libsndfile.la $(OS_SPECIFIC_LINKS)
|
||||
|
||||
sndfile_convert_SOURCES = sndfile-convert.c
|
||||
sndfile_convert_LDADD = $(SNDFILEDIR)/libsndfile.la
|
||||
|
||||
sndfile_data_trim_SOURCES = sndfile-data-trim.c
|
||||
sndfile_data_trim_LDADD = $(SNDFILEDIR)/libsndfile.la
|
||||
|
||||
make_sine_SOURCES = make_sine.c
|
||||
make_sine_LDADD = $(SNDFILEDIR)/libsndfile.la
|
||||
|
||||
@ -35,6 +32,9 @@ sfprocess_LDADD = $(SNDFILEDIR)/libsndfile.la
|
||||
list_formats_SOURCES = list_formats.c
|
||||
list_formats_LDADD = $(SNDFILEDIR)/libsndfile.la
|
||||
|
||||
cooledit_fixer_SOURCES = cooledit-fixer.c
|
||||
cooledit_fixer_LDADD = $(SNDFILEDIR)/libsndfile.la
|
||||
|
||||
generate_SOURCES = generate.c
|
||||
generate_LDADD = $(SNDFILEDIR)/libsndfile.la
|
||||
|
||||
|
233
examples/cooledit-fixer.c
Normal file
233
examples/cooledit-fixer.c
Normal file
@ -0,0 +1,233 @@
|
||||
/*
|
||||
** Copyright (C) 2002-2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation; either version 2 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#define BUFFER_LEN 1024
|
||||
|
||||
static void usage_exit (char *progname) ;
|
||||
static int is_data_really_float (SNDFILE *sndfile) ;
|
||||
static void fix_file (char *filename) ;
|
||||
static off_t file_size (char *filename) ;
|
||||
|
||||
static int buffer [BUFFER_LEN] ;
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{ SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
int k, data_is_float, converted = 0 ;
|
||||
|
||||
puts ("\nCooledit Fixer.\n---------------") ;
|
||||
|
||||
if (argc < 2)
|
||||
usage_exit (argv [0]) ;
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
{ if ((sndfile = sf_open (argv [k], SFM_READ, &sfinfo)) == NULL)
|
||||
{ /*-printf ("Failed to open : %s\n", argv [k]) ;-*/
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (sfinfo.format != (SF_FORMAT_WAV | SF_FORMAT_PCM_32))
|
||||
{ /*-printf ("%-50s : not a 32 bit PCM WAV file.\n", argv [k]) ;-*/
|
||||
sf_close (sndfile) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
data_is_float = is_data_really_float (sndfile) ;
|
||||
|
||||
sf_close (sndfile) ;
|
||||
|
||||
if (data_is_float == SF_FALSE)
|
||||
{ /*-printf ("%-50s : not a Cooledit abomination.\n", argv [k]) ;-*/
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
fix_file (argv [k]) ;
|
||||
converted ++ ;
|
||||
} ;
|
||||
|
||||
if (converted == 0)
|
||||
puts ("\nNo files converted.") ;
|
||||
|
||||
puts ("") ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
|
||||
static void
|
||||
usage_exit (char *progname)
|
||||
{ char *cptr ;
|
||||
|
||||
if ((cptr = strrchr (progname, '/')))
|
||||
progname = cptr + 1 ;
|
||||
if ((cptr = strrchr (progname, '\\')))
|
||||
progname = cptr + 1 ;
|
||||
|
||||
printf ("\n Usage : %s <filename>\n", progname) ;
|
||||
puts ("\n"
|
||||
"Fix broken files created by Syntrillium's Cooledit. These files are \n"
|
||||
"marked as containing PCM data but actually contain floating point \n"
|
||||
"data. Only the broken files created by Cooledit are processed. All \n"
|
||||
"other files remain untouched.\n"
|
||||
"\n"
|
||||
"More than one file may be included on the command line. \n"
|
||||
) ;
|
||||
|
||||
exit (1) ;
|
||||
} /* usage_exit */
|
||||
|
||||
static int
|
||||
is_data_really_float (SNDFILE *sndfile)
|
||||
{ float *fptr ;
|
||||
int k, readcount ;
|
||||
|
||||
fptr = (float *) buffer ;
|
||||
|
||||
while ((readcount = sf_read_int (sndfile, buffer, BUFFER_LEN)) > 0)
|
||||
{ for (k = 0 ; k < readcount ; k++)
|
||||
{ if (buffer [k] == 0)
|
||||
continue ;
|
||||
|
||||
if (fabs (fptr [k]) > 32768.0)
|
||||
return SF_FALSE ;
|
||||
} ;
|
||||
} ;
|
||||
|
||||
return SF_TRUE ;
|
||||
} /* is_data_really_float */
|
||||
|
||||
static void
|
||||
fix_file (char *filename)
|
||||
{ static char newfilename [512] ;
|
||||
|
||||
SNDFILE *infile, *outfile ;
|
||||
SF_INFO sfinfo ;
|
||||
int readcount, k ;
|
||||
float *fptr, normfactor ;
|
||||
char *cptr ;
|
||||
|
||||
printf ("\nFixing : %s\n", filename) ;
|
||||
|
||||
if ((infile = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("Not able to open input file %s\n", filename) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (strlen (filename) >= sizeof (newfilename) - 1)
|
||||
{ puts ("Error : Path name too long.\n") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
strncpy (newfilename, filename, sizeof (newfilename)) ;
|
||||
newfilename [sizeof (newfilename) - 1] = 0 ;
|
||||
|
||||
if ((cptr = strrchr (newfilename, '/')) == NULL)
|
||||
cptr = strrchr (newfilename, '\\') ;
|
||||
|
||||
if (cptr)
|
||||
{ cptr [1] = 0 ;
|
||||
strncat (newfilename, "fixed.wav", sizeof (newfilename) - strlen (newfilename) - 1) ;
|
||||
}
|
||||
else
|
||||
strncpy (newfilename, "fixed.wav", sizeof (newfilename) - 1) ;
|
||||
|
||||
newfilename [sizeof (newfilename) - 1] = 0 ;
|
||||
|
||||
printf (" Output : %s\n", newfilename) ;
|
||||
|
||||
sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT ;
|
||||
|
||||
if ((outfile = sf_open (newfilename, SFM_WRITE, &sfinfo)) == NULL)
|
||||
{ printf ("Not able to output open file %s\n", filename) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
/* Find the file peak. sf-command (SFC_CALC_SIGNAL_MAX) cannot be used. */
|
||||
|
||||
fptr = (float *) buffer ;
|
||||
|
||||
normfactor = 0.0 ;
|
||||
|
||||
while ((readcount = sf_read_int (infile, buffer, BUFFER_LEN)) > 0)
|
||||
{ for (k = 0 ; k < readcount ; k++)
|
||||
if (fabs (fptr [k]) > normfactor)
|
||||
normfactor = fabs (fptr [k]) ;
|
||||
} ;
|
||||
|
||||
printf (" Peak : %g\n", normfactor) ;
|
||||
|
||||
normfactor = 1.0 / normfactor ;
|
||||
|
||||
sf_seek (infile, 0, SEEK_SET) ;
|
||||
|
||||
while ((readcount = sf_read_int (infile, buffer, BUFFER_LEN)) > 0)
|
||||
{ for (k = 0 ; k < readcount ; k++)
|
||||
fptr [k] *= normfactor ;
|
||||
sf_write_float (outfile, fptr, readcount) ;
|
||||
} ;
|
||||
|
||||
sf_close (infile) ;
|
||||
sf_close (outfile) ;
|
||||
|
||||
if (abs (file_size (filename) - file_size (newfilename)) > 50)
|
||||
{ puts ("Error : file size mismatch.\n") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
printf (" Renaming : %s\n", filename) ;
|
||||
|
||||
if (remove (filename) != 0)
|
||||
{ perror ("rename") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (rename (newfilename, filename) != 0)
|
||||
{ perror ("rename") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* fix_file */
|
||||
|
||||
static off_t
|
||||
file_size (char *filename)
|
||||
{ struct stat buf ;
|
||||
|
||||
if (stat (filename, &buf) != 0)
|
||||
{ perror ("stat") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
return buf.st_size ;
|
||||
} /* file_size */
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 5475655e-3898-40ff-969b-c8ab2351b0e4
|
||||
*/
|
@ -1,22 +1,22 @@
|
||||
/*
|
||||
** Copyright (C) 2002-2005 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** Copyright (C) 2002,2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -29,7 +29,7 @@
|
||||
|
||||
static void encode_file (const char *infilename, const char *outfilename, int filetype) ;
|
||||
|
||||
int
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
if (argc != 2)
|
||||
@ -41,25 +41,25 @@ main (int argc, char **argv)
|
||||
} ;
|
||||
|
||||
/* A couple of standard WAV files. Make sure Win32 plays these. */
|
||||
encode_file (argv [1], "pcmu8.wav" , SF_FORMAT_WAV | SF_FORMAT_PCM_U8) ;
|
||||
encode_file (argv [1], "pcm16.wav" , SF_FORMAT_WAV | SF_FORMAT_PCM_16) ;
|
||||
encode_file (argv [1], "pcmu8.wav" , SF_FORMAT_WAV | SF_FORMAT_PCM_U8) ;
|
||||
encode_file (argv [1], "pcm16.wav" , SF_FORMAT_WAV | SF_FORMAT_PCM_16) ;
|
||||
encode_file (argv [1], "imaadpcm.wav", SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM) ;
|
||||
encode_file (argv [1], "msadpcm.wav", SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM) ;
|
||||
encode_file (argv [1], "gsm610.wav" , SF_FORMAT_WAV | SF_FORMAT_GSM610) ;
|
||||
encode_file (argv [1], "msadpcm.wav" , SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM) ;
|
||||
encode_file (argv [1], "gsm610.wav" , SF_FORMAT_WAV | SF_FORMAT_GSM610) ;
|
||||
|
||||
/* Soundforge W64. */
|
||||
encode_file (argv [1], "pcmu8.w64" , SF_FORMAT_W64 | SF_FORMAT_PCM_U8) ;
|
||||
encode_file (argv [1], "pcm16.w64" , SF_FORMAT_W64 | SF_FORMAT_PCM_16) ;
|
||||
encode_file (argv [1], "pcmu8.w64" , SF_FORMAT_W64 | SF_FORMAT_PCM_U8) ;
|
||||
encode_file (argv [1], "pcm16.w64" , SF_FORMAT_W64 | SF_FORMAT_PCM_16) ;
|
||||
encode_file (argv [1], "imaadpcm.w64", SF_FORMAT_W64 | SF_FORMAT_MS_ADPCM) ;
|
||||
encode_file (argv [1], "msadpcm.w64", SF_FORMAT_W64 | SF_FORMAT_IMA_ADPCM) ;
|
||||
encode_file (argv [1], "gsm610.w64" , SF_FORMAT_W64 | SF_FORMAT_GSM610) ;
|
||||
encode_file (argv [1], "msadpcm.w64" , SF_FORMAT_W64 | SF_FORMAT_IMA_ADPCM) ;
|
||||
encode_file (argv [1], "gsm610.w64" , SF_FORMAT_W64 | SF_FORMAT_GSM610) ;
|
||||
|
||||
return 0 ;
|
||||
return 0;
|
||||
} /* main */
|
||||
|
||||
/*============================================================================================
|
||||
** Helper functions and macros.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define PUT_DOTS(k) \
|
||||
{ while (k--) \
|
||||
@ -70,14 +70,14 @@ main (int argc, char **argv)
|
||||
/*========================================================================================
|
||||
*/
|
||||
|
||||
static void
|
||||
static void
|
||||
encode_file (const char *infilename, const char *outfilename, int filetype)
|
||||
{ static float buffer [BUFFER_LEN] ;
|
||||
|
||||
|
||||
SNDFILE *infile, *outfile ;
|
||||
SF_INFO sfinfo ;
|
||||
int k, readcount ;
|
||||
|
||||
|
||||
printf (" %s -> %s ", infilename, outfilename) ;
|
||||
fflush (stdout) ;
|
||||
|
||||
@ -91,19 +91,19 @@ encode_file (const char *infilename, const char *outfilename, int filetype)
|
||||
}
|
||||
|
||||
sfinfo.format = filetype ;
|
||||
|
||||
|
||||
if (! sf_format_check (&sfinfo))
|
||||
{ sf_close (infile) ;
|
||||
printf ("Invalid encoding\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
|
||||
if (! (outfile = sf_open (outfilename, SFM_WRITE, &sfinfo)))
|
||||
{ printf ("Error : could not open file : %s\n", outfilename) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
|
||||
while ((readcount = sf_read_float (infile, buffer, BUFFER_LEN)) > 0)
|
||||
sf_write_float (outfile, buffer, BUFFER_LEN) ;
|
||||
|
||||
@ -112,13 +112,13 @@ encode_file (const char *infilename, const char *outfilename, int filetype)
|
||||
|
||||
printf ("ok\n") ;
|
||||
|
||||
return ;
|
||||
return ;
|
||||
} /* encode_file */
|
||||
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: fe28ef37-ae89-4f61-966b-0b1f68e37425
|
||||
|
@ -1,18 +1,18 @@
|
||||
/*
|
||||
** Copyright (C) 2001-2005 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** Copyright (C) 2001-2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
@ -23,14 +23,13 @@
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
int
|
||||
int
|
||||
main (void)
|
||||
{ SF_FORMAT_INFO info ;
|
||||
{ SF_FORMAT_INFO info ;
|
||||
SF_INFO sfinfo ;
|
||||
char buffer [128] ;
|
||||
int format, major_count, subtype_count, m, s ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
buffer [0] = 0 ;
|
||||
sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer)) ;
|
||||
if (strlen (buffer) < 1)
|
||||
@ -41,21 +40,21 @@ main (void)
|
||||
|
||||
sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &major_count, sizeof (int)) ;
|
||||
sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &subtype_count, sizeof (int)) ;
|
||||
|
||||
|
||||
sfinfo.channels = 1 ;
|
||||
for (m = 0 ; m < major_count ; m++)
|
||||
{ info.format = m ;
|
||||
sf_command (NULL, SFC_GET_FORMAT_MAJOR, &info, sizeof (info)) ;
|
||||
printf ("%s (extension \"%s\")\n", info.name, info.extension) ;
|
||||
|
||||
|
||||
format = info.format ;
|
||||
|
||||
|
||||
for (s = 0 ; s < subtype_count ; s++)
|
||||
{ info.format = s ;
|
||||
sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &info, sizeof (info)) ;
|
||||
|
||||
|
||||
format = (format & SF_FORMAT_TYPEMASK) | info.format ;
|
||||
|
||||
|
||||
sfinfo.format = format ;
|
||||
if (sf_format_check (&sfinfo))
|
||||
printf (" %s\n", info.name) ;
|
||||
@ -64,12 +63,12 @@ main (void)
|
||||
} ;
|
||||
puts ("") ;
|
||||
|
||||
return 0 ;
|
||||
return 0;
|
||||
} /* main */
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 58127a0c-93a2-46cf-b615-fcb9adacf3f1
|
||||
|
@ -1,88 +1,88 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2005 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
|
||||
** 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.
|
||||
*/
|
||||
/*
|
||||
** Copyright (C) 1999-2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation; either version 2 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846264338
|
||||
#endif
|
||||
|
||||
#define SAMPLE_RATE 44100
|
||||
#define SAMPLE_COUNT (SAMPLE_RATE * 4) /* 4 seconds */
|
||||
#define SAMPLE_COUNT (SAMPLE_RATE*4) /* 4 seconds */
|
||||
#define AMPLITUDE (1.0 * 0x7F000000)
|
||||
#define LEFT_FREQ (344.0 / SAMPLE_RATE)
|
||||
#define RIGHT_FREQ (466.0 / SAMPLE_RATE)
|
||||
#define LEFT_FREQ (344.0 / SAMPLE_RATE)
|
||||
#define RIGHT_FREQ (466.0 / SAMPLE_RATE)
|
||||
|
||||
int
|
||||
main (void)
|
||||
{ SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
int k ;
|
||||
int *buffer ;
|
||||
int
|
||||
main (void)
|
||||
{ SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
int k ;
|
||||
int *buffer ;
|
||||
|
||||
if (! (buffer = malloc (2 * SAMPLE_COUNT * sizeof (int))))
|
||||
{ printf ("Malloc failed.\n") ;
|
||||
exit (0) ;
|
||||
} ;
|
||||
|
||||
if (! (buffer = malloc (2 * SAMPLE_COUNT * sizeof (int))))
|
||||
{ printf ("Malloc failed.\n") ;
|
||||
exit (0) ;
|
||||
} ;
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
sfinfo.samplerate = SAMPLE_RATE ;
|
||||
sfinfo.frames = SAMPLE_COUNT ;
|
||||
sfinfo.channels = 2 ;
|
||||
sfinfo.format = (SF_FORMAT_WAV | SF_FORMAT_PCM_24) ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
sfinfo.samplerate = SAMPLE_RATE ;
|
||||
sfinfo.frames = SAMPLE_COUNT ;
|
||||
sfinfo.channels = 2 ;
|
||||
sfinfo.format = (SF_FORMAT_WAV | SF_FORMAT_PCM_24) ;
|
||||
|
||||
if (! (file = sf_open ("sine.wav", SFM_WRITE, &sfinfo)))
|
||||
{ printf ("Error : Not able to open output file.\n") ;
|
||||
return 1 ;
|
||||
} ;
|
||||
if (! (file = sf_open ("sine.wav", SFM_WRITE, &sfinfo)))
|
||||
{ printf ("Error : Not able to open output file.\n") ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if (sfinfo.channels == 1)
|
||||
{ for (k = 0 ; k < SAMPLE_COUNT ; k++)
|
||||
buffer [k] = AMPLITUDE * sin (LEFT_FREQ * 2 * k * M_PI) ;
|
||||
{ for (k = 0 ; k < SAMPLE_COUNT ; k++)
|
||||
buffer [k] = AMPLITUDE * sin (LEFT_FREQ * 2 * k * M_PI) ;
|
||||
}
|
||||
else if (sfinfo.channels == 2)
|
||||
{ for (k = 0 ; k < SAMPLE_COUNT ; k++)
|
||||
{ buffer [2 * k] = AMPLITUDE * sin (LEFT_FREQ * 2 * k * M_PI) ;
|
||||
buffer [2 * k + 1] = AMPLITUDE * sin (RIGHT_FREQ * 2 * k * M_PI) ;
|
||||
} ;
|
||||
{ for (k = 0 ; k < SAMPLE_COUNT ; k++)
|
||||
{ buffer [2*k ] = AMPLITUDE * sin (LEFT_FREQ * 2 * k * M_PI) ;
|
||||
buffer [2*k+1] = AMPLITUDE * sin (RIGHT_FREQ * 2 * k * M_PI) ;
|
||||
} ;
|
||||
}
|
||||
else
|
||||
{ printf ("makesine can only generate mono or stereo files.\n") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (sf_write_int (file, buffer, sfinfo.channels * SAMPLE_COUNT) !=
|
||||
sfinfo.channels * SAMPLE_COUNT)
|
||||
puts (sf_strerror (file)) ;
|
||||
|
||||
if (sf_write_int (file, buffer, sfinfo.channels * SAMPLE_COUNT) !=
|
||||
sfinfo.channels * SAMPLE_COUNT)
|
||||
puts (sf_strerror (file)) ;
|
||||
|
||||
sf_close (file) ;
|
||||
return 0 ;
|
||||
} /* main */
|
||||
sf_close (file) ;
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: fd945a2c-a306-49ef-a262-6336ced15246
|
||||
|
@ -1,87 +1,87 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2005 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
|
||||
** 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.
|
||||
*/
|
||||
/*
|
||||
** Copyright (C) 1999-2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation; either version 2 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
#define SAMPLE_RATE 8000
|
||||
#define SAMPLE_COUNT 100
|
||||
#define SAMPLE_RATE 8000
|
||||
#define SAMPLE_COUNT 100
|
||||
|
||||
int
|
||||
main (void)
|
||||
{ SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
int
|
||||
main (void)
|
||||
{ SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
char *filename ;
|
||||
int k, buffer [SAMPLE_COUNT] ;
|
||||
|
||||
int k, buffer [SAMPLE_COUNT] ;
|
||||
|
||||
for (k = 0 ; k < SAMPLE_COUNT ; k++)
|
||||
buffer [k] = ((3 * k + 2) << 24) + ((3 * k + 1) << 16) + ((3 * k) << 8) ;
|
||||
buffer [k] = ((3 * k + 2) << 24) + ((3 * k + 1) << 16) + ((3 * k) << 8) ;
|
||||
|
||||
/* Big endian first. */
|
||||
sfinfo.samplerate = SAMPLE_RATE ;
|
||||
sfinfo.frames = SAMPLE_COUNT ;
|
||||
sfinfo.channels = 1 ;
|
||||
sfinfo.format = (SF_ENDIAN_BIG | SF_FORMAT_PAF | SF_FORMAT_PCM_24) ;
|
||||
|
||||
sfinfo.samplerate = SAMPLE_RATE ;
|
||||
sfinfo.frames = SAMPLE_COUNT ;
|
||||
sfinfo.channels = 1 ;
|
||||
sfinfo.format = (SF_ENDIAN_BIG | SF_FORMAT_PAF | SF_FORMAT_PCM_24) ;
|
||||
|
||||
filename = "be-pcm24.paf" ;
|
||||
|
||||
if (! (file = sf_open (filename, SFM_WRITE, &sfinfo)))
|
||||
{ printf ("Error : Not able to open output file.\n") ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if (! (file = sf_open (filename, SFM_WRITE, &sfinfo)))
|
||||
{ printf ("Error : Not able to open output file.\n") ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
printf ("Writing data to '%s'\n", filename) ;
|
||||
|
||||
if (sf_write_int (file, buffer, SAMPLE_COUNT) != SAMPLE_COUNT)
|
||||
puts (sf_strerror (file)) ;
|
||||
if (sf_write_int (file, buffer, SAMPLE_COUNT) != SAMPLE_COUNT)
|
||||
puts (sf_strerror (file)) ;
|
||||
|
||||
sf_close (file) ;
|
||||
sf_close (file) ;
|
||||
|
||||
/* Little endian first. */
|
||||
sfinfo.samplerate = SAMPLE_RATE ;
|
||||
sfinfo.frames = SAMPLE_COUNT ;
|
||||
sfinfo.channels = 1 ;
|
||||
sfinfo.format = (SF_ENDIAN_LITTLE | SF_FORMAT_PAF | SF_FORMAT_PCM_24) ;
|
||||
|
||||
sfinfo.samplerate = SAMPLE_RATE ;
|
||||
sfinfo.frames = SAMPLE_COUNT ;
|
||||
sfinfo.channels = 1 ;
|
||||
sfinfo.format = (SF_ENDIAN_LITTLE | SF_FORMAT_PAF | SF_FORMAT_PCM_24) ;
|
||||
|
||||
filename = "le-pcm24.paf" ;
|
||||
|
||||
if (! (file = sf_open (filename, SFM_WRITE, &sfinfo)))
|
||||
{ printf ("Error : Not able to open output file.\n") ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if (! (file = sf_open (filename, SFM_WRITE, &sfinfo)))
|
||||
{ printf ("Error : Not able to open output file.\n") ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
printf ("Writing data to '%s'\n", filename) ;
|
||||
|
||||
if (sf_write_int (file, buffer, SAMPLE_COUNT) != SAMPLE_COUNT)
|
||||
puts (sf_strerror (file)) ;
|
||||
if (sf_write_int (file, buffer, SAMPLE_COUNT) != SAMPLE_COUNT)
|
||||
puts (sf_strerror (file)) ;
|
||||
|
||||
sf_close (file) ;
|
||||
sf_close (file) ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 62025b88-1f3f-46fb-994a-8220bf915772
|
||||
|
@ -1,39 +1,39 @@
|
||||
/*
|
||||
** Copyright (C) 2001-2005 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** Copyright (C) 2001-2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* Include this header file to use functions from libsndfile. */
|
||||
#include <sndfile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
/* This will be the length of the buffer used to hold.frames while
|
||||
** we process them.
|
||||
*/
|
||||
#define BUFFER_LEN 1024
|
||||
#define BUFFER_LEN 1024
|
||||
|
||||
/* libsndfile can handle more than 6 channels but we'll restrict it to 6. */
|
||||
#define MAX_CHANNELS 6
|
||||
#define MAX_CHANNELS 6
|
||||
|
||||
/* Function prototype. */
|
||||
static void process_data (double *data, int count, int channels) ;
|
||||
|
||||
|
||||
int
|
||||
int
|
||||
main (void)
|
||||
{ /* This is a buffer of double precision floating point values
|
||||
** which will hold our data while we process it.
|
||||
@ -41,7 +41,7 @@ main (void)
|
||||
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
|
||||
** sf_open function return an SNDFILE* pointer when they sucessfully
|
||||
** open the specified file.
|
||||
*/
|
||||
SNDFILE *infile, *outfile ;
|
||||
@ -49,7 +49,7 @@ main (void)
|
||||
/* 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" ;
|
||||
@ -58,14 +58,14 @@ main (void)
|
||||
/* 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.
|
||||
** 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
|
||||
** 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
|
||||
** instance to open a raw 16 bit stereo PCM file you would need the following
|
||||
** two lines:
|
||||
**
|
||||
**
|
||||
** sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16 ;
|
||||
** sfinfo.channels = 2 ;
|
||||
*/
|
||||
@ -105,13 +105,13 @@ main (void)
|
||||
|
||||
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 } ;
|
||||
{ double channel_gain [MAX_CHANNELS] = { 0.5, 0.8, 0.1, 0.4, 0.4, 0.9 } ;
|
||||
int k, chan ;
|
||||
|
||||
/* Process the data here.
|
||||
** If the soundfile contains more then 1 channel you need to take care of
|
||||
/* 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.
|
||||
** Current we just apply a channel dependant gain.
|
||||
*/
|
||||
|
||||
for (chan = 0 ; chan < channels ; chan ++)
|
||||
@ -124,7 +124,7 @@ process_data (double *data, int count, int channels)
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: de9fdd1e-b807-41ef-9d51-075ba383e536
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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
|
||||
@ -17,14 +17,14 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
#define BUFFER_LEN 1024
|
||||
#define BUFFER_LEN 1024
|
||||
|
||||
|
||||
typedef struct
|
||||
@ -34,11 +34,10 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{ const char *ext ;
|
||||
int len ;
|
||||
int format ;
|
||||
int len ;
|
||||
int format ;
|
||||
} OUTPUT_FORMAT_MAP ;
|
||||
|
||||
static void copy_metadata (SNDFILE *outfile, SNDFILE *infile) ;
|
||||
static void copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels) ;
|
||||
static void copy_data_int (SNDFILE *outfile, SNDFILE *infile, int channels) ;
|
||||
|
||||
@ -47,13 +46,10 @@ 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 },
|
||||
{ "ircam", 0, SF_FORMAT_IRCAM },
|
||||
{ "sf", 0, SF_FORMAT_IRCAM },
|
||||
@ -65,10 +61,7 @@ static OUTPUT_FORMAT_MAP format_map [] =
|
||||
{ "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 }
|
||||
{ "xi", 0, SF_FORMAT_XI }
|
||||
} ; /* format_map */
|
||||
|
||||
static int
|
||||
@ -78,7 +71,7 @@ guess_output_file_type (char *str, int format)
|
||||
|
||||
format &= SF_FORMAT_SUBMASK ;
|
||||
|
||||
if ((cptr = strrchr (str, '.')) == NULL)
|
||||
if (! (cptr = strrchr (str, '.')))
|
||||
return 0 ;
|
||||
|
||||
strncpy (buffer, cptr + 1, 15) ;
|
||||
@ -87,17 +80,12 @@ guess_output_file_type (char *str, int format)
|
||||
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 ;
|
||||
{ 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 format_map [k].format | format ;
|
||||
} ;
|
||||
|
||||
return 0 ;
|
||||
@ -110,12 +98,7 @@ print_usage (char *progname)
|
||||
|
||||
int k ;
|
||||
|
||||
printf ("\nUsage : %s [options] [encoding] <input file> <output file>\n", progname) ;
|
||||
puts ("\n"
|
||||
" where [option] may be:\n\n"
|
||||
" -override-sample-rate=X : force sample rate of input to X\n\n"
|
||||
) ;
|
||||
|
||||
printf ("\nUsage : %s [encoding] <input file> <output file>\n", progname) ;
|
||||
puts ("\n"
|
||||
" where [encoding] may be one of the following:\n\n"
|
||||
" -pcms8 : force the output to signed 8 bit pcm\n"
|
||||
@ -144,47 +127,46 @@ print_usage (char *progname)
|
||||
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) ;
|
||||
printf (" %-10s : %s\n", format_map [k].ext, info.name) ;
|
||||
} ;
|
||||
|
||||
puts ("") ;
|
||||
} /* print_usage */
|
||||
|
||||
int
|
||||
main (int argc, char * argv [])
|
||||
main (int argc, char *argv[])
|
||||
{ char *progname, *infilename, *outfilename ;
|
||||
SNDFILE *infile = NULL, *outfile = NULL ;
|
||||
SNDFILE *infile, *outfile ;
|
||||
SF_INFO sfinfo ;
|
||||
int k, outfilemajor, outfileminor = 0, infileminor ;
|
||||
int override_sample_rate = 0 ; /* assume no sample rate override. */
|
||||
|
||||
progname = strrchr (argv [0], '/') ;
|
||||
progname = progname ? progname + 1 : argv [0] ;
|
||||
|
||||
if (argc < 3 || argc > 5)
|
||||
{ print_usage (progname) ;
|
||||
return 1 ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
infilename = argv [argc-2] ;
|
||||
outfilename = argv [argc-1] ;
|
||||
|
||||
if (strcmp (infilename, outfilename) == 0)
|
||||
if (! strcmp (infilename, outfilename))
|
||||
{ printf ("Error : Input and output filenames are the same.\n\n") ;
|
||||
print_usage (progname) ;
|
||||
return 1 ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if (infilename [0] == '-')
|
||||
{ printf ("Error : Input filename (%s) looks like an option.\n\n", infilename) ;
|
||||
print_usage (progname) ;
|
||||
return 1 ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if (outfilename [0] == '-')
|
||||
{ printf ("Error : Output filename (%s) looks like an option.\n\n", outfilename) ;
|
||||
print_usage (progname) ;
|
||||
return 1 ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
for (k = 1 ; k < argc - 2 ; k++)
|
||||
@ -245,41 +227,26 @@ main (int argc, char * argv [])
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (! strcmp (argv [k], "-override-sample-rate="))
|
||||
{ char *ptr ;
|
||||
|
||||
ptr = argv [k] + strlen ("-override-sample-rate=") ;
|
||||
override_sample_rate = atoi (ptr) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
printf ("Error : Not able to decode argunment '%s'.\n", argv [k]) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if ((infile = sf_open (infilename, SFM_READ, &sfinfo)) == NULL)
|
||||
if (! (infile = sf_open (infilename, SFM_READ, &sfinfo)))
|
||||
{ printf ("Not able to open input file %s.\n", infilename) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return 1 ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
/* Update sample rate if forced to something else. */
|
||||
if (override_sample_rate)
|
||||
sfinfo.samplerate=override_sample_rate ;
|
||||
|
||||
|
||||
infileminor = sfinfo.format & SF_FORMAT_SUBMASK ;
|
||||
|
||||
if ((sfinfo.format = guess_output_file_type (outfilename, sfinfo.format)) == 0)
|
||||
if (! (sfinfo.format = guess_output_file_type (outfilename, sfinfo.format)))
|
||||
{ printf ("Error : Not able to determine output file type for %s.\n", outfilename) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
outfilemajor = sfinfo.format & (SF_FORMAT_TYPEMASK | SF_FORMAT_ENDMASK) ;
|
||||
|
||||
if (outfileminor == 0)
|
||||
outfileminor = sfinfo.format & SF_FORMAT_SUBMASK ;
|
||||
|
||||
if (outfileminor != 0)
|
||||
if (outfileminor)
|
||||
sfinfo.format = outfilemajor | outfileminor ;
|
||||
else
|
||||
sfinfo.format = outfilemajor | (sfinfo.format & SF_FORMAT_SUBMASK) ;
|
||||
@ -304,12 +271,9 @@ main (int argc, char * argv [])
|
||||
/* Open the output file. */
|
||||
if ((outfile = sf_open (outfilename, SFM_WRITE, &sfinfo)) == NULL)
|
||||
{ printf ("Not able to open output file %s : %s\n", outfilename, sf_strerror (NULL)) ;
|
||||
return 1 ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
/* Copy the metadata */
|
||||
copy_metadata (outfile, infile) ;
|
||||
|
||||
if ((outfileminor == SF_FORMAT_DOUBLE) || (outfileminor == SF_FORMAT_FLOAT) ||
|
||||
(infileminor == SF_FORMAT_DOUBLE) || (infileminor == SF_FORMAT_FLOAT))
|
||||
copy_data_fp (outfile, infile, sfinfo.channels) ;
|
||||
@ -322,24 +286,6 @@ main (int argc, char * argv [])
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
static void
|
||||
copy_metadata (SNDFILE *outfile, SNDFILE *infile)
|
||||
{ SF_INSTRUMENT inst ;
|
||||
const char *str ;
|
||||
int k, err = 0 ;
|
||||
|
||||
for (k = SF_STR_FIRST ; k <= SF_STR_LAST ; k++)
|
||||
{ str = sf_get_string (infile, k) ;
|
||||
if (str != NULL)
|
||||
err = sf_set_string (outfile, k, str) ;
|
||||
} ;
|
||||
|
||||
memset (&inst, 0, sizeof (inst)) ;
|
||||
if (sf_command (infile, SFC_GET_INSTRUMENT, &inst, sizeof (inst)) == SF_TRUE)
|
||||
sf_command (outfile, SFC_SET_INSTRUMENT, &inst, sizeof (inst)) ;
|
||||
|
||||
} /* copy_metadata */
|
||||
|
||||
static void
|
||||
copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels)
|
||||
{ static double data [BUFFER_LEN], max ;
|
||||
@ -349,7 +295,7 @@ copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels)
|
||||
readcount = frames ;
|
||||
|
||||
sf_command (infile, SFC_CALC_SIGNAL_MAX, &max, sizeof (max)) ;
|
||||
|
||||
|
||||
if (max < 1.0)
|
||||
{ while (readcount > 0)
|
||||
{ readcount = sf_readf_double (infile, data, frames) ;
|
||||
@ -357,11 +303,9 @@ copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels)
|
||||
} ;
|
||||
}
|
||||
else
|
||||
{ sf_command (infile, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE) ;
|
||||
|
||||
while (readcount > 0)
|
||||
{ while (readcount > 0)
|
||||
{ readcount = sf_readf_double (infile, data, frames) ;
|
||||
for (k = 0 ; k < readcount * channels ; k++)
|
||||
for (k = 0 ; k < readcount ; k++)
|
||||
data [k] /= max ;
|
||||
sf_writef_double (outfile, data, readcount) ;
|
||||
} ;
|
||||
@ -388,7 +332,7 @@ copy_data_int (SNDFILE *outfile, SNDFILE *infile, int channels)
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 259682b3-2887-48a6-b5bb-3cde00521ba3
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2006 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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
|
||||
@ -24,55 +24,12 @@
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#define BUFFER_LEN (1 << 16)
|
||||
#define BUFFER_LEN (1 << 16)
|
||||
|
||||
#if (defined (WIN32) || defined (_WIN32))
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
static void print_version (void) ;
|
||||
static void print_usage (const char *progname) ;
|
||||
|
||||
static void info_dump (const char *filename) ;
|
||||
static void instrument_dump (const char *filename) ;
|
||||
static void broadcast_dump (const char *filename) ;
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{ int k ;
|
||||
|
||||
print_version () ;
|
||||
|
||||
if (argc < 2 || strcmp (argv [1], "--help") == 0 || strcmp (argv [1], "-h") == 0)
|
||||
{ char *progname ;
|
||||
|
||||
progname = strrchr (argv [0], '/') ;
|
||||
progname = progname ? progname + 1 : argv [0] ;
|
||||
|
||||
print_usage (progname) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if (strcmp (argv [1], "-i") == 0)
|
||||
{ instrument_dump (argv [2]) ;
|
||||
return 0 ;
|
||||
} ;
|
||||
|
||||
if (strcmp (argv [1], "-b") == 0)
|
||||
{ broadcast_dump (argv [2]) ;
|
||||
return 0 ;
|
||||
} ;
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
info_dump (argv [k]) ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
/*==============================================================================
|
||||
** Print version and usage.
|
||||
*/
|
||||
|
||||
static double data [BUFFER_LEN] ;
|
||||
|
||||
static void
|
||||
@ -81,22 +38,17 @@ print_version (void)
|
||||
|
||||
sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer)) ;
|
||||
printf ("\nVersion : %s\n\n", buffer) ;
|
||||
} /* print_version */
|
||||
} /* print_usage */
|
||||
|
||||
|
||||
static void
|
||||
print_usage (const char *progname)
|
||||
{ printf ("Usage :\n %s <file> ...\n", progname) ;
|
||||
printf (" Prints out information about one or more sound files.\n\n") ;
|
||||
printf (" %s -i <file>\n", progname) ;
|
||||
printf (" Prints out the instrument data for the given file.\n\n") ;
|
||||
printf (" %s -b <file>\n", progname) ;
|
||||
printf (" Prints out the broadcast WAV info for the given file.\n\n") ;
|
||||
print_usage (char *progname)
|
||||
{ printf ("\nUsage : %s <file> ...\n", progname) ;
|
||||
printf ("\nPrints out information about one or more sound files.\n\n") ;
|
||||
#if (defined (_WIN32) || defined (WIN32))
|
||||
printf ("This is a Unix style command line application which\n"
|
||||
"should be run in a MSDOS box or Command Shell window.\n\n") ;
|
||||
printf ("Sleeping for 5 seconds before exiting.\n\n") ;
|
||||
fflush (stdout) ;
|
||||
|
||||
/* This is the officially blessed by microsoft way but I can't get
|
||||
** it to link.
|
||||
@ -107,12 +59,6 @@ print_usage (const char *progname)
|
||||
#endif
|
||||
} /* print_usage */
|
||||
|
||||
/*==============================================================================
|
||||
** Dumping of sndfile info.
|
||||
*/
|
||||
|
||||
static double data [BUFFER_LEN] ;
|
||||
|
||||
static double
|
||||
get_signal_max (SNDFILE *file)
|
||||
{ double max, temp ;
|
||||
@ -135,41 +81,6 @@ get_signal_max (SNDFILE *file)
|
||||
return max ;
|
||||
} /* get_signal_max */
|
||||
|
||||
static double
|
||||
calc_decibels (SF_INFO * sfinfo, double max)
|
||||
{ double decibels ;
|
||||
|
||||
switch (sfinfo->format & SF_FORMAT_SUBMASK)
|
||||
{ case SF_FORMAT_PCM_U8 :
|
||||
case SF_FORMAT_PCM_S8 :
|
||||
decibels = max / 0x80 ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_PCM_16 :
|
||||
decibels = max / 0x8000 ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_PCM_24 :
|
||||
decibels = max / 0x800000 ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_PCM_32 :
|
||||
decibels = max / 0x80000000 ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_FLOAT :
|
||||
case SF_FORMAT_DOUBLE :
|
||||
decibels = max / 1.0 ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
decibels = max / 0x8000 ;
|
||||
break ;
|
||||
} ;
|
||||
|
||||
return 20.0 * log10 (decibels) ;
|
||||
} /* calc_decibels */
|
||||
|
||||
static const char *
|
||||
generate_duration_str (SF_INFO *sfinfo)
|
||||
{ static char str [128] ;
|
||||
@ -185,7 +96,7 @@ generate_duration_str (SF_INFO *sfinfo)
|
||||
return "unknown" ;
|
||||
|
||||
seconds = sfinfo->frames / sfinfo->samplerate ;
|
||||
|
||||
|
||||
snprintf (str, sizeof (str) - 1, "%02d:", seconds / 60 / 60) ;
|
||||
|
||||
seconds = seconds % (60 * 60) ;
|
||||
@ -200,154 +111,75 @@ generate_duration_str (SF_INFO *sfinfo)
|
||||
return str ;
|
||||
} /* generate_duration_str */
|
||||
|
||||
static void
|
||||
info_dump (const char *filename)
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{ static char strbuffer [BUFFER_LEN] ;
|
||||
SNDFILE *file ;
|
||||
char *progname, *infilename ;
|
||||
SNDFILE *infile ;
|
||||
SF_INFO sfinfo ;
|
||||
double signal_max, decibels ;
|
||||
int k ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
progname = strrchr (argv [0], '/') ;
|
||||
progname = progname ? progname + 1 : argv [0] ;
|
||||
|
||||
if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("Error : Not able to open input file %s.\n", filename) ;
|
||||
fflush (stdout) ;
|
||||
memset (data, 0, sizeof (data)) ;
|
||||
sf_command (file, SFC_GET_LOG_INFO, strbuffer, BUFFER_LEN) ;
|
||||
print_version () ;
|
||||
|
||||
if (argc < 2)
|
||||
{ print_usage (progname) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
{ infilename = argv [k] ;
|
||||
|
||||
if (strcmp (infilename, "--help") == 0 || strcmp (infilename, "-h") == 0)
|
||||
{ print_usage (progname) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
sfinfo.format = 0 ;
|
||||
|
||||
infile = sf_open (infilename, SFM_READ, &sfinfo) ;
|
||||
|
||||
/*-if (sfinfo.format != (SF_FORMAT_AIFF | SF_FORMAT_IMA_ADPCM))
|
||||
{ puts ("Temporary check : Not SF_FORMAT_AIFF | SF_FORMAT_IMA_ADPCM.\n") ; /+*-exit (1) ;-*+/ }
|
||||
-*/
|
||||
printf ("========================================\n") ;
|
||||
sf_command (infile, SFC_GET_LOG_INFO, strbuffer, BUFFER_LEN) ;
|
||||
puts (strbuffer) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return ;
|
||||
} ;
|
||||
printf ("----------------------------------------\n") ;
|
||||
|
||||
printf ("========================================\n") ;
|
||||
sf_command (file, SFC_GET_LOG_INFO, strbuffer, BUFFER_LEN) ;
|
||||
puts (strbuffer) ;
|
||||
printf ("----------------------------------------\n") ;
|
||||
|
||||
if (file == NULL)
|
||||
{ printf ("Error : Not able to open input file %s.\n", filename) ;
|
||||
fflush (stdout) ;
|
||||
memset (data, 0, sizeof (data)) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
}
|
||||
else
|
||||
{ printf ("Sample Rate : %d\n", sfinfo.samplerate) ;
|
||||
if (sfinfo.frames > 0x7FFFFFFF)
|
||||
printf ("Frames : unknown\n") ;
|
||||
if (! infile)
|
||||
{ printf ("Error : Not able to open input file %s.\n", infilename) ;
|
||||
fflush (stdout) ;
|
||||
memset (data, 0, sizeof (data)) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
}
|
||||
else
|
||||
printf ("Frames : %ld\n", (long) sfinfo.frames) ;
|
||||
printf ("Channels : %d\n", sfinfo.channels) ;
|
||||
printf ("Format : 0x%08X\n", sfinfo.format) ;
|
||||
printf ("Sections : %d\n", sfinfo.sections) ;
|
||||
printf ("Seekable : %s\n", (sfinfo.seekable ? "TRUE" : "FALSE")) ;
|
||||
printf ("Duration : %s\n", generate_duration_str (&sfinfo)) ;
|
||||
{ printf ("Sample Rate : %d\n", sfinfo.samplerate) ;
|
||||
if (sfinfo.frames > 0x7FFFFFFF)
|
||||
printf ("Frames : unknown\n") ;
|
||||
else
|
||||
printf ("Frames : %ld\n", (long) sfinfo.frames) ;
|
||||
printf ("Channels : %d\n", sfinfo.channels) ;
|
||||
printf ("Format : 0x%08X\n", sfinfo.format) ;
|
||||
printf ("Sections : %d\n", sfinfo.sections) ;
|
||||
printf ("Seekable : %s\n", (sfinfo.seekable ? "TRUE" : "FALSE")) ;
|
||||
printf ("Duration : %s\n", generate_duration_str (&sfinfo)) ;
|
||||
|
||||
/* Do not use sf_signal_max because it doesn work for non-seekable files . */
|
||||
signal_max = get_signal_max (file) ;
|
||||
decibels = calc_decibels (&sfinfo, signal_max) ;
|
||||
printf ("Signal Max : %g (%4.2f dB)\n\n", signal_max, decibels) ;
|
||||
/* Do not use sf_signal_max because it doesn work for non-seekable files . */
|
||||
printf ("Signal Max : %g\n\n", get_signal_max (infile)) ;
|
||||
} ;
|
||||
|
||||
sf_close (infile) ;
|
||||
} ;
|
||||
|
||||
sf_close (file) ;
|
||||
|
||||
} /* info_dump */
|
||||
|
||||
/*==============================================================================
|
||||
** Dumping of SF_INSTRUMENT data.
|
||||
*/
|
||||
|
||||
static const char *
|
||||
str_of_type (int mode)
|
||||
{ switch (mode)
|
||||
{ case SF_LOOP_NONE : return "none" ;
|
||||
case SF_LOOP_FORWARD : return "fwd " ;
|
||||
case SF_LOOP_BACKWARD : return "back" ;
|
||||
case SF_LOOP_ALTERNATING : return "alt " ;
|
||||
default : break ;
|
||||
} ;
|
||||
|
||||
return "????" ;
|
||||
} /* str_of_mode */
|
||||
|
||||
static void
|
||||
instrument_dump (const char *filename)
|
||||
{ SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
SF_INSTRUMENT inst ;
|
||||
int got_inst, k ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("Error : Not able to open input file %s.\n", filename) ;
|
||||
fflush (stdout) ;
|
||||
memset (data, 0, sizeof (data)) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
got_inst = sf_command (file, SFC_GET_INSTRUMENT, &inst, sizeof (inst)) ;
|
||||
sf_close (file) ;
|
||||
|
||||
if (got_inst == SF_FALSE)
|
||||
{ printf ("Error : File '%s' does not contain instrument data.\n\n", filename) ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
printf ("Instrument : %s\n\n", filename) ;
|
||||
printf (" Gain : %d\n", inst.gain) ;
|
||||
printf (" Base note : %d\n", inst.basenote) ;
|
||||
printf (" Velocity : %d - %d\n", (int) inst.velocity_lo, (int) inst.velocity_hi) ;
|
||||
printf (" Key : %d - %d\n", (int) inst.key_lo, (int) inst.key_hi) ;
|
||||
printf (" Loop points : %d\n", inst.loop_count) ;
|
||||
|
||||
for (k = 0 ; k < inst.loop_count ; k++)
|
||||
printf (" %-2d Mode : %s Start : %6d End : %6d Count : %6d\n", k, str_of_type (inst.loops [k].mode), inst.loops [k].start, inst.loops [k].end, inst.loops [k].count) ;
|
||||
|
||||
putchar ('\n') ;
|
||||
} /* instrument_dump */
|
||||
|
||||
static void
|
||||
broadcast_dump (const char *filename)
|
||||
{ SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
SF_BROADCAST_INFO bext ;
|
||||
int got_bext ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("Error : Not able to open input file %s.\n", filename) ;
|
||||
fflush (stdout) ;
|
||||
memset (data, 0, sizeof (data)) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
memset (&bext, 0, sizeof (SF_BROADCAST_INFO)) ;
|
||||
|
||||
got_bext = sf_command (file, SFC_GET_BROADCAST_INFO, &bext, sizeof (bext)) ;
|
||||
sf_close (file) ;
|
||||
|
||||
if (got_bext == SF_FALSE)
|
||||
{ printf ("Error : File '%s' does not contain broadcast information.\n\n", filename) ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
printf ("Description : %.*s\n", (int) sizeof (bext.description), bext.description) ;
|
||||
printf ("Originator : %.*s\n", (int) sizeof (bext.originator), bext.originator) ;
|
||||
printf ("Origination ref : %.*s\n", (int) sizeof (bext.originator_reference), bext.originator_reference) ;
|
||||
printf ("Origination date : %.*s\n", (int) sizeof (bext.origination_date), bext.origination_date) ;
|
||||
printf ("Origination time : %.*s\n", (int) sizeof (bext.origination_time), bext.origination_time) ;
|
||||
printf ("BWF version : %d\n", bext.version) ;
|
||||
printf ("UMID : %.*s\n", (int) sizeof (bext.umid), bext.umid) ;
|
||||
printf ("Coding history : %.*s\n", bext.coding_history_size, bext.coding_history) ;
|
||||
|
||||
} /* broadcast_dump */
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: f59a05db-a182-41de-aedd-d717ce2bb099
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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
|
||||
@ -16,7 +16,7 @@
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -27,13 +27,6 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_ALSA_ASOUNDLIB_H
|
||||
#define ALSA_PCM_NEW_HW_PARAMS_API
|
||||
#define ALSA_PCM_NEW_SW_PARAMS_API
|
||||
#include <alsa/asoundlib.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#if defined (__linux__)
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
@ -48,9 +41,10 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/audioio.h>
|
||||
|
||||
#elif (OS_IS_WIN32 == 1)
|
||||
#elif (defined (_WIN32) || defined (WIN32))
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include <mmreg.h>
|
||||
|
||||
#endif
|
||||
|
||||
@ -63,282 +57,6 @@
|
||||
** Linux/OSS functions for playing a sound.
|
||||
*/
|
||||
|
||||
#if HAVE_ALSA_ASOUNDLIB_H
|
||||
|
||||
static snd_pcm_t * alsa_open (int channels, unsigned srate, int realtime) ;
|
||||
static int alsa_write_float (snd_pcm_t *alsa_dev, float *data, int frames, int channels) ;
|
||||
|
||||
static void
|
||||
alsa_play (int argc, char *argv [])
|
||||
{ static float buffer [BUFFER_LEN] ;
|
||||
SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
snd_pcm_t * alsa_dev ;
|
||||
int k, readcount, subformat ;
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
{ memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
printf ("Playing %s\n", argv [k]) ;
|
||||
if (! (sndfile = sf_open (argv [k], SFM_READ, &sfinfo)))
|
||||
{ puts (sf_strerror (NULL)) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (sfinfo.channels < 1 || sfinfo.channels > 2)
|
||||
{ printf ("Error : channels = %d.\n", sfinfo.channels) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if ((alsa_dev = alsa_open (sfinfo.channels, (unsigned) sfinfo.samplerate, SF_FALSE)) == NULL)
|
||||
continue ;
|
||||
|
||||
subformat = sfinfo.format & SF_FORMAT_SUBMASK ;
|
||||
|
||||
if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE)
|
||||
{ double scale ;
|
||||
int m ;
|
||||
|
||||
sf_command (sndfile, SFC_CALC_SIGNAL_MAX, &scale, sizeof (scale)) ;
|
||||
if (scale < 1e-10)
|
||||
scale = 1.0 ;
|
||||
else
|
||||
scale = 32700.0 / scale ;
|
||||
|
||||
while ((readcount = sf_read_float (sndfile, buffer, BUFFER_LEN)))
|
||||
{ for (m = 0 ; m < readcount ; m++)
|
||||
buffer [m] *= scale ;
|
||||
alsa_write_float (alsa_dev, buffer, BUFFER_LEN / sfinfo.channels, sfinfo.channels) ;
|
||||
} ;
|
||||
}
|
||||
else
|
||||
{ while ((readcount = sf_read_float (sndfile, buffer, BUFFER_LEN)))
|
||||
alsa_write_float (alsa_dev, buffer, BUFFER_LEN / sfinfo.channels, sfinfo.channels) ;
|
||||
} ;
|
||||
|
||||
snd_pcm_drain (alsa_dev) ;
|
||||
snd_pcm_close (alsa_dev) ;
|
||||
|
||||
sf_close (sndfile) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* alsa_play */
|
||||
|
||||
static snd_pcm_t *
|
||||
alsa_open (int channels, unsigned samplerate, int realtime)
|
||||
{ const char * device = "default" ;
|
||||
snd_pcm_t *alsa_dev = NULL ;
|
||||
snd_pcm_hw_params_t *hw_params ;
|
||||
snd_pcm_uframes_t buffer_size, xfer_align, start_threshold ;
|
||||
snd_pcm_uframes_t alsa_period_size, alsa_buffer_frames ;
|
||||
snd_pcm_sw_params_t *sw_params ;
|
||||
|
||||
int err ;
|
||||
|
||||
if (realtime)
|
||||
{ alsa_period_size = 256 ;
|
||||
alsa_buffer_frames = 3 * alsa_period_size ;
|
||||
}
|
||||
else
|
||||
{ alsa_period_size = 1024 ;
|
||||
alsa_buffer_frames = 4 * alsa_period_size ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_open (&alsa_dev, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0)
|
||||
{ fprintf (stderr, "cannot open audio device \"%s\" (%s)\n", device, snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
snd_pcm_nonblock (alsa_dev, 0) ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_malloc (&hw_params)) < 0)
|
||||
{ fprintf (stderr, "cannot allocate hardware parameter structure (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_any (alsa_dev, hw_params)) < 0)
|
||||
{ fprintf (stderr, "cannot initialize hardware parameter structure (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_access (alsa_dev, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0)
|
||||
{ fprintf (stderr, "cannot set access type (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_format (alsa_dev, hw_params, SND_PCM_FORMAT_FLOAT)) < 0)
|
||||
{ fprintf (stderr, "cannot set sample format (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_rate_near (alsa_dev, hw_params, &samplerate, 0)) < 0)
|
||||
{ fprintf (stderr, "cannot set sample rate (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_channels (alsa_dev, hw_params, channels)) < 0)
|
||||
{ fprintf (stderr, "cannot set channel count (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_buffer_size_near (alsa_dev, hw_params, &alsa_buffer_frames)) < 0)
|
||||
{ fprintf (stderr, "cannot set buffer size (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_period_size_near (alsa_dev, hw_params, &alsa_period_size, 0)) < 0)
|
||||
{ fprintf (stderr, "cannot set period size (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params (alsa_dev, hw_params)) < 0)
|
||||
{ fprintf (stderr, "cannot set parameters (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
/* extra check: if we have only one period, this code won't work */
|
||||
snd_pcm_hw_params_get_period_size (hw_params, &alsa_period_size, 0) ;
|
||||
snd_pcm_hw_params_get_buffer_size (hw_params, &buffer_size) ;
|
||||
if (alsa_period_size == buffer_size)
|
||||
{ fprintf (stderr, "Can't use period equal to buffer size (%lu == %lu)", alsa_period_size, buffer_size) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
snd_pcm_hw_params_free (hw_params) ;
|
||||
|
||||
if ((err = snd_pcm_sw_params_malloc (&sw_params)) != 0)
|
||||
{ fprintf (stderr, "%s: snd_pcm_sw_params_malloc: %s", __func__, snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_sw_params_current (alsa_dev, sw_params)) != 0)
|
||||
{ fprintf (stderr, "%s: snd_pcm_sw_params_current: %s", __func__, snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
/* note: set start threshold to delay start until the ring buffer is full */
|
||||
snd_pcm_sw_params_current (alsa_dev, sw_params) ;
|
||||
if ((err = snd_pcm_sw_params_get_xfer_align (sw_params, &xfer_align)) < 0)
|
||||
{ fprintf (stderr, "cannot get xfer align (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
/* round up to closest transfer boundary */
|
||||
start_threshold = (buffer_size / xfer_align) * xfer_align ;
|
||||
if (start_threshold < 1)
|
||||
start_threshold = 1 ;
|
||||
if ((err = snd_pcm_sw_params_set_start_threshold (alsa_dev, sw_params, start_threshold)) < 0)
|
||||
{ fprintf (stderr, "cannot set start threshold (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_sw_params (alsa_dev, sw_params)) != 0)
|
||||
{ fprintf (stderr, "%s: snd_pcm_sw_params: %s", __func__, snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
snd_pcm_sw_params_free (sw_params) ;
|
||||
|
||||
snd_pcm_reset (alsa_dev) ;
|
||||
|
||||
catch_error :
|
||||
|
||||
if (err < 0 && alsa_dev != NULL)
|
||||
{ snd_pcm_close (alsa_dev) ;
|
||||
return NULL ;
|
||||
} ;
|
||||
|
||||
return alsa_dev ;
|
||||
} /* alsa_open */
|
||||
|
||||
static int
|
||||
alsa_write_float (snd_pcm_t *alsa_dev, float *data, int frames, int channels)
|
||||
{ static int epipe_count = 0 ;
|
||||
|
||||
snd_pcm_status_t *status ;
|
||||
int total = 0 ;
|
||||
int retval ;
|
||||
|
||||
if (epipe_count > 0)
|
||||
epipe_count -- ;
|
||||
|
||||
while (total < frames)
|
||||
{ retval = snd_pcm_writei (alsa_dev, data + total * channels, frames - total) ;
|
||||
|
||||
if (retval >= 0)
|
||||
{ total += retval ;
|
||||
if (total == frames)
|
||||
return total ;
|
||||
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
switch (retval)
|
||||
{ case -EAGAIN :
|
||||
puts ("alsa_write_float: EAGAIN") ;
|
||||
continue ;
|
||||
break ;
|
||||
|
||||
case -EPIPE :
|
||||
if (epipe_count > 0)
|
||||
{ printf ("alsa_write_float: EPIPE %d\n", epipe_count) ;
|
||||
if (epipe_count > 140)
|
||||
return retval ;
|
||||
} ;
|
||||
epipe_count += 100 ;
|
||||
|
||||
if (0)
|
||||
{ snd_pcm_status_alloca (&status) ;
|
||||
if ((retval = snd_pcm_status (alsa_dev, status)) < 0)
|
||||
fprintf (stderr, "alsa_out: xrun. can't determine length\n") ;
|
||||
else if (snd_pcm_status_get_state (status) == SND_PCM_STATE_XRUN)
|
||||
{ struct timeval now, diff, tstamp ;
|
||||
|
||||
gettimeofday (&now, 0) ;
|
||||
snd_pcm_status_get_trigger_tstamp (status, &tstamp) ;
|
||||
timersub (&now, &tstamp, &diff) ;
|
||||
|
||||
fprintf (stderr, "alsa_write_float xrun: of at least %.3f msecs. resetting stream\n",
|
||||
diff.tv_sec * 1000 + diff.tv_usec / 1000.0) ;
|
||||
}
|
||||
else
|
||||
fprintf (stderr, "alsa_write_float: xrun. can't determine length\n") ;
|
||||
} ;
|
||||
|
||||
snd_pcm_prepare (alsa_dev) ;
|
||||
break ;
|
||||
|
||||
case -EBADFD :
|
||||
fprintf (stderr, "alsa_write_float: Bad PCM state.n") ;
|
||||
return 0 ;
|
||||
break ;
|
||||
|
||||
case -ESTRPIPE :
|
||||
fprintf (stderr, "alsa_write_float: Suspend event.n") ;
|
||||
return 0 ;
|
||||
break ;
|
||||
|
||||
case -EIO :
|
||||
puts ("alsa_write_float: EIO") ;
|
||||
return 0 ;
|
||||
|
||||
default :
|
||||
fprintf (stderr, "alsa_write_float: retval = %d\n", retval) ;
|
||||
return 0 ;
|
||||
break ;
|
||||
} ; /* switch */
|
||||
} ; /* while */
|
||||
|
||||
return total ;
|
||||
} /* alsa_write_float */
|
||||
|
||||
#endif /* HAVE_ALSA_ASOUNDLIB_H */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
** Linux/OSS functions for playing a sound.
|
||||
*/
|
||||
|
||||
#if defined (__linux__)
|
||||
|
||||
static int linux_open_dsp_device (int channels, int srate) ;
|
||||
@ -390,15 +108,9 @@ linux_play (int argc, char *argv [])
|
||||
write (audio_device, buffer, readcount * sizeof (short)) ;
|
||||
} ;
|
||||
|
||||
if (ioctl (audio_device, SNDCTL_DSP_POST, 0) == -1)
|
||||
perror ("ioctl (SNDCTL_DSP_POST) ") ;
|
||||
|
||||
if (ioctl (audio_device, SNDCTL_DSP_SYNC, 0) == -1)
|
||||
perror ("ioctl (SNDCTL_DSP_SYNC) ") ;
|
||||
sf_close (sndfile) ;
|
||||
|
||||
close (audio_device) ;
|
||||
|
||||
sf_close (sndfile) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
@ -406,19 +118,19 @@ linux_play (int argc, char *argv [])
|
||||
|
||||
static int
|
||||
linux_open_dsp_device (int channels, int srate)
|
||||
{ int fd, stereo, fmt ;
|
||||
{ int fd, stereo, temp, error ;
|
||||
|
||||
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("linux_open_dsp_device : open ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
stereo = 0 ;
|
||||
if (ioctl (fd, SNDCTL_DSP_STEREO, &stereo) == -1)
|
||||
{ /* Fatal error */
|
||||
perror ("linux_open_dsp_device : stereo ") ;
|
||||
exit (1) ;
|
||||
perror("linux_open_dsp_device : stereo ") ;
|
||||
exit (1);
|
||||
} ;
|
||||
|
||||
if (ioctl (fd, SNDCTL_DSP_RESET, 0))
|
||||
@ -426,23 +138,23 @@ linux_open_dsp_device (int channels, int srate)
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
fmt = CPU_IS_BIG_ENDIAN ? AFMT_S16_BE : AFMT_S16_LE ;
|
||||
if (ioctl (fd, SOUND_PCM_SETFMT, &fmt) != 0)
|
||||
{ perror ("linux_open_dsp_device : set format ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
temp = 16 ;
|
||||
if ((error = ioctl (fd, SOUND_PCM_WRITE_BITS, &temp)) != 0)
|
||||
{ perror ("linux_open_dsp_device : bitwidth ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (ioctl (fd, SOUND_PCM_WRITE_CHANNELS, &channels) != 0)
|
||||
if ((error = ioctl (fd, SOUND_PCM_WRITE_CHANNELS, &channels)) != 0)
|
||||
{ perror ("linux_open_dsp_device : channels ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (ioctl (fd, SOUND_PCM_WRITE_RATE, &srate) != 0)
|
||||
if ((error = ioctl (fd, SOUND_PCM_WRITE_RATE, &srate)) != 0)
|
||||
{ perror ("linux_open_dsp_device : sample rate ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (ioctl (fd, SNDCTL_DSP_SYNC, 0) != 0)
|
||||
if ((error = ioctl (fd, SNDCTL_DSP_SYNC, 0)) != 0)
|
||||
{ perror ("linux_open_dsp_device : sync ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
@ -459,16 +171,15 @@ linux_open_dsp_device (int channels, int srate)
|
||||
#if (defined (__MACH__) && defined (__APPLE__)) /* MacOSX */
|
||||
|
||||
typedef struct
|
||||
{ AudioStreamBasicDescription format ;
|
||||
{ AudioStreamBasicDescription format;
|
||||
|
||||
UInt32 buf_size ;
|
||||
AudioDeviceID device ;
|
||||
UInt32 buf_size;
|
||||
AudioDeviceID device;
|
||||
|
||||
SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
|
||||
int fake_stereo ;
|
||||
int done_playing ;
|
||||
int done_playing ;
|
||||
} MacOSXAudioData ;
|
||||
|
||||
#include <math.h>
|
||||
@ -479,43 +190,31 @@ macosx_audio_out_callback (AudioDeviceID device, const AudioTimeStamp* current_t
|
||||
AudioBufferList* data_out, const AudioTimeStamp* time_out,
|
||||
void* client_data)
|
||||
{ MacOSXAudioData *audio_data ;
|
||||
int size, sample_count, read_count, k ;
|
||||
int size, sample_count, read_count ;
|
||||
float *buffer ;
|
||||
|
||||
/* Prevent compiler warnings. */
|
||||
device = device ;
|
||||
current_time = current_time ;
|
||||
data_in = data_in ;
|
||||
data_in = data _in ;
|
||||
time_in = time_in ;
|
||||
time_out = time_out ;
|
||||
|
||||
audio_data = (MacOSXAudioData*) client_data ;
|
||||
|
||||
size = data_out->mBuffers [0].mDataByteSize ;
|
||||
sample_count = size / sizeof (float) ;
|
||||
size = data_out->mBuffers[0].mDataByteSize ;
|
||||
sample_count = size / sizeof(float) ;
|
||||
|
||||
buffer = (float*) data_out->mBuffers [0].mData ;
|
||||
|
||||
if (audio_data->fake_stereo != 0)
|
||||
{ read_count = sf_read_float (audio_data->sndfile, buffer, sample_count / 2) ;
|
||||
|
||||
for (k = read_count - 1 ; k >= 0 ; k--)
|
||||
{ buffer [2 * k ] = buffer [k] ;
|
||||
buffer [2 * k + 1] = buffer [k] ;
|
||||
} ;
|
||||
read_count *= 2 ;
|
||||
}
|
||||
else
|
||||
read_count = sf_read_float (audio_data->sndfile, buffer, sample_count) ;
|
||||
|
||||
/* Fill the remainder with zeroes. */
|
||||
read_count = sf_read_float (audio_data->sndfile, buffer, sample_count) ;
|
||||
|
||||
if (read_count < sample_count)
|
||||
{ if (audio_data->fake_stereo == 0)
|
||||
memset (&(buffer [read_count]), 0, (sample_count - read_count) * sizeof (float)) ;
|
||||
{ memset (&(buffer [read_count]), 0, (sample_count - read_count) * sizeof (float)) ;
|
||||
/* Tell the main application to terminate. */
|
||||
audio_data->done_playing = SF_TRUE ;
|
||||
} ;
|
||||
|
||||
|
||||
return noErr ;
|
||||
} /* macosx_audio_out_callback */
|
||||
|
||||
@ -526,14 +225,13 @@ macosx_play (int argc, char *argv [])
|
||||
UInt32 count, buffer_size ;
|
||||
int k ;
|
||||
|
||||
audio_data.fake_stereo = 0 ;
|
||||
audio_data.device = kAudioDeviceUnknown ;
|
||||
|
||||
/* get the default output device for the HAL */
|
||||
count = sizeof (AudioDeviceID) ;
|
||||
if ((err = AudioHardwareGetProperty (kAudioHardwarePropertyDefaultOutputDevice,
|
||||
&count, (void *) &(audio_data.device))) != noErr)
|
||||
{ printf ("AudioHardwareGetProperty (kAudioDevicePropertyDefaultOutputDevice) failed.\n") ;
|
||||
{ printf ("AudioHardwareGetProperty failed.\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
@ -541,7 +239,7 @@ macosx_play (int argc, char *argv [])
|
||||
count = sizeof (UInt32) ;
|
||||
if ((err = AudioDeviceGetProperty (audio_data.device, 0, false, kAudioDevicePropertyBufferSize,
|
||||
&count, &buffer_size)) != noErr)
|
||||
{ printf ("AudioDeviceGetProperty (kAudioDevicePropertyBufferSize) failed.\n") ;
|
||||
{ printf ("AudioDeviceGetProperty (AudioDeviceGetProperty) failed.\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
@ -566,15 +264,10 @@ macosx_play (int argc, char *argv [])
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
|
||||
audio_data.format.mSampleRate = audio_data.sfinfo.samplerate ;
|
||||
|
||||
if (audio_data.sfinfo.channels == 1)
|
||||
{ audio_data.format.mChannelsPerFrame = 2 ;
|
||||
audio_data.fake_stereo = 1 ;
|
||||
}
|
||||
else
|
||||
audio_data.format.mChannelsPerFrame = audio_data.sfinfo.channels ;
|
||||
|
||||
|
||||
if ((err = AudioDeviceSetProperty (audio_data.device, NULL, 0, false, kAudioDevicePropertyStreamFormat,
|
||||
sizeof (AudioStreamBasicDescription), &(audio_data.format))) != noErr)
|
||||
{ printf ("AudioDeviceSetProperty (kAudioDevicePropertyStreamFormat) failed.\n") ;
|
||||
@ -586,7 +279,7 @@ macosx_play (int argc, char *argv [])
|
||||
return ;
|
||||
|
||||
/* Fire off the device. */
|
||||
if ((err = AudioDeviceAddIOProc (audio_data.device, macosx_audio_out_callback,
|
||||
if ((err = AudioDeviceAddIOProc (audio_data.device, macosx_audio_out_callback,
|
||||
(void *) &audio_data)) != noErr)
|
||||
{ printf ("AudioDeviceAddIOProc failed.\n") ;
|
||||
return ;
|
||||
@ -605,9 +298,9 @@ macosx_play (int argc, char *argv [])
|
||||
{ printf ("AudioDeviceStop failed.\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
|
||||
err = AudioDeviceRemoveIOProc (audio_data.device, macosx_audio_out_callback) ;
|
||||
if (err != noErr)
|
||||
if (err != noErr)
|
||||
{ printf ("AudioDeviceRemoveIOProc failed.\n") ;
|
||||
return ;
|
||||
} ;
|
||||
@ -629,33 +322,30 @@ macosx_play (int argc, char *argv [])
|
||||
** point to data instead of short*. It plain sucks!
|
||||
*/
|
||||
|
||||
#if (OS_IS_WIN32 == 1)
|
||||
#if (defined (_WIN32) || defined (WIN32))
|
||||
|
||||
#define WIN32_BUFFER_LEN (1<<15)
|
||||
|
||||
typedef struct
|
||||
{ HWAVEOUT hwave ;
|
||||
WAVEHDR whdr [2] ;
|
||||
{ HWAVEOUT hwave ;
|
||||
WAVEHDR whdr [2] ;
|
||||
|
||||
HANDLE Event ;
|
||||
|
||||
short buffer [WIN32_BUFFER_LEN / sizeof (short)] ;
|
||||
int current, bufferlen ;
|
||||
|
||||
CRITICAL_SECTION mutex ; /* to control access to BuffersInUSe */
|
||||
HANDLE Event ; /* signal that a buffer is free */
|
||||
SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
|
||||
short buffer [WIN32_BUFFER_LEN / sizeof (short)] ;
|
||||
int current, bufferlen ;
|
||||
int BuffersInUse ;
|
||||
|
||||
SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
|
||||
sf_count_t remaining ;
|
||||
sf_count_t remaining ;
|
||||
} Win32_Audio_Data ;
|
||||
|
||||
|
||||
static void
|
||||
win32_play_data (Win32_Audio_Data *audio_data)
|
||||
{ int thisread, readcount ;
|
||||
|
||||
/* fill a buffer if there is more data and we can read it sucessfully */
|
||||
|
||||
readcount = (audio_data->remaining > audio_data->bufferlen) ? audio_data->bufferlen : (int) audio_data->remaining ;
|
||||
|
||||
thisread = (int) sf_read_short (audio_data->sndfile, (short *) (audio_data->whdr [audio_data->current].lpData), readcount) ;
|
||||
@ -663,63 +353,48 @@ win32_play_data (Win32_Audio_Data *audio_data)
|
||||
audio_data->remaining -= thisread ;
|
||||
|
||||
if (thisread > 0)
|
||||
{ /* Fix buffer length if this is only a partial block. */
|
||||
if (thisread < audio_data->bufferlen)
|
||||
{ /* Fix buffer length is only a partial block. */
|
||||
if (thisread * SIGNED_SIZEOF (short) < audio_data->bufferlen)
|
||||
audio_data->whdr [audio_data->current].dwBufferLength = thisread * sizeof (short) ;
|
||||
|
||||
/* Queue the WAVEHDR */
|
||||
waveOutWrite (audio_data->hwave, (LPWAVEHDR) &(audio_data->whdr [audio_data->current]), sizeof (WAVEHDR)) ;
|
||||
}
|
||||
else
|
||||
{ /* Stop playback */
|
||||
waveOutPause (audio_data->hwave) ;
|
||||
|
||||
/* count another buffer in use */
|
||||
EnterCriticalSection (&audio_data->mutex) ;
|
||||
audio_data->BuffersInUse ++ ;
|
||||
LeaveCriticalSection (&audio_data->mutex) ;
|
||||
|
||||
/* use the other buffer next time */
|
||||
audio_data->current = (audio_data->current + 1) % 2 ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* win32_play_data */
|
||||
|
||||
static void CALLBACK
|
||||
win32_audio_out_callback (HWAVEOUT hwave, UINT msg, DWORD data, DWORD param1, DWORD param2)
|
||||
{ Win32_Audio_Data *audio_data ;
|
||||
|
||||
/* Prevent compiler warnings. */
|
||||
hwave = hwave ;
|
||||
param1 = param2 ;
|
||||
|
||||
if (data == 0)
|
||||
return ;
|
||||
|
||||
/*
|
||||
** I consider this technique of passing a pointer via an integer as
|
||||
** fundamentally broken but thats the way microsoft has defined the
|
||||
** interface.
|
||||
*/
|
||||
audio_data = (Win32_Audio_Data*) data ;
|
||||
|
||||
/* let main loop know a buffer is free */
|
||||
if (msg == MM_WOM_DONE)
|
||||
{ EnterCriticalSection (&audio_data->mutex) ;
|
||||
audio_data->BuffersInUse -- ;
|
||||
LeaveCriticalSection (&audio_data->mutex) ;
|
||||
SetEvent (audio_data->Event) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* win32_audio_out_callback */
|
||||
audio_data->current = (audio_data->current + 1) % 2 ;
|
||||
|
||||
/* This is needed for earlier versions of the M$ development tools. */
|
||||
#ifndef DWORD_PTR
|
||||
#define DWORD_PTR DWORD
|
||||
#endif
|
||||
} /* win32_play_data */
|
||||
|
||||
static DWORD CALLBACK
|
||||
win32_audio_out_callback (HWAVEOUT hwave, UINT msg, DWORD data, DWORD param1, DWORD param2)
|
||||
{ Win32_Audio_Data *audio_data ;
|
||||
|
||||
if (! data)
|
||||
return 1 ;
|
||||
|
||||
/*
|
||||
** I consider this technique of passing a pointer via an integer as
|
||||
** fundamentally broken but thats the way microsoft has defined the
|
||||
** interface.
|
||||
*/
|
||||
audio_data = (Win32_Audio_Data*) data ;
|
||||
|
||||
if (msg == MM_WOM_DONE)
|
||||
win32_play_data (audio_data) ;
|
||||
|
||||
return 0 ;
|
||||
} /* win32_audio_out_callback */
|
||||
|
||||
static void
|
||||
win32_play (int argc, char *argv [])
|
||||
{ Win32_Audio_Data audio_data ;
|
||||
|
||||
|
||||
WAVEFORMATEX wf ;
|
||||
int k, error ;
|
||||
|
||||
@ -733,81 +408,73 @@ win32_play (int argc, char *argv [])
|
||||
{ puts (sf_strerror (NULL)) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
audio_data.remaining = audio_data.sfinfo.frames * audio_data.sfinfo.channels ;
|
||||
|
||||
audio_data.remaining = audio_data.sfinfo.frames ;
|
||||
audio_data.current = 0 ;
|
||||
|
||||
InitializeCriticalSection (&audio_data.mutex) ;
|
||||
|
||||
audio_data.Event = CreateEvent (0, FALSE, FALSE, 0) ;
|
||||
|
||||
|
||||
wf.nChannels = audio_data.sfinfo.channels ;
|
||||
wf.wFormatTag = WAVE_FORMAT_PCM ;
|
||||
wf.cbSize = 0 ;
|
||||
wf.wBitsPerSample = 16 ;
|
||||
|
||||
wf.nSamplesPerSec = audio_data.sfinfo.samplerate ;
|
||||
|
||||
|
||||
wf.nBlockAlign = audio_data.sfinfo.channels * sizeof (short) ;
|
||||
|
||||
|
||||
wf.nAvgBytesPerSec = wf.nBlockAlign * wf.nSamplesPerSec ;
|
||||
|
||||
error = waveOutOpen (&(audio_data.hwave), WAVE_MAPPER, &wf, (DWORD_PTR) win32_audio_out_callback,
|
||||
(DWORD_PTR) &audio_data, CALLBACK_FUNCTION) ;
|
||||
error = waveOutOpen (&(audio_data.hwave), WAVE_MAPPER, &wf, (DWORD) win32_audio_out_callback,
|
||||
(DWORD) &audio_data, CALLBACK_FUNCTION) ;
|
||||
if (error)
|
||||
{ puts ("waveOutOpen failed.") ;
|
||||
audio_data.hwave = 0 ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
waveOutPause (audio_data.hwave) ;
|
||||
|
||||
audio_data.whdr [0].lpData = (char*) audio_data.buffer ;
|
||||
audio_data.whdr [1].lpData = ((char*) audio_data.buffer) + sizeof (audio_data.buffer) / 2 ;
|
||||
|
||||
|
||||
audio_data.whdr [0].dwBufferLength = sizeof (audio_data.buffer) / 2 ;
|
||||
audio_data.whdr [1].dwBufferLength = sizeof (audio_data.buffer) / 2 ;
|
||||
|
||||
audio_data.whdr [0].dwFlags = 0 ;
|
||||
audio_data.whdr [1].dwFlags = 0 ;
|
||||
|
||||
/* length of each audio buffer in samples */
|
||||
audio_data.bufferlen = sizeof (audio_data.buffer) / 2 / sizeof (short) ;
|
||||
|
||||
audio_data.bufferlen = sizeof (audio_data.buffer) / 2 / sizeof (short) ;
|
||||
|
||||
/* Prepare the WAVEHDRs */
|
||||
if ((error = waveOutPrepareHeader (audio_data.hwave, &(audio_data.whdr [0]), sizeof (WAVEHDR))))
|
||||
{ printf ("waveOutPrepareHeader [0] failed : %08X\n", error) ;
|
||||
{ printf("waveOutPrepareHeader [0] failed : %08X\n", error) ;
|
||||
waveOutClose (audio_data.hwave) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if ((error = waveOutPrepareHeader (audio_data.hwave, &(audio_data.whdr [1]), sizeof (WAVEHDR))))
|
||||
{ printf ("waveOutPrepareHeader [1] failed : %08X\n", error) ;
|
||||
waveOutUnprepareHeader (audio_data.hwave, &(audio_data.whdr [0]), sizeof (WAVEHDR)) ;
|
||||
{ printf("waveOutPrepareHeader [1] failed : %08X\n", error) ;
|
||||
waveOutUnprepareHeader (audio_data.hwave, &(audio_data.whdr [0]), sizeof(WAVEHDR)) ;
|
||||
waveOutClose (audio_data.hwave) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
/* Fill up both buffers with audio data */
|
||||
audio_data.BuffersInUse = 0 ;
|
||||
waveOutRestart (audio_data.hwave) ;
|
||||
|
||||
/* Need to call this twice to queue up enough audio. */
|
||||
win32_play_data (&audio_data) ;
|
||||
win32_play_data (&audio_data) ;
|
||||
|
||||
/* loop until both buffers are released */
|
||||
while (audio_data.BuffersInUse > 0)
|
||||
{
|
||||
/* wait for buffer to be released */
|
||||
WaitForSingleObject (audio_data.Event, INFINITE) ;
|
||||
/* Wait for playback to finish. My callback notifies me when all wave data has been played */
|
||||
WaitForSingleObject (audio_data.Event, INFINITE);
|
||||
|
||||
/* refill the buffer if there is more data to play */
|
||||
win32_play_data (&audio_data) ;
|
||||
} ;
|
||||
waveOutPause (audio_data.hwave) ;
|
||||
waveOutReset (audio_data.hwave);
|
||||
|
||||
waveOutUnprepareHeader (audio_data.hwave, &(audio_data.whdr [0]), sizeof (WAVEHDR)) ;
|
||||
waveOutUnprepareHeader (audio_data.hwave, &(audio_data.whdr [1]), sizeof (WAVEHDR)) ;
|
||||
waveOutUnprepareHeader (audio_data.hwave, &(audio_data.whdr [0]), sizeof(WAVEHDR)) ;
|
||||
waveOutUnprepareHeader (audio_data.hwave, &(audio_data.whdr [1]), sizeof(WAVEHDR)) ;
|
||||
|
||||
waveOutClose (audio_data.hwave) ;
|
||||
waveOutClose (audio_data.hwave) ;
|
||||
audio_data.hwave = 0 ;
|
||||
|
||||
DeleteCriticalSection (&audio_data.mutex) ;
|
||||
|
||||
sf_close (audio_data.sndfile) ;
|
||||
} ;
|
||||
|
||||
@ -830,7 +497,7 @@ solaris_play (int argc, char *argv [])
|
||||
unsigned long delay_time ;
|
||||
long k, start_count, output_count, write_count, read_count ;
|
||||
int audio_fd, error, done ;
|
||||
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
{ printf ("Playing %s\n", argv [k]) ;
|
||||
if (! (sndfile = sf_open (argv [k], SFM_READ, &sfinfo)))
|
||||
@ -848,25 +515,25 @@ solaris_play (int argc, char *argv [])
|
||||
{ perror ("open (/dev/audio) failed") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
|
||||
/* Retrive standard values. */
|
||||
AUDIO_INITINFO (&audio_info) ;
|
||||
|
||||
|
||||
audio_info.play.sample_rate = sfinfo.samplerate ;
|
||||
audio_info.play.channels = sfinfo.channels ;
|
||||
audio_info.play.precision = 16 ;
|
||||
audio_info.play.encoding = AUDIO_ENCODING_LINEAR ;
|
||||
audio_info.play.gain = AUDIO_MAX_GAIN ;
|
||||
audio_info.play.balance = AUDIO_MID_BALANCE ;
|
||||
|
||||
|
||||
if ((error = ioctl (audio_fd, AUDIO_SETINFO, &audio_info)))
|
||||
{ perror ("ioctl (AUDIO_SETINFO) failed") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
|
||||
/* Delay time equal to 1/4 of a buffer in microseconds. */
|
||||
delay_time = (BUFFER_LEN * 1000000) / (audio_info.play.sample_rate * 4) ;
|
||||
|
||||
|
||||
done = 0 ;
|
||||
while (! done)
|
||||
{ read_count = sf_read_short (sndfile, buffer, BUFFER_LEN) ;
|
||||
@ -878,7 +545,7 @@ solaris_play (int argc, char *argv [])
|
||||
|
||||
start_count = 0 ;
|
||||
output_count = BUFFER_LEN * sizeof (short) ;
|
||||
|
||||
|
||||
while (output_count > 0)
|
||||
{ /* write as much data as possible */
|
||||
write_count = write (audio_fd, &(buffer [start_count]), output_count) ;
|
||||
@ -892,7 +559,7 @@ solaris_play (int argc, char *argv [])
|
||||
} ;
|
||||
} ; /* while (outpur_count > 0) */
|
||||
} ; /* while (! done) */
|
||||
|
||||
|
||||
close (audio_fd) ;
|
||||
} ;
|
||||
|
||||
@ -909,9 +576,9 @@ int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
if (argc < 2)
|
||||
{
|
||||
{
|
||||
printf ("\nUsage : %s <input sound file>\n\n", argv [0]) ;
|
||||
#if (OS_IS_WIN32 == 1)
|
||||
#if (defined (_WIN32) || defined (WIN32))
|
||||
printf ("This is a Unix style command line application which\n"
|
||||
"should be run in a MSDOS box or Command Shell window.\n\n") ;
|
||||
printf ("Sleeping for 5 seconds before exiting.\n\n") ;
|
||||
@ -927,25 +594,26 @@ main (int argc, char *argv [])
|
||||
} ;
|
||||
|
||||
#if defined (__linux__)
|
||||
#if HAVE_ALSA_ASOUNDLIB_H
|
||||
#if (defined (HAVE_ALSA) && HAVE_ALSA)
|
||||
if (access ("/proc/asound/cards", R_OK) == 0)
|
||||
alsa_play (argc, argv) ;
|
||||
else
|
||||
#endif
|
||||
#else
|
||||
linux_play (argc, argv) ;
|
||||
#endif
|
||||
#elif (defined (__MACH__) && defined (__APPLE__))
|
||||
macosx_play (argc, argv) ;
|
||||
#elif (defined (sun) && defined (unix))
|
||||
solaris_play (argc, argv) ;
|
||||
#elif (OS_IS_WIN32 == 1)
|
||||
#elif (defined (_WIN32) || defined (WIN32))
|
||||
win32_play (argc, argv) ;
|
||||
#elif defined (__BEOS__)
|
||||
printf ("This program cannot be compiled on BeOS.\n") ;
|
||||
printf ("Instead, compile the file sfplay_beos.cpp.\n") ;
|
||||
return 1 ;
|
||||
#else
|
||||
puts ("*** Playing sound not yet supported on this platform.") ;
|
||||
puts ("*** Please feel free to submit a patch.") ;
|
||||
#warning "*** Playing sound not yet supported on this platform."
|
||||
#warning "*** Please feel free to submit a patch."
|
||||
printf ("Error : Playing sound not yet supported on this platform.\n") ;
|
||||
return 1 ;
|
||||
#endif
|
||||
|
||||
@ -953,7 +621,7 @@ main (int argc, char *argv [])
|
||||
} /* main */
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 8fc4110d-6cec-4e03-91df-0f384cabedac
|
||||
|
@ -9,8 +9,8 @@ Version: %{version}
|
||||
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/
|
||||
Source: http://www.zip.com.au/~erikd/libsndfile/libsndfile-%{version}.tar.gz
|
||||
URL: http://www.zip.com.au/~erikd/libsndfile/
|
||||
BuildRoot: /var/tmp/%{name}-%{version}
|
||||
|
||||
%description
|
||||
@ -47,7 +47,6 @@ if [ -d $RPM_BUILD_ROOT ]; then rm -rf $RPM_BUILD_ROOT; fi
|
||||
%{_bindir}/*
|
||||
%{_mandir}/man1/*
|
||||
%{_datadir}/octave/site/m/*
|
||||
%{_defaultdocdir}/libsndfile1-dev/html/*
|
||||
|
||||
%files devel
|
||||
%defattr(-,root,root)
|
||||
@ -58,11 +57,9 @@ if [ -d $RPM_BUILD_ROOT ]; then rm -rf $RPM_BUILD_ROOT; fi
|
||||
%{_libdir}/pkgconfig/sndfile.pc
|
||||
|
||||
%changelog
|
||||
* Sun May 15 2005 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
- Add html files to the files section.
|
||||
* Tue Sep 16 2003 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
* Tue Sep 16 2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
- Apply corrections from Andrew Schultz.
|
||||
* Mon Oct 21 2002 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
* Mon Oct 21 2002 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
- Force installation of sndfile.pc file.
|
||||
* Thu Jul 6 2000 Josh Green <jgreen@users.sourceforge.net>
|
||||
- Created libsndfile.spec.in
|
||||
|
@ -469,7 +469,7 @@ 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"):
|
||||
if os.system ("./reconf && ./configure --disable-shared --disable-gcc-opt && make check"):
|
||||
os.system ('PS1="FIX > " bash --norc')
|
||||
sys.exit (1)
|
||||
|
||||
@ -480,7 +480,6 @@ if os.system ("make distcheck"):
|
||||
|
||||
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)
|
||||
|
||||
|
@ -9,7 +9,7 @@ sndfile-convert \- convert a sound files from one format to another
|
||||
.RI --help
|
||||
.SH DESCRIPTION
|
||||
sndfile-convert converts sound files from one format to another using
|
||||
libsndfile (http://www.mega-nerd.com/libsndfile/) to read and write
|
||||
libsndfile (http://www.zip.com.au/~erikd/libsndfile/) to read and write
|
||||
the data.
|
||||
.LP
|
||||
The format of the output file is determined by the filename extension
|
||||
|
@ -7,7 +7,7 @@ sndfile-info \- display information about a sound file
|
||||
.SH DESCRIPTION
|
||||
sndfile-info will display basic information about a sound file such as
|
||||
its format, its sample rate, and the number of channels. This information
|
||||
is obtained using libsndfile (http://www.mega-nerd.com/libsndfile/).
|
||||
is obtained using libsndfile (http://www.zip.com.au/~erikd/libsndfile/).
|
||||
.SH AUTHOR
|
||||
This manual page was originally written by Joshua Haberman
|
||||
<joshua@debian.org>, for the Debian GNU/Linux system (but may be used by
|
||||
|
@ -20,13 +20,12 @@ sndfile-play \- play a sound file
|
||||
.SH DESCRIPTION
|
||||
sndfile-play plays the specified sound file using :
|
||||
.EX
|
||||
ALSA on Linux
|
||||
/dev/dsp on systems supporting OSS (including Linux)
|
||||
/dev/audio on Sun Solaris
|
||||
CoreAudio on Apple MacOSX
|
||||
waveOut on Microsoft Win32
|
||||
.EE
|
||||
sndfile-play uses libsndfile (http://www.mega-nerd.com/libsndfile/)
|
||||
sndfile-play uses libsndfile (http://www.zip.com.au/~erikd/libsndfile/)
|
||||
to read the file.
|
||||
.SH AUTHOR
|
||||
This manual page was originally written by Joshua Haberman
|
||||
|
17
mntest/Makefile
Normal file
17
mntest/Makefile
Normal file
@ -0,0 +1,17 @@
|
||||
TARGETS =
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -W -Wall
|
||||
|
||||
all : $(TARGETS)
|
||||
|
||||
|
||||
|
||||
check : $(TARGETS)
|
||||
@echo "Running tests"
|
||||
|
||||
# Do not edit or modify anything in this comment block.
|
||||
# The arch-tag line is a file identity tag for the GNU Arch
|
||||
# revision control system.
|
||||
#
|
||||
# arch-tag: 8d3eaa9f-ac36-44f4-9ea2-86e2c24e6b5c
|
41
reconf
Normal file
41
reconf
Normal file
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/make -f
|
||||
|
||||
Makefile.am: configure
|
||||
automake --copy --add-missing
|
||||
|
||||
configure: configure.ac src/config.h.in libtool ltmain.sh
|
||||
autoconf
|
||||
|
||||
src/config.h.in: configure.ac libtool
|
||||
autoheader
|
||||
|
||||
libtool ltmain.sh: aclocal.m4
|
||||
libtoolize --copy --force
|
||||
|
||||
aclocal.m4: acinclude.m4
|
||||
aclocal
|
||||
|
||||
acinclude.m4:
|
||||
@echo "acinclude.m4"
|
||||
@if [ -d $(HOME)/Proj/M4 ] ; then \
|
||||
cat $(HOME)/Proj/M4/extra_largefile.m4 >acinclude.m4.new ; \
|
||||
cat $(HOME)/Proj/M4/endian.m4 >>acinclude.m4.new ; \
|
||||
cat $(HOME)/Proj/M4/lrint.m4 >>acinclude.m4.new ; \
|
||||
cat $(HOME)/Proj/M4/lrintf.m4 >>acinclude.m4.new ; \
|
||||
cat $(HOME)/Proj/M4/llrint.m4 >>acinclude.m4.new ; \
|
||||
cat $(HOME)/Proj/M4/clip_mode.m4 >>acinclude.m4.new ; \
|
||||
mv -f acinclude.m4.new acinclude.m4 ; \
|
||||
else \
|
||||
touch acinclude.m4 ; \
|
||||
fi
|
||||
|
||||
clean:
|
||||
rm -f libtool ltmain.sh aclocal.m4 Makefile.in src/config.h.in config.cache
|
||||
|
||||
|
||||
# Do not edit or modify anything in this comment block.
|
||||
# The arch-tag line is a file identity tag for the GNU Arch
|
||||
# revision control system.
|
||||
#
|
||||
# arch-tag: 2b02bfd0-d5ed-489b-a554-2bf36903cca9
|
||||
|
6
run-mntest
Normal file
6
run-mntest
Normal file
@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
(cd src ; make ) && \
|
||||
(cd examples ; make sndfile-convert sndfile-info ) && \
|
||||
(cd mntest ; make check )
|
||||
|
@ -4,7 +4,7 @@ libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: sndfile
|
||||
Description: A library for reading and writing audio files
|
||||
Description: A library for reading and writing audio files.
|
||||
Requires:
|
||||
Version: @VERSION@
|
||||
Libs: -L${libdir} -lsndfile
|
||||
|
@ -1,15 +1,15 @@
|
||||
2001-06-05 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
2001-06-05 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
|
||||
* g72x.c
|
||||
Added {} in function update () to prevent 'ambiguous else' warning messages.
|
||||
|
||||
2000-07-14 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
2000-07-14 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
|
||||
* g72x.c
|
||||
Modified g72x_init_state () to fit in with the new structure of the code.
|
||||
Implemented g72x_encode_block () and g72x_decode_block ().
|
||||
|
||||
2000-07-12 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
2000-07-12 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
|
||||
* g72x.h
|
||||
Moved nearly all definitions and function prototypes from this file have been
|
||||
@ -24,7 +24,7 @@
|
||||
Changed struct g72x_state to a typedef struct { .. } G72x_PRIVATE.
|
||||
Added fields to G72x_PRIVATE required for working on blocks of samples.
|
||||
|
||||
2000-06-07 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
2000-06-07 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
|
||||
* g72x.c
|
||||
Fixed all compiler warnings.
|
||||
|
@ -5,7 +5,7 @@ EXTRA_DIST = README README.original ChangeLog
|
||||
noinst_HEADERS = g72x.h g72x_priv.h
|
||||
noinst_LTLIBRARIES = libg72x.la
|
||||
|
||||
noinst_PROGRAMS = g72x_test$(EXEEXT)
|
||||
noinst_PROGRAMS = g72x_test
|
||||
|
||||
CFILES = g72x.c g721.c g723_16.c g723_24.c g723_40.c
|
||||
|
||||
|
248
src/G72x/g72x.c
248
src/G72x/g72x.c
@ -29,7 +29,7 @@
|
||||
*
|
||||
* Common routines for G.721 and G.723 conversions.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -37,12 +37,8 @@
|
||||
#include "g72x.h"
|
||||
#include "g72x_priv.h"
|
||||
|
||||
static G72x_STATE * g72x_state_new (void) ;
|
||||
static int unpack_bytes (int bits, int blocksize, const unsigned char * block, short * samples) ;
|
||||
static int pack_bytes (int bits, const short * samples, unsigned char * block) ;
|
||||
|
||||
static
|
||||
short power2 [15] =
|
||||
static
|
||||
short power2 [15] =
|
||||
{ 1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80,
|
||||
0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000
|
||||
} ;
|
||||
@ -55,7 +51,7 @@ short power2 [15] =
|
||||
*
|
||||
* Using linear search for simple coding.
|
||||
*/
|
||||
static
|
||||
static
|
||||
int quan (int val, short *table, int size)
|
||||
{
|
||||
int i;
|
||||
@ -72,7 +68,7 @@ int quan (int val, short *table, int size)
|
||||
* returns the integer product of the 14-bit integer "an" and
|
||||
* "floating point" representation (4-bit exponent, 6-bit mantessa) "srn".
|
||||
*/
|
||||
static
|
||||
static
|
||||
int fmult (int an, int srn)
|
||||
{
|
||||
short anmag, anexp, anmant;
|
||||
@ -87,23 +83,19 @@ int fmult (int an, int srn)
|
||||
|
||||
/*
|
||||
** The original was :
|
||||
** wanmant = (anmant * (srn & 0x3F) + 0x30) >> 4 ;
|
||||
** wanmant = (anmant * (srn & 0x37) + 0x30) >> 4 ;
|
||||
** but could see no valid reason for the + 0x30.
|
||||
** Removed it and it improved the SNR of the codec.
|
||||
*/
|
||||
|
||||
wanmant = (anmant * (srn & 0x3F)) >> 4 ;
|
||||
|
||||
wanmant = (anmant * (srn & 0x37)) >> 4 ;
|
||||
|
||||
retval = (wanexp >= 0) ? ((wanmant << wanexp) & 0x7FFF) :
|
||||
(wanmant >> -wanexp);
|
||||
|
||||
return (((an ^ srn) < 0) ? -retval : retval);
|
||||
}
|
||||
|
||||
static G72x_STATE * g72x_state_new (void)
|
||||
{ return calloc (1, sizeof (G72x_STATE)) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* private_init_state()
|
||||
*
|
||||
@ -132,134 +124,171 @@ void private_init_state (G72x_STATE *state_ptr)
|
||||
state_ptr->td = 0;
|
||||
} /* private_init_state */
|
||||
|
||||
struct g72x_state * g72x_reader_init (int codec, int *blocksize, int *samplesperblock)
|
||||
int g72x_reader_init (G72x_DATA *data, int codec)
|
||||
{ G72x_STATE *pstate ;
|
||||
|
||||
if ((pstate = g72x_state_new ()) == NULL)
|
||||
return NULL ;
|
||||
if (sizeof (data->private) < sizeof (G72x_STATE))
|
||||
{ /* This is for safety only. */
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
memset (data, 0, sizeof (G72x_DATA)) ;
|
||||
|
||||
pstate = (G72x_STATE*) data->private ;
|
||||
private_init_state (pstate) ;
|
||||
|
||||
|
||||
pstate->encoder = NULL ;
|
||||
|
||||
|
||||
switch (codec)
|
||||
{ case G723_16_BITS_PER_SAMPLE : /* 2 bits per sample. */
|
||||
pstate->decoder = g723_16_decoder ;
|
||||
*blocksize = G723_16_BYTES_PER_BLOCK ;
|
||||
*samplesperblock = G723_16_SAMPLES_PER_BLOCK ;
|
||||
data->blocksize = G723_16_BYTES_PER_BLOCK ;
|
||||
data->samplesperblock = G723_16_SAMPLES_PER_BLOCK ;
|
||||
pstate->codec_bits = 2 ;
|
||||
pstate->blocksize = G723_16_BYTES_PER_BLOCK ;
|
||||
pstate->samplesperblock = G723_16_SAMPLES_PER_BLOCK ;
|
||||
break ;
|
||||
|
||||
case G723_24_BITS_PER_SAMPLE : /* 3 bits per sample. */
|
||||
|
||||
case G723_24_BITS_PER_SAMPLE : /* 3 bits per sample. */
|
||||
pstate->decoder = g723_24_decoder ;
|
||||
*blocksize = G723_24_BYTES_PER_BLOCK ;
|
||||
*samplesperblock = G723_24_SAMPLES_PER_BLOCK ;
|
||||
data->blocksize = G723_24_BYTES_PER_BLOCK ;
|
||||
data->samplesperblock = G723_24_SAMPLES_PER_BLOCK ;
|
||||
pstate->codec_bits = 3 ;
|
||||
pstate->blocksize = G723_24_BYTES_PER_BLOCK ;
|
||||
pstate->samplesperblock = G723_24_SAMPLES_PER_BLOCK ;
|
||||
break ;
|
||||
|
||||
|
||||
case G721_32_BITS_PER_SAMPLE : /* 4 bits per sample. */
|
||||
pstate->decoder = g721_decoder ;
|
||||
*blocksize = G721_32_BYTES_PER_BLOCK ;
|
||||
*samplesperblock = G721_32_SAMPLES_PER_BLOCK ;
|
||||
data->blocksize = G721_32_BYTES_PER_BLOCK ;
|
||||
data->samplesperblock = G721_32_SAMPLES_PER_BLOCK ;
|
||||
pstate->codec_bits = 4 ;
|
||||
pstate->blocksize = G721_32_BYTES_PER_BLOCK ;
|
||||
pstate->samplesperblock = G721_32_SAMPLES_PER_BLOCK ;
|
||||
break ;
|
||||
|
||||
|
||||
case G721_40_BITS_PER_SAMPLE : /* 5 bits per sample. */
|
||||
pstate->decoder = g723_40_decoder ;
|
||||
*blocksize = G721_40_BYTES_PER_BLOCK ;
|
||||
*samplesperblock = G721_40_SAMPLES_PER_BLOCK ;
|
||||
data->blocksize = G721_40_BYTES_PER_BLOCK ;
|
||||
data->samplesperblock = G721_40_SAMPLES_PER_BLOCK ;
|
||||
pstate->codec_bits = 5 ;
|
||||
pstate->blocksize = G721_40_BYTES_PER_BLOCK ;
|
||||
pstate->samplesperblock = G721_40_SAMPLES_PER_BLOCK ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
free (pstate) ;
|
||||
return NULL ;
|
||||
|
||||
default : return 1 ;
|
||||
} ;
|
||||
|
||||
return pstate ;
|
||||
return 0 ;
|
||||
} /* g72x_reader_init */
|
||||
|
||||
struct g72x_state * g72x_writer_init (int codec, int *blocksize, int *samplesperblock)
|
||||
int g72x_writer_init (G72x_DATA *data, int codec)
|
||||
{ G72x_STATE *pstate ;
|
||||
|
||||
if ((pstate = g72x_state_new ()) == NULL)
|
||||
return NULL ;
|
||||
if (sizeof (data->private) < sizeof (G72x_STATE))
|
||||
{ /* This is for safety only. Gets optimised out. */
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
memset (data, 0, sizeof (G72x_DATA)) ;
|
||||
|
||||
pstate = (G72x_STATE*) data->private ;
|
||||
private_init_state (pstate) ;
|
||||
|
||||
pstate->decoder = NULL ;
|
||||
|
||||
|
||||
switch (codec)
|
||||
{ case G723_16_BITS_PER_SAMPLE : /* 2 bits per sample. */
|
||||
pstate->encoder = g723_16_encoder ;
|
||||
*blocksize = G723_16_BYTES_PER_BLOCK ;
|
||||
*samplesperblock = G723_16_SAMPLES_PER_BLOCK ;
|
||||
data->blocksize = G723_16_BYTES_PER_BLOCK ;
|
||||
data->samplesperblock = G723_16_SAMPLES_PER_BLOCK ;
|
||||
pstate->codec_bits = 2 ;
|
||||
pstate->blocksize = G723_16_BYTES_PER_BLOCK ;
|
||||
pstate->samplesperblock = G723_16_SAMPLES_PER_BLOCK ;
|
||||
break ;
|
||||
|
||||
case G723_24_BITS_PER_SAMPLE : /* 3 bits per sample. */
|
||||
|
||||
case G723_24_BITS_PER_SAMPLE : /* 3 bits per sample. */
|
||||
pstate->encoder = g723_24_encoder ;
|
||||
*blocksize = G723_24_BYTES_PER_BLOCK ;
|
||||
*samplesperblock = G723_24_SAMPLES_PER_BLOCK ;
|
||||
data->blocksize = G723_24_BYTES_PER_BLOCK ;
|
||||
data->samplesperblock = G723_24_SAMPLES_PER_BLOCK ;
|
||||
pstate->codec_bits = 3 ;
|
||||
pstate->blocksize = G723_24_BYTES_PER_BLOCK ;
|
||||
pstate->samplesperblock = G723_24_SAMPLES_PER_BLOCK ;
|
||||
break ;
|
||||
|
||||
|
||||
case G721_32_BITS_PER_SAMPLE : /* 4 bits per sample. */
|
||||
pstate->encoder = g721_encoder ;
|
||||
*blocksize = G721_32_BYTES_PER_BLOCK ;
|
||||
*samplesperblock = G721_32_SAMPLES_PER_BLOCK ;
|
||||
data->blocksize = G721_32_BYTES_PER_BLOCK ;
|
||||
data->samplesperblock = G721_32_SAMPLES_PER_BLOCK ;
|
||||
pstate->codec_bits = 4 ;
|
||||
pstate->blocksize = G721_32_BYTES_PER_BLOCK ;
|
||||
pstate->samplesperblock = G721_32_SAMPLES_PER_BLOCK ;
|
||||
break ;
|
||||
|
||||
|
||||
case G721_40_BITS_PER_SAMPLE : /* 5 bits per sample. */
|
||||
pstate->encoder = g723_40_encoder ;
|
||||
*blocksize = G721_40_BYTES_PER_BLOCK ;
|
||||
*samplesperblock = G721_40_SAMPLES_PER_BLOCK ;
|
||||
data->blocksize = G721_40_BYTES_PER_BLOCK ;
|
||||
data->samplesperblock = G721_40_SAMPLES_PER_BLOCK ;
|
||||
pstate->codec_bits = 5 ;
|
||||
pstate->blocksize = G721_40_BYTES_PER_BLOCK ;
|
||||
pstate->samplesperblock = G721_40_SAMPLES_PER_BLOCK ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
free (pstate) ;
|
||||
return NULL ;
|
||||
|
||||
default : return 1 ;
|
||||
} ;
|
||||
|
||||
return pstate ;
|
||||
return 0 ;
|
||||
} /* g72x_writer_init */
|
||||
|
||||
int g72x_decode_block (G72x_STATE *pstate, const unsigned char *block, short *samples)
|
||||
{ int k, count ;
|
||||
int unpack_bytes (G72x_DATA *data, int bits)
|
||||
{ unsigned int in_buffer = 0 ;
|
||||
unsigned char in_byte ;
|
||||
int k, in_bits = 0, bindex = 0 ;
|
||||
|
||||
for (k = 0 ; bindex <= data->blocksize && k < G72x_BLOCK_SIZE ; k++)
|
||||
{ if (in_bits < bits)
|
||||
{ in_byte = data->block [bindex++] ;
|
||||
|
||||
count = unpack_bytes (pstate->codec_bits, pstate->blocksize, block, samples) ;
|
||||
in_buffer |= (in_byte << in_bits);
|
||||
in_bits += 8;
|
||||
}
|
||||
data->samples [k] = in_buffer & ((1 << bits) - 1);
|
||||
in_buffer >>= bits;
|
||||
in_bits -= bits;
|
||||
} ;
|
||||
|
||||
return k ;
|
||||
} /* unpack_bytes */
|
||||
|
||||
int g72x_decode_block (G72x_DATA *data)
|
||||
{ G72x_STATE *pstate ;
|
||||
int k, count ;
|
||||
|
||||
pstate = (G72x_STATE*) data->private ;
|
||||
|
||||
count = unpack_bytes (data, pstate->codec_bits) ;
|
||||
|
||||
for (k = 0 ; k < count ; k++)
|
||||
samples [k] = pstate->decoder (samples [k], pstate) ;
|
||||
|
||||
data->samples [k] = pstate->decoder (data->samples [k], pstate) ;
|
||||
|
||||
return 0 ;
|
||||
} /* g72x_decode_block */
|
||||
|
||||
int g72x_encode_block (G72x_STATE *pstate, short *samples, unsigned char *block)
|
||||
{ int k, count ;
|
||||
int pack_bytes (G72x_DATA *data, int bits)
|
||||
{
|
||||
unsigned int out_buffer = 0 ;
|
||||
int k, bindex = 0, out_bits = 0 ;
|
||||
unsigned char out_byte ;
|
||||
|
||||
for (k = 0 ; k < pstate->samplesperblock ; k++)
|
||||
samples [k] = pstate->encoder (samples [k], pstate) ;
|
||||
for (k = 0 ; k < G72x_BLOCK_SIZE ; k++)
|
||||
{ out_buffer |= (data->samples [k] << out_bits) ;
|
||||
out_bits += bits ;
|
||||
if (out_bits >= 8)
|
||||
{ out_byte = out_buffer & 0xFF ;
|
||||
out_bits -= 8 ;
|
||||
out_buffer >>= 8 ;
|
||||
data->block [bindex++] = out_byte ;
|
||||
}
|
||||
} ;
|
||||
|
||||
count = pack_bytes (pstate->codec_bits, samples, block) ;
|
||||
return bindex ;
|
||||
} /* pack_bytes */
|
||||
|
||||
int g72x_encode_block (G72x_DATA *data)
|
||||
{ G72x_STATE *pstate ;
|
||||
int k, count ;
|
||||
|
||||
pstate = (G72x_STATE*) data->private ;
|
||||
|
||||
for (k = 0 ; k < data->samplesperblock ; k++)
|
||||
data->samples [k] = pstate->encoder (data->samples [k], pstate) ;
|
||||
|
||||
count = pack_bytes (data, pstate->codec_bits) ;
|
||||
|
||||
return count ;
|
||||
} /* g72x_encode_block */
|
||||
|
||||
@ -593,58 +622,13 @@ update(
|
||||
state_ptr->ap += (0x200 - state_ptr->ap) >> 4;
|
||||
else
|
||||
state_ptr->ap += (-state_ptr->ap) >> 4;
|
||||
|
||||
|
||||
return ;
|
||||
} /* update */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int
|
||||
unpack_bytes (int bits, int blocksize, const unsigned char * block, short * samples)
|
||||
{ unsigned int in_buffer = 0 ;
|
||||
unsigned char in_byte ;
|
||||
int k, in_bits = 0, bindex = 0 ;
|
||||
|
||||
for (k = 0 ; bindex <= blocksize && k < G72x_BLOCK_SIZE ; k++)
|
||||
{ if (in_bits < bits)
|
||||
{ in_byte = block [bindex++] ;
|
||||
|
||||
in_buffer |= (in_byte << in_bits);
|
||||
in_bits += 8;
|
||||
}
|
||||
samples [k] = in_buffer & ((1 << bits) - 1);
|
||||
in_buffer >>= bits;
|
||||
in_bits -= bits;
|
||||
} ;
|
||||
|
||||
return k ;
|
||||
} /* unpack_bytes */
|
||||
|
||||
static int
|
||||
pack_bytes (int bits, const short * samples, unsigned char * block)
|
||||
{
|
||||
unsigned int out_buffer = 0 ;
|
||||
int k, bindex = 0, out_bits = 0 ;
|
||||
unsigned char out_byte ;
|
||||
|
||||
for (k = 0 ; k < G72x_BLOCK_SIZE ; k++)
|
||||
{ out_buffer |= (samples [k] << out_bits) ;
|
||||
out_bits += bits ;
|
||||
if (out_bits >= 8)
|
||||
{ out_byte = out_buffer & 0xFF ;
|
||||
out_bits -= 8 ;
|
||||
out_buffer >>= 8 ;
|
||||
block [bindex++] = out_byte ;
|
||||
}
|
||||
} ;
|
||||
|
||||
return bindex ;
|
||||
} /* pack_bytes */
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 6298dc75-fd0f-4062-9b90-f73ed69f22d4
|
||||
|
@ -1,52 +1,52 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
** This file is not the same as the original file from Sun Microsystems. Nearly
|
||||
** all the original definitions and function prototypes that were in the file
|
||||
** of this name have been moved to g72x_priv.h.
|
||||
*/
|
||||
** all the original definitions and function prototypes that were in the file
|
||||
** of this name have been moved to private.h.
|
||||
*/
|
||||
|
||||
#ifndef G72X_HEADER_FILE
|
||||
#define G72X_HEADER_FILE
|
||||
|
||||
/*
|
||||
** Number of samples per block to process.
|
||||
/*
|
||||
** Number of samples per block to process.
|
||||
** Must be a common multiple of possible bits per sample : 2, 3, 4, 5 and 8.
|
||||
*/
|
||||
#define G72x_BLOCK_SIZE (3 * 5 * 8)
|
||||
#define G72x_BLOCK_SIZE (3*5*8)
|
||||
|
||||
/*
|
||||
/*
|
||||
** Identifiers for the differing kinds of G72x ADPCM codecs.
|
||||
** The identifiers also define the number of encoded bits per sample.
|
||||
*/
|
||||
|
||||
enum
|
||||
{ G723_16_BITS_PER_SAMPLE = 2,
|
||||
G723_24_BITS_PER_SAMPLE = 3,
|
||||
G723_40_BITS_PER_SAMPLE = 5,
|
||||
G723_24_BITS_PER_SAMPLE = 3,
|
||||
G723_40_BITS_PER_SAMPLE = 5,
|
||||
|
||||
G721_32_BITS_PER_SAMPLE = 4,
|
||||
G721_40_BITS_PER_SAMPLE = 5,
|
||||
|
||||
G723_16_SAMPLES_PER_BLOCK = G72x_BLOCK_SIZE,
|
||||
G723_24_SAMPLES_PER_BLOCK = G723_24_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G723_24_BITS_PER_SAMPLE),
|
||||
G723_40_SAMPLES_PER_BLOCK = G723_40_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G723_40_BITS_PER_SAMPLE),
|
||||
G723_24_SAMPLES_PER_BLOCK = G723_24_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G723_24_BITS_PER_SAMPLE),
|
||||
G723_40_SAMPLES_PER_BLOCK = G723_40_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G723_40_BITS_PER_SAMPLE),
|
||||
|
||||
G721_32_SAMPLES_PER_BLOCK = G72x_BLOCK_SIZE,
|
||||
G721_40_SAMPLES_PER_BLOCK = G721_40_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G721_40_BITS_PER_SAMPLE),
|
||||
@ -57,41 +57,59 @@ enum
|
||||
|
||||
G721_32_BYTES_PER_BLOCK = (G721_32_BITS_PER_SAMPLE * G72x_BLOCK_SIZE) / 8,
|
||||
G721_40_BYTES_PER_BLOCK = (G721_40_BITS_PER_SAMPLE * G72x_BLOCK_SIZE) / 8
|
||||
} ;
|
||||
} ;
|
||||
|
||||
/* Forward declaration of of g72x_state. */
|
||||
/*
|
||||
** This is the public structure for passing data between the caller and
|
||||
** the G72x encoder and decoder.
|
||||
** The private array is used by the encoder and decoder for internal
|
||||
** state information and should not be changed in any way by the caller.
|
||||
** When decoding or encoding a stream, the same instance of this struct
|
||||
** should be used for every call so that the decoder/encoder keeps the
|
||||
** correct state data between calls.
|
||||
*/
|
||||
|
||||
struct g72x_state ;
|
||||
typedef struct
|
||||
{ /* Private data. Don't mess with it. */
|
||||
unsigned char private [256] ;
|
||||
|
||||
/* Public data. Read only. */
|
||||
int blocksize, max_bytes, samplesperblock, bytesperblock ;
|
||||
|
||||
/* Public data. Read and write. */
|
||||
int blocks, blockcount, samplecount ;
|
||||
unsigned char block [G72x_BLOCK_SIZE] ;
|
||||
short samples [G72x_BLOCK_SIZE] ;
|
||||
} G72x_DATA ;
|
||||
|
||||
/* External function definitions. */
|
||||
|
||||
struct g72x_state * g72x_reader_init (int codec, int *blocksize, int *samplesperblock) ;
|
||||
struct g72x_state * g72x_writer_init (int codec, int *blocksize, int *samplesperblock) ;
|
||||
int g72x_reader_init (G72x_DATA *data, int codec) ;
|
||||
int g72x_writer_init (G72x_DATA *data, int codec) ;
|
||||
/*
|
||||
** Initialize the ADPCM state table for the given codec.
|
||||
** Return 0 on success, 1 on fail.
|
||||
*/
|
||||
|
||||
int g72x_decode_block (struct g72x_state *pstate, const unsigned char *block, short *samples) ;
|
||||
int g72x_decode_block (G72x_DATA *data) ;
|
||||
/*
|
||||
** The caller fills data->block with data->bytes bytes before calling the
|
||||
** function. The value data->bytes must be an integer multiple of
|
||||
** The caller fills data->block with data->bytes bytes before calling the
|
||||
** function. The value data->bytes must be an integer multiple of
|
||||
** data->blocksize and be <= data->max_bytes.
|
||||
** When it returns, the caller can read out data->samples samples.
|
||||
*/
|
||||
** When it returns, the caller can read out data->samples samples.
|
||||
*/
|
||||
|
||||
int g72x_encode_block (struct g72x_state *pstate, short *samples, unsigned char *block) ;
|
||||
/*
|
||||
int g72x_encode_block (G72x_DATA *data) ;
|
||||
/*
|
||||
** The caller fills state->samples some integer multiple data->samples_per_block
|
||||
** (up to G72x_BLOCK_SIZE) samples before calling the function.
|
||||
** When it returns, the caller can read out bytes encoded bytes.
|
||||
** When it returns, the caller can read out bytes encoded bytes.
|
||||
*/
|
||||
|
||||
#endif /* !G72X_HEADER_FILE */
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 6ca84e5f-f932-4ba1-87ee-37056d921621
|
||||
|
@ -27,21 +27,18 @@
|
||||
#ifndef G72X_PRIVATE_H
|
||||
#define G72X_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#error "This code is not designed to be compiled with a C++ compiler."
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The following is the definition of the state structure used by the
|
||||
** G.721/G.723 encoder and decoder to preserve their internal state
|
||||
** between successive calls. The meanings of the majority of the state
|
||||
** structure fields are explained in detail in the CCITT Recommendation
|
||||
** G.721. The field names are essentially identical to variable names
|
||||
** in the bit level description of the coding algorithm included in this
|
||||
** between successive calls. The meanings of the majority of the state
|
||||
** structure fields are explained in detail in the CCITT Recommendation
|
||||
** G.721. The field names are essentially identical to variable names
|
||||
** in the bit level description of the coding algorithm included in this
|
||||
** Recommendation.
|
||||
*/
|
||||
|
||||
struct g72x_state
|
||||
typedef struct private_g72x
|
||||
{ long yl; /* Locked or steady state step size multiplier. */
|
||||
short yu; /* Unlocked or non-steady state step size multiplier. */
|
||||
short dms; /* Short term energy estimate. */
|
||||
@ -65,20 +62,22 @@ struct g72x_state
|
||||
** format.
|
||||
*/
|
||||
char td; /* delayed tone detect, new in 1988 version */
|
||||
|
||||
/* The following struct members were added for libsndfile. The original
|
||||
** code worked by calling a set of functions on a sample by sample basis
|
||||
** which is slow on architectures like Intel x86. For libsndfile, this
|
||||
|
||||
/* The following struct members were added for libsndfile. The original
|
||||
** code worked by calling a set of functions on a sample by sample basis
|
||||
** which is slow on architectures like Intel x86. For libsndfile, this
|
||||
** was changed so that the encoding and decoding routines could work on
|
||||
** a block of samples at a time to reduce the function call overhead.
|
||||
*/
|
||||
int (*encoder) (int, struct g72x_state* state) ;
|
||||
int (*decoder) (int, struct g72x_state* state) ;
|
||||
int (*encoder) (int, struct private_g72x* state) ;
|
||||
int (*decoder) (int, struct private_g72x* state) ;
|
||||
|
||||
int codec_bits ;
|
||||
int byte_index, sample_index ;
|
||||
|
||||
} G72x_STATE ;
|
||||
|
||||
int codec_bits, blocksize, samplesperblock ;
|
||||
} ;
|
||||
|
||||
typedef struct g72x_state G72x_STATE ;
|
||||
|
||||
int predictor_zero (G72x_STATE *state_ptr);
|
||||
|
||||
@ -104,13 +103,15 @@ int g723_24_decoder (int code, G72x_STATE *state_ptr);
|
||||
int g723_40_encoder (int sample, G72x_STATE *state_ptr);
|
||||
int g723_40_decoder (int code, G72x_STATE *state_ptr);
|
||||
|
||||
int unpack_bytes (G72x_DATA *data, int bits) ;
|
||||
int pack_bytes (G72x_DATA *data, int bits) ;
|
||||
|
||||
void private_init_state (G72x_STATE *state_ptr) ;
|
||||
|
||||
#endif /* G72X_PRIVATE_H */
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: d9ad4da7-0fa3-471d-8020-720b5cfb5e5b
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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,29 +1,20 @@
|
||||
2004-05-12 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* gsm610_priv.h
|
||||
Replace ugly macros with inline functions.
|
||||
|
||||
* *.c
|
||||
Remove temporary variables used by macros and other minor fixes required by
|
||||
above change.
|
||||
|
||||
2003-06-02 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
2003-06-02 Erik de Castro Lopo <erikd AT zipworld DOT com DOT au>
|
||||
|
||||
* rpe.c
|
||||
Renamed variables "exp" to "expon" to avoid shadowed parameter warnigns.
|
||||
|
||||
2002-06-08 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
2002-06-08 Erik de Castro Lopo <erikd AT zipworld DOT com DOT au>
|
||||
|
||||
* long_term.c
|
||||
Changes tp removed compiler warnings about shadowed parameters.
|
||||
|
||||
2002-06-08 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
2002-06-08 Erik de Castro Lopo <erikd AT zipworld DOT com DOT au>
|
||||
|
||||
* private.h
|
||||
Made declarations of gsm_A, gsm_B, gsm_MIC etc extern. This fixed a compile
|
||||
problem on MacOSX.
|
||||
|
||||
2002-05-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
2002-05-10 Erik de Castro Lopo <erikd AT zipworld DOT com DOT au>
|
||||
|
||||
* *.[ch]
|
||||
Removed all pre-ANSI prototype kludges. Removed proto.h and unproto.h.
|
||||
@ -33,23 +24,23 @@
|
||||
Function Gsm_Coder () used a statically defined array. This was obviously
|
||||
not re-entrant so moved it to struct gsm_state.
|
||||
|
||||
2001-09-16 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
2001-09-16 Erik de Castro Lopo <erikd AT zipworld DOT com DOT au>
|
||||
|
||||
* code.c
|
||||
Added #includes for string.h and stdlib.h.
|
||||
|
||||
2000-10-27 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
2000-10-27 Erik de Castro Lopo <erikd AT zipworld DOT com DOT au>
|
||||
|
||||
* config.h
|
||||
Removed some commented out #defines (ie //*efine) which were causing problems on
|
||||
the Sun cc compiler.
|
||||
|
||||
2000-02-29 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
2000-02-29 Erik de Castro Lopo <erikd AT zipworld DOT com DOT au>
|
||||
|
||||
* private.h
|
||||
Added #defines to emulate normal compile time options.
|
||||
|
||||
2000-02-28 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
2000-02-28 Erik de Castro Lopo <erikd AT zipworld DOT com DOT au>
|
||||
|
||||
* everthing
|
||||
Created this directory and copied files from libgsm.
|
||||
|
@ -31,10 +31,8 @@ word gsm_sub ( word a, word b)
|
||||
|
||||
word gsm_mult ( word a, word b)
|
||||
{
|
||||
if (a == MIN_WORD && b == MIN_WORD)
|
||||
return MAX_WORD;
|
||||
|
||||
return SASR_L( (longword)a * (longword)b, 15 );
|
||||
if (a == MIN_WORD && b == MIN_WORD) return MAX_WORD;
|
||||
else return SASR( (longword)a * (longword)b, 15 );
|
||||
}
|
||||
|
||||
word gsm_mult_r ( word a, word b)
|
||||
@ -163,7 +161,12 @@ word gsm_asr (word a, int n)
|
||||
if (n <= -16) return 0;
|
||||
if (n < 0) return a << -n;
|
||||
|
||||
return SASR_W (a, (word) n);
|
||||
# ifdef SASR
|
||||
return a >> n;
|
||||
# else
|
||||
if (a >= 0) return a >> n;
|
||||
else return -(word)( -(uword)a >> n );
|
||||
# endif
|
||||
}
|
||||
|
||||
word gsm_asl (word a, int n)
|
||||
@ -180,7 +183,12 @@ longword gsm_L_asr (longword a, int n)
|
||||
if (n <= -32) return 0;
|
||||
if (n < 0) return a << -n;
|
||||
|
||||
return SASR_L (a, (word) n);
|
||||
# ifdef SASR
|
||||
return a >> n;
|
||||
# else
|
||||
if (a >= 0) return a >> n;
|
||||
else return -(longword)( -(ulongword)a >> n );
|
||||
# endif
|
||||
}
|
||||
|
||||
/*
|
||||
@ -190,7 +198,7 @@ longword gsm_L_asr (longword a, int n)
|
||||
** if (n <= -16) return 0;
|
||||
** if (n < 0) return a << -n;
|
||||
**
|
||||
** # ifdef SASR_W
|
||||
** # ifdef SASR
|
||||
** return a >> n;
|
||||
** # else
|
||||
** if (a >= 0) return a >> n;
|
||||
|
@ -77,6 +77,7 @@ void Gsm_Coder (
|
||||
*/
|
||||
|
||||
{ register int i;
|
||||
register longword ltmp;
|
||||
for (i = 0; i <= 39; i++)
|
||||
dp[ i ] = GSM_ADD( State->e[5 + i], dpp[i] );
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ static void Postprocessing (
|
||||
{
|
||||
register int k;
|
||||
register word msr = S->msr;
|
||||
register longword ltmp; /* for GSM_ADD */
|
||||
register word tmp;
|
||||
|
||||
for (k = 160; k--; s++) {
|
||||
|
@ -8,13 +8,10 @@
|
||||
#define PRIVATE_H
|
||||
|
||||
/* Added by Erik de Castro Lopo */
|
||||
#define SASR
|
||||
#define USE_FLOAT_MUL
|
||||
#define FAST
|
||||
#define WAV49
|
||||
|
||||
#ifdef __cplusplus
|
||||
#error "This code is not designed to be compiled with a C++ compiler."
|
||||
#endif
|
||||
#define WAV49
|
||||
/* Added by Erik de Castro Lopo */
|
||||
|
||||
|
||||
@ -25,7 +22,7 @@ typedef int longword; /* 32 bit signed int */
|
||||
typedef unsigned short uword; /* unsigned word */
|
||||
typedef unsigned int ulongword; /* unsigned longword */
|
||||
|
||||
struct gsm_state
|
||||
struct gsm_state
|
||||
{ word dp0[ 280 ] ;
|
||||
|
||||
word z1; /* preprocessing.c, Offset_com. */
|
||||
@ -60,16 +57,12 @@ typedef struct gsm_state GSM_STATE ;
|
||||
#define MIN_LONGWORD (-2147483647 - 1)
|
||||
#define MAX_LONGWORD 2147483647
|
||||
|
||||
/* Signed arithmetic shift right. */
|
||||
static inline word
|
||||
SASR_W (word x, word by)
|
||||
{ return (x >> by) ;
|
||||
} /* SASR */
|
||||
|
||||
static inline longword
|
||||
SASR_L (longword x, word by)
|
||||
{ return (x >> by) ;
|
||||
} /* SASR */
|
||||
#ifdef SASR /* flag: >> is a signed arithmetic shift right */
|
||||
#undef SASR
|
||||
#define SASR(x, by) ((x) >> (by))
|
||||
#else
|
||||
#define SASR(x, by) ((x) >= 0 ? (x) >> (by) : (~(-((x) + 1) >> (by))))
|
||||
#endif /* SASR */
|
||||
|
||||
/*
|
||||
* Prototypes from add.c
|
||||
@ -97,79 +90,60 @@ longword gsm_L_asr (longword a, int n) ;
|
||||
word gsm_asr (word a, int n) ;
|
||||
|
||||
/*
|
||||
* Inlined functions from add.h
|
||||
* Inlined functions from add.h
|
||||
*/
|
||||
|
||||
static inline longword
|
||||
GSM_MULT_R (word a, word b)
|
||||
{ return (((longword) (a)) * ((longword) (b)) + 16384) >> 15 ;
|
||||
} /* GSM_MULT_R */
|
||||
/*
|
||||
* #define GSM_MULT_R(a, b) (* word a, word b, !(a == b == MIN_WORD) *) \
|
||||
* (0x0FFFF & SASR(((longword)(a) * (longword)(b) + 16384), 15))
|
||||
*/
|
||||
#define GSM_MULT_R(a, b) /* word a, word b, !(a == b == MIN_WORD) */ \
|
||||
(SASR( ((longword)(a) * (longword)(b) + 16384), 15 ))
|
||||
|
||||
static inline longword
|
||||
GSM_MULT (word a, word b)
|
||||
{ return (((longword) (a)) * ((longword) (b))) >> 15 ;
|
||||
} /* GSM_MULT */
|
||||
# define GSM_MULT(a,b) /* word a, word b, !(a == b == MIN_WORD) */ \
|
||||
(SASR( ((longword)(a) * (longword)(b)), 15 ))
|
||||
|
||||
static inline longword
|
||||
GSM_L_MULT (word a, word b)
|
||||
{ return ((longword) (a)) * ((longword) (b)) << 1 ;
|
||||
} /* GSM_L_MULT */
|
||||
# define GSM_L_MULT(a, b) /* word a, word b */ \
|
||||
(((longword)(a) * (longword)(b)) << 1)
|
||||
|
||||
static inline longword
|
||||
GSM_L_ADD (longword a, longword b)
|
||||
{ ulongword utmp ;
|
||||
# define GSM_L_ADD(a, b) \
|
||||
( (a) < 0 ? ( (b) >= 0 ? (a) + (b) \
|
||||
: (utmp = (ulongword)-((a) + 1) + (ulongword)-((b) + 1)) \
|
||||
>= ((ulongword) MAX_LONGWORD) ? MIN_LONGWORD : -(longword)utmp-2 ) \
|
||||
: ((b) <= 0 ? (a) + (b) \
|
||||
: (utmp = (ulongword)(a) + (ulongword)(b)) >= ((ulongword) MAX_LONGWORD) \
|
||||
? MAX_LONGWORD : utmp))
|
||||
|
||||
if (a < 0 && b < 0)
|
||||
{ utmp = (ulongword)-((a) + 1) + (ulongword)-((b) + 1) ;
|
||||
return (utmp >= (ulongword) MAX_LONGWORD) ? MIN_LONGWORD : -(longword)utmp-2 ;
|
||||
} ;
|
||||
/*
|
||||
* # define GSM_ADD(a, b) \
|
||||
* ((ltmp = (longword)(a) + (longword)(b)) >= MAX_WORD \
|
||||
* ? MAX_WORD : ltmp <= MIN_WORD ? MIN_WORD : ltmp)
|
||||
*/
|
||||
/* Nonportable, but faster: */
|
||||
|
||||
if (a > 0 && b > 0)
|
||||
{ utmp = (ulongword) a + (ulongword) b ;
|
||||
return (utmp >= (ulongword) MAX_LONGWORD) ? MAX_LONGWORD : utmp ;
|
||||
} ;
|
||||
#define GSM_ADD(a, b) \
|
||||
((ulongword)((ltmp = (longword)(a) + (longword)(b)) - MIN_WORD) > \
|
||||
MAX_WORD - MIN_WORD ? (ltmp > 0 ? MAX_WORD : MIN_WORD) : ltmp)
|
||||
|
||||
return a + b ;
|
||||
} /* GSM_L_ADD */
|
||||
# define GSM_SUB(a, b) \
|
||||
((ltmp = (longword)(a) - (longword)(b)) >= MAX_WORD \
|
||||
? MAX_WORD : ltmp <= MIN_WORD ? MIN_WORD : ltmp)
|
||||
|
||||
static inline longword
|
||||
GSM_ADD (word a, word b)
|
||||
{ longword ltmp ;
|
||||
# define GSM_ABS(a) ((a) < 0 ? ((a) == MIN_WORD ? MAX_WORD : -(a)) : (a))
|
||||
|
||||
ltmp = ((longword) a) + ((longword) b) ;
|
||||
/* Use these if necessary:
|
||||
|
||||
if (ltmp >= MAX_WORD)
|
||||
return MAX_WORD ;
|
||||
if (ltmp <= MIN_WORD)
|
||||
return MIN_WORD ;
|
||||
# define GSM_MULT_R(a, b) gsm_mult_r(a, b)
|
||||
# define GSM_MULT(a, b) gsm_mult(a, b)
|
||||
# define GSM_L_MULT(a, b) gsm_L_mult(a, b)
|
||||
|
||||
return ltmp ;
|
||||
} /* GSM_ADD */
|
||||
# define GSM_L_ADD(a, b) gsm_L_add(a, b)
|
||||
# define GSM_ADD(a, b) gsm_add(a, b)
|
||||
# define GSM_SUB(a, b) gsm_sub(a, b)
|
||||
|
||||
static inline longword
|
||||
GSM_SUB (word a, word b)
|
||||
{ longword ltmp ;
|
||||
|
||||
ltmp = ((longword) a) - ((longword) b) ;
|
||||
|
||||
if (ltmp >= MAX_WORD)
|
||||
ltmp = MAX_WORD ;
|
||||
else if (ltmp <= MIN_WORD)
|
||||
ltmp = MIN_WORD ;
|
||||
|
||||
return ltmp ;
|
||||
} /* GSM_SUB */
|
||||
|
||||
static inline word
|
||||
GSM_ABS (word a)
|
||||
{
|
||||
if (a > 0)
|
||||
return a ;
|
||||
if (a == MIN_WORD)
|
||||
return MAX_WORD ;
|
||||
return -a ;
|
||||
} /* GSM_ADD */
|
||||
# define GSM_ABS(a) gsm_abs(a)
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* More prototypes from implementations..
|
||||
@ -204,10 +178,10 @@ void Gsm_Preprocess (
|
||||
|
||||
void Gsm_Encoding (
|
||||
struct gsm_state * S,
|
||||
word * e,
|
||||
word * ep,
|
||||
word * e,
|
||||
word * ep,
|
||||
word * xmaxc,
|
||||
word * Mc,
|
||||
word * Mc,
|
||||
word * xMc) ;
|
||||
|
||||
void Gsm_Short_Term_Analysis_Filter (
|
||||
@ -300,7 +274,7 @@ extern word gsm_FAC [8] ;
|
||||
#endif /* PRIVATE_H */
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 8bc5fdf2-e8c8-4686-9bd7-a30b512bef0c
|
||||
|
@ -89,7 +89,7 @@ static void Cut_Calculation_of_the_LTP_parameters (
|
||||
*/
|
||||
L_max = 0;
|
||||
Nc = 40; /* index for the maximum cross-correlation */
|
||||
wt_k = SASR_W(d[best_k], scal);
|
||||
wt_k = SASR(d[best_k], scal);
|
||||
|
||||
for (lambda = 40; lambda <= 120; lambda++) {
|
||||
L_result = (longword)wt_k * dp[best_k - lambda];
|
||||
@ -116,7 +116,7 @@ static void Cut_Calculation_of_the_LTP_parameters (
|
||||
|
||||
register longword L_temp;
|
||||
|
||||
L_temp = SASR_W( dp[k - Nc], 3 );
|
||||
L_temp = SASR( dp[k - Nc], 3 );
|
||||
L_power += L_temp * L_temp;
|
||||
}
|
||||
L_power <<= 1; /* from L_MULT */
|
||||
@ -190,7 +190,7 @@ static void Calculation_of_the_LTP_parameters (
|
||||
/* Initialization of a working array wt
|
||||
*/
|
||||
|
||||
for (k = 0; k <= 39; k++) wt[k] = SASR_W( d[k], scal );
|
||||
for (k = 0; k <= 39; k++) wt[k] = SASR( d[k], scal );
|
||||
|
||||
/* Search for the maximum cross-correlation and coding of the LTP lag
|
||||
*/
|
||||
@ -251,7 +251,7 @@ static void Calculation_of_the_LTP_parameters (
|
||||
|
||||
register longword L_temp;
|
||||
|
||||
L_temp = SASR_W( dp[k - Nc], 3 );
|
||||
L_temp = SASR( dp[k - Nc], 3 );
|
||||
L_power += L_temp * L_temp;
|
||||
}
|
||||
L_power <<= 1; /* from L_MULT */
|
||||
@ -270,8 +270,8 @@ static void Calculation_of_the_LTP_parameters (
|
||||
|
||||
temp = gsm_norm( L_power );
|
||||
|
||||
R = SASR_L( L_max << temp, 16 );
|
||||
S = SASR_L( L_power << temp, 16 );
|
||||
R = SASR( L_max << temp, 16 );
|
||||
S = SASR( L_power << temp, 16 );
|
||||
|
||||
/* Coding of the LTP gain
|
||||
*/
|
||||
@ -327,14 +327,14 @@ static void Cut_Calculation_of_the_LTP_parameters (
|
||||
else scal = 6 - temp;
|
||||
|
||||
assert(scal >= 0);
|
||||
ltp_cut = (longword)SASR_W(dmax, scal) * st->ltp_cut / 100;
|
||||
ltp_cut = (longword)SASR(dmax, scal) * st->ltp_cut / 100;
|
||||
|
||||
|
||||
/* Initialization of a working array wt
|
||||
*/
|
||||
|
||||
for (k = 0; k < 40; k++) {
|
||||
register word w = SASR_W( d[k], scal );
|
||||
register word w = SASR( d[k], scal );
|
||||
if (w < 0 ? w > -ltp_cut : w < ltp_cut) {
|
||||
wt_float[k] = 0.0;
|
||||
}
|
||||
@ -401,15 +401,6 @@ static void Cut_Calculation_of_the_LTP_parameters (
|
||||
STEP_A(32); STEP_B(33); STEP_C(34); STEP_D(35);
|
||||
STEP_E(36); STEP_F(37); STEP_G(38); STEP_H(39);
|
||||
|
||||
# undef STEP_A
|
||||
# undef STEP_B
|
||||
# undef STEP_C
|
||||
# undef STEP_D
|
||||
# undef STEP_E
|
||||
# undef STEP_F
|
||||
# undef STEP_G
|
||||
# undef STEP_H
|
||||
|
||||
if (S0 > L_max) { L_max = S0; Nc = lambda; }
|
||||
if (S1 > L_max) { L_max = S1; Nc = lambda + 1; }
|
||||
if (S2 > L_max) { L_max = S2; Nc = lambda + 2; }
|
||||
@ -440,7 +431,7 @@ static void Cut_Calculation_of_the_LTP_parameters (
|
||||
|
||||
register longword L_temp;
|
||||
|
||||
L_temp = SASR_W( dp[k - Nc], 3 );
|
||||
L_temp = SASR( dp[k - Nc], 3 );
|
||||
L_power += L_temp * L_temp;
|
||||
}
|
||||
L_power <<= 1; /* from L_MULT */
|
||||
@ -516,7 +507,7 @@ static void Calculation_of_the_LTP_parameters (
|
||||
/* Initialization of a working array wt
|
||||
*/
|
||||
|
||||
for (k = 0; k < 40; k++) wt_float[k] = SASR_W (din [k], scal) ;
|
||||
for (k = 0; k < 40; k++) wt_float[k] = SASR (din [k], scal) ;
|
||||
for (k = -120; k < 0; k++) dp_float[k] = dp[k];
|
||||
|
||||
/* Search for the maximum cross-correlation and coding of the LTP lag
|
||||
@ -576,15 +567,6 @@ static void Calculation_of_the_LTP_parameters (
|
||||
STEP_A(32); STEP_B(33); STEP_C(34); STEP_D(35);
|
||||
STEP_E(36); STEP_F(37); STEP_G(38); STEP_H(39);
|
||||
|
||||
# undef STEP_A
|
||||
# undef STEP_B
|
||||
# undef STEP_C
|
||||
# undef STEP_D
|
||||
# undef STEP_E
|
||||
# undef STEP_F
|
||||
# undef STEP_G
|
||||
# undef STEP_H
|
||||
|
||||
if (S0 > L_max) { L_max = S0; Nc = lambda; }
|
||||
if (S1 > L_max) { L_max = S1; Nc = lambda + 1; }
|
||||
if (S2 > L_max) { L_max = S2; Nc = lambda + 2; }
|
||||
@ -614,7 +596,7 @@ static void Calculation_of_the_LTP_parameters (
|
||||
|
||||
register longword L_temp;
|
||||
|
||||
L_temp = SASR_W( dp[k - Nc], 3 );
|
||||
L_temp = SASR( dp[k - Nc], 3 );
|
||||
L_power += L_temp * L_temp;
|
||||
}
|
||||
L_power <<= 1; /* from L_MULT */
|
||||
@ -633,8 +615,8 @@ static void Calculation_of_the_LTP_parameters (
|
||||
|
||||
temp = gsm_norm( L_power );
|
||||
|
||||
R = SASR_L ( L_max << temp, 16 );
|
||||
S = SASR_L ( L_power << temp, 16 );
|
||||
R = SASR( L_max << temp, 16 );
|
||||
S = SASR( L_power << temp, 16 );
|
||||
|
||||
/* Coding of the LTP gain
|
||||
*/
|
||||
@ -861,6 +843,7 @@ static void Long_term_analysis_filtering (
|
||||
*/
|
||||
{
|
||||
register int k;
|
||||
register longword ltmp;
|
||||
|
||||
# undef STEP
|
||||
# define STEP(BP) \
|
||||
@ -929,6 +912,7 @@ void Gsm_Long_Term_Synthesis_Filtering (
|
||||
* table 4.3b.
|
||||
*/
|
||||
{
|
||||
register longword ltmp; /* for ADD */
|
||||
register int k;
|
||||
word brp, drpp, Nr;
|
||||
|
||||
|
@ -176,6 +176,7 @@ static void Reflection_coefficients (
|
||||
{
|
||||
register int i, m, n;
|
||||
register word temp;
|
||||
register longword ltmp;
|
||||
word ACF[9]; /* 0..8 */
|
||||
word P[ 9]; /* 0..8 */
|
||||
word K[ 9]; /* 2..8 */
|
||||
@ -194,7 +195,7 @@ static void Reflection_coefficients (
|
||||
assert(temp >= 0 && temp < 32);
|
||||
|
||||
/* ? overflow ? */
|
||||
for (i = 0; i <= 8; i++) ACF[i] = SASR_L( L_ACF[i] << temp, 16 );
|
||||
for (i = 0; i <= 8; i++) ACF[i] = SASR( L_ACF[i] << temp, 16 );
|
||||
|
||||
/* Initialize array P[..] and K[..] for the recursion.
|
||||
*/
|
||||
@ -283,6 +284,8 @@ static void Quantization_and_coding (
|
||||
)
|
||||
{
|
||||
register word temp;
|
||||
longword ltmp;
|
||||
|
||||
|
||||
/* This procedure needs four tables; the following equations
|
||||
* give the optimum scaling for the constants:
|
||||
@ -298,7 +301,7 @@ static void Quantization_and_coding (
|
||||
temp = GSM_MULT( A, *LAR ); \
|
||||
temp = GSM_ADD( temp, B ); \
|
||||
temp = GSM_ADD( temp, 256 ); \
|
||||
temp = SASR_W( temp, 9 ); \
|
||||
temp = SASR( temp, 9 ); \
|
||||
*LAR = temp>MAC ? MAC - MIC : (temp<MIC ? 0 : temp - MIC); \
|
||||
LAR++;
|
||||
|
||||
|
@ -46,13 +46,16 @@ void Gsm_Preprocess (
|
||||
word msp, lsp;
|
||||
word SO;
|
||||
|
||||
longword ltmp; /* for ADD */
|
||||
ulongword utmp; /* for L_ADD */
|
||||
|
||||
register int k = 160;
|
||||
|
||||
while (k--) {
|
||||
|
||||
/* 4.2.1 Downscaling of the input signal
|
||||
*/
|
||||
SO = SASR_W( *s, 3 ) << 2;
|
||||
SO = SASR( *s, 3 ) << 2;
|
||||
s++;
|
||||
|
||||
assert (SO >= -0x4000); /* downscaled by */
|
||||
@ -82,7 +85,7 @@ void Gsm_Preprocess (
|
||||
/* Execution of a 31 bv 16 bits multiplication
|
||||
*/
|
||||
|
||||
msp = SASR_L( L_z2, 15 );
|
||||
msp = SASR( L_z2, 15 );
|
||||
lsp = L_z2-((longword)msp<<15); /* gsm_L_sub(L_z2,(msp<<15)); */
|
||||
|
||||
L_s2 += GSM_MULT_R( lsp, 32735 );
|
||||
@ -97,7 +100,7 @@ void Gsm_Preprocess (
|
||||
*/
|
||||
|
||||
msp = GSM_MULT_R( mp, -28180 );
|
||||
mp = SASR_L( L_temp, 15 );
|
||||
mp = SASR( L_temp, 15 );
|
||||
*so++ = GSM_ADD( mp, msp );
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ static void Weighting_filter (
|
||||
* those we lost when replacing L_MULT by '*'.
|
||||
*/
|
||||
|
||||
L_result = SASR_L( L_result, 13 );
|
||||
L_result = SASR( L_result, 13 );
|
||||
x[k] = ( L_result < MIN_WORD ? MIN_WORD
|
||||
: (L_result > MAX_WORD ? MAX_WORD : L_result ));
|
||||
}
|
||||
@ -137,7 +137,7 @@ static void RPE_grid_selection (
|
||||
*
|
||||
* for (i = 0; i <= 12; i++) {
|
||||
*
|
||||
* temp1 = SASR_W( x[m + 3*i], 2 );
|
||||
* temp1 = SASR( x[m + 3*i], 2 );
|
||||
*
|
||||
* assert(temp1 != MIN_WORD);
|
||||
*
|
||||
@ -153,7 +153,7 @@ static void RPE_grid_selection (
|
||||
*/
|
||||
|
||||
#undef STEP
|
||||
#define STEP( m, i ) L_temp = SASR_W( x[m + 3 * i], 2 ); \
|
||||
#define STEP( m, i ) L_temp = SASR( x[m + 3 * i], 2 ); \
|
||||
L_result += L_temp * L_temp;
|
||||
|
||||
/* common part of 0 and 3 */
|
||||
@ -228,7 +228,7 @@ static void APCM_quantization_xmaxc_to_exp_mant (
|
||||
*/
|
||||
|
||||
expon = 0;
|
||||
if (xmaxc > 15) expon = SASR_W(xmaxc, 3) - 1;
|
||||
if (xmaxc > 15) expon = SASR(xmaxc, 3) - 1;
|
||||
mant = xmaxc - (expon << 3);
|
||||
|
||||
if (mant == 0) {
|
||||
@ -278,13 +278,13 @@ static void APCM_quantization (
|
||||
*/
|
||||
|
||||
expon = 0;
|
||||
temp = SASR_W( xmax, 9 );
|
||||
temp = SASR( xmax, 9 );
|
||||
itest = 0;
|
||||
|
||||
for (i = 0; i <= 5; i++) {
|
||||
|
||||
itest |= (temp <= 0);
|
||||
temp = SASR_W( temp, 1 );
|
||||
temp = SASR( temp, 1 );
|
||||
|
||||
assert(expon <= 5);
|
||||
if (itest == 0) expon++; /* expon = add (expon, 1) */
|
||||
@ -294,7 +294,7 @@ static void APCM_quantization (
|
||||
temp = expon + 5;
|
||||
|
||||
assert(temp <= 11 && temp >= 0);
|
||||
xmaxc = gsm_add( SASR_W(xmax, temp), (word) (expon << 3) );
|
||||
xmaxc = gsm_add( SASR(xmax, temp), expon << 3 );
|
||||
|
||||
/* Quantizing and coding of the xM[0..12] RPE sequence
|
||||
* to get the xMc[0..12]
|
||||
@ -328,7 +328,7 @@ static void APCM_quantization (
|
||||
|
||||
temp = xM[i] << temp1;
|
||||
temp = GSM_MULT( temp, temp2 );
|
||||
temp = SASR_W(temp, 12);
|
||||
temp = SASR(temp, 12);
|
||||
xMc[i] = temp + 4; /* see note below */
|
||||
}
|
||||
|
||||
@ -355,6 +355,7 @@ static void APCM_inverse_quantization (
|
||||
{
|
||||
int i;
|
||||
word temp, temp1, temp2, temp3;
|
||||
longword ltmp;
|
||||
|
||||
assert( mant >= 0 && mant <= 7 );
|
||||
|
||||
|
@ -22,6 +22,7 @@ static void Decoding_of_the_coded_Log_Area_Ratios (
|
||||
word * LARpp) /* out: decoded .. */
|
||||
{
|
||||
register word temp1 /* , temp2 */;
|
||||
register long ltmp; /* for GSM_ADD */
|
||||
|
||||
/* This procedure requires for efficient implementation
|
||||
* two tables.
|
||||
@ -90,10 +91,11 @@ static void Coefficients_0_12 (
|
||||
register word * LARp)
|
||||
{
|
||||
register int i;
|
||||
register longword ltmp;
|
||||
|
||||
for (i = 1; i <= 8; i++, LARp++, LARpp_j_1++, LARpp_j++) {
|
||||
*LARp = GSM_ADD( SASR_W( *LARpp_j_1, 2 ), SASR_W( *LARpp_j, 2 ));
|
||||
*LARp = GSM_ADD( *LARp, SASR_W( *LARpp_j_1, 1));
|
||||
*LARp = GSM_ADD( SASR( *LARpp_j_1, 2 ), SASR( *LARpp_j, 2 ));
|
||||
*LARp = GSM_ADD( *LARp, SASR( *LARpp_j_1, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,8 +105,9 @@ static void Coefficients_13_26 (
|
||||
register word * LARp)
|
||||
{
|
||||
register int i;
|
||||
register longword ltmp;
|
||||
for (i = 1; i <= 8; i++, LARpp_j_1++, LARpp_j++, LARp++) {
|
||||
*LARp = GSM_ADD( SASR_W( *LARpp_j_1, 1), SASR_W( *LARpp_j, 1 ));
|
||||
*LARp = GSM_ADD( SASR( *LARpp_j_1, 1), SASR( *LARpp_j, 1 ));
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,10 +117,11 @@ static void Coefficients_27_39 (
|
||||
register word * LARp)
|
||||
{
|
||||
register int i;
|
||||
register longword ltmp;
|
||||
|
||||
for (i = 1; i <= 8; i++, LARpp_j_1++, LARpp_j++, LARp++) {
|
||||
*LARp = GSM_ADD( SASR_W( *LARpp_j_1, 2 ), SASR_W( *LARpp_j, 2 ));
|
||||
*LARp = GSM_ADD( *LARp, SASR_W( *LARpp_j, 1 ));
|
||||
*LARp = GSM_ADD( SASR( *LARpp_j_1, 2 ), SASR( *LARpp_j, 2 ));
|
||||
*LARp = GSM_ADD( *LARp, SASR( *LARpp_j, 1 ));
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,6 +148,7 @@ static void LARp_to_rp (
|
||||
{
|
||||
register int i;
|
||||
register word temp;
|
||||
register longword ltmp;
|
||||
|
||||
for (i = 1; i <= 8; i++, LARp++) {
|
||||
|
||||
@ -160,12 +165,12 @@ static void LARp_to_rp (
|
||||
temp = *LARp == MIN_WORD ? MAX_WORD : -(*LARp);
|
||||
*LARp = - ((temp < 11059) ? temp << 1
|
||||
: ((temp < 20070) ? temp + 11059
|
||||
: GSM_ADD( (word) (temp >> 2), (word) 26112 )));
|
||||
: GSM_ADD( temp >> 2, 26112 )));
|
||||
} else {
|
||||
temp = *LARp;
|
||||
*LARp = (temp < 11059) ? temp << 1
|
||||
: ((temp < 20070) ? temp + 11059
|
||||
: GSM_ADD( (word) (temp >> 2), (word) 26112 ));
|
||||
: GSM_ADD( temp >> 2, 26112 ));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -192,6 +197,7 @@ static void Short_term_analysis_filtering (
|
||||
register word * u = S->u;
|
||||
register int i;
|
||||
register word di, zzz, ui, sav, rpi;
|
||||
register longword ltmp;
|
||||
|
||||
for (; k_n--; s++) {
|
||||
|
||||
@ -264,6 +270,7 @@ static void Short_term_synthesis_filtering (
|
||||
register word * v = S->v;
|
||||
register int i;
|
||||
register word sri, tmp1, tmp2;
|
||||
register longword ltmp; /* for GSM_ADD & GSM_SUB */
|
||||
|
||||
while (k--) {
|
||||
sri = *wt++;
|
||||
|
108
src/Makefile.am
108
src/Makefile.am
@ -1,120 +1,72 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
SUBDIRS = OGG FLAC GSM610 G72x
|
||||
|
||||
SUBDIRS = GSM610 G72x
|
||||
|
||||
lib_LTLIBRARIES = libsndfile.la
|
||||
include_HEADERS = sndfile.hh
|
||||
nodist_include_HEADERS = sndfile.h
|
||||
include_HEADERS = sndfile.h
|
||||
|
||||
noinst_LTLIBRARIES = libcommon.la
|
||||
EXTRA_DIST = sndfile.h.in config.h.in create_symbols_file.sh
|
||||
|
||||
OS_SPECIFIC_CFLAGS = @OS_SPECIFIC_CFLAGS@
|
||||
OS_SPECIFIC_LINKS = @OS_SPECIFIC_LINKS@
|
||||
noinst_HEADERS = common.h sfendian.h float_cast.h wav_w64.h au.h sf_unistd.h
|
||||
|
||||
EXTRA_DIST = sndfile.h.in config.h.in test_endswap.tpl test_endswap.def \
|
||||
Symbols.linux Symbols.darwin libsndfile.def cygsndfile.def \
|
||||
create_symbols_file.py binheader_writef_check.py
|
||||
noinst_PROGRAMS = test_file_io test_log_printf
|
||||
|
||||
noinst_HEADERS = common.h sfconfig.h sfendian.h float_cast.h wav_w64.h sf_unistd.h
|
||||
CLEANFILES = Symbols
|
||||
|
||||
noinst_PROGRAMS = test_endswap test_file_io test_conversions test_log_printf \
|
||||
test_audio_detect
|
||||
COMMON = sndfile.c common.c file_io.c command.c pcm.c ulaw.c alaw.c float32.c \
|
||||
double64.c ima_adpcm.c ms_adpcm.c gsm610.c dwvw.c sfendian.c vox_adpcm.c \
|
||||
interleave.c strings.c dither.c
|
||||
|
||||
COMMON = common.c file_io.c command.c pcm.c ulaw.c alaw.c float32.c \
|
||||
double64.c ima_adpcm.c ms_adpcm.c gsm610.c dwvw.c vox_adpcm.c \
|
||||
interleave.c strings.c dither.c broadcast.c audio_detect.c
|
||||
|
||||
FILESPECIFIC = sndfile.c aiff.c au.c avr.c caf.c dwd.c flac.c g72x.c htk.c ircam.c \
|
||||
macbinary3.c macos.c mat4.c mat5.c nist.c ogg.c paf.c pvf.c raw.c rx2.c sd2.c \
|
||||
sds.c svx.c txw.c voc.c wve.c w64.c wav_w64.c wav.c xi.c
|
||||
|
||||
# MinGW requires -no-undefined if a DLL is to be built.
|
||||
libsndfile_la_LDFLAGS = -no-undefined -version-info @SHARED_VERSION_INFO@ @SHLIB_VERSION_ARG@
|
||||
libsndfile_la_SOURCES = $(FILESPECIFIC) $(noinst_HEADERS)
|
||||
nodist_libsndfile_la_SOURCES = $(nodist_include_HEADERS)
|
||||
libsndfile_la_LIBADD = libcommon.la FLAC/src/libFLAC/libFLAC.la GSM610/libgsm.la \
|
||||
G72x/libg72x.la OGG/libogg.la -lm
|
||||
|
||||
libcommon_la_SOURCES = $(COMMON)
|
||||
|
||||
test_endswap_SOURCES = test_endswap.c
|
||||
FILESPECIFIC = aiff.c au.c au_g72x.c ircam.c macbinary3.c macos.c mat4.c mat5.c \
|
||||
nist.c paf.c pvf.c raw.c svx.c voc.c htk.c dwd.c ogg.c rx2.c \
|
||||
sd2.c sds.c txw.c wve.c w64.c wav_w64.c wav.c xi.c
|
||||
|
||||
libsndfile_la_SOURCES = $(COMMON) $(FILESPECIFIC) $(noinst_HEADERS) sndfile.h
|
||||
libsndfile_la_LDFLAGS = -version-info @SHARED_VERSION_INFO@ @SHLIB_VERSION_ARG@
|
||||
libsndfile_la_LIBADD = GSM610/libgsm.la G72x/libg72x.la -lm
|
||||
|
||||
test_file_io_CFLAGS = $(AM_CFLAGS)
|
||||
test_file_io_SOURCES = test_file_io.c
|
||||
test_file_io_LDADD = libcommon.la
|
||||
test_file_io_SOURCES = file_io.c test_file_io.c
|
||||
|
||||
test_log_printf_CFLAGS = $(AM_CFLAGS)
|
||||
test_log_printf_SOURCES = test_log_printf.c
|
||||
test_log_printf_LDADD = libcommon.la
|
||||
|
||||
test_conversions_CFLAGS = $(AM_CFLAGS)
|
||||
test_conversions_SOURCES = test_conversions.c
|
||||
test_conversions_LDADD = libcommon.la
|
||||
|
||||
test_audio_detect_CFLAGS = $(AM_CFLAGS)
|
||||
test_audio_detect_SOURCES = test_audio_detect.c
|
||||
test_audio_detect_LDADD = libcommon.la
|
||||
|
||||
test_endswap.c: test_endswap.def test_endswap.tpl
|
||||
autogen --writable test_endswap.def
|
||||
|
||||
genfiles : test_endswap.c Symbols.linux Symbols.darwin libsndfile.def cygsndfile.def
|
||||
|
||||
# Two test programs.
|
||||
# It is not possible to place these in the tests/ directory because they
|
||||
# need access to the internals of the SF_PRIVATE struct.
|
||||
|
||||
check: test_endswap test_file_io test_conversions test_log_printf
|
||||
check: test_file_io
|
||||
@echo
|
||||
@echo
|
||||
@echo
|
||||
@echo "============================================================"
|
||||
@if [ -x /usr/bin/python2.4 ]; then $(srcdir)/binheader_writef_check.py $(srcdir)/*.c ; fi
|
||||
./test_endswap
|
||||
./test_file_io
|
||||
./test_conversions
|
||||
./test_log_printf
|
||||
./test_audio_detect
|
||||
@echo "============================================================"
|
||||
@echo
|
||||
@echo
|
||||
@echo
|
||||
|
||||
#======================================================================
|
||||
# Generate an OS specific Symbols files. This is done when the author
|
||||
# builds the distribution tarball. There should be not need for the
|
||||
# end user to create these files.
|
||||
# Generate an OS specific Symbols file.
|
||||
Symbols: create_symbols_file.sh
|
||||
$(SHELL) $(srcdir)/create_symbols_file.sh $(target_os) $(VERSION) > Symbols
|
||||
|
||||
Symbols.linux: create_symbols_file.py
|
||||
./create_symbols_file.py linux $(VERSION) > Symbols.linux
|
||||
|
||||
Symbols.darwin: create_symbols_file.py
|
||||
./create_symbols_file.py darwin $(VERSION) > Symbols.darwin
|
||||
|
||||
libsndfile.def: create_symbols_file.py
|
||||
./create_symbols_file.py win32 $(VERSION) > libsndfile.def
|
||||
|
||||
cygsndfile.def: create_symbols_file.py
|
||||
./create_symbols_file.py cygwin $(VERSION) > cygsndfile.def
|
||||
|
||||
# Fake dependancy to force the creation of these files.
|
||||
sndfile.o : Symbols.linux Symbols.darwin libsndfile.def cygsndfile.def
|
||||
|
||||
#======================================================================
|
||||
# Disable autoheader.
|
||||
# Disable autoheader.
|
||||
AUTOHEADER=echo
|
||||
|
||||
# Dependancies.
|
||||
|
||||
aiff.c au.c g72x.c ircam.c mat4.c mat5.c nist.c paf.c pvf.c : sndfile.h common.h
|
||||
sndfile.c : Symbols
|
||||
|
||||
aiff.c au.c au_g72x.c ircam.c mat4.c mat5.c nist.c paf.c pvf.c : sndfile.h common.h
|
||||
raw.c svx.c voc.c w64.c wav.c wav_w64.c htk.c sd2.c rx2.c txw.c : sndfile.h common.h
|
||||
sds.c wve.c dwd.c ogg.c xi.c sndfile.c common.c file_io.c : sndfile.h common.h
|
||||
command.c pcm.c ulaw.c alaw.c float32.c double64.c ima_adpcm.c : sndfile.h common.h
|
||||
ms_adpcm.c gsm610.c dwvw.c vox_adpcm.c interleave.c strings.c : sndfile.h common.h
|
||||
dither.c : sndfile.h common.h
|
||||
command.c pcm.c ulaw.c alaw.c float32.c double64.c ima_adpcm.c : sndfile.h common.h
|
||||
ms_adpcm.c gsm610.c dwvw.c sfendian.c vox_adpcm.c interleave.c : sndfile.h common.h
|
||||
strings.c dither.c : sndfile.h common.h
|
||||
|
||||
## Do not edit or modify anything in this comment block.
|
||||
## The arch-tag line is a file identity tag for the GNU Arch
|
||||
## The arch-tag line is a file identity tag for the GNU Arch
|
||||
## revision control system.
|
||||
##
|
||||
## arch-tag: fc3511e6-4230-4bcb-9c86-f728d7a06fe7
|
||||
|
719
src/aiff.c
719
src/aiff.c
File diff suppressed because it is too large
Load Diff
827
src/alaw.c
827
src/alaw.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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
|
||||
@ -20,25 +20,25 @@
|
||||
#include "float_cast.h"
|
||||
#include "common.h"
|
||||
|
||||
static sf_count_t alaw_read_alaw2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
|
||||
static sf_count_t alaw_read_alaw2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
static sf_count_t alaw_read_alaw2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
static sf_count_t alaw_read_alaw2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
static sf_count_t alaw_read_alaw2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
|
||||
static sf_count_t alaw_read_alaw2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
static sf_count_t alaw_read_alaw2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
static sf_count_t alaw_read_alaw2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
|
||||
static sf_count_t alaw_write_s2alaw (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ;
|
||||
static sf_count_t alaw_write_i2alaw (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ;
|
||||
static sf_count_t alaw_write_f2alaw (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ;
|
||||
static sf_count_t alaw_write_d2alaw (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
|
||||
static sf_count_t alaw_write_s2alaw (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
|
||||
static sf_count_t alaw_write_i2alaw (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
static sf_count_t alaw_write_f2alaw (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
static sf_count_t alaw_write_d2alaw (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
|
||||
static void alaw2s_array (unsigned char *buffer, int count, short *ptr) ;
|
||||
static void alaw2i_array (unsigned char *buffer, int count, int *ptr) ;
|
||||
static void alaw2f_array (unsigned char *buffer, int count, float *ptr, float normfact) ;
|
||||
static void alaw2d_array (unsigned char *buffer, int count, double *ptr, double normfact) ;
|
||||
static void alaw2s_array (unsigned char *buffer, unsigned int count, short *ptr) ;
|
||||
static void alaw2i_array (unsigned char *buffer, unsigned int count, int *ptr) ;
|
||||
static void alaw2f_array (unsigned char *buffer, unsigned int count, float *ptr, float normfact) ;
|
||||
static void alaw2d_array (unsigned char *buffer, unsigned int count, double *ptr, double normfact) ;
|
||||
|
||||
static void s2alaw_array (const short *buffer, int count, unsigned char *ptr) ;
|
||||
static void i2alaw_array (const int *buffer, int count, unsigned char *ptr) ;
|
||||
static void f2alaw_array (const float *buffer, int count, unsigned char *ptr, float normfact) ;
|
||||
static void d2alaw_array (const double *buffer, int count, unsigned char *ptr, double normfact) ;
|
||||
static void s2alaw_array (short *buffer, unsigned int count, unsigned char *ptr) ;
|
||||
static void i2alaw_array (int *buffer, unsigned int count, unsigned char *ptr) ;
|
||||
static void f2alaw_array (float *buffer, unsigned int count, unsigned char *ptr, float normfact) ;
|
||||
static void d2alaw_array (double *buffer, unsigned int count, unsigned char *ptr, double normfact) ;
|
||||
|
||||
|
||||
int
|
||||
@ -61,8 +61,10 @@ alaw_init (SF_PRIVATE *psf)
|
||||
psf->bytewidth = 1 ;
|
||||
psf->blockwidth = psf->sf.channels ;
|
||||
|
||||
|
||||
if (psf->filelength > psf->dataoffset)
|
||||
psf->datalength = (psf->dataend) ? psf->dataend - psf->dataoffset : psf->filelength - psf->dataoffset ;
|
||||
psf->datalength = (psf->dataend) ? psf->dataend - psf->dataoffset :
|
||||
psf->filelength - psf->dataoffset ;
|
||||
else
|
||||
psf->datalength = 0 ;
|
||||
|
||||
@ -71,12 +73,190 @@ alaw_init (SF_PRIVATE *psf)
|
||||
return 0 ;
|
||||
} /* alaw_init */
|
||||
|
||||
/*==============================================================================
|
||||
static sf_count_t
|
||||
alaw_read_alaw2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (char) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->buffer, 1, readcount, psf) ;
|
||||
alaw2s_array ((unsigned char*) (psf->buffer), thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* alaw_read_alaw2s */
|
||||
|
||||
static sf_count_t
|
||||
alaw_read_alaw2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (char) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->buffer, 1, readcount, psf) ;
|
||||
alaw2i_array ((unsigned char*) (psf->buffer), thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* alaw_read_alaw2i */
|
||||
|
||||
static sf_count_t
|
||||
alaw_read_alaw2f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
sf_count_t total = 0 ;
|
||||
float normfact ;
|
||||
|
||||
normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ;
|
||||
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (char) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->buffer, 1, readcount, psf) ;
|
||||
alaw2f_array ((unsigned char*) (psf->buffer), thisread, ptr + total, normfact) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* alaw_read_alaw2f */
|
||||
|
||||
static sf_count_t
|
||||
alaw_read_alaw2d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
sf_count_t total = 0 ;
|
||||
double normfact ;
|
||||
|
||||
normfact = (psf->norm_double) ? 1.0 / ((double) 0x8000) : 1.0 ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (char) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->buffer, 1, readcount, psf) ;
|
||||
alaw2d_array ((unsigned char*) (psf->buffer), thisread, ptr + total, normfact) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* alaw_read_alaw2d */
|
||||
|
||||
/*=============================================================================================
|
||||
*/
|
||||
|
||||
static sf_count_t
|
||||
alaw_write_s2alaw (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (char) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
s2alaw_array (ptr + total, writecount, (unsigned char*) (psf->buffer)) ;
|
||||
thiswrite = psf_fwrite (psf->buffer, 1, writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
break ;
|
||||
|
||||
len -= thiswrite ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* alaw_write_s2alaw */
|
||||
|
||||
static sf_count_t
|
||||
alaw_write_i2alaw (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (char) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
i2alaw_array (ptr + total, writecount, (unsigned char*) (psf->buffer)) ;
|
||||
thiswrite = psf_fwrite (psf->buffer, 1, writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
break ;
|
||||
|
||||
len -= thiswrite ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* alaw_write_i2alaw */
|
||||
|
||||
static sf_count_t
|
||||
alaw_write_f2alaw (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
float normfact ;
|
||||
|
||||
normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ;
|
||||
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (char) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
f2alaw_array (ptr + total, writecount, (unsigned char*) (psf->buffer), normfact) ;
|
||||
thiswrite = psf_fwrite (psf->buffer, 1, writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
break ;
|
||||
|
||||
len -= thiswrite ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* alaw_write_f2alaw */
|
||||
|
||||
static sf_count_t
|
||||
alaw_write_d2alaw (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
double normfact ;
|
||||
|
||||
normfact = (psf->norm_double) ? (1.0 * 0x7FFF) : 1.0 ;
|
||||
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (char) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
d2alaw_array (ptr + total, writecount, (unsigned char*) (psf->buffer), normfact) ;
|
||||
thiswrite = psf_fwrite (psf->buffer, 1, writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
break ;
|
||||
|
||||
len -= thiswrite ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* alaw_write_d2alaw */
|
||||
|
||||
/*=============================================================================================
|
||||
* Private static functions and data.
|
||||
*/
|
||||
|
||||
static
|
||||
short alaw_decode [256] =
|
||||
short alaw_decode [128] =
|
||||
{ -5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736,
|
||||
-7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784,
|
||||
-2752, -2624, -3008, -2880, -2240, -2112, -2496, -2368,
|
||||
@ -92,49 +272,33 @@ short alaw_decode [256] =
|
||||
-1376, -1312, -1504, -1440, -1120, -1056, -1248, -1184,
|
||||
-1888, -1824, -2016, -1952, -1632, -1568, -1760, -1696,
|
||||
-688, -656, -752, -720, -560, -528, -624, -592,
|
||||
-944, -912, -1008, -976, -816, -784, -880, -848,
|
||||
5504, 5248, 6016, 5760, 4480, 4224, 4992, 4736,
|
||||
7552, 7296, 8064, 7808, 6528, 6272, 7040, 6784,
|
||||
2752, 2624, 3008, 2880, 2240, 2112, 2496, 2368,
|
||||
3776, 3648, 4032, 3904, 3264, 3136, 3520, 3392,
|
||||
22016, 20992, 24064, 23040, 17920, 16896, 19968, 18944,
|
||||
30208, 29184, 32256, 31232, 26112, 25088, 28160, 27136,
|
||||
11008, 10496, 12032, 11520, 8960, 8448, 9984, 9472,
|
||||
15104, 14592, 16128, 15616, 13056, 12544, 14080, 13568,
|
||||
344, 328, 376, 360, 280, 264, 312, 296,
|
||||
472, 456, 504, 488, 408, 392, 440, 424,
|
||||
88, 72, 120, 104, 24, 8, 56, 40,
|
||||
216, 200, 248, 232, 152, 136, 184, 168,
|
||||
1376, 1312, 1504, 1440, 1120, 1056, 1248, 1184,
|
||||
1888, 1824, 2016, 1952, 1632, 1568, 1760, 1696,
|
||||
688, 656, 752, 720, 560, 528, 624, 592,
|
||||
944, 912, 1008, 976, 816, 784, 880, 848
|
||||
-944, -912, -1008, -976, -816, -784, -880, -848
|
||||
} ; /* alaw_decode */
|
||||
|
||||
static
|
||||
unsigned char alaw_encode [2048 + 1] =
|
||||
{ 0xd5, 0xd4, 0xd7, 0xd6, 0xd1, 0xd0, 0xd3, 0xd2, 0xdd, 0xdc, 0xdf, 0xde,
|
||||
0xd9, 0xd8, 0xdb, 0xda, 0xc5, 0xc4, 0xc7, 0xc6, 0xc1, 0xc0, 0xc3, 0xc2,
|
||||
0xcd, 0xcc, 0xcf, 0xce, 0xc9, 0xc8, 0xcb, 0xca, 0xf5, 0xf5, 0xf4, 0xf4,
|
||||
0xf7, 0xf7, 0xf6, 0xf6, 0xf1, 0xf1, 0xf0, 0xf0, 0xf3, 0xf3, 0xf2, 0xf2,
|
||||
0xfd, 0xfd, 0xfc, 0xfc, 0xff, 0xff, 0xfe, 0xfe, 0xf9, 0xf9, 0xf8, 0xf8,
|
||||
0xfb, 0xfb, 0xfa, 0xfa, 0xe5, 0xe5, 0xe5, 0xe5, 0xe4, 0xe4, 0xe4, 0xe4,
|
||||
0xe7, 0xe7, 0xe7, 0xe7, 0xe6, 0xe6, 0xe6, 0xe6, 0xe1, 0xe1, 0xe1, 0xe1,
|
||||
0xe0, 0xe0, 0xe0, 0xe0, 0xe3, 0xe3, 0xe3, 0xe3, 0xe2, 0xe2, 0xe2, 0xe2,
|
||||
0xed, 0xed, 0xed, 0xed, 0xec, 0xec, 0xec, 0xec, 0xef, 0xef, 0xef, 0xef,
|
||||
0xee, 0xee, 0xee, 0xee, 0xe9, 0xe9, 0xe9, 0xe9, 0xe8, 0xe8, 0xe8, 0xe8,
|
||||
0xeb, 0xeb, 0xeb, 0xeb, 0xea, 0xea, 0xea, 0xea, 0x95, 0x95, 0x95, 0x95,
|
||||
unsigned char alaw_encode [2049] =
|
||||
{ 0xD5, 0xD4, 0xD7, 0xD6, 0xD1, 0xD0, 0xD3, 0xD2, 0xDD, 0xDC, 0xDF, 0xDE,
|
||||
0xD9, 0xD8, 0xDB, 0xDA, 0xC5, 0xC4, 0xC7, 0xC6, 0xC1, 0xC0, 0xC3, 0xC2,
|
||||
0xCD, 0xCC, 0xCF, 0xCE, 0xC9, 0xC8, 0xCB, 0xCA, 0xF5, 0xF5, 0xF4, 0xF4,
|
||||
0xF7, 0xF7, 0xF6, 0xF6, 0xF1, 0xF1, 0xF0, 0xF0, 0xF3, 0xF3, 0xF2, 0xF2,
|
||||
0xFD, 0xFD, 0xFC, 0xFC, 0xFF, 0xFF, 0xFE, 0xFE, 0xF9, 0xF9, 0xF8, 0xF8,
|
||||
0xFB, 0xFB, 0xFA, 0xFA, 0xE5, 0xE5, 0xE5, 0xE5, 0xE4, 0xE4, 0xE4, 0xE4,
|
||||
0xE7, 0xE7, 0xE7, 0xE7, 0xE6, 0xE6, 0xE6, 0xE6, 0xE1, 0xE1, 0xE1, 0xE1,
|
||||
0xE0, 0xE0, 0xE0, 0xE0, 0xE3, 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2, 0xE2,
|
||||
0xED, 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEF, 0xEF, 0xEF, 0xEF,
|
||||
0xEE, 0xEE, 0xEE, 0xEE, 0xE9, 0xE9, 0xE9, 0xE9, 0xE8, 0xE8, 0xE8, 0xE8,
|
||||
0xEB, 0xEB, 0xEB, 0xEB, 0xEA, 0xEA, 0xEA, 0xEA, 0x95, 0x95, 0x95, 0x95,
|
||||
0x95, 0x95, 0x95, 0x95, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94,
|
||||
0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x96, 0x96, 0x96, 0x96,
|
||||
0x96, 0x96, 0x96, 0x96, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91,
|
||||
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x93, 0x93, 0x93, 0x93,
|
||||
0x93, 0x93, 0x93, 0x93, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92,
|
||||
0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9c, 0x9c, 0x9c, 0x9c,
|
||||
0x9c, 0x9c, 0x9c, 0x9c, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f,
|
||||
0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x99, 0x99, 0x99, 0x99,
|
||||
0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9C, 0x9C, 0x9C, 0x9C,
|
||||
0x9C, 0x9C, 0x9C, 0x9C, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F,
|
||||
0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x99, 0x99, 0x99, 0x99,
|
||||
0x99, 0x99, 0x99, 0x99, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98,
|
||||
0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9a, 0x9a, 0x9a, 0x9a,
|
||||
0x9a, 0x9a, 0x9a, 0x9a, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85,
|
||||
0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9A, 0x9A, 0x9A, 0x9A,
|
||||
0x9A, 0x9A, 0x9A, 0x9A, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85,
|
||||
0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x84, 0x84, 0x84, 0x84,
|
||||
0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84,
|
||||
0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87,
|
||||
@ -145,396 +309,235 @@ unsigned char alaw_encode [2048 + 1] =
|
||||
0x80, 0x80, 0x80, 0x80, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83,
|
||||
0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x82, 0x82, 0x82, 0x82,
|
||||
0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82,
|
||||
0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d,
|
||||
0x8d, 0x8d, 0x8d, 0x8d, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c,
|
||||
0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8f, 0x8f, 0x8f, 0x8f,
|
||||
0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f,
|
||||
0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e,
|
||||
0x8e, 0x8e, 0x8e, 0x8e, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89,
|
||||
0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D,
|
||||
0x8D, 0x8D, 0x8D, 0x8D, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C,
|
||||
0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8F, 0x8F, 0x8F, 0x8F,
|
||||
0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F,
|
||||
0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E,
|
||||
0x8E, 0x8E, 0x8E, 0x8E, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89,
|
||||
0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x88, 0x88, 0x88, 0x88,
|
||||
0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
|
||||
0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b,
|
||||
0x8b, 0x8b, 0x8b, 0x8b, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a,
|
||||
0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0xb5, 0xb5, 0xb5, 0xb5,
|
||||
0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5,
|
||||
0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5,
|
||||
0xb5, 0xb5, 0xb5, 0xb5, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4,
|
||||
0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4,
|
||||
0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4,
|
||||
0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7,
|
||||
0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7,
|
||||
0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb6, 0xb6, 0xb6, 0xb6,
|
||||
0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6,
|
||||
0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6,
|
||||
0xb6, 0xb6, 0xb6, 0xb6, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1,
|
||||
0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1,
|
||||
0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1,
|
||||
0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0,
|
||||
0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0,
|
||||
0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb3, 0xb3, 0xb3, 0xb3,
|
||||
0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3,
|
||||
0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3,
|
||||
0xb3, 0xb3, 0xb3, 0xb3, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2,
|
||||
0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2,
|
||||
0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2,
|
||||
0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd,
|
||||
0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd,
|
||||
0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbc, 0xbc, 0xbc, 0xbc,
|
||||
0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc,
|
||||
0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc,
|
||||
0xbc, 0xbc, 0xbc, 0xbc, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf,
|
||||
0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf,
|
||||
0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf,
|
||||
0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe,
|
||||
0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe,
|
||||
0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xb9, 0xb9, 0xb9, 0xb9,
|
||||
0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9,
|
||||
0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9,
|
||||
0xb9, 0xb9, 0xb9, 0xb9, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8,
|
||||
0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8,
|
||||
0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8,
|
||||
0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb,
|
||||
0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb,
|
||||
0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xba, 0xba, 0xba, 0xba,
|
||||
0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba,
|
||||
0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba,
|
||||
0xba, 0xba, 0xba, 0xba, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5,
|
||||
0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5,
|
||||
0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5,
|
||||
0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5,
|
||||
0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5,
|
||||
0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa4, 0xa4, 0xa4, 0xa4,
|
||||
0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4,
|
||||
0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4,
|
||||
0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4,
|
||||
0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4,
|
||||
0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4,
|
||||
0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7,
|
||||
0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7,
|
||||
0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7,
|
||||
0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7,
|
||||
0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7,
|
||||
0xa7, 0xa7, 0xa7, 0xa7, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6,
|
||||
0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6,
|
||||
0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6,
|
||||
0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6,
|
||||
0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6,
|
||||
0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa1, 0xa1, 0xa1, 0xa1,
|
||||
0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1,
|
||||
0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1,
|
||||
0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1,
|
||||
0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1,
|
||||
0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1,
|
||||
0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0,
|
||||
0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0,
|
||||
0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0,
|
||||
0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0,
|
||||
0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0,
|
||||
0xa0, 0xa0, 0xa0, 0xa0, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa2, 0xa2, 0xa2, 0xa2,
|
||||
0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2,
|
||||
0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2,
|
||||
0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2,
|
||||
0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2,
|
||||
0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2,
|
||||
0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad,
|
||||
0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad,
|
||||
0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad,
|
||||
0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad,
|
||||
0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad,
|
||||
0xad, 0xad, 0xad, 0xad, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac,
|
||||
0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac,
|
||||
0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac,
|
||||
0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac,
|
||||
0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac,
|
||||
0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xaf, 0xaf, 0xaf, 0xaf,
|
||||
0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf,
|
||||
0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf,
|
||||
0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf,
|
||||
0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf,
|
||||
0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf,
|
||||
0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae,
|
||||
0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae,
|
||||
0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae,
|
||||
0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae,
|
||||
0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae,
|
||||
0xae, 0xae, 0xae, 0xae, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9,
|
||||
0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9,
|
||||
0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9,
|
||||
0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9,
|
||||
0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9,
|
||||
0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa8, 0xa8, 0xa8, 0xa8,
|
||||
0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8,
|
||||
0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8,
|
||||
0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8,
|
||||
0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8,
|
||||
0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8,
|
||||
0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab,
|
||||
0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab,
|
||||
0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab,
|
||||
0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab,
|
||||
0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab,
|
||||
0xab, 0xab, 0xab, 0xab, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
|
||||
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
|
||||
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
|
||||
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
|
||||
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
|
||||
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x2a
|
||||
0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B,
|
||||
0x8B, 0x8B, 0x8B, 0x8B, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A,
|
||||
0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0xB5, 0xB5, 0xB5, 0xB5,
|
||||
0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5,
|
||||
0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5,
|
||||
0xB5, 0xB5, 0xB5, 0xB5, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4,
|
||||
0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4,
|
||||
0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4,
|
||||
0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7,
|
||||
0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7,
|
||||
0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB6, 0xB6, 0xB6, 0xB6,
|
||||
0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6,
|
||||
0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6,
|
||||
0xB6, 0xB6, 0xB6, 0xB6, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1,
|
||||
0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1,
|
||||
0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1,
|
||||
0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0,
|
||||
0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0,
|
||||
0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB3, 0xB3, 0xB3, 0xB3,
|
||||
0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3,
|
||||
0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3,
|
||||
0xB3, 0xB3, 0xB3, 0xB3, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2,
|
||||
0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2,
|
||||
0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2,
|
||||
0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD,
|
||||
0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD,
|
||||
0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBC, 0xBC, 0xBC, 0xBC,
|
||||
0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC,
|
||||
0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC,
|
||||
0xBC, 0xBC, 0xBC, 0xBC, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF,
|
||||
0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF,
|
||||
0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF,
|
||||
0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE,
|
||||
0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE,
|
||||
0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xB9, 0xB9, 0xB9, 0xB9,
|
||||
0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9,
|
||||
0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9,
|
||||
0xB9, 0xB9, 0xB9, 0xB9, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8,
|
||||
0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8,
|
||||
0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8,
|
||||
0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB,
|
||||
0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB,
|
||||
0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBA, 0xBA, 0xBA, 0xBA,
|
||||
0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA,
|
||||
0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA,
|
||||
0xBA, 0xBA, 0xBA, 0xBA, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5,
|
||||
0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5,
|
||||
0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5,
|
||||
0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5,
|
||||
0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5,
|
||||
0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA4, 0xA4, 0xA4, 0xA4,
|
||||
0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4,
|
||||
0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4,
|
||||
0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4,
|
||||
0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4,
|
||||
0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4,
|
||||
0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7,
|
||||
0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7,
|
||||
0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7,
|
||||
0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7,
|
||||
0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7,
|
||||
0xA7, 0xA7, 0xA7, 0xA7, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6,
|
||||
0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6,
|
||||
0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6,
|
||||
0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6,
|
||||
0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6,
|
||||
0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA1, 0xA1, 0xA1, 0xA1,
|
||||
0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1,
|
||||
0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1,
|
||||
0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1,
|
||||
0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1,
|
||||
0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1,
|
||||
0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0,
|
||||
0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0,
|
||||
0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0,
|
||||
0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0,
|
||||
0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0,
|
||||
0xA0, 0xA0, 0xA0, 0xA0, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
|
||||
0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
|
||||
0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
|
||||
0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
|
||||
0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
|
||||
0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA2, 0xA2, 0xA2, 0xA2,
|
||||
0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2,
|
||||
0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2,
|
||||
0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2,
|
||||
0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2,
|
||||
0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2,
|
||||
0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD,
|
||||
0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD,
|
||||
0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD,
|
||||
0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD,
|
||||
0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD,
|
||||
0xAD, 0xAD, 0xAD, 0xAD, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC,
|
||||
0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC,
|
||||
0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC,
|
||||
0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC,
|
||||
0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC,
|
||||
0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAF, 0xAF, 0xAF, 0xAF,
|
||||
0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF,
|
||||
0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF,
|
||||
0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF,
|
||||
0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF,
|
||||
0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF,
|
||||
0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE,
|
||||
0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE,
|
||||
0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE,
|
||||
0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE,
|
||||
0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE,
|
||||
0xAE, 0xAE, 0xAE, 0xAE, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9,
|
||||
0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9,
|
||||
0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9,
|
||||
0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9,
|
||||
0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9,
|
||||
0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA8, 0xA8, 0xA8, 0xA8,
|
||||
0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8,
|
||||
0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8,
|
||||
0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8,
|
||||
0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8,
|
||||
0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8,
|
||||
0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB,
|
||||
0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB,
|
||||
0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB,
|
||||
0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB,
|
||||
0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB,
|
||||
0xAB, 0xAB, 0xAB, 0xAB, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
|
||||
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
|
||||
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
|
||||
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
|
||||
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
|
||||
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0x2A
|
||||
} ; /* alaw_encode */
|
||||
|
||||
static inline void
|
||||
alaw2s_array (unsigned char *buffer, int count, short *ptr)
|
||||
{ while (--count >= 0)
|
||||
ptr [count] = alaw_decode [(int) buffer [count]] ;
|
||||
static void
|
||||
alaw2s_array (unsigned char *buffer, unsigned int count, short *ptr)
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
if (buffer [count] & 0x80)
|
||||
ptr [count] = -1 * alaw_decode [((int) buffer [count]) & 0x7F] ;
|
||||
else
|
||||
ptr [count] = alaw_decode [((int) buffer [count]) & 0x7F] ;
|
||||
} ;
|
||||
} /* alaw2s_array */
|
||||
|
||||
static inline void
|
||||
alaw2i_array (unsigned char *buffer, int count, int *ptr)
|
||||
{ while (--count >= 0)
|
||||
ptr [count] = alaw_decode [(int) buffer [count]] << 16 ;
|
||||
static void
|
||||
alaw2i_array (unsigned char *buffer, unsigned int count, int *ptr)
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
if (buffer [count] & 0x80)
|
||||
ptr [count] = (-1 * alaw_decode [((int) buffer [count]) & 0x7F]) << 16 ;
|
||||
else
|
||||
ptr [count] = alaw_decode [((int) buffer [count]) & 0x7F] << 16 ;
|
||||
} ;
|
||||
} /* alaw2i_array */
|
||||
|
||||
static inline void
|
||||
alaw2f_array (unsigned char *buffer, int count, float *ptr, float normfact)
|
||||
{ while (--count >= 0)
|
||||
ptr [count] = normfact * alaw_decode [(int) buffer [count]] ;
|
||||
static void
|
||||
alaw2f_array (unsigned char *buffer, unsigned int count, float *ptr, float normfact)
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
if (buffer [count] & 0x80)
|
||||
ptr [count] = -normfact * alaw_decode [((int) buffer [count]) & 0x7F] ;
|
||||
else
|
||||
ptr [count] = normfact * alaw_decode [((int) buffer [count]) & 0x7F] ;
|
||||
} ;
|
||||
} /* alaw2f_array */
|
||||
|
||||
static inline void
|
||||
alaw2d_array (unsigned char *buffer, int count, double *ptr, double normfact)
|
||||
{ while (--count >= 0)
|
||||
ptr [count] = normfact * alaw_decode [(int) buffer [count]] ;
|
||||
static void
|
||||
alaw2d_array (unsigned char *buffer, unsigned int count, double *ptr, double normfact)
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
if (buffer [count] & 0x80)
|
||||
ptr [count] = -normfact * alaw_decode [((int) buffer [count]) & 0x7F] ;
|
||||
else
|
||||
ptr [count] = normfact * alaw_decode [((int) buffer [count]) & 0x7F] ;
|
||||
} ;
|
||||
} /* alaw2d_array */
|
||||
|
||||
static inline void
|
||||
s2alaw_array (const short *ptr, int count, unsigned char *buffer)
|
||||
{ while (--count >= 0)
|
||||
{ if (ptr [count] >= 0)
|
||||
static void
|
||||
s2alaw_array (short *ptr, unsigned int count, unsigned char *buffer)
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
if (ptr [count] >= 0)
|
||||
buffer [count] = alaw_encode [ptr [count] / 16] ;
|
||||
else
|
||||
buffer [count] = 0x7F & alaw_encode [ptr [count] / -16] ;
|
||||
} ;
|
||||
} /* s2alaw_array */
|
||||
|
||||
static inline void
|
||||
i2alaw_array (const int *ptr, int count, unsigned char *buffer)
|
||||
{ while (--count >= 0)
|
||||
{ if (ptr [count] >= 0)
|
||||
static void
|
||||
i2alaw_array (int *ptr, unsigned int count, unsigned char *buffer)
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
if (ptr [count] >= 0)
|
||||
buffer [count] = alaw_encode [ptr [count] >> (16 + 4)] ;
|
||||
else
|
||||
buffer [count] = 0x7F & alaw_encode [- ptr [count] >> (16 + 4)] ;
|
||||
} ;
|
||||
} /* i2alaw_array */
|
||||
|
||||
static inline void
|
||||
f2alaw_array (const float *ptr, int count, unsigned char *buffer, float normfact)
|
||||
{ while (--count >= 0)
|
||||
{ if (ptr [count] >= 0)
|
||||
buffer [count] = alaw_encode [lrintf (normfact * ptr [count])] ;
|
||||
static void
|
||||
f2alaw_array (float *ptr, unsigned int count, unsigned char *buffer, float normfact)
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
if (ptr [count] >= 0)
|
||||
buffer [count] = alaw_encode [(lrintf (normfact * ptr [count])) / 16] ;
|
||||
else
|
||||
buffer [count] = 0x7F & alaw_encode [- lrintf (normfact * ptr [count])] ;
|
||||
buffer [count] = 0x7F & alaw_encode [(lrintf (normfact * ptr [count])) / -16] ;
|
||||
} ;
|
||||
} /* f2alaw_array */
|
||||
|
||||
static inline void
|
||||
d2alaw_array (const double *ptr, int count, unsigned char *buffer, double normfact)
|
||||
{ while (--count >= 0)
|
||||
{ if (ptr [count] >= 0)
|
||||
buffer [count] = alaw_encode [lrint (normfact * ptr [count])] ;
|
||||
static void
|
||||
d2alaw_array (double *ptr, unsigned int count, unsigned char *buffer, double normfact)
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
if (ptr [count] >= 0)
|
||||
buffer [count] = alaw_encode [(lrint (normfact * ptr [count])) / 16] ;
|
||||
else
|
||||
buffer [count] = 0x7F & alaw_encode [- lrint (normfact * ptr [count])] ;
|
||||
buffer [count] = 0x7F & alaw_encode [(lrint (normfact * ptr [count])) / -16] ;
|
||||
} ;
|
||||
} /* d2alaw_array */
|
||||
|
||||
/*==============================================================================
|
||||
*/
|
||||
|
||||
static sf_count_t
|
||||
alaw_read_alaw2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->u.ucbuf, 1, bufferlen, psf) ;
|
||||
alaw2s_array (psf->u.ucbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* alaw_read_alaw2s */
|
||||
|
||||
static sf_count_t
|
||||
alaw_read_alaw2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->u.ucbuf, 1, bufferlen, psf) ;
|
||||
alaw2i_array (psf->u.ucbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* alaw_read_alaw2i */
|
||||
|
||||
static sf_count_t
|
||||
alaw_read_alaw2f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
float normfact ;
|
||||
|
||||
normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->u.ucbuf, 1, bufferlen, psf) ;
|
||||
alaw2f_array (psf->u.ucbuf, readcount, ptr + total, normfact) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* alaw_read_alaw2f */
|
||||
|
||||
static sf_count_t
|
||||
alaw_read_alaw2d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
double normfact ;
|
||||
|
||||
normfact = (psf->norm_double) ? 1.0 / ((double) 0x8000) : 1.0 ;
|
||||
bufferlen = ARRAY_LEN (psf->u.ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->u.ucbuf, 1, bufferlen, psf) ;
|
||||
alaw2d_array (psf->u.ucbuf, readcount, ptr + total, normfact) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* alaw_read_alaw2d */
|
||||
|
||||
/*=============================================================================================
|
||||
*/
|
||||
|
||||
static sf_count_t
|
||||
alaw_write_s2alaw (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
s2alaw_array (ptr + total, bufferlen, psf->u.ucbuf) ;
|
||||
writecount = psf_fwrite (psf->u.ucbuf, 1, bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* alaw_write_s2alaw */
|
||||
|
||||
static sf_count_t
|
||||
alaw_write_i2alaw (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
i2alaw_array (ptr + total, bufferlen, psf->u.ucbuf) ;
|
||||
writecount = psf_fwrite (psf->u.ucbuf, 1, bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* alaw_write_i2alaw */
|
||||
|
||||
static sf_count_t
|
||||
alaw_write_f2alaw (SF_PRIVATE *psf, const float *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
float normfact ;
|
||||
|
||||
normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7FFF) / 16.0 : 1.0 / 16 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
f2alaw_array (ptr + total, bufferlen, psf->u.ucbuf, normfact) ;
|
||||
writecount = psf_fwrite (psf->u.ucbuf, 1, bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* alaw_write_f2alaw */
|
||||
|
||||
static sf_count_t
|
||||
alaw_write_d2alaw (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
double normfact ;
|
||||
|
||||
normfact = (psf->norm_double) ? (1.0 * 0x7FFF) / 16.0 : 1.0 / 16.0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
d2alaw_array (ptr + total, bufferlen, psf->u.ucbuf, normfact) ;
|
||||
writecount = psf_fwrite (psf->u.ucbuf, 1, bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* alaw_write_d2alaw */
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
|
57
src/au.c
57
src/au.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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,16 +16,16 @@
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "sndfile.h"
|
||||
#include "config.h"
|
||||
#include "sfendian.h"
|
||||
#include "common.h"
|
||||
#include "au.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
** Macros to handle big/little endian issues.
|
||||
@ -129,7 +129,7 @@ au_open (SF_PRIVATE *psf)
|
||||
psf->write_header = au_write_header ;
|
||||
} ;
|
||||
|
||||
psf->container_close = au_close ;
|
||||
psf->close = au_close ;
|
||||
|
||||
psf->blockwidth = psf->bytewidth * psf->sf.channels ;
|
||||
|
||||
@ -162,17 +162,26 @@ au_open (SF_PRIVATE *psf)
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_G721_32 :
|
||||
error = g72x_init (psf) ;
|
||||
if (psf->mode == SFM_READ)
|
||||
error = au_g72x_reader_init (psf, AU_H_G721_32) ;
|
||||
else if (psf->mode == SFM_WRITE)
|
||||
error = au_g72x_writer_init (psf, AU_H_G721_32) ;
|
||||
psf->sf.seekable = SF_FALSE ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_G723_24 :
|
||||
error = g72x_init (psf) ;
|
||||
if (psf->mode == SFM_READ)
|
||||
error = au_g72x_reader_init (psf, AU_H_G723_24) ;
|
||||
else if (psf->mode == SFM_WRITE)
|
||||
error = au_g72x_writer_init (psf, AU_H_G723_24) ;
|
||||
psf->sf.seekable = SF_FALSE ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_G723_40 :
|
||||
error = g72x_init (psf) ;
|
||||
if (psf->mode == SFM_READ)
|
||||
error = au_g72x_reader_init (psf, AU_H_G723_40) ;
|
||||
else if (psf->mode == SFM_WRITE)
|
||||
error = au_g72x_writer_init (psf, AU_H_G723_40) ;
|
||||
psf->sf.seekable = SF_FALSE ;
|
||||
break ;
|
||||
/* Lite remove end */
|
||||
@ -183,6 +192,37 @@ au_open (SF_PRIVATE *psf)
|
||||
return error ;
|
||||
} /* au_open */
|
||||
|
||||
int
|
||||
au_nh_open (SF_PRIVATE *psf)
|
||||
{
|
||||
if (psf->mode == SFM_RDWR)
|
||||
return SFE_BAD_OPEN_FORMAT ;
|
||||
|
||||
if (psf_fseek (psf, psf->dataoffset, SEEK_SET))
|
||||
return SFE_BAD_SEEK ;
|
||||
|
||||
psf_log_printf (psf, "Header-less u-law encoded file.\n") ;
|
||||
psf_log_printf (psf, "Setting up for 8kHz, mono, u-law.\n") ;
|
||||
|
||||
psf->sf.format = SF_FORMAT_AU | SF_FORMAT_ULAW ;
|
||||
|
||||
psf->dataoffset = 0 ;
|
||||
psf->endian = 0 ; /* Irrelevant but it must be something. */
|
||||
psf->sf.samplerate = 8000 ;
|
||||
psf->sf.channels = 1 ;
|
||||
psf->bytewidth = 1 ; /* Before decoding */
|
||||
|
||||
ulaw_init (psf) ;
|
||||
|
||||
psf->close = au_close ;
|
||||
|
||||
psf->blockwidth = 1 ;
|
||||
psf->sf.frames = psf->filelength ;
|
||||
psf->datalength = psf->filelength - AU_DATA_OFFSET ;
|
||||
|
||||
return 0 ;
|
||||
} /* au_nh_open */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@ -294,7 +334,6 @@ au_read_header (SF_PRIVATE *psf)
|
||||
{ AU_FMT au_fmt ;
|
||||
int marker, dword ;
|
||||
|
||||
memset (&au_fmt, 0, sizeof (au_fmt)) ;
|
||||
psf_binheader_readf (psf, "pm", 0, &marker) ;
|
||||
psf_log_printf (psf, "%M\n", marker) ;
|
||||
|
||||
@ -341,6 +380,8 @@ au_read_header (SF_PRIVATE *psf)
|
||||
if (psf_ftell (psf) < psf->dataoffset)
|
||||
psf_binheader_readf (psf, "j", psf->dataoffset - psf_ftell (psf)) ;
|
||||
|
||||
psf->close = au_close ;
|
||||
|
||||
psf->sf.samplerate = au_fmt.samplerate ;
|
||||
psf->sf.channels = au_fmt.channels ;
|
||||
|
||||
|
39
src/au.h
Normal file
39
src/au.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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.
|
||||
*/
|
||||
|
||||
#ifndef AU_HEADER_FILE
|
||||
#define AU_HEADER_FILE
|
||||
|
||||
|
||||
enum
|
||||
{ AU_H_G721_32 = 200,
|
||||
AU_H_G723_24 = 201,
|
||||
AU_H_G723_40 = 202
|
||||
} ;
|
||||
|
||||
int au_g72x_reader_init (SF_PRIVATE *psf, int codec) ;
|
||||
int au_g72x_writer_init (SF_PRIVATE *psf, int codec) ;
|
||||
|
||||
#endif /* AU_HEADER_FILE */
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 63affc81-e204-4468-9705-60abe4d10689
|
||||
*/
|
634
src/au_g72x.c
Normal file
634
src/au_g72x.c
Normal file
@ -0,0 +1,634 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "sndfile.h"
|
||||
#include "sfendian.h"
|
||||
#include "float_cast.h"
|
||||
#include "common.h"
|
||||
#include "au.h"
|
||||
#include "G72x/g72x.h"
|
||||
|
||||
static int au_g72x_read_block (SF_PRIVATE *psf, G72x_DATA *pg72x, short *ptr, int len) ;
|
||||
static int au_g72x_write_block (SF_PRIVATE *psf, G72x_DATA *pg72x, short *ptr, int len) ;
|
||||
|
||||
static int au_g72x_decode_block (SF_PRIVATE *psf, G72x_DATA *pg72x) ;
|
||||
static int au_g72x_encode_block (SF_PRIVATE *psf, G72x_DATA *pg72x) ;
|
||||
|
||||
static sf_count_t au_g72x_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
|
||||
static sf_count_t au_g72x_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
static sf_count_t au_g72x_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
static sf_count_t au_g72x_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
|
||||
static sf_count_t au_g72x_write_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
|
||||
static sf_count_t au_g72x_write_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
static sf_count_t au_g72x_write_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
static sf_count_t au_g72x_write_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
|
||||
static sf_count_t au_g72x_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ;
|
||||
|
||||
static int au_g72x_close (SF_PRIVATE *psf) ;
|
||||
|
||||
|
||||
/*============================================================================================
|
||||
** WAV G721 Reader initialisation function.
|
||||
*/
|
||||
|
||||
int
|
||||
au_g72x_reader_init (SF_PRIVATE *psf, int codec)
|
||||
{ G72x_DATA *pg72x ;
|
||||
int bitspersample ;
|
||||
|
||||
psf->sf.seekable = SF_FALSE ;
|
||||
|
||||
if (psf->sf.channels != 1)
|
||||
return SFE_G72X_NOT_MONO ;
|
||||
|
||||
if (! (pg72x = malloc (sizeof (G72x_DATA))))
|
||||
return SFE_MALLOC_FAILED ;
|
||||
|
||||
psf->fdata = (void*) pg72x ;
|
||||
|
||||
pg72x->blockcount = 0 ;
|
||||
pg72x->samplecount = 0 ;
|
||||
|
||||
switch (codec)
|
||||
{ case AU_H_G721_32 :
|
||||
g72x_reader_init (pg72x, G721_32_BITS_PER_SAMPLE) ;
|
||||
pg72x->bytesperblock = G721_32_BYTES_PER_BLOCK ;
|
||||
bitspersample = G721_32_BITS_PER_SAMPLE ;
|
||||
break ;
|
||||
|
||||
case AU_H_G723_24:
|
||||
g72x_reader_init (pg72x, G723_24_BITS_PER_SAMPLE) ;
|
||||
pg72x->bytesperblock = G723_24_BYTES_PER_BLOCK ;
|
||||
bitspersample = G723_24_BITS_PER_SAMPLE ;
|
||||
break ;
|
||||
|
||||
case AU_H_G723_40:
|
||||
g72x_reader_init (pg72x, G723_40_BITS_PER_SAMPLE) ;
|
||||
pg72x->bytesperblock = G723_40_BYTES_PER_BLOCK ;
|
||||
bitspersample = G723_40_BITS_PER_SAMPLE ;
|
||||
break ;
|
||||
|
||||
default : return SFE_UNIMPLEMENTED ;
|
||||
} ;
|
||||
|
||||
psf->read_short = au_g72x_read_s ;
|
||||
psf->read_int = au_g72x_read_i ;
|
||||
psf->read_float = au_g72x_read_f ;
|
||||
psf->read_double = au_g72x_read_d ;
|
||||
|
||||
psf->seek = au_g72x_seek ;
|
||||
psf->close = au_g72x_close ;
|
||||
|
||||
psf->blockwidth = psf->bytewidth = 1 ;
|
||||
|
||||
psf->filelength = psf_get_filelen (psf) ;
|
||||
psf->datalength = psf->filelength - psf->dataoffset ;
|
||||
|
||||
if (psf->datalength % pg72x->blocksize)
|
||||
pg72x->blocks = (psf->datalength / pg72x->blocksize) + 1 ;
|
||||
else
|
||||
pg72x->blocks = psf->datalength / pg72x->blocksize ;
|
||||
|
||||
psf->sf.frames = (8 * psf->datalength) / bitspersample ;
|
||||
|
||||
if ((psf->sf.frames * bitspersample) / 8 != psf->datalength)
|
||||
psf_log_printf (psf, "*** Warning : weird psf->datalength.\n") ;
|
||||
|
||||
au_g72x_decode_block (psf, pg72x) ;
|
||||
|
||||
return 0 ;
|
||||
} /* au_g72x_reader_init */
|
||||
|
||||
/*============================================================================================
|
||||
** WAV G721 writer initialisation function.
|
||||
*/
|
||||
|
||||
int
|
||||
au_g72x_writer_init (SF_PRIVATE *psf, int codec)
|
||||
{ G72x_DATA *pg72x ;
|
||||
int bitspersample ;
|
||||
|
||||
psf->sf.seekable = SF_FALSE ;
|
||||
|
||||
if (psf->sf.channels != 1)
|
||||
return SFE_G72X_NOT_MONO ;
|
||||
|
||||
if (! (pg72x = malloc (sizeof (G72x_DATA))))
|
||||
return SFE_MALLOC_FAILED ;
|
||||
|
||||
psf->fdata = (void*) pg72x ;
|
||||
|
||||
pg72x->blockcount = 0 ;
|
||||
pg72x->samplecount = 0 ;
|
||||
|
||||
switch (codec)
|
||||
{ case AU_H_G721_32 :
|
||||
g72x_writer_init (pg72x, G721_32_BITS_PER_SAMPLE) ;
|
||||
pg72x->bytesperblock = G721_32_BYTES_PER_BLOCK ;
|
||||
bitspersample = G721_32_BITS_PER_SAMPLE ;
|
||||
break ;
|
||||
|
||||
case AU_H_G723_24:
|
||||
g72x_writer_init (pg72x, G723_24_BITS_PER_SAMPLE) ;
|
||||
pg72x->bytesperblock = G723_24_BYTES_PER_BLOCK ;
|
||||
bitspersample = G723_24_BITS_PER_SAMPLE ;
|
||||
break ;
|
||||
|
||||
case AU_H_G723_40:
|
||||
g72x_writer_init (pg72x, G723_40_BITS_PER_SAMPLE) ;
|
||||
pg72x->bytesperblock = G723_40_BYTES_PER_BLOCK ;
|
||||
bitspersample = G723_40_BITS_PER_SAMPLE ;
|
||||
break ;
|
||||
|
||||
default : return SFE_UNIMPLEMENTED ;
|
||||
} ;
|
||||
|
||||
psf->write_short = au_g72x_write_s ;
|
||||
psf->write_int = au_g72x_write_i ;
|
||||
psf->write_float = au_g72x_write_f ;
|
||||
psf->write_double = au_g72x_write_d ;
|
||||
|
||||
psf->close = au_g72x_close ;
|
||||
|
||||
psf->blockwidth = psf->bytewidth = 1 ;
|
||||
|
||||
psf->filelength = psf_get_filelen (psf) ;
|
||||
if (psf->filelength < psf->dataoffset)
|
||||
psf->filelength = psf->dataoffset ;
|
||||
|
||||
psf->datalength = psf->filelength - psf->dataoffset ;
|
||||
|
||||
if (psf->datalength % pg72x->blocksize)
|
||||
pg72x->blocks = (psf->datalength / pg72x->blocksize) + 1 ;
|
||||
else
|
||||
pg72x->blocks = psf->datalength / pg72x->blocksize ;
|
||||
|
||||
if (psf->datalength > 0)
|
||||
psf->sf.frames = (8 * psf->datalength) / bitspersample ;
|
||||
|
||||
if ((psf->sf.frames * bitspersample) / 8 != psf->datalength)
|
||||
psf_log_printf (psf, "*** Warning : weird psf->datalength.\n") ;
|
||||
|
||||
return 0 ;
|
||||
} /* au_g72x_writer_init */
|
||||
|
||||
/*============================================================================================
|
||||
** G721 Read Functions.
|
||||
*/
|
||||
|
||||
static int
|
||||
au_g72x_decode_block (SF_PRIVATE *psf, G72x_DATA *pg72x)
|
||||
{ int k ;
|
||||
|
||||
pg72x->blockcount ++ ;
|
||||
pg72x->samplecount = 0 ;
|
||||
|
||||
if (pg72x->samplecount > pg72x->blocksize)
|
||||
{ memset (pg72x->samples, 0, G72x_BLOCK_SIZE * sizeof (short)) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if ((k = psf_fread (pg72x->block, 1, pg72x->bytesperblock, psf)) != pg72x->bytesperblock)
|
||||
psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, pg72x->bytesperblock) ;
|
||||
|
||||
pg72x->blocksize = k ;
|
||||
g72x_decode_block (pg72x) ;
|
||||
|
||||
return 1 ;
|
||||
} /* au_g72x_decode_block */
|
||||
|
||||
static int
|
||||
au_g72x_read_block (SF_PRIVATE *psf, G72x_DATA *pg72x, short *ptr, int len)
|
||||
{ int count, total = 0, indx = 0 ;
|
||||
|
||||
while (indx < len)
|
||||
{ if (pg72x->blockcount >= pg72x->blocks && pg72x->samplecount >= pg72x->samplesperblock)
|
||||
{ memset (&(ptr [indx]), 0, (len - indx) * sizeof (short)) ;
|
||||
return total ;
|
||||
} ;
|
||||
|
||||
if (pg72x->samplecount >= pg72x->samplesperblock)
|
||||
au_g72x_decode_block (psf, pg72x) ;
|
||||
|
||||
count = pg72x->samplesperblock - pg72x->samplecount ;
|
||||
count = (len - indx > count) ? count : len - indx ;
|
||||
|
||||
memcpy (&(ptr [indx]), &(pg72x->samples [pg72x->samplecount]), count * sizeof (short)) ;
|
||||
indx += count ;
|
||||
pg72x->samplecount += count ;
|
||||
total = indx ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* au_g72x_read_block */
|
||||
|
||||
static sf_count_t
|
||||
au_g72x_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ G72x_DATA *pg72x ;
|
||||
int readcount, count ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pg72x = (G72x_DATA*) psf->fdata ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len > 0x10000000) ? 0x10000000 : (int) len ;
|
||||
|
||||
count = au_g72x_read_block (psf, pg72x, ptr, readcount) ;
|
||||
|
||||
total += count ;
|
||||
len -= count ;
|
||||
|
||||
if (count != readcount)
|
||||
break ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* au_g72x_read_s */
|
||||
|
||||
static sf_count_t
|
||||
au_g72x_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ G72x_DATA *pg72x ;
|
||||
short *sptr ;
|
||||
int k, bufferlen, readcount = 0, count ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pg72x = (G72x_DATA*) psf->fdata ;
|
||||
|
||||
sptr = (short*) psf->buffer ;
|
||||
bufferlen = SF_BUFFER_LEN / sizeof (short) ;
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : len ;
|
||||
count = au_g72x_read_block (psf, pg72x, sptr, readcount) ;
|
||||
|
||||
for (k = 0 ; k < readcount ; k++)
|
||||
ptr [total + k] = sptr [k] << 16 ;
|
||||
|
||||
total += count ;
|
||||
len -= readcount ;
|
||||
if (count != readcount)
|
||||
break ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* au_g72x_read_i */
|
||||
|
||||
static sf_count_t
|
||||
au_g72x_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ G72x_DATA *pg72x ;
|
||||
short *sptr ;
|
||||
int k, bufferlen, readcount = 0, count ;
|
||||
sf_count_t total = 0 ;
|
||||
float normfact ;
|
||||
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pg72x = (G72x_DATA*) psf->fdata ;
|
||||
|
||||
normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ;
|
||||
|
||||
sptr = (short*) psf->buffer ;
|
||||
bufferlen = SF_BUFFER_LEN / sizeof (short) ;
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : len ;
|
||||
count = au_g72x_read_block (psf, pg72x, sptr, readcount) ;
|
||||
for (k = 0 ; k < readcount ; k++)
|
||||
ptr [total + k] = normfact * sptr [k] ;
|
||||
|
||||
total += count ;
|
||||
len -= readcount ;
|
||||
if (count != readcount)
|
||||
break ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* au_g72x_read_f */
|
||||
|
||||
static sf_count_t
|
||||
au_g72x_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ G72x_DATA *pg72x ;
|
||||
short *sptr ;
|
||||
int k, bufferlen, readcount = 0, count ;
|
||||
sf_count_t total = 0 ;
|
||||
double normfact ;
|
||||
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pg72x = (G72x_DATA*) psf->fdata ;
|
||||
|
||||
normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x8000) : 1.0 ;
|
||||
|
||||
sptr = (short*) psf->buffer ;
|
||||
bufferlen = SF_BUFFER_LEN / sizeof (short) ;
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : len ;
|
||||
count = au_g72x_read_block (psf, pg72x, sptr, readcount) ;
|
||||
for (k = 0 ; k < readcount ; k++)
|
||||
ptr [total + k] = normfact * (double) (sptr [k]) ;
|
||||
|
||||
total += count ;
|
||||
len -= readcount ;
|
||||
if (count != readcount)
|
||||
break ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* au_g72x_read_d */
|
||||
|
||||
static sf_count_t
|
||||
au_g72x_seek (SF_PRIVATE *psf, int mode, sf_count_t offset)
|
||||
{
|
||||
/* Prevent compiler warnings. */
|
||||
mode ++ ;
|
||||
offset ++ ;
|
||||
|
||||
psf_log_printf (psf, "seek unsupported\n") ;
|
||||
|
||||
/* No simple solution. To do properly, would need to seek
|
||||
** to start of file and decode everything up to seek position.
|
||||
** Maybe implement SEEK_SET to 0 only?
|
||||
*/
|
||||
return 0 ;
|
||||
|
||||
/*
|
||||
** G72x_DATA *pg72x ;
|
||||
** int newblock, newsample, samplecount ;
|
||||
**
|
||||
** if (! psf->fdata)
|
||||
** return 0 ;
|
||||
** pg72x = (G72x_DATA*) psf->fdata ;
|
||||
**
|
||||
** if (! (psf->datalength && psf->dataoffset))
|
||||
** { psf->error = SFE_BAD_SEEK ;
|
||||
** return ((sf_count_t) -1) ;
|
||||
** } ;
|
||||
**
|
||||
** samplecount = (8 * psf->datalength) / G721_32_BITS_PER_SAMPLE ;
|
||||
**
|
||||
** switch (whence)
|
||||
** { case SEEK_SET :
|
||||
** if (offset < 0 || offset > samplecount)
|
||||
** { psf->error = SFE_BAD_SEEK ;
|
||||
** return ((sf_count_t) -1) ;
|
||||
** } ;
|
||||
** newblock = offset / pg72x->samplesperblock ;
|
||||
** newsample = offset % pg72x->samplesperblock ;
|
||||
** break ;
|
||||
**
|
||||
** case SEEK_CUR :
|
||||
** if (psf->current + offset < 0 || psf->current + offset > samplecount)
|
||||
** { psf->error = SFE_BAD_SEEK ;
|
||||
** return ((sf_count_t) -1) ;
|
||||
** } ;
|
||||
** newblock = (8 * (psf->current + offset)) / pg72x->samplesperblock ;
|
||||
** newsample = (8 * (psf->current + offset)) % pg72x->samplesperblock ;
|
||||
** break ;
|
||||
**
|
||||
** case SEEK_END :
|
||||
** if (offset > 0 || samplecount + offset < 0)
|
||||
** { psf->error = SFE_BAD_SEEK ;
|
||||
** return ((sf_count_t) -1) ;
|
||||
** } ;
|
||||
** newblock = (samplecount + offset) / pg72x->samplesperblock ;
|
||||
** newsample = (samplecount + offset) % pg72x->samplesperblock ;
|
||||
** break ;
|
||||
**
|
||||
** default :
|
||||
** psf->error = SFE_BAD_SEEK ;
|
||||
** return ((sf_count_t) -1) ;
|
||||
** } ;
|
||||
**
|
||||
** if (psf->mode == SFM_READ)
|
||||
** { psf_fseek (psf, psf->dataoffset + newblock * pg72x->blocksize, SEEK_SET) ;
|
||||
** pg72x->blockcount = newblock ;
|
||||
** au_g72x_decode_block (psf, pg72x) ;
|
||||
** pg72x->samplecount = newsample ;
|
||||
** }
|
||||
** else
|
||||
** { /+* What to do about write??? *+/
|
||||
** psf->error = SFE_BAD_SEEK ;
|
||||
** return ((sf_count_t) -1) ;
|
||||
** } ;
|
||||
**
|
||||
** psf->current = newblock * pg72x->samplesperblock + newsample ;
|
||||
** return psf->current ;
|
||||
**
|
||||
*/
|
||||
} /* au_g72x_seek */
|
||||
|
||||
/*==========================================================================================
|
||||
** G72x Write Functions.
|
||||
*/
|
||||
|
||||
static int
|
||||
au_g72x_encode_block (SF_PRIVATE *psf, G72x_DATA *pg72x)
|
||||
{ int k ;
|
||||
|
||||
/* Encode the samples. */
|
||||
g72x_encode_block (pg72x) ;
|
||||
|
||||
/* Write the block to disk. */
|
||||
if ((k = psf_fwrite (pg72x->block, 1, pg72x->blocksize, psf)) != pg72x->blocksize)
|
||||
psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", k, pg72x->blocksize) ;
|
||||
|
||||
pg72x->samplecount = 0 ;
|
||||
pg72x->blockcount ++ ;
|
||||
|
||||
/* Set samples to zero for next block. */
|
||||
memset (pg72x->samples, 0, G72x_BLOCK_SIZE * sizeof (short)) ;
|
||||
|
||||
return 1 ;
|
||||
} /* au_g72x_encode_block */
|
||||
|
||||
static int
|
||||
au_g72x_write_block (SF_PRIVATE *psf, G72x_DATA *pg72x, short *ptr, int len)
|
||||
{ int count, total = 0, indx = 0 ;
|
||||
|
||||
while (indx < len)
|
||||
{ count = pg72x->samplesperblock - pg72x->samplecount ;
|
||||
|
||||
if (count > len - indx)
|
||||
count = len - indx ;
|
||||
|
||||
memcpy (&(pg72x->samples [pg72x->samplecount]), &(ptr [indx]), count * sizeof (short)) ;
|
||||
indx += count ;
|
||||
pg72x->samplecount += count ;
|
||||
total = indx ;
|
||||
|
||||
if (pg72x->samplecount >= pg72x->samplesperblock)
|
||||
au_g72x_encode_block (psf, pg72x) ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* au_g72x_write_block */
|
||||
|
||||
static sf_count_t
|
||||
au_g72x_write_s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ G72x_DATA *pg72x ;
|
||||
int writecount, count ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pg72x = (G72x_DATA*) psf->fdata ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len > 0x10000000) ? 0x10000000 : (int) len ;
|
||||
|
||||
count = au_g72x_write_block (psf, pg72x, ptr, writecount) ;
|
||||
|
||||
total += count ;
|
||||
len -= count ;
|
||||
if (count != writecount)
|
||||
break ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* au_g72x_write_s */
|
||||
|
||||
static sf_count_t
|
||||
au_g72x_write_i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ G72x_DATA *pg72x ;
|
||||
short *sptr ;
|
||||
int k, bufferlen, writecount = 0, count ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pg72x = (G72x_DATA*) psf->fdata ;
|
||||
|
||||
sptr = (short*) psf->buffer ;
|
||||
bufferlen = ((SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth) / sizeof (short) ;
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : len ;
|
||||
for (k = 0 ; k < writecount ; k++)
|
||||
sptr [k] = ptr [total + k] >> 16 ;
|
||||
count = au_g72x_write_block (psf, pg72x, sptr, writecount) ;
|
||||
|
||||
total += count ;
|
||||
len -= writecount ;
|
||||
if (count != writecount)
|
||||
break ;
|
||||
} ;
|
||||
return total ;
|
||||
} /* au_g72x_write_i */
|
||||
|
||||
static sf_count_t
|
||||
au_g72x_write_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ G72x_DATA *pg72x ;
|
||||
short *sptr ;
|
||||
int k, bufferlen, writecount = 0, count ;
|
||||
sf_count_t total = 0 ;
|
||||
float normfact ;
|
||||
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pg72x = (G72x_DATA*) psf->fdata ;
|
||||
|
||||
normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x8000) : 1.0 ;
|
||||
|
||||
sptr = (short*) psf->buffer ;
|
||||
bufferlen = ((SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth) / sizeof (short) ;
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : len ;
|
||||
for (k = 0 ; k < writecount ; k++)
|
||||
sptr [k] = lrintf (normfact * ptr [total + k]) ;
|
||||
count = au_g72x_write_block (psf, pg72x, sptr, writecount) ;
|
||||
|
||||
total += count ;
|
||||
len -= writecount ;
|
||||
if (count != writecount)
|
||||
break ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* au_g72x_write_f */
|
||||
|
||||
static sf_count_t
|
||||
au_g72x_write_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ G72x_DATA *pg72x ;
|
||||
short *sptr ;
|
||||
int k, bufferlen, writecount = 0, count ;
|
||||
sf_count_t total = 0 ;
|
||||
double normfact ;
|
||||
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pg72x = (G72x_DATA*) psf->fdata ;
|
||||
|
||||
normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x8000) : 1.0 ;
|
||||
|
||||
sptr = (short*) psf->buffer ;
|
||||
bufferlen = ((SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth) / sizeof (short) ;
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : len ;
|
||||
for (k = 0 ; k < writecount ; k++)
|
||||
sptr [k] = lrint (normfact * ptr [total + k]) ;
|
||||
count = au_g72x_write_block (psf, pg72x, sptr, writecount) ;
|
||||
|
||||
total += count ;
|
||||
len -= writecount ;
|
||||
if (count != writecount)
|
||||
break ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* au_g72x_write_d */
|
||||
|
||||
static int
|
||||
au_g72x_close (SF_PRIVATE *psf)
|
||||
{ G72x_DATA *pg72x ;
|
||||
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
|
||||
pg72x = (G72x_DATA*) psf->fdata ;
|
||||
|
||||
if (psf->mode == SFM_WRITE)
|
||||
{ /* If a block has been partially assembled, write it out
|
||||
** as the final block.
|
||||
*/
|
||||
|
||||
if (pg72x->samplecount && pg72x->samplecount < G72x_BLOCK_SIZE)
|
||||
au_g72x_encode_block (psf, pg72x) ;
|
||||
|
||||
if (psf->write_header)
|
||||
psf->write_header (psf, SF_FALSE) ;
|
||||
} ;
|
||||
|
||||
return 0 ;
|
||||
} /* au_g72x_close */
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 3cc5439e-7247-486b-b2e6-11a4affa5744
|
||||
*/
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2001-2004 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2001-2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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,13 +16,12 @@
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "sndfile.h"
|
||||
#include "config.h"
|
||||
#include "common.h"
|
||||
|
||||
static SF_FORMAT_INFO const simple_formats [] =
|
||||
@ -47,14 +46,6 @@ static SF_FORMAT_INFO const simple_formats [] =
|
||||
"AU (Sun/Next 8-bit u-law)", "au"
|
||||
},
|
||||
|
||||
{ SF_FORMAT_CAF | SF_FORMAT_PCM_16,
|
||||
"CAF (Apple 16 bit PCM)", "caf"
|
||||
},
|
||||
|
||||
{ SF_FORMAT_FLAC | SF_FORMAT_PCM_16,
|
||||
"FLAC 16 bit", "flac"
|
||||
},
|
||||
|
||||
{ SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM,
|
||||
"OKI Dialogic VOX ADPCM", "vox"
|
||||
},
|
||||
@ -107,9 +98,6 @@ static SF_FORMAT_INFO const major_formats [] =
|
||||
{
|
||||
{ SF_FORMAT_AIFF, "AIFF (Apple/SGI)", "aiff" },
|
||||
{ SF_FORMAT_AU, "AU (Sun/NeXT)", "au" },
|
||||
{ SF_FORMAT_AVR, "AVR (Audio Visual Research)", "avr" },
|
||||
{ SF_FORMAT_CAF, "CAF (Apple Core Audio File)", "caf" },
|
||||
{ SF_FORMAT_FLAC, "FLAC (FLAC Lossless Audio Codec)", "flac" },
|
||||
{ SF_FORMAT_HTK, "HTK (HMM Tool Kit)", "htk" },
|
||||
{ SF_FORMAT_SVX, "IFF (Amiga IFF/SVX8/SV16)", "iff" },
|
||||
{ SF_FORMAT_MAT4, "MAT4 (GNU Octave 2.0 / Matlab 4.2)", "mat" },
|
||||
@ -117,14 +105,15 @@ static SF_FORMAT_INFO const major_formats [] =
|
||||
{ SF_FORMAT_PAF, "PAF (Ensoniq PARIS)", "paf" },
|
||||
{ SF_FORMAT_PVF, "PVF (Portable Voice Format)", "pvf" },
|
||||
{ SF_FORMAT_RAW, "RAW (header-less)", "raw" },
|
||||
{ SF_FORMAT_SD2, "SD2 (Sound Designer II)", "sd2" },
|
||||
{ SF_FORMAT_SDS, "SDS (Midi Sample Dump Standard)", "sds" },
|
||||
/* Not ready for mainstream use yet.
|
||||
{ SF_FORMAT_SD2, "SD2 (Sound Designer II)", "sd2" },
|
||||
*/
|
||||
{ SF_FORMAT_IRCAM, "SF (Berkeley/IRCAM/CARL)", "sf" },
|
||||
{ SF_FORMAT_VOC, "VOC (Creative Labs)", "voc" },
|
||||
{ SF_FORMAT_W64, "W64 (SoundFoundry WAVE 64)", "w64" },
|
||||
{ SF_FORMAT_WAV, "WAV (Microsoft)", "wav" },
|
||||
{ SF_FORMAT_NIST, "WAV (NIST Sphere)", "wav" },
|
||||
{ SF_FORMAT_WAVEX, "WAVEX (Microsoft)", "wav" },
|
||||
{ SF_FORMAT_XI, "XI (FastTracker 2)", "xi" },
|
||||
|
||||
} ; /* major_formats */
|
||||
@ -179,7 +168,7 @@ static SF_FORMAT_INFO subtype_formats [] =
|
||||
{ SF_FORMAT_VOX_ADPCM, "VOX ADPCM", "vox" },
|
||||
|
||||
{ SF_FORMAT_DPCM_16, "16 bit DPCM", NULL },
|
||||
{ SF_FORMAT_DPCM_8, "8 bit DPCM", NULL }
|
||||
{ SF_FORMAT_DPCM_8, "8 bit DPCM", NULL },
|
||||
} ; /* subtype_formats */
|
||||
|
||||
int
|
||||
@ -239,7 +228,7 @@ psf_get_format_info (SF_FORMAT_INFO *data)
|
||||
double
|
||||
psf_calc_signal_max (SF_PRIVATE *psf, int normalize)
|
||||
{ sf_count_t position ;
|
||||
double max_val, temp, *data ;
|
||||
double max_val = 0.0, temp, *data ;
|
||||
int k, len, readcount, save_state ;
|
||||
|
||||
/* If the file is not seekable, there is nothing we can do. */
|
||||
@ -254,18 +243,19 @@ psf_calc_signal_max (SF_PRIVATE *psf, int normalize)
|
||||
} ;
|
||||
|
||||
save_state = sf_command ((SNDFILE*) psf, SFC_GET_NORM_DOUBLE, NULL, 0) ;
|
||||
|
||||
sf_command ((SNDFILE*) psf, SFC_SET_NORM_DOUBLE, NULL, normalize) ;
|
||||
|
||||
/* Brute force. Read the whole file and find the biggest sample. */
|
||||
/* Get current position in file */
|
||||
position = sf_seek ((SNDFILE*) psf, 0, SEEK_CUR) ;
|
||||
/* Go to start of file. */
|
||||
sf_seek ((SNDFILE*) psf, 0, SEEK_SET) ;
|
||||
position = sf_seek ((SNDFILE*) psf, 0, SEEK_CUR) ; /* Get current position in file */
|
||||
sf_seek ((SNDFILE*) psf, 0, SEEK_SET) ; /* Go to start of file. */
|
||||
|
||||
data = psf->u.dbuf ;
|
||||
len = ARRAY_LEN (psf->u.dbuf) ;
|
||||
len = sizeof (psf->buffer) / sizeof (double) ;
|
||||
|
||||
for (readcount = 1, max_val = 0.0 ; readcount > 0 ; /* nothing */)
|
||||
data = (double*) psf->buffer ;
|
||||
|
||||
readcount = len ;
|
||||
while (readcount > 0)
|
||||
{ readcount = sf_read_double ((SNDFILE*) psf, data, len) ;
|
||||
for (k = 0 ; k < readcount ; k++)
|
||||
{ temp = fabs (data [k]) ;
|
||||
@ -273,8 +263,8 @@ psf_calc_signal_max (SF_PRIVATE *psf, int normalize)
|
||||
} ;
|
||||
} ;
|
||||
|
||||
/* Return to SNDFILE to original state. */
|
||||
sf_seek ((SNDFILE*) psf, position, SEEK_SET) ;
|
||||
sf_seek ((SNDFILE*) psf, position, SEEK_SET) ; /* Return to original position. */
|
||||
|
||||
sf_command ((SNDFILE*) psf, SFC_SET_NORM_DOUBLE, NULL, save_state) ;
|
||||
|
||||
return max_val ;
|
||||
@ -303,9 +293,9 @@ psf_calc_max_all_channels (SF_PRIVATE *psf, double *peaks, int normalize)
|
||||
position = sf_seek ((SNDFILE*) psf, 0, SEEK_CUR) ; /* Get current position in file */
|
||||
sf_seek ((SNDFILE*) psf, 0, SEEK_SET) ; /* Go to start of file. */
|
||||
|
||||
len = ARRAY_LEN (psf->u.dbuf) ;
|
||||
len = sizeof (psf->buffer) / sizeof (double) ;
|
||||
|
||||
data = psf->u.dbuf ;
|
||||
data = (double*) psf->buffer ;
|
||||
|
||||
chan = 0 ;
|
||||
readcount = len ;
|
||||
@ -323,36 +313,7 @@ psf_calc_max_all_channels (SF_PRIVATE *psf, double *peaks, int normalize)
|
||||
sf_command ((SNDFILE*) psf, SFC_SET_NORM_DOUBLE, NULL, save_state) ;
|
||||
|
||||
return 0 ;
|
||||
} /* psf_calc_max_all_channels */
|
||||
|
||||
int
|
||||
psf_get_signal_max (SF_PRIVATE *psf, double *peak)
|
||||
{ int k ;
|
||||
|
||||
if (psf->peak_info == NULL)
|
||||
return SF_FALSE ;
|
||||
|
||||
peak [0] = psf->peak_info->peaks [0].value ;
|
||||
|
||||
for (k = 1 ; k < psf->sf.channels ; k++)
|
||||
peak [0] = SF_MAX (peak [0], psf->peak_info->peaks [k].value) ;
|
||||
|
||||
return SF_TRUE ;
|
||||
} /* psf_get_signal_max */
|
||||
|
||||
int
|
||||
psf_get_max_all_channels (SF_PRIVATE *psf, double *peaks)
|
||||
{ int k ;
|
||||
|
||||
if (psf->peak_info == NULL)
|
||||
return SF_FALSE ;
|
||||
|
||||
for (k = 0 ; k < psf->sf.channels ; k++)
|
||||
peaks [k] = psf->peak_info->peaks [k].value ;
|
||||
|
||||
return SF_TRUE ;
|
||||
} /* psf_get_max_all_channels */
|
||||
|
||||
} /* psf_calc_signal_max */
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
|
513
src/common.c
513
src/common.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2006 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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
|
||||
@ -35,14 +35,12 @@
|
||||
** logbuffer array.
|
||||
*/
|
||||
|
||||
static inline void
|
||||
log_putchar (SF_PRIVATE *psf, char ch)
|
||||
{ if (psf->logindex < SIGNED_SIZEOF (psf->logbuffer) - 1)
|
||||
{ psf->logbuffer [psf->logindex++] = ch ;
|
||||
psf->logbuffer [psf->logindex] = 0 ;
|
||||
} ;
|
||||
return ;
|
||||
} /* log_putchar */
|
||||
#define LOG_PUTCHAR(a,b) \
|
||||
{ if ((a)->logindex < SIGNED_SIZEOF ((a)->logbuffer) - 1)\
|
||||
{ (a)->logbuffer [(a)->logindex++] = (b) ; \
|
||||
(a)->logbuffer [(a)->logindex] = 0 ; \
|
||||
} \
|
||||
}
|
||||
|
||||
void
|
||||
psf_log_printf (SF_PRIVATE *psf, const char *format, ...)
|
||||
@ -55,12 +53,12 @@ psf_log_printf (SF_PRIVATE *psf, const char *format, ...)
|
||||
|
||||
while ((c = *format++))
|
||||
{ if (c != '%')
|
||||
{ log_putchar (psf, c) ;
|
||||
{ LOG_PUTCHAR (psf, c) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (format [0] == '%') /* Handle %% */
|
||||
{ log_putchar (psf, '%') ;
|
||||
{ LOG_PUTCHAR (psf, '%') ;
|
||||
format ++ ;
|
||||
continue ;
|
||||
} ;
|
||||
@ -109,11 +107,11 @@ psf_log_printf (SF_PRIVATE *psf, const char *format, ...)
|
||||
width_specifier -= strlen (strptr) ;
|
||||
if (left_align == SF_FALSE)
|
||||
while (width_specifier -- > 0)
|
||||
log_putchar (psf, ' ') ;
|
||||
LOG_PUTCHAR (psf, ' ') ;
|
||||
while (*strptr)
|
||||
log_putchar (psf, *strptr++) ;
|
||||
LOG_PUTCHAR (psf, *strptr++) ;
|
||||
while (width_specifier -- > 0)
|
||||
log_putchar (psf, ' ') ;
|
||||
LOG_PUTCHAR (psf, ' ') ;
|
||||
break ;
|
||||
|
||||
case 'd': /* int */
|
||||
@ -136,7 +134,7 @@ psf_log_printf (SF_PRIVATE *psf, const char *format, ...)
|
||||
width_specifier -= width ;
|
||||
|
||||
if (sign_char == ' ')
|
||||
{ log_putchar (psf, ' ') ;
|
||||
{ LOG_PUTCHAR (psf, ' ') ;
|
||||
width_specifier -- ;
|
||||
} ;
|
||||
|
||||
@ -145,26 +143,26 @@ psf_log_printf (SF_PRIVATE *psf, const char *format, ...)
|
||||
width_specifier -- ;
|
||||
|
||||
while (width_specifier -- > 0)
|
||||
log_putchar (psf, lead_char) ;
|
||||
LOG_PUTCHAR (psf, lead_char) ;
|
||||
} ;
|
||||
|
||||
if (sign_char == '+' || sign_char == '-')
|
||||
{ log_putchar (psf, sign_char) ;
|
||||
{ LOG_PUTCHAR (psf, sign_char) ;
|
||||
width_specifier -- ;
|
||||
} ;
|
||||
|
||||
if (left_align == SF_FALSE)
|
||||
while (width_specifier -- > 0)
|
||||
log_putchar (psf, lead_char) ;
|
||||
LOG_PUTCHAR (psf, lead_char) ;
|
||||
|
||||
while (tens > 0)
|
||||
{ log_putchar (psf, '0' + d / tens) ;
|
||||
{ LOG_PUTCHAR (psf, '0' + d / tens) ;
|
||||
d %= tens ;
|
||||
tens /= 10 ;
|
||||
} ;
|
||||
|
||||
while (width_specifier -- > 0)
|
||||
log_putchar (psf, lead_char) ;
|
||||
LOG_PUTCHAR (psf, lead_char) ;
|
||||
break ;
|
||||
|
||||
case 'D': /* sf_count_t */
|
||||
@ -174,12 +172,12 @@ psf_log_printf (SF_PRIVATE *psf, const char *format, ...)
|
||||
|
||||
if (D == 0)
|
||||
{ while (-- width_specifier > 0)
|
||||
log_putchar (psf, lead_char) ;
|
||||
log_putchar (psf, '0') ;
|
||||
LOG_PUTCHAR (psf, lead_char) ;
|
||||
LOG_PUTCHAR (psf, '0') ;
|
||||
break ;
|
||||
}
|
||||
if (D < 0)
|
||||
{ log_putchar (psf, '-') ;
|
||||
{ LOG_PUTCHAR (psf, '-') ;
|
||||
D = -D ;
|
||||
} ;
|
||||
Tens = 1 ;
|
||||
@ -190,12 +188,12 @@ psf_log_printf (SF_PRIVATE *psf, const char *format, ...)
|
||||
} ;
|
||||
|
||||
while (width_specifier > width)
|
||||
{ log_putchar (psf, lead_char) ;
|
||||
{ LOG_PUTCHAR (psf, lead_char) ;
|
||||
width_specifier-- ;
|
||||
} ;
|
||||
|
||||
while (Tens > 0)
|
||||
{ log_putchar (psf, '0' + D / Tens) ;
|
||||
{ LOG_PUTCHAR (psf, '0' + D / Tens) ;
|
||||
D %= Tens ;
|
||||
Tens /= 10 ;
|
||||
} ;
|
||||
@ -215,7 +213,7 @@ psf_log_printf (SF_PRIVATE *psf, const char *format, ...)
|
||||
width_specifier -= width ;
|
||||
|
||||
if (sign_char == ' ')
|
||||
{ log_putchar (psf, ' ') ;
|
||||
{ LOG_PUTCHAR (psf, ' ') ;
|
||||
width_specifier -- ;
|
||||
} ;
|
||||
|
||||
@ -224,41 +222,40 @@ psf_log_printf (SF_PRIVATE *psf, const char *format, ...)
|
||||
width_specifier -- ;
|
||||
|
||||
while (width_specifier -- > 0)
|
||||
log_putchar (psf, lead_char) ;
|
||||
LOG_PUTCHAR (psf, lead_char) ;
|
||||
} ;
|
||||
|
||||
if (sign_char == '+' || sign_char == '-')
|
||||
{ log_putchar (psf, sign_char) ;
|
||||
{ LOG_PUTCHAR (psf, sign_char) ;
|
||||
width_specifier -- ;
|
||||
} ;
|
||||
|
||||
if (left_align == SF_FALSE)
|
||||
while (width_specifier -- > 0)
|
||||
log_putchar (psf, lead_char) ;
|
||||
LOG_PUTCHAR (psf, lead_char) ;
|
||||
|
||||
while (tens > 0)
|
||||
{ log_putchar (psf, '0' + u / tens) ;
|
||||
{ LOG_PUTCHAR (psf, '0' + u / tens) ;
|
||||
u %= tens ;
|
||||
tens /= 10 ;
|
||||
} ;
|
||||
|
||||
while (width_specifier -- > 0)
|
||||
log_putchar (psf, lead_char) ;
|
||||
LOG_PUTCHAR (psf, lead_char) ;
|
||||
break ;
|
||||
|
||||
case 'c': /* char */
|
||||
c = va_arg (ap, int) & 0xFF ;
|
||||
log_putchar (psf, c) ;
|
||||
LOG_PUTCHAR (psf, c) ;
|
||||
break ;
|
||||
|
||||
case 'x': /* hex */
|
||||
case 'X': /* hex */
|
||||
d = va_arg (ap, int) ;
|
||||
|
||||
if (d == 0)
|
||||
{ while (--width_specifier > 0)
|
||||
log_putchar (psf, lead_char) ;
|
||||
log_putchar (psf, '0') ;
|
||||
LOG_PUTCHAR (psf, lead_char) ;
|
||||
LOG_PUTCHAR (psf, '0') ;
|
||||
break ;
|
||||
} ;
|
||||
shift = 28 ;
|
||||
@ -269,13 +266,13 @@ psf_log_printf (SF_PRIVATE *psf, const char *format, ...)
|
||||
} ;
|
||||
|
||||
while (width > 0 && width_specifier > width)
|
||||
{ log_putchar (psf, lead_char) ;
|
||||
{ LOG_PUTCHAR (psf, lead_char) ;
|
||||
width_specifier-- ;
|
||||
} ;
|
||||
|
||||
while (shift >= 0)
|
||||
{ c = (d >> shift) & 0xF ;
|
||||
log_putchar (psf, (c > 9) ? c + 'A' - 10 : c + '0') ;
|
||||
LOG_PUTCHAR (psf, (c > 9) ? c + 'A' - 10 : c + '0') ;
|
||||
shift -= 4 ;
|
||||
} ;
|
||||
break ;
|
||||
@ -298,14 +295,14 @@ psf_log_printf (SF_PRIVATE *psf, const char *format, ...)
|
||||
strptr = istr ;
|
||||
while (*strptr)
|
||||
{ c = *strptr++ ;
|
||||
log_putchar (psf, c) ;
|
||||
LOG_PUTCHAR (psf, c) ;
|
||||
} ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
log_putchar (psf, '*') ;
|
||||
log_putchar (psf, c) ;
|
||||
log_putchar (psf, '*') ;
|
||||
LOG_PUTCHAR (psf, '*') ;
|
||||
LOG_PUTCHAR (psf, c) ;
|
||||
LOG_PUTCHAR (psf, '*') ;
|
||||
break ;
|
||||
} /* switch */
|
||||
} /* while */
|
||||
@ -314,6 +311,7 @@ psf_log_printf (SF_PRIVATE *psf, const char *format, ...)
|
||||
return ;
|
||||
} /* psf_log_printf */
|
||||
|
||||
#ifndef PSF_LOG_PRINTF_ONLY
|
||||
/*-----------------------------------------------------------------------------------------------
|
||||
** ASCII header printf functions.
|
||||
** Some formats (ie NIST) use ascii text in their headers.
|
||||
@ -328,9 +326,8 @@ psf_asciiheader_printf (SF_PRIVATE *psf, const char *format, ...)
|
||||
int maxlen ;
|
||||
char *start ;
|
||||
|
||||
maxlen = strlen ((char*) psf->header) ;
|
||||
start = ((char*) psf->header) + maxlen ;
|
||||
maxlen = sizeof (psf->header) - maxlen ;
|
||||
start = (char*) psf->header + strlen ((char*) psf->header) ;
|
||||
maxlen = sizeof (psf->header) - strlen ((char*) psf->header) ;
|
||||
|
||||
va_start (argptr, format) ;
|
||||
LSF_VSNPRINTF (start, maxlen, format, argptr) ;
|
||||
@ -379,8 +376,6 @@ psf_asciiheader_printf (SF_PRIVATE *psf, const char *format, ...)
|
||||
** psf_binheader_writef ("b", &bindata, sizeof (bindata)) ;
|
||||
**
|
||||
** To write N zero bytes use:
|
||||
** NOTE: due to platform issues (ie x86-64) you should cast the
|
||||
** argument to size_t or ensure the variable type is size_t.
|
||||
** psf_binheader_writef ("z", N) ;
|
||||
*/
|
||||
|
||||
@ -388,153 +383,99 @@ psf_asciiheader_printf (SF_PRIVATE *psf, const char *format, ...)
|
||||
** seg. fault when asked to write an int or short to a non-int/short aligned address.
|
||||
*/
|
||||
|
||||
static inline void
|
||||
header_put_byte (SF_PRIVATE *psf, char x)
|
||||
{ if (psf->headindex < SIGNED_SIZEOF (psf->header) - 1)
|
||||
psf->header [psf->headindex++] = x ;
|
||||
} /* header_put_byte */
|
||||
#define PUT_BYTE(psf,x) if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 1) \
|
||||
{ (psf)->header [(psf)->headindex++] = (x) ; }
|
||||
|
||||
#if (CPU_IS_BIG_ENDIAN == 1)
|
||||
static inline void
|
||||
header_put_marker (SF_PRIVATE *psf, int x)
|
||||
{ if (psf->headindex < SIGNED_SIZEOF (psf->header) - 4)
|
||||
{ psf->header [psf->headindex++] = (x >> 24) ;
|
||||
psf->header [psf->headindex++] = (x >> 16) ;
|
||||
psf->header [psf->headindex++] = (x >> 8) ;
|
||||
psf->header [psf->headindex++] = x ;
|
||||
} ;
|
||||
} /* header_put_marker */
|
||||
#define PUT_MARKER(psf,x) if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 4) \
|
||||
{ (psf)->header [(psf)->headindex++] = ((x) >> 24) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 16) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 8) ; \
|
||||
(psf)->header [(psf)->headindex++] = (x) ; }
|
||||
|
||||
#elif (CPU_IS_LITTLE_ENDIAN == 1)
|
||||
static inline void
|
||||
header_put_marker (SF_PRIVATE *psf, int x)
|
||||
{ if (psf->headindex < SIGNED_SIZEOF (psf->header) - 4)
|
||||
{ psf->header [psf->headindex++] = x ;
|
||||
psf->header [psf->headindex++] = (x >> 8) ;
|
||||
psf->header [psf->headindex++] = (x >> 16) ;
|
||||
psf->header [psf->headindex++] = (x >> 24) ;
|
||||
} ;
|
||||
} /* header_put_marker */
|
||||
#define PUT_MARKER(psf,x) if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 4) \
|
||||
{ (psf)->header [(psf)->headindex++] = (x) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 8) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 16) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 24) ; }
|
||||
|
||||
#else
|
||||
# error "Cannot determine endian-ness of processor."
|
||||
#endif
|
||||
|
||||
|
||||
static inline void
|
||||
header_put_be_short (SF_PRIVATE *psf, int x)
|
||||
{ if (psf->headindex < SIGNED_SIZEOF (psf->header) - 2)
|
||||
{ psf->header [psf->headindex++] = (x >> 8) ;
|
||||
psf->header [psf->headindex++] = x ;
|
||||
} ;
|
||||
} /* header_put_be_short */
|
||||
#define PUT_BE_SHORT(psf,x) if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 2) \
|
||||
{ (psf)->header [(psf)->headindex++] = ((x) >> 8) ; \
|
||||
(psf)->header [(psf)->headindex++] = (x) ; }
|
||||
|
||||
static inline void
|
||||
header_put_le_short (SF_PRIVATE *psf, int x)
|
||||
{ if (psf->headindex < SIGNED_SIZEOF (psf->header) - 2)
|
||||
{ psf->header [psf->headindex++] = x ;
|
||||
psf->header [psf->headindex++] = (x >> 8) ;
|
||||
} ;
|
||||
} /* header_put_le_short */
|
||||
#define PUT_LE_SHORT(psf,x) if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 2) \
|
||||
{ (psf)->header [(psf)->headindex++] = (x) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 8) ; }
|
||||
|
||||
static inline void
|
||||
header_put_be_3byte (SF_PRIVATE *psf, int x)
|
||||
{ if (psf->headindex < SIGNED_SIZEOF (psf->header) - 3)
|
||||
{ psf->header [psf->headindex++] = (x >> 16) ;
|
||||
psf->header [psf->headindex++] = (x >> 8) ;
|
||||
psf->header [psf->headindex++] = x ;
|
||||
} ;
|
||||
} /* header_put_be_3byte */
|
||||
#define PUT_BE_3BYTE(psf,x) if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 3) \
|
||||
{ (psf)->header [(psf)->headindex++] = ((x) >> 16) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 8) ; \
|
||||
(psf)->header [(psf)->headindex++] = (x) ; }
|
||||
|
||||
static inline void
|
||||
header_put_le_3byte (SF_PRIVATE *psf, int x)
|
||||
{ if (psf->headindex < SIGNED_SIZEOF (psf->header) - 3)
|
||||
{ psf->header [psf->headindex++] = x ;
|
||||
psf->header [psf->headindex++] = (x >> 8) ;
|
||||
psf->header [psf->headindex++] = (x >> 16) ;
|
||||
} ;
|
||||
} /* header_put_le_3byte */
|
||||
#define PUT_LE_3BYTE(psf,x) if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 3) \
|
||||
{ (psf)->header [(psf)->headindex++] = (x) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 8) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 16) ; }
|
||||
|
||||
static inline void
|
||||
header_put_be_int (SF_PRIVATE *psf, int x)
|
||||
{ if (psf->headindex < SIGNED_SIZEOF (psf->header) - 4)
|
||||
{ psf->header [psf->headindex++] = (x >> 24) ;
|
||||
psf->header [psf->headindex++] = (x >> 16) ;
|
||||
psf->header [psf->headindex++] = (x >> 8) ;
|
||||
psf->header [psf->headindex++] = x ;
|
||||
} ;
|
||||
} /* header_put_be_int */
|
||||
#define PUT_BE_INT(psf,x) if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 4) \
|
||||
{ (psf)->header [(psf)->headindex++] = ((x) >> 24) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 16) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 8) ; \
|
||||
(psf)->header [(psf)->headindex++] = (x) ; }
|
||||
|
||||
static inline void
|
||||
header_put_le_int (SF_PRIVATE *psf, int x)
|
||||
{ if (psf->headindex < SIGNED_SIZEOF (psf->header) - 4)
|
||||
{ psf->header [psf->headindex++] = x ;
|
||||
psf->header [psf->headindex++] = (x >> 8) ;
|
||||
psf->header [psf->headindex++] = (x >> 16) ;
|
||||
psf->header [psf->headindex++] = (x >> 24) ;
|
||||
} ;
|
||||
} /* header_put_le_int */
|
||||
#define PUT_LE_INT(psf,x) if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 4) \
|
||||
{ (psf)->header [(psf)->headindex++] = (x) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 8) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 16) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 24) ; }
|
||||
|
||||
#if (SIZEOF_SF_COUNT_T == 4)
|
||||
#define PUT_BE_8BYTE(psf,x) if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 8) \
|
||||
{ (psf)->header [(psf)->headindex++] = 0 ; \
|
||||
(psf)->header [(psf)->headindex++] = 0 ; \
|
||||
(psf)->header [(psf)->headindex++] = 0 ; \
|
||||
(psf)->header [(psf)->headindex++] = 0 ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 24) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 16) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 8) ; \
|
||||
(psf)->header [(psf)->headindex++] = (x) ; }
|
||||
|
||||
static inline void
|
||||
header_put_be_8byte (SF_PRIVATE *psf, sf_count_t x)
|
||||
{ if (psf->headindex < SIGNED_SIZEOF (psf->header) - 8)
|
||||
{ psf->header [psf->headindex++] = 0 ;
|
||||
psf->header [psf->headindex++] = 0 ;
|
||||
psf->header [psf->headindex++] = 0 ;
|
||||
psf->header [psf->headindex++] = 0 ;
|
||||
psf->header [psf->headindex++] = (x >> 24) ;
|
||||
psf->header [psf->headindex++] = (x >> 16) ;
|
||||
psf->header [psf->headindex++] = (x >> 8) ;
|
||||
psf->header [psf->headindex++] = x ;
|
||||
} ;
|
||||
} /* header_put_be_8byte */
|
||||
|
||||
static inline void
|
||||
header_put_le_8byte (SF_PRIVATE *psf, sf_count_t x)
|
||||
{ if (psf->headindex < SIGNED_SIZEOF (psf->header) - 8)
|
||||
{ psf->header [psf->headindex++] = x ;
|
||||
psf->header [psf->headindex++] = (x >> 8) ;
|
||||
psf->header [psf->headindex++] = (x >> 16) ;
|
||||
psf->header [psf->headindex++] = (x >> 24) ;
|
||||
psf->header [psf->headindex++] = 0 ;
|
||||
psf->header [psf->headindex++] = 0 ;
|
||||
psf->header [psf->headindex++] = 0 ;
|
||||
psf->header [psf->headindex++] = 0 ;
|
||||
} ;
|
||||
} /* header_put_le_8byte */
|
||||
#define PUT_LE_8BYTE(psf,x) if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 8) \
|
||||
{ (psf)->header [(psf)->headindex++] = (x) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 8) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 16) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 24) ; \
|
||||
(psf)->header [(psf)->headindex++] = 0 ; \
|
||||
(psf)->header [(psf)->headindex++] = 0 ; \
|
||||
(psf)->header [(psf)->headindex++] = 0 ; \
|
||||
(psf)->header [(psf)->headindex++] = 0 ; }
|
||||
|
||||
#elif (SIZEOF_SF_COUNT_T == 8)
|
||||
#define PUT_BE_8BYTE(psf,x) if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 8) \
|
||||
{ (psf)->header [(psf)->headindex++] = ((x) >> 56) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 48) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 40) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 32) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 24) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 16) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 8) ; \
|
||||
(psf)->header [(psf)->headindex++] = (x) ; }
|
||||
|
||||
static inline void
|
||||
header_put_be_8byte (SF_PRIVATE *psf, sf_count_t x)
|
||||
{ if (psf->headindex < SIGNED_SIZEOF (psf->header) - 8)
|
||||
{ psf->header [psf->headindex++] = (x >> 56) ;
|
||||
psf->header [psf->headindex++] = (x >> 48) ;
|
||||
psf->header [psf->headindex++] = (x >> 40) ;
|
||||
psf->header [psf->headindex++] = (x >> 32) ;
|
||||
psf->header [psf->headindex++] = (x >> 24) ;
|
||||
psf->header [psf->headindex++] = (x >> 16) ;
|
||||
psf->header [psf->headindex++] = (x >> 8) ;
|
||||
psf->header [psf->headindex++] = x ;
|
||||
} ;
|
||||
} /* header_put_be_8byte */
|
||||
|
||||
static inline void
|
||||
header_put_le_8byte (SF_PRIVATE *psf, sf_count_t x)
|
||||
{ if (psf->headindex < SIGNED_SIZEOF (psf->header) - 8)
|
||||
{ psf->header [psf->headindex++] = x ;
|
||||
psf->header [psf->headindex++] = (x >> 8) ;
|
||||
psf->header [psf->headindex++] = (x >> 16) ;
|
||||
psf->header [psf->headindex++] = (x >> 24) ;
|
||||
psf->header [psf->headindex++] = (x >> 32) ;
|
||||
psf->header [psf->headindex++] = (x >> 40) ;
|
||||
psf->header [psf->headindex++] = (x >> 48) ;
|
||||
psf->header [psf->headindex++] = (x >> 56) ;
|
||||
} ;
|
||||
} /* header_put_le_8byte */
|
||||
|
||||
#define PUT_LE_8BYTE(psf,x) if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 8) \
|
||||
{ (psf)->header [(psf)->headindex++] = (x) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 8) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 16) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 24) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 32) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 40) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 48) ; \
|
||||
(psf)->header [(psf)->headindex++] = ((x) >> 56) ; }
|
||||
#else
|
||||
#error "SIZEOF_SF_COUNT_T is not defined."
|
||||
#endif
|
||||
@ -558,10 +499,7 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
|
||||
|
||||
while ((c = *format++))
|
||||
{ switch (c)
|
||||
{ case ' ' : /* Do nothing. Just used to space out format string. */
|
||||
break ;
|
||||
|
||||
case 'e' : /* All conversions are now from LE to host. */
|
||||
{ case 'e' : /* All conversions are now from LE to host. */
|
||||
psf->rwf_endian = SF_ENDIAN_LITTLE ;
|
||||
break ;
|
||||
|
||||
@ -579,23 +517,23 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
|
||||
|
||||
case 'm' :
|
||||
data = va_arg (argptr, unsigned int) ;
|
||||
header_put_marker (psf, data) ;
|
||||
PUT_MARKER (psf, data) ;
|
||||
count += 4 ;
|
||||
break ;
|
||||
|
||||
case '1' :
|
||||
data = va_arg (argptr, unsigned int) ;
|
||||
header_put_byte (psf, data) ;
|
||||
PUT_BYTE (psf, data) ;
|
||||
count += 1 ;
|
||||
break ;
|
||||
|
||||
case '2' :
|
||||
data = va_arg (argptr, unsigned int) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
{ header_put_be_short (psf, data) ;
|
||||
{ PUT_BE_SHORT (psf, data) ;
|
||||
}
|
||||
else
|
||||
{ header_put_le_short (psf, data) ;
|
||||
{ PUT_LE_SHORT (psf, data) ;
|
||||
} ;
|
||||
count += 2 ;
|
||||
break ;
|
||||
@ -603,10 +541,10 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
|
||||
case '3' : /* tribyte */
|
||||
data = va_arg (argptr, unsigned int) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
{ header_put_be_3byte (psf, data) ;
|
||||
{ PUT_BE_3BYTE (psf, data) ;
|
||||
}
|
||||
else
|
||||
{ header_put_le_3byte (psf, data) ;
|
||||
{ PUT_LE_3BYTE (psf, data) ;
|
||||
} ;
|
||||
count += 3 ;
|
||||
break ;
|
||||
@ -614,10 +552,10 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
|
||||
case '4' :
|
||||
data = va_arg (argptr, unsigned int) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
{ header_put_be_int (psf, data) ;
|
||||
{ PUT_BE_INT (psf, data) ;
|
||||
}
|
||||
else
|
||||
{ header_put_le_int (psf, data) ;
|
||||
{ PUT_LE_INT (psf, data) ;
|
||||
} ;
|
||||
count += 4 ;
|
||||
break ;
|
||||
@ -625,21 +563,21 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
|
||||
case '8' :
|
||||
countdata = va_arg (argptr, sf_count_t) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG && trunc_8to4 == SF_FALSE)
|
||||
{ header_put_be_8byte (psf, countdata) ;
|
||||
{ PUT_BE_8BYTE (psf, countdata) ;
|
||||
count += 8 ;
|
||||
}
|
||||
else if (psf->rwf_endian == SF_ENDIAN_LITTLE && trunc_8to4 == SF_FALSE)
|
||||
{ header_put_le_8byte (psf, countdata) ;
|
||||
{ PUT_LE_8BYTE (psf, countdata) ;
|
||||
count += 8 ;
|
||||
}
|
||||
else if (psf->rwf_endian == SF_ENDIAN_BIG && trunc_8to4 == SF_TRUE)
|
||||
{ longdata = countdata & 0xFFFFFFFF ;
|
||||
header_put_be_int (psf, longdata) ;
|
||||
PUT_BE_INT (psf, longdata) ;
|
||||
count += 4 ;
|
||||
}
|
||||
else if (psf->rwf_endian == SF_ENDIAN_LITTLE && trunc_8to4 == SF_TRUE)
|
||||
{ longdata = countdata & 0xFFFFFFFF ;
|
||||
header_put_le_int (psf, longdata) ;
|
||||
PUT_LE_INT (psf, longdata) ;
|
||||
count += 4 ;
|
||||
}
|
||||
break ;
|
||||
@ -666,14 +604,15 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
|
||||
break ;
|
||||
|
||||
case 's' :
|
||||
/* Write a C string (guaranteed to have a zero terminator). */
|
||||
strptr = va_arg (argptr, char *) ;
|
||||
size = strlen (strptr) + 1 ;
|
||||
size += (size & 1) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
header_put_be_int (psf, size) ;
|
||||
{ PUT_BE_INT (psf, size) ;
|
||||
}
|
||||
else
|
||||
header_put_le_int (psf, size) ;
|
||||
{ PUT_LE_INT (psf, size) ;
|
||||
} ;
|
||||
memcpy (&(psf->header [psf->headindex]), strptr, size) ;
|
||||
psf->headindex += size ;
|
||||
psf->header [psf->headindex - 1] = 0 ;
|
||||
@ -681,21 +620,11 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
|
||||
break ;
|
||||
|
||||
case 'S' :
|
||||
/*
|
||||
** Write an AIFF style string (no zero terminator but possibly
|
||||
** an extra pad byte if the string length is odd).
|
||||
*/
|
||||
strptr = va_arg (argptr, char *) ;
|
||||
size = strlen (strptr) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
header_put_be_int (psf, size) ;
|
||||
else
|
||||
header_put_le_int (psf, size) ;
|
||||
memcpy (&(psf->header [psf->headindex]), strptr, size + 1) ;
|
||||
size += (size & 1) ;
|
||||
strptr = va_arg (argptr, char *) ;
|
||||
size = strlen (strptr) + 1 ;
|
||||
memcpy (&(psf->header [psf->headindex]), strptr, size) ;
|
||||
psf->headindex += size ;
|
||||
psf->header [psf->headindex] = 0 ;
|
||||
count += 4 + size ;
|
||||
count += size ;
|
||||
break ;
|
||||
|
||||
case 'b' :
|
||||
@ -724,7 +653,7 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
|
||||
break ;
|
||||
|
||||
case 'j' :
|
||||
size = va_arg (argptr, size_t) ;
|
||||
size = va_arg (argptr, int) ;
|
||||
psf->headindex += size ;
|
||||
count = size ;
|
||||
break ;
|
||||
@ -747,6 +676,7 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
|
||||
** additions:
|
||||
**
|
||||
** p - jump a given number of position from start of file.
|
||||
** j - jump a given number of bytes forward in the file.
|
||||
**
|
||||
** If format is NULL, psf_binheader_readf returns the current offset.
|
||||
*/
|
||||
@ -775,40 +705,39 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
|
||||
#define GET_BE_INT(ptr) ( ((ptr) [0] << 24) | ((ptr) [1] << 16) | \
|
||||
((ptr) [2] << 8) | ((ptr) [3]) )
|
||||
|
||||
#define GET_LE_8BYTE(ptr) ( (((sf_count_t) (ptr) [7]) << 56) | (((sf_count_t) (ptr) [6]) << 48) | \
|
||||
(((sf_count_t) (ptr) [5]) << 40) | (((sf_count_t) (ptr) [4]) << 32) | \
|
||||
(((sf_count_t) (ptr) [3]) << 24) | (((sf_count_t) (ptr) [2]) << 16) | \
|
||||
(((sf_count_t) (ptr) [1]) << 8 ) | ((ptr) [0]))
|
||||
#if (SIZEOF_LONG == 4)
|
||||
#define GET_LE_8BYTE(ptr) ( ((ptr) [3] << 24) | ((ptr) [2] << 16) | \
|
||||
((ptr) [1] << 8) | ((ptr) [0]) )
|
||||
|
||||
#define GET_BE_8BYTE(ptr) ( (((sf_count_t) (ptr) [0]) << 56) | (((sf_count_t) (ptr) [1]) << 48) | \
|
||||
(((sf_count_t) (ptr) [2]) << 40) | (((sf_count_t) (ptr) [3]) << 32) | \
|
||||
(((sf_count_t) (ptr) [4]) << 24) | (((sf_count_t) (ptr) [5]) << 16) | \
|
||||
(((sf_count_t) (ptr) [6]) << 8 ) | ((ptr) [7]))
|
||||
#define GET_BE_8BYTE(ptr) ( ((ptr) [4] << 24) | ((ptr) [5] << 16) | \
|
||||
((ptr) [6] << 8) | ((ptr) [7]) )
|
||||
#else
|
||||
#define GET_LE_8BYTE(ptr) ( ((ptr) [7] << 56L) | ((ptr) [6] << 48L) | \
|
||||
((ptr) [5] << 40L) | ((ptr) [4] << 32L) | \
|
||||
((ptr) [3] << 24L) | ((ptr) [2] << 16L) | \
|
||||
((ptr) [1] << 8L) | ((ptr) [0] ))
|
||||
|
||||
#define GET_BE_8BYTE(ptr) ( ((ptr) [0] << 56L) | ((ptr) [1] << 48L) | \
|
||||
((ptr) [2] << 40L) | ((ptr) [3] << 32L) | \
|
||||
((ptr) [4] << 24L) | ((ptr) [5] << 16L) | \
|
||||
((ptr) [6] << 8L) | ((ptr) [7] ))
|
||||
|
||||
#endif
|
||||
|
||||
static int
|
||||
header_read (SF_PRIVATE *psf, void *ptr, int bytes)
|
||||
{ int count = 0 ;
|
||||
|
||||
if (psf->headindex >= SIGNED_SIZEOF (psf->header))
|
||||
{ memset (ptr, 0, SIGNED_SIZEOF (psf->header) - psf->headindex) ;
|
||||
|
||||
/* This is the best that we can do. */
|
||||
psf_fseek (psf, bytes, SEEK_CUR) ;
|
||||
return bytes ;
|
||||
} ;
|
||||
|
||||
if (psf->headindex + bytes > SIGNED_SIZEOF (psf->header))
|
||||
{ int most ;
|
||||
{ if (psf->headend < SIGNED_SIZEOF (psf->header))
|
||||
psf_log_printf (psf, "Warning : Further header read would overflow buffer.\n") ;
|
||||
|
||||
most = SIGNED_SIZEOF (psf->header) - psf->headindex ;
|
||||
psf_fread (psf->header + psf->headend, 1, most, psf) ;
|
||||
memset ((char *) ptr + most, 0, bytes - most) ;
|
||||
|
||||
psf_fseek (psf, bytes - most, SEEK_CUR) ;
|
||||
return bytes ;
|
||||
bytes = sizeof (psf->header) - psf->headindex ;
|
||||
if (bytes <= 0)
|
||||
return 0;
|
||||
printf ("\nR sizeof (header): %u headindex: %4u bytes: %d\n", sizeof (psf->header), psf->headindex, bytes) ;
|
||||
} ;
|
||||
|
||||
|
||||
if (psf->headindex + bytes > psf->headend)
|
||||
{ count = psf_fread (psf->header + psf->headend, 1, bytes - (psf->headend - psf->headindex), psf) ;
|
||||
@ -828,37 +757,34 @@ header_read (SF_PRIVATE *psf, void *ptr, int bytes)
|
||||
static void
|
||||
header_seek (SF_PRIVATE *psf, sf_count_t position, int whence)
|
||||
{
|
||||
|
||||
switch (whence)
|
||||
{ case SEEK_SET :
|
||||
if (position > SIGNED_SIZEOF (psf->header))
|
||||
if (position > sizeof (psf->header))
|
||||
{ /* Too much header to cache so just seek instead. */
|
||||
psf_fseek (psf, position, whence) ;
|
||||
//printf ("A sizeof (header): %u headindex: %4u\n", sizeof (psf->header), psf->headindex) ;
|
||||
return ;
|
||||
} ;
|
||||
if (position > psf->headend)
|
||||
psf->headend += psf_fread (psf->header + psf->headend, 1, position - psf->headend, psf) ;
|
||||
psf->headindex = position ;
|
||||
//printf ("B sizeof (header): %u headindex: %4u\n", sizeof (psf->header), psf->headindex) ;
|
||||
break ;
|
||||
|
||||
case SEEK_CUR :
|
||||
if (psf->headindex + position < 0)
|
||||
if (psf->headindex + position < 0 || psf->headindex >= SIGNED_SIZEOF (psf->header))
|
||||
break ;
|
||||
|
||||
if (psf->headindex >= SIGNED_SIZEOF (psf->header))
|
||||
{ psf_fseek (psf, position, whence) ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
if (psf->headindex + position <= psf->headend)
|
||||
{ psf->headindex += position ;
|
||||
break ;
|
||||
} ;
|
||||
|
||||
if (psf->headindex + position > SIGNED_SIZEOF (psf->header))
|
||||
{ /* Need to jump this without caching it. */
|
||||
psf->headindex = psf->headend ;
|
||||
psf_fseek (psf, position, SEEK_CUR) ;
|
||||
{ psf->headend += psf_fread (psf->header + psf->headend, 1, SIGNED_SIZEOF (psf->header) - psf->headend, psf) ;
|
||||
psf->headindex = psf->headend = SIGNED_SIZEOF (psf->header) ;
|
||||
|
||||
psf_fseek (psf, position - (SIGNED_SIZEOF (psf->header) - psf->headend), SEEK_CUR) ;
|
||||
break ;
|
||||
} ;
|
||||
|
||||
@ -910,8 +836,9 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
||||
char *charptr ;
|
||||
float *floatptr ;
|
||||
double *doubleptr ;
|
||||
size_t size ;
|
||||
char c ;
|
||||
int byte_count = 0, count ;
|
||||
int count = 0, position ;
|
||||
|
||||
if (! format)
|
||||
return psf_ftell (psf) ;
|
||||
@ -931,14 +858,14 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
||||
case 'm' :
|
||||
intptr = va_arg (argptr, unsigned int*) ;
|
||||
ucptr = (unsigned char*) intptr ;
|
||||
byte_count += header_read (psf, ucptr, sizeof (int)) ;
|
||||
count += header_read (psf, ucptr, sizeof (int)) ;
|
||||
*intptr = GET_MARKER (ucptr) ;
|
||||
break ;
|
||||
|
||||
case 'h' :
|
||||
intptr = va_arg (argptr, unsigned int*) ;
|
||||
ucptr = (unsigned char*) intptr ;
|
||||
byte_count += header_read (psf, sixteen_bytes, sizeof (sixteen_bytes)) ;
|
||||
count += header_read (psf, sixteen_bytes, sizeof (sixteen_bytes)) ;
|
||||
{ int k ;
|
||||
intdata = 0 ;
|
||||
for (k = 0 ; k < 16 ; k++)
|
||||
@ -949,15 +876,13 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
||||
|
||||
case '1' :
|
||||
charptr = va_arg (argptr, char*) ;
|
||||
*charptr = 0 ;
|
||||
byte_count += header_read (psf, charptr, sizeof (char)) ;
|
||||
count += header_read (psf, charptr, sizeof (char)) ;
|
||||
break ;
|
||||
|
||||
case '2' :
|
||||
shortptr = va_arg (argptr, unsigned short*) ;
|
||||
*shortptr = 0 ;
|
||||
ucptr = (unsigned char*) shortptr ;
|
||||
byte_count += header_read (psf, ucptr, sizeof (short)) ;
|
||||
count += header_read (psf, ucptr, sizeof (short)) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
*shortptr = GET_BE_SHORT (ucptr) ;
|
||||
else
|
||||
@ -966,8 +891,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
||||
|
||||
case '3' :
|
||||
intptr = va_arg (argptr, unsigned int*) ;
|
||||
*intptr = 0 ;
|
||||
byte_count += header_read (psf, sixteen_bytes, 3) ;
|
||||
count += header_read (psf, sixteen_bytes, 3) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
*intptr = GET_BE_3BYTE (sixteen_bytes) ;
|
||||
else
|
||||
@ -976,9 +900,8 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
||||
|
||||
case '4' :
|
||||
intptr = va_arg (argptr, unsigned int*) ;
|
||||
*intptr = 0 ;
|
||||
ucptr = (unsigned char*) intptr ;
|
||||
byte_count += header_read (psf, ucptr, sizeof (int)) ;
|
||||
count += header_read (psf, ucptr, sizeof (int)) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
*intptr = GET_BE_INT (ucptr) ;
|
||||
else
|
||||
@ -986,9 +909,8 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
||||
break ;
|
||||
|
||||
case '8' :
|
||||
countptr = va_arg (argptr, sf_count_t *) ;
|
||||
*countptr = 0 ;
|
||||
byte_count += header_read (psf, sixteen_bytes, 8) ;
|
||||
countptr = va_arg (argptr, sf_count_t*) ;
|
||||
count += header_read (psf, sixteen_bytes, 8) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
countdata = GET_BE_8BYTE (sixteen_bytes) ;
|
||||
else
|
||||
@ -999,7 +921,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
||||
case 'f' : /* Float conversion */
|
||||
floatptr = va_arg (argptr, float *) ;
|
||||
*floatptr = 0.0 ;
|
||||
byte_count += header_read (psf, floatptr, sizeof (float)) ;
|
||||
count += header_read (psf, floatptr, sizeof (float)) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
*floatptr = float32_be_read ((unsigned char*) floatptr) ;
|
||||
else
|
||||
@ -1009,7 +931,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
||||
case 'd' : /* double conversion */
|
||||
doubleptr = va_arg (argptr, double *) ;
|
||||
*doubleptr = 0.0 ;
|
||||
byte_count += header_read (psf, doubleptr, sizeof (double)) ;
|
||||
count += header_read (psf, doubleptr, sizeof (double)) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
*doubleptr = double64_be_read ((unsigned char*) doubleptr) ;
|
||||
else
|
||||
@ -1031,16 +953,16 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
||||
|
||||
case 'b' :
|
||||
charptr = va_arg (argptr, char*) ;
|
||||
count = va_arg (argptr, int) ;
|
||||
if (count > 0)
|
||||
byte_count += header_read (psf, charptr, count) ;
|
||||
size = va_arg (argptr, int) ;
|
||||
if (size > 0)
|
||||
count += header_read (psf, charptr, size) ;
|
||||
break ;
|
||||
|
||||
case 'G' :
|
||||
charptr = va_arg (argptr, char*) ;
|
||||
count = va_arg (argptr, int) ;
|
||||
if (count > 0)
|
||||
byte_count += header_gets (psf, charptr, count) ;
|
||||
size = va_arg (argptr, int) ;
|
||||
if (size > 0)
|
||||
count += header_gets (psf, charptr, size) ;
|
||||
break ;
|
||||
|
||||
case 'z' :
|
||||
@ -1057,16 +979,16 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
||||
|
||||
case 'p' :
|
||||
/* Get the seek position first. */
|
||||
count = va_arg (argptr, int) ;
|
||||
header_seek (psf, count, SEEK_SET) ;
|
||||
byte_count = count ;
|
||||
position = va_arg (argptr, int) ;
|
||||
header_seek (psf, position, SEEK_SET) ;
|
||||
count = position ;
|
||||
break ;
|
||||
|
||||
case 'j' :
|
||||
/* Get the seek position first. */
|
||||
count = va_arg (argptr, int) ;
|
||||
header_seek (psf, count, SEEK_CUR) ;
|
||||
byte_count += count ;
|
||||
position = va_arg (argptr, int) ;
|
||||
header_seek (psf, position, SEEK_CUR) ;
|
||||
count += position ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
@ -1078,33 +1000,35 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
||||
|
||||
va_end (argptr) ;
|
||||
|
||||
return byte_count ;
|
||||
return count ;
|
||||
} /* psf_binheader_readf */
|
||||
|
||||
/*-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
sf_count_t
|
||||
psf_default_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t samples_from_start)
|
||||
psf_default_seek (SF_PRIVATE *psf, int mode, sf_count_t samples_from_start)
|
||||
{ sf_count_t position, retval ;
|
||||
|
||||
if (! (psf->blockwidth && psf->dataoffset >= 0))
|
||||
{ psf->error = SFE_BAD_SEEK ;
|
||||
return PSF_SEEK_ERROR ;
|
||||
return ((sf_count_t) -1) ;
|
||||
} ;
|
||||
|
||||
if (! psf->sf.seekable)
|
||||
{ psf->error = SFE_NOT_SEEKABLE ;
|
||||
return PSF_SEEK_ERROR ;
|
||||
return ((sf_count_t) -1) ;
|
||||
} ;
|
||||
|
||||
position = psf->dataoffset + psf->blockwidth * samples_from_start ;
|
||||
|
||||
if ((retval = psf_fseek (psf, position, SEEK_SET)) != position)
|
||||
{ psf->error = SFE_SEEK_FAILED ;
|
||||
return PSF_SEEK_ERROR ;
|
||||
return ((sf_count_t) -1) ;
|
||||
} ;
|
||||
|
||||
mode = mode ;
|
||||
|
||||
return samples_from_start ;
|
||||
} /* psf_default_seek */
|
||||
|
||||
@ -1112,9 +1036,8 @@ psf_default_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t samples_from_st
|
||||
*/
|
||||
|
||||
void
|
||||
psf_hexdump (const void *ptr, int len)
|
||||
{ const char *data ;
|
||||
char ascii [17] ;
|
||||
psf_hexdump (void *ptr, int len)
|
||||
{ char ascii [17], *data ;
|
||||
int k, m ;
|
||||
|
||||
if ((data = ptr) == NULL)
|
||||
@ -1147,7 +1070,7 @@ psf_log_SF_INFO (SF_PRIVATE *psf)
|
||||
{ psf_log_printf (psf, "---------------------------------\n") ;
|
||||
|
||||
psf_log_printf (psf, " Sample rate : %d\n", psf->sf.samplerate) ;
|
||||
psf_log_printf (psf, " Frames : %D\n", psf->sf.frames) ;
|
||||
psf_log_printf (psf, " Frames : %C\n", psf->sf.frames) ;
|
||||
psf_log_printf (psf, " Channels : %d\n", psf->sf.channels) ;
|
||||
|
||||
psf_log_printf (psf, " Format : 0x%X\n", psf->sf.format) ;
|
||||
@ -1179,38 +1102,7 @@ psf_memset (void *s, int c, sf_count_t len)
|
||||
return s ;
|
||||
} /* psf_memset */
|
||||
|
||||
SF_INSTRUMENT *
|
||||
psf_instrument_alloc (void)
|
||||
{ SF_INSTRUMENT *instr ;
|
||||
|
||||
instr = calloc (1, sizeof (SF_INSTRUMENT)) ;
|
||||
|
||||
if (instr == NULL)
|
||||
return NULL ;
|
||||
|
||||
/* Set non-zero default values. */
|
||||
instr->basenote = -1 ;
|
||||
instr->velocity_lo = -1 ;
|
||||
instr->velocity_hi = -1 ;
|
||||
instr->key_lo = -1 ;
|
||||
instr->key_hi = -1 ;
|
||||
|
||||
return instr ;
|
||||
} /* psf_instrument_alloc */
|
||||
|
||||
void
|
||||
psf_sanitize_string (char * cptr, int len)
|
||||
{
|
||||
do
|
||||
{
|
||||
len -- ;
|
||||
cptr [len] = isprint (cptr [len]) ? cptr [len] : '.' ;
|
||||
}
|
||||
while (len > 0) ;
|
||||
} /* psf_sanitize_string */
|
||||
|
||||
void
|
||||
psf_get_date_str (char *str, int maxlen)
|
||||
void psf_get_date_str (char *str, int maxlen)
|
||||
{ time_t current ;
|
||||
struct tm timedata, *tmptr ;
|
||||
|
||||
@ -1282,9 +1174,10 @@ u_bitwidth_to_subformat (int bits)
|
||||
return array [((bits + 7) / 8) - 1] ;
|
||||
} /* bitwidth_to_subformat */
|
||||
|
||||
#endif /* PSF_LOG_PRINTF_ONLY */
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 33e9795e-f717-461a-9feb-65d083a56395
|
||||
|
320
src/common.h
320
src/common.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2006 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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,62 +16,24 @@
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef SNDFILE_COMMON_H
|
||||
#define SNDFILE_COMMON_H
|
||||
#ifndef COMMON_H_INCLUDED
|
||||
#define COMMON_H_INCLUDED
|
||||
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#if HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#ifndef SNDFILE_H
|
||||
#include "sndfile.h"
|
||||
#elif HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#error "This code is not designed to be compiled with a C++ compiler."
|
||||
#endif
|
||||
|
||||
#if (SIZEOF_LONG == 8)
|
||||
# define SF_PLATFORM_S64(x) x##l
|
||||
#elif COMPILER_IS_GCC
|
||||
# define SF_PLATFORM_S64(x) x##ll
|
||||
#elif OS_IS_WIN32
|
||||
# define SF_PLATFORM_S64(x) x##I64
|
||||
#else
|
||||
# error "Don't know how to define a 64 bit integer constant."
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef UNUSED
|
||||
#elif defined (__GNUC__)
|
||||
# define UNUSED(x) UNUSED_ ## x __attribute__ ((unused))
|
||||
#elif defined (__LCLINT__)
|
||||
# define UNUSED(x) /*@unused@*/ x
|
||||
#else
|
||||
# define UNUSED(x) x
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define WARN_UNUSED __attribute__ ((warn_unused_result))
|
||||
#else
|
||||
# define WARN_UNUSED
|
||||
#include <sndfile.h>
|
||||
#endif
|
||||
|
||||
#define SF_BUFFER_LEN (8192*2)
|
||||
#define SF_FILENAME_LEN (512)
|
||||
#define SF_FILENAME_LEN (256)
|
||||
#define SF_HEADER_LEN (4096)
|
||||
#define SF_TEXT_LEN (1024)
|
||||
#define SF_SYSERR_LEN (256)
|
||||
#define SF_MAX_STRINGS (16)
|
||||
#define SF_STR_BUFFER_LEN (8192)
|
||||
#define SF_HEADER_LEN (4100 + SF_STR_BUFFER_LEN)
|
||||
#define PEAK_CHANNEL_COUNT (16)
|
||||
|
||||
#define PSF_SEEK_ERROR ((sf_count_t) -1)
|
||||
#define SF_SEEK_ERROR ((sf_count_t) -1)
|
||||
|
||||
|
||||
#define BITWIDTH2BYTES(x) (((x) + 7) / 8)
|
||||
@ -84,22 +46,8 @@
|
||||
|
||||
#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0])))
|
||||
|
||||
#if (COMPILER_IS_GCC == 1)
|
||||
#define SF_MAX(x,y) ({ \
|
||||
typeof(x) _x = (x); \
|
||||
typeof(y) _y = (y); \
|
||||
(void) (&_x == &_y); \
|
||||
_x > _y ? _x : _y; })
|
||||
|
||||
#define SF_MIN(x,y) ({ \
|
||||
typeof(x) _x = (x); \
|
||||
typeof(y) _y = (y); \
|
||||
(void) (&_x == &_y); \
|
||||
_x < _y ? _x : _y; })
|
||||
#else
|
||||
#define SF_MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
#define SF_MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
enum
|
||||
{ /* PEAK chunk location. */
|
||||
@ -133,6 +81,7 @@ enum
|
||||
{ /* Work in progress. */
|
||||
|
||||
/* Formats supported read only. */
|
||||
SF_FORMAT_WVE = 0x4020000, /* Psion ALaw Sound File */
|
||||
SF_FORMAT_TXW = 0x4030000, /* Yamaha TX16 sampler file */
|
||||
SF_FORMAT_DWD = 0x4040000, /* DiamondWare Digirized */
|
||||
|
||||
@ -140,10 +89,12 @@ enum
|
||||
SF_FORMAT_OGG = 0x4090000,
|
||||
|
||||
SF_FORMAT_REX = 0x40A0000, /* Propellorheads Rex/Rcy */
|
||||
SF_FORMAT_SD2 = 0x40C0000, /* Sound Designer 2 */
|
||||
SF_FORMAT_REX2 = 0x40D0000, /* Propellorheads Rex2 */
|
||||
SF_FORMAT_KRZ = 0x40E0000, /* Kurzweil sampler file */
|
||||
SF_FORMAT_WMA = 0x4100000, /* Windows Media Audio. */
|
||||
SF_FORMAT_SHN = 0x4110000, /* Shorten. */
|
||||
SF_FORMAT_FLAC = 0x4120000,
|
||||
|
||||
/* Unsupported encodings. */
|
||||
SF_FORMAT_VORBIS = 0x1001,
|
||||
@ -160,40 +111,15 @@ enum
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{ double value ; /* signed value of peak */
|
||||
sf_count_t position ; /* the sample frame for the peak */
|
||||
{ float value ; /* signed value of peak */
|
||||
unsigned int position ; /* the sample frame for the peak */
|
||||
} PEAK_POS ;
|
||||
|
||||
typedef struct
|
||||
{ /* libsndfile internal : write a PEAK chunk at the start or end of the file? */
|
||||
int peak_loc ;
|
||||
|
||||
/* WAV/AIFF */
|
||||
unsigned int version ; /* version of the PEAK chunk */
|
||||
unsigned int timestamp ; /* secs since 1/1/1970 */
|
||||
|
||||
/* CAF */
|
||||
unsigned int edit_number ;
|
||||
|
||||
#if HAVE_FLEXIBLE_ARRAY
|
||||
/* the per channel peak info */
|
||||
PEAK_POS peaks [] ;
|
||||
#else
|
||||
/*
|
||||
** This is not ISO compliant C. It works on some compilers which
|
||||
** don't support the ISO standard flexible struct array which is
|
||||
** used above. If your compiler doesn't like this I suggest you find
|
||||
** youself a 1999 ISO C standards compilant compiler. GCC-3.X is
|
||||
** highly recommended.
|
||||
*/
|
||||
PEAK_POS peaks [0] ;
|
||||
#endif
|
||||
} PEAK_INFO ;
|
||||
|
||||
static inline PEAK_INFO *
|
||||
peak_info_calloc (int channels)
|
||||
{ return calloc (1, sizeof (PEAK_INFO) + channels * sizeof (PEAK_POS)) ;
|
||||
} /* peak_info_calloc */
|
||||
{ unsigned int version ; /* version of the PEAK chunk */
|
||||
unsigned int timestamp ; /* secs since 1/1/1970 */
|
||||
PEAK_POS peak [PEAK_CHANNEL_COUNT] ; /* the peak info */
|
||||
} PEAK_CHUNK ;
|
||||
|
||||
typedef struct
|
||||
{ int type ;
|
||||
@ -201,11 +127,6 @@ typedef struct
|
||||
char *str ;
|
||||
} STR_DATA ;
|
||||
|
||||
static inline size_t
|
||||
make_size_t (int x)
|
||||
{ return (size_t) x ;
|
||||
} /* size_t_of_int */
|
||||
|
||||
/*=======================================================================================
|
||||
** SF_PRIVATE stuct - a pointer to this struct is passed back to the caller of the
|
||||
** sf_open_XXXX functions. The caller however has no knowledge of the struct's
|
||||
@ -214,25 +135,8 @@ make_size_t (int x)
|
||||
|
||||
typedef struct sf_private_tag
|
||||
{ /* Force the compiler to double align the start of buffer. */
|
||||
union
|
||||
{ double dbuf [SF_BUFFER_LEN / sizeof (double)] ;
|
||||
#if (defined (SIZEOF_INT64_T) && (SIZEOF_INT64_T == 8))
|
||||
int64_t lbuf [SF_BUFFER_LEN / sizeof (int64_t)] ;
|
||||
#else
|
||||
long lbuf [SF_BUFFER_LEN / sizeof (double)] ;
|
||||
#endif
|
||||
float fbuf [SF_BUFFER_LEN / sizeof (float)] ;
|
||||
int ibuf [SF_BUFFER_LEN / sizeof (int)] ;
|
||||
short sbuf [SF_BUFFER_LEN / sizeof (short)] ;
|
||||
char cbuf [SF_BUFFER_LEN / sizeof (char)] ;
|
||||
signed char scbuf [SF_BUFFER_LEN / sizeof (signed char)] ;
|
||||
unsigned char ucbuf [SF_BUFFER_LEN / sizeof (signed char)] ;
|
||||
} u ;
|
||||
|
||||
char filepath [SF_FILENAME_LEN] ;
|
||||
char rsrcpath [SF_FILENAME_LEN] ;
|
||||
char directory [SF_FILENAME_LEN] ;
|
||||
char filename [SF_FILENAME_LEN / 4] ;
|
||||
double buffer [SF_BUFFER_LEN / sizeof (double)] ;
|
||||
char filename [SF_FILENAME_LEN] ;
|
||||
|
||||
char syserr [SF_SYSERR_LEN] ;
|
||||
|
||||
@ -247,7 +151,7 @@ typedef struct sf_private_tag
|
||||
** sound files.
|
||||
*/
|
||||
STR_DATA strings [SF_MAX_STRINGS] ;
|
||||
char str_storage [SF_STR_BUFFER_LEN] ;
|
||||
char str_storage [SF_BUFFER_LEN] ;
|
||||
char *str_end ;
|
||||
int str_flags ;
|
||||
|
||||
@ -260,30 +164,15 @@ typedef struct sf_private_tag
|
||||
int has_text ;
|
||||
int do_not_close_descriptor ;
|
||||
|
||||
#if USE_WINDOWS_API
|
||||
/*
|
||||
** These fields can only be used in src/file_io.c.
|
||||
** They are basically the same as a windows file HANDLE.
|
||||
*/
|
||||
void *hfile, *hrsrc, *hsaved ;
|
||||
#else
|
||||
/* These fields can only be used in src/file_io.c. */
|
||||
int filedes, rsrcdes, savedes ;
|
||||
#endif
|
||||
int filedes ;
|
||||
|
||||
int end_of_file ;
|
||||
int error ;
|
||||
|
||||
int mode ; /* Open mode : SFM_READ, SFM_WRITE or SFM_RDWR. */
|
||||
int endian ; /* File endianness : SF_ENDIAN_LITTLE or SF_ENDIAN_BIG. */
|
||||
int float_endswap ; /* Need to endswap float32s? */
|
||||
|
||||
/*
|
||||
** Maximum float value for calculating the multiplier for
|
||||
** float/double to short/int conversions.
|
||||
*/
|
||||
int float_int_mult ;
|
||||
float float_max ;
|
||||
|
||||
/* Vairables for handling pipes. */
|
||||
int is_pipe ; /* True if file is a pipe. */
|
||||
sf_count_t pipeoffset ; /* Number of bytes read from a pipe. */
|
||||
@ -294,23 +183,13 @@ typedef struct sf_private_tag
|
||||
SF_INFO sf ;
|
||||
|
||||
int have_written ; /* Has a single write been done to the file? */
|
||||
PEAK_INFO *peak_info ;
|
||||
|
||||
/* Loop Info */
|
||||
SF_LOOP_INFO *loop_info ;
|
||||
SF_INSTRUMENT *instrument ;
|
||||
|
||||
/* Broadcast (EBU) Info */
|
||||
SF_BROADCAST_INFO *broadcast_info ;
|
||||
|
||||
/* Channel map data (if present) : an array of ints. */
|
||||
int *channel_map ;
|
||||
int has_peak ; /* Has a PEAK chunk (AIFF and WAVE) been read? */
|
||||
int peak_loc ; /* Write a PEAK chunk at the start or end of the file? */
|
||||
PEAK_CHUNK peak ;
|
||||
|
||||
sf_count_t filelength ; /* Overall length of (embedded) file. */
|
||||
sf_count_t fileoffset ; /* Offset in number of bytes from beginning of file. */
|
||||
|
||||
sf_count_t rsrclength ; /* Length of the resource fork (if it exists). */
|
||||
|
||||
sf_count_t dataoffset ; /* Offset in number of bytes from beginning of file. */
|
||||
sf_count_t datalength ; /* Length in bytes of the audio data. */
|
||||
sf_count_t dataend ; /* Offset to file tailer. */
|
||||
@ -325,13 +204,9 @@ typedef struct sf_private_tag
|
||||
sf_count_t read_current ;
|
||||
sf_count_t write_current ;
|
||||
|
||||
void *container_data ; /* This is a pointer to dynamically allocated file
|
||||
** container format specific data.
|
||||
*/
|
||||
|
||||
void *codec_data ; /* This is a pointer to dynamically allocated file
|
||||
** codec format specific data.
|
||||
*/
|
||||
void *fdata ; /* This is a pointer to dynamically allocated file format
|
||||
** specific data.
|
||||
*/
|
||||
|
||||
SF_DITHER_INFO write_dither ;
|
||||
SF_DITHER_INFO read_dither ;
|
||||
@ -342,48 +217,32 @@ typedef struct sf_private_tag
|
||||
int auto_header ;
|
||||
|
||||
int ieee_replace ;
|
||||
|
||||
/* For ambisonic commands */
|
||||
int wavex_ambisonic ;
|
||||
|
||||
/* A set of file specific function pointers */
|
||||
|
||||
sf_count_t (*read_short) (struct sf_private_tag*, short *ptr, sf_count_t len) ;
|
||||
sf_count_t (*read_int) (struct sf_private_tag*, int *ptr, sf_count_t len) ;
|
||||
sf_count_t (*read_float) (struct sf_private_tag*, float *ptr, sf_count_t len) ;
|
||||
sf_count_t (*read_double) (struct sf_private_tag*, double *ptr, sf_count_t len) ;
|
||||
|
||||
sf_count_t (*write_short) (struct sf_private_tag*, const short *ptr, sf_count_t len) ;
|
||||
sf_count_t (*write_int) (struct sf_private_tag*, const int *ptr, sf_count_t len) ;
|
||||
sf_count_t (*write_float) (struct sf_private_tag*, const float *ptr, sf_count_t len) ;
|
||||
sf_count_t (*write_double) (struct sf_private_tag*, const double *ptr, sf_count_t len) ;
|
||||
sf_count_t (*write_short) (struct sf_private_tag*, short *ptr, sf_count_t len) ;
|
||||
sf_count_t (*write_int) (struct sf_private_tag*, int *ptr, sf_count_t len) ;
|
||||
sf_count_t (*write_float) (struct sf_private_tag*, float *ptr, sf_count_t len) ;
|
||||
sf_count_t (*write_double) (struct sf_private_tag*, double *ptr, sf_count_t len) ;
|
||||
|
||||
sf_count_t (*seek) (struct sf_private_tag*, int mode, sf_count_t samples_from_start) ;
|
||||
int (*write_header) (struct sf_private_tag*, int calc_length) ;
|
||||
int (*command) (struct sf_private_tag*, int command, void *data, int datasize) ;
|
||||
|
||||
/*
|
||||
** Separate close functions for the codec and the container.
|
||||
** The codec close function is always called first.
|
||||
*/
|
||||
int (*codec_close) (struct sf_private_tag*) ;
|
||||
int (*container_close) (struct sf_private_tag*) ;
|
||||
int (*close) (struct sf_private_tag*) ;
|
||||
|
||||
char *format_desc ;
|
||||
|
||||
/* Virtual I/O functions. */
|
||||
int virtual_io ;
|
||||
SF_VIRTUAL_IO vio ;
|
||||
void *vio_user_data ;
|
||||
} SF_PRIVATE ;
|
||||
|
||||
|
||||
|
||||
enum
|
||||
{ SFE_NO_ERROR = SF_ERR_NO_ERROR,
|
||||
SFE_BAD_OPEN_FORMAT = SF_ERR_UNRECOGNISED_FORMAT,
|
||||
SFE_SYSTEM = SF_ERR_SYSTEM,
|
||||
SFE_MALFORMED_FILE = SF_ERR_MALFORMED_FILE,
|
||||
SFE_UNSUPPORTED_ENCODING = SF_ERR_UNSUPPORTED_ENCODING,
|
||||
{ SFE_NO_ERROR = SF_ERR_NO_ERROR,
|
||||
SFE_BAD_OPEN_FORMAT = SF_ERR_UNRECOGNISED_FORMAT,
|
||||
SFE_SYSTEM = SF_ERR_SYSTEM,
|
||||
|
||||
SFE_BAD_FILE,
|
||||
SFE_BAD_FILE_READ,
|
||||
@ -409,13 +268,12 @@ enum
|
||||
SFE_NO_PIPE_WRITE,
|
||||
|
||||
SFE_INTERNAL,
|
||||
SFE_LOG_OVERRUN,
|
||||
SFE_BAD_CONTROL_CMD,
|
||||
SFE_BAD_ENDIAN,
|
||||
SFE_CHANNEL_COUNT,
|
||||
SFE_BAD_RDWR_FORMAT,
|
||||
|
||||
SFE_BAD_VIRTUAL_IO,
|
||||
|
||||
SFE_INTERLEAVE_MODE,
|
||||
SFE_INTERLEAVE_SEEK,
|
||||
SFE_INTERLEAVE_READ,
|
||||
@ -429,10 +287,8 @@ enum
|
||||
SFE_BAD_OPEN_MODE,
|
||||
SFE_OPEN_PIPE_RDWR,
|
||||
SFE_RDWR_POSITION,
|
||||
SFE_RDWR_BAD_HEADER,
|
||||
|
||||
SFE_STR_NO_SUPPORT,
|
||||
SFE_STR_NOT_WRITE,
|
||||
SFE_STR_MAX_DATA,
|
||||
SFE_STR_MAX_COUNT,
|
||||
SFE_STR_BAD_TYPE,
|
||||
@ -444,13 +300,13 @@ enum
|
||||
SFE_WAV_NO_WAVE,
|
||||
SFE_WAV_NO_FMT,
|
||||
SFE_WAV_FMT_SHORT,
|
||||
SFE_WAV_FMT_TOO_BIG,
|
||||
SFE_WAV_BAD_FACT,
|
||||
SFE_WAV_BAD_PEAK,
|
||||
SFE_WAV_PEAK_B4_FMT,
|
||||
SFE_WAV_BAD_FORMAT,
|
||||
SFE_WAV_BAD_BLOCKALIGN,
|
||||
SFE_WAV_NO_DATA,
|
||||
SFE_WAV_BAD_LIST,
|
||||
SFE_WAV_ADPCM_NOT4BIT,
|
||||
SFE_WAV_ADPCM_CHANNELS,
|
||||
SFE_WAV_GSM610_FORMAT,
|
||||
@ -544,24 +400,6 @@ enum
|
||||
SFE_SDS_NOT_SDS,
|
||||
SFE_SDS_BAD_BIT_WIDTH,
|
||||
|
||||
SFE_SD2_FD_DISALLOWED,
|
||||
SFE_SD2_BAD_DATA_OFFSET,
|
||||
SFE_SD2_BAD_MAP_OFFSET,
|
||||
SFE_SD2_BAD_DATA_LENGTH,
|
||||
SFE_SD2_BAD_MAP_LENGTH,
|
||||
SFE_SD2_BAD_RSRC,
|
||||
SFE_SD2_BAD_SAMPLE_SIZE,
|
||||
|
||||
SFE_FLAC_BAD_HEADER,
|
||||
SFE_FLAC_NEW_DECODER,
|
||||
SFE_FLAC_INIT_DECODER,
|
||||
SFE_FLAC_LOST_SYNC,
|
||||
SFE_FLAC_BAD_SAMPLE_RATE,
|
||||
SFE_FLAC_UNKOWN_ERROR,
|
||||
|
||||
SFE_WVE_NOT_WVE,
|
||||
SFE_WVE_NO_PIPE,
|
||||
|
||||
SFE_MAX_ERROR /* This must be last in list. */
|
||||
} ;
|
||||
|
||||
@ -587,7 +425,7 @@ void double64_le_write (double in, unsigned char *out) ;
|
||||
void psf_log_printf (SF_PRIVATE *psf, const char *format, ...) ;
|
||||
void psf_log_SF_INFO (SF_PRIVATE *psf) ;
|
||||
|
||||
void psf_hexdump (const void *ptr, int len) ;
|
||||
void psf_hexdump (void *ptr, int len) ;
|
||||
|
||||
/* Functions used when writing file headers. */
|
||||
|
||||
@ -622,18 +460,17 @@ void psf_generate_format_desc (SF_PRIVATE *psf) ;
|
||||
double psf_calc_signal_max (SF_PRIVATE *psf, int normalize) ;
|
||||
int psf_calc_max_all_channels (SF_PRIVATE *psf, double *peaks, int normalize) ;
|
||||
|
||||
int psf_get_signal_max (SF_PRIVATE *psf, double *peak) ;
|
||||
int psf_get_max_all_channels (SF_PRIVATE *psf, double *peaks) ;
|
||||
|
||||
/* Functions in strings.c. */
|
||||
|
||||
const char* psf_get_string (SF_PRIVATE *psf, int str_type) ;
|
||||
int psf_set_string (SF_PRIVATE *psf, int str_type, const char *str) ;
|
||||
int psf_store_string (SF_PRIVATE *psf, int str_type, const char *str) ;
|
||||
|
||||
/* Default seek function. Use for PCM and float encoded data. */
|
||||
sf_count_t psf_default_seek (SF_PRIVATE *psf, int mode, sf_count_t samples_from_start) ;
|
||||
|
||||
/* Generate the currebt date as a string. */
|
||||
void psf_get_date_str (char *str, int maxlen) ;
|
||||
|
||||
int macos_guess_file_type (SF_PRIVATE *psf, const char *filename) ;
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
@ -643,29 +480,21 @@ int macos_guess_file_type (SF_PRIVATE *psf, const char *filename) ;
|
||||
|
||||
int psf_fopen (SF_PRIVATE *psf, const char *pathname, int flags) ;
|
||||
int psf_set_stdio (SF_PRIVATE *psf, int mode) ;
|
||||
int psf_file_valid (SF_PRIVATE *psf) ;
|
||||
int psf_filedes_valid (SF_PRIVATE *psf) ;
|
||||
void psf_set_file (SF_PRIVATE *psf, int fd) ;
|
||||
void psf_init_files (SF_PRIVATE *psf) ;
|
||||
void psf_use_rsrc (SF_PRIVATE *psf, int on_off) ;
|
||||
|
||||
sf_count_t psf_fseek (SF_PRIVATE *psf, sf_count_t offset, int whence) ;
|
||||
sf_count_t psf_fread (void *ptr, sf_count_t bytes, sf_count_t count, SF_PRIVATE *psf) ;
|
||||
sf_count_t psf_fwrite (const void *ptr, sf_count_t bytes, sf_count_t count, SF_PRIVATE *psf) ;
|
||||
sf_count_t psf_fwrite (void *ptr, sf_count_t bytes, sf_count_t count, SF_PRIVATE *psf) ;
|
||||
sf_count_t psf_fgets (char *buffer, sf_count_t bufsize, SF_PRIVATE *psf) ;
|
||||
sf_count_t psf_ftell (SF_PRIVATE *psf) ;
|
||||
sf_count_t psf_get_filelen (SF_PRIVATE *psf) ;
|
||||
|
||||
void psf_fsync (SF_PRIVATE *psf) ;
|
||||
|
||||
int psf_is_pipe (SF_PRIVATE *psf) ;
|
||||
|
||||
int psf_ftruncate (SF_PRIVATE *psf, sf_count_t len) ;
|
||||
int psf_fclose (SF_PRIVATE *psf) ;
|
||||
|
||||
/* Open and close the resource fork of a file. */
|
||||
int psf_open_rsrc (SF_PRIVATE *psf, int mode) ;
|
||||
int psf_close_rsrc (SF_PRIVATE *psf) ;
|
||||
|
||||
/*
|
||||
void psf_fclearerr (SF_PRIVATE *psf) ;
|
||||
int psf_ferror (SF_PRIVATE *psf) ;
|
||||
@ -677,7 +506,7 @@ int psf_ferror (SF_PRIVATE *psf) ;
|
||||
|
||||
int aiff_open (SF_PRIVATE *psf) ;
|
||||
int au_open (SF_PRIVATE *psf) ;
|
||||
int avr_open (SF_PRIVATE *psf) ;
|
||||
int au_nh_open (SF_PRIVATE *psf) ; /* Headerless version of AU. */
|
||||
int htk_open (SF_PRIVATE *psf) ;
|
||||
int ircam_open (SF_PRIVATE *psf) ;
|
||||
int mat4_open (SF_PRIVATE *psf) ;
|
||||
@ -686,21 +515,18 @@ int nist_open (SF_PRIVATE *psf) ;
|
||||
int paf_open (SF_PRIVATE *psf) ;
|
||||
int pvf_open (SF_PRIVATE *psf) ;
|
||||
int raw_open (SF_PRIVATE *psf) ;
|
||||
int sd2_open (SF_PRIVATE *psf) ;
|
||||
int sds_open (SF_PRIVATE *psf) ;
|
||||
int svx_open (SF_PRIVATE *psf) ;
|
||||
int voc_open (SF_PRIVATE *psf) ;
|
||||
int w64_open (SF_PRIVATE *psf) ;
|
||||
int wav_open (SF_PRIVATE *psf) ;
|
||||
int xi_open (SF_PRIVATE *psf) ;
|
||||
int flac_open (SF_PRIVATE *psf) ;
|
||||
int caf_open (SF_PRIVATE *psf) ;
|
||||
|
||||
/* In progress. Do not currently work. */
|
||||
|
||||
int mpeg_open (SF_PRIVATE *psf) ;
|
||||
int ogg_open (SF_PRIVATE *psf) ;
|
||||
int rx2_open (SF_PRIVATE *psf) ;
|
||||
int sd2_open (SF_PRIVATE *psf) ;
|
||||
int txw_open (SF_PRIVATE *psf) ;
|
||||
int wve_open (SF_PRIVATE *psf) ;
|
||||
int dwd_open (SF_PRIVATE *psf) ;
|
||||
@ -711,16 +537,14 @@ int macbinary3_open (SF_PRIVATE *psf) ;
|
||||
** Init functions for a number of common data encodings.
|
||||
*/
|
||||
|
||||
int pcm_init (SF_PRIVATE *psf) ;
|
||||
int ulaw_init (SF_PRIVATE *psf) ;
|
||||
int alaw_init (SF_PRIVATE *psf) ;
|
||||
int float32_init (SF_PRIVATE *psf) ;
|
||||
int double64_init (SF_PRIVATE *psf) ;
|
||||
int dwvw_init (SF_PRIVATE *psf, int bitwidth) ;
|
||||
int gsm610_init (SF_PRIVATE *psf) ;
|
||||
int vox_adpcm_init (SF_PRIVATE *psf) ;
|
||||
int flac_init (SF_PRIVATE *psf) ;
|
||||
int g72x_init (SF_PRIVATE * psf) ;
|
||||
int pcm_init (SF_PRIVATE *psf) ;
|
||||
int ulaw_init (SF_PRIVATE *psf) ;
|
||||
int alaw_init (SF_PRIVATE *psf) ;
|
||||
int float32_init (SF_PRIVATE *psf) ;
|
||||
int double64_init (SF_PRIVATE *psf) ;
|
||||
int dwvw_init (SF_PRIVATE *psf, int bitwidth) ;
|
||||
int gsm610_init (SF_PRIVATE *psf) ;
|
||||
int vox_adpcm_init (SF_PRIVATE *psf) ;
|
||||
|
||||
int dither_init (SF_PRIVATE *psf, int mode) ;
|
||||
|
||||
@ -737,31 +561,12 @@ int interleave_init (SF_PRIVATE *psf) ;
|
||||
|
||||
void *psf_memset (void *s, int c, sf_count_t n) ;
|
||||
|
||||
SF_INSTRUMENT * psf_instrument_alloc (void) ;
|
||||
|
||||
void psf_sanitize_string (char * cptr, int len) ;
|
||||
|
||||
/* Generate the current date as a string. */
|
||||
void psf_get_date_str (char *str, int maxlen) ;
|
||||
|
||||
SF_BROADCAST_INFO* broadcast_info_alloc (void) ;
|
||||
int broadcast_info_copy (SF_BROADCAST_INFO* dst, SF_BROADCAST_INFO* src) ;
|
||||
int broadcast_add_coding_history (SF_BROADCAST_INFO* bext, unsigned int channels, unsigned int samplerate) ;
|
||||
|
||||
typedef struct
|
||||
{ int channels ;
|
||||
int endianness ;
|
||||
} AUDIO_DETECT ;
|
||||
|
||||
int audio_detect (SF_PRIVATE * psf, AUDIO_DETECT *ad, const unsigned char * data, int datalen) ;
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
** Here's how we fix systems which don't snprintf / vsnprintf.
|
||||
** Systems without these functions should use the
|
||||
*/
|
||||
|
||||
#if USE_WINDOWS_API
|
||||
#if (defined (WIN32) || defined (_WIN32))
|
||||
#define LSF_SNPRINTF _snprintf
|
||||
#elif (HAVE_SNPRINTF && ! FORCE_MISSING_SNPRINTF)
|
||||
#define LSF_SNPRINTF snprintf
|
||||
@ -770,7 +575,7 @@ int missing_snprintf (char *str, size_t n, char const *fmt, ...) ;
|
||||
#define LSF_SNPRINTF missing_snprintf
|
||||
#endif
|
||||
|
||||
#if USE_WINDOWS_API
|
||||
#if (defined (WIN32) || defined (_WIN32))
|
||||
#define LSF_VSNPRINTF _vsnprintf
|
||||
#elif (HAVE_VSNPRINTF && ! FORCE_MISSING_SNPRINTF)
|
||||
#define LSF_VSNPRINTF vsnprintf
|
||||
@ -779,6 +584,8 @@ int missing_vsnprintf (char *str, size_t n, const char *fmt, ...) ;
|
||||
#define LSF_VSNPRINTF missing_vsnprintf
|
||||
#endif
|
||||
|
||||
#endif /* COMMON_H_INCLUDED */
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
** Extra commands for sf_command(). Not for public use yet.
|
||||
*/
|
||||
@ -801,12 +608,9 @@ int sf_dither_int (const SF_DITHER_INFO *dither, const int *in, int *out, int c
|
||||
int sf_dither_float (const SF_DITHER_INFO *dither, const float *in, float *out, int count) ;
|
||||
int sf_dither_double (const SF_DITHER_INFO *dither, const double *in, double *out, int count) ;
|
||||
#endif
|
||||
|
||||
#endif /* SNDFILE_COMMON_H */
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 7b45c0ee-5835-4a18-a4ef-994e4cd95b67
|
||||
|
125
src/create_symbols_file.sh
Normal file
125
src/create_symbols_file.sh
Normal file
@ -0,0 +1,125 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
#
|
||||
# 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.
|
||||
|
||||
#----------------------------------------------------------------
|
||||
# These are all of the public functions exported from libsndfile.
|
||||
|
||||
ALL_SYMBOLS=( \
|
||||
sf_close \
|
||||
sf_command \
|
||||
sf_error \
|
||||
sf_error_number \
|
||||
sf_error_str \
|
||||
sf_format_check \
|
||||
sf_open \
|
||||
sf_open_fd \
|
||||
sf_perror \
|
||||
sf_read_double \
|
||||
sf_read_float \
|
||||
sf_read_int \
|
||||
sf_read_raw \
|
||||
sf_read_short \
|
||||
sf_readf_double \
|
||||
sf_readf_float \
|
||||
sf_readf_int \
|
||||
sf_readf_short \
|
||||
sf_seek \
|
||||
sf_strerror \
|
||||
sf_write_double \
|
||||
sf_write_float \
|
||||
sf_write_int \
|
||||
sf_write_raw \
|
||||
sf_write_short \
|
||||
sf_writef_double \
|
||||
sf_writef_float \
|
||||
sf_writef_int \
|
||||
sf_writef_short \
|
||||
sf_get_string \
|
||||
sf_set_string \
|
||||
)
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
linux_symbols () {
|
||||
echo "# Auto-generated by $0"
|
||||
echo
|
||||
echo "libsndfile.so.$VERSION"
|
||||
echo "{"
|
||||
echo " global:"
|
||||
for x in ${ALL_SYMBOLS[@]} ; do
|
||||
echo " $x ;"
|
||||
done
|
||||
echo " local:"
|
||||
echo " * ;"
|
||||
echo "} ;"
|
||||
echo
|
||||
}
|
||||
|
||||
darwin_symbols () {
|
||||
echo "# Auto-generated by $0"
|
||||
echo
|
||||
for x in ${ALL_SYMBOLS[@]} ; do
|
||||
echo "_$x"
|
||||
done
|
||||
echo
|
||||
}
|
||||
|
||||
no_symbols () {
|
||||
OS=`uname`
|
||||
echo
|
||||
echo "No known way of restricting exported symbols on $OS."
|
||||
echo "If you know a way, please contact the author."
|
||||
echo
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
if test $# -ne 2 ; then
|
||||
echo
|
||||
echo "Usage : $0 <target OS name> <libsndfile version>."
|
||||
echo
|
||||
echo " Currently supported values for target OS are:"
|
||||
echo " linux"
|
||||
echo " darwin (ie MacOSX)"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VERSION=`echo $2 | sed -re "s/\.[a-z0-9]+$//"`
|
||||
OS_NAME=$1
|
||||
|
||||
case $OS_NAME in
|
||||
linux*)
|
||||
linux_symbols
|
||||
;;
|
||||
darwin*)
|
||||
darwin_symbols
|
||||
;;
|
||||
*)
|
||||
no_symbols
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
|
||||
# Do not edit or modify anything in this comment block.
|
||||
# The arch-tag line is a file identity tag for the GNU Arch
|
||||
# revision control system.
|
||||
#
|
||||
# arch-tag: 5814f35c-318f-4023-a0c3-d9cf7c9e5f6c
|
||||
|
39
src/dither.c
39
src/dither.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2003,2005 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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,11 +16,10 @@
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "sndfile.h"
|
||||
#include "config.h"
|
||||
#include "sfendian.h"
|
||||
#include "common.h"
|
||||
|
||||
@ -67,10 +66,10 @@ typedef struct
|
||||
sf_count_t (*read_float) (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
sf_count_t (*read_double) (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
|
||||
sf_count_t (*write_short) (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ;
|
||||
sf_count_t (*write_int) (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ;
|
||||
sf_count_t (*write_float) (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ;
|
||||
sf_count_t (*write_double) (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
|
||||
sf_count_t (*write_short) (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
|
||||
sf_count_t (*write_int) (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
sf_count_t (*write_float) (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
sf_count_t (*write_double) (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
|
||||
double buffer [SF_BUFFER_LEN / sizeof (double)] ;
|
||||
} DITHER_DATA ;
|
||||
@ -78,10 +77,10 @@ typedef struct
|
||||
static sf_count_t dither_read_short (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
|
||||
static sf_count_t dither_read_int (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
|
||||
static sf_count_t dither_write_short (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ;
|
||||
static sf_count_t dither_write_int (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ;
|
||||
static sf_count_t dither_write_float (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ;
|
||||
static sf_count_t dither_write_double (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
|
||||
static sf_count_t dither_write_short (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
|
||||
static sf_count_t dither_write_int (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
static sf_count_t dither_write_float (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
static sf_count_t dither_write_double (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
|
||||
int
|
||||
dither_init (SF_PRIVATE *psf, int mode)
|
||||
@ -194,14 +193,16 @@ static void dither_float (const float *in, float *out, int frames, int channels)
|
||||
static void dither_double (const double *in, double *out, int frames, int channels) ;
|
||||
|
||||
static sf_count_t
|
||||
dither_read_short (SF_PRIVATE * UNUSED (psf), short * UNUSED (ptr), sf_count_t len)
|
||||
{
|
||||
dither_read_short (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ psf = psf ;
|
||||
ptr = ptr ;
|
||||
return len ;
|
||||
} /* dither_read_short */
|
||||
|
||||
static sf_count_t
|
||||
dither_read_int (SF_PRIVATE * UNUSED (psf), int * UNUSED (ptr), sf_count_t len)
|
||||
{
|
||||
dither_read_int (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ psf = psf ;
|
||||
ptr = ptr ;
|
||||
return len ;
|
||||
} /* dither_read_int */
|
||||
|
||||
@ -209,7 +210,7 @@ dither_read_int (SF_PRIVATE * UNUSED (psf), int * UNUSED (ptr), sf_count_t len)
|
||||
*/
|
||||
|
||||
static sf_count_t
|
||||
dither_write_short (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
|
||||
dither_write_short (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ DITHER_DATA *pdither ;
|
||||
int bufferlen, writecount, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
@ -249,7 +250,7 @@ dither_write_short (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
|
||||
} /* dither_write_short */
|
||||
|
||||
static sf_count_t
|
||||
dither_write_int (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
|
||||
dither_write_int (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ DITHER_DATA *pdither ;
|
||||
int bufferlen, writecount, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
@ -294,7 +295,7 @@ dither_write_int (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
|
||||
} /* dither_write_int */
|
||||
|
||||
static sf_count_t
|
||||
dither_write_float (SF_PRIVATE *psf, const float *ptr, sf_count_t len)
|
||||
dither_write_float (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ DITHER_DATA *pdither ;
|
||||
int bufferlen, writecount, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
@ -338,7 +339,7 @@ dither_write_float (SF_PRIVATE *psf, const float *ptr, sf_count_t len)
|
||||
} /* dither_write_float */
|
||||
|
||||
static sf_count_t
|
||||
dither_write_double (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
|
||||
dither_write_double (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ DITHER_DATA *pdither ;
|
||||
int bufferlen, writecount, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
|
599
src/double64.c
599
src/double64.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2006 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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,14 +16,13 @@
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "sndfile.h"
|
||||
#include "config.h"
|
||||
#include "sfendian.h"
|
||||
#include "common.h"
|
||||
#include "float_cast.h"
|
||||
@ -36,9 +35,6 @@
|
||||
#define DOUBLE64_WRITE double64_be_write
|
||||
#endif
|
||||
|
||||
/* A 32 number which will not overflow when multiplied by sizeof (double). */
|
||||
#define SENSIBLE_LEN (0x8000000)
|
||||
|
||||
/*--------------------------------------------------------------------------------------------
|
||||
** Processor floating point capabilities. double64_get_capability () returns one of the
|
||||
** latter three values.
|
||||
@ -61,12 +57,20 @@ static sf_count_t host_read_d2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
static sf_count_t host_read_d2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
static sf_count_t host_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
|
||||
static sf_count_t host_write_s2d (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ;
|
||||
static sf_count_t host_write_i2d (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ;
|
||||
static sf_count_t host_write_f2d (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ;
|
||||
static sf_count_t host_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
|
||||
static sf_count_t host_write_s2d (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
|
||||
static sf_count_t host_write_i2d (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
static sf_count_t host_write_f2d (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
static sf_count_t host_write_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
|
||||
static void double64_peak_update (SF_PRIVATE *psf, const double *buffer, int count, sf_count_t indx) ;
|
||||
static void d2s_array (double *buffer, unsigned int count, short *ptr) ;
|
||||
static void d2i_array (double *buffer, unsigned int count, int *ptr) ;
|
||||
static void d2f_array (double *buffer, unsigned int count, float *ptr) ;
|
||||
|
||||
static void s2d_array (short *ptr, double *buffer, unsigned int count) ;
|
||||
static void i2d_array (int *ptr, double *buffer, unsigned int count) ;
|
||||
static void f2d_array (float *ptr, double *buffer, unsigned int count) ;
|
||||
|
||||
static void double64_peak_update (SF_PRIVATE *psf, double *buffer, int count, int indx) ;
|
||||
|
||||
static int double64_get_capability (SF_PRIVATE *psf) ;
|
||||
|
||||
@ -75,10 +79,10 @@ static sf_count_t replace_read_d2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
static sf_count_t replace_read_d2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
static sf_count_t replace_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
|
||||
static sf_count_t replace_write_s2d (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ;
|
||||
static sf_count_t replace_write_i2d (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ;
|
||||
static sf_count_t replace_write_f2d (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ;
|
||||
static sf_count_t replace_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
|
||||
static sf_count_t replace_write_s2d (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
|
||||
static sf_count_t replace_write_i2d (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
static sf_count_t replace_write_f2d (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
static sf_count_t replace_write_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
|
||||
static void d2bd_read (double *buffer, int count) ;
|
||||
static void bd2d_write (double *buffer, int count) ;
|
||||
@ -237,14 +241,10 @@ double64_init (SF_PRIVATE *psf)
|
||||
} ;
|
||||
} ;
|
||||
|
||||
if (psf->filelength > psf->dataoffset)
|
||||
{ psf->datalength = (psf->dataend > 0) ? psf->dataend - psf->dataoffset :
|
||||
psf->filelength = psf_get_filelen (psf) ;
|
||||
psf->datalength = (psf->dataend) ? psf->dataend - psf->dataoffset :
|
||||
psf->filelength - psf->dataoffset ;
|
||||
}
|
||||
else
|
||||
psf->datalength = 0 ;
|
||||
|
||||
psf->sf.frames = psf->datalength / psf->blockwidth ;
|
||||
psf->sf.frames = psf->datalength / (psf->sf.channels * sizeof (double)) ;
|
||||
|
||||
return 0 ;
|
||||
} /* double64_init */
|
||||
@ -277,20 +277,19 @@ double64_init (SF_PRIVATE *psf)
|
||||
|
||||
double
|
||||
double64_be_read (unsigned char *cptr)
|
||||
{ int exponent, negative, upper, lower ;
|
||||
{ int exponent, negative ;
|
||||
double dvalue ;
|
||||
|
||||
negative = (cptr [0] & 0x80) ? 1 : 0 ;
|
||||
exponent = ((cptr [0] & 0x7F) << 4) | ((cptr [1] >> 4) & 0xF) ;
|
||||
|
||||
/* Might not have a 64 bit long, so load the mantissa into a double. */
|
||||
upper = (((cptr [1] & 0xF) << 24) | (cptr [2] << 16) | (cptr [3] << 8) | cptr [4]) ;
|
||||
lower = (cptr [5] << 16) | (cptr [6] << 8) | cptr [7] ;
|
||||
dvalue = (((cptr [1] & 0xF) << 24) | (cptr [2] << 16) | (cptr [3] << 8) | cptr [4]) ;
|
||||
dvalue += ((cptr [5] << 16) | (cptr [6] << 8) | cptr [7]) / ((double) 0x1000000) ;
|
||||
|
||||
if (exponent == 0 && upper == 0 && lower == 0)
|
||||
if (exponent == 0 && dvalue == 0.0)
|
||||
return 0.0 ;
|
||||
|
||||
dvalue = upper + lower / ((double) 0x1000000) ;
|
||||
dvalue += 0x10000000 ;
|
||||
|
||||
exponent = exponent - 0x3FF ;
|
||||
@ -310,20 +309,19 @@ double64_be_read (unsigned char *cptr)
|
||||
|
||||
double
|
||||
double64_le_read (unsigned char *cptr)
|
||||
{ int exponent, negative, upper, lower ;
|
||||
{ int exponent, negative ;
|
||||
double dvalue ;
|
||||
|
||||
negative = (cptr [7] & 0x80) ? 1 : 0 ;
|
||||
exponent = ((cptr [7] & 0x7F) << 4) | ((cptr [6] >> 4) & 0xF) ;
|
||||
|
||||
/* Might not have a 64 bit long, so load the mantissa into a double. */
|
||||
upper = ((cptr [6] & 0xF) << 24) | (cptr [5] << 16) | (cptr [4] << 8) | cptr [3] ;
|
||||
lower = (cptr [2] << 16) | (cptr [1] << 8) | cptr [0] ;
|
||||
dvalue = (((cptr [6] & 0xF) << 24) | (cptr [5] << 16) | (cptr [4] << 8) | cptr [3]) ;
|
||||
dvalue += ((cptr [2] << 16) | (cptr [1] << 8) | cptr [0]) / ((double) 0x1000000) ;
|
||||
|
||||
if (exponent == 0 && upper == 0 && lower == 0)
|
||||
if (exponent == 0 && dvalue == 0.0)
|
||||
return 0.0 ;
|
||||
|
||||
dvalue = upper + lower / ((double) 0x1000000) ;
|
||||
dvalue += 0x10000000 ;
|
||||
|
||||
exponent = exponent - 0x3FF ;
|
||||
@ -347,7 +345,7 @@ double64_be_write (double in, unsigned char *out)
|
||||
|
||||
memset (out, 0, sizeof (double)) ;
|
||||
|
||||
if (fabs (in) < 1e-30)
|
||||
if (in == 0.0)
|
||||
return ;
|
||||
|
||||
if (in < 0.0)
|
||||
@ -387,7 +385,7 @@ double64_le_write (double in, unsigned char *out)
|
||||
|
||||
memset (out, 0, sizeof (double)) ;
|
||||
|
||||
if (fabs (in) < 1e-30)
|
||||
if (in == 0.0)
|
||||
return ;
|
||||
|
||||
if (in < 0.0)
|
||||
@ -426,7 +424,7 @@ double64_le_write (double in, unsigned char *out)
|
||||
*/
|
||||
|
||||
static void
|
||||
double64_peak_update (SF_PRIVATE *psf, const double *buffer, int count, sf_count_t indx)
|
||||
double64_peak_update (SF_PRIVATE *psf, double *buffer, int count, int indx)
|
||||
{ int chan ;
|
||||
int k, position ;
|
||||
float fmaxval ;
|
||||
@ -440,9 +438,9 @@ double64_peak_update (SF_PRIVATE *psf, const double *buffer, int count, sf_count
|
||||
position = k ;
|
||||
} ;
|
||||
|
||||
if (fmaxval > psf->peak_info->peaks [chan].value)
|
||||
{ psf->peak_info->peaks [chan].value = fmaxval ;
|
||||
psf->peak_info->peaks [chan].position = psf->write_current + indx + (position / psf->sf.channels) ;
|
||||
if (fmaxval > psf->peak.peak [chan].value)
|
||||
{ psf->peak.peak [chan].value = fmaxval ;
|
||||
psf->peak.peak [chan].position = psf->write_current + indx + (position / psf->sf.channels) ;
|
||||
} ;
|
||||
} ;
|
||||
|
||||
@ -453,6 +451,7 @@ static int
|
||||
double64_get_capability (SF_PRIVATE *psf)
|
||||
{ union
|
||||
{ double d ;
|
||||
int i [2] ;
|
||||
unsigned char c [8] ;
|
||||
} data ;
|
||||
|
||||
@ -460,13 +459,13 @@ double64_get_capability (SF_PRIVATE *psf)
|
||||
|
||||
if (! psf->ieee_replace)
|
||||
{ /* If this test is true ints and floats are compatible and little endian. */
|
||||
if (data.c [0] == 0xfb && data.c [1] == 0x59 && data.c [2] == 0x8c && data.c [3] == 0x42 &&
|
||||
data.c [4] == 0xca && data.c [5] == 0xc0 && data.c [6] == 0xf3 && data.c [7] == 0x3f)
|
||||
if (data.i [0] == 0x428c59fb && data.i [1] == 0x3ff3c0ca &&
|
||||
data.c [0] == 0xfb && data.c [2] == 0x8c && data.c [4] == 0xca && data.c [6] == 0xf3)
|
||||
return DOUBLE_CAN_RW_LE ;
|
||||
|
||||
/* If this test is true ints and floats are compatible and big endian. */
|
||||
if (data.c [0] == 0x3f && data.c [1] == 0xf3 && data.c [2] == 0xc0 && data.c [3] == 0xca &&
|
||||
data.c [4] == 0x42 && data.c [5] == 0x8c && data.c [6] == 0x59 && data.c [7] == 0xfb)
|
||||
if (data.i [0] == 0x3ff3c0ca && data.i [1] == 0x428c59fb &&
|
||||
data.c [0] == 0x3f && data.c [2] == 0xc0 && data.c [4] == 0x42 && data.c [6] == 0x59)
|
||||
return DOUBLE_CAN_RW_BE ;
|
||||
} ;
|
||||
|
||||
@ -476,105 +475,28 @@ double64_get_capability (SF_PRIVATE *psf)
|
||||
return (CPU_IS_LITTLE_ENDIAN) ? DOUBLE_BROKEN_LE : DOUBLE_BROKEN_BE ;
|
||||
} /* double64_get_capability */
|
||||
|
||||
/*=======================================================================================
|
||||
*/
|
||||
|
||||
static void
|
||||
d2s_array (const double *src, int count, short *dest, double scale)
|
||||
{ while (--count >= 0)
|
||||
{ dest [count] = lrint (scale * src [count]) ;
|
||||
} ;
|
||||
} /* d2s_array */
|
||||
|
||||
static void
|
||||
d2s_clip_array (const double *src, int count, short *dest, double scale)
|
||||
{ while (--count >= 0)
|
||||
{ double tmp = scale * src [count] ;
|
||||
|
||||
if (CPU_CLIPS_POSITIVE == 0 && tmp > 32767.0)
|
||||
dest [count] = SHRT_MAX ;
|
||||
else if (CPU_CLIPS_NEGATIVE == 0 && tmp < -32768.0)
|
||||
dest [count] = SHRT_MIN ;
|
||||
else
|
||||
dest [count] = lrint (tmp) ;
|
||||
} ;
|
||||
} /* d2s_clip_array */
|
||||
|
||||
static void
|
||||
d2i_array (const double *src, int count, int *dest, double scale)
|
||||
{ while (--count >= 0)
|
||||
{ dest [count] = lrint (scale * src [count]) ;
|
||||
} ;
|
||||
} /* d2i_array */
|
||||
|
||||
static void
|
||||
d2i_clip_array (const double *src, int count, int *dest, double scale)
|
||||
{ while (--count >= 0)
|
||||
{ float tmp = scale * src [count] ;
|
||||
|
||||
if (CPU_CLIPS_POSITIVE == 0 && tmp > (1.0 * INT_MAX))
|
||||
dest [count] = INT_MAX ;
|
||||
else if (CPU_CLIPS_NEGATIVE == 0 && tmp < (-1.0 * INT_MAX))
|
||||
dest [count] = INT_MIN ;
|
||||
else
|
||||
dest [count] = lrint (tmp) ;
|
||||
} ;
|
||||
} /* d2i_clip_array */
|
||||
|
||||
static inline void
|
||||
d2f_array (const double *src, int count, float *dest)
|
||||
{ while (--count >= 0)
|
||||
{ dest [count] = src [count] ;
|
||||
} ;
|
||||
} /* d2f_array */
|
||||
|
||||
static inline void
|
||||
s2d_array (const short *src, double *dest, int count)
|
||||
{ while (--count >= 0)
|
||||
{ dest [count] = src [count] ;
|
||||
} ;
|
||||
} /* s2d_array */
|
||||
|
||||
static inline void
|
||||
i2d_array (const int *src, double *dest, int count)
|
||||
{ while (--count >= 0)
|
||||
{ dest [count] = src [count] ;
|
||||
} ;
|
||||
} /* i2d_array */
|
||||
|
||||
static inline void
|
||||
f2d_array (const float *src, double *dest, int count)
|
||||
{ while (--count >= 0)
|
||||
{ dest [count] = src [count] ;
|
||||
} ;
|
||||
} /* f2d_array */
|
||||
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
static sf_count_t
|
||||
host_read_d2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ void (*convert) (const double *, int, short *, double) ;
|
||||
int bufferlen, readcount ;
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
sf_count_t total = 0 ;
|
||||
double scale ;
|
||||
|
||||
convert = (psf->add_clipping) ? d2s_clip_array : d2s_array ;
|
||||
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
|
||||
scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFF / psf->float_max ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (double) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->buffer, sizeof (double), readcount, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_double_array (psf->u.dbuf, readcount) ;
|
||||
endswap_long_array ((long*) psf->buffer, readcount) ;
|
||||
|
||||
convert (psf->u.dbuf, readcount, ptr + total, scale) ;
|
||||
total += readcount ;
|
||||
len -= readcount ;
|
||||
if (readcount < bufferlen)
|
||||
d2s_array ((double*) (psf->buffer), thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
len -= thisread ;
|
||||
if (thisread < readcount)
|
||||
break ;
|
||||
} ;
|
||||
|
||||
@ -583,27 +505,22 @@ host_read_d2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
host_read_d2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ void (*convert) (const double *, int, int *, double) ;
|
||||
int bufferlen, readcount ;
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
sf_count_t total = 0 ;
|
||||
double scale ;
|
||||
|
||||
convert = (psf->add_clipping) ? d2i_clip_array : d2i_array ;
|
||||
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
|
||||
scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFFFFFF / psf->float_max ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (double) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->buffer, sizeof (double), readcount, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_double_array (psf->u.dbuf, bufferlen) ;
|
||||
endswap_long_array ((long*) psf->buffer, readcount) ;
|
||||
|
||||
convert (psf->u.dbuf, readcount, ptr + total, scale) ;
|
||||
total += readcount ;
|
||||
len -= readcount ;
|
||||
if (readcount < bufferlen)
|
||||
d2i_array ((double*) (psf->buffer), thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
len -= thisread ;
|
||||
if (thisread < readcount)
|
||||
break ;
|
||||
} ;
|
||||
|
||||
@ -612,23 +529,22 @@ host_read_d2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
host_read_d2f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount ;
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (double) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->buffer, sizeof (double), readcount, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_double_array (psf->u.dbuf, bufferlen) ;
|
||||
endswap_long_array ((long*) psf->buffer, readcount) ;
|
||||
|
||||
d2f_array (psf->u.dbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
len -= readcount ;
|
||||
if (readcount < bufferlen)
|
||||
d2f_array ((double*) (psf->buffer), thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
len -= thisread ;
|
||||
if (thisread < readcount)
|
||||
break ;
|
||||
} ;
|
||||
|
||||
@ -637,143 +553,134 @@ host_read_d2f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
host_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int bufferlen ;
|
||||
sf_count_t readcount, total = 0 ;
|
||||
|
||||
readcount = psf_fread (ptr, sizeof (double), len, psf) ;
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (psf->float_endswap != SF_TRUE)
|
||||
return readcount ;
|
||||
return psf_fread (ptr, sizeof (double), len, psf) ;
|
||||
|
||||
/* If the read length was sensible, endswap output in one go. */
|
||||
if (readcount < SENSIBLE_LEN)
|
||||
{ endswap_double_array (ptr, readcount) ;
|
||||
return readcount ;
|
||||
} ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (double) ;
|
||||
|
||||
bufferlen = SENSIBLE_LEN ;
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->buffer, sizeof (double), readcount, psf) ;
|
||||
|
||||
endswap_double_array (ptr + total, bufferlen) ;
|
||||
endswap_long_copy ((long*) (ptr + total), (long*) psf->buffer, thisread) ;
|
||||
|
||||
total += bufferlen ;
|
||||
len -= bufferlen ;
|
||||
total += thisread ;
|
||||
len -= thisread ;
|
||||
if (thisread < readcount)
|
||||
break ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* host_read_d */
|
||||
|
||||
static sf_count_t
|
||||
host_write_s2d (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount ;
|
||||
host_write_s2d (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (double) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
|
||||
s2d_array (ptr + total, psf->u.dbuf, bufferlen) ;
|
||||
s2d_array (ptr + total, (double*) (psf->buffer), writecount) ;
|
||||
|
||||
if (psf->peak_info)
|
||||
double64_peak_update (psf, psf->u.dbuf, bufferlen, total / psf->sf.channels) ;
|
||||
if (psf->has_peak)
|
||||
double64_peak_update (psf, (double*) (psf->buffer), writecount, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_double_array (psf->u.dbuf, bufferlen) ;
|
||||
endswap_long_array ((long*) psf->buffer, writecount) ;
|
||||
|
||||
writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
thiswrite = psf_fwrite (psf->buffer, sizeof (double), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
len -= thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* host_write_s2d */
|
||||
|
||||
static sf_count_t
|
||||
host_write_i2d (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount ;
|
||||
host_write_i2d (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (double) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
i2d_array (ptr + total, psf->u.dbuf, bufferlen) ;
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
i2d_array (ptr + total, (double*) (psf->buffer), writecount) ;
|
||||
|
||||
if (psf->peak_info)
|
||||
double64_peak_update (psf, psf->u.dbuf, bufferlen, total / psf->sf.channels) ;
|
||||
if (psf->has_peak)
|
||||
double64_peak_update (psf, (double*) (psf->buffer), writecount, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_double_array (psf->u.dbuf, bufferlen) ;
|
||||
endswap_long_array ((long*) psf->buffer, writecount) ;
|
||||
|
||||
writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
thiswrite = psf_fwrite (psf->buffer, sizeof (double), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
len -= thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* host_write_i2d */
|
||||
|
||||
static sf_count_t
|
||||
host_write_f2d (SF_PRIVATE *psf, const float *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount ;
|
||||
host_write_f2d (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (double) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
f2d_array (ptr + total, psf->u.dbuf, bufferlen) ;
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
f2d_array (ptr + total, (double*) (psf->buffer), writecount) ;
|
||||
|
||||
if (psf->peak_info)
|
||||
double64_peak_update (psf, psf->u.dbuf, bufferlen, total / psf->sf.channels) ;
|
||||
if (psf->has_peak)
|
||||
double64_peak_update (psf, (double*) (psf->buffer), writecount, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_double_array (psf->u.dbuf, bufferlen) ;
|
||||
endswap_long_array ((long*) psf->buffer, writecount) ;
|
||||
|
||||
writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
thiswrite = psf_fwrite (psf->buffer, sizeof (double), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
len -= thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* host_write_f2d */
|
||||
|
||||
static sf_count_t
|
||||
host_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount ;
|
||||
host_write_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (psf->peak_info)
|
||||
if (psf->has_peak)
|
||||
double64_peak_update (psf, ptr, len, 0) ;
|
||||
|
||||
if (psf->float_endswap != SF_TRUE)
|
||||
return psf_fwrite (ptr, sizeof (double), len, psf) ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (double) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
|
||||
endswap_double_copy (psf->u.dbuf, ptr + total, bufferlen) ;
|
||||
endswap_long_copy ((long*) psf->buffer, (long*) (ptr + total), writecount) ;
|
||||
|
||||
writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
thiswrite = psf_fwrite (psf->buffer, sizeof (double), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
len -= thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -782,30 +689,79 @@ host_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
|
||||
/*=======================================================================================
|
||||
*/
|
||||
|
||||
static void
|
||||
d2s_array (double *src, unsigned int count, short *dest)
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
dest [count] = lrint (src [count]) ;
|
||||
} ;
|
||||
} /* d2s_array */
|
||||
|
||||
static void
|
||||
d2i_array (double *src, unsigned int count, int *dest)
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
dest [count] = lrint (src [count]) ;
|
||||
} ;
|
||||
} /* d2i_array */
|
||||
|
||||
static void
|
||||
d2f_array (double *src, unsigned int count, float *dest)
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
dest [count] = src [count] ;
|
||||
} ;
|
||||
} /* d2f_array */
|
||||
|
||||
static void
|
||||
s2d_array (short *src, double *dest, unsigned int count)
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
dest [count] = src [count] ;
|
||||
} ;
|
||||
|
||||
} /* s2d_array */
|
||||
|
||||
static void
|
||||
i2d_array (int *src, double *dest, unsigned int count)
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
dest [count] = src [count] ;
|
||||
} ;
|
||||
} /* i2d_array */
|
||||
|
||||
static void
|
||||
f2d_array (float *src, double *dest, unsigned int count)
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
dest [count] = src [count] ;
|
||||
} ;
|
||||
} /* f2d_array */
|
||||
|
||||
/*=======================================================================================
|
||||
*/
|
||||
|
||||
static sf_count_t
|
||||
replace_read_d2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount ;
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
sf_count_t total = 0 ;
|
||||
double scale ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
|
||||
scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFF / psf->float_max ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (double) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->buffer, sizeof (double), readcount, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_double_array (psf->u.dbuf, bufferlen) ;
|
||||
endswap_long_array ((long*) psf->buffer, readcount) ;
|
||||
|
||||
d2bd_read (psf->u.dbuf, bufferlen) ;
|
||||
d2bd_read ((double *) (psf->buffer), readcount) ;
|
||||
|
||||
d2s_array (psf->u.dbuf, readcount, ptr + total, scale) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
d2s_array ((double*) (psf->buffer), thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
len -= thisread ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -813,28 +769,25 @@ replace_read_d2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
replace_read_d2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount ;
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
sf_count_t total = 0 ;
|
||||
double scale ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
|
||||
scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFFFFFF / psf->float_max ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (double) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->buffer, sizeof (double), readcount, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_double_array (psf->u.dbuf, bufferlen) ;
|
||||
endswap_long_array ((long*) psf->buffer, readcount) ;
|
||||
|
||||
d2bd_read (psf->u.dbuf, bufferlen) ;
|
||||
d2bd_read ((double *) (psf->buffer), readcount) ;
|
||||
|
||||
d2i_array (psf->u.dbuf, readcount, ptr + total, scale) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
d2i_array ((double*) (psf->buffer), thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
len -= thisread ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -842,27 +795,26 @@ replace_read_d2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
replace_read_d2f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount ;
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (double) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->buffer, sizeof (double), readcount, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_double_array (psf->u.dbuf, bufferlen) ;
|
||||
endswap_long_array ((long *) psf->buffer, readcount) ;
|
||||
|
||||
d2bd_read (psf->u.dbuf, bufferlen) ;
|
||||
d2bd_read ((double *) (psf->buffer), readcount) ;
|
||||
|
||||
memcpy (ptr + total, psf->u.dbuf, bufferlen * sizeof (double)) ;
|
||||
memcpy (ptr + total, psf->buffer, readcount * sizeof (double)) ;
|
||||
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
len -= thisread ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -870,147 +822,142 @@ replace_read_d2f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
replace_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount ;
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
/* FIXME : This is probably nowhere near optimal. */
|
||||
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (double) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->buffer, sizeof (double), readcount, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_double_array (psf->u.dbuf, readcount) ;
|
||||
endswap_long_array ((long*) psf->buffer, thisread) ;
|
||||
|
||||
d2bd_read (psf->u.dbuf, readcount) ;
|
||||
d2bd_read ((double *) (psf->buffer), thisread) ;
|
||||
|
||||
memcpy (ptr + total, psf->u.dbuf, readcount * sizeof (double)) ;
|
||||
memcpy (ptr + total, psf->buffer, thisread * sizeof (double)) ;
|
||||
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
len -= thisread ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* replace_read_d */
|
||||
|
||||
static sf_count_t
|
||||
replace_write_s2d (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount ;
|
||||
replace_write_s2d (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ int writecount, bufferlen, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (double) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
s2d_array (ptr + total, psf->u.dbuf, bufferlen) ;
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
s2d_array (ptr + total, (double *) (psf->buffer), writecount) ;
|
||||
|
||||
if (psf->peak_info)
|
||||
double64_peak_update (psf, psf->u.dbuf, bufferlen, total / psf->sf.channels) ;
|
||||
if (psf->has_peak)
|
||||
double64_peak_update (psf, (double *) (psf->buffer), writecount, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
bd2d_write (psf->u.dbuf, bufferlen) ;
|
||||
bd2d_write ((double *) (psf->buffer), writecount) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_double_array (psf->u.dbuf, bufferlen) ;
|
||||
endswap_long_array ((long*) psf->buffer, writecount) ;
|
||||
|
||||
writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
thiswrite = psf_fwrite (psf->buffer, sizeof (double), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
len -= thiswrite ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* replace_write_s2d */
|
||||
|
||||
static sf_count_t
|
||||
replace_write_i2d (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount ;
|
||||
replace_write_i2d (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ int writecount, bufferlen, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (double) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
i2d_array (ptr + total, psf->u.dbuf, bufferlen) ;
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
i2d_array (ptr + total, (double*) (psf->buffer), writecount) ;
|
||||
|
||||
if (psf->peak_info)
|
||||
double64_peak_update (psf, psf->u.dbuf, bufferlen, total / psf->sf.channels) ;
|
||||
if (psf->has_peak)
|
||||
double64_peak_update (psf, (double *) (psf->buffer), writecount, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
bd2d_write (psf->u.dbuf, bufferlen) ;
|
||||
bd2d_write ((double *) (psf->buffer), writecount) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_double_array (psf->u.dbuf, bufferlen) ;
|
||||
endswap_long_array ((long*) psf->buffer, writecount) ;
|
||||
|
||||
writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
thiswrite = psf_fwrite (psf->buffer, sizeof (double), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
len -= thiswrite ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* replace_write_i2d */
|
||||
|
||||
static sf_count_t
|
||||
replace_write_f2d (SF_PRIVATE *psf, const float *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount ;
|
||||
replace_write_f2d (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int writecount, bufferlen, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (double) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
f2d_array (ptr + total, psf->u.dbuf, bufferlen) ;
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
f2d_array (ptr + total, (double*) (psf->buffer), writecount) ;
|
||||
|
||||
bd2d_write (psf->u.dbuf, bufferlen) ;
|
||||
bd2d_write ((double *) (psf->buffer), writecount) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_double_array (psf->u.dbuf, bufferlen) ;
|
||||
endswap_long_array ((long*) psf->buffer, writecount) ;
|
||||
|
||||
writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
thiswrite = psf_fwrite (psf->buffer, sizeof (double), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
len -= thiswrite ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* replace_write_f2d */
|
||||
|
||||
static sf_count_t
|
||||
replace_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount ;
|
||||
replace_write_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int writecount, bufferlen, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
/* FIXME : This is probably nowhere near optimal. */
|
||||
if (psf->peak_info)
|
||||
if (psf->has_peak)
|
||||
double64_peak_update (psf, ptr, len, 0) ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (double) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
|
||||
memcpy (psf->u.dbuf, ptr + total, bufferlen * sizeof (double)) ;
|
||||
memcpy (psf->buffer, ptr + total, writecount * sizeof (double)) ;
|
||||
|
||||
bd2d_write (psf->u.dbuf, bufferlen) ;
|
||||
bd2d_write ((double *) (psf->buffer), writecount) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_double_array (psf->u.dbuf, bufferlen) ;
|
||||
endswap_long_array ((long*) psf->buffer, writecount) ;
|
||||
|
||||
writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
thiswrite = psf_fwrite (psf->buffer, sizeof (double), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
len -= thiswrite ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -1021,21 +968,23 @@ replace_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
|
||||
|
||||
static void
|
||||
d2bd_read (double *buffer, int count)
|
||||
{ while (--count >= 0)
|
||||
{ buffer [count] = DOUBLE64_READ ((unsigned char *) (buffer + count)) ;
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
buffer [count] = DOUBLE64_READ ((unsigned char *) (buffer + count)) ;
|
||||
} ;
|
||||
} /* d2bd_read */
|
||||
|
||||
static void
|
||||
bd2d_write (double *buffer, int count)
|
||||
{ while (--count >= 0)
|
||||
{ DOUBLE64_WRITE (buffer [count], (unsigned char*) (buffer + count)) ;
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
DOUBLE64_WRITE (buffer [count], (unsigned char*) (buffer + count)) ;
|
||||
} ;
|
||||
} /* bd2d_write */
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 4ee243b7-8c7a-469b-869c-e9aa0ee3b77f
|
||||
|
21
src/dwd.c
21
src/dwd.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2002,2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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,14 +16,13 @@
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "sndfile.h"
|
||||
#include "config.h"
|
||||
#include "sfendian.h"
|
||||
#include "common.h"
|
||||
|
||||
@ -33,7 +32,7 @@ int
|
||||
dwd_open (SF_PRIVATE *psf)
|
||||
{ if (psf)
|
||||
return SFE_UNIMPLEMENTED ;
|
||||
return 0 ;
|
||||
return (psf && 0) ;
|
||||
} /* dwd_open */
|
||||
|
||||
#else
|
||||
@ -96,7 +95,7 @@ dwd_open (SF_PRIVATE *psf)
|
||||
-*/
|
||||
} ;
|
||||
|
||||
psf->container_close = dwd_close ;
|
||||
psf->close = dwd_close ;
|
||||
|
||||
/*-psf->blockwidth = psf->bytewidth * psf->sf.channels ;-*/
|
||||
|
||||
@ -107,8 +106,10 @@ dwd_open (SF_PRIVATE *psf)
|
||||
*/
|
||||
|
||||
static int
|
||||
dwd_close (SF_PRIVATE * UNUSED (psf))
|
||||
dwd_close (SF_PRIVATE *psf)
|
||||
{
|
||||
psf = psf ;
|
||||
|
||||
return 0 ;
|
||||
} /* dwd_close */
|
||||
|
||||
@ -126,14 +127,14 @@ static int
|
||||
dwd_read_header (SF_PRIVATE *psf)
|
||||
{ DWD_HEADER dwdh ;
|
||||
|
||||
memset (psf->u.cbuf, 0, sizeof (psf->u.cbuf)) ;
|
||||
memset (psf->buffer, 0, sizeof (psf->buffer)) ;
|
||||
/* Set position to start of file to begin reading header. */
|
||||
psf_binheader_readf (psf, "pb", 0, psf->u.cbuf, DWD_IDENTIFIER_LEN) ;
|
||||
psf_binheader_readf (psf, "pb", 0, psf->buffer, DWD_IDENTIFIER_LEN) ;
|
||||
|
||||
if (memcmp (psf->u.cbuf, DWD_IDENTIFIER, DWD_IDENTIFIER_LEN) != 0)
|
||||
if (memcmp (psf->buffer, DWD_IDENTIFIER, DWD_IDENTIFIER_LEN) != 0)
|
||||
return SFE_DWD_NO_DWD ;
|
||||
|
||||
psf_log_printf (psf, "Read only : DiamondWare Digitized (.dwd)\n", psf->u.cbuf) ;
|
||||
psf_log_printf (psf, "Read only : DiamondWare Digitized (.dwd)\n", psf->buffer) ;
|
||||
|
||||
psf_binheader_readf (psf, "11", &dwdh.major, &dwdh.minor) ;
|
||||
psf_binheader_readf (psf, "e4j1", &dwdh.id, 1, &dwdh.compression) ;
|
||||
|
117
src/dwvw.c
117
src/dwvw.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2002-2005 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2002,2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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
|
||||
@ -26,13 +26,12 @@
|
||||
** Lidstrom and is copyright 1993 by NuEdge Development".
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "sndfile.h"
|
||||
#include "config.h"
|
||||
#include "sfendian.h"
|
||||
#include "float_cast.h"
|
||||
#include "common.h"
|
||||
@ -55,10 +54,10 @@ static sf_count_t dwvw_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
static sf_count_t dwvw_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
static sf_count_t dwvw_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
|
||||
static sf_count_t dwvw_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ;
|
||||
static sf_count_t dwvw_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ;
|
||||
static sf_count_t dwvw_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ;
|
||||
static sf_count_t dwvw_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
|
||||
static sf_count_t dwvw_write_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
|
||||
static sf_count_t dwvw_write_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
static sf_count_t dwvw_write_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
static sf_count_t dwvw_write_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
|
||||
static sf_count_t dwvw_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ;
|
||||
static int dwvw_close (SF_PRIVATE *psf) ;
|
||||
@ -66,7 +65,7 @@ static int dwvw_close (SF_PRIVATE *psf) ;
|
||||
static int dwvw_decode_data (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int *ptr, int len) ;
|
||||
static int dwvw_decode_load_bits (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int bit_count) ;
|
||||
|
||||
static int dwvw_encode_data (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, const int *ptr, int len) ;
|
||||
static int dwvw_encode_data (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int *ptr, int len) ;
|
||||
static void dwvw_encode_store_bits (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int data, int new_bits) ;
|
||||
static void dwvw_read_reset (DWVW_PRIVATE *pdwvw) ;
|
||||
|
||||
@ -78,21 +77,18 @@ int
|
||||
dwvw_init (SF_PRIVATE *psf, int bitwidth)
|
||||
{ DWVW_PRIVATE *pdwvw ;
|
||||
|
||||
if (psf->codec_data != NULL)
|
||||
{ psf_log_printf (psf, "*** psf->codec_data is not NULL.\n") ;
|
||||
return SFE_INTERNAL ;
|
||||
} ;
|
||||
|
||||
if (bitwidth > 24)
|
||||
return SFE_DWVW_BAD_BITWIDTH ;
|
||||
|
||||
if (psf->mode == SFM_RDWR)
|
||||
return SFE_BAD_MODE_RW ;
|
||||
|
||||
if ((pdwvw = calloc (1, sizeof (DWVW_PRIVATE))) == NULL)
|
||||
if (! (pdwvw = malloc (sizeof (DWVW_PRIVATE))))
|
||||
return SFE_MALLOC_FAILED ;
|
||||
|
||||
psf->codec_data = (void*) pdwvw ;
|
||||
psf->fdata = (void*) pdwvw ;
|
||||
|
||||
memset (pdwvw, 0, sizeof (DWVW_PRIVATE)) ;
|
||||
|
||||
pdwvw->bit_width = bitwidth ;
|
||||
pdwvw->dwm_maxsize = bitwidth / 2 ;
|
||||
@ -115,13 +111,13 @@ dwvw_init (SF_PRIVATE *psf, int bitwidth)
|
||||
psf->write_double = dwvw_write_d ;
|
||||
} ;
|
||||
|
||||
psf->codec_close = dwvw_close ;
|
||||
psf->seek = dwvw_seek ;
|
||||
psf->seek = dwvw_seek ;
|
||||
psf->close = dwvw_close ;
|
||||
|
||||
/* FIXME : This is bogus. */
|
||||
/* FIXME : This s bogus. */
|
||||
psf->sf.frames = SF_COUNT_MAX ;
|
||||
psf->datalength = psf->sf.frames ;
|
||||
/* EMXIF : This is bogus. */
|
||||
/* EMXIF : This s bogus. */
|
||||
|
||||
return 0 ;
|
||||
} /* dwvw_init */
|
||||
@ -133,9 +129,9 @@ static int
|
||||
dwvw_close (SF_PRIVATE *psf)
|
||||
{ DWVW_PRIVATE *pdwvw ;
|
||||
|
||||
if (psf->codec_data == NULL)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pdwvw = (DWVW_PRIVATE*) psf->codec_data ;
|
||||
pdwvw = (DWVW_PRIVATE*) psf->fdata ;
|
||||
|
||||
if (psf->mode == SFM_WRITE)
|
||||
{ static int last_values [12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } ;
|
||||
@ -154,15 +150,17 @@ dwvw_close (SF_PRIVATE *psf)
|
||||
} /* dwvw_close */
|
||||
|
||||
static sf_count_t
|
||||
dwvw_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset)
|
||||
dwvw_seek (SF_PRIVATE *psf, int mode, sf_count_t offset)
|
||||
{ DWVW_PRIVATE *pdwvw ;
|
||||
|
||||
if (! psf->codec_data)
|
||||
mode = mode ;
|
||||
|
||||
if (! psf->fdata)
|
||||
{ psf->error = SFE_INTERNAL ;
|
||||
return PSF_SEEK_ERROR ;
|
||||
return ((sf_count_t) -1) ;
|
||||
} ;
|
||||
|
||||
pdwvw = (DWVW_PRIVATE*) psf->codec_data ;
|
||||
pdwvw = (DWVW_PRIVATE*) psf->fdata ;
|
||||
|
||||
if (offset == 0)
|
||||
{ psf_fseek (psf, psf->dataoffset, SEEK_SET) ;
|
||||
@ -171,7 +169,7 @@ dwvw_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset)
|
||||
} ;
|
||||
|
||||
psf->error = SFE_BAD_SEEK ;
|
||||
return PSF_SEEK_ERROR ;
|
||||
return ((sf_count_t) -1) ;
|
||||
} /* dwvw_seek */
|
||||
|
||||
|
||||
@ -185,12 +183,12 @@ dwvw_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
int k, bufferlen, readcount = 0, count ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (! psf->codec_data)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pdwvw = (DWVW_PRIVATE*) psf->codec_data ;
|
||||
pdwvw = (DWVW_PRIVATE*) psf->fdata ;
|
||||
|
||||
iptr = psf->u.ibuf ;
|
||||
bufferlen = ARRAY_LEN (psf->u.ibuf) ;
|
||||
iptr = (int*) psf->buffer ;
|
||||
bufferlen = SF_BUFFER_LEN / sizeof (int) ;
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : len ;
|
||||
count = dwvw_decode_data (psf, pdwvw, iptr, readcount) ;
|
||||
@ -212,9 +210,9 @@ dwvw_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
int readcount, count ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (! psf->codec_data)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pdwvw = (DWVW_PRIVATE*) psf->codec_data ;
|
||||
pdwvw = (DWVW_PRIVATE*) psf->fdata ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len > 0x10000000) ? 0x10000000 : (int) len ;
|
||||
@ -239,14 +237,14 @@ dwvw_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
sf_count_t total = 0 ;
|
||||
float normfact ;
|
||||
|
||||
if (! psf->codec_data)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pdwvw = (DWVW_PRIVATE*) psf->codec_data ;
|
||||
pdwvw = (DWVW_PRIVATE*) psf->fdata ;
|
||||
|
||||
normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80000000) : 1.0 ;
|
||||
|
||||
iptr = psf->u.ibuf ;
|
||||
bufferlen = ARRAY_LEN (psf->u.ibuf) ;
|
||||
iptr = (int*) psf->buffer ;
|
||||
bufferlen = SF_BUFFER_LEN / sizeof (int) ;
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : len ;
|
||||
count = dwvw_decode_data (psf, pdwvw, iptr, readcount) ;
|
||||
@ -270,14 +268,14 @@ dwvw_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
sf_count_t total = 0 ;
|
||||
double normfact ;
|
||||
|
||||
if (! psf->codec_data)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pdwvw = (DWVW_PRIVATE*) psf->codec_data ;
|
||||
pdwvw = (DWVW_PRIVATE*) psf->fdata ;
|
||||
|
||||
normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x80000000) : 1.0 ;
|
||||
|
||||
iptr = psf->u.ibuf ;
|
||||
bufferlen = ARRAY_LEN (psf->u.ibuf) ;
|
||||
iptr = (int*) psf->buffer ;
|
||||
bufferlen = SF_BUFFER_LEN / sizeof (int) ;
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : len ;
|
||||
count = dwvw_decode_data (psf, pdwvw, iptr, readcount) ;
|
||||
@ -471,7 +469,7 @@ dump_bits (DWVW_PRIVATE *pdwvw)
|
||||
} ;
|
||||
|
||||
static int
|
||||
dwvw_encode_data (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, const int *ptr, int len)
|
||||
dwvw_encode_data (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int *ptr, int len)
|
||||
{ int count ;
|
||||
int delta_width_modifier, delta, delta_negative, delta_width, extra_bit ;
|
||||
|
||||
@ -546,18 +544,18 @@ dwvw_encode_data (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, const int *ptr, int len)
|
||||
} /* dwvw_encode_data */
|
||||
|
||||
static sf_count_t
|
||||
dwvw_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
|
||||
dwvw_write_s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ DWVW_PRIVATE *pdwvw ;
|
||||
int *iptr ;
|
||||
int k, bufferlen, writecount = 0, count ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (! psf->codec_data)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pdwvw = (DWVW_PRIVATE*) psf->codec_data ;
|
||||
pdwvw = (DWVW_PRIVATE*) psf->fdata ;
|
||||
|
||||
iptr = psf->u.ibuf ;
|
||||
bufferlen = ARRAY_LEN (psf->u.ibuf) ;
|
||||
iptr = (int*) psf->buffer ;
|
||||
bufferlen = SF_BUFFER_LEN / sizeof (int) ;
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : len ;
|
||||
for (k = 0 ; k < writecount ; k++)
|
||||
@ -574,14 +572,14 @@ dwvw_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
|
||||
} /* dwvw_write_s */
|
||||
|
||||
static sf_count_t
|
||||
dwvw_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
|
||||
dwvw_write_i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ DWVW_PRIVATE *pdwvw ;
|
||||
int writecount, count ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (! psf->codec_data)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pdwvw = (DWVW_PRIVATE*) psf->codec_data ;
|
||||
pdwvw = (DWVW_PRIVATE*) psf->fdata ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len > 0x10000000) ? 0x10000000 : (int) len ;
|
||||
@ -599,21 +597,21 @@ dwvw_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
|
||||
} /* dwvw_write_i */
|
||||
|
||||
static sf_count_t
|
||||
dwvw_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len)
|
||||
dwvw_write_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ DWVW_PRIVATE *pdwvw ;
|
||||
int *iptr ;
|
||||
int k, bufferlen, writecount = 0, count ;
|
||||
sf_count_t total = 0 ;
|
||||
float normfact ;
|
||||
|
||||
if (! psf->codec_data)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pdwvw = (DWVW_PRIVATE*) psf->codec_data ;
|
||||
pdwvw = (DWVW_PRIVATE*) psf->fdata ;
|
||||
|
||||
normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7FFFFFFF) : 1.0 ;
|
||||
|
||||
iptr = psf->u.ibuf ;
|
||||
bufferlen = ARRAY_LEN (psf->u.ibuf) ;
|
||||
iptr = (int*) psf->buffer ;
|
||||
bufferlen = SF_BUFFER_LEN / sizeof (short) ;
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : len ;
|
||||
for (k = 0 ; k < writecount ; k++)
|
||||
@ -630,21 +628,21 @@ dwvw_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len)
|
||||
} /* dwvw_write_f */
|
||||
|
||||
static sf_count_t
|
||||
dwvw_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
|
||||
dwvw_write_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ DWVW_PRIVATE *pdwvw ;
|
||||
int *iptr ;
|
||||
int k, bufferlen, writecount = 0, count ;
|
||||
sf_count_t total = 0 ;
|
||||
double normfact ;
|
||||
|
||||
if (! psf->codec_data)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pdwvw = (DWVW_PRIVATE*) psf->codec_data ;
|
||||
pdwvw = (DWVW_PRIVATE*) psf->fdata ;
|
||||
|
||||
normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x7FFFFFFF) : 1.0 ;
|
||||
|
||||
iptr = psf->u.ibuf ;
|
||||
bufferlen = ARRAY_LEN (psf->u.ibuf) ;
|
||||
iptr = (int*) psf->buffer ;
|
||||
bufferlen = SF_BUFFER_LEN / sizeof (short) ;
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : len ;
|
||||
for (k = 0 ; k < writecount ; k++)
|
||||
@ -659,7 +657,6 @@ dwvw_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
|
||||
|
||||
return total ;
|
||||
} /* dwvw_write_d */
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
|
1161
src/file_io.c
1161
src/file_io.c
File diff suppressed because it is too large
Load Diff
569
src/float32.c
569
src/float32.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2006 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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,14 +16,12 @@
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "sndfile.h"
|
||||
#include "config.h"
|
||||
#include "sfendian.h"
|
||||
#include "common.h"
|
||||
#include "float_cast.h"
|
||||
@ -58,22 +56,30 @@ static sf_count_t host_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
static sf_count_t host_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
static sf_count_t host_read_f2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
|
||||
static sf_count_t host_write_s2f (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ;
|
||||
static sf_count_t host_write_i2f (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ;
|
||||
static sf_count_t host_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ;
|
||||
static sf_count_t host_write_d2f (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
|
||||
static sf_count_t host_write_s2f (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
|
||||
static sf_count_t host_write_i2f (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
static sf_count_t host_write_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
static sf_count_t host_write_d2f (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
|
||||
static void float32_peak_update (SF_PRIVATE *psf, const float *buffer, int count, sf_count_t indx) ;
|
||||
static void f2s_array (float *src, int count, short *dest) ;
|
||||
static void f2i_array (float *src, int count, int *dest) ;
|
||||
static void f2d_array (float *src, int count, double *dest) ;
|
||||
|
||||
static void s2f_array (short *src, float *dest, int count) ;
|
||||
static void i2f_array (int *src, float *dest, int count) ;
|
||||
static void d2f_array (double *src, float *dest, int count) ;
|
||||
|
||||
static void float32_peak_update (SF_PRIVATE *psf, float *buffer, int count, int indx) ;
|
||||
|
||||
static sf_count_t replace_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
|
||||
static sf_count_t replace_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
static sf_count_t replace_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
static sf_count_t replace_read_f2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
|
||||
static sf_count_t replace_write_s2f (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ;
|
||||
static sf_count_t replace_write_i2f (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ;
|
||||
static sf_count_t replace_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ;
|
||||
static sf_count_t replace_write_d2f (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
|
||||
static sf_count_t replace_write_s2f (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
|
||||
static sf_count_t replace_write_i2f (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
static sf_count_t replace_write_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
static sf_count_t replace_write_d2f (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
|
||||
static void bf2f_array (float *buffer, int count) ;
|
||||
static void f2bf_array (float *buffer, int count) ;
|
||||
@ -234,14 +240,10 @@ float32_init (SF_PRIVATE *psf)
|
||||
} ;
|
||||
} ;
|
||||
|
||||
if (psf->filelength > psf->dataoffset)
|
||||
{ psf->datalength = (psf->dataend > 0) ? psf->dataend - psf->dataoffset :
|
||||
psf->filelength = psf_get_filelen (psf) ;
|
||||
psf->datalength = (psf->dataend) ? psf->dataend - psf->dataoffset :
|
||||
psf->filelength - psf->dataoffset ;
|
||||
}
|
||||
else
|
||||
psf->datalength = 0 ;
|
||||
|
||||
psf->sf.frames = psf->datalength / psf->blockwidth ;
|
||||
psf->sf.frames = psf->datalength / (psf->sf.channels * sizeof (float)) ;
|
||||
|
||||
return 0 ;
|
||||
} /* float32_init */
|
||||
@ -306,9 +308,9 @@ void
|
||||
float32_le_write (float in, unsigned char *out)
|
||||
{ int exponent, mantissa, negative = 0 ;
|
||||
|
||||
memset (out, 0, sizeof (int)) ;
|
||||
*((int*) out) = 0 ;
|
||||
|
||||
if (fabs (in) < 1e-30)
|
||||
if (in == 0.0)
|
||||
return ;
|
||||
|
||||
if (in < 0.0)
|
||||
@ -341,9 +343,9 @@ void
|
||||
float32_be_write (float in, unsigned char *out)
|
||||
{ int exponent, mantissa, negative = 0 ;
|
||||
|
||||
memset (out, 0, sizeof (int)) ;
|
||||
*((int*) out) = 0 ;
|
||||
|
||||
if (fabs (in) < 1e-30)
|
||||
if (in == 0.0)
|
||||
return ;
|
||||
|
||||
if (in < 0.0)
|
||||
@ -377,7 +379,7 @@ float32_be_write (float in, unsigned char *out)
|
||||
*/
|
||||
|
||||
static void
|
||||
float32_peak_update (SF_PRIVATE *psf, const float *buffer, int count, sf_count_t indx)
|
||||
float32_peak_update (SF_PRIVATE *psf, float *buffer, int count, int indx)
|
||||
{ int chan ;
|
||||
int k, position ;
|
||||
float fmaxval ;
|
||||
@ -391,9 +393,9 @@ float32_peak_update (SF_PRIVATE *psf, const float *buffer, int count, sf_count_t
|
||||
position = k ;
|
||||
} ;
|
||||
|
||||
if (fmaxval > psf->peak_info->peaks [chan].value)
|
||||
{ psf->peak_info->peaks [chan].value = fmaxval ;
|
||||
psf->peak_info->peaks [chan].position = psf->write_current + indx + (position / psf->sf.channels) ;
|
||||
if (fmaxval > psf->peak.peak [chan].value)
|
||||
{ psf->peak.peak [chan].value = fmaxval ;
|
||||
psf->peak.peak [chan].position = psf->write_current + indx + (position / psf->sf.channels) ;
|
||||
} ;
|
||||
} ;
|
||||
|
||||
@ -426,109 +428,29 @@ float32_get_capability (SF_PRIVATE *psf)
|
||||
return (CPU_IS_LITTLE_ENDIAN) ? FLOAT_BROKEN_LE : FLOAT_BROKEN_BE ;
|
||||
} /* float32_get_capability */
|
||||
|
||||
/*=======================================================================================
|
||||
*/
|
||||
|
||||
static void
|
||||
f2s_array (const float *src, int count, short *dest, float scale)
|
||||
{
|
||||
while (--count >= 0)
|
||||
{ dest [count] = lrintf (scale * src [count]) ;
|
||||
} ;
|
||||
} /* f2s_array */
|
||||
|
||||
static void
|
||||
f2s_clip_array (const float *src, int count, short *dest, float scale)
|
||||
{ while (--count >= 0)
|
||||
{ float tmp = scale * src [count] ;
|
||||
|
||||
if (CPU_CLIPS_POSITIVE == 0 && tmp > 32767.0)
|
||||
dest [count] = SHRT_MAX ;
|
||||
else if (CPU_CLIPS_NEGATIVE == 0 && tmp < 32768.0)
|
||||
dest [count] = SHRT_MIN ;
|
||||
else
|
||||
dest [count] = lrintf (tmp) ;
|
||||
} ;
|
||||
} /* f2s_clip_array */
|
||||
|
||||
static inline void
|
||||
f2i_array (const float *src, int count, int *dest, float scale)
|
||||
{ while (--count >= 0)
|
||||
{ dest [count] = lrintf (scale * src [count]) ;
|
||||
} ;
|
||||
} /* f2i_array */
|
||||
|
||||
static inline void
|
||||
f2i_clip_array (const float *src, int count, int *dest, float scale)
|
||||
{ while (--count >= 0)
|
||||
{ float tmp = scale * src [count] ;
|
||||
|
||||
if (CPU_CLIPS_POSITIVE == 0 && tmp > (1.0 * INT_MAX))
|
||||
dest [count] = INT_MAX ;
|
||||
else if (CPU_CLIPS_NEGATIVE == 0 && tmp < (-1.0 * INT_MAX))
|
||||
dest [count] = INT_MIN ;
|
||||
else
|
||||
dest [count] = lrintf (tmp) ;
|
||||
} ;
|
||||
} /* f2i_clip_array */
|
||||
|
||||
static inline void
|
||||
f2d_array (const float *src, int count, double *dest)
|
||||
{ while (--count >= 0)
|
||||
{ dest [count] = src [count] ;
|
||||
} ;
|
||||
} /* f2d_array */
|
||||
|
||||
static inline void
|
||||
s2f_array (const short *src, float *dest, int count)
|
||||
{ while (--count >= 0)
|
||||
{ dest [count] = src [count] ;
|
||||
} ;
|
||||
|
||||
} /* s2f_array */
|
||||
|
||||
static inline void
|
||||
i2f_array (const int *src, float *dest, int count)
|
||||
{ while (--count >= 0)
|
||||
{ dest [count] = src [count] ;
|
||||
} ;
|
||||
} /* i2f_array */
|
||||
|
||||
static inline void
|
||||
d2f_array (const double *src, float *dest, int count)
|
||||
{ while (--count >= 0)
|
||||
{ dest [count] = src [count] ;
|
||||
} ;
|
||||
} /* d2f_array */
|
||||
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static sf_count_t
|
||||
host_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ void (*convert) (const float *, int, short *, float) ;
|
||||
int bufferlen, readcount ;
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
sf_count_t total = 0 ;
|
||||
float scale ;
|
||||
|
||||
convert = (psf->add_clipping) ? f2s_clip_array : f2s_array ;
|
||||
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
|
||||
scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFF / psf->float_max ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (float) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->buffer, sizeof (float), readcount, psf) ;
|
||||
|
||||
/* Fix me : Need lef2s_array */
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->u.ibuf, bufferlen) ;
|
||||
endswap_int_array ((int*) psf->buffer, readcount) ;
|
||||
|
||||
f2s_array (psf->u.fbuf, readcount, ptr + total, scale) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
f2s_array ((float*) (psf->buffer), thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
len -= thisread ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -536,28 +458,23 @@ host_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
host_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ void (*convert) (const float *, int, int *, float) ;
|
||||
int bufferlen, readcount ;
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
sf_count_t total = 0 ;
|
||||
float scale ;
|
||||
|
||||
convert = (psf->add_clipping) ? f2i_clip_array : f2i_array ;
|
||||
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
|
||||
scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFFFFFF / psf->float_max ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (float) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->buffer, sizeof (float), readcount, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->u.ibuf, bufferlen) ;
|
||||
endswap_int_array ((int*) psf->buffer, readcount) ;
|
||||
|
||||
convert (psf->u.fbuf, readcount, ptr + total, scale) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
f2i_array ((float*) (psf->buffer), thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
len -= thisread ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -565,25 +482,24 @@ host_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
host_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount ;
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (psf->float_endswap != SF_TRUE)
|
||||
return psf_fread (ptr, sizeof (float), len, psf) ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (float) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->buffer, sizeof (float), readcount, psf) ;
|
||||
|
||||
endswap_int_copy ((int*) (ptr + total), psf->u.ibuf, readcount) ;
|
||||
endswap_int_copy ((int*) (ptr + total), (int*) psf->buffer, thisread) ;
|
||||
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
len -= thisread ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -591,139 +507,134 @@ host_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
host_read_f2d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount ;
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (float) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->buffer, sizeof (float), readcount, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->u.ibuf, bufferlen) ;
|
||||
endswap_int_array ((int*) psf->buffer, readcount) ;
|
||||
|
||||
/* Fix me : Need lef2d_array */
|
||||
f2d_array (psf->u.fbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
f2d_array ((float*) (psf->buffer), thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
len -= thisread ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* host_read_f2d */
|
||||
|
||||
static sf_count_t
|
||||
host_write_s2f (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount ;
|
||||
host_write_s2f (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (float) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
s2f_array (ptr + total, psf->u.fbuf, bufferlen) ;
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
s2f_array (ptr + total, (float*) (psf->buffer), writecount) ;
|
||||
|
||||
if (psf->peak_info)
|
||||
float32_peak_update (psf, psf->u.fbuf, bufferlen, total / psf->sf.channels) ;
|
||||
if (psf->has_peak)
|
||||
float32_peak_update (psf, (float *) (psf->buffer), writecount, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->u.ibuf, bufferlen) ;
|
||||
endswap_int_array ((int*) psf->buffer, writecount) ;
|
||||
|
||||
writecount = psf_fwrite (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
thiswrite = psf_fwrite (psf->buffer, sizeof (float), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
len -= thiswrite ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* host_write_s2f */
|
||||
|
||||
static sf_count_t
|
||||
host_write_i2f (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount ;
|
||||
host_write_i2f (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (float) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
i2f_array (ptr + total, psf->u.fbuf, bufferlen) ;
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
i2f_array (ptr + total, (float*) (psf->buffer), writecount) ;
|
||||
|
||||
if (psf->peak_info)
|
||||
float32_peak_update (psf, psf->u.fbuf, bufferlen, total / psf->sf.channels) ;
|
||||
if (psf->has_peak)
|
||||
float32_peak_update (psf, (float *) (psf->buffer), writecount, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->u.ibuf, bufferlen) ;
|
||||
endswap_int_array ((int*) psf->buffer, writecount) ;
|
||||
|
||||
writecount = psf_fwrite (psf->u.fbuf, sizeof (float) , bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
thiswrite = psf_fwrite (psf->buffer, sizeof (float) , writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
len -= thiswrite ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* host_write_i2f */
|
||||
|
||||
static sf_count_t
|
||||
host_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount ;
|
||||
host_write_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (psf->peak_info)
|
||||
if (psf->has_peak)
|
||||
float32_peak_update (psf, ptr, len, 0) ;
|
||||
|
||||
if (psf->float_endswap != SF_TRUE)
|
||||
return psf_fwrite (ptr, sizeof (float), len, psf) ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (float) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
|
||||
endswap_int_copy (psf->u.ibuf, (const int*) (ptr + total), bufferlen) ;
|
||||
endswap_int_copy ((int*) psf->buffer, (int*) (ptr + total), writecount) ;
|
||||
|
||||
writecount = psf_fwrite (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
thiswrite = psf_fwrite (psf->buffer, sizeof (float), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
len -= thiswrite ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* host_write_f */
|
||||
|
||||
static sf_count_t
|
||||
host_write_d2f (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount ;
|
||||
host_write_d2f (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (float) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
|
||||
d2f_array (ptr + total, psf->u.fbuf, bufferlen) ;
|
||||
d2f_array (ptr + total, (float*) (psf->buffer), writecount) ;
|
||||
|
||||
if (psf->peak_info)
|
||||
float32_peak_update (psf, psf->u.fbuf, bufferlen, total / psf->sf.channels) ;
|
||||
if (psf->has_peak)
|
||||
float32_peak_update (psf, (float *) (psf->buffer), writecount, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->u.ibuf, bufferlen) ;
|
||||
endswap_int_array ((int*) psf->buffer, writecount) ;
|
||||
|
||||
writecount = psf_fwrite (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
thiswrite = psf_fwrite (psf->buffer, sizeof (float), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
len -= thiswrite ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -732,30 +643,79 @@ host_write_d2f (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
|
||||
/*=======================================================================================
|
||||
*/
|
||||
|
||||
static void
|
||||
f2s_array (float *src, int count, short *dest)
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
dest [count] = lrintf (src [count]) ;
|
||||
} ;
|
||||
} /* f2s_array */
|
||||
|
||||
static void
|
||||
f2i_array (float *src, int count, int *dest)
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
dest [count] = lrintf (src [count]) ;
|
||||
} ;
|
||||
} /* f2i_array */
|
||||
|
||||
static void
|
||||
f2d_array (float *src, int count, double *dest)
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
dest [count] = src [count] ;
|
||||
} ;
|
||||
} /* f2d_array */
|
||||
|
||||
static void
|
||||
s2f_array (short *src, float *dest, int count)
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
dest [count] = src [count] ;
|
||||
} ;
|
||||
|
||||
} /* s2f_array */
|
||||
|
||||
static void
|
||||
i2f_array (int *src, float *dest, int count)
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
dest [count] = src [count] ;
|
||||
} ;
|
||||
} /* i2f_array */
|
||||
|
||||
static void
|
||||
d2f_array (double *src, float *dest, int count)
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
dest [count] = src [count] ;
|
||||
} ;
|
||||
} /* d2f_array */
|
||||
|
||||
/*=======================================================================================
|
||||
*/
|
||||
|
||||
static sf_count_t
|
||||
replace_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount ;
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
sf_count_t total = 0 ;
|
||||
float scale ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
|
||||
scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFF / psf->float_max ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (float) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->buffer, sizeof (float), readcount, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->u.ibuf, bufferlen) ;
|
||||
endswap_int_array ((int*) psf->buffer, readcount) ;
|
||||
|
||||
bf2f_array (psf->u.fbuf, bufferlen) ;
|
||||
bf2f_array ((float *) (psf->buffer), readcount) ;
|
||||
|
||||
f2s_array (psf->u.fbuf, readcount, ptr + total, scale) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
f2s_array ((float*) (psf->buffer), thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
len -= thisread ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -763,28 +723,25 @@ replace_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
replace_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount ;
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
sf_count_t total = 0 ;
|
||||
float scale ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
|
||||
scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFF / psf->float_max ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (float) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->buffer, sizeof (float), readcount, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->u.ibuf, bufferlen) ;
|
||||
endswap_int_array ((int*) psf->buffer, readcount) ;
|
||||
|
||||
bf2f_array (psf->u.fbuf, bufferlen) ;
|
||||
bf2f_array ((float *) (psf->buffer), readcount) ;
|
||||
|
||||
f2i_array (psf->u.fbuf, readcount, ptr + total, scale) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
f2i_array ((float*) (psf->buffer), thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
len -= thisread ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -792,29 +749,28 @@ replace_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
replace_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount ;
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
/* FIX THIS */
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (float) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->buffer, sizeof (float), readcount, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->u.ibuf, bufferlen) ;
|
||||
endswap_int_array ((int*) psf->buffer, readcount) ;
|
||||
|
||||
bf2f_array (psf->u.fbuf, bufferlen) ;
|
||||
bf2f_array ((float *) (psf->buffer), readcount) ;
|
||||
|
||||
memcpy (ptr + total, psf->u.fbuf, bufferlen * sizeof (float)) ;
|
||||
memcpy (ptr + total, psf->buffer, readcount * sizeof (float)) ;
|
||||
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
len -= thisread ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -822,148 +778,143 @@ replace_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
replace_read_f2d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount ;
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (float) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->buffer, sizeof (float), readcount, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->u.ibuf, bufferlen) ;
|
||||
endswap_int_array ((int*) psf->buffer, readcount) ;
|
||||
|
||||
bf2f_array (psf->u.fbuf, bufferlen) ;
|
||||
bf2f_array ((float *) (psf->buffer), readcount) ;
|
||||
|
||||
f2d_array (psf->u.fbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
f2d_array ((float*) (psf->buffer), thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
len -= thisread ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* replace_read_f2d */
|
||||
|
||||
static sf_count_t
|
||||
replace_write_s2f (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount ;
|
||||
replace_write_s2f (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ int writecount, bufferlen, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (float) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
s2f_array (ptr + total, psf->u.fbuf, bufferlen) ;
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
s2f_array (ptr + total, (float*) (psf->buffer), writecount) ;
|
||||
|
||||
if (psf->peak_info)
|
||||
float32_peak_update (psf, psf->u.fbuf, bufferlen, total / psf->sf.channels) ;
|
||||
if (psf->has_peak)
|
||||
float32_peak_update (psf, (float *) (psf->buffer), writecount, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
f2bf_array (psf->u.fbuf, bufferlen) ;
|
||||
f2bf_array ((float *) (psf->buffer), writecount) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->u.ibuf, bufferlen) ;
|
||||
endswap_int_array ((int*) psf->buffer, writecount) ;
|
||||
|
||||
writecount = psf_fwrite (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
thiswrite = psf_fwrite (psf->buffer, sizeof (float), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
len -= thiswrite ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* replace_write_s2f */
|
||||
|
||||
static sf_count_t
|
||||
replace_write_i2f (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount ;
|
||||
replace_write_i2f (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ int writecount, bufferlen, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (float) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
i2f_array (ptr + total, psf->u.fbuf, bufferlen) ;
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
i2f_array (ptr + total, (float*) (psf->buffer), writecount) ;
|
||||
|
||||
if (psf->peak_info)
|
||||
float32_peak_update (psf, psf->u.fbuf, bufferlen, total / psf->sf.channels) ;
|
||||
if (psf->has_peak)
|
||||
float32_peak_update (psf, (float *) (psf->buffer), writecount, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
f2bf_array (psf->u.fbuf, bufferlen) ;
|
||||
f2bf_array ((float *) (psf->buffer), writecount) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->u.ibuf, bufferlen) ;
|
||||
endswap_int_array ((int*) psf->buffer, writecount) ;
|
||||
|
||||
writecount = psf_fwrite (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
thiswrite = psf_fwrite (psf->buffer, sizeof (float), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
len -= thiswrite ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* replace_write_i2f */
|
||||
|
||||
static sf_count_t
|
||||
replace_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount ;
|
||||
replace_write_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int writecount, bufferlen, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
/* FIX THIS */
|
||||
if (psf->peak_info)
|
||||
if (psf->has_peak)
|
||||
float32_peak_update (psf, ptr, len, 0) ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (float) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
|
||||
memcpy (psf->u.fbuf, ptr + total, bufferlen * sizeof (float)) ;
|
||||
memcpy (psf->buffer, ptr + total, writecount * sizeof (float)) ;
|
||||
|
||||
f2bf_array (psf->u.fbuf, bufferlen) ;
|
||||
f2bf_array ((float *) (psf->buffer), writecount) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->u.ibuf, bufferlen) ;
|
||||
endswap_int_array ((int*) psf->buffer, writecount) ;
|
||||
|
||||
writecount = psf_fwrite (psf->u.fbuf, sizeof (float) , bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
thiswrite = psf_fwrite (psf->buffer, sizeof (float) , writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
len -= thiswrite ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* replace_write_f */
|
||||
|
||||
static sf_count_t
|
||||
replace_write_d2f (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount ;
|
||||
replace_write_d2f (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int writecount, bufferlen, thiswrite ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
|
||||
bufferlen = sizeof (psf->buffer) / sizeof (float) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
d2f_array (ptr + total, psf->u.fbuf, bufferlen) ;
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
d2f_array (ptr + total, (float*) (psf->buffer), writecount) ;
|
||||
|
||||
if (psf->peak_info)
|
||||
float32_peak_update (psf, psf->u.fbuf, bufferlen, total / psf->sf.channels) ;
|
||||
if (psf->has_peak)
|
||||
float32_peak_update (psf, (float *) (psf->buffer), writecount, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
f2bf_array (psf->u.fbuf, bufferlen) ;
|
||||
f2bf_array ((float *) (psf->buffer), writecount) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->u.ibuf, bufferlen) ;
|
||||
endswap_int_array ((int*) psf->buffer, writecount) ;
|
||||
|
||||
writecount = psf_fwrite (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
thiswrite = psf_fwrite (psf->buffer, sizeof (float), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
len -= thiswrite ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -974,21 +925,23 @@ replace_write_d2f (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
|
||||
|
||||
static void
|
||||
bf2f_array (float *buffer, int count)
|
||||
{ while (--count >= 0)
|
||||
{ buffer [count] = FLOAT32_READ ((unsigned char *) (buffer + count)) ;
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
buffer [count] = FLOAT32_READ ((unsigned char *) (buffer + count)) ;
|
||||
} ;
|
||||
} /* bf2f_array */
|
||||
|
||||
static void
|
||||
f2bf_array (float *buffer, int count)
|
||||
{ while (--count >= 0)
|
||||
{ FLOAT32_WRITE (buffer [count], (unsigned char*) (buffer + count)) ;
|
||||
{ while (count)
|
||||
{ count -- ;
|
||||
FLOAT32_WRITE (buffer [count], (unsigned char*) (buffer + count)) ;
|
||||
} ;
|
||||
} /* f2bf_array */
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: b6c34917-488c-4145-9648-f4371fc4c889
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2001-2004 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2001-2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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,10 +16,8 @@
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* Version 1.4 */
|
||||
/* Version 1.3 */
|
||||
|
||||
#ifndef FLOAT_CAST_HEADER
|
||||
#define FLOAT_CAST_HEADER
|
||||
|
||||
/*============================================================================
|
||||
** On Intel Pentium processors (especially PIII and probably P4), converting
|
||||
@ -45,12 +43,12 @@
|
||||
** long int lrint (double x) ;
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
#include "config.h"
|
||||
|
||||
/*
|
||||
** The presence of the required functions are detected during the configure
|
||||
** process and the values HAVE_LRINT and HAVE_LRINTF are set accordingly in
|
||||
** the sfconfig.h file.
|
||||
** the config.h file.
|
||||
*/
|
||||
|
||||
#define HAVE_LRINT_REPLACEMENT 0
|
||||
@ -73,59 +71,10 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#elif (defined (__CYGWIN__))
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#undef HAVE_LRINT_REPLACEMENT
|
||||
#define HAVE_LRINT_REPLACEMENT 1
|
||||
|
||||
#undef lrint
|
||||
#undef lrintf
|
||||
|
||||
#define lrint double2int
|
||||
#define lrintf float2int
|
||||
|
||||
/*
|
||||
** The native CYGWIN lrint and lrintf functions are buggy:
|
||||
** http://sourceware.org/ml/cygwin/2005-06/msg00153.html
|
||||
** http://sourceware.org/ml/cygwin/2005-09/msg00047.html
|
||||
** and slow.
|
||||
** These functions (pulled from the Public Domain MinGW math.h header)
|
||||
** replace the native versions.
|
||||
*/
|
||||
|
||||
static inline long double2int (double in)
|
||||
{ long retval ;
|
||||
|
||||
__asm__ __volatile__
|
||||
( "fistpl %0"
|
||||
: "=m" (retval)
|
||||
: "t" (in)
|
||||
: "st"
|
||||
) ;
|
||||
|
||||
return retval ;
|
||||
} /* double2int */
|
||||
|
||||
static inline long float2int (float in)
|
||||
{ long retval ;
|
||||
|
||||
__asm__ __volatile__
|
||||
( "fistpl %0"
|
||||
: "=m" (retval)
|
||||
: "t" (in)
|
||||
: "st"
|
||||
) ;
|
||||
|
||||
return retval ;
|
||||
} /* float2int */
|
||||
|
||||
#elif (defined (WIN32) || defined (_WIN32))
|
||||
|
||||
#undef HAVE_LRINT_REPLACEMENT
|
||||
#define HAVE_LRINT_REPLACEMENT 1
|
||||
|
||||
#include <math.h>
|
||||
|
||||
/*
|
||||
@ -207,7 +156,7 @@
|
||||
#define lrint double2int
|
||||
#define lrintf float2int
|
||||
|
||||
inline static long
|
||||
inline static long int
|
||||
float2int (register float in)
|
||||
{ int res [2] ;
|
||||
|
||||
@ -222,7 +171,7 @@
|
||||
return res [1] ;
|
||||
} /* lrintf */
|
||||
|
||||
inline static long
|
||||
inline static long int
|
||||
double2int (register double in)
|
||||
{ int res [2] ;
|
||||
|
||||
@ -251,11 +200,10 @@
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* FLOAT_CAST_HEADER */
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 42db1693-ff61-4051-bac1-e4d24c4e30b7
|
||||
|
171
src/gsm610.c
171
src/gsm610.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2006 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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,7 +16,7 @@
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -43,7 +43,6 @@ typedef struct gsm610_tag
|
||||
short samples [WAV_W64_GSM610_SAMPLES] ;
|
||||
unsigned char block [WAV_W64_GSM610_BLOCKSIZE] ;
|
||||
|
||||
/* Damn I hate typedef-ed pointers; yes, gsm is a pointer type. */
|
||||
gsm gsm_data ;
|
||||
} GSM610_PRIVATE ;
|
||||
|
||||
@ -52,13 +51,13 @@ static sf_count_t gsm610_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
static sf_count_t gsm610_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
static sf_count_t gsm610_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
|
||||
static sf_count_t gsm610_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ;
|
||||
static sf_count_t gsm610_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ;
|
||||
static sf_count_t gsm610_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ;
|
||||
static sf_count_t gsm610_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
|
||||
static sf_count_t gsm610_write_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
|
||||
static sf_count_t gsm610_write_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
static sf_count_t gsm610_write_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
static sf_count_t gsm610_write_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
|
||||
static int gsm610_read_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610, short *ptr, int len) ;
|
||||
static int gsm610_write_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610, const short *ptr, int len) ;
|
||||
static int gsm610_write_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610, short *ptr, int len) ;
|
||||
|
||||
static int gsm610_decode_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610) ;
|
||||
static int gsm610_encode_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610) ;
|
||||
@ -79,20 +78,15 @@ gsm610_init (SF_PRIVATE *psf)
|
||||
{ GSM610_PRIVATE *pgsm610 ;
|
||||
int true_flag = 1 ;
|
||||
|
||||
if (psf->codec_data != NULL)
|
||||
{ psf_log_printf (psf, "*** psf->codec_data is not NULL.\n") ;
|
||||
return SFE_INTERNAL ;
|
||||
} ;
|
||||
|
||||
if (psf->mode == SFM_RDWR)
|
||||
return SFE_BAD_MODE_RW ;
|
||||
|
||||
psf->sf.seekable = SF_FALSE ;
|
||||
|
||||
if ((pgsm610 = calloc (1, sizeof (GSM610_PRIVATE))) == NULL)
|
||||
if (! (pgsm610 = malloc (sizeof (GSM610_PRIVATE))))
|
||||
return SFE_MALLOC_FAILED ;
|
||||
|
||||
psf->codec_data = pgsm610 ;
|
||||
psf->fdata = (void*) pgsm610 ;
|
||||
|
||||
memset (pgsm610, 0, sizeof (GSM610_PRIVATE)) ;
|
||||
|
||||
@ -102,53 +96,34 @@ Need separate gsm_data structs for encode and decode.
|
||||
|
||||
============================================================*/
|
||||
|
||||
if ((pgsm610->gsm_data = gsm_create ()) == NULL)
|
||||
if (! (pgsm610->gsm_data = gsm_create ()))
|
||||
return SFE_MALLOC_FAILED ;
|
||||
|
||||
switch (psf->sf.format & SF_FORMAT_TYPEMASK)
|
||||
{ case SF_FORMAT_WAV :
|
||||
case SF_FORMAT_WAVEX :
|
||||
case SF_FORMAT_W64 :
|
||||
gsm_option (pgsm610->gsm_data, GSM_OPT_WAV49, &true_flag) ;
|
||||
if ((psf->sf.format & SF_FORMAT_TYPEMASK) == SF_FORMAT_WAV ||
|
||||
(psf->sf.format & SF_FORMAT_TYPEMASK) == SF_FORMAT_W64)
|
||||
{ gsm_option (pgsm610->gsm_data, GSM_OPT_WAV49, &true_flag) ;
|
||||
|
||||
pgsm610->encode_block = gsm610_wav_encode_block ;
|
||||
pgsm610->decode_block = gsm610_wav_decode_block ;
|
||||
pgsm610->encode_block = gsm610_wav_encode_block ;
|
||||
pgsm610->decode_block = gsm610_wav_decode_block ;
|
||||
|
||||
pgsm610->samplesperblock = WAV_W64_GSM610_SAMPLES ;
|
||||
pgsm610->blocksize = WAV_W64_GSM610_BLOCKSIZE ;
|
||||
break ;
|
||||
pgsm610->samplesperblock = WAV_W64_GSM610_SAMPLES ;
|
||||
pgsm610->blocksize = WAV_W64_GSM610_BLOCKSIZE ;
|
||||
}
|
||||
else
|
||||
{ pgsm610->encode_block = gsm610_encode_block ;
|
||||
pgsm610->decode_block = gsm610_decode_block ;
|
||||
|
||||
case SF_FORMAT_AIFF :
|
||||
case SF_FORMAT_RAW :
|
||||
pgsm610->encode_block = gsm610_encode_block ;
|
||||
pgsm610->decode_block = gsm610_decode_block ;
|
||||
|
||||
pgsm610->samplesperblock = GSM610_SAMPLES ;
|
||||
pgsm610->blocksize = GSM610_BLOCKSIZE ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
return SFE_INTERNAL ;
|
||||
break ;
|
||||
pgsm610->samplesperblock = GSM610_SAMPLES ;
|
||||
pgsm610->blocksize = GSM610_BLOCKSIZE ;
|
||||
} ;
|
||||
|
||||
if (psf->mode == SFM_READ)
|
||||
{ if (psf->datalength % pgsm610->blocksize == 0)
|
||||
pgsm610->blocks = psf->datalength / pgsm610->blocksize ;
|
||||
else if (psf->datalength % pgsm610->blocksize == 1 && pgsm610->blocksize == GSM610_BLOCKSIZE)
|
||||
{ /*
|
||||
** Weird AIFF specific case.
|
||||
** AIFF chunks must be at an even offset from the start of file and
|
||||
** GSM610_BLOCKSIZE is odd which can result in an odd length SSND
|
||||
** chunk. The SSND chunk then gets padded on write which means that
|
||||
** when it is read the datalength is too big by 1.
|
||||
*/
|
||||
pgsm610->blocks = psf->datalength / pgsm610->blocksize ;
|
||||
}
|
||||
else
|
||||
{ if (psf->datalength % pgsm610->blocksize)
|
||||
{ psf_log_printf (psf, "*** Warning : data chunk seems to be truncated.\n") ;
|
||||
pgsm610->blocks = psf->datalength / pgsm610->blocksize + 1 ;
|
||||
} ;
|
||||
}
|
||||
else
|
||||
pgsm610->blocks = psf->datalength / pgsm610->blocksize ;
|
||||
|
||||
psf->sf.frames = pgsm610->samplesperblock * pgsm610->blocks ;
|
||||
|
||||
@ -170,8 +145,7 @@ Need separate gsm_data structs for encode and decode.
|
||||
psf->write_double = gsm610_write_d ;
|
||||
} ;
|
||||
|
||||
psf->codec_close = gsm610_close ;
|
||||
|
||||
psf->close = gsm610_close ;
|
||||
psf->seek = gsm610_seek ;
|
||||
|
||||
psf->filelength = psf_get_filelen (psf) ;
|
||||
@ -241,7 +215,7 @@ gsm610_read_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610, short *ptr, int len
|
||||
|
||||
while (indx < len)
|
||||
{ if (pgsm610->blockcount >= pgsm610->blocks && pgsm610->samplecount >= pgsm610->samplesperblock)
|
||||
{ memset (&(ptr [indx]), 0, (len - indx) * sizeof (short)) ;
|
||||
{ memset (&(ptr [indx]), 0, (size_t) ((len - indx) * sizeof (short))) ;
|
||||
return total ;
|
||||
} ;
|
||||
|
||||
@ -266,9 +240,9 @@ gsm610_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
int readcount, count ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (psf->codec_data == NULL)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pgsm610 = (GSM610_PRIVATE*) psf->codec_data ;
|
||||
pgsm610 = (GSM610_PRIVATE*) psf->fdata ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len > 0x10000000) ? 0x1000000 : (int) len ;
|
||||
@ -292,12 +266,12 @@ gsm610_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
int k, bufferlen, readcount = 0, count ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (psf->codec_data == NULL)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pgsm610 = (GSM610_PRIVATE*) psf->codec_data ;
|
||||
pgsm610 = (GSM610_PRIVATE*) psf->fdata ;
|
||||
|
||||
sptr = psf->u.sbuf ;
|
||||
bufferlen = ARRAY_LEN (psf->u.sbuf) ;
|
||||
sptr = (short*) psf->buffer ;
|
||||
bufferlen = SF_BUFFER_LEN / sizeof (short) ;
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : len ;
|
||||
count = gsm610_read_block (psf, pgsm610, sptr, readcount) ;
|
||||
@ -318,14 +292,14 @@ gsm610_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
sf_count_t total = 0 ;
|
||||
float normfact ;
|
||||
|
||||
if (psf->codec_data == NULL)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pgsm610 = (GSM610_PRIVATE*) psf->codec_data ;
|
||||
pgsm610 = (GSM610_PRIVATE*) psf->fdata ;
|
||||
|
||||
normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ;
|
||||
|
||||
sptr = psf->u.sbuf ;
|
||||
bufferlen = ARRAY_LEN (psf->u.sbuf) ;
|
||||
sptr = (short*) psf->buffer ;
|
||||
bufferlen = SF_BUFFER_LEN / sizeof (short) ;
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : len ;
|
||||
count = gsm610_read_block (psf, pgsm610, sptr, readcount) ;
|
||||
@ -348,12 +322,12 @@ gsm610_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
|
||||
normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x8000) : 1.0 ;
|
||||
|
||||
if (psf->codec_data == NULL)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pgsm610 = (GSM610_PRIVATE*) psf->codec_data ;
|
||||
pgsm610 = (GSM610_PRIVATE*) psf->fdata ;
|
||||
|
||||
sptr = psf->u.sbuf ;
|
||||
bufferlen = ARRAY_LEN (psf->u.sbuf) ;
|
||||
sptr = (short*) psf->buffer ;
|
||||
bufferlen = SF_BUFFER_LEN / sizeof (short) ;
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : len ;
|
||||
count = gsm610_read_block (psf, pgsm610, sptr, readcount) ;
|
||||
@ -367,17 +341,19 @@ gsm610_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
} /* gsm610_read_d */
|
||||
|
||||
static sf_count_t
|
||||
gsm610_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset)
|
||||
gsm610_seek (SF_PRIVATE *psf, int mode, sf_count_t offset)
|
||||
{ GSM610_PRIVATE *pgsm610 ;
|
||||
int newblock, newsample ;
|
||||
|
||||
if (psf->codec_data == NULL)
|
||||
mode = mode ;
|
||||
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pgsm610 = (GSM610_PRIVATE*) psf->codec_data ;
|
||||
pgsm610 = (GSM610_PRIVATE*) psf->fdata ;
|
||||
|
||||
if (psf->dataoffset < 0)
|
||||
{ psf->error = SFE_BAD_SEEK ;
|
||||
return PSF_SEEK_ERROR ;
|
||||
return ((sf_count_t) -1) ;
|
||||
} ;
|
||||
|
||||
if (offset == 0)
|
||||
@ -398,7 +374,7 @@ gsm610_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset)
|
||||
|
||||
if (offset < 0 || offset > pgsm610->blocks * pgsm610->samplesperblock)
|
||||
{ psf->error = SFE_BAD_SEEK ;
|
||||
return PSF_SEEK_ERROR ;
|
||||
return ((sf_count_t) -1) ;
|
||||
} ;
|
||||
|
||||
newblock = offset / pgsm610->samplesperblock ;
|
||||
@ -417,7 +393,7 @@ gsm610_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset)
|
||||
|
||||
/* What to do about write??? */
|
||||
psf->error = SFE_BAD_SEEK ;
|
||||
return PSF_SEEK_ERROR ;
|
||||
return ((sf_count_t) -1) ;
|
||||
} /* gsm610_seek */
|
||||
|
||||
/*==========================================================================================
|
||||
@ -466,7 +442,7 @@ gsm610_wav_encode_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610)
|
||||
} /* gsm610_wav_encode_block */
|
||||
|
||||
static int
|
||||
gsm610_write_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610, const short *ptr, int len)
|
||||
gsm610_write_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610, short *ptr, int len)
|
||||
{ int count, total = 0, indx = 0 ;
|
||||
|
||||
while (indx < len)
|
||||
@ -488,14 +464,14 @@ gsm610_write_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610, const short *ptr,
|
||||
} /* gsm610_write_block */
|
||||
|
||||
static sf_count_t
|
||||
gsm610_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
|
||||
gsm610_write_s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ GSM610_PRIVATE *pgsm610 ;
|
||||
int writecount, count ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (psf->codec_data == NULL)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pgsm610 = (GSM610_PRIVATE*) psf->codec_data ;
|
||||
pgsm610 = (GSM610_PRIVATE*) psf->fdata ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len > 0x10000000) ? 0x10000000 : (int) len ;
|
||||
@ -513,18 +489,18 @@ gsm610_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
|
||||
} /* gsm610_write_s */
|
||||
|
||||
static sf_count_t
|
||||
gsm610_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
|
||||
gsm610_write_i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ GSM610_PRIVATE *pgsm610 ;
|
||||
short *sptr ;
|
||||
int k, bufferlen, writecount = 0, count ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (psf->codec_data == NULL)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pgsm610 = (GSM610_PRIVATE*) psf->codec_data ;
|
||||
pgsm610 = (GSM610_PRIVATE*) psf->fdata ;
|
||||
|
||||
sptr = psf->u.sbuf ;
|
||||
bufferlen = ARRAY_LEN (psf->u.sbuf) ;
|
||||
sptr = (short*) psf->buffer ;
|
||||
bufferlen = SF_BUFFER_LEN / sizeof (short) ;
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : len ;
|
||||
for (k = 0 ; k < writecount ; k++)
|
||||
@ -538,21 +514,21 @@ gsm610_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
|
||||
} /* gsm610_write_i */
|
||||
|
||||
static sf_count_t
|
||||
gsm610_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len)
|
||||
gsm610_write_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ GSM610_PRIVATE *pgsm610 ;
|
||||
short *sptr ;
|
||||
int k, bufferlen, writecount = 0, count ;
|
||||
sf_count_t total = 0 ;
|
||||
float normfact ;
|
||||
|
||||
if (psf->codec_data == NULL)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pgsm610 = (GSM610_PRIVATE*) psf->codec_data ;
|
||||
pgsm610 = (GSM610_PRIVATE*) psf->fdata ;
|
||||
|
||||
normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ;
|
||||
|
||||
sptr = psf->u.sbuf ;
|
||||
bufferlen = ARRAY_LEN (psf->u.sbuf) ;
|
||||
sptr = (short*) psf->buffer ;
|
||||
bufferlen = SF_BUFFER_LEN / sizeof (short) ;
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : len ;
|
||||
for (k = 0 ; k < writecount ; k++)
|
||||
@ -566,21 +542,21 @@ gsm610_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len)
|
||||
} /* gsm610_write_f */
|
||||
|
||||
static sf_count_t
|
||||
gsm610_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
|
||||
gsm610_write_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ GSM610_PRIVATE *pgsm610 ;
|
||||
short *sptr ;
|
||||
int k, bufferlen, writecount = 0, count ;
|
||||
sf_count_t total = 0 ;
|
||||
double normfact ;
|
||||
|
||||
if (psf->codec_data == NULL)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pgsm610 = (GSM610_PRIVATE*) psf->codec_data ;
|
||||
pgsm610 = (GSM610_PRIVATE*) psf->fdata ;
|
||||
|
||||
normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ;
|
||||
|
||||
sptr = psf->u.sbuf ;
|
||||
bufferlen = ARRAY_LEN (psf->u.sbuf) ;
|
||||
sptr = (short*) psf->buffer ;
|
||||
bufferlen = SF_BUFFER_LEN / sizeof (short) ;
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : len ;
|
||||
for (k = 0 ; k < writecount ; k++)
|
||||
@ -597,10 +573,10 @@ static int
|
||||
gsm610_close (SF_PRIVATE *psf)
|
||||
{ GSM610_PRIVATE *pgsm610 ;
|
||||
|
||||
if (psf->codec_data == NULL)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
|
||||
pgsm610 = (GSM610_PRIVATE*) psf->codec_data ;
|
||||
pgsm610 = (GSM610_PRIVATE*) psf->fdata ;
|
||||
|
||||
if (psf->mode == SFM_WRITE)
|
||||
{ /* If a block has been partially assembled, write it out
|
||||
@ -609,6 +585,9 @@ gsm610_close (SF_PRIVATE *psf)
|
||||
|
||||
if (pgsm610->samplecount && pgsm610->samplecount < pgsm610->samplesperblock)
|
||||
pgsm610->encode_block (psf, pgsm610) ;
|
||||
|
||||
if (psf->write_header)
|
||||
psf->write_header (psf, SF_TRUE) ;
|
||||
} ;
|
||||
|
||||
if (pgsm610->gsm_data)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2002,2003,2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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,14 +16,13 @@
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "sndfile.h"
|
||||
#include "config.h"
|
||||
#include "sfendian.h"
|
||||
#include "common.h"
|
||||
|
||||
@ -74,7 +73,7 @@ htk_open (SF_PRIVATE *psf)
|
||||
psf->write_header = htk_write_header ;
|
||||
} ;
|
||||
|
||||
psf->container_close = htk_close ;
|
||||
psf->close = htk_close ;
|
||||
|
||||
psf->blockwidth = psf->bytewidth * psf->sf.channels ;
|
||||
|
||||
@ -209,6 +208,8 @@ htk_read_header (SF_PRIVATE *psf)
|
||||
|
||||
psf->datalength = psf->filelength - psf->dataoffset ;
|
||||
|
||||
psf->close = htk_close ;
|
||||
|
||||
psf->blockwidth = psf->sf.channels * psf->bytewidth ;
|
||||
|
||||
if (! psf->sf.frames && psf->blockwidth)
|
||||
|
168
src/ima_adpcm.c
168
src/ima_adpcm.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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,13 +16,12 @@
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "sndfile.h"
|
||||
#include "config.h"
|
||||
#include "sfendian.h"
|
||||
#include "float_cast.h"
|
||||
#include "common.h"
|
||||
@ -37,11 +36,7 @@ typedef struct IMA_ADPCM_PRIVATE_tag
|
||||
int stepindx [2] ;
|
||||
unsigned char *block ;
|
||||
short *samples ;
|
||||
#if HAVE_FLEXIBLE_ARRAY
|
||||
short data [] ; /* ISO C99 struct flexible array. */
|
||||
#else
|
||||
short data [0] ; /* This is a hack and might not work. */
|
||||
#endif
|
||||
unsigned char data [4] ; /* Dummy size */
|
||||
} IMA_ADPCM_PRIVATE ;
|
||||
|
||||
/*============================================================================================
|
||||
@ -69,21 +64,22 @@ static int ima_reader_init (SF_PRIVATE *psf, int blockalign, int samplesperblock
|
||||
static int ima_writer_init (SF_PRIVATE *psf, int blockalign) ;
|
||||
|
||||
static int ima_read_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima, short *ptr, int len) ;
|
||||
static int ima_write_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima, const short *ptr, int len) ;
|
||||
static int ima_write_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima, short *ptr, int len) ;
|
||||
|
||||
static sf_count_t ima_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
|
||||
static sf_count_t ima_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
static sf_count_t ima_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
static sf_count_t ima_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
|
||||
static sf_count_t ima_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ;
|
||||
static sf_count_t ima_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ;
|
||||
static sf_count_t ima_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ;
|
||||
static sf_count_t ima_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
|
||||
static sf_count_t ima_write_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
|
||||
static sf_count_t ima_write_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
static sf_count_t ima_write_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
static sf_count_t ima_write_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
|
||||
static sf_count_t ima_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ;
|
||||
|
||||
static int ima_close (SF_PRIVATE *psf) ;
|
||||
static int wav_w64_ima_close (SF_PRIVATE *psf) ;
|
||||
static int aiff_ima_close (SF_PRIVATE *psf) ;
|
||||
|
||||
static int wav_w64_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) ;
|
||||
static int wav_w64_ima_encode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) ;
|
||||
@ -101,11 +97,6 @@ int
|
||||
wav_w64_ima_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
|
||||
{ int error ;
|
||||
|
||||
if (psf->codec_data != NULL)
|
||||
{ psf_log_printf (psf, "*** psf->codec_data is not NULL.\n") ;
|
||||
return SFE_INTERNAL ;
|
||||
} ;
|
||||
|
||||
if (psf->mode == SFM_RDWR)
|
||||
return SFE_BAD_MODE_RW ;
|
||||
|
||||
@ -117,12 +108,40 @@ wav_w64_ima_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
|
||||
if ((error = ima_writer_init (psf, blockalign)))
|
||||
return error ;
|
||||
|
||||
psf->codec_close = ima_close ;
|
||||
psf->seek = ima_seek ;
|
||||
psf->close = wav_w64_ima_close ;
|
||||
|
||||
return 0 ;
|
||||
} /* wav_w64_ima_init */
|
||||
|
||||
static int
|
||||
wav_w64_ima_close (SF_PRIVATE *psf)
|
||||
{ IMA_ADPCM_PRIVATE *pima ;
|
||||
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
|
||||
pima = (IMA_ADPCM_PRIVATE*) psf->fdata ;
|
||||
|
||||
if (psf->mode == SFM_WRITE)
|
||||
{ /* If a block has been partially assembled, write it out
|
||||
** as the final block.
|
||||
*/
|
||||
if (pima->samplecount && pima->samplecount < pima->samplesperblock)
|
||||
pima->encode_block (psf, pima) ;
|
||||
|
||||
psf->sf.frames = pima->samplesperblock * pima->blockcount / psf->sf.channels ;
|
||||
|
||||
if (psf->write_header)
|
||||
psf->write_header (psf, SF_TRUE) ;
|
||||
} ;
|
||||
|
||||
free (psf->fdata) ;
|
||||
psf->fdata = NULL ;
|
||||
|
||||
return 0 ;
|
||||
} /* wav_w64_ima_close */
|
||||
|
||||
int
|
||||
aiff_ima_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
|
||||
{ int error ;
|
||||
@ -138,29 +157,38 @@ aiff_ima_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
|
||||
if ((error = ima_writer_init (psf, blockalign)))
|
||||
return error ;
|
||||
|
||||
psf->codec_close = ima_close ;
|
||||
psf->seek = ima_seek ;
|
||||
psf->close = aiff_ima_close ;
|
||||
|
||||
return 0 ;
|
||||
} /* aiff_ima_init */
|
||||
|
||||
static int
|
||||
ima_close (SF_PRIVATE *psf)
|
||||
aiff_ima_close (SF_PRIVATE *psf)
|
||||
{ IMA_ADPCM_PRIVATE *pima ;
|
||||
|
||||
pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ;
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
|
||||
pima = (IMA_ADPCM_PRIVATE*) psf->fdata ;
|
||||
|
||||
if (psf->mode == SFM_WRITE)
|
||||
{ /* If a block has been partially assembled, write it out
|
||||
** as the final block.
|
||||
*/
|
||||
|
||||
if (pima->samplecount && pima->samplecount < pima->samplesperblock)
|
||||
pima->encode_block (psf, pima) ;
|
||||
|
||||
psf->sf.frames = pima->samplesperblock * pima->blockcount / psf->sf.channels ;
|
||||
if (psf->write_header)
|
||||
psf->write_header (psf, SF_TRUE) ;
|
||||
} ;
|
||||
|
||||
free (psf->fdata) ;
|
||||
psf->fdata = NULL ;
|
||||
|
||||
return 0 ;
|
||||
} /* ima_close */
|
||||
} /* aiff_ima_close */
|
||||
|
||||
/*============================================================================================
|
||||
** IMA ADPCM Read Functions.
|
||||
@ -179,12 +207,12 @@ ima_reader_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
|
||||
if (! (pima = malloc (pimasize)))
|
||||
return SFE_MALLOC_FAILED ;
|
||||
|
||||
psf->codec_data = (void*) pima ;
|
||||
psf->fdata = (void*) pima ;
|
||||
|
||||
memset (pima, 0, pimasize) ;
|
||||
|
||||
pima->samples = pima->data ;
|
||||
pima->block = (unsigned char*) (pima->data + samplesperblock * psf->sf.channels) ;
|
||||
pima->block = (unsigned char*) pima->data ;
|
||||
pima->samples = (short*) (pima->data + blockalign * psf->sf.channels) ;
|
||||
|
||||
pima->channels = psf->sf.channels ;
|
||||
pima->blocksize = blockalign ;
|
||||
@ -333,7 +361,7 @@ count ++ ;
|
||||
|
||||
pima->block [blockindx] = (pima->samples [chan] >> 8) & 0xFF ;
|
||||
pima->block [blockindx + 1] = (pima->samples [chan] & 0x80) + (pima->stepindx [chan] & 0x7F) ;
|
||||
|
||||
|
||||
pima->previous [chan] = pima->samples [chan] ;
|
||||
} ;
|
||||
|
||||
@ -384,11 +412,11 @@ count ++ ;
|
||||
|
||||
for (chan = 0 ; chan < pima->channels ; chan ++)
|
||||
{ for (indx = pima->channels ; indx < pima->channels * pima->samplesperblock ; indx += 2 * pima->channels)
|
||||
{ blockindx = chan * pima->blocksize + 2 + indx / 2 ;
|
||||
{ blockindx = chan * pima->blocksize + 2 + indx / 2;
|
||||
|
||||
if (0 && count ++ < 5)
|
||||
printf ("chan: %d blockindx: %3d indx: %3d\n", chan, blockindx, indx) ;
|
||||
|
||||
|
||||
pima->block [blockindx] = pima->samples [indx] & 0x0F ;
|
||||
pima->block [blockindx] |= (pima->samples [indx + pima->channels] << 4) & 0xF0 ;
|
||||
} ;
|
||||
@ -625,9 +653,9 @@ ima_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
int readcount, count ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (! psf->codec_data)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ;
|
||||
pima = (IMA_ADPCM_PRIVATE*) psf->fdata ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len > 0x10000000) ? 0x10000000 : (int) len ;
|
||||
@ -650,12 +678,12 @@ ima_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
int k, bufferlen, readcount, count ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (! psf->codec_data)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ;
|
||||
pima = (IMA_ADPCM_PRIVATE*) psf->fdata ;
|
||||
|
||||
sptr = psf->u.sbuf ;
|
||||
bufferlen = ARRAY_LEN (psf->u.sbuf) ;
|
||||
sptr = (short*) psf->buffer ;
|
||||
bufferlen = SF_BUFFER_LEN / sizeof (short) ;
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
count = ima_read_block (psf, pima, sptr, readcount) ;
|
||||
@ -678,14 +706,14 @@ ima_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
sf_count_t total = 0 ;
|
||||
float normfact ;
|
||||
|
||||
if (! psf->codec_data)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ;
|
||||
pima = (IMA_ADPCM_PRIVATE*) psf->fdata ;
|
||||
|
||||
normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ;
|
||||
|
||||
sptr = psf->u.sbuf ;
|
||||
bufferlen = ARRAY_LEN (psf->u.sbuf) ;
|
||||
sptr = (short*) psf->buffer ;
|
||||
bufferlen = SF_BUFFER_LEN / sizeof (short) ;
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
count = ima_read_block (psf, pima, sptr, readcount) ;
|
||||
@ -708,14 +736,14 @@ ima_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
sf_count_t total = 0 ;
|
||||
double normfact ;
|
||||
|
||||
if (! psf->codec_data)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ;
|
||||
pima = (IMA_ADPCM_PRIVATE*) psf->fdata ;
|
||||
|
||||
normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x8000) : 1.0 ;
|
||||
|
||||
sptr = psf->u.sbuf ;
|
||||
bufferlen = ARRAY_LEN (psf->u.sbuf) ;
|
||||
sptr = (short*) psf->buffer ;
|
||||
bufferlen = SF_BUFFER_LEN / sizeof (short) ;
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
count = ima_read_block (psf, pima, sptr, readcount) ;
|
||||
@ -735,13 +763,13 @@ ima_seek (SF_PRIVATE *psf, int mode, sf_count_t offset)
|
||||
{ IMA_ADPCM_PRIVATE *pima ;
|
||||
int newblock, newsample ;
|
||||
|
||||
if (! psf->codec_data)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ;
|
||||
pima = (IMA_ADPCM_PRIVATE*) psf->fdata ;
|
||||
|
||||
if (psf->datalength < 0 || psf->dataoffset < 0)
|
||||
{ psf->error = SFE_BAD_SEEK ;
|
||||
return PSF_SEEK_ERROR ;
|
||||
return ((sf_count_t) -1) ;
|
||||
} ;
|
||||
|
||||
if (offset == 0)
|
||||
@ -754,7 +782,7 @@ ima_seek (SF_PRIVATE *psf, int mode, sf_count_t offset)
|
||||
|
||||
if (offset < 0 || offset > pima->blocks * pima->samplesperblock)
|
||||
{ psf->error = SFE_BAD_SEEK ;
|
||||
return PSF_SEEK_ERROR ;
|
||||
return ((sf_count_t) -1) ;
|
||||
} ;
|
||||
|
||||
newblock = offset / pima->samplesperblock ;
|
||||
@ -769,7 +797,7 @@ ima_seek (SF_PRIVATE *psf, int mode, sf_count_t offset)
|
||||
else
|
||||
{ /* What to do about write??? */
|
||||
psf->error = SFE_BAD_SEEK ;
|
||||
return PSF_SEEK_ERROR ;
|
||||
return ((sf_count_t) -1) ;
|
||||
} ;
|
||||
|
||||
return newblock * pima->samplesperblock + newsample ;
|
||||
@ -795,7 +823,7 @@ ima_writer_init (SF_PRIVATE *psf, int blockalign)
|
||||
if ((pima = calloc (1, pimasize)) == NULL)
|
||||
return SFE_MALLOC_FAILED ;
|
||||
|
||||
psf->codec_data = (void*) pima ;
|
||||
psf->fdata = (void*) pima ;
|
||||
|
||||
pima->channels = psf->sf.channels ;
|
||||
pima->blocksize = blockalign ;
|
||||
@ -834,7 +862,7 @@ ima_writer_init (SF_PRIVATE *psf, int blockalign)
|
||||
*/
|
||||
|
||||
static int
|
||||
ima_write_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima, const short *ptr, int len)
|
||||
ima_write_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima, short *ptr, int len)
|
||||
{ int count, total = 0, indx = 0 ;
|
||||
|
||||
while (indx < len)
|
||||
@ -856,14 +884,14 @@ ima_write_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima, const short *ptr, int
|
||||
} /* ima_write_block */
|
||||
|
||||
static sf_count_t
|
||||
ima_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
|
||||
ima_write_s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ IMA_ADPCM_PRIVATE *pima ;
|
||||
int writecount, count ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (! psf->codec_data)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ;
|
||||
pima = (IMA_ADPCM_PRIVATE*) psf->fdata ;
|
||||
|
||||
while (len)
|
||||
{ writecount = (len > 0x10000000) ? 0x10000000 : (int) len ;
|
||||
@ -880,18 +908,18 @@ ima_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
|
||||
} /* ima_write_s */
|
||||
|
||||
static sf_count_t
|
||||
ima_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
|
||||
ima_write_i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ IMA_ADPCM_PRIVATE *pima ;
|
||||
short *sptr ;
|
||||
int k, bufferlen, writecount, count ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (! psf->codec_data)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ;
|
||||
pima = (IMA_ADPCM_PRIVATE*) psf->fdata ;
|
||||
|
||||
sptr = psf->u.sbuf ;
|
||||
bufferlen = ARRAY_LEN (psf->u.sbuf) ;
|
||||
sptr = (short*) psf->buffer ;
|
||||
bufferlen = SF_BUFFER_LEN / sizeof (short) ;
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
for (k = 0 ; k < writecount ; k++)
|
||||
@ -907,21 +935,21 @@ ima_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
|
||||
} /* ima_write_i */
|
||||
|
||||
static sf_count_t
|
||||
ima_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len)
|
||||
ima_write_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ IMA_ADPCM_PRIVATE *pima ;
|
||||
short *sptr ;
|
||||
int k, bufferlen, writecount, count ;
|
||||
sf_count_t total = 0 ;
|
||||
float normfact ;
|
||||
|
||||
if (! psf->codec_data)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ;
|
||||
pima = (IMA_ADPCM_PRIVATE*) psf->fdata ;
|
||||
|
||||
normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ;
|
||||
|
||||
sptr = psf->u.sbuf ;
|
||||
bufferlen = ARRAY_LEN (psf->u.sbuf) ;
|
||||
sptr = (short*) psf->buffer ;
|
||||
bufferlen = SF_BUFFER_LEN / sizeof (short) ;
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
for (k = 0 ; k < writecount ; k++)
|
||||
@ -937,21 +965,21 @@ ima_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len)
|
||||
} /* ima_write_f */
|
||||
|
||||
static sf_count_t
|
||||
ima_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
|
||||
ima_write_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ IMA_ADPCM_PRIVATE *pima ;
|
||||
short *sptr ;
|
||||
int k, bufferlen, writecount, count ;
|
||||
sf_count_t total = 0 ;
|
||||
double normfact ;
|
||||
|
||||
if (! psf->codec_data)
|
||||
if (! psf->fdata)
|
||||
return 0 ;
|
||||
pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ;
|
||||
pima = (IMA_ADPCM_PRIVATE*) psf->fdata ;
|
||||
|
||||
normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ;
|
||||
|
||||
sptr = psf->u.sbuf ;
|
||||
bufferlen = ARRAY_LEN (psf->u.sbuf) ;
|
||||
sptr = (short*) psf->buffer ;
|
||||
bufferlen = SF_BUFFER_LEN / sizeof (short) ;
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
for (k = 0 ; k < writecount ; k++)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2002,2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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,11 +16,11 @@
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sfendian.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "sndfile.h"
|
||||
#include "config.h"
|
||||
#include "sfendian.h"
|
||||
#include "common.h"
|
||||
|
||||
#define INTERLEAVE_CHANNELS 6
|
||||
|
22
src/ircam.c
22
src/ircam.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2001-2004 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2001-2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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,14 +16,13 @@
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "sndfile.h"
|
||||
#include "config.h"
|
||||
#include "sfendian.h"
|
||||
#include "common.h"
|
||||
|
||||
@ -41,7 +40,7 @@
|
||||
#define IRCAM_LE_MASK (MAKE_MARKER (0xFF, 0x00, 0xFF, 0xFF))
|
||||
#define IRCAM_LE_MARKER (MAKE_MARKER (0x00, 0x00, 0xA3, 0x64))
|
||||
|
||||
#define IRCAM_02B_MARKER (MAKE_MARKER (0x64, 0xA3, 0x02, 0x00))
|
||||
#define IRCAM_02B_MARKER (MAKE_MARKER (0x00, 0x02, 0xA3, 0x64))
|
||||
#define IRCAM_03L_MARKER (MAKE_MARKER (0x64, 0xA3, 0x03, 0x00))
|
||||
|
||||
#define IRCAM_DATA_OFFSET (1024)
|
||||
@ -103,7 +102,7 @@ ircam_open (SF_PRIVATE *psf)
|
||||
psf->write_header = ircam_write_header ;
|
||||
} ;
|
||||
|
||||
psf->container_close = ircam_close ;
|
||||
psf->close = ircam_close ;
|
||||
|
||||
switch (subformat)
|
||||
{ case SF_FORMAT_ULAW : /* 8-bit Ulaw encoding. */
|
||||
@ -140,7 +139,8 @@ ircam_read_header (SF_PRIVATE *psf)
|
||||
|
||||
psf_binheader_readf (psf, "epmf44", 0, &marker, &samplerate, &(psf->sf.channels), &encoding) ;
|
||||
|
||||
if (((marker & IRCAM_BE_MASK) != IRCAM_BE_MARKER) && ((marker & IRCAM_LE_MASK) != IRCAM_LE_MARKER))
|
||||
if (((marker & IRCAM_LE_MASK) != IRCAM_LE_MARKER) &&
|
||||
((marker & IRCAM_BE_MASK) != IRCAM_BE_MARKER))
|
||||
{ psf_log_printf (psf, "marker: 0x%X\n", marker) ;
|
||||
return SFE_IRCAM_NO_MARKER ;
|
||||
} ;
|
||||
@ -238,7 +238,7 @@ ircam_close (SF_PRIVATE *psf)
|
||||
} /* ircam_close */
|
||||
|
||||
static int
|
||||
ircam_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
|
||||
ircam_write_header (SF_PRIVATE *psf, int calc_length)
|
||||
{ int encoding ;
|
||||
float samplerate ;
|
||||
sf_count_t current ;
|
||||
@ -248,6 +248,8 @@ ircam_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
|
||||
|
||||
current = psf_ftell (psf) ;
|
||||
|
||||
calc_length = calc_length ;
|
||||
|
||||
/* This also sets psf->endian. */
|
||||
encoding = get_encoding (psf->sf.format & SF_FORMAT_SUBMASK) ;
|
||||
|
||||
@ -266,18 +268,18 @@ ircam_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
|
||||
switch (psf->endian)
|
||||
{ case SF_ENDIAN_BIG :
|
||||
psf_binheader_writef (psf, "Emf", IRCAM_02B_MARKER, samplerate) ;
|
||||
psf_binheader_writef (psf, "E44", psf->sf.channels, encoding) ;
|
||||
psf_binheader_writef (psf, "E44", psf->sf.channels, encoding) ;
|
||||
break ;
|
||||
|
||||
case SF_ENDIAN_LITTLE :
|
||||
psf_binheader_writef (psf, "emf", IRCAM_03L_MARKER, samplerate) ;
|
||||
psf_binheader_writef (psf, "e44", psf->sf.channels, encoding) ;
|
||||
psf_binheader_writef (psf, "e44", psf->sf.channels, encoding) ;
|
||||
break ;
|
||||
|
||||
default : return SFE_BAD_OPEN_FORMAT ;
|
||||
} ;
|
||||
|
||||
psf_binheader_writef (psf, "z", (size_t) (IRCAM_DATA_OFFSET - psf->headindex)) ;
|
||||
psf_binheader_writef (psf, "z", IRCAM_DATA_OFFSET - psf->headindex) ;
|
||||
|
||||
/* Header construction complete so write it out. */
|
||||
psf_fwrite (psf->header, psf->headindex, 1, psf) ;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2003-2005 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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,7 +16,7 @@
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -27,22 +27,27 @@
|
||||
|
||||
#if (OS_IS_MACOSX == 1)
|
||||
|
||||
#include <CoreServices.h>
|
||||
|
||||
int
|
||||
macbinary3_open (SF_PRIVATE * UNUSED (psf))
|
||||
macbinary3_open (SF_PRIVATE *psf)
|
||||
{
|
||||
if (psf)
|
||||
return 0 ;
|
||||
|
||||
return 0 ;
|
||||
} /* macbinary3_open */
|
||||
|
||||
#else
|
||||
|
||||
int
|
||||
macbinary3_open (SF_PRIVATE * UNUSED (psf))
|
||||
macbinary3_open (SF_PRIVATE *psf)
|
||||
{
|
||||
psf = psf ;
|
||||
return 0 ;
|
||||
} /* macbinary3_open */
|
||||
|
||||
#endif /* OS_IS_MACOSX */
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
|
17
src/macos.c
17
src/macos.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2003-2005 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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,7 +16,7 @@
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -29,24 +29,23 @@
|
||||
#define STR_MARKER MAKE_MARKER ('S', 'T', 'R', ' ')
|
||||
|
||||
int
|
||||
macos_guess_file_type (SF_PRIVATE * psf, const char *filename)
|
||||
macos_guess_file_type (SF_PRIVATE *psf, const char *filename)
|
||||
{ static char rsrc_name [1024] ;
|
||||
struct stat statbuf ;
|
||||
int format ;
|
||||
|
||||
snprintf (rsrc_name, sizeof (rsrc_name), "%s/rsrc", filename) ;
|
||||
snprintf (rsrc_name, sizeof (rsrc_name), "%s/rsrc", filename);
|
||||
|
||||
/* If there is no resource fork, just return. */
|
||||
if (stat (rsrc_name, &statbuf) != 0)
|
||||
{ psf_log_printf (psf, "No resource fork.\n") ;
|
||||
return 0 ;
|
||||
} ;
|
||||
|
||||
if (statbuf.st_size == 0)
|
||||
{ psf_log_printf (psf, "Have zero size resource fork.\n") ;
|
||||
return 0 ;
|
||||
} ;
|
||||
|
||||
return 0 ;
|
||||
format = 0 ;
|
||||
|
||||
return format ;
|
||||
} /* macos_guess_file_type */
|
||||
|
||||
/*
|
||||
|
25
src/mat4.c
25
src/mat4.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2002-2006 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2002,2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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,17 +16,15 @@
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "sndfile.h"
|
||||
#include "config.h"
|
||||
#include "sfendian.h"
|
||||
#include "common.h"
|
||||
#include "float_cast.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
** Information on how to decode and encode this file was obtained in a PDF
|
||||
@ -102,7 +100,7 @@ mat4_open (SF_PRIVATE *psf)
|
||||
psf->write_header = mat4_write_header ;
|
||||
} ;
|
||||
|
||||
psf->container_close = mat4_close ;
|
||||
psf->close = mat4_close ;
|
||||
|
||||
psf->blockwidth = psf->bytewidth * psf->sf.channels ;
|
||||
|
||||
@ -177,15 +175,15 @@ mat4_write_header (SF_PRIVATE *psf, int calc_length)
|
||||
|
||||
if (psf->endian == SF_ENDIAN_BIG)
|
||||
{ psf_binheader_writef (psf, "Em444", MAT4_BE_DOUBLE, 1, 1, 0) ;
|
||||
psf_binheader_writef (psf, "E4bd", 11, "samplerate", make_size_t (11), samplerate) ;
|
||||
psf_binheader_writef (psf, "E4bd", 11, "samplerate", 11, samplerate) ;
|
||||
psf_binheader_writef (psf, "tEm484", encoding, psf->sf.channels, psf->sf.frames, 0) ;
|
||||
psf_binheader_writef (psf, "E4b", 9, "wavedata", make_size_t (9)) ;
|
||||
psf_binheader_writef (psf, "E4b", 9, "wavedata", 9) ;
|
||||
}
|
||||
else if (psf->endian == SF_ENDIAN_LITTLE)
|
||||
{ psf_binheader_writef (psf, "em444", MAT4_LE_DOUBLE, 1, 1, 0) ;
|
||||
psf_binheader_writef (psf, "e4bd", 11, "samplerate", make_size_t (11), samplerate) ;
|
||||
psf_binheader_writef (psf, "e4bd", 11, "samplerate", 11, samplerate) ;
|
||||
psf_binheader_writef (psf, "tem484", encoding, psf->sf.channels, psf->sf.frames, 0) ;
|
||||
psf_binheader_writef (psf, "e4b", 9, "wavedata", make_size_t (9)) ;
|
||||
psf_binheader_writef (psf, "e4b", 9, "wavedata", 9) ;
|
||||
}
|
||||
else
|
||||
return SFE_BAD_OPEN_FORMAT ;
|
||||
@ -206,8 +204,7 @@ mat4_write_header (SF_PRIVATE *psf, int calc_length)
|
||||
|
||||
static int
|
||||
mat4_read_header (SF_PRIVATE *psf)
|
||||
{ int marker, rows, cols, imag ;
|
||||
unsigned namesize ;
|
||||
{ int marker, namesize, rows, cols, imag ;
|
||||
double value ;
|
||||
const char *marker_str ;
|
||||
char name [64] ;
|
||||
@ -244,13 +241,13 @@ mat4_read_header (SF_PRIVATE *psf)
|
||||
|
||||
psf_binheader_readf (psf, "d", &value) ;
|
||||
|
||||
LSF_SNPRINTF (psf->u.cbuf, sizeof (psf->u.cbuf), " Value : %f\n", value) ;
|
||||
psf_log_printf (psf, psf->u.cbuf) ;
|
||||
LSF_SNPRINTF ((char*) psf->buffer, sizeof (psf->buffer), " Value : %f\n", value) ;
|
||||
psf_log_printf (psf, (char*) psf->buffer) ;
|
||||
|
||||
if ((rows != 1) || (cols != 1))
|
||||
return SFE_MAT4_NO_SAMPLERATE ;
|
||||
|
||||
psf->sf.samplerate = lrint (value) ;
|
||||
psf->sf.samplerate = (int) value ;
|
||||
|
||||
/* Now write out the audio data. */
|
||||
|
||||
|
35
src/mat5.c
35
src/mat5.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2002-2006 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2002,2003 Erik de Castro Lopo <erikd@zip.com.au>
|
||||
**
|
||||
** 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,14 +16,13 @@
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "sndfile.h"
|
||||
#include "config.h"
|
||||
#include "sfendian.h"
|
||||
#include "common.h"
|
||||
#include "float_cast.h"
|
||||
@ -112,7 +111,7 @@ mat5_open (SF_PRIVATE *psf)
|
||||
psf->write_header = mat5_write_header ;
|
||||
} ;
|
||||
|
||||
psf->container_close = mat5_close ;
|
||||
psf->close = mat5_close ;
|
||||
|
||||
psf->blockwidth = psf->bytewidth * psf->sf.channels ;
|
||||
|
||||
@ -154,8 +153,7 @@ mat5_close (SF_PRIVATE *psf)
|
||||
|
||||
static int
|
||||
mat5_write_header (SF_PRIVATE *psf, int calc_length)
|
||||
{ static const char *filename = "MATLAB 5.0 MAT-file, written by " PACKAGE "-" VERSION ", " ;
|
||||
static const char *sr_name = "samplerate\0\0\0\0\0\0\0\0\0\0\0" ;
|
||||
{ static const char *sr_name = "samplerate\0\0\0\0\0\0\0\0\0\0\0" ;
|
||||
static const char *wd_name = "wavedata\0" ;
|
||||
sf_count_t current, datasize ;
|
||||
int encoding ;
|
||||
@ -204,22 +202,23 @@ mat5_write_header (SF_PRIVATE *psf, int calc_length)
|
||||
psf->headindex = 0 ;
|
||||
psf_fseek (psf, 0, SEEK_SET) ;
|
||||
|
||||
psf_get_date_str (psf->u.cbuf, sizeof (psf->u.scbuf)) ;
|
||||
psf_binheader_writef (psf, "bb", filename, strlen (filename), psf->u.cbuf, strlen (psf->u.cbuf) + 1) ;
|
||||
psf_binheader_writef (psf, "S", "MATLAB 5.0 MAT-file, written by " PACKAGE "-" VERSION ", ") ;
|
||||
psf_get_date_str ((char*) psf->buffer, sizeof (psf->buffer)) ;
|
||||
psf_binheader_writef (psf, "jS", -1, psf->buffer) ;
|
||||
|
||||
memset (psf->u.scbuf, ' ', 124 - psf->headindex) ;
|
||||
psf_binheader_writef (psf, "b", psf->u.scbuf, make_size_t (124 - psf->headindex)) ;
|
||||
memset (psf->buffer, ' ', 124 - psf->headindex) ;
|
||||
psf_binheader_writef (psf, "b", psf->buffer, 124 - psf->headindex) ;
|
||||
|
||||
psf->rwf_endian = psf->endian ;
|
||||
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
psf_binheader_writef (psf, "2b", 0x0100, "MI", make_size_t (2)) ;
|
||||
psf_binheader_writef (psf, "2b", 0x0100, "MI", 2) ;
|
||||
else
|
||||
psf_binheader_writef (psf, "2b", 0x0100, "IM", make_size_t (2)) ;
|
||||
psf_binheader_writef (psf, "2b", 0x0100, "IM", 2) ;
|
||||
|
||||
psf_binheader_writef (psf, "444444", MAT5_TYPE_ARRAY, 64, MAT5_TYPE_UINT32, 8, 6, 0) ;
|
||||
psf_binheader_writef (psf, "4444", MAT5_TYPE_INT32, 8, 1, 1) ;
|
||||
psf_binheader_writef (psf, "44b", MAT5_TYPE_SCHAR, strlen (sr_name), sr_name, make_size_t (16)) ;
|
||||
psf_binheader_writef (psf, "44b", MAT5_TYPE_SCHAR, strlen (sr_name), sr_name, 16) ;
|
||||
|
||||
if (psf->sf.samplerate > 0xFFFF)
|
||||
psf_binheader_writef (psf, "44", MAT5_TYPE_COMP_UINT, psf->sf.samplerate) ;
|
||||
@ -261,15 +260,15 @@ mat5_read_header (SF_PRIVATE *psf)
|
||||
short version, endian ;
|
||||
int type, size, flags1, flags2, rows, cols ;
|
||||
|
||||
psf_binheader_readf (psf, "pb", 0, psf->u.cbuf, 124) ;
|
||||
psf_binheader_readf (psf, "pb", 0, psf->buffer, 124) ;
|
||||
|
||||
psf->u.scbuf [125] = 0 ;
|
||||
psf->buffer [125] = 0 ;
|
||||
|
||||
if (strlen (psf->u.cbuf) >= 124)
|
||||
if (strlen ((char*) psf->buffer) >= 124)
|
||||
return SFE_UNIMPLEMENTED ;
|
||||
|
||||
if (strstr (psf->u.cbuf, "MATLAB 5.0 MAT-file") == psf->u.cbuf)
|
||||
psf_log_printf (psf, "%s\n", psf->u.scbuf) ;
|
||||
if (strstr ((char*) psf->buffer, "MATLAB 5.0 MAT-file") == (char*) psf->buffer)
|
||||
psf_log_printf (psf, "%s\n", psf->buffer) ;
|
||||
|
||||
|
||||
psf_binheader_readf (psf, "E22", &version, &endian) ;
|
||||
|
1369
src/missing.c
Normal file
1369
src/missing.c
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user