MCPcopy Create free account
hub / github.com/csound/csound / instanceOpcode_

Function instanceOpcode_

Engine/linevent.c:613–653  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

611}
612
613int instanceOpcode_(CSOUND *csound, LINEVENT2 *p, int insname)
614{
615 EVTBLK evt;
616 int i;
617
618 evt.strarg = NULL; evt.scnt = 0;
619 evt.opcod = 'i';
620 evt.pcnt = p->INOCOUNT;
621
622 /* pass in the memory to hold the instance after insertion */
623 evt.pinstance = (void *) p->inst;
624
625 /* IV - Oct 31 2002: allow string argument */
626 if (evt.pcnt > 0) {
627 int res;
628 if (insname) {
629 res = csound->strarg2insno(csound,
630 ((STRINGDAT*) p->args[0])->data, 1);
631 /* The comprison below and later is suspect */
632 if (UNLIKELY(evt.p[1] == NOT_AN_INSTRUMENT)) return NOTOK;
633 evt.p[1] = (MYFLT)res;
634 evt.strarg = NULL; evt.scnt = 0;
635 }
636 else {
637 if (csound->ISSTRCOD(*p->args[0])) {
638 res = csound->strarg2insno(csound,
639 get_arg_string(csound, *p->args[0]), 1);
640 if (UNLIKELY(evt.p[1] == NOT_AN_INSTRUMENT)) return NOTOK;
641 evt.p[1] = (MYFLT)res;
642 } else evt.p[1] = *p->args[0];
643 evt.strarg = NULL; evt.scnt = 0;
644 }
645 for (i = 2; i <= evt.pcnt; i++)
646 evt.p[i] = *p->args[i-1];
647 }
648 if (insert_score_event_at_sample(csound, &evt, csound->icurTime) != 0)
649 return csound->PerfError(csound, &(p->h),
650 Str("instance: error creating event"));
651
652 return OK;
653}
654
655int instanceOpcode(CSOUND *csound, LINEVENT2 *p)
656{

Callers 2

instanceOpcodeFunction · 0.85
instanceOpcode_SFunction · 0.85

Calls 2

get_arg_stringFunction · 0.85

Tested by

no test coverage detected