Commit af810089 authored by Gargaj's avatar Gargaj
Browse files

Merge branch 'drop-the-bass'

parents 77eb00a9 b1825640
......@@ -111,23 +111,23 @@ set(BZC_PROJECT_INCLUDES ${BZC_PROJECT_INCLUDES}
)
##############################################################################
# BASS
set(BZC_PROJECT_INCLUDES ${BZC_PROJECT_INCLUDES} ${CMAKE_SOURCE_DIR}/external/bass)
if (APPLE)
set(BZC_PROJECT_LIBS ${BZC_PROJECT_LIBS} ${CMAKE_SOURCE_DIR}/external/bass/libbass.dylib)
elseif (UNIX)
if (BONZOMATIC_64BIT)
set(BZC_PROJECT_LIBS ${BZC_PROJECT_LIBS} ${CMAKE_SOURCE_DIR}/external/bass/x64/libbass.so)
else ()
set(BZC_PROJECT_LIBS ${BZC_PROJECT_LIBS} ${CMAKE_SOURCE_DIR}/external/bass/x86/libbass.so)
endif ()
elseif (WIN32)
if (BONZOMATIC_64BIT)
set(BZC_PROJECT_LIBS ${BZC_PROJECT_LIBS} ${CMAKE_SOURCE_DIR}/external/bass/x64/bass.lib)
else ()
set(BZC_PROJECT_LIBS ${BZC_PROJECT_LIBS} ${CMAKE_SOURCE_DIR}/external/bass/x86/bass.lib)
endif ()
# mini_al
set(BZC_PROJECT_INCLUDES ${BZC_PROJECT_INCLUDES} ${CMAKE_SOURCE_DIR}/external/mini_al)
##############################################################################
# kiss_fft
set(KISSFFT_SRCS
${CMAKE_SOURCE_DIR}/external/kiss_fft/kiss_fft.c
${CMAKE_SOURCE_DIR}/external/kiss_fft/tools/kiss_fftr.c
)
add_library(bzc_kissfft STATIC ${KISSFFT_SRCS})
target_include_directories(bzc_kissfft PUBLIC ${CMAKE_SOURCE_DIR}/external/kiss_fft ${CMAKE_SOURCE_DIR}/external/kiss_fft/tools)
if (MSVC)
target_compile_options(bzc_kissfft PUBLIC "$<$<CONFIG:Release>:/MT>")
endif ()
set(BZC_PROJECT_INCLUDES ${BZC_PROJECT_INCLUDES} ${CMAKE_SOURCE_DIR}/external/kiss_fft)
set(BZC_PROJECT_INCLUDES ${BZC_PROJECT_INCLUDES} ${CMAKE_SOURCE_DIR}/external/kiss_fft/tools)
set(BZC_PROJECT_LIBS ${BZC_PROJECT_LIBS} bzc_kissfft)
##############################################################################
# JSONXX
......@@ -425,7 +425,6 @@ if (APPLE)
set_source_files_properties(${BZC_RESOURCES_DATA} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
set(OSX_LIB_FILES ${CMAKE_SOURCE_DIR}/external/bass/libbass.dylib)
set_source_files_properties(${OSX_LIB_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION MacOS)
set(BZC_PROJECT_SRCS ${BZC_PROJECT_SRCS} ${OSX_LIB_FILES})
......@@ -482,12 +481,7 @@ endif ()
target_include_directories(${BZC_EXE_NAME} PUBLIC ${BZC_PROJECT_INCLUDES})
target_link_libraries(${BZC_EXE_NAME} ${BZC_PROJECT_LIBS})
if (WIN32)
if (BONZOMATIC_64BIT)
add_custom_command(TARGET ${BZC_EXE_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/external/bass/x64/bass.dll" $<TARGET_FILE_DIR:${BZC_EXE_NAME}>)
else ()
add_custom_command(TARGET ${BZC_EXE_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/external/bass/x86/bass.dll" $<TARGET_FILE_DIR:${BZC_EXE_NAME}>)
endif ()
if (MSVC)
if (BONZOMATIC_NDI)
if (BONZOMATIC_64BIT)
add_custom_command(TARGET ${BZC_EXE_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${NDI_SDK_DIR}/Bin/x64/Processing.NDI.Lib.x64.dll" $<TARGET_FILE_DIR:${BZC_EXE_NAME}>)
......@@ -499,11 +493,6 @@ endif ()
## install
if (UNIX AND (NOT APPLE))
if (BONZOMATIC_64BIT)
install(FILES "${CMAKE_SOURCE_DIR}/external/bass/x64/libbass.so" DESTINATION lib)
else ()
install(FILES "${CMAKE_SOURCE_DIR}/external/bass/x86/libbass.so" DESTINATION lib)
endif ()
install(TARGETS ${BZC_EXE_NAME} RUNTIME DESTINATION bin)
install(FILES "${CMAKE_SOURCE_DIR}/data/unix/bonzomatic.desktop"
DESTINATION "${CMAKE_INSTALL_PREFIX}/share/applications")
......
......@@ -38,6 +38,7 @@ Create a `config.json` with e.g. the following contents: (all fields are optiona
},
"rendering":{
"fftSmoothFactor": 0.9, // 0.0 means there's no smoothing at all, 1.0 means the FFT is completely smoothed flat
"fftAmplification": 1.0, // 1.0 means no change, larger values will result in brighter/stronger bands, smaller values in darker/weaker ones
},
"textures":{ // the keys below will become the shader variable names
"texChecker":"textures/checker.png",
......@@ -85,7 +86,8 @@ https://github.com/Gargaj/Bonzomatic/wiki/How-to-set-up-a-Live-Coding-compo
### Libraries and other included software
- Scintilla editing component by the Scintilla Dev Team (http://www.scintilla.org/)
- OpenGL Extension Wrangler Library by Nigel Stewart (http://glew.sourceforge.net/)
- BASS.DLL by Ian Luck (http://www.un4seen.com/)
- mini_al by David Reid (https://github.com/dr-soft/mini_al)
- KISSFFT by Mark Borgerding (https://github.com/mborgerding/kissfft/)
- STB Image and Truetype libraries by Sean Barrett (http://nothings.org/)
- GLFW by whoever made GLFW (http://www.glfw.org/faq.html)
- JSON++ by Hong Jiang (https://github.com/hjiang/jsonxx)
......
......@@ -61,7 +61,6 @@ cmake --build . --config Release
mkdir ..\_package.%BNZ_OUT_DIR%\
del ..\_package.%BNZ_OUT_DIR%\Bonzomatic_%BNZ_PLATFORM%_%BNZ_FLAVOR%.exe
copy .\Release\Bonzomatic.exe ..\_package.%BNZ_OUT_DIR%\Bonzomatic_%BNZ_PLATFORM%_%BNZ_FLAVOR%.exe
copy .\Release\bass.dll ..\_package.%BNZ_OUT_DIR%\
copy .\Release\Processing.NDI.Lib.%BNZ_OUT_DIR%.dll ..\_package.%BNZ_OUT_DIR%\
cd ..
goto :eof
This diff is collapsed.
*.o
*.swp
*.so
*.a
*.dylib
test/bm_fftw_double
test/bm_fftw_float
test/bm_fftw_int16_t
test/bm_fftw_int32_t
test/bm_fftw_simd
test/bm_kiss_double
test/bm_kiss_float
test/bm_kiss_int16_t
test/bm_kiss_int32_t
test/bm_kiss_simd
test/st_double
test/st_float
test/st_int16_t
test/st_int32_t
test/st_simd
test/tkfc_double
test/tkfc_float
test/tkfc_int16_t
test/tkfc_int32_t
test/tkfc_simd
test/tr_double
test/tr_float
test/tr_int16_t
test/tr_int32_t
test/tr_simd
tools/fastconv_double
tools/fastconv_float
tools/fastconv_int16_t
tools/fastconv_int32_t
tools/fastconv_simd
tools/fastconvr_double
tools/fastconvr_float
tools/fastconvr_int16_t
tools/fastconvr_int32_t
tools/fastconvr_simd
tools/fft_double
tools/fft_float
tools/fft_int16_t
tools/fft_int32_t
tools/fft_simd
syntax:glob
test/bm_*
test/st_*
test/tkfc_*
test/tr_*
tools/fastconv_*
tools/fastconvr_*
tools/fft_*
*.swp
*~
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
Copyright (c) 2003-2010 Mark Borgerding . All rights reserved.
KISS FFT is provided under:
SPDX-License-Identifier: BSD-3-Clause
Being under the terms of the BSD 3-clause "New" or "Revised" License,
according with:
LICENSES/BSD-3-Clause
Valid-License-Identifier: BSD-3-Clause
SPDX-URL: https://spdx.org/licenses/BSD-3-Clause.html
Usage-Guide:
To use the BSD 3-clause "New" or "Revised" License put the following SPDX
tag/value pair into a comment according to the placement guidelines in
the licensing rules documentation:
SPDX-License-Identifier: BSD-3-Clause
License-Text:
Copyright (c) <year> <owner> . 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.
3. Neither the name of the copyright holder nor the names of its 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 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.
Valid-License-Identifier: Unlicense
SPDX-URL: https://spdx.org/licenses/Unlicense.html
Usage-Guide:
To use the Unlicense put the following SPDX tag/value pair into a
comment according to the placement guidelines in the licensing rules
documentation:
SPDX-License-Identifier: Unlicense
License-Text:
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute
this software, either in source code form or as a compiled binary, for any
purpose, commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and
to the detriment of our heirs and successors. We intend this dedication to be
an overt act of relinquishment in perpetuity of all present and future rights
to this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
KFVER=130
ifeq ($(shell uname -s),Darwin)
SHARED := -Wl,-install_name,libkissfft.dylib -o libkissfft.dylib
else
SHARED := -Wl,-soname,libkissfft.so -o libkissfft.so
endif
all:
gcc -Wall -fPIC -c *.c -Dkiss_fft_scalar=float -o kiss_fft.o
ar crus libkissfft.a kiss_fft.o
gcc -shared $(SHARED) kiss_fft.o
install: all
cp libkissfft.so /usr/local/lib/
doc:
@echo "Start by reading the README file. If you want to build and test lots of stuff, do a 'make testall'"
@echo "but be aware that 'make testall' has dependencies that the basic kissfft software does not."
@echo "It is generally unneeded to run these tests yourself, unless you plan on changing the inner workings"
@echo "of kissfft and would like to make use of its regression tests."
testall:
# The simd and int32_t types may or may not work on your machine
make -C test DATATYPE=simd CFLAGADD="$(CFLAGADD)" test
make -C test DATATYPE=int32_t CFLAGADD="$(CFLAGADD)" test
make -C test DATATYPE=int16_t CFLAGADD="$(CFLAGADD)" test
make -C test DATATYPE=float CFLAGADD="$(CFLAGADD)" test
make -C test DATATYPE=double CFLAGADD="$(CFLAGADD)" test
echo "all tests passed"
tarball: clean
hg archive -r v$(KFVER) -t tgz kiss_fft$(KFVER).tar.gz
hg archive -r v$(KFVER) -t zip kiss_fft$(KFVER).zip
clean:
cd test && make clean
cd tools && make clean
rm -f kiss_fft*.tar.gz *~ *.pyc kiss_fft*.zip
asm: kiss_fft.s
kiss_fft.s: kiss_fft.c kiss_fft.h _kiss_fft_guts.h
[ -e kiss_fft.s ] && mv kiss_fft.s kiss_fft.s~ || true
gcc -S kiss_fft.c -O3 -mtune=native -ffast-math -fomit-frame-pointer -unroll-loops -dA -fverbose-asm
gcc -o kiss_fft_short.s -S kiss_fft.c -O3 -mtune=native -ffast-math -fomit-frame-pointer -dA -fverbose-asm -DFIXED_POINT
[ -e kiss_fft.s~ ] && diff kiss_fft.s~ kiss_fft.s || true
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
kiss_fft_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
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<pDestEnd)
{
*pDest=_mm_set_ps(*source3,*source2,*source1,*source0);
source0++;
source1++;
source2++;
source3++;
pDest++;
}
}
void SSETools::unpack128(float* target, float* source, unsigned long size128)
{
float* pSrc = source;
float* pSrcEnd = pSrc+size128*4;
float* target0=target;