| Thank you both!
linlin is perfect! I didn’t find it in the manual while searching for a fitting opcode, thanks!
> Am 16.01.2024 um 00:36 schrieb Eduardo Moguillansky :
> 
> linlin can do exactly that, see the following form, where kA and kB are two arrays of the same shape and kx is the interpolation index
> kC[] linlin kx, kA[], kB[] [, kx0, kx1 ]
> 
> On 15.01.24 19:41, Philipp Neumann wrote:
>> Hello everybody!
>> 
>> I don’t know if this already exists as an opcode (i couldn’t find it), so i tried to do it as an recursive UDO for an actual project.
>> 
>> I want to morph/interpolate between two arrays.
>> This should happen between the values of the same index.
>> For example:
>> Array-1[0] = 0
>> Array-2[0] = 10
>> 
>> ResultArray[0] gives the interpolate numbers between 0 and 10 via indexing.
>> 
>> I thought i found the solution,
>> but the value accumulation is not working as expected and i get strange results.
>> 
>> Here is my code:
>> 
>> 
>> opcode morf_arrays,k[],ki[]i[]o
>> kIndex,iArray1[],iArray2[],iArrIndx xin
>> kArray[] init lenarray(iArray1)
>> 
>> iTable ftgen 0,0,0,-2,iArray1[iArrIndx],iArray2[iArrIndx]
>> kRes tablei kIndex,iTable
>> kArray[iArrIndx] = kRes
>> if iArrIndx < lenarray(iArray1)-1 then
>> kArray[] += morf_arrays(kIndex,iArray1,iArray2,iArrIndx+1)
>> endif
>> 
>> xout kArray
>> endop
>> 
>> 
>> 
>> instr 1
>> iSpectrArr1[] fillarray 1,1.0, 3,0.33, 5,0.2, 7,0.8, 24,0.9, 12,0.1
>> iSpectrArr2[] fillarray 2,1.0, 1,0.33, 50,0.2, 10,0.8, 24,0.9, 12,0.9
>> 
>> kMorphIndex line 0,p3,1
>> kSpectrArr[] morf_arrays kMorphIndex,iSpectrArr1,iSpectrArr2
>> 
>> printk 0.1,kSpectrArr[2]
>> endin
>> 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
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  |