{"id":5827,"date":"2023-07-10T15:52:05","date_gmt":"2023-07-10T13:52:05","guid":{"rendered":"https:\/\/www.pschatzmann.ch\/home\/?p=5827"},"modified":"2023-07-10T16:03:26","modified_gmt":"2023-07-10T14:03:26","slug":"arduino-uno-r4-fft-using-cmsis-dsp","status":"publish","type":"post","link":"https:\/\/www.pschatzmann.ch\/home\/2023\/07\/10\/arduino-uno-r4-fft-using-cmsis-dsp\/","title":{"rendered":"Arduino UNO R4: FFT using CMSIS DSP"},"content":{"rendered":"<p>In my <a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-tools\">Arduino Audio Tools<\/a> library I am providing a common API to do FFT against different implementations. I was already testing some of the implementations.<\/p>\n<p>On ARM microcontrollers we can use the <strong>CMSIS DSP library<\/strong> which usually comes automatically with the Arduino Core. This is not the case for the Arduino UNO R4, but we can install the <strong>Arduino CMSIS DSP library<\/strong> with the Arduino <strong>library manager<\/strong>.<\/p>\n<p>Here is the adapted test sketch that generates a sine tone to be analysed by FFT: I just needed to reduce the length parameter from 4k to 1k because of the limited available RAM.<\/p>\n<h3>Example Sketch<\/h3>\n<pre><code>#include \"AudioTools.h\"\n#include \"AudioLibs\/AudioCmsisFFT.h\" \/\/ using CMSIS DSP\n\nAudioCmsisFFT fft; \/\/ or AudioKissFFT\nSineWaveGenerator&lt;int16_t&gt; sineWave(32000);\nGeneratedSoundStream&lt;int16_t&gt; in(sineWave);\nStreamCopy copier(fft, in);\nAudioInfo info(8000, 1, 16);\nfloat value = 0;\n\n\/\/ display fft result\nvoid fftResult(AudioFFTBase &amp;fft) {\n  float diff;\n  auto result = fft.result();\n  if (result.magnitude &gt; 100) {\n    Serial.print(result.frequency);\n    Serial.print(\" \");\n    Serial.print(result.magnitude);\n    Serial.print(\" =&gt; \");\n    Serial.print(result.frequencyAsNote(diff));\n    Serial.print(\" diff: \");\n    Serial.print(diff);\n    Serial.print(\" - time ms \");\n    Serial.print(fft.resultTime() - fft.resultTimeBegin());\n    Serial.println();\n  }\n}\n\nvoid setup() {\n  Serial.begin(115200);\n  AudioLogger::instance().begin(Serial, AudioLogger::Warning);\n\n  while(!Serial);\n\n  \/\/ set the frequency\n  sineWave.setFrequency(N_B4);\n\n  \/\/ Setup sine wave\n  auto cfg = in.defaultConfig();\n  cfg.copyFrom(info);\n  in.begin(cfg);\n\n  \/\/ Setup FFT\n  auto tcfg = fft.defaultConfig();\n  tcfg.copyFrom(info);\n  tcfg.length = 1024;\n  tcfg.callback = &amp;fftResult;\n  fft.begin(tcfg);\n}\n\nvoid loop() { copier.copy(); }\n<\/code><\/pre>\n<h3>Dependencies<\/h3>\n<p>You need to install the following libraries:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-tools\">Arduino Audio Tools<\/a><\/li>\n<li>Arduino_CMSIS-DSP <\/li>\n<\/ul>\n<p>Here you can also find some of <a href=\"https:\/\/www.pschatzmann.ch\/tag\/uno\/\">my other posts related to the Arduino Uno R4<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my Arduino Audio Tools library I am providing a common API to do FFT against different implementations. I was already testing some of the implementations. On ARM microcontrollers we can use the CMSIS DSP library which usually comes automatically with the Arduino Core. This is not the case for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5728,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","_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":[44],"class_list":["post-5827","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-machine-sound","tag-uno"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Arduino UNO R4: FFT using CMSIS DSP - 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\/2023\/07\/10\/arduino-uno-r4-fft-using-cmsis-dsp\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Arduino UNO R4: FFT using CMSIS DSP - Phil Schatzmann\" \/>\n<meta property=\"og:description\" content=\"In my Arduino Audio Tools library I am providing a common API to do FFT against different implementations. I was already testing some of the implementations. On ARM microcontrollers we can use the CMSIS DSP library which usually comes automatically with the Arduino Core. This is not the case for [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pschatzmann.ch\/home\/2023\/07\/10\/arduino-uno-r4-fft-using-cmsis-dsp\/\" \/>\n<meta property=\"og:site_name\" content=\"Phil Schatzmann\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-10T13:52:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-07-10T14:03:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2023\/06\/UnoR4.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"300\" \/>\n\t<meta property=\"og:image:height\" content=\"300\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/07\\\/10\\\/arduino-uno-r4-fft-using-cmsis-dsp\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/07\\\/10\\\/arduino-uno-r4-fft-using-cmsis-dsp\\\/\"},\"author\":{\"name\":\"pschatzmann\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"headline\":\"Arduino UNO R4: FFT using CMSIS DSP\",\"datePublished\":\"2023-07-10T13:52:05+00:00\",\"dateModified\":\"2023-07-10T14:03:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/07\\\/10\\\/arduino-uno-r4-fft-using-cmsis-dsp\\\/\"},\"wordCount\":140,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/07\\\/10\\\/arduino-uno-r4-fft-using-cmsis-dsp\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/UnoR4.jpg\",\"keywords\":[\"UNO\"],\"articleSection\":[\"Arduino\",\"Machine Sound\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/07\\\/10\\\/arduino-uno-r4-fft-using-cmsis-dsp\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/07\\\/10\\\/arduino-uno-r4-fft-using-cmsis-dsp\\\/\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/07\\\/10\\\/arduino-uno-r4-fft-using-cmsis-dsp\\\/\",\"name\":\"Arduino UNO R4: FFT using CMSIS DSP - Phil Schatzmann\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/07\\\/10\\\/arduino-uno-r4-fft-using-cmsis-dsp\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/07\\\/10\\\/arduino-uno-r4-fft-using-cmsis-dsp\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/UnoR4.jpg\",\"datePublished\":\"2023-07-10T13:52:05+00:00\",\"dateModified\":\"2023-07-10T14:03:26+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/07\\\/10\\\/arduino-uno-r4-fft-using-cmsis-dsp\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/07\\\/10\\\/arduino-uno-r4-fft-using-cmsis-dsp\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/07\\\/10\\\/arduino-uno-r4-fft-using-cmsis-dsp\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/UnoR4.jpg\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/UnoR4.jpg\",\"width\":300,\"height\":300},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/07\\\/10\\\/arduino-uno-r4-fft-using-cmsis-dsp\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Arduino UNO R4: FFT using CMSIS DSP\"}]},{\"@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":"Arduino UNO R4: FFT using CMSIS DSP - 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\/2023\/07\/10\/arduino-uno-r4-fft-using-cmsis-dsp\/","og_locale":"en_US","og_type":"article","og_title":"Arduino UNO R4: FFT using CMSIS DSP - Phil Schatzmann","og_description":"In my Arduino Audio Tools library I am providing a common API to do FFT against different implementations. I was already testing some of the implementations. On ARM microcontrollers we can use the CMSIS DSP library which usually comes automatically with the Arduino Core. This is not the case for [&hellip;]","og_url":"https:\/\/www.pschatzmann.ch\/home\/2023\/07\/10\/arduino-uno-r4-fft-using-cmsis-dsp\/","og_site_name":"Phil Schatzmann","article_published_time":"2023-07-10T13:52:05+00:00","article_modified_time":"2023-07-10T14:03:26+00:00","og_image":[{"width":300,"height":300,"url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2023\/06\/UnoR4.jpg","type":"image\/jpeg"}],"author":"pschatzmann","twitter_card":"summary_large_image","twitter_misc":{"Written by":"pschatzmann","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/07\/10\/arduino-uno-r4-fft-using-cmsis-dsp\/#article","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/07\/10\/arduino-uno-r4-fft-using-cmsis-dsp\/"},"author":{"name":"pschatzmann","@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"headline":"Arduino UNO R4: FFT using CMSIS DSP","datePublished":"2023-07-10T13:52:05+00:00","dateModified":"2023-07-10T14:03:26+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/07\/10\/arduino-uno-r4-fft-using-cmsis-dsp\/"},"wordCount":140,"commentCount":0,"publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/07\/10\/arduino-uno-r4-fft-using-cmsis-dsp\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2023\/06\/UnoR4.jpg","keywords":["UNO"],"articleSection":["Arduino","Machine Sound"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pschatzmann.ch\/home\/2023\/07\/10\/arduino-uno-r4-fft-using-cmsis-dsp\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/07\/10\/arduino-uno-r4-fft-using-cmsis-dsp\/","url":"https:\/\/www.pschatzmann.ch\/home\/2023\/07\/10\/arduino-uno-r4-fft-using-cmsis-dsp\/","name":"Arduino UNO R4: FFT using CMSIS DSP - Phil Schatzmann","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/07\/10\/arduino-uno-r4-fft-using-cmsis-dsp\/#primaryimage"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/07\/10\/arduino-uno-r4-fft-using-cmsis-dsp\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2023\/06\/UnoR4.jpg","datePublished":"2023-07-10T13:52:05+00:00","dateModified":"2023-07-10T14:03:26+00:00","breadcrumb":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/07\/10\/arduino-uno-r4-fft-using-cmsis-dsp\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pschatzmann.ch\/home\/2023\/07\/10\/arduino-uno-r4-fft-using-cmsis-dsp\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/07\/10\/arduino-uno-r4-fft-using-cmsis-dsp\/#primaryimage","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2023\/06\/UnoR4.jpg","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2023\/06\/UnoR4.jpg","width":300,"height":300},{"@type":"BreadcrumbList","@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/07\/10\/arduino-uno-r4-fft-using-cmsis-dsp\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pschatzmann.ch\/home\/"},{"@type":"ListItem","position":2,"name":"Arduino UNO R4: FFT using CMSIS DSP"}]},{"@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\/5827","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=5827"}],"version-history":[{"count":7,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/5827\/revisions"}],"predecessor-version":[{"id":5834,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/5827\/revisions\/5834"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media\/5728"}],"wp:attachment":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media?parent=5827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/categories?post=5827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/tags?post=5827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}