aboutsummaryrefslogtreecommitdiff
path: root/include/effects_global.inc
blob: c7657434e2887e076e2485dac057832a7abd8d7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#ifndef INC_GLOBALEFFECTS_INSTR
#define INC_GLOBALEFFECTS_INSTR ##
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

	Partial Emergence
		by Richard Knight 2022

	Installation submission for the International Csound Conference 2022

	Global effects

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */


/*
	Reverb
*/
instr global_reverb1
	aL, aR bus_read "reverb1"
	aL, aR freeverb aL, aR, 0.8, 0.6
	bus_mix("master", aL, aR)
endin


/*
	Delay 1
*/
instr global_delay1
	aL, aR bus_read "delay1"
	;aL *= abs(oscil(1, 1))
	;aR *= abs(oscil(1, 1))
	kfeedback = abs:k(oscil:k(0.5, 4)) + 0.2

	aLdlr delayr 0.8
	kdeltime = abs(oscil(0.02, 0.04)) + 0.1
	aLdel deltapi kdeltime + 0.002
	delayw aL + (aLdel * kfeedback)
	aRdlr delayr 0.8
	aRdel deltapi kdeltime + 0.001
	delayw aR + (aRdel * kfeedback)
	bus_mix("master", aLdel, aRdel)
endin


/*
	Delay 2
*/
instr global_delay2
	aL, aR bus_read "delay2"
	ifreq1 = 0.25
	kfdbkL = abs(oscil(0.8, 1.63))
	kfdbkR = abs(oscil(0.8, 1.67))

	atimeL = abs(oscil(0.2, ifreq1)) + 0.01
	atimeR = abs(oscil(0.2, ifreq1)) + 0.01

	aLdlr delayr 1
	aLdel deltapi atimeL
	aLdel butterhp aLdel, 130
	delayw aL + (aLdel * kfdbkL)

	aRdlr delayr 1
	aRdel deltapi atimeR
	aRdel butterhp aRdel, 130
	delayw aR + (aRdel * kfdbkR)

	bus_mix("master", aLdel, aRdel)
endin



/*
	Cyclical PVS sampler
*/
instr global_pvsamp1 
	aL, aR bus_read "pvsamp1"
	ir = 512
	iscales[] fillarray 0.25, 0.5, 1, 2, 4
	ksampling init 1
	ktime = timeinsts()
	ksamplestarttime init 0
	kplaystarttime init 0
	imaxlength = 6
	ksamplelength init random(2, imaxlength)
	kplaylength init random(2, imaxlength)
	krevsend init random(0, 0.4)
	kdotune init (random(0, 1) > 0.8) ? 1 : 0
	kdohpf init round(random(0, 1))
	khpfreq init random(100, 2000)
	kreadrate init random(0.005, 0.3)
	kscale init iscales[round(random(0, lenarray(iscales) - 1))]
	
	if (ksampling == 1) then
		fL1 pvsanal aL, ir, ir/4, ir, 1
		fR1 pvsanal aR, ir, ir/4, ir, 1
	
		ibufL, ktL pvsbuffer fL1, imaxlength
		ibufR, ktR pvsbuffer fR1, imaxlength

		if (ktime - ksamplestarttime >= ksamplelength) then
			ksampling = 0
			kplaylength = random:k(2, imaxlength*0.9)
			kplaystarttime = ktime
			kdohpf = round:k(random:k(0, 1))
			khpfreq = random:k(100, 2000)
			kdotune = (random:k(0, 1) > 0.8) ? 1 : 0
			krevsend = random:k(0, 0.6)
			kreadrate = random:k(0.005, 0.3)
			if (random:k(0, 1) >= 0.7) then
				kscale = iscales[round:k(random:k(0, lenarray(iscales) - 1))]
			endif
		endif
	endif

	if (ksampling == 0 && ktime - kplaystarttime >= kplaylength) then
		ksampling = 1
		ksamplestarttime = ktime
		ksamplelength = random:k(2, imaxlength)
	endif

	ktime = abs:k(oscil:k(1, kreadrate))

	kplaylengthp = port(kplaylength, 0.1)
	fL2 pvsbufread ktime*kplaylengthp, ibufL
	fR2 pvsbufread ktime*kplaylengthp, ibufR

	kscalep = port(kscale, 0.1)
	fL3 pvscale fL2, kscalep
	fR3 pvscale fR2, kscalep

	aL pvsynth fL3
	aR pvsynth fR3
	
	if (kdotune == 1) then
		aL, aR mel_tune_portamento aL*0.8, aR*0.8, gifnSine, 16, 1024, 4
	endif

	if (kdohpf == 1) then
		aL butterhp aL, khpfreq
		aR butterhp aR, khpfreq
	endif

	bus_mix("reverb1", aL*krevsend, aR*krevsend)
	bus_mix("master", aL, aR)
endin




#end