{"id":4391,"date":"2022-01-27T12:40:55","date_gmt":"2022-01-27T11:40:55","guid":{"rendered":"https:\/\/www.pschatzmann.ch\/home\/?p=4391"},"modified":"2022-01-30T17:49:18","modified_gmt":"2022-01-30T16:49:18","slug":"aac-encoding-on-the-audiokit","status":"publish","type":"post","link":"https:\/\/www.pschatzmann.ch\/home\/2022\/01\/27\/aac-encoding-on-the-audiokit\/","title":{"rendered":"AAC Encoding on the AudioKit"},"content":{"rendered":"<p>For quite some time I was wondering why my <a href=\"https:\/\/github.com\/pschatzmann\/arduino-fdk-aac\">arduino-fdk-aac library<\/a> was using so much memory for the encoding of AAC files. Now that I have an <strong>AudioKit<\/strong> working with the <strong>debugger<\/strong> it was easier to analyze the situation and &#8211; oh boy &#8211; I found quite some errors.<\/p>\n<p>So I decided to address the issues and published a new <a href=\"https:\/\/github.com\/pschatzmann\/arduino-fdk-aac\/releases\/tag\/v0.3\">corrected release<\/a>.<\/p>\n<h2>Arduino Sketch<\/h2>\n<p>Here is a quick Arduino Sketch which demonstrates how to use the Encoder with the AudioKit:<\/p>\n<pre><code>#define USE_FDK\n\n#include \"AudioTools.h\"\n#include \"AudioLibs\/AudioKit.h\"\n\nAudioKitStream kit;    \nAACEncoderFDK *fdk=nullptr;\nAudioEncoderServer *server=nullptr;  \n\n\/\/ Arduino setup\nvoid setup(){\n  Serial.begin(115200);\n  \/\/ Defining Loglevels for the different libraries\n  \/\/AudioLogger::instance().begin(Serial, AudioLogger::Info);\n  \/\/LOGLEVEL_FDK = FDKInfo; \n  \/\/LOGLEVEL_AUDIOKIT = AudioKitInfo;\n\n  \/\/ setup and configure fdk\n  fdk = new AACEncoderFDK();  \n  fdk-&gt;setAudioObjectType(2);  \/\/ AAC low complexity\n  fdk-&gt;setOutputBufferSize(1024); \/\/ decrease output buffer size\n  fdk-&gt;setVariableBitrateMode(2); \/\/ low variable bitrate\n  server = new AudioEncoderServer(fdk,\"WIFI\",\"password\");  \n\n  \/\/ start i2s input with default configuration\n  Serial.println(\"starting AudioKit...\");\n  auto config = kit.defaultConfig(RX_MODE);\n  config.input_device = AUDIO_HAL_ADC_INPUT_LINE2;\n  config.sample_rate = 44100; \n  config.default_actions_active = false; \n  config.channels = 2; \n  kit.begin(config);\n  Serial.println(\"AudioKit started\");\n\n  \/\/ start data sink\n  server-&gt;begin(kit, config);\n  Serial.println(\"Server started\");\n\n}\n\n\/\/ Arduino loop  \nvoid loop() {\n  \/\/ Handle new connections\n  server-&gt;doLoop();  \n}\n<\/code><\/pre>\n<p>This demo shows<\/p>\n<ul>\n<li>how to set up the <strong>logger<\/strong> for the different libraries and <\/li>\n<li>how to <strong>configure<\/strong> the AACEncoderFDK. <\/li>\n<\/ul>\n<p>The shown encoder configuration values are corresponding with my updated default values proposed by the library &#8211; so they would not be necessary. But I left them to demonstrate how you could define your own settings. The available configuration methods are documented in the <a href=\"https:\/\/pschatzmann.github.io\/arduino-fdk-aac\/html\/classaac__fdk_1_1_a_a_c_encoder_f_d_k.html\">class documentation<\/a>.<\/p>\n<h2>Source Code<\/h2>\n<p>The (potentially updated) example can also be found on <a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-tools\/tree\/main\/examples\/examples-audiokit\/streams-audiokit-webserver_aac\">Github<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For quite some time I was wondering why my arduino-fdk-aac library was using so much memory for the encoding of AAC files. Now that I have an AudioKit working with the debugger it was easier to analyze the situation and &#8211; oh boy &#8211; I found quite some errors. So [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3633,"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":[28],"class_list":["post-4391","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-machine-sound","tag-esp32audiokit"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>AAC Encoding on the AudioKit - 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\/01\/27\/aac-encoding-on-the-audiokit\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"AAC Encoding on the AudioKit - Phil Schatzmann\" \/>\n<meta property=\"og:description\" content=\"For quite some time I was wondering why my arduino-fdk-aac library was using so much memory for the encoding of AAC files. Now that I have an AudioKit working with the debugger it was easier to analyze the situation and &#8211; oh boy &#8211; I found quite some errors. So [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pschatzmann.ch\/home\/2022\/01\/27\/aac-encoding-on-the-audiokit\/\" \/>\n<meta property=\"og:site_name\" content=\"Phil Schatzmann\" \/>\n<meta property=\"article:published_time\" content=\"2022-01-27T11:40:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-01-30T16:49:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/10\/aac.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=\"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\\\/01\\\/27\\\/aac-encoding-on-the-audiokit\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/01\\\/27\\\/aac-encoding-on-the-audiokit\\\/\"},\"author\":{\"name\":\"pschatzmann\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"headline\":\"AAC Encoding on the AudioKit\",\"datePublished\":\"2022-01-27T11:40:55+00:00\",\"dateModified\":\"2022-01-30T16:49:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/01\\\/27\\\/aac-encoding-on-the-audiokit\\\/\"},\"wordCount\":162,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/01\\\/27\\\/aac-encoding-on-the-audiokit\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2021\\\/10\\\/aac.png\",\"keywords\":[\"ESP32AudioKit\"],\"articleSection\":[\"Arduino\",\"Machine Sound\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/01\\\/27\\\/aac-encoding-on-the-audiokit\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/01\\\/27\\\/aac-encoding-on-the-audiokit\\\/\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/01\\\/27\\\/aac-encoding-on-the-audiokit\\\/\",\"name\":\"AAC Encoding on the AudioKit - Phil Schatzmann\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/01\\\/27\\\/aac-encoding-on-the-audiokit\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/01\\\/27\\\/aac-encoding-on-the-audiokit\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2021\\\/10\\\/aac.png\",\"datePublished\":\"2022-01-27T11:40:55+00:00\",\"dateModified\":\"2022-01-30T16:49:18+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/01\\\/27\\\/aac-encoding-on-the-audiokit\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/01\\\/27\\\/aac-encoding-on-the-audiokit\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/01\\\/27\\\/aac-encoding-on-the-audiokit\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2021\\\/10\\\/aac.png\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2021\\\/10\\\/aac.png\",\"width\":225,\"height\":225},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/01\\\/27\\\/aac-encoding-on-the-audiokit\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"AAC Encoding on the AudioKit\"}]},{\"@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":"AAC Encoding on the AudioKit - 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\/01\/27\/aac-encoding-on-the-audiokit\/","og_locale":"en_US","og_type":"article","og_title":"AAC Encoding on the AudioKit - Phil Schatzmann","og_description":"For quite some time I was wondering why my arduino-fdk-aac library was using so much memory for the encoding of AAC files. Now that I have an AudioKit working with the debugger it was easier to analyze the situation and &#8211; oh boy &#8211; I found quite some errors. So [&hellip;]","og_url":"https:\/\/www.pschatzmann.ch\/home\/2022\/01\/27\/aac-encoding-on-the-audiokit\/","og_site_name":"Phil Schatzmann","article_published_time":"2022-01-27T11:40:55+00:00","article_modified_time":"2022-01-30T16:49:18+00:00","og_image":[{"width":225,"height":225,"url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/10\/aac.png","type":"image\/png"}],"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\/01\/27\/aac-encoding-on-the-audiokit\/#article","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/01\/27\/aac-encoding-on-the-audiokit\/"},"author":{"name":"pschatzmann","@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"headline":"AAC Encoding on the AudioKit","datePublished":"2022-01-27T11:40:55+00:00","dateModified":"2022-01-30T16:49:18+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/01\/27\/aac-encoding-on-the-audiokit\/"},"wordCount":162,"commentCount":0,"publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/01\/27\/aac-encoding-on-the-audiokit\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/10\/aac.png","keywords":["ESP32AudioKit"],"articleSection":["Arduino","Machine Sound"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pschatzmann.ch\/home\/2022\/01\/27\/aac-encoding-on-the-audiokit\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/01\/27\/aac-encoding-on-the-audiokit\/","url":"https:\/\/www.pschatzmann.ch\/home\/2022\/01\/27\/aac-encoding-on-the-audiokit\/","name":"AAC Encoding on the AudioKit - Phil Schatzmann","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/01\/27\/aac-encoding-on-the-audiokit\/#primaryimage"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/01\/27\/aac-encoding-on-the-audiokit\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/10\/aac.png","datePublished":"2022-01-27T11:40:55+00:00","dateModified":"2022-01-30T16:49:18+00:00","breadcrumb":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/01\/27\/aac-encoding-on-the-audiokit\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pschatzmann.ch\/home\/2022\/01\/27\/aac-encoding-on-the-audiokit\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/01\/27\/aac-encoding-on-the-audiokit\/#primaryimage","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/10\/aac.png","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/10\/aac.png","width":225,"height":225},{"@type":"BreadcrumbList","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/01\/27\/aac-encoding-on-the-audiokit\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pschatzmann.ch\/home\/"},{"@type":"ListItem","position":2,"name":"AAC Encoding on the AudioKit"}]},{"@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\/4391","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=4391"}],"version-history":[{"count":12,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/4391\/revisions"}],"predecessor-version":[{"id":4403,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/4391\/revisions\/4403"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media\/3633"}],"wp:attachment":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media?parent=4391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/categories?post=4391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/tags?post=4391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}