Learn Arduino Guitar Effects with me. Project 1 - Audio Pass Through

Hi everyone.
I’m going to start off by saying that I’m a VERY amateur programmer and brand new into DSP. After building a bunch of analog guitar effects over the years, I caught wind of the Daisy Seed and thought that it would be fun to tinker around with. However, there are very few resources on learning how to program it. The mods on this forum seem to be active and very helpful, but I believe they’re putting most of their resources into improving the Daisy.
I’m still learning C++ and I have some Arduino experience, so I figured I’d start out with that. If you have limited programming experience (like myself) and opened up an example, you’ll see that very few of them have comments and can be confusing. I may not be the best or most capable, but I believe that contributing something, however basic, is better than not contributing at all. To build a better and lasting community, we need to help out the newbies.

My goal is to help newer people to read and understand the code, and also to be able to pick apart and dissect examples to create their own stuff.

I’m assuming that you were able to configure Arduino and are able to upload a program to the Seed. I know I had several frustrating hours to get it to work only to find a post in the forum about not installing an updated version of stm32duino.

Getting Started:
When I first hooked up my Daisy Seed to a breadboard and some 1/4" guitar jacks, it was very noisy, low volume, and muddy. This is because the guitar output signal is very low compared to what the Seed can handle. We can fix these problems by making an input and output buffer. The buffer will amplify the signal a bit and block out the noise. There is another post on this forum about buffers, but to make it easy, I just picked up the Terrarium PCB from pedalpcb.com. It works great (however, I don’t have any pots or switches hooked up to it yet!). If you’re brand new to programming, I would highly recommend watching some YouTube videos on basic Arduino or C programming. I’m currently watching this 10 hour video on C++. The young dude is a fantastic intructor and would highly recommend watching it. https://youtu.be/_bYFu9mBnr4

The Code:
Many of the examples use left and right channels. Since we’re here just making single channel guitar effects, we can ignore a lot of the example code. For the first few examples, I’m also going to leave out any potentiometers and switches. We’ll just hard code everything for simplicity. I wrote a very simple input to output straight-through program just to get a ‘boiler plate’ program working. Copy this code into Arduino and upload it to your Seed.

#include <DaisyDuino.h>

DaisyHardware hw;

static void AudioCallback(float *in, float *out, size_t size)
{
  for(size_t i = 0; i < size; i++)
  {
    out[i] = in[i];
  }
}


void setup() {

  hw = DAISY.init(DAISY_PETAL, AUDIO_SR_48K);

  DAISY.begin(AudioCallback);

}

void loop() {
  // put your main code here, to run repeatedly:

}

Great! You should hear your guitar going through the Seed and out into your amp. Now what’s going on? Let’s take it step by step.

#include <DaisyDuino.h>

This statement allows Arduino to access the DaisyDuino header and libraries. The header contains all the necessary stuff to interface and compile the program from Arduino to our Seed.

DaisyHardware hw;

Here, we’re creating an object, hw, of the DaisyHardware Class which is built into the DaisyDuino library. It makes it easier for us to access the class without cumbersome code. We’re going to skip the next section for now and jump to the void setup

void setup() {

  hw = DAISY.init(DAISY_PETAL, AUDIO_SR_48K);

  DAISY.begin(AudioCallback);

}

void loop() {
  // put your main code here, to run repeatedly:

}

So what’s going on here? When an Arduino program runs, the very first thing it does is run through the code in the ‘void setup’ function. It only runs this code once. The next line in this function ‘hw = DAISY.init(DAISY_PETAL, AUDIO_SR_48K);’ is how we’re going to initialize our Seed. It’s going to assign all the input/output pins to be that of a Daisy Pedal (which I don’t have, but the Terrarium is indentical for our purposes) and have a sample rate of 48k.
After that, we need to start processing audio with ‘DAISY.begin(AudioCallback);’ This is going to call the AudioCallback function and run on effectively a loop. Because of this, we don’t need anything in the void loop(){} function, but Arduino requires that loop function to compile.

static void AudioCallback(float *in, float *out, size_t size)
{
  for(size_t i = 0; i < size; i++)
  {
    out[i] = in[i];
  }
}

To be completely honest, this is magic to me. I’ve looked around and there are virtually no references on what really goes on inside the DaisyDuino. I’m sure if you dig deep enough you can find a better explanation, but for now, realize that you need this code to make any program to work.
As far as I can tell, when you call the AudioCallback function using DAISY.begin, it defines in and out as floats. The * points to a location, which I assume is defined in the header as the input and output pins. The program runs this function whenever it has audio to process. I haven’t figured out what the ‘size_t size’ does yet, but you need it for the subsequent ‘for’ loop. Inside that ‘for’ loop is what actually processes our code. In this instance, we’re just making the output to be equal to the input by doing ‘out[i] = in[i];’

So we walked through our first, simple program, but I’m not too happy with it. Fidelity is pretty good, latency is not noticable at all, but I found the output volume a bit too low. Let’s fix that with a quick adjustment.

out[i] = in[i] * 2;

There we go. The volume on the amp is about the same if I have my guitar plugged in through the Seed or not. Next, let’s make a simple distortion effect!

3 Likes

Hey man, I’m still waiting on my Petal, but just to let you know, got the notification for this thread today in my e-mail and very stoked that you started something like this. Once I get my Petal I’ll join with what you’re doing here, I started to explore Max 8 and bought myself the crossover version of Max from M4L, but I’ll be glad to switch topics back and forth to get into this Arduino coding with you. I’m also interested in making guitar pedal effects with this thing so I’ll stay tuned to what you post on the forum. Super noob myself, so very happy to see you took the initiative to start a thread like this.

1 Like

Sorry I’m a bit late with this follow up. I just copied and pasted the text into my Arduino IDE, uploaded the file to my board and it worked like a charm. Audio is heard from my Fender Squier Strat, into the Daisy Petal, and out through my small BOSS Katana amp.

Yes, I did have to format my old Daisy with ZADIG (link to the Github page) on Windows. The new one that I got was already formatted.

This Github page (link) has all the steps for Windows, I followed them and believe my environment has been set up correctly.

For those of you interested in the exact details, I’m running:

  1. A Windows 7 Ultimate SP1 (aka Service Pack 1) 64-bit OS.

  2. Arduino IDE
    Version: 2.0.0-beta.7
    Date: 2021-05-17T10:10:22.608Z (1 month ago)
    CLI Version: 0.18.3 alpha [d710b642]

  3. My Arduino settings for upload are:

In the “Boards Manager”, I have marked as “INSTALLED” the [DEPRECATED] Ver 1.9.0 of the STMicroelectronics library for Generic STM microcontrollers. (Important! As the newer version gave me issues, haven’t checked for a new version with a fix for this yet, this is a known issue)

In the “Library Manager”, the DaisyDuino by stephenhensley Version 1.3.0 is marked as “INSTALLED”.

Under the “Tools” drop-down menu, following these steps:

Tools → Board → [Deprecated] → I selected “Generic STM32H7 Series”

Port → I selected “COM1” in my case.

Board Part Number → I selected “Daisy”

Upload Method → I selected “STM32CubeProgrammer (DFU)”

USB support (if available) → I selected “CDC (generic ‘Serial’ supercede U(S)ART)”

U(S)ART support → I selected “Enabled (generic ‘Serial’)”

USB speed (if available) → I selected “Low/Full Speed”

  1. I held the “Boot” button and clicked the “Reset” button to put the Daisy Seed into upload mode.

  2. Other settings left by default. I hit the upload button and got this screen after 10 seconds.

I was using USB 3.0 to upload and the USB cable was a data cable, not just a power cable. This is a very common mistake since not all USB cables are made the same. I think a “micro USB” cable that came with your smartphone (I think the USB C type cable is becoming more common now though) should be able to do this, but don’t take my word for it.

Hope this helps someone.

1 Like