Hi Mark,
not shure if I got you right, but the following might be what zou
want to see. Though it is a little more stable it still slows down
drastically after the 230th iteration. Anyhow it might help you.
Sincerely,
Bjoern
(
//dummy data set
a=Array.fill(500, {rrand(350, 500)});
~thusFar=Array.new;
~timeIncrement=0.05;
~time = 0;
SynthDef("sinetest", {arg freq=440, dur=0.3;
o=PanAz.ar(2, SinOsc.ar(freq, 0, 0.2));
e=Env.sine(dur);
Out.ar(0, o*(EnvGen.kr(e, doneAction:2)));
}).send(s);
w = GUI.window.new( "plot the dummy", Rect( 128, 64, 340, 400 ));
~playbutton=GUI.button.new(w, Rect(10, 23, 100, 50));
~playbutton.states=[ ["play", Color.blue,
Color.new255(204,206,226) ] ];
~playbutton.action = { ~testTask.start(AppClock); };
~stopbutton=GUI.button.new(w, Rect(150, 24, 100, 50));
~stopbutton.states=[ ["stop/reset", Color.blue,
Color.new255(204,206,226) ] ];
~stopbutton.action = { ~testTask.stop; ~time = 0; ~timeArray =
Array.new;
a=Array.fill(500, {rrand(350, 500)}); ~thusFar=Array.new };
~plotWindow=GUI.envelopeView.new(w,Rect(10,75,300,300));
w.front;
~timeArray = Array.new;
~testTask = Task({
a.size.do({ arg i;
i.postln;
f=a.at(i);
s.sendMsg("/s_new", "sinetest", s.nextNodeID, 0, 0,
"freq", f,
"dur", ~timeIncrement);
~thusFar = ~thusFar.add(f);
~timeArray = ~timeArray.add( ~time );
~plotWindow.drawLines_( true ).thumbSize_( 0 )
.value_([ ~timeArray.normalize, ~thusFar.normalize ]);
//~thusFar.asArray.plot(parent:~plotWindow);
~time = ~time + ~timeIncrement;
~timeIncrement.wait;
})
});
)
--- Mark Ballora <ballora@xxxxxxx> schrieb am Mi, 3.12.2008:
Von: Mark Ballora <ballora@xxxxxxx>
Betreff: [sc-users] timing problems when a Task plays and plots
An: sc-users@xxxxxxxxxxxxxxxx
Datum: Mittwoch, 3. Dezember 2008, 3:45
SC folks --
I'm attempting to sonify a data set while plotting it
in a GUI window.
The methodology is:
o Use a Task to iterate through the set, mapping its values
appropriately.
o Create an empty List; with each iteration, add the
current data value to the List, then plot the List as an
Array into a compositeView.
(I couldn't find a way to add a point to a pre-existing
view, thus I take the inelegant step of re-plotting the
ever-growing List as an Array with each iteration.)
I find that after about 90 iterations, the timing slows
down considerably, despite the wait time in the Task.
Is there a better way to do this that anyone knows of?
Here's a code example:
s=Server.local;
s.boot
(
//dummy data set
a=Array.fill(500, {rrand(350, 500)});
~thusFar=List.new;
~timeIncrement=0.05;
SynthDef("sinetest", {arg freq=440, dur=0.3;
o=PanAz.ar(2, SinOsc.ar(freq, 0, 0.2));
e=Env.sine(dur);
Out.ar(0, o*(EnvGen.kr(e, doneAction:2)));
}).send(s);
w = GUI.window.new( "plot the dummy", Rect( 128,
64, 340, 400 ));
~playbutton=GUI.button.new(w, Rect(10, 23, 100, 50));
~playbutton.states=[ ["play", Color.blue,
Color.new255(204,206,226) ] ];
~playbutton.action = { ~testTask.start(AppClock); };
~stopbutton=GUI.button.new(w, Rect(150, 24, 100, 50));
~stopbutton.states=[ ["stop/reset", Color.blue,
Color.new255(204,206,226) ] ];
~stopbutton.action = { ~testTask.stop; };
~plotWindow=GUI.compositeView.new(w,Rect(10,75,300,300));
w.front;
~testTask = Task({
a.size.do({ arg i;
i.postln;
> f=a.at(i);
s.sendMsg("/s_new", "sinetest",
s.nextNodeID, 0, 0,
"freq", f,
"dur", ~timeIncrement);
~thusFar.add(f);
~thusFar.asArray.plot(parent:~plotWindow);
~timeIncrement.wait;
})
});
)
TIA --
Mark
_______________________________________________
sc-users mailing list
info (subscription, etc.):
http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search:
https://listarc.bham.ac.uk/lists/sc-users/search/
_______________________________________________
sc-users mailing list
info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/