March 11, 2021
Setting up and using the Daisy Seed DSP platform on Linux
I recently got hold of Electro-Smith’s powerful Daisy Seed microcontroller board for developing embedded DSP projects. Unfortunately, at the time of writing the libraries for it do not support Platformio fully which is normally my preferred way of working with microcontrollers but fortunately it’s pretty easy to setup and use using make. Here are my notes for doing that.
Install prerequisites (on Arch)
yay -S dfu-util gcc-arm-none-eabi-bin
Setup and build libraries
From the root of your project:
git init
git submodule add https://github.com/electro-smith/DaisySP
git submodule add https://github.com/electro-smith/libDaisy
echo "building DaisySP . . ."
cd "DaisySP" ; make clean ; make | grep "warning:r\|error" ;
echo "done."
cd ../libDaisy
echo "building libDaisy . . ."
make clean ; make | grep "warning:r\|error" ;
echo "done."
Makefile and cpp file
Here’s an example of a Makefile:
# Project Name
TARGET = ex_vco
# Sources
CPP_SOURCES = ex_vco.cpp
# Library Locations
LIBDAISY_DIR = libDaisy
DAISYSP_DIR = DaisySP
# Core location, and generic Makefile.
SYSTEM_FILES_DIR = $(LIBDAISY_DIR)/core
include $(SYSTEM_FILES_DIR)/Makefile
And the accompanying code (ex_vco.cpp)
#include "daisysp.h"
#include "daisy_patch.h"
#include <string>
using namespace daisy;
using namespace daisysp;
DaisyPatch patch;
Oscillator osc;
Parameter freqctrl, wavectrl, ampctrl, finectrl;
static void AudioCallback(float **in, float **out, size_t size)
{
float sig, freq, amp;
size_t wave;
patch.ProcessAnalogControls();
for(size_t i = 0; i < size; i++)
{
// Read Knobs
freq = mtof(freqctrl.Process() + finectrl.Process());
wave = wavectrl.Process();
amp = ampctrl.Process();
// Set osc params
osc.SetFreq(freq);
osc.SetWaveform(wave);
osc.SetAmp(amp);
//.Process
sig = osc.Process();
// Assign Synthesized Waveform to all four outputs.
for(size_t chn = 0; chn < 4; chn++)
{
out[chn][i] = sig;
}
}
}
int main(void)
{
float samplerate;
int num_waves = Oscillator::WAVE_LAST - 1;
patch.Init(); // Initialize hardware (daisy seed, and patch)
samplerate = patch.AudioSampleRate();
osc.Init(samplerate); // Init oscillator
freqctrl.Init(
patch.controls[patch.CTRL_1], 10.0, 110.0f, Parameter::LINEAR);
finectrl.Init(patch.controls[patch.CTRL_2], 0.f, 7.f, Parameter::LINEAR);
wavectrl.Init(
patch.controls[patch.CTRL_3], 0.0, num_waves, Parameter::LINEAR);
ampctrl.Init(patch.controls[patch.CTRL_4], 0.0, 0.5f, Parameter::LINEAR);
//briefly display module name
std::string str = "VCO";
char * cstr = &str[0];
patch.display.WriteString(cstr, Font_7x10, true);
patch.display.Update();
patch.DelayMs(1000);
patch.StartAdc();
patch.StartAudio(AudioCallback);
while(1)
{
patch.DisplayControls(false);
}
}
Both of these are from the Daisy examples.
Building
make clean; make
Uploading
Put Daisy into DFU mode by pressing BOOT, then RESET, then letting go of RESET and then of BOOT.
make program-dfu
Or build and upload in one:
make clean; make; make program-dfu
Project generator script
I created a small script for myself to generate projects for the Daisy Seed.
#dsp #cpp #daisy