DaisySP and openFrameworks

I want to do some audio programming on an ordinary Debian laptop for a couple of future projects. So I started with openFrameworks and added DaisySP. I just got started but so far it is working great!

The AudioCallback is replaced with a very similar audioOut callback function/method.

Example code from a small project that plays a random note with filter and envelope when a key is pressed.

void ofApp::setup(){

// soundstream
ofSoundStreamSettings settings;
settings.numOutputChannels = 2;
settings.sampleRate = 44100;
settings.bufferSize = 512;
settings.numBuffers = 4;
settings.setOutListener(this);
soundStream.setup(settings);

// oscillator
osc1.Init(settings.sampleRate);
osc1.SetWaveform(osc1.WAVE_SQUARE);
osc1.SetAmp(0.1f);
osc1.SetFreq(500);

// filter
svf1.Init(settings.sampleRate);
svf1.SetFreq(500);
svf1.SetRes(0.3);

// env
env1.Init(settings.sampleRate);
env1.SetTime(daisysp::ADENV_SEG_ATTACK, .01);
env1.SetTime(daisysp::ADENV_SEG_DECAY, .4);
//minimum and maximum envelope values
env1.SetMin(0.0);
env1.SetMax(1.f);
env1.SetCurve(0); // linear

}

void ofApp::audioOut(ofSoundBuffer &outBuffer) {

for(size_t i = 0; i < outBuffer.getNumFrames(); i++) {

    float env_out = env1.Process();
    osc1.SetAmp(env_out);

    float fullSample = osc1.Process();

    svf1.Process(fullSample);
    fullSample = svf1.Low();

    // write the computed sample to the left and right channels
    outBuffer.getSample(i, 0) = fullSample;
    outBuffer.getSample(i, 1) = fullSample;

}

}

void ofApp::keyPressed(int key){

{
    float ffreq = ofRandom(1000) + 500;
    svf1.SetFreq(ffreq);

    float freq = ofRandom(1000) + 100;

    osc1.SetFreq(freq);
    env1.Trigger();
}

}

If anyone is interested I can post my explorations!

Yes please! I, for one, am very interested. I’d like to use-port DaisySP (and also Zynthian) to an Intel-AMD architecture now, with a long term goal-dream of porting to a Risc V target when the chips are available.

1 Like

There’s nothing in particular to port, it’s just C++ code that can be compiled anywhere. And you can use it on X86 without any problems, there even was a port for VCVrack on Stephen’s github page.

If there were block-based processing functions, they could implemented with platform specific vectorized code that gives considerable performance improvements. But unfortunately that’s not the case except just a few classes.

1 Like

Thanks @tunagenes! As @antisvin wrote, there is really no port involved. I used openFrameworks just as a framework to get an “environment” in which to use DaisySP and get a ready to run program, and found that it is very simple! Give me a week or so, and I hope to have some kind of guide and/or example project to show that you can study.

openFrameworks is also available for several platforms, and it has a lot of interesting parts for graphics and UI, some of which I plan to use with DaisySP.

I have finished a first version!

Demo: DStudio - addons and examples to make music with openFrameworks - YouTube

Announcement: DStudio – addons and examples to make music with openFrameworks - resources - openFrameworks

Download: Open source – OSCILLATOR

2 Likes

Wow! Thanks Staffan - the drone in the youtube video sounds fantastic. I couldn’t open the announcement - got:
This site can’t be reached The webpage at DStudio – addons and examples to make music with openFrameworks - resources - openFrameworks might be temporarily down or it may have moved permanently to a new web address.
ERR_FAILED

I don’t know if it’s something about my setup or the link.

1 Like

I hope you will like it and find it useful, @tunagenes!

The whole openFrameworks site has been down, unfortunately. I hope they can fix it soon.

You can download the project here
https://www.oscillator.se/opensource/#openframeworks

There is a manual in the download describing the project.

The openFrameworks site seems to be up and running again:

Eyup - works for me now too, thanks.

1 Like

V1.0 now released: DStudio - make music using openFrameworks v1.0 released!