[Csnd] Ability to change array values in a recursive udo

Hello everybody!

I’m wondering if it’s possible to change the values in a recursive udo durring performance time.

To be clearer:
i have a recursive udo, which gets a k-array as input.
on base of this array it creates it’s recursive instances.

outside of the udo i want to morph with linlin between two arrays to change the input array for the udo.

but i get only silence. so i guess, this is not working.
or am i doing something wrong?

greetings
philipp

heres is my code

opcode square_batterie,a,k[]o
  kSpectrum[],iIndex xin
  iLenArr = lenarray(kSpectrum)
  
  kFreqs[],kAmps[] deinterleave kSpectrum

  aSig vco2 kAmps[iIndex],kFreqs[iIndex],10
  
  if iIndex+1 < iLenArr/2 then
    aSig += square_batterie(kSpectrum,iIndex+1)
  endif

  /* output */
  aOut = aSig/(iLenArr/2)
  xout aOut
endop

instr 1
  #include "square_batterie-kSpectrum1.txt"
  #include "square_batterie-kSpectrum2.txt"

  kMorph line 0,p3,1
  kSpectrum[] linlin kMorph,kSpectrum1,kSpectrum2

  aSig square_batterie kSpectrum
  aSig1,aSig2 hilbert aSig

  aOut1 = aSig1
  aOut2 = aSig2
  outs aOut1,aOut2
endin
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

You can use poly for that, your opcode would be reduced to:

aSigs[] poly lenarray:i(kAmps), "vco2", kAmps, kFreqs, 10
aSig = sumarray(aSigs)

Csound mailing list Send bugs reports to Discussions of bugs and features can be posted here

Sorry, where can i find the documentation for the „Poly" opcode? it’s also not in the list of opcode when i do „csound -z“ in the terminal.
Belongs this to a package?

It is an external, see the docs at poly - Csound Plugins

You can install externals manually (take a look at Installation - Csound Plugins) or use risset (GitHub - csound-plugins/risset: Csound Package Manager)

Also, regarding your initial question about arrays in UDOs, I think the array will be copied into the UDO when it is called. That would also mean that your recursive UDO call would copy the array again and again (someone correct me if I’ve misunderstood this). It would not be the most effective way, I think. Perhaps if you can keep the array out of the UDO and just iterate it would be less complicated.

Øyvind

ons. 6. mars 2024 kl. 20:28 skrev Philipp Neumann <philipp@von-neumann.com>:

Sorry, where can i find the documentation for the „Poly" opcode? it’s also not in the list of opcode when i do „csound -z“ in the terminal.
Belongs this to a package?

You can use poly for that, your opcode would be reduced to:

aSigs poly lenarray:i(kAmps), “vco2”, kAmps, kFreqs, 10
aSig = sumarray(aSigs)

Hello everybody!

I’m wondering if it’s possible to change the values in a recursive udo durring performance time.

To be clearer:
i have a recursive udo, which gets a k-array as input.
on base of this array it creates it’s recursive instances.

outside of the udo i want to morph with linlin between two arrays to change the input array for the udo.

but i get only silence. so i guess, this is not working.
or am i doing something wrong?

greetings
philipp

heres is my code

opcode square_batterie,a,ko
kSpectrum,iIndex xin
iLenArr = lenarray(kSpectrum)

kFreqs,kAmps deinterleave kSpectrum

aSig vco2 kAmps[iIndex],kFreqs[iIndex],10

if iIndex+1 < iLenArr/2 then
aSig += square_batterie(kSpectrum,iIndex+1)
endif

/* output */
aOut = aSig/(iLenArr/2)
xout aOut
endop

instr 1
#include “square_batterie-kSpectrum1.txt”
#include “square_batterie-kSpectrum2.txt”

kMorph line 0,p3,1
kSpectrum linlin kMorph,kSpectrum1,kSpectrum2

aSig square_batterie kSpectrum
aSig1,aSig2 hilbert aSig

aOut1 = aSig1
aOut2 = aSig2
outs aOut1,aOut2
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

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

Thanks, Eduardo!

It’s running fine!

Oh cool, I didn’t know about poly. This seems like something that would be really helpful to have in the core. (though presumably that has been considered by people who know a lot more about the situation than me…)

iain

Au contraire, code living outside of the core distribution can be updated more often and can be used with older versions of csound, as long as the plugin API does not change. These external plugins, for example, are compatible with csound back to 6.16. All fixes are available via risset as soon as the CI task finishes compilation, without needing to compile csound yourself.