diff --git a/.travis.yml b/.travis.yml index b051004..b354641 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,3 +31,5 @@ addons: - libavcodec-dev - libavformat-dev - libavutil-dev + - libresample-dev + - libkissfft-dev diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d8bf0e..c5b0d2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,18 @@ pkg_check_modules(FFMPEG REQUIRED IMPORTED_TARGET libavcodec libavformat libavutil) +pkg_check_modules(LIBRESAMPLE REQUIRED IMPORTED_TARGET libresample) +pkg_search_module(KISSFFT REQUIRED IMPORTED_TARGET + kissfft-simd + kissfft-double + kissfft-float + kissfft-int32_t + kissfft-int16_t + kissfft-simd-openmp + kissfft-double-openmp + kissfft-float-openmp + kissfft-int32_t-openmp + kissfft-int16_t-openmp) include_directories( "${PROJECT_SOURCE_DIR}/include") diff --git a/libmusly/CMakeLists.txt b/libmusly/CMakeLists.txt index b9f6d11..6f8c8e9 100644 --- a/libmusly/CMakeLists.txt +++ b/libmusly/CMakeLists.txt @@ -13,19 +13,11 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external") PROPERTIES COMPILE_FLAGS "-DLIBMUSLY_EXTERNAL ${LIBMUSLY_EXTERNAL_FLAGS}") endif() -if(USE_OPENMP AND OPENMP_FOUND) - # disable OpenMP for kiss FFT, it slows things down terribly - set_source_files_properties(kissfft/kiss_fft.c - PROPERTIES COMPILE_FLAGS "-U_OPENMP") -endif() - include_directories( ${LIBMUSLY_INCLUDE} ${CMAKE_CURRENT_SOURCE_DIR}) add_library(libmusly - kissfft/kiss_fft.c - kissfft/kiss_fftr.c methods/mandelellis.cpp methods/timbre.cpp decoders/libav.cpp @@ -56,7 +48,9 @@ set_target_properties(libmusly target_link_libraries(libmusly ${LIBMUSLY_LIBS} PkgConfig::EIGEN3 - PkgConfig::FFMPEG) + PkgConfig::FFMPEG + PkgConfig::LIBRESAMPLE + PkgConfig::KISSFFT) if(WIN32 OR MINGW) # link against winsock2 for ntohl() and htonl() target_link_libraries(libmusly ws2_32) diff --git a/libmusly/kissfft/CHANGELOG b/libmusly/kissfft/CHANGELOG deleted file mode 100644 index 2dd3603..0000000 --- a/libmusly/kissfft/CHANGELOG +++ /dev/null @@ -1,123 +0,0 @@ -1.3.0 2012-07-18 - removed non-standard malloc.h from kiss_fft.h - - moved -lm to end of link line - - checked various return values - - converted python Numeric code to NumPy - - fixed test of int32_t on 64 bit OS - - added padding in a couple of places to allow SIMD alignment of structs - -1.2.9 2010-05-27 - threadsafe ( including OpenMP ) - - first edition of kissfft.hh the C++ template fft engine - -1.2.8 - Changed memory.h to string.h -- apparently more standard - - Added openmp extensions. This can have fairly linear speedups for larger FFT sizes. - -1.2.7 - Shrank the real-fft memory footprint. Thanks to Galen Seitz. - -1.2.6 (Nov 14, 2006) The "thanks to GenArts" release. - Added multi-dimensional real-optimized FFT, see tools/kiss_fftndr - Thanks go to GenArts, Inc. for sponsoring the development. - -1.2.5 (June 27, 2006) The "release for no good reason" release. - Changed some harmless code to make some compilers' warnings go away. - Added some more digits to pi -- why not. - Added kiss_fft_next_fast_size() function to help people decide how much to pad. - Changed multidimensional test from 8 dimensions to only 3 to avoid testing - problems with fixed point (sorry Buckaroo Banzai). - -1.2.4 (Oct 27, 2005) The "oops, inverse fixed point real fft was borked" release. - Fixed scaling bug for inverse fixed point real fft -- also fixed test code that should've been failing. - Thanks to Jean-Marc Valin for bug report. - - Use sys/types.h for more portable types than short,int,long => int16_t,int32_t,int64_t - If your system does not have these, you may need to define them -- but at least it breaks in a - loud and easily fixable way -- unlike silently using the wrong size type. - - Hopefully tools/psdpng.c is fixed -- thanks to Steve Kellog for pointing out the weirdness. - -1.2.3 (June 25, 2005) The "you want to use WHAT as a sample" release. - Added ability to use 32 bit fixed point samples -- requires a 64 bit intermediate result, a la 'long long' - - Added ability to do 4 FFTs in parallel by using SSE SIMD instructions. This is accomplished by - using the __m128 (vector of 4 floats) as kiss_fft_scalar. Define USE_SIMD to use this. - - I know, I know ... this is drifting a bit from the "kiss" principle, but the speed advantages - make it worth it for some. Also recent gcc makes it SOO easy to use vectors of 4 floats like a POD type. - -1.2.2 (May 6, 2005) The Matthew release - Replaced fixed point division with multiply&shift. Thanks to Jean-Marc Valin for - discussions regarding. Considerable speedup for fixed-point. - - Corrected overflow protection in real fft routines when using fixed point. - Finder's Credit goes to Robert Oschler of robodance for pointing me at the bug. - This also led to the CHECK_OVERFLOW_OP macro. - -1.2.1 (April 4, 2004) - compiles cleanly with just about every -W warning flag under the sun - - reorganized kiss_fft_state so it could be read-only/const. This may be useful for embedded systems - that are willing to predeclare twiddle factors, factorization. - - Fixed C_MUL,S_MUL on 16-bit platforms. - - tmpbuf will only be allocated if input & output buffers are same - scratchbuf will only be allocated for ffts that are not multiples of 2,3,5 - - NOTE: The tmpbuf,scratchbuf changes may require synchronization code for multi-threaded apps. - - -1.2 (Feb 23, 2004) - interface change -- cfg object is forward declaration of struct instead of void* - This maintains type saftey and lets the compiler warn/error about stupid mistakes. - (prompted by suggestion from Erik de Castro Lopo) - - small speed improvements - - added psdpng.c -- sample utility that will create png spectrum "waterfalls" from an input file - ( not terribly useful yet) - -1.1.1 (Feb 1, 2004 ) - minor bug fix -- only affects odd rank, in-place, multi-dimensional FFTs - -1.1 : (Jan 30,2004) - split sample_code/ into test/ and tools/ - - Removed 2-D fft and added N-D fft (arbitrary) - - modified fftutil.c to allow multi-d FFTs - - Modified core fft routine to allow an input stride via kiss_fft_stride() - (eased support of multi-D ffts) - - Added fast convolution filtering (FIR filtering using overlap-scrap method, with tail scrap) - - Add kfc.[ch]: the KISS FFT Cache. It takes care of allocs for you ( suggested by Oscar Lesta ). - -1.0.1 (Dec 15, 2003) - fixed bug that occurred when nfft==1. Thanks to Steven Johnson. - -1.0 : (Dec 14, 2003) - changed kiss_fft function from using a single buffer, to two buffers. - If the same buffer pointer is supplied for both in and out, kiss will - manage the buffer copies. - - added kiss_fft2d and kiss_fftr as separate source files (declarations in kiss_fft.h ) - -0.4 :(Nov 4,2003) optimized for radix 2,3,4,5 - -0.3 :(Oct 28, 2003) woops, version 2 didn't actually factor out any radices other than 2. - Thanks to Steven Johnson for finding this one. - -0.2 :(Oct 27, 2003) added mixed radix, only radix 2,4 optimized versions - -0.1 :(May 19 2003) initial release, radix 2 only diff --git a/libmusly/kissfft/COPYING b/libmusly/kissfft/COPYING deleted file mode 100644 index 2fc6685..0000000 --- a/libmusly/kissfft/COPYING +++ /dev/null @@ -1,11 +0,0 @@ -Copyright (c) 2003-2010 Mark Borgerding - -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. - * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -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 OWNER 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. diff --git a/libmusly/kissfft/README b/libmusly/kissfft/README deleted file mode 100644 index 03b2e7a..0000000 --- a/libmusly/kissfft/README +++ /dev/null @@ -1,134 +0,0 @@ -KISS FFT - A mixed-radix Fast Fourier Transform based up on the principle, -"Keep It Simple, Stupid." - - There are many great fft libraries already around. Kiss FFT is not trying -to be better than any of them. It only attempts to be a reasonably efficient, -moderately useful FFT that can use fixed or floating data types and can be -incorporated into someone's C program in a few minutes with trivial licensing. - -USAGE: - - The basic usage for 1-d complex FFT is: - - #include "kiss_fft.h" - - kiss_fft_cfg cfg = kiss_fft_alloc( nfft ,is_inverse_fft ,0,0 ); - - while ... - - ... // put kth sample in cx_in[k].r and cx_in[k].i - - kiss_fft( cfg , cx_in , cx_out ); - - ... // transformed. DC is in cx_out[0].r and cx_out[0].i - - free(cfg); - - Note: frequency-domain data is stored from dc up to 2pi. - so cx_out[0] is the dc bin of the FFT - and cx_out[nfft/2] is the Nyquist bin (if exists) - - Declarations are in "kiss_fft.h", along with a brief description of the -functions you'll need to use. - -Code definitions for 1d complex FFTs are in kiss_fft.c. - -You can do other cool stuff with the extras you'll find in tools/ - - * multi-dimensional FFTs - * real-optimized FFTs (returns the positive half-spectrum: (nfft/2+1) complex frequency bins) - * fast convolution FIR filtering (not available for fixed point) - * spectrum image creation - -The core fft and most tools/ code can be compiled to use float, double, - Q15 short or Q31 samples. The default is float. - - -BACKGROUND: - - I started coding this because I couldn't find a fixed point FFT that didn't -use assembly code. I started with floating point numbers so I could get the -theory straight before working on fixed point issues. In the end, I had a -little bit of code that could be recompiled easily to do ffts with short, float -or double (other types should be easy too). - - Once I got my FFT working, I was curious about the speed compared to -a well respected and highly optimized fft library. I don't want to criticize -this great library, so let's call it FFT_BRANDX. -During this process, I learned: - - 1. FFT_BRANDX has more than 100K lines of code. The core of kiss_fft is about 500 lines (cpx 1-d). - 2. It took me an embarrassingly long time to get FFT_BRANDX working. - 3. A simple program using FFT_BRANDX is 522KB. A similar program using kiss_fft is 18KB (without optimizing for size). - 4. FFT_BRANDX is roughly twice as fast as KISS FFT in default mode. - - It is wonderful that free, highly optimized libraries like FFT_BRANDX exist. -But such libraries carry a huge burden of complexity necessary to extract every -last bit of performance. - - Sometimes simpler is better, even if it's not better. - -FREQUENTLY ASKED QUESTIONS: - Q: Can I use kissfft in a project with a ___ license? - A: Yes. See LICENSE below. - - Q: Why don't I get the output I expect? - A: The two most common causes of this are - 1) scaling : is there a constant multiplier between what you got and what you want? - 2) mixed build environment -- all code must be compiled with same preprocessor - definitions for FIXED_POINT and kiss_fft_scalar - - Q: Will you write/debug my code for me? - A: Probably not unless you pay me. I am happy to answer pointed and topical questions, but - I may refer you to a book, a forum, or some other resource. - - -PERFORMANCE: - (on Athlon XP 2100+, with gcc 2.96, float data type) - - Kiss performed 10000 1024-pt cpx ffts in .63 s of cpu time. - For comparison, it took md5sum twice as long to process the same amount of data. - - Transforming 5 minutes of CD quality audio takes less than a second (nfft=1024). - -DO NOT: - ... use Kiss if you need the Fastest Fourier Transform in the World - ... ask me to add features that will bloat the code - -UNDER THE HOOD: - - Kiss FFT uses a time decimation, mixed-radix, out-of-place FFT. If you give it an input buffer - and output buffer that are the same, a temporary buffer will be created to hold the data. - - No static data is used. The core routines of kiss_fft are thread-safe (but not all of the tools directory). - - No scaling is done for the floating point version (for speed). - Scaling is done both ways for the fixed-point version (for overflow prevention). - - Optimized butterflies are used for factors 2,3,4, and 5. - - The real (i.e. not complex) optimization code only works for even length ffts. It does two half-length - FFTs in parallel (packed into real&imag), and then combines them via twiddling. The result is - nfft/2+1 complex frequency bins from DC to Nyquist. If you don't know what this means, search the web. - - The fast convolution filtering uses the overlap-scrap method, slightly - modified to put the scrap at the tail. - -LICENSE: - Revised BSD License, see COPYING for verbiage. - Basically, "free to use&change, give credit where due, no guarantees" - Note this license is compatible with GPL at one end of the spectrum and closed, commercial software at - the other end. See http://www.fsf.org/licensing/licenses - - A commercial license is available which removes the requirement for attribution. Contact me for details. - - -TODO: - *) Add real optimization for odd length FFTs - *) Document/revisit the input/output fft scaling - *) Make doc describing the overlap (tail) scrap fast convolution filtering in kiss_fastfir.c - *) Test all the ./tools/ code with fixed point (kiss_fastfir.c doesn't work, maybe others) - -AUTHOR: - Mark Borgerding - Mark@Borgerding.net diff --git a/libmusly/kissfft/README.simd b/libmusly/kissfft/README.simd deleted file mode 100644 index b0fdac5..0000000 --- a/libmusly/kissfft/README.simd +++ /dev/null @@ -1,78 +0,0 @@ -If you are reading this, it means you think you may be interested in using the SIMD extensions in kissfft -to do 4 *separate* FFTs at once. - -Beware! Beyond here there be dragons! - -This API is not easy to use, is not well documented, and breaks the KISS principle. - - -Still reading? Okay, you may get rewarded for your patience with a considerable speedup -(2-3x) on intel x86 machines with SSE if you are willing to jump through some hoops. - -The basic idea is to use the packed 4 float __m128 data type as a scalar element. -This means that the format is pretty convoluted. It performs 4 FFTs per fft call on signals A,B,C,D. - -For complex data, the data is interlaced as follows: -rA0,rB0,rC0,rD0, iA0,iB0,iC0,iD0, rA1,rB1,rC1,rD1, iA1,iB1,iC1,iD1 ... -where "rA0" is the real part of the zeroth sample for signal A - -Real-only data is laid out: -rA0,rB0,rC0,rD0, rA1,rB1,rC1,rD1, ... - -Compile with gcc flags something like --O3 -mpreferred-stack-boundary=4 -DUSE_SIMD=1 -msse - -Be aware of SIMD alignment. This is the most likely cause of segfaults. -The code within kissfft uses scratch variables on the stack. -With SIMD, these must have addresses on 16 byte boundaries. -Search on "SIMD alignment" for more info. - - - -Robin at Divide Concept was kind enough to share his code for formatting to/from the SIMD kissfft. -I have not run it -- use it at your own risk. It appears to do 4xN and Nx4 transpositions -(out of place). - -void SSETools::pack128(float* target, float* source, unsigned long size128) -{ - __m128* pDest = (__m128*)target; - __m128* pDestEnd = pDest+size128; - float* source0=source; - float* source1=source0+size128; - float* source2=source1+size128; - float* source3=source2+size128; - - while(pDest - -#define MAXFACTORS 32 -/* e.g. an fft of length 128 has 4 factors - as far as kissfft is concerned - 4*4*4*2 - */ - -struct kiss_fft_state{ - int nfft; - int inverse; - int factors[2*MAXFACTORS]; - kiss_fft_cpx twiddles[1]; -}; - -/* - Explanation of macros dealing with complex math: - - C_MUL(m,a,b) : m = a*b - C_FIXDIV( c , div ) : if a fixed point impl., c /= div. noop otherwise - C_SUB( res, a,b) : res = a - b - C_SUBFROM( res , a) : res -= a - C_ADDTO( res , a) : res += a - * */ -#ifdef FIXED_POINT -#if (FIXED_POINT==32) -# define FRACBITS 31 -# define SAMPPROD int64_t -#define SAMP_MAX 2147483647 -#else -# define FRACBITS 15 -# define SAMPPROD int32_t -#define SAMP_MAX 32767 -#endif - -#define SAMP_MIN -SAMP_MAX - -#if defined(CHECK_OVERFLOW) -# define CHECK_OVERFLOW_OP(a,op,b) \ - if ( (SAMPPROD)(a) op (SAMPPROD)(b) > SAMP_MAX || (SAMPPROD)(a) op (SAMPPROD)(b) < SAMP_MIN ) { \ - fprintf(stderr,"WARNING:overflow @ " __FILE__ "(%d): (%d " #op" %d) = %ld\n",__LINE__,(a),(b),(SAMPPROD)(a) op (SAMPPROD)(b) ); } -#endif - - -# define smul(a,b) ( (SAMPPROD)(a)*(b) ) -# define sround( x ) (kiss_fft_scalar)( ( (x) + (1<<(FRACBITS-1)) ) >> FRACBITS ) - -# define S_MUL(a,b) sround( smul(a,b) ) - -# define C_MUL(m,a,b) \ - do{ (m).r = sround( smul((a).r,(b).r) - smul((a).i,(b).i) ); \ - (m).i = sround( smul((a).r,(b).i) + smul((a).i,(b).r) ); }while(0) - -# define DIVSCALAR(x,k) \ - (x) = sround( smul( x, SAMP_MAX/k ) ) - -# define C_FIXDIV(c,div) \ - do { DIVSCALAR( (c).r , div); \ - DIVSCALAR( (c).i , div); }while (0) - -# define C_MULBYSCALAR( c, s ) \ - do{ (c).r = sround( smul( (c).r , s ) ) ;\ - (c).i = sround( smul( (c).i , s ) ) ; }while(0) - -#else /* not FIXED_POINT*/ - -# define S_MUL(a,b) ( (a)*(b) ) -#define C_MUL(m,a,b) \ - do{ (m).r = (a).r*(b).r - (a).i*(b).i;\ - (m).i = (a).r*(b).i + (a).i*(b).r; }while(0) -# define C_FIXDIV(c,div) /* NOOP */ -# define C_MULBYSCALAR( c, s ) \ - do{ (c).r *= (s);\ - (c).i *= (s); }while(0) -#endif - -#ifndef CHECK_OVERFLOW_OP -# define CHECK_OVERFLOW_OP(a,op,b) /* noop */ -#endif - -#define C_ADD( res, a,b)\ - do { \ - CHECK_OVERFLOW_OP((a).r,+,(b).r)\ - CHECK_OVERFLOW_OP((a).i,+,(b).i)\ - (res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \ - }while(0) -#define C_SUB( res, a,b)\ - do { \ - CHECK_OVERFLOW_OP((a).r,-,(b).r)\ - CHECK_OVERFLOW_OP((a).i,-,(b).i)\ - (res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \ - }while(0) -#define C_ADDTO( res , a)\ - do { \ - CHECK_OVERFLOW_OP((res).r,+,(a).r)\ - CHECK_OVERFLOW_OP((res).i,+,(a).i)\ - (res).r += (a).r; (res).i += (a).i;\ - }while(0) - -#define C_SUBFROM( res , a)\ - do {\ - CHECK_OVERFLOW_OP((res).r,-,(a).r)\ - CHECK_OVERFLOW_OP((res).i,-,(a).i)\ - (res).r -= (a).r; (res).i -= (a).i; \ - }while(0) - - -#ifdef FIXED_POINT -# define KISS_FFT_COS(phase) floor(.5+SAMP_MAX * cos (phase)) -# define KISS_FFT_SIN(phase) floor(.5+SAMP_MAX * sin (phase)) -# define HALF_OF(x) ((x)>>1) -#elif defined(USE_SIMD) -# define KISS_FFT_COS(phase) _mm_set1_ps( cos(phase) ) -# define KISS_FFT_SIN(phase) _mm_set1_ps( sin(phase) ) -# define HALF_OF(x) ((x)*_mm_set1_ps(.5)) -#else -# define KISS_FFT_COS(phase) (kiss_fft_scalar) cos(phase) -# define KISS_FFT_SIN(phase) (kiss_fft_scalar) sin(phase) -# define HALF_OF(x) ((x)*.5) -#endif - -#define kf_cexp(x,phase) \ - do{ \ - (x)->r = KISS_FFT_COS(phase);\ - (x)->i = KISS_FFT_SIN(phase);\ - }while(0) - - -/* a debugging function */ -#define pcpx(c)\ - fprintf(stderr,"%g + %gi\n",(double)((c)->r),(double)((c)->i) ) - - -#ifdef KISS_FFT_USE_ALLOCA -// define this to allow use of alloca instead of malloc for temporary buffers -// Temporary buffers are used in two case: -// 1. FFT sizes that have "bad" factors. i.e. not 2,3 and 5 -// 2. "in-place" FFTs. Notice the quotes, since kissfft does not really do an in-place transform. -#include -#define KISS_FFT_TMP_ALLOC(nbytes) alloca(nbytes) -#define KISS_FFT_TMP_FREE(ptr) -#else -#define KISS_FFT_TMP_ALLOC(nbytes) KISS_FFT_MALLOC(nbytes) -#define KISS_FFT_TMP_FREE(ptr) KISS_FFT_FREE(ptr) -#endif diff --git a/libmusly/kissfft/kiss_fft.c b/libmusly/kissfft/kiss_fft.c deleted file mode 100644 index 465d6c9..0000000 --- a/libmusly/kissfft/kiss_fft.c +++ /dev/null @@ -1,408 +0,0 @@ -/* -Copyright (c) 2003-2010, Mark Borgerding - -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. - * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -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 OWNER 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. -*/ - - -#include "_kiss_fft_guts.h" -/* The guts header contains all the multiplication and addition macros that are defined for - fixed or floating point complex numbers. It also delares the kf_ internal functions. - */ - -static void kf_bfly2( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_cfg st, - int m - ) -{ - kiss_fft_cpx * Fout2; - kiss_fft_cpx * tw1 = st->twiddles; - kiss_fft_cpx t; - Fout2 = Fout + m; - do{ - C_FIXDIV(*Fout,2); C_FIXDIV(*Fout2,2); - - C_MUL (t, *Fout2 , *tw1); - tw1 += fstride; - C_SUB( *Fout2 , *Fout , t ); - C_ADDTO( *Fout , t ); - ++Fout2; - ++Fout; - }while (--m); -} - -static void kf_bfly4( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_cfg st, - const size_t m - ) -{ - kiss_fft_cpx *tw1,*tw2,*tw3; - kiss_fft_cpx scratch[6]; - size_t k=m; - const size_t m2=2*m; - const size_t m3=3*m; - - - tw3 = tw2 = tw1 = st->twiddles; - - do { - C_FIXDIV(*Fout,4); C_FIXDIV(Fout[m],4); C_FIXDIV(Fout[m2],4); C_FIXDIV(Fout[m3],4); - - C_MUL(scratch[0],Fout[m] , *tw1 ); - C_MUL(scratch[1],Fout[m2] , *tw2 ); - C_MUL(scratch[2],Fout[m3] , *tw3 ); - - C_SUB( scratch[5] , *Fout, scratch[1] ); - C_ADDTO(*Fout, scratch[1]); - C_ADD( scratch[3] , scratch[0] , scratch[2] ); - C_SUB( scratch[4] , scratch[0] , scratch[2] ); - C_SUB( Fout[m2], *Fout, scratch[3] ); - tw1 += fstride; - tw2 += fstride*2; - tw3 += fstride*3; - C_ADDTO( *Fout , scratch[3] ); - - if(st->inverse) { - Fout[m].r = scratch[5].r - scratch[4].i; - Fout[m].i = scratch[5].i + scratch[4].r; - Fout[m3].r = scratch[5].r + scratch[4].i; - Fout[m3].i = scratch[5].i - scratch[4].r; - }else{ - Fout[m].r = scratch[5].r + scratch[4].i; - Fout[m].i = scratch[5].i - scratch[4].r; - Fout[m3].r = scratch[5].r - scratch[4].i; - Fout[m3].i = scratch[5].i + scratch[4].r; - } - ++Fout; - }while(--k); -} - -static void kf_bfly3( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_cfg st, - size_t m - ) -{ - size_t k=m; - const size_t m2 = 2*m; - kiss_fft_cpx *tw1,*tw2; - kiss_fft_cpx scratch[5]; - kiss_fft_cpx epi3; - epi3 = st->twiddles[fstride*m]; - - tw1=tw2=st->twiddles; - - do{ - C_FIXDIV(*Fout,3); C_FIXDIV(Fout[m],3); C_FIXDIV(Fout[m2],3); - - C_MUL(scratch[1],Fout[m] , *tw1); - C_MUL(scratch[2],Fout[m2] , *tw2); - - C_ADD(scratch[3],scratch[1],scratch[2]); - C_SUB(scratch[0],scratch[1],scratch[2]); - tw1 += fstride; - tw2 += fstride*2; - - Fout[m].r = Fout->r - HALF_OF(scratch[3].r); - Fout[m].i = Fout->i - HALF_OF(scratch[3].i); - - C_MULBYSCALAR( scratch[0] , epi3.i ); - - C_ADDTO(*Fout,scratch[3]); - - Fout[m2].r = Fout[m].r + scratch[0].i; - Fout[m2].i = Fout[m].i - scratch[0].r; - - Fout[m].r -= scratch[0].i; - Fout[m].i += scratch[0].r; - - ++Fout; - }while(--k); -} - -static void kf_bfly5( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_cfg st, - int m - ) -{ - kiss_fft_cpx *Fout0,*Fout1,*Fout2,*Fout3,*Fout4; - int u; - kiss_fft_cpx scratch[13]; - kiss_fft_cpx * twiddles = st->twiddles; - kiss_fft_cpx *tw; - kiss_fft_cpx ya,yb; - ya = twiddles[fstride*m]; - yb = twiddles[fstride*2*m]; - - Fout0=Fout; - Fout1=Fout0+m; - Fout2=Fout0+2*m; - Fout3=Fout0+3*m; - Fout4=Fout0+4*m; - - tw=st->twiddles; - for ( u=0; ur += scratch[7].r + scratch[8].r; - Fout0->i += scratch[7].i + scratch[8].i; - - scratch[5].r = scratch[0].r + S_MUL(scratch[7].r,ya.r) + S_MUL(scratch[8].r,yb.r); - scratch[5].i = scratch[0].i + S_MUL(scratch[7].i,ya.r) + S_MUL(scratch[8].i,yb.r); - - scratch[6].r = S_MUL(scratch[10].i,ya.i) + S_MUL(scratch[9].i,yb.i); - scratch[6].i = -S_MUL(scratch[10].r,ya.i) - S_MUL(scratch[9].r,yb.i); - - C_SUB(*Fout1,scratch[5],scratch[6]); - C_ADD(*Fout4,scratch[5],scratch[6]); - - scratch[11].r = scratch[0].r + S_MUL(scratch[7].r,yb.r) + S_MUL(scratch[8].r,ya.r); - scratch[11].i = scratch[0].i + S_MUL(scratch[7].i,yb.r) + S_MUL(scratch[8].i,ya.r); - scratch[12].r = - S_MUL(scratch[10].i,yb.i) + S_MUL(scratch[9].i,ya.i); - scratch[12].i = S_MUL(scratch[10].r,yb.i) - S_MUL(scratch[9].r,ya.i); - - C_ADD(*Fout2,scratch[11],scratch[12]); - C_SUB(*Fout3,scratch[11],scratch[12]); - - ++Fout0;++Fout1;++Fout2;++Fout3;++Fout4; - } -} - -/* perform the butterfly for one stage of a mixed radix FFT */ -static void kf_bfly_generic( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_cfg st, - int m, - int p - ) -{ - int u,k,q1,q; - kiss_fft_cpx * twiddles = st->twiddles; - kiss_fft_cpx t; - int Norig = st->nfft; - - kiss_fft_cpx * scratch = (kiss_fft_cpx*)KISS_FFT_TMP_ALLOC(sizeof(kiss_fft_cpx)*p); - - for ( u=0; u=Norig) twidx-=Norig; - C_MUL(t,scratch[q] , twiddles[twidx] ); - C_ADDTO( Fout[ k ] ,t); - } - k += m; - } - } - KISS_FFT_TMP_FREE(scratch); -} - -static -void kf_work( - kiss_fft_cpx * Fout, - const kiss_fft_cpx * f, - const size_t fstride, - int in_stride, - int * factors, - const kiss_fft_cfg st - ) -{ - kiss_fft_cpx * Fout_beg=Fout; - const int p=*factors++; /* the radix */ - const int m=*factors++; /* stage's fft length/p */ - const kiss_fft_cpx * Fout_end = Fout + p*m; - -#ifdef _OPENMP - // use openmp extensions at the - // top-level (not recursive) - if (fstride==1 && p<=5) - { - int k; - - // execute the p different work units in different threads -# pragma omp parallel for - for (k=0;k floor_sqrt) - p = n; /* no more factors, skip to end */ - } - n /= p; - *facbuf++ = p; - *facbuf++ = n; - } while (n > 1); -} - -/* - * - * User-callable function to allocate all necessary storage space for the fft. - * - * The return value is a contiguous block of memory, allocated with malloc. As such, - * It can be freed with free(), rather than a kiss_fft-specific function. - * */ -kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem ) -{ - kiss_fft_cfg st=NULL; - size_t memneeded = sizeof(struct kiss_fft_state) - + sizeof(kiss_fft_cpx)*(nfft-1); /* twiddle factors*/ - - if ( lenmem==NULL ) { - st = ( kiss_fft_cfg)KISS_FFT_MALLOC( memneeded ); - }else{ - if (mem != NULL && *lenmem >= memneeded) - st = (kiss_fft_cfg)mem; - *lenmem = memneeded; - } - if (st) { - int i; - st->nfft=nfft; - st->inverse = inverse_fft; - - for (i=0;iinverse) - phase *= -1; - kf_cexp(st->twiddles+i, phase ); - } - - kf_factor(nfft,st->factors); - } - return st; -} - - -void kiss_fft_stride(kiss_fft_cfg st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int in_stride) -{ - if (fin == fout) { - //NOTE: this is not really an in-place FFT algorithm. - //It just performs an out-of-place FFT into a temp buffer - kiss_fft_cpx * tmpbuf = (kiss_fft_cpx*)KISS_FFT_TMP_ALLOC( sizeof(kiss_fft_cpx)*st->nfft); - kf_work(tmpbuf,fin,1,in_stride, st->factors,st); - memcpy(fout,tmpbuf,sizeof(kiss_fft_cpx)*st->nfft); - KISS_FFT_TMP_FREE(tmpbuf); - }else{ - kf_work( fout, fin, 1,in_stride, st->factors,st ); - } -} - -void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout) -{ - kiss_fft_stride(cfg,fin,fout,1); -} - - -void kiss_fft_cleanup(void) -{ - // nothing needed any more -} - -int kiss_fft_next_fast_size(int n) -{ - while(1) { - int m=n; - while ( (m%2) == 0 ) m/=2; - while ( (m%3) == 0 ) m/=3; - while ( (m%5) == 0 ) m/=5; - if (m<=1) - break; /* n is completely factorable by twos, threes, and fives */ - n++; - } - return n; -} diff --git a/libmusly/kissfft/kiss_fft.h b/libmusly/kissfft/kiss_fft.h deleted file mode 100644 index 64c50f4..0000000 --- a/libmusly/kissfft/kiss_fft.h +++ /dev/null @@ -1,124 +0,0 @@ -#ifndef KISS_FFT_H -#define KISS_FFT_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - ATTENTION! - If you would like a : - -- a utility that will handle the caching of fft objects - -- real-only (no imaginary time component ) FFT - -- a multi-dimensional FFT - -- a command-line utility to perform ffts - -- a command-line utility to perform fast-convolution filtering - - Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c - in the tools/ directory. -*/ - -#ifdef USE_SIMD -# include -# define kiss_fft_scalar __m128 -#define KISS_FFT_MALLOC(nbytes) _mm_malloc(nbytes,16) -#define KISS_FFT_FREE _mm_free -#else -#define KISS_FFT_MALLOC malloc -#define KISS_FFT_FREE free -#endif - - -#ifdef FIXED_POINT -#include -# if (FIXED_POINT == 32) -# define kiss_fft_scalar int32_t -# else -# define kiss_fft_scalar int16_t -# endif -#else -# ifndef kiss_fft_scalar -/* default is float */ -# define kiss_fft_scalar float -# endif -#endif - -typedef struct { - kiss_fft_scalar r; - kiss_fft_scalar i; -}kiss_fft_cpx; - -typedef struct kiss_fft_state* kiss_fft_cfg; - -/* - * kiss_fft_alloc - * - * Initialize a FFT (or IFFT) algorithm's cfg/state buffer. - * - * typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL); - * - * The return value from fft_alloc is a cfg buffer used internally - * by the fft routine or NULL. - * - * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc. - * The returned value should be free()d when done to avoid memory leaks. - * - * The state can be placed in a user supplied buffer 'mem': - * If lenmem is not NULL and mem is not NULL and *lenmem is large enough, - * then the function places the cfg in mem and the size used in *lenmem - * and returns mem. - * - * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough), - * then the function returns NULL and places the minimum cfg - * buffer size in *lenmem. - * */ - -kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem); - -/* - * kiss_fft(cfg,in_out_buf) - * - * Perform an FFT on a complex input buffer. - * for a forward FFT, - * fin should be f[0] , f[1] , ... ,f[nfft-1] - * fout will be F[0] , F[1] , ... ,F[nfft-1] - * Note that each element is complex and can be accessed like - f[k].r and f[k].i - * */ -void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); - -/* - A more generic version of the above function. It reads its input from every Nth sample. - * */ -void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride); - -/* If kiss_fft_alloc allocated a buffer, it is one contiguous - buffer and can be simply free()d when no longer needed*/ -#define kiss_fft_free free - -/* - Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up - your compiler output to call this before you exit. -*/ -void kiss_fft_cleanup(void); - - -/* - * Returns the smallest integer k, such that k>=n and k has only "fast" factors (2,3,5) - */ -int kiss_fft_next_fast_size(int n); - -/* for real ffts, we need an even size */ -#define kiss_fftr_next_fast_size_real(n) \ - (kiss_fft_next_fast_size( ((n)+1)>>1)<<1) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libmusly/kissfft/kiss_fftr.c b/libmusly/kissfft/kiss_fftr.c deleted file mode 100644 index b8e238b..0000000 --- a/libmusly/kissfft/kiss_fftr.c +++ /dev/null @@ -1,159 +0,0 @@ -/* -Copyright (c) 2003-2004, Mark Borgerding - -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. - * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -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 OWNER 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. -*/ - -#include "kiss_fftr.h" -#include "_kiss_fft_guts.h" - -struct kiss_fftr_state{ - kiss_fft_cfg substate; - kiss_fft_cpx * tmpbuf; - kiss_fft_cpx * super_twiddles; -#ifdef USE_SIMD - void * pad; -#endif -}; - -kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem) -{ - int i; - kiss_fftr_cfg st = NULL; - size_t subsize, memneeded; - - if (nfft & 1) { - fprintf(stderr,"Real FFT optimization must be even.\n"); - return NULL; - } - nfft >>= 1; - - kiss_fft_alloc (nfft, inverse_fft, NULL, &subsize); - memneeded = sizeof(struct kiss_fftr_state) + subsize + sizeof(kiss_fft_cpx) * ( nfft * 3 / 2); - - if (lenmem == NULL) { - st = (kiss_fftr_cfg) KISS_FFT_MALLOC (memneeded); - } else { - if (*lenmem >= memneeded) - st = (kiss_fftr_cfg) mem; - *lenmem = memneeded; - } - if (!st) - return NULL; - - st->substate = (kiss_fft_cfg) (st + 1); /*just beyond kiss_fftr_state struct */ - st->tmpbuf = (kiss_fft_cpx *) (((char *) st->substate) + subsize); - st->super_twiddles = st->tmpbuf + nfft; - kiss_fft_alloc(nfft, inverse_fft, st->substate, &subsize); - - for (i = 0; i < nfft/2; ++i) { - double phase = - -3.14159265358979323846264338327 * ((double) (i+1) / nfft + .5); - if (inverse_fft) - phase *= -1; - kf_cexp (st->super_twiddles+i,phase); - } - return st; -} - -void kiss_fftr(kiss_fftr_cfg st,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata) -{ - /* input buffer timedata is stored row-wise */ - int k,ncfft; - kiss_fft_cpx fpnk,fpk,f1k,f2k,tw,tdc; - - if ( st->substate->inverse) { - fprintf(stderr,"kiss fft usage error: improper alloc\n"); - exit(1); - } - - ncfft = st->substate->nfft; - - /*perform the parallel fft of two real signals packed in real,imag*/ - kiss_fft( st->substate , (const kiss_fft_cpx*)timedata, st->tmpbuf ); - /* The real part of the DC element of the frequency spectrum in st->tmpbuf - * contains the sum of the even-numbered elements of the input time sequence - * The imag part is the sum of the odd-numbered elements - * - * The sum of tdc.r and tdc.i is the sum of the input time sequence. - * yielding DC of input time sequence - * The difference of tdc.r - tdc.i is the sum of the input (dot product) [1,-1,1,-1... - * yielding Nyquist bin of input time sequence - */ - - tdc.r = st->tmpbuf[0].r; - tdc.i = st->tmpbuf[0].i; - C_FIXDIV(tdc,2); - CHECK_OVERFLOW_OP(tdc.r ,+, tdc.i); - CHECK_OVERFLOW_OP(tdc.r ,-, tdc.i); - freqdata[0].r = tdc.r + tdc.i; - freqdata[ncfft].r = tdc.r - tdc.i; -#ifdef USE_SIMD - freqdata[ncfft].i = freqdata[0].i = _mm_set1_ps(0); -#else - freqdata[ncfft].i = freqdata[0].i = 0; -#endif - - for ( k=1;k <= ncfft/2 ; ++k ) { - fpk = st->tmpbuf[k]; - fpnk.r = st->tmpbuf[ncfft-k].r; - fpnk.i = - st->tmpbuf[ncfft-k].i; - C_FIXDIV(fpk,2); - C_FIXDIV(fpnk,2); - - C_ADD( f1k, fpk , fpnk ); - C_SUB( f2k, fpk , fpnk ); - C_MUL( tw , f2k , st->super_twiddles[k-1]); - - freqdata[k].r = HALF_OF(f1k.r + tw.r); - freqdata[k].i = HALF_OF(f1k.i + tw.i); - freqdata[ncfft-k].r = HALF_OF(f1k.r - tw.r); - freqdata[ncfft-k].i = HALF_OF(tw.i - f1k.i); - } -} - -void kiss_fftri(kiss_fftr_cfg st,const kiss_fft_cpx *freqdata,kiss_fft_scalar *timedata) -{ - /* input buffer timedata is stored row-wise */ - int k, ncfft; - - if (st->substate->inverse == 0) { - fprintf (stderr, "kiss fft usage error: improper alloc\n"); - exit (1); - } - - ncfft = st->substate->nfft; - - st->tmpbuf[0].r = freqdata[0].r + freqdata[ncfft].r; - st->tmpbuf[0].i = freqdata[0].r - freqdata[ncfft].r; - C_FIXDIV(st->tmpbuf[0],2); - - for (k = 1; k <= ncfft / 2; ++k) { - kiss_fft_cpx fk, fnkc, fek, fok, tmp; - fk = freqdata[k]; - fnkc.r = freqdata[ncfft - k].r; - fnkc.i = -freqdata[ncfft - k].i; - C_FIXDIV( fk , 2 ); - C_FIXDIV( fnkc , 2 ); - - C_ADD (fek, fk, fnkc); - C_SUB (tmp, fk, fnkc); - C_MUL (fok, tmp, st->super_twiddles[k-1]); - C_ADD (st->tmpbuf[k], fek, fok); - C_SUB (st->tmpbuf[ncfft - k], fek, fok); -#ifdef USE_SIMD - st->tmpbuf[ncfft - k].i *= _mm_set1_ps(-1.0); -#else - st->tmpbuf[ncfft - k].i *= -1; -#endif - } - kiss_fft (st->substate, st->tmpbuf, (kiss_fft_cpx *) timedata); -} diff --git a/libmusly/kissfft/kiss_fftr.h b/libmusly/kissfft/kiss_fftr.h deleted file mode 100644 index 72e5a57..0000000 --- a/libmusly/kissfft/kiss_fftr.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef KISS_FTR_H -#define KISS_FTR_H - -#include "kiss_fft.h" -#ifdef __cplusplus -extern "C" { -#endif - - -/* - - Real optimized version can save about 45% cpu time vs. complex fft of a real seq. - - - - */ - -typedef struct kiss_fftr_state *kiss_fftr_cfg; - - -kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem, size_t * lenmem); -/* - nfft must be even - - If you don't care to allocate space, use mem = lenmem = NULL -*/ - - -void kiss_fftr(kiss_fftr_cfg cfg,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata); -/* - input timedata has nfft scalar points - output freqdata has nfft/2+1 complex points -*/ - -void kiss_fftri(kiss_fftr_cfg cfg,const kiss_fft_cpx *freqdata,kiss_fft_scalar *timedata); -/* - input freqdata has nfft/2+1 complex points - output timedata has nfft scalar points -*/ - -#define kiss_fftr_free free - -#ifdef __cplusplus -} -#endif -#endif diff --git a/libmusly/libresample/CMakeLists.txt b/libmusly/libresample/CMakeLists.txt deleted file mode 100644 index ab29a74..0000000 --- a/libmusly/libresample/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -# CMake buildfile generator file. -# Process with cmake to create your desired buildfiles. - -# (c) 2013-2014, Dominik Schnitzer - -find_file(HAVE_INTTYPES inttypes.h) -configure_file(config.h.in config.h) - -add_library(musly_resample - filterkit.c - resamplesubs.c - resample.c) - -target_include_directories(musly_resample PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}) - -set(LIBMUSLY_LIBS - ${LIBMUSLY_LIBS} - musly_resample - PARENT_SCOPE) - -install(TARGETS musly_resample - DESTINATION lib) diff --git a/libmusly/libresample/LICENSE-BSD.txt b/libmusly/libresample/LICENSE-BSD.txt deleted file mode 100644 index 9372da4..0000000 --- a/libmusly/libresample/LICENSE-BSD.txt +++ /dev/null @@ -1,23 +0,0 @@ -Copyright (c) 2003, Dominic Mazzoni -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. diff --git a/libmusly/libresample/LICENSE-LGPL.txt b/libmusly/libresample/LICENSE-LGPL.txt deleted file mode 100644 index 4ccd6cc..0000000 --- a/libmusly/libresample/LICENSE-LGPL.txt +++ /dev/null @@ -1,463 +0,0 @@ - - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations -below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control -compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply, and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License -may add an explicit geographical distribution limitation excluding those -countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - diff --git a/libmusly/libresample/README.md b/libmusly/libresample/README.md deleted file mode 100644 index 9b09bb9..0000000 --- a/libmusly/libresample/README.md +++ /dev/null @@ -1,117 +0,0 @@ -libresample -=========== - -Real-time library interface by Dominic Mazzoni - -Based on resample-1.7: - http://www-ccrma.stanford.edu/~jos/resample/ - -Two licenses available: -License: LGPL - see LICENSE-LGPL.txt -License: BSD - see LICENSE-BSD.txt - -History: - -This library is not the highest-quality resampling library -available, nor is it the most flexible, nor is it the -fastest. But it is pretty good in all of these regards, and -it is quite portable. The best resampling library I am aware -of is libsamplerate by Erik de Castro Lopo. It's small, fast, -and very high quality. However, it uses the GPL for its -license (with commercial options available) and I needed -a more free library. So I wrote this library, using -the LGPL resample-1.7 library by Julius Smith as a basis. - -Resample-1.7 is a fixed-point resampler, and as a result -has only limited precision. I rewrote it to use single-precision -floating-point arithmetic instead and increased the number -of filter coefficients between time steps significantly. -On modern processors it can resample in real time even -with this extra overhead. - -Resample-1.7 was designed to read and write from files, so -I removed all of that code and replaced it with an API that -lets you pass samples in small chunks. It should be easy -to link to resample-1.7 as a library. - -Changes in version 0.1.3: - -* Fixed two bugs that were causing subtle problems - on Intel x86 processors due to differences in roundoff errors. - -* Prefixed most function names with lrs and changed header file - from resample.h to libresample.h, to avoid namespace - collisions with existing programs and libraries. - -* Added resample_dup (thanks to Glenn Maynard) - -* Argument to resample_get_filter_width takes a const void * - (thanks to Glenn Maynard) - -* resample-sndfile clips output to -1...1 (thanks to Glenn Maynard) - -Changes in version 0.1.4: - -* Added BSD license, with support from all authors and contributors. - -* Uploaded to GitHub: http://github.com/minorninth/libresample - -Usage notes: - -- If the output buffer you pass is too small, resample_process - may not use any input samples because its internal output - buffer is too full to process any more. So do not assume - that it is an error just because no input samples were - consumed. Just keep passing valid output buffers. - -- Given a resampling factor f > 1, and a number of input - samples n, the number of output samples should be between - floor(n - f) and ceil(n + f). In other words, if you - resample 1000 samples at a factor of 8, the number of - output samples might be between 7992 and 8008. Do not - assume that it will be exactly 8000. If you need exactly - 8000 outputs, pad the input with extra zeros as necessary. - -License and warranty: - -All of the files in this package are Copyright 2003 by Dominic -Mazzoni . This library was based heavily -on Resample-1.7, Copyright 1994-2002 by Julius O. Smith III -, all rights reserved. - -Permission to use and copy is granted subject to the terms of the -"GNU Lesser General Public License" (LGPL) as published by the -Free Software Foundation; either version 2.1 of the License, -or any later version. In addition, Julius O. Smith III requests -that a copy of any modified files be sent by email to -jos@ccrma.stanford.edu so that he may incorporate them into the -CCRMA version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - -Permission to use and copy is also granted subject to the terms of the -BSD license found in LICENSE-BSD.txt. - -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. diff --git a/libmusly/libresample/config.h.in b/libmusly/libresample/config.h.in deleted file mode 100644 index 7cefdb4..0000000 --- a/libmusly/libresample/config.h.in +++ /dev/null @@ -1 +0,0 @@ -#cmakedefine HAVE_INTTYPES diff --git a/libmusly/libresample/filterkit.c b/libmusly/libresample/filterkit.c deleted file mode 100644 index d4360a4..0000000 --- a/libmusly/libresample/filterkit.c +++ /dev/null @@ -1,215 +0,0 @@ -/********************************************************************** - - resamplesubs.c - - Real-time library interface by Dominic Mazzoni - - Based on resample-1.7: - http://www-ccrma.stanford.edu/~jos/resample/ - - Dual-licensed as LGPL and BSD; see README.md and LICENSE* files. - - This file provides Kaiser-windowed low-pass filter support, - including a function to create the filter coefficients, and - two functions to apply the filter at a particular point. - -**********************************************************************/ - -/* Definitions */ -#include "resample_defs.h" - -#include "filterkit.h" - -#include -#include -#include -#include - -/* LpFilter() - * - * reference: "Digital Filters, 2nd edition" - * R.W. Hamming, pp. 178-179 - * - * Izero() computes the 0th order modified bessel function of the first kind. - * (Needed to compute Kaiser window). - * - * LpFilter() computes the coeffs of a Kaiser-windowed low pass filter with - * the following characteristics: - * - * c[] = array in which to store computed coeffs - * frq = roll-off frequency of filter - * N = Half the window length in number of coeffs - * Beta = parameter of Kaiser window - * Num = number of coeffs before 1/frq - * - * Beta trades the rejection of the lowpass filter against the transition - * width from passband to stopband. Larger Beta means a slower - * transition and greater stopband rejection. See Rabiner and Gold - * (Theory and Application of DSP) under Kaiser windows for more about - * Beta. The following table from Rabiner and Gold gives some feel - * for the effect of Beta: - * - * All ripples in dB, width of transition band = D*N where N = window length - * - * BETA D PB RIP SB RIP - * 2.120 1.50 +-0.27 -30 - * 3.384 2.23 0.0864 -40 - * 4.538 2.93 0.0274 -50 - * 5.658 3.62 0.00868 -60 - * 6.764 4.32 0.00275 -70 - * 7.865 5.0 0.000868 -80 - * 8.960 5.7 0.000275 -90 - * 10.056 6.4 0.000087 -100 - */ - -#define IzeroEPSILON 1E-21 /* Max error acceptable in Izero */ - -static double Izero(double x) -{ - double sum, u, halfx, temp; - int n; - - sum = u = n = 1; - halfx = x/2.0; - do { - temp = halfx/(double)n; - n += 1; - temp *= temp; - u *= temp; - sum += u; - } while (u >= IzeroEPSILON*sum); - return(sum); -} - -void lrsLpFilter(double c[], int N, double frq, double Beta, int Num) -{ - double IBeta, temp, temp1, inm1; - int i; - - /* Calculate ideal lowpass filter impulse response coefficients: */ - c[0] = 2.0*frq; - for (i=1; i -#include -#include -#include - -typedef struct { - float *Imp; - float *ImpD; - float LpScl; - UWORD Nmult; - UWORD Nwing; - double minFactor; - double maxFactor; - UWORD XSize; - float *X; - UWORD Xp; /* Current "now"-sample pointer for input */ - UWORD Xread; /* Position to put new samples */ - UWORD Xoff; - UWORD YSize; - float *Y; - UWORD Yp; - double Time; -} rsdata; - -void *resample_dup(const void * handle) -{ - const rsdata *cpy = (const rsdata *)handle; - rsdata *hp = (rsdata *)malloc(sizeof(rsdata)); - - hp->minFactor = cpy->minFactor; - hp->maxFactor = cpy->maxFactor; - hp->Nmult = cpy->Nmult; - hp->LpScl = cpy->LpScl; - hp->Nwing = cpy->Nwing; - - hp->Imp = (float *)malloc(hp->Nwing * sizeof(float)); - memcpy(hp->Imp, cpy->Imp, hp->Nwing * sizeof(float)); - hp->ImpD = (float *)malloc(hp->Nwing * sizeof(float)); - memcpy(hp->ImpD, cpy->ImpD, hp->Nwing * sizeof(float)); - - hp->Xoff = cpy->Xoff; - hp->XSize = cpy->XSize; - hp->X = (float *)malloc((hp->XSize + hp->Xoff) * sizeof(float)); - memcpy(hp->X, cpy->X, (hp->XSize + hp->Xoff) * sizeof(float)); - hp->Xp = cpy->Xp; - hp->Xread = cpy->Xread; - hp->YSize = cpy->YSize; - hp->Y = (float *)malloc(hp->YSize * sizeof(float)); - memcpy(hp->Y, cpy->Y, hp->YSize * sizeof(float)); - hp->Yp = cpy->Yp; - hp->Time = cpy->Time; - - return (void *)hp; -} - -void *resample_open(int highQuality, double minFactor, double maxFactor) -{ - double *Imp64; - double Rolloff, Beta; - rsdata *hp; - UWORD Xoff_min, Xoff_max; - int i; - - /* Just exit if we get invalid factors */ - if (minFactor <= 0.0 || maxFactor <= 0.0 || maxFactor < minFactor) { - #if DEBUG - fprintf(stderr, - "libresample: " - "minFactor and maxFactor must be positive real numbers,\n" - "and maxFactor should be larger than minFactor.\n"); - #endif - return 0; - } - - hp = (rsdata *)malloc(sizeof(rsdata)); - - hp->minFactor = minFactor; - hp->maxFactor = maxFactor; - - if (highQuality) - hp->Nmult = 35; - else - hp->Nmult = 11; - - hp->LpScl = 1.0; - hp->Nwing = Npc*(hp->Nmult-1)/2; /* # of filter coeffs in right wing */ - - Rolloff = 0.90; - Beta = 6; - - Imp64 = (double *)malloc(hp->Nwing * sizeof(double)); - - lrsLpFilter(Imp64, hp->Nwing, 0.5*Rolloff, Beta, Npc); - - hp->Imp = (float *)malloc(hp->Nwing * sizeof(float)); - hp->ImpD = (float *)malloc(hp->Nwing * sizeof(float)); - for(i=0; iNwing; i++) - hp->Imp[i] = Imp64[i]; - - /* Storing deltas in ImpD makes linear interpolation - of the filter coefficients faster */ - for (i=0; iNwing-1; i++) - hp->ImpD[i] = hp->Imp[i+1] - hp->Imp[i]; - - /* Last coeff. not interpolated */ - hp->ImpD[hp->Nwing-1] = - hp->Imp[hp->Nwing-1]; - - free(Imp64); - - /* Calc reach of LP filter wing (plus some creeping room) */ - Xoff_min = ((hp->Nmult+1)/2.0) * MAX(1.0, 1.0/minFactor) + 10; - Xoff_max = ((hp->Nmult+1)/2.0) * MAX(1.0, 1.0/maxFactor) + 10; - hp->Xoff = MAX(Xoff_min, Xoff_max); - - /* Make the inBuffer size at least 4096, but larger if necessary - in order to store the minimum reach of the LP filter and then some. - Then allocate the buffer an extra Xoff larger so that - we can zero-pad up to Xoff zeros at the end when we reach the - end of the input samples. */ - hp->XSize = MAX(2*hp->Xoff+10, 4096); - hp->X = (float *)malloc((hp->XSize + hp->Xoff) * sizeof(float)); - hp->Xp = hp->Xoff; - hp->Xread = hp->Xoff; - - /* Need Xoff zeros at begining of X buffer */ - for(i=0; iXoff; i++) - hp->X[i]=0; - - /* Make the outBuffer long enough to hold the entire processed - output of one inBuffer */ - hp->YSize = (int)(((double)hp->XSize)*maxFactor+2.0); - hp->Y = (float *)malloc(hp->YSize * sizeof(float)); - hp->Yp = 0; - - hp->Time = (double)hp->Xoff; /* Current-time pointer for converter */ - - return (void *)hp; -} - -int resample_get_filter_width(const void *handle) -{ - const rsdata *hp = (const rsdata *)handle; - return hp->Xoff; -} - -int resample_process(void *handle, - double factor, - float *inBuffer, - int inBufferLen, - int lastFlag, - int *inBufferUsed, /* output param */ - float *outBuffer, - int outBufferLen) -{ - rsdata *hp = (rsdata *)handle; - float *Imp = hp->Imp; - float *ImpD = hp->ImpD; - float LpScl = hp->LpScl; - UWORD Nwing = hp->Nwing; - BOOL interpFilt = FALSE; /* TRUE means interpolate filter coeffs */ - int outSampleCount; - UWORD Nout, Ncreep, Nreuse; - int Nx; - int i, len; - - #if DEBUG - fprintf(stderr, "resample_process: in=%d, out=%d lastFlag=%d\n", - inBufferLen, outBufferLen, lastFlag); - #endif - - /* Initialize inBufferUsed and outSampleCount to 0 */ - *inBufferUsed = 0; - outSampleCount = 0; - - if (factor < hp->minFactor || factor > hp->maxFactor) { - #if DEBUG - fprintf(stderr, - "libresample: factor %f is not between " - "minFactor=%f and maxFactor=%f", - factor, hp->minFactor, hp->maxFactor); - #endif - return -1; - } - - /* Start by copying any samples still in the Y buffer to the output - buffer */ - if (hp->Yp && (outBufferLen-outSampleCount)>0) { - len = MIN(outBufferLen-outSampleCount, hp->Yp); - for(i=0; iY[i]; - outSampleCount += len; - for(i=0; iYp-len; i++) - hp->Y[i] = hp->Y[i+len]; - hp->Yp -= len; - } - - /* If there are still output samples left, return now - we need - the full output buffer available to us... */ - if (hp->Yp) - return outSampleCount; - - /* Account for increased filter gain when using factors less than 1 */ - if (factor < 1) - LpScl = LpScl*factor; - - for(;;) { - - /* This is the maximum number of samples we can process - per loop iteration */ - - #ifdef DEBUG - printf("XSize: %d Xoff: %d Xread: %d Xp: %d lastFlag: %d\n", - hp->XSize, hp->Xoff, hp->Xread, hp->Xp, lastFlag); - #endif - - /* Copy as many samples as we can from the input buffer into X */ - len = hp->XSize - hp->Xread; - - if (len >= (inBufferLen - (*inBufferUsed))) - len = (inBufferLen - (*inBufferUsed)); - - for(i=0; iX[hp->Xread + i] = inBuffer[(*inBufferUsed) + i]; - - *inBufferUsed += len; - hp->Xread += len; - - if (lastFlag && (*inBufferUsed == inBufferLen)) { - /* If these are the last samples, zero-pad the - end of the input buffer and make sure we process - all the way to the end */ - Nx = hp->Xread - hp->Xoff; - for(i=0; iXoff; i++) - hp->X[hp->Xread + i] = 0; - } - else - Nx = hp->Xread - 2 * hp->Xoff; - - #ifdef DEBUG - fprintf(stderr, "new len=%d Nx=%d\n", len, Nx); - #endif - - if (Nx <= 0) - break; - - /* Resample stuff in input buffer */ - if (factor >= 1) { /* SrcUp() is faster if we can use it */ - Nout = lrsSrcUp(hp->X, hp->Y, factor, &hp->Time, Nx, - Nwing, LpScl, Imp, ImpD, interpFilt); - } - else { - Nout = lrsSrcUD(hp->X, hp->Y, factor, &hp->Time, Nx, - Nwing, LpScl, Imp, ImpD, interpFilt); - } - - #ifdef DEBUG - printf("Nout: %d\n", Nout); - #endif - - hp->Time -= Nx; /* Move converter Nx samples back in time */ - hp->Xp += Nx; /* Advance by number of samples processed */ - - /* Calc time accumulation in Time */ - Ncreep = (int)(hp->Time) - hp->Xoff; - if (Ncreep) { - hp->Time -= Ncreep; /* Remove time accumulation */ - hp->Xp += Ncreep; /* and add it to read pointer */ - } - - /* Copy part of input signal that must be re-used */ - Nreuse = hp->Xread - (hp->Xp - hp->Xoff); - - for (i=0; iX[i] = hp->X[i + (hp->Xp - hp->Xoff)]; - - #ifdef DEBUG - printf("New Xread=%d\n", Nreuse); - #endif - - hp->Xread = Nreuse; /* Pos in input buff to read new data into */ - hp->Xp = hp->Xoff; - - /* Check to see if output buff overflowed (shouldn't happen!) */ - if (Nout > hp->YSize) { - #ifdef DEBUG - printf("Nout: %d YSize: %d\n", Nout, hp->YSize); - #endif - fprintf(stderr, "libresample: Output array overflow!\n"); - return -1; - } - - hp->Yp = Nout; - - /* Copy as many samples as possible to the output buffer */ - if (hp->Yp && (outBufferLen-outSampleCount)>0) { - len = MIN(outBufferLen-outSampleCount, hp->Yp); - for(i=0; iY[i]; - outSampleCount += len; - for(i=0; iYp-len; i++) - hp->Y[i] = hp->Y[i+len]; - hp->Yp -= len; - } - - /* If there are still output samples left, return now, - since we need the full output buffer available */ - if (hp->Yp) - break; - } - - return outSampleCount; -} - -void resample_close(void *handle) -{ - rsdata *hp = (rsdata *)handle; - free(hp->X); - free(hp->Y); - free(hp->Imp); - free(hp->ImpD); - free(hp); -} - diff --git a/libmusly/libresample/resample_defs.h b/libmusly/libresample/resample_defs.h deleted file mode 100644 index a361f5d..0000000 --- a/libmusly/libresample/resample_defs.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************** - - resample_defs.h - - Real-time library interface by Dominic Mazzoni - - Based on resample-1.7: - http://www-ccrma.stanford.edu/~jos/resample/ - - Dual-licensed as LGPL and BSD; see README.md and LICENSE* files. - -**********************************************************************/ - -#ifndef __RESAMPLE_DEFS__ -#define __RESAMPLE_DEFS__ - -#if !defined(WIN32) && !defined(__CYGWIN__) -#include "config.h" -#endif - -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef PI -#define PI (3.14159265358979232846) -#endif - -#ifndef PI2 -#define PI2 (6.28318530717958465692) -#endif - -#define D2R (0.01745329348) /* (2*pi)/360 */ -#define R2D (57.29577951) /* 360/(2*pi) */ - -#ifndef MAX -#define MAX(x,y) ((x)>(y) ?(x):(y)) -#endif -#ifndef MIN -#define MIN(x,y) ((x)<(y) ?(x):(y)) -#endif - -#ifndef ABS -#define ABS(x) ((x)<0 ?(-(x)):(x)) -#endif - -#ifndef SGN -#define SGN(x) ((x)<0 ?(-1):((x)==0?(0):(1))) -#endif - -#if HAVE_INTTYPES_H - #include - typedef char BOOL; - typedef int32_t WORD; - typedef uint32_t UWORD; -#else - typedef char BOOL; - typedef int WORD; - typedef unsigned int UWORD; -#endif - -#ifdef DEBUG -#define INLINE -#else -#define INLINE inline -#endif - -/* Accuracy */ - -#define Npc 4096 - -/* Function prototypes */ - -int lrsSrcUp(float X[], float Y[], double factor, double *Time, - UWORD Nx, UWORD Nwing, float LpScl, - float Imp[], float ImpD[], BOOL Interp); - -int lrsSrcUD(float X[], float Y[], double factor, double *Time, - UWORD Nx, UWORD Nwing, float LpScl, - float Imp[], float ImpD[], BOOL Interp); - -#endif diff --git a/libmusly/libresample/resamplesubs.c b/libmusly/libresample/resamplesubs.c deleted file mode 100644 index 849d160..0000000 --- a/libmusly/libresample/resamplesubs.c +++ /dev/null @@ -1,123 +0,0 @@ -/********************************************************************** - - resamplesubs.c - - Real-time library interface by Dominic Mazzoni - - Based on resample-1.7: - http://www-ccrma.stanford.edu/~jos/resample/ - - Dual-licensed as LGPL and BSD; see README.md and LICENSE* files. - - This file provides the routines that do sample-rate conversion - on small arrays, calling routines from filterkit. - -**********************************************************************/ - -/* Definitions */ -#include "resample_defs.h" - -#include "filterkit.h" - -#include -#include -#include -#include - -/* Sampling rate up-conversion only subroutine; - * Slightly faster than down-conversion; - */ -int lrsSrcUp(float X[], - float Y[], - double factor, - double *TimePtr, - UWORD Nx, - UWORD Nwing, - float LpScl, - float Imp[], - float ImpD[], - BOOL Interp) -{ - float *Xp, *Ystart; - float v; - - double CurrentTime = *TimePtr; - double dt; /* Step through input signal */ - double endTime; /* When Time reaches EndTime, return to user */ - - dt = 1.0/factor; /* Output sampling period */ - - Ystart = Y; - endTime = CurrentTime + Nx; - while (CurrentTime < endTime) - { - double LeftPhase = CurrentTime-floor(CurrentTime); - double RightPhase = 1.0 - LeftPhase; - - Xp = &X[(int)CurrentTime]; /* Ptr to current input sample */ - /* Perform left-wing inner product */ - v = lrsFilterUp(Imp, ImpD, Nwing, Interp, Xp, - LeftPhase, -1); - /* Perform right-wing inner product */ - v += lrsFilterUp(Imp, ImpD, Nwing, Interp, Xp+1, - RightPhase, 1); - - v *= LpScl; /* Normalize for unity filter gain */ - - *Y++ = v; /* Deposit output */ - CurrentTime += dt; /* Move to next sample by time increment */ - } - - *TimePtr = CurrentTime; - return (Y - Ystart); /* Return the number of output samples */ -} - -/* Sampling rate conversion subroutine */ - -int lrsSrcUD(float X[], - float Y[], - double factor, - double *TimePtr, - UWORD Nx, - UWORD Nwing, - float LpScl, - float Imp[], - float ImpD[], - BOOL Interp) -{ - float *Xp, *Ystart; - float v; - - double CurrentTime = (*TimePtr); - double dh; /* Step through filter impulse response */ - double dt; /* Step through input signal */ - double endTime; /* When Time reaches EndTime, return to user */ - - dt = 1.0/factor; /* Output sampling period */ - - dh = MIN(Npc, factor*Npc); /* Filter sampling period */ - - Ystart = Y; - endTime = CurrentTime + Nx; - while (CurrentTime < endTime) - { - double LeftPhase = CurrentTime-floor(CurrentTime); - double RightPhase = 1.0 - LeftPhase; - - Xp = &X[(int)CurrentTime]; /* Ptr to current input sample */ - /* Perform left-wing inner product */ - v = lrsFilterUD(Imp, ImpD, Nwing, Interp, Xp, - LeftPhase, -1, dh); - /* Perform right-wing inner product */ - v += lrsFilterUD(Imp, ImpD, Nwing, Interp, Xp+1, - RightPhase, 1, dh); - - v *= LpScl; /* Normalize for unity filter gain */ - *Y++ = v; /* Deposit output */ - - CurrentTime += dt; /* Move to next sample by time increment */ - } - - *TimePtr = CurrentTime; - return (Y - Ystart); /* Return the number of output samples */ -} diff --git a/libmusly/powerspectrum.h b/libmusly/powerspectrum.h index 6957db4..096fc31 100644 --- a/libmusly/powerspectrum.h +++ b/libmusly/powerspectrum.h @@ -14,7 +14,7 @@ #include extern "C" { - #include "kissfft/kiss_fftr.h" + #include } diff --git a/libmusly/resampler.h b/libmusly/resampler.h index df8aaa4..f48e22a 100644 --- a/libmusly/resampler.h +++ b/libmusly/resampler.h @@ -14,7 +14,7 @@ #include extern "C" { - #include "libresample/libresample.h" + #include } namespace musly {