Skip to content

Commit 2aa0432

Browse files
committed
formatting
1 parent 184bca3 commit 2aa0432

File tree

4 files changed

+135
-135
lines changed

4 files changed

+135
-135
lines changed

fields.lua

+80-80
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
--
33
-- llllllll.co/t/forestscapes
44
--
5-
-- pseudo-ambisonics of
5+
-- pseudo-ambisonics of
66
-- field recordings.
77
--
88

99
tree_=include("lib/tree")
10-
engine.name = "Forestscapes1"
11-
player = {}
10+
engine.name="Forestscapes1"
11+
player={}
1212

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}
2222

2323
-- setup osc
2424
osc_fun={
@@ -27,30 +27,30 @@ function init()
2727
rerun()
2828
end,
2929
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])
3434
end,
3535
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])
4040
end,
4141
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
4848
end,
4949
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])
5454
end,
5555
}
5656
osc.event=function(path,args,from)
@@ -62,72 +62,72 @@ function init()
6262
end
6363
end
6464

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
8484

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)
9292
end
9393

9494
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
9898
end
9999

100100
function enc(k,d)
101101
end
102102

103103
function redraw()
104-
screen.clear()
105-
screen.blend_mode(12)
104+
screen.clear()
105+
screen.blend_mode(12)
106106

107-
tree:redraw()
107+
tree:redraw()
108108

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()
123122
end
124-
screen.update()
123+
end
124+
screen.update()
125125
end
126126

127127

128128
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)
132132
end
133133

grains.lua

+10-10
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,26 @@ player={}
1616

1717
function init()
1818
--os.execute(_path.code.."forestscapes/lib/oscnotify/run.sh &")
19-
params:set("reverb",2)
20-
params:set("rev_eng_input",0)
21-
params:set("rev_return_level",0)
22-
params:set("rev_low_time",9)
23-
params:set("rev_mid_time",6)
19+
params:set("reverb",2)
20+
params:set("rev_eng_input",0)
21+
params:set("rev_return_level",0)
22+
params:set("rev_low_time",9)
23+
params:set("rev_mid_time",6)
2424

2525

26-
tree = tree_:new{x=64,y=64,age=math.random(80,100)/100}
26+
tree=tree_:new{x=64,y=64,age=math.random(80,100)/100}
2727
player={}
2828
for i=1,total_num do
2929
table.insert(player,player_:new{id=i})
3030
end
3131

3232

33-
params:add_file("fileload", "load file", _path.code.."forestscapes/sounds/field")
33+
params:add_file("fileload","load file",_path.code.."forestscapes/sounds/field")
3434
params:set_action("fileload",function(x)
35-
if (string.find(x,".ogg") or string.find(x,".wav")) then
35+
if (string.find(x,".ogg") or string.find(x,".wav")) then
3636
engine.load_tape(1,x)
3737
end
38-
end)
38+
end)
3939

4040
local params_menu={
4141
{id="db",name="volume",min=-96,max=12,exp=false,div=0.1,default=-6,unit="db"},
@@ -54,7 +54,7 @@ function init()
5454
}
5555
params:set_action(pram.id,function(x)
5656
engine.setp(pram.id,x)
57-
end)
57+
end)
5858
end
5959

6060
params:bang()

lib/player.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ function Player:init()
1818
end
1919

2020
function Player:redraw()
21-
if self.wait>0 then
22-
self.wait = self.wait - 1
23-
do return end
21+
if self.wait>0 then
22+
self.wait=self.wait-1
23+
do return end
2424
end
2525
local spacing=4
2626
local height=64/total_num

lib/tree.lua

+42-42
Original file line numberDiff line numberDiff line change
@@ -23,68 +23,68 @@ function Tree:init()
2323
end
2424

2525
function Tree:branches(a,b,len,ang,dir,count)
26-
local period=math.random(5,20)
27-
local offset=math.random(5,20)
28-
local angle=27*math.pi/180*(util.linlin(-1,1,0.75,1.25,math.sin(clock.get_beat_sec()*clock.get_beats()/period+offset)))
29-
len=len*util.linlin(0,1,0.55,0.68,self.age)
30-
if count>8 then return end
31-
if len<3 then return end
32-
if dir>0 then ang=ang-angle
33-
else ang=ang+angle
34-
end
35-
local vx,vy=self:rotate(0,len,ang)
36-
vx=a+vx;vy=b-vy
37-
math.randomseed(len)
38-
if count<=2 then
39-
screen.line_width(3)
40-
elseif count <=4 then
41-
screen.line_width(2)
42-
else
43-
screen.line_width(1)
44-
end
45-
self:line(a,b,vx,vy,util.round(self.color))
46-
self:branches(vx,vy,len+math.random()*2,ang,1,count+1)
47-
self:branches(vx,vy,len+math.random()*2,ang,0,count+1)
26+
local period=math.random(5,20)
27+
local offset=math.random(5,20)
28+
local angle=27*math.pi/180*(util.linlin(-1,1,0.75,1.25,math.sin(clock.get_beat_sec()*clock.get_beats()/period+offset)))
29+
len=len*util.linlin(0,1,0.55,0.68,self.age)
30+
if count>8 then return end
31+
if len<3 then return end
32+
if dir>0 then ang=ang-angle
33+
else ang=ang+angle
4834
end
49-
35+
local vx,vy=self:rotate(0,len,ang)
36+
vx=a+vx;vy=b-vy
37+
math.randomseed(len)
38+
if count<=2 then
39+
screen.line_width(3)
40+
elseif count<=4 then
41+
screen.line_width(2)
42+
else
43+
screen.line_width(1)
44+
end
45+
self:line(a,b,vx,vy,util.round(self.color))
46+
self:branches(vx,vy,len+math.random()*2,ang,1,count+1)
47+
self:branches(vx,vy,len+math.random()*2,ang,0,count+1)
48+
end
49+
5050
function Tree:rotate(x,y,a)
5151
local s,c=math.sin(a),math.cos(a)
5252
local a,b=x*c-y*s,x*s+y*c
5353
return a,b
5454
end
5555

5656
function Tree:redraw()
57-
if not self.active and self.color==0 then
58-
do return end
57+
if not self.active and self.color==0 then
58+
do return end
5959
end
60-
if not self.active and self.color>0 then
60+
if not self.active and self.color>0 then
6161
self.color=self.color-0.5
6262
end
63-
if self.active and self.color<self.coloring then
64-
self.color=self.color + 0.25
63+
if self.active and self.color<self.coloring then
64+
self.color=self.color+0.25
6565
self.ll=util.round(self.color)
6666
end
6767

68-
local wid=self.x
69-
local hei=self.y
70-
local a,b=wid/2,hei-5
71-
local ll=util.round(self.color)
72-
screen.line_width(4)
73-
self:line(wid/2,hei,a,b,self.color)
74-
math.randomseed(self.randseed)
75-
self:branches(a,b,util.linlin(-1,1,5,30,self.branchl)+math.random()*10,0,0,2,math.floor(util.linlin(-1,1,1,self.ll,self.branchl)))
76-
self:branches(a,b,util.linlin(-1,1,5,30,self.branchr)+math.random()*10,0,1,2,math.floor(util.linlin(-1,1,1,self.ll,self.branchr)))
68+
local wid=self.x
69+
local hei=self.y
70+
local a,b=wid/2,hei-5
71+
local ll=util.round(self.color)
72+
screen.line_width(4)
73+
self:line(wid/2,hei,a,b,self.color)
74+
math.randomseed(self.randseed)
75+
self:branches(a,b,util.linlin(-1,1,5,30,self.branchl)+math.random()*10,0,0,2,math.floor(util.linlin(-1,1,1,self.ll,self.branchl)))
76+
self:branches(a,b,util.linlin(-1,1,5,30,self.branchr)+math.random()*10,0,1,2,math.floor(util.linlin(-1,1,1,self.ll,self.branchr)))
7777
end
7878

7979
function Tree:line(x1,y1,x2,y2,level)
80-
screen.level(util.round(level))
81-
screen.move(x1,y1)
82-
screen.line(x2,y2)
83-
screen.stroke()
80+
screen.level(util.round(level))
81+
screen.move(x1,y1)
82+
screen.line(x2,y2)
83+
screen.stroke()
8484
end
8585

8686
function Tree:activate(yes)
87-
self.active=yes
87+
self.active=yes
8888
end
8989

9090

0 commit comments

Comments
 (0)