{"id":16985671,"url":"https://github.com/sinshu/fftflat","last_synced_at":"2025-07-30T14:40:10.216Z","repository":{"id":202695923,"uuid":"707631759","full_name":"sinshu/fftflat","owner":"sinshu","description":"A fast FFT implementation in pure C#","archived":false,"fork":false,"pushed_at":"2024-12-02T00:48:56.000Z","size":202,"stargazers_count":18,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-18T13:15:17.733Z","etag":null,"topics":["audio","dsp","fft","math","numerics"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sinshu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-20T10:12:11.000Z","updated_at":"2025-03-06T09:43:58.000Z","dependencies_parsed_at":"2023-12-23T04:22:42.900Z","dependency_job_id":"4043aa04-ff46-4e41-9675-53c170ac3aa1","html_url":"https://github.com/sinshu/fftflat","commit_stats":null,"previous_names":["sinshu/fftflat"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinshu%2Ffftflat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinshu%2Ffftflat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinshu%2Ffftflat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinshu%2Ffftflat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sinshu","download_url":"https://codeload.github.com/sinshu/fftflat/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244978430,"owners_count":20541854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","dsp","fft","math","numerics"],"created_at":"2024-10-14T02:43:58.194Z","updated_at":"2025-03-22T15:30:48.564Z","avatar_url":"https://github.com/sinshu.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FftFlat\n\nThe purpose of this library is to provide a fast FFT (Fast Fourier Transform) implementation, entirely in pure C#.\nThis library is adapted from [General Purpose FFT Package by Ooura](https://www.kurims.kyoto-u.ac.jp/~ooura/fft.html),\nmodified to be compatible with the .NET Standard complex number type.\n\n\u003e [!NOTE]\n\u003e This library was created as an FFT implementation for [NumFlat](https://github.com/sinshu/numflat),\n\u003e a general purpose numerical computing library written in pure C#.\n\u003e If you're interested in numerical computing with C#, please check out [NumFlat](https://github.com/sinshu/numflat).\n\n\n\n## Features\n\n* __Fast:__ More than four times as fast as the managed FFT implementation in Math.NET Numerics.\n* __Lightweight:__ Small code size, with no dependencies other than .NET Standard 2.1.\n\n\n\n## Installation\n\n[The NuGet package](https://www.nuget.org/packages/FftFlat) is available:\n\n```ps1\nInstall-Package FftFlat\n```\n\nIf you don't want to add a DLL, copy [the .cs files](https://github.com/sinshu/fftflat/tree/main/FftFlat) to your project.\n\n\n\n## Usage\n\nFirst, add a `using` statement for the `FftFlat` namespace.\n\n```cs\nusing FftFlat;\n```\n\nTo perform FFT or IFFT, create an instance of `FastFourierTransform` and call the appropriate method.\n\n```cs\nvar samples = new Complex[1024];\nsamples[0] = 1;\n\nvar fft = new FastFourierTransform(1024);\nfft.Forward(samples);\n```\n\n\n\n## Important Notices\n\nOoura's original FFT implementation is based on a different definition from that used in Math.NET Numerics. FFtFlat adjusts this difference, ensuring its results match those of [Math.NET Numerics' FFT](https://numerics.mathdotnet.com/api/MathNet.Numerics.IntegralTransforms/Fourier.htm).\n\nNormalization is only done during the IFFT.\nThis is similar to using `FourierOptions.AsymmetricScaling` for FFT in Math.NET Numerics.\n\nNote that the `FastFourierTransform` object is not thread-safe.\nIf performing FFT across multiple threads, ensure a separate instance is provided for each thread.\n\n\n\n## Demo\n\nIn this demo video, the spectrum is visualized in real-time as sound is played using `AudioStream` of [RayLib-CsLo](https://github.com/NotNotTech/Raylib-CsLo).\n\nhttps://www.youtube.com/watch?v=KTpG_z_ejZ0  \n\n[![Demo video](https://img.youtube.com/vi/KTpG_z_ejZ0/0.jpg)](https://www.youtube.com/watch?v=KTpG_z_ejZ0)\n\n\n\n## Performance\n\nThe following is a benchmark comparing this with other pure C# FFT implementations.\nIn this benchmark, the time taken to perform FFT and IFFT on a random signal was measured.\nThe FFT lengths used were powers of two, ranging from 256 to 8192.\n\n### Complex FFT\n\n| Method   | Length | Mean         | Error     | StdDev    | Median       | Allocated |\n|--------- |------- |-------------:|----------:|----------:|-------------:|----------:|\n| FftFlat  | 2048   |    17.664 μs | 0.0444 μs | 0.0415 μs |    17.664 μs |         - |\n| FftSharp | 2048   |   203.196 μs | 0.6797 μs | 0.6358 μs |   203.137 μs |         - |\n| MathNet  | 2048   |    71.875 μs | 0.5197 μs | 0.4340 μs |    71.836 μs |   25660 B |\n| FftFlat  | 4096   |    36.990 μs | 0.2119 μs | 0.1983 μs |    37.014 μs |         - |\n| FftSharp | 4096   |   439.636 μs | 1.4182 μs | 1.3265 μs |   439.750 μs |         - |\n| MathNet  | 4096   |   157.341 μs | 0.6241 μs | 0.5211 μs |   157.270 μs |   33650 B |\n| FftFlat  | 8192   |    83.777 μs | 0.1272 μs | 0.1128 μs |    83.769 μs |         - |\n| FftSharp | 8192   |   954.118 μs | 2.7325 μs | 2.5560 μs |   953.749 μs |         - |\n| MathNet  | 8192   |   343.381 μs | 5.1914 μs | 4.8561 μs |   339.598 μs |   47481 B |\n\n![A graphical plot of the table above.](plot_cfft.png)\n\n### Real FFT\n\n| Method   | Length | Mean         | Error     | StdDev    | Median       | Allocated |\n|--------- |------- |-------------:|----------:|----------:|-------------:|----------:|\n| FftFlat  | 2048   |    10.303 μs | 0.0359 μs | 0.0336 μs |    10.296 μs |         - |\n| FftSharp | 2048   |   208.290 μs | 0.6072 μs | 0.5679 μs |   208.354 μs |   98416 B |\n| MathNet  | 2048   |    77.546 μs | 0.5357 μs | 0.4749 μs |    77.576 μs |   90663 B |\n| FftFlat  | 4096   |    22.647 μs | 0.1032 μs | 0.0966 μs |    22.640 μs |         - |\n| FftSharp | 4096   |   454.185 μs | 1.5450 μs | 1.4452 μs |   454.305 μs |  196720 B |\n| MathNet  | 4096   |   179.540 μs | 1.2277 μs | 1.1484 μs |   179.667 μs |  165035 B |\n| FftFlat  | 8192   |    47.374 μs | 0.2011 μs | 0.1881 μs |    47.337 μs |         - |\n| FftSharp | 8192   | 1,034.310 μs | 3.5584 μs | 3.1544 μs | 1,034.975 μs |  393356 B |\n| MathNet  | 8192   |   417.383 μs | 0.5965 μs | 0.5288 μs |   417.317 μs |  309285 B |\n\n![A graphical plot of the table above.](plot_rfft.png)\n\n\n\n## Todo\n\n* ✅ FFT for power-of-two length samples\n* ✅ Real FFT\n* ⬜ Other transformations (such as cosine transform)\n* ⬜ Support for 32-bit floating-point numbers\n* ⬜ FFT for arbitrary length samples\n\n\n\n## License\n\nFftFlat is available under [the MIT license](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinshu%2Ffftflat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsinshu%2Ffftflat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinshu%2Ffftflat/lists"}