Created
June 29, 2015 19:26
-
-
Save thormagnusson/ee21f017ef34cabb4b1d to your computer and use it in GitHub Desktop.
Recording, saving and reloading slider values
This file contains 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
( | |
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