2
2
--
3
3
-- llllllll.co/t/forestscapes
4
4
--
5
- -- pseudo-ambisonics of
5
+ -- pseudo-ambisonics of
6
6
-- field recordings.
7
7
--
8
8
9
9
tree_ = include (" lib/tree" )
10
- engine .name = " Forestscapes1"
11
- player = {}
10
+ engine .name = " Forestscapes1"
11
+ player = {}
12
12
13
- function init ()
14
- print (" starting" )
15
-
16
- params :set (" reverb" ,2 )
17
- params :set (" rev_eng_input" ,0 )
18
- params :set (" rev_return_level" ,0 )
19
- params :set (" rev_low_time" ,9 )
20
- params :set (" rev_mid_time" ,6 )
21
- tree = tree_ :new {x = 120 ,y = 64 ,age = math.random (70 ,100 )/ 100 }
13
+ function init ()
14
+ print (" starting" )
15
+
16
+ params :set (" reverb" ,2 )
17
+ params :set (" rev_eng_input" ,0 )
18
+ params :set (" rev_return_level" ,0 )
19
+ params :set (" rev_low_time" ,9 )
20
+ params :set (" rev_mid_time" ,6 )
21
+ tree = tree_ :new {x = 120 ,y = 64 ,age = math.random (70 ,100 )/ 100 }
22
22
23
23
-- setup osc
24
24
osc_fun = {
@@ -27,30 +27,30 @@ function init()
27
27
rerun ()
28
28
end ,
29
29
lr = function (args )
30
- if player [tonumber (args [1 ])]== nil then
31
- player [tonumber (args [1 ])]= {lr = 0 ,fb = 0 ,amp = 0 }
32
- end
33
- player [tonumber (args [1 ])].lr = tonumber (args [2 ])
30
+ if player [tonumber (args [1 ])]== nil then
31
+ player [tonumber (args [1 ])]= {lr = 0 ,fb = 0 ,amp = 0 }
32
+ end
33
+ player [tonumber (args [1 ])].lr = tonumber (args [2 ])
34
34
end ,
35
35
fb = function (args )
36
- if player [tonumber (args [1 ])]== nil then
37
- player [tonumber (args [1 ])]= {lr = 0 ,fb = 0 ,amp = 0 }
38
- end
39
- player [tonumber (args [1 ])].fb = tonumber (args [2 ])
36
+ if player [tonumber (args [1 ])]== nil then
37
+ player [tonumber (args [1 ])]= {lr = 0 ,fb = 0 ,amp = 0 }
38
+ end
39
+ player [tonumber (args [1 ])].fb = tonumber (args [2 ])
40
40
end ,
41
41
on = function (args )
42
- if player [tonumber (args [1 ])]== nil then
43
- player [tonumber (args [1 ])]= {lr = 0 ,fb = 0 ,amp = 0 }
44
- end
45
- print (" on" )
46
- tab .print (args )
47
- player [tonumber (args [1 ])].on = tonumber (args [2 ])== 1
42
+ if player [tonumber (args [1 ])]== nil then
43
+ player [tonumber (args [1 ])]= {lr = 0 ,fb = 0 ,amp = 0 }
44
+ end
45
+ print (" on" )
46
+ tab .print (args )
47
+ player [tonumber (args [1 ])].on = tonumber (args [2 ])== 1
48
48
end ,
49
49
amp = function (args )
50
- if player [tonumber (args [1 ])]== nil then
51
- player [tonumber (args [1 ])]= {lr = 0 ,fb = 0 ,amp = 0 }
52
- end
53
- player [tonumber (args [1 ])].amp = tonumber (args [2 ])
50
+ if player [tonumber (args [1 ])]== nil then
51
+ player [tonumber (args [1 ])]= {lr = 0 ,fb = 0 ,amp = 0 }
52
+ end
53
+ player [tonumber (args [1 ])].amp = tonumber (args [2 ])
54
54
end ,
55
55
}
56
56
osc .event = function (path ,args ,from )
@@ -62,72 +62,72 @@ function init()
62
62
end
63
63
end
64
64
65
- -- local params_menu={
66
- -- }
67
- -- for i=1,4 do
68
- -- table.insert(params_menu,{id="mod"..i,name="mod"..i,modi=i,min=-1,max=1,exp=false,div=0.1,default=0,unit="db"})
69
- -- end
70
- -- for _,pram in ipairs(params_menu) do
71
- -- params:add{
72
- -- type="control",
73
- -- id=pram.id,
74
- -- name=pram.name,
75
- -- controlspec=controlspec.new(pram.min,pram.max,pram.exp and "exp" or "lin",pram.div,pram.default,pram.unit or "",pram.div/(pram.max-pram.min)),
76
- -- formatter=pram.formatter,
77
- -- }
78
- -- params:set_action(pram.id,function(x)
79
- -- if pram.modi~=nil then
80
- -- mod[pram.modi]=x
81
- -- end
82
- -- end)
83
- -- end
65
+ -- local params_menu={
66
+ -- }
67
+ -- for i=1,4 do
68
+ -- table.insert(params_menu,{id="mod"..i,name="mod"..i,modi=i,min=-1,max=1,exp=false,div=0.1,default=0,unit="db"})
69
+ -- end
70
+ -- for _,pram in ipairs(params_menu) do
71
+ -- params:add{
72
+ -- type="control",
73
+ -- id=pram.id,
74
+ -- name=pram.name,
75
+ -- controlspec=controlspec.new(pram.min,pram.max,pram.exp and "exp" or "lin",pram.div,pram.default,pram.unit or "",pram.div/(pram.max-pram.min)),
76
+ -- formatter=pram.formatter,
77
+ -- }
78
+ -- params:set_action(pram.id,function(x)
79
+ -- if pram.modi~=nil then
80
+ -- mod[pram.modi]=x
81
+ -- end
82
+ -- end)
83
+ -- end
84
84
85
- clock .run (function ()
86
- while true do
87
- clock .sleep (1 / 10 )
88
- redraw ()
89
- end
90
- end )
91
- engine .sound_delta (_path .code .. " forestscapes/sounds/field/" ,2 )
85
+ clock .run (function ()
86
+ while true do
87
+ clock .sleep (1 / 10 )
88
+ redraw ()
89
+ end
90
+ end )
91
+ engine .sound_delta (_path .code .. " forestscapes/sounds/field/" ,2 )
92
92
end
93
93
94
94
function key (k ,z )
95
- if z == 1 and k > 1 then
96
- engine .sound_delta (_path .code .. " forestscapes/sounds/field/" ,k == 2 and - 1 or 1 )
97
- end
95
+ if z == 1 and k > 1 then
96
+ engine .sound_delta (_path .code .. " forestscapes/sounds/field/" ,k == 2 and- 1 or 1 )
97
+ end
98
98
end
99
99
100
100
function enc (k ,d )
101
101
end
102
102
103
103
function redraw ()
104
- screen .clear ()
105
- screen .blend_mode (12 )
104
+ screen .clear ()
105
+ screen .blend_mode (12 )
106
106
107
- tree :redraw ()
107
+ tree :redraw ()
108
108
109
- local points = {}
110
- for k ,v in pairs (player ) do
111
- x = util .linlin (- 1 ,1 ,0 ,128 ,v .lr )
112
- y = util .linlin (- 1 ,1 ,0 ,64 ,v .fb )
113
- r = util .linlin (0 ,1 ,3 ,16 ,v .amp )
114
- l = util .linlin (0 ,1 ,15 ,1 ,v .amp )
115
- table.insert (points ,{x = x ,y = y ,r = r ,used = false ,l = util .round (l ),on = v .on })
116
- end
117
- for _ , point in ipairs (points ) do
118
- if point .on == true then
119
- screen .level (point .l )
120
- screen .circle (point .x ,point .y ,point .r )
121
- screen .fill ()
122
- end
109
+ local points = {}
110
+ for k ,v in pairs (player ) do
111
+ x = util .linlin (- 1 ,1 ,0 ,128 ,v .lr )
112
+ y = util .linlin (- 1 ,1 ,0 ,64 ,v .fb )
113
+ r = util .linlin (0 ,1 ,3 ,16 ,v .amp )
114
+ l = util .linlin (0 ,1 ,15 ,1 ,v .amp )
115
+ table.insert (points ,{x = x ,y = y ,r = r ,used = false ,l = util .round (l ),on = v .on })
116
+ end
117
+ for _ ,point in ipairs (points ) do
118
+ if point .on == true then
119
+ screen .level (point .l )
120
+ screen .circle (point .x ,point .y ,point .r )
121
+ screen .fill ()
123
122
end
124
- screen .update ()
123
+ end
124
+ screen .update ()
125
125
end
126
126
127
127
128
128
function distance (p1 ,p2 )
129
- local dx = p1 .x - p2 .x
130
- local dy = p1 .y - p2 .y
131
- return math.sqrt ( dx * dx + dy * dy )
129
+ local dx = p1 .x - p2 .x
130
+ local dy = p1 .y - p2 .y
131
+ return math.sqrt (dx * dx + dy * dy )
132
132
end
133
133
0 commit comments