Simple bytebeat-inspired DaisySP wrapper using sox

i’m getting my feet wet with DaisySP, trying to use it on MacOS. I also have the hardware, but I want a faster way to code stuff, without the slow feedback loop + I’m also interested to run it in other ways.

inspired by bytebeat/floatbeat, here’s what i came up with:

(disclaimer: i have no cpp skills, so my way of building might be stupid)

  1. prequisite:
brew install sox # replace with similar command on other platforms
# clone repo
git clone https://github.com/electro-smith/DaisySP.git
cd DaisySP
# build
mkdir build && cd build
cmake .. -DCMAKE_OSX_ARCHITECTURES=arm64
make
cd ..
# create test file:
mkdir hello && touch ./hello/daisy_sine.cpp
  1. create test file
// daisy_sine.cpp
#include <cmath>
#include <cstdio>
#include "daisysp.h"

using namespace daisysp;

#define BUFFER_SIZE 1024

int main()
{
    Oscillator osc;
    osc.Init(48000);
    osc.SetWaveform(osc.WAVE_SIN);
    osc.SetFreq(440.0f);
    float buffer[BUFFER_SIZE];

    while(1)
    {
        for(unsigned int t = 0; t < BUFFER_SIZE; t++)
        {
            float sample = osc.Process();
            buffer[t]    = sample * 0.3;
        }
        fwrite(buffer, sizeof(float), BUFFER_SIZE, stdout);
    }
    return 0;
}
  1. compile
g++ ./hello/daisy_sine.cpp -o ./hello/daisy_sine -I./Source -L./build -ldaisysp # compile
  1. run
./hello/daisy_sine | sox -traw -r48000 -b32 -e float -c 1 - -tcoreaudio # run through sox

maybe someone is looking for this. would be interested to hear if other people are doing this / similar things and how they approach it.

2 Likes