Debian Codegraph @

src/Examples/FLOSS Manual Examples/03 Csound Language/03G09_Recursive_UDO.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 </CsOptions>
4 <CsInstruments>
5 sr = 44100
6 ksmps = 32
7 nchnls = 2
8 0dbfs = 1
9
10 opcode Recursion, a, iip
11 ;input: frequency, number of partials, first partial (default=1)
12 ifreq, inparts, istart xin
13 iamp = 1/inparts/istart ;decreasing amplitudes for higher partials
14 if istart < inparts then ;if inparts have not yet reached
15 acall Recursion ifreq, inparts, istart+1 ;call another instance of this UDO
16 endif
17 aout oscils iamp, ifreq*istart, 0 ;execute this partial
18 aout = aout + acall ;add the audio signals
19 xout aout
20 endop
21
22 instr 1
23 amix Recursion 400, 8 ;8 partials with a base frequency of 400 Hz
24 aout linen amix, .01, p3, .1
25 outs aout, aout
26 endin
27
28 </CsInstruments>
29 <CsScore>
30 i 1 0 1
31 </CsScore>
32 </CsoundSynthesizer>
33 ;example by joachim heintz