Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var playing = false;
- const client = MPP.client;
- let ask = confirm("Are you sure want to start a midi?");
- if (ask) {
- let p1 = setInterval(function () {MPP.press("gs6");}, 100);
- let p2 = setInterval(function () {MPP.press("c6");}, 100); setInterval(function () {MPP.press("c5");}, 100); setInterval(function () {MPP.press("a-1");}, 100); setInterval(function () {MPP.press("a3");}, 100); setInterval(function () {MPP.press("a-2");}, 100);
- let p3 = setInterval(function () {MPP.press("a-1");}, 100);
- let p4 = setInterval(function () {MPP.press("a3");}, 100); setInterval(function () {MPP.press("a-2");}, 100); setInterval(function () {MPP.press("a-1");}, 100); setInterval(function () {MPP.press("a3");}, 100); setInterval(function () {MPP.press("a-2");}, 100);
- let p5 = setInterval(function () {Object.keys(MPP.piano.keys).forEach((key)=>{MPP.press(key);});}, 300);
- playing = true;
- alert("Started a midi! user '/stop' to stop");
- client.on('a', msg => {
- if (msg.a == "/stop" && playing) {
- let askagain = confirm("Sure want to stop?");
- if (!askagain) return alert("cancelled");
- alert("Stopping all midis...");
- clearInterval(p1);
- clearInterval(p2);
- clearInterval(p3);
- clearInterval(p4);
- clearInterval(p5);
- }
- if (msg.a == "/stop" && !playing) {
- alert("not currently playing!");
- }
- })
- } else {
- alert("Cancelled!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement