Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 28 additions & 43 deletions src/assets/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,65 +482,50 @@ function updateThemeIcon(theme) {
/**
* 5. EASTER EGG LOGIC & TRIGGERS
*/
window.playForceSoundtrack = function (duration = 8000) {
function playForceSoundtrack(duration = 8000) {
initAudio();
if (!audioCtx) return;

const now = audioCtx.currentTime;
const seconds = duration / 1000;

// Master compressor: gentle settings to avoid pumping/crackle
// 1. Create a Master Compressor to prevent distortion
const compressor = audioCtx.createDynamicsCompressor();
compressor.threshold.setValueAtTime(-24, now);
compressor.knee.setValueAtTime(30, now);
compressor.ratio.setValueAtTime(4, now);
compressor.attack.setValueAtTime(0.01, now);
compressor.release.setValueAtTime(0.25, now);
compressor.threshold.setValueAtTime(-24, audioCtx.currentTime);
compressor.knee.setValueAtTime(40, audioCtx.currentTime);
compressor.ratio.setValueAtTime(12, audioCtx.currentTime);
compressor.attack.setValueAtTime(0, audioCtx.currentTime);
compressor.release.setValueAtTime(0.25, audioCtx.currentTime);
compressor.connect(audioCtx.destination);

// Lowpass filter: removes harsh high frequencies
const filter = audioCtx.createBiquadFilter();
filter.type = "lowpass";
filter.frequency.setValueAtTime(2000, now);
filter.connect(compressor);

// Master volume: smooth swell in and fade out
const now = audioCtx.currentTime;
const masterGain = audioCtx.createGain();
masterGain.connect(filter);
masterGain.gain.setValueAtTime(0.0001, now);
masterGain.gain.linearRampToValueAtTime(0.5, now + 1.5);
masterGain.gain.setValueAtTime(0.5, now + seconds - 2);
masterGain.gain.exponentialRampToValueAtTime(0.001, now + seconds);

// Harmonic stack: each oscillator has its own small gain so the sum never clips
const layers = [
{ freq: 110, type: "triangle", level: 0.4 },
{ freq: 220, type: "triangle", level: 0.3 },
{ freq: 330, type: "sine", level: 0.3 },
];
masterGain.connect(compressor);

layers.forEach(({ freq, type, level }, i) => {
const osc = audioCtx.createOscillator();
const oscGain = audioCtx.createGain();
// Smooth volume swell
masterGain.gain.setValueAtTime(0, now);
masterGain.gain.linearRampToValueAtTime(0.6, now + 1.5);
masterGain.gain.setValueAtTime(0.6, now + duration / 1000 - 2);
masterGain.gain.exponentialRampToValueAtTime(0.001, now + duration / 1000);

osc.type = type;
// Create the "Harmonic Stack" (Multiple notes for a rich sound)
[55, 110, 164.81].forEach((freq, i) => {
const osc = audioCtx.createOscillator();
osc.type = i === 0 ? "sawtooth" : "triangle"; // Mix textures
osc.frequency.setValueAtTime(freq, now);
osc.detune.setValueAtTime(i * 5, now); // slight wobble
oscGain.gain.setValueAtTime(level, now);

osc.connect(oscGain);
oscGain.connect(masterGain);
// Add a slight "wobble" (detune) for realism
osc.detune.setValueAtTime(i * 5, now);

osc.connect(masterGain);
osc.start(now);
osc.stop(now + seconds);
osc.stop(now + duration / 1000);
});
};
}
Comment thread
jbampton marked this conversation as resolved.
Resolved

window.triggerForceSurge = function () {
function triggerForceSurge() {
if (isSurging) return;
isSurging = true;

// 1. Audio
window.playForceSoundtrack(8000);
playForceSoundtrack(8000);

// 2. Add Overlay
const overlay = document.createElement("div");
Expand Down Expand Up @@ -573,7 +558,7 @@ window.triggerForceSurge = function () {
flash.remove();
isSurging = false;
}, 8000);
};
}

// biome-ignore lint/correctness/noUnusedVariables: Used outside this classic script.
function triggerMagicXP() {
Expand Down Expand Up @@ -1412,7 +1397,7 @@ function handleFooterDotClick() {
// 3. Update the global unlockedEggs array
if (!unlockedEggs.includes("secret_footer_surge")) {
// Trigger the main function
window.triggerForceSurge();
triggerForceSurge();

unlockedEggs.push("secret_footer_surge");
localStorage.setItem("unlockedEggs", JSON.stringify(unlockedEggs));
Expand Down
Loading