{"id":6621,"date":"2025-03-08T16:21:41","date_gmt":"2025-03-08T15:21:41","guid":{"rendered":"https:\/\/www.pschatzmann.ch\/home\/?p=6621"},"modified":"2025-03-08T17:43:54","modified_gmt":"2025-03-08T16:43:54","slug":"audiotools-an-internet-mp3-player-in-idf","status":"publish","type":"post","link":"https:\/\/www.pschatzmann.ch\/home\/2025\/03\/08\/audiotools-an-internet-mp3-player-in-idf\/","title":{"rendered":"AudioTools: An Internet MP3 Player with the Espressif IDF"},"content":{"rendered":"<p>In my <a href=\"https:\/\/www.pschatzmann.ch\/home\/2025\/03\/04\/audiotools-an-esp32-idf-implementation-of-urlstream\/\">last post<\/a>, I described that I have implemented the <strong>URLStream class<\/strong> using pure IDF functionality. So you will not be wrong if you expect a <strong>working MP3 Internat Player<\/strong> next that just relies on the IDF w\/o Arduino.<\/p>\n<h3>The main.cpp Program<\/h3>\n<p>Here is the complete IDF program that mimicks the Arduino setup() and loop() methods. The only other difference to the usual Arduino sketches is, that we can&#8217;t use Serial and the related logging, but we rely on the logging functionality provided by the IDF.<\/p>\n<p>In this example we use an <strong>AI Thinker AudioKit<\/strong> as output device. But you can easily replace the AudioBoardStream with any other output class (e.g. I2SStream).<\/p>\n<pre><code>#include \"AudioTools.h\"\n#include \"AudioTools\/AudioCodecs\/CodecMP3Helix.h\"\n#include \"AudioTools\/AudioLibs\/AudioBoardStream.h\" \/\/ for AudioKit\n\nURLStream url(\"ssid\",\"password\");  \/\/ or replace with ICYStream to get metadata\nAudioBoardStream i2s(AudioKitEs8388V1); \/\/ final output of decoded stream\nMP3DecoderHelix mp3;\nEncodedAudioStream dec_stream(&amp;i2s, &amp;mp3); \/\/ Decoding stream\nStreamCopy copier(dec_stream, url); \/\/ copy url to decoder\n\nvoid setup(){\n  \/\/ setup i2s\n  auto config = i2s.defaultConfig(TX_MODE);\n  i2s.begin(config);\n\n  \/\/ setup I2S based on sampling rate provided by decoder\n  dec_stream.begin();\n\n  \/\/ mp3 radio\n  if (!url.begin(\"http:\/\/stream.srg-ssr.ch\/m\/rsj\/mp3_128\",\"audio\/mp3\")){\n    stop();\n  }\n}\n\nvoid loop(){\n  copier.copy();\n}\n\nextern \"C\" void app_main() {\n    setup();\n    while(true) loop();\n}\n<\/code><\/pre>\n<p>So like in the Arduino Variant, we just copy the mp3 data from an URLStream to a EncodedAudioStream which decods the mp3 to pcm and sends the result to the AudioBoardStream.<\/p>\n<h3>The CMakeLists.txt<\/h3>\n<p>Next to the main.cpp we have the following CMakeLists.txt<\/p>\n<pre><code># This file was automatically generated for projects\n# without default 'CMakeLists.txt' file.\n\nFILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}\/src\/*.*)\n\nidf_component_register(SRCS ${app_sources})\n\n# imporant defines\nadd_compile_definitions(-DESP32_CMAKE -DLOG_LOCAL_LEVEL=ESP_LOG_INFO )\n\n<\/code><\/pre>\n<p>The -DESP32_CMAKE tells all libraries that we use the ESP32 IDF framework w\/o Arduino.<br \/>\nNote that we also define the <strong>log level<\/strong> here!<\/p>\n<h3>Dependencies<\/h3>\n<p>The components directory contains all dependencies:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-tools\">arduino-audio-tools<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-driver\">arduino-audio-driver<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/pschatzmann\/arduino-libhelix\">arduino-libhelix<\/a> <\/li>\n<\/ul>\n<h3>Complete Source Code<\/h3>\n<p>You can find the <a href=\"https:\/\/github.com\/pschatzmann\/idf-example-audio-tools\">complete source code on Github<\/a>!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my last post, I described that I have implemented the URLStream class using pure IDF functionality. So you will not be wrong if you expect a working MP3 Internat Player next that just relies on the IDF w\/o Arduino. The main.cpp Program Here is the complete IDF program that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6623,"comment_status":"open","ping_status":"closed","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":[22],"tags":[50],"class_list":["post-6621","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-machine-sound","tag-idf"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>AudioTools: An Internet MP3 Player with the Espressif IDF - 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\/03\/08\/audiotools-an-internet-mp3-player-in-idf\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"AudioTools: An Internet MP3 Player with the Espressif IDF - Phil Schatzmann\" \/>\n<meta property=\"og:description\" content=\"In my last post, I described that I have implemented the URLStream class using pure IDF functionality. So you will not be wrong if you expect a working MP3 Internat Player next that just relies on the IDF w\/o Arduino. The main.cpp Program Here is the complete IDF program that [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pschatzmann.ch\/home\/2025\/03\/08\/audiotools-an-internet-mp3-player-in-idf\/\" \/>\n<meta property=\"og:site_name\" content=\"Phil Schatzmann\" \/>\n<meta property=\"article:published_time\" content=\"2025-03-08T15:21:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-03-08T16:43:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2025\/03\/idf.png\" \/>\n\t<meta property=\"og:image:width\" content=\"225\" \/>\n\t<meta property=\"og:image:height\" content=\"225\" \/>\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\\\/2025\\\/03\\\/08\\\/audiotools-an-internet-mp3-player-in-idf\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/03\\\/08\\\/audiotools-an-internet-mp3-player-in-idf\\\/\"},\"author\":{\"name\":\"pschatzmann\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"headline\":\"AudioTools: An Internet MP3 Player with the Espressif IDF\",\"datePublished\":\"2025-03-08T15:21:41+00:00\",\"dateModified\":\"2025-03-08T16:43:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/03\\\/08\\\/audiotools-an-internet-mp3-player-in-idf\\\/\"},\"wordCount\":219,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/03\\\/08\\\/audiotools-an-internet-mp3-player-in-idf\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/idf.png\",\"keywords\":[\"IDF\"],\"articleSection\":[\"Machine Sound\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/03\\\/08\\\/audiotools-an-internet-mp3-player-in-idf\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/03\\\/08\\\/audiotools-an-internet-mp3-player-in-idf\\\/\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/03\\\/08\\\/audiotools-an-internet-mp3-player-in-idf\\\/\",\"name\":\"AudioTools: An Internet MP3 Player with the Espressif IDF - Phil Schatzmann\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/03\\\/08\\\/audiotools-an-internet-mp3-player-in-idf\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/03\\\/08\\\/audiotools-an-internet-mp3-player-in-idf\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/idf.png\",\"datePublished\":\"2025-03-08T15:21:41+00:00\",\"dateModified\":\"2025-03-08T16:43:54+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/03\\\/08\\\/audiotools-an-internet-mp3-player-in-idf\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/03\\\/08\\\/audiotools-an-internet-mp3-player-in-idf\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/03\\\/08\\\/audiotools-an-internet-mp3-player-in-idf\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/idf.png\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/idf.png\",\"width\":225,\"height\":225},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/03\\\/08\\\/audiotools-an-internet-mp3-player-in-idf\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"AudioTools: An Internet MP3 Player with the Espressif IDF\"}]},{\"@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":"AudioTools: An Internet MP3 Player with the Espressif IDF - 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\/03\/08\/audiotools-an-internet-mp3-player-in-idf\/","og_locale":"en_US","og_type":"article","og_title":"AudioTools: An Internet MP3 Player with the Espressif IDF - Phil Schatzmann","og_description":"In my last post, I described that I have implemented the URLStream class using pure IDF functionality. So you will not be wrong if you expect a working MP3 Internat Player next that just relies on the IDF w\/o Arduino. The main.cpp Program Here is the complete IDF program that [&hellip;]","og_url":"https:\/\/www.pschatzmann.ch\/home\/2025\/03\/08\/audiotools-an-internet-mp3-player-in-idf\/","og_site_name":"Phil Schatzmann","article_published_time":"2025-03-08T15:21:41+00:00","article_modified_time":"2025-03-08T16:43:54+00:00","og_image":[{"width":225,"height":225,"url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2025\/03\/idf.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\/2025\/03\/08\/audiotools-an-internet-mp3-player-in-idf\/#article","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/03\/08\/audiotools-an-internet-mp3-player-in-idf\/"},"author":{"name":"pschatzmann","@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"headline":"AudioTools: An Internet MP3 Player with the Espressif IDF","datePublished":"2025-03-08T15:21:41+00:00","dateModified":"2025-03-08T16:43:54+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/03\/08\/audiotools-an-internet-mp3-player-in-idf\/"},"wordCount":219,"commentCount":0,"publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/03\/08\/audiotools-an-internet-mp3-player-in-idf\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2025\/03\/idf.png","keywords":["IDF"],"articleSection":["Machine Sound"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pschatzmann.ch\/home\/2025\/03\/08\/audiotools-an-internet-mp3-player-in-idf\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/03\/08\/audiotools-an-internet-mp3-player-in-idf\/","url":"https:\/\/www.pschatzmann.ch\/home\/2025\/03\/08\/audiotools-an-internet-mp3-player-in-idf\/","name":"AudioTools: An Internet MP3 Player with the Espressif IDF - Phil Schatzmann","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/03\/08\/audiotools-an-internet-mp3-player-in-idf\/#primaryimage"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/03\/08\/audiotools-an-internet-mp3-player-in-idf\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2025\/03\/idf.png","datePublished":"2025-03-08T15:21:41+00:00","dateModified":"2025-03-08T16:43:54+00:00","breadcrumb":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/03\/08\/audiotools-an-internet-mp3-player-in-idf\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pschatzmann.ch\/home\/2025\/03\/08\/audiotools-an-internet-mp3-player-in-idf\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/03\/08\/audiotools-an-internet-mp3-player-in-idf\/#primaryimage","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2025\/03\/idf.png","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2025\/03\/idf.png","width":225,"height":225},{"@type":"BreadcrumbList","@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/03\/08\/audiotools-an-internet-mp3-player-in-idf\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pschatzmann.ch\/home\/"},{"@type":"ListItem","position":2,"name":"AudioTools: An Internet MP3 Player with the Espressif IDF"}]},{"@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\/6621","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=6621"}],"version-history":[{"count":12,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/6621\/revisions"}],"predecessor-version":[{"id":6635,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/6621\/revisions\/6635"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media\/6623"}],"wp:attachment":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media?parent=6621"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/categories?post=6621"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/tags?post=6621"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}