mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-25 23:25:41 +00:00
dep: Remove libsamplerate
This commit is contained in:
parent
68b5dd869c
commit
1625908847
|
@ -13,9 +13,6 @@ add_subdirectory(simpleini)
|
|||
add_subdirectory(vulkan)
|
||||
add_subdirectory(soundtouch)
|
||||
|
||||
set(LIBSAMPLERATE_ENABLE_SINC_BEST_CONVERTER OFF)
|
||||
add_subdirectory(libsamplerate)
|
||||
|
||||
add_subdirectory(tinyxml2)
|
||||
add_subdirectory(cubeb)
|
||||
add_subdirectory(googletest)
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Erik de Castro Lopo <erikd@mega-nerd.com>
|
|
@ -1,110 +0,0 @@
|
|||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
# Policies
|
||||
|
||||
# Include file check macros honor CMAKE_REQUIRED_LIBRARIES, CMake >= 3.12
|
||||
if(POLICY CMP0075)
|
||||
cmake_policy(SET CMP0075 NEW)
|
||||
endif()
|
||||
|
||||
# MSVC runtime library flags are selected by an abstraction, CMake >= 3.15
|
||||
# This policy still need to be set even with cmake_minimum_required() command above.
|
||||
if(POLICY CMP0091)
|
||||
if(DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
|
||||
cmake_policy(SET CMP0091 NEW)
|
||||
else()
|
||||
cmake_policy(SET CMP0091 OLD)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
project(libsamplerate VERSION 0.1.9 LANGUAGES C)
|
||||
|
||||
# Configuration
|
||||
|
||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
set(IS_ROOT_PROJECT ON)
|
||||
else()
|
||||
set(IS_ROOT_PROJECT OFF)
|
||||
endif()
|
||||
|
||||
option(LIBSAMPLERATE_EXAMPLES "Enable to generate examples" ${IS_ROOT_PROJECT})
|
||||
option(LIBSAMPLERATE_INSTALL "Enable to add install directives" ${IS_ROOT_PROJECT})
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(CMAKE_C_STANDARD_REQUIRED TRUE)
|
||||
|
||||
include(TestBigEndian)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckIncludeFile)
|
||||
include(CheckLibraryExists)
|
||||
include(CheckSymbolExists)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
if(DEFINED LIBSAMPLERATE_TESTS)
|
||||
message(DEPRECATION "LIBSAMPLERATE_TESTS option deprecated, use BUILD_TESTING option instead.")
|
||||
set(BUILD_TESTING ${LIBSAMPLERATE_TESTS})
|
||||
endif()
|
||||
include(CTest)
|
||||
|
||||
add_definitions(-DHAVE_CONFIG_H)
|
||||
include_directories(${PROJECT_BINARY_DIR})
|
||||
if(MSVC)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
if(NOT WIN32)
|
||||
find_library(MATH_LIBRARY m)
|
||||
if(MATH_LIBRARY)
|
||||
set(LIBM_REQUIRED 1)
|
||||
if(LIBM_REQUIRED)
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES m)
|
||||
if(LIBM_REQUIRED)
|
||||
link_libraries(${MATH_LIBRARY})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
option(LIBSAMPLERATE_ENABLE_SANITIZERS "Enable ASAN and UBSAN" OFF)
|
||||
|
||||
if(LIBSAMPLERATE_ENABLE_SANITIZERS)
|
||||
# Use ASAN and UBSAN, make it fail on any error, improve stack traces
|
||||
set(sanitizer_flags -fsanitize=address,undefined -fno-sanitize-recover=all -fno-omit-frame-pointer)
|
||||
|
||||
add_compile_options(${sanitizer_flags})
|
||||
string(REPLACE ";" " " sanitizer_flags "${sanitizer_flags}")
|
||||
string(APPEND CMAKE_EXE_LINKER_FLAGS " ${sanitizer_flags}")
|
||||
string(APPEND CMAKE_MODULE_LINKER_FLAGS " ${sanitizer_flags}")
|
||||
string(APPEND CMAKE_SHARED_LINKER_FLAGS " ${sanitizer_flags}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
test_big_endian(CPU_IS_BIG_ENDIAN)
|
||||
if(CPU_IS_BIG_ENDIAN)
|
||||
set(CPU_IS_LITTLE_ENDIAN 0)
|
||||
else()
|
||||
set(CPU_IS_LITTLE_ENDIAN 1)
|
||||
endif()
|
||||
|
||||
check_include_file(stdbool.h HAVE_STDBOOL_H)
|
||||
check_include_file(unistd.h HAVE_UNISTD_H)
|
||||
|
||||
# SampleRate library
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
configure_file(config.h.cmake config.h)
|
||||
|
||||
# Packaging support
|
||||
|
||||
# See https://cmake.org/cmake/help/v3.12/release/3.12.html#cpack
|
||||
if(CMAKE_VERSION VERSION_LESS 3.12)
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
|
||||
endif()
|
||||
|
||||
include(CPack)
|
|
@ -1,25 +0,0 @@
|
|||
Copyright (c) 2012-2016, Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@ -1,50 +0,0 @@
|
|||
Unreleased
|
||||
|
||||
* CMake:
|
||||
* Fix CMake generated shared library ABI compliance with Autotools build
|
||||
* Documentation:
|
||||
* Move site to new URL: http://libsndfile.github.io/libsamplerate/
|
||||
* Convert documentation pages from HTML to Markdown
|
||||
* Use GitHub's Jekyll static site generator to generate static HTML pages
|
||||
for site
|
||||
|
||||
Version 0.1.9 (2016-09-23)
|
||||
* Relicense under 2 clause BSD license.
|
||||
* Minor bug fixes and upates.
|
||||
|
||||
Version 0.1.8 (2011-08-15)
|
||||
* Minor bug fixes and upates.
|
||||
|
||||
Version 0.1.7 (2009-02-14)
|
||||
* Fix a segfault which occurs when memcpy is passed a bad length parameter.
|
||||
* Fix compilation under MSVC.
|
||||
|
||||
Version 0.1.6 (2009-01-27)
|
||||
* Minor bug fix in test suite (account for rounding error on x86_64).
|
||||
|
||||
Version 0.1.5 (2009-01-11)
|
||||
* Optimisation resulting dramatic throughput improvements.
|
||||
|
||||
Version 0.1.4 (2008-07-02)
|
||||
* Fix bug which causes a segfault with extremely low conversion ratios.
|
||||
|
||||
Version 0.1.3 (2008-03-23)
|
||||
* Huge improvement to the quality of conversion with the
|
||||
SRC_SINC_MEDIUM_QUALITY and SRC_SINC_BEST_QUALITY converters.
|
||||
* Minor bug fixes.
|
||||
|
||||
Version 0.1.2 (2004-09-12)
|
||||
* Fixed where callback based API wasn't being reset properly.
|
||||
* Minor bug fixes.
|
||||
|
||||
Version 0.1.1 (2004-07-17)
|
||||
* Fixed bug in callback based API.
|
||||
* Fixed a bug brought to light by aggressive optimisations of gcc-3.4.
|
||||
* Minor bug fixes.
|
||||
|
||||
Version 0.1.0 (2004-03-14)
|
||||
* Added callback based API.
|
||||
* Added a pair of functions for doing short to float and float to short
|
||||
conversions on an arrays of data.
|
||||
* Many minor bug fixes.
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
![Logo](docs/SRC.png)
|
||||
|
||||
This is libsamplerate, `0.1.9`.
|
||||
|
||||
libsamplerate (also known as Secret Rabbit Code) is a library for performing sample rate conversion of audio data.
|
||||
|
||||
* The [`src/`](https://github.com/libsndfile/libsamplerate/tree/master/src) directory contains the source code for library itself.
|
||||
* The [`docs/`](https://github.com/libsndfile/libsamplerate/tree/master/docs) directory contains the libsamplerate documentation.
|
||||
* The [`examples/`](https://github.com/libsndfile/libsamplerate/tree/master/examples) directory contains examples of how to write code using libsamplerate.
|
||||
* The [`tests/`](https://github.com/libsndfile/libsamplerate/tree/master/tests) directory contains programs which link against libsamplerate and test its functionality.
|
||||
* The [`Win32/`](https://github.com/libsndfile/libsamplerate/tree/master/Win32) directory contains files and documentation to allow libsamplerate to compile under Win32 with the Microsoft Visual C++ compiler.
|
||||
|
||||
Additional references:
|
||||
|
||||
* [Official website](http://libsndfile.github.io/libsamplerate//)
|
||||
* [GitHub](https://github.com/libsndfile/libsamplerate)
|
||||
|
||||
---
|
||||
|
||||
## Build Status
|
||||
|
||||
| Branch | Status |
|
||||
|----------------|-------------------------------------------------------------------------------------------------------------------|
|
||||
| `master` | ![Build](https://github.com/libsndfile/libsamplerate/workflows/Build/badge.svg) |
|
||||
|
||||
Branches [actively built](https://github.com/libsndfile/libsamplerate/actions) by GitHub Actions.
|
||||
|
||||
---
|
||||
|
||||
## Win32
|
||||
|
||||
There are detailed instructions for building libsamplerate on Win32 in the file [`docs/win32.md`](https://github.com/libsndfile/libsamplerate/tree/master/docs/win32.md).
|
||||
|
||||
## macOS
|
||||
|
||||
Building on macOS should be the same as building it on any other Unix platform.
|
||||
|
||||
## Other Platforms
|
||||
|
||||
To compile libsamplerate on platforms which have a Bourne compatible shell, an ANSI C compiler and a make utility should require no more that the following three commands:
|
||||
```bash
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
```
|
||||
|
||||
## CMake
|
||||
|
||||
There is a new [CMake](https://cmake.org/download/)-based build system available:
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
```
|
||||
|
||||
* Use `cmake -DCMAKE_BUILD_TYPE=Release ..` to make a release build.
|
||||
* Use `cmake -DBUILD_SHARED_LIBS=ON ..` to build a shared library.
|
||||
|
||||
## Contacts
|
||||
|
||||
libsamplerate was written by [Erik de Castro Lopo](mailto:erikd@mega-nerd.com).
|
|
@ -1,81 +0,0 @@
|
|||
macro(CLIP_MODE)
|
||||
|
||||
set(CLIP_MODE_POSITIVE_MESSAGE "Target processor clips on positive float to int conversion")
|
||||
set(CLIP_MODE_NEGATIVE_MESSAGE "Target processor clips on negative float to int conversion")
|
||||
|
||||
message(STATUS "Checking processor clipping capabilities...")
|
||||
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
|
||||
set(CLIP_MSG "disabled")
|
||||
set(CPU_CLIPS_POSITIVE FALSE CACHE BOOL ${CLIP_MODE_POSITIVE_MESSAGE})
|
||||
set(CPU_CLIPS_NEGATIVE FALSE CACHE BOOL ${CLIP_MODE_NEGATIVE_MESSAGE})
|
||||
|
||||
else()
|
||||
include(CheckCSourceRuns)
|
||||
include(CMakePushCheckState)
|
||||
cmake_push_check_state(RESET)
|
||||
|
||||
if(MATH_LIBRARY)
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES ${MATH_LIBRARY})
|
||||
endif()
|
||||
|
||||
check_c_source_runs(
|
||||
"
|
||||
#include <math.h>
|
||||
int main (void)
|
||||
{ double fval ;
|
||||
int k, ival ;
|
||||
|
||||
fval = 1.0 * 0x7FFFFFFF ;
|
||||
for (k = 0 ; k < 100 ; k++)
|
||||
{ ival = (lrint (fval)) >> 24 ;
|
||||
if (ival != 127)
|
||||
return 1 ;
|
||||
|
||||
fval *= 1.2499999 ;
|
||||
} ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
"
|
||||
CPU_CLIPS_POSITIVE)
|
||||
|
||||
check_c_source_runs(
|
||||
"
|
||||
#include <math.h>
|
||||
int main (void)
|
||||
{ double fval ;
|
||||
int k, ival ;
|
||||
|
||||
fval = -8.0 * 0x10000000 ;
|
||||
for (k = 0 ; k < 100 ; k++)
|
||||
{ ival = (lrint (fval)) >> 24 ;
|
||||
if (ival != -128)
|
||||
return 1 ;
|
||||
|
||||
fval *= 1.2499999 ;
|
||||
} ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
"
|
||||
CPU_CLIPS_NEGATIVE)
|
||||
|
||||
cmake_pop_check_state()
|
||||
|
||||
if(CPU_CLIPS_POSITIVE AND CPU_CLIPS_NEGATIVE)
|
||||
set(CLIP_MSG "both")
|
||||
elseif(CPU_CLIPS_POSITIVE)
|
||||
set(CLIP_MSG "positive")
|
||||
elseif(CPU_CLIPS_NEGATIVE)
|
||||
set(CLIP_MSG "negative")
|
||||
else()
|
||||
set(CLIP_MSG "none")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
message(STATUS "Checking processor clipping capabilities... ${CLIP_MSG}")
|
||||
|
||||
endmacro()
|
|
@ -1,88 +0,0 @@
|
|||
# Adapted from: https://github.com/wjakob/layerlab/blob/master/cmake/FindFFTW.cmake
|
||||
|
||||
# Copyright (c) 2015, Wenzel Jakob
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice, this
|
||||
# list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# - Find FFTW3
|
||||
# Find the native FFTW3 includes and library
|
||||
#
|
||||
# Cache variables:
|
||||
#
|
||||
# FFTW3_INCLUDE_DIR - where to find fftw3.h
|
||||
# FFTW3_LIBRARY - Path to FFTW3 libray.
|
||||
# FFTW3_ROOT - Root of FFTW3 installation.
|
||||
#
|
||||
# User variables:
|
||||
#
|
||||
# FFTW3_INCLUDE_DIRS - where to find fftw3.h
|
||||
# FFTW3_LIBRARIES - List of libraries when using FFTW3.
|
||||
# FFTW3_FOUND - True if FFTW3 found.
|
||||
|
||||
|
||||
if(FFTW3_INCLUDE_DIR)
|
||||
# Already in cache, be silent
|
||||
set(FFTW3_FIND_QUIETLY TRUE)
|
||||
endif(FFTW3_INCLUDE_DIR)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_FFTW3 QUIET fftw3)
|
||||
|
||||
set(FFTW3_VERSION ${PC_FFTW3_VERSION})
|
||||
|
||||
find_path(FFTW3_INCLUDE_DIR fftw3.h
|
||||
HINTS
|
||||
${PC_FFTW3_INCLUDEDIR}
|
||||
${PC_FFTW3_INCLUDE_DIRS}
|
||||
${FFTW3_ROOT})
|
||||
|
||||
find_library(FFTW3_LIBRARY NAMES fftw3
|
||||
HINTS
|
||||
${PC_FFTW3_LIBDIR}
|
||||
${PC_FFTW3_LIBRARY_DIRS}
|
||||
${FFTW3_ROOT})
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set FFTW3_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(FFTW3
|
||||
REQUIRED_VARS
|
||||
FFTW3_LIBRARY
|
||||
FFTW3_INCLUDE_DIR
|
||||
VERSION_VAR
|
||||
FFTW3_VERSION)
|
||||
|
||||
if(FFTW3_FOUND)
|
||||
set(FFTW3_LIBRARIES ${FFTW3_LIBRARY})
|
||||
set(FFTW3_INCLUDE_DIRS ${FFTW3_INCLUDE_DIR})
|
||||
|
||||
if(NOT TARGET FFTW3::fftw3)
|
||||
add_library(FFTW3::fftw3 UNKNOWN IMPORTED)
|
||||
set_target_properties(FFTW3::fftw3 PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${FFTW3_INCLUDE_DIR}"
|
||||
IMPORTED_LOCATION "${FFTW3_LIBRARY}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
mark_as_advanced(FFTW3_LIBRARY FFTW3_INCLUDE_DIR)
|
|
@ -1,63 +0,0 @@
|
|||
# - Find FLAC
|
||||
# Find the native FLAC includes and libraries
|
||||
#
|
||||
# FLAC_INCLUDE_DIRS - where to find FLAC headers.
|
||||
# FLAC_LIBRARIES - List of libraries when using libFLAC.
|
||||
# FLAC_FOUND - True if libFLAC found.
|
||||
# FLAC_DEFINITIONS - FLAC compile definitons
|
||||
|
||||
if(FLAC_INCLUDE_DIR)
|
||||
# Already in cache, be silent
|
||||
set(FLAC_FIND_QUIETLY TRUE)
|
||||
endif()
|
||||
|
||||
find_package(Ogg QUIET)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_FLAC QUIET flac)
|
||||
|
||||
set(FLAC_VERSION ${PC_FLAC_VERSION})
|
||||
|
||||
find_path(FLAC_INCLUDE_DIR FLAC/stream_decoder.h
|
||||
HINTS
|
||||
${PC_FLAC_INCLUDEDIR}
|
||||
${PC_FLAC_INCLUDE_DIRS}
|
||||
${FLAC_ROOT})
|
||||
|
||||
# MSVC built libraries can name them *_static, which is good as it
|
||||
# distinguishes import libraries from static libraries with the same extension.
|
||||
find_library(FLAC_LIBRARY
|
||||
NAMES
|
||||
FLAC
|
||||
libFLAC
|
||||
libFLAC_dynamic
|
||||
libFLAC_static
|
||||
HINTS
|
||||
${PC_FLAC_LIBDIR}
|
||||
${PC_FLAC_LIBRARY_DIRS}
|
||||
${FLAC_ROOT})
|
||||
|
||||
# Handle the QUIETLY and REQUIRED arguments and set FLAC_FOUND to TRUE if
|
||||
# all listed variables are TRUE.
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(FLAC
|
||||
REQUIRED_VARS
|
||||
FLAC_LIBRARY
|
||||
FLAC_INCLUDE_DIR
|
||||
Ogg_FOUND
|
||||
VERSION_VAR
|
||||
FLAC_VERSION)
|
||||
|
||||
if(FLAC_FOUND)
|
||||
set(FLAC_INCLUDE_DIRS ${FLAC_INCLUDE_DIR} ${Ogg_INCLUDE_DIRS})
|
||||
set(FLAC_LIBRARIES ${FLAC_LIBRARY} ${Ogg_LIBRARIES})
|
||||
if(NOT TARGET FLAC::FLAC)
|
||||
add_library(FLAC::FLAC UNKNOWN IMPORTED)
|
||||
set_target_properties(FLAC::FLAC PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${FLAC_INCLUDE_DIR}"
|
||||
IMPORTED_LOCATION "${FLAC_LIBRARY}"
|
||||
INTERFACE_LINK_LIBRARIES Ogg::ogg)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
mark_as_advanced(FLAC_INCLUDE_DIR FLAC_LIBRARY)
|
|
@ -1,57 +0,0 @@
|
|||
# - Find ogg
|
||||
# Find the native ogg includes and libraries
|
||||
#
|
||||
# Ogg_INCLUDE_DIRS - where to find ogg.h, etc.
|
||||
# Ogg_LIBRARIES - List of libraries when using ogg.
|
||||
# Ogg_FOUND - True if ogg found.
|
||||
|
||||
if(Ogg_INCLUDE_DIR)
|
||||
# Already in cache, be silent
|
||||
set(Ogg_FIND_QUIETLY TRUE)
|
||||
endif()
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_Ogg QUIET ogg)
|
||||
|
||||
set(Ogg_VERSION ${PC_Ogg_VERSION})
|
||||
|
||||
find_path(Ogg_INCLUDE_DIR ogg/ogg.h
|
||||
HINTS
|
||||
${PC_Ogg_INCLUDEDIR}
|
||||
${PC_Ogg_INCLUDE_DIRS}
|
||||
${Ogg_ROOT})
|
||||
# MSVC built ogg may be named ogg_static.
|
||||
# The provided project files name the library with the lib prefix.
|
||||
find_library(Ogg_LIBRARY
|
||||
NAMES
|
||||
ogg
|
||||
ogg_static
|
||||
libogg
|
||||
libogg_static
|
||||
HINTS
|
||||
${PC_Ogg_LIBDIR}
|
||||
${PC_Ogg_LIBRARY_DIRS}
|
||||
${Ogg_ROOT})
|
||||
# Handle the QUIETLY and REQUIRED arguments and set Ogg_FOUND
|
||||
# to TRUE if all listed variables are TRUE.
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Ogg
|
||||
REQUIRED_VARS
|
||||
Ogg_LIBRARY
|
||||
Ogg_INCLUDE_DIR
|
||||
VERSION_VAR
|
||||
Ogg_VERSION)
|
||||
|
||||
if(Ogg_FOUND)
|
||||
set(Ogg_LIBRARIES ${Ogg_LIBRARY})
|
||||
set(Ogg_INCLUDE_DIRS ${Ogg_INCLUDE_DIR})
|
||||
|
||||
if(NOT TARGET Ogg::ogg)
|
||||
add_library(Ogg::ogg UNKNOWN IMPORTED)
|
||||
set_target_properties(Ogg::ogg PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Ogg_INCLUDE_DIR}"
|
||||
IMPORTED_LOCATION "${Ogg_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
mark_as_advanced(Ogg_INCLUDE_DIR Ogg_LIBRARY)
|
|
@ -1,64 +0,0 @@
|
|||
# - Find opus
|
||||
# Find the native opus includes and libraries
|
||||
#
|
||||
# OPUS_INCLUDE_DIRS - where to find opus.h, etc.
|
||||
# OPUS_LIBRARIES - List of libraries when using opus.
|
||||
# OPUS_FOUND - True if Opus found.
|
||||
|
||||
if(OPUS_INCLUDE_DIR)
|
||||
# Already in cache, be silent
|
||||
set(OPUS_FIND_QUIETLY TRUE)
|
||||
endif()
|
||||
|
||||
find_package(Ogg QUIET)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_OPUS QUIET opus)
|
||||
|
||||
set(OPUS_VERSION ${PC_OPUS_VERSION})
|
||||
|
||||
find_path(OPUS_INCLUDE_DIR opus/opus.h
|
||||
HINTS
|
||||
${PC_OPUS_INCLUDEDIR}
|
||||
${PC_OPUS_INCLUDE_DIRS}
|
||||
${OPUS_ROOT})
|
||||
|
||||
# MSVC built opus may be named opus_static.
|
||||
# The provided project files name the library with the lib prefix.
|
||||
|
||||
find_library(OPUS_LIBRARY
|
||||
NAMES
|
||||
opus
|
||||
opus_static
|
||||
libopus
|
||||
libopus_static
|
||||
HINTS
|
||||
${PC_OPUS_LIBDIR}
|
||||
${PC_OPUS_LIBRARY_DIRS}
|
||||
${OPUS_ROOT})
|
||||
|
||||
# Handle the QUIETLY and REQUIRED arguments and set OPUS_FOUND
|
||||
# to TRUE if all listed variables are TRUE.
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Opus
|
||||
REQUIRED_VARS
|
||||
OPUS_LIBRARY
|
||||
OPUS_INCLUDE_DIR
|
||||
Ogg_FOUND
|
||||
VERSION_VAR
|
||||
OPUS_VERSION)
|
||||
|
||||
if(OPUS_FOUND)
|
||||
set(OPUS_LIBRARIES ${OPUS_LIBRARY})
|
||||
set(OPUS_INCLUDE_DIRS ${OPUS_INCLUDE_DIR} ${Ogg_INCLUDE_DIRS})
|
||||
|
||||
if(NOT TARGET Opus::opus)
|
||||
add_library(Opus::opus UNKNOWN IMPORTED)
|
||||
set_target_properties(Opus::opus PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${OPUS_INCLUDE_DIR}"
|
||||
IMPORTED_LOCATION "${OPUS_LIBRARY}"
|
||||
INTERFACE_LINK_LIBRARIES Ogg::ogg)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
mark_as_advanced(OPUS_INCLUDE_DIR OPUS_LIBRARY)
|
|
@ -1,57 +0,0 @@
|
|||
# Variables defined:
|
||||
# SNDFILE_FOUND
|
||||
# SNDFILE_INCLUDE_DIR
|
||||
# SNDFILE_LIBRARY
|
||||
#
|
||||
# Environment variables used:
|
||||
# SNDFILE_ROOT
|
||||
|
||||
if(SndFile_INCLUDE_DIR)
|
||||
# Already in cache, be silent
|
||||
set(SndFile_FIND_QUIETLY TRUE)
|
||||
endif(SndFile_INCLUDE_DIR)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_SndFile QUIET sndfile)
|
||||
|
||||
set(SndFile_VERSION ${PC_SndFile_VERSION})
|
||||
|
||||
find_package(Vorbis COMPONENTS Enc QUIET)
|
||||
find_package(FLAC QUIET)
|
||||
find_package(Opus QUIET)
|
||||
|
||||
find_path(SndFile_INCLUDE_DIR sndfile.h
|
||||
HINTS
|
||||
${PC_SndFile_INCLUDEDIR}
|
||||
${PC_SndFile_INCLUDE_DIRS}
|
||||
${SndFile_ROOT})
|
||||
|
||||
find_library(SndFile_LIBRARY NAMES sndfile
|
||||
HINTS
|
||||
${PC_SndFile_LIBDIR}
|
||||
${PC_SndFile_LIBRARY_DIRS}
|
||||
${SndFile_ROOT})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(SndFile
|
||||
REQUIRED_VARS
|
||||
SndFile_LIBRARY
|
||||
SndFile_INCLUDE_DIR
|
||||
VERSION_VAR
|
||||
SndFile_VERSION)
|
||||
|
||||
if(SndFile_FOUND)
|
||||
|
||||
set(SndFile_LIBRARIES ${SndFile_LIBRARY} ${Vorbis_Enc_LIBRARIES} ${FLAC_LIBRARIES} ${OPUS_LIBRARIES})
|
||||
set(SndFile_INCLUDE_DIRS ${SndFile_INCLUDE_DIR} ${Vorbis_Enc_INCLUDE_DIRS} ${FLAC_INCLUDE_DIRS} ${OPUS_INCLUDE_DIRS})
|
||||
|
||||
if(NOT TARGET SndFile::sndfile)
|
||||
add_library(SndFile::sndfile UNKNOWN IMPORTED)
|
||||
set_target_properties(SndFile::sndfile PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SndFile_INCLUDE_DIR}"
|
||||
IMPORTED_LOCATION "${SndFile_LIBRARY}"
|
||||
INTERFACE_LINK_LIBRARIES "Vorbis::vorbisenc;Opus::opus;FLAC::FLAC")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
mark_as_advanced(SndFile_LIBRARY SndFile_INCLUDE_DIR)
|
|
@ -1,204 +0,0 @@
|
|||
#[=======================================================================[.rst:
|
||||
FindVorbis
|
||||
----------
|
||||
|
||||
Finds the native vorbis, vorbisenc amd vorbisfile includes and libraries.
|
||||
|
||||
Imported Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module provides the following imported targets, if found:
|
||||
|
||||
``Vorbis::vorbis``
|
||||
The Vorbis library
|
||||
``Vorbis::vorbisenc``
|
||||
The VorbisEnc library
|
||||
``Vorbis::vorbisfile``
|
||||
The VorbisFile library
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This will define the following variables:
|
||||
|
||||
``Vorbis_Vorbis_INCLUDE_DIRS``
|
||||
List of include directories when using vorbis.
|
||||
``Vorbis_Enc_INCLUDE_DIRS``
|
||||
List of include directories when using vorbisenc.
|
||||
``Vorbis_File_INCLUDE_DIRS``
|
||||
List of include directories when using vorbisfile.
|
||||
``Vorbis_Vorbis_LIBRARIES``
|
||||
List of libraries when using vorbis.
|
||||
``Vorbis_Enc_LIBRARIES``
|
||||
List of libraries when using vorbisenc.
|
||||
``Vorbis_File_LIBRARIES``
|
||||
List of libraries when using vorbisfile.
|
||||
``Vorbis_FOUND``
|
||||
True if vorbis and requested components found.
|
||||
``Vorbis_Vorbis_FOUND``
|
||||
True if vorbis found.
|
||||
``Vorbis_Enc_FOUND``
|
||||
True if vorbisenc found.
|
||||
``Vorbis_Enc_FOUND``
|
||||
True if vorbisfile found.
|
||||
|
||||
Cache variables
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
The following cache variables may also be set:
|
||||
|
||||
``Vorbis_Vorbis_INCLUDE_DIR``
|
||||
The directory containing ``vorbis/vorbis.h``.
|
||||
``Vorbis_Enc_INCLUDE_DIR``
|
||||
The directory containing ``vorbis/vorbisenc.h``.
|
||||
``Vorbis_File_INCLUDE_DIR``
|
||||
The directory containing ``vorbis/vorbisenc.h``.
|
||||
``Vorbis_Vorbis_LIBRARY``
|
||||
The path to the vorbis library.
|
||||
``Vorbis_Enc_LIBRARY``
|
||||
The path to the vorbisenc library.
|
||||
``Vorbis_File_LIBRARY``
|
||||
The path to the vorbisfile library.
|
||||
|
||||
Hints
|
||||
^^^^^
|
||||
|
||||
A user may set ``Vorbis_ROOT`` to a vorbis installation root to tell this module where to look.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
if(Vorbis_Vorbis_INCLUDE_DIR)
|
||||
# Already in cache, be silent
|
||||
set(Vorbis_FIND_QUIETLY TRUE)
|
||||
endif()
|
||||
|
||||
set(Vorbis_Vorbis_FIND_QUIETLY TRUE)
|
||||
set(Vorbis_Enc_FIND_QUIETLY TRUE)
|
||||
set(Vorbis_File_FIND_QUIETLY TRUE)
|
||||
|
||||
find_package(Ogg QUIET)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_Vorbis_Vorbis QUIET vorbis)
|
||||
pkg_check_modules(PC_Vorbis_Enc QUIET vorbisenc)
|
||||
pkg_check_modules(PC_Vorbis_File QUIET vorbisfile)
|
||||
|
||||
set(Vorbis_VERSION ${PC_Vorbis_Vorbis_VERSION})
|
||||
|
||||
find_path(Vorbis_Vorbis_INCLUDE_DIR vorbis/codec.h
|
||||
HINTS
|
||||
${PC_Vorbis_Vorbis_INCLUDEDIR}
|
||||
${PC_Vorbis_Vorbis_INCLUDE_DIRS}
|
||||
${Vorbis_ROOT})
|
||||
|
||||
find_path(Vorbis_Enc_INCLUDE_DIR vorbis/vorbisenc.h
|
||||
HINTS
|
||||
${PC_Vorbis_Enc_INCLUDEDIR}
|
||||
${PC_Vorbis_Enc_INCLUDE_DIRS}
|
||||
${Vorbis_ROOT})
|
||||
|
||||
find_path(Vorbis_File_INCLUDE_DIR vorbis/vorbisfile.h
|
||||
HINTS
|
||||
${PC_Vorbis_File_INCLUDEDIR}
|
||||
${PC_Vorbis_File_INCLUDE_DIRS}
|
||||
${Vorbis_ROOT})
|
||||
|
||||
find_library(Vorbis_Vorbis_LIBRARY
|
||||
NAMES
|
||||
vorbis
|
||||
vorbis_static
|
||||
libvorbis
|
||||
libvorbis_static
|
||||
HINTS
|
||||
${PC_Vorbis_Vorbis_LIBDIR}
|
||||
${PC_Vorbis_Vorbis_LIBRARY_DIRS}
|
||||
${Vorbis_ROOT})
|
||||
|
||||
find_library(Vorbis_Enc_LIBRARY
|
||||
NAMES
|
||||
vorbisenc
|
||||
vorbisenc_static
|
||||
libvorbisenc
|
||||
libvorbisenc_static
|
||||
HINTS
|
||||
${PC_Vorbis_Enc_LIBDIR}
|
||||
${PC_Vorbis_Enc_LIBRARY_DIRS}
|
||||
${Vorbis_ROOT})
|
||||
|
||||
find_library(Vorbis_File_LIBRARY
|
||||
NAMES
|
||||
vorbisfile
|
||||
vorbisfile_static
|
||||
libvorbisfile
|
||||
libvorbisfile_static
|
||||
HINTS
|
||||
${PC_Vorbis_File_LIBDIR}
|
||||
${PC_Vorbis_File_LIBRARY_DIRS}
|
||||
${Vorbis_ROOT})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
if(Vorbis_Vorbis_LIBRARY AND Vorbis_Vorbis_INCLUDE_DIR AND Ogg_FOUND)
|
||||
set(Vorbis_Vorbis_FOUND TRUE)
|
||||
endif()
|
||||
|
||||
if(Vorbis_Enc_LIBRARY AND Vorbis_Enc_INCLUDE_DIR AND Vorbis_Vorbis_FOUND)
|
||||
set(Vorbis_Enc_FOUND TRUE)
|
||||
endif()
|
||||
|
||||
if(Vorbis_Vorbis_FOUND AND Vorbis_File_LIBRARY AND Vorbis_File_INCLUDE_DIR)
|
||||
set(Vorbis_File_FOUND TRUE)
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(Vorbis
|
||||
REQUIRED_VARS
|
||||
Vorbis_Vorbis_LIBRARY
|
||||
Vorbis_Vorbis_INCLUDE_DIR
|
||||
Ogg_FOUND
|
||||
HANDLE_COMPONENTS
|
||||
VERSION_VAR Vorbis_VERSION)
|
||||
|
||||
|
||||
if(Vorbis_Vorbis_FOUND)
|
||||
set(Vorbis_Vorbis_INCLUDE_DIRS ${Vorbis_Vorbis_INCLUDE_DIR} ${Ogg_INCLUDE_DIRS})
|
||||
set(Vorbis_Vorbis_LIBRARIES ${Vorbis_Vorbis_LIBRARY} ${Ogg_LIBRARIES})
|
||||
if(NOT TARGET Vorbis::vorbis)
|
||||
add_library(Vorbis::vorbis UNKNOWN IMPORTED)
|
||||
set_target_properties(Vorbis::vorbis PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_Vorbis_INCLUDE_DIR}"
|
||||
IMPORTED_LOCATION "${Vorbis_Vorbis_LIBRARY}"
|
||||
INTERFACE_LINK_LIBRARIES Ogg::ogg
|
||||
)
|
||||
endif()
|
||||
|
||||
if(Vorbis_Enc_FOUND)
|
||||
set(Vorbis_Enc_INCLUDE_DIRS ${Vorbis_Enc_INCLUDE_DIR} ${Ogg_INCLUDE_DIRS})
|
||||
set(Vorbis_Enc_LIBRARIES ${Vorbis_Enc_LIBRARY} ${Vorbis_Vorbis_LIBRARIES})
|
||||
if(NOT TARGET Vorbis::vorbisenc)
|
||||
add_library(Vorbis::vorbisenc UNKNOWN IMPORTED)
|
||||
set_target_properties(Vorbis::vorbisenc PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_Enc_INCLUDE_DIR}"
|
||||
IMPORTED_LOCATION "${Vorbis_Enc_LIBRARY}"
|
||||
INTERFACE_LINK_LIBRARIES Vorbis::vorbis
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(Vorbis_File_FOUND)
|
||||
set(Vorbis_File_INCLUDE_DIRS ${Vorbis_File_INCLUDE_DIR} ${Ogg_INCLUDE_DIRS})
|
||||
set(Vorbis_File_LIBRARIES ${Vorbis_File_LIBRARY} ${Vorbis_Vorbis_LIBRARIES})
|
||||
if(NOT TARGET Vorbis::vorbisfile)
|
||||
add_library(Vorbis::vorbisfile UNKNOWN IMPORTED)
|
||||
set_target_properties(Vorbis::vorbisfile PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_File_INCLUDE_DIR}"
|
||||
IMPORTED_LOCATION "${Vorbis_File_LIBRARY}"
|
||||
INTERFACE_LINK_LIBRARIES Vorbis::vorbis
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
mark_as_advanced(Vorbis_Vorbis_INCLUDE_DIR Vorbis_Vorbis_LIBRARY)
|
||||
mark_as_advanced(Vorbis_Enc_INCLUDE_DIR Vorbis_Enc_LIBRARY)
|
||||
mark_as_advanced(Vorbis_File_INCLUDE_DIR Vorbis_File_LIBRARY)
|
|
@ -1 +0,0 @@
|
|||
include(${CMAKE_CURRENT_LIST_DIR}/SampleRateTargets.cmake)
|
|
@ -1,70 +0,0 @@
|
|||
/* config.h - generated by CMake. */
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "${PROJECT_NAME}"
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "${PROJECT_VERSION}"
|
||||
|
||||
/* Target processor clips on negative float to int conversion. */
|
||||
#cmakedefine01 CPU_CLIPS_NEGATIVE
|
||||
|
||||
/* Target processor clips on positive float to int conversion. */
|
||||
#cmakedefine01 CPU_CLIPS_POSITIVE
|
||||
|
||||
/* Target processor is big endian. */
|
||||
#cmakedefine01 CPU_IS_BIG_ENDIAN
|
||||
|
||||
/* Target processor is little endian. */
|
||||
#cmakedefine01 CPU_IS_LITTLE_ENDIAN
|
||||
|
||||
/* Define to 1 if you have the `alarm' function. */
|
||||
#cmakedefine01 HAVE_ALARM
|
||||
|
||||
/* Define to 1 if you have the <alsa/asoundlib.h> header file. */
|
||||
#cmakedefine01 HAVE_ALSA
|
||||
|
||||
/* Set to 1 if you have libfftw3. */
|
||||
#cmakedefine01 HAVE_FFTW3
|
||||
|
||||
/* Define if you have C99's lrint function. */
|
||||
#cmakedefine01 HAVE_LRINT
|
||||
|
||||
/* Define if you have C99's lrintf function. */
|
||||
#cmakedefine01 HAVE_LRINTF
|
||||
|
||||
/* Define if you have signal SIGALRM. */
|
||||
#cmakedefine01 HAVE_SIGALRM
|
||||
|
||||
/* Define to 1 if you have the `signal' function. */
|
||||
#cmakedefine01 HAVE_SIGNAL
|
||||
|
||||
/* Set to 1 if you have libsndfile. */
|
||||
#cmakedefine01 HAVE_SNDFILE
|
||||
|
||||
/* Define to 1 if you have the <stdbool.h> header file. */
|
||||
#cmakedefine HAVE_STDBOOL_H
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#cmakedefine01 HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/times.h> header file. */
|
||||
#cmakedefine01 HAVE_SYS_TIMES_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#cmakedefine HAVE_UNISTD_H
|
||||
|
||||
/* define fast samplerate convertor */
|
||||
#cmakedefine ENABLE_SINC_FAST_CONVERTER
|
||||
|
||||
/* define balanced samplerate convertor */
|
||||
#cmakedefine ENABLE_SINC_MEDIUM_CONVERTER
|
||||
|
||||
/* define best samplerate convertor */
|
||||
#cmakedefine ENABLE_SINC_BEST_CONVERTER
|
||||
|
||||
/* The size of `int', as computed by sizeof. */
|
||||
#define SIZEOF_INT ${SIZEOF_INT}
|
||||
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#define SIZEOF_LONG ${SIZEOF_LONG}
|
|
@ -1,189 +0,0 @@
|
|||
/*
|
||||
** Copyright (c) 2002-2016, Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** All rights reserved.
|
||||
**
|
||||
** This code is released under 2-clause BSD license. Please see the
|
||||
** file at : https://github.com/libsndfile/libsamplerate/blob/master/COPYING
|
||||
*/
|
||||
|
||||
/*
|
||||
** API documentation is available here:
|
||||
** http://libsndfile.github.io/libsamplerate/api.html
|
||||
*/
|
||||
|
||||
#ifndef SAMPLERATE_H
|
||||
#define SAMPLERATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/* Opaque data type SRC_STATE. */
|
||||
typedef struct SRC_STATE_tag SRC_STATE ;
|
||||
|
||||
/* SRC_DATA is used to pass data to src_simple() and src_process(). */
|
||||
typedef struct
|
||||
{ const float *data_in ;
|
||||
float *data_out ;
|
||||
|
||||
long input_frames, output_frames ;
|
||||
long input_frames_used, output_frames_gen ;
|
||||
|
||||
int end_of_input ;
|
||||
|
||||
double src_ratio ;
|
||||
} SRC_DATA ;
|
||||
|
||||
/*
|
||||
** User supplied callback function type for use with src_callback_new()
|
||||
** and src_callback_read(). First parameter is the same pointer that was
|
||||
** passed into src_callback_new(). Second parameter is pointer to a
|
||||
** pointer. The user supplied callback function must modify *data to
|
||||
** point to the start of the user supplied float array. The user supplied
|
||||
** function must return the number of frames that **data points to.
|
||||
*/
|
||||
|
||||
typedef long (*src_callback_t) (void *cb_data, float **data) ;
|
||||
|
||||
/*
|
||||
** Standard initialisation function : return an anonymous pointer to the
|
||||
** internal state of the converter. Choose a converter from the enums below.
|
||||
** Error returned in *error.
|
||||
*/
|
||||
|
||||
SRC_STATE* src_new (int converter_type, int channels, int *error) ;
|
||||
|
||||
/*
|
||||
** Clone a handle : return an anonymous pointer to a new converter
|
||||
** containing the same internal state as orig. Error returned in *error.
|
||||
*/
|
||||
SRC_STATE* src_clone (SRC_STATE* orig, int *error) ;
|
||||
|
||||
/*
|
||||
** Initilisation for callback based API : return an anonymous pointer to the
|
||||
** internal state of the converter. Choose a converter from the enums below.
|
||||
** The cb_data pointer can point to any data or be set to NULL. Whatever the
|
||||
** value, when processing, user supplied function "func" gets called with
|
||||
** cb_data as first parameter.
|
||||
*/
|
||||
|
||||
SRC_STATE* src_callback_new (src_callback_t func, int converter_type, int channels,
|
||||
int *error, void* cb_data) ;
|
||||
|
||||
/*
|
||||
** Cleanup all internal allocations.
|
||||
** Always returns NULL.
|
||||
*/
|
||||
|
||||
SRC_STATE* src_delete (SRC_STATE *state) ;
|
||||
|
||||
/*
|
||||
** Standard processing function.
|
||||
** Returns non zero on error.
|
||||
*/
|
||||
|
||||
int src_process (SRC_STATE *state, SRC_DATA *data) ;
|
||||
|
||||
/*
|
||||
** Callback based processing function. Read up to frames worth of data from
|
||||
** the converter int *data and return frames read or -1 on error.
|
||||
*/
|
||||
long src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data) ;
|
||||
|
||||
/*
|
||||
** Simple interface for performing a single conversion from input buffer to
|
||||
** output buffer at a fixed conversion ratio.
|
||||
** Simple interface does not require initialisation as it can only operate on
|
||||
** a single buffer worth of audio.
|
||||
*/
|
||||
|
||||
int src_simple (SRC_DATA *data, int converter_type, int channels) ;
|
||||
|
||||
/*
|
||||
** This library contains a number of different sample rate converters,
|
||||
** numbered 0 through N.
|
||||
**
|
||||
** Return a string giving either a name or a more full description of each
|
||||
** sample rate converter or NULL if no sample rate converter exists for
|
||||
** the given value. The converters are sequentially numbered from 0 to N.
|
||||
*/
|
||||
|
||||
const char *src_get_name (int converter_type) ;
|
||||
const char *src_get_description (int converter_type) ;
|
||||
const char *src_get_version (void) ;
|
||||
|
||||
/*
|
||||
** Set a new SRC ratio. This allows step responses
|
||||
** in the conversion ratio.
|
||||
** Returns non zero on error.
|
||||
*/
|
||||
|
||||
int src_set_ratio (SRC_STATE *state, double new_ratio) ;
|
||||
|
||||
/*
|
||||
** Get the current channel count.
|
||||
** Returns negative on error, positive channel count otherwise
|
||||
*/
|
||||
|
||||
int src_get_channels (SRC_STATE *state) ;
|
||||
|
||||
/*
|
||||
** Reset the internal SRC state.
|
||||
** Does not modify the quality settings.
|
||||
** Does not free any memory allocations.
|
||||
** Returns non zero on error.
|
||||
*/
|
||||
|
||||
int src_reset (SRC_STATE *state) ;
|
||||
|
||||
/*
|
||||
** Return TRUE if ratio is a valid conversion ratio, FALSE
|
||||
** otherwise.
|
||||
*/
|
||||
|
||||
int src_is_valid_ratio (double ratio) ;
|
||||
|
||||
/*
|
||||
** Return an error number.
|
||||
*/
|
||||
|
||||
int src_error (SRC_STATE *state) ;
|
||||
|
||||
/*
|
||||
** Convert the error number into a string.
|
||||
*/
|
||||
const char* src_strerror (int error) ;
|
||||
|
||||
/*
|
||||
** The following enums can be used to set the interpolator type
|
||||
** using the function src_set_converter().
|
||||
*/
|
||||
|
||||
enum
|
||||
{
|
||||
SRC_SINC_BEST_QUALITY = 0,
|
||||
SRC_SINC_MEDIUM_QUALITY = 1,
|
||||
SRC_SINC_FASTEST = 2,
|
||||
SRC_ZERO_ORDER_HOLD = 3,
|
||||
SRC_LINEAR = 4,
|
||||
} ;
|
||||
|
||||
/*
|
||||
** Extra helper functions for converting from short to float and
|
||||
** back again.
|
||||
*/
|
||||
|
||||
void src_short_to_float_array (const short *in, float *out, int len) ;
|
||||
void src_float_to_short_array (const float *in, short *out, int len) ;
|
||||
|
||||
void src_int_to_float_array (const int *in, float *out, int len) ;
|
||||
void src_float_to_int_array (const float *in, int *out, int len) ;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* SAMPLERATE_H */
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
|
||||
%define name @PACKAGE@
|
||||
%define version @VERSION@
|
||||
%define release 1
|
||||
%define prefix /usr
|
||||
|
||||
Summary: A library to do sample rate conversion for audio.
|
||||
Name: %{name}
|
||||
Version: %{version}
|
||||
Release: %{release}
|
||||
Prefix: %{prefix}
|
||||
Copyright: BSD
|
||||
Group: Libraries/Sound
|
||||
Source: http://www.mega-nerd.com/SRC/libsamplerate-%{version}.tar.gz
|
||||
URL: https://github.com/libsndfile/libsamplerate/
|
||||
BuildRoot: /var/tmp/%{name}-%{version}
|
||||
|
||||
%description
|
||||
libsamplerate is a C library capable of arbitrary and time varying
|
||||
conversions; from downsampling by a factor of 12 to upsampling by the
|
||||
same factor. The conversion ratio can also vary with time for speeding
|
||||
up and slowing down effects.
|
||||
|
||||
%package devel
|
||||
Summary: Libraries, includes, etc to develop libsamplerate applications
|
||||
Group: Libraries
|
||||
|
||||
%description devel
|
||||
Libraries, include files, etc you can use to develop libsamplerate applications.
|
||||
|
||||
%prep
|
||||
%setup
|
||||
|
||||
%build
|
||||
./configure --prefix=%{prefix}
|
||||
make
|
||||
|
||||
%install
|
||||
if [ -d $RPM_BUILD_ROOT ]; then rm -rf $RPM_BUILD_ROOT; fi
|
||||
mkdir -p $RPM_BUILD_ROOT
|
||||
make prefix=$RPM_BUILD_ROOT%{prefix} install
|
||||
|
||||
%clean
|
||||
if [ -d $RPM_BUILD_ROOT ]; then rm -rf $RPM_BUILD_ROOT; fi
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%doc AUTHORS COPYING ChangeLog INSTALL NEWS README doc
|
||||
%prefix/lib/libsamplerate.so.*
|
||||
|
||||
%files devel
|
||||
%defattr(-,root,root)
|
||||
%{prefix}/lib/libsamplerate.a
|
||||
%{prefix}/lib/libsamplerate.la
|
||||
%{prefix}/lib/libsamplerate.so
|
||||
%{prefix}/include/samplerate.h
|
||||
%{prefix}/lib/pkgconfig/samplerate.pc
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\msvc\vsprops\Configurations.props" />
|
||||
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\samplerate.h" />
|
||||
<ClInclude Include="src\common.h" />
|
||||
<ClInclude Include="src\fastest_coeffs.h" />
|
||||
<ClInclude Include="src\high_qual_coeffs.h" />
|
||||
<ClInclude Include="src\mid_qual_coeffs.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\samplerate.c" />
|
||||
<ClCompile Include="src\src_linear.c" />
|
||||
<ClCompile Include="src\src_sinc.c" />
|
||||
<ClCompile Include="src\src_zoh.c" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\msvc\vsprops\StaticLibrary.props" />
|
||||
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||
<PreprocessorDefinitions>HAVE_CONFIG_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\msvc;$(ProjectDir)\include;$(ProjectDir)src\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
<Import Project="..\msvc\vsprops\Targets.props" />
|
||||
</Project>
|
|
@ -1,16 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\common.h" />
|
||||
<ClInclude Include="src\fastest_coeffs.h" />
|
||||
<ClInclude Include="src\high_qual_coeffs.h" />
|
||||
<ClInclude Include="src\mid_qual_coeffs.h" />
|
||||
<ClInclude Include="include\samplerate.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\samplerate.c" />
|
||||
<ClCompile Include="src\src_linear.c" />
|
||||
<ClCompile Include="src\src_sinc.c" />
|
||||
<ClCompile Include="src\src_zoh.c" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,70 +0,0 @@
|
|||
#include <stdbool.h>
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "libsamplerate"
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "0.1.9"
|
||||
|
||||
/* Target processor clips on negative float to int conversion. */
|
||||
#define CPU_CLIPS_NEGATIVE 0
|
||||
|
||||
/* Target processor clips on positive float to int conversion. */
|
||||
#define CPU_CLIPS_POSITIVE 0
|
||||
|
||||
/* Target processor is big endian. */
|
||||
#define CPU_IS_BIG_ENDIAN 0
|
||||
|
||||
/* Target processor is little endian. */
|
||||
#define CPU_IS_LITTLE_ENDIAN 1
|
||||
|
||||
/* Define to 1 if you have the `alarm' function. */
|
||||
/* #undef HAVE_ALARM */
|
||||
|
||||
/* Define to 1 if you have the <alsa/asoundlib.h> header file. */
|
||||
/* #undef HAVE_ALSA */
|
||||
|
||||
/* Set to 1 if you have libfftw3. */
|
||||
/* #undef HAVE_FFTW3 */
|
||||
|
||||
/* Define if you have C99's lrint function. */
|
||||
/* #undef HAVE_LRINT */
|
||||
|
||||
/* Define if you have C99's lrintf function. */
|
||||
/* #undef HAVE_LRINTF */
|
||||
|
||||
/* Define if you have signal SIGALRM. */
|
||||
/* #undef HAVE_SIGALRM */
|
||||
|
||||
/* Define to 1 if you have the `signal' function. */
|
||||
/* #undef HAVE_SIGNAL */
|
||||
|
||||
/* Set to 1 if you have libsndfile. */
|
||||
/* #undef HAVE_SNDFILE */
|
||||
|
||||
/* Define to 1 if you have the <stdbool.h> header file. */
|
||||
/* #undef HAVE_STDBOOL_H */
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/times.h> header file. */
|
||||
/* #undef HAVE_SYS_TIMES_H */
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
/* #undef HAVE_UNISTD_H */
|
||||
|
||||
/* define fast samplerate convertor */
|
||||
#define ENABLE_SINC_FAST_CONVERTER 1
|
||||
|
||||
/* define balanced samplerate convertor */
|
||||
#define ENABLE_SINC_MEDIUM_CONVERTER 1
|
||||
|
||||
/* define best samplerate convertor */
|
||||
/* #define ENABLE_SINC_BEST_CONVERTER 1 */
|
||||
|
||||
/* The size of `int', as computed by sizeof. */
|
||||
#define SIZEOF_INT 4
|
||||
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#define SIZEOF_LONG 4
|
|
@ -1,12 +0,0 @@
|
|||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: samplerate
|
||||
Description: An audio Sample Rate Conversion library
|
||||
Requires:
|
||||
Version: @VERSION@
|
||||
Libs: -L${libdir} -lsamplerate
|
||||
Libs.private: @LIBS@
|
||||
Cflags: -I${includedir}
|
|
@ -1,139 +0,0 @@
|
|||
option(LIBSAMPLERATE_COMPATIBLE_NAME "Use old dll name on Windows platform" OFF)
|
||||
|
||||
option(LIBSAMPLERATE_ENABLE_SINC_FAST_CONVERTER "Enable Fastest Sinc Interpolator converter" ON)
|
||||
option(LIBSAMPLERATE_ENABLE_SINC_MEDIUM_CONVERTER "Enable Medium Sinc Interpolator converter" ON)
|
||||
option(LIBSAMPLERATE_ENABLE_SINC_BEST_CONVERTER "Enable Best Sinc Interpolator converter" ON)
|
||||
|
||||
option(LIBSAMPLERATE_INSTALL_PKGCONFIG_MODULE "Install samplerate.pc PkgConfig module." ON)
|
||||
|
||||
set(ENABLE_SINC_FAST_CONVERTER ${LIBSAMPLERATE_ENABLE_SINC_FAST_CONVERTER} PARENT_SCOPE)
|
||||
set(ENABLE_SINC_MEDIUM_CONVERTER ${LIBSAMPLERATE_ENABLE_SINC_MEDIUM_CONVERTER} PARENT_SCOPE)
|
||||
set(ENABLE_SINC_BEST_CONVERTER ${LIBSAMPLERATE_ENABLE_SINC_BEST_CONVERTER} PARENT_SCOPE)
|
||||
|
||||
include(ClipMode)
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
# This will set CPU_CLIPS_NEGATIVE and CPU_CLIPS_POSITIVE
|
||||
clip_mode()
|
||||
|
||||
add_library(samplerate
|
||||
common.h
|
||||
fastest_coeffs.h
|
||||
high_qual_coeffs.h
|
||||
mid_qual_coeffs.h
|
||||
samplerate.c
|
||||
${PROJECT_SOURCE_DIR}/include/samplerate.h
|
||||
src_linear.c
|
||||
src_sinc.c
|
||||
src_zoh.c
|
||||
$<$<AND:$<BOOL:${WIN32}>,$<BOOL:${BUILD_SHARED_LIBS}>>:../Win32/libsamplerate-0.def>)
|
||||
|
||||
# ALIAS to use if libsamplerate is included from other project with add_subdirectory()
|
||||
add_library(SampleRate::samplerate ALIAS samplerate)
|
||||
|
||||
# CMake generates wrong DLL names for MinGW and Cygwin, fix it
|
||||
if(BUILD_SHARED_LIBS AND WIN32)
|
||||
if(LIBSAMPLERATE_COMPATIBLE_NAME)
|
||||
if(MSVC)
|
||||
set_target_properties(samplerate PROPERTIES OUTPUT_NAME "libsamplerate-${libsamplerate_VERSION_MAJOR}")
|
||||
else()
|
||||
set_target_properties(samplerate PROPERTIES OUTPUT_NAME "samplerate-${libsamplerate_VERSION_MAJOR}")
|
||||
endif()
|
||||
else()
|
||||
if(MINGW OR CYGWIN)
|
||||
set_target_properties(samplerate PROPERTIES RUNTIME_OUTPUT_NAME "samplerate-${libsamplerate_VERSION_MAJOR}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_include_directories(samplerate
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||
|
||||
if(LIBM_REQUIRED)
|
||||
target_link_libraries(samplerate PRIVATE m)
|
||||
endif()
|
||||
|
||||
# Set public header
|
||||
set_property(TARGET samplerate PROPERTY PUBLIC_HEADER ${PROJECT_SOURCE_DIR}/include/samplerate.h)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
# Set ABI version. This is critical for Unix-like OSes
|
||||
set_target_properties(samplerate PROPERTIES
|
||||
VERSION ${libsamplerate_VERSION}
|
||||
SOVERSION ${libsamplerate_VERSION_MAJOR})
|
||||
|
||||
# Use Version_script to export ABI set
|
||||
if(UNIX AND (NOT APPLE))
|
||||
if((CMAKE_C_COMPILER_ID STREQUAL "GNU") OR
|
||||
(CMAKE_C_COMPILER_ID STREQUAL "Clang") OR
|
||||
(CMAKE_C_COMPILER_ID STREQUAL "Intel"))
|
||||
|
||||
set(PACKAGE ${PROJECT_NAME})
|
||||
configure_file(Version_script.in Version_script)
|
||||
unset(PACKAGE)
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS 3.13)
|
||||
# This works
|
||||
set_property(TARGET samplerate APPEND_STRING PROPERTY
|
||||
LINK_FLAGS "-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/Version_script")
|
||||
else()
|
||||
# This works even better, e.g. for Clang it uses `-Xlinker` option,
|
||||
# but requires CMake >= 3.13.
|
||||
target_link_options(samplerate
|
||||
PRIVATE
|
||||
"LINKER:--version-script,${CMAKE_CURRENT_BINARY_DIR}/Version_script")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Istallation
|
||||
|
||||
if(LIBSAMPLERATE_INSTALL)
|
||||
|
||||
install(TARGETS samplerate EXPORT SampleRateTargets
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
|
||||
# pkg-config module
|
||||
|
||||
if(LIBSAMPLERATE_INSTALL_PKGCONFIG_MODULE)
|
||||
set(prefix ${CMAKE_INSTALL_PREFIX})
|
||||
set(exec_prefix "\${prefix}")
|
||||
set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
|
||||
set(VERSION "${PROJECT_VERSION}")
|
||||
if(LIBM_REQUIRED)
|
||||
set(LIBS "-lm")
|
||||
endif()
|
||||
configure_file(../samplerate.pc.in samplerate.pc @ONLY)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/samplerate.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
endif()
|
||||
|
||||
if(WIN32 AND (NOT MINGW) AND (NOT CYGWIN))
|
||||
set(CMAKE_INSTALL_PACKAGEDIR cmake)
|
||||
else()
|
||||
set(CMAKE_INSTALL_PACKAGEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/SampleRate)
|
||||
endif()
|
||||
|
||||
configure_package_config_file(../cmake/SampleRateConfig.cmake.in SampleRateConfig.cmake
|
||||
INSTALL_DESTINATION ${CMAKE_INSTALL_PACKAGEDIR})
|
||||
|
||||
write_basic_package_version_file(SampleRateConfigVersion.cmake COMPATIBILITY SameMajorVersion)
|
||||
install(
|
||||
FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/SampleRateConfig.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/SampleRateConfigVersion.cmake
|
||||
DESTINATION
|
||||
${CMAKE_INSTALL_PACKAGEDIR})
|
||||
|
||||
install(EXPORT SampleRateTargets
|
||||
NAMESPACE SampleRate::
|
||||
DESTINATION ${CMAKE_INSTALL_PACKAGEDIR})
|
||||
|
||||
endif()
|
|
@ -1,45 +0,0 @@
|
|||
#
|
||||
# Export file for libsamplerate
|
||||
#
|
||||
# Only the symbols listed in the global section will be callable from
|
||||
# applications linking to libsamplerate.
|
||||
#
|
||||
|
||||
@PACKAGE@.so.0.0
|
||||
{
|
||||
global:
|
||||
src_new ;
|
||||
src_delete ;
|
||||
src_get_name ;
|
||||
src_get_description ;
|
||||
src_get_version ;
|
||||
src_process ;
|
||||
src_reset ;
|
||||
src_error ;
|
||||
src_strerror ;
|
||||
src_simple ;
|
||||
src_is_valid_ratio ;
|
||||
src_set_ratio ;
|
||||
|
||||
local:
|
||||
*;
|
||||
};
|
||||
|
||||
@PACKAGE@.so.0.1
|
||||
{
|
||||
global:
|
||||
src_callback_new ;
|
||||
src_callback_read ;
|
||||
|
||||
src_short_to_float_array ;
|
||||
src_float_to_short_array ;
|
||||
src_int_to_float_array ;
|
||||
src_float_to_int_array ;
|
||||
src_get_channels ;
|
||||
} @PACKAGE@.so.0.0;
|
||||
|
||||
@PACKAGE@.so.0.2
|
||||
{
|
||||
global:
|
||||
src_clone ;
|
||||
} @PACKAGE@.so.0.1;
|
|
@ -1,47 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2004-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# 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.
|
||||
|
||||
#=======================================================================
|
||||
# This short test script compiles the file src_sinc.c into assembler
|
||||
# output and the greps the assembler output for the fldcw (FPU Load
|
||||
# Control Word) instruction which is very detrimental to the perfromance
|
||||
# of floating point code.
|
||||
|
||||
echo -n " Checking assembler output for bad code : "
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "Error : Need the name of the input file."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
filename=$1
|
||||
|
||||
if [ ! -f $filename ];then
|
||||
echo "Error : Can't find file $filename."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
count=`grep fldcw $filename | wc -l`
|
||||
|
||||
if [ $count -gt 0 ]; then
|
||||
echo -e "\n\nError : found $count bad instructions.\n\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "ok"
|
||||
|
|
@ -1,179 +0,0 @@
|
|||
/*
|
||||
** Copyright (c) 2002-2016, Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** All rights reserved.
|
||||
**
|
||||
** This code is released under 2-clause BSD license. Please see the
|
||||
** file at : https://github.com/libsndfile/libsamplerate/blob/master/COPYING
|
||||
*/
|
||||
|
||||
#ifndef COMMON_H_INCLUDED
|
||||
#define COMMON_H_INCLUDED
|
||||
|
||||
#include <stdint.h>
|
||||
#ifdef HAVE_STDBOOL_H
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#define SRC_MAX_RATIO 256
|
||||
#define SRC_MAX_RATIO_STR "256"
|
||||
|
||||
#define SRC_MIN_RATIO_DIFF (1e-20)
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0])))
|
||||
#define OFFSETOF(type,member) ((int) (&((type*) 0)->member))
|
||||
|
||||
#define MAKE_MAGIC(a,b,c,d,e,f) ((a) + ((b) << 4) + ((c) << 8) + ((d) << 12) + ((e) << 16) + ((f) << 20))
|
||||
|
||||
/*
|
||||
** Inspiration : http://sourcefrog.net/weblog/software/languages/C/unused.html
|
||||
*/
|
||||
#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
|
||||
#endif
|
||||
|
||||
#include "samplerate.h"
|
||||
|
||||
enum
|
||||
{ SRC_FALSE = 0,
|
||||
SRC_TRUE = 1,
|
||||
} ;
|
||||
|
||||
enum SRC_MODE
|
||||
{
|
||||
SRC_MODE_PROCESS = 0,
|
||||
SRC_MODE_CALLBACK = 1
|
||||
} ;
|
||||
|
||||
typedef enum SRC_ERROR
|
||||
{
|
||||
SRC_ERR_NO_ERROR = 0,
|
||||
|
||||
SRC_ERR_MALLOC_FAILED,
|
||||
SRC_ERR_BAD_STATE,
|
||||
SRC_ERR_BAD_DATA,
|
||||
SRC_ERR_BAD_DATA_PTR,
|
||||
SRC_ERR_NO_PRIVATE,
|
||||
SRC_ERR_BAD_SRC_RATIO,
|
||||
SRC_ERR_BAD_PROC_PTR,
|
||||
SRC_ERR_SHIFT_BITS,
|
||||
SRC_ERR_FILTER_LEN,
|
||||
SRC_ERR_BAD_CONVERTER,
|
||||
SRC_ERR_BAD_CHANNEL_COUNT,
|
||||
SRC_ERR_SINC_BAD_BUFFER_LEN,
|
||||
SRC_ERR_SIZE_INCOMPATIBILITY,
|
||||
SRC_ERR_BAD_PRIV_PTR,
|
||||
SRC_ERR_BAD_SINC_STATE,
|
||||
SRC_ERR_DATA_OVERLAP,
|
||||
SRC_ERR_BAD_CALLBACK,
|
||||
SRC_ERR_BAD_MODE,
|
||||
SRC_ERR_NULL_CALLBACK,
|
||||
SRC_ERR_NO_VARIABLE_RATIO,
|
||||
SRC_ERR_SINC_PREPARE_DATA_BAD_LEN,
|
||||
SRC_ERR_BAD_INTERNAL_STATE,
|
||||
|
||||
/* This must be the last error number. */
|
||||
SRC_ERR_MAX_ERROR
|
||||
} SRC_ERROR ;
|
||||
|
||||
typedef struct SRC_STATE_VT_tag
|
||||
{
|
||||
/* Varispeed process function. */
|
||||
SRC_ERROR (*vari_process) (SRC_STATE *state, SRC_DATA *data) ;
|
||||
|
||||
/* Constant speed process function. */
|
||||
SRC_ERROR (*const_process) (SRC_STATE *state, SRC_DATA *data) ;
|
||||
|
||||
/* State reset. */
|
||||
void (*reset) (SRC_STATE *state) ;
|
||||
|
||||
/* State clone. */
|
||||
SRC_STATE *(*copy) (SRC_STATE *state) ;
|
||||
|
||||
/* State close. */
|
||||
void (*close) (SRC_STATE *state) ;
|
||||
} SRC_STATE_VT ;
|
||||
|
||||
struct SRC_STATE_tag
|
||||
{
|
||||
SRC_STATE_VT *vt ;
|
||||
|
||||
double last_ratio, last_position ;
|
||||
|
||||
SRC_ERROR error ;
|
||||
int channels ;
|
||||
|
||||
/* SRC_MODE_PROCESS or SRC_MODE_CALLBACK */
|
||||
enum SRC_MODE mode ;
|
||||
|
||||
/* Data specific to SRC_MODE_CALLBACK. */
|
||||
src_callback_t callback_func ;
|
||||
void *user_callback_data ;
|
||||
long saved_frames ;
|
||||
const float *saved_data ;
|
||||
|
||||
/* Pointer to data to converter specific data. */
|
||||
void *private_data ;
|
||||
} ;
|
||||
|
||||
/* In src_sinc.c */
|
||||
const char* sinc_get_name (int src_enum) ;
|
||||
const char* sinc_get_description (int src_enum) ;
|
||||
|
||||
SRC_STATE *sinc_state_new (int converter_type, int channels, SRC_ERROR *error) ;
|
||||
|
||||
/* In src_linear.c */
|
||||
const char* linear_get_name (int src_enum) ;
|
||||
const char* linear_get_description (int src_enum) ;
|
||||
|
||||
SRC_STATE *linear_state_new (int channels, SRC_ERROR *error) ;
|
||||
|
||||
/* In src_zoh.c */
|
||||
const char* zoh_get_name (int src_enum) ;
|
||||
const char* zoh_get_description (int src_enum) ;
|
||||
|
||||
SRC_STATE *zoh_state_new (int channels, SRC_ERROR *error) ;
|
||||
|
||||
/*----------------------------------------------------------
|
||||
** Common static inline functions.
|
||||
*/
|
||||
|
||||
static inline double
|
||||
fmod_one (double x)
|
||||
{ double res ;
|
||||
|
||||
res = x - lrint (x) ;
|
||||
if (res < 0.0)
|
||||
return res + 1.0 ;
|
||||
|
||||
return res ;
|
||||
} /* fmod_one */
|
||||
|
||||
static inline int
|
||||
is_bad_src_ratio (double ratio)
|
||||
{ return (ratio < (1.0 / SRC_MAX_RATIO) || ratio > (1.0 * SRC_MAX_RATIO)) ;
|
||||
} /* is_bad_src_ratio */
|
||||
|
||||
|
||||
#endif /* COMMON_H_INCLUDED */
|
||||
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,533 +0,0 @@
|
|||
/*
|
||||
** Copyright (c) 2002-2016, Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** All rights reserved.
|
||||
**
|
||||
** This code is released under 2-clause BSD license. Please see the
|
||||
** file at : https://github.com/libsndfile/libsamplerate/blob/master/COPYING
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "samplerate.h"
|
||||
#include "common.h"
|
||||
|
||||
static SRC_STATE *psrc_set_converter (int converter_type, int channels, int *error) ;
|
||||
|
||||
|
||||
SRC_STATE *
|
||||
src_new (int converter_type, int channels, int *error)
|
||||
{
|
||||
return psrc_set_converter (converter_type, channels, error) ;
|
||||
} /* src_new */
|
||||
|
||||
SRC_STATE*
|
||||
src_clone (SRC_STATE* orig, int *error)
|
||||
{
|
||||
if (!orig)
|
||||
{
|
||||
if (error)
|
||||
*error = SRC_ERR_BAD_STATE ;
|
||||
return NULL ;
|
||||
}
|
||||
if (error)
|
||||
*error = SRC_ERR_NO_ERROR ;
|
||||
|
||||
SRC_STATE *state = orig->vt->copy (orig) ;
|
||||
if (!state)
|
||||
if (error)
|
||||
*error = SRC_ERR_MALLOC_FAILED ;
|
||||
|
||||
return state ;
|
||||
}
|
||||
|
||||
SRC_STATE*
|
||||
src_callback_new (src_callback_t func, int converter_type, int channels, int *error, void* cb_data)
|
||||
{ SRC_STATE *state ;
|
||||
|
||||
if (func == NULL)
|
||||
{ if (error)
|
||||
*error = SRC_ERR_BAD_CALLBACK ;
|
||||
return NULL ;
|
||||
} ;
|
||||
|
||||
if (error != NULL)
|
||||
*error = 0 ;
|
||||
|
||||
if ((state = src_new (converter_type, channels, error)) == NULL)
|
||||
return NULL ;
|
||||
|
||||
src_reset (state) ;
|
||||
|
||||
state->mode = SRC_MODE_CALLBACK ;
|
||||
state->callback_func = func ;
|
||||
state->user_callback_data = cb_data ;
|
||||
|
||||
return state ;
|
||||
} /* src_callback_new */
|
||||
|
||||
SRC_STATE *
|
||||
src_delete (SRC_STATE *state)
|
||||
{
|
||||
if (state)
|
||||
state->vt->close (state) ;
|
||||
|
||||
return NULL ;
|
||||
} /* src_state */
|
||||
|
||||
int
|
||||
src_process (SRC_STATE *state, SRC_DATA *data)
|
||||
{
|
||||
int error ;
|
||||
|
||||
if (state == NULL)
|
||||
return SRC_ERR_BAD_STATE ;
|
||||
|
||||
if (state->mode != SRC_MODE_PROCESS)
|
||||
return SRC_ERR_BAD_MODE ;
|
||||
|
||||
/* Check for valid SRC_DATA first. */
|
||||
if (data == NULL)
|
||||
return SRC_ERR_BAD_DATA ;
|
||||
|
||||
/* And that data_in and data_out are valid. */
|
||||
if ((data->data_in == NULL && data->input_frames > 0)
|
||||
|| (data->data_out == NULL && data->output_frames > 0))
|
||||
return SRC_ERR_BAD_DATA_PTR ;
|
||||
|
||||
/* Check src_ratio is in range. */
|
||||
if (is_bad_src_ratio (data->src_ratio))
|
||||
return SRC_ERR_BAD_SRC_RATIO ;
|
||||
|
||||
if (data->input_frames < 0)
|
||||
data->input_frames = 0 ;
|
||||
if (data->output_frames < 0)
|
||||
data->output_frames = 0 ;
|
||||
|
||||
if (data->data_in < data->data_out)
|
||||
{ if (data->data_in + data->input_frames * state->channels > data->data_out)
|
||||
{ /*-printf ("\n\ndata_in: %p data_out: %p\n",
|
||||
(void*) (data->data_in + data->input_frames * psrc->channels), (void*) data->data_out) ;-*/
|
||||
return SRC_ERR_DATA_OVERLAP ;
|
||||
} ;
|
||||
}
|
||||
else if (data->data_out + data->output_frames * state->channels > data->data_in)
|
||||
{ /*-printf ("\n\ndata_in : %p ouput frames: %ld data_out: %p\n", (void*) data->data_in, data->output_frames, (void*) data->data_out) ;
|
||||
|
||||
printf ("data_out: %p (%p) data_in: %p\n", (void*) data->data_out,
|
||||
(void*) (data->data_out + data->input_frames * psrc->channels), (void*) data->data_in) ;-*/
|
||||
return SRC_ERR_DATA_OVERLAP ;
|
||||
} ;
|
||||
|
||||
/* Set the input and output counts to zero. */
|
||||
data->input_frames_used = 0 ;
|
||||
data->output_frames_gen = 0 ;
|
||||
|
||||
/* Special case for when last_ratio has not been set. */
|
||||
if (state->last_ratio < (1.0 / SRC_MAX_RATIO))
|
||||
state->last_ratio = data->src_ratio ;
|
||||
|
||||
/* Now process. */
|
||||
if (fabs (state->last_ratio - data->src_ratio) < 1e-15)
|
||||
error = state->vt->const_process (state, data) ;
|
||||
else
|
||||
error = state->vt->vari_process (state, data) ;
|
||||
|
||||
return error ;
|
||||
} /* src_process */
|
||||
|
||||
long
|
||||
src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data)
|
||||
{
|
||||
SRC_DATA src_data ;
|
||||
|
||||
long output_frames_gen ;
|
||||
int error = 0 ;
|
||||
|
||||
if (state == NULL)
|
||||
return 0 ;
|
||||
|
||||
if (frames <= 0)
|
||||
return 0 ;
|
||||
|
||||
if (state->mode != SRC_MODE_CALLBACK)
|
||||
{ state->error = SRC_ERR_BAD_MODE ;
|
||||
return 0 ;
|
||||
} ;
|
||||
|
||||
if (state->callback_func == NULL)
|
||||
{ state->error = SRC_ERR_NULL_CALLBACK ;
|
||||
return 0 ;
|
||||
} ;
|
||||
|
||||
memset (&src_data, 0, sizeof (src_data)) ;
|
||||
|
||||
/* Check src_ratio is in range. */
|
||||
if (is_bad_src_ratio (src_ratio))
|
||||
{ state->error = SRC_ERR_BAD_SRC_RATIO ;
|
||||
return 0 ;
|
||||
} ;
|
||||
|
||||
/* Switch modes temporarily. */
|
||||
src_data.src_ratio = src_ratio ;
|
||||
src_data.data_out = data ;
|
||||
src_data.output_frames = frames ;
|
||||
|
||||
src_data.data_in = state->saved_data ;
|
||||
src_data.input_frames = state->saved_frames ;
|
||||
|
||||
output_frames_gen = 0 ;
|
||||
while (output_frames_gen < frames)
|
||||
{ /* Use a dummy array for the case where the callback function
|
||||
** returns without setting the ptr.
|
||||
*/
|
||||
float dummy [1] ;
|
||||
|
||||
if (src_data.input_frames == 0)
|
||||
{ float *ptr = dummy ;
|
||||
|
||||
src_data.input_frames = state->callback_func (state->user_callback_data, &ptr) ;
|
||||
src_data.data_in = ptr ;
|
||||
|
||||
if (src_data.input_frames == 0)
|
||||
src_data.end_of_input = 1 ;
|
||||
} ;
|
||||
|
||||
/*
|
||||
** Now call process function. However, we need to set the mode
|
||||
** to SRC_MODE_PROCESS first and when we return set it back to
|
||||
** SRC_MODE_CALLBACK.
|
||||
*/
|
||||
state->mode = SRC_MODE_PROCESS ;
|
||||
error = src_process (state, &src_data) ;
|
||||
state->mode = SRC_MODE_CALLBACK ;
|
||||
|
||||
if (error != 0)
|
||||
break ;
|
||||
|
||||
src_data.data_in += src_data.input_frames_used * state->channels ;
|
||||
src_data.input_frames -= src_data.input_frames_used ;
|
||||
|
||||
src_data.data_out += src_data.output_frames_gen * state->channels ;
|
||||
src_data.output_frames -= src_data.output_frames_gen ;
|
||||
|
||||
output_frames_gen += src_data.output_frames_gen ;
|
||||
|
||||
if (src_data.end_of_input == SRC_TRUE && src_data.output_frames_gen == 0)
|
||||
break ;
|
||||
} ;
|
||||
|
||||
state->saved_data = src_data.data_in ;
|
||||
state->saved_frames = src_data.input_frames ;
|
||||
|
||||
if (error != 0)
|
||||
{ state->error = (SRC_ERROR) error ;
|
||||
return 0 ;
|
||||
} ;
|
||||
|
||||
return output_frames_gen ;
|
||||
} /* src_callback_read */
|
||||
|
||||
/*==========================================================================
|
||||
*/
|
||||
|
||||
int
|
||||
src_set_ratio (SRC_STATE *state, double new_ratio)
|
||||
{
|
||||
if (state == NULL)
|
||||
return SRC_ERR_BAD_STATE ;
|
||||
|
||||
if (is_bad_src_ratio (new_ratio))
|
||||
return SRC_ERR_BAD_SRC_RATIO ;
|
||||
|
||||
state->last_ratio = new_ratio ;
|
||||
|
||||
return SRC_ERR_NO_ERROR ;
|
||||
} /* src_set_ratio */
|
||||
|
||||
int
|
||||
src_get_channels (SRC_STATE *state)
|
||||
{
|
||||
if (state == NULL)
|
||||
return -SRC_ERR_BAD_STATE ;
|
||||
|
||||
return state->channels ;
|
||||
} /* src_get_channels */
|
||||
|
||||
int
|
||||
src_reset (SRC_STATE *state)
|
||||
{
|
||||
if (state == NULL)
|
||||
return SRC_ERR_BAD_STATE ;
|
||||
|
||||
state->vt->reset (state) ;
|
||||
|
||||
state->last_position = 0.0 ;
|
||||
state->last_ratio = 0.0 ;
|
||||
|
||||
state->saved_data = NULL ;
|
||||
state->saved_frames = 0 ;
|
||||
|
||||
state->error = SRC_ERR_NO_ERROR ;
|
||||
|
||||
return SRC_ERR_NO_ERROR ;
|
||||
} /* src_reset */
|
||||
|
||||
/*==============================================================================
|
||||
** Control functions.
|
||||
*/
|
||||
|
||||
const char *
|
||||
src_get_name (int converter_type)
|
||||
{ const char *desc ;
|
||||
|
||||
if ((desc = sinc_get_name (converter_type)) != NULL)
|
||||
return desc ;
|
||||
|
||||
if ((desc = zoh_get_name (converter_type)) != NULL)
|
||||
return desc ;
|
||||
|
||||
if ((desc = linear_get_name (converter_type)) != NULL)
|
||||
return desc ;
|
||||
|
||||
return NULL ;
|
||||
} /* src_get_name */
|
||||
|
||||
const char *
|
||||
src_get_description (int converter_type)
|
||||
{ const char *desc ;
|
||||
|
||||
if ((desc = sinc_get_description (converter_type)) != NULL)
|
||||
return desc ;
|
||||
|
||||
if ((desc = zoh_get_description (converter_type)) != NULL)
|
||||
return desc ;
|
||||
|
||||
if ((desc = linear_get_description (converter_type)) != NULL)
|
||||
return desc ;
|
||||
|
||||
return NULL ;
|
||||
} /* src_get_description */
|
||||
|
||||
const char *
|
||||
src_get_version (void)
|
||||
{ return PACKAGE "-" VERSION " (c) 2002-2008 Erik de Castro Lopo" ;
|
||||
} /* src_get_version */
|
||||
|
||||
int
|
||||
src_is_valid_ratio (double ratio)
|
||||
{
|
||||
if (is_bad_src_ratio (ratio))
|
||||
return SRC_FALSE ;
|
||||
|
||||
return SRC_TRUE ;
|
||||
} /* src_is_valid_ratio */
|
||||
|
||||
/*==============================================================================
|
||||
** Error reporting functions.
|
||||
*/
|
||||
|
||||
int
|
||||
src_error (SRC_STATE *state)
|
||||
{ if (state)
|
||||
return state->error ;
|
||||
return SRC_ERR_NO_ERROR ;
|
||||
} /* src_error */
|
||||
|
||||
const char*
|
||||
src_strerror (int error)
|
||||
{
|
||||
switch (error)
|
||||
{ case SRC_ERR_NO_ERROR :
|
||||
return "No error." ;
|
||||
case SRC_ERR_MALLOC_FAILED :
|
||||
return "Malloc failed." ;
|
||||
case SRC_ERR_BAD_STATE :
|
||||
return "SRC_STATE pointer is NULL." ;
|
||||
case SRC_ERR_BAD_DATA :
|
||||
return "SRC_DATA pointer is NULL." ;
|
||||
case SRC_ERR_BAD_DATA_PTR :
|
||||
return "SRC_DATA->data_out or SRC_DATA->data_in is NULL." ;
|
||||
case SRC_ERR_NO_PRIVATE :
|
||||
return "Internal error. No private data." ;
|
||||
|
||||
case SRC_ERR_BAD_SRC_RATIO :
|
||||
return "SRC ratio outside [1/" SRC_MAX_RATIO_STR ", " SRC_MAX_RATIO_STR "] range." ;
|
||||
|
||||
case SRC_ERR_BAD_SINC_STATE :
|
||||
return "src_process() called without reset after end_of_input." ;
|
||||
case SRC_ERR_BAD_PROC_PTR :
|
||||
return "Internal error. No process pointer." ;
|
||||
case SRC_ERR_SHIFT_BITS :
|
||||
return "Internal error. SHIFT_BITS too large." ;
|
||||
case SRC_ERR_FILTER_LEN :
|
||||
return "Internal error. Filter length too large." ;
|
||||
case SRC_ERR_BAD_CONVERTER :
|
||||
return "Bad converter number." ;
|
||||
case SRC_ERR_BAD_CHANNEL_COUNT :
|
||||
return "Channel count must be >= 1." ;
|
||||
case SRC_ERR_SINC_BAD_BUFFER_LEN :
|
||||
return "Internal error. Bad buffer length. Please report this." ;
|
||||
case SRC_ERR_SIZE_INCOMPATIBILITY :
|
||||
return "Internal error. Input data / internal buffer size difference. Please report this." ;
|
||||
case SRC_ERR_BAD_PRIV_PTR :
|
||||
return "Internal error. Private pointer is NULL. Please report this." ;
|
||||
case SRC_ERR_DATA_OVERLAP :
|
||||
return "Input and output data arrays overlap." ;
|
||||
case SRC_ERR_BAD_CALLBACK :
|
||||
return "Supplied callback function pointer is NULL." ;
|
||||
case SRC_ERR_BAD_MODE :
|
||||
return "Calling mode differs from initialisation mode (ie process v callback)." ;
|
||||
case SRC_ERR_NULL_CALLBACK :
|
||||
return "Callback function pointer is NULL in src_callback_read ()." ;
|
||||
case SRC_ERR_NO_VARIABLE_RATIO :
|
||||
return "This converter only allows constant conversion ratios." ;
|
||||
case SRC_ERR_SINC_PREPARE_DATA_BAD_LEN :
|
||||
return "Internal error : Bad length in prepare_data ()." ;
|
||||
case SRC_ERR_BAD_INTERNAL_STATE :
|
||||
return "Error : Someone is trampling on my internal state." ;
|
||||
|
||||
case SRC_ERR_MAX_ERROR :
|
||||
return "Placeholder. No error defined for this error number." ;
|
||||
|
||||
default : break ;
|
||||
}
|
||||
|
||||
return NULL ;
|
||||
} /* src_strerror */
|
||||
|
||||
/*==============================================================================
|
||||
** Simple interface for performing a single conversion from input buffer to
|
||||
** output buffer at a fixed conversion ratio.
|
||||
*/
|
||||
|
||||
int
|
||||
src_simple (SRC_DATA *src_data, int converter, int channels)
|
||||
{ SRC_STATE *src_state ;
|
||||
int error ;
|
||||
|
||||
if ((src_state = src_new (converter, channels, &error)) == NULL)
|
||||
return error ;
|
||||
|
||||
src_data->end_of_input = 1 ; /* Only one buffer worth of input. */
|
||||
|
||||
error = src_process (src_state, src_data) ;
|
||||
|
||||
src_delete (src_state) ;
|
||||
|
||||
return error ;
|
||||
} /* src_simple */
|
||||
|
||||
void
|
||||
src_short_to_float_array (const short *in, float *out, int len)
|
||||
{
|
||||
while (len)
|
||||
{ len -- ;
|
||||
out [len] = (float) (in [len] / (1.0 * 0x8000)) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* src_short_to_float_array */
|
||||
|
||||
void
|
||||
src_float_to_short_array (const float *in, short *out, int len)
|
||||
{
|
||||
while (len)
|
||||
{ float scaled_value ;
|
||||
len -- ;
|
||||
scaled_value = in [len] * 32768.f ;
|
||||
if (scaled_value >= 32767.f)
|
||||
out [len] = 32767 ;
|
||||
else if (scaled_value <= -32768.f)
|
||||
out [len] = -32768 ;
|
||||
else
|
||||
out [len] = (short) (lrintf (scaled_value)) ;
|
||||
}
|
||||
} /* src_float_to_short_array */
|
||||
|
||||
void
|
||||
src_int_to_float_array (const int *in, float *out, int len)
|
||||
{
|
||||
while (len)
|
||||
{ len -- ;
|
||||
out [len] = (float) (in [len] / (8.0 * 0x10000000)) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* src_int_to_float_array */
|
||||
|
||||
void
|
||||
src_float_to_int_array (const float *in, int *out, int len)
|
||||
{ double scaled_value ;
|
||||
|
||||
while (len)
|
||||
{ len -- ;
|
||||
|
||||
scaled_value = in [len] * (8.0 * 0x10000000) ;
|
||||
#if CPU_CLIPS_POSITIVE == 0
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
{ out [len] = 0x7fffffff ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
#if CPU_CLIPS_NEGATIVE == 0
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
{ out [len] = -1 - 0x7fffffff ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
out [len] = (int) lrint (scaled_value) ;
|
||||
} ;
|
||||
|
||||
} /* src_float_to_int_array */
|
||||
|
||||
/*==============================================================================
|
||||
** Private functions.
|
||||
*/
|
||||
|
||||
static SRC_STATE *
|
||||
psrc_set_converter (int converter_type, int channels, int *error)
|
||||
{
|
||||
SRC_ERROR temp_error;
|
||||
SRC_STATE *state ;
|
||||
switch (converter_type)
|
||||
{
|
||||
#ifdef ENABLE_SINC_BEST_CONVERTER
|
||||
case SRC_SINC_BEST_QUALITY :
|
||||
state = sinc_state_new (converter_type, channels, &temp_error) ;
|
||||
break ;
|
||||
#endif
|
||||
#ifdef ENABLE_SINC_MEDIUM_CONVERTER
|
||||
case SRC_SINC_MEDIUM_QUALITY :
|
||||
state = sinc_state_new (converter_type, channels, &temp_error) ;
|
||||
break ;
|
||||
#endif
|
||||
#ifdef ENABLE_SINC_FAST_CONVERTER
|
||||
case SRC_SINC_FASTEST :
|
||||
state = sinc_state_new (converter_type, channels, &temp_error) ;
|
||||
break ;
|
||||
#endif
|
||||
case SRC_ZERO_ORDER_HOLD :
|
||||
state = zoh_state_new (channels, &temp_error) ;
|
||||
break ;
|
||||
case SRC_LINEAR :
|
||||
state = linear_state_new (channels, &temp_error) ;
|
||||
break ;
|
||||
default :
|
||||
temp_error = SRC_ERR_BAD_CONVERTER ;
|
||||
state = NULL ;
|
||||
break ;
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = (int) temp_error ;
|
||||
|
||||
return state ;
|
||||
} /* psrc_set_converter */
|
||||
|
|
@ -1,301 +0,0 @@
|
|||
/*
|
||||
** Copyright (c) 2002-2016, Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** All rights reserved.
|
||||
**
|
||||
** This code is released under 2-clause BSD license. Please see the
|
||||
** file at : https://github.com/libsndfile/libsamplerate/blob/master/COPYING
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
static SRC_ERROR linear_vari_process (SRC_STATE *state, SRC_DATA *data) ;
|
||||
static void linear_reset (SRC_STATE *state) ;
|
||||
static SRC_STATE *linear_copy (SRC_STATE *state) ;
|
||||
static void linear_close (SRC_STATE *state) ;
|
||||
|
||||
/*========================================================================================
|
||||
*/
|
||||
|
||||
#define LINEAR_MAGIC_MARKER MAKE_MAGIC ('l', 'i', 'n', 'e', 'a', 'r')
|
||||
|
||||
#define SRC_DEBUG 0
|
||||
|
||||
typedef struct
|
||||
{ int linear_magic_marker ;
|
||||
bool dirty ;
|
||||
long in_count, in_used ;
|
||||
long out_count, out_gen ;
|
||||
float *last_value ;
|
||||
} LINEAR_DATA ;
|
||||
|
||||
static SRC_STATE_VT linear_state_vt =
|
||||
{
|
||||
linear_vari_process,
|
||||
linear_vari_process,
|
||||
linear_reset,
|
||||
linear_copy,
|
||||
linear_close
|
||||
} ;
|
||||
|
||||
/*----------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static SRC_ERROR
|
||||
linear_vari_process (SRC_STATE *state, SRC_DATA *data)
|
||||
{ LINEAR_DATA *priv ;
|
||||
double src_ratio, input_index, rem ;
|
||||
int ch ;
|
||||
|
||||
if (data->input_frames <= 0)
|
||||
return SRC_ERR_NO_ERROR ;
|
||||
|
||||
if (state->private_data == NULL)
|
||||
return SRC_ERR_NO_PRIVATE ;
|
||||
|
||||
priv = (LINEAR_DATA*) state->private_data ;
|
||||
|
||||
if (!priv->dirty)
|
||||
{ /* If we have just been reset, set the last_value data. */
|
||||
for (ch = 0 ; ch < state->channels ; ch++)
|
||||
priv->last_value [ch] = data->data_in [ch] ;
|
||||
priv->dirty = true ;
|
||||
} ;
|
||||
|
||||
priv->in_count = data->input_frames * state->channels ;
|
||||
priv->out_count = data->output_frames * state->channels ;
|
||||
priv->in_used = priv->out_gen = 0 ;
|
||||
|
||||
src_ratio = state->last_ratio ;
|
||||
|
||||
if (is_bad_src_ratio (src_ratio))
|
||||
return SRC_ERR_BAD_INTERNAL_STATE ;
|
||||
|
||||
input_index = state->last_position ;
|
||||
|
||||
/* Calculate samples before first sample in input array. */
|
||||
while (input_index < 1.0 && priv->out_gen < priv->out_count)
|
||||
{
|
||||
if (priv->in_used + state->channels * (1.0 + input_index) >= priv->in_count)
|
||||
break ;
|
||||
|
||||
if (priv->out_count > 0 && fabs (state->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
|
||||
src_ratio = state->last_ratio + priv->out_gen * (data->src_ratio - state->last_ratio) / priv->out_count ;
|
||||
|
||||
for (ch = 0 ; ch < state->channels ; ch++)
|
||||
{ data->data_out [priv->out_gen] = (float) (priv->last_value [ch] + input_index *
|
||||
((double) data->data_in [ch] - priv->last_value [ch])) ;
|
||||
priv->out_gen ++ ;
|
||||
} ;
|
||||
|
||||
/* Figure out the next index. */
|
||||
input_index += 1.0 / src_ratio ;
|
||||
} ;
|
||||
|
||||
rem = fmod_one (input_index) ;
|
||||
priv->in_used += state->channels * lrint (input_index - rem) ;
|
||||
input_index = rem ;
|
||||
|
||||
/* Main processing loop. */
|
||||
while (priv->out_gen < priv->out_count && priv->in_used + state->channels * input_index < priv->in_count)
|
||||
{
|
||||
if (priv->out_count > 0 && fabs (state->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
|
||||
src_ratio = state->last_ratio + priv->out_gen * (data->src_ratio - state->last_ratio) / priv->out_count ;
|
||||
|
||||
#if SRC_DEBUG
|
||||
if (priv->in_used < state->channels && input_index < 1.0)
|
||||
{ printf ("Whoops!!!! in_used : %ld channels : %d input_index : %f\n", priv->in_used, state->channels, input_index) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
#endif
|
||||
|
||||
for (ch = 0 ; ch < state->channels ; ch++)
|
||||
{ data->data_out [priv->out_gen] = (float) (data->data_in [priv->in_used - state->channels + ch] + input_index *
|
||||
((double) data->data_in [priv->in_used + ch] - data->data_in [priv->in_used - state->channels + ch])) ;
|
||||
priv->out_gen ++ ;
|
||||
} ;
|
||||
|
||||
/* Figure out the next index. */
|
||||
input_index += 1.0 / src_ratio ;
|
||||
rem = fmod_one (input_index) ;
|
||||
|
||||
priv->in_used += state->channels * lrint (input_index - rem) ;
|
||||
input_index = rem ;
|
||||
} ;
|
||||
|
||||
if (priv->in_used > priv->in_count)
|
||||
{ input_index += (priv->in_used - priv->in_count) / state->channels ;
|
||||
priv->in_used = priv->in_count ;
|
||||
} ;
|
||||
|
||||
state->last_position = input_index ;
|
||||
|
||||
if (priv->in_used > 0)
|
||||
for (ch = 0 ; ch < state->channels ; ch++)
|
||||
priv->last_value [ch] = data->data_in [priv->in_used - state->channels + ch] ;
|
||||
|
||||
/* Save current ratio rather then target ratio. */
|
||||
state->last_ratio = src_ratio ;
|
||||
|
||||
data->input_frames_used = priv->in_used / state->channels ;
|
||||
data->output_frames_gen = priv->out_gen / state->channels ;
|
||||
|
||||
return SRC_ERR_NO_ERROR ;
|
||||
} /* linear_vari_process */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
const char*
|
||||
linear_get_name (int src_enum)
|
||||
{
|
||||
if (src_enum == SRC_LINEAR)
|
||||
return "Linear Interpolator" ;
|
||||
|
||||
return NULL ;
|
||||
} /* linear_get_name */
|
||||
|
||||
const char*
|
||||
linear_get_description (int src_enum)
|
||||
{
|
||||
if (src_enum == SRC_LINEAR)
|
||||
return "Linear interpolator, very fast, poor quality." ;
|
||||
|
||||
return NULL ;
|
||||
} /* linear_get_descrition */
|
||||
|
||||
static LINEAR_DATA *
|
||||
linear_data_new (int channels)
|
||||
{
|
||||
assert (channels > 0) ;
|
||||
|
||||
LINEAR_DATA *priv = (LINEAR_DATA *) calloc (1, sizeof (LINEAR_DATA)) ;
|
||||
if (priv)
|
||||
{
|
||||
priv->linear_magic_marker = LINEAR_MAGIC_MARKER ;
|
||||
priv->last_value = (float *) calloc (channels, sizeof (float)) ;
|
||||
if (!priv->last_value)
|
||||
{
|
||||
free (priv) ;
|
||||
priv = NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
return priv ;
|
||||
}
|
||||
|
||||
SRC_STATE *
|
||||
linear_state_new (int channels, SRC_ERROR *error)
|
||||
{
|
||||
assert (channels > 0) ;
|
||||
assert (error != NULL) ;
|
||||
|
||||
SRC_STATE *state = (SRC_STATE *) calloc (1, sizeof (SRC_STATE)) ;
|
||||
if (!state)
|
||||
{
|
||||
*error = SRC_ERR_MALLOC_FAILED ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
state->channels = channels ;
|
||||
state->mode = SRC_MODE_PROCESS ;
|
||||
|
||||
state->private_data = linear_data_new (state->channels) ;
|
||||
if (!state->private_data)
|
||||
{
|
||||
free (state) ;
|
||||
*error = SRC_ERR_MALLOC_FAILED ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
state->vt = &linear_state_vt ;
|
||||
|
||||
linear_reset (state) ;
|
||||
|
||||
*error = SRC_ERR_NO_ERROR ;
|
||||
|
||||
return state ;
|
||||
}
|
||||
|
||||
/*===================================================================================
|
||||
*/
|
||||
|
||||
static void
|
||||
linear_reset (SRC_STATE *state)
|
||||
{ LINEAR_DATA *priv = NULL ;
|
||||
|
||||
priv = (LINEAR_DATA*) state->private_data ;
|
||||
if (priv == NULL)
|
||||
return ;
|
||||
|
||||
priv->dirty = false ;
|
||||
memset (priv->last_value, 0, sizeof (priv->last_value [0]) * state->channels) ;
|
||||
|
||||
return ;
|
||||
} /* linear_reset */
|
||||
|
||||
SRC_STATE *
|
||||
linear_copy (SRC_STATE *state)
|
||||
{
|
||||
assert (state != NULL) ;
|
||||
|
||||
if (state->private_data == NULL)
|
||||
return NULL ;
|
||||
|
||||
SRC_STATE *to = (SRC_STATE *) calloc (1, sizeof (SRC_STATE)) ;
|
||||
if (!state)
|
||||
return NULL ;
|
||||
memcpy (to, state, sizeof (SRC_STATE)) ;
|
||||
|
||||
LINEAR_DATA* from_priv = (LINEAR_DATA*) state->private_data ;
|
||||
LINEAR_DATA *to_priv = (LINEAR_DATA *) calloc (1, sizeof (LINEAR_DATA)) ;
|
||||
if (!to_priv)
|
||||
{
|
||||
free (to) ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
memcpy (to_priv, from_priv, sizeof (LINEAR_DATA)) ;
|
||||
to_priv->last_value = (float *) malloc (sizeof (float) * state->channels) ;
|
||||
if (!to_priv->last_value)
|
||||
{
|
||||
free (to) ;
|
||||
free (to_priv) ;
|
||||
return NULL ;
|
||||
}
|
||||
memcpy (to_priv->last_value, from_priv->last_value, sizeof (float) * state->channels) ;
|
||||
|
||||
to->private_data = to_priv ;
|
||||
|
||||
return to ;
|
||||
} /* linear_copy */
|
||||
|
||||
static void
|
||||
linear_close (SRC_STATE *state)
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
LINEAR_DATA *linear = (LINEAR_DATA *) state->private_data ;
|
||||
if (linear)
|
||||
{
|
||||
if (linear->last_value)
|
||||
{
|
||||
free (linear->last_value) ;
|
||||
linear->last_value = NULL ;
|
||||
}
|
||||
free (linear) ;
|
||||
linear = NULL ;
|
||||
}
|
||||
free (state) ;
|
||||
state = NULL ;
|
||||
}
|
||||
} /* linear_close */
|
File diff suppressed because it is too large
Load diff
|
@ -1,290 +0,0 @@
|
|||
/*
|
||||
** Copyright (c) 2002-2016, Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** All rights reserved.
|
||||
**
|
||||
** This code is released under 2-clause BSD license. Please see the
|
||||
** file at : https://github.com/libsndfile/libsamplerate/blob/master/COPYING
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
static SRC_ERROR zoh_vari_process (SRC_STATE *state, SRC_DATA *data) ;
|
||||
static void zoh_reset (SRC_STATE *state) ;
|
||||
static SRC_STATE *zoh_copy (SRC_STATE *state) ;
|
||||
static void zoh_close (SRC_STATE *state) ;
|
||||
|
||||
/*========================================================================================
|
||||
*/
|
||||
|
||||
#define ZOH_MAGIC_MARKER MAKE_MAGIC ('s', 'r', 'c', 'z', 'o', 'h')
|
||||
|
||||
typedef struct
|
||||
{ int zoh_magic_marker ;
|
||||
bool dirty ;
|
||||
long in_count, in_used ;
|
||||
long out_count, out_gen ;
|
||||
float *last_value ;
|
||||
} ZOH_DATA ;
|
||||
|
||||
static SRC_STATE_VT zoh_state_vt =
|
||||
{
|
||||
zoh_vari_process,
|
||||
zoh_vari_process,
|
||||
zoh_reset,
|
||||
zoh_copy,
|
||||
zoh_close
|
||||
} ;
|
||||
|
||||
/*----------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static SRC_ERROR
|
||||
zoh_vari_process (SRC_STATE *state, SRC_DATA *data)
|
||||
{ ZOH_DATA *priv ;
|
||||
double src_ratio, input_index, rem ;
|
||||
int ch ;
|
||||
|
||||
if (data->input_frames <= 0)
|
||||
return SRC_ERR_NO_ERROR ;
|
||||
|
||||
if (state->private_data == NULL)
|
||||
return SRC_ERR_NO_PRIVATE ;
|
||||
|
||||
priv = (ZOH_DATA*) state->private_data ;
|
||||
|
||||
if (!priv->dirty)
|
||||
{ /* If we have just been reset, set the last_value data. */
|
||||
for (ch = 0 ; ch < state->channels ; ch++)
|
||||
priv->last_value [ch] = data->data_in [ch] ;
|
||||
priv->dirty = true ;
|
||||
} ;
|
||||
|
||||
priv->in_count = data->input_frames * state->channels ;
|
||||
priv->out_count = data->output_frames * state->channels ;
|
||||
priv->in_used = priv->out_gen = 0 ;
|
||||
|
||||
src_ratio = state->last_ratio ;
|
||||
|
||||
if (is_bad_src_ratio (src_ratio))
|
||||
return SRC_ERR_BAD_INTERNAL_STATE ;
|
||||
|
||||
input_index = state->last_position ;
|
||||
|
||||
/* Calculate samples before first sample in input array. */
|
||||
while (input_index < 1.0 && priv->out_gen < priv->out_count)
|
||||
{
|
||||
if (priv->in_used + state->channels * input_index >= priv->in_count)
|
||||
break ;
|
||||
|
||||
if (priv->out_count > 0 && fabs (state->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
|
||||
src_ratio = state->last_ratio + priv->out_gen * (data->src_ratio - state->last_ratio) / priv->out_count ;
|
||||
|
||||
for (ch = 0 ; ch < state->channels ; ch++)
|
||||
{ data->data_out [priv->out_gen] = priv->last_value [ch] ;
|
||||
priv->out_gen ++ ;
|
||||
} ;
|
||||
|
||||
/* Figure out the next index. */
|
||||
input_index += 1.0 / src_ratio ;
|
||||
} ;
|
||||
|
||||
rem = fmod_one (input_index) ;
|
||||
priv->in_used += state->channels * lrint (input_index - rem) ;
|
||||
input_index = rem ;
|
||||
|
||||
/* Main processing loop. */
|
||||
while (priv->out_gen < priv->out_count && priv->in_used + state->channels * input_index <= priv->in_count)
|
||||
{
|
||||
if (priv->out_count > 0 && fabs (state->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
|
||||
src_ratio = state->last_ratio + priv->out_gen * (data->src_ratio - state->last_ratio) / priv->out_count ;
|
||||
|
||||
for (ch = 0 ; ch < state->channels ; ch++)
|
||||
{ data->data_out [priv->out_gen] = data->data_in [priv->in_used - state->channels + ch] ;
|
||||
priv->out_gen ++ ;
|
||||
} ;
|
||||
|
||||
/* Figure out the next index. */
|
||||
input_index += 1.0 / src_ratio ;
|
||||
rem = fmod_one (input_index) ;
|
||||
|
||||
priv->in_used += state->channels * lrint (input_index - rem) ;
|
||||
input_index = rem ;
|
||||
} ;
|
||||
|
||||
if (priv->in_used > priv->in_count)
|
||||
{ input_index += (priv->in_used - priv->in_count) / state->channels ;
|
||||
priv->in_used = priv->in_count ;
|
||||
} ;
|
||||
|
||||
state->last_position = input_index ;
|
||||
|
||||
if (priv->in_used > 0)
|
||||
for (ch = 0 ; ch < state->channels ; ch++)
|
||||
priv->last_value [ch] = data->data_in [priv->in_used - state->channels + ch] ;
|
||||
|
||||
/* Save current ratio rather then target ratio. */
|
||||
state->last_ratio = src_ratio ;
|
||||
|
||||
data->input_frames_used = priv->in_used / state->channels ;
|
||||
data->output_frames_gen = priv->out_gen / state->channels ;
|
||||
|
||||
return SRC_ERR_NO_ERROR ;
|
||||
} /* zoh_vari_process */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
const char*
|
||||
zoh_get_name (int src_enum)
|
||||
{
|
||||
if (src_enum == SRC_ZERO_ORDER_HOLD)
|
||||
return "ZOH Interpolator" ;
|
||||
|
||||
return NULL ;
|
||||
} /* zoh_get_name */
|
||||
|
||||
const char*
|
||||
zoh_get_description (int src_enum)
|
||||
{
|
||||
if (src_enum == SRC_ZERO_ORDER_HOLD)
|
||||
return "Zero order hold interpolator, very fast, poor quality." ;
|
||||
|
||||
return NULL ;
|
||||
} /* zoh_get_descrition */
|
||||
|
||||
static ZOH_DATA *
|
||||
zoh_data_new (int channels)
|
||||
{
|
||||
assert (channels > 0) ;
|
||||
|
||||
ZOH_DATA *priv = (ZOH_DATA *) calloc (1, sizeof (ZOH_DATA)) ;
|
||||
if (priv)
|
||||
{
|
||||
priv->zoh_magic_marker = ZOH_MAGIC_MARKER ;
|
||||
priv->last_value = (float *) calloc (channels, sizeof (float)) ;
|
||||
if (!priv->last_value)
|
||||
{
|
||||
free (priv) ;
|
||||
priv = NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
return priv ;
|
||||
}
|
||||
|
||||
SRC_STATE *
|
||||
zoh_state_new (int channels, SRC_ERROR *error)
|
||||
{
|
||||
assert (channels > 0) ;
|
||||
assert (error != NULL) ;
|
||||
|
||||
SRC_STATE *state = (SRC_STATE *) calloc (1, sizeof (SRC_STATE)) ;
|
||||
if (!state)
|
||||
{
|
||||
*error = SRC_ERR_MALLOC_FAILED ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
state->channels = channels ;
|
||||
state->mode = SRC_MODE_PROCESS ;
|
||||
|
||||
state->private_data = zoh_data_new (state->channels) ;
|
||||
if (!state->private_data)
|
||||
{
|
||||
free (state) ;
|
||||
*error = SRC_ERR_MALLOC_FAILED ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
state->vt = &zoh_state_vt ;
|
||||
|
||||
zoh_reset (state) ;
|
||||
|
||||
*error = SRC_ERR_NO_ERROR ;
|
||||
|
||||
return state ;
|
||||
}
|
||||
|
||||
/*===================================================================================
|
||||
*/
|
||||
|
||||
static void
|
||||
zoh_reset (SRC_STATE *state)
|
||||
{ ZOH_DATA *priv ;
|
||||
|
||||
priv = (ZOH_DATA*) state->private_data ;
|
||||
if (priv == NULL)
|
||||
return ;
|
||||
|
||||
priv->dirty = false ;
|
||||
memset (priv->last_value, 0, sizeof (float) * state->channels) ;
|
||||
|
||||
return ;
|
||||
} /* zoh_reset */
|
||||
|
||||
static SRC_STATE *
|
||||
zoh_copy (SRC_STATE *state)
|
||||
{
|
||||
assert (state != NULL) ;
|
||||
|
||||
if (state->private_data == NULL)
|
||||
return NULL ;
|
||||
|
||||
SRC_STATE *to = (SRC_STATE *) calloc (1, sizeof (SRC_STATE)) ;
|
||||
if (!state)
|
||||
return NULL ;
|
||||
memcpy (to, state, sizeof (SRC_STATE)) ;
|
||||
|
||||
ZOH_DATA* from_priv = (ZOH_DATA*) state->private_data ;
|
||||
ZOH_DATA *to_priv = (ZOH_DATA *) calloc (1, sizeof (ZOH_DATA)) ;
|
||||
if (!to_priv)
|
||||
{
|
||||
free (to) ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
memcpy (to_priv, from_priv, sizeof (ZOH_DATA)) ;
|
||||
to_priv->last_value = (float *) malloc (sizeof (float) * state->channels) ;
|
||||
if (!to_priv->last_value)
|
||||
{
|
||||
free (to) ;
|
||||
free (to_priv) ;
|
||||
return NULL ;
|
||||
}
|
||||
memcpy (to_priv->last_value, from_priv->last_value, sizeof (float) * state->channels) ;
|
||||
|
||||
to->private_data = to_priv ;
|
||||
|
||||
return to ;
|
||||
} /* zoh_copy */
|
||||
|
||||
static void
|
||||
zoh_close (SRC_STATE *state)
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
ZOH_DATA *zoh = (ZOH_DATA *) state->private_data ;
|
||||
if (zoh)
|
||||
{
|
||||
if (zoh->last_value)
|
||||
{
|
||||
free (zoh->last_value) ;
|
||||
zoh->last_value = NULL ;
|
||||
}
|
||||
free (zoh) ;
|
||||
zoh = NULL ;
|
||||
}
|
||||
free (state) ;
|
||||
state = NULL ;
|
||||
}
|
||||
} /* zoh_close */
|
|
@ -85,8 +85,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "updater", "src\updater\upda
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vixl", "dep\vixl\vixl.vcxproj", "{8906836E-F06E-46E8-B11A-74E5E8C7B8FB}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libsamplerate", "dep\libsamplerate\libsamplerate.vcxproj", "{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "duckstation-nogui", "src\duckstation-nogui\duckstation-nogui.vcxproj", "{0A172B2E-DC67-49FC-A4C1-975F93C586C4}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{6245DEC8-D2DA-47EE-A373-CBD6FCF3ECE6} = {6245DEC8-D2DA-47EE-A373-CBD6FCF3ECE6}
|
||||
|
@ -783,36 +781,6 @@ Global
|
|||
{8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.ReleaseUWP|ARM64.ActiveCfg = ReleaseUWP|ARM64
|
||||
{8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.ReleaseUWP|x64.ActiveCfg = ReleaseUWP|x64
|
||||
{8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.ReleaseUWP|x86.ActiveCfg = ReleaseUWP|Win32
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.Debug|x64.Build.0 = Debug|x64
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.Debug|x86.Build.0 = Debug|Win32
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.DebugFast|ARM64.ActiveCfg = DebugFast|ARM64
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.DebugFast|ARM64.Build.0 = DebugFast|ARM64
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.DebugFast|x64.ActiveCfg = DebugFast|x64
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.DebugFast|x64.Build.0 = DebugFast|x64
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.DebugFast|x86.ActiveCfg = DebugFast|Win32
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.DebugFast|x86.Build.0 = DebugFast|Win32
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.DebugUWP|ARM64.ActiveCfg = DebugUWP|ARM64
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.DebugUWP|x64.ActiveCfg = DebugUWP|x64
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.DebugUWP|x86.ActiveCfg = DebugUWP|Win32
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.Release|x64.ActiveCfg = Release|x64
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.Release|x64.Build.0 = Release|x64
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.Release|x86.ActiveCfg = Release|Win32
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.Release|x86.Build.0 = Release|Win32
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.ReleaseLTCG|ARM64.ActiveCfg = ReleaseLTCG|ARM64
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.ReleaseLTCG|ARM64.Build.0 = ReleaseLTCG|ARM64
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.ReleaseLTCG|x64.ActiveCfg = ReleaseLTCG|x64
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.ReleaseLTCG|x64.Build.0 = ReleaseLTCG|x64
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.ReleaseLTCG|x86.ActiveCfg = ReleaseLTCG|Win32
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.ReleaseLTCG|x86.Build.0 = ReleaseLTCG|Win32
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.ReleaseUWP|ARM64.ActiveCfg = ReleaseUWP|ARM64
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.ReleaseUWP|x64.ActiveCfg = ReleaseUWP|x64
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3}.ReleaseUWP|x86.ActiveCfg = ReleaseUWP|Win32
|
||||
{0A172B2E-DC67-49FC-A4C1-975F93C586C4}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{0A172B2E-DC67-49FC-A4C1-975F93C586C4}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{0A172B2E-DC67-49FC-A4C1-975F93C586C4}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
|
@ -1047,7 +1015,6 @@ Global
|
|||
{4266505B-DBAF-484B-AB31-B53B9C8235B3} = {BA490C0E-497D-4634-A21E-E65012006385}
|
||||
{7F909E29-4808-4BD9-A60C-56C51A3AAEC2} = {BA490C0E-497D-4634-A21E-E65012006385}
|
||||
{8906836E-F06E-46E8-B11A-74E5E8C7B8FB} = {BA490C0E-497D-4634-A21E-E65012006385}
|
||||
{39F0ADFF-3A84-470D-9CF0-CA49E164F2F3} = {BA490C0E-497D-4634-A21E-E65012006385}
|
||||
{4BA0A6D4-3AE1-42B2-9347-096FD023FF64} = {BA490C0E-497D-4634-A21E-E65012006385}
|
||||
{E4357877-D459-45C7-B8F6-DCBB587BB528} = {BA490C0E-497D-4634-A21E-E65012006385}
|
||||
{8BE398E6-B882-4248-9065-FECC8728E038} = {BA490C0E-497D-4634-A21E-E65012006385}
|
||||
|
|
Loading…
Reference in a new issue