Upgrade to libsoxr 0.0.2.

This commit is contained in:
v.audacity 2012-10-12 23:54:03 +00:00
parent 3cb679ccd8
commit 2416f94980
51 changed files with 1300 additions and 372 deletions

View File

@ -15,7 +15,7 @@ Patches: None
Upstream version: 2.0.1
FileDialog
------------
----------
The customised file saving dialogs for wxwidgets to provide the options
button for format preferences. This is written and maintained by us so doesn't
have an upstream at the moment.
@ -84,7 +84,8 @@ Upstream Version: 1.1.3
libresample
-----------
Audio sample rate conversion library. Maintained by Audacity project
Audio sample rate conversion library. Maintained by Audacity project.
(Not currently used, in favor of libsoxr.)
libsamplerate
-------------
@ -117,7 +118,7 @@ libsoxr
-------
The SoX Resampler library performs one-dimensional sample-rate conversion,
by Rob Sykes.
Version in Audacity SVN: <?> (latest as of 2012-10-09)
Version in Audacity SVN: 0.0.2
No patches, used as is, with modified .vcproj file in win\Projects\libsoxr.

1
lib-src/libsoxr/AUTHORS Normal file
View File

@ -0,0 +1 @@
Rob Sykes <robs@users.sourceforge.net>

View File

@ -1,24 +1,32 @@
# SoX Resampler Library Copyright (c) 2007-12 robs@users.sourceforge.net
# Licence for this file: LGPL v2.1 See LICENCE for details.
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "Usage: cmake <path-to-source> (from another directory)")
endif ()
cmake_minimum_required (VERSION 2.8)
cmake_minimum_required (VERSION 2.8 FATAL_ERROR)
project (soxr C)
enable_testing ()
set (VERSION_MAJOR 0)
set (VERSION_MINOR 0)
set (VERSION_PATCH 1)
set (VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
set (DESCRIPTION_SUMMARY "One-dimensional sample-rate conversion library")
# Options:
# Release versioning:
set (PROJECT_VERSION_MAJOR 0)
set (PROJECT_VERSION_MINOR 0)
set (PROJECT_VERSION_PATCH 2)
# For shared-object; if, since the last public release:
# * library code changed at all: ++revision
# * interfaces changed at all: ++current, revision = 0
# * interfaces added: ++age
# * interfaces removed: age = 0
set (SO_VERSION_CURRENT 0)
set (SO_VERSION_REVISION 0)
set (SO_VERSION_AGE 0)
# Main options:
include (CMakeDependentOption)
@ -26,9 +34,11 @@ if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif ()
option (BUILD_TESTS "Build sanity-tests." OFF)
option (BUILD_SHARED_LIBS "Build shared libraries." ON)
option (BUILD_EXAMPLES "Build examples." OFF)
option (WITH_OPENMP "Include OpenMP threading." ON)
option (WITH_LSR_IF "Include a `libsamplerate'-like interface." ON)
option (WITH_LSR_BINDINGS "Include a `libsamplerate'-like interface." ON)
cmake_dependent_option (WITH_SINGLE_PRECISION "Build with single precision (for up to 20-bit accuracy)." ON
"WITH_DOUBLE_PRECISION" ON)
cmake_dependent_option (WITH_DOUBLE_PRECISION "Build with double precision (for up to 32-bit accuracy)." ON
@ -40,24 +50,24 @@ cmake_dependent_option (WITH_AVFFT "Use libavcodec (LGPL) for SIMD DFT." OFF
cmake_dependent_option (WITH_PFFFT "Use PFFFT (BSD-like licence) for SIMD DFT." ON
"WITH_SIMD;NOT WITH_AVFFT" OFF)
if (UNIX)
cmake_dependent_option (WITH_LSR_TESTS "Build LSR tests." OFF
"WITH_LSR_IF" OFF)
cmake_dependent_option (BUILD_LSR_TESTS "Build LSR tests." OFF
"WITH_LSR_BINDINGS" OFF)
endif ()
# Introspection:
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
include (CheckFunctionExists)
include (CheckIncludeFiles)
include (CheckLibraryExists)
include (TestBigEndian)
check_library_exists(m pow "" NEED_LIBM)
check_library_exists (m pow "" NEED_LIBM)
if (NEED_LIBM)
set(CMAKE_REQUIRED_LIBRARIES "m;${CMAKE_REQUIRED_LIBRARIES}")
set (CMAKE_REQUIRED_LIBRARIES "m;${CMAKE_REQUIRED_LIBRARIES}")
link_libraries (m)
endif ()
@ -74,7 +84,7 @@ if (WITH_SIMD)
if (SIMD_FOUND)
set (HAVE_SIMD 1)
endif ()
endif()
endif ()
if (WITH_SINGLE_PRECISION)
set (HAVE_SINGLE_PRECISION 1)
@ -93,6 +103,10 @@ if (WITH_AVFFT)
endif ()
endif ()
check_function_exists (lrint HAVE_LRINT)
check_include_files (fenv.h HAVE_FENV_H)
test_big_endian (WORDS_BIGENDIAN)
macro (make_exist)
foreach (x ${ARGN})
if (NOT ${x})
@ -101,31 +115,33 @@ macro (make_exist)
endforeach ()
endmacro ()
check_function_exists (lrint HAVE_LRINT)
check_include_files(fenv.h HAVE_FENV_H)
test_big_endian(WORDS_BIGENDIAN)
make_exist (HAVE_LRINT HAVE_FENV_H WORDS_BIGENDIAN HAVE_SIMD)
make_exist (HAVE_SINGLE_PRECISION HAVE_DOUBLE_PRECISION HAVE_AVFFT)
configure_file (
${PROJECT_SOURCE_DIR}/${PROJECT_NAME}-config.h.in
${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.h)
include_directories (${PROJECT_BINARY_DIR})
# Compiler configuration:
if (CMAKE_COMPILER_IS_GNUCC)
set (PROJECT_DEFS "-Wconversion -Wall -W -Wmissing-prototypes
-Wstrict-prototypes -pedantic -Wundef -Wno-long-long")
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set (PROJECT_CXX_FLAGS "-Wconversion -Wall -W -pedantic -Wundef -Wcast-align -Wpointer-arith -Wno-long-long")
set (PROJECT_C_FLAGS "${PROJECT_CXX_FLAGS} -Wnested-externs -Wmissing-prototypes -Wstrict-prototypes")
if (CMAKE_BUILD_TYPE STREQUAL "Release")
set (CMAKE_SHARED_LINKER_FLAGS "-s") # strip
endif ()
#option (VISIBILITY_HIDDEN "Build with -fvisibility=hidden." ON)
if (VISIBILITY_HIDDEN)
add_definitions (-fvisibility=hidden)
endif ()
endif ()
if (MSVC)
add_definitions (-D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS)
option (ENABLE_STATIC_RUNTIME "Visual Studio, link with runtime statically." OFF)
if (ENABLE_STATIC_RUNTIME)
foreach (flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
string (REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endforeach ()
endif ()
# By default, do not warn when built on machines using only VS Express:
if (NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
set (CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
@ -137,15 +153,13 @@ endif ()
# Build configuration:
if (${BUILD_SHARED_LIBS} AND ${CMAKE_SYSTEM_NAME} STREQUAL Windows) # Allow exes to find dlls:
set (bin ${PROJECT_BINARY_DIR}/bin/)
set (obin ${bin})
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${bin}
CACHE PATH "Single directory for all shared libraries")
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${bin}
CACHE PATH "Single directory for all executables.")
set (BIN ${PROJECT_BINARY_DIR}/bin/)
set (EXAMPLES_BIN ${BIN})
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BIN})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BIN})
else ()
set (bin ./)
set (obin ../examples/)
set (BIN ./)
set (EXAMPLES_BIN ../examples/)
endif ()
set (LIB_TYPE STATIC)
@ -158,28 +172,81 @@ endif ()
# Installation configuration:
set (LIB_SUFFIX "" CACHE STRING "Define suffix of libraries directory name (32 or 64).")
set (BIN_INSTALL_DIR "bin" CACHE PATH "The subdirectory to the binaries." FORCE)
set (LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "The subdirectory to the libraries." FORCE)
set (INCLUDE_INSTALL_DIR "include" CACHE PATH "The subdirectory to the headers." FORCE)
if (APPLE)
option (BUILD_FRAMEWORK "Build an OS X framework." OFF)
set (FRAMEWORK_INSTALL_DIR "/Library/Frameworks" CACHE STRING "Directory to install frameworks to.")
endif ()
# Top-level:
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
math (EXPR SO_VERSION_MAJOR "${SO_VERSION_CURRENT} - ${SO_VERSION_AGE}")
math (EXPR SO_VERSION_MINOR "${SO_VERSION_AGE}")
math (EXPR SO_VERSION_PATCH "${SO_VERSION_REVISION}")
set (SO_VERSION ${SO_VERSION_MAJOR}.${SO_VERSION_MINOR}.${SO_VERSION_PATCH})
configure_file (
${PROJECT_SOURCE_DIR}/${PROJECT_NAME}-config.h.in
${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.h)
include_directories (${PROJECT_BINARY_DIR})
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
file (COPY doc/logo.png DESTINATION doc)
add_custom_target (docs doxygen)
if (BUILD_TESTS OR BUILD_LSR_TESTS)
enable_testing ()
endif ()
# Subdirectories:
include_directories (${PROJECT_SOURCE_DIR}/src)
add_subdirectory (src)
add_subdirectory (examples)
add_subdirectory (tests)
if (WITH_LSR_TESTS)
if (BUILD_TESTS)
add_subdirectory (tests)
endif ()
if (BUILD_LSR_TESTS)
add_subdirectory (lsr-tests)
endif ()
if (BUILD_EXAMPLES OR BUILD_TESTS)
add_subdirectory (examples)
endif ()
# Deinstallation:
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/deinstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/deinstall.cmake"
IMMEDIATE @ONLY)
add_custom_target (deinstall
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/deinstall.cmake")
# Packaging:
if (UNIX)
set (CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
set (CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
set (CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}")
set (CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set (CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set (CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
set (CPACK_SOURCE_GENERATOR "TBZ2")
set (CPACK_SOURCE_IGNORE_FILES "/Debug/;/Release/;/cpack/;/dev/;\\\\.swp$")
set (CPACK_SOURCE_IGNORE_FILES "/Debug/;/Release/;/cpack/;\\\\.swp$;\\\\.gitignore")
include (CPack)

View File

@ -500,5 +500,3 @@ necessary. Here is a sample; alter the names:
Ty Coon, President of Vice
That's all there is to it!

208
lib-src/libsoxr/Doxyfile.in Normal file
View File

@ -0,0 +1,208 @@
# Doxyfile 1.3.4
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = lib${PROJECT_NAME}
PROJECT_NUMBER = ${PROJECT_VERSION}
OUTPUT_DIRECTORY = doc
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = NO
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = NO
STRIP_FROM_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
DISTRIBUTE_GROUP_DOC = NO
TAB_SIZE = 2
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_JAVA = NO
SUBGROUPING = YES
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = YES
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = NO
EXTRACT_LOCAL_CLASSES = NO
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = YES
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
GENERATE_TODOLIST = NO
GENERATE_TESTLIST = NO
GENERATE_BUGLIST = NO
GENERATE_DEPRECATEDLIST= NO
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = NO
WARN_IF_DOC_ERROR = YES
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = @CMAKE_SOURCE_DIR@/src
FILE_PATTERNS = @PROJECT_NAME@.h
RECURSIVE = YES
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
VERBATIM_HEADERS = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = YES
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER = @CMAKE_SOURCE_DIR@/doc/header.html
HTML_FOOTER = @CMAKE_SOURCE_DIR@/doc/footer.html
HTML_STYLESHEET = @CMAKE_SOURCE_DIR@/doc/stylesheet.css
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = YES
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = NO
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = NO
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = letter
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = YES
USE_PDFLATEX = YES
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED = DO_NOT_DOCUMENT \
DOXYGEN \
WITH_MP4 \
WITH_ASF
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = YES
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
UML_LOOK = NO
TEMPLATE_RELATIONS = YES
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = NO
GRAPHICAL_HIERARCHY = YES
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
MAX_DOT_GRAPH_DEPTH = 0
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO

View File

@ -13,3 +13,12 @@ General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Notes
1. Re software in the `examples' directory: works that are not resampling
examples but are based on the given examples -- for example, applications using
the library -- shall not be considered to be derivative works of the examples.
2. If building with pffft.c, see the licence embedded in that file.

View File

@ -1,46 +1,50 @@
SoX Resampler Library Copyright (c) 2007-12 robs@users.sourceforge.net
The SoX Resampler library performs one-dimensional sample-rate conversion.
It may be used, for example, to resample PCM-encoded audio. For higher-
dimensional resampling, such as for visual-image processing, you should look
elsewhere.
The SoX Resampler library `libsoxr' performs one-dimensional sample-rate
conversion - it may be used, for example, to resample PCM-encoded audio.
For higher-dimensional resampling, such as for visual-image processing, you
should look elsewhere.
Its aim is to provide fast, high-quality resampling. At its highest quality
settings, it can produce 32-bit-perfect results with signal occupied-
bandwidths of up to 98%.¹ Resampling ratios can be any (floating point)
value between +/- 8 octaves.
Depending on how the resampler is configured, quality may be traded for
speed, but only to a certain extent: there may be faster, average-quality
resamplers available. Multi-channel resampling can be configured to use
multiple CPU-cores, thus reducing execution time (with a slight expense of
CPU-cycles).
It aims to be fast (e.g. multi-channel resampling can utilise multiple
CPU-cores), high-quality (i.e. bit-perfect up to 32-bits, for occupied-
bandwidths up to 98%¹), and to allow any rational or irrational resampling
ratio. Phase-response, preserved bandwidth, aliasing, and rejection level
parameters are all configurable; alternatively, simple `preset'
configurations may be selected.
The resampler is currently available either as part of `libsox' (the audio
file-format and effect library), or stand-alone as `libsoxr' (this package).
The interfaces to libsox and libsoxr are slightly different, with that of
libsoxr designed specifically for resampling. An application requiring
support for other effects, or for reading-from or writing-to audio files or
devices, should use libsox (or other libraries such as libsndfile or
libavformat).
The APIs of libsox and libsoxr are slightly different, with that of libsoxr
designed specifically for resampling. An application requiring support for
other effects, or for reading-from or writing-to audio files or devices, can
use libsox (or other libraries such as libsndfile or libavformat).
Applications may use either floating-point or integer sample formats, and,
in the case of multiple channels, either channel-interleaved, or split-
channels.
The libsoxr API is currently documented in the header file `soxr.h' and by
example code in the 'examples' directory.
Libsoxr provides a simple API that allows interfacing using any commonly-
used sample format or buffering scheme: clients may use either floating-
point or integer sample formats, and, in the case of multiple channels,
either channel-interleaved, or split channels. The API is currently
documented in the header file `soxr.h' and by example code in the 'examples'
directory.
For compatibility with the popular `libsamplerate' library, the header file
`soxr-lsr.h' is provided and may be used as an alternative API. For details
`soxr-lsr.h' is provided and may be used as an alternative API. For details
of that API, see http://www.mega-nerd.com/SRC/api.html. Note however, that
libsoxr does not provide a full emulation of libsamplerate; in particular,
`vari-speeding' is not currently supported.
`vari-speeding' is not supported.
For build and installation instructions, see the file `INSTALL'; for
copyright and licensing information, see the file `copyright'.
copyright and licensing information, see the file `LICENCE'.
The resampler was inspired by Laurent De Soras' paper `The Quest For The
Perfect Resampler', http://ldesoras.free.fr/doc/articles/resampler-en.pdf.
Perfect Resampler', http://ldesoras.free.fr/doc/articles/resampler-en.pdf;
it combines Julius O. Smith's `Bandlimited Interpolation' technique
(https://ccrma.stanford.edu/~jos/resample/resample.pdf) with FFT-based
over-sampling.
Its use of FFTs means that, for real-time resampling, libsoxr may have a
higher latency than non-FFT based resamplers. E.g. when using the `High
Quality' configuration to resample between 44100Hz and 48kHz, the latency is
around 1000 output samples, i.e. roughly 20 ms.
¹ Note that no practical resampler can be bit-perfect to 100% bandwidth.

View File

@ -1,2 +1,3 @@
* Explicit flush API fn.
* More SIMD work
* SOXR_ALLOW_ALIASING
* Explicit flush API fn, perhaps.
* More SIMD.

View File

@ -19,14 +19,16 @@
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#
# Modified for libsoxr not to rely on presence of C++ compiler.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
include(CheckCSourceCompiles)
include(FindPackageHandleStandardArgs)
include (CheckCSourceCompiles)
include (FindPackageHandleStandardArgs)
set(OpenMP_C_FLAG_CANDIDATES
set (OpenMP_C_FLAG_CANDIDATES
#Gnu
"-fopenmp"
#Microsoft Visual Studio
@ -48,7 +50,7 @@ set(OpenMP_C_FLAG_CANDIDATES
)
# sample openmp source code to test
set(OpenMP_C_TEST_SOURCE
set (OpenMP_C_TEST_SOURCE
"
#include <omp.h>
int main() {
@ -61,31 +63,29 @@ int main() {
")
# if these are set then do not try to find them again,
# by avoiding any try_compiles for the flags
if(DEFINED OpenMP_C_FLAGS)
set(OpenMP_C_FLAG_CANDIDATES)
endif(DEFINED OpenMP_C_FLAGS)
if (DEFINED OpenMP_C_FLAGS)
set (OpenMP_C_FLAG_CANDIDATES)
endif (DEFINED OpenMP_C_FLAGS)
# check c compiler
foreach(FLAG ${OpenMP_C_FLAG_CANDIDATES})
set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
set(CMAKE_REQUIRED_FLAGS "${FLAG}")
unset(OpenMP_FLAG_DETECTED CACHE)
message(STATUS "Try OpenMP C flag = [${FLAG}]")
check_c_source_compiles("${OpenMP_C_TEST_SOURCE}" OpenMP_FLAG_DETECTED)
set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
if(OpenMP_FLAG_DETECTED)
set(OpenMP_C_FLAGS_INTERNAL "${FLAG}")
break()
endif(OpenMP_FLAG_DETECTED)
endforeach(FLAG ${OpenMP_C_FLAG_CANDIDATES})
foreach (FLAG ${OpenMP_C_FLAG_CANDIDATES})
set (SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
set (CMAKE_REQUIRED_FLAGS "${FLAG}")
unset (OpenMP_FLAG_DETECTED CACHE)
message (STATUS "Try OpenMP C flag = [${FLAG}]")
check_c_source_compiles ("${OpenMP_C_TEST_SOURCE}" OpenMP_FLAG_DETECTED)
set (CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
if (OpenMP_FLAG_DETECTED)
set (OpenMP_C_FLAGS_INTERNAL "${FLAG}")
break ()
endif (OpenMP_FLAG_DETECTED)
endforeach (FLAG ${OpenMP_C_FLAG_CANDIDATES})
set(OpenMP_C_FLAGS "${OpenMP_C_FLAGS_INTERNAL}"
set (OpenMP_C_FLAGS "${OpenMP_C_FLAGS_INTERNAL}"
CACHE STRING "C compiler flags for OpenMP parallization")
# handle the standard arguments for find_package
find_package_handle_standard_args(OpenMP DEFAULT_MSG
OpenMP_C_FLAGS OpenMP_C_FLAGS )
find_package_handle_standard_args (OpenMP DEFAULT_MSG
OpenMP_C_FLAGS OpenMP_C_FLAGS)
mark_as_advanced(
OpenMP_C_FLAGS
)
mark_as_advanced (OpenMP_C_FLAGS)

View File

@ -7,17 +7,17 @@
include (CheckCSourceCompiles)
include (FindPackageHandleStandardArgs)
set(SIMD_C_FLAG_CANDIDATES
set (SIMD_C_FLAG_CANDIDATES
#Microsoft Visual Studio
"/arch:SSE /fp:fast -D__SSE__"
#Gnu
"-msse -mfpmath=sse"
)
set(SIMD_C_TEST_SOURCE
set (SIMD_C_TEST_SOURCE
"
#include <xmmintrin.h>
int main ()
int main()
{
__m128 a, b;
float vals[4] = {0};
@ -38,7 +38,7 @@ foreach (FLAG ${SIMD_C_FLAG_CANDIDATES})
set (CMAKE_REQUIRED_FLAGS "${FLAG}")
unset (SIMD_FLAG_DETECTED CACHE)
message (STATUS "Try SIMD C flag = [${FLAG}]")
check_c_source_compiles("${SIMD_C_TEST_SOURCE}" SIMD_FLAG_DETECTED)
check_c_source_compiles ("${SIMD_C_TEST_SOURCE}" SIMD_FLAG_DETECTED)
set (CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
if (SIMD_FLAG_DETECTED)
set (SIMD_C_FLAGS_INTERNAL "${FLAG}")

View File

@ -0,0 +1,15 @@
# SoX Resampler Library Copyright (c) 2007-12 robs@users.sourceforge.net
# Licence for this file: LGPL v2.1 See LICENCE for details.
# - Macro to determine endian type
# test_big_endian (VARIABLE)
# VARIABLE - variable to store the result to
macro (test_big_endian VARIABLE)
if ("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$")
include (CheckCSourceRuns)
check_c_source_runs ("int main() {union {long i; char c[sizeof(long)];}
const u = {1}; return !!u.c[0];}" HAVE_${VARIABLE})
set (${VARIABLE} "${HAVE_${VARIABLE}}" CACHE INTERNAL "1 if system is big endian" FORCE)
endif ()
endmacro ()

13
lib-src/libsoxr/configure vendored Normal file
View File

@ -0,0 +1,13 @@
#!/bin/sh
# SoX Resampler Library Copyright (c) 2007-12 robs@users.sourceforge.net
# Licence for this file: LGPL v2.1 See LICENCE for details.
# Wrapper to allow easier integration with projects using autotools.
# Such projects will probably be using static libs so should pass
# -DBUILD_SHARED_LIBS=OFF amongst any other options needed.
# Autotools options should not be passed to this script.
cmake $* .

View File

@ -0,0 +1,25 @@
# SoX Resampler Library Copyright (c) 2007-12 robs@users.sourceforge.net
# Licence for this file: LGPL v2.1 See LICENCE for details.
if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message (FATAL_ERROR "Cannot find install manifest")
endif ()
file (READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string (REGEX REPLACE "\n" ";" files "${files}")
foreach (file ${files})
set (dest "$ENV{DESTDIR}${file}")
message (STATUS "Deinstalling \"${dest}\"")
if (EXISTS "${dest}" OR IS_SYMLINK "${dest}")
execute_process (
COMMAND @CMAKE_COMMAND@ -E remove "${dest}"
OUTPUT_VARIABLE rm_out
RESULT_VARIABLE rm_retval
)
if (NOT ${rm_retval} EQUAL 0)
message (FATAL_ERROR "Problem when removing \"${dest}\"")
endif ()
else ()
message (STATUS "File \"${dest}\" does not exist.")
endif ()
endforeach ()

View File

@ -0,0 +1,3 @@
Not convinced that this is going anywhere useful.
Run "make docs" in the parent directory to generate the API documentation.

View File

@ -0,0 +1,4 @@
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,31 @@
<head>
<title>$title ($projectname)</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="container">
<table border="0" width="100%">
<tr>
<td width="1">
<img src="../logo.png">
</td>
<td>
<div id="intro">
<table border="0" height="119" cellpadding="0" cellspacing="0" width="100%">
<tr><td valign="top"><h1>The SoX Resampler $projectnumber ($title)</h1></td></tr>
<tr>
<td valign="bottom">
<div id="links">
<a href="index.html">Home</a>
<a href="files.html">Headers</a>
<a href="functions.html">Class&nbsp;Members</a>
<a href="globals.html">File&nbsp;Members</a>
</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<div id="text">

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

@ -0,0 +1,395 @@
body {
font-family: sans-serif;
background: white;
color: black;
margin: 0px;
padding: 15px;
}
a:link {
font-weight: bold;
text-decoration: none;
color: gray;
}
a:visited {
font-weight: bold;
text-decoration: none;
color: gray;
}
a:hover {
color: #cccccc;
text-decoration: underline;
}
a:active {
color: #cccccc;
text-decoration: underline;
}
img {
border-style: none;
}
h1 {
font-family: sans-serif;
}
h2 {
font-family: sans-serif;
}
h3 {
font-family: sans-serif;
}
/* container */
#container {
position: absolute;
border-width: thin;
border-style: solid;
width: 95%;
}
/* intro */
#intro {
padding: 5px;
margin: 0px;
background: #cccccc;
border-width: medium;
border-style: solid;
}
#intro h1 {
margin: 5px;
padding: 5px;
}
/* links */
#links {
font-size: x-small;
vertical-align: bottom;
}
#links a {
border-width: thin;
border-style: dotted;
border-color: white;
/* margin: 0px 10px 0px 0px; */
margin: 1px;
padding: 3px;
line-height: 230%
}
#links a:hover {
color: black;
text-decoration: underline;
}
#links h3 {
outline-width: thin;
border-style: solid;
padding: 2px;
margin: 3px 0px 3px 0px;
}
/* menu */
#menu h3 {
text-align: center;
}
/* text */
#text {
margin: 0px;
padding: 5px 5px 0px 5px;
float: left;
}
#text h3 {
border-width: thin;
border-style: solid;
padding: 2px;
margin: 3px 0px 3px 0px;
}
#text li {
margin: 0px 0px 10px 0px;
}
#text ul {
margin: 5px;
padding: 0px 0px 0px 20px;
}
#leftcolumn {
float: left;
width: 300px;
margin: 0px 10px 0px 0px;
padding: 0px;
}
#rightcolumn {
float: right;
width: 210px;
margin: 0px;
padding: 0px;
}
/* vspacer */
.vspacer {
height: 10px;
}
.silver {
border-width: thin;
border-color: black;
border-style: solid;
background: #cccccc;
}
a.code {
text-decoration: none;
font-weight: normal;
color: #4444ee
}
a.codeRef {
font-weight: normal;
color: #4444ee
}
div.fragment {
width: 98%;
border: 1px solid #CCCCCC;
background-color: #f5f5f5;
padding-left: 4px;
margin: 4px;
}
div.ah {
background-color: black;
font-weight: bold; color: #ffffff;
margin-bottom: 3px;
margin-top: 3px
}
#text td {
width: auto;
}
div.memdoc {
margin-top: 0px;
margin-bottom: 20px;
padding: 10px 10px 10px 40px;
}
div.memproto {
border: thin solid black;
background-color: #f2f2ff;
width: 100%;
margin-top: 20px;
padding-top: 10px;
padding-bottom: 10px;
}
td.paramtype {
color: #602020;
}
table.memname {
font-weight: bold;
}
div.groupHeader {
margin-left: 16px;
margin-top: 12px;
margin-bottom: 6px;
font-weight: bold
}
div.groupText {
margin-left: 16px;
font-style: italic;
font-size: smaller
}
body {
background: white;
color: black;
margin-right: 20px;
margin-left: 20px;
}
td.indexkey {
background-color: #eeeeff;
font-weight: bold;
padding-right : 10px;
padding-top : 2px;
padding-left : 10px;
padding-bottom : 2px;
margin-left : 0px;
margin-right : 0px;
margin-top : 2px;
margin-bottom : 2px
}
td.indexvalue {
background-color: #eeeeff;
font-style: italic;
padding-right : 10px;
padding-top : 2px;
padding-left : 10px;
padding-bottom : 2px;
margin-left : 0px;
margin-right : 0px;
margin-top : 2px;
margin-bottom : 2px
}
tr.memlist {
background-color: #f0f0f0;
}
p.formulaDsp {
text-align: center;
}
img.formulaDsp {
}
img.formulaInl {
vertical-align: middle;
}
span.keyword {
color: #008000
}
span.keywordtype {
color: #604020
}
span.keywordflow {
color: #e08000
}
span.comment {
color: #800000
}
span.preprocessor {
color: #806020
}
span.stringliteral {
color: #002080
}
span.charliteral {
color: #008080
}
.mdTable {
border: 1px solid #868686;
background-color: #f2f2ff;
}
.mdRow {
padding: 8px 20px;
}
.mdescLeft {
font-size: smaller;
font-family: Arial, Helvetica, sans-serif;
background-color: #FAFAFA;
padding-left: 8px;
border-top: 1px none #E0E0E0;
border-right: 1px none #E0E0E0;
border-bottom: 1px none #E0E0E0;
border-left: 1px none #E0E0E0;
margin: 0px;
}
.mdescRight {
font-size: smaller;
font-family: Arial, Helvetica, sans-serif;
font-style: italic;
background-color: #FAFAFA;
padding-left: 4px;
border-top: 1px none #E0E0E0;
border-right: 1px none #E0E0E0;
border-bottom: 1px none #E0E0E0;
border-left: 1px none #E0E0E0;
margin: 0px;
padding-bottom: 0px;
padding-right: 8px;
}
.memItemLeft {
padding: 1px 0px 0px 8px;
margin: 4px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-top-color: #E0E0E0;
border-right-color: #E0E0E0;
border-bottom-color: #E0E0E0;
border-left-color: #E0E0E0;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
background-color: #FAFAFA;
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 12px;
}
.memItemRight {
padding: 1px 0px 0px 8px;
margin: 4px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-top-color: #E0E0E0;
border-right-color: #E0E0E0;
border-bottom-color: #E0E0E0;
border-left-color: #E0E0E0;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
background-color: #FAFAFA;
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 13px;
}
.search {
color: #0000ee;
font-weight: bold;
}
form.search {
margin-bottom: 0px;
margin-top: 0px;
}
input.search {
font-size: 75%;
color: #000080;
font-weight: normal;
background-color: #eeeeff;
}
td.tiny {
font-size: 75%;
}

View File

@ -6,10 +6,18 @@
* N.B. See example 2 for how to resample a stream (of blocks).
*
* Optional arguments are: INPUT-RATE OUTPUT-RATE
*
* With the default arguments, the output should produce lines similar to the
* following:
*
* 0.00 0.71 1.00 0.71 -0.00 -0.71 -1.00 -0.71
*
* Gibbs effect may be seen at the ends of the resampled signal; this is because
* unlike a `real-world' signal, the synthetic input signal is not band-limited.
*/
#include "util.h"
#include <soxr.h>
#include "examples-common.h"
const float in[] = { /* Input: 12 cycles of a sine wave with freq. = irate/4 */
0,1,0,-1, 0,1,0,-1, 0,1,0,-1, 0,1,0,-1, 0,1,0,-1, 0,1,0,-1,

View File

@ -3,15 +3,13 @@
/* Example 2a: resample a raw, single-channel, floating-point data stream from
* stdin to stdout. The application uses the single function `soxr_process'
* for input and output to/from the resampler.
* for both input and output to/from the resampler.
*
* Arguments are: INPUT-RATE OUTPUT-RATE
*/
#include "util.h"
#include <soxr.h>
#include "examples-common.h"
int main(int argc, char const * arg[])
{
@ -19,11 +17,14 @@ int main(int argc, char const * arg[])
double orate = argc > 2? atof(arg[2]) : 96000.;
soxr_error_t error;
soxr_t resampler = soxr_create(irate, orate, 1, &error, 0, 0, 0);
STD_STDIO;
soxr_t resampler = soxr_create(
irate, orate, 1, /* Input rate, output rate, # of channels. */
&error, /* To report any error during creation. */
NULL, NULL, NULL); /* Use configuration defaults.*/
if (!error) {
#define buf_total_len 15000
#define buf_total_len 12000 /* In samples. */
/* Allocate resampling input and output buffers in proportion to the input
* and output rates: */
@ -35,15 +36,20 @@ int main(int argc, char const * arg[])
size_t iavailable = 0;
size_t idone, odone, written;
USE_STD_STDIO;
do { /* Resample in blocks: */
if (!iavailable && ibuf) /* If ibuf empty, try to fill it: */
if (!(iavailable = fread(iptr = ibuf, sizeof(float), ibuflen, stdin)))
free(ibuf), ibuf = 0; /* If none available, don't retry. */
if (!iavailable && ibuf) { /* If ibuf is empty, try to fill it: */
iavailable = fread(ibuf, sizeof(float), ibuflen, stdin);
if (!iavailable) /* If none available, don't retry. Pass NULL */
free(ibuf), ibuf = 0;/* ibuf to resampler to indicate end-of-input. */
iptr = ibuf; /* Reset input to the start of the buffer. */
}
error = soxr_process(resampler,
iptr, iavailable, &idone, obuf, obuflen, &odone);
iptr += idone * sizeof(float), iavailable -= idone; /* Consumed input. */
iptr += idone * sizeof(float); /* Update input buffer according to how */
iavailable -= idone; /* much the resampler has consumed. */
written = fwrite(obuf, sizeof(float), odone, stdout); /* Consume output.*/
} while (!error && (ibuf || written));
@ -52,7 +58,7 @@ int main(int argc, char const * arg[])
soxr_delete(resampler);
}
/* Diagnostics: */
fprintf(stderr, "resampler: %s; I/O: %s\n",
fprintf(stderr, "%-26s %s; I/O: %s\n", arg[0],
soxr_strerror(error), errno? strerror(errno) : "no error");
return error || errno;
}

View File

@ -8,10 +8,10 @@
* Arguments are: INPUT-RATE OUTPUT-RATE
*/
#include "util.h"
#include <soxr.h>
#include "examples-common.h"
#define iolen 10000
static size_t input_fn(
void * p, /* Generic pointer to any state variables neded here. */
@ -20,23 +20,25 @@ static size_t input_fn(
{
static float * ibuf; /* Static context; this could be changed using `p'. */
size_t actual;
size_t len = min(requested_len, iolen);
/* Allocate the input buffer memory; check for errors: */
*buf = ibuf = realloc(ibuf, sizeof(float) * requested_len);
*buf = ibuf = (float *)realloc(ibuf, sizeof(float) * len);
if (!ibuf)
return 0; /* Indicate failure (*buf is also 0). */
/* Read samples from the input stream; check for errors: */
actual = fread(ibuf, sizeof(float), requested_len, stdin);
if (!actual && ferror(stdin))
*buf = 0; /* Indicate failure (actual is also 0). */
actual = fread(ibuf, sizeof(float), len, stdin);
if (!actual) {
if (ferror(stdin))
*buf = 0; /* Indicate failure (actual is also 0). */
free(ibuf), ibuf = 0;
}
return actual;
(void)p; /* Not used in this example. */
}
int main(int argc, char const * arg[])
{
double irate = argc > 1? atof(arg[1]) : 44100.;
@ -47,20 +49,19 @@ int main(int argc, char const * arg[])
if (!error) /* Register input_fn with the resampler: */
error = soxr_set_input_fn(resampler, input_fn, 0);
STD_STDIO;
if (!error) { /* If all is good, run the resampler: */
#define olen 1000
float resampled[olen];
float resampled[iolen];
size_t actual;
/* Resample in blocks: */
do actual = soxr_output(resampler, resampled, olen);
USE_STD_STDIO;
do actual = soxr_output(resampler, resampled, iolen);
while (fwrite(resampled, sizeof(float), actual, stdout));
error = soxr_error(resampler); /* Note: before deleting the resampler! */
soxr_delete(resampler);
}
/* Diagnostics: */
fprintf(stderr, "resampler: %s; I/O: %s\n",
fprintf(stderr, "%-26s %s; I/O: %s\n", arg[0],
soxr_strerror(error), errno? strerror(errno) : "no error");
return error || errno;
}

View File

@ -4,20 +4,19 @@
/* Example 3a: extends example 2a with multiple channels, multiple datatypes,
* and other options.
*
* The seven arguments are:
* The eight arguments are:
* INPUT-RATE As example 2a
* OUTPUT-RATE Ditto
* NUM-CHANNELS Number of interleaved channels
* IN-DATATYPE# 0:float32 1:float64 2:int32 3:int16
* OUT-DATATYPE# Ditto
* Q# Quality-recipe | (quality-flags << 16) (in hex) See soxr.h
* Q-RECIPE Quality recipe (in hex) See soxr.h
* Q-FLAGS Quality flags (in hex) See soxr.h
* USE-THREADS 1 to use multi-threading
*/
#include "util.h"
#include <soxr.h>
#include "examples-common.h"
int main(int n, char const * arg[])
{
@ -28,6 +27,7 @@ int main(int n, char const * arg[])
soxr_datatype_t itype = n? --n, (soxr_datatype_t)atoi(*arg++) :SOXR_FLOAT32_I;
soxr_datatype_t otype = n? --n, (soxr_datatype_t)atoi(*arg++) :SOXR_FLOAT32_I;
unsigned long q_recipe= n? --n, strtoul(*arg++, 0, 16) : SOXR_HQ;
unsigned long q_flags = n? --n, strtoul(*arg++, 0, 16) : 0;
int use_threads = n? --n, atoi(*arg++) : 1;
size_t isize = soxr_datatype_size(itype) * chans;
@ -35,16 +35,15 @@ int main(int n, char const * arg[])
size_t clips = 0;
soxr_error_t error;
soxr_quality_spec_t q_spec = soxr_quality_spec(q_recipe &65535, q_recipe>>16);
soxr_quality_spec_t q_spec = soxr_quality_spec(q_recipe, q_flags);
soxr_io_spec_t io_spec = soxr_io_spec(itype, otype);
soxr_runtime_spec_t runtime_spec = soxr_runtime_spec(!use_threads);
soxr_t resampler = soxr_create(
irate, orate, chans, &error, &io_spec, &q_spec, &runtime_spec);
STD_STDIO;
if (!error) {
#define buf_total_len 15000
#define buf_total_len 15000 /* In samples. */
/* Allocate resampling input and output buffers in proportion to the input
* and output rates: */
@ -56,15 +55,20 @@ int main(int n, char const * arg[])
size_t iavailable = 0;
size_t idone, odone, written;
do {
if (!iavailable && ibuf) /* If ibuf empty, try to fill it: */
if (!(iavailable = fread(iptr = ibuf, isize, ibuflen, stdin)))
free(ibuf), ibuf = 0; /* If none available, don't retry. */
USE_STD_STDIO;
do { /* Resample in blocks: */
if (!iavailable && ibuf) { /* If ibuf is empty, try to fill it: */
iavailable = fread(ibuf, isize, ibuflen, stdin);
if (!iavailable) /* If none available, don't retry. Pass NULL */
free(ibuf), ibuf = 0;/* ibuf to resampler to indicate end-of-input. */
iptr = ibuf; /* Reset input to the start of the buffer. */
}
error = soxr_process(resampler,
iptr, iavailable, &idone, obuf, obuflen, &odone);
iptr += idone * isize, iavailable -= idone; /* Consumed input. */
iptr += idone * isize; /* Update input buffer according to how */
iavailable -= idone; /* much the resampler has consumed. */
written = fwrite(obuf, osize, odone, stdout); /* Consume output. */
} while (!error && (ibuf || written));
@ -73,7 +77,7 @@ int main(int n, char const * arg[])
clips = *soxr_num_clips(resampler); /* Can occur only with integer output.*/
soxr_delete(resampler);
}
fprintf(stderr, "%s %s; %lu clips; I/O: %s\n", arg0, soxr_strerror(error),
fprintf(stderr, "%-26s %s; %lu clips; I/O: %s\n", arg0, soxr_strerror(error),
(long unsigned)clips, errno? strerror(errno) : "no error");
return error || errno;
}

View File

@ -1,21 +1,24 @@
/* SoX Resampler Library Copyright (c) 2007-12 robs@users.sourceforge.net
* Licence for this file: LGPL v2.1 See LICENCE for details. */
/* Example 3a: extends example 2a with multiple channels, multiple datatypes,
/* Example 3b: extends example 2b with multiple channels, multiple datatypes,
* and other options.
*
* The seven arguments are:
* INPUT-RATE As example 2a
* The eight arguments are:
* INPUT-RATE As example 2b
* OUTPUT-RATE Ditto
* NUM-CHANNELS Number of interleaved channels
* IN-DATATYPE# 0:float32 1:float64 2:int32 3:int16
* OUT-DATATYPE# Ditto
* Q# Quality-recipe | (quality-flags << 16) (in hex) See soxr.h
* Q-RECIPE Quality recipe (in hex) See soxr.h
* Q-FLAGS Quality flags (in hex) See soxr.h
* USE-THREADS 1 to use multi-threading
*/
#include "util.h"
#include <soxr.h>
#include "examples-common.h"
#define iolen 8000
@ -23,6 +26,7 @@ static size_t input_fn(void * p, soxr_cbuf_t * buf, size_t len)
{
static float * ibuf;
size_t isize = *(size_t *)p;
len = min(len, iolen);
*buf = ibuf = realloc(ibuf, isize * len);
if (!ibuf)
return 0;
@ -46,6 +50,7 @@ int main(int n, char const * arg[])
soxr_datatype_t itype = n? --n, (soxr_datatype_t)atoi(*arg++) :SOXR_FLOAT32_I;
soxr_datatype_t otype = n? --n, (soxr_datatype_t)atoi(*arg++) :SOXR_FLOAT32_I;
unsigned long q_recipe= n? --n, strtoul(*arg++, 0, 16) : SOXR_HQ;
unsigned long q_flags = n? --n, strtoul(*arg++, 0, 16) : 0;
int use_threads = n? --n, atoi(*arg++) : 1;
size_t isize = soxr_datatype_size(itype) * chans;
@ -53,7 +58,7 @@ int main(int n, char const * arg[])
size_t clips = 0;
soxr_error_t error;
soxr_quality_spec_t q_spec = soxr_quality_spec(q_recipe &65535, q_recipe>>16);
soxr_quality_spec_t q_spec = soxr_quality_spec(q_recipe, q_flags);
soxr_io_spec_t io_spec = soxr_io_spec(itype, otype);
soxr_runtime_spec_t runtime_spec = soxr_runtime_spec(!use_threads);
@ -61,13 +66,12 @@ int main(int n, char const * arg[])
irate, orate, chans, &error, &io_spec, &q_spec, &runtime_spec);
if (!error) error = soxr_set_input_fn(resampler, input_fn, &isize);
STD_STDIO;
USE_STD_STDIO;
if (!error) {
#define olen 8000
void * resampled = malloc(osize * olen);
void * resampled = malloc(osize * iolen);
size_t actual;
do actual = soxr_output(resampler, resampled, olen);
do actual = soxr_output(resampler, resampled, iolen);
while (fwrite(resampled, osize, actual, stdout));
free(resampled);
@ -75,7 +79,7 @@ int main(int n, char const * arg[])
clips = *soxr_num_clips(resampler); /* Can occur only with integer output.*/
soxr_delete(resampler);
}
fprintf(stderr, "%s %s; %lu clips; I/O: %s\n", arg0, soxr_strerror(error),
fprintf(stderr, "%-26s %s; %lu clips; I/O: %s\n", arg0, soxr_strerror(error),
(long unsigned)clips, errno? strerror(errno) : "no error");
return error || errno;
}

View File

@ -1,10 +1,22 @@
/* SoX Resampler Library Copyright (c) 2007-12 robs@users.sourceforge.net
* Licence for this file: LGPL v2.1 See LICENCE for details. */
/* Example 4a: variant of example 3a demonstrating I/O with split channels. */
/* Example 4: variant of example 3a; demonstrates I/O with split channels.
*
* Note that, for convenience of the demonstration, split-channel data is
* made available by deinterleaving data sourced from and sent to
* interleaved file-streams; this adds a lot of code to the example that,
* for purposes of understanding how to use split-channels, may safely be
* ignored. In a real application, the channel-data might never be
* interleaved; for example, the split-channel data output from the
* resampler might be sent directly to digital-to-analogue converters.
*
* Note also (not shown in the examples) that split/interleaved channels may
* be used for input and output independently.
*/
#include <soxr.h>
#include "util.h"
#include "examples-common.h"
@ -63,6 +75,7 @@ int main(int n, char const * arg[])
soxr_datatype_t itype = n? --n, (soxr_datatype_t)atoi(*arg++) :SOXR_FLOAT32_I;
soxr_datatype_t otype = n? --n, (soxr_datatype_t)atoi(*arg++) :SOXR_FLOAT32_I;
unsigned long q_recipe= n? --n, strtoul(*arg++, 0, 16) : SOXR_HQ;
unsigned long q_flags = n? --n, strtoul(*arg++, 0, 16) : 0;
int use_threads = n? --n, atoi(*arg++) : 1;
size_t isize = soxr_datatype_size(itype) * chans;
@ -70,16 +83,15 @@ int main(int n, char const * arg[])
size_t clips = 0;
soxr_error_t error;
soxr_quality_spec_t q_spec = soxr_quality_spec(q_recipe &65535, q_recipe>>16);
soxr_quality_spec_t q_spec = soxr_quality_spec(q_recipe, q_flags);
soxr_io_spec_t io_spec = soxr_io_spec(itype|SOXR_SPLIT, otype|SOXR_SPLIT);
soxr_runtime_spec_t runtime_spec = soxr_runtime_spec(!use_threads);
soxr_t resampler = soxr_create(
irate, orate, chans, &error, &io_spec, &q_spec, &runtime_spec);
STD_STDIO;
if (!error) {
#define buf_total_len 15000
#define buf_total_len 14000
/* Allocate resampling input and output buffers in proportion to the input
* and output rates: */
@ -108,6 +120,7 @@ int main(int n, char const * arg[])
optr += obuflen * soxr_datatype_size(otype);
}
USE_STD_STDIO;
do {
if (!iavailable && ibuf_offset_ptrs) { /* If ibuf empty, try to fill it: */
if (!(iavailable = fread(ibuf, isize, ibuflen, stdin)))
@ -134,7 +147,7 @@ int main(int n, char const * arg[])
clips = *soxr_num_clips(resampler);
soxr_delete(resampler);
}
fprintf(stderr, "%s %s; %lu clips; I/O: %s\n", arg0, soxr_strerror(error),
fprintf(stderr, "%-26s %s; %lu clips; I/O: %s\n", arg0, soxr_strerror(error),
(long unsigned)clips, errno? strerror(errno) : "no error");
return error || errno;
}

View File

@ -1,14 +1,21 @@
# SoX Resampler Library Copyright (c) 2007-12 robs@users.sourceforge.net
# Licence for this file: LGPL v2.1 See LICENCE for details.
add_definitions (${PROJECT_DEFS})
if (${BUILD_EXAMPLES})
project (soxr)
file (GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.[cC])
if (NOT BUILD_SHARED_LIBS AND OPENMP_FOUND)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_C_FLAGS}")
endif ()
else ()
file (GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/3b*.c)
endif ()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PROJECT_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PROJECT_CXX_FLAGS}")
link_libraries (${PROJECT_NAME})
file (GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.c)
foreach (fe ${SOURCES})
get_filename_component (f ${fe} NAME_WE)
add_executable (${f} ${fe})
if (NOT ${f} MATCHES "^3b")
set_target_properties(${f} PROPERTIES EXCLUDE_FROM_ALL TRUE)
endif ()
endforeach ()

View File

@ -12,6 +12,19 @@
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
/* Work-around for broken file-I/O on MS-Windows: */
#include <io.h>
#include <fcntl.h>
#define USE_STD_STDIO _setmode(_fileno(stdout), _O_BINARY), \
_setmode(_fileno(stdin ), _O_BINARY);
/* Sometimes missing, so ensure that it is defined: */
#undef M_PI
#define M_PI 3.14159265358979323846
#else
#define USE_STD_STDIO
#endif
#undef int16_t
#define int16_t short
@ -28,16 +41,3 @@
#define min(x,y) ((x)<(y)?(x):(y))
#define AL(a) (sizeof(a)/sizeof((a)[0])) /* Array Length */
#ifdef _WIN32
#undef M_PI
#define M_PI 3.14159265358979323846
/* Work-around for broken file-I/O on MS-Windows: */
#include <io.h>
#include <fcntl.h>
#define STD_STDIO _setmode(_fileno(stdout), _O_BINARY), \
_setmode(_fileno(stdin ), _O_BINARY);
#else
#define STD_STDIO
#endif

View File

@ -8,6 +8,6 @@ test x$build = x && build=Release
mkdir -p $build
cd $build
cmake -DCMAKE_BUILD_TYPE=$build .. &&
cmake -DCMAKE_BUILD_TYPE=$build -DBUILD_TESTS=ON .. &&
make &&
(make test || echo "FAILURE details in $build/Testing/Temporary/LastTest.log")

View File

@ -8,7 +8,7 @@ if x%build% == x set build=Release
mkdir %build%
cd %build%
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=%build% ..
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=%build% -DBUILD_TESTS=ON ..
if errorlevel 1 goto end
nmake

View File

@ -1,19 +1,19 @@
# SoX Resampler Library Copyright (c) 2007-12 robs@users.sourceforge.net
# Licence for this file: LGPL v2.1 See LICENCE for details.
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
find_package(FFTW)
find_package (FFTW)
if (FFTW_FOUND)
include_directories(${FFTW_INCLUDE_DIRS})
link_libraries(${FFTW_LIBRARIES})
include_directories (${FFTW_INCLUDE_DIRS})
link_libraries (${FFTW_LIBRARIES})
set (HAVE_FFTW3 1)
endif ()
find_package(sndfile)
find_package (sndfile)
if (SNDFILE_FOUND)
include_directories(${SNDFILE_INCLUDE_DIRS})
link_libraries(${SNDFILE_LIBRARIES})
include_directories (${SNDFILE_INCLUDE_DIRS})
link_libraries (${SNDFILE_LIBRARIES})
set (HAVE_SNDFILE 1)
endif ()
@ -31,7 +31,7 @@ add_library (tests_lib SHARED util calc_snr)
link_libraries (tests_lib ${PROJECT_NAME}-lsr)
enable_testing()
enable_testing ()
set (tests
callback_hang_test callback_test downsample_test
@ -40,8 +40,8 @@ set (tests
foreach (test ${tests})
add_executable (${test} ${test})
add_test (lsr-${test} ${bin}${test})
set_property(TEST lsr-${test} PROPERTY ENVIRONMENT "SOXR_LSR_STRICT=1")
add_test (lsr-${test} ${BIN}${test})
set_property (TEST lsr-${test} PROPERTY ENVIRONMENT "SOXR_LSR_STRICT=1")
endforeach ()
add_executable (multichan_throughput_test multichan_throughput_test)

View File

@ -4,18 +4,14 @@
#if !defined soxr_config_included
#define soxr_config_included
#define SOXR_VERSION_MAJOR @VERSION_MAJOR@
#define SOXR_VERSION_MINOR @VERSION_MINOR@
#define SOXR_VERSION_PATCH @VERSION_PATCH@
#define SOXR_VERSION "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@"
#define SOXR_VERSION "@PROJECT_VERSION@"
#define HAVE_SINGLE_PRECISION @HAVE_SINGLE_PRECISION@
#define HAVE_DOUBLE_PRECISION @HAVE_DOUBLE_PRECISION@
#define HAVE_AVFFT @HAVE_AVFFT@
#define HAVE_SIMD @HAVE_SIMD@
#define HAVE_FENV_H @HAVE_FENV_H@
#define HAVE_LRINT @HAVE_LRINT@
#define WORDS_BIGENDIAN @WORDS_BIGENDIAN@
#define HAVE_AVFFT @HAVE_AVFFT@
#define HAVE_SIMD @HAVE_SIMD@
#define HAVE_FENV_H @HAVE_FENV_H@
#define HAVE_LRINT @HAVE_LRINT@
#define WORDS_BIGENDIAN @WORDS_BIGENDIAN@
#include <limits.h>
@ -40,7 +36,7 @@
#error this library requires that 'long int' has at least 32-bits
#else
#define int32_t long
#if defined(_MSC_VER)
#if defined _MSC_VER
#define int64_t __int64
#else
#define int64_t long long

View File

@ -1,7 +1,11 @@
# SoX Resampler Library Copyright (c) 2007-12 robs@users.sourceforge.net
# Licence for this file: LGPL v2.1 See LICENCE for details.
add_definitions (${PROJECT_DEFS} -DSOXR_LIB)
add_definitions (${PROJECT_C_FLAGS} -DSOXR_LIB)
# Libsoxr configuration:
set (RDFT32 fft4g32)
if (WITH_AVFFT AND AVCODEC_FOUND)
@ -23,42 +27,82 @@ endif ()
if (HAVE_SIMD)
set (SIMD_SOURCES rate32s ${RDFT32S} simd)
foreach (source ${SIMD_SOURCES})
set_property(SOURCE ${source} PROPERTY COMPILE_FLAGS ${SIMD_C_FLAGS})
set_property (SOURCE ${source} PROPERTY COMPILE_FLAGS ${SIMD_C_FLAGS})
endforeach ()
endif ()
add_library(${PROJECT_NAME} ${LIB_TYPE} ${PROJECT_NAME} data-io dbesi0 filter fft4g64
# Libsoxr:
add_library (${PROJECT_NAME} ${LIB_TYPE} ${PROJECT_NAME}.c data-io dbesi0 filter fft4g64
${SP_SOURCES} ${DP_SOURCES} ${SIMD_SOURCES})
set_target_properties (${PROJECT_NAME} PROPERTIES SOVERSION "${VERSION}")
list (APPEND TARGET_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.h")
set_target_properties (${PROJECT_NAME} PROPERTIES
VERSION "${SO_VERSION}"
SOVERSION ${SO_VERSION_MAJOR}
INSTALL_NAME_DIR ${LIB_INSTALL_DIR}
LINK_INTERFACE_LIBRARIES ""
PUBLIC_HEADER "${PROJECT_NAME}.h")
if (BUILD_FRAMEWORK)
set_target_properties (${PROJECT_NAME} PROPERTIES FRAMEWORK TRUE)
elseif (NOT WIN32)
set (TARGET_PCS ${CMAKE_CURRENT_BINARY_DIR}/lib${PROJECT_NAME}.pc)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/lib${PROJECT_NAME}.pc.in ${TARGET_PCS})
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
endif ()
if (WITH_LSR_IF)
set (LSR samplerate)
# LSR bindings:
if (WITH_LSR_BINDINGS)
set (LSR ${PROJECT_NAME}-lsr)
add_library(${LSR} ${LIB_TYPE} lsr)
set (LSR_SO_VERSION 0.1.8)
set (LSR_SO_VERSION_MAJOR 0)
add_library (${LSR} ${LIB_TYPE} lsr)
target_link_libraries (${LSR} ${PROJECT_NAME})
set_target_properties (${LSR} PROPERTIES SOVERSION ${VERSION})
list (APPEND TARGET_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/${LSR}.h")
endif ()
install (TARGETS ${PROJECT_NAME} ${LSR} DESTINATION lib)
install (FILES ${TARGET_HEADERS} DESTINATION include)
# Packaging
get_property(LIB1 TARGET ${PROJECT_NAME} PROPERTY LOCATION)
if (BUILD_SHARED_LIBS)
set (LIB1 ${LIB1}.${VERSION})
endif ()
if (WITH_LSR_IF)
get_property(LIB2 TARGET ${LSR} PROPERTY LOCATION)
if (BUILD_SHARED_LIBS)
set (LIB2 ${LIB2}.${VERSION})
set_target_properties (${LSR} PROPERTIES
VERSION "${LSR_SO_VERSION}"
SOVERSION ${LSR_SO_VERSION_MAJOR}
INSTALL_NAME_DIR ${LIB_INSTALL_DIR}
LINK_INTERFACE_LIBRARIES ""
PUBLIC_HEADER "${LSR}.h")
if (BUILD_FRAMEWORK)
set_target_properties (${LSR} PROPERTIES FRAMEWORK TRUE)
elseif (NOT WIN32)
set (TARGET_PCS "${TARGET_PCS} ${CMAKE_CURRENT_BINARY_DIR}/lib${LSR}.pc")
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/lib${LSR}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/lib${LSR}.pc)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${LSR}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
endif ()
endif ()
# Installation (from build from source):
install (TARGETS ${PROJECT_NAME} ${LSR}
FRAMEWORK DESTINATION ${FRAMEWORK_INSTALL_DIR}
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
PUBLIC_HEADER DESTINATION ${INCLUDE_INSTALL_DIR})
# Packaging (for unix-like distributions):
get_property (LIB1 TARGET ${PROJECT_NAME} PROPERTY LOCATION)
if (BUILD_SHARED_LIBS)
set (LIB1 ${LIB1}.${SO_VERSION_MAJOR} ${LIB1}.${SO_VERSION})
endif ()
list (APPEND TARGET_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.h")
if (WITH_LSR_BINDINGS)
get_property (LIB2 TARGET ${LSR} PROPERTY LOCATION)
if (BUILD_SHARED_LIBS)
set (LIB2 ${LIB2}.${LSR_SO_VERSION_MAJOR} ${LIB2}.${LSR_SO_VERSION})
endif ()
list (APPEND TARGET_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/${LSR}.h")
endif ()
set (TARGET_LIBS ${LIB1} ${LIB2})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libsoxr.src ${CMAKE_CURRENT_BINARY_DIR}/libsoxr.src)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libsoxr-dev.src ${CMAKE_CURRENT_BINARY_DIR}/libsoxr-dev.src)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/libsoxr.src.in ${CMAKE_CURRENT_BINARY_DIR}/libsoxr.src)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/libsoxr-dev.src.in ${CMAKE_CURRENT_BINARY_DIR}/libsoxr-dev.src)

View File

@ -1,30 +1,37 @@
/* SoX Resampler Library Copyright (c) 2007-12 robs@users.sourceforge.net
* Licence for this file: LGPL v2.1 See LICENCE for details. */
#if defined SOXR_LIB
#define lsx_bessel_I_0 _soxr_bessel_I_0
#define lsx_cdft _soxr_cdft
#define lsx_cdft_f _soxr_cdft_f
#define lsx_clear_fft_cache _soxr_clear_fft_cache
#define lsx_clear_fft_cache_f _soxr_clear_fft_cache_f
#define lsx_ddct _soxr_ddct
#define lsx_ddct_f _soxr_ddct_f
#define lsx_ddst _soxr_ddst
#define lsx_ddst_f _soxr_ddst_f
#define lsx_design_lpf _soxr_design_lpf
#define lsx_dfct _soxr_dfct
#define lsx_dfct_f _soxr_dfct_f
#define lsx_dfst _soxr_dfst
#define lsx_dfst_f _soxr_dfst_f
#define lsx_fir_to_phase _soxr_fir_to_phase
#define lsx_init_fft_cache _soxr_init_fft_cache
#define lsx_init_fft_cache_f _soxr_init_fft_cache_f
#define lsx_kaiser_beta _soxr_kaiser_beta
#define lsx_kaiser_params _soxr_kaiser_params
#define lsx_make_lpf _soxr_make_lpf
#define lsx_rdft _soxr_rdft
#define lsx_rdft_f _soxr_rdft_f
#define lsx_safe_cdft _soxr_safe_cdft
#define lsx_safe_cdft_f _soxr_safe_cdft_f
#define lsx_safe_rdft _soxr_safe_rdft
#define lsx_safe_rdft_f _soxr_safe_rdft_f
#define lsx_bessel_I_0 _soxr_bessel_I_0
#define lsx_cdft_f _soxr_cdft_f
#define lsx_cdft _soxr_cdft
#define lsx_clear_fft_cache_f _soxr_clear_fft_cache_f
#define lsx_clear_fft_cache _soxr_clear_fft_cache
#define lsx_ddct_f _soxr_ddct_f
#define lsx_ddct _soxr_ddct
#define lsx_ddst_f _soxr_ddst_f
#define lsx_ddst _soxr_ddst
#define lsx_design_lpf _soxr_design_lpf
#define lsx_dfct_f _soxr_dfct_f
#define lsx_dfct _soxr_dfct
#define lsx_dfst_f _soxr_dfst_f
#define lsx_dfst _soxr_dfst
#define lsx_fir_to_phase _soxr_fir_to_phase
#define lsx_init_fft_cache_f _soxr_init_fft_cache_f
#define lsx_init_fft_cache _soxr_init_fft_cache
#define lsx_kaiser_beta _soxr_kaiser_beta
#define lsx_kaiser_params _soxr_kaiser_params
#define lsx_make_lpf _soxr_make_lpf
#define lsx_ordered_convolve_f _soxr_ordered_convolve_f
#define lsx_ordered_convolve _soxr_ordered_convolve
#define lsx_ordered_partial_convolve_f _soxr_ordered_partial_convolve_f
#define lsx_ordered_partial_convolve _soxr_ordered_partial_convolve
#define lsx_rdft_f _soxr_rdft_f
#define lsx_rdft _soxr_rdft
#define lsx_safe_cdft_f _soxr_safe_cdft_f
#define lsx_safe_cdft _soxr_safe_cdft
#define lsx_safe_rdft_f _soxr_safe_rdft_f
#define lsx_safe_rdft _soxr_safe_rdft
#endif

View File

@ -44,7 +44,9 @@ static bool UPDATE_FFT_CACHE(int len)
LSX_FFT_SC = realloc(LSX_FFT_SC, dft_sc_len(FFT_LEN) * sizeof(*LSX_FFT_SC));
if (!old_n) {
LSX_FFT_BR[0] = 0;
#if SOXR_LIB
atexit(LSX_CLEAR_FFT_CACHE);
#endif
}
return true;
}

View File

@ -48,17 +48,17 @@
#include "fft4g_cache.h"
#endif
#if HAVE_DOUBLE_PRECISION
#if HAVE_DOUBLE_PRECISION || !SOXR_LIB
#define DFT_FLOAT double
#define ORDERED_CONVOLVE _soxr_ordered_convolve
#define ORDERED_PARTIAL_CONVOLVE _soxr_ordered_partial_convolve
#define ORDERED_CONVOLVE lsx_ordered_convolve
#define ORDERED_PARTIAL_CONVOLVE lsx_ordered_partial_convolve
#include "rdft.h"
#endif
#if HAVE_SINGLE_PRECISION
#define DFT_FLOAT float
#define ORDERED_CONVOLVE _soxr_ordered_convolve_f
#define ORDERED_PARTIAL_CONVOLVE _soxr_ordered_partial_convolve_f
#define ORDERED_CONVOLVE lsx_ordered_convolve_f
#define ORDERED_PARTIAL_CONVOLVE lsx_ordered_partial_convolve_f
#include "rdft.h"
#endif

View File

@ -7,7 +7,6 @@
#include "aliases.h"
double lsx_bessel_I_0(double x);
int lsx_set_dft_length(int num_taps, int min, int large);
void lsx_init_fft_cache(void);
void lsx_clear_fft_cache(void);
void lsx_init_fft_cache_f(void);
@ -17,10 +16,10 @@ void lsx_safe_rdft(int len, int type, double * d);
void lsx_safe_cdft(int len, int type, double * d);
void lsx_safe_rdft_f(int len, int type, float * d);
void lsx_safe_cdft_f(int len, int type, float * d);
void _soxr_ordered_convolve(int n, void * not_used, double * a, const double * b);
void _soxr_ordered_convolve_f(int n, void * not_used, float * a, const float * b);
void _soxr_ordered_partial_convolve(int n, double * a, const double * b);
void _soxr_ordered_partial_convolve_f(int n, float * a, const float * b);
void lsx_ordered_convolve(int n, void * not_used, double * a, const double * b);
void lsx_ordered_convolve_f(int n, void * not_used, float * a, const float * b);
void lsx_ordered_partial_convolve(int n, double * a, const double * b);
void lsx_ordered_partial_convolve_f(int n, float * a, const float * b);
double lsx_kaiser_beta(double att, double tr_bw);
double * lsx_make_lpf(int num_taps, double Fc, double beta, double rho,

View File

@ -1 +1,2 @@
set(TARGET_HEADERS "@TARGET_HEADERS@")
set(TARGET_PCS "@TARGET_PCS@")

View File

@ -0,0 +1,11 @@
prefix=${CMAKE_INSTALL_PREFIX}
exec_prefix=${CMAKE_INSTALL_PREFIX}
libdir=${LIB_INSTALL_DIR}
includedir=${INCLUDE_INSTALL_DIR}
Name: lib${LSR}
Description: ${DESCRIPTION_SUMMARY} (with libsamplerate-like bindings)
Requires: libsoxr
Version: ${PROJECT_VERSION}
Libs: -L${LIB_INSTALL_DIR} -l${LSR}
Cflags: -I${INCLUDE_INSTALL_DIR}

View File

@ -0,0 +1,11 @@
prefix=${CMAKE_INSTALL_PREFIX}
exec_prefix=${CMAKE_INSTALL_PREFIX}
libdir=${LIB_INSTALL_DIR}
includedir=${INCLUDE_INSTALL_DIR}
Name: lib${PROJECT_NAME}
Description: ${DESCRIPTION_SUMMARY}
Requires:
Version: ${PROJECT_VERSION}
Libs: -L${LIB_INSTALL_DIR} -l${PROJECT_NAME}
Cflags: -I${INCLUDE_INSTALL_DIR}

View File

@ -1,2 +1 @@
set(TARGET_LIBS "@TARGET_LIBS@")

View File

@ -11,7 +11,7 @@
typedef struct io_t {
float *in,*out; long ilen,olen,idone,odone; int eoi; double oi_ratio;} io_t;
#define SRC_DATA io_t
typedef struct soxr_t SRC_STATE;
typedef struct soxr SRC_STATE;
#define src_callback_t soxr_input_fn_t
#define SRC_ERROR soxr_error_t
#define SRC_SRCTYPE unsigned
@ -62,10 +62,8 @@ soxr_error_t src_process(soxr_t p, io_t * io)
soxr_set_error(p, soxr_set_oi_ratio(p, io->oi_ratio));
{ size_t idone , odone;
if (io->eoi)
io->ilen = -io->ilen; /* hack */
soxr_process(p,
io->in, (size_t)io->ilen, &idone, io->out, (size_t)io->olen, &odone);
soxr_process(p, io->in, (size_t)(io->eoi? ~io->ilen : io->ilen), /* hack */
&idone, io->out, (size_t)io->olen, &odone);
io->idone = (long)idone, io->odone = (long)odone;
return soxr_error(p); }
}

View File

@ -9,6 +9,8 @@
#include "filter.h"
#include "internal.h"
#if defined SOXR_LIB
extern struct {
void * (* forward_setup)(int);
void * (* backward_setup)(int);
@ -35,6 +37,8 @@ extern struct {
#define rdft_multiplier (*RDFT_CB.multiplier)
#define rdft_reorder_back (*RDFT_CB.reorder_back)
#endif
#if RATE_SIMD /* Align for SIMD: */
#include "simd.h"
#if 0 /* Not using this yet. */
@ -606,9 +610,8 @@ static void rate_process(rate_t * p)
static sample_t * rate_input(rate_t * p, sample_t const * samples, size_t n)
{
fifo_t * fifo = &p->stages[0].fifo;
p->samples_in += n;
return fifo_write(fifo, (int)n, samples);
return fifo_write(&p->stages[0].fifo, (int)n, samples);
}
static sample_t const * rate_output(rate_t * p, sample_t * samples, size_t * n)
@ -626,13 +629,12 @@ static void rate_flush(rate_t * p)
#else
uint64_t samples_out = (uint64_t)((double)p->samples_in / p->factor + .5);
#endif
size_t remaining = (size_t)(samples_out - p->samples_out), idone;
size_t remaining = (size_t)(samples_out - p->samples_out);
sample_t * buff = calloc(1024, sizeof(*buff));
if ((int)remaining > 0) {
while ((size_t)fifo_occupancy(fifo) < remaining) {
idone = 1024;
rate_input(p, buff, idone);
rate_input(p, buff, 1024);
rate_process(p);
}
fifo_trim_to(fifo, (int)remaining);

View File

@ -26,18 +26,18 @@
#if defined SOXR_DLL
#if defined soxr_lsr_EXPORTS
#define _ __declspec(dllexport)
#define SOXR __declspec(dllexport)
#else
#define _ __declspec(dllimport)
#define SOXR __declspec(dllimport)
#endif
#else
#define _
#define SOXR
#endif
typedef float SRC_SAMPLE;
#if !defined SOXR_LIB
enum SRC_SRCTYPE{SRC_SINC_BEST_QUALITY,SRC_SINC_MEDIUM_QUALITY,SRC_SINC_FASTEST,
SRC_ZERO_ORDER_HOLD, SRC_LINEAR};
enum SRC_SRCTYPE_e {SRC_SINC_BEST_QUALITY, SRC_SINC_MEDIUM_QUALITY,
SRC_SINC_FASTEST, SRC_ZERO_ORDER_HOLD, SRC_LINEAR};
typedef int SRC_SRCTYPE;
typedef int SRC_ERROR;
typedef long (* src_callback_t)(void *, SRC_SAMPLE * *);
@ -50,28 +50,28 @@ typedef struct SRC_DATA {
double src_ratio;
} SRC_DATA;
#endif
_ SRC_STATE * src_new(SRC_SRCTYPE, int num_channels, SRC_ERROR *);
_ SRC_ERROR src_process (SRC_STATE *, SRC_DATA *);
_ SRC_ERROR src_set_ratio(SRC_STATE *, double);
_ SRC_ERROR src_reset (SRC_STATE *);
_ SRC_ERROR src_error (SRC_STATE *);
_ SRC_STATE * src_delete (SRC_STATE *);
_ SRC_STATE * src_callback_new(
SOXR SRC_STATE * src_new(SRC_SRCTYPE, int num_channels, SRC_ERROR *);
SOXR SRC_ERROR src_process (SRC_STATE *, SRC_DATA *);
SOXR SRC_ERROR src_set_ratio(SRC_STATE *, double);
SOXR SRC_ERROR src_reset (SRC_STATE *);
SOXR SRC_ERROR src_error (SRC_STATE *);
SOXR SRC_STATE * src_delete (SRC_STATE *);
SOXR SRC_STATE * src_callback_new(
src_callback_t, SRC_SRCTYPE, int, SRC_ERROR *, void *);
_ long src_callback_read(
SOXR long src_callback_read(
SRC_STATE *, double src_ratio, long, SRC_SAMPLE *);
_ SRC_ERROR src_simple(SRC_DATA *, SRC_SRCTYPE, int);
_ char const * src_get_name(SRC_SRCTYPE);
_ char const * src_get_description(SRC_SRCTYPE);
_ char const * src_get_version(void);
_ char const * src_strerror(SRC_ERROR);
_ int src_is_valid_ratio(double);
_ void src_short_to_float_array(short const *, float *, int);
_ void src_float_to_short_array(float const *, short *, int);
_ void src_int_to_float_array(int const *, float *, int);
_ void src_float_to_int_array(float const *, int *, int);
SOXR SRC_ERROR src_simple(SRC_DATA *, SRC_SRCTYPE, int);
SOXR char const * src_get_name(SRC_SRCTYPE);
SOXR char const * src_get_description(SRC_SRCTYPE);
SOXR char const * src_get_version(void);
SOXR char const * src_strerror(SRC_ERROR);
SOXR int src_is_valid_ratio(double);
SOXR void src_short_to_float_array(short const *, float *, int);
SOXR void src_float_to_short_array(float const *, short *, int);
SOXR void src_int_to_float_array(int const *, float *, int);
SOXR void src_float_to_int_array(float const *, int *, int);
#undef _
#undef SOXR
#if defined __cplusplus
}
#endif

View File

@ -55,7 +55,7 @@ typedef void (* deinterleave_t)(sample_t * * dest,
typedef size_t (* interleave_t)(soxr_datatype_t data_type, void * * dest,
sample_t const * const * src, size_t, unsigned, unsigned long *);
struct soxr_t {
struct soxr {
unsigned num_channels;
double oi_ratio;
soxr_error_t error;
@ -405,7 +405,7 @@ void soxr_delete(soxr_t p)
soxr_error_t soxr_clear(soxr_t p) /* TODO: this, properly. */
{
if (p) {
struct soxr_t tmp = *p;
struct soxr tmp = *p;
soxr_delete0(p);
memset(p, 0, sizeof(*p));
p->input_fn = tmp.input_fn;
@ -464,9 +464,9 @@ static size_t soxr_output_1ch(soxr_t p, unsigned i, soxr_buf_t dest, size_t len,
resampler_process(p->resamplers[i]);
src = resampler_output(p->resamplers[i], NULL, &len);
if (separated)
p->clips += (p->interleave)(p->io_spec.otype, &dest, &src,
p->clips += (p->interleave)(p->io_spec.otype, &dest, &src,
len, 1, (p->io_spec.flags & SOXR_NO_DITHER)? 0 : &p->seed);
else p->channel_ptrs[i] = (void /* const */ *)src;;
else p->channel_ptrs[i] = (void /* const */ *)src;
return len;
}
@ -502,6 +502,7 @@ size_t soxr_output(soxr_t p, void * out, size_t len0)
{
size_t odone, odone0 = 0, olen = len0, osize, idone;
void const * in = out; /* Set to !=0, so that caller may leave unset. */
bool was_flushing;
if (!p || p->error) return 0;
if (!out && len0) {p->error = "null output buffer pointer"; return 0;}
@ -516,10 +517,11 @@ size_t soxr_output(soxr_t p, void * out, size_t len0)
out = (char *)out + osize * odone;
olen -= odone;
idone = p->input_fn(p->input_fn_state, &in, (size_t)ceil((double)olen /p->oi_ratio));
was_flushing = p->flushing;
if (!in)
p->error = "input function reported failure";
else soxr_input(p, in, idone);
} while (in && (odone || idone));
} while (odone || idone || (!was_flushing && p->flushing));
return odone0;
}
@ -561,7 +563,7 @@ soxr_error_t soxr_process(soxr_t p,
flush_requested = true, ilen = ilen0 = 0;
else {
if ((ptrdiff_t)ilen0 < 0)
flush_requested = true, ilen0 = 1 + ~ilen0;
flush_requested = true, ilen0 = ~ilen0;
if (1 || flush_requested)
ilen = soxr_i_for_o(p, olen, ilen0);
else
@ -592,7 +594,7 @@ soxr_error_t soxr_process(soxr_t p,
idone = ilen;
}
else {
idone = soxr_input (p, in , ilen);
idone = ilen? soxr_input (p, in , ilen) : 0;
odone = soxr_output(p, out, olen);
}
if (idone0) *idone0 = idone;
@ -621,8 +623,7 @@ soxr_error_t soxr_oneshot(
&error, io_spec, q_spec, runtime_spec);
}
if (!error) {
ilen = 1 + ~ilen;
error = soxr_process(resampler, in, ilen, idone, out, olen, odone);
error = soxr_process(resampler, in, ~ilen, idone, out, olen, odone);
soxr_delete(resampler);
}
return error;

View File

@ -32,17 +32,17 @@
#if defined SOXR_DLL
#if defined soxr_EXPORTS
#define _ __declspec(dllexport)
#define SOXR __declspec(dllexport)
#else
#define _ __declspec(dllimport)
#define SOXR __declspec(dllimport)
#endif
#else
#define _
#define SOXR
#endif
typedef struct soxr_io_spec_t soxr_io_spec_t;
typedef struct soxr_quality_spec_t soxr_quality_spec_t;
typedef struct soxr_runtime_spec_t soxr_runtime_spec_t;
typedef struct soxr_io_spec soxr_io_spec_t;
typedef struct soxr_quality_spec soxr_quality_spec_t;
typedef struct soxr_runtime_spec soxr_runtime_spec_t;
@ -60,8 +60,8 @@ input or output (e.g. ilen, olen). */
/* --------------------------- Type declarations ---------------------------- */
typedef struct soxr_t * soxr_t; /* A resampler for 1 or more channels. */
typedef char const * soxr_error_t; /* 0:no-error; non-0:error. */
typedef struct soxr * soxr_t; /* A resampler for 1 or more channels. */
typedef char const * soxr_error_t; /* 0:no-error; non-0:error. */
typedef void * soxr_buf_t; /* 1 buffer of channel-interleaved samples. */
typedef void const * soxr_cbuf_t; /* Ditto; read-only. */
@ -78,7 +78,7 @@ typedef void * soxr_out_t; /* Either a soxr_buf_t or soxr_bufs_t,
/* --------------------------- API main functions --------------------------- */
_ char const * soxr_version(void); /* Query library version: "x.y.z". */
SOXR char const * soxr_version(void); /* Query library version: "x.y.z". */
#define soxr_strerror(e) /* Soxr counterpart to strerror. */ \
((e)?(e):"no error")
@ -86,7 +86,7 @@ _ char const * soxr_version(void); /* Query library version: "x.y.z". */
/* Create a stream resampler: */
_ soxr_t soxr_create(
SOXR soxr_t soxr_create(
double input_rate, /* Input sample-rate. */
double output_rate, /* Output sample-rate. */
unsigned num_channels, /* Number of channels to be used. */
@ -101,16 +101,20 @@ _ soxr_t soxr_create(
/* If not using an app-supplied input function, after creating a stream
* resampler, repeatedly call: */
_ soxr_error_t soxr_process(
SOXR soxr_error_t soxr_process(
soxr_t resampler, /* As returned by soxr_create. */
/* Input (to be resampled): */
soxr_in_t in, /* Interleaved or split input buffer(s). */
soxr_in_t in, /* Input buffer(s); may be NULL (see below). */
size_t ilen, /* Input buf. length (samples per channel). */
size_t * idone, /* To return actual # samples used (<= ilen). */
/* Output (resampled): */
soxr_out_t out, /* Interleaved or split output buffer(s).*/
soxr_out_t out, /* Output buffer(s).*/
size_t olen, /* Output buf. length (samples per channel). */
size_t * odone); /* To return actual # samples out (<= olen). */
size_t * odone); /* To return actual # samples out (<= olen).
Note that no special meaning is associated with ilen or olen equal to
zero. End-of-input (i.e. no data is available nor shall be available)
may be indicated by seting in to zero. */
@ -118,7 +122,7 @@ _ soxr_error_t soxr_process(
typedef size_t /* data_len */
(* soxr_input_fn_t)( /* Supply data to be resampled. */
void * input_fn_state, /* As given to soxr_set_input_fn. */
void * input_fn_state, /* As given to soxr_set_input_fn (below). */
soxr_in_t * data, /* Returned data; see below. N.B. ptr to ptr(s)*/
size_t requested_len); /* Samples per channel, >= returned data_len.
@ -133,14 +137,14 @@ typedef size_t /* data_len */
/* and be registered with a previously created stream resampler using: */
_ soxr_error_t soxr_set_input_fn(/* Set (or reset) an input function.*/
SOXR soxr_error_t soxr_set_input_fn(/* Set (or reset) an input function.*/
soxr_t resampler, /* As returned by soxr_create. */
soxr_input_fn_t, /* Function to supply data to be resampled.*/
void * input_fn_state); /* If needed by the input function. */
/* then repeatedly call: */
_ size_t /*odone*/ soxr_output(/* Resample and output a portion of the signal.*/
SOXR size_t /*odone*/ soxr_output(/* Resample and output a block of data.*/
soxr_t resampler, /* As returned by soxr_create. */
soxr_out_t data, /* App-supplied buffer(s) for resampled data.*/
size_t olen); /* Amount of data to output; >= odone. */
@ -149,20 +153,20 @@ _ size_t /*odone*/ soxr_output(/* Resample and output a portion of the signal.*/
/* Common stream resampler operations: */
_ soxr_error_t soxr_error(soxr_t); /* Query error status. */
_ size_t * soxr_num_clips(soxr_t); /* Query int. clip counter (for R/W). */
_ double soxr_delay(soxr_t); /* Query current delay in output samples.*/
_ char const * soxr_engine(soxr_t p);/* Query resampling engine name. */
SOXR soxr_error_t soxr_error(soxr_t); /* Query error status. */
SOXR size_t * soxr_num_clips(soxr_t); /* Query int. clip counter (for R/W). */
SOXR double soxr_delay(soxr_t); /* Query current delay in output samples.*/
SOXR char const * soxr_engine(soxr_t p);/* Query resampling engine name. */
_ soxr_error_t soxr_clear(soxr_t); /* Ready for fresh signal, same config. */
_ void soxr_delete(soxr_t); /* Free resources. */
SOXR soxr_error_t soxr_clear(soxr_t); /* Ready for fresh signal, same config. */
SOXR void soxr_delete(soxr_t); /* Free resources. */
/* `Short-cut', single call to resample a (probably short) signal held entirely
* in memory. See soxr_create and soxr_process above for parameter details. */
_ soxr_error_t soxr_oneshot(
SOXR soxr_error_t soxr_oneshot(
double input_rate,
double output_rate,
unsigned num_channels,
@ -193,7 +197,7 @@ typedef enum { /* Datatypes supported for I/O to/from the resampler: */
struct soxr_io_spec_t { /* Typically */
struct soxr_io_spec { /* Typically */
soxr_datatype_t itype; /* Input datatype. SOXR_FLOAT32_I */
soxr_datatype_t otype; /* Output datatype. SOXR_FLOAT32_I */
double scale; /* Linear gain to apply during resampling. 1 */
@ -206,7 +210,7 @@ struct soxr_io_spec_t { /* Typically */
struct soxr_quality_spec_t { /* Typically */
struct soxr_quality_spec { /* Typically */
double bits; /* Required bit-accuracy (pass + stop). 20 */
double phase; /* Linear/minimum etc. phase. [0,100] 50 */
double bw_pc; /* Pass-band % (0dB pt.) to preserve. 91.3 */
@ -225,7 +229,7 @@ struct soxr_quality_spec_t { /* Typically */
struct soxr_runtime_spec_t { /* Typically */
struct soxr_runtime_spec { /* Typically */
unsigned log2_min_dft_size;/* For DFT efficiency. [8,15] 10 */
unsigned log2_large_dft_size;/* For DFT efficiency. [16,20] 17 */
unsigned coef_size_kbytes; /* For SOXR_COEF_INTERP_AUTO (below). 400 */
@ -249,7 +253,7 @@ struct soxr_runtime_spec_t { /* Typically */
* parameters, with other parameters being given default values. The default
* values may then be overridden, directly in the structure, if needed. */
_ soxr_quality_spec_t soxr_quality_spec(
SOXR soxr_quality_spec_t soxr_quality_spec(
unsigned long recipe, /* Per the #defines immediately below. */
unsigned long flags); /* As soxr_quality_spec_t.flags. */
@ -278,12 +282,12 @@ _ soxr_quality_spec_t soxr_quality_spec(
_ soxr_runtime_spec_t soxr_runtime_spec(
SOXR soxr_runtime_spec_t soxr_runtime_spec(
unsigned num_threads);
_ soxr_io_spec_t soxr_io_spec(
SOXR soxr_io_spec_t soxr_io_spec(
soxr_datatype_t itype,
soxr_datatype_t otype);
@ -291,14 +295,14 @@ _ soxr_io_spec_t soxr_io_spec(
/* --------------------------- Internal use only ---------------------------- */
_ soxr_error_t soxr_set_error(soxr_t, soxr_error_t);
_ soxr_error_t soxr_set_num_channels(soxr_t, unsigned);
_ soxr_error_t soxr_set_oi_ratio(soxr_t, double);
_ soxr_error_t soxr_set_pitch(soxr_t, long);
SOXR soxr_error_t soxr_set_error(soxr_t, soxr_error_t);
SOXR soxr_error_t soxr_set_num_channels(soxr_t, unsigned);
SOXR soxr_error_t soxr_set_oi_ratio(soxr_t, double);
SOXR soxr_error_t soxr_set_pitch(soxr_t, long);
#undef _
#undef SOXR
#if defined __cplusplus
}

View File

@ -1,7 +1,7 @@
# SoX Resampler Library Copyright (c) 2007-12 robs@users.sourceforge.net
# Licence for this file: LGPL v2.1 See LICENCE for details.
add_definitions (${PROJECT_DEFS})
add_definitions (${PROJECT_C_FLAGS})
link_libraries (${PROJECT_NAME})
file (GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.c)
@ -20,13 +20,13 @@ math (EXPR base_rate "${sweep_to_freq} + ${sweep_to_freq}")
macro (add_vector r)
set (output ${CMAKE_CURRENT_BINARY_DIR}/ref-${r}.s32)
add_custom_command (OUTPUT ${output} DEPENDS vector-gen ${CMAKE_CURRENT_LIST_FILE}
COMMAND vector-gen ${r} ${leader} ${len} ${sweep_to_freq} ${output})
COMMAND vector-gen ${r} ${leader} ${len} ${sweep_to_freq} 1 ${output})
set (vectors ${output} ${vectors})
endmacro ()
macro (add_cmp_test from to bits)
set (name ${bits}-bit-perfect-${from}-${to})
add_test (NAME ${name} COMMAND ${CMAKE_COMMAND} -Dbits=${bits} -Dbin=${bin} -Dobin=${obin} -Dleader=${leader} -Dto=${to}
add_test (NAME ${name} COMMAND ${CMAKE_COMMAND} -Dbits=${bits} -DBIN=${BIN} -DEXAMPLES_BIN=${EXAMPLES_BIN} -Dleader=${leader} -Dto=${to}
-Dfrom=${from} -Dlen=${len} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmp-test.cmake)
add_vector (${from})
add_vector (${to})
@ -42,8 +42,8 @@ endif ()
foreach (b ${test_bits})
foreach (r 96000 65537)
add_cmp_test(${base_rate} ${r} ${b})
add_cmp_test(${r} ${base_rate} ${b})
add_cmp_test (${base_rate} ${r} ${b})
add_cmp_test (${r} ${base_rate} ${b})
endforeach ()
endforeach ()

View File

@ -1 +1 @@
A few tests on the pass-band performance; not the comprehensive test suite.
A few tests on the pass-band performance; not a comprehensive test suite.

View File

@ -2,12 +2,12 @@
# Licence for this file: LGPL v2.1 See LICENCE for details.
if (${bits} STREQUAL 24)
set (quality A0045)
set (quality 45)
else ()
set (quality A0044)
set (quality 44)
endif ()
execute_process(COMMAND ${obin}3b-options-with-input-fn ${from} ${to} 1 2 2 ${quality}
execute_process(COMMAND ${EXAMPLES_BIN}3b-options-with-input-fn ${from} ${to} 1 2 2 ${quality} a
INPUT_FILE ref-${from}.s32
OUTPUT_FILE ${from}-${to}.s32
ERROR_VARIABLE test_error
@ -19,7 +19,7 @@ if (test_result)
#message (STATUS ${test_error})
endif ()
execute_process(COMMAND ${bin}vector-cmp ref-${to}.s32 ${from}-${to}.s32 ${to} ${leader} ${len} ${bits} 98
execute_process(COMMAND ${BIN}vector-cmp ref-${to}.s32 ${from}-${to}.s32 ${to} ${leader} ${len} ${bits} 98
OUTPUT_VARIABLE test_output
RESULT_VARIABLE test_result)

View File

@ -0,0 +1,21 @@
#!/bin/bash
# SoX Resampler Library Copyright (c) 2007-12 robs@users.sourceforge.net
# Licence for this file: LGPL v2.1 See LICENCE for details.
len=8
#vg="valgrind --leak-check=full --show-reachable=yes"
ir=96000
or=44100
for i in 1 2; do
prev=""
sox -r $ir -n 0.f32 synth $len sin 0+`expr $ir / 2`
for f in `find ../examples -type f -executable -name "[2-4]*"`; do
$vg $f $ir $or < 0.f32 > $f.f32
test x$prev != x && cmp $f.f32 $prev
prev=$f.f32
done
or=96000
ir=44100
done
rm *.f32

View File

@ -8,9 +8,7 @@ len=8
f=3k
f=0+48k
g=48k+0
ex=../examples/4-split-channels
#vg="valgrind --leak-check=full --show-reachable=yes "
ex="$vg../examples/3b-options-with-input-fn"
ex=../examples/3b-options-with-input-fn
types=(f32 f64 s32 s16)

View File

@ -0,0 +1,13 @@
#!/bin/sh
# SoX Resampler Library Copyright (c) 2007-12 robs@users.sourceforge.net
# Licence for this file: LGPL v2.1 See LICENCE for details.
# Warning: the intermediate signal (piped) is 3.2 Gbytes so may slug the
# system somewhat.
ex=../examples/3b-options-with-input-fn
q=6
./vector-gen 1000 0 8 500 .9375 1.s32
$ex 1 1e5 1 2 1 $q < 1.s32 | $ex 1e5 1 1 1 2 $q > 2.s32
/usr/bin/sox -M -r 1k 1.s32 -r 1k 2.s32 -n spectrogram -hwk -z180 -o 2.png
display 2.png &

View File

@ -11,7 +11,7 @@
#include <quadmath.h>
#endif
#include "../examples/util.h"
#include "../examples/examples-common.h"
#if QUAD
#define modf modfq
@ -31,23 +31,26 @@ int main(int i, char const * argv[])
real rate = atof(argv[1]), /* Rate for this vector */
lead_in_len = atof(argv[2]), /* Lead-in length in seconds */
len = atof(argv[3]), /* Sweep length (excl. lead_in_len) */
sweep_to_freq = atof(argv[4]),
sweep_to_freq = atof(argv[4]), /* Sweep from DC to this freq. */
multiplier = atof(argv[5]), /* For headroom */
f1 = -sweep_to_freq / len * lead_in_len, f2 = sweep_to_freq,
n1 = rate * -lead_in_len, n2 = rate * len,
m = (f2 - f1) / (n2 - n1) / 2, dummy;
FILE * file = fopen(argv[5], "wb");
FILE * file = fopen(argv[6], "wb");
i = (int)n1;
if (!file || i != n1)
exit(1);
for (; i < (int)(n2 + .5); ++i) {
double d1 = sin(2 * M_PI * modf(i * m * i / rate, &dummy));
double d1 = multiplier * sin(2 * M_PI * modf(i * m * i / rate, &dummy));
double d = i < 0? d1 * (1 - cos(M_PI * (i + n1) / n1)) * .5 : d1;
#if QUAD
fwrite(&d, sizeof(d), 1, file);
size_t actual = fwrite(&d, sizeof(d), 1, file);
#else
int32_t out = rint32(d * (32768. * 65536 - 1));
fwrite(&out, sizeof(out), 1, file);
size_t actual = fwrite(&out, sizeof(out), 1, file);
#endif
if (actual != 1)
return 1;
}
return 0;
}