-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path3-cut.lua
84 lines (73 loc) · 1.69 KB
/
3-cut.lua
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
-- softcut study 3: cut
--
-- E2 fade time
-- E3 metro time (random cut)
file = _path.dust.."/code/softcut-studies/lib/whirl1.aif"
fade_time = 0.01
metro_time = 1.0
positions = {0,0,0,0}
m = metro.init()
m.time = metro_time
m.event = function()
for i=1,4 do
softcut.position(i,1+math.random(8)*0.25)
end
end
function update_positions(i,pos)
positions[i] = pos - 1
redraw()
end
function init()
softcut.buffer_clear()
softcut.buffer_read_mono(file,0,1,-1,1,1)
for i=1,4 do
softcut.enable(i,1)
softcut.buffer(i,1)
softcut.level(i,1.0)
softcut.pan(i,(i-2.5)*0.5)
softcut.rate(i,i*0.25)
softcut.loop(i,1)
softcut.loop_start(i,1)
softcut.loop_end(i,3)
softcut.position(i,1)
softcut.play(i,1)
softcut.fade_time(i,fade_time)
softcut.phase_quant(i,0.125)
end
softcut.event_phase(update_positions)
softcut.poll_start_phase()
m:start()
end
function enc(n,d)
if n==2 then
fade_time = util.clamp(fade_time+d/100,0,1)
for i=1,4 do
softcut.fade_time(i,fade_time)
end
elseif n==3 then
metro_time = util.clamp(metro_time+d/8,0.125,4)
m.time = metro_time
end
redraw()
end
function redraw()
screen.clear()
screen.move(10,20)
screen.line_rel(positions[1]*8,0)
screen.move(40,20)
screen.line_rel(positions[2]*8,0)
screen.move(70,20)
screen.line_rel(positions[3]*8,0)
screen.move(100,20)
screen.line_rel(positions[4]*8,0)
screen.stroke()
screen.move(10,40)
screen.text("fade time:")
screen.move(118,40)
screen.text_right(string.format("%.2f",fade_time))
screen.move(10,50)
screen.text("metro time:")
screen.move(118,50)
screen.text_right(string.format("%.2f",metro_time))
screen.update()
end