{"id":6006,"date":"2024-02-07T17:16:43","date_gmt":"2024-02-07T16:16:43","guid":{"rendered":"https:\/\/www.pschatzmann.ch\/home\/?p=6006"},"modified":"2024-03-27T03:32:30","modified_gmt":"2024-03-27T02:32:30","slug":"a-new-library-for-the-audiokit","status":"publish","type":"post","link":"https:\/\/www.pschatzmann.ch\/home\/2024\/02\/07\/a-new-library-for-the-audiokit\/","title":{"rendered":"A new flexible Driver Library for the AudioKit and other Audio Boards"},"content":{"rendered":"<p>So far I used my <a href=\"https:\/\/github.com\/pschatzmann\/arduino-audiokit\">arduino-audiokit<\/a> library together with my <a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-tools\">AudioTools<\/a> when I wanted to work with my <strong>AudioKit board<\/strong>. This library was a just quick and dirty adaptation of the drivers that were made available by the Espressif ADF framework to Arduino. But it had the following major drawbacks<\/p>\n<ul>\n<li>it is <strong>complex<\/strong> and difficult to maintain with many layers and quite a lot of source code files in C<\/li>\n<li>it is <strong>inflexible<\/strong> and you need to change a configuration file if you want to <strong>change the codec<\/strong><\/li>\n<li>it is inflexible if you need to <strong>adapt the pins<\/strong> e.g. for your custom board.<\/li>\n<\/ul>\n<p>I finally took some time this week to write a <a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-driver\">new lean and flexible audio driver library<\/a> that allows to select the codec in the Arduino Sketch and where you can define a new board with just a few lines of code!<\/p>\n<h3>Using a Predefined Board<\/h3>\n<p>Here is an example that shows how to set up the codec and I2S for a <strong>LyratV43<\/strong> board:<\/p>\n<pre><code>#include \"AudioTools.h\"\n#include \"AudioLibs\/I2SCodecStream.h\"\n\nI2SCodecStream i2s(LyratV43);\n\nvoid setup() {\n  \/\/ setup i2s and codec\n  auto cfg = i2s.defaultConfig();\n  cfg.sample_rate = 44100;\n  cfg.bits_per_sample = 16;\n  cfg.channels = 1;\n  i2s.begin();\n\n  \/\/ set volume\n  i2s.setVolume(0.5);\n}  \n<\/code><\/pre>\n<p>You can just specify the <strong>board in the constructor<\/strong> of the I2SCodecStream.<\/p>\n<h3>Defining Your Own Custom Codec Board<\/h3>\n<p>Here is one way to define your <strong>own board<\/strong> with your own pin assignments:<\/p>\n<pre><code>#include \"AudioTools.h\"\n#include \"AudioLibs\/I2SCodecStream.h\"\n\nDriverPins my_pins;\nAudioBoard my_board(AudioDriverES8388, my_pins);\nI2SCodecStream i2s(my_board);\n\nvoid setup() {\n  \/\/ add i2c codec pins: scl, sda, port\n  my_pins.addI2C(CODEC, 32, 22, 0x20);\n  \/\/ add i2s pins: mclk, bclk, ws, data_out, data_in\n  my_pins.addI2S(CODEC, 0, 27, 26, 25, 35);\n  \/\/ add other pins: PA on gpio 21\n  my_pins.addPin(PA, 21);\n\n  \/\/ setup i2s and codec\n  auto cfg = i2s.defaultConfig();\n  cfg.sample_rate = 44100;\n  cfg.bits_per_sample = 16;\n  cfg.channels = 1;\n  i2s.begin();\n\n  \/\/ set volume\n  i2s.setVolume(0.5);\n\n}\n<\/code><\/pre>\n<p>You just define your board which consists of a driver implementation and add your custom pin definitions!<\/p>\n<h2>Further Information<\/h2>\n<p>Further information can be found in<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-driver\">Readme<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-driver\/wiki\">Wiki<\/a><\/li>\n<li><a href=\"https:\/\/pschatzmann.github.io\/arduino-audio-driver\/html\/group__audio__driver.html\">Classes and Objects<\/a><\/li>\n<li><a href=\"https:\/\/pschatzmann.github.io\/arduino-audio-tools\/classaudio__tools_1_1_i2_s_codec_stream.html\">AudioTools Integration<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-driver\/tree\/main\/examples\">Examples<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>So far I used my arduino-audiokit library together with my AudioTools when I wanted to work with my AudioKit board. This library was a just quick and dirty adaptation of the drivers that were made available by the Espressif ADF framework to Arduino. But it had the following major drawbacks [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3882,"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],"class_list":["post-6006","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-machine-sound","tag-codecs"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>A new flexible Driver Library for the AudioKit and other Audio Boards - 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\/2024\/02\/07\/a-new-library-for-the-audiokit\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"A new flexible Driver Library for the AudioKit and other Audio Boards - Phil Schatzmann\" \/>\n<meta property=\"og:description\" content=\"So far I used my arduino-audiokit library together with my AudioTools when I wanted to work with my AudioKit board. This library was a just quick and dirty adaptation of the drivers that were made available by the Espressif ADF framework to Arduino. But it had the following major drawbacks [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pschatzmann.ch\/home\/2024\/02\/07\/a-new-library-for-the-audiokit\/\" \/>\n<meta property=\"og:site_name\" content=\"Phil Schatzmann\" \/>\n<meta property=\"article:published_time\" content=\"2024-02-07T16:16:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-27T02:32:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/12\/audio-toolkit.png\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"500\" \/>\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\\\/2024\\\/02\\\/07\\\/a-new-library-for-the-audiokit\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/02\\\/07\\\/a-new-library-for-the-audiokit\\\/\"},\"author\":{\"name\":\"pschatzmann\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"headline\":\"A new flexible Driver Library for the AudioKit and other Audio Boards\",\"datePublished\":\"2024-02-07T16:16:43+00:00\",\"dateModified\":\"2024-03-27T02:32:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/02\\\/07\\\/a-new-library-for-the-audiokit\\\/\"},\"wordCount\":247,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/02\\\/07\\\/a-new-library-for-the-audiokit\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2021\\\/12\\\/audio-toolkit.png\",\"keywords\":[\"Codecs\"],\"articleSection\":[\"Arduino\",\"Machine Sound\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/02\\\/07\\\/a-new-library-for-the-audiokit\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/02\\\/07\\\/a-new-library-for-the-audiokit\\\/\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/02\\\/07\\\/a-new-library-for-the-audiokit\\\/\",\"name\":\"A new flexible Driver Library for the AudioKit and other Audio Boards - Phil Schatzmann\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/02\\\/07\\\/a-new-library-for-the-audiokit\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/02\\\/07\\\/a-new-library-for-the-audiokit\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2021\\\/12\\\/audio-toolkit.png\",\"datePublished\":\"2024-02-07T16:16:43+00:00\",\"dateModified\":\"2024-03-27T02:32:30+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/02\\\/07\\\/a-new-library-for-the-audiokit\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/02\\\/07\\\/a-new-library-for-the-audiokit\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/02\\\/07\\\/a-new-library-for-the-audiokit\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2021\\\/12\\\/audio-toolkit.png\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2021\\\/12\\\/audio-toolkit.png\",\"width\":800,\"height\":500},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/02\\\/07\\\/a-new-library-for-the-audiokit\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"A new flexible Driver Library for the AudioKit and other Audio Boards\"}]},{\"@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":"A new flexible Driver Library for the AudioKit and other Audio Boards - 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\/2024\/02\/07\/a-new-library-for-the-audiokit\/","og_locale":"en_US","og_type":"article","og_title":"A new flexible Driver Library for the AudioKit and other Audio Boards - Phil Schatzmann","og_description":"So far I used my arduino-audiokit library together with my AudioTools when I wanted to work with my AudioKit board. This library was a just quick and dirty adaptation of the drivers that were made available by the Espressif ADF framework to Arduino. But it had the following major drawbacks [&hellip;]","og_url":"https:\/\/www.pschatzmann.ch\/home\/2024\/02\/07\/a-new-library-for-the-audiokit\/","og_site_name":"Phil Schatzmann","article_published_time":"2024-02-07T16:16:43+00:00","article_modified_time":"2024-03-27T02:32:30+00:00","og_image":[{"width":800,"height":500,"url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/12\/audio-toolkit.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\/2024\/02\/07\/a-new-library-for-the-audiokit\/#article","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2024\/02\/07\/a-new-library-for-the-audiokit\/"},"author":{"name":"pschatzmann","@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"headline":"A new flexible Driver Library for the AudioKit and other Audio Boards","datePublished":"2024-02-07T16:16:43+00:00","dateModified":"2024-03-27T02:32:30+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2024\/02\/07\/a-new-library-for-the-audiokit\/"},"wordCount":247,"commentCount":0,"publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2024\/02\/07\/a-new-library-for-the-audiokit\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/12\/audio-toolkit.png","keywords":["Codecs"],"articleSection":["Arduino","Machine Sound"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pschatzmann.ch\/home\/2024\/02\/07\/a-new-library-for-the-audiokit\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pschatzmann.ch\/home\/2024\/02\/07\/a-new-library-for-the-audiokit\/","url":"https:\/\/www.pschatzmann.ch\/home\/2024\/02\/07\/a-new-library-for-the-audiokit\/","name":"A new flexible Driver Library for the AudioKit and other Audio Boards - Phil Schatzmann","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2024\/02\/07\/a-new-library-for-the-audiokit\/#primaryimage"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2024\/02\/07\/a-new-library-for-the-audiokit\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/12\/audio-toolkit.png","datePublished":"2024-02-07T16:16:43+00:00","dateModified":"2024-03-27T02:32:30+00:00","breadcrumb":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2024\/02\/07\/a-new-library-for-the-audiokit\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pschatzmann.ch\/home\/2024\/02\/07\/a-new-library-for-the-audiokit\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/home\/2024\/02\/07\/a-new-library-for-the-audiokit\/#primaryimage","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/12\/audio-toolkit.png","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/12\/audio-toolkit.png","width":800,"height":500},{"@type":"BreadcrumbList","@id":"https:\/\/www.pschatzmann.ch\/home\/2024\/02\/07\/a-new-library-for-the-audiokit\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pschatzmann.ch\/home\/"},{"@type":"ListItem","position":2,"name":"A new flexible Driver Library for the AudioKit and other Audio Boards"}]},{"@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\/6006","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=6006"}],"version-history":[{"count":11,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/6006\/revisions"}],"predecessor-version":[{"id":6100,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/6006\/revisions\/6100"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media\/3882"}],"wp:attachment":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media?parent=6006"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/categories?post=6006"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/tags?post=6006"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}