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
|
#ifndef UDO_TRANSITION_CLICK
#define UDO_TRANSITION_CLICK ##
#include "sequencing_scheduled.udo"
#include "sequencing_melodic_portamento.udo"
#include "uniqueid.udo"
#include "bussing.udo"
#include "sounddb.udo"
gifnmt_clickfn[] sounddb_getcollection "Snare.Regular,Hihat.Closed"
instr fnmt_clickplay
istartbeats = p4 ; number of beats before next event point as specified in iwaitmode
iwaitmode = p5 ; -1 = start of next bar, -2 = start of next bargroup , any other = number of total beats before event point
iampmode = p6 ; 0 = linear, 1 = exponential, 2 = random (randomises each individually)
idorelease = p7 ; do release, 0 or 1
idotune = p8 ; do tuning, 0 or 1
idorandom = p9 ; do random sound selection for each click
Sbus = strget(p10) ; bus to send to ; defaults to "main"
SonHit = strget(p11) ; instrument to call when hit point is reached
if (strcmp(Sbus, "") == 0) then
Sbus = "main"
endif
p3 = 600
if (iwaitmode == -1) then
kwaittrig = bar_lastbeatxof(istartbeats)
elseif (iwaitmode == -2) then
kwaittrig = bargroup_lastbeatxof(istartbeats)
else
kwaittrig = lastbeatxof(iwaitmode, istartbeats)
endif
if (kwaittrig == 1) then
schedulek "_fnmt_clickplay", 0, i(gkseq_beattime) * istartbeats, iampmode, idorelease, idotune, idorandom, Sbus, SonHit
turnoff
endif
endin
instr _fnmt_clickplay
imode = p4 ; 0 = linear, 1 = exponential, 2 = random (randomises each individually)
idorelease = p5
idotune = p6
idorandom = p7
Sbus = p8
SonHit = p9
ichannelid = uniqueid()
ibeattime = i(gkseq_beattime)
itempo = i(gkseq_tempo)
ireltime = (idorelease == 1) ? random(ibeattime, ibeattime*4) : 0
imtime = p3
ibeathz = itempo / 60
if (strcmp(SonHit, "") != 0) then
schedule(SonHit, imtime, 1)
endif
if (imode == 0 || (imode == 2 && random(0, 1) >= 0.5)) then
kfreq linsegr ibeathz * round(random(4, 16)), imtime, ibeathz * round(random(4, 16)), ireltime, ibeathz * round(random(4, 16))
else
kfreq expsegr ibeathz * round(random(4, 16)), imtime, ibeathz * round(random(4, 16)), ireltime, ibeathz * round(random(4, 16))
endif
iminpitch = 6
imaxpitch = 20
if (imode == 0 || (imode == 2 && random(0, 1) >= 0.5)) then
kpitch linsegr random(iminpitch, imaxpitch), imtime, random(iminpitch, imaxpitch), ireltime, random(iminpitch, imaxpitch)
else
kpitch expsegr random(iminpitch, imaxpitch), imtime, random(iminpitch, imaxpitch), ireltime, random(iminpitch, imaxpitch)
endif
if (imode == 0 || (imode == 2 && random(0, 1) >= 0.5)) then
kpan linsegr random(0, 1), imtime, random(0, 1), ireltime, random(0, 1)
else
kpan expsegr random(0.0001, 1), imtime, random(0.0001, 1), ireltime, random(0.0001, 1)
endif
if (imode == 0 || (imode == 2 && random(0, 1) >= 0.5)) then
kamp linsegr 0, p3, 1, ireltime, 0
else
kamp expsegr 0.0001, imtime, 1, ireltime, 0.0001
endif
if (idorandom == 1) then
ifn = -1
ichans = -1
idur = 1
else
ifileid = gifnmt_clickfn[round(random(0, lenarray(gifnmt_clickfn) - 1))]
ifn = gisounddb[ifileid][0]
ichans = gisounddb[ifileid][1]
idur = gisounddb[ifileid][2]
endif
kmetro metro kfreq
if (kmetro == 1) then
schedulek "_fnmt_clickitem", 0, idur / kpitch, ifn, kamp, kpitch, kpan, ichannelid, ichans
endif
aL, aR bus_read sprintf("fnmt_click%d", ichannelid)
if (idotune == 1) then
aL, aR mel_tune_portamento aL, aR, 0, 2
endif
bus_mix(Sbus, aL, aR)
endin
instr _fnmt_clickitem
ifn = p4
iamp = p5
ipitch = p6
ipan = p7
ichannelid = p8
ichans = p9
if (ifn == -1) then ; random sound
ifileid = gifnmt_clickfn[round(random(0, lenarray(gifnmt_clickfn) - 1))]
ifn = gisounddb[ifileid][0]
ichans = gisounddb[ifileid][1]
p3 = gisounddb[ifileid][2] / ipitch
endif
if (ichans == 2) then
a1, a_ loscil iamp, ipitch, ifn, 1
else
a1 loscil iamp, ipitch, ifn, 1
endif
aL, aR pan2 a1, ipan
bus_mix(sprintf("fnmt_click%d", ichannelid), aL, aR)
endin
#end
|