{"id":3357,"date":"2021-08-13T13:39:34","date_gmt":"2021-08-13T11:39:34","guid":{"rendered":"https:\/\/www.pschatzmann.ch\/home\/?p=3357"},"modified":"2025-02-02T08:18:33","modified_gmt":"2025-02-02T07:18:33","slug":"audio-decoders-for-microcontrollers","status":"publish","type":"post","link":"https:\/\/www.pschatzmann.ch\/home\/2021\/08\/13\/audio-decoders-for-microcontrollers\/","title":{"rendered":"Audio Encoders and Decoders for Microcontrollers"},"content":{"rendered":"<p>Unfortunately the available memory on Microcontrollers is quite restricted and we do not get very far by storing a (uncompressed) WAV file e.g. in program\/flesh memory, so I started to look into <strong>compressed audio formats<\/strong>.<\/p>\n<p>On the desktop we can use the <a href=\"https:\/\/www.ffmpeg.org\/\">FFmpeg project<\/a> which comes with a rich set of functionality. Unfortunately the situation is much more fragmented for Microcontrollers.<\/p>\n<p>I started to collect the relevant libraries and in order to make things simple to use I also added <strong>a simple C++ API<\/strong> on top of the available libraries:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/pschatzmann\/arduino-libhelix\">libhelix<\/a> A <strong>MP3 and AAC Decoder<\/strong> from Realnetworks<\/li>\n<li><a href=\"https:\/\/github.com\/pschatzmann\/arduino-fdk-aac\">fdk-aac<\/a> A <strong>AAC Encoder and Decoder<\/strong> from the Frauenhofer Institute<\/li>\n<li><a href=\"https:\/\/github.com\/pschatzmann\/arduino-libmad\">libmad<\/a> A open source <strong>MP3 Decoder<\/strong> from Underbit<\/li>\n<li><a href=\"https:\/\/github.com\/pschatzmann\/arduino-liblame\">liblame<\/a> A open source <strong>MP3 Encoder<\/strong> uing <a href=\"https:\/\/lame.sourceforge.io\/about.php\">LAME<\/a><\/li>\n<\/ul>\n<p>All these projects can be used as <strong>Arduino Libraries<\/strong>, but they compile and work also <strong>outside of Arduino with the help of cmake<\/strong>.<\/p>\n<p>I am also providing an integration into my <a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-tools\">Arduino Audio Tools<\/a> where you can use these libraries with the <a href=\"https:\/\/pschatzmann.github.io\/arduino-audio-tools\/html\/classaudio__tools_1_1_encoded_audio_stream.html\">EncodedAudioStream<\/a> class:<\/p>\n<pre><code>#include \"Arduino.h\"\n#include \"AudioTools.h\"\n#include \"AudioCodecs\/CodecMP3Helix.h\"\n#include \"BabyElephantWalk60_mp3.h\"\n\nusing namespace audio_tools;  \n\nMemoryStream mp3(BabyElephantWalk60_mp3, BabyElephantWalk60_mp3_len); \/\/ MP3 data source\nI2SStream i2s; \/\/ final output of decoded stream\nEncodedAudioStream dec(new i2s, new MP3DecoderHelix()); \/\/ Decoding stream\nStreamCopy copier(dec, mp3); \/\/ copy in to out\n\nvoid setup(){\n  Serial.begin(115200);\n\n  dec.setNotifyAudioChange(i2s);\n  dec.begin();\n\n  i2s.begin();\n}\n\nvoid loop(){\n  if (mp3) {\n    copier.copy();\n  } \n}\n\n<\/code><\/pre>\n<p>The <code>setNotifyAudioChange<\/code> method is making sure, that the I2S settings are updated with the audio Information (channels, bits per sample, audio rate) based in the information provided by the decoder.<\/p>\n<p>Further updated information can be found in the related <a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-tools\/wiki\/Encoding-and-Decoding-of-Audio\">Wiki of the Project<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Unfortunately the available memory on Microcontrollers is quite restricted and we do not get very far by storing a (uncompressed) WAV file e.g. in program\/flesh memory, so I started to look into compressed audio formats. On the desktop we can use the FFmpeg project which comes with a rich set [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1854,"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":[38,44],"class_list":["post-3357","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-machine-sound","tag-codecs","tag-uno"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Audio Encoders and Decoders for Microcontrollers - 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\/2021\/08\/13\/audio-decoders-for-microcontrollers\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Audio Encoders and Decoders for Microcontrollers - Phil Schatzmann\" \/>\n<meta property=\"og:description\" content=\"Unfortunately the available memory on Microcontrollers is quite restricted and we do not get very far by storing a (uncompressed) WAV file e.g. in program\/flesh memory, so I started to look into compressed audio formats. On the desktop we can use the FFmpeg project which comes with a rich set [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pschatzmann.ch\/home\/2021\/08\/13\/audio-decoders-for-microcontrollers\/\" \/>\n<meta property=\"og:site_name\" content=\"Phil Schatzmann\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-13T11:39:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-02-02T07:18:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2020\/09\/Screen-Shot-2020-09-24-at-11.14.37.png\" \/>\n\t<meta property=\"og:image:width\" content=\"725\" \/>\n\t<meta property=\"og:image:height\" content=\"403\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\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\\\/2021\\\/08\\\/13\\\/audio-decoders-for-microcontrollers\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/08\\\/13\\\/audio-decoders-for-microcontrollers\\\/\"},\"author\":{\"name\":\"pschatzmann\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"headline\":\"Audio Encoders and Decoders for Microcontrollers\",\"datePublished\":\"2021-08-13T11:39:34+00:00\",\"dateModified\":\"2025-02-02T07:18:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/08\\\/13\\\/audio-decoders-for-microcontrollers\\\/\"},\"wordCount\":219,\"commentCount\":8,\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/08\\\/13\\\/audio-decoders-for-microcontrollers\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/Screen-Shot-2020-09-24-at-11.14.37.png\",\"keywords\":[\"Codecs\",\"UNO\"],\"articleSection\":[\"Arduino\",\"Machine Sound\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/08\\\/13\\\/audio-decoders-for-microcontrollers\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/08\\\/13\\\/audio-decoders-for-microcontrollers\\\/\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/08\\\/13\\\/audio-decoders-for-microcontrollers\\\/\",\"name\":\"Audio Encoders and Decoders for Microcontrollers - Phil Schatzmann\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/08\\\/13\\\/audio-decoders-for-microcontrollers\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/08\\\/13\\\/audio-decoders-for-microcontrollers\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/Screen-Shot-2020-09-24-at-11.14.37.png\",\"datePublished\":\"2021-08-13T11:39:34+00:00\",\"dateModified\":\"2025-02-02T07:18:33+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/08\\\/13\\\/audio-decoders-for-microcontrollers\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/08\\\/13\\\/audio-decoders-for-microcontrollers\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/08\\\/13\\\/audio-decoders-for-microcontrollers\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/Screen-Shot-2020-09-24-at-11.14.37.png\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/Screen-Shot-2020-09-24-at-11.14.37.png\",\"width\":725,\"height\":403},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/08\\\/13\\\/audio-decoders-for-microcontrollers\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Audio Encoders and Decoders for Microcontrollers\"}]},{\"@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":"Audio Encoders and Decoders for Microcontrollers - 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\/2021\/08\/13\/audio-decoders-for-microcontrollers\/","og_locale":"en_US","og_type":"article","og_title":"Audio Encoders and Decoders for Microcontrollers - Phil Schatzmann","og_description":"Unfortunately the available memory on Microcontrollers is quite restricted and we do not get very far by storing a (uncompressed) WAV file e.g. in program\/flesh memory, so I started to look into compressed audio formats. On the desktop we can use the FFmpeg project which comes with a rich set [&hellip;]","og_url":"https:\/\/www.pschatzmann.ch\/home\/2021\/08\/13\/audio-decoders-for-microcontrollers\/","og_site_name":"Phil Schatzmann","article_published_time":"2021-08-13T11:39:34+00:00","article_modified_time":"2025-02-02T07:18:33+00:00","og_image":[{"width":725,"height":403,"url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2020\/09\/Screen-Shot-2020-09-24-at-11.14.37.png","type":"image\/png"}],"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\/2021\/08\/13\/audio-decoders-for-microcontrollers\/#article","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2021\/08\/13\/audio-decoders-for-microcontrollers\/"},"author":{"name":"pschatzmann","@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"headline":"Audio Encoders and Decoders for Microcontrollers","datePublished":"2021-08-13T11:39:34+00:00","dateModified":"2025-02-02T07:18:33+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2021\/08\/13\/audio-decoders-for-microcontrollers\/"},"wordCount":219,"commentCount":8,"publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2021\/08\/13\/audio-decoders-for-microcontrollers\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2020\/09\/Screen-Shot-2020-09-24-at-11.14.37.png","keywords":["Codecs","UNO"],"articleSection":["Arduino","Machine Sound"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pschatzmann.ch\/home\/2021\/08\/13\/audio-decoders-for-microcontrollers\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pschatzmann.ch\/home\/2021\/08\/13\/audio-decoders-for-microcontrollers\/","url":"https:\/\/www.pschatzmann.ch\/home\/2021\/08\/13\/audio-decoders-for-microcontrollers\/","name":"Audio Encoders and Decoders for Microcontrollers - Phil Schatzmann","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2021\/08\/13\/audio-decoders-for-microcontrollers\/#primaryimage"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2021\/08\/13\/audio-decoders-for-microcontrollers\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2020\/09\/Screen-Shot-2020-09-24-at-11.14.37.png","datePublished":"2021-08-13T11:39:34+00:00","dateModified":"2025-02-02T07:18:33+00:00","breadcrumb":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2021\/08\/13\/audio-decoders-for-microcontrollers\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pschatzmann.ch\/home\/2021\/08\/13\/audio-decoders-for-microcontrollers\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/home\/2021\/08\/13\/audio-decoders-for-microcontrollers\/#primaryimage","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2020\/09\/Screen-Shot-2020-09-24-at-11.14.37.png","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2020\/09\/Screen-Shot-2020-09-24-at-11.14.37.png","width":725,"height":403},{"@type":"BreadcrumbList","@id":"https:\/\/www.pschatzmann.ch\/home\/2021\/08\/13\/audio-decoders-for-microcontrollers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pschatzmann.ch\/home\/"},{"@type":"ListItem","position":2,"name":"Audio Encoders and Decoders for Microcontrollers"}]},{"@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\/3357","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=3357"}],"version-history":[{"count":38,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/3357\/revisions"}],"predecessor-version":[{"id":6585,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/3357\/revisions\/6585"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media\/1854"}],"wp:attachment":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media?parent=3357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/categories?post=3357"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/tags?post=3357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}