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

Function eventOpcodeI_

Engine/linevent.c:528–601  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

526/* i-time version of event opcode */
527
528int eventOpcodeI_(CSOUND *csound, LINEVENT *p, int insname, char p1)
529{
530 EVTBLK evt;
531 int i, err = 0;
532 char opcod;
533 memset(&evt, 0, sizeof(EVTBLK));
534
535 if (p1==0)
536 opcod = *((STRINGDAT*) p->args[0])->data;
537 else opcod = p1;
538 if (UNLIKELY((opcod != 'a' && opcod != 'i' && opcod != 'q' && opcod != 'f' &&
539 opcod != 'e' && opcod != 'd')
540 /*|| ((STRINGDAT*) p->args[0])->data[1] != '\0'*/))
541 return csound->InitError(csound, "%s", Str(errmsg_1));
542 evt.strarg = NULL; evt.scnt = 0;
543 evt.opcod = opcod;
544 if (p->flag==1) evt.pcnt = p->argno-1;
545 else
546 evt.pcnt = p->INOCOUNT - 1;
547 /* IV - Oct 31 2002: allow string argument */
548 if (evt.pcnt > 0) {
549 if (insname) {
550 int res;
551 if (UNLIKELY(evt.opcod != 'i' && evt.opcod != 'q' && opcod != 'd'))
552 return csound->InitError(csound, "%s", Str(errmsg_2));
553 res = csound->strarg2insno(csound,((STRINGDAT *)p->args[1])->data, 1);
554 if (UNLIKELY(res == NOT_AN_INSTRUMENT)) return NOTOK;
555 evt.p[1] = (MYFLT)res;
556 evt.strarg = NULL; evt.scnt = 0;
557 for (i = 2; i <= evt.pcnt; i++)
558 evt.p[i] = *p->args[i];
559 }
560 else {
561 evt.strarg = NULL; evt.scnt = 0;
562 if (csound->ISSTRCOD(*p->args[1])) {
563 int res = csound->strarg2insno(csound,
564 get_arg_string(csound, *p->args[1]), 1);
565 if (UNLIKELY(evt.p[1] == NOT_AN_INSTRUMENT)) return NOTOK;
566 evt.p[1] = (MYFLT)res;
567 }
568 else { /* Should check for valid instr num here */
569 MYFLT insno = FABS(*p->args[1]);
570 evt.p[1] = *p->args[1];
571 if (UNLIKELY((opcod == 'i' || opcod == 'd') && (insno ==0 ||
572 insno > csound->engineState.maxinsno ||
573 !csound->engineState.instrtxtp[(int)insno]))) {
574 csound->Message(csound, Str("WARNING: Cannot Find Instrument %d. No action."),
575 (int) insno);
576 return OK;
577 }
578 evt.strarg = NULL; evt.scnt = 0;
579 }
580 for (i = 2; i <= evt.pcnt; i++)
581 evt.p[i] = *p->args[i];
582 }
583
584 }
585 if(opcod == 'd') {

Callers 5

eventOpcodeIFunction · 0.85
eventOpcodeI_SFunction · 0.85
schedule_arrayFunction · 0.85
scheduleFunction · 0.85
schedule_SFunction · 0.85

Calls 3

get_arg_stringFunction · 0.85
MessageMethod · 0.80

Tested by

no test coverage detected