{bit:magie}

Yet another csound code-file

Additive Synthesis

Additive Synthesis

The Sound

The Code

<CsoundSynthesizer>
<CsOptions>
;-odac -d
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

instr 1

k2hrm expseg 200,p3/2,234,p3/2,200
k3hrm expseg 300,p3/2,333,p3/2,300
k4hrm expseg 400,p3/2,376,p3/2,400
k5hrm expseg 500,p3/2,527,p3/2,500
k6hrm expseg 600,p3/2,609,p3/2,600
k7hrm expseg 700,p3/2,715,p3/2,700
k8hrm expseg 800,p3/2,853,p3/2,800

afund oscili .125 , 100  , 1
ahrm2 oscili .125 , k2hrm, 1
ahrm3 oscili .125 , k3hrm, 1
ahrm4 oscili .125 , k4hrm, 1
ahrm5 oscili .125 , k5hrm, 1
ahrm6 oscili .125 , k6hrm, 1
ahrm7 oscili .125 , k7hrm, 1
ahrm8 oscili .125 , k8hrm, 1

asig = afund + 
       ahrm2 + 
       ahrm3 + 
       ahrm4 + 
       ahrm5 + 
       ahrm6 + 
       ahrm7 + 
       ahrm8  
outs asig,asig
dispfft asig, 0.5, 1024 ;calculate spectrum
endin
instr 2

k2hrm2 expseg 200,p3/2,220,p3/2,200
k3hrm2 expseg 300,p3/2,320,p3/2,300
k4hrm2 expseg 400,p3/2,420,p3/2,400
k5hrm2 expseg 500,p3/2,520,p3/2,500
k6hrm2 expseg 600,p3/2,620,p3/2,600
k7hrm2 expseg 700,p3/2,720,p3/2,700
k8hrm2 expseg 800,p3/2,820,p3/2,800

afund2 oscili .125 , 100  , 1
ahrm22 oscili .125 , k2hrm2, 1
ahrm32 oscili .125 , k3hrm2, 1
ahrm42 oscili .125 , k4hrm2, 1
ahrm52 oscili .125 , k5hrm2, 1
ahrm62 oscili .125 , k6hrm2, 1
ahrm72 oscili .125 , k7hrm2, 1
ahrm82 oscili .125 , k8hrm2, 1
ahrm22b oscili .0625 , 200, 1
ahrm32b oscili .0625 , 300, 1
ahrm42b oscili .0625 , 400, 1
ahrm52b oscili .0625 , 500, 1
ahrm62b oscili .0625 , 600, 1
ahrm72b oscili .0625 , 700, 1
ahrm82b oscili .0625 , 800, 1

asig2 = afund2 + 
        ahrm22 + 
        ahrm32 + 
        ahrm42 + 
        ahrm52 + 
        ahrm62 + 
        ahrm72 + 
        ahrm82 + 
        ahrm22b + 
        ahrm32b + 
        ahrm42b + 
        ahrm52b + 
        ahrm62b + 
        ahrm72b + 
        ahrm82b   
outs asig2,asig2
dispfft asig2, 0.5, 1024 ;calculate spectrum
endin

instr 3
k2hrm expseg 200,p3/4,234,p3/4,244,p3/4,234,p3/4,200
k3hrm expseg 300,p3/4,333,p3/4,323,p3/4,333,p3/4,300
k4hrm expseg 400,p3/4,376,p3/4,386,p3/4,376,p3/4,400
k5hrm expseg 500,p3/4,527,p3/4,517,p3/4,527,p3/4,500
k6hrm expseg 600,p3/4,609,p3/4,619,p3/4,609,p3/4,600
k7hrm expseg 700,p3/4,715,p3/4,705,p3/4,715,p3/4,700
k8hrm expseg 800,p3/4,853,p3/4,863,p3/4,853,p3/4,800


k2hrm2 expseg 200,p3/4,234,p3/2,234,p3/4,200
k3hrm2 expseg 300,p3/4,333,p3/2,333,p3/4,300
k4hrm2 expseg 400,p3/4,376,p3/2,376,p3/4,400
k5hrm2 expseg 500,p3/4,527,p3/2,527,p3/4,500
k6hrm2 expseg 600,p3/4,609,p3/2,609,p3/4,600
k7hrm2 expseg 700,p3/4,715,p3/2,715,p3/4,700
k8hrm2 expseg 800,p3/4,853,p3/2,853,p3/4,800


afund2 oscili .125 , 100  , 1
ahrm2 oscili .0625 , k2hrm, 1
ahrm3 oscili .0625 , k3hrm, 1
ahrm4 oscili .0625 , k4hrm, 1
ahrm5 oscili .0625 , k5hrm, 1
ahrm6 oscili .0625 , k6hrm, 1
ahrm7 oscili .0625 , k7hrm, 1
ahrm8 oscili .0625 , k8hrm, 1
ahrm22 oscili .0625 , k2hrm2, 1
ahrm32 oscili .0625 , k3hrm2, 1
ahrm42 oscili .0625 , k4hrm2, 1
ahrm52 oscili .0625 , k5hrm2, 1
ahrm62 oscili .0625 , k6hrm2, 1
ahrm72 oscili .0625 , k7hrm2, 1
ahrm82 oscili .0625 , k8hrm2, 1

asig2 = afund2 + 
        ahrm22 + 
        ahrm32 + 
        ahrm42 + 
        ahrm52 + 
        ahrm62 + 
        ahrm72 + 
        ahrm82 +  
        ahrm2 + 
        ahrm3 + 
        ahrm4 + 
        ahrm5 + 
        ahrm6 + 
        ahrm7 + 
        ahrm8   
outs asig2,asig2
dispfft asig2, 0.5, 1024 ;calculate spectrum
endin


instr 4
k2hrm expseg 234,1,200,p3-1,200
k3hrm expseg 333,1,300,p3-1,300
k4hrm expseg 376,1,400,p3-1,400
k5hrm expseg 527,1,500,p3-1,500
k6hrm expseg 609,1,600,p3-1,600
k7hrm expseg 715,1,700,p3-1,700
k8hrm expseg 853,1,800,p3-1,800

kampodd linseg 0,.1,.4,.1,.2,2,.2,2,.7,p3-6.2,.5,2,0
kampeven linseg 0,.1,.4,.1,.2,2,.2,2,0,p3-6.2,.3,2,0

afund oscili kampeven, 100, 1
af oscili kampodd, 100,1
ahrm2 oscili kampeven,k2hrm,1
ahrm3 oscili kampodd,k3hrm,1
ahrm4 oscili kampeven,k4hrm,1
ahrm5 oscili kampodd,k5hrm,1
ahrm6 oscili kampeven,k6hrm,1
ahrm7 oscili kampodd,k7hrm,1
ahrm8 oscili kampeven,k8hrm,1

asig = afund +
       af +
       ahrm2 +
       ahrm3 +
       ahrm4 +
       ahrm5 +
       ahrm6 +
       ahrm7 +
       ahrm8
outs asig,asig
dispfft asig, 0.5, 1024 ;calculate spectrum
endin

</CsInstruments>
<CsScore>
f 1 0 4096 10 1

i 4 0 8

i 1 9 30
i 2 + .
i 3 + .
e
</CsScore>
</CsoundSynthesizer>