Debian Codegraph @

examples/ATSsinnoi-2.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 -odac -d -m128
4 </CsOptions>
5 <CsInstruments>
6 ;example by joachim heintz (& Menno Knevel)
7 sr = 44100
8 ksmps = 32
9 nchnls = 2
10 0dbfs = 1
11
12 ires system_i 1,{{ atsa fox.wav fox.ats }} ; default settings
13
14 giSine ftgen 0, 0, 1024, 10, 1
15 gSfile = "fox.ats"
16 giNumParts ATSinfo gSfile, 3 ;overall number of partials
17 giDur ATSinfo gSfile, 7 ;duration
18 seed 0
19
20
21 instr PlayList
22 event_i "i", "PlayAll", 0, 1, 1, 0, .5 ;sine only, half speed
23 event_i "i", "PlayAll", giDur*2+1, 1, 0, 1, .5 ;noise only
24 event_i "i", "PlayAll", giDur*4+2, 1, .5, .5, .5 ;half sine, half noise
25 endin
26
27 instr PlayAll
28 iSinAmnt = p4 ;sinee amount (0-1)
29 iNzAmnt = p5 ;noise amount (0-1)
30 iSpeed = p6 ;speed
31 p3 = giDur/iSpeed
32 ktime line 0, giDur/iSpeed, giDur
33 prints "Resynthesizing all partials with tone = %.1f and noise = %.1f.\n", iSinAmnt, iNzAmnt
34 aOut ATSsinnoi ktime, iSinAmnt, iNzAmnt, 1, gSfile, giNumParts
35 outs aOut, aOut
36 endin
37
38 instr PlayBand
39 iOffset = p4 ;offset in partials
40 iSpeed = p5 ;speed
41 p3 = giDur/iSpeed
42 ktime line 0, giDur/iSpeed, giDur
43 prints "Resynthesizing partials %d to %d with related noise.\n", iOffset+1, iOffset+10
44 aOut ATSsinnoi ktime, 1, .3, 1, gSfile, 10, iOffset, 1 ; a bit less noise (.3)
45 outs aOut*2, aOut ; left channel a bit louder
46 ;call itself again
47 if iOffset < giNumParts - 20 then
48 event_i "i", "PlayBand", giDur/iSpeed+1, 1, iOffset+10, iSpeed
49 endif
50 endin
51
52 instr PlayWeighted
53 ;sine amount, noise amount and speeed are varying
54 kSinAmnt randomi 0, 1, 1, 3
55 kNzAmnt = 1-kSinAmnt
56 kSpeed randomi .01, .3, 1, 3
57 async init 0
58 atime, aEnd syncphasor kSpeed/giDur, async
59 kTrig metro 100
60 kEnd max_k aEnd, kTrig, 1 ;1 if phasor signal crosses zero
61 ktime downsamp atime
62 aOut ATSsinnoi ktime*giDur, kSinAmnt, kNzAmnt, 1, gSfile, giNumParts
63 outs aOut*.6, aOut ; pan a bit to the right
64 ;exit if file is at the end
65 if kEnd == 1 then
66 event "e", 0, 0
67 endif
68
69 endin
70
71 </CsInstruments>
72 <CsScore>
73 i "PlayList" 0 1
74 i "PlayBand" 20 1 0 .5
75 i "PlayWeighted" 110 100
76 </CsScore>
77 </CsoundSynthesizer>