Debian Codegraph @

examples/imagegetpixel-musical.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 ; Select audio/midi flags here according to platform
4 -odac ;;;realtime audio out
5 ;-iadc ;;;uncomment -iadc if realtime audio input is needed too
6 ; For Non-realtime ouput leave only the line below:
7 ; -o imagegetpixel-musical.wav -W ;;; for file output any platform
8 </CsOptions>
9 <CsInstruments>
10
11 sr = 44100
12 ksmps = 32
13 nchnls = 2
14 0dbfs = 1
15
16 #define TABLEN# 64#
17 giRtab ftgen 1, 0, $TABLEN, 10, 1
18 giGtab ftgen 2, 0, $TABLEN, 10, 1
19 giBtab ftgen 3, 0, $TABLEN, 10, 1
20
21 gisin ftgen 11, 0, 1024, 10, 1
22
23 giimg imageload "imageOpcode03.png"
24 giimgH, giimgW imagesize giimg
25
26 instr 1
27 kndx = 0
28
29 kyR oscili .5, .15, 11
30 kyR = (kyR + .5) * .999
31
32 kyG oscili .5, .25, 11
33 kyG = (kyG + .5) * .999
34
35 kyB oscili .5, .4, 11
36 kyB = (kyB + .5) * .999
37
38 ilen = 64
39 loop:
40 kR, k0, k1 imagegetpixel giimg, kndx / (ilen+1), kyR
41 k2, kG, k3 imagegetpixel giimg, kndx / (ilen+1), kyG
42 k4, k5, kB imagegetpixel giimg, kndx / (ilen+1), kyB
43
44 kRval = kR * 2 - 1
45 tabw kRval, kndx, giRtab
46
47 kGval = kG * 2 - 1
48 tabw kGval, kndx, giGtab
49
50 kBval = kB * 2 - 1
51 tabw kBval, kndx, giBtab
52
53 if kndx < ilen then
54 kndx = kndx + 1
55 kgoto loop
56 endif
57
58 iampgain = .3
59 kamp madsr 2, 0, 1, 3
60 kamp = kamp * iampgain
61 ifrq = cpspch(p4)
62
63 aR oscil3 kamp * kyG, ifrq, giRtab
64 aG oscil3 kamp * kyB * .8, ifrq * 2.01, giGtab
65 aB oscil3 kamp * kyR * .8, ifrq * 1.99, giBtab
66
67 aR butlp aR, 5000
68 aG butlp aG, 10000
69 aB butlp aB, 10000
70
71 asigL = (aR + aG)*.9 ; green Left channel
72 asigR = (aR + aB)*.9 ; blue Right channel & red in the middle
73
74 adelL comb asigL, 1, .25
75 asigL = asigL + adelL * .5
76 asigL dcblock asigL
77
78 adelR comb asigR, 1, .3
79 asigR = asigR + adelR * .5
80 asigR dcblock asigR
81
82 outs asigL, asigR
83
84 endin
85
86 </CsInstruments>
87 <CsScore>
88 i1 0 25 8.00
89 i. 5 20 8.02
90 i. 10 10 8.07
91 i. 15 10 8.09
92 i. 20 5 8.11
93
94 </CsScore>
95 </CsoundSynthesizer>