// probably only called from UI, // can err on the side of caution vs speed io_t net_inc_in_value(s32 inIdx, io_t inc) { op_t* op; /* print_dbg("\r\n incrementing input in network, value: "); */ /* print_dbg_hex(net_get_in_value(inIdx < 0 ? 0 : (u16)inIdx)); */ /* print_dbg(" , increment: "); */ /* print_dbg_hex(inc); */ if(inIdx >= net->numIns) { // hack to get param idx inIdx -= net->numIns; // set_param_value(inIdx, op_sadd(get_param_value(inIdx), inc)); // return get_param_value(inIdx); return inc_param_value(inIdx, inc); } else { op = net->ops[net->ins[inIdx].opIdx]; (*(op->inc_fn))(op, net->ins[inIdx].opInIdx, inc); print_dbg(" , result: "); print_dbg_hex( net_get_in_value(inIdx)); return net_get_in_value(inIdx); } }
// store everything enabled in given preset void preset_store(u32 preIdx) { u16 i; // ins for(i=0; i<net_num_ins(); ++i) { if( net_get_in_preset(i) ) { presets[preIdx].ins[i].value = net_get_in_value(i); presets[preIdx].ins[i].enabled = 1; } } // outs for(i=0; i<net_num_outs(); ++i) { if(net_get_out_preset(i)) { presets[preIdx].outs[i].target = net_get_target(i); presets[preIdx].outs[i].enabled = 1; } } // params /* for(i=0; i<net_num_params(); ++i) { */ /* if(get_param_preset(i)) { */ /* presets[preIdx].params[i].value = get_param_value( i ); */ /* presets[preIdx].params[i].enabled = 1; */ /* } */ /* } */ select = preIdx; }
// retrigger all inputs void net_retrigger_inputs(void) { u32 i; netActive = 0; for(i=0; i<net->numIns; i++) { net_activate(i, net_get_in_value(i), NULL); } netActive = 1; }
// probably only called from UI, // can err on the side of caution vs speed io_t net_inc_in_value(s32 inIdx, io_t inc) { op_t* op; if(inIdx >= net->numIns) { // hack to get param idx inIdx -= net->numIns; return inc_param_value(inIdx, inc); } else { op = net->ops[net->ins[inIdx].opIdx]; op_inc_in_val(op, net->ins[inIdx].opInIdx, inc); return net_get_in_value(inIdx); } }
// fill tmp region with new content // given input index and foreground color static void render_line(s16 idx, u8 fg) { const s16 opIdx = net_in_op_idx(idx); region_fill(lineRegion, 0x0); if(opIdx >= 0) { // operator input // build descriptor string clearln(); appendln_idx_lj(opIdx); appendln_char('.'); appendln( net_op_name(opIdx) ); appendln_char('/'); appendln( net_in_name(idx) ); endln(); font_string_region_clip(lineRegion, lineBuf, 4, 0, fg, 0); clearln(); op_print(lineBuf, net_get_in_value(idx)); font_string_region_clip(lineRegion, lineBuf, LINE_VAL_POS_SHORT, 0, fg, 0); } else { // parameter input clearln(); appendln_idx_lj( (int)net_param_idx(idx)); appendln_char('.'); appendln( net_in_name(idx)); endln(); font_string_region_clip(lineRegion, lineBuf, 4, 0, 0xa, 0); clearln(); // op_print(lineBuf, net_get_in_value(idx)); /// FIXME: this is pretty dumb, // params and inputs should just be on separate pages i guess net_get_param_value_string(lineBuf, idx); font_string_region_clip(lineRegion, lineBuf, LINE_VAL_POS_LONG, 0, fg, 0); } // draw something to indicate play mode visibility if(net_get_in_play(idx)) { font_string_region_clip(lineRegion, ".", 0, 0, fg, 0); } // draw something to indicate preset inclusion if(net_get_in_preset(idx)) { font_string_region_clip(lineRegion, ".", 126, 0, fg, 0); } }
static json_t* net_write_json_ins(void) { json_t* ins = json_object(); json_t* l = json_array(); json_t* o; int i; json_object_set(ins, "count", json_integer(net->numIns)); for(i=0; i<net->numIns; i++) { o = json_object(); json_object_set(o, "idx", json_integer(i)); json_object_set(o, "name", json_string(net_in_name(i))); json_object_set(o, "opIdx", json_integer(net->ins[i].opIdx)); json_object_set(o, "opInIdx", json_integer(net->ins[i].opInIdx)); json_object_set(o, "value", json_integer(net_get_in_value(i))); json_object_set(o, "play", json_boolean(net_get_in_play(i))); json_array_append(l, o); } json_object_set(ins, "data", l); return ins; }
// store a particular input void preset_store_in(u32 preIdx, u32 inIdx) { // presets[preIdx].ins[inIdx].enabled = net_get_in_preset(inIdx); presets[preIdx].ins[inIdx].enabled = 1; presets[preIdx].ins[inIdx].value = net_get_in_value(inIdx); }
// redraw based on provisional preset seleciton void redraw_ins_preset ( void ) { s32 max = net_num_ins() - 1; u8 i=0; u8 n = *pageSelect - 3; u8 enabled; io_t opVal; s32 paramVal; s16 opIdx; print_dbg("\r\n redraw_ins_preset() "); while(i<8) { region_fill(lineRegion, 0x0); opIdx = net_in_op_idx(n); if(n <= max) { enabled = net_get_in_preset(n); if(opIdx < 0 ) { // parameter... clearln(); appendln_idx_lj( (int)net_param_idx(n)); appendln_char('.'); appendln( net_in_name(n)) ; endln(); font_string_region_clip(lineRegion, lineBuf, 4, 0, 0xf, 0); clearln(); if(enabled) { paramVal = preset_get_selected()->ins[n].value; net_get_param_value_string_conversion(lineBuf, net_param_idx(n), paramVal); } else { net_get_param_value_string(lineBuf, n); } font_string_region_clip(lineRegion, lineBuf, LINE_VAL_POS_LONG, 0, 0xf, 0); } else { // op input clearln(); appendln_idx_lj(opIdx); appendln_char('.'); appendln( net_op_name(opIdx) ); appendln_char('/'); appendln( net_in_name(n) ); endln(); font_string_region_clip(lineRegion, lineBuf, 4, 0, 0xf, 0); if(enabled) { opVal = preset_get_selected()->ins[n].value; } else { opVal = net_get_in_value(n); } op_print(lineBuf, opVal); font_string_region_clip(lineRegion, lineBuf, LINE_VAL_POS_SHORT, 0, 0xf, 0); } // draw something to indicate preset inclusion if(enabled) { font_string_region_clip(lineRegion, ".", 126, 0, 0xf, 0); } } render_to_scroll_line(i, 0); ++i; ++n; } // print_dbg("\r\n\r\n"); draw_preset_name(); }
// scroll the current selection static void select_scroll(s32 dir) { const s32 max = net_num_ins() - 1; // index for new content s16 newIdx; s16 newSel; s16 oldSel; int i; // wrap with blank line newSel = *pageSelect + dir; if (newSel < -1) { newSel += (max + 2); } if(newSel > max) { newSel -= (max + 2); } // print_dbg("\r\n scrolled selection on inputs page, old sel: "); // print_dbg_ulong(*pageSelect); // print_dbg(" , dir: "); // print_dbg_hex(dir); // print_dbg(" , new idx: "); // print_dbg_ulong(newSel); oldSel = *pageSelect; *pageSelect = newSel; // remove highlight from old center render_scroll_apply_hl(SCROLL_CENTER_LINE, 0); // update 'zeroed' flag zeroed = (net_get_in_value(*pageSelect) == 0); if(dir > 0) { // add content at bottom for(i=0; i<dir; ++i) { newIdx = oldSel + SCROLL_LINES_BELOW + i + 2; if(newIdx == (max + 1)) { region_fill(lineRegion, 0); } else { if(newIdx > max) { newIdx = newIdx - (max+2); } // print_dbg(" , rendering new line for idx: "); // print_dbg_ulong(newIdx); render_line(newIdx, 0xa); } // render tmp region to bottom of scroll // (this also updates scroll byte offset) render_to_scroll_bottom(); // add highlight to new center } render_scroll_apply_hl(SCROLL_CENTER_LINE, 1); } else { // add content at top for(i=0; i>dir; --i) { newIdx = oldSel - SCROLL_LINES_ABOVE + i; if(newIdx == -1) { region_fill(lineRegion, 0); } else { if(newIdx < -1) { newIdx = newIdx + max + 2; } // print_dbg(" , rendering new line for idx: "); // print_dbg_ulong(newIdx); render_line(newIdx, 0xa); } // render tmp region to top of scroll // (this also updates scroll byte offset) render_to_scroll_top(); } // add highlight to new center render_scroll_apply_hl(SCROLL_CENTER_LINE, 1); } }
// scroll the current selection static void select_scroll(s32 dir) { const s32 max = net_num_ins() - 1; // index for new content s16 newIdx; s16 newSel; if(dir < 0) { /// SCROLL DOWN // wrap with blank line if(*pageSelect == -1) { newSel = max; } else { // decrement selection newSel = *pageSelect - 1; // print_dbg("\r\n scroll down to new selection on ins page: "); // print_dbg_ulong(newSel); } *pageSelect = newSel; // remove highlight from old center render_scroll_apply_hl(SCROLL_CENTER_LINE, 0); // update 'zeroed' flag zeroed = (net_get_in_value(*pageSelect) == 0); // add new content at top newIdx = newSel - SCROLL_LINES_BELOW; if(newIdx == -1) { region_fill(lineRegion, 0); } else { if(newIdx < -1) { newIdx = newIdx + max + 2; } render_line(newIdx, 0xa); } // render tmp region to bottom of scroll // (this also updates scroll byte offset) render_to_scroll_top(); // add highlight to new center render_scroll_apply_hl(SCROLL_CENTER_LINE, 1); } else { // SCROLL UP // wrap with a blank line if(*pageSelect == max) { newSel = -1; } else { // increment selection newSel = *pageSelect + 1; } // print_dbg("\r\n scroll up to new selection on ins page: "); // print_dbg_ulong(newSel); *pageSelect = newSel; // remove highlight from old center render_scroll_apply_hl(SCROLL_CENTER_LINE, 0); // add new content at bottom of screen newIdx = newSel + SCROLL_LINES_ABOVE; if(newIdx == (max + 1)) { region_fill(lineRegion, 0); } else { if(newIdx > max) { newIdx = newIdx - (max+2); } render_line(newIdx, 0xa); } // render tmp region to bottom of scroll // (this also updates scroll byte offset) render_to_scroll_bottom(); // add highlight to new center render_scroll_apply_hl(SCROLL_CENTER_LINE, 1); } }