Csound Csound-dev Csound-tekno Search About

[Cs-dev] Bug in p()

Date2006-12-13 20:31
FromAnthony Kozar
Subject[Cs-dev] Bug in p()
The p() function seems to be buggy.  It prints the index of the pfield
rather than its value:

int pfun(CSOUND *csound, PFUN *p)
{
    int n = (int)(*p->pnum + FL(0.5));
    MYFLT ans;
    csound->Message(csound, "p(%d) %f\n", n,*p->pnum);
    if (n<1 || n>PMAX) ans = FL(0.0);
    else ans = csound->currevent->p[n];
    *p->ans = ans;
    return OK;
}

The code should probably be something like this instead:


int pfun(CSOUND *csound, PFUN *p)
{
    int n = (int)(*p->pnum + FL(0.5));
    MYFLT ans;
    if (n<1 || n>PMAX) ans = FL(0.0);
    else ans = csound->currevent->p[n];
    csound->Message(csound, "p(%d) %f\n", n, ans);
    *p->ans = ans;
    return OK;
}



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2006-12-14 09:39
Fromjpff
SubjectRe: [Cs-dev] Bug in p()
Surely pfun should not print anything.  Looks more like soem debugging
information left in.
==John ffitch

>>>>> "Anthony" == Anthony Kozar  writes:

 Anthony> The p() function seems to be buggy.  It prints the index of the pfield
 Anthony> rather than its value:

 Anthony> int pfun(CSOUND *csound, PFUN *p)
 Anthony> {
 Anthony>     int n = (int)(*p->pnum + FL(0.5));
 Anthony>     MYFLT ans;
 Anthony>     csound-> Message(csound, "p(%d) %f\n", n,*p->pnum);
 Anthony>     if (n<1 || n>PMAX) ans = FL(0.0);
 Anthony>     else ans = csound->currevent->p[n];
 Anthony>     *p->ans = ans;
 Anthony>     return OK;
 Anthony> }

 Anthony> The code should probably be something like this instead:


 Anthony> int pfun(CSOUND *csound, PFUN *p)
 Anthony> {
 Anthony>     int n = (int)(*p->pnum + FL(0.5));
 Anthony>     MYFLT ans;
 Anthony>     if (n<1 || n>PMAX) ans = FL(0.0);
 Anthony>     else ans = csound->currevent->p[n];
 Anthony>     csound-> Message(csound, "p(%d) %f\n", n, ans);
 Anthony>     *p->ans = ans;
 Anthony>     return OK;
 Anthony> }




-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2006-12-14 13:50
FromAnthony Kozar
SubjectRe: [Cs-dev] Bug in p()
Could be.  I thought it was annoying myself.

But the manual does say that p() "Shows the value in a given p-field."

The new opcode pindex allows retrieving any pfield without printing a
message.  But I don't think that it can be called as a function.

Anthony

jpff wrote on 12/14/06 4:39 AM:

> Surely pfun should not print anything.  Looks more like soem debugging
> information left in.
> ==John ffitch


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net