Last active
May 21, 2021 20:03
-
-
Save Jack5079/3df00dcca6922444ade43bfbd39d1d69 to your computer and use it in GitHub Desktop.
Shared Piano destroyer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const notes = [...document.querySelector('piano-keyboard').shadowRoot.querySelectorAll('piano-keyboard-octave')].map(oct=>oct.shadowRoot.querySelectorAll('piano-keyboard-note')).map((a)=>Array.from(a)).flat() | |
| async function trollar () { | |
| for (const note of notes.filter((_,e)=>e%2==0)) { | |
| note.clicked = true | |
| } | |
| await new Promise(r=>setTimeout(r,5)) | |
| for (const note of notes.filter((_,e)=>e%2==0)) { | |
| note.clicked = false | |
| note.release() | |
| } | |
| for (const note of notes.filter((_,e)=>e%2!=0)) { | |
| note.clicked = true | |
| } | |
| await new Promise(r=>setTimeout(r,5)) | |
| for (const note of notes.filter((_,e)=>e%2!=0)) { | |
| note.clicked = false | |
| note.release() | |
| } | |
| trollar() | |
| } | |
| trollar() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const selector = document.querySelector('piano-instrument-selector') | |
| const notes = [...document.querySelector('piano-keyboard').shadowRoot.querySelectorAll('piano-keyboard-octave')].map(oct=>oct.shadowRoot.querySelectorAll('piano-keyboard-note')).map((a)=>Array.from(a)).flat() | |
| async function trollar () { | |
| for (const note of notes) { | |
| note.clicked = true | |
| await new Promise(r=>setTimeout(r,5)) | |
| } | |
| for (const note of notes) { | |
| note.clicked = false | |
| note.release() | |
| } | |
| for (const note of notes.reverse()) { | |
| note.clicked = true | |
| await new Promise(r=>setTimeout(r,5)) | |
| } | |
| for (const note of notes.reverse()) { | |
| note.clicked = false | |
| note.release() | |
| } | |
| trollar() | |
| } | |
| trollar() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Test it: https://musiclab.chromeexperiments.com/Shared-Piano/#a | |
| const notes = [...document.querySelector('piano-keyboard').shadowRoot.querySelectorAll('piano-keyboard-octave')].map(oct=>oct.shadowRoot.querySelectorAll('piano-keyboard-note')).map((a)=>Array.from(a)).flat() | |
| setInterval(()=>{ | |
| notes.forEach(note=>(note.clicked=true)) | |
| setTimeout(()=>notes.forEach(note=>{note.clicked=false;note.release()}), 10) | |
| }, 20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment