-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
41 lines (33 loc) · 788 Bytes
/
main.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
"use strict"
import * as Orgel from "./orgel.js"
function playTrack(sheet) {
let text = "";
sheet.split('\n').forEach((line)=>{
if (text.length) {
text += ' ';
} text += line;
});
text = text.trim();
let tones = []
text.split(' ').forEach((data)=>{
let octave, note, startAt, duration;
[octave, note, startAt, duration] = data.split(',');
if (!octave) {
debugger;
return;
}
tones.push(new Orgel.Tone(+octave, note, +startAt, +duration));
});
Orgel.playTones(tones);
}
function play() {
stop();
playTrack(document.querySelector('#track1').value);
playTrack(document.querySelector('#track2').value);
}
function stop() {
Orgel.stop();
}
Orgel.setup();
document.querySelector("#play").onclick = play;
document.querySelector("#stop").onclick = stop;