{"id":4753,"date":"2022-05-14T06:25:57","date_gmt":"2022-05-14T04:25:57","guid":{"rendered":"https:\/\/www.pschatzmann.ch\/home\/?p=4753"},"modified":"2022-05-14T21:04:08","modified_gmt":"2022-05-14T19:04:08","slug":"the-minimp3-codec-on-an-esp32","status":"publish","type":"post","link":"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/14\/the-minimp3-codec-on-an-esp32\/","title":{"rendered":"The minimp3 Decoder on an ESP32 ?"},"content":{"rendered":"<p>When I was looking for an <strong>alternative open source MP3 decoder<\/strong>, I found the <a href=\"https:\/\/github.com\/lieff\/minimp3\">minimp3<\/a> project from <strong>lieff<\/strong>.<\/p>\n<h2>Arduino Support<\/h2>\n<p>Yesterday I took another effort to make it work on an <strong>Arduino ESP32<\/strong>. To make the project Arduino compatible was easy: I just had to add <strong>library.properties<\/strong> and change the Readme.md to add the instructions.<\/p>\n<p>Running the code on the ESP32 however turned out to be not so easy: the sketches were <strong>crashing w\/o any proper error messages<\/strong> or stack traces. Reviewing the code, I found 2 data structures that were allocated on the <strong>stack<\/strong>, that were quite big:<\/p>\n<ul>\n<li>mp3dec_scratch_t<\/li>\n<li>L12_scale_info<\/li>\n<\/ul>\n<p>Most of the other data was allocated on the <strong>heap<\/strong> as part of the mp3dec_t, so the solution was simple. I just moved these variables from the stack and made it part of mp3dec_t as well and to my surprise all the issues were resolved with this.<\/p>\n<h2>The Result<\/h2>\n<p>Unfortunately however, <strong>the result is disappointing<\/strong>: The <strong>decoder is too slow<\/strong> (e.g. on an ESP32) to decode any audio with a rate >= 32000 samples per second and the audio quality is quite poor.<\/p>\n<p>On other platforms this library can use <a href=\"https:\/\/en.wikipedia.org\/wiki\/Single_instruction,_multiple_data\">SIMD<\/a> to improve the performance. Unfortunately neither the ESP32 or the RP2040 can support this. W\/o SIMD the library relies heavily on <strong>floating point operations<\/strong> &#8211; which is a known weak spot of all the Espressif microcontrollers  &#8211; so any alternative with a decent floating point performance will perform much better .<\/p>\n<h2>The Source Code<\/h2>\n<p>The <strong>adapted Arduino library can be found on <a href=\"https:\/\/github.com\/pschatzmann\/arduino-minimp3\">github<\/a><\/strong>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When I was looking for an alternative open source MP3 decoder, I found the minimp3 project from lieff. Arduino Support Yesterday I took another effort to make it work on an Arduino ESP32. To make the project Arduino compatible was easy: I just had to add library.properties and change the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"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":[],"class_list":["post-4753","post","type-post","status-publish","format-standard","hentry","category-arduino","category-machine-sound"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>The minimp3 Decoder on an ESP32 ? - 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\/2022\/05\/14\/the-minimp3-codec-on-an-esp32\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The minimp3 Decoder on an ESP32 ? - Phil Schatzmann\" \/>\n<meta property=\"og:description\" content=\"When I was looking for an alternative open source MP3 decoder, I found the minimp3 project from lieff. Arduino Support Yesterday I took another effort to make it work on an Arduino ESP32. To make the project Arduino compatible was easy: I just had to add library.properties and change the [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/14\/the-minimp3-codec-on-an-esp32\/\" \/>\n<meta property=\"og:site_name\" content=\"Phil Schatzmann\" \/>\n<meta property=\"article:published_time\" content=\"2022-05-14T04:25:57+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-05-14T19:04:08+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\\\/2022\\\/05\\\/14\\\/the-minimp3-codec-on-an-esp32\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/05\\\/14\\\/the-minimp3-codec-on-an-esp32\\\/\"},\"author\":{\"name\":\"pschatzmann\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"headline\":\"The minimp3 Decoder on an ESP32 ?\",\"datePublished\":\"2022-05-14T04:25:57+00:00\",\"dateModified\":\"2022-05-14T19:04:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/05\\\/14\\\/the-minimp3-codec-on-an-esp32\\\/\"},\"wordCount\":271,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"articleSection\":[\"Arduino\",\"Machine Sound\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/05\\\/14\\\/the-minimp3-codec-on-an-esp32\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/05\\\/14\\\/the-minimp3-codec-on-an-esp32\\\/\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/05\\\/14\\\/the-minimp3-codec-on-an-esp32\\\/\",\"name\":\"The minimp3 Decoder on an ESP32 ? - Phil Schatzmann\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\"},\"datePublished\":\"2022-05-14T04:25:57+00:00\",\"dateModified\":\"2022-05-14T19:04:08+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/05\\\/14\\\/the-minimp3-codec-on-an-esp32\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/05\\\/14\\\/the-minimp3-codec-on-an-esp32\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/05\\\/14\\\/the-minimp3-codec-on-an-esp32\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"The minimp3 Decoder on an ESP32 ?\"}]},{\"@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":"The minimp3 Decoder on an ESP32 ? - 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\/2022\/05\/14\/the-minimp3-codec-on-an-esp32\/","og_locale":"en_US","og_type":"article","og_title":"The minimp3 Decoder on an ESP32 ? - Phil Schatzmann","og_description":"When I was looking for an alternative open source MP3 decoder, I found the minimp3 project from lieff. Arduino Support Yesterday I took another effort to make it work on an Arduino ESP32. To make the project Arduino compatible was easy: I just had to add library.properties and change the [&hellip;]","og_url":"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/14\/the-minimp3-codec-on-an-esp32\/","og_site_name":"Phil Schatzmann","article_published_time":"2022-05-14T04:25:57+00:00","article_modified_time":"2022-05-14T19:04:08+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\/2022\/05\/14\/the-minimp3-codec-on-an-esp32\/#article","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/14\/the-minimp3-codec-on-an-esp32\/"},"author":{"name":"pschatzmann","@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"headline":"The minimp3 Decoder on an ESP32 ?","datePublished":"2022-05-14T04:25:57+00:00","dateModified":"2022-05-14T19:04:08+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/14\/the-minimp3-codec-on-an-esp32\/"},"wordCount":271,"commentCount":3,"publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"articleSection":["Arduino","Machine Sound"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pschatzmann.ch\/home\/2022\/05\/14\/the-minimp3-codec-on-an-esp32\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/14\/the-minimp3-codec-on-an-esp32\/","url":"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/14\/the-minimp3-codec-on-an-esp32\/","name":"The minimp3 Decoder on an ESP32 ? - Phil Schatzmann","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#website"},"datePublished":"2022-05-14T04:25:57+00:00","dateModified":"2022-05-14T19:04:08+00:00","breadcrumb":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/14\/the-minimp3-codec-on-an-esp32\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pschatzmann.ch\/home\/2022\/05\/14\/the-minimp3-codec-on-an-esp32\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/14\/the-minimp3-codec-on-an-esp32\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pschatzmann.ch\/home\/"},{"@type":"ListItem","position":2,"name":"The minimp3 Decoder on an ESP32 ?"}]},{"@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\/4753","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=4753"}],"version-history":[{"count":18,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/4753\/revisions"}],"predecessor-version":[{"id":4784,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/4753\/revisions\/4784"}],"wp:attachment":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media?parent=4753"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/categories?post=4753"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/tags?post=4753"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}