aboutsummaryrefslogtreecommitdiff
path: root/site/udo/fnml/transitional/base.udo
blob: ba40fbca9e2f1074d7ce6b261a1a201b55a7f929 (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
#ifndef UDO_FNML_TRANSITIONBASE
#define UDO_FNML_TRANSITIONBASE ##

instr fnm_transitionplayer
	if (gifirsttransition == 1) then
		StransInstrument = "fnm_trans5"
		gifirsttransition = 0
	else
		StransInstrument = arr_random(gSfnm_transitionitems)
	endif
	schedule StransInstrument, 0, 36000

	kreleasing init 0
	if (release:k() == 1 && kreleasing == 0) then
		turnoff2 StransInstrument, 0, 1
		kreleasing = 1
	endif
	aL, aR bus_read "fnm_transition"
	bus_mix("master", aL, aR)
endin

instr fnm_sectionplayer
	SnoteInstrument = arr_random(gSfnm_chorditems)
	SbassInstrument = arr_random(gSfnm_bassitems)
	SaugInstrument = arr_random(gSfnm_augmentitems)
	iplaybass = (random(0, 1) >= 0.44) ? 1 : 0
	iplayaugment = (random(0, 1) >= 0.34) ? 1 : 0


	if (random(0, 1) >= 0.5) then
		ifadeintime = random(0.1, 3)
	else
		ifadeintime = 0
	endif
	index = 0
	while (index < table:i(0, gimel_current_notes)) do
		inoteaugment = (random(0, 1) >= 0.7) ? 12 : 0
		schedule SnoteInstrument, 0, p3, table:i(index+1, gimel_current_notes) + inoteaugment, ifadeintime
		index += 1
	od
	if (iplaybass == 1) then
		ibassnoteindex = round(random(1, 3))
		schedule SbassInstrument, 0, p3, table:i(ibassnoteindex, gimel_current_notes) - 24
	endif
	if (iplayaugment == 1) then
		schedule SaugInstrument, 0, p3
	endif

	aL, aR bus_read "fnm_chordnote"
	if (random(0, 1) > 0.6) then
		aLc, aRc simplechorus aL, aR, 0.004, 0.001
		aL += aLc
		aR += aRc
	endif
	aL butterhp aL, 120
	aR butterhp aR, 120

	if (iplaybass == 1) then
		aLb, aRb bus_read "fnm_chordbass"
		aL += aLb
		aR += aRb
	endif

	if (iplayaugment == 1) then
		aLa, aRa bus_read "fnm_augment"
		aL += aLa
		aR += aRa
	endif

	kamp linseg 1, p3, 1, 0.1, 0
	aL *= kamp
	aR *= kamp

	kduck = port(gkduck, 0.1)
	aL *= (1 - kduck)
	aR *= (1 - kduck)
	bus_mix("master", aL*0.8, aR*0.8)

	kreleasing init 0
	if (release:k() == 1 && kreleasing == 0) then
		turnoff2 SnoteInstrument, 0, 1
		if (iplaybass == 1) then
			turnoff2 SbassInstrument, 0, 1
		endif
		if (iplayaugment == 1) then
			turnoff2 SaugInstrument, 0, 1
		endif
		kreleasing = 1
	endif
endin


instr fnm_sectionmanager
	gkmel_pause = 1
	
	ksectionstart init 0.01
	ksectionchange = 0
	ktransitioner = chnget:k("fnm_transition")
	kadvance = chnget:k("fnm_advance")
	krepeat = chnget:k("fnm_repeat")

	if (changed:k(ktransitioner) == 1) then
		if (ktransitioner == 0) then
			turnoff2 "fnm_transitionplayer", 0, 1
			if (random:k(0, 1) > 0.5) then ; have ultimate transition
				if (random:k(0, 1) > 0.5) then ; no other output during ultimate transition
					turnoff2 "fnm_sectionplayer", 0, 1
				endif
				gkutransitiontime = random:k(0.2, 1)
				schedulek("fnm_ultimatetransitionplayer", 0, gkutransitiontime)
				ksectionstart = gkutransitiontime
			else
				gkutransitiontime = 0
				ksectionstart = 0.01
			endif
			ksectionchange = 1
		else
			schedulek("fnm_transitionplayer", 0, 36000)
		endif
	endif

	if (ksectionchange == 1 || (changed:k(kadvance) == 1 && kadvance == 1) || (changed:k(krepeat) == 1 && krepeat == 1)) then
		if (krepeat == 1) then
			ksectionstart = 0
		endif
		turnoff2 "fnm_sectionplayer", 0, 1
		if (krepeat != 1) then
			gkmel_advance_trig = 1
		endif
		schedulek("fnm_sectionplayer", ksectionstart, 36000)
	endif

	kreleasing init 0
	if (release:k() == 1 && kreleasing == 0) then
		turnoff2 "fnm_sectionplayer", 0, 1
		kreleasing = 1
	endif

endin

#end