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
|
#ifndef UDO_FNMI_AUTOMEL
#define UDO_FNMI_AUTOMEL ##
#include "sequencing_table.udo"
#include "sequencing_melodic.udo"
#include "bussing.udo"
instr _play_fnmi_automel1
icollectionid = p4
Sbus = p5
ifreqmult = p6
inote = mel_randomnote()
if (random(0, 1) >= 0.5) then
inote += 12
endif
idowaveset = (random(0, 1) >= 0.8) ? 1 : 0
if (idowaveset == 1) then
if (random(0, 1) >= 0.6) then
p3 *= random(1.2, 1.8)
endif
endif
ifileid, ipitchratio sounddb_mel_nearestnote icollectionid, inote
ifn, ichannels, iduration, irmsnorm sounddb_get ifileid
ireadtype = round(random(0, 2))
if (ireadtype == 0) then
aL, aR loscil 1, ipitchratio * ifreqmult, ifn, 1
else
atime line 0, p3, iduration * random(0.5, 1)
if (ireadtype == 1) then
imincerfftsize = pow(2, round(random(8, 11)))
aL, aR mincer atime, random(0.7, 1.1), ipitchratio * ifreqmult, ifn, 0, imincerfftsize
elseif (ireadtype == 2) then
iwsize = random(441, 4410)
aL, aR sndwarpst 1, atime, ipitchratio * ifreqmult * (ftsr(ifn) / sr), ifn, 0, iwsize, iwsize * 0.1, 4, gifnHalfSine, 1
endif
endif
aamp linseg 1, p3*0.9, 1, p3*0.1, 0
if (random(0, 1) >= 0.6) then
aL, aR ringmod1 aL, aR, cpsmidinn(inote) * 2
endif
aL *= aamp
aR *= aamp
if (idowaveset == 1) then
kwaveseta line 0, p3, round(random(2, 5))
aL waveset aL, kwaveseta
aR waveset aR, kwaveseta
endif
if (random(0, 1) >= 0.7) then
aL distort aL, 0.5, gifnSine
aR distort aR, 0.5, gifnSine
aL *= 0.4
aR *= 0.4
endif
bus_mix(Sbus, aL, aR)
endin
/*
aL, aR automel1 icollectionid1, kchance=1, kdivisions=4, icollectionid2=icollectionid1, kfreqmult=1
*/
opcode automel1, aa, iVJjJ
icollectionid1, kchance, kdivisions, icollectionid2, kfreqmult xin
kdivisions = (kdivisions == -1) ? 4 : kdivisions
kfreqmult = (kfreqmult == -1) ? 1 : kfreqmult
kcollectionid init icollectionid1
Sbus = sprintf("fnmautomel%d", uniqueid())
ktrig seq_table gifn_tabseq_all, 0, 4, kchance
instrnum = nstrnum("_play_fnmi_automel1") + uniquefrac()
if (ktrig == 1 && active:k(instrnum) == 0) then
if (icollectionid2 != -1) then
if (random:k(0, 1) >= 0.5) then
kcollectionid = icollectionid1
else
kcollectionid = icollectionid2
endif
endif
schedulek(instrnum, 0, gkseq_quartertime * random:k(0.5, 4), kcollectionid, Sbus, kfreqmult)
endif
aL, aR bus_read Sbus
xout aL, aR
endop
#end
|