// Engine/entry1.c { "activeorder", S(ACTIVEORDER), 2, "k", "", NULL, activeorder, NULL }, { "turnoffnow", S(LINK), 2, "", "", NULL, turnoffnow }, // H/entry1.h int activeorder(CSOUND *csound, ACTIVEORDER *p); int turnoffnow(CSOUND *csound, LINK *p); // H/insert.h typedef struct { OPDS h; MYFLT *orderNo; } ACTIVEORDER; // OOps/goto_ops.c int activeorder(CSOUND *csound, ACTIVEORDER *p) { INSDS *ip=NULL, *lcurip = csound->pds->insdshead; int insno, count=0; /* IV - Oct 16 2002: check for subinstr and user opcode */ /* find top level instrument instance */ while (lcurip->opcod_iobufs) lcurip = ((OPCOD_IOBUFS*) lcurip->opcod_iobufs)->parent_ip; insno = lcurip->insno; ip = &(csound->actanchor); while ((ip = ip->nxtact) != NULL && (int) ip->insno != insno); do { ++count; if(ip == lcurip) break; } while ((ip=ip->nxtact) != NULL && (int) ip->insno == insno); *p->orderNo = count; return OK; } int turnoffnow(CSOUND *csound, LINK *p) /* terminate the current instrument */ { /* called by turnoff statmt at Ptime */ INSDS *lcurip = csound->pds->insdshead; /* IV - Oct 16 2002: check for subinstr and user opcode */ /* find top level instrument instance */ while (lcurip->opcod_iobufs) lcurip = ((OPCOD_IOBUFS*) lcurip->opcod_iobufs)->parent_ip; xturnoff_now(csound, lcurip); /* turn off immediately */ if (lcurip->xtratim <= 0) while (csound->pds->nxtp != NULL) csound->pds = csound->pds->nxtp; /* loop to last opds */ return OK; }