Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch sm support #58

Closed
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ae1a5e1
Updated libDaisy
CorvusPrudens Oct 6, 2021
5c2d9a2
Added incomplete patch sm json
CorvusPrudens Oct 6, 2021
dc22946
Added patch_sm to available targets
CorvusPrudens Oct 6, 2021
5459602
Added second gate out
CorvusPrudens Oct 6, 2021
729e980
Updated json with all parameters
CorvusPrudens Oct 6, 2021
5bcea9a
Added patch_sm target
CorvusPrudens Oct 6, 2021
4a84e35
Made changes for patch_sm class
CorvusPrudens Oct 6, 2021
fa25808
Updated change log
CorvusPrudens Oct 6, 2021
85ab56c
Added patch_sm controls processing
CorvusPrudens Oct 7, 2021
c4b5366
Added switch classes for hardware
CorvusPrudens Oct 7, 2021
0554a1c
Created patch_sm template
CorvusPrudens Oct 7, 2021
6970825
Cleaning up namespaces
CorvusPrudens Oct 12, 2021
0d2ed4b
Removed midi-related fields
CorvusPrudens Oct 12, 2021
4c2dddc
Removed unnecessary button init params
CorvusPrudens Oct 12, 2021
aa6bf09
Removed unnecessary `ProcessAllControls` call
CorvusPrudens Oct 12, 2021
010f636
Fixed all namespacing issues
CorvusPrudens Oct 12, 2021
7574b21
Cleaned up patch_sm template
CorvusPrudens Oct 12, 2021
f9839ea
Removed switch for patch sm
CorvusPrudens Oct 12, 2021
8c3405c
Removed most patch sm ifdefs
CorvusPrudens Oct 12, 2021
c0eba69
Updated change log
CorvusPrudens Oct 12, 2021
e56cdd1
Added pin aliases to match hardware
CorvusPrudens Oct 13, 2021
ddf8e55
Added patch_sm object substitution
CorvusPrudens Oct 13, 2021
a8f1ea6
Merge branch 'patch_sm_support' of https://github.com/CorvusPrudens/o…
CorvusPrudens Oct 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions patchers/oopsy.maxpat
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"appversion" : {
"major" : 8,
"minor" : 1,
"revision" : 8,
"revision" : 11,
"architecture" : "x64",
"modernui" : 1
}
,
"classnamespace" : "box",
"rect" : [ 356.0, 113.0, 1246.0, 808.0 ],
"rect" : [ 213.0, 106.0, 1076.0, 652.0 ],
"bglocked" : 0,
"openinpresentation" : 1,
"default_fontsize" : 12.0,
Expand Down Expand Up @@ -341,7 +341,7 @@
"box" : {
"fontsize" : 9.0,
"id" : "obj-76",
"items" : [ "patch", ",", "field", ",", "petal", ",", "pod", ",", "versio" ],
"items" : [ "patch", ",", "patch_sm", ",", "field", ",", "petal", ",", "pod", ",", "versio" ],
"maxclass" : "umenu",
"numinlets" : 1,
"numoutlets" : 3,
Expand All @@ -365,13 +365,13 @@
"appversion" : {
"major" : 8,
"minor" : 1,
"revision" : 8,
"revision" : 11,
"architecture" : "x64",
"modernui" : 1
}
,
"classnamespace" : "box",
"rect" : [ 839.0, 277.0, 807.0, 498.0 ],
"rect" : [ 483.0, 255.0, 807.0, 498.0 ],
"bglocked" : 0,
"openinpresentation" : 0,
"default_fontsize" : 12.0,
Expand Down Expand Up @@ -399,6 +399,7 @@
"style" : "",
"subpatcher_template" : "",
"assistshowspatchername" : 0,
"visible" : 1,
"boxes" : [ {
"box" : {
"id" : "obj-31",
Expand All @@ -415,11 +416,11 @@
"box" : {
"id" : "obj-29",
"maxclass" : "newobj",
"numinlets" : 6,
"numoutlets" : 6,
"outlettype" : [ "", "", "", "", "", "" ],
"patching_rect" : [ 59.0, 140.0, 207.0, 22.0 ],
"text" : "routepass patch field petal pod versio"
"numinlets" : 7,
"numoutlets" : 7,
"outlettype" : [ "", "", "", "", "", "", "" ],
"patching_rect" : [ 59.0, 140.0, 263.0, 22.0 ],
"text" : "routepass patch patch_sm field petal pod versio"
}

}
Expand Down Expand Up @@ -562,8 +563,8 @@
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 16.0, 47.0, 413.0, 22.0 ],
"text" : "clear, append patch, append field, append petal, append pod, append versio"
"patching_rect" : [ 16.0, 47.0, 516.0, 22.0 ],
"text" : "clear, append patch, append patch_sm, append field, append petal, append pod, append versio"
}

}
Expand Down Expand Up @@ -672,6 +673,13 @@
, {
"patchline" : {
"destination" : [ "obj-27", 0 ],
"source" : [ "obj-29", 6 ]
}

}
, {
"patchline" : {
"destination" : [ "obj-37", 0 ],
"source" : [ "obj-29", 5 ]
}

Expand Down Expand Up @@ -960,7 +968,7 @@
"appversion" : {
"major" : 8,
"minor" : 1,
"revision" : 8,
"revision" : 11,
"architecture" : "x64",
"modernui" : 1
}
Expand Down Expand Up @@ -1298,6 +1306,8 @@
"saved_object_attributes" : {
"autostart" : 0,
"defer" : 0,
"node_bin_path" : "",
"npm_bin_path" : "",
"watch" : 0
}
,
Expand Down Expand Up @@ -1341,7 +1351,7 @@
"appversion" : {
"major" : 8,
"minor" : 1,
"revision" : 8,
"revision" : 11,
"architecture" : "x64",
"modernui" : 1
}
Expand Down
1 change: 1 addition & 0 deletions source/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- Updates to makefiles to support SDcard and fix some compilation errors
- Code generation cleanup
- Targets:
- Support for the Daisy Patch SM on the patch.Init()
- Support for Noise Engineering's Versio, including all on-panel controls and LEDs, and template patch.
- Param view added to Daisy Field; params not tweakable (because of no encoder) but at least visible
- Added ability to select custom JSON config from within oopsy.maxpat via "browse" button or @target argument
Expand Down
138 changes: 138 additions & 0 deletions source/daisy.patch_sm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
{
"max_apps":8,
"defines": {
"OOPSY_TARGET_PATCH_SM": 1,
"OOPSY_IO_COUNT": 2
},
"inserts": [
{ "where": "header", "code": "#include \"daisy_patch_sm.h\"" },
{ "where": "header", "code": "typedef daisy::patch_sm::DaisyPatchSM Daisy;" },
{ "where": "header", "code": "daisy::Switch sw_class;" },
{ "where": "init", "code": "sw_class.Init(oopsy::daisy.hardware.B8, 1000, daisy::Switch::Type::TYPE_TOGGLE, daisy::Switch::Polarity::POLARITY_INVERTED, daisy::Switch::Pull::PULL_UP);"},
{ "where": "audio", "code": "sw_class.Debounce();" },

{ "where": "header", "code": "daisy::Switch button_class;" },
{ "where": "init", "code": "button_class.Init(oopsy::daisy.hardware.B7, 1000, daisy::Switch::Type::TYPE_MOMENTARY, daisy::Switch::Polarity::POLARITY_INVERTED, daisy::Switch::Pull::PULL_UP);"},
{ "where": "audio", "code": "button_class.Debounce();" },

{ "where": "audio", "code": "hardware.ProcessAllControls();" }
],
"labels": {
"params": {
"knob1": "kn1",
"knob2": "kn2",
"knob3": "kn3",
"knob4": "kn4",
"gate1": "gt1",
"gate2": "gt2",

"sw": "sw",
"sw1": "sw",
"sw2": "button",
"button": "button",
"press": "button",

"knob": "kn1",
"cv": "kn1",
"cv1": "kn1",
"cv2": "kn2",
"cv3": "kn3",
"cv4": "kn4",
"cv5": "cv5",
"cv6": "cv6",
"cv7": "cv7",
"cv8": "cv8",

"ctrl": "kn1",
"ctrl1": "kn1",
"ctrl2": "kn2",
"ctrl3": "kn3",
"ctrl4": "kn4",

"gate": "gt1"
},
"outs": {
"cv1": "cvout1",
"cv2": "cvout2",
"gate1": "gateout1",
"gate2": "gateout2",

"cv": "cvout1",
"gate": "gateout1"
},
"datas": {
"midi": "dsy_midi_out"
}
},
"inputs": {
"kn1": {
"automap": true,
"code": "hardware.GetAdcValue(daisy::patch_sm::CV_1);"
},
"kn2": {
"automap": true,
"code": "hardware.GetAdcValue(daisy::patch_sm::CV_2);"
},
"kn3": {
"automap": true,
"code": "hardware.GetAdcValue(daisy::patch_sm::CV_3);"
},
"kn4": {
"automap": true,
"code": "hardware.GetAdcValue(daisy::patch_sm::CV_4);"
},
"cv5": {
"automap": true,
"code": "hardware.GetAdcValue(daisy::patch_sm::CV_5);"
},
"cv6": {
"automap": true,
"code": "hardware.GetAdcValue(daisy::patch_sm::CV_6);"
},
"cv7": {
"automap": true,
"code": "hardware.GetAdcValue(daisy::patch_sm::CV_7);"
},
"cv8": {
"automap": true,
"code": "hardware.GetAdcValue(daisy::patch_sm::CV_8);"
},
"gt1": {
"code": "(hardware.gate_in_1.State()?1.f:0.f);"
},
"gt2": {
"code": "(hardware.gate_in_2.State()?1.f:0.f);"
},
"button": {
"code": "(button_class.Pressed() ? 1.f : 0.f);"
},
"sw": {
"code": "(sw_class.Pressed() ? 1.f : 0.f);"
}
},
"outputs": {
"cvout1": {
"where": "main",
"code": "hardware.WriteCvOut(Daisy::CV_OUT_1, $<name>);"
},
"cvout2": {
"where": "main",
"code": "hardware.WriteCvOut(Daisy::CV_OUT_2, $<name>);"
},
"gateout1": {
"where": "audio",
"code": "dsy_gpio_write(&hardware.gate_out_1, $<name> > 0.f);"
},
"gateout2": {
"where": "audio",
"code": "dsy_gpio_write(&hardware.gate_out_2, $<name> > 0.f);"
}
},
"datahandlers": {
"dsy_midi_out": {
"where":"main",
"init": "daisy.midi_nullData($<data>)",
"code": "daisy.midi_fromData($<data>);"
}
}
}
50 changes: 45 additions & 5 deletions source/genlib_daisy.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,11 @@ namespace oopsy {
mainloopCallback = nullMainloopCallback;
displayCallback = nullMainloopCallback;
nullAudioCallbackRunning = false;
#ifdef OOPSY_TARGET_PATCH_SM
hardware.ChangeAudioCallback(nullAudioCallback);
#else
hardware.seed.ChangeAudioCallback(nullAudioCallback);
#endif
while (!nullAudioCallbackRunning) daisy::System::Delay(1);
// reset memory
oopsy::init();
Expand All @@ -400,9 +404,17 @@ namespace oopsy {
#if defined(OOPSY_TARGET_HAS_OLED) && defined(OOPSY_HAS_PARAM_VIEW)
paramCallback = newapp.staticParamCallback;
#endif
#ifdef OOPSY_TARGET_PATCH_SM
hardware.ChangeAudioCallback(newapp.staticAudioCallback);
#else
hardware.seed.ChangeAudioCallback(newapp.staticAudioCallback);
#endif
log("gen~ %s", appdefs[app_selected].name);
#ifdef OOPSY_TARGET_PATCH_SM
log("SR %dkHz / %dHz", (int)(hardware.AudioSampleRate()/1000), (int)hardware.AudioCallbackRate());
#else
log("SR %dkHz / %dHz", (int)(hardware.seed.AudioSampleRate()/1000), (int)hardware.seed.AudioCallbackRate());
#endif
{
log("%d%s/%dKB+%d%s/%dMB",
oopsy::sram_used > 1024 ? oopsy::sram_used/1024 : oopsy::sram_used,
Expand Down Expand Up @@ -446,10 +458,18 @@ namespace oopsy {
app_count = count;
mode = 0;

#ifdef OOPSY_USE_USB_SERIAL_INPUT
hardware.seed.usb_handle.Init(daisy::UsbHandle::FS_INTERNAL);
daisy::System::Delay(500);
hardware.seed.usb_handle.SetReceiveCallback(UsbCallback, daisy::UsbHandle::FS_INTERNAL);
#ifdef OOPSY_TARGET_PATCH_SM
#ifdef OOPSY_USE_USB_SERIAL_INPUT
hardware.usb.Init(daisy::UsbHandle::FS_INTERNAL);
daisy::System::Delay(500);
hardware.usb.SetReceiveCallback(UsbCallback, daisy::UsbHandle::FS_INTERNAL);
#endif
#else
#ifdef OOPSY_USE_USB_SERIAL_INPUT
hardware.seed.usb_handle.Init(daisy::UsbHandle::FS_INTERNAL);
daisy::System::Delay(500);
hardware.seed.usb_handle.SetReceiveCallback(UsbCallback, daisy::UsbHandle::FS_INTERNAL);
#endif
#endif

#ifdef OOPSY_USE_LOGGING
Expand All @@ -472,8 +492,12 @@ namespace oopsy {
console_line = console_rows-1;
#endif

#ifdef OOPSY_TARGET_PATCH_SM
hardware.StartAudio(nullAudioCallback);
#else
hardware.seed.adc.Start();
hardware.seed.StartAudio(nullAudioCallback);
#endif
mainloopCallback = nullMainloopCallback;
displayCallback = nullMainloopCallback;

Expand Down Expand Up @@ -513,7 +537,11 @@ namespace oopsy {
t = t1;

// pulse seed LED for status according to CPU usage:
#ifdef OOPSY_TARGET_PATCH_SM
hardware.SetLed((t % 1000)/10 <= uint32_t(audioCpuUsage));
#else
hardware.seed.SetLed((t % 1000)/10 <= uint32_t(audioCpuUsage));
#endif

if (app_load_scheduled) {
app_load_scheduled = 0;
Expand Down Expand Up @@ -541,7 +569,11 @@ namespace oopsy {

if (uitimer.ready(dt)) {
#ifdef OOPSY_USE_LOGGING
hardware.seed.PrintLine("the time is"FLT_FMT3"", FLT_VAR3(t/1000.f));
#ifdef OOPSY_TARGET_PATCH_SM
hardware.PrintLine("the time is"FLT_FMT3"", FLT_VAR3(t/1000.f));
#else
hardware.seed.PrintLine("the time is"FLT_FMT3"", FLT_VAR3(t/1000.f));
#endif
#endif
#ifdef OOPSY_USE_USB_SERIAL_INPUT
if(update && rx_size > 0) {
Expand Down Expand Up @@ -786,7 +818,11 @@ namespace oopsy {
} break;
case SCOPEOPTION_ZOOM: {
// each pixel is zoom samples; zoom/samplerate seconds
#ifdef OOPSY_TARGET_PATCH_SM
float scope_duration = OOPSY_OLED_DISPLAY_WIDTH*(1000.f*zoomlevel/hardware.AudioSampleRate());
#else
float scope_duration = OOPSY_OLED_DISPLAY_WIDTH*(1000.f*zoomlevel/hardware.seed.AudioSampleRate());
#endif
int offset = snprintf(scope_label, console_cols, "%dx %dms", zoomlevel, (int)ceilf(scope_duration));
hardware.display.SetCursor(0, h - font.FontHeight);
hardware.display.WriteString(scope_label, font, true);
Expand Down Expand Up @@ -1076,7 +1112,11 @@ namespace oopsy {
daisy.audio_postperform(buffers, size);
// convert elapsed time (us) to CPU percentage (0-100) of available processing time
// 100 (%) * (0.000001 * used_us) * callbackrateHz
#ifdef OOPSY_TARGET_PATCH_SM
float percent = (daisy::System::GetUs() - start)*0.0001f*daisy.hardware.AudioCallbackRate();
#else
float percent = (daisy::System::GetUs() - start)*0.0001f*daisy.hardware.seed.AudioCallbackRate();
#endif
percent = percent > 100.f ? 100.f : percent;
// with a falling-only slew to capture spikes, since we care most about worst-case performance
daisy.audioCpuUsage = (percent > daisy.audioCpuUsage) ? percent
Expand Down
Loading