Csound Csound-dev Csound-tekno Search About

[Csnd-dev] passign and pset

Date2021-10-20 21:57
FromEduardo Moguillansky
Subject[Csnd-dev] passign and pset

Hi,

passign does not take pset defaults into consideration. I would like to fix this but the code is somewhat confusing to me. I think that the problem is that passign reads from init_event instead of using GetPFields. Is there any reason against using GetPFields?

int32_t pinit(CSOUND *csound, PINIT *p)
{
    int32_t n;
    int32_t    nargs = p->OUTOCOUNT;
    int32_t    pargs = csound->init_event->pcnt;
    int32_t    start = (int32_t)(*p->start);
    /* Should check that inits exist> */
    int32_t    k = (int32_t)(*p->end);
    MYFLT *p0 = 
    if (*p->end!=FL(0.0)) {
      if (k<pargs) pargs = k;
    }
    if (UNLIKELY(nargs>pargs))
      csound->Warning(csound, Str("More arguments than p fields"));
    pargs -= (int)*p->end;
    for (n=0; (n<nargs) && (n<=pargs-start); n++) {
      if (csound->ISSTRCOD(csound->init_event->p[n+start])) {
        ((STRINGDAT *)p->inits[n])->data =
          cs_strdup(csound, get_arg_string(csound, csound->init_event->p[n+start]));
        ((STRINGDAT *)p->inits[n])->size =
          strlen(((STRINGDAT *)p->inits[n])->data)+1;
      }
      else  *p->inits[n] = csound->init_event->p[n+start];
    }
    return OK;
}

Date2021-10-20 23:30
FromVictor Lazzarini
SubjectRe: [Csnd-dev] [EXTERNAL] [Csnd-dev] passign and pset
I don't think there is, maybe this was written before GetPfields was introduced.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 20 Oct 2021, at 21:57, Eduardo Moguillansky <eduardo.moguillansky@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

Hi,

passign does not take pset defaults into consideration. I would like to fix this but the code is somewhat confusing to me. I think that the problem is that passign reads from init_event instead of using GetPFields. Is there any reason against using GetPFields?

int32_t pinit(CSOUND *csound, PINIT *p)
{
    int32_t n;
    int32_t    nargs = p->OUTOCOUNT;
    int32_t    pargs = csound->init_event->pcnt;
    int32_t    start = (int32_t)(*p->start);
    /* Should check that inits exist> */
    int32_t    k = (int32_t)(*p->end);
    MYFLT *p0 = 
    if (*p->end!=FL(0.0)) {
      if (k<pargs) pargs = k;
    }
    if (UNLIKELY(nargs>pargs))
      csound->Warning(csound, Str("More arguments than p fields"));
    pargs -= (int)*p->end;
    for (n=0; (n<nargs) && (n<=pargs-start); n++) {
      if (csound->ISSTRCOD(csound->init_event->p[n+start])) {
        ((STRINGDAT *)p->inits[n])->data =
          cs_strdup(csound, get_arg_string(csound, csound->init_event->p[n+start]));
        ((STRINGDAT *)p->inits[n])->size =
          strlen(((STRINGDAT *)p->inits[n])->data)+1;
      }
      else  *p->inits[n] = csound->init_event->p[n+start];
    }
    return OK;
}

Date2021-10-20 23:39
FromJohn ff
SubjectRe: [Csnd-dev] [EXTERNAL] [Csnd-dev] passign and pset
It was

On 20 Oct 2021, at 23:31, Victor Lazzarini <victor.lazzarini@mu.ie> wrote:
I don't think there is, maybe this was written before GetPfields was introduced.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 20 Oct 2021, at 21:57, Eduardo Moguillansky <eduardo.moguillansky@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

Hi,

passign does not take pset defaults into consideration. I would like to fix this but the code is somewhat confusing to me. I think that the problem is that passign reads from init_event instead of using GetPFields. Is there any reason against using GetPFields?

int32_t pinit(CSOUND *csound, PINIT *p)
{
    int32_t n;
    int32_t    nargs = p->OUTOCOUNT;
    int32_t    pargs = csound->init_event->pcnt;
    int32_t    start = (int32_t)(*p->start);
    /* Should check that inits exist> */
    int32_t    k = (int32_t)(*p->end);
    MYFLT *p0 = 
    if (*p->end!=FL(0.0)) {
      if (k<pargs) pargs = k;
    }
    if (UNLIKELY(nargs>pargs))
      csound->Warning(csound, Str("More arguments than p fields"));
    pargs -= (int)*p->end;
    for (n=0; (n<nargs) && (n<=pargs-start); n++) {
      if (csound->ISSTRCOD(csound->init_event->p[n+start])) {
        ((STRINGDAT *)p->inits[n])->data =
          cs_strdup(csound, get_arg_string(csound, csound->init_event->p[n+start]));
        ((STRINGDAT *)p->inits[n])->size =
          strlen(((STRINGDAT *)p->inits[n])->data)+1;
      }
      else  *p->inits[n] = csound->init_event->p[n+start];
    }
    return OK;
}