static json_t* net_write_json_params(void) { json_t *params = json_object(); json_t *l = json_array(); json_t* o; int i; json_object_set(params, "count", json_integer(net->numParams)); for(i=0; i<net->numParams; i++) { o = json_object(); json_object_set(o, "idx", json_integer(i)); json_object_set(o, "label", json_string(net->params[i].desc.label)); json_object_set(o, "type", json_integer(net->params[i].desc.type)); json_object_set(o, "min", json_integer(net->params[i].desc.min)); json_object_set(o, "max", json_integer(net->params[i].desc.max)); json_object_set(o, "value", json_integer(net->params[i].data.value)); /// FIXME: this dumb indexing. play flag not stored correctly... json_object_set(o, "play", json_boolean(net_get_in_play(i + net->numIns))); json_array_append(l, o); } json_object_set(params, "data", l); return params; }
// 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 void show_foot1(void) { u8 fill = 0; if(keyPressed == 1) { fill = 0x5; } region_fill(footRegion[1], fill); if(altMode) { if(net_get_in_play(*pageSelect)) { font_string_region_clip(footRegion[1], "HIDE", 0, 0, 0xf, fill); } else { font_string_region_clip(footRegion[1], "SHOW", 0, 0, 0xf, fill); } } else { if(net_get_in_preset(*pageSelect)) { font_string_region_clip(footRegion[1], "EXC", 0, 0, 0xf, fill); } else { font_string_region_clip(footRegion[1], "INC", 0, 0, 0xf, fill); } } }
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; }
// activate an input node with a value void net_activate(s16 inIdx, const io_t val, void* op) { static inode_t* pIn; s16 pIndex; u8 vis; print_dbg("\r\n net_activate, input idx: "); print_dbg_hex(inIdx); print_dbg(" , value: "); print_dbg_hex(val); print_dbg(" , op index: "); print_dbg_ulong(net->ins[inIdx].opIdx); print_dbg(" , input idx: "); print_dbg_ulong(net->ins[inIdx].opInIdx); if(!netActive) { if(op != NULL) { // if the net isn't active, dont respond to requests from operators print_dbg(" ... ignoring node activation from op."); return; } } if(inIdx < 0) { return; } vis = net_get_in_play(inIdx); print_dbg(" , play visibility flag : "); print_dbg_ulong(vis); if(inIdx < net->numIns) { // this is an op input pIn = &(net->ins[inIdx]); print_dbg(" ; input node pointer: 0x"); print_dbg_hex((u32)pIn); op_set_in_val(net->ops[pIn->opIdx], pIn->opInIdx, val); } else { // this is a parameter //// FIXME this is horrible pIndex = inIdx - net->numIns; if (pIndex >= net->numParams) { return; } print_dbg(" ; param index: 0x"); print_dbg_ulong(pIndex); set_param_value(pIndex, val); } /// only process for play mode if we're in play mode if(pageIdx == ePagePlay) { print_dbg(" , play mode "); if(opPlay) { // operators have focus, do nothing print_dbg(" , op focus mode"); } else { // process if play-mode-visibility is set on this input if(vis) { print_dbg(" , input enabled"); play_input(inIdx); } } } }