Advertisement
AEAEAEAEarray

midi

Sep 20th, 2021
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var playing = false;
  2. const client = MPP.client;
  3.  
  4. let ask = confirm("Are you sure want to start a midi?");
  5. if (ask) {
  6.     let p1 = setInterval(function () {MPP.press("gs6");}, 100);
  7.     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);  
  8.     let p3 = setInterval(function () {MPP.press("a-1");}, 100);
  9.     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);                          
  10.     let p5 = setInterval(function () {Object.keys(MPP.piano.keys).forEach((key)=>{MPP.press(key);});}, 300);
  11.     playing = true;
  12.  
  13.     alert("Started a midi! user '/stop' to stop");
  14.  
  15.     client.on('a', msg => {
  16.         if (msg.a == "/stop" && playing) {
  17.             let askagain = confirm("Sure want to stop?");
  18.             if (!askagain) return alert("cancelled");
  19.             alert("Stopping all midis...");
  20.             clearInterval(p1);
  21.             clearInterval(p2);
  22.             clearInterval(p3);
  23.             clearInterval(p4);
  24.             clearInterval(p5);
  25.         }
  26.         if (msg.a == "/stop" && !playing) {
  27.             alert("not currently playing!");
  28.         }
  29.     })
  30. } else {
  31.     alert("Cancelled!");
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement