History keeps a history of interpreted lines of code
History keeps track of all code lines that are being executed, in order to forward them to other players, to easily reuse earlier versions, or to store and reproduce a performance. Since it records everything that is interpreted, there is only one instance of History.
(adc 2006)
*start / *stop start/stop adding interpreted code to history
*clear remove all items from history
*enter(obj) add an entry by hand
*document post the history in a new document
*drop(n) drop the newest n lines from history. if n is negative, drop the oldest n lines
*keep(n) keep only the newest n lines from history. if n is negative, keep the oldest n lines
*saveCS(path, forward)
store the history as one compileString
*saveStory(path) store in a file, in historical order as individual code snippets
// example
History.start;
a = { |freq=440| SinOsc.ar(freq, 0, 0.2) }.play;
a.set(\freq, 450);
a.free;
History.document; // create a document with all the changes
History.makeWin; // gui window
History.stop; // stop collecting
// removing and adding lines
History.enter("2 + 2"); // make a simple entry by hand.
History.drop(-1); // drop the oldest memory
History.drop(1); // drop the newest memory
// more examples
History.start;
1 + 2; // code line gets stored
(nil + 2).postln; // error lines are ignored
// comment-only is kept, empty lines not:
s.boot; // do some things
p = ProxySpace.push;
(
~test = { Blip.ar(50 * [1, 1.02], 8) * 0.1 };
~test.playN;
)
~test = { Blip.ar(LFNoise1.kr(3 ! 2, 200, 500), 4) * 0.1 };
~test = { Blip.ar(LFNoise1.kr(3 ! 2, 200, 500), LFNoise1.kr(5 ! 2, 5, 8)) * 0.1 };
~test.vol_(0.1);
~test.stop;
~test.clear;
History.document;
History.removeAt(0); // clear last line
History.removeAt((0..3)); // clear last 4 lines
History.postDoc(0); // post most recent line
History.postDoc(4); // go back 4 lines
History.keep(4); // keep newest 4
History.stop;
History.saveCS; // save as compilestring for reloading.
History.saveCS("~/Desktop/testHist.txt", forward: true);
// save with special name, in forward time order.
History.saveStory; // write all to file in historical order
History.saveStory("~/Desktop/myTest.sc"); // ... with given filename.
History.clear; // start over with a clean slate.
// To Do:
// History Reloaded - from a saved file:
// History.loadCS("~/Desktop/testHist.sc");
// auto-save by appending to a file ...
// History.autoSave_(true);
// save as one runnable task/script.
// History.saveScript;
// History.saveScript("~/Desktop/histScript.sc"); // with given filename.