Created
June 19, 2024 15:15
-
-
Save bryanbraun/035a93a01cd9a14b9dc26513a78fe1b6 to your computer and use it in GitHub Desktop.
musicbox.fun console hack
This file contains 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
// Run me in the developer console at https://musicbox.fun | |
let startTime = performance.now(); | |
let wave = (x, elapsedTime) => (80 * Math.sin((x - (elapsedTime*4)) / 3)); | |
function loop() { | |
let elapsedTimeSeconds = (performance.now() - (startTime / 10)) / 1000; | |
let waveVals = []; | |
for (let i=0; i < 15; i++) { | |
waveVals.push(wave(i, elapsedTimeSeconds) + 100); | |
} | |
MusicBoxFun.store.setState('songState.songData', { | |
"C4": [waveVals[0]], | |
"D4": [waveVals[1]], | |
"E4": [waveVals[2]], | |
"F4": [waveVals[3]], | |
"G4": [waveVals[4]], | |
"A4": [waveVals[5]], | |
"B4": [waveVals[6]], | |
"C5": [waveVals[7]], | |
"D5": [waveVals[8]], | |
"E5": [waveVals[9]], | |
"F5": [waveVals[10]], | |
"G5": [waveVals[11]], | |
"A5": [waveVals[12]], | |
"B5": [waveVals[13]], | |
"C6": [waveVals[14]], | |
}); | |
setTimeout(loop, 20); | |
} | |
loop(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment