Hansy Synth and Daisy seed

Thank you so much for keeping us posted about this project :slight_smile:
Cool to see a real-time update!

As for your question about block size, digital audio is often handled in blocks rather than acquiring, processing, and delivering one sample at a time. Since the hardware takes a little bit of extra time to set up the transaction to acquire and deliver new samples, working in block is more efficient. With block size, you can be filling a new group of samples while the last group is being sent through the hardware.

Therefore, increasing the block size will take a load off on your CPU (which means less chance of those noise happening) but will introduce more latency as you may have noticed. And vice versa. This is similar to working with the buffer size in your DAW.
So, you can try finding a good balance between latency and CPU load for your project.

You can also measure the CPU to see what’s taking up the load most if you want to optimize for lowest latency as possible.

#include "daisy_seed.h"
#include "daisysp.h"
using namespace daisy;
DaisySeed hw;
CpuLoadMeter loadMeter;

void MyCallback(AudioHandle::InputBuffer in, 
                AudioHandle::OutputBuffer out, 
                size_t size) 
{
    loadMeter.OnBlockStart();
    for (size_t i = 0; i < size; i++)
    {
        // add your processing here
        out[0][i] = 0.0f;
        out[1][i] = 0.0f;
    }
    loadMeter.OnBlockEnd();
}
int main(void)
{
    hw.Init();

    // start logging to the serial connection
    hw.StartLog();

    // initialize the load meter so that it knows what time is available for the processing:
    loadMeter.Init(hw.AudioSampleRate(), hw.AudioBlockSize());

    // start the audio processing callback
    hw.StartAudio(MyCallback);

    while(1) {
        // get the current load (smoothed value and peak values)
        const float avgLoad = cpuLoadMeter.GetAvgCpuLoad();
        const float maxLoad = cpuLoadMeter.GetMaxCpuLoad();
        const float minLoad = cpuLoadMeter.GetMinCpuLoad();
        // print it to the serial connection (as percentages)
        hw.PrintLine("Processing Load %:");
        hw.PrintLine("Max: " FLT_FMT3, FLT_VAR3(maxLoad * 100.0f));
        hw.PrintLine("Avg: " FLT_FMT3, FLT_VAR3(avgLoad * 100.0f));
        hw.PrintLine("Min: " FLT_FMT3, FLT_VAR3(minLoad * 100.0f));
        // don't spam the serial connection too much
        System::Delay(500);
    }
}