WIP: The MuSiCaL Update #1

Draft
unfunny wants to merge 27 commits from music into master
Showing only changes of commit 47f38e587c - Show all commits

View File

@@ -1,38 +1,33 @@
//Based off of the one found at not_found.html but randomizes the songs
let song = "/Music/noway.mid"
//for checkaudio() but if it's called recursively this won't be defined so one defining here later it should be fine
let consecutivefails = 0;
function SongRNG() {
//this is actually code from minima and its absolutely NOT made for this BUT WHO CARES????
//some refactoring done by Gemini
//@ts-check
console.log("yo whatap")
console.log("picking a song...")
let min = 0
let max = 13
let scarynumber = Math.random() * (max - min + 1) + min;
let randint = Math.round(scarynumber)
//funni.mid is uhh- 24 hour cinderella
let lines = ["AnotherMedium-Updated.mid", "CORE_.mid", "Death_by_Glamour.mid", "maniaStudiopolisZoneAct1.mid", "maniaStudiopolisZoneAct2.mid", "mk7_select_menu.mid", "Mpntbgm1.mid", "MPntBgk2.mid", "portal.mid", "rhythmheaven4thmix.mid", "SmashMenu.mid", "funni.mid", "utruins.mid"]
let lines = ["AnotherMedium-Updated.mid", "CORE_.mid", "Death_by_Glamour.mid", "maniaStudiopolisZoneAct1.mid", "maniaStudiopolisZoneAct2.mid", "mk7_select_menu.mid", "Mpntbgm1.mid", "MPntBgk2.mid", "portal.mid", "SmashMenu.mid", "funni.mid", "utruins.mid"]
let max = lines.length - 1;
// Generate a random integer between 0 and max (inclusive)
let randint = Math.floor(Math.random() * (max + 1));
console.log("random number:", randint)
//32 lines randomly picked, probably will sometimes return "undefined". i don't feel like fixing it.
//32 lines is a lie. just read the "max" variable plus one for rounding errors. If you can't tell i never update these comments (but hey, at least when someone accuses me of being AI i have... whatever the hell this is )
console.log("today's track:", lines[randint])
if (randint > max) {
console.warn("song doesn't exist. you know what that means...")
//window.open("/not_found.html");
//btw the not found page plays noway.mid
//ik it would be funny as hell but lets actually NOT send the user to nomans land because of MY bug
//doesn't mean they're off the hook though
song = "/Music/noway.mid"
//YEAH, THAT'S MORE LIKE IT!!
} else {
song = "/Music/bgm/" + lines[randint]
}
song = "/Music/bgm/" + lines[randint]
//window.addEventListener('DOMContentLoaded', newLine);
}
//could be useful
function getSongTitle() {
console.log("song info for", randint)
let titles = ["Another Medium", "CORE", "Death by Glamour", "Studiopolis Act 1 (Lights, Camera, Action!)", "Studiopolis Act 2", "Select a kart", "Creative Exersise", "Monkeys", "Still Alive", "Remix 4", "Main Menu", "24 Hour Cinderella", "The Ruins"]
let games = ["Undertale", "Undertale", "Undertale", "Sonic Mania", "Sonic Mania", "Mario Kart 7", "Mario Paint", "Mario Paint", "Portal", "Rhythm Heaven DS", "SSB Wii U/3DS", "Yakuza", "Undertale"]
let titles = ["Another Medium", "CORE", "Death by Glamour", "Studiopolis Act 1 (Lights, Camera, Action!)", "Studiopolis Act 2", "Select a kart", "Creative Exersise", "Monkeys", "Still Alive", "Main Menu", "24 Hour Cinderella", "The Ruins"]
let games = ["Undertale", "Undertale", "Undertale", "Sonic Mania", "Sonic Mania", "Mario Kart 7", "Mario Paint", "Mario Paint", "Portal", "SSB Wii U/3DS", "Yakuza", "Undertale"]
console.log(titles[randint], "from ", games[randint])
//if for some reason randint is undefined.. this just completly breaks. unfortunately for you purists this stuff's unused atp so it's NEVER getting fixed AHAHHAAHHAH
}
//ok, now we actually do stuff
@@ -63,7 +58,17 @@ if (isplaying == "false") {
console.log("music do be the playing")
} else if (isplaying == "idk") {
console.warn("idk if there be music")
console.log("showing error anyways")
document.getElementById("autoplay").innerHTML = "<p>Music is playing, but your autoplay is turned off.</p><noscript>JS is off, MIDIjs won't be able to play audio anyways.</noscript> <button onclick=MIDIjs.play(song, true)>Play Music</button>"
//This used to just show the error anyway but i'm tired of it showing randomly so it's going to re-test now
console.log("gonna check midijs again, attempt number:", consecutivefails + 1)
consecutivefails++;
if (consecutivefails >= 2) {
console.log("afaik music is infact, not playing")
document.getElementById("autoplay").innerHTML = "<p>Music is playing, but your autoplay is turned off.</p><noscript>JS is off, MIDIjs won't be able to play audio anyways.</noscript> <button onclick=MIDIjs.play(song, true)>Play Music</button>"
} else { setTimeout(function(){
checkAudio()
}, 5000) }
}
}
}
function testchkaudio(isplaying) {
checkAudio()
}