{"id":4963,"date":"2022-09-17T14:12:58","date_gmt":"2022-09-17T12:12:58","guid":{"rendered":"https:\/\/www.pschatzmann.ch\/home\/?p=4963"},"modified":"2022-10-08T11:57:32","modified_gmt":"2022-10-08T09:57:32","slug":"arduino-audio-tools-a-multiuser-audio-webserver","status":"publish","type":"post","link":"https:\/\/www.pschatzmann.ch\/home\/2022\/09\/17\/arduino-audio-tools-a-multiuser-audio-webserver\/","title":{"rendered":"Arduino Audio Tools &#8211; Creating A Multiuser Audio Webserver"},"content":{"rendered":"<p>Quite some time ago I was playing with the idea that it should be quite easy to implement a <strong>web server<\/strong> in Arduino that provides the <strong>same audio signal to multiple users<\/strong>. All that needs to be done is register new connections and close them when the user closes the browser window. Then we just need to copy the same data to all open connections. That&#8217;s how my <strong><a href=\"https:\/\/github.com\/pschatzmann\/TinyHttp\">TinyHttp (Audio) Server<\/a><\/strong> got started.<\/p>\n<p>This week I decided to <strong>finish and release the project<\/strong> and provide a nice integration to my <strong><a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-tools\">Arduino Audio Tools<\/a><\/strong>.<\/p>\n<h2>Arduino Sketch<\/h2>\n<p>The new server can be treated like any other Audio Sketch: We create a source, the web server as sink and a copier to copy the data from the source to the sink:<\/p>\n<pre><code>#include \"AudioTools.h\"\n#include \"AudioLibs\/AudioServerEx.h\"\n\n\/\/ WIFI\nconst char *ssid = \"SSID\";\nconst char *password = \"password\";\nconst int sample_rate = 10000;\nconst int channels = 1;\n\nSineWaveGenerator&lt;int16_t&gt; sineWave;            \/\/ Subclass of SoundGenerator with max amplitude of 32000\nGeneratedSoundStream&lt;int16_t&gt; in(sineWave);     \/\/ Stream generated from sine wave\nAudioWAVServerEx server;\nStreamCopy copier(server, in);  \/\/ copy gen to server\n\n\nvoid setup() {\n  Serial.begin(115200);\n  AudioLogger::instance().begin(Serial,AudioLogger::Info);\n  HttpLogger.setLevel(tinyhttp::Info);\n\n  \/\/ start server\n  auto cfg = server.defaultConfig();\n  cfg.sample_rate = sample_rate;\n  cfg.channels = channels;\n  cfg.ssid = ssid;\n  cfg.password = password; \n  server.begin(cfg);\n\n  \/\/ start generation of sound\n  sineWave.begin(channels, sample_rate, N_B4);\n  in.begin();\n}\n\n\n\/\/ copy the data\nvoid loop() {\n  copier.copy(); \/\/ copy data to server\n  server.copy(); \/\/ from server to client\n}\n\n<\/code><\/pre>\n<p>Just open your web browser and type in the indicated address and then you and anybody else can hear the generated sine signal&#8230;<\/p>\n<h2>Source Code<\/h2>\n<p>The <a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-tools\/tree\/main\/examples\/examples-webserver\">source code and further examples<\/a> be found on <strong>Github<\/strong>: Just select the examples that end with <strong>serverex<\/strong><\/p>\n<h2>Dependencies<\/h2>\n<p>You need to install the following libraries:<\/p>\n<ul>\n<li>https:\/\/github.com\/pschatzmann\/arduino-audio-tools<\/li>\n<li>https:\/\/github.com\/pschatzmann\/TinyHttp.git<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Quite some time ago I was playing with the idea that it should be quite easy to implement a web server in Arduino that provides the same audio signal to multiple users. All that needs to be done is register new connections and close them when the user closes the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2289,"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":[37],"class_list":["post-4963","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-machine-sound","tag-tinyhttp"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Arduino Audio Tools - Creating A Multiuser Audio Webserver - 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\/09\/17\/arduino-audio-tools-a-multiuser-audio-webserver\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Arduino Audio Tools - Creating A Multiuser Audio Webserver - Phil Schatzmann\" \/>\n<meta property=\"og:description\" content=\"Quite some time ago I was playing with the idea that it should be quite easy to implement a web server in Arduino that provides the same audio signal to multiple users. All that needs to be done is register new connections and close them when the user closes the [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pschatzmann.ch\/home\/2022\/09\/17\/arduino-audio-tools-a-multiuser-audio-webserver\/\" \/>\n<meta property=\"og:site_name\" content=\"Phil Schatzmann\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-17T12:12:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-10-08T09:57:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2020\/12\/http.jpeg\" \/>\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\/jpeg\" \/>\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\\\/2022\\\/09\\\/17\\\/arduino-audio-tools-a-multiuser-audio-webserver\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/09\\\/17\\\/arduino-audio-tools-a-multiuser-audio-webserver\\\/\"},\"author\":{\"name\":\"pschatzmann\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"headline\":\"Arduino Audio Tools &#8211; Creating A Multiuser Audio Webserver\",\"datePublished\":\"2022-09-17T12:12:58+00:00\",\"dateModified\":\"2022-10-08T09:57:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/09\\\/17\\\/arduino-audio-tools-a-multiuser-audio-webserver\\\/\"},\"wordCount\":200,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/09\\\/17\\\/arduino-audio-tools-a-multiuser-audio-webserver\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/http.jpeg\",\"keywords\":[\"TinyHttp\"],\"articleSection\":[\"Arduino\",\"Machine Sound\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/09\\\/17\\\/arduino-audio-tools-a-multiuser-audio-webserver\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/09\\\/17\\\/arduino-audio-tools-a-multiuser-audio-webserver\\\/\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/09\\\/17\\\/arduino-audio-tools-a-multiuser-audio-webserver\\\/\",\"name\":\"Arduino Audio Tools - Creating A Multiuser Audio Webserver - Phil Schatzmann\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/09\\\/17\\\/arduino-audio-tools-a-multiuser-audio-webserver\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/09\\\/17\\\/arduino-audio-tools-a-multiuser-audio-webserver\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/http.jpeg\",\"datePublished\":\"2022-09-17T12:12:58+00:00\",\"dateModified\":\"2022-10-08T09:57:32+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/09\\\/17\\\/arduino-audio-tools-a-multiuser-audio-webserver\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/09\\\/17\\\/arduino-audio-tools-a-multiuser-audio-webserver\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/09\\\/17\\\/arduino-audio-tools-a-multiuser-audio-webserver\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/http.jpeg\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/http.jpeg\",\"width\":225,\"height\":225},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/09\\\/17\\\/arduino-audio-tools-a-multiuser-audio-webserver\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Arduino Audio Tools &#8211; Creating A Multiuser Audio Webserver\"}]},{\"@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":"Arduino Audio Tools - Creating A Multiuser Audio Webserver - 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\/09\/17\/arduino-audio-tools-a-multiuser-audio-webserver\/","og_locale":"en_US","og_type":"article","og_title":"Arduino Audio Tools - Creating A Multiuser Audio Webserver - Phil Schatzmann","og_description":"Quite some time ago I was playing with the idea that it should be quite easy to implement a web server in Arduino that provides the same audio signal to multiple users. All that needs to be done is register new connections and close them when the user closes the [&hellip;]","og_url":"https:\/\/www.pschatzmann.ch\/home\/2022\/09\/17\/arduino-audio-tools-a-multiuser-audio-webserver\/","og_site_name":"Phil Schatzmann","article_published_time":"2022-09-17T12:12:58+00:00","article_modified_time":"2022-10-08T09:57:32+00:00","og_image":[{"width":225,"height":225,"url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2020\/12\/http.jpeg","type":"image\/jpeg"}],"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\/2022\/09\/17\/arduino-audio-tools-a-multiuser-audio-webserver\/#article","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/09\/17\/arduino-audio-tools-a-multiuser-audio-webserver\/"},"author":{"name":"pschatzmann","@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"headline":"Arduino Audio Tools &#8211; Creating A Multiuser Audio Webserver","datePublished":"2022-09-17T12:12:58+00:00","dateModified":"2022-10-08T09:57:32+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/09\/17\/arduino-audio-tools-a-multiuser-audio-webserver\/"},"wordCount":200,"commentCount":2,"publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/09\/17\/arduino-audio-tools-a-multiuser-audio-webserver\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2020\/12\/http.jpeg","keywords":["TinyHttp"],"articleSection":["Arduino","Machine Sound"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pschatzmann.ch\/home\/2022\/09\/17\/arduino-audio-tools-a-multiuser-audio-webserver\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/09\/17\/arduino-audio-tools-a-multiuser-audio-webserver\/","url":"https:\/\/www.pschatzmann.ch\/home\/2022\/09\/17\/arduino-audio-tools-a-multiuser-audio-webserver\/","name":"Arduino Audio Tools - Creating A Multiuser Audio Webserver - Phil Schatzmann","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/09\/17\/arduino-audio-tools-a-multiuser-audio-webserver\/#primaryimage"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/09\/17\/arduino-audio-tools-a-multiuser-audio-webserver\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2020\/12\/http.jpeg","datePublished":"2022-09-17T12:12:58+00:00","dateModified":"2022-10-08T09:57:32+00:00","breadcrumb":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/09\/17\/arduino-audio-tools-a-multiuser-audio-webserver\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pschatzmann.ch\/home\/2022\/09\/17\/arduino-audio-tools-a-multiuser-audio-webserver\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/09\/17\/arduino-audio-tools-a-multiuser-audio-webserver\/#primaryimage","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2020\/12\/http.jpeg","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2020\/12\/http.jpeg","width":225,"height":225},{"@type":"BreadcrumbList","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/09\/17\/arduino-audio-tools-a-multiuser-audio-webserver\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pschatzmann.ch\/home\/"},{"@type":"ListItem","position":2,"name":"Arduino Audio Tools &#8211; Creating A Multiuser Audio Webserver"}]},{"@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\/4963","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=4963"}],"version-history":[{"count":13,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/4963\/revisions"}],"predecessor-version":[{"id":4976,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/4963\/revisions\/4976"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media\/2289"}],"wp:attachment":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media?parent=4963"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/categories?post=4963"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/tags?post=4963"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}