Csound Csound-dev Csound-tekno Search About

[Csnd] Recursive UDO Amplitudes

Date2024-06-28 18:33
FromPhilipp Neumann
Subject[Csnd] Recursive UDO Amplitudes
Hello Everybody!

I’m sitting now quite a while at a instrument and i don’t get it… my head is maybe not working perfectly right now.

But i have a few problems with recursive UDOs:
- it’s too loud. of course, you say. you are adding a lot of signals together. yes, i know. but i don’t get the right spot to make it quiter. And also i don’t get the right factor to make it quiter.
- when i change the order of my frequencies in my input kFreq array it’s also changing the sound. and i don’t get why.

Maybe someone can help :)

Philipp



opcode saw_voice, a, kkpp
  kAmp, kFreq, iDetune, iIndex xin

  if iIndex < iDetune then
    aDetune saw_voice kAmp, kFreq, iDetune, iIndex+1
  endif

  aSaw vco2 kAmp, kFreq + (random(-0.5,0.5)*randomi:k(kFreq*0.005, kFreq*0.01, 0.25, 1))

  aVoice sum aSaw, aDetune
  xout aVoice/iDetune
endop


opcode saw_array, a, kk[]po
  kAmp, kFreqs[], iDetune, iIndex  xin

  print iIndex
  iInstances lenarray kFreqs

  if iIndex < iInstances-1 then
    aVoice saw_array kAmp, kFreqs, iDetune, iIndex+1
  endif
  
  kAmp = kAmp 
  kFreq = kFreqs[iIndex]
  aSaw saw_voice kAmp, kFreq, iDetune, iIndex

  aOut sum aSaw, aVoice
  xout aOut
endop

instr 1
  // signal
  kAmp = 1
  kFreqs[] fillarray  65/2, 65*11,  65*17
  iDetune = 1
  aSaw saw_array kAmp, kFreqs, iDetune
  
  // amp env
  iAtt = 0.05
  iRel = iAtt
  iSusTime = p3 - (iAtt + iRel)
  aEnv linseg 0, iAtt, 1, iSusTime, 1, iRel, 0
  aSaw *= aEnv

  // output
  aOut1 = aSaw
  aOut2 = aSaw
  outs aOut1, aOut2
endin


i1 0 10



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

Date2024-06-28 20:14
FromEduardo Moguillansky
SubjectRe: [Csnd] Recursive UDO Amplitudes
The general structure for a recursive udo is to generate your part and then call the rest, adding it to your part. A good way to scale the signal is to divide by the sqrt of the number of instances, this scales better than dividing by the instances itself

opcode saw_voice, a, kkiio

kAmp, kFreq, iDetune, iWidth, iIndex xin

kFreq2 = kFreq * randomi:k(1 - iWidth, 1 + iWidth, 0.25, 1)

aout = vco2(kAmp, kFreq2)

if iIndex < iDetune - 1 then

aout += saw_voice(kAmp/sqrt(iDetune), kFreq, iDetune, iWidth, iIndex + 1)

endif

xout aout

endop



opcode saw_array, a, kk[]iio

kAmp, kFreqs[], iDetune, iWidth, iIndex xin

aout saw_voice kAmp, kFreqs[iIndex], iDetune, iWidth, iIndex

if iIndex < lenarray(kFreqs) - 1 then

aout += saw_array(kAmp/sqrt(lenarray(kFreqs)), kFreqs, iDetune, iWidth, iIndex+1)

endif

xout aout

endop




On Fri, Jun 28, 2024 at 7:33 PM Philipp Neumann <philipp@von-neumann.com> wrote:
Hello Everybody!

I’m sitting now quite a while at a instrument and i don’t get it… my head is maybe not working perfectly right now.

But i have a few problems with recursive UDOs:
- it’s too loud. of course, you say. you are adding a lot of signals together. yes, i know. but i don’t get the right spot to make it quiter. And also i don’t get the right factor to make it quiter.
- when i change the order of my frequencies in my input kFreq array it’s also changing the sound. and i don’t get why.

Maybe someone can help :)

Philipp



opcode saw_voice, a, kkpp
  kAmp, kFreq, iDetune, iIndex xin

  if iIndex < iDetune then
    aDetune saw_voice kAmp, kFreq, iDetune, iIndex+1
  endif

  aSaw vco2 kAmp, kFreq + (random(-0.5,0.5)*randomi:k(kFreq*0.005, kFreq*0.01, 0.25, 1))

  aVoice sum aSaw, aDetune
  xout aVoice/iDetune
endop


opcode saw_array, a, kk[]po
  kAmp, kFreqs[], iDetune, iIndex  xin

  print iIndex
  iInstances lenarray kFreqs

  if iIndex < iInstances-1 then
    aVoice saw_array kAmp, kFreqs, iDetune, iIndex+1
  endif

  kAmp = kAmp
  kFreq = kFreqs[iIndex]
  aSaw saw_voice kAmp, kFreq, iDetune, iIndex

  aOut sum aSaw, aVoice
  xout aOut
endop

instr 1
  // signal
  kAmp = 1
  kFreqs[] fillarray  65/2, 65*11,  65*17
  iDetune = 1
  aSaw saw_array kAmp, kFreqs, iDetune

  // amp env
  iAtt = 0.05
  iRel = iAtt
  iSusTime = p3 - (iAtt + iRel)
  aEnv linseg 0, iAtt, 1, iSusTime, 1, iRel, 0
  aSaw *= aEnv

  // output
  aOut1 = aSaw
  aOut2 = aSaw
  outs aOut1, aOut2
endin
</CsInstruments>
<CsScore>
i1 0 10
</CsScore>
</CsoundSynthesizer>

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