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 all 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
2 changes: 2 additions & 0 deletions init/oopsy-objectmappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ max definesubstitution oopsy.petal bpatcher @name oopsy.maxpat @args petal;
max objectfile oopsy.petal oopsy.petal;
max definesubstitution oopsy.pod bpatcher @name oopsy.maxpat @args pod;
max objectfile oopsy.pod oopsy.pod;
max definesubstitution oopsy.patch_sm bpatcher @name oopsy.maxpat @args patch_sm;
max objectfile oopsy.patch_sm oopsy.patch_sm;
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
5 changes: 5 additions & 0 deletions source/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v0.5.0-beta

- Targets:
- Support for the Daisy Patch SM on the patch.Init()

## v0.4.0-beta

- Params:
Expand Down
155 changes: 155 additions & 0 deletions source/daisy.patch_sm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
{
"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);"},
{ "where": "audio", "code": "sw_class.Debounce();" },

{ "where": "header", "code": "daisy::Switch button_class;" },
{ "where": "init", "code": "button_class.Init(oopsy::daisy.hardware.B7, 1000);"},
{ "where": "audio", "code": "button_class.Debounce();" }
],
"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",

"CV_1": "kn1",
"CV_2": "kn2",
"CV_3": "kn3",
"CV_4": "kn4",
"CV_5": "cv5",
"CV_6": "cv6",
"CV_7": "cv7",
"CV_8": "cv8",

"B7": "button",
"B8": "sw",

"B10": "gt1",
"B9": "gt2",
"gate_in_1": "gt1",
"gate_in_2": "gt2"
},
"outs": {
"cv1": "cvout1",
"cv2": "cvout2",
"gate1": "gateout1",
"gate2": "gateout2",

"cv": "cvout1",
"led": "cvout2",
"gate": "gateout1",

"CV_OUT_1": "cvout1",
"C10": "cvout1",
"CV_OUT_2": "cvout2",

"B5": "gateout1",
"B6": "gateout2",
"gate_out_1": "gateout1",
"gate_out_2": "gateout2"
},
"datas": {}
},
"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::patch_sm::DaisyPatchSM::CV_OUT_1, $<name> * 5.f);"
},
"cvout2": {
"where": "main",
"code": "hardware.WriteCvOut(daisy::patch_sm::DaisyPatchSM::CV_OUT_2, $<name> * 5.f);"
},
"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": {}
}
30 changes: 18 additions & 12 deletions source/genlib_daisy.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ namespace oopsy {
struct GenDaisy {

Daisy hardware;
#ifdef OOPSY_TARGET_PATCH_SM
Daisy *sub_board = &hardware;
#else
daisy::DaisySeed *sub_board = &hardware.seed;
#endif
AppDef * appdefs = nullptr;

int mode, screensave=0;
Expand Down Expand Up @@ -387,7 +392,7 @@ namespace oopsy {
mainloopCallback = nullMainloopCallback;
displayCallback = nullMainloopCallback;
nullAudioCallbackRunning = false;
hardware.seed.ChangeAudioCallback(nullAudioCallback);
sub_board->ChangeAudioCallback(nullAudioCallback);
while (!nullAudioCallbackRunning) daisy::System::Delay(1);
// reset memory
oopsy::init();
Expand All @@ -400,9 +405,10 @@ namespace oopsy {
#if defined(OOPSY_TARGET_HAS_OLED) && defined(OOPSY_HAS_PARAM_VIEW)
paramCallback = newapp.staticParamCallback;
#endif
hardware.seed.ChangeAudioCallback(newapp.staticAudioCallback);

sub_board->ChangeAudioCallback(newapp.staticAudioCallback);
log("gen~ %s", appdefs[app_selected].name);
log("SR %dkHz / %dHz", (int)(hardware.seed.AudioSampleRate()/1000), (int)hardware.seed.AudioCallbackRate());
log("SR %dkHz / %dHz", (int)(sub_board->AudioSampleRate()/1000), (int)sub_board->AudioCallbackRate());
{
log("%d%s/%dKB+%d%s/%dMB",
oopsy::sram_used > 1024 ? oopsy::sram_used/1024 : oopsy::sram_used,
Expand Down Expand Up @@ -447,9 +453,9 @@ namespace oopsy {
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);
sub_board->usb.Init(daisy::UsbHandle::FS_INTERNAL);
daisy::System::Delay(500);
sub_board->usb.SetReceiveCallback(UsbCallback, daisy::UsbHandle::FS_INTERNAL);
#endif

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

hardware.seed.adc.Start();
hardware.seed.StartAudio(nullAudioCallback);
sub_board->adc.Start();
sub_board->StartAudio(nullAudioCallback);
mainloopCallback = nullMainloopCallback;
displayCallback = nullMainloopCallback;

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

// pulse seed LED for status according to CPU usage:
hardware.seed.SetLed((t % 1000)/10 <= uint32_t(audioCpuUsage));
sub_board->SetLed((t % 1000)/10 <= uint32_t(audioCpuUsage));

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

if (uitimer.ready(dt)) {
#ifdef OOPSY_USE_LOGGING
hardware.seed.PrintLine("the time is"FLT_FMT3"", FLT_VAR3(t/1000.f));
sub_board->PrintLine("the time is"FLT_FMT3"", FLT_VAR3(t/1000.f));
#endif
#ifdef OOPSY_USE_USB_SERIAL_INPUT
if(update && rx_size > 0) {
Expand Down Expand Up @@ -786,7 +792,7 @@ namespace oopsy {
} break;
case SCOPEOPTION_ZOOM: {
// each pixel is zoom samples; zoom/samplerate seconds
float scope_duration = OOPSY_OLED_DISPLAY_WIDTH*(1000.f*zoomlevel/hardware.seed.AudioSampleRate());
float scope_duration = OOPSY_OLED_DISPLAY_WIDTH*(1000.f*zoomlevel/sub_board->AudioSampleRate());
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 +1082,7 @@ 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
float percent = (daisy::System::GetUs() - start)*0.0001f*daisy.hardware.seed.AudioCallbackRate();
float percent = (daisy::System::GetUs() - start)*0.0001f*daisy.sub_board->AudioCallbackRate();
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