├── Builds
├── MacOSX
│ ├── .gitignore
│ ├── RecentFilesMenuTemplate.nib
│ ├── WavegenPlugin.xcodeproj
│ │ ├── xcuserdata
│ │ │ └── aaronleese.xcuserdatad
│ │ │ │ ├── xcdebugger
│ │ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ │ └── xcschemes
│ │ │ │ ├── xcschememanagement.plist
│ │ │ │ ├── WavegenPlugin (VST3).xcscheme
│ │ │ │ ├── WavegenPlugin (AU).xcscheme
│ │ │ │ ├── WavegenPlugin (Shared Code).xcscheme
│ │ │ │ ├── WavegenPlugin (All).xcscheme
│ │ │ │ └── WavegenPlugin (VST).xcscheme
│ │ └── project.xcworkspace
│ │ │ ├── xcuserdata
│ │ │ └── aaronleese.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── contents.xcworkspacedata
│ ├── JuceDemoPlugin.entitlements
│ ├── Info-VST.plist
│ ├── Info-VST3.plist
│ ├── Info-Shared_Code.plist
│ └── Info-AU.plist
├── VisualStudio2015
│ ├── resources.rc
│ └── JuceDemoPlugin.sln
└── Linux
│ └── Makefile
├── VisualStudio2015
├── resources.aps
├── JuceDemoPlugin.vcxproj.user
├── WavegenPlugin.sln
└── resources.rc
├── Source
├── kiss_fft130
│ ├── test
│ │ ├── pstats.h
│ │ ├── tailscrap.m
│ │ ├── pstats.c
│ │ ├── test_vs_dft.c
│ │ ├── benchfftw.c
│ │ ├── testcpp.cc
│ │ ├── compfft.py
│ │ ├── twotonetest.c
│ │ ├── fastfir.py
│ │ ├── Makefile
│ │ ├── mk_test.py
│ │ ├── benchkiss.c
│ │ ├── testkiss.py
│ │ ├── doit.c
│ │ ├── test_real.c
│ │ └── fft.py
│ ├── .hg_archival.txt
│ ├── .hgignore
│ ├── tools
│ │ ├── kiss_fftnd.h
│ │ ├── kiss_fftr.h
│ │ ├── kiss_fftndr.h
│ │ ├── kfc.h
│ │ ├── Makefile
│ │ ├── kfc.c
│ │ ├── kiss_fftndr.c
│ │ ├── kiss_fftr.c
│ │ ├── fftutil.c
│ │ ├── kiss_fftnd.c
│ │ └── psdpng.c
│ ├── .hgtags
│ ├── COPYING
│ ├── Makefile
│ ├── TIPS
│ ├── README.simd
│ ├── kiss_fft.h
│ ├── CHANGELOG
│ ├── README
│ └── _kiss_fft_guts.h
├── PluginEditor.h
├── SinewaveSynth.h
├── PluginProcessor.h
├── FFTKiss.h
└── PluginProcessor.cpp
├── JuceLibraryCode
├── juce_core.cpp
├── juce_core.mm
├── juce_events.cpp
├── juce_events.mm
├── juce_graphics.mm
├── juce_graphics.cpp
├── juce_gui_basics.mm
├── juce_gui_extra.cpp
├── juce_gui_extra.mm
├── juce_audio_utils.cpp
├── juce_audio_utils.mm
├── juce_gui_basics.cpp
├── juce_audio_basics.cpp
├── juce_audio_basics.mm
├── juce_audio_devices.mm
├── juce_audio_formats.mm
├── juce_audio_devices.cpp
├── juce_audio_formats.cpp
├── juce_data_structures.mm
├── juce_audio_processors.cpp
├── juce_audio_processors.mm
├── juce_data_structures.cpp
├── juce_audio_plugin_client_AAX.mm
├── juce_audio_plugin_client_AAX.cpp
├── juce_audio_plugin_client_AU_1.mm
├── juce_audio_plugin_client_AU_2.mm
├── juce_audio_plugin_client_AUv3.mm
├── juce_audio_plugin_client_VST2.cpp
├── juce_audio_plugin_client_VST3.cpp
├── juce_audio_plugin_client_RTAS_1.cpp
├── juce_audio_plugin_client_RTAS_2.cpp
├── juce_audio_plugin_client_RTAS_3.cpp
├── juce_audio_plugin_client_RTAS_4.cpp
├── juce_audio_plugin_client_utils.cpp
├── juce_audio_plugin_client_RTAS_utils.mm
├── juce_audio_plugin_client_VST_utils.mm
├── juce_audio_plugin_client_RTAS_utils.cpp
├── juce_audio_plugin_client_Standalone.cpp
├── ReadMe.txt
└── JuceHeader.h
├── README.md
└── JuceDemoPlugin.jucer
/Builds/MacOSX/.gitignore:
--------------------------------------------------------------------------------
1 | build/*
2 |
--------------------------------------------------------------------------------
/VisualStudio2015/resources.aps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aaronleese/JucePlugin-Synth-with-AntiAliasing/HEAD/VisualStudio2015/resources.aps
--------------------------------------------------------------------------------
/Source/kiss_fft130/test/pstats.h:
--------------------------------------------------------------------------------
1 | #ifndef PSTATS_H
2 | #define PSTATS_H
3 |
4 | void pstats_init(void);
5 | void pstats_report(void);
6 |
7 | #endif
8 |
--------------------------------------------------------------------------------
/Builds/MacOSX/RecentFilesMenuTemplate.nib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aaronleese/JucePlugin-Synth-with-AntiAliasing/HEAD/Builds/MacOSX/RecentFilesMenuTemplate.nib
--------------------------------------------------------------------------------
/Source/kiss_fft130/.hg_archival.txt:
--------------------------------------------------------------------------------
1 | repo: d844c818f599aea64fe86745cdd2ef9b3d1910dc
2 | node: b354a59534b0a77c43c67deb1eb1bc39eb99b487
3 | branch: default
4 | tag: v130
5 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/.hgignore:
--------------------------------------------------------------------------------
1 | syntax:glob
2 | test/bm_*
3 | test/st_*
4 | test/tkfc_*
5 | test/tr_*
6 | tools/fastconv_*
7 | tools/fastconvr_*
8 | tools/fft_*
9 | *.swp
10 | *~
11 |
--------------------------------------------------------------------------------
/VisualStudio2015/JuceDemoPlugin.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Builds/MacOSX/WavegenPlugin.xcodeproj/xcuserdata/aaronleese.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/Builds/MacOSX/JuceDemoPlugin.entitlements:
--------------------------------------------------------------------------------
1 | com.apple.security.app-sandbox
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_core.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_core.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_events.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_events.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_graphics.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_graphics.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_gui_basics.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_gui_extra.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_gui_extra.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_utils.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_utils.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_gui_basics.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_basics.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_basics.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_devices.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_formats.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_devices.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_formats.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_data_structures.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/Builds/MacOSX/WavegenPlugin.xcodeproj/project.xcworkspace/xcuserdata/aaronleese.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aaronleese/JucePlugin-Synth-with-AntiAliasing/HEAD/Builds/MacOSX/WavegenPlugin.xcodeproj/project.xcworkspace/xcuserdata/aaronleese.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_processors.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_processors.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_data_structures.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/Builds/MacOSX/WavegenPlugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_plugin_client_AAX.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_plugin_client_AAX.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_plugin_client_AU_1.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_plugin_client_AU_2.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_plugin_client_AUv3.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_plugin_client_VST2.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_plugin_client_VST3.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_plugin_client_RTAS_1.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_plugin_client_RTAS_2.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_plugin_client_RTAS_3.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_plugin_client_RTAS_4.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_plugin_client_utils.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_plugin_client_RTAS_utils.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_plugin_client_VST_utils.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_plugin_client_RTAS_utils.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/juce_audio_plugin_client_Standalone.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/tools/kiss_fftnd.h:
--------------------------------------------------------------------------------
1 | #ifndef KISS_FFTND_H
2 | #define KISS_FFTND_H
3 |
4 | #include "kiss_fft.h"
5 |
6 | #ifdef __cplusplus
7 | extern "C" {
8 | #endif
9 |
10 | typedef struct kiss_fftnd_state * kiss_fftnd_cfg;
11 |
12 | kiss_fftnd_cfg kiss_fftnd_alloc(const int *dims,int ndims,int inverse_fft,void*mem,size_t*lenmem);
13 | void kiss_fftnd(kiss_fftnd_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout);
14 |
15 | #ifdef __cplusplus
16 | }
17 | #endif
18 | #endif
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | JUCE Plugin Synth with Anti-Aliasing
2 | ===============
3 |
4 | This code implements a modification of the JUCE plugin example which adds minblep-based antialiasing to the synth.
5 |
6 | For an explanaition of this implementation, see the blog: [Modern Bandwidth Limiting for Synths](http://www.stagecraftsoftware.com/advanced-features/modern-bandwidth-limiting-for-synths/).
7 |
8 | For technical details of this method, see Eli Brandt of CMU's paper on the minblep technique: [Hard Sync Without Aliasing](http://www.cs.cmu.edu/~eli/papers/icmc01-hardsync.pdf).
9 |
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/ReadMe.txt:
--------------------------------------------------------------------------------
1 |
2 | Important Note!!
3 | ================
4 |
5 | The purpose of this folder is to contain files that are auto-generated by the Projucer,
6 | and ALL files in this folder will be mercilessly DELETED and completely re-written whenever
7 | the Projucer saves your project.
8 |
9 | Therefore, it's a bad idea to make any manual changes to the files in here, or to
10 | put any of your own files in here if you don't want to lose them. (Of course you may choose
11 | to add the folder's contents to your version-control system so that you can re-merge your own
12 | modifications after the Projucer has saved its changes).
13 |
--------------------------------------------------------------------------------
/Builds/VisualStudio2015/resources.rc:
--------------------------------------------------------------------------------
1 | #ifdef JUCE_USER_DEFINED_RC_FILE
2 | #include JUCE_USER_DEFINED_RC_FILE
3 | #else
4 |
5 | #undef WIN32_LEAN_AND_MEAN
6 | #define WIN32_LEAN_AND_MEAN
7 | #include
8 |
9 | VS_VERSION_INFO VERSIONINFO
10 | FILEVERSION 1,0,0,0
11 | BEGIN
12 | BLOCK "StringFileInfo"
13 | BEGIN
14 | BLOCK "040904E4"
15 | BEGIN
16 | VALUE "CompanyName", "ROLI Ltd.\0"
17 | VALUE "FileDescription", "JuceDemoPlugin\0"
18 | VALUE "FileVersion", "1.0.0\0"
19 | VALUE "ProductName", "JuceDemoPlugin\0"
20 | VALUE "ProductVersion", "1.0.0\0"
21 | END
22 | END
23 |
24 | BLOCK "VarFileInfo"
25 | BEGIN
26 | VALUE "Translation", 0x409, 1252
27 | END
28 | END
29 |
30 | #endif
31 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/test/tailscrap.m:
--------------------------------------------------------------------------------
1 | function maxabsdiff=tailscrap()
2 | % test code for circular convolution with the scrapped portion
3 | % at the tail of the buffer, rather than the front
4 | %
5 | % The idea is to rotate the zero-padded h (impulse response) buffer
6 | % to the left nh-1 samples, rotating the junk samples as well.
7 | % This could be very handy in avoiding buffer copies during fast filtering.
8 | nh=10;
9 | nfft=256;
10 |
11 | h=rand(1,nh);
12 | x=rand(1,nfft);
13 |
14 | hpad=[ h(nh) zeros(1,nfft-nh) h(1:nh-1) ];
15 |
16 | % baseline comparison
17 | y1 = filter(h,1,x);
18 | y1_notrans = y1(nh:nfft);
19 |
20 | % fast convolution
21 | y2 = ifft( fft(hpad) .* fft(x) );
22 | y2_notrans=y2(1:nfft-nh+1);
23 |
24 | maxabsdiff = max(abs(y2_notrans - y1_notrans))
25 |
26 | end
27 |
--------------------------------------------------------------------------------
/Builds/MacOSX/Info-VST.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleExecutable
6 | ${EXECUTABLE_NAME}
7 | CFBundleIconFile
8 |
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleName
12 | WaveGenPlugin
13 | CFBundleDisplayName
14 | WaveGenPlugin
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleSignature
18 | ????
19 | CFBundleShortVersionString
20 | 1.0.0
21 | CFBundleVersion
22 | 1.0.0
23 | NSHumanReadableCopyright
24 | ROLI Ltd.
25 | NSHighResolutionCapable
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Builds/MacOSX/Info-VST3.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleExecutable
6 | ${EXECUTABLE_NAME}
7 | CFBundleIconFile
8 |
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleName
12 | WaveGenPlugin
13 | CFBundleDisplayName
14 | WaveGenPlugin
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleSignature
18 | ????
19 | CFBundleShortVersionString
20 | 1.0.0
21 | CFBundleVersion
22 | 1.0.0
23 | NSHumanReadableCopyright
24 | ROLI Ltd.
25 | NSHighResolutionCapable
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Builds/VisualStudio2015/JuceDemoPlugin.sln:
--------------------------------------------------------------------------------
1 | Microsoft Visual Studio Solution File, Format Version 11.00
2 | # Visual Studio 2015
3 | Project("{45F7ED0D-469F-7EB0-7B2E-D2EAA2170C4E}") = "JuceDemoPlugin", "JuceDemoPlugin.vcxproj", "{64F92774-5695-B20A-C63E-7690CA0ECE34}"
4 | EndProject
5 | Global
6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
7 | Debug|Win32 = Debug|Win32
8 | Release|Win32 = Release|Win32
9 | EndGlobalSection
10 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
11 | {64F92774-5695-B20A-C63E-7690CA0ECE34}.Debug|Win32.ActiveCfg = Debug|Win32
12 | {64F92774-5695-B20A-C63E-7690CA0ECE34}.Debug|Win32.Build.0 = Debug|Win32
13 | {64F92774-5695-B20A-C63E-7690CA0ECE34}.Release|Win32.ActiveCfg = Release|Win32
14 | {64F92774-5695-B20A-C63E-7690CA0ECE34}.Release|Win32.Build.0 = Release|Win32
15 | EndGlobalSection
16 | GlobalSection(SolutionProperties) = preSolution
17 | HideSolutionNode = FALSE
18 | EndGlobalSection
19 | EndGlobal
20 |
--------------------------------------------------------------------------------
/Builds/MacOSX/Info-Shared_Code.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | CFBundleExecutable
7 | ${EXECUTABLE_NAME}
8 | CFBundleIconFile
9 |
10 | CFBundleIdentifier
11 | $(PRODUCT_BUNDLE_IDENTIFIER)
12 | CFBundleName
13 | JuceDemoPlugin
14 | CFBundleDisplayName
15 | JuceDemoPlugin
16 | CFBundlePackageType
17 | FMWK
18 | CFBundleSignature
19 | ????
20 | CFBundleShortVersionString
21 | 1.0.0
22 | CFBundleVersion
23 | 1.0.0
24 | NSHumanReadableCopyright
25 | ROLI Ltd.
26 | NSHighResolutionCapable
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/tools/kiss_fftr.h:
--------------------------------------------------------------------------------
1 | #ifndef KISS_FTR_H
2 | #define KISS_FTR_H
3 |
4 | #include "kiss_fft.h"
5 | #ifdef __cplusplus
6 | extern "C" {
7 | #endif
8 |
9 |
10 | /*
11 |
12 | Real optimized version can save about 45% cpu time vs. complex fft of a real seq.
13 |
14 |
15 |
16 | */
17 |
18 | typedef struct kiss_fftr_state *kiss_fftr_cfg;
19 |
20 |
21 | kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem, size_t * lenmem);
22 | /*
23 | nfft must be even
24 |
25 | If you don't care to allocate space, use mem = lenmem = NULL
26 | */
27 |
28 |
29 | void kiss_fftr(kiss_fftr_cfg cfg,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata);
30 | /*
31 | input timedata has nfft scalar points
32 | output freqdata has nfft/2+1 complex points
33 | */
34 |
35 | void kiss_fftri(kiss_fftr_cfg cfg,const kiss_fft_cpx *freqdata,kiss_fft_scalar *timedata);
36 | /*
37 | input freqdata has nfft/2+1 complex points
38 | output timedata has nfft scalar points
39 | */
40 |
41 | #define kiss_fftr_free free
42 |
43 | #ifdef __cplusplus
44 | }
45 | #endif
46 | #endif
47 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/.hgtags:
--------------------------------------------------------------------------------
1 | 32061530d4353ced38386a4578153954f46e5f8e v04_prehg
2 | 52a9ca23c9d9600794388912103e0f7d5f4c92ee v1_2_2_prehg
3 | 68e0375761a5789d72c4baa2f8265cec26fb546e v110_prehg
4 | 69a218df7458f0269a84b07f64678392edbff941 v111_prehg
5 | 702f90b11f060d45b23d563764a3b1bd8f851b7d about2do_real_multi_d_prehg
6 | 9c3041fb0677c071d7ca2797e22a63fe681d311b b4simd_prehg
7 | 9e532c64d324a0844f1efa7c32908fc2bc0cf350 v1_2_6_prehg
8 | a9797b79bf2c61f7c8259ec417a0189caa48b17a v1_2_3_prehg
9 | b1b2739c82378d6e04977440b2c31b7d1b34c266 aftersimd_prehg
10 | b8c210e0bccdeb66930423a528b11b3660491af8 v120_prehg
11 | c16172181d6aef63712a3f7bc31ef555ce7178bd help_prehg
12 | c16172181d6aef63712a3f7bc31ef555ce7178bd v1_2_3a_prehg
13 | c83c1ec6a5f21c40edf3bb9cbfd8ba1f862f1e0f half_bottle_o_wine_prehg
14 | dec01bc9c4c5f807e2e04aef3449031bc5c6b69e v1_2_5_prehg
15 | e6a840a1383ffc83c8ba17ed4b0bf5d6aefc9a34 v127_prehg
16 | ea3a56794d9326d5505b5bf02f98a70217a1b86d v101_prehg
17 | edd6236ecb25904b385856ffae608548ce3df4e5 v011_prehg
18 | f19b7bcef3f322d277d5b51b2b132657cf08c1a7 v1_2_8_prehg
19 | f73f8d58c37d52379e9d7f13d81f5391226209c1 v1_2_1_prehg
20 | 9e0bf8478cc337da0de18b7413d51c714aa0db46 v129
21 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/tools/kiss_fftndr.h:
--------------------------------------------------------------------------------
1 | #ifndef KISS_NDR_H
2 | #define KISS_NDR_H
3 |
4 | #include "kiss_fft.h"
5 | #include "kiss_fftr.h"
6 | #include "kiss_fftnd.h"
7 |
8 | #ifdef __cplusplus
9 | extern "C" {
10 | #endif
11 |
12 | typedef struct kiss_fftndr_state *kiss_fftndr_cfg;
13 |
14 |
15 | kiss_fftndr_cfg kiss_fftndr_alloc(const int *dims,int ndims,int inverse_fft,void*mem,size_t*lenmem);
16 | /*
17 | dims[0] must be even
18 |
19 | If you don't care to allocate space, use mem = lenmem = NULL
20 | */
21 |
22 |
23 | void kiss_fftndr(
24 | kiss_fftndr_cfg cfg,
25 | const kiss_fft_scalar *timedata,
26 | kiss_fft_cpx *freqdata);
27 | /*
28 | input timedata has dims[0] X dims[1] X ... X dims[ndims-1] scalar points
29 | output freqdata has dims[0] X dims[1] X ... X dims[ndims-1]/2+1 complex points
30 | */
31 |
32 | void kiss_fftndri(
33 | kiss_fftndr_cfg cfg,
34 | const kiss_fft_cpx *freqdata,
35 | kiss_fft_scalar *timedata);
36 | /*
37 | input and output dimensions are the exact opposite of kiss_fftndr
38 | */
39 |
40 |
41 | #define kiss_fftr_free free
42 |
43 | #ifdef __cplusplus
44 | }
45 | #endif
46 |
47 | #endif
48 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/test/pstats.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | #include "pstats.h"
8 |
9 | static struct tms tms_beg;
10 | static struct tms tms_end;
11 | static int has_times = 0;
12 |
13 |
14 | void pstats_init(void)
15 | {
16 | has_times = times(&tms_beg) != -1;
17 | }
18 |
19 | static void tms_report(void)
20 | {
21 | double cputime;
22 | if (! has_times )
23 | return;
24 | times(&tms_end);
25 | cputime = ( ((float)tms_end.tms_utime + tms_end.tms_stime + tms_end.tms_cutime + tms_end.tms_cstime ) -
26 | ((float)tms_beg.tms_utime + tms_beg.tms_stime + tms_beg.tms_cutime + tms_beg.tms_cstime ) )
27 | / sysconf(_SC_CLK_TCK);
28 | fprintf(stderr,"\tcputime=%.3f\n" , cputime);
29 | }
30 |
31 | static void ps_report(void)
32 | {
33 | char buf[1024];
34 | #ifdef __APPLE__ /* MAC OS X */
35 | sprintf(buf,"ps -o command,majflt,minflt,rss,pagein,vsz -p %d 1>&2",getpid() );
36 | #else /* GNU/Linux */
37 | sprintf(buf,"ps -o comm,majflt,minflt,rss,drs,pagein,sz,trs,vsz %d 1>&2",getpid() );
38 | #endif
39 | if (system( buf )==-1) {
40 | perror("system call to ps failed");
41 | }
42 | }
43 |
44 | void pstats_report()
45 | {
46 | ps_report();
47 | tms_report();
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/VisualStudio2015/WavegenPlugin.sln:
--------------------------------------------------------------------------------
1 | Microsoft Visual Studio Solution File, Format Version 12.00
2 | # Visual Studio 14
3 | VisualStudioVersion = 14.0.23107.0
4 | MinimumVisualStudioVersion = 10.0.40219.1
5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WavegenPlugin", "WavegenPlugin.vcxproj", "{64F92774-5695-B20A-C63E-7690CA0ECE34}"
6 | EndProject
7 | Global
8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
9 | Debug|Win32 = Debug|Win32
10 | Debug|x64 = Debug|x64
11 | Release|Win32 = Release|Win32
12 | Release|x64 = Release|x64
13 | EndGlobalSection
14 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
15 | {64F92774-5695-B20A-C63E-7690CA0ECE34}.Debug|Win32.ActiveCfg = Debug|Win32
16 | {64F92774-5695-B20A-C63E-7690CA0ECE34}.Debug|Win32.Build.0 = Debug|Win32
17 | {64F92774-5695-B20A-C63E-7690CA0ECE34}.Debug|x64.ActiveCfg = Debug|x64
18 | {64F92774-5695-B20A-C63E-7690CA0ECE34}.Debug|x64.Build.0 = Debug|x64
19 | {64F92774-5695-B20A-C63E-7690CA0ECE34}.Release|Win32.ActiveCfg = Release|Win32
20 | {64F92774-5695-B20A-C63E-7690CA0ECE34}.Release|Win32.Build.0 = Release|Win32
21 | {64F92774-5695-B20A-C63E-7690CA0ECE34}.Release|x64.ActiveCfg = Release|x64
22 | {64F92774-5695-B20A-C63E-7690CA0ECE34}.Release|x64.Build.0 = Release|x64
23 | EndGlobalSection
24 | GlobalSection(SolutionProperties) = preSolution
25 | HideSolutionNode = FALSE
26 | EndGlobalSection
27 | EndGlobal
28 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/tools/kfc.h:
--------------------------------------------------------------------------------
1 | #ifndef KFC_H
2 | #define KFC_H
3 | #include "kiss_fft.h"
4 |
5 | #ifdef __cplusplus
6 | extern "C" {
7 | #endif
8 |
9 | /*
10 | KFC -- Kiss FFT Cache
11 |
12 | Not needing to deal with kiss_fft_alloc and a config
13 | object may be handy for a lot of programs.
14 |
15 | KFC uses the underlying KISS FFT functions, but caches the config object.
16 | The first time kfc_fft or kfc_ifft for a given FFT size, the cfg
17 | object is created for it. All subsequent calls use the cached
18 | configuration object.
19 |
20 | NOTE:
21 | You should probably not use this if your program will be using a lot
22 | of various sizes of FFTs. There is a linear search through the
23 | cached objects. If you are only using one or two FFT sizes, this
24 | will be negligible. Otherwise, you may want to use another method
25 | of managing the cfg objects.
26 |
27 | There is no automated cleanup of the cached objects. This could lead
28 | to large memory usage in a program that uses a lot of *DIFFERENT*
29 | sized FFTs. If you want to force all cached cfg objects to be freed,
30 | call kfc_cleanup.
31 |
32 | */
33 |
34 | /*forward complex FFT */
35 | void kfc_fft(int nfft, const kiss_fft_cpx * fin,kiss_fft_cpx * fout);
36 | /*reverse complex FFT */
37 | void kfc_ifft(int nfft, const kiss_fft_cpx * fin,kiss_fft_cpx * fout);
38 |
39 | /*free all cached objects*/
40 | void kfc_cleanup(void);
41 |
42 | #ifdef __cplusplus
43 | }
44 | #endif
45 |
46 | #endif
47 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/COPYING:
--------------------------------------------------------------------------------
1 | Copyright (c) 2003-2010 Mark Borgerding
2 |
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 | * 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.
9 | * 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.
10 |
11 | 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.
12 |
--------------------------------------------------------------------------------
/Builds/MacOSX/Info-AU.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleExecutable
6 | ${EXECUTABLE_NAME}
7 | CFBundleIconFile
8 |
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleName
12 | WaveGenPlugin
13 | CFBundleDisplayName
14 | WaveGenPlugin
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleSignature
18 | ????
19 | CFBundleShortVersionString
20 | 1.0.0
21 | CFBundleVersion
22 | 1.0.0
23 | NSHumanReadableCopyright
24 | ROLI Ltd.
25 | NSHighResolutionCapable
26 |
27 | AudioComponents
28 |
29 |
30 | name
31 | ROLI Ltd.: Juce Demo Plugin
32 | description
33 | Juce Demo Plugin
34 | factoryFunction
35 | WaveGenProjectAUFactory
36 | manufacturer
37 | ROLI
38 | type
39 | aumf
40 | subtype
41 | Jcdm
42 | version
43 | 65536
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/Makefile:
--------------------------------------------------------------------------------
1 | KFVER=130
2 |
3 | doc:
4 | @echo "Start by reading the README file. If you want to build and test lots of stuff, do a 'make testall'"
5 | @echo "but be aware that 'make testall' has dependencies that the basic kissfft software does not."
6 | @echo "It is generally unneeded to run these tests yourself, unless you plan on changing the inner workings"
7 | @echo "of kissfft and would like to make use of its regression tests."
8 |
9 | testall:
10 | # The simd and int32_t types may or may not work on your machine
11 | make -C test DATATYPE=simd CFLAGADD="$(CFLAGADD)" test
12 | make -C test DATATYPE=int32_t CFLAGADD="$(CFLAGADD)" test
13 | make -C test DATATYPE=int16_t CFLAGADD="$(CFLAGADD)" test
14 | make -C test DATATYPE=float CFLAGADD="$(CFLAGADD)" test
15 | make -C test DATATYPE=double CFLAGADD="$(CFLAGADD)" test
16 | echo "all tests passed"
17 |
18 | tarball: clean
19 | hg archive -r v$(KFVER) -t tgz kiss_fft$(KFVER).tar.gz
20 | hg archive -r v$(KFVER) -t zip kiss_fft$(KFVER).zip
21 |
22 | clean:
23 | cd test && make clean
24 | cd tools && make clean
25 | rm -f kiss_fft*.tar.gz *~ *.pyc kiss_fft*.zip
26 |
27 | asm: kiss_fft.s
28 |
29 | kiss_fft.s: kiss_fft.c kiss_fft.h _kiss_fft_guts.h
30 | [ -e kiss_fft.s ] && mv kiss_fft.s kiss_fft.s~ || true
31 | gcc -S kiss_fft.c -O3 -mtune=native -ffast-math -fomit-frame-pointer -unroll-loops -dA -fverbose-asm
32 | gcc -o kiss_fft_short.s -S kiss_fft.c -O3 -mtune=native -ffast-math -fomit-frame-pointer -dA -fverbose-asm -DFIXED_POINT
33 | [ -e kiss_fft.s~ ] && diff kiss_fft.s~ kiss_fft.s || true
34 |
--------------------------------------------------------------------------------
/Builds/MacOSX/WavegenPlugin.xcodeproj/xcuserdata/aaronleese.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | WavegenPlugin (AU).xcscheme
8 |
9 | orderHint
10 | 3
11 |
12 | WavegenPlugin (All).xcscheme
13 |
14 | orderHint
15 | 0
16 |
17 | WavegenPlugin (Shared Code).xcscheme
18 |
19 | orderHint
20 | 4
21 |
22 | WavegenPlugin (VST).xcscheme
23 |
24 | orderHint
25 | 1
26 |
27 | WavegenPlugin (VST3).xcscheme
28 |
29 | orderHint
30 | 2
31 |
32 |
33 | SuppressBuildableAutocreation
34 |
35 | 03F6829513830045329610BB
36 |
37 | primary
38 |
39 |
40 | 71E1E34CFC671ACBBCE0726C
41 |
42 | primary
43 |
44 |
45 | 921CB4BBA34ADBC5270F81EF
46 |
47 | primary
48 |
49 |
50 | C3F206BB3277FBADE3BD615B
51 |
52 | primary
53 |
54 |
55 | D4A200CA175E6673EB359B63
56 |
57 | primary
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/JuceLibraryCode/JuceHeader.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | This is the header file that your files should include in order to get all the
7 | JUCE library headers. You should avoid including the JUCE headers directly in
8 | your own source files, because that wouldn't pick up the correct configuration
9 | options for your app.
10 |
11 | */
12 |
13 | #ifndef __APPHEADERFILE_0NRD9LLGO__
14 | #define __APPHEADERFILE_0NRD9LLGO__
15 |
16 | #include "AppConfig.h"
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 |
31 |
32 | #if ! DONT_SET_USING_JUCE_NAMESPACE
33 | // If your code uses a lot of JUCE classes, then this will obviously save you
34 | // a lot of typing, but can be disabled by setting DONT_SET_USING_JUCE_NAMESPACE.
35 | using namespace juce;
36 | #endif
37 |
38 | #if ! JUCE_DONT_DECLARE_PROJECTINFO
39 | namespace ProjectInfo
40 | {
41 | const char* const projectName = "WaveGenPlugin";
42 | const char* const versionString = "1.0.0";
43 | const int versionNumber = 0x10000;
44 | }
45 | #endif
46 |
47 | #endif // __APPHEADERFILE_0NRD9LLGO__
48 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/tools/Makefile:
--------------------------------------------------------------------------------
1 | WARNINGS=-W -Wall -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return \
2 | -Wcast-align -Wcast-qual -Wnested-externs -Wshadow -Wbad-function-cast \
3 | -Wwrite-strings
4 |
5 | ifeq "$(DATATYPE)" ""
6 | DATATYPE=float
7 | endif
8 |
9 | ifeq "$(DATATYPE)" "int32_t"
10 | TYPEFLAGS=-DFIXED_POINT=32
11 | endif
12 |
13 | ifeq "$(DATATYPE)" "int16_t"
14 | TYPEFLAGS=-DFIXED_POINT=16
15 | endif
16 |
17 | ifeq "$(DATATYPE)" "simd"
18 | TYPEFLAGS=-DUSE_SIMD=1 -msse
19 | endif
20 |
21 | ifeq "$(TYPEFLAGS)" ""
22 | TYPEFLAGS=-Dkiss_fft_scalar=$(DATATYPE)
23 | endif
24 |
25 | ifneq ("$(KISS_FFT_USE_ALLOCA)","")
26 | CFLAGS+= -DKISS_FFT_USE_ALLOCA=1
27 | endif
28 | CFLAGS+= $(CFLAGADD)
29 |
30 |
31 | FFTUTIL=fft_$(DATATYPE)
32 | FASTFILT=fastconv_$(DATATYPE)
33 | FASTFILTREAL=fastconvr_$(DATATYPE)
34 | PSDPNG=psdpng_$(DATATYPE)
35 | DUMPHDR=dumphdr_$(DATATYPE)
36 |
37 | all: $(FFTUTIL) $(FASTFILT) $(FASTFILTREAL)
38 | # $(PSDPNG)
39 | # $(DUMPHDR)
40 |
41 | #CFLAGS=-Wall -O3 -pedantic -march=pentiumpro -ffast-math -fomit-frame-pointer $(WARNINGS)
42 | # If the above flags do not work, try the following
43 | CFLAGS=-Wall -O3 $(WARNINGS)
44 | # tip: try -openmp or -fopenmp to use multiple cores
45 |
46 | $(FASTFILTREAL): ../kiss_fft.c kiss_fastfir.c kiss_fftr.c
47 | $(CC) -o $@ $(CFLAGS) -I.. $(TYPEFLAGS) -DREAL_FASTFIR $+ -DFAST_FILT_UTIL -lm
48 |
49 | $(FASTFILT): ../kiss_fft.c kiss_fastfir.c
50 | $(CC) -o $@ $(CFLAGS) -I.. $(TYPEFLAGS) $+ -DFAST_FILT_UTIL -lm
51 |
52 | $(FFTUTIL): ../kiss_fft.c fftutil.c kiss_fftnd.c kiss_fftr.c kiss_fftndr.c
53 | $(CC) -o $@ $(CFLAGS) -I.. $(TYPEFLAGS) $+ -lm
54 |
55 | $(PSDPNG): ../kiss_fft.c psdpng.c kiss_fftr.c
56 | $(CC) -o $@ $(CFLAGS) -I.. $(TYPEFLAGS) $+ -lpng -lm
57 |
58 | $(DUMPHDR): ../kiss_fft.c dumphdr.c
59 | $(CC) -o $@ $(CFLAGS) -I.. $(TYPEFLAGS) $+ -lm
60 |
61 | clean:
62 | rm -f *~ fft fft_* fastconv fastconv_* fastconvr fastconvr_* psdpng psdpng_*
63 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/test/test_vs_dft.c:
--------------------------------------------------------------------------------
1 | #include "kiss_fft.h"
2 |
3 |
4 | void check(kiss_fft_cpx * in,kiss_fft_cpx * out,int nfft,int isinverse)
5 | {
6 | int bin,k;
7 | double errpow=0,sigpow=0;
8 |
9 | for (bin=0;bin1) {
64 | int k;
65 | for (k=1;k gainSlider, delaySlider;
41 |
42 | ScopedPointer outputUI;
43 | ScopedPointer waveType;
44 |
45 | ScopedPointer tone, pwm, overtoneDepth, test;
46 |
47 | Label PWMLabel, toneLabel, depthLabel;
48 |
49 | void comboBoxChanged (ComboBox* comboBoxThatHasChanged) override;
50 | void sliderValueChanged(Slider* sliderThatWasMoved) override;
51 |
52 | //==============================================================================
53 | WaveGenPluginAudioProcessor& getProcessor() const
54 | {
55 | return static_cast (processor);
56 | }
57 |
58 | void updateTimecodeDisplay (AudioPlayHead::CurrentPositionInfo);
59 | };
60 |
61 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/TIPS:
--------------------------------------------------------------------------------
1 | Speed:
2 | * If you want to use multiple cores, then compile with -openmp or -fopenmp (see your compiler docs).
3 | Realize that larger FFTs will reap more benefit than smaller FFTs. This generally uses more CPU time, but
4 | less wall time.
5 |
6 | * experiment with compiler flags
7 | Special thanks to Oscar Lesta. He suggested some compiler flags
8 | for gcc that make a big difference. They shave 10-15% off
9 | execution time on some systems. Try some combination of:
10 | -march=pentiumpro
11 | -ffast-math
12 | -fomit-frame-pointer
13 |
14 | * If the input data has no imaginary component, use the kiss_fftr code under tools/.
15 | Real ffts are roughly twice as fast as complex.
16 |
17 | * If you can rearrange your code to do 4 FFTs in parallel and you are on a recent Intel or AMD machine,
18 | then you might want to experiment with the USE_SIMD code. See README.simd
19 |
20 |
21 | Reducing code size:
22 | * remove some of the butterflies. There are currently butterflies optimized for radices
23 | 2,3,4,5. It is worth mentioning that you can still use FFT sizes that contain
24 | other factors, they just won't be quite as fast. You can decide for yourself
25 | whether to keep radix 2 or 4. If you do some work in this area, let me
26 | know what you find.
27 |
28 | * For platforms where ROM/code space is more plentiful than RAM,
29 | consider creating a hardcoded kiss_fft_state. In other words, decide which
30 | FFT size(s) you want and make a structure with the correct factors and twiddles.
31 |
32 | * Frank van der Hulst offered numerous suggestions for smaller code size and correct operation
33 | on embedded targets. "I'm happy to help anyone who is trying to implement KISSFFT on a micro"
34 |
35 | Some of these were rolled into the mainline code base:
36 | - using long casts to promote intermediate results of short*short multiplication
37 | - delaying allocation of buffers that are sometimes unused.
38 | In some cases, it may be desirable to limit capability in order to better suit the target:
39 | - predefining the twiddle tables for the desired fft size.
40 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/test/benchfftw.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include "pstats.h"
6 |
7 | #ifdef DATATYPEdouble
8 |
9 | #define CPXTYPE fftw_complex
10 | #define PLAN fftw_plan
11 | #define FFTMALLOC fftw_malloc
12 | #define MAKEPLAN fftw_plan_dft_1d
13 | #define DOFFT fftw_execute
14 | #define DESTROYPLAN fftw_destroy_plan
15 | #define FFTFREE fftw_free
16 |
17 | #elif defined(DATATYPEfloat)
18 |
19 | #define CPXTYPE fftwf_complex
20 | #define PLAN fftwf_plan
21 | #define FFTMALLOC fftwf_malloc
22 | #define MAKEPLAN fftwf_plan_dft_1d
23 | #define DOFFT fftwf_execute
24 | #define DESTROYPLAN fftwf_destroy_plan
25 | #define FFTFREE fftwf_free
26 |
27 | #endif
28 |
29 | #ifndef CPXTYPE
30 | int main(void)
31 | {
32 | fprintf(stderr,"Datatype not available in FFTW\n" );
33 | return 0;
34 | }
35 | #else
36 | int main(int argc,char ** argv)
37 | {
38 | int nfft=1024;
39 | int isinverse=0;
40 | int numffts=1000,i;
41 |
42 | CPXTYPE * in=NULL;
43 | CPXTYPE * out=NULL;
44 | PLAN p;
45 |
46 | pstats_init();
47 |
48 | while (1) {
49 | int c = getopt (argc, argv, "n:ix:h");
50 | if (c == -1)
51 | break;
52 | switch (c) {
53 | case 'n':
54 | nfft = atoi (optarg);
55 | break;
56 | case 'x':
57 | numffts = atoi (optarg);
58 | break;
59 | case 'i':
60 | isinverse = 1;
61 | break;
62 | case 'h':
63 | case '?':
64 | default:
65 | fprintf(stderr,"options:\n-n N: complex fft length\n-i: inverse\n-x N: number of ffts to compute\n"
66 | "");
67 | }
68 | }
69 |
70 | in=FFTMALLOC(sizeof(CPXTYPE) * nfft);
71 | out=FFTMALLOC(sizeof(CPXTYPE) * nfft);
72 | for (i=0;i
3 | #include
4 | #include
5 |
6 | #include
7 | static inline
8 | double curtime(void)
9 | {
10 | struct timeval tv;
11 | gettimeofday(&tv, NULL);
12 | return (double)tv.tv_sec + (double)tv.tv_usec*.000001;
13 | }
14 |
15 | using namespace std;
16 |
17 | template
18 | void dotest(int nfft)
19 | {
20 | typedef kissfft FFT;
21 | typedef std::complex cpx_type;
22 |
23 | cout << "type:" << typeid(T).name() << " nfft:" << nfft;
24 |
25 | FFT fft(nfft,false);
26 |
27 | vector inbuf(nfft);
28 | vector outbuf(nfft);
29 | for (int k=0;k acc = 0;
39 | long double phinc = 2*k0* M_PIl / nfft;
40 | for (int k1=0;k1 x(inbuf[k1].real(),inbuf[k1].imag());
42 | acc += x * exp( complex(0,-k1*phinc) );
43 | }
44 | totalpower += norm(acc);
45 | complex x(outbuf[k0].real(),outbuf[k0].imag());
46 | complex dif = acc - x;
47 | difpower += norm(dif);
48 | }
49 | cout << " RMSE:" << sqrt(difpower/totalpower) << "\t";
50 |
51 | double t0 = curtime();
52 | int nits=20e6/nfft;
53 | for (int k=0;k1) {
63 | for (int k=1;k(nfft); dotest(nfft); dotest(nfft);
66 | }
67 | }else{
68 | dotest(32); dotest(32); dotest(32);
69 | dotest(1024); dotest(1024); dotest(1024);
70 | dotest(840); dotest(840); dotest(840);
71 | }
72 | return 0;
73 | }
74 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/test/compfft.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | # use FFTPACK as a baseline
4 | import FFT
5 | from Numeric import *
6 | import math
7 | import random
8 | import sys
9 | import struct
10 | import fft
11 |
12 | pi=math.pi
13 | e=math.e
14 | j=complex(0,1)
15 | lims=(-32768,32767)
16 |
17 | def randbuf(n,cpx=1):
18 | res = array( [ random.uniform( lims[0],lims[1] ) for i in range(n) ] )
19 | if cpx:
20 | res = res + j*randbuf(n,0)
21 | return res
22 |
23 | def main():
24 | from getopt import getopt
25 | import popen2
26 | opts,args = getopt( sys.argv[1:],'u:n:Rt:' )
27 | opts=dict(opts)
28 | exitcode=0
29 |
30 | util = opts.get('-u','./kf_float')
31 |
32 | try:
33 | dims = [ int(d) for d in opts['-n'].split(',')]
34 | cpx = opts.get('-R') is None
35 | fmt=opts.get('-t','f')
36 | except KeyError:
37 | sys.stderr.write("""
38 | usage: compfft.py
39 | -n d1[,d2,d3...] : FFT dimension(s)
40 | -u utilname : see sample_code/fftutil.c, default = ./kf_float
41 | -R : real-optimized version\n""")
42 | sys.exit(1)
43 |
44 | x = fft.make_random( dims )
45 |
46 | cmd = '%s -n %s ' % ( util, ','.join([ str(d) for d in dims]) )
47 | if cpx:
48 | xout = FFT.fftnd(x)
49 | xout = reshape(xout,(size(xout),))
50 | else:
51 | cmd += '-R '
52 | xout = FFT.real_fft(x)
53 |
54 | proc = popen2.Popen3( cmd , bufsize=len(x) )
55 |
56 | proc.tochild.write( dopack( x , fmt ,cpx ) )
57 | proc.tochild.close()
58 | xoutcomp = dounpack( proc.fromchild.read( ) , fmt ,1 )
59 | #xoutcomp = reshape( xoutcomp , dims )
60 |
61 | sig = xout * conjugate(xout)
62 | sigpow = sum( sig )
63 |
64 | diff = xout-xoutcomp
65 | noisepow = sum( diff * conjugate(diff) )
66 |
67 | snr = 10 * math.log10(abs( sigpow / noisepow ) )
68 | if snr<100:
69 | print xout
70 | print xoutcomp
71 | exitcode=1
72 | print 'NFFT=%s,SNR = %f dB' % (str(dims),snr)
73 | sys.exit(exitcode)
74 |
75 | def dopack(x,fmt,cpx):
76 | x = reshape( x, ( size(x),) )
77 | if cpx:
78 | s = ''.join( [ struct.pack('ff',c.real,c.imag) for c in x ] )
79 | else:
80 | s = ''.join( [ struct.pack('f',c) for c in x ] )
81 | return s
82 |
83 | def dounpack(x,fmt,cpx):
84 | uf = fmt * ( len(x) / 4 )
85 | s = struct.unpack(uf,x)
86 | if cpx:
87 | return array(s[::2]) + array( s[1::2] )*j
88 | else:
89 | return array(s )
90 |
91 | if __name__ == "__main__":
92 | main()
93 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/README.simd:
--------------------------------------------------------------------------------
1 | If you are reading this, it means you think you may be interested in using the SIMD extensions in kissfft
2 | to do 4 *separate* FFTs at once.
3 |
4 | Beware! Beyond here there be dragons!
5 |
6 | This API is not easy to use, is not well documented, and breaks the KISS principle.
7 |
8 |
9 | Still reading? Okay, you may get rewarded for your patience with a considerable speedup
10 | (2-3x) on intel x86 machines with SSE if you are willing to jump through some hoops.
11 |
12 | The basic idea is to use the packed 4 float __m128 data type as a scalar element.
13 | This means that the format is pretty convoluted. It performs 4 FFTs per fft call on signals A,B,C,D.
14 |
15 | For complex data, the data is interlaced as follows:
16 | rA0,rB0,rC0,rD0, iA0,iB0,iC0,iD0, rA1,rB1,rC1,rD1, iA1,iB1,iC1,iD1 ...
17 | where "rA0" is the real part of the zeroth sample for signal A
18 |
19 | Real-only data is laid out:
20 | rA0,rB0,rC0,rD0, rA1,rB1,rC1,rD1, ...
21 |
22 | Compile with gcc flags something like
23 | -O3 -mpreferred-stack-boundary=4 -DUSE_SIMD=1 -msse
24 |
25 | Be aware of SIMD alignment. This is the most likely cause of segfaults.
26 | The code within kissfft uses scratch variables on the stack.
27 | With SIMD, these must have addresses on 16 byte boundaries.
28 | Search on "SIMD alignment" for more info.
29 |
30 |
31 |
32 | Robin at Divide Concept was kind enough to share his code for formatting to/from the SIMD kissfft.
33 | I have not run it -- use it at your own risk. It appears to do 4xN and Nx4 transpositions
34 | (out of place).
35 |
36 | void SSETools::pack128(float* target, float* source, unsigned long size128)
37 | {
38 | __m128* pDest = (__m128*)target;
39 | __m128* pDestEnd = pDest+size128;
40 | float* source0=source;
41 | float* source1=source0+size128;
42 | float* source2=source1+size128;
43 | float* source3=source2+size128;
44 |
45 | while(pDest
2 | #include
3 | #include
4 | #include "kiss_fft.h"
5 | #include "kiss_fftr.h"
6 | #include
7 |
8 |
9 | static
10 | double two_tone_test( int nfft, int bin1,int bin2)
11 | {
12 | kiss_fftr_cfg cfg = NULL;
13 | kiss_fft_cpx *kout = NULL;
14 | kiss_fft_scalar *tbuf = NULL;
15 |
16 | int i;
17 | double f1 = bin1*2*M_PI/nfft;
18 | double f2 = bin2*2*M_PI/nfft;
19 | double sigpow=0;
20 | double noisepow=0;
21 | #if FIXED_POINT==32
22 | long maxrange = LONG_MAX;
23 | #else
24 | long maxrange = SHRT_MAX;/* works fine for float too*/
25 | #endif
26 |
27 | cfg = kiss_fftr_alloc(nfft , 0, NULL, NULL);
28 | tbuf = KISS_FFT_MALLOC(nfft * sizeof(kiss_fft_scalar));
29 | kout = KISS_FFT_MALLOC(nfft * sizeof(kiss_fft_cpx));
30 |
31 | /* generate a signal with two tones*/
32 | for (i = 0; i < nfft; i++) {
33 | #ifdef USE_SIMD
34 | tbuf[i] = _mm_set1_ps( (maxrange>>1)*cos(f1*i)
35 | + (maxrange>>1)*cos(f2*i) );
36 | #else
37 | tbuf[i] = (maxrange>>1)*cos(f1*i)
38 | + (maxrange>>1)*cos(f2*i);
39 | #endif
40 | }
41 |
42 | kiss_fftr(cfg, tbuf, kout);
43 |
44 | for (i=0;i < (nfft/2+1);++i) {
45 | #ifdef USE_SIMD
46 | double tmpr = (double)*(float*)&kout[i].r / (double)maxrange;
47 | double tmpi = (double)*(float*)&kout[i].i / (double)maxrange;
48 | #else
49 | double tmpr = (double)kout[i].r / (double)maxrange;
50 | double tmpi = (double)kout[i].i / (double)maxrange;
51 | #endif
52 | double mag2 = tmpr*tmpr + tmpi*tmpi;
53 | if (i!=0 && i!= nfft/2)
54 | mag2 *= 2; /* all bins except DC and Nyquist have symmetric counterparts implied*/
55 |
56 | /* if there is power in one of the expected bins, it is signal, otherwise noise*/
57 | if ( i!=bin1 && i != bin2 )
58 | noisepow += mag2;
59 | else
60 | sigpow += mag2;
61 | }
62 | kiss_fft_cleanup();
63 | /*printf("TEST %d,%d,%d noise @ %fdB\n",nfft,bin1,bin2,10*log10(noisepow/sigpow +1e-30) );*/
64 | return 10*log10(sigpow/(noisepow+1e-50) );
65 | }
66 |
67 | int main(int argc,char ** argv)
68 | {
69 | int nfft = 4*2*2*3*5;
70 | if (argc>1) nfft = atoi(argv[1]);
71 |
72 | int i,j;
73 | double minsnr = 500;
74 | double maxsnr = -500;
75 | double snr;
76 | for (i=0;i>4)+1) {
77 | for (j=i;j>4)+7) {
78 | snr = two_tone_test(nfft,i,j);
79 | if (snrmaxsnr) {
83 | maxsnr=snr;
84 | }
85 | }
86 | }
87 | snr = two_tone_test(nfft,nfft/2,nfft/2);
88 | if (snrmaxsnr) maxsnr=snr;
90 |
91 | printf("TwoToneTest: snr ranges from %ddB to %ddB\n",(int)minsnr,(int)maxsnr);
92 | printf("sizeof(kiss_fft_scalar) = %d\n",(int)sizeof(kiss_fft_scalar) );
93 | return 0;
94 | }
95 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/test/fastfir.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | from Numeric import *
4 | from FFT import *
5 |
6 | def make_random(len):
7 | import random
8 | res=[]
9 | for i in range(int(len)):
10 | r=random.uniform(-1,1)
11 | i=random.uniform(-1,1)
12 | res.append( complex(r,i) )
13 | return res
14 |
15 | def slowfilter(sig,h):
16 | translen = len(h)-1
17 | return convolve(sig,h)[translen:-translen]
18 |
19 | def nextpow2(x):
20 | return 2 ** math.ceil(math.log(x)/math.log(2))
21 |
22 | def fastfilter(sig,h,nfft=None):
23 | if nfft is None:
24 | nfft = int( nextpow2( 2*len(h) ) )
25 | H = fft( h , nfft )
26 | scraplen = len(h)-1
27 | keeplen = nfft-scraplen
28 | res=[]
29 | isdone = 0
30 | lastidx = nfft
31 | idx0 = 0
32 | while not isdone:
33 | idx1 = idx0 + nfft
34 | if idx1 >= len(sig):
35 | idx1 = len(sig)
36 | lastidx = idx1-idx0
37 | if lastidx <= scraplen:
38 | break
39 | isdone = 1
40 | Fss = fft(sig[idx0:idx1],nfft)
41 | fm = Fss * H
42 | m = inverse_fft(fm)
43 | res.append( m[scraplen:lastidx] )
44 | idx0 += keeplen
45 | return concatenate( res )
46 |
47 | def main():
48 | import sys
49 | from getopt import getopt
50 | opts,args = getopt(sys.argv[1:],'rn:l:')
51 | opts=dict(opts)
52 |
53 | siglen = int(opts.get('-l',1e4 ) )
54 | hlen =50
55 |
56 | nfft = int(opts.get('-n',128) )
57 | usereal = opts.has_key('-r')
58 |
59 | print 'nfft=%d'%nfft
60 | # make a signal
61 | sig = make_random( siglen )
62 | # make an impulse response
63 | h = make_random( hlen )
64 | #h=[1]*2+[0]*3
65 | if usereal:
66 | sig=[c.real for c in sig]
67 | h=[c.real for c in h]
68 |
69 | # perform MAC filtering
70 | yslow = slowfilter(sig,h)
71 | #print '',yslow,''
72 | #yfast = fastfilter(sig,h,nfft)
73 | yfast = utilfastfilter(sig,h,nfft,usereal)
74 | #print yfast
75 | print 'len(yslow)=%d'%len(yslow)
76 | print 'len(yfast)=%d'%len(yfast)
77 | diff = yslow-yfast
78 | snr = 10*log10( abs( vdot(yslow,yslow) / vdot(diff,diff) ) )
79 | print 'snr=%s' % snr
80 | if snr < 10.0:
81 | print 'h=',h
82 | print 'sig=',sig[:5],'...'
83 | print 'yslow=',yslow[:5],'...'
84 | print 'yfast=',yfast[:5],'...'
85 |
86 | def utilfastfilter(sig,h,nfft,usereal):
87 | import compfft
88 | import os
89 | open( 'sig.dat','w').write( compfft.dopack(sig,'f',not usereal) )
90 | open( 'h.dat','w').write( compfft.dopack(h,'f',not usereal) )
91 | if usereal:
92 | util = './fastconvr'
93 | else:
94 | util = './fastconv'
95 | cmd = 'time %s -n %d -i sig.dat -h h.dat -o out.dat' % (util, nfft)
96 | print cmd
97 | ec = os.system(cmd)
98 | print 'exited->',ec
99 | return compfft.dounpack(open('out.dat').read(),'f',not usereal)
100 |
101 | if __name__ == "__main__":
102 | main()
103 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/test/Makefile:
--------------------------------------------------------------------------------
1 |
2 | WARNINGS=-W -Wall -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return \
3 | -Wcast-align -Wcast-qual -Wnested-externs -Wshadow -Wbad-function-cast \
4 | -Wwrite-strings
5 |
6 | CFLAGS=-O3 -I.. -I../tools $(WARNINGS)
7 | CFLAGS+=-ffast-math -fomit-frame-pointer
8 | #CFLAGS+=-funroll-loops
9 | #CFLAGS+=-march=prescott
10 | #CFLAGS+= -mtune=native
11 | # TIP: try adding -openmp or -fopenmp to enable OPENMP directives and use of multiple cores
12 | #CFLAGS+=-fopenmp
13 | CFLAGS+= $(CFLAGADD)
14 |
15 |
16 | ifeq "$(NFFT)" ""
17 | NFFT=1800
18 | endif
19 | ifeq "$(NUMFFTS)" ""
20 | NUMFFTS=10000
21 | endif
22 |
23 | ifeq "$(DATATYPE)" ""
24 | DATATYPE=float
25 | endif
26 |
27 | BENCHKISS=bm_kiss_$(DATATYPE)
28 | BENCHFFTW=bm_fftw_$(DATATYPE)
29 | SELFTEST=st_$(DATATYPE)
30 | TESTREAL=tr_$(DATATYPE)
31 | TESTKFC=tkfc_$(DATATYPE)
32 | FASTFILTREAL=ffr_$(DATATYPE)
33 | SELFTESTSRC=twotonetest.c
34 |
35 |
36 | TYPEFLAGS=-Dkiss_fft_scalar=$(DATATYPE)
37 |
38 | ifeq "$(DATATYPE)" "int16_t"
39 | TYPEFLAGS=-DFIXED_POINT=16
40 | endif
41 |
42 | ifeq "$(DATATYPE)" "int32_t"
43 | TYPEFLAGS=-DFIXED_POINT=32
44 | endif
45 |
46 | ifeq "$(DATATYPE)" "simd"
47 | TYPEFLAGS=-DUSE_SIMD=1 -msse
48 | endif
49 |
50 |
51 | ifeq "$(DATATYPE)" "float"
52 | # fftw needs to be built with --enable-float to build this lib
53 | FFTWLIB=-lfftw3f
54 | else
55 | FFTWLIB=-lfftw3
56 | endif
57 |
58 | FFTWLIBDIR=-L/usr/local/lib/
59 |
60 | SRCFILES=../kiss_fft.c ../tools/kiss_fftnd.c ../tools/kiss_fftr.c pstats.c ../tools/kfc.c ../tools/kiss_fftndr.c
61 |
62 | all: tools $(BENCHKISS) $(SELFTEST) $(BENCHFFTW) $(TESTREAL) $(TESTKFC)
63 |
64 | tools:
65 | cd ../tools && make all
66 |
67 |
68 | $(SELFTEST): $(SELFTESTSRC) $(SRCFILES)
69 | $(CC) -o $@ $(CFLAGS) $(TYPEFLAGS) $+ -lm
70 |
71 | $(TESTKFC): $(SRCFILES)
72 | $(CC) -o $@ $(CFLAGS) -DKFC_TEST $(TYPEFLAGS) $+ -lm
73 |
74 | $(TESTREAL): test_real.c $(SRCFILES)
75 | $(CC) -o $@ $(CFLAGS) $(TYPEFLAGS) $+ -lm
76 |
77 | $(BENCHKISS): benchkiss.c $(SRCFILES)
78 | $(CC) -o $@ $(CFLAGS) $(TYPEFLAGS) $+ -lm
79 |
80 | $(BENCHFFTW): benchfftw.c pstats.c
81 | @echo "======attempting to build FFTW benchmark"
82 | @$(CC) -o $@ $(CFLAGS) -DDATATYPE$(DATATYPE) $+ $(FFTWLIB) $(FFTWLIBDIR) -lm || echo "FFTW not available for comparison"
83 |
84 | test: all
85 | @./$(TESTKFC)
86 | @echo "======1d & 2-d complex fft self test (type= $(DATATYPE) )"
87 | @./$(SELFTEST)
88 | @echo "======real FFT (type= $(DATATYPE) )"
89 | @./$(TESTREAL)
90 | @echo "======timing test (type=$(DATATYPE))"
91 | @./$(BENCHKISS) -x $(NUMFFTS) -n $(NFFT)
92 | @[ -x ./$(BENCHFFTW) ] && ./$(BENCHFFTW) -x $(NUMFFTS) -n $(NFFT) ||true
93 | @echo "======higher dimensions type=$(DATATYPE))"
94 | @./testkiss.py
95 |
96 | selftest.c:
97 | ./mk_test.py 10 12 14 > selftest.c
98 | selftest_short.c:
99 | ./mk_test.py -s 10 12 14 > selftest_short.c
100 |
101 |
102 | CXXFLAGS=-O3 -ffast-math -fomit-frame-pointer -I.. -I../tools -W -Wall
103 | testcpp: testcpp.cc ../kissfft.hh
104 | $(CXX) -o $@ $(CXXFLAGS) testcpp.cc -lm
105 |
106 |
107 | clean:
108 | rm -f *~ bm_* st_* tr_* kf_* tkfc_* ff_* ffr_* *.pyc *.pyo *.dat testcpp
109 |
--------------------------------------------------------------------------------
/Builds/MacOSX/WavegenPlugin.xcodeproj/xcuserdata/aaronleese.xcuserdatad/xcschemes/WavegenPlugin (VST3).xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
34 |
35 |
45 |
46 |
52 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
70 |
71 |
72 |
73 |
75 |
76 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/Builds/MacOSX/WavegenPlugin.xcodeproj/xcuserdata/aaronleese.xcuserdatad/xcschemes/WavegenPlugin (AU).xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
34 |
35 |
45 |
46 |
52 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
70 |
71 |
72 |
73 |
75 |
76 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/Builds/MacOSX/WavegenPlugin.xcodeproj/xcuserdata/aaronleese.xcuserdatad/xcschemes/WavegenPlugin (Shared Code).xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
34 |
35 |
45 |
46 |
52 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
70 |
71 |
72 |
73 |
75 |
76 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/Builds/MacOSX/WavegenPlugin.xcodeproj/xcuserdata/aaronleese.xcuserdatad/xcschemes/WavegenPlugin (All).xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
34 |
35 |
45 |
48 |
49 |
50 |
56 |
57 |
58 |
59 |
60 |
61 |
67 |
68 |
74 |
75 |
76 |
77 |
79 |
80 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/Builds/MacOSX/WavegenPlugin.xcodeproj/xcuserdata/aaronleese.xcuserdatad/xcschemes/WavegenPlugin (VST).xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
34 |
35 |
45 |
49 |
50 |
51 |
57 |
58 |
59 |
60 |
61 |
62 |
68 |
69 |
75 |
76 |
77 |
78 |
80 |
81 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/test/mk_test.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | import FFT
4 | import sys
5 | import random
6 | import re
7 | j=complex(0,1)
8 |
9 | def randvec(n,iscomplex):
10 | if iscomplex:
11 | return [
12 | int(random.uniform(-32768,32767) ) + j*int(random.uniform(-32768,32767) )
13 | for i in range(n) ]
14 | else:
15 | return [ int(random.uniform(-32768,32767) ) for i in range(n) ]
16 |
17 | def c_format(v,round=0):
18 | if round:
19 | return ','.join( [ '{%d,%d}' %(int(c.real),int(c.imag) ) for c in v ] )
20 | else:
21 | s= ','.join( [ '{%.60f ,%.60f }' %(c.real,c.imag) for c in v ] )
22 | return re.sub(r'\.?0+ ',' ',s)
23 |
24 | def test_cpx( n,inverse ,short):
25 | v = randvec(n,1)
26 | scale = 1
27 | if short:
28 | minsnr=30
29 | else:
30 | minsnr=100
31 |
32 | if inverse:
33 | tvecout = FFT.inverse_fft(v)
34 | if short:
35 | scale = 1
36 | else:
37 | scale = len(v)
38 | else:
39 | tvecout = FFT.fft(v)
40 | if short:
41 | scale = 1.0/len(v)
42 |
43 | tvecout = [ c * scale for c in tvecout ]
44 |
45 |
46 | s="""#define NFFT %d""" % len(v) + """
47 | {
48 | double snr;
49 | kiss_fft_cpx test_vec_in[NFFT] = { """ + c_format(v) + """};
50 | kiss_fft_cpx test_vec_out[NFFT] = {""" + c_format( tvecout ) + """};
51 | kiss_fft_cpx testbuf[NFFT];
52 | void * cfg = kiss_fft_alloc(NFFT,%d,0,0);""" % inverse + """
53 |
54 | kiss_fft(cfg,test_vec_in,testbuf);
55 | snr = snr_compare(test_vec_out,testbuf,NFFT);
56 | printf("DATATYPE=" xstr(kiss_fft_scalar) ", FFT n=%d, inverse=%d, snr = %g dB\\n",NFFT,""" + str(inverse) + """,snr);
57 | if (snr<""" + str(minsnr) + """)
58 | exit_code++;
59 | free(cfg);
60 | }
61 | #undef NFFT
62 | """
63 | return s
64 |
65 | def compare_func():
66 | s="""
67 | #define xstr(s) str(s)
68 | #define str(s) #s
69 | double snr_compare( kiss_fft_cpx * test_vec_out,kiss_fft_cpx * testbuf, int n)
70 | {
71 | int k;
72 | double sigpow,noisepow,err,snr,scale=0;
73 | kiss_fft_cpx err;
74 | sigpow = noisepow = .000000000000000000000000000001;
75 |
76 | for (k=0;k (sound) != nullptr;
58 | }
59 |
60 | void startNote (int midiNoteNumber, float velocity,
61 | SynthesiserSound* /*sound*/,
62 | int /*currentPitchWheelPosition*/) override
63 | {
64 |
65 | currentAngle = 0.0;
66 | level = velocity * 0.15;
67 | tailOff = 0.0;
68 |
69 | double cyclesPerSecond = MidiMessage::getMidiNoteInHertz (midiNoteNumber);
70 | double cyclesPerSample = cyclesPerSecond / getSampleRate();
71 |
72 | angleDelta = cyclesPerSample * 2.0 * double_Pi;
73 |
74 | // PITCH ::::
75 | myWaveGenerator.setMasterDelta(angleDelta);
76 | myWaveGenerator.setVolume(0);
77 |
78 | }
79 |
80 | void stopNote (float /*velocity*/, bool allowTailOff) override
81 | {
82 |
83 | myWaveGenerator.setVolume(-120);
84 |
85 | clearCurrentNote();
86 | }
87 |
88 | void pitchWheelMoved (int /*newValue*/) override
89 | {
90 | // not implemented for the purposes of this demo!
91 | }
92 |
93 | void controllerMoved (int /*controllerNumber*/, int /*newValue*/) override
94 | {
95 | // not implemented for the purposes of this demo!
96 | }
97 |
98 | void renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples) override
99 | {
100 |
101 |
102 | AudioSampleBuffer nextBuffer(2, numSamples);
103 | nextBuffer.clear();
104 |
105 | myWaveGenerator.renderNextBlock(nextBuffer, numSamples);
106 |
107 | outputBuffer.copyFrom(0, startSample, *nextBuffer.getArrayOfReadPointers(), numSamples);
108 | outputBuffer.copyFrom(1, startSample, *nextBuffer.getArrayOfReadPointers(), numSamples);
109 |
110 | }
111 |
112 | private:
113 | double currentAngle, angleDelta, level, tailOff;
114 | };
115 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/test/benchkiss.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include "kiss_fft.h"
6 | #include "kiss_fftr.h"
7 | #include "kiss_fftnd.h"
8 | #include "kiss_fftndr.h"
9 |
10 | #include "pstats.h"
11 |
12 | static
13 | int getdims(int * dims, char * arg)
14 | {
15 | char *s;
16 | int ndims=0;
17 | while ( (s=strtok( arg , ",") ) ) {
18 | dims[ndims++] = atoi(s);
19 | //printf("%s=%d\n",s,dims[ndims-1]);
20 | arg=NULL;
21 | }
22 | return ndims;
23 | }
24 |
25 | int main(int argc,char ** argv)
26 | {
27 | int k;
28 | int nfft[32];
29 | int ndims = 1;
30 | int isinverse=0;
31 | int numffts=1000,i;
32 | kiss_fft_cpx * buf;
33 | kiss_fft_cpx * bufout;
34 | int real = 0;
35 |
36 | nfft[0] = 1024;// default
37 |
38 | while (1) {
39 | int c = getopt (argc, argv, "n:ix:r");
40 | if (c == -1)
41 | break;
42 | switch (c) {
43 | case 'r':
44 | real = 1;
45 | break;
46 | case 'n':
47 | ndims = getdims(nfft, optarg );
48 | if (nfft[0] != kiss_fft_next_fast_size(nfft[0]) ) {
49 | int ng = kiss_fft_next_fast_size(nfft[0]);
50 | fprintf(stderr,"warning: %d might be a better choice for speed than %d\n",ng,nfft[0]);
51 | }
52 | break;
53 | case 'x':
54 | numffts = atoi (optarg);
55 | break;
56 | case 'i':
57 | isinverse = 1;
58 | break;
59 | }
60 | }
61 | int nbytes = sizeof(kiss_fft_cpx);
62 | for (k=0;k
5 | #include
6 | #include
7 | #include
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*
14 | ATTENTION!
15 | If you would like a :
16 | -- a utility that will handle the caching of fft objects
17 | -- real-only (no imaginary time component ) FFT
18 | -- a multi-dimensional FFT
19 | -- a command-line utility to perform ffts
20 | -- a command-line utility to perform fast-convolution filtering
21 |
22 | Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c
23 | in the tools/ directory.
24 | */
25 |
26 | #ifdef USE_SIMD
27 | # include
28 | # define kiss_fft_scalar __m128
29 | #define KISS_FFT_MALLOC(nbytes) _mm_malloc(nbytes,16)
30 | #define KISS_FFT_FREE _mm_free
31 | #else
32 | #define KISS_FFT_MALLOC malloc
33 | #define KISS_FFT_FREE free
34 | #endif
35 |
36 |
37 | #ifdef FIXED_POINT
38 | #include
39 | # if (FIXED_POINT == 32)
40 | # define kiss_fft_scalar int32_t
41 | # else
42 | # define kiss_fft_scalar int16_t
43 | # endif
44 | #else
45 | # ifndef kiss_fft_scalar
46 | /* default is float */
47 | # define kiss_fft_scalar float
48 | # endif
49 | #endif
50 |
51 | typedef struct {
52 | kiss_fft_scalar r;
53 | kiss_fft_scalar i;
54 | }kiss_fft_cpx;
55 |
56 | typedef struct kiss_fft_state* kiss_fft_cfg;
57 |
58 | /*
59 | * kiss_fft_alloc
60 | *
61 | * Initialize a FFT (or IFFT) algorithm's cfg/state buffer.
62 | *
63 | * typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL);
64 | *
65 | * The return value from fft_alloc is a cfg buffer used internally
66 | * by the fft routine or NULL.
67 | *
68 | * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc.
69 | * The returned value should be free()d when done to avoid memory leaks.
70 | *
71 | * The state can be placed in a user supplied buffer 'mem':
72 | * If lenmem is not NULL and mem is not NULL and *lenmem is large enough,
73 | * then the function places the cfg in mem and the size used in *lenmem
74 | * and returns mem.
75 | *
76 | * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough),
77 | * then the function returns NULL and places the minimum cfg
78 | * buffer size in *lenmem.
79 | * */
80 |
81 | kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem);
82 |
83 | /*
84 | * kiss_fft(cfg,in_out_buf)
85 | *
86 | * Perform an FFT on a complex input buffer.
87 | * for a forward FFT,
88 | * fin should be f[0] , f[1] , ... ,f[nfft-1]
89 | * fout will be F[0] , F[1] , ... ,F[nfft-1]
90 | * Note that each element is complex and can be accessed like
91 | f[k].r and f[k].i
92 | * */
93 | void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout);
94 |
95 | /*
96 | A more generic version of the above function. It reads its input from every Nth sample.
97 | * */
98 | void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride);
99 |
100 | /* If kiss_fft_alloc allocated a buffer, it is one contiguous
101 | buffer and can be simply free()d when no longer needed*/
102 | #define kiss_fft_free free
103 |
104 | /*
105 | Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up
106 | your compiler output to call this before you exit.
107 | */
108 | void kiss_fft_cleanup(void);
109 |
110 |
111 | /*
112 | * Returns the smallest integer k, such that k>=n and k has only "fast" factors (2,3,5)
113 | */
114 | int kiss_fft_next_fast_size(int n);
115 |
116 | /* for real ffts, we need an even size */
117 | #define kiss_fftr_next_fast_size_real(n) \
118 | (kiss_fft_next_fast_size( ((n)+1)>>1)<<1)
119 |
120 | #ifdef __cplusplus
121 | }
122 | #endif
123 |
124 | #endif
125 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/tools/kfc.c:
--------------------------------------------------------------------------------
1 | #include "kfc.h"
2 |
3 | /*
4 | Copyright (c) 2003-2004, Mark Borgerding
5 |
6 | All rights reserved.
7 |
8 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
9 |
10 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
11 | * 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.
12 | * 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.
13 |
14 | 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.
15 | */
16 |
17 |
18 | typedef struct cached_fft *kfc_cfg;
19 |
20 | struct cached_fft
21 | {
22 | int nfft;
23 | int inverse;
24 | kiss_fft_cfg cfg;
25 | kfc_cfg next;
26 | };
27 |
28 | static kfc_cfg cache_root=NULL;
29 | static int ncached=0;
30 |
31 | static kiss_fft_cfg find_cached_fft(int nfft,int inverse)
32 | {
33 | size_t len;
34 | kfc_cfg cur=cache_root;
35 | kfc_cfg prev=NULL;
36 | while ( cur ) {
37 | if ( cur->nfft == nfft && inverse == cur->inverse )
38 | break;/*found the right node*/
39 | prev = cur;
40 | cur = prev->next;
41 | }
42 | if (cur== NULL) {
43 | /* no cached node found, need to create a new one*/
44 | kiss_fft_alloc(nfft,inverse,0,&len);
45 | #ifdef USE_SIMD
46 | int padding = (16-sizeof(struct cached_fft)) & 15;
47 | // make sure the cfg aligns on a 16 byte boundary
48 | len += padding;
49 | #endif
50 | cur = (kfc_cfg)KISS_FFT_MALLOC((sizeof(struct cached_fft) + len ));
51 | if (cur == NULL)
52 | return NULL;
53 | cur->cfg = (kiss_fft_cfg)(cur+1);
54 | #ifdef USE_SIMD
55 | cur->cfg = (kiss_fft_cfg) ((char*)(cur+1)+padding);
56 | #endif
57 | kiss_fft_alloc(nfft,inverse,cur->cfg,&len);
58 | cur->nfft=nfft;
59 | cur->inverse=inverse;
60 | cur->next = NULL;
61 | if ( prev )
62 | prev->next = cur;
63 | else
64 | cache_root = cur;
65 | ++ncached;
66 | }
67 | return cur->cfg;
68 | }
69 |
70 | void kfc_cleanup(void)
71 | {
72 | kfc_cfg cur=cache_root;
73 | kfc_cfg next=NULL;
74 | while (cur){
75 | next = cur->next;
76 | free(cur);
77 | cur=next;
78 | }
79 | ncached=0;
80 | cache_root = NULL;
81 | }
82 | void kfc_fft(int nfft, const kiss_fft_cpx * fin,kiss_fft_cpx * fout)
83 | {
84 | kiss_fft( find_cached_fft(nfft,0),fin,fout );
85 | }
86 |
87 | void kfc_ifft(int nfft, const kiss_fft_cpx * fin,kiss_fft_cpx * fout)
88 | {
89 | kiss_fft( find_cached_fft(nfft,1),fin,fout );
90 | }
91 |
92 | #ifdef KFC_TEST
93 | static void check(int nc)
94 | {
95 | if (ncached != nc) {
96 | fprintf(stderr,"ncached should be %d,but it is %d\n",nc,ncached);
97 | exit(1);
98 | }
99 | }
100 |
101 | int main(void)
102 | {
103 | kiss_fft_cpx buf1[1024],buf2[1024];
104 | memset(buf1,0,sizeof(buf1));
105 | check(0);
106 | kfc_fft(512,buf1,buf2);
107 | check(1);
108 | kfc_fft(512,buf1,buf2);
109 | check(1);
110 | kfc_ifft(512,buf1,buf2);
111 | check(2);
112 | kfc_cleanup();
113 | check(0);
114 | return 0;
115 | }
116 | #endif
117 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/test/testkiss.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | import math
4 | import sys
5 | import os
6 | import random
7 | import struct
8 | import popen2
9 | import getopt
10 | import numpy
11 |
12 | pi=math.pi
13 | e=math.e
14 | j=complex(0,1)
15 |
16 | doreal=0
17 |
18 | datatype = os.environ.get('DATATYPE','float')
19 |
20 | util = '../tools/fft_' + datatype
21 | minsnr=90
22 | if datatype == 'double':
23 | fmt='d'
24 | elif datatype=='int16_t':
25 | fmt='h'
26 | minsnr=10
27 | elif datatype=='int32_t':
28 | fmt='i'
29 | elif datatype=='simd':
30 | fmt='4f'
31 | sys.stderr.write('testkiss.py does not yet test simd')
32 | sys.exit(0)
33 | elif datatype=='float':
34 | fmt='f'
35 | else:
36 | sys.stderr.write('unrecognized datatype %s\n' % datatype)
37 | sys.exit(1)
38 |
39 |
40 | def dopack(x,cpx=1):
41 | x = numpy.reshape( x, ( numpy.size(x),) )
42 |
43 | if cpx:
44 | s = ''.join( [ struct.pack(fmt*2,c.real,c.imag) for c in x ] )
45 | else:
46 | s = ''.join( [ struct.pack(fmt,c.real) for c in x ] )
47 | return s
48 |
49 | def dounpack(x,cpx):
50 | uf = fmt * ( len(x) / struct.calcsize(fmt) )
51 | s = struct.unpack(uf,x)
52 | if cpx:
53 | return numpy.array(s[::2]) + numpy.array( s[1::2] )*j
54 | else:
55 | return numpy.array(s )
56 |
57 | def make_random(dims=[1]):
58 | res = []
59 | for i in range(dims[0]):
60 | if len(dims)==1:
61 | r=random.uniform(-1,1)
62 | if doreal:
63 | res.append( r )
64 | else:
65 | i=random.uniform(-1,1)
66 | res.append( complex(r,i) )
67 | else:
68 | res.append( make_random( dims[1:] ) )
69 | return numpy.array(res)
70 |
71 | def flatten(x):
72 | ntotal = numpy.size(x)
73 | return numpy.reshape(x,(ntotal,))
74 |
75 | def randmat( ndims ):
76 | dims=[]
77 | for i in range( ndims ):
78 | curdim = int( random.uniform(2,5) )
79 | if doreal and i==(ndims-1):
80 | curdim = int(curdim/2)*2 # force even last dimension if real
81 | dims.append( curdim )
82 | return make_random(dims )
83 |
84 | def test_fft(ndims):
85 | x=randmat( ndims )
86 |
87 |
88 | if doreal:
89 | xver = numpy.fft.rfftn(x)
90 | else:
91 | xver = numpy.fft.fftn(x)
92 |
93 | open('/tmp/fftexp.dat','w').write(dopack( flatten(xver) , True ) )
94 |
95 | x2=dofft(x,doreal)
96 | err = xver - x2
97 | errf = flatten(err)
98 | xverf = flatten(xver)
99 | errpow = numpy.vdot(errf,errf)+1e-10
100 | sigpow = numpy.vdot(xverf,xverf)+1e-10
101 | snr = 10*math.log10(abs(sigpow/errpow) )
102 | print 'SNR (compared to NumPy) : %.1fdB' % float(snr)
103 |
104 | if snr
7 |
8 | #include "kiss_fft.h"
9 | #include "kiss_fftnd.h"
10 | #include "kiss_fftr.h"
11 |
12 | BEGIN_BENCH_DOC
13 | BENCH_DOC("name", "kissfft")
14 | BENCH_DOC("version", "1.0.1")
15 | BENCH_DOC("year", "2004")
16 | BENCH_DOC("author", "Mark Borgerding")
17 | BENCH_DOC("language", "C")
18 | BENCH_DOC("url", "http://sourceforge.net/projects/kissfft/")
19 | BENCH_DOC("copyright",
20 | "Copyright (c) 2003,4 Mark Borgerding\n"
21 | "\n"
22 | "All rights reserved.\n"
23 | "\n"
24 | "Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n"
25 | "\n"
26 | " * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n"
27 | " * 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.\n"
28 | " * 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.\n"
29 | "\n"
30 | "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.\n")
31 | END_BENCH_DOC
32 |
33 | int can_do(struct problem *p)
34 | {
35 | if (p->rank == 1) {
36 | if (p->kind == PROBLEM_REAL) {
37 | return (p->n[0] & 1) == 0; /* only even real is okay */
38 | } else {
39 | return 1;
40 | }
41 | } else {
42 | return p->kind == PROBLEM_COMPLEX;
43 | }
44 | }
45 |
46 | static kiss_fft_cfg cfg=NULL;
47 | static kiss_fftr_cfg cfgr=NULL;
48 | static kiss_fftnd_cfg cfgnd=NULL;
49 |
50 | #define FAILIF( c ) \
51 | if ( c ) do {\
52 | fprintf(stderr,\
53 | "kissfft: " #c " (file=%s:%d errno=%d %s)\n",\
54 | __FILE__,__LINE__ , errno,strerror( errno ) ) ;\
55 | exit(1);\
56 | }while(0)
57 |
58 |
59 |
60 | void setup(struct problem *p)
61 | {
62 | size_t i;
63 |
64 | /*
65 | fprintf(stderr,"%s %s %d-d ",
66 | (p->sign == 1)?"Inverse":"Forward",
67 | p->kind == PROBLEM_COMPLEX?"Complex":"Real",
68 | p->rank);
69 | */
70 | if (p->rank == 1) {
71 | if (p->kind == PROBLEM_COMPLEX) {
72 | cfg = kiss_fft_alloc (p->n[0], (p->sign == 1), 0, 0);
73 | FAILIF(cfg==NULL);
74 | }else{
75 | cfgr = kiss_fftr_alloc (p->n[0], (p->sign == 1), 0, 0);
76 | FAILIF(cfgr==NULL);
77 | }
78 | }else{
79 | int dims[5];
80 | for (i=0;irank;++i){
81 | dims[i] = p->n[i];
82 | }
83 | /* multi-dimensional */
84 | if (p->kind == PROBLEM_COMPLEX) {
85 | cfgnd = kiss_fftnd_alloc( dims , p->rank, (p->sign == 1), 0, 0 );
86 | FAILIF(cfgnd==NULL);
87 | }
88 | }
89 | }
90 |
91 | void doit(int iter, struct problem *p)
92 | {
93 | int i;
94 | void *in = p->in;
95 | void *out = p->out;
96 |
97 | if (p->in_place)
98 | out = p->in;
99 |
100 | if (p->rank == 1) {
101 | if (p->kind == PROBLEM_COMPLEX){
102 | for (i = 0; i < iter; ++i)
103 | kiss_fft (cfg, in, out);
104 | } else {
105 | /* PROBLEM_REAL */
106 | if (p->sign == -1) /* FORWARD */
107 | for (i = 0; i < iter; ++i)
108 | kiss_fftr (cfgr, in, out);
109 | else
110 | for (i = 0; i < iter; ++i)
111 | kiss_fftri (cfgr, in, out);
112 | }
113 | }else{
114 | /* multi-dimensional */
115 | for (i = 0; i < iter; ++i)
116 | kiss_fftnd(cfgnd,in,out);
117 | }
118 | }
119 |
120 | void done(struct problem *p)
121 | {
122 | free(cfg);
123 | cfg=NULL;
124 | free(cfgr);
125 | cfgr=NULL;
126 | free(cfgnd);
127 | cfgnd=NULL;
128 | UNUSED(p);
129 | }
130 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/tools/kiss_fftndr.c:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2003-2004, Mark Borgerding
3 |
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7 |
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9 | * 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.
10 | * 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.
11 |
12 | 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.
13 | */
14 |
15 | #include "kiss_fftndr.h"
16 | #include "_kiss_fft_guts.h"
17 | #define MAX(x,y) ( ( (x)<(y) )?(y):(x) )
18 |
19 | struct kiss_fftndr_state
20 | {
21 | int dimReal;
22 | int dimOther;
23 | kiss_fftr_cfg cfg_r;
24 | kiss_fftnd_cfg cfg_nd;
25 | void * tmpbuf;
26 | };
27 |
28 | static int prod(const int *dims, int ndims)
29 | {
30 | int x=1;
31 | while (ndims--)
32 | x *= *dims++;
33 | return x;
34 | }
35 |
36 | kiss_fftndr_cfg kiss_fftndr_alloc(const int *dims,int ndims,int inverse_fft,void*mem,size_t*lenmem)
37 | {
38 | kiss_fftndr_cfg st = NULL;
39 | size_t nr=0 , nd=0,ntmp=0;
40 | int dimReal = dims[ndims-1];
41 | int dimOther = prod(dims,ndims-1);
42 | size_t memneeded;
43 |
44 | (void)kiss_fftr_alloc(dimReal,inverse_fft,NULL,&nr);
45 | (void)kiss_fftnd_alloc(dims,ndims-1,inverse_fft,NULL,&nd);
46 | ntmp =
47 | MAX( 2*dimOther , dimReal+2) * sizeof(kiss_fft_scalar) // freq buffer for one pass
48 | + dimOther*(dimReal+2) * sizeof(kiss_fft_scalar); // large enough to hold entire input in case of in-place
49 |
50 | memneeded = sizeof( struct kiss_fftndr_state ) + nr + nd + ntmp;
51 |
52 | if (lenmem==NULL) {
53 | st = (kiss_fftndr_cfg) malloc(memneeded);
54 | }else{
55 | if (*lenmem >= memneeded)
56 | st = (kiss_fftndr_cfg)mem;
57 | *lenmem = memneeded;
58 | }
59 | if (st==NULL)
60 | return NULL;
61 | memset( st , 0 , memneeded);
62 |
63 | st->dimReal = dimReal;
64 | st->dimOther = dimOther;
65 | st->cfg_r = kiss_fftr_alloc( dimReal,inverse_fft,st+1,&nr);
66 | st->cfg_nd = kiss_fftnd_alloc(dims,ndims-1,inverse_fft, ((char*) st->cfg_r)+nr,&nd);
67 | st->tmpbuf = (char*)st->cfg_nd + nd;
68 |
69 | return st;
70 | }
71 |
72 | void kiss_fftndr(kiss_fftndr_cfg st,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata)
73 | {
74 | int k1,k2;
75 | int dimReal = st->dimReal;
76 | int dimOther = st->dimOther;
77 | int nrbins = dimReal/2+1;
78 |
79 | kiss_fft_cpx * tmp1 = (kiss_fft_cpx*)st->tmpbuf;
80 | kiss_fft_cpx * tmp2 = tmp1 + MAX(nrbins,dimOther);
81 |
82 | // timedata is N0 x N1 x ... x Nk real
83 |
84 | // take a real chunk of data, fft it and place the output at correct intervals
85 | for (k1=0;k1cfg_r, timedata + k1*dimReal , tmp1 ); // tmp1 now holds nrbins complex points
87 | for (k2=0;k2cfg_nd, tmp2+k2*dimOther, tmp1); // tmp1 now holds dimOther complex points
93 | for (k1=0;k1dimReal;
102 | int dimOther = st->dimOther;
103 | int nrbins = dimReal/2+1;
104 | kiss_fft_cpx * tmp1 = (kiss_fft_cpx*)st->tmpbuf;
105 | kiss_fft_cpx * tmp2 = tmp1 + MAX(nrbins,dimOther);
106 |
107 | for (k2=0;k2cfg_nd, tmp1, tmp2+k2*dimOther);
111 | }
112 |
113 | for (k1=0;k1cfg_r,tmp1,timedata + k1*dimReal);
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/test/test_real.c:
--------------------------------------------------------------------------------
1 | #include "kiss_fftr.h"
2 | #include "_kiss_fft_guts.h"
3 | #include
4 | #include
5 | #include
6 |
7 | static double cputime(void)
8 | {
9 | struct tms t;
10 | times(&t);
11 | return (double)(t.tms_utime + t.tms_stime)/ sysconf(_SC_CLK_TCK) ;
12 | }
13 |
14 | static
15 | kiss_fft_scalar rand_scalar(void)
16 | {
17 | #ifdef USE_SIMD
18 | return _mm_set1_ps(rand()-RAND_MAX/2);
19 | #else
20 | kiss_fft_scalar s = (kiss_fft_scalar)(rand() -RAND_MAX/2);
21 | return s/2;
22 | #endif
23 | }
24 |
25 | static
26 | double snr_compare( kiss_fft_cpx * vec1,kiss_fft_cpx * vec2, int n)
27 | {
28 | int k;
29 | double sigpow=1e-10,noisepow=1e-10,err,snr,scale=0;
30 |
31 | #ifdef USE_SIMD
32 | float *fv1 = (float*)vec1;
33 | float *fv2 = (float*)vec2;
34 | for (k=0;k<8*n;++k) {
35 | sigpow += *fv1 * *fv1;
36 | err = *fv1 - *fv2;
37 | noisepow += err*err;
38 | ++fv1;
39 | ++fv2;
40 | }
41 | #else
42 | for (k=0;k1)
74 | nfft = atoi(argv[1]);
75 | kiss_fft_cpx cin[nfft];
76 | kiss_fft_cpx cout[nfft];
77 | kiss_fft_cpx sout[nfft];
78 | kiss_fft_cfg kiss_fft_state;
79 | kiss_fftr_cfg kiss_fftr_state;
80 |
81 | kiss_fft_scalar rin[nfft+2];
82 | kiss_fft_scalar rout[nfft+2];
83 | kiss_fft_scalar zero;
84 | memset(&zero,0,sizeof(zero) ); // ugly way of setting short,int,float,double, or __m128 to zero
85 |
86 | srand(time(0));
87 |
88 | for (i=0;i int16_t,int32_t,int64_t
43 | If your system does not have these, you may need to define them -- but at least it breaks in a
44 | loud and easily fixable way -- unlike silently using the wrong size type.
45 |
46 | Hopefully tools/psdpng.c is fixed -- thanks to Steve Kellog for pointing out the weirdness.
47 |
48 | 1.2.3 (June 25, 2005) The "you want to use WHAT as a sample" release.
49 | Added ability to use 32 bit fixed point samples -- requires a 64 bit intermediate result, a la 'long long'
50 |
51 | Added ability to do 4 FFTs in parallel by using SSE SIMD instructions. This is accomplished by
52 | using the __m128 (vector of 4 floats) as kiss_fft_scalar. Define USE_SIMD to use this.
53 |
54 | I know, I know ... this is drifting a bit from the "kiss" principle, but the speed advantages
55 | make it worth it for some. Also recent gcc makes it SOO easy to use vectors of 4 floats like a POD type.
56 |
57 | 1.2.2 (May 6, 2005) The Matthew release
58 | Replaced fixed point division with multiply&shift. Thanks to Jean-Marc Valin for
59 | discussions regarding. Considerable speedup for fixed-point.
60 |
61 | Corrected overflow protection in real fft routines when using fixed point.
62 | Finder's Credit goes to Robert Oschler of robodance for pointing me at the bug.
63 | This also led to the CHECK_OVERFLOW_OP macro.
64 |
65 | 1.2.1 (April 4, 2004)
66 | compiles cleanly with just about every -W warning flag under the sun
67 |
68 | reorganized kiss_fft_state so it could be read-only/const. This may be useful for embedded systems
69 | that are willing to predeclare twiddle factors, factorization.
70 |
71 | Fixed C_MUL,S_MUL on 16-bit platforms.
72 |
73 | tmpbuf will only be allocated if input & output buffers are same
74 | scratchbuf will only be allocated for ffts that are not multiples of 2,3,5
75 |
76 | NOTE: The tmpbuf,scratchbuf changes may require synchronization code for multi-threaded apps.
77 |
78 |
79 | 1.2 (Feb 23, 2004)
80 | interface change -- cfg object is forward declaration of struct instead of void*
81 | This maintains type saftey and lets the compiler warn/error about stupid mistakes.
82 | (prompted by suggestion from Erik de Castro Lopo)
83 |
84 | small speed improvements
85 |
86 | added psdpng.c -- sample utility that will create png spectrum "waterfalls" from an input file
87 | ( not terribly useful yet)
88 |
89 | 1.1.1 (Feb 1, 2004 )
90 | minor bug fix -- only affects odd rank, in-place, multi-dimensional FFTs
91 |
92 | 1.1 : (Jan 30,2004)
93 | split sample_code/ into test/ and tools/
94 |
95 | Removed 2-D fft and added N-D fft (arbitrary)
96 |
97 | modified fftutil.c to allow multi-d FFTs
98 |
99 | Modified core fft routine to allow an input stride via kiss_fft_stride()
100 | (eased support of multi-D ffts)
101 |
102 | Added fast convolution filtering (FIR filtering using overlap-scrap method, with tail scrap)
103 |
104 | Add kfc.[ch]: the KISS FFT Cache. It takes care of allocs for you ( suggested by Oscar Lesta ).
105 |
106 | 1.0.1 (Dec 15, 2003)
107 | fixed bug that occurred when nfft==1. Thanks to Steven Johnson.
108 |
109 | 1.0 : (Dec 14, 2003)
110 | changed kiss_fft function from using a single buffer, to two buffers.
111 | If the same buffer pointer is supplied for both in and out, kiss will
112 | manage the buffer copies.
113 |
114 | added kiss_fft2d and kiss_fftr as separate source files (declarations in kiss_fft.h )
115 |
116 | 0.4 :(Nov 4,2003) optimized for radix 2,3,4,5
117 |
118 | 0.3 :(Oct 28, 2003) woops, version 2 didn't actually factor out any radices other than 2.
119 | Thanks to Steven Johnson for finding this one.
120 |
121 | 0.2 :(Oct 27, 2003) added mixed radix, only radix 2,4 optimized versions
122 |
123 | 0.1 :(May 19 2003) initial release, radix 2 only
124 |
--------------------------------------------------------------------------------
/Source/PluginProcessor.h:
--------------------------------------------------------------------------------
1 | /*
2 | ==============================================================================
3 |
4 | This file was auto-generated by the Jucer!
5 |
6 | It contains the basic startup code for a Juce application.
7 |
8 | ==============================================================================
9 | */
10 |
11 | #ifndef __PLUGINPROCESSOR_H_526ED7A9__
12 | #define __PLUGINPROCESSOR_H_526ED7A9__
13 |
14 | #include "../JuceLibraryCode/JuceHeader.h"
15 | #include "FFTKiss.h"
16 |
17 | //==============================================================================
18 | /**
19 | As the name suggest, this class does the actual audio processing.
20 | */
21 | class WaveGenPluginAudioProcessor : public AudioProcessor
22 | {
23 | public:
24 |
25 | // OUTPUT ::: for display
26 | AudioSampleBuffer currentOutput;
27 |
28 | //==============================================================================
29 | WaveGenPluginAudioProcessor();
30 | ~WaveGenPluginAudioProcessor();
31 |
32 | //==============================================================================
33 | void prepareToPlay (double sampleRate, int samplesPerBlock) override;
34 | void releaseResources() override;
35 | void reset() override;
36 |
37 | //==============================================================================
38 | void processBlock (AudioBuffer& buffer, MidiBuffer& midiMessages) override
39 | {
40 | jassert (! isUsingDoublePrecision());
41 | process (buffer, midiMessages, delayBufferFloat);
42 | }
43 |
44 | void processBlock (AudioBuffer& buffer, MidiBuffer& midiMessages) override
45 | {
46 | jassert (isUsingDoublePrecision());
47 | process (buffer, midiMessages, delayBufferDouble);
48 | }
49 |
50 | //==============================================================================
51 | bool hasEditor() const override { return true; }
52 | AudioProcessorEditor* createEditor() override;
53 |
54 | Component* createFFTGraph();
55 |
56 | //==============================================================================
57 | const String getName() const override { return JucePlugin_Name; }
58 |
59 | bool acceptsMidi() const override { return true; }
60 | bool producesMidi() const override { return true; }
61 |
62 | double getTailLengthSeconds() const override { return 0.0; }
63 |
64 | //==============================================================================
65 | int getNumPrograms() override { return 0; }
66 | int getCurrentProgram() override { return 0; }
67 | void setCurrentProgram (int /*index*/) override {}
68 | const String getProgramName (int /*index*/) override { return String(); }
69 | void changeProgramName (int /*index*/, const String& /*name*/) override {}
70 |
71 | //==============================================================================
72 | void getStateInformation (MemoryBlock&) override;
73 | void setStateInformation (const void* data, int sizeInBytes) override;
74 |
75 | //==============================================================================
76 | // These properties are public so that our editor component can access them
77 | // A bit of a hacky way to do it, but it's only a demo! Obviously in your own
78 | // code you'll do this much more neatly..
79 |
80 | // this is kept up to date with the midi messages that arrive, and the UI component
81 | // registers with it so it can represent the incoming messages
82 | MidiKeyboardState keyboardState;
83 |
84 | // this keeps a copy of the last set of time info that was acquired during an audio
85 | // callback - the UI component will read this and display it.
86 | AudioPlayHead::CurrentPositionInfo lastPosInfo;
87 |
88 | // these are used to persist the UI's size - the values are stored along with the
89 | // filter's other parameters, and the UI component will update them when it gets
90 | // resized.
91 | int lastUIWidth, lastUIHeight;
92 |
93 | // Our parameters
94 | AudioParameterFloat* gainParam;
95 | AudioParameterFloat* delayParam;
96 |
97 | Synthesiser* getSynth() { return &synth; }
98 |
99 | private:
100 | //==============================================================================
101 | template
102 | void process (AudioBuffer& buffer, MidiBuffer& midiMessages, AudioBuffer& delayBuffer);
103 | template
104 | void applyGain (AudioBuffer&, AudioBuffer& delayBuffer);
105 | template
106 | void applyDelay (AudioBuffer&, AudioBuffer& delayBuffer);
107 |
108 | AudioBuffer delayBufferFloat;
109 | AudioBuffer delayBufferDouble;
110 | int delayPosition;
111 |
112 | Synthesiser synth;
113 | FFTProcessor myFFT;
114 |
115 | void initialiseSynth();
116 | void updateCurrentTimeInfoFromHost();
117 |
118 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WaveGenPluginAudioProcessor)
119 | };
120 |
121 | #endif // __PLUGINPROCESSOR_H_526ED7A9__
122 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/test/fft.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | import math
4 | import sys
5 | import random
6 |
7 | pi=math.pi
8 | e=math.e
9 | j=complex(0,1)
10 |
11 | def fft(f,inv):
12 | n=len(f)
13 | if n==1:
14 | return f
15 |
16 | for p in 2,3,5:
17 | if n%p==0:
18 | break
19 | else:
20 | raise Exception('%s not factorable ' % n)
21 |
22 | m = n/p
23 | Fout=[]
24 | for q in range(p): # 0,1
25 | fp = f[q::p] # every p'th time sample
26 | Fp = fft( fp ,inv)
27 | Fout.extend( Fp )
28 |
29 | for u in range(m):
30 | scratch = Fout[u::m] # u to end in strides of m
31 | for q1 in range(p):
32 | k = q1*m + u # indices to Fout above that became scratch
33 | Fout[ k ] = scratch[0] # cuz e**0==1 in loop below
34 | for q in range(1,p):
35 | if inv:
36 | t = e ** ( j*2*pi*k*q/n )
37 | else:
38 | t = e ** ( -j*2*pi*k*q/n )
39 | Fout[ k ] += scratch[q] * t
40 |
41 | return Fout
42 |
43 | def rifft(F):
44 | N = len(F) - 1
45 | Z = [0] * (N)
46 | for k in range(N):
47 | Fek = ( F[k] + F[-k-1].conjugate() )
48 | Fok = ( F[k] - F[-k-1].conjugate() ) * e ** (j*pi*k/N)
49 | Z[k] = Fek + j*Fok
50 |
51 | fp = fft(Z , 1)
52 |
53 | f = []
54 | for c in fp:
55 | f.append(c.real)
56 | f.append(c.imag)
57 | return f
58 |
59 | def real_fft( f,inv ):
60 | if inv:
61 | return rifft(f)
62 |
63 | N = len(f) / 2
64 |
65 | res = f[::2]
66 | ims = f[1::2]
67 |
68 | fp = [ complex(r,i) for r,i in zip(res,ims) ]
69 | print 'fft input ', fp
70 | Fp = fft( fp ,0 )
71 | print 'fft output ', Fp
72 |
73 | F = [ complex(0,0) ] * ( N+1 )
74 |
75 | F[0] = complex( Fp[0].real + Fp[0].imag , 0 )
76 |
77 | for k in range(1,N/2+1):
78 | tw = e ** ( -j*pi*(.5+float(k)/N ) )
79 |
80 | F1k = Fp[k] + Fp[N-k].conjugate()
81 | F2k = Fp[k] - Fp[N-k].conjugate()
82 | F2k *= tw
83 | F[k] = ( F1k + F2k ) * .5
84 | F[N-k] = ( F1k - F2k ).conjugate() * .5
85 | #F[N-k] = ( F1kp + e ** ( -j*pi*(.5+float(N-k)/N ) ) * F2kp ) * .5
86 | #F[N-k] = ( F1k.conjugate() - tw.conjugate() * F2k.conjugate() ) * .5
87 |
88 | F[N] = complex( Fp[0].real - Fp[0].imag , 0 )
89 | return F
90 |
91 | def main():
92 | #fft_func = fft
93 | fft_func = real_fft
94 |
95 | tvec = [0.309655,0.815653,0.768570,0.591841,0.404767,0.637617,0.007803,0.012665]
96 | Ftvec = [ complex(r,i) for r,i in zip(
97 | [3.548571,-0.378761,-0.061950,0.188537,-0.566981,0.188537,-0.061950,-0.378761],
98 | [0.000000,-1.296198,-0.848764,0.225337,0.000000,-0.225337,0.848764,1.296198] ) ]
99 |
100 | F = fft_func( tvec,0 )
101 |
102 | nerrs= 0
103 | for i in range(len(Ftvec)/2 + 1):
104 | if abs( F[i] - Ftvec[i] )> 1e-5:
105 | print 'F[%d]: %s != %s' % (i,F[i],Ftvec[i])
106 | nerrs += 1
107 |
108 | print '%d errors in forward fft' % nerrs
109 | if nerrs:
110 | return
111 |
112 | trec = fft_func( F , 1 )
113 |
114 | for i in range(len(trec) ):
115 | trec[i] /= len(trec)
116 |
117 | for i in range(len(tvec) ):
118 | if abs( trec[i] - tvec[i] )> 1e-5:
119 | print 't[%d]: %s != %s' % (i,tvec[i],trec[i])
120 | nerrs += 1
121 |
122 | print '%d errors in reverse fft' % nerrs
123 |
124 |
125 | def make_random(dims=[1]):
126 | import Numeric
127 | res = []
128 | for i in range(dims[0]):
129 | if len(dims)==1:
130 | r=random.uniform(-1,1)
131 | i=random.uniform(-1,1)
132 | res.append( complex(r,i) )
133 | else:
134 | res.append( make_random( dims[1:] ) )
135 | return Numeric.array(res)
136 |
137 | def flatten(x):
138 | import Numeric
139 | ntotal = Numeric.product(Numeric.shape(x))
140 | return Numeric.reshape(x,(ntotal,))
141 |
142 | def randmat( ndims ):
143 | dims=[]
144 | for i in range( ndims ):
145 | curdim = int( random.uniform(2,4) )
146 | dims.append( curdim )
147 | return make_random(dims )
148 |
149 | def test_fftnd(ndims=3):
150 | import FFT
151 | import Numeric
152 |
153 | x=randmat( ndims )
154 | print 'dimensions=%s' % str( Numeric.shape(x) )
155 | #print 'x=%s' %str(x)
156 | xver = FFT.fftnd(x)
157 | x2=myfftnd(x)
158 | err = xver - x2
159 | errf = flatten(err)
160 | xverf = flatten(xver)
161 | errpow = Numeric.vdot(errf,errf)+1e-10
162 | sigpow = Numeric.vdot(xverf,xverf)+1e-10
163 | snr = 10*math.log10(abs(sigpow/errpow) )
164 | if snr<80:
165 | print xver
166 | print x2
167 | print 'SNR=%sdB' % str( snr )
168 |
169 | def myfftnd(x):
170 | import Numeric
171 | xf = flatten(x)
172 | Xf = fftndwork( xf , Numeric.shape(x) )
173 | return Numeric.reshape(Xf,Numeric.shape(x) )
174 |
175 | def fftndwork(x,dims):
176 | import Numeric
177 | dimprod=Numeric.product( dims )
178 |
179 | for k in range( len(dims) ):
180 | cur_dim=dims[ k ]
181 | stride=dimprod/cur_dim
182 | next_x = [complex(0,0)]*len(x)
183 | for i in range(stride):
184 | next_x[i*cur_dim:(i+1)*cur_dim] = fft(x[i:(i+cur_dim)*stride:stride],0)
185 | x = next_x
186 | return x
187 |
188 | if __name__ == "__main__":
189 | try:
190 | nd = int(sys.argv[1])
191 | except:
192 | nd=None
193 | if nd:
194 | test_fftnd( nd )
195 | else:
196 | sys.exit(0)
197 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/README:
--------------------------------------------------------------------------------
1 | KISS FFT - A mixed-radix Fast Fourier Transform based up on the principle,
2 | "Keep It Simple, Stupid."
3 |
4 | There are many great fft libraries already around. Kiss FFT is not trying
5 | to be better than any of them. It only attempts to be a reasonably efficient,
6 | moderately useful FFT that can use fixed or floating data types and can be
7 | incorporated into someone's C program in a few minutes with trivial licensing.
8 |
9 | USAGE:
10 |
11 | The basic usage for 1-d complex FFT is:
12 |
13 | #include "kiss_fft.h"
14 |
15 | kiss_fft_cfg cfg = kiss_fft_alloc( nfft ,is_inverse_fft ,0,0 );
16 |
17 | while ...
18 |
19 | ... // put kth sample in cx_in[k].r and cx_in[k].i
20 |
21 | kiss_fft( cfg , cx_in , cx_out );
22 |
23 | ... // transformed. DC is in cx_out[0].r and cx_out[0].i
24 |
25 | free(cfg);
26 |
27 | Note: frequency-domain data is stored from dc up to 2pi.
28 | so cx_out[0] is the dc bin of the FFT
29 | and cx_out[nfft/2] is the Nyquist bin (if exists)
30 |
31 | Declarations are in "kiss_fft.h", along with a brief description of the
32 | functions you'll need to use.
33 |
34 | Code definitions for 1d complex FFTs are in kiss_fft.c.
35 |
36 | You can do other cool stuff with the extras you'll find in tools/
37 |
38 | * multi-dimensional FFTs
39 | * real-optimized FFTs (returns the positive half-spectrum: (nfft/2+1) complex frequency bins)
40 | * fast convolution FIR filtering (not available for fixed point)
41 | * spectrum image creation
42 |
43 | The core fft and most tools/ code can be compiled to use float, double,
44 | Q15 short or Q31 samples. The default is float.
45 |
46 |
47 | BACKGROUND:
48 |
49 | I started coding this because I couldn't find a fixed point FFT that didn't
50 | use assembly code. I started with floating point numbers so I could get the
51 | theory straight before working on fixed point issues. In the end, I had a
52 | little bit of code that could be recompiled easily to do ffts with short, float
53 | or double (other types should be easy too).
54 |
55 | Once I got my FFT working, I was curious about the speed compared to
56 | a well respected and highly optimized fft library. I don't want to criticize
57 | this great library, so let's call it FFT_BRANDX.
58 | During this process, I learned:
59 |
60 | 1. FFT_BRANDX has more than 100K lines of code. The core of kiss_fft is about 500 lines (cpx 1-d).
61 | 2. It took me an embarrassingly long time to get FFT_BRANDX working.
62 | 3. A simple program using FFT_BRANDX is 522KB. A similar program using kiss_fft is 18KB (without optimizing for size).
63 | 4. FFT_BRANDX is roughly twice as fast as KISS FFT in default mode.
64 |
65 | It is wonderful that free, highly optimized libraries like FFT_BRANDX exist.
66 | But such libraries carry a huge burden of complexity necessary to extract every
67 | last bit of performance.
68 |
69 | Sometimes simpler is better, even if it's not better.
70 |
71 | FREQUENTLY ASKED QUESTIONS:
72 | Q: Can I use kissfft in a project with a ___ license?
73 | A: Yes. See LICENSE below.
74 |
75 | Q: Why don't I get the output I expect?
76 | A: The two most common causes of this are
77 | 1) scaling : is there a constant multiplier between what you got and what you want?
78 | 2) mixed build environment -- all code must be compiled with same preprocessor
79 | definitions for FIXED_POINT and kiss_fft_scalar
80 |
81 | Q: Will you write/debug my code for me?
82 | A: Probably not unless you pay me. I am happy to answer pointed and topical questions, but
83 | I may refer you to a book, a forum, or some other resource.
84 |
85 |
86 | PERFORMANCE:
87 | (on Athlon XP 2100+, with gcc 2.96, float data type)
88 |
89 | Kiss performed 10000 1024-pt cpx ffts in .63 s of cpu time.
90 | For comparison, it took md5sum twice as long to process the same amount of data.
91 |
92 | Transforming 5 minutes of CD quality audio takes less than a second (nfft=1024).
93 |
94 | DO NOT:
95 | ... use Kiss if you need the Fastest Fourier Transform in the World
96 | ... ask me to add features that will bloat the code
97 |
98 | UNDER THE HOOD:
99 |
100 | Kiss FFT uses a time decimation, mixed-radix, out-of-place FFT. If you give it an input buffer
101 | and output buffer that are the same, a temporary buffer will be created to hold the data.
102 |
103 | No static data is used. The core routines of kiss_fft are thread-safe (but not all of the tools directory).
104 |
105 | No scaling is done for the floating point version (for speed).
106 | Scaling is done both ways for the fixed-point version (for overflow prevention).
107 |
108 | Optimized butterflies are used for factors 2,3,4, and 5.
109 |
110 | The real (i.e. not complex) optimization code only works for even length ffts. It does two half-length
111 | FFTs in parallel (packed into real&imag), and then combines them via twiddling. The result is
112 | nfft/2+1 complex frequency bins from DC to Nyquist. If you don't know what this means, search the web.
113 |
114 | The fast convolution filtering uses the overlap-scrap method, slightly
115 | modified to put the scrap at the tail.
116 |
117 | LICENSE:
118 | Revised BSD License, see COPYING for verbiage.
119 | Basically, "free to use&change, give credit where due, no guarantees"
120 | Note this license is compatible with GPL at one end of the spectrum and closed, commercial software at
121 | the other end. See http://www.fsf.org/licensing/licenses
122 |
123 | A commercial license is available which removes the requirement for attribution. Contact me for details.
124 |
125 |
126 | TODO:
127 | *) Add real optimization for odd length FFTs
128 | *) Document/revisit the input/output fft scaling
129 | *) Make doc describing the overlap (tail) scrap fast convolution filtering in kiss_fastfir.c
130 | *) Test all the ./tools/ code with fixed point (kiss_fastfir.c doesn't work, maybe others)
131 |
132 | AUTHOR:
133 | Mark Borgerding
134 | Mark@Borgerding.net
135 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/_kiss_fft_guts.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2003-2010, Mark Borgerding
3 |
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7 |
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9 | * 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.
10 | * 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.
11 |
12 | 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.
13 | */
14 |
15 | /* kiss_fft.h
16 | defines kiss_fft_scalar as either short or a float type
17 | and defines
18 | typedef struct { kiss_fft_scalar r; kiss_fft_scalar i; }kiss_fft_cpx; */
19 | #include "kiss_fft.h"
20 | #include
21 |
22 | #define MAXFACTORS 32
23 | /* e.g. an fft of length 128 has 4 factors
24 | as far as kissfft is concerned
25 | 4*4*4*2
26 | */
27 |
28 | struct kiss_fft_state{
29 | int nfft;
30 | int inverse;
31 | int factors[2*MAXFACTORS];
32 | kiss_fft_cpx twiddles[1];
33 | };
34 |
35 | /*
36 | Explanation of macros dealing with complex math:
37 |
38 | C_MUL(m,a,b) : m = a*b
39 | C_FIXDIV( c , div ) : if a fixed point impl., c /= div. noop otherwise
40 | C_SUB( res, a,b) : res = a - b
41 | C_SUBFROM( res , a) : res -= a
42 | C_ADDTO( res , a) : res += a
43 | * */
44 | #ifdef FIXED_POINT
45 | #if (FIXED_POINT==32)
46 | # define FRACBITS 31
47 | # define SAMPPROD int64_t
48 | #define SAMP_MAX 2147483647
49 | #else
50 | # define FRACBITS 15
51 | # define SAMPPROD int32_t
52 | #define SAMP_MAX 32767
53 | #endif
54 |
55 | #define SAMP_MIN -SAMP_MAX
56 |
57 | #if defined(CHECK_OVERFLOW)
58 | # define CHECK_OVERFLOW_OP(a,op,b) \
59 | if ( (SAMPPROD)(a) op (SAMPPROD)(b) > SAMP_MAX || (SAMPPROD)(a) op (SAMPPROD)(b) < SAMP_MIN ) { \
60 | fprintf(stderr,"WARNING:overflow @ " __FILE__ "(%d): (%d " #op" %d) = %ld\n",__LINE__,(a),(b),(SAMPPROD)(a) op (SAMPPROD)(b) ); }
61 | #endif
62 |
63 |
64 | # define smul(a,b) ( (SAMPPROD)(a)*(b) )
65 | # define sround( x ) (kiss_fft_scalar)( ( (x) + (1<<(FRACBITS-1)) ) >> FRACBITS )
66 |
67 | # define S_MUL(a,b) sround( smul(a,b) )
68 |
69 | # define C_MUL(m,a,b) \
70 | do{ (m).r = sround( smul((a).r,(b).r) - smul((a).i,(b).i) ); \
71 | (m).i = sround( smul((a).r,(b).i) + smul((a).i,(b).r) ); }while(0)
72 |
73 | # define DIVSCALAR(x,k) \
74 | (x) = sround( smul( x, SAMP_MAX/k ) )
75 |
76 | # define C_FIXDIV(c,div) \
77 | do { DIVSCALAR( (c).r , div); \
78 | DIVSCALAR( (c).i , div); }while (0)
79 |
80 | # define C_MULBYSCALAR( c, s ) \
81 | do{ (c).r = sround( smul( (c).r , s ) ) ;\
82 | (c).i = sround( smul( (c).i , s ) ) ; }while(0)
83 |
84 | #else /* not FIXED_POINT*/
85 |
86 | # define S_MUL(a,b) ( (a)*(b) )
87 | #define C_MUL(m,a,b) \
88 | do{ (m).r = (a).r*(b).r - (a).i*(b).i;\
89 | (m).i = (a).r*(b).i + (a).i*(b).r; }while(0)
90 | # define C_FIXDIV(c,div) /* NOOP */
91 | # define C_MULBYSCALAR( c, s ) \
92 | do{ (c).r *= (s);\
93 | (c).i *= (s); }while(0)
94 | #endif
95 |
96 | #ifndef CHECK_OVERFLOW_OP
97 | # define CHECK_OVERFLOW_OP(a,op,b) /* noop */
98 | #endif
99 |
100 | #define C_ADD( res, a,b)\
101 | do { \
102 | CHECK_OVERFLOW_OP((a).r,+,(b).r)\
103 | CHECK_OVERFLOW_OP((a).i,+,(b).i)\
104 | (res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \
105 | }while(0)
106 | #define C_SUB( res, a,b)\
107 | do { \
108 | CHECK_OVERFLOW_OP((a).r,-,(b).r)\
109 | CHECK_OVERFLOW_OP((a).i,-,(b).i)\
110 | (res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \
111 | }while(0)
112 | #define C_ADDTO( res , a)\
113 | do { \
114 | CHECK_OVERFLOW_OP((res).r,+,(a).r)\
115 | CHECK_OVERFLOW_OP((res).i,+,(a).i)\
116 | (res).r += (a).r; (res).i += (a).i;\
117 | }while(0)
118 |
119 | #define C_SUBFROM( res , a)\
120 | do {\
121 | CHECK_OVERFLOW_OP((res).r,-,(a).r)\
122 | CHECK_OVERFLOW_OP((res).i,-,(a).i)\
123 | (res).r -= (a).r; (res).i -= (a).i; \
124 | }while(0)
125 |
126 |
127 | #ifdef FIXED_POINT
128 | # define KISS_FFT_COS(phase) floor(.5+SAMP_MAX * cos (phase))
129 | # define KISS_FFT_SIN(phase) floor(.5+SAMP_MAX * sin (phase))
130 | # define HALF_OF(x) ((x)>>1)
131 | #elif defined(USE_SIMD)
132 | # define KISS_FFT_COS(phase) _mm_set1_ps( cos(phase) )
133 | # define KISS_FFT_SIN(phase) _mm_set1_ps( sin(phase) )
134 | # define HALF_OF(x) ((x)*_mm_set1_ps(.5))
135 | #else
136 | # define KISS_FFT_COS(phase) (kiss_fft_scalar) cos(phase)
137 | # define KISS_FFT_SIN(phase) (kiss_fft_scalar) sin(phase)
138 | # define HALF_OF(x) ((x)*.5)
139 | #endif
140 |
141 | #define kf_cexp(x,phase) \
142 | do{ \
143 | (x)->r = KISS_FFT_COS(phase);\
144 | (x)->i = KISS_FFT_SIN(phase);\
145 | }while(0)
146 |
147 |
148 | /* a debugging function */
149 | #define pcpx(c)\
150 | fprintf(stderr,"%g + %gi\n",(double)((c)->r),(double)((c)->i) )
151 |
152 |
153 | #ifdef KISS_FFT_USE_ALLOCA
154 | // define this to allow use of alloca instead of malloc for temporary buffers
155 | // Temporary buffers are used in two case:
156 | // 1. FFT sizes that have "bad" factors. i.e. not 2,3 and 5
157 | // 2. "in-place" FFTs. Notice the quotes, since kissfft does not really do an in-place transform.
158 | #include
159 | #define KISS_FFT_TMP_ALLOC(nbytes) alloca(nbytes)
160 | #define KISS_FFT_TMP_FREE(ptr)
161 | #else
162 | #define KISS_FFT_TMP_ALLOC(nbytes) KISS_FFT_MALLOC(nbytes)
163 | #define KISS_FFT_TMP_FREE(ptr) KISS_FFT_FREE(ptr)
164 | #endif
165 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/tools/kiss_fftr.c:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2003-2004, Mark Borgerding
3 |
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7 |
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9 | * 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.
10 | * 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.
11 |
12 | 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.
13 | */
14 |
15 | #include "kiss_fftr.h"
16 | #include "_kiss_fft_guts.h"
17 |
18 | struct kiss_fftr_state{
19 | kiss_fft_cfg substate;
20 | kiss_fft_cpx * tmpbuf;
21 | kiss_fft_cpx * super_twiddles;
22 | #ifdef USE_SIMD
23 | void * pad;
24 | #endif
25 | };
26 |
27 | kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem)
28 | {
29 | int i;
30 | kiss_fftr_cfg st = NULL;
31 | size_t subsize, memneeded;
32 |
33 | if (nfft & 1) {
34 | fprintf(stderr,"Real FFT optimization must be even.\n");
35 | return NULL;
36 | }
37 | nfft >>= 1;
38 |
39 | kiss_fft_alloc (nfft, inverse_fft, NULL, &subsize);
40 | memneeded = sizeof(struct kiss_fftr_state) + subsize + sizeof(kiss_fft_cpx) * ( nfft * 3 / 2);
41 |
42 | if (lenmem == NULL) {
43 | st = (kiss_fftr_cfg) KISS_FFT_MALLOC (memneeded);
44 | } else {
45 | if (*lenmem >= memneeded)
46 | st = (kiss_fftr_cfg) mem;
47 | *lenmem = memneeded;
48 | }
49 | if (!st)
50 | return NULL;
51 |
52 | st->substate = (kiss_fft_cfg) (st + 1); /*just beyond kiss_fftr_state struct */
53 | st->tmpbuf = (kiss_fft_cpx *) (((char *) st->substate) + subsize);
54 | st->super_twiddles = st->tmpbuf + nfft;
55 | kiss_fft_alloc(nfft, inverse_fft, st->substate, &subsize);
56 |
57 | for (i = 0; i < nfft/2; ++i) {
58 | double phase =
59 | -3.14159265358979323846264338327 * ((double) (i+1) / nfft + .5);
60 | if (inverse_fft)
61 | phase *= -1;
62 | kf_cexp (st->super_twiddles+i,phase);
63 | }
64 | return st;
65 | }
66 |
67 | void kiss_fftr(kiss_fftr_cfg st,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata)
68 | {
69 | /* input buffer timedata is stored row-wise */
70 | int k,ncfft;
71 | kiss_fft_cpx fpnk,fpk,f1k,f2k,tw,tdc;
72 |
73 | if ( st->substate->inverse) {
74 | fprintf(stderr,"kiss fft usage error: improper alloc\n");
75 | exit(1);
76 | }
77 |
78 | ncfft = st->substate->nfft;
79 |
80 | /*perform the parallel fft of two real signals packed in real,imag*/
81 | kiss_fft( st->substate , (const kiss_fft_cpx*)timedata, st->tmpbuf );
82 | /* The real part of the DC element of the frequency spectrum in st->tmpbuf
83 | * contains the sum of the even-numbered elements of the input time sequence
84 | * The imag part is the sum of the odd-numbered elements
85 | *
86 | * The sum of tdc.r and tdc.i is the sum of the input time sequence.
87 | * yielding DC of input time sequence
88 | * The difference of tdc.r - tdc.i is the sum of the input (dot product) [1,-1,1,-1...
89 | * yielding Nyquist bin of input time sequence
90 | */
91 |
92 | tdc.r = st->tmpbuf[0].r;
93 | tdc.i = st->tmpbuf[0].i;
94 | C_FIXDIV(tdc,2);
95 | CHECK_OVERFLOW_OP(tdc.r ,+, tdc.i);
96 | CHECK_OVERFLOW_OP(tdc.r ,-, tdc.i);
97 | freqdata[0].r = tdc.r + tdc.i;
98 | freqdata[ncfft].r = tdc.r - tdc.i;
99 | #ifdef USE_SIMD
100 | freqdata[ncfft].i = freqdata[0].i = _mm_set1_ps(0);
101 | #else
102 | freqdata[ncfft].i = freqdata[0].i = 0;
103 | #endif
104 |
105 | for ( k=1;k <= ncfft/2 ; ++k ) {
106 | fpk = st->tmpbuf[k];
107 | fpnk.r = st->tmpbuf[ncfft-k].r;
108 | fpnk.i = - st->tmpbuf[ncfft-k].i;
109 | C_FIXDIV(fpk,2);
110 | C_FIXDIV(fpnk,2);
111 |
112 | C_ADD( f1k, fpk , fpnk );
113 | C_SUB( f2k, fpk , fpnk );
114 | C_MUL( tw , f2k , st->super_twiddles[k-1]);
115 |
116 | freqdata[k].r = HALF_OF(f1k.r + tw.r);
117 | freqdata[k].i = HALF_OF(f1k.i + tw.i);
118 | freqdata[ncfft-k].r = HALF_OF(f1k.r - tw.r);
119 | freqdata[ncfft-k].i = HALF_OF(tw.i - f1k.i);
120 | }
121 | }
122 |
123 | void kiss_fftri(kiss_fftr_cfg st,const kiss_fft_cpx *freqdata,kiss_fft_scalar *timedata)
124 | {
125 | /* input buffer timedata is stored row-wise */
126 | int k, ncfft;
127 |
128 | if (st->substate->inverse == 0) {
129 | fprintf (stderr, "kiss fft usage error: improper alloc\n");
130 | exit (1);
131 | }
132 |
133 | ncfft = st->substate->nfft;
134 |
135 | st->tmpbuf[0].r = freqdata[0].r + freqdata[ncfft].r;
136 | st->tmpbuf[0].i = freqdata[0].r - freqdata[ncfft].r;
137 | C_FIXDIV(st->tmpbuf[0],2);
138 |
139 | for (k = 1; k <= ncfft / 2; ++k) {
140 | kiss_fft_cpx fk, fnkc, fek, fok, tmp;
141 | fk = freqdata[k];
142 | fnkc.r = freqdata[ncfft - k].r;
143 | fnkc.i = -freqdata[ncfft - k].i;
144 | C_FIXDIV( fk , 2 );
145 | C_FIXDIV( fnkc , 2 );
146 |
147 | C_ADD (fek, fk, fnkc);
148 | C_SUB (tmp, fk, fnkc);
149 | C_MUL (fok, tmp, st->super_twiddles[k-1]);
150 | C_ADD (st->tmpbuf[k], fek, fok);
151 | C_SUB (st->tmpbuf[ncfft - k], fek, fok);
152 | #ifdef USE_SIMD
153 | st->tmpbuf[ncfft - k].i *= _mm_set1_ps(-1.0);
154 | #else
155 | st->tmpbuf[ncfft - k].i *= -1;
156 | #endif
157 | }
158 | kiss_fft (st->substate, st->tmpbuf, (kiss_fft_cpx *) timedata);
159 | }
160 |
--------------------------------------------------------------------------------
/Source/FFTKiss.h:
--------------------------------------------------------------------------------
1 | /*
2 | * accelerateFFT.h
3 | * Livetronica Studio
4 | *
5 | * Created by Aaron Leese on 7/15/10.
6 | * Copyright 2010 StageCraft Software. All rights reserved.
7 | *
8 | */
9 |
10 |
11 | #pragma once
12 |
13 | #include "JuceHeader.h"
14 | #include "kiss_fft130/kiss_fft.h"
15 | #include "kiss_fft130/tools/kiss_fftr.h"
16 |
17 |
18 | class SpectralData;
19 |
20 | class FFTProcessor : public AudioProcessor
21 | {
22 |
23 | private:
24 |
25 | Array hanningWindow;
26 | Array magnitudes;
27 | Array phaseAngles;
28 |
29 | kiss_fft_cpx* input; // complex in
30 | kiss_fft_cpx* output; // complex result / output for FFT (input for iFFT)
31 |
32 | kiss_fft_cfg kiss_FFT_config;
33 | kiss_fft_cfg kiss_iFFT_config;
34 |
35 | kiss_fftr_cfg kiss_FFT_real_config;
36 | kiss_fftr_cfg kiss_iFFT_real_config;
37 |
38 |
39 | // For real only :::::
40 | kiss_fft_scalar* timedata; // for REAL only input
41 |
42 | public:
43 |
44 | Array incomingData;
45 | int recordMarker;
46 | int lastBufWritePos;
47 |
48 | int FFT_Resolution;
49 | bool realOnlyFFT; // set the FFT to use only REAL input (no imaginery numbers)
50 |
51 | public:
52 |
53 | bool stopCalculations;
54 | bool active; // for controlling if it repaints ...
55 | uint32 lastMillSecCount;
56 |
57 | // Pitch Detection
58 | StringArray notes; // = {"C ","C#","D ","D#","E ","F ","F#","G ","G#","A ","A#","B "};
59 | const float base_a4; //=440.0; // set A4=440Hz
60 |
61 | int currentRoot; // root notes, C,C#,etc.
62 | bool scale[12];
63 | float scaleIntervals[12];
64 | bool continuous;
65 |
66 | unsigned short currentNote;
67 | unsigned short lastNote;
68 |
69 | unsigned int cents; // for pitch bending from input
70 | unsigned int detune; // for pitch wheel
71 | double currentNoteStartTime;
72 |
73 | float peakIndex;
74 | float currentSum;
75 | uint32 lastBeat;
76 |
77 | FFTProcessor();
78 | ~FFTProcessor();
79 |
80 | int getResolution() {
81 |
82 | return incomingData.size();
83 | }
84 |
85 | void setResolution(int resolution, bool realDataOnly = true);
86 |
87 | float getFreqPeakPercent() {
88 |
89 | //
90 | float size = magnitudes.size();
91 | return peakIndex/size;
92 | }
93 |
94 | float getCurrentSum() {
95 |
96 | return currentSum;
97 | }
98 |
99 | Array getHanningWindow() {
100 |
101 | return hanningWindow;
102 |
103 | }
104 |
105 | kiss_fft_cpx* getOutput() {
106 |
107 | return output;
108 | }
109 |
110 | kiss_fft_cpx* getCurrentFullFFT(int numSamples);
111 |
112 | // :::::::::::::: AudioProcessor Methods
113 | //============================================================================== PROCESSOR CALLBACK METHODS
114 | void prepareToPlay (double sampleRate, int samplesPerBlock) override;
115 | void releaseResources() override;
116 |
117 | //==============================================================================
118 | void processBlock (AudioBuffer& buffer, MidiBuffer& midiMessages) override;
119 |
120 | void processBlock (AudioBuffer& buffer, MidiBuffer& midiMessages) override
121 | {
122 | // NOT implemented for double precision currently ...
123 | jassertfalse;
124 |
125 | }
126 |
127 |
128 | // ACTUALLY CALCULATE the FFT
129 | void calculateFFT();
130 |
131 | void getFFTfor(float* time, kiss_fft_cpx* freq);
132 | void getInverseFFTfor(kiss_fft_cpx* freq, float* timeData);
133 |
134 | Array getCurrentFFT(int resolution);
135 | Array getNoteResponse(int loMidiNote, int hiMidiNote, int noteSpan = 1);
136 | Array buildInverseFFT();
137 | Array getCurrentPhaseBins() {
138 |
139 | return phaseAngles;
140 |
141 | }
142 |
143 | Path getFullFFTPath();
144 |
145 | // Calculations ::::
146 | void calculateHistogram(AudioSampleBuffer* bufferToAnalyze, SpectralData& mySpectralAnalysis);
147 |
148 | void calculateKey(AudioSampleBuffer* bufferToAnalyze, SpectralData& mySpectralAnalysis);
149 |
150 | // AP methods :::
151 |
152 | bool acceptsMidi() const override { return true; }
153 | bool producesMidi() const override { return true; }
154 |
155 | double getTailLengthSeconds() const override { return 0.0; }
156 |
157 | //==============================================================================
158 | int getNumPrograms() override { return 0; }
159 | int getCurrentProgram() override { return 0; }
160 | void setCurrentProgram (int /*index*/) override {}
161 | const String getProgramName (int /*index*/) override { return String(); }
162 | void changeProgramName (int /*index*/, const String& /*name*/) override {}
163 |
164 | //==============================================================================
165 | void getStateInformation (MemoryBlock&) override {}
166 | void setStateInformation (const void* data, int sizeInBytes) override {}
167 |
168 |
169 | //============================================================================== UI
170 | bool hasEditor() const override {
171 | return false;
172 | }
173 |
174 | AudioProcessorEditor* createEditor() override
175 | {
176 | return nullptr;
177 | }
178 |
179 | Component* createFFTGraph();
180 | Component* createHistogramGraph();
181 |
182 |
183 | const String getName() const override {
184 |
185 | return "FFT Processor";
186 | }
187 |
188 |
189 | };
190 |
191 |
192 | /// UI ::::::::::
193 | class FFTGraphView : public Component,
194 | public Timer
195 | {
196 |
197 | ScopedPointer history;
198 | ScopedPointer historyGraphic;
199 | Path m_path;
200 | FFTProcessor* myFFTProcessor;
201 |
202 | bool refreshing;
203 | float animateCount;
204 | float animationLength = 100;
205 |
206 | ColourGradient spectrum;
207 |
208 | float maxPos = 0;
209 | float fadeMultiple = 0.8; //0.9;
210 |
211 | public:
212 |
213 | FFTGraphView(FFTProcessor* FFTCalc);
214 | ~FFTGraphView();
215 |
216 | void setFadeMultiple(float fade);
217 |
218 | private:
219 |
220 | void paint(Graphics& g) override;
221 |
222 | void update();
223 |
224 | void timerCallback() override;
225 |
226 | int getXforF(float freq);
227 |
228 | JUCE_LEAK_DETECTOR (FFTGraphView)
229 | };
230 |
--------------------------------------------------------------------------------
/JuceDemoPlugin.jucer:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
18 |
20 |
21 |
23 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
45 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
65 |
66 |
68 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
90 |
92 |
94 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/tools/fftutil.c:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2003-2004, Mark Borgerding
3 |
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7 |
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9 | * 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.
10 | * 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.
11 |
12 | 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.
13 | */
14 |
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 |
21 | #include "kiss_fft.h"
22 | #include "kiss_fftndr.h"
23 |
24 | static
25 | void fft_file(FILE * fin,FILE * fout,int nfft,int isinverse)
26 | {
27 | kiss_fft_cfg st;
28 | kiss_fft_cpx * buf;
29 | kiss_fft_cpx * bufout;
30 |
31 | buf = (kiss_fft_cpx*)malloc(sizeof(kiss_fft_cpx) * nfft );
32 | bufout = (kiss_fft_cpx*)malloc(sizeof(kiss_fft_cpx) * nfft );
33 | st = kiss_fft_alloc( nfft ,isinverse ,0,0);
34 |
35 | while ( fread( buf , sizeof(kiss_fft_cpx) * nfft ,1, fin ) > 0 ) {
36 | kiss_fft( st , buf ,bufout);
37 | fwrite( bufout , sizeof(kiss_fft_cpx) , nfft , fout );
38 | }
39 | free(st);
40 | free(buf);
41 | free(bufout);
42 | }
43 |
44 | static
45 | void fft_filend(FILE * fin,FILE * fout,int *dims,int ndims,int isinverse)
46 | {
47 | kiss_fftnd_cfg st;
48 | kiss_fft_cpx *buf;
49 | int dimprod=1,i;
50 | for (i=0;i 0) {
57 | kiss_fftnd (st, buf, buf);
58 | fwrite (buf, sizeof (kiss_fft_cpx), dimprod, fout);
59 | }
60 | free (st);
61 | free (buf);
62 | }
63 |
64 |
65 |
66 | static
67 | void fft_filend_real(FILE * fin,FILE * fout,int *dims,int ndims,int isinverse)
68 | {
69 | int dimprod=1,i;
70 | kiss_fftndr_cfg st;
71 | void *ibuf;
72 | void *obuf;
73 | int insize,outsize; // size in bytes
74 |
75 | for (i=0;i 0) {
91 | if (isinverse) {
92 | kiss_fftndri(st,
93 | (kiss_fft_cpx*)ibuf,
94 | (kiss_fft_scalar*)obuf);
95 | }else{
96 | kiss_fftndr(st,
97 | (kiss_fft_scalar*)ibuf,
98 | (kiss_fft_cpx*)obuf);
99 | }
100 | fwrite (obuf, sizeof(kiss_fft_scalar), outsize,fout);
101 | }
102 | free(st);
103 | free(ibuf);
104 | free(obuf);
105 | }
106 |
107 | static
108 | void fft_file_real(FILE * fin,FILE * fout,int nfft,int isinverse)
109 | {
110 | kiss_fftr_cfg st;
111 | kiss_fft_scalar * rbuf;
112 | kiss_fft_cpx * cbuf;
113 |
114 | rbuf = (kiss_fft_scalar*)malloc(sizeof(kiss_fft_scalar) * nfft );
115 | cbuf = (kiss_fft_cpx*)malloc(sizeof(kiss_fft_cpx) * (nfft/2+1) );
116 | st = kiss_fftr_alloc( nfft ,isinverse ,0,0);
117 |
118 | if (isinverse==0) {
119 | while ( fread( rbuf , sizeof(kiss_fft_scalar) * nfft ,1, fin ) > 0 ) {
120 | kiss_fftr( st , rbuf ,cbuf);
121 | fwrite( cbuf , sizeof(kiss_fft_cpx) , (nfft/2 + 1) , fout );
122 | }
123 | }else{
124 | while ( fread( cbuf , sizeof(kiss_fft_cpx) * (nfft/2+1) ,1, fin ) > 0 ) {
125 | kiss_fftri( st , cbuf ,rbuf);
126 | fwrite( rbuf , sizeof(kiss_fft_scalar) , nfft , fout );
127 | }
128 | }
129 | free(st);
130 | free(rbuf);
131 | free(cbuf);
132 | }
133 |
134 | static
135 | int get_dims(char * arg,int * dims)
136 | {
137 | char *p0;
138 | int ndims=0;
139 |
140 | do{
141 | p0 = strchr(arg,',');
142 | if (p0)
143 | *p0++ = '\0';
144 | dims[ndims++] = atoi(arg);
145 | // fprintf(stderr,"dims[%d] = %d\n",ndims-1,dims[ndims-1]);
146 | arg = p0;
147 | }while (p0);
148 | return ndims;
149 | }
150 |
151 | int main(int argc,char ** argv)
152 | {
153 | int isinverse=0;
154 | int isreal=0;
155 | FILE *fin=stdin;
156 | FILE *fout=stdout;
157 | int ndims=1;
158 | int dims[32];
159 | dims[0] = 1024; /*default fft size*/
160 |
161 | while (1) {
162 | int c=getopt(argc,argv,"n:iR");
163 | if (c==-1) break;
164 | switch (c) {
165 | case 'n':
166 | ndims = get_dims(optarg,dims);
167 | break;
168 | case 'i':isinverse=1;break;
169 | case 'R':isreal=1;break;
170 | case '?':
171 | fprintf(stderr,"usage options:\n"
172 | "\t-n d1[,d2,d3...]: fft dimension(s)\n"
173 | "\t-i : inverse\n"
174 | "\t-R : real input samples, not complex\n");
175 | exit (1);
176 | default:fprintf(stderr,"bad %c\n",c);break;
177 | }
178 | }
179 |
180 | if ( optind < argc ) {
181 | if (strcmp("-",argv[optind]) !=0)
182 | fin = fopen(argv[optind],"rb");
183 | ++optind;
184 | }
185 |
186 | if ( optind < argc ) {
187 | if ( strcmp("-",argv[optind]) !=0 )
188 | fout = fopen(argv[optind],"wb");
189 | ++optind;
190 | }
191 |
192 | if (ndims==1) {
193 | if (isreal)
194 | fft_file_real(fin,fout,dims[0],isinverse);
195 | else
196 | fft_file(fin,fout,dims[0],isinverse);
197 | }else{
198 | if (isreal)
199 | fft_filend_real(fin,fout,dims,ndims,isinverse);
200 | else
201 | fft_filend(fin,fout,dims,ndims,isinverse);
202 | }
203 |
204 | if (fout!=stdout) fclose(fout);
205 | if (fin!=stdin) fclose(fin);
206 |
207 | return 0;
208 | }
209 |
--------------------------------------------------------------------------------
/Builds/Linux/Makefile:
--------------------------------------------------------------------------------
1 | # Automatically generated makefile, created by the Projucer
2 | # Don't edit this file! Your changes will be overwritten when you re-save the Projucer project!
3 |
4 | # (this disables dependency generation if multiple architectures are set)
5 | DEPFLAGS := $(if $(word 2, $(TARGET_ARCH)), , -MMD)
6 |
7 | ifndef STRIP
8 | STRIP=strip
9 | endif
10 |
11 | ifndef AR
12 | AR=ar
13 | endif
14 |
15 | ifndef CONFIG
16 | CONFIG=Debug
17 | endif
18 |
19 | ifeq ($(CONFIG),Debug)
20 | JUCE_BINDIR := build
21 | JUCE_LIBDIR := build
22 | JUCE_OBJDIR := build/intermediate/Debug
23 | JUCE_OUTDIR := build
24 |
25 | ifeq ($(TARGET_ARCH),)
26 | TARGET_ARCH := -march=native
27 | endif
28 |
29 | JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DDEBUG=1 -D_DEBUG=1 -DJUCER_LINUX_MAKE_7346DA2A=1 -DJUCE_APP_VERSION=1.0.0 -DJUCE_APP_VERSION_HEX=0x10000 $(shell pkg-config --cflags alsa freetype2 libcurl x11 xext xinerama) -pthread -I../../JuceLibraryCode -I../../../../modules
30 | JUCE_CFLAGS += $(CFLAGS) $(JUCE_CPPFLAGS) $(TARGET_ARCH) -g -ggdb -fPIC -O0
31 | JUCE_CXXFLAGS += $(CXXFLAGS) $(JUCE_CFLAGS) -std=c++11
32 | JUCE_LDFLAGS += $(LDFLAGS) $(TARGET_ARCH) -L$(JUCE_BINDIR) -L$(JUCE_LIBDIR) -Wl,--no-undefined -shared -L/usr/X11R6/lib/ $(shell pkg-config --libs alsa freetype2 libcurl x11 xext xinerama) -ldl -lpthread -lrt
33 |
34 | TARGET := JuceDemoPlugin.so
35 | BLDCMD = $(CXX) -o $(JUCE_OUTDIR)/$(TARGET) $(OBJECTS) $(JUCE_LDFLAGS) $(RESOURCES) $(TARGET_ARCH)
36 | CLEANCMD = rm -rf $(JUCE_OUTDIR)/$(TARGET) $(JUCE_OBJDIR)
37 | endif
38 |
39 | ifeq ($(CONFIG),Release)
40 | JUCE_BINDIR := build
41 | JUCE_LIBDIR := build
42 | JUCE_OBJDIR := build/intermediate/Release
43 | JUCE_OUTDIR := build
44 |
45 | ifeq ($(TARGET_ARCH),)
46 | TARGET_ARCH := -march=native
47 | endif
48 |
49 | JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DNDEBUG=1 -DJUCER_LINUX_MAKE_7346DA2A=1 -DJUCE_APP_VERSION=1.0.0 -DJUCE_APP_VERSION_HEX=0x10000 $(shell pkg-config --cflags alsa freetype2 libcurl x11 xext xinerama) -pthread -I../../JuceLibraryCode -I../../../../modules
50 | JUCE_CFLAGS += $(CFLAGS) $(JUCE_CPPFLAGS) $(TARGET_ARCH) -fPIC -O3
51 | JUCE_CXXFLAGS += $(CXXFLAGS) $(JUCE_CFLAGS) -std=c++11
52 | JUCE_LDFLAGS += $(LDFLAGS) $(TARGET_ARCH) -L$(JUCE_BINDIR) -L$(JUCE_LIBDIR) -Wl,--no-undefined -shared -fvisibility=hidden -L/usr/X11R6/lib/ $(shell pkg-config --libs alsa freetype2 libcurl x11 xext xinerama) -ldl -lpthread -lrt
53 |
54 | TARGET := JuceDemoPlugin.so
55 | BLDCMD = $(CXX) -o $(JUCE_OUTDIR)/$(TARGET) $(OBJECTS) $(JUCE_LDFLAGS) $(RESOURCES) $(TARGET_ARCH)
56 | CLEANCMD = rm -rf $(JUCE_OUTDIR)/$(TARGET) $(JUCE_OBJDIR)
57 | endif
58 |
59 | OBJECTS := \
60 | $(JUCE_OBJDIR)/PluginEditor_94d4fb09.o \
61 | $(JUCE_OBJDIR)/PluginProcessor_a059e380.o \
62 | $(JUCE_OBJDIR)/juce_audio_basics_6b797ca1.o \
63 | $(JUCE_OBJDIR)/juce_audio_devices_a742c38b.o \
64 | $(JUCE_OBJDIR)/juce_audio_formats_5a29c68a.o \
65 | $(JUCE_OBJDIR)/juce_audio_plugin_client_utils_35fbf7.o \
66 | $(JUCE_OBJDIR)/juce_audio_plugin_client_VST2_fd137df.o \
67 | $(JUCE_OBJDIR)/juce_audio_processors_dea3173d.o \
68 | $(JUCE_OBJDIR)/juce_audio_utils_c7eb679f.o \
69 | $(JUCE_OBJDIR)/juce_core_75b14332.o \
70 | $(JUCE_OBJDIR)/juce_data_structures_72d3da2c.o \
71 | $(JUCE_OBJDIR)/juce_events_d2be882c.o \
72 | $(JUCE_OBJDIR)/juce_graphics_9c18891e.o \
73 | $(JUCE_OBJDIR)/juce_gui_basics_8a6da59c.o \
74 | $(JUCE_OBJDIR)/juce_gui_extra_4a026f23.o \
75 |
76 | .PHONY: clean
77 |
78 | $(JUCE_OUTDIR)/$(TARGET): check-pkg-config $(OBJECTS) $(RESOURCES)
79 | @echo Linking JuceDemoPlugin
80 | -@mkdir -p $(JUCE_BINDIR)
81 | -@mkdir -p $(JUCE_LIBDIR)
82 | -@mkdir -p $(JUCE_OUTDIR)
83 | @$(BLDCMD)
84 |
85 | check-pkg-config:
86 | @command -v pkg-config >/dev/null 2>&1 || { echo >&2 "pkg-config not installed. Please, install it."; exit 1; }
87 | @pkg-config --print-errors alsa freetype2 libcurl x11 xext xinerama
88 |
89 | clean:
90 | @echo Cleaning JuceDemoPlugin
91 | @$(CLEANCMD)
92 |
93 | strip:
94 | @echo Stripping JuceDemoPlugin
95 | -@$(STRIP) --strip-unneeded $(JUCE_OUTDIR)/$(TARGET)
96 |
97 | $(JUCE_OBJDIR)/PluginEditor_94d4fb09.o: ../../Source/PluginEditor.cpp
98 | -@mkdir -p $(JUCE_OBJDIR)
99 | @echo "Compiling PluginEditor.cpp"
100 | @$(CXX) $(JUCE_CXXFLAGS) -o "$@" -c "$<"
101 |
102 | $(JUCE_OBJDIR)/PluginProcessor_a059e380.o: ../../Source/PluginProcessor.cpp
103 | -@mkdir -p $(JUCE_OBJDIR)
104 | @echo "Compiling PluginProcessor.cpp"
105 | @$(CXX) $(JUCE_CXXFLAGS) -o "$@" -c "$<"
106 |
107 | $(JUCE_OBJDIR)/juce_audio_basics_6b797ca1.o: ../../JuceLibraryCode/juce_audio_basics.cpp
108 | -@mkdir -p $(JUCE_OBJDIR)
109 | @echo "Compiling juce_audio_basics.cpp"
110 | @$(CXX) $(JUCE_CXXFLAGS) -o "$@" -c "$<"
111 |
112 | $(JUCE_OBJDIR)/juce_audio_devices_a742c38b.o: ../../JuceLibraryCode/juce_audio_devices.cpp
113 | -@mkdir -p $(JUCE_OBJDIR)
114 | @echo "Compiling juce_audio_devices.cpp"
115 | @$(CXX) $(JUCE_CXXFLAGS) -o "$@" -c "$<"
116 |
117 | $(JUCE_OBJDIR)/juce_audio_formats_5a29c68a.o: ../../JuceLibraryCode/juce_audio_formats.cpp
118 | -@mkdir -p $(JUCE_OBJDIR)
119 | @echo "Compiling juce_audio_formats.cpp"
120 | @$(CXX) $(JUCE_CXXFLAGS) -o "$@" -c "$<"
121 |
122 | $(JUCE_OBJDIR)/juce_audio_plugin_client_utils_35fbf7.o: ../../JuceLibraryCode/juce_audio_plugin_client_utils.cpp
123 | -@mkdir -p $(JUCE_OBJDIR)
124 | @echo "Compiling juce_audio_plugin_client_utils.cpp"
125 | @$(CXX) $(JUCE_CXXFLAGS) -o "$@" -c "$<"
126 |
127 | $(JUCE_OBJDIR)/juce_audio_plugin_client_VST2_fd137df.o: ../../JuceLibraryCode/juce_audio_plugin_client_VST2.cpp
128 | -@mkdir -p $(JUCE_OBJDIR)
129 | @echo "Compiling juce_audio_plugin_client_VST2.cpp"
130 | @$(CXX) $(JUCE_CXXFLAGS) -o "$@" -c "$<"
131 |
132 | $(JUCE_OBJDIR)/juce_audio_processors_dea3173d.o: ../../JuceLibraryCode/juce_audio_processors.cpp
133 | -@mkdir -p $(JUCE_OBJDIR)
134 | @echo "Compiling juce_audio_processors.cpp"
135 | @$(CXX) $(JUCE_CXXFLAGS) -o "$@" -c "$<"
136 |
137 | $(JUCE_OBJDIR)/juce_audio_utils_c7eb679f.o: ../../JuceLibraryCode/juce_audio_utils.cpp
138 | -@mkdir -p $(JUCE_OBJDIR)
139 | @echo "Compiling juce_audio_utils.cpp"
140 | @$(CXX) $(JUCE_CXXFLAGS) -o "$@" -c "$<"
141 |
142 | $(JUCE_OBJDIR)/juce_core_75b14332.o: ../../JuceLibraryCode/juce_core.cpp
143 | -@mkdir -p $(JUCE_OBJDIR)
144 | @echo "Compiling juce_core.cpp"
145 | @$(CXX) $(JUCE_CXXFLAGS) -o "$@" -c "$<"
146 |
147 | $(JUCE_OBJDIR)/juce_data_structures_72d3da2c.o: ../../JuceLibraryCode/juce_data_structures.cpp
148 | -@mkdir -p $(JUCE_OBJDIR)
149 | @echo "Compiling juce_data_structures.cpp"
150 | @$(CXX) $(JUCE_CXXFLAGS) -o "$@" -c "$<"
151 |
152 | $(JUCE_OBJDIR)/juce_events_d2be882c.o: ../../JuceLibraryCode/juce_events.cpp
153 | -@mkdir -p $(JUCE_OBJDIR)
154 | @echo "Compiling juce_events.cpp"
155 | @$(CXX) $(JUCE_CXXFLAGS) -o "$@" -c "$<"
156 |
157 | $(JUCE_OBJDIR)/juce_graphics_9c18891e.o: ../../JuceLibraryCode/juce_graphics.cpp
158 | -@mkdir -p $(JUCE_OBJDIR)
159 | @echo "Compiling juce_graphics.cpp"
160 | @$(CXX) $(JUCE_CXXFLAGS) -o "$@" -c "$<"
161 |
162 | $(JUCE_OBJDIR)/juce_gui_basics_8a6da59c.o: ../../JuceLibraryCode/juce_gui_basics.cpp
163 | -@mkdir -p $(JUCE_OBJDIR)
164 | @echo "Compiling juce_gui_basics.cpp"
165 | @$(CXX) $(JUCE_CXXFLAGS) -o "$@" -c "$<"
166 |
167 | $(JUCE_OBJDIR)/juce_gui_extra_4a026f23.o: ../../JuceLibraryCode/juce_gui_extra.cpp
168 | -@mkdir -p $(JUCE_OBJDIR)
169 | @echo "Compiling juce_gui_extra.cpp"
170 | @$(CXX) $(JUCE_CXXFLAGS) -o "$@" -c "$<"
171 |
172 | -include $(OBJECTS:%.o=%.d)
173 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/tools/kiss_fftnd.c:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*
4 | Copyright (c) 2003-2004, Mark Borgerding
5 |
6 | All rights reserved.
7 |
8 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
9 |
10 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
11 | * 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.
12 | * 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.
13 |
14 | 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.
15 | */
16 |
17 | #include "kiss_fftnd.h"
18 | #include "_kiss_fft_guts.h"
19 |
20 | struct kiss_fftnd_state{
21 | int dimprod; /* dimsum would be mighty tasty right now */
22 | int ndims;
23 | int *dims;
24 | kiss_fft_cfg *states; /* cfg states for each dimension */
25 | kiss_fft_cpx * tmpbuf; /*buffer capable of hold the entire input */
26 | };
27 |
28 | kiss_fftnd_cfg kiss_fftnd_alloc(const int *dims,int ndims,int inverse_fft,void*mem,size_t*lenmem)
29 | {
30 | kiss_fftnd_cfg st = NULL;
31 | int i;
32 | int dimprod=1;
33 | size_t memneeded = sizeof(struct kiss_fftnd_state);
34 | char * ptr;
35 |
36 | for (i=0;istates[i] */
40 | dimprod *= dims[i];
41 | }
42 | memneeded += sizeof(int) * ndims;/* st->dims */
43 | memneeded += sizeof(void*) * ndims;/* st->states */
44 | memneeded += sizeof(kiss_fft_cpx) * dimprod; /* st->tmpbuf */
45 |
46 | if (lenmem == NULL) {/* allocate for the caller*/
47 | st = (kiss_fftnd_cfg) malloc (memneeded);
48 | } else { /* initialize supplied buffer if big enough */
49 | if (*lenmem >= memneeded)
50 | st = (kiss_fftnd_cfg) mem;
51 | *lenmem = memneeded; /*tell caller how big struct is (or would be) */
52 | }
53 | if (!st)
54 | return NULL; /*malloc failed or buffer too small */
55 |
56 | st->dimprod = dimprod;
57 | st->ndims = ndims;
58 | ptr=(char*)(st+1);
59 |
60 | st->states = (kiss_fft_cfg *)ptr;
61 | ptr += sizeof(void*) * ndims;
62 |
63 | st->dims = (int*)ptr;
64 | ptr += sizeof(int) * ndims;
65 |
66 | st->tmpbuf = (kiss_fft_cpx*)ptr;
67 | ptr += sizeof(kiss_fft_cpx) * dimprod;
68 |
69 | for (i=0;idims[i] = dims[i];
72 | kiss_fft_alloc (st->dims[i], inverse_fft, NULL, &len);
73 | st->states[i] = kiss_fft_alloc (st->dims[i], inverse_fft, ptr,&len);
74 | ptr += len;
75 | }
76 | /*
77 | Hi there!
78 |
79 | If you're looking at this particular code, it probably means you've got a brain-dead bounds checker
80 | that thinks the above code overwrites the end of the array.
81 |
82 | It doesn't.
83 |
84 | -- Mark
85 |
86 | P.S.
87 | The below code might give you some warm fuzzies and help convince you.
88 | */
89 | if ( ptr - (char*)st != (int)memneeded ) {
90 | fprintf(stderr,
91 | "################################################################################\n"
92 | "Internal error! Memory allocation miscalculation\n"
93 | "################################################################################\n"
94 | );
95 | }
96 | return st;
97 | }
98 |
99 | /*
100 | This works by tackling one dimension at a time.
101 |
102 | In effect,
103 | Each stage starts out by reshaping the matrix into a DixSi 2d matrix.
104 | A Di-sized fft is taken of each column, transposing the matrix as it goes.
105 |
106 | Here's a 3-d example:
107 | Take a 2x3x4 matrix, laid out in memory as a contiguous buffer
108 | [ [ [ a b c d ] [ e f g h ] [ i j k l ] ]
109 | [ [ m n o p ] [ q r s t ] [ u v w x ] ] ]
110 |
111 | Stage 0 ( D=2): treat the buffer as a 2x12 matrix
112 | [ [a b ... k l]
113 | [m n ... w x] ]
114 |
115 | FFT each column with size 2.
116 | Transpose the matrix at the same time using kiss_fft_stride.
117 |
118 | [ [ a+m a-m ]
119 | [ b+n b-n]
120 | ...
121 | [ k+w k-w ]
122 | [ l+x l-x ] ]
123 |
124 | Note fft([x y]) == [x+y x-y]
125 |
126 | Stage 1 ( D=3) treats the buffer (the output of stage D=2) as an 3x8 matrix,
127 | [ [ a+m a-m b+n b-n c+o c-o d+p d-p ]
128 | [ e+q e-q f+r f-r g+s g-s h+t h-t ]
129 | [ i+u i-u j+v j-v k+w k-w l+x l-x ] ]
130 |
131 | And perform FFTs (size=3) on each of the columns as above, transposing
132 | the matrix as it goes. The output of stage 1 is
133 | (Legend: ap = [ a+m e+q i+u ]
134 | am = [ a-m e-q i-u ] )
135 |
136 | [ [ sum(ap) fft(ap)[0] fft(ap)[1] ]
137 | [ sum(am) fft(am)[0] fft(am)[1] ]
138 | [ sum(bp) fft(bp)[0] fft(bp)[1] ]
139 | [ sum(bm) fft(bm)[0] fft(bm)[1] ]
140 | [ sum(cp) fft(cp)[0] fft(cp)[1] ]
141 | [ sum(cm) fft(cm)[0] fft(cm)[1] ]
142 | [ sum(dp) fft(dp)[0] fft(dp)[1] ]
143 | [ sum(dm) fft(dm)[0] fft(dm)[1] ] ]
144 |
145 | Stage 2 ( D=4) treats this buffer as a 4*6 matrix,
146 | [ [ sum(ap) fft(ap)[0] fft(ap)[1] sum(am) fft(am)[0] fft(am)[1] ]
147 | [ sum(bp) fft(bp)[0] fft(bp)[1] sum(bm) fft(bm)[0] fft(bm)[1] ]
148 | [ sum(cp) fft(cp)[0] fft(cp)[1] sum(cm) fft(cm)[0] fft(cm)[1] ]
149 | [ sum(dp) fft(dp)[0] fft(dp)[1] sum(dm) fft(dm)[0] fft(dm)[1] ] ]
150 |
151 | Then FFTs each column, transposing as it goes.
152 |
153 | The resulting matrix is the 3d FFT of the 2x3x4 input matrix.
154 |
155 | Note as a sanity check that the first element of the final
156 | stage's output (DC term) is
157 | sum( [ sum(ap) sum(bp) sum(cp) sum(dp) ] )
158 | , i.e. the summation of all 24 input elements.
159 |
160 | */
161 | void kiss_fftnd(kiss_fftnd_cfg st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout)
162 | {
163 | int i,k;
164 | const kiss_fft_cpx * bufin=fin;
165 | kiss_fft_cpx * bufout;
166 |
167 | /*arrange it so the last bufout == fout*/
168 | if ( st->ndims & 1 ) {
169 | bufout = fout;
170 | if (fin==fout) {
171 | memcpy( st->tmpbuf, fin, sizeof(kiss_fft_cpx) * st->dimprod );
172 | bufin = st->tmpbuf;
173 | }
174 | }else
175 | bufout = st->tmpbuf;
176 |
177 | for ( k=0; k < st->ndims; ++k) {
178 | int curdim = st->dims[k];
179 | int stride = st->dimprod / curdim;
180 |
181 | for ( i=0 ; istates[k], bufin+i , bufout+i*curdim, stride );
183 |
184 | /*toggle back and forth between the two buffers*/
185 | if (bufout == st->tmpbuf){
186 | bufout = fout;
187 | bufin = st->tmpbuf;
188 | }else{
189 | bufout = st->tmpbuf;
190 | bufin = fout;
191 | }
192 | }
193 | }
194 |
--------------------------------------------------------------------------------
/Source/kiss_fft130/tools/psdpng.c:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2003-2004, Mark Borgerding
3 |
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7 |
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9 | * 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.
10 | * 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.
11 |
12 | 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.
13 | */
14 |
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 | #include
21 |
22 | #include "kiss_fft.h"
23 | #include "kiss_fftr.h"
24 |
25 | int nfft=1024;
26 | FILE * fin=NULL;
27 | FILE * fout=NULL;
28 |
29 | int navg=20;
30 | int remove_dc=0;
31 | int nrows=0;
32 | float * vals=NULL;
33 | int stereo=0;
34 |
35 | static
36 | void config(int argc,char** argv)
37 | {
38 | while (1) {
39 | int c = getopt (argc, argv, "n:r:as");
40 | if (c == -1)
41 | break;
42 | switch (c) {
43 | case 'n': nfft=(int)atoi(optarg);break;
44 | case 'r': navg=(int)atoi(optarg);break;
45 | case 'a': remove_dc=1;break;
46 | case 's': stereo=1;break;
47 | case '?':
48 | fprintf (stderr, "usage options:\n"
49 | "\t-n d: fft dimension(s) [1024]\n"
50 | "\t-r d: number of rows to average [20]\n"
51 | "\t-a : remove average from each fft buffer\n"
52 | "\t-s : input is stereo, channels will be combined before fft\n"
53 | "16 bit machine format real input is assumed\n"
54 | );
55 | default:
56 | fprintf (stderr, "bad %c\n", c);
57 | exit (1);
58 | break;
59 | }
60 | }
61 | if ( optind < argc ) {
62 | if (strcmp("-",argv[optind]) !=0)
63 | fin = fopen(argv[optind],"rb");
64 | ++optind;
65 | }
66 |
67 | if ( optind < argc ) {
68 | if ( strcmp("-",argv[optind]) !=0 )
69 | fout = fopen(argv[optind],"wb");
70 | ++optind;
71 | }
72 | if (fin==NULL)
73 | fin=stdin;
74 | if (fout==NULL)
75 | fout=stdout;
76 | }
77 |
78 | #define CHECKNULL(p) if ( (p)==NULL ) do { fprintf(stderr,"CHECKNULL failed @ %s(%d): %s\n",__FILE__,__LINE__,#p );exit(1);} while(0)
79 |
80 | typedef struct
81 | {
82 | png_byte r;
83 | png_byte g;
84 | png_byte b;
85 | } rgb_t;
86 |
87 | static
88 | void val2rgb(float x,rgb_t *p)
89 | {
90 | const double pi = 3.14159265358979;
91 | p->g = (int)(255*sin(x*pi));
92 | p->r = (int)(255*abs(sin(x*pi*3/2)));
93 | p->b = (int)(255*abs(sin(x*pi*5/2)));
94 | //fprintf(stderr,"%.2f : %d,%d,%d\n",x,(int)p->r,(int)p->g,(int)p->b);
95 | }
96 |
97 | static
98 | void cpx2pixels(rgb_t * res,const float * fbuf,size_t n)
99 | {
100 | size_t i;
101 | float minval,maxval,valrange;
102 | minval=maxval=fbuf[0];
103 |
104 | for (i = 0; i < n; ++i) {
105 | if (fbuf[i] > maxval) maxval = fbuf[i];
106 | if (fbuf[i] < minval) minval = fbuf[i];
107 | }
108 |
109 | fprintf(stderr,"min ==%f,max=%f\n",minval,maxval);
110 | valrange = maxval-minval;
111 | if (valrange == 0) {
112 | fprintf(stderr,"min == max == %f\n",minval);
113 | exit (1);
114 | }
115 |
116 | for (i = 0; i < n; ++i)
117 | val2rgb( (fbuf[i] - minval)/valrange , res+i );
118 | }
119 |
120 | static
121 | void transform_signal(void)
122 | {
123 | short *inbuf;
124 | kiss_fftr_cfg cfg=NULL;
125 | kiss_fft_scalar *tbuf;
126 | kiss_fft_cpx *fbuf;
127 | float *mag2buf;
128 | int i;
129 | int n;
130 | int avgctr=0;
131 |
132 | int nfreqs=nfft/2+1;
133 |
134 | CHECKNULL( cfg=kiss_fftr_alloc(nfft,0,0,0) );
135 | CHECKNULL( inbuf=(short*)malloc(sizeof(short)*2*nfft ) );
136 | CHECKNULL( tbuf=(kiss_fft_scalar*)malloc(sizeof(kiss_fft_scalar)*nfft ) );
137 | CHECKNULL( fbuf=(kiss_fft_cpx*)malloc(sizeof(kiss_fft_cpx)*nfreqs ) );
138 | CHECKNULL( mag2buf=(float*)malloc(sizeof(float)*nfreqs ) );
139 |
140 | memset(mag2buf,0,sizeof(mag2buf)*nfreqs);
141 |
142 | while (1) {
143 | if (stereo) {
144 | n = fread(inbuf,sizeof(short)*2,nfft,fin);
145 | if (n != nfft )
146 | break;
147 | for (i=0;i= 0;)
54 | synth.addVoice (new SineWaveVoice());
55 |
56 | // ..and give the synth a sound to play
57 | synth.addSound (new SineWaveSound());
58 | }
59 |
60 | //==============================================================================
61 | void WaveGenPluginAudioProcessor::prepareToPlay (double newSampleRate, int samplesPerBlock)
62 | {
63 | // Use this method as the place to do any pre-playback
64 | // initialisation that you need..
65 | synth.setCurrentPlaybackSampleRate (newSampleRate);
66 | keyboardState.reset();
67 |
68 | if (isUsingDoublePrecision())
69 | {
70 | delayBufferDouble.setSize (2, 12000);
71 | delayBufferFloat.setSize (1, 1);
72 | }
73 | else
74 | {
75 | delayBufferFloat.setSize (2, 12000);
76 | delayBufferDouble.setSize (1, 1);
77 | }
78 |
79 | //
80 | myFFT.prepareToPlay(newSampleRate, samplesPerBlock);
81 |
82 | reset();
83 | }
84 |
85 | void WaveGenPluginAudioProcessor::releaseResources()
86 | {
87 | // When playback stops, you can use this as an opportunity to free up any
88 | // spare memory, etc.
89 | keyboardState.reset();
90 | }
91 |
92 | void WaveGenPluginAudioProcessor::reset()
93 | {
94 | // Use this method as the place to clear any delay lines, buffers, etc, as it
95 | // means there's been a break in the audio's continuity.
96 | delayBufferFloat.clear();
97 | delayBufferDouble.clear();
98 | }
99 |
100 | template
101 | void WaveGenPluginAudioProcessor::process (AudioBuffer& buffer,
102 | MidiBuffer& midiMessages,
103 | AudioBuffer& delayBuffer)
104 | {
105 | const int numSamples = buffer.getNumSamples();
106 |
107 | // Now pass any incoming midi messages to our keyboard state object, and let it
108 | // add messages to the buffer if the user is clicking on the on-screen keys
109 | keyboardState.processNextMidiBuffer (midiMessages, 0, numSamples, true);
110 |
111 | // and now get our synth to process these midi events and generate its output.
112 | synth.renderNextBlock (buffer, midiMessages, 0, numSamples);
113 |
114 | // Apply our delay effect to the new output..
115 | // applyDelay (buffer, delayBuffer);
116 |
117 | // In case we have more outputs than inputs, we'll clear any output
118 | // channels that didn't contain input data, (because these aren't
119 | // guaranteed to be empty - they may contain garbage).
120 | for (int i = getTotalNumInputChannels(); i < getTotalNumOutputChannels(); ++i)
121 | buffer.clear (i, 0, numSamples);
122 |
123 | // Now ask the host for the current time so we can store it to be displayed later...
124 | updateCurrentTimeInfoFromHost();
125 |
126 | // get the FFT ::::
127 | myFFT.processBlock(buffer, midiMessages);
128 |
129 | if (currentOutput.getNumSamples() < numSamples)
130 | currentOutput.setSize(2, numSamples);
131 |
132 | // for VIEWING ::::
133 | // Since the FFT and FFT-UI are currently written for float only
134 | // we have an ungainly copy function here ...
135 | for (int i=0; i < numSamples; i++)
136 | {
137 | float sample = buffer.getSample(0, i);
138 | currentOutput.setSample(0, i, sample);
139 | }
140 |
141 |
142 | }
143 |
144 |
145 | void WaveGenPluginAudioProcessor::updateCurrentTimeInfoFromHost()
146 | {
147 | if (AudioPlayHead* ph = getPlayHead())
148 | {
149 | AudioPlayHead::CurrentPositionInfo newTime;
150 |
151 | if (ph->getCurrentPosition (newTime))
152 | {
153 | lastPosInfo = newTime; // Successfully got the current time from the host..
154 | return;
155 | }
156 | }
157 |
158 | // If the host fails to provide the current time, we'll just reset our copy to a default..
159 | lastPosInfo.resetToDefault();
160 | }
161 |
162 | //==============================================================================
163 | AudioProcessorEditor* WaveGenPluginAudioProcessor::createEditor()
164 | {
165 | return new WaveGenPluginAudioProcessorEditor (*this);
166 | }
167 |
168 | //==============================================================================
169 | void WaveGenPluginAudioProcessor::getStateInformation (MemoryBlock& destData)
170 | {
171 | // You should use this method to store your parameters in the memory block.
172 | // Here's an example of how you can use XML to make it easy and more robust:
173 |
174 | // Create an outer XML element..
175 | XmlElement xml ("MYPLUGINSETTINGS");
176 |
177 | // add some attributes to it..
178 | xml.setAttribute ("uiWidth", lastUIWidth);
179 | xml.setAttribute ("uiHeight", lastUIHeight);
180 |
181 | // Store the values of all our parameters, using their param ID as the XML attribute
182 | for (int i = 0; i < getNumParameters(); ++i)
183 | if (AudioProcessorParameterWithID* p = dynamic_cast (getParameters().getUnchecked(i)))
184 | xml.setAttribute (p->paramID, p->getValue());
185 |
186 | // then use this helper function to stuff it into the binary blob and return it..
187 | copyXmlToBinary (xml, destData);
188 | }
189 |
190 | void WaveGenPluginAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
191 | {
192 | // You should use this method to restore your parameters from this memory block,
193 | // whose contents will have been created by the getStateInformation() call.
194 |
195 | // This getXmlFromBinary() helper function retrieves our XML from the binary blob..
196 | ScopedPointer xmlState (getXmlFromBinary (data, sizeInBytes));
197 |
198 | if (xmlState != nullptr)
199 | {
200 | // make sure that it's actually our type of XML object..
201 | if (xmlState->hasTagName ("MYPLUGINSETTINGS"))
202 | {
203 | // ok, now pull out our last window size..
204 | lastUIWidth = jmax (xmlState->getIntAttribute ("uiWidth", lastUIWidth), 400);
205 | lastUIHeight = jmax (xmlState->getIntAttribute ("uiHeight", lastUIHeight), 200);
206 |
207 | // Now reload our parameters..
208 | for (int i = 0; i < getNumParameters(); ++i)
209 | if (AudioProcessorParameterWithID* p = dynamic_cast (getParameters().getUnchecked(i)))
210 | p->setValueNotifyingHost ((float) xmlState->getDoubleAttribute (p->paramID, p->getValue()));
211 | }
212 | }
213 | }
214 |
215 | //==============================================================================
216 | // This creates new instances of the plugin..
217 | AudioProcessor* JUCE_CALLTYPE createPluginFilter()
218 | {
219 | return new WaveGenPluginAudioProcessor();
220 | }
221 |
--------------------------------------------------------------------------------