diff --git a/Cargo.lock b/Cargo.lock
index 43985861..a6d0b4a7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -47,22 +47,13 @@ dependencies = [
"version_check",
]
-[[package]]
-name = "aho-corasick"
-version = "0.5.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66"
-dependencies = [
- "memchr 0.1.11",
-]
-
[[package]]
name = "aho-corasick"
version = "0.7.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
dependencies = [
- "memchr 2.4.1",
+ "memchr",
]
[[package]]
@@ -196,7 +187,7 @@ dependencies = [
"slab",
"socket2",
"waker-fn",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -242,7 +233,7 @@ dependencies = [
"libc",
"once_cell",
"signal-hook",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -264,7 +255,7 @@ dependencies = [
"gloo-timers",
"kv-log-macro",
"log",
- "memchr 2.4.1",
+ "memchr",
"num_cpus",
"once_cell",
"pin-project-lite",
@@ -321,7 +312,7 @@ dependencies = [
"objc",
"raw-window-handle",
"uuid",
- "winapi 0.3.9",
+ "winapi",
"x11",
"xcb 0.9.0",
"xcb-util",
@@ -339,7 +330,7 @@ dependencies = [
"objc",
"raw-window-handle",
"uuid",
- "winapi 0.3.9",
+ "winapi",
"x11",
"xcb 0.9.0",
"xcb-util",
@@ -418,27 +409,6 @@ version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
-[[package]]
-name = "bzip2"
-version = "0.4.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6afcd980b5f3a45017c57e57a2fcccbb351cc43a356ce117ef760ef8052b89b0"
-dependencies = [
- "bzip2-sys",
- "libc",
-]
-
-[[package]]
-name = "bzip2-sys"
-version = "0.1.11+1.0.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc"
-dependencies = [
- "cc",
- "libc",
- "pkg-config",
-]
-
[[package]]
name = "cache-padded"
version = "1.2.0"
@@ -482,16 +452,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17cc5e6b5ab06331c33589842070416baa137e8b0eb912b008cfd4a78ada7919"
-[[package]]
-name = "chrono"
-version = "0.2.25"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9213f7cd7c27e95c2b57c49f0e69b1ea65b27138da84a170133fd21b07659c00"
-dependencies = [
- "num",
- "time",
-]
-
[[package]]
name = "clap-sys"
version = "0.23.0"
@@ -504,7 +464,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fdf5e01086b6be750428ba4a40619f847eb2e95756eee84b18e06e5f0b50342"
dependencies = [
"lazy-bytes-cast",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -706,7 +666,7 @@ dependencies = [
"autocfg",
"cfg-if 1.0.0",
"crossbeam-utils",
- "lazy_static 1.4.0",
+ "lazy_static",
"memoffset",
"scopeguard",
]
@@ -728,7 +688,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38"
dependencies = [
"cfg-if 1.0.0",
- "lazy_static 1.4.0",
+ "lazy_static",
]
[[package]]
@@ -782,7 +742,7 @@ checksum = "2daefd788d1e96e0a9d66dee4b828b883509bc3ea9ce30665f04c3246372690c"
dependencies = [
"bitflags",
"libloading",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -817,9 +777,9 @@ dependencies = [
name = "diopser"
version = "0.1.0"
dependencies = [
- "fftw",
"nih_plug",
"nih_plug_vizia",
+ "realfft",
"triple_buffer",
]
@@ -841,7 +801,7 @@ checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
dependencies = [
"libc",
"redox_users",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -880,9 +840,9 @@ version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439a1c2ba5611ad3ed731280541d36d2e9c4ac5e7fb818a27b604bdc5a6aa65b"
dependencies = [
- "lazy_static 1.4.0",
+ "lazy_static",
"libc",
- "winapi 0.3.9",
+ "winapi",
"wio",
]
@@ -992,45 +952,6 @@ dependencies = [
"web-sys",
]
-[[package]]
-name = "fftw"
-version = "0.7.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9dc6a84bbb6bac64521bfb5a544701ce118f329d550cf9b9054d1954fe61adef"
-dependencies = [
- "bitflags",
- "fftw-sys",
- "lazy_static 1.4.0",
- "ndarray",
- "num-complex 0.3.1",
- "num-traits",
- "thiserror",
-]
-
-[[package]]
-name = "fftw-src"
-version = "0.3.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c08962470ab0e91e74ec7d338c8731476c28ed4e503a3080b0f001692e395a7c"
-dependencies = [
- "anyhow",
- "cc",
- "fs_extra",
- "ftp",
- "zip",
-]
-
-[[package]]
-name = "fftw-sys"
-version = "0.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e8e3951d695cc2f17610cd041e87ebc15078d1af5eb8c6be77921381fc98b3fd"
-dependencies = [
- "fftw-src",
- "libc",
- "num-complex 0.3.1",
-]
-
[[package]]
name = "flate2"
version = "1.0.22"
@@ -1119,14 +1040,14 @@ dependencies = [
"dwrote",
"float-ord",
"freetype",
- "lazy_static 1.4.0",
+ "lazy_static",
"libc",
"log",
"pathfinder_geometry",
"pathfinder_simd",
"servo-fontconfig",
"walkdir",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -1176,23 +1097,6 @@ dependencies = [
"pkg-config",
]
-[[package]]
-name = "fs_extra"
-version = "1.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394"
-
-[[package]]
-name = "ftp"
-version = "3.0.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "542951aad0071952c27409e3bd7cb62d1a3ad419c4e7314106bf994e0083ad5d"
-dependencies = [
- "chrono",
- "lazy_static 0.1.16",
- "regex 0.1.80",
-]
-
[[package]]
name = "futures"
version = "0.3.21"
@@ -1251,7 +1155,7 @@ dependencies = [
"fastrand",
"futures-core",
"futures-io",
- "memchr 2.4.1",
+ "memchr",
"parking",
"pin-project-lite",
"waker-fn",
@@ -1292,7 +1196,7 @@ dependencies = [
"futures-macro",
"futures-sink",
"futures-task",
- "memchr 2.4.1",
+ "memchr",
"pin-project-lite",
"pin-utils",
"slab",
@@ -1812,16 +1716,6 @@ dependencies = [
"mutate_once",
]
-[[package]]
-name = "kernel32-sys"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
-dependencies = [
- "winapi 0.2.8",
- "winapi-build",
-]
-
[[package]]
name = "keyboard-types"
version = "0.6.2"
@@ -1871,12 +1765,6 @@ version = "5.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10257499f089cd156ad82d0a9cd57d9501fa2c989068992a97eb3c27836f206b"
-[[package]]
-name = "lazy_static"
-version = "0.1.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cf186d1a8aa5f5bee5fd662bc9c1b949e0259e1bcc379d1f006847b0080c7417"
-
[[package]]
name = "lazy_static"
version = "1.4.0"
@@ -1896,7 +1784,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd"
dependencies = [
"cfg-if 1.0.0",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -1911,11 +1799,11 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d2c35b16f4483f6c26f0e4e9550717a2f6575bcd6f12a53ff0c490a94a6934"
dependencies = [
- "lazy_static 1.4.0",
+ "lazy_static",
"objc",
"objc-foundation",
- "regex 1.5.5",
- "winapi 0.3.9",
+ "regex",
+ "winapi",
]
[[package]]
@@ -2008,24 +1896,6 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
-[[package]]
-name = "matrixmultiply"
-version = "0.2.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "916806ba0031cd542105d916a97c8572e1fa6dd79c9c51e7eb43a09ec2dd84c1"
-dependencies = [
- "rawpointer",
-]
-
-[[package]]
-name = "memchr"
-version = "0.1.11"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20"
-dependencies = [
- "libc",
-]
-
[[package]]
name = "memchr"
version = "2.4.1"
@@ -2131,19 +2001,6 @@ dependencies = [
"thiserror",
]
-[[package]]
-name = "ndarray"
-version = "0.14.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6c0d5c9540a691d153064dc47a4db2504587a75eae07bf1d73f7a596ebc73c04"
-dependencies = [
- "matrixmultiply",
- "num-complex 0.3.1",
- "num-integer",
- "num-traits",
- "rawpointer",
-]
-
[[package]]
name = "nih_plug"
version = "0.0.0"
@@ -2155,7 +2012,7 @@ dependencies = [
"cfg-if 1.0.0",
"clap-sys",
"crossbeam",
- "lazy_static 1.4.0",
+ "lazy_static",
"nih_plug_derive",
"parking_lot 0.12.0",
"raw-window-handle",
@@ -2187,7 +2044,7 @@ dependencies = [
"crossbeam",
"egui",
"egui-baseview",
- "lazy_static 1.4.0",
+ "lazy_static",
"nih_plug",
"parking_lot 0.12.0",
]
@@ -2252,30 +2109,10 @@ version = "7.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36"
dependencies = [
- "memchr 2.4.1",
+ "memchr",
"minimal-lexical",
]
-[[package]]
-name = "num"
-version = "0.1.42"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e"
-dependencies = [
- "num-integer",
- "num-iter",
- "num-traits",
-]
-
-[[package]]
-name = "num-complex"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "747d632c0c558b87dbabbe6a82f3b4ae03720d0646ac5b7b4dae89394be5f2c5"
-dependencies = [
- "num-traits",
-]
-
[[package]]
name = "num-complex"
version = "0.4.0"
@@ -2496,7 +2333,7 @@ dependencies = [
"libc",
"redox_syscall",
"smallvec",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -2658,7 +2495,7 @@ dependencies = [
"libc",
"log",
"wepoll-ffi",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -2744,7 +2581,7 @@ version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8533f14c8382aaad0d592c812ac3b826162128b65662331e1127b45c3d18536b"
dependencies = [
- "memchr 2.4.1",
+ "memchr",
]
[[package]]
@@ -2852,12 +2689,6 @@ dependencies = [
"cty",
]
-[[package]]
-name = "rawpointer"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
-
[[package]]
name = "rayon"
version = "1.5.1"
@@ -2879,7 +2710,7 @@ dependencies = [
"crossbeam-channel",
"crossbeam-deque",
"crossbeam-utils",
- "lazy_static 1.4.0",
+ "lazy_static",
"num_cpus",
]
@@ -2924,20 +2755,7 @@ version = "0.1.3"
source = "git+https://github.com/nicokoch/reflink?rev=e8d93b465f5d9ad340cd052b64bbc77b8ee107e2#e8d93b465f5d9ad340cd052b64bbc77b8ee107e2"
dependencies = [
"libc",
- "winapi 0.3.9",
-]
-
-[[package]]
-name = "regex"
-version = "0.1.80"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f"
-dependencies = [
- "aho-corasick 0.5.3",
- "memchr 0.1.11",
- "regex-syntax 0.3.9",
- "thread_local",
- "utf8-ranges",
+ "winapi",
]
[[package]]
@@ -2946,17 +2764,11 @@ version = "1.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
dependencies = [
- "aho-corasick 0.7.18",
- "memchr 2.4.1",
- "regex-syntax 0.6.25",
+ "aho-corasick",
+ "memchr",
+ "regex-syntax",
]
-[[package]]
-name = "regex-syntax"
-version = "0.3.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957"
-
[[package]]
name = "regex-syntax"
version = "0.6.25"
@@ -3024,7 +2836,7 @@ version = "6.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1d089e5c57521629a59f5f39bca7434849ff89bd6873b521afe389c1c602543"
dependencies = [
- "num-complex 0.4.0",
+ "num-complex",
"num-integer",
"num-traits",
"primal-check",
@@ -3275,7 +3087,7 @@ checksum = "1325f292209cee78d5035530932422a30aa4c8fda1a16593ac083c1de211e68a"
dependencies = [
"bitflags",
"dlib",
- "lazy_static 1.4.0",
+ "lazy_static",
"log",
"memmap2",
"nix",
@@ -3320,7 +3132,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0"
dependencies = [
"libc",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -3424,35 +3236,6 @@ dependencies = [
"syn",
]
-[[package]]
-name = "thread-id"
-version = "2.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03"
-dependencies = [
- "kernel32-sys",
- "libc",
-]
-
-[[package]]
-name = "thread_local"
-version = "0.2.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5"
-dependencies = [
- "thread-id",
-]
-
-[[package]]
-name = "time"
-version = "0.1.43"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438"
-dependencies = [
- "libc",
- "winapi 0.3.9",
-]
-
[[package]]
name = "tiny-skia"
version = "0.6.3"
@@ -3648,12 +3431,6 @@ dependencies = [
"xmlwriter",
]
-[[package]]
-name = "utf8-ranges"
-version = "0.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f"
-
[[package]]
name = "uuid"
version = "0.8.2"
@@ -3783,7 +3560,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56"
dependencies = [
"same-file",
- "winapi 0.3.9",
+ "winapi",
"winapi-util",
]
@@ -3816,7 +3593,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca"
dependencies = [
"bumpalo",
- "lazy_static 1.4.0",
+ "lazy_static",
"log",
"proc-macro2",
"quote",
@@ -3949,7 +3726,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9341df79a8975679188e37dab3889bfa57c44ac2cb6da166f519a81cbe452d4"
dependencies = [
"dlib",
- "lazy_static 1.4.0",
+ "lazy_static",
"pkg-config",
]
@@ -4057,7 +3834,7 @@ dependencies = [
"wasm-bindgen",
"web-sys",
"wgpu-types",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -4087,12 +3864,6 @@ version = "1.0.0-beta.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6f1efe828a707edf85994a4501734ac1c1b9d244cfcf4de235f11c4125ace8f"
-[[package]]
-name = "winapi"
-version = "0.2.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
-
[[package]]
name = "winapi"
version = "0.3.9"
@@ -4103,12 +3874,6 @@ dependencies = [
"winapi-x86_64-pc-windows-gnu",
]
-[[package]]
-name = "winapi-build"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
-
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
@@ -4121,7 +3886,7 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -4192,7 +3957,7 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5"
dependencies = [
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -4285,17 +4050,3 @@ version = "0.1.0"
dependencies = [
"nih_plug_xtask",
]
-
-[[package]]
-name = "zip"
-version = "0.5.13"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "93ab48844d61251bb3835145c521d88aa4031d7139e8485990f60ca911fa0815"
-dependencies = [
- "byteorder",
- "bzip2",
- "crc32fast",
- "flate2",
- "thiserror",
- "time",
-]
diff --git a/plugins/diopser/Cargo.toml b/plugins/diopser/Cargo.toml
index e0b01922..c429367c 100644
--- a/plugins/diopser/Cargo.toml
+++ b/plugins/diopser/Cargo.toml
@@ -19,5 +19,5 @@ nih_plug = { path = "../../", features = ["assert_process_allocs"] }
nih_plug_vizia = { path = "../../nih_plug_vizia" }
# For the GUI
-fftw = "0.7"
+realfft = "3.0"
triple_buffer = "6.0"
diff --git a/plugins/diopser/src/spectrum.rs b/plugins/diopser/src/spectrum.rs
index 469499be..083838b1 100644
--- a/plugins/diopser/src/spectrum.rs
+++ b/plugins/diopser/src/spectrum.rs
@@ -14,11 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use fftw::array::AlignedVec;
-use fftw::plan::{R2CPlan, R2CPlan32};
-use fftw::types::{c32, Flag};
use nih_plug::prelude::*;
+use realfft::num_complex::Complex32;
+use realfft::{RealFftPlanner, RealToComplex};
use std::f32;
+use std::sync::Arc;
use triple_buffer::TripleBuffer;
pub const SPECTRUM_WINDOW_SIZE: usize = 2048;
@@ -43,24 +43,15 @@ pub struct SpectrumInput {
/// A scratch buffer to compute the resulting power amplitude spectrum.
spectrum_result_buffer: Spectrum,
- /// The algorithm for the FFT operation.
- plan: Plan,
+ /// The algorithm for the FFT operation used for our spectrum analyzer.
+ plan: Arc>,
/// A Hann window window, passed to the STFT helper. The gain compensation is already part of
/// this window to save a multiplication step.
compensated_window_function: Vec,
- /// Scratch buffers for computing our FFT. The [`StftHelper`] already contains a buffer for the
- /// real values.
- complex_fft_scratch_buffer: AlignedVec,
+ /// The output of our real->complex FFT.
+ complex_fft_buffer: Vec,
}
-/// FFTW uses raw pointers which aren't Send+Sync, so we'll wrap this in a separate struct.
-struct Plan {
- r2c_plan: R2CPlan32,
-}
-
-unsafe impl Send for Plan {}
-unsafe impl Sync for Plan {}
-
impl SpectrumInput {
/// Create a new spectrum input and output pair. The output should be moved to the editor.
pub fn new(num_channels: usize) -> (SpectrumInput, SpectrumOutput) {
@@ -74,19 +65,13 @@ impl SpectrumInput {
triple_buffer_input,
spectrum_result_buffer: [0.0; SPECTRUM_WINDOW_SIZE / 2],
- plan: Plan {
- r2c_plan: R2CPlan32::aligned(
- &[SPECTRUM_WINDOW_SIZE],
- Flag::MEASURE | Flag::DESTROYINPUT,
- )
- .unwrap(),
- },
+ plan: RealFftPlanner::new().plan_fft_forward(SPECTRUM_WINDOW_SIZE),
compensated_window_function: util::window::hann(SPECTRUM_WINDOW_SIZE)
.into_iter()
// Include the gain compensation in the window function to save some multiplications
.map(|x| x / SPECTRUM_WINDOW_SIZE as f32)
.collect(),
- complex_fft_scratch_buffer: AlignedVec::new(SPECTRUM_WINDOW_SIZE / 2 + 1),
+ complex_fft_buffer: vec![Complex32::default(); SPECTRUM_WINDOW_SIZE / 2 + 1],
};
(input, triple_buffer_output)
@@ -101,10 +86,11 @@ impl SpectrumInput {
|channel_idx, real_fft_scratch_buffer| {
// Forward FFT, the helper has already applied window function
self.plan
- .r2c_plan
- .r2c(
+ .process_with_scratch(
real_fft_scratch_buffer,
- &mut self.complex_fft_scratch_buffer,
+ &mut self.complex_fft_buffer,
+ // We don't actually need a scratch buffer
+ &mut [],
)
.unwrap();
@@ -113,7 +99,7 @@ impl SpectrumInput {
// Gain compensation has already been baked into the window function.
if channel_idx == 0 {
for (bin, spectrum_result) in self
- .complex_fft_scratch_buffer
+ .complex_fft_buffer
.iter()
// We don't care about the DC bin
.skip(1)
@@ -123,7 +109,7 @@ impl SpectrumInput {
}
} else {
for (bin, spectrum_result) in self
- .complex_fft_scratch_buffer
+ .complex_fft_buffer
.iter()
.skip(1)
.zip(&mut self.spectrum_result_buffer)