Skip to content

Commit

Permalink
Merge 17ad0c2 into 9b8b0b1
Browse files Browse the repository at this point in the history
  • Loading branch information
1bpm committed Jul 27, 2019
2 parents 9b8b0b1 + 17ad0c2 commit 48dcc07
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions Opcodes/nlfilt.c
Expand Up @@ -39,6 +39,12 @@ typedef struct {
MYFLT *index;
} PFIELD;

typedef struct {
OPDS h;
STRINGDAT *ians;
MYFLT *index;
} PFIELDSTR;

typedef struct {
OPDS h;
MYFLT *inits[24];
Expand Down Expand Up @@ -230,10 +236,24 @@ int32_t pvalue(CSOUND *csound, PFIELD *p)
{
int32_t n = (int32_t)(*p->index);
if (UNLIKELY(csound->init_event==NULL || n<1 || n>csound->init_event->pcnt)) {
*p->ians = FL(0.0); /* For tidyness */
return NOTOK; /* Should this be an error?? */
return csound->InitError(csound, "invalid p field index");
}
*p->ians = csound->init_event->p[n];
return OK;
}

int32_t pvaluestr(CSOUND *csound, PFIELDSTR *p)
{
int32_t n = (int32_t)(*p->index);
if (UNLIKELY(csound->init_event==NULL || n<1 || n>csound->init_event->pcnt)) {
return csound->InitError(csound, "invalid p field index");
}

if (LIKELY(csound->ISSTRCOD(csound->init_event->p[n]))) {
p->ians->data = cs_strdup(csound,
get_arg_string(csound, csound->init_event->p[n]));
p->ians->size = strlen(p->ians->data) + 1;
}
return OK;
}

Expand Down Expand Up @@ -285,6 +305,7 @@ int32_t painit(CSOUND *csound, PAINIT *p)
static OENTRY localops[] = {
{ "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 },
Expand Down

0 comments on commit 48dcc07

Please sign in to comment.