I’m working on an generative installation that will be shown in the public space. The piece unfolds over 13 hours, from morning to night. I wander how to automate the starting of the generative composition, everyday at the same time (the installation will be shown for one month in june).
Get the code so that you can load the whole piece by executing one file. (This file may load other files – see “path-to-file.scd”.load.) You should not have to run several blocks – just one block, complete contents of the main file.
Then try it from the command line with sclang main-file.scd. In Windows you might need to cd to the SC directory in Program Files first. Mac would be sclang main-file.scd; Windows, sclang.exe main-file.scd. You might need a full path to the scd script.
Then, make a script (Mac) or batch (Win) file so that you just run this file to launch sclang with your code.
Then, add the script as a system startup item.
The devil is in the details, but that’s the outline.
Though, if you would rather do this entirely in sclang, you can… just make sure your code is executed whenever the system boots up:
(
// this will run your code at 7am:
var hour = 07;
var minute = 00;
// set this to false if you don't want your code to run if you execute
// sometime in the day after your scheduled start time:
var armed = true;
fork {
loop {
var d = Date.getDate;
var fired = false;
if ((d.hour < hour) or: ((d.hour == hour) and: (d.minute < minute))) {
armed = true;
};
if ((d.hour == hour) and: (d.minute == minute)) {
fired = true;
armed = false;
};
if (armed) {
if ((d.hour > hour) or: ((d.hour == hour) and: (d.minute > minute))) {
fired = true;
armed = false;
}
};
if (fired) {
("This function will execute once a day at " ++ hour ++ ":" ++ minute).postln;
};
60.wait;
};
}
)
It appears that this quark implements the skipjack class… which would have been my next suggestion.
After creating your daytimer instance, you can run .skip on your day-timer object in order to gain access to any of the methods defined by the implementing class… along with those defined explicitly in the extension.