-
Notifications
You must be signed in to change notification settings - Fork 1
/
Olbos_Custom_Functions.tidal
122 lines (120 loc) · 12.1 KB
/
Olbos_Custom_Functions.tidal
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
--- useful shortcuts ---
let degBy = degradeBy --same as Guiot's functions for compatibility
somBy = sometimesBy
someBy = sometimesBy
sBy = sometimesBy
dBy = degradeBy
sile = silence
rotl n p = (n <~) $ p --courtesy of Guiot
rotr n p = (n ~>) $ p --courtesy of Guiot
shiftl = rotl --same as Guiot for compatibility
shiftr = rotr --same as Guiot for compatibility
stop = (const $ s "~") -- a convenient way to stop a pattern
gtfo = (const $ s "~")
bpm x = cps (x/120) -- utility for direct bpm setting
ev = every
evry = every
eve = every
jrevby x = juxBy x (rev)
jrevBy = jrevby
jrby = jrevby
jrev = jux (rev)
panr = pan rand
superimp = superimpose
simpose = superimpose
supimp = superimpose
spose = superimpose
sWith = stutWith
swith = stutWith
stutW = stutWith
stutw = stutWith
-- plyW = plyWith --not sure why it doesn't work
-- plyw = plyWith
slo = slow
fa = fast
accel = accelerate
xlr8 = accelerate
strct = struct
struc = struct
---------
--- Composite functions ------
transup n p = (|+ note n) $ p --courtesy of Guiot
transdown n p = (|- note n) $ p --courtesy of Guiot
degRange x y = degBy (range x y $ rand)
wchoose pairs = choose $ concatMap (\x -> replicate (fst x) (snd x)) pairs -- weighted choose with the syntax wchoose [(2,'a'),(1,'b')] <- not sure who wrote this function
---------
--SIEVES--- implementation of the Xenakis' technique for pattern generation
restogen value offset amount = [if (x `mod` value) == 0 then 1 else 0 | x <- [(0 + offset)..(amount + offset)]]
gen x y z = restogen x y z
sieveor val1 off1 val2 off2 d = listToPat $ [if (gen val1 off1 d !! x) == 1 || (gen val2 off2 d !! x) == 1 then True else False | x <- [0..d-1]]
sieveinvor val1 off1 val2 off2 d = listToPat $ [if (gen val1 off1 d !! x) == 1 || (gen val2 off2 d !! x) == 1 then False else True | x <- [0..d-1]]
sieveoror val1 off1 val2 off2 val3 off3 d = listToPat $ [if (gen val1 off1 d !! x) == 1 || (gen val2 off2 d !! x) == 1 || (gen val3 off3 d !! x) == 1 then True else False | x <- [0..d-1]]
sieveinvoror val1 off1 val2 off2 val3 off3 d = listToPat $ [if (gen val1 off1 d !! x) == 1 || (gen val2 off2 d !! x) == 1 || (gen val3 off3 d !! x) == 1 then False else True | x <- [0..d-1]]
sieveand val1 off1 val2 off2 d = listToPat $ [if (gen val1 off1 d !! x) == 1 && (gen val2 off2 d !! x) == 1 then True else False | x <- [0..d-1]]
sieveinvand val1 off1 val2 off2 d = listToPat $ [if (gen val1 off1 d !! x) == 1 && (gen val2 off2 d !! x) == 1 then False else True | x <- [0..d-1]]
sieveandand val1 off1 val2 off2 val3 off3 d = listToPat $ [if (gen val1 off1 d !! x) == 1 && (gen val2 off2 d !! x) == 1 && (gen val3 off3 d !! x) == 1 then True else False | x <- [0..d-1]]
sieveinvandand val1 off1 val2 off2 val3 off3 d = listToPat $ [if (gen val1 off1 d !! x) == 1 && (gen val2 off2 d !! x) == 1 && (gen val3 off3 d !! x) == 1 then False else True | x <- [0..d-1]]
sieveorand val1 off1 val2 off2 val3 off3 d = listToPat $ [if (gen val1 off1 d !! x) == 1 || (gen val2 off2 d !! x) == 1 && (gen val3 off3 d !! x) == 1 then True else False | x <- [0..d-1]]
sieveinvorand val1 off1 val2 off2 val3 off3 d = listToPat $ [if (gen val1 off1 d !! x) == 1 || (gen val2 off2 d !! x) == 1 && (gen val3 off3 d !! x) == 1 then False else True | x <- [0..d-1]]
sieveandor val1 off1 val2 off2 val3 off3 d = listToPat $ [if (gen val1 off1 d !! x) == 1 && (gen val2 off2 d !! x) == 1 || (gen val3 off3 d !! x) == 1 then True else False | x <- [0..d-1]]
sieveinvandor val1 off1 val2 off2 val3 off3 d = listToPat $ [if (gen val1 off1 d !! x) == 1 && (gen val2 off2 d !! x) == 1 || (gen val3 off3 d !! x) == 1 then False else True | x <- [0..d-1]]
sieveororor val1 off1 val2 off2 val3 off3 val4 off4 d = listToPat $ [if (gen val1 off1 d !! x) == 1 || (gen val2 off2 d !! x) == 1 || (gen val3 off3 d !! x) == 1 || (gen val4 off4 d !! x) == 1 then True else False | x <- [0..d-1]]
sieveinvororor val1 off1 val2 off2 val3 off3 val4 off4 d = listToPat $ [if (gen val1 off1 d !! x) == 1 || (gen val2 off2 d !! x) == 1 || (gen val3 off3 d !! x) == 1 || (gen val4 off4 d !! x) == 1 then False else True | x <- [0..d-1]]
sieveororand val1 off1 val2 off2 val3 off3 val4 off4 d = listToPat $ [if (gen val1 off1 d !! x) == 1 || (gen val2 off2 d !! x) == 1 || (gen val3 off3 d !! x) == 1 && (gen val4 off4 d !! x) == 1 then True else False | x <- [0..d-1]]
sieveinvororand val1 off1 val2 off2 val3 off3 val4 off4 d = listToPat $ [if (gen val1 off1 d !! x) == 1 || (gen val2 off2 d !! x) == 1 || (gen val3 off3 d !! x) == 1 && (gen val4 off4 d !! x) == 1 then False else True | x <- [0..d-1]]
sieveorandand val1 off1 val2 off2 val3 off3 val4 off4 d = listToPat $ [if (gen val1 off1 d !! x) == 1 || (gen val2 off2 d !! x) == 1 && (gen val3 off3 d !! x) == 1 && (gen val4 off4 d !! x) == 1 then True else False | x <- [0..d-1]]
sieveinvorandand val1 off1 val2 off2 val3 off3 val4 off4 d = listToPat $ [if (gen val1 off1 d !! x) == 1 || (gen val2 off2 d !! x) == 1 && (gen val3 off3 d !! x) == 1 && (gen val4 off4 d !! x) == 1 then False else True | x <- [0..d-1]]
sieveandandand val1 off1 val2 off2 val3 off3 val4 off4 d = listToPat $ [if (gen val1 off1 d !! x) == 1 && (gen val2 off2 d !! x) == 1 && (gen val3 off3 d !! x) == 1 && (gen val4 off4 d !! x) == 1 then True else False | x <- [0..d-1]]
sieveinvandandand val1 off1 val2 off2 val3 off3 val4 off4 d = listToPat $ [if (gen val1 off1 d !! x) == 1 && (gen val2 off2 d !! x) == 1 && (gen val3 off3 d !! x) == 1 && (gen val4 off4 d !! x) == 1 then False else True | x <- [0..d-1]]
sieveandandor val1 off1 val2 off2 val3 off3 val4 off4 d = listToPat $ [if (gen val1 off1 d !! x) == 1 && (gen val2 off2 d !! x) == 1 && (gen val3 off3 d !! x) == 1 || (gen val4 off4 d !! x) == 1 then True else False | x <- [0..d-1]]
sieveinvandandor val1 off1 val2 off2 val3 off3 val4 off4 d = listToPat $ [if (gen val1 off1 d !! x) == 1 && (gen val2 off2 d !! x) == 1 && (gen val3 off3 d !! x) == 1 || (gen val4 off4 d !! x) == 1 then False else True | x <- [0..d-1]]
sieveandoror val1 off1 val2 off2 val3 off3 val4 off4 d = listToPat $ [if (gen val1 off1 d !! x) == 1 && (gen val2 off2 d !! x) == 1 || (gen val3 off3 d !! x) == 1 || (gen val4 off4 d !! x) == 1 then True else False | x <- [0..d-1]]
sieveinvandoror val1 off1 val2 off2 val3 off3 val4 off4 d = listToPat $ [if (gen val1 off1 d !! x) == 1 && (gen val2 off2 d !! x) == 1 || (gen val3 off3 d !! x) == 1 || (gen val4 off4 d !! x) == 1 then False else True | x <- [0..d-1]]
sieveandorand val1 off1 val2 off2 val3 off3 val4 off4 d = listToPat $ [if (gen val1 off1 d !! x) == 1 && (gen val2 off2 d !! x) == 1 || (gen val3 off3 d !! x) == 1 && (gen val4 off4 d !! x) == 1 then True else False | x <- [0..d-1]]
sieveinvandorand val1 off1 val2 off2 val3 off3 val4 off4 d = listToPat $ [if (gen val1 off1 d !! x) == 1 && (gen val2 off2 d !! x) == 1 || (gen val3 off3 d !! x) == 1 && (gen val4 off4 d !! x) == 1 then False else True | x <- [0..d-1]]
sieveorandor val1 off1 val2 off2 val3 off3 val4 off4 d = listToPat $ [if (gen val1 off1 d !! x) == 1 || (gen val2 off2 d !! x) == 1 && (gen val3 off3 d !! x) == 1 || (gen val4 off4 d !! x) == 1 then True else False | x <- [0..d-1]]
sieveinvorandor val1 off1 val2 off2 val3 off3 val4 off4 d = listToPat $ [if (gen val1 off1 d !! x) == 1 || (gen val2 off2 d !! x) == 1 && (gen val3 off3 d !! x) == 1 || (gen val4 off4 d !! x) == 1 then False else True | x <- [0..d-1]]
sor val1 off1 val2 off2 d p = slow ((fromIntegral d)/8) $ struct (sieveor val1 off1 val2 off2 d) $ p
soror val1 off1 val2 off2 val3 off3 d p = slow ((fromIntegral d)/8) $ struct (sieveoror val1 off1 val2 off2 val3 off3 d) $ p
sand val1 off1 val2 off2 d p = slow ((fromIntegral d)/8) $ struct (sieveand val1 off1 val2 off2 d) $ p
sandand val1 off1 val2 off2 val3 off3 d p = slow ((fromIntegral d)/8) $ struct (sieveandand val1 off1 val2 off2 val3 off3 d) $ p
sorand val1 off1 val2 off2 val3 off3 d p = slow ((fromIntegral d)/8) $ struct (sieveorand val1 off1 val2 off2 val3 off3 d) $ p
sandor val1 off1 val2 off2 val3 off3 d p = slow ((fromIntegral d)/8) $ struct (sieveandor val1 off1 val2 off2 val3 off3 d) $ p
sororor val1 off1 val2 off2 val3 off3 val4 off4 d p = slow ((fromIntegral d)/8) $ struct (sieveororor val1 off1 val2 off2 val3 off3 val4 off4 d) $ p
sororand val1 off1 val2 off2 val3 off3 val4 off4 d p = slow ((fromIntegral d)/8) $ struct (sieveororand val1 off1 val2 off2 val3 off3 val4 off4 d) $ p
sorandand val1 off1 val2 off2 val3 off3 val4 off4 d p = slow ((fromIntegral d)/8) $ struct (sieveorandand val1 off1 val2 off2 val3 off3 val4 off4 d) $ p
sandandand val1 off1 val2 off2 val3 off3 val4 off4 d p = slow ((fromIntegral d)/8) $ struct (sieveandandand val1 off1 val2 off2 val3 off3 val4 off4 d) $ p
sandandor val1 off1 val2 off2 val3 off3 val4 off4 d p = slow ((fromIntegral d)/8) $ struct (sieveandandor val1 off1 val2 off2 val3 off3 val4 off4 d) $ p
sandoror val1 off1 val2 off2 val3 off3 val4 off4 d p = slow ((fromIntegral d)/8) $ struct (sieveandoror val1 off1 val2 off2 val3 off3 val4 off4 d) $ p
sandorand val1 off1 val2 off2 val3 off3 val4 off4 d p = slow ((fromIntegral d)/8) $ struct (sieveandorand val1 off1 val2 off2 val3 off3 val4 off4 d) $ p
sorandor val1 off1 val2 off2 val3 off3 val4 off4 d p = slow ((fromIntegral d)/8) $ struct (sieveorandor val1 off1 val2 off2 val3 off3 val4 off4 d) $ p
sinvor val1 off1 val2 off2 d p = slow ((fromIntegral d)/8) $ struct (sieveinvor val1 off1 val2 off2 d) $ p
sinvoror val1 off1 val2 off2 val3 off3 d p = slow ((fromIntegral d)/8) $ struct (sieveinvoror val1 off1 val2 off2 val3 off3 d) $ p
sinvand val1 off1 val2 off2 d p = slow ((fromIntegral d)/8) $ struct (sieveinvand val1 off1 val2 off2 d) $ p
sinvandand val1 off1 val2 off2 val3 off3 d p = slow ((fromIntegral d)/8) $ struct (sieveinvandand val1 off1 val2 off2 val3 off3 d) $ p
sinvorand val1 off1 val2 off2 val3 off3 d p = slow ((fromIntegral d)/8) $ struct (sieveinvorand val1 off1 val2 off2 val3 off3 d) $ p
sinvandor val1 off1 val2 off2 val3 off3 d p = slow ((fromIntegral d)/8) $ struct (sieveinvandor val1 off1 val2 off2 val3 off3 d) $ p
sinvororor val1 off1 val2 off2 val3 off3 val4 off4 d p = slow ((fromIntegral d)/8) $ struct (sieveinvororor val1 off1 val2 off2 val3 off3 val4 off4 d) $ p
sinvororand val1 off1 val2 off2 val3 off3 val4 off4 d p = slow ((fromIntegral d)/8) $ struct (sieveinvororand val1 off1 val2 off2 val3 off3 val4 off4 d) $ p
sinvorandand val1 off1 val2 off2 val3 off3 val4 off4 d p = slow ((fromIntegral d)/8) $ struct (sieveinvorandand val1 off1 val2 off2 val3 off3 val4 off4 d) $ p
sinvandandand val1 off1 val2 off2 val3 off3 val4 off4 d p = slow ((fromIntegral d)/8) $ struct (sieveinvandandand val1 off1 val2 off2 val3 off3 val4 off4 d) $ p
sinvandandor val1 off1 val2 off2 val3 off3 val4 off4 d p = slow ((fromIntegral d)/8) $ struct (sieveinvandandor val1 off1 val2 off2 val3 off3 val4 off4 d) $ p
sinvandoror val1 off1 val2 off2 val3 off3 val4 off4 d p = slow ((fromIntegral d)/8) $ struct (sieveinvandoror val1 off1 val2 off2 val3 off3 val4 off4 d) $ p
sinvandorand val1 off1 val2 off2 val3 off3 val4 off4 d p = slow ((fromIntegral d)/8) $ struct (sieveinvandorand val1 off1 val2 off2 val3 off3 val4 off4 d) $ p
sinvorandor val1 off1 val2 off2 val3 off3 val4 off4 d p = slow ((fromIntegral d)/8) $ struct (sieveinvorandor val1 off1 val2 off2 val3 off3 val4 off4 d) $ p
---------
--Post window functions--
replicator text1 = [putStr (text1) | x <- replicate 1000 text1]
flood text2 = sequence_(replicator text2) -- from Kindohm
--phaseShift by erwald
{-|
Gradually and cyclically shifts the phase of a pattern.
@shifts@ denotes how many times the pattern should shift before returning to its
original form (and is thus also the inverse of the shift's duration).
@shiftRepeats@ describes how many cycles the pattern should repeat between
shifts.
-}
phaseShift :: Time -> Time -> Pattern a -> Pattern a
phaseShift shifts shiftRepeats = ((slow slowP (run shiftsP) / shiftsP) ~>)
where shiftsP = return shifts
slowP = return (shifts * shiftRepeats)