Created
April 7, 2012 14:36
-
-
Save fjolnir/2329407 to your computer and use it in GitHub Desktop.
Harmonograph to music
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scene:clear() | |
count = 8000 | |
scene.clearColor = rgb(0,0,0) | |
p1=buildParticles(count) | |
local x,y,Ax,wx,px,As,ws,ps,Ay,wy,py | |
Ax = 300.4 | |
wx = 390.4 | |
px = 123.9 | |
Ay = 390.9 | |
wy = 250.1 | |
py = 200.4 | |
As = 60.9 | |
ws = 130.2 | |
ps = 300.8 | |
d = 0.99 | |
local function A(Aarg,t) | |
return Aarg*(t-1)*(1-d) | |
end | |
audio:setSmoothingFactor(0.9) | |
everyFrame(function() | |
withPrimitive(p1, function() | |
rotate(0.03, vec3(0,1,0)) | |
wx = audio:mag(2)*1000 | |
px = px +0.08 | |
ps = 20*audio:mag(8) | |
py = time()/10 | |
wy = 200*audio:mag(4) | |
p1:map(function(i,v) | |
t = i/count | |
x = A(Ax,t) * sin(wx*t+px) + A(As,t)*sin(ws*t+ps) | |
y = A(Ay,t) * sin(wy*t+py) | |
z = A(Ay,t) * A(Ax,t)*sin(wy*t+ps) | |
v.position = vec3(x, y, z) | |
v.size=1 | |
v.color = rgb(1,1,1,0.2)--rgb(0, 0, 0, 0.8)--rgb(sin(y),cos(x),sin(y)) | |
end) | |
end) | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment