patch.Init(): can't read the knob values

Hi - I just started with the patch.Init(). I’m trying to do something obvious but that doesn’t work: print the current value of a knob. Here’s what I’m using:

#include <daisy_patch.h>

using namespace daisy;

DaisyPatch dp;

void InitHardware(bool debug) {
  dp.Init();
  dp.seed.StartLog(debug);
}

int main(void)
{
  InitHardware(true);

  int i = 0;
  for(;;) {
    dp.ProcessAnalogControls();
    int v = dp.controls[0].GetRawValue();
    dp.seed.PrintLine("Value %d", v);
    dp.seed.PrintLine("Cycle: %d", i++);
    System::Delay(10);
  }
}

I’ve been also using GetKnobValue(CTRL_1), removing ProcessAnalogControls() as I’m going through trial and errors but I’m not getting any value as I’m turning the knob:

Cycle: 1343
Value 0
Cycle: 1344
Value 0
Cycle: 1345
Value 0

I must be missing something obvious - before I spend more time digging, has anyone any idea? Thanks!

Hi @apbianco,

Welcome to the Forum!

It looks like your code is set up to use the Daisy Patch, not the Patch.Init hw.

The DaisyExamples/patch_sm folder has a number of examples you can take a look at, including this fun TripleSaw generator that reads multiple knobs.

Welcome to the Forum!

Thank you and thank you for all you are doing for the community!

Ah - I didn’t realise there was dedicated support for the Patch.Init():

Daisy Patch Submodule for use in custom eurorack modules and other audio hardware.

Hmm - figures. Yes, this now works like a charm:

DaisyPatchSM dpsm;
dpsm.Init();
dpsm.StartLog(true);
while (true) {
  dpsm.ProcessAnalogControls();
  dpsm.PrintLine("// %d", static_cast<int>(1000.0 * dpsm.controls[CV_1].Value()));
}