{"id":6556,"date":"2025-01-19T15:22:01","date_gmt":"2025-01-19T14:22:01","guid":{"rendered":"https:\/\/www.pschatzmann.ch\/home\/?p=6556"},"modified":"2025-01-20T19:33:29","modified_gmt":"2025-01-20T18:33:29","slug":"audio-tools-mixing-effects-with-the-input-signal","status":"publish","type":"post","link":"https:\/\/www.pschatzmann.ch\/home\/2025\/01\/19\/audio-tools-mixing-effects-with-the-input-signal\/","title":{"rendered":"arduino-audio-tools: Mixing Effects with the Input Signal"},"content":{"rendered":"<p>Yesterday, a user was proposing an Arduino Sketch for a Guitar Effects Pedal which is <strong>mixing the original input with an effect<\/strong>. Setting up a simple effect is easy, but I have never thought about how to mix the effect with the original input. He was proposing the following process chain (which I think is just ingenious):<\/p>\n<pre><code>                               |-&gt; AudioEffectStream --| \nI2SStream -copy-&gt; MultiOutput -|                       |-&gt; OutputMixer -&gt; I2SStream\n                               |-----------------------|\n\n<\/code><\/pre>\n<p>It took me quite some time to figure out why this is not working: The OutputMixer requires consistent write sizes of all it&#8217;s input components and the AudioEffectStream seemed to be writing individual samples. Fortunately this can be easily fixed by adding a buffer into the chain:<\/p>\n<pre><code>                 |-&gt; AudioEffectStream -&gt; BufferedStream --| \n... MultiOutput -|                                         |-&gt; OutputMixer ...\n                 |-&gt; BufferedStream -----------------------|\n\n<\/code><\/pre>\n<p>The BufferedStream makes sure that the OutputMixer gets fed with a consistent number of samples.<\/p>\n<p>The corresponding sketch for a <strong>LyraT<\/strong> board look as follows:<\/p>\n<pre><code><br \/>#include \"AudioTools.h\"\n#include \"AudioTools\/AudioLibs\/AudioSTK.h\"\n#include \"AudioTools\/AudioLibs\/AudioBoardStream.h\"\n\nAudioInfo info(44100, 2, 16);\nAudioBoardStream i2s(LyratV43);  \/\/ or use I2SStream\nMultiOutput split;\nOutputMixer&lt;int16_t&gt; mixer(i2s, 2);  \/\/ output mixer with 2 outputs\nBufferedStream effects_buffer(1024, mixer);\nBufferedStream direct_buffer(1024, mixer);\nAudioEffectStream effects(effects_buffer);\nStreamCopy copier(split, i2s, 1024); \/\/ copy i2sStream \nFuzz fuzz(6.5, 500);\nSTKChorus chorus(6000);\nPitchShift pitch(0.5);\nBoost boost(1.0);\n\n\/\/ Arduino Setup\nvoid setup(void) {\n  Serial.begin(115200);\n  AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);\n\n  \/\/ setup multioutput\n  split.add(effects);\n  split.add(direct_buffer);\n\n  \/\/ setup effects\n  \/\/effects.addEffect(fuzz);\n  \/\/effects.addEffect(chorus);\n  \/\/effects.addEffect(boost);\n  \/\/effects.addEffect(pitch);\n  effects.begin(info);\n\n  \/\/ setup i2s\n  auto cfg = i2s.defaultConfig(RXTX_MODE);\n  cfg.copyFrom(info);\n  cfg.sd_active = false;\n  cfg.input_device = ADC_INPUT_LINE2;\n  cfg.buffer_size = 256;\n  cfg.buffer_count = 3;\n  i2s.begin(cfg);\n  i2s.setVolume(1.0);\n\n  \/\/ setup mixer\n  \/\/mixer.setWeight(0, 1.0); \/\/ dynamically adjust weights\n  \/\/mixer.setWeight(1, 1.0);\n  mixer.begin(1024);\n}\n\n\/\/ Arduino loop - copy data\nvoid loop() {\n  copier.copy();\n}\n<\/code><\/pre>\n<p>I was selecting the LyraT because there it is possible to define the aux input source properly.<\/p>\n<p>It might be a good idea to replace the 1024 values that are scattered across the Sketch with one constant that is defined in the beginning. I have the gut feeling that it&#8217;s possible to decrease this value to optimize the RAM use.<\/p>\n<p>I am still impressed that it is possible to write such a complex logic with only 50 lines!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Yesterday, a user was proposing an Arduino Sketch for a Guitar Effects Pedal which is mixing the original input with an effect. Setting up a simple effect is easy, but I have never thought about how to mix the effect with the original input. He was proposing the following process [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4313,"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":[20,22],"tags":[],"class_list":["post-6556","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-machine-sound"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>arduino-audio-tools: Mixing Effects with the Input Signal - 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\/01\/19\/audio-tools-mixing-effects-with-the-input-signal\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"arduino-audio-tools: Mixing Effects with the Input Signal - Phil Schatzmann\" \/>\n<meta property=\"og:description\" content=\"Yesterday, a user was proposing an Arduino Sketch for a Guitar Effects Pedal which is mixing the original input with an effect. Setting up a simple effect is easy, but I have never thought about how to mix the effect with the original input. He was proposing the following process [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pschatzmann.ch\/home\/2025\/01\/19\/audio-tools-mixing-effects-with-the-input-signal\/\" \/>\n<meta property=\"og:site_name\" content=\"Phil Schatzmann\" \/>\n<meta property=\"article:published_time\" content=\"2025-01-19T14:22:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-01-20T18:33:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/01\/esp32_lyrat.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"540\" \/>\n\t<meta property=\"og:image:height\" content=\"540\" \/>\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\\\/2025\\\/01\\\/19\\\/audio-tools-mixing-effects-with-the-input-signal\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/01\\\/19\\\/audio-tools-mixing-effects-with-the-input-signal\\\/\"},\"author\":{\"name\":\"pschatzmann\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"headline\":\"arduino-audio-tools: Mixing Effects with the Input Signal\",\"datePublished\":\"2025-01-19T14:22:01+00:00\",\"dateModified\":\"2025-01-20T18:33:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/01\\\/19\\\/audio-tools-mixing-effects-with-the-input-signal\\\/\"},\"wordCount\":214,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/01\\\/19\\\/audio-tools-mixing-effects-with-the-input-signal\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/esp32_lyrat.jpg\",\"articleSection\":[\"Arduino\",\"Machine Sound\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/01\\\/19\\\/audio-tools-mixing-effects-with-the-input-signal\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/01\\\/19\\\/audio-tools-mixing-effects-with-the-input-signal\\\/\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/01\\\/19\\\/audio-tools-mixing-effects-with-the-input-signal\\\/\",\"name\":\"arduino-audio-tools: Mixing Effects with the Input Signal - Phil Schatzmann\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/01\\\/19\\\/audio-tools-mixing-effects-with-the-input-signal\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/01\\\/19\\\/audio-tools-mixing-effects-with-the-input-signal\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/esp32_lyrat.jpg\",\"datePublished\":\"2025-01-19T14:22:01+00:00\",\"dateModified\":\"2025-01-20T18:33:29+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/01\\\/19\\\/audio-tools-mixing-effects-with-the-input-signal\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/01\\\/19\\\/audio-tools-mixing-effects-with-the-input-signal\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/01\\\/19\\\/audio-tools-mixing-effects-with-the-input-signal\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/esp32_lyrat.jpg\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/esp32_lyrat.jpg\",\"width\":540,\"height\":540},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2025\\\/01\\\/19\\\/audio-tools-mixing-effects-with-the-input-signal\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"arduino-audio-tools: Mixing Effects with the Input Signal\"}]},{\"@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: Mixing Effects with the Input Signal - 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\/01\/19\/audio-tools-mixing-effects-with-the-input-signal\/","og_locale":"en_US","og_type":"article","og_title":"arduino-audio-tools: Mixing Effects with the Input Signal - Phil Schatzmann","og_description":"Yesterday, a user was proposing an Arduino Sketch for a Guitar Effects Pedal which is mixing the original input with an effect. Setting up a simple effect is easy, but I have never thought about how to mix the effect with the original input. He was proposing the following process [&hellip;]","og_url":"https:\/\/www.pschatzmann.ch\/home\/2025\/01\/19\/audio-tools-mixing-effects-with-the-input-signal\/","og_site_name":"Phil Schatzmann","article_published_time":"2025-01-19T14:22:01+00:00","article_modified_time":"2025-01-20T18:33:29+00:00","og_image":[{"width":540,"height":540,"url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/01\/esp32_lyrat.jpg","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\/2025\/01\/19\/audio-tools-mixing-effects-with-the-input-signal\/#article","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/01\/19\/audio-tools-mixing-effects-with-the-input-signal\/"},"author":{"name":"pschatzmann","@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"headline":"arduino-audio-tools: Mixing Effects with the Input Signal","datePublished":"2025-01-19T14:22:01+00:00","dateModified":"2025-01-20T18:33:29+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/01\/19\/audio-tools-mixing-effects-with-the-input-signal\/"},"wordCount":214,"commentCount":0,"publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/01\/19\/audio-tools-mixing-effects-with-the-input-signal\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/01\/esp32_lyrat.jpg","articleSection":["Arduino","Machine Sound"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pschatzmann.ch\/home\/2025\/01\/19\/audio-tools-mixing-effects-with-the-input-signal\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/01\/19\/audio-tools-mixing-effects-with-the-input-signal\/","url":"https:\/\/www.pschatzmann.ch\/home\/2025\/01\/19\/audio-tools-mixing-effects-with-the-input-signal\/","name":"arduino-audio-tools: Mixing Effects with the Input Signal - Phil Schatzmann","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/01\/19\/audio-tools-mixing-effects-with-the-input-signal\/#primaryimage"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/01\/19\/audio-tools-mixing-effects-with-the-input-signal\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/01\/esp32_lyrat.jpg","datePublished":"2025-01-19T14:22:01+00:00","dateModified":"2025-01-20T18:33:29+00:00","breadcrumb":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/01\/19\/audio-tools-mixing-effects-with-the-input-signal\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pschatzmann.ch\/home\/2025\/01\/19\/audio-tools-mixing-effects-with-the-input-signal\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/01\/19\/audio-tools-mixing-effects-with-the-input-signal\/#primaryimage","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/01\/esp32_lyrat.jpg","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/01\/esp32_lyrat.jpg","width":540,"height":540},{"@type":"BreadcrumbList","@id":"https:\/\/www.pschatzmann.ch\/home\/2025\/01\/19\/audio-tools-mixing-effects-with-the-input-signal\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pschatzmann.ch\/home\/"},{"@type":"ListItem","position":2,"name":"arduino-audio-tools: Mixing Effects with the Input Signal"}]},{"@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\/6556","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=6556"}],"version-history":[{"count":14,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/6556\/revisions"}],"predecessor-version":[{"id":6570,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/6556\/revisions\/6570"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media\/4313"}],"wp:attachment":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media?parent=6556"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/categories?post=6556"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/tags?post=6556"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}