Daisy performance

Posted this on the slack, but thought I’d post here to get some feedback regarding some issues I am having with the speed of my c++ patch. The example below illustrates the issue. In the processing of each sample, I perform 20 floating point additions. As a result, I get a low-level 3kHz whine in both channels. In testing, I can lower the bit rate, but that just lowers the pitch of the whine. Is this asking too much of the Daisy to do that much processing per sample?

In my actual patch, I don’t do 20 operations per sample. I do 4 multiply/divide operations and 2 additions per sample, also writing samples into a couple of line buffers but I was having trouble with the noise. So I have narrowed it down to the fact that I am just spending too much processing time for each sample…

Any suggestions or advice would be welcome.

#include "daisy_pod.h"

using namespace daisy;

DaisyPod hw;

int32_t lineIndex;
float debugNum;

static void audio(AudioHandle::InterleavingInputBuffer in,
                  AudioHandle::InterleavingOutputBuffer out,
                  size_t size)
{
    // Audio Loop
    for (size_t i = 0; i < size; i += 2)
    {
        // this section introduces a lag that causes a 3kHz whine in the output
        for (lineIndex= 0; lineIndex < 20; ++lineIndex)
        {
            debugNum+= lineIndex;
        }

        // copy in to out.
        out[i] = in[i];
        out[i + 1] = in[i+1];
    }
}

int main(void)
{

    hw.Init();
    // Start Callbacks
    hw.StartAdc();
    hw.StartAudio(audio);
    while (1)
    {
    }
}

Hi @shhQuiet , welcome on the forums!

The whine that you hear is a well known issue. It’s not a sign of high processing load. What happens is that the processor does short bursts of processing for each block of audio, during which it consumes more power than the time in between. These short bursts of higher power consumption result in current spikes and noise on the power rails, which eventually feeds back u to the analog circuitry on the inputs and outputs

There are two things you can do to reduce the whine:

  1. Make the power consumption more continuous by reducing the block size of the audio callback.
  2. Improve the power delivery circuit so that the spikes in power consumption can’t feed back into the audio circuitry.

Block size reduction can be a quick and dirty solution, but it comes at the cost of less efficient processing => the processor spends more time jumping in and out of functions and doing other housekeeping. That limits how much actual processing you can do.
2. Is the better long term solution, but to help you, we would need to know a bit more about your current setup. Is it an official Electro-Smith device or your own circuit? If so, can you share a schematic?

Hey, thanks for your reply! Well, good to know that this is a known issue (I guess?) - I am using the Electro-smith Pod with the Daisy. I am powering it with USB from my iMac and I’m also using the STLink debugger, also plugged into the iMac. Running line-level audio from a Scarlett Solo audio interface and playing back through some small speakers.

Maybe it would help if I tried using a USB switched mode power supply rather than using the computer. I have a clean linear power supply as well, but that seems like overkill for this application and I’d rather not use batteries. I have been thinking about getting a Petal or a Patch- I just got the Pod to try my hand at writing some DSP code. I do like the results I have been getting so far (except for the noise), so maybe it’s time to upgrade.

I assume the Petal and Patch have a clean supply and this is not an issue there. In the meantime, I’ll try reducing the block size. Thanks again for the advice!

Since you’re using an STLink already, try powering the Daisy from a USB-wallwart first. That could already reduce the noise considerably. It sounds a bit like a ground loop problem to me.

Unfortunately, the Petal and Patch also have some residual noise. It’s probably much less than you experience, but it’s noticable. You can search the forums for more advice. The processor on the Daisy Seed is quite a beast, sadly also in terms of power consumption and “emitted power rail noise”.

I have tried it already using a wall wart and I reduced the block size to 24 (from 96) and the noise has decreased quite a bit. Thanks for this advice!

Hi @TheSlowGrowth I read with great interest the answer about the famous whistle. I also have the same problem and I am fighting it with the BlockSize method, but it is my intention to fix it at the HW level.
I built a pedal starting from the Petal diagrams and I would like to understand how to modify the circuit to eliminate the whistle problem, as for example on the Daisy Patch where it seems not to be there.
Have you managed to figure out how to improve the circuits to eliminate this problem?
A thousand thanks

We had a lot of discussion in the daisy slack about this, here is a link to one of these threads.

I’ll post a part of my reply from that thread here, but before I do that, please note that my knowledge is also limited. I have a diploma in electrical engineering and >10y of synth DIY experience, but my hands on experience with the daisy is not deep enough to really give you specific guidelines and best practices. I think @shensley or @raf can probably give you some more practical hints and tips. What I can try to contribute is a more theoretical understanding of where the noise comes from and how it could be eliminated.

That being said, here is my reply from the slack thread:

The seed pulls current from the power rails as needed and that current is not continuous, it varies depending on what the circuitry inside the chip is doing. All current that enters the positive power pin eventually leaves the Seed through the negative power pin and flows back to the power supply through the ground wires. This is what’s called a return current.

This can be mitigated by lowering the blocksize

Sure, you can spread the processing load to make the currents less “spikey” == less audible. But that is close to impossible to achieve unless you’re willing to completely destroy the structure of your software code (by artificially spreading code execution out and making it pretty much unmaintainable and unreadable) - or reduce the block size and live with the reduced processing power (!).
This is not a real solution, more of a hack, IMHO.

The better, safer, cleaner way of dealing with this problem is to make sure that the return currents take a path that doesn’t affect the GND referencing in the circuit. As I wrote in my last post, that is:

  • the current passes through a dedicated wire back to the power supply so that the voltage delta it produces doesn’t affect the GND references (star ground)
  • The GND traces are thick and have low resistance (reducing the voltage delta that the current can generate)
  • the current passes straight back into low ESR bulk capacitance located close to the power pins (high quality bypass caps)
  • The current doesn’t even pass through the GND at all, e.g. by generating the 5V from -12V and 12V as done on the Daisy Patch

And from another reply in that thread:

If you draw yourself a little diagram of the GND connections in your circuit, you can trace how the parts connect together and where they share a GND connection. The problem is that any current in a conductor results in a little voltage fluctuation across the conductor (Ohms law). If you imagine the following situation:

Audio Jack GND --------------------+--------- Power connector
                                   /
 Seed AGND -----\                 /
                 \               /
 Seed DGND -------+-------------/

Now think about where currents flow through the system:
Any power supply return current flowing out of the Seed DGND back into the power connector will create a little voltage delta along the path it takes (imagine the traces as a string of very small resistors). The Seed AGND shares a lot of the distance with those noisy digital return currents. That means that the voltage delta introduced by the DGND return current will also be visible when you measure the voltage between the Seed AGND pin and the power connector. More critically, though: The voltage delta will also be present between the Audio Jack GND and the AGND, meaning that your audio signal will be noisy: The equipment plugged into the jack will measure the audio signal relative to the jacks GND pin and the DAC on the Daisy will output the signal relative to its AGND pin, but there’s this voltage delta between the two. There’s your source of noise.

You can reduce the effects by:

  • making the ground traces thicker => less resistance => less voltage delta. This will however push some of the noise back into the rest of the world, e.g. your eurorack power bus (which als has a nonzero resistance and has the same voltage-delta-problem between its various modules)
  • reducing the noise in the DGND return current, thus reducing the voltage delta towards a small, inaudible DC offset
    • You can do this by spreading the processing load of the Daisy (as suggested by reducing the block size)
    • You can do this by adding bypass caps really close to the Daisy Seeds supply pins, so that the return current spikes out of the DGND pin can flow through the capacitor instead of directly going back into the power input. To reduce the effect even more, you can connect that capacitor directly to the 3.3V and DGND pins, and add a small resistor (e.g. 10 Ohms) between the 3.3V and the power supply. This will make the currents prefer the path through the capacitor instead of the path through the power supply. In addition you should pick a capacitor with a low ESR (equivalent series resistance) so that the return current prefers the path through the capacitor even more.
  • separating the return current paths such that the voltage delta created in one path doesn’t affect the other path => this is commonly referred to as a “star connection” or “star GND”

All of the above can be combined. It’s good practice to always do the start grounding pattern and additionally provide low ESR bypass capacitors to each of the components for exactly these reasons.

Thanks a lot for your reply. I’ll try each advice!!

For what it’s worth, I have always powered my Daisy Patch with a generous amount of linear power through big bus bars with well though out system grounding and have never had any whine.

Certain daisy PCB’s are probably more or less vulnerable and of course issues there will probably overshadow any system power. I have seen a certain 3rd party daisy guitar pcb that is horribly laid out. And made a few heads angry explaining this on their forum once.

But they designed in a way that perfectly articulates theslowgrowth’s explanation. In that design, the grounding leaves multiples paths for loops and even if the plane is big and sends most things right out, I would guess that the spikes he’s referring to pop up right as he says, causing the whine they complain about.

1 Like