Skip to content

Instantly share code, notes, and snippets.

@thormagnusson
Created June 29, 2015 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thormagnusson/ee21f017ef34cabb4b1d to your computer and use it in GitHub Desktop.
Save thormagnusson/ee21f017ef34cabb4b1d to your computer and use it in GitHub Desktop.
Recording, saving and reloading slider values
(
a = [];
t = Main.elapsedTime;
w = Window.new.front;
r = Slider(w, Rect(100, 140, 200, 20))
.action_({ arg sl;
a = a.add([Main.elapsedTime-t, sl.value*1000]);
});
)
b
f = File.new("myFile.txt", "w");
f.write(a.asCompileString)
f.close
z = a.collect({arg array; array[1]}); // turn it into value only
z.plot
(
x = File("myFile.txt", "r");
g = x.readAllString;
y = g.interpret;
t = 0;
{
y.do({arg timeval;
timeval[1].postln;
{r.value = timeval[1]/1000}.defer;
(timeval[0]-t).wait;
t = timeval[0];
})}.fork;
)
// another option
a.writeArchive("myFile")
b = Object.readArchive("myFile")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment