Debian Codegraph @

src/Examples/FLOSS Manual Examples/05 Sound Modification/05G05_random_deviations.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 -odac -m128
4 </CsOptions>
5 <CsInstruments>
6 sr = 44100
7 ksmps = 32
8 nchnls = 2
9 0dbfs = 1
10
11 giSample ftgen 0, 0, 0, -1, "fox.wav", 0, 0, 1
12 giHalfSine ftgen 0, 0, 1024, 9, .5, 1, 0
13
14 instr Granulator
15 //standard input parameter
16 iSndTab = giSample
17 iSampleLen = ftlen(iSndTab)/sr
18 iStart = 0 ;sec
19 kPointerSpeed = 2/3
20 iGrainDur = 30 ;milliseconds
21 iTranspos = -100 ;cent
22 iVolume = -6 ;dB
23 iEnv = giHalfSine ;table with envelope
24 iPan = .5 ;panning 0-1
25 iDensity = 50 ;Hz (grains per second)
26 iDistribution = .5 ;0-1
27 //random deviations (for demonstration set to p-fields)
28 iPointerRndDev = p4 ;sec
29 iGrainDurRndDev = p5 ;percent
30 iTransposRndDev = p6 ;cent
31 iVolumeRndDev = p7 ;dB
32 iPanRndDev = p8 ;as in iPan
33 //perform
34 kPhasor = phasor:k(kPointerSpeed/iSampleLen,iStart/iSampleLen)
35 kTrig = metro(iDensity)
36 if kTrig==1 then
37 kPointer = kPhasor*iSampleLen + rnd31:k(iPointerRndDev,0)
38 kOffset = random:k(0,iDistribution/iDensity)
39 kGrainDurDiff = rnd31:k(iGrainDurRndDev,0) ;percent
40 kGrainDur = iGrainDur*2^(kGrainDurDiff/100) ;ms
41 kTranspos = cent(iTranspos+rnd31:k(iTransposRndDev,0))
42 kVol = iVolume+rnd31:k(iVolumeRndDev,0)
43 kPan = iPan+rnd31:k(iPanRndDev,0)
44 schedulek("Grain",kOffset,kGrainDur/1000,iSndTab,
45 iSampleLen,kPointer,kTranspos,kVol,iEnv,kPan)
46 endif
47 endin
48
49 instr Grain
50 //input parameters
51 iSndTab = p4
52 iSampleLen = p5
53 iStart = p6
54 iSpeed = p7
55 iVolume = p8 ;dB
56 iEnvTab = p9
57 iPan = p10
58 //perform
59 aEnv = poscil3:a(ampdb(iVolume),1/p3,iEnvTab)
60 aSound = poscil3:a(aEnv,iSpeed/iSampleLen,iSndTab,iStart/iSampleLen)
61 aL, aR pan2 aSound, iPan
62 out(aL,aR)
63 endin
64
65 </CsInstruments>
66 <CsScore>
67 t 0 40
68 ; Random Deviations: Pointer GrainDur Transp Vol Pan
69 ;RANDOM POINTER DEVIATIONS
70 i "Granulator" 0 2.7 0 0 0 0 0 ;normal pointer
71 i . 3 . 0.1 0 0 0 0 ;slight trembling
72 i . 6 . 1 0 0 0 0 ;chaotic jumps
73 ;RANDOM GRAIN DURATION DEVIATIONS
74 i . 10 . 0 0 0 0 0 ;no deviation
75 i . 13 . 0 100 0 0 0 ;100%
76 i . 16 . 0 200 0 0 0 ;200%
77 ;RANDOM TRANSPOSITION DEVIATIONS
78 i . 20 . 0 0 0 0 0 ;no deviation
79 i . 23 . 0 0 300 0 0 ;±300 cent maximum
80 i . 26 . 0 0 1200 0 0 ;±1200 cent maximum
81 ;RANDOM VOLUME DEVIATIONS
82 i . 30 . 0 0 0 0 0 ;no deviation
83 i . 33 . 0 0 0 6 0 ;±6 dB maximum
84 i . 36 . 0 0 0 12 0 ;±12 dB maximum
85 ;RANDOM PAN DEVIATIONS
86 i . 40 . 0 0 0 0 0 ;no deviation
87 i . 43 . 0 0 0 0 .1 ;±0.1 maximum
88 i . 46 . 0 0 0 0 .5 ;±0.5 maximum
89 </CsScore>
90 </CsoundSynthesizer>
91 ;example by joachim heintz