Example #1
0
// insert a split after an output node
// return out11 of split if original out was unconnected,
// otherwise connect out1 of split to old target and return out2
s16 net_split_out(s16 outIdx) {
  // saved target
  s16 target =   net->outs[outIdx].target;
  // index of added split operator
  s16 split;
  if( target < 0) {
    // no target
    split = net_add_op(eOpSplit);
    if(split < 0) {
      // failed to add, do nothing
      return outIdx; 
    } else {
      // FIXME: net_op_in_idx is pretty slow
      net_connect(outIdx, net_op_in_idx(split, 0));
      return net_op_out_idx(split, 0);
    } // add ok
  } else {
    // had target; reroute
    split = net_add_op(eOpSplit);
    if(split < 0) {
      // failed to add, do nothing
      return outIdx; 
    } else {
      // FIXME: net_op_in_idx is pretty slow
      net_connect(outIdx, net_op_in_idx(split, 0));
      net_connect(net_op_out_idx(split, 0), target);
      return net_op_out_idx(split, 1);
    } // add ok
  }
}
Example #2
0
// insert a split after an output node
// return out11 of split if original out was unconnected,
// otherwise connect out1 of split to old target and return out2
s16 net_split_out(s16 outIdx) {
  // saved target
  s16 target =   net->outs[outIdx].target;
  // index of added split operator
  s16 split;
  if( target < 0) {
    // no target
    split = net_add_op(eOpSplit);
    if(split < 0) {
      // failed to add, do nothing
      return outIdx; 
    } else {
      // FIXME: net_op_in_idx is pretty slow
      net_connect(outIdx, net_op_in_idx(split, 0));
      return net_op_out_idx(split, 0);
    } // add ok
  } else {
    // had target; reroute
    split = net_add_op(eOpSplit);
    // fix for github issue #219
    // get the target again, because maybe it was a DSP param
    // (if it was, its index will have shifted. 
    // patch and presets have been updated, but local var has not.)
    target =   net->outs[outIdx].target;
    if(split < 0) {
      // failed to add, do nothing
      return outIdx; 
    } else {
      // FIXME: net_op_in_idx is pretty slow
      net_connect(outIdx, net_op_in_idx(split, 0));
      net_connect(net_op_out_idx(split, 0), target);
      return net_op_out_idx(split, 1);
    } // add ok
  }
}
Example #3
0
// function keys
void handle_key_0(s32 val) {
  if(val == 0) { return; }
  if(check_key(0)) {
    // select op's inputs on ins page
    pages[ePageIns].select = net_op_in_idx(*pageSelect, 0);
    print_dbg("\r\n got 1st input index for selected op ( ");
    print_dbg_ulong( *pageSelect );
    print_dbg(", result : ");
    print_dbg_ulong( net_op_in_idx(*pageSelect, 0));
    // go to inputs page
    set_page(ePageIns);
    redraw_ins();
  }
  show_foot();
}
Example #4
0
File: net.c Project: doomglue/aleph
// destroy last operator created
s16 net_pop_op(void) {
  const s16 opIdx = net->numOps - 1;
  op_t* op = net->ops[opIdx];
  int i=0;
  int x, y;

  app_pause();
  // bail if system op
  if(net_op_flag (opIdx, eOpFlagSys)) { return 1; }
  // de-init
  op_deinit(op);
  // store the global index of the first input
  x = net_op_in_idx(opIdx, 0);
  y = x + op->numInputs;

  // check if anything connects here
  for(i=0; i<net->numOuts; i++) {
    // this check works b/c we know this is last op in list
    if( net->outs[i].target >= x ) {
      if( net->outs[i].target < y) {
	net_disconnect(i);
      } else {
	//	net->outs[i].target -= op->numInputs;
	net_connect(i, net->outs[i].target - op->numInputs); 
      }
    }
  }
  // erase input nodes
  while(x < y) {
    net_init_inode(x++);
  }
  // store the global index of the first output
  x = net_op_out_idx(opIdx, 0);
  y = x + op->numOutputs;
  // erase output nodes
  while(x < y) {
    net_init_onode(x++);
  }

  net->numIns -= op->numInputs;
  net->numOuts -= op->numOutputs;

  net->opPoolOffset -= op_registry[op->type].size;
  net->numOps -= 1;

  app_resume();
  return 0;

}
Example #5
0
// destroy last operator created
s16 net_pop_op(void) {
  const s16 opIdx = net->numOps - 1;
  op_t* op = net->ops[opIdx];
  int i, j;
  int x, y;
  int ins;
  int numInsSave = net->numIns;
  int idxOld, idxNew;

  app_pause();
  // bail if system op
  if(net_op_flag (opIdx, eOpFlagSys)) { return 1; }
  // de-init
  op_deinit(op);
  ins = op->numInputs;
  // store the global index of the first input
  x = net_op_in_idx(opIdx, 0);
  y = x + ins;

  // check if anything connects here
  for(i=0; i<net->numOuts; i++) {
    // this check works b/c we know this is last op in list
    if( net->outs[i].target >= x ) {
      if( net->outs[i].target < y) {
	net_disconnect(i);
      } else {
	/// this should take care of both param and op input targets.
	net_connect(i, net->outs[i].target - op->numInputs); 
      }
    }
  }
  // erase input nodes
  while(x < y) {
    net_init_inode(x++);
  }
  // store the global index of the first output
  x = net_op_out_idx(opIdx, 0);
  y = x + op->numOutputs;
  // erase output nodes
  while(x < y) {
    net_init_onode(x++);
  }

  net->numIns -= op->numInputs;
  net->numOuts -= op->numOutputs;

  net->opPoolOffset -= op_registry[op->type].size;
  net->numOps -= 1;

  // FIXME: shift preset param data and connections to params, 
  // since they share an indexing list with inputs and we just changed it.

  for(i=0; i<NET_PRESETS_MAX; ++i) {
    // shift parameter nodes in preset data
    for(j=0; j<net->numParams; ++j) {
      // this was the old param index
      idxOld = j + numInsSave;
      // copy to new param index
      idxNew = idxOld - ins;
      presets[i].ins[idxNew].value = presets[i].ins[idxOld].value;
      presets[i].ins[idxNew].enabled = presets[i].ins[idxOld].enabled;
      // clear the old data.
      presets[i].ins[idxOld].enabled = 0;
      presets[i].ins[idxOld].value = 0;
    }

  }


  app_resume();
  return 0;

}