setFreq() on Variable Shape OSC

Hello friends,

Struggling to get the Variable shape osc to change pitch with set freq. Can get PW and shape to work so not sure what i’m doing wrong (It’s based just off the simpleOSC example:

#include "daisy_patch_sm.h"
#include "daisysp.h"

using namespace daisy;
using namespace patch_sm;
using namespace daisysp;

/** TODO: ADD CALIBRATION */

DaisyPatchSM patch;
VariableShapeOscillator   osc;

void AudioCallback(AudioHandle::InputBuffer  in,
                   AudioHandle::OutputBuffer out,
                   size_t                    size)
{
    patch.ProcessAllControls();

    float coarse_knob = patch.GetAdcValue(CV_1);
    float coarse      = fmap(coarse_knob, 36.f, 96.f);

    float voct_cv = patch.GetAdcValue(CV_5);
    float voct    = fmap(voct_cv, 0.f, 60.f);

    float midi_nn = fclamp(coarse + voct, 0.f, 127.f);
    float freq    = mtof(midi_nn);

    float wave_shape = patch.GetAdcValue(CV_2);
    float pulse_width = patch.GetAdcValue(CV_3);

    osc.SetFreq(freq);
    osc.SetWaveshape(wave_shape);
    osc.SetPW(pulse_width);

    for(size_t i = 0; i < size; i++)
    {
        float sig = osc.Process();
        OUT_L[i]  = sig;
        OUT_R[i]  = sig;
    }
}

int main(void)
{
    patch.Init();
    osc.Init(patch.AudioSampleRate());
    patch.StartAudio(AudioCallback);
    while(1) {}
}

I’m having the same issue, SetFreq() does not change the frequency and the perceived pitch of the variable shape oscillator is locked at 220 Hz.

I noticed in the .cpp file that the Init() function calls SetFreq(440) and SetSyncFreq(220). I didn’t think sync would be relevant because I called SetSync(false) for good measure in my code. However, I find that if I call SetSyncFreq() it behaves like I would expect SetFreq to behave. So I have my code working by just calling SetSyncFreq().

1 Like