| 2355 | /* allocates and sets up all pntrs */ |
| 2356 | |
| 2357 | static void instance(CSOUND *csound, int insno) |
| 2358 | { |
| 2359 | INSTRTXT *tp; |
| 2360 | INSDS *ip; |
| 2361 | OPTXT *optxt; |
| 2362 | OPDS *opds, *prvids, *prvpds; |
| 2363 | const OENTRY *ep; |
| 2364 | int i, n, pextent, pextra, pextrab; |
| 2365 | char *nxtopds, *opdslim; |
| 2366 | MYFLT **argpp, *lclbas; |
| 2367 | CS_VAR_MEM *lcloffbas; // start of pfields |
| 2368 | char* opMemStart; |
| 2369 | |
| 2370 | OPARMS *O = csound->oparms; |
| 2371 | int odebug = O->odebug; |
| 2372 | ARG* arg; |
| 2373 | int argStringCount; |
| 2374 | CS_VARIABLE* current; |
| 2375 | |
| 2376 | tp = csound->engineState.instrtxtp[insno]; |
| 2377 | n = 3; |
| 2378 | if (O->midiKey>n) n = O->midiKey; |
| 2379 | if (O->midiKeyCps>n) n = O->midiKeyCps; |
| 2380 | if (O->midiKeyOct>n) n = O->midiKeyOct; |
| 2381 | if (O->midiKeyPch>n) n = O->midiKeyPch; |
| 2382 | if (O->midiVelocity>n) n = O->midiVelocity; |
| 2383 | if (O->midiVelocityAmp>n) n = O->midiVelocityAmp; |
| 2384 | pextra = n-3; |
| 2385 | pextrab = ((i = tp->pmax - 3L) > 0 ? (int) i * sizeof(CS_VAR_MEM) : 0); |
| 2386 | /* alloc new space, */ |
| 2387 | pextent = sizeof(INSDS) + pextrab + pextra*sizeof(CS_VAR_MEM); |
| 2388 | ip = |
| 2389 | (INSDS*) csound->Calloc(csound, |
| 2390 | (size_t) pextent + tp->varPool->poolSize + |
| 2391 | (tp->varPool->varCount * |
| 2392 | CS_FLOAT_ALIGN(CS_VAR_TYPE_OFFSET)) + |
| 2393 | (tp->varPool->varCount * sizeof(CS_VARIABLE*)) + |
| 2394 | tp->opdstot); |
| 2395 | ip->csound = csound; |
| 2396 | ip->m_chnbp = (MCHNBLK*) NULL; |
| 2397 | ip->instr = tp; |
| 2398 | /* IV - Oct 26 2002: replaced with faster version (no search) */ |
| 2399 | ip->prvinstance = tp->lst_instance; |
| 2400 | if (tp->lst_instance) |
| 2401 | tp->lst_instance->nxtinstance = ip; |
| 2402 | else |
| 2403 | tp->instance = ip; |
| 2404 | tp->lst_instance = ip; |
| 2405 | /* link into free instance chain */ |
| 2406 | ip->nxtact = tp->act_instance; |
| 2407 | tp->act_instance = ip; |
| 2408 | ip->insno = insno; |
| 2409 | csoundDebugMsg(csound,"instance(): tp->act_instance = %p\n", |
| 2410 | tp->act_instance); |
| 2411 | |
| 2412 | |
| 2413 | if (insno > csound->engineState.maxinsno) { |
| 2414 | // size_t pcnt = (size_t) tp->opcode_info->perf_incnt; |
no test coverage detected