Scet SuperCollider Egg Timer



An interval timing tool for disciplined live-coding (or boiling eggs)

Scet closes on CmdPeriod


Class methods


*new(times, loop)


a = Scet.new([1, 2])

times are an unsorted array of arrays or numbers. 

Each time element is in the form: mins, [mins, secs] 

or [hrs, mins, secs]. The above indicates two sections, 

the second beginning after 1 minute and ending after two minutes.

For a single duration, the time can sit outside of an aray.

a = Scet.new(3) // For boiling an egg

loop is Boolean, looping is an optional argument and false by default.

a = Scet.new([[0, 30], [0, 25]], true)

 

One second before the end of a section, the GUI flashes.


*closeAll

closes all open Scets

The following instance methods can be used via the GUI or code


Instance methods


play

play or resume the timer


pause

pause the timer

displays the elapsed time where the (section) name is otherwise displayed

stop

stop the timer. The left display shows the elapsed time,

the right the elapsed time including pauses (if any).


close

close the GUI (if the timer is still running, best to first stop it.)

t  - GUI button 

toggle_(bool)  - code setter method

toggle the display (false by default).

The default display counts down the remaining time for the current section,

the slider shows the remaining time for the sum of all sections

The toggled display shows the elapsed time (including looped time if any)

the slider shows the elapsed time for the current section.

names_(array)


Names are an array of strings.

The default is "Part 1, Part 2 ... Part n"

a = Scet.new([[0, 30], [0, 25]]).names_(["start", "alert"])


sound(status, s, tck, mel, amp)

It is your responsibility to ensure the server is booted

when using the sound method.

status is Boolean and turns sound on / off, default is off

s is a server

tck is a tick every n time (in the array format as above), default is false

melody replaces the tick with a short melody, default is false

amp is the amplitude of the sound, default is  0.3

Two short ascending runs give 1 seconds warning of a new section;

a longer descending run ends the egg timer playback cycle.


Sound examples

a = Scet.new([[0, 12], [0, 18]], true)

s.boot

a.sound(true, s, [0, 2])

a.sound(true, s)

a.play

a.sound(false)

a.close


(

a = Scet.new([[0, 4], [0, 8]], true)

.sound(true, s, [0, 1], true)

.play

)

a.stop

a.close


Wake me up in the morning with a 20 min lie-in please

s.boot

(

a = Scet.new([[8, 20, 0], [8, 0, 0]])

.names_(["sleep", "wake"])

.sound(true, s, amp: 0.7)

.play

)


setColor(color)

changes the background GUI colour

winOnTop(bool)

the default is true


winBounds_(posW, posH)

set the position of the GUI

expects values between 0 and 1

default it top right (1, 1)


winBounds

get the position of the GUI


Autopilot example

(

// Create three random partitions of 15 seconds

var b, a;

b = 15.partition(parts: 3, min: 3).integrate;

b = b.collect{|i| i.secs2time};

b.postln;

a = Scet.new(b);

r{ 2.wait; 

3.do{|i| 

if (i%2==1, {

a.pause; 

}, {

a.play

}); 

a.setColor; // random

a.winBounds_(1.0.rand, 1.0.rand);

rrand(4, 6).wait;

};

3.wait;

a.stop;

3.wait;

a.close;

}.play;

)