[Csnd] Interpolated table access and its challenges
Date | 2024-03-06 21:34 |
From | "Jeanette C." |
Subject | [Csnd] Interpolated table access and its challenges |
Hey hey, I'm simply trying to read/calculate an interpolated value. I want to "rescale" a 0-1 input to a succession of 1/25, 1/12.5 and 1. So I created a table: iValueTab = ftgenonce(0, 0, 4, 2, .04, .08, 1, 1) No I can scan through that with an index between 0 and .5. This is all rather unintuitive: kIndex = line:k(0, p3, .5) kValue = tablei:k(kIndex, iValueTab, 1) I thought an index of at least 0-.75 would do the trick, but after index values of .5 the output is 1. Is there a more intuitive/numerically meaningful way to solve this issue? Best wishes and thanks, Jeanette -- * Website: http://juliencoder.de - for summer is a state of sound * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g * Audiobombs: https://www.audiobombs.com/users/jeanette_c * GitHub: https://github.com/jeanette-c Say hello to the girl that I am! <3 (Britney Spears) 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 | 2024-03-06 22:14 |
From | joachim heintz |
Subject | Re: [Csnd] Interpolated table access and its challenges |
yeah interesting --- i tried it and i see your point. i found two possible solutions. the first avoids to reach 1, in normalized reading. the second - adds one value to the table, and - multiplies the normalized index by the last raw index (here 2) for me this second solution looks better. but perhaps best is to put the three values in an array and write a UDO for linear interpolation? best - j instr 1 //normalized iVals = ftgen(0,0,3,-2,1/25,2/25,1) kIndx = linseg:k(0,1,0.999999) kValue = tablei:k(kIndx,iVals,1) printk(.1,kValue) endin schedule(1,0,1.1) instr 2 //raw indices iVals = ftgen(0,0,4,-2,1/25,2/25,1) kIndx = linseg:k(0,1,1) kIndx *= 2 kValue = tablei:k(kIndx,iVals) printk(.1,kValue) endin schedule(2,2,1.1) On 06/03/2024 22:34, Jeanette C. wrote: > Hey hey, > I'm simply trying to read/calculate an interpolated value. I want to > "rescale" a 0-1 input to a succession of 1/25, 1/12.5 and 1. So I > created a table: > iValueTab = ftgenonce(0, 0, 4, 2, .04, .08, 1, 1) > No I can scan through that with an index between 0 and .5. This is all > rather unintuitive: > kIndex = line:k(0, p3, .5) > kValue = tablei:k(kIndex, iValueTab, 1) > I thought an index of at least 0-.75 would do the trick, but after index > values of .5 the output is 1. > > Is there a more intuitive/numerically meaningful way to solve this issue? > > Best wishes and thanks, > > Jeanette > 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 | 2024-03-06 22:18 |
From | "Jeanette C." |
Subject | Re: [Csnd] Interpolated table access and its challenges |
Hi Joachim, thanks for your solutions. I think I'd prefer the first solution, but it's good to have the choice. Many thanks for investigating and chiming in! Best wishes, Jeanette Mar 6 2024, joachim heintz has written: > yeah interesting --- i tried it and i see your point. > i found two possible solutions. > the first avoids to reach 1, in normalized reading. > the second > - adds one value to the table, and > - multiplies the normalized index by the last raw index (here 2) > for me this second solution looks better. > but perhaps best is to put the three values in an array and write a UDO for > linear interpolation? > best - > j > > instr 1 //normalized > iVals = ftgen(0,0,3,-2,1/25,2/25,1) > kIndx = linseg:k(0,1,0.999999) > kValue = tablei:k(kIndx,iVals,1) > printk(.1,kValue) > endin > schedule(1,0,1.1) > > instr 2 //raw indices > iVals = ftgen(0,0,4,-2,1/25,2/25,1) > kIndx = linseg:k(0,1,1) > kIndx *= 2 > kValue = tablei:k(kIndx,iVals) > printk(.1,kValue) > endin > schedule(2,2,1.1) > > > > On 06/03/2024 22:34, Jeanette C. wrote: >> Hey hey, >> I'm simply trying to read/calculate an interpolated value. I want to >> "rescale" a 0-1 input to a succession of 1/25, 1/12.5 and 1. So I created >> a table: >> iValueTab = ftgenonce(0, 0, 4, 2, .04, .08, 1, 1) >> No I can scan through that with an index between 0 and .5. This is all >> rather unintuitive: >> kIndex = line:k(0, p3, .5) >> kValue = tablei:k(kIndex, iValueTab, 1) >> I thought an index of at least 0-.75 would do the trick, but after index >> values of .5 the output is 1. >> >> Is there a more intuitive/numerically meaningful way to solve this issue? >> >> Best wishes and thanks, >> >> Jeanette >> > > 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 > -- * Website: http://juliencoder.de - for summer is a state of sound * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g * Audiobombs: https://www.audiobombs.com/users/jeanette_c * GitHub: https://github.com/jeanette-c Say hello to the girl that I am! <3 (Britney Spears) 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 | 2024-03-07 00:07 |
From | Eduardo Moguillansky |
Subject | Re: [Csnd] Interpolated table access and its challenges |
kidx = linseg:k(0, p3, 1) kval = bpf:k(kidx, 0, 1/25, 0.5, 2/25, 1, 1) printks "kidx: %f, kval: %f\n", 0.01, kidx, kval On 06.03.24 22:34, Jeanette C. wrote:
Hey hey, |
Date | 2024-03-07 06:43 |
From | Victor Lazzarini |
Subject | Re: [Csnd] [EXTERNAL] Re: [Csnd] Interpolated table access and its challenges |
Wouldn't a table like this do the job with your original code? f1 0 1025 7 0.04 512 0.08 256 1 256 1 Prof. Victor Lazzarini Maynooth University Ireland > On 6 Mar 2024, at 22:18, Jeanette C. |
Date | 2024-03-07 10:39 |
From | "Jeanette C." |
Subject | Re: [Csnd] Interpolated table access and its challenges |
Hi Eduardo! Mar 7 2024, Eduardo Moguillansky has written: > kidx = linseg:k(0, p3, 1) > > kval = bpf:k(kidx, 0, 1/25, 0.5, 2/25, 1, 1) ... Many thanks. This is a great solution! Simple and straightforward. Best wishes, Jeanette -- * Website: http://juliencoder.de - for summer is a state of sound * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g * Audiobombs: https://www.audiobombs.com/users/jeanette_c * GitHub: https://github.com/jeanette-c Ain't no way I'll be lonely <3 (Britney Spears) 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 |