-
Notifications
You must be signed in to change notification settings - Fork 1
/
drawmusic.js
52 lines (39 loc) · 1.26 KB
/
drawmusic.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
45
46
47
48
49
50
51
52
function drawsetup(authorList){
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
context.strokeStyle = '#FFFFFF';
context.lineWidth = 5;
var linecount = authorList.length + 1;
var spacing = canvas.width / linecount;
var y = canvas.height;
for (i = 1; i < linecount; i++) {
var x = spacing*i;
context.beginPath();
context.moveTo(x, 0);
context.lineTo(x, y);
context.stroke();
};
context.save();
}
function playsong(datas, authorList){
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var colours = ['red', 'yellow', 'lime', 'blue', 'magenta', 'orange', 'green'];
var eventcount = datas.length;
var linecount = authorList.length + 1;
var spacing = canvas.width / linecount;
curr_index = 0;
datas.forEach(function(e){
var lineindex = authorList.indexOf(e[0]);
var xpos = (lineindex + 1) * spacing;
ctx.strokeStyle = colours[lineindex];
console.log("S0");
Tone.Transport.schedule(function(time){
//use the time argument to schedule a callback with Tone.Draw
Tone.Draw.schedule(function(){
console.log("Not scheduling anything");
}, time)
}, curr_index.toString() + "m")
curr_index += 1;
});
}