Skip to content

Commit 0bbcaf1

Browse files
author
joachimheintz
committed
more work on examples
1 parent 28be74a commit 0bbcaf1

File tree

8 files changed

+213
-464
lines changed

8 files changed

+213
-464
lines changed

learn/examples/fox.wav

237 KB
Binary file not shown.

learn/examples/pling.csd

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<CsoundSynthesizer>
2+
<CsOptions>
3+
-odac -m128
4+
</CsOptions>
5+
<CsInstruments>
6+
sr = 44100
7+
ksmps = 64
8+
nchnls = 2
9+
0dbfs = 1
10+
seed 0
11+
12+
// by joachim heintz
13+
14+
instr PlingStruct
15+
// generate one tone in a wide range between short/noisy and long/pitched
16+
aMode = mode(mpulse(ampdb(random:i(-22,0)),p3),mtof:i(random:i(80,100)),10^(p3-1))
17+
// distribute anywhere in the stereo field and output
18+
aL,aR pan2 aMode,random:i(0,1)
19+
out(aL,aR)
20+
// call the next instance of this instrument
21+
schedule("PlingStruct",rnd:i(1),random:i(1,4))
22+
endin
23+
schedule("PlingStruct",0,3)
24+
25+
</CsInstruments>
26+
<CsScore>
27+
</CsScore>
28+
</CsoundSynthesizer>
29+
<bsbPanel>
30+
<label>Widgets</label>
31+
<objectName/>
32+
<x>100</x>
33+
<y>100</y>
34+
<width>320</width>
35+
<height>240</height>
36+
<visible>true</visible>
37+
<uuid/>
38+
<bgcolor mode="background">
39+
<r>240</r>
40+
<g>240</g>
41+
<b>240</b>
42+
</bgcolor>
43+
</bsbPanel>
44+
<bsbPresets>
45+
</bsbPresets>

learn/examples/vibes.csd

Lines changed: 78 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,97 @@
44
</CsOptions>
55
<CsInstruments>
66
7+
// by luis antunes pena, modified by joachim heintz
8+
79
sr = 44100
810
ksmps = 32
911
nchnls = 2
1012
0dbfs = 1
11-
seed 1
13+
seed 0
1214
15+
// load function tables
1316
giStrike = ftgen(1,0,256,1,"marmstk1.wav",0,0,0)
1417
giSine = ftgen(2,0,128,10,1)
1518
16-
garev1 init 0
17-
garev2 init 0
19+
// initialize globale reverb variables
20+
garev1,garev2 init 0,0
21+
22+
// custom function for random integer
23+
opcode RndInt,i,ii
24+
iMin,iMax xin
25+
xout int(random:i(iMin,iMax+.9999))
26+
endop
27+
28+
opcode RndInt,k,kk
29+
kMin,kMax xin
30+
xout int(random:k(kMin,kMax+.9999))
31+
endop
32+
33+
34+
// generate a 2-dimensional global array with the parameters of each section
35+
instr Params
36+
37+
gkAllParams[][] init 9,8
38+
gkAllParams = fillarray(-15,5,1, 110,110,5,5,4,
39+
-15,5,1, 55,220,4,5,6,
40+
-15,5,10,220,220,4,4,2,
41+
-15,5,10,220,220,3,5,3,
42+
-18,5,20,220, 55,2,8,7,
43+
-12,2,10, 55, 55,3,5,3,
44+
-9,6,30,330,330,2,3,2,
45+
-18,6,10,330,330,1,4,5,
46+
-18,2,10, 30, 20,4,8,6)
47+
48+
turnoff
49+
50+
endin
51+
schedule("Params",0,1)
1852
53+
// create one section
1954
instr MakeChord
20-
21-
idb = p4
22-
ifm = p5 ;repetition frequency
23-
itime = p6 ;phasor time
24-
ifreq1 = p7 ;base freq
25-
ifreq2 = p8
26-
iint1 = p9 ;interval in semitones (used for chords)
27-
iint2 = p10
28-
innotes = p11 ;number of notes in chord
55+
56+
gkArr[] init 8
57+
kDurs[] = fillarray(20,10,10,10,20,10,30,10,10) //durations of sections
58+
kTime init 0
59+
kCount init 0
60+
61+
// for each new section
62+
if kTime <= 0 then
63+
// go through all rows of gkAllParams, the select one row randomly
64+
kIndx = (kCount < 9) ? kCount : RndInt:k(0,8)
65+
// get time and row according to the count index
66+
kTime = kDurs[kIndx]
67+
gkArr = getrow(gkAllParams,kIndx)
68+
printks("Playing row %d for %d seconds\n",0,kIndx,kTime)
69+
kCount += 1
70+
endif
2971
3072
// slight irregularity in metro ticks
31-
kfm = randomi:k(ifm,ifm*1.05,1)
73+
kfm = randomi:k(gkArr[1],gkArr[1]*1.05,1)
3274
// frequency shift if ifreq1 != ifreq2
33-
kfreq = ifreq1 + phasor:k(1/itime) * (ifreq2-ifreq1)
75+
kfreq = gkArr[3] + phasor:k(1/gkArr[2]) * (gkArr[4]-gkArr[3])
3476
// generate chord for each metro tick
35-
schedkwhen(metro(kfm),0,0,"Chord",0,1/kfm,idb,iint1,iint2,innotes,kfreq)
77+
schedkwhen(metro(kfm),0,0,"Chord",0,1/gkArr[1],kfreq)
78+
79+
// count time (decrease like in a sandglass)
80+
kTime -= 1/kr
3681
3782
endin
83+
schedule("MakeChord",0,-1)
3884
39-
85+
// create one chord
4086
instr Chord
4187
42-
p3 *= random:i(1,3)
43-
iamp = ampdb(p4)
44-
iint1 = p5
45-
iint2 = p6
46-
innotes = p7
47-
ifreq = p8
88+
// get and adjust parameters
89+
p3 *= random:i(2,4)
90+
idb = i(gkArr,0)
91+
iamp = ampdb(idb)
92+
iint1 = i(gkArr,5)
93+
iint2 = i(gkArr,6)
94+
innotes = i(gkArr,7)
95+
ifreq = p4
4896
97+
// loop for number of notes in chord
4998
indx = 0
5099
while (indx < innotes) do
51100
@@ -61,6 +110,7 @@ instr Chord
61110
62111
endin
63112
113+
// create one tone with the vibes physical model
64114
instr Tone
65115
66116
iamp = p4
@@ -81,32 +131,24 @@ instr Tone
81131
82132
endin
83133
134+
// add reverb
84135
instr Reverb
136+
85137
arev1, arev2 reverbsc garev1, garev2, 0.85, sr/2
86-
out(arev1,arev2)
138+
out(arev1/2,arev2/2)
87139
clear(garev1,garev2)
140+
88141
endin
89142
schedule("Reverb",0,-1)
90143
91144
</CsInstruments>
92145
<CsScore>
93-
;;
94-
; amp[dB] metro[Hz] phasor[s] freq1 freq2 int1 int2 nnotes
95-
i1 0 20 -15 5 1 110 110 5 5 4
96-
i1 + 10 -15 . 1 55 220 4 5 6
97-
i1 30 10 -15 . 10 220 220 4 4 2
98-
i1 + 10 -15 . 10 220 220 3 5 3
99-
i1 + 20 -18 . 20 220 55 2 8 7
100-
i1 + 10 -12 2 10 55 55 3 5 3
101-
i1 71 30 -9 6 30 330 330 2 3 2
102-
i1 + 10 -18 6 10 330 330 1 4 5
103-
i1 + 9 -18 2 10 30 20 4 8 6
104-
105-
e
106146
107147
</CsScore>
108148
</CsoundSynthesizer>
109149

150+
151+
110152
<bsbPanel>
111153
<label>Widgets</label>
112154
<objectName/>

learn/examples/vibes1.csd

Lines changed: 0 additions & 128 deletions
This file was deleted.

0 commit comments

Comments
 (0)