diff --git a/Engine/csound_orc_compile.c b/Engine/csound_orc_compile.c index 78f7c4f2f72..35fdec9ef12 100644 --- a/Engine/csound_orc_compile.c +++ b/Engine/csound_orc_compile.c @@ -1935,10 +1935,14 @@ if (engineState != &csound->engineState) { continue; if (PARSER_DEBUG) csound->DebugMsg(csound, "Instr 0 check on opcode=%s\n", bp->t.opcod); - if (UNLIKELY((thread = oentry->thread) & 06 || - (!thread && bp->t.pftype != 'b'))) { - csound->DebugMsg(csound, "***opcode=%s thread=%d pftype=%c\n", - bp->t.opcod, thread, bp->t.pftype); + /* VL: now the check is simply for oentry->perf, which is the + only condition possible for perf-time code + */ + if (UNLIKELY(oentry->perf != NULL || + (oentry->init == NULL && bp->t.pftype != 'b'))) { + thread = oentry->init && oentry->perf ? 3 : (oentry->init ? 1 : 2); + csound->DebugMsg(csound, "***opcode=%s thread=%d", + bp->t.opcod, thread); /* synterr(csound, Str("perf-pass statements illegal in header blk (%s)\n"), oentry->opname);*/ diff --git a/Engine/csound_orc_semantics.c b/Engine/csound_orc_semantics.c index 830b8a9065d..05ff59855f4 100644 --- a/Engine/csound_orc_semantics.c +++ b/Engine/csound_orc_semantics.c @@ -2205,7 +2205,7 @@ int add_struct_definition(CSOUND* csound, TREE* structDefTree) { // csound->Message(csound, "Member Found: %s : %s\n", memBase, typedIdentArg); CONS_CELL* member = csound->Calloc(csound, sizeof(CONS_CELL)); - member->value = var; + member->value = var; type->members = cs_cons_append(type->members, member); current = current->next; } @@ -2220,10 +2220,9 @@ int add_struct_definition(CSOUND* csound, TREE* structDefTree) { oentry.opname = cs_strdup(csound, temp); oentry.dsblksiz = sizeof(INIT_STRUCT_VAR); oentry.flags = 0; - oentry.thread = 1; - oentry.iopadr = initStructVar; - oentry.kopadr = NULL; - oentry.aopadr = NULL; + oentry.init = initStructVar; + oentry.perf = NULL; + oentry.deinit = NULL; oentry.useropinfo = NULL; /* FIXME - this is not yet implemented */ diff --git a/Engine/entry1.c b/Engine/entry1.c index b7b6391bcdc..4482d8dc5ca 100644 --- a/Engine/entry1.c +++ b/Engine/entry1.c @@ -67,15 +67,15 @@ */ /* outarg types include: - i, k, a, S as above - * multiple out args of any-type - m multiple out aargs - z multiple out kargs - I multiple out irate (not implemented yet) - s deprecated (use a or k as required) - X multiple args (a, k, or i-rate) IV - Sep 1 2002 - N multiple args (a, k, i, or S-rate) - F multiple args (f-rate)# + i, k, a, S as above + * multiple out args of any-type + m multiple out aargs + z multiple out kargs + I multiple out irate (not implemented yet) + s deprecated (use a or k as required) + X multiple args (a, k, or i-rate) IV - Sep 1 2002 + N multiple args (a, k, i, or S-rate) + F multiple args (f-rate)# */ /* inargs and outargs may also be arrays, e.g. "a[b]" is an array of @@ -85,1203 +85,1213 @@ OENTRY opcodlst_1[] = { /* opcode dspace flags thread outarg inargs isub ksub asub */ - { "", 0, 0, 0, "", "", NULL, NULL, NULL, NULL }, - { "instr", 0, 0, 0, "", "", NULL, NULL, NULL, NULL }, - { "endin", 0, 0, 0, "", "", NULL, NULL, NULL, NULL }, + { "", 0, 0, "", "", NULL, NULL, NULL, NULL }, + { "instr", 0, 0, "", "", NULL, NULL, NULL, NULL }, + { "endin", 0, 0, "", "", NULL, NULL, NULL, NULL }, /* IV - Sep 8 2002 */ - { "opcode", 0, 0, 0, "", "", NULL, NULL, NULL, NULL }, - { "endop", 0, 0, 0, "", "", NULL, NULL, NULL, NULL }, - { "declare", 0, 0, 0, "", "", NULL, NULL, NULL, NULL }, - { "$label", S(LBLBLK), 0,0, "", "", NULL, NULL, NULL, NULL }, - { "pset", S(PVSET), 0,0, "", "m", NULL, NULL, NULL, NULL }, + { "opcode", 0, 0, "", "", NULL, NULL, NULL, NULL }, + { "endop", 0, 0, "", "", NULL, NULL, NULL, NULL }, + { "declare", 0, 0, "", "", NULL, NULL, NULL, NULL }, + { "$label", S(LBLBLK), 0, "", "", NULL, NULL, NULL, NULL }, + { "pset", S(PVSET), 0, "", "m", NULL, NULL, NULL, NULL }, /* IV - Sep 8 2002 - added entries for user defined opcodes, xin, xout */ /* and setksmps */ - { "##userOpcode", S(UOPCODE),0, 7, "", "", useropcdset, useropcd, useropcd, NULL }, + { "##userOpcode", S(UOPCODE),0, "", "", useropcdset, useropcd, NULL, NULL }, /* IV - Sep 10 2002: removed perf time routines of xin and xout */ - { "xin", S(XIN_MAX),0, 1, "****************", "", xinset, NULL, NULL, NULL }, - /* { "xin.64", S(XIN_HIGH),0, 1, - "****************************************************************", "", - xinset, NULL, NULL }, - { "##xin256", S(XIN_MAX),0, 1, - "****************************************************************" - "****************************************************************" - "****************************************************************" - "****************************************************************", "", - xinset, NULL, NULL },*/ - { "xout", S(XOUT_MAX),0, 1, "", "*", xoutset, NULL, NULL, NULL }, - { "setksmps", S(SETKSMPS),0, 1, "", "i", setksmpsset, NULL, NULL }, - { "oversample", S(OVSMPLE),0, 1, "", "io", oversampleset, NULL, NULL }, - { "undersample", S(OVSMPLE),0, 1, "", "io", oversampleset, NULL, NULL }, - { "ctrlinit",S(CTLINIT),0,1, "", "im", ctrlinit, NULL, NULL, NULL}, - { "ctrlinit.S",S(CTLINITS),0,1, "", "Sm", ctrlnameinit, NULL, NULL, NULL}, - { "ctrlsave",S(SAVECTRL),0,3, "k[]","im", savectrl_init, savectrl_perf, NULL, NULL}, - { "ctrlprint.S",S(PRINTCTRL),0,3, "", "k[]S", printctrl_init1, printctrl, NULL}, - { "ctrlprint",S(PRINTCTRL),0,3, "", "k[]", printctrl_init, printctrl, NULL}, - { "ctrlpreset", S(PRESETCTRL1), 0,3, "k", "kk[]", presetctrl1_init, presetctrl1_perf, NULL}, - { "ctrlpreset", S(PRESETCTRL), 0,3, "k", "kim", presetctrl_init, presetctrl_perf, NULL}, - { "ctrlselect", S(SELECTCTRL), 0,3,"", "k", selectctrl_init, selectctrl_perf, NULL }, - { "ctrlprintpresets", S(PRINTPRESETS), 0,3, "", "", printpresets_init, printpresets_perf, NULL}, - { "ctrlprintpresets.S", S(PRINTPRESETS), 0,3, "", "S", printpresets_init1, printpresets_perf, NULL}, - { "massign",S(MASSIGN), 0,1, "", "iip",massign_p, NULL, NULL, NULL}, - { "massign.iS",S(MASSIGNS), 0,1, "", "iSp",massign_S, NULL, NULL, NULL}, - { "turnon", S(TURNON), 0,1, "", "io", turnon, NULL, NULL, NULL}, - { "turnon.S", S(TURNON), 0,1, "", "So", turnon_S, NULL, NULL, NULL}, - { "remoteport", S(REMOTEPORT), 0,1, "", "i", remoteport, NULL, NULL, NULL}, - { "insremot",S(INSREMOT),0,1, "", "SSm",insremot, NULL, NULL, NULL}, - { "midremot",S(MIDREMOT),0,1, "", "SSm",midremot, NULL, NULL, NULL}, - { "insglobal",S(INSGLOBAL),0,1, "", "Sm", insglobal, NULL, NULL, NULL}, - { "midglobal",S(MIDGLOBAL),0,1, "", "Sm", midglobal, NULL, NULL, NULL}, - { "ihold", S(LINK),0, 1, "", "", ihold, NULL, NULL, NULL }, - { "turnoff",S(LINK),0, 2, "", "", NULL, turnoff, NULL, NULL }, - /* VL: 10.2.22 this was thread 1, but with parser3 we need to make string assignment on threads 1 & 2 */ - { "=.S", S(STRCPY_OP),0, 3, "S", "S", + { "xin", S(XIN_MAX),0, "****************", "", xinset, NULL, NULL, NULL }, + /* { "xin.64", S(XIN_HIGH),0, + "****************************************************************", "", + xinset, NULL, NULL }, + { "##xin256", S(XIN_MAX),0, + "****************************************************************" + "****************************************************************" + "****************************************************************" + "****************************************************************", "", + xinset, NULL, NULL },*/ + { "xout", S(XOUT_MAX),0, "", "*", xoutset, NULL, NULL, NULL }, + { "setksmps", S(SETKSMPS),0, "", "i", setksmpsset, NULL, NULL }, + { "oversample", S(OVSMPLE),0, "", "io", oversampleset, NULL, NULL }, + { "undersample", S(OVSMPLE),0, "", "io", oversampleset, NULL, NULL }, + { "ctrlinit",S(CTLINIT),0, "", "im", ctrlinit, NULL, NULL, NULL}, + { "ctrlinit.S",S(CTLINITS),0, "", "Sm", ctrlnameinit, NULL, NULL, NULL}, + { "ctrlsave",S(SAVECTRL),0, "k[]","im", savectrl_init, savectrl_perf, NULL, NULL}, + { "ctrlprint.S",S(PRINTCTRL),0, "", "k[]S", printctrl_init1, printctrl, NULL}, + { "ctrlprint",S(PRINTCTRL),0, "", "k[]", printctrl_init, printctrl, NULL}, + { "ctrlpreset", S(PRESETCTRL1), 0, "k", "kk[]", presetctrl1_init, presetctrl1_perf, NULL}, + { "ctrlpreset", S(PRESETCTRL), 0, "k", "kim", presetctrl_init, presetctrl_perf, NULL}, + { "ctrlselect", S(SELECTCTRL), 0,"", "k", selectctrl_init, selectctrl_perf, NULL }, + { "ctrlprintpresets", S(PRINTPRESETS), 0, "", "", printpresets_init, printpresets_perf, NULL}, + { "ctrlprintpresets.S", S(PRINTPRESETS), 0, "", "S", printpresets_init1, printpresets_perf, NULL}, + { "massign",S(MASSIGN), 0, "", "iip",massign_p, NULL, NULL, NULL}, + { "massign.iS",S(MASSIGNS), 0, "", "iSp",massign_S, NULL, NULL, NULL}, + { "turnon", S(TURNON), 0, "", "io", turnon, NULL, NULL, NULL}, + { "turnon.S", S(TURNON), 0, "", "So", turnon_S, NULL, NULL, NULL}, + { "remoteport", S(REMOTEPORT), 0, "", "i", remoteport, NULL, NULL, NULL}, + { "insremot",S(INSREMOT),0, "", "SSm",insremot, NULL, NULL, NULL}, + { "midremot",S(MIDREMOT),0, "", "SSm",midremot, NULL, NULL, NULL}, + { "insglobal",S(INSGLOBAL),0, "", "Sm", insglobal, NULL, NULL, NULL}, + { "midglobal",S(MIDGLOBAL),0, "", "Sm", midglobal, NULL, NULL, NULL}, + { "ihold", S(LINK),0, "", "", ihold, NULL, NULL, NULL }, + { "turnoff",S(LINK),0, "", "", NULL, turnoff, NULL, NULL }, + /* VL: 10.2.22 this was thread but with parser3 we need to make string assignment on threads 1 & 2 */ + { "=.S", S(STRCPY_OP),0, "S", "S", (SUBR) strcpy_opcode_S, (SUBR) strassign_k, (SUBR) NULL, NULL }, - /* VL: 11.2.22 this was thread 2, but with an update count, we need to be initialised */ - { "#=.S", S(STRCPY_OP),0, 3, "S", "S", + /* VL: 11.2.22 this was thread but with an update count, we need to be initialised */ + { "#=.S", S(STRCPY_OP),0, "S", "S", (SUBR) strcpy_opcode_S, (SUBR) strassign_k, (SUBR) NULL, NULL }, - { "=.T", S(STRCPY_OP),0, 1, "S", "i", + { "=.T", S(STRCPY_OP),0, "S", "i", (SUBR) strcpy_opcode_p, (SUBR) NULL, (SUBR) NULL, NULL }, - { "=.r", S(ASSIGN),0, 1, "r", "i", rassign, NULL, NULL, NULL }, - { "=.i", S(ASSIGNM),0, 1, "IIIIIIIIIIIIIIIIIIIIIIII", "m", + { "=.r", S(ASSIGN),0, "r", "i", rassign, NULL, NULL, NULL }, + { "=.i", S(ASSIGNM),0, "IIIIIIIIIIIIIIIIIIIIIIII", "m", minit, NULL, NULL, NULL }, - { "=.k", S(ASSIGNM),0, 2, "zzzzzzzzzzzzzzzzzzzzzzzz", "z", + { "=.k", S(ASSIGNM),0, "zzzzzzzzzzzzzzzzzzzzzzzz", "z", NULL, minit, NULL, NULL }, - { "=.a", S(ASSIGN),0, 2, "a", "a", NULL, gaassign, NULL }, - { "=.l", S(ASSIGN),0, 2, "a", "a", NULL, laassign, NULL }, - { "=.up", S(UPSAMP),0, 2, "a", "k", NULL, (SUBR)upsamp, NULL }, - { "=.down", S(DOWNSAMP),0, 3, "k", "ao", (SUBR)downset,(SUBR)downsamp }, - // { "=.t", S(ASSIGNT),0, 2, "t", "kk", NULL, tassign, NULL }, - { "init.S", S(STRCPY_OP),0, 1, "S", "S", (SUBR) strcpy_opcode_S }, - { "init.Si", S(STRCPY_OP),0, 1, "S", "i", (SUBR) strcpy_opcode_p }, - { "init.i", S(ASSIGNM),0, 1, "IIIIIIIIIIIIIIIIIIIIIIII", "m", minit }, - { "init.k", S(ASSIGNM),0, 1, "zzzzzzzzzzzzzzzzzzzzzzzz", "m", minit }, - { "init.a", S(ASSIGNM),0, 1, "mmmmmmmmmmmmmmmmmmmmmmmm", "m", mainit }, - { ">", S(RELAT),0, 0, "b", "ii", gt, gt }, - { ">.0", S(RELAT),0, 0, "B", "kk", gt, gt }, - { ">=", S(RELAT),0, 0, "b", "ii", ge, ge }, - { ">=.0", S(RELAT),0, 0, "B", "kk", ge, ge }, - { "<", S(RELAT),0, 0, "b", "ii", lt, lt }, - { "<.0", S(RELAT),0, 0, "B", "kk", lt, lt }, - { "<=", S(RELAT),0, 0, "b", "ii", le, le }, - { "<=.0", S(RELAT),0, 0, "B", "kk", le, le }, - { "==", S(RELAT),0, 0, "b", "ii", eq, eq }, - { "==.0", S(RELAT),0, 0, "B", "kk", eq, eq }, - { "!=", S(RELAT),0, 0, "b", "ii", ne, ne }, - { "!=.0", S(RELAT),0, 0, "B", "kk", ne, ne }, - { "!", S(LOGCL),0, 0, "b", "b", b_not, b_not }, - { "!.0", S(LOGCL),0, 0, "B", "B", b_not, b_not }, - { "&&", S(LOGCL),0, 0, "b", "bb", and, and }, - { "&&.0", S(LOGCL),0, 0, "B", "BB", and, and }, - { "||", S(LOGCL),0, 0, "b", "bb", or, or }, - { "||.0", S(LOGCL),0, 0, "B", "BB", or, or }, - { ":cond.i", S(CONVAL),0, 1, "i", "bii", conval }, - { ":cond.k", S(CONVAL),0, 2, "k", "Bkk", NULL, conval }, - { ":cond.a", S(CONVAL),0, 2, "a", "Bxx", NULL, aconval }, - { ":cond.s", S(CONVAL),0, 1, "S", "bSS", conval, NULL }, - { ":cond.S", S(CONVAL),0, 3, "S", "BSS", conval, conval }, - { "##add.ii", S(AOP),0, 1, "i", "ii", addkk }, - { "##sub.ii", S(AOP),0, 1, "i", "ii", subkk }, - { "##mul.ii", S(AOP),0, 1, "i", "ii", mulkk }, - { "##div.ii", S(AOP),0, 1, "i", "ii", divkk }, - { "##mod.ii", S(AOP),0, 1, "i", "ii", modkk }, - { "##add.kk", S(AOP),0, 2, "k", "kk", NULL, addkk }, - { "##sub.kk", S(AOP),0, 2, "k", "kk", NULL, subkk }, - { "##mul.kk", S(AOP),0, 2, "k", "kk", NULL, mulkk }, - { "##div.kk", S(AOP),0, 2, "k", "kk", NULL, divkk }, - { "##mod.kk", S(AOP),0, 2, "k", "kk", NULL, modkk }, - { "##add.ka", S(AOP),0, 2, "a", "ka", NULL, addka }, - { "##sub.ka", S(AOP),0, 2, "a", "ka", NULL, subka }, - { "##mul.ka", S(AOP),0, 2, "a", "ka", NULL, mulka }, - { "##div.ka", S(AOP),0, 2, "a", "ka", NULL, divka }, - { "##mod.ka", S(AOP),0, 2, "a", "ka", NULL, modka }, - { "##add.ak", S(AOP),0, 2, "a", "ak", NULL, addak }, - { "##sub.ak", S(AOP),0, 2, "a", "ak", NULL, subak }, - { "##mul.ak", S(AOP),0, 2, "a", "ak", NULL, mulak }, - { "##div.ak", S(AOP),0, 2, "a", "ak", NULL, divak }, - { "##mod.ak", S(AOP),0, 2, "a", "ak", NULL, modak }, - { "##add.aa", S(AOP),0, 2, "a", "aa", NULL, addaa }, - { "##sub.aa", S(AOP),0, 2, "a", "aa", NULL, subaa }, - { "##mul.aa", S(AOP),0, 2, "a", "aa", NULL, mulaa }, - { "##div.aa", S(AOP),0, 2, "a", "aa", NULL, divaa }, - { "##mod.aa", S(AOP),0, 2, "a", "aa", NULL, modaa }, - { "##addin.i", S(ASSIGN),0, 1, "i", "i", addin, NULL }, - { "##addin.k", S(ASSIGN),0, 2, "k", "k", NULL, addin }, - { "##addin.K", S(ASSIGN),0, 2, "a", "k", NULL, addinak }, - { "##addin.a", S(ASSIGN),0, 2, "a", "a", NULL, addina }, - { "##subin.i", S(ASSIGN),0, 1, "i", "i", subin, NULL }, - { "##subin.k", S(ASSIGN),0, 2, "k", "k", NULL, subin }, - { "##subin.K", S(ASSIGN),0, 2, "a", "k", NULL, subinak }, - { "##subin.a", S(ASSIGN),0, 2, "a", "a", NULL, subina }, + { "=.a", S(ASSIGN),0, "a", "a", NULL, gaassign, NULL }, + { "=.l", S(ASSIGN),0, "a", "a", NULL, laassign, NULL }, + { "=.up", S(UPSAMP),0, "a", "k", NULL, (SUBR)upsamp, NULL }, + { "=.down", S(DOWNSAMP),0, "k", "ao", (SUBR)downset,(SUBR)downsamp }, + // { "=.t", S(ASSIGNT),0, "t", "kk", NULL, tassign, NULL }, + { "init.S", S(STRCPY_OP),0, "S", "S", (SUBR) strcpy_opcode_S }, + { "init.Si", S(STRCPY_OP),0, "S", "i", (SUBR) strcpy_opcode_p }, + { "init.i", S(ASSIGNM),0, "IIIIIIIIIIIIIIIIIIIIIIII", "m", minit }, + { "init.k", S(ASSIGNM),0, "zzzzzzzzzzzzzzzzzzzzzzzz", "m", minit }, + { "init.a", S(ASSIGNM),0, "mmmmmmmmmmmmmmmmmmmmmmmm", "m", mainit }, + /* VL 4.4.24 removing thread field: + These boolean were all marked thread 0, with both init and perf functions. + At instance(), there was a check for NOT thread 3 (meaning init XOR perf), + and a check for type 'b' output was made, placing the opcode in the init chain, + or else perf chain. + I'm Reinterpreting them as either init or perf by removing the relevant function. + This should take care of assigning these to the correct chain. + */ + { ">", S(RELAT),0, /* 0,*/ "b", "ii", gt, NULL }, + { ">.0", S(RELAT),0, /* 0,*/ "B", "kk", NULL, gt }, + { ">=", S(RELAT),0, /* 0,*/ "b", "ii", ge, NULL }, + { ">=.0", S(RELAT),0, /* 0,*/ "B", "kk", NULL, ge }, + { "<", S(RELAT),0, /* 0,*/ "b", "ii", lt, NULL }, + { "<.0", S(RELAT),0, /* 0,*/ "B", "kk", NULL, lt }, + { "<=", S(RELAT),0, /* 0,*/ "b", "ii", le, NULL }, + { "<=.0", S(RELAT),0, /* 0,*/ "B", "kk", NULL, le }, + { "==", S(RELAT),0, /* 0,*/ "b", "ii", eq, NULL }, + { "==.0", S(RELAT),0, /* 0,*/ "B", "kk", NULL, eq }, + { "!=", S(RELAT),0, /* 0,*/ "b", "ii", ne, NULL }, + { "!=.0", S(RELAT),0, /* 0,*/ "B", "kk", NULL, ne }, + { "!", S(LOGCL),0, /* 0,*/ "b", "b", b_not, NULL }, + { "!.0", S(LOGCL),0, /* 0,*/ "B", "B", NULL, b_not }, + { "&&", S(LOGCL),0, /* 0,*/ "b", "bb", and, NULL }, + { "&&.0", S(LOGCL),0, /* 0,*/ "B", "BB", NULL, and }, + { "||", S(LOGCL),0, /* 0,*/ "b", "bb", or, NULL }, + { "||.0", S(LOGCL),0, /* 0,*/ "B", "BB", NULL, or }, + /* end boolean */ + { ":cond.i", S(CONVAL),0, "i", "bii", conval }, + { ":cond.k", S(CONVAL),0, "k", "Bkk", NULL, conval }, + { ":cond.a", S(CONVAL),0, "a", "Bxx", NULL, aconval }, + { ":cond.s", S(CONVAL),0, "S", "bSS", conval, NULL }, + { ":cond.S", S(CONVAL),0, "S", "BSS", conval, conval }, + { "##add.ii", S(AOP),0, "i", "ii", addkk }, + { "##sub.ii", S(AOP),0, "i", "ii", subkk }, + { "##mul.ii", S(AOP),0, "i", "ii", mulkk }, + { "##div.ii", S(AOP),0, "i", "ii", divkk }, + { "##mod.ii", S(AOP),0, "i", "ii", modkk }, + { "##add.kk", S(AOP),0, "k", "kk", NULL, addkk }, + { "##sub.kk", S(AOP),0, "k", "kk", NULL, subkk }, + { "##mul.kk", S(AOP),0, "k", "kk", NULL, mulkk }, + { "##div.kk", S(AOP),0, "k", "kk", NULL, divkk }, + { "##mod.kk", S(AOP),0, "k", "kk", NULL, modkk }, + { "##add.ka", S(AOP),0, "a", "ka", NULL, addka }, + { "##sub.ka", S(AOP),0, "a", "ka", NULL, subka }, + { "##mul.ka", S(AOP),0, "a", "ka", NULL, mulka }, + { "##div.ka", S(AOP),0, "a", "ka", NULL, divka }, + { "##mod.ka", S(AOP),0, "a", "ka", NULL, modka }, + { "##add.ak", S(AOP),0, "a", "ak", NULL, addak }, + { "##sub.ak", S(AOP),0, "a", "ak", NULL, subak }, + { "##mul.ak", S(AOP),0, "a", "ak", NULL, mulak }, + { "##div.ak", S(AOP),0, "a", "ak", NULL, divak }, + { "##mod.ak", S(AOP),0, "a", "ak", NULL, modak }, + { "##add.aa", S(AOP),0, "a", "aa", NULL, addaa }, + { "##sub.aa", S(AOP),0, "a", "aa", NULL, subaa }, + { "##mul.aa", S(AOP),0, "a", "aa", NULL, mulaa }, + { "##div.aa", S(AOP),0, "a", "aa", NULL, divaa }, + { "##mod.aa", S(AOP),0, "a", "aa", NULL, modaa }, + { "##addin.i", S(ASSIGN),0, "i", "i", addin, NULL }, + { "##addin.k", S(ASSIGN),0, "k", "k", NULL, addin }, + { "##addin.K", S(ASSIGN),0, "a", "k", NULL, addinak }, + { "##addin.a", S(ASSIGN),0, "a", "a", NULL, addina }, + { "##subin.i", S(ASSIGN),0, "i", "i", subin, NULL }, + { "##subin.k", S(ASSIGN),0, "k", "k", NULL, subin }, + { "##subin.K", S(ASSIGN),0, "a", "k", NULL, subinak }, + { "##subin.a", S(ASSIGN),0, "a", "a", NULL, subina }, //{ "divz", 0xfffc }, - { "divz.ii", S(DIVZ),0, 1, "i", "iii", divzkk, NULL, NULL }, - { "divz.kk", S(DIVZ),0, 2, "k", "kkk", NULL, divzkk, NULL }, - { "divz.ak", S(DIVZ),0, 2, "a", "akk", NULL, divzak }, - { "divz.ka", S(DIVZ),0, 2, "a", "kak", NULL, divzka }, - { "divz.aa", S(DIVZ),0, 2, "a", "aak", NULL, divzaa }, - { "int.i", S(EVAL),0, 1, "i", "i", int1 }, - { "frac.i", S(EVAL),0, 1, "i", "i", frac1 }, - { "round.i",S(EVAL),0, 1, "i", "i", int1_round }, - { "floor.i",S(EVAL),0, 1, "i", "i", int1_floor }, - { "ceil.i", S(EVAL),0, 1, "i", "i", int1_ceil }, - { "rndseed", S(EVAL),0, 1, "", "i", rnd1seed }, - { "rnd.i", S(EVAL),0, 1, "i", "i", rnd1 }, - { "birnd.i",S(EVAL),0, 1, "i", "i", birnd1 }, - { "abs.i", S(EVAL),0, 1, "i", "i", abs1 }, - { "exp.i", S(EVAL),0, 1, "i", "i", exp01 }, - { "log.i", S(EVAL),0, 1, "i", "i", log01 }, - { "sqrt.i", S(EVAL),0, 1, "i", "i", sqrt1 }, - { "sin.i", S(EVAL),0, 1, "i", "i", sin1 }, - { "cos.i", S(EVAL),0, 1, "i", "i", cos1 }, - { "tan.i", S(EVAL),0, 1, "i", "i", tan1 }, - { "qinf.i", S(EVAL),0, 1, "i", "i", is_inf }, - { "qnan.i", S(EVAL),0, 1, "i", "i", is_NaN }, - { "sininv.i", S(EVAL),0, 1, "i", "i", asin1 }, - { "cosinv.i", S(EVAL),0, 1, "i", "i", acos1 }, - { "taninv.i", S(EVAL),0, 1, "i", "i", atan1 }, - { "taninv2.i",S(AOP),0, 1, "i", "ii", atan21 }, - { "log10.i",S(EVAL),0, 1, "i", "i", log101 }, - { "log2.i", S(EVAL),0, 1, "i", "i", log21 }, - { "sinh.i", S(EVAL),0, 1, "i", "i", sinh1 }, - { "cosh.i", S(EVAL),0, 1, "i", "i", cosh1 }, - { "tanh.i", S(EVAL),0, 1, "i", "i", tanh1 }, - { "int.k", S(EVAL),0, 2, "k", "k", NULL, int1 }, - { "frac.k", S(EVAL),0, 2, "k", "k", NULL, frac1 }, - { "round.k",S(EVAL),0, 2, "k", "k", NULL, int1_round }, - { "floor.k",S(EVAL),0, 2, "k", "k", NULL, int1_floor }, - { "ceil.k", S(EVAL),0, 2, "k", "k", NULL, int1_ceil }, - { "rnd.k", S(EVAL),0, 2, "k", "k", NULL, rnd1 }, - { "birnd.k",S(EVAL),0, 2, "k", "k", NULL, birnd1 }, - { "abs.k", S(EVAL),0, 2, "k", "k", NULL, abs1 }, - { "exp.k", S(EVAL),0, 2, "k", "k", NULL, exp01 }, - { "log.k", S(EVAL),0, 2, "k", "k", NULL, log01 }, - { "sqrt.k", S(EVAL),0, 2, "k", "k", NULL, sqrt1 }, - { "sin.k", S(EVAL),0, 2, "k", "k", NULL, sin1 }, - { "cos.k", S(EVAL),0, 2, "k", "k", NULL, cos1 }, - { "tan.k", S(EVAL),0, 2, "k", "k", NULL, tan1 }, - { "qinf.k", S(EVAL),0, 2, "k", "k", NULL, is_inf }, - { "qnan.k", S(EVAL),0, 2, "k", "k", NULL, is_NaN }, - { "sininv.k", S(EVAL),0, 2, "k", "k", NULL, asin1 }, - { "cosinv.k", S(EVAL),0, 2, "k", "k", NULL, acos1 }, - { "taninv.k", S(EVAL),0, 2, "k", "k", NULL, atan1 }, - { "taninv2.k",S(AOP),0, 2, "k", "kk", NULL, atan21 }, - { "sinh.k", S(EVAL),0, 2, "k", "k", NULL, sinh1 }, - { "cosh.k", S(EVAL),0, 2, "k", "k", NULL, cosh1 }, - { "tanh.k", S(EVAL),0, 2, "k", "k", NULL, tanh1 }, - { "log10.k",S(EVAL),0, 2, "k", "k", NULL, log101 }, - { "log2.k", S(EVAL),0, 2, "k", "k", NULL, log21 }, - { "int.a", S(EVAL),0, 2, "a", "a", NULL, int1a }, - { "frac.a", S(EVAL),0, 2, "a", "a", NULL, frac1a }, - { "round.a",S(EVAL),0, 2, "a", "a", NULL, int1a_round }, - { "floor.a",S(EVAL),0, 2, "a", "a", NULL, int1a_floor }, - { "ceil.a", S(EVAL),0, 2, "a", "a", NULL, int1a_ceil }, - { "abs.a", S(EVAL),0, 2, "a", "a", NULL, absa }, - { "exp.a", S(EVAL),0, 2, "a", "a", NULL, expa }, - { "log.a", S(EVAL),0, 2, "a", "a", NULL, loga }, - { "sqrt.a", S(EVAL),0, 2, "a", "a", NULL, sqrta }, - { "sin.a", S(EVAL),0, 2, "a", "a", NULL, sina }, - { "cos.a", S(EVAL),0, 2, "a", "a", NULL, cosa }, - { "tan.a", S(EVAL),0, 2, "a", "a", NULL, tana }, - { "qinf.a", S(EVAL),0, 2, "a", "a", NULL, is_infa }, - { "qnan.a", S(EVAL),0, 2, "a", "a", NULL, is_NaNa }, - { "sininv.a", S(EVAL),0, 2, "a", "a", NULL, asina }, - { "cosinv.a", S(EVAL),0, 2, "a", "a", NULL, acosa }, - { "taninv.a", S(EVAL),0, 2, "a", "a", NULL, atana }, - { "taninv2.a",S(AOP),0, 2, "a", "aa", NULL, atan2aa }, - { "sinh.a", S(EVAL),0, 2, "a", "a", NULL, sinha }, - { "cosh.a", S(EVAL),0, 2, "a", "a", NULL, cosha }, - { "tanh.a", S(EVAL),0, 2, "a", "a", NULL, tanha }, - { "log10.a",S(EVAL),0, 2, "a", "a", NULL, log10a }, - { "log2.a", S(EVAL),0, 2, "a", "a", NULL, log2a }, - { "ampdb.a",S(EVAL),0, 2, "a", "a", NULL, aampdb }, - { "ampdb.i",S(EVAL),0, 1, "i", "i", ampdb }, - { "ampdb.k",S(EVAL),0, 2, "k", "k", NULL, ampdb }, - { "ampdbfs.a",S(EVAL),0, 2, "a", "a", NULL, aampdbfs }, - { "ampdbfs.i",S(EVAL),0, 1, "i", "i", ampdbfs }, - { "ampdbfs.k",S(EVAL),0, 2, "k", "k", NULL, ampdbfs }, - { "dbamp.i",S(EVAL),0, 1, "i", "i", dbamp }, - { "dbamp.k",S(EVAL),0, 2, "k", "k", NULL, dbamp }, - { "dbfsamp.i",S(EVAL),0, 1, "i", "i", dbfsamp }, - { "dbfsamp.k",S(EVAL),0, 2, "k", "k", NULL, dbfsamp }, - { "rtclock.i",S(EVAL),0, 1, "i", "", rtclock }, - { "rtclock.k",S(EVAL),0, 2, "k", "", NULL, rtclock }, - { "ftlen.i",S(EVAL),0, 1, "i", "i", ftlen }, - { "ftsr.i",S(EVAL),0, 1, "i", "i", ftsr }, - { "ftlptim.i",S(EVAL),0, 1, "i", "i", ftlptim }, - { "ftchnls.i",S(EVAL),0, 1, "i", "i", ftchnls }, - { "ftcps.i",S(EVAL),0, 1, "i", "i", ftcps }, - { "i.i", S(ASSIGN),0, 1, "i", "i", assign }, - { "i.k", S(ASSIGN),0, 1, "i", "k", assign }, - { "k.i", S(ASSIGN),0, 1, "k", "i", assign }, - { "k.a", S(DOWNSAMP),0, 3, "k", "ao", (SUBR)downset,(SUBR)downsamp }, - { "cpsoct.i",S(EVAL),0, 1, "i", "i", cpsoct }, - { "octpch.i",S(EVAL),0, 1, "i", "i", octpch }, - { "cpspch.i",S(EVAL),0, 1, "i", "i", cpspch }, - { "pchoct.i",S(EVAL),0, 1, "i", "i", pchoct }, - { "octcps.i",S(EVAL),0, 1, "i", "i", octcps }, - { "cpsoct.k",S(EVAL),0, 2, "k", "k", NULL, cpsoct }, - { "octpch.k",S(EVAL),0, 2, "k", "k", NULL, octpch }, - { "cpspch.k",S(EVAL),0, 2, "k", "k", NULL, cpspch }, - { "pchoct.k",S(EVAL),0, 2, "k", "k", NULL, pchoct }, - { "octcps.k",S(EVAL),0, 2, "k", "k", NULL, octcps }, - { "cpsoct.a",S(EVAL),0, 2, "a", "a", NULL, acpsoct }, - { "cpsmidinn.i",S(EVAL),0,1, "i", "i", cpsmidinn }, - { "octmidinn.i",S(EVAL),0,1, "i", "i", octmidinn }, - { "pchmidinn.i",S(EVAL),0,1, "i", "i", pchmidinn }, - { "cpsmidinn.k",S(EVAL),0,2, "k", "k", NULL, cpsmidinn }, - { "octmidinn.k",S(EVAL),0,2, "k", "k", NULL, octmidinn }, - { "pchmidinn.k",S(EVAL),0,2, "k", "k", NULL, pchmidinn }, - { "notnum", S(MIDIKMB),0, 1, "i", "", notnum }, - { "veloc", S(MIDIMAP),0, 1, "i", "oh", veloc }, - { "pchmidi",S(MIDIKMB),0, 1, "i", "", pchmidi }, - { "octmidi",S(MIDIKMB),0, 1, "i", "", octmidi }, - { "cpsmidi",S(MIDIKMB),0, 1, "i", "", cpsmidi }, - { "pchmidib.i",S(MIDIKMB),0,1, "i", "o", pchmidib_i }, - { "octmidib.i",S(MIDIKMB),0,1, "i", "o", octmidib_i }, - { "cpsmidib.i",S(MIDIKMB),0,1, "i", "o", icpsmidib_i }, - { "pchmidib.k",S(MIDIKMB),0,3, "k", "o", midibset, pchmidib }, - { "octmidib.k",S(MIDIKMB),0,3, "k", "o", midibset, octmidib }, - { "cpsmidib.k",S(MIDIKMB),0,3, "k", "o", midibset, icpsmidib }, - { "ampmidi",S(MIDIAMP),0, 1, "i", "io", ampmidi }, - { "aftouch",S(MIDIKMAP),0, 3, "k", "oh", aftset, aftouch }, - { "pchbend.i",S(MIDIMAP),0,1, "i", "jp", ipchbend }, - { "pchbend.k",S(MIDIKMAP),0,3, "k", "jp", kbndset,kpchbend }, - { "midictrl.i",S(MIDICTL),0,1, "i", "ioh", imidictl }, - { "midictrl.k",S(MIDICTL),0,3, "k", "ioh", mctlset, midictl }, - { "polyaft.i",S(MIDICTL),0,1, "i", "ioh", imidiaft }, - { "polyaft.k",S(MIDICTL),0,3, "k", "ioh", maftset, midiaft }, - { "chanctrl.i",S(CHANCTL),0,1, "i", "iioh", ichanctl }, - { "chanctrl.k",S(CHANCTL),0,3, "k", "iioh", chctlset,chanctl }, - { "line", S(LINE),0, 3, "k", "iii", linset, kline, NULL }, - { "line.a", S(LINE),0, 3, "a", "iii", linset, aline }, - { "expon", S(EXPON),0, 3, "k", "iii", expset, kexpon, NULL }, - { "expon.a", S(EXPON),0, 3, "a", "iii", expset, expon }, - { "cosseg", S(COSSEG),0, 3, "k", "iim", csgset, kosseg, NULL }, - { "cosseg.a", S(COSSEG),0, 3, "a", "iim", csgset, cosseg }, - { "cossegb", S(COSSEG),0, 3, "k", "iim", csgset_bkpt, kosseg, NULL }, - { "cossegb.a", S(COSSEG),0, 3, "a", "iim", csgset_bkpt, cosseg }, - { "cossegr", S(COSSEG),0, 3, "k", "iim", csgrset, kcssegr, NULL }, - { "cossegr.a", S(COSSEG),0, 3, "a", "iim", csgrset, cossegr }, - { "linseg", S(LINSEG),0, 3, "k", "iim", lsgset, klnseg, NULL }, - { "linseg.a", S(LINSEG),0, 3, "a", "iim", lsgset, linseg }, - { "linsegb", S(LINSEG),0, 3, "k", "iim", lsgset_bkpt, klnseg, NULL }, - { "linsegb.a", S(LINSEG),0, 3, "a", "iim", lsgset_bkpt, linseg }, - { "linsegr",S(LINSEG),0, 3, "k", "iim", lsgrset,klnsegr,NULL }, - { "linsegr.a",S(LINSEG),0, 3, "a", "iim", lsgrset,linsegr }, - { "expseg", S(EXXPSEG),0, 3, "k", "iim", xsgset, kxpseg, NULL }, - { "expseg.a", S(EXXPSEG),0, 3, "a", "iim", xsgset, expseg }, - { "expsegb", S(EXXPSEG),0, 3, "k", "iim", xsgset_bkpt, kxpseg, NULL }, - { "expsegb.a", S(EXXPSEG),0, 3, "a", "iim", xsgset_bkpt, expseg }, - { "expsega",S(EXPSEG2),0, 3, "a", "iim", xsgset2, expseg2 }, - { "expsegba",S(EXPSEG2),0, 3, "a", "iim", xsgset2b, expseg2 }, - { "expsegr",S(EXPSEG),0, 3, "k", "iim", xsgrset,kxpsegr,NULL }, - { "expsegr.a",S(EXPSEG),0, 3, "a", "iim", xsgrset,expsegr }, - { "linen", S(LINEN),0, 3, "k", "kiii", lnnset, klinen, NULL }, - { "linen.a", S(LINEN),0, 3, "a", "aiii", alnnset, linen }, - { "linen.x", S(LINEN),0, 3, "a", "kiii", alnnset, linen }, - { "linenr", S(LINENR),0, 3, "k", "kiii", lnrset, klinenr,NULL }, - { "linenr.a", S(LINENR),0, 3, "a", "aiii", alnrset,linenr }, - { "linenr.x", S(LINENR),0, 3, "a", "kiii", alnrset,linenr }, - { "envlpx", S(ENVLPX), TR, 3, "k","kiiiiiio", evxset, knvlpx, NULL }, - { "envlpxr", S(ENVLPR),TR, 3, "k","kiiiiioo", evrset, knvlpxr, NULL }, - { "envlpx.a", S(ENVLPX), TR, 3, "a","aiiiiiio", aevxset,envlpx }, - { "envlpxr.a", S(ENVLPR),TR, 3, "a","aiiiiioo", aevrset,envlpxr }, - { "envlpx.x", S(ENVLPX), TR, 3, "a","kiiiiiio", aevxset,envlpx }, - { "envlpxr.x", S(ENVLPR),TR, 3, "a","kiiiiioo", aevrset,envlpxr }, - { "phasor", S(PHSOR),0, 3, "a", "xo", phsset, phsor }, - { "phasor.k", S(PHSOR),0, 3, "k", "ko", phsset, kphsor, NULL }, - { "ephasor", S(EPHSOR), 0, 3, "aa", "xko", ephsset, ephsor }, - { "signum.i", S(ASSIGN), 0, 1, "i", "i", signum, NULL, NULL }, - { "signum.k", S(ASSIGN), 0, 3, "k", "k", signum, signum, NULL }, - { "signum.a", S(ASSIGN), 0, 2, "a", "a", NULL, asignum }, - { "table.i", S(TABL),TR, 1, "i", "iiooo",(SUBR)tabler_init }, - { "table.k", S(TABL),TR, 3, "k", "xiooo",(SUBR)tabl_setup, + { "divz.ii", S(DIVZ),0, "i", "iii", divzkk, NULL, NULL }, + { "divz.kk", S(DIVZ),0, "k", "kkk", NULL, divzkk, NULL }, + { "divz.ak", S(DIVZ),0, "a", "akk", NULL, divzak }, + { "divz.ka", S(DIVZ),0, "a", "kak", NULL, divzka }, + { "divz.aa", S(DIVZ),0, "a", "aak", NULL, divzaa }, + { "int.i", S(EVAL),0, "i", "i", int1 }, + { "frac.i", S(EVAL),0, "i", "i", frac1 }, + { "round.i",S(EVAL),0, "i", "i", int1_round }, + { "floor.i",S(EVAL),0, "i", "i", int1_floor }, + { "ceil.i", S(EVAL),0, "i", "i", int1_ceil }, + { "rndseed", S(EVAL),0, "", "i", rnd1seed }, + { "rnd.i", S(EVAL),0, "i", "i", rnd1 }, + { "birnd.i",S(EVAL),0, "i", "i", birnd1 }, + { "abs.i", S(EVAL),0, "i", "i", abs1 }, + { "exp.i", S(EVAL),0, "i", "i", exp01 }, + { "log.i", S(EVAL),0, "i", "i", log01 }, + { "sqrt.i", S(EVAL),0, "i", "i", sqrt1 }, + { "sin.i", S(EVAL),0, "i", "i", sin1 }, + { "cos.i", S(EVAL),0, "i", "i", cos1 }, + { "tan.i", S(EVAL),0, "i", "i", tan1 }, + { "qinf.i", S(EVAL),0, "i", "i", is_inf }, + { "qnan.i", S(EVAL),0, "i", "i", is_NaN }, + { "sininv.i", S(EVAL),0, "i", "i", asin1 }, + { "cosinv.i", S(EVAL),0, "i", "i", acos1 }, + { "taninv.i", S(EVAL),0, "i", "i", atan1 }, + { "taninv2.i",S(AOP),0, "i", "ii", atan21 }, + { "log10.i",S(EVAL),0, "i", "i", log101 }, + { "log2.i", S(EVAL),0, "i", "i", log21 }, + { "sinh.i", S(EVAL),0, "i", "i", sinh1 }, + { "cosh.i", S(EVAL),0, "i", "i", cosh1 }, + { "tanh.i", S(EVAL),0, "i", "i", tanh1 }, + { "int.k", S(EVAL),0, "k", "k", NULL, int1 }, + { "frac.k", S(EVAL),0, "k", "k", NULL, frac1 }, + { "round.k",S(EVAL),0, "k", "k", NULL, int1_round }, + { "floor.k",S(EVAL),0, "k", "k", NULL, int1_floor }, + { "ceil.k", S(EVAL),0, "k", "k", NULL, int1_ceil }, + { "rnd.k", S(EVAL),0, "k", "k", NULL, rnd1 }, + { "birnd.k",S(EVAL),0, "k", "k", NULL, birnd1 }, + { "abs.k", S(EVAL),0, "k", "k", NULL, abs1 }, + { "exp.k", S(EVAL),0, "k", "k", NULL, exp01 }, + { "log.k", S(EVAL),0, "k", "k", NULL, log01 }, + { "sqrt.k", S(EVAL),0, "k", "k", NULL, sqrt1 }, + { "sin.k", S(EVAL),0, "k", "k", NULL, sin1 }, + { "cos.k", S(EVAL),0, "k", "k", NULL, cos1 }, + { "tan.k", S(EVAL),0, "k", "k", NULL, tan1 }, + { "qinf.k", S(EVAL),0, "k", "k", NULL, is_inf }, + { "qnan.k", S(EVAL),0, "k", "k", NULL, is_NaN }, + { "sininv.k", S(EVAL),0, "k", "k", NULL, asin1 }, + { "cosinv.k", S(EVAL),0, "k", "k", NULL, acos1 }, + { "taninv.k", S(EVAL),0, "k", "k", NULL, atan1 }, + { "taninv2.k",S(AOP),0, "k", "kk", NULL, atan21 }, + { "sinh.k", S(EVAL),0, "k", "k", NULL, sinh1 }, + { "cosh.k", S(EVAL),0, "k", "k", NULL, cosh1 }, + { "tanh.k", S(EVAL),0, "k", "k", NULL, tanh1 }, + { "log10.k",S(EVAL),0, "k", "k", NULL, log101 }, + { "log2.k", S(EVAL),0, "k", "k", NULL, log21 }, + { "int.a", S(EVAL),0, "a", "a", NULL, int1a }, + { "frac.a", S(EVAL),0, "a", "a", NULL, frac1a }, + { "round.a",S(EVAL),0, "a", "a", NULL, int1a_round }, + { "floor.a",S(EVAL),0, "a", "a", NULL, int1a_floor }, + { "ceil.a", S(EVAL),0, "a", "a", NULL, int1a_ceil }, + { "abs.a", S(EVAL),0, "a", "a", NULL, absa }, + { "exp.a", S(EVAL),0, "a", "a", NULL, expa }, + { "log.a", S(EVAL),0, "a", "a", NULL, loga }, + { "sqrt.a", S(EVAL),0, "a", "a", NULL, sqrta }, + { "sin.a", S(EVAL),0, "a", "a", NULL, sina }, + { "cos.a", S(EVAL),0, "a", "a", NULL, cosa }, + { "tan.a", S(EVAL),0, "a", "a", NULL, tana }, + { "qinf.a", S(EVAL),0, "a", "a", NULL, is_infa }, + { "qnan.a", S(EVAL),0, "a", "a", NULL, is_NaNa }, + { "sininv.a", S(EVAL),0, "a", "a", NULL, asina }, + { "cosinv.a", S(EVAL),0, "a", "a", NULL, acosa }, + { "taninv.a", S(EVAL),0, "a", "a", NULL, atana }, + { "taninv2.a",S(AOP),0, "a", "aa", NULL, atan2aa }, + { "sinh.a", S(EVAL),0, "a", "a", NULL, sinha }, + { "cosh.a", S(EVAL),0, "a", "a", NULL, cosha }, + { "tanh.a", S(EVAL),0, "a", "a", NULL, tanha }, + { "log10.a",S(EVAL),0, "a", "a", NULL, log10a }, + { "log2.a", S(EVAL),0, "a", "a", NULL, log2a }, + { "ampdb.a",S(EVAL),0, "a", "a", NULL, aampdb }, + { "ampdb.i",S(EVAL),0, "i", "i", ampdb }, + { "ampdb.k",S(EVAL),0, "k", "k", NULL, ampdb }, + { "ampdbfs.a",S(EVAL),0, "a", "a", NULL, aampdbfs }, + { "ampdbfs.i",S(EVAL),0, "i", "i", ampdbfs }, + { "ampdbfs.k",S(EVAL),0, "k", "k", NULL, ampdbfs }, + { "dbamp.i",S(EVAL),0, "i", "i", dbamp }, + { "dbamp.k",S(EVAL),0, "k", "k", NULL, dbamp }, + { "dbfsamp.i",S(EVAL),0, "i", "i", dbfsamp }, + { "dbfsamp.k",S(EVAL),0, "k", "k", NULL, dbfsamp }, + { "rtclock.i",S(EVAL),0, "i", "", rtclock }, + { "rtclock.k",S(EVAL),0, "k", "", NULL, rtclock }, + { "ftlen.i",S(EVAL),0, "i", "i", ftlen }, + { "ftsr.i",S(EVAL),0, "i", "i", ftsr }, + { "ftlptim.i",S(EVAL),0, "i", "i", ftlptim }, + { "ftchnls.i",S(EVAL),0, "i", "i", ftchnls }, + { "ftcps.i",S(EVAL),0, "i", "i", ftcps }, + { "i.i", S(ASSIGN),0, "i", "i", assign }, + { "i.k", S(ASSIGN),0, "i", "k", assign }, + { "k.i", S(ASSIGN),0, "k", "i", assign }, + { "k.a", S(DOWNSAMP),0, "k", "ao", (SUBR)downset,(SUBR)downsamp }, + { "cpsoct.i",S(EVAL),0, "i", "i", cpsoct }, + { "octpch.i",S(EVAL),0, "i", "i", octpch }, + { "cpspch.i",S(EVAL),0, "i", "i", cpspch }, + { "pchoct.i",S(EVAL),0, "i", "i", pchoct }, + { "octcps.i",S(EVAL),0, "i", "i", octcps }, + { "cpsoct.k",S(EVAL),0, "k", "k", NULL, cpsoct }, + { "octpch.k",S(EVAL),0, "k", "k", NULL, octpch }, + { "cpspch.k",S(EVAL),0, "k", "k", NULL, cpspch }, + { "pchoct.k",S(EVAL),0, "k", "k", NULL, pchoct }, + { "octcps.k",S(EVAL),0, "k", "k", NULL, octcps }, + { "cpsoct.a",S(EVAL),0, "a", "a", NULL, acpsoct }, + { "cpsmidinn.i",S(EVAL),0, "i", "i", cpsmidinn }, + { "octmidinn.i",S(EVAL),0, "i", "i", octmidinn }, + { "pchmidinn.i",S(EVAL),0, "i", "i", pchmidinn }, + { "cpsmidinn.k",S(EVAL),0, "k", "k", NULL, cpsmidinn }, + { "octmidinn.k",S(EVAL),0, "k", "k", NULL, octmidinn }, + { "pchmidinn.k",S(EVAL),0, "k", "k", NULL, pchmidinn }, + { "notnum", S(MIDIKMB),0, "i", "", notnum }, + { "veloc", S(MIDIMAP),0, "i", "oh", veloc }, + { "pchmidi",S(MIDIKMB),0, "i", "", pchmidi }, + { "octmidi",S(MIDIKMB),0, "i", "", octmidi }, + { "cpsmidi",S(MIDIKMB),0, "i", "", cpsmidi }, + { "pchmidib.i",S(MIDIKMB),0, "i", "o", pchmidib_i }, + { "octmidib.i",S(MIDIKMB),0, "i", "o", octmidib_i }, + { "cpsmidib.i",S(MIDIKMB),0, "i", "o", icpsmidib_i }, + { "pchmidib.k",S(MIDIKMB),0, "k", "o", midibset, pchmidib }, + { "octmidib.k",S(MIDIKMB),0, "k", "o", midibset, octmidib }, + { "cpsmidib.k",S(MIDIKMB),0, "k", "o", midibset, icpsmidib }, + { "ampmidi",S(MIDIAMP),0, "i", "io", ampmidi }, + { "aftouch",S(MIDIKMAP),0, "k", "oh", aftset, aftouch }, + { "pchbend.i",S(MIDIMAP),0, "i", "jp", ipchbend }, + { "pchbend.k",S(MIDIKMAP),0, "k", "jp", kbndset,kpchbend }, + { "midictrl.i",S(MIDICTL),0, "i", "ioh", imidictl }, + { "midictrl.k",S(MIDICTL),0, "k", "ioh", mctlset, midictl }, + { "polyaft.i",S(MIDICTL),0, "i", "ioh", imidiaft }, + { "polyaft.k",S(MIDICTL),0, "k", "ioh", maftset, midiaft }, + { "chanctrl.i",S(CHANCTL),0, "i", "iioh", ichanctl }, + { "chanctrl.k",S(CHANCTL),0, "k", "iioh", chctlset,chanctl }, + { "line", S(LINE),0, "k", "iii", linset, kline, NULL }, + { "line.a", S(LINE),0, "a", "iii", linset, aline }, + { "expon", S(EXPON),0, "k", "iii", expset, kexpon, NULL }, + { "expon.a", S(EXPON),0, "a", "iii", expset, expon }, + { "cosseg", S(COSSEG),0, "k", "iim", csgset, kosseg, NULL }, + { "cosseg.a", S(COSSEG),0, "a", "iim", csgset, cosseg }, + { "cossegb", S(COSSEG),0, "k", "iim", csgset_bkpt, kosseg, NULL }, + { "cossegb.a", S(COSSEG),0, "a", "iim", csgset_bkpt, cosseg }, + { "cossegr", S(COSSEG),0, "k", "iim", csgrset, kcssegr, NULL }, + { "cossegr.a", S(COSSEG),0, "a", "iim", csgrset, cossegr }, + { "linseg", S(LINSEG),0, "k", "iim", lsgset, klnseg, NULL }, + { "linseg.a", S(LINSEG),0, "a", "iim", lsgset, linseg }, + { "linsegb", S(LINSEG),0, "k", "iim", lsgset_bkpt, klnseg, NULL }, + { "linsegb.a", S(LINSEG),0, "a", "iim", lsgset_bkpt, linseg }, + { "linsegr",S(LINSEG),0, "k", "iim", lsgrset,klnsegr,NULL }, + { "linsegr.a",S(LINSEG),0, "a", "iim", lsgrset,linsegr }, + { "expseg", S(EXXPSEG),0, "k", "iim", xsgset, kxpseg, NULL }, + { "expseg.a", S(EXXPSEG),0, "a", "iim", xsgset, expseg }, + { "expsegb", S(EXXPSEG),0, "k", "iim", xsgset_bkpt, kxpseg, NULL }, + { "expsegb.a", S(EXXPSEG),0, "a", "iim", xsgset_bkpt, expseg }, + { "expsega",S(EXPSEG2),0, "a", "iim", xsgset2, expseg2 }, + { "expsegba",S(EXPSEG2),0, "a", "iim", xsgset2b, expseg2 }, + { "expsegr",S(EXPSEG),0, "k", "iim", xsgrset,kxpsegr,NULL }, + { "expsegr.a",S(EXPSEG),0, "a", "iim", xsgrset,expsegr }, + { "linen", S(LINEN),0, "k", "kiii", lnnset, klinen, NULL }, + { "linen.a", S(LINEN),0, "a", "aiii", alnnset, linen }, + { "linen.x", S(LINEN),0, "a", "kiii", alnnset, linen }, + { "linenr", S(LINENR),0, "k", "kiii", lnrset, klinenr,NULL }, + { "linenr.a", S(LINENR),0, "a", "aiii", alnrset,linenr }, + { "linenr.x", S(LINENR),0, "a", "kiii", alnrset,linenr }, + { "envlpx", S(ENVLPX), TR, "k","kiiiiiio", evxset, knvlpx, NULL }, + { "envlpxr", S(ENVLPR),TR, "k","kiiiiioo", evrset, knvlpxr, NULL }, + { "envlpx.a", S(ENVLPX), TR, "a","aiiiiiio", aevxset,envlpx }, + { "envlpxr.a", S(ENVLPR),TR, "a","aiiiiioo", aevrset,envlpxr }, + { "envlpx.x", S(ENVLPX), TR, "a","kiiiiiio", aevxset,envlpx }, + { "envlpxr.x", S(ENVLPR),TR, "a","kiiiiioo", aevrset,envlpxr }, + { "phasor", S(PHSOR),0, "a", "xo", phsset, phsor }, + { "phasor.k", S(PHSOR),0, "k", "ko", phsset, kphsor, NULL }, + { "ephasor", S(EPHSOR), 0, "aa", "xko", ephsset, ephsor }, + { "signum.i", S(ASSIGN), 0, "i", "i", signum, NULL, NULL }, + { "signum.k", S(ASSIGN), 0, "k", "k", signum, signum, NULL }, + { "signum.a", S(ASSIGN), 0, "a", "a", NULL, asignum }, + { "table.i", S(TABL),TR, "i", "iiooo",(SUBR)tabler_init }, + { "table.k", S(TABL),TR, "k", "xiooo",(SUBR)tabl_setup, (SUBR)tabler_kontrol }, - { "table.a", S(TABL),TR, 3, "a", "xiooo",(SUBR)tabl_setup, + { "table.a", S(TABL),TR, "a", "xiooo",(SUBR)tabl_setup, (SUBR)tabler_audio }, - { "tablei.i", S(TABL),TR, 1, "i", "iiooo",(SUBR)tableir_init }, - { "tablei.k", S(TABL),TR, 3, "k", "xiooo",(SUBR)tabl_setup, + { "tablei.i", S(TABL),TR, "i", "iiooo",(SUBR)tableir_init }, + { "tablei.k", S(TABL),TR, "k", "xiooo",(SUBR)tabl_setup, (SUBR)tableir_kontrol }, - { "tablei.a", S(TABL),TR, 3, "a", "xiooo",(SUBR)tabl_setup, + { "tablei.a", S(TABL),TR, "a", "xiooo",(SUBR)tabl_setup, (SUBR)tableir_audio }, - { "table3.i", S(TABL),TR, 1, "i", "iiooo",(SUBR)table3r_init }, - { "table3.k", S(TABL),TR, 3, "k", "xiooo",(SUBR)tabl_setup, + { "table3.i", S(TABL),TR, "i", "iiooo",(SUBR)table3r_init }, + { "table3.k", S(TABL),TR, "k", "xiooo",(SUBR)tabl_setup, (SUBR)table3r_kontrol }, - { "table3.a", S(TABL),TR, 3, "a", "xiooo",(SUBR)tabl_setup, + { "table3.a", S(TABL),TR, "a", "xiooo",(SUBR)tabl_setup, (SUBR)table3r_audio }, - { "ptable.i", S(TABLE),TR|_QQ, 1,"i", "iiooo",(SUBR)tabler_init }, - { "ptable.k", S(TABLE),TR|_QQ, 3, "k", "xiooo",(SUBR)tabl_setup, + { "ptable.i", S(TABLE),TR|_QQ, "i", "iiooo",(SUBR)tabler_init }, + { "ptable.k", S(TABLE),TR|_QQ, "k", "xiooo",(SUBR)tabl_setup, (SUBR)tabler_kontrol }, - { "ptable.a", S(TABLE),TR|_QQ, 3, "a", "xiooo",(SUBR)tabl_setup, + { "ptable.a", S(TABLE),TR|_QQ, "a", "xiooo",(SUBR)tabl_setup, (SUBR)tabler_audio }, - { "ptablei.i", S(TABLE),TR|_QQ, 1,"i", "iiooo",(SUBR)tableir_init }, - { "ptablei.k", S(TABLE),TR|_QQ, 3, "k", "xiooo",(SUBR)tabl_setup, + { "ptablei.i", S(TABLE),TR|_QQ, "i", "iiooo",(SUBR)tableir_init }, + { "ptablei.k", S(TABLE),TR|_QQ, "k", "xiooo",(SUBR)tabl_setup, (SUBR)tableir_kontrol }, - { "ptablei.a", S(TABLE),TR|_QQ, 3, "a", "xiooo",(SUBR)tabl_setup, + { "ptablei.a", S(TABLE),TR|_QQ, "a", "xiooo",(SUBR)tabl_setup, (SUBR)tableir_audio }, - { "ptable3.i", S(TABLE),TR|_QQ, 1,"i", "iiooo",(SUBR)table3r_init }, - { "ptable3.k", S(TABLE),TR|_QQ, 3, "k", "xiooo",(SUBR)tabl_setup, + { "ptable3.i", S(TABLE),TR|_QQ, "i", "iiooo",(SUBR)table3r_init }, + { "ptable3.k", S(TABLE),TR|_QQ, "k", "xiooo",(SUBR)tabl_setup, (SUBR)table3r_kontrol }, - { "ptable3.a", S(TABLE),TR|_QQ, 3, "a", "xiooo",(SUBR)tabl_setup, + { "ptable3.a", S(TABLE),TR|_QQ, "a", "xiooo",(SUBR)tabl_setup, (SUBR)table3r_audio }, - { "oscil1", S(OSCIL1), TR, 3, "k", "ikij", ko1set, kosc1 }, - { "oscil1i",S(OSCIL1), TR, 3, "k", "ikij", ko1set, kosc1i }, - { "osciln", S(OSCILN), TR, 3, "a", "kiii", oscnset, osciln }, - { "oscil.a",S(OSC),TR, 3, "a", "kkjo", oscset, osckk }, - { "oscil.kkk",S(OSC),TR, 3, "k", "kkjo", oscset, koscil }, - { "oscil.kka",S(OSC),TR, 3, "a", "kkjo", oscset, osckk }, - { "oscil.ka",S(OSC),TR, 3, "a", "kajo", oscset, oscka }, - { "oscil.ak",S(OSC),TR, 3, "a", "akjo", oscset, oscak }, - { "oscil.aa",S(OSC),TR, 3, "a", "aajo", oscset, oscaa }, - { "oscil.kkA",S(OSC),0, 3, "k", "kki[]o", oscsetA, koscil }, - { "oscil.kkA",S(OSC),0, 3, "a", "kki[]o", oscsetA, osckk }, - { "oscil.kaA",S(OSC),0, 3, "a", "kai[]o", oscsetA, oscka }, - { "oscil.akA",S(OSC),0, 3, "a", "aki[]o", oscsetA, oscak }, - { "oscil.aaA",S(OSC),0, 3, "a", "aai[]o", oscsetA,oscaa }, + { "oscil1", S(OSCIL1), TR, "k", "ikij", ko1set, kosc1 }, + { "oscil1i",S(OSCIL1), TR, "k", "ikij", ko1set, kosc1i }, + { "osciln", S(OSCILN), TR, "a", "kiii", oscnset, osciln }, + { "oscil.a",S(OSC),TR, "a", "kkjo", oscset, osckk }, + { "oscil.kkk",S(OSC),TR, "k", "kkjo", oscset, koscil }, + { "oscil.kka",S(OSC),TR, "a", "kkjo", oscset, osckk }, + { "oscil.ka",S(OSC),TR, "a", "kajo", oscset, oscka }, + { "oscil.ak",S(OSC),TR, "a", "akjo", oscset, oscak }, + { "oscil.aa",S(OSC),TR, "a", "aajo", oscset, oscaa }, + { "oscil.kkA",S(OSC),0, "k", "kki[]o", oscsetA, koscil }, + { "oscil.kkA",S(OSC),0, "a", "kki[]o", oscsetA, osckk }, + { "oscil.kaA",S(OSC),0, "a", "kai[]o", oscsetA, oscka }, + { "oscil.akA",S(OSC),0, "a", "aki[]o", oscsetA, oscak }, + { "oscil.aaA",S(OSC),0, "a", "aai[]o", oscsetA,oscaa }, /* Change these to - { "oscil.kkk", S(POSC),TR, 3, "k", "kkjo", posc_set, kposc }, - { "oscil.kka", S(POSC),TR, 3,, "a", "kkjo"_set, NULL, posckk }, - { "oscil.ka", S(POSC),TR, 3, "a", "kajo", posc_set, poscka }, - { "oscil.ak", S(POSC),TR, 3, "a", "akjo", posc_set, poscak }, - { "oscil.aa", S(POSC),TR, 3, "a", "aajo", posc_set, poscaa }, - { "oscil3.kk", S(POSC),TR, 7, "s", "kkjo", posc_set, kposc3, posc3 }, + { "oscil.kkk", S(POSC),TR, "k", "kkjo", posc_set, kposc }, + { "oscil.kka", S(POSC),TR, , "a", "kkjo"_set, NULL, posckk }, + { "oscil.ka", S(POSC),TR, "a", "kajo", posc_set, poscka }, + { "oscil.ak", S(POSC),TR, "a", "akjo", posc_set, poscak }, + { "oscil.aa", S(POSC),TR, "a", "aajo", posc_set, poscaa }, + { "oscil3.kk", S(POSC),TR, 7, "s", "kkjo", posc_set, kposc posc3 }, */ - { "oscili.a",S(OSC),TR, 3, "a", "kkjo", oscset, osckki }, - { "oscili.kk",S(OSC),TR, 3, "k", "kkjo", oscset, koscli, NULL }, - { "oscili.ka",S(OSC),TR, 3, "a", "kajo", oscset, osckai }, - { "oscili.ak",S(OSC),TR, 3, "a", "akjo", oscset, oscaki }, - { "oscili.aa",S(OSC),TR, 3, "a", "aajo", oscset, oscaai }, - { "oscili.aA",S(OSC),0, 3, "a", "kki[]o", oscsetA, osckki }, - { "oscili.kkA",S(OSC),0, 3, "k", "kki[]o", oscsetA, koscli, NULL }, - { "oscili.kaA",S(OSC),0, 3, "a", "kai[]o", oscsetA, osckai }, - { "oscili.akA",S(OSC),0, 3, "a", "aki[]o", oscsetA, oscaki }, - { "oscili.aaA",S(OSC),0, 3, "a", "aai[]o", oscsetA, oscaai }, - { "oscil3.a",S(OSC),TR, 3, "a", "kkjo", oscset, osckk3 }, - { "oscil3.kk",S(OSC),TR, 3, "k", "kkjo", oscset, koscl3, NULL }, - { "oscil3.ka",S(OSC),TR, 3, "a", "kajo", oscset, oscka3 }, - { "oscil3.ak",S(OSC),TR, 3, "a", "akjo", oscset, oscak3 }, - { "oscil3.aa",S(OSC),TR, 3, "a", "aajo", oscset, oscaa3 }, - { "oscil3.aA",S(OSC),0, 3, "a", "kki[]o", oscsetA, osckk3 }, - { "oscil3.kkA",S(OSC),0, 3, "k", "kki[]o", oscsetA, koscl3, NULL }, - { "oscil3.kaA",S(OSC),0, 3, "a", "kai[]o", oscsetA, oscka3 }, - { "oscil3.akA",S(OSC),0, 3, "a", "aki[]o", oscsetA, oscak3 }, - { "oscil3.aaA",S(OSC),0, 3, "a", "aai[]o", oscsetA, oscaa3 }, -{ "poscil.a", S(OSC), TR,3, "a", "kkjo", (SUBR)posc_set,(SUBR)posckk }, -{ "poscil.kk", S(OSC), TR,3, "k", "kkjo", (SUBR)posc_set,(SUBR)kposc,NULL }, -{ "poscil.ka", S(OSC), TR,3, "a", "kajo", (SUBR)posc_set, (SUBR)poscka }, -{ "poscil.ak", S(OSC), TR,3, "a", "akjo", (SUBR)posc_set, (SUBR)poscak }, -{ "poscil.aa", S(OSC), TR,3, "a", "aajo", (SUBR)posc_set, (SUBR)poscaa }, -{ "lposcil", S(LPOSC), TR, 3, "a", "kkkkjo", (SUBR)lposc_set, (SUBR)lposc}, -{ "poscil3.a",S(OSC), TR,3, "a", "kkjo", - (SUBR)posc_set,(SUBR)posc3kk }, -{ "poscil3.kk",S(OSC), TR,3, "k", "kkjo", - (SUBR)posc_set,(SUBR)kposc3,NULL}, -{ "poscil3.ak", S(OSC), TR,3, "a", "akjo", (SUBR)posc_set, (SUBR)posc3ak }, -{ "poscil3.ka", S(OSC), TR,3, "a", "kajo", (SUBR)posc_set, (SUBR)posc3ka }, -{ "poscil3.aa", S(OSC), TR,3, "a", "aajo", (SUBR)posc_set, (SUBR)posc3aa }, -{ "lposcil3", S(LPOSC), TR, 3, "a", "kkkkjo", (SUBR)lposc_set,(SUBR)lposc3}, - { "lposcila", S(LPOSC), TR, 3, "a", "akkkio", - (SUBR)lposc_set, (SUBR)lposca}, + { "oscili.a",S(OSC),TR, "a", "kkjo", oscset, osckki }, + { "oscili.kk",S(OSC),TR, "k", "kkjo", oscset, koscli, NULL }, + { "oscili.ka",S(OSC),TR, "a", "kajo", oscset, osckai }, + { "oscili.ak",S(OSC),TR, "a", "akjo", oscset, oscaki }, + { "oscili.aa",S(OSC),TR, "a", "aajo", oscset, oscaai }, + { "oscili.aA",S(OSC),0, "a", "kki[]o", oscsetA, osckki }, + { "oscili.kkA",S(OSC),0, "k", "kki[]o", oscsetA, koscli, NULL }, + { "oscili.kaA",S(OSC),0, "a", "kai[]o", oscsetA, osckai }, + { "oscili.akA",S(OSC),0, "a", "aki[]o", oscsetA, oscaki }, + { "oscili.aaA",S(OSC),0, "a", "aai[]o", oscsetA, oscaai }, + { "oscil3.a",S(OSC),TR, "a", "kkjo", oscset, osckk3 }, + { "oscil3.kk",S(OSC),TR, "k", "kkjo", oscset, koscl3, NULL }, + { "oscil3.ka",S(OSC),TR, "a", "kajo", oscset, oscka3 }, + { "oscil3.ak",S(OSC),TR, "a", "akjo", oscset, oscak3 }, + { "oscil3.aa",S(OSC),TR, "a", "aajo", oscset, oscaa3 }, + { "oscil3.aA",S(OSC),0, "a", "kki[]o", oscsetA, osckk3 }, + { "oscil3.kkA",S(OSC),0, "k", "kki[]o", oscsetA, koscl3, NULL }, + { "oscil3.kaA",S(OSC),0, "a", "kai[]o", oscsetA, oscka3 }, + { "oscil3.akA",S(OSC),0, "a", "aki[]o", oscsetA, oscak3 }, + { "oscil3.aaA",S(OSC),0, "a", "aai[]o", oscsetA, oscaa3 }, + { "poscil.a", S(OSC), TR, "a", "kkjo", (SUBR)posc_set,(SUBR)posckk }, + { "poscil.kk", S(OSC), TR, "k", "kkjo", (SUBR)posc_set,(SUBR)kposc,NULL }, + { "poscil.ka", S(OSC), TR, "a", "kajo", (SUBR)posc_set, (SUBR)poscka }, + { "poscil.ak", S(OSC), TR, "a", "akjo", (SUBR)posc_set, (SUBR)poscak }, + { "poscil.aa", S(OSC), TR, "a", "aajo", (SUBR)posc_set, (SUBR)poscaa }, + { "lposcil", S(LPOSC), TR, "a", "kkkkjo", (SUBR)lposc_set, (SUBR)lposc}, + { "poscil3.a",S(OSC), TR, "a", "kkjo", + (SUBR)posc_set,(SUBR)posc3kk }, + { "poscil3.kk",S(OSC), TR, "k", "kkjo", + (SUBR)posc_set,(SUBR)kposc3,NULL}, + { "poscil3.ak", S(OSC), TR, "a", "akjo", (SUBR)posc_set, (SUBR)posc3ak }, + { "poscil3.ka", S(OSC), TR, "a", "kajo", (SUBR)posc_set, (SUBR)posc3ka }, + { "poscil3.aa", S(OSC), TR, "a", "aajo", (SUBR)posc_set, (SUBR)posc3aa }, + { "lposcil3", S(LPOSC), TR, "a", "kkkkjo", (SUBR)lposc_set,(SUBR)lposc3}, + { "lposcila", S(LPOSC), TR, "a", "akkkio", + (SUBR)lposc_set, (SUBR)lposca}, /* end change */ - { "foscil", S(FOSC),TR, 3, "a", "xkxxkjo",foscset, foscil }, - { "foscili",S(FOSC),TR, 3, "a", "xkxxkjo",foscset, foscili }, - { "loscil", S(LOSC),TR, 3, "mm","xkjojoojoo",losset, loscil }, - { "loscilphs", S(LOSCPHS),TR, 3, "amm","xkjojoojoo",losset_phs, loscil_phs }, - { "loscil3phs", S(LOSCPHS),TR, 3,"amm","xkjojoojoo",losset_phs, loscil3_phs }, - { "loscil3", S(LOSC),TR, 3, "mm","xkjojoojoo",losset, loscil3 }, - { "adsyn", S(ADSYN),0, 3, "a", "kkkSo", adset_S, adsyn }, - { "adsyn.i", S(ADSYN),0, 3, "a", "kkkio", adset, adsyn }, - { "buzz", S(BUZZ),TR, 3, "a", "xxkio", bzzset, buzz }, - { "gbuzz", S(GBUZZ),TR, 3, "a", "xxkkkio",gbzset, gbuzz }, - { "pluck", S(PLUCK), TR, 3, "a", "kkiiioo",plukset, pluck }, - { "rand", S(RAND),0, 3, "a", "xvoo", rndset, arand }, - { "rand.k", S(RAND),0, 3, "k", "xvoo", rndset, krand, NULL }, - { "randh", S(RANDH),0, 3, "a", "xxvoo", rhset, randh }, - { "randh.k", S(RANDH),0, 3, "k", "xxvoo", rhset, krandh, NULL }, - { "randi", S(RANDI),0, 3, "a", "xxvoo", riset, randi }, - { "randi.k", S(RANDI),0, 3, "k", "xxvoo", riset, krandi }, - { "randc", S(RANDC),0, 3, "a", "xxvoo", rcset, randc }, - { "randc.k", S(RANDC),0, 3, "k", "xxvoo", rcset, krandc }, - { "port", S(PORT),0, 3, "k", "kio", porset, port }, - { "tone.k", S(TONE),0, 3, "a", "ako", tonset, tone }, - { "tonex.k",S(TONEX),0, 3, "a", "akoo", tonsetx, tonex }, - { "atone.k", S(TONE),0, 3, "a", "ako", tonset, atone }, - { "atonex.k", S(TONEX),0, 3, "a", "akoo", tonsetx, atonex }, - { "reson", S(RESON), 0, 3, "a", "axxoo", rsnset, reson }, - { "resonx", S(RESONX),0, 3, "a", "axxooo", rsnsetx, resonx }, - { "areson.kk", S(RESON),0,3, "a", "akkoo",rsnset, areson }, - { "lpread", S(LPREAD),0, 3, "kkkk", "kSoo", lprdset_S,lpread }, - { "lpread.i", S(LPREAD),0, 3, "kkkk", "kioo", lprdset,lpread }, - { "lpform", S(LPFORM),0, 3, "kk", "k", lpformantset,lpformant }, - { "lpreson",S(LPRESON),0, 3, "a", "a", lprsnset, lpreson }, - { "lpfreson",S(LPFRESON),0,3, "a", "ak", lpfrsnset, lpfreson}, - { "lpslot" , S(LPSLOT),0, 1, "", "i", lpslotset, NULL, NULL }, - { "lpinterp", S(LPINTERPOL),0, 3, "", "iik", lpitpset, lpinterpol, NULL}, - { "rms", S(RMS),0, 3, "k", "aqo", rmsset, rms }, - { "gain", S(GAIN),0, 3, "a", "akqo", gainset, gain }, - { "balance",S(BALANCE),0, 3, "a", "aaqo", balnset, balance }, - { "balance2",S(BALANCE),0, 3, "a", "aaqo", balnset, balance2 }, - { "pan", S(PAN),0, 3, "aaaa", "akkioo",(SUBR)panset, (SUBR)pan }, - { "soundin",S(DISKIN2),0,3,"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm","Soooo", - sndinset_S, soundin }, - { "soundin.i",S(DISKIN2),0,3,"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm","ioooo", - sndinset, soundin }, - { "soundout",S(SNDOUT), _QQ, 3, "", "aSo", sndoutset_S, soundout }, - { "soundout.i",S(SNDOUT), _QQ, 3, "", "aio", sndoutset, soundout }, - { "soundouts",S(SNDOUTS),_QQ, 3, "", "aaSo", sndoutset_S, soundouts }, - { "soundouts.i",S(SNDOUTS),_QQ, 3, "", "aaio", sndoutset, soundouts }, - { "in.a", S(INM),0, 2, "a", "", NULL, in }, - { "in.s", S(INS),0, 2, "aa", "", NULL, ins }, - { "in.A", S(INA),0, 2, "a[]", "", NULL, inarray }, - { "ins", S(INS),0, 2, "aa", "", NULL, ins }, - { "inq", S(INQ),0, 2, "aaaa", "", NULL, inq }, - { "out.a", S(OUTX),IR, 3, "", "y", ochn, outall }, - { "out.A", S(OUTARRAY),IR, 3, "", "a[]", outarr_init, outarr }, - { "outs", S(OUTX),IR, 3, "", "y", ochn, outall }, - { "outq", S(OUTX),IR, 3, "", "y", ochn, outall }, - { "outh", S(OUTX),IR, 3, "", "y", ochn, outall }, - { "outo", S(OUTX),IR, 3, "", "y", ochn, outall }, - { "outx", S(OUTX),IR, 3, "", "y", ochn, outall }, - { "out32", S(OUTX),IR, 3, "", "y", ochn, outall }, - { "outs1", S(OUTM),IR, 2, "", "a", NULL, outs1 }, - { "outs2", S(OUTM),IR, 3, "", "a", och2, outs2 }, - { "outq1", S(OUTM),IR, 2, "", "a", NULL, outs1 }, - { "outq2", S(OUTM),IR, 3, "", "a", och2, outs2 }, - { "outq3", S(OUTM),IR, 3, "", "a", och3, outq3 }, - { "outq4", S(OUTM),IR, 3, "", "a", och2, outq4 }, - { "outall", S(OUTM),IR, 2, "", "a", NULL, outrep }, - { "igoto", S(GOTO),0, 1, "", "l", igoto }, - { "kgoto", S(GOTO),0, 2, "", "l", NULL, kgoto }, - { "goto", S(GOTO),0, 3, "", "l", igoto, kgoto }, - { "cigoto", S(CGOTO),0, 1, "", "Bl", icgoto }, - { "ckgoto", S(CGOTO),0, 2, "", "Bl", NULL, kcgoto }, - { "cggoto.0", S(CGOTO),0, 3, "", "Bl", icgoto, kcgoto }, - { "timout", S(TIMOUT),0, 3, "", "iil", timset, timout }, - { "reinit", S(GOTO),0, 2, "", "l", NULL, reinit }, - { "rigoto", S(GOTO),0, 1, "", "l", rigoto }, - { "rireturn",S(LINK),0, 1, "", "", rireturn }, - { "tigoto", S(GOTO),0, 1, "", "l", tigoto }, - { "tival", S(EVAL),0, 1, "i", "", tival }, - { "print", S(PRINTV),WR, 1, "", "m", printv }, - { "display.k",S(DSPLAY),0, 3, "", "kioo", dspset, kdsplay,NULL }, - { "display.a",S(DSPLAY),0, 3, "", "aioo", dspset ,dsplay }, - { "pvsdisp",S(FSIGDISP),0, 3, "", "foo", fdspset, fdsplay,NULL }, - { "dispfft.k",S(DSPFFT),0, 3, "", "kiiooooo",fftset,kdspfft,NULL }, - { "dispfft.a",S(DSPFFT),0, 3, "", "aiiooooo",fftset,dspfft }, - { "dumpk", S(KDUMP),0, 3, "", "kSii", kdmpset_S,kdump }, - { "dumpk2", S(KDUMP2),0, 3, "", "kkSii",kdmp2set_S,kdump2 }, - { "dumpk3", S(KDUMP3),0, 3, "", "kkkSii",kdmp3set_S,kdump3 }, - { "dumpk4", S(KDUMP4),0, 3, "", "kkkkSii",kdmp4set_S,kdump4 }, - { "dumpk.i", S(KDUMP),0, 3, "", "kiii", kdmpset_p,kdump }, - { "dumpk2.i", S(KDUMP2),0, 3, "", "kkiii",kdmp2set_p,kdump2 }, - { "dumpk3.i", S(KDUMP3),0, 3, "", "kkkiii",kdmp3set_p,kdump3 }, - { "dumpk4.i", S(KDUMP4),0, 3, "", "kkkkiii",kdmp4set_p,kdump4 }, - { "readk", S(KREAD),0, 3, "k", "Sii", krdset_S, kread }, - { "readk2", S(KREAD2),0, 3, "kk", "Sii", krd2set_S, kread2 }, - { "readk3", S(KREAD3),0, 3, "kkk", "Sii", krd3set_S, kread3 }, - { "readk4", S(KREAD4),0, 3, "kkkk", "Sii", krd4set_S, kread4 }, - { "readk.i", S(KREAD),0, 3, "k", "iii", krdset_p, kread }, - { "readk2.i", S(KREAD2),0, 3, "kk", "iii", krd2set_p, kread2 }, - { "readk3.i", S(KREAD3),0, 3, "kkk", "iii", krd3set_p, kread3 }, - { "readk4.i", S(KREAD4),0, 3, "kkkk", "iii", krd4set_p, kread4 }, - { "readks", S(KREADS),0, 3, "S", "Si", krdsset_S, kreads }, - { "readks.i", S(KREADS),0, 3, "S", "ii", krdsset_p, kreads }, - { "xyin", S(XYIN), _QQ, 1, "kk", "iiiiioo",xyinset,NULL }, - { "tempest", S(TEMPEST),0, 3, "k","kiiiiiiiiiop",tempeset,tempest}, - { "tempo", S(TEMPO),0, 3, "", "ki", tempset,tempo }, - { "pow.i", S(POW),0, 1, "i", "iip", ipow, NULL, NULL }, - { "pow.k", S(POW),0, 2, "k", "kkp", NULL, ipow, NULL }, - { "pow.a", S(POW),0, 2, "a", "akp", NULL, apow }, - { "##pow.i", S(POW),0, 1, "i", "iip", ipow, NULL, NULL }, - { "##pow.k", S(POW),0, 2, "k", "kkp", NULL, ipow, NULL }, - { "##pow.a", S(POW),0, 2, "a", "akp", NULL, apow }, - { "oscilx", S(OSCILN), TR, 3, "a", "kiii", oscnset, osciln }, - { "linrand.i",S(PRAND),0, 1, "i", "k", iklinear, NULL, NULL }, - { "linrand.k",S(PRAND),0, 2, "k", "k", NULL, iklinear, NULL }, - { "linrand.a",S(PRAND),0, 2, "a", "k", NULL, alinear }, - { "trirand.i",S(PRAND),0, 1, "i", "k", iktrian, NULL, NULL }, - { "trirand.k",S(PRAND),0, 2, "k", "k", NULL, iktrian, NULL }, - { "trirand.a",S(PRAND),0, 2, "a", "k", NULL, atrian }, - { "exprand.i",S(PRAND),0, 1, "i", "k", ikexp, NULL, NULL }, - { "exprand.k",S(PRAND),0, 2, "k", "k", NULL, ikexp, NULL }, - { "exprand.a",S(PRAND),0, 2, "a", "k", NULL, aexp }, - { "bexprnd.i",S(PRAND),0, 1, "i", "k", ikbiexp, NULL, NULL }, - { "bexprnd.k",S(PRAND),0, 2, "k", "k", NULL, ikbiexp, NULL }, - { "bexprnd.a",S(PRAND),0, 2, "a", "k", NULL, abiexp }, - { "cauchy.i", S(PRAND),0, 1, "i", "k", ikcauchy, NULL, NULL }, - { "cauchy.k", S(PRAND),0, 2, "k", "k", NULL, ikcauchy, NULL }, - { "cauchy.a", S(PRAND),0, 2, "a", "k", NULL, acauchy }, - { "pcauchy.i",S(PRAND),0, 1, "i", "k", ikpcauchy, NULL,NULL }, - { "pcauchy.k",S(PRAND),0, 2, "k", "k", NULL, ikpcauchy,NULL }, - { "pcauchy.a",S(PRAND),0, 2, "a", "k", NULL, apcauchy}, - { "poisson.i",S(PRAND),0, 1, "i", "k", ikpoiss, NULL, NULL }, - { "poisson.k",S(PRAND),0, 2, "k", "k", NULL, ikpoiss, NULL }, - { "poisson.a",S(PRAND),0, 2, "a", "k", NULL, apoiss }, - { "gauss.i" , S(PRAND),0, 1, "i", "k", ikgaus, NULL, NULL }, - { "gauss.k" , S(PRAND),0, 2, "k", "k", NULL, ikgaus, NULL }, - { "gauss.a" , S(PRAND),0, 2, "a", "k", NULL, agaus }, - { "gauss.iii" , S(GAUSS),0, 1, "i", "ii", gauss_scalar, NULL, NULL }, - { "gauss.kkk" , S(GAUSS),0, 2, "k", "kk", NULL, gauss_scalar, NULL }, - { "gauss.akk" , S(GAUSS),0, 2, "a", "kk", NULL, gauss_vector }, - { "weibull.i",S(PRAND),0, 1, "i", "kk", ikweib, NULL, NULL }, - { "weibull.k",S(PRAND),0, 2, "k", "kk", NULL, ikweib, NULL }, - { "weibull.a",S(PRAND),0, 2, "a", "kk", NULL, aweib }, - { "betarand.i",S(PRAND),0,1, "i", "kkk", ikbeta, NULL, NULL }, - { "betarand.k",S(PRAND),0,2, "k", "kkk", NULL, ikbeta,NULL }, - { "betarand.a",S(PRAND),0,2, "a", "kkk", NULL, abeta }, - { "seed", S(PRAND),0, 1, "", "i", seedrand, NULL, NULL }, - { "getseed.i",S(GETSEED),0, 1, "i", "", getseed, NULL, NULL }, - { "getseed.k",S(GETSEED),0, 3, "k", "", getseed, getseed, NULL }, - { "unirand.i",S(PRAND),0, 1, "i", "k", ikuniform, NULL, NULL }, - { "unirand.k",S(PRAND),0, 2, "k", "k", NULL, ikuniform, NULL}, - { "unirand.a",S(PRAND),0, 2, "a", "k", NULL, auniform }, - { "diskin",S(DISKIN2_ARRAY),0, 3, "a[]", + { "foscil", S(FOSC),TR, "a", "xkxxkjo",foscset, foscil }, + { "foscili",S(FOSC),TR, "a", "xkxxkjo",foscset, foscili }, + { "loscil", S(LOSC),TR, "mm","xkjojoojoo",losset, loscil }, + { "loscilphs", S(LOSCPHS),TR, "amm","xkjojoojoo",losset_phs, loscil_phs }, + { "loscil3phs", S(LOSCPHS),TR, "amm","xkjojoojoo",losset_phs, loscil3_phs }, + { "loscil3", S(LOSC),TR, "mm","xkjojoojoo",losset, loscil3 }, + { "adsyn", S(ADSYN),0, "a", "kkkSo", adset_S, adsyn }, + { "adsyn.i", S(ADSYN),0, "a", "kkkio", adset, adsyn }, + { "buzz", S(BUZZ),TR, "a", "xxkio", bzzset, buzz }, + { "gbuzz", S(GBUZZ),TR, "a", "xxkkkio",gbzset, gbuzz }, + { "pluck", S(PLUCK), TR, "a", "kkiiioo",plukset, pluck }, + { "rand", S(RAND),0, "a", "xvoo", rndset, arand }, + { "rand.k", S(RAND),0, "k", "xvoo", rndset, krand, NULL }, + { "randh", S(RANDH),0, "a", "xxvoo", rhset, randh }, + { "randh.k", S(RANDH),0, "k", "xxvoo", rhset, krandh, NULL }, + { "randi", S(RANDI),0, "a", "xxvoo", riset, randi }, + { "randi.k", S(RANDI),0, "k", "xxvoo", riset, krandi }, + { "randc", S(RANDC),0, "a", "xxvoo", rcset, randc }, + { "randc.k", S(RANDC),0, "k", "xxvoo", rcset, krandc }, + { "port", S(PORT),0, "k", "kio", porset, port }, + { "tone.k", S(TONE),0, "a", "ako", tonset, tone }, + { "tonex.k",S(TONEX),0, "a", "akoo", tonsetx, tonex }, + { "atone.k", S(TONE),0, "a", "ako", tonset, atone }, + { "atonex.k", S(TONEX),0, "a", "akoo", tonsetx, atonex }, + { "reson", S(RESON), 0, "a", "axxoo", rsnset, reson }, + { "resonx", S(RESONX),0, "a", "axxooo", rsnsetx, resonx }, + { "areson.kk", S(RESON),0, "a", "akkoo",rsnset, areson }, + { "lpread", S(LPREAD),0, "kkkk", "kSoo", lprdset_S,lpread }, + { "lpread.i", S(LPREAD),0, "kkkk", "kioo", lprdset,lpread }, + { "lpform", S(LPFORM),0, "kk", "k", lpformantset,lpformant }, + { "lpreson",S(LPRESON),0, "a", "a", lprsnset, lpreson }, + { "lpfreson",S(LPFRESON),0, "a", "ak", lpfrsnset, lpfreson}, + { "lpslot" , S(LPSLOT),0, "", "i", lpslotset, NULL, NULL }, + { "lpinterp", S(LPINTERPOL),0, "", "iik", lpitpset, lpinterpol, NULL}, + { "rms", S(RMS),0, "k", "aqo", rmsset, rms }, + { "gain", S(GAIN),0, "a", "akqo", gainset, gain }, + { "balance",S(BALANCE),0, "a", "aaqo", balnset, balance }, + { "balance2",S(BALANCE),0, "a", "aaqo", balnset, balance2 }, + { "pan", S(PAN),0, "aaaa", "akkioo",(SUBR)panset, (SUBR)pan }, + { "soundin",S(DISKIN2),0,"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm","Soooo", + sndinset_S, soundin, (SUBR) diskin2_async_deinit }, + { "soundin.i",S(DISKIN2),0,"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm","ioooo", + sndinset, soundin, (SUBR) diskin2_async_deinit }, + { "soundout",S(SNDOUT), _QQ, "", "aSo", sndoutset_S, soundout, soundout_deinit}, + { "soundout.i",S(SNDOUT), _QQ, "", "aio", sndoutset, soundout, soundout_deinit }, + { "soundouts",S(SNDOUTS),_QQ, "", "aaSo", sndoutset_S, soundouts, soundout_deinit}, + { "soundouts.i",S(SNDOUTS),_QQ, "", "aaio", sndoutset, soundouts, soundout_deinit}, + { "in.a", S(INM),0, "a", "", NULL, in }, + { "in.s", S(INS),0, "aa", "", NULL, ins }, + { "in.A", S(INA),0, "a[]", "", NULL, inarray }, + { "ins", S(INS),0, "aa", "", NULL, ins }, + { "inq", S(INQ),0, "aaaa", "", NULL, inq }, + { "out.a", S(OUTX),IR, "", "y", ochn, outall }, + { "out.A", S(OUTARRAY),IR, "", "a[]", outarr_init, outarr }, + { "outs", S(OUTX),IR, "", "y", ochn, outall }, + { "outq", S(OUTX),IR, "", "y", ochn, outall }, + { "outh", S(OUTX),IR, "", "y", ochn, outall }, + { "outo", S(OUTX),IR, "", "y", ochn, outall }, + { "outx", S(OUTX),IR, "", "y", ochn, outall }, + { "out32", S(OUTX),IR, "", "y", ochn, outall }, + { "outs1", S(OUTM),IR, "", "a", NULL, outs1 }, + { "outs2", S(OUTM),IR, "", "a", och2, outs2 }, + { "outq1", S(OUTM),IR, "", "a", NULL, outs1 }, + { "outq2", S(OUTM),IR, "", "a", och2, outs2 }, + { "outq3", S(OUTM),IR, "", "a", och3, outq3 }, + { "outq4", S(OUTM),IR, "", "a", och2, outq4 }, + { "outall", S(OUTM),IR, "", "a", NULL, outrep }, + { "igoto", S(GOTO),0, "", "l", igoto }, + { "kgoto", S(GOTO),0, "", "l", NULL, kgoto }, + { "goto", S(GOTO),0, "", "l", igoto, kgoto }, + { "cigoto", S(CGOTO),0, "", "Bl", icgoto }, + { "ckgoto", S(CGOTO),0, "", "Bl", NULL, kcgoto }, + { "cggoto.0", S(CGOTO),0, "", "Bl", icgoto, kcgoto }, + { "timout", S(TIMOUT),0, "", "iil", timset, timout }, + { "reinit", S(GOTO),0, "", "l", NULL, reinit }, + { "rigoto", S(GOTO),0, "", "l", rigoto }, + { "rireturn",S(LINK),0, "", "", rireturn }, + { "tigoto", S(GOTO),0, "", "l", tigoto }, + { "tival", S(EVAL),0, "i", "", tival }, + { "print", S(PRINTV),WR, "", "m", printv }, + { "display.k",S(DSPLAY),0, "", "kioo", dspset, kdsplay,NULL }, + { "display.a",S(DSPLAY),0, "", "aioo", dspset ,dsplay }, + { "pvsdisp",S(FSIGDISP),0, "", "foo", fdspset, fdsplay,NULL }, + { "dispfft.k",S(DSPFFT),0, "", "kiiooooo",fftset,kdspfft,NULL }, + { "dispfft.a",S(DSPFFT),0, "", "aiiooooo",fftset,dspfft }, + { "dumpk", S(KDUMP),0, "", "kSii", kdmpset_S,kdump }, + { "dumpk2", S(KDUMP2),0, "", "kkSii",kdmp2set_S,kdump2 }, + { "dumpk3", S(KDUMP3),0, "", "kkkSii",kdmp3set_S,kdump3 }, + { "dumpk4", S(KDUMP4),0, "", "kkkkSii",kdmp4set_S,kdump4 }, + { "dumpk.i", S(KDUMP),0, "", "kiii", kdmpset_p,kdump }, + { "dumpk2.i", S(KDUMP2),0, "", "kkiii",kdmp2set_p,kdump2 }, + { "dumpk3.i", S(KDUMP3),0, "", "kkkiii",kdmp3set_p,kdump3 }, + { "dumpk4.i", S(KDUMP4),0, "", "kkkkiii",kdmp4set_p,kdump4 }, + { "readk", S(KREAD),0, "k", "Sii", krdset_S, kread }, + { "readk2", S(KREAD2),0, "kk", "Sii", krd2set_S, kread2 }, + { "readk3", S(KREAD3),0, "kkk", "Sii", krd3set_S, kread3 }, + { "readk4", S(KREAD4),0, "kkkk", "Sii", krd4set_S, kread4 }, + { "readk.i", S(KREAD),0, "k", "iii", krdset_p, kread }, + { "readk2.i", S(KREAD2),0, "kk", "iii", krd2set_p, kread2 }, + { "readk3.i", S(KREAD3),0, "kkk", "iii", krd3set_p, kread3 }, + { "readk4.i", S(KREAD4),0, "kkkk", "iii", krd4set_p, kread4 }, + { "readks", S(KREADS),0, "S", "Si", krdsset_S, kreads }, + { "readks.i", S(KREADS),0, "S", "ii", krdsset_p, kreads }, + { "xyin", S(XYIN), _QQ, "kk", "iiiiioo",xyinset,NULL }, + { "tempest", S(TEMPEST),0, "k","kiiiiiiiiiop",tempeset,tempest}, + { "tempo", S(TEMPO),0, "", "ki", tempset,tempo }, + { "pow.i", S(POW),0, "i", "iip", ipow, NULL, NULL }, + { "pow.k", S(POW),0, "k", "kkp", NULL, ipow, NULL }, + { "pow.a", S(POW),0, "a", "akp", NULL, apow }, + { "##pow.i", S(POW),0, "i", "iip", ipow, NULL, NULL }, + { "##pow.k", S(POW),0, "k", "kkp", NULL, ipow, NULL }, + { "##pow.a", S(POW),0, "a", "akp", NULL, apow }, + { "oscilx", S(OSCILN), TR, "a", "kiii", oscnset, osciln }, + { "linrand.i",S(PRAND),0, "i", "k", iklinear, NULL, NULL }, + { "linrand.k",S(PRAND),0, "k", "k", NULL, iklinear, NULL }, + { "linrand.a",S(PRAND),0, "a", "k", NULL, alinear }, + { "trirand.i",S(PRAND),0, "i", "k", iktrian, NULL, NULL }, + { "trirand.k",S(PRAND),0, "k", "k", NULL, iktrian, NULL }, + { "trirand.a",S(PRAND),0, "a", "k", NULL, atrian }, + { "exprand.i",S(PRAND),0, "i", "k", ikexp, NULL, NULL }, + { "exprand.k",S(PRAND),0, "k", "k", NULL, ikexp, NULL }, + { "exprand.a",S(PRAND),0, "a", "k", NULL, aexp }, + { "bexprnd.i",S(PRAND),0, "i", "k", ikbiexp, NULL, NULL }, + { "bexprnd.k",S(PRAND),0, "k", "k", NULL, ikbiexp, NULL }, + { "bexprnd.a",S(PRAND),0, "a", "k", NULL, abiexp }, + { "cauchy.i", S(PRAND),0, "i", "k", ikcauchy, NULL, NULL }, + { "cauchy.k", S(PRAND),0, "k", "k", NULL, ikcauchy, NULL }, + { "cauchy.a", S(PRAND),0, "a", "k", NULL, acauchy }, + { "pcauchy.i",S(PRAND),0, "i", "k", ikpcauchy, NULL,NULL }, + { "pcauchy.k",S(PRAND),0, "k", "k", NULL, ikpcauchy,NULL }, + { "pcauchy.a",S(PRAND),0, "a", "k", NULL, apcauchy}, + { "poisson.i",S(PRAND),0, "i", "k", ikpoiss, NULL, NULL }, + { "poisson.k",S(PRAND),0, "k", "k", NULL, ikpoiss, NULL }, + { "poisson.a",S(PRAND),0, "a", "k", NULL, apoiss }, + { "gauss.i" , S(PRAND),0, "i", "k", ikgaus, NULL, NULL }, + { "gauss.k" , S(PRAND),0, "k", "k", NULL, ikgaus, NULL }, + { "gauss.a" , S(PRAND),0, "a", "k", NULL, agaus }, + { "gauss.iii" , S(GAUSS),0, "i", "ii", gauss_scalar, NULL, NULL }, + { "gauss.kkk" , S(GAUSS),0, "k", "kk", NULL, gauss_scalar, NULL }, + { "gauss.akk" , S(GAUSS),0, "a", "kk", NULL, gauss_vector }, + { "weibull.i",S(PRAND),0, "i", "kk", ikweib, NULL, NULL }, + { "weibull.k",S(PRAND),0, "k", "kk", NULL, ikweib, NULL }, + { "weibull.a",S(PRAND),0, "a", "kk", NULL, aweib }, + { "betarand.i",S(PRAND),0, "i", "kkk", ikbeta, NULL, NULL }, + { "betarand.k",S(PRAND),0, "k", "kkk", NULL, ikbeta,NULL }, + { "betarand.a",S(PRAND),0, "a", "kkk", NULL, abeta }, + { "seed", S(PRAND),0, "", "i", seedrand, NULL, NULL }, + { "getseed.i",S(GETSEED),0, "i", "", getseed, NULL, NULL }, + { "getseed.k",S(GETSEED),0, "k", "", getseed, getseed, NULL }, + { "unirand.i",S(PRAND),0, "i", "k", ikuniform, NULL, NULL }, + { "unirand.k",S(PRAND),0, "k", "k", NULL, ikuniform, NULL}, + { "unirand.a",S(PRAND),0, "a", "k", NULL, auniform }, + { "diskin",S(DISKIN2_ARRAY),0, "a[]", "SPooooooo", (SUBR) diskin_init_array_S, - (SUBR) diskin2_perf_array }, - { "diskin2",S(DISKIN2_ARRAY),0, 3, "a[]", + (SUBR) diskin2_perf_array, (SUBR) diskin2_async_deinit_array }, + { "diskin2",S(DISKIN2_ARRAY),0, "a[]", "SPooooooo", (SUBR) diskin2_init_array_S, - (SUBR) diskin2_perf_array }, - { "diskin.i",S(DISKIN2_ARRAY),0, 3, "a[]", + (SUBR) diskin2_perf_array, (SUBR) diskin2_async_deinit_array}, + { "diskin.i",S(DISKIN2_ARRAY),0, "a[]", "iPooooooo", (SUBR) diskin_init_array_I, - (SUBR) diskin2_perf_array }, - { "diskin2.i",S(DISKIN2_ARRAY),0, 3, "a[]", + (SUBR) diskin2_perf_array, (SUBR) diskin2_async_deinit_array}, + { "diskin2.i",S(DISKIN2_ARRAY),0, "a[]", "iPooooooo", (SUBR) diskin2_init_array_I, - (SUBR) diskin2_perf_array }, - { "diskin",S(DISKIN2),0, 3, "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", + (SUBR) diskin2_perf_array, (SUBR) diskin2_async_deinit_array}, + { "diskin",S(DISKIN2),0, "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", "SPooooooo", (SUBR) diskin_init_S, - (SUBR) diskin2_perf }, - { "diskin2",S(DISKIN2),0, 3, "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", + (SUBR) diskin2_perf, (SUBR) diskin2_async_deinit }, + { "diskin2",S(DISKIN2),0, "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", "SPooooooo", (SUBR) diskin2_init_S, - (SUBR) diskin2_perf }, - { "diskin.i",S(DISKIN2),0, 3, "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", + (SUBR) diskin2_perf, (SUBR) diskin2_async_deinit }, + { "diskin.i",S(DISKIN2),0, "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", "iPooooooo", (SUBR) diskin_init, - (SUBR) diskin2_perf }, - { "diskin2.i",S(DISKIN2),0, 3, "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", + (SUBR) diskin2_perf, (SUBR) diskin2_async_deinit }, + { "diskin2.i",S(DISKIN2),0, "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", "iPooooooo", (SUBR) diskin2_init, - (SUBR) diskin2_perf }, - { "noteon", S(OUT_ON),0, 1, "", "iii", iout_on, NULL, NULL }, - { "noteoff", S(OUT_ON),0, 1, "", "iii", iout_off, NULL, NULL }, - { "noteondur",S(OUT_ON_DUR),0,3, "", "iiii", iout_on_dur_set,iout_on_dur,NULL}, - { "noteondur2",S(OUT_ON_DUR),0,3, "", "iiii", iout_on_dur_set,iout_on_dur2,NULL}, - { "moscil",S(MOSCIL),0, 3, "", "kkkkk",moscil_set, moscil, NULL}, - { "midion",S(KOUT_ON),0, 3, "", "kkk", kvar_out_on_set,kvar_out_on,NULL}, - { "outic",S(OUT_CONTR),0, 1, "", "iiiii", out_controller, NULL, NULL}, - { "outkc",S(OUT_CONTR),0, 2, "", "kkkkk", NULL, out_controller, NULL}, - { "outic14",S(OUT_CONTR14),0,1, "", "iiiiii",out_controller14, NULL,NULL}, - { "outkc14",S(OUT_CONTR14),0,2, "", "kkkkkk",NULL, out_controller14, NULL}, - { "outipb",S(OUT_PB),0, 1, "", "iiii", out_pitch_bend, NULL , NULL}, - { "outkpb",S(OUT_PB),0, 2, "", "kkkk", NULL, out_pitch_bend, NULL}, - { "outiat",S(OUT_ATOUCH),0,1, "", "iiii", out_aftertouch, NULL , NULL}, - { "outkat",S(OUT_ATOUCH),0,2, "", "kkkk", NULL, out_aftertouch, NULL}, - { "outipc",S(OUT_PCHG),0, 1, "", "iiii", out_progchange, NULL , NULL}, - { "outkpc",S(OUT_PCHG),0, 2, "", "kkkk", NULL, out_progchange, NULL}, - { "outipat",S(OUT_POLYATOUCH),0,1,"", "iiiii", out_poly_aftertouch, NULL,NULL}, - { "outkpat",S(OUT_POLYATOUCH),0,2,"", "kkkkk", NULL, out_poly_aftertouch,NULL}, - { "release",S(REL),0, 3, "k", "", release_set, release, NULL }, - { "xtratim",S(XTRADUR),0, 1, "", "i", xtratim, NULL, NULL }, - { "mclock", S(MCLOCK),0, 3, "", "i", mclock_set, mclock, NULL }, - { "mrtmsg", S(XTRADUR),0, 1, "", "i", mrtmsg, NULL, NULL }, - { "midiout",S(MIDIOUT),0, 2, "", "kkkk", NULL, midiout, NULL }, - { "midiout_i",S(MIDIOUT), 0, 1, "", "iiii", midiout, NULL, NULL }, - { "midion2", S(KON2),0, 3, "", "kkkk", kon2_set, kon2, NULL }, - { "nrpn", S(NRPN),0, 2, "", "kkk", NULL, nrpn ,NULL }, - { "mdelay", S(MDELAY),0, 3, "", "kkkkk",mdelay_set, mdelay, NULL }, - { "nsamp.i", S(EVAL),0, 1, "i", "i", numsamp }, - { "powoftwo.i",S(EVAL),0, 1, "i", "i", powoftwo }, - { "powoftwo.k",S(EVAL),0, 2, "k", "k", NULL, powoftwo }, - { "powoftwo.a",S(EVAL),0, 2, "a", "a", NULL, powoftwoa }, - { "logbtwo.i",S(EVAL),0, 1, "i", "i", ilogbasetwo }, - { "logbtwo.k",S(EVAL),0, 3, "k", "k", logbasetwo_set, logbasetwo }, - { "logbtwo.a",S(EVAL),0, 3, "a", "a", + (SUBR) diskin2_perf, (SUBR) diskin2_async_deinit }, + { "noteon", S(OUT_ON),0, "", "iii", iout_on, NULL, NULL }, + { "noteoff", S(OUT_ON),0, "", "iii", iout_off, NULL, NULL }, + { "noteondur",S(OUT_ON_DUR),0, "", "iiii", iout_on_dur_set,iout_on_dur,NULL}, + { "noteondur2",S(OUT_ON_DUR),0, "", "iiii", iout_on_dur_set,iout_on_dur2,NULL}, + { "moscil",S(MOSCIL),0, "", "kkkkk",moscil_set, moscil, NULL}, + { "midion",S(KOUT_ON),0, "", "kkk", kvar_out_on_set,kvar_out_on,NULL}, + { "outic",S(OUT_CONTR),0, "", "iiiii", out_controller, NULL, NULL}, + { "outkc",S(OUT_CONTR),0, "", "kkkkk", NULL, out_controller, NULL}, + { "outic14",S(OUT_CONTR14),0, "", "iiiiii",out_controller14, NULL,NULL}, + { "outkc14",S(OUT_CONTR14),0, "", "kkkkkk",NULL, out_controller14, NULL}, + { "outipb",S(OUT_PB),0, "", "iiii", out_pitch_bend, NULL , NULL}, + { "outkpb",S(OUT_PB),0, "", "kkkk", NULL, out_pitch_bend, NULL}, + { "outiat",S(OUT_ATOUCH),0, "", "iiii", out_aftertouch, NULL , NULL}, + { "outkat",S(OUT_ATOUCH),0, "", "kkkk", NULL, out_aftertouch, NULL}, + { "outipc",S(OUT_PCHG),0, "", "iiii", out_progchange, NULL , NULL}, + { "outkpc",S(OUT_PCHG),0, "", "kkkk", NULL, out_progchange, NULL}, + { "outipat",S(OUT_POLYATOUCH),0,"", "iiiii", out_poly_aftertouch, NULL,NULL}, + { "outkpat",S(OUT_POLYATOUCH),0, "", "kkkkk", NULL, out_poly_aftertouch,NULL}, + { "release",S(REL),0, "k", "", release_set, release, NULL }, + { "xtratim",S(XTRADUR),0, "", "i", xtratim, NULL, NULL }, + { "mclock", S(MCLOCK),0, "", "i", mclock_set, mclock, NULL }, + { "mrtmsg", S(XTRADUR),0, "", "i", mrtmsg, NULL, NULL }, + { "midiout",S(MIDIOUT),0, "", "kkkk", NULL, midiout, NULL }, + { "midiout_i",S(MIDIOUT), 0, "", "iiii", midiout, NULL, NULL }, + { "midion2", S(KON2),0, "", "kkkk", kon2_set, kon2, NULL }, + { "nrpn", S(NRPN),0, "", "kkk", NULL, nrpn ,NULL }, + { "mdelay", S(MDELAY),0, "", "kkkkk",mdelay_set, mdelay, NULL }, + { "nsamp.i", S(EVAL),0, "i", "i", numsamp }, + { "powoftwo.i",S(EVAL),0, "i", "i", powoftwo }, + { "powoftwo.k",S(EVAL),0, "k", "k", NULL, powoftwo }, + { "powoftwo.a",S(EVAL),0, "a", "a", NULL, powoftwoa }, + { "logbtwo.i",S(EVAL),0, "i", "i", ilogbasetwo }, + { "logbtwo.k",S(EVAL),0, "k", "k", logbasetwo_set, logbasetwo }, + { "logbtwo.a",S(EVAL),0, "a", "a", logbasetwo_set, logbasetwoa }, - { "filelen", S(SNDINFO),0, 1, "i", "Sp", filelen_S, NULL, NULL }, - { "filenchnls", S(SNDINFO),0, 1, "i", "Sp", filenchnls_S, NULL, NULL }, - { "filesr", S(SNDINFO),0, 1, "i", "Sp", filesr_S, NULL, NULL }, - { "filebit", S(SNDINFO),0, 1, "i", "Sp", filebit_S, NULL, NULL }, - { "filepeak", S(SNDINFOPEAK),0, 1, "i", "So", filepeak_S, NULL, NULL }, - { "filevalid", S(FILEVALID),0, 1, "i", "S", filevalid_S, NULL, NULL }, - { "filelen.i", S(SNDINFO),0, 1, "i", "ip", filelen, NULL, NULL }, - { "filenchnls.i", S(SNDINFO),0, 1, "i", "ip", filenchnls, NULL, NULL }, - { "filesr.i", S(SNDINFO),0, 1, "i", "ip", filesr, NULL, NULL }, - { "filebit.i", S(SNDINFO),0, 1, "i", "ip", filebit, NULL, NULL }, - { "filepeak.i", S(SNDINFOPEAK),0, 1, "i", "io", filepeak, NULL, NULL }, - { "filevalid.i", S(FILEVALID),0, 1, "i", "i", filevalid, NULL, NULL }, - { "filevalid.k", S(FILEVALID),0, 2, "k", "S", NULL, filevalid_S, NULL }, - { "filevalid.k", S(FILEVALID),0, 2, "k", "i", NULL, filevalid, NULL }, - /* { "nlalp", S(NLALP),0, 3, "a", "akkoo", nlalp_set, nlalp }, */ - { "ptableiw", S(TABLEW),TW|_QQ, 1, "", "iiiooo", (SUBR)tablew_init, NULL, NULL}, - { "ptablew.kk", S(TABLEW),TB, 3, "", "kkiooo",(SUBR)tabl_setup, + { "filelen", S(SNDINFO),0, "i", "Sp", filelen_S, NULL, NULL }, + { "filenchnls", S(SNDINFO),0, "i", "Sp", filenchnls_S, NULL, NULL }, + { "filesr", S(SNDINFO),0, "i", "Sp", filesr_S, NULL, NULL }, + { "filebit", S(SNDINFO),0, "i", "Sp", filebit_S, NULL, NULL }, + { "filepeak", S(SNDINFOPEAK),0, "i", "So", filepeak_S, NULL, NULL }, + { "filevalid", S(FILEVALID),0, "i", "S", filevalid_S, NULL, NULL }, + { "filelen.i", S(SNDINFO),0, "i", "ip", filelen, NULL, NULL }, + { "filenchnls.i", S(SNDINFO),0, "i", "ip", filenchnls, NULL, NULL }, + { "filesr.i", S(SNDINFO),0, "i", "ip", filesr, NULL, NULL }, + { "filebit.i", S(SNDINFO),0, "i", "ip", filebit, NULL, NULL }, + { "filepeak.i", S(SNDINFOPEAK),0, "i", "io", filepeak, NULL, NULL }, + { "filevalid.i", S(FILEVALID),0, "i", "i", filevalid, NULL, NULL }, + { "filevalid.k", S(FILEVALID),0, "k", "S", NULL, filevalid_S, NULL }, + { "filevalid.k", S(FILEVALID),0, "k", "i", NULL, filevalid, NULL }, + /* { "nlalp", S(NLALP),0, "a", "akkoo", nlalp_set, nlalp }, */ + { "ptableiw", S(TABLEW),TW|_QQ, "", "iiiooo", (SUBR)tablew_init, NULL, NULL}, + { "ptablew.kk", S(TABLEW),TB, "", "kkiooo",(SUBR)tabl_setup, (SUBR)tablew_kontrol, NULL }, - { "ptablew.aa", S(TABLEW),TB, 3, "", "aaiooo",(SUBR)tabl_setup, + { "ptablew.aa", S(TABLEW),TB, "", "aaiooo",(SUBR)tabl_setup, (SUBR)tablew_audio }, - { "tableiw", S(TABL),TW|_QQ, 1, "", "iiiooo", (SUBR)tablew_init, NULL, NULL}, - { "tablew", S(TABL),TW, 1, "", "iiiooo", (SUBR)tablew_init, NULL, NULL}, - { "tablew.kk", S(TABL),TW, 3, "", "kkiooo",(SUBR)tabl_setup, + { "tableiw", S(TABL),TW|_QQ, "", "iiiooo", (SUBR)tablew_init, NULL, NULL}, + { "tablew", S(TABL),TW, "", "iiiooo", (SUBR)tablew_init, NULL, NULL}, + { "tablew.kk", S(TABL),TW, "", "kkiooo",(SUBR)tabl_setup, (SUBR)tablew_kontrol, NULL }, - { "tablew.aa", S(TABL),TW, 3, "", "aaiooo",(SUBR)tabl_setup, + { "tablew.aa", S(TABL),TW, "", "aaiooo",(SUBR)tabl_setup, (SUBR)tablew_audio }, - { "tablewkt.kk", S(TABL),TW,3, "", "kkkooo", + { "tablewkt.kk", S(TABL),TW, "", "kkkooo", (SUBR)tablkt_setup,(SUBR)tablewkt_kontrol,NULL}, - { "tablewkt.aa", S(TABL),TW,3, "", "aakooo", + { "tablewkt.aa", S(TABL),TW, "", "aakooo", (SUBR)tablkt_setup,(SUBR)tablewkt_audio}, - { "tableng.i", S(TLEN),TR,1, "i", "i", (SUBR)table_length, NULL, NULL}, - { "tableng.k", S(TLEN),TR,2, "k", "k", NULL, (SUBR)table_length, NULL}, - { "tableigpw",S(TGP), TB, 1, "", "i", (SUBR)table_gpw, NULL, NULL}, - { "tablegpw", S(TGP), TB,2, "", "k", NULL, (SUBR)table_gpw, NULL}, - { "tableimix",S(TABLMIX),TB, 1, "", "iiiiiiiii", (SUBR)table_mix, NULL, NULL}, - { "tablemix", S(TABLMIX),TB, 2, "", "kkkkkkkkk", NULL, (SUBR)table_mix, NULL}, - { "tableicopy",S(TGP),TB, 1, "", "ii", (SUBR)table_copy, NULL, NULL}, - { "tablecopy", S(TGP),TB, 2, "", "kk", NULL, (SUBR)table_copy, NULL}, - { "tablera", S(TABLRA),TR, 3, "a", "kkk", + { "tableng.i", S(TLEN),TR, "i", "i", (SUBR)table_length, NULL, NULL}, + { "tableng.k", S(TLEN),TR, "k", "k", NULL, (SUBR)table_length, NULL}, + { "tableigpw",S(TGP), TB, "", "i", (SUBR)table_gpw, NULL, NULL}, + { "tablegpw", S(TGP), TB, "", "k", NULL, (SUBR)table_gpw, NULL}, + { "tableimix",S(TABLMIX),TB, "", "iiiiiiiii", (SUBR)table_mix, NULL, NULL}, + { "tablemix", S(TABLMIX),TB, "", "kkkkkkkkk", NULL, (SUBR)table_mix, NULL}, + { "tableicopy",S(TGP),TB, "", "ii", (SUBR)table_copy, NULL, NULL}, + { "tablecopy", S(TGP),TB, "", "kk", NULL, (SUBR)table_copy, NULL}, + { "tablera", S(TABLRA),TR, "a", "kkk", (SUBR)table_ra_set, (SUBR)table_ra}, - { "tablewa", S(TABLWA),TW, 3, "k", "kakp", + { "tablewa", S(TABLWA),TW, "k", "kakp", (SUBR)table_wa_set, (SUBR)table_wa}, - { "tablekt", S(TABL),TR, 3, "k", "xkooo", (SUBR)tablkt_setup, + { "tablekt", S(TABL),TR, "k", "xkooo", (SUBR)tablkt_setup, (SUBR)tablerkt_kontrol, NULL }, - { "tablekt.a", S(TABL),TR, 3, "a", "xkooo", (SUBR)tablkt_setup, + { "tablekt.a", S(TABL),TR, "a", "xkooo", (SUBR)tablkt_setup, (SUBR)tablerkt_audio }, - { "tableikt", S(TABL),TR, 3, "k", "xkooo", (SUBR)tablkt_setup, + { "tableikt", S(TABL),TR, "k", "xkooo", (SUBR)tablkt_setup, (SUBR)tableirkt_kontrol, NULL }, - { "tableikt.a", S(TABL),TR, 3, "a", "xkooo", (SUBR)tablkt_setup, + { "tableikt.a", S(TABL),TR, "a", "xkooo", (SUBR)tablkt_setup, (SUBR)tableirkt_audio }, - { "table3kt", S(TABL),TR, 3, "k", "xkooo", (SUBR)tablkt_setup, + { "table3kt", S(TABL),TR, "k", "xkooo", (SUBR)tablkt_setup, (SUBR)table3rkt_kontrol, NULL }, - { "table3kt.a", S(TABL),TR, 3, "a", "xkooo", (SUBR)tablkt_setup, + { "table3kt.a", S(TABL),TR, "a", "xkooo", (SUBR)tablkt_setup, (SUBR)table3rkt_audio }, - { "inz", S(IOZ), ZW, 2, "", "k", NULL, (SUBR)inz }, - { "outz", S(IOZ),ZR|IR, 2, "", "k", NULL, (SUBR)outz }, + { "inz", S(IOZ), ZW, "", "k", NULL, (SUBR)inz }, + { "outz", S(IOZ),ZR|IR, "", "k", NULL, (SUBR)outz }, - { "timek.k", S(RDTIME),0, 2, "k", "", NULL, (SUBR)timek, NULL }, - { "timek.i", S(RDTIME),0, 1, "i", "", (SUBR)timek, NULL, NULL }, + { "timek.k", S(RDTIME),0, "k", "", NULL, (SUBR)timek, NULL }, + { "timek.i", S(RDTIME),0, "i", "", (SUBR)timek, NULL, NULL }, - { "times.k", S(RDTIME),0, 2, "k", "", NULL, (SUBR)timesr,NULL }, - { "times.i", S(RDTIME),0, 1, "i", "", (SUBR)timesr, NULL, NULL }, + { "times.k", S(RDTIME),0, "k", "", NULL, (SUBR)timesr,NULL }, + { "times.i", S(RDTIME),0, "i", "", (SUBR)timesr, NULL, NULL }, - { "elapsedcycles.k", S(RDTIME),0, 2, "k", "", NULL, (SUBR)elapsedcycles, NULL }, - { "elapsedcycles.i", S(RDTIME),0, 1, "i", "", (SUBR)elapsedcycles, NULL, NULL }, + { "elapsedcycles.k", S(RDTIME),0, "k", "", NULL, (SUBR)elapsedcycles, NULL }, + { "elapsedcycles.i", S(RDTIME),0, "i", "", (SUBR)elapsedcycles, NULL, NULL }, - { "elapsedtime.k", S(RDTIME),0, 2, "k", "", NULL, (SUBR)elapsedtime,NULL }, - { "elapsedtime.i", S(RDTIME),0, 1, "i", "", (SUBR)elapsedtime, NULL, NULL }, + { "elapsedtime.k", S(RDTIME),0, "k", "", NULL, (SUBR)elapsedtime,NULL }, + { "elapsedtime.i", S(RDTIME),0, "i", "", (SUBR)elapsedtime, NULL, NULL }, - { "timeinstk", S(RDTIME),0, 3, "k", "", + { "timeinstk", S(RDTIME),0, "k", "", (SUBR)instimset, (SUBR)instimek, NULL }, - { "timeinsts", S(RDTIME),0, 3, "k", "", + { "timeinsts", S(RDTIME),0, "k", "", (SUBR)instimset, (SUBR)instimes, NULL }, - { "eventcycles", S(RDTIME),0, 3, "k", "", + { "eventcycles", S(RDTIME),0, "k", "", (SUBR)instimset, (SUBR)eventcycles, NULL }, - { "eventtime", S(RDTIME),0, 3, "k", "", + { "eventtime", S(RDTIME),0, "k", "", (SUBR)instimset, (SUBR)eventtime, NULL }, - { "peak.k", S(PEAK),0, 2, "k", "k", NULL, (SUBR)peakk, NULL }, - { "peak.a", S(PEAK),0, 2, "k", "a", NULL, (SUBR)peaka }, - { "printk", S(PRINTK),WR, 3,"", "ikoooo", + { "peak.k", S(PEAK),0, "k", "k", NULL, (SUBR)peakk, NULL }, + { "peak.a", S(PEAK),0, "k", "a", NULL, (SUBR)peaka }, + { "printk", S(PRINTK),WR, "", "ikoooo", (SUBR)printkset, (SUBR)printk, NULL }, - { "printks",S(PRINTKS),WR, 3, "", "SiN", + { "printks",S(PRINTKS),WR, "", "SiN", (SUBR)printksset_S,(SUBR)printks, NULL }, - { "printks2", sizeof(PRINTK3),0, 3, "", "Sk", (SUBR)printk3set, (SUBR)printk3 }, - { "printks.i",S(PRINTKS),WR, 3, "", "iiN", + { "printks2", sizeof(PRINTK3),0, "", "Sk", (SUBR)printk3set, (SUBR)printk3 }, + { "printks.i",S(PRINTKS),WR, "", "iiN", (SUBR)printksset,(SUBR)printks, NULL }, - { "prints",S(PRINTS),0, 1, "", "SN", (SUBR)printsset_S, NULL, NULL }, - { "prints.i",S(PRINTS),0, 1, "", "iN", (SUBR)printsset, NULL, NULL }, - { "printk2", S(PRINTK2), WR, 3, "", "koo", + { "prints",S(PRINTS),0, "", "SN", (SUBR)printsset_S, NULL, NULL }, + { "prints.i",S(PRINTS),0, "", "iN", (SUBR)printsset, NULL, NULL }, + { "printk2", S(PRINTK2), WR, "", "koo", (SUBR)printk2set, (SUBR)printk2, NULL }, - { "portk", S(PORT),0, 3, "k", "kko", (SUBR)porset, (SUBR)kport, NULL }, - { "tonek", S(TONE),0, 3, "k", "kko", (SUBR)tonset, (SUBR)ktone, NULL }, - { "atonek", S(TONE),0, 3, "k", "kko", (SUBR)tonset, (SUBR)katone, NULL}, - { "resonk", S(RESON),0, 3, "k", "kkkpo",(SUBR)rsnset, (SUBR)kreson, NULL}, - { "aresonk",S(RESON),0, 3, "k", "kkkpo",(SUBR)rsnset, (SUBR)kreson, NULL}, - { "aresonk",S(RESON),0, 3, "k", "kkkpo",(SUBR)rsnset, (SUBR)kareson, NULL}, - { "limit.i", S(LIMIT),0, 1, "i", "iii", (SUBR)klimit, NULL, NULL }, - { "limit.k", S(LIMIT),0, 2, "k", "kkk", NULL, (SUBR)klimit, NULL }, - { "limit.a", S(LIMIT),0, 2, "a", "akk", NULL, (SUBR)limit }, - { "prealloc", S(AOP),0, 1, "", "iio", (SUBR)prealloc, NULL, NULL }, - { "prealloc.S", S(AOP),0, 1, "", "Sio", (SUBR)prealloc_S, NULL, NULL }, + { "portk", S(PORT),0, "k", "kko", (SUBR)porset, (SUBR)kport, NULL }, + { "tonek", S(TONE),0, "k", "kko", (SUBR)tonset, (SUBR)ktone, NULL }, + { "atonek", S(TONE),0, "k", "kko", (SUBR)tonset, (SUBR)katone, NULL}, + { "resonk", S(RESON),0, "k", "kkkpo",(SUBR)rsnset, (SUBR)kreson, NULL}, + { "aresonk",S(RESON),0, "k", "kkkpo",(SUBR)rsnset, (SUBR)kreson, NULL}, + { "aresonk",S(RESON),0, "k", "kkkpo",(SUBR)rsnset, (SUBR)kareson, NULL}, + { "limit.i", S(LIMIT),0, "i", "iii", (SUBR)klimit, NULL, NULL }, + { "limit.k", S(LIMIT),0, "k", "kkk", NULL, (SUBR)klimit, NULL }, + { "limit.a", S(LIMIT),0, "a", "akk", NULL, (SUBR)limit }, + { "prealloc", S(AOP),0, "", "iio", (SUBR)prealloc, NULL, NULL }, + { "prealloc.S", S(AOP),0, "", "Sio", (SUBR)prealloc_S, NULL, NULL }, /* opcode dspace thread outarg inargs isub ksub asub */ - { "inh", S(INH),0, 2, "aaaaaa","", NULL, inh }, - { "ino", S(INO),0, 2, "aaaaaaaa","", NULL, ino }, - { "inx", S(INALL),0, 2, "aaaaaaaaaaaaaaaa","", NULL, in16 }, - { "in32", S(INALL),0, 2, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + { "inh", S(INH),0, "aaaaaa","", NULL, inh }, + { "ino", S(INO),0, "aaaaaaaa","", NULL, ino }, + { "inx", S(INALL),0, "aaaaaaaaaaaaaaaa","", NULL, in16 }, + { "in32", S(INALL),0, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "", NULL, in32 }, - { "inch", S(INCH1),0, 3, "a", + { "inch", S(INCH1),0, "a", "k", inch1_set, (SUBR) inch_opcode1 }, - { "inch.m", S(INCH),0, 3, "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", + { "inch.m", S(INCH),0, "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", "z", inch_set, inch_opcode }, - { "_in", S(INALL),0, 3, "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", + { "_in", S(INALL),0, "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", "", inch_set, inall_opcode }, /* Note that there is code in rdorch.c that assumes that opcodes starting with the characters out followed by a s, q, h, o or x are in this group ***BEWARE*** CODE REMOVED 2011-Dec-14 */ - { "outch", S(OUTCH),IR, 2, "", "Z", NULL, outch }, - { "outc", S(OUTX),IR, 2, "", "y", ochn, outall }, - { "cpsxpch", S(XENH),TR, 1, "i", "iiii", cpsxpch, NULL, NULL }, - { "cps2pch", S(XENH),TR, 1, "i", "ii", cps2pch, NULL, NULL }, - { "cpstun", S(CPSTUN), TR, 2, "k", "kkk", NULL, cpstun }, - { "cpstuni",S(CPSTUNI), TR, 1, "i", "ii", cpstun_i, }, - { "cpstmid", S(CPSTABLE),0, 1, "i", "i", (SUBR)cpstmid }, - { "adsr", S(LINSEG),0, 3, "k", "iiiio",adsrset,klnseg, NULL }, - { "adsr.a", S(LINSEG),0, 3, "a", "iiiio",adsrset, linseg }, - { "madsr", S(LINSEG),0, 3, "k", "iiiioj", madsrset,klnsegr,NULL }, - { "madsr.a", S(LINSEG),0, 3, "a", "iiiioj", madsrset, linsegr }, - { "xadsr", S(EXXPSEG),0, 3, "k", "iiiio", xdsrset, kxpseg, NULL }, - { "xadsr.a", S(EXXPSEG),0, 3, "a", "iiiio", xdsrset, expseg }, - { "mxadsr", S(EXPSEG),0, 3, "k", "iiiioj", mxdsrset, kxpsegr, NULL}, - { "mxadsr.a", S(EXPSEG),0, 3, "a", "iiiioj", mxdsrset, expsegr}, - { "schedule", S(SCHED),0, 1, "", "iiim", + { "outch", S(OUTCH),IR, "", "Z", NULL, outch }, + { "outc", S(OUTX),IR, "", "y", ochn, outall }, + { "cpsxpch", S(XENH),TR, "i", "iiii", cpsxpch, NULL, NULL }, + { "cps2pch", S(XENH),TR, "i", "ii", cps2pch, NULL, NULL }, + { "cpstun", S(CPSTUN), TR, "k", "kkk", NULL, cpstun }, + { "cpstuni",S(CPSTUNI), TR, "i", "ii", cpstun_i, }, + { "cpstmid", S(CPSTABLE),0, "i", "i", (SUBR)cpstmid }, + { "adsr", S(LINSEG),0, "k", "iiiio",adsrset,klnseg, NULL }, + { "adsr.a", S(LINSEG),0, "a", "iiiio",adsrset, linseg }, + { "madsr", S(LINSEG),0, "k", "iiiioj", madsrset,klnsegr,NULL }, + { "madsr.a", S(LINSEG),0, "a", "iiiioj", madsrset, linsegr }, + { "xadsr", S(EXXPSEG),0, "k", "iiiio", xdsrset, kxpseg, NULL }, + { "xadsr.a", S(EXXPSEG),0, "a", "iiiio", xdsrset, expseg }, + { "mxadsr", S(EXPSEG),0, "k", "iiiioj", mxdsrset, kxpsegr, NULL}, + { "mxadsr.a", S(EXPSEG),0, "a", "iiiioj", mxdsrset, expsegr}, + { "schedule", S(SCHED),0, "", "iiim", schedule, NULL, NULL }, - { "schedule.N", S(SCHED),0, 1, "", "iiiN", + { "schedule.N", S(SCHED),0, "", "iiiN", schedule_N, NULL, NULL }, - { "schedule.S", S(SCHED),0, 1, "", "Siim", + { "schedule.S", S(SCHED),0, "", "Siim", schedule_S, NULL, NULL }, - { "schedule.SN", S(SCHED),0, 1, "", "SiiN", + { "schedule.SN", S(SCHED),0, "", "SiiN", schedule_SN, NULL, NULL }, - { "schedule.array", S(SCHED),0, 1, "", "i[]", + { "schedule.array", S(SCHED),0, "", "i[]", schedule_array, NULL, NULL }, /* **** Experimental schedulek opcodes **** */ - { "schedulek", S(SCHED),0, 2, "", "kkkM", + { "schedulek", S(SCHED),0, "", "kkkM", NULL, schedule, NULL }, - { "schedulek.N", S(SCHED),0, 2, "", "kkkN", + { "schedulek.N", S(SCHED),0, "", "kkkN", NULL, schedule_N, NULL }, - { "schedulek.S", S(SCHED),0, 2, "", "SkkM", + { "schedulek.S", S(SCHED),0, "", "SkkM", NULL, schedule_S, NULL }, - { "schedulek.SN", S(SCHED),0, 2, "", "SkkN", + { "schedulek.SN", S(SCHED),0, "", "SkkN", NULL, schedule_SN, NULL }, - { "schedulek.array", S(SCHED),0, 2, "", "k[]", + { "schedulek.array", S(SCHED),0, "", "k[]", NULL, schedule_array, NULL }, /* **** End of schedulek **** */ - { "schedwhen", S(WSCHED),0,3, "", "kkkkm",ifschedule, kschedule, NULL }, - { "schedwhen", S(WSCHED),0,3, "", "kSkkm",ifschedule, kschedule, NULL }, - { "schedkwhen", S(TRIGINSTR),0, 3,"", "kkkkkz",triginset, ktriginstr, NULL }, - { "schedkwhen.S", S(TRIGINSTR),0, 3,"", "kkkSkz", - triginset_S, ktriginstr_S, NULL }, - { "schedkwhennamed", S(TRIGINSTR),0, 3,"", "kkkkkz",triginset, ktriginstr, NULL }, - { "schedkwhennamed.S", S(TRIGINSTR),0, 3,"", - "kkkSkz",triginset_S, ktriginstr_S, NULL }, - { "trigseq", S(TRIGSEQ),0, 3, "", "kkkkkz", trigseq_set, trigseq, NULL }, - { "event", S(LINEVENT),0, 2, "", "Skz", NULL, eventOpcode, NULL }, - { "event_i", S(LINEVENT),0,1, "", "Sim", eventOpcodeI, NULL, NULL }, - { "event.S", S(LINEVENT),0, 2, "", "SSz", NULL, eventOpcode_S, NULL }, - { "event_i.S", S(LINEVENT),0,1, "", "SSm", eventOpcodeI_S, NULL, NULL }, - { "nstance", S(LINEVENT2),0,2, "k", "kkz", NULL, instanceOpcode, NULL }, - { "nstance.i", S(LINEVENT2),0,1, "i", "iiim", instanceOpcode, NULL, NULL }, - { "nstance.kS", S(LINEVENT2),0, 2, "k", "SSz", NULL, instanceOpcode_S, NULL }, - { "nstance.S", S(LINEVENT2),0, 1, "i", "Siim", instanceOpcode_S, NULL, NULL}, - { "turnoff.i", S(KILLOP),0,1, "", "i", kill_instance, NULL, NULL }, - { "turnoff.k", S(KILLOP),0,2, "", "k", NULL, kill_instance, NULL}, - { "lfo", S(LFO),0, 3, "k", "kko", lfoset, lfok, NULL }, - { "lfo.a", S(LFO),0, 3, "a", "kko", lfoset, lfoa }, - { "oscils", S(OSCILS),0, 3, "a", "iiio", + { "schedwhen", S(WSCHED),0, "", "kkkkm",ifschedule, kschedule, NULL }, + { "schedwhen", S(WSCHED),0, "", "kSkkm",ifschedule, kschedule, NULL }, + { "schedkwhen", S(TRIGINSTR),0, "", "kkkkkz",triginset, ktriginstr, NULL }, + { "schedkwhen.S", S(TRIGINSTR),0, "", "kkkSkz", + triginset_S, ktriginstr_S, NULL }, + { "schedkwhennamed", S(TRIGINSTR),0, "", "kkkkkz",triginset, ktriginstr, NULL }, + { "schedkwhennamed.S", S(TRIGINSTR),0, "", + "kkkSkz",triginset_S, ktriginstr_S, NULL }, + { "trigseq", S(TRIGSEQ),0, "", "kkkkkz", trigseq_set, trigseq, NULL }, + { "event", S(LINEVENT),0, "", "Skz", NULL, eventOpcode, NULL }, + { "event_i", S(LINEVENT),0, "", "Sim", eventOpcodeI, NULL, NULL }, + { "event.S", S(LINEVENT),0, "", "SSz", NULL, eventOpcode_S, NULL }, + { "event_i.S", S(LINEVENT),0, "", "SSm", eventOpcodeI_S, NULL, NULL }, + { "nstance", S(LINEVENT2),0, "k", "kkz", NULL, instanceOpcode, NULL }, + { "nstance.i", S(LINEVENT2),0, "i", "iiim", instanceOpcode, NULL, NULL }, + { "nstance.kS", S(LINEVENT2),0, "k", "SSz", NULL, instanceOpcode_S, NULL }, + { "nstance.S", S(LINEVENT2),0, "i", "Siim", instanceOpcode_S, NULL, NULL}, + { "turnoff.i", S(KILLOP),0, "", "i", kill_instance, NULL, NULL }, + { "turnoff.k", S(KILLOP),0, "", "k", NULL, kill_instance, NULL}, + { "lfo", S(LFO),0, "k", "kko", lfoset, lfok, NULL }, + { "lfo.a", S(LFO),0, "a", "kko", lfoset, lfoa }, + { "oscils", S(OSCILS),0, "a", "iiio", (SUBR)oscils_set, (SUBR)oscils }, - { "lphasor", S(LPHASOR),0,3, "a", "xooooooo" , + { "lphasor", S(LPHASOR),0, "a", "xooooooo" , (SUBR)lphasor_set, (SUBR)lphasor }, - { "tablexkt", S(TABLEXKT),TR, 3, "a", "xkkiooo", (SUBR)tablexkt_set, + { "tablexkt", S(TABLEXKT),TR, "a", "xkkiooo", (SUBR)tablexkt_set, (SUBR)tablexkt }, - { "reverb2", S(NREV2),0, 3, "a", "akkoojoj", + { "reverb2", S(NREV2),0, "a", "akkoojoj", (SUBR)reverbx_set,(SUBR)reverbx }, - { "nreverb", S(NREV2),0, 3, "a", "akkoojoj", + { "nreverb", S(NREV2),0, "a", "akkoojoj", (SUBR)reverbx_set,(SUBR) reverbx }, - { "=.f", S(FASSIGN),0, 3, "f", "f", (SUBR)fassign_set, (SUBR)fassign }, - { "init.f", S(FASSIGN),0, 1, "f", "f", (SUBR)fassign_set, NULL, NULL }, - { "pvsanal", S(PVSANAL), 0, 3, "f", "aiiiioo", pvsanalset, pvsanal }, - { "pvsynth", S(PVSYNTH),0, 3, "a", "fo", pvsynthset, pvsynth }, - { "pvsadsyn", S(PVADS),0, 3, "a", "fikopo", pvadsynset, pvadsyn, NULL }, - { "pvscross", S(PVSCROSS),0,3, "f", "ffkk", pvscrosset, pvscross, NULL }, - { "pvsfread", S(PVSFREAD),0,3, "f", "kSo", pvsfreadset_S, pvsfread, NULL}, - { "pvsfread.i", S(PVSFREAD),0,3, "f", "kio", pvsfreadset, pvsfread, NULL}, - { "pvsmaska", S(PVSMASKA),0,3, "f", "fik", pvsmaskaset, pvsmaska, NULL }, - { "pvsftw", S(PVSFTW), TW, 3, "k", "fio", pvsftwset, pvsftw, NULL }, - { "pvsftr", S(PVSFTR),TR, 3, "", "fio", pvsftrset, pvsftr, NULL }, - { "pvsinfo", S(PVSINFO),0, 1, "iiii","f", pvsinfo, NULL, NULL }, - { "octave.i", S(EVAL),0, 1, "i", "i", powoftwo }, - { "octave.k", S(EVAL),0, 2, "k", "k", NULL, powoftwo }, - { "octave.a", S(EVAL),0, 2, "a", "a", NULL, powoftwoa }, - { "semitone.i",S(EVAL),0, 1, "i", "i", semitone }, - { "semitone.k",S(EVAL),0, 2, "k", "k", NULL, semitone }, - { "semitone.a",S(EVAL),0, 2, "a", "a", NULL, asemitone }, - { "cent.i", S(EVAL),0, 1, "i", "i", cent }, - { "cent.k", S(EVAL),0, 2, "k", "k", NULL, cent }, - { "cent.a", S(EVAL),0, 2, "a", "a", NULL, acent }, - { "db.i", S(EVAL),0, 1, "i", "i", db }, - { "db.k", S(EVAL),0, 2, "k", "k", NULL, db }, - { "db.a", S(EVAL),0, 2, "a", "a", NULL, dba }, - { "midichn", S(MIDICHN),0, 1, "i", "", midichn, NULL, NULL }, - { "pgmassign",S(PGMASSIGN),0, 1, "", "iio", pgmassign, NULL, NULL }, - { "pgmassign.S",S(PGMASSIGN),0, 1, "", "iSo", pgmassign_S, NULL, NULL }, - { "midiin", S(MIDIIN),0, 3, "kkkk", "", midiin_set, midiin, NULL }, - { "pgmchn", S(PGMIN),0, 3, "kk", "o", pgmin_set, pgmin, NULL }, - { "ctlchn", S(CTLIN),0, 3, "kkk", "oo", ctlin_set, ctlin, NULL }, - { "miditempo", S(MIDITEMPO),0, 3, "k", "", + { "=.f", S(FASSIGN),0, "f", "f", (SUBR)fassign_set, (SUBR)fassign }, + { "init.f", S(FASSIGN),0, "f", "f", (SUBR)fassign_set, NULL, NULL }, + { "pvsanal", S(PVSANAL), 0, "f", "aiiiioo", pvsanalset, pvsanal }, + { "pvsynth", S(PVSYNTH),0, "a", "fo", pvsynthset, pvsynth }, + { "pvsadsyn", S(PVADS),0, "a", "fikopo", pvadsynset, pvadsyn, NULL }, + { "pvscross", S(PVSCROSS),0, "f", "ffkk", pvscrosset, pvscross, NULL }, + { "pvsfread", S(PVSFREAD),0, "f", "kSo", pvsfreadset_S, pvsfread, NULL}, + { "pvsfread.i", S(PVSFREAD),0, "f", "kio", pvsfreadset, pvsfread, NULL}, + { "pvsmaska", S(PVSMASKA),0, "f", "fik", pvsmaskaset, pvsmaska, NULL }, + { "pvsftw", S(PVSFTW), TW, "k", "fio", pvsftwset, pvsftw, NULL }, + { "pvsftr", S(PVSFTR),TR, "", "fio", pvsftrset, pvsftr, NULL }, + { "pvsinfo", S(PVSINFO),0, "iiii","f", pvsinfo, NULL, NULL }, + { "octave.i", S(EVAL),0, "i", "i", powoftwo }, + { "octave.k", S(EVAL),0, "k", "k", NULL, powoftwo }, + { "octave.a", S(EVAL),0, "a", "a", NULL, powoftwoa }, + { "semitone.i",S(EVAL),0, "i", "i", semitone }, + { "semitone.k",S(EVAL),0, "k", "k", NULL, semitone }, + { "semitone.a",S(EVAL),0, "a", "a", NULL, asemitone }, + { "cent.i", S(EVAL),0, "i", "i", cent }, + { "cent.k", S(EVAL),0, "k", "k", NULL, cent }, + { "cent.a", S(EVAL),0, "a", "a", NULL, acent }, + { "db.i", S(EVAL),0, "i", "i", db }, + { "db.k", S(EVAL),0, "k", "k", NULL, db }, + { "db.a", S(EVAL),0, "a", "a", NULL, dba }, + { "midichn", S(MIDICHN),0, "i", "", midichn, NULL, NULL }, + { "pgmassign",S(PGMASSIGN),0, "", "iio", pgmassign, NULL, NULL }, + { "pgmassign.S",S(PGMASSIGN),0, "", "iSo", pgmassign_S, NULL, NULL }, + { "midiin", S(MIDIIN),0, "kkkk", "", midiin_set, midiin, NULL }, + { "pgmchn", S(PGMIN),0, "kk", "o", pgmin_set, pgmin, NULL }, + { "ctlchn", S(CTLIN),0, "kkk", "oo", ctlin_set, ctlin, NULL }, + { "miditempo", S(MIDITEMPO),0, "k", "", (SUBR) midiTempoOpcode, (SUBR) midiTempoOpcode, NULL }, - { "midifilestatus", S(MIDITEMPO),0, 2, "k", "", - NULL, (SUBR) midiFileStatus, NULL }, - { "midinoteoff", S(MIDINOTEON),0,3 ,"", "xx", midinoteoff, midinoteoff, }, - { "midinoteonkey", S(MIDINOTEON),0,3, "", "xx", midinoteonkey, midinoteonkey }, - { "midinoteoncps", S(MIDINOTEON),0, 3, "", "xx", midinoteoncps,midinoteoncps }, - { "midinoteonoct", S(MIDINOTEON),0, 3, "", "xx", midinoteonoct,midinoteonoct }, - { "midinoteonpch", S(MIDINOTEON),0, 3, "", "xx", midinoteonpch, midinoteonpch }, + { "midifilestatus", S(MIDITEMPO),0, "k", "", + NULL, (SUBR) midiFileStatus, NULL }, + { "midinoteoff", S(MIDINOTEON),0 ,"", "xx", midinoteoff, midinoteoff, }, + { "midinoteonkey", S(MIDINOTEON),0, "", "xx", midinoteonkey, midinoteonkey }, + { "midinoteoncps", S(MIDINOTEON),0, "", "xx", midinoteoncps,midinoteoncps }, + { "midinoteonoct", S(MIDINOTEON),0, "", "xx", midinoteonoct,midinoteonoct }, + { "midinoteonpch", S(MIDINOTEON),0, "", "xx", midinoteonpch, midinoteonpch }, { "midipolyaftertouch", S(MIDIPOLYAFTERTOUCH),0, - 3, "", "xxoh", midipolyaftertouch, midipolyaftertouch}, + "", "xxoh", midipolyaftertouch, midipolyaftertouch}, { "midicontrolchange", S(MIDICONTROLCHANGE),0, - 3, "", "xxoh",midicontrolchange, midicontrolchange }, + "", "xxoh",midicontrolchange, midicontrolchange }, { "midiprogramchange", S(MIDIPROGRAMCHANGE),0, - 3, "", "x", midiprogramchange, midiprogramchange }, + "", "x", midiprogramchange, midiprogramchange }, { "midichannelaftertouch", S(MIDICHANNELAFTERTOUCH),0, - 3, "", "xoh",midichannelaftertouch, midichannelaftertouch }, - { "midipitchbend", S(MIDIPITCHBEND),0,3, "", "xoh", + "", "xoh",midichannelaftertouch, midichannelaftertouch }, + { "midipitchbend", S(MIDIPITCHBEND),0, "", "xoh", midipitchbend, midipitchbend }, - { "mididefault", S(MIDIDEFAULT),0, 3, "", "xx", mididefault, mididefault }, + { "mididefault", S(MIDIDEFAULT),0, "", "xx", mididefault, mididefault }, //{ "invalue", 0xFFFF, _CR, 0, NULL, NULL, NULL, NULL }, - { "invalue.k", S(INVAL),_CR, 3, "k", "i", (SUBR) invalset,(SUBR)kinval, NULL }, - { "invalue.i", S(INVAL),_CR, 1, "i", "i", (SUBR) invalsetgo, NULL, NULL }, - { "invalue.iS", S(INVAL),_CR, 1, "i", "S", (SUBR) invalsetSgo, NULL, NULL }, - { "invalue.kS", S(INVAL),_CR, 3, "k", "S",(SUBR) invalset_S,(SUBR)kinval, NULL }, - { "invalue.S", S(INVAL),_CR, 3, "S", "i", - (SUBR) invalset_string, (SUBR)kinvalS, NULL }, - { "invalue.SS", S(INVAL),_CR, 3, "S", "S", - (SUBR) invalset_string_S, (SUBR)kinvalS, NULL }, - { "outvalue", S(OUTVAL), _CW, 3, "", "ik", (SUBR) outvalset, (SUBR)koutval, NULL}, - { "outvalue.i", S(OUTVAL), _CW, 1, "", "ii", (SUBR) outvalsetgo, NULL, NULL}, - { "outvalue.Si", S(OUTVAL), _CW, 1, "", "Si", - (SUBR) outvalsetSgo, NULL, NULL}, - { "outvalue.k", S(OUTVAL), _CW, 3, "", "Sk", - (SUBR) outvalset_S, (SUBR)koutval, NULL}, - { "outvalue.S", S(OUTVAL), _CW, 3, "", "iS", - (SUBR) outvalset_string, (SUBR)koutvalS, NULL}, - { "outvalue.SS", S(OUTVAL), _CW, 3, "", "SS", - (SUBR) outvalset_string_S, (SUBR)koutvalS, NULL}, + { "invalue.k", S(INVAL),_CR, "k", "i", (SUBR) invalset,(SUBR)kinval, NULL }, + { "invalue.i", S(INVAL),_CR, "i", "i", (SUBR) invalsetgo, NULL, NULL }, + { "invalue.iS", S(INVAL),_CR, "i", "S", (SUBR) invalsetSgo, NULL, NULL }, + { "invalue.kS", S(INVAL),_CR, "k", "S",(SUBR) invalset_S,(SUBR)kinval, NULL }, + { "invalue.S", S(INVAL),_CR, "S", "i", + (SUBR) invalset_string, (SUBR)kinvalS, NULL }, + { "invalue.SS", S(INVAL),_CR, "S", "S", + (SUBR) invalset_string_S, (SUBR)kinvalS, NULL }, + { "outvalue", S(OUTVAL), _CW, "", "ik", (SUBR) outvalset, (SUBR)koutval, NULL}, + { "outvalue.i", S(OUTVAL), _CW, "", "ii", (SUBR) outvalsetgo, NULL, NULL}, + { "outvalue.Si", S(OUTVAL), _CW, "", "Si", + (SUBR) outvalsetSgo, NULL, NULL}, + { "outvalue.k", S(OUTVAL), _CW, "", "Sk", + (SUBR) outvalset_S, (SUBR)koutval, NULL}, + { "outvalue.S", S(OUTVAL), _CW, "", "iS", + (SUBR) outvalset_string, (SUBR)koutvalS, NULL}, + { "outvalue.SS", S(OUTVAL), _CW, "", "SS", + (SUBR) outvalset_string_S, (SUBR)koutvalS, NULL}, /* IV - Oct 20 2002 */ - { "subinstr", S(SUBINST),0, 3, "mmmmmmmm", "SN", subinstrset_S, subinstr }, - { "subinstrinit", S(SUBINST),0, 1, "", "SN", subinstrset_S, NULL, NULL }, - { "subinstr.i", S(SUBINST),0, 3, "mmmmmmmm", "iN", subinstrset, subinstr }, - { "subinstrinit.i", S(SUBINST),0, 1, "", "iN", subinstrset, NULL, NULL }, - { "nstrnum", S(NSTRNUM),0, 1, "i", "S", nstrnumset_S, NULL, NULL }, - { "nstrnum.i", S(NSTRNUM),0, 1, "i", "i", nstrnumset, NULL, NULL }, - { "nstrstr", S(NSTRSTR),0, 1, "S", "i", nstrstr, NULL, NULL }, - { "nstrstr.k", S(NSTRSTR),0, 2, "S", "k", NULL, nstrstr, NULL }, + { "subinstr", S(SUBINST),0, "mmmmmmmm", "SN", subinstrset_S, subinstr }, + { "subinstrinit", S(SUBINST),0, "", "SN", subinstrset_S, NULL, NULL }, + { "subinstr.i", S(SUBINST),0, "mmmmmmmm", "iN", subinstrset, subinstr }, + { "subinstrinit.i", S(SUBINST),0, "", "iN", subinstrset, NULL, NULL }, + { "nstrnum", S(NSTRNUM),0, "i", "S", nstrnumset_S, NULL, NULL }, + { "nstrnum.i", S(NSTRNUM),0, "i", "i", nstrnumset, NULL, NULL }, + { "nstrstr", S(NSTRSTR),0, "S", "i", nstrstr, NULL, NULL }, + { "nstrstr.k", S(NSTRSTR),0, "S", "k", NULL, nstrstr, NULL }, //{ "turnoff2", 0xFFFB, _CW, 0, NULL, NULL, NULL, NULL, NULL }, - { "turnoff2_i.S",S(TURNOFF2),_CW,1, "", "Soo", turnoff2S, NULL }, - { "turnoff2_i.i",S(TURNOFF2),_CW,1, "", "ioo", turnoff2k, NULL }, - { "turnoff2.S",S(TURNOFF2),_CW,2, "", "Skk", NULL, turnoff2S, NULL }, - { "turnoff2.c",S(TURNOFF2),_CW,2, "", "ikk", NULL, turnoff2k, NULL }, - { "turnoff2.k",S(TURNOFF2),_CW,2, "", "kkk", NULL, turnoff2k, NULL }, - { "turnoff2.i",S(TURNOFF2),_CW,2, "", "ikk", NULL, turnoff2k, NULL }, - { "turnoff2.r",S(TURNOFF2),_CW,2, "", "ikk", NULL, turnoff2k, NULL }, - { "turnoff3.S",S(TURNOFF2),_CW,2, "", "S", NULL, turnoff3S, NULL }, - { "turnoff3.c",S(TURNOFF2),_CW,2, "", "i", NULL, turnoff3k, NULL }, - { "turnoff3.k",S(TURNOFF2),_CW,2, "", "k", NULL, turnoff3k, NULL }, - { "turnoff3.i",S(TURNOFF2),_CW,2, "", "i", NULL, turnoff3k, NULL }, - { "turnoff3.r",S(TURNOFF2),_CW,2, "", "i", NULL, turnoff3k, NULL }, - { "cngoto", S(CGOTO),0, 3, "", "Bl", ingoto, kngoto, NULL }, - { "cnkgoto", S(CGOTO),0, 2, "", "Bl", NULL, kngoto, NULL }, - { "cingoto", S(CGOTO),0, 1, "", "Bl", ingoto, NULL, NULL }, - { "tempoval", S(GTEMPO),0, 2, "k", "", NULL, (SUBR)gettempo, NULL }, - { "downsamp",S(DOWNSAMP),0,3, "k", "ao", (SUBR)downset,(SUBR)downsamp }, - { "upsamp", S(UPSAMP),0, 2, "a", "k", NULL, (SUBR)upsamp }, + { "turnoff2_i.S",S(TURNOFF2),_CW, "", "Soo", turnoff2S, NULL }, + { "turnoff2_i.i",S(TURNOFF2),_CW, "", "ioo", turnoff2k, NULL }, + { "turnoff2.S",S(TURNOFF2),_CW, "", "Skk", NULL, turnoff2S, NULL }, + { "turnoff2.c",S(TURNOFF2),_CW, "", "ikk", NULL, turnoff2k, NULL }, + { "turnoff2.k",S(TURNOFF2),_CW, "", "kkk", NULL, turnoff2k, NULL }, + { "turnoff2.i",S(TURNOFF2),_CW, "", "ikk", NULL, turnoff2k, NULL }, + { "turnoff2.r",S(TURNOFF2),_CW, "", "ikk", NULL, turnoff2k, NULL }, + { "turnoff3.S",S(TURNOFF2),_CW, "", "S", NULL, turnoff3S, NULL }, + { "turnoff3.c",S(TURNOFF2),_CW, "", "i", NULL, turnoff3k, NULL }, + { "turnoff3.k",S(TURNOFF2),_CW, "", "k", NULL, turnoff3k, NULL }, + { "turnoff3.i",S(TURNOFF2),_CW, "", "i", NULL, turnoff3k, NULL }, + { "turnoff3.r",S(TURNOFF2),_CW, "", "i", NULL, turnoff3k, NULL }, + { "cngoto", S(CGOTO),0, "", "Bl", ingoto, kngoto, NULL }, + { "cnkgoto", S(CGOTO),0, "", "Bl", NULL, kngoto, NULL }, + { "cingoto", S(CGOTO),0, "", "Bl", ingoto, NULL, NULL }, + { "tempoval", S(GTEMPO),0, "k", "", NULL, (SUBR)gettempo, NULL }, + { "downsamp",S(DOWNSAMP),0, "k", "ao", (SUBR)downset,(SUBR)downsamp }, + { "upsamp", S(UPSAMP),0, "a", "k", NULL, (SUBR)upsamp }, /* IV - Sep 5 2002 */ - { "interp", S(INTERP),0, 3, "a", "kooo", (SUBR)interpset, (SUBR)interp }, - { "a.k", S(INTERP),0, 3, "a", "k", (SUBR)a_k_set, (SUBR)interp }, - { "integ", S(INDIFF), 0, 3, "a", "xo", + { "interp", S(INTERP),0, "a", "kooo", (SUBR)interpset, (SUBR)interp }, + { "a.k", S(INTERP),0, "a", "k", (SUBR)a_k_set, (SUBR)interp }, + { "integ", S(INDIFF), 0, "a", "xo", (SUBR)indfset,(SUBR)integrate}, - { "integ.k", S(INDIFF), 0, 3, "k", "xo", + { "integ.k", S(INDIFF), 0, "k", "xo", (SUBR)indfset,(SUBR)kntegrate, NULL}, - { "diff", S(INDIFF),0, 3, "a", "xo", (SUBR)indfset, (SUBR)diff }, - { "diff.k", S(INDIFF),0, 3, "k", "xo", (SUBR)indfset,(SUBR)kdiff, NULL }, - { "samphold",S(SAMPHOLD),0,3, "a", "xxoo", + { "diff", S(INDIFF),0, "a", "xo", (SUBR)indfset, (SUBR)diff }, + { "diff.k", S(INDIFF),0, "k", "xo", (SUBR)indfset,(SUBR)kdiff, NULL }, + { "samphold",S(SAMPHOLD),0, "a", "xxoo", (SUBR)samphset,(SUBR)samphold }, - { "samphold.k",S(SAMPHOLD),0,3, "k", "xxoo", + { "samphold.k",S(SAMPHOLD),0, "k", "xxoo", (SUBR)samphset,(SUBR)ksmphold,NULL }, - { "delay", S(DELAY),0, 3, "a", "aio", (SUBR)delset, (SUBR)delay }, - { "delayr", S(DELAYR),0, 3, "aX","io", (SUBR)delrset, (SUBR)delayr }, - { "delayw", S(DELAYW),0, 3, "", "a", (SUBR)delwset, (SUBR)delayw }, - { "delay1", S(DELAY1),0, 3, "a", "ao", (SUBR)del1set, (SUBR)delay1 }, - { "deltap", S(DELTAP),0, 3, "a", "ko", (SUBR)tapset, (SUBR)deltap }, - { "deltapi",S(DELTAP),0, 3, "a", "xo", (SUBR)tapset, (SUBR)deltapi }, - { "deltapn",S(DELTAP),0, 3, "a", "xo", (SUBR)tapset, (SUBR)deltapn }, - { "deltap3",S(DELTAP),0, 3, "a", "xo", (SUBR)tapset, (SUBR)deltap3 }, - { "reverb", S(REVERB),0, 3, "a", "ako", (SUBR)rvbset, (SUBR)reverb }, - { "vdelay", S(VDEL),0, 3, "a", "axio", (SUBR)vdelset, (SUBR)vdelay }, - { "vdelay3", S(VDEL),0, 3, "a", "axio", (SUBR)vdelset, (SUBR)vdelay3 }, - { "vdelayxwq",S(VDELXQ),0,3, "aaaa", "aaaaaiio", + { "delay", S(DELAY),0, "a", "aio", (SUBR)delset, (SUBR)delay }, + { "delayr", S(DELAYR),0, "aX","io", (SUBR)delrset, (SUBR)delayr }, + { "delayw", S(DELAYW),0, "", "a", (SUBR)delwset, (SUBR)delayw }, + { "delay1", S(DELAY1),0, "a", "ao", (SUBR)del1set, (SUBR)delay1 }, + { "deltap", S(DELTAP),0, "a", "ko", (SUBR)tapset, (SUBR)deltap }, + { "deltapi",S(DELTAP),0, "a", "xo", (SUBR)tapset, (SUBR)deltapi }, + { "deltapn",S(DELTAP),0, "a", "xo", (SUBR)tapset, (SUBR)deltapn }, + { "deltap3",S(DELTAP),0, "a", "xo", (SUBR)tapset, (SUBR)deltap3 }, + { "reverb", S(REVERB),0, "a", "ako", (SUBR)rvbset, (SUBR)reverb }, + { "vdelay", S(VDEL),0, "a", "axio", (SUBR)vdelset, (SUBR)vdelay }, + { "vdelay3", S(VDEL),0, "a", "axio", (SUBR)vdelset, (SUBR)vdelay3 }, + { "vdelayxwq",S(VDELXQ),0, "aaaa", "aaaaaiio", (SUBR)vdelxqset, (SUBR)vdelayxwq}, - { "vdelayxws",S(VDELXS),0,3, "aa", "aaaiio", (SUBR)vdelxsset, + { "vdelayxws",S(VDELXS),0, "aa", "aaaiio", (SUBR)vdelxsset, (SUBR)vdelayxws }, - { "vdelayxw", S(VDELX),0, 3, "a", "aaiio", + { "vdelayxw", S(VDELX),0, "a", "aaiio", (SUBR)vdelxset, (SUBR)vdelayxw}, - { "vdelayxq", S(VDELXQ),0,3, "aaaa", "aaaaaiio", + { "vdelayxq", S(VDELXQ),0, "aaaa", "aaaaaiio", (SUBR)vdelxqset, (SUBR)vdelayxq}, - { "vdelayxs", S(VDELXS),0,3, "aa", "aaaiio", + { "vdelayxs", S(VDELXS),0, "aa", "aaaiio", (SUBR)vdelxsset, (SUBR)vdelayxs}, - { "vdelayx", S(VDELX),0, 3, "a", "aaiio", (SUBR)vdelxset, (SUBR)vdelayx}, - { "deltapx", S(DELTAPX),0,3, "a", "aio", (SUBR)tapxset, (SUBR)deltapx }, - { "deltapxw", S(DELTAPX),0,3, "", "aaio", (SUBR)tapxset, (SUBR)deltapxw }, - { "multitap", S(MDEL),0, 3, "a", "am", + { "vdelayx", S(VDELX),0, "a", "aaiio", (SUBR)vdelxset, (SUBR)vdelayx}, + { "deltapx", S(DELTAPX),0, "a", "aio", (SUBR)tapxset, (SUBR)deltapx }, + { "deltapxw", S(DELTAPX),0, "", "aaio", (SUBR)tapxset, (SUBR)deltapxw }, + { "multitap", S(MDEL),0, "a", "am", (SUBR)multitap_set,(SUBR)multitap_play}, - { "comb", S(COMB),0, 3, "a", "akioo", (SUBR)cmbset, (SUBR)comb }, - { "combinv",S(COMB),0, 3, "a", "akioo", (SUBR)cmbset, (SUBR)invcomb }, - { "alpass", S(COMB),0, 3, "a", "axioo", (SUBR)cmbset, (SUBR)alpass }, - { "strset", S(STRSET_OP),0, 1, "", "iS", - (SUBR) strset_init, NULL, NULL }, - { "strget", S(STRGET_OP),0, 1, "S", "i", - (SUBR) strget_init, NULL, NULL }, - { "S", S(STRGET_OP),0, 1, "S", "i", + { "comb", S(COMB),0, "a", "akioo", (SUBR)cmbset, (SUBR)comb }, + { "combinv",S(COMB),0, "a", "akioo", (SUBR)cmbset, (SUBR)invcomb }, + { "alpass", S(COMB),0, "a", "axioo", (SUBR)cmbset, (SUBR)alpass }, + { "strset", S(STRSET_OP),0, "", "iS", + (SUBR) strset_init, NULL, NULL }, + { "strget", S(STRGET_OP),0, "S", "i", + (SUBR) strget_init, NULL, NULL }, + { "S", S(STRGET_OP),0, "S", "i", (SUBR) s_opcode, NULL, NULL }, - { "S", S(STRGET_OP),0, 3, "S", "k", + { "S", S(STRGET_OP),0, "S", "k", (SUBR) s_opcode,(SUBR) s_opcode_k, NULL }, - { "strcpy", S(STRCPY_OP),0, 1, "S", "S", + { "strcpy", S(STRCPY_OP),0, "S", "S", (SUBR) strcpy_opcode_S, NULL, NULL }, - { "strcpy", S(STRGET_OP),0, 1, "S", "i", + { "strcpy", S(STRGET_OP),0, "S", "i", (SUBR) strcpy_opcode_p, NULL, NULL }, - { "strcpyk", S(STRCPY_OP),0, 3, "S", "S", + { "strcpyk", S(STRCPY_OP),0, "S", "S", (SUBR) strcpy_opcode_S, (SUBR) strcpy_opcode_S, NULL }, - { "strcpyk.k", S(STRGET_OP),0, 3, "S", "k", + { "strcpyk.k", S(STRGET_OP),0, "S", "k", (SUBR) strcpy_opcode_p, (SUBR) strcpy_opcode_p, NULL }, - { "strcat", S(STRCAT_OP),0, 1, "S", "SS", + { "strcat", S(STRCAT_OP),0, "S", "SS", (SUBR) strcat_opcode, NULL, NULL }, - { "strcatk", S(STRCAT_OP),0, 3, "S", "SS", + { "strcatk", S(STRCAT_OP),0, "S", "SS", (SUBR) strcat_opcode, (SUBR) strcat_opcode, NULL }, - { "strcmp", S(STRCMP_OP),0, 1, "i", "SS", + { "strcmp", S(STRCMP_OP),0, "i", "SS", (SUBR) strcmp_opcode, NULL, NULL }, - { "strcmpk", S(STRCMP_OP),0, 3, "k", "SS", + { "strcmpk", S(STRCMP_OP),0, "k", "SS", (SUBR) strcmp_opcode, (SUBR) strcmp_opcode, NULL }, - { "sprintf", S(SPRINTF_OP),0, 1, "S", "STN", + { "sprintf", S(SPRINTF_OP),0, "S", "STN", (SUBR) sprintf_opcode, NULL, NULL }, - { "sprintfk", S(SPRINTF_OP),WR, 3, "S", "SUN", + { "sprintfk", S(SPRINTF_OP),WR, "S", "SUN", (SUBR) sprintf_opcode, (SUBR) sprintf_opcode, NULL }, - { "printf_i", S(PRINTF_OP),0, 1, "", "SiN", /* SiTN */ + { "printf_i", S(PRINTF_OP),0, "", "SiN", /* SiTN */ (SUBR) printf_opcode_init, NULL, NULL }, - { "printf", S(PRINTF_OP),WR, 3, "", "SkN", /* SkUN */ + { "printf", S(PRINTF_OP),WR, "", "SkN", /* SkUN */ (SUBR) printf_opcode_set, (SUBR) printf_opcode_perf, NULL }, - { "puts", S(PUTS_OP),WR, 3, "", "Sko", + { "puts", S(PUTS_OP),WR, "", "Sko", (SUBR) puts_opcode_init, (SUBR) puts_opcode_perf, NULL }, - { "strtod", S(STRSET_OP),0, 1, "i", "S", + { "strtod", S(STRSET_OP),0, "i", "S", (SUBR) strtod_opcode_S, NULL, NULL }, - { "strtod", S(STRTOD_OP),0, 1, "i", "i", + { "strtod", S(STRTOD_OP),0, "i", "i", (SUBR) strtod_opcode_p, NULL, NULL }, - { "strtodk", S(STRSET_OP),0, 3, "k", "S", + { "strtodk", S(STRSET_OP),0, "k", "S", (SUBR) strtod_opcode_S, (SUBR) strtod_opcode_S, NULL }, - { "strtol", S(STRSET_OP),0, 1, "i", "S", + { "strtol", S(STRSET_OP),0, "i", "S", (SUBR) strtol_opcode_S, NULL, NULL }, - { "strtol", S(STRTOD_OP),0, 1, "i", "i", + { "strtol", S(STRTOD_OP),0, "i", "i", (SUBR) strtol_opcode_p, NULL, NULL }, - { "strtolk", S(STRSET_OP),0, 3, "k", "S", + { "strtolk", S(STRSET_OP),0, "k", "S", (SUBR) strtol_opcode_S, (SUBR) strtol_opcode_S, NULL }, - { "strsub", S(STRSUB_OP),0, 1, "S", "Soj", + { "strsub", S(STRSUB_OP),0, "S", "Soj", (SUBR) strsub_opcode, NULL, NULL }, - { "strsubk", S(STRSUB_OP),0, 3, "S", "Skk", + { "strsubk", S(STRSUB_OP),0, "S", "Skk", (SUBR) strsub_opcode, (SUBR) strsub_opcode, NULL }, - { "strchar", S(STRCHAR_OP),0, 1, "i", "So", + { "strchar", S(STRCHAR_OP),0, "i", "So", (SUBR) strchar_opcode, NULL, NULL }, - { "strchark", S(STRCHAR_OP),0, 3, "k", "SO", + { "strchark", S(STRCHAR_OP),0, "k", "SO", (SUBR) strchar_opcode, (SUBR) strchar_opcode, NULL }, - { "strlen", S(STRLEN_OP),0, 1, "i", "S", + { "strlen", S(STRLEN_OP),0, "i", "S", (SUBR) strlen_opcode, NULL, NULL }, - { "strlenk", S(STRLEN_OP),0, 3, "k", "S", + { "strlenk", S(STRLEN_OP),0, "k", "S", (SUBR) strlen_opcode, (SUBR) strlen_opcode, NULL }, - { "strupper", S(STRUPPER_OP),0, 1, "S", "S", + { "strupper", S(STRUPPER_OP),0, "S", "S", (SUBR) strupper_opcode, NULL, NULL }, - { "strupperk", S(STRUPPER_OP),0, 3, "S", "S", + { "strupperk", S(STRUPPER_OP),0, "S", "S", (SUBR) strupper_opcode, (SUBR) strupper_opcode, NULL }, - { "strlower", S(STRUPPER_OP),0, 1, "S", "S", + { "strlower", S(STRUPPER_OP),0, "S", "S", (SUBR) strlower_opcode, NULL, NULL }, - { "strlowerk", S(STRUPPER_OP),0, 3, "S", "S", + { "strlowerk", S(STRUPPER_OP),0, "S", "S", (SUBR) strlower_opcode, (SUBR) strlower_opcode, NULL }, - { "getcfg", S(GETCFG_OP),0, 1, "S", "i", + { "getcfg", S(GETCFG_OP),0, "S", "i", (SUBR) getcfg_opcode, NULL, NULL }, - { "strindex", S(STRINDEX_OP),0, 1, "i", "SS", + { "strindex", S(STRINDEX_OP),0, "i", "SS", (SUBR) strindex_opcode, NULL, NULL }, - { "strindexk", S(STRINDEX_OP),0, 3, "k", "SS", + { "strindexk", S(STRINDEX_OP),0, "k", "SS", (SUBR) strindex_opcode, (SUBR) strindex_opcode, NULL }, - { "strrindex", S(STRINDEX_OP),0, 1, "i", "SS", + { "strrindex", S(STRINDEX_OP),0, "i", "SS", (SUBR) strrindex_opcode, NULL, NULL }, - { "strrindexk", S(STRINDEX_OP),0, 3, "k", "SS", + { "strrindexk", S(STRINDEX_OP),0, "k", "SS", (SUBR) strrindex_opcode, (SUBR) strrindex_opcode, NULL }, - { "print_type", S(PRINT_TYPE_OP),0, 1, "", ".", + { "print_type", S(PRINT_TYPE_OP),0, "", ".", (SUBR) print_type_opcode, NULL, NULL }, #ifdef HAVE_CURL - { "strfromurl", S(STRCPY_OP), 0, 1, "S", "S", (SUBR) str_from_url }, + { "strfromurl", S(STRCPY_OP), 0, "S", "S", (SUBR) str_from_url }, #endif - { "changed.S", S(STRCHGD),0, 3, "k", "S", + { "changed.S", S(STRCHGD),0, "k", "S", (SUBR) str_changed, (SUBR) str_changed_k, NULL }, - { "changed2.S", S(STRCHGD),0, 3, "k", "S", + { "changed2.S", S(STRCHGD),0, "k", "S", (SUBR) str_changed, (SUBR) str_changed_k, NULL }, - { "loop_lt.i", S(LOOP_OPS),0, 1, "", "iiil", (SUBR) loop_l_i, NULL, NULL }, - { "loop_le.i", S(LOOP_OPS),0, 1, "", "iiil", (SUBR) loop_le_i, NULL, NULL }, - { "loop_gt.i", S(LOOP_OPS),0, 1, "", "iiil", (SUBR) loop_g_i, NULL, NULL }, - { "loop_ge.i", S(LOOP_OPS),0, 1, "", "iiil", (SUBR) loop_ge_i, NULL, NULL }, - { "loop_lt.k", S(LOOP_OPS),0, 2, "", "kkkl", NULL, (SUBR) loop_l_p, NULL }, - { "loop_le.k", S(LOOP_OPS),0, 2, "", "kkkl", NULL, (SUBR) loop_le_p, NULL }, - { "loop_gt.k", S(LOOP_OPS),0, 2, "", "kkkl", NULL, (SUBR) loop_g_p, NULL }, - { "loop_ge.k", S(LOOP_OPS),0, 2, "", "kkkl", NULL, (SUBR) loop_ge_p, NULL }, + { "loop_lt.i", S(LOOP_OPS),0, "", "iiil", (SUBR) loop_l_i, NULL, NULL }, + { "loop_le.i", S(LOOP_OPS),0, "", "iiil", (SUBR) loop_le_i, NULL, NULL }, + { "loop_gt.i", S(LOOP_OPS),0, "", "iiil", (SUBR) loop_g_i, NULL, NULL }, + { "loop_ge.i", S(LOOP_OPS),0, "", "iiil", (SUBR) loop_ge_i, NULL, NULL }, + { "loop_lt.k", S(LOOP_OPS),0, "", "kkkl", NULL, (SUBR) loop_l_p, NULL }, + { "loop_le.k", S(LOOP_OPS),0, "", "kkkl", NULL, (SUBR) loop_le_p, NULL }, + { "loop_gt.k", S(LOOP_OPS),0, "", "kkkl", NULL, (SUBR) loop_g_p, NULL }, + { "loop_ge.k", S(LOOP_OPS),0, "", "kkkl", NULL, (SUBR) loop_ge_p, NULL }, { "chnget", 0xFFFF, _CR }, - { "chnget.i", S(CHNGET),_CR, 1, "i", "S", + { "chnget.i", S(CHNGET),_CR, "i", "S", (SUBR) chnget_opcode_init_i, NULL, NULL }, - { "chnget.k", S(CHNGET),_CR, 3, "k", "S", + { "chnget.k", S(CHNGET),_CR, "k", "S", (SUBR) chnget_opcode_init_k, (SUBR) notinit_opcode_stub, NULL }, - { "chngeti.i", S(CHNGET),_CR, 1, "i[]", "S[]", + { "chngeti.i", S(CHNGET),_CR, "i[]", "S[]", (SUBR) chnget_array_opcode_init_i, NULL, NULL }, - { "chngeta.a", S(CHNGET),_CR, 3, "a[]", "S[]", + { "chngeta.a", S(CHNGET),_CR, "a[]", "S[]", (SUBR) chnget_array_opcode_init, (SUBR) notinit_opcode_stub, NULL }, - { "chngets.s", S(CHNGET),_CR, 3, "S[]", "S[]", + { "chngets.s", S(CHNGET),_CR, "S[]", "S[]", (SUBR) chnget_array_opcode_init, (SUBR) notinit_opcode_stub, NULL }, - { "chngetk.k", S(CHNGET),_CR, 3, "k[]", "S[]", + { "chngetk.k", S(CHNGET),_CR, "k[]", "S[]", (SUBR) chnget_array_opcode_init, (SUBR) notinit_opcode_stub, NULL }, - { "chnget.a", S(CHNGET),_CR, 3, "a", "S", + { "chnget.a", S(CHNGET),_CR, "a", "S", (SUBR) chnget_opcode_init_a, (SUBR) notinit_opcode_stub }, - { "chnget.S", S(CHNGET),_CR, 3, "S", "S", + { "chnget.S", S(CHNGET),_CR, "S", "S", (SUBR) chnget_opcode_init_S, (SUBR) chnget_opcode_perf_S, NULL}, - { "chngetks", S(CHNGET),_CR, 2, "S", "S", + { "chngetks", S(CHNGET),_CR, "S", "S", NULL, (SUBR) chnget_opcode_perf_S, NULL}, //{ "chnset", 0xFFFB, _CW }, - { "chnseti.i", S(CHNGET),_CW, 1, "", "i[]S[]", + { "chnseti.i", S(CHNGET),_CW, "", "i[]S[]", (SUBR) chnset_array_opcode_init_i, NULL, NULL }, - { "chnsetk.k", S(CHNGET),_CW, 3, "", "k[]S[]", + { "chnsetk.k", S(CHNGET),_CW, "", "k[]S[]", (SUBR) chnset_array_opcode_init, (SUBR) notinit_opcode_stub, NULL }, - { "chnseta.a", S(CHNGET),_CW, 3, "", "a[]S[]", + { "chnseta.a", S(CHNGET),_CW, "", "a[]S[]", (SUBR) chnset_array_opcode_init, (SUBR) notinit_opcode_stub, NULL }, - { "chnsets.s", S(CHNGET),_CW, 3, "", "S[]S[]", + { "chnsets.s", S(CHNGET),_CW, "", "S[]S[]", (SUBR) chnset_array_opcode_init, (SUBR) notinit_opcode_stub, NULL }, - { "chnset.i", S(CHNGET),_CW, 1, "", "iS", + { "chnset.i", S(CHNGET),_CW, "", "iS", (SUBR) chnset_opcode_init_i, NULL, NULL }, - // { "chnset.r", S(CHNGET),0, 1, "", "iS", + // { "chnset.r", S(CHNGET),0, "", "iS", // (SUBR) chnset_opcode_init_i, NULL, NULL }, - // { "chnset.c", S(CHNGET),0, 1, "", "iS", + // { "chnset.c", S(CHNGET),0, "", "iS", // (SUBR) chnset_opcode_init_i, NULL, NULL }, - { "chnset.k", S(CHNGET),_CW, 3, "", "kS", + { "chnset.k", S(CHNGET),_CW, "", "kS", (SUBR) chnset_opcode_init_k, (SUBR) notinit_opcode_stub, NULL }, - { "chnset.a", S(CHNGET),_CW, 3, "", "aS", + { "chnset.a", S(CHNGET),_CW, "", "aS", (SUBR) chnset_opcode_init_a, (SUBR) notinit_opcode_stub }, - { "chnset.S", S(CHNGET),_CW, 3, "", "SS", + { "chnset.S", S(CHNGET),_CW, "", "SS", (SUBR) chnset_opcode_init_S, (SUBR) chnset_opcode_perf_S, NULL }, - { "chnsetks", S(CHNGET),_CW, 2, "", "SS", + { "chnsetks", S(CHNGET),_CW, "", "SS", NULL, (SUBR) chnset_opcode_perf_S, NULL }, - { "chnmix", S(CHNGET), _CB, 3, "", "aS", + { "chnmix", S(CHNGET), _CB, "", "aS", (SUBR) chnmix_opcode_init, (SUBR) notinit_opcode_stub }, - { "chnclear", S(CHNCLEAR), _CW, 3, "", "W", + { "chnclear", S(CHNCLEAR), _CW, "", "W", (SUBR) chnclear_opcode_init, (SUBR) notinit_opcode_stub }, - { "chn_k", S(CHN_OPCODE_K), _CW, 1, "", "SiooooooooN", + { "chn_k", S(CHN_OPCODE_K), _CW, "", "SiooooooooN", (SUBR) chn_k_opcode_init, NULL, NULL }, - { "chn_k", S(CHN_OPCODE_K), _CW, 1, "", "SSooooooooN", + { "chn_k", S(CHN_OPCODE_K), _CW, "", "SSooooooooN", (SUBR) chn_k_opcode_init_S, NULL, NULL}, - { "chn_a", S(CHN_OPCODE), _CW, 1, "", "Si", + { "chn_a", S(CHN_OPCODE), _CW, "", "Si", (SUBR) chn_a_opcode_init, NULL, NULL }, - { "chn_S", S(CHN_OPCODE), _CW, 1, "", "Si", + { "chn_S", S(CHN_OPCODE), _CW, "", "Si", (SUBR) chn_S_opcode_init, NULL, NULL }, //{ "chnexport", 0xFFFF, 0, 0, NULL, NULL, NULL, NULL }, - { "chnexport.i", S(CHNEXPORT_OPCODE),0, 1, "i", "Sioooo", + { "chnexport.i", S(CHNEXPORT_OPCODE),0, "i", "Sioooo", (SUBR) chnexport_opcode_init, NULL, NULL }, - { "chnexport.k", S(CHNEXPORT_OPCODE),0, 1, "k", "Sioooo", + { "chnexport.k", S(CHNEXPORT_OPCODE),0, "k", "Sioooo", (SUBR) chnexport_opcode_init, NULL, NULL }, - { "chnexport.a", S(CHNEXPORT_OPCODE),0, 1, "a", "Si", + { "chnexport.a", S(CHNEXPORT_OPCODE),0, "a", "Si", (SUBR) chnexport_opcode_init, NULL, NULL }, - { "chnexport.S", S(CHNEXPORT_OPCODE),0, 1, "S", "Si", + { "chnexport.S", S(CHNEXPORT_OPCODE),0, "S", "Si", (SUBR) chnexport_opcode_init, NULL, NULL }, - { "chnparams", S(CHNPARAMS_OPCODE),_CR, 1, "iiiiii", "S", + { "chnparams", S(CHNPARAMS_OPCODE),_CR, "iiiiii", "S", (SUBR) chnparams_opcode_init, NULL, NULL }, /* these opcodes have never been fully implemented - { "chnrecv", S(CHNSEND), _CR, 3, "", "So", + { "chnrecv", S(CHNSEND), _CR, "", "So", (SUBR) chnrecv_opcode_init, (SUBR) notinit_opcode_stub, NULL }, - { "chnsend", S(CHNSEND),0, 3, "", "So", + { "chnsend", S(CHNSEND),0, "", "So", (SUBR) chnsend_opcode_init, (SUBR) notinit_opcode_stub, NULL }, */ //{ "chano", 0xFFFD, _CW, 0, NULL, NULL, NULL, NULL }, - { "chano.k", S(ASSIGN),_CW, 2, "", "kk", + { "chano.k", S(ASSIGN),_CW, "", "kk", NULL, (SUBR) chano_opcode_perf_k, NULL }, - { "chano.a", S(ASSIGN),_CW, 2, "", "ak", + { "chano.a", S(ASSIGN),_CW, "", "ak", NULL, (SUBR) chano_opcode_perf_a }, - { "pvsout", S(FCHAN),0, 3, "", "fk", + { "pvsout", S(FCHAN),0, "", "fk", (SUBR) pvsout_init, (SUBR) pvsout_perf, NULL }, //{ "chani", 0xFFFF, _CR, 0, NULL, NULL, NULL, NULL }, - { "chani.k", S(ASSIGN),_CR, 2, "k", "k", + { "chani.k", S(ASSIGN),_CR, "k", "k", NULL, (SUBR) chani_opcode_perf_k, NULL }, - { "chani.a", S(ASSIGN),_CR, 2, "a", "k", + { "chani.a", S(ASSIGN),_CR, "a", "k", NULL, (SUBR) chani_opcode_perf_a }, - { "pvsin", S(FCHAN),0, 3, "f", "kooopo", + { "pvsin", S(FCHAN),0, "f", "kooopo", (SUBR) pvsin_init, (SUBR) pvsin_perf, NULL }, - { "sense", S(KSENSE),0, 2, "kz", "", + { "sense", S(KSENSE),0, "kz", "", NULL, (SUBR) sensekey_perf, NULL }, - { "sensekey", S(KSENSE),0, 2, "kz", "", + { "sensekey", S(KSENSE),0, "kz", "", NULL, (SUBR) sensekey_perf, NULL }, - { "remove", S(DELETEIN),0, 1, "", "T", + { "remove", S(DELETEIN),0, "", "T", (SUBR) delete_instr, NULL, NULL }, - // { "##globallock", S(GLOBAL_LOCK_UNLOCK),0, 3, "", "i", + // { "##globallock", S(GLOBAL_LOCK_UNLOCK),0, "", "i", // globallock, globallock, NULL}, - // { "##globalunlock", S(GLOBAL_LOCK_UNLOCK),0, 3, "", "i", + // { "##globalunlock", S(GLOBAL_LOCK_UNLOCK),0, "", "i", // globalunlock, globalunlock, NULL}, - { "##error",S(ERRFN),0, 1, "i", "i", error_fn, NULL, NULL }, - { "exprandi.i",S(PRANDI),0, 1, "i", "kxx", iexprndi, NULL, NULL }, - { "exprandi.k",S(PRANDI),0, 3, "k", "kxx", exprndiset, kexprndi, NULL }, - { "exprandi.a",S(PRANDI),0, 2, "a", "kxx", exprndiset, aexprndi }, - { "cauchyi.i", S(PRANDI),0, 1, "i", "kxx", icauchyi, NULL, NULL }, - { "cauchyi.k", S(PRANDI),0, 3, "k", "kxx", cauchyiset, kcauchyi, NULL }, - { "cauchyi.a", S(PRANDI),0, 2, "a", "kxx", cauchyiset, acauchyi }, - { "gaussi.i", S(PRANDI),0, 1, "i", "kxx", igaussi, NULL, NULL }, - { "gaussi.k", S(PRANDI),0, 3, "k", "kxx", gaussiset, kgaussi, NULL }, - { "gaussi.a", S(PRANDI),0, 2, "a", "kxx", gaussiset, agaussi }, - { "ftresizei", S(RESIZE), TB, 1, "i", "ii", (SUBR) resize_table, NULL, NULL }, - { "ftresize", S(RESIZE), TB, 2, "k", "kk", NULL, (SUBR) resize_table, NULL }, - { "compileorc", S(COMPILE), 0, 1, "i", "S", (SUBR) compile_orc_i, NULL, NULL }, - { "compilecsd", S(COMPILE), 0, 1, "i", "S", (SUBR) compile_csd_i, NULL, NULL }, - { "compilestr", S(COMPILE), 0, 1, "i", "S", (SUBR) compile_str_i, NULL, NULL }, - { "evalstr", S(COMPILE), 0, 1, "i", "S", (SUBR) eval_str_i, NULL, NULL }, - { "evalstr", S(COMPILE), 0, 2, "k", "Sk", NULL, (SUBR) eval_str_k, NULL }, - { "readscore", S(COMPILE), 0, 1, "i", "S", (SUBR) read_score_i, NULL, NULL }, - { "return", S(RETVAL), 0, 1, "", "i", (SUBR) retval_i, NULL, NULL }, - { "pcount", S(PFIELD), 0, 1, "i", "", (SUBR)pcount, NULL, NULL }, -{ "pindex", S(PFIELD), 0, 1, "i", "i", (SUBR)pvalue, NULL, NULL }, -{ "pindex.S", S(PFIELDSTR), 0, 1, "S", "i", (SUBR)pvaluestr, NULL, NULL }, -{ "passign", S(PINIT), 0, 1, "IIIIIIIIIIIIIIIIIIIIIIII", "po", - (SUBR)pinit, NULL, NULL }, -{ "passign.i", S(PAINIT), 0, 1, "i[]", "po", (SUBR)painit, NULL, NULL }, -{ "passign.k", S(PAINIT), 0, 1, "k[]", "po", (SUBR)painit, NULL, NULL }, + { "##error",S(ERRFN),0, "i", "i", error_fn, NULL, NULL }, + { "exprandi.i",S(PRANDI),0, "i", "kxx", iexprndi, NULL, NULL }, + { "exprandi.k",S(PRANDI),0, "k", "kxx", exprndiset, kexprndi, NULL }, + { "exprandi.a",S(PRANDI),0, "a", "kxx", exprndiset, aexprndi }, + { "cauchyi.i", S(PRANDI),0, "i", "kxx", icauchyi, NULL, NULL }, + { "cauchyi.k", S(PRANDI),0, "k", "kxx", cauchyiset, kcauchyi, NULL }, + { "cauchyi.a", S(PRANDI),0, "a", "kxx", cauchyiset, acauchyi }, + { "gaussi.i", S(PRANDI),0, "i", "kxx", igaussi, NULL, NULL }, + { "gaussi.k", S(PRANDI),0, "k", "kxx", gaussiset, kgaussi, NULL }, + { "gaussi.a", S(PRANDI),0, "a", "kxx", gaussiset, agaussi }, + { "ftresizei", S(RESIZE), TB, "i", "ii", (SUBR) resize_table, NULL, NULL }, + { "ftresize", S(RESIZE), TB, "k", "kk", NULL, (SUBR) resize_table, NULL }, + { "compileorc", S(COMPILE), 0, "i", "S", (SUBR) compile_orc_i, NULL, NULL }, + { "compilecsd", S(COMPILE), 0, "i", "S", (SUBR) compile_csd_i, NULL, NULL }, + { "compilestr", S(COMPILE), 0, "i", "S", (SUBR) compile_str_i, NULL, NULL }, + { "evalstr", S(COMPILE), 0, "i", "S", (SUBR) eval_str_i, NULL, NULL }, + { "evalstr", S(COMPILE), 0, "k", "Sk", NULL, (SUBR) eval_str_k, NULL }, + { "readscore", S(COMPILE), 0, "i", "S", (SUBR) read_score_i, NULL, NULL }, + { "return", S(RETVAL), 0, "", "i", (SUBR) retval_i, NULL, NULL }, + { "pcount", S(PFIELD), 0, "i", "", (SUBR)pcount, NULL, NULL }, + { "pindex", S(PFIELD), 0, "i", "i", (SUBR)pvalue, NULL, NULL }, + { "pindex.S", S(PFIELDSTR), 0, "S", "i", (SUBR)pvaluestr, NULL, NULL }, + { "passign", S(PINIT), 0, "IIIIIIIIIIIIIIIIIIIIIIII", "po", + (SUBR)pinit, NULL, NULL }, + { "passign.i", S(PAINIT), 0, "i[]", "po", (SUBR)painit, NULL, NULL }, + { "passign.k", S(PAINIT), 0, "k[]", "po", (SUBR)painit, NULL, NULL }, + /* ----------------------------------------------------------------------- */ // VL: 9.3.22 this is causing a problem in parsing arrays // I am modifying it to accept only i-time inputs - { "=.generic", S(ASSIGN), 0,1, ".", ".", (SUBR)copyVarGeneric, NULL, NULL}, - { "monitor", sizeof(MONITOR_OPCODE), IB, 3, "mmmmmmmmmmmmmmmmmmmmmmmm", "", + { "=.generic", S(ASSIGN), 0, ".", ".", (SUBR)copyVarGeneric, NULL, NULL}, + { "monitor", sizeof(MONITOR_OPCODE), IB, "mmmmmmmmmmmmmmmmmmmmmmmm", "", (SUBR) monitor_opcode_init, (SUBR) notinit_opcode_stub, NULL }, - { "outrg", S(OUTRANGE), IR,3, "", "ky", + { "outrg", S(OUTRANGE), IR, "", "ky", (SUBR)outRange_i, (SUBR)outRange}, - { "nchnls_hw", S(ASSIGN), 0,1, "ii", "", + { "nchnls_hw", S(ASSIGN), 0, "ii", "", (SUBR)hw_channels}, - { "midiarp", S(MIDIARP),0, 3, "kk", "kO", - midiarp_set, midiarp, NULL }, - {"lpcfilter", S(LPCFIL), 0, 3, "a", "akkiiio", + { "midiarp", S(MIDIARP),0, "kk", "kO", + midiarp_set, midiarp, NULL }, + {"lpcfilter", S(LPCFIL), 0, "a", "akkiiio", (SUBR) lpfil_init, (SUBR) lpfil_perf}, - {"lpcfilter", S(LPCFIL2), 0, 3, "a", "aakkiio", + {"lpcfilter", S(LPCFIL2), 0, "a", "aakkiio", (SUBR) lpfil2_init, (SUBR) lpfil2_perf}, - {"allpole", S(LPCFIL3), 0, 3, "a", "ak[]", + {"allpole", S(LPCFIL3), 0, "a", "ak[]", (SUBR) lpfil3_init, (SUBR) lpfil3_perf}, - {"lpcanal", S(LPREDA), 0, 3, "k[]kkk", "kkiiio", + {"lpcanal", S(LPREDA), 0, "k[]kkk", "kkiiio", (SUBR) lpred_alloc, (SUBR) lpred_run}, - {"lpcanal", S(LPREDA2), 0, 3, "k[]kkk", "akkiio", + {"lpcanal", S(LPREDA2), 0, "k[]kkk", "akkiio", (SUBR) lpred_alloc2, (SUBR) lpred_run2}, - {"lpcanal", S(LPREDA), 0, 1, "i[]iii", "iiii", + {"lpcanal", S(LPREDA), 0, "i[]iii", "iiii", (SUBR) lpred_i, NULL}, - {"pvslpc", S(LPCPVS), 0, 3, "f", "aiiio", - (SUBR) lpcpvs_init, (SUBR) lpcpvs}, - {"pvscfs", S(PVSCFS), 0, 3, "k[]kk", "fip", - (SUBR) pvscoefs_init, (SUBR) pvscoefs}, - {"apoleparams", S(CF2P), 0, 3, "k[]", "k[]", - (SUBR) coef2parm_init, (SUBR) coef2parm}, - {"resonbnk", S(RESONB), 0, 3, "a", "ak[]kkipoo", + {"pvslpc", S(LPCPVS), 0, "f", "aiiio", + (SUBR) lpcpvs_init, (SUBR) lpcpvs}, + {"pvscfs", S(PVSCFS), 0, "k[]kk", "fip", + (SUBR) pvscoefs_init, (SUBR) pvscoefs}, + {"apoleparams", S(CF2P), 0, "k[]", "k[]", + (SUBR) coef2parm_init, (SUBR) coef2parm}, + {"resonbnk", S(RESONB), 0, "a", "ak[]kkipoo", (SUBR) resonbnk_init, (SUBR) resonbnk}, - { "inrg", S(INRANGE), WI,3, "", "ky", (SUBR)inRange_i, (SUBR)inRange }, + { "inrg", S(INRANGE), WI, "", "ky", (SUBR)inRange_i, (SUBR)inRange }, /* terminate list */ { NULL, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } }; diff --git a/Engine/insert.c b/Engine/insert.c index a0657feb23d..47fe75d6e72 100644 --- a/Engine/insert.c +++ b/Engine/insert.c @@ -121,7 +121,7 @@ static int init_pass(CSOUND *csound, INSDS *ip) { csound->op = csound->ids->optext->t.oentry->opname; csound->Message(csound, "init %s:\n", csound->op); } - error = (*csound->ids->iopadr)(csound, csound->ids); + error = (*csound->ids->init)(csound, csound->ids); } csound->mode = 0; if(csound->oparms->realtime) @@ -140,11 +140,11 @@ static int reinit_pass(CSOUND *csound, INSDS *ip, OPDS *ids) { csound->ids = ids; csound->mode = 1; while (error == 0 && (csound->ids = csound->ids->nxti) != NULL && - (csound->ids->iopadr != (SUBR) rireturn)){ + (csound->ids->init != (SUBR) rireturn)){ csound->op = csound->ids->optext->t.oentry->opname; if (UNLIKELY(csound->oparms->odebug)) csound->Message(csound, "reinit %s:\n", csound->op); - error = (*csound->ids->iopadr)(csound, csound->ids); + error = (*csound->ids->init)(csound, csound->ids); } csound->mode = 0; @@ -263,7 +263,7 @@ int init0(CSOUND *csound) csound->mode = 1; while ((csound->ids = csound->ids->nxti) != NULL) { csound->op = csound->ids->optext->t.oentry->opname; - (*csound->ids->iopadr)(csound, csound->ids); /* run all i-code */ + (*csound->ids->init)(csound, csound->ids); /* run all i-code */ } csound->mode = 0; return csound->inerrcnt; /* return errcnt */ @@ -918,13 +918,29 @@ static void schedofftim(CSOUND *csound, INSDS *ip) extern int csoundDeinitialiseOpcodes(CSOUND *csound, INSDS *ip); int useropcd(CSOUND *, UOPCODE*); + +void deinit_pass(CSOUND *csound, INSDS *ip) { + int error = 0; + OPDS *dds = (OPDS *) ip; + const char* op; + while (error == 0 && (dds = dds->nxtd) != NULL) { + if (UNLIKELY(csound->oparms->odebug)) { + op = dds->optext->t.oentry->opname; + csound->Message(csound, "deinit %s:\n", op); + } + error = (*dds->deinit)(csound, dds); + if(error) { + op = dds->optext->t.oentry->opname; + csound->ErrorMsg(csound, "%s deinit error\n", op); + } + } +} + static void deact(CSOUND *csound, INSDS *ip) { /* unlink single instr from activ chain */ INSDS *nxtp; /* and mark it inactive */ - /* close any files in fd chain */ - - if (ip->nxtd != NULL) - csoundDeinitialiseOpcodes(csound, ip); + /* do deinit pass */ + deinit_pass(csound, ip); /* remove an active instrument */ csound->engineState.instrtxtp[ip->insno]->active--; if (ip->xtratim > 0) @@ -949,11 +965,11 @@ static void deact(CSOUND *csound, INSDS *ip) p->cvt_out[k] = NULL; // clear pointer } else break; // first null indicates end of cvt list - + deact(csound, p->ip); /* deactivate */ p->ip = NULL; /* IV - Oct 26 2002: set perf routine to "not initialised" */ - p->h.opadr = (SUBR) useropcd; + p->h.perf = (SUBR) useropcd; ip->opcod_deact = NULL; } if (ip->subins_deact) { @@ -997,7 +1013,6 @@ int kill_instance(CSOUND *csound, KILLOP *p) { void xturnoff(CSOUND *csound, INSDS *ip) /* turnoff a particular insalloc */ { /* called by inexclus on ctrl 111 */ MCHNBLK *chn; - if (UNLIKELY(ip->relesing)) return; /* already releasing: nothing to do */ @@ -1276,7 +1291,7 @@ int subinstrset_(CSOUND *csound, SUBINST *p, int instno) int n, init_op, inarg_ofs; INSDS *pip = p->h.insdshead; - init_op = (p->h.opadr == NULL ? 1 : 0); + init_op = (p->h.perf == NULL ? 1 : 0); inarg_ofs = (init_op ? 0 : SUBINSTNUMOUTS); if (UNLIKELY(instno < 0)) return NOTOK; /* IV - Oct 9 2002: need this check */ @@ -1407,7 +1422,7 @@ int subinstrset_(CSOUND *csound, SUBINST *p, int instno) csound->mode = 1; while ((csound->ids = csound->ids->nxti) != NULL) { csound->op = csound->ids->optext->t.oentry->opname; - (*csound->ids->iopadr)(csound, csound->ids); + (*csound->ids->init)(csound, csound->ids); } csound->mode = 0; p->ip->init_done = 1; @@ -1427,7 +1442,7 @@ int subinstrset_(CSOUND *csound, SUBINST *p, int instno) int subinstrset_S(CSOUND *csound, SUBINST *p){ int instno, init_op, inarg_ofs; /* check if we are using subinstrinit or subinstr */ - init_op = (p->h.opadr == NULL ? 1 : 0); + init_op = (p->h.perf == NULL ? 1 : 0); inarg_ofs = (init_op ? 0 : SUBINSTNUMOUTS); instno = strarg2insno(csound, ((STRINGDAT *)p->ar[inarg_ofs])->data, 1); if (UNLIKELY(instno==NOT_AN_INSTRUMENT)) instno = -1; @@ -1438,7 +1453,7 @@ int subinstrset_S(CSOUND *csound, SUBINST *p){ int subinstrset(CSOUND *csound, SUBINST *p){ int instno, init_op, inarg_ofs; /* check if we are using subinstrinit or subinstr */ - init_op = (p->h.opadr == NULL ? 1 : 0); + init_op = (p->h.perf == NULL ? 1 : 0); inarg_ofs = (init_op ? 0 : SUBINSTNUMOUTS); instno = (int) *(p->ar[inarg_ofs]); return subinstrset_(csound,p,instno); @@ -1580,7 +1595,7 @@ int useropcdset(CSOUND *csound, UOPCODE *p) buf->iflag = 0; while (csound->ids != NULL) { csound->op = csound->ids->optext->t.oentry->opname; - (*csound->ids->iopadr)(csound, csound->ids); + (*csound->ids->init)(csound, csound->ids); csound->ids = csound->ids->nxti; } csound->mode = 0; @@ -1606,12 +1621,12 @@ int useropcdset(CSOUND *csound, UOPCODE *p) int ksmps_scale = lcurip->ksmps / parent_ip->ksmps; parent_ip->xtratim = lcurip->xtratim * ksmps_scale; if(lcurip->esr == parent_ip->esr) // (1) local sr == parent sr - p->h.opadr = (SUBR) useropcd1; + p->h.perf = (SUBR) useropcd1; else // (2) local sr < parent sr - p->h.opadr = (SUBR) useropcd2; + p->h.perf = (SUBR) useropcd2; } else { // (3) local sr >= parent sr parent_ip->xtratim = lcurip->xtratim; - p->h.opadr = (SUBR) useropcd2; + p->h.perf = (SUBR) useropcd2; } // debug msg if (UNLIKELY(csound->oparms->odebug)) @@ -2107,7 +2122,7 @@ int subinstr(CSOUND *csound, SUBINST *p) if ((CS_PDS = (OPDS *) (ip->nxtp)) != NULL) { CS_PDS->insdshead->pds = NULL; do { - error = (*CS_PDS->opadr)(csound, CS_PDS); + error = (*CS_PDS->perf)(csound, CS_PDS); if (CS_PDS->insdshead->pds != NULL) { CS_PDS = CS_PDS->insdshead->pds; CS_PDS->insdshead->pds = NULL; @@ -2149,7 +2164,7 @@ int subinstr(CSOUND *csound, SUBINST *p) memset(p->ar, 0, sizeof(MYFLT)*CS_KSMPS*p->OUTCOUNT); goto endin; } - error = (*CS_PDS->opadr)(csound, CS_PDS); + error = (*CS_PDS->perf)(csound, CS_PDS); if (CS_PDS->insdshead->pds != NULL) { CS_PDS = CS_PDS->insdshead->pds; CS_PDS->insdshead->pds = NULL; @@ -2264,7 +2279,7 @@ int useropcd1(CSOUND *csound, UOPCODE *p) CS_PDS->insdshead->pds = NULL; do { if(UNLIKELY(!ATOMIC_GET8(p->ip->actflg))) goto endop; - error = (*CS_PDS->opadr)(csound, CS_PDS); + error = (*CS_PDS->perf)(csound, CS_PDS); if (CS_PDS->insdshead->pds != NULL && CS_PDS->insdshead->pds->insdshead) { CS_PDS = CS_PDS->insdshead->pds; @@ -2373,7 +2388,7 @@ int useropcd1(CSOUND *csound, UOPCODE *p) CS_PDS->insdshead->pds = NULL; do { if(UNLIKELY(!ATOMIC_GET8(p->ip->actflg))) goto endop; - error = (*CS_PDS->opadr)(csound, CS_PDS); + error = (*CS_PDS->perf)(csound, CS_PDS); if (CS_PDS->insdshead->pds != NULL && CS_PDS->insdshead->pds->insdshead) { CS_PDS = CS_PDS->insdshead->pds; @@ -2554,7 +2569,7 @@ int useropcd2(CSOUND *csound, UOPCODE *p) p->ip->kcounter++; /* kcount should be incremented BEFORE perf */ do { if(UNLIKELY(!ATOMIC_GET8(p->ip->actflg))) goto endop; - error = (*CS_PDS->opadr)(csound, CS_PDS); + error = (*CS_PDS->perf)(csound, CS_PDS); if (CS_PDS->insdshead->pds != NULL && CS_PDS->insdshead->pds->insdshead) { CS_PDS = CS_PDS->insdshead->pds; @@ -2636,7 +2651,7 @@ static void instance(CSOUND *csound, int insno) INSTRTXT *tp; INSDS *ip; OPTXT *optxt; - OPDS *opds, *prvids, *prvpds; + OPDS *opds, *prvids, *prvpds, *prvpdd; const OENTRY *ep; int i, n, pextent, pextra, pextrab; char *nxtopds, *opdslim; @@ -2709,7 +2724,7 @@ static void instance(CSOUND *csound, int insno) Str("instr %d allocated at %p\n\tlclbas %p, opds %p\n"), insno, ip, lclbas, nxtopds); optxt = (OPTXT*) tp; - prvids = prvpds = (OPDS*) ip; + prvids = prvpds = prvpdd = (OPDS*) ip; // prvids->insdshead = ip; /* initialize vars for CS_TYPE */ @@ -2742,38 +2757,32 @@ static void instance(CSOUND *csound, int insno) LBLBLK *lblbp = (LBLBLK *) opds; lblbp->prvi = prvids; /* save i/p links */ lblbp->prvp = prvpds; + lblbp->prvd = prvpdd; continue; /* for later refs */ - } - // ******** This needs revisipn with no distinction between k- and a- rate **** - if ((ep->thread & 03) == 0) { /* thread 1 OR 2: */ - if (ttp->pftype == 'b') { - prvids = prvids->nxti = opds; - opds->iopadr = ep->iopadr; + } + + if (ep->init != NULL) { /* init */ + prvids = prvids->nxti = opds; /* link into ichain */ + opds->init = ep->init; /* & set exec adr */ + if (UNLIKELY(odebug)) + csound->Message(csound, "%s init = %p\n", + ep->opname,(void*) opds->init); } - else { - prvpds = prvpds->nxtp = opds; - opds->opadr = ep->kopadr; + if (ep->perf != NULL) { /* perf */ + prvpds = prvpds->nxtp = opds; /* link into pchain */ + opds->perf = ep->perf; /* perf */ + if (UNLIKELY(odebug)) + csound->Message(csound, "%s perf = %p\n", + ep->opname,(void*) opds->perf); } - goto args; - } - if ((ep->thread & 01) != 0) { /* thread 1: */ - prvids = prvids->nxti = opds; /* link into ichain */ - opds->iopadr = ep->iopadr; /* & set exec adr */ - if (UNLIKELY(opds->iopadr == NULL)) - csoundDie(csound, Str("null iopadr")); - } - if ((n = ep->thread & 02) != 0) { /* thread 2 : */ - prvpds = prvpds->nxtp = opds; /* link into pchain */ - /* if (!(n & 04) || */ - /* ((ttp->pftype == 'k' || ttp->pftype == 'c') && ep->kopadr != NULL)) */ - opds->opadr = ep->kopadr; /* krate or */ - /* else opds->opadr = ep->aopadr; /\* arate *\/ */ + if(ep->deinit != NULL) { /* deinit */ + prvpdd = prvpdd->nxtd = opds; /* link into dchain */ + opds->deinit = ep->deinit; /* deinit */ if (UNLIKELY(odebug)) - csound->Message(csound, "opadr = %p\n", (void*) opds->opadr); - if (UNLIKELY(opds->opadr == NULL)) - csoundDie(csound, Str("null opadr")); - } - args: + csound->Message(csound, "%s deinit = %p\n", + ep->opname,(void*) opds->deinit); + } + if (ep->useropinfo == NULL) argpp = (MYFLT **) ((char *) opds + sizeof(OPDS)); else /* user defined opcodes are a special case */ diff --git a/Engine/symbtab.c b/Engine/symbtab.c index ff14be57953..b44c64b0bce 100644 --- a/Engine/symbtab.c +++ b/Engine/symbtab.c @@ -386,9 +386,9 @@ OENTRY* csound_find_internal_oentry(CSOUND* csound, OENTRY* oentry) { while (items != NULL) { ep = items->value; - if (oentry->iopadr == ep->iopadr && - oentry->kopadr == ep->kopadr && - oentry->aopadr == ep->aopadr && + if (oentry->init == ep->init && + oentry->perf == ep->perf && + oentry->deinit == ep->deinit && strcmp(oentry->opname, ep->opname) == 0 && strcmp(oentry->outypes, ep->outypes) == 0 && strcmp(oentry->intypes, ep->intypes) == 0) { @@ -484,7 +484,7 @@ int add_udo_definition(CSOUND *csound, char *opname, memcpy(&tmpEntry, opc, sizeof(OENTRY)); tmpEntry.opname = cs_strdup(csound, opname); - csound->AppendOpcodes(csound, &tmpEntry, 1); + csoundAppendOpcodes(csound, &tmpEntry, 1); newopc = csound_find_internal_oentry(csound, &tmpEntry); newopc->useropinfo = (void*) inm; /* ptr to opcode parameters */ diff --git a/Engine/ugen.c b/Engine/ugen.c index eb871019301..e3875701f0e 100644 --- a/Engine/ugen.c +++ b/Engine/ugen.c @@ -254,8 +254,8 @@ PUBLIC UGEN* ugen_new(UGEN_FACTORY* factory, char* opName, char* outargTypes, ch opds = ugen->opcodeMem; opds->insdshead = insds; - opds->iopadr = oentry->iopadr; - opds->opadr = oentry->kopadr; + opds->init = oentry->init; + opds->perf = oentry->perf; opds->optext = optxt; @@ -308,6 +308,7 @@ PUBLIC UGEN* ugen_new(UGEN_FACTORY* factory, char* opName, char* outargTypes, ch ugen->data = (MYFLT*)csound->Calloc(csound, ugen->outPool->poolSize + ugen->inPool->poolSize); /*MYFLT* temp = (MYFLT*)this->opcodeMem +(sizeof(OPDS) / sizeof(MYFLT));*/ + /*MYFLT** p = (MYFLT**) temp;*/ /*int outOffset = outPool->poolSize / sizeof(MYFLT);*/ /*int count = 0;*/ @@ -345,28 +346,18 @@ PUBLIC int ugen_init(UGEN* ugen) { OPDS* opds = (OPDS*)ugen->opcodeMem; OENTRY* oentry = ugen->oentry; opds->optext->t.inArgCount = ugen->inocount; - if (oentry->iopadr != NULL) { - return (*oentry->iopadr)(ugen->csound, ugen->opcodeMem); + if (oentry->init != NULL) { + return (*oentry->init)(ugen->csound, ugen->opcodeMem); } return CSOUND_SUCCESS; } PUBLIC int ugen_perform(UGEN* ugen) { - // TODO - check how csound chooses kopadr vs. aopadr OENTRY* oentry = ugen->oentry; CSOUND* csound = ugen->csound; void* opcodeMem = ugen->opcodeMem; - if((oentry->thread & 2) == 2) { - if (oentry->kopadr != NULL) { - return (*oentry->kopadr)(csound, opcodeMem); - } - } - if((oentry->thread & 4) == 4) { - if (oentry->aopadr != NULL) { - return (*oentry->aopadr)(csound, opcodeMem); - } - } - + if (oentry->perf != NULL) + return (*oentry->perf)(csound, opcodeMem); return CSOUND_SUCCESS; } diff --git a/H/diskin2.h b/H/diskin2.h index f85334ef792..03458f088db 100644 --- a/H/diskin2.h +++ b/H/diskin2.h @@ -125,6 +125,9 @@ int32_t diskin2_init_array_S(CSOUND *csound, DISKIN2_ARRAY *p); int32_t diskin_init_array_I(CSOUND *csound, DISKIN2_ARRAY *p); int32_t diskin_init_array_S(CSOUND *csound, DISKIN2_ARRAY *p); int32_t diskin2_perf_array(CSOUND *csound, DISKIN2_ARRAY *p); +int32_t diskin2_async_deinit(CSOUND *csound, DISKIN2 *p); +int32_t soundout_deinit(CSOUND *csound, void *pp); +int32_t diskin2_async_deinit_array(CSOUND *csound, DISKIN2_ARRAY *p); typedef struct { OPDS h; diff --git a/H/prototyp.h b/H/prototyp.h index 61c281e39a4..f1f1b193574 100644 --- a/H/prototyp.h +++ b/H/prototyp.h @@ -112,18 +112,6 @@ int insert_score_event_at_sample(CSOUND *, EVTBLK *, int64_t); char *get_arg_string(CSOUND *, MYFLT); -/** - * Register a function to be called at note deactivation. - * Should be called from the initialisation routine of an opcode. - * 'p' is a pointer to the OPDS structure of the opcode, and 'func' - * is the function to be called, with the same arguments and return - * value as in the case of opcode init/perf functions. - * The functions are called in reverse order of registration. - * Returns zero on success. - */ -int csoundRegisterDeinitCallback(CSOUND *, void *p, - int (*func)(CSOUND *, void *)); - /** * Register a function to be called by csoundReset(), in reverse order * of registration, before unloading external modules. The function takes diff --git a/OOps/aops.c b/OOps/aops.c index 6101f8921e4..73f66546bff 100644 --- a/OOps/aops.c +++ b/OOps/aops.c @@ -2154,7 +2154,7 @@ int32_t monitor_opcode_init(CSOUND *csound, MONITOR_OPCODE *p) { if (UNLIKELY(csound->GetOutputArgCnt(p) != (int32_t)csound->GetNchnls(csound))) return csound->InitError(csound, Str("number of arguments != nchnls")); - p->h.opadr = (SUBR) monitor_opcode_perf; + p->h.perf = (SUBR) monitor_opcode_perf; return OK; } diff --git a/OOps/bus.c b/OOps/bus.c index abb0aef331c..bdc58f65790 100644 --- a/OOps/bus.c +++ b/OOps/bus.c @@ -619,8 +619,8 @@ static CS_NOINLINE void print_chn_err_perf(void *p, int32_t err) CSOUND *csound = ((OPDS*) p)->insdshead->csound; const char *msg; - if (((OPDS*) p)->opadr != (SUBR) NULL) - ((OPDS*) p)->opadr = (SUBR) notinit_opcode_stub; + if (((OPDS*) p)->perf != (SUBR) NULL) + ((OPDS*) p)->perf = (SUBR) notinit_opcode_stub; if (err == CSOUND_MEMORY) msg = "memory allocation failure"; else if (err < 0) @@ -635,8 +635,8 @@ static CS_NOINLINE int32_t print_chn_err(void *p, int32_t err) CSOUND *csound = ((OPDS*) p)->insdshead->csound; const char *msg; - if (((OPDS*) p)->opadr != (SUBR) NULL) - ((OPDS*) p)->opadr = (SUBR) notinit_opcode_stub; + if (((OPDS*) p)->perf != (SUBR) NULL) + ((OPDS*) p)->perf = (SUBR) notinit_opcode_stub; if (err == CSOUND_MEMORY) msg = "memory allocation failure"; else if (err < 0) @@ -855,11 +855,11 @@ int32_t chnget_array_opcode_init(CSOUND* csound, CHNGETARRAY* p) } if(channelType == (CSOUND_CONTROL_CHANNEL | CSOUND_INPUT_CHANNEL)) - p->h.opadr = (SUBR) chnget_array_opcode_perf_k; + p->h.perf = (SUBR) chnget_array_opcode_perf_k; else if(channelType == (CSOUND_AUDIO_CHANNEL | CSOUND_INPUT_CHANNEL)) - p->h.opadr = (SUBR) chnget_array_opcode_perf_a; + p->h.perf = (SUBR) chnget_array_opcode_perf_a; else - p->h.opadr = (SUBR) chnget_array_opcode_perf_S; + p->h.perf = (SUBR) chnget_array_opcode_perf_S; return OK; } @@ -1035,11 +1035,11 @@ int32_t chnset_array_opcode_init(CSOUND* csound, CHNGETARRAY* p) } if(channelType == (CSOUND_CONTROL_CHANNEL | CSOUND_INPUT_CHANNEL)) - p->h.opadr = (SUBR) chnset_array_opcode_perf_k; + p->h.perf = (SUBR) chnset_array_opcode_perf_k; else if(channelType == (CSOUND_AUDIO_CHANNEL | CSOUND_INPUT_CHANNEL)) - p->h.opadr = (SUBR) chnset_array_opcode_perf_a; + p->h.perf = (SUBR) chnset_array_opcode_perf_a; else - p->h.opadr = (SUBR) chnset_array_opcode_perf_S; + p->h.perf = (SUBR) chnset_array_opcode_perf_S; return OK; } @@ -1161,7 +1161,7 @@ int32_t chnget_opcode_init_k(CSOUND *csound, CHNGET *p) strNcpy(p->chname, p->iname->data, MAX_CHAN_NAME); } - p->h.opadr = (SUBR) chnget_opcode_perf_k; + p->h.perf = (SUBR) chnget_opcode_perf_k; return OK; } @@ -1180,7 +1180,7 @@ int32_t chnget_opcode_init_a(CSOUND* csound, CHNGET* p) strNcpy(p->chname, p->iname->data, MAX_CHAN_NAME); } - p->h.opadr = (SUBR) chnget_opcode_perf_a; + p->h.perf = (SUBR) chnget_opcode_perf_a; return OK; } @@ -1399,7 +1399,7 @@ int32_t chnset_opcode_init_k(CSOUND* csound, CHNGET* p) p->lock = (spin_lock_t*) csoundGetChannelLock(csound, (char*) p->iname->data); } else return print_chn_err(p, err); - p->h.opadr = (SUBR) chnset_opcode_perf_k; + p->h.perf = (SUBR) chnset_opcode_perf_k; return OK; } @@ -1415,7 +1415,7 @@ int32_t chnset_opcode_init_a(CSOUND* csound, CHNGET* p) p->lock = (spin_lock_t*) csoundGetChannelLock(csound, (char*) p->iname->data); } else return print_chn_err(p, err); - p->h.opadr = (SUBR) chnset_opcode_perf_a; + p->h.perf = (SUBR) chnset_opcode_perf_a; return OK; } @@ -1429,7 +1429,7 @@ int32_t chnmix_opcode_init(CSOUND *csound, CHNGET *p) CSOUND_AUDIO_CHANNEL | CSOUND_OUTPUT_CHANNEL); if (LIKELY(!err)) { p->lock = (spin_lock_t *)csoundGetChannelLock(csound, (char*) p->iname->data); - p->h.opadr = (SUBR) chnmix_opcode_perf; + p->h.perf = (SUBR) chnmix_opcode_perf; return OK; } return print_chn_err(p, err); @@ -1451,7 +1451,7 @@ int32_t chnclear_opcode_init(CSOUND *csound, CHNCLEAR *p) } else return print_chn_err(p, err); } - p->h.opadr = (SUBR) chnclear_opcode_perf; + p->h.perf = (SUBR) chnclear_opcode_perf; return OK; } diff --git a/OOps/diskin2.c b/OOps/diskin2.c index b44628e2712..14056dbcdff 100644 --- a/OOps/diskin2.c +++ b/OOps/diskin2.c @@ -294,8 +294,6 @@ int32_t soundin(CSOUND *csound, DISKIN2 *p){ return ret; } -int32_t diskin2_async_deinit(CSOUND *csound, void *p); - static int32_t diskin2_init_(CSOUND *csound, DISKIN2 *p, int32_t stringname) { double pos; @@ -303,6 +301,7 @@ static int32_t diskin2_init_(CSOUND *csound, DISKIN2 *p, int32_t stringname) void *fd; SFLIB_INFO sfinfo; int32_t n; + /* check number of channels */ p->nChannels = (int32_t)(p->OUTOCOUNT); @@ -470,7 +469,7 @@ static int32_t diskin2_init_(CSOUND *csound, DISKIN2 *p, int32_t stringname) *start = 1; } #endif - csound->RegisterDeinitCallback(csound, p, diskin2_async_deinit); + p->async = 1; /* print file information */ @@ -507,12 +506,14 @@ static int32_t diskin2_init_(CSOUND *csound, DISKIN2 *p, int32_t stringname) return OK; } -int32_t diskin2_async_deinit(CSOUND *csound, void *p){ +int32_t diskin2_async_deinit(CSOUND *csound, DISKIN2 *p){ + if(p->async) { // deinit only needed in asybc MODE DISKIN_INST **top, *current, *prv; - if ((top = (DISKIN_INST **) - csound->QueryGlobalVariable(csound, "DISKIN_INST")) == NULL) return NOTOK; + csound->QueryGlobalVariable(csound, "DISKIN_INST")) == NULL) + return NOTOK; + current = *top; prv = NULL; while(current->diskin != (DISKIN2 *)p) { @@ -538,8 +539,9 @@ int32_t diskin2_async_deinit(CSOUND *csound, void *p){ #endif csound->Free(csound, current); csound->DestroyCircularBuffer(csound, ((DISKIN2 *)p)->cb); + } - return OK; + return OK; } static inline void diskin2_file_pos_inc(DISKIN2 *p, int32_t *ndx) @@ -1002,7 +1004,7 @@ int32_t diskin2_perf(CSOUND *csound, DISKIN2 *p) { -static int32_t soundout_deinit(CSOUND *csound, void *pp) +int32_t soundout_deinit(CSOUND *csound, void *pp) { char *opname = csound->GetOpcodeName(pp); SNDCOM *q; @@ -1062,8 +1064,6 @@ static int32_t sndo1set_(CSOUND *csound, void *pp, int32_t stringname) if (q->fd != NULL) /* if file already open, */ return OK; /* return now */ - csound->RegisterDeinitCallback(csound, pp, soundout_deinit); - if (stringname==0){ if (csound->ISSTRCOD(*ifilcod)) strNcpy(name,get_arg_string(csound, *ifilcod), 1023); @@ -1313,8 +1313,9 @@ static inline void diskin2_get_sample_array(CSOUND *csound, } } -int32_t diskin2_async_deinit_array(CSOUND *csound, void *p){ +int32_t diskin2_async_deinit_array(CSOUND *csound, DISKIN2_ARRAY *p){ + if(p->async) { DISKIN_INST **top, *current, *prv; if ((top = (DISKIN_INST **) @@ -1346,7 +1347,7 @@ int32_t diskin2_async_deinit_array(CSOUND *csound, void *p){ csound->Free(csound, current); csound->DestroyCircularBuffer(csound, ((DISKIN2_ARRAY *)p)->cb); - + } return OK; } @@ -1760,8 +1761,6 @@ static int32_t diskin2_init_array(CSOUND *csound, DISKIN2_ARRAY *p, csound->CreateThread(diskin_io_thread_array, *top); } #endif - csound->RegisterDeinitCallback(csound, (DISKIN2 *) p, - diskin2_async_deinit_array); p->async = 1; /* print file information */ diff --git a/OOps/goto_ops.c b/OOps/goto_ops.c index c9a61953305..919afb29ecf 100644 --- a/OOps/goto_ops.c +++ b/OOps/goto_ops.c @@ -41,8 +41,10 @@ int32_t kgoto(CSOUND *csound, GOTO *p) CS_PDS = p->lblblk->prvp; /* VL 16.2.23 fix for UDOs where the label gets confused */ - if(CS_PDS->insdshead == NULL) - CS_PDS->insdshead = p->h.insdshead; + // not sure it's right 1.4.24 + // with changes to OPDS, this leads to infinite deact loop + //if(CS_PDS->insdshead == NULL) + // CS_PDS->insdshead = p->h.insdshead; return OK; } @@ -111,8 +113,8 @@ int32_t reinit(CSOUND *csound, GOTO *p) csound->curip = p->h.insdshead; csound->ids = p->lblblk->prvi; /* now, despite ANSI C warning: */ while ((csound->ids = csound->ids->nxti) != NULL && - (csound->ids->iopadr != (SUBR) rireturn)) - (*csound->ids->iopadr)(csound, csound->ids); + (csound->ids->init != (SUBR) rireturn)) + (*csound->ids->init)(csound, csound->ids); csound->reinitflag = p->h.insdshead->reinitflag = 0; } else { @@ -204,7 +206,7 @@ int32_t turnoff2(CSOUND *csound, TURNOFF2 *p, int32_t isStringArg) insno = (int32_t) p1; if (UNLIKELY(insno < 1 || insno > (int32_t) csound->engineState.maxinsno || csound->engineState.instrtxtp[insno] == NULL)) { - if(p->h.iopadr == NULL) + if(p->h.init == NULL) return csoundPerfError(csound, &(p->h), Str("turnoff2: invalid instrument number")); else return csoundInitError(csound, @@ -214,7 +216,7 @@ int32_t turnoff2(CSOUND *csound, TURNOFF2 *p, int32_t isStringArg) mode = (int32_t) (*(p->kFlags) + FL(0.5)); allow_release = (*(p->kRelease) == FL(0.0) ? 0 : 1); if (UNLIKELY(mode < 0 || mode > 15 || (mode & 3) == 3)) { - if(p->h.iopadr == NULL) + if(p->h.init == NULL) return csoundPerfError(csound, &(p->h), Str("turnoff2: invalid mode parameter")); else csoundInitError(csound, diff --git a/OOps/ugens2.c b/OOps/ugens2.c index 899147d0a0d..27632b3cd55 100644 --- a/OOps/ugens2.c +++ b/OOps/ugens2.c @@ -186,6 +186,7 @@ int32_t phsor(CSOUND *csound, PHSOR *p) return OK; } + int32_t ko1set(CSOUND *csound, OSCIL1 *p) { FUNC *ftp; @@ -955,50 +956,50 @@ int32_t kposc3(CSOUND *csound, OSC *p) return OK; } -static void reassign_opadr(CSOUND *csound, OSC *p) { +static void reassign_perf(CSOUND *csound, OSC *p) { const char* name = p->h.optext->t.opcod; // check for arg types and change PDS if(!strcmp(name, "oscil")) { if(IS_ASIG_ARG(p->sr)) { if(IS_ASIG_ARG(p->xamp) && IS_ASIG_ARG(p->xcps)) // aa - p->h.opadr = (SUBR) poscaat; + p->h.perf = (SUBR) poscaat; else if(IS_ASIG_ARG(p->xamp)) // ak - p->h.opadr = (SUBR) poscakt; + p->h.perf = (SUBR) poscakt; else if(IS_ASIG_ARG(p->xcps)) // ka - p->h.opadr = (SUBR) posckat; + p->h.perf = (SUBR) posckat; else // kk - p->h.opadr = (SUBR) posckkt; + p->h.perf = (SUBR) posckkt; } else // kosc - p->h.opadr = (SUBR) kposct; + p->h.perf = (SUBR) kposct; } else if(!strcmp(name, "oscili")) { if(IS_ASIG_ARG(p->sr)) { if(IS_ASIG_ARG(p->xamp) && IS_ASIG_ARG(p->xcps)) // aa - p->h.opadr = (SUBR) poscaa; + p->h.perf = (SUBR) poscaa; else if(IS_ASIG_ARG(p->xamp)) // ak - p->h.opadr = (SUBR) poscak; + p->h.perf = (SUBR) poscak; else if(IS_ASIG_ARG(p->xcps)) // ka - p->h.opadr = (SUBR) poscka; + p->h.perf = (SUBR) poscka; else // kk - p->h.opadr = (SUBR) posckk; + p->h.perf = (SUBR) posckk; } else // kosc - p->h.opadr = (SUBR) kposc; + p->h.perf = (SUBR) kposc; } else { // oscil3 if(IS_ASIG_ARG(p->sr)) { if(IS_ASIG_ARG(p->xamp) && IS_ASIG_ARG(p->xcps)) // aa - p->h.opadr = (SUBR) poscaa; + p->h.perf = (SUBR) poscaa; else if(IS_ASIG_ARG(p->xamp)) // ak - p->h.opadr = (SUBR) poscak; + p->h.perf = (SUBR) poscak; else if(IS_ASIG_ARG(p->xcps)) // ka - p->h.opadr = (SUBR) poscka; + p->h.perf = (SUBR) poscka; else // kk - p->h.opadr = (SUBR) posckk; + p->h.perf = (SUBR) posckk; } else // kosc - p->h.opadr = (SUBR) kposc; + p->h.perf = (SUBR) kposc; } } -// this may select different opadr if non-pow of two is used. +// this may select different perf if non-pow of two is used. int32_t oscset(CSOUND *csound, OSC *p) { FUNC *ftp; @@ -1010,7 +1011,7 @@ int32_t oscset(CSOUND *csound, OSC *p) p->lphs = ((int32_t)(*p->iphs * FMAXLEN)) & PHMASK; return OK; } - reassign_opadr(csound, p); + reassign_perf(csound, p); return posc_set(csound,p); } @@ -1060,7 +1061,7 @@ int32_t oscsetA(CSOUND *csound, OSC *p) p->phs = *p->iphs * p->tablen; while (UNLIKELY(p->phs >= p->tablen)) p->phs -= p->tablen; - reassign_opadr(csound, p); + reassign_perf(csound, p); return OK; } diff --git a/Opcodes/OSC.c b/Opcodes/OSC.c index ac271c62391..cbecc80f23f 100644 --- a/Opcodes/OSC.c +++ b/Opcodes/OSC.c @@ -188,8 +188,6 @@ static int32_t osc_send_set(CSOUND *csound, OSCSEND *p) if (UNLIKELY(p->multicast)) lo_address_set_ttl(p->addr, 1); p->cnt = 0; p->last = 0; - csound->RegisterDeinitCallback(csound, p, - (int32_t (*)(CSOUND *, void *)) oscsend_deinit); p->thread = NULL; return OK; } @@ -628,8 +626,8 @@ static int32_t osc_listener_init(CSOUND *csound, OSCINIT *p) pp->nPorts = n + 1; csound->Warning(csound, Str("OSC listener #%d started on port %s\n"), n, buff); *(p->ihandle) = (MYFLT) n; - csound->RegisterDeinitCallback(csound, p, - (int32_t (*)(CSOUND *, void *)) OSC_deinit); + //csound->RegisterDeinitCallback(csound, p, + // (int32_t (*)(CSOUND *, void *)) OSC_deinit); return OK; } @@ -666,8 +664,7 @@ static int32_t osc_listener_initMulti(CSOUND *csound, OSCINITM *p) Str("OSC multicast listener #%d started on port %s\n"), n, buff); *(p->ihandle) = (MYFLT) n; - csound->RegisterDeinitCallback(csound, p, - (int32_t (*)(CSOUND *, void *)) OSC_deinit); + return OK; } @@ -789,8 +786,6 @@ static int32_t OSC_list_init(CSOUND *csound, OSCLISTEN *p) p->c.method = lo_server_thread_add_method(p->port->thread, p->c.saved_path, p->c.saved_types, OSC_handler, p->port); - csound->RegisterDeinitCallback(csound, p, - (int32_t (*)(CSOUND *, void *)) OSC_listdeinit); return OK; } @@ -1069,8 +1064,6 @@ static int32_t OSC_alist_init(CSOUND *csound, OSCLISTENA *p) p->c.method = lo_server_thread_add_method(p->port->thread, p->c.saved_path, p->c.saved_types, OSC_ahandler, p->port); - csound->RegisterDeinitCallback(csound, p, - (int32_t (*)(CSOUND *, void *)) OSC_listadeinit); return OK; } @@ -1115,19 +1108,19 @@ static int32_t OSC_alist(CSOUND *csound, OSCLISTENA *p) #define S(x) sizeof(x) static OENTRY localops[] = { - { "OSCsend_lo", S(OSCSEND), 0, 3, "", "kSkSN", - (SUBR)osc_send_set, (SUBR)osc_send, NULL,NULL }, - { "OSCinit", S(OSCINIT), 0, 1, "i", "i", - (SUBR)osc_listener_init, NULL, NULL, NULL }, - { "OSCinitM", S(OSCINITM), 0, 1, "i", "Si", - (SUBR)osc_listener_initMulti, NULL, NULL, NULL }, - { "OSClisten", S(OSCLISTEN),0, 3, "k", "iSSN", - (SUBR)OSC_list_init, (SUBR)OSC_list, NULL, NULL }, - { "OSClisten", S(OSCLISTEN),0, 3, "k", "iSS", - (SUBR)OSC_list_init, (SUBR)OSC_list, NULL, NULL }, - { "OSClisten", S(OSCLISTENA),0, 3, "kk[]", "iSS", - (SUBR)OSC_alist_init, (SUBR)OSC_alist, NULL, NULL }, - { "OSCcount", S(OSCcount), 0, 3, "k", "", + { "OSCsend_lo", S(OSCSEND), 0, "", "kSkSN", + (SUBR)osc_send_set, (SUBR)osc_send, (SUBR) oscsend_deinit, NULL }, + { "OSCinit", S(OSCINIT), 0, "i", "i", + (SUBR)osc_listener_init, NULL, (SUBR) OSC_deinit , NULL }, + { "OSCinitM", S(OSCINITM), 0, "i", "Si", + (SUBR)osc_listener_initMulti, NULL, (SUBR) OSC_deinit , NULL }, + { "OSClisten", S(OSCLISTEN),0, "k", "iSSN", + (SUBR)OSC_list_init, (SUBR)OSC_list, (SUBR) OSC_listdeinit, NULL }, + { "OSClisten", S(OSCLISTEN),0, "k", "iSS", + (SUBR)OSC_list_init, (SUBR)OSC_list, (SUBR) OSC_listdeinit, NULL }, + { "OSClisten", S(OSCLISTENA),0, "kk[]", "iSS", + (SUBR)OSC_alist_init, (SUBR)OSC_alist, (SUBR) OSC_listadeinit, NULL }, + { "OSCcount", S(OSCcount), 0, "k", "", (SUBR)OSCcounter, (SUBR)OSCcounter, NULL } }; diff --git a/Opcodes/OpcodeBase.hpp b/Opcodes/OpcodeBase.hpp index 9a8b78a1b5b..364de804b9a 100644 --- a/Opcodes/OpcodeBase.hpp +++ b/Opcodes/OpcodeBase.hpp @@ -254,14 +254,20 @@ class OpcodeNoteoffBase IGN(csound); return NOTOK; } + + static int deinit_(CSOUND *csound, void *opcode) + { + if (!csound->GetReinitFlag(csound) && !csound->GetTieFlag(csound)) { + return noteoff_(csound, opcode); + } + return OK; + } + static int init_(CSOUND *csound, void *opcode) { - if (!csound->GetReinitFlag(csound) && !csound->GetTieFlag(csound)) { - csound->RegisterDeinitCallback(csound, opcode, - &OpcodeNoteoffBase::noteoff_); - } return reinterpret_cast(opcode)->init(csound); } + int kontrol(CSOUND *csound) { IGN(csound); diff --git a/Opcodes/Vosim.c b/Opcodes/Vosim.c index 5803a63e3f5..3f67de815bf 100644 --- a/Opcodes/Vosim.c +++ b/Opcodes/Vosim.c @@ -224,7 +224,7 @@ int32_t vosim(CSOUND* csound, VOSIM *p) #define S(x) sizeof(x) static OENTRY vosim_localops[] = { - { "vosim", S(VOSIM), TR, 3, "a", "kkkkkkio", (SUBR)vosimset, (SUBR)vosim } + { "vosim", S(VOSIM), TR, "a", "kkkkkkio", (SUBR)vosimset, (SUBR)vosim } }; diff --git a/Opcodes/afilters.c b/Opcodes/afilters.c index 3a0f141cb74..1da133ae3d0 100644 --- a/Opcodes/afilters.c +++ b/Opcodes/afilters.c @@ -1,24 +1,24 @@ /* - afilters.c: + afilters.c: - Copyright (C) 1991 Barry Vercoe, John ffitch, Gabriel Maldonado + Copyright (C) 1991 Barry Vercoe, John ffitch, Gabriel Maldonado - This file is part of Csound. + This file is part of Csound. - The Csound Library is free software; you can redistribute it - and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + The Csound Library is free software; you can redistribute it + and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - Csound is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. + Csound is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with Csound; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - 02110-1301 USA + You should have received a copy of the GNU Lesser General Public + License along with Csound; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + 02110-1301 USA */ #ifdef BUILD_PLUGINS @@ -32,308 +32,308 @@ static int32_t atonset(CSOUND *csound, TONE *p) { - double b; - p->prvhp = (double)*p->khp; - b = 2.0 - cos((double)(p->prvhp * CS_TPIDSR)); - p->c2 = b - sqrt(b * b - 1.0); - p->c1 = 1.0 - p->c2; - - if (LIKELY(!(*p->istor))) - p->yt1 = 0.0; - return OK; + double b; + p->prvhp = (double)*p->khp; + b = 2.0 - cos((double)(p->prvhp * CS_TPIDSR)); + p->c2 = b - sqrt(b * b - 1.0); + p->c1 = 1.0 - p->c2; + + if (LIKELY(!(*p->istor))) + p->yt1 = 0.0; + return OK; } static int32_t atonsetx(CSOUND *csound, TONEX *p) { /* From Gabriel Maldonado, modified for arbitrary order */ - { - double b; - p->prvhp = *p->khp; - b = 2.0 - cos((double)(*p->khp * CS_TPIDSR)); - p->c2 = b - sqrt(b * b - 1.0); - p->c1 = 1.0 - p->c2; - } - if (UNLIKELY((p->loop = (int32_t) (*p->ord + FL(0.5))) < 1)) p->loop = 4; - if (!*p->istor && (p->aux.auxp == NULL || - (uint32_t)(p->loop*sizeof(double)) > p->aux.size)) - csound->AuxAlloc(csound, (int32_t)(p->loop*sizeof(double)), &p->aux); - p->yt1 = (double*)p->aux.auxp; - if (LIKELY(!(*p->istor))) { + { + double b; + p->prvhp = *p->khp; + b = 2.0 - cos((double)(*p->khp * CS_TPIDSR)); + p->c2 = b - sqrt(b * b - 1.0); + p->c1 = 1.0 - p->c2; + } + if (UNLIKELY((p->loop = (int32_t) (*p->ord + FL(0.5))) < 1)) p->loop = 4; + if (!*p->istor && (p->aux.auxp == NULL || + (uint32_t)(p->loop*sizeof(double)) > p->aux.size)) + csound->AuxAlloc(csound, (int32_t)(p->loop*sizeof(double)), &p->aux); + p->yt1 = (double*)p->aux.auxp; + if (LIKELY(!(*p->istor))) { memset(p->yt1, 0, p->loop*sizeof(double)); /* Punning zero and 0.0 */ - } - return OK; + } + return OK; } static int32_t arsnset(CSOUND *csound, RESON *p) { - int32_t scale; - p->scale = scale = (int32_t)*p->iscl; - if (UNLIKELY(scale && scale != 1 && scale != 2)) { - return csound->InitError(csound, Str("illegal reson iscl value, %f"), - *p->iscl); - } - p->prvcf = p->prvbw = -100.0; - if (!(*p->istor)) - p->yt1 = p->yt2 = 0.0; - p->asigf = IS_ASIG_ARG(p->kcf); - p->asigw = IS_ASIG_ARG(p->kbw); - - return OK; + int32_t scale; + p->scale = scale = (int32_t)*p->iscl; + if (UNLIKELY(scale && scale != 1 && scale != 2)) { + return csound->InitError(csound, Str("illegal reson iscl value, %f"), + *p->iscl); + } + p->prvcf = p->prvbw = -100.0; + if (!(*p->istor)) + p->yt1 = p->yt2 = 0.0; + p->asigf = IS_ASIG_ARG(p->kcf); + p->asigw = IS_ASIG_ARG(p->kbw); + + return OK; } static int32_t aresonaa(CSOUND *csound, RESON *p) { - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t flag = 0, n, nsmps = CS_KSMPS; - MYFLT *ar, *asig; - double c3p1, c3t4, omc3, c2sqr; /* 1/RMS = root2 (rand) */ - /* or 1/.5 (sine) */ - double yt1, yt2, c1, c2, c3; - - asig = p->asig; - ar = p->ar; - if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - nsmps -= early; - memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); - } - c1 = p->c1; c2 = p->c2; c3 = p->c3; yt1 = p->yt1; yt2 = p->yt2; - if (p->scale == 1 || p->scale == 0) { - for (n=offset; nkcf[n] != (MYFLT)p->prvcf) { - p->prvcf = (double)p->kcf[n]; - p->cosf = cos(p->prvcf * (double)(CS_TPIDSR)); - flag = 1; - } - if (p->kbw[n] != (MYFLT)p->prvbw) { - p->prvbw = (double)p->kbw[n]; - p->c3 = exp(p->prvbw * (double)(CS_MTPIDSR)); - flag = 1; - } - if (flag) { - c3p1 = p->c3 + 1.0; - c3t4 = p->c3 * 4.0; - omc3 = 1.0 - p->c3; - p->c2 = c3t4 * p->cosf / c3p1; - c2sqr = p->c2 * p->c2; - if (p->scale == 1) /* i.e. 1 - A(reson) */ - p->c1 = 1.0 - omc3 * sqrt(1.0 - c2sqr / c3t4); - else if (p->scale == 2) /* i.e. D - A(reson) */ - p->c1 = 2.0 - sqrt((c3p1*c3p1-c2sqr)*omc3/c3p1); - else p->c1 = 0.0; /* cannot tell */ - } - ans = c1 * sig + c2 * yt1 - c3 * yt2; - yt2 = yt1; - yt1 = ans - sig; /* yt1 contains yt1-xt1 */ - ar[n] = (MYFLT)ans; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t flag = 0, n, nsmps = CS_KSMPS; + MYFLT *ar, *asig; + double c3p1, c3t4, omc3, c2sqr; /* 1/RMS = root2 (rand) */ + /* or 1/.5 (sine) */ + double yt1, yt2, c1, c2, c3; + + asig = p->asig; + ar = p->ar; + if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + nsmps -= early; + memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); + } + c1 = p->c1; c2 = p->c2; c3 = p->c3; yt1 = p->yt1; yt2 = p->yt2; + if (p->scale == 1 || p->scale == 0) { + for (n=offset; nkcf[n] != (MYFLT)p->prvcf) { + p->prvcf = (double)p->kcf[n]; + p->cosf = cos(p->prvcf * (double)(CS_TPIDSR)); + flag = 1; } - } - else if (p->scale == 2) { - for (n=offset; nkcf[n] != (MYFLT)p->prvcf) { - p->prvcf = (double)p->kcf[n]; - p->cosf = cos(p->prvcf * (double)(CS_TPIDSR)); - flag = 1; - } - if (p->kbw[n] != (MYFLT)p->prvbw) { - p->prvbw = (double)p->kbw[n]; - p->c3 = exp(p->prvbw * (double)(CS_MTPIDSR)); - flag = 1; - } - if (flag) { - c3p1 = p->c3 + 1.0; - c3t4 = p->c3 * 4.0; - omc3 = 1.0 - p->c3; - p->c2 = c3t4 * p->cosf / c3p1; - c2sqr = p->c2 * p->c2; - if (p->scale == 1) /* i.e. 1 - A(reson) */ - p->c1 = 1.0 - omc3 * sqrt(1.0 - c2sqr / c3t4); - else if (p->scale == 2) /* i.e. D - A(reson) */ - p->c1 = 2.0 - sqrt((c3p1*c3p1-c2sqr)*omc3/c3p1); - else p->c1 = 0.0; /* cannot tell */ - } - ans = c1 * sig + c2 * yt1 - c3 * yt2; - yt2 = yt1; - yt1 = ans - 2.0 * sig; /* yt1 contains yt1-D*xt1 */ - ar[n] = (MYFLT)ans; + if (p->kbw[n] != (MYFLT)p->prvbw) { + p->prvbw = (double)p->kbw[n]; + p->c3 = exp(p->prvbw * (double)(CS_MTPIDSR)); + flag = 1; + } + if (flag) { + c3p1 = p->c3 + 1.0; + c3t4 = p->c3 * 4.0; + omc3 = 1.0 - p->c3; + p->c2 = c3t4 * p->cosf / c3p1; + c2sqr = p->c2 * p->c2; + if (p->scale == 1) /* i.e. 1 - A(reson) */ + p->c1 = 1.0 - omc3 * sqrt(1.0 - c2sqr / c3t4); + else if (p->scale == 2) /* i.e. D - A(reson) */ + p->c1 = 2.0 - sqrt((c3p1*c3p1-c2sqr)*omc3/c3p1); + else p->c1 = 0.0; /* cannot tell */ } + ans = c1 * sig + c2 * yt1 - c3 * yt2; + yt2 = yt1; + yt1 = ans - sig; /* yt1 contains yt1-xt1 */ + ar[n] = (MYFLT)ans; } - p->yt1 = yt1; p->yt2 = yt2; - return OK; + } + else if (p->scale == 2) { + for (n=offset; nkcf[n] != (MYFLT)p->prvcf) { + p->prvcf = (double)p->kcf[n]; + p->cosf = cos(p->prvcf * (double)(CS_TPIDSR)); + flag = 1; + } + if (p->kbw[n] != (MYFLT)p->prvbw) { + p->prvbw = (double)p->kbw[n]; + p->c3 = exp(p->prvbw * (double)(CS_MTPIDSR)); + flag = 1; + } + if (flag) { + c3p1 = p->c3 + 1.0; + c3t4 = p->c3 * 4.0; + omc3 = 1.0 - p->c3; + p->c2 = c3t4 * p->cosf / c3p1; + c2sqr = p->c2 * p->c2; + if (p->scale == 1) /* i.e. 1 - A(reson) */ + p->c1 = 1.0 - omc3 * sqrt(1.0 - c2sqr / c3t4); + else if (p->scale == 2) /* i.e. D - A(reson) */ + p->c1 = 2.0 - sqrt((c3p1*c3p1-c2sqr)*omc3/c3p1); + else p->c1 = 0.0; /* cannot tell */ + } + ans = c1 * sig + c2 * yt1 - c3 * yt2; + yt2 = yt1; + yt1 = ans - 2.0 * sig; /* yt1 contains yt1-D*xt1 */ + ar[n] = (MYFLT)ans; + } + } + p->yt1 = yt1; p->yt2 = yt2; + return OK; } static int32_t aresonak(CSOUND *csound, RESON *p) { - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t n, nsmps = CS_KSMPS; - MYFLT *ar, *asig; - double c3p1, c3t4, omc3, c2sqr; /* 1/RMS = root2 (rand) */ - /* or 1/.5 (sine) */ - double yt1, yt2, c1, c2, c3; - - if (*p->kbw != (MYFLT)p->prvbw) { - p->prvbw = (double)*p->kbw; - p->c3 = exp(p->prvbw * (double)(CS_MTPIDSR)); - c3p1 = p->c3 + 1.0; - c3t4 = p->c3 * 4.0; - omc3 = 1.0 - p->c3; - p->c2 = c3t4 * p->cosf / c3p1; - c2sqr = p->c2 * p->c2; - if (p->scale == 1) /* i.e. 1 - A(reson) */ - p->c1 = 1.0 - omc3 * sqrt(1.0 - c2sqr / c3t4); - else if (p->scale == 2) /* i.e. D - A(reson) */ - p->c1 = 2.0 - sqrt((c3p1*c3p1-c2sqr)*omc3/c3p1); - else p->c1 = 0.0; /* cannot tell */ - } - asig = p->asig; - ar = p->ar; - if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - nsmps -= early; - memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); - } - c1 = p->c1; c2 = p->c2; c3 = p->c3; yt1 = p->yt1; yt2 = p->yt2; - if (p->scale == 1 || p->scale == 0) { - for (n=offset; nkcf[n] != (MYFLT)p->prvcf) { - p->prvcf = (double)p->kcf[n]; - p->cosf = cos(p->prvcf * (double)(CS_TPIDSR)); - c3p1 = p->c3 + 1.0; - c3t4 = p->c3 * 4.0; - omc3 = 1.0 - p->c3; - p->c2 = c3t4 * p->cosf / c3p1; - c2sqr = p->c2 * p->c2; - if (p->scale == 1) /* i.e. 1 - A(reson) */ - p->c1 = 1.0 - omc3 * sqrt(1.0 - c2sqr / c3t4); - else if (p->scale == 2) /* i.e. D - A(reson) */ - p->c1 = 2.0 - sqrt((c3p1*c3p1-c2sqr)*omc3/c3p1); - else p->c1 = 0.0; /* cannot tell */ - } - ans = c1 * sig + c2 * yt1 - c3 * yt2; - yt2 = yt1; - yt1 = ans - sig; /* yt1 contains yt1-xt1 */ - ar[n] = (MYFLT)ans; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t n, nsmps = CS_KSMPS; + MYFLT *ar, *asig; + double c3p1, c3t4, omc3, c2sqr; /* 1/RMS = root2 (rand) */ + /* or 1/.5 (sine) */ + double yt1, yt2, c1, c2, c3; + + if (*p->kbw != (MYFLT)p->prvbw) { + p->prvbw = (double)*p->kbw; + p->c3 = exp(p->prvbw * (double)(CS_MTPIDSR)); + c3p1 = p->c3 + 1.0; + c3t4 = p->c3 * 4.0; + omc3 = 1.0 - p->c3; + p->c2 = c3t4 * p->cosf / c3p1; + c2sqr = p->c2 * p->c2; + if (p->scale == 1) /* i.e. 1 - A(reson) */ + p->c1 = 1.0 - omc3 * sqrt(1.0 - c2sqr / c3t4); + else if (p->scale == 2) /* i.e. D - A(reson) */ + p->c1 = 2.0 - sqrt((c3p1*c3p1-c2sqr)*omc3/c3p1); + else p->c1 = 0.0; /* cannot tell */ + } + asig = p->asig; + ar = p->ar; + if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + nsmps -= early; + memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); + } + c1 = p->c1; c2 = p->c2; c3 = p->c3; yt1 = p->yt1; yt2 = p->yt2; + if (p->scale == 1 || p->scale == 0) { + for (n=offset; nkcf[n] != (MYFLT)p->prvcf) { + p->prvcf = (double)p->kcf[n]; + p->cosf = cos(p->prvcf * (double)(CS_TPIDSR)); + c3p1 = p->c3 + 1.0; + c3t4 = p->c3 * 4.0; + omc3 = 1.0 - p->c3; + p->c2 = c3t4 * p->cosf / c3p1; + c2sqr = p->c2 * p->c2; + if (p->scale == 1) /* i.e. 1 - A(reson) */ + p->c1 = 1.0 - omc3 * sqrt(1.0 - c2sqr / c3t4); + else if (p->scale == 2) /* i.e. D - A(reson) */ + p->c1 = 2.0 - sqrt((c3p1*c3p1-c2sqr)*omc3/c3p1); + else p->c1 = 0.0; /* cannot tell */ } + ans = c1 * sig + c2 * yt1 - c3 * yt2; + yt2 = yt1; + yt1 = ans - sig; /* yt1 contains yt1-xt1 */ + ar[n] = (MYFLT)ans; } - else if (p->scale == 2) { - for (n=offset; nkcf[n] != (MYFLT)p->prvcf) { - p->prvcf = (double)p->kcf[n]; - p->cosf = cos(p->prvcf * (double)(CS_TPIDSR)); - c3p1 = p->c3 + 1.0; - c3t4 = p->c3 * 4.0; - omc3 = 1.0 - p->c3; - p->c2 = c3t4 * p->cosf / c3p1; - c2sqr = p->c2 * p->c2; - if (p->scale == 1) /* i.e. 1 - A(reson) */ - p->c1 = 1.0 - omc3 * sqrt(1.0 - c2sqr / c3t4); - else if (p->scale == 2) /* i.e. D - A(reson) */ - p->c1 = 2.0 - sqrt((c3p1*c3p1-c2sqr)*omc3/c3p1); - else p->c1 = 0.0; /* cannot tell */ - } - ans = c1 * sig + c2 * yt1 - c3 * yt2; - yt2 = yt1; - yt1 = ans - 2.0 * sig; /* yt1 contains yt1-D*xt1 */ - ar[n] = (MYFLT)ans; + } + else if (p->scale == 2) { + for (n=offset; nkcf[n] != (MYFLT)p->prvcf) { + p->prvcf = (double)p->kcf[n]; + p->cosf = cos(p->prvcf * (double)(CS_TPIDSR)); + c3p1 = p->c3 + 1.0; + c3t4 = p->c3 * 4.0; + omc3 = 1.0 - p->c3; + p->c2 = c3t4 * p->cosf / c3p1; + c2sqr = p->c2 * p->c2; + if (p->scale == 1) /* i.e. 1 - A(reson) */ + p->c1 = 1.0 - omc3 * sqrt(1.0 - c2sqr / c3t4); + else if (p->scale == 2) /* i.e. D - A(reson) */ + p->c1 = 2.0 - sqrt((c3p1*c3p1-c2sqr)*omc3/c3p1); + else p->c1 = 0.0; /* cannot tell */ } - } - p->yt1 = yt1; p->yt2 = yt2; - return OK; + ans = c1 * sig + c2 * yt1 - c3 * yt2; + yt2 = yt1; + yt1 = ans - 2.0 * sig; /* yt1 contains yt1-D*xt1 */ + ar[n] = (MYFLT)ans; + } + } + p->yt1 = yt1; p->yt2 = yt2; + return OK; } static int32_t aresonka(CSOUND *csound, RESON *p) { - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t n, nsmps = CS_KSMPS; - MYFLT *ar, *asig; - double c3p1, c3t4, omc3, c2sqr; /* 1/RMS = root2 (rand) */ - /* or 1/.5 (sine) */ - double yt1, yt2, c1, c2, c3; - - if (*p->kcf != (MYFLT)p->prvcf) { - p->prvcf = (double)*p->kcf; - p->cosf = cos(p->prvcf * (double)(CS_TPIDSR)); - c3p1 = p->c3 + 1.0; - c3t4 = p->c3 * 4.0; - omc3 = 1.0 - p->c3; - p->c2 = c3t4 * p->cosf / c3p1; - c2sqr = p->c2 * p->c2; - if (p->scale == 1) /* i.e. 1 - A(reson) */ - p->c1 = 1.0 - omc3 * sqrt(1.0 - c2sqr / c3t4); - else if (p->scale == 2) /* i.e. D - A(reson) */ - p->c1 = 2.0 - sqrt((c3p1*c3p1-c2sqr)*omc3/c3p1); - else p->c1 = 0.0; /* cannot tell */ - } - asig = p->asig; - ar = p->ar; - if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - nsmps -= early; - memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); - } - c1 = p->c1; c2 = p->c2; c3 = p->c3; yt1 = p->yt1; yt2 = p->yt2; - if (p->scale == 1 || p->scale == 0) { - for (n=offset; nkbw[n] != (MYFLT)p->prvbw) { - p->prvbw = (double)p->kbw[n]; - p->c3 = exp(p->prvbw * (double)(CS_MTPIDSR)); - c3p1 = p->c3 + 1.0; - c3t4 = p->c3 * 4.0; - omc3 = 1.0 - p->c3; - p->c2 = c3t4 * p->cosf / c3p1; - c2sqr = p->c2 * p->c2; - if (p->scale == 1) /* i.e. 1 - A(reson) */ - p->c1 = 1.0 - omc3 * sqrt(1.0 - c2sqr / c3t4); - else if (p->scale == 2) /* i.e. D - A(reson) */ - p->c1 = 2.0 - sqrt((c3p1*c3p1-c2sqr)*omc3/c3p1); - else p->c1 = 0.0; /* cannot tell */ - } - ans = c1 * sig + c2 * yt1 - c3 * yt2; - yt2 = yt1; - yt1 = ans - sig; /* yt1 contains yt1-xt1 */ - ar[n] = (MYFLT)ans; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t n, nsmps = CS_KSMPS; + MYFLT *ar, *asig; + double c3p1, c3t4, omc3, c2sqr; /* 1/RMS = root2 (rand) */ + /* or 1/.5 (sine) */ + double yt1, yt2, c1, c2, c3; + + if (*p->kcf != (MYFLT)p->prvcf) { + p->prvcf = (double)*p->kcf; + p->cosf = cos(p->prvcf * (double)(CS_TPIDSR)); + c3p1 = p->c3 + 1.0; + c3t4 = p->c3 * 4.0; + omc3 = 1.0 - p->c3; + p->c2 = c3t4 * p->cosf / c3p1; + c2sqr = p->c2 * p->c2; + if (p->scale == 1) /* i.e. 1 - A(reson) */ + p->c1 = 1.0 - omc3 * sqrt(1.0 - c2sqr / c3t4); + else if (p->scale == 2) /* i.e. D - A(reson) */ + p->c1 = 2.0 - sqrt((c3p1*c3p1-c2sqr)*omc3/c3p1); + else p->c1 = 0.0; /* cannot tell */ + } + asig = p->asig; + ar = p->ar; + if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + nsmps -= early; + memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); + } + c1 = p->c1; c2 = p->c2; c3 = p->c3; yt1 = p->yt1; yt2 = p->yt2; + if (p->scale == 1 || p->scale == 0) { + for (n=offset; nkbw[n] != (MYFLT)p->prvbw) { + p->prvbw = (double)p->kbw[n]; + p->c3 = exp(p->prvbw * (double)(CS_MTPIDSR)); + c3p1 = p->c3 + 1.0; + c3t4 = p->c3 * 4.0; + omc3 = 1.0 - p->c3; + p->c2 = c3t4 * p->cosf / c3p1; + c2sqr = p->c2 * p->c2; + if (p->scale == 1) /* i.e. 1 - A(reson) */ + p->c1 = 1.0 - omc3 * sqrt(1.0 - c2sqr / c3t4); + else if (p->scale == 2) /* i.e. D - A(reson) */ + p->c1 = 2.0 - sqrt((c3p1*c3p1-c2sqr)*omc3/c3p1); + else p->c1 = 0.0; /* cannot tell */ } + ans = c1 * sig + c2 * yt1 - c3 * yt2; + yt2 = yt1; + yt1 = ans - sig; /* yt1 contains yt1-xt1 */ + ar[n] = (MYFLT)ans; } - else if (p->scale == 2) { - for (n=offset; nkbw[n] != (MYFLT)p->prvbw) { - p->prvbw = (double)p->kbw[n]; - p->c3 = exp(p->prvbw * (double)(CS_MTPIDSR)); - c3p1 = p->c3 + 1.0; - c3t4 = p->c3 * 4.0; - omc3 = 1.0 - p->c3; - p->c2 = c3t4 * p->cosf / c3p1; - c2sqr = p->c2 * p->c2; - if (p->scale == 1) /* i.e. 1 - A(reson) */ - p->c1 = 1.0 - omc3 * sqrt(1.0 - c2sqr / c3t4); - else if (p->scale == 2) /* i.e. D - A(reson) */ - p->c1 = 2.0 - sqrt((c3p1*c3p1-c2sqr)*omc3/c3p1); - else p->c1 = 0.0; /* cannot tell */ - } - ans = c1 * sig + c2 * yt1 - c3 * yt2; - yt2 = yt1; - yt1 = ans - 2.0 * sig; /* yt1 contains yt1-D*xt1 */ - ar[n] = (MYFLT)ans; + } + else if (p->scale == 2) { + for (n=offset; nkbw[n] != (MYFLT)p->prvbw) { + p->prvbw = (double)p->kbw[n]; + p->c3 = exp(p->prvbw * (double)(CS_MTPIDSR)); + c3p1 = p->c3 + 1.0; + c3t4 = p->c3 * 4.0; + omc3 = 1.0 - p->c3; + p->c2 = c3t4 * p->cosf / c3p1; + c2sqr = p->c2 * p->c2; + if (p->scale == 1) /* i.e. 1 - A(reson) */ + p->c1 = 1.0 - omc3 * sqrt(1.0 - c2sqr / c3t4); + else if (p->scale == 2) /* i.e. D - A(reson) */ + p->c1 = 2.0 - sqrt((c3p1*c3p1-c2sqr)*omc3/c3p1); + else p->c1 = 0.0; /* cannot tell */ } - } - p->yt1 = yt1; p->yt2 = yt2; - return OK; + ans = c1 * sig + c2 * yt1 - c3 * yt2; + yt2 = yt1; + yt1 = ans - 2.0 * sig; /* yt1 contains yt1-D*xt1 */ + ar[n] = (MYFLT)ans; + } + } + p->yt1 = yt1; p->yt2 = yt2; + return OK; } extern int32_t tonset(CSOUND*, TONE*); @@ -341,423 +341,402 @@ extern int32_t tonsetx(CSOUND *csound, TONEX *p); static int32_t atonea(CSOUND *csound, TONE *p) { - MYFLT *ar, *asig; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t n, nsmps = CS_KSMPS; - double c2 = p->c2, yt1 = p->yt1; - - ar = p->ar; - if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - nsmps -= early; - memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); - } - asig = p->asig; - for (n=offset; nkhp[n] != p->prvhp) { - double b; - p->prvhp = p->khp[n]; - b = 2.0 - cos((double)(p->khp[n] * CS_TPIDSR)); - p->c2 = c2 = b - sqrt(b * b - 1.0); - /* p->c1 = c1 = 1.0 - c2; */ - } - x = yt1 = c2 * (yt1 + sig); - ar[n] = (MYFLT)x; - yt1 -= sig; /* yt1 contains yt1-xt1 */ - } - p->yt1 = yt1; - return OK; + MYFLT *ar, *asig; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t n, nsmps = CS_KSMPS; + double c2 = p->c2, yt1 = p->yt1; + + ar = p->ar; + if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + nsmps -= early; + memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); + } + asig = p->asig; + for (n=offset; nkhp[n] != p->prvhp) { + double b; + p->prvhp = p->khp[n]; + b = 2.0 - cos((double)(p->khp[n] * CS_TPIDSR)); + p->c2 = c2 = b - sqrt(b * b - 1.0); + /* p->c1 = c1 = 1.0 - c2; */ + } + x = yt1 = c2 * (yt1 + sig); + ar[n] = (MYFLT)x; + yt1 -= sig; /* yt1 contains yt1-xt1 */ + } + p->yt1 = yt1; + return OK; } static int32_t tonea(CSOUND *csound, TONE *p) { - MYFLT *ar, *asig; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t n, nsmps = CS_KSMPS; - double c1 = p->c1, c2 = p->c2; - double yt1 = p->yt1; - double prvhp = p->prvhp; - - ar = p->ar; - asig = p->asig; - if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - nsmps -= early; - memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nkhp[n] != prvhp) { - double b; - prvhp = (double)p->khp[n]; - b = 2.0 - cos((double)(prvhp * CS_TPIDSR)); - c2 = b - sqrt(b * b - 1.0); - c1 = 1.0 - c2; - } - yt1 = c1 * (double)(asig[n]) + c2 * yt1; - ar[n] = (MYFLT)yt1; - } - p->yt1 = yt1; - p->prvhp = prvhp; - p->c1 = c1; - p->c2 = c2; - return OK; + MYFLT *ar, *asig; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t n, nsmps = CS_KSMPS; + double c1 = p->c1, c2 = p->c2; + double yt1 = p->yt1; + double prvhp = p->prvhp; + + ar = p->ar; + asig = p->asig; + if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + nsmps -= early; + memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); + } + for (n=offset; nkhp[n] != prvhp) { + double b; + prvhp = (double)p->khp[n]; + b = 2.0 - cos((double)(prvhp * CS_TPIDSR)); + c2 = b - sqrt(b * b - 1.0); + c1 = 1.0 - c2; + } + yt1 = c1 * (double)(asig[n]) + c2 * yt1; + ar[n] = (MYFLT)yt1; + } + p->yt1 = yt1; + p->prvhp = prvhp; + p->c1 = c1; + p->c2 = c2; + return OK; } static int32_t tonexa(CSOUND *csound, TONEX *p) /* From G Maldonado, modified */ { - MYFLT *ar = p->ar; - double c2 = p->c2, *yt1 = p->yt1,c1 = p->c1; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t n, nsmps = CS_KSMPS; - int32_t j, lp = p->loop; - - memmove(ar,p->asig,sizeof(MYFLT)*nsmps); - if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - nsmps -= early; - memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); - } - for (j=0; j< lp; j++) { - /* Should *yt1 be reset to something?? */ - for (n=offset; nkhp[n] != p->prvhp) { - double b; - p->prvhp = (double)p->khp[n]; - b = 2.0 - cos(p->prvhp * (double)CS_TPIDSR); - p->c2 = b - sqrt(b * b - 1.0); - p->c1 = 1.0 - p->c2; - } - x = c1 * ar[n] + c2 * yt1[j]; - yt1[j] = x; - ar[n] = (MYFLT)x; + MYFLT *ar = p->ar; + double c2 = p->c2, *yt1 = p->yt1,c1 = p->c1; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t n, nsmps = CS_KSMPS; + int32_t j, lp = p->loop; + + memmove(ar,p->asig,sizeof(MYFLT)*nsmps); + if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + nsmps -= early; + memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); + } + for (j=0; j< lp; j++) { + /* Should *yt1 be reset to something?? */ + for (n=offset; nkhp[n] != p->prvhp) { + double b; + p->prvhp = (double)p->khp[n]; + b = 2.0 - cos(p->prvhp * (double)CS_TPIDSR); + p->c2 = b - sqrt(b * b - 1.0); + p->c1 = 1.0 - p->c2; } + x = c1 * ar[n] + c2 * yt1[j]; + yt1[j] = x; + ar[n] = (MYFLT)x; } - return OK; + } + return OK; } static int32_t atonexa(CSOUND *csound, TONEX *p) /* Gabriel Maldonado, modified */ { - MYFLT *ar = p->ar; - double c2 = p->c2, *yt1 = p->yt1; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t n, nsmps = CS_KSMPS; - int32_t j, lp = p->loop; - MYFLT prvhp = p->prvhp; - - memmove(ar,p->asig,sizeof(MYFLT)*nsmps); - if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - nsmps -= early; - memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); - } - for (j=1; jkhp[n] != prvhp) { - double b; - prvhp = p->khp[n]; - b = 2.0 - cos((double)(p->prvhp * CS_TPIDSR)); - c2 = b - sqrt(b * b - 1.0); - } - x = c2 * (yt1[j] + sig); - yt1[j] = x - sig; /* yt1 contains yt1-xt1 */ - ar[n] = (MYFLT)x; + MYFLT *ar = p->ar; + double c2 = p->c2, *yt1 = p->yt1; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t n, nsmps = CS_KSMPS; + int32_t j, lp = p->loop; + MYFLT prvhp = p->prvhp; + + memmove(ar,p->asig,sizeof(MYFLT)*nsmps); + if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + nsmps -= early; + memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); + } + for (j=1; jkhp[n] != prvhp) { + double b; + prvhp = p->khp[n]; + b = 2.0 - cos((double)(p->prvhp * CS_TPIDSR)); + c2 = b - sqrt(b * b - 1.0); } + x = c2 * (yt1[j] + sig); + yt1[j] = x - sig; /* yt1 contains yt1-xt1 */ + ar[n] = (MYFLT)x; } - p->c2 = c2; - p->prvhp = prvhp; - return OK; + } + p->c2 = c2; + p->prvhp = prvhp; + return OK; } typedef struct { - OPDS h; - MYFLT *sr, *ain, *afc, *istor; - MYFLT lkf; - double a[8]; + OPDS h; + MYFLT *sr, *ain, *afc, *istor; + MYFLT lkf; + double a[8]; } BFIL; typedef struct { - OPDS h; - MYFLT *sr, *ain, *kfo, *kbw, *istor; - MYFLT lkf, lkb; - double a[8]; + OPDS h; + MYFLT *sr, *ain, *kfo, *kbw, *istor; + MYFLT lkf, lkb; + double a[8]; } BBFIL; //#define ROOT2 (1.4142135623730950488) static int32_t butseta(CSOUND *csound, BFIL *p) /* Hi/Lo pass set-up */ { - IGN(csound); - if (*p->istor==FL(0.0)) { - p->a[6] = p->a[7] = 0.0; - p->lkf = FL(0.0); - } - return OK; + IGN(csound); + if (*p->istor==FL(0.0)) { + p->a[6] = p->a[7] = 0.0; + p->lkf = FL(0.0); + } + return OK; } static int32_t bbutset(CSOUND *csound, BBFIL *p) /* Band set-up */ { - IGN(csound); - if (*p->istor==FL(0.0)) { - p->a[6] = p->a[7] = 0.0; - p->lkb = FL(0.0); - p->lkf = FL(0.0); - } - return OK; + IGN(csound); + if (*p->istor==FL(0.0)) { + p->a[6] = p->a[7] = 0.0; + p->lkb = FL(0.0); + p->lkf = FL(0.0); + } + return OK; } static int32_t hibuta(CSOUND *csound, BFIL *p) /* Hipass filter */ { - MYFLT *out, *in; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t nsmps = CS_KSMPS; - double *a; - double t, y; - uint32_t nn; - a = p->a; - - in = p->ain; - out = p->sr; - if (UNLIKELY(offset)) memset(out, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - nsmps -= early; - memset(&out[nsmps], '\0', early*sizeof(MYFLT)); - } - - if (UNLIKELY(p->afc[0] <= FL(0.0))) { - memcpy(&out[offset], &in[offset], (nsmps-offset)*sizeof(MYFLT)); - return OK; - } - - /* if (p->afc[0] != p->lkf) { */ - /* p->lkf = p->afc[0]; */ - /* c = tan((double)(CS_PIDSR * p->lkf)); */ - - /* a[1] = 1.0 / ( 1.0 + ROOT2 * c + c * c); */ - /* a[2] = -(a[1] + a[1]); */ - /* a[3] = a[1]; */ - /* a[4] = 2.0 * ( c*c - 1.0) * a[1]; */ - /* a[5] = ( 1.0 - ROOT2 * c + c * c) * a[1]; */ - /* } */ - for (nn=offset; nnafc[nn] != p->lkf) { - double c; - p->lkf = p->afc[nn]; - c = tan((double)(CS_PIDSR * p->lkf)); - - a[1] = 1.0 / ( 1.0 + ROOT2 * c + c * c); - a[2] = -(a[1] + a[1]); - a[3] = a[1]; - a[4] = 2.0 * ( c*c - 1.0) * a[1]; - a[5] = ( 1.0 - ROOT2 * c + c * c) * a[1]; - } - t = (double)in[nn] - a[4] * a[6] - a[5] * a[7]; - t = csoundUndenormalizeDouble(t); /* Not needed on AMD */ - y = t * a[1] + a[2] * a[6] + a[3] * a[7]; - a[7] = a[6]; - a[6] = t; - out[nn] = (MYFLT)y; - } + MYFLT *out, *in; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t nsmps = CS_KSMPS; + double *a; + double t, y; + uint32_t nn; + a = p->a; + + in = p->ain; + out = p->sr; + if (UNLIKELY(offset)) memset(out, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + nsmps -= early; + memset(&out[nsmps], '\0', early*sizeof(MYFLT)); + } + + if (UNLIKELY(p->afc[0] <= FL(0.0))) { + memcpy(&out[offset], &in[offset], (nsmps-offset)*sizeof(MYFLT)); return OK; + } + + /* if (p->afc[0] != p->lkf) { */ + /* p->lkf = p->afc[0]; */ + /* c = tan((double)(CS_PIDSR * p->lkf)); */ + + /* a[1] = 1.0 / ( 1.0 + ROOT2 * c + c * c); */ + /* a[2] = -(a[1] + a[1]); */ + /* a[3] = a[1]; */ + /* a[4] = 2.0 * ( c*c - 1.0) * a[1]; */ + /* a[5] = ( 1.0 - ROOT2 * c + c * c) * a[1]; */ + /* } */ + for (nn=offset; nnafc[nn] != p->lkf) { + double c; + p->lkf = p->afc[nn]; + c = tan((double)(CS_PIDSR * p->lkf)); + + a[1] = 1.0 / ( 1.0 + ROOT2 * c + c * c); + a[2] = -(a[1] + a[1]); + a[3] = a[1]; + a[4] = 2.0 * ( c*c - 1.0) * a[1]; + a[5] = ( 1.0 - ROOT2 * c + c * c) * a[1]; + } + t = (double)in[nn] - a[4] * a[6] - a[5] * a[7]; + t = csoundUndenormalizeDouble(t); /* Not needed on AMD */ + y = t * a[1] + a[2] * a[6] + a[3] * a[7]; + a[7] = a[6]; + a[6] = t; + out[nn] = (MYFLT)y; + } + return OK; } static int32_t lobuta(CSOUND *csound, BFIL *p) /* Lopass filter */ { - MYFLT *out, *in; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t nsmps = CS_KSMPS; - double *a = p->a; - double t, y; - uint32_t nn; - - in = p->ain; - out = p->sr; - - if (UNLIKELY(*p->afc <= FL(0.0))) { - memset(out, 0, CS_KSMPS*sizeof(MYFLT)); - return OK; - } - - if (UNLIKELY(offset)) memset(out, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - nsmps -= early; - memset(&out[nsmps], '\0', early*sizeof(MYFLT)); - } - - /* if (p->afc[0] != p->lkf) { */ - /* p->lkf = p->afc[0]; */ - /* c = 1.0 / tan((double)(CS_PIDSR * p->lkf)); */ - /* a[1] = 1.0 / ( 1.0 + ROOT2 * c + c * c); */ - /* a[2] = a[1] + a[1]; */ - /* a[3] = a[1]; */ - /* a[4] = 2.0 * ( 1.0 - c*c) * a[1]; */ - /* a[5] = ( 1.0 - ROOT2 * c + c * c) * a[1]; */ - /* } */ - - for (nn=offset; nnafc[nn] != p->lkf) { - double c; - p->lkf = p->afc[nn]; - c = 1.0 / tan((double)(CS_PIDSR * p->lkf)); - a[1] = 1.0 / ( 1.0 + ROOT2 * c + c * c); - a[2] = a[1] + a[1]; - a[3] = a[1]; - a[4] = 2.0 * ( 1.0 - c*c) * a[1]; - a[5] = ( 1.0 - ROOT2 * c + c * c) * a[1]; - } - t = (double)in[nn] - a[4] * a[6] - a[5] * a[7]; - t = csoundUndenormalizeDouble(t); /* Not needed on AMD */ - y = t * a[1] + a[2] * a[6] + a[3] * a[7]; - a[7] = a[6]; - a[6] = t; - out[nn] = (MYFLT)y; - } + MYFLT *out, *in; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t nsmps = CS_KSMPS; + double *a = p->a; + double t, y; + uint32_t nn; + + in = p->ain; + out = p->sr; + + if (UNLIKELY(*p->afc <= FL(0.0))) { + memset(out, 0, CS_KSMPS*sizeof(MYFLT)); return OK; + } + + if (UNLIKELY(offset)) memset(out, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + nsmps -= early; + memset(&out[nsmps], '\0', early*sizeof(MYFLT)); + } + + for (nn=offset; nnafc[nn] != p->lkf) { + double c; + p->lkf = p->afc[nn]; + c = 1.0 / tan((double)(CS_PIDSR * p->lkf)); + a[1] = 1.0 / ( 1.0 + ROOT2 * c + c * c); + a[2] = a[1] + a[1]; + a[3] = a[1]; + a[4] = 2.0 * ( 1.0 - c*c) * a[1]; + a[5] = ( 1.0 - ROOT2 * c + c * c) * a[1]; + } + t = (double)in[nn] - a[4] * a[6] - a[5] * a[7]; + t = csoundUndenormalizeDouble(t); /* Not needed on AMD */ + y = t * a[1] + a[2] * a[6] + a[3] * a[7]; + a[7] = a[6]; + a[6] = t; + out[nn] = (MYFLT)y; + } + return OK; } static int32_t bppasxx(CSOUND *csound, BBFIL *p) /* Bandpass filter */ { - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t nsmps = CS_KSMPS; - MYFLT *out, *in; - double *a = p->a; - double t, y; - uint32_t nn; - int32_t asgbw = IS_ASIG_ARG(p->kbw), asgfr = IS_ASIG_ARG(p->kfo); - - in = p->ain; - out = p->sr; - if (UNLIKELY(p->kbw[0] <= FL(0.0))) { - memset(out, 0, CS_KSMPS*sizeof(MYFLT)); - return OK; - } - if (UNLIKELY(offset)) memset(out, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - nsmps -= early; - memset(&out[nsmps], '\0', early*sizeof(MYFLT)); - } - /* if (p->kbw[0] != p->lkb || p->kfo[0] != p->lkf) { */ - /* p->lkf = p->kfo[0]; */ - /* p->lkb = p->kbw[0]; */ - /* c = 1.0 / tan((double)(CS_PIDSR * p->lkb)); */ - /* d = 2.0 * cos((double)(CS_TPIDSR * p->lkf)); */ - /* a[1] = 1.0 / (1.0 + c); */ - /* a[2] = 0.0; */ - /* a[3] = -a[1]; */ - /* a[4] = - c * d * a[1]; */ - /* a[5] = (c - 1.0) * a[1]; */ - /* } */ - //butter_filter(nsmps, offset, in, out, p->a); - for (nn=offset; nnkbw[nn] : *p->kbw); - fr = (asgfr ? p->kfo[nn] : *p->kfo); - if (bw != p->lkb || fr != p->lkf) { - double c, d; - p->lkf = fr; - p->lkb = bw; - c = 1.0 / tan((double)(CS_PIDSR * bw)); - d = 2.0 * cos((double)(CS_TPIDSR * fr)); - a[1] = 1.0 / (1.0 + c); - a[2] = 0.0; - a[3] = -a[1]; - a[4] = - c * d * a[1]; - a[5] = (c - 1.0) * a[1]; - } - t = (double)in[nn] - a[4] * a[6] - a[5] * a[7]; - t = csoundUndenormalizeDouble(t); /* Not needed on AMD */ - y = t * a[1] + a[2] * a[6] + a[3] * a[7]; - a[7] = a[6]; - a[6] = t; - out[nn] = (MYFLT)y; - } + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t nsmps = CS_KSMPS; + MYFLT *out, *in; + double *a = p->a; + double t, y; + uint32_t nn; + int32_t asgbw = IS_ASIG_ARG(p->kbw), asgfr = IS_ASIG_ARG(p->kfo); + + in = p->ain; + out = p->sr; + if (UNLIKELY(p->kbw[0] <= FL(0.0))) { + memset(out, 0, CS_KSMPS*sizeof(MYFLT)); return OK; + } + if (UNLIKELY(offset)) memset(out, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + nsmps -= early; + memset(&out[nsmps], '\0', early*sizeof(MYFLT)); + } + + for (nn=offset; nnkbw[nn] : *p->kbw); + fr = (asgfr ? p->kfo[nn] : *p->kfo); + if (bw != p->lkb || fr != p->lkf) { + double c, d; + p->lkf = fr; + p->lkb = bw; + c = 1.0 / tan((double)(CS_PIDSR * bw)); + d = 2.0 * cos((double)(CS_TPIDSR * fr)); + a[1] = 1.0 / (1.0 + c); + a[2] = 0.0; + a[3] = -a[1]; + a[4] = - c * d * a[1]; + a[5] = (c - 1.0) * a[1]; + } + t = (double)in[nn] - a[4] * a[6] - a[5] * a[7]; + t = csoundUndenormalizeDouble(t); /* Not needed on AMD */ + y = t * a[1] + a[2] * a[6] + a[3] * a[7]; + a[7] = a[6]; + a[6] = t; + out[nn] = (MYFLT)y; + } + return OK; } static int32_t bpcutxx(CSOUND *csound, BBFIL *p) /* Band reject filter */ { - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t nsmps = CS_KSMPS; - MYFLT *out, *in; - double *a = p->a; - double t, y; - uint32_t nn; - int32_t - asgbw = IS_ASIG_ARG(p->kbw), asgfr = IS_ASIG_ARG(p->kfo); - - in = p->ain; - out = p->sr; - - if (UNLIKELY(offset)) memset(out, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - nsmps -= early; - memset(&out[nsmps], '\0', early*sizeof(MYFLT)); - } - if (UNLIKELY(p->kbw[0] <= FL(0.0))) { - memcpy(&out[offset], &in[offset], (nsmps-offset)*sizeof(MYFLT)); - return OK; - } - - for (nn=offset; nnkbw[nn] : *p->kbw); - fr = (asgfr ? p->kfo[nn] : *p->kfo); - if (bw != p->lkb || fr != p->lkf) { - double c, d; - p->lkf = fr; - p->lkb = bw; - c = tan((double)(CS_PIDSR * bw)); - d = 2.0 * cos((double)(CS_TPIDSR * fr)); - a[1] = 1.0 / (1.0 + c); - a[2] = - d * a[1]; - a[3] = a[1]; - a[4] = a[2]; - a[5] = (1.0 - c) * a[1]; - } - t = (double)in[nn] - a[4] * a[6] - a[5] * a[7]; - t = csoundUndenormalizeDouble(t); /* Not needed on AMD */ - y = t * a[1] + a[2] * a[6] + a[3] * a[7]; - a[7] = a[6]; - a[6] = t; - out[nn] = (MYFLT)y; - } + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t nsmps = CS_KSMPS; + MYFLT *out, *in; + double *a = p->a; + double t, y; + uint32_t nn; + int32_t + asgbw = IS_ASIG_ARG(p->kbw), asgfr = IS_ASIG_ARG(p->kfo); + + in = p->ain; + out = p->sr; + + if (UNLIKELY(offset)) memset(out, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + nsmps -= early; + memset(&out[nsmps], '\0', early*sizeof(MYFLT)); + } + if (UNLIKELY(p->kbw[0] <= FL(0.0))) { + memcpy(&out[offset], &in[offset], (nsmps-offset)*sizeof(MYFLT)); return OK; + } + + for (nn=offset; nnkbw[nn] : *p->kbw); + fr = (asgfr ? p->kfo[nn] : *p->kfo); + if (bw != p->lkb || fr != p->lkf) { + double c, d; + p->lkf = fr; + p->lkb = bw; + c = tan((double)(CS_PIDSR * bw)); + d = 2.0 * cos((double)(CS_TPIDSR * fr)); + a[1] = 1.0 / (1.0 + c); + a[2] = - d * a[1]; + a[3] = a[1]; + a[4] = a[2]; + a[5] = (1.0 - c) * a[1]; + } + t = (double)in[nn] - a[4] * a[6] - a[5] * a[7]; + t = csoundUndenormalizeDouble(t); /* Not needed on AMD */ + y = t * a[1] + a[2] * a[6] + a[3] * a[7]; + a[7] = a[6]; + a[6] = t; + out[nn] = (MYFLT)y; + } + return OK; } static OENTRY afilts_localops[] = -{ - { "areson.aa", sizeof(RESON), 0,3,"a","aaaoo",(SUBR)arsnset,(SUBR)aresonaa}, - { "areson.ak", sizeof(RESON), 0,3,"a","aakoo",(SUBR)arsnset,(SUBR)aresonak}, - { "areson.ka", sizeof(RESON), 0,3,"a","akaoo",(SUBR)arsnset,(SUBR)aresonka}, - { "atone.a", sizeof(TONE), 0,3,"a","ako", (SUBR)atonset,(SUBR)atonea }, - { "atonex.a", sizeof(TONEX), 0,3, "a","aaoo",(SUBR)atonsetx,(SUBR)atonexa}, - { "tone.a", sizeof(TONE), 0,3,"a","aao", (SUBR)atonset,(SUBR)tonea }, - { "tonex.a", sizeof(TONEX), 0,3,"a","aaoo", (SUBR)atonsetx,(SUBR)tonexa }, - { "butterhp.a", sizeof(BFIL), 0,3,"a","aao", (SUBR)butseta,(SUBR)hibuta }, - { "butterlp.a", sizeof(BFIL), 0,3,"a","aao", (SUBR)butseta,(SUBR)lobuta }, - { "buthp.a", sizeof(BFIL), 0,3,"a","aao", (SUBR)butseta,(SUBR)hibuta }, - { "butlp.a", sizeof(BFIL), 0,3,"a","aao", (SUBR)butseta,(SUBR)lobuta }, - { "butterbp", sizeof(BBFIL),0,3,"a","axxo", (SUBR)bbutset,(SUBR)bppasxx}, - { "butbp", sizeof(BBFIL),0,3,"a","axxo", (SUBR)bbutset,(SUBR)bppasxx}, - { "butterbr", sizeof(BBFIL),0,3,"a","axxo", (SUBR)bbutset,(SUBR)bpcutxx}, - { "butbr", sizeof(BBFIL),0,3,"a","axxo", (SUBR)bbutset,(SUBR)bpcutxx}, -}; + { + { "areson.aa", sizeof(RESON), 0,"a","aaaoo",(SUBR)arsnset,(SUBR)aresonaa}, + { "areson.ak", sizeof(RESON), 0,"a","aakoo",(SUBR)arsnset,(SUBR)aresonak}, + { "areson.ka", sizeof(RESON), 0,"a","akaoo",(SUBR)arsnset,(SUBR)aresonka}, + { "atone.a", sizeof(TONE), 0,"a","ako", (SUBR)atonset,(SUBR)atonea }, + { "atonex.a", sizeof(TONEX), 0, "a","aaoo",(SUBR)atonsetx,(SUBR)atonexa}, + { "tone.a", sizeof(TONE), 0,"a","aao", (SUBR)atonset,(SUBR)tonea }, + { "tonex.a", sizeof(TONEX), 0,"a","aaoo", (SUBR)atonsetx,(SUBR)tonexa }, + { "butterhp.a", sizeof(BFIL), 0,"a","aao", (SUBR)butseta,(SUBR)hibuta }, + { "butterlp.a", sizeof(BFIL), 0,"a","aao", (SUBR)butseta,(SUBR)lobuta }, + { "buthp.a", sizeof(BFIL), 0,"a","aao", (SUBR)butseta,(SUBR)hibuta }, + { "butlp.a", sizeof(BFIL), 0,"a","aao", (SUBR)butseta,(SUBR)lobuta }, + { "butterbp", sizeof(BBFIL),0,"a","axxo", (SUBR)bbutset,(SUBR)bppasxx}, + { "butbp", sizeof(BBFIL),0,"a","axxo", (SUBR)bbutset,(SUBR)bppasxx}, + { "butterbr", sizeof(BBFIL),0,"a","axxo", (SUBR)bbutset,(SUBR)bpcutxx}, + { "butbr", sizeof(BBFIL),0,"a","axxo", (SUBR)bbutset,(SUBR)bpcutxx}, + }; LINKAGE_BUILTIN(afilts_localops) diff --git a/Opcodes/ambicode.c b/Opcodes/ambicode.c index 89c37fc2096..a49afa7d954 100644 --- a/Opcodes/ambicode.c +++ b/Opcodes/ambicode.c @@ -735,9 +735,9 @@ static int32_t aambideco(CSOUND *csound, AMBID *p) #define S(x) sizeof(x) static OENTRY localops[] = { - { "bformenc", S(AMBIC), _QQ, 3, "mmmmmmmmmmmmmmmm", "akkPPPP", + { "bformenc", S(AMBIC), _QQ, "mmmmmmmmmmmmmmmm", "akkPPPP", (SUBR)iambicode, (SUBR)aambicode }, - { "bformdec", S(AMBID), _QQ, 3, "mmmmmmmm", "iaaay", + { "bformdec", S(AMBID), _QQ, "mmmmmmmm", "iaaay", (SUBR)iambideco, (SUBR)aambideco } }; diff --git a/Opcodes/ambicode1.c b/Opcodes/ambicode1.c index da9142b2590..0bfea8090fe 100644 --- a/Opcodes/ambicode1.c +++ b/Opcodes/ambicode1.c @@ -1088,13 +1088,13 @@ abformdec_a(CSOUND * csound, AMBIDA * p) { #define S(x) sizeof(x) static OENTRY ambicode1_localops[] = { - { "bformenc1.a", S(AMBIC), 0, 3, "mmmmmmmmmmmmmmmm", "akk", + { "bformenc1.a", S(AMBIC), 0, "mmmmmmmmmmmmmmmm", "akk", (SUBR)ibformenc, (SUBR)abformenc }, - { "bformenc1.A", S(AMBIC), 0, 3, "a[]", "akk", + { "bformenc1.A", S(AMBIC), 0, "a[]", "akk", (SUBR)ibformenc_a, (SUBR)abformenc_a }, - { "bformdec1.a", S(AMBID), 0, 3, "mmmmmmmm", "iy", + { "bformdec1.a", S(AMBID), 0, "mmmmmmmm", "iy", (SUBR)ibformdec, (SUBR)abformdec }, - { "bformdec1.A", S(AMBIDA), 0, 3, "a[]", "ia[]", + { "bformdec1.A", S(AMBIDA), 0, "a[]", "ia[]", (SUBR)ibformdec_a, (SUBR)abformdec_a }, }; diff --git a/Opcodes/ampmidid.cpp b/Opcodes/ampmidid.cpp index 5778a52501d..46d50ec446d 100644 --- a/Opcodes/ampmidid.cpp +++ b/Opcodes/ampmidid.cpp @@ -152,33 +152,29 @@ class AMPMIDICURVE : public OpcodeBase { extern "C" { PUBLIC int32_t csoundModuleInit_ampmidid(CSOUND *csound) { int status = csound->AppendOpcode( - csound, (char *)"ampmidid.k", sizeof(KAMPMIDID), 0, 3, (char *)"k", + csound, (char *)"ampmidid.k", sizeof(KAMPMIDID), 0, (char *)"k", (char *)"kio", (int32_t (*)(CSOUND *, void *))KAMPMIDID::init_, (int32_t (*)(CSOUND *, void *))KAMPMIDID::kontrol_, (int32_t (*)(CSOUND *, void *))0); status |= csound->AppendOpcode( - csound, (char *)"ampmidid.i", sizeof(IAMPMIDID), 0, 1, (char *)"i", + csound, (char *)"ampmidid.i", sizeof(IAMPMIDID), 0, (char *)"i", (char *)"iio", - (int32_t (*)(CSOUND *, void *))IAMPMIDID::init_, - (int32_t (*)(CSOUND *, void *))0, - (int32_t (*)(CSOUND *, void *))0); - status |= csound->AppendOpcode(csound, (char *)"ampmidid", 0xffff, 0, 0, 0, 0, - 0, 0, 0); + (int (*)(CSOUND *, void *))IAMPMIDID::init_, + (int (*)(CSOUND *, void *))0, + (int (*)(CSOUND *, void *))0); status = csound->AppendOpcode( - csound, (char *)"ampmidicurve.k", sizeof(AMPMIDICURVE), 0, 3, (char *)"k", + csound, (char *)"ampmidicurve.k", sizeof(AMPMIDICURVE), 0, (char *)"k", (char *)"kkk", (int32_t (*)(CSOUND *, void *))AMPMIDICURVE::init_, (int32_t (*)(CSOUND *, void *))AMPMIDICURVE::kontrol_, (int32_t (*)(CSOUND *, void *))0); status |= csound->AppendOpcode( - csound, (char *)"ampmidicurve.i", sizeof(AMPMIDICURVE), 0, 1, (char *)"i", + csound, (char *)"ampmidicurve.i", sizeof(AMPMIDICURVE), 0, (char *)"i", (char *)"iii", - (int32_t (*)(CSOUND *, void *))AMPMIDICURVE::init_, - (int32_t (*)(CSOUND *, void *))0, - (int32_t (*)(CSOUND *, void *))0); - status |= csound->AppendOpcode(csound, (char *)"ampmidicurve", 0xffff, 0, 0, 0, 0, - 0, 0, 0); + (int (*)(CSOUND *, void *))AMPMIDICURVE::init_, + (int (*)(CSOUND *, void *))0, + (int (*)(CSOUND *, void *))0); return status; } diff --git a/Opcodes/arrays.c b/Opcodes/arrays.c index 16ad53744b7..b0bc7c5e89b 100644 --- a/Opcodes/arrays.c +++ b/Opcodes/arrays.c @@ -86,11 +86,11 @@ typedef struct { #ifdef SOME_FINE_DAY static int32_t array_del(CSOUND *csound, void *p) { - ARRAYDAT *t = ((ARRAYDEL*)p)->arrayDat; - t->arrayType = NULL; // types cleaned up later - csound->Free(csound, t->data); - csound->Free(csound, p); /* Unlikely to free the p */ - return OK; + ARRAYDAT *t = ((ARRAYDEL*)p)->arrayDat; + t->arrayType = NULL; // types cleaned up later + csound->Free(csound, t->data); + csound->Free(csound, p); /* Unlikely to free the p */ + return OK; } #endif @@ -98,289 +98,289 @@ static int32_t array_del(CSOUND *csound, void *p) static int32_t array_init(CSOUND *csound, ARRAYINIT *p) { - ARRAYDAT* arrayDat = p->arrayDat; - int32_t i, size; + ARRAYDAT* arrayDat = p->arrayDat; + int32_t i, size; - int32_t inArgCount = p->INOCOUNT; + int32_t inArgCount = p->INOCOUNT; - if (UNLIKELY(inArgCount == 0)) + if (UNLIKELY(inArgCount == 0)) + return + csound->InitError(csound, "%s", + Str("Error: no sizes set for array initialization")); + + for (i = 0; i < inArgCount; i++) { + if (UNLIKELY(MYFLT2LRND(*p->isizes[i]) <= 0)) { return csound->InitError(csound, "%s", - Str("Error: no sizes set for array initialization")); - - for (i = 0; i < inArgCount; i++) { - if (UNLIKELY(MYFLT2LRND(*p->isizes[i]) <= 0)) { - return - csound->InitError(csound, "%s", - Str("Error: sizes must be > 0 for array initialization")); - } + Str("Error: sizes must be > 0 for array initialization")); } + } - arrayDat->dimensions = inArgCount; - arrayDat->sizes = csound->Calloc(csound, sizeof(int32_t) * inArgCount); - for (i = 0; i < inArgCount; i++) { - arrayDat->sizes[i] = MYFLT2LRND(*p->isizes[i]); - } + arrayDat->dimensions = inArgCount; + arrayDat->sizes = csound->Calloc(csound, sizeof(int32_t) * inArgCount); + for (i = 0; i < inArgCount; i++) { + arrayDat->sizes[i] = MYFLT2LRND(*p->isizes[i]); + } - size = arrayDat->sizes[0]; - if (inArgCount > 1) { - for (i = 1; i < inArgCount; i++) { - size *= arrayDat->sizes[i]; - } - //size = MYFLT2LRND(size); // size is an int32_t not float + size = arrayDat->sizes[0]; + if (inArgCount > 1) { + for (i = 1; i < inArgCount; i++) { + size *= arrayDat->sizes[i]; } + //size = MYFLT2LRND(size); // size is an int32_t not float + } - { - CS_VARIABLE* var = arrayDat->arrayType->createVariable(csound,arrayDat->arrayType); - char *mem; - arrayDat->arrayMemberSize = var->memBlockSize; - arrayDat->data = csound->Calloc(csound, - arrayDat->allocated=var->memBlockSize*size); - mem = (char *) arrayDat->data; - for (i=0; i < size; i++) { - var->initializeVariableMemory(csound, var, - (MYFLT*)(mem+i*var->memBlockSize)); - } + { + CS_VARIABLE* var = arrayDat->arrayType->createVariable(csound,arrayDat->arrayType); + char *mem; + arrayDat->arrayMemberSize = var->memBlockSize; + arrayDat->data = csound->Calloc(csound, + arrayDat->allocated=var->memBlockSize*size); + mem = (char *) arrayDat->data; + for (i=0; i < size; i++) { + var->initializeVariableMemory(csound, var, + (MYFLT*)(mem+i*var->memBlockSize)); } - return OK; + } + return OK; } static int32_t tabfill(CSOUND *csound, TABFILL *p) { - int32_t nargs = p->INOCOUNT; - int32_t i, size; - size_t memMyfltSize; - MYFLT **valp = p->iargs; - tabinit(csound, p->ans, nargs); -/* if (UNLIKELY(p->ans->dimensions > 2)) { */ -/* return */ -/* csound->InitError(csound, "%s", */ -/* "%s", Str("fillarrray: arrays with dim > 2 not " */ -/* "currently supported\n")); */ -/* } */ - size = p->ans->sizes[0]; - for (i=1; ians->dimensions; i++) size *= p->ans->sizes[i]; - if (sizeans->arrayMemberSize / sizeof(MYFLT); - for (i=0; ians->arrayType->copyValue(csound, - p->ans->arrayType, - p->ans->data + (i * memMyfltSize), - valp[i]); - } - return OK; + int32_t nargs = p->INOCOUNT; + int32_t i, size; + size_t memMyfltSize; + MYFLT **valp = p->iargs; + tabinit(csound, p->ans, nargs); + /* if (UNLIKELY(p->ans->dimensions > 2)) { */ + /* return */ + /* csound->InitError(csound, "%s", */ + /* "%s", Str("fillarrray: arrays with dim > 2 not " */ + /* "currently supported\n")); */ + /* } */ + size = p->ans->sizes[0]; + for (i=1; ians->dimensions; i++) size *= p->ans->sizes[i]; + if (sizeans->arrayMemberSize / sizeof(MYFLT); + for (i=0; ians->arrayType->copyValue(csound, + p->ans->arrayType, + p->ans->data + (i * memMyfltSize), + valp[i]); + } + return OK; } #include static MYFLT nextval(FILE *f) { - /* Read the next character; suppress multiple space and comments to a - single space */ - int c; + /* Read the next character; suppress multiple space and comments to a + single space */ + int c; top: - c = getc(f); + c = getc(f); top1: - if (UNLIKELY(feof(f))) return NAN; /* Hope value is ignored */ - if (isdigit(c) || c=='e' || c=='E' || c=='+' || c=='-' || c=='.') { - double d; /* A number starts */ - char buff[128]; - int j = 0; - do { /* Fill buffer */ - buff[j++] = c; - c = getc(f); - } while (isdigit(c) || c=='e' || c=='E' || c=='+' || c=='-' || c=='.'); - buff[j]='\0'; - d = atof(buff); - if (c==';' || c=='#') { /* If extended with comment clear it now */ - while ((c = getc(f)) != '\n'); - } - return (MYFLT)d; - } - while (isspace(c) || c == ',') c = getc(f); /* Whitespace */ - if (c==';' || c=='#' || c=='<') { /* Comment and tag*/ + if (UNLIKELY(feof(f))) return NAN; /* Hope value is ignored */ + if (isdigit(c) || c=='e' || c=='E' || c=='+' || c=='-' || c=='.') { + double d; /* A number starts */ + char buff[128]; + int j = 0; + do { /* Fill buffer */ + buff[j++] = c; + c = getc(f); + } while (isdigit(c) || c=='e' || c=='E' || c=='+' || c=='-' || c=='.'); + buff[j]='\0'; + d = atof(buff); + if (c==';' || c=='#') { /* If extended with comment clear it now */ while ((c = getc(f)) != '\n'); } - if (isdigit(c) || c=='e' || c=='E' || c=='+' || c=='-' || c=='.') goto top1; - goto top; + return (MYFLT)d; + } + while (isspace(c) || c == ',') c = getc(f); /* Whitespace */ + if (c==';' || c=='#' || c=='<') { /* Comment and tag*/ + while ((c = getc(f)) != '\n'); + } + if (isdigit(c) || c=='e' || c=='E' || c=='+' || c=='-' || c=='.') goto top1; + goto top; } static int32_t tabfillf(CSOUND* csound, TABFILLF* p) { - int32_t i = 0, flen = 0, size; - char *fname = p->fname->data; - FILE *infile; - void *fd = csound->FileOpen2(csound, &infile, CSFILE_STD, fname, "r", - "SFDIR;SSDIR;INCDIR", CSFTYPE_FLOATS_TEXT, 0); - if (UNLIKELY(fd == NULL)) { - return csound->InitError(csound, Str("error opening ASCII file %s\n"), fname); - } - do { - flen++; - nextval(infile); - } while (!feof(infile)); - flen--; // overshoots by 1 - tabinit(csound, p->ans, flen); - size = p->ans->sizes[0]; - for (i=1; ians->dimensions; i++) size *= p->ans->sizes[i]; - if (sizeans->dimensions == 1 && (flen > p->ans->sizes[0])) - flen = p->ans->sizes[0]; - else if (p->ans->dimensions == 2 && (flen > p->ans->sizes[0]*p->ans->sizes[1])) - flen = p->ans->sizes[0]*p->ans->sizes[1]; - //memMyfltSize = p->ans->arrayMemberSize / sizeof(MYFLT); - rewind(infile); - i = 0; - while (!feof(infile) && i < flen) - ((MYFLT*)p->ans->data)[i++] = nextval(infile); - return OK; + int32_t i = 0, flen = 0, size; + char *fname = p->fname->data; + FILE *infile; + void *fd = csound->FileOpen2(csound, &infile, CSFILE_STD, fname, "r", + "SFDIR;SSDIR;INCDIR", CSFTYPE_FLOATS_TEXT, 0); + if (UNLIKELY(fd == NULL)) { + return csound->InitError(csound, Str("error opening ASCII file %s\n"), fname); + } + do { + flen++; + nextval(infile); + } while (!feof(infile)); + flen--; // overshoots by 1 + tabinit(csound, p->ans, flen); + size = p->ans->sizes[0]; + for (i=1; ians->dimensions; i++) size *= p->ans->sizes[i]; + if (sizeans->dimensions == 1 && (flen > p->ans->sizes[0])) + flen = p->ans->sizes[0]; + else if (p->ans->dimensions == 2 && (flen > p->ans->sizes[0]*p->ans->sizes[1])) + flen = p->ans->sizes[0]*p->ans->sizes[1]; + //memMyfltSize = p->ans->arrayMemberSize / sizeof(MYFLT); + rewind(infile); + i = 0; + while (!feof(infile) && i < flen) + ((MYFLT*)p->ans->data)[i++] = nextval(infile); + return OK; } static MYFLT nextsval(char **ff) { - /* Read the next character; suppress multiple space - * should use stdtod */ - int c; - char *f = *ff; + /* Read the next character; suppress multiple space + * should use stdtod */ + int c; + char *f = *ff; top: - c = *f++; + c = *f++; top1: - if (UNLIKELY(c=='\0')) { *ff = f; return NAN; } - if (isdigit(c) || c=='e' || c=='E' || c=='+' || c=='-' || c=='.') { - double d; /* A number starts */ - char buff[128]; - int j = 0; - do { /* Fill buffer */ - buff[j++] = c; - c = *f++; - } while (isdigit(c) || c=='e' || c=='E' || c=='+' || c=='-' || c=='.'); - buff[j]='\0'; - d = atof(buff); - while (isspace(c) || c == ',') c = *f++; /* Whitespace */ - *ff = --f; - //printf(">> %f\n", d); - return (MYFLT)d; - } + if (UNLIKELY(c=='\0')) { *ff = f; return NAN; } + if (isdigit(c) || c=='e' || c=='E' || c=='+' || c=='-' || c=='.') { + double d; /* A number starts */ + char buff[128]; + int j = 0; + do { /* Fill buffer */ + buff[j++] = c; + c = *f++; + } while (isdigit(c) || c=='e' || c=='E' || c=='+' || c=='-' || c=='.'); + buff[j]='\0'; + d = atof(buff); while (isspace(c) || c == ',') c = *f++; /* Whitespace */ - if (isdigit(c) || c=='e' || c=='E' || c=='+' || c=='-' || c=='.') goto top1; - goto top; + *ff = --f; + //printf(">> %f\n", d); + return (MYFLT)d; + } + while (isspace(c) || c == ',') c = *f++; /* Whitespace */ + if (isdigit(c) || c=='e' || c=='E' || c=='+' || c=='-' || c=='.') goto top1; + goto top; } static int32_t tabsfill(CSOUND *csound, TABFILLF *p) { - int32_t i = 0, flen = 0, size; - char *string = p->fname->data; - MYFLT x; - do { - x = nextsval(&string); - if (x==NAN) break; - flen++; - } while (*string!='\0'); - //flen--; // overshoots by 1 - tabinit(csound, p->ans, flen); - size = p->ans->sizes[0]; - for (i=1; ians->dimensions; i++) size *= p->ans->sizes[i]; - if (sizeans->dimensions == 1 && (flen > p->ans->sizes[0])) - flen = p->ans->sizes[0]; - else if (p->ans->dimensions == 2 && (flen > p->ans->sizes[0]*p->ans->sizes[1])) - flen = p->ans->sizes[0]*p->ans->sizes[1]; - //memMyfltSize = p->ans->arrayMemberSize / sizeof(MYFLT); - string = p->fname->data; - i = 0; - while ((*string!='\0') && i < flen) - ((MYFLT*)p->ans->data)[i++] = nextsval(&string); - return OK; + int32_t i = 0, flen = 0, size; + char *string = p->fname->data; + MYFLT x; + do { + x = nextsval(&string); + if (x==NAN) break; + flen++; + } while (*string!='\0'); + //flen--; // overshoots by 1 + tabinit(csound, p->ans, flen); + size = p->ans->sizes[0]; + for (i=1; ians->dimensions; i++) size *= p->ans->sizes[i]; + if (sizeans->dimensions == 1 && (flen > p->ans->sizes[0])) + flen = p->ans->sizes[0]; + else if (p->ans->dimensions == 2 && (flen > p->ans->sizes[0]*p->ans->sizes[1])) + flen = p->ans->sizes[0]*p->ans->sizes[1]; + //memMyfltSize = p->ans->arrayMemberSize / sizeof(MYFLT); + string = p->fname->data; + i = 0; + while ((*string!='\0') && i < flen) + ((MYFLT*)p->ans->data)[i++] = nextsval(&string); + return OK; } static int32_t array_err(CSOUND* csound, ARRAY_SET *p) { - IGN(p); - return csound->InitError(csound, "%s", Str("Cannot set i-array at k-rate\n")); + IGN(p); + return csound->InitError(csound, "%s", Str("Cannot set i-array at k-rate\n")); } static int32_t array_set(CSOUND* csound, ARRAY_SET *p) { - ARRAYDAT* dat = p->arrayDat; - MYFLT* mem = dat->data; - int32_t i; - int32_t end, index, incr; + ARRAYDAT* dat = p->arrayDat; + MYFLT* mem = dat->data; + int32_t i; + int32_t end, index, incr; - int32_t indefArgCount = p->INOCOUNT - 2; + int32_t indefArgCount = p->INOCOUNT - 2; - //printf("*** value=%f, index = [%d][%d][%d]\n", *(double*)p->value, - // (int)(*p->indexes[0]), (int)(*p->indexes[1]), (int)(*p->indexes[2])); + //printf("*** value=%f, index = [%d][%d][%d]\n", *(double*)p->value, + // (int)(*p->indexes[0]), (int)(*p->indexes[1]), (int)(*p->indexes[2])); - if (UNLIKELY(indefArgCount == 0)) { - csound->ErrorMsg(csound, "%s", Str("Error: no indexes set for array set\n")); - return CSOUND_ERROR; - } - if (UNLIKELY(indefArgCount!=dat->dimensions)) { + if (UNLIKELY(indefArgCount == 0)) { + csound->ErrorMsg(csound, "%s", Str("Error: no indexes set for array set\n")); + return CSOUND_ERROR; + } + if (UNLIKELY(indefArgCount!=dat->dimensions)) { + return csound->PerfError(csound, &(p->h), + Str("Array dimension %d does not match " + "for dimensions %d\n"), + indefArgCount, dat->dimensions); + } + index = 0; + for (i=0;iindexes[i]); + //printf("** dimemnsion %d end = %d\n", i, end); + if (UNLIKELY(end>=dat->sizes[i])) return csound->PerfError(csound, &(p->h), - Str("Array dimension %d does not match " - "for dimensions %d\n"), - indefArgCount, dat->dimensions); - } - index = 0; - for (i=0;iindexes[i]); - //printf("** dimemnsion %d end = %d\n", i, end); - if (UNLIKELY(end>=dat->sizes[i])) - return csound->PerfError(csound, &(p->h), - Str("Array index %d out of range (0,%d) " - "for dimension %d"), + Str("Array index %d out of range (0,%d) " + "for dimension %d"), end, dat->sizes[i], i+1); - // printf("*** index %d -> ", index); - index = (index * dat->sizes[i]) + end; - // printf("%d : %d\n", index, dat->sizes[i]); - } - incr = (index * (dat->arrayMemberSize / sizeof(MYFLT))); - mem += incr; - //memcpy(mem, p->value, dat->arrayMemberSize); - dat->arrayType->copyValue(csound, dat->arrayType, mem, p->value); - /* printf("array_set: mem = %p, incr = %d, value = %f\n", */ - /* mem, incr, *((MYFLT*)p->value)); */ - return OK; + // printf("*** index %d -> ", index); + index = (index * dat->sizes[i]) + end; + // printf("%d : %d\n", index, dat->sizes[i]); + } + incr = (index * (dat->arrayMemberSize / sizeof(MYFLT))); + mem += incr; + //memcpy(mem, p->value, dat->arrayMemberSize); + dat->arrayType->copyValue(csound, dat->arrayType, mem, p->value); + /* printf("array_set: mem = %p, incr = %d, value = %f\n", */ + /* mem, incr, *((MYFLT*)p->value)); */ + return OK; } static int32_t array_get(CSOUND* csound, ARRAY_GET *p) { - ARRAYDAT* dat = p->arrayDat; - MYFLT* mem = dat->data; - int32_t i; - int32_t incr; - int32_t end; - int32_t index; - int32_t indefArgCount = p->INOCOUNT - 1; - - if (UNLIKELY(indefArgCount == 0)) - return csound->PerfError(csound, &(p->h), - "%s", Str("Error: no indexes set for array get")); - if (UNLIKELY(indefArgCount!=dat->dimensions)) { + ARRAYDAT* dat = p->arrayDat; + MYFLT* mem = dat->data; + int32_t i; + int32_t incr; + int32_t end; + int32_t index; + int32_t indefArgCount = p->INOCOUNT - 1; + + if (UNLIKELY(indefArgCount == 0)) + return csound->PerfError(csound, &(p->h), + "%s", Str("Error: no indexes set for array get")); + if (UNLIKELY(indefArgCount!=dat->dimensions)) { + return csound->PerfError(csound, &(p->h), + Str("Array dimension %d out of range " + "for dimensions %d"), + indefArgCount, dat->dimensions); + } + index = 0; + for (i=0;iindexes[i]); + //printf("++++ ** dimemnsion %d end = %d\n", i, end); + if (UNLIKELY(end>=dat->sizes[i])) return csound->PerfError(csound, &(p->h), - Str("Array dimension %d out of range " - "for dimensions %d"), - indefArgCount, dat->dimensions); - } - index = 0; - for (i=0;iindexes[i]); - //printf("++++ ** dimemnsion %d end = %d\n", i, end); - if (UNLIKELY(end>=dat->sizes[i])) - return csound->PerfError(csound, &(p->h), - Str("Array index %d out of range (0,%d) " - "for dimension %d"), + Str("Array index %d out of range (0,%d) " + "for dimension %d"), end, dat->sizes[i]-1, i+1); - //printf("*** index %d -> ", index); - index = (index * dat->sizes[i]) + end; - //printf("%d : %d\n", index, dat->sizes[i]); - } + //printf("*** index %d -> ", index); + index = (index * dat->sizes[i]) + end; + //printf("%d : %d\n", index, dat->sizes[i]); + } - incr = (index * (dat->arrayMemberSize / sizeof(MYFLT))); - mem += incr; - // memcpy(p->out, &mem[incr], dat->arrayMemberSize); - dat->arrayType->copyValue(csound, dat->arrayType, (void*)p->out, (void*)mem); - return OK; + incr = (index * (dat->arrayMemberSize / sizeof(MYFLT))); + mem += incr; + // memcpy(p->out, &mem[incr], dat->arrayMemberSize); + dat->arrayType->copyValue(csound, dat->arrayType, (void*)p->out, (void*)mem); + return OK; } typedef struct { @@ -454,23 +454,23 @@ typedef struct { static int32_t tabarithset(CSOUND *csound, TABARITH *p) { - if (LIKELY(p->left->data && p->right->data)) { - int i; - if (UNLIKELY(p->left->dimensions != p->right->dimensions)) + if (LIKELY(p->left->data && p->right->data)) { + int i; + if (UNLIKELY(p->left->dimensions != p->right->dimensions)) + return + csound->InitError(csound, "%s", + Str("Dimensions do not match in array arithmetic")); + for (i=0; ileft->dimensions; i++) { + if (UNLIKELY(p->left->sizes[i] != p->right->sizes[i])) return csound->InitError(csound, "%s", Str("Dimensions do not match in array arithmetic")); - for (i=0; ileft->dimensions; i++) { - if (UNLIKELY(p->left->sizes[i] != p->right->sizes[i])) - return - csound->InitError(csound, "%s", - Str("Dimensions do not match in array arithmetic")); - } - tabinit_like(csound, p->ans, p->left); - return OK; } - else return csound->InitError(csound, "%s", - Str("array-variable not initialised")); + tabinit_like(csound, p->ans, p->left); + return OK; + } + else return csound->InitError(csound, "%s", + Str("array-variable not initialised")); } static int32_t tabiadd(CSOUND *csound, ARRAYDAT *ans, @@ -479,184 +479,184 @@ static int32_t tabiadd(CSOUND *csound, ARRAYDAT *ans, // For cases with array as first arg static int32_t tabarithset1(CSOUND *csound, TABARITH1 *p) { - ARRAYDAT *left = p->left; - - if (p->ans->data == left->data) { - // printf("same ptr\n"); - return OK; - } + ARRAYDAT *left = p->left; - tabinit_like(csound, p->ans, left); + if (p->ans->data == left->data) { + // printf("same ptr\n"); return OK; + } + + tabinit_like(csound, p->ans, left); + return OK; } // For cases with array as second arg static int32_t tabarithset2(CSOUND *csound, TABARITH2 *p) { - ARRAYDAT *right = p->right; + ARRAYDAT *right = p->right; - if (p->ans->data == right->data) { - // printf("same ptr\n"); - return OK; - } - - tabinit_like(csound, p->ans, right); + if (p->ans->data == right->data) { + // printf("same ptr\n"); return OK; + } + + tabinit_like(csound, p->ans, right); + return OK; } static int32_t tabadd(CSOUND *csound, TABARITH *p) { - ARRAYDAT *ans = p->ans; - ARRAYDAT *l = p->left; - ARRAYDAT *r = p->right; - int32_t sizel = l->sizes[0]; - int32_t sizer = r->sizes[0]; - int32_t i; - - if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerdata[i] = l->data[i] + r->data[i]; - return OK; + ARRAYDAT *ans = p->ans; + ARRAYDAT *l = p->left; + ARRAYDAT *r = p->right; + int32_t sizel = l->sizes[0]; + int32_t sizer = r->sizes[0]; + int32_t i; + + if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[i] = l->data[i] + r->data[i]; + return OK; } static int32_t tabsub(CSOUND *csound, TABARITH *p) { - ARRAYDAT *ans = p->ans; - ARRAYDAT *l = p->left; - ARRAYDAT *r = p->right; - int32_t sizel = l->sizes[0]; - int32_t sizer = r->sizes[0]; - int32_t i; - - if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerdata[i] = l->data[i] - r->data[i]; - return OK; + ARRAYDAT *ans = p->ans; + ARRAYDAT *l = p->left; + ARRAYDAT *r = p->right; + int32_t sizel = l->sizes[0]; + int32_t sizer = r->sizes[0]; + int32_t i; + + if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[i] = l->data[i] - r->data[i]; + return OK; } static int32_t tabmult(CSOUND *csound, TABARITH *p) { - ARRAYDAT *ans = p->ans; - ARRAYDAT *l = p->left; - ARRAYDAT *r = p->right; - int32_t sizel = l->sizes[0]; - int32_t sizer = r->sizes[0]; - int32_t i; - - if (UNLIKELY(ans->data == NULL || l->data== NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerdata[i] = l->data[i] * r->data[i]; - return OK; + ARRAYDAT *ans = p->ans; + ARRAYDAT *l = p->left; + ARRAYDAT *r = p->right; + int32_t sizel = l->sizes[0]; + int32_t sizer = r->sizes[0]; + int32_t i; + + if (UNLIKELY(ans->data == NULL || l->data== NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[i] = l->data[i] * r->data[i]; + return OK; } static int32_t tabdiv(CSOUND *csound, TABARITH *p) { - ARRAYDAT *ans = p->ans; - ARRAYDAT *l = p->left; - ARRAYDAT *r = p->right; - int32_t sizel = l->sizes[0]; - int32_t sizer = r->sizes[0]; - int32_t i; - - if (UNLIKELY(ans->data == NULL || l->data== NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerdata[i]!=0)) - ans->data[i] = l->data[i] / r->data[i]; - else - return - csound->PerfError(csound, &(p->h), - Str("division by zero in array-var at index %d"), i); - return OK; + ARRAYDAT *ans = p->ans; + ARRAYDAT *l = p->left; + ARRAYDAT *r = p->right; + int32_t sizel = l->sizes[0]; + int32_t sizer = r->sizes[0]; + int32_t i; + + if (UNLIKELY(ans->data == NULL || l->data== NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[i]!=0)) + ans->data[i] = l->data[i] / r->data[i]; + else + return + csound->PerfError(csound, &(p->h), + Str("division by zero in array-var at index %d"), i); + return OK; } static int32_t tabrem(CSOUND *csound, TABARITH *p) { - ARRAYDAT *ans = p->ans; - ARRAYDAT *l = p->left; - ARRAYDAT *r = p->right; - int32_t sizel = l->sizes[0]; - int32_t sizer = r->sizes[0]; - int32_t i; - - if (UNLIKELY(ans->data == NULL || l->data== NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerdata[i]!=0)) - ans->data[i] = MOD(l->data[i], r->data[i]); - else - return - csound->PerfError(csound, &(p->h), - Str("division by zero in array-var at index %d"), i); + ARRAYDAT *ans = p->ans; + ARRAYDAT *l = p->left; + ARRAYDAT *r = p->right; + int32_t sizel = l->sizes[0]; + int32_t sizer = r->sizes[0]; + int32_t i; + + if (UNLIKELY(ans->data == NULL || l->data== NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[i]!=0)) + ans->data[i] = MOD(l->data[i], r->data[i]); + else + return + csound->PerfError(csound, &(p->h), + Str("division by zero in array-var at index %d"), i); - return OK; + return OK; } static int32_t tabpow(CSOUND *csound, TABARITH *p) { - ARRAYDAT *ans = p->ans; - ARRAYDAT *l = p->left; - ARRAYDAT *r = p->right; - int32_t sizel = l->sizes[0]; - int32_t sizer = r->sizes[0]; - int32_t i; - MYFLT tmp; - - if (UNLIKELY(ans->data == NULL || l->data== NULL || r->data==NULL)) + ARRAYDAT *ans = p->ans; + ARRAYDAT *l = p->left; + ARRAYDAT *r = p->right; + int32_t sizel = l->sizes[0]; + int32_t sizer = r->sizes[0]; + int32_t i; + MYFLT tmp; + + if (UNLIKELY(ans->data == NULL || l->data== NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[i]>=0) || MODF(r->data[i],&tmp)==FL(0.0)) + ans->data[i] = POWER(l->data[i],r->data[i]); + else return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerdata[i]>=0) || MODF(r->data[i],&tmp)==FL(0.0)) - ans->data[i] = POWER(l->data[i],r->data[i]); - else - return csound->PerfError(csound, &(p->h), - Str("undefined power in array-var at index %d"), - i); - return OK; + Str("undefined power in array-var at index %d"), + i); + return OK; } @@ -677,365 +677,365 @@ IIARRAY(tabpowi,tabpow) // Add array and scalar static int32_t tabiadd(CSOUND *csound, ARRAYDAT *ans, ARRAYDAT *l, MYFLT r, void *p) { - int32_t sizel = l->sizes[0]; - int32_t i; + int32_t sizel = l->sizes[0]; + int32_t i; - if (UNLIKELY(ans->data == NULL || l->data== NULL)) - return csound->PerfError(csound, &(((TABARITH *) p)->h), - "%s", Str("array-variable not initialised")); + if (UNLIKELY(ans->data == NULL || l->data== NULL)) + return csound->PerfError(csound, &(((TABARITH *) p)->h), + "%s", Str("array-variable not initialised")); - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - } - for (i=0; idata[i] = l->data[i] + r; - return OK; + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + } + for (i=0; idata[i] = l->data[i] + r; + return OK; } // K[]+K static int32_t tabaiadd(CSOUND *csound, TABARITH1 *p) { - ARRAYDAT *ans = p->ans; - ARRAYDAT *l = p->left; - MYFLT r = *p->right; - tabinit_like(csound, ans, l); - return tabiadd(csound, ans, l, r, p); + ARRAYDAT *ans = p->ans; + ARRAYDAT *l = p->left; + MYFLT r = *p->right; + tabinit_like(csound, ans, l); + return tabiadd(csound, ans, l, r, p); } // K+K[] static int32_t tabiaadd(CSOUND *csound, TABARITH2 *p) { - ARRAYDAT *ans = p->ans; - ARRAYDAT *l = p->right; - MYFLT r = *p->left; - return tabiadd(csound, ans, l, r, p); + ARRAYDAT *ans = p->ans; + ARRAYDAT *l = p->right; + MYFLT r = *p->left; + return tabiadd(csound, ans, l, r, p); } /* ****************Array versions of addin/subin*********** */ /// K[] += K static int32_t addinAA(CSOUND *csound, TABARITHIN1 *p) { - ARRAYDAT *ans = p->ans; - MYFLT r = *p->right; - //tabinit_like(csound, ans, l); - return tabiadd(csound, ans, ans, r, p); + ARRAYDAT *ans = p->ans; + MYFLT r = *p->right; + //tabinit_like(csound, ans, l); + return tabiadd(csound, ans, ans, r, p); } // K[] += K[] static int32_t tabaddinkk(CSOUND *csound, TABARITHIN *p) { - ARRAYDAT *ans = p->ans; - ARRAYDAT *r = p->right; - int32_t sizel = ans->sizes[0]; - int32_t sizer = r->sizes[0]; - int32_t i; - - tabinit_like(csound, ans, r); - if (UNLIKELY(ans->data == NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=ans->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerdata[i] += r->data[i]; - return OK; + ARRAYDAT *ans = p->ans; + ARRAYDAT *r = p->right; + int32_t sizel = ans->sizes[0]; + int32_t sizer = r->sizes[0]; + int32_t i; + + tabinit_like(csound, ans, r); + if (UNLIKELY(ans->data == NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=ans->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[i] += r->data[i]; + return OK; } //a[]+=a[] static int32_t tabaaddin(CSOUND *csound, TABARITHIN *p) { - ARRAYDAT *ans = p->ans; - ARRAYDAT *r = p->right; - int32_t sizel = ans->sizes[0]; - int32_t sizer = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=ans->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerans; + ARRAYDAT *r = p->right; + int32_t sizel = ans->sizes[0]; + int32_t sizer = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=ans->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); if (UNLIKELY(early)) { - nsmps -= early; - } - for (i=0; idata[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; - ARRAYDAT *r = p->right; - int32_t sizel = ans->sizes[0]; - int32_t sizer = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=ans->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerans; + ARRAYDAT *r = p->right; + int32_t sizel = ans->sizes[0]; + int32_t sizer = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=ans->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); if (UNLIKELY(early)) { - nsmps -= early; + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - for (i=0; idata[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; - ARRAYDAT *r = p->right; - int32_t sizel = ans->sizes[0]; - int32_t sizer = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=ans->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerdata[i]; - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + ARRAYDAT *r = p->right; + int32_t sizel = ans->sizes[0]; + int32_t sizer = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=ans->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[i]; + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - ARRAYDAT *r = p->right; - int32_t sizel = ans->sizes[0]; - int32_t sizer = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=ans->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerdata[i]; - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + ARRAYDAT *r = p->right; + int32_t sizel = ans->sizes[0]; + int32_t sizer = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=ans->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[i]; + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - MYFLT l = *p->right; - int32_t sizel = ans->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) - sizel*=ans->sizes[i]; - for (i=0; idata[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + MYFLT l = *p->right; + int32_t sizel = ans->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) + sizel*=ans->sizes[i]; + for (i=0; idata[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - MYFLT l = *p->right; - int32_t sizel = ans->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) - sizel*=ans->sizes[i]; - for (i=0; idata[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + MYFLT l = *p->right; + int32_t sizel = ans->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) + sizel*=ans->sizes[i]; + for (i=0; idata[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - MYFLT l = *p->right; - ARRAYDAT *r = p->left; - int32_t sizel = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) - sizel*=r->sizes[i]; - for (i=0; idata[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + MYFLT l = *p->right; + ARRAYDAT *r = p->left; + int32_t sizel = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) + sizel*=r->sizes[i]; + for (i=0; idata[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - ARRAYDAT *r = p->right; - int32_t sizel = ans->sizes[0]; - int32_t sizer = r->sizes[0]; - int32_t i; - - if (UNLIKELY(ans->data == NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=ans->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerdata[i] -=r->data[i]; - return OK; + ARRAYDAT *ans = p->ans; + ARRAYDAT *r = p->right; + int32_t sizel = ans->sizes[0]; + int32_t sizer = r->sizes[0]; + int32_t i; + + if (UNLIKELY(ans->data == NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=ans->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[i] -=r->data[i]; + return OK; } // K[] -= K[] static int32_t tabsubinkk(CSOUND *csound, TABARITHIN *p) { - ARRAYDAT *ans = p->ans; - ARRAYDAT *r = p->right; - int32_t sizel = ans->sizes[0]; - int32_t sizer = r->sizes[0]; - int32_t i; - - tabinit_like(csound, ans, r); - if (UNLIKELY(ans->data == NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=ans->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerdata[i] -= r->data[i]; - return OK; + ARRAYDAT *ans = p->ans; + ARRAYDAT *r = p->right; + int32_t sizel = ans->sizes[0]; + int32_t sizer = r->sizes[0]; + int32_t i; + + tabinit_like(csound, ans, r); + if (UNLIKELY(ans->data == NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=ans->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[i] -= r->data[i]; + return OK; } @@ -1044,238 +1044,238 @@ static int32_t tabsubinkk(CSOUND *csound, TABARITHIN *p) // Subtract K[]-K static int32_t tabaisub(CSOUND *csound, TABARITH1 *p) { - ARRAYDAT *ans = p->ans; - ARRAYDAT *l = p->left; - MYFLT r = *p->right; - int32_t sizel = l->sizes[0]; - int32_t i; - - if (UNLIKELY(ans->data == NULL || l->data== NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - } - for (i=0; idata[i] = l->data[i] - r; - return OK; + ARRAYDAT *ans = p->ans; + ARRAYDAT *l = p->left; + MYFLT r = *p->right; + int32_t sizel = l->sizes[0]; + int32_t i; + + if (UNLIKELY(ans->data == NULL || l->data== NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + } + for (i=0; idata[i] = l->data[i] - r; + return OK; } // Subtract K-K[] static int32_t tabiasub(CSOUND *csound, TABARITH2 *p) { - ARRAYDAT *ans = p->ans; - ARRAYDAT *l = p->right; - MYFLT r = *p->left; - int32_t sizel = l->sizes[0]; - int32_t i; - - if (UNLIKELY(ans->data == NULL || l->data== NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - } - for (i=0; idata[i] = r - l->data[i]; - return OK; + ARRAYDAT *ans = p->ans; + ARRAYDAT *l = p->right; + MYFLT r = *p->left; + int32_t sizel = l->sizes[0]; + int32_t i; + + if (UNLIKELY(ans->data == NULL || l->data== NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + } + for (i=0; idata[i] = r - l->data[i]; + return OK; } // Multiply scalar by array static int32_t tabimult(CSOUND *csound, ARRAYDAT *ans, ARRAYDAT *l, MYFLT r, void *p) { - int32_t sizel = l->sizes[0]; - int32_t i; + int32_t sizel = l->sizes[0]; + int32_t i; - if (UNLIKELY(ans->data == NULL || l->data== NULL)) - return csound->PerfError(csound, &(((TABARITH1 *)p)->h), - "%s", Str("array-variable not initialised")); + if (UNLIKELY(ans->data == NULL || l->data== NULL)) + return csound->PerfError(csound, &(((TABARITH1 *)p)->h), + "%s", Str("array-variable not initialised")); - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - } - for (i=0; idata[i] = l->data[i] * r; - return OK; + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + } + for (i=0; idata[i] = l->data[i] * r; + return OK; } // K[] * K static int32_t tabaimult(CSOUND *csound, TABARITH1 *p) { - ARRAYDAT *ans = p->ans; - ARRAYDAT *l = p->left; - MYFLT r = *p->right; - return tabimult(csound, ans, l, r, p); + ARRAYDAT *ans = p->ans; + ARRAYDAT *l = p->left; + MYFLT r = *p->right; + return tabimult(csound, ans, l, r, p); } // K * K[] static int32_t tabiamult(CSOUND *csound, TABARITH2 *p) { - ARRAYDAT *ans = p->ans; - ARRAYDAT *l = p->right; - MYFLT r = *p->left; - return tabimult(csound, ans, l, r, p); + ARRAYDAT *ans = p->ans; + ARRAYDAT *l = p->right; + MYFLT r = *p->left; + return tabimult(csound, ans, l, r, p); } // K[] / K static int32_t tabaidiv(CSOUND *csound, TABARITH1 *p) { - ARRAYDAT *ans = p->ans; - ARRAYDAT *l = p->left; - MYFLT r = *p->right; - int32_t sizel = l->sizes[0]; - int32_t i; - - if (UNLIKELY(r==FL(0.0))) - return csound->PerfError(csound, &(p->h), - "%s", Str("division by zero in array-var")); - if (UNLIKELY(ans->data == NULL || l->data== NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - } - for (i=0; idata[i] = l->data[i] / r; - return OK; + ARRAYDAT *ans = p->ans; + ARRAYDAT *l = p->left; + MYFLT r = *p->right; + int32_t sizel = l->sizes[0]; + int32_t i; + + if (UNLIKELY(r==FL(0.0))) + return csound->PerfError(csound, &(p->h), + "%s", Str("division by zero in array-var")); + if (UNLIKELY(ans->data == NULL || l->data== NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + } + for (i=0; idata[i] = l->data[i] / r; + return OK; } // K / K[] static int32_t tabiadiv(CSOUND *csound, TABARITH2 *p) { - ARRAYDAT *ans = p->ans; - ARRAYDAT *l = p->right; - MYFLT r = *p->left; - int32_t sizel = l->sizes[0]; - int32_t i; - - if (UNLIKELY(ans->data == NULL || l->data== NULL)) + ARRAYDAT *ans = p->ans; + ARRAYDAT *l = p->right; + MYFLT r = *p->left; + int32_t sizel = l->sizes[0]; + int32_t i; + + if (UNLIKELY(ans->data == NULL || l->data== NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + } + for (i=0; idata[i]==FL(0.0))) return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - } - for (i=0; idata[i]==FL(0.0))) - return csound->PerfError(csound, &(p->h), - "%s", Str("division by zero in array-var")); - ans->data[i] = r / l->data[i]; - } - return OK; + "%s", Str("division by zero in array-var")); + ans->data[i] = r / l->data[i]; + } + return OK; } // K[] % K static int32_t tabairem(CSOUND *csound, TABARITH1 *p) { - ARRAYDAT *ans = p->ans; - ARRAYDAT *l = p->left; - MYFLT r = *p->right; - int32_t sizel = l->sizes[0]; - int32_t i; - - if (UNLIKELY(r==FL(0.0))) - return csound->PerfError(csound, &(p->h), - "%s", Str("division by zero in array-var")); - if (UNLIKELY(ans->data == NULL || l->data== NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - } - for (i=0; idata[i] = MOD(l->data[i], r); - return OK; + ARRAYDAT *ans = p->ans; + ARRAYDAT *l = p->left; + MYFLT r = *p->right; + int32_t sizel = l->sizes[0]; + int32_t i; + + if (UNLIKELY(r==FL(0.0))) + return csound->PerfError(csound, &(p->h), + "%s", Str("division by zero in array-var")); + if (UNLIKELY(ans->data == NULL || l->data== NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + } + for (i=0; idata[i] = MOD(l->data[i], r); + return OK; } // K % K[] static int32_t tabiarem(CSOUND *csound, TABARITH2 *p) { - ARRAYDAT *ans = p->ans; - ARRAYDAT *l = p->right; - MYFLT r = *p->left; - int32_t sizel = l->sizes[0]; - int32_t i; - - if (UNLIKELY(ans->data == NULL || l->data== NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - } - for (i=0; idata[i]==FL(0.0))) - return - csound->PerfError(csound, &(p->h), - Str("division by zero in array-var at index %d"), i); - else - ans->data[i] = MOD(r,l->data[i]); - } - return OK; + ARRAYDAT *ans = p->ans; + ARRAYDAT *l = p->right; + MYFLT r = *p->left; + int32_t sizel = l->sizes[0]; + int32_t i; + + if (UNLIKELY(ans->data == NULL || l->data== NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + } + for (i=0; idata[i]==FL(0.0))) + return + csound->PerfError(csound, &(p->h), + Str("division by zero in array-var at index %d"), i); + else + ans->data[i] = MOD(r,l->data[i]); + } + return OK; } // K[] pow K static int32_t tabaipow(CSOUND *csound, TABARITH1 *p) { - ARRAYDAT *ans = p->ans; - ARRAYDAT *l = p->left; - MYFLT r = *p->right; - int32_t sizel = l->sizes[0]; - int32_t i; - MYFLT tmp; - int32_t intcase = (MODF(r,&tmp)==FL(0.0)); - - if (UNLIKELY(ans->data == NULL || l->data== NULL)) + ARRAYDAT *ans = p->ans; + ARRAYDAT *l = p->left; + MYFLT r = *p->right; + int32_t sizel = l->sizes[0]; + int32_t i; + MYFLT tmp; + int32_t intcase = (MODF(r,&tmp)==FL(0.0)); + + if (UNLIKELY(ans->data == NULL || l->data== NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + } + for (i=0; idata[i]>=0)) + ans->data[i] = POWER(l->data[i], r); + else return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - } - for (i=0; idata[i]>=0)) - ans->data[i] = POWER(l->data[i], r); - else - return csound->PerfError(csound, &(p->h), - Str("undefined power in array-var at index %d"), - i); - } - return OK; + Str("undefined power in array-var at index %d"), + i); + } + return OK; } // K ^ K[] static int32_t tabiapow(CSOUND *csound, TABARITH2 *p) { - ARRAYDAT *ans = p->ans; - ARRAYDAT *l = p->right; - MYFLT r = *p->left; - int32_t sizel = l->sizes[0]; - int32_t i; - MYFLT tmp; - int32_t poscase = (r>=FL(0.0)); - - if (UNLIKELY(ans->data == NULL || l->data== NULL)) + ARRAYDAT *ans = p->ans; + ARRAYDAT *l = p->right; + MYFLT r = *p->left; + int32_t sizel = l->sizes[0]; + int32_t i; + MYFLT tmp; + int32_t poscase = (r>=FL(0.0)); + + if (UNLIKELY(ans->data == NULL || l->data== NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + } + for (i=0; idata[i],&tmp)==FL(0.0))) + ans->data[i] = POWER(r,l->data[i]); + else return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - } - for (i=0; idata[i],&tmp)==FL(0.0))) - ans->data[i] = POWER(r,l->data[i]); - else - return csound->PerfError(csound, &(p->h), - Str("undefined power in array-var at index %d"), - i); - } - return OK; + Str("undefined power in array-var at index %d"), + i); + } + return OK; } #define IiARRAY(opcode,fn) \ @@ -1309,1146 +1309,1146 @@ iIARRAY(tabiapowi,tabiapow) //a[]+a[] static int32_t tabaadd(CSOUND *csound, TABARITH *p) { - ARRAYDAT *ans = p->ans; - ARRAYDAT *l = p->left; - ARRAYDAT *r = p->right; - int32_t sizel = l->sizes[0]; - int32_t sizer = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerans; + ARRAYDAT *l = p->left; + ARRAYDAT *r = p->right; + int32_t sizel = l->sizes[0]; + int32_t sizer = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[j]); b = (MYFLT*)&(r->data[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); if (UNLIKELY(early)) { - nsmps -= early; - } - for (i=0; idata[j]); b = (MYFLT*)&(r->data[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; - ARRAYDAT *l = p->left; - ARRAYDAT *r = p->right; - int32_t sizel = l->sizes[0]; - int32_t sizer = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerans; + ARRAYDAT *l = p->left; + ARRAYDAT *r = p->right; + int32_t sizel = l->sizes[0]; + int32_t sizer = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[j]); b = (MYFLT*)&(r->data[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); if (UNLIKELY(early)) { - nsmps -= early; + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - for (i=0; idata[j]); b = (MYFLT*)&(r->data[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; - ARRAYDAT *l = p->left; - ARRAYDAT *r = p->right; - int32_t sizel = l->sizes[0]; - int32_t sizer = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerans; + ARRAYDAT *l = p->left; + ARRAYDAT *r = p->right; + int32_t sizel = l->sizes[0]; + int32_t sizer = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[j]); b = (MYFLT*)&(r->data[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); if (UNLIKELY(early)) { - nsmps -= early; + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - for (i=0; idata[j]); b = (MYFLT*)&(r->data[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; - ARRAYDAT *l = p->left; - ARRAYDAT *r = p->right; - int32_t sizel = l->sizes[0]; - int32_t sizer = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerans; + ARRAYDAT *l = p->left; + ARRAYDAT *r = p->right; + int32_t sizel = l->sizes[0]; + int32_t sizer = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[j]); b = (MYFLT*)&(r->data[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); if (UNLIKELY(early)) { - nsmps -= early; + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - for (i=0; idata[j]); b = (MYFLT*)&(r->data[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nPerfError(csound, &(p->h), - Str("division by zero in array-var " - "at index %d/%d"), i,n); - aa[n] = a[n] / b[n]; - } + for (n=offset; nPerfError(csound, &(p->h), + Str("division by zero in array-var " + "at index %d/%d"), i,n); + aa[n] = a[n] / b[n]; } - return OK; + } + return OK; } // k * a[] static int32_t tabkamult(CSOUND *csound, TABARITH2 *p) { - ARRAYDAT *ans = p->ans; - MYFLT l = *p->left; - ARRAYDAT *r = p->right; - int32_t sizel = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) - sizel*=r->sizes[i]; - for (i=0; idata[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + MYFLT l = *p->left; + ARRAYDAT *r = p->right; + int32_t sizel = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) + sizel*=r->sizes[i]; + for (i=0; idata[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - MYFLT l = *p->right; - ARRAYDAT *r = p->left; - int32_t sizel = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) - sizel*=r->sizes[i]; - for (i=0; idata[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + MYFLT l = *p->right; + ARRAYDAT *r = p->left; + int32_t sizel = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) + sizel*=r->sizes[i]; + for (i=0; idata[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - MYFLT l = *p->left; - ARRAYDAT *r = p->right; - int32_t sizel = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) - sizel*=r->sizes[i]; - for (i=0; idata[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + MYFLT l = *p->left; + ARRAYDAT *r = p->right; + int32_t sizel = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) + sizel*=r->sizes[i]; + for (i=0; idata[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - MYFLT l = *p->right; - ARRAYDAT *r = p->left; - int32_t sizel = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) - sizel*=r->sizes[i]; - for (i=0; idata[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + MYFLT l = *p->right; + ARRAYDAT *r = p->left; + int32_t sizel = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) + sizel*=r->sizes[i]; + for (i=0; idata[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - MYFLT l = *p->left; - ARRAYDAT *r = p->right; - int32_t sizel = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) - sizel*=r->sizes[i]; - for (i=0; idata[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + MYFLT l = *p->left; + ARRAYDAT *r = p->right; + int32_t sizel = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) + sizel*=r->sizes[i]; + for (i=0; idata[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - MYFLT l = *p->left; - ARRAYDAT *r = p->right; - int32_t sizel = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) - sizel*=r->sizes[i]; - for (i=0; idata[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nPerfError(csound, &(p->h), - Str("division by zero in array-var " - "at index %d/%d"), i,n); - aa[n] = l / b[n]; - } + ARRAYDAT *ans = p->ans; + MYFLT l = *p->left; + ARRAYDAT *r = p->right; + int32_t sizel = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) + sizel*=r->sizes[i]; + for (i=0; idata[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nPerfError(csound, &(p->h), + Str("division by zero in array-var " + "at index %d/%d"), i,n); + aa[n] = l / b[n]; + } + } + return OK; } // a[] / k static int32_t tabakdiv(CSOUND *csound, TABARITH1 *p) { - ARRAYDAT *ans = p->ans; - MYFLT l = *p->right; - ARRAYDAT *r = p->left; - int32_t sizel = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - if (UNLIKELY(l==FL(0.0))) - return csound->PerfError(csound, &(p->h), - "%s", Str("division by zero in array-var")); - - for (i=1; idimensions; i++) - sizel*=r->sizes[i]; - for (i=0; idata[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + MYFLT l = *p->right; + ARRAYDAT *r = p->left; + int32_t sizel = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + if (UNLIKELY(l==FL(0.0))) + return csound->PerfError(csound, &(p->h), + "%s", Str("division by zero in array-var")); + + for (i=1; idimensions; i++) + sizel*=r->sizes[i]; + for (i=0; idata[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - MYFLT l = *p->right; - ARRAYDAT *r = p->left; - int32_t sizel = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - if (UNLIKELY(l==FL(0.0))) - return csound->PerfError(csound, &(p->h), - "%s", Str("division by zero in array-var")); - - for (i=1; idimensions; i++) - sizel*=r->sizes[i]; - for (i=0; idata[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + MYFLT l = *p->right; + ARRAYDAT *r = p->left; + int32_t sizel = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + if (UNLIKELY(l==FL(0.0))) + return csound->PerfError(csound, &(p->h), + "%s", Str("division by zero in array-var")); + + for (i=1; idimensions; i++) + sizel*=r->sizes[i]; + for (i=0; idata[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - MYFLT l = *p->right; - ARRAYDAT *r = p->left; - int32_t sizel = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) - sizel*=r->sizes[i]; - for (i=0; idata[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + MYFLT l = *p->right; + ARRAYDAT *r = p->left; + int32_t sizel = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) + sizel*=r->sizes[i]; + for (i=0; idata[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - ARRAYDAT *r = p->right; - MYFLT *a = p->left; - int32_t sizel = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) - sizel*=r->sizes[i]; - for (i=0; idata[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + ARRAYDAT *r = p->right; + MYFLT *a = p->left; + int32_t sizel = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) + sizel*=r->sizes[i]; + for (i=0; idata[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - ARRAYDAT *r = p->right; - MYFLT *a = p->left; - int32_t sizel = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) - sizel*=r->sizes[i]; - for (i=0; idata[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + ARRAYDAT *r = p->right; + MYFLT *a = p->left; + int32_t sizel = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) + sizel*=r->sizes[i]; + for (i=0; idata[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - ARRAYDAT *r = p->right; - MYFLT *a = p->left; - int32_t sizel = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) - sizel*=r->sizes[i]; - for (i=0; idata[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + ARRAYDAT *r = p->right; + MYFLT *a = p->left; + int32_t sizel = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) + sizel*=r->sizes[i]; + for (i=0; idata[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - ARRAYDAT *r = p->right; - MYFLT *a = p->left; - int32_t sizel = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) - sizel*=r->sizes[i]; - for (i=0; idata[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + ARRAYDAT *r = p->right; + MYFLT *a = p->left; + int32_t sizel = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) + sizel*=r->sizes[i]; + for (i=0; idata[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - ARRAYDAT *l = p->left; - MYFLT *b = p->right; - int32_t sizel = l->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || l->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) - sizel*=l->sizes[i]; - for (i=0; idata[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + ARRAYDAT *l = p->left; + MYFLT *b = p->right; + int32_t sizel = l->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || l->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) + sizel*=l->sizes[i]; + for (i=0; idata[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - ARRAYDAT *l = p->left; - MYFLT *b = p->right; - int32_t sizel = l->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || l->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) - sizel*=l->sizes[i]; - for (i=0; idata[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + ARRAYDAT *l = p->left; + MYFLT *b = p->right; + int32_t sizel = l->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || l->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) + sizel*=l->sizes[i]; + for (i=0; idata[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - ARRAYDAT *l = p->left; - MYFLT *b = p->right; - int32_t sizel = l->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || l->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) - sizel*=l->sizes[i]; - for (i=0; idata[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + ARRAYDAT *l = p->left; + MYFLT *b = p->right; + int32_t sizel = l->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || l->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) + sizel*=l->sizes[i]; + for (i=0; idata[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - ARRAYDAT *l = p->left; - MYFLT *b = p->right; - int32_t sizel = l->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || l->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) - sizel*=l->sizes[i]; - for (i=0; idata[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + ARRAYDAT *l = p->left; + MYFLT *b = p->right; + int32_t sizel = l->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || l->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) + sizel*=l->sizes[i]; + for (i=0; idata[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - ARRAYDAT *l = p->left; - ARRAYDAT *r = p->right; - int32_t sizel = l->sizes[0]; - int32_t sizer = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerdata[i]; b = (MYFLT*)&(r->data[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + ARRAYDAT *l = p->left; + ARRAYDAT *r = p->right; + int32_t sizel = l->sizes[0]; + int32_t sizer = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[i]; b = (MYFLT*)&(r->data[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - ARRAYDAT *l = p->left; - ARRAYDAT *r = p->right; - int32_t sizel = l->sizes[0]; - int32_t sizer = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerdata[i]; b = (MYFLT*)&(r->data[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + ARRAYDAT *l = p->left; + ARRAYDAT *r = p->right; + int32_t sizel = l->sizes[0]; + int32_t sizer = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[i]; b = (MYFLT*)&(r->data[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - ARRAYDAT *l = p->left; - ARRAYDAT *r = p->right; - int32_t sizel = l->sizes[0]; - int32_t sizer = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerdata[i]; b = (MYFLT*)&(r->data[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + ARRAYDAT *l = p->left; + ARRAYDAT *r = p->right; + int32_t sizel = l->sizes[0]; + int32_t sizer = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[i]; b = (MYFLT*)&(r->data[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - ARRAYDAT *l = p->left; - ARRAYDAT *r = p->right; - int32_t sizel = l->sizes[0]; - int32_t sizer = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerdata[i]; b = (MYFLT*)&(r->data[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + ARRAYDAT *l = p->left; + ARRAYDAT *r = p->right; + int32_t sizel = l->sizes[0]; + int32_t sizer = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[i]; b = (MYFLT*)&(r->data[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - ARRAYDAT *l = p->left; - ARRAYDAT *r = p->right; - int32_t sizel = l->sizes[0]; - int32_t sizer = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerdata[i]; b = (MYFLT*)&(r->data[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + ARRAYDAT *l = p->left; + ARRAYDAT *r = p->right; + int32_t sizel = l->sizes[0]; + int32_t sizer = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[i]; b = (MYFLT*)&(r->data[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - ARRAYDAT *l = p->left; - ARRAYDAT *r = p->right; - int32_t sizel = l->sizes[0]; - int32_t sizer = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerdata[i]; a = (MYFLT*)&(l->data[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + ARRAYDAT *l = p->left; + ARRAYDAT *r = p->right; + int32_t sizel = l->sizes[0]; + int32_t sizer = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[i]; a = (MYFLT*)&(l->data[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - ARRAYDAT *l = p->left; - ARRAYDAT *r = p->right; - int32_t sizel = l->sizes[0]; - int32_t sizer = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerdata[i]; a = (MYFLT*)&(l->data[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + ARRAYDAT *l = p->left; + ARRAYDAT *r = p->right; + int32_t sizel = l->sizes[0]; + int32_t sizer = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[i]; a = (MYFLT*)&(l->data[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - ARRAYDAT *l = p->left; - ARRAYDAT *r = p->right; - int32_t sizel = l->sizes[0]; - int32_t sizer = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerdata[i]; a = (MYFLT*)&(l->data[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + ARRAYDAT *l = p->left; + ARRAYDAT *r = p->right; + int32_t sizel = l->sizes[0]; + int32_t sizer = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[i]; a = (MYFLT*)&(l->data[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - ARRAYDAT *l = p->left; - ARRAYDAT *r = p->right; - int32_t sizel = l->sizes[0]; - int32_t sizer = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerdata[i]; a = (MYFLT*)&(l->data[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + ARRAYDAT *l = p->left; + ARRAYDAT *r = p->right; + int32_t sizel = l->sizes[0]; + int32_t sizer = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[i]; a = (MYFLT*)&(l->data[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - ARRAYDAT *l = p->left; - ARRAYDAT *r = p->right; - int32_t sizel = l->sizes[0]; - int32_t sizer = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerdata[i]; a = (MYFLT*)&(l->data[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + ARRAYDAT *l = p->left; + ARRAYDAT *r = p->right; + int32_t sizel = l->sizes[0]; + int32_t sizer = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[i]; a = (MYFLT*)&(l->data[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; nans; - ARRAYDAT *l = p->left; - ARRAYDAT *r = p->right; - int32_t sizel = l->sizes[0]; - int32_t sizer = r->sizes[0]; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t i, n, nsmps = CS_KSMPS-early; - int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - - for (i=1; idimensions; i++) { - sizel*=l->sizes[i]; - sizer*=r->sizes[i]; - } - if (sizerdata[i]; a = (MYFLT*)&(l->data[j]); - aa = (MYFLT*)&(ans->data[j]); - if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset; nans; + ARRAYDAT *l = p->left; + ARRAYDAT *r = p->right; + int32_t sizel = l->sizes[0]; + int32_t sizer = r->sizes[0]; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t i, n, nsmps = CS_KSMPS-early; + int32_t span = (ans->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(ans->data == NULL || l->data==NULL || r->data==NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + + for (i=1; idimensions; i++) { + sizel*=l->sizes[i]; + sizer*=r->sizes[i]; + } + if (sizerdata[i]; a = (MYFLT*)&(l->data[j]); + aa = (MYFLT*)&(ans->data[j]); + if (UNLIKELY(offset)) memset(aa, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + memset(&aa[nsmps], '\0', early*sizeof(MYFLT)); } - return OK; + for (n=offset; ntab->data)) return OK; - return csound->InitError(csound, "%s", Str("array-variable not initialised")); + if (LIKELY(p->tab->data)) return OK; + return csound->InitError(csound, "%s", Str("array-variable not initialised")); } static int32_t tabqset1(CSOUND *csound, TABQUERY1 *p) { - if (LIKELY(p->tab->data)) return OK; - return csound->InitError(csound, "%s", Str("array-variable not initialised")); + if (LIKELY(p->tab->data)) return OK; + return csound->InitError(csound, "%s", Str("array-variable not initialised")); } static int32_t tabmax(CSOUND *csound, TABQUERY *p) { - ARRAYDAT *t = p->tab; - int32_t i, size = 0, pos = 0;; - MYFLT ans; - - if (UNLIKELY(t->data == NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - /* if (UNLIKELY(t->dimensions!=1)) */ - /* return csound->PerfError(csound, &(p->h), */ - /* Str("array-variable not vector")); */ - - for (i=0; idimensions; i++) size += t->sizes[i]; - ans = t->data[0]; - for (i=1; idata[i]>ans) { - ans = t->data[i]; - pos = i; - } - *p->ans = ans; - if (p->OUTOCOUNT>1) *p->pos = (MYFLT)pos; - return OK; + ARRAYDAT *t = p->tab; + int32_t i, size = 0, pos = 0;; + MYFLT ans; + + if (UNLIKELY(t->data == NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + /* if (UNLIKELY(t->dimensions!=1)) */ + /* return csound->PerfError(csound, &(p->h), */ + /* Str("array-variable not vector")); */ + + for (i=0; idimensions; i++) size += t->sizes[i]; + ans = t->data[0]; + for (i=1; idata[i]>ans) { + ans = t->data[i]; + pos = i; + } + *p->ans = ans; + if (p->OUTOCOUNT>1) *p->pos = (MYFLT)pos; + return OK; } static int32_t tabmax1(CSOUND *csound, TABQUERY *p) { - if (tabqset(csound, p) == OK) return tabmax(csound, p); - else return NOTOK; + if (tabqset(csound, p) == OK) return tabmax(csound, p); + else return NOTOK; } static int32_t tabmin(CSOUND *csound, TABQUERY *p) { - ARRAYDAT *t = p->tab; - int32_t i, size = 0, pos = 0; - MYFLT ans; - - if (UNLIKELY(t->data == NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - /* if (UNLIKELY(t->dimensions!=1)) */ - /* return csound->PerfError(csound, - &(p->h), Str("array-variable not a vector")); */ - - for (i=0; idimensions; i++) size += t->sizes[i]; - ans = t->data[0]; - for (i=1; idata[i]data[i]; - pos = i; - } - *p->ans = ans; - if (p->OUTOCOUNT>1) *p->pos = (MYFLT)pos; - return OK; + ARRAYDAT *t = p->tab; + int32_t i, size = 0, pos = 0; + MYFLT ans; + + if (UNLIKELY(t->data == NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + /* if (UNLIKELY(t->dimensions!=1)) */ + /* return csound->PerfError(csound, + &(p->h), Str("array-variable not a vector")); */ + + for (i=0; idimensions; i++) size += t->sizes[i]; + ans = t->data[0]; + for (i=1; idata[i]data[i]; + pos = i; + } + *p->ans = ans; + if (p->OUTOCOUNT>1) *p->pos = (MYFLT)pos; + return OK; } static int32_t tabmin1(CSOUND *csound, TABQUERY *p) { - if (LIKELY(tabqset(csound, p) == OK)) return tabmin(csound, p); - else return NOTOK; + if (LIKELY(tabqset(csound, p) == OK)) return tabmin(csound, p); + else return NOTOK; } static int32_t tabsuma(CSOUND *csound, TABQUERY1 *p) { - ARRAYDAT *t = p->tab; - int32_t i, numarrays = 0; - MYFLT *ans = p->ans, *in0, *in1, *in2, *in3; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t nsmps = CS_KSMPS; - int32_t span = (t->arrayMemberSize)/sizeof(MYFLT); - - if (UNLIKELY(t->data == NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - if (UNLIKELY(t->dimensions!=1)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not a vector")); - - - if (UNLIKELY(offset)) memset(ans, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - nsmps -= early; - memset(&ans[nsmps], '\0', early*sizeof(MYFLT)); - } + ARRAYDAT *t = p->tab; + int32_t i, numarrays = 0; + MYFLT *ans = p->ans, *in0, *in1, *in2, *in3; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t nsmps = CS_KSMPS; + int32_t span = (t->arrayMemberSize)/sizeof(MYFLT); + + if (UNLIKELY(t->data == NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + if (UNLIKELY(t->dimensions!=1)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not a vector")); + + + if (UNLIKELY(offset)) memset(ans, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + nsmps -= early; + memset(&ans[nsmps], '\0', early*sizeof(MYFLT)); + } - for (i=0; idimensions; i++) numarrays += t->sizes[i]; + for (i=0; idimensions; i++) numarrays += t->sizes[i]; - memset(&ans[offset], '\0', nsmps*sizeof(MYFLT)); + memset(&ans[offset], '\0', nsmps*sizeof(MYFLT)); - int numarrays4 = numarrays - (numarrays % 4); + int numarrays4 = numarrays - (numarrays % 4); - for (i=0; idata[i*span]); - in1 = &(t->data[(i+1)*span]); - in2 = &(t->data[(i+2)*span]); - in3 = &(t->data[(i+3)*span]); + for (i=0; idata[i*span]); + in1 = &(t->data[(i+1)*span]); + in2 = &(t->data[(i+2)*span]); + in3 = &(t->data[(i+3)*span]); - for(int j=offset; j < nsmps; j++) { - ans[j] += in0[j] + in1[j] + in2[j] + in3[j]; - } + for(int j=offset; j < nsmps; j++) { + ans[j] += in0[j] + in1[j] + in2[j] + in3[j]; } + } - for (i=numarrays4;idata[i*span]); - for(int j=offset; j < nsmps; j++) { - ans[j] += in0[j]; - } + for (i=numarrays4;idata[i*span]); + for(int j=offset; j < nsmps; j++) { + ans[j] += in0[j]; } - return OK; + } + return OK; } static int32_t tabclearset(CSOUND *csound, TABCLEAR *p) { - if (LIKELY(p->tab->data)) return OK; - return csound->InitError(csound, "%s", Str("array-variable not initialised")); + if (LIKELY(p->tab->data)) return OK; + return csound->InitError(csound, "%s", Str("array-variable not initialised")); } static int32_t tabclear(CSOUND *csound, TABCLEAR *p) { - ARRAYDAT *t = p->tab; - int32_t i; - int32_t nsmps = CS_KSMPS; - int32_t size = 1; + ARRAYDAT *t = p->tab; + int32_t i; + int32_t nsmps = CS_KSMPS; + int32_t size = 1; - if (UNLIKELY(t->data == NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - /* if (UNLIKELY(t->dimensions!=1)) */ - /* return csound->PerfError(csound, &(p->h), */ - /* Str("array-variable not a vector")); */ - - for(i = 0; i < t->dimensions; i++) size *= t->sizes[i]; - memset(t->data, 0, sizeof(MYFLT)*nsmps*size); + if (UNLIKELY(t->data == NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + /* if (UNLIKELY(t->dimensions!=1)) */ + /* return csound->PerfError(csound, &(p->h), */ + /* Str("array-variable not a vector")); */ + + for(i = 0; i < t->dimensions; i++) size *= t->sizes[i]; + memset(t->data, 0, sizeof(MYFLT)*nsmps*size); - return OK; + return OK; } static int32_t tabcleark(CSOUND *csound, TABCLEAR *p) { - ARRAYDAT *t = p->tab; - int32_t i; - int32_t size = 1; + ARRAYDAT *t = p->tab; + int32_t i; + int32_t size = 1; - if (UNLIKELY(t->data == NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - /* if (UNLIKELY(t->dimensions!=1)) */ - /* return csound->PerfError(csound, &(p->h), */ - /* Str("array-variable not a vector")); */ - - for(i = 0; i < t->dimensions; i++) size *= t->sizes[i]; - memset(t->data, 0, sizeof(MYFLT)*size); + if (UNLIKELY(t->data == NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + /* if (UNLIKELY(t->dimensions!=1)) */ + /* return csound->PerfError(csound, &(p->h), */ + /* Str("array-variable not a vector")); */ + + for(i = 0; i < t->dimensions; i++) size *= t->sizes[i]; + memset(t->data, 0, sizeof(MYFLT)*size); - return OK; + return OK; } static int32_t tabsum(CSOUND *csound, TABQUERY1 *p) { - ARRAYDAT *t = p->tab; - int32_t i, size = 0; - MYFLT ans; - - if (UNLIKELY(t->data == NULL)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not initialised")); - if (UNLIKELY(t->dimensions!=1)) - return csound->PerfError(csound, &(p->h), - "%s", Str("array-variable not a vector")); - ans = t->data[0]; - for (i=0; idimensions; i++) size += t->sizes[i]; - for (i=1; idata[i]; - *p->ans = ans; - return OK; + ARRAYDAT *t = p->tab; + int32_t i, size = 0; + MYFLT ans; + + if (UNLIKELY(t->data == NULL)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not initialised")); + if (UNLIKELY(t->dimensions!=1)) + return csound->PerfError(csound, &(p->h), + "%s", Str("array-variable not a vector")); + ans = t->data[0]; + for (i=0; idimensions; i++) size += t->sizes[i]; + for (i=1; idata[i]; + *p->ans = ans; + return OK; } static int32_t tabsuma1(CSOUND *csound, TABQUERY1 *p) { - if (LIKELY(tabqset1(csound, p) == OK)) return tabsuma(csound, p); - else return NOTOK; + if (LIKELY(tabqset1(csound, p) == OK)) return tabsuma(csound, p); + else return NOTOK; } static int32_t tabsum1(CSOUND *csound, TABQUERY1 *p) { - if (LIKELY(tabqset1(csound, p) == OK)) return tabsum(csound, p); - else return NOTOK; + if (LIKELY(tabqset1(csound, p) == OK)) return tabsum(csound, p); + else return NOTOK; } static int32_t tabscaleset(CSOUND *csound, TABSCALE *p) { - if (LIKELY(p->tab->data && p->tab->dimensions==1)) return OK; - return csound->InitError(csound, "%s", Str("array-variable not initialised")); + if (LIKELY(p->tab->data && p->tab->dimensions==1)) return OK; + return csound->InitError(csound, "%s", Str("array-variable not initialised")); } static int32_t tabscale(CSOUND *csound, TABSCALE *p) { - IGN(csound); - MYFLT min = *p->kmin, max = *p->kmax; - int32_t strt = (int32_t)MYFLT2LRND(*p->kstart), - end = (int32_t)MYFLT2LRND(*p->kend); - ARRAYDAT *t = p->tab; - MYFLT tmin; - MYFLT tmax; - int32_t i; - MYFLT range; - - tmin = t->data[strt]; - tmax = tmin; - - // Correct start and ending points - if (end<0) end = t->sizes[0]; - else if (end>t->sizes[0]) end = t->sizes[0]; - if (strt<0) strt = 0; - else if (strt>t->sizes[0]) strt = t->sizes[0]; - if (enddata[i]data[i]; - if (t->data[i]>tmax) tmax = t->data[i]; - } - /* printf("start/end %d/%d max/min = %g/%g tmax/tmin = %g/%g range=%g\n", */ - /* strt, end, max, min, tmax, tmin, range); */ - range = (max-min)/(tmax-tmin); - for (i=strt; idata[i] = (t->data[i]-tmin)*range + min; - } - return OK; + IGN(csound); + MYFLT min = *p->kmin, max = *p->kmax; + int32_t strt = (int32_t)MYFLT2LRND(*p->kstart), + end = (int32_t)MYFLT2LRND(*p->kend); + ARRAYDAT *t = p->tab; + MYFLT tmin; + MYFLT tmax; + int32_t i; + MYFLT range; + + tmin = t->data[strt]; + tmax = tmin; + + // Correct start and ending points + if (end<0) end = t->sizes[0]; + else if (end>t->sizes[0]) end = t->sizes[0]; + if (strt<0) strt = 0; + else if (strt>t->sizes[0]) strt = t->sizes[0]; + if (enddata[i]data[i]; + if (t->data[i]>tmax) tmax = t->data[i]; + } + /* printf("start/end %d/%d max/min = %g/%g tmax/tmin = %g/%g range=%g\n", */ + /* strt, end, max, min, tmax, tmin, range); */ + range = (max-min)/(tmax-tmin); + for (i=strt; idata[i] = (t->data[i]-tmin)*range + min; + } + return OK; } static int32_t tabscale1(CSOUND *csound, TABSCALE *p) { - if (LIKELY(tabscaleset(csound, p) == OK)) return tabscale(csound, p); - else return NOTOK; + if (LIKELY(tabscaleset(csound, p) == OK)) return tabscale(csound, p); + else return NOTOK; } typedef struct { @@ -2723,264 +2723,264 @@ typedef struct { static int32_t get_array_total_size(ARRAYDAT* dat) { - int32_t i; - int32_t size; + int32_t i; + int32_t size; - if (UNLIKELY(dat->sizes == NULL)) { - return -1; - } + if (UNLIKELY(dat->sizes == NULL)) { + return -1; + } - size = dat->sizes[0]; - for (i = 1; i < dat->dimensions; i++) { - size *= dat->sizes[i]; - } - return size; + size = dat->sizes[0]; + for (i = 1; i < dat->dimensions; i++) { + size *= dat->sizes[i]; + } + return size; } static int32_t tabcopy(CSOUND *csound, TABCPY *p) { - int32_t i, arrayTotalSize, memMyfltSize; + int32_t i, arrayTotalSize, memMyfltSize; - if (UNLIKELY(p->src->data==NULL) || p->src->dimensions <= 0 ) - return csound->InitError(csound, "%s", Str("array-variable not initialised")); - if (UNLIKELY(p->dst->dimensions > 0 && - p->src->dimensions != p->dst->dimensions)) - return csound->InitError(csound, "%s", - Str("array-variable dimensions do not match")); - if (UNLIKELY(p->src->arrayType != p->dst->arrayType)) - return csound->InitError(csound, "%s", - Str("array-variable types do not match")); + if (UNLIKELY(p->src->data==NULL) || p->src->dimensions <= 0 ) + return csound->InitError(csound, "%s", Str("array-variable not initialised")); + if (UNLIKELY(p->dst->dimensions > 0 && + p->src->dimensions != p->dst->dimensions)) + return csound->InitError(csound, "%s", + Str("array-variable dimensions do not match")); + if (UNLIKELY(p->src->arrayType != p->dst->arrayType)) + return csound->InitError(csound, "%s", + Str("array-variable types do not match")); - if (p->src == p->dst) return OK; + if (p->src == p->dst) return OK; - arrayTotalSize = get_array_total_size(p->src); - memMyfltSize = p->src->arrayMemberSize / sizeof(MYFLT); - p->dst->arrayMemberSize = p->src->arrayMemberSize; + arrayTotalSize = get_array_total_size(p->src); + memMyfltSize = p->src->arrayMemberSize / sizeof(MYFLT); + p->dst->arrayMemberSize = p->src->arrayMemberSize; - if (arrayTotalSize != get_array_total_size(p->dst)) { - p->dst->dimensions = p->src->dimensions; + if (arrayTotalSize != get_array_total_size(p->dst)) { + p->dst->dimensions = p->src->dimensions; - p->dst->sizes = csound->Malloc(csound, sizeof(int32_t) * p->src->dimensions); - memcpy(p->dst->sizes, p->src->sizes, sizeof(int32_t) * p->src->dimensions); + p->dst->sizes = csound->Malloc(csound, sizeof(int32_t) * p->src->dimensions); + memcpy(p->dst->sizes, p->src->sizes, sizeof(int32_t) * p->src->dimensions); - if (p->dst->data == NULL) { - p->dst->data = csound->Calloc(csound, - p->src->arrayMemberSize * arrayTotalSize); - p->dst->allocated = p->src->arrayMemberSize * arrayTotalSize; - } else { - p->dst->data = csound->ReAlloc(csound, p->dst->data, - p->src->arrayMemberSize * arrayTotalSize); - memset(p->dst->data, 0, p->src->arrayMemberSize * arrayTotalSize); - } + if (p->dst->data == NULL) { + p->dst->data = csound->Calloc(csound, + p->src->arrayMemberSize * arrayTotalSize); + p->dst->allocated = p->src->arrayMemberSize * arrayTotalSize; + } else { + p->dst->data = csound->ReAlloc(csound, p->dst->data, + p->src->arrayMemberSize * arrayTotalSize); + memset(p->dst->data, 0, p->src->arrayMemberSize * arrayTotalSize); } + } - for (i = 0; i < arrayTotalSize; i++) { - int32_t index = (i * memMyfltSize); - p->dst->arrayType->copyValue(csound, p->dst->arrayType, - (void*)(p->dst->data + index), - (void*)(p->src->data + index)); - } + for (i = 0; i < arrayTotalSize; i++) { + int32_t index = (i * memMyfltSize); + p->dst->arrayType->copyValue(csound, p->dst->arrayType, + (void*)(p->dst->data + index), + (void*)(p->src->data + index)); + } - return OK; + return OK; } static int32_t tabcopyk_init(CSOUND *csound, TABCPY *p) { - tabinit(csound, p->dst, get_array_total_size(p->src)); - return OK; + tabinit(csound, p->dst, get_array_total_size(p->src)); + return OK; } static int32_t tabcopyk(CSOUND *csound, TABCPY *p) { - int32_t i, arrayTotalSize, memMyfltSize; - - if (UNLIKELY(p->src->data==NULL) || p->src->dimensions <= 0 ) - return csound->PerfError(csound, &(p->h), "%s", Str("array-variable not initialised")); - if (UNLIKELY(p->dst->dimensions > 0 && - p->src->dimensions != p->dst->dimensions)) - return csound->PerfError(csound,&(p->h), "%s", - Str("array-variable dimensions do not match")); - if (UNLIKELY(p->src->arrayType != p->dst->arrayType)) - return csound->PerfError(csound, &(p->h), "%s", - Str("array-variable types do not match")); - - if (p->src == p->dst) return OK; - - arrayTotalSize = get_array_total_size(p->src); - memMyfltSize = p->src->arrayMemberSize / sizeof(MYFLT); - p->dst->arrayMemberSize = p->src->arrayMemberSize; - - if (arrayTotalSize != get_array_total_size(p->dst)) { - p->dst->dimensions = p->src->dimensions; - - p->dst->sizes = csound->Malloc(csound, sizeof(int32_t) * p->src->dimensions); - memcpy(p->dst->sizes, p->src->sizes, sizeof(int32_t) * p->src->dimensions); - - if (p->dst->data == NULL) { - p->dst->data = csound->Calloc(csound, - p->src->arrayMemberSize * arrayTotalSize); - p->dst->allocated = p->src->arrayMemberSize * arrayTotalSize; - } else { - p->dst->data = csound->ReAlloc(csound, p->dst->data, - p->src->arrayMemberSize * arrayTotalSize); - memset(p->dst->data, 0, p->src->arrayMemberSize * arrayTotalSize); - } + int32_t i, arrayTotalSize, memMyfltSize; + + if (UNLIKELY(p->src->data==NULL) || p->src->dimensions <= 0 ) + return csound->PerfError(csound, &(p->h), "%s", Str("array-variable not initialised")); + if (UNLIKELY(p->dst->dimensions > 0 && + p->src->dimensions != p->dst->dimensions)) + return csound->PerfError(csound,&(p->h), "%s", + Str("array-variable dimensions do not match")); + if (UNLIKELY(p->src->arrayType != p->dst->arrayType)) + return csound->PerfError(csound, &(p->h), "%s", + Str("array-variable types do not match")); + + if (p->src == p->dst) return OK; + + arrayTotalSize = get_array_total_size(p->src); + memMyfltSize = p->src->arrayMemberSize / sizeof(MYFLT); + p->dst->arrayMemberSize = p->src->arrayMemberSize; + + if (arrayTotalSize != get_array_total_size(p->dst)) { + p->dst->dimensions = p->src->dimensions; + + p->dst->sizes = csound->Malloc(csound, sizeof(int32_t) * p->src->dimensions); + memcpy(p->dst->sizes, p->src->sizes, sizeof(int32_t) * p->src->dimensions); + + if (p->dst->data == NULL) { + p->dst->data = csound->Calloc(csound, + p->src->arrayMemberSize * arrayTotalSize); + p->dst->allocated = p->src->arrayMemberSize * arrayTotalSize; + } else { + p->dst->data = csound->ReAlloc(csound, p->dst->data, + p->src->arrayMemberSize * arrayTotalSize); + memset(p->dst->data, 0, p->src->arrayMemberSize * arrayTotalSize); } + } - for (i = 0; i < arrayTotalSize; i++) { - int32_t index = (i * memMyfltSize); - p->dst->arrayType->copyValue(csound, p->dst->arrayType, - (void*)(p->dst->data + index), - (void*)(p->src->data + index)); - } + for (i = 0; i < arrayTotalSize; i++) { + int32_t index = (i * memMyfltSize); + p->dst->arrayType->copyValue(csound, p->dst->arrayType, + (void*)(p->dst->data + index), + (void*)(p->src->data + index)); + } - return OK; + return OK; } static int32_t tabcopy1(CSOUND *csound, TABCPY *p) { - int32_t i, arrayTotalSize, memMyfltSize; + int32_t i, arrayTotalSize, memMyfltSize; - if (UNLIKELY(p->src->data==NULL) || p->src->dimensions <= 0 ) - return csound->InitError(csound, "%s", Str("array-variable not initialised")); - if (p->dst->dimensions > 0 && p->src->dimensions != p->dst->dimensions) - return csound->InitError(csound, "%s", - Str("array-variable dimensions do not match")); -// if (p->src->arrayType != p->dst->arrayType) -// return csound->InitError(csound, "%s", -// Str("array-variable types do not match")); + if (UNLIKELY(p->src->data==NULL) || p->src->dimensions <= 0 ) + return csound->InitError(csound, "%s", Str("array-variable not initialised")); + if (p->dst->dimensions > 0 && p->src->dimensions != p->dst->dimensions) + return csound->InitError(csound, "%s", + Str("array-variable dimensions do not match")); + // if (p->src->arrayType != p->dst->arrayType) + // return csound->InitError(csound, "%s", + // Str("array-variable types do not match")); - if (p->src == p->dst) return OK; + if (p->src == p->dst) return OK; - arrayTotalSize = get_array_total_size(p->src); - memMyfltSize = p->src->arrayMemberSize / sizeof(MYFLT); - p->dst->arrayMemberSize = p->src->arrayMemberSize; + arrayTotalSize = get_array_total_size(p->src); + memMyfltSize = p->src->arrayMemberSize / sizeof(MYFLT); + p->dst->arrayMemberSize = p->src->arrayMemberSize; - if (arrayTotalSize != get_array_total_size(p->dst)) { - p->dst->dimensions = p->src->dimensions; + if (arrayTotalSize != get_array_total_size(p->dst)) { + p->dst->dimensions = p->src->dimensions; - p->dst->sizes = csound->Malloc(csound, sizeof(int32_t) * p->src->dimensions); - memcpy(p->dst->sizes, p->src->sizes, sizeof(int32_t) * p->src->dimensions); + p->dst->sizes = csound->Malloc(csound, sizeof(int32_t) * p->src->dimensions); + memcpy(p->dst->sizes, p->src->sizes, sizeof(int32_t) * p->src->dimensions); - if (p->dst->data == NULL) { - p->dst->data = csound->Calloc(csound, - p->src->arrayMemberSize * arrayTotalSize); - p->dst->allocated = p->src->arrayMemberSize * arrayTotalSize; - } else { - p->dst->data = csound->ReAlloc(csound, p->dst->data, - p->src->arrayMemberSize * arrayTotalSize); - memset(p->dst->data, 0, p->src->arrayMemberSize * arrayTotalSize); - } + if (p->dst->data == NULL) { + p->dst->data = csound->Calloc(csound, + p->src->arrayMemberSize * arrayTotalSize); + p->dst->allocated = p->src->arrayMemberSize * arrayTotalSize; + } else { + p->dst->data = csound->ReAlloc(csound, p->dst->data, + p->src->arrayMemberSize * arrayTotalSize); + memset(p->dst->data, 0, p->src->arrayMemberSize * arrayTotalSize); } + } - for (i = 0; i < arrayTotalSize; i++) { - int32_t index = (i * memMyfltSize); - p->dst->arrayType->copyValue(csound, - p->dst->arrayType, - (void*)(p->dst->data + index), - (void*)(p->src->data + index)); - } + for (i = 0; i < arrayTotalSize; i++) { + int32_t index = (i * memMyfltSize); + p->dst->arrayType->copyValue(csound, + p->dst->arrayType, + (void*)(p->dst->data + index), + (void*)(p->src->data + index)); + } - return OK; + return OK; } static int32_t tabcopy2(CSOUND *csound, TABCPY *p) { /* Like tabcopy but sample-accurate */ - int32_t i, j, arrayTotalSize; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - int32_t nsmps = CS_KSMPS; - MYFLT * dest, *src; - uint32_t k; - - if (UNLIKELY(p->src->data==NULL) || p->src->dimensions <= 0 ) - return csound->InitError(csound, "%s", Str("array-variable not initialised")); - if (UNLIKELY(p->dst->dimensions > 0 && - p->src->dimensions != p->dst->dimensions)) - return csound->InitError(csound, "%s", - Str("array-variable dimensions do not match")); - if (UNLIKELY(p->src->arrayType != p->dst->arrayType)) - return csound->InitError(csound, "%s", - Str("array-variable types do not match")); + int32_t i, j, arrayTotalSize; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + int32_t nsmps = CS_KSMPS; + MYFLT * dest, *src; + uint32_t k; + + if (UNLIKELY(p->src->data==NULL) || p->src->dimensions <= 0 ) + return csound->InitError(csound, "%s", Str("array-variable not initialised")); + if (UNLIKELY(p->dst->dimensions > 0 && + p->src->dimensions != p->dst->dimensions)) + return csound->InitError(csound, "%s", + Str("array-variable dimensions do not match")); + if (UNLIKELY(p->src->arrayType != p->dst->arrayType)) + return csound->InitError(csound, "%s", + Str("array-variable types do not match")); - if (p->src == p->dst) return OK; + if (p->src == p->dst) return OK; - arrayTotalSize = get_array_total_size(p->src); - p->dst->arrayMemberSize = p->src->arrayMemberSize; + arrayTotalSize = get_array_total_size(p->src); + p->dst->arrayMemberSize = p->src->arrayMemberSize; - if (arrayTotalSize != get_array_total_size(p->dst)) { - p->dst->dimensions = p->src->dimensions; + if (arrayTotalSize != get_array_total_size(p->dst)) { + p->dst->dimensions = p->src->dimensions; - p->dst->sizes = csound->Malloc(csound, sizeof(int32_t) * p->src->dimensions); - memcpy(p->dst->sizes, p->src->sizes, sizeof(int32_t) * p->src->dimensions); + p->dst->sizes = csound->Malloc(csound, sizeof(int32_t) * p->src->dimensions); + memcpy(p->dst->sizes, p->src->sizes, sizeof(int32_t) * p->src->dimensions); - if (p->dst->data == NULL) { - p->dst->data = csound->Calloc(csound, - p->src->arrayMemberSize * arrayTotalSize); - p->dst->allocated = p->src->arrayMemberSize * arrayTotalSize; - } else { - p->dst->data = csound->ReAlloc(csound, p->dst->data, - p->src->arrayMemberSize * arrayTotalSize); - memset(p->dst->data, 0, p->src->arrayMemberSize * arrayTotalSize); - } + if (p->dst->data == NULL) { + p->dst->data = csound->Calloc(csound, + p->src->arrayMemberSize * arrayTotalSize); + p->dst->allocated = p->src->arrayMemberSize * arrayTotalSize; + } else { + p->dst->data = csound->ReAlloc(csound, p->dst->data, + p->src->arrayMemberSize * arrayTotalSize); + memset(p->dst->data, 0, p->src->arrayMemberSize * arrayTotalSize); } - dest = (MYFLT*)p->dst->data; - src = (MYFLT*)p->src->data; - for (i=0;idst->dimensions; i++) { - for (j=0; jsrc->sizes[i]; j++) { - if (offset) - memset(dest, '\0', offset*sizeof(MYFLT)); - if (early) memset(&dest[nsmps-early], '\0', early*sizeof(MYFLT)); - for (k=offset;kdst->data; + src = (MYFLT*)p->src->data; + for (i=0;idst->dimensions; i++) { + for (j=0; jsrc->sizes[i]; j++) { + if (offset) + memset(dest, '\0', offset*sizeof(MYFLT)); + if (early) memset(&dest[nsmps-early], '\0', early*sizeof(MYFLT)); + for (k=offset;ktab; - int32_t i, tlen = 0; - - if (UNLIKELY(p->tab->data==NULL)) - return csound->PerfError(csound, - &(p->h), "%s", Str("array-var not initialised")); - if (UNLIKELY((ftp = csound->FTFindP(csound, p->kfn)) == NULL)) - return csound->PerfError(csound, - &(p->h), "%s", Str("No table for copy2ftab")); - for (i=0; idimensions; i++) tlen += t->sizes[i]; - fsize = ftp->flen; - fdata = ftp->ftable; - if (fsizetab->data, sizeof(MYFLT)*tlen); - return OK; + FUNC *ftp; + int32_t fsize; + MYFLT *fdata; + ARRAYDAT *t = p->tab; + int32_t i, tlen = 0; + + if (UNLIKELY(p->tab->data==NULL)) + return csound->PerfError(csound, + &(p->h), "%s", Str("array-var not initialised")); + if (UNLIKELY((ftp = csound->FTFindP(csound, p->kfn)) == NULL)) + return csound->PerfError(csound, + &(p->h), "%s", Str("No table for copy2ftab")); + for (i=0; idimensions; i++) tlen += t->sizes[i]; + fsize = ftp->flen; + fdata = ftp->ftable; + if (fsizetab->data, sizeof(MYFLT)*tlen); + return OK; } static int32_t tab2ftabi(CSOUND *csound, TABCOPY *p) { - FUNC *ftp; - int32_t fsize; - MYFLT *fdata; - ARRAYDAT *t = p->tab; - int32_t i, tlen = 0; - - if (UNLIKELY(p->tab->data==NULL)) - return csound->InitError(csound, "%s", Str("array-var not initialised")); - if (UNLIKELY((ftp = csound->FTFindP(csound, p->kfn)) == NULL)) - return csound->InitError(csound, "%s", Str("No table for copy2ftab")); - for (i=0; idimensions; i++) tlen += t->sizes[i]; - fsize = ftp->flen; - fdata = ftp->ftable; - if (fsizetab->data, sizeof(MYFLT)*tlen); - return OK; + FUNC *ftp; + int32_t fsize; + MYFLT *fdata; + ARRAYDAT *t = p->tab; + int32_t i, tlen = 0; + + if (UNLIKELY(p->tab->data==NULL)) + return csound->InitError(csound, "%s", Str("array-var not initialised")); + if (UNLIKELY((ftp = csound->FTFindP(csound, p->kfn)) == NULL)) + return csound->InitError(csound, "%s", Str("No table for copy2ftab")); + for (i=0; idimensions; i++) tlen += t->sizes[i]; + fsize = ftp->flen; + fdata = ftp->ftable; + if (fsizetab->data, sizeof(MYFLT)*tlen); + return OK; } // copya2ftab k[], iftable, [, koffset=0] @@ -2998,13 +2998,13 @@ static int32_t tab2ftab_offset(CSOUND *csound, TABCOPY2 *p) return csound->PerfError(csound, &(p->h), "%s", Str("No table for copy2ftab")); fsize = ftp->flen; if (UNLIKELY(offset >= fsize || offset < 0)) - return csound->PerfError(csound, &(p->h), "%s", Str("Offset is out of bounds")); + return csound->PerfError(csound, &(p->h), "%s", Str("Offset is out of bounds")); for (i=0; idimensions; i++) - tlen += t->sizes[i]; + tlen += t->sizes[i]; fdata = ftp->ftable; maxitems = fsize - offset; if (maxitems < tlen) - tlen = maxitems; + tlen = maxitems; memcpy(&(fdata[offset]), t->data, sizeof(MYFLT)*tlen); return OK; } @@ -3012,33 +3012,33 @@ static int32_t tab2ftab_offset(CSOUND *csound, TABCOPY2 *p) // copya2ftab i[], iftable, [, ioffset=0] static int32_t tab2ftab_offset_i(CSOUND *csound, TABCOPY2 *p) { - FUNC *ftp; - int32_t fsize; - MYFLT *fdata; - ARRAYDAT *t = p->tab; - int32_t offset = (int)*p->offset;; - int32_t i, tlen = 0, maxitems; - if (UNLIKELY(t->data==NULL)) - return csound->InitError(csound, "%s", Str("array-var not initialised")); - if (UNLIKELY((ftp = csound->FTFindP(csound, p->kfn)) == NULL)) - return csound->InitError(csound, "%s", Str("No table for copy2ftab")); - fsize = ftp->flen; - fdata = ftp->ftable; - if (UNLIKELY(offset >= fsize || offset < 0)) - return csound->InitError(csound, "%s", Str("Offset is out of bounds")); - for (i=0; idimensions; i++) - tlen += t->sizes[i]; - maxitems = fsize - offset; - if (maxitems < tlen) - tlen = maxitems; - memcpy(&(fdata[offset]), t->data, sizeof(MYFLT)*tlen); - return OK; + FUNC *ftp; + int32_t fsize; + MYFLT *fdata; + ARRAYDAT *t = p->tab; + int32_t offset = (int)*p->offset;; + int32_t i, tlen = 0, maxitems; + if (UNLIKELY(t->data==NULL)) + return csound->InitError(csound, "%s", Str("array-var not initialised")); + if (UNLIKELY((ftp = csound->FTFindP(csound, p->kfn)) == NULL)) + return csound->InitError(csound, "%s", Str("No table for copy2ftab")); + fsize = ftp->flen; + fdata = ftp->ftable; + if (UNLIKELY(offset >= fsize || offset < 0)) + return csound->InitError(csound, "%s", Str("Offset is out of bounds")); + for (i=0; idimensions; i++) + tlen += t->sizes[i]; + maxitems = fsize - offset; + if (maxitems < tlen) + tlen = maxitems; + memcpy(&(fdata[offset]), t->data, sizeof(MYFLT)*tlen); + return OK; } typedef struct { - OPDS h; - ARRAYDAT *tab; + OPDS h; + ARRAYDAT *tab; MYFLT *start, *end, *incr; int32_t len; } TABGEN; @@ -3046,77 +3046,77 @@ typedef struct { static int32_t tabgen(CSOUND *csound, TABGEN *p) { - MYFLT *data = p->tab->data; - MYFLT start = *p->start; - MYFLT end = *p->end; - MYFLT incr = *p->incr; - int32_t i, size = (end - start)/incr + 1; - - //printf("start=%f end=%f incr=%f size=%d\n", start, end, incr, size); - if (UNLIKELY(size < 0)) - return - csound->InitError(csound, "%s", - Str("inconsistent start, end and increment parameters")); + MYFLT *data = p->tab->data; + MYFLT start = *p->start; + MYFLT end = *p->end; + MYFLT incr = *p->incr; + int32_t i, size = (end - start)/incr + 1; + + //printf("start=%f end=%f incr=%f size=%d\n", start, end, incr, size); + if (UNLIKELY(size < 0)) + return + csound->InitError(csound, "%s", + Str("inconsistent start, end and increment parameters")); + tabinit(csound, p->tab, size); + if (UNLIKELY(p->tab->data==NULL)) { tabinit(csound, p->tab, size); - if (UNLIKELY(p->tab->data==NULL)) { - tabinit(csound, p->tab, size); - p->tab->sizes[0] = size; - } - //else /* This is wrong if array exists only write to specified part */ - //size = p->tab->sizes[0]; - data = p->tab->data; - for (i=0; i < size; i++) { - data[i] = start; - //printf("%f ", start); - start += incr; - } - //printf("]\n"); + p->tab->sizes[0] = size; + } + //else /* This is wrong if array exists only write to specified part */ + //size = p->tab->sizes[0]; + data = p->tab->data; + for (i=0; i < size; i++) { + data[i] = start; + //printf("%f ", start); + start += incr; + } + //printf("]\n"); - return OK; + return OK; } static int32_t ftab2tabi(CSOUND *csound, TABCOPY *p) { - FUNC *ftp; - int32_t fsize; - MYFLT *fdata; - int32_t tlen; - - if (UNLIKELY((ftp = csound->FTFindP(csound, p->kfn)) == NULL)) - return csound->InitError(csound, "%s", Str("No table for copy2ftab")); - fsize = ftp->flen; - if (UNLIKELY(p->tab->data==NULL)) { - tabinit(csound, p->tab, fsize); - p->tab->sizes[0] = fsize; - } - tlen = p->tab->sizes[0]; - fdata = ftp->ftable; - if (fsizetab->data, fdata, sizeof(MYFLT)*tlen); - return OK; + FUNC *ftp; + int32_t fsize; + MYFLT *fdata; + int32_t tlen; + + if (UNLIKELY((ftp = csound->FTFindP(csound, p->kfn)) == NULL)) + return csound->InitError(csound, "%s", Str("No table for copy2ftab")); + fsize = ftp->flen; + if (UNLIKELY(p->tab->data==NULL)) { + tabinit(csound, p->tab, fsize); + p->tab->sizes[0] = fsize; + } + tlen = p->tab->sizes[0]; + fdata = ftp->ftable; + if (fsizetab->data, fdata, sizeof(MYFLT)*tlen); + return OK; } static int32_t ftab2tab(CSOUND *csound, TABCOPY *p) { - FUNC *ftp; - int32_t fsize; - MYFLT *fdata; - int32_t tlen; - - if (UNLIKELY((ftp = csound->FTFindP(csound, p->kfn)) == NULL)) - return csound->PerfError(csound, - &(p->h), "%s", Str("No table for copy2ftab")); - fsize = ftp->flen; - if (UNLIKELY(p->tab->data==NULL)) { - if (tabcheck(csound, p->tab, fsize, &(p->h))) return NOTOK; - p->tab->sizes[0] = fsize; - } - tlen = p->tab->sizes[0]; - fdata = ftp->ftable; - if (fsizetab->data, fdata, sizeof(MYFLT)*tlen); - return OK; + FUNC *ftp; + int32_t fsize; + MYFLT *fdata; + int32_t tlen; + + if (UNLIKELY((ftp = csound->FTFindP(csound, p->kfn)) == NULL)) + return csound->PerfError(csound, + &(p->h), "%s", Str("No table for copy2ftab")); + fsize = ftp->flen; + if (UNLIKELY(p->tab->data==NULL)) { + if (tabcheck(csound, p->tab, fsize, &(p->h))) return NOTOK; + p->tab->sizes[0] = fsize; + } + tlen = p->tab->sizes[0]; + fdata = ftp->ftable; + if (fsizetab->data, fdata, sizeof(MYFLT)*tlen); + return OK; } typedef struct { @@ -3127,18 +3127,18 @@ typedef struct { static int32_t trim_i(CSOUND *csound, TRIM *p) { - int size = (int)(*p->size); - tabinit(csound, p->tab, size); - p->tab->sizes[0] = size; - return OK; + int size = (int)(*p->size); + tabinit(csound, p->tab, size); + p->tab->sizes[0] = size; + return OK; } static int32_t trim(CSOUND *csound, TRIM *p) { - int size = (int)(*p->size); - int n = tabcheck(csound, p->tab, size, &(p->h)); - if (n != OK) return n; - p->tab->sizes[0] = size; - return OK; + int size = (int)(*p->size); + int n = tabcheck(csound, p->tab, size, &(p->h)); + if (n != OK) return n; + p->tab->sizes[0] = size; + return OK; } @@ -3152,34 +3152,34 @@ typedef struct { static int32_t tabslice(CSOUND *csound, TABSLICE *p) { - MYFLT *tabin = p->tabin->data; - int32_t start = (int32_t) *p->start; - int32_t end = (int32_t) *p->end; - int32_t inc = (int32_t) *p->inc; - int32_t size = (end - start)/inc + 1; - int32_t i, destIndex; - int32_t memMyfltSize = p->tabin->arrayMemberSize / sizeof(MYFLT); + MYFLT *tabin = p->tabin->data; + int32_t start = (int32_t) *p->start; + int32_t end = (int32_t) *p->end; + int32_t inc = (int32_t) *p->inc; + int32_t size = (end - start)/inc + 1; + int32_t i, destIndex; + int32_t memMyfltSize = p->tabin->arrayMemberSize / sizeof(MYFLT); - if (UNLIKELY(size < 0)) - return csound->InitError(csound, "%s", - Str("inconsistent start, end parameters")); - if (UNLIKELY(p->tabin->dimensions!=1 || end >= p->tabin->sizes[0])) { - //printf("size=%d old tab size = %d\n", size, p->tabin->sizes[0]); - return csound->InitError(csound, "%s", - Str("slice larger than original size")); - } - if (UNLIKELY(inc<=0)) - return csound->InitError(csound, "%s", - Str("slice increment must be positive")); - tabinit(csound, p->tab, size); + if (UNLIKELY(size < 0)) + return csound->InitError(csound, "%s", + Str("inconsistent start, end parameters")); + if (UNLIKELY(p->tabin->dimensions!=1 || end >= p->tabin->sizes[0])) { + //printf("size=%d old tab size = %d\n", size, p->tabin->sizes[0]); + return csound->InitError(csound, "%s", + Str("slice larger than original size")); + } + if (UNLIKELY(inc<=0)) + return csound->InitError(csound, "%s", + Str("slice increment must be positive")); + tabinit(csound, p->tab, size); - for (i = start, destIndex = 0; i < end + 1; i+=inc, destIndex++) { - p->tab->arrayType->copyValue(csound, p->tab->arrayType, - p->tab->data + (destIndex * memMyfltSize), - tabin + (memMyfltSize * i)); - } + for (i = start, destIndex = 0; i < end + 1; i+=inc, destIndex++) { + p->tab->arrayType->copyValue(csound, p->tab->arrayType, + p->tab->data + (destIndex * memMyfltSize), + tabin + (memMyfltSize * i)); + } - return OK; + return OK; } //#include "str_ops.h" @@ -3221,76 +3221,76 @@ typedef struct { static int32_t tabmap_set(CSOUND *csound, TABMAP *p) { - MYFLT *data, *tabin = p->tabin->data; - int32_t n, size; - OENTRY *opc = NULL; - EVAL eval; - - if (UNLIKELY(p->tabin->data == NULL)||p->tabin->dimensions!=1) - return csound->InitError(csound, "%s", Str("array-var not initialised")); - - size = p->tabin->sizes[0]; - if (UNLIKELY(p->tab->data==NULL)) { - tabinit(csound, p->tab, size); - p->tab->sizes[0] = size; - } - else size = size < p->tab->sizes[0] ? size : p->tab->sizes[0]; - data = p->tab->data; - - opc = csound->find_opcode_new(csound, p->str->data, "i", "i"); - - if (UNLIKELY(opc == NULL)) - return csound->InitError(csound, Str("%s not found"), p->str->data); - p->opc = opc; - for (n=0; n < size; n++) { - eval.a = &tabin[n]; - eval.r = &data[n]; - opc->iopadr(csound, (void *) &eval); - } + MYFLT *data, *tabin = p->tabin->data; + int32_t n, size; + OENTRY *opc = NULL; + EVAL eval; - opc = csound->find_opcode_new(csound, p->str->data, "k", "k"); + if (UNLIKELY(p->tabin->data == NULL)||p->tabin->dimensions!=1) + return csound->InitError(csound, "%s", Str("array-var not initialised")); - p->opc = opc; - return OK; + size = p->tabin->sizes[0]; + if (UNLIKELY(p->tab->data==NULL)) { + tabinit(csound, p->tab, size); + p->tab->sizes[0] = size; + } + else size = size < p->tab->sizes[0] ? size : p->tab->sizes[0]; + data = p->tab->data; + + opc = csound->find_opcode_new(csound, p->str->data, "i", "i"); + + if (UNLIKELY(opc == NULL)) + return csound->InitError(csound, Str("%s not found"), p->str->data); + p->opc = opc; + for (n=0; n < size; n++) { + eval.a = &tabin[n]; + eval.r = &data[n]; + opc->init(csound, (void *) &eval); + } + + opc = csound->find_opcode_new(csound, p->str->data, "k", "k"); + + p->opc = opc; + return OK; } static int32_t tabmap_perf(CSOUND *csound, TABMAP *p) { - /* FIXME; eeds check */ - MYFLT *data = p->tab->data, *tabin = p->tabin->data; - int32_t n, size; - OENTRY *opc = p->opc; - EVAL eval; - - if (UNLIKELY(p->tabin->data == NULL) || p->tabin->dimensions !=1) - return csound->PerfError(csound, - &(p->h), "%s", Str("array-var not initialised")); - if (UNLIKELY(p->tab->data==NULL) || p->tab->dimensions !=1) - return csound->PerfError(csound, - &(p->h), "%s", Str("array-var not initialised")); - size = p->tab->sizes[0]; - - if (UNLIKELY(opc == NULL)) - return csound->PerfError(csound, - &(p->h), "%s", Str("map fn not found at k rate")); - for (n=0; n < size; n++) { - eval.a = &tabin[n]; - eval.r = &data[n]; - opc->kopadr(csound, (void *) &eval); - } + /* FIXME; eeds check */ + MYFLT *data = p->tab->data, *tabin = p->tabin->data; + int32_t n, size; + OENTRY *opc = p->opc; + EVAL eval; + + if (UNLIKELY(p->tabin->data == NULL) || p->tabin->dimensions !=1) + return csound->PerfError(csound, + &(p->h), "%s", Str("array-var not initialised")); + if (UNLIKELY(p->tab->data==NULL) || p->tab->dimensions !=1) + return csound->PerfError(csound, + &(p->h), "%s", Str("array-var not initialised")); + size = p->tab->sizes[0]; + + if (UNLIKELY(opc == NULL)) + return csound->PerfError(csound, + &(p->h), "%s", Str("map fn not found at k rate")); + for (n=0; n < size; n++) { + eval.a = &tabin[n]; + eval.r = &data[n]; + opc->perf(csound, (void *) &eval); + } - return OK; + return OK; } int32_t tablength(CSOUND *csound, TABQUERY1 *p) { - IGN(csound); - int32_t opt = (int32_t)*p->opt; - if (UNLIKELY(p->tab==NULL || opt>p->tab->dimensions)) - *p->ans = -FL(1.0); - else if (UNLIKELY(opt<=0)) *p->ans = p->tab->dimensions; - else *p->ans = p->tab->sizes[opt-1]; - return OK; + IGN(csound); + int32_t opt = (int32_t)*p->opt; + if (UNLIKELY(p->tab==NULL || opt>p->tab->dimensions)) + *p->ans = -FL(1.0); + else if (UNLIKELY(opt<=0)) *p->ans = p->tab->dimensions; + else *p->ans = p->tab->sizes[opt-1]; + return OK; } typedef struct { @@ -3301,87 +3301,87 @@ typedef struct { static int32_t ina_set(CSOUND *csound, OUTA *p) { - ARRAYDAT *aa = p->tabin; - // should call ensure here but it is a-rate - aa->dimensions = 1; - if (aa->sizes) csound->Free(csound, aa->sizes); - if (aa->data) csound->Free(csound, aa->data); - aa->sizes = (int32_t*)csound->Malloc(csound, sizeof(int32_t)); - aa->sizes[0] = p->len = csound->GetNchnls_i(csound); - aa->data = (MYFLT*) - csound->Malloc(csound, CS_KSMPS*sizeof(MYFLT)*p->len); - aa->arrayMemberSize = CS_KSMPS*sizeof(MYFLT); - return OK; + ARRAYDAT *aa = p->tabin; + // should call ensure here but it is a-rate + aa->dimensions = 1; + if (aa->sizes) csound->Free(csound, aa->sizes); + if (aa->data) csound->Free(csound, aa->data); + aa->sizes = (int32_t*)csound->Malloc(csound, sizeof(int32_t)); + aa->sizes[0] = p->len = csound->GetNchnls_i(csound); + aa->data = (MYFLT*) + csound->Malloc(csound, CS_KSMPS*sizeof(MYFLT)*p->len); + aa->arrayMemberSize = CS_KSMPS*sizeof(MYFLT); + return OK; } static int32_t ina(CSOUND *csound, OUTA *p) { - IGN(csound); - ARRAYDAT *aa = p->tabin; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t n, l, nsmps = CS_KSMPS; - MYFLT *data = aa->data; - MYFLT *sp= CS_SPIN; - uint32_t len = (uint32_t)p->len; - for (l=0; ltabin; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t n, l, nsmps = CS_KSMPS; + MYFLT *data = aa->data; + MYFLT *sp= CS_SPIN; + uint32_t len = (uint32_t)p->len; + for (l=0; ltabin; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t i, j, l, nsmps = CS_KSMPS; - MYFLT *data = aa->data; - MYFLT *sp= CS_SPOUT; - uint32_t len = (uint32_t)p->len; - - for (l=0; lGetNchnls(csound); j++) { - if (itabin; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t i, j, l, nsmps = CS_KSMPS; + MYFLT *data = aa->data; + MYFLT *sp= CS_SPOUT; + uint32_t len = (uint32_t)p->len; + + for (l=0; lGetNchnls(csound); j++) { + if (itabin; - // should call ensure here but it is a-rate - aa->dimensions = 1; - if (aa->sizes) csound->Free(csound, aa->sizes); - if (aa->data) csound->Free(csound, aa->data); - aa->sizes = (int32_t*)csound->Malloc(csound, sizeof(int32_t)); - aa->sizes[0] = p->len = csound->GetNchnls(csound); - aa->data = (MYFLT*) - csound->Malloc(csound, CS_KSMPS*sizeof(MYFLT)*p->len); - aa->arrayMemberSize = CS_KSMPS*sizeof(MYFLT); - return OK; + ARRAYDAT *aa = p->tabin; + // should call ensure here but it is a-rate + aa->dimensions = 1; + if (aa->sizes) csound->Free(csound, aa->sizes); + if (aa->data) csound->Free(csound, aa->data); + aa->sizes = (int32_t*)csound->Malloc(csound, sizeof(int32_t)); + aa->sizes[0] = p->len = csound->GetNchnls(csound); + aa->data = (MYFLT*) + csound->Malloc(csound, CS_KSMPS*sizeof(MYFLT)*p->len); + aa->arrayMemberSize = CS_KSMPS*sizeof(MYFLT); + return OK; } /* @@ -3401,7 +3401,7 @@ int32_t init_autocorr(CSOUND *csound, AUTOCORR *p) { int32_t N = p->in->sizes[0], fn; for(fn=2; fn < N*2-1; fn*=2); if (p->mem.auxp == 0 || p->mem.size < fn*sizeof(MYFLT)) - csound->AuxAlloc(csound, fn*sizeof(MYFLT), &p->mem); + csound->AuxAlloc(csound, fn*sizeof(MYFLT), &p->mem); p->N = N; p->FN = fn; tabinit(csound, p->out,N); @@ -3448,16 +3448,16 @@ int32_t init_rfft(CSOUND *csound, FFT *p) { } int32_t perf_rfft(CSOUND *csound, FFT *p) { - int32_t N = p->out->sizes[0]; - memcpy(p->out->data,p->in->data,N*sizeof(MYFLT)); - if (isPowerOfTwo(N)) { - csound->RealFFT2(csound,p->setup,p->out->data); - } - else{ - p->out->data[N] = FL(0.0); - csound->RealFFTnp2(csound,p->out->data,N); - } - return OK; + int32_t N = p->out->sizes[0]; + memcpy(p->out->data,p->in->data,N*sizeof(MYFLT)); + if (isPowerOfTwo(N)) { + csound->RealFFT2(csound,p->setup,p->out->data); + } + else{ + p->out->data[N] = FL(0.0); + csound->RealFFTnp2(csound,p->out->data,N); + } + return OK; } int32_t rfft_i(CSOUND *csound, FFT *p) { @@ -3481,15 +3481,15 @@ int32_t init_rifft(CSOUND *csound, FFT *p) { } int32_t perf_rifft(CSOUND *csound, FFT *p) { - int32_t N = p->in->sizes[0]; - memcpy(p->out->data,p->in->data,N*sizeof(MYFLT)); - if (isPowerOfTwo(N)) - csound->RealFFT2(csound,p->setup,p->out->data); - else{ - p->out->data[N] = FL(0.0); - csound->InverseRealFFTnp2(csound,p->out->data,N); - } - return OK; + int32_t N = p->in->sizes[0]; + memcpy(p->out->data,p->in->data,N*sizeof(MYFLT)); + if (isPowerOfTwo(N)) + csound->RealFFT2(csound,p->setup,p->out->data); + else{ + p->out->data[N] = FL(0.0); + csound->InverseRealFFTnp2(csound,p->out->data,N); + } + return OK; } int32_t rifft_i(CSOUND *csound, FFT *p) { @@ -3499,22 +3499,22 @@ int32_t rifft_i(CSOUND *csound, FFT *p) { } int32_t init_rfftmult(CSOUND *csound, FFT *p) { - int32_t N = p->in->sizes[0]; - if (UNLIKELY(N != p->in2->sizes[0])) - return csound->InitError(csound, "%s", Str("array sizes do not match\n")); - /*if (isPowerOfTwo(N))*/ - tabinit(csound, p->out, N); - /* else - return - csound->InitError(csound, "%s", - Str("non-pow-of-two case not implemented yet\n"));*/ - return OK; + int32_t N = p->in->sizes[0]; + if (UNLIKELY(N != p->in2->sizes[0])) + return csound->InitError(csound, "%s", Str("array sizes do not match\n")); + /*if (isPowerOfTwo(N))*/ + tabinit(csound, p->out, N); + /* else + return + csound->InitError(csound, "%s", + Str("non-pow-of-two case not implemented yet\n"));*/ + return OK; } int32_t perf_rfftmult(CSOUND *csound, FFT *p) { - int32_t N = p->out->sizes[0]; - csound->RealFFTMult(csound,p->out->data,p->in->data,p->in2->data,N,1); - return OK; + int32_t N = p->out->sizes[0]; + csound->RealFFTMult(csound,p->out->data,p->in->data,p->in2->data,N,1); + return OK; } int32_t initialise_fft(CSOUND *csound, FFT *p) { @@ -3527,14 +3527,14 @@ int32_t initialise_fft(CSOUND *csound, FFT *p) { } int32_t perf_fft(CSOUND *csound, FFT *p) { - int32_t N2 = p->in->sizes[0]; - memcpy(p->out->data,p->in->data,N2*sizeof(MYFLT)); - if (isPowerOfTwo(N2)) - csound->ComplexFFT(csound,p->out->data,N2/2); - else { - csound->ComplexFFTnp2(csound,p->out->data,N2/2); - } - return OK; + int32_t N2 = p->in->sizes[0]; + memcpy(p->out->data,p->in->data,N2*sizeof(MYFLT)); + if (isPowerOfTwo(N2)) + csound->ComplexFFT(csound,p->out->data,N2/2); + else { + csound->ComplexFFTnp2(csound,p->out->data,N2/2); + } + return OK; } int32_t fft_i(CSOUND *csound, FFT *p) { @@ -3545,232 +3545,232 @@ int32_t fft_i(CSOUND *csound, FFT *p) { int32_t init_ifft(CSOUND *csound, FFT *p) { - int32_t N2 = p->in->sizes[0]; - if (UNLIKELY(p->in->dimensions > 1)) - return csound->InitError(csound, "%s", - Str("fftinv: only one-dimensional arrays allowed")); - tabinit(csound, p->out, N2); - return OK; + int32_t N2 = p->in->sizes[0]; + if (UNLIKELY(p->in->dimensions > 1)) + return csound->InitError(csound, "%s", + Str("fftinv: only one-dimensional arrays allowed")); + tabinit(csound, p->out, N2); + return OK; } int32_t perf_ifft(CSOUND *csound, FFT *p) { - int32_t N2 = p->out->sizes[0]; - memcpy(p->out->data,p->in->data,N2*sizeof(MYFLT)); - if (isPowerOfTwo(N2)) { - csound->InverseComplexFFT(csound,p->out->data,N2/2); - } - else { - csound->InverseComplexFFTnp2(csound,p->out->data,N2/2); - } - return OK; + int32_t N2 = p->out->sizes[0]; + memcpy(p->out->data,p->in->data,N2*sizeof(MYFLT)); + if (isPowerOfTwo(N2)) { + csound->InverseComplexFFT(csound,p->out->data,N2/2); + } + else { + csound->InverseComplexFFTnp2(csound,p->out->data,N2/2); + } + return OK; } int32_t ifft_i(CSOUND *csound, FFT *p) { - if (LIKELY(init_ifft(csound,p) == OK)) + if (LIKELY(init_ifft(csound,p) == OK)) return perf_ifft(csound, p); else return NOTOK; } int32_t init_recttopol(CSOUND *csound, FFT *p) { - int32_t N = p->in->sizes[0]; - tabinit(csound, p->out, N); - return OK; + int32_t N = p->in->sizes[0]; + tabinit(csound, p->out, N); + return OK; } int32_t perf_recttopol(CSOUND *csound, FFT *p) { - IGN(csound); - int32_t i, end = p->out->sizes[0]; - MYFLT *in, *out, mag, ph; - in = p->in->data; - out = p->out->data; - for (i=2;iout->sizes[0]; + MYFLT *in, *out, mag, ph; + in = p->in->data; + out = p->out->data; + for (i=2;iout->sizes[0]; - MYFLT *in, *out, re, im; - in = p->in->data; - out = p->out->data; - for (i=2;iout->sizes[0]; + MYFLT *in, *out, re, im; + in = p->in->data; + out = p->out->data; + for (i=2;iin2->sizes[0] == p->in->sizes[0])) { - int32_t N = p->in2->sizes[0]; - tabinit(csound, p->out, N*2 - 2); - return OK; - } else return csound->InitError(csound, - Str("in array sizes do not match: %d and %d\n"), - p->in2->sizes[0],p->in->sizes[0]); + if (LIKELY(p->in2->sizes[0] == p->in->sizes[0])) { + int32_t N = p->in2->sizes[0]; + tabinit(csound, p->out, N*2 - 2); + return OK; + } else return csound->InitError(csound, + Str("in array sizes do not match: %d and %d\n"), + p->in2->sizes[0],p->in->sizes[0]); } int32_t perf_poltorect2(CSOUND *csound, FFT *p) { - IGN(csound); - int32_t i,j, end = p->in->sizes[0]-1; - MYFLT *mags, *phs, *out, re, im; - mags = p->in->data; - phs = p->in2->data; - out = p->out->data; - for (i=2,j=1;jin->sizes[0]-1; + MYFLT *mags, *phs, *out, re, im; + mags = p->in->data; + phs = p->in2->data; + out = p->out->data; + for (i=2,j=1;jin->sizes[0]; - tabinit(csound, p->out, N/2+1); - return OK; + int32_t N = p->in->sizes[0]; + tabinit(csound, p->out, N/2+1); + return OK; } int32_t perf_mags(CSOUND *csound, FFT *p) { - IGN(csound); - int32_t i,j, end = p->out->sizes[0]; - MYFLT *in, *out; - in = p->in->data; - out = p->out->data; - for (i=2,j=1;jout->sizes[0]; + MYFLT *in, *out; + in = p->in->data; + out = p->out->data; + for (i=2,j=1;jout->sizes[0]; - MYFLT *in, *out; - in = p->in->data; - out = p->out->data; - for (i=2,j=1;jout->sizes[0]; + MYFLT *in, *out; + in = p->in->data; + out = p->out->data; + for (i=2,j=1;jout, p->in->sizes[0]); - if (LIKELY(*((MYFLT *)p->in2))) - p->b = 1/log(*((MYFLT *)p->in2)); - else - p->b = FL(1.0); - return OK; + tabinit(csound, p->out, p->in->sizes[0]); + if (LIKELY(*((MYFLT *)p->in2))) + p->b = 1/log(*((MYFLT *)p->in2)); + else + p->b = FL(1.0); + return OK; } int32_t perf_logarray(CSOUND *csound, FFT *p) { - IGN(csound); - int32_t i, end = p->out->sizes[0]; - MYFLT bas = p->b; - MYFLT *in, *out; - in = p->in->data; - out = p->out->data; - if (LIKELY(bas)) - for (i=0;iout->sizes[0]; + MYFLT bas = p->b; + MYFLT *in, *out; + in = p->in->data; + out = p->out->data; + if (LIKELY(bas)) + for (i=0;iin->sizes[0]; - tabinit(csound, p->out, N*2); - return OK; + int32_t N = p->in->sizes[0]; + tabinit(csound, p->out, N*2); + return OK; } int32_t perf_rtoc(CSOUND *csound, FFT *p) { - IGN(csound); - int32_t i,j, end = p->out->sizes[0]; - MYFLT *in, *out; - in = p->in->data; - out = p->out->data; - for (i=0,j=0;iout->sizes[0]; + MYFLT *in, *out; + in = p->in->data; + out = p->out->data; + for (i=0,j=0;iin->sizes[0]; - tabinit(csound, p->out, N/2); - return OK; + int32_t N = p->in->sizes[0]; + tabinit(csound, p->out, N/2); + return OK; } int32_t perf_ctor(CSOUND *csound, FFT *p) { - IGN(csound); - int32_t i,j, end = p->out->sizes[0]; - MYFLT *in, *out; - in = p->in->data; - out = p->out->data; - for (i=0,j=0;jout->sizes[0]; + MYFLT *in, *out; + in = p->in->data; + out = p->out->data; + for (i=0,j=0;jin->sizes[0]; - int32_t i,type = (int32_t) *p->f; - MYFLT *w; - tabinit(csound, p->out, N); - if (p->mem.auxp == 0 || p->mem.size < N*sizeof(MYFLT)) - csound->AuxAlloc(csound, N*sizeof(MYFLT), &p->mem); - w = (MYFLT *) p->mem.auxp; - switch(type) { - case 0: - for (i=0; iin->sizes[0]; + int32_t i,type = (int32_t) *p->f; + MYFLT *w; + tabinit(csound, p->out, N); + if (p->mem.auxp == 0 || p->mem.size < N*sizeof(MYFLT)) + csound->AuxAlloc(csound, N*sizeof(MYFLT), &p->mem); + w = (MYFLT *) p->mem.auxp; + switch(type) { + case 0: + for (i=0; iout->sizes[0], off = *((MYFLT *)p->in2); - MYFLT *in, *out, *w; - in = p->in->data; - out = p->out->data; - w = (MYFLT *) p->mem.auxp; - /*while (off < 0) off += end; - for (i=0;iout->sizes[0], off = *((MYFLT *)p->in2); + MYFLT *in, *out, *w; + in = p->in->data; + out = p->out->data; + w = (MYFLT *) p->mem.auxp; + /*while (off < 0) off += end; + for (i=0;ifin->N; - if (LIKELY(isPowerOfTwo(N))) { - p->setup = csound->RealFFT2Setup(csound, N/2, FFT_FWD); - tabinit(csound, p->out, N/2+1); - } - else - return csound->InitError(csound, "%s", - Str("non-pow-of-two case not implemented yet\n")); - p->lastframe = 0; - return OK; + int32_t N = p->fin->N; + if (LIKELY(isPowerOfTwo(N))) { + p->setup = csound->RealFFT2Setup(csound, N/2, FFT_FWD); + tabinit(csound, p->out, N/2+1); + } + else + return csound->InitError(csound, "%s", + Str("non-pow-of-two case not implemented yet\n")); + p->lastframe = 0; + return OK; } int32_t pvsceps_perf(CSOUND *csound, PVSCEPS *p) { - if (p->lastframe < p->fin->framecount) { - int32_t N = p->fin->N; - int32_t i, j; - MYFLT *ceps = p->out->data; - MYFLT coefs = *p->coefs; - float *fin = (float *) p->fin->frame.auxp; - for (i=j=0; i < N; i+=2, j++) { - ceps[j] = log(fin[i] > 0.0 ? fin[i] : 1e-20); - } - ceps[N/2] = fin[N/2]; - csound->RealFFT2(csound, p->setup, ceps); - if (coefs) { - // lifter coefs - for (i=coefs*2; i < N/2; i++) ceps[i] = 0.0; - ceps[N/2] = 0.0; - } - p->lastframe = p->fin->framecount; + if (p->lastframe < p->fin->framecount) { + int32_t N = p->fin->N; + int32_t i, j; + MYFLT *ceps = p->out->data; + MYFLT coefs = *p->coefs; + float *fin = (float *) p->fin->frame.auxp; + for (i=j=0; i < N; i+=2, j++) { + ceps[j] = log(fin[i] > 0.0 ? fin[i] : 1e-20); } - return OK; + ceps[N/2] = fin[N/2]; + csound->RealFFT2(csound, p->setup, ceps); + if (coefs) { + // lifter coefs + for (i=coefs*2; i < N/2; i++) ceps[i] = 0.0; + ceps[N/2] = 0.0; + } + p->lastframe = p->fin->framecount; + } + return OK; } int32_t init_ceps(CSOUND *csound, FFT *p) { - int32_t N = p->in->sizes[0]-1; - if (UNLIKELY(N < 64)) - return csound->InitError(csound, "%s", - Str("FFT size too small (min 64 samples)\n")); - if (LIKELY(isPowerOfTwo(N))) { - p->setup = csound->RealFFT2Setup(csound, N, FFT_FWD); - tabinit(csound, p->out, N+1); - } - else - return csound->InitError(csound, "%s", - Str("non-pow-of-two case not implemented yet\n")); + int32_t N = p->in->sizes[0]-1; + if (UNLIKELY(N < 64)) + return csound->InitError(csound, "%s", + Str("FFT size too small (min 64 samples)\n")); + if (LIKELY(isPowerOfTwo(N))) { + p->setup = csound->RealFFT2Setup(csound, N, FFT_FWD); + tabinit(csound, p->out, N+1); + } + else + return csound->InitError(csound, "%s", + Str("non-pow-of-two case not implemented yet\n")); - return OK; + return OK; } int32_t perf_ceps(CSOUND *csound, FFT *p) { - int32_t siz = p->out->sizes[0]-1, i; - MYFLT *ceps = p->out->data; - MYFLT coefs = *((MYFLT *)p->in2); - MYFLT *mags = (MYFLT *) p->in->data; - for (i=0; i < siz; i++) { - ceps[i] = log(mags[i] > 0.0 ? mags[i] : 1e-20); - } - ceps[siz] = mags[siz]; - csound->RealFFT2(csound, p->setup, ceps); - if (coefs) { - // lifter coefs - for (i=coefs*2; i < siz; i++) ceps[i] = 0.0; - ceps[siz] = 0.0; - } - return OK; + int32_t siz = p->out->sizes[0]-1, i; + MYFLT *ceps = p->out->data; + MYFLT coefs = *((MYFLT *)p->in2); + MYFLT *mags = (MYFLT *) p->in->data; + for (i=0; i < siz; i++) { + ceps[i] = log(mags[i] > 0.0 ? mags[i] : 1e-20); + } + ceps[siz] = mags[siz]; + csound->RealFFT2(csound, p->setup, ceps); + if (coefs) { + // lifter coefs + for (i=coefs*2; i < siz; i++) ceps[i] = 0.0; + ceps[siz] = 0.0; + } + return OK; } int32_t init_iceps(CSOUND *csound, FFT *p) { - int32_t N = p->in->sizes[0]-1; - if (LIKELY(isPowerOfTwo(N))) { - p->setup = csound->RealFFT2Setup(csound, N, FFT_INV); - tabinit(csound, p->out, N+1); - } - else - return csound->InitError(csound, "%s", - Str("non-pow-of-two case not implemented yet\n")); - N++; - if (p->mem.auxp == NULL || p->mem.size < N*sizeof(MYFLT)) - csound->AuxAlloc(csound, N*sizeof(MYFLT), &p->mem); - return OK; + int32_t N = p->in->sizes[0]-1; + if (LIKELY(isPowerOfTwo(N))) { + p->setup = csound->RealFFT2Setup(csound, N, FFT_INV); + tabinit(csound, p->out, N+1); + } + else + return csound->InitError(csound, "%s", + Str("non-pow-of-two case not implemented yet\n")); + N++; + if (p->mem.auxp == NULL || p->mem.size < N*sizeof(MYFLT)) + csound->AuxAlloc(csound, N*sizeof(MYFLT), &p->mem); + return OK; } int32_t perf_iceps(CSOUND *csound, FFT *p) { - int32_t siz = p->in->sizes[0]-1, i; - MYFLT *spec = (MYFLT *)p->mem.auxp; - MYFLT *out = p->out->data; - memcpy(spec, p->in->data, siz*sizeof(MYFLT)); - csound->RealFFT2(csound,p->setup,spec); - for (i=0; i < siz; i++) { - out[i] = exp(spec[i]); - } - out[siz] = spec[siz]; /* Writes outside data allocated */ - return OK; + int32_t siz = p->in->sizes[0]-1, i; + MYFLT *spec = (MYFLT *)p->mem.auxp; + MYFLT *out = p->out->data; + memcpy(spec, p->in->data, siz*sizeof(MYFLT)); + csound->RealFFT2(csound,p->setup,spec); + for (i=0; i < siz; i++) { + out[i] = exp(spec[i]); + } + out[siz] = spec[siz]; /* Writes outside data allocated */ + return OK; } int32_t rows_init(CSOUND *csound, FFT *p) { - if (p->in->dimensions == 2) { - int32_t siz = p->in->sizes[1]; - tabinit(csound, p->out, siz); - return OK; - } - else - return csound->InitError(csound, "%s", - Str("in array not 2-dimensional\n")); + if (p->in->dimensions == 2) { + int32_t siz = p->in->sizes[1]; + tabinit(csound, p->out, siz); + return OK; + } + else + return csound->InitError(csound, "%s", + Str("in array not 2-dimensional\n")); } int32_t rows_perf(CSOUND *csound, FFT *p) { - int32_t start = *((MYFLT *)p->in2); - if (LIKELY(start < p->in->sizes[0])) { - int32_t bytes = p->in->sizes[1]*sizeof(MYFLT); - start *= p->in->sizes[1]; - memcpy(p->out->data,p->in->data+start,bytes); - return OK; - } - else return csound->PerfError(csound, &(p->h), - "%s", Str("requested row is out of range\n")); + int32_t start = *((MYFLT *)p->in2); + if (LIKELY(start < p->in->sizes[0])) { + int32_t bytes = p->in->sizes[1]*sizeof(MYFLT); + start *= p->in->sizes[1]; + memcpy(p->out->data,p->in->data+start,bytes); + return OK; + } + else return csound->PerfError(csound, &(p->h), + "%s", Str("requested row is out of range\n")); } /* Getrow for string arrays */ int32_t rows_perf_S(CSOUND *csound, FFT *p) { - ARRAYDAT* dat = p->in; /* The data in e 2_D array */ - STRINGDAT* mem = (STRINGDAT*)dat->data; - STRINGDAT* dest = (STRINGDAT*)p->out->data; - int32_t i; - int32_t index = (int32_t)(*((MYFLT *)p->in2)); - if (LIKELY(index < p->in->sizes[0])) { - index = (index * dat->sizes[1]); - //printf("%d : %d\n", index, dat->sizes[1]); - mem += index; - //incr = (index * (dat->arrayMemberSize / sizeof(MYFLT))); - //printf("*** mem = %p dst = %p\n", mem, dest); - for (i = 0; iin->sizes[1]; i++) { - dat->arrayType->copyValue(csound, dat->arrayType, (void*)dest, (void*)mem); - //printf("*** copies i=%d: %s -> %s\n", i,(char*)(mem->data),(char*)(dest->data)); - dest +=1; - mem += 1; - } - return OK; + ARRAYDAT* dat = p->in; /* The data in e 2_D array */ + STRINGDAT* mem = (STRINGDAT*)dat->data; + STRINGDAT* dest = (STRINGDAT*)p->out->data; + int32_t i; + int32_t index = (int32_t)(*((MYFLT *)p->in2)); + if (LIKELY(index < p->in->sizes[0])) { + index = (index * dat->sizes[1]); + //printf("%d : %d\n", index, dat->sizes[1]); + mem += index; + //incr = (index * (dat->arrayMemberSize / sizeof(MYFLT))); + //printf("*** mem = %p dst = %p\n", mem, dest); + for (i = 0; iin->sizes[1]; i++) { + dat->arrayType->copyValue(csound, dat->arrayType, (void*)dest, (void*)mem); + //printf("*** copies i=%d: %s -> %s\n", i,(char*)(mem->data),(char*)(dest->data)); + dest +=1; + mem += 1; } - else return csound->PerfError(csound, &(p->h), - "%s", Str("requested row is out of range\n")); + return OK; + } + else return csound->PerfError(csound, &(p->h), + "%s", Str("requested row is out of range\n")); } int32_t set_rows_perf_S(CSOUND *csound, FFT *p) { - ARRAYDAT* dat = p->in; /* The data in e 2_D array */ - STRINGDAT* mem = (STRINGDAT*)dat->data; - STRINGDAT* dest = (STRINGDAT*)p->out->data; - int32_t i; - int32_t index = (int32_t)(*((MYFLT *)p->in2)); - if (LIKELY(index < p->in->sizes[0])) { - index = (index * dat->sizes[1]); - //printf("%d : %d\n", index, dat->sizes[1]); - mem += index; - //incr = (index * (dat->arrayMemberSize / sizeof(MYFLT))); - //printf("*** mem = %p dst = %p\n", mem, dest); - for (i = 0; iin->sizes[1]; i++) { - dat->arrayType->copyValue(csound, dat->arrayType, (void*)mem, (void*)dest); - //printf("*** copies i=%d: %s -> %s\n", i,(char*)(mem->data),(char*)(dest->data)); - dest+= 1; - mem += 1; - } - return OK; + ARRAYDAT* dat = p->in; /* The data in e 2_D array */ + STRINGDAT* mem = (STRINGDAT*)dat->data; + STRINGDAT* dest = (STRINGDAT*)p->out->data; + int32_t i; + int32_t index = (int32_t)(*((MYFLT *)p->in2)); + if (LIKELY(index < p->in->sizes[0])) { + index = (index * dat->sizes[1]); + //printf("%d : %d\n", index, dat->sizes[1]); + mem += index; + //incr = (index * (dat->arrayMemberSize / sizeof(MYFLT))); + //printf("*** mem = %p dst = %p\n", mem, dest); + for (i = 0; iin->sizes[1]; i++) { + dat->arrayType->copyValue(csound, dat->arrayType, (void*)mem, (void*)dest); + //printf("*** copies i=%d: %s -> %s\n", i,(char*)(mem->data),(char*)(dest->data)); + dest+= 1; + mem += 1; } - else return csound->PerfError(csound, &(p->h), - "%s", Str("requested row is out of range\n")); + return OK; + } + else return csound->PerfError(csound, &(p->h), + "%s", Str("requested row is out of range\n")); } int32_t rows_i(CSOUND *csound, FFT *p) { if (rows_init(csound,p) == OK) { - int32_t start = *((MYFLT *)p->in2); - if (LIKELY(start < p->in->sizes[0])) { + int32_t start = *((MYFLT *)p->in2); + if (LIKELY(start < p->in->sizes[0])) { int32_t bytes = p->in->sizes[1]*sizeof(MYFLT); start *= p->in->sizes[1]; memcpy(p->out->data,p->in->data+start,bytes); @@ -3979,79 +3979,79 @@ int32_t rows_i(CSOUND *csound, FFT *p) { static inline void tabensure2D(CSOUND *csound, ARRAYDAT *p, int32_t rows, int32_t columns) { - if (p->data==NULL || p->dimensions == 0 || - (p->dimensions==2 && (p->sizes[0] < rows || p->sizes[1] < columns))) { - size_t ss; - if (p->data == NULL) { - CS_VARIABLE* var = p->arrayType->createVariable(csound, NULL); - p->arrayMemberSize = var->memBlockSize; - } - ss = p->arrayMemberSize*rows*columns; - if (p->data==NULL) { - p->data = (MYFLT*)csound->Calloc(csound, ss); - p->dimensions = 2; - p->sizes = (int32_t*)csound->Malloc(csound, sizeof(int32_t)*2); - } - else p->data = (MYFLT*) csound->ReAlloc(csound, p->data, ss); - p->sizes[0] = rows; p->sizes[1] = columns; - } + if (p->data==NULL || p->dimensions == 0 || + (p->dimensions==2 && (p->sizes[0] < rows || p->sizes[1] < columns))) { + size_t ss; + if (p->data == NULL) { + CS_VARIABLE* var = p->arrayType->createVariable(csound, NULL); + p->arrayMemberSize = var->memBlockSize; + } + ss = p->arrayMemberSize*rows*columns; + if (p->data==NULL) { + p->data = (MYFLT*)csound->Calloc(csound, ss); + p->dimensions = 2; + p->sizes = (int32_t*)csound->Malloc(csound, sizeof(int32_t)*2); + } + else p->data = (MYFLT*) csound->ReAlloc(csound, p->data, ss); + p->sizes[0] = rows; p->sizes[1] = columns; + } } int32_t set_rows_init(CSOUND *csound, FFT *p) { - int32_t sizs = p->in->sizes[0]; - int32_t row = *((MYFLT *)p->in2); - tabensure2D(csound, p->out, row+1, sizs); - return OK; + int32_t sizs = p->in->sizes[0]; + int32_t row = *((MYFLT *)p->in2); + tabensure2D(csound, p->out, row+1, sizs); + return OK; } int32_t set_rows_init_S(CSOUND *csound, FFT *p) { - if (set_rows_init(csound, p)==0) - return set_rows_perf_S(csound, p); - return NOTOK; + if (set_rows_init(csound, p)==0) + return set_rows_perf_S(csound, p); + return NOTOK; } int32_t rows_init_S(CSOUND *csound, FFT *p) { - if (rows_init(csound, p)==0) - return rows_perf_S(csound, p); - return NOTOK; + if (rows_init(csound, p)==0) + return rows_perf_S(csound, p); + return NOTOK; } int32_t cols_init(CSOUND *csound, FFT *p) { - if (LIKELY(p->in->dimensions == 2)) { - int32_t siz = p->in->sizes[0]; - tabinit(csound, p->out, siz); - return OK; - } - else - return csound->InitError(csound, "%s", - Str("in array not 2-dimensional\n")); + if (LIKELY(p->in->dimensions == 2)) { + int32_t siz = p->in->sizes[0]; + tabinit(csound, p->out, siz); + return OK; + } + else + return csound->InitError(csound, "%s", + Str("in array not 2-dimensional\n")); } int32_t cols_perf(CSOUND *csound, FFT *p) { - int32_t start = *((MYFLT *)p->in2); + int32_t start = *((MYFLT *)p->in2); - if (LIKELY(start < p->in->sizes[1])) { - int32_t j,i,collen = p->in->sizes[1], len = p->in->sizes[0]; - for (j=0,i=start; j < len; i+=collen, j++) { - p->out->data[j] = p->in->data[i]; - } - return OK; + if (LIKELY(start < p->in->sizes[1])) { + int32_t j,i,collen = p->in->sizes[1], len = p->in->sizes[0]; + for (j=0,i=start; j < len; i+=collen, j++) { + p->out->data[j] = p->in->data[i]; } - else return csound->PerfError(csound, &(p->h), - "%s", Str("requested col is out of range\n")); + return OK; + } + else return csound->PerfError(csound, &(p->h), + "%s", Str("requested col is out of range\n")); } int32_t cols_i(CSOUND *csound, FFT *p) { if (cols_init(csound, p) == OK) { - int32_t start = *((MYFLT *)p->in2); + int32_t start = *((MYFLT *)p->in2); if (LIKELY(start < p->in->sizes[1])) { - int32_t j,i,collen = p->in->sizes[1], len = p->in->sizes[0]; - for (j=0,i=start; j < len; i+=collen, j++) { - p->out->data[j] = p->in->data[i]; - } - return OK; + int32_t j,i,collen = p->in->sizes[1], len = p->in->sizes[0]; + for (j=0,i=start; j < len; i+=collen, j++) { + p->out->data[j] = p->in->data[i]; + } + return OK; } else return csound->InitError(csound, "%s", Str("requested col is out of range\n")); @@ -4060,47 +4060,47 @@ int32_t cols_i(CSOUND *csound, FFT *p) { } int32_t cols_perf_S(CSOUND *csound, FFT *p) { - ARRAYDAT* dat = p->in; /* The data in e 2_D array */ - STRINGDAT* mem = (STRINGDAT*)dat->data; - STRINGDAT* dest = (STRINGDAT*)p->out->data; - int32_t i; - int32_t index = (int32_t)(*((MYFLT *)p->in2)); - if (LIKELY(index < p->in->sizes[0])) { - //index = (index * dat->sizes[1]); - //printf("%d : %d\n", index, dat->sizes[1]); - mem += index; - //dest += index; - //incr = (index * (dat->arrayMemberSize / sizeof(MYFLT))); - //printf("*** mem = %p dst = %p\n", mem, dest); - for (i = 0; iin->sizes[0]; i++) { - dat->arrayType->copyValue(csound, dat->arrayType, (void*)dest, (void*)mem); - //printf("*** copies i=%d: %s -> %s\n", i,(char*)(dest->data),(char*)(mem->data)); - dest+= 1; - mem += p->in->sizes[1]; - } - return OK; + ARRAYDAT* dat = p->in; /* The data in e 2_D array */ + STRINGDAT* mem = (STRINGDAT*)dat->data; + STRINGDAT* dest = (STRINGDAT*)p->out->data; + int32_t i; + int32_t index = (int32_t)(*((MYFLT *)p->in2)); + if (LIKELY(index < p->in->sizes[0])) { + //index = (index * dat->sizes[1]); + //printf("%d : %d\n", index, dat->sizes[1]); + mem += index; + //dest += index; + //incr = (index * (dat->arrayMemberSize / sizeof(MYFLT))); + //printf("*** mem = %p dst = %p\n", mem, dest); + for (i = 0; iin->sizes[0]; i++) { + dat->arrayType->copyValue(csound, dat->arrayType, (void*)dest, (void*)mem); + //printf("*** copies i=%d: %s -> %s\n", i,(char*)(dest->data),(char*)(mem->data)); + dest+= 1; + mem += p->in->sizes[1]; } - else return csound->PerfError(csound, &(p->h), - "%s", Str("requested col is out of range\n")); + return OK; + } + else return csound->PerfError(csound, &(p->h), + "%s", Str("requested col is out of range\n")); } int32_t set_rows_perf(CSOUND *csound, FFT *p) { - int32_t start = *((MYFLT *)p->in2); - if (UNLIKELY(start < 0 || start >= p->out->sizes[0])) - return csound->PerfError(csound, &(p->h), - "%s", Str("Error: index out of range\n")); - int32_t bytes = p->in->sizes[0]*sizeof(MYFLT); - start *= p->out->sizes[1]; - memcpy(p->out->data+start,p->in->data,bytes); - return OK; + int32_t start = *((MYFLT *)p->in2); + if (UNLIKELY(start < 0 || start >= p->out->sizes[0])) + return csound->PerfError(csound, &(p->h), + "%s", Str("Error: index out of range\n")); + int32_t bytes = p->in->sizes[0]*sizeof(MYFLT); + start *= p->out->sizes[1]; + memcpy(p->out->data+start,p->in->data,bytes); + return OK; } int32_t set_rows_i(CSOUND *csound, FFT *p) { int32_t start = *((MYFLT *)p->in2); set_rows_init(csound, p); if (UNLIKELY(start < 0 || start >= p->out->sizes[0])) - return csound->InitError(csound, "%s", - Str("Error: index out of range\n")); + return csound->InitError(csound, "%s", + Str("Error: index out of range\n")); int32_t bytes = p->in->sizes[0]*sizeof(MYFLT); start *= p->out->sizes[1]; memcpy(p->out->data+start,p->in->data,bytes); @@ -4109,243 +4109,243 @@ int32_t set_rows_i(CSOUND *csound, FFT *p) { int32_t set_cols_init(CSOUND *csound, FFT *p) { - int32_t siz = p->in->sizes[0]; - int32_t col = *((MYFLT *)p->in2); - tabensure2D(csound, p->out, siz, col+1); - return OK; + int32_t siz = p->in->sizes[0]; + int32_t col = *((MYFLT *)p->in2); + tabensure2D(csound, p->out, siz, col+1); + return OK; } int32_t set_cols_perf(CSOUND *csound, FFT *p) { - int32_t start = *((MYFLT *)p->in2); + int32_t start = *((MYFLT *)p->in2); - if (UNLIKELY(start < 0 || start >= p->out->sizes[1])) - return csound->PerfError(csound, &(p->h), - "%s", Str("Error: index out of range\n")); - if (UNLIKELY(p->in->dimensions != 1 || p->in->sizes[0]out->sizes[0])) - return csound->PerfError(csound, &(p->h), - "%s", Str("Error: New column too short\n")); + if (UNLIKELY(start < 0 || start >= p->out->sizes[1])) + return csound->PerfError(csound, &(p->h), + "%s", Str("Error: index out of range\n")); + if (UNLIKELY(p->in->dimensions != 1 || p->in->sizes[0]out->sizes[0])) + return csound->PerfError(csound, &(p->h), + "%s", Str("Error: New column too short\n")); - int32_t j,i,row = p->out->sizes[1], col = p->out->sizes[0]; - for (j=0,i=start; j < col; i+=row, j++) - p->out->data[i] = p->in->data[j]; - return OK; + int32_t j,i,row = p->out->sizes[1], col = p->out->sizes[0]; + for (j=0,i=start; j < col; i+=row, j++) + p->out->data[i] = p->in->data[j]; + return OK; } int32_t set_cols_i(CSOUND *csound, FFT *p) { - int32_t start = *((MYFLT *)p->in2); - set_cols_init(csound,p); - if (UNLIKELY(start < 0 || start >= p->out->sizes[1])) - return csound->InitError(csound, "%s", - Str("Error: index out of range\n")); - if (UNLIKELY(p->in->dimensions != 1 || p->in->sizes[0]out->sizes[0])) - return csound->InitError(csound, "%s", - Str("Error: New column too short\n")); - int32_t j,i,row = p->out->sizes[1], col = p->out->sizes[0]; - for (j=0,i=start; j < col; i+=row, j++) - p->out->data[i] = p->in->data[j]; - return OK; + int32_t start = *((MYFLT *)p->in2); + set_cols_init(csound,p); + if (UNLIKELY(start < 0 || start >= p->out->sizes[1])) + return csound->InitError(csound, "%s", + Str("Error: index out of range\n")); + if (UNLIKELY(p->in->dimensions != 1 || p->in->sizes[0]out->sizes[0])) + return csound->InitError(csound, "%s", + Str("Error: New column too short\n")); + int32_t j,i,row = p->out->sizes[1], col = p->out->sizes[0]; + for (j=0,i=start; j < col; i+=row, j++) + p->out->data[i] = p->in->data[j]; + return OK; } int32_t set_cols_perf_S(CSOUND *csound, FFT *p) { - ARRAYDAT* dat = p->in; /* The data in 2_D array */ - STRINGDAT* mem = (STRINGDAT*)dat->data; - STRINGDAT* dest = (STRINGDAT*)p->out->data; - int32_t i; - int32_t index = (int32_t)(*((MYFLT *)p->in2)); - if (LIKELY(index < p->in->sizes[0])) { - index = (index * dat->sizes[1]); - //printf("%d : %d\n", index, dat->sizes[1]); - mem += index; - //incr = (index * (dat->arrayMemberSize / sizeof(MYFLT))); - //printf("*** mem = %p dst = %p\n", mem, dest); - for (i = 0; iin->sizes[0]; i++) { - dat->arrayType->copyValue(csound, dat->arrayType, (void*)mem, (void*)dest ); - //printf("*** copies i=%d: %s -> %s\n", i,(char*)(mem->data),(char*)(dest->data)); - dest += p->in->sizes[1]; - mem += 1; - } - return OK; + ARRAYDAT* dat = p->in; /* The data in 2_D array */ + STRINGDAT* mem = (STRINGDAT*)dat->data; + STRINGDAT* dest = (STRINGDAT*)p->out->data; + int32_t i; + int32_t index = (int32_t)(*((MYFLT *)p->in2)); + if (LIKELY(index < p->in->sizes[0])) { + index = (index * dat->sizes[1]); + //printf("%d : %d\n", index, dat->sizes[1]); + mem += index; + //incr = (index * (dat->arrayMemberSize / sizeof(MYFLT))); + //printf("*** mem = %p dst = %p\n", mem, dest); + for (i = 0; iin->sizes[0]; i++) { + dat->arrayType->copyValue(csound, dat->arrayType, (void*)mem, (void*)dest ); + //printf("*** copies i=%d: %s -> %s\n", i,(char*)(mem->data),(char*)(dest->data)); + dest += p->in->sizes[1]; + mem += 1; } - else return csound->PerfError(csound, &(p->h), - "%s", Str("requested col is out of range\n")); + return OK; + } + else return csound->PerfError(csound, &(p->h), + "%s", Str("requested col is out of range\n")); } int32_t set_cols_init_S(CSOUND *csound, FFT *p) { - if (set_cols_i(csound,p)==0) - return set_cols_perf_S(csound, p); - return NOTOK; + if (set_cols_i(csound,p)==0) + return set_cols_perf_S(csound, p); + return NOTOK; } int32_t cols_init_S(CSOUND *csound, FFT *p) { - if (cols_init(csound,p)==0) - return cols_perf_S(csound, p); - return NOTOK; + if (cols_init(csound,p)==0) + return cols_perf_S(csound, p); + return NOTOK; } int32_t shiftin_init(CSOUND *csound, FFT *p) { - int32_t sizs = CS_KSMPS; - if(p->out->sizes[0] < sizs) - tabinit(csound, p->out, sizs); - p->n = 0; - return OK; + int32_t sizs = CS_KSMPS; + if(p->out->sizes[0] < sizs) + tabinit(csound, p->out, sizs); + p->n = 0; + return OK; } int32_t shiftin_perf(CSOUND *csound, FFT *p) { - IGN(csound); - uint32_t siz = p->out->sizes[0], n = p->n; - MYFLT *in = ((MYFLT *) p->in); - if (n + CS_KSMPS < siz) { - memcpy(p->out->data+n,in,CS_KSMPS*sizeof(MYFLT)); - } - else { - int32_t num = siz - n; - memcpy(p->out->data+n,in,num*sizeof(MYFLT)); - memcpy(p->out->data,in+num,(CS_KSMPS-num)*sizeof(MYFLT)); - } - p->n = (n + CS_KSMPS)%siz; - return OK; + IGN(csound); + uint32_t siz = p->out->sizes[0], n = p->n; + MYFLT *in = ((MYFLT *) p->in); + if (n + CS_KSMPS < siz) { + memcpy(p->out->data+n,in,CS_KSMPS*sizeof(MYFLT)); + } + else { + int32_t num = siz - n; + memcpy(p->out->data+n,in,num*sizeof(MYFLT)); + memcpy(p->out->data,in+num,(CS_KSMPS-num)*sizeof(MYFLT)); + } + p->n = (n + CS_KSMPS)%siz; + return OK; } int32_t shiftout_init(CSOUND *csound, FFT *p) { - int32_t siz = p->in->sizes[0]; - p->n = ((int32_t)*((MYFLT *)p->in2) % siz); - if (UNLIKELY((uint32_t) siz < CS_KSMPS)) - return csound->InitError(csound, "%s", Str("input array too small\n")); - return OK; + int32_t siz = p->in->sizes[0]; + p->n = ((int32_t)*((MYFLT *)p->in2) % siz); + if (UNLIKELY((uint32_t) siz < CS_KSMPS)) + return csound->InitError(csound, "%s", Str("input array too small\n")); + return OK; } int32_t shiftout_perf(CSOUND *csound, FFT *p) { - IGN(csound); - uint32_t siz = p->in->sizes[0], n = p->n; - MYFLT *out = ((MYFLT *) p->out); + IGN(csound); + uint32_t siz = p->in->sizes[0], n = p->n; + MYFLT *out = ((MYFLT *) p->out); - if (n + CS_KSMPS < siz) { - memcpy(out,p->in->data+n,CS_KSMPS*sizeof(MYFLT)); - } - else { - int32_t num = siz - n; - memcpy(out,p->in->data+n,num*sizeof(MYFLT)); - memcpy(out+num,p->in->data,(CS_KSMPS-num)*sizeof(MYFLT)); - } - p->n = (n + CS_KSMPS)%siz; - return OK; + if (n + CS_KSMPS < siz) { + memcpy(out,p->in->data+n,CS_KSMPS*sizeof(MYFLT)); + } + else { + int32_t num = siz - n; + memcpy(out,p->in->data+n,num*sizeof(MYFLT)); + memcpy(out+num,p->in->data,(CS_KSMPS-num)*sizeof(MYFLT)); + } + p->n = (n + CS_KSMPS)%siz; + return OK; } int32_t scalarset(CSOUND *csound, TABCOPY *p) { - IGN(csound); - uint32_t siz = 0 , dim = p->tab->dimensions, i; - MYFLT val = *p->kfn; - for (i=0; i < dim; i++) - siz += p->tab->sizes[i]; - for (i=0; i < siz; i++) - p->tab->data[i] = val; - return OK; + IGN(csound); + uint32_t siz = 0 , dim = p->tab->dimensions, i; + MYFLT val = *p->kfn; + for (i=0; i < dim; i++) + siz += p->tab->sizes[i]; + for (i=0; i < siz; i++) + p->tab->data[i] = val; + return OK; } int32_t arrayass(CSOUND *csound, TABCOPY *p) { - IGN(csound); - uint32_t siz = 0 , dim = p->tab->dimensions, i; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t n, nsmps = CS_KSMPS; - int32_t span = (p->tab->arrayMemberSize)/sizeof(MYFLT); - MYFLT *val = p->kfn; - - for (i=0; i < dim; i++) - siz += p->tab->sizes[i]; - for (i=0; i < siz; i++) { - int32_t pp = i*span; - for (n=0; ntab->data[pp+n] = FL(0.0); - for (n=offset; ntab->data[pp+n] = val[n]; - for (n=nsmps-early; ntab->data[pp+n] = FL(0.0); - } - return OK; + IGN(csound); + uint32_t siz = 0 , dim = p->tab->dimensions, i; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t n, nsmps = CS_KSMPS; + int32_t span = (p->tab->arrayMemberSize)/sizeof(MYFLT); + MYFLT *val = p->kfn; + + for (i=0; i < dim; i++) + siz += p->tab->sizes[i]; + for (i=0; i < siz; i++) { + int32_t pp = i*span; + for (n=0; ntab->data[pp+n] = FL(0.0); + for (n=offset; ntab->data[pp+n] = val[n]; + for (n=nsmps-early; ntab->data[pp+n] = FL(0.0); + } + return OK; } int32_t unwrap(CSOUND *csound, FFT *p) { - IGN(csound); - int32_t i,siz = p->in->sizes[0]; - MYFLT *phs = p->out->data; - for (i=0; i < siz; i++) { - while (phs[i] >= PI) phs[i] -= TWOPI; - while (phs[i] < -PI) phs[i] += TWOPI; - } - return OK; + IGN(csound); + int32_t i,siz = p->in->sizes[0]; + MYFLT *phs = p->out->data; + for (i=0; i < siz; i++) { + while (phs[i] >= PI) phs[i] -= TWOPI; + while (phs[i] < -PI) phs[i] += TWOPI; + } + return OK; } int32_t init_dct(CSOUND *csound, FFT *p) { - int32_t N = p->in->sizes[0]; - if (LIKELY(isPowerOfTwo(N))) { - if (UNLIKELY(p->in->dimensions > 1)) - return csound->InitError(csound, "%s", - Str("dct: only one-dimensional arrays allowed")); + int32_t N = p->in->sizes[0]; + if (LIKELY(isPowerOfTwo(N))) { + if (UNLIKELY(p->in->dimensions > 1)) + return csound->InitError(csound, "%s", + Str("dct: only one-dimensional arrays allowed")); tabinit(csound, p->out, N); p->setup = csound->DCTSetup(csound,N,FFT_FWD); return OK; - } - else return - csound->InitError(csound, "%s", - Str("dct: non-pow-of-two sizes not yet implemented")); + } + else return + csound->InitError(csound, "%s", + Str("dct: non-pow-of-two sizes not yet implemented")); } int32_t kdct(CSOUND *csound, FFT *p) { - // FIXME: IF N changes value do we need a check - int32_t N = p->out->sizes[0]; - memcpy(p->out->data,p->in->data,N*sizeof(MYFLT)); - csound->DCT(csound,p->setup,p->out->data); - return OK; + // FIXME: IF N changes value do we need a check + int32_t N = p->out->sizes[0]; + memcpy(p->out->data,p->in->data,N*sizeof(MYFLT)); + csound->DCT(csound,p->setup,p->out->data); + return OK; } int32_t dct(CSOUND *csound, FFT *p) { - if (!init_dct(csound,p)) { - kdct(csound,p); - return OK; - } else return NOTOK; + if (!init_dct(csound,p)) { + kdct(csound,p); + return OK; + } else return NOTOK; } int32_t init_dctinv(CSOUND *csound, FFT *p) { - int32_t N = p->in->sizes[0]; - if (LIKELY(isPowerOfTwo(N))) { - if (UNLIKELY(p->in->dimensions > 1)) - return csound->InitError(csound, "%s", - Str("dctinv: only one-dimensional arrays allowed")); - tabinit(csound, p->out, N); - p->setup = csound->DCTSetup(csound,N,FFT_INV); - return OK; - } - else - return - csound->InitError(csound, "%s", - Str("dctinv: non-pow-of-two sizes not yet implemented")); + int32_t N = p->in->sizes[0]; + if (LIKELY(isPowerOfTwo(N))) { + if (UNLIKELY(p->in->dimensions > 1)) + return csound->InitError(csound, "%s", + Str("dctinv: only one-dimensional arrays allowed")); + tabinit(csound, p->out, N); + p->setup = csound->DCTSetup(csound,N,FFT_INV); + return OK; + } + else + return + csound->InitError(csound, "%s", + Str("dctinv: non-pow-of-two sizes not yet implemented")); } int32_t dctinv(CSOUND *csound, FFT *p) { - if (LIKELY(!init_dctinv(csound,p))) { - kdct(csound,p); - return OK; - } else return NOTOK; + if (LIKELY(!init_dctinv(csound,p))) { + kdct(csound,p); + return OK; + } else return NOTOK; } int32_t perf_pows(CSOUND *csound, FFT *p) { - IGN(csound); - int32_t i,j, end = p->out->sizes[0]; - MYFLT *in, *out; - in = p->in->data; - out = p->out->data; - for (i=2,j=1;jout->sizes[0]; + MYFLT *in, *out; + in = p->in->data; + out = p->out->data; + for (i=2,j=1;jlen; - int32_t N = p->in->sizes[0]; - if (LIKELY(L < N)) { - tabinit(csound, p->out, L); - } - else - return csound->InitError(csound, "%s", - Str("mfb: filter bank size exceeds input array length")); - if (p->bins.auxp == NULL || p->bins.size < (L+2)*sizeof(int32_t)) - csound->AuxAlloc(csound, (L+2)*sizeof(MYFLT), &p->bins); - return OK; + int32_t L = *p->len; + int32_t N = p->in->sizes[0]; + if (LIKELY(L < N)) { + tabinit(csound, p->out, L); + } + else + return csound->InitError(csound, "%s", + Str("mfb: filter bank size exceeds input array length")); + if (p->bins.auxp == NULL || p->bins.size < (L+2)*sizeof(int32_t)) + csound->AuxAlloc(csound, (L+2)*sizeof(MYFLT), &p->bins); + return OK; } int32_t mfb(CSOUND *csound, MFB *p) { - /* FIXME: Init cals tabinit but not checked in erf? */ - int32_t i,j; - int32_t *bin = (int32_t *) p->bins.auxp; - MYFLT start,max,end; - MYFLT g = FL(0.0), incr, decr; - int32_t L = p->out->sizes[0]; - int32_t N = p->in->sizes[0]; - MYFLT sum = FL(0.0); - MYFLT *out = p->out->data; - MYFLT *in = p->in->data; - MYFLT sr = CS_ESR; + /* FIXME: Init cals tabinit but not checked in erf? */ + int32_t i,j; + int32_t *bin = (int32_t *) p->bins.auxp; + MYFLT start,max,end; + MYFLT g = FL(0.0), incr, decr; + int32_t L = p->out->sizes[0]; + int32_t N = p->in->sizes[0]; + MYFLT sum = FL(0.0); + MYFLT *out = p->out->data; + MYFLT *in = p->in->data; + MYFLT sr = CS_ESR; - start = f2mel(*p->low); - end = f2mel(*p->up); - incr = (end-start)/(L+1); + start = f2mel(*p->low); + end = f2mel(*p->up); + incr = (end-start)/(L+1); - for (i=0;i N) bin[i] = N; - start += incr; - } + for (i=0;i N) bin[i] = N; + start += incr; + } - g = FL(0.0); - sum = FL(0.0); - } + for (i=0; i < L; i++) { + start = bin[i]; + max = bin[i+1]; + end = bin[i+2]; + incr = 1.0/(max - start); + decr = 1.0/(end - max); + for (j=start; j < max; j++) { + sum += in[j]*g; + g += incr; + } + g = FL(1.0); + for (j=max; j < end; j++) { + sum += in[j]*g; + g -= decr; + } + out[i] = sum/(end - start); + + g = FL(0.0); + sum = FL(0.0); + } - return OK; + return OK; } int32_t mfbi(CSOUND *csound, MFB *p) { - if (LIKELY(mfb_init(csound,p) == OK)) + if (LIKELY(mfb_init(csound,p) == OK)) return mfb(csound,p); - else return NOTOK; + else return NOTOK; } typedef struct _centr{ @@ -4445,17 +4445,17 @@ typedef struct _centr{ int32_t array_centroid(CSOUND *csound, CENTR *p) { - MYFLT *in = p->in->data,a=FL(0.0),b=FL(0.0); - int32_t NP1 = p->in->sizes[0]; - MYFLT f = CS_ESR/(2*(NP1 - 1)),cf; - int32_t i; - cf = f*FL(0.5); - for (i=0; i < NP1-1; i++, cf+=f) { - a += in[i]; - b += in[i]*cf; - } - *p->out = a > FL(0.0) ? b/a : FL(0.0); - return OK; + MYFLT *in = p->in->data,a=FL(0.0),b=FL(0.0); + int32_t NP1 = p->in->sizes[0]; + MYFLT f = CS_ESR/(2*(NP1 - 1)),cf; + int32_t i; + cf = f*FL(0.5); + for (i=0; i < NP1-1; i++, cf+=f) { + a += in[i]; + b += in[i]*cf; + } + *p->out = a > FL(0.0) ? b/a : FL(0.0); + return OK; } typedef struct _inout { @@ -4464,12 +4464,12 @@ typedef struct _inout { } INOUT; int32_t nxtpow2(CSOUND *csound, INOUT *p) { - IGN(csound); - int32_t inval = (int32_t)*p->in; - int32_t powtwo = 2; - while (powtwo < inval) powtwo *= 2; - *p->out = powtwo; - return OK; + IGN(csound); + int32_t inval = (int32_t)*p->in; + int32_t powtwo = 2; + while (powtwo < inval) powtwo *= 2; + *p->out = powtwo; + return OK; } @@ -4482,28 +4482,28 @@ typedef struct interl{ int32_t interleave_i (CSOUND *csound, INTERL *p) { - if(p->b->dimensions == 1 && - p->c->dimensions == 1 && - p->b->sizes[0] == p->c->sizes[0]) { - int32_t len = p->b->sizes[0], i,j; - tabinit(csound, p->a, len*2); - for(i = 0, j = 0; i < len; i++,j+=2) { - p->a->data[j] = p->b->data[i]; - p->a->data[j+1] = p->c->data[i]; - } - return OK; - } - return csound->InitError(csound, "%s", Str("array inputs not in correct format\n")); -} - -int32_t interleave_perf (CSOUND *csound, INTERL *p) { + if(p->b->dimensions == 1 && + p->c->dimensions == 1 && + p->b->sizes[0] == p->c->sizes[0]) { int32_t len = p->b->sizes[0], i,j; - tabcheck(csound, p->a, len*2, &(p->h)); + tabinit(csound, p->a, len*2); for(i = 0, j = 0; i < len; i++,j+=2) { p->a->data[j] = p->b->data[i]; p->a->data[j+1] = p->c->data[i]; } return OK; + } + return csound->InitError(csound, "%s", Str("array inputs not in correct format\n")); +} + +int32_t interleave_perf (CSOUND *csound, INTERL *p) { + int32_t len = p->b->sizes[0], i,j; + tabcheck(csound, p->a, len*2, &(p->h)); + for(i = 0, j = 0; i < len; i++,j+=2) { + p->a->data[j] = p->b->data[i]; + p->a->data[j+1] = p->c->data[i]; + } + return OK; } int32_t deinterleave_i (CSOUND *csound, INTERL *p) { @@ -4521,66 +4521,66 @@ int32_t deinterleave_i (CSOUND *csound, INTERL *p) { } int32_t deinterleave_perf (CSOUND *csound, INTERL *p) { - int32_t len = p->c->sizes[0]/2, i,j; - tabcheck(csound, p->a, len, &(p->h)); - tabcheck(csound, p->b, len, &(p->h)); - for(i = 0, j = 0; i < len; i++,j+=2) { - p->a->data[i] = p->c->data[j]; - p->b->data[i] = p->c->data[j+1]; - } - return OK; + int32_t len = p->c->sizes[0]/2, i,j; + tabcheck(csound, p->a, len, &(p->h)); + tabcheck(csound, p->b, len, &(p->h)); + for(i = 0, j = 0; i < len; i++,j+=2) { + p->a->data[i] = p->c->data[j]; + p->b->data[i] = p->c->data[j+1]; + } + return OK; } static int32 taninv2_Ai(CSOUND* csound, TABARITH* p) { - ARRAYDAT* ans = p->ans; - ARRAYDAT* aa = p->left; - ARRAYDAT* bb = p->right; - int i, j, k; - if (tabarithset(csound, p)!=OK) - return NOTOK; - k = 0; - for (i=0; idimensions; i++) { - for (j=0; jsizes[i]; j++) { - ans->data[k] = ATAN2(aa->data[k], bb->data[k]); - k++; - } + ARRAYDAT* ans = p->ans; + ARRAYDAT* aa = p->left; + ARRAYDAT* bb = p->right; + int i, j, k; + if (tabarithset(csound, p)!=OK) + return NOTOK; + k = 0; + for (i=0; idimensions; i++) { + for (j=0; jsizes[i]; j++) { + ans->data[k] = ATAN2(aa->data[k], bb->data[k]); + k++; } - return OK; + } + return OK; } static int32 taninv2_A(CSOUND* csound, TABARITH* p) { - ARRAYDAT* ans = p->ans; - ARRAYDAT* aa = p->left; - ARRAYDAT* bb = p->right; - int i, j, k; - k = 0; - for (i=0; idimensions; i++) { - for (j=0; jsizes[i]; j++) { - ans->data[k] = ATAN2(aa->data[k], bb->data[k]); - k++; - } + ARRAYDAT* ans = p->ans; + ARRAYDAT* aa = p->left; + ARRAYDAT* bb = p->right; + int i, j, k; + k = 0; + for (i=0; idimensions; i++) { + for (j=0; jsizes[i]; j++) { + ans->data[k] = ATAN2(aa->data[k], bb->data[k]); + k++; } - return OK; + } + return OK; } static int32 taninv2_Aa(CSOUND* csound, TABARITH* p) { - ARRAYDAT* ans = p->ans; - ARRAYDAT* aa = p->left; - ARRAYDAT* bb = p->right; - int i, j, k; - uint32_t m; - k = 0; - for (i=0; idimensions; i++) { - for (j=0; jsizes[i]; j++) - for (m=0; mdata[k] = ATAN2(aa->data[k], bb->data[k]); - k++; - } - } - return OK; + ARRAYDAT* ans = p->ans; + ARRAYDAT* aa = p->left; + ARRAYDAT* bb = p->right; + int i, j, k; + uint32_t m; + k = 0; + for (i=0; idimensions; i++) { + for (j=0; jsizes[i]; j++) + for (m=0; mdata[k] = ATAN2(aa->data[k], bb->data[k]); + k++; + } + } + return OK; } @@ -4590,417 +4590,417 @@ static int32 taninv2_Aa(CSOUND* csound, TABARITH* p) static OENTRY arrayvars_localops[] = { - { "nxtpow2", sizeof(INOUT), 0, 1, "i", "i", (SUBR)nxtpow2}, - { "init.i", sizeof(ARRAYINIT), 0, 1, "i[]", "m", (SUBR)array_init }, - { "init.k", sizeof(ARRAYINIT), 0, 1, "k[]", "m", (SUBR)array_init }, - { "init.a", sizeof(ARRAYINIT), 0, 1, "a[]", "m", (SUBR)array_init }, - { "init.S", sizeof(ARRAYINIT), 0, 1, "S[]", "m", (SUBR)array_init }, - { "init.0", sizeof(ARRAYINIT), 0, 1, ".[]", "m", (SUBR)array_init }, - { "fillarray.k", sizeof(TABFILL), 0, 1, "k[]", "m", (SUBR)tabfill }, - { "fillarray.i", sizeof(TABFILL), 0, 1, "i[]", "m", (SUBR)tabfill }, - { "fillarray.s", sizeof(TABFILL), 0, 1, "S[]", "W", (SUBR)tabfill }, - { "fillarray.K", sizeof(TABFILL), 0, 2, "k[]", "z", NULL, (SUBR)tabfill }, - { "fillarray.f", sizeof(TABFILLF), 0, 1, "k[]", "S", (SUBR)tabfillf }, - { "fillarray.F", sizeof(TABFILLF), 0, 1, "i[]", "S", (SUBR)tabfillf }, - { "string2array.S", sizeof(TABFILLF), 0, 1, "i[]", "S", (SUBR)tabsfill }, - { "string2array.s", sizeof(TABFILLF), 0, 1, "k[]", "S", (SUBR)tabsfill }, - { "array.k", sizeof(TABFILL), _QQ, 1, "k[]", "m", (SUBR)tabfill }, - { "array.i", sizeof(TABFILL), _QQ, 1, "i[]", "m", (SUBR)tabfill }, - { "##array_init", sizeof(ARRAY_SET), 0, 1, "", ".[].m", (SUBR)array_set }, - { "##array_set.k", sizeof(ARRAY_SET), 0, 2, "", "k[]km", NULL,(SUBR)array_set}, - { "##array_set.a", sizeof(ARRAY_SET), 0, 2, "", "a[]am", NULL, (SUBR)array_set}, + { "nxtpow2", sizeof(INOUT), 0, "i", "i", (SUBR)nxtpow2}, + { "init.i", sizeof(ARRAYINIT), 0, "i[]", "m", (SUBR)array_init }, + { "init.k", sizeof(ARRAYINIT), 0, "k[]", "m", (SUBR)array_init }, + { "init.a", sizeof(ARRAYINIT), 0, "a[]", "m", (SUBR)array_init }, + { "init.S", sizeof(ARRAYINIT), 0, "S[]", "m", (SUBR)array_init }, + { "init.0", sizeof(ARRAYINIT), 0, ".[]", "m", (SUBR)array_init }, + { "fillarray.k", sizeof(TABFILL), 0, "k[]", "m", (SUBR)tabfill }, + { "fillarray.i", sizeof(TABFILL), 0, "i[]", "m", (SUBR)tabfill }, + { "fillarray.s", sizeof(TABFILL), 0, "S[]", "W", (SUBR)tabfill }, + { "fillarray.K", sizeof(TABFILL), 0, "k[]", "z", NULL, (SUBR)tabfill }, + { "fillarray.f", sizeof(TABFILLF), 0, "k[]", "S", (SUBR)tabfillf }, + { "fillarray.F", sizeof(TABFILLF), 0, "i[]", "S", (SUBR)tabfillf }, + { "string2array.S", sizeof(TABFILLF), 0, "i[]", "S", (SUBR)tabsfill }, + { "string2array.s", sizeof(TABFILLF), 0, "k[]", "S", (SUBR)tabsfill }, + { "array.k", sizeof(TABFILL), _QQ, "k[]", "m", (SUBR)tabfill }, + { "array.i", sizeof(TABFILL), _QQ, "i[]", "m", (SUBR)tabfill }, + { "##array_init", sizeof(ARRAY_SET), 0, "", ".[].m", (SUBR)array_set }, + { "##array_set.k", sizeof(ARRAY_SET), 0, "", "k[]km", NULL,(SUBR)array_set}, + { "##array_set.a", sizeof(ARRAY_SET), 0, "", "a[]am", NULL, (SUBR)array_set}, // VL: 11.2.22 I think array set S needs to be added running at thread 3 for parser3 - { "##array_set.S", sizeof(ARRAY_SET), 0, 3, "", "S[].m", (SUBR)array_set , (SUBR)array_set }, - { "##array_set.i", sizeof(ARRAY_SET), 0, 1, "", ".[].m", (SUBR)array_set }, - { "##array_set.e", sizeof(ARRAY_SET), 0, 1, "", "i[].z", (SUBR)array_err }, - { "##array_set.x", sizeof(ARRAY_SET), 0, 2, "", ".[].z", NULL, (SUBR)array_set}, - { "##array_get.k", sizeof(ARRAY_GET), 0, 2, "k", "k[]m", NULL,(SUBR)array_get }, - { "##array_get.a", sizeof(ARRAY_GET), 0, 2, "a", "a[]m",NULL, (SUBR)array_get }, - { "##array_get.x", sizeof(ARRAY_GET), 0, 1, ".", ".[]m",(SUBR)array_get }, - { "##array_get.K", sizeof(ARRAY_GET), 0, 2, ".", ".[]z",NULL, (SUBR)array_get}, - { "i.Ai", sizeof(ARRAY_GET),0, 1, "i", "k[]m", (SUBR)array_get }, - { "i.Ak", sizeof(ARRAY_GET),0, 1, "i", "k[]z", (SUBR)array_get }, + { "##array_set.S", sizeof(ARRAY_SET), 0, "", "S[].m", (SUBR)array_set , (SUBR)array_set }, + { "##array_set.i", sizeof(ARRAY_SET), 0, "", ".[].m", (SUBR)array_set }, + { "##array_set.e", sizeof(ARRAY_SET), 0, "", "i[].z", (SUBR)array_err }, + { "##array_set.x", sizeof(ARRAY_SET), 0, "", ".[].z", NULL, (SUBR)array_set}, + { "##array_get.k", sizeof(ARRAY_GET), 0, "k", "k[]m", NULL,(SUBR)array_get }, + { "##array_get.a", sizeof(ARRAY_GET), 0, "a", "a[]m",NULL, (SUBR)array_get }, + { "##array_get.x", sizeof(ARRAY_GET), 0, ".", ".[]m",(SUBR)array_get }, + { "##array_get.K", sizeof(ARRAY_GET), 0, ".", ".[]z",NULL, (SUBR)array_get}, + { "i.Ai", sizeof(ARRAY_GET),0, "i", "k[]m", (SUBR)array_get }, + { "i.Ak", sizeof(ARRAY_GET),0, "i", "k[]z", (SUBR)array_get }, /* ******************************************** */ - {"##add.[s]", sizeof(TABARITH), 0, 3, "a[]", "a[]a[]", + {"##add.[s]", sizeof(TABARITH), 0, "a[]", "a[]a[]", (SUBR)tabarithset, (SUBR)tabaadd}, - {"##add.[]", sizeof(TABARITH), 0, 3, "k[]", "k[]k[]", + {"##add.[]", sizeof(TABARITH), 0, "k[]", "k[]k[]", (SUBR)tabarithset, (SUBR)tabadd}, - {"##add.[i]", sizeof(TABARITH), 0, 1, "i[]", "i[]i[]", + {"##add.[i]", sizeof(TABARITH), 0, "i[]", "i[]i[]", (SUBR)tabaddi}, /* ******************************************** */ - {"##sub.[a]", sizeof(TABARITH), 0, 3, "a[]", "a[]a[]", + {"##sub.[a]", sizeof(TABARITH), 0, "a[]", "a[]a[]", (SUBR)tabarithset, (SUBR)tabasub}, - {"##sub.[]", sizeof(TABARITH), 0, 3, "k[]", "k[]k[]", + {"##sub.[]", sizeof(TABARITH), 0, "k[]", "k[]k[]", (SUBR)tabarithset, (SUBR)tabsub}, - {"##sub.[i]", sizeof(TABARITH), 0, 1, "i[]", "i[]i[]", + {"##sub.[i]", sizeof(TABARITH), 0, "i[]", "i[]i[]", (SUBR)tabsubi}, - // {"##neg.[]", sizeof(TABARITH), 0, 3, "k[]", "k[]", + // {"##neg.[]", sizeof(TABARITH), 0, "k[]", "k[]", // (SUBR)tabarithset1, (SUBR)tabneg}, - {"##mul.[a]", sizeof(TABARITH), 0, 3, "a[]", "a[]a[]", - (SUBR)tabarithset,(SUBR)tabamul}, - {"##mul.[]", sizeof(TABARITH), 0, 3, "k[]", "k[]k[]", + {"##mul.[a]", sizeof(TABARITH), 0, "a[]", "a[]a[]", + (SUBR)tabarithset,(SUBR)tabamul}, + {"##mul.[]", sizeof(TABARITH), 0, "k[]", "k[]k[]", (SUBR)tabarithset,(SUBR)tabmult}, - {"##mul.[i]", sizeof(TABARITH), 0, 1, "i[]", "i[]i[]", + {"##mul.[i]", sizeof(TABARITH), 0, "i[]", "i[]i[]", (SUBR)tabmulti}, - {"##div.[a]", sizeof(TABARITH), 0, 3, "a[]", "a[]a[]", + {"##div.[a]", sizeof(TABARITH), 0, "a[]", "a[]a[]", (SUBR)tabarithset, (SUBR)tabadiv}, - {"##div.[]", sizeof(TABARITH), 0, 3, "k[]", "k[]k[]", + {"##div.[]", sizeof(TABARITH), 0, "k[]", "k[]k[]", (SUBR)tabarithset,(SUBR)tabdiv }, - {"##div.[i]", sizeof(TABARITH), 0, 1, "i[]", "i[]i[]", + {"##div.[i]", sizeof(TABARITH), 0, "i[]", "i[]i[]", (SUBR)tabdivi }, - {"##rem.[]", sizeof(TABARITH), 0, 3, "k[]", "k[]k[]", + {"##rem.[]", sizeof(TABARITH), 0, "k[]", "k[]k[]", (SUBR)tabarithset, (SUBR)tabrem}, - {"##rem.[i]", sizeof(TABARITH), 0, 1, "i[]", "i[]i[]", (SUBR)tabremi}, - {"##add.[i", sizeof(TABARITH1), 0, 3, "k[]", "k[]i", + {"##rem.[i]", sizeof(TABARITH), 0, "i[]", "i[]i[]", (SUBR)tabremi}, + {"##add.[i", sizeof(TABARITH1), 0, "k[]", "k[]i", (SUBR)tabarithset1, (SUBR)tabaiadd }, - {"##add.i[", sizeof(TABARITH2), 0, 3, "k[]", "ik[]", + {"##add.i[", sizeof(TABARITH2), 0, "k[]", "ik[]", (SUBR)tabarithset2, (SUBR)tabiaadd }, - {"##add.[p", sizeof(TABARITH1), 0, 1, "i[]", "i[]i", (SUBR)tabaiaddi }, - {"##add.p[", sizeof(TABARITH2), 0, 1, "i[]", "ii[]", (SUBR)tabiaaddi }, - {"##add.k[a[", sizeof(TABARITH), 0, 3, "a[]", "k[]a[]", + {"##add.[p", sizeof(TABARITH1), 0, "i[]", "i[]i", (SUBR)tabaiaddi }, + {"##add.p[", sizeof(TABARITH2), 0, "i[]", "ii[]", (SUBR)tabiaaddi }, + {"##add.k[a[", sizeof(TABARITH), 0, "a[]", "k[]a[]", (SUBR)tabarithset, (SUBR)tabkrardd }, - {"##add.a[k[", sizeof(TABARITH), 0, 3, "a[]", "a[]k[]", + {"##add.a[k[", sizeof(TABARITH), 0, "a[]", "a[]k[]", (SUBR)tabarithset, (SUBR)tabarkrdd }, - {"##addin.[i", sizeof(TABARITHIN1), 0, 1, "i[]", "i", (SUBR)addinAA, NULL }, - {"##addin.[k", sizeof(TABARITHIN1), 0, 2, "k[]", "i", NULL, (SUBR)addinAA }, - {"##addin.[", sizeof(TABARITHIN), 0, 1, "i[]", "i[]", (SUBR)tabaddinkk, NULL }, - {"##addin.[K", sizeof(TABARITHIN), 0, 2, "k[]", "k[]", NULL, (SUBR)tabaddinkk }, - {"##addin.[a", sizeof(TABARITHIN), 0, 2, "a[]", "a[]", NULL, (SUBR)tabaaddin }, - {"##addin.[a", sizeof(TABARITHIN), 0, 2, "a[]", "a[]", NULL, (SUBR)tabaaddin }, - {"##addin.[ak", sizeof(TABARITHIN), 0, 2, "a[]", "k[]", NULL, (SUBR)tabarkrddin }, - {"##addin.[aks", sizeof(TABARITHIN), 0, 2, "a[]", "k", NULL, (SUBR)tabakaddin }, - {"##sub.[i", sizeof(TABARITH1), 0, 3, "k[]", "k[]i", + {"##addin.[i", sizeof(TABARITHIN1), 0, "i[]", "i", (SUBR)addinAA, NULL }, + {"##addin.[k", sizeof(TABARITHIN1), 0, "k[]", "i", NULL, (SUBR)addinAA }, + {"##addin.[", sizeof(TABARITHIN), 0, "i[]", "i[]", (SUBR)tabaddinkk, NULL }, + {"##addin.[K", sizeof(TABARITHIN), 0, "k[]", "k[]", NULL, (SUBR)tabaddinkk }, + {"##addin.[a", sizeof(TABARITHIN), 0, "a[]", "a[]", NULL, (SUBR)tabaaddin }, + {"##addin.[a", sizeof(TABARITHIN), 0, "a[]", "a[]", NULL, (SUBR)tabaaddin }, + {"##addin.[ak", sizeof(TABARITHIN), 0, "a[]", "k[]", NULL, (SUBR)tabarkrddin }, + {"##addin.[aks", sizeof(TABARITHIN), 0, "a[]", "k", NULL, (SUBR)tabakaddin }, + {"##sub.[i", sizeof(TABARITH1), 0, "k[]", "k[]i", (SUBR)tabarithset1, (SUBR)tabaisub }, - {"##sub.i[", sizeof(TABARITH2), 0, 3, "k[]", "ik[]", + {"##sub.i[", sizeof(TABARITH2), 0, "k[]", "ik[]", (SUBR)tabarithset2, (SUBR)tabiasub }, - {"##subin.[i", sizeof(TABARITHIN1), 0, 1, "i[]", "i", (SUBR)subinAA, NULL }, - {"##subin.[", sizeof(TABARITHIN), 0, 1, "i[]", "i[]", (SUBR)tabsubinkk, NULL }, - {"##subin.[K", sizeof(TABARITHIN), 0, 2, "k[]", "k[]", NULL, (SUBR)tabsubinkk }, - {"##subin.[k", sizeof(TABARITHIN1), 0, 2, "k[]", "k", NULL, (SUBR)subinAA }, - {"##subin.[a", sizeof(TABARITHIN), 0, 2, "a[]", "a[]", NULL, (SUBR)tabaasubin }, - {"##subin.[ak", sizeof(TABARITHIN), 0, 2, "a[]", "k[]", NULL, (SUBR)tabarkrsbin }, - {"##subdin.[aks", sizeof(TABARITHIN), 0, 2, "a[]", "k", NULL, (SUBR)tabaksubin }, - {"##sub.[p", sizeof(TABARITH1), 0, 1, "i[]", "i[]i", (SUBR)tabaisubi }, - {"##sub.p[", sizeof(TABARITH2), 0, 1, "i[]", "ii[]", (SUBR)tabiasubi }, - {"##sub.k[a[", sizeof(TABARITH), 0, 3, "a[]", "k[]a[]", + {"##subin.[i", sizeof(TABARITHIN1), 0, "i[]", "i", (SUBR)subinAA, NULL }, + {"##subin.[", sizeof(TABARITHIN), 0, "i[]", "i[]", (SUBR)tabsubinkk, NULL }, + {"##subin.[K", sizeof(TABARITHIN), 0, "k[]", "k[]", NULL, (SUBR)tabsubinkk }, + {"##subin.[k", sizeof(TABARITHIN1), 0, "k[]", "k", NULL, (SUBR)subinAA }, + {"##subin.[a", sizeof(TABARITHIN), 0, "a[]", "a[]", NULL, (SUBR)tabaasubin }, + {"##subin.[ak", sizeof(TABARITHIN), 0, "a[]", "k[]", NULL, (SUBR)tabarkrsbin }, + {"##subdin.[aks", sizeof(TABARITHIN), 0, "a[]", "k", NULL, (SUBR)tabaksubin }, + {"##sub.[p", sizeof(TABARITH1), 0, "i[]", "i[]i", (SUBR)tabaisubi }, + {"##sub.p[", sizeof(TABARITH2), 0, "i[]", "ii[]", (SUBR)tabiasubi }, + {"##sub.k[a[", sizeof(TABARITH), 0, "a[]", "k[]a[]", (SUBR)tabarithset, (SUBR)tabkrarsb }, - {"##sub.a[k[", sizeof(TABARITH), 0, 3, "a[]", "a[]k[]", + {"##sub.a[k[", sizeof(TABARITH), 0, "a[]", "a[]k[]", (SUBR)tabarithset, (SUBR)tabarkrsb }, - {"##mul.[i", sizeof(TABARITH1), 0, 3, "k[]", "k[]i", + {"##mul.[i", sizeof(TABARITH1), 0, "k[]", "k[]i", (SUBR)tabarithset1, (SUBR)tabaimult }, - {"##mul.i[", sizeof(TABARITH2), 0, 3, "k[]", "ik[]", + {"##mul.i[", sizeof(TABARITH2), 0, "k[]", "ik[]", (SUBR)tabarithset2, (SUBR)tabiamult }, - {"##mul.[p", sizeof(TABARITH1), 0, 1, "i[]", "i[]i", (SUBR)tabaimulti }, - {"##mul.p[", sizeof(TABARITH2), 0, 1, "i[]", "ii[]", (SUBR)tabiamulti }, - {"##mul.k[a[", sizeof(TABARITH), 0, 3, "a[]", "k[]a[]", + {"##mul.[p", sizeof(TABARITH1), 0, "i[]", "i[]i", (SUBR)tabaimulti }, + {"##mul.p[", sizeof(TABARITH2), 0, "i[]", "ii[]", (SUBR)tabiamulti }, + {"##mul.k[a[", sizeof(TABARITH), 0, "a[]", "k[]a[]", (SUBR)tabarithset, (SUBR)tabkrarml }, - {"##mul.a[k[", sizeof(TABARITH), 0, 3, "a[]", "a[]k[]", + {"##mul.a[k[", sizeof(TABARITH), 0, "a[]", "a[]k[]", (SUBR)tabarithset, (SUBR)tabarkrml }, - {"##div.[i", sizeof(TABARITH1), 0, 3, "k[]", "k[]i", + {"##div.[i", sizeof(TABARITH1), 0, "k[]", "k[]i", (SUBR)tabarithset1, (SUBR)tabaidiv }, - {"##div.i[", sizeof(TABARITH2), 0, 3, "k[]", "ik[]", + {"##div.i[", sizeof(TABARITH2), 0, "k[]", "ik[]", (SUBR)tabarithset2, (SUBR)tabiadiv }, - {"##div.[p", sizeof(TABARITH1), 0, 1, "i[]", "i[]i", (SUBR)tabaidivi }, - {"##div.p[", sizeof(TABARITH2), 0, 1, "i[]", "ii[]", (SUBR)tabiadivi }, - {"##div.k[a[", sizeof(TABARITH), 0, 3, "a[]", "k[]a[]", + {"##div.[p", sizeof(TABARITH1), 0, "i[]", "i[]i", (SUBR)tabaidivi }, + {"##div.p[", sizeof(TABARITH2), 0, "i[]", "ii[]", (SUBR)tabiadivi }, + {"##div.k[a[", sizeof(TABARITH), 0, "a[]", "k[]a[]", (SUBR)tabarithset, (SUBR)tabkrardv }, - {"##div.a[k[", sizeof(TABARITH), 0, 3, "a[]", "a[]k[]", + {"##div.a[k[", sizeof(TABARITH), 0, "a[]", "a[]k[]", (SUBR)tabarithset, (SUBR)tabarkrdv }, - {"##rem.[i", sizeof(TABARITH1),0, 3, "k[]", "k[]i", + {"##rem.[i", sizeof(TABARITH1),0, "k[]", "k[]i", (SUBR)tabarithset1, (SUBR)tabairem }, - {"##rem.i[", sizeof(TABARITH2),0, 3, "k[]", "ik[]", + {"##rem.i[", sizeof(TABARITH2),0, "k[]", "ik[]", (SUBR)tabarithset2, (SUBR)tabiarem }, - {"##rem.[p", sizeof(TABARITH1),0, 1, "i[]", "i[]i", (SUBR)tabairemi }, - {"##rem.p[", sizeof(TABARITH2),0, 1, "i[]", "ii[]", (SUBR)tabiaremi }, - {"##rem.a[k[", sizeof(TABARITH), 0, 3, "a[]", "a[]k[]", + {"##rem.[p", sizeof(TABARITH1),0, "i[]", "i[]i", (SUBR)tabairemi }, + {"##rem.p[", sizeof(TABARITH2),0, "i[]", "ii[]", (SUBR)tabiaremi }, + {"##rem.a[k[", sizeof(TABARITH), 0, "a[]", "a[]k[]", (SUBR)tabarithset, (SUBR)tabarkrmd }, - {"##re.k[a[", sizeof(TABARITH), 0, 3, "a[]", "k[]a[]", + {"##re.k[a[", sizeof(TABARITH), 0, "a[]", "k[]a[]", (SUBR)tabarithset, (SUBR)tabkrarmd }, - {"##add.[k", sizeof(TABARITH1), 0, 3, "k[]", "i[]k", + {"##add.[k", sizeof(TABARITH1), 0, "k[]", "i[]k", (SUBR)tabarithset1, (SUBR)tabaiadd }, - {"##add.[k", sizeof(TABARITH1), 0, 3, "k[]", "k[]k", + {"##add.[k", sizeof(TABARITH1), 0, "k[]", "k[]k", (SUBR)tabarithset1, (SUBR)tabaiadd }, - {"##add.k[", sizeof(TABARITH2), 0, 3, "k[]", "ik[]", + {"##add.k[", sizeof(TABARITH2), 0, "k[]", "ik[]", (SUBR)tabarithset2, (SUBR)tabiaadd }, - {"##add.k[", sizeof(TABARITH2), 0, 3, "k[]", "kk[]", + {"##add.k[", sizeof(TABARITH2), 0, "k[]", "kk[]", (SUBR)tabarithset2, (SUBR)tabiaadd }, - {"##add.[ak", sizeof(TABARITH1), 0, 3, "a[]", "a[]k", + {"##add.[ak", sizeof(TABARITH1), 0, "a[]", "a[]k", (SUBR)tabarithset1, (SUBR)tabakadd }, - {"##add.k[a", sizeof(TABARITH2), 0, 3, "a[]", "ka[]", + {"##add.k[a", sizeof(TABARITH2), 0, "a[]", "ka[]", (SUBR)tabarithset2, (SUBR)tabkaadd }, - {"##add.aa[", sizeof(TABARITH1), 0, 3, "a[]", "aa[]", + {"##add.aa[", sizeof(TABARITH1), 0, "a[]", "aa[]", (SUBR)tabarithset1, (SUBR)tabaardd }, - {"##add.a[a", sizeof(TABARITH2), 0, 3, "a[]", "a[]a", + {"##add.a[a", sizeof(TABARITH2), 0, "a[]", "a[]a", (SUBR)tabarithset2, (SUBR)tabaradd }, - {"##sub.[k", sizeof(TABARITH1), 0, 3, "k[]", "i[]k", + {"##sub.[k", sizeof(TABARITH1), 0, "k[]", "i[]k", (SUBR)tabarithset1, (SUBR)tabaisub }, - {"##sub.[k", sizeof(TABARITH1), 0, 3, "k[]", "k[]k", + {"##sub.[k", sizeof(TABARITH1), 0, "k[]", "k[]k", (SUBR)tabarithset1, (SUBR)tabaisub }, - {"##sub.k[", sizeof(TABARITH2), 0, 3, "k[]", "kk[]", + {"##sub.k[", sizeof(TABARITH2), 0, "k[]", "kk[]", (SUBR)tabarithset2, (SUBR)tabiasub }, - {"##sub.k[", sizeof(TABARITH2), 0, 3, "k[]", "ki[]", + {"##sub.k[", sizeof(TABARITH2), 0, "k[]", "ki[]", (SUBR)tabarithset2, (SUBR)tabiasub }, - {"##sub.[ak", sizeof(TABARITH1), 0, 3, "a[]", "a[]k", + {"##sub.[ak", sizeof(TABARITH1), 0, "a[]", "a[]k", (SUBR)tabarithset1, (SUBR)tabaksub }, - {"##sub.k[a", sizeof(TABARITH2), 0, 3, "a[]", "ka[]", + {"##sub.k[a", sizeof(TABARITH2), 0, "a[]", "ka[]", (SUBR)tabarithset2, (SUBR)tabkasub }, - {"##sub.aa[", sizeof(TABARITH2), 0, 3, "a[]", "a[]a", + {"##sub.aa[", sizeof(TABARITH2), 0, "a[]", "a[]a", (SUBR)tabarithset2, (SUBR)tabaarsb }, - {"##sub.a[a", sizeof(TABARITH1), 0, 3, "a[]", "aa[]", + {"##sub.a[a", sizeof(TABARITH1), 0, "a[]", "aa[]", (SUBR)tabarithset1, (SUBR)tabarasb }, - {"##mul.[k", sizeof(TABARITH1), 0, 3, "k[]", "k[]k", + {"##mul.[k", sizeof(TABARITH1), 0, "k[]", "k[]k", (SUBR)tabarithset1, (SUBR)tabaimult }, - {"##mul.[k", sizeof(TABARITH1), 0, 3, "k[]", "i[]k", + {"##mul.[k", sizeof(TABARITH1), 0, "k[]", "i[]k", (SUBR)tabarithset1, (SUBR)tabaimult }, - {"##mul.k[", sizeof(TABARITH2), 0, 3, "k[]", "kk[]", + {"##mul.k[", sizeof(TABARITH2), 0, "k[]", "kk[]", (SUBR)tabarithset2, (SUBR)tabiamult }, - {"##mul.k[", sizeof(TABARITH2), 0, 3, "k[]", "ki[]", + {"##mul.k[", sizeof(TABARITH2), 0, "k[]", "ki[]", (SUBR)tabarithset2, (SUBR)tabiamult }, - {"##mul.[ak", sizeof(TABARITH1), 0, 3, "a[]", "a[]k", + {"##mul.[ak", sizeof(TABARITH1), 0, "a[]", "a[]k", (SUBR)tabarithset1, (SUBR)tabakmult }, - {"##mul.k[a", sizeof(TABARITH2), 0, 3, "a[]", "ka[]", + {"##mul.k[a", sizeof(TABARITH2), 0, "a[]", "ka[]", (SUBR)tabarithset2, (SUBR)tabkamult }, - {"##mul.a[a", sizeof(TABARITH1), 0, 3, "a[]", "a[]a", + {"##mul.a[a", sizeof(TABARITH1), 0, "a[]", "a[]a", (SUBR)tabarithset1, (SUBR)tabaraml }, - {"##mul.aa[", sizeof(TABARITH2), 0, 3, "a[]", "aa[]", + {"##mul.aa[", sizeof(TABARITH2), 0, "a[]", "aa[]", (SUBR)tabarithset2, (SUBR)tabaarml }, - {"##div.[k", sizeof(TABARITH1), 0, 3, "k[]", "k[]k", + {"##div.[k", sizeof(TABARITH1), 0, "k[]", "k[]k", (SUBR)tabarithset1, (SUBR)tabaidiv }, - {"##div.k[", sizeof(TABARITH2), 0, 3, "k[]", "ki[]", + {"##div.k[", sizeof(TABARITH2), 0, "k[]", "ki[]", (SUBR)tabarithset2, (SUBR)tabiadiv }, - {"##div.[k", sizeof(TABARITH1), 0, 3, "k[]", "i[]k", + {"##div.[k", sizeof(TABARITH1), 0, "k[]", "i[]k", (SUBR)tabarithset1, (SUBR)tabaidiv }, - {"##div.k[", sizeof(TABARITH2), 0, 3, "k[]", "kk[]", + {"##div.k[", sizeof(TABARITH2), 0, "k[]", "kk[]", (SUBR)tabarithset2, (SUBR)tabiadiv }, - {"##div.[ak", sizeof(TABARITH1), 0, 3, "a[]", "a[]k", + {"##div.[ak", sizeof(TABARITH1), 0, "a[]", "a[]k", (SUBR)tabarithset1, (SUBR)tabakdiv }, - {"##div.k[a", sizeof(TABARITH2), 0, 3, "a[]", "ka[]", + {"##div.k[a", sizeof(TABARITH2), 0, "a[]", "ka[]", (SUBR)tabarithset2, (SUBR)tabkadiv }, - {"##div.a[a", sizeof(TABARITH1), 0, 3, "a[]", "a[]a", + {"##div.a[a", sizeof(TABARITH1), 0, "a[]", "a[]a", (SUBR)tabarithset1, (SUBR)tabaardv }, - {"##div.a[a", sizeof(TABARITH1), 0, 3, "a[]", "a[]a", + {"##div.a[a", sizeof(TABARITH1), 0, "a[]", "a[]a", (SUBR)tabarithset1, (SUBR)tabaradv }, - {"##rem.[k", sizeof(TABARITH1),0, 3, "k[]", "k[]k", + {"##rem.[k", sizeof(TABARITH1),0, "k[]", "k[]k", (SUBR)tabarithset1, (SUBR)tabairem }, - {"##rem.[ak", sizeof(TABARITH1),0, 3, "a[]", "a[]k", + {"##rem.[ak", sizeof(TABARITH1),0, "a[]", "a[]k", (SUBR)tabarithset1, (SUBR)tabarkrem }, - {"##rem.k[", sizeof(TABARITH2),0, 3, "k[]", "kk[]", + {"##rem.k[", sizeof(TABARITH2),0, "k[]", "kk[]", (SUBR)tabarithset2, (SUBR)tabiarem }, - {"##pow.[]", sizeof(TABARITH), 0, 3, "k[]", "k[]k[]", + {"##pow.[]", sizeof(TABARITH), 0, "k[]", "k[]k[]", (SUBR)tabarithset,(SUBR)tabpow }, - {"##pow.[i]", sizeof(TABARITH), 0, 1, "i[]", "i[]i[]", + {"##pow.[i]", sizeof(TABARITH), 0, "i[]", "i[]i[]", (SUBR)tabpowi }, - {"##pow.[i", sizeof(TABARITH1), 0, 3, "k[]", "k[]i", + {"##pow.[i", sizeof(TABARITH1), 0, "k[]", "k[]i", (SUBR)tabarithset1, (SUBR)tabaipow }, - {"##pow.i[", sizeof(TABARITH2), 0, 3, "k[]", "ik[]", + {"##pow.i[", sizeof(TABARITH2), 0, "k[]", "ik[]", (SUBR)tabarithset2, (SUBR)tabiapow }, - {"##pow.[p", sizeof(TABARITH1), 0, 1, "i[]", "i[]i", (SUBR)tabaipowi }, - {"##pow.p[", sizeof(TABARITH2), 0, 1, "i[]", "ii[]", (SUBR)tabiapowi }, - {"##pow.[k", sizeof(TABARITH1), 0, 3, "k[]", "k[]k", + {"##pow.[p", sizeof(TABARITH1), 0, "i[]", "i[]i", (SUBR)tabaipowi }, + {"##pow.p[", sizeof(TABARITH2), 0, "i[]", "ii[]", (SUBR)tabiapowi }, + {"##pow.[k", sizeof(TABARITH1), 0, "k[]", "k[]k", (SUBR)tabarithset1, (SUBR)tabaipow }, - {"##pow.k[", sizeof(TABARITH2), 0, 3, "k[]", "kk[]", + {"##pow.k[", sizeof(TABARITH2), 0, "k[]", "kk[]", (SUBR)tabarithset2, (SUBR)tabiapow }, - {"##pow.ki[", sizeof(TABARITH2), 0, 3, "k[]", "ki[]", + {"##pow.ki[", sizeof(TABARITH2), 0, "k[]", "ki[]", (SUBR)tabarithset2, (SUBR)tabiapow }, - {"##pow.[ak", sizeof(TABARITH1), 0, 3, "a[]", "a[]k", + {"##pow.[ak", sizeof(TABARITH1), 0, "a[]", "a[]k", (SUBR)tabarithset1, (SUBR)tabarkpow }, - {"##pow.a[k[", sizeof(TABARITH), 0, 3, "a[]", "a[]k[]", + {"##pow.a[k[", sizeof(TABARITH), 0, "a[]", "a[]k[]", (SUBR)tabarithset, (SUBR)tabarkrpw }, - { "maxtab.k",sizeof(TABQUERY),_QQ, 3, "kz", "k[]", + { "maxtab.k",sizeof(TABQUERY),_QQ, "kz", "k[]", (SUBR) tabqset, (SUBR) tabmax }, - { "maxarray.k", sizeof(TABQUERY), 0, 3, "kz", "k[]", + { "maxarray.k", sizeof(TABQUERY), 0, "kz", "k[]", (SUBR) tabqset,(SUBR) tabmax }, - { "maxarray.i", sizeof(TABQUERY), 0, 1, "iI", "i[]",(SUBR) tabmax1, NULL }, - { "mintab.k", sizeof(TABQUERY),_QQ, 3, "kz", "k[]", + { "maxarray.i", sizeof(TABQUERY), 0, "iI", "i[]",(SUBR) tabmax1, NULL }, + { "mintab.k", sizeof(TABQUERY),_QQ, "kz", "k[]", (SUBR) tabqset, (SUBR) tabmin }, - { "minarray.k", sizeof(TABQUERY),0, 3, "kz", "k[]",(SUBR) tabqset, + { "minarray.k", sizeof(TABQUERY),0, "kz", "k[]",(SUBR) tabqset, (SUBR) tabmin }, - { "minarray.i", sizeof(TABQUERY),0, 1, "iI", "i[]",(SUBR) tabmin1 }, - { "sumtab", sizeof(TABQUERY1),_QQ, 3, "k", "k[]", + { "minarray.i", sizeof(TABQUERY),0, "iI", "i[]",(SUBR) tabmin1 }, + { "sumtab", sizeof(TABQUERY1),_QQ, "k", "k[]", (SUBR) tabqset1, (SUBR) tabsum }, - { "sumarray.k", sizeof(TABQUERY1),0, 3, "k", "k[]", + { "sumarray.k", sizeof(TABQUERY1),0, "k", "k[]", (SUBR) tabqset1, (SUBR) tabsum }, - { "sumarray.a", sizeof(TABQUERY1),0, 3, "a", "a[]", + { "sumarray.a", sizeof(TABQUERY1),0, "a", "a[]", (SUBR) tabqset1, (SUBR) tabsuma1 }, - { "sumarray.i", sizeof(TABQUERY1),0, 1, "i", "i[]", (SUBR) tabsum1 }, - { "scalet", sizeof(TABSCALE), _QQ|WI, 3, "", "k[]kkOJ", + { "sumarray.i", sizeof(TABQUERY1),0, "i", "i[]", (SUBR) tabsum1 }, + { "scalet", sizeof(TABSCALE), _QQ|WI, "", "k[]kkOJ", (SUBR) tabscaleset,(SUBR) tabscale }, - { "scalearray.k", sizeof(TABSCALE), WI, 3, "", "k[]kkOJ", + { "scalearray.k", sizeof(TABSCALE), WI, "", "k[]kkOJ", (SUBR) tabscaleset,(SUBR) tabscale }, - { "scalearray.1", sizeof(TABSCALE), WI, 1, "", "i[]iiOJ", (SUBR) tabscale1 }, - { "=.I", sizeof(TABCPY), 0, 1, "i[]", "i[]", (SUBR)tabcopy1, NULL }, - { "fillarray", sizeof(TABCPY), 0, 1, "k[]", "i[]", (SUBR)tabcopy1, NULL }, - { "=.J", sizeof(TABCPY), 0, 1, "i[]", "k[]", (SUBR)tabcopy1, NULL }, - { "=.IK", sizeof(TABCPY), 0, 3, "k[]", "i[]", (SUBR)tabcopy1, (SUBR)tabcopy1 }, - { "=.K", sizeof(TABCPY), 0, 3, "k[]", "k[]", (SUBR)tabcopyk_init, (SUBR)tabcopyk }, - { "=._", sizeof(TABCPY), 0, 3, ".[]", ".[]", (SUBR)tabcopy, (SUBR)tabcopy }, - { "=.L", sizeof(TABCPY), 0, 3, ".[]", ".[]", (SUBR)tabcopy2, (SUBR)tabcopy2 }, - { "tabgen", sizeof(TABGEN), _QQ, 1, "k[]", "iip", (SUBR) tabgen, NULL }, - { "tabmap_i", sizeof(TABMAP), _QQ, 1, "k[]", "k[]S", (SUBR) tabmap_set }, - { "tabmap", sizeof(TABMAP), _QQ, 3, "k[]", "k[]S", (SUBR) tabmap_set, + { "scalearray.1", sizeof(TABSCALE), WI, "", "i[]iiOJ", (SUBR) tabscale1 }, + { "=.I", sizeof(TABCPY), 0, "i[]", "i[]", (SUBR)tabcopy1, NULL }, + { "fillarray", sizeof(TABCPY), 0, "k[]", "i[]", (SUBR)tabcopy1, NULL }, + { "=.J", sizeof(TABCPY), 0, "i[]", "k[]", (SUBR)tabcopy1, NULL }, + { "=.IK", sizeof(TABCPY), 0, "k[]", "i[]", (SUBR)tabcopy1, (SUBR)tabcopy1 }, + { "=.K", sizeof(TABCPY), 0, "k[]", "k[]", (SUBR)tabcopyk_init, (SUBR)tabcopyk }, + { "=._", sizeof(TABCPY), 0, ".[]", ".[]", (SUBR)tabcopy, (SUBR)tabcopy }, + { "=.L", sizeof(TABCPY), 0, ".[]", ".[]", (SUBR)tabcopy2, (SUBR)tabcopy2 }, + { "tabgen", sizeof(TABGEN), _QQ, "k[]", "iip", (SUBR) tabgen, NULL }, + { "tabmap_i", sizeof(TABMAP), _QQ, "k[]", "k[]S", (SUBR) tabmap_set }, + { "tabmap", sizeof(TABMAP), _QQ, "k[]", "k[]S", (SUBR) tabmap_set, (SUBR) tabmap_perf}, - { "tabmap", sizeof(TABMAP), _QQ, 3, "k[]", "k[]S", (SUBR) tabmap_set, + { "tabmap", sizeof(TABMAP), _QQ, "k[]", "k[]S", (SUBR) tabmap_set, (SUBR) tabmap_perf}, - { "genarray.i", sizeof(TABGEN),0, 1, "i[]", "iip", (SUBR) tabgen, NULL }, - { "genarray_i", sizeof(TABGEN),0, 1, "k[]", "iip", (SUBR) tabgen, NULL, NULL}, - { "genarray.k", sizeof(TABGEN),0, 2, "k[]", "kkp", NULL, (SUBR)tabgen }, - { "maparray_i", sizeof(TABMAP),0, 1, "k[]", "k[]S", (SUBR) tabmap_set }, - { "maparray.k", sizeof(TABMAP), 0, 3, "k[]", "k[]S", (SUBR) tabmap_set, + { "genarray.i", sizeof(TABGEN),0, "i[]", "iip", (SUBR) tabgen, NULL }, + { "genarray_i", sizeof(TABGEN),0, "k[]", "iip", (SUBR) tabgen, NULL, NULL}, + { "genarray.k", sizeof(TABGEN),0, "k[]", "kkp", NULL, (SUBR)tabgen }, + { "maparray_i", sizeof(TABMAP),0, "k[]", "k[]S", (SUBR) tabmap_set }, + { "maparray.k", sizeof(TABMAP), 0, "k[]", "k[]S", (SUBR) tabmap_set, (SUBR) tabmap_perf }, - { "maparray.i", sizeof(TABMAP), 0, 1, "i[]", "i[]S", (SUBR) tabmap_set }, - /* { "maparray.s", sizeof(TABMAP), 0, 3, "S[]", "S[]S", (SUBR) tabmap_set, */ + { "maparray.i", sizeof(TABMAP), 0, "i[]", "i[]S", (SUBR) tabmap_set }, + /* { "maparray.s", sizeof(TABMAP), 0, "S[]", "S[]S", (SUBR) tabmap_set, */ /* (SUBR) tabmap_perf }, */ - { "tabslice", sizeof(TABSLICE), _QQ, 2, "k[]", "k[]iip", + { "tabslice", sizeof(TABSLICE), _QQ, "k[]", "k[]iip", NULL, (SUBR) tabslice, NULL }, - { "slicearray.i", sizeof(TABSLICE), 0, 1, "i[]", "i[]iip", + { "slicearray.i", sizeof(TABSLICE), 0, "i[]", "i[]iip", (SUBR) tabslice, NULL, NULL }, - { "slicearray.k", sizeof(TABSLICE), 0, 2, "k[]", "k[]iip", + { "slicearray.k", sizeof(TABSLICE), 0, "k[]", "k[]iip", (SUBR) tabslice, (SUBR) tabslice, NULL }, - { "slicearray.a", sizeof(TABSLICE), 0, 2, "a[]", "a[]iip", + { "slicearray.a", sizeof(TABSLICE), 0, "a[]", "a[]iip", (SUBR) tabslice, (SUBR) tabslice, NULL }, - { "slicearray.S", sizeof(TABSLICE), 0, 2, "S[]", "S[]iip", + { "slicearray.S", sizeof(TABSLICE), 0, "S[]", "S[]iip", (SUBR) tabslice, (SUBR) tabslice, NULL }, - { "slicearray_i.i", sizeof(TABSLICE), 0, 1, "i[]", "i[]iip", + { "slicearray_i.i", sizeof(TABSLICE), 0, "i[]", "i[]iip", + (SUBR) tabslice, NULL }, + { "slicearray_i.k", sizeof(TABSLICE), 0, "k[]", "k[]iip", (SUBR) tabslice, NULL }, - { "slicearray_i.k", sizeof(TABSLICE), 0, 1, "k[]", "k[]iip", - (SUBR) tabslice, NULL }, - { "slicearray_i.S", sizeof(TABSLICE), 0, 1, "S[]", "S[]iip", + { "slicearray_i.S", sizeof(TABSLICE), 0, "S[]", "S[]iip", (SUBR) tabslice, NULL }, - { "trim.i", sizeof(TRIM), WI, 1, "", "i[]i", (SUBR)trim_i, NULL }, - { "trim.k", sizeof(TRIM), WI, 2, "", ".[]k", NULL, (SUBR)trim }, - { "trim_i", sizeof(TRIM), WI, 1, "", ".[]i", (SUBR)trim_i, NULL }, - { "copy2ftab", sizeof(TABCOPY), TW|_QQ, 2, "", "k[]k", NULL, (SUBR) tab2ftab }, - { "copy2ttab", sizeof(TABCOPY), TR|_QQ, 2, "", "k[]k", NULL, (SUBR) ftab2tab }, - { "copya2ftab.k", sizeof(TABCOPY), TW, 3, "", "k[]k", + { "trim.i", sizeof(TRIM), WI, "", "i[]i", (SUBR)trim_i, NULL }, + { "trim.k", sizeof(TRIM), WI, "", ".[]k", NULL, (SUBR)trim }, + { "trim_i", sizeof(TRIM), WI, "", ".[]i", (SUBR)trim_i, NULL }, + { "copy2ftab", sizeof(TABCOPY), TW|_QQ, "", "k[]k", NULL, (SUBR) tab2ftab }, + { "copy2ttab", sizeof(TABCOPY), TR|_QQ, "", "k[]k", NULL, (SUBR) ftab2tab }, + { "copya2ftab.k", sizeof(TABCOPY), TW, "", "k[]k", (SUBR) tab2ftabi, (SUBR) tab2ftab }, - { "copyf2array.k", sizeof(TABCOPY), TR, 3, "", "k[]k", + { "copyf2array.k", sizeof(TABCOPY), TR, "", "k[]k", (SUBR) ftab2tabi, (SUBR) ftab2tab }, - { "copyf2array.kk", sizeof(TABCOPY), TR, 3, "", "k[]kk", + { "copyf2array.kk", sizeof(TABCOPY), TR, "", "k[]kk", (SUBR) ftab2tabi, (SUBR) ftab2tab }, - // { "copya2ftab.i", sizeof(TABCOPY), TW, 1, "", "i[]i", (SUBR) tab2ftabi }, - { "copya2ftab.ii", sizeof(TABCOPY2), TW, 1, "", "i[]io", (SUBR) tab2ftab_offset_i }, - { "copya2ftab.kk", sizeof(TABCOPY2), TW, 2, "", "k[]kO", NULL , (SUBR) tab2ftab_offset }, - { "copyf2array.i", sizeof(TABCOPY), TR, 1, "", "i[]i", (SUBR) ftab2tabi }, + // { "copya2ftab.i", sizeof(TABCOPY), TW, "", "i[]i", (SUBR) tab2ftabi }, + { "copya2ftab.ii", sizeof(TABCOPY2), TW, "", "i[]io", (SUBR) tab2ftab_offset_i }, + { "copya2ftab.kk", sizeof(TABCOPY2), TW, "", "k[]kO", NULL , (SUBR) tab2ftab_offset }, + { "copyf2array.i", sizeof(TABCOPY), TR, "", "i[]i", (SUBR) ftab2tabi }, /* { "lentab", 0xffff}, */ - { "lentab.i", sizeof(TABQUERY1), _QQ, 1, "i", "k[]p", (SUBR) tablength }, - { "lentab.k", sizeof(TABQUERY1), _QQ, 1, "k", "k[]p", NULL, (SUBR) tablength }, - { "lenarray.ix", sizeof(TABQUERY1), 0, 1, "i", ".[]p", (SUBR) tablength }, - { "lenarray.kx", sizeof(TABQUERY1), 0, 2, "k", ".[]p", NULL, (SUBR)tablength }, - { "in.A", sizeof(OUTA), 0, 3, "a[]", "", (SUBR)ina_set, (SUBR)ina}, - { "monitor.A", sizeof(OUTA), IB, 3, "a[]", "", + { "lentab.i", sizeof(TABQUERY1), _QQ, "i", "k[]p", (SUBR) tablength }, + { "lentab.k", sizeof(TABQUERY1), _QQ, "k", "k[]p", NULL, (SUBR) tablength }, + { "lenarray.ix", sizeof(TABQUERY1), 0, "i", ".[]p", (SUBR) tablength }, + { "lenarray.kx", sizeof(TABQUERY1), 0, "k", ".[]p", NULL, (SUBR)tablength }, + { "in.A", sizeof(OUTA), 0, "a[]", "", (SUBR)ina_set, (SUBR)ina}, + { "monitor.A", sizeof(OUTA), IB, "a[]", "", (SUBR)monitora_init, (SUBR)monitora_perf}, - { "rfft", sizeof(FFT), 0, 3, "k[]","k[]", + { "rfft", sizeof(FFT), 0, "k[]","k[]", (SUBR) init_rfft, (SUBR) perf_rfft, NULL}, - {"rfft", sizeof(FFT), 0, 1, "i[]","i[]", + {"rfft", sizeof(FFT), 0, "i[]","i[]", (SUBR) rfft_i, NULL, NULL}, - {"rifft", sizeof(FFT), 0, 3, "k[]","k[]", + {"rifft", sizeof(FFT), 0, "k[]","k[]", (SUBR) init_rifft, (SUBR) perf_rifft, NULL}, - {"rifft", sizeof(FFT), 0, 1, "i[]","i[]", + {"rifft", sizeof(FFT), 0, "i[]","i[]", (SUBR) rifft_i, NULL, NULL}, - {"cmplxprod", sizeof(FFT), 0, 3, "k[]","k[]k[]", + {"cmplxprod", sizeof(FFT), 0, "k[]","k[]k[]", (SUBR) init_rfftmult, (SUBR) perf_rfftmult, NULL}, - {"fft", sizeof(FFT), 0, 3, "k[]","k[]", + {"fft", sizeof(FFT), 0, "k[]","k[]", (SUBR) initialise_fft, (SUBR) perf_fft, NULL}, - {"fft", sizeof(FFT), 0, 1, "i[]","i[]", + {"fft", sizeof(FFT), 0, "i[]","i[]", (SUBR) fft_i, NULL, NULL}, - {"fftinv", sizeof(FFT), 0, 3, "k[]","k[]", + {"fftinv", sizeof(FFT), 0, "k[]","k[]", (SUBR) init_ifft, (SUBR) perf_ifft, NULL}, - {"fftinv", sizeof(FFT), 0, 1, "i[]","i[]", + {"fftinv", sizeof(FFT), 0, "i[]","i[]", (SUBR) ifft_i, NULL, NULL}, - {"rect2pol", sizeof(FFT), 0, 3, "k[]","k[]", + {"rect2pol", sizeof(FFT), 0, "k[]","k[]", (SUBR) init_recttopol, (SUBR) perf_recttopol, NULL}, - {"pol2rect", sizeof(FFT), 0, 3, "k[]","k[]", + {"pol2rect", sizeof(FFT), 0, "k[]","k[]", (SUBR) init_recttopol, (SUBR) perf_poltorect, NULL}, - {"pol2rect.AA", sizeof(FFT), 0, 3, "k[]","k[]k[]", + {"pol2rect.AA", sizeof(FFT), 0, "k[]","k[]k[]", (SUBR) init_poltorect2, (SUBR) perf_poltorect2, NULL}, - {"mags", sizeof(FFT), 0, 3, "k[]","k[]", + {"mags", sizeof(FFT), 0, "k[]","k[]", (SUBR) init_mags, (SUBR) perf_mags, NULL}, - {"pows", sizeof(FFT), 0, 3, "k[]","k[]", + {"pows", sizeof(FFT), 0, "k[]","k[]", (SUBR) init_mags, (SUBR) perf_pows, NULL}, - {"phs", sizeof(FFT), 0, 3, "k[]","k[]", + {"phs", sizeof(FFT), 0, "k[]","k[]", (SUBR) init_mags, (SUBR) perf_phs, NULL}, - {"log", sizeof(FFT), 0, 3, "k[]","k[]i", + {"log", sizeof(FFT), 0, "k[]","k[]i", (SUBR) init_logarray, (SUBR) perf_logarray, NULL}, - {"r2c", sizeof(FFT), 0, 1, "i[]","i[]", + {"r2c", sizeof(FFT), 0, "i[]","i[]", (SUBR) rtoc_i, NULL, NULL}, - {"r2c", sizeof(FFT), 0, 3, "k[]","k[]", + {"r2c", sizeof(FFT), 0, "k[]","k[]", (SUBR) init_rtoc, (SUBR) perf_rtoc, NULL}, - {"c2r", sizeof(FFT), 0, 1, "i[]","i[]", + {"c2r", sizeof(FFT), 0, "i[]","i[]", (SUBR) ctor_i, NULL, NULL}, - {"c2r", sizeof(FFT), 0, 3, "k[]","k[]", + {"c2r", sizeof(FFT), 0, "k[]","k[]", (SUBR) init_ctor, (SUBR) perf_ctor, NULL}, - {"window", sizeof(FFT), 0, 3, "k[]","k[]Op", + {"window", sizeof(FFT), 0, "k[]","k[]Op", (SUBR) init_window, (SUBR) perf_window, NULL}, - {"pvsceps", sizeof(PVSCEPS), 0, 3, "k[]","fo", + {"pvsceps", sizeof(PVSCEPS), 0, "k[]","fo", (SUBR) pvsceps_init, (SUBR) pvsceps_perf, NULL}, - {"cepsinv", sizeof(FFT), 0, 3, "k[]","k[]", + {"cepsinv", sizeof(FFT), 0, "k[]","k[]", (SUBR) init_iceps, (SUBR) perf_iceps, NULL}, - {"ceps", sizeof(FFT), 0, 3, "k[]","k[]k", + {"ceps", sizeof(FFT), 0, "k[]","k[]k", (SUBR) init_ceps, (SUBR) perf_ceps, NULL}, - {"getrow", sizeof(FFT), 0, 1, "i[]","i[]i", + {"getrow", sizeof(FFT), 0, "i[]","i[]i", (SUBR) rows_i, NULL, NULL}, - {"getrow.S", sizeof(FFT), 0, 3, "S[]","S[]k", + {"getrow.S", sizeof(FFT), 0, "S[]","S[]k", (SUBR) rows_init_S, (SUBR) rows_perf_S, NULL}, - {"getrow", sizeof(FFT), 0, 3, "k[]","k[]k", + {"getrow", sizeof(FFT), 0, "k[]","k[]k", (SUBR) rows_init, (SUBR) rows_perf, NULL}, - {"getcol", sizeof(FFT), 0, 1, "i[]","i[]i", + {"getcol", sizeof(FFT), 0, "i[]","i[]i", (SUBR) cols_i, NULL, NULL}, - {"getcol", sizeof(FFT), 0, 3, "k[]","k[]k", + {"getcol", sizeof(FFT), 0, "k[]","k[]k", (SUBR) cols_init, (SUBR) cols_perf, NULL}, - {"getcol", sizeof(FFT), 0, 3, "S[]","S[]k", + {"getcol", sizeof(FFT), 0, "S[]","S[]k", (SUBR) cols_init_S, (SUBR) cols_perf_S, NULL}, - {"setrow", sizeof(FFT), 0, 1, "i[]","i[]i", + {"setrow", sizeof(FFT), 0, "i[]","i[]i", (SUBR) set_rows_i, NULL, NULL}, - {"setrow", sizeof(FFT), 0, 3, "k[]","k[]k", + {"setrow", sizeof(FFT), 0, "k[]","k[]k", (SUBR) set_rows_init, (SUBR) set_rows_perf, NULL}, - {"setrow.S", sizeof(FFT), 0, 3, "S[]","S[]k", + {"setrow.S", sizeof(FFT), 0, "S[]","S[]k", (SUBR) set_rows_init_S, (SUBR) set_rows_perf_S, NULL}, - {"setcol", sizeof(FFT), 0, 1, "i[]","i[]i", + {"setcol", sizeof(FFT), 0, "i[]","i[]i", (SUBR) set_cols_i, NULL, NULL}, - {"setcol", sizeof(FFT), 0, 3, "k[]","k[]k", + {"setcol", sizeof(FFT), 0, "k[]","k[]k", (SUBR) set_cols_init, (SUBR) set_cols_perf, NULL}, - {"setcol", sizeof(FFT), 0, 3, "S[]","S[]k", + {"setcol", sizeof(FFT), 0, "S[]","S[]k", (SUBR) set_cols_init_S, (SUBR) set_cols_perf_S, NULL}, - {"shiftin", sizeof(FFT), 0, 3, "k[]","a", + {"shiftin", sizeof(FFT), 0, "k[]","a", (SUBR) shiftin_init, (SUBR) shiftin_perf}, - {"shiftout", sizeof(FFT), 0, 3, "a","k[]o", + {"shiftout", sizeof(FFT), 0, "a","k[]o", (SUBR) shiftout_init, (SUBR) shiftout_perf}, - {"unwrap", sizeof(FFT), 0, 3, "k[]","k[]", + {"unwrap", sizeof(FFT), 0, "k[]","k[]", (SUBR) init_recttopol, (SUBR) unwrap}, - {"=.X", sizeof(TABCOPY), 0, 3, "k[]","k", (SUBR) scalarset, (SUBR) scalarset}, - {"=.Z", sizeof(TABCOPY), 0 , 2, "a[]", "a", NULL, (SUBR) arrayass}, - {"dct", sizeof(FFT), 0, 3, "k[]","k[]", + {"=.X", sizeof(TABCOPY), 0, "k[]","k", (SUBR) scalarset, (SUBR) scalarset}, + {"=.Z", sizeof(TABCOPY), 0 , "a[]", "a", NULL, (SUBR) arrayass}, + {"dct", sizeof(FFT), 0, "k[]","k[]", (SUBR) init_dct, (SUBR) kdct, NULL}, - {"dct", sizeof(FFT), 0, 1, "i[]","i[]", + {"dct", sizeof(FFT), 0, "i[]","i[]", (SUBR) dct, NULL, NULL}, - {"dctinv", sizeof(FFT), 0, 3, "k[]","k[]", + {"dctinv", sizeof(FFT), 0, "k[]","k[]", (SUBR) init_dctinv, (SUBR) kdct, NULL}, - {"dctinv", sizeof(FFT), 0, 1, "i[]","i[]", + {"dctinv", sizeof(FFT), 0, "i[]","i[]", (SUBR)dctinv, NULL, NULL}, - {"mfb", sizeof(MFB), 0, 3, "k[]","k[]kki", + {"mfb", sizeof(MFB), 0, "k[]","k[]kki", (SUBR) mfb_init, (SUBR) mfb, NULL}, - {"mfb", sizeof(MFB), 0, 1, "i[]","i[]iii", + {"mfb", sizeof(MFB), 0, "i[]","i[]iii", (SUBR)mfbi, NULL, NULL}, - {"centroid", sizeof(CENTR), 0, 1, "i","i[]", + {"centroid", sizeof(CENTR), 0, "i","i[]", (SUBR) array_centroid, NULL, NULL}, - {"centroid", sizeof(CENTR), 0, 2, "k","k[]", NULL, + {"centroid", sizeof(CENTR), 0, "k","k[]", NULL, (SUBR)array_centroid, NULL}, - {"interleave", sizeof(INTERL), 0, 1, "i[]","i[]i[]", + {"interleave", sizeof(INTERL), 0, "i[]","i[]i[]", (SUBR)interleave_i}, - {"interleave", sizeof(INTERL), 0, 1, "k[]","k[]k[]", + {"interleave", sizeof(INTERL), 0, "k[]","k[]k[]", (SUBR)interleave_i, (SUBR) interleave_perf}, - {"deinterleave", sizeof(INTERL), 0, 1, "i[]i[]","i[]", + {"deinterleave", sizeof(INTERL), 0, "i[]i[]","i[]", (SUBR)deinterleave_i}, - {"deinterleave", sizeof(INTERL), 0, 1, "k[]k[]","k[]", + {"deinterleave", sizeof(INTERL), 0, "k[]k[]","k[]", (SUBR)deinterleave_i, (SUBR)deinterleave_perf}, - { "taninv2.Ai", sizeof(TABARITH), 0, 1, "i[]", "i[]i[]", (SUBR)taninv2_Ai }, - { "taninv2.Ak", sizeof(TABARITH), 0, 2, "k[]", "k[]k[]", (SUBR)tabarithset, (SUBR)taninv2_A }, - { "taninv2.Aa", sizeof(TABARITH), 0, 2, "a[]", "a[]a[]", (SUBR)tabarithset, (SUBR)taninv2_Aa }, - { "autocorr", sizeof(AUTOCORR), 0, 3, "k[]", "k[]", (SUBR) init_autocorr, (SUBR) perf_autocorr }, - { "clear", sizeof(TABCLEAR), 0, 3, "", "a[]", (SUBR)tabclearset, (SUBR)tabclear }, - { "clear", sizeof(TABCLEAR), 0, 3, "", "k[]", (SUBR)tabclearset, (SUBR)tabcleark } + { "taninv2.Ai", sizeof(TABARITH), 0, "i[]", "i[]i[]", (SUBR)taninv2_Ai }, + { "taninv2.Ak", sizeof(TABARITH), 0, "k[]", "k[]k[]", (SUBR)tabarithset, (SUBR)taninv2_A }, + { "taninv2.Aa", sizeof(TABARITH), 0, "a[]", "a[]a[]", (SUBR)tabarithset, (SUBR)taninv2_Aa }, + { "autocorr", sizeof(AUTOCORR), 0, "k[]", "k[]", (SUBR) init_autocorr, (SUBR) perf_autocorr }, + { "clear", sizeof(TABCLEAR), 0, "", "a[]", (SUBR)tabclearset, (SUBR)tabclear }, + { "clear", sizeof(TABCLEAR), 0, "", "k[]", (SUBR)tabclearset, (SUBR)tabcleark } }; LINKAGE_BUILTIN(arrayvars_localops) diff --git a/Opcodes/babo.c b/Opcodes/babo.c index d41193dbabf..1c8da11c371 100644 --- a/Opcodes/babo.c +++ b/Opcodes/babo.c @@ -929,8 +929,8 @@ babo2(CSOUND *csound, void *entry) #define S(x) sizeof(x) static OENTRY babo_localops[] = { - { "babo", S(BABO), TR, 3, "aa", "akkkiiijj",(SUBR)baboset, (SUBR)babo }, - { "babo2", S(BABO), TR, 3, "aa", "akkkiiijj",(SUBR)baboset, (SUBR)babo2 } + { "babo", S(BABO), TR, "aa", "akkkiiijj",(SUBR)baboset, (SUBR)babo }, + { "babo2", S(BABO), TR, "aa", "akkkiiijj",(SUBR)baboset, (SUBR)babo2 } }; LINKAGE_BUILTIN(babo_localops) diff --git a/Opcodes/bbcut.c b/Opcodes/bbcut.c index f7786f12fdf..2e8c2f4155e 100644 --- a/Opcodes/bbcut.c +++ b/Opcodes/bbcut.c @@ -536,9 +536,9 @@ static int32_t BBCutStereo(CSOUND *csound, BBCUTSTEREO *p) #define S(x) sizeof(x) static OENTRY localops[] = { - { "bbcutm",S(BBCUTMONO), 0, 3, "a","aiiiiipop", + { "bbcutm",S(BBCUTMONO), 0, "a","aiiiiipop", (SUBR)BBCutMonoInit, (SUBR)BBCutMono }, - { "bbcuts",S(BBCUTSTEREO), 0, 3, "aa","aaiiiiipop", + { "bbcuts",S(BBCUTSTEREO), 0, "aa","aaiiiiipop", (SUBR)BBCutStereoInit, (SUBR)BBCutStereo} }; diff --git a/Opcodes/bformdec2.cpp b/Opcodes/bformdec2.cpp index 8b042a12411..1d639dbbc07 100644 --- a/Opcodes/bformdec2.cpp +++ b/Opcodes/bformdec2.cpp @@ -2153,7 +2153,7 @@ static void process_nfc(CSOUND *csound, HOAMBDEC* p, int signal_order, int n, in #define S(x) sizeof(x) extern "C" { static OENTRY bformdec2_localops[] = { - { (char*) "bformdec2.A", S(HOAMBDEC), 0, 3, (char*) "a[]", (char*) "ia[]ooooNN", + { (char*) "bformdec2.A", S(HOAMBDEC), 0, (char*) "a[]", (char*) "ia[]ooooNN", (SUBR)ihoambdec, (SUBR)ahoambdec }, }; diff --git a/Opcodes/bilbar.c b/Opcodes/bilbar.c index caafe20727b..4c272903905 100644 --- a/Opcodes/bilbar.c +++ b/Opcodes/bilbar.c @@ -577,9 +577,9 @@ int32_t play_pp(CSOUND *csound, CSPP *p) #define S(x) sizeof(x) static OENTRY bilbar_localops[] = { - { "barmodel", S(BAR), 0, 3, "a", "kkiikiiii", (SUBR) bar_init, + { "barmodel", S(BAR), 0, "a", "kkiikiiii", (SUBR) bar_init, (SUBR) bar_run}, - { "prepiano", S(CSPP), 0, 3, "mm", "iiiiiikkiiiiiiioo", + { "prepiano", S(CSPP), 0, "mm", "iiiiiikkiiiiiiioo", (SUBR)init_pp, (SUBR)play_pp }, }; diff --git a/Opcodes/biquad.c b/Opcodes/biquad.c index 9ef7290e654..e048d145fc1 100644 --- a/Opcodes/biquad.c +++ b/Opcodes/biquad.c @@ -1720,32 +1720,32 @@ static int32_t vco(CSOUND *csound, VCO *p) #define S(x) sizeof(x) - static OENTRY localops[] = { - { "biquad", S(BIQUAD), 0, 3, "a", "akkkkkko", - (SUBR)biquadset, (SUBR)biquad }, - { "biquada", S(BIQUAD), 0, 3, "a", "aaaaaaao", - (SUBR)biquadset, (SUBR)biquada }, - { "moogvcf", S(MOOGVCF), 0, 3, "a", "axxpo", - (SUBR)moogvcfset, (SUBR)moogvcf }, - { "moogvcf2", S(MOOGVCF),0, 3, "a", "axxoo", - (SUBR)moogvcfset, (SUBR)moogvcf }, - { "rezzy", S(REZZY), 0, 3, "a", "axxoo", (SUBR)rezzyset, (SUBR)rezzy }, - { "bqrez", S(REZZY), 0, 3, "a", "axxoo", (SUBR)bqrezset, (SUBR)bqrez }, - { "distort1", S(DISTORT),TR, 2, "a", "akkkko", NULL, (SUBR)distort }, - { "vco", S(VCO), TR, 3, "a", "xxiVppovoo",(SUBR)vcoset, (SUBR)vco }, - { "tbvcf", S(TBVCF), 0, 3, "a", "axxkkp", - (SUBR)tbvcfset, (SUBR)tbvcf }, - { "planet", S(PLANET),0, 3,"aaa","kkkiiiiiiioo", - (SUBR)planetset, (SUBR)planet}, - { "pareq", S(PAREQ), 0, 3, "a", "akkkoo",(SUBR)pareqset, (SUBR)pareq }, - { "nestedap", S(NESTEDAP),0, 3,"a", "aiiiiooooo", - (SUBR)nestedapset, (SUBR)nestedap}, - { "lorenz", S(LORENZ),0, 3, "aaa", "kkkkiiiio", - (SUBR)lorenzset, (SUBR)lorenz}, - { "mode", S(MODE), 0, 3, "a", "axxo", (SUBR)modeset, (SUBR)mode }, - { "mvmfilter", S(MVMFILT), 0, 3, "a", "axxo", - (SUBR) mvmfilterset, (SUBR) mvmfilter }, - }; +static OENTRY localops[] = { + { "biquad", S(BIQUAD), 0, "a", "akkkkkko", + (SUBR)biquadset, (SUBR)biquad }, +{ "biquada", S(BIQUAD), 0, "a", "aaaaaaao", + (SUBR)biquadset, (SUBR)biquada }, +{ "moogvcf", S(MOOGVCF), 0, "a", "axxpo", + (SUBR)moogvcfset, (SUBR)moogvcf }, +{ "moogvcf2", S(MOOGVCF),0, "a", "axxoo", + (SUBR)moogvcfset, (SUBR)moogvcf }, +{ "rezzy", S(REZZY), 0, "a", "axxoo", (SUBR)rezzyset, (SUBR)rezzy }, +{ "bqrez", S(REZZY), 0, "a", "axxoo", (SUBR)bqrezset, (SUBR)bqrez }, +{ "distort1", S(DISTORT),TR, "a", "akkkko", NULL, (SUBR)distort }, +{ "vco", S(VCO), TR, "a", "xxiVppovoo",(SUBR)vcoset, (SUBR)vco }, +{ "tbvcf", S(TBVCF), 0, "a", "axxkkp", + (SUBR)tbvcfset, (SUBR)tbvcf }, +{ "planet", S(PLANET),0,"aaa","kkkiiiiiiioo", + (SUBR)planetset, (SUBR)planet}, +{ "pareq", S(PAREQ), 0, "a", "akkkoo",(SUBR)pareqset, (SUBR)pareq }, +{ "nestedap", S(NESTEDAP),0,"a", "aiiiiooooo", + (SUBR)nestedapset, (SUBR)nestedap}, +{ "lorenz", S(LORENZ),0, "aaa", "kkkkiiiio", + (SUBR)lorenzset, (SUBR)lorenz}, +{ "mode", S(MODE), 0, "a", "axxo", (SUBR)modeset, (SUBR)mode }, +{ "mvmfilter", S(MVMFILT), 0, "a", "axxo", + (SUBR) mvmfilterset, (SUBR) mvmfilter }, +}; int32_t biquad_init_(CSOUND *csound) { diff --git a/Opcodes/buchla.c b/Opcodes/buchla.c index 9751437fe31..ef84c7bd8b6 100644 --- a/Opcodes/buchla.c +++ b/Opcodes/buchla.c @@ -325,10 +325,10 @@ static double kontrolconvert(CSOUND *csound, double in1, double in2) static OENTRY buchla_localops[] = { #ifdef JPFF - { "buchla", S(BUCHLA), 0, 3, "a", "aakkaPP", + { "buchla", S(BUCHLA), 0, "a", "aakkaPP", (SUBR)poly_LPG_init, (SUBR)poly_LPG_perf }, #endif - { "vactrol", S(VACTROL), 0, 3, "a", "ajj", + { "vactrol", S(VACTROL), 0, "a", "ajj", (SUBR)vactrol_init, (SUBR)vactrol_perf } }; diff --git a/Opcodes/butter.c b/Opcodes/butter.c index ff9e464ee93..f13bea8144c 100644 --- a/Opcodes/butter.c +++ b/Opcodes/butter.c @@ -151,10 +151,10 @@ static void butter_filter(uint32_t n, uint32_t offset, #define S(x) sizeof(x) static OENTRY localops[] = { -{ "butterhp.k", S(BFIL), 0, 3, "a", "ako", (SUBR)butset, (SUBR)hibut }, -{ "butterlp.k", S(BFIL), 0, 3, "a", "ako", (SUBR)butset, (SUBR)lobut }, -{ "buthp.k", S(BFIL), 0, 3, "a", "ako", (SUBR)butset, (SUBR)hibut }, -{ "butlp.k", S(BFIL), 0, 3, "a", "ako", (SUBR)butset, (SUBR)lobut }, +{ "butterhp.k", S(BFIL), 0, "a", "ako", (SUBR)butset, (SUBR)hibut }, +{ "butterlp.k", S(BFIL), 0, "a", "ako", (SUBR)butset, (SUBR)lobut }, +{ "buthp.k", S(BFIL), 0, "a", "ako", (SUBR)butset, (SUBR)hibut }, +{ "butlp.k", S(BFIL), 0, "a", "ako", (SUBR)butset, (SUBR)lobut }, }; int32_t butter_init_(CSOUND *csound) diff --git a/Opcodes/cellular.c b/Opcodes/cellular.c index 36e1369f3a0..8dfbc650f9f 100644 --- a/Opcodes/cellular.c +++ b/Opcodes/cellular.c @@ -128,7 +128,7 @@ static int32_t cell(CSOUND *csound,CELL *p) #define S sizeof static OENTRY cell_localops[] = { - {"cell", S(CELL), TB, 3, "", "kkiiii",(SUBR)cell_set, (SUBR)cell } + {"cell", S(CELL), TB, "", "kkiiii",(SUBR)cell_set, (SUBR)cell } }; LINKAGE_BUILTIN(cell_localops) diff --git a/Opcodes/clfilt.c b/Opcodes/clfilt.c index a6fe6a5dfa4..c69d8f878fb 100644 --- a/Opcodes/clfilt.c +++ b/Opcodes/clfilt.c @@ -424,7 +424,7 @@ static int32_t clfilt(CSOUND *csound, CLFILT *p) #define S sizeof static OENTRY localops[] = { -{ "clfilt", S(CLFILT), 0, 3, "a", "akiioppo",(SUBR)clfiltset, (SUBR)clfilt }, +{ "clfilt", S(CLFILT), 0, "a", "akiioppo",(SUBR)clfiltset, (SUBR)clfilt }, }; int32_t clfilt_init_(CSOUND *csound) diff --git a/Opcodes/compress.c b/Opcodes/compress.c index 1260d83614f..155d48ae72c 100644 --- a/Opcodes/compress.c +++ b/Opcodes/compress.c @@ -285,9 +285,9 @@ static int32_t distort(CSOUND *csound, DIST *p) #define S(x) sizeof(x) static OENTRY compress_localops[] = { - { "compress", S(CMPRS), 0, 3, "a", "aakkkkkki", (SUBR) compset, (SUBR) compress }, - { "compress2", S(CMPRS), 0, 3, "a", "aakkkkkki", (SUBR)comp2set,(SUBR) compress }, - { "distort", S(DIST), TR, 3, "a", "akiqo", (SUBR) distset, (SUBR) distort }, + { "compress", S(CMPRS), 0, "a", "aakkkkkki", (SUBR) compset, (SUBR) compress }, + { "compress2", S(CMPRS), 0, "a", "aakkkkkki", (SUBR)comp2set,(SUBR) compress }, + { "distort", S(DIST), TR, "a", "akiqo", (SUBR) distset, (SUBR) distort }, }; LINKAGE_BUILTIN(compress_localops) diff --git a/Opcodes/control.c b/Opcodes/control.c index 9692fbe37fe..1c9715379f6 100644 --- a/Opcodes/control.c +++ b/Opcodes/control.c @@ -330,13 +330,13 @@ textflash_S(CSOUND *csound, TXTWIN *p){ #define S(x) sizeof(x) static OENTRY control_localops[] = { - { "control", S(CNTRL), 0, 3, "k", "k", (SUBR) cntrl_set, (SUBR) control, NULL }, -{ "setctrl", S(SCNTRL), 0, 1, "", "iii", (SUBR) ocontrol, NULL, NULL }, -{ "setctrl.S", S(SCNTRL), 0, 1, "", "iSi", (SUBR) ocontrol_S, NULL, NULL }, -{ "button", S(CNTRL), 0, 3, "k", "k", (SUBR) button_set, (SUBR) button, NULL }, -{ "checkbox", S(CNTRL), 0, 3, "k", "k", (SUBR) check_set, (SUBR) check, NULL }, -{ "flashtxt", S(TXTWIN), 0, 1, "", "ii", (SUBR) textflash, NULL, NULL }, -{ "flashtxt.S", S(TXTWIN), 0, 1, "", "iS", (SUBR) textflash_S, NULL, NULL }, + { "control", S(CNTRL), 0, "k", "k", (SUBR) cntrl_set, (SUBR) control, NULL }, +{ "setctrl", S(SCNTRL), 0, "", "iii", (SUBR) ocontrol, NULL, NULL }, +{ "setctrl.S", S(SCNTRL), 0, "", "iSi", (SUBR) ocontrol_S, NULL, NULL }, +{ "button", S(CNTRL), 0, "k", "k", (SUBR) button_set, (SUBR) button, NULL }, +{ "checkbox", S(CNTRL), 0, "k", "k", (SUBR) check_set, (SUBR) check, NULL }, +{ "flashtxt", S(TXTWIN), 0, "", "ii", (SUBR) textflash, NULL, NULL }, +{ "flashtxt.S", S(TXTWIN), 0, "", "iS", (SUBR) textflash_S, NULL, NULL }, }; LINKAGE_BUILTIN(control_localops) diff --git a/Opcodes/counter.c b/Opcodes/counter.c index d93ea2a1ce2..8c975cb5c57 100644 --- a/Opcodes/counter.c +++ b/Opcodes/counter.c @@ -290,15 +290,15 @@ static int32_t count_del(CSOUND *csound, void p) #define S(x) sizeof(x) static OENTRY counter_localops[] = { - { "cntCreate", S(CNTSET), 0, 1, "i", "pop", (SUBR)setcnt, NULL, NULL }, - { "count", S(COUNTER), SK, 3, "k", "o", (SUBR)count_init, (SUBR)count_perf }, - { "count_i", S(COUNTER), SK, 1, "i", "o", (SUBR)count_init_perf, NULL }, - { "cntCycles", S(COUNTER), SK, 3, "k", "o", (SUBR)count_init, (SUBR)count_cycles }, - { "cntRead", S(COUNTER), SK, 3, "k", "o", (SUBR)count_init, (SUBR)count_read }, - { "cntReset", S(COUNTER), SK, 3, "", "o", (SUBR)count_init0, (SUBR)count_reset }, - { "cntState", S(CNTSTATE), SK, 3, "kkk", "o", (SUBR)count_init3, (SUBR)count_state }, - { "cntDelete", S(COUNTER), SK, 2, "k", "k", NULL, (SUBR)count_del, NULL }, - { "cntDelete_i", S(COUNTER), SK, 1, "i", "i", (SUBR)count_del, NULL, NULL }, + { "cntCreate", S(CNTSET), 0, "i", "pop", (SUBR)setcnt, NULL, NULL }, + { "count", S(COUNTER), SK, "k", "o", (SUBR)count_init, (SUBR)count_perf }, + { "count_i", S(COUNTER), SK, "i", "o", (SUBR)count_init_perf, NULL }, + { "cntCycles", S(COUNTER), SK, "k", "o", (SUBR)count_init, (SUBR)count_cycles }, + { "cntRead", S(COUNTER), SK, "k", "o", (SUBR)count_init, (SUBR)count_read }, + { "cntReset", S(COUNTER), SK, "", "o", (SUBR)count_init0, (SUBR)count_reset }, + { "cntState", S(CNTSTATE), SK, "kkk", "o", (SUBR)count_init3, (SUBR)count_state }, + { "cntDelete", S(COUNTER), SK, "k", "k", NULL, (SUBR)count_del, NULL }, + { "cntDelete_i", S(COUNTER), SK, "i", "i", (SUBR)count_del, NULL, NULL }, }; LINKAGE_BUILTIN(counter_localops) diff --git a/Opcodes/cpumeter.c b/Opcodes/cpumeter.c index 287e5741d83..705583c8b72 100644 --- a/Opcodes/cpumeter.c +++ b/Opcodes/cpumeter.c @@ -72,7 +72,7 @@ typedef struct { * cpus[0] thru cpus[n] == tics for each separate cpu * cpus[Cpu_tot] == tics from the 1st /proc/stat line */ -static int32_t deinit_cpupercent(CSOUND *csound, void *pdata) +int32_t deinit_cpupercent(CSOUND *csound, void *pdata) { CPUMETER *p = (CPUMETER *) pdata; fclose(p->fp); @@ -106,9 +106,6 @@ int32_t cpupercent_init(CSOUND *csound, CPUMETER* p) p->cpus = (CPU_t *) p->cpu_a.auxp; k = cpupercent_renew(csound, p); p->cnt = (p->trig = (int32_t)(*p->itrig * CS_ESR)); - // Would it be better to add a deinit process so the closing happens in perf? - //csound->CreateFileHandle(csound, &p->fp, CSFILE_STD, "/proc/stat"); - csound->RegisterDeinitCallback(csound, (void *) p, deinit_cpupercent); return k; } @@ -229,6 +226,14 @@ typedef struct { } CPUMETER; +int32_t deinit_cpupercent(CSOUND *csound, void *p) +{ + IGN(p); + csound->Message(csound, "not implemented\n"); + return OK; +} + + int32_t cpupercent_init(CSOUND *csound, CPUMETER *p) { IGN(p); csound->Message(csound, "not implemented\n"); @@ -264,10 +269,10 @@ systime(CSOUND *csound, SYST *p){ #define S(x) sizeof(x) static OENTRY cpumeter_localops[] = { - { "cpumeter", S(CPUMETER), 0,3, "kzzzzzzzz", "i", - (SUBR)cpupercent_init, (SUBR)cpupercent }, -{ "systime", S(SYST),0, 3, "k", "", (SUBR)systime, (SUBR)systime}, -{ "systime", S(SYST),0, 1, "i", "", (SUBR)systime} + { "cpumeter", S(CPUMETER), 0, "kzzzzzzzz", "i", + (SUBR)cpupercent_init, (SUBR)cpupercent, (SUBR) deinit_cpupercent }, +{ "systime", S(SYST),0, "k", "", (SUBR)systime, (SUBR)systime}, +{ "systime", S(SYST),0, "i", "", (SUBR)systime} }; LINKAGE_BUILTIN(cpumeter_localops) diff --git a/Opcodes/cross2.c b/Opcodes/cross2.c index 3cac5a5549d..554275f4909 100644 --- a/Opcodes/cross2.c +++ b/Opcodes/cross2.c @@ -441,7 +441,7 @@ static int32_t Xsynth(CSOUND *csound, CON *p) #define S(x) sizeof(x) static OENTRY localops[] = { - { "cross2", S(CON), TR, 3, "a", "aaiiik",(SUBR)Xsynthset, (SUBR)Xsynth} + { "cross2", S(CON), TR, "a", "aaiiik",(SUBR)Xsynthset, (SUBR)Xsynth} }; int32_t cross2_init_(CSOUND *csound) diff --git a/Opcodes/crossfm.c b/Opcodes/crossfm.c index 5f44b8de17d..71dcb1e7edc 100644 --- a/Opcodes/crossfm.c +++ b/Opcodes/crossfm.c @@ -495,12 +495,12 @@ int32_t xfmpmi(CSOUND *csound, CROSSFM *p) #define S sizeof static OENTRY crossfm_localops[] = { - { "crossfm", S(CROSSFM), TR, 3, "aa", "xxxxkiioo", (SUBR)xfmset, (SUBR)xfm }, - { "crossfmi", S(CROSSFM), TR, 3, "aa", "xxxxkiioo",(SUBR)xfmset, (SUBR)xfmi }, - { "crosspm", S(CROSSFM), TR, 3, "aa", "xxxxkiioo", (SUBR)xfmset, (SUBR)xpm }, - { "crosspmi", S(CROSSFM), TR, 3, "aa", "xxxxkiioo",(SUBR)xfmset, (SUBR)xpmi }, - { "crossfmpm", S(CROSSFM), TR, 3, "aa", "xxxxkiioo",(SUBR)xfmset,(SUBR)xfmpm}, - { "crossfmpmi", S(CROSSFM),TR, 3, "aa", "xxxxkiioo",(SUBR)xfmset, (SUBR)xfmpmi }, + { "crossfm", S(CROSSFM), TR, "aa", "xxxxkiioo", (SUBR)xfmset, (SUBR)xfm }, + { "crossfmi", S(CROSSFM), TR, "aa", "xxxxkiioo",(SUBR)xfmset, (SUBR)xfmi }, + { "crosspm", S(CROSSFM), TR, "aa", "xxxxkiioo", (SUBR)xfmset, (SUBR)xpm }, + { "crosspmi", S(CROSSFM), TR, "aa", "xxxxkiioo",(SUBR)xfmset, (SUBR)xpmi }, + { "crossfmpm", S(CROSSFM), TR, "aa", "xxxxkiioo",(SUBR)xfmset,(SUBR)xfmpm}, + { "crossfmpmi", S(CROSSFM),TR, "aa", "xxxxkiioo",(SUBR)xfmset, (SUBR)xfmpmi }, }; LINKAGE_BUILTIN(crossfm_localops) diff --git a/Opcodes/dam.c b/Opcodes/dam.c index 65f6b8a4e66..6dc62d6aad1 100644 --- a/Opcodes/dam.c +++ b/Opcodes/dam.c @@ -153,7 +153,7 @@ static int32_t dam(CSOUND *csound, DAM *p) #define S(x) sizeof(x) static OENTRY localops[] = { -{ "dam", S(DAM), 0, 3, "a", "akiiii",(SUBR)daminit, (SUBR)dam }, +{ "dam", S(DAM), 0, "a", "akiiii",(SUBR)daminit, (SUBR)dam }, }; int32_t dam_init_(CSOUND *csound) diff --git a/Opcodes/date.c b/Opcodes/date.c index cea945c1a27..d2ded290c42 100644 --- a/Opcodes/date.c +++ b/Opcodes/date.c @@ -183,7 +183,7 @@ static int32_t readf_init_(CSOUND *csound, READF *p, int32_t isstring) } if (UNLIKELY(p->fd==NULL)) return csound->InitError(csound, "%s", Str("readf: failed to open file")); - return csound->RegisterDeinitCallback(csound, p, readf_delete); + return OK; } static int32_t readf_init(CSOUND *csound, READF *p){ @@ -234,17 +234,17 @@ static int32_t readfi_S(CSOUND *csound, READF *p) static OENTRY date_localops[] = { - { "date.i", sizeof(DATEMYFLT), 0, 1, "iI", "", (SUBR)datemyfltset }, - { "date.k", sizeof(DATEMYFLT), 0, 3, "kz", "", (SUBR)datemyfltset, + { "date.i", sizeof(DATEMYFLT), 0, "iI", "", (SUBR)datemyfltset }, + { "date.k", sizeof(DATEMYFLT), 0, "kz", "", (SUBR)datemyfltset, (SUBR)datemyfltset }, - { "dates", sizeof(DATESTRING), 0, 1, "S", "j", (SUBR)datestringset }, - { "pwd", sizeof(GETCWD), 0, 1, "S", "", (SUBR)getcurdir }, - { "readfi", sizeof(READF), 0, 1, "Si", "i", (SUBR)readfi, }, - { "readfi.S", sizeof(READF), 0, 1, "Si", "S", (SUBR)readfi_S, }, - { "readf", sizeof(READF), 0, 3, "Sk", "i", (SUBR)readf_init, - (SUBR)readf }, - { "readf.S", sizeof(READF), 0, 3, "Sk", "S", (SUBR)readf_init_S, - (SUBR)readf } + { "dates", sizeof(DATESTRING), 0, "S", "j", (SUBR)datestringset }, + { "pwd", sizeof(GETCWD), 0, "S", "", (SUBR)getcurdir }, + { "readfi", sizeof(READF), 0, "Si", "i", (SUBR)readfi, }, + { "readfi.S", sizeof(READF), 0, "Si", "S", (SUBR)readfi_S, }, + { "readf", sizeof(READF), 0, "Sk", "i", (SUBR)readf_init, + (SUBR)readf, (SUBR)readf_delete }, + { "readf.S", sizeof(READF), 0, "Sk", "S", (SUBR)readf_init_S, + (SUBR)readf, (SUBR)readf_delete } }; diff --git a/Opcodes/dcblockr.c b/Opcodes/dcblockr.c index c51880fc284..ccb6b515337 100644 --- a/Opcodes/dcblockr.c +++ b/Opcodes/dcblockr.c @@ -196,9 +196,9 @@ static int32_t dcblock2(CSOUND *csound, DCBlock2* p) #define S(x) sizeof(x) static OENTRY localops[] = { - { "dcblock", S(DCBlocker), 0, 3, "a", "ao", + { "dcblock", S(DCBlocker), 0, "a", "ao", (SUBR)dcblockrset, (SUBR)dcblockr}, - { "dcblock2", S(DCBlock2), 0, 3, "a", "aoo", + { "dcblock2", S(DCBlock2), 0, "a", "aoo", (SUBR)dcblock2set, (SUBR)dcblock2} }; diff --git a/Opcodes/deprecated.c b/Opcodes/deprecated.c index 57fbc3c1e98..5bc5a6d1b5a 100644 --- a/Opcodes/deprecated.c +++ b/Opcodes/deprecated.c @@ -356,7 +356,7 @@ static int32_t push_opcode_init(CSOUND *csound, PUSH_OPCODE *p) p->pp = csoundStack_GetGlobals(csound); if (UNLIKELY(csoundStack_CreateArgMap(p, (int32_t*)&(p->argMap[0]), 0) != OK)) return NOTOK; - p->h.opadr = (int32_t (*)(CSOUND *, void *)) push_opcode_perf; + p->h.perf = (int32_t (*)(CSOUND *, void *)) push_opcode_perf; p->initDone = 1; } if (p->argMap[1] != 0) { @@ -461,7 +461,7 @@ static int32_t pop_opcode_init(CSOUND *csound, POP_OPCODE *p) if (UNLIKELY(csoundStack_CreateArgMap((PUSH_OPCODE*)p, &(p->argMap[0]), 1) != OK)) return NOTOK; - p->h.opadr = (int32_t (*)(CSOUND *, void *)) pop_opcode_perf; + p->h.perf = (int32_t (*)(CSOUND *, void *)) pop_opcode_perf; p->initDone = 1; } if (p->argMap[1] != 0) { @@ -565,7 +565,7 @@ static int32_t push_f_opcode_init(CSOUND *csound, PUSH_OPCODE *p) offs = csoundStack_Align(offs); p->argMap[1] = offs; p->argMap[2] = offs; - p->h.opadr = (int32_t (*)(CSOUND *, void *)) push_f_opcode_perf; + p->h.perf = (int32_t (*)(CSOUND *, void *)) push_f_opcode_perf; p->initDone = 1; } if (UNLIKELY(p->pp->freeSpaceOffset + p->argMap[1] > p->pp->freeSpaceEndOffset)) @@ -634,7 +634,7 @@ static int32_t pop_f_opcode_init(CSOUND *csound, POP_OPCODE *p) offs = csoundStack_Align(offs); p->argMap[1] = offs; p->argMap[2] = offs; - p->h.opadr = (int32_t (*)(CSOUND *, void *)) pop_f_opcode_perf; + p->h.perf = (int32_t (*)(CSOUND *, void *)) pop_f_opcode_perf; p->initDone = 1; } if (UNLIKELY(p->pp->curBundle == NULL)) @@ -662,16 +662,16 @@ static int32_t pop_f_opcode_init(CSOUND *csound, POP_OPCODE *p) /* ------------------------------------------------------------------------ */ static OENTRY localops[] = { - { "stack", sizeof(STACK_OPCODE), SK|_QQ, 1, "", "i", + { "stack", sizeof(STACK_OPCODE), SK|_QQ, "", "i", (SUBR) stack_opcode_init, (SUBR) NULL, (SUBR) NULL }, - { "push", sizeof(PUSH_OPCODE), SK|_QQ, 3, "", "N", + { "push", sizeof(PUSH_OPCODE), SK|_QQ, "", "N", (SUBR) push_opcode_init, (SUBR) notinit_opcode_stub_perf, (SUBR) NULL }, - { "pop", sizeof(POP_OPCODE), SK|_QQ, 3, + { "pop", sizeof(POP_OPCODE), SK|_QQ, "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "", (SUBR) pop_opcode_init, (SUBR) notinit_opcode_stub_perf, (SUBR) NULL }, - { "push_f", sizeof(PUSH_OPCODE), SK|_QQ, 3, "", "f", + { "push_f", sizeof(PUSH_OPCODE), SK|_QQ, "", "f", (SUBR) push_f_opcode_init, (SUBR) notinit_opcode_stub_perf, (SUBR) NULL }, - { "pop_f", sizeof(POP_OPCODE), SK|_QQ, 3, "f", "", + { "pop_f", sizeof(POP_OPCODE), SK|_QQ, "f", "", (SUBR) pop_f_opcode_init, (SUBR) notinit_opcode_stub_perf, (SUBR) NULL } }; diff --git a/Opcodes/doppler.cpp b/Opcodes/doppler.cpp index 17c7873f7ee..7caed2c8f4c 100644 --- a/Opcodes/doppler.cpp +++ b/Opcodes/doppler.cpp @@ -260,23 +260,23 @@ class Doppler : public OpcodeNoteoffBase { extern "C" { OENTRY oentries[] = {{ - (char *)"doppler", sizeof(Doppler), 0, 3, (char *)"a", + (char *)"doppler", sizeof(Doppler), 0, (char *)"a", (char *)"akkjj", (SUBR)Doppler::init_, (SUBR)Doppler::kontrol_, }, { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, }}; PUBLIC int32_t csoundModuleInit_doppler(CSOUND *csound) { int32_t status = 0; for (OENTRY *oentry = &oentries[0]; oentry->opname; oentry++) { status |= csound->AppendOpcode(csound, oentry->opname, oentry->dsblksiz, - oentry->flags, oentry->thread, + oentry->flags, oentry->outypes, oentry->intypes, - (int32_t (*)(CSOUND *, void *))oentry->iopadr, - (int32_t (*)(CSOUND *, void *))oentry->kopadr, - (int32_t (*)(CSOUND *, void *))oentry->aopadr); + (int32_t (*)(CSOUND *, void *))oentry->init, + (int32_t (*)(CSOUND *, void *))oentry->perf, + (int32_t (*)(CSOUND *, void *))oentry->deinit); } return status; } diff --git a/Opcodes/dssi4cs/src/dssi4cs.c b/Opcodes/dssi4cs/src/dssi4cs.c index 9c4931cc18e..71c7eca5e8e 100644 --- a/Opcodes/dssi4cs/src/dssi4cs.c +++ b/Opcodes/dssi4cs/src/dssi4cs.c @@ -918,16 +918,8 @@ int32_t dssictls_init(CSOUND * csound, DSSICTLS * p) #ifdef DEBUG csound->Message(csound, "DSSI4CS: Port %lu using internal port %lu.\n", PortIndex, p->PortNumber); - /*csound->Message(csound, "DSSI4CS: ArgMask: %lu.\n",*/ - /* csound->GetInputArgAMask(p));*/ -#endif -// if ((int) csound->GetInputArgAMask(p) & 4) { -// p->h.opadr = (SUBR) dssictls_ak; /* "iiak" */ -// } -// else { -// p->h.opadr = (SUBR) dssictls_kk; /* "iikk" */ -// } +#endif return OK; } @@ -1199,23 +1191,23 @@ int32_t dssilist(CSOUND * csound, DSSILIST * p) } static OENTRY dssi_localops[] = { - {"dssiinit", sizeof(DSSIINIT), 0, 1, "i", "Tip", (SUBR) dssiinit, NULL, NULL }, - {"dssiactivate", sizeof(DSSIACTIVATE), 0, 3, "", "ik", + {"dssiinit", sizeof(DSSIINIT), 0, "i", "Tip", (SUBR) dssiinit, NULL, NULL }, + {"dssiactivate", sizeof(DSSIACTIVATE), 0, "", "ik", (SUBR) dssiactivate_init, (SUBR) dssiactivate, NULL }, - {"dssiaudio", sizeof(DSSIAUDIO), 0, 3, "mmmmmmmmm", "iMMMMMMMMM", + {"dssiaudio", sizeof(DSSIAUDIO), 0, "mmmmmmmmm", "iMMMMMMMMM", (SUBR) dssiaudio_init, (SUBR) dssiaudio }, - {"dssictls", sizeof(DSSICTLS), 0, 3, "", "iikk", (SUBR) dssictls_init, + {"dssictls", sizeof(DSSICTLS), 0, "", "iikk", (SUBR) dssictls_init, (SUBR) dssictls_kk, NULL }, - {"dssilist", sizeof(DSSILIST), 0, 1, "", "", (SUBR) dssilist, NULL, NULL } + {"dssilist", sizeof(DSSILIST), 0, "", "", (SUBR) dssilist, NULL, NULL } #if 0 , - {"dssisynth", sizeof(DSSISYNTH), 0, 3, "aa", "i", (SUBR) dssisynth_init, + {"dssisynth", sizeof(DSSISYNTH), 0, "aa", "i", (SUBR) dssisynth_init, (SUBR) dssisynth} , - {"dssinote", sizeof(DSSINOTE), 0, 3, "", "kikkk", (SUBR) dssinote_init, + {"dssinote", sizeof(DSSINOTE), 0, "", "kikkk", (SUBR) dssinote_init, (SUBR) dssinote} , - {"dssievent", sizeof(DSSINOTEON), 0, 3, "", "kikk", (SUBR) dssievent_init, + {"dssievent", sizeof(DSSINOTEON), 0, "", "kikk", (SUBR) dssievent_init, (SUBR) dssievent} #endif }; diff --git a/Opcodes/emugens/emugens.c b/Opcodes/emugens/emugens.c index 0fd2af51ac1..e9fd44faf75 100644 --- a/Opcodes/emugens/emugens.c +++ b/Opcodes/emugens/emugens.c @@ -2990,165 +2990,165 @@ int32_t printsk_perf(CSOUND *csound, PRINTLN *p) { #define S(x) sizeof(x) static OENTRY emugens_localops[] = { - { "linlin", S(LINLIN1), 0, 2, "k", "kkkkk", NULL, (SUBR)linlin1_perf }, - { "linlin", S(LINLIN1), 0, 2, "k", "kkkop", NULL, (SUBR)linlin1_perf }, - { "linlin", S(LINLIN1), 0, 1, "i", "iiiop", (SUBR)linlin1_perf}, - { "linlin", S(LINLINARR1), 0, 3, "k[]", "k[]kkOP", (SUBR)linlinarr1_init, + { "linlin", S(LINLIN1), 0, "k", "kkkkk", NULL, (SUBR)linlin1_perf }, + { "linlin", S(LINLIN1), 0, "k", "kkkop", NULL, (SUBR)linlin1_perf }, + { "linlin", S(LINLIN1), 0, "i", "iiiop", (SUBR)linlin1_perf}, + { "linlin", S(LINLINARR1), 0, "k[]", "k[]kkOP", (SUBR)linlinarr1_init, (SUBR)linlinarr1_perf}, - { "linlin", S(LINLINARR1), 0, 1, "i[]", "i[]iiop", (SUBR)linlinarr1_i}, - { "linlin", S(BLENDARRAY), 0, 3, "k[]", "kk[]k[]OP", + { "linlin", S(LINLINARR1), 0, "i[]", "i[]iiop", (SUBR)linlinarr1_i}, + { "linlin", S(BLENDARRAY), 0, "k[]", "kk[]k[]OP", (SUBR)blendarray_init, (SUBR)blendarray_perf}, - { "linlin", S(BLENDARRAY), 0, 1, "i[]", "ii[]i[]op", (SUBR)blendarray_i}, - { "lincos", S(LINLIN1), 0, 2, "k", "kkkOP", NULL, (SUBR)lincos_perf }, - { "lincos", S(LINLIN1), 0, 1, "i", "iiiop", (SUBR)lincos_perf }, + { "linlin", S(BLENDARRAY), 0, "i[]", "ii[]i[]op", (SUBR)blendarray_i}, + { "lincos", S(LINLIN1), 0, "k", "kkkOP", NULL, (SUBR)lincos_perf }, + { "lincos", S(LINLIN1), 0, "i", "iiiop", (SUBR)lincos_perf }, - { "xyscale", S(XYSCALE), 0, 2, "k", "kkkkkk", NULL, (SUBR)xyscale }, - { "xyscale", S(XYSCALE), 0, 3, "k", "kkiiii", (SUBR)xyscalei_init, + { "xyscale", S(XYSCALE), 0, "k", "kkkkkk", NULL, (SUBR)xyscale }, + { "xyscale", S(XYSCALE), 0, "k", "kkiiii", (SUBR)xyscalei_init, (SUBR)xyscalei }, - { "mtof", S(PITCHCONV), 0, 3, "k", "k", (SUBR)mtof_init, (SUBR)mtof }, - { "mtof", S(PITCHCONV), 0, 1, "i", "i", (SUBR)mtof_init }, - { "mtof", S(PITCHCONV_ARR), 0, 3, "k[]", "k[]", + { "mtof", S(PITCHCONV), 0, "k", "k", (SUBR)mtof_init, (SUBR)mtof }, + { "mtof", S(PITCHCONV), 0, "i", "i", (SUBR)mtof_init }, + { "mtof", S(PITCHCONV_ARR), 0, "k[]", "k[]", (SUBR)mtof_arr_init, (SUBR)mtof_arr }, - { "mtof", S(PITCHCONV_ARR), 0, 1, "i[]", "i[]", (SUBR)mtof_arr_init }, + { "mtof", S(PITCHCONV_ARR), 0, "i[]", "i[]", (SUBR)mtof_arr_init }, - { "ftom", S(PITCHCONV), 0, 3, "k", "ko", (SUBR)ftom_init, (SUBR)ftom}, - { "ftom", S(PITCHCONV), 0, 1, "i", "io", (SUBR)ftom_init}, - { "ftom", S(PITCHCONV_ARR), 0, 3, "k[]", "k[]o", + { "ftom", S(PITCHCONV), 0, "k", "ko", (SUBR)ftom_init, (SUBR)ftom}, + { "ftom", S(PITCHCONV), 0, "i", "io", (SUBR)ftom_init}, + { "ftom", S(PITCHCONV_ARR), 0, "k[]", "k[]o", (SUBR)ftom_arr_init, (SUBR)ftom_arr}, - { "ftom", S(PITCHCONV_ARR), 0, 1, "i[]", "i[]o", + { "ftom", S(PITCHCONV_ARR), 0, "i[]", "i[]o", (SUBR)ftom_arr_init, (SUBR)ftom_arr}, - { "pchtom", S(PITCHCONV), 0, 1, "i", "i", (SUBR)pchtom }, - { "pchtom", S(PITCHCONV), 0, 2, "k", "k", NULL, (SUBR)pchtom }, + { "pchtom", S(PITCHCONV), 0, "i", "i", (SUBR)pchtom }, + { "pchtom", S(PITCHCONV), 0, "k", "k", NULL, (SUBR)pchtom }, - { "bpf.k_kM", S(BPFX), 0, 3, "k", "kM", (SUBR)bpfx_init, (SUBR)bpfx_k }, - { "bpfcos.k_kM", S(BPFX), 0, 3, "k", "kM", (SUBR)bpfx_init, (SUBR)bpfxcos_k }, + { "bpf.k_kM", S(BPFX), 0, "k", "kM", (SUBR)bpfx_init, (SUBR)bpfx_k }, + { "bpfcos.k_kM", S(BPFX), 0, "k", "kM", (SUBR)bpfx_init, (SUBR)bpfxcos_k }, - { "bpf.i_im", S(BPFX), 0, 1, "i", "im", (SUBR)bpfx_i }, - { "bpfcos.i_im", S(BPFX), 0, 1, "i", "im", (SUBR)bpfxcos_i }, + { "bpf.i_im", S(BPFX), 0, "i", "im", (SUBR)bpfx_i }, + { "bpfcos.i_im", S(BPFX), 0, "i", "im", (SUBR)bpfxcos_i }, - { "bpf.K_KM", S(BPF_K_Km), 0, 3, "k[]", "k[]M", (SUBR)bpf_K_Km_init, (SUBR)bpf_K_Km_kr }, - { "bpfcos.K_KM", S(BPF_K_Km), 0, 3, "k[]", "k[]M", (SUBR)bpf_K_Km_init, (SUBR)bpfcos_K_Km_kr }, + { "bpf.K_KM", S(BPF_K_Km), 0, "k[]", "k[]M", (SUBR)bpf_K_Km_init, (SUBR)bpf_K_Km_kr }, + { "bpfcos.K_KM", S(BPF_K_Km), 0, "k[]", "k[]M", (SUBR)bpf_K_Km_init, (SUBR)bpfcos_K_Km_kr }, - { "bpf.a_aM", S(BPF_a_am), 0, 3, "a", "aM", (SUBR)bpf_a_am_init, (SUBR)bpf_a_am_kr }, - { "bpfcos.a_aM", S(BPF_a_am), 0, 3, "a", "aM", (SUBR)bpf_a_am_init, (SUBR)bpfcos_a_am_kr }, + { "bpf.a_aM", S(BPF_a_am), 0, "a", "aM", (SUBR)bpf_a_am_init, (SUBR)bpf_a_am_kr }, + { "bpfcos.a_aM", S(BPF_a_am), 0, "a", "aM", (SUBR)bpf_a_am_init, (SUBR)bpfcos_a_am_kr }, - { "bpf.k_kKK", S(BPF_k_kKK), 0, 3, "k", "kk[]k[]", (SUBR)bpf_k_kKK_init, (SUBR)bpf_k_kKK_kr }, - { "bpfcos.k_kKK", S(BPF_k_kKK), 0, 3, "k", "kk[]k[]", (SUBR)bpf_k_kKK_init, (SUBR)bpfcos_k_kKK_kr }, + { "bpf.k_kKK", S(BPF_k_kKK), 0, "k", "kk[]k[]", (SUBR)bpf_k_kKK_init, (SUBR)bpf_k_kKK_kr }, + { "bpfcos.k_kKK", S(BPF_k_kKK), 0, "k", "kk[]k[]", (SUBR)bpf_k_kKK_init, (SUBR)bpfcos_k_kKK_kr }, - { "bpf.k_kII", S(BPF_k_kKK), 0, 3, "k", "ki[]i[]", (SUBR)bpf_k_kKK_init, (SUBR)bpf_k_kKK_kr }, - { "bpfcos.k_kII", S(BPF_k_kKK), 0, 3, "k", "ki[]i[]", (SUBR)bpf_k_kKK_init, (SUBR)bpfcos_k_kKK_kr }, + { "bpf.k_kII", S(BPF_k_kKK), 0, "k", "ki[]i[]", (SUBR)bpf_k_kKK_init, (SUBR)bpf_k_kKK_kr }, + { "bpfcos.k_kII", S(BPF_k_kKK), 0, "k", "ki[]i[]", (SUBR)bpf_k_kKK_init, (SUBR)bpfcos_k_kKK_kr }, - { "bpf.a_aKK", S(BPF_k_kKK), 0, 3, "a", "ak[]k[]", (SUBR)bpf_k_kKK_init, (SUBR)bpf_a_aKK_kr }, - { "bpfcos.a_aKK", S(BPF_k_kKK), 0, 3, "a", "ak[]k[]", (SUBR)bpf_k_kKK_init, (SUBR)bpfcos_a_aKK_kr }, + { "bpf.a_aKK", S(BPF_k_kKK), 0, "a", "ak[]k[]", (SUBR)bpf_k_kKK_init, (SUBR)bpf_a_aKK_kr }, + { "bpfcos.a_aKK", S(BPF_k_kKK), 0, "a", "ak[]k[]", (SUBR)bpf_k_kKK_init, (SUBR)bpfcos_a_aKK_kr }, - { "bpf.a_aII", S(BPF_k_kKK), 0, 3, "a", "ai[]i[]", (SUBR)bpf_k_kKK_init, (SUBR)bpf_a_aKK_kr }, - { "bpfcos.a_aII", S(BPF_k_kKK), 0, 3, "a", "ai[]i[]", (SUBR)bpf_k_kKK_init, (SUBR)bpfcos_a_aKK_kr }, + { "bpf.a_aII", S(BPF_k_kKK), 0, "a", "ai[]i[]", (SUBR)bpf_k_kKK_init, (SUBR)bpf_a_aKK_kr }, + { "bpfcos.a_aII", S(BPF_k_kKK), 0, "a", "ai[]i[]", (SUBR)bpf_k_kKK_init, (SUBR)bpfcos_a_aKK_kr }, - { "bpf.i_iII", S(BPF_k_kKK), 0, 1, "i", "ii[]i[]", (SUBR)bpf_k_kKK_ir }, - { "bpfcos.i_iII", S(BPF_k_kKK), 0, 1, "i", "ii[]i[]", (SUBR)bpfcos_k_kKK_ir }, + { "bpf.i_iII", S(BPF_k_kKK), 0, "i", "ii[]i[]", (SUBR)bpf_k_kKK_ir }, + { "bpfcos.i_iII", S(BPF_k_kKK), 0, "i", "ii[]i[]", (SUBR)bpfcos_k_kKK_ir }, - { "bpf.kk_kKKK", S(BPF_kk_kKKK), 0, 3, "kk", "kk[]k[]k[]", (SUBR)bpf_kk_kKKK_init, (SUBR)bpf_kk_kKKK_kr }, + { "bpf.kk_kKKK", S(BPF_kk_kKKK), 0, "kk", "kk[]k[]k[]", (SUBR)bpf_kk_kKKK_init, (SUBR)bpf_kk_kKKK_kr }, // TODO - { "bpf.kk_kIII", S(BPF_kk_kKKK), 0, 3, "kk", "ki[]i[]i[]", (SUBR)bpf_kk_kKKK_init, (SUBR)bpf_kk_kKKK_kr }, + { "bpf.kk_kIII", S(BPF_kk_kKKK), 0, "kk", "ki[]i[]i[]", (SUBR)bpf_kk_kKKK_init, (SUBR)bpf_kk_kKKK_kr }, // TODO - { "bpf.ii_iIII", S(BPF_kk_kKKK), 0, 1, "ii", "ii[]i[]i[]", (SUBR)bpf_kk_kKKK_ir }, + { "bpf.ii_iIII", S(BPF_kk_kKKK), 0, "ii", "ii[]i[]i[]", (SUBR)bpf_kk_kKKK_ir }, // TODO - { "ntom.i", S(NTOM), 0, 1, "i", "S", (SUBR)ntom }, - { "ntom.k", S(NTOM), 0, 3, "k", "S", (SUBR)ntom, (SUBR)ntom }, + { "ntom.i", S(NTOM), 0, "i", "S", (SUBR)ntom }, + { "ntom.k", S(NTOM), 0, "k", "S", (SUBR)ntom, (SUBR)ntom }, - { "mton.i", S(MTON), 0, 1, "S", "i", (SUBR)mton }, - { "mton.k", S(MTON), 0, 3, "S", "k", (SUBR)mton, (SUBR)mton }, + { "mton.i", S(MTON), 0, "S", "i", (SUBR)mton }, + { "mton.k", S(MTON), 0, "S", "k", (SUBR)mton, (SUBR)mton }, - { "ntof.i", S(NTOM), 0, 1, "i", "S", (SUBR)ntof }, - { "ntof.k", S(NTOM), 0, 3, "k", "S", (SUBR)ntof, (SUBR)ntof }, + { "ntof.i", S(NTOM), 0, "i", "S", (SUBR)ntof }, + { "ntof.k", S(NTOM), 0, "k", "S", (SUBR)ntof, (SUBR)ntof }, - { "cmp", S(Cmp), 0, 3, "a", "aSa", (SUBR)cmp_init, (SUBR)cmp_aa,}, - { "cmp", S(Cmp), 0, 3, "a", "aSk", (SUBR)cmp_init, (SUBR)cmp_ak }, - { "cmp", S(Cmp_array1), 0, 3, "k[]", "k[]Sk", + { "cmp", S(Cmp), 0, "a", "aSa", (SUBR)cmp_init, (SUBR)cmp_aa,}, + { "cmp", S(Cmp), 0, "a", "aSk", (SUBR)cmp_init, (SUBR)cmp_ak }, + { "cmp", S(Cmp_array1), 0, "k[]", "k[]Sk", (SUBR)cmparray1_init, (SUBR)cmparray1_k }, - { "cmp", S(Cmp_array1), 0, 1, "i[]", "i[]Si", (SUBR)cmparray1_i }, + { "cmp", S(Cmp_array1), 0, "i[]", "i[]Si", (SUBR)cmparray1_i }, - { "cmp", S(Cmp_array2), 0, 3, "k[]", "k[]Sk[]", + { "cmp", S(Cmp_array2), 0, "k[]", "k[]Sk[]", (SUBR)cmparray2_init, (SUBR)cmparray2_k }, - { "cmp", S(Cmp_array2), 0, 1, "i[]", "i[]Si[]", + { "cmp", S(Cmp_array2), 0, "i[]", "i[]Si[]", (SUBR)cmparray2_i }, - { "cmp", S(Cmp2_array1), 0, 3, "k[]", "kSk[]Sk", + { "cmp", S(Cmp2_array1), 0, "k[]", "kSk[]Sk", (SUBR)cmp2array1_init, (SUBR)cmp2array1_k }, - { "cmp", S(Cmp2_array1), 0, 1, "i[]", "iSi[]Si", (SUBR)cmp2array1_i}, + { "cmp", S(Cmp2_array1), 0, "i[]", "iSi[]Si", (SUBR)cmp2array1_i}, - { "##or", S(BINOP_AAA), 0, 3, "k[]", "k[]k[]", + { "##or", S(BINOP_AAA), 0, "k[]", "k[]k[]", (SUBR)array_binop_init, (SUBR)array_or}, - { "##and", S(BINOP_AAA), 0, 3, "k[]", "k[]k[]", + { "##and", S(BINOP_AAA), 0, "k[]", "k[]k[]", (SUBR)array_binop_init, (SUBR)array_and}, - { "reshapearray", S(ARRAYRESHAPE), 0, 1, "", ".[]io", (SUBR)arrayreshape}, + { "reshapearray", S(ARRAYRESHAPE), 0, "", ".[]io", (SUBR)arrayreshape}, - { "ftslicei", S(TABSLICE), TB, 1, "", "iioop", (SUBR)tabslice_i }, + { "ftslicei", S(TABSLICE), TB, "", "iioop", (SUBR)tabslice_i }, - { "ftslice.perf", S(TABSLICE), TB, 3, "", "iiOOP", + { "ftslice.perf", S(TABSLICE), TB, "", "iiOOP", (SUBR)tabslice_init, (SUBR)tabslice_k}, - { "ftslice.onlyperf", S(TABSLICE), TB, 2, "", "kkOOP", + { "ftslice.onlyperf", S(TABSLICE), TB, "", "kkOOP", NULL, (SUBR)tabslice_allk}, - { "ftset.i", S(FTSET), TW, 1, "", "iioop", (SUBR)ftset_i }, - { "ftset.k", S(FTSET), TW, 3, "", "kkOOP", (SUBR)ftset_init, (SUBR)ftset_k }, + { "ftset.i", S(FTSET), TW, "", "iioop", (SUBR)ftset_i }, + { "ftset.k", S(FTSET), TW, "", "kkOOP", (SUBR)ftset_init, (SUBR)ftset_k }, - { "tab2array", S(TAB2ARRAY), TR, 3, "k[]", "iOOP", + { "tab2array", S(TAB2ARRAY), TR, "k[]", "iOOP", (SUBR)tab2array_init, (SUBR)tab2array_k}, - { "tab2array", S(TAB2ARRAY), TR, 1, "i[]", "ioop", (SUBR)tab2array_i}, + { "tab2array", S(TAB2ARRAY), TR, "i[]", "ioop", (SUBR)tab2array_i}, - { "printarray", S(ARRAYPRINTK), 0, 3, "", "k[]J", + { "printarray", S(ARRAYPRINTK), 0, "", "k[]J", (SUBR)arrayprint_init, (SUBR)arrayprint_perf}, - { "printarray", S(ARRAYPRINTK), 0, 3, "", "k[]kS", + { "printarray", S(ARRAYPRINTK), 0, "", "k[]kS", (SUBR)arrayprint_init, (SUBR)arrayprint_perf}, - { "printarray.k_notrig", S(ARRAYPRINT), 0, 3, "", "k[]S", + { "printarray.k_notrig", S(ARRAYPRINT), 0, "", "k[]S", (SUBR)arrayprint_init_notrig, (SUBR)arrayprint_perf_notrig}, - { "printarray", S(ARRAYPRINTK), 0, 3, "", "k[]kSS", + { "printarray", S(ARRAYPRINTK), 0, "", "k[]kSS", (SUBR)arrayprint_init, (SUBR)arrayprint_perf}, - { "printarray.k_notrig", S(ARRAYPRINT), 0, 3, "", "k[]SS", + { "printarray.k_notrig", S(ARRAYPRINT), 0, "", "k[]SS", (SUBR)arrayprint_init_notrig, (SUBR)arrayprint_perf_notrig}, - { "printarray.i", S(ARRAYPRINT), 0, 1, "", "i[]", (SUBR)arrayprint_i}, - { "printarray.fmt_i", S(ARRAYPRINT), 0, 1, "", "i[]S", (SUBR)arrayprintf_i}, - { "printarray.fmt_label_i", S(ARRAYPRINT), 0, 1, "", "i[]SS", + { "printarray.i", S(ARRAYPRINT), 0, "", "i[]", (SUBR)arrayprint_i}, + { "printarray.fmt_i", S(ARRAYPRINT), 0, "", "i[]S", (SUBR)arrayprintf_i}, + { "printarray.fmt_label_i", S(ARRAYPRINT), 0, "", "i[]SS", (SUBR)arrayprintf_i}, - { "printarray", S(ARRAYPRINTK), 0, 3, "", "S[]J", + { "printarray", S(ARRAYPRINTK), 0, "", "S[]J", (SUBR)arrayprint_init, (SUBR)arrayprint_perf}, - { "printarray", S(ARRAYPRINTK), 0, 3, "", "S[]kS", + { "printarray", S(ARRAYPRINTK), 0, "", "S[]kS", (SUBR)arrayprint_init, (SUBR)arrayprint_perf}, - { "printarray", S(ARRAYPRINT), 0, 3, "", "S[]S", + { "printarray", S(ARRAYPRINT), 0, "", "S[]S", (SUBR)arrayprint_init_notrig, (SUBR)arrayprint_perf_notrig}, - { "printarray", S(ARRAYPRINT), 0, 3, "", "S[]SS", + { "printarray", S(ARRAYPRINT), 0, "", "S[]SS", (SUBR)arrayprint_init_notrig, (SUBR)arrayprint_perf_notrig}, - { "ftprint", S(FTPRINT), TR, 3, "", "iPOOPo", + { "ftprint", S(FTPRINT), TR, "", "iPOOPo", (SUBR)ftprint_init, (SUBR)ftprint_perf }, - { "ftexists", S(FTEXISTS), TR, 1, "i", "i", + { "ftexists", S(FTEXISTS), TR, "i", "i", (SUBR)ftexists_init}, - { "ftexists", S(FTEXISTS), TR, 3, "k", "k", + { "ftexists", S(FTEXISTS), TR, "k", "k", (SUBR)ftexists_init, (SUBR)ftexists_init}, - { "lastcycle", S(LASTCYCLE), 0, 3, "k", "", + { "lastcycle", S(LASTCYCLE), 0, "k", "", (SUBR)lastcycle_init, (SUBR)lastcycle}, - { "strstrip.i_side", S(STR1_1), 0, 1, "S", "SS", (SUBR)stripside}, - { "strstrip.i", S(STR1_1), 0, 1, "S", "S", (SUBR)strstrip}, - { "println", S(PRINTLN), 0, 3, "", "SN", + { "strstrip.i_side", S(STR1_1), 0, "S", "SS", (SUBR)stripside}, + { "strstrip.i", S(STR1_1), 0, "S", "S", (SUBR)strstrip}, + { "println", S(PRINTLN), 0, "", "SN", (SUBR)println_init, (SUBR)println_perf}, - { "printsk", S(PRINTLN), 0, 3, "", "SN", + { "printsk", S(PRINTLN), 0, "", "SN", (SUBR)printsk_init, (SUBR)printsk_perf} }; diff --git a/Opcodes/emugens/scugens.c b/Opcodes/emugens/scugens.c index 3e944dce0bc..1b9786ddf89 100644 --- a/Opcodes/emugens/scugens.c +++ b/Opcodes/emugens/scugens.c @@ -618,72 +618,72 @@ phasor_k_kk(CSOUND *csound, Phasor *p) { #define S(x) sizeof(x) static OENTRY scugens_localops[] = { - {"sc_lag", S(LAG0), 0, 3, "k", "kk", + {"sc_lag", S(LAG0), 0, "k", "kk", (SUBR)lag0_init_no_initial_value, (SUBR)lag0k_next}, - {"lag", S(LAG0), 0, 3, "k", "kk", + {"lag", S(LAG0), 0, "k", "kk", (SUBR)lag0_init_no_initial_value, (SUBR)lag0k_next}, - {"sc_lag", S(LAG0), 0, 3, "k", "kki", + {"sc_lag", S(LAG0), 0, "k", "kki", (SUBR)lag0_init_initial_value, (SUBR)lag0k_next}, - {"lag", S(LAG0), 0, 3, "k", "kki", + {"lag", S(LAG0), 0, "k", "kki", (SUBR)lag0_init_initial_value, (SUBR)lag0k_next}, - {"sc_lag", S(LAG0), 0, 3, "a", "aki", + {"sc_lag", S(LAG0), 0, "a", "aki", (SUBR)laga_init_initial_value, (SUBR)laga_next}, - {"lag", S(LAG0), 0, 3, "a", "aki", + {"lag", S(LAG0), 0, "a", "aki", (SUBR)laga_init_initial_value, (SUBR)laga_next}, - {"sc_lag", S(LAG0), 0, 3, "a", "ak", + {"sc_lag", S(LAG0), 0, "a", "ak", (SUBR)laga_init_no_initial_value, (SUBR)laga_next}, - {"lag", S(LAG0), 0, 3, "a", "ak", + {"lag", S(LAG0), 0, "a", "ak", (SUBR)laga_init_no_initial_value, (SUBR)laga_next}, - {"sc_lagud", S(LagUD), 0, 3, "k", "kkki", + {"sc_lagud", S(LagUD), 0, "k", "kkki", (SUBR)lagud_init_initial_value, (SUBR)lagud_k }, - {"lagud", S(LagUD), 0, 3, "k", "kkki", + {"lagud", S(LagUD), 0, "k", "kkki", (SUBR)lagud_init_initial_value, (SUBR)lagud_k }, - {"sc_lagud", S(LagUD), 0, 3, "a", "akki", + {"sc_lagud", S(LagUD), 0, "a", "akki", (SUBR)lagud_init_initial_value, (SUBR)lagud_a }, - {"lagud", S(LagUD), 0, 3, "a", "akki", + {"lagud", S(LagUD), 0, "a", "akki", (SUBR)lagud_init_initial_value, (SUBR)lagud_a }, - {"sc_lagud", S(LagUD), 0, 3, "k", "kkk", + {"sc_lagud", S(LagUD), 0, "k", "kkk", (SUBR)lagud_init_no_initial_value, (SUBR)lagud_k }, - {"lagud", S(LagUD), 0, 3, "k", "kkk", + {"lagud", S(LagUD), 0, "k", "kkk", (SUBR)lagud_init_no_initial_value, (SUBR)lagud_k }, - {"sc_lagud", S(LagUD), 0, 3, "a", "akk", + {"sc_lagud", S(LagUD), 0, "a", "akk", (SUBR)lagud_init_no_initial_value, (SUBR)lagud_a }, - {"lagud", S(LagUD), 0, 3, "a", "akk", + {"lagud", S(LagUD), 0, "a", "akk", (SUBR)lagud_init_no_initial_value, (SUBR)lagud_a }, - {"sc_trig", S(Trig), 0, 3, "k", "kk", (SUBR)trig_init, (SUBR)trig_k }, - {"trighold", S(Trig), 0, 3, "k", "kk", (SUBR)trig_init, (SUBR)trig_k }, + {"sc_trig", S(Trig), 0, "k", "kk", (SUBR)trig_init, (SUBR)trig_k }, + {"trighold", S(Trig), 0, "k", "kk", (SUBR)trig_init, (SUBR)trig_k }, - {"sc_trig", S(Trig), 0, 3, "a", "ak", (SUBR)trig_init, (SUBR)trig_a }, - {"trighold", S(Trig), 0, 3, "a", "ak", (SUBR)trig_init, (SUBR)trig_a }, + {"sc_trig", S(Trig), 0, "a", "ak", (SUBR)trig_init, (SUBR)trig_a }, + {"trighold", S(Trig), 0, "a", "ak", (SUBR)trig_init, (SUBR)trig_a }, - {"sc_phasor", S(Phasor), 0, 3, "k", "kkkkO", + {"sc_phasor", S(Phasor), 0, "k", "kkkkO", (SUBR)phasor_init, (SUBR)phasor_k_kk }, - {"trigphasor", S(Phasor), 0, 3, "k", "kkkkO", + {"trigphasor", S(Phasor), 0, "k", "kkkkO", (SUBR)phasor_init, (SUBR)phasor_k_kk }, - {"sc_phasor", S(Phasor), 0, 3, "a", "akkkO", + {"sc_phasor", S(Phasor), 0, "a", "akkkO", (SUBR)phasor_init, (SUBR)phasor_a_ak }, - {"trigphasor", S(Phasor), 0, 3, "a", "akkkO", + {"trigphasor", S(Phasor), 0, "a", "akkkO", (SUBR)phasor_init, (SUBR)phasor_a_ak }, - {"sc_phasor", S(Phasor), 0, 3, "a", "aakkO", + {"sc_phasor", S(Phasor), 0, "a", "aakkO", (SUBR)phasor_init, (SUBR)phasor_a_aa }, - {"trigphasor", S(Phasor), 0, 3, "a", "aakkO", + {"trigphasor", S(Phasor), 0, "a", "aakkO", (SUBR)phasor_init, (SUBR)phasor_a_aa }, - {"sc_phasor", S(Phasor), 0, 3, "a", "kkkkO", + {"sc_phasor", S(Phasor), 0, "a", "kkkkO", (SUBR)phasor_init, (SUBR)phasor_a_kk }, - {"trigphasor", S(Phasor), 0, 3, "a", "kkkkO", + {"trigphasor", S(Phasor), 0, "a", "kkkkO", (SUBR)phasor_init, (SUBR)phasor_a_kk } }; diff --git a/Opcodes/eqfil.c b/Opcodes/eqfil.c index 2c3695f5986..07a1174f7ae 100644 --- a/Opcodes/eqfil.c +++ b/Opcodes/eqfil.c @@ -91,7 +91,7 @@ static int32_t equ_process(CSOUND *csound, equ *p) } static OENTRY eqfil_localops[] = { - {"eqfil", sizeof(equ), 0, 3, + {"eqfil", sizeof(equ), 0, "a", "akkko", (SUBR)equ_init, (SUBR)equ_process}, }; diff --git a/Opcodes/exciter.c b/Opcodes/exciter.c index 9d58ced58a2..ac4cbbf9f0c 100644 --- a/Opcodes/exciter.c +++ b/Opcodes/exciter.c @@ -291,7 +291,7 @@ int32_t exciter_perf(CSOUND *csound, EXCITER *p) #define S(x) sizeof(x) static OENTRY exciter_localops[] = { - { "exciter", S(EXCITER), 0, 3, "a", "akkkk", + { "exciter", S(EXCITER), 0, "a", "akkkk", (SUBR)exciter_init, (SUBR)exciter_perf }, }; diff --git a/Opcodes/fareyseq.c b/Opcodes/fareyseq.c index 98128aeb7b5..5d0c6fb5a55 100644 --- a/Opcodes/fareyseq.c +++ b/Opcodes/fareyseq.c @@ -742,14 +742,14 @@ void float_to_cfrac (CSOUND *csound, double r, int32_t n, #define S sizeof static OENTRY fareyseq_localops[] = { - {"tablefilteri", S(TABFILT),TB, 1, "i", "iiii", (SUBR) tableifilter,NULL,NULL}, - {"tablefilter", S(TABFILT), TB, 3, "k", "kkkk", + {"tablefilteri", S(TABFILT),TB, "i", "iiii", (SUBR) tableifilter,NULL,NULL}, + {"tablefilter", S(TABFILT), TB, "k", "kkkk", (SUBR) tablefilterset, (SUBR) tablefilter, NULL}, - {"fareyleni", S(FAREYLEN), TR, 1, "i", "i", (SUBR) fareylen, NULL, NULL}, - {"fareylen", S(FAREYLEN), TR, 2, "k", "k", NULL, (SUBR) fareylen, NULL}, - {"tableshufflei", S(TABSHUFFLE), TB, 1, "", "i", + {"fareyleni", S(FAREYLEN), TR, "i", "i", (SUBR) fareylen, NULL, NULL}, + {"fareylen", S(FAREYLEN), TR, "k", "k", NULL, (SUBR) fareylen, NULL}, + {"tableshufflei", S(TABSHUFFLE), TB, "", "i", (SUBR) tableishuffle, NULL, NULL}, - {"tableshuffle", S(TABSHUFFLE), TB, 3, "", "k", + {"tableshuffle", S(TABSHUFFLE), TB, "", "k", (SUBR) tableshuffleset, (SUBR) tableshuffle, NULL}, }; diff --git a/Opcodes/filter.c b/Opcodes/filter.c index b2455dc1f2e..aa6af2882b6 100644 --- a/Opcodes/filter.c +++ b/Opcodes/filter.c @@ -870,9 +870,9 @@ static fcomplex RCmul(double x, fcomplex a) static OENTRY localops[] = { { "filter2",0xffff, }, -{ "filter2.a", S(FILTER), 0, 3, "a", "aiim", (SUBR)ifilter, (SUBR)afilter}, -{ "filter2.k", S(FILTER), 0, 3, "k", "kiim", (SUBR)ifilter, (SUBR)kfilter,NULL }, -{ "zfilter2", S(ZFILTER), 0, 3, "a", "akkiim", (SUBR)izfilter, (SUBR)azfilter} +{ "filter2.a", S(FILTER), 0, "a", "aiim", (SUBR)ifilter, (SUBR)afilter}, +{ "filter2.k", S(FILTER), 0, "k", "kiim", (SUBR)ifilter, (SUBR)kfilter,NULL }, +{ "zfilter2", S(ZFILTER), 0, "a", "akkiim", (SUBR)izfilter, (SUBR)azfilter} }; int32_t filter_init_(CSOUND *csound) diff --git a/Opcodes/flanger.c b/Opcodes/flanger.c index 202fc651c53..d65b792ad07 100644 --- a/Opcodes/flanger.c +++ b/Opcodes/flanger.c @@ -334,9 +334,9 @@ static int32_t wguide2(CSOUND *csound, WGUIDE2 *p) #define S(x) sizeof(x) static OENTRY localops[] = { -{ "flanger", S(FLANGER), 0, 3, "a", "aakvo", (SUBR)flanger_set, (SUBR)flanger }, -{ "wguide1", S(WGUIDE1), 0, 3, "a", "axkk",(SUBR) wguide1set, (SUBR)wguide1 }, -{ "wguide2", S(WGUIDE2), 0, 3, "a", "axxkkkk",(SUBR)wguide2set, (SUBR)wguide2 } +{ "flanger", S(FLANGER), 0, "a", "aakvo", (SUBR)flanger_set, (SUBR)flanger }, +{ "wguide1", S(WGUIDE1), 0, "a", "axkk",(SUBR) wguide1set, (SUBR)wguide1 }, +{ "wguide2", S(WGUIDE2), 0, "a", "axxkkkk",(SUBR)wguide2set, (SUBR)wguide2 } }; int32_t flanger_init_(CSOUND *csound) diff --git a/Opcodes/follow.c b/Opcodes/follow.c index 170c2f59683..b86080f1b5a 100644 --- a/Opcodes/follow.c +++ b/Opcodes/follow.c @@ -144,8 +144,8 @@ static int32_t envext(CSOUND *csound, ENV *p) #define S(x) sizeof(x) static OENTRY localops[] = { -{ "follow", S(FOL), 0, 3, "a", "ai", (SUBR)flwset, (SUBR)follow }, -{ "follow2", S(ENV), 0, 3, "a", "akk", (SUBR)envset, (SUBR)envext } +{ "follow", S(FOL), 0, "a", "ai", (SUBR)flwset, (SUBR)follow }, +{ "follow2", S(ENV), 0, "a", "akk", (SUBR)envset, (SUBR)envext } }; int32_t follow_init_(CSOUND *csound) diff --git a/Opcodes/fout.c b/Opcodes/fout.c index c0fed472fa7..38665a4ca2c 100644 --- a/Opcodes/fout.c +++ b/Opcodes/fout.c @@ -1,25 +1,25 @@ /* - fout.c: + fout.c: - Copyright (C) 1999 Gabriel Maldonado, John ffitch, Matt Ingalls - (C) 2005, 2006 Istvan Varga + Copyright (C) 1999 Gabriel Maldonado, John ffitch, Matt Ingalls + (C) 2005, 2006 Istvan Varga, Victor Lazzarini - This file is part of Csound. + This file is part of Csound. - The Csound Library is free software; you can redistribute it - and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + The Csound Library is free software; you can redistribute it + and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - Csound is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. + Csound is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with Csound; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - 02110-1301 USA + You should have received a copy of the GNU Lesser General Public + License along with Csound; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + 02110-1301 USA */ /* Opcodes By Gabriel Maldonado, 1999 */ @@ -32,13 +32,14 @@ #include /* remove a file reference, optionally closing the file */ - -static CS_NOINLINE int32_t fout_deinit_callback(CSOUND *csound, void *p_) +static CS_NOINLINE int32_t fout_deinit(CSOUND *csound, FOUT_FILE *p) { - FOUT_FILE *p = (FOUT_FILE*) p_; + + if(p->need_deinit) { + p->need_deinit = 0; struct fileinTag *pp; STDOPCOD_GLOBALS *ppp = (STDOPCOD_GLOBALS*) csound->QueryGlobalVariable(csound, - "STDOPC_GLOBALS"); + "STDOPC_GLOBALS"); p->sf = (SNDFILE*) NULL; p->f = (FILE*) NULL; if (p->idx) { @@ -59,564 +60,500 @@ static CS_NOINLINE int32_t fout_deinit_callback(CSOUND *csound, void *p_) if (pp->fd != NULL) { if ((ppp->oparms.msglevel & 7) == 7) csound->Message(csound, Str("Closing file '%s'...\n"), - csound->GetFileName(pp->fd)); + csound->GetFileName(pp->fd)); csound->FileClose(csound, pp->fd); pp->fd = NULL; } } } } - - return OK; + } + return OK; } -static CS_NOINLINE int32_t fout_open_file(CSOUND *csound, FOUT_FILE *p, void *fp, - int32_t fileType, MYFLT *iFile, - int32_t isString, - void *fileParams, int32_t forceSync) +static CS_NOINLINE FOUT_FILE *fout_open_file(CSOUND *csound, FOUT_FILE *p, void *fp, + int32_t fileType, MYFLT *iFile, + int32_t isString, + void *fileParams, int32_t forceSync) { - STDOPCOD_GLOBALS *pp = (STDOPCOD_GLOBALS*) - csound->QueryGlobalVariable(csound,"STDOPC_GLOBALS"); - char *name; - int32_t idx, csFileType, need_deinit = 0; - - if (p != (FOUT_FILE*) NULL) p->async = 0; - if (fp != NULL) { - if (fileType == CSFILE_STD) - *((FILE**) fp) = (FILE*) NULL; - else - *((SNDFILE**) fp) = (SNDFILE*) NULL; - } - /* if the opcode already uses a file, remove old reference first */ - if (p != (FOUT_FILE*) NULL) { - if (p->idx) - fout_deinit_callback(csound, (void*) p); - else - need_deinit = 1; - } - /* get file name, */ - if (isString) name = csound->Strdup(csound, ((STRINGDAT *)iFile)->data); - else if (csound->ISSTRCOD(*iFile)) - name = csound->Strdup(csound, csound->GetString(csound, *iFile)); - /* else csound->strarg2name(csound, NULL, iFile, "fout.", 0);*/ - else { - /* or handle to previously opened file */ - idx = (int32_t) MYFLT2LRND(*iFile); - if (UNLIKELY(idx < 0 || idx > pp->file_num || - (fileType == CSFILE_STD && pp->file_opened[idx].raw == NULL) || - (fileType != CSFILE_STD && pp->file_opened[idx].file == NULL))) { - return csound->InitError(csound, "%s", Str("invalid file handle")); - } - goto returnHandle; - } - /* check for a valid name */ - if (UNLIKELY(name == NULL || name[0] == '\0')) { - csound->Free(csound, name); - return csound->InitError(csound, "%s", Str("invalid file name")); + STDOPCOD_GLOBALS *pp = (STDOPCOD_GLOBALS*) + csound->QueryGlobalVariable(csound,"STDOPC_GLOBALS"); + char *name; + int32_t idx, csFileType; + + if (p != (FOUT_FILE*) NULL) p->async = 0; + if (fp != NULL) { + if (fileType == CSFILE_STD) + *((FILE**) fp) = (FILE*) NULL; + else + *((SNDFILE**) fp) = (SNDFILE*) NULL; + } + /* if the opcode already uses a file, remove old reference first */ + if (p != (FOUT_FILE*) NULL) { + if (p->idx) { + p->need_deinit = 1; + fout_deinit(csound, (void*) p); } - /* is this file already open ? */ - if (fileType == CSFILE_STD) { - for (idx = 0; idx <= pp->file_num; idx++) { - if (pp->file_opened[idx].raw != (FILE*) NULL && - strcmp(pp->file_opened[idx].name, name) == 0) - goto returnHandle; - } + else + p->need_deinit = 1; + } + /* get file name, */ + if (isString) name = csound->Strdup(csound, ((STRINGDAT *)iFile)->data); + else if (csound->ISSTRCOD(*iFile)) + name = csound->Strdup(csound, csound->GetString(csound, *iFile)); + /* else csound->strarg2name(csound, NULL, iFile, "fout.", 0);*/ + else { + /* or handle to previously opened file */ + idx = (int32_t) MYFLT2LRND(*iFile); + if (UNLIKELY(idx < 0 || idx > pp->file_num || + (fileType == CSFILE_STD && pp->file_opened[idx].raw == NULL) || + (fileType != CSFILE_STD && pp->file_opened[idx].file == NULL))) { + csound->InitError(csound, "%s", Str("invalid file handle")); + return NULL; } - else { - for (idx = 0; idx <= pp->file_num; idx++) { - if (pp->file_opened[idx].file != (SNDFILE*) NULL && - strcmp(pp->file_opened[idx].name, name) == 0) - goto returnHandle; - } + goto returnHandle; + } + /* check for a valid name */ + if (UNLIKELY(name == NULL || name[0] == '\0')) { + csound->Free(csound, name); + csound->InitError(csound, "%s", Str("invalid file name")); + return NULL; + } + /* is this file already open ? */ + if (fileType == CSFILE_STD) { + for (idx = 0; idx <= pp->file_num; idx++) { + if (pp->file_opened[idx].raw != (FILE*) NULL && + strcmp(pp->file_opened[idx].name, name) == 0) + goto returnHandle; } - /* allocate new file handle, or use an already existing unused one */ + } + else { for (idx = 0; idx <= pp->file_num; idx++) { - if (pp->file_opened[idx].fd == NULL) - break; + if (pp->file_opened[idx].file != (SNDFILE*) NULL && + strcmp(pp->file_opened[idx].name, name) == 0) + goto returnHandle; } - if (idx > pp->file_num) { - if (idx >= pp->file_max) { - struct fileinTag *tmp; - /* Expand by 4 each time */ - pp->file_max = (idx | 3) + 1; - tmp = (struct fileinTag *) - csound->ReAlloc(csound, pp->file_opened, - sizeof(struct fileinTag) * pp->file_max); - pp->file_opened = tmp; - memset(&(tmp[pp->file_num + 1]), 0, - sizeof(struct fileinTag) * (pp->file_max - (pp->file_num + 1))); - } - pp->file_num = idx; + } + /* allocate new file handle, or use an already existing unused one */ + for (idx = 0; idx <= pp->file_num; idx++) { + if (pp->file_opened[idx].fd == NULL) + break; + } + if (idx > pp->file_num) { + if (idx >= pp->file_max) { + struct fileinTag *tmp; + /* Expand by 4 each time */ + pp->file_max = (idx | 3) + 1; + tmp = (struct fileinTag *) + csound->ReAlloc(csound, pp->file_opened, + sizeof(struct fileinTag) * pp->file_max); + pp->file_opened = tmp; + memset(&(tmp[pp->file_num + 1]), 0, + sizeof(struct fileinTag) * (pp->file_max - (pp->file_num + 1))); } - memset(&pp->file_opened[idx], 0, sizeof(struct fileinTag)); - /* pp->file_opened[idx].file = (SNDFILE*) NULL; */ - /* pp->file_opened[idx].raw = (FILE*) NULL; */ - /* pp->file_opened[idx].fd = NULL; */ - /* pp->file_opened[idx].name = (char*) NULL; */ - /* pp->file_opened[idx].do_scale = 0; */ - /* pp->file_opened[idx].refCount = 0U; */ - /* attempt to open file */ - if (fileType == CSFILE_STD) { - FILE *f; - void *fd; - char *filemode = (char*)fileParams; - - /* akozar: csFileType cannot be as specific as I'd like since it is not - possible to know the real file type until this handle is used */ - if ((strcmp(filemode, "rb") == 0 || (strcmp(filemode, "wb") == 0))) - csFileType = CSFTYPE_OTHER_BINARY; - else csFileType = CSFTYPE_OTHER_TEXT; - fd = csound->FileOpen2(csound, &f, fileType, name, fileParams, "", - csFileType, 0); - if (UNLIKELY(fd == NULL)) { - csound->InitError(csound, Str("error opening file '%s'"), name); - csound->Free(csound, name); - return NOTOK; - } - /* setvbuf(f, (char *) NULL, _IOLBF, 0); */ /* Ensure line buffering */ - pp->file_opened[idx].raw = f; - pp->file_opened[idx].fd = fd; + pp->file_num = idx; + } + memset(&pp->file_opened[idx], 0, sizeof(struct fileinTag)); + if (fileType == CSFILE_STD) { + FILE *f; + void *fd; + char *filemode = (char*)fileParams; + if ((strcmp(filemode, "rb") == 0 || (strcmp(filemode, "wb") == 0))) + csFileType = CSFTYPE_OTHER_BINARY; + else csFileType = CSFTYPE_OTHER_TEXT; + fd = csound->FileOpen2(csound, &f, fileType, name, fileParams, "", + csFileType, 0); + if (UNLIKELY(fd == NULL)) { + csound->InitError(csound, Str("error opening file '%s'"), name); + csound->Free(csound, name); + return NULL; } - else { - SNDFILE *sf; - void *fd; - //int32_t buf_reqd; - int32_t do_scale = 0; - - if (fileType == CSFILE_SND_W) { - do_scale = ((SFLIB_INFO*) fileParams)->format; - csFileType = csound->sftype2csfiletype(do_scale); - if (pp->oparms.realtime == 0 || forceSync == 1) { - fd = csound->FileOpen2(csound, &sf, fileType, name, fileParams, - "SFDIR", csFileType, 0); - p->async = 0; - } - else { - p->fd = fd = csound->FileOpenAsync(csound, &sf, fileType, - name, fileParams, - "SFDIR;SSDIR", CSFTYPE_UNKNOWN_AUDIO, - p->bufsize, 0); - p->async = 1; - } - p->nchnls = ((SFLIB_INFO*) fileParams)->channels; + pp->file_opened[idx].raw = f; + pp->file_opened[idx].fd = fd; + } + else { + SNDFILE *sf; + void *fd; + int32_t do_scale = 0; + + if (fileType == CSFILE_SND_W) { + do_scale = ((SFLIB_INFO*) fileParams)->format; + csFileType = csound->sftype2csfiletype(do_scale); + if (pp->oparms.realtime == 0 || forceSync == 1) { + fd = csound->FileOpen2(csound, &sf, fileType, name, fileParams, + "SFDIR", csFileType, 0); + p->async = 0; } else { - if (pp->oparms.realtime == 0 || forceSync == 1) { - fd = csound->FileOpen2(csound, &sf, fileType, name, fileParams, - "SFDIR;SSDIR", CSFTYPE_UNKNOWN_AUDIO, 0); - p->async = 0; - - } else { - p->fd = fd = csound->FileOpenAsync(csound, &sf, fileType, - name, fileParams, - "SFDIR;SSDIR", CSFTYPE_UNKNOWN_AUDIO, - p->bufsize, 0); - p->async = 1; - } - p->nchnls = ((SFLIB_INFO*) fileParams)->channels; - do_scale = ((SFLIB_INFO*) fileParams)->format; + p->fd = fd = csound->FileOpenAsync(csound, &sf, fileType, + name, fileParams, + "SFDIR;SSDIR", CSFTYPE_UNKNOWN_AUDIO, + p->bufsize, 0); + p->async = 1; } - do_scale = (SF2TYPE(do_scale) == TYP_RAW ? 0 : 1); - if (UNLIKELY(fd == NULL)) { - csound->InitError(csound, Str("error opening sound file '%s'"), name); - csound->Free(csound, name); - return NOTOK; + p->nchnls = ((SFLIB_INFO*) fileParams)->channels; + } + else { + if (pp->oparms.realtime == 0 || forceSync == 1) { + fd = csound->FileOpen2(csound, &sf, fileType, name, fileParams, + "SFDIR;SSDIR", CSFTYPE_UNKNOWN_AUDIO, 0); + p->async = 0; + + } else { + p->fd = fd = csound->FileOpenAsync(csound, &sf, fileType, + name, fileParams, + "SFDIR;SSDIR", CSFTYPE_UNKNOWN_AUDIO, + p->bufsize, 0); + p->async = 1; } - if (!do_scale) { + p->nchnls = ((SFLIB_INFO*) fileParams)->channels; + do_scale = ((SFLIB_INFO*) fileParams)->format; + } + do_scale = (SF2TYPE(do_scale) == TYP_RAW ? 0 : 1); + if (UNLIKELY(fd == NULL)) { + csound->InitError(csound, Str("error opening sound file '%s'"), name); + csound->Free(csound, name); + return NULL; + } + if (!do_scale) { #ifdef USE_DOUBLE - csound->FileCommand(csound,sf, SFC_SET_NORM_DOUBLE, NULL, SFLIB_FALSE); + csound->FileCommand(csound,sf, SFC_SET_NORM_DOUBLE, NULL, SFLIB_FALSE); #else - csound->FileCommand(csound,sf, SFC_SET_NORM_FLOAT, NULL, SFLIB_FALSE); + csound->FileCommand(csound,sf, SFC_SET_NORM_FLOAT, NULL, SFLIB_FALSE); #endif - } - /* if (CS_KSMPS >= 512) - buf_reqd = CS_KSMPS * ((SFLIB_INFO*) fileParams)->channels; - else - buf_reqd = (1 + (int32_t)(512 / CS_KSMPS)) * CS_KSMPS - * ((SFLIB_INFO*) fileParams)->channels; - if (UNLIKELY(buf_reqd > pp->buf_size)) { - pp->buf_size = buf_reqd; - pp->buf = (MYFLT*) csound->ReAlloc(csound, pp->buf, sizeof(MYFLT) - * buf_reqd); - } - */ /* VL - now using per-instance buffer */ - pp->file_opened[idx].file = sf; - pp->file_opened[idx].fd = fd; - pp->file_opened[idx].do_scale = do_scale; } - /* store file information */ - pp->file_opened[idx].name = name; + + /* VL - now using per-instance buffer */ + pp->file_opened[idx].file = sf; + pp->file_opened[idx].fd = fd; + pp->file_opened[idx].do_scale = do_scale; + } + /* store file information */ + pp->file_opened[idx].name = name; returnHandle: - /* return 'idx' as file handle */ - if (fp != NULL) { - if (fileType == CSFILE_STD) - *((FILE**) fp) = pp->file_opened[idx].raw; - else - *((SNDFILE**) fp) = pp->file_opened[idx].file; + /* return 'idx' as file handle */ + if (fp != NULL) { + if (fileType == CSFILE_STD) + *((FILE**) fp) = pp->file_opened[idx].raw; + else + *((SNDFILE**) fp) = pp->file_opened[idx].file; + } + if (p != (FOUT_FILE*) NULL) { + if (fileType == CSFILE_STD) { + p->sf = (SNDFILE*) NULL; + p->f = pp->file_opened[idx].raw; } - if (p != (FOUT_FILE*) NULL) { - if (fileType == CSFILE_STD) { - p->sf = (SNDFILE*) NULL; - p->f = pp->file_opened[idx].raw; - } - else { - p->sf = pp->file_opened[idx].file; - p->f = (FILE*) NULL; - } - p->idx = idx + 1; - pp->file_opened[idx].refCount++; - if (need_deinit) { - // p->h.insdshead = csound->ids->insdshead; - /* FIXME: should check for error here */ - p->h.insdshead = p->head; - csound->RegisterDeinitCallback(csound, p, fout_deinit_callback); - } + else { + p->sf = pp->file_opened[idx].file; + p->f = (FILE*) NULL; } - return idx; + p->idx = idx + 1; + pp->file_opened[idx].refCount++; + } + return p; } static int32_t outfile(CSOUND *csound, OUTFILE *p) { - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t i, j, k, nsmps = CS_KSMPS; - uint32_t nargs = p->nargs; - MYFLT *buf = (MYFLT *) p->buf.auxp; - - if (UNLIKELY(early)) nsmps -= early; - if (p->f.sf == NULL) { - if (p->f.f != NULL) { /* VL: make sure there is an open file */ - FILE *fp = p->f.f; - for (k = offset; k < nsmps; k++) { - for (j = 0; j < nargs; j++) - fprintf(fp, "%g ", p->argums[j][k]); - fprintf(fp, "\n"); - } + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t i, j, k, nsmps = CS_KSMPS; + uint32_t nargs = p->nargs; + MYFLT *buf = (MYFLT *) p->buf.auxp; + + if (UNLIKELY(early)) nsmps -= early; + if (p->f.sf == NULL) { + if (p->f.f != NULL) { /* VL: make sure there is an open file */ + FILE *fp = p->f.f; + for (k = offset; k < nsmps; k++) { + for (j = 0; j < nargs; j++) + fprintf(fp, "%g ", p->argums[j][k]); + fprintf(fp, "\n"); } } - else { - for (j = offset, k = p->buf_pos; j < nsmps; j++) - for (i = 0; i < nargs; i++) - buf[k++] = p->argums[i][j] * p->scaleFac; - p->buf_pos = k; - if (p->buf_pos >= p->guard_pos) { - - //#ifndef USE_DOUBLE - //sflib_write_float(p->f.sf, buf, p->buf_pos); - //#else - //sflib_write_double(p->f.sf, buf, p->buf_pos); - //#endif - if (p->f.async==1) - csound->WriteAsync(csound, p->f.fd, buf, p->buf_pos); - else //sflib_write_MYFLT(p->f.sf, buf, p->buf_pos); - csound->SndfileWrite(csound, p->f.sf, buf, p->buf_pos/nargs); // in frames - p->buf_pos = 0; - } - + } + else { + for (j = offset, k = p->buf_pos; j < nsmps; j++) + for (i = 0; i < nargs; i++) + buf[k++] = p->argums[i][j] * p->scaleFac; + p->buf_pos = k; + if (p->buf_pos >= p->guard_pos) { + if (p->f.async==1) + csound->WriteAsync(csound, p->f.fd, buf, p->buf_pos); + else //sflib_write_MYFLT(p->f.sf, buf, p->buf_pos); + csound->SndfileWrite(csound, p->f.sf, buf, p->buf_pos/nargs); // in frames + p->buf_pos = 0; } - return OK; + + } + return OK; } static int32_t outfile_array(CSOUND *csound, OUTFILEA *p) { - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t i, j, k, nsmps = CS_KSMPS; - uint32_t nargs = p->tabin->sizes[0]; - MYFLT *buf = (MYFLT *) p->buf.auxp; - MYFLT *data = p->tabin->data; - - if (UNLIKELY(early)) nsmps -= early; - if (p->f.sf == NULL) { - if (p->f.f != NULL) { /* VL: make sure there is an open file */ - FILE *fp = p->f.f; - for (k = offset; k < nsmps; k++) { - for (j = 0; j < nargs; j++) - fprintf(fp, "%g ", data[j*CS_KSMPS+k]); - fprintf(fp, "\n"); - } + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t i, j, k, nsmps = CS_KSMPS; + uint32_t nargs = p->tabin->sizes[0]; + MYFLT *buf = (MYFLT *) p->buf.auxp; + MYFLT *data = p->tabin->data; + + if (UNLIKELY(early)) nsmps -= early; + if (p->f.sf == NULL) { + if (p->f.f != NULL) { /* VL: make sure there is an open file */ + FILE *fp = p->f.f; + for (k = offset; k < nsmps; k++) { + for (j = 0; j < nargs; j++) + fprintf(fp, "%g ", data[j*CS_KSMPS+k]); + fprintf(fp, "\n"); } } - else { - for (j = offset, k = p->buf_pos; j < nsmps; j++) - for (i = 0; i < nargs; i++) - buf[k++] = data[i*CS_KSMPS+j] * p->scaleFac; - p->buf_pos = k; - if (p->buf_pos >= p->guard_pos) { - - //#ifndef USE_DOUBLE - //sflib_write_float(p->f.sf, buf, p->buf_pos); - //#else - //sflib_write_double(p->f.sf, buf, p->buf_pos); - //#endif - if (p->f.async==1) - csound->WriteAsync(csound, p->f.fd, buf, p->buf_pos); - else - //sflib_write_MYFLT(p->f.sf, buf, p->buf_pos); - csound->SndfileWrite(csound, p->f.sf, (MYFLT *) buf, p->buf_pos/nargs); // in frames - p->buf_pos = 0; - } - + } + else { + for (j = offset, k = p->buf_pos; j < nsmps; j++) + for (i = 0; i < nargs; i++) + buf[k++] = data[i*CS_KSMPS+j] * p->scaleFac; + p->buf_pos = k; + if (p->buf_pos >= p->guard_pos) { + if (p->f.async==1) + csound->WriteAsync(csound, p->f.fd, buf, p->buf_pos); + else + //sflib_write_MYFLT(p->f.sf, buf, p->buf_pos); + csound->SndfileWrite(csound, p->f.sf, (MYFLT *) buf, p->buf_pos/nargs); // in frames + p->buf_pos = 0; } - return OK; + + } + return OK; } static const int32_t fout_format_table[51] = { - /* 0 - 9 */ - (AE_FLOAT | TYP2SF(TYP_RAW)), (AE_SHORT | TYP2SF(TYP_RAW)), - AE_SHORT, AE_ULAW, AE_SHORT, AE_LONG, - AE_FLOAT, AE_UNCH, AE_24INT, AE_DOUBLE, - /* 10 - 19 */ - TYP2SF(TYP_WAV), (AE_CHAR | TYP2SF(TYP_WAV)), - (AE_ALAW | TYP2SF(TYP_WAV)), (AE_ULAW | TYP2SF(TYP_WAV)), - (AE_SHORT | TYP2SF(TYP_WAV)), (AE_LONG | TYP2SF(TYP_WAV)), - (AE_FLOAT | TYP2SF(TYP_WAV)), (AE_UNCH | TYP2SF(TYP_WAV)), - (AE_24INT | TYP2SF(TYP_WAV)), (AE_DOUBLE | TYP2SF(TYP_WAV)), - /* 20 - 29 */ - TYP2SF(TYP_AIFF), (AE_CHAR | TYP2SF(TYP_AIFF)), - (AE_ALAW | TYP2SF(TYP_AIFF)), (AE_ULAW | TYP2SF(TYP_AIFF)), - (AE_SHORT | TYP2SF(TYP_AIFF)), (AE_LONG | TYP2SF(TYP_AIFF)), - (AE_FLOAT | TYP2SF(TYP_AIFF)), (AE_UNCH | TYP2SF(TYP_AIFF)), - (AE_24INT | TYP2SF(TYP_AIFF)), (AE_DOUBLE | TYP2SF(TYP_AIFF)), - /* 30 - 39 */ - TYP2SF(TYP_RAW), (AE_CHAR | TYP2SF(TYP_RAW)), - (AE_ALAW | TYP2SF(TYP_RAW)), (AE_ULAW | TYP2SF(TYP_RAW)), - (AE_SHORT | TYP2SF(TYP_RAW)), (AE_LONG | TYP2SF(TYP_RAW)), - (AE_FLOAT | TYP2SF(TYP_RAW)), (AE_UNCH | TYP2SF(TYP_RAW)), - (AE_24INT | TYP2SF(TYP_RAW)), (AE_DOUBLE | TYP2SF(TYP_RAW)), - /* 40 - 49 */ - TYP2SF(TYP_IRCAM), (AE_CHAR | TYP2SF(TYP_IRCAM)), - (AE_ALAW | TYP2SF(TYP_IRCAM)), (AE_ULAW | TYP2SF(TYP_IRCAM)), - (AE_SHORT | TYP2SF(TYP_IRCAM)), (AE_LONG | TYP2SF(TYP_IRCAM)), - (AE_FLOAT | TYP2SF(TYP_IRCAM)), (AE_UNCH | TYP2SF(TYP_IRCAM)), - (AE_24INT | TYP2SF(TYP_IRCAM)), (AE_DOUBLE | TYP2SF(TYP_IRCAM)), - /* 50 */ - (TYP2SF(TYP_OGG) | AE_VORBIS) + /* 0 - 9 */ + (AE_FLOAT | TYP2SF(TYP_RAW)), (AE_SHORT | TYP2SF(TYP_RAW)), + AE_SHORT, AE_ULAW, AE_SHORT, AE_LONG, + AE_FLOAT, AE_UNCH, AE_24INT, AE_DOUBLE, + /* 10 - 19 */ + TYP2SF(TYP_WAV), (AE_CHAR | TYP2SF(TYP_WAV)), + (AE_ALAW | TYP2SF(TYP_WAV)), (AE_ULAW | TYP2SF(TYP_WAV)), + (AE_SHORT | TYP2SF(TYP_WAV)), (AE_LONG | TYP2SF(TYP_WAV)), + (AE_FLOAT | TYP2SF(TYP_WAV)), (AE_UNCH | TYP2SF(TYP_WAV)), + (AE_24INT | TYP2SF(TYP_WAV)), (AE_DOUBLE | TYP2SF(TYP_WAV)), + /* 20 - 29 */ + TYP2SF(TYP_AIFF), (AE_CHAR | TYP2SF(TYP_AIFF)), + (AE_ALAW | TYP2SF(TYP_AIFF)), (AE_ULAW | TYP2SF(TYP_AIFF)), + (AE_SHORT | TYP2SF(TYP_AIFF)), (AE_LONG | TYP2SF(TYP_AIFF)), + (AE_FLOAT | TYP2SF(TYP_AIFF)), (AE_UNCH | TYP2SF(TYP_AIFF)), + (AE_24INT | TYP2SF(TYP_AIFF)), (AE_DOUBLE | TYP2SF(TYP_AIFF)), + /* 30 - 39 */ + TYP2SF(TYP_RAW), (AE_CHAR | TYP2SF(TYP_RAW)), + (AE_ALAW | TYP2SF(TYP_RAW)), (AE_ULAW | TYP2SF(TYP_RAW)), + (AE_SHORT | TYP2SF(TYP_RAW)), (AE_LONG | TYP2SF(TYP_RAW)), + (AE_FLOAT | TYP2SF(TYP_RAW)), (AE_UNCH | TYP2SF(TYP_RAW)), + (AE_24INT | TYP2SF(TYP_RAW)), (AE_DOUBLE | TYP2SF(TYP_RAW)), + /* 40 - 49 */ + TYP2SF(TYP_IRCAM), (AE_CHAR | TYP2SF(TYP_IRCAM)), + (AE_ALAW | TYP2SF(TYP_IRCAM)), (AE_ULAW | TYP2SF(TYP_IRCAM)), + (AE_SHORT | TYP2SF(TYP_IRCAM)), (AE_LONG | TYP2SF(TYP_IRCAM)), + (AE_FLOAT | TYP2SF(TYP_IRCAM)), (AE_UNCH | TYP2SF(TYP_IRCAM)), + (AE_24INT | TYP2SF(TYP_IRCAM)), (AE_DOUBLE | TYP2SF(TYP_IRCAM)), + /* 50 */ + (TYP2SF(TYP_OGG) | AE_VORBIS) }; static int32_t fout_flush_callback(CSOUND *csound, void *p_) { - OUTFILE *p = (OUTFILE*) p_; - - if (p->f.sf != NULL && p->buf_pos > 0) { - //#ifndef USE_DOUBLE - //sflib_write_float(p->f.sf, (float*) p->buf.auxp, p->buf_pos); - //#else - //sflib_write_double(p->f.sf, (double*) p->buf.auxp, p->buf_pos); - //#endif - if (p->f.async == 1) - csound->WriteAsync(csound, p->f.fd, (MYFLT *) p->buf.auxp, p->buf_pos); - else - // sflib_write_MYFLT(p->f.sf, (MYFLT *) p->buf.auxp, p->buf_pos); - csound->SndfileWrite(csound, p->f.sf, (MYFLT *) p->buf.auxp, p->buf_pos/p->nargs); // in frames - } - return OK; + OUTFILE *p = (OUTFILE*) p_; + + if (p->f.sf != NULL && p->buf_pos > 0) { + if (p->f.async == 1) + csound->WriteAsync(csound, p->f.fd, (MYFLT *) p->buf.auxp, p->buf_pos); + else + // sflib_write_MYFLT(p->f.sf, (MYFLT *) p->buf.auxp, p->buf_pos); + csound->SndfileWrite(csound, p->f.sf, (MYFLT *) p->buf.auxp, p->buf_pos/p->nargs); // in frames + } + return fout_deinit(csound, &(p->f)); } static int32_t fouta_flush_callback(CSOUND *csound, void *p_) { - OUTFILEA *p = (OUTFILEA*) p_; - - if (p->f.sf != NULL && p->buf_pos > 0) { - //#ifndef USE_DOUBLE - //sflib_write_float(p->f.sf, (float*) p->buf.auxp, p->buf_pos); - //#else - //sflib_write_double(p->f.sf, (double*) p->buf.auxp, p->buf_pos); - //#endif - if (p->f.async == 1) - csound->WriteAsync(csound, p->f.fd, (MYFLT *) p->buf.auxp, p->buf_pos); - else - // sflib_write_MYFLT(p->f.sf, (MYFLT *) p->buf.auxp, p->buf_pos); + OUTFILEA *p = (OUTFILEA*) p_; + if (p->f.sf != NULL && p->buf_pos > 0) { + if (p->f.async == 1) + csound->WriteAsync(csound, p->f.fd, (MYFLT *) p->buf.auxp, p->buf_pos); + else + // sflib_write_MYFLT(p->f.sf, (MYFLT *) p->buf.auxp, p->buf_pos); csound->SndfileWrite(csound, p->f.sf, (MYFLT *) p->buf.auxp, p->buf_pos/p->tabin->sizes[0]); // in frames - } - return OK; + } + return fout_deinit(csound, &(p->f)); } -static int32_t outfile_set_S(CSOUND *csound, OUTFILE *p/*, int32_t istring*/) +static int32_t outfile_set_S(CSOUND *csound, OUTFILE *p) { - SFLIB_INFO sfinfo; - int32_t format_, n, buf_reqd; - int32_t istring = 1; - STDOPCOD_GLOBALS *pp = (STDOPCOD_GLOBALS*) csound->QueryGlobalVariable(csound, - "STDOPC_GLOBALS"); - - p->f.head = p->h.insdshead; - - memset(&sfinfo, 0, sizeof(SFLIB_INFO)); - format_ = (int32_t) MYFLT2LRND(*p->iflag); - if (format_ >= 51) - sfinfo.format = AE_SHORT | TYP2SF(TYP_RAW); - else if (format_ < 0) { - sfinfo.format = FORMAT2SF(pp->oparms.outformat); - sfinfo.format |= TYPE2SF(pp->oparms.filetyp); - } - else sfinfo.format = fout_format_table[format_]; - if (!SF2FORMAT(sfinfo.format)) - sfinfo.format |= FORMAT2SF(pp->oparms.outformat); - if (!SF2TYPE(sfinfo.format)) - sfinfo.format |= TYPE2SF(pp->oparms.filetyp); - sfinfo.samplerate = (int32_t) MYFLT2LRND(CS_ESR); - p->nargs = p->INOCOUNT - 2; - p->buf_pos = 0; - - if (CS_KSMPS >= 512) - p->guard_pos = CS_KSMPS * p->nargs; - else - p->guard_pos = 512* p->nargs; - - if (CS_KSMPS >= 512) - buf_reqd = CS_KSMPS * p->nargs; - else - buf_reqd = (1 + (int32_t)(512 / CS_KSMPS)) * CS_KSMPS * p->nargs; - if (p->buf.auxp == NULL || p->buf.size < buf_reqd*sizeof(MYFLT)) { - csound->AuxAlloc(csound, sizeof(MYFLT)*buf_reqd, &p->buf); - } - p->f.bufsize = p->buf.size; - sfinfo.channels = p->nargs; - n = fout_open_file(csound, &(p->f), NULL, CSFILE_SND_W, - p->fname, istring, &sfinfo, 0); - if (UNLIKELY(n < 0)) - return NOTOK; - - if (pp->file_opened[n].do_scale) - p->scaleFac = (FL(1.)/csound->Get0dBFS(csound)); - else - p->scaleFac = FL(1.0); - - csound->RegisterDeinitCallback(csound, p, fout_flush_callback); - return OK; + SFLIB_INFO sfinfo; + int32_t format_, n, buf_reqd; + int32_t istring = 1; + STDOPCOD_GLOBALS *pp = (STDOPCOD_GLOBALS*) csound->QueryGlobalVariable(csound, + "STDOPC_GLOBALS"); + + memset(&sfinfo, 0, sizeof(SFLIB_INFO)); + format_ = (int32_t) MYFLT2LRND(*p->iflag); + if (format_ >= 51) + sfinfo.format = AE_SHORT | TYP2SF(TYP_RAW); + else if (format_ < 0) { + sfinfo.format = FORMAT2SF(pp->oparms.outformat); + sfinfo.format |= TYPE2SF(pp->oparms.filetyp); + } + else sfinfo.format = fout_format_table[format_]; + if (!SF2FORMAT(sfinfo.format)) + sfinfo.format |= FORMAT2SF(pp->oparms.outformat); + if (!SF2TYPE(sfinfo.format)) + sfinfo.format |= TYPE2SF(pp->oparms.filetyp); + sfinfo.samplerate = (int32_t) MYFLT2LRND(CS_ESR); + p->nargs = p->INOCOUNT - 2; + p->buf_pos = 0; + + if (CS_KSMPS >= 512) + p->guard_pos = CS_KSMPS * p->nargs; + else + p->guard_pos = 512* p->nargs; + + if (CS_KSMPS >= 512) + buf_reqd = CS_KSMPS * p->nargs; + else + buf_reqd = (1 + (int32_t)(512 / CS_KSMPS)) * CS_KSMPS * p->nargs; + if (p->buf.auxp == NULL || p->buf.size < buf_reqd*sizeof(MYFLT)) { + csound->AuxAlloc(csound, sizeof(MYFLT)*buf_reqd, &p->buf); + } + p->f.bufsize = p->buf.size; + sfinfo.channels = p->nargs; + if(fout_open_file(csound, &(p->f), NULL, CSFILE_SND_W, + p->fname, istring, &sfinfo, 0) != NULL) + n = p->f.idx - 1; + else return NOTOK; + + if (pp->file_opened[n].do_scale) + p->scaleFac = (FL(1.)/csound->Get0dBFS(csound)); + else + p->scaleFac = FL(1.0); + return OK; } -/* static int32_t outfile_set(CSOUND *csound, OUTFILE *p){ */ -/* return outfile_set_(csound,p,0); */ -/* } */ - -/* static int32_t outfile_set_S(CSOUND *csound, OUTFILE *p){ */ -/* return outfile_set_(csound,p,1); */ -/* } */ - static int32_t outfile_set_A(CSOUND *csound, OUTFILEA *p) { - SFLIB_INFO sfinfo; - int32_t format_, n, buf_reqd; - int32_t len = p->tabin->sizes[0]; - STDOPCOD_GLOBALS *pp = (STDOPCOD_GLOBALS*) csound->QueryGlobalVariable(csound, - "STDOPC_GLOBALS"); - - p->f.head = p->h.insdshead; - memset(&sfinfo, 0, sizeof(SFLIB_INFO)); - format_ = (int32_t) MYFLT2LRND(*p->iflag); - if (format_ >= 51) - sfinfo.format = AE_SHORT | TYP2SF(TYP_RAW); - else if (format_ < 0) { - sfinfo.format = FORMAT2SF(pp->oparms.outformat); - sfinfo.format |= TYPE2SF(pp->oparms.filetyp); - } - else - sfinfo.format = fout_format_table[format_]; - if (!SF2FORMAT(sfinfo.format)) - sfinfo.format |= FORMAT2SF(pp->oparms.outformat); - if (!SF2TYPE(sfinfo.format)) - sfinfo.format |= TYPE2SF(pp->oparms.filetyp); - sfinfo.samplerate = (int32_t) MYFLT2LRND(CS_ESR); - p->buf_pos = 0; - - if (CS_KSMPS >= 512) - buf_reqd = p->guard_pos = CS_KSMPS * len; - else { - p->guard_pos = 512 * len; - buf_reqd = (1 + (int32_t)(512 / CS_KSMPS)) * p->guard_pos; - // Or...... - //buf_reqd = (1 + (int32_t)(512 / CS_KSMPS)) * CS_KSMPS * len; - } - if (p->buf.auxp == NULL || p->buf.size < buf_reqd*sizeof(MYFLT)) { - csound->AuxAlloc(csound, sizeof(MYFLT)*buf_reqd, &p->buf); - } - p->f.bufsize = p->buf.size; - sfinfo.channels = len; - n = fout_open_file(csound, &(p->f), NULL, CSFILE_SND_W, - p->fname, 1, &sfinfo, 0); - if (UNLIKELY(n < 0)) - return NOTOK; - - if (pp->file_opened[n].do_scale) - p->scaleFac = (FL(1.)/csound->Get0dBFS(csound)); - else - p->scaleFac = FL(1.0); - - csound->RegisterDeinitCallback(csound, p, fouta_flush_callback); - return OK; + SFLIB_INFO sfinfo; + int32_t format_, n, buf_reqd; + int32_t len = p->tabin->sizes[0]; + STDOPCOD_GLOBALS *pp = (STDOPCOD_GLOBALS*) csound->QueryGlobalVariable(csound, + "STDOPC_GLOBALS"); + + + memset(&sfinfo, 0, sizeof(SFLIB_INFO)); + format_ = (int32_t) MYFLT2LRND(*p->iflag); + if (format_ >= 51) + sfinfo.format = AE_SHORT | TYP2SF(TYP_RAW); + else if (format_ < 0) { + sfinfo.format = FORMAT2SF(pp->oparms.outformat); + sfinfo.format |= TYPE2SF(pp->oparms.filetyp); + } + else + sfinfo.format = fout_format_table[format_]; + if (!SF2FORMAT(sfinfo.format)) + sfinfo.format |= FORMAT2SF(pp->oparms.outformat); + if (!SF2TYPE(sfinfo.format)) + sfinfo.format |= TYPE2SF(pp->oparms.filetyp); + sfinfo.samplerate = (int32_t) MYFLT2LRND(CS_ESR); + p->buf_pos = 0; + + + if (CS_KSMPS >= 512) + buf_reqd = p->guard_pos = CS_KSMPS * len; + else { + p->guard_pos = 512 * len; + buf_reqd = (1 + (int32_t)(512 / CS_KSMPS)) * p->guard_pos; + } + if (p->buf.auxp == NULL || p->buf.size < buf_reqd*sizeof(MYFLT)) { + csound->AuxAlloc(csound, sizeof(MYFLT)*buf_reqd, &p->buf); + } + p->f.bufsize = p->buf.size; + sfinfo.channels = len; + if(fout_open_file(csound, &(p->f), NULL, CSFILE_SND_W, + p->fname, 1, &sfinfo, 0) != NULL){ + n = p->f.idx - 1; + } + else return NOTOK; + + if (pp->file_opened[n].do_scale) + p->scaleFac = (FL(1.)/csound->Get0dBFS(csound)); + else + p->scaleFac = FL(1.0); + return OK; } static int32_t koutfile(CSOUND *csound, KOUTFILE *p) { - int32_t i, k; - int32_t nargs = p->nargs; - MYFLT *buf = (MYFLT *) p->buf.auxp; + int32_t i, k; + int32_t nargs = p->nargs; + MYFLT *buf = (MYFLT *) p->buf.auxp; + + for (i = 0, k = p->buf_pos; i < nargs; i++) + buf[k++] = p->argums[i][0] * p->scaleFac; + p->buf_pos = k; + if (p->buf_pos >= p->guard_pos) { + if (p->f.async==1) + csound->WriteAsync(csound, p->f.fd, buf, p->buf_pos); + else //sflib_write_MYFLT(p->f.sf, buf, p->buf_pos); + csound->SndfileWrite(csound, p->f.sf, (MYFLT *) buf, p->buf_pos/nargs); // in frames + p->buf_pos = 0; + } + return OK; +} - for (i = 0, k = p->buf_pos; i < nargs; i++) - buf[k++] = p->argums[i][0] * p->scaleFac; - p->buf_pos = k; - if (p->buf_pos >= p->guard_pos) { - //#ifndef USE_DOUBLE - //sflib_write_float(p->f.sf, buf, p->buf_pos); - //#else - //sflib_write_double(p->f.sf, buf, p->buf_pos); - //#endif - if (p->f.async==1) - csound->WriteAsync(csound, p->f.fd, buf, p->buf_pos); - else //sflib_write_MYFLT(p->f.sf, buf, p->buf_pos); - csound->SndfileWrite(csound, p->f.sf, (MYFLT *) buf, p->buf_pos/nargs); // in frames - p->buf_pos = 0; - } - return OK; +int32_t koutfile_deinit(CSOUND *csound, KOUTFILE *p) { + return fout_deinit(csound, &(p->f)); } static int32_t koutfile_set_(CSOUND *csound, KOUTFILE *p, int32_t istring) { - SFLIB_INFO sfinfo; - int32_t format_, n, buf_reqd; - - p->f.head = p->h.insdshead; - memset(&sfinfo, 0, sizeof(SFLIB_INFO)); - p->nargs = p->INOCOUNT - 2; - p->buf_pos = 0; - - if (CS_KSMPS >= 512) - p->guard_pos = CS_KSMPS * p->nargs; - else - p->guard_pos = 512 * p->nargs; - - sfinfo.channels = p->nargs; - sfinfo.samplerate = (int32_t) MYFLT2LRND(CS_EKR); - format_ = (int32_t) MYFLT2LRND(*p->iflag); - if ((uint32_t) format_ >= 10ul) - sfinfo.format = AE_SHORT | TYP2SF(TYP_RAW); - else - sfinfo.format = fout_format_table[format_] | TYP2SF(TYP_RAW); - - if (CS_KSMPS >= 512) - buf_reqd = CS_KSMPS * p->nargs; - else - buf_reqd = (1 + (int32_t)(512 / CS_KSMPS)) * CS_KSMPS * p->nargs; - if (p->buf.auxp == NULL || p->buf.size < buf_reqd*sizeof(MYFLT)) { - csound->AuxAlloc(csound, sizeof(MYFLT)*buf_reqd, &p->buf); - } - p->f.bufsize = p->buf.size; - n = fout_open_file(csound, &(p->f), NULL, CSFILE_SND_W, - p->fname, istring, &sfinfo, 0); - if (UNLIKELY(n < 0)) - return NOTOK; - - if (((STDOPCOD_GLOBALS*) csound->QueryGlobalVariable(csound,"STDOPC_GLOBALS"))->file_opened[n].do_scale) - p->scaleFac = (FL(1.)/csound->Get0dBFS(csound)); - else - p->scaleFac = FL(1.0); - - csound->RegisterDeinitCallback(csound, p, fout_flush_callback); - return OK; + SFLIB_INFO sfinfo; + int32_t format_, n, buf_reqd; + + memset(&sfinfo, 0, sizeof(SFLIB_INFO)); + p->nargs = p->INOCOUNT - 2; + p->buf_pos = 0; + + if (CS_KSMPS >= 512) + p->guard_pos = CS_KSMPS * p->nargs; + else + p->guard_pos = 512 * p->nargs; + + sfinfo.channels = p->nargs; + sfinfo.samplerate = (int32_t) MYFLT2LRND(CS_EKR); + format_ = (int32_t) MYFLT2LRND(*p->iflag); + if ((uint32_t) format_ >= 10ul) + sfinfo.format = AE_SHORT | TYP2SF(TYP_RAW); + else + sfinfo.format = fout_format_table[format_] | TYP2SF(TYP_RAW); + + if (CS_KSMPS >= 512) + buf_reqd = CS_KSMPS * p->nargs; + else + buf_reqd = (1 + (int32_t)(512 / CS_KSMPS)) * CS_KSMPS * p->nargs; + if (p->buf.auxp == NULL || p->buf.size < buf_reqd*sizeof(MYFLT)) { + csound->AuxAlloc(csound, sizeof(MYFLT)*buf_reqd, &p->buf); + } + p->f.bufsize = p->buf.size; + if(fout_open_file(csound, &(p->f), NULL, CSFILE_SND_W, + p->fname, istring, &sfinfo, 0) != NULL) + n = p->f.idx - 1; + else return NOTOK; + + if (((STDOPCOD_GLOBALS*) csound->QueryGlobalVariable(csound,"STDOPC_GLOBALS"))->file_opened[n].do_scale) + p->scaleFac = (FL(1.)/csound->Get0dBFS(csound)); + else + p->scaleFac = FL(1.0); + return OK; } static int32_t koutfile_set(CSOUND *csound, KOUTFILE *p){ @@ -627,885 +564,846 @@ static int32_t koutfile_set_S(CSOUND *csound, KOUTFILE *p){ return koutfile_set_(csound,p,1); } - -/*--------------*/ - /* syntax: - ihandle fiopen "filename" [, iascii] + ihandle fiopen "filename" [, iascii] */ +int32_t fiopen_deinit(CSOUND *csound, FIOPEN *p) { + if(p->f) { + fout_deinit(csound, p->f); + p->f = NULL; + } + return OK; +} /* open a file and return its handle */ /* the handle is simply a stack index */ static int32_t fiopen_(CSOUND *csound, FIOPEN *p, int32_t istring) { - char *omodes[] = {"w", "r", "wb", "rb"}; - FILE *rfp = (FILE*) NULL; - int32_t idx = (int32_t) MYFLT2LRND(*p->iascii), n; - - if (idx < 0 || idx > 3) - idx = 0; - n = fout_open_file(csound, (FOUT_FILE*) NULL, &rfp, CSFILE_STD, - p->fname, istring, omodes[idx], 1); - if (UNLIKELY(n < 0)) - return NOTOK; - if (idx > 1) - setbuf(rfp, NULL); - *p->ihandle = (MYFLT) n; - - return OK; + char *omodes[] = {"w", "r", "wb", "rb"}; + FILE *rfp = (FILE*) NULL; + int32_t idx = (int32_t) MYFLT2LRND(*p->iascii), n; + + if (idx < 0 || idx > 3) + idx = 0; + p->f = fout_open_file(csound, (FOUT_FILE*) NULL, &rfp, CSFILE_STD, + p->fname, istring, omodes[idx], 1); + if(p->f != NULL) n = p->f->idx - 1; + else return NOTOK; + + if (idx > 1) + setbuf(rfp, NULL); + *p->ihandle = (MYFLT) n; + + return OK; } static int32_t fiopen(CSOUND *csound, FIOPEN *p){ - return fiopen_(csound, p, 0); + return fiopen_(csound, p, 0); } static int32_t fiopen_S(CSOUND *csound, FIOPEN *p){ - return fiopen_(csound, p, 1); + return fiopen_(csound, p, 1); } static int32_t ficlose_opcode_(CSOUND *csound, FICLOSE *p, int32_t istring) { STDOPCOD_GLOBALS *pp = (STDOPCOD_GLOBALS*) csound->QueryGlobalVariable(csound,"STDOPC_GLOBALS"); - int32_t idx = -1; - - if (istring || csound->ISSTRCOD(*(p->iFile))) { - char *fname = NULL; - if (istring) fname = csound->Strdup(csound, ((STRINGDAT *)p->iFile)->data); - else if (csound->ISSTRCOD(*(p->iFile))) - fname = csound->Strdup(csound, csound->GetString(csound, *p->iFile)); - if (UNLIKELY(fname == NULL || fname[0] == (char) 0)) { - if (fname != NULL) csound->Free(csound, fname); - return csound->InitError(csound, "%s", Str("invalid file name")); - } - for (idx = 0; idx <= pp->file_num; idx++) { - if (pp->file_opened[idx].fd != NULL && - pp->file_opened[idx].name != (char*) NULL && - strcmp(fname, pp->file_opened[idx].name) == 0) - break; - } - if (UNLIKELY(idx > pp->file_num)) { - csound->Warning(csound, Str("cannot close '%s': " - "not found in list of open files"), fname); - csound->Free(csound, fname); - return OK; - } - csound->Free(csound, fname); + int32_t idx = -1; + + if (istring || csound->ISSTRCOD(*(p->iFile))) { + char *fname = NULL; + if (istring) fname = csound->Strdup(csound, ((STRINGDAT *)p->iFile)->data); + else if (csound->ISSTRCOD(*(p->iFile))) + fname = csound->Strdup(csound, csound->GetString(csound, *p->iFile)); + if (UNLIKELY(fname == NULL || fname[0] == (char) 0)) { + if (fname != NULL) csound->Free(csound, fname); + return csound->InitError(csound, "%s", Str("invalid file name")); } - else { - idx = (int32_t) MYFLT2LRND(*(p->iFile)); - if (UNLIKELY(idx < 0 || idx > pp->file_num || - pp->file_opened[idx].fd == NULL)) { - csound->Warning(csound, - Str("cannot close file #%d: not a valid handle"), idx); - return OK; - } + for (idx = 0; idx <= pp->file_num; idx++) { + if (pp->file_opened[idx].fd != NULL && + pp->file_opened[idx].name != (char*) NULL && + strcmp(fname, pp->file_opened[idx].name) == 0) + break; } - if (pp->file_opened[idx].refCount) { - if (UNLIKELY(!(pp->file_opened[idx].refCount & 0x80000000U))) { - pp->file_opened[idx].refCount |= 0x80000000U; - csound->Warning(csound, Str("file #%d (%s) is in use, will be closed " - "when released"), - idx, pp->file_opened[idx].name); - } + if (UNLIKELY(idx > pp->file_num)) { + csound->Warning(csound, Str("cannot close '%s': " + "not found in list of open files"), fname); + csound->Free(csound, fname); + return OK; } - else { - FOUT_FILE tmp; - pp->file_opened[idx].refCount = 1; - /*ref count was set to 0x80000001U, but it needs to be 1 */ - memset(&tmp, 0, sizeof(FOUT_FILE)); - tmp.h.insdshead = p->h.insdshead; - tmp.idx = idx + 1; - fout_deinit_callback(csound, (void*) &tmp); + csound->Free(csound, fname); + } + else { + idx = (int32_t) MYFLT2LRND(*(p->iFile)); + if (UNLIKELY(idx < 0 || idx > pp->file_num || + pp->file_opened[idx].fd == NULL)) { + csound->Warning(csound, + Str("cannot close file #%d: not a valid handle"), idx); + return OK; } - - return OK; + } + if (pp->file_opened[idx].refCount) { + if (UNLIKELY(!(pp->file_opened[idx].refCount & 0x80000000U))) { + pp->file_opened[idx].refCount |= 0x80000000U; + csound->Warning(csound, Str("file #%d (%s) is in use, will be closed " + "when released"), + idx, pp->file_opened[idx].name); + } + } + else { + FOUT_FILE tmp; + pp->file_opened[idx].refCount = 1; + memset(&tmp, 0, sizeof(FOUT_FILE)); + tmp.h.insdshead = p->h.insdshead; + tmp.idx = idx + 1; + tmp.need_deinit = 1; + fout_deinit(csound, (void*) &tmp); + } + + return OK; } static int32_t ficlose_opcode(CSOUND *csound, FICLOSE *p){ - return ficlose_opcode_(csound,p,0); + return ficlose_opcode_(csound,p,0); } static int32_t ficlose_opcode_S(CSOUND *csound, FICLOSE *p){ - return ficlose_opcode_(csound,p,1); + return ficlose_opcode_(csound,p,1); } /* syntax: fouti ihandle, iascii, iflag, iarg1 [, iarg2, ...., iargN] */ - static int32_t ioutfile_set(CSOUND *csound, IOUTFILE *p) { - STDOPCOD_GLOBALS *pp = (STDOPCOD_GLOBALS*) csound->QueryGlobalVariable(csound,"STDOPC_GLOBALS"); - MYFLT **args = p->argums; - FILE *rfil; - uint32_t j; - int32_t n = (int32_t) MYFLT2LRND(*p->ihandle); - - if (UNLIKELY(n < 0 || n > pp->file_num)) - return csound->InitError(csound, "%s", Str("fouti: invalid file handle")); - rfil = pp->file_opened[n].raw; - if (UNLIKELY(rfil == NULL)) - return csound->InitError(csound, "%s", Str("fouti: invalid file handle")); - if (*p->iascii == 0) { /* ascii format */ - switch ((int32_t) MYFLT2LRND(*p->iflag)) { - case 1: - { /* with prefix (i-statement, p1, p2 and p3) */ - int32_t p1 = (int32_t) p->h.insdshead->p1.value; - double p2 = (double) CS_KCNT * CS_ONEDKR; - double p3 = p->h.insdshead->p3.value; - if (p3 > FL(0.0)) - fprintf(rfil, "i %i %f %f ", p1, p2, p3); - else - fprintf(rfil, "i %i %f . ", p1, p2); - } - break; - case 2: /* with prefix (start at 0 time) */ - if (pp->fout_kreset == 0) - pp->fout_kreset = CS_KCNT; - { - int32_t p1 = (int32_t) p->h.insdshead->p1.value; - double p2 = (double) (CS_KCNT - pp->fout_kreset) - * CS_ONEDKR; - double p3 = p->h.insdshead->p3.value; - if (p3 > FL(0.0)) - fprintf(rfil, "i %i %f %f ", p1, p2, p3); - else - fprintf(rfil, "i %i %f . ", p1, p2); - } - break; - case 3: /* reset */ - pp->fout_kreset = 0; - return OK; + STDOPCOD_GLOBALS *pp = (STDOPCOD_GLOBALS*) csound->QueryGlobalVariable(csound,"STDOPC_GLOBALS"); + MYFLT **args = p->argums; + FILE *rfil; + uint32_t j; + int32_t n = (int32_t) MYFLT2LRND(*p->ihandle); + + if (UNLIKELY(n < 0 || n > pp->file_num)) + return csound->InitError(csound, "%s", Str("fouti: invalid file handle")); + rfil = pp->file_opened[n].raw; + if (UNLIKELY(rfil == NULL)) + return csound->InitError(csound, "%s", Str("fouti: invalid file handle")); + if (*p->iascii == 0) { /* ascii format */ + switch ((int32_t) MYFLT2LRND(*p->iflag)) { + case 1: + { /* with prefix (i-statement, p1, p2 and p3) */ + int32_t p1 = (int32_t) p->h.insdshead->p1.value; + double p2 = (double) CS_KCNT * CS_ONEDKR; + double p3 = p->h.insdshead->p3.value; + if (p3 > FL(0.0)) + fprintf(rfil, "i %i %f %f ", p1, p2, p3); + else + fprintf(rfil, "i %i %f . ", p1, p2); } - for (j = 0; j < p->INOCOUNT - 3; j++) { - fprintf(rfil, " %f", (double) *args[j]); + break; + case 2: /* with prefix (start at 0 time) */ + if (pp->fout_kreset == 0) + pp->fout_kreset = CS_KCNT; + { + int32_t p1 = (int32_t) p->h.insdshead->p1.value; + double p2 = (double) (CS_KCNT - pp->fout_kreset) + * CS_ONEDKR; + double p3 = p->h.insdshead->p3.value; + if (p3 > FL(0.0)) + fprintf(rfil, "i %i %f %f ", p1, p2, p3); + else + fprintf(rfil, "i %i %f . ", p1, p2); } - putc('\n', rfil); + break; + case 3: /* reset */ + pp->fout_kreset = 0; + return OK; } - else { /* binary format */ - for (j = 0; j < p->INOCOUNT - 3; j++) { - if (UNLIKELY(1!=fwrite(args[j], sizeof(MYFLT), 1, rfil))) return NOTOK; - } + for (j = 0; j < p->INOCOUNT - 3; j++) { + fprintf(rfil, " %f", (double) *args[j]); } - return OK; + putc('\n', rfil); + } + else { /* binary format */ + for (j = 0; j < p->INOCOUNT - 3; j++) { + if (UNLIKELY(1!=fwrite(args[j], sizeof(MYFLT), 1, rfil))) return NOTOK; + } + } + return OK; } static int32_t ioutfile_set_r(CSOUND *csound, IOUTFILE_R *p) { - STDOPCOD_GLOBALS *pp = (STDOPCOD_GLOBALS*) csound->QueryGlobalVariable(csound,"STDOPC_GLOBALS"); - if (p->h.insdshead->xtratim < 1) - p->h.insdshead->xtratim = 1; - p->counter = CS_KCNT; - p->done = 1; - if (*p->iflag == 2 && pp->fout_kreset == 0) - pp->fout_kreset = CS_KCNT; - return OK; + STDOPCOD_GLOBALS *pp = (STDOPCOD_GLOBALS*) csound->QueryGlobalVariable(csound,"STDOPC_GLOBALS"); + if (p->h.insdshead->xtratim < 1) + p->h.insdshead->xtratim = 1; + p->counter = CS_KCNT; + p->done = 1; + if (*p->iflag == 2 && pp->fout_kreset == 0) + pp->fout_kreset = CS_KCNT; + return OK; } static int32_t ioutfile_r(CSOUND *csound, IOUTFILE_R *p) { - STDOPCOD_GLOBALS *pp; - MYFLT **args; - FILE *rfil; - uint32_t j; - int32_t n; + STDOPCOD_GLOBALS *pp; + MYFLT **args; + FILE *rfil; + uint32_t j; + int32_t n; - if (!p->h.insdshead->relesing || !p->done) - return OK; + if (!p->h.insdshead->relesing || !p->done) + return OK; - pp = (STDOPCOD_GLOBALS*) csound->QueryGlobalVariable(csound,"STDOPC_GLOBALS"); - args = p->argums; - n = (int32_t) MYFLT2LRND(*p->ihandle); - if (UNLIKELY(n < 0 || n > pp->file_num)) - return csound->InitError(csound, "%s", Str("fouti: invalid file handle")); - rfil = pp->file_opened[n].raw; - if (UNLIKELY(rfil == NULL)) - return csound->InitError(csound, "%s", Str("fouti: invalid file handle")); - if (*p->iascii == 0) { /* ascii format */ - switch ((int32_t) MYFLT2LRND(*p->iflag)) { - case 1: - { /* whith prefix (i-statement, p1, p2 and p3) */ - int32_t p1 = (int32_t) p->h.insdshead->p1.value; - double p2 = p->counter * CS_ONEDKR; - double p3 = (double) (CS_KCNT - p->counter) - * CS_ONEDKR; - fprintf(rfil, "i %i %f %f ", p1, p2, p3); - } - break; - case 2: /* with prefix (start at 0 time) */ - { - int32_t p1 = (int32_t) p->h.insdshead->p1.value; - double p2 = (p->counter - pp->fout_kreset) * CS_ONEDKR; - double p3 = (double) (CS_KCNT - p->counter) - * CS_ONEDKR; - fprintf(rfil, "i %i %f %f ", p1, p2, p3); - } - break; - case 3: /* reset */ - pp->fout_kreset = 0; - return OK; + pp = (STDOPCOD_GLOBALS*) csound->QueryGlobalVariable(csound,"STDOPC_GLOBALS"); + args = p->argums; + n = (int32_t) MYFLT2LRND(*p->ihandle); + if (UNLIKELY(n < 0 || n > pp->file_num)) + return csound->InitError(csound, "%s", Str("fouti: invalid file handle")); + rfil = pp->file_opened[n].raw; + if (UNLIKELY(rfil == NULL)) + return csound->InitError(csound, "%s", Str("fouti: invalid file handle")); + if (*p->iascii == 0) { /* ascii format */ + switch ((int32_t) MYFLT2LRND(*p->iflag)) { + case 1: + { /* whith prefix (i-statement, p1, p2 and p3) */ + int32_t p1 = (int32_t) p->h.insdshead->p1.value; + double p2 = p->counter * CS_ONEDKR; + double p3 = (double) (CS_KCNT - p->counter) + * CS_ONEDKR; + fprintf(rfil, "i %i %f %f ", p1, p2, p3); } - for (j = 0; j < p->INOCOUNT - 3; j++) { - fprintf(rfil, " %f", (double) *args[j]); + break; + case 2: /* with prefix (start at 0 time) */ + { + int32_t p1 = (int32_t) p->h.insdshead->p1.value; + double p2 = (p->counter - pp->fout_kreset) * CS_ONEDKR; + double p3 = (double) (CS_KCNT - p->counter) + * CS_ONEDKR; + fprintf(rfil, "i %i %f %f ", p1, p2, p3); } - putc('\n', rfil); + break; + case 3: /* reset */ + pp->fout_kreset = 0; + return OK; } - else { /* binary format */ - for (j = 0; j < p->INOCOUNT - 3; j++) { - if (UNLIKELY(1!=fwrite(args[j], sizeof(MYFLT), 1, rfil))) return NOTOK; - } + for (j = 0; j < p->INOCOUNT - 3; j++) { + fprintf(rfil, " %f", (double) *args[j]); + } + putc('\n', rfil); + } + else { /* binary format */ + for (j = 0; j < p->INOCOUNT - 3; j++) { + if (UNLIKELY(1!=fwrite(args[j], sizeof(MYFLT), 1, rfil))) return NOTOK; } - p->done = 0; + } + p->done = 0; - return OK; + return OK; } -/*----------------------------------*/ +int32_t infile_deinit(CSOUND *csound, INFILE *p) { + return fout_deinit(csound, &(p->f)); +} static int32_t infile_set_(CSOUND *csound, INFILE *p, int32_t istring) { - SFLIB_INFO sfinfo; - int32_t n, buf_reqd; - p->f.head = p->h.insdshead; - p->nargs = p->INOCOUNT - 3; - p->currpos = MYFLT2LRND(*p->iskpfrms); - p->flag = 1; - memset(&sfinfo, 0, sizeof(SFLIB_INFO)); - sfinfo.samplerate = (int32_t) MYFLT2LRND(CS_ESR); - /* Following code is seriously broken*/ - if ((int32_t) MYFLT2LRND(*p->iflag) == -2) - sfinfo.format = FORMAT2SF(AE_FLOAT) | TYPE2SF(TYP_RAW); - else if ((int32_t) MYFLT2LRND(*p->iflag) == -1) - sfinfo.format = FORMAT2SF(AE_SHORT) | TYPE2SF(TYP_RAW); - else - sfinfo.format = 0; - sfinfo.channels = p->INOCOUNT - 3; - if (CS_KSMPS >= 512) - p->frames = CS_KSMPS; - else - p->frames = (int32_t)(512 / CS_KSMPS) * CS_KSMPS; - if (CS_KSMPS >= 512) - buf_reqd = CS_KSMPS * sfinfo.channels; - else - buf_reqd = (1 + (int32_t)(512 / CS_KSMPS)) * CS_KSMPS * p->nargs; - if (p->buf.auxp == NULL || p->buf.size < buf_reqd*sizeof(MYFLT)) { - csound->AuxAlloc(csound, sizeof(MYFLT)*buf_reqd, &p->buf); - } - p->f.bufsize = p->buf.size; - n = fout_open_file(csound, &(p->f), NULL, CSFILE_SND_R, - p->fname, istring, &sfinfo, 0); - if (UNLIKELY(n < 0)) - return NOTOK; - - if (((STDOPCOD_GLOBALS*) - csound->QueryGlobalVariable(csound,"STDOPC_GLOBALS")) - ->file_opened[n].do_scale) - p->scaleFac = csound->Get0dBFS(csound); - else - p->scaleFac = FL(1.0); - - - - p->guard_pos = p->frames * p->nargs; - p->buf_pos = p->guard_pos; - - if (p->f.async == 1) + SFLIB_INFO sfinfo; + int32_t n, buf_reqd; + p->nargs = p->INOCOUNT - 3; + p->currpos = MYFLT2LRND(*p->iskpfrms); + p->flag = 1; + memset(&sfinfo, 0, sizeof(SFLIB_INFO)); + sfinfo.samplerate = (int32_t) MYFLT2LRND(CS_ESR); + /* Following code is seriously broken*/ + if ((int32_t) MYFLT2LRND(*p->iflag) == -2) + sfinfo.format = FORMAT2SF(AE_FLOAT) | TYPE2SF(TYP_RAW); + else if ((int32_t) MYFLT2LRND(*p->iflag) == -1) + sfinfo.format = FORMAT2SF(AE_SHORT) | TYPE2SF(TYP_RAW); + else + sfinfo.format = 0; + sfinfo.channels = p->INOCOUNT - 3; + if (CS_KSMPS >= 512) + p->frames = CS_KSMPS; + else + p->frames = (int32_t)(512 / CS_KSMPS) * CS_KSMPS; + + + if (CS_KSMPS >= 512) + buf_reqd = CS_KSMPS * sfinfo.channels; + else + buf_reqd = (1 + (int32_t)(512 / CS_KSMPS)) * CS_KSMPS * p->nargs; + if (p->buf.auxp == NULL || p->buf.size < buf_reqd*sizeof(MYFLT)) { + csound->AuxAlloc(csound, sizeof(MYFLT)*buf_reqd, &p->buf); + } + p->f.bufsize = p->buf.size; + if(fout_open_file(csound, &(p->f), NULL, CSFILE_SND_R, + p->fname, istring, &sfinfo, 0) != NULL) { + n = p->f.idx - 1; + } + else return NOTOK; + + if (((STDOPCOD_GLOBALS*) + csound->QueryGlobalVariable(csound,"STDOPC_GLOBALS")) + ->file_opened[n].do_scale) + p->scaleFac = csound->Get0dBFS(csound); + else + p->scaleFac = FL(1.0); + + p->guard_pos = p->frames * p->nargs; + p->buf_pos = p->guard_pos; + + if (p->f.async == 1) csound->FSeekAsync(csound,p->f.fd, p->currpos*p->f.nchnls, SEEK_SET); - return OK; + return OK; } static int32_t infile_set(CSOUND *csound, INFILE *p){ - return infile_set_(csound,p,0); + return infile_set_(csound,p,0); } static int32_t infile_set_S(CSOUND *csound, INFILE *p){ - return infile_set_(csound,p,1); + return infile_set_(csound,p,1); } #include "arrays.h" - +int32_t infilea_deinit(CSOUND *csound, INFILEA *p) { + return fout_deinit(csound, &(p->f)); +} static int32_t infile_set_A(CSOUND *csound, INFILEA *p) { - SFLIB_INFO sfinfo; - int32_t n, buf_reqd; - - p->f.head = p->h.insdshead; - p->currpos = MYFLT2LRND(*p->iskpfrms); - p->flag = 1; - memset(&sfinfo, 0, sizeof(SFLIB_INFO)); - sfinfo.samplerate = (int32_t) MYFLT2LRND(CS_ESR); - if ((int32_t) MYFLT2LRND(*p->iflag) == -2) - sfinfo.format = FORMAT2SF(AE_FLOAT) | TYPE2SF(TYP_RAW); - else if ((int32_t) MYFLT2LRND(*p->iflag) == -1) - sfinfo.format = FORMAT2SF(AE_SHORT) | TYPE2SF(TYP_RAW); - else - sfinfo.format = 0; - sfinfo.channels = p->INOCOUNT - 3; - if (CS_KSMPS >= 512) - p->frames = CS_KSMPS; - else - p->frames = (int32_t)(512 / CS_KSMPS) * CS_KSMPS; - p->chn = sfinfo.channels; - if (CS_KSMPS >= 512) - buf_reqd = CS_KSMPS * sfinfo.channels; - else - buf_reqd = (1 + (int32_t)(512 / CS_KSMPS)) * CS_KSMPS * sfinfo.channels; - if (p->buf.auxp == NULL || p->buf.size < buf_reqd*sizeof(MYFLT)) { - csound->AuxAlloc(csound, sizeof(MYFLT)*buf_reqd, &p->buf); - } - p->f.bufsize = p->buf.size; - n = fout_open_file(csound, &(p->f), NULL, CSFILE_SND_R, - p->fname, 1, &sfinfo, 0); - if (UNLIKELY(n < 0)) - return NOTOK; - - if (((STDOPCOD_GLOBALS*) - csound->QueryGlobalVariable(csound,"STDOPC_GLOBALS")) - ->file_opened[n].do_scale) - p->scaleFac = csound->Get0dBFS(csound); - else - p->scaleFac = FL(1.0); - - p->guard_pos = p->frames * p->chn; - p->buf_pos = p->guard_pos; - if (p->f.async == 1) + SFLIB_INFO sfinfo; + int32_t n, buf_reqd; + p->currpos = MYFLT2LRND(*p->iskpfrms); + p->flag = 1; + memset(&sfinfo, 0, sizeof(SFLIB_INFO)); + sfinfo.samplerate = (int32_t) MYFLT2LRND(CS_ESR); + if ((int32_t) MYFLT2LRND(*p->iflag) == -2) + sfinfo.format = FORMAT2SF(AE_FLOAT) | TYPE2SF(TYP_RAW); + else if ((int32_t) MYFLT2LRND(*p->iflag) == -1) + sfinfo.format = FORMAT2SF(AE_SHORT) | TYPE2SF(TYP_RAW); + else + sfinfo.format = 0; + sfinfo.channels = p->INOCOUNT - 3; + if (CS_KSMPS >= 512) + p->frames = CS_KSMPS; + else + p->frames = (int32_t)(512 / CS_KSMPS) * CS_KSMPS; + p->chn = sfinfo.channels; + if (CS_KSMPS >= 512) + buf_reqd = CS_KSMPS * sfinfo.channels; + else + buf_reqd = (1 + (int32_t)(512 / CS_KSMPS)) * CS_KSMPS * sfinfo.channels; + if (p->buf.auxp == NULL || p->buf.size < buf_reqd*sizeof(MYFLT)) { + csound->AuxAlloc(csound, sizeof(MYFLT)*buf_reqd, &p->buf); + } + p->f.bufsize = p->buf.size; + if(fout_open_file(csound, &(p->f), NULL, CSFILE_SND_R, + p->fname, 1, &sfinfo, 0) != NULL) { + n = p->f.idx - 1; + } + else return NOTOK; + + + if (((STDOPCOD_GLOBALS*) + csound->QueryGlobalVariable(csound,"STDOPC_GLOBALS")) + ->file_opened[n].do_scale) + p->scaleFac = csound->Get0dBFS(csound); + else + p->scaleFac = FL(1.0); + + p->guard_pos = p->frames * p->chn; + p->buf_pos = p->guard_pos; + + if (p->f.async == 1) csound->FSeekAsync(csound,p->f.fd, p->currpos*p->f.nchnls, SEEK_SET); - tabinit(csound, p->tabout, p->chn); - return OK; + tabinit(csound, p->tabout, p->chn); + return OK; } static int32_t infile_act(CSOUND *csound, INFILE *p) { - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t i, k, j = offset; - uint32_t nsmps = CS_KSMPS, ksmps, nargs = p->nargs; - MYFLT *buf = (MYFLT *) p->buf.auxp; - - ksmps = nsmps; - if (UNLIKELY(offset)) - for (i = 0; i < nargs; i++) - memset(p->argums[i], '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - nsmps -= early; - for (i = 0; i < nargs; i++) - memset(&p->argums[i][nsmps], '\0', early*sizeof(MYFLT)); - } - if (p->flag) { - if (p->buf_pos >= p->guard_pos) { - if (UNLIKELY(p->f.async == 0)) { - csound->SndfileSeek(csound, p->f.sf, p->currpos*p->f.nchnls, SEEK_SET); - p->remain = (uint32_t) csound->SndfileRead(csound, p->f.sf, (MYFLT*) buf, - p->frames); - p->remain /= p->f.nchnls; - } else { - p->remain = csound->ReadAsync(csound,p->f.fd,(MYFLT *)buf, + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t i, k, j = offset; + uint32_t nsmps = CS_KSMPS, ksmps, nargs = p->nargs; + MYFLT *buf = (MYFLT *) p->buf.auxp; + + ksmps = nsmps; + if (UNLIKELY(offset)) + for (i = 0; i < nargs; i++) + memset(p->argums[i], '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + nsmps -= early; + for (i = 0; i < nargs; i++) + memset(&p->argums[i][nsmps], '\0', early*sizeof(MYFLT)); + } + if (p->flag) { + if (p->buf_pos >= p->guard_pos) { + if (UNLIKELY(p->f.async == 0)) { + csound->SndfileSeek(csound, p->f.sf, p->currpos*p->f.nchnls, SEEK_SET); + p->remain = (uint32_t) csound->SndfileRead(csound, p->f.sf, (MYFLT*) buf, + p->frames); + p->remain /= p->f.nchnls; + } else { + p->remain = csound->ReadAsync(csound,p->f.fd,(MYFLT *)buf, p->frames*p->f.nchnls); - p->remain /= p->f.nchnls; - } - p->currpos += p->frames; - p->buf_pos = 0; - } - if (p->remain < nsmps) - nsmps = p->remain; - for (k = (uint32_t)p->buf_pos; j < nsmps; j++) - for (i = 0; i < nargs; i++) - p->argums[i][j] = buf[k++] * p->scaleFac; - p->buf_pos = k; - p->remain -= ksmps; - if (p->remain <= 0 && p->buf_pos < p->guard_pos) { - p->flag = 0; - for (; j < ksmps; j++) - for (i = 0; i < nargs; i++) - p->argums[i][j] = FL(0.0); + p->remain /= p->f.nchnls; } - return OK; + p->currpos += p->frames; + p->buf_pos = 0; } - for ( ; j < ksmps; j++) + if (p->remain < nsmps) + nsmps = p->remain; + for (k = (uint32_t)p->buf_pos; j < nsmps; j++) for (i = 0; i < nargs; i++) - p->argums[i][j] = FL(0.0); - + p->argums[i][j] = buf[k++] * p->scaleFac; + p->buf_pos = k; + p->remain -= ksmps; + if (p->remain <= 0 && p->buf_pos < p->guard_pos) { + p->flag = 0; + for (; j < ksmps; j++) + for (i = 0; i < nargs; i++) + p->argums[i][j] = FL(0.0); + } return OK; + } + for ( ; j < ksmps; j++) + for (i = 0; i < nargs; i++) + p->argums[i][j] = FL(0.0); + + return OK; } static int32_t infile_arr(CSOUND *csound, INFILEA *p) { - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t i, k, j = offset; - uint32_t nsmps = CS_KSMPS, ksmps, chn = p->chn; - MYFLT *buf = (MYFLT *) p->buf.auxp; - MYFLT *data = p->tabout->data; - - ksmps = nsmps; - if (UNLIKELY(offset)) - for (i = 0; i < chn; i++) - memset(&data[i*chn], '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - nsmps -= early; - for (i = 0; i < chn; i++) - memset(&data[i*chn+nsmps], '\0', early*sizeof(MYFLT)); - } - if (p->flag) { - if (p->buf_pos >= p->guard_pos) { - if (UNLIKELY(p->f.async == 0)) { - csound->SndfileSeek(csound,p->f.sf, p->currpos*p->f.nchnls, SEEK_SET); - p->remain = (uint32_t) csound->SndfileRead(csound, p->f.sf, (MYFLT*) buf, - p->frames); - p->remain /= p->f.nchnls; - } else { - p->remain = csound->ReadAsync(csound,p->f.fd,(MYFLT *)buf, + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t i, k, j = offset; + uint32_t nsmps = CS_KSMPS, ksmps, chn = p->chn; + MYFLT *buf = (MYFLT *) p->buf.auxp; + MYFLT *data = p->tabout->data; + + ksmps = nsmps; + if (UNLIKELY(offset)) + for (i = 0; i < chn; i++) + memset(&data[i*chn], '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + nsmps -= early; + for (i = 0; i < chn; i++) + memset(&data[i*chn+nsmps], '\0', early*sizeof(MYFLT)); + } + if (p->flag) { + if (p->buf_pos >= p->guard_pos) { + if (UNLIKELY(p->f.async == 0)) { + csound->SndfileSeek(csound,p->f.sf, p->currpos*p->f.nchnls, SEEK_SET); + p->remain = (uint32_t) csound->SndfileRead(csound, p->f.sf, (MYFLT*) buf, + p->frames); + p->remain /= p->f.nchnls; + } else { + p->remain = csound->ReadAsync(csound,p->f.fd,(MYFLT *)buf, p->frames*p->f.nchnls); - p->remain /= p->f.nchnls; - } - p->currpos += p->frames; - p->buf_pos = 0; - } - if (p->remain < nsmps) - nsmps = p->remain; - for (k = (uint32_t)p->buf_pos; j < nsmps; j++) - for (i = 0; i < chn; i++) - data[i*chn+j] = buf[k++] * p->scaleFac; - p->buf_pos = k; - p->remain -= ksmps; - if (p->remain <= 0 && p->buf_pos < p->guard_pos) { - p->flag = 0; - for (; j < ksmps; j++) - for (i = 0; i < chn; i++) - data[i*chn+j] = FL(0.0); + p->remain /= p->f.nchnls; } - return OK; + p->currpos += p->frames; + p->buf_pos = 0; } - for ( ; j < ksmps; j++) + if (p->remain < nsmps) + nsmps = p->remain; + for (k = (uint32_t)p->buf_pos; j < nsmps; j++) for (i = 0; i < chn; i++) - data[i*chn+j] = FL(0.0); - + data[i*chn+j] = buf[k++] * p->scaleFac; + p->buf_pos = k; + p->remain -= ksmps; + if (p->remain <= 0 && p->buf_pos < p->guard_pos) { + p->flag = 0; + for (; j < ksmps; j++) + for (i = 0; i < chn; i++) + data[i*chn+j] = FL(0.0); + } return OK; + } + for ( ; j < ksmps; j++) + for (i = 0; i < chn; i++) + data[i*chn+j] = FL(0.0); + + return OK; } /* ---------------------------- */ +int32_t kinfile_deinit(CSOUND *csound, KINFILE *p) { + return fout_deinit(csound, &(p->f)); +} static int32_t kinfile_set_(CSOUND *csound, KINFILE *p, int32_t istring) { - SFLIB_INFO sfinfo; - int32_t n, buf_reqd; - - p->f.head = p->h.insdshead; - memset(&sfinfo, 0, sizeof(SFLIB_INFO)); - sfinfo.samplerate = (int32_t) MYFLT2LRND(CS_EKR); - if ((int32_t) MYFLT2LRND(*p->iflag) == -2) - sfinfo.format = FORMAT2SF(AE_FLOAT) | TYPE2SF(TYP_RAW); - else if ((int32_t) MYFLT2LRND(*p->iflag) == -1) - sfinfo.format = FORMAT2SF(AE_SHORT) | TYPE2SF(TYP_RAW); - else - sfinfo.format = 0; - sfinfo.channels = p->INOCOUNT - 3; - - p->nargs = p->INOCOUNT - 3; - p->currpos = MYFLT2LRND(*p->iskpfrms); - p->flag = 1; - - if (CS_KSMPS >= 512) - p->frames = CS_KSMPS; - else - p->frames = (int32_t)(512 / CS_KSMPS) * CS_KSMPS; - - if (CS_KSMPS >= 512) - buf_reqd = CS_KSMPS * sfinfo.channels; - else - buf_reqd = (1 + (int32_t)(512 / CS_KSMPS)) * CS_KSMPS * p->nargs; - if (p->buf.auxp == NULL || p->buf.size < buf_reqd*sizeof(MYFLT)) { - csound->AuxAlloc(csound, sizeof(MYFLT)*buf_reqd, &p->buf); - } - p->f.bufsize = p->buf.size; - n = fout_open_file(csound, &(p->f), NULL, CSFILE_SND_R, - p->fname, istring, &sfinfo, 0); - if (UNLIKELY(n < 0)) - return NOTOK; - - if (((STDOPCOD_GLOBALS*) - csound->QueryGlobalVariable(csound,"STDOPC_GLOBALS")) - ->file_opened[n].do_scale) - p->scaleFac = csound->Get0dBFS(csound); - else - p->scaleFac = FL(1.0); - - p->guard_pos = p->frames * p->nargs; - p->buf_pos = p->guard_pos; - - if (p->f.async == 1) + SFLIB_INFO sfinfo; + int32_t n, buf_reqd; + + memset(&sfinfo, 0, sizeof(SFLIB_INFO)); + sfinfo.samplerate = (int32_t) MYFLT2LRND(CS_EKR); + if ((int32_t) MYFLT2LRND(*p->iflag) == -2) + sfinfo.format = FORMAT2SF(AE_FLOAT) | TYPE2SF(TYP_RAW); + else if ((int32_t) MYFLT2LRND(*p->iflag) == -1) + sfinfo.format = FORMAT2SF(AE_SHORT) | TYPE2SF(TYP_RAW); + else + sfinfo.format = 0; + sfinfo.channels = p->INOCOUNT - 3; + + p->nargs = p->INOCOUNT - 3; + p->currpos = MYFLT2LRND(*p->iskpfrms); + p->flag = 1; + + if (CS_KSMPS >= 512) + p->frames = CS_KSMPS; + else + p->frames = (int32_t)(512 / CS_KSMPS) * CS_KSMPS; + + if (CS_KSMPS >= 512) + buf_reqd = CS_KSMPS * sfinfo.channels; + else + buf_reqd = (1 + (int32_t)(512 / CS_KSMPS)) * CS_KSMPS * p->nargs; + if (p->buf.auxp == NULL || p->buf.size < buf_reqd*sizeof(MYFLT)) { + csound->AuxAlloc(csound, sizeof(MYFLT)*buf_reqd, &p->buf); + } + p->f.bufsize = p->buf.size; + if(fout_open_file(csound, &(p->f), NULL, CSFILE_SND_R, + p->fname, istring, &sfinfo, 0) != NULL) { + n = p->f.idx - 1; + } + else return NOTOK; + + if (((STDOPCOD_GLOBALS*) + csound->QueryGlobalVariable(csound,"STDOPC_GLOBALS")) + ->file_opened[n].do_scale) + p->scaleFac = csound->Get0dBFS(csound); + else + p->scaleFac = FL(1.0); + + p->guard_pos = p->frames * p->nargs; + p->buf_pos = p->guard_pos; + + if (p->f.async == 1) csound->FSeekAsync(csound,p->f.fd, p->currpos*p->f.nchnls, SEEK_SET); - return OK; + return OK; } static int32_t kinfile_set(CSOUND *csound, KINFILE *p){ - return kinfile_set_(csound,p,0); + return kinfile_set_(csound,p,0); } static int32_t kinfile_set_S(CSOUND *csound, KINFILE *p){ - return kinfile_set_(csound,p,1); + return kinfile_set_(csound,p,1); } static int32_t kinfile(CSOUND *csound, KINFILE *p) { - int32_t i, k; - int32_t nargs = p->nargs; - MYFLT *buf = (MYFLT *) p->buf.auxp; - - if (p->flag) { - if (p->buf_pos >= p->guard_pos) { - if (UNLIKELY(p->f.async == 0)) { - csound->SndfileSeek(csound,p->f.sf, p->currpos*p->f.nchnls, SEEK_SET); - p->remain = (uint32_t) csound->SndfileRead(csound, p->f.sf, (MYFLT*) buf, - p->frames); - p->remain /= p->f.nchnls; - } else { - p->remain = csound->ReadAsync(csound,p->f.fd,(MYFLT *)buf, + int32_t i, k; + int32_t nargs = p->nargs; + MYFLT *buf = (MYFLT *) p->buf.auxp; + + if (p->flag) { + if (p->buf_pos >= p->guard_pos) { + if (UNLIKELY(p->f.async == 0)) { + csound->SndfileSeek(csound,p->f.sf, p->currpos*p->f.nchnls, SEEK_SET); + p->remain = (uint32_t) csound->SndfileRead(csound, p->f.sf, (MYFLT*) buf, + p->frames); + p->remain /= p->f.nchnls; + } else { + p->remain = csound->ReadAsync(csound,p->f.fd,(MYFLT *)buf, p->frames*p->f.nchnls); - p->remain /= p->f.nchnls; - } - p->currpos += p->frames; - p->buf_pos = 0; - } - if (p->remain > 0) { - for (i = 0, k = p->buf_pos; i < nargs; i++) - p->argums[i][0] = buf[k++] * p->scaleFac; - p->buf_pos = k; - p->remain--; - return OK; + p->remain /= p->f.nchnls; } - p->flag = 0; + p->currpos += p->frames; + p->buf_pos = 0; } - for (i = 0; i < nargs; i++) - p->argums[i][0] = FL(0.0); - return OK; + if (p->remain > 0) { + for (i = 0, k = p->buf_pos; i < nargs; i++) + p->argums[i][0] = buf[k++] * p->scaleFac; + p->buf_pos = k; + p->remain--; + return OK; + } + p->flag = 0; + } + for (i = 0; i < nargs; i++) + p->argums[i][0] = FL(0.0); + return OK; +} + +int32_t i_infile_deinit(CSOUND *csound, I_INFILE *p) { + if(p->f) { + fout_deinit(csound, p->f); + p->f = NULL; + } + return OK; } static int32_t i_infile_(CSOUND *csound, I_INFILE *p, int32_t istring) { - int32_t j, n, nargs; - FILE *fp = NULL; - MYFLT **args = p->argums; - char *omodes[] = {"r", "r", "rb"}; - int32_t idx = (int32_t) MYFLT2LRND(*p->iflag); - - if (UNLIKELY(idx < 0 || idx > 2)) - idx = 0; - n = fout_open_file(csound, (FOUT_FILE*) NULL, &fp, CSFILE_STD, - p->fname, istring, omodes[idx], 0); - if (UNLIKELY(n < 0)) - return NOTOK; - - nargs = p->INOCOUNT - 3; - switch ((int32_t) MYFLT2LRND(*p->iflag)) { - case 0: /* ascii file with loop */ - { - char cf[64], *cfp; - int32_t cc; - newcycle: - for (j = 0; j < nargs; j++) { - cfp = cf; - while ((*cfp = cc = getc(fp)) == 'i' || isspace(*cfp)); - if (cc == EOF) { - fseek(fp, 0, SEEK_SET); - goto newcycle; - } - while (isdigit(*cfp) || *cfp == '.' || *cfp == '+' || *cfp == '-') { - *(++cfp) = (char)(cc = getc(fp)); - } - *++cfp = '\0'; /* Must terminate string */ - *(args[j]) = (MYFLT) atof(cf); - if (cc == EOF) { - fseek(fp, 0, SEEK_SET); - break; - } + int32_t j, nargs; + FILE *fp = NULL; + MYFLT **args = p->argums; + char *omodes[] = {"r", "r", "rb"}; + int32_t idx = (int32_t) MYFLT2LRND(*p->iflag); + + p->f = fout_open_file(csound, (FOUT_FILE*) NULL, &fp, CSFILE_STD, + p->fname, istring, omodes[idx], 0); + if(p->f == NULL) return NOTOK; + + nargs = p->INOCOUNT - 3; + switch ((int32_t) MYFLT2LRND(*p->iflag)) { + case 0: /* ascii file with loop */ + { + char cf[64], *cfp; + int32_t cc; + newcycle: + for (j = 0; j < nargs; j++) { + cfp = cf; + while ((*cfp = cc = getc(fp)) == 'i' || isspace(*cfp)); + if (cc == EOF) { + fseek(fp, 0, SEEK_SET); + goto newcycle; } - } - break; - case 1: /* ascii file without loop */ - { - char cf[64], *cfp; - int32_t cc; - for (j = 0; j < nargs; j++) { - cfp = cf; - while ((*cfp = cc = getc(fp)) == 'i' || isspace(*cfp)); - if (cc == EOF) { - *(args[j]) = FL(0.0); - break; - } - while (isdigit(*cfp) || *cfp == '.' || *cfp == '+' || *cfp == '-') { - *(++cfp) = cc = getc(fp); - } - *++cfp = '\0'; /* Must terminate */ - *(args[j]) = (MYFLT) atof (cf); - if (cc == EOF) { - *(args[j]) = FL(0.0); - break; - } + while (isdigit(*cfp) || *cfp == '.' || *cfp == '+' || *cfp == '-') { + *(++cfp) = (char)(cc = getc(fp)); + } + *++cfp = '\0'; /* Must terminate string */ + *(args[j]) = (MYFLT) atof(cf); + if (cc == EOF) { + fseek(fp, 0, SEEK_SET); + break; } } - break; - case 2: /* binary floats without loop */ - if (fseek(fp, p->currpos * sizeof(float) * nargs, SEEK_SET)<0) return NOTOK; - p->currpos++; + } + break; + case 1: /* ascii file without loop */ + { + char cf[64], *cfp; + int32_t cc; for (j = 0; j < nargs; j++) { - if (1 == fread(args[j], sizeof(float), 1, fp)); - else { - p->flag = 0; + cfp = cf; + while ((*cfp = cc = getc(fp)) == 'i' || isspace(*cfp)); + if (cc == EOF) { *(args[j]) = FL(0.0); + break; + } + while (isdigit(*cfp) || *cfp == '.' || *cfp == '+' || *cfp == '-') { + *(++cfp) = cc = getc(fp); + } + *++cfp = '\0'; /* Must terminate */ + *(args[j]) = (MYFLT) atof (cf); + if (cc == EOF) { + *(args[j]) = FL(0.0); + break; } } - break; } - return OK; + break; + case 2: /* binary floats without loop */ + if (fseek(fp, p->currpos * sizeof(float) * nargs, SEEK_SET)<0) return NOTOK; + p->currpos++; + for (j = 0; j < nargs; j++) { + if (1 == fread(args[j], sizeof(float), 1, fp)); + else { + p->flag = 0; + *(args[j]) = FL(0.0); + } + } + break; + } + return OK; } static int32_t i_infile(CSOUND *csound, I_INFILE *p){ - return i_infile_(csound,p,0); + return i_infile_(csound,p,0); } static int32_t i_infile_S(CSOUND *csound, I_INFILE *p){ - return i_infile_(csound,p,1); + return i_infile_(csound,p,1); } - -/*---------------------------*/ - static int32_t incr(CSOUND *csound, INCR *p) { - IGN(csound); - MYFLT *avar = p->avar, *aincr = p->aincr; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t n, nsmps = CS_KSMPS; - - if (UNLIKELY(early)) nsmps -= early; - for (n = offset; n < nsmps; n++) - avar[n] += aincr[n]; - return OK; + IGN(csound); + MYFLT *avar = p->avar, *aincr = p->aincr; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t n, nsmps = CS_KSMPS; + + if (UNLIKELY(early)) nsmps -= early; + for (n = offset; n < nsmps; n++) + avar[n] += aincr[n]; + return OK; } static int32_t clear(CSOUND *csound, CLEARS *p) { - IGN(csound); - uint32_t nsmps = CS_KSMPS, j; + IGN(csound); + uint32_t nsmps = CS_KSMPS, j; - for (j = 0; j < p->INOCOUNT; j++) { - memset(p->argums[j], 0, sizeof(MYFLT)*nsmps); - } - return OK; + for (j = 0; j < p->INOCOUNT; j++) { + memset(p->argums[j], 0, sizeof(MYFLT)*nsmps); + } + return OK; } -/*---------------------------------*/ -/* formatted output to a text file */ +int32_t fprintf_deinit(CSOUND *csound, FPRINTF *p) { + return fout_deinit(csound, &(p->f)); +} static int32_t fprintf_set_(CSOUND *csound, FPRINTF *p, int32_t istring) { - int32_t n; - char *sarg = (char*) p->fmt->data; - char *sdest = p->txtstring; - p->f.head = p->h.insdshead; - - memset(p->txtstring, 0, 8192); /* Nasty to have exposed constant in code */ - - if (p->h.opadr != (SUBR) NULL) /* fprintks */ - n = fout_open_file(csound, &(p->f), NULL, CSFILE_STD, - p->fname, istring, "w", 1); - else /* fprints */ - n = fout_open_file(csound, (FOUT_FILE*) NULL, &(p->f.f), CSFILE_STD, - p->fname, istring, "w", 1); - if (UNLIKELY(n < 0)) - return NOTOK; - //setvbuf(p->f.f, (char*)NULL, _IOLBF, BUFSIZ); /* Seems a good option */ - /* Copy the string to the storage place in PRINTKS. - * - * We will look out for certain special codes and write special - * bytes directly to the string. - * - * There is probably a more elegant way of doing this, then using - * the look flag. I could use goto - but I would rather not. */ - /* This is really a if then else if... - * construct and is currently grotty -- JPff */ - do { - char temp = *sarg++; - char tempn = *sarg--; - /* Look for a single caret and insert an escape char. */ - if ((temp == '^') && (tempn != '^')) { - *sdest++ = 0x1B; /* ESC */ - } - /* Look for a double caret and insert a single caret - - stepping forward one */ - else if ((temp == '^') && (tempn == '^')) { - *sdest++ = '^'; + + char *sarg = (char*) p->fmt->data; + char *sdest = p->txtstring; + FOUT_FILE* pp; + + memset(p->txtstring, 0, 8192); /* Nasty to have exposed constant in code */ + + if (p->h.perf != (SUBR) NULL) /* fprintks */ + pp = fout_open_file(csound, &(p->f), NULL, CSFILE_STD, + p->fname, istring, "w", 1); + else /* fprints */ + pp = fout_open_file(csound, (FOUT_FILE*) NULL, &(p->f.f), CSFILE_STD, + p->fname, istring, "w", 1); + if (UNLIKELY(pp == NULL)) + return NOTOK; + + //setvbuf(p->f.f, (char*)NULL, _IOLBF, BUFSIZ); /* Seems a good option */ + /* Copy the string to the storage place in PRINTKS. + * + * We will look out for certain special codes and write special + * bytes directly to the string. + * + * There is probably a more elegant way of doing this, then using + * the look flag. I could use goto - but I would rather not. */ + /* This is really a if then else if... + * construct and is currently grotty -- JPff */ + do { + char temp = *sarg++; + char tempn = *sarg--; + /* Look for a single caret and insert an escape char. */ + if ((temp == '^') && (tempn != '^')) { + *sdest++ = 0x1B; /* ESC */ + } + /* Look for a double caret and insert a single caret + - stepping forward one */ + else if ((temp == '^') && (tempn == '^')) { + *sdest++ = '^'; + sarg++; + } + /* Look for a single tilde and insert an escape followed by a '['. + * ESC[ is the escape sequence for ANSI consoles */ + else if ((temp == '~') && (tempn != '~')) { + *sdest++ = 0x1B; /* ESC */ + *sdest++ = '['; + } + /* Look for a double tilde and insert a tilde caret + - stepping forward one. */ + else if ((temp == '~') && (tempn == '~')) { + *sdest++ = '~'; + sarg++; + } + /* Look for \n, \N etc */ + else if (temp == '\\') { + switch (tempn) { + case 'r': case 'R': + *sdest++ = '\r'; sarg++; - } - /* Look for a single tilde and insert an escape followed by a '['. - * ESC[ is the escape sequence for ANSI consoles */ - else if ((temp == '~') && (tempn != '~')) { - *sdest++ = 0x1B; /* ESC */ - *sdest++ = '['; - } - /* Look for a double tilde and insert a tilde caret - - stepping forward one. */ - else if ((temp == '~') && (tempn == '~')) { - *sdest++ = '~'; + break; + case 'n': case 'N': + *sdest++ = '\n'; sarg++; + break; + case 't': case 'T': + *sdest++ = '\t'; + sarg++; + break; + case 'a': case 'A': + *sdest++ = '\a'; + sarg++; + break; + case 'b': case 'B': + *sdest++ = '\b'; + sarg++; + break; + case '\\': + *sdest++ = '\\'; + sarg++; + break; + default: + *sdest++ = tempn; + sarg++; + break; } - /* Look for \n, \N etc */ - else if (temp == '\\') { - switch (tempn) { - case 'r': case 'R': - *sdest++ = '\r'; - sarg++; - break; - case 'n': case 'N': - *sdest++ = '\n'; - sarg++; - break; - case 't': case 'T': - *sdest++ = '\t'; - sarg++; - break; - case 'a': case 'A': - *sdest++ = '\a'; - sarg++; - break; - case 'b': case 'B': - *sdest++ = '\b'; - sarg++; - break; - case '\\': - *sdest++ = '\\'; - sarg++; - break; - default: - *sdest++ = tempn; - sarg++; - break; - } - } - else if (temp == '%') { - /* an extra option to specify tab and return as %t and %r */ - switch (tempn) { - case 'r': case 'R': - *sdest++ = '\r'; - sarg++; - break; - case 'n': case 'N': - *sdest++ = '\n'; - sarg++; - break; - case 't': case 'T': - *sdest++ = '\t'; - sarg++; - break; - case '!': /* and a ';' */ - *sdest++ = ';'; - sarg++; - break; - default: - *sdest++ = temp; - break; - } - } - else { - /* If none of these match, then copy the character directly - * and try again. */ + } + else if (temp == '%') { + /* an extra option to specify tab and return as %t and %r */ + switch (tempn) { + case 'r': case 'R': + *sdest++ = '\r'; + sarg++; + break; + case 'n': case 'N': + *sdest++ = '\n'; + sarg++; + break; + case 't': case 'T': + *sdest++ = '\t'; + sarg++; + break; + case '!': /* and a ';' */ + *sdest++ = ';'; + sarg++; + break; + default: *sdest++ = temp; + break; } - /* Increment pointer and process next character until end of string. */ - } while (*++sarg != 0); - return OK; + } + else { + /* If none of these match, then copy the character directly + * and try again. */ + *sdest++ = temp; + } + /* Increment pointer and process next character until end of string. */ + } while (*++sarg != 0); + return OK; } static int32_t fprintf_set(CSOUND *csound, FPRINTF *p){ - return fprintf_set_(csound,p,0); + return fprintf_set_(csound,p,0); } static int32_t fprintf_set_S(CSOUND *csound, FPRINTF *p){ - return fprintf_set_(csound,p,1); + return fprintf_set_(csound,p,1); } - - - /* perform a sprintf-style format -- matt ingalls */ void sprints1(char *outstring, char *fmt, MYFLT **kvals, int32 numVals) { - char strseg[8192]; - int32_t len = 8192; - int32_t i = 0, j = 0; - char *segwaiting = 0; - while (*fmt) { - if (*fmt == '%') { - /* if already a segment waiting, then lets print it */ - if (segwaiting) { - strseg[i] = '\0'; - switch (*segwaiting) { - case '%': - strncpy(outstring, "%%", len); - j--; - break; - case 'd': - case 'i': - case 'o': - case 'x': - case 'X': - case 'u': - case 'c': - snprintf(outstring, len, strseg, (int32_t) MYFLT2LRND(*kvals[j])); - break; - case 'h': - snprintf(outstring, len, strseg, (int16) MYFLT2LRND(*kvals[j])); - break; - case 'l': - snprintf(outstring, len, strseg, (int32) MYFLT2LRND(*kvals[j])); - break; - case 's': - snprintf(outstring, len, strseg, ((STRINGDAT*)(kvals[j]))->data); - break; - default: - snprintf(outstring, len, strseg, *kvals[j]); - break; - } - len -= strlen(outstring); - outstring += strlen(outstring); - i = 0; - segwaiting = 0; - - /* prevent potential problems */ - /* if user didnt give enough input params */ - if (j < numVals-1) - j++; - } - /* copy the '%' */ - strseg[i++] = *fmt++; - - /* find the format code */ - segwaiting = fmt; - while (*segwaiting && !isalpha(*segwaiting) && !(*segwaiting=='%')) - segwaiting++; - } - else - strseg[i++] = *fmt++; - } - - if (i) { - strseg[i] = '\0'; + char strseg[8192]; + int32_t len = 8192; + int32_t i = 0, j = 0; + char *segwaiting = 0; + while (*fmt) { + if (*fmt == '%') { + /* if already a segment waiting, then lets print it */ if (segwaiting) { + strseg[i] = '\0'; switch (*segwaiting) { - case '%': - strncpy(outstring, "%%", len); - j--; - break; + case '%': + strncpy(outstring, "%%", len); + j--; + break; case 'd': case 'i': case 'o': @@ -1519,114 +1417,164 @@ void sprints1(char *outstring, char *fmt, MYFLT **kvals, int32 numVals) snprintf(outstring, len, strseg, (int16) MYFLT2LRND(*kvals[j])); break; case 'l': - snprintf(outstring, len, strseg, (int64_t) MYFLT2LRND(*kvals[j])); + snprintf(outstring, len, strseg, (int32) MYFLT2LRND(*kvals[j])); break; case 's': - snprintf(outstring, len, strseg, ((STRINGDAT*)(kvals[j]))->data); - break; - + snprintf(outstring, len, strseg, ((STRINGDAT*)(kvals[j]))->data); + break; default: snprintf(outstring, len, strseg, *kvals[j]); break; } + len -= strlen(outstring); + outstring += strlen(outstring); + i = 0; + segwaiting = 0; + + /* prevent potential problems */ + /* if user didnt give enough input params */ + if (j < numVals-1) + j++; + } + /* copy the '%' */ + strseg[i++] = *fmt++; + + /* find the format code */ + segwaiting = fmt; + while (*segwaiting && !isalpha(*segwaiting) && !(*segwaiting=='%')) + segwaiting++; + } + else + strseg[i++] = *fmt++; + } + + if (i) { + strseg[i] = '\0'; + if (segwaiting) { + switch (*segwaiting) { + case '%': + strncpy(outstring, "%%", len); + j--; + break; + case 'd': + case 'i': + case 'o': + case 'x': + case 'X': + case 'u': + case 'c': + snprintf(outstring, len, strseg, (int32_t) MYFLT2LRND(*kvals[j])); + break; + case 'h': + snprintf(outstring, len, strseg, (int16) MYFLT2LRND(*kvals[j])); + break; + case 'l': + snprintf(outstring, len, strseg, (int64_t) MYFLT2LRND(*kvals[j])); + break; + case 's': + snprintf(outstring, len, strseg, ((STRINGDAT*)(kvals[j]))->data); + break; + + default: + snprintf(outstring, len, strseg, *kvals[j]); + break; } - else - snprintf(outstring, len, "%s", strseg); } + else + snprintf(outstring, len, "%s", strseg); + } } static int32_t fprintf_k(CSOUND *csound, FPRINTF *p) { - char string[8192]; + char string[8192]; - (void) csound; - sprints1(string, p->txtstring, p->argums, p->INOCOUNT - 2); - fprintf(p->f.f, "%s", string); - fflush(p->f.f); - return OK; + (void) csound; + sprints1(string, p->txtstring, p->argums, p->INOCOUNT - 2); + fprintf(p->f.f, "%s", string); + fflush(p->f.f); + return OK; } /* i-rate fprints */ static int32_t fprintf_i(CSOUND *csound, FPRINTF *p) { - char string[8192]; - - if (UNLIKELY(fprintf_set(csound, p) != OK)) - return NOTOK; - sprints1(string, p->txtstring, p->argums, p->INOCOUNT - 2); - fprintf(p->f.f,"%s", string); - fflush(p->f.f); - return OK; + char string[8192]; + + if (UNLIKELY(fprintf_set(csound, p) != OK)) + return NOTOK; + sprints1(string, p->txtstring, p->argums, p->INOCOUNT - 2); + fprintf(p->f.f,"%s", string); + fflush(p->f.f); + return OK; } static int32_t fprintf_i_S(CSOUND *csound, FPRINTF *p) { - char string[8192]; - - if (UNLIKELY(fprintf_set_S(csound, p) != OK)) - return NOTOK; - sprints1(string, p->txtstring, p->argums, p->INOCOUNT - 2); - fprintf(p->f.f, "%s", string); - fflush(p->f.f); - return OK; + char string[8192]; + + if (UNLIKELY(fprintf_set_S(csound, p) != OK)) + return NOTOK; + sprints1(string, p->txtstring, p->argums, p->INOCOUNT - 2); + fprintf(p->f.f, "%s", string); + fflush(p->f.f); + return OK; } #define S(x) sizeof(x) static OENTRY localops[] = { - {"fprints", S(FPRINTF), 0, 1, "", "SSN", - (SUBR) fprintf_i_S, (SUBR) NULL,(SUBR) NULL, NULL, }, - {"fprints.i", S(FPRINTF), 0, 1, "", "iSN", - (SUBR) fprintf_i, (SUBR) NULL,(SUBR) NULL, NULL}, - { "fprintks", S(FPRINTF), WR, 3, "", "SSN", - (SUBR) fprintf_set_S, (SUBR) fprintf_k, (SUBR) NULL, NULL,}, - { "fprintks.i", S(FPRINTF), WR, 3, "", "iSN", - (SUBR) fprintf_set, (SUBR) fprintf_k, (SUBR) NULL, NULL}, - { "vincr", S(INCR), WI, 2, "", "aa", - (SUBR) NULL, (SUBR) incr, NULL }, - { "clear", S(CLEARS), WI, 2, "", "y", - (SUBR) NULL, (SUBR) clear, NULL}, - { "fout", S(OUTFILE), 0, 3, "", "Siy", - (SUBR) outfile_set_S, (SUBR) outfile, NULL}, - { "fout.A", S(OUTFILEA), 0, 3, "", "Sia[]", - (SUBR) outfile_set_A, (SUBR) outfile_array, NULL}, - /* { "fout.i", S(OUTFILE), 0, 3, "", "iiy", */ - /* (SUBR) outfile_set, (SUBR) outfile, NULL}, */ - { "foutk", S(KOUTFILE), 0, 3, "", "Siz", - (SUBR) koutfile_set_S, (SUBR) koutfile, (SUBR) NULL, NULL }, - { "foutk.i", S(KOUTFILE), 0, 3, "", "iiz", - (SUBR) koutfile_set, (SUBR) koutfile, (SUBR) NULL, NULL }, - { "fouti", S(IOUTFILE), 0, 1, "", "iiim", - (SUBR) ioutfile_set, (SUBR) NULL, (SUBR) NULL, NULL }, - { "foutir", S(IOUTFILE_R), 0, 3, "", "iiim", - (SUBR) ioutfile_set_r, (SUBR) ioutfile_r, (SUBR) NULL, NULL}, - { "fiopen", S(FIOPEN), 0, 1, "i", "Si", - (SUBR) fiopen_S, (SUBR) NULL, (SUBR) NULL, NULL}, - { "fiopen.i", S(FIOPEN), 0, 1, "i", "ii", - (SUBR) fiopen, (SUBR) NULL, (SUBR) NULL, NULL}, - { "ficlose", S(FICLOSE), 0, 1, "", "S", - (SUBR) ficlose_opcode_S, (SUBR) NULL, (SUBR) NULL, NULL}, - { "ficlose.S", S(FICLOSE), 0, 1, "", "i", - (SUBR) ficlose_opcode, (SUBR) NULL, (SUBR) NULL, NULL }, - { "fin.a", S(INFILE), WI|_QQ, 3, "", "Siiy", - (SUBR) infile_set_S, (SUBR) infile_act, NULL}, - { "fin.A", S(INFILEA), WI, 3, "", "Siia[]", - (SUBR) infile_set_A, (SUBR) infile_arr, NULL}, - { "fin.i", S(INFILE), WI|_QQ, 3, "", "iiiy", - (SUBR) infile_set, (SUBR) infile_act, NULL}, - { "fink", S(KINFILE), WI, 3, "", "Siiz", - (SUBR) kinfile_set_S, (SUBR) kinfile, (SUBR) NULL, NULL}, - { "fink.i", S(KINFILE), WI, 3, "", "iiiz", - (SUBR) kinfile_set, (SUBR) kinfile, (SUBR) NULL, NULL}, - { "fini", S(I_INFILE), WI, 1, "", "Siim", - (SUBR) i_infile_S, (SUBR) NULL, (SUBR) NULL, NULL }, - { "fini.i", S(I_INFILE), WI, 1, "", "iiim", - (SUBR) i_infile, (SUBR) NULL, (SUBR) NULL, NULL} + {"fprints", S(FPRINTF), 0, "", "SSN", + (SUBR) fprintf_i_S, (SUBR) NULL,(SUBR) fprintf_deinit, NULL, }, + {"fprints.i", S(FPRINTF), 0, "", "iSN", + (SUBR) fprintf_i, (SUBR) NULL,(SUBR) fprintf_deinit, NULL}, + { "fprintks", S(FPRINTF), WR, "", "SSN", + (SUBR) fprintf_set_S, (SUBR) fprintf_k, (SUBR) fprintf_deinit, NULL,}, + { "fprintks.i", S(FPRINTF), WR, "", "iSN", + (SUBR) fprintf_set, (SUBR) fprintf_k, (SUBR) fprintf_deinit, NULL}, + { "vincr", S(INCR), WI, "", "aa", + (SUBR) NULL, (SUBR) incr, NULL }, + { "clear", S(CLEARS), WI, "", "y", + (SUBR) NULL, (SUBR) clear, NULL}, + { "fout", S(OUTFILE), 0, "", "Siy", + (SUBR) outfile_set_S, (SUBR) outfile, (SUBR) fout_flush_callback}, + { "fout.A", S(OUTFILEA), 0, "", "Sia[]", + (SUBR) outfile_set_A, (SUBR) outfile_array, (SUBR) fouta_flush_callback}, + { "foutk", S(KOUTFILE), 0, "", "Siz", + (SUBR) koutfile_set_S, (SUBR) koutfile, (SUBR) koutfile_deinit, NULL }, + { "foutk.i", S(KOUTFILE), 0, "", "iiz", + (SUBR) koutfile_set, (SUBR) koutfile, (SUBR) koutfile_deinit, NULL }, + { "fouti", S(IOUTFILE), 0, "", "iiim", + (SUBR) ioutfile_set, (SUBR) NULL, (SUBR) NULL, NULL }, + { "foutir", S(IOUTFILE_R), 0, "", "iiim", + (SUBR) ioutfile_set_r, (SUBR) ioutfile_r, (SUBR) NULL, NULL}, + { "fiopen", S(FIOPEN), 0, "i", "Si", + (SUBR) fiopen_S, (SUBR) NULL, (SUBR) fiopen_deinit, NULL}, + { "fiopen.i", S(FIOPEN), 0, "i", "ii", + (SUBR) fiopen, (SUBR) NULL, (SUBR) fiopen_deinit, NULL}, + { "ficlose", S(FICLOSE), 0, "", "S", + (SUBR) ficlose_opcode_S, (SUBR) NULL, (SUBR) NULL, NULL}, + { "ficlose.S", S(FICLOSE), 0, "", "i", + (SUBR) ficlose_opcode, (SUBR) NULL, (SUBR) NULL, NULL }, + { "fin.a", S(INFILE), WI|_QQ, "", "Siiy", + (SUBR) infile_set_S, (SUBR) infile_act, (SUBR) infile_deinit}, + { "fin.A", S(INFILEA), WI, "", "Siia[]", + (SUBR) infile_set_A, (SUBR) infile_arr, (SUBR) infilea_deinit}, + { "fin.i", S(INFILE), WI|_QQ, "", "iiiy", + (SUBR) infile_set, (SUBR) infile_act, (SUBR) infile_deinit}, + { "fink", S(KINFILE), WI, "", "Siiz", + (SUBR) kinfile_set_S, (SUBR) kinfile, (SUBR) kinfile_deinit, NULL}, + { "fink.i", S(KINFILE), WI, "", "iiiz", + (SUBR) kinfile_set, (SUBR) kinfile, (SUBR) kinfile_deinit, NULL}, + { "fini", S(I_INFILE), WI, "", "Siim", + (SUBR) i_infile_S, (SUBR) NULL, (SUBR) i_infile_deinit, NULL }, + { "fini.i", S(I_INFILE), WI, "", "iiim", + (SUBR) i_infile, (SUBR) NULL, (SUBR) i_infile_deinit, NULL} }; int32_t fout_init_(CSOUND *csound) { - return csound->AppendOpcodes(csound, &(localops[0]), - (int32_t) (sizeof(localops) / sizeof(OENTRY))); + return csound->AppendOpcodes(csound, &(localops[0]), + (int32_t) (sizeof(localops) / sizeof(OENTRY))); } diff --git a/Opcodes/fout.h b/Opcodes/fout.h index edc7b35df7c..cf935583860 100644 --- a/Opcodes/fout.h +++ b/Opcodes/fout.h @@ -35,7 +35,7 @@ typedef struct FOUT_FILE_ { int32_t nchnls; int32_t async; int32_t idx; /* file index + 1 */ - INSDS *head; + int32_t need_deinit; } FOUT_FILE; typedef struct { @@ -122,6 +122,7 @@ typedef struct { MYFLT *fname, *iskpfrms, *iflag, *argums[VARGMAX-3]; int32 currpos; int32_t flag; + FOUT_FILE *f; } I_INFILE; typedef struct { @@ -139,6 +140,7 @@ typedef struct { MYFLT *ihandle, *fname; /* iascii=0 open ascii (default), iflag=1 open binary */ MYFLT *iascii; + FOUT_FILE *f; } FIOPEN; typedef struct { diff --git a/Opcodes/framebuffer.c b/Opcodes/framebuffer.c index 68ec3b4aa91..14f2088a0ed 100644 --- a/Opcodes/framebuffer.c +++ b/Opcodes/framebuffer.c @@ -438,22 +438,20 @@ static OENTRY framebuffer_localops[] = { { .opname = "framebuffer", .dsblksiz = sizeof(Framebuffer), - .thread = 3, .outypes = "*", .intypes = "*", - .iopadr = (SUBR)Framebuffer_initialise, - .kopadr = (SUBR)Framebuffer_process, - .aopadr = NULL + .init = (SUBR)Framebuffer_initialise, + .perf = (SUBR)Framebuffer_process, + .deinit = NULL }, { .opname = "olabuffer", .dsblksiz = sizeof(OLABuffer), - .thread = 3, .outypes = "a", .intypes = "k[]i", - .iopadr = (SUBR)OLABuffer_initialise, - .kopadr = (SUBR)OLABuffer_process, - .aopadr = NULL + .init = (SUBR)OLABuffer_initialise, + .perf = (SUBR)OLABuffer_process, + .deinit = NULL } }; diff --git a/Opcodes/freeverb.c b/Opcodes/freeverb.c index 3e9f1b720e2..c4efd9cccd2 100644 --- a/Opcodes/freeverb.c +++ b/Opcodes/freeverb.c @@ -277,7 +277,7 @@ static int32_t freeverb_perf(CSOUND *csound, FREEVERB *p) int32_t freeverb_init_(CSOUND *csound) { return csound->AppendOpcode(csound, "freeverb", - (int32_t) sizeof(FREEVERB), 0, 3, "aa", "aakkjo", + (int32_t) sizeof(FREEVERB), 0, "aa", "aakkjo", (int32_t (*)(CSOUND*, void*)) freeverb_init, (int32_t (*)(CSOUND*, void*)) freeverb_perf, NULL); diff --git a/Opcodes/ftconv.c b/Opcodes/ftconv.c index a3cd4570d3d..5b7c3bf65e5 100644 --- a/Opcodes/ftconv.c +++ b/Opcodes/ftconv.c @@ -312,7 +312,7 @@ static int32_t ftconv_perf(CSOUND *csound, FTCONV *p) int32_t ftconv_init_(CSOUND *csound) { return csound->AppendOpcode(csound, "ftconv", - (int32_t) sizeof(FTCONV), TR, 3, + (int32_t) sizeof(FTCONV), TR, "mmmmmmmm", "aiiooo", (int32_t (*)(CSOUND *, void *)) ftconv_init, (int32_t (*)(CSOUND *, void *)) ftconv_perf, diff --git a/Opcodes/ftgen.c b/Opcodes/ftgen.c index 060c8d92376..a0be9191248 100644 --- a/Opcodes/ftgen.c +++ b/Opcodes/ftgen.c @@ -26,6 +26,7 @@ typedef struct { OPDS h; MYFLT *ifno, *p1, *p2, *p3, *p4, *p5, *argums[VARGMAX-5]; + int32_t fno; } FTGEN; typedef struct { @@ -42,39 +43,25 @@ typedef struct { typedef struct { OPDS h; MYFLT *iftno, *ifreeTime; + int32_t fno, deinit; } FTFREE; -typedef struct { - OPDS h; - int32_t fno; -} FTDELETE; - typedef struct namedgen { char *name; int32_t genum; struct namedgen *next; } NAMEDGEN; -static int32_t ftable_delete(CSOUND *csound, void *p) +static int32_t ftable_delete(CSOUND *csound, FTGEN *p) { - int32_t err = csound->FTDelete(csound, ((FTDELETE*) p)->fno); + int32_t err = csound->FTDelete(csound, p->fno); if (UNLIKELY(err != OK)) csound->ErrorMsg(csound, Str("Error deleting ftable %d"), - ((FTDELETE*) p)->fno); + p->fno); csound->Free(csound, p); return err; } -static int32_t register_ftable_delete(CSOUND *csound, void *p, int32_t tableNum) -{ - FTDELETE *op = (FTDELETE*) csound->Calloc(csound, sizeof(FTDELETE)); - if (UNLIKELY(op == NULL)) - return csound->InitError(csound, "%s", Str("memory allocation failure")); - op->h.insdshead = ((OPDS*) p)->insdshead; - op->fno = tableNum; - return csound->RegisterDeinitCallback(csound, op, ftable_delete); -} - /* set up and call any GEN routine */ static int32_t ftgen_(CSOUND *csound, FTGEN *p, int32_t istring1, int32_t istring2) { @@ -172,69 +159,82 @@ static int32_t ftgen_SS(CSOUND *csound, FTGEN *p) { static int32_t ftgentmp(CSOUND *csound, FTGEN *p) { - int32_t p1, fno; + int32_t p1; if (UNLIKELY(ftgen(csound, p) != OK)) return NOTOK; p1 = (int32_t) MYFLT2LRND(*p->p1); if (p1) return OK; - fno = (int32_t) MYFLT2LRND(*p->ifno); - return register_ftable_delete(csound, p, fno); + p->fno = (int32_t) MYFLT2LRND(*p->ifno); + return OK; } static int32_t ftgentmp_S(CSOUND *csound, FTGEN *p) { - int32_t p1, fno; + int32_t p1; if (UNLIKELY(ftgen_(csound, p,0,1) != OK)) return NOTOK; p1 = (int32_t) MYFLT2LRND(*p->p1); if (p1) return OK; - fno = (int32_t) MYFLT2LRND(*p->ifno); - return register_ftable_delete(csound, p, fno); + p->fno = (int32_t) MYFLT2LRND(*p->ifno); + return OK; } static int32_t ftgentmp_Si(CSOUND *csound, FTGEN *p) { - int32_t p1, fno; + int32_t p1; if (UNLIKELY(ftgen_(csound, p,1,0) != OK)) return NOTOK; p1 = (int32_t) MYFLT2LRND(*p->p1); if (p1) return OK; - fno = (int32_t) MYFLT2LRND(*p->ifno); - return register_ftable_delete(csound, p, fno); + p->fno = (int32_t) MYFLT2LRND(*p->ifno); + return OK; } static int32_t ftgentmp_SS(CSOUND *csound, FTGEN *p) { - int32_t p1, fno; + int32_t p1; if (UNLIKELY(ftgen_(csound, p,1,1) != OK)) return NOTOK; p1 = (int32_t) MYFLT2LRND(*p->p1); if (p1) return OK; - fno = (int32_t) MYFLT2LRND(*p->ifno); - return register_ftable_delete(csound, p, fno); + p->fno = (int32_t) MYFLT2LRND(*p->ifno); + return OK; } +static int32_t ftfree_deinit(CSOUND *csound, FTFREE *p) +{ + if(p->deinit) { + int32_t err = csound->FTDelete(csound, p->fno); + if (UNLIKELY(err != OK)) + csound->ErrorMsg(csound, Str("Error deleting ftable %d"), + p->fno); + csound->Free(csound, p); + return err; + } else return OK; +} static int32_t ftfree(CSOUND *csound, FTFREE *p) { - int32_t fno = (int32_t) MYFLT2LRND(*p->iftno); + p->fno = (int32_t) MYFLT2LRND(*p->iftno); - if (UNLIKELY(fno <= 0)) - return csound->InitError(csound, Str("Invalid table number: %d"), fno); + if (UNLIKELY(p->fno <= 0)) + return csound->InitError(csound, Str("Invalid table number: %d"), p->fno); if (*p->ifreeTime == FL(0.0)) { - if (UNLIKELY(csound->FTDelete(csound, fno) != 0)) - return csound->InitError(csound, Str("Error deleting ftable %d"), fno); + p->deinit = 0; + if (UNLIKELY(csound->FTDelete(csound, p->fno) != 0)) + return csound->InitError(csound, Str("Error deleting ftable %d"), p->fno); return OK; } - return register_ftable_delete(csound, p, fno); + p->deinit = 1; + return OK; } static int32_t myInitError(CSOUND *csound, OPDS *p, const char *str, ...) @@ -779,30 +779,35 @@ static int32_t getftargs(CSOUND *csound, FTARGS *p) #define S(x) sizeof(x) static OENTRY localops[] = { - { "ftgen", S(FTGEN), TW, 1, "i", "iiiiim", (SUBR) ftgen, NULL, NULL }, - { "ftgen.S", S(FTGEN), TW, 1, "i", "iiiSim", (SUBR) ftgen_S, NULL, NULL }, - { "ftgen.iS", S(FTGEN), TW, 1, "i", "iiiiSm", (SUBR) ftgen_iS, NULL, NULL }, - { "ftgen.SS", S(FTGEN), TW, 1, "i", "iiiSSm", (SUBR) ftgen_SS, NULL, NULL }, - { "ftgen", S(FTGEN), TW, 1, "i", "iiiii[]", (SUBR) ftgen_list_i, NULL }, - { "ftgen", S(FTGEN), TW, 1, "i", "iiiSi[]", (SUBR) ftgen_list_S, NULL }, - { "ftgentmp.i", S(FTGEN), TW, 1, "i", "iiiiim", (SUBR) ftgentmp, NULL, NULL }, - { "ftgentmp.iS", S(FTGEN), TW, 1, "i", "iiiiSm", (SUBR) ftgentmp_S, NULL,NULL}, - { "ftgentmp.Si", S(FTGEN), TW, 1, "i", "iiiSim", (SUBR) ftgentmp_Si,NULL,NULL}, - { "ftgentmp.SS", S(FTGEN), TW, 1, "i", "iiiSSm", (SUBR) ftgentmp_SS,NULL,NULL}, - { "ftfree", S(FTFREE), TW, 1, "", "ii", (SUBR) ftfree, NULL, NULL }, - { "ftsave", S(FTLOAD), TR, 1, "", "iim", (SUBR) ftsave, NULL, NULL }, - { "ftsave.S", S(FTLOAD), TR, 1, "", "Sim", (SUBR) ftsave_S, NULL, NULL }, - { "ftload", S(FTLOAD), TW, 1, "", "iim", (SUBR) ftload, NULL, NULL }, - { "ftload.S", S(FTLOAD), TW, 1, "", "Sim", (SUBR) ftload_S, NULL, NULL }, - { "ftsavek", S(FTLOAD_K), TW, 3, "", "ikim", (SUBR) ftsave_k_set, + { "ftgen", S(FTGEN), TW, "i", "iiiiim", (SUBR) ftgen, NULL, NULL }, + { "ftgen.S", S(FTGEN), TW, "i", "iiiSim", (SUBR) ftgen_S, NULL, NULL }, + { "ftgen.iS", S(FTGEN), TW, "i", "iiiiSm", (SUBR) ftgen_iS, NULL, NULL }, + { "ftgen.SS", S(FTGEN), TW, "i", "iiiSSm", (SUBR) ftgen_SS, NULL, NULL }, + { "ftgen", S(FTGEN), TW, "i", "iiiii[]", (SUBR) ftgen_list_i, NULL }, + { "ftgen", S(FTGEN), TW, "i", "iiiSi[]", (SUBR) ftgen_list_S, NULL }, + { "ftgentmp.i", S(FTGEN), TW, "i", "iiiiim", (SUBR) ftgentmp, NULL, + (SUBR) ftable_delete }, + { "ftgentmp.iS", S(FTGEN), TW, "i", "iiiiSm", (SUBR) ftgentmp_S, NULL, + (SUBR) ftable_delete}, + { "ftgentmp.Si", S(FTGEN), TW, "i", "iiiSim", (SUBR) ftgentmp_Si,NULL, + (SUBR) ftable_delete}, + { "ftgentmp.SS", S(FTGEN), TW, "i", "iiiSSm", (SUBR) ftgentmp_SS,NULL, + (SUBR) ftable_delete}, + { "ftfree", S(FTFREE), TW, "", "ii", (SUBR) ftfree, NULL, + (SUBR) ftfree_deinit}, + { "ftsave", S(FTLOAD), TR, "", "iim", (SUBR) ftsave, NULL, NULL }, + { "ftsave.S", S(FTLOAD), TR, "", "Sim", (SUBR) ftsave_S, NULL, NULL }, + { "ftload", S(FTLOAD), TW, "", "iim", (SUBR) ftload, NULL, NULL }, + { "ftload.S", S(FTLOAD), TW, "", "Sim", (SUBR) ftload_S, NULL, NULL }, + { "ftsavek", S(FTLOAD_K), TW, "", "ikim", (SUBR) ftsave_k_set, (SUBR) ftsave_k, NULL }, - { "ftsavek.S", S(FTLOAD_K), TW, 3, "", "Skim", (SUBR) ftsave_k_set, + { "ftsavek.S", S(FTLOAD_K), TW, "", "Skim", (SUBR) ftsave_k_set, (SUBR) ftsave_kS, NULL }, - { "ftloadk", S(FTLOAD_K), TW, 3, "", "ikim", (SUBR) ftsave_k_set, + { "ftloadk", S(FTLOAD_K), TW, "", "ikim", (SUBR) ftsave_k_set, (SUBR) ftload_k, NULL }, - { "ftloadk.S", S(FTLOAD_K), TW, 3, "", "Skim", (SUBR) ftsave_k_set, + { "ftloadk.S", S(FTLOAD_K), TW, "", "Skim", (SUBR) ftsave_k_set, (SUBR) ftload_kS, NULL }, - { "getftargs", sizeof(FTARGS), 0, 3, "S", "ik", + { "getftargs", sizeof(FTARGS), 0, "S", "ik", (SUBR)getftargs_init, (SUBR)getftargs_process } }; diff --git a/Opcodes/ftsamplebank.cpp b/Opcodes/ftsamplebank.cpp index d95f938b67d..6e0fe001288 100644 --- a/Opcodes/ftsamplebank.cpp +++ b/Opcodes/ftsamplebank.cpp @@ -331,14 +331,14 @@ extern "C" { PUBLIC int32_t csoundModuleInit_ftsamplebank(CSOUND *csound) { int status = csound->AppendOpcode( - csound, (char *)"ftsamplebank.k", sizeof(kftsamplebank), 0, 3, + csound, (char *)"ftsamplebank.k", sizeof(kftsamplebank), 0, (char *)"k", (char *)"Skkkkk", (int (*)(CSOUND *, void *))kftsamplebank::init_, (int (*)(CSOUND *, void *))kftsamplebank::kontrol_, (int (*)(CSOUND *, void *))0); status |= csound->AppendOpcode( - csound, (char *)"ftsamplebank.i", sizeof(iftsamplebank), 0, 1, + csound, (char *)"ftsamplebank.i", sizeof(iftsamplebank), 0, (char *)"i", (char *)"Siiii", (int (*)(CSOUND *, void *))iftsamplebank::init_, (int (*)(CSOUND *, void *))0, (int (*)(CSOUND *, void *))0); @@ -355,7 +355,7 @@ PUBLIC int32_t csoundModuleInit_ftsamplebank(CSOUND *csound) { 0); */ status |= csound->AppendOpcode( - csound, (char *)"directory", sizeof(DIR_STRUCT), 0, 1, (char *)"S[]", + csound, (char *)"directory", sizeof(DIR_STRUCT), 0, (char *)"S[]", (char *)"SN", (int (*)(CSOUND *, void *))directory, (int (*)(CSOUND *, void *))0, (int (*)(CSOUND *, void *))0); return status; diff --git a/Opcodes/gab/gab.c b/Opcodes/gab/gab.c index e2c03e28646..03707bf230c 100644 --- a/Opcodes/gab/gab.c +++ b/Opcodes/gab/gab.c @@ -286,7 +286,7 @@ static CS_NOINLINE int32_t tab_i_tmp(CSOUND *csound, FASTB *p, int32_t ndx) STDOPCOD_GLOBALS *pp; pp = (STDOPCOD_GLOBALS*) csound->QueryGlobalVariable(csound,"STDOPC_GLOBALS"); p->tb_ptr = &(pp->tb_ptrs[ndx]); - p->h.iopadr = (SUBR) tab_perf; + p->h.init = (SUBR) tab_perf; return tab_perf(csound, p); } @@ -295,7 +295,7 @@ static CS_NOINLINE int32_t tab_k_tmp(CSOUND *csound, FASTB *p, int32_t ndx) STDOPCOD_GLOBALS *pp; pp = (STDOPCOD_GLOBALS*) csound->QueryGlobalVariable(csound,"STDOPC_GLOBALS"); p->tb_ptr = &(pp->tb_ptrs[ndx]); - p->h.opadr = (SUBR) tab_perf; + p->h.perf = (SUBR) tab_perf; return tab_perf(csound, p); } @@ -877,91 +877,91 @@ static int32_t mandel(CSOUND *csound,MANDEL *p) #define S(x) sizeof(x) OENTRY gab_localops[] = { - {"resonxk", S(KRESONX), 0, 3, "k", "kkkooo", + {"resonxk", S(KRESONX), 0, "k", "kkkooo", (SUBR) krsnsetx, (SUBR) kresonx, NULL }, - { "tab_i",S(FASTAB), TR, 1, "i", "iio", (SUBR) fastabi, NULL, NULL }, - { "tab",S(FASTAB), TR, 3, "a", "xio", + { "tab_i",S(FASTAB), TR, "i", "iio", (SUBR) fastabi, NULL, NULL }, + { "tab",S(FASTAB), TR, "a", "xio", (SUBR) fastab_set, (SUBR) fastab }, - { "tab.k",S(FASTAB), TR, 3, "k", "kio", + { "tab.k",S(FASTAB), TR, "k", "kio", (SUBR) fastab_set, (SUBR)fastabk, NULL }, - { "tabw_i",S(FASTAB), TW, 1, "", "iiio", (SUBR) fastabiw, NULL, NULL }, - { "tabw",S(FASTAB), TW, 3, "", "kkio", + { "tabw_i",S(FASTAB), TW, "", "iiio", (SUBR) fastabiw, NULL, NULL }, + { "tabw",S(FASTAB), TW, "", "kkio", (SUBR)fastab_set, (SUBR)fastabkw }, - { "tabw",S(FASTAB), TW, 3, "", "aaio", + { "tabw",S(FASTAB), TW, "", "aaio", (SUBR)fastab_set, (SUBR)fastabw }, - { "tb0_init", S(TB_INIT), _QQ, 1, "", "i", (SUBR)tab0_init}, - { "tb1_init", S(TB_INIT), _QQ, 1, "", "i", (SUBR)tab1_init}, - { "tb2_init", S(TB_INIT), _QQ, 1, "", "i", (SUBR)tab2_init}, - { "tb3_init", S(TB_INIT), _QQ, 1, "", "i", (SUBR)tab3_init}, - { "tb4_init", S(TB_INIT), _QQ, 1, "", "i", (SUBR)tab4_init}, - { "tb5_init", S(TB_INIT), _QQ, 1, "", "i", (SUBR)tab5_init}, - { "tb6_init", S(TB_INIT), _QQ, 1, "", "i", (SUBR)tab6_init}, - { "tb7_init", S(TB_INIT), _QQ, 1, "", "i", (SUBR)tab7_init}, - { "tb8_init", S(TB_INIT), _QQ, 1, "", "i", (SUBR)tab8_init}, - { "tb9_init", S(TB_INIT), _QQ, 1, "", "i", (SUBR)tab9_init}, - { "tb10_init", S(TB_INIT), _QQ, 1, "", "i", (SUBR)tab10_init}, - { "tb11_init", S(TB_INIT), _QQ, 1, "", "i", (SUBR)tab11_init}, - { "tb12_init", S(TB_INIT), _QQ, 1, "", "i", (SUBR)tab12_init}, - { "tb13_init", S(TB_INIT), _QQ, 1, "", "i", (SUBR)tab13_init}, - { "tb14_init", S(TB_INIT), _QQ, 1, "", "i", (SUBR)tab14_init}, - { "tb15_init", S(TB_INIT), _QQ, 1, "", "i", (SUBR)tab15_init}, + { "tb0_init", S(TB_INIT), _QQ, "", "i", (SUBR)tab0_init}, + { "tb1_init", S(TB_INIT), _QQ, "", "i", (SUBR)tab1_init}, + { "tb2_init", S(TB_INIT), _QQ, "", "i", (SUBR)tab2_init}, + { "tb3_init", S(TB_INIT), _QQ, "", "i", (SUBR)tab3_init}, + { "tb4_init", S(TB_INIT), _QQ, "", "i", (SUBR)tab4_init}, + { "tb5_init", S(TB_INIT), _QQ, "", "i", (SUBR)tab5_init}, + { "tb6_init", S(TB_INIT), _QQ, "", "i", (SUBR)tab6_init}, + { "tb7_init", S(TB_INIT), _QQ, "", "i", (SUBR)tab7_init}, + { "tb8_init", S(TB_INIT), _QQ, "", "i", (SUBR)tab8_init}, + { "tb9_init", S(TB_INIT), _QQ, "", "i", (SUBR)tab9_init}, + { "tb10_init", S(TB_INIT), _QQ, "", "i", (SUBR)tab10_init}, + { "tb11_init", S(TB_INIT), _QQ, "", "i", (SUBR)tab11_init}, + { "tb12_init", S(TB_INIT), _QQ, "", "i", (SUBR)tab12_init}, + { "tb13_init", S(TB_INIT), _QQ, "", "i", (SUBR)tab13_init}, + { "tb14_init", S(TB_INIT), _QQ, "", "i", (SUBR)tab14_init}, + { "tb15_init", S(TB_INIT), _QQ, "", "i", (SUBR)tab15_init}, /* tbx_t (t-rate version removed here) */ - { "tb0.i", S(FASTB), _QQ|TR, 1, "i", "i", (SUBR) tab0_i_tmp }, - { "tb1.i", S(FASTB), _QQ|TR, 1, "i", "i", (SUBR) tab1_i_tmp }, - { "tb2.i", S(FASTB), _QQ|TR, 1, "i", "i", (SUBR) tab2_i_tmp }, - { "tb3.i", S(FASTB), _QQ|TR, 1, "i", "i", (SUBR) tab3_i_tmp }, - { "tb4.i", S(FASTB), _QQ|TR, 1, "i", "i", (SUBR) tab4_i_tmp }, - { "tb5.i", S(FASTB), _QQ|TR, 1, "i", "i", (SUBR) tab5_i_tmp }, - { "tb6.i", S(FASTB), _QQ|TR, 1, "i", "i", (SUBR) tab6_i_tmp }, - { "tb7.i", S(FASTB), _QQ|TR, 1, "i", "i", (SUBR) tab7_i_tmp }, - { "tb8.i", S(FASTB), _QQ|TR, 1, "i", "i", (SUBR) tab8_i_tmp }, - { "tb9.i", S(FASTB), _QQ|TR, 1, "i", "i", (SUBR) tab9_i_tmp }, - { "tb10.i", S(FASTB), _QQ|TR, 1, "i", "i", (SUBR) tab10_i_tmp }, - { "tb11.i", S(FASTB), _QQ|TR, 1, "i", "i", (SUBR) tab11_i_tmp }, - { "tb12.i", S(FASTB), _QQ|TR, 1, "i", "i", (SUBR) tab12_i_tmp }, - { "tb13.i", S(FASTB), _QQ|TR, 1, "i", "i", (SUBR) tab13_i_tmp }, - { "tb14.i", S(FASTB), _QQ|TR, 1, "i", "i", (SUBR) tab14_i_tmp }, - { "tb15.i", S(FASTB), _QQ|TR, 1, "i", "i", (SUBR) tab15_i_tmp }, - { "tb0.k", S(FASTB), _QQ|TR, 2, "k", "k", NULL, (SUBR) tab0_k_tmp }, - { "tb1.k", S(FASTB), _QQ|TR, 2, "k", "k", NULL, (SUBR) tab1_k_tmp }, - { "tb2.k", S(FASTB), _QQ|TR, 2, "k", "k", NULL, (SUBR) tab2_k_tmp }, - { "tb3.k", S(FASTB), _QQ|TR, 2, "k", "k", NULL, (SUBR) tab3_k_tmp }, - { "tb4.k", S(FASTB), _QQ|TR, 2, "k", "k", NULL, (SUBR) tab4_k_tmp }, - { "tb5.k", S(FASTB), _QQ|TR, 2, "k", "k", NULL, (SUBR) tab5_k_tmp }, - { "tb6.k", S(FASTB), _QQ|TR, 2, "k", "k", NULL, (SUBR) tab6_k_tmp }, - { "tb7.k", S(FASTB), _QQ|TR, 2, "k", "k", NULL, (SUBR) tab7_k_tmp }, - { "tb8.k", S(FASTB), _QQ|TR, 2, "k", "k", NULL, (SUBR) tab8_k_tmp }, - { "tb9.k", S(FASTB), _QQ|TR, 2, "k", "k", NULL, (SUBR) tab9_k_tmp }, - { "tb10.k", S(FASTB), _QQ|TR, 2, "k", "k", NULL, (SUBR) tab10_k_tmp }, - { "tb11.k", S(FASTB), _QQ|TR, 2, "k", "k", NULL, (SUBR) tab11_k_tmp }, - { "tb12.k", S(FASTB), _QQ|TR, 2, "k", "k", NULL, (SUBR) tab12_k_tmp }, - { "tb13.k", S(FASTB), _QQ|TR, 2, "k", "k", NULL, (SUBR) tab13_k_tmp }, - { "tb14.k", S(FASTB), _QQ|TR, 2, "k", "k", NULL, (SUBR) tab14_k_tmp }, - { "tb15.k", S(FASTB), _QQ|TR, 2, "k", "k", NULL, (SUBR) tab15_k_tmp }, - { "nlalp", S(NLALP), 0, 3, "a", "akkoo", + { "tb0.i", S(FASTB), _QQ|TR, "i", "i", (SUBR) tab0_i_tmp }, + { "tb1.i", S(FASTB), _QQ|TR, "i", "i", (SUBR) tab1_i_tmp }, + { "tb2.i", S(FASTB), _QQ|TR, "i", "i", (SUBR) tab2_i_tmp }, + { "tb3.i", S(FASTB), _QQ|TR, "i", "i", (SUBR) tab3_i_tmp }, + { "tb4.i", S(FASTB), _QQ|TR, "i", "i", (SUBR) tab4_i_tmp }, + { "tb5.i", S(FASTB), _QQ|TR, "i", "i", (SUBR) tab5_i_tmp }, + { "tb6.i", S(FASTB), _QQ|TR, "i", "i", (SUBR) tab6_i_tmp }, + { "tb7.i", S(FASTB), _QQ|TR, "i", "i", (SUBR) tab7_i_tmp }, + { "tb8.i", S(FASTB), _QQ|TR, "i", "i", (SUBR) tab8_i_tmp }, + { "tb9.i", S(FASTB), _QQ|TR, "i", "i", (SUBR) tab9_i_tmp }, + { "tb10.i", S(FASTB), _QQ|TR, "i", "i", (SUBR) tab10_i_tmp }, + { "tb11.i", S(FASTB), _QQ|TR, "i", "i", (SUBR) tab11_i_tmp }, + { "tb12.i", S(FASTB), _QQ|TR, "i", "i", (SUBR) tab12_i_tmp }, + { "tb13.i", S(FASTB), _QQ|TR, "i", "i", (SUBR) tab13_i_tmp }, + { "tb14.i", S(FASTB), _QQ|TR, "i", "i", (SUBR) tab14_i_tmp }, + { "tb15.i", S(FASTB), _QQ|TR, "i", "i", (SUBR) tab15_i_tmp }, + { "tb0.k", S(FASTB), _QQ|TR, "k", "k", NULL, (SUBR) tab0_k_tmp }, + { "tb1.k", S(FASTB), _QQ|TR, "k", "k", NULL, (SUBR) tab1_k_tmp }, + { "tb2.k", S(FASTB), _QQ|TR, "k", "k", NULL, (SUBR) tab2_k_tmp }, + { "tb3.k", S(FASTB), _QQ|TR, "k", "k", NULL, (SUBR) tab3_k_tmp }, + { "tb4.k", S(FASTB), _QQ|TR, "k", "k", NULL, (SUBR) tab4_k_tmp }, + { "tb5.k", S(FASTB), _QQ|TR, "k", "k", NULL, (SUBR) tab5_k_tmp }, + { "tb6.k", S(FASTB), _QQ|TR, "k", "k", NULL, (SUBR) tab6_k_tmp }, + { "tb7.k", S(FASTB), _QQ|TR, "k", "k", NULL, (SUBR) tab7_k_tmp }, + { "tb8.k", S(FASTB), _QQ|TR, "k", "k", NULL, (SUBR) tab8_k_tmp }, + { "tb9.k", S(FASTB), _QQ|TR, "k", "k", NULL, (SUBR) tab9_k_tmp }, + { "tb10.k", S(FASTB), _QQ|TR, "k", "k", NULL, (SUBR) tab10_k_tmp }, + { "tb11.k", S(FASTB), _QQ|TR, "k", "k", NULL, (SUBR) tab11_k_tmp }, + { "tb12.k", S(FASTB), _QQ|TR, "k", "k", NULL, (SUBR) tab12_k_tmp }, + { "tb13.k", S(FASTB), _QQ|TR, "k", "k", NULL, (SUBR) tab13_k_tmp }, + { "tb14.k", S(FASTB), _QQ|TR, "k", "k", NULL, (SUBR) tab14_k_tmp }, + { "tb15.k", S(FASTB), _QQ|TR, "k", "k", NULL, (SUBR) tab15_k_tmp }, + { "nlalp", S(NLALP), 0, "a", "akkoo", (SUBR) nlalp_set, (SUBR) nlalp }, - { "adsynt2",S(ADSYNT2),TR, 3, "a", "kkiiiio", + { "adsynt2",S(ADSYNT2),TR, "a", "kkiiiio", (SUBR) adsynt2_set, (SUBR)adsynt2 }, - { "exitnow",S(EXITNOW), 0, 1, "", "o", (SUBR) exitnow, NULL, NULL }, -/* { "zr_i", S(ZKR), 0, 1, "i", "i", (SUBR)zread, NULL, NULL}, */ -/* { "zr_k", S(ZKR), 0, 2, "k", "k", NULL, (SUBR)zread, NULL}, */ -/* { "zr_a", S(ZAR), 0, 3, "a", "a", (SUBR)zaset, (SUBR)zar}, */ -/* { "k_i", S(ASSIGN), 0, 1, "k", "i", (SUBR)assign}, */ -/* { "k_t", S(ASSIGN), 0, 2, "k", "t", NULL, (SUBR)assign}, */ -/* { "a_k", S(INDIFF), 0, 3, "a", "k", (SUBR)a_k_set, (SUBR)interp }, */ - { "tabrec", S(TABREC), TW, 3, "", "kkkkz", + { "exitnow",S(EXITNOW), 0, "", "o", (SUBR) exitnow, NULL, NULL }, +/* { "zr_i", S(ZKR), 0, "i", "i", (SUBR)zread, NULL, NULL}, */ +/* { "zr_k", S(ZKR), 0, "k", "k", NULL, (SUBR)zread, NULL}, */ +/* { "zr_a", S(ZAR), 0, "a", "a", (SUBR)zaset, (SUBR)zar}, */ +/* { "k_i", S(ASSIGN), 0, "k", "i", (SUBR)assign}, */ +/* { "k_t", S(ASSIGN), 0, "k", "t", NULL, (SUBR)assign}, */ +/* { "a_k", S(INDIFF), 0, "a", "k", (SUBR)a_k_set, (SUBR)interp }, */ + { "tabrec", S(TABREC), TW, "", "kkkkz", (SUBR) tabrec_set, (SUBR) tabrec_k, NULL }, - { "tabplay", S(TABPLAY), TR, 3, "", "kkkz", + { "tabplay", S(TABPLAY), TR, "", "kkkz", (SUBR) tabplay_set, (SUBR) tabplay_k, NULL }, - { "changed.k", S(ISCHANGED), 0, 3, "k", "z", + { "changed.k", S(ISCHANGED), 0, "k", "z", (SUBR) isChanged_set, (SUBR)isChanged, NULL }, - { "changed2.k", S(ISCHANGED), 0, 3, "k", "z", + { "changed2.k", S(ISCHANGED), 0, "k", "z", (SUBR) isChanged2_set, (SUBR)isChanged, NULL }, - { "changed2.A", S(ISACHANGED), 0, 3, "k", ".[]", + { "changed2.A", S(ISACHANGED), 0, "k", ".[]", (SUBR) isAChanged_set, (SUBR)isAChanged, NULL }, - { "max_k", S(P_MAXIMUM), 0, 3, "k", "aki", + { "max_k", S(P_MAXIMUM), 0, "k", "aki", (SUBR) partial_maximum_set, (SUBR) partial_maximum }, - { "mandel",S(MANDEL), 0, 3, "kk", "kkkk", + { "mandel",S(MANDEL), 0, "kk", "kkkk", (SUBR) mandel_set, (SUBR) mandel, NULL } }; diff --git a/Opcodes/gab/hvs.c b/Opcodes/gab/hvs.c index 86a807de438..dcaa1eb33f3 100644 --- a/Opcodes/gab/hvs.c +++ b/Opcodes/gab/hvs.c @@ -503,13 +503,13 @@ static int32_t vphaseseg(CSOUND *csound, VPSEG *p) #define S(x) sizeof(x) OENTRY hvs_localops[] = { - { "hvs1", S(HVS1), TB, 3, "", "kiiiiio", + { "hvs1", S(HVS1), TB, "", "kiiiiio", (SUBR)hvs1_set, (SUBR)hvs1, (SUBR)NULL }, - { "hvs2", S(HVS2), TB, 3, "", "kkiiiiiio", + { "hvs2", S(HVS2), TB, "", "kkiiiiiio", (SUBR)hvs2_set, (SUBR)hvs2, (SUBR)NULL }, - { "hvs3", S(HVS3), TB, 3, "", "kkkiiiiiiio", + { "hvs3", S(HVS3), TB, "", "kkkiiiiiiio", (SUBR)hvs3_set, (SUBR)hvs3, (SUBR)NULL }, - { "vphaseseg", S(VPSEG), TB, 3, "", "kiim", + { "vphaseseg", S(VPSEG), TB, "", "kiim", (SUBR)vphaseseg_set, (SUBR)vphaseseg } }; diff --git a/Opcodes/gab/newgabopc.c b/Opcodes/gab/newgabopc.c index 57c7d52a7ad..45d6a8f10a9 100644 --- a/Opcodes/gab/newgabopc.c +++ b/Opcodes/gab/newgabopc.c @@ -245,13 +245,13 @@ static int32_t dashow(CSOUND *csound, DSH *p) #define S(x) sizeof(x) static OENTRY localops[] = { - { "vtable1k", S(MTABLE1), TR, 3, "", "kz", + { "vtable1k", S(MTABLE1), TR, "", "kz", (SUBR)mtable1_set, (SUBR)mtable1_k, (SUBR) NULL }, - { "trandom", S(TRANGERAND), 0, 2, "k", "kkk", + { "trandom", S(TRANGERAND), 0, "k", "kkk", NULL, (SUBR)trRangeRand }, - { "lposcilsa", S(LPOSC_ST), TR, 3, "aa","akkkio", + { "lposcilsa", S(LPOSC_ST), TR, "aa","akkkio", (SUBR)lposc_stereo_set, (SUBR)lposca_stereo}, - { "lposcilsa2", S(LPOSC_ST), TR, 3, "aa","akkkio", + { "lposcilsa2", S(LPOSC_ST), TR, "aa","akkkio", (SUBR)lposc_stereo_set, (SUBR)lposca_stereo_no_trasp} }; diff --git a/Opcodes/gab/sliderTable.c b/Opcodes/gab/sliderTable.c index fe9d28d3212..73ab53a1628 100644 --- a/Opcodes/gab/sliderTable.c +++ b/Opcodes/gab/sliderTable.c @@ -624,20 +624,20 @@ static int32_t ctrl7a(CSOUND *csound, CTRL7a *p) #define S(x) sizeof(x) OENTRY sliderTable_localops[] = { -{ "slider8table", S(SLIDER8t), 0, 3, "k", "iii" +{ "slider8table", S(SLIDER8t), 0, "k", "iii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii", (SUBR)sliderTable_i8, (SUBR)sliderTable8, (SUBR)NULL }, -{ "slider16table", S(SLIDER8t), 0, 3, "k", "iii" +{ "slider16table", S(SLIDER8t), 0, "k", "iii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii", (SUBR)sliderTable_i16, (SUBR)sliderTable16, (SUBR)NULL }, -{ "slider32table", S(SLIDER8t), 0, 3, "k", "iii" +{ "slider32table", S(SLIDER8t), 0, "k", "iii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii", (SUBR)sliderTable_i32, (SUBR)sliderTable32, (SUBR)NULL }, -{ "slider64table", S(SLIDER8t), 0, 3, "k", "iii" +{ "slider64table", S(SLIDER8t), 0, "k", "iii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" @@ -647,20 +647,20 @@ OENTRY sliderTable_localops[] = { "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii", (SUBR)sliderTable_i64, (SUBR)sliderTable64, (SUBR)NULL }, -{ "slider8tablef", S(SLIDER8tf), 0, 3, "k", "iii" +{ "slider8tablef", S(SLIDER8tf), 0, "k", "iii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii", (SUBR)sliderTable_i8f, (SUBR)sliderTable8f, (SUBR)NULL }, -{ "slider16tablef",S(SLIDER16tf), 0, 3, "k", "iii" +{ "slider16tablef",S(SLIDER16tf), 0, "k", "iii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii", (SUBR)sliderTable_i16f, (SUBR)sliderTable16f, (SUBR)NULL }, -{ "slider32tablef",S(SLIDER32tf), 0, 3, "k", "iii" +{ "slider32tablef",S(SLIDER32tf), 0, "k", "iii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii", (SUBR)sliderTable_i32f, (SUBR)sliderTable32f, (SUBR)NULL }, -{ "slider64tablef",S(SLIDER64tf), 0, 3, "k", "iii" +{ "slider64tablef",S(SLIDER64tf), 0, "k", "iii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" @@ -670,11 +670,11 @@ OENTRY sliderTable_localops[] = { "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii", (SUBR)sliderTable_i64f, (SUBR)sliderTable64f, (SUBR)NULL }, -{ "sliderKawai", S(SLIDERKAWAI), 0, 3, "kkkkkkkkkkkkkkkk", +{ "sliderKawai", S(SLIDERKAWAI), 0, "kkkkkkkkkkkkkkkk", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii", (SUBR)sliderKawai_i, (SUBR)sliderKawai, NULL }, -{ "ctrl7.a", S(CTRL7a), 0, 3, "a", "iikkoo", +{ "ctrl7.a", S(CTRL7a), 0, "a", "iikkoo", (SUBR) ctrl7a_set, (SUBR) ctrl7a }, }; diff --git a/Opcodes/gab/tabmorph.c b/Opcodes/gab/tabmorph.c index f741a627bf6..433e57acc66 100644 --- a/Opcodes/gab/tabmorph.c +++ b/Opcodes/gab/tabmorph.c @@ -286,13 +286,13 @@ static int32_t atabmorphi(CSOUND *csound, TABMORPH *p) OENTRY tabmoroph_localops[] = { -{ "tabmorph", S(TABMORPH), TR, 3, "k", "kkkkm", +{ "tabmorph", S(TABMORPH), TR, "k", "kkkkm", (SUBR) tabmorph_set, (SUBR) tabmorph, NULL}, -{ "tabmorphi", S(TABMORPH), TR, 3, "k", "kkkkm", +{ "tabmorphi", S(TABMORPH), TR, "k", "kkkkm", (SUBR) tabmorph_set, (SUBR) tabmorphi, NULL}, -{ "tabmorpha", S(TABMORPH), TR, 3, "a", "aaaam", +{ "tabmorpha", S(TABMORPH), TR, "a", "aaaam", (SUBR) tabmorph_set, (SUBR) atabmorphia}, -{ "tabmorphak",S(TABMORPH), TR, 3, "a", "akkkm", +{ "tabmorphak",S(TABMORPH), TR, "a", "akkkm", (SUBR) tabmorph_set, (SUBR) atabmorphi } }; diff --git a/Opcodes/gab/vectorial.c b/Opcodes/gab/vectorial.c index 5972bfa7a30..20ff4f1284a 100644 --- a/Opcodes/gab/vectorial.c +++ b/Opcodes/gab/vectorial.c @@ -2565,73 +2565,73 @@ static int32_t ca(CSOUND *csound,CELLA *p) #define S(x) sizeof(x) OENTRY vectorial_localops[] = { - { "vtablei", S(MTABLEI), TR, 1, "", "iiiim", (SUBR)mtable_i, NULL }, - { "vtablek", S(MTABLE), TR, 3, "", "kkkiz", + { "vtablei", S(MTABLEI), TR, "", "iiiim", (SUBR)mtable_i, NULL }, + { "vtablek", S(MTABLE), TR, "", "kkkiz", (SUBR)mtable_set, (SUBR)mtable_k, NULL }, - { "vtablea", S(MTABLE), TR, 3, "", "akkiy", + { "vtablea", S(MTABLE), TR, "", "akkiy", (SUBR)mtable_set, (SUBR)mtable_a }, - { "vtablewi", S(MTABLEIW), TB, 1, "", "iiim", (SUBR)mtablew_i, NULL }, - { "vtablewk", S(MTABLEW), TB, 3, "", "kkiz", + { "vtablewi", S(MTABLEIW), TB, "", "iiim", (SUBR)mtablew_i, NULL }, + { "vtablewk", S(MTABLEW), TB, "", "kkiz", (SUBR)mtablew_set, (SUBR)mtablew_k, NULL }, - { "vtablewa", S(MTABLEW), TB, 3, "", "akiy", + { "vtablewa", S(MTABLEW), TB, "", "akiy", (SUBR)mtablew_set, (SUBR)mtablew_a }, - { "vtabi", S(MTABI), TR, 1, "", "iim", (SUBR)mtab_i, NULL }, - { "vtabk", S(MTAB), TR, 3, "", "kiz", + { "vtabi", S(MTABI), TR, "", "iim", (SUBR)mtab_i, NULL }, + { "vtabk", S(MTAB), TR, "", "kiz", (SUBR)mtab_set, (SUBR)mtab_k, NULL }, - { "vtaba", S(MTAB), TR, 3, "", "aiy", + { "vtaba", S(MTAB), TR, "", "aiy", (SUBR)mtab_set, (SUBR)mtab_a }, - { "vtabwi", S(MTABIW), TB, 1, "", "iim", (SUBR)mtabw_i, NULL }, - { "vtabwk", S(MTABW), TB, 3, "", "kiz", + { "vtabwi", S(MTABIW), TB, "", "iim", (SUBR)mtabw_i, NULL }, + { "vtabwk", S(MTABW), TB, "", "kiz", (SUBR)mtabw_set, (SUBR)mtabw_k, NULL }, - { "vtabwa", S(MTABW), TB, 3, "", "aiy", + { "vtabwa", S(MTABW), TB, "", "aiy", (SUBR)mtabw_set, (SUBR)mtabw_a }, - { "vadd", S(VECTOROP), TB, 3, "", "ikkOO", + { "vadd", S(VECTOROP), TB, "", "ikkOO", (SUBR)vectorOp_set, (SUBR) vaddk }, - { "vadd_i", S(VECTOROPI), TB, 1, "", "iiio", (SUBR) vadd_i, NULL, NULL }, - { "vmult", S(VECTOROP), TB, 3, "", "ikkOO", + { "vadd_i", S(VECTOROPI), TB, "", "iiio", (SUBR) vadd_i, NULL, NULL }, + { "vmult", S(VECTOROP), TB, "", "ikkOO", (SUBR)vectorOp_set, (SUBR) vmultk}, - { "vmult_i", S(VECTOROPI), TB, 1, "", "iiio", (SUBR) vmult_i, NULL, NULL }, - { "vpow", S(VECTOROP), TB, 3, "", "ikkOO", + { "vmult_i", S(VECTOROPI), TB, "", "iiio", (SUBR) vmult_i, NULL, NULL }, + { "vpow", S(VECTOROP), TB, "", "ikkOO", (SUBR)vectorOp_set, (SUBR) vpowk }, - { "vpow_i", S(VECTOROPI), TB, 1, "", "iiio", (SUBR) vpow_i, NULL, NULL }, - { "vexp", S(VECTOROP), TB, 3, "", "ikkOO", + { "vpow_i", S(VECTOROPI), TB, "", "iiio", (SUBR) vpow_i, NULL, NULL }, + { "vexp", S(VECTOROP), TB, "", "ikkOO", (SUBR)vectorOp_set, (SUBR) vexpk }, - { "vexp_i", S(VECTOROPI), TB, 1, "", "iiio", (SUBR) vexp_i, NULL, NULL }, - { "vaddv", S(VECTORSOP), TB, 3, "", "iikOOO", + { "vexp_i", S(VECTOROPI), TB, "", "iiio", (SUBR) vexp_i, NULL, NULL }, + { "vaddv", S(VECTORSOP), TB, "", "iikOOO", (SUBR)vectorsOp_set, (SUBR) vaddvk }, - { "vaddv_i", S(VECTORSOPI), TB, 1, "", "iiioo", (SUBR)vaddv_i, NULL, NULL }, - { "vsubv", S(VECTORSOP), TB, 3, "", "iikOOO", + { "vaddv_i", S(VECTORSOPI), TB, "", "iiioo", (SUBR)vaddv_i, NULL, NULL }, + { "vsubv", S(VECTORSOP), TB, "", "iikOOO", (SUBR)vectorsOp_set, (SUBR) vsubvk }, - { "vsubv_i", S(VECTORSOPI), TB, 1, "", "iiioo", + { "vsubv_i", S(VECTORSOPI), TB, "", "iiioo", (SUBR)vsubv_i, NULL, NULL }, - { "vmultv", S(VECTORSOP), TB, 3, "", "iikOOO", + { "vmultv", S(VECTORSOP), TB, "", "iikOOO", (SUBR)vectorsOp_set, (SUBR) vmultvk}, - { "vmultv_i", S(VECTORSOPI), TB, 1, "", "iiioo", (SUBR)vmultv_i, NULL, NULL }, - { "vdivv", S(VECTORSOP), TB, 3, "", "iikOOO", + { "vmultv_i", S(VECTORSOPI), TB, "", "iiioo", (SUBR)vmultv_i, NULL, NULL }, + { "vdivv", S(VECTORSOP), TB, "", "iikOOO", (SUBR)vectorsOp_set, (SUBR) vdivvk }, - { "vdivv_i", S(VECTORSOPI), TB, 1, "", "iiioo", (SUBR)vdivv_i, NULL, NULL }, - { "vpowv", S(VECTORSOP), TB, 3, "", "iikOOO", + { "vdivv_i", S(VECTORSOPI), TB, "", "iiioo", (SUBR)vdivv_i, NULL, NULL }, + { "vpowv", S(VECTORSOP), TB, "", "iikOOO", (SUBR)vectorsOp_set, (SUBR) vpowvk }, - { "vpowv_i", S(VECTORSOPI), TB, 1, "", "iiioo", (SUBR)vpowv_i, NULL, NULL }, - { "vexpv", S(VECTORSOP), TB, 3, "", "iikOOO", + { "vpowv_i", S(VECTORSOPI), TB, "", "iiioo", (SUBR)vpowv_i, NULL, NULL }, + { "vexpv", S(VECTORSOP), TB, "", "iikOOO", (SUBR)vectorsOp_set, (SUBR) vexpvk }, - { "vexpv_i", S(VECTORSOPI), TB, 1, "", "iiioo", (SUBR)vexpv_i, NULL, NULL }, - { "vcopy", S(VECTORSOP), TB, 3, "", "iikOOO", + { "vexpv_i", S(VECTORSOPI), TB, "", "iiioo", (SUBR)vexpv_i, NULL, NULL }, + { "vcopy", S(VECTORSOP), TB, "", "iikOOO", (SUBR)vectorsOp_set, (SUBR) vcopy }, - { "vcopy_i", S(VECTORSOP), TB, 1, "", "iiioo", (SUBR) vcopy_i, NULL, NULL}, - { "vmap", S(VECTORSOPI), TB, 1, "", "iiioo", (SUBR)vmap_i, NULL, NULL }, - { "vlimit", S(VLIMIT), TR, 3, "", "ikki",(SUBR)vlimit_set, (SUBR)vlimit }, - { "vwrap", S(VLIMIT), TB, 3, "", "ikki",(SUBR)vlimit_set, (SUBR) vwrap }, - { "vmirror", S(VLIMIT), TB, 3, "", "ikki",(SUBR)vlimit_set, (SUBR)vmirror }, - { "vlinseg", S(VSEG), TB, 3, "", "iim", (SUBR)vseg_set, (SUBR)vlinseg }, - { "vexpseg", S(VSEG), TB, 3, "", "iim", (SUBR)vseg_set, (SUBR)vexpseg }, - { "vrandh", S(VRANDH), TB, 3, "", "ikkiovoo",(SUBR)vrandh_set, (SUBR)vrandh}, - { "vrandi", S(VRANDI), TB, 3, "", "ikkiovoo",(SUBR)vrandi_set, (SUBR)vrandi }, - { "vport", S(VPORT), TB, 3, "", "ikio",(SUBR)vport_set, (SUBR)vport }, - { "vecdelay", S(VECDEL), TB, 3, "", "iiiiio",(SUBR)vecdly_set, (SUBR)vecdly }, - { "vdelayk", S(KDEL), 0, 3, "k", "kkioo",(SUBR)kdel_set, (SUBR)kdelay }, - { "vcella", S(CELLA), TB, 3, "", "kkiiiiip",(SUBR)ca_set, (SUBR)ca } + { "vcopy_i", S(VECTORSOP), TB, "", "iiioo", (SUBR) vcopy_i, NULL, NULL}, + { "vmap", S(VECTORSOPI), TB, "", "iiioo", (SUBR)vmap_i, NULL, NULL }, + { "vlimit", S(VLIMIT), TR, "", "ikki",(SUBR)vlimit_set, (SUBR)vlimit }, + { "vwrap", S(VLIMIT), TB, "", "ikki",(SUBR)vlimit_set, (SUBR) vwrap }, + { "vmirror", S(VLIMIT), TB, "", "ikki",(SUBR)vlimit_set, (SUBR)vmirror }, + { "vlinseg", S(VSEG), TB, "", "iim", (SUBR)vseg_set, (SUBR)vlinseg }, + { "vexpseg", S(VSEG), TB, "", "iim", (SUBR)vseg_set, (SUBR)vexpseg }, + { "vrandh", S(VRANDH), TB, "", "ikkiovoo",(SUBR)vrandh_set, (SUBR)vrandh}, + { "vrandi", S(VRANDI), TB, "", "ikkiovoo",(SUBR)vrandi_set, (SUBR)vrandi }, + { "vport", S(VPORT), TB, "", "ikio",(SUBR)vport_set, (SUBR)vport }, + { "vecdelay", S(VECDEL), TB, "", "iiiiio",(SUBR)vecdly_set, (SUBR)vecdly }, + { "vdelayk", S(KDEL), 0, "k", "kkioo",(SUBR)kdel_set, (SUBR)kdelay }, + { "vcella", S(CELLA), TB, "", "kkiiiiip",(SUBR)ca_set, (SUBR)ca } }; int32_t gab_vectorial_init_(CSOUND *csound) diff --git a/Opcodes/gammatone.c b/Opcodes/gammatone.c index 0c677c28e55..31fb446a45a 100644 --- a/Opcodes/gammatone.c +++ b/Opcodes/gammatone.c @@ -127,7 +127,7 @@ static int32_t gammatone_perf(CSOUND *csound, GAMMA *p) #define S(x) sizeof(x) static OENTRY gamma_localops[] = { -{ "gtf", S(GAMMA), 0, 3, "a", "akioo", (SUBR)gammatone_init, (SUBR)gammatone_perf } +{ "gtf", S(GAMMA), 0, "a", "akioo", (SUBR)gammatone_init, (SUBR)gammatone_perf } }; LINKAGE_BUILTIN(gamma_localops) diff --git a/Opcodes/gendy.c b/Opcodes/gendy.c index 70f33e8f2c3..af93f1ae4b1 100644 --- a/Opcodes/gendy.c +++ b/Opcodes/gendy.c @@ -535,20 +535,17 @@ static int32_t agendyc(CSOUND *csound, GENDYC *p) } static OENTRY gendy_localops[] = { - { "gendy", 0xffff }, - { "gendyx", 0xffff }, - { "gendyc", 0xffff }, - { "gendy.k", sizeof(GENDY), 0,3, "k", "kkkkkkkkkoO", + { "gendy.k", sizeof(GENDY), 0, "k", "kkkkkkkkkoO", (SUBR)gendyset, (SUBR)kgendy, (SUBR)NULL }, - { "gendy.a", sizeof(GENDY), 0,3, "a", "kkkkkkkkkoO", + { "gendy.a", sizeof(GENDY), 0, "a", "kkkkkkkkkoO", (SUBR)gendyset, (SUBR)agendy }, - { "gendyx.k", sizeof(GENDYX), 0,3, "k", "kkkkkkkkkkkoO", + { "gendyx.k", sizeof(GENDYX), 0, "k", "kkkkkkkkkkkoO", (SUBR)gendyxset, (SUBR)kgendyx, (SUBR)NULL }, - { "gendyx.a", sizeof(GENDYX), 0,3, "a", "kkkkkkkkkkkoO", + { "gendyx.a", sizeof(GENDYX), 0, "a", "kkkkkkkkkkkoO", (SUBR)gendyxset, (SUBR)agendyx }, - { "gendyc.k", sizeof(GENDYC), 0,3, "k", "kkkkkkkkkoO", + { "gendyc.k", sizeof(GENDYC), 0, "k", "kkkkkkkkkoO", (SUBR)gendycset, (SUBR)kgendyc, (SUBR)NULL }, - { "gendyc.a", sizeof(GENDYC), 0,3, "a", "kkkkkkkkkoO", + { "gendyc.a", sizeof(GENDYC), 0, "a", "kkkkkkkkkoO", (SUBR)gendycset, (SUBR)agendyc } }; diff --git a/Opcodes/grain.c b/Opcodes/grain.c index decd9a7f3dc..3291c34ba27 100644 --- a/Opcodes/grain.c +++ b/Opcodes/grain.c @@ -196,7 +196,7 @@ static int32_t ags(CSOUND *csound, PGRA *p) /* Granular U.G. a-rate main routin static OENTRY localops[] = { - { "grain", S(PGRA), TR, 3, "a", "xxxkkkiiio", (SUBR)agsset, (SUBR)ags } + { "grain", S(PGRA), TR, "a", "xxxkkkiiio", (SUBR)agsset, (SUBR)ags } }; int32_t grain_init_(CSOUND *csound) diff --git a/Opcodes/grain4.c b/Opcodes/grain4.c index 8baf68f116a..0fd6843b253 100644 --- a/Opcodes/grain4.c +++ b/Opcodes/grain4.c @@ -452,7 +452,7 @@ static MYFLT grand( GRAINV4 *p) static OENTRY grain4_localops[] = { - { "granule", S(GRAINV4), TR, 3, "a", "xiiiiiiiiikikiiivppppo", + { "granule", S(GRAINV4), TR, "a", "xiiiiiiiiikikiiivppppo", (SUBR)grainsetv4, (SUBR)graingenv4}, }; diff --git a/Opcodes/harmon.c b/Opcodes/harmon.c index 1f9f781a169..c2f79f4634b 100644 --- a/Opcodes/harmon.c +++ b/Opcodes/harmon.c @@ -461,9 +461,9 @@ int32_t harm4set(CSOUND *csound, HARM234 *p) static OENTRY harmon_localops[] = { - { "harmon2",S(HARM234),0,3,"a","akkkiip", (SUBR)harm2set, (SUBR)harmon234 }, - { "harmon3",S(HARM234),0,3,"a","akkkkiip", (SUBR)harm3set, (SUBR)harmon234 }, - { "harmon4",S(HARM234),0,3,"a","akkkkkiip",(SUBR)harm4set, (SUBR)harmon234 }, + { "harmon2",S(HARM234),0,"a","akkkiip", (SUBR)harm2set, (SUBR)harmon234 }, + { "harmon3",S(HARM234),0,"a","akkkkiip", (SUBR)harm3set, (SUBR)harmon234 }, + { "harmon4",S(HARM234),0,"a","akkkkkiip",(SUBR)harm4set, (SUBR)harmon234 }, }; LINKAGE_BUILTIN(harmon_localops) diff --git a/Opcodes/hrtfearly.c b/Opcodes/hrtfearly.c index 9773eca46c3..6d03330e87e 100644 --- a/Opcodes/hrtfearly.c +++ b/Opcodes/hrtfearly.c @@ -1804,7 +1804,7 @@ static int32_t early_process(CSOUND *csound, early *p) static OENTRY hrtfearly_localops[] = { { - "hrtfearly", sizeof(early), 0,3, "aaiii", + "hrtfearly", sizeof(early), 0, "aaiii", "axxxxxxSSioopoOoooooooooooooooooo", (SUBR)early_init, (SUBR)early_process } diff --git a/Opcodes/hrtferX.c b/Opcodes/hrtferX.c index 547c94bd35b..eca7ed8ebfe 100644 --- a/Opcodes/hrtferX.c +++ b/Opcodes/hrtferX.c @@ -447,7 +447,7 @@ static int32_t hrtferxk(CSOUND *csound, HRTFER *p) static OENTRY hrtferX_localops[] = { - { "hrtfer", sizeof(HRTFER), _QQ, 3, "aa", "akkS", + { "hrtfer", sizeof(HRTFER), _QQ, "aa", "akkS", (SUBR)hrtferxkSet, (SUBR)hrtferxk}, }; diff --git a/Opcodes/hrtfopcodes.c b/Opcodes/hrtfopcodes.c index 61bda11593d..43b255119f9 100644 --- a/Opcodes/hrtfopcodes.c +++ b/Opcodes/hrtfopcodes.c @@ -2668,11 +2668,11 @@ static int32_t hrtfmove2_process(CSOUND *csound, hrtfmove2 *p) /* see csound manual (extending csound) for details of below */ static OENTRY hrtfopcodes_localops[] = { - { "hrtfmove", sizeof(hrtfmove),0, 3, "aa", "akkSSooo", + { "hrtfmove", sizeof(hrtfmove),0, "aa", "akkSSooo", (SUBR)hrtfmove_init, (SUBR)hrtfmove_process }, - { "hrtfstat", sizeof(hrtfstat),0, 3, "aa", "aiiSSoo", + { "hrtfstat", sizeof(hrtfstat),0, "aa", "aiiSSoo", (SUBR)hrtfstat_init, (SUBR)hrtfstat_process }, - { "hrtfmove2", sizeof(hrtfmove2),0, 3, "aa", "akkSSooo", + { "hrtfmove2", sizeof(hrtfmove2),0, "aa", "akkSSooo", (SUBR)hrtfmove2_init, (SUBR)hrtfmove2_process } }; diff --git a/Opcodes/hrtfreverb.c b/Opcodes/hrtfreverb.c index 0663aa24b36..714bb66db19 100644 --- a/Opcodes/hrtfreverb.c +++ b/Opcodes/hrtfreverb.c @@ -1341,7 +1341,7 @@ int32_t hrtfreverb_process(CSOUND *csound, hrtfreverb *p) static OENTRY hrtfreverb_localops[] = { { - "hrtfreverb", sizeof(hrtfreverb), 0,3, "aai", "aiiSSoop", + "hrtfreverb", sizeof(hrtfreverb), 0, "aai", "aiiSSoop", (SUBR)hrtfreverb_init, (SUBR)hrtfreverb_process } }; diff --git a/Opcodes/ifd.c b/Opcodes/ifd.c index 94840839efd..167f801b0f5 100644 --- a/Opcodes/ifd.c +++ b/Opcodes/ifd.c @@ -390,9 +390,9 @@ static int32_t tifd_process(CSOUND * csound, IFD * p) static OENTRY localops[] = { - { "pvsifd", sizeof(IFD), 0, 3, "ff", "aiiip", + { "pvsifd", sizeof(IFD), 0, "ff", "aiiip", (SUBR) ifd_init, (SUBR) ifd_process}, - { "tabifd", sizeof(IFD), 0, 3, "ff", "kkkiiii", + { "tabifd", sizeof(IFD), 0, "ff", "kkkiiii", (SUBR) tifd_init, (SUBR) tifd_process} }; diff --git a/Opcodes/linuxjoystick.c b/Opcodes/linuxjoystick.c index a56ad18e330..7a7d39056b3 100644 --- a/Opcodes/linuxjoystick.c +++ b/Opcodes/linuxjoystick.c @@ -141,7 +141,7 @@ static int32_t linuxjoystick (CSOUND *csound, LINUXJOYSTICK *stick) } static OENTRY localops[] = { - { "joystick", sizeof(LINUXJOYSTICK), 0, 2, "k", "kk", + { "joystick", sizeof(LINUXJOYSTICK), 0, "k", "kk", NULL, (SUBR) linuxjoystick, NULL }, }; diff --git a/Opcodes/liveconv.c b/Opcodes/liveconv.c index 344a0f5865f..724571d62ca 100644 --- a/Opcodes/liveconv.c +++ b/Opcodes/liveconv.c @@ -515,7 +515,7 @@ static OENTRY liveconv_localops[] = { { "liveconv", // name of opcode sizeof(liveconv_t), // data size of state block - TR, 3, // thread + TR, "a", // output arguments "aiikk", // input arguments (SUBR) liveconv_init, // init function diff --git a/Opcodes/locsig.c b/Opcodes/locsig.c index 2300f218ef4..00140780684 100644 --- a/Opcodes/locsig.c +++ b/Opcodes/locsig.c @@ -231,9 +231,9 @@ static int32_t locsend(CSOUND *csound, LOCSEND *p) static OENTRY localops[] = { - { "locsig", S(LOCSIG), 0, 3, "mmmm", "akkk", + { "locsig", S(LOCSIG), 0, "mmmm", "akkk", (SUBR)locsigset, (SUBR)locsig }, - { "locsend", S(LOCSEND),0, 3, "mmmm", "",(SUBR)locsendset, (SUBR)locsend } + { "locsend", S(LOCSEND),0, "mmmm", "",(SUBR)locsendset, (SUBR)locsend } }; int32_t locsig_init_(CSOUND *csound) diff --git a/Opcodes/loscilx.c b/Opcodes/loscilx.c index bac11f8e55d..e136447a4d8 100644 --- a/Opcodes/loscilx.c +++ b/Opcodes/loscilx.c @@ -1141,13 +1141,13 @@ static int32_t loscilxa_opcode_perf(CSOUND *csound, LOSCILXA_OPCODE *p) /* ------------------------------------------------------------------------ */ static OENTRY loscilx_localops[] = { - { "sndload", sizeof(SNDLOAD_OPCODE), _QQ, 1, "", "iooooojjoo", + { "sndload", sizeof(SNDLOAD_OPCODE), _QQ, "", "iooooojjoo", (SUBR) sndload_opcode_init, (SUBR) NULL, (SUBR) NULL }, - { "sndload.S", sizeof(SNDLOAD_OPCODE), _QQ, 1, "", "Sooooojjoo", + { "sndload.S", sizeof(SNDLOAD_OPCODE), _QQ, "", "Sooooojjoo", (SUBR) sndload_opcode_init_S, (SUBR) NULL, (SUBR) NULL }, - { "loscilx", sizeof(LOSCILX_OPCODE), TR, 3, "mmmmmmmmmmmmmmmm", "xkioojjoo", + { "loscilx", sizeof(LOSCILX_OPCODE), TR, "mmmmmmmmmmmmmmmm", "xkioojjoo", (SUBR) loscilx_opcode_init, (SUBR) loscilx_opcode_perf }, - { "loscilx", sizeof(LOSCILXA_OPCODE), TR, 3, "a[]", "xkioojjoo", + { "loscilx", sizeof(LOSCILXA_OPCODE), TR, "a[]", "xkioojjoo", (SUBR) loscilxa_opcode_init, (SUBR) loscilxa_opcode_perf } }; diff --git a/Opcodes/lowpassr.c b/Opcodes/lowpassr.c index fd45e619b91..09ef007325c 100644 --- a/Opcodes/lowpassr.c +++ b/Opcodes/lowpassr.c @@ -375,17 +375,17 @@ static int32_t lowpr_w_sep(CSOUND *csound, LOWPR_SEP *p) static OENTRY localops[] = { - { "lowres.kk", S(LOWPR), 0, 3, "a", "akko", (SUBR)lowpr_set, (SUBR)lowpr }, - { "lowres.aa", S(LOWPR), 0, 3, "a", "aaao", (SUBR)lowpr_set, (SUBR)lowpraa }, - { "lowres.ak", S(LOWPR), 0, 3, "a", "aako", (SUBR)lowpr_set, (SUBR)lowprak }, - { "lowres.ka", S(LOWPR), 0, 3, "a", "akao", (SUBR)lowpr_set, (SUBR)lowprka }, + { "lowres.kk", S(LOWPR), 0, "a", "akko", (SUBR)lowpr_set, (SUBR)lowpr }, + { "lowres.aa", S(LOWPR), 0, "a", "aaao", (SUBR)lowpr_set, (SUBR)lowpraa }, + { "lowres.ak", S(LOWPR), 0, "a", "aako", (SUBR)lowpr_set, (SUBR)lowprak }, + { "lowres.ka", S(LOWPR), 0, "a", "akao", (SUBR)lowpr_set, (SUBR)lowprka }, - { "lowresx.kk", S(LOWPRX),0, 3, "a", "akkoo", (SUBR)lowpr_setx, (SUBR)lowprx }, - { "lowresx.ak", S(LOWPRX),0, 3, "a", "aakoo", (SUBR)lowpr_setx, (SUBR)lowprx }, - { "lowresx.ka", S(LOWPRX),0, 3, "a", "akaoo", (SUBR)lowpr_setx, (SUBR)lowprx }, - { "lowresx.aa", S(LOWPRX),0, 3, "a", "aaaoo", (SUBR)lowpr_setx, (SUBR)lowprx }, + { "lowresx.kk", S(LOWPRX),0, "a", "akkoo", (SUBR)lowpr_setx, (SUBR)lowprx }, + { "lowresx.ak", S(LOWPRX),0, "a", "aakoo", (SUBR)lowpr_setx, (SUBR)lowprx }, + { "lowresx.ka", S(LOWPRX),0, "a", "akaoo", (SUBR)lowpr_setx, (SUBR)lowprx }, + { "lowresx.aa", S(LOWPRX),0, "a", "aaaoo", (SUBR)lowpr_setx, (SUBR)lowprx }, - { "vlowres", S(LOWPR_SEP),0, 3, "a", "akkik", (SUBR)lowpr_w_sep_set, (SUBR)lowpr_w_sep } + { "vlowres", S(LOWPR_SEP),0, "a", "akkik", (SUBR)lowpr_w_sep_set, (SUBR)lowpr_w_sep } }; int32_t lowpassr_init_(CSOUND *csound) diff --git a/Opcodes/lufs.c b/Opcodes/lufs.c index f39ae725a1b..31a4725853a 100644 --- a/Opcodes/lufs.c +++ b/Opcodes/lufs.c @@ -392,8 +392,8 @@ static int32_t lufs_perf2(CSOUND *csound, LUFS2 *p) #define S(x) sizeof(x) static OENTRY lufs_localops[] = { -{ "lufs.a", S(LUFS), 0, 3, "kkk", "ka", (SUBR)lufs_init, (SUBR)lufs_perf }, -{ "lufs.aa", S(LUFS2), 0, 3, "kkk", "kaa", (SUBR)lufs_init2, (SUBR)lufs_perf2 } +{ "lufs.a", S(LUFS), 0, "kkk", "ka", (SUBR)lufs_init, (SUBR)lufs_perf }, +{ "lufs.aa", S(LUFS2), 0, "kkk", "kaa", (SUBR)lufs_init2, (SUBR)lufs_perf2 } }; LINKAGE_BUILTIN(lufs_localops) diff --git a/Opcodes/metro.c b/Opcodes/metro.c index 15078834509..4b34edc3b8a 100644 --- a/Opcodes/metro.c +++ b/Opcodes/metro.c @@ -346,12 +346,12 @@ static int32_t timeseq(CSOUND *csound, TIMEDSEQ *p) #define S(x) sizeof(x) static OENTRY localops[] = { - { "metro", S(METRO), 0, 3, "k", "ko", (SUBR)metro_set, (SUBR)metro }, - { "metro2", S(METRO2), 0, 3, "k", "kkpo", (SUBR)metro2_set, (SUBR)metro2 }, - { "metrobpm",S(METRO), 0, 3, "k", "koO", (SUBR)metro_set, (SUBR)metrobpm }, - { "splitrig", S(SPLIT_TRIG), 0, 3, "", "kkiiz", + { "metro", S(METRO), 0, "k", "ko", (SUBR)metro_set, (SUBR)metro }, + { "metro2", S(METRO2), 0, "k", "kkpo", (SUBR)metro2_set, (SUBR)metro2 }, + { "metrobpm",S(METRO), 0, "k", "koO", (SUBR)metro_set, (SUBR)metrobpm }, + { "splitrig", S(SPLIT_TRIG), 0, "", "kkiiz", (SUBR)split_trig_set, (SUBR)split_trig }, - { "timedseq",S(TIMEDSEQ), TR, 3, "k", "kiz", (SUBR)timeseq_set, (SUBR)timeseq } + { "timedseq",S(TIMEDSEQ), TR, "k", "kiz", (SUBR)timeseq_set, (SUBR)timeseq } }; int32_t metro_init_(CSOUND *csound) diff --git a/Opcodes/midiops2.c b/Opcodes/midiops2.c index 21e1981d7d8..fba7d61f02a 100644 --- a/Opcodes/midiops2.c +++ b/Opcodes/midiops2.c @@ -617,28 +617,22 @@ static int32_t midipgm_opcode(CSOUND *csound, MIDIPGM_OP *p) #define S(x) sizeof(x) static OENTRY localops[] = { -{ "ctrl14", 0xffff, }, -{ "ctrl21", 0xffff, }, -{ "ctrl7", 0xffff, }, -{ "midic14", 0xffff, }, -{ "midic21", 0xffff, }, -{ "midic7", 0xffff, }, -{ "midic7.i",S(MIDICTL2),0, 1, "i", "iiio", (SUBR)imidic7, NULL, NULL }, -{ "midic7.k", S(MIDICTL2),0, 3, "k", "ikko", (SUBR)midic7set, (SUBR)midic7, NULL }, -{ "midic14.i", S(MIDICTL3), 0, 1,"i", "iiiio",(SUBR)imidic14, NULL, NULL }, -{ "midic14.k", S(MIDICTL3), 0, 3,"k", "iikko",(SUBR)midic14set, (SUBR)midic14,NULL}, -{ "midic21.i", S(MIDICTL4),0, 1,"i", "iiiiio",(SUBR)imidic21, NULL, NULL }, -{ "midic21.k", S(MIDICTL4), 0, 3,"k", "iiikko",(SUBR)midic21set,(SUBR)midic21,NULL}, -{ "ctrl7.i", S(CTRL7), 0, 1, "i", "iiiio", (SUBR)ictrl7, NULL, NULL }, -{ "ctrl7.k", S(CTRL7), 0, 3, "k", "iikko", (SUBR)ctrl7set, (SUBR)ctrl7, NULL }, -{ "ctrl14.i", S(CTRL14),0, 1, "i", "iiiiio",(SUBR)ictrl14, NULL, NULL }, -{ "ctrl14.k", S(CTRL14), 0, 3, "k", "iiikko",(SUBR)ctrl14set, (SUBR)ctrl14, NULL }, -{ "ctrl21.i", S(CTRL21),0, 1, "i", "iiiiiio", (SUBR)ictrl21, NULL, NULL }, -{ "ctrl21.k", S(CTRL21), 0, 3, "k", "iiiikko", (SUBR)ctrl21set,(SUBR)ctrl21,NULL}, -{ "initc7", S(INITC7), 0, 1, "", "iii", (SUBR)initc7, NULL, NULL }, -{ "initc14", S(INITC14), 0, 1, "", "iiii", (SUBR)initc14, NULL, NULL }, -{ "initc21", S(INITC21), 0, 1, "", "iiiii",(SUBR)initc21, NULL, NULL }, -{ "midipgm", S(MIDIPGM_OP), 0, 1, "i", "o", (SUBR)midipgm_opcode, NULL, NULL } + { "midic7.i",S(MIDICTL2),0, "i", "iiio", (SUBR)imidic7, NULL, NULL }, +{ "midic7.k", S(MIDICTL2),0, "k", "ikko", (SUBR)midic7set, (SUBR)midic7, NULL }, +{ "midic14.i", S(MIDICTL3), 0,"i", "iiiio",(SUBR)imidic14, NULL, NULL }, +{ "midic14.k", S(MIDICTL3), 0, "k", "iikko",(SUBR)midic14set, (SUBR)midic14,NULL}, +{ "midic21.i", S(MIDICTL4),0,"i", "iiiiio",(SUBR)imidic21, NULL, NULL }, +{ "midic21.k", S(MIDICTL4), 0, "k", "iiikko",(SUBR)midic21set,(SUBR)midic21,NULL}, +{ "ctrl7.i", S(CTRL7), 0, "i", "iiiio", (SUBR)ictrl7, NULL, NULL }, +{ "ctrl7.k", S(CTRL7), 0, "k", "iikko", (SUBR)ctrl7set, (SUBR)ctrl7, NULL }, +{ "ctrl14.i", S(CTRL14),0, "i", "iiiiio",(SUBR)ictrl14, NULL, NULL }, +{ "ctrl14.k", S(CTRL14), 0, "k", "iiikko",(SUBR)ctrl14set, (SUBR)ctrl14, NULL }, +{ "ctrl21.i", S(CTRL21),0, "i", "iiiiiio", (SUBR)ictrl21, NULL, NULL }, +{ "ctrl21.k", S(CTRL21), 0, "k", "iiiikko", (SUBR)ctrl21set,(SUBR)ctrl21,NULL}, +{ "initc7", S(INITC7), 0, "", "iii", (SUBR)initc7, NULL, NULL }, +{ "initc14", S(INITC14), 0, "", "iiii", (SUBR)initc14, NULL, NULL }, +{ "initc21", S(INITC21), 0, "", "iiiii",(SUBR)initc21, NULL, NULL }, +{ "midipgm", S(MIDIPGM_OP), 0, "i", "o", (SUBR)midipgm_opcode, NULL, NULL } }; int32_t midiops2_init_(CSOUND *csound) diff --git a/Opcodes/midiops3.c b/Opcodes/midiops3.c index 7e4b093537e..dd9752daa5a 100644 --- a/Opcodes/midiops3.c +++ b/Opcodes/midiops3.c @@ -466,41 +466,35 @@ static int32_t islider32bit14(CSOUND *csound, ISLIDER32BIT14 *p) #define S(x) sizeof(x) static OENTRY localops[] = { -{ "s16b14", 0xffff, }, -{ "s32b14", 0xffff, }, -{ "slider16", 0xffff, }, -{ "slider32", 0xffff, }, -{ "slider64", 0xffff, }, -{ "slider8", 0xffff, }, -{ "slider8.k", S(SLIDER8), 0, 3, "kkkkkkkk", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" +{ "slider8.k", S(SLIDER8), 0, "kkkkkkkk", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiii", (SUBR)slider_i8, (SUBR)slider8, NULL }, -{ "slider8f", S(SLIDER8f), 0, 3, "kkkkkkkk","iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" +{ "slider8f", S(SLIDER8f), 0, "kkkkkkkk","iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiii", (SUBR)slider_i8f, (SUBR)slider8f, NULL }, -{ "slider8.i", S(SLIDER8), 0, 1, "iiiiiiii", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii", +{ "slider8.i", S(SLIDER8), 0, "iiiiiiii", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii", (SUBR)islider8, NULL, NULL }, -{ "slider16.k", S(SLIDER16), 0, 3, "kkkkkkkkkkkkkkkk", +{ "slider16.k", S(SLIDER16), 0, "kkkkkkkkkkkkkkkk", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiii", (SUBR)slider_i16, (SUBR)slider16, NULL }, -{ "slider16f", S(SLIDER16f), 0, 3, "kkkkkkkkkkkkkkkk", +{ "slider16f", S(SLIDER16f), 0, "kkkkkkkkkkkkkkkk", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiii", (SUBR)slider_i16f, (SUBR)slider16f, NULL }, -{ "slider16.i", S(SLIDER16), 0, 1, "iiiiiiiiiiiiiiii", +{ "slider16.i", S(SLIDER16), 0, "iiiiiiiiiiiiiiii", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiii", (SUBR)islider16, NULL, NULL }, -{ "slider32.k", S(SLIDER32), 0, 3, "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk", +{ "slider32.k", S(SLIDER32), 0, "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiii", (SUBR)slider_i32, (SUBR)slider32, NULL }, -{ "slider32f", S(SLIDER32f), 0, 3, "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk", +{ "slider32f", S(SLIDER32f), 0, "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" @@ -508,13 +502,13 @@ static OENTRY localops[] = { "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiii", (SUBR)slider_i32f, (SUBR)slider32f, NULL }, -{ "slider32.i", S(SLIDER32), 0, 1, "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii", +{ "slider32.i", S(SLIDER32), 0, "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiii", (SUBR)islider32, NULL, NULL }, -{ "slider64.k", S(SLIDER64), 0, 3, "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk" +{ "slider64.k", S(SLIDER64), 0, "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk" "kkkkkkkkkkkkkkkkkkk", "iiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiii" @@ -530,7 +524,7 @@ static OENTRY localops[] = { "iiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiii", (SUBR)slider_i64, (SUBR)slider64, NULL }, -{ "slider64f", S(SLIDER64f), 0, 3, "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk" +{ "slider64f", S(SLIDER64f), 0, "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk" "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk", "iiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiii" @@ -549,7 +543,7 @@ static OENTRY localops[] = { "iiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiii", (SUBR)slider_i64f, (SUBR)slider64f, NULL }, -{ "slider64.i", S(SLIDER64), 0, 1, "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" +{ "slider64.i", S(SLIDER64), 0, "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii", "iiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiii" @@ -563,12 +557,12 @@ static OENTRY localops[] = { "iiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiii", (SUBR)islider64, NULL, NULL }, -{ "s16b14.k", S(SLIDER16BIT14), 0, 3, "kkkkkkkkkkkkkkkk", +{ "s16b14.k", S(SLIDER16BIT14), 0, "kkkkkkkkkkkkkkkk", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii", (SUBR)slider_i16bit14, (SUBR)slider16bit14, NULL}, -{ "s32b14.k", S(SLIDER32BIT14), 0, 3, "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk", +{ "s32b14.k", S(SLIDER32BIT14), 0, "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" @@ -576,14 +570,14 @@ static OENTRY localops[] = { "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii", (SUBR)slider_i32bit14, (SUBR)slider32bit14, NULL}, -{ "s16b14.i", S(ISLIDER16BIT14), 0, 1, "iiiiiiiiiiiiiiii", +{ "s16b14.i", S(ISLIDER16BIT14), 0, "iiiiiiiiiiiiiiii", "iiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiii", (SUBR)islider16bit14, NULL, NULL }, -{ "s32b14.i", S(ISLIDER32BIT14), 0, 1, "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii", +{ "s32b14.i", S(ISLIDER32BIT14), 0, "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" diff --git a/Opcodes/minmax.c b/Opcodes/minmax.c index 0636c3d7768..9b717ffa9f2 100644 --- a/Opcodes/minmax.c +++ b/Opcodes/minmax.c @@ -364,22 +364,22 @@ static int32_t MinAbs_krate(CSOUND *csound, MINMAX *p) #define S(x) sizeof(x) static OENTRY minmax_localops[] = { - {"maxaccum", S(MINMAXACCUM), WI, 2, "", "aa", NULL, (SUBR) MaxAccumulate}, - {"minaccum", S(MINMAXACCUM), WI, 2, "", "aa", NULL, (SUBR) MinAccumulate}, - {"maxabsaccum", S(MINMAXACCUM), WI, 2, "", "aa", NULL, + {"maxaccum", S(MINMAXACCUM), WI, "", "aa", NULL, (SUBR) MaxAccumulate}, + {"minaccum", S(MINMAXACCUM), WI, "", "aa", NULL, (SUBR) MinAccumulate}, + {"maxabsaccum", S(MINMAXACCUM), WI, "", "aa", NULL, (SUBR) MaxAbsAccumulate}, - {"minabsaccum", S(MINMAXACCUM), WI, 2, "", "aa", NULL, + {"minabsaccum", S(MINMAXACCUM), WI, "", "aa", NULL, (SUBR) MinAbsAccumulate}, - {"max.a", S(MINMAX), 0, 2, "a", "ay", NULL, (SUBR) Max_arate}, - {"min.a", S(MINMAX), 0, 2, "a", "ay", NULL, (SUBR) Min_arate}, - {"maxabs.a", S(MINMAX), 0, 2, "a", "ay", NULL, (SUBR) MaxAbs_arate}, - {"minabs.a", S(MINMAX), 0, 2, "a", "ay", NULL, (SUBR) MinAbs_arate}, - {"max.i", S(MINMAX), 0, 1, "i", "im", (SUBR) Max_krate, NULL, NULL}, - {"max.k", S(MINMAX), 0, 2, "k", "kz", NULL, (SUBR) Max_krate, NULL}, - {"min.i", S(MINMAX), 0, 1, "i", "im", (SUBR) Min_krate, NULL, NULL}, - {"min.k", S(MINMAX), 0, 2, "k", "kz", NULL, (SUBR) Min_krate, NULL}, - {"maxabs.k", S(MINMAX), 0, 2, "k", "kz", NULL, (SUBR) MaxAbs_krate, NULL}, - {"minabs.k", S(MINMAX), 0, 2, "k", "kz", NULL, (SUBR) MinAbs_krate, NULL} + {"max.a", S(MINMAX), 0, "a", "ay", NULL, (SUBR) Max_arate}, + {"min.a", S(MINMAX), 0, "a", "ay", NULL, (SUBR) Min_arate}, + {"maxabs.a", S(MINMAX), 0, "a", "ay", NULL, (SUBR) MaxAbs_arate}, + {"minabs.a", S(MINMAX), 0, "a", "ay", NULL, (SUBR) MinAbs_arate}, + {"max.i", S(MINMAX), 0, "i", "im", (SUBR) Max_krate, NULL, NULL}, + {"max.k", S(MINMAX), 0, "k", "kz", NULL, (SUBR) Max_krate, NULL}, + {"min.i", S(MINMAX), 0, "i", "im", (SUBR) Min_krate, NULL, NULL}, + {"min.k", S(MINMAX), 0, "k", "kz", NULL, (SUBR) Min_krate, NULL}, + {"maxabs.k", S(MINMAX), 0, "k", "kz", NULL, (SUBR) MaxAbs_krate, NULL}, + {"minabs.k", S(MINMAX), 0, "k", "kz", NULL, (SUBR) MinAbs_krate, NULL} }; LINKAGE_BUILTIN(minmax_localops) diff --git a/Opcodes/mixer.cpp b/Opcodes/mixer.cpp index 8ab05d14f6e..8c9e720538c 100644 --- a/Opcodes/mixer.cpp +++ b/Opcodes/mixer.cpp @@ -300,21 +300,21 @@ struct MixerClear : public OpcodeBase { extern "C" { static OENTRY localops[] = { - {(char *)"MixerSetLevel", sizeof(MixerSetLevel), _CW, 3, (char *)"", + {(char *)"MixerSetLevel", sizeof(MixerSetLevel), _CW, (char *)"", (char *)"iik", (SUBR)&MixerSetLevel::init_, (SUBR)&MixerSetLevel::kontrol_, 0}, - {(char *)"MixerSetLevel_i", sizeof(MixerSetLevel), _CW, 1, (char *)"", + {(char *)"MixerSetLevel_i", sizeof(MixerSetLevel), _CW, (char *)"", (char *)"iii", (SUBR)&MixerSetLevel::init_, 0, 0}, - {(char *)"MixerGetLevel", sizeof(MixerGetLevel), _CR, 3, (char *)"k", + {(char *)"MixerGetLevel", sizeof(MixerGetLevel), _CR, (char *)"k", (char *)"ii", (SUBR)&MixerGetLevel::init_, (SUBR)&MixerGetLevel::kontrol_, 0}, - {(char *)"MixerSend", sizeof(MixerSend), _CW, 3, (char *)"", (char *)"aiii", + {(char *)"MixerSend", sizeof(MixerSend), _CW, (char *)"", (char *)"aiii", (SUBR)&MixerSend::init_, (SUBR)&MixerSend::audio_}, - {(char *)"MixerReceive", sizeof(MixerReceive), _CR, 3, (char *)"a", + {(char *)"MixerReceive", sizeof(MixerReceive), _CR, (char *)"a", (char *)"ii", (SUBR)&MixerReceive::init_, (SUBR)&MixerReceive::audio_}, - {(char *)"MixerClear", sizeof(MixerClear), 0, 3, (char *)"", (char *)"", + {(char *)"MixerClear", sizeof(MixerClear), 0, (char *)"", (char *)"", (SUBR)&MixerClear::init_, (SUBR)&MixerClear::audio_}, - {NULL, 0, 0, 0, NULL, NULL, (SUBR)NULL, (SUBR)NULL, (SUBR)NULL}}; + {NULL, 0, 0, NULL, NULL, (SUBR)NULL, (SUBR)NULL, (SUBR)NULL}}; PUBLIC int csoundModuleCreate_mixer(CSOUND *csound) { std::map>>> @@ -328,8 +328,6 @@ PUBLIC int csoundModuleCreate_mixer(CSOUND *csound) { return OK; } - - /* * The mixer busses are laid out: * busses[csound][bus][channel][frame]. @@ -387,10 +385,10 @@ PUBLIC int32_t csoundModuleInit_mixer(CSOUND *csound) { while (ep->opname != NULL) { err |= csound->AppendOpcode(csound, ep->opname, ep->dsblksiz, ep->flags, - ep->thread, ep->outypes, ep->intypes, - (int32_t (*)(CSOUND *, void *))ep->iopadr, - (int32_t (*)(CSOUND *, void *))ep->kopadr, - (int32_t (*)(CSOUND *, void *))ep->aopadr); + ep->outypes, ep->intypes, + (int32_t (*)(CSOUND *, void *))ep->init, + (int32_t (*)(CSOUND *, void *))ep->perf, + (int32_t (*)(CSOUND *, void *))ep->deinit); ep++; } // need to register reset callback diff --git a/Opcodes/modal4.c b/Opcodes/modal4.c index 35e709bde05..a19fe58f1aa 100644 --- a/Opcodes/modal4.c +++ b/Opcodes/modal4.c @@ -1,25 +1,25 @@ /* - modal4.c: + modal4.c: - Copyright (C) 1996, 1997 Perry Cook, John ffitch + Copyright (C) 1996, 1997 Perry Cook, John ffitch - This file is part of Csound. + This file is part of Csound. - The Csound Library is free software; you can redistribute it - and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + The Csound Library is free software; you can redistribute it + and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - Csound is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. + Csound is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with Csound; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - 02110-1301 USA - */ + You should have received a copy of the GNU Lesser General Public + License along with Csound; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + 02110-1301 USA +*/ /*******************************************/ /* 4 Resonance Modal Synthesis Instrument */ @@ -42,195 +42,195 @@ #include #include "interlocks.h" static int32_t make_Modal4(CSOUND *csound, - Modal4 *m, MYFLT *ifn, MYFLT vgain, MYFLT vrate) + Modal4 *m, MYFLT *ifn, MYFLT vgain, MYFLT vrate) { - FUNC *ftp; - - if (LIKELY((ftp = csound->FTnp2Find(csound,ifn)) != NULL)) - m->vibr = ftp; - else { /* Expect sine wave */ - csound->ErrorMsg(csound, "%s", Str("No table for Modal4 case")); - return NOTOK; - } - make_Envelope(&m->envelope); - /* We do not make the excitation wave here yet, */ - /* because we do not know what it's going to be. */ - make_BiQuad(&m->filters[0]); - make_BiQuad(&m->filters[1]); - make_BiQuad(&m->filters[2]); - make_BiQuad(&m->filters[3]); - make_OnePole(&m->onepole); - - m->v_rate = vrate; /* 6.0; */ - m->vibrGain = vgain; /* 0.05; */ - -/* m->directGain = 0.0; */ - m->masterGain = FL(1.0); -/* m->baseFreq = 440.0; */ -/* Modal4_setRatioAndReson(m, 0, 1.00, 0.9997); */ /* Set some */ -/* Modal4_setRatioAndReson(m, 1, 1.30, 0.9997); */ /* silly */ -/* Modal4_setRatioAndReson(m, 2, 1.77, 0.9997); */ /* default */ -/* Modal4_setRatioAndReson(m, 3, 2.37, 0.9997); */ /* values here */ -/* Modal4_setFiltGain(m, 0, 0.01); */ -/* Modal4_setFiltGain(m, 1, 0.01); */ -/* Modal4_setFiltGain(m, 2, 0.01); */ -/* Modal4_setFiltGain(m, 3, 0.01); */ -/* OnePole_clear(&m->onepole); */ - BiQuad_clear(&m->filters[0]); - BiQuad_clear(&m->filters[1]); - BiQuad_clear(&m->filters[2]); - BiQuad_clear(&m->filters[3]); - BiQuad_setEqualGainZeroes(m->filters[0]); - BiQuad_setEqualGainZeroes(m->filters[1]); - BiQuad_setEqualGainZeroes(m->filters[2]); - BiQuad_setEqualGainZeroes(m->filters[3]); -/* stickHardness = 0.5; */ -/* strikePosition = 0.561; */ - return OK; + FUNC *ftp; + + if (LIKELY((ftp = csound->FTnp2Find(csound,ifn)) != NULL)) + m->vibr = ftp; + else { /* Expect sine wave */ + csound->ErrorMsg(csound, "%s", Str("No table for Modal4 case")); + return NOTOK; + } + make_Envelope(&m->envelope); + /* We do not make the excitation wave here yet, */ + /* because we do not know what it's going to be. */ + make_BiQuad(&m->filters[0]); + make_BiQuad(&m->filters[1]); + make_BiQuad(&m->filters[2]); + make_BiQuad(&m->filters[3]); + make_OnePole(&m->onepole); + + m->v_rate = vrate; /* 6.0; */ + m->vibrGain = vgain; /* 0.05; */ + + /* m->directGain = 0.0; */ + m->masterGain = FL(1.0); + /* m->baseFreq = 440.0; */ + /* Modal4_setRatioAndReson(m, 0, 1.00, 0.9997); */ /* Set some */ + /* Modal4_setRatioAndReson(m, 1, 1.30, 0.9997); */ /* silly */ + /* Modal4_setRatioAndReson(m, 2, 1.77, 0.9997); */ /* default */ + /* Modal4_setRatioAndReson(m, 3, 2.37, 0.9997); */ /* values here */ + /* Modal4_setFiltGain(m, 0, 0.01); */ + /* Modal4_setFiltGain(m, 1, 0.01); */ + /* Modal4_setFiltGain(m, 2, 0.01); */ + /* Modal4_setFiltGain(m, 3, 0.01); */ + /* OnePole_clear(&m->onepole); */ + BiQuad_clear(&m->filters[0]); + BiQuad_clear(&m->filters[1]); + BiQuad_clear(&m->filters[2]); + BiQuad_clear(&m->filters[3]); + BiQuad_setEqualGainZeroes(m->filters[0]); + BiQuad_setEqualGainZeroes(m->filters[1]); + BiQuad_setEqualGainZeroes(m->filters[2]); + BiQuad_setEqualGainZeroes(m->filters[3]); + /* stickHardness = 0.5; */ + /* strikePosition = 0.561; */ + return OK; } void Modal4_setFreq(CSOUND *csound, Modal4 *m, MYFLT frequency) { - m->baseFreq = frequency; - Modal4_setRatioAndReson(csound, m, 0,m->ratios[0],m->resons[0]); - Modal4_setRatioAndReson(csound, m, 1,m->ratios[1],m->resons[1]); - Modal4_setRatioAndReson(csound, m, 2,m->ratios[2],m->resons[2]); - Modal4_setRatioAndReson(csound, m, 3,m->ratios[3],m->resons[3]); + m->baseFreq = frequency; + Modal4_setRatioAndReson(csound, m, 0,m->ratios[0],m->resons[0]); + Modal4_setRatioAndReson(csound, m, 1,m->ratios[1],m->resons[1]); + Modal4_setRatioAndReson(csound, m, 2,m->ratios[2],m->resons[2]); + Modal4_setRatioAndReson(csound, m, 3,m->ratios[3],m->resons[3]); } void Modal4_setRatioAndReson(CSOUND *csound, Modal4 *m, int32_t whichOne, MYFLT ratio,MYFLT reson) { - MYFLT temp; - Modal4 *p = m; - if (ratio* m->baseFreq < m->sr * FL(0.5)) { - m->ratios[whichOne] = ratio; - } - else { - temp = ratio; - while (temp* m->baseFreq > FL(0.5)*m->sr) temp *= FL(0.5); - m->ratios[whichOne] = temp; - } - m->resons[whichOne] = reson; - if (ratio<0) - temp = -ratio; - else - temp = ratio * m->baseFreq; - BiQuad_setFreqAndReson(m->filters[whichOne], temp,reson); + MYFLT temp; + Modal4 *p = m; + if (ratio* m->baseFreq < m->sr * FL(0.5)) { + m->ratios[whichOne] = ratio; + } + else { + temp = ratio; + while (temp* m->baseFreq > FL(0.5)*m->sr) temp *= FL(0.5); + m->ratios[whichOne] = temp; + } + m->resons[whichOne] = reson; + if (ratio<0) + temp = -ratio; + else + temp = ratio * m->baseFreq; + BiQuad_setFreqAndReson(m->filters[whichOne], temp,reson); } static void Modal4_strike(CSOUND *csound, Modal4 *m, MYFLT amplitude) { - int32_t i; - MYFLT temp; - Modal4 *p = m; - Envelope_setRate(csound, &m->envelope, FL(1.0)); - Envelope_setTarget(&m->envelope, amplitude); - OnePole_setPole(&m->onepole, FL(1.0) - amplitude); - Envelope_tick(&m->envelope); - m->w_time = FL(0.0); - //m->w_lastOutput = FL(0.0); - m->w_allDone = 0; - /* wave->reset(); */ - for (i=0;i<4;i++) { - if (m->ratios[i] < 0) - temp = - m->ratios[i]; - else - temp = m->ratios[i] * m->baseFreq; - BiQuad_setFreqAndReson(m->filters[i], temp, m->resons[i]); - } + int32_t i; + MYFLT temp; + Modal4 *p = m; + Envelope_setRate(csound, &m->envelope, FL(1.0)); + Envelope_setTarget(&m->envelope, amplitude); + OnePole_setPole(&m->onepole, FL(1.0) - amplitude); + Envelope_tick(&m->envelope); + m->w_time = FL(0.0); + //m->w_lastOutput = FL(0.0); + m->w_allDone = 0; + /* wave->reset(); */ + for (i=0;i<4;i++) { + if (m->ratios[i] < 0) + temp = - m->ratios[i]; + else + temp = m->ratios[i] * m->baseFreq; + BiQuad_setFreqAndReson(m->filters[i], temp, m->resons[i]); + } } static void Modal4_damp(CSOUND *csound, Modal4 *m, MYFLT amplitude) { - int32_t i; - MYFLT temp; - Modal4 *p = m; - for (i=0;i<4;i++) { - if (m->ratios[i] < 0) - temp = - m->ratios[i]; - else - temp = m->ratios[i] * m->baseFreq; - BiQuad_setFreqAndReson(m->filters[i], temp, m->resons[i]*amplitude); - } + int32_t i; + MYFLT temp; + Modal4 *p = m; + for (i=0;i<4;i++) { + if (m->ratios[i] < 0) + temp = - m->ratios[i]; + else + temp = m->ratios[i] * m->baseFreq; + BiQuad_setFreqAndReson(m->filters[i], temp, m->resons[i]*amplitude); + } } static MYFLT Modal4_tick(Modal4 *m) { - MYFLT temp,temp2; - int32 itemp; - MYFLT temp_time, alpha, lastOutput; - int32_t length = (int32_t)m->wave->flen; - - m->w_time += m->w_rate; /* Update current time */ - if (m->w_time >= length) { /* Check for end of sound */ - m->w_time = (MYFLT)(length-1); /* stick at end */ - m->w_allDone = 1; /* Information for one-shot use */ - } - else if (m->w_time < FL(0.0)) /* Check for end of sound */ - m->w_time = FL(0.0); /* stick at beg */ + MYFLT temp,temp2; + int32 itemp; + MYFLT temp_time, alpha, lastOutput; + int32_t length = (int32_t)m->wave->flen; + + m->w_time += m->w_rate; /* Update current time */ + if (m->w_time >= length) { /* Check for end of sound */ + m->w_time = (MYFLT)(length-1); /* stick at end */ + m->w_allDone = 1; /* Information for one-shot use */ + } + else if (m->w_time < FL(0.0)) /* Check for end of sound */ + m->w_time = FL(0.0); /* stick at beg */ - temp_time = m->w_time; + temp_time = m->w_time; #ifdef phase_offset - if (m->w_phaseOffset != FL(0.0)) { - temp_time += m->w_phaseOffset; /* Add phase offset */ - if (temp_time >= length) /* Check for end of sound */ - temp_time = length-1; /* stick at end */ - else if (temp_time < FL(0.0)) /* check for end of sound */ - temp_time = FL(0.0); /* stick at beg */ - } + if (m->w_phaseOffset != FL(0.0)) { + temp_time += m->w_phaseOffset; /* Add phase offset */ + if (temp_time >= length) /* Check for end of sound */ + temp_time = length-1; /* stick at end */ + else if (temp_time < FL(0.0)) /* check for end of sound */ + temp_time = FL(0.0); /* stick at beg */ + } #endif - itemp = (int32) temp_time; /* Integer part of time address */ - alpha = temp_time - (MYFLT)itemp; /* fractional part of time address */ - lastOutput = m->wave->ftable[itemp]; /* Do linear interpolation */ - lastOutput = lastOutput + /* same as alpha*data[temp+1] */ - (alpha * (m->wave->ftable[itemp+1] - - lastOutput)); /* + (1-alpha)data[temp] */ - - temp = m->masterGain * - OnePole_tick(&m->onepole, lastOutput * Envelope_tick(&m->envelope)); - temp2 = BiQuad_tick(&m->filters[0], temp); - temp2 += BiQuad_tick(&m->filters[1], temp); - temp2 += BiQuad_tick(&m->filters[2], temp); - temp2 += BiQuad_tick(&m->filters[3], temp); - temp2 = temp2 - (temp2 * m->directGain); - temp2 += m->directGain * temp; - - if (m->vibrGain != 0.0) { - /* Tick on vibrato table */ - m->v_time += m->v_rate; /* Update current time */ - while (m->v_time >= m->vibr->flen) /* Check for end of sound */ - m->v_time -= m->vibr->flen; /* loop back to beginning */ - while (m->v_time < FL(0.0)) /* Check for end of sound */ - m->v_time += m->vibr->flen; /* loop back to beginning */ - - temp_time = m->v_time; + itemp = (int32) temp_time; /* Integer part of time address */ + alpha = temp_time - (MYFLT)itemp; /* fractional part of time address */ + lastOutput = m->wave->ftable[itemp]; /* Do linear interpolation */ + lastOutput = lastOutput + /* same as alpha*data[temp+1] */ + (alpha * (m->wave->ftable[itemp+1] - + lastOutput)); /* + (1-alpha)data[temp] */ + + temp = m->masterGain * + OnePole_tick(&m->onepole, lastOutput * Envelope_tick(&m->envelope)); + temp2 = BiQuad_tick(&m->filters[0], temp); + temp2 += BiQuad_tick(&m->filters[1], temp); + temp2 += BiQuad_tick(&m->filters[2], temp); + temp2 += BiQuad_tick(&m->filters[3], temp); + temp2 = temp2 - (temp2 * m->directGain); + temp2 += m->directGain * temp; + + if (m->vibrGain != 0.0) { + /* Tick on vibrato table */ + m->v_time += m->v_rate; /* Update current time */ + while (m->v_time >= m->vibr->flen) /* Check for end of sound */ + m->v_time -= m->vibr->flen; /* loop back to beginning */ + while (m->v_time < FL(0.0)) /* Check for end of sound */ + m->v_time += m->vibr->flen; /* loop back to beginning */ + + temp_time = m->v_time; #ifdef phase_offset - if (m->v_phaseOffset != FL(0.0)) { - temp_time += m->v_phaseOffset; /* Add phase offset */ - while (temp_time >= m->vibr->flen) /* Check for end of sound */ - temp_time -= m->vibr->flen; /* loop back to beginning */ - while (temp_time < FL(0.0)) /* Check for end of sound */ - temp_time += m->vibr->flen; /* loop back to beginning */ - } -#endif - - itemp = (int32) temp_time; /* Integer part of time address */ - /* fractional part of time address */ - alpha = temp_time - (MYFLT)itemp; - lastOutput = m->vibr->ftable[itemp]; /* Do linear interpolation */ - /* same as alpha*data[itemp+1] + (1-alpha)data[temp] */ - lastOutput = /*m->v)*/lastOutput + - (alpha * (m->vibr->ftable[itemp+1] - lastOutput)); - /* End of vibrato tick */ - temp = FL(1.0) + (lastOutput * m->vibrGain); /* Calculate AM */ - temp2 = temp * temp2; /* and apply to master out */ + if (m->v_phaseOffset != FL(0.0)) { + temp_time += m->v_phaseOffset; /* Add phase offset */ + while (temp_time >= m->vibr->flen) /* Check for end of sound */ + temp_time -= m->vibr->flen; /* loop back to beginning */ + while (temp_time < FL(0.0)) /* Check for end of sound */ + temp_time += m->vibr->flen; /* loop back to beginning */ } +#endif - return (temp2 + temp2); + itemp = (int32) temp_time; /* Integer part of time address */ + /* fractional part of time address */ + alpha = temp_time - (MYFLT)itemp; + lastOutput = m->vibr->ftable[itemp]; /* Do linear interpolation */ + /* same as alpha*data[itemp+1] + (1-alpha)data[temp] */ + lastOutput = /*m->v)*/lastOutput + + (alpha * (m->vibr->ftable[itemp+1] - lastOutput)); + /* End of vibrato tick */ + temp = FL(1.0) + (lastOutput * m->vibrGain); /* Calculate AM */ + temp2 = temp * temp2; /* and apply to master out */ + } + + return (temp2 + temp2); } /*******************************************/ @@ -245,119 +245,119 @@ static MYFLT Modal4_tick(Modal4 *m) int32_t marimbaset(CSOUND *csound, MARIMBA *p) { - Modal4 *m = &(p->m4); - MYFLT temp,temp2; - int32_t itemp; - FUNC *ftp; - p->m4.sr = CS_ESR; - p->m4.h = p->h; - - if (LIKELY((ftp = csound->FTnp2Find(csound, p->ifn)) != NULL)) - p->m4.wave = ftp; - else { /* Expect an impulslything */ - return csound->InitError(csound, "%s", Str("No table for Marimba strike")); - } - - if (UNLIKELY(make_Modal4(csound, - m, p->ivfn, *p->vibAmt, *p->vibFreq)==NOTOK)) - return NOTOK; - p->m4.w_phaseOffset = FL(0.0); -/* p->m4.w_rate = 0.5; */ - Modal4_setRatioAndReson(csound,m,0, FL(1.00), FL(0.9996)); /* Set all 132.0 */ - Modal4_setRatioAndReson(csound,m,1, FL(3.99), FL(0.9994)); /* of our 523.0 */ - Modal4_setRatioAndReson(csound,m,2,FL(10.65), FL(0.9994)); /* default 1405.0 */ - Modal4_setRatioAndReson(csound,m,3,-FL(18.50),FL(0.999)); /* resonances 2443 */ - Modal4_setFiltGain(m, 0, FL(0.04)); /* and */ - Modal4_setFiltGain(m, 1, FL(0.01)); /* gains */ - Modal4_setFiltGain(m, 2, FL(0.01)); /* for each */ - Modal4_setFiltGain(m, 3, FL(0.008)); /* resonance */ - p->m4.directGain = FL(0.1); - p->multiStrike = 0; - p->strikePosition = *p->spos; - /* Set Stick hardness stuff */ - p->stickHardness = *p->hardness; - p->m4.w_rate = (FL(0.25) * (MYFLT)pow(4.0,(double)p->stickHardness)); - p->m4.masterGain = (FL(0.1) + (FL(1.8) * p->stickHardness)); - /* Set Strike position */ - temp2 = p->strikePosition * PI_F; - temp = SIN(temp2); - BiQuad_setGain(p->m4.filters[0], FL(0.12)*temp); /* 1st mode function of pos.*/ - temp = SIN(FL(0.05) + (FL(3.9) * temp2)); - BiQuad_setGain(p->m4.filters[1], - -FL(0.03)*temp); /* 2nd mode function of pos.*/ - temp = SIN(-FL(0.05) + (FL(11.0) * temp2)); - BiQuad_setGain(p->m4.filters[2], FL(0.11)*temp); /* 3rd mode function of pos.*/ - /* Strike */ - { - int32_t triples = (*p->triples<=FL(0.0) ? 20 : (int32_t)*p->triples); - int32_t doubles = (*p->doubles<=FL(0.0) ? 40 : triples + (int32_t)*p->doubles); - OPARMS parm; - csound->GetOParms(csound, &parm); - itemp = csound->Rand31(csound->RandSeed1(csound)) % 100; - if (itemp < triples) { - p->multiStrike = 2; - if (parm.msglevel & CS_RNGEMSG) - csound->Message(csound, "%s", Str("striking three times here!!!\n")); - } - else if (itemp < doubles) { - p->multiStrike = 1; - if (parm.msglevel & CS_RNGEMSG) - csound->Message(csound, "%s", Str("striking twice here!!\n")); - } - else p->multiStrike = 0; + Modal4 *m = &(p->m4); + MYFLT temp,temp2; + int32_t itemp; + FUNC *ftp; + p->m4.sr = CS_ESR; + p->m4.h = p->h; + + if (LIKELY((ftp = csound->FTnp2Find(csound, p->ifn)) != NULL)) + p->m4.wave = ftp; + else { /* Expect an impulslything */ + return csound->InitError(csound, "%s", Str("No table for Marimba strike")); + } + + if (UNLIKELY(make_Modal4(csound, + m, p->ivfn, *p->vibAmt, *p->vibFreq)==NOTOK)) + return NOTOK; + p->m4.w_phaseOffset = FL(0.0); + /* p->m4.w_rate = 0.5; */ + Modal4_setRatioAndReson(csound,m,0, FL(1.00), FL(0.9996)); /* Set all 132.0 */ + Modal4_setRatioAndReson(csound,m,1, FL(3.99), FL(0.9994)); /* of our 523.0 */ + Modal4_setRatioAndReson(csound,m,2,FL(10.65), FL(0.9994)); /* default 1405.0 */ + Modal4_setRatioAndReson(csound,m,3,-FL(18.50),FL(0.999)); /* resonances 2443 */ + Modal4_setFiltGain(m, 0, FL(0.04)); /* and */ + Modal4_setFiltGain(m, 1, FL(0.01)); /* gains */ + Modal4_setFiltGain(m, 2, FL(0.01)); /* for each */ + Modal4_setFiltGain(m, 3, FL(0.008)); /* resonance */ + p->m4.directGain = FL(0.1); + p->multiStrike = 0; + p->strikePosition = *p->spos; + /* Set Stick hardness stuff */ + p->stickHardness = *p->hardness; + p->m4.w_rate = (FL(0.25) * (MYFLT)pow(4.0,(double)p->stickHardness)); + p->m4.masterGain = (FL(0.1) + (FL(1.8) * p->stickHardness)); + /* Set Strike position */ + temp2 = p->strikePosition * PI_F; + temp = SIN(temp2); + BiQuad_setGain(p->m4.filters[0], FL(0.12)*temp); /* 1st mode function of pos.*/ + temp = SIN(FL(0.05) + (FL(3.9) * temp2)); + BiQuad_setGain(p->m4.filters[1], + -FL(0.03)*temp); /* 2nd mode function of pos.*/ + temp = SIN(-FL(0.05) + (FL(11.0) * temp2)); + BiQuad_setGain(p->m4.filters[2], FL(0.11)*temp); /* 3rd mode function of pos.*/ + /* Strike */ + { + int32_t triples = (*p->triples<=FL(0.0) ? 20 : (int32_t)*p->triples); + int32_t doubles = (*p->doubles<=FL(0.0) ? 40 : triples + (int32_t)*p->doubles); + OPARMS parm; + csound->GetOParms(csound, &parm); + itemp = csound->Rand31(csound->RandSeed1(csound)) % 100; + if (itemp < triples) { + p->multiStrike = 2; + if (parm.msglevel & CS_RNGEMSG) + csound->Message(csound, "%s", Str("striking three times here!!!\n")); } - Modal4_strike(csound, m, *p->amplitude * AMP_RSCALE); - Modal4_setFreq(csound, m, *p->frequency); - p->first = 1; - { - int32_t relestim = (int32_t) (CS_EKR * *p->dettack); - /* 0.1 second decay extention */ - if (relestim > p->h.insdshead->xtratim) - p->h.insdshead->xtratim = relestim; + else if (itemp < doubles) { + p->multiStrike = 1; + if (parm.msglevel & CS_RNGEMSG) + csound->Message(csound, "%s", Str("striking twice here!!\n")); } - p->kloop = (int32_t) ((int32_t) (p->h.insdshead->offtim * CS_EKR) - - (int32_t) (CS_EKR * *p->dettack)); - return OK; + else p->multiStrike = 0; + } + Modal4_strike(csound, m, *p->amplitude * AMP_RSCALE); + Modal4_setFreq(csound, m, *p->frequency); + p->first = 1; + { + int32_t relestim = (int32_t) (CS_EKR * *p->dettack); + /* 0.1 second decay extention */ + if (relestim > p->h.insdshead->xtratim) + p->h.insdshead->xtratim = relestim; + } + p->kloop = (int32_t) ((int32_t) (p->h.insdshead->offtim * CS_EKR) + - (int32_t) (CS_EKR * *p->dettack)); + return OK; } int32_t marimba(CSOUND *csound, MARIMBA *p) { - Modal4 *m = &(p->m4); - MYFLT *ar = p->ar; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t n, nsmps = CS_KSMPS; - MYFLT amp = (*p->amplitude) * AMP_RSCALE; /* Normalise */ - - if (p->kloop>0 && p->h.insdshead->relesing) p->kloop=1; - if ((--p->kloop) == 0) { - Modal4_damp(csound, m, FL(1.0) - (amp * FL(0.03))); - } - p->m4.v_rate = *p->vibFreq; /* 6.0; */ - p->m4.vibrGain = *p->vibAmt; /* 0.05; */ - if (UNLIKELY(p->first)) { - Modal4_strike(csound, m, *p->amplitude * AMP_RSCALE); - Modal4_setFreq(csound, m, *p->frequency); - p->first = 0; - } - if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - nsmps -= early; - memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset;nmultiStrike>0) - if (p->m4.w_allDone) { - p->m4.w_time = FL(0.0); - //p->m4.w_lastOutput = FL(0.0); - p->m4.w_allDone = 0; - p->multiStrike -= 1; - } - lastOutput = Modal4_tick(m); - ar[n] = lastOutput*AMP_SCALE*FL(0.5); - } - return OK; + Modal4 *m = &(p->m4); + MYFLT *ar = p->ar; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t n, nsmps = CS_KSMPS; + MYFLT amp = (*p->amplitude) * AMP_RSCALE; /* Normalise */ + + if (p->kloop>0 && p->h.insdshead->relesing) p->kloop=1; + if ((--p->kloop) == 0) { + Modal4_damp(csound, m, FL(1.0) - (amp * FL(0.03))); + } + p->m4.v_rate = *p->vibFreq; /* 6.0; */ + p->m4.vibrGain = *p->vibAmt; /* 0.05; */ + if (UNLIKELY(p->first)) { + Modal4_strike(csound, m, *p->amplitude * AMP_RSCALE); + Modal4_setFreq(csound, m, *p->frequency); + p->first = 0; + } + if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + nsmps -= early; + memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); + } + for (n=offset;nmultiStrike>0) + if (p->m4.w_allDone) { + p->m4.w_time = FL(0.0); + //p->m4.w_lastOutput = FL(0.0); + p->m4.w_allDone = 0; + p->multiStrike -= 1; + } + lastOutput = Modal4_tick(m); + ar[n] = lastOutput*AMP_SCALE*FL(0.5); + } + return OK; } /*******************************************/ @@ -372,79 +372,79 @@ int32_t marimba(CSOUND *csound, MARIMBA *p) int32_t vibraphnset(CSOUND *csound, VIBRAPHN *p) { - Modal4 *m = &(p->m4); - MYFLT temp; - FUNC *ftp; - p->m4.sr = CS_ESR; - p->m4.h = p->h; - - if (LIKELY((ftp = csound->FTnp2Find(csound, p->ifn)) != NULL)) - p->m4.wave = ftp; /* Expect an impulslything */ - else { - return csound->InitError(csound, "%s", Str("No table for Vibraphone strike")); - } - - if (UNLIKELY(make_Modal4(csound, m, p->ivfn, *p->vibAmt, *p->vibFreq)==NOTOK)) - return NOTOK; - - p->m4.w_phaseOffset = FL(0.0); -/* p->m4.w_rate = 13.33; */ - OnePole_setPole(&p->m4.onepole, FL(0.2)); - Modal4_setRatioAndReson(csound, m, 0, FL(1.0), FL(0.99995)); /* Set */ - Modal4_setRatioAndReson(csound, m, 1, FL(2.01),FL(0.99991)); /* our */ - Modal4_setRatioAndReson(csound, m, 2, FL(3.9), FL(0.99992)); /* resonance */ - Modal4_setRatioAndReson(csound, m, 3,FL(14.37),FL(0.99990)); /* values here */ - Modal4_setFiltGain(m, 0, FL(0.025)); - Modal4_setFiltGain(m, 1, FL(0.015)); - Modal4_setFiltGain(m, 2, FL(0.015)); - Modal4_setFiltGain(m, 3, FL(0.015)); - p->m4.directGain = FL(0.0); -/* vibrGain = 0.2; */ - p->m4.w_rate = FL(2.0) + (FL(22.66) * *p->hardness); - p->m4.masterGain = FL(0.2) + (*p->hardness * FL(1.6)); - /* Set Strike position */ - temp = (p->strikePosition = *p->spos) * PI_F; - BiQuad_setGain(p->m4.filters[0], FL(0.025) * SIN(temp)); - BiQuad_setGain(p->m4.filters[1], FL(0.015) * - SIN(FL(0.1) + (FL(2.01) * temp))); - BiQuad_setGain(p->m4.filters[2], FL(0.015) * SIN(FL(3.95) * temp)); - /* Strike */ - Modal4_strike(csound, m, *p->amplitude * AMP_RSCALE); - Modal4_setFreq(csound, m, *p->frequency); - p->first = 1; - return OK; + Modal4 *m = &(p->m4); + MYFLT temp; + FUNC *ftp; + p->m4.sr = CS_ESR; + p->m4.h = p->h; + + if (LIKELY((ftp = csound->FTnp2Find(csound, p->ifn)) != NULL)) + p->m4.wave = ftp; /* Expect an impulslything */ + else { + return csound->InitError(csound, "%s", Str("No table for Vibraphone strike")); + } + + if (UNLIKELY(make_Modal4(csound, m, p->ivfn, *p->vibAmt, *p->vibFreq)==NOTOK)) + return NOTOK; + + p->m4.w_phaseOffset = FL(0.0); + /* p->m4.w_rate = 13.33; */ + OnePole_setPole(&p->m4.onepole, FL(0.2)); + Modal4_setRatioAndReson(csound, m, 0, FL(1.0), FL(0.99995)); /* Set */ + Modal4_setRatioAndReson(csound, m, 1, FL(2.01),FL(0.99991)); /* our */ + Modal4_setRatioAndReson(csound, m, 2, FL(3.9), FL(0.99992)); /* resonance */ + Modal4_setRatioAndReson(csound, m, 3,FL(14.37),FL(0.99990)); /* values here */ + Modal4_setFiltGain(m, 0, FL(0.025)); + Modal4_setFiltGain(m, 1, FL(0.015)); + Modal4_setFiltGain(m, 2, FL(0.015)); + Modal4_setFiltGain(m, 3, FL(0.015)); + p->m4.directGain = FL(0.0); + /* vibrGain = 0.2; */ + p->m4.w_rate = FL(2.0) + (FL(22.66) * *p->hardness); + p->m4.masterGain = FL(0.2) + (*p->hardness * FL(1.6)); + /* Set Strike position */ + temp = (p->strikePosition = *p->spos) * PI_F; + BiQuad_setGain(p->m4.filters[0], FL(0.025) * SIN(temp)); + BiQuad_setGain(p->m4.filters[1], FL(0.015) * + SIN(FL(0.1) + (FL(2.01) * temp))); + BiQuad_setGain(p->m4.filters[2], FL(0.015) * SIN(FL(3.95) * temp)); + /* Strike */ + Modal4_strike(csound, m, *p->amplitude * AMP_RSCALE); + Modal4_setFreq(csound, m, *p->frequency); + p->first = 1; + return OK; } int32_t vibraphn(CSOUND *csound, VIBRAPHN *p) { - Modal4 *m = &(p->m4); - MYFLT *ar = p->ar; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t n, nsmps = CS_KSMPS; - MYFLT amp = (*p->amplitude)*AMP_RSCALE; /* Normalise */ - - if (p->kloop>0 && p->h.insdshead->relesing) p->kloop=1; - if ((--p->kloop) == 0) { - Modal4_damp(csound, m, FL(1.0) - (amp * FL(0.03))); - } - if (UNLIKELY(p->first)) { - Modal4_strike(csound, m, *p->amplitude * AMP_RSCALE); - Modal4_setFreq(csound, m, *p->frequency); - p->first = 0; - } - p->m4.v_rate = *p->vibFreq; - p->m4.vibrGain =*p->vibAmt; - if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - nsmps -= early; - memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset;nm4); + MYFLT *ar = p->ar; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t n, nsmps = CS_KSMPS; + MYFLT amp = (*p->amplitude)*AMP_RSCALE; /* Normalise */ + + if (p->kloop>0 && p->h.insdshead->relesing) p->kloop=1; + if ((--p->kloop) == 0) { + Modal4_damp(csound, m, FL(1.0) - (amp * FL(0.03))); + } + if (UNLIKELY(p->first)) { + Modal4_strike(csound, m, *p->amplitude * AMP_RSCALE); + Modal4_setFreq(csound, m, *p->frequency); + p->first = 0; + } + p->m4.v_rate = *p->vibFreq; + p->m4.vibrGain =*p->vibAmt; + if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + nsmps -= early; + memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); + } + for (n=offset;nm4); - FUNC *ftp; - MYFLT temp; - p->m4.sr = CS_ESR; - p->m4.h = p->h; - - /* Expect an impulslything */ - if (LIKELY((ftp = csound->FTnp2Find(csound, p->ifn)) != NULL)) p->m4.wave = ftp; - else { - return csound->InitError(csound, "%s", Str("No table for Agogobell strike")); - } - - if (UNLIKELY(make_Modal4(csound, m, p->ivfn, *p->vibAmt, *p->vibFreq)==NOTOK)) - return NOTOK; - - p->m4.w_phaseOffset = FL(0.0); -/* p->m4.w_rate = 7.0; */ - OnePole_setPole(&p->m4.onepole, FL(0.2)); - Modal4_setRatioAndReson(csound, m, 0, FL(1.00), FL(0.999)); /* Set */ - Modal4_setRatioAndReson(csound, m, 1, FL(4.08), FL(0.999)); /* our */ - Modal4_setRatioAndReson(csound, m, 2, FL(6.669),FL(0.999)); /* resonance */ - Modal4_setRatioAndReson(csound, m, 3,-FL(3725.0), FL(0.999)); /* values here */ - Modal4_setFiltGain(m, 0, FL(0.06)); - Modal4_setFiltGain(m, 1, FL(0.05)); - Modal4_setFiltGain(m, 2, FL(0.03)); - Modal4_setFiltGain(m, 3, FL(0.02)); - p->m4.directGain = FL(0.25); -/* vibrGain = 0.2; */ - p->m4.w_rate = FL(3.0) + (FL(8.0) * *p->hardness); - p->m4.masterGain = FL(1.0); - /* Set Strike position */ - temp = (p->strikePosition = *p->spos) * PI_F; - BiQuad_setGain(p->m4.filters[0], FL(0.08) * SIN(FL(0.7) * temp)); - BiQuad_setGain(p->m4.filters[1], FL(0.07) * SIN(FL(0.1) + (FL(5.0) * temp))); - BiQuad_setGain(p->m4.filters[2], FL(0.04) * SIN(FL(0.2) + (FL(7.0) * temp))); - /* Strike */ - Modal4_strike(csound, m, *p->amplitude*AMP_RSCALE); - Modal4_setFreq(csound, m, *p->frequency); - return OK; + Modal4 *m = &(p->m4); + FUNC *ftp; + MYFLT temp; + p->m4.sr = CS_ESR; + p->m4.h = p->h; + + /* Expect an impulslything */ + if (LIKELY((ftp = csound->FTnp2Find(csound, p->ifn)) != NULL)) p->m4.wave = ftp; + else { + return csound->InitError(csound, "%s", Str("No table for Agogobell strike")); + } + + if (UNLIKELY(make_Modal4(csound, m, p->ivfn, *p->vibAmt, *p->vibFreq)==NOTOK)) + return NOTOK; + + p->m4.w_phaseOffset = FL(0.0); + /* p->m4.w_rate = 7.0; */ + OnePole_setPole(&p->m4.onepole, FL(0.2)); + Modal4_setRatioAndReson(csound, m, 0, FL(1.00), FL(0.999)); /* Set */ + Modal4_setRatioAndReson(csound, m, 1, FL(4.08), FL(0.999)); /* our */ + Modal4_setRatioAndReson(csound, m, 2, FL(6.669),FL(0.999)); /* resonance */ + Modal4_setRatioAndReson(csound, m, 3,-FL(3725.0), FL(0.999)); /* values here */ + Modal4_setFiltGain(m, 0, FL(0.06)); + Modal4_setFiltGain(m, 1, FL(0.05)); + Modal4_setFiltGain(m, 2, FL(0.03)); + Modal4_setFiltGain(m, 3, FL(0.02)); + p->m4.directGain = FL(0.25); + /* vibrGain = 0.2; */ + p->m4.w_rate = FL(3.0) + (FL(8.0) * *p->hardness); + p->m4.masterGain = FL(1.0); + /* Set Strike position */ + temp = (p->strikePosition = *p->spos) * PI_F; + BiQuad_setGain(p->m4.filters[0], FL(0.08) * SIN(FL(0.7) * temp)); + BiQuad_setGain(p->m4.filters[1], FL(0.07) * SIN(FL(0.1) + (FL(5.0) * temp))); + BiQuad_setGain(p->m4.filters[2], FL(0.04) * SIN(FL(0.2) + (FL(7.0) * temp))); + /* Strike */ + Modal4_strike(csound, m, *p->amplitude*AMP_RSCALE); + Modal4_setFreq(csound, m, *p->frequency); + return OK; } int32_t agogobel(CSOUND *csound, VIBRAPHN *p) { - Modal4 *m = &(p->m4); - MYFLT *ar = p->ar; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t n, nsmps = CS_KSMPS; - - p->m4.v_rate = *p->vibFreq; - p->m4.vibrGain =*p->vibAmt; - if (UNLIKELY(p->first)) { - Modal4_strike(csound, m, *p->amplitude * AMP_RSCALE); - Modal4_setFreq(csound, m, *p->frequency); - p->first = 0; - } - if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - nsmps -= early; - memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset;nm4); + MYFLT *ar = p->ar; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t n, nsmps = CS_KSMPS; + + p->m4.v_rate = *p->vibFreq; + p->m4.vibrGain =*p->vibAmt; + if (UNLIKELY(p->first)) { + Modal4_strike(csound, m, *p->amplitude * AMP_RSCALE); + Modal4_setFreq(csound, m, *p->frequency); + p->first = 0; + } + if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + nsmps -= early; + memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); + } + for (n=offset;nr = r; - if (p->initDone == 0) - csound->RegisterDeinitCallback(csound, p, - (int32_t (*)(CSOUND*, void*)) mp3in_cleanup); /* done initialisation */ p->initDone = -1; p->pos = 0; @@ -564,9 +561,6 @@ static int32_t sinit3_(CSOUND *csound, DATASPACE *p) p->tab[0] = (MYFLT *) p->fdata[0].auxp; p->tab[1] = (MYFLT *) p->fdata[1].auxp; p->tstamp = 0; - if(p->initDone == -1) - csound->RegisterDeinitCallback(csound, p, - (int32_t (*)(CSOUND*, void*))mp3scale_cleanup); p->initDone = -1; p->finished = 0; p->init = 1; @@ -860,1622 +854,22 @@ static int32_t sprocess3(CSOUND *csound, DATASPACE *p) } -#ifdef ANDROID - -typedef struct _mp3scal2_ { - int32_t cnt, hsize, curframe, N, decim,tscale; - double pos; - MYFLT accum; - AUXCH outframe[MP3_CHNS], win, bwin[MP3_CHNS], fwin[MP3_CHNS], - nwin[MP3_CHNS], prev[MP3_CHNS], framecount[MP3_CHNS], fdata[MP3_CHNS], buffer; - MYFLT *indataL[8], *indataR[8]; - MYFLT *tab[MP3_CHNS]; - char curbuf; - mp3dec_t mpa; - FDCH fdch; - MYFLT resamp; - double tstamp, incr; - int32_t initDone; - uint32_t bufused; - int32_t finished; - char init; - CSOUND *csound; - pthread_t t,t1; - int32_t ti; - MYFLT ilen; - MYFLT skip; - char playing; - int32_t nsmps; - char filling; - int32_t async; - int32_t error; - MYFLT orsr; - char lock; - uint64_t end; -} MP3SCAL2; - -typedef struct _loader { - OPDS h; - STRINGDAT *res; - STRINGDAT *name; - MYFLT *skip, *iN, *idecim, *bfs; - MP3SCAL2 p; -} LOADER; - - -void *buffiller(void *pp){ - MP3SCAL2 *p = (MP3SCAL2 *) pp; - int32_t nsmps = p->nsmps; - short *buffer= (short *) p->buffer.auxp; - MYFLT *data[2]; - p->lock = 1; - if(p->mpa != NULL) { - data[0] = p->indataL[(int32_t)p->curbuf]; - data[1] = p->indataR[(int32_t)p->curbuf]; - int32_t i,j, end; - memset(data[0],0,nsmps*sizeof(MYFLT)); - memset(data[1],0,nsmps*sizeof(MYFLT)); - if(!p->finished){ - mp3dec_decode(p->mpa,p->buffer.auxp, - MP3_CHNS*nsmps*sizeof(short), - &p->bufused); - if(p->bufused == 0) p->finished = 1; - else { - end = (p->bufused/sizeof(short))/MP3_CHNS; - for(i=j=0; i < end; i++, j+=2){ - data[0][i] = buffer[j]/32768.0; - data[1][i] = buffer[j+1]/32768.0; - } - } - } - p->curbuf = (p->curbuf+1)%8; - } - p->lock = 0; - return NULL; -} - -void fillbuf2(CSOUND *csound, MP3SCAL2 *p, int32_t nsmps){ - p->nsmps = nsmps; - if(p->async) { - int32_t policy; - struct sched_param param; - pthread_create(&(p->t1), NULL, buffiller, p); - pthread_getschedparam(p->t1, &policy, - ¶m); - param.sched_priority = 1; - //policy = SCHED_OTHER; - if(pthread_setschedparam(p->t1, policy, - ¶m) != 0) - csound->Message(csound, "%s", Str("could not set priority\n")); - } - else - buffiller((void *) p); -} - - -static int32_t meminit(CSOUND *csound, LOADER *pp) -{ - - MP3SCAL2 *p = &(pp->p); - int32_t N = *pp->iN, ui; - uint32_t i; - uint32_t size; - int32_t decim = *pp->idecim; - p->N = N; - p->error = 0; - if (N) { - for (i=0; N; i++) { - N >>= 1; - } - N = (int32_t) pow(2.0, i-1); - } else N = 2048; - if (decim == 0) decim = 4; - - p->hsize = N/decim; - p->cnt = p->hsize; - p->curframe = 0; - p->pos = 0; - - for (i=0; i < MP3_CHNS; i++){ - - size = (N+2)*sizeof(MYFLT); - if (p->fwin[i].auxp == NULL || p->fwin[i].size < size) - csound->AuxAlloc(csound, size, &p->fwin[i]); - if (p->bwin[i].auxp == NULL || p->bwin[i].size < size) - csound->AuxAlloc(csound, size, &p->bwin[i]); - if (p->prev[i].auxp == NULL || p->prev[i].size < size) - csound->AuxAlloc(csound, size, &p->prev[i]); - - size = decim*sizeof(int32_t); - if (p->framecount[i].auxp == NULL || p->framecount[i].size < size) - csound->AuxAlloc(csound, size, &p->framecount[i]); - { - int32_t k=0; - for (k=0; k < decim; k++) { - ((int32_t *)(p->framecount[i].auxp))[k] = k*N; - } - } - size = decim*sizeof(MYFLT)*N; - if (p->outframe[i].auxp == NULL || p->outframe[i].size < size) - csound->AuxAlloc(csound, size, &p->outframe[i]); - else - memset(p->outframe[i].auxp,0,size); - } - size = N*sizeof(MYFLT); - if (p->win.auxp == NULL || p->win.size < size) - csound->AuxAlloc(csound, size, &p->win); - - { - MYFLT x = FL(2.0)*PI_F/N; - for (ui=0; ui < N; ui++) - ((MYFLT *)p->win.auxp)[ui] = FL(0.5) - FL(0.5)*COS((MYFLT)ui*x); - } - - p->N = N; - p->decim = decim; - return OK; -} - -int32_t mp3dec_cleanup(CSOUND *csound, LOADER *p) -{ - while(p->p.lock) - usleep(1000); - if (p->p.mpa != NULL) - mp3dec_uninit(p->p.mpa); - p->p.mpa = NULL; - return OK; -} - -void decode_seek(CSOUND *csound, mp3dec_t mpa, int32_t skip){ - unsigned char buffer[1152*4]; - mp3dec_seek(mpa, 0, MP3DEC_SEEK_SAMPLES); - while (skip > 0) { - mp3dec_decode(mpa,buffer, 1152*4,NULL); - skip -= 1152; - } -} - - -static int32_t filinit(CSOUND *csound, LOADER *pp) -{ - MP3SCAL2 *p = &(pp->p); - uint32_t size; - char *name; - // open file - int32_t fd; - int32_t r; - mp3dec_t mpa = NULL; - mpadec_config_t config = { MPADEC_CONFIG_FULL_QUALITY, MPADEC_CONFIG_STEREO, - MPADEC_CONFIG_16BIT, MPADEC_CONFIG_LITTLE_ENDIAN, - MPADEC_CONFIG_REPLAYGAIN_NONE, TRUE, TRUE, TRUE, - 0.0 }; - mpadec_info_t mpainfo; - int32_t buffsize = 32768; - - p->init = 0; - if(*pp->bfs) buffsize = *pp->bfs*8; - - name = pp->name->data; - if(p->mpa != NULL) mp3dec_uninit(p->mpa); - p->mpa = mpa = mp3dec_init(); - if (UNLIKELY(!mpa)) { - p->error = MPADEC_RETCODE_NOT_ENOUGH_MEMORY; - return NOTOK; - } - if (UNLIKELY((r = mp3dec_configure(mpa, &config)) != MP3DEC_RETCODE_OK)) { - mp3dec_uninit(mpa); - p->mpa = NULL; - p->error = r; - return NOTOK; - } - if (UNLIKELY(csound->FileOpen2(csound, &fd, CSFILE_FD_R, - name, "rb", "SFDIR;SSDIR", - CSFTYPE_OTHER_BINARY, 0) == NULL)) { - mp3dec_uninit(mpa); - p->error = -1; - return NOTOK; - } - if (UNLIKELY((r = mp3dec_init_file(mpa, fd, 0, TRUE)) != MP3DEC_RETCODE_OK)) { - mp3dec_uninit(mpa); - p->error = r; - return NOTOK; - } - - if (UNLIKELY((r = mp3dec_get_info(mpa, &mpainfo, MPADEC_INFO_STREAM)) != - MP3DEC_RETCODE_OK)) { - mp3dec_uninit(mpa); - return NOTOK; - } - - p->ilen = (MYFLT) mpainfo.duration; - if(mpainfo.frequency != CS_ESR) - p->resamp = mpainfo.frequency/CS_ESR; - else - p->resamp = 1; - meminit(csound, pp); - size = buffsize*sizeof(MYFLT); - if (p->fdata[0].auxp == NULL || p->fdata[0].size < size) - csound->AuxAlloc(csound, size, &p->fdata[0]); - p->indataL[0] = p->fdata[0].auxp; - p->indataL[1] = p->fdata[0].auxp + size/8; - p->indataL[2] = p->fdata[0].auxp + size/4; - p->indataL[3] = p->fdata[0].auxp + 3*size/8; - p->indataL[4] = p->fdata[0].auxp + size/2; - p->indataL[5] = p->fdata[0].auxp + 5*size/8; - p->indataL[6] = p->fdata[0].auxp + 3*size/4; - p->indataL[7] = p->fdata[0].auxp + 7*size/8; - memset(p->indataL[7], 0, size/8); - if (p->fdata[1].auxp == NULL || p->fdata[1].size < size) - csound->AuxAlloc(csound, size, &p->fdata[1]); - p->indataR[0] = p->fdata[1].auxp; - p->indataR[1] = p->fdata[1].auxp + size/8; - p->indataR[2] = p->fdata[1].auxp + size/4; - p->indataR[3] = p->fdata[1].auxp + 3*size/8; - p->indataR[4] = p->fdata[1].auxp + size/2; - p->indataR[5] = p->fdata[1].auxp + 5*size/8; - p->indataR[6] = p->fdata[1].auxp + 3*size/4; - p->indataR[7] = p->fdata[1].auxp + 7*size/8; - memset(p->indataR[7], 0, size/8); - size = buffsize*sizeof(short)/4; - if (p->buffer.auxp == NULL || p->buffer.size < size) - csound->AuxAlloc(csound, size, &p->buffer); - /*double dtime; - struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - dtime = ts.tv_sec + 1e-9*ts.tv_nsec; - */ - - int32_t skip = (int32_t)(*pp->skip*mpainfo.frequency); - p->bufused = -1; - /* mp3_seek operates on multiples of 1152 frames */ - int32_t frmsiz = mpainfo.decoded_frame_samples; - if(skip > 0) { - int32_t ftbr = skip/frmsiz; - int32_t skips = ftbr*frmsiz; - MYFLT fsize = (FL(125.0)*mpainfo.bitrate*frmsiz)/mpainfo.frequency; - if(fsize - (int32_t) fsize > FL(0.0)){ - char dat[4]; - int32_t byts, pad, i; - mp3dec_seek(mpa, 0, MP3DEC_SEEK_SAMPLES); - for(i=0; i < ftbr; i++){ - byts = read(fd,dat,4); - pad = dat[2] & 0x02 ? 1 : 0; - lseek(fd,(int32_t)fsize + pad - 4, SEEK_CUR); - //printf("skip %d pad %d\n", i, pad); - } - } else - mp3dec_seek(mpa, skips, MP3DEC_SEEK_SAMPLES); - skip = skip - skips; - } else mp3dec_seek(mpa, 0, MP3DEC_SEEK_SAMPLES); - - /*clock_gettime(CLOCK_MONOTONIC, &ts); - dtime = ts.tv_sec + 1e-9*ts.tv_nsec - dtime; - csound->Message(csound, "skip time %f\n", dtime);*/ - - // fill buffers - p->orsr = mpainfo.frequency; - p->curbuf = 0; - p->finished = 0; - p->nsmps = buffsize/8; - buffiller((void *)p); - buffiller((void *)p); - buffiller((void *)p); - buffiller((void *)p); - buffiller((void *)p); - buffiller((void *)p); - buffiller((void *)p); - buffiller((void *)p); - - p->pos = skip*CS_ESR/p->orsr; - p->tscale = 0; - p->accum = 0; - p->tab[0] = (MYFLT *) p->fdata[0].auxp; - p->tab[1] = (MYFLT *) p->fdata[1].auxp; - p->tstamp = 0; - p->finished = 0; - p->skip = *pp->skip; - p->filling = 0; - p->init = 1; - - return OK; -} - -void *loader_thread(void *p){ - LOADER *pp = (LOADER *) p; - if(filinit(pp->p.csound,pp) != OK) { - if(pp->p.error > 0) - pp->p.csound->Message(pp->p.csound, "%s", Str("mp3scal_load error: %s\n"), - mp3dec_error(pp->p.error)); - else - pp->p.csound->Message(pp->p.csound, - "%s", Str("mp3scal_load error: could not open %s\n"), - pp->name->data); - } - return NULL; -} - -static int32_t loader_init(CSOUND *csound, LOADER *pp){ - MP3SCAL2 *p = &(pp->p); - p->csound = csound; - p->init = 0; - p->ti = 0; - if(p->playing == 0){ - if(pthread_create(&(pp->p.t), NULL, loader_thread, pp) != 0) - csound->Message(csound, "%s", Str("failed to start thread\n")); - struct sched_param param; - int32_t policy; - pthread_getschedparam((pp->p.t), &policy, - ¶m); - param.sched_priority = 0; - policy = SCHED_OTHER; - if(pthread_setschedparam((pp->p.t), policy, - ¶m) != 0) - csound->Message(csound, "%s", Str("could not set priority\n")); - } - else return csound->InitError(csound, - "%s", Str("cannot load: player still active\n")); - pp->res->data = (char *) p; - pp->res->size = sizeof(MP3SCAL2); - // if(p->initDone == 0) - //csound->RegisterDeinitCallback(csound, pp, - // (int32_t (*)(CSOUND*, void*)) mp3dec_cleanup); - //p->initDone = 1; - return OK; -} - -typedef struct _check { - OPDS h; - MYFLT *res; - STRINGDAT *pp; - MP3SCAL2 *p; -} CHECK; - - -static int32_t check_init(CSOUND *csound, CHECK *p){ - if(p->pp->data != NULL && - p->pp->size != sizeof(MP3SCAL2)) { - p->p = (MP3SCAL2 *) p->pp->data; - } - else return csound->InitError(csound, "%s", Str("invalid handle\n")); - return OK; -} - -static int32_t check_play(CSOUND *csound, CHECK *p){ - *p->res = p->p->init; - return OK; -} - -#ifdef HAVE_NEON -#include -#endif - -typedef struct _player { - OPDS h; - MYFLT *out1, *out2, *kstamp, *ilen; - STRINGDAT *pp; - MYFLT *time, *kpitch, *kamp, *klock, *kinterp, *async; - MP3SCAL2 *p; - char start_flag; -#ifdef HAVE_NEON - PFFFT_Setup *setup; - float *bw,*fw; -#else - void *fwdsetup, *invsetup; -#endif -} PLAYER; - -int32_t mp3dec_cleanup_player(CSOUND *csound, PLAYER *p) -{ - while(p->p->lock) - usleep(1000); - pthread_join(p->p->t1, NULL); - if (p->p->mpa != NULL) - mp3dec_uninit(p->p->mpa); - p->p->mpa = NULL; -#ifdef HAVE_NEON - pffft_destroy_setup(p->setup); - pffft_aligned_free(p->bw); - pffft_aligned_free(p->fw); -#endif - return OK; -} - -static int32_t player_init(CSOUND *csound, PLAYER *p){ - if(p->pp->data != NULL && - p->pp->size != sizeof(MP3SCAL2)) { - p->p = (MP3SCAL2 *) p->pp->data; - } - else return csound->InitError(csound, "%s", Str("invalid handle\n")); - *p->ilen = p->p->ilen; - p->p->async = *p->async; - if(p->p->initDone == 0) - csound->RegisterDeinitCallback(csound, p, - (int32_t (*)(CSOUND*,void*))mp3dec_cleanup_player); - p->p->initDone = 1; - - int32_t policy; - struct sched_param param; - pthread_getschedparam(pthread_self(), &policy, - ¶m); - /*if(policy == SCHED_OTHER) - csound->Message(csound, "POLICY: SCHED_OTHER"); - struct sched_param param; - pthread_getschedparam(pthread_self(), &policy, - ¶m); - if(policy == SCHED_OTHER) - csound->Message(csound, "POLICY: SCHED_OTHER"); - else if(policy == SCHED_FIFO) - csound->Message(csound, "POLICY: SCHED_FIFO, %d", param.sched_priority);*/ - -#ifdef HAVE_NEON - while(!p->p->N) usleep(1000); - p->setup = pffft_new_setup(p->p->N,PFFFT_REAL); - p->bw = pffft_aligned_malloc(p->p->N*sizeof(float)); - p->fw = pffft_aligned_malloc(p->p->N*sizeof(float)); -#else - while(!p->p->N) usleep(1000); - p->fwdsetup = csound->RealFFT2Setup(csound,p->p->N,FFT_FWD); - p->invsetup = csound->RealFFT2Setup(csound,p->p->N,FFT_INV); -#endif - p->start_flag = 1; - return OK; -} - - - - -#include -#ifdef HAVE_NEON -#include -static -inline -void -cmplx_multiply_scal(MYFLT *ans_r, MYFLT *ans_i, - MYFLT *in1, MYFLT *in2, - MYFLT div, bool neg){ - float32x4_t op1, op2, ans; - float32x2_t tmp1, tmp2; - float32_t vans[4]; - tmp1 = vld1_f32(in1); - tmp2 = vld1_f32(in2); - op1 = vcombine_f32(tmp1,tmp1); - op2 = vcombine_f32(tmp2,vrev64_f32(tmp2)); - /* ac - bd + i(ad + bc) */ - ans = vmulq_n_f32(op2,div); - op2 = vmulq_f32(op1,ans); - vst1q_f32(vans, op2); - *ans_r = vans[0] - (neg ? -vans[1] : vans[1]); - *ans_i = vans[2] + (neg ? -vans[3] : vans[3]); -} -static -inline -MYFLT -invsqrt(MYFLT x) -{ - int64_t i; - float x2 = x*0.5f; - i = * (int64_t *) &x; - i = 0x5f3759df - (i >> 1); - x = *(float *) &i; - x = x*(1.5f - (x2*x*x)); - return x; -} - -static -inline -MYFLT -inv_mag_(MYFLT *a){ - float32x2_t ans, op; - float32_t vans[2]; - op = vld1_f32(a); - ans = vmul_f32(op,op); - vst1_f32(vans, ans); - return invsqrt(vans[0]+vans[1]); -} - -#else - -static -inline -void -cmplx_multiply_scal(MYFLT *ans_r, MYFLT *ans_i, - MYFLT* in1, MYFLT* in2, - MYFLT div, bool neg){ - - MYFLT r = in2[0] * div, i = in2[1] * div; - *ans_r = in1[0]*r - (neg ? -in1[1]*i : in1[1]*i); - *ans_i = in1[0]*i + (neg ? -in1[1]*r : in1[1]*r); -} - -#endif - -static -inline -MYFLT -inv_mag(MYFLT *a){ - return FL(1.0)/(hypot(a[0], a[1])+1.0e-15); - //return invsqrt(a[0]*a[0]+a[1]*a[1]); -} -static -inline -MYFLT -inv_mag2(MYFLT *a){ // FIXME: use HYPOT - a[0] += 1.0e-15; - return FL(1.0)/(hypot(a[0],a[1])); - //return invsqrt(a[0]*a[0]+a[1]*a[1]); -} - - - -#define FTOINT(x) ((int32_t)x) - -static int32_t player_play(CSOUND *csound, PLAYER *pp) -{ - MP3SCAL2 *p = pp->p; - uint32_t offset = pp->h.insdshead->ksmps_offset; - uint32_t early = pp->h.insdshead->ksmps_no_end; - int32_t decim = p->decim; - MYFLT pitch = *pp->kpitch*p->resamp, time = *pp->time*p->resamp, - lock = *pp->klock; - double amp = *pp->kamp*csound->Get0dBFS(csound)*(8./decim)/3.; - int32_t interp = *pp->kinterp; -#ifdef __clang__ - MYFLT *restrict out; - MYFLT *restrict fwin; - MYFLT *restrict bwin; - MYFLT *restrict prev; - MYFLT *restrict win = (MYFLT *) p->win.auxp, *restrict outframe; - int32_t *restrict framecnt, curframe = p->curframe; - MYFLT *restrict tab, **table,frac; - MYFLT *restrict phs; -#else - MYFLT *out; - MYFLT *fwin; - MYFLT *bwin; - MYFLT *prev; - MYFLT *win = (MYFLT *) p->win.auxp, *outframe; - int32_t *framecnt, curframe = p->curframe; - MYFLT *tab, **table,frac; - MYFLT *phs; -#endif - int32_t N = p->N, hsize = p->hsize, cnt = p->cnt; - int32_t nsmps = csound->GetKsmps(csound), n; - int32_t size = p->fdata[0].size/sizeof(MYFLT), post, i, j; - double pos, spos = p->pos; - MYFLT in; - MYFLT div; - double tstamp = p->tstamp, incrt = p->incr; - AUXCH *mfwin = p->fwin, - *mbwin = p->bwin, - *mprev = p->prev, - *moutframe = p->outframe, - *mframecount = p->framecount; - MYFLT hsizepitch = hsize*pitch; - int32_t nbytes = p->N*sizeof(MYFLT); - int32_t start_flag = pp->start_flag; -#ifdef HAVE_NEON - float *restrict bw = pp->bw, *restrict fw = pp->fw; -#endif - p->playing = 1; - - if(time < 0) time = 0.0; - table = p->tab; - - if(!p->init){ - for (j=0; j < MP3_CHNS; j++) { - out = j == 0 ? pp->out1 : pp->out2; - memset(out, '\0', nsmps*sizeof(MYFLT)); - } - csound->Message(csound, "%s", Str("not init\n")); - p->ti++; - *pp->kstamp = 0; - return OK; - } else *pp->ilen = p->ilen; - - if (UNLIKELY(early)) { - nsmps -= early; - for (j=0; j < MP3_CHNS; j++) { - out = j == 0 ? pp->out1 : pp->out2; - memset(&out[nsmps], '\0', early*sizeof(MYFLT)); - } - } - if (UNLIKELY(offset)) { - for (j=0; j < MP3_CHNS; j++) { - out = j == 0 ? pp->out1 : pp->out2; - memset(out, '\0', offset*sizeof(MYFLT)); - } - } - - for (n=offset; n < nsmps; n++) { - - if (cnt == hsize){ - while(spos >= size) { - spos -= size; - } - while(spos < 0){ - spos += size; - } - - if (spos > size/8+hsize && p->curbuf == 0 && p->filling == 0) { - fillbuf2(csound,p,size/8); - p->filling = 1; - } else if (spos > size/4+hsize && p->curbuf == 1 && p->filling == 1){ - fillbuf2(csound,p,size/8); - p->filling = 2; - } - else if (spos > 3*size/8+hsize && p->curbuf == 2 && p->filling == 2){ - fillbuf2(csound,p,size/8); - p->filling = 3; - } - else if (spos > size/2+hsize && p->curbuf == 3 && p->filling == 3){ - fillbuf2(csound,p,size/8); - p->filling = 4; - } - else if (spos > 5*size/8+hsize && p->curbuf == 4 && p->filling == 4){ - fillbuf2(csound,p,size/8); - p->filling = 5; - } - else if (spos > 3*size/4+hsize && p->curbuf == 5 && p->filling == 5){ - fillbuf2(csound,p,size/8); - p->filling = 6; - } - else if (spos > 7*size/8+hsize && p->curbuf == 6 && p->filling == 6){ - fillbuf2(csound,p,size/8); - p->filling = 7; - } - else if (spos < size/8+hsize && p->curbuf == 7 && p->filling == 7){ - fillbuf2(csound,p,size/8); - p->filling = 0; - } - - - for (j = 0; j < MP3_CHNS; j++) { - bwin = (MYFLT *) mbwin[j].auxp; - fwin = (MYFLT *) mfwin[j].auxp; - prev = (MYFLT *) mprev[j].auxp; - framecnt = (int32_t *) mframecount[j].auxp; - outframe= (MYFLT *) moutframe[j].auxp; - tab = table[j]; - if(pitch != 1) { - pos = spos; - -#ifndef HAVE_NEON - for (i=0; i < N; i++) { - post = (int32_t) pos; - frac = pos - post; - if(post < 0) post += size; - if(post >= size) post -= size; - if(post+1 < size && interp){ - in = tab[post] + frac*(tab[post+1] - tab[post]); - } - else - in = tab[post]; -#ifdef HAVE_NEON - fw[i] = in * win[i]; -#else - fwin[i] = in * win[i]; -#endif - - post -= hsizepitch; - if(post < 0) post += size; - if(post >= size) post -= size; - if(post+1 < size && interp){ - in = tab[post] + frac*(tab[post+1] - tab[post]); - } - else - in = tab[post]; -#ifdef HAVE_NEON - bw[i] = in * win[i]; -#else - bwin[i] = in * win[i]; -#endif - pos += pitch; - } -#else - float32x4_t bsm1,bsm2,ans; - float tmpf[5],fracv[4]; - float tmpos; - int32_t tmposi; - for (i=0; i < N; i+=4) { - tmpos = pos; - if(tmpos < 0) tmpos += size; - if(tmpos >= size) tmpos -= size; - tmposi = FTOINT(tmpos); - tmpf[0] = tab[tmposi]; - fracv[0] = tmpos - tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - if(tmposi < size){ - tmpf[1] = tab[tmposi]; - fracv[1] = tmpos -tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - if(tmposi < size){ - tmpf[2] = tab[tmposi]; - fracv[2] = tmpos - tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - if(tmposi < size){ - tmpf[3] = tab[tmposi]; - fracv[3] = tmpos - tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - if(tmposi < size) - tmpf[4] = tab[tmposi]; - else { - tmpos -= size; - tmposi = FTOINT(tmpos); - tmpf[4] = tab[tmposi]; - } - } - else { - tmpos -= size; - tmposi = FTOINT(tmpos); - tmpf[3] = tab[tmposi]; - fracv[3] = tmpos -tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - tmpf[4] = tab[tmposi]; - } - } - else { - tmpos -= size; - tmposi = FTOINT(tmpos); - tmpf[2] = tab[tmposi]; - fracv[2] = tmpos - tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - tmpf[3] = tab[tmposi]; - fracv[3] = tmpos - tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - tmpf[4] = tab[tmposi]; - } - } - else { - tmpos -= size; - tmposi = FTOINT(tmpos); - tmpf[1] = tab[tmposi]; - fracv[1] = tmpos -tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - tmpf[2] = tab[tmposi]; - fracv[2] = tmpos - tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - tmpf[3] = tab[tmposi]; - fracv[3] = tmpos - tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - tmpf[4] = tab[tmposi]; - } - - bsm1 = vld1q_f32(&tmpf[0]); - bsm2 = vld1q_f32(&tmpf[1]); - ans = vsubq_f32(bsm2,bsm1); - bsm2 = vld1q_f32(fracv); - bsm2 = vmulq_f32(ans,bsm2); - ans = vaddq_f32(bsm1,bsm2); - bsm1 = vld1q_f32(&win[i]); - bsm2 = vmulq_f32(ans,bsm1); - vst1q_f32(&fw[i],bsm2); - - tmpos = pos - hsize*pitch; - if(tmpos < 0) tmpos += size; - if(tmpos >= size) tmpos -= size; - if(tmpos < 0) tmpos += size; - if(tmpos >= size) tmpos -= size; - tmposi = FTOINT(tmpos); - tmpf[0] = tab[tmposi]; - fracv[0] = tmpos - tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - if(tmposi < size){ - tmpf[1] = tab[tmposi]; - fracv[1] = tmpos -tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - if(tmposi < size){ - tmpf[2] = tab[tmposi]; - fracv[2] = tmpos - tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - if(tmposi < size){ - tmpf[3] = tab[tmposi]; - fracv[3] = tmpos - tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - if(tmposi < size) - tmpf[4] = tab[tmposi]; - else { - tmpos -= size; - tmposi = FTOINT(tmpos); - tmpf[4] = tab[tmposi]; - } - } - else { - tmpos -= size; - tmposi = FTOINT(tmpos); - tmpf[3] = tab[tmposi]; - fracv[3] = tmpos -tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - tmpf[4] = tab[tmposi]; - } - } - else { - tmpos -= size; - tmposi = FTOINT(tmpos); - tmpf[2] = tab[tmposi]; - fracv[2] = tmpos - tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - tmpf[3] = tab[tmposi]; - fracv[3] = tmpos - tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - tmpf[4] = tab[tmposi]; - } - } - else { - tmpos -= size; - tmposi = FTOINT(tmpos); - tmpf[1] = tab[tmposi]; - fracv[1] = tmpos -tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - tmpf[2] = tab[tmposi]; - fracv[2] = tmpos - tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - tmpf[3] = tab[tmposi]; - fracv[3] = tmpos - tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - tmpf[4] = tab[tmposi]; - } - - bsm1 = vld1q_f32(&tmpf[0]); - bsm2 = vld1q_f32(&tmpf[1]); - ans = vsubq_f32(bsm2,bsm1); - bsm2 = vld1q_f32(fracv); - bsm2 = vmulq_f32(ans,bsm2); - ans = vaddq_f32(bsm1,bsm2); - bsm1 = vld1q_f32(&win[i]); - bsm2 = vmulq_f32(ans,bsm1); - vst1q_f32(&bw[i],bsm2); - pos += pitch*4; - } -#endif - } - else { - post = (int32_t) spos; - int32_t end = post+N; - if(end <= size) - memcpy(fwin,&tab[post],nbytes); - else { - int32_t endbytes; - endbytes = (end - size)*sizeof(MYFLT); - end = N - (end - size); - memcpy(fwin,&tab[post],nbytes-endbytes); - memcpy(&fwin[end],tab,endbytes); - } - post -= hsize; - if(post < 0) post += size; - end = post+N; - if(end < size) - memcpy(bwin,&tab[post],nbytes); - else { - int32_t endbytes; - endbytes = (end - size)*sizeof(MYFLT); - end = N - (end - size); - memcpy(bwin,&tab[post],nbytes-endbytes); - memcpy(&bwin[end],tab,endbytes); - } - -#ifdef HAVE_NEON - for(i=0; i < N; i++) { - bw[i] = bwin[i]*win[i]; - fw[i] = fwin[i]*win[i]; - } -#else - for(i=0; i < N; i++) { - bwin[i] *= win[i]; - fwin[i] *= win[i]; - } -#endif - } - -#ifdef HAVE_NEON - pffft_transform_ordered(pp->setup,bw,bw,NULL,PFFFT_FORWARD); - pffft_transform_ordered(pp->setup,fw,fw,NULL,PFFFT_FORWARD); - memcpy(bwin,bw,N*sizeof(float)); - memcpy(fwin,fw,N*sizeof(float)); - bwin[N] = bw[1]; - fwin[N] = fw[1]; -#else - csound->RealFFT2(csound, pp->fwdsetup, bwin); - csound->RealFFT2(csound, pp->fwdsetup, fwin); -#endif - bwin[N] = bwin[1]; - bwin[N+1] = FL(0.0); - fwin[N] = fwin[1]; - fwin[N+1] = FL(0.0); - - if(start_flag){ - memcpy(prev, bwin, sizeof(MYFLT)*(N+2)); - pp->start_flag = 0; - } - - for (i=0; i < N; i+=2) { - div = inv_mag(&prev[i]); - cmplx_multiply_scal(&prev[i],&prev[i+1], - &bwin[i],&prev[i], - div, true); - } - - if (lock) { - phs = prev; - for(i = 2; i < N; i++) - bwin[i] = phs[i]; - for(i = 2; i < N; i++) - bwin[i] += phs[i-2]; - for(i = 2; i < N; i++) - bwin[i] += phs[i+2]; - bwin[0] = prev[i] + prev[i-2]; - bwin[N] = prev[i] + prev[i+2]; - } - else memcpy(bwin,prev,sizeof(MYFLT)*(N+2)); - - for (i=0; i < N; i+=2) { - div = inv_mag2(&bwin[i]); - cmplx_multiply_scal(&prev[i],&prev[i+1], - &fwin[i], &bwin[i], - div, false); - } -#ifdef HAVE_NEON - for(i=0;isetup,fw,fw,NULL,PFFFT_BACKWARD); -#else - - - for(i=0; i < N+2; i++) - fwin[i] = prev[i]; - fwin[1] = fwin[N]; - csound->RealFFT2(csound, pp->invsetup, fwin); -#endif - framecnt[curframe] = curframe*N; - for (i=0;iout1 : pp->out2; - framecnt = (int32_t *) p->framecount[j].auxp; - outframe = (MYFLT *) p->outframe[j].auxp; - out[n] = (MYFLT) 0; - - for (i = 0; i < decim; i++) { - out[n] += outframe[framecnt[i]]; - framecnt[i]++; - } - out[n] *= amp; - } - cnt++; - } - p->cnt = cnt; - p->curframe = curframe; - p->pos = spos; - *pp->kstamp = (p->skip + p->tstamp/p->orsr); - p->tstamp = tstamp + incrt; - p->incr = incrt; - p->playing = 0; - return OK; - -} -#endif - -#ifdef ONE_FINE_DAY -static int32_t meminit2(CSOUND *csound, LOADER *pp) -{ - - MP3SCAL2 *p = &(pp->p); - int32_t N = *pp->iN, ui; - uint32_t i; - uint32_t size; - int32_t decim = *pp->idecim; - p->N = N; - p->error = 0; - if (N) { - for (i=0; N; i++) { - N >>= 1; - } - N = (int32_t) pow(2.0, i-1); - } else N = 2048; - if (decim == 0) decim = 4; - - p->hsize = N/decim; - p->cnt = p->hsize; - p->curframe = 0; - p->pos = 0; - - for (i=0; i < MP3_CHNS; i++){ - - size = (N+2)*sizeof(MYFLT); - if (p->fwin[i].auxp == NULL || p->fwin[i].size < size) - csound->AuxAlloc(csound, size, &p->fwin[i]); - if (p->bwin[i].auxp == NULL || p->bwin[i].size < size) - csound->AuxAlloc(csound, size, &p->bwin[i]); - if (p->prev[i].auxp == NULL || p->prev[i].size < size) - csound->AuxAlloc(csound, size, &p->prev[i]); - - size = decim*sizeof(int32_t); - if (p->framecount[i].auxp == NULL || p->framecount[i].size < size) - csound->AuxAlloc(csound, size, &p->framecount[i]); - { - int32_t k=0; - for (k=0; k < decim; k++) { - ((int32_t *)(p->framecount[i].auxp))[k] = k*N; - } - } - size = decim*sizeof(MYFLT)*N; - if (p->outframe[i].auxp == NULL || p->outframe[i].size < size) - csound->AuxAlloc(csound, size, &p->outframe[i]); - else - memset(p->outframe[i].auxp,0,size); - } - size = N*sizeof(MYFLT); - if (p->win.auxp == NULL || p->win.size < size) - csound->AuxAlloc(csound, size, &p->win); - - { - MYFLT x = FL(2.0)*PI_F/N; - for (ui=0; ui < N; ui++) - ((MYFLT *)p->win.auxp)[ui] = FL(0.5) - FL(0.5)*COS((MYFLT)ui*x); - } - - p->N = N; - p->decim = decim; - return OK; -} - -static int32_t filinit2(CSOUND *csound, LOADER *pp) -{ - MP3SCAL2 *p = &(pp->p); - uint32_t size; - char *name; - // open file - int32_t fd; - int32_t r; - mp3dec_t mpa = NULL; - mpadec_config_t config = { MPADEC_CONFIG_FULL_QUALITY, MPADEC_CONFIG_STEREO, - MPADEC_CONFIG_16BIT, MPADEC_CONFIG_LITTLE_ENDIAN, - MPADEC_CONFIG_REPLAYGAIN_NONE, TRUE, TRUE, TRUE, - 0.0 }; - mpadec_info_t mpainfo; - int32_t buffsize = 32768; - if(*pp->bfs) buffsize = *pp->bfs*8; - - name = pp->name->data; - if(p->mpa != NULL) mp3dec_uninit(p->mpa); - p->mpa = mpa = mp3dec_init(); - if (UNLIKELY(!mpa)) { - p->error = MPADEC_RETCODE_NOT_ENOUGH_MEMORY; - return NOTOK; - } - if (UNLIKELY((r = mp3dec_configure(mpa, &config)) != MP3DEC_RETCODE_OK)) { - mp3dec_uninit(mpa); - p->mpa = NULL; - p->error = r; - return NOTOK; - } - if (UNLIKELY(csound->FileOpen2(csound, &fd, CSFILE_FD_R, - name, "rb", "SFDIR;SSDIR", - CSFTYPE_OTHER_BINARY, 0) == NULL)) { - mp3dec_uninit(mpa); - p->error = -1; - return NOTOK; - } - if (UNLIKELY((r = mp3dec_init_file(mpa, fd, 0, FALSE)) != MP3DEC_RETCODE_OK)) { - mp3dec_uninit(mpa); - p->error = r; - return NOTOK; - } - - if (UNLIKELY((r = mp3dec_get_info(mpa, &mpainfo, MPADEC_INFO_STREAM)) != - MP3DEC_RETCODE_OK)) { - mp3dec_uninit(mpa); - return NOTOK; - } - - p->ilen = (MYFLT) mpainfo.duration; - if(mpainfo.frequency != CS_ESR) - p->resamp = mpainfo.frequency/CS_ESR; - else - p->resamp = 1; - meminit2(csound, pp); - - int32_t extrasmps = p->N+p->hsize+528; - size = (mpainfo.duration*mpainfo.frequency + extrasmps)*sizeof(MYFLT); - if (p->fdata[0].auxp == NULL || p->fdata[0].size < size) - csound->AuxAlloc(csound, size, &p->fdata[0]); - if (p->fdata[1].auxp == NULL || p->fdata[1].size < size) - csound->AuxAlloc(csound, size, &p->fdata[1]); - - int32_t frmsiz = mpainfo.decoded_frame_samples; - int32_t skip = (int32_t)(*pp->skip*mpainfo.frequency); - p->bufused = -1; - p->orsr = mpainfo.frequency; - p->curbuf = 0; - p->nsmps = buffsize/8; - p->pos = p->hsize + skip - 528; - p->tscale = 0; - p->accum = 0; - p->tab[0] = (MYFLT *) p->fdata[0].auxp; - p->tab[1] = (MYFLT *) p->fdata[1].auxp; - p->tstamp = 0; - p->finished = 0; - p->init = 0; - p->skip = *pp->skip; - p->filling = 7; - - // fill buffers - mp3dec_seek(mpa,0, MP3DEC_SEEK_SAMPLES); - int32_t end = mpainfo.duration*mpainfo.frequency; - short decbuffer[frmsiz*sizeof(short)*MP3_CHNS]; - p->end = end; - MYFLT *left = (MYFLT *) p->fdata[0].auxp; - MYFLT *right = (MYFLT *) p->fdata[1].auxp; - left += p->hsize; - right += p->hsize; - int32_t i,j,k; - uint32_t bufused = 0; - for(i=0;i p->pos) { - p->init = 1; - } - } - return OK; -} - -void *loader_thread2(void *p){ - LOADER *pp = (LOADER *) p; - if(filinit2(pp->p.csound,pp) != OK) { - if(pp->p.error > 0) - pp->p.csound->Message(pp->p.csound, "%s", Str("mp3scal_load error: %s\n"), - mp3dec_error(pp->p.error)); - else - pp->p.csound->Message(pp->p.csound, - "%s", Str("mp3scal_load error: could not open %s\n"), - pp->name->data); - } - return NULL; -} - - -static int32_t loader_init2(CSOUND *csound, LOADER *pp){ - MP3SCAL2 *p = &(pp->p); - p->csound = csound; - p->init = 0; - p->ti = 0; - if(p->playing == 0){ - pthread_create(&(pp->p.t), NULL, loader_thread2, pp); - struct sched_param param; - int32_t policy; - pthread_getschedparam((pp->p.t), &policy, - ¶m); - param.sched_priority = 0; - policy = SCHED_OTHER; - if(pthread_setschedparam((pp->p.t), policy, - ¶m) != 0) - csound->Message(csound, "could not set priority\n"); - } - else return csound->InitError(csound, - "%s", Str("cannot load: player still active\n")); - pp->res->data = (char *) p; - pp->res->size = sizeof(MP3SCAL2); - return OK; -} - -static int32_t player_init2(CSOUND *csound, PLAYER *p){ - if(p->pp->data != NULL && - p->pp->size != sizeof(MP3SCAL2)) { - p->p = (MP3SCAL2 *) p->pp->data; - } - else return csound->InitError(csound, "invalid handle\n"); - *p->ilen = p->p->ilen; - p->p->async = *p->async; - if(p->p->initDone == 0) - csound->RegisterDeinitCallback(csound, p, - (int32_t (*)(CSOUND*, void*)) mp3dec_cleanup_player); - p->p->initDone = 1; - -#ifdef HAVE_NEON - while(!p->p->N) usleep(1000); - p->setup = pffft_new_setup(p->p->N,PFFFT_REAL); - p->bw = pffft_aligned_malloc(p->p->N*sizeof(float)); - p->fw = pffft_aligned_malloc(p->p->N*sizeof(float)); -#else - while(!p->p->N) usleep(1000); - p->fwdsetup = csound->RealFFT2Setup(csound,p->p->N,FFT_FWD); - p->invsetup = csound->RealFFT2Setup(csound,p->p->N,FFT_INV); -#endif - p->start_flag = 1; - return OK; -} - - - -static int32_t player_play2(CSOUND *csound, PLAYER *pp) -{ - MP3SCAL2 *p = pp->p; - uint32_t offset = pp->h.insdshead->ksmps_offset; - uint32_t early = pp->h.insdshead->ksmps_no_end; - int32_t decim = p->decim; - MYFLT pitch = *pp->kpitch*p->resamp, time = *pp->time*p->resamp, - lock = *pp->klock; - double amp = *pp->kamp*csound->Get0dBFS(csound)*(8.0/decim)/3.0; - int32_t interp = *pp->kinterp; -#ifdef __clang__ - MYFLT *restrict out; - MYFLT *restrict fwin; - MYFLT *restrict bwin; - MYFLT *restrict prev; - MYFLT *restrict win = (MYFLT *) p->win.auxp, *restrict outframe; - int32_t *restrict framecnt, curframe = p->curframe; - MYFLT *restrict tab; - MYFLT frac; - MYFLT *restrict phs; -#else - MYFLT *out; - MYFLT *fwin; - MYFLT *bwin; - MYFLT *prev; - MYFLT *win = (MYFLT *) p->win.auxp, *outframe; - int32_t *framecnt, curframe = p->curframe; - MYFLT *tab; - MYFLT frac; - MYFLT *phs; -#endif - int32_t N = p->N, hsize = p->hsize, cnt = p->cnt; - int32_t nsmps = csound->GetKsmps(csound), n; - int32_t post, i, j; - double pos, spos = p->pos; - MYFLT in; - MYFLT div; - double tstamp = p->tstamp, incrt = p->incr; - AUXCH *mfwin = p->fwin, - *mbwin = p->bwin, - *mprev = p->prev, - *moutframe = p->outframe, - *mframecount = p->framecount; - MYFLT hsizepitch = hsize*pitch; - int32_t nbytes = p->N*sizeof(MYFLT); - int32_t start_flag = pp->start_flag; -#ifdef HAVE_NEON - float *restrict bw = pp->bw, *restrict fw = pp->fw; -#endif - if(spos >= p->end) { - for (j=0; j < MP3_CHNS; j++) { - out = j == 0 ? pp->out1 : pp->out2; - memset(out, '\0', nsmps*sizeof(MYFLT)); - } - return OK; - } - p->playing = 1; - - if(time < 0) time = 0.0; - - - - if(!p->init){ - for (j=0; j < MP3_CHNS; j++) { - out = j == 0 ? pp->out1 : pp->out2; - memset(out, '\0', nsmps*sizeof(MYFLT)); - } - p->ti++; - *pp->kstamp = 0; - return OK; - } else *pp->ilen = p->ilen; - - if (UNLIKELY(early)) { - nsmps -= early; - for (j=0; j < MP3_CHNS; j++) { - out = j == 0 ? pp->out1 : pp->out2; - memset(&out[nsmps], '\0', early*sizeof(MYFLT)); - } - } - if (UNLIKELY(offset)) { - for (j=0; j < MP3_CHNS; j++) { - out = j == 0 ? pp->out1 : pp->out2; - memset(out, '\0', offset*sizeof(MYFLT)); - } - } - - for (n=offset; n < nsmps; n++) { - if(cnt == hsize){ - for (j = 0; j < MP3_CHNS; j++) { - bwin = (MYFLT *) mbwin[j].auxp; - fwin = (MYFLT *) mfwin[j].auxp; - prev = (MYFLT *) mprev[j].auxp; - framecnt = (int32_t *) mframecount[j].auxp; - outframe= (MYFLT *) moutframe[j].auxp; - tab = (MYFLT *) p->fdata[j].auxp; - if(pitch != 1) { - pos = spos; -#ifndef HAVE_NEON - for (i=0; i < N; i++) { - post = (int32_t) pos; - frac = pos - post; - if(interp){ - in = tab[post] + frac*(tab[post+1] - tab[post]); - } - else - in = tab[post]; -#ifdef HAVE_NEON - fw[i] = in * win[i]; -#else - fwin[i] = in * win[i]; -#endif - - post -= hsizepitch; - if(interp){ - in = tab[post] + frac*(tab[post+1] - tab[post]); - } - else - in = tab[post]; -#ifdef HAVE_NEON - bw[i] = in * win[i]; -#else - bwin[i] = in * win[i]; -#endif - pos += pitch; - } -#else - float32x4_t bsm1,bsm2,ans; - float tmpf[5],fracv[4]; - float tmpos; - int32_t tmposi; - for (i=0; i < N; i+=4) { - tmpos = pos; - tmposi = FTOINT(tmpos); - tmpf[0] = tab[tmposi]; - fracv[0] = tmpos - tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - tmpf[1] = tab[tmposi]; - fracv[1] = tmpos -tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - tmpf[2] = tab[tmposi]; - fracv[2] = tmpos - tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - tmpf[3] = tab[tmposi]; - fracv[3] = tmpos - tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - tmpf[4] = tab[tmposi]; - - bsm1 = vld1q_f32(&tmpf[0]); - bsm2 = vld1q_f32(&tmpf[1]); - ans = vsubq_f32(bsm2,bsm1); - bsm2 = vld1q_f32(fracv); - bsm2 = vmulq_f32(ans,bsm2); - ans = vaddq_f32(bsm1,bsm2); - bsm1 = vld1q_f32(&win[i]); - bsm2 = vmulq_f32(ans,bsm1); - vst1q_f32(&fw[i],bsm2); - - tmpos = pos - hsize*pitch; - tmposi = FTOINT(tmpos); - tmpf[0] = tab[tmposi]; - fracv[0] = tmpos - tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - tmpf[1] = tab[tmposi]; - fracv[1] = tmpos -tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - tmpf[2] = tab[tmposi]; - fracv[2] = tmpos - tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - tmpf[3] = tab[tmposi]; - fracv[3] = tmpos - tmposi; - tmpos += pitch; - tmposi = FTOINT(tmpos); - tmpf[4] = tab[tmposi]; - - bsm1 = vld1q_f32(&tmpf[0]); - bsm2 = vld1q_f32(&tmpf[1]); - ans = vsubq_f32(bsm2,bsm1); - bsm2 = vld1q_f32(fracv); - bsm2 = vmulq_f32(ans,bsm2); - ans = vaddq_f32(bsm1,bsm2); - bsm1 = vld1q_f32(&win[i]); - bsm2 = vmulq_f32(ans,bsm1); - vst1q_f32(&bw[i],bsm2); - pos += pitch*4; - } -#endif - } - else { - post = (int32_t) spos; - memcpy(fwin,&tab[post],nbytes); - post -= hsize; - memcpy(bwin,&tab[post],nbytes); -#ifdef HAVE_NEON - for(i=0; i < N; i++) { - bw[i] = bwin[i]*win[i]; - fw[i] = fwin[i]*win[i]; - } -#else - for(i=0; i < N; i++) { - bwin[i] *= win[i]; - fwin[i] *= win[i]; - } -#endif - } - - // if(time != FL(1.0) || pitch != FL(1.0)){ - -#ifdef HAVE_NEON - pffft_transform_ordered(pp->setup,bw,bw,NULL,PFFFT_FORWARD); - pffft_transform_ordered(pp->setup,fw,fw,NULL,PFFFT_FORWARD); - memcpy(bwin,bw,N*sizeof(float)); - memcpy(fwin,fw,N*sizeof(float)); - bwin[N] = bw[1]; - fwin[N] = fw[1]; -#else - csound->RealFFT2(csound, pp->fwdsetup, bwin); - csound->RealFFT2(csound, pp->fwdsetup, fwin); -#endif - bwin[N] = bwin[1]; - bwin[N+1] = FL(0.0); - fwin[N] = fwin[1]; - fwin[N+1] = FL(0.0); - - if(start_flag){ - memcpy(prev, bwin, sizeof(MYFLT)*(N+2)); - pp->start_flag = 0; - } - - for (i=0; i < N; i+=2) { - div = inv_mag(&prev[i]); - cmplx_multiply_scal(&prev[i],&prev[i+1], - &bwin[i],&prev[i], - div, true); - } - - if (lock) { - phs = prev; - for(i = 2; i < N; i++) - bwin[i] = phs[i]; - for(i = 2; i < N; i++) - bwin[i] += phs[i-2]; - for(i = 2; i < N; i++) - bwin[i] += phs[i+2]; - bwin[0] = prev[i] + prev[i-2]; - bwin[N] = prev[i] + prev[i+2]; - } - else memcpy(bwin,prev,sizeof(MYFLT)*(N+2)); - - for (i=0; i < N; i+=2) { - div = inv_mag(&bwin[i]); - cmplx_multiply_scal(&prev[i],&prev[i+1], - &fwin[i], &bwin[i], - div, false); - } -#ifdef HAVE_NEON - for(i=0;isetup,fw,fw,NULL,PFFFT_BACKWARD); -#else - -#endif - //} else pp->start_flag = 1; - - framecnt[curframe] = curframe*N; - for (i=0;iout1 : pp->out2; - framecnt = (int32_t *) p->framecount[j].auxp; - outframe = (MYFLT *) p->outframe[j].auxp; - out[n] = (MYFLT) 0; - - for (i = 0; i < decim; i++) { - out[n] += outframe[framecnt[i]]; - framecnt[i]++; - } - out[n] *= amp; - } - cnt++; - } - p->cnt = cnt; - p->curframe = curframe; - p->pos = spos; - *pp->kstamp = (p->skip + p->tstamp/p->orsr); - p->tstamp = tstamp + incrt; - p->incr = incrt; - p->playing = 0; - return OK; - -} - -#endif - - #define S(x) sizeof(x) static OENTRY mp3in_localops[] = { - {"mp3in", S(MP3IN), _QQ, 3, "mm", "Soooo", (SUBR) mp3ininit_S, (SUBR)mp3in}, - {"mp3in.i", S(MP3IN), _QQ, 3, "mm", "ioooo", (SUBR) mp3ininit, (SUBR)mp3in}, - {"mp3len", S(MP3LEN), _QQ, 1, "i", "S", (SUBR) mp3len_S, NULL, NULL}, - {"mp3len.i", S(MP3LEN), _QQ, 1, "i", "i", (SUBR) mp3len, NULL, NULL}, - {"mp3sr", S(MP3LEN), 0, 1, "i", "S", (SUBR) mp3len_S, NULL, NULL}, - {"mp3sr.i", S(MP3LEN), 0, 1, "i", "i", (SUBR) mp3len, NULL, NULL}, - {"mp3bitrate", S(MP3LEN), 0, 1, "i", "S", (SUBR) mp3len_S, NULL, NULL}, - {"mp3bitrate.i", S(MP3LEN), 0, 1, "i", "i", (SUBR) mp3len, NULL, NULL}, - {"mp3nchnls", S(MP3LEN), 0, 1, "i", "S", (SUBR) mp3len_S, NULL, NULL}, - {"mp3nchnls.i", S(MP3LEN), 0, 1, "i", "i", (SUBR) mp3len, NULL, NULL}, - {"mp3scal", sizeof(DATASPACE), 0, 3, "aak", "SkkkoooPP", - (SUBR)sinit3,(SUBR)sprocess3 }, -#ifdef ANDROID - {"mp3scal_load", sizeof(LOADER), 0, 1, "i", "Soooo", - (SUBR)loader_init, NULL,NULL }, - {"mp3scal_play", sizeof(PLAYER), 0, 3, "aaki", "ikkkPPo", - (SUBR)player_init,(SUBR)player_play}, - {"mp3scal_check", sizeof(CHECK), 0, 3, "k", "i", - (SUBR)check_init,(SUBR)check_play}, - #endif - /* - {"mp3scal_load2", sizeof(LOADER), 0, 1, "i", "Soooo", - (SUBR)loader_init2, NULL,NULL }, - {"mp3scal_play2", sizeof(PLAYER), 0, 3, "aaki", "ikkkPPo", - (SUBR)player_init2,(SUBR)player_play2} - */ + {"mp3in", S(MP3IN), _QQ, "mm", "Soooo", (SUBR) mp3ininit_S, (SUBR)mp3in, (SUBR) mp3in_cleanup}, + {"mp3in.i", S(MP3IN), _QQ, "mm", "ioooo", (SUBR) mp3ininit, (SUBR)mp3in, (SUBR) mp3in_cleanup}, + {"mp3len", S(MP3LEN), _QQ, "i", "S", (SUBR) mp3len_S, NULL, NULL}, + {"mp3len.i", S(MP3LEN), _QQ, "i", "i", (SUBR) mp3len, NULL, NULL}, + {"mp3sr", S(MP3LEN), 0, "i", "S", (SUBR) mp3len_S, NULL, NULL}, + {"mp3sr.i", S(MP3LEN), 0, "i", "i", (SUBR) mp3len, NULL, NULL}, + {"mp3bitrate", S(MP3LEN), 0, "i", "S", (SUBR) mp3len_S, NULL, NULL}, + {"mp3bitrate.i", S(MP3LEN), 0, "i", "i", (SUBR) mp3len, NULL, NULL}, + {"mp3nchnls", S(MP3LEN), 0, "i", "S", (SUBR) mp3len_S, NULL, NULL}, + {"mp3nchnls.i", S(MP3LEN), 0, "i", "i", (SUBR) mp3len, NULL, NULL}, + {"mp3scal", sizeof(DATASPACE), 0, "aak", "SkkkoooPP", + (SUBR)sinit3,(SUBR)sprocess3, (SUBR) mp3scale_cleanup}, }; diff --git a/Opcodes/newfils.c b/Opcodes/newfils.c index 66eddc30e2c..42091faf6ee 100644 --- a/Opcodes/newfils.c +++ b/Opcodes/newfils.c @@ -3653,109 +3653,109 @@ int ms_decod(CSOUND *csound, MIDSID *p) { static OENTRY localops[] = { - {"mvchpf", sizeof(mvchpf24), 0, 3, "a", "ako", + {"mvchpf", sizeof(mvchpf24), 0, "a", "ako", (SUBR) mvchpf24_init, (SUBR) mvchpf24_perf}, - {"mvchpf", sizeof(mvchpf24), 0, 3, "a", "aao", + {"mvchpf", sizeof(mvchpf24), 0, "a", "aao", (SUBR) mvchpf24_init, (SUBR) mvchpf24_perf_a}, - {"mvclpf1", sizeof(mvclpf24), 0, 3, "a", "akko", + {"mvclpf1", sizeof(mvclpf24), 0, "a", "akko", (SUBR) mvclpf24_init, (SUBR) mvclpf24_perf1}, - {"mvclpf1", sizeof(mvclpf24), 0, 3, "a", "aako", + {"mvclpf1", sizeof(mvclpf24), 0, "a", "aako", (SUBR) mvclpf24_init, (SUBR) mvclpf24_perf1_ak}, - {"mvclpf1", sizeof(mvclpf24), 0, 3, "a", "akao", + {"mvclpf1", sizeof(mvclpf24), 0, "a", "akao", (SUBR) mvclpf24_init, (SUBR) mvclpf24_perf1_ka}, - {"mvclpf1", sizeof(mvclpf24), 0, 3, "a", "aaao", + {"mvclpf1", sizeof(mvclpf24), 0, "a", "aaao", (SUBR) mvclpf24_init, (SUBR) mvclpf24_perf1_aa}, - {"mvclpf2", sizeof(mvclpf24), 0, 3, "a", "akko", + {"mvclpf2", sizeof(mvclpf24), 0, "a", "akko", (SUBR) mvclpf24_init, (SUBR) mvclpf24_perf2}, - {"mvclpf2", sizeof(mvclpf24), 0, 3, "a", "aako", + {"mvclpf2", sizeof(mvclpf24), 0, "a", "aako", (SUBR) mvclpf24_init, (SUBR) mvclpf24_perf2_ak}, - {"mvclpf2", sizeof(mvclpf24), 0, 3, "a", "akao", + {"mvclpf2", sizeof(mvclpf24), 0, "a", "akao", (SUBR) mvclpf24_init, (SUBR) mvclpf24_perf2_ka}, - {"mvclpf2", sizeof(mvclpf24), 0, 3, "a", "aaao", + {"mvclpf2", sizeof(mvclpf24), 0, "a", "aaao", (SUBR) mvclpf24_init, (SUBR) mvclpf24_perf2_aa}, - {"mvclpf3", sizeof(mvclpf24), 0, 3, "a", "akko", + {"mvclpf3", sizeof(mvclpf24), 0, "a", "akko", (SUBR) mvclpf24_init, (SUBR) mvclpf24_perf3}, - {"mvclpf3", sizeof(mvclpf24), 0, 3, "a", "aako", + {"mvclpf3", sizeof(mvclpf24), 0, "a", "aako", (SUBR) mvclpf24_init, (SUBR) mvclpf24_perf3_ak}, - {"mvclpf3", sizeof(mvclpf24), 0, 3, "a", "akao", + {"mvclpf3", sizeof(mvclpf24), 0, "a", "akao", (SUBR) mvclpf24_init, (SUBR) mvclpf24_perf3_ka}, - {"mvclpf3", sizeof(mvclpf24), 0, 3, "a", "aaao", + {"mvclpf3", sizeof(mvclpf24), 0, "a", "aaao", (SUBR) mvclpf24_init, (SUBR) mvclpf24_perf3_aa}, - {"mvclpf4", sizeof(mvclpf24_4), 0, 3, "aaaa", "akko", + {"mvclpf4", sizeof(mvclpf24_4), 0, "aaaa", "akko", (SUBR) mvclpf24_4_init, (SUBR) mvclpf24_perf4}, - {"mvclpf4", sizeof(mvclpf24), 0, 3, "aaaa", "aako", + {"mvclpf4", sizeof(mvclpf24), 0, "aaaa", "aako", (SUBR) mvclpf24_init, (SUBR) mvclpf24_perf4_ak}, - {"mvclpf4", sizeof(mvclpf24), 0, 3, "aaaa", "akao", + {"mvclpf4", sizeof(mvclpf24), 0, "aaaa", "akao", (SUBR) mvclpf24_init, (SUBR) mvclpf24_perf4_ka}, - {"mvclpf4", sizeof(mvclpf24), 0, 3, "aaaa", "aaao", + {"mvclpf4", sizeof(mvclpf24), 0, "aaaa", "aaao", (SUBR) mvclpf24_init, (SUBR) mvclpf24_perf4_aa}, - {"moogladder.kk", sizeof(moogladder), 0, 3, "a", "akko", + {"moogladder.kk", sizeof(moogladder), 0, "a", "akko", (SUBR) moogladder_init, (SUBR) moogladder_process }, - {"moogladder.aa", sizeof(moogladder), 0, 3, "a", "aaao", + {"moogladder.aa", sizeof(moogladder), 0, "a", "aaao", (SUBR) moogladder_init, (SUBR) moogladder_process_aa }, - {"moogladder.ak", sizeof(moogladder), 0, 3, "a", "aako", + {"moogladder.ak", sizeof(moogladder), 0, "a", "aako", (SUBR) moogladder_init, (SUBR) moogladder_process_ak }, - {"moogladder.ka", sizeof(moogladder), 0, 3, "a", "akao", + {"moogladder.ka", sizeof(moogladder), 0, "a", "akao", (SUBR) moogladder_init, (SUBR) moogladder_process_ka }, - {"moogladder2.kk", sizeof(moogladder), 0, 3, "a", "akko", + {"moogladder2.kk", sizeof(moogladder), 0, "a", "akko", (SUBR) moogladder_init, (SUBR) moogladder2_process }, - {"moogladder2.aa", sizeof(moogladder), 0, 3, "a", "aaao", + {"moogladder2.aa", sizeof(moogladder), 0, "a", "aaao", (SUBR) moogladder_init, (SUBR) moogladder2_process_aa }, - {"moogladder2.ak", sizeof(moogladder), 0, 3, "a", "aako", + {"moogladder2.ak", sizeof(moogladder), 0, "a", "aako", (SUBR) moogladder_init, (SUBR) moogladder2_process_ak }, - {"moogladder2.ka", sizeof(moogladder), 0, 3, "a", "akao", + {"moogladder2.ka", sizeof(moogladder), 0, "a", "akao", (SUBR) moogladder_init, (SUBR) moogladder2_process_ka }, - {"statevar", sizeof(statevar), 0, 3, "aaaa", "axxoo", + {"statevar", sizeof(statevar), 0, "aaaa", "axxoo", (SUBR) statevar_init, (SUBR) statevar_process }, - {"fofilter", sizeof(fofilter), 0, 3, "a", "axxxo", + {"fofilter", sizeof(fofilter), 0, "a", "axxxo", (SUBR) fofilter_init, (SUBR) fofilter_process }, - {"bob", sizeof(BOB), 0, 3, "a", "axxxoo", + {"bob", sizeof(BOB), 0, "a", "axxxoo", (SUBR) bob_init, (SUBR) bob_process }, - {"vps", sizeof(VPS), 0, 2, "a", "akk", + {"vps", sizeof(VPS), 0, "a", "akk", (SUBR) NULL, (SUBR) vps_process }, - {"vclpf", sizeof(VCF), 0, 3, "a", "akko", + {"vclpf", sizeof(VCF), 0, "a", "akko", (SUBR) vcf_init, (SUBR) vcf_perfk }, - {"vclpf", sizeof(VCF), 0, 3, "a", "aako", + {"vclpf", sizeof(VCF), 0, "a", "aako", (SUBR) vcf_init, (SUBR) vcf_perfak }, - {"vclpf", sizeof(VCF), 0, 3, "a", "akao", + {"vclpf", sizeof(VCF), 0, "a", "akao", (SUBR) vcf_init, (SUBR) vcf_perfka }, - {"vclpf", sizeof(VCF), 0, 3, "a", "aaao", + {"vclpf", sizeof(VCF), 0, "a", "aaao", (SUBR) vcf_init, (SUBR) vcf_perfaa }, - {"spf", sizeof(SPF), 0, 3, "a", "aaakko", + {"spf", sizeof(SPF), 0, "a", "aaakko", (SUBR) spf_init, (SUBR) spf_perfkk }, - {"spf", sizeof(SPF), 0, 3, "a", "aaaako", + {"spf", sizeof(SPF), 0, "a", "aaaako", (SUBR) spf_init, (SUBR) spf_perfak }, - {"spf", sizeof(SPF), 0, 3, "a", "aaaaao", + {"spf", sizeof(SPF), 0, "a", "aaaaao", (SUBR) spf_init, (SUBR) spf_perfaa }, - {"spf", sizeof(SPF), 0, 3, "a", "aaakao", + {"spf", sizeof(SPF), 0, "a", "aaakao", (SUBR) spf_init, (SUBR) spf_perfka }, - {"skf", sizeof(SKF), 0, 3, "a", "akkoo", + {"skf", sizeof(SKF), 0, "a", "akkoo", (SUBR) skf_init, (SUBR) skf_perfkk }, - {"skf", sizeof(SKF), 0, 3, "a", "aakoo", + {"skf", sizeof(SKF), 0, "a", "aakoo", (SUBR) skf_init, (SUBR) skf_perfak }, - {"skf", sizeof(SKF), 0, 3, "a", "aaaoo", + {"skf", sizeof(SKF), 0, "a", "aaaoo", (SUBR) skf_init, (SUBR) skf_perfaa }, - {"skf", sizeof(SKF), 0, 3, "a", "akaoo", + {"skf", sizeof(SKF), 0, "a", "akaoo", (SUBR) skf_init, (SUBR) skf_perfka }, - {"svn", sizeof(SVN), 0, 3, "aaaa", "akkkoopo", + {"svn", sizeof(SVN), 0, "aaaa", "akkkoopo", (SUBR) svn_init, (SUBR) svn_perfkk }, - {"svn", sizeof(SVN), 0, 3, "aaaa", "aakkoopo", + {"svn", sizeof(SVN), 0, "aaaa", "aakkoopo", (SUBR) svn_init, (SUBR) svn_perfak }, - {"svn", sizeof(SVN), 0, 3, "aaaa", "akakoopo", + {"svn", sizeof(SVN), 0, "aaaa", "akakoopo", (SUBR) svn_init, (SUBR) svn_perfka }, - {"svn", sizeof(SVN), 0, 3, "aaaa", "aaakoopo", + {"svn", sizeof(SVN), 0, "aaaa", "aaakoopo", (SUBR) svn_init, (SUBR) svn_perfaa }, - {"st2ms", sizeof(MIDSID), 0, 2, "aa", "aa", + {"st2ms", sizeof(MIDSID), 0, "aa", "aa", (SUBR) NULL, (SUBR) ms_encod}, - {"ms2st", sizeof(MIDSID), 0, 2, "aa", "aak", + {"ms2st", sizeof(MIDSID), 0, "aa", "aak", (SUBR) NULL, (SUBR) ms_decod }, - {"otafilter", sizeof(VCFNL), 0, 3, "aa", "akkko", + {"otafilter", sizeof(VCFNL), 0, "aa", "akkko", (SUBR) vcfnl_init, (SUBR) vcfnl_perfk}, - {"otafilter", sizeof(VCFNL), 0, 3, "aa", "aakko", + {"otafilter", sizeof(VCFNL), 0, "aa", "aakko", (SUBR) vcfnl_init, (SUBR) vcfnl_perfak}, - {"otafilter", sizeof(VCFNL), 0, 3, "aa", "akako", + {"otafilter", sizeof(VCFNL), 0, "aa", "akako", (SUBR) vcfnl_init, (SUBR) vcfnl_perfka}, - {"otafilter", sizeof(VCFNL), 0, 3, "aa", "aaako", + {"otafilter", sizeof(VCFNL), 0, "aa", "aaako", (SUBR) vcfnl_init, (SUBR) vcfnl_perfaa}, }; diff --git a/Opcodes/nlfilt.c b/Opcodes/nlfilt.c index f1cefc378a8..92a42e11fc4 100644 --- a/Opcodes/nlfilt.c +++ b/Opcodes/nlfilt.c @@ -199,8 +199,8 @@ static int32_t nlfilt2(CSOUND *csound, NLFILT *p) #define S(x) sizeof(x) static OENTRY localops[] = { -{ "nlfilt", S(NLFILT), 0, 3, "a", "akkkkk", (SUBR)nlfiltset, (SUBR)nlfilt }, -{ "nlfilt2", S(NLFILT), 0, 3, "a", "akkkkk", (SUBR)nlfiltset, (SUBR)nlfilt2 } +{ "nlfilt", S(NLFILT), 0, "a", "akkkkk", (SUBR)nlfiltset, (SUBR)nlfilt }, +{ "nlfilt2", S(NLFILT), 0, "a", "akkkkk", (SUBR)nlfiltset, (SUBR)nlfilt2 } }; int32_t nlfilt_init_(CSOUND *csound) diff --git a/Opcodes/oscbnk.c b/Opcodes/oscbnk.c index d2b66fa234a..df00753b849 100644 --- a/Opcodes/oscbnk.c +++ b/Opcodes/oscbnk.c @@ -2318,20 +2318,20 @@ static int32_t vco2ftset(CSOUND *csound, VCO2FT *p) + (*(p->vco2_tables))[w]->ntabl; p->npart_old = p->nparts + ((*(p->vco2_tables))[w]->ntabl >> 1); #endif - p->base_ftnum = (*(p->vco2_tables))[w]->base_ftnum; - if (*(p->inyx) > FL(0.5)) - p->p_scl = FL(0.5) * CS_ESR; - else if (*(p->inyx) < FL(0.001)) - p->p_scl = FL(0.001) * CS_ESR; - else - p->p_scl = *(p->inyx) * CS_ESR; - p->p_min = p->p_scl / (MYFLT) VCO2_MAX_NPART; - /* in case of vco2ift opcode, find table number now */ - if (!strcmp(p->h.optext->t.opcod, "vco2ift")) - vco2ftp(csound, p); - else /* else set perf routine to avoid */ - p->h.opadr = (SUBR) vco2ftp; /* "not initialised" error */ - return OK; + p->base_ftnum = (*(p->vco2_tables))[w]->base_ftnum; + if (*(p->inyx) > FL(0.5)) + p->p_scl = FL(0.5) * CS_ESR; + else if (*(p->inyx) < FL(0.001)) + p->p_scl = FL(0.001) * CS_ESR; + else + p->p_scl = *(p->inyx) * CS_ESR; + p->p_min = p->p_scl / (MYFLT) VCO2_MAX_NPART; + /* in case of vco2ift opcode, find table number now */ + if (!strcmp(p->h.optext->t.opcod, "vco2ift")) + vco2ftp(csound, p); + else /* else set perf routine to avoid */ + p->h.perf = (SUBR) vco2ftp; /* "not initialised" error */ + return OK; } /* ---- vco2ft opcode (performance) ---- */ @@ -2993,56 +2993,54 @@ static int32_t vco2(CSOUND *csound, VCO2 *p) static const OENTRY localops[] = { - { "oscbnk", sizeof(OSCBNK), TR, 3, "a", "kkkkiikkkkikkkkkkikooooooo", - (SUBR) oscbnkset, (SUBR) oscbnk }, - { "grain2", sizeof(GRAIN2), TR, 3, "a", "kkkikiooo", - (SUBR) grain2set, (SUBR) grain2 }, - { "grain3", sizeof(GRAIN3), TR, 3, "a", "kkkkkkikikkoo", - (SUBR) grain3set, (SUBR) grain3 }, - { "rnd31", 0xFFFF, 0, 0, NULL, NULL, - (SUBR) NULL, (SUBR) NULL, (SUBR) NULL }, - { "rnd31.i", sizeof(RND31), 0, 1, "i", "iio", - (SUBR) rnd31i, (SUBR) NULL, (SUBR) NULL }, - { "rnd31.k", sizeof(RND31), 0, 3, "k", "kko", - (SUBR) rnd31set, (SUBR) rnd31k, (SUBR) NULL }, - { "rnd31.a", sizeof(RND31), 0, 3, "a", "kko", - (SUBR) rnd31set, (SUBR) rnd31a }, - { "oscilikt", 0xFFFE, TR }, - { "oscilikt.a", sizeof(OSCKT), 0, 3, "a", "kkkoo", - (SUBR) oscktset, (SUBR)osckkikt }, - { "oscilikt.kk", sizeof(OSCKT), 0, 3, "k", "kkkoo", - (SUBR) oscktset, (SUBR) kosclikt, NULL }, - { "oscilikt.ka", sizeof(OSCKT), 0, 3, "a", "kakoo", - (SUBR) oscktset, (SUBR) osckaikt }, - { "oscilikt.ak", sizeof(OSCKT), 0, 3, "a", "akkoo", - (SUBR) oscktset, (SUBR) oscakikt }, - { "oscilikt.aa", sizeof(OSCKT), 0, 3, "a", "aakoo", - (SUBR) oscktset, (SUBR) oscaaikt }, - { "osciliktp", sizeof(OSCKTP), TR, 3, "a", "kkko", - (SUBR) oscktpset, (SUBR) oscktp }, - { "oscilikts", sizeof(OSCKTS), TR, 3, "a", "xxkako", - (SUBR) oscktsset, (SUBR) osckts }, - { "vco2init", sizeof(VCO2INIT), TW, 1, "i", "ijjjjj", - (SUBR) vco2init, (SUBR) NULL, (SUBR) NULL }, - { "vco2ift", sizeof(VCO2FT), TW, 1, "i", "iov", - (SUBR) vco2ftset, (SUBR) NULL, (SUBR) NULL }, - { "vco2ft", sizeof(VCO2FT), TW, 3, "k", "kov", - (SUBR) vco2ftset, (SUBR) vco2ft, (SUBR) NULL }, - // { "vco2", sizeof(VCO2), TR, 3, "a", "kkoM", - { "vco2", sizeof(VCO2), TR, 3, "a", "kkoOOo", - (SUBR) vco2set, (SUBR) vco2 }, - { "denorm", sizeof(DENORMS), WI, 2, "", "y", - (SUBR) NULL, (SUBR) denorms }, - { "delayk", sizeof(DELAYK), 0, 3, "k", "kio", - (SUBR) delaykset, (SUBR) delayk, (SUBR) NULL }, - { "vdel_k", sizeof(VDELAYK), 0, 3, "k", "kkio", - (SUBR) vdelaykset, (SUBR) vdelayk, (SUBR) NULL }, - { "rbjeq", sizeof(RBJEQ), 0, 3, "a", "akkkko", - (SUBR) rbjeqset, (SUBR) rbjeq } - }; - - int32_t oscbnk_init_(CSOUND *csound) - { + { "oscbnk", sizeof(OSCBNK), TR, "a", "kkkkiikkkkikkkkkkikooooooo", + (SUBR) oscbnkset, (SUBR) oscbnk }, + { "grain2", sizeof(GRAIN2), TR, "a", "kkkikiooo", + (SUBR) grain2set, (SUBR) grain2 }, + { "grain3", sizeof(GRAIN3), TR, "a", "kkkkkkikikkoo", + (SUBR) grain3set, (SUBR) grain3 }, + { "rnd31.i", sizeof(RND31), 0, "i", "iio", + (SUBR) rnd31i, (SUBR) NULL, (SUBR) NULL }, + { "rnd31.k", sizeof(RND31), 0, "k", "kko", + (SUBR) rnd31set, (SUBR) rnd31k, (SUBR) NULL }, + { "rnd31.a", sizeof(RND31), 0, "a", "kko", + (SUBR) rnd31set, (SUBR) rnd31a }, + { "oscilikt", 0xFFFE, TR }, + { "oscilikt.a", sizeof(OSCKT), 0, "a", "kkkoo", + (SUBR) oscktset, (SUBR)osckkikt }, + { "oscilikt.kk", sizeof(OSCKT), 0, "k", "kkkoo", + (SUBR) oscktset, (SUBR) kosclikt, NULL }, + { "oscilikt.ka", sizeof(OSCKT), 0, "a", "kakoo", + (SUBR) oscktset, (SUBR) osckaikt }, + { "oscilikt.ak", sizeof(OSCKT), 0, "a", "akkoo", + (SUBR) oscktset, (SUBR) oscakikt }, + { "oscilikt.aa", sizeof(OSCKT), 0, "a", "aakoo", + (SUBR) oscktset, (SUBR) oscaaikt }, + { "osciliktp", sizeof(OSCKTP), TR, "a", "kkko", + (SUBR) oscktpset, (SUBR) oscktp }, + { "oscilikts", sizeof(OSCKTS), TR, "a", "xxkako", + (SUBR) oscktsset, (SUBR) osckts }, + { "vco2init", sizeof(VCO2INIT), TW, "i", "ijjjjj", + (SUBR) vco2init, (SUBR) NULL, (SUBR) NULL }, + { "vco2ift", sizeof(VCO2FT), TW, "i", "iov", + (SUBR) vco2ftset, (SUBR) NULL, (SUBR) NULL }, + { "vco2ft", sizeof(VCO2FT), TW, "k", "kov", + (SUBR) vco2ftset, (SUBR) vco2ft, (SUBR) NULL }, +// { "vco2", sizeof(VCO2), TR, "a", "kkoM", + { "vco2", sizeof(VCO2), TR, "a", "kkoOOo", + (SUBR) vco2set, (SUBR) vco2 }, + { "denorm", sizeof(DENORMS), WI, "", "y", + (SUBR) NULL, (SUBR) denorms }, + { "delayk", sizeof(DELAYK), 0, "k", "kio", + (SUBR) delaykset, (SUBR) delayk, (SUBR) NULL }, + { "vdel_k", sizeof(VDELAYK), 0, "k", "kkio", + (SUBR) vdelaykset, (SUBR) vdelayk, (SUBR) NULL }, + { "rbjeq", sizeof(RBJEQ), 0, "a", "akkkko", + (SUBR) rbjeqset, (SUBR) rbjeq } +}; + +int32_t oscbnk_init_(CSOUND *csound) +{ return csound->AppendOpcodes(csound, &(localops[0]), (int32_t ) (sizeof(localops) / sizeof(OENTRY))); diff --git a/Opcodes/pan2.c b/Opcodes/pan2.c index 5583fe10a8b..33a7b226cb0 100644 --- a/Opcodes/pan2.c +++ b/Opcodes/pan2.c @@ -172,7 +172,7 @@ static int32_t pan2run(CSOUND *csound, PAN2 *p) static OENTRY pan2_localops[] = { - { "pan2", sizeof(PAN2), 0, 3, "aa", "axo", (SUBR) pan2set, (SUBR) pan2run }, + { "pan2", sizeof(PAN2), 0, "aa", "axo", (SUBR) pan2set, (SUBR) pan2run }, }; LINKAGE_BUILTIN(pan2_localops) diff --git a/Opcodes/partials.c b/Opcodes/partials.c index dc68df1d568..b6ab16d86d4 100644 --- a/Opcodes/partials.c +++ b/Opcodes/partials.c @@ -530,9 +530,9 @@ int32_t part2txt_perf(CSOUND *csound, PARTXT *p){ static OENTRY localops[] = { - { "partials", sizeof(_PARTS), 0, 3, "f", "ffkkki", + { "partials", sizeof(_PARTS), 0, "f", "ffkkki", (SUBR) partials_init, (SUBR) partials_process }, - { "part2txt", sizeof(_PARTS), 0, 3, "", "Sf", + { "part2txt", sizeof(_PARTS), 0, "", "Sf", (SUBR) part2txt_init, (SUBR) part2txt_perf } }; diff --git a/Opcodes/partikkel.c b/Opcodes/partikkel.c index 54c64c79f03..0a56040598b 100644 --- a/Opcodes/partikkel.c +++ b/Opcodes/partikkel.c @@ -1011,27 +1011,27 @@ static int32_t partikkelset(CSOUND *csound, PARTIKKEL_SET *p) static OENTRY partikkel_localops[] = { { - "partikkel", sizeof(PARTIKKEL), TR, 3, + "partikkel", sizeof(PARTIKKEL), TR, "ammmmmmm", "xkiakiiikkkkikkiiaikikkkikkkkkiaaaakkkkioj", (SUBR)partikkel_init, (SUBR)partikkel }, { - "partikkelsync", sizeof(PARTIKKEL_SYNC), TR, 3, + "partikkelsync", sizeof(PARTIKKEL_SYNC), TR, "am", "i", (SUBR)partikkelsync_init, (SUBR)partikkelsync }, { - "partikkelget", sizeof(PARTIKKEL_GET), TR, 3, + "partikkelget", sizeof(PARTIKKEL_GET), TR, "k", "ki", (SUBR)partikkelget_init, (SUBR)partikkelget, (SUBR)NULL }, { - "partikkelset", sizeof(PARTIKKEL_SET), TR, 3, + "partikkelset", sizeof(PARTIKKEL_SET), TR, "", "kki", (SUBR)partikkelset_init, (SUBR)partikkelset, diff --git a/Opcodes/paulstretch.c b/Opcodes/paulstretch.c index ea9b4b557f9..f30fab4a97e 100644 --- a/Opcodes/paulstretch.c +++ b/Opcodes/paulstretch.c @@ -204,7 +204,7 @@ static int32_t paulstretch_perf(CSOUND* csound, PAULSTRETCH *p) } static OENTRY paulstretch_localops[] = { - { "paulstretch", (int32_t) sizeof(PAULSTRETCH), TR, 3, "a", "iii", + { "paulstretch", (int32_t) sizeof(PAULSTRETCH), TR, "a", "iii", (int32_t (*)(CSOUND *, void *)) ps_init, (int32_t (*)(CSOUND *, void *)) paulstretch_perf} }; diff --git a/Opcodes/phisem.c b/Opcodes/phisem.c index 7f7a8f86ea8..c9ecccb0a23 100644 --- a/Opcodes/phisem.c +++ b/Opcodes/phisem.c @@ -1299,18 +1299,18 @@ static int32_t sleighbells(CSOUND *csound, SLEIGHBELLS *p) static OENTRY phisem_localops[] = { - { "cabasa", S(CABASA), 0, 3, "a", "iiooo", (SUBR)cabasaset, (SUBR)cabasa}, - { "crunch", S(CABASA), 0, 3, "a", "iiooo", (SUBR)crunchset, (SUBR)cabasa}, - { "sekere", S(SEKERE), 0, 3, "a", "iiooo", (SUBR)sekereset, (SUBR)sekere}, - { "sandpaper", S(SEKERE),0, 3, "a", "iiooo", (SUBR)sandset, (SUBR)sekere}, - { "stix", S(SEKERE), 0, 3, "a", "iiooo", (SUBR)stixset, (SUBR)sekere}, - { "guiro", S(GUIRO), 0, 3, "a", "kiooooo",(SUBR)guiroset, (SUBR)guiro }, - { "tambourine", S(TAMBOURINE),0, 3,"a", "kioooooo", + { "cabasa", S(CABASA), 0, "a", "iiooo", (SUBR)cabasaset, (SUBR)cabasa}, + { "crunch", S(CABASA), 0, "a", "iiooo", (SUBR)crunchset, (SUBR)cabasa}, + { "sekere", S(SEKERE), 0, "a", "iiooo", (SUBR)sekereset, (SUBR)sekere}, + { "sandpaper", S(SEKERE),0, "a", "iiooo", (SUBR)sandset, (SUBR)sekere}, + { "stix", S(SEKERE), 0, "a", "iiooo", (SUBR)stixset, (SUBR)sekere}, + { "guiro", S(GUIRO), 0, "a", "kiooooo",(SUBR)guiroset, (SUBR)guiro }, + { "tambourine", S(TAMBOURINE),0,"a", "kioooooo", (SUBR)tambourset, (SUBR)tambourine}, - { "bamboo", S(BAMBOO), 0, 3, "a", "kioooooo", + { "bamboo", S(BAMBOO), 0, "a", "kioooooo", (SUBR)bambooset, (SUBR)bamboo }, - { "dripwater", S(WUTER), 0, 3, "a", "kioooooo", (SUBR)wuterset, (SUBR)wuter }, - { "sleighbells", S(SLEIGHBELLS), 0, 3, "a","kioooooo", + { "dripwater", S(WUTER), 0, "a", "kioooooo", (SUBR)wuterset, (SUBR)wuter }, + { "sleighbells", S(SLEIGHBELLS), 0, "a","kioooooo", (SUBR)sleighset, (SUBR)sleighbells } }; diff --git a/Opcodes/physmod.c b/Opcodes/physmod.c index f57288deaf2..6a94baceb87 100644 --- a/Opcodes/physmod.c +++ b/Opcodes/physmod.c @@ -1,24 +1,24 @@ /* - physmod.c: + physmod.c: - Copyright (C) 1996, 1997 Perry Cook, John ffitch + Copyright (C) 1996, 1997 Perry Cook, John ffitch - This file is part of Csound. + This file is part of Csound. - The Csound Library is free software; you can redistribute it - and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + The Csound Library is free software; you can redistribute it + and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - Csound is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. + Csound is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with Csound; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - 02110-1301 USA + You should have received a copy of the GNU Lesser General Public + License along with Csound; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + 02110-1301 USA */ /* Collection of physical modelled instruments */ @@ -57,15 +57,15 @@ /**********************************************/ static inline MYFLT ReedTabl_LookUp(ReedTabl *r, MYFLT deltaP) - /* Perform "Table Lookup" by direct clipped */ - /* linear function calculation */ +/* Perform "Table Lookup" by direct clipped */ +/* linear function calculation */ { /* deltaP is differential reed pressure */ - MYFLT lastOutput = r->offSet + (r->slope * deltaP); /* basic non-lin */ - if (lastOutput > FL(1.0)) - lastOutput = FL(1.0); /* if other way, reed slams shut */ - if (lastOutput < -FL(1.0)) - lastOutput = -FL(1.0); /* if all the way open, acts like open end */ - return lastOutput; + MYFLT lastOutput = r->offSet + (r->slope * deltaP); /* basic non-lin */ + if (lastOutput > FL(1.0)) + lastOutput = FL(1.0); /* if other way, reed slams shut */ + if (lastOutput < -FL(1.0)) + lastOutput = -FL(1.0); /* if all the way open, acts like open end */ + return lastOutput; } /*******************************************/ @@ -85,28 +85,28 @@ static inline MYFLT ReedTabl_LookUp(ReedTabl *r, MYFLT deltaP) void make_OneZero(OneZero* z) { - z->gain = FL(1.0); - z->zeroCoeff = FL(1.0); - z->sgain = FL(0.5); - z->inputs = FL(0.0); + z->gain = FL(1.0); + z->zeroCoeff = FL(1.0); + z->sgain = FL(0.5); + z->inputs = FL(0.0); } MYFLT OneZero_tick(OneZero* z, MYFLT sample) /* Perform Filter Operation */ { - MYFLT temp, lastOutput; - temp = z->sgain * sample; - lastOutput = (z->inputs * z->zeroCoeff) + temp; - z->inputs = temp; - return lastOutput; + MYFLT temp, lastOutput; + temp = z->sgain * sample; + lastOutput = (z->inputs * z->zeroCoeff) + temp; + z->inputs = temp; + return lastOutput; } void OneZero_setCoeff(OneZero* z, MYFLT aValue) { - z->zeroCoeff = aValue; - if (z->zeroCoeff > FL(0.0)) /* Normalize gain to 1.0 max */ - z->sgain = z->gain / (FL(1.0) + z->zeroCoeff); - else - z->sgain = z->gain / (FL(1.0) - z->zeroCoeff); + z->zeroCoeff = aValue; + if (z->zeroCoeff > FL(0.0)) /* Normalize gain to 1.0 max */ + z->sgain = z->gain / (FL(1.0) + z->zeroCoeff); + else + z->sgain = z->gain / (FL(1.0) - z->zeroCoeff); } /* void OneZero_print(CSOUND *csound, OneZero *p) */ @@ -119,137 +119,137 @@ void OneZero_setCoeff(OneZero* z, MYFLT aValue) /* *********************************************************************** */ int32_t clarinset(CSOUND *csound, CLARIN *p) { - FUNC *ftp; - - if (LIKELY((ftp = csound->FTnp2Find(csound, p->ifn)) != NULL)) p->vibr = ftp; - else { /* Expect sine wave */ - return csound->InitError(csound, "%s", Str("No table for Clarinet")); + FUNC *ftp; + + if (LIKELY((ftp = csound->FTnp2Find(csound, p->ifn)) != NULL)) p->vibr = ftp; + else { /* Expect sine wave */ + return csound->InitError(csound, "%s", Str("No table for Clarinet")); + } + if (*p->lowestFreq>=FL(0.0)) { /* Skip initialisation */ + if (*p->lowestFreq) + p->length = (int32_t) (CS_ESR / *p->lowestFreq + FL(1.0)); + else if (LIKELY(*p->frequency)) + p->length = (int32_t) (CS_ESR / *p->frequency + FL(1.0)); + else { + csound->Warning(csound, "%s", Str("No base frequency for clarinet " + "-- assuming 50Hz\n")); + p->length = (int32_t) (CS_ESR / FL(50.0) + FL(1.0)); } - if (*p->lowestFreq>=FL(0.0)) { /* Skip initialisation */ - if (*p->lowestFreq) - p->length = (int32_t) (CS_ESR / *p->lowestFreq + FL(1.0)); - else if (LIKELY(*p->frequency)) - p->length = (int32_t) (CS_ESR / *p->frequency + FL(1.0)); - else { - csound->Warning(csound, "%s", Str("No base frequency for clarinet " - "-- assuming 50Hz\n")); - p->length = (int32_t) (CS_ESR / FL(50.0) + FL(1.0)); - } - make_DLineL(csound, &p->delayLine, p->length); - p->reedTable.offSet = FL(0.7); - p->reedTable.slope = -FL(0.3); - make_OneZero(&(p->filter)); - make_Envelope(&p->envelope); - make_Noise(p->noise); + make_DLineL(csound, &p->delayLine, p->length); + p->reedTable.offSet = FL(0.7); + p->reedTable.slope = -FL(0.3); + make_OneZero(&(p->filter)); + make_Envelope(&p->envelope); + make_Noise(p->noise); /* p->noiseGain = 0.2f; */ /* Arguemnts; suggested values? */ /* p->vibrGain = 0.1f; */ - { - int32_t relestim = (int32_t)(CS_EKR * FL(0.1)); - /* 1/10th second decay extention */ - if (relestim > p->h.insdshead->xtratim) - p->h.insdshead->xtratim = relestim; - } - p->kloop = (int32_t) ((int32_t) (p->h.insdshead->offtim * CS_EKR) - - (int32_t) (CS_EKR * *p->attack)); + { + int32_t relestim = (int32_t)(CS_EKR * FL(0.1)); + /* 1/10th second decay extention */ + if (relestim > p->h.insdshead->xtratim) + p->h.insdshead->xtratim = relestim; + } + p->kloop = (int32_t) ((int32_t) (p->h.insdshead->offtim * CS_EKR) + - (int32_t) (CS_EKR * *p->attack)); #ifdef BETA - csound->Message(csound, "offtim=%f kloop=%d\n", - p->h.insdshead->offtim, p->kloop); + csound->Message(csound, "offtim=%f kloop=%d\n", + p->h.insdshead->offtim, p->kloop); #endif - p->envelope.rate = FL(0.0); - p->v_time = 0; - } - return OK; + p->envelope.rate = FL(0.0); + p->v_time = 0; + } + return OK; } int32_t clarin(CSOUND *csound, CLARIN *p) { - MYFLT *ar = p->ar; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t n, nsmps = CS_KSMPS; - MYFLT amp = (*p->amp)*AMP_RSCALE; /* Normalise */ - MYFLT nGain = *p->noiseGain; - int32_t v_len = (int32_t)p->vibr->flen; - MYFLT *v_data = p->vibr->ftable; - MYFLT vibGain = *p->vibAmt; - MYFLT vTime = p->v_time; - - if (p->envelope.rate==FL(0.0)) { - p->envelope.rate = amp /(*p->attack*CS_ESR); - p->envelope.value = p->envelope.target = FL(0.55) + amp*FL(0.30); - } - p->outputGain = amp + FL(0.001); - DLineL_setDelay(&p->delayLine, /* length - approx filter delay */ - (CS_ESR/ *p->frequency) * FL(0.5) - FL(1.5)); - p->v_rate = *p->vibFreq * p->vibr->flen * CS_ONEDSR; - /* Check to see if into decay yet */ - if (p->kloop>0 && p->h.insdshead->relesing) p->kloop=1; - if ((--p->kloop) == 0) { - p->envelope.state = 1; /* Start change */ - p->envelope.rate = p->envelope.value / (*p->dettack * CS_ESR); - p->envelope.target = FL(0.0); + MYFLT *ar = p->ar; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t n, nsmps = CS_KSMPS; + MYFLT amp = (*p->amp)*AMP_RSCALE; /* Normalise */ + MYFLT nGain = *p->noiseGain; + int32_t v_len = (int32_t)p->vibr->flen; + MYFLT *v_data = p->vibr->ftable; + MYFLT vibGain = *p->vibAmt; + MYFLT vTime = p->v_time; + + if (p->envelope.rate==FL(0.0)) { + p->envelope.rate = amp /(*p->attack*CS_ESR); + p->envelope.value = p->envelope.target = FL(0.55) + amp*FL(0.30); + } + p->outputGain = amp + FL(0.001); + DLineL_setDelay(&p->delayLine, /* length - approx filter delay */ + (CS_ESR/ *p->frequency) * FL(0.5) - FL(1.5)); + p->v_rate = *p->vibFreq * p->vibr->flen * CS_ONEDSR; + /* Check to see if into decay yet */ + if (p->kloop>0 && p->h.insdshead->relesing) p->kloop=1; + if ((--p->kloop) == 0) { + p->envelope.state = 1; /* Start change */ + p->envelope.rate = p->envelope.value / (*p->dettack * CS_ESR); + p->envelope.target = FL(0.0); #ifdef BETA - csound->Message(csound, "Set off phase time = %f Breath v,r = %f, %f\n", - (MYFLT) CS_KCNT * CS_ONEDKR, - p->envelope.value, p->envelope.rate); + csound->Message(csound, "Set off phase time = %f Breath v,r = %f, %f\n", + (MYFLT) CS_KCNT * CS_ONEDKR, + p->envelope.value, p->envelope.rate); #endif - } - if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - nsmps -= early; - memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset;nenvelope); - breathPressure += breathPressure * nGain * Noise_tick(csound,&p->noise); - /* Tick on vibrato table */ - vTime += p->v_rate; /* Update current time */ - while (vTime >= v_len) /* Check for end of sound */ - vTime -= v_len; /* loop back to beginning */ - while (vTime < FL(0.0)) /* Check for end of sound */ - vTime += v_len; /* loop back to beginning */ - - temp_time = vTime; + } + if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + nsmps -= early; + memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); + } + for (n=offset;nenvelope); + breathPressure += breathPressure * nGain * Noise_tick(csound,&p->noise); + /* Tick on vibrato table */ + vTime += p->v_rate; /* Update current time */ + while (vTime >= v_len) /* Check for end of sound */ + vTime -= v_len; /* loop back to beginning */ + while (vTime < FL(0.0)) /* Check for end of sound */ + vTime += v_len; /* loop back to beginning */ + + temp_time = vTime; #ifdef have_phase - if (p->v_phaseOffset != FL(0.0)) { - temp_time += p->v_phaseOffset; /* Add phase offset */ - while (temp_time >= v_len) /* Check for end of sound */ - temp_time -= v_len; /* loop back to beginning */ - while (temp_time < FL(0.0)) /* Check for end of sound */ - temp_time += v_len; /* loop back to beginning */ - } + if (p->v_phaseOffset != FL(0.0)) { + temp_time += p->v_phaseOffset; /* Add phase offset */ + while (temp_time >= v_len) /* Check for end of sound */ + temp_time -= v_len; /* loop back to beginning */ + while (temp_time < FL(0.0)) /* Check for end of sound */ + temp_time += v_len; /* loop back to beginning */ + } #endif - temp = (int32_t) temp_time; /* Integer part of time address */ + temp = (int32_t) temp_time; /* Integer part of time address */ /* fractional part of time address */ - alpha = temp_time - (MYFLT)temp; - v_lastOutput = v_data[temp]; /* Do linear interpolation */ - /* same as alpha*data[temp+1] + (1-alpha)data[temp] */ - v_lastOutput += (alpha * (v_data[temp+1] - v_lastOutput)); - /* End of vibrato tick */ - breathPressure += breathPressure * vibGain * v_lastOutput; - pressureDiff = OneZero_tick(&p->filter, /* differential pressure */ - DLineL_lastOut(&p->delayLine)); - pressureDiff = (-FL(0.95)*pressureDiff) - breathPressure; - /* of reflected and mouth */ - nextsamp = pressureDiff * ReedTabl_LookUp(&p->reedTable,pressureDiff); - nextsamp = breathPressure + nextsamp; - /* perform scattering in economical way */ - lastOutput = DLineL_tick(&p->delayLine, nextsamp); - lastOutput *= p->outputGain; - ar[n] = lastOutput*AMP_SCALE; - } - p->v_time = vTime; - - return OK; + alpha = temp_time - (MYFLT)temp; + v_lastOutput = v_data[temp]; /* Do linear interpolation */ + /* same as alpha*data[temp+1] + (1-alpha)data[temp] */ + v_lastOutput += (alpha * (v_data[temp+1] - v_lastOutput)); + /* End of vibrato tick */ + breathPressure += breathPressure * vibGain * v_lastOutput; + pressureDiff = OneZero_tick(&p->filter, /* differential pressure */ + DLineL_lastOut(&p->delayLine)); + pressureDiff = (-FL(0.95)*pressureDiff) - breathPressure; + /* of reflected and mouth */ + nextsamp = pressureDiff * ReedTabl_LookUp(&p->reedTable,pressureDiff); + nextsamp = breathPressure + nextsamp; + /* perform scattering in economical way */ + lastOutput = DLineL_tick(&p->delayLine, nextsamp); + lastOutput *= p->outputGain; + ar[n] = lastOutput*AMP_SCALE; + } + p->v_time = vTime; + + return OK; } /******************************************/ @@ -278,191 +278,191 @@ int32_t clarin(CSOUND *csound, CLARIN *p) static inline MYFLT JetTabl_lookup(MYFLT sample) /* Perform "Table Lookup" */ { /* By Polynomial Calculation */ /* (x^3 - x) approximates sigmoid of jet */ - MYFLT j = sample * (sample*sample - FL(1.0)); - if (j > FL(1.0)) j = FL(1.0); /* Saturation at +/- 1.0 */ - else if (j < -FL(1.0)) j = -FL(1.0); - return j; + MYFLT j = sample * (sample*sample - FL(1.0)); + if (j > FL(1.0)) j = FL(1.0); /* Saturation at +/- 1.0 */ + else if (j < -FL(1.0)) j = -FL(1.0); + return j; } int32_t fluteset(CSOUND *csound, FLUTE *p) { - FUNC *ftp; - int32 length; - - if (LIKELY((ftp = csound->FTnp2Find(csound, p->ifn)) != NULL)) p->vibr = ftp; - else { /* Expect sine wave */ - return csound->InitError(csound, "%s", Str("No table for Flute")); + FUNC *ftp; + int32 length; + + if (LIKELY((ftp = csound->FTnp2Find(csound, p->ifn)) != NULL)) p->vibr = ftp; + else { /* Expect sine wave */ + return csound->InitError(csound, "%s", Str("No table for Flute")); + } + if (*p->lowestFreq>=FL(0.0)) { /* Skip initialisation?? */ + if (*p->lowestFreq!=FL(0.0)) { + length = (int32_t) (CS_ESR / *p->lowestFreq + FL(1.0)); + p->limit = *p->lowestFreq; } - if (*p->lowestFreq>=FL(0.0)) { /* Skip initialisation?? */ - if (*p->lowestFreq!=FL(0.0)) { - length = (int32_t) (CS_ESR / *p->lowestFreq + FL(1.0)); - p->limit = *p->lowestFreq; - } - else if (*p->frequency!=FL(0.0)) { - length = (int32_t) (CS_ESR / *p->frequency + FL(1.0)); - p->limit = *p->frequency; - } - else { - csound->Warning(csound, "%s", Str("No base frequency for flute " - "-- assumed to be 50Hz\n")); - length = (int32_t) (CS_ESR / FL(50.0) + FL(1.0)); - p->limit = FL(50.0); - } - make_DLineL(csound, &p->boreDelay, length); - length = length >> 1; /* ??? really; yes from later version */ - make_DLineL(csound, &p->jetDelay, length); - make_OnePole(&p->filter); - make_DCBlock(&p->dcBlock); - make_Noise(p->noise); - make_ADSR(&p->adsr, CS_ESR); - /* Clear */ -/* OnePole_clear(&p->filter); */ -/* DCBlock_clear(&p->dcBlock); */ - /* End Clear */ -/* DLineL_setDelay(&p->boreDelay, 100.0f); */ -/* DLineL_setDelay(&p->jetDelay, 49.0f); */ - - OnePole_setPole(&p->filter, FL(0.7) - (FL(0.1) * RATE_NORM)); - OnePole_setGain(&p->filter, -FL(1.0)); - ADSR_setAllTimes(csound, &p->adsr, FL(0.005), FL(0.01), FL(0.8), FL(0.010)); -/* ADSR_setAll(&p->adsr, 0.02f, 0.05f, 0.8f, 0.001f); */ + else if (*p->frequency!=FL(0.0)) { + length = (int32_t) (CS_ESR / *p->frequency + FL(1.0)); + p->limit = *p->frequency; + } + else { + csound->Warning(csound, "%s", Str("No base frequency for flute " + "-- assumed to be 50Hz\n")); + length = (int32_t) (CS_ESR / FL(50.0) + FL(1.0)); + p->limit = FL(50.0); + } + make_DLineL(csound, &p->boreDelay, length); + length = length >> 1; /* ??? really; yes from later version */ + make_DLineL(csound, &p->jetDelay, length); + make_OnePole(&p->filter); + make_DCBlock(&p->dcBlock); + make_Noise(p->noise); + make_ADSR(&p->adsr, CS_ESR); + /* Clear */ + /* OnePole_clear(&p->filter); */ + /* DCBlock_clear(&p->dcBlock); */ + /* End Clear */ + /* DLineL_setDelay(&p->boreDelay, 100.0f); */ + /* DLineL_setDelay(&p->jetDelay, 49.0f); */ + + OnePole_setPole(&p->filter, FL(0.7) - (FL(0.1) * RATE_NORM)); + OnePole_setGain(&p->filter, -FL(1.0)); + ADSR_setAllTimes(csound, &p->adsr, FL(0.005), FL(0.01), FL(0.8), FL(0.010)); + /* ADSR_setAll(&p->adsr, 0.02f, 0.05f, 0.8f, 0.001f); */ /* Suggested values */ /* p->endRefl = 0.5; */ /* p->jetRefl = 0.5; */ /* p->noiseGain = 0.15; */ /* Breath pressure random component */ /* p->vibrGain = 0.05; */ /* breath periodic vibrato component */ /* p->jetRatio = 0.32; */ - p->lastamp = FL(1.0); /* Remember */ - /* This should be controlled by attack */ - ADSR_setAttackRate(csound, &p->adsr, FL(0.02)); - p->maxPress = FL(2.3) / FL(0.8); - p->outputGain = FL(1.001); - ADSR_keyOn(&p->adsr); - p->kloop = (MYFLT)((int32_t)(p->h.insdshead->offtim*CS_EKR - - CS_EKR*(*p->dettack))); - - p->lastFreq = FL(0.0); - p->lastJet = -FL(1.0); - /* freq = (2/3)*p->frequency as we're overblowing here */ - /* but 1/(2/3) is 1.5 so multiply for speed */ - } - return OK; + p->lastamp = FL(1.0); /* Remember */ + /* This should be controlled by attack */ + ADSR_setAttackRate(csound, &p->adsr, FL(0.02)); + p->maxPress = FL(2.3) / FL(0.8); + p->outputGain = FL(1.001); + ADSR_keyOn(&p->adsr); + p->kloop = (MYFLT)((int32_t)(p->h.insdshead->offtim*CS_EKR - + CS_EKR*(*p->dettack))); + + p->lastFreq = FL(0.0); + p->lastJet = -FL(1.0); + /* freq = (2/3)*p->frequency as we're overblowing here */ + /* but 1/(2/3) is 1.5 so multiply for speed */ + } + return OK; } int32_t flute(CSOUND *csound, FLUTE *p) { - MYFLT *ar = p->ar; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t n, nsmps = CS_KSMPS; - MYFLT amp = (*p->amp)*AMP_RSCALE; /* Normalise */ - MYFLT temp; - int32_t v_len = (int32_t)p->vibr->flen; - MYFLT *v_data = p->vibr->ftable; - MYFLT v_time = p->v_time; - MYFLT vibGain = *p->vibAmt; - MYFLT jetRefl, endRefl, noisegain; - - if (amp!=p->lastamp) { /* If amplitude has changed */ - /* This should be controlled by attack */ - ADSR_setAttackRate(csound, &p->adsr, amp * FL(0.02)); - p->maxPress = (FL(1.1) + (amp * FL(0.20))) / FL(0.8); - p->outputGain = amp + FL(0.001); - p->lastamp = amp; - } - p->v_rate = *p->vibFreq * v_len * CS_ONEDSR; - /* Start SetFreq */ - if (p->lastFreq != *p->frequency) { /* It changed */ - p->lastFreq = *p->frequency; - if (p->limit>p->lastFreq) { - p->lastFreq = p->limit; - csound->Warning(csound, "%s", Str("frequency too low, set to minimum")); - } - p->lastJet = *p->jetRatio; - /* freq = (2/3)*p->frequency as we're overblowing here */ - /* but 1/(2/3) is 1.5 so multiply for speed */ - /* Length - approx. filter delay */ - temp = FL(1.5)* CS_ESR / p->lastFreq - FL(2.0); - DLineL_setDelay(&p->boreDelay, temp); /* Length of bore tube */ - DLineL_setDelay(&p->jetDelay, temp * p->lastJet); /* jet delay shorter */ - } - else if (*p->jetRatio != p->lastJet) { /* Freq same but jet changed */ - p->lastJet = *p->jetRatio; - /* Length - approx. filter delay */ - temp = FL(1.5)* CS_ESR / p->lastFreq - FL(2.0); - DLineL_setDelay(&p->jetDelay, temp * p->lastJet); /* jet delay shorter */ - } - /* End SetFreq */ - - if (p->kloop>FL(0.0) && p->h.insdshead->relesing) p->kloop=FL(1.0); - if ((--p->kloop) == 0) { - p->adsr.releaseRate = p->adsr.value / (*p->dettack * CS_ESR); - p->adsr.target = FL(0.0); - p->adsr.rate = p->adsr.releaseRate; - p->adsr.state = RELEASE; - } - noisegain = *p->noiseGain; jetRefl = *p->jetRefl; endRefl = *p->endRefl; - if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - nsmps -= early; - memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); + MYFLT *ar = p->ar; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t n, nsmps = CS_KSMPS; + MYFLT amp = (*p->amp)*AMP_RSCALE; /* Normalise */ + MYFLT temp; + int32_t v_len = (int32_t)p->vibr->flen; + MYFLT *v_data = p->vibr->ftable; + MYFLT v_time = p->v_time; + MYFLT vibGain = *p->vibAmt; + MYFLT jetRefl, endRefl, noisegain; + + if (amp!=p->lastamp) { /* If amplitude has changed */ + /* This should be controlled by attack */ + ADSR_setAttackRate(csound, &p->adsr, amp * FL(0.02)); + p->maxPress = (FL(1.1) + (amp * FL(0.20))) / FL(0.8); + p->outputGain = amp + FL(0.001); + p->lastamp = amp; + } + p->v_rate = *p->vibFreq * v_len * CS_ONEDSR; + /* Start SetFreq */ + if (p->lastFreq != *p->frequency) { /* It changed */ + p->lastFreq = *p->frequency; + if (p->limit>p->lastFreq) { + p->lastFreq = p->limit; + csound->Warning(csound, "%s", Str("frequency too low, set to minimum")); } - for (n=offset;nmaxPress * ADSR_tick(&p->adsr); /* Breath Pressure */ - randPress = noisegain*Noise_tick(csound,&p->noise); /* Random Deviation */ - /* Tick on vibrato table */ - v_time += p->v_rate; /* Update current time */ - while (v_time >= v_len) /* Check for end of sound */ - v_time -= v_len; /* loop back to beginning */ - while (v_time < FL(0.0)) /* Check for end of sound */ - v_time += v_len; /* loop back to beginning */ - - temp_time = v_time; + p->lastJet = *p->jetRatio; + /* freq = (2/3)*p->frequency as we're overblowing here */ + /* but 1/(2/3) is 1.5 so multiply for speed */ + /* Length - approx. filter delay */ + temp = FL(1.5)* CS_ESR / p->lastFreq - FL(2.0); + DLineL_setDelay(&p->boreDelay, temp); /* Length of bore tube */ + DLineL_setDelay(&p->jetDelay, temp * p->lastJet); /* jet delay shorter */ + } + else if (*p->jetRatio != p->lastJet) { /* Freq same but jet changed */ + p->lastJet = *p->jetRatio; + /* Length - approx. filter delay */ + temp = FL(1.5)* CS_ESR / p->lastFreq - FL(2.0); + DLineL_setDelay(&p->jetDelay, temp * p->lastJet); /* jet delay shorter */ + } + /* End SetFreq */ + + if (p->kloop>FL(0.0) && p->h.insdshead->relesing) p->kloop=FL(1.0); + if ((--p->kloop) == 0) { + p->adsr.releaseRate = p->adsr.value / (*p->dettack * CS_ESR); + p->adsr.target = FL(0.0); + p->adsr.rate = p->adsr.releaseRate; + p->adsr.state = RELEASE; + } + noisegain = *p->noiseGain; jetRefl = *p->jetRefl; endRefl = *p->endRefl; + if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + nsmps -= early; + memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); + } + for (n=offset;nmaxPress * ADSR_tick(&p->adsr); /* Breath Pressure */ + randPress = noisegain*Noise_tick(csound,&p->noise); /* Random Deviation */ + /* Tick on vibrato table */ + v_time += p->v_rate; /* Update current time */ + while (v_time >= v_len) /* Check for end of sound */ + v_time -= v_len; /* loop back to beginning */ + while (v_time < FL(0.0)) /* Check for end of sound */ + v_time += v_len; /* loop back to beginning */ + + temp_time = v_time; #ifdef phase_offset - if (p->v_phaseOffset != FL(0.0)) { - temp_time += p->v_phaseOffset;/* Add phase offset */ - while (temp_time >= v_len) /* Check for end of sound */ - temp_time -= v_len; /* loop back to beginning */ - while (temp_time < FL(0.0)) /* Check for end of sound */ - temp_time += v_len; /* loop back to beginning */ - } + if (p->v_phaseOffset != FL(0.0)) { + temp_time += p->v_phaseOffset;/* Add phase offset */ + while (temp_time >= v_len) /* Check for end of sound */ + temp_time -= v_len; /* loop back to beginning */ + while (temp_time < FL(0.0)) /* Check for end of sound */ + temp_time += v_len; /* loop back to beginning */ + } #endif - temp = (int32_t) temp_time; /* Integer part of time address */ + temp = (int32_t) temp_time; /* Integer part of time address */ /* fractional part of time address */ - alpha = temp_time - (MYFLT)temp; - v_lastOutput = v_data[temp]; /* Do linear interpolation */ - /* same as alpha*data[temp+1] + (1-alpha)data[temp] */ - v_lastOutput += (alpha * (v_data[temp+1] - v_lastOutput)); - /* End of vibrato tick */ - randPress += vibGain * v_lastOutput; /* + breath vibrato */ - randPress *= breathPress; /* All scaled by Breath Pressure */ - temf = OnePole_tick(&p->filter, DLineL_lastOut(&p->boreDelay)); - temf = DCBlock_tick(&p->dcBlock, temf); /* Block DC on reflection */ - pressDiff = breathPress + randPress /* Breath Pressure */ - - (jetRefl * temf); /* - reflected */ - pressDiff = DLineL_tick(&p->jetDelay, pressDiff); /* Jet Delay Line */ - pressDiff = JetTabl_lookup(pressDiff) /* Non-Lin Jet + reflected */ - + (endRefl * temf); - /* Bore Delay and "bell" filter */ - lastOutput = FL(0.3) * DLineL_tick(&p->boreDelay, pressDiff); - - lastOutput *= p->outputGain; - ar[n] = lastOutput*AMP_SCALE*FL(1.4); - } - - p->v_time = v_time; - return OK; + alpha = temp_time - (MYFLT)temp; + v_lastOutput = v_data[temp]; /* Do linear interpolation */ + /* same as alpha*data[temp+1] + (1-alpha)data[temp] */ + v_lastOutput += (alpha * (v_data[temp+1] - v_lastOutput)); + /* End of vibrato tick */ + randPress += vibGain * v_lastOutput; /* + breath vibrato */ + randPress *= breathPress; /* All scaled by Breath Pressure */ + temf = OnePole_tick(&p->filter, DLineL_lastOut(&p->boreDelay)); + temf = DCBlock_tick(&p->dcBlock, temf); /* Block DC on reflection */ + pressDiff = breathPress + randPress /* Breath Pressure */ + - (jetRefl * temf); /* - reflected */ + pressDiff = DLineL_tick(&p->jetDelay, pressDiff); /* Jet Delay Line */ + pressDiff = JetTabl_lookup(pressDiff) /* Non-Lin Jet + reflected */ + + (endRefl * temf); + /* Bore Delay and "bell" filter */ + lastOutput = FL(0.3) * DLineL_tick(&p->boreDelay, pressDiff); + + lastOutput *= p->outputGain; + ar[n] = lastOutput*AMP_SCALE*FL(1.4); + } + + p->v_time = v_time; + return OK; } /******************************************/ @@ -483,198 +483,198 @@ int32_t flute(CSOUND *csound, FLUTE *p) /* by Perry R. Cook, 1995-96 */ /******************************************/ - /* Perform Table Lookup */ +/* Perform Table Lookup */ MYFLT BowTabl_lookup(CSOUND *csound, BowTabl *b, MYFLT sample) { /* sample is differential */ - MYFLT lastOutput; /* string vs. bow velocity */ - MYFLT input; - input = sample /* + b->offSet*/ ; /* add bias to sample */ - input *= b->slope; /* scale it */ - lastOutput = FABS(input) + FL(0.75); /* below min delta, frict = 1 */ - lastOutput = csound->intpow(lastOutput,-4L); -/* if (lastOutput < FL(0.0) ) lastOutput = FL(0.0); */ /* minimum frict is 0.0 */ - if (lastOutput > FL(1.0)) lastOutput = FL(1.0); /* maximum friction is 1.0 */ - return lastOutput; + MYFLT lastOutput; /* string vs. bow velocity */ + MYFLT input; + input = sample /* + b->offSet*/ ; /* add bias to sample */ + input *= b->slope; /* scale it */ + lastOutput = FABS(input) + FL(0.75); /* below min delta, frict = 1 */ + lastOutput = csound->intpow(lastOutput,-4L); + /* if (lastOutput < FL(0.0) ) lastOutput = FL(0.0); */ /* minimum frict is 0.0 */ + if (lastOutput > FL(1.0)) lastOutput = FL(1.0); /* maximum friction is 1.0 */ + return lastOutput; } int32_t bowedset(CSOUND *csound, BOWED *p) { - int32 length; - FUNC *ftp; - MYFLT amp = (*p->amp)*AMP_RSCALE; /* Normalise */ - - if (LIKELY((ftp = csound->FTnp2Find(csound, p->ifn)) != NULL)) p->vibr = ftp; - else { /* Expect sine wave */ - return csound->InitError(csound, "%s", Str("No table for wgbow vibrato")); + int32 length; + FUNC *ftp; + MYFLT amp = (*p->amp)*AMP_RSCALE; /* Normalise */ + + if (LIKELY((ftp = csound->FTnp2Find(csound, p->ifn)) != NULL)) p->vibr = ftp; + else { /* Expect sine wave */ + return csound->InitError(csound, "%s", Str("No table for wgbow vibrato")); + } + if (*p->lowestFreq>=FL(0.0)) { /* If no init skip */ + if (*p->lowestFreq!=FL(0.0)) { + length = (int32_t) (CS_ESR / *p->lowestFreq + FL(1.0)); + p->limit = *p->lowestFreq; } - if (*p->lowestFreq>=FL(0.0)) { /* If no init skip */ - if (*p->lowestFreq!=FL(0.0)) { - length = (int32_t) (CS_ESR / *p->lowestFreq + FL(1.0)); - p->limit = *p->lowestFreq; - } - else if (*p->frequency!=FL(0.0)) { - length = (int32_t) (CS_ESR / *p->frequency + FL(1.0)); - p->limit = *p->frequency; - } - else { - csound->Warning(csound, "%s", Str("unknown lowest frequency for bowed string " - "-- assuming 50Hz\n")); - length = (int32_t) (CS_ESR / FL(50.0) + FL(1.0)); - p->limit = FL(50.0); - } - make_DLineL(csound, &p->neckDelay, length); - length = length >> 1; /* Unsure about this; seems correct in later code */ - make_DLineL(csound, &p->bridgeDelay, length); - - /* p->bowTabl.offSet = FL(0.0);*/ - /* offset is a bias, really not needed unless */ - /* friction is different in each direction */ - - /* p->bowTabl.slope contrls width of friction pulse, related to bowForce */ - p->bowTabl.slope = FL(3.0); - make_OnePole(&p->reflFilt); - make_BiQuad(&p->bodyFilt); - make_ADSR(&p->adsr, CS_ESR); - - DLineL_setDelay(&p->neckDelay, FL(100.0)); - DLineL_setDelay(&p->bridgeDelay, FL(29.0)); - - OnePole_setPole(&p->reflFilt, FL(0.6) - (FL(0.1) * RATE_NORM)); - OnePole_setGain(&p->reflFilt, FL(0.95)); - - BiQuad_setFreqAndReson(p->bodyFilt, FL(500.0), FL(0.85)); - BiQuad_setEqualGainZeroes(p->bodyFilt); - BiQuad_setGain(p->bodyFilt, FL(0.2)); - - ADSR_setAllTimes(csound, &p->adsr, FL(0.02), FL(0.005), FL(0.9), FL(0.01)); -/* ADSR_setAll(&p->adsr, 0.002f,0.01f,0.9f,0.01f); */ - - p->adsr.target = FL(1.0); - p->adsr.rate = p->adsr.attackRate; - p->adsr.state = ATTACK; - p->maxVelocity = FL(0.03) + (FL(0.2) * amp); - - p->lastpress = FL(0.0); /* Set unknown state */ - p->lastfreq = FL(0.0); - p->lastbeta = FL(0.0); /* Remember states */ - p->lastamp = amp; + else if (*p->frequency!=FL(0.0)) { + length = (int32_t) (CS_ESR / *p->frequency + FL(1.0)); + p->limit = *p->frequency; + } + else { + csound->Warning(csound, "%s", Str("unknown lowest frequency for bowed string " + "-- assuming 50Hz\n")); + length = (int32_t) (CS_ESR / FL(50.0) + FL(1.0)); + p->limit = FL(50.0); } - return OK; + make_DLineL(csound, &p->neckDelay, length); + length = length >> 1; /* Unsure about this; seems correct in later code */ + make_DLineL(csound, &p->bridgeDelay, length); + + /* p->bowTabl.offSet = FL(0.0);*/ + /* offset is a bias, really not needed unless */ + /* friction is different in each direction */ + + /* p->bowTabl.slope contrls width of friction pulse, related to bowForce */ + p->bowTabl.slope = FL(3.0); + make_OnePole(&p->reflFilt); + make_BiQuad(&p->bodyFilt); + make_ADSR(&p->adsr, CS_ESR); + + DLineL_setDelay(&p->neckDelay, FL(100.0)); + DLineL_setDelay(&p->bridgeDelay, FL(29.0)); + + OnePole_setPole(&p->reflFilt, FL(0.6) - (FL(0.1) * RATE_NORM)); + OnePole_setGain(&p->reflFilt, FL(0.95)); + + BiQuad_setFreqAndReson(p->bodyFilt, FL(500.0), FL(0.85)); + BiQuad_setEqualGainZeroes(p->bodyFilt); + BiQuad_setGain(p->bodyFilt, FL(0.2)); + + ADSR_setAllTimes(csound, &p->adsr, FL(0.02), FL(0.005), FL(0.9), FL(0.01)); + /* ADSR_setAll(&p->adsr, 0.002f,0.01f,0.9f,0.01f); */ + + p->adsr.target = FL(1.0); + p->adsr.rate = p->adsr.attackRate; + p->adsr.state = ATTACK; + p->maxVelocity = FL(0.03) + (FL(0.2) * amp); + + p->lastpress = FL(0.0); /* Set unknown state */ + p->lastfreq = FL(0.0); + p->lastbeta = FL(0.0); /* Remember states */ + p->lastamp = amp; + } + return OK; } int32_t bowed(CSOUND *csound, BOWED *p) { - MYFLT *ar = p->ar; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t n, nsmps = CS_KSMPS; - MYFLT amp = (*p->amp)*AMP_RSCALE; /* Normalise */ - MYFLT maxVel; - int32_t freq_changed = 0; - - if (amp != p->lastamp) { - p->maxVelocity = FL(0.03) + (FL(0.2) * amp); - p->lastamp = amp; - } - maxVel = p->maxVelocity; - if (p->lastpress != *p->bowPress) - p->bowTabl.slope = p->lastpress = *p->bowPress; - - /* Set Frequency if changed */ - if (p->lastfreq != *p->frequency) { - /* delay - approx. filter delay */ - if (p->limit<=*p->frequency) - p->lastfreq = *p->frequency; - else { - p->lastfreq = p->limit; - csound->Warning(csound, "%s", Str("frequency too low, set to minimum")); - } - p->baseDelay = CS_ESR / p->lastfreq - FL(4.0); - freq_changed = 1; - } - if (p->lastbeta != *p->betaRatio || - freq_changed) { /* Reset delays if changed */ - p->lastbeta = *p->betaRatio; - DLineL_setDelay(&p->bridgeDelay, /* bow to bridge length */ - p->baseDelay * p->lastbeta); - DLineL_setDelay(&p->neckDelay, /* bow to nut (finger) length */ - p->baseDelay *(FL(1.0) - p->lastbeta)); - } - p->v_rate = *p->vibFreq * p->vibr->flen * CS_ONEDSR; - if (p->kloop>0 && p->h.insdshead->relesing) p->kloop=1; - if ((--p->kloop) == 0) { - ADSR_setDecayRate(csound, &p->adsr, (FL(1.0) - p->adsr.value) * FL(0.005)); - p->adsr.target = FL(0.0); - p->adsr.rate = p->adsr.releaseRate; - p->adsr.state = RELEASE; + MYFLT *ar = p->ar; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t n, nsmps = CS_KSMPS; + MYFLT amp = (*p->amp)*AMP_RSCALE; /* Normalise */ + MYFLT maxVel; + int32_t freq_changed = 0; + + if (amp != p->lastamp) { + p->maxVelocity = FL(0.03) + (FL(0.2) * amp); + p->lastamp = amp; + } + maxVel = p->maxVelocity; + if (p->lastpress != *p->bowPress) + p->bowTabl.slope = p->lastpress = *p->bowPress; + + /* Set Frequency if changed */ + if (p->lastfreq != *p->frequency) { + /* delay - approx. filter delay */ + if (p->limit<=*p->frequency) + p->lastfreq = *p->frequency; + else { + p->lastfreq = p->limit; + csound->Warning(csound, "%s", Str("frequency too low, set to minimum")); } + p->baseDelay = CS_ESR / p->lastfreq - FL(4.0); + freq_changed = 1; + } + if (p->lastbeta != *p->betaRatio || + freq_changed) { /* Reset delays if changed */ + p->lastbeta = *p->betaRatio; + DLineL_setDelay(&p->bridgeDelay, /* bow to bridge length */ + p->baseDelay * p->lastbeta); + DLineL_setDelay(&p->neckDelay, /* bow to nut (finger) length */ + p->baseDelay *(FL(1.0) - p->lastbeta)); + } + p->v_rate = *p->vibFreq * p->vibr->flen * CS_ONEDSR; + if (p->kloop>0 && p->h.insdshead->relesing) p->kloop=1; + if ((--p->kloop) == 0) { + ADSR_setDecayRate(csound, &p->adsr, (FL(1.0) - p->adsr.value) * FL(0.005)); + p->adsr.target = FL(0.0); + p->adsr.rate = p->adsr.releaseRate; + p->adsr.state = RELEASE; + } + + if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + nsmps -= early; + memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); + } + for (n=offset;nadsr); + + /* Bridge Reflection */ + bridgeRefl = - OnePole_tick(&p->reflFilt, p->bridgeDelay.lastOutput); + nutRefl = - p->neckDelay.lastOutput; /* Nut Reflection */ + stringVel = bridgeRefl + nutRefl; /* Sum is String Velocity */ + velDiff = bowVelocity - stringVel; /* Differential Velocity */ + /* Non-Lin Bow Function */ + newVel = velDiff * BowTabl_lookup(csound, &p->bowTabl, velDiff); + DLineL_tick(&p->neckDelay, bridgeRefl + newVel); /* Do string */ + DLineL_tick(&p->bridgeDelay, nutRefl + newVel); /* propagations */ + + if (*p->vibAmt > FL(0.0)) { + int32 temp; + MYFLT temp_time, alpha; + /* Tick on vibrato table */ + p->v_time += p->v_rate; /* Update current time */ + while (p->v_time >= p->vibr->flen) /* Check for end of sound */ + p->v_time -= p->vibr->flen; /* loop back to beginning */ + while (p->v_time < FL(0.0)) /* Check for end of sound */ + p->v_time += p->vibr->flen; /* loop back to beginning */ - if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - nsmps -= early; - memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset;nadsr); - - /* Bridge Reflection */ - bridgeRefl = - OnePole_tick(&p->reflFilt, p->bridgeDelay.lastOutput); - nutRefl = - p->neckDelay.lastOutput; /* Nut Reflection */ - stringVel = bridgeRefl + nutRefl; /* Sum is String Velocity */ - velDiff = bowVelocity - stringVel; /* Differential Velocity */ - /* Non-Lin Bow Function */ - newVel = velDiff * BowTabl_lookup(csound, &p->bowTabl, velDiff); - DLineL_tick(&p->neckDelay, bridgeRefl + newVel); /* Do string */ - DLineL_tick(&p->bridgeDelay, nutRefl + newVel); /* propagations */ - - if (*p->vibAmt > FL(0.0)) { - int32 temp; - MYFLT temp_time, alpha; - /* Tick on vibrato table */ - p->v_time += p->v_rate; /* Update current time */ - while (p->v_time >= p->vibr->flen) /* Check for end of sound */ - p->v_time -= p->vibr->flen; /* loop back to beginning */ - while (p->v_time < FL(0.0)) /* Check for end of sound */ - p->v_time += p->vibr->flen; /* loop back to beginning */ - - temp_time = p->v_time; + temp_time = p->v_time; #ifdef phase_offset - if (p->v_phaseOffset != FL(0.0)) { - temp_time += p->v_phaseOffset; /* Add phase offset */ - while (temp_time >= p->vibr->flen) /* Check for end of sound */ - temp_time -= p->vibr->flen; /* loop back to beginning */ - while (temp_time < FL(0.0)) /* Check for end of sound */ - temp_time += p->vibr->flen; /* loop back to beginning */ - } -#endif - temp = (int32_t) temp_time; /* Integer part of time address */ - /* fractional part of time address */ - alpha = temp_time - (MYFLT)temp; - p->v_lastOutput = p->vibr->ftable[temp]; /* Do linear interpolation */ - /* same as alpha*data[temp+1] + (1-alpha)data[temp] */ - p->v_lastOutput = p->v_lastOutput + - (alpha * (p->vibr->ftable[temp+1] - p->v_lastOutput)); - /* End of vibrato tick */ - - DLineL_setDelay(&p->neckDelay, - (p->baseDelay * (FL(1.0) - p->lastbeta)) + - (p->baseDelay * *p->vibAmt * p->v_lastOutput)); + if (p->v_phaseOffset != FL(0.0)) { + temp_time += p->v_phaseOffset; /* Add phase offset */ + while (temp_time >= p->vibr->flen) /* Check for end of sound */ + temp_time -= p->vibr->flen; /* loop back to beginning */ + while (temp_time < FL(0.0)) /* Check for end of sound */ + temp_time += p->vibr->flen; /* loop back to beginning */ } - else - DLineL_setDelay(&p->neckDelay, - (p->baseDelay * (FL(1.0) - p->lastbeta))); - - lastOutput = BiQuad_tick(&p->bodyFilt, p->bridgeDelay.lastOutput); +#endif + temp = (int32_t) temp_time; /* Integer part of time address */ + /* fractional part of time address */ + alpha = temp_time - (MYFLT)temp; + p->v_lastOutput = p->vibr->ftable[temp]; /* Do linear interpolation */ + /* same as alpha*data[temp+1] + (1-alpha)data[temp] */ + p->v_lastOutput = p->v_lastOutput + + (alpha * (p->vibr->ftable[temp+1] - p->v_lastOutput)); + /* End of vibrato tick */ - ar[n] = lastOutput*AMP_SCALE * amp *FL(1.8); + DLineL_setDelay(&p->neckDelay, + (p->baseDelay * (FL(1.0) - p->lastbeta)) + + (p->baseDelay * *p->vibAmt * p->v_lastOutput)); } - return OK; + else + DLineL_setDelay(&p->neckDelay, + (p->baseDelay * (FL(1.0) - p->lastbeta))); + + lastOutput = BiQuad_tick(&p->bodyFilt, p->bridgeDelay.lastOutput); + + ar[n] = lastOutput*AMP_SCALE * amp *FL(1.8); + } + return OK; } /******************************************/ @@ -703,50 +703,50 @@ int32_t bowed(CSOUND *csound, BOWED *p) void make_DLineA(CSOUND *csound, DLineA *p, int32 max_length) { - p->length = max_length; - csound->AuxAlloc(csound, max_length * sizeof(MYFLT), &p->inputs); - p->lastIn = FL(0.0); - p->lastOutput = FL(0.0); - p->inPoint = 0; - p->outPoint = max_length >> 1; + p->length = max_length; + csound->AuxAlloc(csound, max_length * sizeof(MYFLT), &p->inputs); + p->lastIn = FL(0.0); + p->lastOutput = FL(0.0); + p->inPoint = 0; + p->outPoint = max_length >> 1; } int32_t DLineA_setDelay(CSOUND *csound, DLineA *p, MYFLT lag) { - MYFLT outputPointer; + MYFLT outputPointer; /* outPoint chases inpoint + 2 for interp and other */ - outputPointer = (MYFLT)p->inPoint - lag + FL(2.0); - - if (UNLIKELY(p->length<=0)) goto err1; - while (outputPointer<0) - outputPointer += p->length; /* modulo table length */ - p->outPoint = (int32_t) outputPointer; /* Integer part of delay */ - p->alpha = FL(1.0) + p->outPoint - outputPointer;/* fractional part of delay */ - if (p->alphaoutPoint++; /* cancellation. Keeps allpass */ - p->alpha += FL(1.0); /* delay in range of .1 to 1.1 */ - } - p->coeff = (FL(1.0)-p->alpha)/(FL(1.0)+p->alpha); /* coefficient for all pass*/ - return 0; + outputPointer = (MYFLT)p->inPoint - lag + FL(2.0); + + if (UNLIKELY(p->length<=0)) goto err1; + while (outputPointer<0) + outputPointer += p->length; /* modulo table length */ + p->outPoint = (int32_t) outputPointer; /* Integer part of delay */ + p->alpha = FL(1.0) + p->outPoint - outputPointer;/* fractional part of delay */ + if (p->alphaoutPoint++; /* cancellation. Keeps allpass */ + p->alpha += FL(1.0); /* delay in range of .1 to 1.1 */ + } + p->coeff = (FL(1.0)-p->alpha)/(FL(1.0)+p->alpha); /* coefficient for all pass*/ + return 0; err1: - csound->ErrorMsg(csound, "%s", Str("DlineA not initialised")); - return NOTOK; + csound->ErrorMsg(csound, "%s", Str("DlineA not initialised")); + return NOTOK; } MYFLT DLineA_tick(DLineA *p, MYFLT sample) /* Take sample, yield sample */ { - MYFLT temp; - ((MYFLT*)p->inputs.auxp)[p->inPoint++] = sample; /* Write input sample */ - if (p->inPoint >= p->length) /* Increment input pointer */ - p->inPoint -= p->length; /* modulo length */ - temp = ((MYFLT*)p->inputs.auxp)[p->outPoint++]; /* filter input */ - if (p->outPoint >= p->length) /* Increment output pointer*/ - p->outPoint -= p->length; /* modulo length */ - p->lastOutput = -p->coeff * p->lastOutput; /* delayed output */ - p->lastOutput += p->lastIn + (p->coeff * temp); /* input + delayed Input*/ - p->lastIn = temp; - return p->lastOutput; /* save output and return */ + MYFLT temp; + ((MYFLT*)p->inputs.auxp)[p->inPoint++] = sample; /* Write input sample */ + if (p->inPoint >= p->length) /* Increment input pointer */ + p->inPoint -= p->length; /* modulo length */ + temp = ((MYFLT*)p->inputs.auxp)[p->outPoint++]; /* filter input */ + if (p->outPoint >= p->length) /* Increment output pointer*/ + p->outPoint -= p->length; /* modulo length */ + p->lastOutput = -p->coeff * p->lastOutput; /* delayed output */ + p->lastOutput += p->lastIn + (p->coeff * temp); /* input + delayed Input*/ + p->lastIn = temp; + return p->lastOutput; /* save output and return */ } /* ====================================================================== */ @@ -763,12 +763,12 @@ MYFLT DLineA_tick(DLineA *p, MYFLT sample) /* Take sample, yield sample */ void LipFilt_setFreq(BRASS *p, LipFilt *pp, MYFLT frequency) { - MYFLT coeffs[2]; - coeffs[0] = FL(2.0) * FL(0.997) * - (MYFLT)cos(CS_TPIDSR * (double)frequency); /* damping should */ - coeffs[1] = -FL(0.997) * FL(0.997); /* change with lip */ - BiQuad_setPoleCoeffs(pp, coeffs); /* parameters, but */ - BiQuad_setGain(*pp, FL(0.03)); /* not yet. */ + MYFLT coeffs[2]; + coeffs[0] = FL(2.0) * FL(0.997) * + (MYFLT)cos(CS_TPIDSR * (double)frequency); /* damping should */ + coeffs[1] = -FL(0.997) * FL(0.997); /* change with lip */ + BiQuad_setPoleCoeffs(pp, coeffs); /* parameters, but */ + BiQuad_setGain(*pp, FL(0.03)); /* not yet. */ } /* NOTE: Here we should add lip tension */ @@ -776,177 +776,177 @@ void LipFilt_setFreq(BRASS *p, LipFilt *pp, MYFLT frequency) /* Maybe in TookKit97 */ MYFLT LipFilt_tick(LipFilt *p, MYFLT mouthSample, MYFLT boreSample) - /* Perform "Table Lookup" By Polynomial Calculation */ +/* Perform "Table Lookup" By Polynomial Calculation */ { - MYFLT temp; - MYFLT output; - temp = mouthSample - boreSample; /* Differential pressure */ - temp = BiQuad_tick(p, temp); /* Force -> position */ - temp = temp*temp; /* Simple position to area mapping */ - if (temp > FL(1.0)) temp = FL(1.0); /* Saturation at + 1.0 */ - output = temp * mouthSample; /* Assume mouth input = area */ - output += (FL(1.0)-temp) * boreSample; /* and Bore reflection is compliment */ - return output; + MYFLT temp; + MYFLT output; + temp = mouthSample - boreSample; /* Differential pressure */ + temp = BiQuad_tick(p, temp); /* Force -> position */ + temp = temp*temp; /* Simple position to area mapping */ + if (temp > FL(1.0)) temp = FL(1.0); /* Saturation at + 1.0 */ + output = temp * mouthSample; /* Assume mouth input = area */ + output += (FL(1.0)-temp) * boreSample; /* and Bore reflection is compliment */ + return output; } /* ====================================================================== */ int32_t brassset(CSOUND *csound, BRASS *p) { - FUNC *ftp; - MYFLT amp = (*p->amp)*AMP_RSCALE; /* Normalise */ - - if (LIKELY((ftp = csound->FTnp2Find(csound, p->ifn)) != NULL)) p->vibr = ftp; - else { /* Expect sine wave */ - return csound->InitError(csound, "%s", Str("No table for Brass")); + FUNC *ftp; + MYFLT amp = (*p->amp)*AMP_RSCALE; /* Normalise */ + + if (LIKELY((ftp = csound->FTnp2Find(csound, p->ifn)) != NULL)) p->vibr = ftp; + else { /* Expect sine wave */ + return csound->InitError(csound, "%s", Str("No table for Brass")); + } + p->frq = *p->frequency; /* Remember */ + if (*p->lowestFreq>=FL(0.0)) { + if (*p->lowestFreq!=FL(0.0)) { + p->length = (int32_t) (CS_ESR / *p->lowestFreq + FL(1.0)); + p->limit = *p->lowestFreq; } - p->frq = *p->frequency; /* Remember */ - if (*p->lowestFreq>=FL(0.0)) { - if (*p->lowestFreq!=FL(0.0)) { - p->length = (int32_t) (CS_ESR / *p->lowestFreq + FL(1.0)); - p->limit = *p->lowestFreq; - } - else if (p->frq!=FL(0.0)) { - p->length = (int32_t) (CS_ESR / p->frq + FL(1.0)); - p->limit = p->frq; - } - else { - csound->Warning(csound, "%s", Str("No base frequency for brass " - "-- assumed to be 50Hz\n")); - p->length = (int32_t) (CS_ESR / FL(50.0) + FL(1.0)); - p->limit = FL(50.0); - } - make_DLineA(csound, &p->delayLine, p->length); - make_LipFilt(&p->lipFilter); - make_DCBlock(&p->dcBlock); - make_ADSR(&p->adsr, CS_ESR); - ADSR_setAllTimes(csound, &p->adsr, FL(0.005), FL(0.001), FL(1.0), FL(0.010)); -/* ADSR_setAll(&p->adsr, 0.02f, 0.05f, FL(1.0), 0.001f); */ - - ADSR_setAttackRate(csound, &p->adsr, amp * FL(0.001)); - - p->maxPressure = amp; - ADSR_keyOn(&p->adsr); - - /* Set frequency */ - /* p->slideTarget = (CS_ESR / p->frq * FL(2.0)) + 3.0f; */ - /* fudge correction for filter delays */ - /* DLineA_setDelay(&p->delayLine, p->slideTarget);*/ - /* we'll play a harmonic */ - p->lipTarget = FL(0.0); -/* LipFilt_setFreq(csound, &p->lipFilter, p->frq); */ - /* End of set frequency */ - p->frq = FL(0.0); /* to say we do not know */ - p->lipT = FL(0.0); - /* LipFilt_setFreq(csound, &p->lipFilter, */ - /* p->lipTarget * (MYFLT)pow(4.0, - (2.0* p->lipT) -1.0)); */ - { - int32_t relestim = (int32_t)(CS_EKR * FL(0.1)); - /* 1/10th second decay extention */ - if (relestim > p->h.insdshead->xtratim) - p->h.insdshead->xtratim = relestim; - } - p->kloop = (int32_t) ((int32_t) (p->h.insdshead->offtim * CS_EKR) - - (int32_t) (CS_EKR * *p->dettack)); + else if (p->frq!=FL(0.0)) { + p->length = (int32_t) (CS_ESR / p->frq + FL(1.0)); + p->limit = p->frq; + } + else { + csound->Warning(csound, "%s", Str("No base frequency for brass " + "-- assumed to be 50Hz\n")); + p->length = (int32_t) (CS_ESR / FL(50.0) + FL(1.0)); + p->limit = FL(50.0); + } + make_DLineA(csound, &p->delayLine, p->length); + make_LipFilt(&p->lipFilter); + make_DCBlock(&p->dcBlock); + make_ADSR(&p->adsr, CS_ESR); + ADSR_setAllTimes(csound, &p->adsr, FL(0.005), FL(0.001), FL(1.0), FL(0.010)); + /* ADSR_setAll(&p->adsr, 0.02f, 0.05f, FL(1.0), 0.001f); */ + + ADSR_setAttackRate(csound, &p->adsr, amp * FL(0.001)); + + p->maxPressure = amp; + ADSR_keyOn(&p->adsr); + + /* Set frequency */ + /* p->slideTarget = (CS_ESR / p->frq * FL(2.0)) + 3.0f; */ + /* fudge correction for filter delays */ + /* DLineA_setDelay(&p->delayLine, p->slideTarget);*/ + /* we'll play a harmonic */ + p->lipTarget = FL(0.0); + /* LipFilt_setFreq(csound, &p->lipFilter, p->frq); */ + /* End of set frequency */ + p->frq = FL(0.0); /* to say we do not know */ + p->lipT = FL(0.0); + /* LipFilt_setFreq(csound, &p->lipFilter, */ + /* p->lipTarget * (MYFLT)pow(4.0, + (2.0* p->lipT) -1.0)); */ + { + int32_t relestim = (int32_t)(CS_EKR * FL(0.1)); + /* 1/10th second decay extention */ + if (relestim > p->h.insdshead->xtratim) + p->h.insdshead->xtratim = relestim; } - return OK; + p->kloop = (int32_t) ((int32_t) (p->h.insdshead->offtim * CS_EKR) + - (int32_t) (CS_EKR * *p->dettack)); + } + return OK; } int32_t brass(CSOUND *csound, BRASS *p) { - MYFLT *ar = p->ar; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t n, nsmps = CS_KSMPS; - MYFLT amp = (*p->amp)*AMP_RSCALE; /* Normalise */ - MYFLT maxPressure = p->maxPressure = amp; - int32_t v_len = (int32_t)p->vibr->flen; - MYFLT *v_data = p->vibr->ftable; - MYFLT vibGain = *p->vibAmt; - MYFLT vTime = p->v_time; - - p->v_rate = *p->vibFreq * v_len * CS_ONEDSR; - /* vibr->setFreq(6.137); */ - /* vibrGain = 0.05; */ /* breath periodic vibrato component */ - if (p->kloop>0 && p->h.insdshead->relesing) p->kloop=1; - if ((--p->kloop) == 0) { - ADSR_setReleaseRate(csound, &p->adsr, amp * FL(0.005)); - ADSR_keyOff(&p->adsr); - } - if (p->frq != *p->frequency) { /* Set frequency if changed */ - p->frq = *p->frequency; - if (p->limit > p->frq) { - p->frq =p->limit; - csound->Warning(csound, "%s", Str("frequency too low, set to minimum")); - } - p->slideTarget = (CS_ESR / p->frq * FL(2.0)) + FL(3.0); - /* fudge correction for filter delays */ - /* we'll play a harmonic */ - if (DLineA_setDelay(csound, &p->delayLine, p->slideTarget)) return OK; - p->lipTarget = p->frq; - p->lipT = FL(0.0); /* So other part is set */ - } /* End of set frequency */ - if (*p->liptension != p->lipT) { - p->lipT = *p->liptension; - LipFilt_setFreq(p, &p->lipFilter, - p->lipTarget * (MYFLT)pow(4.0,(2.0* p->lipT) -1.0)); + MYFLT *ar = p->ar; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t n, nsmps = CS_KSMPS; + MYFLT amp = (*p->amp)*AMP_RSCALE; /* Normalise */ + MYFLT maxPressure = p->maxPressure = amp; + int32_t v_len = (int32_t)p->vibr->flen; + MYFLT *v_data = p->vibr->ftable; + MYFLT vibGain = *p->vibAmt; + MYFLT vTime = p->v_time; + + p->v_rate = *p->vibFreq * v_len * CS_ONEDSR; + /* vibr->setFreq(6.137); */ + /* vibrGain = 0.05; */ /* breath periodic vibrato component */ + if (p->kloop>0 && p->h.insdshead->relesing) p->kloop=1; + if ((--p->kloop) == 0) { + ADSR_setReleaseRate(csound, &p->adsr, amp * FL(0.005)); + ADSR_keyOff(&p->adsr); + } + if (p->frq != *p->frequency) { /* Set frequency if changed */ + p->frq = *p->frequency; + if (p->limit > p->frq) { + p->frq =p->limit; + csound->Warning(csound, "%s", Str("frequency too low, set to minimum")); } - - if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - nsmps -= early; - memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); - } - for (n=offset;nadsr); - /* Tick on vibrato table */ - vTime += p->v_rate; /* Update current time */ - while (vTime >= v_len) /* Check for end of sound */ - vTime -= v_len; /* loop back to beginning */ - while (vTime < FL(0.0)) /* Check for end of sound */ - vTime += v_len; /* loop back to beginning */ - - temp_time = vTime; + p->slideTarget = (CS_ESR / p->frq * FL(2.0)) + FL(3.0); + /* fudge correction for filter delays */ + /* we'll play a harmonic */ + if (DLineA_setDelay(csound, &p->delayLine, p->slideTarget)) return OK; + p->lipTarget = p->frq; + p->lipT = FL(0.0); /* So other part is set */ + } /* End of set frequency */ + if (*p->liptension != p->lipT) { + p->lipT = *p->liptension; + LipFilt_setFreq(p, &p->lipFilter, + p->lipTarget * (MYFLT)pow(4.0,(2.0* p->lipT) -1.0)); + } + + if (UNLIKELY(offset)) memset(ar, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + nsmps -= early; + memset(&ar[nsmps], '\0', early*sizeof(MYFLT)); + } + for (n=offset;nadsr); + /* Tick on vibrato table */ + vTime += p->v_rate; /* Update current time */ + while (vTime >= v_len) /* Check for end of sound */ + vTime -= v_len; /* loop back to beginning */ + while (vTime < FL(0.0)) /* Check for end of sound */ + vTime += v_len; /* loop back to beginning */ + + temp_time = vTime; #ifdef phase_offset - if (p->v_phaseOffset != FL(0.0)) { - temp_time += p->v_phaseOffset; /* Add phase offset */ - while (temp_time >= v_len) /* Check for end of sound */ - temp_time -= v_len; /* loop back to beginning */ - while (temp_time < FL(0.0)) /* Check for end of sound */ - temp_time += v_len; /* loop back to beginning */ - } -#endif - - temp = (int32_t) temp_time; /* Integer part of time address */ - /* fractional part of time address */ - alpha = temp_time - (MYFLT)temp; - v_lastOutput = v_data[temp]; /* Do linear interpolation, same as */ - v_lastOutput += /*alpha*data[temp+1]+(1-alpha)data[temp] */ - (alpha * (v_data[temp+1] - v_lastOutput)); - /* End of vibrato tick */ - breathPressure += vibGain * v_lastOutput; - lastOutput = - DLineA_tick(&p->delayLine, /* bore delay */ - DCBlock_tick(&p->dcBlock, /* block DC */ - LipFilt_tick(&p->lipFilter, - FL(0.3) * breathPressure, /* mouth input */ - /* and bore reflection */ - FL(0.85) * p->delayLine.lastOutput))); - ans = lastOutput*AMP_SCALE*FL(3.5); - ar[n] = ans; + if (p->v_phaseOffset != FL(0.0)) { + temp_time += p->v_phaseOffset; /* Add phase offset */ + while (temp_time >= v_len) /* Check for end of sound */ + temp_time -= v_len; /* loop back to beginning */ + while (temp_time < FL(0.0)) /* Check for end of sound */ + temp_time += v_len; /* loop back to beginning */ } +#endif - p->v_time = vTime; - return OK; + temp = (int32_t) temp_time; /* Integer part of time address */ + /* fractional part of time address */ + alpha = temp_time - (MYFLT)temp; + v_lastOutput = v_data[temp]; /* Do linear interpolation, same as */ + v_lastOutput += /*alpha*data[temp+1]+(1-alpha)data[temp] */ + (alpha * (v_data[temp+1] - v_lastOutput)); + /* End of vibrato tick */ + breathPressure += vibGain * v_lastOutput; + lastOutput = + DLineA_tick(&p->delayLine, /* bore delay */ + DCBlock_tick(&p->dcBlock, /* block DC */ + LipFilt_tick(&p->lipFilter, + FL(0.3) * breathPressure, /* mouth input */ + /* and bore reflection */ + FL(0.85) * p->delayLine.lastOutput))); + ans = lastOutput*AMP_SCALE*FL(3.5); + ar[n] = ans; + } + + p->v_time = vTime; + return OK; } #define S sizeof @@ -991,34 +991,34 @@ int32_t agogobel(void*,void*); static OENTRY physmod_localops[] = { - { "wgclar", S(CLARIN),TR, 3, "a", "kkkiikkkjo",(SUBR)clarinset, (SUBR)clarin }, - { "wgflute", S(FLUTE), TR, 3, "a", "kkkiikkkjovv",(SUBR)fluteset, (SUBR)flute }, - { "wgbow", S(BOWED), TR, 3, "a", "kkkkkkjo", (SUBR)bowedset, (SUBR)bowed }, - { "wgbrass", S(BRASS), TR, 3, "a", "kkkikkjo", (SUBR)brassset, (SUBR)brass}, - { "mandol", S(MANDOL), TR, 3, "a", "kkkkkkio",(SUBR)mandolinset,(SUBR)mandolin}, - { "voice", S(VOICF), TR, 3, "a", "kkkkkkii",(SUBR)voicformset,(SUBR)voicform}, - { "fmbell", S(FM4OP), TR, 3, "a", "kkkkkkjjjjjo", - (SUBR)tubebellset,(SUBR)tubebell}, - { "fmrhode", S(FM4OP), TR, 3, "a", "kkkkkkiiiii",(SUBR)rhodeset,(SUBR)tubebell}, - { "fmwurlie", S(FM4OP),TR, 3, "a", "kkkkkkiiiii",(SUBR)wurleyset,(SUBR)wurley }, - { "fmmetal", S(FM4OP), TR, 3, "a", "kkkkkkiiiii", - (SUBR)heavymetset, (SUBR)heavymet}, - { "fmb3", S(FM4OP), TR, 3, "a", "kkkkkkjjjjj", (SUBR)b3set,(SUBR)hammondB3 }, - { "fmvoice", S(FM4OPV),TR, 3, "a", "kkkkkkjjjjj", - (SUBR)FMVoiceset,(SUBR)FMVoice}, - { "fmpercfl", S(FM4OP),TR, 3, "a", "kkkkkkjjjjj", - (SUBR)percfluteset, (SUBR)percflute}, - { "moog", S(MOOG1), TR, 3, "a", "kkkkkkiii", (SUBR)Moog1set, (SUBR)Moog1 }, - { "shaker", S(SHAKER), 0, 3, "a", "kkkkko", (SUBR)shakerset, (SUBR)shaker}, - { "wgbowedbar", S(BOWEDBAR), 0, 3, "a","kkkkkoooo", - (SUBR)bowedbarset,(SUBR) bowedbar }, - { "marimba", S(MARIMBA), TR, 3, "a", "kkiiikkiijj", - (SUBR)marimbaset, (SUBR)marimba}, - { "vibes", S(VIBRAPHN), TR, 3, "a", "kkiiikkii", - (SUBR)vibraphnset,(SUBR)vibraphn}, - { "gogobel",S(VIBRAPHN), TR, 3, "a", "kkiiikki", - (SUBR)agogobelset, (SUBR)agogobel}, -}; + { "wgclar", S(CLARIN),TR, "a", "kkkiikkkjo",(SUBR)clarinset, (SUBR)clarin }, + { "wgflute", S(FLUTE), TR, "a", "kkkiikkkjovv",(SUBR)fluteset, (SUBR)flute }, + { "wgbow", S(BOWED), TR, "a", "kkkkkkjo", (SUBR)bowedset, (SUBR)bowed }, + { "wgbrass", S(BRASS), TR, "a", "kkkikkjo", (SUBR)brassset, (SUBR)brass}, + { "mandol", S(MANDOL), TR, "a", "kkkkkkio",(SUBR)mandolinset,(SUBR)mandolin}, + { "voice", S(VOICF), TR, "a", "kkkkkkii",(SUBR)voicformset,(SUBR)voicform}, + { "fmbell", S(FM4OP), TR, "a", "kkkkkkjjjjjo", + (SUBR)tubebellset,(SUBR)tubebell}, + { "fmrhode", S(FM4OP), TR, "a", "kkkkkkiiiii",(SUBR)rhodeset,(SUBR)tubebell}, + { "fmwurlie", S(FM4OP),TR, "a", "kkkkkkiiiii",(SUBR)wurleyset,(SUBR)wurley }, + { "fmmetal", S(FM4OP), TR, "a", "kkkkkkiiiii", + (SUBR)heavymetset, (SUBR)heavymet}, + { "fmb3", S(FM4OP), TR, "a", "kkkkkkjjjjj", (SUBR)b3set,(SUBR)hammondB3 }, + { "fmvoice", S(FM4OPV),TR, "a", "kkkkkkjjjjj", + (SUBR)FMVoiceset,(SUBR)FMVoice}, + { "fmpercfl", S(FM4OP),TR, "a", "kkkkkkjjjjj", + (SUBR)percfluteset, (SUBR)percflute}, + { "moog", S(MOOG1), TR, "a", "kkkkkkiii", (SUBR)Moog1set, (SUBR)Moog1 }, + { "shaker", S(SHAKER), 0, "a", "kkkkko", (SUBR)shakerset, (SUBR)shaker}, + { "wgbowedbar", S(BOWEDBAR), 0, "a","kkkkkoooo", + (SUBR)bowedbarset,(SUBR) bowedbar }, + { "marimba", S(MARIMBA), TR, "a", "kkiiikkiijj", + (SUBR)marimbaset, (SUBR)marimba}, + { "vibes", S(VIBRAPHN), TR, "a", "kkiiikkii", + (SUBR)vibraphnset,(SUBR)vibraphn}, + { "gogobel",S(VIBRAPHN), TR, "a", "kkiiikki", + (SUBR)agogobelset, (SUBR)agogobel}, + }; diff --git a/Opcodes/pinker.c b/Opcodes/pinker.c index 7d704be3d75..c66169107ea 100644 --- a/Opcodes/pinker.c +++ b/Opcodes/pinker.c @@ -177,7 +177,7 @@ static int pink_init(CSOUND *csound, PINKER *p) // constructor static OENTRY pinker_localops[] = { - { "pinker", sizeof(PINKER),0,3, "a", "", (SUBR)pink_init, (SUBR)pink_perf } + { "pinker", sizeof(PINKER),0, "a", "", (SUBR)pink_init, (SUBR)pink_perf } }; LINKAGE_BUILTIN(pinker_localops) diff --git a/Opcodes/pitchtrack.c b/Opcodes/pitchtrack.c index 2140e2f7cf0..f9fe5bb237d 100644 --- a/Opcodes/pitchtrack.c +++ b/Opcodes/pitchtrack.c @@ -758,11 +758,11 @@ int32_t plltrack_perf(CSOUND *csound, PLLTRACK *p) static OENTRY pitchtrack_localops[] = { - {"ptrack", S(PITCHTRACK), 0, 3, "kk", "aio", + {"ptrack", S(PITCHTRACK), 0, "kk", "aio", (SUBR)pitchtrackinit, (SUBR)pitchtrackprocess}, - {"pitchac", S(PITCHTRACK), 0, 3, "k", "akki", + {"pitchac", S(PITCHTRACK), 0, "k", "akki", (SUBR)pitchafset, (SUBR)pitchafproc}, - {"plltrack", S(PLLTRACK), 0, 3, "aa", "akOOOOO", + {"plltrack", S(PLLTRACK), 0, "aa", "akOOOOO", (SUBR)plltrack_set, (SUBR)plltrack_perf} }; diff --git a/Opcodes/platerev.c b/Opcodes/platerev.c index 886d079d427..20231bfe4d4 100644 --- a/Opcodes/platerev.c +++ b/Opcodes/platerev.c @@ -251,7 +251,7 @@ static int32_t platerev(CSOUND *csound, PLATE *p) static OENTRY platerev_localops[] = { - { "platerev", sizeof(PLATE), 0, 3, "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", + { "platerev", sizeof(PLATE), 0, "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", "iikiiiiy", (SUBR) platerev_init, (SUBR) platerev }, diff --git a/Opcodes/pluck.c b/Opcodes/pluck.c index 8c46b9fde7f..0a91318c2c1 100644 --- a/Opcodes/pluck.c +++ b/Opcodes/pluck.c @@ -357,7 +357,7 @@ static void waveguideSetTuning(CSOUND *csound, waveguide* wg, MYFLT df) static OENTRY localops[] = { - { "wgpluck",S(WGPLUCK),0, 3,"a","iikiiia", + { "wgpluck",S(WGPLUCK),0, "a","iikiiia", (SUBR)pluckPluck,(SUBR)pluckGetSamps} }; diff --git a/Opcodes/psynth.c b/Opcodes/psynth.c index c02c9288d8d..495fc2e0995 100644 --- a/Opcodes/psynth.c +++ b/Opcodes/psynth.c @@ -1243,40 +1243,40 @@ static int32_t binit_process(CSOUND *csound, _PSBIN *p) static OENTRY localops[] = { - {"tradsyn", sizeof(_PSYN),0, 3, "a", "fkkkij", (SUBR) psynth_init, + {"tradsyn", sizeof(_PSYN),0, "a", "fkkkij", (SUBR) psynth_init, (SUBR) psynth_process} , - {"sinsyn", sizeof(_PSYN2), TR, 3, "a", "fkkij", (SUBR) psynth2_init, + {"sinsyn", sizeof(_PSYN2), TR, "a", "fkkij", (SUBR) psynth2_init, (SUBR) psynth2_process} , - {"resyn", sizeof(_PSYN), TR, 3, "a", "fkkkij", (SUBR) psynth_init, + {"resyn", sizeof(_PSYN), TR, "a", "fkkkij", (SUBR) psynth_init, (SUBR) psynth3_process} , - {"trscale", sizeof(_PTRANS),0, 3, "f", "fz", (SUBR) trans_init, + {"trscale", sizeof(_PTRANS),0, "f", "fz", (SUBR) trans_init, (SUBR) trscale_process} , - {"trshift", sizeof(_PTRANS),0, 3, "f", "fz", (SUBR) trans_init, + {"trshift", sizeof(_PTRANS),0, "f", "fz", (SUBR) trans_init, (SUBR) trshift_process} , - {"trsplit", sizeof(_PSPLIT),0, 3, "ff", "fz", (SUBR) trsplit_init, + {"trsplit", sizeof(_PSPLIT),0, "ff", "fz", (SUBR) trsplit_init, (SUBR) trsplit_process} , - {"trmix", sizeof(_PSMIX),0, 3, "f", "ff", (SUBR) trmix_init, + {"trmix", sizeof(_PSMIX),0, "f", "ff", (SUBR) trmix_init, (SUBR) trmix_process} , - {"trlowest", sizeof(_PLOW),0, 3, "fkk", "fk", (SUBR) trlowest_init, + {"trlowest", sizeof(_PLOW),0, "fkk", "fk", (SUBR) trlowest_init, (SUBR) trlowest_process} , - {"trhighest", sizeof(_PLOW),0, 3, "fkk", "fk", (SUBR) trlowest_init, + {"trhighest", sizeof(_PLOW),0, "fkk", "fk", (SUBR) trlowest_init, (SUBR) trhighest_process} , - {"trfilter", sizeof(_PSFIL),0, 3, "f", "fki", (SUBR) trfil_init, + {"trfilter", sizeof(_PSFIL),0, "f", "fki", (SUBR) trfil_init, (SUBR) trfil_process} , - {"trcross", sizeof(_PSCROSS),0, 3, "f", "ffkz", (SUBR) trcross_init, + {"trcross", sizeof(_PSCROSS),0, "f", "ffkz", (SUBR) trcross_init, (SUBR) trcross_process} , - {"binit", sizeof(_PSBIN),0, 3, "f", "fi", (SUBR) binit_init, + {"binit", sizeof(_PSBIN),0, "f", "fi", (SUBR) binit_init, (SUBR) binit_process} }; diff --git a/Opcodes/pvlock.c b/Opcodes/pvlock.c index 0313516f5ae..9faa5cf8121 100644 --- a/Opcodes/pvlock.c +++ b/Opcodes/pvlock.c @@ -1673,21 +1673,21 @@ int32_t am_fm(CSOUND *csound, AMFM *p) { static OENTRY pvlock_localops[] = { - {"mincer", sizeof(DATASPACEM), 0, 3, "a", "akkkkoo", + {"mincer", sizeof(DATASPACEM), 0, "a", "akkkkoo", (SUBR)sinit1m,(SUBR)sprocess1m }, - {"mincer", sizeof(DATASPACE), 0, 3, "mm", "akkkkoo", + {"mincer", sizeof(DATASPACE), 0, "mm", "akkkkoo", (SUBR)sinit1,(SUBR)sprocess1 }, - {"temposcal", sizeof(DATASPACEM), 0, 3, "a", "kkkkkooPOP", + {"temposcal", sizeof(DATASPACEM), 0, "a", "kkkkkooPOP", (SUBR)sinit2m,(SUBR)sprocess2m }, - {"temposcal", sizeof(DATASPACE), 0, 3, "mm", "kkkkkooPOP", + {"temposcal", sizeof(DATASPACE), 0, "mm", "kkkkkooPOP", (SUBR)sinit2,(SUBR)sprocess2 }, - {"filescal", sizeof(DATASPACE), 0, 3, "mm", "kkkSkooPOP", + {"filescal", sizeof(DATASPACE), 0, "mm", "kkkSkooPOP", (SUBR)sinit3,(SUBR)sprocess3 }, - {"hilbert2", sizeof(HILB), 0, 3, "aa", "aii", (SUBR) hilbert_init, + {"hilbert2", sizeof(HILB), 0, "aa", "aii", (SUBR) hilbert_init, (SUBR) hilbert_proc}, - {"fmanal", sizeof(AMFM), 0, 3, "aa", "aa", (SUBR) am_fm_init, + {"fmanal", sizeof(AMFM), 0, "aa", "aa", (SUBR) am_fm_init, (SUBR) am_fm}, - {"pvslock", sizeof(PVSLOCK), 0, 3, "f", "fk", (SUBR) pvslockset, + {"pvslock", sizeof(PVSLOCK), 0, "f", "fk", (SUBR) pvslockset, (SUBR) pvslockproc}, }; diff --git a/Opcodes/pvoc.c b/Opcodes/pvoc.c index 6f4610f62a3..0657741c2a4 100644 --- a/Opcodes/pvoc.c +++ b/Opcodes/pvoc.c @@ -45,23 +45,23 @@ int32_t pvinterpset_S(CSOUND *, void *); static OENTRY pvoc_localops[] = { - { "pvoc", S(PVOC), 0, 3, "a", "kkSoooo", pvset_S, pvoc }, - { "pvoc.i", S(PVOC), 0, 3, "a", "kkioooo", pvset, pvoc }, -{ "tableseg", S(TABLESEG), TR, 3, "", "iim", tblesegset, ktableseg, NULL }, -{ "ktableseg", S(TABLESEG), _QQ|TR, 3, "", "iim", tblesegset, ktableseg, NULL }, -{ "tablexseg", S(TABLESEG), TW, 3, "", "iin", tblesegset, ktablexseg, NULL }, - { "vpvoc", S(VPVOC), TR, 3, "a", "kkSoo", vpvset_S, vpvoc }, - { "vpvoc.i", S(VPVOC), TR, 3, "a", "kkioo", vpvset, vpvoc }, -{ "pvread", S(PVREAD), 0, 3, "kk", "kSi", pvreadset_S, pvread, NULL }, -{ "pvread.i", S(PVREAD), 0, 3, "kk", "kii", pvreadset, pvread, NULL }, - { "pvcross", S(PVCROSS), 0, 3, "a", "kkSkko", pvcrossset_S, pvcross }, -{ "pvbufread", S(PVBUFREAD),0, 3, "", "kS", pvbufreadset_S, pvbufread, NULL}, - { "pvinterp", S(PVINTERP), 0, 3, "a", "kkSkkkkkk", pvinterpset_S, pvinterp}, - { "pvcross.i", S(PVCROSS), 0, 3, "a", "kkikko", pvcrossset, pvcross }, -{ "pvbufread.i", S(PVBUFREAD),0, 3, "", "ki", pvbufreadset, pvbufread, NULL}, - { "pvinterp.i", S(PVINTERP), 0, 3, "a", "kkikkkkkk", pvinterpset, pvinterp}, - { "pvadd", S(PVADD), 0, 3, "a", "kkSiiopooo", pvaddset_S, pvadd }, - { "pvadd.i", S(PVADD), 0, 3, "a", "kkiiiopooo", pvaddset, pvadd } + { "pvoc", S(PVOC), 0, "a", "kkSoooo", pvset_S, pvoc }, + { "pvoc.i", S(PVOC), 0, "a", "kkioooo", pvset, pvoc }, +{ "tableseg", S(TABLESEG), TR, "", "iim", tblesegset, ktableseg, NULL }, +{ "ktableseg", S(TABLESEG), _QQ|TR, "", "iim", tblesegset, ktableseg, NULL }, +{ "tablexseg", S(TABLESEG), TW, "", "iin", tblesegset, ktablexseg, NULL }, + { "vpvoc", S(VPVOC), TR, "a", "kkSoo", vpvset_S, vpvoc }, + { "vpvoc.i", S(VPVOC), TR, "a", "kkioo", vpvset, vpvoc }, +{ "pvread", S(PVREAD), 0, "kk", "kSi", pvreadset_S, pvread, NULL }, +{ "pvread.i", S(PVREAD), 0, "kk", "kii", pvreadset, pvread, NULL }, + { "pvcross", S(PVCROSS), 0, "a", "kkSkko", pvcrossset_S, pvcross }, +{ "pvbufread", S(PVBUFREAD),0, "", "kS", pvbufreadset_S, pvbufread, NULL}, + { "pvinterp", S(PVINTERP), 0, "a", "kkSkkkkkk", pvinterpset_S, pvinterp}, + { "pvcross.i", S(PVCROSS), 0, "a", "kkikko", pvcrossset, pvcross }, +{ "pvbufread.i", S(PVBUFREAD),0, "", "ki", pvbufreadset, pvbufread, NULL}, + { "pvinterp.i", S(PVINTERP), 0, "a", "kkikkkkkk", pvinterpset, pvinterp}, + { "pvadd", S(PVADD), 0, "a", "kkSiiopooo", pvaddset_S, pvadd }, + { "pvadd.i", S(PVADD), 0, "a", "kkiiiopooo", pvaddset, pvadd } }; PVOC_GLOBALS *PVOC_AllocGlobals(CSOUND *csound) diff --git a/Opcodes/pvsband.c b/Opcodes/pvsband.c index 933311f1174..82e14059eeb 100644 --- a/Opcodes/pvsband.c +++ b/Opcodes/pvsband.c @@ -286,9 +286,9 @@ static int32_t pvsbrej(CSOUND *csound, PVSBAND *p) } static OENTRY localops[] = { - {"pvsbandp", sizeof(PVSBAND), 0, 3, "f", "fxxxxO", + {"pvsbandp", sizeof(PVSBAND), 0, "f", "fxxxxO", (SUBR) pvsbandinit, (SUBR) pvsband, (SUBR) NULL }, - {"pvsbandr", sizeof(PVSBAND), 0, 3, "f", "fxxxxO", + {"pvsbandr", sizeof(PVSBAND), 0, "f", "fxxxxO", (SUBR) pvsbandinit, (SUBR) pvsbrej, (SUBR) NULL } }; diff --git a/Opcodes/pvsbasic.c b/Opcodes/pvsbasic.c index 0733df3f45e..63b141841ee 100644 --- a/Opcodes/pvsbasic.c +++ b/Opcodes/pvsbasic.c @@ -263,7 +263,6 @@ static int32_t pvsfwriteset_(CSOUND *csound, PVSFWRITE *p, int32_t stringname) csound->AuxAlloc(csound, (N + 2) * sizeof(float), &p->frame); p->async = 0; } - csound->RegisterDeinitCallback(csound, p, pvsfwrite_destroy); p->lastframe = 0; return OK; } @@ -2848,67 +2847,67 @@ int32_t tab2pvssplit(CSOUND *csound, TAB2PVSSPLIT_T *p) static OENTRY localops[] = { - {"pvsfwrite", sizeof(PVSFWRITE),0, 3, "", "fS", (SUBR) pvsfwriteset_S, - (SUBR) pvsfwrite}, - {"pvsfwrite.i", sizeof(PVSFWRITE),0, 3, "", "fi", (SUBR) pvsfwriteset, - (SUBR) pvsfwrite}, - {"pvsfilter", sizeof(PVSFILTER),0, 3, "f", "ffxp", (SUBR) pvsfilterset, + {"pvsfwrite", sizeof(PVSFWRITE),0, "", "fS", (SUBR) pvsfwriteset_S, + (SUBR) pvsfwrite, (SUBR) pvsfwrite_destroy}, + {"pvsfwrite.i", sizeof(PVSFWRITE),0, "", "fi", (SUBR) pvsfwriteset, + (SUBR) pvsfwrite, (SUBR) pvsfwrite_destroy}, + {"pvsfilter", sizeof(PVSFILTER),0, "f", "ffxp", (SUBR) pvsfilterset, (SUBR) pvsfilter}, - {"pvscale", sizeof(PVSSCALE),0, 3, "f", "fxOPO", (SUBR) pvsscaleset, + {"pvscale", sizeof(PVSSCALE),0, "f", "fxOPO", (SUBR) pvsscaleset, (SUBR) pvsscale}, - {"pvshift", sizeof(PVSSHIFT),0, 3, "f", "fxkOPO", (SUBR) pvsshiftset, + {"pvshift", sizeof(PVSSHIFT),0, "f", "fxkOPO", (SUBR) pvsshiftset, (SUBR) pvsshift}, - {"pvsfilter", sizeof(PVSFILTER),0, 3, "f", "fffp", (SUBR) pvsfilterset, + {"pvsfilter", sizeof(PVSFILTER),0, "f", "fffp", (SUBR) pvsfilterset, (SUBR) pvsfilter}, - {"pvscale", sizeof(PVSSCALE),0, 3, "f", "fkOPO", + {"pvscale", sizeof(PVSSCALE),0, "f", "fkOPO", (SUBR) pvsscaleset, (SUBR) pvsscale}, - {"pvshift", sizeof(PVSSHIFT),0, 3, "f", "fkkOPO", (SUBR) pvsshiftset, + {"pvshift", sizeof(PVSSHIFT),0, "f", "fkkOPO", (SUBR) pvsshiftset, (SUBR) pvsshift}, - {"pvsmix", sizeof(PVSMIX),0, 3, "f", "ff", (SUBR) pvsmixset, (SUBR)pvsmix, NULL}, - {"pvsfilter", sizeof(PVSFILTER),0, 3, "f", "ffxp", (SUBR) pvsfilterset, + {"pvsmix", sizeof(PVSMIX),0, "f", "ff", (SUBR) pvsmixset, (SUBR)pvsmix, NULL}, + {"pvsfilter", sizeof(PVSFILTER),0, "f", "ffxp", (SUBR) pvsfilterset, (SUBR) pvsfilter}, - {"pvsblur", sizeof(PVSBLUR),0, 3, "f", "fki", (SUBR) pvsblurset, (SUBR) pvsblur, + {"pvsblur", sizeof(PVSBLUR),0, "f", "fki", (SUBR) pvsblurset, (SUBR) pvsblur, NULL}, - {"pvstencil", sizeof(PVSTENCIL), TR, 3, "f", "fkki", (SUBR) pvstencilset, + {"pvstencil", sizeof(PVSTENCIL), TR, "f", "fkki", (SUBR) pvstencilset, (SUBR) pvstencil}, - {"pvsinit", sizeof(PVSINI),0, 1, "f", "ioopo", (SUBR) pvsinit, NULL, NULL}, - {"pvsbin", sizeof(PVSBIN),0, 3, "ss", "fk", (SUBR) pvsbinset, + {"pvsinit", sizeof(PVSINI),0, "f", "ioopo", (SUBR) pvsinit, NULL, NULL}, + {"pvsbin", sizeof(PVSBIN),0, "ss", "fk", (SUBR) pvsbinset, (SUBR) pvsbinprocess, (SUBR) pvsbinprocessa}, - {"pvsfreeze", sizeof(PVSFREEZE),0, 3, "f", "fkk", (SUBR) pvsfreezeset, + {"pvsfreeze", sizeof(PVSFREEZE),0, "f", "fkk", (SUBR) pvsfreezeset, (SUBR) pvsfreezeprocess, NULL}, - {"pvsmooth", sizeof(PVSFREEZE),0, 3, "f", "fxx", (SUBR) pvsmoothset, + {"pvsmooth", sizeof(PVSFREEZE),0, "f", "fxx", (SUBR) pvsmoothset, (SUBR) pvsmoothprocess, NULL}, - {"pvsosc", sizeof(PVSOSC),0, 3, "f", "kkkioopo", (SUBR) pvsoscset, + {"pvsosc", sizeof(PVSOSC),0, "f", "kkkioopo", (SUBR) pvsoscset, (SUBR) pvsoscprocess, NULL}, - {"pvsdiskin", sizeof(pvsdiskin),0, 3, "f", "SkkopP",(SUBR) pvsdiskinset_S, + {"pvsdiskin", sizeof(pvsdiskin),0, "f", "SkkopP",(SUBR) pvsdiskinset_S, (SUBR) pvsdiskinproc, NULL}, - {"pvsdiskin.i", sizeof(pvsdiskin),0, 3, "f", "ikkopP",(SUBR) pvsdiskinset, + {"pvsdiskin.i", sizeof(pvsdiskin),0, "f", "ikkopP",(SUBR) pvsdiskinset, (SUBR) pvsdiskinproc, NULL}, - {"pvstanal", sizeof(PVST1),0, 3, "f", "kkkkPPoooP", + {"pvstanal", sizeof(PVST1),0, "f", "kkkkPPoooP", (SUBR) pvstanalset1, (SUBR) pvstanal1, NULL}, - {"pvstanal", sizeof(PVST),0, 3, "FFFFFFFFFFFFFFFF", "kkkkPPoooP", + {"pvstanal", sizeof(PVST),0, "FFFFFFFFFFFFFFFF", "kkkkPPoooP", (SUBR) pvstanalset, (SUBR) pvstanal, NULL}, - {"pvswarp", sizeof(PVSWARP),0, 3, "f", "fkkOPPO", + {"pvswarp", sizeof(PVSWARP),0, "f", "fkkOPPO", (SUBR) pvswarpset, (SUBR) pvswarp}, - {"pvsenvftw", sizeof(PVSENVW),0, 3, "k", "fkPPO", + {"pvsenvftw", sizeof(PVSENVW),0, "k", "fkPPO", (SUBR) pvsenvwset, (SUBR) pvsenvw}, - {"pvsgain", sizeof(PVSGAIN), 0,3, "f", "fk", + {"pvsgain", sizeof(PVSGAIN), 0, "f", "fk", (SUBR) pvsgainset, (SUBR) pvsgain, NULL}, - {"pvs2tab", sizeof(PVS2TAB_T), 0,3, "k", "k[]f", + {"pvs2tab", sizeof(PVS2TAB_T), 0, "k", "k[]f", (SUBR) pvs2tab_init, (SUBR) pvs2tab, NULL}, - {"pvs2tab", sizeof(PVS2TABSPLIT_T), 0,3, "k", "k[]k[]f", + {"pvs2tab", sizeof(PVS2TABSPLIT_T), 0, "k", "k[]k[]f", (SUBR) pvs2tabsplit_init, (SUBR) pvs2tabsplit, NULL}, - {"tab2pvs", sizeof(TAB2PVS_T), 0, 3, "f", "k[]oop", (SUBR) tab2pvs_init, + {"tab2pvs", sizeof(TAB2PVS_T), 0, "f", "k[]oop", (SUBR) tab2pvs_init, (SUBR) tab2pvs, NULL}, - {"tab2pvs", sizeof(TAB2PVSSPLIT_T), 0, 3, "f", "k[]k[]oop", + {"tab2pvs", sizeof(TAB2PVSSPLIT_T), 0, "f", "k[]k[]oop", (SUBR) tab2pvssplit_init, (SUBR) tab2pvssplit, NULL}, - {"pvs2array", sizeof(PVS2TAB_T), 0,3, "k", "k[]f", + {"pvs2array", sizeof(PVS2TAB_T), 0, "k", "k[]f", (SUBR) pvs2tab_init, (SUBR) pvs2tab, NULL}, - {"pvs2array", sizeof(PVS2TABSPLIT_T), 0,3, "k", "k[]k[]f", + {"pvs2array", sizeof(PVS2TABSPLIT_T), 0, "k", "k[]k[]f", (SUBR) pvs2tabsplit_init, (SUBR) pvs2tabsplit, NULL}, - {"pvsfromarray", sizeof(TAB2PVS_T), 0, 3, "f", "k[]oop", + {"pvsfromarray", sizeof(TAB2PVS_T), 0, "f", "k[]oop", (SUBR) tab2pvs_init, (SUBR) tab2pvs, NULL}, - {"pvsfromarray", sizeof(TAB2PVSSPLIT_T), 0, 3, "f", "k[]k[]oop", + {"pvsfromarray", sizeof(TAB2PVSSPLIT_T), 0, "f", "k[]k[]oop", (SUBR) tab2pvssplit_init, (SUBR) tab2pvssplit, NULL} }; diff --git a/Opcodes/pvsbuffer.c b/Opcodes/pvsbuffer.c index e716d29daa6..344157cf268 100644 --- a/Opcodes/pvsbuffer.c +++ b/Opcodes/pvsbuffer.c @@ -328,11 +328,11 @@ static int32_t pvsbufreadproc2(CSOUND *csound, PVSBUFFERREAD *p) /* static */ static OENTRY pvsbuffer_localops[] = { - {"pvsbuffer", S(PVSBUFFER), 0, 3, "ik", "fi", + {"pvsbuffer", S(PVSBUFFER), 0, "ik", "fi", (SUBR)pvsbufferset, (SUBR)pvsbufferproc, NULL}, - {"pvsbufread", S(PVSBUFFERREAD), 0, 3, "f", "kkOOo", + {"pvsbufread", S(PVSBUFFERREAD), 0, "f", "kkOOo", (SUBR)pvsbufreadset, (SUBR)pvsbufreadproc, NULL}, - {"pvsbufread2", S(PVSBUFFERREAD), 0, 3, "f", "kkkk", + {"pvsbufread2", S(PVSBUFFERREAD), 0, "f", "kkkk", (SUBR)pvsbufreadset, (SUBR)pvsbufreadproc2, NULL} }; diff --git a/Opcodes/pvscent.c b/Opcodes/pvscent.c index 8f11834dba6..b2c98ef6a0b 100644 --- a/Opcodes/pvscent.c +++ b/Opcodes/pvscent.c @@ -449,14 +449,14 @@ int32_t pvspitch_process(CSOUND *csound, PVSPITCH *p) } static OENTRY localops[] = { - { "pvscent", sizeof(PVSCENT), 0, 3, "k", "f", + { "pvscent", sizeof(PVSCENT), 0, "k", "f", (SUBR)pvscentset, (SUBR)pvscent }, - { "pvsbandwidth", sizeof(PVSCENT), 0, 3, "k", "f", + { "pvsbandwidth", sizeof(PVSCENT), 0, "k", "f", (SUBR)pvscentset, (SUBR)pvsbandw }, - { "pvscent", sizeof(PVSCENT), 0, 3, "a", "f", + { "pvscent", sizeof(PVSCENT), 0, "a", "f", (SUBR)pvscentset, (SUBR)pvsscent }, - { "centroid", sizeof(CENT), 0, 3, "k", "aki", (SUBR)cent_i, (SUBR)cent_k, NULL}, - { "pvspitch", sizeof(PVSPITCH), 0, 3, "kk", "fk", + { "centroid", sizeof(CENT), 0, "k", "aki", (SUBR)cent_i, (SUBR)cent_k, NULL}, + { "pvspitch", sizeof(PVSPITCH), 0, "kk", "fk", (SUBR)pvspitch_init, (SUBR)pvspitch_process, NULL} }; diff --git a/Opcodes/pvsdemix.c b/Opcodes/pvsdemix.c index 7a17238123a..351c99d657b 100644 --- a/Opcodes/pvsdemix.c +++ b/Opcodes/pvsdemix.c @@ -189,7 +189,7 @@ static int32_t pvsdemix_process(CSOUND *csound, PVSDEMIX *p) static OENTRY localops[] = { - {"pvsdemix", sizeof(PVSDEMIX), 0, 3, "f", "ffkki", + {"pvsdemix", sizeof(PVSDEMIX), 0, "f", "ffkki", (SUBR) pvsdemix_init, (SUBR) pvsdemix_process, (SUBR) NULL } }; diff --git a/Opcodes/pvsgendy.c b/Opcodes/pvsgendy.c index aa7f037988d..81cff3a62eb 100644 --- a/Opcodes/pvsgendy.c +++ b/Opcodes/pvsgendy.c @@ -114,7 +114,7 @@ static int32_t pvsgendy(CSOUND *csound, PVSGENDY *p) } static OENTRY pvsgendy_localops[] = { - { "pvsgendy", sizeof(PVSGENDY), 0, 3, "f", "fkk", + { "pvsgendy", sizeof(PVSGENDY), 0, "f", "fkk", (SUBR) pvsgendyinit, (SUBR) pvsgendy, (SUBR) NULL } }; diff --git a/Opcodes/pvsops.cpp b/Opcodes/pvsops.cpp index 70d8c2bcf87..6f10b1099fd 100644 --- a/Opcodes/pvsops.cpp +++ b/Opcodes/pvsops.cpp @@ -395,75 +395,6 @@ struct Gtadsr : public csnd::Plugin<1,6> { -/* -class PrintThread : public csnd::Thread { - std::atomic_bool splock; - std::atomic_bool on; - std::string message; - - void lock() { - bool tmp = false; - while(!splock.compare_exchange_weak(tmp,true)) - tmp = false; - } - - void unlock() { - splock = false; - } - - uintptr_t run() { - std::string old; - while(on) { - lock(); - if(old.compare(message)) { - csound->message(message.c_str()); - old = message; - } - unlock(); - } - return 0; - } - -public: - PrintThread(csnd::Csound *csound) - : Thread(csound), splock(false), on(true), message("") {}; - - ~PrintThread(){ - on = false; - join(); - } - - void set_message(const char *m) { - lock(); - message = m; - unlock(); - } - -}; - - -struct TPrint : csnd::Plugin<0, 1> { - static constexpr char const *otypes = ""; - static constexpr char const *itypes = "S"; - PrintThread t; - - int init() { - csound->plugin_deinit(this); - csnd::constr(&t, csound); - return OK; - } - - int deinit() { - csnd::destr(&t); - return OK; - } - - int kperf() { - t.set_message(inargs.str_data(0).data); - return OK; - } -}; -*/ void onload(csnd::Csound *csound) { csnd::plugin(csound, "pvstrace", csnd::thread::ik); diff --git a/Opcodes/repluck.c b/Opcodes/repluck.c index 2d50c959474..a829c30695d 100644 --- a/Opcodes/repluck.c +++ b/Opcodes/repluck.c @@ -304,9 +304,9 @@ static int32_t streson(CSOUND *csound, STRES *p) static OENTRY localops[] = { - { "repluck", S(WGPLUCK2), 0, 3, "a", "ikikka",(SUBR)wgpsetin, (SUBR)wgpluck}, - { "wgpluck2",S(WGPLUCK2), 0, 3, "a", "ikikk", (SUBR)wgpset, (SUBR)wgpluck}, - { "streson", S(STRES), 0, 3, "a", "akk", (SUBR)stresonset, (SUBR)streson} + { "repluck", S(WGPLUCK2), 0, "a", "ikikka",(SUBR)wgpsetin, (SUBR)wgpluck}, + { "wgpluck2",S(WGPLUCK2), 0, "a", "ikikk", (SUBR)wgpset, (SUBR)wgpluck}, + { "streson", S(STRES), 0, "a", "akk", (SUBR)stresonset, (SUBR)streson} }; int32_t repluck_init_(CSOUND *csound) diff --git a/Opcodes/reverbsc.c b/Opcodes/reverbsc.c index d0aa56e2456..1aff82c2229 100644 --- a/Opcodes/reverbsc.c +++ b/Opcodes/reverbsc.c @@ -312,7 +312,7 @@ static int32_t sc_reverb_perf(CSOUND *csound, SC_REVERB *p) int32_t reverbsc_init_(CSOUND *csound) { return csound->AppendOpcode(csound, "reverbsc", - (int32_t) sizeof(SC_REVERB), 0, 3, "aa", "aakkjpo", + (int32_t) sizeof(SC_REVERB), 0, "aa", "aakkjpo", (int32_t (*)(CSOUND *, void *)) sc_reverb_init, (int32_t (*)(CSOUND *, void *)) sc_reverb_perf, NULL); diff --git a/Opcodes/sc_noise.c b/Opcodes/sc_noise.c index 8dddf4b6598..ac3fcf29adc 100644 --- a/Opcodes/sc_noise.c +++ b/Opcodes/sc_noise.c @@ -388,17 +388,17 @@ static int32_t gausstrig_process_arate(CSOUND* csound, GAUSSTRIG *p) } static OENTRY scnoise_localops[] = { - { "dust.k", sizeof(DUST), 0,3, "k", "kk", + { "dust.k", sizeof(DUST), 0, "k", "kk", (SUBR)dust_init, (SUBR)dust_process_krate, NULL }, - { "dust.a", sizeof(DUST), 0,3, "a", "kk", + { "dust.a", sizeof(DUST), 0, "a", "kk", (SUBR)dust_init, (SUBR)dust_process_arate }, - { "dust2.k", sizeof(DUST), 0,3, "k", "kk", + { "dust2.k", sizeof(DUST), 0, "k", "kk", (SUBR)dust_init, (SUBR)dust2_process_krate, NULL }, - { "dust2.a", sizeof(DUST), 0,3, "a", "kk", + { "dust2.a", sizeof(DUST), 0, "a", "kk", (SUBR)dust_init, (SUBR)dust2_process_arate }, - { "gausstrig.k", sizeof(GAUSSTRIG), 0,3, "k", "kkkoo", + { "gausstrig.k", sizeof(GAUSSTRIG), 0, "k", "kkkoo", (SUBR)gausstrig_initk, (SUBR)gausstrig_process_krate, NULL }, - { "gausstrig.a", sizeof(GAUSSTRIG), 0,3, "a", "kkkoo", + { "gausstrig.a", sizeof(GAUSSTRIG), 0, "a", "kkkoo", (SUBR)gausstrig_init, (SUBR)gausstrig_process_arate } }; diff --git a/Opcodes/scansyn.c b/Opcodes/scansyn.c index 05c9e840f45..6e17ffd92e0 100644 --- a/Opcodes/scansyn.c +++ b/Opcodes/scansyn.c @@ -180,9 +180,6 @@ static void listadd(SCANSYN_GLOBALS *pp, PSCSNU *p) i->p = p; i->next = (struct scsn_elem *) pp->scsn_list; pp->scsn_list = (void*) i; -#if 0 - csound->RegisterDeinitCallback(csound, p, (int32_t (*)(CSOUND*, void*)) listrm); -#endif } /* Return from list according to id */ @@ -809,16 +806,16 @@ static int32_t scsnmapV(CSOUND *csound, PSCSNMAPV *p) static OENTRY localops[] = { - { "scanu", S(PSCSNU),TR, 3, "", "iiiiiiikkkkiikkaii", + { "scanu", S(PSCSNU),TR, "", "iiiiiiikkkkiikkaii", (SUBR)scsnu_init1, (SUBR)scsnu_play}, - { "scanu2", S(PSCSNU),TR, 3, "", "iiiiiiikkkkiikkaii", + { "scanu2", S(PSCSNU),TR, "", "iiiiiiikkkkiikkaii", (SUBR)scsnu_init2, (SUBR)scsnu_play }, - { "scans", S(PSCSNS),TR, 3, "a","kkiio", (SUBR)scsns_init, (SUBR)scsns_play}, - { "scanmap", S(PSCSNMAP),TR, 3, "kk", "ikko", (SUBR)scsnmap_init, + { "scans", S(PSCSNS),TR, "a","kkiio", (SUBR)scsns_init, (SUBR)scsns_play}, + { "scanmap", S(PSCSNMAP),TR, "kk", "ikko", (SUBR)scsnmap_init, (SUBR)scsnmap,NULL }, - { "scanmap.A", S(PSCSNMAPV),0, 3, "k[]k[]", "iPP", (SUBR)scsnmapV_init, + { "scanmap.A", S(PSCSNMAPV),0, "k[]k[]", "iPP", (SUBR)scsnmapV_init, (SUBR)scsnmapV,NULL }, - { "scansmap", S(PSCSNMAP),TR, 3,"", "kkikko", (SUBR)scsnmap_init, + { "scansmap", S(PSCSNMAP),TR, "", "kkikko", (SUBR)scsnmap_init, (SUBR)scsnsmap,NULL } }; diff --git a/Opcodes/scansynx.c b/Opcodes/scansynx.c index 72fd8302468..5c9debf2a81 100644 --- a/Opcodes/scansynx.c +++ b/Opcodes/scansynx.c @@ -757,15 +757,15 @@ static int32_t scsnsmapx(CSOUND *csound, PSCSNMAPX *p) static OENTRY localops[] = { - { "xscanu", S(PSCSNUX),_QQ|TR, 3, "", "iiiiSiikkkkiikkaii", (SUBR)scsnux_init_S, + { "xscanu", S(PSCSNUX),_QQ|TR, "", "iiiiSiikkkkiikkaii", (SUBR)scsnux_init_S, (SUBR)scsnux }, - { "xscanu", S(PSCSNUX),_QQ|TR, 3, "", "iiiiiiikkkkiikkaii", (SUBR)scsnux_init, + { "xscanu", S(PSCSNUX),_QQ|TR, "", "iiiiiiikkkkiikkaii", (SUBR)scsnux_init, (SUBR)scsnux }, - { "xscans", S(PSCSNSX), _QQ|TR, 3, "a", "kkiio", (SUBR)scsnsx_init, + { "xscans", S(PSCSNSX), _QQ|TR, "a", "kkiio", (SUBR)scsnsx_init, (SUBR)scsnsx}, - { "xscanmap", S(PSCSNMAPX),_QQ|TR, 3, "kk", "ikko", (SUBR)scsnmapx_init, + { "xscanmap", S(PSCSNMAPX),_QQ|TR, "kk", "ikko", (SUBR)scsnmapx_init, (SUBR)scsnmapx,NULL }, - { "xscansmap", S(PSCSNMAPX),_QQ|TR, 3,"", "kkikko", (SUBR)scsnmapx_init, + { "xscansmap", S(PSCSNMAPX),_QQ|TR,"", "kkikko", (SUBR)scsnmapx_init, (SUBR)scsnsmapx,NULL } }; diff --git a/Opcodes/scoreline.c b/Opcodes/scoreline.c index da6d8206070..7232bdfd6be 100644 --- a/Opcodes/scoreline.c +++ b/Opcodes/scoreline.c @@ -66,10 +66,10 @@ rewindscore(CSOUND *csound, SCOREPOS *p){ static OENTRY scoreline_localops[] = { - {"scoreline_i", sizeof(INMESS), 0, 1, "", "S", (SUBR)messi, NULL, NULL}, - {"scoreline", sizeof(INMESS), 0, 2, "", "Sk", NULL, (SUBR)messk, NULL}, - {"setscorepos", sizeof(SCOREPOS), 0, 1, "", "i", (SUBR)setscorepos, NULL, NULL}, - {"rewindscore", sizeof(SCOREPOS), 0, 1, "", "", (SUBR)rewindscore, NULL, NULL} + {"scoreline_i", sizeof(INMESS), 0, "", "S", (SUBR)messi, NULL, NULL}, + {"scoreline", sizeof(INMESS), 0, "", "Sk", NULL, (SUBR)messk, NULL}, + {"setscorepos", sizeof(SCOREPOS), 0, "", "i", (SUBR)setscorepos, NULL, NULL}, + {"rewindscore", sizeof(SCOREPOS), 0, "", "", (SUBR)rewindscore, NULL, NULL} }; LINKAGE_BUILTIN(scoreline_localops) diff --git a/Opcodes/select.c b/Opcodes/select.c index d7c9ce1570f..1d1cd25ee6a 100644 --- a/Opcodes/select.c +++ b/Opcodes/select.c @@ -60,7 +60,7 @@ static int32_t selecter(CSOUND *csound, Selecter* p) #define S(x) sizeof(x) static OENTRY select_localops[] = { - { "select", S(Selecter), 0, 2, "a", "aaaaa", NULL, (SUBR)selecter} + { "select", S(Selecter), 0, "a", "aaaaa", NULL, (SUBR)selecter} }; LINKAGE_BUILTIN(select_localops) diff --git a/Opcodes/seqtime.c b/Opcodes/seqtime.c index 2c8135e6ca1..7689d358236 100644 --- a/Opcodes/seqtime.c +++ b/Opcodes/seqtime.c @@ -256,8 +256,8 @@ static int32_t seqtim2(CSOUND *csound, SEQTIM2 *p) #define S(x) sizeof(x) static OENTRY localops[] = { -{ "seqtime", S(SEQTIM), TR, 3, "k", "kkkkk", (SUBR)seqtim_set, (SUBR)seqtim }, -{ "seqtime2", S(SEQTIM2),TR, 3, "k", "kkkkkk", (SUBR)seqtim2_set, (SUBR)seqtim2} +{ "seqtime", S(SEQTIM), TR, "k", "kkkkk", (SUBR)seqtim_set, (SUBR)seqtim }, +{ "seqtime2", S(SEQTIM2),TR, "k", "kkkkkk", (SUBR)seqtim2_set, (SUBR)seqtim2} }; int32_t seqtime_init_(CSOUND *csound) diff --git a/Opcodes/sequencer.c b/Opcodes/sequencer.c index d7d039ffb4c..f412babc9bc 100644 --- a/Opcodes/sequencer.c +++ b/Opcodes/sequencer.c @@ -278,12 +278,12 @@ static int sequState(CSOUND *csound, SEQSTATE* p) static OENTRY sequencer_localops[] = { - { "sequ", sizeof(SEQ), 0, 3, "k", + { "sequ", sizeof(SEQ), 0, "k", "i[]i[]i[]kkOOOoo", (SUBR) sequencer_init, (SUBR) sequencer }, - { "sequstate.i", sizeof(SEQSTATE), 0, 1, "ii[]", "o", + { "sequstate.i", sizeof(SEQSTATE), 0, "ii[]", "o", (SUBR) sequStateInit }, - { "sequstate.k", sizeof(SEQSTATE), 0, 3, "kk[]", "o", + { "sequstate.k", sizeof(SEQSTATE), 0, "kk[]", "o", (SUBR) sequStateInit, (SUBR) sequState } }; diff --git a/Opcodes/serial.c b/Opcodes/serial.c index c6dd5686585..353edc029bd 100644 --- a/Opcodes/serial.c +++ b/Opcodes/serial.c @@ -646,8 +646,6 @@ int32_t arduinoStart(CSOUND* csound, ARD_START* p) // Start listening thread q->stop = 0; q->thread = csound->CreateThread(arduino_listen, (void *)q); - csound->RegisterDeinitCallback(csound, p, - (int32_t (*)(CSOUND *, void *)) arduino_deinit); *p->returnedPort = xx; return OK; } @@ -746,33 +744,34 @@ int32_t arduinoStop(CSOUND* csound, ARD_START* p) #define S(x) sizeof(x) static OENTRY serial_localops[] = { - { (char *)"serialBegin", S(SERIALBEGIN), 0, 1, (char *)"i", (char *)"So", + { (char *)"serialBegin", S(SERIALBEGIN), 0, (char *)"i", (char *)"So", (SUBR)serialBegin, (SUBR)NULL, (SUBR)NULL }, - { (char *)"serialEnd", S(SERIALEND), 0, 2, (char *)"", (char *)"i", + { (char *)"serialEnd", S(SERIALEND), 0, (char *)"", (char *)"i", (SUBR)NULL, (SUBR)serialEnd, (SUBR)NULL }, - { (char *)"serialWrite_i", S(SERIALWRITE), 0, 1, (char *)"", (char *)"ii", + { (char *)"serialWrite_i", S(SERIALWRITE), 0, (char *)"", (char *)"ii", (SUBR)serialWrite, (SUBR)NULL, (SUBR)NULL }, - { (char *)"serialWrite_i.S", S(SERIALWRITE), 0, 1, (char *)"", (char *)"iS", + { (char *)"serialWrite_i.S", S(SERIALWRITE), 0, (char *)"", (char *)"iS", (SUBR)serialWrite_S, (SUBR)NULL, (SUBR)NULL }, - { (char *)"serialWrite", S(SERIALWRITE), WR, 2, (char *)"", (char *)"ik", + { (char *)"serialWrite", S(SERIALWRITE), WR, (char *)"", (char *)"ik", (SUBR)NULL, (SUBR)serialWrite, (SUBR)NULL }, - { (char *)"serialWrite.S", S(SERIALWRITE), WR, 2, (char *)"", (char *)"iS", + { (char *)"serialWrite.S", S(SERIALWRITE), WR, (char *)"", (char *)"iS", (SUBR)NULL, (SUBR)serialWrite_S, (SUBR)NULL }, - { (char *)"serialRead", S(SERIALREAD), 0, 2, (char *)"k", (char *)"i", + { (char *)"serialRead", S(SERIALREAD), 0, (char *)"k", (char *)"i", (SUBR)NULL, (SUBR)serialRead, (SUBR)NULL }, - { (char *)"serialPrint", S(SERIALPRINT), WR,2, (char *)"", (char *)"i", + { (char *)"serialPrint", S(SERIALPRINT), WR, (char *)"", (char *)"i", (SUBR)NULL, (SUBR)serialPrint, (SUBR)NULL }, - { (char *)"serialFlush", S(SERIALFLUSH), 0, 2, (char *)"", (char *)"i", + { (char *)"serialFlush", S(SERIALFLUSH), 0, (char *)"", (char *)"i", (SUBR)NULL, (SUBR)serialFlush, (SUBR)NULL }, - { "arduinoStart", S(ARD_START), 0, 1, "i", "So", (SUBR)arduinoStart, NULL }, - { "arduinoRead", S(ARD_READ), 0, 3, "k", "iio", + { "arduinoStart", S(ARD_START), 0, "i", "So", (SUBR)arduinoStart, NULL, + (SUBR) arduino_deinit}, + { "arduinoRead", S(ARD_READ), 0, "k", "iio", (SUBR)arduinoReadSetup, (SUBR)arduinoRead }, - { "arduinoReadF", S(ARD_READF), 0, 3, "k", "iiii", + { "arduinoReadF", S(ARD_READF), 0, "k", "iiii", (SUBR)arduinoReadFSetup, (SUBR)arduinoReadF }, - { "arduinoStop", S(ARD_START), 0, 1, "", "i", (SUBR)arduinoStop, NULL }, -/* { (char *)"serialAvailable", S(SERIALAVAIL), 0, 2, (char *)"k", (char *)"i", */ + { "arduinoStop", S(ARD_START), 0, "", "i", (SUBR)arduinoStop, NULL }, +/* { (char *)"serialAvailable", S(SERIALAVAIL), 0, (char *)"k", (char *)"i", */ /* (SUBR)NULL, (SUBR)serialAvailable, (SUBR)NULL }, */ -/* { (char *)"serialPeekByte", S(SERIALPEEK),0, 2, (char *)"k", (char *)"i", */ +/* { (char *)"serialPeekByte", S(SERIALPEEK),0, (char *)"k", (char *)"i", */ /* (SUBR)NULL, (SUBR)serialPeekByte, (SUBR)NULL } */ }; diff --git a/Opcodes/sfont.c b/Opcodes/sfont.c index e59dc0d109f..185a8e0b347 100644 --- a/Opcodes/sfont.c +++ b/Opcodes/sfont.c @@ -2708,33 +2708,33 @@ static int32_t sflooper_process(CSOUND *csound, sflooper *p) #define S sizeof static OENTRY localops[] = { - { "sfload",S(SFLOAD), 0, 1, "i", "S", (SUBR)SfLoad_S, NULL, NULL }, - { "sfload.i",S(SFLOAD), 0, 1, "i", "i", (SUBR)SfLoad, NULL, NULL }, - { "sfpreset",S(SFPRESET), 0, 1, "i", "iiii", (SUBR)SfPreset }, - { "sfplay", S(SFPLAY), 0, 3, "aa", "iixxioooo", + { "sfload",S(SFLOAD), 0, "i", "S", (SUBR)SfLoad_S, NULL, NULL }, + { "sfload.i",S(SFLOAD), 0, "i", "i", (SUBR)SfLoad, NULL, NULL }, + { "sfpreset",S(SFPRESET), 0, "i", "iiii", (SUBR)SfPreset }, + { "sfplay", S(SFPLAY), 0, "aa", "iixxioooo", (SUBR)SfPlay_set, (SUBR)SfPlay }, - { "sfplaym", S(SFPLAYMONO), 0, 3, "a", "iixxioooo", + { "sfplaym", S(SFPLAYMONO), 0, "a", "iixxioooo", (SUBR)SfPlayMono_set, (SUBR)SfPlayMono }, - { "sfplist",S(SFPLIST), 0, 1, "", "i", (SUBR)Sfplist }, - { "sfilist",S(SFPLIST), 0, 1, "", "i", (SUBR)Sfilist }, - { "sfilist.prefix",S(SFPLIST), 0, 1, "", "iS", (SUBR)Sfilist_prefix}, + { "sfplist",S(SFPLIST), 0, "", "i", (SUBR)Sfplist }, + { "sfilist",S(SFPLIST), 0, "", "i", (SUBR)Sfilist }, + { "sfilist.prefix",S(SFPLIST), 0, "", "iS", (SUBR)Sfilist_prefix}, - { "sfpassign",S(SFPASSIGN), 0, 1, "", "iip", (SUBR)SfAssignAllPresets }, - { "sfinstrm", S(SFIPLAYMONO),0, 3, "a", "iixxiioooo", + { "sfpassign",S(SFPASSIGN), 0, "", "iip", (SUBR)SfAssignAllPresets }, + { "sfinstrm", S(SFIPLAYMONO),0, "a", "iixxiioooo", (SUBR)SfInstrPlayMono_set, (SUBR)SfInstrPlayMono }, - { "sfinstr", S(SFIPLAY), 0, 3, "aa", "iixxiioooo", + { "sfinstr", S(SFIPLAY), 0, "aa", "iixxiioooo", (SUBR)SfInstrPlay_set,(SUBR)SfInstrPlay }, - { "sfplay3", S(SFPLAY), 0, 3, "aa", "iixxioooo", + { "sfplay3", S(SFPLAY), 0, "aa", "iixxioooo", (SUBR)SfPlay_set, (SUBR)SfPlay3 }, - { "sfplay3m", S(SFPLAYMONO), 0, 3, "a", "iixxioooo", + { "sfplay3m", S(SFPLAYMONO), 0, "a", "iixxioooo", (SUBR)SfPlayMono_set,(SUBR)SfPlayMono3 }, - { "sfinstr3", S(SFIPLAY), 0, 3, "aa", "iixxiioooo", + { "sfinstr3", S(SFIPLAY), 0, "aa", "iixxiioooo", (SUBR)SfInstrPlay_set, (SUBR)SfInstrPlay3 }, - { "sfinstr3m", S(SFIPLAYMONO), 0, 3, "a", "iixxiioooo", + { "sfinstr3m", S(SFIPLAYMONO), 0, "a", "iixxiioooo", (SUBR)SfInstrPlayMono_set, (SUBR)SfInstrPlayMono3 }, - { "sflooper", S(sflooper), 0, 3, "aa", "iikkikkkooooo", + { "sflooper", S(sflooper), 0, "aa", "iikkikkkooooo", (SUBR)sflooper_init, (SUBR)sflooper_process }, - { NULL, 0, 0, 0, NULL, NULL, (SUBR) NULL, (SUBR) NULL, (SUBR) NULL } + { NULL, 0, 0, NULL, NULL, (SUBR) NULL, (SUBR) NULL, (SUBR) NULL } }; int32_t sfont_ModuleCreate(CSOUND *csound) @@ -2770,11 +2770,11 @@ int32_t sfont_ModuleInit(CSOUND *csound) while (ep->opname != NULL) { err |= csound->AppendOpcode(csound, ep->opname, ep->dsblksiz, ep->flags, - ep->thread, ep->outypes, ep->intypes, - (int32_t (*)(CSOUND *, void*)) ep->iopadr, - (int32_t (*)(CSOUND *, void*)) ep->kopadr, + ep->outypes, ep->intypes, + (int32_t (*)(CSOUND *, void*)) ep->init, + (int32_t (*)(CSOUND *, void*)) ep->perf, (int32_t - (*)(CSOUND *, void*)) ep->aopadr); + (*)(CSOUND *, void*)) ep->deinit); ep++; } return err; diff --git a/Opcodes/shape.c b/Opcodes/shape.c index 851e19bc337..52205a593bd 100644 --- a/Opcodes/shape.c +++ b/Opcodes/shape.c @@ -570,17 +570,17 @@ static int32_t Phasine(CSOUND* csound, PHASINE* p) static OENTRY shape_localops[] = { - /* { "phasine", S(PHASINE), 0, 3, "a", "akp", + /* { "phasine", S(PHASINE), 0, "a", "akp", (SUBR)PhasineInit, (SUBR)Phasine }, */ - { "powershape", S(POWER_SHAPE), 0, 3, "a", "akp", + { "powershape", S(POWER_SHAPE), 0, "a", "akp", (SUBR)PowerShapeInit, (SUBR)PowerShape }, - { "polynomial", S(POLYNOMIAL), 0, 2, "a", "az", NULL, (SUBR)Polynomial }, - { "chebyshevpoly", S(CHEBPOLY), 0, 3, "a", "az", + { "polynomial", S(POLYNOMIAL), 0, "a", "az", NULL, (SUBR)Polynomial }, + { "chebyshevpoly", S(CHEBPOLY), 0, "a", "az", (SUBR)ChebyshevPolyInit, (SUBR)ChebyshevPolynomial }, - { "pdclip", S(PD_CLIP), 0, 2, "a", "akkop", NULL, (SUBR)PDClip }, - { "pdhalf", S(PD_HALF), 0, 2, "a", "akop", NULL, (SUBR)PDHalfX }, - { "pdhalfy", S(PD_HALF), 0, 2, "a", "akop", NULL, (SUBR)PDHalfY }, - { "syncphasor", S(SYNCPHASOR), 0, 3, "aa", "xao", + { "pdclip", S(PD_CLIP), 0, "a", "akkop", NULL, (SUBR)PDClip }, + { "pdhalf", S(PD_HALF), 0, "a", "akop", NULL, (SUBR)PDHalfX }, + { "pdhalfy", S(PD_HALF), 0, "a", "akop", NULL, (SUBR)PDHalfY }, + { "syncphasor", S(SYNCPHASOR), 0, "aa", "xao", (SUBR)SyncPhasorInit, (SUBR)SyncPhasor }, }; diff --git a/Opcodes/signalflowgraph.cpp b/Opcodes/signalflowgraph.cpp index 4720c4481b9..6e380921b91 100644 --- a/Opcodes/signalflowgraph.cpp +++ b/Opcodes/signalflowgraph.cpp @@ -1438,50 +1438,52 @@ static int ftgenonce_SS(CSOUND *csound, FTGEN *p) { extern "C" { static OENTRY oentries[] = { - {(char *)"outleta", sizeof(Outleta), _CW, 3, (char *)"", (char *)"Sa", - (SUBR)&Outleta::init_, (SUBR)&Outleta::audio_}, - {(char *)"inleta", sizeof(Inleta), _CR, 3, (char *)"a", (char *)"S", + {(char *)"outleta", sizeof(Outleta), _CW, (char *)"", (char *)"Sa", + (SUBR)&Outleta::init_, (SUBR)&Outleta::audio_, (SUBR)&Outleta::deinit_}, + {(char *)"inleta", sizeof(Inleta), _CR, (char *)"a", (char *)"S", (SUBR)&Inleta::init_, (SUBR)&Inleta::audio_}, - {(char *)"outletk", sizeof(Outletk), _CW, 3, (char *)"", (char *)"Sk", - (SUBR)&Outletk::init_, (SUBR)&Outletk::kontrol_, 0}, - {(char *)"inletk", sizeof(Inletk), _CR, 3, (char *)"k", (char *)"S", + {(char *)"outletk", sizeof(Outletk), _CW, (char *)"", (char *)"Sk", + (SUBR)&Outletk::init_, (SUBR)&Outletk::kontrol_, (SUBR)&Outleta::deinit_}, + {(char *)"inletk", sizeof(Inletk), _CR, (char *)"k", (char *)"S", (SUBR)&Inletk::init_, (SUBR)&Inletk::kontrol_, 0}, - {(char *)"outletkid", sizeof(Outletkid), _CW, 3, (char *)"", (char *)"SSk", - (SUBR)&Outletk::init_, (SUBR)&Outletk::kontrol_, 0}, - {(char *)"inletkid", sizeof(Inletkid), _CR, 3, (char *)"k", (char *)"SS", + {(char *)"outletkid", sizeof(Outletkid), _CW, (char *)"", (char *)"SSk", + (SUBR)&Outletk::init_, (SUBR)&Outletk::kontrol_, (SUBR)&Outleta::deinit_}, + {(char *)"inletkid", sizeof(Inletkid), _CR, (char *)"k", (char *)"SS", (SUBR)&Inletk::init_, (SUBR)&Inletk::kontrol_, 0}, - {(char *)"outletf", sizeof(Outletf), _CW, 3, (char *)"", (char *)"Sf", - (SUBR)&Outletf::init_, (SUBR)&Outletf::audio_}, - {(char *)"inletf", sizeof(Inletf), _CR, 3, (char *)"f", (char *)"S", + {(char *)"outletf", sizeof(Outletf), _CW, (char *)"", (char *)"Sf", + (SUBR)&Outletf::init_, (SUBR)&Outletf::audio_, (SUBR)&Outleta::deinit_}, + {(char *)"inletf", sizeof(Inletf), _CR, (char *)"f", (char *)"S", (SUBR)&Inletf::init_, (SUBR)&Inletf::audio_}, - {(char *)"outletv", sizeof(Outletv), _CW, 3, (char *)"", (char *)"Sa[]", - (SUBR)&Outletv::init_, (SUBR)&Outletv::audio_}, - {(char *)"inletv", sizeof(Inletv), _CR, 3, (char *)"a[]", (char *)"S", + {(char *)"outletv", sizeof(Outletv), _CW, (char *)"", (char *)"Sa[]", + (SUBR)&Outletv::init_, (SUBR)&Outletv::audio_, (SUBR)&Outleta::deinit_}, + {(char *)"inletv", sizeof(Inletv), _CR, (char *)"a[]", (char *)"S", (SUBR)&Inletv::init_, (SUBR)&Inletv::audio_}, - {(char *)"connect", sizeof(Connect), 0, 1, (char *)"", (char *)"iSiSp", + {(char *)"connect", sizeof(Connect), 0, (char *)"", (char *)"iSiSp", (SUBR)&Connect::init_, 0, 0}, - {(char *)"connect.i", sizeof(Connecti), 0, 1, (char *)"", (char *)"iSSSp", + {(char *)"connect.i", sizeof(Connecti), 0, (char *)"", (char *)"iSSSp", (SUBR)&Connecti::init_, 0, 0}, - {(char *)"connect.ii", sizeof(Connectii), 0, 1, (char *)"", (char *)"SSiSp", + {(char *)"connect.ii", sizeof(Connectii), 0, (char *)"", (char *)"SSiSp", (SUBR)&Connectii::init_, 0, 0}, - {(char *)"connect.S", sizeof(ConnectS), 0, 1, (char *)"", (char *)"SSSSp", + {(char *)"connect.S", sizeof(ConnectS), 0, (char *)"", (char *)"SSSSp", (SUBR)&ConnectS::init_, 0, 0}, - {(char *)"alwayson", sizeof(AlwaysOn), 0, 1, (char *)"", (char *)"im", + {(char *)"alwayson", sizeof(AlwaysOn), 0, (char *)"", (char *)"im", (SUBR)&AlwaysOn::init_, 0, 0}, - {(char *)"alwayson.S", sizeof(AlwaysOnS), 0, 1, (char *)"", (char *)"Sm", + {(char *)"alwayson.S", sizeof(AlwaysOnS), 0, (char *)"", (char *)"Sm", (SUBR)&AlwaysOnS::init_, 0, 0}, - {(char *)"ftgenonce", sizeof(FTGEN), TW, 1, (char *)"i", (char *)"iiiiim", + {(char *)"ftgenonce", sizeof(FTGEN), TW, (char *)"i", (char *)"iiiiim", (SUBR)&ftgenonce, 0, 0}, - {(char *)"ftgenonce.S", sizeof(FTGEN), TW, 1, (char *)"i", (char *)"iiiSim", + {(char *)"ftgenonce.S", sizeof(FTGEN), TW, (char *)"i", (char *)"iiiSim", (SUBR)&ftgenonce_S, 0, 0}, - {(char *)"ftgenonce.iS", sizeof(FTGEN), TW, 1, (char *)"i", + {(char *)"ftgenonce.iS", sizeof(FTGEN), TW, (char *)"i", (char *)"iiiiSm", (SUBR)&ftgenonce_iS, 0, 0}, - {(char *)"ftgenonce.SS", sizeof(FTGEN), TW, 1, (char *)"i", + {(char *)"ftgenonce.SS", sizeof(FTGEN), TW, (char *)"i", (char *)"iiiSSm", (SUBR)&ftgenonce_SS, 0, 0}, - {0, 0, 0, 0, 0, 0, (SUBR)0, (SUBR)0, (SUBR)0}}; + {0, 0, 0, 0, 0, (SUBR)0, (SUBR)0, (SUBR)0}}; + int32_t destroySignalflowgraph(CSOUND *csound, void *p) { IGN(p); + if (csound->GetDebug(csound)) { csound->Message(csound, "signalflowgraph: csoundModuleDestroy(%p)...\n", csound); @@ -1532,10 +1534,10 @@ PUBLIC int32_t csoundModuleInit_signalflowgraph(CSOUND *csound) { int err = 0; while (ep->opname != 0) { err |= csound->AppendOpcode(csound, ep->opname, ep->dsblksiz, ep->flags, - ep->thread, ep->outypes, ep->intypes, - (int32_t (*)(CSOUND *, void *))ep->iopadr, - (int32_t (*)(CSOUND *, void *))ep->kopadr, - (int32_t (*)(CSOUND *, void *))ep->aopadr); + ep->outypes, ep->intypes, + (int32_t (*)(CSOUND *, void *))ep->init, + (int32_t (*)(CSOUND *, void *))ep->perf, + (int32_t (*)(CSOUND *, void *))ep->deinit); ep++; } // need to register reset callback diff --git a/Opcodes/sndloop.c b/Opcodes/sndloop.c index 570f6a103c9..f3b083b22db 100644 --- a/Opcodes/sndloop.c +++ b/Opcodes/sndloop.c @@ -1333,19 +1333,19 @@ static int32_t pvsmorph_process(CSOUND *csound, pvsmorph *p) static OENTRY localops[] = { - {"sndloop", sizeof(sndloop),0, 3, + {"sndloop", sizeof(sndloop),0, "ak", "akkii", (SUBR)sndloop_init, (SUBR)sndloop_process}, - {"flooper", sizeof(flooper), TR, 3, + {"flooper", sizeof(flooper), TR, "mm", "kkiiii", (SUBR)flooper_init, (SUBR)flooper_process}, - {"pvsarp", sizeof(pvsarp), 0,3, + {"pvsarp", sizeof(pvsarp), 0, "f", "fkkk", (SUBR)pvsarp_init, (SUBR)pvsarp_process}, - {"pvsvoc", sizeof(pvsvoc), 0,3, + {"pvsvoc", sizeof(pvsvoc), 0, "f", "ffkkO", (SUBR)pvsvoc_init, (SUBR)pvsvoc_process}, - {"flooper2", sizeof(flooper2), TR, 3, + {"flooper2", sizeof(flooper2), TR, "mm", "kkkkkiooooO", (SUBR)flooper2_init, (SUBR)flooper2_process}, - /* {"flooper3", sizeof(flooper3), TR, 3, + /* {"flooper3", sizeof(flooper3), TR, "a", "kkkkkioooo", (SUBR)flooper3_init, (SUBR)flooper3_process},*/ - {"pvsmorph", sizeof(pvsvoc), 0,3, + {"pvsmorph", sizeof(pvsvoc), 0, "f", "ffkk", (SUBR)pvsmorph_init, (SUBR)pvsmorph_process} }; diff --git a/Opcodes/sndwarp.c b/Opcodes/sndwarp.c index 97c34eb986c..db5233657ef 100644 --- a/Opcodes/sndwarp.c +++ b/Opcodes/sndwarp.c @@ -376,9 +376,9 @@ static int32_t sndwarpst(CSOUND *csound, SNDWARPST *p) static OENTRY localops[] = { - { "sndwarp", S(SNDWARP), TR, 3, "mm", "xxxiiiiiii", + { "sndwarp", S(SNDWARP), TR, "mm", "xxxiiiiiii", (SUBR)sndwarpgetset, (SUBR)sndwarp}, - { "sndwarpst", S(SNDWARPST), TR, 3, "mmmm","xxxiiiiiii", + { "sndwarpst", S(SNDWARPST), TR, "mmmm","xxxiiiiiii", (SUBR)sndwarpstset,(SUBR)sndwarpst} }; diff --git a/Opcodes/sockrecv.c b/Opcodes/sockrecv.c index 1a6cd6a01ec..e07db524f8c 100644 --- a/Opcodes/sockrecv.c +++ b/Opcodes/sockrecv.c @@ -232,7 +232,6 @@ static int32_t init_recv(CSOUND *csound, SOCKRECV *p) /* create thread */ p->threadon = 1; p->thrid = csound->CreateThread(udpRecv, (void *) p); - csound->RegisterDeinitCallback(csound, (void *) p, deinit_udpRecv); p->buf = p->buffer.auxp; p->outsamps = p->rcvsamps = 0; return OK; @@ -288,7 +287,6 @@ static int32_t init_recv_S(CSOUND *csound, SOCKRECVSTR *p) /* create thread */ p->threadon = 1; p->thrid = csound->CreateThread(udpRecv_S, (void *) p); - csound->RegisterDeinitCallback(csound, (void *) p, deinit_udpRecv_S); p->buf = p->buffer.auxp; p->outsamps = p->rcvsamps = 0; return OK; @@ -402,7 +400,6 @@ static int32_t init_recvS(CSOUND *csound, SOCKRECV *p) /* create thread */ p->threadon = 1; p->thrid = csound->CreateThread(udpRecv, (void *) p); - csound->RegisterDeinitCallback(csound, (void *) p, deinit_udpRecv); p->buf = p->buffer.auxp; p->outsamps = p->rcvsamps = 0; p->buffsize = p->buffer.size/sizeof(MYFLT); @@ -620,8 +617,6 @@ static int32_t init_raw_osc(CSOUND *csound, RAWOSC *p) buf = (MYFLT *) p->buffer.auxp; /* make sure buffer is empty */ memset(buf, 0, MTU); } - - csound->RegisterDeinitCallback(csound, (void *) p, destroy_raw_osc); if(p->sout->data == NULL) tabinit(csound, p->sout, 2); @@ -770,21 +765,22 @@ static int32_t perf_raw_osc(CSOUND *csound, RAWOSC *p) { #define S(x) sizeof(x) static OENTRY sockrecv_localops[] = { - { "sockrecv.k", S(SOCKRECV), 0, 3, "k", "ii", - (SUBR) init_recv, (SUBR) send_recv_k, NULL }, - { "sockrecv.a", S(SOCKRECV), 0, 3, "a", "ii", - (SUBR) init_recv, (SUBR) send_recv, NULL }, - { "sockrecv.S", S(SOCKRECVSTR), 0, 3, "S", "ii", + { "sockrecv.k", S(SOCKRECV), 0, "k", "ii", + (SUBR) init_recv, (SUBR) send_recv_k, NULL, (SUBR) deinit_udpRecv }, + { "sockrecv.a", S(SOCKRECV), 0, "a", "ii", + (SUBR) init_recv, (SUBR) send_recv, (SUBR) deinit_udpRecv }, + { "sockrecv.S", S(SOCKRECVSTR), 0, "S", "ii", (SUBR) init_recv_S, - (SUBR) send_recv_S, NULL }, - { "sockrecvs", S(SOCKRECV), 0, 3, "aa", "ii", + (SUBR) send_recv_S, NULL, (SUBR) deinit_udpRecv_S }, + { "sockrecvs", S(SOCKRECV), 0, "aa", "ii", (SUBR) init_recvS, - (SUBR) send_recvS, NULL }, - { "strecv", S(SOCKRECVT), 0, 3, "az", "Si", + (SUBR) send_recvS, (SUBR) deinit_udpRecv }, + { "strecv", S(SOCKRECVT), 0, "az", "Si", (SUBR) init_srecv, (SUBR) send_srecv, NULL }, - { "OSCraw", S(RAWOSC), 0, 3, "S[]k", "i", - (SUBR) init_raw_osc, (SUBR) perf_raw_osc, NULL, NULL} + { "OSCraw", S(RAWOSC), 0, "S[]k", "i", + (SUBR) init_raw_osc, (SUBR) perf_raw_osc, + (SUBR) destroy_raw_osc, NULL} }; LINKAGE_BUILTIN(sockrecv_localops) diff --git a/Opcodes/socksend.c b/Opcodes/socksend.c index fb5d2669a5a..f42d772a81d 100644 --- a/Opcodes/socksend.c +++ b/Opcodes/socksend.c @@ -414,9 +414,6 @@ static int32_t init_ssend(CSOUND *csound, SOCKSEND *p) #endif return csound->InitError(csound, Str("connect failed (%d)"), err); } - csound->RegisterDeinitCallback(csound, p, - (int32_t (*)(CSOUND *, void *)) stsend_deinit); - return OK; } @@ -510,9 +507,6 @@ static int32_t osc_send2_init(CSOUND *csound, OSCSEND2 *p) #endif p->server_addr.sin_port = htons((int32_t) *p->port); /* the port */ - csound->RegisterDeinitCallback(csound, p, - (int32_t (*)(CSOUND *, void *)) oscsend_deinit); - if(p->INCOUNT > 4) { if (p->types.auxp == NULL || strlen(p->type->data) > p->types.size) /* allocate space for the types buffer */ @@ -1032,19 +1026,19 @@ static int oscbundle_perf(CSOUND *csound, OSCBUNDLE *p){ static OENTRY socksend_localops[] = { - { "socksend.a", S(SOCKSEND), 0, 3, "", "aSiio", (SUBR) init_send, + { "socksend.a", S(SOCKSEND), 0, "", "aSiio", (SUBR) init_send, (SUBR) send_send }, - { "socksend.k", S(SOCKSEND), 0, 3, "", "kSiio", (SUBR) init_send, + { "socksend.k", S(SOCKSEND), 0, "", "kSiio", (SUBR) init_send, (SUBR) send_send_k, NULL }, - { "socksend.S", S(SOCKSENDT), 0, 3, "", "SSiio", (SUBR) init_send, + { "socksend.S", S(SOCKSENDT), 0, "", "SSiio", (SUBR) init_send, (SUBR) send_send_Str, NULL }, - { "socksends", S(SOCKSENDS), 0, 3, "", "aaSiio", (SUBR) init_sendS, + { "socksends", S(SOCKSENDS), 0, "", "aaSiio", (SUBR) init_sendS, (SUBR) send_sendS }, - { "stsend", S(SOCKSEND), 0, 3, "", "aSi", (SUBR) init_ssend, - (SUBR) send_ssend }, - { "OSCsend", S(OSCSEND2), 0, 3, "", "kSkSN", (SUBR)osc_send2_init, - (SUBR)osc_send2 }, - { "OSCbundle", S(OSCBUNDLE), 0, 3, "", "kSkS[]S[]k[][]o", (SUBR)oscbundle_init, + { "stsend", S(SOCKSEND), 0, "", "aSi", (SUBR) init_ssend, + (SUBR) send_ssend, (SUBR) stsend_deinit }, + { "OSCsend", S(OSCSEND2), 0, "", "kSkSN", (SUBR)osc_send2_init, + (SUBR)osc_send2, (SUBR) oscsend_deinit }, + { "OSCbundle", S(OSCBUNDLE), 0, "", "kSkS[]S[]k[][]o", (SUBR)oscbundle_init, (SUBR)oscbundle_perf }, }; diff --git a/Opcodes/space.c b/Opcodes/space.c index 9ddd93b1b7f..a31856b0278 100644 --- a/Opcodes/space.c +++ b/Opcodes/space.c @@ -268,9 +268,9 @@ static int32_t spdist(CSOUND *csound, SPDIST *p) static OENTRY localops[] = { - { "space", S(SPACE), TR,3, "aaaa", "aikkkk",(SUBR)spaceset, (SUBR)space }, - { "spsend", S(SPSEND), 0,3, "aaaa", "", (SUBR)spsendset, (SUBR)spsend }, - { "spdist", S(SPDIST), 0,3, "k", "ikkk", (SUBR)spdistset, (SUBR)spdist } + { "space", S(SPACE), TR, "aaaa", "aikkkk",(SUBR)spaceset, (SUBR)space }, + { "spsend", S(SPSEND), 0, "aaaa", "", (SUBR)spsendset, (SUBR)spsend }, + { "spdist", S(SPDIST), 0, "k", "ikkk", (SUBR)spdistset, (SUBR)spdist } }; int32_t space_init_(CSOUND *csound) diff --git a/Opcodes/spat3d.c b/Opcodes/spat3d.c index ecf825479ff..2f14eecd5ba 100644 --- a/Opcodes/spat3d.c +++ b/Opcodes/spat3d.c @@ -884,11 +884,11 @@ static int32_t spat3dt(CSOUND *csound, SPAT3D *p) static OENTRY localops[] = { - { "spat3d", S(SPAT3D), 0, 3, "aaaa", "akkkiiiiio", + { "spat3d", S(SPAT3D), 0, "aaaa", "akkkiiiiio", (SUBR) spat3dset, (SUBR) spat3d }, - { "spat3di",S(SPAT3D), 0, 3, "aaaa", "aiiiiiio", + { "spat3di",S(SPAT3D), 0, "aaaa", "aiiiiiio", (SUBR) spat3diset, (SUBR) spat3di }, - { "spat3dt",S(SPAT3D), 0, 1, "", "iiiiiiiio", + { "spat3dt",S(SPAT3D), 0, "", "iiiiiiiio", (SUBR) spat3dt, NULL, NULL } }; diff --git a/Opcodes/spectra.c b/Opcodes/spectra.c index ff0b3f8ff1a..7030d1670ab 100644 --- a/Opcodes/spectra.c +++ b/Opcodes/spectra.c @@ -374,7 +374,7 @@ int32_t spectrum(CSOUND *csound, SPECTRUM *p) /* hanning = (*p->ihann) ? 1 : 0; */ /* if ((p->dbout = *p->idbout) && p->dbout != 1 && p->dbout != 2) { */ /* return csound->InitError(csound, - Str("noctdft: unknown dbout code of %d"), */ + "%s", Str("noctdft: unknown dbout code of %d"), */ /* p->dbout); */ /* } */ /* nocts = downp->nocts; */ @@ -650,7 +650,6 @@ int32_t sptrkset(CSOUND *csound, SPECPTRK *p) *fp++ = FL(0.0); /* clear unused lo and hi range */ for (fp = fhip; fp < fendp; ) *fp++ = FL(0.0); - csound->Warning(csound, Str("specptrk: %d freqs, %d%s ptls at "), (int32_t)nfreqs, (int32_t)nptls, inc==2 ? Str(" odd") : ""); for (nn = 0; nn < nptls; nn++) @@ -1251,59 +1250,58 @@ int32_t specfilt(CSOUND *csound, SPECFILT *p) #define S sizeof static OENTRY spectra_localops[] = { - { "spectrum", S(SPECTRUM),_QQ, 3, "w", "kiiiqoooo", + { "spectrum", S(SPECTRUM),_QQ, "w", "kiiiqoooo", (SUBR)spectset,(SUBR)spectrum }, - { "spectrum", S(SPECTRUM),_QQ, 3, "w", "aiiiqoooo", + { "spectrum", S(SPECTRUM),_QQ, "w", "aiiiqoooo", (SUBR)spectset,(SUBR)spectrum }, - { "specaddm", S(SPECADDM),_QQ, 3, "w", "wwp", (SUBR)spadmset, (SUBR)specaddm}, - { "specdiff", S(SPECDIFF),_QQ, 3, "w", "w", (SUBR)spdifset, (SUBR)specdiff}, - { "specscal", S(SPECSCAL),_QQ, 3, "w", "wii", (SUBR)spsclset, (SUBR)specscal}, - { "spechist", S(SPECHIST),_QQ, 3, "w", "w", (SUBR)sphstset, (SUBR)spechist}, - { "specfilt", S(SPECFILT),_QQ, 3, "w", "wi", (SUBR)spfilset, (SUBR)specfilt}, - { "specptrk", S(SPECPTRK),_QQ, 3, "kk", "wkiiiiiioqooo", + { "specaddm", S(SPECADDM),_QQ, "w", "wwp", (SUBR)spadmset, (SUBR)specaddm}, + { "specdiff", S(SPECDIFF),_QQ, "w", "w", (SUBR)spdifset, (SUBR)specdiff}, + { "specscal", S(SPECSCAL),_QQ, "w", "wii", (SUBR)spsclset, (SUBR)specscal}, + { "spechist", S(SPECHIST),_QQ, "w", "w", (SUBR)sphstset, (SUBR)spechist}, + { "specfilt", S(SPECFILT),_QQ, "w", "wi", (SUBR)spfilset, (SUBR)specfilt}, + { "specptrk", S(SPECPTRK),_QQ, "kk", "wkiiiiiioqooo", (SUBR)sptrkset,(SUBR)specptrk}, - { "specsum", S(SPECSUM), _QQ, 3, "k", "wo", (SUBR)spsumset, (SUBR)specsum }, - { "specdisp", S(SPECDISP),_QQ, 3, "", "wio", (SUBR)spdspset, (SUBR)specdisp}, - { "pitch", S(PITCH), 0, 3, "kk", "aiiiiqooooojo", + { "specsum", S(SPECSUM), _QQ, "k", "wo", (SUBR)spsumset, (SUBR)specsum }, + { "specdisp", S(SPECDISP),_QQ, "", "wio", (SUBR)spdspset, (SUBR)specdisp}, + { "pitch", S(PITCH), 0, "kk", "aiiiiqooooojo", (SUBR)pitchset, (SUBR)pitch }, - { "maca", S(SUM), 0, 3, "a", "y", (SUBR)macset, (SUBR)maca }, - { "mac", S(SUM), 0, 3, "a", "Z", (SUBR)macset, (SUBR)mac }, - { "clockon", S(CLOCK), 0, 3, "", "i", (SUBR)clockset, (SUBR)clockon, NULL }, - { "clockoff", S(CLOCK),0, 3, "", "i", (SUBR)clockset, (SUBR)clockoff, NULL }, - { "readclock", S(CLKRD),0, 1, "i", "i", (SUBR)clockread, NULL, NULL }, - { "readscratch", S(SCRATCHPAD),0, 1, "i", "o", (SUBR)scratchread, NULL, NULL }, - { "writescratch", S(SCRATCHPAD),0, 1, "", "io", (SUBR)scratchwrite, NULL, NULL }, - { "pitchamdf",S(PITCHAMDF),0,3,"kk","aiioppoo", + { "maca", S(SUM), 0, "a", "y", (SUBR)macset, (SUBR)maca }, + { "mac", S(SUM), 0, "a", "Z", (SUBR)macset, (SUBR)mac }, + { "clockon", S(CLOCK), 0, "", "i", (SUBR)clockset, (SUBR)clockon, NULL }, + { "clockoff", S(CLOCK),0, "", "i", (SUBR)clockset, (SUBR)clockoff, NULL }, + { "readclock", S(CLKRD),0, "i", "i", (SUBR)clockread, NULL, NULL }, + { "readscratch", S(SCRATCHPAD),0, "i", "o", (SUBR)scratchread, NULL, NULL }, + { "writescratch", S(SCRATCHPAD),0, "", "io", (SUBR)scratchwrite, NULL, NULL }, + { "pitchamdf",S(PITCHAMDF),0, "kk","aiioppoo", (SUBR)pitchamdfset, (SUBR)pitchamdf }, - { "hsboscil",S(HSBOSC), TR, 3, "a", "kkkiiioo", - + { "hsboscil",S(HSBOSC), TR, "a", "kkkiiioo", (SUBR)hsboscset,(SUBR)hsboscil }, - { "phasorbnk", S(PHSORBNK),0,3,"a", "xkio", + { "phasorbnk", S(PHSORBNK),0,"a", "xkio", (SUBR)phsbnkset, (SUBR)phsorbnk }, - { "phasorbnk.k", S(PHSORBNK),0,3,"k", "xkio", + { "phasorbnk.k", S(PHSORBNK),0,"k", "xkio", (SUBR)phsbnkset, (SUBR)kphsorbnk, NULL}, - { "adsynt",S(HSBOSC), TR, 3, "a", "kkiiiio", (SUBR)adsyntset, (SUBR)adsynt }, - { "mpulse", S(IMPULSE), 0, 3, "a", "kko", + { "adsynt",S(HSBOSC), TR, "a", "kkiiiio", (SUBR)adsyntset, (SUBR)adsynt }, + { "mpulse", S(IMPULSE), 0, "a", "kko", (SUBR)impulse_set, (SUBR)impulse }, - { "lpf18", S(LPF18), 0, 3, "a", "axxxo", (SUBR)lpf18set, (SUBR)lpf18db }, - { "waveset", S(BARRI), 0, 3, "a", "ako", (SUBR)wavesetset, (SUBR)waveset}, - { "pinkish", S(PINKISH), 0, 3, "a", "xoooo", (SUBR)pinkset, (SUBR)pinkish }, - { "noise", S(VARI), 0, 3, "a", "xk", (SUBR)varicolset, (SUBR)varicol }, - { "transeg", S(TRANSEG),0, 3, "k", "iiim", + { "lpf18", S(LPF18), 0, "a", "axxxo", (SUBR)lpf18set, (SUBR)lpf18db }, + { "waveset", S(BARRI), 0, "a", "ako", (SUBR)wavesetset, (SUBR)waveset}, + { "pinkish", S(PINKISH), 0, "a", "xoooo", (SUBR)pinkset, (SUBR)pinkish }, + { "noise", S(VARI), 0, "a", "xk", (SUBR)varicolset, (SUBR)varicol }, + { "transeg", S(TRANSEG),0, "k", "iiim", (SUBR)trnset,(SUBR)ktrnseg, NULL}, - { "transeg.a", S(TRANSEG),0, 3, "a", "iiim", + { "transeg.a", S(TRANSEG),0, "a", "iiim", (SUBR)trnset,(SUBR)trnseg}, - { "transegb", S(TRANSEG),0, 3, "k", "iiim", + { "transegb", S(TRANSEG),0, "k", "iiim", (SUBR)trnset_bkpt,(SUBR)ktrnseg,(SUBR)NULL}, - { "transegb.a", S(TRANSEG),0, 3, "a", "iiim", + { "transegb.a", S(TRANSEG),0, "a", "iiim", (SUBR)trnset_bkpt,(SUBR)trnseg }, - { "transegr", S(TRANSEG),0, 3, "k", "iiim", + { "transegr", S(TRANSEG),0, "k", "iiim", (SUBR)trnsetr,(SUBR)ktrnsegr,(SUBR)NULL }, - { "transegr.a", S(TRANSEG),0, 3, "a", "iiim", + { "transegr.a", S(TRANSEG),0, "a", "iiim", (SUBR)trnsetr,(SUBR)trnsegr }, - { "clip", S(CLIP), 0, 3, "a", "aiiv", (SUBR)clip_set, (SUBR)clip }, - { "median", S(MEDFILT), 0, 3, "a", "akio", (SUBR)medfiltset, (SUBR)medfilt }, - { "mediank", S(MEDFILT), 0,3, "k", "kkio", (SUBR)medfiltset, (SUBR)kmedfilt}, + { "clip", S(CLIP), 0, "a", "aiiv", (SUBR)clip_set, (SUBR)clip }, + { "median", S(MEDFILT), 0, "a", "akio", (SUBR)medfiltset, (SUBR)medfilt }, + { "mediank", S(MEDFILT), 0, "k", "kkio", (SUBR)medfiltset, (SUBR)kmedfilt}, }; LINKAGE_BUILTIN(spectra_localops) diff --git a/Opcodes/squinewave.c b/Opcodes/squinewave.c index 8d4e8cda637..89bb2b0e0c4 100644 --- a/Opcodes/squinewave.c +++ b/Opcodes/squinewave.c @@ -391,9 +391,9 @@ int32_t squinewave_gen(CSOUND* csound, SQUINEWAVE *p) static OENTRY squinewave_localops[] = { - { "squinewave", sizeof(SQUINEWAVE), 0, 3, "am", "aaaaoj", + { "squinewave", sizeof(SQUINEWAVE), 0, "am", "aaaaoj", (SUBR)squinewave_init, (SUBR)squinewave_gen }, - { "squinewave", sizeof(SQUINEWAVE), 0, 3, "am", "aaaOoj", + { "squinewave", sizeof(SQUINEWAVE), 0, "am", "aaaOoj", (SUBR)squinewave_init, (SUBR)squinewave_gen }, }; diff --git a/Opcodes/sterrain.c b/Opcodes/sterrain.c index 0ced924e7df..9fc731d4028 100644 --- a/Opcodes/sterrain.c +++ b/Opcodes/sterrain.c @@ -204,7 +204,7 @@ static int32_t wtPerf(CSOUND *csound, SUPERTER *p) #define S(x) sizeof(x) static OENTRY sterrain_localops[] = { - { "sterrain", S(SUPERTER), TR, 3, "a", "kkkkkkkkkkkkkkkkk", + { "sterrain", S(SUPERTER), TR, "a", "kkkkkkkkkkkkkkkkk", (SUBR)wtinit, (SUBR)wtPerf }, }; diff --git a/Opcodes/syncgrain.c b/Opcodes/syncgrain.c index 9907c7ce12c..8562b99608e 100644 --- a/Opcodes/syncgrain.c +++ b/Opcodes/syncgrain.c @@ -721,11 +721,11 @@ static int32_t filegrain_process(CSOUND *csound, filegrain *p) static OENTRY localops[] = { - {"syncgrain", sizeof(syncgrain), TR, 3, "a", "kkkkkiii", + {"syncgrain", sizeof(syncgrain), TR, "a", "kkkkkiii", (SUBR)syncgrain_init,(SUBR)syncgrain_process }, - {"syncloop", sizeof(syncgrainloop), TR, 3, "a", "kkkkkkkiiioo", + {"syncloop", sizeof(syncgrainloop), TR, "a", "kkkkkkkiiioo", (SUBR)syncgrainloop_init,(SUBR)syncgrainloop_process }, - {"diskgrain", sizeof(filegrain), TR, 3, DGRAIN_OUTTYPES, "Skkkkkiipo", + {"diskgrain", sizeof(filegrain), TR, DGRAIN_OUTTYPES, "Skkkkkiipo", (SUBR)filegrain_init,(SUBR)filegrain_process } }; diff --git a/Opcodes/system_call.c b/Opcodes/system_call.c index 272177c544f..0cd67418511 100644 --- a/Opcodes/system_call.c +++ b/Opcodes/system_call.c @@ -156,9 +156,9 @@ call_system_k(CSOUND *csound, void *p) #define S(x) sizeof(x) static OENTRY system_localops[] = { - { "system", S(SYSTEM), 0, 3, "k", "kSO", + { "system", S(SYSTEM), 0, "k", "kSO", (SUBR)call_system_set,(SUBR)call_system_k}, - { "system_i", S(SYSTEM), 0, 1, "i", "iSo", (SUBR)call_system_i} + { "system_i", S(SYSTEM), 0, "i", "iSo", (SUBR)call_system_i} }; LINKAGE_BUILTIN(system_localops) diff --git a/Opcodes/tabaudio.c b/Opcodes/tabaudio.c index 2b84f119b9f..e8239aa348b 100644 --- a/Opcodes/tabaudio.c +++ b/Opcodes/tabaudio.c @@ -261,8 +261,8 @@ static int32_t tabaudioi(CSOUND *csound, TABAUDIO *p) static OENTRY tabaudio_localops[] = { - { "ftaudio.i", S(TABAUDIO), TR, 1, "i", "iSioo", (SUBR)tabaudioi, NULL }, - { "ftaudio.k", S(TABAUDIOK), TR, 2, "k", "kkSkpOO", NULL, (SUBR)tabaudiok }, + { "ftaudio.i", S(TABAUDIO), TR, "i", "iSioo", (SUBR)tabaudioi, NULL }, + { "ftaudio.k", S(TABAUDIOK), TR, "k", "kkSkpOO", NULL, (SUBR)tabaudiok }, }; LINKAGE_BUILTIN(tabaudio_localops) diff --git a/Opcodes/tabsum.c b/Opcodes/tabsum.c index eb0a9badd5c..da2b6f2c09e 100644 --- a/Opcodes/tabsum.c +++ b/Opcodes/tabsum.c @@ -76,7 +76,7 @@ static int32_t tabsum(CSOUND *csound, TABSUM *p) #define S(x) sizeof(x) static OENTRY tabsum_localops[] = { -{ "tabsum", S(TABSUM), 0, 3, "k", "iOO", +{ "tabsum", S(TABSUM), 0, "k", "iOO", (SUBR)tabsuminit, (SUBR)tabsum }, }; diff --git a/Opcodes/tl/fractalnoise.cpp b/Opcodes/tl/fractalnoise.cpp index ac4a45b4513..c3d169bfcef 100644 --- a/Opcodes/tl/fractalnoise.cpp +++ b/Opcodes/tl/fractalnoise.cpp @@ -439,8 +439,6 @@ int32_t fractalnoise_init(CSOUND *csound, FRACTALNOISE *p) { p->cs_interface = new csUI; p->faust->init((int32_t)CS_ESR); p->faust->buildUserInterface(p->cs_interface); - csound->RegisterDeinitCallback( - csound, p, (int32_t (*)(CSOUND *, void *))fractalnoise_cleanup); return OK; } @@ -450,10 +448,9 @@ int32_t fractalnoise_process(CSOUND *csound, FRACTALNOISE *p) { return OK; } - -static OENTRY localops[] = {{(char *)"fractalnoise", sizeof(FRACTALNOISE), 0, 3, + static OENTRY localops[] = {{(char *)"fractalnoise", sizeof(FRACTALNOISE), 0, (char *)"a", (char *)"kk", (SUBR)fractalnoise_init, - (SUBR)fractalnoise_process}, + (SUBR)fractalnoise_process, (SUBR) fractalnoise_cleanup }, {0, 0, 0, 0, 0, 0, 0, 0, 0}}; @@ -461,11 +458,11 @@ PUBLIC int32_t csoundModuleInit_fractalnoise(CSOUND *csound) { int32_t status = 0; for (OENTRY *oentry = &localops[0]; oentry->opname; oentry++) { status |= csound->AppendOpcode(csound, oentry->opname, oentry->dsblksiz, - oentry->flags, oentry->thread, + oentry->flags, oentry->outypes, oentry->intypes, - (int32_t (*)(CSOUND *, void *))oentry->iopadr, - (int32_t (*)(CSOUND *, void *))oentry->kopadr, - (int32_t (*)(CSOUND *, void *))oentry->aopadr); + (int32_t (*)(CSOUND *, void *))oentry->init, + (int32_t (*)(CSOUND *, void *))oentry->perf, + (int32_t (*)(CSOUND *, void *))oentry->deinit); } return status; } diff --git a/Opcodes/ugakbari.c b/Opcodes/ugakbari.c index 011fc919774..5e563ee72e8 100644 --- a/Opcodes/ugakbari.c +++ b/Opcodes/ugakbari.c @@ -172,13 +172,13 @@ gainslider_perf(CSOUND *csound, gainslider *p) /* opcode library entries */ static OENTRY ugakbari_localops[] = { - { "scale", sizeof(scale), 0, 2, "k", "kkkPO", NULL, (SUBR)scale_process, NULL }, - { "scale2", sizeof(SCALE2), 0, 3, "k", "kkkOPo", (SUBR)scale2_init, (SUBR)scale2_process, NULL }, - { "expcurve", sizeof(expcurve), 0, 2, "k", "kk", NULL, + { "scale", sizeof(scale), 0, "k", "kkkPO", NULL, (SUBR)scale_process, NULL }, + { "scale2", sizeof(SCALE2), 0, "k", "kkkOPo", (SUBR)scale2_init, (SUBR)scale2_process, NULL }, + { "expcurve", sizeof(expcurve), 0, "k", "kk", NULL, (SUBR)expcurve_perf, NULL }, - { "logcurve", sizeof(logcurve), 0, 2, "k", "kk", NULL, + { "logcurve", sizeof(logcurve), 0, "k", "kk", NULL, (SUBR)logcurve_perf, NULL }, - { "gainslider", sizeof(gainslider), 0, 2, "k", "k", NULL, + { "gainslider", sizeof(gainslider), 0, "k", "k", NULL, (SUBR)gainslider_perf, NULL } }; diff --git a/Opcodes/ugens7.c b/Opcodes/ugens7.c index 4759aec7d39..8af80bd2b4a 100644 --- a/Opcodes/ugens7.c +++ b/Opcodes/ugens7.c @@ -719,10 +719,10 @@ static int32_t harmon(CSOUND *csound, HARMON *p) static OENTRY localops[] = { - { "fof", S(FOFS), TR, 3, "a","xxxkkkkkiiiiooo",(SUBR)fofset,(SUBR)fof }, - { "fof2", S(FOFS), TR, 3, "a","xxxkkkkkiiiikko",(SUBR)fofset2,(SUBR)fof }, - { "harmon", S(HARMON), 0,3, "a", "akkkkiii",(SUBR)harmset, (SUBR)harmon } - }; + { "fof", S(FOFS), TR, "a","xxxkkkkkiiiiooo",(SUBR)fofset,(SUBR)fof }, + { "fof2", S(FOFS), TR, "a","xxxkkkkkiiiikko",(SUBR)fofset2,(SUBR)fof }, + { "harmon", S(HARMON), 0, "a", "akkkkiii",(SUBR)harmset, (SUBR)harmon } +}; int32_t ugens7_init_(CSOUND *csound) { diff --git a/Opcodes/ugens9.c b/Opcodes/ugens9.c index 9ba8ad3787f..65495ff20a5 100644 --- a/Opcodes/ugens9.c +++ b/Opcodes/ugens9.c @@ -656,17 +656,17 @@ static int32_t pconvolve(CSOUND *csound, PCONVOLVE *p) static OENTRY localops[] = { - { "convolve", sizeof(CONVOLVE), 0, 3, "mmmm", "aSo", + { "convolve", sizeof(CONVOLVE), 0, "mmmm", "aSo", (SUBR) cvset_S, (SUBR) convolve }, - { "convle", sizeof(CONVOLVE), 0, 3, "mmmm", "aSo", + { "convle", sizeof(CONVOLVE), 0, "mmmm", "aSo", (SUBR) cvset_S, (SUBR) convolve }, - { "pconvolve",sizeof(PCONVOLVE), 0, 3, "mmmm", "aSoo", + { "pconvolve",sizeof(PCONVOLVE), 0, "mmmm", "aSoo", (SUBR) pconvset_S, (SUBR) pconvolve }, - { "convolve.i", sizeof(CONVOLVE), 0, 3, "mmmm", "aio", + { "convolve.i", sizeof(CONVOLVE), 0, "mmmm", "aio", (SUBR) cvset, (SUBR) convolve }, - { "convle.i", sizeof(CONVOLVE), 0, 3, "mmmm", "aio", + { "convle.i", sizeof(CONVOLVE), 0, "mmmm", "aio", (SUBR) cvset, (SUBR) convolve }, - { "pconvolve.i",sizeof(PCONVOLVE), 0, 3, "mmmm", "aioo", + { "pconvolve.i",sizeof(PCONVOLVE), 0, "mmmm", "aioo", (SUBR) pconvset, (SUBR) pconvolve } }; diff --git a/Opcodes/ugensa.c b/Opcodes/ugensa.c index 3d19c30f820..2a5ad985e69 100644 --- a/Opcodes/ugensa.c +++ b/Opcodes/ugensa.c @@ -320,7 +320,7 @@ static int32_t newpulse(CSOUND *csound, FOGS *p, OVERLAP *ovp, MYFLT *amp, #define S(x) sizeof(x) static OENTRY localops[] = { - { "fog", S(FOGS), TR, 3, "a","xxxakkkkkiiiiooo",(SUBR)fogset,(SUBR)fog} + { "fog", S(FOGS), TR, "a","xxxakkkkkiiiiooo",(SUBR)fogset,(SUBR)fog} }; int32_t ugensa_init_(CSOUND *csound) diff --git a/Opcodes/uggab.c b/Opcodes/uggab.c index b2708b018b4..40565bc4be8 100644 --- a/Opcodes/uggab.c +++ b/Opcodes/uggab.c @@ -1520,68 +1520,67 @@ static int32_t random3a(CSOUND *csound, RANDOM3 *p) #define S(x) sizeof(x) static OENTRY localops[] = { -{ "wrap", 0xffff }, -{ "wrap.i", S(WRAP), 0,1, "i", "iii", (SUBR)kwrap, NULL, NULL }, -{ "wrap.k", S(WRAP), 0,2, "k", "kkk", NULL, (SUBR)kwrap, NULL }, -{ "wrap.a", S(WRAP), 0,2, "a", "akk", NULL, (SUBR)wrap }, +{ "wrap.i", S(WRAP), 0, "i", "iii", (SUBR)kwrap, NULL, NULL }, +{ "wrap.k", S(WRAP), 0, "k", "kkk", NULL, (SUBR)kwrap, NULL }, +{ "wrap.a", S(WRAP), 0, "a", "akk", NULL, (SUBR)wrap }, { "mirror", 0xffff }, -{ "mirror.i", S(WRAP), 0,1, "i", "iii", (SUBR)kmirror, NULL, NULL }, -{ "mirror.k", S(WRAP), 0,2, "k", "kkk", NULL, (SUBR)kmirror, NULL }, -{ "mirror.a", S(WRAP), 0,2, "a", "akk", NULL, (SUBR)mirror }, -{ "ntrpol.i",S(INTERPOL), 0,1, "i", "iiiop",(SUBR)interpol }, -{ "ntrpol.k",S(INTERPOL), 0,3, "k", "kkkop",(SUBR)nterpol_init, (SUBR)knterpol }, -{ "ntrpol.a",S(INTERPOL), 0,3, "a", "aakop",(SUBR)nterpol_init,(SUBR)anterpol}, -{ "fold", S(FOLD), 0,3, "a", "ak", (SUBR)fold_set, (SUBR)fold }, -{ "lineto", S(LINETO), 0,3, "k", "kk", (SUBR)lineto_set, (SUBR)lineto, NULL }, -{ "tlineto", S(LINETO2), 0,3, "k", "kkk", (SUBR)tlineto_set, (SUBR)tlineto, NULL}, -{ "vibrato", S(VIBRATO), TR, 3, "k", "kkkkkkkkio", +{ "mirror.i", S(WRAP), 0, "i", "iii", (SUBR)kmirror, NULL, NULL }, +{ "mirror.k", S(WRAP), 0, "k", "kkk", NULL, (SUBR)kmirror, NULL }, +{ "mirror.a", S(WRAP), 0, "a", "akk", NULL, (SUBR)mirror }, +{ "ntrpol.i",S(INTERPOL), 0, "i", "iiiop",(SUBR)interpol }, +{ "ntrpol.k",S(INTERPOL), 0, "k", "kkkop",(SUBR)nterpol_init, (SUBR)knterpol }, +{ "ntrpol.a",S(INTERPOL), 0, "a", "aakop",(SUBR)nterpol_init,(SUBR)anterpol}, +{ "fold", S(FOLD), 0, "a", "ak", (SUBR)fold_set, (SUBR)fold }, +{ "lineto", S(LINETO), 0, "k", "kk", (SUBR)lineto_set, (SUBR)lineto, NULL }, +{ "tlineto", S(LINETO2), 0, "k", "kkk", (SUBR)tlineto_set, (SUBR)tlineto, NULL}, +{ "vibrato", S(VIBRATO), TR, "k", "kkkkkkkkio", (SUBR)vibrato_set, (SUBR)vibrato, NULL }, -{ "vibr", S(VIBRATO), TR, 3, "k", "kki", (SUBR)vibr_set, (SUBR)vibr, NULL }, -{ "jitter2", S(JITTER2), 0,3, "k", "kkkkkkko", (SUBR)jitter2_set, (SUBR)jitter2 }, -{ "jitter", S(JITTER), 0,3, "k", "kkk", (SUBR)jitter_set, (SUBR)jitter, NULL }, -{ "jspline", S(JITTERS), 0,3, "k", "xkk", +{ "vibr", S(VIBRATO), TR, "k", "kki", (SUBR)vibr_set, (SUBR)vibr, NULL }, +{ "jitter2", S(JITTER2), 0, "k", "kkkkkkko", (SUBR)jitter2_set, (SUBR)jitter2 }, +{ "jitter", S(JITTER), 0, "k", "kkk", (SUBR)jitter_set, (SUBR)jitter, NULL }, +{ "jspline", S(JITTERS), 0, "k", "xkk", (SUBR)jitters_set, (SUBR)jitters, NULL }, -{ "jspline.a", S(JITTERS), 0,3, "a", "xkk", +{ "jspline.a", S(JITTERS), 0, "a", "xkk", (SUBR)jitters_set, (SUBR)jittersa }, -{ "loopseg", S(LOOPSEG), 0,3, "k", "kkiz", (SUBR)loopseg_set, (SUBR)loopseg, NULL}, -{ "loopxseg", S(LOOPSEG), 0,3, "k", "kkiz", (SUBR)loopseg_set,(SUBR)loopxseg, NULL}, -{ "looptseg", S(LOOPSEG), 0,3, "k", "kkiz",(SUBR)looptseg_set,(SUBR)looptseg, NULL}, -{ "lpshold", S(LOOPSEG), 0,3, "k", "kkiz",(SUBR)loopseg_set, (SUBR)lpshold, NULL }, -{ "loopsegp", S(LOOPSEGP), 0,3,"k", "kz", (SUBR)loopsegp_set,(SUBR)loopsegp, NULL}, -{ "lpsholdp", S(LOOPSEGP), 0,3,"k", "kz", (SUBR)loopsegp_set,(SUBR)lpsholdp, NULL}, -{ "cuserrnd.i", S(CURAND),0,1,"i", "iii", (SUBR)iContinuousUserRand, NULL, NULL }, -{ "cuserrnd.k", S(CURAND),0,2,"k", "kkk", +{ "loopseg", S(LOOPSEG), 0, "k", "kkiz", (SUBR)loopseg_set, (SUBR)loopseg, NULL}, +{ "loopxseg", S(LOOPSEG), 0, "k", "kkiz", (SUBR)loopseg_set,(SUBR)loopxseg, NULL}, +{ "looptseg", S(LOOPSEG), 0, "k", "kkiz",(SUBR)looptseg_set,(SUBR)looptseg, NULL}, +{ "lpshold", S(LOOPSEG), 0, "k", "kkiz",(SUBR)loopseg_set, (SUBR)lpshold, NULL }, +{ "loopsegp", S(LOOPSEGP), 0,"k", "kz", (SUBR)loopsegp_set,(SUBR)loopsegp, NULL}, +{ "lpsholdp", S(LOOPSEGP), 0,"k", "kz", (SUBR)loopsegp_set,(SUBR)lpsholdp, NULL}, +{ "cuserrnd.i", S(CURAND),0,"i", "iii", (SUBR)iContinuousUserRand, NULL, NULL }, +{ "cuserrnd.k", S(CURAND),0,"k", "kkk", (SUBR)Cuserrnd_set, (SUBR)kContinuousUserRand, NULL }, -{ "cuserrnd.a",S(CURAND),0,2, "a", "kkk", +{ "cuserrnd.a",S(CURAND),0, "a", "kkk", (SUBR)Cuserrnd_set, (SUBR)aContinuousUserRand }, -{ "random.i", S(RANGERAND), 0,1, "i", "ii", (SUBR)ikRangeRand, NULL, NULL }, -{ "random.k", S(RANGERAND), 0,2, "k", "kk", NULL, (SUBR)ikRangeRand, NULL }, -{ "random.a", S(RANGERAND), 0,2, "a", "kk", NULL, (SUBR)aRangeRand }, -{ "rspline", S(RANDOM3), 0,3, "k", "xxkk", +{ "random.i", S(RANGERAND), 0, "i", "ii", (SUBR)ikRangeRand, NULL, NULL }, +{ "random.k", S(RANGERAND), 0, "k", "kk", NULL, (SUBR)ikRangeRand, NULL }, +{ "random.a", S(RANGERAND), 0, "a", "kk", NULL, (SUBR)aRangeRand }, +{ "rspline", S(RANDOM3), 0, "k", "xxkk", (SUBR)random3_set, (SUBR)random3, NULL }, -{ "rspline.a", S(RANDOM3), 0,3, "a", "xxkk", +{ "rspline.a", S(RANDOM3), 0, "a", "xxkk", (SUBR)random3_set, (SUBR)random3a }, -{ "randomi", S(RANDOMI), 0,3, "a", "kkxoo", +{ "randomi", S(RANDOMI), 0, "a", "kkxoo", (SUBR)randomi_set, (SUBR)randomi }, -{ "randomi.k", S(RANDOMI), 0,3, "k", "kkkoo", +{ "randomi.k", S(RANDOMI), 0, "k", "kkkoo", (SUBR)randomi_set, (SUBR)krandomi,NULL }, -{ "randomh", S(RANDOMH), 0,3, "a", "kkxoo", +{ "randomh", S(RANDOMH), 0, "a", "kkxoo", (SUBR)randomh_set,(SUBR)randomh }, -{ "randomh.k", S(RANDOMH), 0,3, "k", "kkkoo", +{ "randomh.k", S(RANDOMH), 0, "k", "kkkoo", (SUBR)randomh_set,(SUBR)krandomh,NULL}, -{ "urd.i", S(DURAND), 0,1, "i", "i", (SUBR)iDiscreteUserRand, NULL, NULL }, -{ "urd.k", S(DURAND), 0,2, "k", "k", (SUBR)Cuserrnd_set,(SUBR)kDiscreteUserRand }, -{ "urd.a", S(DURAND), 0,2, "a", "k", +{ "urd.i", S(DURAND), 0, "i", "i", (SUBR)iDiscreteUserRand, NULL, NULL }, +{ "urd.k", S(DURAND), 0, "k", "k", (SUBR)Cuserrnd_set,(SUBR)kDiscreteUserRand }, +{ "urd.a", S(DURAND), 0, "a", "k", (SUBR)Cuserrnd_set, (SUBR)aDiscreteUserRand }, -{ "duserrnd.i", S(DURAND),0,1, "i", "i", (SUBR)iDiscreteUserRand, NULL, NULL }, -{ "duserrnd.k", S(DURAND),0,2, "k", "k", +{ "duserrnd.i", S(DURAND),0, "i", "i", (SUBR)iDiscreteUserRand, NULL, NULL }, +{ "duserrnd.k", S(DURAND),0, "k", "k", (SUBR)Cuserrnd_set,(SUBR)kDiscreteUserRand,NULL }, -{ "duserrnd.a", S(DURAND),0,2, "a", "k", +{ "duserrnd.a", S(DURAND),0, "a", "k", (SUBR)Cuserrnd_set,(SUBR)aDiscreteUserRand }, -{ "trigger", S(TRIG), 0,3, "k", "kkk", (SUBR)trig_set, (SUBR)trig, NULL }, -{ "sum", S(SUM), 0,3, "a", "y", (SUBR)sum_init, (SUBR)sum_ }, -{ "product", S(SUM), 0,2, "a", "y", NULL, (SUBR)product }, -{ "resony", S(RESONY), 0,3, "a", "akkikooo", (SUBR)rsnsety, (SUBR)resony } +{ "trigger", S(TRIG), 0, "k", "kkk", (SUBR)trig_set, (SUBR)trig, NULL }, +{ "sum", S(SUM), 0, "a", "y", (SUBR)sum_init, (SUBR)sum_ }, +{ "product", S(SUM), 0, "a", "y", NULL, (SUBR)product }, +{ "resony", S(RESONY), 0, "a", "akkikooo", (SUBR)rsnsety, (SUBR)resony } }; int32_t uggab_init_(CSOUND *csound) diff --git a/Opcodes/ugmoss.c b/Opcodes/ugmoss.c index d51dbd7342c..bc0c7ac3fa7 100644 --- a/Opcodes/ugmoss.c +++ b/Opcodes/ugmoss.c @@ -883,38 +883,38 @@ static int32_t ftmorf(CSOUND *csound, FTMORF *p) static OENTRY localops[] = { - { "dconv", S(DCONV), TR, 3, "a", "aii", (SUBR)dconvset, (SUBR)dconv }, - { "vcomb", S(VCOMB), 0,3, "a", "akxioo", (SUBR)vcombset, (SUBR)vcomb }, - { "valpass", S(VCOMB),0,3, "a", "akxioo", (SUBR)vcombset, (SUBR)valpass }, - { "ftmorf", S(FTMORF),TR, 3, "", "kii", (SUBR)ftmorfset, (SUBR)ftmorf, }, - { "##and.ii", S(AOP), 0,1, "i", "ii", (SUBR)and_kk }, - { "##and.kk", S(AOP), 0,2, "k", "kk", NULL, (SUBR)and_kk }, - { "##and.ka", S(AOP), 0,2, "a", "ka", NULL, (SUBR)and_ka }, - { "##and.ak", S(AOP), 0,2, "a", "ak", NULL, (SUBR)and_ak }, - { "##and.aa", S(AOP), 0,2, "a", "aa", NULL, (SUBR)and_aa }, - { "##or.ii", S(AOP), 0,1, "i", "ii", (SUBR)or_kk }, - { "##or.kk", S(AOP), 0,2, "k", "kk", NULL, (SUBR)or_kk }, - { "##or.ka", S(AOP), 0,2, "a", "ka", NULL, (SUBR)or_ka }, - { "##or.ak", S(AOP), 0,2, "a", "ak", NULL, (SUBR)or_ak }, - { "##or.aa", S(AOP), 0,2, "a", "aa", NULL, (SUBR)or_aa }, - { "##xor.ii", S(AOP), 0,1, "i", "ii", (SUBR)xor_kk }, - { "##xor.kk", S(AOP), 0,2, "k", "kk", NULL, (SUBR)xor_kk }, - { "##xor.ka", S(AOP), 0,2, "a", "ka", NULL, (SUBR)xor_ka }, - { "##xor.ak", S(AOP), 0,2, "a", "ak", NULL, (SUBR)xor_ak }, - { "##xor.aa", S(AOP), 0,2, "a", "aa", NULL, (SUBR)xor_aa }, - { "##not.i", S(AOP), 0,1, "i", "i", (SUBR)not_k }, - { "##not.k", S(AOP), 0,2, "k", "k", NULL, (SUBR)not_k }, - { "##not.a", S(AOP), 0,2, "a", "a", NULL, (SUBR)not_a }, - { "##shl.ii", S(AOP), 0,1, "i", "ii", (SUBR) shift_left_kk }, - { "##shl.kk", S(AOP), 0,2, "k", "kk", NULL, (SUBR) shift_left_kk }, - { "##shl.ka", S(AOP), 0,2, "a", "ka", NULL, (SUBR) shift_left_ka }, - { "##shl.ak", S(AOP), 0,2, "a", "ak", NULL, (SUBR) shift_left_ak }, - { "##shl.aa", S(AOP), 0,2, "a", "aa", NULL, (SUBR) shift_left_aa }, - { "##shr.ii", S(AOP), 0,1, "i", "ii", (SUBR) shift_right_kk }, - { "##shr.kk", S(AOP), 0,2, "k", "kk", NULL, (SUBR) shift_right_kk }, - { "##shr.ka", S(AOP), 0,2, "a", "ka", NULL, (SUBR) shift_right_ka }, - { "##shr.ak", S(AOP), 0,2, "a", "ak", NULL, (SUBR) shift_right_ak }, - { "##shr.aa", S(AOP), 0,2, "a", "aa", NULL, (SUBR) shift_right_aa } + { "dconv", S(DCONV), TR, "a", "aii", (SUBR)dconvset, (SUBR)dconv }, + { "vcomb", S(VCOMB), 0, "a", "akxioo", (SUBR)vcombset, (SUBR)vcomb }, + { "valpass", S(VCOMB),0, "a", "akxioo", (SUBR)vcombset, (SUBR)valpass }, + { "ftmorf", S(FTMORF),TR, "", "kii", (SUBR)ftmorfset, (SUBR)ftmorf, }, + { "##and.ii", S(AOP), 0, "i", "ii", (SUBR)and_kk }, + { "##and.kk", S(AOP), 0, "k", "kk", NULL, (SUBR)and_kk }, + { "##and.ka", S(AOP), 0, "a", "ka", NULL, (SUBR)and_ka }, + { "##and.ak", S(AOP), 0, "a", "ak", NULL, (SUBR)and_ak }, + { "##and.aa", S(AOP), 0, "a", "aa", NULL, (SUBR)and_aa }, + { "##or.ii", S(AOP), 0, "i", "ii", (SUBR)or_kk }, + { "##or.kk", S(AOP), 0, "k", "kk", NULL, (SUBR)or_kk }, + { "##or.ka", S(AOP), 0, "a", "ka", NULL, (SUBR)or_ka }, + { "##or.ak", S(AOP), 0, "a", "ak", NULL, (SUBR)or_ak }, + { "##or.aa", S(AOP), 0, "a", "aa", NULL, (SUBR)or_aa }, + { "##xor.ii", S(AOP), 0, "i", "ii", (SUBR)xor_kk }, + { "##xor.kk", S(AOP), 0, "k", "kk", NULL, (SUBR)xor_kk }, + { "##xor.ka", S(AOP), 0, "a", "ka", NULL, (SUBR)xor_ka }, + { "##xor.ak", S(AOP), 0, "a", "ak", NULL, (SUBR)xor_ak }, + { "##xor.aa", S(AOP), 0, "a", "aa", NULL, (SUBR)xor_aa }, + { "##not.i", S(AOP), 0, "i", "i", (SUBR)not_k }, + { "##not.k", S(AOP), 0, "k", "k", NULL, (SUBR)not_k }, + { "##not.a", S(AOP), 0, "a", "a", NULL, (SUBR)not_a }, + { "##shl.ii", S(AOP), 0, "i", "ii", (SUBR) shift_left_kk }, + { "##shl.kk", S(AOP), 0, "k", "kk", NULL, (SUBR) shift_left_kk }, + { "##shl.ka", S(AOP), 0, "a", "ka", NULL, (SUBR) shift_left_ka }, + { "##shl.ak", S(AOP), 0, "a", "ak", NULL, (SUBR) shift_left_ak }, + { "##shl.aa", S(AOP), 0, "a", "aa", NULL, (SUBR) shift_left_aa }, + { "##shr.ii", S(AOP), 0, "i", "ii", (SUBR) shift_right_kk }, + { "##shr.kk", S(AOP), 0, "k", "kk", NULL, (SUBR) shift_right_kk }, + { "##shr.ka", S(AOP), 0, "a", "ka", NULL, (SUBR) shift_right_ka }, + { "##shr.ak", S(AOP), 0, "a", "ak", NULL, (SUBR) shift_right_ak }, + { "##shr.aa", S(AOP), 0, "a", "aa", NULL, (SUBR) shift_right_aa } }; int32_t ugmoss_init_(CSOUND *csound) diff --git a/Opcodes/ugnorman.c b/Opcodes/ugnorman.c index 01736788566..6b2b6bc8b5a 100644 --- a/Opcodes/ugnorman.c +++ b/Opcodes/ugnorman.c @@ -2982,47 +2982,47 @@ static int32_t atscross(CSOUND *csound, ATSCROSS *p) #define S(x) sizeof(x) static OENTRY localops[] = { - { "ATSread", S(ATSREAD), 0, 3, "kk", "kSi", - (SUBR) atsreadset_S, (SUBR) atsread, (SUBR) NULL }, - { "ATSread.i", S(ATSREAD), 0, 3, "kk", "kii", - (SUBR) atsreadset, (SUBR) atsread, (SUBR) NULL }, - { "ATSreadnz", S(ATSREADNZ), 0, 3, "k", "kSi", - (SUBR) atsreadnzset_S, (SUBR) atsreadnz, (SUBR) NULL }, - { "ATSreadnz.i", S(ATSREADNZ), 0, 3, "k", "kii", - (SUBR) atsreadnzset, (SUBR) atsreadnz, (SUBR) NULL }, - { "ATSadd", S(ATSADD), TR, 3, "a", "kkSiiopo", - (SUBR) atsaddset_S, (SUBR) atsadd }, - { "ATSadd.i", S(ATSADD), TR, 3, "a", "kkiiiopo", - (SUBR) atsaddset, (SUBR) atsadd }, - { "ATSaddnz", S(ATSADDNZ), 0, 3, "a", "kSiop", - (SUBR) atsaddnzset_S, (SUBR) atsaddnz }, - { "ATSaddnz.i", S(ATSADDNZ), 0, 3, "a", "kiiop", - (SUBR) atsaddnzset, (SUBR) atsaddnz }, - { "ATSsinnoi", S(ATSSINNOI), 0,3, "a", "kkkkSiop", - (SUBR) atssinnoiset_S, (SUBR) atssinnoi }, - { "ATSsinnoi.i", S(ATSSINNOI), 0,3, "a", "kkkkiiop", - (SUBR) atssinnoiset, (SUBR) atssinnoi }, - { "ATSbufread", S(ATSBUFREAD), TW,3, "", "kkSiop", - (SUBR) atsbufreadset_S, (SUBR) atsbufread, (SUBR) NULL }, - { "ATSbufread.i", S(ATSBUFREAD), TW,3, "", "kkiiop", - (SUBR) atsbufreadset, (SUBR) atsbufread, (SUBR) NULL }, - { "ATSpartialtap", S(ATSPARTIALTAP), 0,3, "kk", "i", - (SUBR) atspartialtapset, (SUBR) atspartialtap, (SUBR) NULL }, - { "ATSinterpread", S(ATSINTERPREAD), 0,3, "k", "k", - (SUBR) atsinterpreadset, (SUBR) atsinterpread, (SUBR) NULL }, - { "ATScross", S(ATSCROSS), TR, 3, "a", "kkSikkiopoo", - (SUBR) atscrossset_S, (SUBR) atscross }, - { "ATSinfo", S(ATSINFO), 0,1, "i", "Si", - (SUBR) atsinfo_S, (SUBR) NULL, (SUBR) NULL }, - { "ATScross.i", S(ATSCROSS), TR, 3, "a", "kkiikkiopoo", - (SUBR) atscrossset, (SUBR) atscross }, - { "ATSinfo.i", S(ATSINFO), 0,1, "i", "ii", - (SUBR) atsinfo, (SUBR) NULL, (SUBR) NULL } + { "ATSread", S(ATSREAD), 0, "kk", "kSi", + (SUBR) atsreadset_S, (SUBR) atsread, (SUBR) NULL }, + { "ATSread.i", S(ATSREAD), 0, "kk", "kii", + (SUBR) atsreadset, (SUBR) atsread, (SUBR) NULL }, + { "ATSreadnz", S(ATSREADNZ), 0, "k", "kSi", + (SUBR) atsreadnzset_S, (SUBR) atsreadnz, (SUBR) NULL }, + { "ATSreadnz.i", S(ATSREADNZ), 0, "k", "kii", + (SUBR) atsreadnzset, (SUBR) atsreadnz, (SUBR) NULL }, + { "ATSadd", S(ATSADD), TR, "a", "kkSiiopo", + (SUBR) atsaddset_S, (SUBR) atsadd }, + { "ATSadd.i", S(ATSADD), TR, "a", "kkiiiopo", + (SUBR) atsaddset, (SUBR) atsadd }, + { "ATSaddnz", S(ATSADDNZ), 0, "a", "kSiop", + (SUBR) atsaddnzset_S, (SUBR) atsaddnz }, + { "ATSaddnz.i", S(ATSADDNZ), 0, "a", "kiiop", + (SUBR) atsaddnzset, (SUBR) atsaddnz }, + { "ATSsinnoi", S(ATSSINNOI), 0, "a", "kkkkSiop", + (SUBR) atssinnoiset_S, (SUBR) atssinnoi }, + { "ATSsinnoi.i", S(ATSSINNOI), 0, "a", "kkkkiiop", + (SUBR) atssinnoiset, (SUBR) atssinnoi }, + { "ATSbufread", S(ATSBUFREAD), TW, "", "kkSiop", + (SUBR) atsbufreadset_S, (SUBR) atsbufread, (SUBR) NULL }, + { "ATSbufread.i", S(ATSBUFREAD), TW, "", "kkiiop", + (SUBR) atsbufreadset, (SUBR) atsbufread, (SUBR) NULL }, + { "ATSpartialtap", S(ATSPARTIALTAP), 0, "kk", "i", + (SUBR) atspartialtapset, (SUBR) atspartialtap, (SUBR) NULL }, + { "ATSinterpread", S(ATSINTERPREAD), 0, "k", "k", + (SUBR) atsinterpreadset, (SUBR) atsinterpread, (SUBR) NULL }, + { "ATScross", S(ATSCROSS), TR, "a", "kkSikkiopoo", + (SUBR) atscrossset_S, (SUBR) atscross }, + { "ATSinfo", S(ATSINFO), 0, "i", "Si", + (SUBR) atsinfo_S, (SUBR) NULL, (SUBR) NULL }, + { "ATScross.i", S(ATSCROSS), TR, "a", "kkiikkiopoo", + (SUBR) atscrossset, (SUBR) atscross }, + { "ATSinfo.i", S(ATSINFO), 0, "i", "ii", + (SUBR) atsinfo, (SUBR) NULL, (SUBR) NULL } }; int32_t ugnorman_init_(CSOUND *csound) { - return csound->AppendOpcodes(csound, &(localops[0]), + return csound->AppendOpcodes(csound, &(localops[0]), (int32_t ) (sizeof(localops) / sizeof(OENTRY))); } diff --git a/Opcodes/ugsc.c b/Opcodes/ugsc.c index 28ce3e9c656..6b6ca95797c 100644 --- a/Opcodes/ugsc.c +++ b/Opcodes/ugsc.c @@ -725,16 +725,16 @@ static int32_t lp2ak(CSOUND *csound, LP2 *p) static OENTRY localops[] = { - { "svfilter", S(SVF), 0, 3, "aaa", "axxoo",(SUBR)svfset, (SUBR)svf }, - { "hilbert", S(HILBERT), 0,3, "aa", "a", (SUBR)hilbertset, (SUBR)hilbert }, - { "resonr", S(RESONZ), 0,3, "a", "axxoo", (SUBR)resonzset, (SUBR)resonr}, - { "resonz", S(RESONZ), 0,3, "a", "axxoo", (SUBR)resonzset, (SUBR)resonz}, - { "lowpass2.kk", S(LP2), 0,3, "a", "akko", (SUBR)lp2_set, (SUBR)lp2 }, - { "lowpass2.aa", S(LP2), 0,3, "a", "aaao", (SUBR)lp2_set, (SUBR)lp2aa }, - { "lowpass2.ak", S(LP2), 0,3, "a", "aakao", (SUBR)lp2_set, (SUBR)lp2ak }, - { "lowpass2.ka", S(LP2), 0,3, "a", "akao", (SUBR)lp2_set, (SUBR)lp2ka }, - { "phaser2", S(PHASER2), 0,3, "a", "akkkkkko",(SUBR)phaser2set,(SUBR)phaser2}, - { "phaser1", S(PHASER1), 0,3, "a", "akkko", (SUBR)phaser1set,(SUBR)phaser1} + { "svfilter", S(SVF), 0, "aaa", "axxoo",(SUBR)svfset, (SUBR)svf }, + { "hilbert", S(HILBERT), 0, "aa", "a", (SUBR)hilbertset, (SUBR)hilbert }, + { "resonr", S(RESONZ), 0, "a", "axxoo", (SUBR)resonzset, (SUBR)resonr}, + { "resonz", S(RESONZ), 0, "a", "axxoo", (SUBR)resonzset, (SUBR)resonz}, + { "lowpass2.kk", S(LP2), 0, "a", "akko", (SUBR)lp2_set, (SUBR)lp2 }, + { "lowpass2.aa", S(LP2), 0, "a", "aaao", (SUBR)lp2_set, (SUBR)lp2aa }, + { "lowpass2.ak", S(LP2), 0, "a", "aakao", (SUBR)lp2_set, (SUBR)lp2ak }, + { "lowpass2.ka", S(LP2), 0, "a", "akao", (SUBR)lp2_set, (SUBR)lp2ka }, + { "phaser2", S(PHASER2), 0, "a", "akkkkkko",(SUBR)phaser2set,(SUBR)phaser2}, + { "phaser1", S(PHASER1), 0, "a", "akkko", (SUBR)phaser1set,(SUBR)phaser1} }; int32_t ugsc_init_(CSOUND *csound) diff --git a/Opcodes/urandom.c b/Opcodes/urandom.c index 186670b15bf..09c9d1c7779 100644 --- a/Opcodes/urandom.c +++ b/Opcodes/urandom.c @@ -58,8 +58,6 @@ static int32_t urand_init(CSOUND *csound, URANDOM *p) int32_t ur = open("/dev/urandom", O_RDONLY); if (UNLIKELY(ur<0)) return NOTOK; p->ur = ur; - csound->RegisterDeinitCallback(csound, p, - (int32_t (*)(CSOUND *, void *)) urand_deinit); p->mul = FL(0.5)*(*p->imax - *p->imin); p->add = FL(0.5)*(*p->imax + *p->imin); return OK; @@ -113,10 +111,10 @@ static int32_t urand_arun(CSOUND *csound, URANDOM *p) #define S(x) sizeof(x) static OENTRY urandom_localops[] = { - { "urandom.i", S(URANDOM), 0, 1, "i", "jp", (SUBR) urand_irate }, - { "urandom.k", S(URANDOM), 0, 3, "k", "jp", (SUBR) urand_init, (SUBR) urand_run}, - { "urandom.a", S(URANDOM), 0, 3, "a", "jp", - (SUBR) urand_init, (SUBR) urand_arun} + { "urandom.i", S(URANDOM), 0, "i", "jp", (SUBR) urand_irate }, + { "urandom.k", S(URANDOM), 0, "k", "jp", (SUBR) urand_init, (SUBR) urand_run, (SUBR) urand_deinit}, + { "urandom.a", S(URANDOM), 0, "a", "jp", + (SUBR) urand_init, (SUBR) urand_arun, (SUBR) urand_deinit} }; LINKAGE_BUILTIN(urandom_localops) diff --git a/Opcodes/vaops.c b/Opcodes/vaops.c index 9b417800aeb..90bb974766c 100644 --- a/Opcodes/vaops.c +++ b/Opcodes/vaops.c @@ -104,10 +104,10 @@ static int32_t vasigset(CSOUND *csound, VASIG_SET *p) #define S(x) sizeof(x) static OENTRY vaops_localops[] = { - { "vaget", S(VA_GET), 0, 2, "k", "ka", NULL, (SUBR)vaget }, - { "vaset", S(VA_SET), WI, 2, "", "kka", NULL, (SUBR)vaset }, - { "##array_get", S(VASIG_GET), 0, 2, "k", "ak", NULL, (SUBR)vasigget }, - { "##array_set", S(VASIG_SET), 0, 2, "", "akk", NULL, (SUBR)vasigset } + { "vaget", S(VA_GET), 0, "k", "ka", NULL, (SUBR)vaget }, + { "vaset", S(VA_SET), WI, "", "kka", NULL, (SUBR)vaset }, + { "##array_get", S(VASIG_GET), 0, "k", "ak", NULL, (SUBR)vasigget }, + { "##array_set", S(VASIG_SET), 0, "", "akk", NULL, (SUBR)vasigset } }; diff --git a/Opcodes/vbap.c b/Opcodes/vbap.c index 47f434fd248..e3d494f63fa 100644 --- a/Opcodes/vbap.c +++ b/Opcodes/vbap.c @@ -1,31 +1,31 @@ /* - vbap.c: + vbap.c: - Copyright (C) 2000 Ville Pulkki + Copyright (C) 2000 Ville Pulkki - This file is part of Csound. + This file is part of Csound. - The Csound Library is free software; you can redistribute it - and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + The Csound Library is free software; you can redistribute it + and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - Csound is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. + Csound is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with Csound; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - 02110-1301 USA + You should have received a copy of the GNU Lesser General Public + License along with Csound; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + 02110-1301 USA */ /* vbap.c -assisting functions for VBAP -functions for loudspeaker table initialization -Re-written to take flexible number of outputs by JPff 2012 */ + assisting functions for VBAP + functions for loudspeaker table initialization + Re-written to take flexible number of outputs by JPff 2012 */ #ifdef BUILD_PLUGINS @@ -61,185 +61,185 @@ static void sort_2D_lss(ls lss[], int32_t sorted_lss[], static inline MYFLT vec_prod(CART_VEC v1, CART_VEC v2) { - return (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z); + return (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z); } static inline MYFLT vec_length(CART_VEC v1) { - return SQRT(v1.x*v1.x + v1.y*v1.y + v1.z*v1.z); + return SQRT(v1.x*v1.x + v1.y*v1.y + v1.z*v1.z); } static MYFLT *create_ls_table(CSOUND *csound, size_t cnt, int32_t ind) { - char name[24]; - snprintf(name, 24, "vbap_ls_table_%d", ind); - csound->DestroyGlobalVariable(csound, name); - if (UNLIKELY(csound->CreateGlobalVariable(csound, name, - cnt * sizeof(MYFLT)) != 0)) { - csound->ErrorMsg(csound, "%s", Str("vbap: error allocating loudspeaker table")); - return NULL; - } - return (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, name)); + char name[24]; + snprintf(name, 24, "vbap_ls_table_%d", ind); + csound->DestroyGlobalVariable(csound, name); + if (UNLIKELY(csound->CreateGlobalVariable(csound, name, + cnt * sizeof(MYFLT)) != 0)) { + csound->ErrorMsg(csound, "%s", Str("vbap: error allocating loudspeaker table")); + return NULL; + } + return (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, name)); } void calc_vbap_gns(int32_t ls_set_am, int32_t dim, LS_SET *sets, MYFLT *gains, int32_t ls_amount, CART_VEC cart_dir) - /* Selects a vector base of a virtual source. - Calculates gain factors in that base. */ +/* Selects a vector base of a virtual source. + Calculates gain factors in that base. */ { - int32_t i,j,k, tmp2; - MYFLT vec[3], tmp; - /* direction of the virtual source in cartesian coordinates*/ - vec[0] = cart_dir.x; - vec[1] = cart_dir.y; - vec[2] = cart_dir.z; - - - for (i=0; i< ls_set_am; i++) { - sets[i].set_gains[0] = FL(0.0); - sets[i].set_gains[1] = FL(0.0); - sets[i].set_gains[2] = FL(0.0); - sets[i].smallest_wt = FL(1000.0); - sets[i].neg_g_am = 0; - } - - for (i=0; i< ls_set_am; i++) { - for (j=0; j< dim; j++) { - for (k=0; k< dim; k++) { - sets[i].set_gains[j] += vec[k] * sets[i].ls_mx[((dim * j )+ k)]; - } - if (sets[i].smallest_wt > sets[i].set_gains[j]) - sets[i].smallest_wt = sets[i].set_gains[j]; - if (sets[i].set_gains[j] < -FL(0.05)) - sets[i].neg_g_am++; + int32_t i,j,k, tmp2; + MYFLT vec[3], tmp; + /* direction of the virtual source in cartesian coordinates*/ + vec[0] = cart_dir.x; + vec[1] = cart_dir.y; + vec[2] = cart_dir.z; + + + for (i=0; i< ls_set_am; i++) { + sets[i].set_gains[0] = FL(0.0); + sets[i].set_gains[1] = FL(0.0); + sets[i].set_gains[2] = FL(0.0); + sets[i].smallest_wt = FL(1000.0); + sets[i].neg_g_am = 0; + } + + for (i=0; i< ls_set_am; i++) { + for (j=0; j< dim; j++) { + for (k=0; k< dim; k++) { + sets[i].set_gains[j] += vec[k] * sets[i].ls_mx[((dim * j )+ k)]; } + if (sets[i].smallest_wt > sets[i].set_gains[j]) + sets[i].smallest_wt = sets[i].set_gains[j]; + if (sets[i].set_gains[j] < -FL(0.05)) + sets[i].neg_g_am++; } + } - j=0; - tmp = sets[0].smallest_wt; - tmp2=sets[0].neg_g_am; - for (i=1; i< ls_set_am; i++) { - if (sets[i].neg_g_am < tmp2) { + j=0; + tmp = sets[0].smallest_wt; + tmp2=sets[0].neg_g_am; + for (i=1; i< ls_set_am; i++) { + if (sets[i].neg_g_am < tmp2) { + tmp = sets[i].smallest_wt; + tmp2=sets[i].neg_g_am; + j=i; + } + else if (sets[i].neg_g_am == tmp2) { + if (sets[i].smallest_wt > tmp) { tmp = sets[i].smallest_wt; tmp2=sets[i].neg_g_am; j=i; } - else if (sets[i].neg_g_am == tmp2) { - if (sets[i].smallest_wt > tmp) { - tmp = sets[i].smallest_wt; - tmp2=sets[i].neg_g_am; - j=i; - } - } } + } - if (sets[j].set_gains[0]<=FL(0.0) && - sets[j].set_gains[1]<=FL(0.0) && - sets[j].set_gains[2]<=FL(0.0)) { - sets[j].set_gains[0] = FL(1.0); - sets[j].set_gains[1] = FL(1.0); - sets[j].set_gains[2] = FL(1.0); - } + if (sets[j].set_gains[0]<=FL(0.0) && + sets[j].set_gains[1]<=FL(0.0) && + sets[j].set_gains[2]<=FL(0.0)) { + sets[j].set_gains[0] = FL(1.0); + sets[j].set_gains[1] = FL(1.0); + sets[j].set_gains[2] = FL(1.0); + } - memset(gains, 0, ls_amount*sizeof(MYFLT)); + memset(gains, 0, ls_amount*sizeof(MYFLT)); - gains[sets[j].ls_nos[0]-1] = sets[j].set_gains[0]; - gains[sets[j].ls_nos[1]-1] = sets[j].set_gains[1]; - if (dim==3) gains[sets[j].ls_nos[2]-1] = sets[j].set_gains[2]; + gains[sets[j].ls_nos[0]-1] = sets[j].set_gains[0]; + gains[sets[j].ls_nos[1]-1] = sets[j].set_gains[1]; + if (dim==3) gains[sets[j].ls_nos[2]-1] = sets[j].set_gains[2]; - for (i=0;iazi > FL(180.0)) - avec->azi -= FL(360.0); - while (avec->azi < -FL(180.0)) - avec->azi += FL(360.0); - if (avec->ele > FL(90.0)) - avec->ele = FL(90.0); - if (avec->ele < -FL(90.0)) - avec->ele = -FL(90.0); + while (avec->azi > FL(180.0)) + avec->azi -= FL(360.0); + while (avec->azi < -FL(180.0)) + avec->azi += FL(360.0); + if (avec->ele > FL(90.0)) + avec->ele = FL(90.0); + if (avec->ele < -FL(90.0)) + avec->ele = -FL(90.0); } void normalize_wts(OUT_WTS *wts) - /* performs equal-power normalization to gain factors*/ +/* performs equal-power normalization to gain factors*/ { - double tmp; - MYFLT tmp1; - if (wts->wt1 < 0) wts->wt1 = FL(0.0); - if (wts->wt2 < 0) wts->wt2 = FL(0.0); - if (wts->wt3 < 0) wts->wt3 = FL(0.0); - - tmp = (double)wts->wt1 * wts->wt1; - tmp += (double)wts->wt2 * wts->wt2; - tmp += (double)wts->wt3 * wts->wt3; - - tmp = sqrt(tmp); - tmp1 = (MYFLT)(1.0 / tmp); - wts->wt1 *= tmp1; - wts->wt2 *= tmp1; - wts->wt3 *= tmp1; + double tmp; + MYFLT tmp1; + if (wts->wt1 < 0) wts->wt1 = FL(0.0); + if (wts->wt2 < 0) wts->wt2 = FL(0.0); + if (wts->wt3 < 0) wts->wt3 = FL(0.0); + + tmp = (double)wts->wt1 * wts->wt1; + tmp += (double)wts->wt2 * wts->wt2; + tmp += (double)wts->wt3 * wts->wt3; + + tmp = sqrt(tmp); + tmp1 = (MYFLT)(1.0 / tmp); + wts->wt1 *= tmp1; + wts->wt2 *= tmp1; + wts->wt3 *= tmp1; } void angle_to_cart(ANG_VEC avec, CART_VEC *cvec) - /* conversion */ +/* conversion */ { - /* length unattended */ - //MYFLT atorad = (TWOPI_F / FL(360.0)); - cvec->x = (MYFLT) (cos((double) (avec.azi * ATORAD)) * - cos((double) (avec.ele * ATORAD))); - cvec->y = (MYFLT) (sin((double) (avec.azi * ATORAD)) * - cos((double) (avec.ele * ATORAD))); - cvec->z = (MYFLT) (sin((double) (avec.ele * ATORAD))); + /* length unattended */ + //MYFLT atorad = (TWOPI_F / FL(360.0)); + cvec->x = (MYFLT) (cos((double) (avec.azi * ATORAD)) * + cos((double) (avec.ele * ATORAD))); + cvec->y = (MYFLT) (sin((double) (avec.azi * ATORAD)) * + cos((double) (avec.ele * ATORAD))); + cvec->z = (MYFLT) (sin((double) (avec.ele * ATORAD))); } void cart_to_angle(CART_VEC cvec, ANG_VEC *avec) - /* conversion */ +/* conversion */ { - MYFLT tmp, tmp2, tmp3, tmp4; - //MYFLT atorad = (TWOPI_F / FL(360.0)); - - tmp3 = SQRT(FL(1.0) - cvec.z*cvec.z); - if (FABS(tmp3) > FL(0.001)) { - tmp4 = (cvec.x / tmp3); - if (tmp4 > FL(1.0)) tmp4 = FL(1.0); - if (tmp4 < -FL(1.0)) tmp4 = -FL(1.0); - tmp = ACOS(tmp4 ); - } - else { - tmp = FL(10000.0); - } - if (FABS(cvec.y) <= FL(0.001)) - tmp2 = FL(1.0); - else - tmp2 = cvec.y / FABS(cvec.y); - tmp *= tmp2; - if (FABS(tmp) <= PI_F) { - avec->azi = tmp; - avec->azi /= ATORAD; - } - avec->ele = ASIN(cvec.z); - avec->length = SQRT(cvec.x * cvec.x + cvec.y * cvec.y + cvec.z * cvec.z); - avec->ele /= ATORAD; + MYFLT tmp, tmp2, tmp3, tmp4; + //MYFLT atorad = (TWOPI_F / FL(360.0)); + + tmp3 = SQRT(FL(1.0) - cvec.z*cvec.z); + if (FABS(tmp3) > FL(0.001)) { + tmp4 = (cvec.x / tmp3); + if (tmp4 > FL(1.0)) tmp4 = FL(1.0); + if (tmp4 < -FL(1.0)) tmp4 = -FL(1.0); + tmp = ACOS(tmp4 ); + } + else { + tmp = FL(10000.0); + } + if (FABS(cvec.y) <= FL(0.001)) + tmp2 = FL(1.0); + else + tmp2 = cvec.y / FABS(cvec.y); + tmp *= tmp2; + if (FABS(tmp) <= PI_F) { + avec->azi = tmp; + avec->azi /= ATORAD; + } + avec->ele = ASIN(cvec.z); + avec->length = SQRT(cvec.x * cvec.x + cvec.y * cvec.y + cvec.z * cvec.z); + avec->ele /= ATORAD; } void angle_to_cart_II(ANG_VEC *from, CART_VEC *to) - /* conversion, double*/ +/* conversion, double*/ { - MYFLT ang2rad = TWOPI_F / FL(360.0); - to->x= COS(from->azi * ang2rad) * COS(from->ele * ang2rad); - to->y= SIN(from->azi * ang2rad) * COS(from->ele * ang2rad); - to->z= SIN(from->ele * ang2rad); + MYFLT ang2rad = TWOPI_F / FL(360.0); + to->x= COS(from->azi * ang2rad) * COS(from->ele * ang2rad); + to->y= SIN(from->azi * ang2rad) * COS(from->ele * ang2rad); + to->z= SIN(from->ele * ang2rad); } MYFLT vol_p_side_lgth(int32_t i, int32_t j,int32_t k, ls lss[] ) @@ -248,57 +248,57 @@ MYFLT vol_p_side_lgth(int32_t i, int32_t j,int32_t k, ls lss[] ) direction vectors and divide it with total length of the triangle sides. This is used when removing too narrow triangles. */ - MYFLT volper, lgth; - CART_VEC xprod; - cross_prod(lss[i].coords, lss[j].coords, &xprod); - volper = FABS(vec_prod(xprod, lss[k].coords)); - lgth = FABS(vec_angle(lss[i].coords,lss[j].coords)) - + FABS(vec_angle(lss[i].coords,lss[k].coords)) - + FABS(vec_angle(lss[j].coords,lss[k].coords)); - if (LIKELY(lgth>FL(0.00001))) - return volper / lgth; - else - return FL(0.0); + MYFLT volper, lgth; + CART_VEC xprod; + cross_prod(lss[i].coords, lss[j].coords, &xprod); + volper = FABS(vec_prod(xprod, lss[k].coords)); + lgth = FABS(vec_angle(lss[i].coords,lss[j].coords)) + + FABS(vec_angle(lss[i].coords,lss[k].coords)) + + FABS(vec_angle(lss[j].coords,lss[k].coords)); + if (LIKELY(lgth>FL(0.00001))) + return volper / lgth; + else + return FL(0.0); } static void choose_ls_triplets(CSOUND *csound, ls *lss, struct ls_triplet_chain **ls_triplets, int32_t ls_amount) - /* Selects the loudspeaker triplets, and - calculates the inversion matrices for each selected triplet. - A line (connection) is drawn between each loudspeaker. The lines - denote the sides of the triangles. The triangles should not be - intersecting. All crossing connections are searched and the - longer connection is erased. This yields non-intesecting triangles, - which can be used in panning.*/ +/* Selects the loudspeaker triplets, and + calculates the inversion matrices for each selected triplet. + A line (connection) is drawn between each loudspeaker. The lines + denote the sides of the triangles. The triangles should not be + intersecting. All crossing connections are searched and the + longer connection is erased. This yields non-intesecting triangles, + which can be used in panning.*/ { - int32_t i, j, k, l, table_size; - int32_t *connections; -/* int32_t *i_ptr; */ - MYFLT *distance_table; - int32_t *distance_table_i; - int32_t *distance_table_j; - MYFLT distance; - struct ls_triplet_chain *trip_ptr, *prev, *tmp_ptr; - - if (UNLIKELY(ls_amount == 0)) { - csound->ErrorMsg(csound, "%s", Str("Number of loudspeakers is zero\nExiting")); - return; - } - - connections = csound->Calloc(csound, ls_amount * ls_amount * sizeof(int32_t)); - distance_table = - csound->Calloc(csound, ((ls_amount * (ls_amount - 1)) / 2)* sizeof(MYFLT)); - distance_table_i = - csound->Calloc(csound, ((ls_amount * (ls_amount - 1)) / 2)* sizeof(int32_t)); - distance_table_j = - csound->Calloc(csound, ((ls_amount * (ls_amount - 1)) / 2)* sizeof(int32_t)); - -/* i_ptr = (int32_t *) connections; */ -/* for (i=0;i< ((CHANNELS) * (CHANNELS )); i++) */ -/* *(i_ptr++) = 0; */ - - for (i=0;iErrorMsg(csound, "%s", Str("Number of loudspeakers is zero\nExiting")); + return; + } + + connections = csound->Calloc(csound, ls_amount * ls_amount * sizeof(int32_t)); + distance_table = + csound->Calloc(csound, ((ls_amount * (ls_amount - 1)) / 2)* sizeof(MYFLT)); + distance_table_i = + csound->Calloc(csound, ((ls_amount * (ls_amount - 1)) / 2)* sizeof(int32_t)); + distance_table_j = + csound->Calloc(csound, ((ls_amount * (ls_amount - 1)) / 2)* sizeof(int32_t)); + + /* i_ptr = (int32_t *) connections; */ + /* for (i=0;i< ((CHANNELS) * (CHANNELS )); i++) */ + /* *(i_ptr++) = 0; */ + + for (i=0;i MIN_VOL_P_SIDE_LGTH) { @@ -313,416 +313,416 @@ static void choose_ls_triplets(CSOUND *csound, ls *lss, } /*calculate distancies between all lss and sorting them*/ - table_size =(((ls_amount - 1) * (ls_amount)) / 2); - for (i=0;i k;l--) { - distance_table[l] = distance_table[l-1]; - distance_table_i[l] = distance_table_i[l-1]; - distance_table_j[l] = distance_table_j[l-1]; - } - distance_table[k] = distance; - distance_table_i[k] = i; - distance_table_j[k] = j; + table_size =(((ls_amount - 1) * (ls_amount)) / 2); + for (i=0;i k;l--) { + distance_table[l] = distance_table[l-1]; + distance_table_i[l] = distance_table_i[l-1]; + distance_table_j[l] = distance_table_j[l-1]; } - else - table_size--; + distance_table[k] = distance; + distance_table_i[k] = i; + distance_table_j[k] = j; } + else + table_size--; } + } - /* disconnecting connections which are crossing shorter ones, - starting from shortest one and removing all that cross it, - and proceeding to next shortest */ - for (i=0; i<(table_size); i++) { - int32_t fst_ls = distance_table_i[i]; - int32_t sec_ls = distance_table_j[i]; - if (connections[fst_ls+ls_amount*sec_ls] == 1) - for (j=0; jls_nos[0]; - j = trip_ptr->ls_nos[1]; - k = trip_ptr->ls_nos[2]; - if (connections[i+ls_amount*j] == 0 || - connections[i+ls_amount*k] == 0 || - connections[j+ls_amount*k] == 0 || - any_ls_inside_triplet(i,j,k,lss,ls_amount) == 1) { - if (prev != NULL) { - prev->next = trip_ptr->next; - tmp_ptr = trip_ptr; - trip_ptr = trip_ptr->next; - csound->Free(csound, tmp_ptr); - } - else { - *ls_triplets = trip_ptr->next; - tmp_ptr = trip_ptr; - trip_ptr = trip_ptr->next; - csound->Free(csound, tmp_ptr); - } + /* disconnecting connections which are crossing shorter ones, + starting from shortest one and removing all that cross it, + and proceeding to next shortest */ + for (i=0; i<(table_size); i++) { + int32_t fst_ls = distance_table_i[i]; + int32_t sec_ls = distance_table_j[i]; + if (connections[fst_ls+ls_amount*sec_ls] == 1) + for (j=0; jls_nos[0]; + j = trip_ptr->ls_nos[1]; + k = trip_ptr->ls_nos[2]; + if (connections[i+ls_amount*j] == 0 || + connections[i+ls_amount*k] == 0 || + connections[j+ls_amount*k] == 0 || + any_ls_inside_triplet(i,j,k,lss,ls_amount) == 1) { + if (prev != NULL) { + prev->next = trip_ptr->next; + tmp_ptr = trip_ptr; + trip_ptr = trip_ptr->next; + csound->Free(csound, tmp_ptr); } else { - prev = trip_ptr; + *ls_triplets = trip_ptr->next; + tmp_ptr = trip_ptr; trip_ptr = trip_ptr->next; + csound->Free(csound, tmp_ptr); } } - csound->Free(csound,connections); - csound->Free(csound,distance_table); - csound->Free(csound,distance_table_i); - csound->Free(csound,distance_table_j); + else { + prev = trip_ptr; + trip_ptr = trip_ptr->next; + } + } + csound->Free(csound,connections); + csound->Free(csound,distance_table); + csound->Free(csound,distance_table_i); + csound->Free(csound,distance_table_j); } /* returns 1 if there is loudspeaker(s) inside given ls triplet */ static int32_t any_ls_inside_triplet(int32_t a, int32_t b, int32_t c, ls lss[], - int32_t ls_amount) + int32_t ls_amount) { - MYFLT invdet; - CART_VEC *lp1, *lp2, *lp3; - MYFLT invmx[9]; - int32_t i,j; - MYFLT tmp; - int32_t any_ls_inside, this_inside; - - lp1 = &(lss[a].coords); - lp2 = &(lss[b].coords); - lp3 = &(lss[c].coords); - - /* matrix inversion */ - invdet = FL(1.0) / ( lp1->x * ((lp2->y * lp3->z) - (lp2->z * lp3->y)) - - lp1->y * ((lp2->x * lp3->z) - (lp2->z * lp3->x)) - + lp1->z * ((lp2->x * lp3->y) - (lp2->y * lp3->x))); - - invmx[0] = ((lp2->y * lp3->z) - (lp2->z * lp3->y)) * invdet; - invmx[3] = ((lp1->y * lp3->z) - (lp1->z * lp3->y)) * -invdet; - invmx[6] = ((lp1->y * lp2->z) - (lp1->z * lp2->y)) * invdet; - invmx[1] = ((lp2->x * lp3->z) - (lp2->z * lp3->x)) * -invdet; - invmx[4] = ((lp1->x * lp3->z) - (lp1->z * lp3->x)) * invdet; - invmx[7] = ((lp1->x * lp2->z) - (lp1->z * lp2->x)) * -invdet; - invmx[2] = ((lp2->x * lp3->y) - (lp2->y * lp3->x)) * invdet; - invmx[5] = ((lp1->x * lp3->y) - (lp1->y * lp3->x)) * -invdet; - invmx[8] = ((lp1->x * lp2->y) - (lp1->y * lp2->x)) * invdet; - - any_ls_inside = 0; - for (i=0; i< ls_amount; i++) { - if (i != a && i!=b && i != c) { - this_inside = 1; - for (j=0; j< 3; j++) { - tmp = lss[i].coords.x * invmx[0 + j*3]; - tmp += lss[i].coords.y * invmx[1 + j*3]; - tmp += lss[i].coords.z * invmx[2 + j*3]; - if (tmp < -FL(0.001)) - this_inside = 0; - } - if (this_inside == 1) - any_ls_inside=1; + MYFLT invdet; + CART_VEC *lp1, *lp2, *lp3; + MYFLT invmx[9]; + int32_t i,j; + MYFLT tmp; + int32_t any_ls_inside, this_inside; + + lp1 = &(lss[a].coords); + lp2 = &(lss[b].coords); + lp3 = &(lss[c].coords); + + /* matrix inversion */ + invdet = FL(1.0) / ( lp1->x * ((lp2->y * lp3->z) - (lp2->z * lp3->y)) + - lp1->y * ((lp2->x * lp3->z) - (lp2->z * lp3->x)) + + lp1->z * ((lp2->x * lp3->y) - (lp2->y * lp3->x))); + + invmx[0] = ((lp2->y * lp3->z) - (lp2->z * lp3->y)) * invdet; + invmx[3] = ((lp1->y * lp3->z) - (lp1->z * lp3->y)) * -invdet; + invmx[6] = ((lp1->y * lp2->z) - (lp1->z * lp2->y)) * invdet; + invmx[1] = ((lp2->x * lp3->z) - (lp2->z * lp3->x)) * -invdet; + invmx[4] = ((lp1->x * lp3->z) - (lp1->z * lp3->x)) * invdet; + invmx[7] = ((lp1->x * lp2->z) - (lp1->z * lp2->x)) * -invdet; + invmx[2] = ((lp2->x * lp3->y) - (lp2->y * lp3->x)) * invdet; + invmx[5] = ((lp1->x * lp3->y) - (lp1->y * lp3->x)) * -invdet; + invmx[8] = ((lp1->x * lp2->y) - (lp1->y * lp2->x)) * invdet; + + any_ls_inside = 0; + for (i=0; i< ls_amount; i++) { + if (i != a && i!=b && i != c) { + this_inside = 1; + for (j=0; j< 3; j++) { + tmp = lss[i].coords.x * invmx[0 + j*3]; + tmp += lss[i].coords.y * invmx[1 + j*3]; + tmp += lss[i].coords.z * invmx[2 + j*3]; + if (tmp < -FL(0.001)) + this_inside = 0; } + if (this_inside == 1) + any_ls_inside=1; } - return any_ls_inside; + } + return any_ls_inside; } static void add_ldsp_triplet(CSOUND *csound, int32_t i, int32_t j, int32_t k, struct ls_triplet_chain **ls_triplets, ls lss[]) { - IGN(lss); - struct ls_triplet_chain *ls_ptr, *prev; - ls_ptr = *ls_triplets; - prev = NULL; + IGN(lss); + struct ls_triplet_chain *ls_ptr, *prev; + ls_ptr = *ls_triplets; + prev = NULL; /*printf("Adding triangle %d %d %d %x... \n",i,j,k,ls_ptr);*/ - while (ls_ptr != NULL) { - /*printf("ls_ptr %x %x\n",ls_ptr,ls_ptr->next);*/ - prev = ls_ptr; - ls_ptr = ls_ptr->next; - } - ls_ptr = (struct ls_triplet_chain*) - csound->Malloc(csound, sizeof(struct ls_triplet_chain)); - if (prev == NULL) - *ls_triplets = ls_ptr; - else - prev->next = ls_ptr; - ls_ptr->next = NULL; - ls_ptr->ls_nos[0] = i; - ls_ptr->ls_nos[1] = j; - ls_ptr->ls_nos[2] = k; - /*printf("added.\n");*/ + while (ls_ptr != NULL) { + /*printf("ls_ptr %x %x\n",ls_ptr,ls_ptr->next);*/ + prev = ls_ptr; + ls_ptr = ls_ptr->next; + } + ls_ptr = (struct ls_triplet_chain*) + csound->Malloc(csound, sizeof(struct ls_triplet_chain)); + if (prev == NULL) + *ls_triplets = ls_ptr; + else + prev->next = ls_ptr; + ls_ptr->next = NULL; + ls_ptr->ls_nos[0] = i; + ls_ptr->ls_nos[1] = j; + ls_ptr->ls_nos[2] = k; + /*printf("added.\n");*/ } MYFLT angle_in_base(CART_VEC vb1,CART_VEC vb2,CART_VEC vec) { - MYFLT tmp1,tmp2; - tmp1 = vec_prod(vec,vb2); - if (FABS(tmp1) <= FL(0.001)) - tmp2 = FL(1.0); - else - tmp2 = tmp1 / FABS(tmp1); - return (vec_angle(vb1,vec) * tmp2); + MYFLT tmp1,tmp2; + tmp1 = vec_prod(vec,vb2); + if (FABS(tmp1) <= FL(0.001)) + tmp2 = FL(1.0); + else + tmp2 = tmp1 / FABS(tmp1); + return (vec_angle(vb1,vec) * tmp2); } MYFLT vec_angle(CART_VEC v1, CART_VEC v2) { - MYFLT inner= ((v1.x*v2.x + v1.y*v2.y + v1.z*v2.z)/ - (vec_length(v1) * vec_length(v2))); - if (inner > FL(1.0)) - inner= FL(1.0); - if (inner < -FL(1.0)) - inner = -FL(1.0); - return ACOS(inner); + MYFLT inner= ((v1.x*v2.x + v1.y*v2.y + v1.z*v2.z)/ + (vec_length(v1) * vec_length(v2))); + if (inner > FL(1.0)) + inner= FL(1.0); + if (inner < -FL(1.0)) + inner = -FL(1.0); + return ACOS(inner); } void vec_mean(CART_VEC v1, CART_VEC v2, CART_VEC *v3) { - v3->x=(v1.x+v2.x)*FL(0.5); - v3->y=(v1.y+v2.y)*FL(0.5); - v3->z=(v1.z+v2.z)*FL(0.5); + v3->x=(v1.x+v2.x)*FL(0.5); + v3->y=(v1.y+v2.y)*FL(0.5); + v3->z=(v1.z+v2.z)*FL(0.5); } void cross_prod(CART_VEC v1,CART_VEC v2, CART_VEC *res) { - MYFLT length; - res->x = (v1.y * v2.z ) - (v1.z * v2.y); - res->y = (v1.z * v2.x ) - (v1.x * v2.z); - res->z = (v1.x * v2.y ) - (v1.y * v2.x); - - length= vec_length(*res); - res->x /= length; - res->y /= length; - res->z /= length; + MYFLT length; + res->x = (v1.y * v2.z ) - (v1.z * v2.y); + res->y = (v1.z * v2.x ) - (v1.x * v2.z); + res->z = (v1.x * v2.y ) - (v1.y * v2.x); + + length= vec_length(*res); + res->x /= length; + res->y /= length; + res->z /= length; } void vec_print(CSOUND *csound, CART_VEC v) { - csound->Message(csound, "vec_print %f %f %f\n", v.x, v.y,v.z); + csound->Message(csound, "vec_print %f %f %f\n", v.x, v.y,v.z); } int32_t lines_intersect(int32_t i,int32_t j,int32_t k,int32_t l,ls lss[]) - /* checks if two lines intersect on 3D sphere - see theory in paper Pulkki, V. Lokki, T. "Creating Auditory Displays - with Multiple Loudspeakers Using VBAP: A Case Study with - DIVA Project" in International Conference on - Auditory Displays -98. E-mail Ville.Pulkki@hut.fi - if you want to have that paper.*/ +/* checks if two lines intersect on 3D sphere + see theory in paper Pulkki, V. Lokki, T. "Creating Auditory Displays + with Multiple Loudspeakers Using VBAP: A Case Study with + DIVA Project" in International Conference on + Auditory Displays -98. E-mail Ville.Pulkki@hut.fi + if you want to have that paper.*/ { - CART_VEC v1; - CART_VEC v2; - CART_VEC v3, neg_v3; - MYFLT dist_ij,dist_kl,dist_iv3,dist_jv3,dist_inv3,dist_jnv3; - MYFLT dist_kv3,dist_lv3,dist_knv3,dist_lnv3; - - cross_prod(lss[i].coords,lss[j].coords,&v1); - cross_prod(lss[k].coords,lss[l].coords,&v2); - cross_prod(v1,v2,&v3); - - neg_v3.x= FL(0.0) - v3.x; - neg_v3.y= FL(0.0) - v3.y; - neg_v3.z= FL(0.0) - v3.z; - - dist_ij = (vec_angle(lss[i].coords,lss[j].coords)); - dist_kl = (vec_angle(lss[k].coords,lss[l].coords)); - dist_iv3 = (vec_angle(lss[i].coords,v3)); - dist_jv3 = (vec_angle(v3,lss[j].coords)); - dist_inv3 = (vec_angle(lss[i].coords,neg_v3)); - dist_jnv3 = (vec_angle(neg_v3,lss[j].coords)); - dist_kv3 = (vec_angle(lss[k].coords,v3)); - dist_lv3 = (vec_angle(v3,lss[l].coords)); - dist_knv3 = (vec_angle(lss[k].coords,neg_v3)); - dist_lnv3 = (vec_angle(neg_v3,lss[l].coords)); - - /* if one of loudspeakers is close to crossing point, don't do anything*/ - if (FABS(dist_iv3) <= FL(0.01) || FABS(dist_jv3) <= FL(0.01) || - FABS(dist_kv3) <= FL(0.01) || FABS(dist_lv3) <= FL(0.01) || - FABS(dist_inv3) <= FL(0.01) || FABS(dist_jnv3) <= FL(0.01) || - FABS(dist_knv3) <= FL(0.01) || FABS(dist_lnv3) <= FL(0.01) ) - return(0); - - if (((FABS(dist_ij - (dist_iv3 + dist_jv3)) <= FL(0.01) ) && - (FABS(dist_kl - (dist_kv3 + dist_lv3)) <= FL(0.01))) || - ((FABS(dist_ij - (dist_inv3 + dist_jnv3)) <= FL(0.01)) && - (FABS(dist_kl - (dist_knv3 + dist_lnv3)) <= FL(0.01) ))) { - return (1); - } - else { - return (0); - } + CART_VEC v1; + CART_VEC v2; + CART_VEC v3, neg_v3; + MYFLT dist_ij,dist_kl,dist_iv3,dist_jv3,dist_inv3,dist_jnv3; + MYFLT dist_kv3,dist_lv3,dist_knv3,dist_lnv3; + + cross_prod(lss[i].coords,lss[j].coords,&v1); + cross_prod(lss[k].coords,lss[l].coords,&v2); + cross_prod(v1,v2,&v3); + + neg_v3.x= FL(0.0) - v3.x; + neg_v3.y= FL(0.0) - v3.y; + neg_v3.z= FL(0.0) - v3.z; + + dist_ij = (vec_angle(lss[i].coords,lss[j].coords)); + dist_kl = (vec_angle(lss[k].coords,lss[l].coords)); + dist_iv3 = (vec_angle(lss[i].coords,v3)); + dist_jv3 = (vec_angle(v3,lss[j].coords)); + dist_inv3 = (vec_angle(lss[i].coords,neg_v3)); + dist_jnv3 = (vec_angle(neg_v3,lss[j].coords)); + dist_kv3 = (vec_angle(lss[k].coords,v3)); + dist_lv3 = (vec_angle(v3,lss[l].coords)); + dist_knv3 = (vec_angle(lss[k].coords,neg_v3)); + dist_lnv3 = (vec_angle(neg_v3,lss[l].coords)); + + /* if one of loudspeakers is close to crossing point, don't do anything*/ + if (FABS(dist_iv3) <= FL(0.01) || FABS(dist_jv3) <= FL(0.01) || + FABS(dist_kv3) <= FL(0.01) || FABS(dist_lv3) <= FL(0.01) || + FABS(dist_inv3) <= FL(0.01) || FABS(dist_jnv3) <= FL(0.01) || + FABS(dist_knv3) <= FL(0.01) || FABS(dist_lnv3) <= FL(0.01) ) + return(0); + + if (((FABS(dist_ij - (dist_iv3 + dist_jv3)) <= FL(0.01) ) && + (FABS(dist_kl - (dist_kv3 + dist_lv3)) <= FL(0.01))) || + ((FABS(dist_ij - (dist_inv3 + dist_jnv3)) <= FL(0.01)) && + (FABS(dist_kl - (dist_knv3 + dist_lnv3)) <= FL(0.01) ))) { + return (1); + } + else { + return (0); + } } static inline int32_t vbap_ls_init_sr (CSOUND *csound, int32_t dim, int32_t count, - MYFLT **f, int32_t layout) - /* Inits the loudspeaker data. Calls choose_ls_tuplets or _triplets - according to current dimension. The inversion matrices are - stored in transposed form to ease calculation at run time.*/ + MYFLT **f, int32_t layout) +/* Inits the loudspeaker data. Calls choose_ls_tuplets or _triplets + according to current dimension. The inversion matrices are + stored in transposed form to ease calculation at run time.*/ { - struct ls_triplet_chain *ls_triplets = NULL; - ls *lss = malloc(sizeof(ls)*count); - - ANG_VEC a_vector; - CART_VEC c_vector; - int32_t i=0,j; - - //dim = (int32_t) *p->dim; - csound->Message(csound, "dim : %d\n",dim); - if (UNLIKELY(!((dim==2) || (dim == 3)))) { - free(lss); - csound->ErrorMsg(csound, - Str("Error in loudspeaker dimension. %d not permitted"), - dim); - return NOTOK; - } - //count = (int32_t) *p->ls_amount; - for (j=1;j<=count;j++) { - if (dim == 3) { - a_vector.azi= (MYFLT) *f[2*j-2]; - a_vector.ele= (MYFLT) *f[2*j-1]; - } - else if (dim == 2) { - a_vector.azi= (MYFLT) *f[j-1]; - a_vector.ele=FL(0.0); - } - angle_to_cart_II(&a_vector,&c_vector); - lss[i].coords.x = c_vector.x; - lss[i].coords.y = c_vector.y; - lss[i].coords.z = c_vector.z; - lss[i].angles.azi = a_vector.azi; - lss[i].angles.ele = a_vector.ele; - lss[i].angles.length = FL(1.0); - /* printf("**** lss[%d]: (%g %g %g) %g %g\n", i, lss[i].coords.x, */ - /* lss[i].coords.y, lss[i].coords.z, a_vector.azi, a_vector.ele); */ - i++; - } - //ls_amount = (int32_t)*p->ls_amount; - if (UNLIKELY(count < dim)) { - free(lss); - csound->ErrorMsg(csound, "%s", Str("Too few loudspeakers")); - return NOTOK; - } + struct ls_triplet_chain *ls_triplets = NULL; + ls *lss = malloc(sizeof(ls)*count); + + ANG_VEC a_vector; + CART_VEC c_vector; + int32_t i=0,j; + //dim = (int32_t) *p->dim; + csound->Message(csound, "dim : %d\n",dim); + if (UNLIKELY(!((dim==2) || (dim == 3)))) { + free(lss); + csound->ErrorMsg(csound, + Str("Error in loudspeaker dimension. %d not permitted"), + dim); + return NOTOK; + } + //count = (int32_t) *p->ls_amount; + for (j=1;j<=count;j++) { if (dim == 3) { - choose_ls_triplets(csound, lss, &ls_triplets, count); - calculate_3x3_matrixes(csound, ls_triplets, lss, count, layout); + a_vector.azi= (MYFLT) *f[2*j-2]; + a_vector.ele= (MYFLT) *f[2*j-1]; } - else if (dim ==2) { - choose_ls_tuplets(csound, lss, &ls_triplets, count, layout); + else if (dim == 2) { + a_vector.azi= (MYFLT) *f[j-1]; + a_vector.ele=FL(0.0); } + angle_to_cart_II(&a_vector,&c_vector); + lss[i].coords.x = c_vector.x; + lss[i].coords.y = c_vector.y; + lss[i].coords.z = c_vector.z; + lss[i].angles.azi = a_vector.azi; + lss[i].angles.ele = a_vector.ele; + lss[i].angles.length = FL(1.0); + /* printf("**** lss[%d]: (%g %g %g) %g %g\n", i, lss[i].coords.x, */ + /* lss[i].coords.y, lss[i].coords.z, a_vector.azi, a_vector.ele); */ + i++; + } + //ls_amount = (int32_t)*p->ls_amount; + if (UNLIKELY(count < dim)) { free(lss); - return OK; + csound->ErrorMsg(csound, "%s", Str("Too few loudspeakers")); + return NOTOK; + } + + if (dim == 3) { + choose_ls_triplets(csound, lss, &ls_triplets, count); + calculate_3x3_matrixes(csound, ls_triplets, lss, count, layout); + } + else if (dim ==2) { + choose_ls_tuplets(csound, lss, &ls_triplets, count, layout); + } + free(lss); + return OK; } int32_t vbap_ls_init (CSOUND *csound, VBAP_LS_INIT *p) { - int32_t dim = (int32_t) *p->dim; - MYFLT layout = (*p->dim-dim)*100; - return vbap_ls_init_sr(csound, dim, (int32_t) *p->ls_amount, - p->f, round(layout)); + int32_t dim = (int32_t) *p->dim; + MYFLT layout = (*p->dim-dim)*100; + return vbap_ls_init_sr(csound, dim, (int32_t) *p->ls_amount, + p->f, round(layout)); } int32_t vbap_ls_inita (CSOUND *csound, VBAP_LS_INITA *p) { - int32_t dim = (int32_t) *p->dim; - MYFLT layout = (*p->dim-dim)*100; - int32_t i, n = (int32_t)*p->ls_amount; - /* if (n>CHANNELS) */ - /* return csound->InitError(csound, "%s", Str("Too many speakers (%n)\n"), n); */ - if (UNLIKELY(n>p->a->sizes[0])) - return csound->InitError(csound, Str("Too little data speakers (%d)\n"), - n>p->a->sizes[0]); - MYFLT **f = csound->Malloc(csound, 2*sizeof(MYFLT*)*n); - // Transfer values to pointers - for (i=0; i<2*n; i++) f[i] = &(p->a->data[i]); - n = vbap_ls_init_sr(csound, dim, n, f, round(layout)); - csound->Free(csound, f); - return n; + int32_t dim = (int32_t) *p->dim; + MYFLT layout = (*p->dim-dim)*100; + int32_t i, n = (int32_t)*p->ls_amount; + /* if (n>CHANNELS) */ + /* return csound->InitError(csound, "%s", Str("Too many speakers (%n)\n"), n); */ + if (UNLIKELY(n>p->a->sizes[0])) + return csound->InitError(csound, Str("Too little data speakers (%d)\n"), + n>p->a->sizes[0]); + MYFLT **f = csound->Malloc(csound, 2*sizeof(MYFLT*)*n); + // Transfer values to pointers + for (i=0; i<2*n; i++) f[i] = &(p->a->data[i]); + n = vbap_ls_init_sr(csound, dim, n, f, round(layout)); + csound->Free(csound, f); + return n; } static void calculate_3x3_matrixes(CSOUND *csound, struct ls_triplet_chain *ls_triplets, ls lss[], int32_t ls_amount, int32_t ind) - /* Calculates the inverse matrices for 3D */ +/* Calculates the inverse matrices for 3D */ { - MYFLT invdet; - CART_VEC *lp1, *lp2, *lp3; - MYFLT *ls_table, *invmx; - MYFLT *ptr; - struct ls_triplet_chain *tr_ptr = ls_triplets; - int32_t triplet_amount = 0, i,j,k; - - if (UNLIKELY(tr_ptr == NULL)) { - csound->ErrorMsg(csound, "%s", Str("Not valid 3-D configuration")); - return; - } - - /* counting triplet amount */ - while (tr_ptr != NULL) { - triplet_amount++; - tr_ptr = tr_ptr->next; - } - - /* calculations and data storage to a global array */ - ls_table = create_ls_table(csound, triplet_amount * 12 + 3, ind); - ls_table[0] = FL(3.0); /* dimension */ - ls_table[1] = (MYFLT) ls_amount; - ls_table[2] = (MYFLT) triplet_amount; - tr_ptr = ls_triplets; - ptr = (MYFLT *) &(ls_table[3]); - while (tr_ptr != NULL) { - lp1 = &(lss[tr_ptr->ls_nos[0]].coords); - lp2 = &(lss[tr_ptr->ls_nos[1]].coords); - lp3 = &(lss[tr_ptr->ls_nos[2]].coords); - - /* matrix inversion */ - invmx = tr_ptr->inv_mx; - invdet = FL(1.0) / ( lp1->x * ((lp2->y * lp3->z) - (lp2->z * lp3->y)) - - lp1->y * ((lp2->x * lp3->z) - (lp2->z * lp3->x)) - + lp1->z * ((lp2->x * lp3->y) - (lp2->y * lp3->x))); - - invmx[0] = ((lp2->y * lp3->z) - (lp2->z * lp3->y)) * invdet; - invmx[3] = ((lp1->y * lp3->z) - (lp1->z * lp3->y)) * -invdet; - invmx[6] = ((lp1->y * lp2->z) - (lp1->z * lp2->y)) * invdet; - invmx[1] = ((lp2->x * lp3->z) - (lp2->z * lp3->x)) * -invdet; - invmx[4] = ((lp1->x * lp3->z) - (lp1->z * lp3->x)) * invdet; - invmx[7] = ((lp1->x * lp2->z) - (lp1->z * lp2->x)) * -invdet; - invmx[2] = ((lp2->x * lp3->y) - (lp2->y * lp3->x)) * invdet; - invmx[5] = ((lp1->x * lp3->y) - (lp1->y * lp3->x)) * -invdet; - invmx[8] = ((lp1->x * lp2->y) - (lp1->y * lp2->x)) * invdet; - for (i=0;i<3;i++) { - *(ptr++) = (MYFLT) tr_ptr->ls_nos[i]+1; - } - for (i=0;i<9;i++) { - *(ptr++) = (MYFLT) invmx[i]; - } - tr_ptr = tr_ptr->next; + MYFLT invdet; + CART_VEC *lp1, *lp2, *lp3; + MYFLT *ls_table, *invmx; + MYFLT *ptr; + struct ls_triplet_chain *tr_ptr = ls_triplets; + int32_t triplet_amount = 0, i,j,k; + + if (UNLIKELY(tr_ptr == NULL)) { + csound->ErrorMsg(csound, "%s", Str("Not valid 3-D configuration")); + return; + } + + /* counting triplet amount */ + while (tr_ptr != NULL) { + triplet_amount++; + tr_ptr = tr_ptr->next; + } + + /* calculations and data storage to a global array */ + ls_table = create_ls_table(csound, triplet_amount * 12 + 3, ind); + ls_table[0] = FL(3.0); /* dimension */ + ls_table[1] = (MYFLT) ls_amount; + ls_table[2] = (MYFLT) triplet_amount; + tr_ptr = ls_triplets; + ptr = (MYFLT *) &(ls_table[3]); + while (tr_ptr != NULL) { + lp1 = &(lss[tr_ptr->ls_nos[0]].coords); + lp2 = &(lss[tr_ptr->ls_nos[1]].coords); + lp3 = &(lss[tr_ptr->ls_nos[2]].coords); + + /* matrix inversion */ + invmx = tr_ptr->inv_mx; + invdet = FL(1.0) / ( lp1->x * ((lp2->y * lp3->z) - (lp2->z * lp3->y)) + - lp1->y * ((lp2->x * lp3->z) - (lp2->z * lp3->x)) + + lp1->z * ((lp2->x * lp3->y) - (lp2->y * lp3->x))); + + invmx[0] = ((lp2->y * lp3->z) - (lp2->z * lp3->y)) * invdet; + invmx[3] = ((lp1->y * lp3->z) - (lp1->z * lp3->y)) * -invdet; + invmx[6] = ((lp1->y * lp2->z) - (lp1->z * lp2->y)) * invdet; + invmx[1] = ((lp2->x * lp3->z) - (lp2->z * lp3->x)) * -invdet; + invmx[4] = ((lp1->x * lp3->z) - (lp1->z * lp3->x)) * invdet; + invmx[7] = ((lp1->x * lp2->z) - (lp1->z * lp2->x)) * -invdet; + invmx[2] = ((lp2->x * lp3->y) - (lp2->y * lp3->x)) * invdet; + invmx[5] = ((lp1->x * lp3->y) - (lp1->y * lp3->x)) * -invdet; + invmx[8] = ((lp1->x * lp2->y) - (lp1->y * lp2->x)) * invdet; + for (i=0;i<3;i++) { + *(ptr++) = (MYFLT) tr_ptr->ls_nos[i]+1; } + for (i=0;i<9;i++) { + *(ptr++) = (MYFLT) invmx[i]; + } + tr_ptr = tr_ptr->next; + } - k = 3; - csound->Warning(csound, "%s", Str("\nConfigured loudspeakers\n")); - for (i = 0; i < triplet_amount; i++) { - csound->Warning(csound, Str("Triplet %d Loudspeakers: "), i); - for (j = 0; j < 3; j++) { - csound->Warning(csound, "%d ", (int32_t) ls_table[k++]); - } - csound->Warning(csound, "\n"); + k = 3; + csound->Warning(csound, "%s", Str("\nConfigured loudspeakers\n")); + for (i = 0; i < triplet_amount; i++) { + csound->Warning(csound, Str("Triplet %d Loudspeakers: "), i); + for (j = 0; j < 3; j++) { + csound->Warning(csound, "%d ", (int32_t) ls_table[k++]); + } + csound->Warning(csound, "\n"); /* printf("\nMatrix "); */ /* for (j = 0; j < 9; j++) { */ @@ -730,300 +730,2326 @@ static void calculate_3x3_matrixes(CSOUND *csound, /* k++; */ /* } */ /* printf("\n\n"); */ - } + } } static void choose_ls_tuplets(CSOUND *csound, ls lss[], ls_triplet_chain **ls_triplets, int32_t ls_amount, int32_t ind) - /* selects the loudspeaker pairs, calculates the inversion - matrices and stores the data to a global array */ +/* selects the loudspeaker pairs, calculates the inversion + matrices and stores the data to a global array */ { - IGN(ls_triplets); - int32_t i, j, k; - int32_t *sorted_lss = (int32_t*)malloc(sizeof(int32_t)*ls_amount); - int32_t *exist = (int32_t*)calloc(1,sizeof(int32_t)*ls_amount); - int32_t amount = 0; - MYFLT *inv_mat = (MYFLT*)malloc(MATSIZE*sizeof(MYFLT)*ls_amount), - *ls_table, *ptr; - //int32_t ftable_size; - - /* sort loudspeakers according their aximuth angle */ - sort_2D_lss(lss,sorted_lss,ls_amount); - - /* adjacent loudspeakers are the loudspeaker pairs to be used.*/ - for (i=0;i<(ls_amount-1);i++) { - csound->Message(csound, "***%d %d %f %f\n",sorted_lss[i],sorted_lss[i+1], - lss[sorted_lss[i]].angles.azi, - lss[sorted_lss[i+1]].angles.azi); - if (LIKELY((lss[sorted_lss[i+1]].angles.azi - - lss[sorted_lss[i]].angles.azi) <= (PI - 0.0175))) { - if (LIKELY(calc_2D_inv_tmatrix( lss[sorted_lss[i]].angles.azi, - lss[sorted_lss[i+1]].angles.azi, - &inv_mat[MATSIZE*i]) != 0)) { - exist[i]=1; - amount++; - } - } - else csound->Warning(csound, Str("Pair of speakers at %f and %f ignored\n"), - lss[sorted_lss[i]].angles.azi*FL(180.0)/PI_F, - lss[sorted_lss[i+1]].angles.azi*FL(180.0)/PI_F); - } - - if (LIKELY(((TWOPI_F - lss[sorted_lss[ls_amount-1]].angles.azi) - +lss[sorted_lss[0]].angles.azi) < (PI - 0.0175))) { - //printf("**less than PI type 2- 0.175\n"); - if (LIKELY(calc_2D_inv_tmatrix(lss[sorted_lss[ls_amount-1]].angles.azi, - lss[sorted_lss[0]].angles.azi, - &inv_mat[MATSIZE*(ls_amount-1)]) != 0)) { - exist[ls_amount-1]=1; + IGN(ls_triplets); + int32_t i, j, k; + int32_t *sorted_lss = (int32_t*)malloc(sizeof(int32_t)*ls_amount); + int32_t *exist = (int32_t*)calloc(1,sizeof(int32_t)*ls_amount); + int32_t amount = 0; + MYFLT *inv_mat = (MYFLT*)malloc(MATSIZE*sizeof(MYFLT)*ls_amount), + *ls_table, *ptr; + //int32_t ftable_size; + + /* sort loudspeakers according their aximuth angle */ + sort_2D_lss(lss,sorted_lss,ls_amount); + + /* adjacent loudspeakers are the loudspeaker pairs to be used.*/ + for (i=0;i<(ls_amount-1);i++) { + csound->Message(csound, "***%d %d %f %f\n",sorted_lss[i],sorted_lss[i+1], + lss[sorted_lss[i]].angles.azi, + lss[sorted_lss[i+1]].angles.azi); + if (LIKELY((lss[sorted_lss[i+1]].angles.azi - + lss[sorted_lss[i]].angles.azi) <= (PI - 0.0175))) { + if (LIKELY(calc_2D_inv_tmatrix( lss[sorted_lss[i]].angles.azi, + lss[sorted_lss[i+1]].angles.azi, + &inv_mat[MATSIZE*i]) != 0)) { + exist[i]=1; amount++; } } else csound->Warning(csound, Str("Pair of speakers at %f and %f ignored\n"), - lss[sorted_lss[ls_amount-1]].angles.azi*FL(180.0)/PI_F, - lss[sorted_lss[0]].angles.azi*FL(180.0)/PI_F); + lss[sorted_lss[i]].angles.azi*FL(180.0)/PI_F, + lss[sorted_lss[i+1]].angles.azi*FL(180.0)/PI_F); + } - if (UNLIKELY(amount==0)) { - csound->InitError(csound, "%s", Str("insufficient valid speakers")); - free(sorted_lss); free(exist); free(inv_mat); - return; + if (LIKELY(((TWOPI_F - lss[sorted_lss[ls_amount-1]].angles.azi) + +lss[sorted_lss[0]].angles.azi) < (PI - 0.0175))) { + //printf("**less than PI type 2- 0.175\n"); + if (LIKELY(calc_2D_inv_tmatrix(lss[sorted_lss[ls_amount-1]].angles.azi, + lss[sorted_lss[0]].angles.azi, + &inv_mat[MATSIZE*(ls_amount-1)]) != 0)) { + exist[ls_amount-1]=1; + amount++; } + } + else csound->Warning(csound, Str("Pair of speakers at %f and %f ignored\n"), + lss[sorted_lss[ls_amount-1]].angles.azi*FL(180.0)/PI_F, + lss[sorted_lss[0]].angles.azi*FL(180.0)/PI_F); + + if (UNLIKELY(amount==0)) { + csound->InitError(csound, "%s", Str("insufficient valid speakers")); + free(sorted_lss); free(exist); free(inv_mat); + return; + } #if 0 - if ( amount*6 + 6 <= 16) ftable_size = 16; - else if ( amount*6 + 6 <= 32) ftable_size = 32; - else if ( amount*6 + 6 <= 64) ftable_size = 64; - else if ( amount*6 + 6 <= 128) ftable_size = 128; - else if ( amount*6 + 6 <= 256) ftable_size = 256; - else if ( amount*6 + 6 <= 1024) ftable_size = 1024; - csound->Message(csound, - "Loudspeaker matrices calculated with configuration : "); - for (i=0; i< ls_amount; i++) - csound->Message(csound, "%.1f ", lss[i].angles.azi / ATORAD); - csound->Message(csound, "\n"); + if ( amount*6 + 6 <= 16) ftable_size = 16; + else if ( amount*6 + 6 <= 32) ftable_size = 32; + else if ( amount*6 + 6 <= 64) ftable_size = 64; + else if ( amount*6 + 6 <= 128) ftable_size = 128; + else if ( amount*6 + 6 <= 256) ftable_size = 256; + else if ( amount*6 + 6 <= 1024) ftable_size = 1024; + csound->Message(csound, + "Loudspeaker matrices calculated with configuration : "); + for (i=0; i< ls_amount; i++) + csound->Message(csound, "%.1f ", lss[i].angles.azi / ATORAD); + csound->Message(csound, "\n"); #endif - ls_table = create_ls_table(csound, amount * 6 + 3 + 100, ind); - ls_table[0] = FL(2.0); /* dimension */ - ls_table[1] = (MYFLT) ls_amount; - ls_table[2] = (MYFLT) amount; - ptr = &(ls_table[3]); - for (i=0;iMessage(csound, "%s", Str("\nConfigured loudspeakers\n")); - for (i=0; i < amount; i++) { - csound->Message(csound, Str("Pair %d Loudspeakers: "), i); - for (j=0; j < 2; j++) { - csound->Message(csound, "%d ", (int32_t) ls_table[k++]); - } + } + if (exist[ls_amount-1] == 1) { + *(ptr++) = (MYFLT)sorted_lss[ls_amount-1]+1; + *(ptr++) = (MYFLT)sorted_lss[0]+1; + for (j=0;jMessage(csound, "%s", Str("\nConfigured loudspeakers\n")); + for (i=0; i < amount; i++) { + csound->Message(csound, Str("Pair %d Loudspeakers: "), i); + for (j=0; j < 2; j++) { + csound->Message(csound, "%d ", (int32_t) ls_table[k++]); + } - csound->Message(csound, "\nMatrix "); - for (j=0; j < MATSIZE; j++) { - csound->Message(csound, "%f ", ls_table[k]); - k++; - } - csound->Message(csound, "\n\n"); + csound->Message(csound, "\nMatrix "); + for (j=0; j < MATSIZE; j++) { + csound->Message(csound, "%f ", ls_table[k]); + k++; } - free(sorted_lss); free(exist); free(inv_mat); + csound->Message(csound, "\n\n"); + } + free(sorted_lss); free(exist); free(inv_mat); } static void sort_2D_lss(ls lss[], int32_t sorted_lss[], int32_t ls_amount) { - int32_t i,j,index=-1; - MYFLT tmp, tmp_azi; - - /* Transforming angles between -180 and 180 */ - for (i=0; ix = a * vscartdir.x + b * spread_base.x; - spreaddir->y = a * vscartdir.y + b * spread_base.y; - spreaddir->z = a * vscartdir.z + b * spread_base.z; - - power=SQRT(spreaddir->x*spreaddir->x + - spreaddir->y*spreaddir->y + - spreaddir->z*spreaddir->z); - spreaddir->x /= power; - spreaddir->y /= power; - spreaddir->z /= power; + } + beta = FL(180.0) - gamma; + b=SIN(spread * PI_F / FL(180.0)) / + SIN(beta * PI_F / FL(180.0)); + a=SIN((FL(180.0)- spread - beta) * PI_F / FL(180.0)) / + SIN (beta * PI_F / FL(180.0)); + spreaddir->x = a * vscartdir.x + b * spread_base.x; + spreaddir->y = a * vscartdir.y + b * spread_base.y; + spreaddir->z = a * vscartdir.z + b * spread_base.z; + + power=SQRT(spreaddir->x*spreaddir->x + + spreaddir->y*spreaddir->y + + spreaddir->z*spreaddir->z); + spreaddir->x /= power; + spreaddir->y /= power; + spreaddir->z /= power; } void new_spread_base(CART_VEC spreaddir, CART_VEC vscartdir, MYFLT spread, CART_VEC *spread_base) { - MYFLT d; - MYFLT power; - - d = COS(spread/FL(180.0)*PI_F); - spread_base->x = spreaddir.x - d * vscartdir.x; - spread_base->y = spreaddir.y - d * vscartdir.y; - spread_base->z = spreaddir.z - d * vscartdir.z; - power=SQRT(spread_base->x*spread_base->x + - spread_base->y*spread_base->y + - spread_base->z*spread_base->z); - spread_base->x /= power; - spread_base->y /= power; - spread_base->z /= power; + MYFLT d; + MYFLT power; + + d = COS(spread/FL(180.0)*PI_F); + spread_base->x = spreaddir.x - d * vscartdir.x; + spread_base->y = spreaddir.y - d * vscartdir.y; + spread_base->z = spreaddir.z - d * vscartdir.z; + power=SQRT(spread_base->x*spread_base->x + + spread_base->y*spread_base->y + + spread_base->z*spread_base->z); + spread_base->x /= power; + spread_base->y /= power; + spread_base->z /= power; +} + + +static int32_t vbap1_moving_control(CSOUND *, VBAP1_MOVE_DATA *, OPDS *, MYFLT, + MYFLT, MYFLT, MYFLT**); +static int32_t vbap1_control(CSOUND *, VBAP1_DATA *, MYFLT*, MYFLT*, MYFLT*); + +int32_t vbap1(CSOUND *csound, VBAP1 *p) /* during note performance: */ +{ + int32_t j; + int32_t cnt = p->q.number; + vbap1_control(csound,&p->q, p->azi, p->ele, p->spread); + + /* write gains */ + for (j=0; jout_array[j] = p->q.gains[j]; + } + return OK; +} + +static int32_t vbap1_control(CSOUND *csound, VBAP1_DATA *p, + MYFLT* azi, MYFLT* ele, MYFLT* spread) +{ + CART_VEC spreaddir[16]; + CART_VEC spreadbase[16]; + ANG_VEC atmp; + int32 i,j, spreaddirnum; + int32_t cnt = p->number; + MYFLT *tmp_gains=malloc(sizeof(MYFLT)*cnt),sum=FL(0.0); + if (UNLIKELY(p->dim == 2 && fabs(*ele) > 0.0)) { + csound->Warning(csound, + "%s", Str("Warning: truncating elevation to 2-D plane\n")); + *ele = FL(0.0); + } + + if (*spread FL(100.0)) + *spread = FL(100.0); + /* Current panning angles */ + p->ang_dir.azi = *azi; + p->ang_dir.ele = *ele; + p->ang_dir.length = FL(1.0); + angle_to_cart(p->ang_dir, &(p->cart_dir)); + calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, + p->gains, cnt, p->cart_dir); + + /* Calculated gain factors of a spreaded virtual source*/ + if (*spread > FL(0.0)) { + if (p->dim == 3) { + spreaddirnum = 16; + /* four orthogonal dirs*/ + new_spread_dir(&spreaddir[0], p->cart_dir, + p->spread_base, *azi, *spread); + new_spread_base(spreaddir[0], p->cart_dir, + *spread, &p->spread_base); + cross_prod(p->spread_base, p->cart_dir, &spreadbase[1]); + cross_prod(spreadbase[1], p->cart_dir, &spreadbase[2]); + cross_prod(spreadbase[2], p->cart_dir, &spreadbase[3]); + /* four between them*/ + vec_mean(p->spread_base, spreadbase[1], &spreadbase[4]); + vec_mean(spreadbase[1], spreadbase[2], &spreadbase[5]); + vec_mean(spreadbase[2], spreadbase[3], &spreadbase[6]); + vec_mean(spreadbase[3], p->spread_base, &spreadbase[7]); + + /* four at half spreadangle*/ + vec_mean(p->cart_dir, p->spread_base, &spreadbase[8]); + vec_mean(p->cart_dir, spreadbase[1], &spreadbase[9]); + vec_mean(p->cart_dir, spreadbase[2], &spreadbase[10]); + vec_mean(p->cart_dir, spreadbase[3], &spreadbase[11]); + + /* four at quarter spreadangle*/ + vec_mean(p->cart_dir, spreadbase[8], &spreadbase[12]); + vec_mean(p->cart_dir, spreadbase[9], &spreadbase[13]); + vec_mean(p->cart_dir, spreadbase[10], &spreadbase[14]); + vec_mean(p->cart_dir, spreadbase[11], &spreadbase[15]); + + for (i=1;icart_dir, + spreadbase[i],*azi,*spread); + calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, + tmp_gains, cnt, spreaddir[i]); + for (j=0;jgains[j] += tmp_gains[j]; + } + } + } + else if (p->dim == 2) { + spreaddirnum = 6; + atmp.ele = FL(0.0); + atmp.azi = *azi - *spread; + angle_to_cart(atmp, &spreaddir[0]); + atmp.azi = *azi - *spread/2; + angle_to_cart(atmp, &spreaddir[1]); + atmp.azi = *azi - *spread/4; + angle_to_cart(atmp, &spreaddir[2]); + atmp.azi = *azi + *spread/4; + angle_to_cart(atmp, &spreaddir[3]); + atmp.azi = *azi + *spread/2; + angle_to_cart(atmp, &spreaddir[4]); + atmp.azi = *azi + *spread; + angle_to_cart(atmp, &spreaddir[5]); + + for (i=0;ils_set_am, p->dim, p->ls_sets, + tmp_gains, cnt, spreaddir[i]); + for (j=0;jgains[j] += tmp_gains[j]; + } + } + } + } + if (*spread > FL(70.0)) + for (i=0;igains[i] +=(*spread - FL(70.0))/FL(30.0) * + (*spread - FL(70.0))/FL(30.0)*FL(20.0); + } + + /*normalization*/ + for (i=0;igains[i]*p->gains[i]); + } + + sum=SQRT(sum); + for (i=0;igains[i] /= sum; + } + free(tmp_gains); + return OK; +} + +int32_t vbap1_init(CSOUND *csound, VBAP1 *p) +{ /* Initializations before run time*/ + int32_t i, j; + MYFLT *ls_table, *ptr; + LS_SET *ls_set_ptr; + char name[24]; + snprintf(name, 24, "vbap_ls_table_%d", (int32_t)*p->layout); + ls_table = (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, name)); + if (ls_table==NULL) + return csound->InitError(csound, + Str("could not find layout table no.%d"), + (int32_t)*p->layout ); + p->q.number = p->OUTOCOUNT; + p->q.dim = (int32_t)ls_table[0]; /* reading in loudspeaker info */ + p->q.ls_am = (int32_t)ls_table[1]; + p->q.ls_set_am = (int32_t)ls_table[2]; + ptr = &(ls_table[3]); + if (!p->q.ls_set_am) + return csound->InitError(csound, "%s", Str("vbap system NOT configured.\nMissing" + " vbaplsinit opcode in orchestra?")); + csound->AuxAlloc(csound, p->q.ls_set_am * sizeof (LS_SET), &p->q.aux); + if (UNLIKELY(p->q.aux.auxp == NULL)) { + return csound->InitError(csound, "%s", Str("could not allocate memory")); + } + p->q.ls_sets = (LS_SET*) p->q.aux.auxp; + ls_set_ptr = p->q.ls_sets; + for (i=0; i < p->q.ls_set_am; i++) { + ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ + for (j=0 ; j < p->q.dim ; j++) { + ls_set_ptr[i].ls_nos[j] = (int32_t)*(ptr++); + } + memset(ls_set_ptr[i].ls_mx, '\0', 9*sizeof(MYFLT)); // initial setting + /* for (j=0 ; j < 9; j++) */ + /* ls_set_ptr[i].ls_mx[j] = FL(0.0); /\*initial setting*\/ */ + for (j=0 ; j < (p->q.dim) * (p->q.dim); j++) { + ls_set_ptr[i].ls_mx[j] = (MYFLT)*(ptr++); + } + } + + /* other initialization */ + if (UNLIKELY(p->q.dim == 2 && fabs(*p->ele) > 0.0)) { + csound->Warning(csound, + "%s", Str("Warning: truncating elevation to 2-D plane\n")); + *p->ele = FL(0.0); + } + p->q.ang_dir.azi = (MYFLT)*p->azi; + p->q.ang_dir.ele = (MYFLT)*p->ele; + p->q.ang_dir.length = FL(1.0); + angle_to_cart(p->q.ang_dir, &(p->q.cart_dir)); + p->q.spread_base.x = p->q.cart_dir.y; + p->q.spread_base.y = p->q.cart_dir.z; + p->q.spread_base.z = -p->q.cart_dir.x; + vbap1_control(csound,&p->q, p->azi, p->ele, p->spread); + return OK; +} + +int32_t vbap1a(CSOUND *csound, VBAPA1 *p) /* during note performance: */ +{ + int32_t j; + int32_t cnt = p->q.number; + vbap1_control(csound,&p->q, p->azi, p->ele, p->spread); + + /* write gains */ + for (j=0; jtabout->data[j] = p->q.gains[j]; + } + return OK; +} + +int32_t vbap1_init_a(CSOUND *csound, VBAPA1 *p) +{ /* Initializations before run time*/ + int32_t i, j; + MYFLT *ls_table, *ptr; + LS_SET *ls_set_ptr; + char name[24]; + snprintf(name, 24, "vbap_ls_table_%d", (int32_t)*p->layout); + ls_table = (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, name)); + if (ls_table==NULL) + return csound->InitError(csound, + Str("could not find layout table no.%d"), + (int32_t)*p->layout ); + p->q.number = p->tabout->sizes[0]; + p->q.dim = (int32_t)ls_table[0]; /* reading in loudspeaker info */ + p->q.ls_am = (int32_t)ls_table[1]; + p->q.ls_set_am = (int32_t)ls_table[2]; + ptr = &(ls_table[3]); + if (!p->q.ls_set_am) + return csound->InitError(csound, "%s", Str("vbap system NOT configured.\nMissing" + " vbaplsinit opcode in orchestra?")); + csound->AuxAlloc(csound, p->q.ls_set_am * sizeof (LS_SET), &p->q.aux); + if (UNLIKELY(p->q.aux.auxp == NULL)) { + return csound->InitError(csound, "%s", Str("could not allocate memory")); + } + p->q.ls_sets = (LS_SET*) p->q.aux.auxp; + ls_set_ptr = p->q.ls_sets; + for (i=0; i < p->q.ls_set_am; i++) { + ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ + for (j=0 ; j < p->q.dim ; j++) { + ls_set_ptr[i].ls_nos[j] = (int32_t)*(ptr++); + } + memset(ls_set_ptr[i].ls_mx, '\0', 9*sizeof(MYFLT)); /*initial setting*/ + for (j=0 ; j < (p->q.dim) * (p->q.dim); j++) { + ls_set_ptr[i].ls_mx[j] = (MYFLT)*(ptr++); + } + } + + /* other initialization */ + if (UNLIKELY(p->q.dim == 2 && fabs(*p->ele) > 0.0)) { + csound->Warning(csound, + "%s", Str("Warning: truncating elevation to 2-D plane\n")); + *p->ele = FL(0.0); + } + p->q.ang_dir.azi = (MYFLT)*p->azi; + p->q.ang_dir.ele = (MYFLT)*p->ele; + p->q.ang_dir.length = FL(1.0); + angle_to_cart(p->q.ang_dir, &(p->q.cart_dir)); + p->q.spread_base.x = p->q.cart_dir.y; + p->q.spread_base.y = p->q.cart_dir.z; + p->q.spread_base.z = -p->q.cart_dir.x; + vbap1_control(csound,&p->q, p->azi, p->ele, p->spread); + return OK; +} + +int32_t vbap1_moving(CSOUND *csound, VBAP1_MOVING *p) +{ /* during note performance: */ + int32_t j; + int32_t cnt = p->q.number; + + vbap1_moving_control(csound,&p->q, &(p->h), CS_ONEDKR, + *p->spread, *p->field_am, p->fld); + + /* write audio to resulting audio streams weighted + with gain factors*/ + for (j=0; jout_array[j] = p->q.gains[j]; + } + return OK; +} + +int32_t vbap1_moving_a(CSOUND *csound, VBAPA1_MOVING *p) +{ /* during note performance: */ + // int32_t j; + int32_t cnt = p->q.number; + + vbap1_moving_control(csound,&p->q, &(p->h), CS_ONEDKR, + *p->spread, *p->field_am, p->fld); + + /* write audio to resulting audio streams weighted + with gain factors*/ + memcpy(p->tabout->data, p->q.gains, cnt*sizeof(MYFLT)); + /* for (j=0; jtabout->data[j] = p->q.gains[j]; */ + /* } */ + return OK; +} + +static int32_t vbap1_moving_control(CSOUND *csound, VBAP1_MOVE_DATA *p, + OPDS *h, MYFLT ONEDKR, + MYFLT spread, MYFLT field_am, MYFLT **fld) +{ + CART_VEC spreaddir[16]; + CART_VEC spreadbase[16]; + ANG_VEC atmp; + int32 i,j, spreaddirnum; + CART_VEC tmp1, tmp2, tmp3; + MYFLT coeff, angle; + int32_t cnt = p->number; + MYFLT *tmp_gains=malloc(sizeof(MYFLT)*cnt),sum=FL(0.0); +#ifdef JPFF + printf("cnt=%d dim=%d\n", cnt, p->dim); +#endif + if (UNLIKELY(p->dim == 2 && fabs(p->ang_dir.ele) > 0.0)) { + csound->Warning(csound, + "%s", Str("Warning: truncating elevation to 2-D plane\n")); + p->ang_dir.ele = FL(0.0); + } + if (spread FL(100.0)) + spread = FL(100.0); + if (p->point_change_counter++ >= p->point_change_interval) { + p->point_change_counter = 0; + p->curr_fld = p->next_fld; + if (++p->next_fld >= (int32_t) fabs(field_am)) { + if (field_am >= FL(0.0)) /* point-to-point */ + p->next_fld = 0; + else + p->next_fld = 1; + } + if (p->dim == 3) { /*jumping over second field */ + p->curr_fld = p->next_fld; + if (++p->next_fld >= ((int32_t) fabs(field_am))) { + if (field_am >= FL(0.0)) /* point-to-point */ + p->next_fld = 0; + else + p->next_fld = 1; + } + } + if (UNLIKELY((fld[abs(p->next_fld)]==NULL))) { + free(tmp_gains); + return csound->PerfError(csound, h, + "%s", Str("Missing fields in vbapmove\n")); + } + if (field_am >= FL(0.0) && p->dim == 2) /* point-to-point */ + if (UNLIKELY(fabs(fabs(*fld[p->next_fld] - + *fld[p->curr_fld]) - 180.0) < 1.0)) + csound->Warning(csound, + "%s", Str("Warning: Ambiguous transition 180 degrees.\n")); + } + if (field_am >= FL(0.0)) { /* point-to-point */ + if (p->dim == 3) { /* 3-D*/ + p->prev_ang_dir.azi = *fld[p->curr_fld-1]; + p->next_ang_dir.azi = *fld[p->next_fld]; + p->prev_ang_dir.ele = *fld[p->curr_fld]; + p->next_ang_dir.ele = *fld[p->next_fld+1]; + coeff = ((MYFLT) p->point_change_counter) / + ((MYFLT) p->point_change_interval); + angle_to_cart( p->prev_ang_dir,&tmp1); + angle_to_cart( p->next_ang_dir,&tmp2); + tmp3.x = (FL(1.0)-coeff) * tmp1.x + coeff * tmp2.x; + tmp3.y = (FL(1.0)-coeff) * tmp1.y + coeff * tmp2.y; + tmp3.z = (FL(1.0)-coeff) * tmp1.z + coeff * tmp2.z; + coeff = (MYFLT)sqrt((double)(tmp3.x * tmp3.x + + tmp3.y * tmp3.y + + tmp3.z * tmp3.z)); + tmp3.x /= coeff; tmp3.y /= coeff; tmp3.z /= coeff; + cart_to_angle(tmp3,&(p->ang_dir)); + } + else if (p->dim == 2) { /* 2-D */ + p->prev_ang_dir.azi = *fld[p->curr_fld]; + p->next_ang_dir.azi = *fld[p->next_fld ]; + p->prev_ang_dir.ele = p->next_ang_dir.ele = FL(0.0); + scale_angles(&(p->prev_ang_dir)); + scale_angles(&(p->next_ang_dir)); + angle = (p->prev_ang_dir.azi - p->next_ang_dir.azi); + while (angle > FL(180.0)) + angle -= FL(360.0); + while (angle < -FL(180.0)) + angle += FL(360.0); + coeff = ((MYFLT) p->point_change_counter) / + ((MYFLT) p->point_change_interval); + angle *= (coeff); + p->ang_dir.azi = p->prev_ang_dir.azi - angle; + p->ang_dir.ele = FL(0.0); + } + else { + free(tmp_gains); + return csound->PerfError(csound, h, + "%s", Str("Missing fields in vbapmove\n")); + } + } + else { /* angular velocities */ + if (p->dim == 2) { + p->ang_dir.azi = p->ang_dir.azi + + (*fld[p->next_fld] * ONEDKR); + scale_angles(&(p->ang_dir)); + } + else { /* 3D angular*/ + p->ang_dir.azi = p->ang_dir.azi + + (*fld[p->next_fld] * ONEDKR); + p->ang_dir.ele = p->ang_dir.ele + + p->ele_vel * (*fld[p->next_fld+1] * ONEDKR); + if (p->ang_dir.ele > FL(90.0)) { + p->ang_dir.ele = FL(90.0); + p->ele_vel = -p->ele_vel; + } + if (p->ang_dir.ele < FL(0.0)) { + p->ang_dir.ele = FL(0.0); + p->ele_vel = -p->ele_vel; + } + scale_angles(&(p->ang_dir)); + } + } + angle_to_cart(p->ang_dir, &(p->cart_dir)); + calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, + p->gains, cnt, p->cart_dir); + if (spread > FL(0.0)) { + if (p->dim == 3) { + spreaddirnum=16; + /* four orthogonal dirs*/ + new_spread_dir(&spreaddir[0], p->cart_dir, + p->spread_base, p->ang_dir.azi, spread); + + new_spread_base(spreaddir[0], p->cart_dir, spread, &p->spread_base); + cross_prod(p->spread_base, p->cart_dir, &spreadbase[1]); + cross_prod(spreadbase[1], p->cart_dir, &spreadbase[2]); + cross_prod(spreadbase[2], p->cart_dir, &spreadbase[3]); + /* four between them*/ + vec_mean(p->spread_base, spreadbase[1], &spreadbase[4]); + vec_mean(spreadbase[1], spreadbase[2], &spreadbase[5]); + vec_mean(spreadbase[2], spreadbase[3], &spreadbase[6]); + vec_mean(spreadbase[3], p->spread_base, &spreadbase[7]); + + /* four at half spreadangle*/ + vec_mean(p->cart_dir, p->spread_base, &spreadbase[8]); + vec_mean(p->cart_dir, spreadbase[1], &spreadbase[9]); + vec_mean(p->cart_dir, spreadbase[2], &spreadbase[10]); + vec_mean(p->cart_dir, spreadbase[3], &spreadbase[11]); + + /* four at quarter spreadangle*/ + vec_mean(p->cart_dir, spreadbase[8], &spreadbase[12]); + vec_mean(p->cart_dir, spreadbase[9], &spreadbase[13]); + vec_mean(p->cart_dir, spreadbase[10], &spreadbase[14]); + vec_mean(p->cart_dir, spreadbase[11], &spreadbase[15]); + + for (i=1;icart_dir, + spreadbase[i],p->ang_dir.azi,spread); + calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, + tmp_gains, cnt, spreaddir[i]); + for (j=0;jgains[j] += tmp_gains[j]; + } + } + } + else if (p->dim == 2) { + spreaddirnum=6; + atmp.ele = FL(0.0); + atmp.azi = p->ang_dir.azi - spread; + angle_to_cart(atmp, &spreaddir[0]); + atmp.azi = p->ang_dir.azi - spread/2; + angle_to_cart(atmp, &spreaddir[1]); + atmp.azi = p->ang_dir.azi - spread/4; + angle_to_cart(atmp, &spreaddir[2]); + atmp.azi = p->ang_dir.azi + spread/4; + angle_to_cart(atmp, &spreaddir[3]); + atmp.azi = p->ang_dir.azi + spread/2; + angle_to_cart(atmp, &spreaddir[4]); + atmp.azi = p->ang_dir.azi + spread; + angle_to_cart(atmp, &spreaddir[5]); + + for (i=0;ils_set_am, p->dim, p->ls_sets, + tmp_gains, cnt, spreaddir[i]); + for (j=0;jgains[j] += tmp_gains[j]; + } + } + } + } + if (spread > FL(70.0)) + for (i=0;igains[i] +=(spread - FL(70.0))/FL(30.0) * + (spread - FL(70.0))/FL(30.0)*FL(10.0); + } + /*normalization*/ + for (i=0;igains[i]*p->gains[i]); + } + + sum=SQRT(sum); + for (i=0;igains[i] /= sum; + } + free(tmp_gains); + return OK; +} + +int32_t vbap1_moving_init(CSOUND *csound, VBAP1_MOVING *p) +{ + int32_t i, j; + MYFLT *ls_table, *ptr; + LS_SET *ls_set_ptr; + + p->q.number = p->OUTCOUNT; + ls_table = + (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, "vbap_ls_table_0")); + /* reading in loudspeaker info */ + p->q.dim = (int32_t)ls_table[0]; + p->q.ls_am = (int32_t)ls_table[1]; + p->q.ls_set_am = (int32_t)ls_table[2]; + ptr = &(ls_table[3]); + if (!p->q.ls_set_am) + return csound->InitError(csound, "%s", Str("vbap system NOT configured.\n" + "Missing vbaplsinit opcode" + " in orchestra?")); + csound->AuxAlloc(csound, p->q.ls_set_am * sizeof(LS_SET), &p->q.aux); + if (UNLIKELY(p->q.aux.auxp == NULL)) { + return csound->InitError(csound, "%s", Str("could not allocate memory")); + } + p->q.ls_sets = (LS_SET*) p->q.aux.auxp; + ls_set_ptr = p->q.ls_sets; + for (i=0 ; i < p->q.ls_set_am ; i++) { + ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ + for (j=0 ; j < p->q.dim ; j++) { + ls_set_ptr[i].ls_nos[j] = (int32_t)*(ptr++); + } + for (j=0 ; j < 9; j++) + ls_set_ptr[i].ls_mx[j] = FL(0.0); /*initial setting*/ + for (j=0 ; j < (p->q.dim) * (p->q.dim); j++) { + ls_set_ptr[i].ls_mx[j] = (MYFLT)*(ptr++); + } + } + + /* other initialization */ + p->q.ele_vel = FL(1.0); /* functions specific to movement */ + if (UNLIKELY(fabs(*p->field_am) < (2+ (p->q.dim - 2)*2))) { + return csound->InitError(csound, + Str("Have to have at least %d directions in vbapmove"), + 2 + (p->q.dim - 2) * 2); + } + if (p->q.dim == 2) + p->q.point_change_interval = + (int32_t)(CS_EKR * *p->dur /(fabs(*p->field_am) - 1.0)); + else if (LIKELY(p->q.dim == 3)) + p->q.point_change_interval = + (int32_t)(CS_EKR * *p->dur /(fabs(*p->field_am)*0.5 - 1.0)); + else + return csound->InitError(csound, "%s", Str("Wrong dimension")); + p->q.point_change_counter = 0; + p->q.curr_fld = 0; + p->q.next_fld = 1; + p->q.ang_dir.azi = *p->fld[0]; + if (p->q.dim == 3) { + p->q.ang_dir.ele = *p->fld[1]; + } else { + p->q.ang_dir.ele = FL(0.0); + } + if (p->q.dim == 3) { + p->q.curr_fld = 1; + p->q.next_fld = 2; + } + angle_to_cart(p->q.ang_dir, &(p->q.cart_dir)); + p->q.spread_base.x = p->q.cart_dir.y; + p->q.spread_base.y = p->q.cart_dir.z; + p->q.spread_base.z = -p->q.cart_dir.x; + vbap1_moving_control(csound,&p->q, &(p->h), CS_ONEDKR, + *p->spread, *p->field_am, p->fld); + return OK; +} + +int32_t vbap1_moving_init_a(CSOUND *csound, VBAPA1_MOVING *p) +{ + int32_t i, j; + MYFLT *ls_table, *ptr; + LS_SET *ls_set_ptr; + + if (UNLIKELY(p->tabout->data == NULL || p->tabout->dimensions!=1)) + return csound->InitError(csound, "%s", Str("Output array not initialised")); + p->q.number = p->tabout->sizes[0]; + ls_table = + (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, "vbap_ls_table_0")); + /* reading in loudspeaker info */ + p->q.dim = (int32_t)ls_table[0]; + p->q.ls_am = (int32_t)ls_table[1]; + p->q.ls_set_am = (int32_t)ls_table[2]; + ptr = &(ls_table[3]); + if (UNLIKELY(!p->q.ls_set_am)) + return csound->InitError(csound, "%s", Str("vbap system NOT configured.\n" + "Missing vbaplsinit opcode" + " in orchestra?")); + csound->AuxAlloc(csound, p->q.ls_set_am * sizeof(LS_SET), &p->q.aux); + if (UNLIKELY(p->q.aux.auxp == NULL)) { + return csound->InitError(csound, "%s", Str("could not allocate memory")); + } + p->q.ls_sets = (LS_SET*) p->q.aux.auxp; + ls_set_ptr = p->q.ls_sets; + for (i=0 ; i < p->q.ls_set_am ; i++) { + ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ + for (j=0 ; j < p->q.dim ; j++) { + ls_set_ptr[i].ls_nos[j] = (int32_t)*(ptr++); + } + for (j=0 ; j < 9; j++) + ls_set_ptr[i].ls_mx[j] = FL(0.0); /*initial setting*/ + for (j=0 ; j < (p->q.dim) * (p->q.dim); j++) { + ls_set_ptr[i].ls_mx[j] = (MYFLT)*(ptr++); + } + } + + /* other initialization */ + p->q.ele_vel = FL(1.0); /* functions specific to movement */ + if (UNLIKELY(fabs(*p->field_am) < (2+ (p->q.dim - 2)*2))) { + return csound->InitError(csound, + Str("Have to have at least %d directions in vbapmove"), + 2 + (p->q.dim - 2) * 2); + } + if (p->q.dim == 2) + p->q.point_change_interval = + (int32_t)(CS_EKR * *p->dur /(fabs(*p->field_am) - 1.0)); + else if (LIKELY(p->q.dim == 3)) + p->q.point_change_interval = + (int32_t)(CS_EKR * *p->dur /(fabs(*p->field_am)*0.5 - 1.0)); + else + return csound->InitError(csound, "%s", Str("Wrong dimension")); + p->q.point_change_counter = 0; + p->q.curr_fld = 0; + p->q.next_fld = 1; + p->q.ang_dir.azi = *p->fld[0]; + if (p->q.dim == 3) { + p->q.ang_dir.ele = *p->fld[1]; + } else { + p->q.ang_dir.ele = FL(0.0); + } + if (p->q.dim == 3) { + p->q.curr_fld = 1; + p->q.next_fld = 2; + } + angle_to_cart(p->q.ang_dir, &(p->q.cart_dir)); + p->q.spread_base.x = p->q.cart_dir.y; + p->q.spread_base.y = p->q.cart_dir.z; + p->q.spread_base.z = -p->q.cart_dir.x; + vbap1_moving_control(csound,&p->q, &(p->h), CS_ONEDKR, + *p->spread, *p->field_am, p->fld); + return OK; +} + +#include "arrays.h" + +int32_t vbap_moving_control(CSOUND *, VBAP_MOVE_DATA *, OPDS*, MYFLT, + MYFLT *, MYFLT*,MYFLT**); + +int32_t vbap(CSOUND *csound, VBAP *p) /* during note performance: */ +{ + MYFLT *outptr, *inptr; + MYFLT ogain, ngain, gainsubstr; + MYFLT invfloatn; + int32_t j; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t i, nsmps = CS_KSMPS; + int32_t cnt = p->q.number; + vbap_control(csound,&p->q, p->azi, p->ele, p->spread); + for (j=0; jq.beg_gains[j] = p->q.end_gains[j]; + p->q.end_gains[j] = p->q.updated_gains[j]; + } + + /* write audio to result audio streams weighted + with gain factors*/ + if (UNLIKELY(early)) nsmps -= early; + invfloatn = FL(1.0)/(nsmps-offset); + for (j=0; jaudio; + outptr = p->out_array[j]; + ogain = p->q.beg_gains[j]; + ngain = p->q.end_gains[j]; + gainsubstr = ngain - ogain; + if (UNLIKELY(offset)) memset(outptr, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) memset(&outptr[nsmps], '\0', early*sizeof(MYFLT)); + //printf("cnt%d: ngain=%lf ogain=%f\n", j, ngain, ogain); + if (ngain != FL(0.0) || ogain != FL(0.0)) { + if (ngain != ogain) { + for (i = offset; i < nsmps; i++) { + outptr[i] = inptr[i] * + (ogain + (MYFLT)(i+1) * invfloatn * gainsubstr); + } + p->q.curr_gains[j]= ogain + + (MYFLT)(i) * invfloatn * gainsubstr; + } + else { + for (i=offset; ih.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t i, nsmps = CS_KSMPS; + uint32_t ksmps = nsmps; + int32_t cnt = p->q.number; + + vbap_control(csound,&p->q, p->azi, p->ele, p->spread); + for (j=0; jq.beg_gains[j] = p->q.end_gains[j]; + p->q.end_gains[j] = p->q.updated_gains[j]; + } + + /* write audio to result audio streams weighted + with gain factors*/ + if (UNLIKELY(early)) nsmps -= early; + invfloatn = FL(1.0)/(nsmps-offset); + for (j=0; jtabout->data[j*ksmps]; + inptr = p->audio; + ogain = p->q.beg_gains[j]; + ngain = p->q.end_gains[j]; + gainsubstr = ngain - ogain; + if (UNLIKELY(offset)) memset(outptr, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) memset(&outptr[nsmps], '\0', early*sizeof(MYFLT)); + if (ngain != FL(0.0) || ogain != FL(0.0)) { + if (ngain != ogain) { + for (i = offset; i < nsmps; i++) { + outptr[i] = inptr[i] * + (ogain + (MYFLT)(i+1) * invfloatn * gainsubstr); + } + p->q.curr_gains[j]= ogain + + (MYFLT)(i) * invfloatn * gainsubstr; + } + else { + for (i=offset; inumber; + MYFLT *tmp_gains = malloc(sizeof(MYFLT)*cnt),sum=FL(0.0); + if (UNLIKELY(p->dim == 2 && fabs(*ele) > 0.0)) { + csound->Warning(csound, + "%s", Str("Warning: truncating elevation to 2-D plane\n")); + *ele = FL(0.0); + } + + if (*spread FL(100.0)) + *spread = FL(100.0); + /* Current panning angles */ + p->ang_dir.azi = (MYFLT) *azi; + p->ang_dir.ele = (MYFLT) *ele; + p->ang_dir.length = FL(1.0); + angle_to_cart(p->ang_dir, &(p->cart_dir)); + calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, + p->updated_gains, cnt, p->cart_dir); + + /* Calculated gain factors of a spreaded virtual source*/ + if (*spread > FL(0.0)) { + if (p->dim == 3) { + spreaddirnum = 16; + /* four orthogonal dirs*/ + new_spread_dir(&spreaddir[0], p->cart_dir, + p->spread_base, *azi, *spread); + new_spread_base(spreaddir[0], p->cart_dir, + *spread, &p->spread_base); + cross_prod(p->spread_base, p->cart_dir, &spreadbase[1]); + cross_prod(spreadbase[1], p->cart_dir, &spreadbase[2]); + cross_prod(spreadbase[2], p->cart_dir, &spreadbase[3]); + /* four between them*/ + vec_mean(p->spread_base, spreadbase[1], &spreadbase[4]); + vec_mean(spreadbase[1], spreadbase[2], &spreadbase[5]); + vec_mean(spreadbase[2], spreadbase[3], &spreadbase[6]); + vec_mean(spreadbase[3], p->spread_base, &spreadbase[7]); + + /* four at half spreadangle*/ + vec_mean(p->cart_dir, p->spread_base, &spreadbase[8]); + vec_mean(p->cart_dir, spreadbase[1], &spreadbase[9]); + vec_mean(p->cart_dir, spreadbase[2], &spreadbase[10]); + vec_mean(p->cart_dir, spreadbase[3], &spreadbase[11]); + + /* four at quarter spreadangle*/ + vec_mean(p->cart_dir, spreadbase[8], &spreadbase[12]); + vec_mean(p->cart_dir, spreadbase[9], &spreadbase[13]); + vec_mean(p->cart_dir, spreadbase[10], &spreadbase[14]); + vec_mean(p->cart_dir, spreadbase[11], &spreadbase[15]); + + for (i=1;icart_dir, + spreadbase[i],*azi,*spread); + calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, + tmp_gains, cnt, spreaddir[i]); + for (j=0;jupdated_gains[j] += tmp_gains[j]; + } + } + } + else if (p->dim == 2) { + spreaddirnum = 6; + atmp.ele = FL(0.0); + atmp.azi = *azi - *spread; + angle_to_cart(atmp, &spreaddir[0]); + atmp.azi = *azi - *spread/2; + angle_to_cart(atmp, &spreaddir[1]); + atmp.azi = *azi - *spread/4; + angle_to_cart(atmp, &spreaddir[2]); + atmp.azi = *azi + *spread/4; + angle_to_cart(atmp, &spreaddir[3]); + atmp.azi = *azi + *spread/2; + angle_to_cart(atmp, &spreaddir[4]); + atmp.azi = *azi + *spread; + angle_to_cart(atmp, &spreaddir[5]); + + for (i=0;ils_set_am, p->dim, p->ls_sets, + tmp_gains, cnt, spreaddir[i]); + for (j=0;jupdated_gains[j] += tmp_gains[j]; + } + } + } + } + if (*spread > FL(70.0)) + for (i=0;iupdated_gains[i] +=(*spread - FL(70.0))/FL(30.0) * + (*spread - FL(70.0))/FL(30.0)*FL(20.0); + } + + /*normalization*/ + for (i=0;iupdated_gains[i]*p->updated_gains[i]; + } + + sum=SQRT(sum); + for (i=0;iupdated_gains[i] /= sum; + } + free(tmp_gains); + return OK; +} + +int32_t vbap_init(CSOUND *csound, VBAP *p) +{ /* Initializations before run time*/ + int32_t i, j; + MYFLT *ls_table, *ptr; + LS_SET *ls_set_ptr; + int32_t cnt = p->q.number = (int32_t)(p->OUTOCOUNT); + char name[24]; + + snprintf(name, 24, "vbap_ls_table_%d", (p->layout==NULL?0:(int32_t)*p->layout)); + ls_table = (MYFLT*) (csound->QueryGlobalVariable(csound, name)); + + if (UNLIKELY(ls_table==NULL)) + return csound->InitError(csound, + Str("could not find layout table no.%d"), + (int32_t)*p->layout ); + + p->q.dim = (int32_t)ls_table[0]; /* reading in loudspeaker info */ + p->q.ls_am = (int32_t)ls_table[1]; + p->q.ls_set_am = (int32_t)ls_table[2]; + ptr = &(ls_table[3]); + if (UNLIKELY(!p->q.ls_set_am)) + return csound->InitError(csound, + "%s", Str("vbap system NOT configured.\nMissing" + " vbaplsinit opcode in orchestra?")); + csound->AuxAlloc(csound, p->q.ls_set_am * sizeof (LS_SET), &p->q.aux); + if (UNLIKELY(p->q.aux.auxp == NULL)) { + return csound->InitError(csound, "%s", Str("could not allocate memory")); + } + p->q.ls_sets = (LS_SET*) p->q.aux.auxp; + ls_set_ptr = p->q.ls_sets; + for (i=0; i < p->q.ls_set_am; i++) { + ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ + for (j=0 ; j < p->q.dim ; j++) { + ls_set_ptr[i].ls_nos[j] = (int32_t)*(ptr++); + } + memset(ls_set_ptr[i].ls_mx, '\0', 9*sizeof(MYFLT)); // initial setting + /* for (j=0 ; j < 9; j++) */ + /* ls_set_ptr[i].ls_mx[j] = FL(0.0); /\*initial setting*\/ */ + for (j=0 ; j < (p->q.dim) * (p->q.dim); j++) { + ls_set_ptr[i].ls_mx[j] = (MYFLT)*(ptr++); + } + } + + /* other initialization */ + if (UNLIKELY(p->q.dim == 2 && fabs(p->ele==NULL?0:*p->ele) > 0.0)) { + csound->Warning(csound, + "%s", Str("Warning: truncating elevation to 2-D plane\n")); + *p->ele = FL(0.0); + } + p->q.ang_dir.azi = (MYFLT)*p->azi; + p->q.ang_dir.ele = (MYFLT)*p->ele; + p->q.ang_dir.length = FL(1.0); + angle_to_cart(p->q.ang_dir, &(p->q.cart_dir)); + p->q.spread_base.x = p->q.cart_dir.y; + p->q.spread_base.y = p->q.cart_dir.z; + p->q.spread_base.z = -p->q.cart_dir.x; + vbap_control(csound,&(p->q), p->azi, p->ele, p->spread); + for (i=0;iq.beg_gains[i] = p->q.updated_gains[i]; + p->q.end_gains[i] = p->q.updated_gains[i]; + } + return OK; +} + +int32_t vbap_init_a(CSOUND *csound, VBAPA *p) +{ /* Initializations before run time*/ + int32_t i, j; + MYFLT *ls_table, *ptr; + LS_SET *ls_set_ptr; + int32_t cnt; + char name[24]; + + snprintf(name, 24, "vbap_ls_table_%d", (int32_t)*p->layout); + ls_table = (MYFLT*) (csound->QueryGlobalVariable(csound, name)); + + if (UNLIKELY(ls_table==NULL)) + return csound->InitError(csound, + Str("could not find layout table no.%d"), + (int32_t)*p->layout ); + + p->q.dim = (int32_t)ls_table[0]; /* reading in loudspeaker info */ + p->q.ls_am = (int32_t)ls_table[1]; + p->q.ls_set_am = (int32_t)ls_table[2]; + ptr = &(ls_table[3]); + if (UNLIKELY(!p->q.ls_set_am)) + return csound->InitError(csound, + "%s", Str("vbap system NOT configured.\nMissing" + " vbaplsinit opcode in orchestra?")); + //printf("**** size = %d\n", p->q.ls_set_am); + tabinit(csound, p->tabout, p->q.ls_set_am); + cnt = p->q.number = p->tabout->sizes[0]; + csound->AuxAlloc(csound, p->q.ls_set_am * sizeof(LS_SET), &p->q.aux); + if (UNLIKELY(p->q.aux.auxp == NULL)) { + return csound->InitError(csound, "%s", Str("could not allocate memory")); + } + p->q.ls_sets = (LS_SET*) p->q.aux.auxp; + ls_set_ptr = p->q.ls_sets; + for (i=0; i < p->q.ls_set_am; i++) { + ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ + for (j=0 ; j < p->q.dim ; j++) { + ls_set_ptr[i].ls_nos[j] = (int32_t)*(ptr++); + } + memset(ls_set_ptr[i].ls_mx, '\0', 9*sizeof(MYFLT)); + /* for (j=0 ; j < 9; j++) */ + /* ls_set_ptr[i].ls_mx[j] = FL(0.0); /\*initial setting*\/ */ + for (j=0 ; j < (p->q.dim) * (p->q.dim); j++) { + ls_set_ptr[i].ls_mx[j] = (MYFLT)*(ptr++); + } + } + + /* other initialization */ + if (UNLIKELY(p->q.dim == 2 && fabs(*p->ele) > 0.0)) { + csound->Warning(csound, + "%s", Str("Warning: truncating elevation to 2-D plane\n")); + *p->ele = FL(0.0); + } + p->q.ang_dir.azi = *p->azi; + p->q.ang_dir.ele = *p->ele; + p->q.ang_dir.length = FL(1.0); + angle_to_cart(p->q.ang_dir, &(p->q.cart_dir)); + p->q.spread_base.x = p->q.cart_dir.y; + p->q.spread_base.y = p->q.cart_dir.z; + p->q.spread_base.z = -p->q.cart_dir.x; + vbap_control(csound,&(p->q), p->azi, p->ele, p->spread); + for (i=0;iq.beg_gains[i] = p->q.updated_gains[i]; + p->q.end_gains[i] = p->q.updated_gains[i]; + } + return OK; +} + +int32_t vbap_moving(CSOUND *csound, VBAP_MOVING *p) +{ /* during note performance: */ + MYFLT *outptr, *inptr; + MYFLT ogain, ngain, gainsubstr; + MYFLT invfloatn; + int32_t j; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t i, nsmps = CS_KSMPS; + int32_t cnt = p->q.number; + + vbap_moving_control(csound,&p->q, &(p->h), CS_ONEDKR, + p->spread, p->field_am, p->fld); + // vbap_moving_control(csound,p); + for (j=0;jq.beg_gains[j] = p->q.end_gains[j]; + p->q.end_gains[j] = p->q.updated_gains[j]; + } + + /* write audio to resulting audio streams weighted + with gain factors*/ + if (UNLIKELY(early)) nsmps -= early; + invfloatn = FL(1.0)/(nsmps-offset); + for (j=0; jaudio; + outptr = p->out_array[j]; + if (UNLIKELY(offset)) memset(outptr, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) memset(&outptr[nsmps], '\0', early*sizeof(MYFLT)); + ogain = p->q.beg_gains[j]; + ngain = p->q.end_gains[j]; + gainsubstr = ngain - ogain; + if (ngain != FL(0.0) || ogain != FL(0.0)) + if (ngain != ogain) { + for (i = offset; i < nsmps; i++) { + outptr[i] = inptr[i] * + (ogain + (MYFLT)(i+1) * invfloatn * gainsubstr); + } + p->q.curr_gains[j]= ogain + + (MYFLT)(i) * invfloatn * gainsubstr; + } + else + for (i=offset; inumber; + MYFLT *tmp_gains=malloc(sizeof(MYFLT)*cnt),sum=FL(0.0); + + if (UNLIKELY(p->dim == 2 && fabs(p->ang_dir.ele) > 0.0)) { + csound->Warning(csound, + "%s", Str("Warning: truncating elevation to 2-D plane\n")); + p->ang_dir.ele = FL(0.0); + } + if (*spread FL(100.0)) + *spread = FL(100.0); + if (p->point_change_counter++ >= p->point_change_interval) { + p->point_change_counter = 0; + p->curr_fld = p->next_fld; + if (++p->next_fld >= (int32_t) fabs(*field_am)) { + if (*field_am >= FL(0.0)) /* point-to-point */ + p->next_fld = 0; + else + p->next_fld = 1; + } + if (p->dim == 3) { /*jumping over second field */ + p->curr_fld = p->next_fld; + if (++p->next_fld >= ((int32_t) fabs(*field_am))) { + if (*field_am >= FL(0.0)) /* point-to-point */ + p->next_fld = 0; + else + p->next_fld = 1; + } + } + if (UNLIKELY((fld[abs(p->next_fld)]==NULL))) { + free(tmp_gains); + return csound->PerfError(csound, h, + "%s", Str("Missing fields in vbapmove\n")); + } + if (*field_am >= FL(0.0) && p->dim == 2) /* point-to-point */ + if (UNLIKELY(fabs(fabs(*fld[p->next_fld] - + *fld[p->curr_fld]) - 180.0) < 1.0)) + csound->Warning(csound, + "%s", Str("Warning: Ambiguous transition 180 degrees.\n")); + } + if (*field_am >= FL(0.0)) { /* point-to-point */ + if (p->dim == 3) { /* 3-D*/ + p->prev_ang_dir.azi = *fld[p->curr_fld-1]; + p->next_ang_dir.azi = *fld[p->next_fld]; + p->prev_ang_dir.ele = *fld[p->curr_fld]; + p->next_ang_dir.ele = *fld[p->next_fld+1]; + coeff = ((MYFLT) p->point_change_counter) / + ((MYFLT) p->point_change_interval); + angle_to_cart( p->prev_ang_dir,&tmp1); + angle_to_cart( p->next_ang_dir,&tmp2); + tmp3.x = (FL(1.0)-coeff) * tmp1.x + coeff * tmp2.x; + tmp3.y = (FL(1.0)-coeff) * tmp1.y + coeff * tmp2.y; + tmp3.z = (FL(1.0)-coeff) * tmp1.z + coeff * tmp2.z; + coeff = (MYFLT)sqrt((double)(tmp3.x * tmp3.x + + tmp3.y * tmp3.y + + tmp3.z * tmp3.z)); + tmp3.x /= coeff; tmp3.y /= coeff; tmp3.z /= coeff; + cart_to_angle(tmp3,&(p->ang_dir)); + } + else if (LIKELY(p->dim == 2)) { /* 2-D */ + p->prev_ang_dir.azi = *fld[p->curr_fld]; + p->next_ang_dir.azi = *fld[p->next_fld ]; + p->prev_ang_dir.ele = p->next_ang_dir.ele = FL(0.0); + scale_angles(&(p->prev_ang_dir)); + scale_angles(&(p->next_ang_dir)); + angle = (p->prev_ang_dir.azi - p->next_ang_dir.azi); + while (angle > FL(180.0)) + angle -= FL(360.0); + while (angle < -FL(180.0)) + angle += FL(360.0); + coeff = ((MYFLT) p->point_change_counter) / + ((MYFLT) p->point_change_interval); + angle *= (coeff); + p->ang_dir.azi = p->prev_ang_dir.azi - angle; + p->ang_dir.ele = FL(0.0); + } + else { + free(tmp_gains); + return csound->PerfError(csound, h, + "%s", Str("Missing fields in vbapmove\n")); + } + } + else { /* angular velocities */ + if (p->dim == 2) { + p->ang_dir.azi = p->ang_dir.azi + + (*fld[p->next_fld] * ONEDKR); + scale_angles(&(p->ang_dir)); + } + else { /* 3D angular*/ + p->ang_dir.azi = p->ang_dir.azi + + (*fld[p->next_fld] * ONEDKR); + p->ang_dir.ele = p->ang_dir.ele + + p->ele_vel * (*fld[p->next_fld+1] * ONEDKR); + if (p->ang_dir.ele > FL(90.0)) { + p->ang_dir.ele = FL(90.0); + p->ele_vel = -p->ele_vel; + } + if (p->ang_dir.ele < FL(0.0)) { + p->ang_dir.ele = FL(0.0); + p->ele_vel = -p->ele_vel; + } + scale_angles(&(p->ang_dir)); + } + } + angle_to_cart(p->ang_dir, &(p->cart_dir)); + calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, + p->updated_gains, cnt, p->cart_dir); + if (*spread > FL(0.0)) { + if (p->dim == 3) { + spreaddirnum=16; + /* four orthogonal dirs*/ + new_spread_dir(&spreaddir[0], p->cart_dir, + p->spread_base, p->ang_dir.azi, *spread); + + new_spread_base(spreaddir[0], p->cart_dir,*spread, &p->spread_base); + cross_prod(p->spread_base, p->cart_dir, &spreadbase[1]); + cross_prod(spreadbase[1], p->cart_dir, &spreadbase[2]); + cross_prod(spreadbase[2], p->cart_dir, &spreadbase[3]); + /* four between them*/ + vec_mean(p->spread_base, spreadbase[1], &spreadbase[4]); + vec_mean(spreadbase[1], spreadbase[2], &spreadbase[5]); + vec_mean(spreadbase[2], spreadbase[3], &spreadbase[6]); + vec_mean(spreadbase[3], p->spread_base, &spreadbase[7]); + + /* four at half spreadangle*/ + vec_mean(p->cart_dir, p->spread_base, &spreadbase[8]); + vec_mean(p->cart_dir, spreadbase[1], &spreadbase[9]); + vec_mean(p->cart_dir, spreadbase[2], &spreadbase[10]); + vec_mean(p->cart_dir, spreadbase[3], &spreadbase[11]); + + /* four at quarter spreadangle*/ + vec_mean(p->cart_dir, spreadbase[8], &spreadbase[12]); + vec_mean(p->cart_dir, spreadbase[9], &spreadbase[13]); + vec_mean(p->cart_dir, spreadbase[10], &spreadbase[14]); + vec_mean(p->cart_dir, spreadbase[11], &spreadbase[15]); + + for (i=1;icart_dir, + spreadbase[i],p->ang_dir.azi,*spread); + calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, + tmp_gains, cnt, spreaddir[i]); + for (j=0;jupdated_gains[j] += tmp_gains[j]; + } + } + } + else if (p->dim == 2) { + spreaddirnum=6; + atmp.ele = FL(0.0); + atmp.azi = p->ang_dir.azi - *spread; + angle_to_cart(atmp, &spreaddir[0]); + atmp.azi = p->ang_dir.azi - *spread/2; + angle_to_cart(atmp, &spreaddir[1]); + atmp.azi = p->ang_dir.azi - *spread/4; + angle_to_cart(atmp, &spreaddir[2]); + atmp.azi = p->ang_dir.azi + *spread/4; + angle_to_cart(atmp, &spreaddir[3]); + atmp.azi = p->ang_dir.azi + *spread/2; + angle_to_cart(atmp, &spreaddir[4]); + atmp.azi = p->ang_dir.azi + *spread; + angle_to_cart(atmp, &spreaddir[5]); + + for (i=0;ils_set_am, p->dim, p->ls_sets, + tmp_gains, cnt, spreaddir[i]); + for (j=0;jupdated_gains[j] += tmp_gains[j]; + } + } + } + } + if (*spread > FL(70.0)) + for (i=0;iupdated_gains[i] +=(*spread - FL(70.0))/FL(30.0) * + (*spread - FL(70.0))/FL(30.0)*FL(10.0); + } + /*normalization*/ + for (i=0;iupdated_gains[i]*p->updated_gains[i]); + } + + sum=SQRT(sum); + for (i=0;iupdated_gains[i] /= sum; + } + free(tmp_gains); + return OK; +} + +int32_t vbap_moving_init(CSOUND *csound, VBAP_MOVING *p) +{ + int32_t i, j; + MYFLT *ls_table, *ptr; + LS_SET *ls_set_ptr; + int32_t cnt = (int32_t)p->h.optext->t.outArgCount; + if ((!strncmp(p->h.optext->t.opcod, "vbapmove", 8)) == 0) { + p->audio = p->out_array[cnt]; + p->dur = p->out_array[cnt+1]; + p->spread = p->out_array[cnt+2]; + p->field_am = p->out_array[cnt+3]; + memcpy(p->fld, &(p->out_array[cnt+4]), + sizeof(MYFLT *)*(p->h.optext->t.inArgCount-4)); + } + + ls_table = (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, + "vbap_ls_table_0")); + if (UNLIKELY(ls_table==NULL)) + return csound->InitError(csound, "%s", Str("could not find layout table no.0")); + p->q.number = cnt; + /* reading in loudspeaker info */ + p->q.dim = (int32_t)ls_table[0]; + p->q.ls_am = (int32_t)ls_table[1]; + p->q.ls_set_am = (int32_t)ls_table[2]; + ptr = &(ls_table[3]); + if (UNLIKELY(!p->q.ls_set_am)) + return csound->InitError(csound, "%s", Str("vbap system NOT configured.\nMissing" + " vbaplsinit opcode in orchestra?")); + csound->AuxAlloc(csound, p->q.ls_set_am * sizeof(LS_SET), &p->q.aux); + if (UNLIKELY(p->q.aux.auxp == NULL)) { + return csound->InitError(csound, "%s", Str("could not allocate memory")); + } + p->q.ls_sets = (LS_SET*) p->q.aux.auxp; + ls_set_ptr = p->q.ls_sets; + for (i=0 ; i < p->q.ls_set_am ; i++) { + ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ + for (j=0 ; j < p->q.dim ; j++) { + ls_set_ptr[i].ls_nos[j] = (int32_t)*(ptr++); + } + for (j=0 ; j < 9; j++) + ls_set_ptr[i].ls_mx[j] = FL(0.0); /*initial setting*/ + for (j=0 ; j < (p->q.dim) * (p->q.dim); j++) { + ls_set_ptr[i].ls_mx[j] = (MYFLT)*(ptr++); + } + } + + /* other initialization */ + p->q.ele_vel = FL(1.0); /* functions specific to movement */ + if (UNLIKELY(fabs(*p->field_am) < (2+ (p->q.dim - 2)*2))) { + return csound->InitError(csound, + Str("Have to have at least %d directions in vbapmove"), + 2 + (p->q.dim - 2) * 2); + } + if (p->q.dim == 2) + p->q.point_change_interval = + (int32_t)(CS_EKR * *p->dur /(fabs(*p->field_am) - 1.0)); + else if (LIKELY(p->q.dim == 3)) + p->q.point_change_interval = + (int32_t)(CS_EKR * *p->dur /(fabs(*p->field_am)*0.5 - 1.0)); + else + return csound->InitError(csound, "%s", Str("Wrong dimension")); + p->q.point_change_counter = 0; + p->q.curr_fld = 0; + p->q.next_fld = 1; + p->q.ang_dir.azi = *p->fld[0]; + if (p->q.dim == 3) { + p->q.ang_dir.ele = *p->fld[1]; + } else { + p->q.ang_dir.ele = FL(0.0); + } + if (p->q.dim == 3) { + p->q.curr_fld = 1; + p->q.next_fld = 2; + } + angle_to_cart(p->q.ang_dir, &(p->q.cart_dir)); + p->q.spread_base.x = p->q.cart_dir.y; + p->q.spread_base.y = p->q.cart_dir.z; + p->q.spread_base.z = -p->q.cart_dir.x; + vbap_moving_control(csound,&p->q, &(p->h), CS_ONEDKR, + p->spread, p->field_am, p->fld); + for (i = 0; iq.beg_gains[i] = p->q.updated_gains[i]; + p->q.end_gains[i] = p->q.updated_gains[i]; + } + return OK; +} + +int32_t vbap_moving_a(CSOUND *csound, VBAPA_MOVING *p) +{ /* during note performance: */ + MYFLT *outptr, *inptr; + MYFLT ogain, ngain, gainsubstr; + MYFLT invfloatn; + int32_t j; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t i, nsmps = CS_KSMPS; + uint32_t ksmps = nsmps; + int32_t cnt = p->q.number; + + vbap_moving_control(csound,&p->q, &(p->h), CS_ONEDKR, + p->spread, p->field_am, p->fld); + // vbap_moving_control(csound,p); + for (j=0;jq.beg_gains[j] = p->q.end_gains[j]; + p->q.end_gains[j] = p->q.updated_gains[j]; + } + + /* write audio to resulting audio streams weighted + with gain factors*/ + if (UNLIKELY(early)) nsmps -= early; + invfloatn = FL(1.0)/(nsmps-offset); + //outptr = p->tabout->data; + for (j=0; jaudio; + outptr = &p->tabout->data[j*ksmps]; + if (UNLIKELY(offset)) memset(outptr, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) memset(&outptr[nsmps], '\0', early*sizeof(MYFLT)); + ogain = p->q.beg_gains[j]; + ngain = p->q.end_gains[j]; + gainsubstr = ngain - ogain; + if (ngain != FL(0.0) || ogain != FL(0.0)) + if (ngain != ogain) { + for (i = offset; i < nsmps; i++) { + outptr[i] = inptr[i] * + (ogain + (MYFLT)(i+1) * invfloatn * gainsubstr); + } + p->q.curr_gains[j]= ogain + + (MYFLT)(i) * invfloatn * gainsubstr; + } + else + for (i=offset; itabout->data==NULL)) { + return csound->InitError(csound, + "%s", Str("Output array in vpabmove not initialised")); + } + cnt = p->tabout->sizes[0]; + + ls_table = (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, + "vbap_ls_table_0")); + if (UNLIKELY(ls_table==NULL)) + return csound->InitError(csound, "%s", Str("could not find layout table no.0")); + p->q.number = cnt; + /* reading in loudspeaker info */ + p->q.dim = (int32_t)ls_table[0]; + p->q.ls_am = (int32_t)ls_table[1]; + p->q.ls_set_am = (int32_t)ls_table[2]; + ptr = &(ls_table[3]); + if (UNLIKELY(!p->q.ls_set_am)) + return csound->InitError(csound, + "%s", Str("vbap system NOT configured.\nMissing" + " vbaplsinit opcode in orchestra?")); + csound->AuxAlloc(csound, p->q.ls_set_am * sizeof(LS_SET), &p->q.aux); + if (UNLIKELY(p->q.aux.auxp == NULL)) { + return csound->InitError(csound, "%s", Str("could not allocate memory")); + } + p->q.ls_sets = (LS_SET*) p->q.aux.auxp; + ls_set_ptr = p->q.ls_sets; + for (i=0 ; i < p->q.ls_set_am ; i++) { + ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ + for (j=0 ; j < p->q.dim ; j++) { + ls_set_ptr[i].ls_nos[j] = (int32_t)*(ptr++); + } + memset(ls_set_ptr[i].ls_mx, '\0', 9*sizeof(MYFLT)); + /* for (j=0 ; j < 9; j++) */ + /* ls_set_ptr[i].ls_mx[j] = FL(0.0); /\*initial setting*\/ */ + for (j=0 ; j < (p->q.dim) * (p->q.dim); j++) { + ls_set_ptr[i].ls_mx[j] = (MYFLT)*(ptr++); + } + } + + /* other initialization */ + p->q.ele_vel = FL(1.0); /* functions specific to movement */ + if (UNLIKELY(fabs(*p->field_am) < (2+ (p->q.dim - 2)*2))) { + return csound->InitError(csound, + Str("Have to have at least %d directions in vbapmove"), + 2 + (p->q.dim - 2) * 2); + } + if (p->q.dim == 2) + p->q.point_change_interval = + (int32_t)(CS_EKR * *p->dur /(fabs(*p->field_am) - 1.0)); + else if (LIKELY(p->q.dim == 3)) + p->q.point_change_interval = + (int32_t)(CS_EKR * *p->dur /(fabs(*p->field_am)*0.5 - 1.0)); + else + return csound->InitError(csound, "%s", Str("Wrong dimension")); + p->q.point_change_counter = 0; + p->q.curr_fld = 0; + p->q.next_fld = 1; + p->q.ang_dir.azi = *p->fld[0]; + if (p->q.dim == 3) { + p->q.ang_dir.ele = *p->fld[1]; + } else { + p->q.ang_dir.ele = FL(0.0); + } + if (p->q.dim == 3) { + p->q.curr_fld = 1; + p->q.next_fld = 2; + } + angle_to_cart(p->q.ang_dir, &(p->q.cart_dir)); + p->q.spread_base.x = p->q.cart_dir.y; + p->q.spread_base.y = p->q.cart_dir.z; + p->q.spread_base.z = -p->q.cart_dir.x; + vbap_moving_control(csound,&p->q, &(p->h), CS_ONEDKR, + p->spread, p->field_am, p->fld); + for (i = 0; iq.beg_gains[i] = p->q.updated_gains[i]; + p->q.end_gains[i] = p->q.updated_gains[i]; + } + return OK; +} + +#include "zak.h" + +int32_t vbap_zak_moving_control(CSOUND *, VBAP_ZAK_MOVING *); +int32_t vbap_zak_control(CSOUND *,VBAP_ZAK *); + +int32_t vbap_zak(CSOUND *csound, VBAP_ZAK *p) /* during note performance: */ +{ + MYFLT *outptr, *inptr; + MYFLT ogain, ngain, gainsubstr; + MYFLT invfloatn; + int32_t j; + int32_t n = p->n; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t i, nsmps = CS_KSMPS; + + vbap_zak_control(csound,p); + for (j=0; jbeg_gains[j] = p->end_gains[j]; + p->end_gains[j] = p->updated_gains[j]; + } + + /* write audio to result audio streams weighted + with gain factors */ + outptr = p->out_array; + if (UNLIKELY(early)) nsmps -= early; + invfloatn = FL(1.0)/(nsmps-offset); + for (j=0; jaudio; + ogain = p->beg_gains[j]; + ngain = p->end_gains[j]; + gainsubstr = ngain - ogain; + if (UNLIKELY(offset)) memset(outptr, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) memset(&outptr[nsmps], '\0', early*sizeof(MYFLT)); + if (ngain != FL(0.0) || ogain != FL(0.0)) + if (ngain != ogain) { + for (i = offset; i < nsmps; i++) { + outptr[i] = inptr[i] * + (ogain + (MYFLT) (i+1) * invfloatn * gainsubstr); + } + p->curr_gains[j]= ogain + + (MYFLT) (i) * invfloatn * gainsubstr; + } + else { + for (i=offset; in; + MYFLT tmp_gains[MAXCHNLS],sum = FL(0.0); + if (UNLIKELY(p->dim == 2 && fabs(*p->ele) > 0.0)) { + csound->Warning(csound, + "%s", Str("Warning: truncating elevation to 2-D plane\n")); + *p->ele = FL(0.0); + } + if (*p->spread spread=FL(0.0); + else if (*p->spread >FL(100.0)) + *p->spread=FL(100.0); + /* Current panning angles */ + p->ang_dir.azi = (MYFLT) *p->azi; + p->ang_dir.ele = (MYFLT) *p->ele; + p->ang_dir.length = FL(1.0); + angle_to_cart(p->ang_dir, &(p->cart_dir)); + calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, + p->updated_gains, n, p->cart_dir); + + /* Calculated gain factors of a spreaded virtual source */ + if (*p->spread > FL(0.0)) { + if (p->dim == 3) { + spreaddirnum=16; + /* four orthogonal dirs */ + new_spread_dir(&spreaddir[0], p->cart_dir, + p->spread_base, *p->azi, *p->spread); + new_spread_base(spreaddir[0], p->cart_dir,*p->spread, &p->spread_base); + cross_prod(p->spread_base, p->cart_dir, &spreadbase[1]); + cross_prod(spreadbase[1], p->cart_dir, &spreadbase[2]); + cross_prod(spreadbase[2], p->cart_dir, &spreadbase[3]); + /* four between them */ + vec_mean(p->spread_base, spreadbase[1], &spreadbase[4]); + vec_mean(spreadbase[1], spreadbase[2], &spreadbase[5]); + vec_mean(spreadbase[2], spreadbase[3], &spreadbase[6]); + vec_mean(spreadbase[3], p->spread_base, &spreadbase[7]); + + /* four at half spreadangle */ + vec_mean(p->cart_dir, p->spread_base, &spreadbase[8]); + vec_mean(p->cart_dir, spreadbase[1], &spreadbase[9]); + vec_mean(p->cart_dir, spreadbase[2], &spreadbase[10]); + vec_mean(p->cart_dir, spreadbase[3], &spreadbase[11]); + + /* four at quarter spreadangle */ + vec_mean(p->cart_dir, spreadbase[8], &spreadbase[12]); + vec_mean(p->cart_dir, spreadbase[9], &spreadbase[13]); + vec_mean(p->cart_dir, spreadbase[10], &spreadbase[14]); + vec_mean(p->cart_dir, spreadbase[11], &spreadbase[15]); + + for (i=1;icart_dir, + spreadbase[i],*p->azi,*p->spread); + calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, + tmp_gains, n, spreaddir[i]); + for (j=0;jupdated_gains[j] += tmp_gains[j]; + } + } + } + else if (p->dim == 2) { + spreaddirnum = 6; + atmp.ele = FL(0.0); + atmp.azi = *p->azi - *p->spread; + angle_to_cart(atmp, &spreaddir[0]); + atmp.azi = *p->azi - *p->spread/2; + angle_to_cart(atmp, &spreaddir[1]); + atmp.azi = *p->azi - *p->spread/4; + angle_to_cart(atmp, &spreaddir[2]); + atmp.azi = *p->azi + *p->spread/4; + angle_to_cart(atmp, &spreaddir[3]); + atmp.azi = *p->azi + *p->spread/2; + angle_to_cart(atmp, &spreaddir[4]); + atmp.azi = *p->azi + *p->spread; + angle_to_cart(atmp, &spreaddir[5]); + + for (i=0;ils_set_am, p->dim, p->ls_sets, + tmp_gains, n, spreaddir[i]); + for (j=0;jupdated_gains[j] += tmp_gains[j]; + } + } + } + } + if (*p->spread > FL(70.0)) + for (i=0;iupdated_gains[i] +=(*p->spread - FL(70.0))/FL(30.0) * + (*p->spread - FL(70.0))/FL(30.0)*FL(20.0); + } + + /* normalization */ + for (i=0;iupdated_gains[i]*p->updated_gains[i]); + } + + sum = SQRT(sum); + for (i=0;iupdated_gains[i] /= sum; + } + return OK; +} + +int32_t vbap_zak_init(CSOUND *csound, VBAP_ZAK *p) +{ /* Initializations before run time */ + int32_t i, j, indx; + MYFLT *ls_table, *ptr; /* , *gains; */ + LS_SET *ls_set_ptr; + int32_t n = p->n = (int32_t)MYFLT2LONG(*p->numb); /* Set size */ + char name[24]; + /* Check to see this index is within the limits of za space. */ + MYFLT* zastart; + int zalast = csound->GetZaBounds(csound, &zastart); + indx = (int32) *p->ndx; + if (UNLIKELY(indx > zalast)) { + return csound->PerfError(csound, &(p->h), + "%s", Str("outz index > isizea. No output")); + } + else if (UNLIKELY(indx < 0)) { + return csound->PerfError(csound, &(p->h), + "%s", Str("outz index < 0. No output.")); + } + if ((int32_t)*p->layout==0) strcpy(name, "vbap_ls_table"); + else snprintf(name, 24, "vbap_ls_table_%d", (int32_t)*p->layout==0); + /* Now read from the array in za space and write to the output. */ + p->out_array = zastart + (indx * CS_KSMPS);/* outputs */ + csound->AuxAlloc(csound, p->n*sizeof(MYFLT)*4, &p->auxch); + p->curr_gains = (MYFLT*)p->auxch.auxp; + p->beg_gains = p->curr_gains + p->n; + p->end_gains = p->beg_gains + p->n; + p->updated_gains = p->end_gains + p->n; + ls_table = (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, name)); + p->dim = (int32_t) ls_table[0]; /* reading in loudspeaker info */ + p->ls_am = (int32_t) ls_table[1]; + p->ls_set_am = (int32_t) ls_table[2]; + ptr = &(ls_table[3]); + csound->AuxAlloc(csound, p->ls_set_am * sizeof (LS_SET), &p->aux); + if (UNLIKELY(p->aux.auxp == NULL)) { + return csound->InitError(csound, "%s", Str("could not allocate memory")); + } + p->ls_sets = (LS_SET*) p->aux.auxp; + ls_set_ptr = p->ls_sets; + for (i=0 ; i < p->ls_set_am ; i++) { + ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ + for (j=0 ; j < p->dim ; j++) { + ls_set_ptr[i].ls_nos[j] = (int32_t) *(ptr++); + } + for (j=0 ; j < 9; j++) + ls_set_ptr[i].ls_mx[j] = FL(0.0); /* initial setting */ + for (j=0 ; j < (p->dim) * (p->dim); j++) { + ls_set_ptr[i].ls_mx[j] = (MYFLT) *(ptr++); + } + } + + /* other initialization */ + if (UNLIKELY(p->dim == 2 && fabs(*p->ele) > 0.0)) { + csound->Warning(csound, + "%s", Str("Warning: truncating elevation to 2-D plane\n")); + *p->ele = FL(0.0); + } + p->ang_dir.azi = (MYFLT) *p->azi; + p->ang_dir.ele = (MYFLT) *p->ele; + p->ang_dir.length = FL(1.0); + angle_to_cart(p->ang_dir, &(p->cart_dir)); + p->spread_base.x = p->cart_dir.y; + p->spread_base.y = p->cart_dir.z; + p->spread_base.z = -p->cart_dir.x; + vbap_zak_control(csound,p); + for (i=0;ibeg_gains[i] = p->updated_gains[i]; + p->end_gains[i] = p->updated_gains[i]; + } + return OK; } +int32_t vbap_zak_moving(CSOUND *csound, VBAP_ZAK_MOVING *p) +{ /* during note performance: */ + MYFLT *outptr, *inptr; + MYFLT ogain, ngain, gainsubstr; + MYFLT invfloatn; + int32_t j; + uint32_t offset = p->h.insdshead->ksmps_offset; + uint32_t early = p->h.insdshead->ksmps_no_end; + uint32_t i, nsmps = CS_KSMPS; + + vbap_zak_moving_control(csound,p); + for (j=0;j< p->n; j++) { + p->beg_gains[j] = p->end_gains[j]; + p->end_gains[j] = p->updated_gains[j]; + } + + /* write audio to resulting audio streams weighted + with gain factors */ + invfloatn = FL(1.0)/(nsmps-offset); + outptr = p->out_array; + if (UNLIKELY(offset)) memset(outptr, '\0', offset*sizeof(MYFLT)); + if (UNLIKELY(early)) { + nsmps -= early; + memset(&outptr[nsmps], '\0', early*sizeof(MYFLT)); + } + for (j=0; jn ;j++) { + inptr = p->audio; + ogain = p->beg_gains[j]; + ngain = p->end_gains[j]; + gainsubstr = ngain - ogain; + if (ngain != FL(0.0) || ogain != FL(0.0)) + if (ngain != ogain) { + for (i = offset; i < nsmps; i++) { + outptr[i] = inptr[i] * + (ogain + (MYFLT) (i+1) * invfloatn * gainsubstr); + } + p->curr_gains[j] = ogain + + (MYFLT) (i) * invfloatn * gainsubstr; + } + else + for (i=offset; in; + CART_VEC tmp1, tmp2, tmp3; + MYFLT coeff, angle; + MYFLT tmp_gains[MAXCHNLS],sum = FL(0.0); /* Array long enough */ + if (UNLIKELY(p->dim == 2 && fabs(p->ang_dir.ele) > 0.0)) { + csound->Warning(csound, + "%s", Str("Warning: truncating elevation to 2-D plane\n")); + p->ang_dir.ele = FL(0.0); + } + + if (*p->spread spread = FL(0.0); + else if (*p->spread >FL(100.0)) + *p->spread = FL(100.0); + if (p->point_change_counter++ >= p->point_change_interval) { + p->point_change_counter = 0; + p->curr_fld = p->next_fld; + if (++p->next_fld >= (int32_t) fabs(*p->field_am)) { + if (*p->field_am >= FL(0.0)) /* point-to-point */ + p->next_fld = 0; + else + p->next_fld = 1; + } + if (p->dim == 3) { /* jumping over second field */ + p->curr_fld = p->next_fld; + if (++p->next_fld >= ((int32_t) fabs(*p->field_am))) { + if (*p->field_am >= FL(0.0)) /* point-to-point */ + p->next_fld = 0; + else + p->next_fld = 1; + } + } + if (UNLIKELY((p->fld[abs(p->next_fld)]==NULL))) + return csound->PerfError(csound, &(p->h), + "%s", Str("Missing fields in vbapzmove\n")); + if (*p->field_am >= FL(0.0) && p->dim == 2) /* point-to-point */ + if (UNLIKELY(fabs(fabs(*p->fld[p->next_fld] - *p->fld[p->curr_fld]) + - 180.0) < 1.0)) + csound->Warning(csound, + "%s", Str("Warning: Ambiguous transition 180 degrees.\n")); + } + if (*p->field_am >= FL(0.0)) { /* point-to-point */ + if (p->dim == 3) { /* 3-D */ + p->prev_ang_dir.azi = *p->fld[p->curr_fld-1]; + p->next_ang_dir.azi = *p->fld[p->next_fld]; + p->prev_ang_dir.ele = *p->fld[p->curr_fld]; + p->next_ang_dir.ele = *p->fld[p->next_fld+1]; + coeff = ((MYFLT) p->point_change_counter) / + ((MYFLT) p->point_change_interval); + angle_to_cart( p->prev_ang_dir,&tmp1); + angle_to_cart( p->next_ang_dir,&tmp2); + tmp3.x = (FL(1.0)-coeff) * tmp1.x + coeff * tmp2.x; + tmp3.y = (FL(1.0)-coeff) * tmp1.y + coeff * tmp2.y; + tmp3.z = (FL(1.0)-coeff) * tmp1.z + coeff * tmp2.z; + coeff = (MYFLT)sqrt((double)(tmp3.x * tmp3.x + + tmp3.y * tmp3.y + + tmp3.z * tmp3.z)); + tmp3.x /= coeff; tmp3.y /= coeff; tmp3.z /= coeff; + cart_to_angle(tmp3,&(p->ang_dir)); + } + else if (p->dim == 2) { /* 2-D */ + p->prev_ang_dir.azi = *p->fld[p->curr_fld]; + p->next_ang_dir.azi = *p->fld[p->next_fld ]; + p->prev_ang_dir.ele = p->next_ang_dir.ele = FL(0.0); + scale_angles(&(p->prev_ang_dir)); + scale_angles(&(p->next_ang_dir)); + angle = (p->prev_ang_dir.azi - p->next_ang_dir.azi); + while (angle > FL(180.0)) + angle -= FL(360.0); + while (angle < -FL(180.0)) + angle += FL(360.0); + coeff = ((MYFLT) p->point_change_counter) / + ((MYFLT) p->point_change_interval); + angle *= (coeff); + p->ang_dir.azi = p->prev_ang_dir.azi - angle; + p->ang_dir.ele = FL(0.0); + } + else { + return csound->PerfError(csound, &(p->h), + "%s", Str("Missing fields in vbapzmove\n")); + } + } + else { /* angular velocities */ + if (p->dim == 2) { + p->ang_dir.azi = p->ang_dir.azi + + (*p->fld[p->next_fld] * CS_ONEDKR); + scale_angles(&(p->ang_dir)); + } + else { /* 3D angular */ + p->ang_dir.azi = p->ang_dir.azi + + (*p->fld[p->next_fld] * CS_ONEDKR); + p->ang_dir.ele = p->ang_dir.ele + + p->ele_vel * (*p->fld[p->next_fld+1] * CS_ONEDKR); + if (p->ang_dir.ele > FL(90.0)) { + p->ang_dir.ele = FL(90.0); + p->ele_vel = -p->ele_vel; + } + if (p->ang_dir.ele < FL(0.0)) { + p->ang_dir.ele = FL(0.0); + p->ele_vel = -p->ele_vel; + } + scale_angles(&(p->ang_dir)); + } + } + angle_to_cart(p->ang_dir, &(p->cart_dir)); + calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, + p->updated_gains, n, p->cart_dir); + if (*p->spread > FL(0.0)) { + if (p->dim == 3) { + spreaddirnum=16; + /* four orthogonal dirs */ + new_spread_dir(&spreaddir[0], p->cart_dir, + p->spread_base, p->ang_dir.azi, *p->spread); + + new_spread_base(spreaddir[0], p->cart_dir,*p->spread, &p->spread_base); + cross_prod(p->spread_base, p->cart_dir, &spreadbase[1]); + cross_prod(spreadbase[1], p->cart_dir, &spreadbase[2]); + cross_prod(spreadbase[2], p->cart_dir, &spreadbase[3]); + /* four between them */ + vec_mean(p->spread_base, spreadbase[1], &spreadbase[4]); + vec_mean(spreadbase[1], spreadbase[2], &spreadbase[5]); + vec_mean(spreadbase[2], spreadbase[3], &spreadbase[6]); + vec_mean(spreadbase[3], p->spread_base, &spreadbase[7]); + + /* four at half spreadangle */ + vec_mean(p->cart_dir, p->spread_base, &spreadbase[8]); + vec_mean(p->cart_dir, spreadbase[1], &spreadbase[9]); + vec_mean(p->cart_dir, spreadbase[2], &spreadbase[10]); + vec_mean(p->cart_dir, spreadbase[3], &spreadbase[11]); + + /* four at quarter spreadangle */ + vec_mean(p->cart_dir, spreadbase[8], &spreadbase[12]); + vec_mean(p->cart_dir, spreadbase[9], &spreadbase[13]); + vec_mean(p->cart_dir, spreadbase[10], &spreadbase[14]); + vec_mean(p->cart_dir, spreadbase[11], &spreadbase[15]); + + for (i=1;icart_dir, + spreadbase[i],p->ang_dir.azi,*p->spread); + calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, + tmp_gains, n, spreaddir[i]); + for (j=0;jupdated_gains[j] += tmp_gains[j]; + } + } + } + else if (p->dim == 2) { + spreaddirnum=6; + atmp.ele=FL(0.0); + atmp.azi=p->ang_dir.azi - *p->spread; + angle_to_cart(atmp, &spreaddir[0]); + atmp.azi=p->ang_dir.azi - *p->spread/2; + angle_to_cart(atmp, &spreaddir[1]); + atmp.azi=p->ang_dir.azi - *p->spread/4; + angle_to_cart(atmp, &spreaddir[2]); + atmp.azi=p->ang_dir.azi + *p->spread/4; + angle_to_cart(atmp, &spreaddir[3]); + atmp.azi=p->ang_dir.azi + *p->spread/2; + angle_to_cart(atmp, &spreaddir[4]); + atmp.azi=p->ang_dir.azi + *p->spread; + angle_to_cart(atmp, &spreaddir[5]); + + for (i=0;ils_set_am, p->dim, p->ls_sets, + tmp_gains, n, spreaddir[i]); + for (j=0;jupdated_gains[j] += tmp_gains[j]; + } + } + } + } + if (*p->spread > FL(70.0)) + for (i=0;iupdated_gains[i] += (*p->spread - FL(70.0))/FL(30.0) * + (*p->spread - FL(70.0))/FL(30.0)*FL(10.0); + } + /* normalization */ + for (i=0;iupdated_gains[i]*p->updated_gains[i]); + } + + sum = SQRT(sum); + for (i=0;iupdated_gains[i] /= sum; + } + return OK; +} + +int32_t vbap_zak_moving_init(CSOUND *csound, VBAP_ZAK_MOVING *p) +{ + int32_t i, j, indx; + MYFLT *ls_table, *ptr; + LS_SET *ls_set_ptr; + int32_t n = p->n; + p->n = (int32_t)MYFLT2LONG(*p->numb); /* Set size */ + /* Check to see this index is within the limits of za space. */ + MYFLT* zastart; + int zalast = csound->GetZaBounds(csound, &zastart); + indx = (int32) *p->ndx; + if (UNLIKELY(indx > zalast)) { + return csound->PerfError(csound, &(p->h), + "%s", Str("outz index > isizea. No output")); + } + else if (UNLIKELY(indx < 0)) { + return csound->PerfError(csound, &(p->h), + "%s", Str("outz index < 0. No output.")); + } + /* Now read from the array in za space and write to the output. */ + p->out_array = zastart + (indx * CS_KSMPS);/* outputs */ + csound->AuxAlloc(csound, p->n*sizeof(MYFLT)*4, &p->auxch); + p->curr_gains = (MYFLT*)p->auxch.auxp; + p->beg_gains = p->curr_gains + p->n; + p->end_gains = p->beg_gains + p->n; + p->updated_gains = p->end_gains + p->n; + /* reading in loudspeaker info */ + ls_table = (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, + "vbap_ls_table_0")); + p->dim = (int32_t) ls_table[0]; + p->ls_am = (int32_t) ls_table[1]; + p->ls_set_am = (int32_t) ls_table[2]; + ptr = &(ls_table[3]); + csound->AuxAlloc(csound, p->ls_set_am * sizeof (LS_SET), &p->aux); + if (UNLIKELY(p->aux.auxp == NULL)) { + return csound->InitError(csound, "%s", Str("could not allocate memory")); + } + p->ls_sets = (LS_SET*) p->aux.auxp; + ls_set_ptr = p->ls_sets; + for (i=0 ; i < p->ls_set_am ; i++) { + ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ + for (j=0 ; j < p->dim ; j++) { + ls_set_ptr[i].ls_nos[j] = (int32_t) *(ptr++); + } + memset(ls_set_ptr[i].ls_mx, '\0', 9*sizeof(MYFLT)); + /* for (j=0 ; j < 9; j++) */ + /* ls_set_ptr[i].ls_mx[j] = FL(0.0); /\* initial setting *\/ */ + for (j=0 ; j < (p->dim) * (p->dim); j++) { + ls_set_ptr[i].ls_mx[j] = (MYFLT) *(ptr++); + } + } + + /* other initialization */ + p->ele_vel = FL(1.0); /* functions specific to movement */ + if (UNLIKELY(fabs(*p->field_am) < (2+ (p->dim - 2)*2))) { + return csound->InitError(csound, + Str("Have to have at least %d directions in vbapzmove"), + 2 + (p->dim - 2) * 2); + } + if (p->dim == 2) + p->point_change_interval = (int32_t) (CS_EKR * *p->dur + / (fabs(*p->field_am) - 1.0)); + else if (LIKELY(p->dim == 3)) + p->point_change_interval = (int32_t) (CS_EKR * *p->dur + / (fabs(*p->field_am) * 0.5 - 1.0)); + else + return csound->InitError(csound, "%s", Str("Wrong dimension")); + p->point_change_counter = 0; + p->curr_fld = 0; + p->next_fld = 1; + p->ang_dir.azi = *p->fld[0]; + if (p->dim == 3) { + p->ang_dir.ele = *p->fld[1]; + } else { + p->ang_dir.ele = FL(0.0); + } + if (p->dim == 3) { + p->curr_fld = 1; + p->next_fld = 2; + } + angle_to_cart(p->ang_dir, &(p->cart_dir)); + p->spread_base.x = p->cart_dir.y; + p->spread_base.y = p->cart_dir.z; + p->spread_base.z = -p->cart_dir.x; + vbap_zak_moving_control(csound,p); + for (i=0;ibeg_gains[i] = p->updated_gains[i]; + p->end_gains[i] = p->updated_gains[i]; + } + return OK; +} + + + #define S(x) sizeof(x) /* static */ static OENTRY vbap_localops[] = { { "vbap.a", S(VBAP), - TR, 3, "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm" + TR, "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm" "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", "akOOo", (SUBR) vbap_init, (SUBR) vbap }, - { "vbap.A", S(VBAPA), TR, 3, "a[]", "akOOo", + { "vbap.A", S(VBAPA), TR, "a[]", "akOOo", (SUBR) vbap_init_a, (SUBR) vbap_a }, { "vbap4", S(VBAP), - TR|_QQ, 3, "aaaammmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm" + TR|_QQ, "aaaammmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm" "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", "akOOo", (SUBR) vbap_init, (SUBR) vbap }, { "vbap8", S(VBAP), - TR|_QQ, 3, "aaaaaaaammmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm" + TR|_QQ, "aaaaaaaammmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm" "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", "akOOo", (SUBR) vbap_init, (SUBR) vbap }, { "vbap16", S(VBAP), - TR|_QQ, 3, "aaaaaaaaaaaaaaaammmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm" + TR|_QQ, "aaaaaaaaaaaaaaaammmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm" "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", "akOOo", (SUBR) vbap_init, (SUBR) vbap }, - { "vbapg.a", S(VBAP1), TR, 3, + { "vbapg.a", S(VBAP1), TR, "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", "kOOo", (SUBR) vbap1_init, (SUBR) vbap1 }, - { "vbapg.A", S(VBAPA1), TR, 3, + { "vbapg.A", S(VBAPA1), TR, "k[]", "kOOo", (SUBR) vbap1_init_a, (SUBR) vbap1a }, - { "vbapz", S(VBAP_ZAK), ZW|TR, 3, "", "iiakOOo", + { "vbapz", S(VBAP_ZAK), ZW|TR, "", "iiakOOo", (SUBR) vbap_zak_init, (SUBR) vbap_zak }, - { "vbaplsinit",S(VBAP_LS_INIT),TR,1, "", + { "vbaplsinit",S(VBAP_LS_INIT),TR, "", "ii" "oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" "oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo", (SUBR) vbap_ls_init, (SUBR) NULL, (SUBR) NULL, (SUBR) NULL }, - { "vbaplsinit",S(VBAP_LS_INIT),TR,1, "", "iii[]", + { "vbaplsinit",S(VBAP_LS_INIT),TR, "", "iii[]", (SUBR) vbap_ls_inita, (SUBR) NULL, (SUBR) NULL, (SUBR) NULL }, { "vbapmove.a", S(VBAP_MOVING), - TR, 3, "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm" + TR, "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm" "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", "aiiim", (SUBR) vbap_moving_init, (SUBR) vbap_moving }, - { "vbapgmove.a", S(VBAP1_MOVING), TR, 3, + { "vbapgmove.a", S(VBAP1_MOVING), TR, "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", "iiim", (SUBR) vbap1_moving_init, (SUBR) vbap1_moving }, { "vbapmove.A", S(VBAPA_MOVING), - TR, 3, "a[]", "aiiim", + TR, "a[]", "aiiim", (SUBR) vbap_moving_init_a, (SUBR) vbap_moving_a }, - { "vbapgmove.A", S(VBAPA1_MOVING), TR, 3, + { "vbapgmove.A", S(VBAPA1_MOVING), TR, "k[]", "iiim", (SUBR) vbap1_moving_init_a, (SUBR) vbap1_moving_a }, - { "vbapzmove", S(VBAP_ZAK_MOVING), ZW|TR, 3, "", "iiaiiim", + { "vbapzmove", S(VBAP_ZAK_MOVING), ZW|TR, "", "iiaiiim", (SUBR) vbap_zak_moving_init, (SUBR) vbap_zak_moving }, - { "vbap4move", S(VBAP_MOVING), TR|_QQ, 3, "aaaa", - "aiiim", + { "vbap4move", S(VBAP_MOVING), TR|_QQ, "aaaa", + "aiiim", (SUBR) vbap_moving_init, (SUBR) vbap_moving }, { "vbap8move", S(VBAP_MOVING), - TR|_QQ, 3, "aaaaaaaa", + TR|_QQ, "aaaaaaaa", "aiiim", (SUBR) vbap_moving_init, (SUBR) vbap_moving } diff --git a/Opcodes/vbap1.c b/Opcodes/vbap1.c index 3d25c75019c..21db8d8a4b8 100644 --- a/Opcodes/vbap1.c +++ b/Opcodes/vbap1.c @@ -28,649 +28,4 @@ functions specific gains for loudspeaker VBAP Ville Pulkki heavily modified by John ffitch 2012 */ - - -#ifdef BUILD_PLUGINS -#include "csdl.h" -#else -#include "csoundCore.h" -#endif -#include "vbap.h" -#include -#include -#include - -static int32_t vbap1_moving_control(CSOUND *, VBAP1_MOVE_DATA *, OPDS *, MYFLT, - MYFLT, MYFLT, MYFLT**); -static int32_t vbap1_control(CSOUND *, VBAP1_DATA *, MYFLT*, MYFLT*, MYFLT*); - -int32_t vbap1(CSOUND *csound, VBAP1 *p) /* during note performance: */ -{ - int32_t j; - int32_t cnt = p->q.number; - vbap1_control(csound,&p->q, p->azi, p->ele, p->spread); - - /* write gains */ - for (j=0; jout_array[j] = p->q.gains[j]; - } - return OK; -} - -static int32_t vbap1_control(CSOUND *csound, VBAP1_DATA *p, - MYFLT* azi, MYFLT* ele, MYFLT* spread) -{ - CART_VEC spreaddir[16]; - CART_VEC spreadbase[16]; - ANG_VEC atmp; - int32 i,j, spreaddirnum; - int32_t cnt = p->number; - MYFLT *tmp_gains=malloc(sizeof(MYFLT)*cnt),sum=FL(0.0); - if (UNLIKELY(p->dim == 2 && fabs(*ele) > 0.0)) { - csound->Warning(csound, - "%s", Str("Warning: truncating elevation to 2-D plane\n")); - *ele = FL(0.0); - } - - if (*spread FL(100.0)) - *spread = FL(100.0); - /* Current panning angles */ - p->ang_dir.azi = *azi; - p->ang_dir.ele = *ele; - p->ang_dir.length = FL(1.0); - angle_to_cart(p->ang_dir, &(p->cart_dir)); - calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, - p->gains, cnt, p->cart_dir); - - /* Calculated gain factors of a spreaded virtual source*/ - if (*spread > FL(0.0)) { - if (p->dim == 3) { - spreaddirnum = 16; - /* four orthogonal dirs*/ - new_spread_dir(&spreaddir[0], p->cart_dir, - p->spread_base, *azi, *spread); - new_spread_base(spreaddir[0], p->cart_dir, - *spread, &p->spread_base); - cross_prod(p->spread_base, p->cart_dir, &spreadbase[1]); - cross_prod(spreadbase[1], p->cart_dir, &spreadbase[2]); - cross_prod(spreadbase[2], p->cart_dir, &spreadbase[3]); - /* four between them*/ - vec_mean(p->spread_base, spreadbase[1], &spreadbase[4]); - vec_mean(spreadbase[1], spreadbase[2], &spreadbase[5]); - vec_mean(spreadbase[2], spreadbase[3], &spreadbase[6]); - vec_mean(spreadbase[3], p->spread_base, &spreadbase[7]); - - /* four at half spreadangle*/ - vec_mean(p->cart_dir, p->spread_base, &spreadbase[8]); - vec_mean(p->cart_dir, spreadbase[1], &spreadbase[9]); - vec_mean(p->cart_dir, spreadbase[2], &spreadbase[10]); - vec_mean(p->cart_dir, spreadbase[3], &spreadbase[11]); - - /* four at quarter spreadangle*/ - vec_mean(p->cart_dir, spreadbase[8], &spreadbase[12]); - vec_mean(p->cart_dir, spreadbase[9], &spreadbase[13]); - vec_mean(p->cart_dir, spreadbase[10], &spreadbase[14]); - vec_mean(p->cart_dir, spreadbase[11], &spreadbase[15]); - - for (i=1;icart_dir, - spreadbase[i],*azi,*spread); - calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, - tmp_gains, cnt, spreaddir[i]); - for (j=0;jgains[j] += tmp_gains[j]; - } - } - } - else if (p->dim == 2) { - spreaddirnum = 6; - atmp.ele = FL(0.0); - atmp.azi = *azi - *spread; - angle_to_cart(atmp, &spreaddir[0]); - atmp.azi = *azi - *spread/2; - angle_to_cart(atmp, &spreaddir[1]); - atmp.azi = *azi - *spread/4; - angle_to_cart(atmp, &spreaddir[2]); - atmp.azi = *azi + *spread/4; - angle_to_cart(atmp, &spreaddir[3]); - atmp.azi = *azi + *spread/2; - angle_to_cart(atmp, &spreaddir[4]); - atmp.azi = *azi + *spread; - angle_to_cart(atmp, &spreaddir[5]); - - for (i=0;ils_set_am, p->dim, p->ls_sets, - tmp_gains, cnt, spreaddir[i]); - for (j=0;jgains[j] += tmp_gains[j]; - } - } - } - } - if (*spread > FL(70.0)) - for (i=0;igains[i] +=(*spread - FL(70.0))/FL(30.0) * - (*spread - FL(70.0))/FL(30.0)*FL(20.0); - } - - /*normalization*/ - for (i=0;igains[i]*p->gains[i]); - } - - sum=SQRT(sum); - for (i=0;igains[i] /= sum; - } - free(tmp_gains); - return OK; -} - -int32_t vbap1_init(CSOUND *csound, VBAP1 *p) -{ /* Initializations before run time*/ - int32_t i, j; - MYFLT *ls_table, *ptr; - LS_SET *ls_set_ptr; - char name[24]; - snprintf(name, 24, "vbap_ls_table_%d", (int32_t)*p->layout); - ls_table = (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, name)); - if (ls_table==NULL) - return csound->InitError(csound, - Str("could not find layout table no.%d"), - (int32_t)*p->layout ); - p->q.number = p->OUTOCOUNT; - p->q.dim = (int32_t)ls_table[0]; /* reading in loudspeaker info */ - p->q.ls_am = (int32_t)ls_table[1]; - p->q.ls_set_am = (int32_t)ls_table[2]; - ptr = &(ls_table[3]); - if (!p->q.ls_set_am) - return csound->InitError(csound, "%s", Str("vbap system NOT configured.\nMissing" - " vbaplsinit opcode in orchestra?")); - csound->AuxAlloc(csound, p->q.ls_set_am * sizeof (LS_SET), &p->q.aux); - if (UNLIKELY(p->q.aux.auxp == NULL)) { - return csound->InitError(csound, "%s", Str("could not allocate memory")); - } - p->q.ls_sets = (LS_SET*) p->q.aux.auxp; - ls_set_ptr = p->q.ls_sets; - for (i=0; i < p->q.ls_set_am; i++) { - ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ - for (j=0 ; j < p->q.dim ; j++) { - ls_set_ptr[i].ls_nos[j] = (int32_t)*(ptr++); - } - memset(ls_set_ptr[i].ls_mx, '\0', 9*sizeof(MYFLT)); // initial setting - /* for (j=0 ; j < 9; j++) */ - /* ls_set_ptr[i].ls_mx[j] = FL(0.0); /\*initial setting*\/ */ - for (j=0 ; j < (p->q.dim) * (p->q.dim); j++) { - ls_set_ptr[i].ls_mx[j] = (MYFLT)*(ptr++); - } - } - - /* other initialization */ - if (UNLIKELY(p->q.dim == 2 && fabs(*p->ele) > 0.0)) { - csound->Warning(csound, - "%s", Str("Warning: truncating elevation to 2-D plane\n")); - *p->ele = FL(0.0); - } - p->q.ang_dir.azi = (MYFLT)*p->azi; - p->q.ang_dir.ele = (MYFLT)*p->ele; - p->q.ang_dir.length = FL(1.0); - angle_to_cart(p->q.ang_dir, &(p->q.cart_dir)); - p->q.spread_base.x = p->q.cart_dir.y; - p->q.spread_base.y = p->q.cart_dir.z; - p->q.spread_base.z = -p->q.cart_dir.x; - vbap1_control(csound,&p->q, p->azi, p->ele, p->spread); - return OK; -} - -int32_t vbap1a(CSOUND *csound, VBAPA1 *p) /* during note performance: */ -{ - int32_t j; - int32_t cnt = p->q.number; - vbap1_control(csound,&p->q, p->azi, p->ele, p->spread); - - /* write gains */ - for (j=0; jtabout->data[j] = p->q.gains[j]; - } - return OK; -} - -int32_t vbap1_init_a(CSOUND *csound, VBAPA1 *p) -{ /* Initializations before run time*/ - int32_t i, j; - MYFLT *ls_table, *ptr; - LS_SET *ls_set_ptr; - char name[24]; - snprintf(name, 24, "vbap_ls_table_%d", (int32_t)*p->layout); - ls_table = (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, name)); - if (ls_table==NULL) - return csound->InitError(csound, - Str("could not find layout table no.%d"), - (int32_t)*p->layout ); - p->q.number = p->tabout->sizes[0]; - p->q.dim = (int32_t)ls_table[0]; /* reading in loudspeaker info */ - p->q.ls_am = (int32_t)ls_table[1]; - p->q.ls_set_am = (int32_t)ls_table[2]; - ptr = &(ls_table[3]); - if (!p->q.ls_set_am) - return csound->InitError(csound, "%s", Str("vbap system NOT configured.\nMissing" - " vbaplsinit opcode in orchestra?")); - csound->AuxAlloc(csound, p->q.ls_set_am * sizeof (LS_SET), &p->q.aux); - if (UNLIKELY(p->q.aux.auxp == NULL)) { - return csound->InitError(csound, "%s", Str("could not allocate memory")); - } - p->q.ls_sets = (LS_SET*) p->q.aux.auxp; - ls_set_ptr = p->q.ls_sets; - for (i=0; i < p->q.ls_set_am; i++) { - ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ - for (j=0 ; j < p->q.dim ; j++) { - ls_set_ptr[i].ls_nos[j] = (int32_t)*(ptr++); - } - memset(ls_set_ptr[i].ls_mx, '\0', 9*sizeof(MYFLT)); /*initial setting*/ - for (j=0 ; j < (p->q.dim) * (p->q.dim); j++) { - ls_set_ptr[i].ls_mx[j] = (MYFLT)*(ptr++); - } - } - - /* other initialization */ - if (UNLIKELY(p->q.dim == 2 && fabs(*p->ele) > 0.0)) { - csound->Warning(csound, - "%s", Str("Warning: truncating elevation to 2-D plane\n")); - *p->ele = FL(0.0); - } - p->q.ang_dir.azi = (MYFLT)*p->azi; - p->q.ang_dir.ele = (MYFLT)*p->ele; - p->q.ang_dir.length = FL(1.0); - angle_to_cart(p->q.ang_dir, &(p->q.cart_dir)); - p->q.spread_base.x = p->q.cart_dir.y; - p->q.spread_base.y = p->q.cart_dir.z; - p->q.spread_base.z = -p->q.cart_dir.x; - vbap1_control(csound,&p->q, p->azi, p->ele, p->spread); - return OK; -} - -int32_t vbap1_moving(CSOUND *csound, VBAP1_MOVING *p) -{ /* during note performance: */ - int32_t j; - int32_t cnt = p->q.number; - - vbap1_moving_control(csound,&p->q, &(p->h), CS_ONEDKR, - *p->spread, *p->field_am, p->fld); - - /* write audio to resulting audio streams weighted - with gain factors*/ - for (j=0; jout_array[j] = p->q.gains[j]; - } - return OK; -} - -int32_t vbap1_moving_a(CSOUND *csound, VBAPA1_MOVING *p) -{ /* during note performance: */ - // int32_t j; - int32_t cnt = p->q.number; - - vbap1_moving_control(csound,&p->q, &(p->h), CS_ONEDKR, - *p->spread, *p->field_am, p->fld); - - /* write audio to resulting audio streams weighted - with gain factors*/ - memcpy(p->tabout->data, p->q.gains, cnt*sizeof(MYFLT)); - /* for (j=0; jtabout->data[j] = p->q.gains[j]; */ - /* } */ - return OK; -} - -static int32_t vbap1_moving_control(CSOUND *csound, VBAP1_MOVE_DATA *p, - OPDS *h, MYFLT ONEDKR, - MYFLT spread, MYFLT field_am, MYFLT **fld) -{ - CART_VEC spreaddir[16]; - CART_VEC spreadbase[16]; - ANG_VEC atmp; - int32 i,j, spreaddirnum; - CART_VEC tmp1, tmp2, tmp3; - MYFLT coeff, angle; - int32_t cnt = p->number; - MYFLT *tmp_gains=malloc(sizeof(MYFLT)*cnt),sum=FL(0.0); -#ifdef JPFF - printf("cnt=%d dim=%d\n", cnt, p->dim); -#endif - if (UNLIKELY(p->dim == 2 && fabs(p->ang_dir.ele) > 0.0)) { - csound->Warning(csound, - "%s", Str("Warning: truncating elevation to 2-D plane\n")); - p->ang_dir.ele = FL(0.0); - } - if (spread FL(100.0)) - spread = FL(100.0); - if (p->point_change_counter++ >= p->point_change_interval) { - p->point_change_counter = 0; - p->curr_fld = p->next_fld; - if (++p->next_fld >= (int32_t) fabs(field_am)) { - if (field_am >= FL(0.0)) /* point-to-point */ - p->next_fld = 0; - else - p->next_fld = 1; - } - if (p->dim == 3) { /*jumping over second field */ - p->curr_fld = p->next_fld; - if (++p->next_fld >= ((int32_t) fabs(field_am))) { - if (field_am >= FL(0.0)) /* point-to-point */ - p->next_fld = 0; - else - p->next_fld = 1; - } - } - if (UNLIKELY((fld[abs(p->next_fld)]==NULL))) { - free(tmp_gains); - return csound->PerfError(csound, h, - "%s", Str("Missing fields in vbapmove\n")); - } - if (field_am >= FL(0.0) && p->dim == 2) /* point-to-point */ - if (UNLIKELY(fabs(fabs(*fld[p->next_fld] - - *fld[p->curr_fld]) - 180.0) < 1.0)) - csound->Warning(csound, - "%s", Str("Warning: Ambiguous transition 180 degrees.\n")); - } - if (field_am >= FL(0.0)) { /* point-to-point */ - if (p->dim == 3) { /* 3-D*/ - p->prev_ang_dir.azi = *fld[p->curr_fld-1]; - p->next_ang_dir.azi = *fld[p->next_fld]; - p->prev_ang_dir.ele = *fld[p->curr_fld]; - p->next_ang_dir.ele = *fld[p->next_fld+1]; - coeff = ((MYFLT) p->point_change_counter) / - ((MYFLT) p->point_change_interval); - angle_to_cart( p->prev_ang_dir,&tmp1); - angle_to_cart( p->next_ang_dir,&tmp2); - tmp3.x = (FL(1.0)-coeff) * tmp1.x + coeff * tmp2.x; - tmp3.y = (FL(1.0)-coeff) * tmp1.y + coeff * tmp2.y; - tmp3.z = (FL(1.0)-coeff) * tmp1.z + coeff * tmp2.z; - coeff = (MYFLT)sqrt((double)(tmp3.x * tmp3.x + - tmp3.y * tmp3.y + - tmp3.z * tmp3.z)); - tmp3.x /= coeff; tmp3.y /= coeff; tmp3.z /= coeff; - cart_to_angle(tmp3,&(p->ang_dir)); - } - else if (p->dim == 2) { /* 2-D */ - p->prev_ang_dir.azi = *fld[p->curr_fld]; - p->next_ang_dir.azi = *fld[p->next_fld ]; - p->prev_ang_dir.ele = p->next_ang_dir.ele = FL(0.0); - scale_angles(&(p->prev_ang_dir)); - scale_angles(&(p->next_ang_dir)); - angle = (p->prev_ang_dir.azi - p->next_ang_dir.azi); - while (angle > FL(180.0)) - angle -= FL(360.0); - while (angle < -FL(180.0)) - angle += FL(360.0); - coeff = ((MYFLT) p->point_change_counter) / - ((MYFLT) p->point_change_interval); - angle *= (coeff); - p->ang_dir.azi = p->prev_ang_dir.azi - angle; - p->ang_dir.ele = FL(0.0); - } - else { - free(tmp_gains); - return csound->PerfError(csound, h, - "%s", Str("Missing fields in vbapmove\n")); - } - } - else { /* angular velocities */ - if (p->dim == 2) { - p->ang_dir.azi = p->ang_dir.azi + - (*fld[p->next_fld] * ONEDKR); - scale_angles(&(p->ang_dir)); - } - else { /* 3D angular*/ - p->ang_dir.azi = p->ang_dir.azi + - (*fld[p->next_fld] * ONEDKR); - p->ang_dir.ele = p->ang_dir.ele + - p->ele_vel * (*fld[p->next_fld+1] * ONEDKR); - if (p->ang_dir.ele > FL(90.0)) { - p->ang_dir.ele = FL(90.0); - p->ele_vel = -p->ele_vel; - } - if (p->ang_dir.ele < FL(0.0)) { - p->ang_dir.ele = FL(0.0); - p->ele_vel = -p->ele_vel; - } - scale_angles(&(p->ang_dir)); - } - } - angle_to_cart(p->ang_dir, &(p->cart_dir)); - calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, - p->gains, cnt, p->cart_dir); - if (spread > FL(0.0)) { - if (p->dim == 3) { - spreaddirnum=16; - /* four orthogonal dirs*/ - new_spread_dir(&spreaddir[0], p->cart_dir, - p->spread_base, p->ang_dir.azi, spread); - - new_spread_base(spreaddir[0], p->cart_dir, spread, &p->spread_base); - cross_prod(p->spread_base, p->cart_dir, &spreadbase[1]); - cross_prod(spreadbase[1], p->cart_dir, &spreadbase[2]); - cross_prod(spreadbase[2], p->cart_dir, &spreadbase[3]); - /* four between them*/ - vec_mean(p->spread_base, spreadbase[1], &spreadbase[4]); - vec_mean(spreadbase[1], spreadbase[2], &spreadbase[5]); - vec_mean(spreadbase[2], spreadbase[3], &spreadbase[6]); - vec_mean(spreadbase[3], p->spread_base, &spreadbase[7]); - - /* four at half spreadangle*/ - vec_mean(p->cart_dir, p->spread_base, &spreadbase[8]); - vec_mean(p->cart_dir, spreadbase[1], &spreadbase[9]); - vec_mean(p->cart_dir, spreadbase[2], &spreadbase[10]); - vec_mean(p->cart_dir, spreadbase[3], &spreadbase[11]); - - /* four at quarter spreadangle*/ - vec_mean(p->cart_dir, spreadbase[8], &spreadbase[12]); - vec_mean(p->cart_dir, spreadbase[9], &spreadbase[13]); - vec_mean(p->cart_dir, spreadbase[10], &spreadbase[14]); - vec_mean(p->cart_dir, spreadbase[11], &spreadbase[15]); - - for (i=1;icart_dir, - spreadbase[i],p->ang_dir.azi,spread); - calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, - tmp_gains, cnt, spreaddir[i]); - for (j=0;jgains[j] += tmp_gains[j]; - } - } - } - else if (p->dim == 2) { - spreaddirnum=6; - atmp.ele = FL(0.0); - atmp.azi = p->ang_dir.azi - spread; - angle_to_cart(atmp, &spreaddir[0]); - atmp.azi = p->ang_dir.azi - spread/2; - angle_to_cart(atmp, &spreaddir[1]); - atmp.azi = p->ang_dir.azi - spread/4; - angle_to_cart(atmp, &spreaddir[2]); - atmp.azi = p->ang_dir.azi + spread/4; - angle_to_cart(atmp, &spreaddir[3]); - atmp.azi = p->ang_dir.azi + spread/2; - angle_to_cart(atmp, &spreaddir[4]); - atmp.azi = p->ang_dir.azi + spread; - angle_to_cart(atmp, &spreaddir[5]); - - for (i=0;ils_set_am, p->dim, p->ls_sets, - tmp_gains, cnt, spreaddir[i]); - for (j=0;jgains[j] += tmp_gains[j]; - } - } - } - } - if (spread > FL(70.0)) - for (i=0;igains[i] +=(spread - FL(70.0))/FL(30.0) * - (spread - FL(70.0))/FL(30.0)*FL(10.0); - } - /*normalization*/ - for (i=0;igains[i]*p->gains[i]); - } - - sum=SQRT(sum); - for (i=0;igains[i] /= sum; - } - free(tmp_gains); - return OK; -} - -int32_t vbap1_moving_init(CSOUND *csound, VBAP1_MOVING *p) -{ - int32_t i, j; - MYFLT *ls_table, *ptr; - LS_SET *ls_set_ptr; - - p->q.number = p->OUTCOUNT; - ls_table = - (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, "vbap_ls_table_0")); - /* reading in loudspeaker info */ - p->q.dim = (int32_t)ls_table[0]; - p->q.ls_am = (int32_t)ls_table[1]; - p->q.ls_set_am = (int32_t)ls_table[2]; - ptr = &(ls_table[3]); - if (!p->q.ls_set_am) - return csound->InitError(csound, "%s", Str("vbap system NOT configured.\n" - "Missing vbaplsinit opcode" - " in orchestra?")); - csound->AuxAlloc(csound, p->q.ls_set_am * sizeof(LS_SET), &p->q.aux); - if (UNLIKELY(p->q.aux.auxp == NULL)) { - return csound->InitError(csound, "%s", Str("could not allocate memory")); - } - p->q.ls_sets = (LS_SET*) p->q.aux.auxp; - ls_set_ptr = p->q.ls_sets; - for (i=0 ; i < p->q.ls_set_am ; i++) { - ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ - for (j=0 ; j < p->q.dim ; j++) { - ls_set_ptr[i].ls_nos[j] = (int32_t)*(ptr++); - } - for (j=0 ; j < 9; j++) - ls_set_ptr[i].ls_mx[j] = FL(0.0); /*initial setting*/ - for (j=0 ; j < (p->q.dim) * (p->q.dim); j++) { - ls_set_ptr[i].ls_mx[j] = (MYFLT)*(ptr++); - } - } - - /* other initialization */ - p->q.ele_vel = FL(1.0); /* functions specific to movement */ - if (UNLIKELY(fabs(*p->field_am) < (2+ (p->q.dim - 2)*2))) { - return csound->InitError(csound, - Str("Have to have at least %d directions in vbapmove"), - 2 + (p->q.dim - 2) * 2); - } - if (p->q.dim == 2) - p->q.point_change_interval = - (int32_t)(CS_EKR * *p->dur /(fabs(*p->field_am) - 1.0)); - else if (LIKELY(p->q.dim == 3)) - p->q.point_change_interval = - (int32_t)(CS_EKR * *p->dur /(fabs(*p->field_am)*0.5 - 1.0)); - else - return csound->InitError(csound, "%s", Str("Wrong dimension")); - p->q.point_change_counter = 0; - p->q.curr_fld = 0; - p->q.next_fld = 1; - p->q.ang_dir.azi = *p->fld[0]; - if (p->q.dim == 3) { - p->q.ang_dir.ele = *p->fld[1]; - } else { - p->q.ang_dir.ele = FL(0.0); - } - if (p->q.dim == 3) { - p->q.curr_fld = 1; - p->q.next_fld = 2; - } - angle_to_cart(p->q.ang_dir, &(p->q.cart_dir)); - p->q.spread_base.x = p->q.cart_dir.y; - p->q.spread_base.y = p->q.cart_dir.z; - p->q.spread_base.z = -p->q.cart_dir.x; - vbap1_moving_control(csound,&p->q, &(p->h), CS_ONEDKR, - *p->spread, *p->field_am, p->fld); - return OK; -} - -int32_t vbap1_moving_init_a(CSOUND *csound, VBAPA1_MOVING *p) -{ - int32_t i, j; - MYFLT *ls_table, *ptr; - LS_SET *ls_set_ptr; - - if (UNLIKELY(p->tabout->data == NULL || p->tabout->dimensions!=1)) - return csound->InitError(csound, "%s", Str("Output array not initialised")); - p->q.number = p->tabout->sizes[0]; - ls_table = - (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, "vbap_ls_table_0")); - /* reading in loudspeaker info */ - p->q.dim = (int32_t)ls_table[0]; - p->q.ls_am = (int32_t)ls_table[1]; - p->q.ls_set_am = (int32_t)ls_table[2]; - ptr = &(ls_table[3]); - if (UNLIKELY(!p->q.ls_set_am)) - return csound->InitError(csound, "%s", Str("vbap system NOT configured.\n" - "Missing vbaplsinit opcode" - " in orchestra?")); - csound->AuxAlloc(csound, p->q.ls_set_am * sizeof(LS_SET), &p->q.aux); - if (UNLIKELY(p->q.aux.auxp == NULL)) { - return csound->InitError(csound, "%s", Str("could not allocate memory")); - } - p->q.ls_sets = (LS_SET*) p->q.aux.auxp; - ls_set_ptr = p->q.ls_sets; - for (i=0 ; i < p->q.ls_set_am ; i++) { - ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ - for (j=0 ; j < p->q.dim ; j++) { - ls_set_ptr[i].ls_nos[j] = (int32_t)*(ptr++); - } - for (j=0 ; j < 9; j++) - ls_set_ptr[i].ls_mx[j] = FL(0.0); /*initial setting*/ - for (j=0 ; j < (p->q.dim) * (p->q.dim); j++) { - ls_set_ptr[i].ls_mx[j] = (MYFLT)*(ptr++); - } - } - - /* other initialization */ - p->q.ele_vel = FL(1.0); /* functions specific to movement */ - if (UNLIKELY(fabs(*p->field_am) < (2+ (p->q.dim - 2)*2))) { - return csound->InitError(csound, - Str("Have to have at least %d directions in vbapmove"), - 2 + (p->q.dim - 2) * 2); - } - if (p->q.dim == 2) - p->q.point_change_interval = - (int32_t)(CS_EKR * *p->dur /(fabs(*p->field_am) - 1.0)); - else if (LIKELY(p->q.dim == 3)) - p->q.point_change_interval = - (int32_t)(CS_EKR * *p->dur /(fabs(*p->field_am)*0.5 - 1.0)); - else - return csound->InitError(csound, "%s", Str("Wrong dimension")); - p->q.point_change_counter = 0; - p->q.curr_fld = 0; - p->q.next_fld = 1; - p->q.ang_dir.azi = *p->fld[0]; - if (p->q.dim == 3) { - p->q.ang_dir.ele = *p->fld[1]; - } else { - p->q.ang_dir.ele = FL(0.0); - } - if (p->q.dim == 3) { - p->q.curr_fld = 1; - p->q.next_fld = 2; - } - angle_to_cart(p->q.ang_dir, &(p->q.cart_dir)); - p->q.spread_base.x = p->q.cart_dir.y; - p->q.spread_base.y = p->q.cart_dir.z; - p->q.spread_base.z = -p->q.cart_dir.x; - vbap1_moving_control(csound,&p->q, &(p->h), CS_ONEDKR, - *p->spread, *p->field_am, p->fld); - return OK; -} - +// moved code to vbap.c diff --git a/Opcodes/vbap_n.c b/Opcodes/vbap_n.c index facdf7d6e90..7ce2a86c34c 100644 --- a/Opcodes/vbap_n.c +++ b/Opcodes/vbap_n.c @@ -27,837 +27,4 @@ functions specific to four loudspeaker VBAP Ville Pulkki heavily modified by John ffitch 2012 */ - - -#ifdef BUILD_PLUGINS -#include "csdl.h" -#else -#include "csoundCore.h" -#endif -#include "vbap.h" -#include -#include -#include -#include "arrays.h" - -int32_t vbap_moving_control(CSOUND *, VBAP_MOVE_DATA *, OPDS*, MYFLT, - MYFLT *, MYFLT*,MYFLT**); - -int32_t vbap(CSOUND *csound, VBAP *p) /* during note performance: */ -{ - MYFLT *outptr, *inptr; - MYFLT ogain, ngain, gainsubstr; - MYFLT invfloatn; - int32_t j; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t i, nsmps = CS_KSMPS; - int32_t cnt = p->q.number; - vbap_control(csound,&p->q, p->azi, p->ele, p->spread); - for (j=0; jq.beg_gains[j] = p->q.end_gains[j]; - p->q.end_gains[j] = p->q.updated_gains[j]; - } - - /* write audio to result audio streams weighted - with gain factors*/ - if (UNLIKELY(early)) nsmps -= early; - invfloatn = FL(1.0)/(nsmps-offset); - for (j=0; jaudio; - outptr = p->out_array[j]; - ogain = p->q.beg_gains[j]; - ngain = p->q.end_gains[j]; - gainsubstr = ngain - ogain; - if (UNLIKELY(offset)) memset(outptr, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) memset(&outptr[nsmps], '\0', early*sizeof(MYFLT)); - //printf("cnt%d: ngain=%lf ogain=%f\n", j, ngain, ogain); - if (ngain != FL(0.0) || ogain != FL(0.0)) { - if (ngain != ogain) { - for (i = offset; i < nsmps; i++) { - outptr[i] = inptr[i] * - (ogain + (MYFLT)(i+1) * invfloatn * gainsubstr); - } - p->q.curr_gains[j]= ogain + - (MYFLT)(i) * invfloatn * gainsubstr; - } - else { - for (i=offset; ih.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t i, nsmps = CS_KSMPS; - uint32_t ksmps = nsmps; - int32_t cnt = p->q.number; - - vbap_control(csound,&p->q, p->azi, p->ele, p->spread); - for (j=0; jq.beg_gains[j] = p->q.end_gains[j]; - p->q.end_gains[j] = p->q.updated_gains[j]; - } - - /* write audio to result audio streams weighted - with gain factors*/ - if (UNLIKELY(early)) nsmps -= early; - invfloatn = FL(1.0)/(nsmps-offset); - for (j=0; jtabout->data[j*ksmps]; - inptr = p->audio; - ogain = p->q.beg_gains[j]; - ngain = p->q.end_gains[j]; - gainsubstr = ngain - ogain; - if (UNLIKELY(offset)) memset(outptr, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) memset(&outptr[nsmps], '\0', early*sizeof(MYFLT)); - if (ngain != FL(0.0) || ogain != FL(0.0)) { - if (ngain != ogain) { - for (i = offset; i < nsmps; i++) { - outptr[i] = inptr[i] * - (ogain + (MYFLT)(i+1) * invfloatn * gainsubstr); - } - p->q.curr_gains[j]= ogain + - (MYFLT)(i) * invfloatn * gainsubstr; - } - else { - for (i=offset; inumber; - MYFLT *tmp_gains = malloc(sizeof(MYFLT)*cnt),sum=FL(0.0); - if (UNLIKELY(p->dim == 2 && fabs(*ele) > 0.0)) { - csound->Warning(csound, - "%s", Str("Warning: truncating elevation to 2-D plane\n")); - *ele = FL(0.0); - } - - if (*spread FL(100.0)) - *spread = FL(100.0); - /* Current panning angles */ - p->ang_dir.azi = (MYFLT) *azi; - p->ang_dir.ele = (MYFLT) *ele; - p->ang_dir.length = FL(1.0); - angle_to_cart(p->ang_dir, &(p->cart_dir)); - calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, - p->updated_gains, cnt, p->cart_dir); - - /* Calculated gain factors of a spreaded virtual source*/ - if (*spread > FL(0.0)) { - if (p->dim == 3) { - spreaddirnum = 16; - /* four orthogonal dirs*/ - new_spread_dir(&spreaddir[0], p->cart_dir, - p->spread_base, *azi, *spread); - new_spread_base(spreaddir[0], p->cart_dir, - *spread, &p->spread_base); - cross_prod(p->spread_base, p->cart_dir, &spreadbase[1]); - cross_prod(spreadbase[1], p->cart_dir, &spreadbase[2]); - cross_prod(spreadbase[2], p->cart_dir, &spreadbase[3]); - /* four between them*/ - vec_mean(p->spread_base, spreadbase[1], &spreadbase[4]); - vec_mean(spreadbase[1], spreadbase[2], &spreadbase[5]); - vec_mean(spreadbase[2], spreadbase[3], &spreadbase[6]); - vec_mean(spreadbase[3], p->spread_base, &spreadbase[7]); - - /* four at half spreadangle*/ - vec_mean(p->cart_dir, p->spread_base, &spreadbase[8]); - vec_mean(p->cart_dir, spreadbase[1], &spreadbase[9]); - vec_mean(p->cart_dir, spreadbase[2], &spreadbase[10]); - vec_mean(p->cart_dir, spreadbase[3], &spreadbase[11]); - - /* four at quarter spreadangle*/ - vec_mean(p->cart_dir, spreadbase[8], &spreadbase[12]); - vec_mean(p->cart_dir, spreadbase[9], &spreadbase[13]); - vec_mean(p->cart_dir, spreadbase[10], &spreadbase[14]); - vec_mean(p->cart_dir, spreadbase[11], &spreadbase[15]); - - for (i=1;icart_dir, - spreadbase[i],*azi,*spread); - calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, - tmp_gains, cnt, spreaddir[i]); - for (j=0;jupdated_gains[j] += tmp_gains[j]; - } - } - } - else if (p->dim == 2) { - spreaddirnum = 6; - atmp.ele = FL(0.0); - atmp.azi = *azi - *spread; - angle_to_cart(atmp, &spreaddir[0]); - atmp.azi = *azi - *spread/2; - angle_to_cart(atmp, &spreaddir[1]); - atmp.azi = *azi - *spread/4; - angle_to_cart(atmp, &spreaddir[2]); - atmp.azi = *azi + *spread/4; - angle_to_cart(atmp, &spreaddir[3]); - atmp.azi = *azi + *spread/2; - angle_to_cart(atmp, &spreaddir[4]); - atmp.azi = *azi + *spread; - angle_to_cart(atmp, &spreaddir[5]); - - for (i=0;ils_set_am, p->dim, p->ls_sets, - tmp_gains, cnt, spreaddir[i]); - for (j=0;jupdated_gains[j] += tmp_gains[j]; - } - } - } - } - if (*spread > FL(70.0)) - for (i=0;iupdated_gains[i] +=(*spread - FL(70.0))/FL(30.0) * - (*spread - FL(70.0))/FL(30.0)*FL(20.0); - } - - /*normalization*/ - for (i=0;iupdated_gains[i]*p->updated_gains[i]; - } - - sum=SQRT(sum); - for (i=0;iupdated_gains[i] /= sum; - } - free(tmp_gains); - return OK; -} - -int32_t vbap_init(CSOUND *csound, VBAP *p) -{ /* Initializations before run time*/ - int32_t i, j; - MYFLT *ls_table, *ptr; - LS_SET *ls_set_ptr; - int32_t cnt = p->q.number = (int32_t)(p->OUTOCOUNT); - char name[24]; - - snprintf(name, 24, "vbap_ls_table_%d", (p->layout==NULL?0:(int32_t)*p->layout)); - ls_table = (MYFLT*) (csound->QueryGlobalVariable(csound, name)); - - if (UNLIKELY(ls_table==NULL)) - return csound->InitError(csound, - Str("could not find layout table no.%d"), - (int32_t)*p->layout ); - - p->q.dim = (int32_t)ls_table[0]; /* reading in loudspeaker info */ - p->q.ls_am = (int32_t)ls_table[1]; - p->q.ls_set_am = (int32_t)ls_table[2]; - ptr = &(ls_table[3]); - if (UNLIKELY(!p->q.ls_set_am)) - return csound->InitError(csound, - "%s", Str("vbap system NOT configured.\nMissing" - " vbaplsinit opcode in orchestra?")); - csound->AuxAlloc(csound, p->q.ls_set_am * sizeof (LS_SET), &p->q.aux); - if (UNLIKELY(p->q.aux.auxp == NULL)) { - return csound->InitError(csound, "%s", Str("could not allocate memory")); - } - p->q.ls_sets = (LS_SET*) p->q.aux.auxp; - ls_set_ptr = p->q.ls_sets; - for (i=0; i < p->q.ls_set_am; i++) { - ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ - for (j=0 ; j < p->q.dim ; j++) { - ls_set_ptr[i].ls_nos[j] = (int32_t)*(ptr++); - } - memset(ls_set_ptr[i].ls_mx, '\0', 9*sizeof(MYFLT)); // initial setting - /* for (j=0 ; j < 9; j++) */ - /* ls_set_ptr[i].ls_mx[j] = FL(0.0); /\*initial setting*\/ */ - for (j=0 ; j < (p->q.dim) * (p->q.dim); j++) { - ls_set_ptr[i].ls_mx[j] = (MYFLT)*(ptr++); - } - } - - /* other initialization */ - if (UNLIKELY(p->q.dim == 2 && fabs(p->ele==NULL?0:*p->ele) > 0.0)) { - csound->Warning(csound, - "%s", Str("Warning: truncating elevation to 2-D plane\n")); - *p->ele = FL(0.0); - } - p->q.ang_dir.azi = (MYFLT)*p->azi; - p->q.ang_dir.ele = (MYFLT)*p->ele; - p->q.ang_dir.length = FL(1.0); - angle_to_cart(p->q.ang_dir, &(p->q.cart_dir)); - p->q.spread_base.x = p->q.cart_dir.y; - p->q.spread_base.y = p->q.cart_dir.z; - p->q.spread_base.z = -p->q.cart_dir.x; - vbap_control(csound,&(p->q), p->azi, p->ele, p->spread); - for (i=0;iq.beg_gains[i] = p->q.updated_gains[i]; - p->q.end_gains[i] = p->q.updated_gains[i]; - } - return OK; -} - -int32_t vbap_init_a(CSOUND *csound, VBAPA *p) -{ /* Initializations before run time*/ - int32_t i, j; - MYFLT *ls_table, *ptr; - LS_SET *ls_set_ptr; - int32_t cnt; - char name[24]; - - snprintf(name, 24, "vbap_ls_table_%d", (int32_t)*p->layout); - ls_table = (MYFLT*) (csound->QueryGlobalVariable(csound, name)); - - if (UNLIKELY(ls_table==NULL)) - return csound->InitError(csound, - Str("could not find layout table no.%d"), - (int32_t)*p->layout ); - - p->q.dim = (int32_t)ls_table[0]; /* reading in loudspeaker info */ - p->q.ls_am = (int32_t)ls_table[1]; - p->q.ls_set_am = (int32_t)ls_table[2]; - ptr = &(ls_table[3]); - if (UNLIKELY(!p->q.ls_set_am)) - return csound->InitError(csound, - "%s", Str("vbap system NOT configured.\nMissing" - " vbaplsinit opcode in orchestra?")); - //printf("**** size = %d\n", p->q.ls_set_am); - tabinit(csound, p->tabout, p->q.ls_set_am); - cnt = p->q.number = p->tabout->sizes[0]; - csound->AuxAlloc(csound, p->q.ls_set_am * sizeof(LS_SET), &p->q.aux); - if (UNLIKELY(p->q.aux.auxp == NULL)) { - return csound->InitError(csound, "%s", Str("could not allocate memory")); - } - p->q.ls_sets = (LS_SET*) p->q.aux.auxp; - ls_set_ptr = p->q.ls_sets; - for (i=0; i < p->q.ls_set_am; i++) { - ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ - for (j=0 ; j < p->q.dim ; j++) { - ls_set_ptr[i].ls_nos[j] = (int32_t)*(ptr++); - } - memset(ls_set_ptr[i].ls_mx, '\0', 9*sizeof(MYFLT)); - /* for (j=0 ; j < 9; j++) */ - /* ls_set_ptr[i].ls_mx[j] = FL(0.0); /\*initial setting*\/ */ - for (j=0 ; j < (p->q.dim) * (p->q.dim); j++) { - ls_set_ptr[i].ls_mx[j] = (MYFLT)*(ptr++); - } - } - - /* other initialization */ - if (UNLIKELY(p->q.dim == 2 && fabs(*p->ele) > 0.0)) { - csound->Warning(csound, - "%s", Str("Warning: truncating elevation to 2-D plane\n")); - *p->ele = FL(0.0); - } - p->q.ang_dir.azi = *p->azi; - p->q.ang_dir.ele = *p->ele; - p->q.ang_dir.length = FL(1.0); - angle_to_cart(p->q.ang_dir, &(p->q.cart_dir)); - p->q.spread_base.x = p->q.cart_dir.y; - p->q.spread_base.y = p->q.cart_dir.z; - p->q.spread_base.z = -p->q.cart_dir.x; - vbap_control(csound,&(p->q), p->azi, p->ele, p->spread); - for (i=0;iq.beg_gains[i] = p->q.updated_gains[i]; - p->q.end_gains[i] = p->q.updated_gains[i]; - } - return OK; -} - -int32_t vbap_moving(CSOUND *csound, VBAP_MOVING *p) -{ /* during note performance: */ - MYFLT *outptr, *inptr; - MYFLT ogain, ngain, gainsubstr; - MYFLT invfloatn; - int32_t j; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t i, nsmps = CS_KSMPS; - int32_t cnt = p->q.number; - - vbap_moving_control(csound,&p->q, &(p->h), CS_ONEDKR, - p->spread, p->field_am, p->fld); - // vbap_moving_control(csound,p); - for (j=0;jq.beg_gains[j] = p->q.end_gains[j]; - p->q.end_gains[j] = p->q.updated_gains[j]; - } - - /* write audio to resulting audio streams weighted - with gain factors*/ - if (UNLIKELY(early)) nsmps -= early; - invfloatn = FL(1.0)/(nsmps-offset); - for (j=0; jaudio; - outptr = p->out_array[j]; - if (UNLIKELY(offset)) memset(outptr, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) memset(&outptr[nsmps], '\0', early*sizeof(MYFLT)); - ogain = p->q.beg_gains[j]; - ngain = p->q.end_gains[j]; - gainsubstr = ngain - ogain; - if (ngain != FL(0.0) || ogain != FL(0.0)) - if (ngain != ogain) { - for (i = offset; i < nsmps; i++) { - outptr[i] = inptr[i] * - (ogain + (MYFLT)(i+1) * invfloatn * gainsubstr); - } - p->q.curr_gains[j]= ogain + - (MYFLT)(i) * invfloatn * gainsubstr; - } - else - for (i=offset; inumber; - MYFLT *tmp_gains=malloc(sizeof(MYFLT)*cnt),sum=FL(0.0); - - if (UNLIKELY(p->dim == 2 && fabs(p->ang_dir.ele) > 0.0)) { - csound->Warning(csound, - "%s", Str("Warning: truncating elevation to 2-D plane\n")); - p->ang_dir.ele = FL(0.0); - } - if (*spread FL(100.0)) - *spread = FL(100.0); - if (p->point_change_counter++ >= p->point_change_interval) { - p->point_change_counter = 0; - p->curr_fld = p->next_fld; - if (++p->next_fld >= (int32_t) fabs(*field_am)) { - if (*field_am >= FL(0.0)) /* point-to-point */ - p->next_fld = 0; - else - p->next_fld = 1; - } - if (p->dim == 3) { /*jumping over second field */ - p->curr_fld = p->next_fld; - if (++p->next_fld >= ((int32_t) fabs(*field_am))) { - if (*field_am >= FL(0.0)) /* point-to-point */ - p->next_fld = 0; - else - p->next_fld = 1; - } - } - if (UNLIKELY((fld[abs(p->next_fld)]==NULL))) { - free(tmp_gains); - return csound->PerfError(csound, h, - "%s", Str("Missing fields in vbapmove\n")); - } - if (*field_am >= FL(0.0) && p->dim == 2) /* point-to-point */ - if (UNLIKELY(fabs(fabs(*fld[p->next_fld] - - *fld[p->curr_fld]) - 180.0) < 1.0)) - csound->Warning(csound, - "%s", Str("Warning: Ambiguous transition 180 degrees.\n")); - } - if (*field_am >= FL(0.0)) { /* point-to-point */ - if (p->dim == 3) { /* 3-D*/ - p->prev_ang_dir.azi = *fld[p->curr_fld-1]; - p->next_ang_dir.azi = *fld[p->next_fld]; - p->prev_ang_dir.ele = *fld[p->curr_fld]; - p->next_ang_dir.ele = *fld[p->next_fld+1]; - coeff = ((MYFLT) p->point_change_counter) / - ((MYFLT) p->point_change_interval); - angle_to_cart( p->prev_ang_dir,&tmp1); - angle_to_cart( p->next_ang_dir,&tmp2); - tmp3.x = (FL(1.0)-coeff) * tmp1.x + coeff * tmp2.x; - tmp3.y = (FL(1.0)-coeff) * tmp1.y + coeff * tmp2.y; - tmp3.z = (FL(1.0)-coeff) * tmp1.z + coeff * tmp2.z; - coeff = (MYFLT)sqrt((double)(tmp3.x * tmp3.x + - tmp3.y * tmp3.y + - tmp3.z * tmp3.z)); - tmp3.x /= coeff; tmp3.y /= coeff; tmp3.z /= coeff; - cart_to_angle(tmp3,&(p->ang_dir)); - } - else if (LIKELY(p->dim == 2)) { /* 2-D */ - p->prev_ang_dir.azi = *fld[p->curr_fld]; - p->next_ang_dir.azi = *fld[p->next_fld ]; - p->prev_ang_dir.ele = p->next_ang_dir.ele = FL(0.0); - scale_angles(&(p->prev_ang_dir)); - scale_angles(&(p->next_ang_dir)); - angle = (p->prev_ang_dir.azi - p->next_ang_dir.azi); - while (angle > FL(180.0)) - angle -= FL(360.0); - while (angle < -FL(180.0)) - angle += FL(360.0); - coeff = ((MYFLT) p->point_change_counter) / - ((MYFLT) p->point_change_interval); - angle *= (coeff); - p->ang_dir.azi = p->prev_ang_dir.azi - angle; - p->ang_dir.ele = FL(0.0); - } - else { - free(tmp_gains); - return csound->PerfError(csound, h, - "%s", Str("Missing fields in vbapmove\n")); - } - } - else { /* angular velocities */ - if (p->dim == 2) { - p->ang_dir.azi = p->ang_dir.azi + - (*fld[p->next_fld] * ONEDKR); - scale_angles(&(p->ang_dir)); - } - else { /* 3D angular*/ - p->ang_dir.azi = p->ang_dir.azi + - (*fld[p->next_fld] * ONEDKR); - p->ang_dir.ele = p->ang_dir.ele + - p->ele_vel * (*fld[p->next_fld+1] * ONEDKR); - if (p->ang_dir.ele > FL(90.0)) { - p->ang_dir.ele = FL(90.0); - p->ele_vel = -p->ele_vel; - } - if (p->ang_dir.ele < FL(0.0)) { - p->ang_dir.ele = FL(0.0); - p->ele_vel = -p->ele_vel; - } - scale_angles(&(p->ang_dir)); - } - } - angle_to_cart(p->ang_dir, &(p->cart_dir)); - calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, - p->updated_gains, cnt, p->cart_dir); - if (*spread > FL(0.0)) { - if (p->dim == 3) { - spreaddirnum=16; - /* four orthogonal dirs*/ - new_spread_dir(&spreaddir[0], p->cart_dir, - p->spread_base, p->ang_dir.azi, *spread); - - new_spread_base(spreaddir[0], p->cart_dir,*spread, &p->spread_base); - cross_prod(p->spread_base, p->cart_dir, &spreadbase[1]); - cross_prod(spreadbase[1], p->cart_dir, &spreadbase[2]); - cross_prod(spreadbase[2], p->cart_dir, &spreadbase[3]); - /* four between them*/ - vec_mean(p->spread_base, spreadbase[1], &spreadbase[4]); - vec_mean(spreadbase[1], spreadbase[2], &spreadbase[5]); - vec_mean(spreadbase[2], spreadbase[3], &spreadbase[6]); - vec_mean(spreadbase[3], p->spread_base, &spreadbase[7]); - - /* four at half spreadangle*/ - vec_mean(p->cart_dir, p->spread_base, &spreadbase[8]); - vec_mean(p->cart_dir, spreadbase[1], &spreadbase[9]); - vec_mean(p->cart_dir, spreadbase[2], &spreadbase[10]); - vec_mean(p->cart_dir, spreadbase[3], &spreadbase[11]); - - /* four at quarter spreadangle*/ - vec_mean(p->cart_dir, spreadbase[8], &spreadbase[12]); - vec_mean(p->cart_dir, spreadbase[9], &spreadbase[13]); - vec_mean(p->cart_dir, spreadbase[10], &spreadbase[14]); - vec_mean(p->cart_dir, spreadbase[11], &spreadbase[15]); - - for (i=1;icart_dir, - spreadbase[i],p->ang_dir.azi,*spread); - calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, - tmp_gains, cnt, spreaddir[i]); - for (j=0;jupdated_gains[j] += tmp_gains[j]; - } - } - } - else if (p->dim == 2) { - spreaddirnum=6; - atmp.ele = FL(0.0); - atmp.azi = p->ang_dir.azi - *spread; - angle_to_cart(atmp, &spreaddir[0]); - atmp.azi = p->ang_dir.azi - *spread/2; - angle_to_cart(atmp, &spreaddir[1]); - atmp.azi = p->ang_dir.azi - *spread/4; - angle_to_cart(atmp, &spreaddir[2]); - atmp.azi = p->ang_dir.azi + *spread/4; - angle_to_cart(atmp, &spreaddir[3]); - atmp.azi = p->ang_dir.azi + *spread/2; - angle_to_cart(atmp, &spreaddir[4]); - atmp.azi = p->ang_dir.azi + *spread; - angle_to_cart(atmp, &spreaddir[5]); - - for (i=0;ils_set_am, p->dim, p->ls_sets, - tmp_gains, cnt, spreaddir[i]); - for (j=0;jupdated_gains[j] += tmp_gains[j]; - } - } - } - } - if (*spread > FL(70.0)) - for (i=0;iupdated_gains[i] +=(*spread - FL(70.0))/FL(30.0) * - (*spread - FL(70.0))/FL(30.0)*FL(10.0); - } - /*normalization*/ - for (i=0;iupdated_gains[i]*p->updated_gains[i]); - } - - sum=SQRT(sum); - for (i=0;iupdated_gains[i] /= sum; - } - free(tmp_gains); - return OK; -} - -int32_t vbap_moving_init(CSOUND *csound, VBAP_MOVING *p) -{ - int32_t i, j; - MYFLT *ls_table, *ptr; - LS_SET *ls_set_ptr; - int32_t cnt = (int32_t)p->h.optext->t.outArgCount; - if ((!strncmp(p->h.optext->t.opcod, "vbapmove", 8)) == 0) { - p->audio = p->out_array[cnt]; - p->dur = p->out_array[cnt+1]; - p->spread = p->out_array[cnt+2]; - p->field_am = p->out_array[cnt+3]; - memcpy(p->fld, &(p->out_array[cnt+4]), - sizeof(MYFLT *)*(p->h.optext->t.inArgCount-4)); - } - - ls_table = (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, - "vbap_ls_table_0")); - if (UNLIKELY(ls_table==NULL)) - return csound->InitError(csound, "%s", Str("could not find layout table no.0")); - p->q.number = cnt; - /* reading in loudspeaker info */ - p->q.dim = (int32_t)ls_table[0]; - p->q.ls_am = (int32_t)ls_table[1]; - p->q.ls_set_am = (int32_t)ls_table[2]; - ptr = &(ls_table[3]); - if (UNLIKELY(!p->q.ls_set_am)) - return csound->InitError(csound, "%s", Str("vbap system NOT configured.\nMissing" - " vbaplsinit opcode in orchestra?")); - csound->AuxAlloc(csound, p->q.ls_set_am * sizeof(LS_SET), &p->q.aux); - if (UNLIKELY(p->q.aux.auxp == NULL)) { - return csound->InitError(csound, "%s", Str("could not allocate memory")); - } - p->q.ls_sets = (LS_SET*) p->q.aux.auxp; - ls_set_ptr = p->q.ls_sets; - for (i=0 ; i < p->q.ls_set_am ; i++) { - ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ - for (j=0 ; j < p->q.dim ; j++) { - ls_set_ptr[i].ls_nos[j] = (int32_t)*(ptr++); - } - for (j=0 ; j < 9; j++) - ls_set_ptr[i].ls_mx[j] = FL(0.0); /*initial setting*/ - for (j=0 ; j < (p->q.dim) * (p->q.dim); j++) { - ls_set_ptr[i].ls_mx[j] = (MYFLT)*(ptr++); - } - } - - /* other initialization */ - p->q.ele_vel = FL(1.0); /* functions specific to movement */ - if (UNLIKELY(fabs(*p->field_am) < (2+ (p->q.dim - 2)*2))) { - return csound->InitError(csound, - Str("Have to have at least %d directions in vbapmove"), - 2 + (p->q.dim - 2) * 2); - } - if (p->q.dim == 2) - p->q.point_change_interval = - (int32_t)(CS_EKR * *p->dur /(fabs(*p->field_am) - 1.0)); - else if (LIKELY(p->q.dim == 3)) - p->q.point_change_interval = - (int32_t)(CS_EKR * *p->dur /(fabs(*p->field_am)*0.5 - 1.0)); - else - return csound->InitError(csound, "%s", Str("Wrong dimension")); - p->q.point_change_counter = 0; - p->q.curr_fld = 0; - p->q.next_fld = 1; - p->q.ang_dir.azi = *p->fld[0]; - if (p->q.dim == 3) { - p->q.ang_dir.ele = *p->fld[1]; - } else { - p->q.ang_dir.ele = FL(0.0); - } - if (p->q.dim == 3) { - p->q.curr_fld = 1; - p->q.next_fld = 2; - } - angle_to_cart(p->q.ang_dir, &(p->q.cart_dir)); - p->q.spread_base.x = p->q.cart_dir.y; - p->q.spread_base.y = p->q.cart_dir.z; - p->q.spread_base.z = -p->q.cart_dir.x; - vbap_moving_control(csound,&p->q, &(p->h), CS_ONEDKR, - p->spread, p->field_am, p->fld); - for (i = 0; iq.beg_gains[i] = p->q.updated_gains[i]; - p->q.end_gains[i] = p->q.updated_gains[i]; - } - return OK; -} - -int32_t vbap_moving_a(CSOUND *csound, VBAPA_MOVING *p) -{ /* during note performance: */ - MYFLT *outptr, *inptr; - MYFLT ogain, ngain, gainsubstr; - MYFLT invfloatn; - int32_t j; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t i, nsmps = CS_KSMPS; - uint32_t ksmps = nsmps; - int32_t cnt = p->q.number; - - vbap_moving_control(csound,&p->q, &(p->h), CS_ONEDKR, - p->spread, p->field_am, p->fld); - // vbap_moving_control(csound,p); - for (j=0;jq.beg_gains[j] = p->q.end_gains[j]; - p->q.end_gains[j] = p->q.updated_gains[j]; - } - - /* write audio to resulting audio streams weighted - with gain factors*/ - if (UNLIKELY(early)) nsmps -= early; - invfloatn = FL(1.0)/(nsmps-offset); - //outptr = p->tabout->data; - for (j=0; jaudio; - outptr = &p->tabout->data[j*ksmps]; - if (UNLIKELY(offset)) memset(outptr, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) memset(&outptr[nsmps], '\0', early*sizeof(MYFLT)); - ogain = p->q.beg_gains[j]; - ngain = p->q.end_gains[j]; - gainsubstr = ngain - ogain; - if (ngain != FL(0.0) || ogain != FL(0.0)) - if (ngain != ogain) { - for (i = offset; i < nsmps; i++) { - outptr[i] = inptr[i] * - (ogain + (MYFLT)(i+1) * invfloatn * gainsubstr); - } - p->q.curr_gains[j]= ogain + - (MYFLT)(i) * invfloatn * gainsubstr; - } - else - for (i=offset; itabout->data==NULL)) { - return csound->InitError(csound, - "%s", Str("Output array in vpabmove not initialised")); - } - cnt = p->tabout->sizes[0]; - - ls_table = (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, - "vbap_ls_table_0")); - if (UNLIKELY(ls_table==NULL)) - return csound->InitError(csound, "%s", Str("could not find layout table no.0")); - p->q.number = cnt; - /* reading in loudspeaker info */ - p->q.dim = (int32_t)ls_table[0]; - p->q.ls_am = (int32_t)ls_table[1]; - p->q.ls_set_am = (int32_t)ls_table[2]; - ptr = &(ls_table[3]); - if (UNLIKELY(!p->q.ls_set_am)) - return csound->InitError(csound, - "%s", Str("vbap system NOT configured.\nMissing" - " vbaplsinit opcode in orchestra?")); - csound->AuxAlloc(csound, p->q.ls_set_am * sizeof(LS_SET), &p->q.aux); - if (UNLIKELY(p->q.aux.auxp == NULL)) { - return csound->InitError(csound, "%s", Str("could not allocate memory")); - } - p->q.ls_sets = (LS_SET*) p->q.aux.auxp; - ls_set_ptr = p->q.ls_sets; - for (i=0 ; i < p->q.ls_set_am ; i++) { - ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ - for (j=0 ; j < p->q.dim ; j++) { - ls_set_ptr[i].ls_nos[j] = (int32_t)*(ptr++); - } - memset(ls_set_ptr[i].ls_mx, '\0', 9*sizeof(MYFLT)); - /* for (j=0 ; j < 9; j++) */ - /* ls_set_ptr[i].ls_mx[j] = FL(0.0); /\*initial setting*\/ */ - for (j=0 ; j < (p->q.dim) * (p->q.dim); j++) { - ls_set_ptr[i].ls_mx[j] = (MYFLT)*(ptr++); - } - } - - /* other initialization */ - p->q.ele_vel = FL(1.0); /* functions specific to movement */ - if (UNLIKELY(fabs(*p->field_am) < (2+ (p->q.dim - 2)*2))) { - return csound->InitError(csound, - Str("Have to have at least %d directions in vbapmove"), - 2 + (p->q.dim - 2) * 2); - } - if (p->q.dim == 2) - p->q.point_change_interval = - (int32_t)(CS_EKR * *p->dur /(fabs(*p->field_am) - 1.0)); - else if (LIKELY(p->q.dim == 3)) - p->q.point_change_interval = - (int32_t)(CS_EKR * *p->dur /(fabs(*p->field_am)*0.5 - 1.0)); - else - return csound->InitError(csound, "%s", Str("Wrong dimension")); - p->q.point_change_counter = 0; - p->q.curr_fld = 0; - p->q.next_fld = 1; - p->q.ang_dir.azi = *p->fld[0]; - if (p->q.dim == 3) { - p->q.ang_dir.ele = *p->fld[1]; - } else { - p->q.ang_dir.ele = FL(0.0); - } - if (p->q.dim == 3) { - p->q.curr_fld = 1; - p->q.next_fld = 2; - } - angle_to_cart(p->q.ang_dir, &(p->q.cart_dir)); - p->q.spread_base.x = p->q.cart_dir.y; - p->q.spread_base.y = p->q.cart_dir.z; - p->q.spread_base.z = -p->q.cart_dir.x; - vbap_moving_control(csound,&p->q, &(p->h), CS_ONEDKR, - p->spread, p->field_am, p->fld); - for (i = 0; iq.beg_gains[i] = p->q.updated_gains[i]; - p->q.end_gains[i] = p->q.updated_gains[i]; - } - return OK; -} - - +// code moved to vbap.c diff --git a/Opcodes/vbap_zak.c b/Opcodes/vbap_zak.c index 425fc58ea9a..9c04c1678e9 100644 --- a/Opcodes/vbap_zak.c +++ b/Opcodes/vbap_zak.c @@ -27,580 +27,4 @@ Ville Pulkki & John ffitch */ - - -#ifdef BUILD_PLUGINS -#include "csdl.h" -#else -#include "csoundCore.h" -#endif -#include "vbap.h" -#include -#include -#include -#include "zak.h" - -int32_t vbap_zak_moving_control(CSOUND *, VBAP_ZAK_MOVING *); -int32_t vbap_zak_control(CSOUND *,VBAP_ZAK *); - -int32_t vbap_zak(CSOUND *csound, VBAP_ZAK *p) /* during note performance: */ -{ - MYFLT *outptr, *inptr; - MYFLT ogain, ngain, gainsubstr; - MYFLT invfloatn; - int32_t j; - int32_t n = p->n; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t i, nsmps = CS_KSMPS; - - vbap_zak_control(csound,p); - for (j=0; jbeg_gains[j] = p->end_gains[j]; - p->end_gains[j] = p->updated_gains[j]; - } - - /* write audio to result audio streams weighted - with gain factors */ - outptr = p->out_array; - if (UNLIKELY(early)) nsmps -= early; - invfloatn = FL(1.0)/(nsmps-offset); - for (j=0; jaudio; - ogain = p->beg_gains[j]; - ngain = p->end_gains[j]; - gainsubstr = ngain - ogain; - if (UNLIKELY(offset)) memset(outptr, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) memset(&outptr[nsmps], '\0', early*sizeof(MYFLT)); - if (ngain != FL(0.0) || ogain != FL(0.0)) - if (ngain != ogain) { - for (i = offset; i < nsmps; i++) { - outptr[i] = inptr[i] * - (ogain + (MYFLT) (i+1) * invfloatn * gainsubstr); - } - p->curr_gains[j]= ogain + - (MYFLT) (i) * invfloatn * gainsubstr; - } - else { - for (i=offset; in; - MYFLT tmp_gains[MAXCHNLS],sum = FL(0.0); - if (UNLIKELY(p->dim == 2 && fabs(*p->ele) > 0.0)) { - csound->Warning(csound, - "%s", Str("Warning: truncating elevation to 2-D plane\n")); - *p->ele = FL(0.0); - } - if (*p->spread spread=FL(0.0); - else if (*p->spread >FL(100.0)) - *p->spread=FL(100.0); - /* Current panning angles */ - p->ang_dir.azi = (MYFLT) *p->azi; - p->ang_dir.ele = (MYFLT) *p->ele; - p->ang_dir.length = FL(1.0); - angle_to_cart(p->ang_dir, &(p->cart_dir)); - calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, - p->updated_gains, n, p->cart_dir); - - /* Calculated gain factors of a spreaded virtual source */ - if (*p->spread > FL(0.0)) { - if (p->dim == 3) { - spreaddirnum=16; - /* four orthogonal dirs */ - new_spread_dir(&spreaddir[0], p->cart_dir, - p->spread_base, *p->azi, *p->spread); - new_spread_base(spreaddir[0], p->cart_dir,*p->spread, &p->spread_base); - cross_prod(p->spread_base, p->cart_dir, &spreadbase[1]); - cross_prod(spreadbase[1], p->cart_dir, &spreadbase[2]); - cross_prod(spreadbase[2], p->cart_dir, &spreadbase[3]); - /* four between them */ - vec_mean(p->spread_base, spreadbase[1], &spreadbase[4]); - vec_mean(spreadbase[1], spreadbase[2], &spreadbase[5]); - vec_mean(spreadbase[2], spreadbase[3], &spreadbase[6]); - vec_mean(spreadbase[3], p->spread_base, &spreadbase[7]); - - /* four at half spreadangle */ - vec_mean(p->cart_dir, p->spread_base, &spreadbase[8]); - vec_mean(p->cart_dir, spreadbase[1], &spreadbase[9]); - vec_mean(p->cart_dir, spreadbase[2], &spreadbase[10]); - vec_mean(p->cart_dir, spreadbase[3], &spreadbase[11]); - - /* four at quarter spreadangle */ - vec_mean(p->cart_dir, spreadbase[8], &spreadbase[12]); - vec_mean(p->cart_dir, spreadbase[9], &spreadbase[13]); - vec_mean(p->cart_dir, spreadbase[10], &spreadbase[14]); - vec_mean(p->cart_dir, spreadbase[11], &spreadbase[15]); - - for (i=1;icart_dir, - spreadbase[i],*p->azi,*p->spread); - calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, - tmp_gains, n, spreaddir[i]); - for (j=0;jupdated_gains[j] += tmp_gains[j]; - } - } - } - else if (p->dim == 2) { - spreaddirnum = 6; - atmp.ele = FL(0.0); - atmp.azi = *p->azi - *p->spread; - angle_to_cart(atmp, &spreaddir[0]); - atmp.azi = *p->azi - *p->spread/2; - angle_to_cart(atmp, &spreaddir[1]); - atmp.azi = *p->azi - *p->spread/4; - angle_to_cart(atmp, &spreaddir[2]); - atmp.azi = *p->azi + *p->spread/4; - angle_to_cart(atmp, &spreaddir[3]); - atmp.azi = *p->azi + *p->spread/2; - angle_to_cart(atmp, &spreaddir[4]); - atmp.azi = *p->azi + *p->spread; - angle_to_cart(atmp, &spreaddir[5]); - - for (i=0;ils_set_am, p->dim, p->ls_sets, - tmp_gains, n, spreaddir[i]); - for (j=0;jupdated_gains[j] += tmp_gains[j]; - } - } - } - } - if (*p->spread > FL(70.0)) - for (i=0;iupdated_gains[i] +=(*p->spread - FL(70.0))/FL(30.0) * - (*p->spread - FL(70.0))/FL(30.0)*FL(20.0); - } - - /* normalization */ - for (i=0;iupdated_gains[i]*p->updated_gains[i]); - } - - sum = SQRT(sum); - for (i=0;iupdated_gains[i] /= sum; - } - return OK; -} - -int32_t vbap_zak_init(CSOUND *csound, VBAP_ZAK *p) -{ /* Initializations before run time */ - int32_t i, j, indx; - MYFLT *ls_table, *ptr; /* , *gains; */ - LS_SET *ls_set_ptr; - int32_t n = p->n = (int32_t)MYFLT2LONG(*p->numb); /* Set size */ - char name[24]; - /* Check to see this index is within the limits of za space. */ - MYFLT* zastart; - int zalast = csound->GetZaBounds(csound, &zastart); - indx = (int32) *p->ndx; - if (UNLIKELY(indx > zalast)) { - return csound->PerfError(csound, &(p->h), - "%s", Str("outz index > isizea. No output")); - } - else if (UNLIKELY(indx < 0)) { - return csound->PerfError(csound, &(p->h), - "%s", Str("outz index < 0. No output.")); - } - if ((int32_t)*p->layout==0) strcpy(name, "vbap_ls_table"); - else snprintf(name, 24, "vbap_ls_table_%d", (int32_t)*p->layout==0); - /* Now read from the array in za space and write to the output. */ - p->out_array = zastart + (indx * CS_KSMPS);/* outputs */ - csound->AuxAlloc(csound, p->n*sizeof(MYFLT)*4, &p->auxch); - p->curr_gains = (MYFLT*)p->auxch.auxp; - p->beg_gains = p->curr_gains + p->n; - p->end_gains = p->beg_gains + p->n; - p->updated_gains = p->end_gains + p->n; - ls_table = (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, name)); - p->dim = (int32_t) ls_table[0]; /* reading in loudspeaker info */ - p->ls_am = (int32_t) ls_table[1]; - p->ls_set_am = (int32_t) ls_table[2]; - ptr = &(ls_table[3]); - csound->AuxAlloc(csound, p->ls_set_am * sizeof (LS_SET), &p->aux); - if (UNLIKELY(p->aux.auxp == NULL)) { - return csound->InitError(csound, "%s", Str("could not allocate memory")); - } - p->ls_sets = (LS_SET*) p->aux.auxp; - ls_set_ptr = p->ls_sets; - for (i=0 ; i < p->ls_set_am ; i++) { - ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ - for (j=0 ; j < p->dim ; j++) { - ls_set_ptr[i].ls_nos[j] = (int32_t) *(ptr++); - } - for (j=0 ; j < 9; j++) - ls_set_ptr[i].ls_mx[j] = FL(0.0); /* initial setting */ - for (j=0 ; j < (p->dim) * (p->dim); j++) { - ls_set_ptr[i].ls_mx[j] = (MYFLT) *(ptr++); - } - } - - /* other initialization */ - if (UNLIKELY(p->dim == 2 && fabs(*p->ele) > 0.0)) { - csound->Warning(csound, - "%s", Str("Warning: truncating elevation to 2-D plane\n")); - *p->ele = FL(0.0); - } - p->ang_dir.azi = (MYFLT) *p->azi; - p->ang_dir.ele = (MYFLT) *p->ele; - p->ang_dir.length = FL(1.0); - angle_to_cart(p->ang_dir, &(p->cart_dir)); - p->spread_base.x = p->cart_dir.y; - p->spread_base.y = p->cart_dir.z; - p->spread_base.z = -p->cart_dir.x; - vbap_zak_control(csound,p); - for (i=0;ibeg_gains[i] = p->updated_gains[i]; - p->end_gains[i] = p->updated_gains[i]; - } - return OK; -} - -int32_t vbap_zak_moving(CSOUND *csound, VBAP_ZAK_MOVING *p) -{ /* during note performance: */ - MYFLT *outptr, *inptr; - MYFLT ogain, ngain, gainsubstr; - MYFLT invfloatn; - int32_t j; - uint32_t offset = p->h.insdshead->ksmps_offset; - uint32_t early = p->h.insdshead->ksmps_no_end; - uint32_t i, nsmps = CS_KSMPS; - - vbap_zak_moving_control(csound,p); - for (j=0;j< p->n; j++) { - p->beg_gains[j] = p->end_gains[j]; - p->end_gains[j] = p->updated_gains[j]; - } - - /* write audio to resulting audio streams weighted - with gain factors */ - invfloatn = FL(1.0)/(nsmps-offset); - outptr = p->out_array; - if (UNLIKELY(offset)) memset(outptr, '\0', offset*sizeof(MYFLT)); - if (UNLIKELY(early)) { - nsmps -= early; - memset(&outptr[nsmps], '\0', early*sizeof(MYFLT)); - } - for (j=0; jn ;j++) { - inptr = p->audio; - ogain = p->beg_gains[j]; - ngain = p->end_gains[j]; - gainsubstr = ngain - ogain; - if (ngain != FL(0.0) || ogain != FL(0.0)) - if (ngain != ogain) { - for (i = offset; i < nsmps; i++) { - outptr[i] = inptr[i] * - (ogain + (MYFLT) (i+1) * invfloatn * gainsubstr); - } - p->curr_gains[j] = ogain + - (MYFLT) (i) * invfloatn * gainsubstr; - } - else - for (i=offset; in; - CART_VEC tmp1, tmp2, tmp3; - MYFLT coeff, angle; - MYFLT tmp_gains[MAXCHNLS],sum = FL(0.0); /* Array long enough */ - if (UNLIKELY(p->dim == 2 && fabs(p->ang_dir.ele) > 0.0)) { - csound->Warning(csound, - "%s", Str("Warning: truncating elevation to 2-D plane\n")); - p->ang_dir.ele = FL(0.0); - } - - if (*p->spread spread = FL(0.0); - else if (*p->spread >FL(100.0)) - *p->spread = FL(100.0); - if (p->point_change_counter++ >= p->point_change_interval) { - p->point_change_counter = 0; - p->curr_fld = p->next_fld; - if (++p->next_fld >= (int32_t) fabs(*p->field_am)) { - if (*p->field_am >= FL(0.0)) /* point-to-point */ - p->next_fld = 0; - else - p->next_fld = 1; - } - if (p->dim == 3) { /* jumping over second field */ - p->curr_fld = p->next_fld; - if (++p->next_fld >= ((int32_t) fabs(*p->field_am))) { - if (*p->field_am >= FL(0.0)) /* point-to-point */ - p->next_fld = 0; - else - p->next_fld = 1; - } - } - if (UNLIKELY((p->fld[abs(p->next_fld)]==NULL))) - return csound->PerfError(csound, &(p->h), - "%s", Str("Missing fields in vbapzmove\n")); - if (*p->field_am >= FL(0.0) && p->dim == 2) /* point-to-point */ - if (UNLIKELY(fabs(fabs(*p->fld[p->next_fld] - *p->fld[p->curr_fld]) - - 180.0) < 1.0)) - csound->Warning(csound, - "%s", Str("Warning: Ambiguous transition 180 degrees.\n")); - } - if (*p->field_am >= FL(0.0)) { /* point-to-point */ - if (p->dim == 3) { /* 3-D */ - p->prev_ang_dir.azi = *p->fld[p->curr_fld-1]; - p->next_ang_dir.azi = *p->fld[p->next_fld]; - p->prev_ang_dir.ele = *p->fld[p->curr_fld]; - p->next_ang_dir.ele = *p->fld[p->next_fld+1]; - coeff = ((MYFLT) p->point_change_counter) / - ((MYFLT) p->point_change_interval); - angle_to_cart( p->prev_ang_dir,&tmp1); - angle_to_cart( p->next_ang_dir,&tmp2); - tmp3.x = (FL(1.0)-coeff) * tmp1.x + coeff * tmp2.x; - tmp3.y = (FL(1.0)-coeff) * tmp1.y + coeff * tmp2.y; - tmp3.z = (FL(1.0)-coeff) * tmp1.z + coeff * tmp2.z; - coeff = (MYFLT)sqrt((double)(tmp3.x * tmp3.x + - tmp3.y * tmp3.y + - tmp3.z * tmp3.z)); - tmp3.x /= coeff; tmp3.y /= coeff; tmp3.z /= coeff; - cart_to_angle(tmp3,&(p->ang_dir)); - } - else if (p->dim == 2) { /* 2-D */ - p->prev_ang_dir.azi = *p->fld[p->curr_fld]; - p->next_ang_dir.azi = *p->fld[p->next_fld ]; - p->prev_ang_dir.ele = p->next_ang_dir.ele = FL(0.0); - scale_angles(&(p->prev_ang_dir)); - scale_angles(&(p->next_ang_dir)); - angle = (p->prev_ang_dir.azi - p->next_ang_dir.azi); - while (angle > FL(180.0)) - angle -= FL(360.0); - while (angle < -FL(180.0)) - angle += FL(360.0); - coeff = ((MYFLT) p->point_change_counter) / - ((MYFLT) p->point_change_interval); - angle *= (coeff); - p->ang_dir.azi = p->prev_ang_dir.azi - angle; - p->ang_dir.ele = FL(0.0); - } - else { - return csound->PerfError(csound, &(p->h), - "%s", Str("Missing fields in vbapzmove\n")); - } - } - else { /* angular velocities */ - if (p->dim == 2) { - p->ang_dir.azi = p->ang_dir.azi + - (*p->fld[p->next_fld] * CS_ONEDKR); - scale_angles(&(p->ang_dir)); - } - else { /* 3D angular */ - p->ang_dir.azi = p->ang_dir.azi + - (*p->fld[p->next_fld] * CS_ONEDKR); - p->ang_dir.ele = p->ang_dir.ele + - p->ele_vel * (*p->fld[p->next_fld+1] * CS_ONEDKR); - if (p->ang_dir.ele > FL(90.0)) { - p->ang_dir.ele = FL(90.0); - p->ele_vel = -p->ele_vel; - } - if (p->ang_dir.ele < FL(0.0)) { - p->ang_dir.ele = FL(0.0); - p->ele_vel = -p->ele_vel; - } - scale_angles(&(p->ang_dir)); - } - } - angle_to_cart(p->ang_dir, &(p->cart_dir)); - calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, - p->updated_gains, n, p->cart_dir); - if (*p->spread > FL(0.0)) { - if (p->dim == 3) { - spreaddirnum=16; - /* four orthogonal dirs */ - new_spread_dir(&spreaddir[0], p->cart_dir, - p->spread_base, p->ang_dir.azi, *p->spread); - - new_spread_base(spreaddir[0], p->cart_dir,*p->spread, &p->spread_base); - cross_prod(p->spread_base, p->cart_dir, &spreadbase[1]); - cross_prod(spreadbase[1], p->cart_dir, &spreadbase[2]); - cross_prod(spreadbase[2], p->cart_dir, &spreadbase[3]); - /* four between them */ - vec_mean(p->spread_base, spreadbase[1], &spreadbase[4]); - vec_mean(spreadbase[1], spreadbase[2], &spreadbase[5]); - vec_mean(spreadbase[2], spreadbase[3], &spreadbase[6]); - vec_mean(spreadbase[3], p->spread_base, &spreadbase[7]); - - /* four at half spreadangle */ - vec_mean(p->cart_dir, p->spread_base, &spreadbase[8]); - vec_mean(p->cart_dir, spreadbase[1], &spreadbase[9]); - vec_mean(p->cart_dir, spreadbase[2], &spreadbase[10]); - vec_mean(p->cart_dir, spreadbase[3], &spreadbase[11]); - - /* four at quarter spreadangle */ - vec_mean(p->cart_dir, spreadbase[8], &spreadbase[12]); - vec_mean(p->cart_dir, spreadbase[9], &spreadbase[13]); - vec_mean(p->cart_dir, spreadbase[10], &spreadbase[14]); - vec_mean(p->cart_dir, spreadbase[11], &spreadbase[15]); - - for (i=1;icart_dir, - spreadbase[i],p->ang_dir.azi,*p->spread); - calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, - tmp_gains, n, spreaddir[i]); - for (j=0;jupdated_gains[j] += tmp_gains[j]; - } - } - } - else if (p->dim == 2) { - spreaddirnum=6; - atmp.ele=FL(0.0); - atmp.azi=p->ang_dir.azi - *p->spread; - angle_to_cart(atmp, &spreaddir[0]); - atmp.azi=p->ang_dir.azi - *p->spread/2; - angle_to_cart(atmp, &spreaddir[1]); - atmp.azi=p->ang_dir.azi - *p->spread/4; - angle_to_cart(atmp, &spreaddir[2]); - atmp.azi=p->ang_dir.azi + *p->spread/4; - angle_to_cart(atmp, &spreaddir[3]); - atmp.azi=p->ang_dir.azi + *p->spread/2; - angle_to_cart(atmp, &spreaddir[4]); - atmp.azi=p->ang_dir.azi + *p->spread; - angle_to_cart(atmp, &spreaddir[5]); - - for (i=0;ils_set_am, p->dim, p->ls_sets, - tmp_gains, n, spreaddir[i]); - for (j=0;jupdated_gains[j] += tmp_gains[j]; - } - } - } - } - if (*p->spread > FL(70.0)) - for (i=0;iupdated_gains[i] += (*p->spread - FL(70.0))/FL(30.0) * - (*p->spread - FL(70.0))/FL(30.0)*FL(10.0); - } - /* normalization */ - for (i=0;iupdated_gains[i]*p->updated_gains[i]); - } - - sum = SQRT(sum); - for (i=0;iupdated_gains[i] /= sum; - } - return OK; -} - -int32_t vbap_zak_moving_init(CSOUND *csound, VBAP_ZAK_MOVING *p) -{ - int32_t i, j, indx; - MYFLT *ls_table, *ptr; - LS_SET *ls_set_ptr; - int32_t n = p->n; - p->n = (int32_t)MYFLT2LONG(*p->numb); /* Set size */ - /* Check to see this index is within the limits of za space. */ - MYFLT* zastart; - int zalast = csound->GetZaBounds(csound, &zastart); - indx = (int32) *p->ndx; - if (UNLIKELY(indx > zalast)) { - return csound->PerfError(csound, &(p->h), - "%s", Str("outz index > isizea. No output")); - } - else if (UNLIKELY(indx < 0)) { - return csound->PerfError(csound, &(p->h), - "%s", Str("outz index < 0. No output.")); - } - /* Now read from the array in za space and write to the output. */ - p->out_array = zastart + (indx * CS_KSMPS);/* outputs */ - csound->AuxAlloc(csound, p->n*sizeof(MYFLT)*4, &p->auxch); - p->curr_gains = (MYFLT*)p->auxch.auxp; - p->beg_gains = p->curr_gains + p->n; - p->end_gains = p->beg_gains + p->n; - p->updated_gains = p->end_gains + p->n; - /* reading in loudspeaker info */ - ls_table = (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, - "vbap_ls_table_0")); - p->dim = (int32_t) ls_table[0]; - p->ls_am = (int32_t) ls_table[1]; - p->ls_set_am = (int32_t) ls_table[2]; - ptr = &(ls_table[3]); - csound->AuxAlloc(csound, p->ls_set_am * sizeof (LS_SET), &p->aux); - if (UNLIKELY(p->aux.auxp == NULL)) { - return csound->InitError(csound, "%s", Str("could not allocate memory")); - } - p->ls_sets = (LS_SET*) p->aux.auxp; - ls_set_ptr = p->ls_sets; - for (i=0 ; i < p->ls_set_am ; i++) { - ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ - for (j=0 ; j < p->dim ; j++) { - ls_set_ptr[i].ls_nos[j] = (int32_t) *(ptr++); - } - memset(ls_set_ptr[i].ls_mx, '\0', 9*sizeof(MYFLT)); - /* for (j=0 ; j < 9; j++) */ - /* ls_set_ptr[i].ls_mx[j] = FL(0.0); /\* initial setting *\/ */ - for (j=0 ; j < (p->dim) * (p->dim); j++) { - ls_set_ptr[i].ls_mx[j] = (MYFLT) *(ptr++); - } - } - - /* other initialization */ - p->ele_vel = FL(1.0); /* functions specific to movement */ - if (UNLIKELY(fabs(*p->field_am) < (2+ (p->dim - 2)*2))) { - return csound->InitError(csound, - Str("Have to have at least %d directions in vbapzmove"), - 2 + (p->dim - 2) * 2); - } - if (p->dim == 2) - p->point_change_interval = (int32_t) (CS_EKR * *p->dur - / (fabs(*p->field_am) - 1.0)); - else if (LIKELY(p->dim == 3)) - p->point_change_interval = (int32_t) (CS_EKR * *p->dur - / (fabs(*p->field_am) * 0.5 - 1.0)); - else - return csound->InitError(csound, "%s", Str("Wrong dimension")); - p->point_change_counter = 0; - p->curr_fld = 0; - p->next_fld = 1; - p->ang_dir.azi = *p->fld[0]; - if (p->dim == 3) { - p->ang_dir.ele = *p->fld[1]; - } else { - p->ang_dir.ele = FL(0.0); - } - if (p->dim == 3) { - p->curr_fld = 1; - p->next_fld = 2; - } - angle_to_cart(p->ang_dir, &(p->cart_dir)); - p->spread_base.x = p->cart_dir.y; - p->spread_base.y = p->cart_dir.z; - p->spread_base.z = -p->cart_dir.x; - vbap_zak_moving_control(csound,p); - for (i=0;ibeg_gains[i] = p->updated_gains[i]; - p->end_gains[i] = p->updated_gains[i]; - } - return OK; -} +// code moved to vbap.c diff --git a/Opcodes/wave-terrain.c b/Opcodes/wave-terrain.c index a01b280ced0..180c9cb39f7 100644 --- a/Opcodes/wave-terrain.c +++ b/Opcodes/wave-terrain.c @@ -291,11 +291,11 @@ static int32_t scantPerf(CSOUND *csound, SCANTABLE *p) #define S(x) sizeof(x) static OENTRY localops[] = { - { "wterrain", S(WAVETER), TR, 3, "a", "kkkkkkii", + { "wterrain", S(WAVETER), TR, "a", "kkkkkkii", (SUBR)wtinit, (SUBR)wtPerf }, - { "scantable", S(SCANTABLE),TR, 3,"a", "kkiiiii", + { "scantable", S(SCANTABLE),TR, "a", "kkiiiii", (SUBR)scantinit,(SUBR)scantPerf}, - { "scanhammer",S(SCANHAMMER),TB, 1,"", "iiii", (SUBR)scanhinit, NULL, NULL } + { "scanhammer",S(SCANHAMMER),TB, "", "iiii", (SUBR)scanhinit, NULL, NULL } }; int32_t wave_terrain_init_(CSOUND *csound) diff --git a/Opcodes/wpfilters.c b/Opcodes/wpfilters.c index 450d1237ba8..4cfd1eea662 100644 --- a/Opcodes/wpfilters.c +++ b/Opcodes/wpfilters.c @@ -1057,21 +1057,21 @@ static int32_t k35_hpf_perf(CSOUND* csound, K35_HPF* p) { static OENTRY wpfilters_localops[] = { - { "zdf_1pole", sizeof(ZDF_1POLE), 0,3,"a","axOo", + { "zdf_1pole", sizeof(ZDF_1POLE), 0,"a","axOo", (SUBR)zdf_1pole_init,(SUBR)zdf_1pole_perf}, - { "zdf_1pole_mode", sizeof(ZDF_1POLE_MODE), 0,3,"aa","axo", + { "zdf_1pole_mode", sizeof(ZDF_1POLE_MODE), 0,"aa","axo", (SUBR)zdf_1pole_mode_init,(SUBR)zdf_1pole_mode_perf}, - { "zdf_2pole", sizeof(ZDF_2POLE), 0,3,"a","axxOo", + { "zdf_2pole", sizeof(ZDF_2POLE), 0,"a","axxOo", (SUBR)zdf_2pole_init,(SUBR)zdf_2pole_perf}, - { "zdf_2pole_mode", sizeof(ZDF_2POLE_MODE), 0,3,"aaa","axxo", + { "zdf_2pole_mode", sizeof(ZDF_2POLE_MODE), 0,"aaa","axxo", (SUBR)zdf_2pole_mode_init,(SUBR)zdf_2pole_mode_perf}, - { "zdf_ladder", sizeof(ZDF_LADDER), 0,3,"a","axxo", + { "zdf_ladder", sizeof(ZDF_LADDER), 0,"a","axxo", (SUBR)zdf_ladder_init,(SUBR)zdf_ladder_perf}, - { "diode_ladder", sizeof(DIODE_LADDER), 0,3,"a","axxOPo", + { "diode_ladder", sizeof(DIODE_LADDER), 0,"a","axxOPo", (SUBR)diode_ladder_init,(SUBR)diode_ladder_perf}, - { "K35_lpf", sizeof(K35_LPF), 0,3,"a","axxOPo", + { "K35_lpf", sizeof(K35_LPF), 0,"a","axxOPo", (SUBR)k35_lpf_init,(SUBR)k35_lpf_perf}, - { "K35_hpf", sizeof(K35_LPF), 0,3,"a","axxOPo",(SUBR) + { "K35_hpf", sizeof(K35_LPF), 0,"a","axxOPo",(SUBR) k35_hpf_init,(SUBR)k35_hpf_perf}, }; diff --git a/Opcodes/wterrain2.c b/Opcodes/wterrain2.c index 9a5c15481b2..f0791c8d837 100644 --- a/Opcodes/wterrain2.c +++ b/Opcodes/wterrain2.c @@ -225,7 +225,7 @@ static int32_t wtPerf(CSOUND *csound, WAVETER *p) #define S(x) sizeof(x) static OENTRY wter_localops[] = { - { "wterrain2", S(WAVETER), TR, 3, "a", "kkkkkkkkkkk", + { "wterrain2", S(WAVETER), TR, "a", "kkkkkkkkkkk", (SUBR)wtinit, (SUBR)wtPerf }, }; diff --git a/Opcodes/zak.c b/Opcodes/zak.c index 279326a360c..c50914a2ed6 100644 --- a/Opcodes/zak.c +++ b/Opcodes/zak.c @@ -720,21 +720,21 @@ int32_t zacl(CSOUND *csound, ZACL *p) #define S(x) sizeof(x) static OENTRY zak_localops[] = { - { "zakinit", S(ZAKINIT), ZB, 1, "", "ii", (SUBR)zakinit, NULL, NULL }, - { "zir", S(ZKR),ZR, 1, "i", "i", (SUBR)zir, NULL, NULL }, - { "zkr", S(ZKR),ZR, 3, "k", "k", (SUBR)zkset, (SUBR)zkr, NULL}, - { "ziw", S(ZKW),ZW, 1, "", "ii", (SUBR)ziw, NULL, NULL }, - { "zkw", S(ZKW), ZW, 3, "", "kk", (SUBR)zkset, (SUBR)zkw, NULL}, - { "ziwm", S(ZKWM), ZB, 1, "", "iip", (SUBR)ziwm, NULL, NULL }, - { "zkwm", S(ZKWM), ZB, 3, "", "kkp", (SUBR)zkset, (SUBR)zkwm, NULL}, - { "zkmod", S(ZKMOD), ZB, 3, "k", "kk", (SUBR)zkset, (SUBR)zkmod, NULL}, - { "zkcl", S(ZKCL), ZW, 3, "", "kk", (SUBR)zkset, (SUBR)zkcl, NULL }, - { "zar", S(ZAR),ZR, 3, "a", "k", (SUBR)zaset, (SUBR)zar }, - { "zarg", S(ZARG), ZB, 3, "a", "kk", (SUBR)zaset, (SUBR)zarg }, - { "zaw", S(ZAW), ZW, 3, "", "ak", (SUBR)zaset, (SUBR)zaw }, - { "zawm", S(ZAWM), ZB, 3, "", "akp", (SUBR)zaset, (SUBR)zawm }, - { "zamod", S(ZAMOD), ZB, 3, "a", "ak", (SUBR)zaset, (SUBR)zamod}, - { "zacl", S(ZACL), ZW, 3, "", "kJ", (SUBR)zaset, (SUBR)zacl} + { "zakinit", S(ZAKINIT), ZB, "", "ii", (SUBR)zakinit, NULL, NULL }, + { "zir", S(ZKR),ZR, "i", "i", (SUBR)zir, NULL, NULL }, + { "zkr", S(ZKR),ZR, "k", "k", (SUBR)zkset, (SUBR)zkr, NULL}, + { "ziw", S(ZKW),ZW, "", "ii", (SUBR)ziw, NULL, NULL }, + { "zkw", S(ZKW), ZW, "", "kk", (SUBR)zkset, (SUBR)zkw, NULL}, + { "ziwm", S(ZKWM), ZB, "", "iip", (SUBR)ziwm, NULL, NULL }, + { "zkwm", S(ZKWM), ZB, "", "kkp", (SUBR)zkset, (SUBR)zkwm, NULL}, + { "zkmod", S(ZKMOD), ZB, "k", "kk", (SUBR)zkset, (SUBR)zkmod, NULL}, + { "zkcl", S(ZKCL), ZW, "", "kk", (SUBR)zkset, (SUBR)zkcl, NULL }, + { "zar", S(ZAR),ZR, "a", "k", (SUBR)zaset, (SUBR)zar }, + { "zarg", S(ZARG), ZB, "a", "kk", (SUBR)zaset, (SUBR)zarg }, + { "zaw", S(ZAW), ZW, "", "ak", (SUBR)zaset, (SUBR)zaw }, + { "zawm", S(ZAWM), ZB, "", "akp", (SUBR)zaset, (SUBR)zawm }, + { "zamod", S(ZAMOD), ZB, "a", "ak", (SUBR)zaset, (SUBR)zamod}, + { "zacl", S(ZACL), ZW, "", "kJ", (SUBR)zaset, (SUBR)zacl} }; LINKAGE_BUILTIN(zak_localops) diff --git a/Top/argdecode.c b/Top/argdecode.c index 9ee2d071f2c..583a367aefb 100644 --- a/Top/argdecode.c +++ b/Top/argdecode.c @@ -1557,8 +1557,11 @@ PUBLIC int argdecode(CSOUND *csound, int argc, const char **argv_) break; } #endif - if (!decode_long(csound, s, argc, argv)) - csound->LongJmp(csound, 1); + if (!decode_long(csound, s, argc, argv)) + // shouldn't need to long jump here - + // - it's crashing if csoundSetOption fails + //csound->LongJmp(csound, 1); + csound->Message(csound,"\n ...ignoring \n"); while (*(++s)); break; case 'j': diff --git a/Top/csound.c b/Top/csound.c index 0526accbb5c..7bbfbb35e33 100644 --- a/Top/csound.c +++ b/Top/csound.c @@ -544,7 +544,6 @@ static const CSOUND cenviron_ = { csoundRegisterKeyboardCallback, csoundRemoveKeyboardCallback, csoundRegisterSenseEventCallback, - csoundRegisterDeinitCallback, csoundRegisterResetCallback, SetInternalYieldCallback, /* opcodes and instruments */ @@ -798,6 +797,7 @@ static const CSOUND cenviron_ = { NULL, NULL, NULL, + NULL, /*nxtdd*/ NULL, NULL, NULL, @@ -829,7 +829,6 @@ static const CSOUND cenviron_ = { FL(0.0), FL(0.0), FL(0.0), NULL, {FL(0.0), FL(0.0), FL(0.0), FL(0.0)}, - NULL, NULL,NULL, NULL, 0, @@ -1692,7 +1691,7 @@ inline static int nodePerf(CSOUND *csound, int index, int numThreads) /* In case of jumping need this repeat of opstart */ opstart->insdshead->pds = opstart; csound->op = opstart->optext->t.opcod; - (*opstart->opadr)(csound, opstart); /* run each opcode */ + (*opstart->perf)(csound, opstart); /* run each opcode */ opstart = opstart->insdshead->pds; } csound->mode = 0; @@ -1726,7 +1725,7 @@ inline static int nodePerf(CSOUND *csound, int index, int numThreads) while ((opstart = opstart->nxtp) != NULL) { opstart->insdshead->pds = opstart; csound->op = opstart->optext->t.opcod; - (*opstart->opadr)(csound, opstart); /* run each opcode */ + (*opstart->perf)(csound, opstart); /* run each opcode */ opstart = opstart->insdshead->pds; } csound->mode = 0; @@ -1887,7 +1886,7 @@ int kperf_nodebug(CSOUND *csound) ip->actflg) { opstart->insdshead->pds = opstart; csound->op = opstart->optext->t.opcod; - error = (*opstart->opadr)(csound, opstart); /* run each opcode */ + error = (*opstart->perf)(csound, opstart); /* run each opcode */ opstart = opstart->insdshead->pds; } csound->mode = 0; @@ -1923,7 +1922,7 @@ int kperf_nodebug(CSOUND *csound) opstart->insdshead->pds = opstart; csound->op = opstart->optext->t.opcod; //csound->ids->optext->t.oentry->opname; - error = (*opstart->opadr)(csound, opstart); /* run each opcode */ + error = (*opstart->perf)(csound, opstart); /* run each opcode */ opstart = opstart->insdshead->pds; } csound->mode = 0; @@ -1989,7 +1988,7 @@ static inline void opcode_perf_debug(CSOUND *csound, } opstart->insdshead->pds = opstart; csound->mode = 2; - (*opstart->opadr)(csound, opstart); /* run each opcode */ + (*opstart->perf)(csound, opstart); /* run each opcode */ opstart = opstart->insdshead->pds; csound->mode = 0; } @@ -3274,7 +3273,6 @@ static CS_NOINLINE int opcode_list_new_oentry(CSOUND *csound, head = cs_hash_table_get(csound, csound->opcodes, shortName); entryCopy = csound->Malloc(csound, sizeof(OENTRY)); - //printf("%p\n", entryCopy); memcpy(entryCopy, ep, sizeof(OENTRY)); entryCopy->useropinfo = NULL; @@ -3294,11 +3292,10 @@ static CS_NOINLINE int opcode_list_new_oentry(CSOUND *csound, PUBLIC int csoundAppendOpcode(CSOUND *csound, const char *opname, int dsblksiz, int flags, - int thread, const char *outypes, - const char *intypes, - int (*iopadr)(CSOUND *, void *), - int (*kopadr)(CSOUND *, void *), - int (*aopadr)(CSOUND *, void *)) + const char *outypes, const char *intypes, + int (*init)(CSOUND *, void *), + int (*perf)(CSOUND *, void *), + int (*deinit)(CSOUND *, void *)) { OENTRY tmpEntry; int err; @@ -3306,12 +3303,11 @@ PUBLIC int csoundAppendOpcode(CSOUND *csound, tmpEntry.opname = (char*) opname; tmpEntry.dsblksiz = (uint16) dsblksiz; tmpEntry.flags = (uint16) flags; - tmpEntry.thread = (uint8_t) thread; tmpEntry.outypes = (char*) outypes; tmpEntry.intypes = (char*) intypes; - tmpEntry.iopadr = iopadr; - tmpEntry.kopadr = kopadr; - tmpEntry.aopadr = aopadr; + tmpEntry.init = init; + tmpEntry.perf = perf; + tmpEntry.deinit = deinit; err = opcode_list_new_oentry(csound, &tmpEntry); //add_to_symbtab(csound, &tmpEntry); if (UNLIKELY(err)) @@ -4146,37 +4142,13 @@ PUBLIC void **csoundGetRtPlayUserData(CSOUND *csound) return &(csound->rtPlay_userdata); } + typedef struct opcodeDeinit_s { void *p; int (*func)(CSOUND *, void *); void *nxt; } opcodeDeinit_t; -/** - * Register a function to be called at note deactivation. - * Should be called from the initialisation routine of an opcode. - * 'p' is a pointer to the OPDS structure of the opcode, and 'func' - * is the function to be called, with the same arguments and return - * value as in the case of opcode init/perf functions. - * The functions are called in reverse order of registration. - * Returns zero on success. - */ - -int csoundRegisterDeinitCallback(CSOUND *csound, void *p, - int (*func)(CSOUND *, void *)) -{ - INSDS *ip = ((OPDS*) p)->insdshead; - opcodeDeinit_t *dp = (opcodeDeinit_t*) malloc(sizeof(opcodeDeinit_t)); - - (void) csound; - if (UNLIKELY(dp == NULL)) - return CSOUND_MEMORY; - dp->p = p; - dp->func = func; - dp->nxt = ip->nxtd; - ip->nxtd = dp; - return CSOUND_SUCCESS; -} /** * Register a function to be called by csoundReset(), in reverse order @@ -4201,22 +4173,6 @@ int csoundRegisterResetCallback(CSOUND *csound, void *userData, return CSOUND_SUCCESS; } -/* call the opcode deinitialisation routines of an instrument instance */ -/* called from deact() in insert.c */ - -int csoundDeinitialiseOpcodes(CSOUND *csound, INSDS *ip) -{ - int err = 0; - - while (ip->nxtd != NULL) { - opcodeDeinit_t *dp = (opcodeDeinit_t*) ip->nxtd; - err |= dp->func(csound, dp->p); - ip->nxtd = (void*) dp->nxt; - free(dp); - } - return err; -} - /** * Returns the name of the opcode of which the data structure * is pointed to by 'p'. diff --git a/Top/opcode.c b/Top/opcode.c index e6370b01b22..1b2efdd27fd 100644 --- a/Top/opcode.c +++ b/Top/opcode.c @@ -86,7 +86,7 @@ PUBLIC int csoundNewOpcodeList(CSOUND *csound, opcodeListEntry **lstp) cnt++; #ifdef JPFF if (strchr(ep->intypes, 'x')) - printf("%s, type %d %s -> %s\n", ep->opname, ep->thread, + printf("%s, type %d %s -> %s\n", ep->opname, (ep->init && ep->perf ? 3 : ep->init ? 1 : 2) ep->intypes, ep->outypes); /* else if (ep->thread==5 */ /* printf("%s, type 6 %s -> %s\n", ep->opname, */ diff --git a/include/csdl.h b/include/csdl.h index 41d06549b9a..87aa64e9498 100644 --- a/include/csdl.h +++ b/include/csdl.h @@ -79,9 +79,9 @@ PUBLIC int csoundModuleInit(CSOUND *csound) err |= csound->AppendOpcode(csound, ep->opname, ep->dsblksiz, ep->thread, ep->outypes, ep->intypes, - (int (*)(CSOUND *, void *)) ep->iopadr, - (int (*)(CSOUND *, void *)) ep->kopadr, - (int (*)(CSOUND *, void *)) ep->aopadr); + (int (*)(CSOUND *, void *)) ep->init, + (int (*)(CSOUND *, void *)) ep->perf, + (int (*)(CSOUND *, void *)) ep->deinit); ep++; } return err; diff --git a/include/csound.h b/include/csound.h index c9c3b3908b7..18093063488 100644 --- a/include/csound.h +++ b/include/csound.h @@ -2120,11 +2120,11 @@ extern "C" { * Returns zero on success. */ PUBLIC int csoundAppendOpcode(CSOUND *, const char *opname, - int dsblksiz, int flags, int thread, + int dsblksiz, int flags, const char *outypes, const char *intypes, - int (*iopadr)(CSOUND *, void *), - int (*kopadr)(CSOUND *, void *), - int (*aopadr)(CSOUND *, void *)); + int (*init)(CSOUND *, void *), + int (*perf)(CSOUND *, void *), + int (*deinit)(CSOUND *, void *)); /** @}*/ /** @defgroup THREADING Threading and concurrency diff --git a/include/csound.hpp b/include/csound.hpp index 40a7415193a..098d031b06d 100644 --- a/include/csound.hpp +++ b/include/csound.hpp @@ -604,13 +604,12 @@ class PUBLIC Csound csoundDisposeOpcodeList(csound, opcodelist); } virtual int AppendOpcode(const char *opname, int dsblksiz, int flags, - int thread, const char *outypes, const char *intypes, int (*iopadr)(CSOUND *, void *), int (*kopadr)(CSOUND *, void *), int (*aopadr)(CSOUND *, void *)) { - return csoundAppendOpcode(csound, opname, dsblksiz, flags, thread, + return csoundAppendOpcode(csound, opname, dsblksiz, flags, outypes, intypes, iopadr, kopadr, aopadr); } virtual void SetYieldCallback(int (*yieldCallback_)(CSOUND *)) diff --git a/include/csoundCore.h b/include/csoundCore.h index 493cc7c540f..2836f09d16b 100644 --- a/include/csoundCore.h +++ b/include/csoundCore.h @@ -317,12 +317,11 @@ typedef struct CORFIL { char *opname; uint16 dsblksiz; uint16 flags; - uint8_t thread; char *outypes; char *intypes; - int32_t (*iopadr)(CSOUND *, void *p); - int32_t (*kopadr)(CSOUND *, void *p); - int32_t (*aopadr)(CSOUND *, void *p); + int32_t (*init)(CSOUND *, void *p); + int32_t (*perf)(CSOUND *, void *p); + int32_t (*deinit)(CSOUND *, void *p); void *useropinfo; /* user opcode parameters */ } OENTRY; @@ -541,6 +540,8 @@ typedef struct CORFIL { struct opds * nxti; /* Chain of performance-time opcodes */ struct opds * nxtp; + /* Chain of deinit opcodes */ + struct opds * nxtd; /* Next allocated instance */ struct insds * nxtinstance; /* Previous allocated instance */ @@ -595,8 +596,6 @@ typedef struct CORFIL { /* user defined opcode I/O buffers */ void *opcod_iobufs; void *opcod_deact, *subins_deact; - /* opcodes to be run at note deactivation */ - void *nxtd; uint32_t ksmps_offset; /* ksmps offset for sample accuracy */ uint32_t no_end; /* samps left at the end for sample accuracy (calculated) */ @@ -647,10 +646,14 @@ typedef int32_t (*SUBR)(CSOUND *, void *); struct opds * nxti; /** Next opcode in perf-time chain */ struct opds * nxtp; + /** Next opcode in deinit chain */ + struct opds * nxtd; /** Initialization (i-time) function pointer */ - SUBR iopadr; + SUBR init; /** Perf-time (k- or a-rate) function pointer */ - SUBR opadr; + SUBR perf; + /** deinit function pointer */ + SUBR deinit; /** Orch file template part for this opcode */ OPTXT *optext; /** Owner instrument instance data structure */ @@ -661,6 +664,7 @@ typedef int32_t (*SUBR)(CSOUND *, void *); OPDS h; OPDS *prvi; OPDS *prvp; + OPDS *prvd; } LBLBLK; typedef struct { @@ -1361,8 +1365,6 @@ typedef struct _message_queue_t_ { int (*func)(void *, void *, unsigned int)); int (*RegisterSenseEventCallback)(CSOUND *, void (*func)(CSOUND *, void *), void *userData); - int (*RegisterDeinitCallback)(CSOUND *, void *p, - int32_t (*func)(CSOUND *, void *)); int (*RegisterResetCallback)(CSOUND *, void *userData, int32_t (*func)(CSOUND *, void *)); void (*SetInternalYieldCallback)(CSOUND *, @@ -1371,10 +1373,11 @@ typedef struct _message_queue_t_ { /** @name Opcodes and instruments */ /**@{ */ int (*AppendOpcode)(CSOUND *, const char *opname, int dsblksiz, int flags, - int thread, const char *outypes, const char *intypes, - int32_t (*iopadr)(CSOUND *, void *), - int32_t (*kopadr)(CSOUND *, void *), - int32_t (*aopadr)(CSOUND *, void *)); + const char *outypes, const char *intypes, + int (*init)(CSOUND *, void *), + int (*perf)(CSOUND *, void *), + int (*deinit)(CSOUND *, void *)); + int (*AppendOpcodes)(CSOUND *, const OENTRY *opcodeList, int n); char *(*GetOpcodeName)(void *p); INSTRTXT **(*GetInstrumentList)(CSOUND *); diff --git a/include/plugin.h b/include/plugin.h index 973c40f5ed3..b056a9bf961 100644 --- a/include/plugin.h +++ b/include/plugin.h @@ -182,12 +182,6 @@ class Csound : CSOUND { return (const INSDS *) GetMidiChannel(p)->kinsptr; } - /** deinit registration for a given plugin class - */ - template void plugin_deinit(T *p) { - RegisterDeinitCallback(this, (void *)p, deinit); - } - /** Csound memory allocation - malloc style */ void *malloc(size_t size) { return Malloc(this, size); } @@ -901,6 +895,10 @@ template struct InPlug : OPDS { */ int init() { return OK; } + /** deinit function placeholder + */ + int deinit() { return OK; } + /** k-rate function placeholder */ int kperf() { return OK; } @@ -996,7 +994,7 @@ template struct InPlug : OPDS { /** check if this opcode runs at init time */ bool is_init() { - return this->iopadr ? true : false; + return this->init ? true : false; } /** check if this opcode runs at perf time @@ -1026,6 +1024,10 @@ template struct Plugin : OPDS { */ int init() { return OK; } + /** deinit function placeholder + */ + int deinit() { return OK; } + /** k-rate function placeholder */ int kperf() { return OK; } @@ -1128,13 +1130,13 @@ template struct Plugin : OPDS { /** check if this opcode runs at init time */ bool is_init() { - return this->iopadr ? true : false; + return (this->init != NULL); } /** check if this opcode runs at perf time */ bool is_perf() { - return this->opadr ? true : false; + return (this->perf != NULL); } }; @@ -1157,6 +1159,16 @@ template int init(CSOUND *csound, T *p) { return p->init(); } +/** + @private + opcode thread function template (deinit) +*/ +template int deinit(CSOUND *csound, T *p) { + p->csound = (Csound *)csound; + return p->deinit(); +} + + /** @private opcode thread function template (k-rate) @@ -1184,15 +1196,14 @@ int plugin(Csound *csound, const char *name, const char *oargs, const char *iargs, uint32_t thr, uint32_t flags = 0) { CSOUND *cs = (CSOUND *)csound; if(thr == thread::ia || thr == thread::a) { - thr = thr == thread::ia ? 3 : 2; - return cs->AppendOpcode(cs, (char *)name, sizeof(T), flags, thr, + return cs->AppendOpcode(cs, (char *)name, sizeof(T), flags, (char *)oargs, (char *)iargs, (SUBR)init, - (SUBR)aperf, NULL); + (SUBR)aperf, (SUBR)deinit); } else - return cs->AppendOpcode(cs, (char *)name, sizeof(T), flags, thr, + return cs->AppendOpcode(cs, (char *)name, sizeof(T), flags, (char *)oargs, (char *)iargs, (SUBR)init, - (SUBR)kperf, NULL); + (SUBR)kperf, (SUBR)deinit); } /** plugin registration function template @@ -1203,16 +1214,15 @@ int plugin(Csound *csound, const char *name, uint32_t thr, uint32_t flags = 0) { CSOUND *cs = (CSOUND *)csound; if(thr == thread::ia || thr == thread::a) { - thr = thr == thread::ia ? 3 : 2; - return cs->AppendOpcode(cs, (char *)name, sizeof(T), flags, thr, + return cs->AppendOpcode(cs, (char *)name, sizeof(T), flags, (char *)T::otypes, (char *)T::itypes, (SUBR)init, - (SUBR)aperf, NULL); + (SUBR)aperf, (SUBR)deinit); } else - return cs->AppendOpcode(cs, (char *)name, sizeof(T), flags, thr, + return cs->AppendOpcode(cs, (char *)name, sizeof(T), flags, (char *)T::otypes, (char *)T::itypes, (SUBR)init, - (SUBR)kperf, NULL); + (SUBR)kperf, (SUBR)deinit); } diff --git a/tests/c/csound_orc_semantics_test.cpp b/tests/c/csound_orc_semantics_test.cpp index bb8b2520c51..2feaedc9003 100644 --- a/tests/c/csound_orc_semantics_test.cpp +++ b/tests/c/csound_orc_semantics_test.cpp @@ -86,14 +86,14 @@ TEST_F (OrcSemanticsTest, ResolveOpcodeTest) entries = find_opcode2(csound, "pcauchy"); opc = resolve_opcode(csound, entries, "i", "k"); - ASSERT_TRUE (opc->iopadr != NULL); + ASSERT_TRUE (opc->init != NULL); opc = resolve_opcode(csound, entries, "k", "k"); - ASSERT_TRUE (opc->kopadr != NULL); + ASSERT_TRUE (opc->perf != NULL); // TODO this test is failing // opc = resolve_opcode(csound, entries, "a", "k"); - // ASSERT_TRUE (opc->aopadr != NULL); + // ASSERT_TRUE (opc->aperf != NULL); csound->Free(csound, entries); } diff --git a/util/mkdb.c b/util/mkdb.c index 19b9279843d..e2ce1e5b843 100644 --- a/util/mkdb.c +++ b/util/mkdb.c @@ -118,12 +118,11 @@ typedef struct oentry { char *opname; uint16_t dsblksiz; uint16_t flags; - uint8_t thread; char *outypes; char *intypes; - int (*iopadr)(void *, void *p); - int (*kopadr)(void *, void *p); - int (*aopadr)(void *, void *p); + int (*init)(void *, void *p); + int (*perf)(void *, void *p); + int (*deinit)(void *, void *p); void *useropinfo; /* user opcode parameters */ } OENTRY;