{"id":6588,"date":"2025-02-21T12:12:31","date_gmt":"2025-02-21T11:12:31","guid":{"rendered":"https:\/\/www.pschatzmann.ch\/home\/?p=6588"},"modified":"2025-03-04T17:16:10","modified_gmt":"2025-03-04T16:16:10","slug":"reverse-fft","status":"publish","type":"post","link":"https:\/\/www.pschatzmann.ch\/home\/2025\/02\/21\/reverse-fft\/","title":{"rendered":"Using Inverse FFT to generate Audio"},"content":{"rendered":"<p>So far I was using the <strong>Fast Fourier Transform (FFT)<\/strong> functionality of my <a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-tools\">&#8220;Arduino Audio Tools Library&#8221;<\/a> for analyzing the audio. This week I spent some time to make sure that we also support the inverse FFT properly.<\/p>\n<p>The <strong>inverse FFT<\/strong> is generating <strong>audio samples<\/strong> in the time domain <strong>from the spektrum information<\/strong>. This functionality is executed automatically when we read the data from the fft source: The spektrum information can be set in the callback.<\/p>\n<p>My implementation also supports a stride and a window function: In this case the samples are combined using the overlap add method.<\/p>\n<p>The output is automatically scaled, therefore the max input values are not really important. In the example we just use 1.0.<\/p>\n<p>Here is an example that generates a tone across the full spektrum:<\/p>\n<pre><code>#include \"AudioTools.h\"\n#include \"AudioTools\/AudioLibs\/AudioRealFFT.h\" \/\/ using RealFFT\n\nAudioInfo info(44100, 2, 16);\nAudioRealFFT afft; \/\/ or AudioKissFFT\n\/\/CsvOutput&lt;int16_t&gt; out(Serial);\nI2SStream out;\nStreamCopy copier(out, afft);\nint bin_idx = 0;\n\n\/\/ provide fft frequency\nvoid fftSelectFrequencies(AudioFFTBase &amp;fft) {\n  fft.clearBins();\n  FFTBin bin{1.0f,1.0f};\n  fft.setBin(bin_idx, bin);\n\n  \/\/ increase bin: restart from first bin\n  if (++bin_idx&gt;=fft.size()) bin_idx = 0;\n}\n\nvoid setup() {\n  AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);\n\n  \/\/ Setup FFT\n  auto tcfg = afft.defaultConfig(RX_MODE);\n  tcfg.copyFrom(info);\n  tcfg.length = 1024;\n  tcfg.callback = fftSelectFrequencies;\n  afft.begin(tcfg);\n\n  \/\/ setup output\n  auto ocfg = out.defaultConfig(TX_MODE);\n  ocfg.copyFrom(info);\n  out.begin(ocfg);\n}\n\nvoid loop() { copier.copy(); }\n\n<\/code><\/pre>\n<h2>Dependencies<\/h2>\n<ul>\n<li>https:\/\/github.com\/pschatzmann\/arduino-audio-tools<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>So far I was using the Fast Fourier Transform (FFT) functionality of my &#8220;Arduino Audio Tools Library&#8221; for analyzing the audio. This week I spent some time to make sure that we also support the inverse FFT properly. The inverse FFT is generating audio samples in the time domain from [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[20,22],"tags":[39],"class_list":["post-6588","post","type-post","status-publish","format-standard","hentry","category-arduino","category-machine-sound","tag-fft"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Using Inverse FFT to generate Audio - Phil Schatzmann<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pschatzmann.ch\/home\/2025\/02\/21\/reverse-fft\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using Inverse FFT to generate Audio - Phil Schatzmann\" \/>\n<meta property=\"og:description\" content=\"So far I was using the Fast Fourier Transform (FFT) functionality of my &#8220;Arduino Audio Tools Library&#8221; for analyzing the audio. This week I spent some time to make sure that we also support the inverse FFT properly. The inverse FFT is generating audio samples in the time domain from [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pschatzmann.ch\/home\/2025\/02\/21\/reverse-fft\/\" \/>\n<meta property=\"og:site_name\" content=\"Phil Schatzmann\" \/>\n<meta property=\"article:published_time\" content=\"2025-02-21T11:12:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-03-04T16:16:10+00:00\" \/>\n<meta name=\"author\" content=\"pschatzmann\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"pschatzmann\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/02\\\/21\\\/reverse-fft\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/02\\\/21\\\/reverse-fft\\\/\"},\"author\":{\"name\":\"pschatzmann\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"headline\":\"Using Inverse FFT to generate Audio\",\"datePublished\":\"2025-02-21T11:12:31+00:00\",\"dateModified\":\"2025-03-04T16:16:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/02\\\/21\\\/reverse-fft\\\/\"},\"wordCount\":142,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"keywords\":[\"FFT\"],\"articleSection\":[\"Arduino\",\"Machine Sound\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/02\\\/21\\\/reverse-fft\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/02\\\/21\\\/reverse-fft\\\/\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/02\\\/21\\\/reverse-fft\\\/\",\"name\":\"Using Inverse FFT to generate Audio - Phil Schatzmann\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\"},\"datePublished\":\"2025-02-21T11:12:31+00:00\",\"dateModified\":\"2025-03-04T16:16:10+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/02\\\/21\\\/reverse-fft\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/02\\\/21\\\/reverse-fft\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/02\\\/21\\\/reverse-fft\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using Inverse FFT to generate Audio\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\",\"name\":\"Phil Schatzmann Consulting\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\",\"name\":\"pschatzmann\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"width\":305,\"height\":305,\"caption\":\"pschatzmann\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using Inverse FFT to generate Audio - Phil Schatzmann","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pschatzmann.ch\/home\/2025\/02\/21\/reverse-fft\/","og_locale":"en_US","og_type":"article","og_title":"Using Inverse FFT to generate Audio - Phil Schatzmann","og_description":"So far I was using the Fast Fourier Transform (FFT) functionality of my &#8220;Arduino Audio Tools Library&#8221; for analyzing the audio. This week I spent some time to make sure that we also support the inverse FFT properly. The inverse FFT is generating audio samples in the time domain from [&hellip;]","og_url":"https:\/\/www.pschatzmann.ch\/home\/2025\/02\/21\/reverse-fft\/","og_site_name":"Phil Schatzmann","article_published_time":"2025-02-21T11:12:31+00:00","article_modified_time":"2025-03-04T16:16:10+00:00","author":"pschatzmann","twitter_card":"summary_large_image","twitter_misc":{"Written by":"pschatzmann","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/02\/21\/reverse-fft\/#article","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/02\/21\/reverse-fft\/"},"author":{"name":"pschatzmann","@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"headline":"Using Inverse FFT to generate Audio","datePublished":"2025-02-21T11:12:31+00:00","dateModified":"2025-03-04T16:16:10+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/02\/21\/reverse-fft\/"},"wordCount":142,"commentCount":0,"publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"keywords":["FFT"],"articleSection":["Arduino","Machine Sound"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pschatzmann.ch\/home\/2025\/02\/21\/reverse-fft\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/02\/21\/reverse-fft\/","url":"https:\/\/www.pschatzmann.ch\/home\/2025\/02\/21\/reverse-fft\/","name":"Using Inverse FFT to generate Audio - Phil Schatzmann","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#website"},"datePublished":"2025-02-21T11:12:31+00:00","dateModified":"2025-03-04T16:16:10+00:00","breadcrumb":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/02\/21\/reverse-fft\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pschatzmann.ch\/home\/2025\/02\/21\/reverse-fft\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/02\/21\/reverse-fft\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pschatzmann.ch\/home\/"},{"@type":"ListItem","position":2,"name":"Using Inverse FFT to generate Audio"}]},{"@type":"WebSite","@id":"https:\/\/www.pschatzmann.ch\/home\/#website","url":"https:\/\/www.pschatzmann.ch\/home\/","name":"Phil Schatzmann Consulting","description":"","publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pschatzmann.ch\/home\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1","name":"pschatzmann","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","width":305,"height":305,"caption":"pschatzmann"},"logo":{"@id":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png"}}]}},"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/6588","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/comments?post=6588"}],"version-history":[{"count":9,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/6588\/revisions"}],"predecessor-version":[{"id":6597,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/6588\/revisions\/6597"}],"wp:attachment":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media?parent=6588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/categories?post=6588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/tags?post=6588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}