Hi there, is it possible to have a variable (that controls a value of line in Pen) to be defined by the sound, like a visualizer does? I know there is Amplitude to follow the sound but I do not know how to put its values into the animation. I am interested for the ~z variable below.
the code:
(
var w,v;
var run = true;
var partial=2000;
///////0/////////////////////////////////////////////////////////////////////////////////////////////////
Window.closeAll;
w = Window("S",Rect( 600,100,2000,1000),scroll:false).front.alwaysOnTop_(true);
w.alpha = 1; w.view.background = Color.black;
//~slider1= Slider(w,Rect(500,940,850,10)).action_({ arg obj; ~z = obj.value.linlin(0,1,1,3600); ~v.refresh;});
//~slider2= Slider(w,Rect(500,950,850,10)).action_({ arg obj; ~y = obj.value.linlin(0,1,1,360); ~v.refresh;});
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////view
~v = UserView.new(w,Rect(50,100,1800,800)).background_(Color.black);
~v.drawFunc ={
Pen.translate(900,400);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////lines
(partial).do{
~z=400;
~x=~z.cos; ~y=~z.sin;
~k=Polar.new(~z,~y*pi).asPoint;~v.refresh;
~a=Polar.new(~z,~x*pi).asPoint;~v.refresh;
Pen.width=0.1;
Color(red:1,green:1,blue:1,alpha:1).set;
Pen.line(~k,~a);Pen.stroke;~v.refresh;
// Pen.line(~a,Polar.new(~z,~y).asPoint);Pen.stroke;~v.refresh;
Pen.rotate(pi/(partial/2));Pen.stroke;~v.refresh;
};
////////////////////////////////////////////////////////////////////////////////
};
{ while { run } {~v.background_(Color.black); ~v.refresh; (1/10).wait } }.fork(AppClock);
//~v.background_(Color.black);~v.refresh;
)