[Csnd] Administrivia
Date | 2020-05-01 04:27 |
From | "john,,," |
Subject | [Csnd] Administrivia |
Message for the May 2020 This is just a regular monthly reminder for the Csound list. The Csound list welcomes posts from people with ALL levels of skill, from the newest newbie to the most serious hacker or established composer. The subject and tenor of the posts varies dramatically depending on what the current concerns are. Newbies are sometimes afraid to post because they read discussions about the incomprehensible deep inner workings, and all they want to know is how to get a sound to come out of their computer, or advice on how to get mobile sounds. Rest assured that your questions will be answered quickly, and (usually) in a helpful and courteous manner. We have all been there. Please post. If you find a bug or want to request for a new feature for the csound library please report it here and/or open a ticket by going to https://github.com/csound/csound/issues Please note that front-ends and other csound-based systems (e.g blue, CsoundQt, Cabbage) have their own reporting schemes. The developers particularly love bug reports that say which platform, operating system and version (we are currently maintaining 6.14 while developing csound7) were involved and a simple test program. If you are thinking of submitting new code please read the Submission advice (Submitting_opcodes.md) and/or consult a core developer. ==List Administrator Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2020-05-12 01:49 |
From | David Bowen |
Subject | [Csnd] Bug in cpd2pch? |
I was looking at the code for cps2pch as a model for a possible oct2pch opcode and noticed what I think is a bug in the handling of the frequency table option.The relevant code is: int32_t cps2pch(CSOUND *csound, XENH *p) { double fract; double loct; fract = modf((double)*p->pc, &loct); /* Get octave */ if (*p->et > 0) { fract = pow(2.0, loct + (100.0*fract)/((double)*p->et)); *p->r = (MYFLT)(fract * 1.02197503906); /* Refer to base frequency */ } else { MYFLT t = - *p->et; FUNC* ftp = csound->FTnp2Finde(csound, &t); int32_t len; if (UNLIKELY(ftp == NULL)) return csound->PerfError(csound, &(p->h),Str("No tuning table %d"), -((int32_t)*p->et)); int32_t cps2pch(CSOUND *csound, XENH *p) { double fract; double loct; fract = modf((double)*p->pc, &loct); /* Get octave */ if (*p->et > 0) { fract = pow(2.0, loct + (100.0*fract)/((double)*p->et)); *p->r = (MYFLT)(fract * 1.02197503906); /* Refer to base frequency */ } else { MYFLT t = - *p->et; FUNC* ftp = csound->FTnp2Finde(csound, &t); int32_t len; if (UNLIKELY(ftp == NULL)) return csound->PerfError(csound, &(p->h),Str("No tuning table %d"), -((int32_t)*p->et)); len = ftp->flen; while (fract>len) { fract -= len; loct++; } fract += 0.005; *p->r = (MYFLT)(1.02197503906 * *(ftp->ftable +(int32_t)(100.0*fract)) * pow(2.0, loct)); } /* double ref = 261.62561 / pow(2.0, 8.0); */ return OK; } } /* double ref = 261.62561 / pow(2.0, 8.0); */ return OK; } I believe the intent of the while loop is to handle the case where the pitch class is larger than the number of elements in the frequency table by incrementing the octave number and reducing the pitch class until the class is in the table range. However, fract is still a number between 0 and 1, so the while will always short circuit and then csound will access outside the table range. I think the corrected code should look something like this: len = ftp->flen; fract *= 100.0; while (fract>len) { fract -= len; loct++; } fract += 0.5; *p->r = (MYFLT)(1.02197503906 * *(ftp->ftable +(int32_t)fract) * pow(2.0, loct)); David Bowen |
Date | 2020-05-12 17:44 |
From | john |
Subject | Re: [Csnd] Bug in cpd2pch? |
Culd you provie an exampleinut that would fail? I cannot see te prolem yet o please enlighten me. ==John ff On Mon, 11 May 2020, David Bowen wrote: > I was looking at the code for cps2pch as a model for a possible oct2pch opcode > and noticed what I think is a bug in the handling of the frequency table > option.The relevant code is: > > int32_t cps2pch(CSOUND *csound, XENH *p) > { > double fract; > double loct; > > fract = modf((double)*p->pc, &loct); /* Get octave */ > if (*p->et > 0) { > fract = pow(2.0, loct + (100.0*fract)/((double)*p->et)); > *p->r = (MYFLT)(fract * 1.02197503906); /* Refer to base frequency */ > } > else { > MYFLT t = - *p->et; > FUNC* ftp = csound->FTnp2Finde(csound, &t); > int32_t len; > if (UNLIKELY(ftp == NULL)) > return csound->PerfError(csound, &(p->h),Str("No tuning table %d"), > -((int32_t)*p->et)); > int32_t cps2pch(CSOUND *csound, XENH *p) > { > double fract; > double loct; > > fract = modf((double)*p->pc, &loct); /* Get octave */ > if (*p->et > 0) { > fract = pow(2.0, loct + (100.0*fract)/((double)*p->et)); > *p->r = (MYFLT)(fract * 1.02197503906); /* Refer to base frequency */ > } > else { > MYFLT t = - *p->et; > FUNC* ftp = csound->FTnp2Finde(csound, &t); > int32_t len; > if (UNLIKELY(ftp == NULL)) > return csound->PerfError(csound, &(p->h),Str("No tuning table %d"), > -((int32_t)*p->et)); > len = ftp->flen; > while (fract>len) { > fract -= len; loct++; > } > fract += 0.005; > *p->r = (MYFLT)(1.02197503906 * *(ftp->ftable +(int32_t)(100.0*fract)) * > pow(2.0, loct)); > } > > /* double ref = 261.62561 / pow(2.0, 8.0); */ > return OK; > } } > > /* double ref = 261.62561 / pow(2.0, 8.0); */ > return OK; > } > > I believe the intent of the while loop is to handle the case where the pitch > class is larger than the number of elements in the frequency table by > incrementing the octave number and reducing the pitch class until the class is > in the table range. However, fract is still a number between 0 and 1, so the > while will always short circuit and then csound will access outside the table > range. I think the corrected code should look something like this: > > len = ftp->flen; > fract *= 100.0; > while (fract>len) { > fract -= len; loct++; > } > fract += 0.5; > *p->r = (MYFLT)(1.02197503906 * *(ftp->ftable +(int32_t)fract) * > pow(2.0, loct)); > > David Bowen > > Csound mailing list Csound@listserv.heanet.ie > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to > https://github.com/csound/csound/issues Discussions of bugs and features can > be posted here > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2020-05-12 20:12 |
From | David Bowen |
Subject | Re: [Csnd] Bug in cpd2pch? |
John, I think this qualifies as an example: <CsoundSynthesizer> <CsOptions> -odac </CsOptions> <CsInstruments> sr = 44100 kr = 441 nchnls = 1 instr 1 ipch cps2pch p4, p5 print ipch endin </CsInstruments> <CsScore> f 1 0 16 -2 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 i 1 0 1 8.02 -1 i 1 1 1 8.12 -1 e 2 </CsScore> </CsoundSynthesizer> The second print shows ipch = 0.00 whereas I would expect it to show ipch twice the value in the first print. David Bowen On Tue, May 12, 2020 at 11:44 AM john <jpff@codemist.co.uk> wrote: Culd you provie an exampleinut that would fail? I cannot see te prolem |
Date | 2020-05-12 20:18 |
From | Pete Goodeve |
Subject | Re: [Csnd] Bug in cpd2pch? |
Attachments | None |
Date | 2020-05-12 20:37 |
From | David Bowen |
Subject | Re: [Csnd] Bug in cpd2pch? |
Pete, cpspch treats pch values like 8.15 as if it were 9.03. I'm assuming cps2pch is trying to duplicate that behavior. The simple multiply to get the index would work if we didn't allow this special case, but I believe the while loop is there to handle it, but the logic isn't quite right. Dave Bowen On Tue, May 12, 2020 at 2:18 PM Pete Goodeve <pete.goodeve@computer.org> wrote: On Tue, May 12, 2020 at 05:44:08PM +0100, john wrote: |
Date | 2020-05-12 20:37 |
From | Pete Goodeve |
Subject | Re: [Csnd] Bug in cpd2pch? |
Attachments | None |
Date | 2020-05-12 20:59 |
From | john |
Subject | Re: [Csnd] Bug in cpd2pch? |
I would expect to see zero i te second print as the table i 16 long anf you look at the 12 value which is empty; i also note the same problem exists in cpsxpch If I chage yor 16 fr 10 it works in my version. Will commit soon. Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2020-05-12 21:13 |
From | Pete Goodeve |
Subject | Re: [Csnd] Bug in cpd2pch? |
Attachments | None |