Yes that’s the general idea.
I tried your JSON here, and (other than weird formatting issues from the forum post) it generates good looking code AFAICT. I also compared it to the basic DaisySeed Knob example (https://github.com/electro-smith/DaisyExamples/blob/master/seed/Knob/Knob.cpp) and it looks quite comparable. I’m not sure why this wouldn’t be working, it all looks good from here.
Here’s the JSON formatted for anyone following along:
{
"defines": {
"OOPSY_TARGET_SEED": 1
},
"labels": {
"params": {
"knob1": "kn1",
"knob2": "kn2",
"knob3": "kn3"
},
"outs": {},
"datas": {}
},
"inputs": {
"kn1": {
"automap": true,
"code": "hardware.seed.adc.GetFloat(0);"
},
"kn2": {
"automap": true,
"code": "hardware.seed.adc.GetFloat(1);"
},
"kn3": {
"automap": true,
"code": "hardware.seed.adc.GetFloat(2);"
}
},
"outputs": {},
"datahandlers": {},
"inserts": [
{
"where": "init",
"code": "AdcChannelConfig cfg[3];"
},
{
"where": "init",
"code": "cfg[0].InitSingle(oopsy::daisy.hardware.seed.GetPin(21));"
},
{
"where": "init",
"code": "cfg[1].InitSingle(oopsy::daisy.hardware.seed.GetPin(22));"
},
{
"where": "init",
"code": "cfg[2].InitSingle(oopsy::daisy.hardware.seed.GetPin(23));"
},
{
"where": "init",
"code": "oopsy::daisy.hardware.seed.adc.Init(cfg, 3);"
},
{
"where": "header",
"code": "#include \"daisy_seed.h\""
},
{
"where": "header",
"code": "using namespace daisy;"
}
],
"max_apps": 1
}
The generated code looks like this:
#define OOPSY_TARGET_SEED (1)
#define OOPSY_IO_COUNT (2)
#include "daisy_seed.h"
using namespace daisy;
#include "../genlib_daisy.h"
#include "../genlib_daisy.cpp"
#include "../../graham/custom_2dtest.cpp"
struct App_custom_2dtest : public oopsy::App<App_custom_2dtest> {
float gen_param_knob1;
void init(oopsy::GenDaisy& daisy) {
daisy.gen = custom_2dtest::create(daisy.hardware.seed.AudioSampleRate(), daisy.hardware.seed.AudioBlockSize());
custom_2dtest::State& gen = *(custom_2dtest::State *)daisy.gen;
daisy.param_count = 1;
gen_param_knob1 = 0.f;
}
void mainloopCallback(oopsy::GenDaisy& daisy, uint32_t t, uint32_t dt) {
Daisy& hardware = daisy.hardware;
custom_2dtest::State& gen = *(custom_2dtest::State *)daisy.gen;
}
void displayCallback(oopsy::GenDaisy& daisy, uint32_t t, uint32_t dt) {
Daisy& hardware = daisy.hardware;
custom_2dtest::State& gen = *(custom_2dtest::State *)daisy.gen;
}
void audioCallback(oopsy::GenDaisy& daisy, float **hardware_ins, float **hardware_outs, size_t size) {
Daisy& hardware = daisy.hardware;
custom_2dtest::State& gen = *(custom_2dtest::State *)daisy.gen;
float kn1 = hardware.seed.adc.GetFloat(0);
gen_param_knob1 = (float)(kn1*1.f + 0.f);
gen.set_knob1(gen_param_knob1);
float * dsy_in1 = hardware_ins[0];
float * dsy_in2 = hardware_ins[1];
float * dsy_out1 = hardware_outs[0];
float * dsy_out2 = hardware_outs[1];
// in1:
float * inputs[] = { dsy_in1 };
// out1:
float * outputs[] = { dsy_out1 };
gen.perform(inputs, outputs, size);
memcpy(dsy_out2, dsy_out1, sizeof(float)*size);
}
};
// store apps in a union to re-use memory, since only one app is active at once:
union {
App_custom_2dtest app_custom_2dtest;
} apps;
oopsy::AppDef appdefs[] = {
{"custom_2dtest", []()->void { oopsy::daisy.reset(apps.app_custom_2dtest); } },
};
int main(void) {
oopsy::daisy.hardware.Init();
oopsy::daisy.hardware.seed.SetAudioSampleRate(daisy::SaiHandle::Config::SampleRate::SAI_48KHZ);
AdcChannelConfig cfg[3];
cfg[0].InitSingle(oopsy::daisy.hardware.seed.GetPin(21));
cfg[1].InitSingle(oopsy::daisy.hardware.seed.GetPin(22));
cfg[2].InitSingle(oopsy::daisy.hardware.seed.GetPin(23));
oopsy::daisy.hardware.seed.adc.Init(cfg, 3);
// insert custom hardware initialization here
return oopsy::daisy.run(appdefs, 1);
}