static void jack_audio_port_mixdown (jack_port_t *port, jack_nframes_t nframes) { JSList *node; jack_port_t *input; #ifndef ARCH_X86 jack_nframes_t n; jack_default_audio_sample_t *dst, *src; #endif jack_default_audio_sample_t *buffer; /* by the time we've called this, we've already established the existence of more than one connection to this input port and allocated a mix_buffer. */ /* no need to take connection lock, since this is called from the process() callback, and the jack server ensures that no changes to connections happen during this time. */ node = port->connections; input = (jack_port_t*)node->data; buffer = port->mix_buffer; #ifndef USE_DYNSIMD memcpy (buffer, jack_output_port_buffer (input), sizeof(jack_default_audio_sample_t) * nframes); #else /* USE_DYNSIMD */ opt_copy (buffer, jack_output_port_buffer (input), nframes); #endif /* USE_DYNSIMD */ for (node = jack_slist_next (node); node; node = jack_slist_next (node)) { input = (jack_port_t*)node->data; #ifndef USE_DYNSIMD n = nframes; dst = buffer; src = jack_output_port_buffer (input); while (n--) *dst++ += *src++; #else /* USE_DYNSIMD */ opt_mix (buffer, jack_output_port_buffer (input), nframes); #endif /* USE_DYNSIMD */ } }
int add_inst(LEXER *lp, char *inst_name) { enum {START,NUM1,NUM2,NUM3,NUM4,END} state = START; double x1, y1; // pick value double x2, y2; // pick value double x3, y3; // pick value double xold=0.0, yold=0.0; // previous pick value to suppress double pics int numpicks=0; // number of picks int done=0; TOKEN token; OPTS opts; char *word; int debug=0; struct db_inst *ip; DB_TAB *ed_rep; XFORM *xp; double xx, yy; opt_set_defaults(&opts); // rl_saveprompt(); rl_setprompt("ADD_INST> "); if (debug) printf("currep = %s\n", currep->name); if (debug) printf("adding inst %s\n", inst_name); /* don't destroy it if it's already in memory */ if (debug) printf("calling db_lookup with %s\n", inst_name); if (loadrep(inst_name) == 0) { printf("warning: you can't add a null instance: %s\n", inst_name); token_flush_EOL(lp); done++; } if ((ed_rep = db_lookup(inst_name)) == 0) { printf("ADD INST: instance not found: %s\n", inst_name ); return(-1); } bb_xmin=ed_rep->minx; bb_xmax=ed_rep->maxx; bb_ymin=ed_rep->miny; bb_ymax=ed_rep->maxy; if (debug) printf("currep = %s\n", currep->name); if (strcmp(currep->name, inst_name) == 0 || db_contains(inst_name, currep->name)) { printf("ADD INST: Sorry, to do that would cause a recursive definition\n" ); return(-1); } while (!done) { token = token_look(lp, &word); if (debug) printf("got %s: %s state: %d\n", tok2str(token), word, state); if (token==CMD) { state=END; } switch(state) { case START: /* get option or first xy pair */ db_checkpoint(lp); rubber_set_callback(draw_inst_bb); if (token == OPT ) { token_get(lp, &word); if (opt_parse(word, INST_OPTS, &opts) == -1) { state = END; } else { /* an option may have scaled the bounding box */ /* clear callback, recompute and then restart */ rubber_clear_callback(draw_inst_bb); xp = matrix_from_opts(&opts); bb_xmin = bb_xmax = bb_ymin = bb_ymax = 0.0; xx = ed_rep->minx; yy = ed_rep->miny; xform_point(xp, &xx, &yy); if (xx < bb_xmin) bb_xmin = xx; if (yy < bb_ymin) bb_ymin = yy; if (xx > bb_xmax) bb_xmax = xx; if (yy > bb_ymax) bb_ymax = yy; xx = ed_rep->maxx; yy = ed_rep->maxy; xform_point(xp, &xx, &yy); if (xx < bb_xmin) bb_xmin = xx; if (yy < bb_ymin) bb_ymin = yy; if (xx > bb_xmax) bb_xmax = xx; if (yy > bb_ymax) bb_ymax = yy; xx = ed_rep->maxx; yy = ed_rep->miny; xform_point(xp, &xx, &yy); if (xx < bb_xmin) bb_xmin = xx; if (yy < bb_ymin) bb_ymin = yy; if (xx > bb_xmax) bb_xmax = xx; if (yy > bb_ymax) bb_ymax = yy; xx = ed_rep->minx; yy = ed_rep->maxy; xform_point(xp, &xx, &yy); if (xx < bb_xmin) bb_xmin = xx; if (yy < bb_ymin) bb_ymin = yy; if (xx > bb_xmax) bb_xmax = xx; if (yy > bb_ymax) bb_ymax = yy; free(xp); state = START; rubber_set_callback(draw_inst_bb); if (opts.stepflag) { rl_setprompt("ARRAY ORIGIN> "); rubber_clear_callback(); } } } else if (token == NUMBER) { if (opts.stepflag) { state = NUM2; } else { state = NUM1; } } else if (token == EOL) { token_get(lp, &word); /* just eat it up */ state = START; } else if (token == EOC || token == CMD) { state = END; } else { token_err("INST", lp, "expected OPT or NUMBER", token); state = END; } break; case NUM1: /* get pair of xy coordinates */ if (token == NUMBER) { if (getnum(lp, "INST", &x1, &y1)) { // supress double clicks if (debug) printf("%d %g %g %g %g\n", numpicks, x1, y1, xold, yold); if (numpicks==0 || ((xold != x1) || (yold != y1))) { db_add_inst(currep, ed_rep, opt_copy(&opts), x1, y1); rubber_clear_callback(); need_redraw++; rubber_set_callback(draw_inst_bb); } numpicks++; xold=x1; yold=y1; state = START; } else { state = END; } } else if (token == EOL) { token_get(lp, &word); } else if (token == EOC || token == CMD) { state = END; } else { token_err("INST", lp, "expected NUMBER", token); state = END; } break; case NUM2: /* get column end coordinate */ rubber_clear_callback(); if (token == NUMBER) { if (getnum(lp, "INST", &x1, &y1)) { rl_setprompt("COLUMN EXTENT> "); state = NUM3; } else { state = END; } } else if (token == EOL) { token_get(lp, &word); } else if (token == EOC || token == CMD) { state = END; } else { token_err("INST", lp, "expected NUMBER", token); state = END; } break; case NUM3: /* get column end coordinate */ if (token == NUMBER) { if (getnum(lp, "INST", &x3, &y3)) { rl_setprompt("ROW EXTENT> "); state = NUM4; } else { state = END; } } else if (token == EOL) { token_get(lp, &word); } else if (token == EOC || token == CMD) { state = END; } else { token_err("INST", lp, "expected NUMBER", token); state = END; } break; case NUM4: /* get column end coordinate */ if (token == NUMBER) { if (getnum(lp, "INST", &x2, &y2)) { if (debug) printf("%g %g %g %g %g %g\n", x1, y1, x2, y2, x3, y3); ip = db_add_inst(currep, ed_rep, opt_copy(&opts), x1, y1); ip->colx = x3; ip->coly = y3; ip->rowx = x2; ip->rowy = y2; rubber_clear_callback(); need_redraw++; state = END; } else { state = END; } } else if (token == EOL) { token_get(lp, &word); } else if (token == EOC || token == CMD) { state = END; } else { token_err("INST", lp, "expected NUMBER", token); state = END; } break; case END: default: if (token == EOC || token == CMD) { ; } else { token_flush_EOL(lp); } done++; break; } } rubber_clear_callback(); rl_restoreprompt(); return(1); }