mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-25 23:25:41 +00:00
Remove libsamplerate dependency
This commit is contained in:
parent
14bc2a1164
commit
9058a79184
|
@ -1,7 +1,6 @@
|
|||
add_subdirectory(glad)
|
||||
add_subdirectory(imgui)
|
||||
add_subdirectory(libcue)
|
||||
add_subdirectory(libsamplerate)
|
||||
add_subdirectory(nativefiledialog)
|
||||
add_subdirectory(stb)
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Erik de Castro Lopo <erikd@mega-nerd.com>
|
|
@ -1,19 +0,0 @@
|
|||
set(SRCS
|
||||
include/samplerate.h
|
||||
src/common.h
|
||||
src/config.h
|
||||
src/fastest_coeffs.h
|
||||
src/float_cast.h
|
||||
src/high_qual_coeffs.h
|
||||
src/mid_qual_coeffs.h
|
||||
src/samplerate.c
|
||||
src/src_linear.c
|
||||
src/src_sinc.c
|
||||
src/src_zoh.c
|
||||
)
|
||||
|
||||
add_library(libsamplerate ${SRCS})
|
||||
target_include_directories(libsamplerate PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
target_include_directories(libsamplerate INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
set_target_properties(libsamplerate PROPERTIES LINKER_LANGUAGE C)
|
||||
|
|
@ -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.
|
File diff suppressed because it is too large
Load diff
|
@ -1,40 +0,0 @@
|
|||
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,50 +0,0 @@
|
|||
This is libsamplerate, 0.1.9
|
||||
|
||||
libsamplerate (also known as Secret Rabbit Code) is a library for
|
||||
perfroming sample rate conversion of audio data.
|
||||
|
||||
The src/ directory contains the source code for library itself.
|
||||
|
||||
The doc/ directory contains the libsamplerate documentation.
|
||||
|
||||
The examples/ directory contains examples of how to write code using
|
||||
libsamplerate.
|
||||
|
||||
The tests/ directory contains programs which link against
|
||||
libsamplerate and test its functionality.
|
||||
|
||||
The Win32/ directory contains files and documentation to allow
|
||||
libsamplerate to compile under Win32 with the Microsoft Visual C++
|
||||
compiler.
|
||||
|
||||
Win32
|
||||
-----
|
||||
There are detailed instructions for building libsamplerate on Win32
|
||||
in the file
|
||||
|
||||
doc/win32.html
|
||||
|
||||
|
||||
MacOSX
|
||||
------
|
||||
Building on MacOSX should be the same as building it on any other
|
||||
Unix.
|
||||
|
||||
|
||||
OTHER PLATFORMS
|
||||
---------------
|
||||
To compile libsamplerate on platforms which have a Bourne Shell compatible
|
||||
shell, an ANSI C compiler and a make utility should require no more that
|
||||
the following three commands :
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
|
||||
CONTACTS
|
||||
--------
|
||||
|
||||
libsamplerate was written by Erik de Castro Lopo (erikd AT mega-nerd DOT com).
|
||||
The libsamplerate home page is at :
|
||||
|
||||
http://www.mega-nerd.com/libsamplerate/
|
||||
|
|
@ -1,183 +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/erikd/libsamplerate/blob/master/COPYING
|
||||
*/
|
||||
|
||||
/*
|
||||
** API documentation is available here:
|
||||
** http://www.mega-nerd.com/SRC/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) ;
|
||||
|
||||
/*
|
||||
** 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,368 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="DebugFast|Win32">
|
||||
<Configuration>DebugFast</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="DebugFast|x64">
|
||||
<Configuration>DebugFast</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="ReleaseLTCG|Win32">
|
||||
<Configuration>ReleaseLTCG</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="ReleaseLTCG|x64">
|
||||
<Configuration>ReleaseLTCG</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\samplerate.h" />
|
||||
<ClInclude Include="src\common.h" />
|
||||
<ClInclude Include="src\config.h" />
|
||||
<ClInclude Include="src\fastest_coeffs.h" />
|
||||
<ClInclude Include="src\float_cast.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>{2F2A2B7B-60B3-478C-921E-3633B3C45C3F}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>libsamplerate</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseLTCG|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseLTCG|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseLTCG|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseLTCG|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)build\$(ProjectName)-$(Platform)-$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)build\$(ProjectName)-$(Platform)-$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)-$(Platform)-$(Configuration)</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<IntDir>$(SolutionDir)build\$(ProjectName)-$(Platform)-$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)-$(Platform)-$(Configuration)</TargetName>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)build\$(ProjectName)-$(Platform)-$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)build\$(ProjectName)-$(Platform)-$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)build\$(ProjectName)-$(Platform)-$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)-$(Platform)-$(Configuration)</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|x64'">
|
||||
<IntDir>$(SolutionDir)build\$(ProjectName)-$(Platform)-$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)-$(Platform)-$(Configuration)</TargetName>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)build\$(ProjectName)-$(Platform)-$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)build\$(ProjectName)-$(Platform)-$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)build\$(ProjectName)-$(Platform)-$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)-$(Platform)-$(Configuration)</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseLTCG|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)build\$(ProjectName)-$(Platform)-$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)build\$(ProjectName)-$(Platform)-$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)-$(Platform)-$(Configuration)</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IntDir>$(SolutionDir)build\$(ProjectName)-$(Platform)-$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)-$(Platform)-$(Configuration)</TargetName>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)build\$(ProjectName)-$(Platform)-$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseLTCG|x64'">
|
||||
<IntDir>$(SolutionDir)build\$(ProjectName)-$(Platform)-$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)-$(Platform)-$(Configuration)</TargetName>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)build\$(ProjectName)-$(Platform)-$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)include;$(ProjectDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>SDL2.lib;SDL2main.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)dep\lib32-debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)include;$(ProjectDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>SDL2.lib;SDL2main.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)dep\lib64-debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_ITERATOR_DEBUG_LEVEL=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUGFAST;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)include;$(ProjectDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<SupportJustMyCode>false</SupportJustMyCode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>SDL2.lib;SDL2main.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)dep\lib32-debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_ITERATOR_DEBUG_LEVEL=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUGFAST;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)include;$(ProjectDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<SupportJustMyCode>false</SupportJustMyCode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>SDL2.lib;SDL2main.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)dep\lib64-debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)include;$(ProjectDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>SDL2.lib;SDL2main.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)dep\lib32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseLTCG|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)include;$(ProjectDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>SDL2.lib;SDL2main.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)dep\lib32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)include;$(ProjectDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>SDL2.lib;SDL2main.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)dep\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseLTCG|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)include;$(ProjectDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>SDL2.lib;SDL2main.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)dep\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -1,18 +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\fastest_coeffs.h" />
|
||||
<ClInclude Include="src\float_cast.h" />
|
||||
<ClInclude Include="src\high_qual_coeffs.h" />
|
||||
<ClInclude Include="src\mid_qual_coeffs.h" />
|
||||
<ClInclude Include="src\common.h" />
|
||||
<ClInclude Include="src\config.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,160 +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/erikd/libsamplerate/blob/master/COPYING
|
||||
*/
|
||||
|
||||
#ifndef COMMON_H_INCLUDED
|
||||
#define COMMON_H_INCLUDED
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#elif (SIZEOF_INT == 4)
|
||||
typedef int int32_t ;
|
||||
#elif (SIZEOF_LONG == 4)
|
||||
typedef long int32_t ;
|
||||
#endif
|
||||
|
||||
#define SRC_MAX_RATIO 256
|
||||
#define SRC_MAX_RATIO_STR "256"
|
||||
|
||||
#define SRC_MIN_RATIO_DIFF (1e-20)
|
||||
|
||||
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
#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,
|
||||
|
||||
SRC_MODE_PROCESS = 555,
|
||||
SRC_MODE_CALLBACK = 556
|
||||
} ;
|
||||
|
||||
enum
|
||||
{ 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
|
||||
} ;
|
||||
|
||||
typedef struct SRC_PRIVATE_tag
|
||||
{ double last_ratio, last_position ;
|
||||
|
||||
int error ;
|
||||
int channels ;
|
||||
|
||||
/* SRC_MODE_PROCESS or SRC_MODE_CALLBACK */
|
||||
int mode ;
|
||||
|
||||
/* Pointer to data to converter specific data. */
|
||||
void *private_data ;
|
||||
|
||||
/* Varispeed process function. */
|
||||
int (*vari_process) (struct SRC_PRIVATE_tag *psrc, SRC_DATA *data) ;
|
||||
|
||||
/* Constant speed process function. */
|
||||
int (*const_process) (struct SRC_PRIVATE_tag *psrc, SRC_DATA *data) ;
|
||||
|
||||
/* State reset. */
|
||||
void (*reset) (struct SRC_PRIVATE_tag *psrc) ;
|
||||
|
||||
/* Data specific to SRC_MODE_CALLBACK. */
|
||||
src_callback_t callback_func ;
|
||||
void *user_callback_data ;
|
||||
long saved_frames ;
|
||||
const float *saved_data ;
|
||||
} SRC_PRIVATE ;
|
||||
|
||||
/* In src_sinc.c */
|
||||
const char* sinc_get_name (int src_enum) ;
|
||||
const char* sinc_get_description (int src_enum) ;
|
||||
|
||||
int sinc_set_converter (SRC_PRIVATE *psrc, int src_enum) ;
|
||||
|
||||
/* In src_linear.c */
|
||||
const char* linear_get_name (int src_enum) ;
|
||||
const char* linear_get_description (int src_enum) ;
|
||||
|
||||
int linear_set_converter (SRC_PRIVATE *psrc, int src_enum) ;
|
||||
|
||||
/* In src_zoh.c */
|
||||
const char* zoh_get_name (int src_enum) ;
|
||||
const char* zoh_get_description (int src_enum) ;
|
||||
|
||||
int zoh_set_converter (SRC_PRIVATE *psrc, int src_enum) ;
|
||||
|
||||
/*----------------------------------------------------------
|
||||
** 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 */
|
||||
|
|
@ -1,197 +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/erikd/libsamplerate/blob/master/COPYING
|
||||
*/
|
||||
|
||||
/*
|
||||
** This is the Win32 specific config.h header file.
|
||||
**
|
||||
** On Unix (including MacOSX), this header file is automatically generated
|
||||
** during the configure process while on Win32 this has to be hand edited
|
||||
** to keep it up to date.
|
||||
**
|
||||
** This is also a good file to add Win32 specific things.
|
||||
*/
|
||||
|
||||
/*
|
||||
** MSVC++ assumes that all floating point constants without a trailing
|
||||
** letter 'f' are double precision.
|
||||
**
|
||||
** If this assumption is incorrect and one of these floating point constants
|
||||
** is assigned to a float variable MSVC++ generates a warning.
|
||||
**
|
||||
** Since there are currently about 25000 of these warnings generated in
|
||||
** src/src_sinc.c this slows down compile times considerably. The
|
||||
** following #pragma disables the warning.
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4305)
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
** Normal #defines follow.
|
||||
*/
|
||||
|
||||
/* Set to 1 if the compile is GNU GCC. */
|
||||
#define COMPILER_IS_GCC 0
|
||||
|
||||
/* 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
|
||||
|
||||
/* Set to 1 to enable debugging. */
|
||||
#define ENABLE_DEBUG 0
|
||||
|
||||
/* Major version of GCC or 3 otherwise. */
|
||||
/* #undef GCC_MAJOR_VERSION */
|
||||
|
||||
/* Define to 1 if you have the `alarm' function. */
|
||||
/* #undef HAVE_ALARM */
|
||||
|
||||
/* Define to 1 if you have the `calloc' function. */
|
||||
#define HAVE_CALLOC 1
|
||||
|
||||
/* Define to 1 if you have the `ceil' function. */
|
||||
#define HAVE_CEIL 1
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
/* #undef HAVE_DLFCN_H */
|
||||
|
||||
/* Set to 1 if you have libfftw3. */
|
||||
/* #undef HAVE_FFTW3 */
|
||||
|
||||
/* Define to 1 if you have the `floor' function. */
|
||||
#define HAVE_FLOOR 1
|
||||
|
||||
/* Define to 1 if you have the `fmod' function. */
|
||||
#define HAVE_FMOD 1
|
||||
|
||||
/* Define to 1 if you have the `free' function. */
|
||||
#define HAVE_FREE 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
/* #undef HAVE_INTTYPES_H */
|
||||
|
||||
/* Define to 1 if you have the `m' library (-lm). */
|
||||
/* #undef HAVE_LIBM */
|
||||
|
||||
/* Define if you have C99's lrint function. */
|
||||
/* #undef HAVE_LRINT */
|
||||
|
||||
/* Define if you have C99's lrintf function. */
|
||||
/* #undef HAVE_LRINTF */
|
||||
|
||||
/* Define to 1 if you have the `malloc' function. */
|
||||
#define HAVE_MALLOC 1
|
||||
|
||||
/* Define to 1 if you have the `memcpy' function. */
|
||||
#define HAVE_MEMCPY 1
|
||||
|
||||
/* Define to 1 if you have the `memmove' function. */
|
||||
#define HAVE_MEMMOVE 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* 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. */
|
||||
#define HAVE_SNDFILE 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
/* #undef HAVE_STDINT_H */
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/times.h> header file. */
|
||||
/* #undef HAVE_SYS_TIMES_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
||||
/* #undef NO_MINUS_C_MINUS_O */
|
||||
|
||||
/* Set to 1 if compiling for Win32 */
|
||||
#define OS_IS_WIN32 1
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "libsamplerate"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "erikd@mega-nerd.com"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "libsamplerate"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "libsamplerate 0.1.8"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "libsamplerate"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL "http://www.mega-nerd.com/libsamplerate/"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "0.1.8"
|
||||
|
||||
/* The size of `double', as computed by sizeof. */
|
||||
#define SIZEOF_DOUBLE 8
|
||||
|
||||
/* The size of `float', as computed by sizeof. */
|
||||
#define SIZEOF_FLOAT 4
|
||||
|
||||
/* The size of `int', as computed by sizeof. */
|
||||
#define SIZEOF_INT 4
|
||||
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#define SIZEOF_LONG 4
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "0.1.8"
|
||||
|
||||
|
||||
|
||||
/* Extra Win32 hacks. */
|
||||
|
||||
/*
|
||||
** Microsoft's compiler still does not support the 1999 ISO C Standard
|
||||
** which includes 'inline'.
|
||||
*/
|
||||
|
||||
#define inline __inline
|
File diff suppressed because it is too large
Load diff
|
@ -1,271 +0,0 @@
|
|||
/*
|
||||
** Copyright (c) 2001-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/erikd/libsamplerate/blob/master/COPYING
|
||||
*/
|
||||
|
||||
/* Version 1.5 */
|
||||
|
||||
#ifndef FLOAT_CAST_HEADER
|
||||
#define FLOAT_CAST_HEADER
|
||||
|
||||
/*============================================================================
|
||||
** On Intel Pentium processors (especially PIII and probably P4), converting
|
||||
** from float to int is very slow. To meet the C specs, the code produced by
|
||||
** most C compilers targeting Pentium needs to change the FPU rounding mode
|
||||
** before the float to int conversion is performed.
|
||||
**
|
||||
** Changing the FPU rounding mode causes the FPU pipeline to be flushed. It
|
||||
** is this flushing of the pipeline which is so slow.
|
||||
**
|
||||
** Fortunately the ISO C99 specifications define the functions lrint, lrintf,
|
||||
** llrint and llrintf which fix this problem as a side effect.
|
||||
**
|
||||
** On Unix-like systems, the configure process should have detected the
|
||||
** presence of these functions. If they weren't found we have to replace them
|
||||
** here with a standard C cast.
|
||||
*/
|
||||
|
||||
/*
|
||||
** The C99 prototypes for lrint and lrintf are as follows:
|
||||
**
|
||||
** long int lrintf (float x) ;
|
||||
** long int lrint (double x) ;
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
/*
|
||||
** The presence of the required functions are detected during the configure
|
||||
** process and the values HAVE_LRINT and HAVE_LRINTF are set accordingly in
|
||||
** the config.h file.
|
||||
*/
|
||||
|
||||
#define HAVE_LRINT_REPLACEMENT 0
|
||||
|
||||
#if (HAVE_LRINT && HAVE_LRINTF)
|
||||
|
||||
/*
|
||||
** These defines enable functionality introduced with the 1999 ISO C
|
||||
** standard. They must be defined before the inclusion of math.h to
|
||||
** engage them. If optimisation is enabled, these functions will be
|
||||
** inlined. With optimisation switched off, you have to link in the
|
||||
** maths library using -lm.
|
||||
*/
|
||||
|
||||
#define _ISOC9X_SOURCE 1
|
||||
#define _ISOC99_SOURCE 1
|
||||
|
||||
#define __USE_ISOC9X 1
|
||||
#define __USE_ISOC99 1
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#elif (defined (__CYGWIN__))
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#undef HAVE_LRINT_REPLACEMENT
|
||||
#define HAVE_LRINT_REPLACEMENT 1
|
||||
|
||||
#undef lrint
|
||||
#undef lrintf
|
||||
|
||||
#define lrint double2int
|
||||
#define lrintf float2int
|
||||
|
||||
/*
|
||||
** The native CYGWIN lrint and lrintf functions are buggy:
|
||||
** http://sourceware.org/ml/cygwin/2005-06/msg00153.html
|
||||
** http://sourceware.org/ml/cygwin/2005-09/msg00047.html
|
||||
** and slow.
|
||||
** These functions (pulled from the Public Domain MinGW math.h header)
|
||||
** replace the native versions.
|
||||
*/
|
||||
|
||||
static inline long double2int (double in)
|
||||
{ long retval ;
|
||||
|
||||
__asm__ __volatile__
|
||||
( "fistpl %0"
|
||||
: "=m" (retval)
|
||||
: "t" (in)
|
||||
: "st"
|
||||
) ;
|
||||
|
||||
return retval ;
|
||||
} /* double2int */
|
||||
|
||||
static inline long float2int (float in)
|
||||
{ long retval ;
|
||||
|
||||
__asm__ __volatile__
|
||||
( "fistpl %0"
|
||||
: "=m" (retval)
|
||||
: "t" (in)
|
||||
: "st"
|
||||
) ;
|
||||
|
||||
return retval ;
|
||||
} /* float2int */
|
||||
|
||||
#elif (defined (WIN64) || defined(_WIN64)) && !defined(__MINGW64__)
|
||||
|
||||
/* Win64 section should be places before Win32 one, because
|
||||
** most likely both WIN32 and WIN64 will be defined in 64-bit case.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
/* Win64 doesn't seem to have these functions, nor inline assembly.
|
||||
** Therefore implement inline versions of these functions here.
|
||||
*/
|
||||
#include <emmintrin.h>
|
||||
#include <mmintrin.h>
|
||||
|
||||
__inline long int
|
||||
lrint(double flt)
|
||||
{
|
||||
return _mm_cvtsd_si32(_mm_load_sd(&flt));
|
||||
}
|
||||
|
||||
__inline long int
|
||||
lrintf(float flt)
|
||||
{
|
||||
return _mm_cvtss_si32(_mm_load_ss(&flt));
|
||||
}
|
||||
|
||||
#elif (defined (WIN32) || defined (_WIN32)) && !defined(__MINGW32__)
|
||||
|
||||
#undef HAVE_LRINT_REPLACEMENT
|
||||
#define HAVE_LRINT_REPLACEMENT 1
|
||||
|
||||
#include <math.h>
|
||||
|
||||
/*
|
||||
** Win32 doesn't seem to have these functions.
|
||||
** Therefore implement inline versions of these functions here.
|
||||
*/
|
||||
|
||||
__inline long int
|
||||
lrint (double flt)
|
||||
{ int intgr ;
|
||||
|
||||
_asm
|
||||
{ fld flt
|
||||
fistp intgr
|
||||
} ;
|
||||
|
||||
return intgr ;
|
||||
}
|
||||
|
||||
__inline long int
|
||||
lrintf (float flt)
|
||||
{ int intgr ;
|
||||
|
||||
_asm
|
||||
{ fld flt
|
||||
fistp intgr
|
||||
} ;
|
||||
|
||||
return intgr ;
|
||||
}
|
||||
|
||||
#elif (defined (__MWERKS__) && defined (macintosh))
|
||||
|
||||
/* This MacOS 9 solution was provided by Stephane Letz */
|
||||
|
||||
#undef HAVE_LRINT_REPLACEMENT
|
||||
#define HAVE_LRINT_REPLACEMENT 1
|
||||
#include <math.h>
|
||||
|
||||
#undef lrint
|
||||
#undef lrintf
|
||||
|
||||
#define lrint double2int
|
||||
#define lrintf float2int
|
||||
|
||||
inline int
|
||||
float2int (register float in)
|
||||
{ long res [2] ;
|
||||
|
||||
asm
|
||||
{ fctiw in, in
|
||||
stfd in, res
|
||||
}
|
||||
return res [1] ;
|
||||
} /* float2int */
|
||||
|
||||
inline int
|
||||
double2int (register double in)
|
||||
{ long res [2] ;
|
||||
|
||||
asm
|
||||
{ fctiw in, in
|
||||
stfd in, res
|
||||
}
|
||||
return res [1] ;
|
||||
} /* double2int */
|
||||
|
||||
#elif (defined (__MACH__) && defined (__APPLE__))
|
||||
|
||||
/* For Apple MacOSX. */
|
||||
|
||||
#undef HAVE_LRINT_REPLACEMENT
|
||||
#define HAVE_LRINT_REPLACEMENT 1
|
||||
#include <math.h>
|
||||
|
||||
#undef lrint
|
||||
#undef lrintf
|
||||
|
||||
#define lrint double2int
|
||||
#define lrintf float2int
|
||||
|
||||
inline static long
|
||||
float2int (register float in)
|
||||
{ int res [2] ;
|
||||
|
||||
__asm__ __volatile__
|
||||
( "fctiw %1, %1\n\t"
|
||||
"stfd %1, %0"
|
||||
: "=m" (res) /* Output */
|
||||
: "f" (in) /* Input */
|
||||
: "memory"
|
||||
) ;
|
||||
|
||||
return res [1] ;
|
||||
} /* lrintf */
|
||||
|
||||
inline static long
|
||||
double2int (register double in)
|
||||
{ int res [2] ;
|
||||
|
||||
__asm__ __volatile__
|
||||
( "fctiw %1, %1\n\t"
|
||||
"stfd %1, %0"
|
||||
: "=m" (res) /* Output */
|
||||
: "f" (in) /* Input */
|
||||
: "memory"
|
||||
) ;
|
||||
|
||||
return res [1] ;
|
||||
} /* lrint */
|
||||
|
||||
#else
|
||||
#ifndef __sgi
|
||||
#warning "Don't have the functions lrint() and lrintf()."
|
||||
#warning "Replacing these functions with a standard C cast."
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#define lrint(dbl) ((long) (dbl))
|
||||
#define lrintf(flt) ((long) (flt))
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* FLOAT_CAST_HEADER */
|
||||
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,540 +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/erikd/libsamplerate/blob/master/COPYING
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "samplerate.h"
|
||||
#include "float_cast.h"
|
||||
#include "common.h"
|
||||
|
||||
static int psrc_set_converter (SRC_PRIVATE *psrc, int converter_type) ;
|
||||
|
||||
|
||||
SRC_STATE *
|
||||
src_new (int converter_type, int channels, int *error)
|
||||
{ SRC_PRIVATE *psrc ;
|
||||
|
||||
if (error)
|
||||
*error = SRC_ERR_NO_ERROR ;
|
||||
|
||||
if (channels < 1)
|
||||
{ if (error)
|
||||
*error = SRC_ERR_BAD_CHANNEL_COUNT ;
|
||||
return NULL ;
|
||||
} ;
|
||||
|
||||
if ((psrc = calloc (1, sizeof (*psrc))) == NULL)
|
||||
{ if (error)
|
||||
*error = SRC_ERR_MALLOC_FAILED ;
|
||||
return NULL ;
|
||||
} ;
|
||||
|
||||
psrc->channels = channels ;
|
||||
psrc->mode = SRC_MODE_PROCESS ;
|
||||
|
||||
if (psrc_set_converter (psrc, converter_type) != SRC_ERR_NO_ERROR)
|
||||
{ if (error)
|
||||
*error = SRC_ERR_BAD_CONVERTER ;
|
||||
free (psrc) ;
|
||||
psrc = NULL ;
|
||||
} ;
|
||||
|
||||
src_reset ((SRC_STATE*) psrc) ;
|
||||
|
||||
return (SRC_STATE*) psrc ;
|
||||
} /* src_new */
|
||||
|
||||
SRC_STATE*
|
||||
src_callback_new (src_callback_t func, int converter_type, int channels, int *error, void* cb_data)
|
||||
{ SRC_STATE *src_state ;
|
||||
|
||||
if (func == NULL)
|
||||
{ if (error)
|
||||
*error = SRC_ERR_BAD_CALLBACK ;
|
||||
return NULL ;
|
||||
} ;
|
||||
|
||||
if (error != NULL)
|
||||
*error = 0 ;
|
||||
|
||||
if ((src_state = src_new (converter_type, channels, error)) == NULL)
|
||||
return NULL ;
|
||||
|
||||
src_reset (src_state) ;
|
||||
|
||||
((SRC_PRIVATE*) src_state)->mode = SRC_MODE_CALLBACK ;
|
||||
((SRC_PRIVATE*) src_state)->callback_func = func ;
|
||||
((SRC_PRIVATE*) src_state)->user_callback_data = cb_data ;
|
||||
|
||||
return src_state ;
|
||||
} /* src_callback_new */
|
||||
|
||||
SRC_STATE *
|
||||
src_delete (SRC_STATE *state)
|
||||
{ SRC_PRIVATE *psrc ;
|
||||
|
||||
psrc = (SRC_PRIVATE*) state ;
|
||||
if (psrc)
|
||||
{ if (psrc->private_data)
|
||||
free (psrc->private_data) ;
|
||||
memset (psrc, 0, sizeof (SRC_PRIVATE)) ;
|
||||
free (psrc) ;
|
||||
} ;
|
||||
|
||||
return NULL ;
|
||||
} /* src_state */
|
||||
|
||||
int
|
||||
src_process (SRC_STATE *state, SRC_DATA *data)
|
||||
{ SRC_PRIVATE *psrc ;
|
||||
int error ;
|
||||
|
||||
psrc = (SRC_PRIVATE*) state ;
|
||||
|
||||
if (psrc == NULL)
|
||||
return SRC_ERR_BAD_STATE ;
|
||||
if (psrc->vari_process == NULL || psrc->const_process == NULL)
|
||||
return SRC_ERR_BAD_PROC_PTR ;
|
||||
|
||||
if (psrc->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->data_out == NULL)
|
||||
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 * psrc->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 * psrc->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 (psrc->last_ratio < (1.0 / SRC_MAX_RATIO))
|
||||
psrc->last_ratio = data->src_ratio ;
|
||||
|
||||
/* Now process. */
|
||||
if (fabs (psrc->last_ratio - data->src_ratio) < 1e-15)
|
||||
error = psrc->const_process (psrc, data) ;
|
||||
else
|
||||
error = psrc->vari_process (psrc, data) ;
|
||||
|
||||
return error ;
|
||||
} /* src_process */
|
||||
|
||||
long
|
||||
src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data)
|
||||
{ SRC_PRIVATE *psrc ;
|
||||
SRC_DATA src_data ;
|
||||
|
||||
long output_frames_gen ;
|
||||
int error = 0 ;
|
||||
|
||||
if (state == NULL)
|
||||
return 0 ;
|
||||
|
||||
if (frames <= 0)
|
||||
return 0 ;
|
||||
|
||||
psrc = (SRC_PRIVATE*) state ;
|
||||
|
||||
if (psrc->mode != SRC_MODE_CALLBACK)
|
||||
{ psrc->error = SRC_ERR_BAD_MODE ;
|
||||
return 0 ;
|
||||
} ;
|
||||
|
||||
if (psrc->callback_func == NULL)
|
||||
{ psrc->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))
|
||||
{ psrc->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 = psrc->saved_data ;
|
||||
src_data.input_frames = psrc->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 = psrc->callback_func (psrc->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.
|
||||
*/
|
||||
psrc->mode = SRC_MODE_PROCESS ;
|
||||
error = src_process (state, &src_data) ;
|
||||
psrc->mode = SRC_MODE_CALLBACK ;
|
||||
|
||||
if (error != 0)
|
||||
break ;
|
||||
|
||||
src_data.data_in += src_data.input_frames_used * psrc->channels ;
|
||||
src_data.input_frames -= src_data.input_frames_used ;
|
||||
|
||||
src_data.data_out += src_data.output_frames_gen * psrc->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 ;
|
||||
} ;
|
||||
|
||||
psrc->saved_data = src_data.data_in ;
|
||||
psrc->saved_frames = src_data.input_frames ;
|
||||
|
||||
if (error != 0)
|
||||
{ psrc->error = error ;
|
||||
return 0 ;
|
||||
} ;
|
||||
|
||||
return output_frames_gen ;
|
||||
} /* src_callback_read */
|
||||
|
||||
/*==========================================================================
|
||||
*/
|
||||
|
||||
int
|
||||
src_set_ratio (SRC_STATE *state, double new_ratio)
|
||||
{ SRC_PRIVATE *psrc ;
|
||||
|
||||
psrc = (SRC_PRIVATE*) state ;
|
||||
|
||||
if (psrc == NULL)
|
||||
return SRC_ERR_BAD_STATE ;
|
||||
if (psrc->vari_process == NULL || psrc->const_process == NULL)
|
||||
return SRC_ERR_BAD_PROC_PTR ;
|
||||
|
||||
if (is_bad_src_ratio (new_ratio))
|
||||
return SRC_ERR_BAD_SRC_RATIO ;
|
||||
|
||||
psrc->last_ratio = new_ratio ;
|
||||
|
||||
return SRC_ERR_NO_ERROR ;
|
||||
} /* src_set_ratio */
|
||||
|
||||
int
|
||||
src_get_channels (SRC_STATE *state)
|
||||
{ SRC_PRIVATE *psrc ;
|
||||
|
||||
psrc = (SRC_PRIVATE*) state ;
|
||||
|
||||
if (psrc == NULL)
|
||||
return SRC_ERR_BAD_STATE ;
|
||||
if (psrc->vari_process == NULL || psrc->const_process == NULL)
|
||||
return SRC_ERR_BAD_PROC_PTR ;
|
||||
|
||||
return psrc->channels ;
|
||||
} /* src_get_channels */
|
||||
|
||||
int
|
||||
src_reset (SRC_STATE *state)
|
||||
{ SRC_PRIVATE *psrc ;
|
||||
|
||||
if ((psrc = (SRC_PRIVATE*) state) == NULL)
|
||||
return SRC_ERR_BAD_STATE ;
|
||||
|
||||
if (psrc->reset != NULL)
|
||||
psrc->reset (psrc) ;
|
||||
|
||||
psrc->last_position = 0.0 ;
|
||||
psrc->last_ratio = 0.0 ;
|
||||
|
||||
psrc->saved_data = NULL ;
|
||||
psrc->saved_frames = 0 ;
|
||||
|
||||
psrc->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 ((SRC_PRIVATE*) 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)
|
||||
{ double scaled_value ;
|
||||
|
||||
while (len)
|
||||
{ len -- ;
|
||||
|
||||
scaled_value = in [len] * (8.0 * 0x10000000) ;
|
||||
if (CPU_CLIPS_POSITIVE == 0 && scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
{ out [len] = 32767 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (CPU_CLIPS_NEGATIVE == 0 && scaled_value <= (-8.0 * 0x10000000))
|
||||
{ out [len] = -32768 ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
out [len] = (short) (lrint (scaled_value) >> 16) ;
|
||||
} ;
|
||||
|
||||
} /* 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 && scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
{ out [len] = 0x7fffffff ;
|
||||
continue ;
|
||||
} ;
|
||||
if (CPU_CLIPS_NEGATIVE == 0 && scaled_value <= (-8.0 * 0x10000000))
|
||||
{ out [len] = -1 - 0x7fffffff ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
out [len] = lrint (scaled_value) ;
|
||||
} ;
|
||||
|
||||
} /* src_float_to_int_array */
|
||||
|
||||
/*==============================================================================
|
||||
** Private functions.
|
||||
*/
|
||||
|
||||
static int
|
||||
psrc_set_converter (SRC_PRIVATE *psrc, int converter_type)
|
||||
{
|
||||
if (sinc_set_converter (psrc, converter_type) == SRC_ERR_NO_ERROR)
|
||||
return SRC_ERR_NO_ERROR ;
|
||||
|
||||
if (zoh_set_converter (psrc, converter_type) == SRC_ERR_NO_ERROR)
|
||||
return SRC_ERR_NO_ERROR ;
|
||||
|
||||
if (linear_set_converter (psrc, converter_type) == SRC_ERR_NO_ERROR)
|
||||
return SRC_ERR_NO_ERROR ;
|
||||
|
||||
return SRC_ERR_BAD_CONVERTER ;
|
||||
} /* psrc_set_converter */
|
||||
|
|
@ -1,209 +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/erikd/libsamplerate/blob/master/COPYING
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "float_cast.h"
|
||||
#include "common.h"
|
||||
|
||||
static int linear_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) ;
|
||||
static void linear_reset (SRC_PRIVATE *psrc) ;
|
||||
|
||||
/*========================================================================================
|
||||
*/
|
||||
|
||||
#define LINEAR_MAGIC_MARKER MAKE_MAGIC ('l', 'i', 'n', 'e', 'a', 'r')
|
||||
|
||||
#define SRC_DEBUG 0
|
||||
|
||||
typedef struct
|
||||
{ int linear_magic_marker ;
|
||||
int channels ;
|
||||
int reset ;
|
||||
long in_count, in_used ;
|
||||
long out_count, out_gen ;
|
||||
float last_value [1] ;
|
||||
} LINEAR_DATA ;
|
||||
|
||||
/*----------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int
|
||||
linear_vari_process (SRC_PRIVATE *psrc, 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 (psrc->private_data == NULL)
|
||||
return SRC_ERR_NO_PRIVATE ;
|
||||
|
||||
priv = (LINEAR_DATA*) psrc->private_data ;
|
||||
|
||||
if (priv->reset)
|
||||
{ /* If we have just been reset, set the last_value data. */
|
||||
for (ch = 0 ; ch < priv->channels ; ch++)
|
||||
priv->last_value [ch] = data->data_in [ch] ;
|
||||
priv->reset = 0 ;
|
||||
} ;
|
||||
|
||||
priv->in_count = data->input_frames * priv->channels ;
|
||||
priv->out_count = data->output_frames * priv->channels ;
|
||||
priv->in_used = priv->out_gen = 0 ;
|
||||
|
||||
src_ratio = psrc->last_ratio ;
|
||||
|
||||
if (is_bad_src_ratio (src_ratio))
|
||||
return SRC_ERR_BAD_INTERNAL_STATE ;
|
||||
|
||||
input_index = psrc->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 + priv->channels * (1.0 + input_index) >= priv->in_count)
|
||||
break ;
|
||||
|
||||
if (priv->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
|
||||
src_ratio = psrc->last_ratio + priv->out_gen * (data->src_ratio - psrc->last_ratio) / priv->out_count ;
|
||||
|
||||
for (ch = 0 ; ch < priv->channels ; ch++)
|
||||
{ data->data_out [priv->out_gen] = (float) (priv->last_value [ch] + input_index *
|
||||
(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 += priv->channels * lrint (input_index - rem) ;
|
||||
input_index = rem ;
|
||||
|
||||
/* Main processing loop. */
|
||||
while (priv->out_gen < priv->out_count && priv->in_used + priv->channels * input_index < priv->in_count)
|
||||
{
|
||||
if (priv->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
|
||||
src_ratio = psrc->last_ratio + priv->out_gen * (data->src_ratio - psrc->last_ratio) / priv->out_count ;
|
||||
|
||||
if (SRC_DEBUG && priv->in_used < priv->channels && input_index < 1.0)
|
||||
{ printf ("Whoops!!!! in_used : %ld channels : %d input_index : %f\n", priv->in_used, priv->channels, input_index) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
for (ch = 0 ; ch < priv->channels ; ch++)
|
||||
{ data->data_out [priv->out_gen] = (float) (data->data_in [priv->in_used - priv->channels + ch] + input_index *
|
||||
(data->data_in [priv->in_used + ch] - data->data_in [priv->in_used - priv->channels + ch])) ;
|
||||
priv->out_gen ++ ;
|
||||
} ;
|
||||
|
||||
/* Figure out the next index. */
|
||||
input_index += 1.0 / src_ratio ;
|
||||
rem = fmod_one (input_index) ;
|
||||
|
||||
priv->in_used += priv->channels * lrint (input_index - rem) ;
|
||||
input_index = rem ;
|
||||
} ;
|
||||
|
||||
if (priv->in_used > priv->in_count)
|
||||
{ input_index += (priv->in_used - priv->in_count) / priv->channels ;
|
||||
priv->in_used = priv->in_count ;
|
||||
} ;
|
||||
|
||||
psrc->last_position = input_index ;
|
||||
|
||||
if (priv->in_used > 0)
|
||||
for (ch = 0 ; ch < priv->channels ; ch++)
|
||||
priv->last_value [ch] = data->data_in [priv->in_used - priv->channels + ch] ;
|
||||
|
||||
/* Save current ratio rather then target ratio. */
|
||||
psrc->last_ratio = src_ratio ;
|
||||
|
||||
data->input_frames_used = priv->in_used / priv->channels ;
|
||||
data->output_frames_gen = priv->out_gen / priv->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 */
|
||||
|
||||
int
|
||||
linear_set_converter (SRC_PRIVATE *psrc, int src_enum)
|
||||
{ LINEAR_DATA *priv = NULL ;
|
||||
|
||||
if (src_enum != SRC_LINEAR)
|
||||
return SRC_ERR_BAD_CONVERTER ;
|
||||
|
||||
if (psrc->private_data != NULL)
|
||||
{ free (psrc->private_data) ;
|
||||
psrc->private_data = NULL ;
|
||||
} ;
|
||||
|
||||
if (psrc->private_data == NULL)
|
||||
{ priv = calloc (1, sizeof (*priv) + psrc->channels * sizeof (float)) ;
|
||||
psrc->private_data = priv ;
|
||||
} ;
|
||||
|
||||
if (priv == NULL)
|
||||
return SRC_ERR_MALLOC_FAILED ;
|
||||
|
||||
priv->linear_magic_marker = LINEAR_MAGIC_MARKER ;
|
||||
priv->channels = psrc->channels ;
|
||||
|
||||
psrc->const_process = linear_vari_process ;
|
||||
psrc->vari_process = linear_vari_process ;
|
||||
psrc->reset = linear_reset ;
|
||||
|
||||
linear_reset (psrc) ;
|
||||
|
||||
return SRC_ERR_NO_ERROR ;
|
||||
} /* linear_set_converter */
|
||||
|
||||
/*===================================================================================
|
||||
*/
|
||||
|
||||
static void
|
||||
linear_reset (SRC_PRIVATE *psrc)
|
||||
{ LINEAR_DATA *priv = NULL ;
|
||||
|
||||
priv = (LINEAR_DATA*) psrc->private_data ;
|
||||
if (priv == NULL)
|
||||
return ;
|
||||
|
||||
priv->channels = psrc->channels ;
|
||||
priv->reset = 1 ;
|
||||
memset (priv->last_value, 0, sizeof (priv->last_value [0]) * priv->channels) ;
|
||||
|
||||
return ;
|
||||
} /* linear_reset */
|
||||
|
File diff suppressed because it is too large
Load diff
|
@ -1,200 +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/erikd/libsamplerate/blob/master/COPYING
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "float_cast.h"
|
||||
#include "common.h"
|
||||
|
||||
static int zoh_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) ;
|
||||
static void zoh_reset (SRC_PRIVATE *psrc) ;
|
||||
|
||||
/*========================================================================================
|
||||
*/
|
||||
|
||||
#define ZOH_MAGIC_MARKER MAKE_MAGIC ('s', 'r', 'c', 'z', 'o', 'h')
|
||||
|
||||
typedef struct
|
||||
{ int zoh_magic_marker ;
|
||||
int channels ;
|
||||
int reset ;
|
||||
long in_count, in_used ;
|
||||
long out_count, out_gen ;
|
||||
float last_value [1] ;
|
||||
} ZOH_DATA ;
|
||||
|
||||
/*----------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int
|
||||
zoh_vari_process (SRC_PRIVATE *psrc, 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 (psrc->private_data == NULL)
|
||||
return SRC_ERR_NO_PRIVATE ;
|
||||
|
||||
priv = (ZOH_DATA*) psrc->private_data ;
|
||||
|
||||
if (priv->reset)
|
||||
{ /* If we have just been reset, set the last_value data. */
|
||||
for (ch = 0 ; ch < priv->channels ; ch++)
|
||||
priv->last_value [ch] = data->data_in [ch] ;
|
||||
priv->reset = 0 ;
|
||||
} ;
|
||||
|
||||
priv->in_count = data->input_frames * priv->channels ;
|
||||
priv->out_count = data->output_frames * priv->channels ;
|
||||
priv->in_used = priv->out_gen = 0 ;
|
||||
|
||||
src_ratio = psrc->last_ratio ;
|
||||
|
||||
if (is_bad_src_ratio (src_ratio))
|
||||
return SRC_ERR_BAD_INTERNAL_STATE ;
|
||||
|
||||
input_index = psrc->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 + priv->channels * input_index >= priv->in_count)
|
||||
break ;
|
||||
|
||||
if (priv->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
|
||||
src_ratio = psrc->last_ratio + priv->out_gen * (data->src_ratio - psrc->last_ratio) / priv->out_count ;
|
||||
|
||||
for (ch = 0 ; ch < priv->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 += priv->channels * lrint (input_index - rem) ;
|
||||
input_index = rem ;
|
||||
|
||||
/* Main processing loop. */
|
||||
while (priv->out_gen < priv->out_count && priv->in_used + priv->channels * input_index <= priv->in_count)
|
||||
{
|
||||
if (priv->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
|
||||
src_ratio = psrc->last_ratio + priv->out_gen * (data->src_ratio - psrc->last_ratio) / priv->out_count ;
|
||||
|
||||
for (ch = 0 ; ch < priv->channels ; ch++)
|
||||
{ data->data_out [priv->out_gen] = data->data_in [priv->in_used - priv->channels + ch] ;
|
||||
priv->out_gen ++ ;
|
||||
} ;
|
||||
|
||||
/* Figure out the next index. */
|
||||
input_index += 1.0 / src_ratio ;
|
||||
rem = fmod_one (input_index) ;
|
||||
|
||||
priv->in_used += priv->channels * lrint (input_index - rem) ;
|
||||
input_index = rem ;
|
||||
} ;
|
||||
|
||||
if (priv->in_used > priv->in_count)
|
||||
{ input_index += (priv->in_used - priv->in_count) / priv->channels ;
|
||||
priv->in_used = priv->in_count ;
|
||||
} ;
|
||||
|
||||
psrc->last_position = input_index ;
|
||||
|
||||
if (priv->in_used > 0)
|
||||
for (ch = 0 ; ch < priv->channels ; ch++)
|
||||
priv->last_value [ch] = data->data_in [priv->in_used - priv->channels + ch] ;
|
||||
|
||||
/* Save current ratio rather then target ratio. */
|
||||
psrc->last_ratio = src_ratio ;
|
||||
|
||||
data->input_frames_used = priv->in_used / priv->channels ;
|
||||
data->output_frames_gen = priv->out_gen / priv->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 */
|
||||
|
||||
int
|
||||
zoh_set_converter (SRC_PRIVATE *psrc, int src_enum)
|
||||
{ ZOH_DATA *priv = NULL ;
|
||||
|
||||
if (src_enum != SRC_ZERO_ORDER_HOLD)
|
||||
return SRC_ERR_BAD_CONVERTER ;
|
||||
|
||||
if (psrc->private_data != NULL)
|
||||
{ free (psrc->private_data) ;
|
||||
psrc->private_data = NULL ;
|
||||
} ;
|
||||
|
||||
if (psrc->private_data == NULL)
|
||||
{ priv = calloc (1, sizeof (*priv) + psrc->channels * sizeof (float)) ;
|
||||
psrc->private_data = priv ;
|
||||
} ;
|
||||
|
||||
if (priv == NULL)
|
||||
return SRC_ERR_MALLOC_FAILED ;
|
||||
|
||||
priv->zoh_magic_marker = ZOH_MAGIC_MARKER ;
|
||||
priv->channels = psrc->channels ;
|
||||
|
||||
psrc->const_process = zoh_vari_process ;
|
||||
psrc->vari_process = zoh_vari_process ;
|
||||
psrc->reset = zoh_reset ;
|
||||
|
||||
zoh_reset (psrc) ;
|
||||
|
||||
return SRC_ERR_NO_ERROR ;
|
||||
} /* zoh_set_converter */
|
||||
|
||||
/*===================================================================================
|
||||
*/
|
||||
|
||||
static void
|
||||
zoh_reset (SRC_PRIVATE *psrc)
|
||||
{ ZOH_DATA *priv ;
|
||||
|
||||
priv = (ZOH_DATA*) psrc->private_data ;
|
||||
if (priv == NULL)
|
||||
return ;
|
||||
|
||||
priv->channels = psrc->channels ;
|
||||
priv->reset = 1 ;
|
||||
memset (priv->last_value, 0, sizeof (priv->last_value [0]) * priv->channels) ;
|
||||
|
||||
return ;
|
||||
} /* zoh_reset */
|
||||
|
|
@ -9,8 +9,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dependencies", "Dependencie
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imgui", "dep\imgui\imgui.vcxproj", "{BB08260F-6FBC-46AF-8924-090EE71360C6}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libsamplerate", "dep\libsamplerate\libsamplerate.vcxproj", "{2F2A2B7B-60B3-478C-921E-3633B3C45C3F}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "src\common\common.vcxproj", "{EE054E08-3799-4A59-A422-18259C105FFD}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core", "src\core\core.vcxproj", "{868B98C8-65A1-494B-8346-250A73A48C0A}"
|
||||
|
@ -69,22 +67,6 @@ Global
|
|||
{BB08260F-6FBC-46AF-8924-090EE71360C6}.ReleaseLTCG|x64.Build.0 = ReleaseLTCG|x64
|
||||
{BB08260F-6FBC-46AF-8924-090EE71360C6}.ReleaseLTCG|x86.ActiveCfg = ReleaseLTCG|Win32
|
||||
{BB08260F-6FBC-46AF-8924-090EE71360C6}.ReleaseLTCG|x86.Build.0 = ReleaseLTCG|Win32
|
||||
{2F2A2B7B-60B3-478C-921E-3633B3C45C3F}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2F2A2B7B-60B3-478C-921E-3633B3C45C3F}.Debug|x64.Build.0 = Debug|x64
|
||||
{2F2A2B7B-60B3-478C-921E-3633B3C45C3F}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{2F2A2B7B-60B3-478C-921E-3633B3C45C3F}.Debug|x86.Build.0 = Debug|Win32
|
||||
{2F2A2B7B-60B3-478C-921E-3633B3C45C3F}.DebugFast|x64.ActiveCfg = DebugFast|x64
|
||||
{2F2A2B7B-60B3-478C-921E-3633B3C45C3F}.DebugFast|x64.Build.0 = DebugFast|x64
|
||||
{2F2A2B7B-60B3-478C-921E-3633B3C45C3F}.DebugFast|x86.ActiveCfg = DebugFast|Win32
|
||||
{2F2A2B7B-60B3-478C-921E-3633B3C45C3F}.DebugFast|x86.Build.0 = DebugFast|Win32
|
||||
{2F2A2B7B-60B3-478C-921E-3633B3C45C3F}.Release|x64.ActiveCfg = Release|x64
|
||||
{2F2A2B7B-60B3-478C-921E-3633B3C45C3F}.Release|x64.Build.0 = Release|x64
|
||||
{2F2A2B7B-60B3-478C-921E-3633B3C45C3F}.Release|x86.ActiveCfg = Release|Win32
|
||||
{2F2A2B7B-60B3-478C-921E-3633B3C45C3F}.Release|x86.Build.0 = Release|Win32
|
||||
{2F2A2B7B-60B3-478C-921E-3633B3C45C3F}.ReleaseLTCG|x64.ActiveCfg = ReleaseLTCG|x64
|
||||
{2F2A2B7B-60B3-478C-921E-3633B3C45C3F}.ReleaseLTCG|x64.Build.0 = ReleaseLTCG|x64
|
||||
{2F2A2B7B-60B3-478C-921E-3633B3C45C3F}.ReleaseLTCG|x86.ActiveCfg = ReleaseLTCG|Win32
|
||||
{2F2A2B7B-60B3-478C-921E-3633B3C45C3F}.ReleaseLTCG|x86.Build.0 = ReleaseLTCG|Win32
|
||||
{EE054E08-3799-4A59-A422-18259C105FFD}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{EE054E08-3799-4A59-A422-18259C105FFD}.Debug|x64.Build.0 = Debug|x64
|
||||
{EE054E08-3799-4A59-A422-18259C105FFD}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
|
@ -204,7 +186,6 @@ Global
|
|||
GlobalSection(NestedProjects) = preSolution
|
||||
{43540154-9E1E-409C-834F-B84BE5621388} = {BA490C0E-497D-4634-A21E-E65012006385}
|
||||
{BB08260F-6FBC-46AF-8924-090EE71360C6} = {BA490C0E-497D-4634-A21E-E65012006385}
|
||||
{2F2A2B7B-60B3-478C-921E-3633B3C45C3F} = {BA490C0E-497D-4634-A21E-E65012006385}
|
||||
{B56CE698-7300-4FA5-9609-942F1D05C5A2} = {BA490C0E-497D-4634-A21E-E65012006385}
|
||||
{ED601289-AC1A-46B8-A8ED-17DB9EB73423} = {BA490C0E-497D-4634-A21E-E65012006385}
|
||||
{6A4208ED-E3DC-41E1-81CD-F61025FC285A} = {BA490C0E-497D-4634-A21E-E65012006385}
|
||||
|
|
|
@ -39,7 +39,7 @@ add_library(common ${SRCS})
|
|||
|
||||
target_include_directories(common PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
target_include_directories(common PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
target_link_libraries(common YBaseLib glad libsamplerate libcue Threads::Threads)
|
||||
target_link_libraries(common YBaseLib glad libcue Threads::Threads)
|
||||
|
||||
if(ENABLE_OPENGL)
|
||||
target_sources(common PRIVATE display_renderer_gl.cpp display_renderer_gl.h)
|
||||
|
|
|
@ -92,9 +92,6 @@
|
|||
<ProjectReference Include="..\..\dep\libcue\libcue.vcxproj">
|
||||
<Project>{6a4208ed-e3dc-41e1-81cd-f61025fc285a}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\dep\libsamplerate\libsamplerate.vcxproj">
|
||||
<Project>{2f2a2b7b-60b3-478c-921e-3633b3c45c3f}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\dep\YBaseLib\Source\YBaseLib.vcxproj">
|
||||
<Project>{b56ce698-7300-4fa5-9609-942f1d05c5a2}</Project>
|
||||
</ProjectReference>
|
||||
|
|
|
@ -84,9 +84,6 @@
|
|||
<ClInclude Include="types.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\dep\libsamplerate\libsamplerate.vcxproj">
|
||||
<Project>{2f2a2b7b-60b3-478c-921e-3633b3c45c3f}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\dep\stb\stb.vcxproj">
|
||||
<Project>{ed601289-ac1a-46b8-a8ed-17db9eb73423}</Project>
|
||||
</ProjectReference>
|
||||
|
|
Loading…
Reference in a new issue