-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
46 lines (38 loc) · 834 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
var colors = require('colors'),
baudio = require('baudio');
program = require('commander');
program
.parse(process.argv);
var startTime;
function start() {
startTime = new Date().getTime();
process.stdout.write('pomodoro'.red);
}
start();
function check() {
var dur = new Date().getTime() - startTime ;
return (dur > 1000 * 60 * 25);
}
var interval;
interval = setInterval(function() {
if(check()) {
clearInterval(interval);
ding();
process.stdout.write(' complete'.green);
}
}, 1000);
function ding() {
var dur = 3;
var b = baudio({
rate: 11250
}, function(t) {
return Math.sin(t * 1500) * Math.max(3 - t, 0) / 3;
});
b.addChannel(function(t) {
return Math.sin(t * 1900) * Math.max(3 - t, 0) / 3;
});
b.play();
setTimeout(function() {
process.exit();
}, 2500);
}