{"id":5661,"date":"2023-05-10T14:02:27","date_gmt":"2023-05-10T12:02:27","guid":{"rendered":"https:\/\/www.pschatzmann.ch\/home\/?p=5661"},"modified":"2024-03-21T09:44:17","modified_gmt":"2024-03-21T08:44:17","slug":"fast-audio-codecs-for-microcontrollers","status":"publish","type":"post","link":"https:\/\/www.pschatzmann.ch\/home\/2023\/05\/10\/fast-audio-codecs-for-microcontrollers\/","title":{"rendered":"Fast Audio Codecs for Microcontrollers"},"content":{"rendered":"<p>My <a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-tools\">AudioTools<\/a> project is supporting quite a few audio <a href=\"https:\/\/pschatzmann.github.io\/arduino-audio-tools\/classaudio__tools_1_1_audio_encoder.html\">encoders<\/a> and <a href=\"https:\/\/pschatzmann.github.io\/arduino-audio-tools\/classaudio__tools_1_1_audio_decoder.html\">decoders<\/a>. They are critical to reduce the storage or transmission volume of audio.<\/p>\n<p>Though I support the encoding of <strong>AAC<\/strong> and <strong>MP3<\/strong>, I can&#8217;t really recommend this: it <strong>requires a lot of memory<\/strong> and processing time.<\/p>\n<p>For an introduction how to use the codecs, please read the <a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-tools\/wiki\/Encoding-and-Decoding-of-Audio\">Wiki<\/a>.<\/p>\n<p>Below you can find my <strong>short list<\/strong> of my favorite codecs which are <strong>fast and efficient<\/strong>. I tried to measure the thruput with the help of the following Arduino sketch<\/p>\n<h2>Measuring Sketch<\/h2>\n<pre><code>#include \"AudioTools.h\"\n#include \"AudioCodecs\/CodecSBC.h\"\n#include \"AudioLibs\/AudioKit.h\"\n\nAudioInfo info(44100, 2, 16);\nSineWaveGenerator&lt;int16_t&gt; sineWave( 32000);  \/\/ subclass of SoundGenerator with max amplitude of 32000\nGeneratedSoundStream&lt;int16_t&gt; sound( sineWave); \/\/ Stream generated from sine wave\nMeasuringStream out(100, &amp;Serial); \nEncodedAudioStream decoder(&amp;out, new SBCDecoder()); \/\/ encode and write\nEncodedAudioStream encoder(&amp;decoder, new SBCEncoder()); \/\/ encode and write\nStreamCopy copier(encoder, sound);     \n\nvoid setup() {\n  Serial.begin(115200);\n  AudioLogger::instance().begin(Serial, AudioLogger::Warning);\n\n  out.begin();\n\n  \/\/ Setup sine wave\n  auto cfgs = sineWave.defaultConfig();\n  cfgs.copyFrom(info);\n  sineWave.begin(info, N_B4);\n\n  \/\/ start decoder\n  decoder.begin(info);\n\n  \/\/ start encoder\n  encoder.begin(info);\n\n  Serial.println(\"Test started...\");\n}\n\n\nvoid loop() { \n  copier.copy();\n}\n<\/code><\/pre>\n<p>We generate a stereo sine tone with a sample rate of 44100 samples\/second and just measure the bytes per second on the output side.<\/p>\n<h2>Result<\/h2>\n<p>Here is the result of my favorite codecs:<\/p>\n<table>\n<thead>\n<tr>\n<th>Codec<\/th>\n<th>Bytes\/second<\/th>\n<th>Frames\/second<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>SBC<\/td>\n<td>327&#8217;000<\/td>\n<td>81&#8217;750<\/td>\n<\/tr>\n<tr>\n<td>ADPCM<\/td>\n<td>609&#8217;000<\/td>\n<td>152&#8217;250<\/td>\n<\/tr>\n<tr>\n<td>L8<\/td>\n<td>1&#8217;951&#8217;000<\/td>\n<td>487&#8217;750<\/td>\n<\/tr>\n<tr>\n<td>&#8211;<\/td>\n<td>861&#8217;000<\/td>\n<td>215&#8217;250<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p\/>\n<p>The sketch is usually reporting multiple values and I was just picking the smallest of them.<\/p>\n<p\/>\n<p>The <strong>SBC codec<\/strong> is usually the default codec for the <strong>A2DP Bluetooth<\/strong> audio profile.<\/p>\n<p><strong>ADPCM<\/strong> is a Adaptive differential pulse-code modulation codec. It  is out of fashion on desktops, but on microcontrollers it still shines.<\/p>\n<p><strong>L8<\/strong> is just a 8 bit unsigned signal, so it is cutting the transmission volume in half at the cost of the reduced resolution. But 8 bit is still giving a decent audio quality!<\/p>\n<p>It is surprising to see that the processing with L8 is even faster than with no codec!<\/p>\n<p>If you plan to transmit <strong>speech<\/strong> over slow transmission lines, I suggest that you consider the codecs that have been designed for that purpose: e.g. GSM, a-low, u-low, G.721 etc (See the classification in the <a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-tools\/wiki\/Encoding-and-Decoding-of-Audio\">Wiki<\/a>)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My AudioTools project is supporting quite a few audio encoders and decoders. They are critical to reduce the storage or transmission volume of audio. Though I support the encoding of AAC and MP3, I can&#8217;t really recommend this: it requires a lot of memory and processing time. For an introduction [&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":[38,46,44],"class_list":["post-5661","post","type-post","status-publish","format-standard","hentry","category-arduino","category-machine-sound","tag-codecs","tag-communications","tag-uno"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Fast Audio Codecs 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\/2023\/05\/10\/fast-audio-codecs-for-microcontrollers\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Fast Audio Codecs for Microcontrollers - Phil Schatzmann\" \/>\n<meta property=\"og:description\" content=\"My AudioTools project is supporting quite a few audio encoders and decoders. They are critical to reduce the storage or transmission volume of audio. Though I support the encoding of AAC and MP3, I can&#8217;t really recommend this: it requires a lot of memory and processing time. For an introduction [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pschatzmann.ch\/home\/2023\/05\/10\/fast-audio-codecs-for-microcontrollers\/\" \/>\n<meta property=\"og:site_name\" content=\"Phil Schatzmann\" \/>\n<meta property=\"article:published_time\" content=\"2023-05-10T12:02:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-21T08:44:17+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=\"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\\\/05\\\/10\\\/fast-audio-codecs-for-microcontrollers\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/05\\\/10\\\/fast-audio-codecs-for-microcontrollers\\\/\"},\"author\":{\"name\":\"pschatzmann\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"headline\":\"Fast Audio Codecs for Microcontrollers\",\"datePublished\":\"2023-05-10T12:02:27+00:00\",\"dateModified\":\"2024-03-21T08:44:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/05\\\/10\\\/fast-audio-codecs-for-microcontrollers\\\/\"},\"wordCount\":277,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"keywords\":[\"Codecs\",\"Communications\",\"UNO\"],\"articleSection\":[\"Arduino\",\"Machine Sound\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/05\\\/10\\\/fast-audio-codecs-for-microcontrollers\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/05\\\/10\\\/fast-audio-codecs-for-microcontrollers\\\/\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/05\\\/10\\\/fast-audio-codecs-for-microcontrollers\\\/\",\"name\":\"Fast Audio Codecs for Microcontrollers - Phil Schatzmann\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\"},\"datePublished\":\"2023-05-10T12:02:27+00:00\",\"dateModified\":\"2024-03-21T08:44:17+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/05\\\/10\\\/fast-audio-codecs-for-microcontrollers\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/05\\\/10\\\/fast-audio-codecs-for-microcontrollers\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/05\\\/10\\\/fast-audio-codecs-for-microcontrollers\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Fast Audio Codecs 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":"Fast Audio Codecs 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\/2023\/05\/10\/fast-audio-codecs-for-microcontrollers\/","og_locale":"en_US","og_type":"article","og_title":"Fast Audio Codecs for Microcontrollers - Phil Schatzmann","og_description":"My AudioTools project is supporting quite a few audio encoders and decoders. They are critical to reduce the storage or transmission volume of audio. Though I support the encoding of AAC and MP3, I can&#8217;t really recommend this: it requires a lot of memory and processing time. For an introduction [&hellip;]","og_url":"https:\/\/www.pschatzmann.ch\/home\/2023\/05\/10\/fast-audio-codecs-for-microcontrollers\/","og_site_name":"Phil Schatzmann","article_published_time":"2023-05-10T12:02:27+00:00","article_modified_time":"2024-03-21T08:44:17+00:00","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\/05\/10\/fast-audio-codecs-for-microcontrollers\/#article","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/05\/10\/fast-audio-codecs-for-microcontrollers\/"},"author":{"name":"pschatzmann","@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"headline":"Fast Audio Codecs for Microcontrollers","datePublished":"2023-05-10T12:02:27+00:00","dateModified":"2024-03-21T08:44:17+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/05\/10\/fast-audio-codecs-for-microcontrollers\/"},"wordCount":277,"commentCount":3,"publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"keywords":["Codecs","Communications","UNO"],"articleSection":["Arduino","Machine Sound"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pschatzmann.ch\/home\/2023\/05\/10\/fast-audio-codecs-for-microcontrollers\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/05\/10\/fast-audio-codecs-for-microcontrollers\/","url":"https:\/\/www.pschatzmann.ch\/home\/2023\/05\/10\/fast-audio-codecs-for-microcontrollers\/","name":"Fast Audio Codecs for Microcontrollers - Phil Schatzmann","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#website"},"datePublished":"2023-05-10T12:02:27+00:00","dateModified":"2024-03-21T08:44:17+00:00","breadcrumb":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/05\/10\/fast-audio-codecs-for-microcontrollers\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pschatzmann.ch\/home\/2023\/05\/10\/fast-audio-codecs-for-microcontrollers\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/05\/10\/fast-audio-codecs-for-microcontrollers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pschatzmann.ch\/home\/"},{"@type":"ListItem","position":2,"name":"Fast Audio Codecs 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\/5661","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=5661"}],"version-history":[{"count":22,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/5661\/revisions"}],"predecessor-version":[{"id":6175,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/5661\/revisions\/6175"}],"wp:attachment":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media?parent=5661"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/categories?post=5661"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/tags?post=5661"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}